diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/commands.h | 34 | ||||
-rw-r--r-- | include/config.h | 81 | ||||
-rw-r--r-- | include/datafiles.h | 67 | ||||
-rw-r--r-- | include/defs.h | 40 | ||||
-rw-r--r-- | include/encrypt.h | 16 | ||||
-rw-r--r-- | include/extern.h | 925 | ||||
-rw-r--r-- | include/messages.h | 23 | ||||
-rw-r--r-- | include/modules.h | 233 | ||||
-rw-r--r-- | include/pseudo.h | 20 | ||||
-rw-r--r-- | include/services.h | 1521 | ||||
-rw-r--r-- | include/slist.h | 63 | ||||
-rw-r--r-- | include/sysconf.h.in | 209 | ||||
-rw-r--r-- | include/timeout.h | 50 | ||||
-rw-r--r-- | include/version.sh | 146 |
14 files changed, 3428 insertions, 0 deletions
diff --git a/include/commands.h b/include/commands.h new file mode 100644 index 000000000..00a866219 --- /dev/null +++ b/include/commands.h @@ -0,0 +1,34 @@ +/* Declarations for command data. + * + * (C) 2003 Anope Team + * Contact us at info@anope.org + * + * Please read COPYING and README for furhter details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + * $Id$ + * + */ + + #include "modules.h" + +/*************************************************************************/ + +/* Routines for looking up commands. Command lists are arrays that must be + * terminated with a NULL name. + */ + +extern Command *lookup_cmd(Command *list, const char *name); +extern void run_cmd(const char *service, User *u, Command *list, + const char *name); +extern void help_cmd(const char *service, User *u, Command *list, + const char *name); +extern void do_run_cmd(const char *service, User * u, Command *c,const char *cmd); +extern void do_help_cmd(const char *service, User * u, Command *c,const char *cmd); +extern void mod_help_cmd(const char *service, User *u, CommandHash *cmdTable[],const char *cmd); +extern void mod_run_cmd(const char *service, User *u, CommandHash *cmdTable[],const char *cmd); + +extern char *mod_current_module_name; +/*************************************************************************/ diff --git a/include/config.h b/include/config.h new file mode 100644 index 000000000..c260b72af --- /dev/null +++ b/include/config.h @@ -0,0 +1,81 @@ +/* Services configuration. + * + * (C) 2003 Anope Team + * Contact us at info@anope.org + * + * Please read COPYING and README for furhter details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + * $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 *******/ + +/* How big a hostname list do we keep for clone detection? On large nets + * (over 500 simultaneous users or so), you may want to increase this if + * you want a good chance of catching clones. */ +#define CLONE_DETECT_SIZE 16 + +/* 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..4312b5af1 --- /dev/null +++ b/include/datafiles.h @@ -0,0 +1,67 @@ +/* Database file descriptor structure and file handling routine prototypes. + * + * (C) 2003 Anope Team + * Contact us at info@anope.org + * + * Please read COPYING and README for furhter details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + * $Id$ + * + */ + +#ifndef DATAFILES_H +#define DATAFILES_H + +/*************************************************************************/ + +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[PATH_MAX]; /* Name of the database file */ + char backupname[PATH_MAX]; /* 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..c2993d270 --- /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 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/encrypt.h b/include/encrypt.h new file mode 100644 index 000000000..e31e44ea7 --- /dev/null +++ b/include/encrypt.h @@ -0,0 +1,16 @@ +/* Include file for high-level encryption routines. + * + * (C) 2003 Anope Team + * Contact us at info@anope.org + * + * Please read COPYING and README for furhter details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + * $Id$ + * + */ + +extern int encrypt(const char *src, int len, char *dest, int size); +extern int check_password(const char *plaintext, const char *password); diff --git a/include/extern.h b/include/extern.h new file mode 100644 index 000000000..fe02b446b --- /dev/null +++ b/include/extern.h @@ -0,0 +1,925 @@ +/* Prototypes and external variable declarations. + * + * (C) 2003 Anope Team + * Contact us at info@anope.org + * + * Please read COPYING and README for furhter details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + * $Id$ + * + */ + +#ifndef EXTERN_H +#define EXTERN_H + +#include "slist.h" + +#define E extern + + +/**** modules.c ****/ +E void moduleCallBackRun(void); +E void moduleCleanStruct(ModuleData * moduleData[]); + +/**** actions.c ****/ + +E void change_user_mode(User * u, char *modes, char *arg); +E void kill_user(const char *source, const char *user, const char *reason); +E void bad_password(User * u); + +/**** botserv.c ****/ + +E BotInfo *botlists[256]; + +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); + +/**** channels.c ****/ + +E Channel *chanlist[1024]; +E CBMode cbmodes[128]; +E CBModeInfo cbmodeinfos[]; + +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 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); +#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 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 void check_modes(Channel * c); +#if defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) +E int check_valid_admin(User * user, Channel * chan, int servermode); +#endif +E int check_valid_op(User * user, Channel * chan, int servermode); +E int check_should_op(User * user, const char *chan); +E int check_should_voice(User * user, const char *chan); +#ifdef HAS_HALFOP +E int check_should_halfop(User * user, const char *chan); +#endif +#if defined(IRC_UNREAL) || defined(IRC_VIAGRA) +E int check_should_owner(User * user, const char *chan); +E int check_should_protect(User * user, const char *chan); +#endif +#if defined(IRC_ULTIMATE3) || defined(IRC_RAGE2) || defined(IRC_PTLINK) +E int check_should_protect(User * user, const char *chan); +#endif +E int check_kick(User * user, char *chan); +E void record_topic(const char *chan); +E void restore_topic(const 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); + +#ifdef HAS_FMODE +E char *cs_get_flood(ChannelInfo * ci); +E void cs_set_flood(ChannelInfo * ci, char *value); +#endif +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); +#ifdef HAS_LMODE +E char *cs_get_redirect(ChannelInfo * ci); +E void cs_set_redirect(ChannelInfo * ci, char *value); +#endif + +/**** 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 + + +/**** 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 **NetworkDomains; +E int DomainNumber; +E char *NetworkName; + +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_IrcIIHelp; +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_IrcIIHelp; +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 DumpCore; +E int LogUsers; +E int NickRegDelay; +E int UseSVSHOLD; + +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 ProxyDetect; +E int ProxyThreads; +E char *ProxyMessage[8]; +E int ProxyCheckWingate; +E int ProxyCheckSocks4; +E int ProxyCheckSocks5; +E int ProxyCheckHTTP1; +E int ProxyCheckHTTP2; +E int ProxyCheckHTTP3; +E int ProxyTimeout; +E char *ProxyTestServer; +E int ProxyTestPort; +E int ProxyExpire; +E int ProxyCacheExpire; +E char *ProxyAkillReason; +E int WallProxy; +E int ProxyMax; + +E int NSDefFlags; +E int NSDefLanguage; +E int NSRegDelay; +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 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 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 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 CheckClones; +E int CloneMinUsers; +E int CloneMaxDelay; +E int CloneWarningDelay; +E int KillClones; +E int AddAkiller; + +E char **ModulesAutoload; +E int ModulesNumber; +E char **ModulesDelayedAutoload; +E int ModulesDelayedNumber; + + +E int KillClonesAkillExpire; + +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; + +#ifdef USE_RDB +E int rdb_init(); +E int rdb_open(); +E int rdb_close(); +E int rdb_tag_table(char *table); +E int rdb_tag_table(char *table); +E int rdb_clear_table(char *table); +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_cs_set_founder(char *channel, char *founder); +E int rdb_cs_deluser(char *nick); +E int rdb_cs_delchan(ChannelInfo * ci); +E void rdb_save_ns_core(NickCore * nc); +E void rdb_save_ns_alias(NickAlias * na); +E void rdb_save_ns_req(NickRequest * nr); +E void rdb_save_cs_info(ChannelInfo * ci); +E void rdb_save_bs_core(BotInfo * bi); +E void rdb_save_bs_rdb_core(BotInfo * bi); +E void rdb_save_hs_core(HostCore * hc); +E void rdb_save_os_db(unsigned int maxucnt, unsigned int maxutime, + SList * ak, SList * sgl, SList * sql, SList * szl, + HostCache * hc); +E void rdb_save_news(NewsItem * ni); +E void rdb_save_exceptions(Exception * e); +E void rdb_load_bs_dbase(void); +E void rdb_load_hs_dbase(void); +E void rdb_load_ns_dbase(void); +E void 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; + +/**** converter.c ****/ + +E int convert_ircservices_44(void); + +/**** init.c ****/ + +E void introduce_user(const char *user); +E int init(int ac, char **av); +E int servernum; + +/**** 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(const 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_build[]; +E const 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 noexpire; + +#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); + +/**** 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); + + +/**** misc.c ****/ + +E char *strscpy(char *d, const char *s, size_t len); +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); + +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(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 void doCleanBuffer(char *str); +E void EnforceQlinedNick(char *nick, char *killer); +E int nickIsServices(char *nick); + + +/**** 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 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 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); +E 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); + +/**** helpserv.c ****/ +E void helpserv(User * u, char *buf); +E void helpserv_init(void); + +/**** hostserv.c ****/ +E void hostserv_init(void); +E void addHostCore(char *nick, char *vIdent, char *vhost, char *creator, int32 tmp_time); + +/**** operserv.c ****/ + +E SList akills, sglines, sqlines, szlines; +E SList servadmins; +E SList servopers; + +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(const 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, ...); +#ifdef IRC_BAHAMUT +E int add_sgline(User *u, char *mask, const char *by, const time_t expires, const char *reason); +E int check_sgline(const char *nick, const char *realname); +E void expire_sglines(void); +#endif + +E int add_sqline(User *u, char *mask, const char *by, const time_t expires, const char *reason); +E int check_sqline(const char *nick, int nick_change); +#ifdef IRC_BAHAMUT +E int check_chan_sqline(const char *chan); +#endif +E void expire_sqlines(void); + +#ifdef IRC_BAHAMUT +E int add_szline(User * u, char *mask, const char *by, + const time_t expires, const char *reason); +E void expire_szlines(void); +#endif + +E void check_clones(User * user); + +E void delete_ignore(const char *nick); + +/**** 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 split_buf(char *buf, char ***argv, int colon_special); +E void process(void); + +/**** protocol.c ****/ + +E void s_akill(char *user, char *host, char *who, time_t when, + time_t expires, char *reason); +E void s_rakill(char *user, char *host); +E void s_sgline(char *mask, char *reason); +E void s_sqline(char *mask, char *reason); +E void s_svsnoop(char *server, int set); +E void s_szline(char *mask, char *reason); +E void s_unsgline(char *mask); +E void s_unsqline(char *mask); +E void s_unszline(char *mask); + +/**** proxy.c ****/ + +E HostCache *hcache[1024]; + +E HostCache *proxy_cache_add(char *host); +E void get_proxy_stats(long *nrec, long *memuse); +E void ntoa(struct in_addr addr, char *ipaddr, int len); +E int proxy_check(char *nick, char *host, uint32 ip); +E void proxy_expire(); +E int proxy_init(void); + +E int do_cache(User *u); + +/**** 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 wallops(const char *source, const char *fmt, ...) + FORMAT(printf,2,3); + +E void notice(const char *source, const char *dest, const char *fmt, ...) + FORMAT(printf,3,4); +E void notice_server(const char *source, Server *s, const char *fmt, ...) + FORMAT(printf,3,4); +E void notice_user(const char *source, User *u, const char *fmt, ...) + FORMAT(printf,3,4); + +E void notice_list(const char *source, const char *dest, const char **text); +E void notice_lang(const char *source, User *dest, int message, ...); +E void notice_help(const char *source, User *dest, int message, ...); + +E void privmsg(const char *source, const char *dest, const char *fmt, ...) + FORMAT(printf,3,4); + +E void send_mode(const char *source, const char *on, const char *fmt, ...) + FORMAT(printf,3,4); + +/**** servers.c ****/ + +E Server *servlist; +E Server *me_server; +#ifdef IRC_BAHAMUT +E uint16 uplink_capab; +#endif + +E Server *first_server(int flags); +E Server *next_server(int flags); + +E Server *new_server(Server *uplink, const char *name, const char *desc, + uint16 flags); + +E Server *findserver(Server *s, const char *name); + +E void do_server(const char *source, int ac, char **av); +E void do_squit(const char *source, int ac, char **av); + +/**** sessions.c ****/ + +E Exception *exceptions; +E int16 nexceptions; + +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(const char *nick, const char *host); +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); + +/**** sockutil.c ****/ + +E int32 total_read, total_written; +E int32 read_buffer_len(void); +E int32 write_buffer_len(void); + +E int sgetc(int s); +E char *sgets(char *buf, int len, int s); +E char *sgets2(char *buf, int len, int s); +E int sread(int s, char *buf, int len); +E int sputs(char *str, int s); +E int sockprintf(int s, char *fmt, ...); +E int conn(const char *host, int port, const char *lhost, int lport); +E void disconn(int s); + +/**** users.c ****/ + +E User *userlist[1024]; + +E int32 usercnt, opcnt, maxusercnt; +E time_t maxusertime; + +E void set_umode(User * user, int ac, char **av); + +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); + +#if defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined(IRC_ULTIMATE3) || defined(IRC_VIAGRA) || defined(IRC_PTLINK) || defined(IRC_RAGE2) +E void change_user_host(User * user, const char *host); +#endif +#if defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined(IRC_ULTIMATE3) || defined(IRC_VIAGRA) || defined(IRC_PTLINK) +E void change_user_username(User * user, const char *username); +E void change_user_realname(User * user, const char *realname); +#endif + +E User *do_nick(const char *source, char *nick, char *username, char *host, + char *server, char *realname, time_t ts, uint32 svid, ...); +E void do_umode(const char *source, int ac, char **av); +E void do_quit(const char *source, int ac, char **av); +E void do_kill(const char *source, int ac, char **av); + +E int is_oper(User * user); +E int is_protected(User * user); + +#ifdef HAS_EXCEPT +E int is_excepted(ChannelInfo * ci, User * user); +E int is_excepted_mask(ChannelInfo * ci, char *mask); +#endif + +E int match_usermask(const char *mask, User * user); +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 void db_mysql_save_ns_core(NickCore * nc); +E void db_mysql_save_ns_alias(NickAlias * na); +E void db_mysql_save_ns_req(NickRequest * nr); +E void db_mysql_save_cs_info(ChannelInfo * ci); +E void db_mysql_save_os_db(unsigned int maxucnt, unsigned int maxutime, + SList * ak, SList * sgl, SList * sql, + SList * szl, HostCache * hc); +E void db_mysql_save_news(NewsItem * ni); +E void db_mysql_save_exceptions(Exception * e); +E void db_mysql_save_hs_core(HostCore * hc); +E void db_mysql_save_bs_core(BotInfo * bi); +E void db_mysql_load_bs_dbase(void); +E void db_mysql_load_hs_dbase(void); +E void db_mysql_load_ns_dbase(void); +E void db_mysql_load_ns_req_dbase(void); +E void db_mysql_load_cs_dbase(void); +E void db_mysql_load_os_dbase(void); +E void db_mysql_load_exceptions(void); +E void db_mysql_load_news(void); +#endif + +#ifdef USE_ENCRYPTION +extern int encrypt_in_place(char *buf, int size); +#endif + + +#endif /* EXTERN_H */ diff --git a/include/messages.h b/include/messages.h new file mode 100644 index 000000000..f1de39648 --- /dev/null +++ b/include/messages.h @@ -0,0 +1,23 @@ +/* Declarations of IRC message structures, variables, and functions. + * + * (C) 2003 Anope Team + * Contact us at info@anope.org + * + * Please read COPYING and README for furhter details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + * $Id$ + * + */ + +/*************************************************************************/ +#include "modules.h" + +extern Message messages[]; +extern void moduleAddMsgs(void); +extern Message *find_message(const char *name); + + +/*************************************************************************/ diff --git a/include/modules.h b/include/modules.h new file mode 100644 index 000000000..dd92029a4 --- /dev/null +++ b/include/modules.h @@ -0,0 +1,233 @@ +/* Modular support + * + * (C) 2003 Anope Team + * Contact us at info@anope.org + * + * Please read COPYING and README for furhter details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + * $Id$ + */ + +#ifndef MODULES_H +#define MODULES_H + +#include <time.h> +#include "services.h" +#include <stdio.h> + +/*************************************************************************/ +#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 + +/********************************************************************** + * 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 + + /*************************************************************************/ + +/* Structure for information about a *Serv command. */ + +typedef struct Command_ Command; +typedef struct CommandHash_ CommandHash; +typedef struct Module_ Module; +typedef struct ModuleHash_ ModuleHash; +typedef struct Message_ Message; +typedef struct MessageHash_ MessageHash; +typedef struct ModuleCallBack_ ModuleCallBack; + + +extern CommandHash *HOSTSERV[MAX_CMD_HASH]; +extern CommandHash *BOTSERV[MAX_CMD_HASH]; +extern CommandHash *MEMOSERV[MAX_CMD_HASH]; +extern CommandHash *NICKSERV[MAX_CMD_HASH]; +extern CommandHash *CHANSERV[MAX_CMD_HASH]; +extern CommandHash *HELPSERV[MAX_CMD_HASH]; +extern CommandHash *OPERSERV[MAX_CMD_HASH]; +extern MessageHash *IRCD[MAX_CMD_HASH]; + +struct Module_ { + char *name; + char *filename; + void *handle; + time_t time; + char *version; + char *author; + + 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]; +}; + +struct ModuleHash_ { + char *name; + Module *m; + ModuleHash *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; +}; + +/*************************************************************************/ +/* Module Managment Functions */ +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 */ +Module *findModule(char *name); /* Find a module */ +int loadModule(Module *m,User *u); /* Load the given module into the program */ +int unloadModule(Module *m, User *u); /* Unload the given module from the pro */ +int prepForUnload(Module *m); /* Prepare the module for unload */ +void moduleAddVersion(char *version); +void moduleAddAuthor(char *author); +void modules_init(void); +void modules_delayed_init(void); +void moduleCallBackPrepForUnload(char *mod_name); +void moduleCallBackDeleteEntry(ModuleCallBack * prev); +char *moduleGetLastBuffer(void); +void moduleSetHelpHelp(void (*func) (User * u)); +void moduleDisplayHelp(int service, User *u); +void moduleSetHostHelp(void (*func) (User * u)); +void moduleSetOperHelp(void (*func) (User * u)); +void moduleSetBotHelp(void (*func) (User * u)); +void moduleSetMemoHelp(void (*func) (User * u)); +void moduleSetChanHelp(void (*func) (User * u)); +void moduleSetNickHelp(void (*func) (User * u)); +int moduleAddHelp(Command * c, int (*func) (User * u)); +int moduleAddRegHelp(Command * c, int (*func) (User * u)); +int moduleAddOperHelp(Command * c, int (*func) (User * u)); +int moduleAddAdminHelp(Command * c, int (*func) (User * u)); +int moduleAddRootHelp(Command * c, int (*func) (User * u)); +/*************************************************************************/ +/*************************************************************************/ +/* Command Managment Functions */ +Command *createCommand(const char *name,int (*func)(User *u),int (*has_priv)(User *u),int help_all, int help_reg, int help_oper, int help_admin,int help_root); +int destroyCommand(Command *c); /* destroy a command */ +int addCoreCommand(CommandHash *cmdTable[], Command *c); /* Add a command to a command table */ +int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos); +int addCommand(CommandHash *cmdTable[], Command *c,int pos); +int delCommand(CommandHash *cmdTable[], Command *c,char *mod_name); /* Del a command from a cmd table */ +int moduleDelCommand(CommandHash *cmdTable[],char *name); /* Del a command from a cmd table */ +Command *findCommand(CommandHash *cmdTable[], const char *name); /* Find a command */ +/*************************************************************************/ +/*************************************************************************/ +/* Message Managment Functions */ +Message *createMessage(char *name,int (*func)(char *source, int ac, char **av)); +Message *findMessage(MessageHash *msgTable[], const char *name); /* Find a Message */ +int addMessage(MessageHash *msgTable[], Message *m, int pos); /* Add a Message to a Message table */ +int addCoreMessage(MessageHash *msgTable[], Message *m); /* Add a Message to a Message table */ +int moduleAddMessage(Message *m, int pos); +int delMessage(MessageHash *msgTable[], Message *m, char *mod_name); /* Del a Message from a msg table */ +int moduleDelMessage(char *name); +int destroyMessage(Message *m); /* destroy a Message*/ +Message *findMessage(MessageHash *msgTable[], const char *name); +/*************************************************************************/ +int moduleAddCallback(char *name,time_t when,int (*func)(int argc, char *argv[]),int argc, char **argv); +void moduleDelCallback(char *name); +void moduleCallBackRun(void); + +char *moduleGetData(ModuleData *md[], char *key); /* Get the value for this key from this struct */ +int moduleAddData(ModuleData *md[], char *key, char *value); /* Set the value for this key for this struct */ +void moduleDelData(ModuleData *md[], char *key); /* Delete this key/value pair */ +void moduleDelAllData(ModuleData *md[]); /* Delete all key/value pairs for this module for this struct */ +void moduleCleanStruct(ModuleData * moduleData[]); /* Clean a moduleData hash */ +void moduleDelAllDataMod(Module *m); /* remove all module data from all structs for this module */ + +/*************************************************************************/ + +#endif +/* EOF */ diff --git a/include/pseudo.h b/include/pseudo.h new file mode 100644 index 000000000..f543d8a6c --- /dev/null +++ b/include/pseudo.h @@ -0,0 +1,20 @@ +/* Include extra includes needed by most/all pseudo-clients. + * + * (C) 2003 Anope Team + * Contact us at info@anope.org + * + * Please read COPYING and README for furhter details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + * $Id$ + * + */ + +#include "commands.h" +#include "language.h" +#include "timeout.h" +#include "encrypt.h" +#include "datafiles.h" +#include "slist.h" diff --git a/include/services.h b/include/services.h new file mode 100644 index 000000000..42dc83dfa --- /dev/null +++ b/include/services.h @@ -0,0 +1,1521 @@ +/* + * + * (C) 2003 Anope Team + * Contact us at info@anope.org + * + * Please read COPYING and README for furhter details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + * + */ + +#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(). */ +#define _GNU_SOURCE + +/* Some AIX boxes define int16 and int32 on their own. Blarph. */ +#if INTTYPE_WORKAROUND +# define int16 builtin_int16 +# define int32 builtin_int32 +#endif + +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <signal.h> +#include <time.h> +#include <errno.h> +#include <grp.h> +#include <limits.h> +#include <netdb.h> +#include <netinet/in.h> +#include <sys/socket.h> +#include <sys/stat.h> /* for umask() on some systems */ +#include <sys/types.h> +#include <sys/time.h> + +#ifdef USE_RDB +# define MAX_SQL_BUF 4096 +#endif + +#ifdef USE_MYSQL +# define MYSQL_WARNING 2 +# define MYSQL_ERROR 4 + +#ifdef HAVE_MYSQL_MYSQL_H +#ifdef MYSQL_HEADER_PREFIX + #include <mysql/mysql.h> + #include <mysql/errmsg.h> +#else + #include <mysql.h> + #include <errmsg.h> +#endif +#endif + + +#endif + +#if HAVE_STRINGS_H +# include <strings.h> +#endif + +#if HAVE_SYS_SELECT_H +# include <sys/select.h> +#endif + +#ifdef USE_THREADS +# include <pthread.h> +#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_ +extern int toupper(char), tolower(char); + +/* We also have our own encrypt(). */ +#define encrypt encrypt_ + + +#if INTTYPE_WORKAROUND +# undef int16 +# undef int32 +#endif + + +/* Miscellaneous definitions. */ +#include "defs.h" +#include "slist.h" + +/*************************************************************************/ + +typedef struct server_ Server; +typedef struct user_ User; +typedef struct channel_ Channel; + +/*************************************************************************/ +/*************************************************************************/ + +/* Protocol tweaks */ + + + +#ifdef IRC_HYBRID +# define HAS_HALFOP +# define HAS_EXCEPT /* Has +e (chan excepts) */ +# define NICKSERV_MODE "+o" +# define CHANSERV_MODE "+o" +# define MEMOSERV_MODE "+o" +# define BOTSERV_MODE "+o" +# define HELPSERV_MODE "+h" +# define OPERSERV_MODE "+io" +# define DEVNULL_MODE "+i" +# define GLOBAL_MODE "+io" +# define NICKSERV_ALIAS_MODE "+o" +# define CHANSERV_ALIAS_MODE "+o" +# define MEMOSERV_ALIAS_MODE "+o" +# define BOTSERV_ALIAS_MODE "+o" +# define HELPSERV_ALIAS_MODE "+h" +# define OPERSERV_ALIAS_MODE "+io" +# define DEVNULL_ALIAS_MODE "+i" +# define GLOBAL_ALIAS_MODE "+io" +# define BOTSERV_BOTS_MODE "+" +#endif + +#ifdef IRC_VIAGRA +# define HAS_HALFOP +# define HAS_VHOST +# define HAS_VIDENT +# define HAS_EXCEPT +# define NICKSERV_MODE "+oS" +# define CHANSERV_MODE "+oS" +# define HOSTSERV_MODE "+oS" +# define MEMOSERV_MODE "+oS" +# define BOTSERV_MODE "+oS" +# define HELPSERV_MODE "+oS" +# define OPERSERV_MODE "+ioS" +# define DEVNULL_MODE "+i" +# define GLOBAL_MODE "+ioS" +# define NICKSERV_ALIAS_MODE "+oS" +# define CHANSERV_ALIAS_MODE "+oS" +# define MEMOSERV_ALIAS_MODE "+oS" +# define BOTSERV_ALIAS_MODE "+oS" +# define HELPSERV_ALIAS_MODE "+oS" +# define OPERSERV_ALIAS_MODE "+ioS" +# define DEVNULL_ALIAS_MODE "+iS" +# define GLOBAL_ALIAS_MODE "+ioS" +# define HOSTSERV_ALIAS_MODE "+ioS" +# define BOTSERV_BOTS_MODE "+qS" +#endif + +#if defined(IRC_BAHAMUT) && !defined(IRC_ULTIMATE3) && !defined(IRC_VIAGRA) && !defined(IRC_RAGE2) +# define HAS_NICKIP +# define HAS_EXCEPT +# define HAS_SVSHOLD +# define NICKSERV_MODE "+o" +# define CHANSERV_MODE "+o" +# define MEMOSERV_MODE "+o" +# define BOTSERV_MODE "+o" +# define HELPSERV_MODE "+h" +# define OPERSERV_MODE "+io" +# define DEVNULL_MODE "+i" +# define GLOBAL_MODE "+io" +# define NICKSERV_ALIAS_MODE "+o" +# define CHANSERV_ALIAS_MODE "+o" +# define MEMOSERV_ALIAS_MODE "+o" +# define BOTSERV_ALIAS_MODE "+o" +# define HELPSERV_ALIAS_MODE "+h" +# define OPERSERV_ALIAS_MODE "+io" +# define DEVNULL_ALIAS_MODE "+i" +# define GLOBAL_ALIAS_MODE "+io" +# define BOTSERV_BOTS_MODE "+" +#endif + +#ifdef IRC_RAGE2 +# define HAS_HALFOP +# define HAS_EXCEPT +# define HAS_VHOST +# define HAS_NICKVHOST +# define NICKSERV_MODE "+dS" +# define CHANSERV_MODE "+dS" +# define HOSTSERV_MODE "+dS" +# define MEMOSERV_MODE "+dS" +# define BOTSERV_MODE "+dS" +# define HELPSERV_MODE "+dSh" +# define OPERSERV_MODE "+diS" +# define DEVNULL_MODE "+diS" +# define GLOBAL_MODE "+diS" +# define NICKSERV_ALIAS_MODE "+o" +# define CHANSERV_ALIAS_MODE "+o" +# define MEMOSERV_ALIAS_MODE "+o" +# define BOTSERV_ALIAS_MODE "+o" +# define HELPSERV_ALIAS_MODE "+h" +# define OPERSERV_ALIAS_MODE "+io" +# define DEVNULL_ALIAS_MODE "+i" +# define GLOBAL_ALIAS_MODE "+io" +# define HOSTSERV_ALIAS_MODE "+io" +# define BOTSERV_BOTS_MODE "+S" +#endif + +#ifdef IRC_PTLINK +# define HAS_NICKVHOST +# define HAS_VHOST +# define HAS_FMODE +# define HAS_EXCEPT +# define NICKSERV_MODE "+o" +# define CHANSERV_MODE "+o" +# define HOSTSERV_MODE "+o" +# define MEMOSERV_MODE "+o" +# define BOTSERV_MODE "+o" +# define HELPSERV_MODE "+h" +# define OPERSERV_MODE "+io" +# define DEVNULL_MODE "+i" +# define GLOBAL_MODE "+io" +# define NICKSERV_ALIAS_MODE "+o" +# define CHANSERV_ALIAS_MODE "+o" +# define MEMOSERV_ALIAS_MODE "+o" +# define BOTSERV_ALIAS_MODE "+o" +# define HELPSERV_ALIAS_MODE "+h" +# define OPERSERV_ALIAS_MODE "+io" +# define DEVNULL_ALIAS_MODE "+i" +# define GLOBAL_ALIAS_MODE "+io" +# define HOSTSERV_ALIAS_MODE "+io" +# define BOTSERV_BOTS_MODE "+" +#endif + +#ifdef IRC_ULTIMATE +# define HAS_FMODE /* Has +f chan mode */ +# define HAS_HALFOP +# define HAS_LMODE /* Has +L chan mode */ +# define HAS_VHOST +# define HAS_VIDENT /* Can the IRCD Change Idents on the fly */ +# define HAS_EXCEPT +# define NICKSERV_MODE "+S" +# define CHANSERV_MODE "+S" +# define HOSTSERV_MODE "+oS" +# define MEMOSERV_MODE "+S" +# define BOTSERV_MODE "+S" +# define HELPSERV_MODE "+Sh" +# define OPERSERV_MODE "+iS" +# define DEVNULL_MODE "+iS" +# define GLOBAL_MODE "+iS" +# define NICKSERV_ALIAS_MODE "+oS" +# define CHANSERV_ALIAS_MODE "+oS" +# define MEMOSERV_ALIAS_MODE "+oS" +# define BOTSERV_ALIAS_MODE "+oS" +# define HELPSERV_ALIAS_MODE "+oS" +# define OPERSERV_ALIAS_MODE "+ioS" +# define DEVNULL_ALIAS_MODE "+iS" +# define GLOBAL_ALIAS_MODE "+ioS" +# define HOSTSERV_ALIAS_MODE "+ioS" +# define BOTSERV_BOTS_MODE "+pS" +#endif + +#ifdef IRC_UNREAL +# define HAS_FMODE /* Has +f chan mode */ +# define HAS_HALFOP +# define HAS_LMODE /* Has +L chan mode */ +# define HAS_NICKVHOST +# define HAS_VHOST +# define HAS_VIDENT /* Can the IRCD Change Idents on the fly */ +# define HAS_EXCEPT +# define NICKSERV_MODE "+oS" +# define CHANSERV_MODE "+oS" +# define HOSTSERV_MODE "+oS" +# define MEMOSERV_MODE "+oS" +# define BOTSERV_MODE "+oS" +# define HELPSERV_MODE "+oS" +# define OPERSERV_MODE "+ioS" +# define DEVNULL_MODE "+iS" +# define GLOBAL_MODE "+ioS" +# define NICKSERV_ALIAS_MODE "+oS" +# define CHANSERV_ALIAS_MODE "+oS" +# define MEMOSERV_ALIAS_MODE "+oS" +# define BOTSERV_ALIAS_MODE "+oS" +# define HELPSERV_ALIAS_MODE "+oS" +# define OPERSERV_ALIAS_MODE "+ioS" +# define DEVNULL_ALIAS_MODE "+iS" +# define GLOBAL_ALIAS_MODE "+ioS" +# define HOSTSERV_ALIAS_MODE "+ioS" +# define BOTSERV_BOTS_MODE "+qS" +#endif + +#ifdef IRC_ULTIMATE3 +# define HAS_HALFOP +# define HAS_VHOST +# define HAS_NICKVHOST +# define HAS_VIDENT /* Can the IRCD Change Idents on the fly */ +# define HAS_EXCEPT +# define NICKSERV_MODE "+S" +# define CHANSERV_MODE "+S" +# define HOSTSERV_MODE "+o" +# define MEMOSERV_MODE "+S" +# define BOTSERV_MODE "+S" +# define HELPSERV_MODE "+Sh" +# define OPERSERV_MODE "+iS" +# define DEVNULL_MODE "+iS" +# define GLOBAL_MODE "+iS" +# define NICKSERV_ALIAS_MODE "+o" +# define CHANSERV_ALIAS_MODE "+o" +# define MEMOSERV_ALIAS_MODE "+o" +# define BOTSERV_ALIAS_MODE "+o" +# define HELPSERV_ALIAS_MODE "+h" +# define OPERSERV_ALIAS_MODE "+io" +# define DEVNULL_ALIAS_MODE "+i" +# define GLOBAL_ALIAS_MODE "+io" +# define HOSTSERV_ALIAS_MODE "+io" +# define BOTSERV_BOTS_MODE "+S" +#endif + +/* + This gets ugly since serval ircds use both DREAMFORCE and their own define +*/ + +#ifdef IRC_DREAMFORGE + #ifndef NICKSERV_MODE + # define NICKSERV_MODE "+o" + #endif + #ifndef CHANSERV_MODE + # define CHANSERV_MODE "+o" + #endif + #ifndef MEMOSERV_MODE + # define MEMOSERV_MODE "+o" + #endif + #ifndef BOTSERV_MODE + # define BOTSERV_MODE "+o" + #endif + #ifndef HELPSERV_MODE + # define HELPSERV_MODE "+h" + #endif + #ifndef OPERSERV_MODE + # define OPERSERV_MODE "+io" + #endif + #ifndef DEVNULL_MODE + # define DEVNULL_MODE "+i" + #endif + #ifndef GLOBAL_MODE + # define GLOBAL_MODE "+io" + #endif + #ifndef BOTSERV_BOTS_MODE + # define BOTSERV_BOTS_MODE "+" + #endif + #ifndef NICKSERV_ALIAS_MODE + # define NICKSERV_ALIAS_MODE "+o" + #endif + #ifndef CHANSERV_ALIAS_MODE + # define CHANSERV_ALIAS_MODE "+o" + #endif + #ifndef MEMOSERV_ALIAS_MODE + # define MEMOSERV_ALIAS_MODE "+o" + #endif + #ifndef BOTSERV_ALIAS_MODE + # define BOTSERV_ALIAS_MODE "+o" + #endif + #ifndef HELPSERV_ALIAS_MODE + # define HELPSERV_ALIAS_MODE "+h" + #endif + #ifndef OPERSERV_ALIAS_MODE + # define OPERSERV_ALIAS_MODE "+io" + #endif + #ifndef DEVNULL_ALIAS_MODE + # define DEVNULL_ALIAS_MODE "+i" + #endif + #ifndef GLOBAL_ALIAS_MODE + # define GLOBAL_ALIAS_MODE "+io" + #endif +#endif + +/*************************************************************************/ + +/* 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 13 +#define PRE_NICK_VERSION 1 +#define OPER_VERSION 13 + +/** + * ModuleData strucs used to allow modules to add / delete module Data from existing structs + */ +typedef struct ModuleData_ ModuleData; /* ModuleData struct */ +typedef struct ModuleDataItem_ ModuleDataItem; /* A Module Data Item struct */ + +struct ModuleDataItem_ { + char *key; /* The key */ + char *value; /* The Value */ + ModuleDataItem *next; /* The next ModuleDataItem in this list */ +}; + +struct ModuleData_ { + char *moduleName; /* Which module we belong to */ + ModuleDataItem *di; /* The first Item they own */ + ModuleData *next; /* The next ModuleData record */ +}; + + + +typedef enum { false, true } boolean; + +/*************************************************************************/ + +/* Memo info structures. Since both nicknames and channels can have memos, + * we encapsulate memo data in a MemoList to make it easier to handle. */ + +typedef struct memo_ Memo; +struct memo_ { + uint32 number; /* Index number -- not necessarily array position! */ + int16 flags; + time_t time; /* When it was sent */ + char sender[NICKMAX]; + char *text; + ModuleData *moduleData[1024]; /* Module saved data attached to the Memo */ +}; + +#define MF_UNREAD 0x0001 /* Memo has not yet been read */ +#define MF_RECEIPT 0x0002 /* Sender requested receipt */ + +typedef struct { + int16 memocount, memomax; + Memo *memos; +} MemoInfo; + +/*************************************************************************/ + +/* NickServ nickname structures. */ +typedef struct nickrequest_ NickRequest; +typedef struct nickalias_ NickAlias; +typedef struct nickcore_ NickCore; + +struct nickrequest_ { + NickRequest *next, *prev; + char *nick; + char *passcode; + char *password; + 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 */ + + int16 status; /* See NS_* below */ + + NickCore *nc; /* I'm an alias of this */ + + /* Not saved */ + ModuleData *moduleData[1024]; /* 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; /* 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 */ + + int32 flags; /* See NI_* below */ + uint16 language; /* Language selected by nickname owner (LANG_*) */ + + int16 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[1024]; /* Module saved data attached to the NickCore */ + time_t lastmail; /* Last time this nick record got a mail */ + SList aliases; /* List of aliases */ +}; + +/* 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 */ + +/* 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 NUM_LANGS 14 /* Number of languages */ +#define USED_LANGS 11 /* Number of languages provided */ + +#define DEF_LANGUAGE LANG_EN_US + +/*************************************************************************/ + +/* Bot info structures. Note that since there won't be many bots, + * they're not in a hash list. + * --lara + */ + +typedef struct botinfo_ BotInfo; + +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 */ +}; + +#define BI_PRIVATE 0x0001 + +/* 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 { + int16 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. + */ +#define ACCESS_FOUNDER 10000 /* Numeric level indicating founder access */ +#define ACCESS_INVALID -10000 /* Used in levels[] for disabled settings */ + +/* Levels for xOP */ + +#define ACCESS_VOP 3 +#ifdef HAS_HALFOP +# define ACCESS_HOP 4 +#endif +#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 */ + + int16 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. */ + +typedef struct badword_ BadWord; + +struct badword_ { + int16 in_use; + + char *word; + int16 type; /* BW_* below */ +}; + +#define BW_ANY 0 +#define BW_SINGLE 1 +#define BW_START 2 +#define BW_END 3 + +typedef struct chaninfo_ ChannelInfo; +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 */ + + int16 accesscount; + ChanAccess *access; /* List of authorized users */ + int16 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 */ +#ifdef HAS_FMODE + char *mlock_flood; /* NULL if no +f */ +#endif +#ifdef HAS_LMODE + char *mlock_redirect; /* NULL if no +L */ +#endif + + 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[1024]; /* 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 */ + + int16 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 */ +#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 */ + +typedef struct csmodeutil_ CSModeUtil; + +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 */ +}; + +#define MUT_DEOP 0 +#define MUT_OP 1 +#define MUT_DEVOICE 2 +#define MUT_VOICE 3 +#ifdef HAS_HALFOP +#define MUT_DEHALFOP 4 +#define MUT_HALFOP 5 +#endif +#ifdef IRC_UNREAL +#define MUT_DEPROTECT 6 +#define MUT_PROTECT 7 +#endif +#ifdef IRC_ULTIMATE3 +#define MUT_DEPROTECT 6 +#define MUT_PROTECT 7 +#endif +#ifdef IRC_RAGE2 +#define MUT_DEPROTECT 6 +#define MUT_PROTECT 7 +#endif +#ifdef IRC_VIAGRA +#define MUT_DEPROTECT 6 +#define MUT_PROTECT 7 +#endif +#ifdef IRC_PTLINK +#define MUT_DEPROTECT 4 +#define MUT_PROTECT 5 +#endif +/*************************************************************************/ + +/* Server CAPAB flags */ +#ifdef IRC_BAHAMUT +# define CAPAB_NOQUIT 0x0001 +# define CAPAB_TSMODE 0x0002 +# define CAPAB_UNCONNECT 0x0004 +#endif + +/* Server data */ + +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 */ + + 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; + char *host; /* User's real hostname */ +#ifdef HAS_VHOST + char *vhost; /* User's virtual hostname */ +#endif +#ifdef HAS_VIDENT + char *vident; /* User's virtual ident */ +#endif + char *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 */ + + NickAlias *na; + + ModuleData *moduleData[1024]; /* 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 */ +}; + +#define UMODE_a 0x00000001 +#define UMODE_h 0x00000002 +#define UMODE_i 0x00000004 +#define UMODE_o 0x00000008 +#define UMODE_r 0x00000010 +#define UMODE_w 0x00000020 +#define UMODE_A 0x00000040 + +#ifdef IRC_ULTIMATE +#define UMODE_p 0x04000000 +#define UMODE_R 0x08000000 +#define UMODE_P 0x20000000 +#endif + +#ifdef IRC_ULTIMATE3 +#define UMODE_p 0x04000000 +#define UMODE_Z 0x08000000 +#define UMODE_P 0x20000000 +#endif + +#ifdef IRC_DREAMFORGE +# define UMODE_g 0x80000000 +#endif + +#ifdef IRC_BAHAMUT +# define UMODE_R 0x80000000 +#endif + +#ifdef IRC_VIAGRA +#define UMODE_p 0x04000000 +#endif + +#if defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined(IRC_ULTIMATE3) || defined(IRC_VIAGRA) || defined(IRC_RAGE2) +# define UMODE_x 0x40000000 +#endif + +/* Returns *current* user hostname */ +#if defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined(IRC_ULTIMATE3) || defined(IRC_VIAGRA) || defined(IRC_RAGE2) +# define GetHost(x) ((x)->mode & UMODE_x ? (x)->vhost : (x)->host) +#elif defined(IRC_PTLINK) +# define GetHost(x) ((x)->mode & UMODE_o ? (x)->vhost ? (x)->vhost : (x)->host : (x)->host) +#else +# define GetHost(x) ((x)->host) +#endif + +/* Returns *current* user ident */ +#if defined(IRC_ULTIMATE) || defined(IRC_UNREAL) || defined(IRC_VIAGRA) +# define GetIdent(x) ((x)->mode & UMODE_x ? (x)->vident ? (x)->vident : (x)->username : (x)->username) +#else +# define GetIdent(x) ((x)->username) +#endif + +/* This will introduce a pseudo client with the given nick, username, hostname, + realname and modes. It will also make a Q line for the nick on demand. + --lara */ +#if defined(IRC_HYBRID) +# define NEWNICK(nick,user,host,real,modes,qline) \ + do { \ + send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s :%s", (nick), time(NULL), (modes), \ + (user), (host), ServerName, (real)); \ + } while (0) +#elif defined(IRC_ULTIMATE3) +# define NEWNICK(nick,user,host,real,modes,qline) \ + do { \ + send_cmd(NULL, "CLIENT %s 1 %ld %s + %s %s * %s 0 0 :%s", (nick), time(NULL), (modes), \ + (user), (host), ServerName, (real)); \ + if ((qline)) send_cmd(NULL, "SQLINE %s :Reserved for services", (nick)); \ + } while (0) +#elif defined(IRC_RAGE2) +# define NEWNICK(nick,user,host,real,modes,qline) \ + do { \ + send_cmd(NULL, "SNICK %s %ld 1 %s %s 0 * %s 0 %s :%s", (nick), time(NULL), (user), \ + (host), ServerName, (modes), (real)); \ + if ((qline)) send_cmd(NULL, "SQLINE %s :Reserved for services", (nick)); \ + } while (0) +#elif defined(IRC_BAHAMUT) && !defined(IRC_ULTIMATE3) && !defined(IRC_RAGE2) +# define NEWNICK(nick,user,host,real,modes,qline) \ + do { \ + send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", (nick), time(NULL), (modes), \ + (user), (host), ServerName, (real)); \ + if ((qline)) send_cmd(NULL, "SQLINE %s :Reserved for services", (nick)); \ + } while (0) +#elif defined(IRC_UNREAL) +# define NEWNICK(nick,user,host,real,modes,qline) \ + do { \ + send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 %s * :%s", (nick), time(NULL), \ + (user), (host), ServerName, (modes), (real)); \ + if ((qline)) send_cmd(NULL, "SQLINE %s :Reserved for services", (nick)); \ + } while (0) +#elif defined(IRC_DREAMFORGE) +# define NEWNICK(nick,user,host,real,modes,qline) \ + do { \ + send_cmd(NULL, "NICK %s 1 %ld %s %s %s 0 :%s", (nick), time(NULL), \ + (user), (host), ServerName, (real)); \ + if (strcmp(modes, "+")) send_cmd((nick), "MODE %s %s", (nick), (modes)); \ + if ((qline)) send_cmd(NULL, "SQLINE %s :Reserved for services", (nick)); \ + } while (0) +#elif defined(IRC_PTLINK) +# define NEWNICK(nick,user,host,real,modes,qline) \ + do { \ + send_cmd(NULL, "NICK %s 1 %lu %s %s %s %s %s :%s", (nick), time(NULL), \ + (modes), (user), (host), (host), ServerName, (real)); \ + if ((qline)) send_cmd(NULL, "SQLINE %s :Reserved for services", (nick)); \ + } while (0) +#endif + +typedef struct cbmode_ CBMode; +typedef struct cbmodeinfo_ CBModeInfo; +typedef struct cmmode_ CMMode; +typedef struct csmode_ CSMode; +typedef struct cumode_ CUMode; + +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); +}; + +/* User flags on channel */ +#define CUS_OP 0x0001 +#define CUS_VOICE 0x0002 + +#ifdef HAS_HALFOP +#define CUS_HALFOP 0x0004 /* Halfop (+h) */ +#endif + +/* Used by Unreal */ +#ifdef IRC_UNREAL +#define CUS_OWNER 0x0008 /* Owner/Founder (+q) */ +#define CUS_PROTECT 0x0010 /* Protected users (+a) */ +#endif + +/* Used by Viagra */ +#ifdef IRC_VIAGRA +#define CUS_OWNER 0x0008 /* Owner/Founder (+q) */ +#define CUS_PROTECT 0x0010 /* Protected users (+a) */ +#endif + +#ifdef IRC_ULTIMATE3 +#define CUS_PROTECT 0x0010 /* Protected users (+a) */ +#endif + +#ifdef IRC_RAGE2 +#define CUS_PROTECT 0x0010 /* Protected users (+a) */ +#endif + +/* Used by PTlink */ +#ifdef IRC_PTLINK +#define CUS_PROTECT 0x0016 /* Protected users (+a) */ +#endif + +/* Channel user mode flags */ + +#define CUF_PROTECT_BOTSERV 0x0001 + +/* Useful value */ + +#if defined(IRC_ULTIMATE) +# define CHAN_MAX_SYMBOLS 3 +#elif defined(IRC_ULTIMATE3) +# define CHAN_MAX_SYMBOLS 5 +#elif defined(IRC_UNREAL) +# define CHAN_MAX_SYMBOLS 5 +#elif defined(IRC_RAGE2) +# define CHAN_MAX_SYMBOLS 3 +#else +# define CHAN_MAX_SYMBOLS 2 +#endif + +/* Binary modes that need to be cleared */ + +#if defined(IRC_RAGE2) +#define MODESTOREMOVE "-iklmnpRstcOASCNM" +#elif defined(IRC_BAHAMUT) +#define MODESTOREMOVE "-ciklmnpstOR" +#elif defined(IRC_ULTIMATE) +#define MODESTOREMOVE "-kiflmnpstxAIKLORS" +#elif defined(IRC_ULTIMATE3) +#define MODESTOREMOVE "-iklmnpstRKAO" +#elif defined(IRC_UNREAL) +#define MODESTOREMOVE "-ckiflmnpstuzACGHKLNOQRSV" +#elif defined(IRC_PTLINK) +#define MODESTOREMOVE "-cdfiklmnpqstRS" +#else +#define MODESTOREMOVE "-iklmnpstR" +#endif + +typedef struct bandata_ BanData; +typedef struct userdata_ UserData; + +/* 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; +}; + +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 */ +#ifdef HAS_LMODE + char *redirect; /* +L; NULL if none */ +#endif +#ifdef HAS_FMODE + char *flood; /* +f; NULL if none */ +#endif + + int32 bancount, bansize; + char **bans; + +#ifdef HAS_EXCEPT + int32 exceptcount, exceptsize; + char **excepts; +#endif + + 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? */ +}; + +#define CMODE_i 0x00000001 +#define CMODE_m 0x00000002 +#define CMODE_n 0x00000004 +#define CMODE_p 0x00000008 +#define CMODE_s 0x00000010 +#define CMODE_t 0x00000020 +#define CMODE_k 0x00000040 /* These two used only by ChanServ */ +#define CMODE_l 0x00000080 + +/* The two modes below are for IRC_DREAMFORGE servers only. */ +#ifndef IRC_HYBRID +#define CMODE_R 0x00000100 /* Only identified users can join */ +#define CMODE_r 0x00000200 /* Set for all registered channels */ +#endif + +/* This mode is for IRC_BAHAMUT servers only. */ +#ifdef IRC_BAHAMUT +#define CMODE_c 0x00000400 /* Colors can't be used */ +#define CMODE_M 0x00000800 /* Non-regged nicks can't send messages */ +#define CMODE_O 0x00008000 /* Only opers can join */ +#endif + +/* This mode is for IRC_HYBRID servers only. */ +#ifdef IRC_HYBRID +#define CMODE_a 0x00000400 +#endif + +/* These modes are for IRC_ULTIMATE servers only. */ +#ifdef IRC_ULTIMATE +#define CMODE_f 0x00000400 +#define CMODE_x 0x00000800 +#define CMODE_A 0x00001000 +#define CMODE_I 0x00002000 +#define CMODE_K 0x00004000 +#define CMODE_L 0x00008000 +#define CMODE_O 0x00010000 +#define CMODE_S 0x00020000 +#endif + +/* These modes are for IRC_UNREAL servers only. */ +#ifdef IRC_UNREAL +#define CMODE_c 0x00000400 +#define CMODE_A 0x00000800 +#define CMODE_H 0x00001000 +#define CMODE_K 0x00002000 +#define CMODE_L 0x00004000 +#define CMODE_O 0x00008000 +#define CMODE_Q 0x00010000 +#define CMODE_S 0x00020000 +#define CMODE_V 0x00040000 +#define CMODE_f 0x00080000 +#define CMODE_G 0x00100000 +#define CMODE_C 0x00200000 +#define CMODE_u 0x00400000 +#define CMODE_z 0x00800000 +#define CMODE_N 0x01000000 +#endif + +/* These modes are for IRC_ULTIMATE3 servers only */ +#ifdef IRC_ULTIMATE3 +#define CMODE_A 0x00000800 +#define CMODE_N 0x00001000 +#define CMODE_S 0x00002000 +#define CMODE_K 0x00004000 +#endif + +/* These modes are for IRC_RAGE2 servers only */ +#ifdef IRC_RAGE2 +#define CMODE_A 0x00000800 +#define CMODE_N 0x00001000 +#define CMODE_S 0x00002000 +#define CMODE_C 0x00004000 +#endif + +/* These modes are for IRC_PTLINK servers only. */ +#ifdef IRC_PTLINK +#define CMODE_A 0x00000400 +#define CMODE_B 0x00000800 +#define CMODE_c 0x00001000 +#define CMODE_d 0x00002000 +#define CMODE_f 0x00004000 +#define CMODE_K 0x00008000 +#define CMODE_O 0x00010000 +#define CMODE_q 0x00020000 +#define CMODE_S 0x00040000 +#define CMODE_N 0x00080000 +#endif + + +/*************************************************************************/ + +/* 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 *next; + char who[NICKMAX]; + time_t time; /* When do we stop ignoring them? */ +} IgnoreData; + +/*************************************************************************/ + +/* Mail data */ + +typedef struct mailinfo_ MailInfo; + +struct mailinfo_ { + FILE *pipe; + User *sender; + NickCore *recipient; + NickRequest *recip; +}; + +/*************************************************************************/ + +typedef struct akill_ Akill; + +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 */ + +typedef struct sxline_ SXLine; + +struct sxline_ { + char *mask; + char *by; + char *reason; + time_t seton; + time_t expires; +}; + +/*************************************************************************/ + +/* Host serv structures */ + +typedef struct hostcore_ HostCore; + +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 */ +}; + +/*************************************************************************/ + +typedef struct newsitem_ NewsItem; + +struct newsitem_ { + int16 type; + int32 num; /* Numbering is separate for login and oper news */ + char *text; + char who[NICKMAX]; + time_t time; +}; + +/*************************************************************************/ + +typedef struct exception_ Exception; +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. */ +}; + +/*************************************************************************/ + +/* Proxy stuff */ + +typedef struct hostcache_ HostCache; + +struct hostcache_ { + HostCache *prev, *next; + + char *host; /* The hostname */ + uint32 ip; /* The IP address */ + + int16 status; /* HC_* below */ + time_t used; /* When was this entry last used? */ +}; + +/* We assume that values < 0 are in-progress values, and values > 0 are + * proxy value. 0 is the normal value. + */ + +#define HC_QUEUED -2 /* Waiting to be scanned */ +#define HC_PROGRESS -1 /* Currently being scanned */ +#define HC_NORMAL 0 /* No proxy found on this host */ +#define HC_WINGATE 1 /* Wingate found */ +#define HC_SOCKS4 2 /* Socks4 found */ +#define HC_SOCKS5 3 /* Socks5 found */ +#define HC_HTTP 4 /* HTTP proxy found */ + +/** + * 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 */ +/*************************************************************************/ + +#include "extern.h" + +/*************************************************************************/ + +#endif /* SERVICES_H */ diff --git a/include/slist.h b/include/slist.h new file mode 100644 index 000000000..904c503f0 --- /dev/null +++ b/include/slist.h @@ -0,0 +1,63 @@ +/* Header for Services list handler. + * + * (C) 2003 Anope Team + * Contact us at info@anope.org + * + * Please read COPYING and README for furhter details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + * $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); + +/* Functions for global use */ +extern int slist_add(SList *slist, void *item); +extern void slist_clear(SList *slist, int free); +extern int slist_delete(SList *slist, int index); +extern int slist_delete_range(SList *slist, char *range, slist_delcheckcb_t cb, ...); +extern int slist_enum(SList *slist, char *range, slist_enumcb_t cb, ...); +extern int slist_full(SList *slist); +extern int slist_indexof(SList *slist, void *item); +extern void slist_init(SList *slist); +extern void slist_pack(SList *slist); +extern int slist_remove(SList *slist, void *item); +extern int slist_setcapacity(SList *slist, int16 capacity); + +#endif /* SLIST_H */ + diff --git a/include/sysconf.h.in b/include/sysconf.h.in new file mode 100644 index 000000000..ff01e38b6 --- /dev/null +++ b/include/sysconf.h.in @@ -0,0 +1,209 @@ +/* include/sysconf.h.in. Generated from ./autoconf/configure.in by autoheader. */ + +/* "Default umask Permissions" */ +#undef DEFUMASK + +/* "Underscore needed for dlopen" */ +#undef DL_PREFIX + +/* "Has sys/types.h" */ +#undef HAS_SYS_TYPES_H + +/* 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 + +/* "We have the mysql Header file" */ +#undef HAVE_MYSQL_MYSQL_H + +/* Define if you have POSIX threads libraries and header files. */ +#undef HAVE_PTHREAD + +/* 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 `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 + +/* "" */ +#undef HAVE_SYS_SYSPROTO_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 + +/* "First IRCD type" */ +#undef IRC_BAHAMUT + +/* "First IRCD type" */ +#undef IRC_DREAMFORGE + +/* "First IRCD type" */ +#undef IRC_HYBRID + +/* "First IRCD type" */ +#undef IRC_PTLINK + +/* "Second IRCD type" */ +#undef IRC_RAGE2 + +/* "Second IRCD type" */ +#undef IRC_ULTIMATE + +/* "Second IRCD type" */ +#undef IRC_ULTIMATE3 + +/* "Second IRCD type" */ +#undef IRC_UNREAL + +/* "Second IRCD type" */ +#undef IRC_VIAGRA + +/* "Module dir" */ +#undef MODULE_PATH + +/* "mysql.h is in a mysql/ folder" */ +#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 + +/* Define to the necessary symbol if this constant uses a non-standard name on + your system. */ +#undef PTHREAD_CREATE_JOINABLE + +/* "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 + +/* "has encryption" */ +#undef USE_ENCRYPTION + +/* "Modules available" */ +#undef USE_MODULES + +/* "Use Mysql" */ +#undef USE_MYSQL + +/* "Use RDB" */ +#undef USE_RDB + +/* "Use threads" */ +#undef USE_THREADS + +/* 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! */ +#ifdef USE_ENCRYPTION +#define ENCRYPT_MD5 +#endif + +#ifdef HAS_SYS_TYPES_H +#include <sys/types.h> +#endif + +typedef int16_t int16; +typedef u_int16_t uint16; +typedef int32_t int32; +typedef u_int32_t uint32; + diff --git a/include/timeout.h b/include/timeout.h new file mode 100644 index 000000000..2ecb0cb9e --- /dev/null +++ b/include/timeout.h @@ -0,0 +1,50 @@ +/* Time-delay routine include stuff. + * + * (C) 2003 Anope Team + * Contact us at info@anope.org + * + * Please read COPYING and README for furhter details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + * + * $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 void 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..0797f2339 --- /dev/null +++ b/include/version.sh @@ -0,0 +1,146 @@ +#!/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})" + +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 Anope Team + * Contact us at info@anope.org + * + * Please read COPYING and CREDITS for furhter 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 + * + */ + +#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" + +const char version_number[] = "$VERSION"; +const char version_build[] = + "build #" BUILD ", compiled " __DATE__ " " __TIME__; + +const char version_protocol[] = +#if defined(IRC_ULTIMATE3) + "UltimateIRCd 3.0.0.a26+" +# define VER_IRCD "UltimateIRCd 3.0.* -" +#elif defined(IRC_VIAGRA) + "ViagraIRCd 1.3.x" +# define VER_IRCD "ViagraIRCd 1.3.* -" +#elif defined(IRC_RAGE2) + "RageIRCd 2.0.x" +# define VER_IRCD "RageIRCd 2.0.* -" +#elif defined(IRC_BAHAMUT) + "Bahamut 1.4.27+" +# define VER_IRCD "BahamutIRCd 1.4.*/1.8.* -" +#elif defined(IRC_ULTIMATE) + "UltimateIRCd 2.8.2+" +# define VER_IRCD "UltimateIRCd 2.8.* -" +#elif defined(IRC_UNREAL) + "UnrealIRCd 3.1.1+" +# define VER_IRCD "UnrealIRCd -" +#elif defined(IRC_DREAMFORGE) + "DreamForge 4.6.7" +# define VER_IRCD "DreamForgeIRCd 4.6.7 -" +#elif defined(IRC_HYBRID) + "Hybrid IRCd 7.0" +# define VER_IRCD "HybridIRCd 7.* -" +#elif defined(IRC_PTLINK) + "PTlink 6.14.5+" +# define VER_IRCD "PTlinkIRCd 6.14.* -" +#else + "unknown" +# define VER_IRCD +#endif + ; + +#ifdef DEBUG_COMMANDS +# define VER_DEBUG "D" +#else +# define VER_DEBUG +#endif + +#if defined(USE_ENCRYPTION) +# if defined(ENCRYPT_MD5) +# define VER_ENCRYPTION "E" +# else +# define VER_ENCRYPTION "E" +# endif +#else +# define VER_ENCRYPTION +#endif + +#ifdef USE_THREADS +# define VER_THREAD "T" +#else +# define VER_THREAD +#endif + +#if defined(LINUX20) +# define VER_OS "l" +#elif defined(LINUX22) +# define VER_OS "L" +#elif defined(JAGUAR) +# define VER_OS "J" +#elif defined(MACOSX) +# define VER_OS "X" +#else +# define VER_OS +#endif + +#if defined(HAVE_GETHOSTBYNAME_R6) +# define VER_GHBNR "6" +#elif defined(HAVE_GETHOSTBYNAME_R5) +# define VER_GHBNR "5" +#elif defined(HAVE_GETHOSTBYNAME_R3) +# define VER_GHBNR "3" +#else +# define VER_GHBNR +#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 + +const char version_flags[] = VER_IRCD VER_DEBUG VER_ENCRYPTION VER_THREAD VER_OS VER_GHBNR VER_MYSQL VER_MODULE; + +EOF + |