diff options
author | trystan trystan@31f1291d-b8d6-0310-a050-a5561fc1590b <trystan trystan@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2005-02-06 19:18:15 +0000 |
---|---|---|
committer | trystan trystan@31f1291d-b8d6-0310-a050-a5561fc1590b <trystan trystan@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2005-02-06 19:18:15 +0000 |
commit | 9b3a357193a020c53624b29f84e0bca4795722f0 (patch) | |
tree | be1a500c8a469dad8164a72d1266780ac8c28510 | |
parent | f8ac398b86ea6a26dba62064d9810796466e4118 (diff) |
BUILD : 1.7.8 (565) BUGS : 293 NOTES : Merge of Win32 branch into the main, support for Unreal +I, German language updated, fixed bug vidents not updating, Setting and Removal of sqlines on forbid or drop
git-svn-id: svn://svn.anope.org/anope/trunk@567 31f1291d-b8d6-0310-a050-a5561fc1590b
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@417 5417fbe8-f217-4b02-8779-1006273d7864
57 files changed, 2186 insertions, 256 deletions
@@ -1,10 +1,20 @@ Anope Version S V N ------------------- Provided by Anope Dev. <dev@anope.org> - 2005 +02/05 A Support for Unreal 3.2 +I channel mode. [ #00] +02/03 A Merged anope-win32 branch into the main, now Win32 ready [ #00] +02/05 F Change Ident function did not update the vident [#293] 01/30 F ChanServ help to reflect the avaiable commands. [ #00] 01/30 F ChanServ still used some commands that were not valid on all ircd [ #00] 01/30 F Compiling modules under Mac OSX. [#285] +Provided by crazytoon <da.crew@gmx.net> - 2005 +02/05 A Updated German language file [ #00] + +Provided by BarkerJr <barkerjr@barkerjr.net> - 2005 +02/05 A Setting and Removal of SQLINEs on forbid of Channels and Nicks [ #00] + + Anope Version 1.7.8 ------------------- Provided by Anope Dev. <dev@anope.org> - 2005 diff --git a/docs/WIN32.txt b/docs/WIN32.txt new file mode 100644 index 000000000..21adb7e41 --- /dev/null +++ b/docs/WIN32.txt @@ -0,0 +1,149 @@ +Anope for Windows + +1. Building the source +2. Installation +3. Compiling modules +4. Credits + +========================================================================= += 1. Building from the ground up = +========================================================================= + + If you want to build Anope on the Win32 system you will need to obtain +the following items. + +1. Download the files required + +- Current Anope source: + http://zero.org:7467/viewcvs/trunk.tar.gz + +If you have Visual C++ 6, 7 or .NET skip ahead to step 2, else download +the following free components from Microsoft. Once downloaded install these packages + +- VCToolKit: + http://download.microsoft.com/download/3/9/b/39bac755-0a1e-4d0b-b72c-3a158b7444c4/VCToolkitSetup.exe + +- .NET Framework 1.1 Redistributable: + http://download.microsoft.com/download/a/a/c/aac39226-8825-44ce-90e3-bf8203e74006/dotnetfx.exe + +- .NET Framework SDK 1.1: + http://download.microsoft.com/download/5/2/0/5202f918-306e-426d-9637-d7ee26fbe507/setup.exe + +- Core SDK for the needed libraries: + http://www.microsoft.com/msdownload/platformsdk/sdkupdate/ + +- MySQL for Windows - needed if building for mysql + http://www.mysql.com + + +2. Unpack the Anope tarball with your favorite uncompression program (winzip or winrar) + +3. Open Makefile.inc.win32 in the main directory with a text editor (notepad or notepad clones) + + A. change the line "IRCD=" to match the ircd that you want to build, and place that number + after the = so if your building Unreal 3.2 (#10), you would change the line to read + "IRCD=10" + + B. If you are building for MySQL change USE_MYSQL to equal 1 (ie.. USE_MYSQL=1), the next + two lines you must enter the path to the MySQL installation. MYSQL_INC, and MYSQL_LIB, + You can define the path one of two ways, either with \ or / if you use \ you must add + a secondary \ so c:\mysql would be c:\\mysql + + C. To use Anope build in Proxy scan you can change PROXY_SCANNER to be equal to 1 + (ie.. PROXY_SCANNER=1), note the proxy scan is not the best and its recommended to use + another thrid party scanner. + + D. If you are using Visual Studio 6, this next line can be very important. If you are an + error during compile about "unresolved external symbol __ftol2", remove the # in front + of VC6=/QIfist and attempt to compile again. + + E. When compiling if you get an error about 'Cannot find wsock32.lib' or 'Cannot find + msvcrt.lib' You need to define the libpath, in the LIBPATH directive. You can define + the path one of two ways, either with \ or / if you use \ you must add a secondary \ + so c:\mysql would be c:\\sdk\lib be sure to remove the # in front of LFLAGS + + F. Most import is to set the DATDEST to be the folder name where data will be stored. + This does not need to be the full path just the folder under the main executable + in which data will exist. In our example we will use "data" + +4. You are now ready to compile, bring up the Visual C++ toolkit command prompt, this + will launch a dos command prompt like window, which will set the enviroment properties + need to make Anope. Change directories to where you unpacked the source code in step 2. + At the prompt type + + nmake -f Makefile.win32 + + Once you are back at the command prompt again, if there have been no + errors, you are ready to go, should you encounter errors check how to adjust + the makefile.inc.win32 to help resolve the issue. + +5. Anope will install the files where the belong. The only thing you need to do + is rename "data/example.conf" to be "services.conf" + +You have now complete the building phase of Anope for Windows. Move to the +section related to setting up Anope. + +========================================================================= += 2. Installation = +========================================================================= + + Since Anope for Windows does not use a visual interface, you must do +the configuration before getting to far into this. + +Open services.conf, and make the following edits + +A. RemoteServer : this is the address to your ircd, along with the port + and password. You should consult your ircd documentation + on how to link ircds. +B. ServicesRoot : Remove the # and change the names to your nick so you + can take control of services once they are online. + +If you are unsure of the settings, You can go to the dos command prompt +and run "anope.exe -nofork -debug" and watch the information as it +attempts to connect. + +To launch services you can do it one of two ways, if you are sure that the +configuration information is correct, simply double clicking on it will +cause it to start, no window will come up. You can start at the dos prompt +and type in "anope.exe" if services are successful in starting up +the dos prompt will seem to hang, at this point you can close the dos +window + +========================================================================= += 3. Compiling Modules = +========================================================================= + + If you want to build other modules. You will need to modify the +Makefile.inc.win32 + + A. When compiling if you get an error about 'Cannot find wsock32.lib' + or 'Cannot find msvcrt.lib' You need to define the libpath, in the + LIBPATH directive. You can define the path one of two ways, either + with \ or / if you use \ you must add a secondary \ so c:\mysql + would be c:\\sdk\lib be sure to remove the # in front of LFLAGS + + B. Add modules fine the line of "SRCS=" add the name of the file to + the end of the line. So if you have two files + + "SRCS=file.c file2.c" + +When that is done, use the same command prompt you set up in Part 1, +change directores to the src/modules folder and type + +nmake -f Makefile.win32 + +Copy the *.dll files that get created to the "data/modules/runtime" +folder. + +========================================================================= += 4. Credits = +========================================================================= + + Anope is based on the code of Epona and IRCServices see README for +full list of developers. + + Anope Winodws code is provided by + + Dominick Meglio <codemastr@unrealircd.com> + Trystan Scott Lee <trystan@nomadirc.net> + Chris Hogben <heinz@anope.org>
\ No newline at end of file diff --git a/include/commands.h b/include/commands.h index 703842690..ec08a44a9 100644 --- a/include/commands.h +++ b/include/commands.h @@ -27,8 +27,8 @@ extern void help_cmd(char *service, User *u, Command *list, char *name); extern void do_run_cmd(char *service, User * u, Command *c,const char *cmd); extern void do_help_cmd(char *service, User * u, Command *c,const char *cmd); -extern void mod_help_cmd(char *service, User *u, CommandHash *cmdTable[],const char *cmd); -extern void mod_run_cmd(char *service, User *u, CommandHash *cmdTable[],const char *cmd); +extern MDE void mod_help_cmd(char *service, User *u, CommandHash *cmdTable[],const char *cmd); +extern MDE void mod_run_cmd(char *service, User *u, CommandHash *cmdTable[],const char *cmd); extern char *mod_current_module_name; /*************************************************************************/ diff --git a/include/datafiles.h b/include/datafiles.h index 32f168ca1..e25b3416a 100644 --- a/include/datafiles.h +++ b/include/datafiles.h @@ -15,7 +15,9 @@ #ifndef DATAFILES_H #define DATAFILES_H +#ifndef _WIN32 #include <sys/param.h> +#endif /*************************************************************************/ diff --git a/include/extern.h b/include/extern.h index 410236363..40e275da2 100644 --- a/include/extern.h +++ b/include/extern.h @@ -17,7 +17,15 @@ #include "slist.h" +#ifndef _WIN32 #define E extern +#else +#ifndef MODULE_COMPILE +#define E extern __declspec(dllexport) +#else +#define E extern __declspec(dllimport) +#endif +#endif E char *uplink; @@ -200,7 +208,9 @@ E char *strerror(int errnum); #if !HAVE_STRSIGNAL char *strsignal(int signum); #endif - +#ifdef _WIN32 +char *sockstrerror(int error); +#endif /**** config.c ****/ @@ -660,7 +670,7 @@ E int process_numlist(const char *numstr, int *count_ret, range_callback_t callback, User * u, ...); E int isValidHost(const char *host, int type); -E int isvalidchar(char c); +E int isvalidchar(const char c); E char *myStrGetToken(const char *str, const char dilim, int token_number); E char *myStrGetOnlyToken(const char *str, const char dilim, @@ -877,14 +887,14 @@ E int32 total_read, total_written; E int32 read_buffer_len(void); E int32 write_buffer_len(void); -E int sgetc(int s); -E char *sgets(char *buf, int len, int s); -E char *sgets2(char *buf, int len, int s); -E int sread(int s, char *buf, int len); -E int sputs(char *str, int s); -E int sockprintf(int s, char *fmt, ...); +E int sgetc(ano_socket_t s); +E char *sgets(char *buf, int len, ano_socket_t s); +E char *sgets2(char *buf, int len, ano_socket_t s); +E int sread(ano_socket_t s, char *buf, int len); +E int sputs(char *str, ano_socket_t s); +E int sockprintf(ano_socket_t s, char *fmt, ...); E int conn(const char *host, int port, const char *lhost, int lport); -E void disconn(int s); +E void disconn(ano_socket_t s); /**** users.c ****/ diff --git a/include/makefile.win32 b/include/makefile.win32 new file mode 100644 index 000000000..b186c578c --- /dev/null +++ b/include/makefile.win32 @@ -0,0 +1,25 @@ +# Make file for Win32 +# +# (C) 2003-2005 Anope Team +# Contact us at info@anope.org +# +# Please read COPYING and README for further details. +# +# Based on the original code of Epona by Lara. +# Based on the original code of Services by Andy Church. +# +# $Id:$ +# + +########################################################################### + +clean: + -@erase language.h + +spotless: clean + -@erase sysconf.h version.h + +distclean: spotless + + +FRC: diff --git a/include/modules.h b/include/modules.h index 2a3025586..91bdb7a88 100644 --- a/include/modules.h +++ b/include/modules.h @@ -18,6 +18,34 @@ #include "services.h" #include <stdio.h> +/* Cross OS compatibility macros */ +#ifdef _WIN32 +typedef HMODULE ano_module_t; + +#define ano_modopen(file) LoadLibrary(file) +/* ano_moderr in modules.c */ +#define ano_modsym(file, symbol) (void *)GetProcAddress(file, symbol) +#define ano_modclose(file) FreeLibrary(file) ? 0 : 1 +#define ano_modclearerr() SetLastError(0) +#define MODULE_EXT ".dll" + +#else +typedef void * ano_module_t; + +#ifdef HAS_RTLD_LOCAL +#define ano_modopen(file) dlopen(file, RTLD_LAZY|RTLD_LOCAL) +#else +#define ano_modopen(file) dlopen(file, RTLD_LAZY) +#endif +#define ano_moderr() dlerror() +#define ano_modsym(file, symbol) dlsym(file, DL_PREFIX symbol) +#define ano_modclose(file) dlclose(file) +#define ano_modclearerr() errno = 0 +#define MODULE_EXT ".so" + +#endif + + /*************************************************************************/ #define CMD_HASH(x) (((x)[0]&31)<<5 | ((x)[1]&31)) /* Will gen a hash from a string :) */ #define MAX_CMD_HASH 1024 @@ -53,7 +81,18 @@ #define MOD_ERR_NOSERVICE 12 #define MOD_ERR_NO_MOD_NAME 13 - /*************************************************************************/ +/*************************************************************************/ +/* Macros to export the Module API functions/variables */ +#ifndef _WIN32 +#define MDE +#else +#ifndef MODULE_COMPILE +#define MDE __declspec(dllexport) +#else +#define MDE __declspec(dllimport) +#endif +#endif +/*************************************************************************/ /* Structure for information about a *Serv command. */ @@ -66,14 +105,14 @@ typedef struct MessageHash_ MessageHash; typedef struct ModuleCallBack_ ModuleCallBack; -extern CommandHash *HOSTSERV[MAX_CMD_HASH]; -extern CommandHash *BOTSERV[MAX_CMD_HASH]; -extern CommandHash *MEMOSERV[MAX_CMD_HASH]; -extern CommandHash *NICKSERV[MAX_CMD_HASH]; -extern CommandHash *CHANSERV[MAX_CMD_HASH]; -extern CommandHash *HELPSERV[MAX_CMD_HASH]; -extern CommandHash *OPERSERV[MAX_CMD_HASH]; -extern MessageHash *IRCD[MAX_CMD_HASH]; +extern MDE CommandHash *HOSTSERV[MAX_CMD_HASH]; +extern MDE CommandHash *BOTSERV[MAX_CMD_HASH]; +extern MDE CommandHash *MEMOSERV[MAX_CMD_HASH]; +extern MDE CommandHash *NICKSERV[MAX_CMD_HASH]; +extern MDE CommandHash *CHANSERV[MAX_CMD_HASH]; +extern MDE CommandHash *HELPSERV[MAX_CMD_HASH]; +extern MDE CommandHash *OPERSERV[MAX_CMD_HASH]; +extern MDE MessageHash *IRCD[MAX_CMD_HASH]; struct Module_ { char *name; @@ -173,62 +212,62 @@ Module *findModule(char *name); /* Find a module */ int loadModule(Module *m,User *u); /* Load the given module into the program */ int unloadModule(Module *m, User *u); /* Unload the given module from the pro */ int prepForUnload(Module *m); /* Prepare the module for unload */ -void moduleAddVersion(char *version); -void moduleAddAuthor(char *author); +MDE void moduleAddVersion(char *version); +MDE void moduleAddAuthor(char *author); void modules_init(void); void modules_delayed_init(void); void moduleCallBackPrepForUnload(char *mod_name); -void moduleCallBackDeleteEntry(ModuleCallBack * prev); -char *moduleGetLastBuffer(void); -void moduleSetHelpHelp(void (*func) (User * u)); -void moduleDisplayHelp(int service, User *u); -void moduleSetHostHelp(void (*func) (User * u)); -void moduleSetOperHelp(void (*func) (User * u)); -void moduleSetBotHelp(void (*func) (User * u)); -void moduleSetMemoHelp(void (*func) (User * u)); -void moduleSetChanHelp(void (*func) (User * u)); -void moduleSetNickHelp(void (*func) (User * u)); -int moduleAddHelp(Command * c, int (*func) (User * u)); -int moduleAddRegHelp(Command * c, int (*func) (User * u)); -int moduleAddOperHelp(Command * c, int (*func) (User * u)); -int moduleAddAdminHelp(Command * c, int (*func) (User * u)); -int moduleAddRootHelp(Command * c, int (*func) (User * u)); +MDE void moduleCallBackDeleteEntry(ModuleCallBack * prev); +MDE char *moduleGetLastBuffer(void); +MDE void moduleSetHelpHelp(void (*func) (User * u)); +MDE void moduleDisplayHelp(int service, User *u); +MDE void moduleSetHostHelp(void (*func) (User * u)); +MDE void moduleSetOperHelp(void (*func) (User * u)); +MDE void moduleSetBotHelp(void (*func) (User * u)); +MDE void moduleSetMemoHelp(void (*func) (User * u)); +MDE void moduleSetChanHelp(void (*func) (User * u)); +MDE void moduleSetNickHelp(void (*func) (User * u)); +MDE int moduleAddHelp(Command * c, int (*func) (User * u)); +MDE int moduleAddRegHelp(Command * c, int (*func) (User * u)); +MDE int moduleAddOperHelp(Command * c, int (*func) (User * u)); +MDE int moduleAddAdminHelp(Command * c, int (*func) (User * u)); +MDE int moduleAddRootHelp(Command * c, int (*func) (User * u)); /*************************************************************************/ /*************************************************************************/ /* Command Managment Functions */ -Command *createCommand(const char *name,int (*func)(User *u),int (*has_priv)(User *u),int help_all, int help_reg, int help_oper, int help_admin,int help_root); -int destroyCommand(Command *c); /* destroy a command */ -int addCoreCommand(CommandHash *cmdTable[], Command *c); /* Add a command to a command table */ -int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos); -int addCommand(CommandHash *cmdTable[], Command *c,int pos); -int delCommand(CommandHash *cmdTable[], Command *c,char *mod_name); /* Del a command from a cmd table */ -int moduleDelCommand(CommandHash *cmdTable[],char *name); /* Del a command from a cmd table */ +MDE Command *createCommand(const char *name,int (*func)(User *u),int (*has_priv)(User *u),int help_all, int help_reg, int help_oper, int help_admin,int help_root); +MDE int destroyCommand(Command *c); /* destroy a command */ +MDE int addCoreCommand(CommandHash *cmdTable[], Command *c); /* Add a command to a command table */ +MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos); +MDE int addCommand(CommandHash *cmdTable[], Command *c,int pos); +MDE int delCommand(CommandHash *cmdTable[], Command *c,char *mod_name); /* Del a command from a cmd table */ +MDE int moduleDelCommand(CommandHash *cmdTable[],char *name); /* Del a command from a cmd table */ Command *findCommand(CommandHash *cmdTable[], const char *name); /* Find a command */ /*************************************************************************/ /*************************************************************************/ /* Message Managment Functions */ -Message *createMessage(char *name,int (*func)(char *source, int ac, char **av)); +MDE Message *createMessage(char *name,int (*func)(char *source, int ac, char **av)); Message *findMessage(MessageHash *msgTable[], const char *name); /* Find a Message */ -int addMessage(MessageHash *msgTable[], Message *m, int pos); /* Add a Message to a Message table */ +MDE int addMessage(MessageHash *msgTable[], Message *m, int pos); /* Add a Message to a Message table */ int addCoreMessage(MessageHash *msgTable[], Message *m); /* Add a Message to a Message table */ -int moduleAddMessage(Message *m, int pos); +MDE int moduleAddMessage(Message *m, int pos); int delMessage(MessageHash *msgTable[], Message *m, char *mod_name); /* Del a Message from a msg table */ -int moduleDelMessage(char *name); +MDE int moduleDelMessage(char *name); int destroyMessage(Message *m); /* destroy a Message*/ Message *findMessage(MessageHash *msgTable[], const char *name); /*************************************************************************/ -int moduleAddCallback(char *name,time_t when,int (*func)(int argc, char *argv[]),int argc, char **argv); -void moduleDelCallback(char *name); -void moduleCallBackRun(void); - -char *moduleGetData(ModuleData **md, char *key); /* Get the value for this key from this struct */ -int moduleAddData(ModuleData **md, char *key, char *value); /* Set the value for this key for this struct */ -void moduleDelData(ModuleData **md, char *key); /* Delete this key/value pair */ -void moduleDelAllData(ModuleData **md); /* Delete all key/value pairs for this module for this struct */ -void moduleCleanStruct(ModuleData **moduleData); /* Clean a moduleData hash */ +MDE int moduleAddCallback(char *name,time_t when,int (*func)(int argc, char *argv[]),int argc, char **argv); +MDE void moduleDelCallback(char *name); +MDE void moduleCallBackRun(void); + +MDE char *moduleGetData(ModuleData **md, char *key); /* Get the value for this key from this struct */ +MDE int moduleAddData(ModuleData **md, char *key, char *value); /* Set the value for this key for this struct */ +MDE void moduleDelData(ModuleData **md, char *key); /* Delete this key/value pair */ +MDE void moduleDelAllData(ModuleData **md); /* Delete all key/value pairs for this module for this struct */ +MDE void moduleCleanStruct(ModuleData **moduleData); /* Clean a moduleData hash */ void moduleDelAllDataMod(Module *m); /* remove all module data from all structs for this module */ int moduleDataDebug(ModuleData **md); /* Allow for debug output of a moduleData struct */ -boolean moduleMinVersion(int major,int minor,int patch,int build); /* Checks if the current version of anope is before or after a given verison */ +MDE boolean moduleMinVersion(int major,int minor,int patch,int build); /* Checks if the current version of anope is before or after a given verison */ /*************************************************************************/ diff --git a/include/resource.h b/include/resource.h new file mode 100644 index 000000000..2f3b54bfc --- /dev/null +++ b/include/resource.h @@ -0,0 +1,20 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by Win32GUI.rc +// +#define VER_ANOPE 1 +#define MANIFEST_RESOURCE_ID 2 +#define ICON_APP 129 + + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 +#define _APS_NEXT_RESOURCE_VALUE 152 +#define _APS_NEXT_COMMAND_VALUE 40061 +#define _APS_NEXT_CONTROL_VALUE 1167 +#define _APS_NEXT_SYMED_VALUE 104 +#endif +#endif diff --git a/include/services.h b/include/services.h index 4523e2e34..730c04f3d 100644 --- a/include/services.h +++ b/include/services.h @@ -37,24 +37,60 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> + +/* Windows does not have: + * unistd.h, grp.h, + * netdb.h, netinet/in.h, + * sys/socket.h, sys/time.h + * Windows requires: + * winsock.h + * -- codemastr + */ + +#ifndef _WIN32 #include <unistd.h> +#endif + #include <signal.h> #include <time.h> #include <errno.h> + +#ifndef _WIN32 #include <grp.h> +#endif + #include <limits.h> + +#ifndef _WIN32 #include <netdb.h> #include <netinet/in.h> #include <arpa/inet.h> #include <sys/socket.h> +#else +#include <winsock.h> +#include <windows.h> +#endif + #include <sys/stat.h> /* for umask() on some systems */ #include <sys/types.h> + +#ifndef _WIN32 #include <sys/time.h> +#endif + +#ifdef _WIN32 +#include <sys/timeb.h> +#include <direct.h> +#include <io.h> +#endif + #include <fcntl.h> +#ifndef _WIN32 #ifdef HAVE_BACKTRACE #include <execinfo.h> #endif +#endif #ifdef USE_RDB # define MAX_SQL_BUF 4096 @@ -81,9 +117,14 @@ #endif #ifdef USE_THREADS -# include <pthread.h> + #ifndef _WIN32 + #include <pthread.h> + #endif +#include "threads.h" #endif +#include "sockets.h" + #ifdef _AIX /* Some AIX boxes seem to have bogus includes that don't have these * prototypes. */ @@ -119,6 +160,14 @@ extern int toupper(char), tolower(char); #define encrypt encrypt_ +#ifdef __WINS__ +#ifndef BKCHECK +#define BKCHECK + extern "C" void __pfnBkCheck() {} +#endif +#endif + + #if INTTYPE_WORKAROUND # undef int16 # undef int32 @@ -162,7 +211,20 @@ typedef struct uid_ Uid; /*************************************************************************/ +/* Windows defines a boolean type as an + * unsigned char. It does however need + * true/false. -- codemastr + */ +#ifndef _WIN32 typedef enum { false, true } boolean; +#else + #ifndef true + #define true 1 + #endif + #ifndef false + #define false 0 + #endif +#endif /* _WIN32 */ /*************************************************************************/ @@ -263,6 +325,7 @@ struct ircdvars_ { int invitemode; /* +I */ int sjoinbanchar; /* use single quotes to define it */ int sjoinexchar; /* use single quotes to define it */ + int sjoininvchar; /* use single quotes to define it */ int svsmode_ucmode; /* Can remove User Channel Modes with SVSMODE */ int sglineenforce; char *vhostchar; /* char used for vhosting */ diff --git a/include/sockets.h b/include/sockets.h new file mode 100644 index 000000000..e5ae27c58 --- /dev/null +++ b/include/sockets.h @@ -0,0 +1,47 @@ +/* + * + * (C) 2004 Anope Team + * Contact us at info@anope.org + * + * Please read COPYING and README for furhter details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + * + */ + +#ifndef SOCKETS_H +#define SOCKETS_H + +#ifdef _WIN32 +typedef SOCKET ano_socket_t; +#define ano_sockread(fd, buf, len) recv(fd, buf, len, 0) +#define ano_sockwrite(fd, buf, len) send(fd, buf, len, 0) +#define ano_sockclose(fd) closesocket(fd) +#define ano_sockgeterr() WSAGetLastError() +#define ano_sockseterr(err) WSASetLastError(err) +/* ano_sockstrerror in sockutil.c */ +/* ano_socksetnonb in sockutil.c */ +#define ano_sockerrnonb(err) (err == WSAEINPROGRESS || err == WSAEWOULDBLOCK) +#define SOCKERR_EBADF WSAENOTSOCK +#define SOCKERR_EINTR WSAEINTR +#define SOCKERR_EINVAL WSAEINVAL +#define SOCKERR_EINPROGRESS WSAEINPROGRESS +#else +typedef int ano_socket_t; +#define ano_sockread(fd, buf, len) read(fd, buf, len) +#define ano_sockwrite(fd, buf, len) write(fd, buf, len) +#define ano_sockclose(fd) close(fd) +#define ano_sockgeterr() errno +#define ano_sockseterr(err) errno = err +#define ano_sockstrerror(err) strerror(err) +#define ano_socksetnonb(fd) fcntl(fd, F_SETFL, O_NONBLOCK) +#define ano_sockerrnonb(err) (err == EINPROGRESS) +#define SOCKERR_EBADF EBADF +#define SOCKERR_EINTR EINTR +#define SOCKERR_EINVAL EINVAL +#define SOCKERR_EINPROGRESS EINPROGRESS +#endif + +#endif diff --git a/include/sysconf.h.win32 b/include/sysconf.h.win32 new file mode 100644 index 000000000..e408f463f --- /dev/null +++ b/include/sysconf.h.win32 @@ -0,0 +1,51 @@ +
+#define SERVICES_DIR "data"
+#define SERVICES_BIN "services.exe"
+
+typedef signed __int16 int16;
+typedef signed __int16 int16_t;
+typedef unsigned __int16 uint16;
+typedef unsigned __int16 u_int16_t;
+typedef signed __int32 int32;
+typedef signed __int32 int32_t;
+typedef unsigned __int32 uint32;
+typedef unsigned __int32 u_int32_t;
+typedef unsigned __int8 u_int8_t;
+
+#define HAVE_STRINGS_H 0
+#define HAVE_SYS_SELECT_H 0
+#define HAVE_SYS_SYSPROTO_H 0
+
+#define HAVE_STRERROR 1
+#define HAVE_SYS_ERRLIST 0
+#define HAVE_SNPRINTF 1
+#define BAD_SNPRINTF 0
+#define HAVE_STRICMP 1
+#define HAVE_STRCASECMP 0
+#define HAVE_STRDUP 1
+#define HAVE_STRSPN 1
+#define HAVE_STRSIGNAL 0
+#define HAVE_GETTIMEOFDAY 0
+#define HAVE_SETGRENT 0
+#define HAVE_UMASK 0
+#define HAVE_FORK 0
+#define HAVE_GETHOSTBYNAME 1
+#define HAVE_BACKTRACE 0
+
+/* Enable Module support */
+#define USE_MODULES
+#define MODULE_PATH ".\\modules\\"
+
+/* Windows/MSVC likes to name things differently */
+#define snprintf _snprintf
+#define vsnprintf _vsnprintf
+#define popen _popen
+#define pclose _pclose
+#define ftruncate _chsize
+#define PATH_MAX MAX_PATH
+#define MAXPATHLEN MAX_PATH
+#define bzero(buf, size) memset(buf, 0, size)
+#define strcasecmp stricmp
+#define sleep(x) Sleep(x*1000)
+
+
diff --git a/include/threads.h b/include/threads.h new file mode 100644 index 000000000..90694a625 --- /dev/null +++ b/include/threads.h @@ -0,0 +1,67 @@ +/* + * + * (C) 2004 Anope Team + * Contact us at info@anope.org + * + * Please read COPYING and README for furhter details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + * + */ + +#ifndef THREADS_H +#define THREADS_H + +#ifdef _WIN32 +typedef long ano_thread_t; +typedef HANDLE ano_mutex_t; +typedef HANDLE ano_cond_t; +typedef unsigned (__stdcall *ano_thread_start) (void *); +typedef struct +{ + ano_thread_start func; + void *arg; +} ano_cleanup_t; + +extern ano_thread_start __declspec(thread) cleanup_func; + +#define ano_thread_create(thread,start,arg) !_beginthreadex(NULL, 0, (ano_thread_start)start, arg, 0, &thread) +#define ano_thread_self() GetCurrentThreadId() +#define ano_thread_detach(thread) 0 +#define ano_mutex_lock(mutex) WaitForSingleObject(mutex, INFINITE) +#define ano_mutex_unlock(mutex) ReleaseMutex(mutex) + +/* ano_cond_wait is in compat.c */ +#define ano_cond_signal(cond) SetEvent(cond) + +/* very minimalistic implementation */ +#define ano_cleanup_push(func, arg) cleanup_func = (ano_thread_start)func +#define ano_cleanup_pop(execute) cleanup_func(NULL) + +#else + +typedef pthread_t ano_thread_t; +typedef pthread_mutex_t ano_mutex_t; +typedef pthread_cond_t ano_cond_t; +typedef void *(*ano_thread_start) (void *); + +#define ano_thread_create(thread,start,arg) pthread_create(&thread, NULL, start, arg) +#define ano_thread_self() pthread_self() +#define ano_thread_detach(thread) pthread_detach(thread) + +#define ano_mutex_lock(mutex) pthread_mutex_lock(&mutex) +#define ano_mutex_unlock(mutex) pthread_mutex_unlock(&mutex) + +#define ano_cond_wait(cond, mutex) pthread_cond_wait(&cond, &mutex) +#define ano_cond_signal(cond) pthread_cond_signal(&cond) + +#define ano_cleanup_push(func, arg) pthread_cleanup_push(func, arg) +#define ano_cleanup_pop(execute) pthread_cleanup_pop(execute) + +#define ano_thread_cancel(thread) pthread_cancel(thread) + +#endif + +#endif diff --git a/include/version.sh.c b/include/version.sh.c new file mode 100644 index 000000000..0332fddfe --- /dev/null +++ b/include/version.sh.c @@ -0,0 +1,215 @@ +/* version file handler for win32. + * + * (C) 2003 Anope Team + * Contact us at info@anope.org + * + * Please read COPYING and README for furhter details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + * Written by Dominick Meglio <codemastr@unrealircd.com> + * + */ + +/* Needed due to Windows lack of a decent interpreter */ + +#include <stdio.h> +#include <string.h> + +#define CTRL "version.log" + +long version_major, version_minor, version_patch, version_build, build; +char *version_extra; +char version[1024]; + + +void load_ctrl(FILE *); +long get_value(char *); +char *get_value_str(char *); +char *strip(char *); +void parse_version(FILE *); +void write_version(FILE *); +void parse_line(FILE *, char *); + +int main() +{ + FILE *fd = fopen(CTRL, "r"); + + + if (!fd) { + fprintf(stderr, "Error: Unable to find control file: " CTRL "\n"); + exit(0); + } + + load_ctrl(fd); + fclose(fd); + + _snprintf(version, 1024, "%d.%d.%d%s", version_major, version_minor, + version_patch, version_extra ? version_extra : ""); + + + fd = fopen("version.h", "r"); + + if (fd) { + parse_version(fd); + fclose(fd); + } else + build = 1; + + + fd = fopen("version.h", "w"); + write_version(fd); + fclose(fd); +} + +void load_ctrl(FILE * fd) +{ + char buf[512]; + while (fgets(buf, 511, fd)) { + char *var; + + strip(buf); + + var = strtok(buf, "="); + if (!var) + continue; + if (!strcmp(var, "VERSION_MAJOR")) + version_major = get_value(strtok(NULL, "")); + else if (!strcmp(var, "VERSION_MINOR")) + version_minor = get_value(strtok(NULL, "")); + else if (!strcmp(var, "VERSION_PATCH")) + version_patch = get_value(strtok(NULL, "")); + else if (!strcmp(var, "VERSION_BUILD")) + version_build = get_value(strtok(NULL, "")); + else if (!strcmp(var, "VERSION_EXTRA")) + version_extra = get_value_str(strtok(NULL, "")); + + } +} + +char *strip(char *str) +{ + char *c; + if ((c = strchr(str, '\n'))) + *c = 0; + if ((c = strchr(str, '\r'))) + *c = 0; + return str; +} + +long get_value(char *string) +{ + return atol(get_value_str(string)); +} + +char *get_value_str(char *string) +{ + int len; + + if (*string == '"') + string++; + + len = strlen(string); + + if (string[len - 1] == '"') + string[len - 1] = 0; + if (!*string) + return NULL; + return string; +} + +void parse_version(FILE * fd) +{ + char buf[1024]; + + while (fgets(buf, 1023, fd)) { + char *para1; + + strip(buf); + para1 = strtok(buf, " \t"); + + if (!para1) + continue; + + if (!strcmp(para1, "#define")) { + char *para2 = strtok(NULL, " \t"); + + if (!para2) + continue; + + if (!strcmp(para2, "BUILD")) { + char *value = strtok(NULL, ""); + build = get_value(value); + build++; + return; + } + } + } + build = 1; +} + +void write_version(FILE * fd) +{ + FILE *fdin = fopen("include\\version.sh", "r"); + char buf[1024]; + short until_eof = 0; + + while (fgets(buf, 1023, fdin)) { + strip(buf); + + if (until_eof) + if (!strcmp(buf, "EOF")) + break; + else + parse_line(fd, buf); + + if (!strcmp(buf, "cat >version.h <<EOF")) + until_eof = 1; + } + +} + +void parse_line(FILE * fd, char *line) +{ + char *c; + for (c = line; *c; c++) { + /* It's a variable, find out which */ + if (*c == '$') { + char *var, *varbegin; + + if (*(c + 1)) + c++; + else + continue; + for (var = varbegin = c; var; var++) { + if (!isalnum(*var) && *var != '_') + break; + } + if (var != varbegin) { + char tmp = *var; + + *var = 0; + if (!strcmp(varbegin, "VERSION_MAJOR")) + fprintf(fd, "%d", version_major); + else if (!strcmp(varbegin, "VERSION_MINOR")) + fprintf(fd, "%d", version_minor); + else if (!strcmp(varbegin, "VERSION_PATCH")) + fprintf(fd, "%d", version_patch); + else if (!strcmp(varbegin, "VERSION_EXTRA")) { + if (version_extra) + fprintf(fd, "%s", version_extra); + } else if (!strcmp(varbegin, "VERSION_BUILD")) + fprintf(fd, "%d", version_build); + else if (!strcmp(varbegin, "BUILD")) + fprintf(fd, "%d", build); + else if (!strcmp(varbegin, "VERSION")) + fprintf(fd, "%s", version); + fputc(tmp, fd); + } + c = var; + } else + fputc(*c, fd); + } + fprintf(fd, "\r\n"); +} diff --git a/lang/Makefile.win32 b/lang/Makefile.win32 new file mode 100644 index 000000000..75347de0d --- /dev/null +++ b/lang/Makefile.win32 @@ -0,0 +1,75 @@ +# Makefile for language module + +include ../Makefile.inc.win32 + + +LANGOBJS = cat de en_us es fr hun gr nl pl pt tr it ru +LANGSRCS = cat de en_us.l es fr.l hun.l gr.l nl.l pl.l pt.l tr.l it.l ru.l + +LANGCOMP = ./langcomp +#LANGCOMP = ./langcomp -w + + +all: $(LANGOBJS) + + +install: all + -copy cat ..\$(DATDEST)\languages + -copy en_us ..\$(DATDEST)\languages + -copy de ..\$(DATDEST)\languages + -copy es ..\$(DATDEST)\languages + -copy fr ..\$(DATDEST)\languages + -copy hun ..\$(DATDEST)\languages + -copy gr ..\$(DATDEST)\languages + -copy nl ..\$(DATDEST)\languages + -copy pl ..\$(DATDEST)\languages + -copy pt ..\$(DATDEST)\languages + -copy tr ..\$(DATDEST)\languages + -copy it ..\$(DATDEST)\languages + -copy ru ..\$(DATDEST)\languages + +clean: + -@erase $(LANGOBJS) langcomp.exe langtool.exe *.obj index + +spotless: clean + -@erase language.h + + +cat: cat.l langtool.exe langcomp.exe index + langcomp $@.l +de: de.l langtool.exe langcomp.exe index + langcomp $@.l +en_us: en_us.l langtool.exe langcomp.exe index + langcomp $@.l +es: es.l langtool.exe langcomp.exe index + langcomp $@.l +fr: fr.l langtool.exe langcomp.exe index + langcomp $@.l +hun: hun.l langtool.exe langcomp.exe index + langcomp $@.l +gr: gr.l langtool.exe langcomp.exe index + langcomp $@.l +nl: nl.l langtool.exe langcomp.exe index + langcomp $@.l +pl: pl.l langtool.exe langcomp.exe index + langcomp $@.l +pt: pt.l langtool.exe langcomp.exe index + langcomp $@.l +tr: tr.l langtool.exe langcomp.exe index + langcomp $@.l +it: it.l langtool.exe langcomp.exe index + langcomp $@.l +ru: ru.l langtool.exe langcomp.exe index + langcomp $@.l + +langtool.exe: langtool.c + $(CC) langtool.c -o $@ + +langcomp.exe: langcomp.c + $(CC) langcomp.c -o $@ + +language.h: langtool.exe index + langtool language.h + +index: langtool.exe en_us.l + langtool index @@ -49,11 +49,11 @@ # (including empty lines). This has to be a tab, not spaces. ########################################################################### # -# WICHTIG: Bitte ändert NICHT die MENÜS,selbst wenn die so komisch ausshen, -# (damit mein ich die ganzen /help /help befehl) im IRC werden die -# richtig angezeigt.THX :) (-Noch nicht ganz fertig jetzt- ) +# INFO : Das File ist zu 95% fertig :) +# Werde es warscheinlich in den nechten 1-2 wochen ganz fertig +# bekommen.. # -# Datum : 22.10.2004 +# Datum : 05.02.2005 # # - crazytoon - # @@ -353,7 +353,7 @@ NICK_ALREADY_REGISTERED NICK_REGISTERED Dein Nickname %s ist unter deinem Host registriert worden: %s NICK_REGISTERED_NO_MASK - Nickname %s registered. + Der Nickname %s ist registriert. NICK_PASSWORD_IS Dein Passwort ist %s - behalte es für spätere Benutzung. NICK_REG_DELAY @@ -2421,15 +2421,15 @@ OPER_ADMIN_ADDED OPER_ADMIN_NOT_FOUND %s wurde nicht auf der Liste der Services Administratoren gefunden. OPER_ADMIN_NO_MATCH - Keine entsprechenden Einträge in der Services Admin-Liste gefunden. + Keine entsprechenden Einträge in der Services Administratoren-Liste gefunden. OPER_ADMIN_DELETED - %s wurde aus der Services Admin-Liste entfernt. + %s wurde aus der Services Administratoren-Liste entfernt. OPER_ADMIN_DELETED_ONE - Es wurde 1 Eintrag aus der Services Admin-Liste entfernt. + Es wurde 1 Eintrag aus der Services Administratoren-Liste entfernt. OPER_ADMIN_DELETED_SEVERAL - Es wurden %d Einträge aus der Services Admin-Liste entfernt. + Es wurden %d Einträge aus der Services Administratoren-Liste entfernt. OPER_ADMIN_LIST_EMPTY - Services Admin-Liste ist leer. + Die Services Administratoren-Liste ist leer. OPER_ADMIN_LIST_HEADER Services Admin-Liste: Nummer Nickname @@ -2438,7 +2438,7 @@ OPER_ADMIN_LIST_FORMAT OPER_ADMIN_CLEAR Die Liste der Services Administratoren wurde geleert. OPER_ADMIN_MOVED - %s has been moved to Services Administrators list. + %s wurde zu der Services Administratoren-Liste verschoben. # OPER responses OPER_OPER_SYNTAX @@ -2471,7 +2471,7 @@ OPER_OPER_LIST_FORMAT OPER_OPER_CLEAR Die Liste der Services Operatoren wurde geleert. OPER_OPER_MOVED - %s has been moved to Services Operators list. + %s wurde zu der Services Operatoren-Liste verschoben. # AKILL responses OPER_AKILL_SYNTAX @@ -2680,17 +2680,17 @@ OPER_SET_NOEXPIRE_ERROR OPER_SET_UNKNOWN_OPTION Unbekannte Option %s. OPER_SET_SQL_ON - SQL code will be used. + SQL code wird jetzt benutzt. OPER_SET_SQL_OFF - SQL code will not be used. + SQL code wird jetzt NICHT mehr benutzt. OPER_SET_SQL_ERROR - Setting for SQL must be ON or OFF. + Einstellungen für SQL können nur ON oder OFF sein. OPER_SET_SQL_ERROR_INIT - Error during init of SQL, check your logs to correct. + SQL FEHLER, schaue bitte in deine Logs nach um zu sehen wie du es berichtigen kannst. OPER_SET_LIST_OPTION_ON - %s is enable + %s ist eingeschaltet OPER_SET_LIST_OPTION_OFF - %s is disabled + %s ist ausgeschaltet # NOOP responses OPER_NOOP_SYNTAX @@ -2965,9 +2965,9 @@ OPER_EXCEPTION_INVALID_LIMIT OPER_EXCEPTION_INVALID_HOSTMASK Ungültige Hostmask. Nur echte Hostmasken sind gültig als Einträge (ohne Nicknamen und Idents). OPER_EXCEPTION_EXISTS - %s already exists on the EXCEPTION list. + %s ist bereits in der EXCEPTION-Liste. OPER_EXCEPTION_CHANGED - Exception for %s has been updated to %d. + Exception für %s ist zu %d aktualisiert worden. # SESSION responses OPER_SESSION_SYNTAX @@ -3782,7 +3782,7 @@ NICK_HELP_GLIST Zeigt alle Nicknamen die in deiner Gruppe enthalten sind. NICK_HELP_STATUS - Syntax: STATUS Nickname... + Syntax: STATUS Nickname Liefert einen Wert zurück, der besagt, ob der augenblickliche Nutzer des Nicknamens der identifizierte Eigentümer ist, oder @@ -3801,8 +3801,8 @@ NICK_HELP_STATUS Identifizierung mit Passwort Bis zu 16 Nicknamen können mit dem Befehl übergeben werden, - der Rest wird ignoriert. If no nickname is given, your status - will be returned. + der Rest wird ignoriert. Wenn kein Nickname angegeben wird, + wird dein STATUS angezeigt. NICK_HELP_SENDPASS Syntax: SENDPASS Nickname @@ -4030,12 +4030,12 @@ CHAN_HELP_ULTIMATE3 CHAN_HELP_IRCD_HALFOP - These commands are also available on this network: + Die folgende Befehle sind auf diesem Netzwerk Verfügbar: DEHALFOP, HALFOP, HOP CHAN_HELP_IRCD_PROTECT - These commands are also available on this network: + Die folgende Befehle sind auf diesem Netzwerk Verfügbar: DEPROTECT, PROTECT CHAN_HELP_EXPIRES @@ -4058,7 +4058,7 @@ CHAN_HELP_REGISTER Wenn du einen Channel registrierst, wird dein Nickname als Founder (Gründer) eingetragen. Der Channel-Founder kann alle Einstellungen des Channels bearbeiten, und - wird automatisch beim Joinen desChannels durch %S mit + wird automatisch beim Joinen des Channels durch %S mit Founder/Operator Privilegien ausgestattet. Mit Hilfe des ACCESS Befehls (/msg %S HELP ACCESS) kann man einen Teil dieser Privilegien anderen registrierten @@ -5329,10 +5329,10 @@ OPER_HELP_OPER_CMD KICK Einen User aus einem beliebigen Channel kicken AKILL Die AutoKill-Liste bearbeiten - CLEARMODES Die Modes eines Channels zurücksetzen + CLEARMODES Die Modis eines Channels zurücksetzen OPER_HELP_OPER_CMD_EXTRA - Following commands are also available + Die folgende Befehle sind Verfügbar OPER_HELP_OPER_CMD_SGLINE SGLINE Die SGLINE-Liste bearbeiten @@ -5375,7 +5375,7 @@ OPER_HELP_ADMIN_CMD ADMIN Liste der Services Administratoren bearbeiten OPER_HELP_ADMIN_CMD_EXTRA - Following commands are also available to Service Admins + Die folgende Befehle sind für Service Administartoren Verfügbar OPER_HELP_ADMIN_CMD_OLINE OLINE Einem User "Operflags" setzen @@ -5800,9 +5800,9 @@ OPER_HELP_SET NOEXPIRE Den Auslauf-Modus der Services an oder aus SUPERADMIN Den Super-Admin Modus an oder aus - SQL Activate or deactivate sql mode - IGNORE Activate or deactivate ignore mode - LIST List the options + SQL SQL-Modus an oder aus + IGNORE Ignore-Modus an oder aus + LIST Optionen-Liste Beschränkt auf Services Administratoren. @@ -5869,20 +5869,19 @@ OPER_HELP_SET_SUPERADMIN OPER_HELP_SET_SQL Syntax: SET SQL {ON | OFF} - Setting this will toggle Anope's from usage of SQL, this should - be used to disable and enable SQL should your SQL server go down - while services are running. + Diese Einstellung wird Anope veranlassen SQL zu benutzen oder nicht. + Kann nützlich sein wenn zB der MySQL-Server aus ist. OPER_HELP_SET_IGNORE Syntax: SET IGNORE {ON | OFF} - Setting this will toggle Anope's usage of the IGNORE system - on or off. + Mit diese Einstellung kannst du Anope's IGNORE-System + an oder aus machen. OPER_HELP_SET_LIST Syntax: SET LIST - Display the various OperServ settings + Zeigt dir eine Liste der verfügbaren Einstellungen von OperServ OPER_HELP_NOOP Syntax: NOOP SET Server diff --git a/lang/langcomp.c b/lang/langcomp.c index 185c6d61d..1aace4e09 100644 --- a/lang/langcomp.c +++ b/lang/langcomp.c @@ -53,6 +53,9 @@ char **strings; /* Strings we have loaded */ int linenum = 0; /* Current line number in input file */ +#ifdef _WIN32 +#define snprintf _snprintf +#endif char *anopeStrDup(const char *src); diff --git a/lang/langtool.c b/lang/langtool.c index 3175118e0..6ac2bd6f6 100644 --- a/lang/langtool.c +++ b/lang/langtool.c @@ -1,4 +1,16 @@ -/* Needed due to Windows lack of a decent interpreter */ +/* Language stuff generator for win32. + * + * (C) 2003 Anope Team + * Contact us at info@anope.org + * + * Please read COPYING and README for furhter details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + * Written by Dominick Meglio <codemastr@unrealircd.com> + * + */ #include <string.h> #include <stdio.h> diff --git a/makefile.inc.win32 b/makefile.inc.win32 new file mode 100644 index 000000000..5c6e4717b --- /dev/null +++ b/makefile.inc.win32 @@ -0,0 +1,174 @@ +# +# Anope IRC Services 1.7.7 for Windows +# +# Contact us at info@anope.org +# +# Please read COPYING and README for further details. +# +# Based on the original code of Epona by Lara. +# Based on the original code of Services by Andy Church. +# + +# Please read and edit the configurations options below. + + +# Set which IRCd to compile for +# 1 DreamForge 4.6.7 [dated IRCd, upgrade to a current one] +# 2 Bahamut 1.4.27 [or later] +# 3 UnrealIRCd 3.1.1 [or later] +# 4 UltimateIRCd 2.8.2 [or later] +# 5 UltimateIRCd 3.0.0 [alpha26 or later] +# 6 Hybrid IRCd 7.0 [experimental] +# 7 ViagraIRCd 1.3.x [or later] +# 8 PTlink 6.15.0 [experimental] +# 9 RageIRCd 2.0 [beta-3 or later] +# 10 Unreal 3.2 [Unreal 3.2 beta19 or later] (default) +# 11 Solid IRCD 3.4.x [Solid IRCD 3.4.6 or later] +# 12 Plexus 2.0 [or later] +# 13 Ratbox 2.0.6 [or later] + +IRCD=10 + + +# Set this to 1 to enable MySQL support +USE_MYSQL=0 +# Set this to the path where the MySQL includes can be found +#MYSQL_INC="c:\\mysql\\include\\" +# Set this to the path where the MySQL libraries can be found +#MYSQL_LIB="c:\\mysql\\lib\\opt\\" + +# Set this to 1 to enable the proxy scanner +PROXY_SCANNER=0 + +# If you want to change the names/locations of files/folders, you +# can do that here. +PROGRAM=anope.exe +BINDEST=bin +DATDEST=data + +# If you are compiling using VC6, or get __ftol2 errors, please uncomment +# the following line: +#VC6=/QIfist + +# If you are getting errors such as 'Cannot find wsock32.lib', then change +# the following line to the path where the library files can be found. +#LIBPATH=C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Vc7\\lib +LIBPATH= + +# If you edited the line above, uncomment the next line. +#LFLAGS=/LIBPATH:"$(LIBPATH)" + + +############################################################### +#Don't touch anything below unless you know what you are doing# +############################################################### + + +CC=cl +RC=rc +MAKE=nmake -f makefile.win32 +BASE_CFLAGS=/O2 /MD +LIBS=wsock32.lib advapi32.lib /NODEFAULTLIB:libcmtd.lib +ELIBS= +MLIBS= + +!IFNDEF IRCTYPE +!IF $(IRCD) == 1 +IRCTYPE=IRC_DREAMFORGE +CAPAB_C=dreamforge.c +CAPAB_O=dreamforge.obj +!ELSEIF $(IRCD) == 2 +IRCTYPE=/D IRC_BAHAMUT +CAPAB_C=bahamut.c +CAPAB_O=bahamut.obj +!ELSEIF $(IRCD) == 3 +IRCTYPE=/D IRC_UNREAL31 +CAPAB_C=unreal31.c +CAPAB_O=unreal31.obj +!ELSEIF $(IRCD) == 4 +IRCTYPE=/D IRC_ULTIMATE2 +CAPAB_C=ultimate2.c +CAPAB_O=ultimate2.obj +!ELSEIF $(IRCD) == 5 +IRCTYPE=/D IRC_ULTIMATE33 +CAPAB_C=ultimate3.c +CAPAB_O=ultimate3.obj +!ELSEIF $(IRCD) == 6 +IRCTYPE=/D IRC_HYBRID +CAPAB_C=hybrid.c +CAPAB_O=hybrid.obj +!ELSEIF $(IRCD) == 7 +IRCTYPE=/D IRC_VIAGRA +CAPAB_C=hybrid.c +CAPAB_O=hybrid.obj +!ELSEIF $(IRCD) == 8 +IRCTYPE=/D IRC_PTLINK +CAPAB_C=ptlink.c +CAPAB_O=ptlink.obj +!ELSEIF $(IRCD) == 9 +IRCTYPE=/D IRC_RAGE2 +CAPAB_C=rageircd.c +CAPAB_O=rageircd.obj +!ELSEIF $(IRCD) == 10 +IRCTYPE=/D IRC_UNREAL32 +CAPAB_C=unreal32.c +CAPAB_O=unreal32.obj +!ELSEIF $(IRCD) == 11 +IRCTYPE=/D IRC_SOLID +CAPAB_C=solidircd.c +CAPAB_O=solidircd.obj +!ELSEIF $(IRCD) == 12 +IRCTYPE=/D IRC_PLEXUS +CAPAB_C=plexus.c +CAPAB_O=plexus.obj +!ELSEIF $(IRCD) == 13 +IRCTYPE=/D IRC_RATBOX +CAPAB_C=ratbox.c +CAPAB_O=ratbox.obj +!ELSE +!ERROR Invalid IRCd +!ENDIF +!ENDIF + +!IF $(USE_MYSQL) == 1 +!IF $(MYSQL_LIB) != "" +LIBS=$(LIBS) /LIBPATH:$(MYSQL_LIB) +MYSQL_LIB_PATH=/LIBPATH:$(MYSQL_LIB) +!ENDIF +!IF $(MYSQL_INC) != "" +BASE_CFLAGS=$(BASE_CFLAGS) /I $(MYSQL_INC) +MYSQL_INC_PATH=/I $(MYSQL_INC) +!ENDIF +RDB_C=rdb.c +RDB_O=rdb.obj + +MYSQL_C=mysql.c +MYSQL_O=mysql.obj +BASE_CFLAGS=/D USE_MYSQL /D USE_RDB $(BASE_CFLAGS) /D HAVE_MYSQL_MYSQL_H + +MYPASQL_BUILD=$(CC) /LD $(MYSQL_INC_PATH) src\mypasql.c /link $(MYSQL_LIB_PATH) $(LFLAGS) \ +/DEF:src\mypasql.def libmysql.lib zlib.lib ws2_32.lib advapi32.lib /NODEFAULTLIB:LIBCMTD.lib + +LIBS=$(LIBS) libmysql.lib zlib.lib +!ENDIF + +!IF $(PROXY_SCANNER) == 1 +BASE_CFLAGS=/D USE_THREADS $(BASE_CFLAGS) +!ENDIF + +# Note that changing any of these options (or, in fact, anything in this +# file) will automatically cause a full rebuild of Services. + +# Compilation options: +# -DCLEAN_COMPILE Attempt to compile without any warnings (note that +# this may reduce performance) +# -DSTREAMLINED Leave out "fancy" options to enhance performance + +CDEFS = + +# Add any extra flags you want here. The default line enables warnings and +# debugging symbols on GCC. If you have a non-GCC compiler, you may want +# to comment it out or change it. + +MORE_CFLAGS = /I"../include" +CFLAGS = /nologo $(VC6) $(CDEFS) $(BASE_CFLAGS) $(MORE_CFLAGS) diff --git a/makefile.win32 b/makefile.win32 new file mode 100644 index 000000000..457297e37 --- /dev/null +++ b/makefile.win32 @@ -0,0 +1,156 @@ +# Makefile for Epona. +# +# Epona (c) 2000-2002 PegSoft +# Contact us at epona@pegsoft.net +# +# This program is free but copyrighted software; see the file COPYING for +# details. +# +# Based on the original code of Services by Andy Church. + +include Makefile.inc.win32 + +########################################################################### + +all: src languages anopesmtp modules install + +src: include\version.h include\sysconf.h include\language.h include\sysconf.h + cd src && $(MAKE) && cd .. + +install: + -@mkdir $(DATDEST)\backups + -@mkdir $(DATDEST)\logs + -@mkdir $(DATDEST)\languages + cd lang && $(MAKE) install && cd .. + cd src && $(MAKE) install && cd .. + cd src\modules && $(MAKE) install && cd .. + -@echo --- + -@echo Anope has been insalled successfully! + -@echo --- + +clean: + cd src && $(MAKE) spotless && cd .. + cd lang && $(MAKE) spotless && cd .. + -@erase src\*.exe + -@erase *.exe version.h *.obj + cd src/modules && $(MAKE) spotless && cd ../.. + +spotless: + cd lang && $(MAKE) spotless && cd .. + cd src && $(MAKE) spotless && cd .. + cd src/modules && $(MAKE) spotless && cd ../.. + -@erase include\language.h include\version.h *~ services.exe version.sh.exe *.obj anopesmtp.exe + +mypasql: + $(MYPASQL_BUILD) + +distclean: spotless + +dist: + $(MAKE) clean +#Compile dreamforge + echo Compiling Dreamforge build + $(MAKE) IRCTYPE=/DIRC_DREAMFORGE CAPAB_C=dreamforge.c CAPAB_O=dreamforge.obj + -@copy src\$(PROGRAM) services-dreamforge.exe + $(MAKE) clean +#Compile bahamut + echo Compiling Bahamut build + $(MAKE) IRCTYPE=/DIRC_BAHAMUT CAPAB_C=bahamut.c CAPAB_O=bahamut.obj + -@copy src\$(PROGRAM) services-bahamut.exe + $(MAKE) clean +#Compile unreal + echo Compiling UnrealIRCd3.1 build + $(MAKE) IRCTYPE=/DIRC_UNREAL31 CAPAB_C=unreal31.c CAPAB_O=unreal31.obj + -@copy src\$(PROGRAM) services-unreal31.exe + $(MAKE) clean +#Compile ultimate2 + echo Compiling UltimateIRCd2 build + $(MAKE) IRCTYPE=/DIRC_ULTIMATE2 CAPAB_C=ultimate2.c CAPAB_O=ultimate2.obj + -@copy src\$(PROGRAM) services-ultimate2.exe + $(MAKE) clean +#Compile ultimate3 + echo Compiling UltimateIRCd 3.x build + $(MAKE) IRCTYPE=/DIRC_ULTIMATE3 CAPAB_C=ultimate3.c CAPAB_O=ultimate3.obj + -@copy src\$(PROGRAM) services-ultimate3.exe + $(MAKE) clean +#Compile hybrid + echo Compiling Hybrid build + $(MAKE) IRCTYPE=/DIRC_HYBRID CAPAB_C=hybrid.c CAPAB_O=hybrid.obj + -@copy src\$(PROGRAM) services-hybrid.exe + $(MAKE) clean +#Compile viagra + echo Compiling ViagraIRCd build + $(MAKE) IRCTYPE=/DIRC_VIAGRA CAPAB_C=viagra.c CAPAB_O=viagra.obj + -@copy src\$(PROGRAM) services-viagra.exe + $(MAKE) clean +#Compile ptlink + echo Compiling PTLink IRCd build + $(MAKE) IRCTYPE=/DIRC_PTLINK CAPAB_C=ptlink.c CAPAB_O=ptlink.obj + -@copy src\$(PROGRAM) services-ptlink.exe + $(MAKE) clean +#Compile rage2 + echo Compiling Rage2 IRCd build + $(MAKE) IRCTYPE=/DIRC_RAGE2 CAPAB_C=rageircd.c CAPAB_O=rageircd.obj + -@copy src\$(PROGRAM) services-rage2.exe + $(MAKE) clean +#Compile UnrealIRCD3.2 + echo Compiling UnrealIRCD3.2 IRCd build + $(MAKE) IRCTYPE=/DIRC_UNREAL32 CAPAB_C=unreal32.c CAPAB_O=unreal32.obj + -@copy src\$(PROGRAM) services-unreal32.exe + $(MAKE) clean +#Compile SolidIRCD + echo Compiling SolidIRCD IRCd build + $(MAKE) IRCTYPE=/DIRC_SOLID CAPAB_C=solidircd.c CAPAB_O=solidircd.obj + -@copy src\$(PROGRAM) services-solid.exe + $(MAKE) clean +#Compile PlexusIRCD + echo Compiling Plexus IRCd build + $(MAKE) IRCTYPE=/DIRC_PLEXUS CAPAB_C=plexus.c CAPAB_O=plexus.obj + -@copy src\$(PROGRAM) services-plexus.exe + $(MAKE) clean +#Compile Ratbox + echo Compiling Ratbox IRCd build + $(MAKE) IRCTYPE=/DIRC_RATBOX CAPAB_C=ratbox.c CAPAB_O=ratbox.obj + -@copy src\$(PROGRAM) services-ratbox.exe + +#Compile mypasql + $(MYPASQL_BUILD) + +#Cleanup + $(MAKE) spotless + + +########################################################################### + + +languages: FRC + cd lang && $(MAKE) && cd .. + +anopesmtp: FRC + $(CC) src/tools/anopesmtp.c /link wsock32.lib $(LFLAGS) + +modules: FRC + cd src\modules && $(MAKE) && cd ..\.. + +########################################################################### + +include\sysconf.h: + copy include\sysconf.h.win32 include\sysconf.h + +lang/language.h: lang/Makefile lang/index + cd lang && $(MAKE) language.h && cd .. + +lang/index: + cd lang && $(MAKE) index && cd .. + +include/language.h: lang/language.h + cd lang && copy language.h ..\include\language.h && cd .. + +include\version.h: version.sh.exe version.log include\services.h include\pseudo.h include\messages.h include\pseudo.h include\messages.h + version.sh.exe + copy version.h include\version.h + +version.sh.exe: + $(CC) include/version.sh.c + +FRC: diff --git a/src/anope-icon.ico b/src/anope-icon.ico Binary files differnew file mode 100644 index 000000000..b60a7994c --- /dev/null +++ b/src/anope-icon.ico diff --git a/src/bahamut.c b/src/bahamut.c index 5e40a7266..36bd28f6d 100644 --- a/src/bahamut.c +++ b/src/bahamut.c @@ -102,6 +102,7 @@ IRCDVar ircd[] = { 1, /* +I support */ 0, /* SJOIN ban char */ 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ 0, /* Can remove User Channel Modes with SVSMODE */ 0, /* Sglines are not enforced until user reconnects */ NULL, /* vhost char */ @@ -856,6 +857,9 @@ void anope_cmd_pong(char *servname, char *who) void anope_cmd_connect(int servernum) { + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); + if (servernum == 1) { anope_cmd_pass(RemotePassword); } else if (servernum == 2) { diff --git a/src/base64.c b/src/base64.c index 68fa80b96..0056822bc 100644 --- a/src/base64.c +++ b/src/base64.c @@ -1,6 +1,6 @@ /* base64 routines. * - * (C) 2003-1005 Anope Team + * (C) 2003-2005 Anope Team * Contact us at info@anope.org * * Please read COPYING and README for further details. diff --git a/src/channels.c b/src/channels.c index 78bdbb045..b9ab710ac 100644 --- a/src/channels.c +++ b/src/channels.c @@ -777,14 +777,14 @@ void do_sjoin(const char *source, int ac, char **av) } } - /* Unreal plans to add +I - for now add the hook to allow - 1.7.6 to work with it and not cause problems - TSL */ - if (*s == '\'') { - add_invite(c, myStrGetToken(s, '\'', 1)); - if (!end) - break; - s = end + 1; - continue; + if (ircd->sjoininvchar) { + if (*s == ircd->sjoininvchar) { + add_invite(c, myStrGetToken(s, ircd->sjoininvchar, 1)); + if (!end) + break; + s = end + 1; + continue; + } } while (csmodes[(int) *s] != 0) diff --git a/src/chanserv.c b/src/chanserv.c index affa29519..ce8863133 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -2925,6 +2925,10 @@ static int do_drop(User * u) } } + if (ircd->chansqline && (ci->flags & CI_VERBOTEN)) { + anope_cmd_unsqline(ci->name); + } + alog("%s: Channel %s dropped by %s!%s@%s (founder: %s)", s_ChanServ, ci->name, u->nick, u->username, common_get_vhost(u), @@ -6360,6 +6364,10 @@ static int do_forbid(User * u) "\2%s\2 used FORBID on channel \2%s\2", u->nick, ci->name); + if (ircd->chansqline) { + anope_cmd_sqline(ci->name, ((reason) ? reason : "Forbidden")); + } + alog("%s: %s set FORBID for channel %s", s_ChanServ, u->nick, ci->name); notice_lang(s_ChanServ, u, CHAN_FORBID_SUCCEEDED, chan); diff --git a/src/compat.c b/src/compat.c index 9db98fc0f..b9931ced9 100644 --- a/src/compat.c +++ b/src/compat.c @@ -136,19 +136,27 @@ char *strerror(int errnum) /*************************************************************************/ #if !HAVE_STRSIGNAL +/* Windows only supports 6 signals: + * SIGINT, SIGILL, SIGABRT, SIGFPE, SIGSEGV, SIGTERM + * -- codemastr + */ char *strsignal(int signum) { static char buf[32]; switch (signum) { +#ifndef _WIN32 case SIGHUP: strscpy(buf, "Hangup", sizeof(buf)); break; +#endif case SIGINT: strscpy(buf, "Interrupt", sizeof(buf)); break; +#ifndef _WIN32 case SIGQUIT: strscpy(buf, "Quit", sizeof(buf)); break; +#endif #ifdef SIGILL case SIGILL: strscpy(buf, "Illegal instruction", sizeof(buf)); @@ -172,15 +180,18 @@ char *strsignal(int signum) case SIGFPE: strscpy(buf, "Floating point exception", sizeof(buf)); break; +#ifndef _WIN32 case SIGKILL: strscpy(buf, "Killed", sizeof(buf)); break; case SIGUSR1: strscpy(buf, "User signal 1", sizeof(buf)); break; +#endif case SIGSEGV: strscpy(buf, "Segmentation fault", sizeof(buf)); break; +#ifndef _WIN32 case SIGUSR2: strscpy(buf, "User signal 2", sizeof(buf)); break; @@ -190,9 +201,11 @@ char *strsignal(int signum) case SIGALRM: strscpy(buf, "Alarm clock", sizeof(buf)); break; +#endif case SIGTERM: strscpy(buf, "Terminated", sizeof(buf)); break; +#ifndef _WIN32 case SIGSTOP: strscpy(buf, "Suspended (signal)", sizeof(buf)); break; @@ -202,6 +215,7 @@ char *strsignal(int signum) case SIGIO: strscpy(buf, "I/O error", sizeof(buf)); break; +#endif default: snprintf(buf, sizeof(buf), "Signal %d\n", signum); break; @@ -210,4 +224,25 @@ char *strsignal(int signum) } #endif +#ifdef _WIN32 + +#ifdef USE_THREADS +/* Simulate pthread conditional variable waiting */ +int ano_cond_wait(ano_cond_t cond, ano_mutex_t mutex) +{ + ReleaseMutex(mutex); + if (WaitForSingleObject(cond, INFINITE) == WAIT_FAILED) + return 1; + if (WaitForSingleObject(mutex, INFINITE) == WAIT_FAILED) + return 1; + return 0; +} + +/* Used for the cleanup functions */ +ano_thread_start __declspec(thread) cleanup_func = NULL; + +#endif + +#endif + /*************************************************************************/ diff --git a/src/datafiles.c b/src/datafiles.c index 48f460f8c..72c795952 100644 --- a/src/datafiles.c +++ b/src/datafiles.c @@ -101,7 +101,8 @@ static dbFILE *open_db_read(const char *service, const char *filename) int errno_save = errno; #ifndef NOT_MAIN if (errno != ENOENT) - log_perror("Can't read %s database %s", service, f->filename); + log_perror("Can not read %s database %s", service, + f->filename); #endif free(f); errno = errno_save; @@ -126,16 +127,33 @@ static dbFILE *open_db_write(const char *service, const char *filename, { dbFILE *f; int fd; +#ifdef _WIN32 + char buffer[_MAX_PATH]; + char win32filename[MAXPATHLEN]; + + /* Get the current working directory: */ + if (_getcwd(buffer, _MAX_PATH) == NULL) { + alog("debug: Unable to set Current working directory"); + } +#endif f = scalloc(sizeof(*f), 1); if (!f) { #ifndef NOT_MAIN - log_perror("Can't read %s database %s", service, filename); + log_perror("Can not read %s database %s", service, filename); +#else + alog("Can not read %s database %s", service, filename); #endif return NULL; } strscpy(f->filename, filename, sizeof(f->filename)); +#ifndef _WIN32 filename = f->filename; +#else + snprintf(win32filename, sizeof(win32filename), "%s\\%s", buffer, + f->filename); + filename = win32filename; +#endif f->mode = 'w'; *f->backupname = 0; @@ -150,19 +168,30 @@ static dbFILE *open_db_write(const char *service, const char *filename, errno = errno_save; return NULL; } - unlink(f->backupname); +#ifndef _WIN32 + unlink(filename); +#else + DeleteFile(filename); +#endif f->backupfp = fopen(filename, "rb"); +#ifdef _WIN32 + if (!MoveFileExA(filename, f->backupname, MOVEFILE_COPY_ALLOWED) + && GetLastError() != ENOENT) { + int errno_save = GetLastError(); +#else if (rename(filename, f->backupname) < 0 && errno != ENOENT) { int errno_save = errno; +#endif #ifndef NOT_MAIN static int walloped = 0; if (!walloped) { walloped++; - anope_cmd_global(NULL, "Can't back up %s database %s", service, - filename); + anope_cmd_global(NULL, "Can not back up %s database %s", + service, filename); } + alog("errno %d %d %d", errno, ENOENT, EACCES); errno = errno_save; - log_perror("Can't back up %s database %s", service, filename); + log_perror("Can not back up %s database %s", service, filename); if (!NoBackupOkay) { #endif if (f->backupfp) @@ -175,9 +204,17 @@ static dbFILE *open_db_write(const char *service, const char *filename, #endif *f->backupname = 0; } +#ifndef _WIN32 unlink(filename); +#else + DeleteFile(filename); +#endif /* Use open() to avoid people sneaking a new file in under us */ +#ifndef _WIN32 fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666); +#else + fd = open(filename, O_WRONLY | O_CREAT | O_EXCL | _O_BINARY, 0666); +#endif f->fp = fdopen(fd, "wb"); /* will fail and return NULL if fd < 0 */ if (!f->fp || !write_file_version(f, version)) { int errno_save = errno; @@ -193,7 +230,11 @@ static dbFILE *open_db_write(const char *service, const char *filename, #endif if (f->fp) { fclose(f->fp); +#ifndef _WIN32 unlink(filename); +#else + DeleteFile(filename); +#endif } if (*f->backupname && rename(f->backupname, filename) < 0) #ifndef NOT_MAIN @@ -283,7 +324,11 @@ void restore_db(dbFILE * f) if (f->backupfp) fclose(f->backupfp); if (*f->backupname) +#ifndef _WIN32 unlink(f->backupname); +#else + DeleteFile(f->backupname); +#endif } fclose(f->fp); if (!errno_save) @@ -306,7 +351,11 @@ void close_db(dbFILE * f) && strcmp(f->backupname, f->filename) != 0) { if (f->backupfp) fclose(f->backupfp); +#ifndef _WIN32 unlink(f->backupname); +#else + DeleteFile(f->backupname); +#endif } fclose(f->fp); free(f); @@ -539,19 +588,47 @@ static void remove_backups(void) strftime(ext, sizeof(ext), "%Y%m%d", &tm); snprintf(path, sizeof(path), "backups/%s.%s", NickDBName, ext); +#ifndef _WIN32 unlink(path); +#else + DeleteFile(path); +#endif snprintf(path, sizeof(path), "backups/%s.%s", BotDBName, ext); +#ifndef _WIN32 unlink(path); +#else + DeleteFile(path); +#endif snprintf(path, sizeof(path), "backups/%s.%s", ChanDBName, ext); +#ifndef _WIN32 unlink(path); +#else + DeleteFile(path); +#endif snprintf(path, sizeof(path), "backups/%s.%s", OperDBName, ext); +#ifndef _WIN32 unlink(path); +#else + DeleteFile(path); +#endif snprintf(path, sizeof(path), "backups/%s.%s", NewsDBName, ext); +#ifndef _WIN32 unlink(path); +#else + DeleteFile(path); +#endif snprintf(path, sizeof(path), "backups/%s.%s", ExceptionDBName, ext); +#ifndef _WIN32 unlink(path); +#else + DeleteFile(path); +#endif snprintf(path, sizeof(path), "backups/%s.%s", HostDBName, ext); +#ifndef _WIN32 unlink(path); +#else + DeleteFile(path); +#endif } /*************************************************************************/ diff --git a/src/dreamforge.c b/src/dreamforge.c index 4193b9df9..8d90704ec 100644 --- a/src/dreamforge.c +++ b/src/dreamforge.c @@ -100,6 +100,7 @@ IRCDVar ircd[] = { 0, /* +I support */ 0, /* SJOIN ban char */ 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ 0, /* Can remove User Channel Modes with SVSMODE */ 0, /* Sglines are not enforced until user reconnects */ NULL, /* vhost char */ @@ -619,6 +620,9 @@ void anope_pong(char *servname) void anope_cmd_connect(int servernum) { + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); + anope_cmd_capab(); if (servernum == 1) anope_cmd_pass(RemotePassword); diff --git a/src/hybrid.c b/src/hybrid.c index e8ddbe477..8ab40ce4a 100644 --- a/src/hybrid.c +++ b/src/hybrid.c @@ -100,6 +100,7 @@ IRCDVar ircd[] = { 0, /* +I support */ 0, /* SJOIN ban char */ 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ 0, /* Can remove User Channel Modes with SVSMODE */ 0, /* Sglines are not enforced until user reconnects */ NULL, /* vhost char */ @@ -778,6 +779,9 @@ void anope_cmd_svsmode(User * u, int ac, char **av) void anope_cmd_connect(int servernum) { + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); + if (servernum == 1) anope_cmd_pass(RemotePassword); else if (servernum == 2) diff --git a/src/init.c b/src/init.c index 2b77668eb..e26378dfb 100644 --- a/src/init.c +++ b/src/init.c @@ -440,8 +440,9 @@ int init(int ac, char **av) } /* Read configuration file; exit if there are problems. */ - if (!read_config(0)) + if (!read_config(0)) { return -1; + } /* Add IRCD Message handlers */ moduleAddIRCDMsgs(); @@ -452,7 +453,7 @@ int init(int ac, char **av) /* Parse all remaining command-line options. */ parse_options(ac, av); - /* Detach ourselves if requested. */ +#ifndef _WIN32 if (!nofork) { if ((i = fork()) < 0) { perror("fork()"); @@ -470,6 +471,21 @@ int init(int ac, char **av) return -1; } } +#else + /* Initialize winsocks -- codemastr */ + { + WSADATA wsa; + if (WSAStartup(MAKEWORD(1, 1), &wsa)) { + alog("Failed to initialized WinSock library"); + return -1; + } + } + if (!nofork) { + alog("Launching Anope into the background"); + FreeConsole(); + } +#endif + /* Write our PID to the PID file. */ write_pidfile(); @@ -515,21 +531,27 @@ int init(int ac, char **av) } #endif signal(SIGTERM, sighandler); +#ifndef _WIN32 signal(SIGQUIT, sighandler); +#endif if (!DumpCore) { signal(SIGSEGV, sighandler); +#ifndef _WIN32 signal(SIGBUS, sighandler); - signal(SIGILL, sighandler); signal(SIGTRAP, sighandler); +#endif } else { signal(SIGSEGV, SIG_DFL); - signal(SIGBUS, SIG_DFL); - signal(SIGILL, SIG_DFL); - signal(SIGTRAP, SIG_DFL); +#ifndef _WIN32 + signal(SIGBUS, sighandler); + signal(SIGTRAP, sighandler); +#endif } +#ifndef _WIN32 signal(SIGQUIT, sighandler); signal(SIGHUP, sighandler); signal(SIGUSR2, sighandler); +#endif #ifdef SIGIOT signal(SIGIOT, sighandler); @@ -537,8 +559,10 @@ int init(int ac, char **av) signal(SIGFPE, sighandler); #if !defined(USE_THREADS) || !defined(LINUX20) +#ifndef _WIN32 signal(SIGUSR1, sighandler); /* This is our "out-of-memory" panic switch */ #endif +#endif /* Initialize multi-language support */ lang_init(); @@ -659,15 +683,6 @@ int init(int ac, char **av) alog("Info: Not reflecting database records."); } #endif - /* Make myself known to myself in the serverlist */ - if (UseTS6 && ircd->ts6) { - me_server = - new_server(NULL, ServerName, ServerDesc, SERVER_ISME, TS6SID); - } else { - me_server = - new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); - } - /* Connect to the remote server */ servsock = conn(RemoteServer, RemotePort, LocalHost, LocalPort); if (servsock < 0 && RemoteServer2) { diff --git a/src/language.c b/src/language.c index a43e03d65..849d7a4a6 100644 --- a/src/language.c +++ b/src/language.c @@ -73,7 +73,11 @@ static void load_lang(int index, const char *filename) index, filename); } snprintf(buf, sizeof(buf), "languages/%s", filename); +#ifndef _WIN32 if (!(f = fopen(buf, "r"))) { +#else + if (!(f = fopen(buf, "rb"))) { +#endif log_perror("Failed to load language %d (%s)", index, filename); return; } else if (read_int32(&num, f) < 0) { @@ -58,7 +58,11 @@ static void remove_log(void) if (!get_logname(name, sizeof(name), &tm)) return; +#ifndef _WIN32 unlink(name); +#else + DeleteFile(name); +#endif } /*************************************************************************/ @@ -314,3 +318,48 @@ void fatal_perror(const char *fmt, ...) } /*************************************************************************/ + +/* Same thing, but do it like perror(). + * This is for socket errors. On *nix, it works just like fatal_perror, + * on Win32, it uses the socket error code and formatting functions. + */ + +void fatal_sockerror(const char *fmt, ...) +{ + va_list args; + time_t t; + struct tm tm; + char buf[256], buf2[4096]; + int errno_save = ano_sockgeterr(); + + checkday(); + + va_start(args, fmt); + time(&t); + tm = *localtime(&t); +#if HAVE_GETTIMEOFDAY + if (debug) { + char *s; + struct timeval tv; + gettimeofday(&tv, NULL); + strftime(buf, sizeof(buf) - 1, "[%b %d %H:%M:%S", &tm); + s = buf + strlen(buf); + s += snprintf(s, sizeof(buf) - (s - buf), ".%06d", tv.tv_usec); + strftime(s, sizeof(buf) - (s - buf) - 1, " %Y] ", &tm); + } else { +#endif + strftime(buf, sizeof(buf) - 1, "[%b %d %H:%M:%S %Y] ", &tm); +#if HAVE_GETTIMEOFDAY + } +#endif + vsnprintf(buf2, sizeof(buf2), fmt, args); + if (logfile) + fprintf(logfile, "%sFATAL: %s: %s\n", buf, buf2, + ano_sockstrerror(errno_save)); + if (stderr) + fprintf(stderr, "%sFATAL: %s: %s\n", buf, buf2, + ano_sockstrerror(errno_save)); + if (servsock >= 0) + wallops(NULL, "FATAL ERROR! %s: %s", buf2, strerror(errno_save)); + exit(1); +} diff --git a/src/main.c b/src/main.c index 6ff76b67f..d75a88f00 100644 --- a/src/main.c +++ b/src/main.c @@ -282,6 +282,7 @@ static void services_shutdown(void) void sighandler(int signum) { if (started) { +#ifndef _WIN32 if (signum == SIGHUP) { /* SIGHUP = save databases and restart */ signal(SIGHUP, SIG_IGN); signal(SIGUSR2, SIG_IGN); @@ -300,7 +301,8 @@ void sighandler(int signum) quitmsg = "Restart attempt failed--SERVICES_BIN not defined (rerun configure)"; #endif - + } else if (signum == SIGQUIT) { + /* had to move it to here to make win32 happy */ } else if (signum == SIGUSR2) { alog("Received SIGUSR2: Saving Databases & Rehash Configuration"); @@ -315,9 +317,13 @@ void sighandler(int signum) } return; - } else if (signum == SIGTERM) { + } else +#endif + if (signum == SIGTERM) { signal(SIGTERM, SIG_IGN); +#ifndef _WIN32 signal(SIGHUP, SIG_IGN); +#endif alog("Received SIGTERM, exiting."); @@ -326,7 +332,6 @@ void sighandler(int signum) quitmsg = "Shutting down on SIGTERM"; services_shutdown(); exit(0); - } else if (signum == SIGINT) { if (nofork) { signal(SIGINT, SIG_IGN); @@ -337,8 +342,6 @@ void sighandler(int signum) services_shutdown(); exit(0); } - } else if (signum == SIGQUIT) { - /* nothing -- terminate below */ } else if (!waiting) { alog("PANIC! buffer = %s", inbuf); /* Cut off if this would make IRC command >510 characters. */ @@ -347,7 +350,7 @@ void sighandler(int signum) inbuf[447] = '>'; inbuf[448] = 0; } - anope_cmd_global(NULL, "PANIC! buffer = %s\r\n", inbuf); + wallops(NULL, "PANIC! buffer = %s\r\n", inbuf); } else if (waiting < 0) { /* This is static on the off-chance we run low on stack */ static char buf[BUFSIZE]; @@ -403,14 +406,13 @@ void sighandler(int signum) default: snprintf(buf, sizeof(buf), "waiting=%d", waiting); } - anope_cmd_global(NULL, "PANIC! %s (%s)", buf, - strsignal(signum)); + wallops(NULL, "PANIC! %s (%s)", buf, strsignal(signum)); alog("PANIC! %s (%s)", buf, strsignal(signum)); } } if ( -#if !defined(USE_THREADS) || !defined(LINUX20) +#if (!defined(USE_THREADS) || !defined(LINUX20)) && !defined(_WIN32) signum == SIGUSR1 || #endif !(quitmsg = calloc(BUFSIZE, 1))) { @@ -599,6 +601,7 @@ int main(int ac, char **av, char **envp) void do_backtrace(int show_segheader) { +#ifndef _WIN32 #ifdef HAVE_BACKTRACE void *array[50]; size_t size; @@ -619,9 +622,9 @@ void do_backtrace(int show_segheader) free(strings); alog("Backtrace: complete"); #else - if (show_segheader) { - alog("Backtrace: Segmentation fault detected"); - } - alog("Backtrace: not available on this system"); + alog("Backtrace: not available on this platform"); +#endif +#else + alog("Backtrace: not available on this windows"); #endif } diff --git a/src/makefile.win32 b/src/makefile.win32 new file mode 100644 index 000000000..e7434cdba --- /dev/null +++ b/src/makefile.win32 @@ -0,0 +1,107 @@ +# Make file for Win32 +# +# (C) 2003-2005 Anope Team +# Contact us at info@anope.org +# +# Please read COPYING and README for further details. +# +# Based on the original code of Epona by Lara. +# Based on the original code of Services by Andy Church. +# +# $Id:$ +# + +# Source Makefile + +include ../Makefile.inc.win32 + +########################################################################### + +OBJS = actions.obj base64.obj botserv.obj channels.obj chanserv.obj commands.obj compat.obj \ + converter.obj config.obj datafiles.obj encrypt.obj helpserv.obj hostserv.obj \ + init.obj language.obj list.obj log.obj mail.obj main.obj memory.obj memoserv.obj \ + messages.obj misc.obj modules.obj news.obj nickserv.obj operserv.obj \ + process.obj proxy.obj send.obj servers.obj sessions.obj slist.obj sockutil.obj \ + timeout.obj users.obj $(RDB_O) $(MYSQL_O) $(CAPAB_O) + +SRCS = actions.c base64.c botserv.c channels.c chanserv.c commands.c compat.c converter.c \ + config.c datafiles.c encrypt.c helpserv.c hostserv.c init.c language.c list.c log.c mail.c main.c \ + memory.c memoserv.c messages.c misc.c modules.c news.c nickserv.c operserv.c \ + process.c proxy.c send.c servers.obj sessions.c slist.c sockutil.c \ + timeout.c users.c $(RDB_C) $(MYSQL_C) $(CAPAB_C) + +########################################################################### + +.c.obj: + $(CC) $(CFLAGS) $(IRCTYPE) -c $< + +all: $(PROGRAM) + +$(PROGRAM): $(OBJS) win32.res + $(CC) $(OBJS) win32.res /link /out:$(PROGRAM) /implib:anope.lib $(LIBS) $(LFLAGS) $(MLIBS) $(ELIBS) + +spotless: + -@erase *.obj *.exe *.exp *.lib tools\*.exe *.res + +install: + -@copy anope.exe ..\anope.exe + -@copy tools\anopesmtp.exe ..\anopesmtp.exe + -@mkdir ..\$(DATDEST)\bin + -@copy bin\* ..\$(DATDEST)\bin + +win32.res: win32.rc + $(RC) /l 0x409 /fowin32.res win32.rc + + +########################################################################### + +# Catch any changes in compilation options at the top of this file +$(OBJS): + +actions.obj: actions.c ..\include\services.h +base64.obj: base64.c ..\include\services.h +botserv.obj: botserv.c ..\include\services.h ..\include\pseudo.h ..\include\language.h +channels.obj: channels.c ..\include\services.h +chanserv.obj: chanserv.c ..\include\services.h ..\include\pseudo.h +commands.obj: commands.c ..\include\services.h ..\include\commands.h ..\include\language.h +compat.obj: compat.c ..\include\services.h +config.obj: config.c ..\include\services.h +converter.obj: converter.c ..\include\services.h ..\include\datafiles.h +datafiles.obj: datafiles.c ..\include\services.h ..\include\datafiles.h +encrypt.obj: encrypt.c ..\include\encrypt.h ..\include\sysconf.h +init.obj: init.c ..\include\services.h +hostserv.obj: hostserv.c ..\include\services.h ..\include\pseudo.h +language.obj: language.c ..\include\services.h ..\include\language.h +list.obj: list.c ..\include\services.h +log.obj: log.c ..\include\services.h ..\include\pseudo.h +mail.obj: mail.c ..\include\services.h ..\include\language.h +main.obj: main.c ..\include\services.h ..\include\timeout.h ..\include\version.h +memory.obj: memory.c ..\include\services.h +memoserv.obj: memoserv.c ..\include\services.h ..\include\pseudo.h +messages.obj: messages.c ..\include\services.h ..\include\messages.h ..\include\language.h +misc.obj: misc.c ..\include\services.h ..\include\language.h +news.obj: news.c ..\include\services.h ..\include\pseudo.h +nickserv.obj: nickserv.c ..\include\services.h ..\include\pseudo.h +operserv.obj: operserv.c ..\include\services.h ..\include\pseudo.h +process.obj: process.c ..\include\services.h ..\include\messages.h +proxy.obj: proxy.c ..\include\services.h ..\include\pseudo.h +send.obj: send.c ..\include\services.h +servers.obj: servers.c ..\include\services.h +sessions.obj: sessions.c ..\include\services.h ..\include\pseudo.h +slist.obj: slist.c ..\include\services.h ..\include\slist.h +sockutil.obj: sockutil.c ..\include\services.h +timeout.obj: timeout.c ..\include\services.h ..\include\timeout.h +users.obj: users.c ..\include\services.h +vsnprintf.obj: vsnprintf.c + +########################################################################### + +..\include\services.h: ..\include\sysconf.h ..\include\config.h ..\include\extern.h + +..\include\extern.h: ..\include\slist.h + +..\include\pseudo.h: ..\include\commands.h ..\include\language.h ..\include\timeout.h ..\include\encrypt.h ..\include\datafiles.h ..\include\slist.h + +########################################################################### + +FRC: diff --git a/src/memory.c b/src/memory.c index 415853416..6c1d8dda7 100644 --- a/src/memory.c +++ b/src/memory.c @@ -38,10 +38,14 @@ void *smalloc(long size) buf = malloc(size); if (!buf) #if !defined(USE_THREADS) || !defined(LINUX20) +#ifndef _WIN32 raise(SIGUSR1); #else abort(); #endif +#else + abort(); +#endif return buf; } @@ -63,10 +67,14 @@ void *scalloc(long elsize, long els) buf = calloc(elsize, els); if (!buf) #if !defined(USE_THREADS) || !defined(LINUX20) +#ifndef _WIN32 raise(SIGUSR1); #else abort(); #endif +#else + abort(); +#endif return buf; } @@ -88,10 +96,14 @@ void *srealloc(void *oldptr, long newsize) buf = realloc(oldptr, newsize); if (!buf) #if !defined(USE_THREADS) || !defined(LINUX20) +#ifndef _WIN32 raise(SIGUSR1); #else abort(); #endif +#else + abort(); +#endif return buf; } @@ -116,10 +128,14 @@ char *sstrdup(const char *src) #endif if (!ret) #if !defined(USE_THREADS) || !defined(LINUX20) +#ifndef _WIN32 raise(SIGUSR1); #else abort(); #endif +#else + abort(); +#endif } else { alog("sstrdup() called with NULL-arg"); if (debug) diff --git a/src/modules.c b/src/modules.c index 32791dfd5..01d1571f3 100644 --- a/src/modules.c +++ b/src/modules.c @@ -16,7 +16,7 @@ #include "language.h" #include "version.h" -#ifdef USE_MODULES +#if defined(USE_MODULES) && !defined(_WIN32) #include <dlfcn.h> /* Define these for systems without them */ #ifndef RTLD_NOW @@ -33,6 +33,10 @@ #endif #endif +#ifdef _WIN32 +const char *ano_moderr(void); +#endif + /** * Declare all the list's we want to use here **/ @@ -283,8 +287,8 @@ int moduleCopyFile(char *name) strncat(output, name, 4095 - len); strncat(input, name, 4095 - len); len += strlen(output); - strncat(output, ".so", 4095 - len); - strncat(input, ".so", 4095 - len); + strncat(output, MODULE_EXT, 4095 - len); + strncat(input, MODULE_EXT, 4095 - len); if ((source = fopen(input, "r")) == NULL) { return MOD_ERR_NOEXIST; @@ -344,22 +348,19 @@ int loadModule(Module * m, User * u) buf[4095] = '\0'; m->filename = sstrdup(buf); -#ifdef HAS_RTLD_LOCAL - m->handle = dlopen(m->filename, RTLD_LAZY | RTLD_LOCAL); -#else - m->handle = dlopen(m->filename, RTLD_LAZY); -#endif - if ((err = dlerror()) != NULL) { + ano_modclearerr(); + m->handle = ano_modopen(m->filename); + if ((err = ano_moderr()) != NULL) { alog(err); if (u) { notice_lang(s_OperServ, u, OPER_MODULE_LOAD_FAIL, m->name); } return MOD_ERR_NOLOAD; } - - func = dlsym(m->handle, DL_PREFIX "AnopeInit"); - if ((err = dlerror()) != NULL) { - dlclose(m->handle); /* If no AnopeInit - it isnt an Anope Module, close it */ + ano_modclearerr(); + func = ano_modsym(m->handle, "AnopeInit"); + if ((err = ano_moderr()) != NULL) { + ano_modclose(m->handle); /* If no AnopeInit - it isnt an Anope Module, close it */ return MOD_ERR_NOLOAD; } if (func) { @@ -421,13 +422,13 @@ int unloadModule(Module * m, User * u) return MOD_ERR_UNKNOWN; } - func = dlsym(m->handle, DL_PREFIX "AnopeFini"); + func = ano_modsym(m->handle, "AnopeFini"); if (func) { func(); /* exec AnopeFini */ } - if ((dlclose(m->handle)) != 0) { - alog(dlerror()); + if ((ano_modclose(m->handle)) != 0) { + alog(ano_moderr()); if (u) { notice_lang(s_OperServ, u, OPER_MODULE_REMOVE_FAIL, m->name); } @@ -2094,4 +2095,18 @@ boolean moduleMinVersion(int major, int minor, int patch, int build) return ret; } +#ifdef _WIN32 +const char *ano_moderr(void) +{ + static char errbuf[513]; + DWORD err = GetLastError(); + if (err == 0) + return NULL; + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err, 0, errbuf, 512, + NULL); + return errbuf; +} +#endif + /* EOF */ diff --git a/src/modules/makefile.inc.win32 b/src/modules/makefile.inc.win32 new file mode 100644 index 000000000..95c0c84b1 --- /dev/null +++ b/src/modules/makefile.inc.win32 @@ -0,0 +1,2 @@ +SRCS=hs_moo.c ircd_catserv.c + diff --git a/src/modules/makefile.win32 b/src/modules/makefile.win32 new file mode 100644 index 000000000..a2cca02e8 --- /dev/null +++ b/src/modules/makefile.win32 @@ -0,0 +1,24 @@ +include ../../Makefile.inc.win32 +include ./Makefile.inc.win32 + +OBJECTS= $(SRCS:.c=.dll) +CFLAGS=/LD /MD /D MODULE_COMPILE $(CFLAGS) /I"../../include" +LFLAGS=/link ../anope.lib wsock32.lib libmysql.lib $(LFLAGS) $(MYSQL_LIB_PATH) /export:AnopeInit + +all: $(OBJECTS) + +distclean: clean spotless + +.c.dll: + $(CC) $(CFLAGS) $(IRCTYPE) $< $(LFLAGS) + +clean: + -@del *.obj + +spotless: clean + -@del *.dll *.lib *.exp + +install: + -@mkdir ..\..\$(DATDEST)\modules + -@mkdir ..\..\$(DATDEST)\modules\runtime + -@copy *.dll ..\..\$(DATDEST)\modules diff --git a/src/mypasql.c b/src/mypasql.c new file mode 100644 index 000000000..a66850c84 --- /dev/null +++ b/src/mypasql.c @@ -0,0 +1,122 @@ +#include <winsock.h> +#include <stdio.h> +#include <mysql.h> + +MYSQL *mysql; +MYSQL_RES *result = NULL; +MYSQL_ROW row; + +int __stdcall mysql_Connect(char *server, char *user, char *pass) +{ + mysql = mysql_init(NULL); + return (int) mysql_real_connect(mysql, server, user, pass, NULL, 0, + NULL, 0); +} + +int __stdcall mysql_SelectDb(char *db) +{ + return (int) mysql_select_db(mysql, db); +} + +const char *__stdcall mysql_Error() +{ + return mysql_error(mysql); +} + +int __stdcall mysql_Query(char *query) +{ + if (result) { + mysql_free_result(result); + result = NULL; + } + return (int) mysql_real_query(mysql, query, strlen(query)); +} + +int __stdcall mysql_NumRows() +{ + if (!result) + result = mysql_store_result(mysql); + return mysql_num_rows(result); +} + +char *strip(char *str) +{ + char *c; + if ((c = strrchr(str, '\n'))) + *c = 0; + if ((c = strrchr(str, '\r'))) + *c = 0; + return str; +} + +void add_line(char **buf, char *line) +{ + int oldlen; + char *tmp; + + if (*buf != NULL) { + oldlen = strlen(*buf); + tmp = malloc(oldlen + 1); + strcpy(tmp, *buf); + *buf = realloc(*buf, oldlen + strlen(line) + 1); + strcpy(*buf, tmp); + strcat(*buf, line); + free(tmp); + } else + *buf = strdup(line); +} + +int __stdcall mysql_LoadFromFile(char *file) +{ + FILE *fd = fopen(file, "r"); + char line[1024]; + char *query = NULL; + + + if (!fd) + return 0; + while (fgets(line, 1024, fd)) { + int len; + strip(line); + len = strlen(line); + if (!*line || (*line == '-' && *(line + 1) == '-')) + continue; + else if (line[len - 1] == ';') { /* End of a query */ + line[len - 1] = 0; + add_line(&query, line); + if (mysql_real_query(mysql, query, strlen(query))) { + free(query); + return 0; + } + free(query); + query = NULL; + } + + else + add_line(&query, line); + } + return 1; +} + +int __stdcall mysql_NumFields() +{ + if (!result) + result = mysql_store_result(mysql); + return mysql_num_fields(result); +} + +int __stdcall mysql_FetchRow() +{ + if (!result) + result = mysql_store_result(mysql); + row = mysql_fetch_row(result); + return (int) row; +} + +char *__stdcall mysql_FetchField(int i) +{ + if (i >= mysql_num_fields(result)) + return NULL; + else + return row[i]; +} diff --git a/src/mypasql.def b/src/mypasql.def new file mode 100644 index 000000000..f04df9556 --- /dev/null +++ b/src/mypasql.def @@ -0,0 +1,10 @@ +EXPORTS
+mysql_Connect
+mysql_Error
+mysql_SelectDb
+mysql_Query
+mysql_NumRows
+mysql_NumFields
+mysql_LoadFromFile
+mysql_FetchRow
+mysql_FetchField
diff --git a/src/nickserv.c b/src/nickserv.c index ae97855e4..bf8d5cd99 100644 --- a/src/nickserv.c +++ b/src/nickserv.c @@ -2794,6 +2794,10 @@ static int do_drop(User * u) if (readonly) notice_lang(s_NickServ, u, READ_ONLY_MODE); + if (ircd->sqline && (na->status & NS_VERBOTEN)) { + anope_cmd_unsqline(na->nick); + } + alog("%s: %s!%s@%s dropped nickname %s (group %s) (e-mail: %s)", s_NickServ, u->nick, u->username, common_get_vhost(u), na->nick, na->nc->display, @@ -4267,6 +4271,11 @@ static int do_forbid(User * u) collide(na, 0); } + + if (ircd->sqline) { + anope_cmd_sqline(na->nick, ((reason) ? reason : "Forbidden")); + } + if (WallForbid) anope_cmd_global(s_NickServ, "\2%s\2 used FORBID on \2%s\2", u->nick, nick); diff --git a/src/plexus.c b/src/plexus.c index 8408c9018..21e89b502 100644 --- a/src/plexus.c +++ b/src/plexus.c @@ -100,6 +100,7 @@ IRCDVar ircd[] = { 1, /* +I support */ 0, /* SJOIN ban char */ 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ 0, /* Can remove User Channel Modes with SVSMODE */ 0, /* Sglines are not enforced until user reconnects */ "h", /* vhost char */ @@ -839,6 +840,9 @@ void anope_cmd_svsmode(User * u, int ac, char **av) void anope_cmd_connect(int servernum) { + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); + if (servernum == 1) anope_cmd_pass(RemotePassword); else if (servernum == 2) diff --git a/src/proxy.c b/src/proxy.c index d1c90ff35..f2e7ae96e 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -45,11 +45,16 @@ void ntoa(struct in_addr addr, char *ipaddr, int len) /* Proxy queue; access controlled by queuemut */ SList pxqueue; -pthread_mutex_t queuemut = PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t queuecond = PTHREAD_COND_INITIALIZER; +#ifndef _WIN32 +ano_mutex_t queuemut = PTHREAD_MUTEX_INITIALIZER; +ano_cond_t queuecond = PTHREAD_COND_INITIALIZER; #if !defined(HAVE_GETHOSTBYNAME_R6) && !defined(HAVE_GETHOSTBYNAME_R5) && !defined(HAVE_GETHOSTBYNAME_R3) -pthread_mutex_t resmut = PTHREAD_MUTEX_INITIALIZER; +ano_mutex_t resmut = PTHREAD_MUTEX_INITIALIZER; +#endif +#else +ano_mutex_t queuemut; +ano_cond_t queuecond; #endif static uint32 aton(char *ipaddr); @@ -259,7 +264,7 @@ int proxy_check(char *nick, char *host, uint32 ip) static int proxy_connect(unsigned long ip, unsigned short port) { struct sockaddr_in sin; - int s; + ano_socket_t s; fd_set fds; struct timeval tv; @@ -269,8 +274,8 @@ static int proxy_connect(unsigned long ip, unsigned short port) if ((s = socket(PF_INET, SOCK_STREAM, 0)) == -1) return -1; - if (fcntl(s, F_SETFL, O_NONBLOCK) == -1) { - close(s); + if (ano_socksetnonb(s) == -1) { + ano_sockclose(s); return -1; } @@ -281,8 +286,8 @@ static int proxy_connect(unsigned long ip, unsigned short port) sin.sin_port = htons(port); if (connect(s, (struct sockaddr *) &sin, sizeof(struct sockaddr_in)) == - -1 && errno != EINPROGRESS) { - close(s); + -1 && ano_sockerrnonb(ano_sockgeterr())) { + ano_sockclose(s); return -1; } @@ -293,14 +298,18 @@ static int proxy_connect(unsigned long ip, unsigned short port) tv.tv_usec = 0; if (select(s + 1, NULL, &fds, NULL, &tv) <= 0) { - close(s); + ano_sockclose(s); return -1; } errlen = sizeof(int); +#ifndef _WIN32 if (getsockopt(s, SOL_SOCKET, SO_ERROR, &error, &errlen) == -1 +#else + if (getsockopt(s, SOL_SOCKET, SO_ERROR, (char *) &error, &errlen) == -1 +#endif || error != 0) { - close(s); + ano_sockclose(s); return -1; } @@ -347,14 +356,19 @@ void proxy_expire() int proxy_init(void) { int i; - pthread_t th; + ano_thread_t th; slist_init(&pxqueue); +#ifdef _WIN32 + queuemut = CreateMutex(NULL, FALSE, NULL); + queuecond = CreateEvent(NULL, FALSE, FALSE, NULL); +#endif + for (i = 1; i <= ProxyThreads; i++) { - if (pthread_create(&th, NULL, proxy_thread_main, NULL)) + if (ano_thread_create(th, proxy_thread_main, NULL)) return 0; - if (pthread_detach(th)) + if (ano_thread_detach(th)) return 0; if (debug) alog("debug: Creating proxy thread %ld (%d of %d)", (long) th, @@ -379,8 +393,8 @@ static void proxy_queue_lock(void) { if (debug) alog("debug: Thread %ld: Locking proxy queue mutex", - (long) pthread_self()); - pthread_mutex_lock(&queuemut); + (long) ano_thread_self()); + ano_mutex_lock(queuemut); } /*************************************************************************/ @@ -389,8 +403,8 @@ static void proxy_queue_signal(void) { if (debug) alog("debug: Thread %ld: Signaling proxy queue condition", - (long) pthread_self()); - pthread_cond_signal(&queuecond); + (long) ano_thread_self()); + ano_cond_signal(queuecond); } /*************************************************************************/ @@ -399,8 +413,8 @@ static void proxy_queue_unlock(void) { if (debug) alog("debug: Thread %ld: Unlocking proxy queue mutex", - (long) pthread_self()); - pthread_mutex_unlock(&queuemut); + (long) ano_thread_self()); + ano_mutex_unlock(queuemut); } /*************************************************************************/ @@ -409,8 +423,8 @@ static void proxy_queue_wait(void) { if (debug) alog("debug: Thread %ld: waiting proxy queue condition", - (long) pthread_self()); - pthread_cond_wait(&queuecond, &queuemut); + (long) ano_thread_self()); + ano_cond_wait(queuecond, queuemut); } /*************************************************************************/ @@ -458,9 +472,12 @@ static uint32 proxy_resolve(char *host) struct hostent hent; struct hostent_data data; hentp = gethostbyname_r(host, &hent, &data); +#elif defined(_WIN32) + /* MSVC's gethostbyname is thread safe -- codemastr */ + hentp = gethostbyname(host); #else /* Make it safe that way */ - pthread_mutex_lock(&resmut); + ano_mutex_lock(resmut); hentp = gethostbyname(host); #endif @@ -472,11 +489,11 @@ static uint32 proxy_resolve(char *host) addr.s_addr = ip; ntoa(addr, ipbuf, sizeof(ipbuf)); alog("debug: Thread %ld: resolved %s to %s", - (long) pthread_self(), host, ipbuf); + (long) ano_thread_self(), host, ipbuf); } } -#if !defined(HAVE_GETHOSTBYNAME_R6) && !defined(HAVE_GETHOSTBYNAME_R5) && !defined(HAVE_GETHOSTBYNAME_R3) - pthread_mutex_unlock(&resmut); +#if !defined(HAVE_GETHOSTBYNAME_R6) && !defined(HAVE_GETHOSTBYNAME_R5) && !defined(HAVE_GETHOSTBYNAME_R3) && !defined(_WIN32) + ano_mutex_unlock(resmut); #endif return ip; @@ -520,17 +537,17 @@ static int proxy_scan(uint32 ip) buf[8] = 0; if (send(s, buf, 9, 0) != 9) { - close(s); + ano_sockclose(s); return HC_NORMAL; } if (proxy_read(s, buf, 2) != 2) { - close(s); + ano_sockclose(s); continue; } if (buf[1] == 90) { - close(s); + ano_sockclose(s); return HC_SOCKS4; } @@ -541,19 +558,19 @@ static int proxy_scan(uint32 ip) uint32 sip; if (send(s, "\5\1\0", 3, 0) != 3) { - close(s); + ano_sockclose(s); continue; } memset(buf, 0, sizeof(buf)); if (proxy_read(s, buf, 2) != 2) { - close(s); + ano_sockclose(s); continue; } if (buf[0] != 5 || buf[1] != 0) { - close(s); + ano_sockclose(s); continue; } @@ -572,14 +589,14 @@ static int proxy_scan(uint32 ip) buf[9] = ((unsigned short) ProxyTestPort) & 0xFF; if (send(s, buf, 10, 0) != 10) { - close(s); + ano_sockclose(s); continue; } memset(buf, 0, sizeof(buf)); if (proxy_read(s, buf, 2) != 2) { - close(s); + ano_sockclose(s); continue; } @@ -589,7 +606,7 @@ static int proxy_scan(uint32 ip) } } - close(s); + ano_sockclose(s); } /* Scan for HTTP proxy */ @@ -613,12 +630,12 @@ static int proxy_scan(uint32 ip) if (!strnicmp(buf, "HTTP/1.0 200", 12) || !stricmp(buf, "HTTP/1.1 200 Co")) { /* Apache may return 200 OK even if it's not processing the CONNECT request. :/ */ - close(s); + ano_sockclose(s); return HC_HTTP; } } } - close(s); + ano_sockclose(s); } } @@ -629,11 +646,11 @@ static int proxy_scan(uint32 ip) if (proxy_read(s, buf, 8) == 8) { buf[8] = '\0'; if (!stricmp(buf, "Wingate>") || !stricmp(buf, "Too many")) { - close(s); + ano_sockclose(s); return HC_WINGATE; } } - close(s); + ano_sockclose(s); } return HC_NORMAL; @@ -646,24 +663,24 @@ static int proxy_scan(uint32 ip) static void *proxy_thread_main(void *arg) { while (1) { - pthread_cleanup_push(&proxy_queue_cleanup_unlock, NULL); + ano_cleanup_push(proxy_queue_cleanup_unlock, NULL); proxy_queue_lock(); proxy_queue_wait(); - pthread_cleanup_pop(1); + ano_cleanup_pop(1); /* We loop until there is no more host to check in the list */ while (1) { HostCache *hc = NULL; int status; - pthread_cleanup_push(&proxy_queue_cleanup_unlock, NULL); + ano_cleanup_push(proxy_queue_cleanup_unlock, NULL); proxy_queue_lock(); if (pxqueue.count > 0) { hc = pxqueue.list[0]; hc->status = HC_PROGRESS; slist_delete(&pxqueue, 0); } - pthread_cleanup_pop(1); + ano_cleanup_pop(1); if (!hc) break; diff --git a/src/ptlink.c b/src/ptlink.c index 1cc053d11..56704ffd7 100644 --- a/src/ptlink.c +++ b/src/ptlink.c @@ -100,6 +100,7 @@ IRCDVar ircd[] = { 0, /* +I support */ 0, /* SJOIN ban char */ 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ 0, /* Can remove User Channel Modes with SVSMODE */ 0, /* Sglines are not enforced until user reconnects */ NULL, /* vhost char */ @@ -733,6 +734,9 @@ void anope_cmd_pong(char *servname, char *who) void anope_cmd_connect(int servernum) { + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); + if (servernum == 1) anope_cmd_pass(RemotePassword); else if (servernum == 2) diff --git a/src/rageircd.c b/src/rageircd.c index 8fa7de622..6521e5934 100644 --- a/src/rageircd.c +++ b/src/rageircd.c @@ -101,6 +101,7 @@ IRCDVar ircd[] = { 1, /* +I support */ 0, /* SJOIN ban char */ 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ 0, /* Can remove User Channel Modes with SVSMODE */ 0, /* Sglines are not enforced until user reconnects */ "x", /* vhost char */ @@ -744,6 +745,18 @@ void anope_cmd_pong(char *servname, char *who) void anope_cmd_connect(int servernum) { + char buf[16]; + *buf = '\0'; + + if (Numeric) { + snprintf(buf, sizeof(buf), "%d", Numeric); + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, buf); + } else { + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); + } + if (servernum == 1) anope_cmd_pass(RemotePassword); else if (servernum == 2) diff --git a/src/ratbox.c b/src/ratbox.c index 3339088d0..45046d654 100644 --- a/src/ratbox.c +++ b/src/ratbox.c @@ -102,6 +102,7 @@ IRCDVar ircd[] = { 1, /* +I support */ 0, /* SJOIN ban char */ 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ 0, /* Can remove User Channel Modes with SVSMODE */ 0, /* Sglines are not enforced until user reconnects */ NULL, /* vhost char */ @@ -912,6 +913,14 @@ void anope_cmd_svsmode(User * u, int ac, char **av) void anope_cmd_connect(int servernum) { + /* Make myself known to myself in the serverlist */ + if (UseTS6) { + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, TS6SID); + } else { + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); + } if (servernum == 1) anope_cmd_pass(RemotePassword); else if (servernum == 2) diff --git a/src/sockutil.c b/src/sockutil.c index f6b3df156..d5f390fbf 100644 --- a/src/sockutil.c +++ b/src/sockutil.c @@ -53,15 +53,15 @@ int32 read_buffer_len() * @param int Length of buffer * @return int */ -static int buffered_read(int fd, char *buf, int len) +static int buffered_read(ano_socket_t fd, char *buf, int len) { int nread, left = len; fd_set fds; struct timeval tv = { 0, 0 }; - int errno_save = errno; + int errno_save = ano_sockgeterr(); if (fd < 0) { - errno = EBADF; + ano_sockseterr(SOCKERR_EBADF); return -1; } while (left > 0) { @@ -80,8 +80,8 @@ static int buffered_read(int fd, char *buf, int len) maxread = read_buftop - read_bufend - 1; else maxread = read_buftop - read_bufend; - nread = read(fd, read_bufend, maxread); - errno_save = errno; + nread = ano_sockread(fd, read_bufend, maxread); + errno_save = ano_sockgeterr(); if (debug >= 3) alog("debug: buffered_read wanted %d, got %d", maxread, nread); @@ -118,7 +118,7 @@ static int buffered_read(int fd, char *buf, int len) alog("debug: buffered_read(%d,%p,%d) returning %d", fd, buf, len, len - left); } - errno = errno_save; + ano_sockseterr(errno_save); return len - left; } @@ -130,17 +130,17 @@ static int buffered_read(int fd, char *buf, int len) * @param fd File Pointer * @return int */ -static int buffered_read_one(int fd) +static int buffered_read_one(ano_socket_t fd) { int nread; fd_set fds; struct timeval tv = { 0, 0 }; char c; struct timeval *tvptr = (read_bufend == read_curpos ? NULL : &tv); - int errno_save = errno; + int errno_save = ano_sockgeterr(); if (fd < 0) { - errno = EBADF; + ano_sockseterr(SOCKERR_EBADF); return -1; } FD_ZERO(&fds); @@ -157,8 +157,8 @@ static int buffered_read_one(int fd) maxread = read_buftop - read_bufend - 1; else maxread = read_buftop - read_bufend; - nread = read(fd, read_bufend, maxread); - errno_save = errno; + nread = ano_sockread(fd, read_bufend, maxread); + errno_save = ano_sockgeterr(); if (debug >= 3) alog("debug: buffered_read_one wanted %d, got %d", maxread, nread); @@ -171,7 +171,7 @@ static int buffered_read_one(int fd) if (read_curpos == read_bufend) { /* No more data on socket */ if (debug >= 4) alog("debug: buffered_read_one(%d) returning %d", fd, EOF); - errno = errno_save; + ano_sockseterr(errno_save); return EOF; } c = *read_curpos++; @@ -210,7 +210,7 @@ static int flush_write_buffer(int wait) { fd_set fds; struct timeval tv = { 0, 0 }; - int errno_save = errno; + int errno_save = ano_sockgeterr(); if (write_bufend == write_curpos || write_fd == -1) return 0; @@ -224,8 +224,8 @@ static int flush_write_buffer(int wait) maxwrite = write_buftop - write_curpos - 1; else maxwrite = write_bufend - write_curpos; - nwritten = write(write_fd, write_curpos, maxwrite); - errno_save = errno; + nwritten = ano_sockwrite(write_fd, write_curpos, maxwrite); + errno_save = ano_sockgeterr(); if (debug >= 3) alog("debug: flush_write_buffer wanted %d, got %d", maxwrite, nwritten); @@ -237,7 +237,7 @@ static int flush_write_buffer(int wait) return nwritten; } } - errno = errno_save; + ano_sockseterr(errno_save); return 0; } @@ -250,10 +250,10 @@ static int flush_write_buffer(int wait) * @param len Length to write * @return int */ -static int buffered_write(int fd, char *buf, int len) +static int buffered_write(ano_socket_t fd, char *buf, int len) { int nwritten, left = len; - int errno_save = errno; + int errno_save = ano_sockgeterr(); if (fd < 0) { errno = EBADF; @@ -310,7 +310,7 @@ static int buffered_write(int fd, char *buf, int len) alog("debug: buffered_write(%d,%p,%d) returning %d", fd, buf, len, len - left); } - errno = errno_save; + ano_sockseterr(errno_save); return len - left; } @@ -326,12 +326,12 @@ static int buffered_write(int fd, char *buf, int len) * @return int */ #if 0 -static int buffered_write_one(int c, int fd) +static int buffered_write_one(int c, ano_socket_t fd) { struct timeval tv = { 0, 0 }; if (fd < 0) { - errno = EBADF; + ano_sockseterr(SOCKERR_EBADF); return -1; } write_fd = fd; @@ -373,7 +373,7 @@ static int buffered_write_one(int c, int fd) * @param int to read * @return int */ -int sgetc(int s) +int sgetc(ano_socket_t s) { int c; @@ -408,7 +408,7 @@ int sungetc(int c, int s) * @param s Socket * @return buffer */ -char *sgets(char *buf, int len, int s) +char *sgets(char *buf, int len, ano_socket_t s) { int c = 0; struct timeval tv; @@ -422,7 +422,7 @@ char *sgets(char *buf, int len, int s) tv.tv_usec = 0; while (read_buffer_len() == 0 && (c = select(s + 1, &fds, NULL, NULL, &tv)) < 0) { - if (errno != EINTR) + if (ano_sockgeterr() != EINTR) break; } if (read_buffer_len() == 0 && c == 0) @@ -445,7 +445,7 @@ char *sgets(char *buf, int len, int s) * @param s Socket * @return buffer */ -char *sgets2(char *buf, int len, int s) +char *sgets2(char *buf, int len, ano_socket_t s) { char *str = sgets(buf, len, s); @@ -469,7 +469,7 @@ char *sgets2(char *buf, int len, int s) * @param len Length * @return int */ -int sread(int s, char *buf, int len) +int sread(ano_socket_t s, char *buf, int len) { return buffered_read(s, buf, len); } @@ -482,7 +482,7 @@ int sread(int s, char *buf, int len) * @param str Buffer to write * @return int */ -int sputs(char *str, int s) +int sputs(char *str, ano_socket_t s) { return buffered_write(s, str, strlen(str)); } @@ -496,7 +496,7 @@ int sputs(char *str, int s) * @param ... various args * @return int */ -int sockprintf(int s, char *fmt, ...) +int sockprintf(ano_socket_t s, char *fmt, ...) { va_list args; char buf[16384]; /* Really huge, to try and avoid truncation */ @@ -555,7 +555,7 @@ int conn(const char *host, int port, const char *lhost, int lport) char *addr; #endif struct sockaddr_in sa, lsa; - int sock; + ano_socket_t sock; memset(&lsa, 0, sizeof(lsa)); if (lhost) { @@ -584,7 +584,7 @@ int conn(const char *host, int port, const char *lhost, int lport) #else if (!(addr = pack_ip(host))) { alog("conn(): `%s' is not a valid IP address", host); - errno = EINVAL; + ano_sockseterr(SOCKERR_EINVAL); return -1; } memcpy((char *) &sa.sin_addr, addr, 4); @@ -597,16 +597,16 @@ int conn(const char *host, int port, const char *lhost, int lport) if ((lhost || lport) && bind(sock, (struct sockaddr *) &lsa, sizeof(lsa)) < 0) { - int errno_save = errno; - close(sock); - errno = errno_save; + int errno_save = ano_sockgeterr(); + ano_sockclose(sock); + ano_sockseterr(errno_save); return -1; } if (connect(sock, (struct sockaddr *) &sa, sizeof(sa)) < 0) { - int errno_save = errno; - close(sock); - errno = errno_save; + int errno_save = ano_sockgeterr(); + ano_sockclose(sock); + ano_sockseterr(errno_save); return -1; } @@ -620,8 +620,109 @@ int conn(const char *host, int port, const char *lhost, int lport) * @param s Socket * @return void */ -void disconn(int s) +void disconn(ano_socket_t s) { shutdown(s, 2); - close(s); + ano_sockclose(s); } + +/*************************************************************************/ +/* Windows support functions */ + +#ifdef _WIN32 +/* Microsoft makes things nice and fun for us! */ +struct u_WSA_errors { + int error_code; + char *error_string; +}; + +/* Must be sorted ascending by error code */ +struct u_WSA_errors WSAErrors[] = { + {WSAEINTR, "Interrupted system call"}, + {WSAEBADF, "Bad file number"}, + {WSAEACCES, "Permission denied"}, + {WSAEFAULT, "Bad address"}, + {WSAEINVAL, "Invalid argument"}, + {WSAEMFILE, "Too many open sockets"}, + {WSAEWOULDBLOCK, "Operation would block"}, + {WSAEINPROGRESS, "Operation now in progress"}, + {WSAEALREADY, "Operation already in progress"}, + {WSAENOTSOCK, "Socket operation on non-socket"}, + {WSAEDESTADDRREQ, "Destination address required"}, + {WSAEMSGSIZE, "Message too long"}, + {WSAEPROTOTYPE, "Protocol wrong type for socket"}, + {WSAENOPROTOOPT, "Bad protocol option"}, + {WSAEPROTONOSUPPORT, "Protocol not supported"}, + {WSAESOCKTNOSUPPORT, "Socket type not supported"}, + {WSAEOPNOTSUPP, "Operation not supported on socket"}, + {WSAEPFNOSUPPORT, "Protocol family not supported"}, + {WSAEAFNOSUPPORT, "Address family not supported"}, + {WSAEADDRINUSE, "Address already in use"}, + {WSAEADDRNOTAVAIL, "Can't assign requested address"}, + {WSAENETDOWN, "Network is down"}, + {WSAENETUNREACH, "Network is unreachable"}, + {WSAENETRESET, "Net connection reset"}, + {WSAECONNABORTED, "Software caused connection abort"}, + {WSAECONNRESET, "Connection reset by peer"}, + {WSAENOBUFS, "No buffer space available"}, + {WSAEISCONN, "Socket is already connected"}, + {WSAENOTCONN, "Socket is not connected"}, + {WSAESHUTDOWN, "Can't send after socket shutdown"}, + {WSAETOOMANYREFS, "Too many references, can't splice"}, + {WSAETIMEDOUT, "Connection timed out"}, + {WSAECONNREFUSED, "Connection refused"}, + {WSAELOOP, "Too many levels of symbolic links"}, + {WSAENAMETOOLONG, "File name too long"}, + {WSAEHOSTDOWN, "Host is down"}, + {WSAEHOSTUNREACH, "No route to host"}, + {WSAENOTEMPTY, "Directory not empty"}, + {WSAEPROCLIM, "Too many processes"}, + {WSAEUSERS, "Too many users"}, + {WSAEDQUOT, "Disc quota exceeded"}, + {WSAESTALE, "Stale NFS file handle"}, + {WSAEREMOTE, "Too many levels of remote in path"}, + {WSASYSNOTREADY, "Network subsystem is unavailable"}, + {WSAVERNOTSUPPORTED, "Winsock version not supported"}, + {WSANOTINITIALISED, "Winsock not yet initialized"}, + {WSAHOST_NOT_FOUND, "Host not found"}, + {WSATRY_AGAIN, "Non-authoritative host not found"}, + {WSANO_RECOVERY, "Non-recoverable errors"}, + {WSANO_DATA, "Valid name, no data record of requested type"}, + {WSAEDISCON, "Graceful disconnect in progress"}, +#ifdef WSASYSCALLFAILURE + {WSASYSCALLFAILURE, "System call failure"}, +#endif + {0, NULL} +}; + +char *ano_sockstrerror(int error) +{ + static char unkerr[64]; + int start = 0; + int stop = sizeof(WSAErrors) / sizeof(WSAErrors[0]) - 1; + int mid; + + /* Microsoft decided not to use sequential numbers for the error codes, + * so we can't just use the array index for the code. But, at least + * use a binary search to make it as fast as possible. + */ + while (start <= stop) { + mid = (start + stop) / 2; + if (WSAErrors[mid].error_code > error) + stop = mid - 1; + + else if (WSAErrors[mid].error_code < error) + start = mid + 1; + else + return WSAErrors[mid].error_string; + } + sprintf(unkerr, "Unknown Error: %d", error); + return unkerr; +} + +int ano_socksetnonb(ano_socket_t fd) +{ + int i = 1; + return (!ioctlsocket(fd, FIONBIO, &i) ? -1 : 1); +} +#endif diff --git a/src/solidircd.c b/src/solidircd.c index 80bf21310..ea577a0fa 100644 --- a/src/solidircd.c +++ b/src/solidircd.c @@ -102,6 +102,7 @@ IRCDVar ircd[] = { 1, /* +I support */ 0, /* SJOIN ban char */ 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ 0, /* Can remove User Channel Modes with SVSMODE */ 0, /* Sglines are not enforced until user reconnects */ "v", /* vhost char */ @@ -899,6 +900,9 @@ void anope_cmd_pong(char *servname, char *who) void anope_cmd_connect(int servernum) { + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); + if (servernum == 1) { anope_cmd_pass(RemotePassword); } else if (servernum == 2) { diff --git a/src/tools/anopesmtp.c b/src/tools/anopesmtp.c index 12949c9f9..910caa3bc 100644 --- a/src/tools/anopesmtp.c +++ b/src/tools/anopesmtp.c @@ -20,6 +20,23 @@ static int curday = 0; /*************************************************************************/ +#ifdef _WIN32 +int strcasecmp(const char *s1, const char *s2) +{ + register int c; + + while ((c = tolower(*s1)) == tolower(*s2)) { + if (c == 0) + return 0; + s1++; + s2++; + } + if (c < tolower(*s2)) + return -1; + return 1; +} +#endif + static int get_logname(char *name, int count, struct tm *tm) { diff --git a/src/tools/smtp.h b/src/tools/smtp.h index bce460684..7ffda89e8 100644 --- a/src/tools/smtp.h +++ b/src/tools/smtp.h @@ -24,21 +24,39 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> + +/* Windows does not have: + * unistd.h, grp.h, + * netdb.h, netinet/in.h, + * sys/socket.h, sys/time.h + * Windows requires: + * winsock.h + * -- codemastr + */ + +#ifndef _WIN32 #include <unistd.h> +#endif + #include <signal.h> #include <time.h> #include <errno.h> -#include <grp.h> #include <limits.h> + +#ifndef _WIN32 #include <netdb.h> #include <netinet/in.h> -#include <arpa/inet.h> #include <sys/socket.h> -#include <sys/stat.h> +#else +#include <winsock.h> +#include <windows.h> +#endif + #include <sys/types.h> + +#ifndef _WIN32 #include <sys/time.h> -#include <fcntl.h> -#include <ctype.h> +#endif #ifdef _AIX extern int strcasecmp(const char *, const char *); @@ -49,6 +67,11 @@ extern int connect(int, struct sockaddr *, int); # endif #endif /* _AIX */ +#ifdef _WIN32 +#define PATH_MAX MAX_PATH +#define snprintf _snprintf +#endif + /*************************************************************************/ diff --git a/src/ultimate2.c b/src/ultimate2.c index 7acc22f05..d52ead4ef 100644 --- a/src/ultimate2.c +++ b/src/ultimate2.c @@ -100,6 +100,7 @@ IRCDVar ircd[] = { 0, /* +I support */ 0, /* SJOIN ban char */ 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ 0, /* Can remove User Channel Modes with SVSMODE */ 0, /* Sglines are not enforced until user reconnects */ "x", /* vhost char */ @@ -845,6 +846,9 @@ void anope_cmd_svsmode(User * u, int ac, char **av) void anope_cmd_connect(int servernum) { + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); + anope_cmd_capab(); if (servernum == 1) anope_cmd_pass(RemotePassword); diff --git a/src/ultimate3.c b/src/ultimate3.c index 37fecc9b8..34d9861c2 100644 --- a/src/ultimate3.c +++ b/src/ultimate3.c @@ -102,6 +102,7 @@ IRCDVar ircd[] = { 0, /* +I support */ 0, /* SJOIN ban char */ 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ 0, /* Can remove User Channel Modes with SVSMODE */ 1, /* Sglines are enforced */ "x", /* vhost char */ @@ -1573,9 +1574,8 @@ void anope_cmd_svsnick(char *source, char *guest, time_t when) void anope_cmd_connect(int servernum) { - if (!servernum) { - servernum = 1; - } + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); if (servernum == 1) { anope_cmd_pass(RemotePassword); diff --git a/src/unreal31.c b/src/unreal31.c index 014122cfc..4be075fd2 100644 --- a/src/unreal31.c +++ b/src/unreal31.c @@ -103,6 +103,7 @@ IRCDVar ircd[] = { 0, /* +I support */ 0, /* SJOIN ban char */ 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ 0, /* Can remove User Channel Modes with SVSMODE */ 0, /* Sglines are not enforced until user reconnects */ "x", /* vhost char */ @@ -1127,9 +1128,8 @@ void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost) void anope_cmd_connect(int servernum) { - if (!servernum) { - servernum = 1; - } + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); anope_cmd_protoctl(); if (servernum == 1) { diff --git a/src/unreal32.c b/src/unreal32.c index ddb553422..2e8123f9a 100644 --- a/src/unreal32.c +++ b/src/unreal32.c @@ -99,9 +99,10 @@ IRCDVar ircd[] = { 1, /* We support Unreal TOKENS */ 0, /* TOKENS are CASE Sensitive */ 1, /* TIME STAMPS are BASE64 */ - 0, /* +I support */ + 1, /* +I support */ '&', /* SJOIN ban char */ '\"', /* SJOIN except char */ + '\'', /* SJOIN invite char */ 1, /* Can remove User Channel Modes with SVSMODE */ 0, /* Sglines are not enforced until user reconnects */ "x", /* vhost char */ @@ -1465,8 +1466,16 @@ void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost) void anope_cmd_connect(int servernum) { - if (!servernum) { - servernum = 1; + char buf[16]; + *buf = '\0'; + + if (Numeric) { + snprintf(buf, sizeof(buf), "%d", Numeric); + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, buf); + } else { + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); } anope_cmd_capab(); diff --git a/src/users.c b/src/users.c index ca7c31b60..1979f0283 100644 --- a/src/users.c +++ b/src/users.c @@ -170,9 +170,9 @@ void change_user_realname(User * user, const char *realname) void change_user_username(User * user, const char *username) { - if (user->username) - free(user->username); - user->username = sstrdup(username); + if (user->vident) + free(user->vident); + user->vident = sstrdup(username); if (user->na && (nick_identified(user) || (!(user->na->nc->flags & NI_SECURE) && nick_recognized(user)))) { diff --git a/src/viagra.c b/src/viagra.c index 1599657ba..1cb883789 100644 --- a/src/viagra.c +++ b/src/viagra.c @@ -101,6 +101,7 @@ IRCDVar ircd[] = { 0, /* +I support */ 0, /* SJOIN ban char */ 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ 0, /* Can remove User Channel Modes with SVSMODE */ 0, /* Sglines are not enforced until user reconnects */ "x", /* vhost char */ @@ -797,7 +798,7 @@ void anope_cmd_topic(char *whosets, char *chan, char *whosetit, void anope_cmd_vhost_off(User * u) { send_cmd(NULL, "SVSMODE %s -x", u->nick); - notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostcar); + notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar); } void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost) @@ -951,6 +952,9 @@ void anope_cmd_pong(char *servname, char *who) void anope_cmd_connect(int servernum) { + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); + if (servernum == 1) { anope_cmd_pass(RemotePassword); } else if (servernum == 2) { diff --git a/src/win32.rc b/src/win32.rc new file mode 100644 index 000000000..9a6c716a3 --- /dev/null +++ b/src/win32.rc @@ -0,0 +1,91 @@ +///Microsoft Developer Studio generated resource script.
+//
+#include "../include/resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#define APSTUDIO_HIDDEN_SYMBOLS
+#include "windows.h"
+#undef APSTUDIO_HIDDEN_SYMBOLS
+#include "../include/resource.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifndef _MAC
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VER_ANOPE VERSIONINFO
+ FILEVERSION 1,7,8,0
+ PRODUCTVERSION 1,7,8,0
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "CompanyName", "Anope Dev"
+ VALUE "FileDescription", "Anope IRC Services"
+ VALUE "FileVersion", "1.7.8"
+ VALUE "InternalName", "Anope"
+ VALUE "LegalCopyright", "Copyright (C) 2005"
+ VALUE "OriginalFilename", "anoservices.exe"
+ VALUE "ProductName", "Anope"
+ VALUE "ProductVersion", "1.7.8"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+#endif // !_MAC
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+ICON_APP ICON "anope-icon.ico"
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/version.log b/version.log index dd3bf7b46..9b4162500 100644 --- a/version.log +++ b/version.log @@ -8,10 +8,15 @@ VERSION_MAJOR="1" VERSION_MINOR="7" VERSION_PATCH="8" -VERSION_BUILD="564" +VERSION_BUILD="565" # $Log$ # +# BUILD : 1.7.8 (565) +# BUGS : 293 +# NOTES : Merge of Win32 branch into the main, support for Unreal +I, German language updated, fixed bug vidents not +# updating, Setting and Removal of sqlines on forbid or drop +# # BUILD : 1.7.8 (564) # BUGS : 285 # NOTES : Compiling modules under MacOSX, and fixes up some ChanServ stuff |