summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorsjaz <sjaz@5417fbe8-f217-4b02-8779-1006273d7864>2009-01-01 12:00:20 +0000
committersjaz <sjaz@5417fbe8-f217-4b02-8779-1006273d7864>2009-01-01 12:00:20 +0000
commitc777c8d9aa7cd5c2e9a399727a7fa9985a77fb1c (patch)
tree9e996ae4a1bbb833cec036c5cd4d87a590149e85 /include
Anope Stable Branch
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/stable@1902 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'include')
-rw-r--r--include/Makefile20
-rw-r--r--include/commands.h34
-rw-r--r--include/config.h76
-rw-r--r--include/datafiles.h71
-rw-r--r--include/defs.h40
-rw-r--r--include/depricated.h127
-rw-r--r--include/encrypt.h22
-rw-r--r--include/events.h64
-rw-r--r--include/extern.h1406
-rw-r--r--include/makefile.win3225
-rw-r--r--include/messages.h23
-rw-r--r--include/module.h16
-rw-r--r--include/modules.h383
-rw-r--r--include/pseudo.h20
-rw-r--r--include/resource.h20
-rw-r--r--include/services.h1389
-rw-r--r--include/slist.h50
-rw-r--r--include/sockets.h47
-rw-r--r--include/sysconf.h.in227
-rw-r--r--include/sysconf.h.win3250
-rw-r--r--include/timeout.h50
-rw-r--r--include/version.sh86
-rw-r--r--include/version.sh.c224
23 files changed, 4470 insertions, 0 deletions
diff --git a/include/Makefile b/include/Makefile
new file mode 100644
index 000000000..b5641c71b
--- /dev/null
+++ b/include/Makefile
@@ -0,0 +1,20 @@
+
+all: services.h extern.h pseudo.h version.h
+
+version.h: Makefile version.sh services.h pseudo.h messages.h $(SRCS)
+ sh version.sh
+
+services.h: sysconf.h config.h extern.h
+ touch $@
+
+extern.h: slist.h
+ touch $@
+
+pseudo.h: commands.h timeout.h encrypt.h datafiles.h slist.h
+ touch $@
+
+clean:
+ (rm -f language.h)
+
+distclean: clean
+ (rm -f sysconf.h version.h)
diff --git a/include/commands.h b/include/commands.h
new file mode 100644
index 000000000..bff95eb16
--- /dev/null
+++ b/include/commands.h
@@ -0,0 +1,34 @@
+/* Declarations for command data.
+ *
+ * (C) 2003-2008 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.
+ *
+ * $Id$
+ *
+ */
+
+ #include "modules.h"
+
+/*************************************************************************/
+
+/* Routines for looking up commands. Command lists are arrays that must be
+ * terminated with a NULL name.
+ */
+
+extern MDE Command *lookup_cmd(Command *list, char *name);
+extern void run_cmd(char *service, User *u, Command *list,
+ char *name);
+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 MDE void do_help_limited(char *service, User * u, Command * c);
+extern void do_help_cmd(char *service, User * u, Command *c,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);
+
+/*************************************************************************/
diff --git a/include/config.h b/include/config.h
new file mode 100644
index 000000000..648205e7c
--- /dev/null
+++ b/include/config.h
@@ -0,0 +1,76 @@
+/* Services configuration.
+ *
+ * (C) 2003-2008 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.
+ *
+ * $Id$
+ *
+ */
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+/* Note that most of the options which used to be here have been moved to
+ * services.conf. */
+
+/*************************************************************************/
+
+/******* General configuration *******/
+
+/* Name of configuration file (in Services directory) */
+#define SERVICES_CONF "services.conf"
+
+/* Name of log file (in Services directory) */
+#define LOG_FILENAME "services.log"
+
+/* Maximum amount of data from/to the network to buffer (bytes). */
+#define NET_BUFSIZE 65536
+
+/******* OperServ configuration *******/
+
+/* Define this to enable OperServ's svs commands (superadmin only). */
+ #define USE_OSSVS
+
+/* Define this to enable OperServ's debugging commands (Services root
+ * only). These commands are undocumented; "use the source, Luke!" */
+/* #define DEBUG_COMMANDS */
+
+/******************* END OF USER-CONFIGURABLE SECTION ********************/
+
+/* Size of input buffer (note: this is different from BUFSIZ)
+ * This must be big enough to hold at least one full IRC message, or messy
+ * things will happen. */
+#define BUFSIZE 1024
+
+/* Extra warning: If you change CHANMAX, your ChanServ database will be
+ * unusable.
+ */
+
+/* Maximum length of a channel name, including the trailing null. Any
+ * channels with a length longer than (CHANMAX-1) including the leading #
+ * will not be usable with ChanServ. */
+#define CHANMAX 64
+
+/* Maximum length of a nickname, including the trailing null. This MUST be
+ * at least one greater than the maximum allowable nickname length on your
+ * network, or people will run into problems using Services! The default
+ * (32) works with all servers I know of. */
+#define NICKMAX 32
+
+/* Maximum length of a password */
+#define PASSMAX 32
+
+/* Maximum length of a username */
+#define USERMAX 10
+
+/* Maximum length of a domain */
+#define HOSTMAX 64
+
+/**************************************************************************/
+
+#endif /* CONFIG_H */
diff --git a/include/datafiles.h b/include/datafiles.h
new file mode 100644
index 000000000..71f269252
--- /dev/null
+++ b/include/datafiles.h
@@ -0,0 +1,71 @@
+/* Database file descriptor structure and file handling routine prototypes.
+ *
+ * (C) 2003-2008 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.
+ *
+ * $Id$
+ *
+ */
+
+#ifndef DATAFILES_H
+#define DATAFILES_H
+
+#ifndef _WIN32
+#include <sys/param.h>
+#endif
+
+/*************************************************************************/
+
+typedef struct dbFILE_ dbFILE;
+struct dbFILE_ {
+ int mode; /* 'r' for reading, 'w' for writing */
+ FILE *fp; /* The normal file descriptor */
+ FILE *backupfp; /* Open file pointer to a backup copy of
+ * the database file (if non-NULL) */
+ char filename[MAXPATHLEN]; /* Name of the database file */
+ char backupname[MAXPATHLEN]; /* Name of the backup file */
+};
+
+/*************************************************************************/
+
+/* Prototypes and macros: */
+
+E void check_file_version(dbFILE *f);
+E int get_file_version(dbFILE *f);
+E int write_file_version(dbFILE *f, uint32 version);
+
+E dbFILE *open_db(const char *service, const char *filename, const char *mode, uint32 version);
+E void restore_db(dbFILE *f); /* Restore to state before open_db() */
+E void close_db(dbFILE *f);
+E void backup_databases(void);
+
+#define read_db(f,buf,len) (fread((buf),1,(len),(f)->fp))
+#define write_db(f,buf,len) (fwrite((buf),1,(len),(f)->fp))
+#define getc_db(f) (fgetc((f)->fp))
+
+E int read_int16(uint16 *ret, dbFILE *f);
+E int write_int16(uint16 val, dbFILE *f);
+E int read_int32(uint32 *ret, dbFILE *f);
+E int write_int32(uint32 val, dbFILE *f);
+E int read_ptr(void **ret, dbFILE *f);
+E int write_ptr(const void *ptr, dbFILE *f);
+E int read_string(char **ret, dbFILE *f);
+E int write_string(const char *s, dbFILE *f);
+
+#define read_int8(ret,f) ((*(ret)=fgetc((f)->fp))==EOF ? -1 : 0)
+#define write_int8(val,f) (fputc((val),(f)->fp)==EOF ? -1 : 0)
+#define read_buffer(buf,f) (read_db((f),(buf),sizeof(buf)) == sizeof(buf))
+#define write_buffer(buf,f) (write_db((f),(buf),sizeof(buf)) == sizeof(buf))
+#define read_buflen(buf,len,f) (read_db((f),(buf),(len)) == (len))
+#define write_buflen(buf,len,f) (write_db((f),(buf),(len)) == (len))
+#define read_variable(var,f) (read_db((f),&(var),sizeof(var)) == sizeof(var))
+#define write_variable(var,f) (write_db((f),&(var),sizeof(var)) == sizeof(var))
+
+/*************************************************************************/
+
+#endif /* DATAFILES_H */
diff --git a/include/defs.h b/include/defs.h
new file mode 100644
index 000000000..78371946d
--- /dev/null
+++ b/include/defs.h
@@ -0,0 +1,40 @@
+/* Set default values for any constants that should be in include files but
+ *
+ * (C) 2003-2008 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.
+ *
+ *
+ * $Id$
+ *
+ */
+
+/*************************************************************************/
+
+#ifndef NAME_MAX
+# define NAME_MAX 255
+#endif
+
+#ifndef BUFSIZ
+# define BUFSIZ 256
+#else
+# if BUFSIZ < 256
+# define BUFSIZ 256
+# endif
+#endif
+
+/* Length of an array: */
+#define lenof(a) (sizeof(a) / sizeof(*(a)))
+
+/* Telling compilers about printf()-like functions: */
+#ifdef __GNUC__
+# define FORMAT(type,fmt,start) __attribute__((format(type,fmt,start)))
+#else
+# define FORMAT(type,fmt,start)
+#endif
+
+/*************************************************************************/
diff --git a/include/depricated.h b/include/depricated.h
new file mode 100644
index 000000000..0d2f7073d
--- /dev/null
+++ b/include/depricated.h
@@ -0,0 +1,127 @@
+/* depricated.h
+ *
+ * (C) 2003-2008 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.
+ *
+ *
+ */
+
+/*
+ All of these functions were replaced in 1.7.6, you should move your modules
+ to use the new functions
+*/
+
+#define change_user_mode(u, modes, arg) common_svsmode(u, modes, arg)
+#define GetIdent(x) common_get_vident(x)
+#define GetHost(x) common_get_vhost(x)
+
+#define NEWNICK(nick,user,host,real,modes,qline) \
+ anope_cmd_bot_nick(nick,user,host,real,modes)
+
+#define s_akill(user, host, who, when, expires, reason) \
+ anope_cmd_akill(user, host, who, when, expires, reason)
+
+#define set_umode(user, ac, av) anope_set_umode(user, ac, av)
+
+#define s_svsnoop(server, set) anope_cmd_svsnoop(server, set)
+
+#define s_sqline(mask, reason) anope_cmd_sqline(mask, reason)
+
+#define s_sgline(mask, reason) anope_cmd_sgline(mask, reason)
+#define s_szline(mask, reason) anope_cmd_szline(mask, reason)
+#define s_unsgline(mask) anope_cmd_unsgline(mask)
+#define s_unsqline(mask) anope_cmd_unsqline(mask)
+#define s_unszline(mask) anope_cmd_unszline(mask)
+
+#define s_rakill(user, host) anope_cmd_remove_akill(user, host)
+
+
+# define NICKSERV_MODE ircd->nickservmode
+# define CHANSERV_MODE ircd->chanservmode
+# define HOSTSERV_MODE ircd->hostservmode
+# define MEMOSERV_MODE ircd->memoservmode
+# define BOTSERV_MODE ircd->botservmode
+# define HELPSERV_MODE ircd->helpservmode
+# define OPERSERV_MODE ircd->oprservmode
+# define DEVNULL_MODE ircd->devnullmode
+# define GLOBAL_MODE ircd->globalmode
+# define NICKSERV_ALIAS_MODE ircd->nickservaliasmode
+# define CHANSERV_ALIAS_MODE ircd->chanservaliasmode
+# define MEMOSERV_ALIAS_MODE ircd->memoservaliasmode
+# define BOTSERV_ALIAS_MODE ircd->botservaliasmode
+# define HELPSERV_ALIAS_MODE ircd->helpservaliasmode
+# define OPERSERV_ALIAS_MODE ircd->operservaliasmode
+# define DEVNULL_ALIAS_MODE ircd->devnullaliasmode
+# define GLOBAL_ALIAS_MODE ircd->globalaliasmode
+# define HOSTSERV_ALIAS_MODE ircd->hostservaliasmode
+# define BOTSERV_BOTS_MODE ircd->botserv_bot_mode
+#define CHAN_MAX_SYMBOL ircd->max_symbols
+#define MODESTOREMOVE ircd->modestoremove
+
+#ifdef IRC_HYBRID
+# define HAS_HALFOP
+# define HAS_EXCEPT
+#endif
+
+#ifdef IRC_VIAGRA
+# define HAS_HALFOP
+# define HAS_VHOST
+# define HAS_VIDENT
+# define HAS_EXCEPT
+#endif
+
+#ifdef IRC_BAHAMUT
+# define HAS_NICKIP
+# define HAS_EXCEPT
+# define HAS_SVSHOLD
+#endif
+
+#ifdef IRC_RAGE2
+# define HAS_HALFOP
+# define HAS_EXCEPT
+# define HAS_VHOST
+# define HAS_NICKVHOST
+#endif
+
+#ifdef IRC_PTLINK
+# define HAS_NICKVHOST
+# define HAS_VHOST
+# define HAS_FMODE
+# define HAS_EXCEPT
+#endif
+
+#ifdef IRC_ULTIMATE2
+# define IRC_ULTIMATE /* gotta do this for old mods */
+# define HAS_FMODE
+# define HAS_HALFOP
+# define HAS_LMODE
+# define HAS_VHOST
+# define HAS_VIDENT
+# define HAS_EXCEPT
+#endif
+
+#if defined(IRC_UNREAL31) || defined(IRC_UNREAL32)
+# define IRC_UNREAL /* gotta do this for old mods */
+# define HAS_FMODE
+# define HAS_HALFOP
+# define HAS_LMODE
+# define HAS_NICKVHOST
+# define HAS_VHOST
+# define HAS_VIDENT
+# define HAS_EXCEPT
+#endif
+
+#ifdef IRC_ULTIMATE3
+# define HAS_HALFOP
+# define HAS_VHOST
+# define HAS_NICKVHOST
+# define HAS_VIDENT
+# define HAS_EXCEPT
+#endif
+
+
diff --git a/include/encrypt.h b/include/encrypt.h
new file mode 100644
index 000000000..7ac3d884a
--- /dev/null
+++ b/include/encrypt.h
@@ -0,0 +1,22 @@
+/* Include file for high-level encryption routines.
+ *
+ * (C) 2003-2008 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.
+ *
+ * $Id$
+ *
+ */
+
+typedef struct encryption_ {
+ int (*encrypt)(const char *src, int len, char *dest, int size);
+ int (*encrypt_in_place)(char *buf, int size);
+ int (*encrypt_check_len)(int passlen, int bufsize);
+ int (*decrypt)(const char *src, char *dest, int size);
+ int (*check_password)(const char *plaintext, const char *password);
+} Encryption;
+
diff --git a/include/events.h b/include/events.h
new file mode 100644
index 000000000..77ec0bf8e
--- /dev/null
+++ b/include/events.h
@@ -0,0 +1,64 @@
+/* Prototypes and external variable declarations.
+ *
+ * (C) 2003-2008 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.
+ *
+ * $Id$
+ *
+ */
+
+#define EVENT_START "start"
+#define EVENT_STOP "stop"
+
+#define EVENT_DB_SAVING "db_saving"
+#define EVENT_DB_BACKUP "db_backup"
+#define EVENT_NEWNICK "newnick"
+#define EVENT_BOT_UNASSIGN "bot_unassign"
+#define EVENT_BOT_JOIN "bot_join"
+#define EVENT_BOT_CREATE "bot_create"
+#define EVENT_BOT_CHANGE "bot_change"
+#define EVENT_BOT_FANTASY "bot_command"
+#define EVENT_BOT_FANTASY_NO_ACCESS "bot_command_no_access"
+#define EVENT_BOT_DEL "bot_del"
+#define EVENT_BOT_ASSIGN "bot_assign"
+#define EVENT_BOT_KICK "bot_kick"
+#define EVENT_BOT_BAN "bot_ban"
+#define EVENT_TOPIC_UPDATED "chan_topic_updated"
+#define EVENT_CHAN_EXPIRE "chan_expire"
+#define EVENT_CHAN_REGISTERED "chan_registered"
+#define EVENT_CHAN_DROP "chan_dropped"
+#define EVENT_CHAN_FORBIDDEN "chan_forbidden"
+#define EVENT_CHAN_SUSPENDED "chan_suspended"
+#define EVENT_CHAN_UNSUSPEND "chan_unsuspend"
+#define EVENT_CONNECT "connect"
+#define EVENT_DB_EXPIRE "db_expire"
+#define EVENT_RESTART "restart"
+#define EVENT_RELOAD "reload"
+#define EVENT_SHUTDOWN "shutdown"
+#define EVENT_SIGNAL "signal"
+#define EVENT_NICK_REGISTERED "nick_registered"
+#define EVENT_NICK_DROPPED "nick_dropped"
+#define EVENT_NICK_FORBIDDEN "nick_forbidden"
+#define EVENT_NICK_EXPIRE "nick_expire"
+#define EVENT_CHANGE_NICK "change_nick"
+#define EVENT_USER_LOGOFF "user_logoff"
+#define EVENT_GROUP "nick_group"
+#define EVENT_NICK_IDENTIFY "nick_id"
+#define EVENT_SERVER_SQUIT "server_squit"
+#define EVENT_SERVER_CONNECT "server_connect"
+#define EVENT_DEFCON_LEVEL "defcon_level"
+#define EVENT_NICK_SUSPENDED "nick_suspended"
+#define EVENT_NICK_UNSUSPEND "nick_unsuspend"
+#define EVENT_JOIN_CHANNEL "join_channel"
+#define EVENT_PART_CHANNEL "part_channel"
+#define EVENT_ACCESS_ADD "access_add"
+#define EVENT_ACCESS_CHANGE "access_change"
+#define EVENT_ACCESS_DEL "access_del"
+#define EVENT_ACCESS_CLEAR "access_clear"
+#define EVENT_NICK_LOGOUT "nick_logout"
+#define EVENT_CHAN_KICK "chan_kick"
diff --git a/include/extern.h b/include/extern.h
new file mode 100644
index 000000000..89e03689b
--- /dev/null
+++ b/include/extern.h
@@ -0,0 +1,1406 @@
+/* Prototypes and external variable declarations.
+ *
+ * (C) 2003-2008 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.
+ *
+ * $Id$
+ *
+ */
+
+#ifndef EXTERN_H
+#define EXTERN_H
+
+#ifndef _WIN32
+#define E extern
+#define EI extern
+#else
+#ifndef MODULE_COMPILE
+#define E extern __declspec(dllexport)
+#define EI extern __declspec(dllimport)
+#else
+#define E extern __declspec(dllimport)
+#define EI extern __declspec(dllexport)
+#endif
+#endif
+
+#include "slist.h"
+
+E void ModuleRunTimeDirCleanUp(void);
+
+
+E char *uplink;
+
+/* IRC Variables */
+
+E IRCDVar *ircd;
+E IRCDCAPAB *ircdcap;
+E char *flood_mode_char_set;
+E char *flood_mode_char_remove;
+E int UseTSMODE; /* hack to get around bahamut clones that don't send TSMODE */
+EI unsigned long umodes[128];
+E char csmodes[128];
+E CMMode cmmodes[128];
+E CBMode cbmodes[128];
+E CBModeInfo *cbmodeinfos;
+E CUMode cumodes[128];
+E char *IRCDModule;
+E IRCDProto ircdproto;
+
+/**** actions.c ****/
+
+E void kill_user(char *source, char *user, char *reason);
+E void bad_password(User * u);
+E void sqline(char *mask, char *reason);
+E void common_unban(ChannelInfo * ci, char *nick);
+E void common_svsmode(User * u, char *modes, char *arg);
+
+/**** botserv.c ****/
+
+E BotInfo *botlists[256];
+E int nbots;
+E void get_botserv_stats(long *nrec, long *memuse);
+E void bs_init(void);
+E void botserv(User *u, char *buf);
+E void botmsgs(User *u, BotInfo *bi, char *buf);
+E void botchanmsgs(User *u, ChannelInfo *ci, char *buf);
+E void load_bs_dbase(void);
+E void save_bs_dbase(void);
+E void save_bs_rdb_dbase(void);
+E BotInfo *makebot(char *nick);
+E BotInfo *findbot(char *nick);
+E void bot_join(ChannelInfo *ci);
+E void bot_rejoin_all(BotInfo *bi);
+E char *normalizeBuffer(char *);
+E void unassign(User * u, ChannelInfo * ci);
+E void insert_bot(BotInfo * bi);
+
+E void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick, char *reason);
+E void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick, char *reason);
+E void bot_raw_mode(User * requester, ChannelInfo * ci, char *mode, char *nick);
+
+/**** channels.c ****/
+
+E Channel *chanlist[1024];
+
+E void add_ban(Channel * chan, char *mask);
+E void chan_adduser2(User * user, Channel * c);
+E void add_invite(Channel * chan, char *mask);
+E void chan_delete(Channel * c);
+E void del_ban(Channel * chan, char *mask);
+E void chan_set_key(Channel * chan, char *value);
+E void set_limit(Channel * chan, char *value);
+E void del_invite(Channel * chan, char *mask);
+E char *get_key(Channel * chan);
+E char *get_limit(Channel * chan);
+E Channel *chan_create(char *chan, time_t ts);
+E Channel *join_user_update(User * user, Channel * chan, char *name, time_t chants);
+
+E void add_exception(Channel * chan, char *mask);
+E void del_exception(Channel * chan, char *mask);
+E char *get_flood(Channel * chan);
+E void set_flood(Channel * chan, char *value);
+E char *get_redirect(Channel * chan);
+E void set_redirect(Channel * chan, char *value);
+
+
+E void get_channel_stats(long *nrec, long *memuse);
+E Channel *findchan(const char *chan);
+E Channel *firstchan(void);
+E Channel *nextchan(void);
+
+E void chan_deluser(User * user, Channel * c);
+
+E int is_on_chan(Channel * c, User * u);
+E User *nc_on_chan(Channel * c, NickCore * nc);
+
+E char *chan_get_modes(Channel * chan, int complete, int plus);
+E void chan_set_modes(const char *source, Channel * chan, int ac,
+ char **av, int check);
+
+E int chan_get_user_status(Channel * chan, User * user);
+E int chan_has_user_status(Channel * chan, User * user, int16 status);
+E void chan_remove_user_status(Channel * chan, User * user, int16 status);
+E void chan_set_user_status(Channel * chan, User * user, int16 status);
+
+E int get_access_level(ChannelInfo * ci, NickAlias * na);
+E const char *get_xop_level(int level);
+
+E void do_cmode(const char *source, int ac, char **av);
+E void do_join(const char *source, int ac, char **av);
+E void do_kick(const char *source, int ac, char **av);
+E void do_part(const char *source, int ac, char **av);
+E void do_sjoin(const char *source, int ac, char **av);
+E void do_topic(const char *source, int ac, char **av);
+E void do_mass_mode(char *modes);
+
+E void chan_set_correct_modes(User * user, Channel * c, int give_modes);
+E void restore_unsynced_topics(void);
+
+E Entry *entry_create(char *mask);
+E Entry *entry_add(EList *list, char *mask);
+E void entry_delete(EList *list, Entry *e);
+E EList *list_create();
+E int entry_match(Entry *e, char *nick, char *user, char *host, uint32 ip);
+E int entry_match_mask(Entry *e, char *mask, uint32 ip);
+E Entry *elist_match(EList *list, char *nick, char *user, char *host, uint32 ip);
+E Entry *elist_match_mask(EList *list, char *mask, uint32 ip);
+E Entry *elist_match_user(EList *list, User *u);
+E Entry *elist_find_mask(EList *list, char *mask);
+E long get_memuse(EList *list);
+
+
+#define whosends(ci) ((!(ci) || !((ci)->botflags & BS_SYMBIOSIS) || !(ci)->bi || !(ci)->c || (ci)->c->usercount < BSMinUsers) ? s_ChanServ : (ci)->bi->nick)
+
+/**** chanserv.c ****/
+
+E ChannelInfo *chanlists[256];
+E CSModeUtil csmodeutils[];
+E LevelInfo levelinfo[];
+
+E void listchans(int count_only, const char *chan);
+E void get_chanserv_stats(long *nrec, long *memuse);
+
+E int delchan(ChannelInfo * ci);
+E void alpha_insert_chan(ChannelInfo * ci);
+E void reset_levels(ChannelInfo * ci);
+E void cs_init(void);
+E void chanserv(User * u, char *buf);
+E void load_cs_dbase(void);
+E void save_cs_dbase(void);
+E void save_cs_rdb_dbase(void);
+E void expire_chans(void);
+E void cs_remove_nick(const NickCore * nc);
+E void cs_remove_bot(const BotInfo * bi);
+
+E int is_real_founder(User * user, ChannelInfo * ci);
+
+E void check_modes(Channel * c);
+E int check_valid_admin(User * user, Channel * chan, int servermode);
+E int check_valid_op(User * user, Channel * chan, int servermode);
+E int check_should_op(User * user, char *chan);
+E int check_should_voice(User * user, char *chan);
+E int check_should_halfop(User * user, char *chan);
+E int check_should_owner(User * user, char *chan);
+E int check_should_protect(User * user, char *chan);
+E int check_kick(User * user, char *chan, time_t chants);
+E void record_topic(const char *chan);
+E void restore_topic(char *chan);
+E int check_topiclock(Channel * c, time_t topic_time);
+
+E ChannelInfo *cs_findchan(const char *chan);
+E int check_access(User * user, ChannelInfo * ci, int what);
+E int is_founder(User * user, ChannelInfo * ci);
+E int get_access(User * user, ChannelInfo * ci);
+E ChanAccess *get_access_entry(NickCore * nc, ChannelInfo * ci);
+E void update_cs_lastseen(User * user, ChannelInfo * ci);
+E int get_idealban(ChannelInfo * ci, User * u, char *ret, int retlen);
+E AutoKick *is_stuck(ChannelInfo * ci, char *mask);
+E void stick_mask(ChannelInfo * ci, AutoKick * akick);
+E void stick_all(ChannelInfo * ci);
+E char *cs_get_flood(ChannelInfo * ci);
+E void cs_set_flood(ChannelInfo * ci, char *value);
+E char *cs_get_key(ChannelInfo * ci);
+E void cs_set_key(ChannelInfo * ci, char *value);
+E char *cs_get_limit(ChannelInfo * ci);
+E void cs_set_limit(ChannelInfo * ci, char *value);
+E char *cs_get_redirect(ChannelInfo * ci);
+E void cs_set_redirect(ChannelInfo * ci, char *value);
+
+E int levelinfo_maxwidth;
+E ChannelInfo *makechan(const char *chan);
+E int is_identified(User * user, ChannelInfo * ci);
+E char *get_mlock_modes(ChannelInfo * ci, int complete);
+
+/**** compat.c ****/
+
+#if !HAVE_SNPRINTF
+# if BAD_SNPRINTF
+# define snprintf my_snprintf
+# endif
+# define vsnprintf my_vsnprintf
+E int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
+E int snprintf(char *buf, size_t size, const char *fmt, ...);
+#endif
+#if !HAVE_STRICMP && !HAVE_STRCASECMP
+E int stricmp(const char *s1, const char *s2);
+E int strnicmp(const char *s1, const char *s2, size_t len);
+#endif
+#if !HAVE_STRDUP
+E char *strdup(const char *s);
+#endif
+#if !HAVE_STRSPN
+E size_t strspn(const char *s, const char *accept);
+#endif
+#if !HAVE_STRERROR
+E char *strerror(int errnum);
+#endif
+#if !HAVE_STRSIGNAL
+char *strsignal(int signum);
+#endif
+#ifdef _WIN32
+char *sockstrerror(int error);
+#endif
+
+/**** config.c ****/
+
+E char *RemoteServer;
+E int RemotePort;
+E char *RemotePassword;
+E char *RemoteServer2;
+E int RemotePort2;
+E char *RemotePassword2;
+E char *RemoteServer3;
+E int RemotePort3;
+E char *RemotePassword3;
+E char *LocalHost;
+E int LocalPort;
+
+E char *ServerName;
+E char *ServerDesc;
+E char *ServiceUser;
+E char *ServiceHost;
+
+E char *HelpChannel;
+E char *LogChannel;
+E char *NetworkName;
+E int NickLen;
+
+E char *s_NickServ;
+E char *s_ChanServ;
+E char *s_MemoServ;
+E char *s_BotServ;
+E char *s_HelpServ;
+E char *s_OperServ;
+E char *s_GlobalNoticer;
+E char *s_DevNull;
+E char *desc_NickServ;
+E char *desc_ChanServ;
+E char *desc_MemoServ;
+E char *desc_BotServ;
+E char *desc_HelpServ;
+E char *desc_OperServ;
+E char *desc_GlobalNoticer;
+E char *desc_DevNull;
+
+E char *HostDBName;
+E char *desc_HostServ;
+E char *s_HostServ;
+E void load_hs_dbase(void);
+E void save_hs_dbase(void);
+E void save_hs_rdb_dbase(void);
+E int do_on_id(User * u);
+E void delHostCore(char *nick);
+E void hostserv(User * u, char *buf);
+
+E char *s_NickServAlias;
+E char *s_ChanServAlias;
+E char *s_MemoServAlias;
+E char *s_BotServAlias;
+E char *s_HelpServAlias;
+E char *s_OperServAlias;
+E char *s_GlobalNoticerAlias;
+E char *s_DevNullAlias;
+E char *s_HostServAlias;
+E char *desc_NickServAlias;
+E char *desc_ChanServAlias;
+E char *desc_MemoServAlias;
+E char *desc_BotServAlias;
+E char *desc_HelpServAlias;
+E char *desc_OperServAlias;
+E char *desc_GlobalNoticerAlias;
+E char *desc_DevNullAlias;
+E char *desc_HostServAlias;
+
+E char *PIDFilename;
+E char *MOTDFilename;
+E char *NickDBName;
+E char *PreNickDBName;
+E char *ChanDBName;
+E char *BotDBName;
+E char *OperDBName;
+E char *AutokillDBName;
+E char *NewsDBName;
+
+E int NoBackupOkay;
+E int StrictPasswords;
+E int BadPassLimit;
+E int BadPassTimeout;
+E int UpdateTimeout;
+E int ExpireTimeout;
+E int ReadTimeout;
+E int WarningTimeout;
+E int TimeoutCheck;
+E int KeepLogs;
+E int KeepBackups;
+E int ForceForbidReason;
+E int UsePrivmsg;
+E int UseStrictPrivMsg;
+E int DumpCore;
+E int LogUsers;
+E int NickRegDelay;
+E int UseSVSHOLD;
+E int UseSVS2MODE;
+E int RestrictOperNicks;
+E int UseTokens;
+E int NewsCount;
+E char *Numeric;
+E int UnRestrictSAdmin;
+E int UseTS6;
+
+E char **HostSetters;
+E int HostNumber;
+
+E int UseMail;
+E char *SendMailPath;
+E char *SendFrom;
+E int RestrictMail;
+E int MailDelay;
+E int DontQuoteAddresses;
+
+E int NSDefFlags;
+E int NSDefLanguage;
+E int NSRegDelay;
+E int NSResendDelay;
+E int NSExpire;
+E int NSRExpire;
+E int NSForceEmail;
+E int NSMaxAliases;
+E int NSAccessMax;
+E char *NSEnforcerUser;
+E char *NSEnforcerHost;
+E int NSReleaseTimeout;
+E int NSAllowKillImmed;
+E int NSNoGroupChange;
+E int NSListOpersOnly;
+E int NSListMax;
+E char *NSGuestNickPrefix;
+E int NSSecureAdmins;
+E int NSStrictPrivileges;
+E int NSEmailReg;
+E int NSModeOnID;
+E int NSRestrictGetPass;
+E int NSNickTracking;
+E int NSAddAccessOnReg;
+
+E int CSDefFlags;
+E int CSMaxReg;
+E int CSExpire;
+E int CSDefBantype;
+E int CSAccessMax;
+E int CSAutokickMax;
+E char *CSAutokickReason;
+E int CSInhabit;
+E int CSListOpersOnly;
+E int CSListMax;
+E int CSRestrictGetPass;
+E int CSOpersOnly;
+
+E int MSMaxMemos;
+E int MSSendDelay;
+E int MSNotifyAll;
+E int MSMemoReceipt;
+
+E int BSDefFlags;
+E int BSKeepData;
+E int BSMinUsers;
+E int BSBadWordsMax;
+E int BSSmartJoin;
+E int BSGentleBWReason;
+E int BSCaseSensitive;
+E char *BSFantasyCharacter;
+
+E int HideStatsO;
+E int GlobalOnCycle;
+E int AnonymousGlobal;
+E char *GlobalOnCycleMessage;
+E char *GlobalOnCycleUP;
+E char **ServicesRoots;
+E int RootNumber;
+E int LogMaxUsers;
+E int SuperAdmin;
+E int LogBot;
+E int AutokillExpiry;
+E int ChankillExpiry;
+E int SGLineExpiry;
+E int SQLineExpiry;
+E int SZLineExpiry;
+E int AkillOnAdd;
+E int KillonSGline;
+E int KillonSQline;
+E int DisableRaw;
+E int WallOper;
+E int WallBadOS;
+E int WallOSGlobal;
+E int WallOSMode;
+E int WallOSClearmodes;
+E int WallOSKick;
+E int WallOSAkill;
+E int WallOSSGLine;
+E int WallOSSQLine;
+E int WallOSSZLine;
+E int WallOSNoOp;
+E int WallOSJupe;
+E int WallOSRaw;
+E int WallAkillExpire;
+E int WallSGLineExpire;
+E int WallSQLineExpire;
+E int WallSZLineExpire;
+E int WallExceptionExpire;
+E int WallDrop;
+E int WallForbid;
+E int WallGetpass;
+E int WallSetpass;
+E int AddAkiller;
+
+E int parse_directive(Directive * d, char *dir, int ac, char *av[MAXPARAMS], int linenum, int reload, char *s);
+
+/**
+ * Modules Stuff
+ **/
+E char **ModulesAutoload;
+E int ModulesNumber;
+E char **ModulesDelayedAutoload;
+E int ModulesDelayedNumber;
+
+E char **HostServCoreModules;
+E int HostServCoreNumber;
+
+E char **HelpServCoreModules;
+E int HelpServCoreNumber;
+
+E char **MemoServCoreModules;
+E int MemoServCoreNumber;
+
+E char **BotServCoreModules;
+E int BotServCoreNumber;
+
+E char **OperServCoreModules;
+E int OperServCoreNumber;
+
+E char **NickServCoreModules;
+E int NickServCoreNumber;
+
+E char **ChanServCoreModules;
+E int ChanServCoreNumber;
+
+E int LimitSessions;
+E int DefSessionLimit;
+E int ExceptionExpiry;
+E int MaxSessionKill;
+E int MaxSessionLimit;
+E int SessionAutoKillExpiry;
+E char *ExceptionDBName;
+E char *SessionLimitDetailsLoc;
+E char *SessionLimitExceeded;
+
+E char *UlineServers;
+E char **Ulines;
+E int NumUlines;
+
+#ifdef USE_RDB
+E int rdb_init();
+E int rdb_open();
+E int rdb_close();
+E char *rdb_quote(char *str);
+E int rdb_tag_table(char *table);
+E int rdb_tag_table_where(char *table, char *clause);
+E int rdb_empty_table(char *table);
+E int rdb_clean_table(char *table);
+E int rdb_clean_table_where(char *table, char *clause);
+E int rdb_scrub_table(char *table, char *clause);
+E int rdb_direct_query(char *query);
+E int rdb_ns_set_display(char *newnick, char *oldnick);
+E int rdb_save_ns_core(NickCore * nc);
+E int rdb_save_ns_alias(NickAlias * na);
+E int rdb_save_ns_req(NickRequest * nr);
+E int rdb_save_cs_info(ChannelInfo * ci);
+E int rdb_save_bs_core(BotInfo * bi);
+E int rdb_save_bs_rdb_core(BotInfo * bi);
+E int rdb_save_hs_core(HostCore * hc);
+E int rdb_save_os_db(unsigned int maxucnt, unsigned int maxutime,
+ SList * ak, SList * sgl, SList * sql, SList * szl);
+E int rdb_save_news(NewsItem * ni);
+E int rdb_save_exceptions(Exception * e);
+E int rdb_load_bs_dbase(void);
+E int rdb_load_hs_dbase(void);
+E int rdb_load_ns_dbase(void);
+E int rdb_load_dbases(void);
+#endif
+
+#ifdef USE_MYSQL
+E char *MysqlHost;
+E char *MysqlUser;
+E char *MysqlPass;
+E char *MysqlName;
+E int MysqlPort;
+E char *MysqlSock;
+E char *MysqlSecure;
+E int MysqlRetries;
+E int MysqlRetryGap;
+E int UseRDB;
+#endif
+
+E int read_config(int reload);
+
+E int DefConLevel;
+E int DefCon[6];
+E int checkDefCon(int level);
+E void resetDefCon(int level);
+E int DefConSessionLimit;
+E char *DefConTimeOut;
+E char *DefConAKILL;
+E char *DefConChanModes;
+E int GlobalOnDefcon;
+E int GlobalOnDefconMore;
+E char *DefconMessage;
+E char *DefConAkillReason;
+E char *DefConOffMessage;
+
+E long unsigned int UserKey1;
+E long unsigned int UserKey2;
+E long unsigned int UserKey3;
+/**** converter.c ****/
+
+E int convert_ircservices_44(void);
+
+/**** encrypt.c ****/
+E char *EncModule;
+E void initEncryption();
+E int enc_encrypt(const char *src, int len, char *dest, int size);
+E int enc_encrypt_in_place(char *buf, int size);
+E int enc_encrypt_check_len(int passlen, int bufsize);
+E int enc_decrypt(const char *src, char *dest, int size);
+E int enc_check_password(const char *plaintext, const char *password);
+E void encmodule_encrypt(int (*func)(const char *src, int len, char *dest, int size));
+E void encmodule_encrypt_in_place(int (*func)(char *buf, int size));
+E void encmodule_encrypt_check_len(int (*func)(int passlen, int bufsize));
+E void encmodule_decrypt(int (*func)(const char *src, char *dest, int size));
+E void encmodule_check_password(int (*func)(const char *plaintext, const char *password));
+
+/**** helpserv.c ****/
+E void helpserv(User * u, char *buf);
+E void helpserv_init(void);
+
+/**** hostserv.c ****/
+E void get_hostserv_stats(long *nrec, long *memuse);
+E void hostserv_init(void);
+E void addHostCore(char *nick, char *vIdent, char *vhost, char *creator, int32 tmp_time);
+E char *getvIdent(char *nick);
+E char *getvHost(char *nick);
+E int is_host_remover(User * u);
+E int is_host_setter(User *u);
+E HostCore *hostCoreListHead();
+E HostCore *findHostCore(HostCore * head, char *nick, boolean * found);
+E HostCore *createHostCorelist(HostCore * next, char *nick, char *vIdent, char *vHost, char *creator, int32 tmp_time);
+E HostCore *insertHostCore(HostCore * head, HostCore * prev, char *nick, char *vIdent, char *vHost, char *creator, int32 tmp_time);
+E HostCore *deleteHostCore(HostCore * head, HostCore * prev);
+E void set_lastmask(User * u);
+
+/**** init.c ****/
+
+E void introduce_user(const char *user);
+E int init_primary(int ac, char **av);
+E int init_secondary(int ac, char **av);
+E int servernum;
+
+/**** ircd.c ****/
+E void pmodule_set_mod_current_buffer(void (*func) (int ac, char **av));
+E void pmodule_cmd_svsnoop(void (*func) (char *server, int set));
+E void pmodule_cmd_remove_akill(void (*func) (char *user, char *host));
+E void pmodule_cmd_topic(void (*func) (char *whosets, char *chan, char *whosetit, char *topic, time_t when));
+E void pmodule_cmd_vhost_off(void (*func) (User * u));
+E void pmodule_cmd_akill(void (*func) (char *user, char *host, char *who, time_t when, time_t expires, char *reason));
+E void pmodule_cmd_svskill(void (*func) (char *source, char *user, char *buf));
+E void pmodule_cmd_svsmode(void (*func) (User * u, int ac, char **av));
+E void pmodule_cmd_372(void (*func) (char *source, char *msg));
+E void pmodule_cmd_372_error(void (*func) (char *source));
+E void pmodule_cmd_375(void (*func) (char *source));
+E void pmodule_cmd_376(void (*func) (char *source));
+E void pmodule_cmd_nick(void (*func) (char *nick, char *name, char *modes));
+E void pmodule_cmd_guest_nick(void (*func) (char *nick, char *user, char *host, char *real, char *modes));
+E void pmodule_cmd_mode(void (*func) (char *source, char *dest, char *buf));
+E void pmodule_cmd_bot_nick(void (*func) (char *nick, char *user, char *host, char *real, char *modes));
+E void pmodule_cmd_kick(void (*func) (char *source, char *chan, char *user, char *buf));
+E void pmodule_cmd_notice_ops(void (*func) (char *source, char *dest, char *buf));
+E void pmodule_cmd_notice(void (*func) (char *source, char *dest, char *buf));
+E void pmodule_cmd_notice2(void (*func) (char *source, char *dest, char *msg));
+E void pmodule_cmd_privmsg(void (*func) (char *source, char *dest, char *buf));
+E void pmodule_cmd_privmsg2(void (*func) (char *source, char *dest, char *msg));
+E void pmodule_cmd_serv_notice(void (*func) (char *source, char *dest, char *msg));
+E void pmodule_cmd_serv_privmsg(void (*func) (char *source, char *dest, char *msg));
+E void pmodule_cmd_bot_chan_mode(void (*func) (char *nick, char *chan));
+E void pmodule_cmd_351(void (*func) (char *source));
+E void pmodule_cmd_quit(void (*func) (char *source, char *buf));
+E void pmodule_cmd_pong(void (*func) (char *servname, char *who));
+E void pmodule_cmd_join(void (*func) (char *user, char *channel, time_t chantime));
+E void pmodule_cmd_unsqline(void (*func) (char *user));
+E void pmodule_cmd_invite(void (*func) (char *source, char *chan, char *nick));
+E void pmodule_cmd_part(void (*func) (char *nick, char *chan, char *buf));
+E void pmodule_cmd_391(void (*func) (char *source, char *timestr));
+E void pmodule_cmd_250(void (*func) (char *buf));
+E void pmodule_cmd_307(void (*func) (char *buf));
+E void pmodule_cmd_311(void (*func) (char *buf));
+E void pmodule_cmd_312(void (*func) (char *buf));
+E void pmodule_cmd_317(void (*func) (char *buf));
+E void pmodule_cmd_219(void (*func) (char *source, char *letter));
+E void pmodule_cmd_401(void (*func) (char *source, char *who));
+E void pmodule_cmd_318(void (*func) (char *source, char *who));
+E void pmodule_cmd_242(void (*func) (char *buf));
+E void pmodule_cmd_243(void (*func) (char *buf));
+E void pmodule_cmd_211(void (*func) (char *buf));
+E void pmodule_cmd_global(void (*func) (char *source, char *buf));
+E void pmodule_cmd_global_legacy(void (*func) (char *source, char *fmt));
+E void pmodule_cmd_sqline(void (*func) (char *mask, char *reason));
+E void pmodule_cmd_squit(void (*func) (char *servname, char *message));
+E void pmodule_cmd_svso(void (*func) (char *source, char *nick, char *flag));
+E void pmodule_cmd_chg_nick(void (*func) (char *oldnick, char *newnick));
+E void pmodule_cmd_svsnick(void (*func) (char *source, char *guest, time_t when));
+E void pmodule_cmd_vhost_on(void (*func) (char *nick, char *vIdent, char *vhost));
+E void pmodule_cmd_connect(void (*func) (int servernum));
+E void pmodule_cmd_svshold(void (*func) (char *nick));
+E void pmodule_cmd_release_svshold(void (*func) (char *nick));
+E void pmodule_cmd_unsgline(void (*func) (char *mask));
+E void pmodule_cmd_unszline(void (*func) (char *mask));
+E void pmodule_cmd_szline(void (*func) (char *mask, char *reason, char *whom));
+E void pmodule_cmd_sgline(void (*func) (char *mask, char *reason));
+E void pmodule_cmd_unban(void (*func) (char *name, char *nick));
+E void pmodule_cmd_svsmode_chan(void (*func) (char *name, char *mode, char *nick));
+E void pmodule_cmd_svid_umode(void (*func) (char *nick, time_t ts));
+E void pmodule_cmd_nc_change(void (*func) (User * u));
+E void pmodule_cmd_svid_umode2(void (*func) (User * u, char *ts));
+E void pmodule_cmd_svid_umode3(void (*func) (User * u, char *ts));
+E void pmodule_cmd_ctcp(void (*func) (char *source, char *dest, char *buf));
+E void pmodule_cmd_svsjoin(void (*func) (char *source, char *nick, char *chan, char *param));
+E void pmodule_cmd_svspart(void (*func) (char *source, char *nick, char *chan));
+E void pmodule_cmd_swhois(void (*func) (char *source, char *who, char *mask));
+E void pmodule_cmd_eob(void (*func) ());
+E void pmodule_cmd_jupe(void (*func) (char *jserver, char *who, char *reason));
+E void pmodule_set_umode(void (*func) (User * user, int ac, char **av));
+E void pmodule_valid_nick(int (*func) (char *nick));
+E void pmodule_valid_chan(int (*func) (char *chan));
+E void pmodule_flood_mode_check(int (*func) (char *value));
+E void pmodule_ircd_var(IRCDVar * ircdvar);
+E void pmodule_ircd_cap(IRCDCAPAB * cap);
+E void pmodule_ircd_version(char *version);
+E void pmodule_ircd_cbmodeinfos(CBModeInfo * modeinfos);
+E void pmodule_ircd_cumodes(CUMode modes[128]);
+E void pmodule_ircd_flood_mode_char_set(char *mode);
+E void pmodule_ircd_flood_mode_char_remove(char *mode);
+E void pmodule_ircd_cbmodes(CBMode modes[128]);
+E void pmodule_ircd_cmmodes(CMMode modes[128]);
+E void pmodule_ircd_csmodes(char mode[128]);
+E void pmodule_ircd_useTSMode(int use);
+E void pmodule_invis_umode(int mode);
+E void pmodule_oper_umode(int mode);
+E void pmodule_invite_cmode(int mode);
+E void pmodule_secret_cmode(int mode);
+E void pmodule_private_cmode(int mode);
+E void pmodule_key_mode(int mode);
+E void pmodule_limit_mode(int mode);
+
+E int anope_get_secret_mode();
+E int anope_get_invite_mode();
+E int anope_get_key_mode();
+E int anope_get_limit_mode();
+E int anope_get_private_mode();
+E int anope_get_invis_mode();
+E int anope_get_oper_mode();
+
+/**** language.c ****/
+
+E char **langtexts[NUM_LANGS];
+E char *langnames[NUM_LANGS];
+E int langlist[NUM_LANGS];
+
+E void lang_init(void);
+#define getstring(na,index) \
+ (langtexts[((na)&&((NickAlias*)na)->nc&&!(((NickAlias*)na)->status & NS_VERBOTEN)?((NickAlias*)na)->nc->language:NSDefLanguage)][(index)])
+#define getstring2(nc,index) \
+ (langtexts[((nc)?((NickCore*)nc)->language:NSDefLanguage)][(index)])
+E int strftime_lang(char *buf, int size, User * u, int format,
+ struct tm *tm);
+E void syntax_error(char *service, User * u, const char *command,
+ int msgnum);
+
+
+/**** list.c ****/
+
+E void do_listnicks(int ac, char **av);
+E void do_listchans(int ac, char **av);
+
+
+/**** log.c ****/
+
+E int open_log(void);
+E void close_log(void);
+E void alog(const char *fmt, ...) FORMAT(printf,1,2);
+E void log_perror(const char *fmt, ...) FORMAT(printf,1,2);
+E void fatal(const char *fmt, ...) FORMAT(printf,1,2);
+E void fatal_perror(const char *fmt, ...) FORMAT(printf,1,2);
+
+/**** mail.c ****/
+
+E MailInfo *MailBegin(User *u, NickCore *nc, char *subject, char *service);
+E MailInfo *MailRegBegin(User *u, NickRequest *nr, char *subject, char *service);
+E MailInfo *MailMemoBegin(NickCore * nc);
+E void MailEnd(MailInfo *mail);
+E void MailReset(User *u, NickCore *nc);
+E int MailValidate(const char *email);
+
+/**** main.c ****/
+
+E const char version_number[];
+E const char version_number_dotted[];
+E const char version_build[];
+E char *version_protocol;
+E const char version_flags[];
+
+E char *services_dir;
+E char *log_filename;
+E int debug;
+E int readonly;
+E int logchan;
+E int skeleton;
+E int nofork;
+E int forceload;
+E int nothird;
+E int noexpire;
+E int protocoldebug;
+
+#ifdef USE_RDB
+E int do_mysql;
+#endif
+
+E int is44;
+E int quitting;
+E int delayed_quit;
+E char *quitmsg;
+E char inbuf[BUFSIZE];
+E int servsock;
+E int save_data;
+E int got_alarm;
+E time_t start_time;
+
+E void save_databases(void);
+E void expire_all(void);
+E void do_backtrace(int show_segheader);
+E void sighandler(int signum);
+E void do_restart_services(void);
+
+/**** memory.c ****/
+
+E void *smalloc(long size);
+E void *scalloc(long elsize, long els);
+E void *srealloc(void *oldptr, long newsize);
+E char *sstrdup(const char *s);
+
+
+/**** memoserv.c ****/
+
+E void ms_init(void);
+E void memoserv(User * u, char *buf);
+E void check_memos(User * u);
+E MemoInfo *getmemoinfo(const char *name, int *ischan, int *isforbid);
+E void memo_send(User * u, char *name, char *text, int z);
+E int delmemo(MemoInfo * mi, int num);
+
+/**** messages.c ****/
+
+E int m_nickcoll(char *user);
+E int m_away(char *source, char *msg);
+E int m_kill(char *nick, char *msg);
+E int m_motd(char *source);
+E int m_privmsg(char *source, char *receiver, char *msg);
+E int m_stats(char *source, int ac, char **av);
+E int m_whois(char *source, char *who);
+E int m_time(char *source, int ac, char **av);
+E int m_version(char *source, int ac, char **av);
+
+
+/**** misc.c ****/
+
+E int toupper(char);
+E int tolower(char);
+E char *strscpy(char *d, const char *s, size_t len);
+#ifndef HAVE_STRLCPY
+E size_t strlcpy(char *, const char *, size_t);
+#endif
+#ifndef HAVE_STRLCAT
+E size_t strlcat(char *, const char *, size_t);
+#endif
+E char *stristr(char *s1, char *s2);
+E char *strnrepl(char *s, int32 size, const char *old, const char *new);
+E char *merge_args(int argc, char **argv);
+E int match_wild(const char *pattern, const char *str);
+E int match_wild_nocase(const char *pattern, const char *str);
+E int dotime(const char *s);
+E char *duration(NickAlias * na, char *buf, int bufsize, time_t seconds);
+E char *expire_left(NickAlias * na, char *buf, int len, time_t expires);
+E void protocol_debug(char *source, char *cmd, int argc, char **argv);
+E int doValidHost(const char *host, int type);
+
+typedef int (*range_callback_t) (User * u, int num, va_list args);
+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(const char c);
+
+E char *myStrGetToken(const char *str, const char dilim, int token_number);
+E char *myStrGetOnlyToken(const char *str, const char dilim,
+ int token_number);
+E char *myStrSubString(const char *src, int start, int end);
+E char *myStrGetTokenRemainder(const char *str, const char dilim,
+ int token_number);
+E char *stripModePrefix(const char *str);
+E int myNumToken(const char *str, const char dilim);
+E void doCleanBuffer(char *str);
+E void EnforceQlinedNick(char *nick, char *killer);
+E int nickIsServices(char *nick, int bot);
+
+E void add_entropy_userkeys(void);
+E void rand_init(void);
+E unsigned char getrandom8(void);
+E u_int16_t getrandom16(void);
+E u_int32_t getrandom32(void);
+
+E char *str_signed(unsigned char *str);
+
+E void ntoa(struct in_addr addr, char *ipaddr, int len);
+
+E char **buildStringList(char *src, int *number);
+E void binary_to_hex(unsigned char *bin, char *hex, int length);
+
+E uint32 cidr_to_netmask(uint16 cidr);
+E uint16 netmask_to_cidr(uint32 mask);
+
+E int str_is_wildcard(const char *str);
+E int str_is_pure_wildcard(const char *str);
+
+E uint32 str_is_ip(char *str);
+E int str_is_cidr(char *str, uint32 * ip, uint32 * mask, char **host);
+
+
+/**** modules.c ****/
+E void modules_core_init(int number, char **list);
+E void modules_unload_all(boolean fini, boolean unload_proto); /* Read warnings near function source */
+E void moduleCallBackRun(void);
+E void moduleCleanStruct(ModuleData **moduleData);
+E void ModuleDatabaseBackup(char *dbname);
+E void ModuleRemoveBackups(char *dbname);
+
+/**** news.c ****/
+
+E int32 nnews, news_size;
+E NewsItem *news;
+E void get_news_stats(long *nrec, long *memuse);
+E void load_news(void);
+E void save_news(void);
+E void save_rdb_news(void);
+E void display_news(User * u, int16 type);
+E int do_logonnews(User * u);
+E int do_opernews(User * u);
+E int do_randomnews(User * u);
+
+/**** nickserv.c ****/
+
+E NickAlias *nalists[1024];
+E NickCore *nclists[1024];
+E NickRequest *nrlists[1024];
+E NickRequest *findrequestnick(const char *nick);
+E int delnickrequest(NickRequest * nr);
+E unsigned int guestnum;
+E void insert_requestnick(NickRequest * nr);
+E void alpha_insert_alias(NickAlias * na);
+E void insert_core(NickCore * nc);
+E void listnicks(int count_only, const char *nick);
+E void get_aliases_stats(long *nrec, long *memuse);
+E void get_core_stats(long *nrec, long *memuse);
+E void collide(NickAlias * na, int from_timeout);
+E void del_ns_timeout(NickAlias * na, int type);
+E void change_core_display(NickCore * nc, char *newdisplay);
+E void release(NickAlias * na, int from_timeout);
+E int do_setmodes(User * u);
+E int should_mode_change(int16 status, int16 mode);
+
+E void ns_init(void);
+E void nickserv(User * u, char *buf);
+E void load_ns_dbase(void);
+E void load_ns_req_db(void);
+E void save_ns_dbase(void);
+E void save_ns_req_dbase(void);
+E void save_ns_rdb_dbase(void);
+E void save_ns_req_rdb_dbase(void);
+E int validate_user(User * u);
+E void cancel_user(User * u);
+E int nick_identified(User * u);
+E int nick_recognized(User * u);
+E void expire_nicks(void);
+E void expire_requests(void);
+EI int ns_do_register(User * u);
+E int delnick(NickAlias * na);
+E NickAlias *findnick(const char *nick);
+E NickCore *findcore(const char *nick);
+E void clean_ns_timeouts(NickAlias * na);
+E void nsStartNickTracking(User * u);
+E void nsStopNickTracking(User * u);
+E int nsCheckNickTracking(User *u);
+
+E int group_identified(User * u, NickCore * nc);
+E int is_on_access(User * u, NickCore * nc);
+
+/**** operserv.c ****/
+
+E SList akills, sglines, sqlines, szlines;
+E SList servadmins;
+E SList servopers;
+
+E int DefConModesSet;
+E uint32 DefConModesOn;
+E uint32 DefConModesOff;
+E ChannelInfo DefConModesCI;
+
+E void operserv(User *u, char *buf);
+E void os_init(void);
+E void load_os_dbase(void);
+E void save_os_dbase(void);
+E void save_os_rdb_dbase(void);
+
+E void os_remove_nick(NickCore *nc);
+E int is_services_root(User *u);
+E int is_services_admin(User *u);
+E int is_services_oper(User *u);
+E int nick_is_services_root(NickCore * nc);
+E int nick_is_services_admin(NickCore *nc);
+E int nick_is_services_oper(NickCore *nc);
+
+E int add_akill(User *u, char *mask, const char *by, const time_t expires, const char *reason);
+E int check_akill(char *nick, const char *username, const char *host, const char *vhost, const char *ip);
+E void expire_akills(void);
+E void oper_global(char *nick, char *fmt, ...);
+
+E int add_sgline(User *u, char *mask, const char *by, const time_t expires, const char *reason);
+E int check_sgline(char *nick, const char *realname);
+E void expire_sglines(void);
+
+E int add_sqline(User *u, char *mask, const char *by, const time_t expires, const char *reason);
+E int check_sqline(char *nick, int nick_change);
+E void expire_sqlines(void);
+E int check_chan_sqline(const char *chan);
+
+E int add_szline(User * u, char *mask, const char *by,
+ const time_t expires, const char *reason);
+E void expire_szlines(void);
+E int check_szline(char *nick, char *ip);
+
+E Server *server_global(Server * s, char *msg);
+
+E int OSOpersOnly;
+E time_t DefContimer;
+E void runDefCon(void);
+E int defconParseModeString(const char *str);
+
+/**** process.c ****/
+
+E int allow_ignore;
+E IgnoreData *ignore;
+
+E void add_ignore(const char *nick, time_t delta);
+E IgnoreData *get_ignore(const char *nick);
+E int delete_ignore(const char *nick);
+E int clear_ignores();
+
+E int split_buf(char *buf, char ***argv, int colon_special);
+E void process(void);
+
+/**** send.c ****/
+
+E void send_cmd(const char *source, const char *fmt, ...)
+ FORMAT(printf,2,3);
+E void vsend_cmd(const char *source, const char *fmt, va_list args)
+ FORMAT(printf,2,0);
+
+E void notice_server(char *source, Server * s, char *fmt, ...)
+ FORMAT(printf,3,4);
+E void notice_user(char *source, User *u, const char *fmt, ...)
+ FORMAT(printf,3,4);
+
+E void notice_list(char *source, char *dest, char **text);
+E void notice_lang(char *source, User *dest, int message, ...);
+E void notice_help(char *source, User *dest, int message, ...);
+
+
+/**** servers.c ****/
+
+E Server *servlist;
+E Server *me_server;
+E Server *serv_uplink;
+E uint32 uplink_capab;
+E CapabInfo capab_info[];
+
+E Server *first_server(int flags);
+E Server *next_server(int flags);
+
+E int is_ulined(char *server);
+E int is_sync(Server *server);
+
+E Server *new_server(Server * uplink, const char *name, const char *desc,
+ uint16 flags, char *suid);
+
+E Server *findserver(Server *s, const char *name);
+
+E void do_server(const char *source, char *servername, char *hops, char *descript, char *numeric);
+E void do_squit(const char *source, int ac, char **av);
+E void capab_parse(int ac, char **av);
+E int anope_check_sync(const char *name);
+
+E void finish_sync(Server *serv, int sync_links);
+
+E void ts6_uid_init(void);
+E void ts6_uid_increment(unsigned int slot);
+E char *ts6_uid_retrieve(void);
+
+/**** sessions.c ****/
+
+E Exception *exceptions;
+E int16 nexceptions;
+
+E Session *sessionlist[1024];
+E int32 nsessions;
+
+E void get_session_stats(long *nrec, long *memuse);
+E void get_exception_stats(long *nrec, long *memuse);
+
+E int do_session(User *u);
+E int add_session(char *nick, char *host, char *hostip);
+E void del_session(const char *host);
+
+E void load_exceptions(void);
+E void save_exceptions(void);
+E void save_rdb_exceptions(void);
+E int do_exception(User *u);
+E void expire_exceptions(void);
+
+E Session *findsession(const char *host);
+
+E Exception *find_host_exception(const char *host);
+E Exception *find_hostip_exception(const char *host, const char *hostip);
+E int exception_add(User * u, const char *mask, const int limit,
+ const char *reason, const char *who,
+ const time_t expires);
+
+/**** slist.c ****/
+E int slist_add(SList *slist, void *item);
+E void slist_clear(SList *slist, int free);
+E int slist_delete(SList *slist, int index);
+E int slist_delete_range(SList *slist, char *range, slist_delcheckcb_t cb, ...);
+E int slist_enum(SList *slist, char *range, slist_enumcb_t cb, ...);
+E int slist_full(SList *slist);
+E int slist_indexof(SList *slist, void *item);
+E void slist_init(SList *slist);
+E void slist_pack(SList *slist);
+E int slist_remove(SList *slist, void *item);
+E int slist_setcapacity(SList *slist, int16 capacity);
+
+/**** sockutil.c ****/
+
+E int32 total_read, total_written;
+E int32 read_buffer_len(void);
+E int32 write_buffer_len(void);
+
+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(ano_socket_t s);
+
+/**** users.c ****/
+
+E User *userlist[1024];
+
+E int32 usercnt, opcnt;
+E uint32 maxusercnt;
+E time_t maxusertime;
+
+E void delete_user(User *user);
+
+E void get_user_stats(long *nusers, long *memuse);
+E User *finduser(const char *nick);
+E User *firstuser(void);
+E User *nextuser(void);
+
+E User *find_byuid(const char *uid);
+E User *first_uid(void);
+E User *next_uid(void);
+E Uid *new_uid(const char *nick, char *uid);
+E Uid *find_uid(const char *nick);
+E Uid *find_nickuid(const char *uid);
+E Server *findserver_uid(Server * s, const char *name);
+E char *TS6SID;
+E char *TS6UPLINK;
+
+E void update_host(User * user);
+E void change_user_host(User * user, const char *host);
+E void change_user_username(User * user, const char *username);
+E void change_user_realname(User * user, const char *realname);
+
+E User *do_nick(const char *source, char *nick, char *username, char *host,
+ char *server, char *realname, time_t ts, uint32 svid, uint32 ip, char *vhost, char *uid);
+
+E void do_umode(const char *source, int ac, char **av);
+E void do_umode2(const char *source, int ac, char **av);
+E void do_quit(const char *source, int ac, char **av);
+E void do_kill(char *source, char *reason);
+
+E int is_oper(User * user);
+E int is_protected(User * user);
+
+E int is_excepted(ChannelInfo * ci, User * user);
+E int is_excepted_mask(ChannelInfo * ci, char *mask);
+
+E int match_usermask(const char *mask, User * user);
+E int match_userip(const char *mask, User * user, char *host);
+E void split_usermask(const char *mask, char **nick, char **user,
+ char **host);
+E char *create_mask(User * u);
+
+#ifdef USE_MYSQL
+/**** mysql.c ****/
+E MYSQL *mysql;
+E MYSQL_RES *mysql_res;
+E MYSQL_FIELD *mysql_fields;
+E MYSQL_ROW mysql_row;
+
+E int db_mysql_init();
+E int db_mysql_open();
+E int db_mysql_close();
+E int db_mysql_query(char *sql);
+E char *db_mysql_quote(char *sql);
+E char *db_mysql_quote_buffer(char *sql, int size);
+E int db_mysql_try(const char *fmt, ...);
+E int db_mysql_save_ns_core(NickCore * nc);
+E int db_mysql_save_ns_alias(NickAlias * na);
+E int db_mysql_save_ns_req(NickRequest * nr);
+E int db_mysql_save_cs_info(ChannelInfo * ci);
+E int db_mysql_save_os_db(unsigned int maxucnt, unsigned int maxutime,
+ SList * ak, SList * sgl, SList * sql,
+ SList * szl);
+E int db_mysql_save_news(NewsItem * ni);
+E int db_mysql_save_exceptions(Exception * e);
+E int db_mysql_save_hs_core(HostCore * hc);
+E int db_mysql_save_bs_core(BotInfo * bi);
+E int db_mysql_load_bs_dbase(void);
+E int db_mysql_load_hs_dbase(void);
+E int db_mysql_load_ns_dbase(void);
+E int db_mysql_load_ns_req_dbase(void);
+E int db_mysql_load_cs_dbase(void);
+E int db_mysql_load_os_dbase(void);
+E int db_mysql_load_exceptions(void);
+E int db_mysql_load_news(void);
+E unsigned int mysql_rand(void);
+#endif
+
+E void privmsg(char *source, char *dest, const char *fmt, ...);
+E void notice(char *source, char *dest, const char *fmt, ...);
+
+/******************************************************************************/
+
+E int anope_set_mod_current_buffer(int ac, char **av);
+
+E void anope_cmd_211(const char *fmt, ...); /* 211 */
+E void anope_cmd_219(char *source, char *who); /* 219 */
+E void anope_cmd_242(const char *fmt, ...); /* 242 */
+E void anope_cmd_243(const char *fmt, ...); /* 243 */
+E void anope_cmd_250(const char *fmt, ...); /* 250 */
+E void anope_cmd_307(const char *fmt, ...); /* 307 */
+E void anope_cmd_311(const char *fmt, ...); /* 311 */
+E void anope_cmd_312(const char *fmt, ...); /* 312 */
+E void anope_cmd_317(const char *fmt, ...); /* 317 */
+E void anope_cmd_318(char *source, char *who); /* 318 */
+E void anope_cmd_351(char *source); /* 351 */
+E void anope_cmd_372(char *source, char *msg); /* 372 */
+E void anope_cmd_372_error(char *source); /* 372 */
+E void anope_cmd_375(char *source); /* 375 */
+E void anope_cmd_376(char *source); /* 376 */
+E void anope_cmd_391(char *source, char *timestr); /* 391 */
+E void anope_cmd_401(char *source, char *who); /* 401 */
+E void anope_cmd_akill(char *user, char *host, char *who, time_t when, time_t expires, char *reason); /* AKILL */
+E void anope_cmd_capab(); /* CAPAB */
+E void anope_cmd_chghost(char *nick, char *vhost); /* CHGHOST */
+E void anope_cmd_chgident(char *nick, char *vIdent); /* CHGIDENT */
+E void anope_cmd_vhost_on(char *nick, char *vIdent, char *vhost); /* CHGHOST + CHGIDENT */
+E void anope_cmd_vhost_off(User *u);
+E void anope_cmd_connect(int servernum); /* Connect */
+E void anope_cmd_ea(); /* EA */
+E void anope_cmd_global(char *source, const char *fmt, ...); /* GLOBOPS */
+E void anope_cmd_invite(char *source, char *chan, char *nick); /* INVITE */
+E void anope_cmd_join(char *user, char *channel, time_t chantime); /* JOIN */
+E void anope_cmd_kick(char *source, char *chan, char *user, const char *fmt, ...); /* KICK */
+E void anope_cmd_mode(char *source, char *dest, const char *fmt, ...); /* MODE */
+E void anope_cmd_tmode(char *source, char *dest, const char *fmt, ...); /* TMODE */
+E void anope_cmd_unban(char *name, char *nick); /* MODE -b */
+E void anope_cmd_bot_chan_mode(char *nick, char *chan); /* MODE BotServ */
+E void anope_cmd_netinfo(int ac, char **av); /* NETINFO */
+E void anope_cmd_nick(char *nick, char *name, char *mode); /* NICK */
+E void anope_cmd_chg_nick(char *oldnick, char *newnick); /* NICK */
+E void anope_cmd_bot_nick(char *nick, char *user,char *host,char *real,char *modes); /* NICK */
+E void anope_cmd_guest_nick(char *nick, char *user,char *host,char *real,char *modes); /* NICK */
+E void anope_cmd_notice(char *source, char *dest, const char *fmt, ...); /* NOTICE */
+E void anope_cmd_notice_ops(char *source, char *dest, const char *fmt, ...); /* NOTICE */
+E void anope_cmd_notice2(char *source, char *dest, char *msg); /* NOTICE */
+E void anope_cmd_serv_notice(char *source, char *dest, char *msg); /* NOTICE */
+E void anope_cmd_part(char *nick, char *chan, const char *fmt, ...); /* PART */
+E void anope_cmd_pass(char *pass); /* PASS */
+E void anope_cmd_pong(char *servname, char *who); /* PONG */
+E void anope_cmd_privmsg(char *source, char *dest, const char *fmt, ...); /* PRIVMSG */
+E void anope_cmd_action(char *source, char *dest, const char *fmt, ...); /* PRIVMSG */
+E void anope_cmd_privmsg2(char *source, char *dest, char *msg); /* PRIVMSG */
+E void anope_cmd_serv_privmsg(char *source, char *dest, char *msg); /* PRIVMSG */
+E void anope_cmd_protoctl(); /* PROTOCTL */
+E void anope_cmd_quit(char *source, const char *fmt, ...); /* QUIT */
+E void anope_cmd_remove_akill(char *user, char *host); /* RAKILL */
+E void anope_cmd_server(char *servname, int hop, char *descript); /* SERVER */
+E void anope_cmd_sgline(char *mask, char *reason); /* SGLINE */
+E void anope_cmd_sqline(char *mask, char *reason); /* SQLINE */
+E void anope_cmd_szline(char *mask, char *reason, char *whom); /* SZLINE */
+E void anope_cmd_squit(char *servname, char *message); /* SQUIT */
+E void anope_cmd_svinfo(); /* SVINFO */
+E void anope_cmd_svsadmin(char *server, int set); /* SVSADMIN */
+E void anope_cmd_svshold(char *nick); /* SVSHOLD */
+E void anope_cmd_release_svshold(char *nick); /* SVSHOLD */
+E void anope_cmd_svsinfo(); /* SVSINFO */
+E void anope_cmd_svsjoin(char *source, char *nick,char *chan, char *param); /* SVSJOIN */
+E void anope_cmd_svskill(char *source,char *user, const char *fmt, ...); /* SVSKILL */
+E void anope_cmd_svsmode(User * u, int ac, char **av); /* SVSMODE */
+E void anope_cmd_svsmode_chan(char *name, char *mode, char *nick); /* SVSMODE */
+E void anope_cmd_svsnick(char *nick,char *newnick, time_t when); /* SVSNICK */
+E void anope_cmd_svsnoop(char *server, int set); /* SVSNOOP */
+E void anope_cmd_svso(char *source,char *nick, char *flag); /* SVSO */
+E void anope_cmd_svspart(char *source, char *nick,char *chan); /* SVSPART */
+E void anope_cmd_swhois(char *source, char *who, char *mask); /* SWHOIS */
+E void anope_cmd_topic(char *whosets, char *chan, char *whosetit, char *topic, time_t when); /* TOPIC */
+E void anope_cmd_unsgline(char *mask); /* UNSGLINE */
+E void anope_cmd_unsqline(char *user); /* UNSQLINE */
+E void anope_cmd_unszline(char *mask); /* UNSZLINE */
+E void anope_cmd_eob(); /* EOB - end of burst */
+E void anope_cmd_burst(); /* BURST - use eob to send burst 0 */
+E void anope_cmd_svswatch(char *sender, char *nick, char *parm);
+E void anope_cmd_ctcp(char *source, char *dest, const char *fmt, ...); /* CTCP */
+
+EI int anope_event_482(char *source, int ac, char **av);
+EI int anope_event_436(char *source, int ac, char **av);
+EI int anope_event_away(char *source, int ac, char **av);
+EI int anope_event_ping(char *source, int ac, char **av);
+EI int anope_event_motd(char *source, int ac, char **av);
+EI int anope_event_join(char *source, int ac, char **av);
+EI int anope_event_kick(char *source, int ac, char **av);
+EI int anope_event_kill(char *source, int ac, char **av);
+EI int anope_event_mode(char *source, int ac, char **av);
+EI int anope_event_tmode(char *source, int ac, char **av);
+EI int anope_event_quit(char *source, int ac, char **av);
+EI int anope_event_squit(char *source, int ac, char **av);
+EI int anope_event_topic(char *source, int ac, char **av);
+EI int anope_event_whois(char *source, int ac, char **av);
+EI int anope_event_part(char *source, int ac, char **av);
+EI int anope_event_server(char *source, int ac, char **av);
+EI int anope_event_sid(char *source, int ac, char **av);
+EI int anope_event_nick(char *source, int ac, char **av);
+EI int anope_event_bmask(char *source, int ac, char **av);
+EI int anope_event_gnotice(char *source, int ac, char **av);
+EI int anope_event_privmsg(char *source, int ac, char **av);
+EI int anope_event_capab(char *source, int ac, char **av);
+EI int anope_event_sjoin(char *source, int ac, char **av);
+EI int anope_event_cs(char *source, int ac, char **av);
+EI int anope_event_hs(char *source, int ac, char **av);
+EI int anope_event_ms(char *source, int ac, char **av);
+EI int anope_event_ns(char *source, int ac, char **av);
+EI int anope_event_os(char *source, int ac, char **av);
+EI int anope_event_vs(char *source, int ac, char **av);
+EI int anope_event_svinfo(char *source, int ac, char **av);
+EI int anope_event_chghost(char *source, int ac, char **av);
+EI int anope_event_sethost(char *source, int ac, char **av);
+EI int anope_event_chgident(char *source, int ac, char **av);
+EI int anope_event_setident(char *source, int ac, char **av);
+EI int anope_event_chgname(char *source, int ac, char **av);
+EI int anope_event_setname(char *source, int ac, char **av);
+EI int anope_event_svsinfo(char *source, int ac, char **av);
+EI int anope_event_snick(char *source, int ac, char **av);
+EI int anope_event_vhost(char *source, int ac, char **av);
+EI int anope_event_tkl(char *source, int ac, char **av);
+EI int anope_event_eos(char *source, int ac, char **av);
+EI int anope_event_eob(char *source, int ac, char **av);
+EI int anope_event_pass(char *source, int ac, char **av);
+EI int anope_event_netinfo(char *source, int ac, char **av);
+EI int anope_event_error(char *source, int ac, char **av);
+EI int anope_event_eb(char *source, int ac, char **av);
+EI int anope_event_netctrl(char *source, int ac, char **av);
+EI int anope_event_notice(char *source, int ac, char **av);
+EI int anope_event_snotice(char *source, int ac, char **av);
+EI int anope_event_sqline(char *source, int ac, char **av);
+EI int anope_event_smo(char *source, int ac, char **av);
+EI int anope_event_myid(char *source, int ac, char **av);
+EI int anope_event_vctrl(char *source, int ac, char **av);
+EI int anope_event_tctrl(char *source, int ac, char **av);
+EI int anope_event_snetinfo(char *source, int ac, char **av);
+EI int anope_event_umode2(char *source, int ac, char **av);
+EI int anope_event_globops(char *source, int ac, char **av);
+EI int anope_event_swhois(char *source, int ac, char **av);
+EI int anope_event_burst(char *source, int ac, char **av);
+EI int anope_event_luserslock(char *source, int ac, char **av);
+EI int anope_event_admin(char *source, int ac, char **av);
+EI int anope_event_credits(char *source, int ac, char **av);
+EI int anope_event_rehash(char *source, int ac, char **av);
+EI int anope_event_sdesc(char *source, int ac, char **av);
+EI int anope_event_netglobal(char *source, int ac, char **av);
+EI int anope_event_invite(char *source, int ac, char **av);
+E int anope_event_null(char *source, int ac, char **av);
+
+E void anope_set_umode(User * user, int ac, char **av);
+E void anope_cmd_svid_umode(char *nick, time_t ts);
+E void anope_cmd_svid_umode2(User *u, char *ts);
+E void anope_cmd_svid_umode3(User *u, char *ts);
+E void anope_cmd_nc_change(User *u);
+E int anope_flood_mode_check(char *value);
+
+E void anope_cmd_jupe(char *jserver, char *who, char *reason);
+
+E void anope_cmd_global_legacy(char *source, char *fmt);
+E void wallops(char *source, const char *fmt, ...);
+
+E int anope_valid_nick(char *nick);
+E int anope_valid_chan(char *chan);
+
+E char *common_get_vident(User *u);
+E char *common_get_vhost(User *u);
+E char *send_token(char *token1, char *token2);
+E char *base64enc(long i);
+E long base64dec(char *b64);
+E long base64dects(char *ts);
+E int b64_encode(char *src, size_t srclength, char *target, size_t targsize);
+E int b64_decode(char *src, char *target, size_t targsize);
+E char *encode_ip(unsigned char *ip);
+E int decode_ip(char *buf);
+
+#define Anope_Free(x) if ((x) != NULL) free(x)
+
+E char *host_resolve(char *host);
+
+E void event_message_process(char *eventbuf);
+E void eventprintf(char *fmt, ...);
+E void event_process_hook(const char *name, int argc, char **argv);
+E void send_event(const char *name, int argc, ...);
+
+#ifdef _WIN32
+E char *GetWindowsVersion(void) ;
+E int SupportedWindowsVersion(void);
+#endif
+
+#endif /* EXTERN_H */
diff --git a/include/makefile.win32 b/include/makefile.win32
new file mode 100644
index 000000000..5d0b9b49b
--- /dev/null
+++ b/include/makefile.win32
@@ -0,0 +1,25 @@
+# Make file for Win32
+#
+# (C) 2003-2008 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/messages.h b/include/messages.h
new file mode 100644
index 000000000..47ac9cda7
--- /dev/null
+++ b/include/messages.h
@@ -0,0 +1,23 @@
+/* Declarations of IRC message structures, variables, and functions.
+ *
+ * (C) 2003-2008 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.
+ *
+ * $Id$
+ *
+ */
+
+/*************************************************************************/
+#include "modules.h"
+
+extern Message messages[];
+extern void moduleAddMsgs(void);
+extern Message *find_message(const char *name);
+
+
+/*************************************************************************/
diff --git a/include/module.h b/include/module.h
new file mode 100644
index 000000000..bd5171c8b
--- /dev/null
+++ b/include/module.h
@@ -0,0 +1,16 @@
+#ifndef MODULE_H
+#define MODULE_H
+
+#include "services.h"
+#include "commands.h"
+#include "language.h"
+#include "modules.h"
+#include "depricated.h"
+#include "version.h"
+
+#define MOD_UNIQUE 0
+#define MOD_HEAD 1
+#define MOD_TAIL 2
+
+#endif
+
diff --git a/include/modules.h b/include/modules.h
new file mode 100644
index 000000000..c04138a23
--- /dev/null
+++ b/include/modules.h
@@ -0,0 +1,383 @@
+/* Modular support
+ *
+ * (C) 2003-2008 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.
+ *
+ * $Id$
+ */
+
+#ifndef MODULES_H
+#define MODULES_H
+
+#include <time.h>
+#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;
+
+#define ano_modopen(file) dlopen(file, RTLD_LAZY)
+#define ano_moderr() dlerror()
+#define ano_modsym(file, symbol) dlsym(file, DL_PREFIX symbol)
+#define ano_modclose(file) dlclose(file)
+/* We call dlerror() here because it clears the module error after being
+ * called. This previously read 'errno = 0', but that didn't work on
+ * all POSIX-compliant architectures. This way the error is guaranteed
+ * to be cleared, POSIX-wise. -GD
+ */
+#define ano_modclearerr() dlerror()
+#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
+
+#define MOD_STOP 1
+#define MOD_CONT 0
+
+#define HOSTSERV HS_cmdTable /* using HOSTSERV etc. looks nicer than HS_cmdTable for modules */
+#define BOTSERV BS_cmdTable
+#define MEMOSERV MS_cmdTable
+#define NICKSERV NS_cmdTable
+#define CHANSERV CS_cmdTable
+#define HELPSERV HE_cmdTable
+#define OPERSERV OS_cmdTable
+#define IRCD IRCD_cmdTable
+#define MODULE_HASH Module_table
+#define EVENT EVENT_cmdTable
+#define EVENTHOOKS HOOK_cmdTable
+
+/**********************************************************************
+ * Module Returns
+ **********************************************************************/
+ #define MOD_ERR_OK 0
+ #define MOD_ERR_MEMORY 1
+ #define MOD_ERR_PARAMS 2
+ #define MOD_ERR_EXISTS 3
+ #define MOD_ERR_NOEXIST 4
+ #define MOD_ERR_NOUSER 5
+ #define MOD_ERR_NOLOAD 6
+ #define MOD_ERR_NOUNLOAD 7
+ #define MOD_ERR_SYNTAX 8
+ #define MOD_ERR_NODELETE 9
+ #define MOD_ERR_UNKNOWN 10
+ #define MOD_ERR_FILE_IO 11
+ #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
+/*************************************************************************/
+
+typedef enum { CORE,PROTOCOL,THIRD,SUPPORTED,QATESTED,ENCRYPTION } MODType;
+typedef enum { MOD_OP_LOAD, MOD_OP_UNLOAD } ModuleOperation;
+
+/*************************************************************************/
+/* Structure for information about a *Serv command. */
+
+typedef struct Command_ Command;
+typedef struct CommandHash_ CommandHash;
+typedef struct Module_ Module;
+typedef struct ModuleLang_ ModuleLang;
+typedef struct ModuleHash_ ModuleHash;
+typedef struct ModuleQueue_ ModuleQueue;
+typedef struct Message_ Message;
+typedef struct MessageHash_ MessageHash;
+typedef struct ModuleCallBack_ ModuleCallBack;
+typedef struct EvtMessage_ EvtMessage;
+typedef struct EvtMessageHash_ EvtMessageHash;
+typedef struct EvtHook_ EvtHook;
+typedef struct EvtHookHash_ EvtHookHash;
+
+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];
+extern MDE ModuleHash *MODULE_HASH[MAX_CMD_HASH];
+extern MDE EvtMessageHash *EVENT[MAX_CMD_HASH];
+extern MDE EvtHookHash *EVENTHOOKS[MAX_CMD_HASH];
+
+struct ModuleLang_ {
+ int argc;
+ char **argv;
+};
+
+struct Module_ {
+ char *name;
+ char *filename;
+ void *handle;
+ time_t time;
+ char *version;
+ char *author;
+
+ MODType type;
+
+ void (*nickHelp)(User *u); /* service 1 */
+ void (*chanHelp)(User *u); /* 2 */
+ void (*memoHelp)(User *u); /* 3 */
+ void (*botHelp)(User *u); /* 4 */
+ void (*operHelp)(User *u); /* 5 */
+ void (*hostHelp)(User *u); /* 6 */
+ void (*helpHelp)(User *u); /* 7 */
+
+/* CommandHash *cmdList[MAX_CMD_HASH]; */
+ MessageHash *msgList[MAX_CMD_HASH];
+ ModuleLang lang[NUM_LANGS];
+};
+
+struct ModuleHash_ {
+ char *name;
+ Module *m;
+ ModuleHash *next;
+};
+
+struct ModuleQueue_ {
+ Module *m;
+ ModuleOperation op;
+ User *u;
+
+ ModuleQueue *next;
+};
+
+struct Command_ {
+ char *name;
+ int (*routine)(User *u);
+ int (*has_priv)(User *u); /* Returns 1 if user may use command, else 0 */
+
+ /* Regrettably, these are hard-coded to correspond to current privilege
+ * levels (v4.0). Suggestions for better ways to do this are
+ * appreciated.
+ */
+ int helpmsg_all; /* Displayed to all users; -1 = no message */
+ int helpmsg_reg; /* Displayed to regular users only */
+ int helpmsg_oper; /* Displayed to Services operators only */
+ int helpmsg_admin; /* Displayed to Services admins only */
+ int helpmsg_root; /* Displayed to Services root only */
+ char *help_param1;
+ char *help_param2;
+ char *help_param3;
+ char *help_param4;
+
+ /* Module related stuff */
+ int core; /* Can this command be deleted? */
+ char *mod_name; /* Name of the module who owns us, NULL for core's */
+ char *service; /* Service we provide this command for */
+ int (*all_help)(User *u);
+ int (*regular_help)(User *u);
+ int (*oper_help)(User *u);
+ int (*admin_help)(User *u);
+ int (*root_help)(User *u);
+
+ Command *next; /* Next command responsible for the same command */
+};
+
+struct CommandHash_ {
+ char *name; /* Name of the command */
+ Command *c; /* Actual command */
+ CommandHash *next; /* Next command */
+};
+
+struct Message_ {
+ char *name;
+ int (*func)(char *source, int ac, char **av);
+ int core;
+ char *mod_name;
+ Message *next;
+};
+
+struct MessageHash_ {
+ char *name;
+ Message *m;
+ MessageHash *next;
+};
+
+struct ModuleCallBack_ {
+ char *name;
+ char *owner_name;
+ time_t when;
+ int (*func)(int argc, char *argv[]);
+ int argc;
+ char **argv;
+ ModuleCallBack *next;
+};
+
+struct EvtMessage_ {
+ char *name;
+ int (*func)(char *source, int ac, char **av);
+ int core;
+ char *mod_name;
+ EvtMessage *next;
+};
+
+struct EvtMessageHash_ {
+ char *name;
+ EvtMessage *evm;
+ EvtMessageHash *next;
+};
+
+
+struct EvtHook_ {
+ int (*func)(int argc, char **argv);
+ int core;
+ char *name;
+ char *mod_name;
+ EvtHook *next;
+};
+
+struct EvtHookHash_ {
+ char *name;
+ EvtHook *evh;
+ EvtHookHash *next;
+};
+
+
+/*************************************************************************/
+/* Module Managment Functions */
+MDE Module *createModule(char *filename); /* Create a new module, using the given name */
+int destroyModule(Module *m); /* Delete the module */
+int addModule(Module *m); /* Add a module to the module hash */
+int delModule(Module *m); /* Remove a module from the module hash */
+MDE Module *findModule(char *name); /* Find a module */
+int loadModule(Module *m,User *u); /* Load the given module into the program */
+int encryption_module_init(void); /* Load the encryption module */
+int protocol_module_init(void); /* Load the IRCD Protocol Module up*/
+int unloadModule(Module *m, User *u); /* Unload the given module from the pro */
+int prepForUnload(Module *m); /* Prepare the module for unload */
+MDE void moduleAddVersion(const char *version);
+MDE void moduleAddAuthor(const char *author);
+void modules_init(void);
+void modules_delayed_init(void);
+void moduleCallBackPrepForUnload(char *mod_name);
+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));
+MDE void moduleSetType(MODType type);
+extern MDE Module *mod_current_module;
+extern MDE char *mod_current_module_name;
+extern MDE char *mod_current_buffer;
+extern MDE int mod_current_op;
+extern MDE User *mod_current_user;
+
+MDE int moduleGetConfigDirective(Directive *h);
+/*************************************************************************/
+/*************************************************************************/
+/* Command Managment Functions */
+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 */
+MDE Message *createMessage(const char *name,int (*func)(char *source, int ac, char **av));
+Message *findMessage(MessageHash *msgTable[], const char *name); /* Find a Message */
+MDE int addMessage(MessageHash *msgTable[], Message *m, int pos); /* Add a Message to a Message table */
+MDE int addCoreMessage(MessageHash *msgTable[], Message *m); /* Add a Message to a Message table */
+MDE int moduleAddMessage(Message *m, int pos);
+int delMessage(MessageHash *msgTable[], Message *m, char *mod_name); /* Del a Message from a msg table */
+MDE int moduleDelMessage(char *name);
+int destroyMessage(Message *m); /* destroy a Message*/
+
+/*************************************************************************/
+
+MDE EvtMessage *createEventHandler(char *name, int (*func) (char *source, int ac, char **av));
+EvtMessage *findEventHandler(EvtMessageHash * msgEvtTable[], const char *name);
+int addCoreEventHandler(EvtMessageHash * msgEvtTable[], EvtMessage * evm);
+MDE int moduleAddEventHandler(EvtMessage * evm);
+MDE int moduleEventDelHandler(char *name);
+int delEventHandler(EvtMessageHash * msgEvtTable[], EvtMessage * evm, char *mod_name);
+int destroyEventHandler(EvtMessage * evm);
+int addEventHandler(EvtMessageHash * msgEvtTable[], EvtMessage * evm);
+
+MDE EvtHook *createEventHook(char *name, int (*func) (int argc, char **argv));
+EvtHook *findEventHook(EvtHookHash * HookEvtTable[], const char *name);
+int addCoreEventHook(EvtHookHash * HookEvtTable[], EvtHook * evh);
+MDE int moduleAddEventHook(EvtHook * evh);
+MDE int moduleEventDelHook(const char *name);
+int delEventHook(EvtHookHash * HookEvtTable[], EvtHook * evh, char *mod_name);
+int destroyEventHook(EvtHook * evh);
+extern char *mod_current_evtbuffer;
+
+MDE void moduleInsertLanguage(int langNumber, int ac, char **av);
+MDE void moduleNoticeLang(char *source, User *u, int number, ...);
+MDE char *moduleGetLangString(User * u, int number);
+MDE void moduleDeleteLanguage(int langNumber);
+
+/*************************************************************************/
+
+MDE int moduleAddCallback(char *name,time_t when,int (*func)(int argc, char *argv[]),int argc, char **argv);
+MDE void moduleDelCallback(char *name);
+
+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 */
+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 */
+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 */
+
+/*************************************************************************/
+/* Module Queue Operations */
+MDE int queueModuleLoad(char *name, User *u);
+MDE int queueModuleUnload(char *name, User *u);
+MDE void handleModuleOperationQueue(void);
+
+/*************************************************************************/
+/* Some IRCD protocol module support functions */
+
+/** Update the protect deatials, could be either protect or admin etc.. */
+MDE void updateProtectDetails(char *level_info_protect_word, char *level_info_protectme_word, char *fant_protect_add, char *fant_protect_del, char *level_protect_word, char *protect_set_mode, char *protect_unset_mode);
+
+/************************************************************************/
+
+#endif
+/* EOF */
diff --git a/include/pseudo.h b/include/pseudo.h
new file mode 100644
index 000000000..e20ec8b7b
--- /dev/null
+++ b/include/pseudo.h
@@ -0,0 +1,20 @@
+/* Include extra includes needed by most/all pseudo-clients.
+ *
+ * (C) 2003-2008 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.
+ *
+ * $Id$
+ *
+ */
+
+#include "commands.h"
+#include "language.h"
+#include "timeout.h"
+#include "encrypt.h"
+#include "datafiles.h"
+#include "slist.h"
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
new file mode 100644
index 000000000..f350d0d2a
--- /dev/null
+++ b/include/services.h
@@ -0,0 +1,1389 @@
+/*
+ *
+ * (C) 2003-2008 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 SERVICES_H
+#define SERVICES_H
+
+/*************************************************************************/
+
+#include "sysconf.h"
+#include "config.h"
+
+#ifndef MAX_CMD_HASH
+#define MAX_CMD_HASH 1024
+#endif
+
+/* Some Linux boxes (or maybe glibc includes) require this for the
+ * prototype of strsignal(). */
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+/* Some SUN fixs */
+#ifdef __sun
+/* Solaris specific code, types that do not exist in Solaris'
+ * sys/types.h
+ **/
+#undef u_int8_t
+#undef u_int16_t
+#undef u_int32_t
+#undef u_int_64_t
+#define u_int8_t uint8_t
+#define u_int16_t uint16_t
+#define u_int32_t uint32_t
+#define u_int64_t uint64_t
+
+#ifndef INADDR_NONE
+#define INADDR_NONE (-1)
+#endif
+
+#endif
+
+
+#include <stdarg.h>
+#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
+
+#ifndef _WIN32
+#include <dirent.h>
+#endif
+
+#ifdef _WIN32
+/* VS2008 hates having this define before its own */
+#define vsnprintf _vsnprintf
+#endif
+
+#ifdef USE_RDB
+# define MAX_SQL_BUF 4096
+#endif
+
+#ifdef USE_MYSQL
+# define MYSQL_WARNING 2
+# define MYSQL_ERROR 4
+# define MYSQL_DEFAULT_PORT 3306
+#ifdef MYSQL_HEADER_PREFIX
+# include <mysql/mysql.h>
+# include <mysql/errmsg.h>
+#else
+# include <mysql.h>
+# include <errmsg.h>
+#endif
+#endif
+
+#if HAVE_STRINGS_H
+# include <strings.h>
+#endif
+
+#if HAVE_SYS_SELECT_H
+# include <sys/select.h>
+#endif
+
+#include "sockets.h"
+
+#ifndef va_copy
+# ifdef __va_copy
+# define VA_COPY(DEST,SRC) __va_copy((DEST),(SRC))
+# else
+# define VA_COPY(DEST, SRC) memcpy ((&DEST), (&SRC), sizeof(va_list))
+# endif
+#else
+# ifdef HAVE_VA_LIST_AS_ARRAY
+# define VA_COPY(DEST,SRC) (*(DEST) = *(SRC))
+# else
+# define VA_COPY(DEST, SRC) va_copy(DEST, SRC)
+# endif
+#endif
+
+#ifdef _AIX
+/* Some AIX boxes seem to have bogus includes that don't have these
+ * prototypes. */
+extern int strcasecmp(const char *, const char *);
+extern int strncasecmp(const char *, const char *, size_t);
+# if 0 /* These break on some AIX boxes (4.3.1 reported). */
+extern int gettimeofday(struct timeval *, struct timezone *);
+extern int socket(int, int, int);
+extern int bind(int, struct sockaddr *, int);
+extern int connect(int, struct sockaddr *, int);
+extern int shutdown(int, int);
+# endif
+# undef FD_ZERO
+# define FD_ZERO(p) memset((p), 0, sizeof(*(p)))
+#endif /* _AIX */
+
+/* Alias stricmp/strnicmp to strcasecmp/strncasecmp if we have the latter
+ * but not the former. */
+#if !HAVE_STRICMP && HAVE_STRCASECMP
+# define stricmp strcasecmp
+# define strnicmp strncasecmp
+#endif
+
+/* We have our own versions of toupper()/tolower(). */
+#include <ctype.h>
+#undef tolower
+#undef toupper
+#define tolower tolower_
+#define toupper toupper_
+
+/* We also have our own encrypt(). */
+#define encrypt encrypt_
+
+
+#ifdef __WINS__
+#ifndef BKCHECK
+#define BKCHECK
+ extern "C" void __pfnBkCheck() {}
+#endif
+#endif
+
+
+#if INTTYPE_WORKAROUND
+# undef int16
+# undef int32
+#endif
+
+
+/* Miscellaneous definitions. */
+#include "defs.h"
+#include "slist.h"
+#include "events.h"
+
+/*************************************************************************/
+
+typedef struct server_ Server;
+typedef struct user_ User;
+typedef struct channel_ Channel;
+typedef struct c_elist EList;
+typedef struct c_elist_entry Entry;
+typedef struct ModuleData_ ModuleData; /* ModuleData struct */
+typedef struct memo_ Memo;
+typedef struct nickrequest_ NickRequest;
+typedef struct nickalias_ NickAlias;
+typedef struct nickcore_ NickCore;
+typedef struct botinfo_ BotInfo;
+typedef struct chaninfo_ ChannelInfo;
+typedef struct badword_ BadWord;
+typedef struct bandata_ BanData;
+typedef struct userdata_ UserData;
+typedef struct mailinfo_ MailInfo;
+typedef struct akill_ Akill;
+typedef struct sxline_ SXLine;
+typedef struct hostcore_ HostCore;
+typedef struct newsitem_ NewsItem;
+typedef struct exception_ Exception;
+typedef struct cbmode_ CBMode;
+typedef struct cbmodeinfo_ CBModeInfo;
+typedef struct cmmode_ CMMode;
+typedef struct csmode_ CSMode;
+typedef struct cumode_ CUMode;
+typedef struct csmodeutil_ CSModeUtil;
+typedef struct session_ Session;
+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 */
+
+/*************************************************************************/
+
+/* Protocol tweaks */
+
+typedef struct ircdvars_ IRCDVar;
+typedef struct ircdcapab_ IRCDCAPAB;
+
+struct ircdvars_ {
+ char *name; /* Name of the ChanServ command */
+ char *nickservmode; /* Mode used by NickServ */
+ char *chanservmode; /* Mode used by ChanServ */
+ char *memoservmode; /* Mode used by MemoServ */
+ char *hostservmode; /* Mode used by HostServ */
+ char *operservmode; /* Mode used by OperServ */
+ char *botservmode; /* Mode used by BotServ */
+ char *helpservmode; /* Mode used by HelpServ */
+ char *devnullmode; /* Mode used by Dev/Null */
+ char *globalmode; /* Mode used by Global */
+ char *nickservaliasmode; /* Mode used by NickServ Alias */
+ char *chanservaliasmode; /* Mode used by ChanServ Alias */
+ char *memoservaliasmode; /* Mode used by MemoServ Alias */
+ char *hostservaliasmode; /* Mode used by HostServ Alias */
+ char *operservaliasmode; /* Mode used by OperServ Alias */
+ char *botservaliasmode; /* Mode used by BotServ Alias */
+ char *helpservaliasmode; /* Mode used by HelpServ Alias */
+ char *devnullvaliasmode; /* Mode used by Dev/Null Alias */
+ char *globalaliasmode; /* Mode used by Global Alias */
+ char *botserv_bot_mode; /* Mode used by BotServ Bots */
+ int max_symbols; /* Chan Max Symbols */
+ char *modestoremove; /* Channel Modes to remove */
+ char *botchanumode; /* Modes set when botserv joins a channel */
+ int svsnick; /* Supports SVSNICK */
+ int vhost; /* Supports vhost */
+ int owner; /* Supports Owner */
+ char *ownerset; /* Mode to set for owner */
+ char *ownerunset; /* Mode to unset for a owner */
+ char *adminset; /* Mode to set for admin */
+ char *adminunset; /* Mode to unset for admin */
+ char *modeonreg; /* Mode on Register */
+ char *rootmodeonid; /* Mode on ID for ROOTS */
+ char *adminmodeonid; /* Mode on ID for ADMINS */
+ char *opermodeonid; /* Mode on ID for OPERS */
+ char *modeonunreg; /* Mode on Unregister */
+ char *modeonnick; /* Mode on nick change */
+ int sgline; /* Supports SGline */
+ int sqline; /* Supports SQline */
+ int szline; /* Supports SZline */
+ int halfop; /* Supports HalfOp */
+ int numservargs; /* Number of Server Args */
+ int join2set; /* Join 2 Set Modes */
+ int join2msg; /* Join 2 Message */
+ int except; /* exception +e */
+ int topictsforward; /* TS on Topics Forward */
+ int topictsbackward; /* TS on Topics Backward */
+ uint32 protectedumode; /* What is the Protected Umode */
+ int admin; /* Has Admin */
+ int chansqline; /* Supports Channel Sqlines */
+ int quitonkill; /* IRCD sends QUIT when kill */
+ int svsmode_unban; /* svsmode can be used to unban */
+ int protect; /* Has protect modes */
+ int reversekickcheck; /* Can reverse ban check */
+ int chanreg; /* channel mode +r for register */
+ uint32 regmode; /* Mode to use for +r */
+ int vident; /* Supports vidents */
+ int svshold; /* Supports svshold */
+ int tsonmode; /* Timestamp on mode changes */
+ int nickip; /* Sends IP on NICK */
+ int omode; /* On the fly o:lines */
+ int umode; /* change user modes */
+ int nickvhost; /* Users vhost sent during NICK */
+ int chgreal; /* Change RealName */
+ uint32 noknock; /* Channel Mode for no knock */
+ uint32 adminmode; /* Admin Only Channel Mode */
+ uint32 defmlock; /* Default mlock modes */
+ uint32 vhostmode; /* Vhost mode */
+ int fmode; /* +f */
+ int Lmode; /* +L */
+ uint32 chan_fmode; /* Mode */
+ uint32 chan_lmode; /* Mode */
+ int check_nick_id; /* On nick change check if they could be identified */
+ int knock_needs_i; /* Check if we needed +i when setting NOKNOCK */
+ char *chanmodes; /* If the ircd sends CHANMODE in CAPAB this is where we store it */
+ int token; /* Does Anope support the tokens for the ircd */
+ int tokencaseless; /* TOKEN are not case senstive - most its Unreal that is case senstive */
+ int sjb64; /* Base 64 encode TIMESTAMP */
+ 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 */
+ int ts6; /* ircd is TS6 */
+ int supporthelper; /* +h helper umodes */
+ int p10; /* ircd is P10 */
+ char *nickchars; /* character set */
+ int sync; /* reports sync state */
+ int cidrchanbei; /* channel bans/excepts/invites support CIDR (syntax: +b *!*@192.168.0.0/15)
+ * 0 for no support, 1 for strict cidr support, anything else
+ * for ircd specific support (nefarious only cares about first /mask) */
+};
+
+struct ircdcapab_ {
+ uint32 noquit;
+ uint32 tsmode;
+ uint32 unconnect;
+ uint32 nickip;
+ uint32 nsjoin;
+ uint32 zip;
+ uint32 burst;
+ uint32 ts5;
+ uint32 ts3;
+ uint32 dkey;
+ uint32 pt4;
+ uint32 scs;
+ uint32 qs;
+ uint32 uid;
+ uint32 knock;
+ uint32 client;
+ uint32 ipv6;
+ uint32 ssj5;
+ uint32 sn2;
+ uint32 token;
+ uint32 vhost;
+ uint32 ssj3;
+ uint32 nick2;
+ uint32 umode2;
+ uint32 vl;
+ uint32 tlkext;
+ uint32 dodkey;
+ uint32 dozip;
+ uint32 chanmodes;
+ uint32 sjb64;
+ uint32 nickchars;
+};
+
+/* tiny struct needed for P10 and other UID servers so we can track
+ services UID
+*/
+struct uid_ {
+ Uid *next, *prev;
+ char nick[NICKMAX];
+ char *uid;
+};
+
+/*************************************************************************/
+/* Config Details */
+/*************************************************************************/
+
+#define MAXPARAMS 8
+
+/* Configuration directives */
+
+typedef struct {
+ char *name;
+ struct {
+ int type; /* PARAM_* below */
+ int flags; /* Same */
+ void *ptr; /* Pointer to where to store the value */
+ } params[MAXPARAMS];
+} Directive;
+
+#define PARAM_NONE 0
+#define PARAM_INT 1
+#define PARAM_POSINT 2 /* Positive integer only */
+#define PARAM_PORT 3 /* 1..65535 only */
+#define PARAM_STRING 4
+#define PARAM_TIME 5
+#define PARAM_STRING_ARRAY 6 /* Array of string */
+#define PARAM_SET -1 /* Not a real parameter; just set the
+ * given integer variable to 1 */
+#define PARAM_DEPRECATED -2 /* Set for deprecated directives; `ptr'
+ * is a function pointer to call */
+
+/* Flags: */
+#define PARAM_OPTIONAL 0x01
+#define PARAM_FULLONLY 0x02 /* Directive only allowed if !STREAMLINED */
+#define PARAM_RELOAD 0x04 /* Directive is reloadable */
+
+/*************************************************************************/
+
+/* File version for each database. Was one version for all before but was
+ changed so they are now easier to maintain. =) */
+
+#define BOT_VERSION 10
+#define CHAN_VERSION 16
+#define EXCEPTION_VERSION 9
+#define NEWS_VERSION 9
+#define NICK_VERSION 14
+#define PRE_NICK_VERSION 2
+#define OPER_VERSION 13
+#define HELP_VERSION 1
+#define HOST_VERSION 3
+
+/*************************************************************************/
+
+
+/**
+ * ModuleData strucs used to allow modules to add / delete module Data from existing structs
+ */
+
+struct ModuleData_ {
+ char *moduleName; /* Which module we belong to */
+ char *key; /* The key */
+ char *value; /* The Value */
+ ModuleData *next; /* The next ModuleData record */
+};
+
+ /*************************************************************************/
+
+/* Memo info structures. Since both nicknames and channels can have memos,
+ * we encapsulate memo data in a MemoList to make it easier to handle. */
+
+struct memo_ {
+ uint32 number; /* Index number -- not necessarily array position! */
+ uint16 flags;
+ time_t time; /* When it was sent */
+ char sender[NICKMAX];
+ char *text;
+ ModuleData *moduleData; /* Module saved data attached to the Memo */
+#ifdef USE_MYSQL
+ uint32 id; /* Database ID; see mysql.c */
+#endif
+};
+
+typedef struct {
+ int16 memocount, memomax;
+ Memo *memos;
+} MemoInfo;
+
+/*************************************************************************/
+
+/* NickServ nickname structures. */
+
+
+struct nickrequest_ {
+ NickRequest *next, *prev;
+ char *nick;
+ char *passcode;
+ char password[PASSMAX];
+ char *email;
+ time_t requested;
+ time_t lastmail; /* Unsaved */
+};
+
+struct nickalias_ {
+ NickAlias *next, *prev;
+ char *nick; /* Nickname */
+ char *last_quit; /* Last quit message */
+ char *last_realname; /* Last realname */
+ char *last_usermask; /* Last usermask */
+ time_t time_registered; /* When the nick was registered */
+ time_t last_seen; /* When it was seen online for the last time */
+ uint16 status; /* See NS_* below */
+ NickCore *nc; /* I'm an alias of this */
+ /* Not saved */
+ ModuleData *moduleData; /* Module saved data attached to the nick alias */
+ User *u; /* Current online user that has me */
+};
+
+struct nickcore_ {
+ NickCore *next, *prev;
+
+ char *display; /* How the nick is displayed */
+ char pass[PASSMAX]; /* Password of the nicks */
+ char *email; /* E-mail associated to the nick */
+ char *greet; /* Greet associated to the nick */
+ uint32 icq; /* ICQ # associated to the nick */
+ char *url; /* URL associated to the nick */
+ uint32 flags; /* See NI_* below */
+ uint16 language; /* Language selected by nickname owner (LANG_*) */
+ uint16 accesscount; /* # of entries */
+ char **access; /* Array of strings */
+ MemoInfo memos;
+ uint16 channelcount; /* Number of channels currently registered */
+ uint16 channelmax; /* Maximum number of channels allowed */
+
+ /* Unsaved data */
+ ModuleData *moduleData; /* Module saved data attached to the NickCore */
+ time_t lastmail; /* Last time this nick record got a mail */
+ SList aliases; /* List of aliases */
+};
+
+
+/*************************************************************************/
+
+/* Bot info structures. Note that since there won't be many bots,
+ * they're not in a hash list.
+ * --lara
+ */
+
+struct botinfo_ {
+ BotInfo *next, *prev;
+
+ char *nick; /* Nickname of the bot */
+ char *user; /* Its user name */
+ char *host; /* Its hostname */
+ char *real; /* Its real name */
+ int16 flags; /* Bot flags -- see BI_* below */
+ time_t created; /* Birth date ;) */
+ int16 chancount; /* Number of channels that use the bot. */
+ /* Dynamic data */
+ time_t lastmsg; /* Last time we said something */
+};
+
+
+
+/* Channel info structures. Stored similarly to the nicks, except that
+ * the second character of the channel name, not the first, is used to
+ * determine the list. (Hashing based on the first character of the name
+ * wouldn't get very far. ;) ) */
+
+/* Access levels for users. */
+typedef struct {
+ uint16 in_use; /* 1 if this entry is in use, else 0 */
+ int16 level;
+ NickCore *nc; /* Guaranteed to be non-NULL if in use, NULL if not */
+ time_t last_seen;
+} ChanAccess;
+
+/* Note that these two levels also serve as exclusive boundaries for valid
+ * access levels. ACCESS_FOUNDER may be assumed to be strictly greater
+ * than any valid access level, and ACCESS_INVALID may be assumed to be
+ * strictly less than any valid access level. Also read below.
+ */
+#define ACCESS_FOUNDER 10000 /* Numeric level indicating founder access */
+#define ACCESS_INVALID -10000 /* Used in levels[] for disabled settings */
+/* There is one exception to the above access levels: SuperAdmins will have
+ * access level 10001. This level is never stored, however; it is only used
+ * in comparison and to let SuperAdmins win from founders where needed
+ */
+#define ACCESS_SUPERADMIN 10001
+
+/* Levels for xOP */
+
+#define ACCESS_VOP 3
+#define ACCESS_HOP 4
+#define ACCESS_AOP 5
+#define ACCESS_SOP 10
+
+/* AutoKick data. */
+typedef struct {
+ int16 in_use; /* Always 0 if not in use */
+ int16 is_nick; /* 1 if a regged nickname, 0 if a nick!user@host mask */
+ uint16 flags;
+ union {
+ char *mask; /* Guaranteed to be non-NULL if in use, NULL if not */
+ NickCore *nc; /* Same */
+ } u;
+ char *reason;
+
+ char *creator;
+ time_t addtime;
+} AutoKick;
+
+#define AK_USED 0x0001
+#define AK_ISNICK 0x0002
+#define AK_STUCK 0x0004
+
+/* Structure used to contain bad words. */
+
+struct badword_ {
+ uint16 in_use;
+ char *word;
+ uint16 type; /* BW_* below */
+};
+
+#define BW_ANY 0
+#define BW_SINGLE 1
+#define BW_START 2
+#define BW_END 3
+
+
+struct chaninfo_ {
+ ChannelInfo *next, *prev;
+ char name[CHANMAX];
+ NickCore *founder;
+ NickCore *successor; /* Who gets the channel if the founder
+ * nick is dropped or expires */
+ char founderpass[PASSMAX];
+ char *desc;
+ char *url;
+ char *email;
+
+ time_t time_registered;
+ time_t last_used;
+ char *last_topic; /* Last topic on the channel */
+ char last_topic_setter[NICKMAX]; /* Who set the last topic */
+ time_t last_topic_time; /* When the last topic was set */
+
+ uint32 flags; /* See below */
+ char *forbidby;
+ char *forbidreason;
+
+ int16 bantype;
+ int16 *levels; /* Access levels for commands */
+
+ uint16 accesscount;
+ ChanAccess *access; /* List of authorized users */
+ uint16 akickcount;
+ AutoKick *akick; /* List of users to kickban */
+
+ uint32 mlock_on, mlock_off; /* See channel modes below */
+ uint32 mlock_limit; /* 0 if no limit */
+ char *mlock_key; /* NULL if no key */
+ char *mlock_flood; /* NULL if no +f */
+ char *mlock_redirect; /* NULL if no +L */
+
+ char *entry_message; /* Notice sent on entering channel */
+
+ MemoInfo memos;
+
+ struct channel_ *c; /* Pointer to channel record (if *
+ * channel is currently in use) */
+
+ ModuleData *moduleData; /* Module saved data attached to the ChannelInfo */
+
+ /* For BotServ */
+
+ BotInfo *bi; /* Bot used on this channel */
+ uint32 botflags; /* BS_* below */
+ int16 *ttb; /* Times to ban for each kicker */
+
+ uint16 bwcount;
+ BadWord *badwords; /* For BADWORDS kicker */
+ int16 capsmin, capspercent; /* For CAPS kicker */
+ int16 floodlines, floodsecs; /* For FLOOD kicker */
+ int16 repeattimes; /* For REPEAT kicker */
+};
+
+/* Retain topic even after last person leaves channel */
+#define CI_KEEPTOPIC 0x00000001
+/* Don't allow non-authorized users to be opped */
+#define CI_SECUREOPS 0x00000002
+/* Hide channel from ChanServ LIST command */
+#define CI_PRIVATE 0x00000004
+/* Topic can only be changed by SET TOPIC */
+#define CI_TOPICLOCK 0x00000008
+/* Those not allowed ops are kickbanned */
+#define CI_RESTRICTED 0x00000010
+/* Don't allow ChanServ and BotServ commands to do bad things to bigger levels */
+#define CI_PEACE 0x00000020
+/* Don't allow any privileges unless a user is IDENTIFY'd with NickServ */
+#define CI_SECURE 0x00000040
+/* Don't allow the channel to be registered or used */
+#define CI_VERBOTEN 0x00000080
+/* Channel password is encrypted */
+#define CI_ENCRYPTEDPW 0x00000100
+/* Channel does not expire */
+#define CI_NO_EXPIRE 0x00000200
+/* Channel memo limit may not be changed */
+#define CI_MEMO_HARDMAX 0x00000400
+/* Send notice to channel on use of OP/DEOP */
+#define CI_OPNOTICE 0x00000800
+/* Stricter control of channel founder status */
+#define CI_SECUREFOUNDER 0x00001000
+/* Always sign kicks */
+#define CI_SIGNKICK 0x00002000
+/* Sign kicks if level is < than the one defined by the SIGNKICK level */
+#define CI_SIGNKICK_LEVEL 0x00004000
+/* Use the xOP lists */
+#define CI_XOP 0x00008000
+/* Channel is suspended */
+#define CI_SUSPENDED 0x00010000
+
+/* TEMPORARY - ChanServ is on the channel. */
+#define CI_INHABIT 0x80000000
+
+/* Indices for cmd_access[]: */
+#define CA_INVITE 0
+#define CA_AKICK 1
+#define CA_SET 2 /* but not FOUNDER or PASSWORD */
+#define CA_UNBAN 3
+#define CA_AUTOOP 4
+#define CA_AUTODEOP 5 /* Maximum, not minimum */
+#define CA_AUTOVOICE 6
+#define CA_OPDEOP 7 /* ChanServ commands OP and DEOP */
+#define CA_ACCESS_LIST 8
+#define CA_CLEAR 9
+#define CA_NOJOIN 10 /* Maximum */
+#define CA_ACCESS_CHANGE 11
+#define CA_MEMO 12
+#define CA_ASSIGN 13 /* BotServ ASSIGN command */
+#define CA_BADWORDS 14 /* BotServ BADWORDS command */
+#define CA_NOKICK 15 /* Not kicked by the bot */
+#define CA_FANTASIA 16
+#define CA_SAY 17
+#define CA_GREET 18
+#define CA_VOICEME 19
+#define CA_VOICE 20
+#define CA_GETKEY 21
+#define CA_AUTOHALFOP 22
+#define CA_AUTOPROTECT 23
+#define CA_OPDEOPME 24
+#define CA_HALFOPME 25
+#define CA_HALFOP 26
+#define CA_PROTECTME 27
+#define CA_PROTECT 28
+#define CA_KICKME 29
+#define CA_KICK 30
+#define CA_SIGNKICK 31
+/* #define CA_AUTOADMIN 32
+#define CA_ADMINME 33
+#define CA_ADMIN 34 */
+ /* Why are these commented out and not removed? -GD */
+#define CA_BANME 32
+#define CA_BAN 33
+#define CA_TOPIC 34
+#define CA_INFO 35
+
+#define CA_SIZE 36
+
+/* BotServ SET flags */
+#define BS_DONTKICKOPS 0x00000001
+#define BS_DONTKICKVOICES 0x00000002
+#define BS_FANTASY 0x00000004
+#define BS_SYMBIOSIS 0x00000008
+#define BS_GREET 0x00000010
+#define BS_NOBOT 0x00000020
+
+/* BotServ Kickers flags */
+#define BS_KICK_BOLDS 0x80000000
+#define BS_KICK_COLORS 0x40000000
+#define BS_KICK_REVERSES 0x20000000
+#define BS_KICK_UNDERLINES 0x10000000
+#define BS_KICK_BADWORDS 0x08000000
+#define BS_KICK_CAPS 0x04000000
+#define BS_KICK_FLOOD 0x02000000
+#define BS_KICK_REPEAT 0x01000000
+
+/* Indices for TTB (Times To Ban) */
+#define TTB_BOLDS 0
+#define TTB_COLORS 1
+#define TTB_REVERSES 2
+#define TTB_UNDERLINES 3
+#define TTB_BADWORDS 4
+#define TTB_CAPS 5
+#define TTB_FLOOD 6
+#define TTB_REPEAT 7
+#define TTB_SIZE 8
+
+/*************************************************************************/
+
+/* ChanServ mode utilities commands */
+
+struct csmodeutil_ {
+ char *name; /* Name of the ChanServ command */
+ char *bsname; /* Name of the BotServ fantasy command */
+ char *mode; /* Mode (ie. +o) */
+ int32 notice; /* Notice flag (for the damn OPNOTICE) */
+ int level; /* Level required to use the command */
+ int levelself; /* Level required to use the command for himself */
+};
+
+typedef struct {
+ int what;
+ char *name;
+ int desc;
+} LevelInfo;
+
+
+/*************************************************************************/
+
+/* Server data */
+
+typedef enum {
+ SSYNC_UNKNOWN = 0, /* We can't get the sync state */
+ SSYNC_IN_PROGRESS = 1, /* Sync is currently in progress */
+ SSYNC_DONE = 2 /* We're in sync */
+} SyncState;
+
+struct server_ {
+ Server *next, *prev;
+
+ char *name; /* Server name */
+ uint16 hops; /* Hops between services and server */
+ char *desc; /* Server description */
+ uint16 flags; /* Some info flags, as defined below */
+ char *suid; /* Server Univeral ID */
+ SyncState sync; /* Server sync state (see above) */
+
+ Server *links; /* Linked list head for linked servers */
+ Server *uplink; /* Server which pretends to be the uplink */
+};
+
+#define SERVER_ISME 0x0001
+#define SERVER_JUPED 0x0002
+
+/*************************************************************************/
+
+/* Online user and channel data. */
+struct user_ {
+ User *next, *prev;
+
+ char nick[NICKMAX];
+
+ char *username; /* ident */
+ char *host; /* User's real hostname */
+ char *hostip; /* User's IP number */
+ char *vhost; /* User's virtual hostname */
+ char *vident; /* User's virtual ident */
+ char *realname; /* Realname */
+ Server *server; /* Server user is connected to */
+ char *nickTrack; /* Nick Tracking */
+ time_t timestamp; /* Timestamp of the nick */
+ time_t my_signon; /* When did _we_ see the user? */
+ uint32 svid; /* Services ID */
+ uint32 mode; /* See below */
+ char *uid; /* Univeral ID */
+
+ NickAlias *na;
+
+ ModuleData *moduleData; /* defined for it, it should allow the module Add/Get */
+
+ int isSuperAdmin; /* is SuperAdmin on or off? */
+
+ struct u_chanlist {
+ struct u_chanlist *next, *prev;
+ Channel *chan;
+ int16 status; /* Associated flags; see CSTATUS_* below. */
+ } *chans; /* Channels user has joined */
+
+ struct u_chaninfolist {
+ struct u_chaninfolist *next, *prev;
+ ChannelInfo *chan;
+ } *founder_chans; /* Channels user has identified for */
+
+ short invalid_pw_count; /* # of invalid password attempts */
+ time_t invalid_pw_time; /* Time of last invalid password */
+
+ time_t lastmemosend; /* Last time MS SEND command used */
+ time_t lastnickreg; /* Last time NS REGISTER cmd used */
+ time_t lastmail; /* Last time this user sent a mail */
+};
+
+
+
+struct cbmode_ {
+ uint32 flag; /* Long value that represents the mode */
+ uint16 flags; /* Flags applying to this mode (CBM_* below) */
+
+ /* Function to associate a value with the mode */
+ void (*setvalue) (Channel *chan, char *value);
+ void (*cssetvalue) (ChannelInfo *ci, char *value);
+};
+
+#define CBM_MINUS_NO_ARG 0x0001 /* No argument for unset */
+#define CBM_NO_MLOCK 0x0002 /* Can't be MLOCKed */
+#define CBM_NO_USER_MLOCK 0x0004 /* Can't be MLOCKed by non-opers */
+
+struct cbmodeinfo_ {
+ char mode; /* The mode */
+ uint32 flag; /* Long value that represents the mode */
+ uint16 flags; /* CBM_* above */
+
+ /* Function to retrieve the value associated to the mode (optional) */
+ char * (*getvalue) (Channel *chan);
+ char * (*csgetvalue) (ChannelInfo *ci);
+};
+
+struct cmmode_ {
+ void (*addmask) (Channel *chan, char *mask);
+ void (*delmask) (Channel *chan, char *mask);
+};
+
+struct cumode_ {
+ int16 status; /* CUS_* below */
+ int16 flags; /* CUF_* below */
+
+ int (*is_valid) (User *user, Channel *chan, int servermode);
+};
+
+/* Channel user mode flags */
+
+#define CUF_PROTECT_BOTSERV 0x0001
+
+/* This structure stocks ban data since it must not be removed when
+ * user is kicked.
+ */
+
+struct bandata_ {
+ BanData *next, *prev;
+
+ char *mask; /* Since a nick is unsure and a User structure
+ is unsafe */
+ time_t last_use; /* Since time is the only way to check
+ whether it's still useful */
+ int16 ttb[TTB_SIZE];
+};
+
+/* This structure stocks information on every user that will be used by
+ * BotServ. */
+
+struct userdata_ {
+ /* Data validity */
+ time_t last_use;
+
+ /* for flood kicker */
+ int16 lines;
+ time_t last_start;
+
+ /* for repeat kicker */
+ char *lastline;
+ int16 times;
+};
+
+/* Channelban type flags */
+#define ENTRYTYPE_NONE 0x00000000
+#define ENTRYTYPE_CIDR4 0x00000001
+#define ENTRYTYPE_NICK_WILD 0x00000004
+#define ENTRYTYPE_NICK 0x00000008
+#define ENTRYTYPE_USER_WILD 0x00000010
+#define ENTRYTYPE_USER 0x00000020
+#define ENTRYTYPE_HOST_WILD 0x00000040
+#define ENTRYTYPE_HOST 0x00000080
+
+struct channel_ {
+ Channel *next, *prev;
+ char name[CHANMAX];
+ ChannelInfo *ci; /* Corresponding ChannelInfo */
+ time_t creation_time; /* When channel was created */
+ char *topic;
+ char topic_setter[NICKMAX]; /* Who set the topic */
+ time_t topic_time; /* When topic was set */
+ uint32 mode; /* Binary modes only */
+ uint32 limit; /* 0 if none */
+ char *key; /* NULL if none */
+ char *redirect; /* +L; NULL if none */
+ char *flood; /* +f; NULL if none */
+ EList *bans;
+ EList *excepts;
+ EList *invites;
+ struct c_userlist {
+ struct c_userlist *next, *prev;
+ User *user;
+ UserData *ud;
+ } *users;
+ int16 usercount;
+
+ BanData *bd;
+
+ time_t server_modetime; /* Time of last server MODE */
+ time_t chanserv_modetime; /* Time of last check_modes() */
+ int16 server_modecount; /* Number of server MODEs this second */
+ int16 chanserv_modecount; /* Number of check_mode()'s this sec */
+ int16 bouncy_modes; /* Did we fail to set modes here? */
+ int16 topic_sync; /* Is the topic in sync? */
+};
+
+struct c_elist {
+ Entry *entries;
+ int32 count;
+};
+
+struct c_elist_entry {
+ Entry *next, *prev;
+ uint32 type;
+ uint32 cidr_ip; /* IP mask for CIDR matching */
+ uint32 cidr_mask; /* Netmask for CIDR matching */
+ char *nick, *user, *host, *mask;
+};
+
+/*************************************************************************/
+
+/* Constants for news types. */
+
+#define NEWS_LOGON 0
+#define NEWS_OPER 1
+#define NEWS_RANDOM 2
+
+/*************************************************************************/
+
+/* Ignorance list data. */
+
+typedef struct ignore_data {
+ struct ignore_data *prev, *next;
+ char *mask;
+ time_t time; /* When do we stop ignoring them? */
+} IgnoreData;
+
+/*************************************************************************/
+
+/* Mail data */
+
+struct mailinfo_ {
+ FILE *pipe;
+ User *sender;
+ NickCore *recipient;
+ NickRequest *recip;
+};
+
+/*************************************************************************/
+
+struct akill_ {
+ char *user; /* User part of the AKILL */
+ char *host; /* Host part of the AKILL */
+
+ char *by; /* Who set the akill */
+ char *reason; /* Why they got akilled */
+
+ time_t seton; /* When it was set */
+ time_t expires; /* When it expires */
+};
+
+/*************************************************************************/
+
+/* Structure for OperServ SGLINE and SZLINE commands */
+
+struct sxline_ {
+ char *mask;
+ char *by;
+ char *reason;
+ time_t seton;
+ time_t expires;
+};
+
+
+/************************************************************************/
+
+/* Host serv structures */
+
+struct hostcore_ {
+ HostCore *next;
+ char *nick; /* Owner of the vHost */
+ char *vIdent; /* vIdent for the user */
+ char *vHost; /* Vhost for this user */
+ char *creator; /* Oper Nick of the oper who set the vhost */
+ time_t time; /* Date/Time vHost was set */
+};
+
+/*************************************************************************/
+
+struct newsitem_ {
+ uint16 type;
+ uint32 num; /* Numbering is separate for login and oper news */
+ char *text;
+ char who[NICKMAX];
+ time_t time;
+};
+
+/*************************************************************************/
+
+
+struct exception_ {
+ char *mask; /* Hosts to which this exception applies */
+ int limit; /* Session limit for exception */
+ char who[NICKMAX]; /* Nick of person who added the exception */
+ char *reason; /* Reason for exception's addition */
+ time_t time; /* When this exception was added */
+ time_t expires; /* Time when it expires. 0 == no expiry */
+ int num; /* Position in exception list; used to track
+ * positions when deleting entries. It is
+ * symbolic and used internally. It is
+ * calculated at load time and never saved. */
+};
+
+/*************************************************************************/
+
+struct session_ {
+ Session *prev, *next;
+ char *host;
+ int count; /* Number of clients with this host */
+ int hits; /* Number of subsequent kills for a host */
+};
+
+/*************************************************************************/
+/**
+ * IRCD Protocol module support struct.
+ * protocol modules register the command they want touse for function X with our set
+ * functions, we then call the correct function for the anope_ commands.
+ **/
+typedef struct ircd_proto_ {
+ void (*ircd_set_mod_current_buffer)(int ac, char **av);
+ void (*ircd_cmd_svsnoop)(char *server, int set);
+ void (*ircd_cmd_remove_akill)(char *user, char *host);
+ void (*ircd_cmd_topic)(char *whosets, char *chan, char *whosetit, char *topic, time_t when);
+ void (*ircd_cmd_vhost_off)(User * u);
+ void (*ircd_cmd_akill)(char *user, char *host, char *who, time_t when,time_t expires, char *reason);
+ void (*ircd_cmd_svskill)(char *source, char *user, char *buf);
+ void (*ircd_cmd_svsmode)(User * u, int ac, char **av);
+ void (*ircd_cmd_372)(char *source, char *msg);
+ void (*ircd_cmd_372_error)(char *source);
+ void (*ircd_cmd_375)(char *source);
+ void (*ircd_cmd_376)(char *source);
+ void (*ircd_cmd_nick)(char *nick, char *name, char *modes);
+ void (*ircd_cmd_guest_nick)(char *nick, char *user, char *host, char *real, char *modes);
+ void (*ircd_cmd_mode)(char *source, char *dest, char *buf);
+ void (*ircd_cmd_bot_nick)(char *nick, char *user, char *host, char *real, char *modes);
+ void (*ircd_cmd_kick)(char *source, char *chan, char *user, char *buf);
+ void (*ircd_cmd_notice_ops)(char *source, char *dest, char *buf);
+ void (*ircd_cmd_notice)(char *source, char *dest, char *buf);
+ void (*ircd_cmd_notice2)(char *source, char *dest, char *msg);
+ void (*ircd_cmd_privmsg)(char *source, char *dest, char *buf);
+ void (*ircd_cmd_privmsg2)(char *source, char *dest, char *msg);
+ void (*ircd_cmd_serv_notice)(char *source, char *dest, char *msg);
+ void (*ircd_cmd_serv_privmsg)(char *source, char *dest, char *msg);
+ void (*ircd_cmd_bot_chan_mode)(char *nick, char *chan);
+ void (*ircd_cmd_351)(char *source);
+ void (*ircd_cmd_quit)(char *source, char *buf);
+ void (*ircd_cmd_pong)(char *servname, char *who);
+ void (*ircd_cmd_join)(char *user, char *channel, time_t chantime);
+ void (*ircd_cmd_unsqline)(char *user);
+ void (*ircd_cmd_invite)(char *source, char *chan, char *nick);
+ void (*ircd_cmd_part)(char *nick, char *chan, char *buf);
+ void (*ircd_cmd_391)(char *source, char *timestr);
+ void (*ircd_cmd_250)(char *buf);
+ void (*ircd_cmd_307)(char *buf);
+ void (*ircd_cmd_311)(char *buf);
+ void (*ircd_cmd_312)(char *buf);
+ void (*ircd_cmd_317)(char *buf);
+ void (*ircd_cmd_219)(char *source, char *letter);
+ void (*ircd_cmd_401)(char *source, char *who);
+ void (*ircd_cmd_318)(char *source, char *who);
+ void (*ircd_cmd_242)(char *buf);
+ void (*ircd_cmd_243)(char *buf);
+ void (*ircd_cmd_211)(char *buf);
+ void (*ircd_cmd_global)(char *source, char *buf);
+ void (*ircd_cmd_global_legacy)(char *source, char *fmt);
+ void (*ircd_cmd_sqline)(char *mask, char *reason);
+ void (*ircd_cmd_squit)(char *servname, char *message);
+ void (*ircd_cmd_svso)(char *source, char *nick, char *flag);
+ void (*ircd_cmd_chg_nick)(char *oldnick, char *newnick);
+ void (*ircd_cmd_svsnick)(char *source, char *guest, time_t when);
+ void (*ircd_cmd_vhost_on)(char *nick, char *vIdent, char *vhost);
+ void (*ircd_cmd_connect)(int servernum);
+ void (*ircd_cmd_svshold)(char *nick);
+ void (*ircd_cmd_release_svshold)(char *nick);
+ void (*ircd_cmd_unsgline)(char *mask);
+ void (*ircd_cmd_unszline)(char *mask);
+ void (*ircd_cmd_szline)(char *mask, char *reason, char *whom);
+ void (*ircd_cmd_sgline)(char *mask, char *reason);
+ void (*ircd_cmd_unban)(char *name, char *nick);
+ void (*ircd_cmd_svsmode_chan)(char *name, char *mode, char *nick);
+ void (*ircd_cmd_svid_umode)(char *nick, time_t ts);
+ void (*ircd_cmd_nc_change)(User * u);
+ void (*ircd_cmd_svid_umode2)(User * u, char *ts);
+ void (*ircd_cmd_svid_umode3)(User * u, char *ts);
+ void (*ircd_cmd_ctcp)(char *source, char *dest, char *buf);
+ void (*ircd_cmd_svsjoin)(char *source, char *nick, char *chan, char *param);
+ void (*ircd_cmd_svspart)(char *source, char *nick, char *chan);
+ void (*ircd_cmd_swhois)(char *source, char *who, char *mask);
+ void (*ircd_cmd_eob)();
+ void (*ircd_cmd_jupe)(char *jserver, char *who, char *reason);
+ void (*ircd_set_umode)(User *user, int ac, char **av);
+ int (*ircd_valid_nick)(char *nick);
+ int (*ircd_valid_chan)(char *chan);
+ int (*ircd_flood_mode_check)(char *value);
+} IRCDProto;
+
+typedef struct ircd_modes_ {
+ int user_invis;
+ int user_oper;
+ int chan_invite;
+ int chan_secret;
+ int chan_private;
+ int chan_key;
+ int chan_limit;
+} IRCDModes;
+
+
+
+/*************************************************************************/
+/**
+ * DEFCON Defines
+ **/
+#define DEFCON_NO_NEW_CHANNELS 1 /* No New Channel Registrations */
+#define DEFCON_NO_NEW_NICKS 2 /* No New Nick Registrations */
+#define DEFCON_NO_MLOCK_CHANGE 4 /* No MLOCK changes */
+#define DEFCON_FORCE_CHAN_MODES 8 /* Force Chan Mode */
+#define DEFCON_REDUCE_SESSION 16 /* Reduce Session Limit */
+#define DEFCON_NO_NEW_CLIENTS 32 /* Kill any NEW clients */
+#define DEFCON_OPER_ONLY 64 /* Restrict services to oper's only */
+#define DEFCON_SILENT_OPER_ONLY 128 /* Silently ignore non-opers */
+#define DEFCON_AKILL_NEW_CLIENTS 256 /* AKILL any new clients */
+#define DEFCON_NO_NEW_MEMOS 512 /* No New Memos Sent */
+
+/*************************************************************************/
+
+/* Memo Flags */
+#define MF_UNREAD 0x0001 /* Memo has not yet been read */
+#define MF_RECEIPT 0x0002 /* Sender requested receipt */
+#define MF_NOTIFYS 0x0004 /* Memo is a notification of receitp */
+
+/* Nickname status flags: */
+#define NS_VERBOTEN 0x0002 /* Nick may not be registered or used */
+#define NS_NO_EXPIRE 0x0004 /* Nick never expires */
+#define NS_IDENTIFIED 0x8000 /* User has IDENTIFY'd */
+#define NS_RECOGNIZED 0x4000 /* ON_ACCESS true && SECURE flag not set */
+#define NS_ON_ACCESS 0x2000 /* User comes from a known address */
+#define NS_KILL_HELD 0x1000 /* Nick is being held after a kill */
+#define NS_GUESTED 0x0100 /* SVSNICK has been sent but nick has not
+ * yet changed. An enforcer will be
+ * introduced when it does change. */
+#define NS_MASTER 0x0200 /* Was a master nick; used to import old databases */
+#define NS_TRANSGROUP 0xC000 /* Status flags that can be passed to a nick of the
+ same group during nick change */
+#define NS_TEMPORARY 0xFF00 /* All temporary status flags */
+/* These two are not used anymore */
+#define NS_OLD_ENCRYPTEDPW 0x0001 /* Nickname password is encrypted */
+
+/* Nickname setting flags: */
+#define NI_KILLPROTECT 0x00000001 /* Kill others who take this nick */
+#define NI_SECURE 0x00000002 /* Don't recognize unless IDENTIFY'd */
+#define NI_MSG 0x00000004 /* Use PRIVMSGs instead of NOTICEs */
+#define NI_MEMO_HARDMAX 0x00000008 /* Don't allow user to change memo limit */
+#define NI_MEMO_SIGNON 0x00000010 /* Notify of memos at signon and un-away */
+#define NI_MEMO_RECEIVE 0x00000020 /* Notify of new memos when sent */
+#define NI_PRIVATE 0x00000040 /* Don't show in LIST to non-servadmins */
+#define NI_HIDE_EMAIL 0x00000080 /* Don't show E-mail in INFO */
+#define NI_HIDE_MASK 0x00000100 /* Don't show last seen address in INFO */
+#define NI_HIDE_QUIT 0x00000200 /* Don't show last quit message in INFO */
+#define NI_KILL_QUICK 0x00000400 /* Kill in 20 seconds instead of 60 */
+#define NI_KILL_IMMED 0x00000800 /* Kill immediately instead of in 60 sec */
+#define NI_SERVICES_OPER 0x00001000 /* User is a Services operator */
+#define NI_SERVICES_ADMIN 0x00002000 /* User is a Services admin */
+#define NI_ENCRYPTEDPW 0x00004000 /* Nickname password is encrypted */
+#define NI_SERVICES_ROOT 0x00008000 /* User is a Services root */
+#define NI_MEMO_MAIL 0x00010000 /* User gets email on memo */
+#define NI_HIDE_STATUS 0x00020000 /* Don't show services access status */
+#define NI_SUSPENDED 0x00040000 /* Nickname is suspended */
+#define NI_AUTOOP 0x00080000 /* Autoop nickname in channels */
+/* Languages. Never insert anything in the middle of this list, or
+ * everybody will start getting the wrong language! If you want to change
+ * the order the languages are displayed in for NickServ HELP SET LANGUAGE,
+ * do it in language.c.
+ */
+#define LANG_EN_US 0 /* United States English */
+#define LANG_JA_JIS 1 /* Japanese (JIS encoding) */
+#define LANG_JA_EUC 2 /* Japanese (EUC encoding) */
+#define LANG_JA_SJIS 3 /* Japanese (SJIS encoding) */
+#define LANG_ES 4 /* Spanish */
+#define LANG_PT 5 /* Portugese */
+#define LANG_FR 6 /* French */
+#define LANG_TR 7 /* Turkish */
+#define LANG_IT 8 /* Italian */
+#define LANG_DE 9 /* German */
+#define LANG_CAT 10 /* Catalan */
+#define LANG_GR 11 /* Greek */
+#define LANG_NL 12 /* Dutch */
+#define LANG_RU 13 /* Russian */
+#define LANG_HUN 14 /* Hungarian */
+#define LANG_PL 15 /* Polish */
+
+#define NUM_LANGS 16 /* Number of languages */
+#define USED_LANGS 13 /* Number of languages provided */
+
+
+#define DEF_LANGUAGE LANG_EN_US
+
+#define BI_PRIVATE 0x0001
+
+#define CUS_OP 0x0001
+#define CUS_VOICE 0x0002
+#define CUS_HALFOP 0x0004 /* Halfop (+h) */
+#define CUS_OWNER 0x0008 /* Owner/Founder (+q) */
+#define CUS_PROTECT 0x0010 /* Protected users (+a) */
+#define CUS_DEOPPED 0x0080 /* User has been specifically deopped */
+
+#define MUT_DEOP 0
+#define MUT_OP 1
+#define MUT_DEVOICE 2
+#define MUT_VOICE 3
+#define MUT_DEHALFOP 4
+#define MUT_HALFOP 5
+#define MUT_DEPROTECT 6
+#define MUT_PROTECT 7
+
+/*************************************************************************/
+/* CAPAB stuffs */
+
+typedef struct capabinfo_ CapabInfo;
+struct capabinfo_ {
+ char *token;
+ uint32 flag;
+};
+
+#define CAPAB_NOQUIT 0x00000001
+#define CAPAB_TSMODE 0x00000002
+#define CAPAB_UNCONNECT 0x00000004
+#define CAPAB_NICKIP 0x00000008
+#define CAPAB_NSJOIN 0x00000010
+#define CAPAB_ZIP 0x00000020
+#define CAPAB_BURST 0x00000040
+#define CAPAB_TS3 0x00000080
+#define CAPAB_TS5 0x00000100
+#define CAPAB_DKEY 0x00000200
+#define CAPAB_DOZIP 0x00000400
+#define CAPAB_DODKEY 0x00000800
+#define CAPAB_QS 0x00001000
+#define CAPAB_SCS 0x00002000
+#define CAPAB_PT4 0x00004000
+#define CAPAB_UID 0x00008000
+#define CAPAB_KNOCK 0x00010000
+#define CAPAB_CLIENT 0x00020000
+#define CAPAB_IPV6 0x00040000
+#define CAPAB_SSJ5 0x00080000
+#define CAPAB_SN2 0x00100000
+#define CAPAB_VHOST 0x00200000
+#define CAPAB_TOKEN 0x00400000
+#define CAPAB_SSJ3 0x00800000
+#define CAPAB_NICK2 0x01000000
+#define CAPAB_UMODE2 0x02000000
+#define CAPAB_VL 0x04000000
+#define CAPAB_TLKEXT 0x08000000
+#define CAPAB_CHANMODE 0x10000000
+#define CAPAB_SJB64 0x20000000
+#define CAPAB_NICKCHARS 0x40000000
+
+/*************************************************************************/
+
+/**
+ * RFC: defination of a valid nick
+ * nickname = ( letter / special ) *8( letter / digit / special / "-" )
+ * letter = %x41-5A / %x61-7A ; A-Z / a-z
+ * digit = %x30-39 ; 0-9
+ * special = %x5B-60 / %x7B-7D ; "[", "]", "\", "`", "_", "^", "{", "|", "}"
+ **/
+#define isvalidnick(c) ( isalnum(c) || ((c) >='\x5B' && (c) <='\x60') || ((c) >='\x7B' && (c) <='\x7D') || (c)=='-' )
+
+/*************************************************************************/
+
+#include "extern.h"
+
+/*************************************************************************/
+
+#endif /* SERVICES_H */
diff --git a/include/slist.h b/include/slist.h
new file mode 100644
index 000000000..64ecbe996
--- /dev/null
+++ b/include/slist.h
@@ -0,0 +1,50 @@
+/* Header for Services list handler.
+ *
+ * (C) 2003-2008 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.
+ *
+ * $Id$
+ *
+ */
+
+#ifndef SLIST_H
+#define SLIST_H
+
+typedef struct slist_ SList;
+typedef struct slistopts_ SListOpts;
+
+struct slist_ {
+ void **list;
+
+ int16 count; /* Total entries of the list */
+ int16 capacity; /* Capacity of the list */
+ int16 limit; /* Maximum possible entries on the list */
+
+ SListOpts *opts;
+};
+
+struct slistopts_ {
+ int32 flags; /* Flags for the list. See below. */
+
+ int (*compareitem) (SList *slist, void *item1, void *item2); /* Called to compare two items */
+ int (*isequal) (SList *slist, void *item1, void *item2); /* Called by slist_indexof. item1 can be an arbitrary pointer. */
+ void (*freeitem) (SList *slist, void *item); /* Called when an item is removed */
+};
+
+#define SLIST_DEFAULT_LIMIT 32767
+
+#define SLISTF_NODUP 0x00000001 /* No duplicates in the list. */
+#define SLISTF_SORT 0x00000002 /* Automatically sort the list. Used with compareitem member. */
+
+/* Note that number is the index in the array + 1 */
+typedef int (*slist_enumcb_t) (SList *slist, int number, void *item, va_list args);
+/* Callback to know whether we can delete the entry. */
+typedef int (*slist_delcheckcb_t) (SList *slist, void *item, va_list args);
+
+#endif /* SLIST_H */
+
diff --git a/include/sockets.h b/include/sockets.h
new file mode 100644
index 000000000..470ad7761
--- /dev/null
+++ b/include/sockets.h
@@ -0,0 +1,47 @@
+/*
+ *
+ * (C) 2004-2008 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.in b/include/sysconf.h.in
new file mode 100644
index 000000000..59f900433
--- /dev/null
+++ b/include/sysconf.h.in
@@ -0,0 +1,227 @@
+/* include/sysconf.h.in. Generated from configure.in by autoheader. */
+
+/* "Default umask Permissions" */
+#undef DEFUMASK
+
+/* "No prefix needed for dlopen" */
+#undef DL_PREFIX
+
+/* "Has sys/types.h" */
+#undef HAS_SYS_TYPES_H
+
+/* "" */
+#undef HAVE_BACKTRACE
+
+/* Define to 1 if you have the `fork' function. */
+#undef HAVE_FORK
+
+/* Define to 1 if you have the `gethostbyname' function. */
+#undef HAVE_GETHOSTBYNAME
+
+/* Define to 1 if you have the `gethostbyname_r' function. */
+#undef HAVE_GETHOSTBYNAME_R
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#undef HAVE_GETTIMEOFDAY
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `setgrent' function. */
+#undef HAVE_SETGRENT
+
+/* Define to 1 if you have the `snprintf' function. */
+#undef HAVE_SNPRINTF
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the `strcasecmp' function. */
+#undef HAVE_STRCASECMP
+
+/* Define to 1 if you have the `strdup' function. */
+#undef HAVE_STRDUP
+
+/* Define to 1 if you have the `strerror' function. */
+#undef HAVE_STRERROR
+
+/* Define to 1 if you have the `stricmp' function. */
+#undef HAVE_STRICMP
+
+/* "" */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the `strlcat' function. */
+#undef HAVE_STRLCAT
+
+/* Define to 1 if you have the `strlcpy' function. */
+#undef HAVE_STRLCPY
+
+/* Define to 1 if you have the `strsignal' function. */
+#undef HAVE_STRSIGNAL
+
+/* Define to 1 if you have the `strspn' function. */
+#undef HAVE_STRSPN
+
+/* Define to 1 if you have the `sys_errlist' function. */
+#undef HAVE_SYS_ERRLIST
+
+/* "" */
+#undef HAVE_SYS_SELECT_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the `umask' function. */
+#undef HAVE_UMASK
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* va_list as array */
+#undef HAVE_VA_LIST_AS_ARRAY
+
+/* "Module dir" */
+#undef MODULE_PATH
+
+/* "Has mysql/mysql.h" */
+#undef MYSQL_HEADER_PREFIX
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* "Run group" */
+#undef RUNGROUP
+
+/* "Binary Dir" */
+#undef SERVICES_BIN
+
+/* "services bin dir" */
+#undef SERVICES_DIR
+
+/* The size of a `int', as computed by sizeof. */
+#undef SIZEOF_INT
+
+/* The size of a `long', as computed by sizeof. */
+#undef SIZEOF_LONG
+
+/* The size of a `short', as computed by sizeof. */
+#undef SIZEOF_SHORT
+
+/* "modules not available" */
+#undef STATIC_LINKING
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* "Modules available" */
+#undef USE_MODULES
+
+/* "Use Mysql" */
+#undef USE_MYSQL
+
+/* "Use RDB" */
+#undef USE_RDB
+
+/* Define to `short' if <sys/types.h> does not define. */
+#undef int16_t
+
+/* Define to `long' if <sys/types.h> does not define. */
+#undef int32_t
+
+/* Define to `unsigned short' if <sys/types.h> does not define. */
+#undef u_int16_t
+
+/* Define to `unsigned long' if <sys/types.h> does not define. */
+#undef u_int32_t
+
+/* Static config, copy from here to below before running autoheader! */
+
+#ifndef BIG_ENDIAN
+
+/* Big Endian system */
+#undef BIG_ENDIAN
+
+#endif
+
+#ifndef LITTLE_ENDIAN
+
+/* Little Endian system */
+#undef LITTLE_ENDIAN
+
+#endif
+
+/**
+ * NOTE: BIG_ENDIAN and LITTLE_ENDIAN defines should not be left in
+ * by autoheader as they may be defined or may not be, as such we check
+ * if there defined before messing with them!
+ **/
+
+#ifdef HAS_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#ifdef __STRICT_ANSI__
+#include <stdarg.h>
+#include <stdio.h>
+
+/* We KNOW these are not ansi, we are defining them here to suppress the warning
+ * * s messages on a "make strict" compile */
+#ifndef snprintf
+int snprintf(char *str, size_t size, const char *format, ...);
+#endif
+#ifndef vprintf
+int vprintf(const char *format, va_list ap);
+#endif
+#ifndef vfprintf
+int vfprintf(FILE *stream, const char *format, va_list ap);
+#endif
+#ifndef vsprintf
+int vsprintf(char *str, const char *format, va_list ap);
+#endif
+#ifndef vsnprintf
+int vsnprintf(char *str, size_t size, const char *format, va_list ap);
+#endif
+
+FILE *popen(const char *command, const char *type);
+int pclose(FILE *stream);
+FILE *fdopen(int fildes, const char *mode);
+
+int ftruncate(int fd, off_t length);
+
+#ifdef HAVE_STRSIGNAL
+char *strsignal(int sig);
+#endif
+
+#endif
+
+
+typedef int16_t int16;
+typedef u_int16_t uint16;
+typedef int32_t int32;
+typedef u_int32_t uint32;
+
diff --git a/include/sysconf.h.win32 b/include/sysconf.h.win32
new file mode 100644
index 000000000..a11694469
--- /dev/null
+++ b/include/sysconf.h.win32
@@ -0,0 +1,50 @@
+
+#define SERVICES_DIR "data"
+#define SERVICES_BIN "anope.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 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/timeout.h b/include/timeout.h
new file mode 100644
index 000000000..ac2f3deda
--- /dev/null
+++ b/include/timeout.h
@@ -0,0 +1,50 @@
+/* Time-delay routine include stuff.
+ *
+ * (C) 2003-2008 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.
+ *
+ * $Id$
+ *
+ */
+
+#ifndef TIMEOUT_H
+#define TIMEOUT_H
+
+#include <time.h>
+
+
+/* Definitions for timeouts: */
+typedef struct timeout_ Timeout;
+struct timeout_ {
+ Timeout *next, *prev;
+ time_t settime, timeout;
+ int repeat; /* Does this timeout repeat indefinitely? */
+ void (*code)(Timeout *); /* This structure is passed to the code */
+ void *data; /* Can be anything */
+};
+
+
+/* Check the timeout list for any pending actions. */
+extern void check_timeouts(void);
+
+/* Add a timeout to the list to be triggered in `delay' seconds. Any
+ * timeout added from within a timeout routine will not be checked during
+ * that run through the timeout list.
+ */
+extern Timeout *add_timeout(int delay, void (*code)(Timeout *), int repeat);
+
+/* Remove a timeout from the list (if it's there). */
+extern void del_timeout(Timeout *t);
+
+#ifdef DEBUG_COMMANDS
+/* Send the list of timeouts to the given user. */
+extern int send_timeout_list(User *u);
+#endif
+
+
+#endif /* TIMEOUT_H */
diff --git a/include/version.sh b/include/version.sh
new file mode 100644
index 000000000..1ee2d756c
--- /dev/null
+++ b/include/version.sh
@@ -0,0 +1,86 @@
+#!/bin/sh
+#
+# Build version string and increment Services build number.
+#
+
+# Grab version information from the version control file.
+CTRL="../version.log"
+if [ -f $CTRL ] ; then
+ . $CTRL
+else
+ echo "Error: Unable to find control file: $CTRL"
+ exit 0
+fi
+
+VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_EXTRA} (${VERSION_BUILD})"
+VERSIONDOTTED="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_EXTRA}.${VERSION_BUILD}"
+
+if [ -f version.h ] ; then
+ BUILD=`fgrep '#define BUILD' version.h | sed 's/^#define BUILD.*\([0-9]*\).*$/\1/'`
+ BUILD=`expr $BUILD + 1 2>/dev/null`
+else
+ BUILD=1
+fi
+if [ ! "$BUILD" ] ; then
+ BUILD=1
+fi
+cat >version.h <<EOF
+/* Version information for Services.
+ *
+ * (C) 2003-2008 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and CREDITS for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * This file is auto-generated by version.sh
+ *
+ */
+
+ #ifndef VERSION_H
+ #define VERSION_H
+
+#define VERSION_MAJOR $VERSION_MAJOR
+#define VERSION_MINOR $VERSION_MINOR
+#define VERSION_PATCH $VERSION_PATCH
+#define VERSION_EXTRA "$VERSION_EXTRA"
+#define VERSION_BUILD $VERSION_BUILD
+
+#define BUILD "$BUILD"
+#define VERSION_STRING "$VERSION"
+#define VERSION_STRING_DOTTED "$VERSIONDOTTED"
+
+#ifdef DEBUG_COMMANDS
+# define VER_DEBUG "D"
+#else
+# define VER_DEBUG
+#endif
+
+#if defined(_WIN32)
+# if _MSC_VER >= 1400
+# define VER_OS "W"
+# else
+# define VER_OS "w"
+# endif
+#else
+# define VER_OS
+#endif
+
+#if defined(USE_MYSQL)
+# define VER_MYSQL "Q"
+#else
+# define VER_MYSQL
+#endif
+
+#if defined(USE_MODULES)
+# define VER_MODULE "M"
+#else
+# define VER_MODULE
+#endif
+
+#endif
+
+EOF
+
diff --git a/include/version.sh.c b/include/version.sh.c
new file mode 100644
index 000000000..f69fe8992
--- /dev/null
+++ b/include/version.sh.c
@@ -0,0 +1,224 @@
+/* version file handler for win32.
+ *
+ * (C) 2003-2008 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 = NULL;
+char version[1024];
+char version_dotted[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 (%d)", version_major, version_minor,
+ version_patch, (version_extra ? version_extra : ""), version_build);
+
+ _snprintf(version_dotted, 1024, "%d.%d.%d%s.%d", version_major, version_minor,
+ version_patch, (version_extra ? version_extra : ""), version_build);
+
+ 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);
+
+ if (version_extra)
+ free(version_extra);
+}
+
+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 strdup(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);
+ else if (!strcmp(varbegin, "VERSIONDOTTED"))
+ fprintf(fd, "%s", version_dotted);
+ fputc(tmp, fd);
+ }
+ c = var;
+ } else
+ fputc(*c, fd);
+ }
+ /* We only need \n here - we didn't open the file as binary -GD */
+ fprintf(fd, "\n");
+}