minor updates and bugfixes

This commit is contained in:
fishwaldo 2003-07-30 13:58:22 +00:00
parent ca7e8620b0
commit acbc8d4a3d
45 changed files with 7504 additions and 7799 deletions

2
.indent.pro vendored
View file

@ -1 +1 @@
-br -ce -ts8 -kr -i8 -ut -v -cdw -v -br -brs -cdw -ce -l200 -nbc -ut -ts8 -i8

706
Bahamut.c

File diff suppressed because it is too large Load diff

276
Bahamut.h
View file

@ -20,7 +20,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: Bahamut.h,v 1.4 2003/07/23 12:45:51 fishwaldo Exp $ ** $Id: Bahamut.h,v 1.5 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
#ifndef BAHAMUT_H #ifndef BAHAMUT_H
#define BAHAMUT_H #define BAHAMUT_H
@ -30,66 +30,66 @@
#define MSG_PRIVATE "PRIVMSG" /* PRIV */ #define MSG_PRIVATE "PRIVMSG" /* PRIV */
#define MSG_WHO "WHO" /* WHO -> WHOC */ #define MSG_WHO "WHO" /* WHO -> WHOC */
#define MSG_WHOIS "WHOIS" /* WHOI */ #define MSG_WHOIS "WHOIS" /* WHOI */
#define MSG_WHOWAS "WHOWAS" /* WHOW */ #define MSG_WHOWAS "WHOWAS" /* WHOW */
#define MSG_USER "USER" /* USER */ #define MSG_USER "USER" /* USER */
#define MSG_NICK "NICK" /* NICK */ #define MSG_NICK "NICK" /* NICK */
#define MSG_SERVER "SERVER" /* SERV */ #define MSG_SERVER "SERVER" /* SERV */
#define MSG_LIST "LIST" /* LIST */ #define MSG_LIST "LIST" /* LIST */
#define MSG_TOPIC "TOPIC" /* TOPI */ #define MSG_TOPIC "TOPIC" /* TOPI */
#define MSG_INVITE "INVITE" /* INVI */ #define MSG_INVITE "INVITE" /* INVI */
#define MSG_VERSION "VERSION" /* VERS */ #define MSG_VERSION "VERSION" /* VERS */
#define MSG_QUIT "QUIT" /* QUIT */ #define MSG_QUIT "QUIT" /* QUIT */
#define MSG_SQUIT "SQUIT" /* SQUI */ #define MSG_SQUIT "SQUIT" /* SQUI */
#define MSG_KILL "KILL" /* KILL */ #define MSG_KILL "KILL" /* KILL */
#define MSG_INFO "INFO" /* INFO */ #define MSG_INFO "INFO" /* INFO */
#define MSG_LINKS "LINKS" /* LINK */ #define MSG_LINKS "LINKS" /* LINK */
#define MSG_WATCH "WATCH" /* WATCH */ #define MSG_WATCH "WATCH" /* WATCH */
#define MSG_STATS "STATS" /* STAT */ #define MSG_STATS "STATS" /* STAT */
#define MSG_HELP "HELP" /* HELP */ #define MSG_HELP "HELP" /* HELP */
#define MSG_HELPOP "HELPOP" /* HELP */ #define MSG_HELPOP "HELPOP" /* HELP */
#define MSG_ERROR "ERROR" /* ERRO */ #define MSG_ERROR "ERROR" /* ERRO */
#define MSG_AWAY "AWAY" /* AWAY */ #define MSG_AWAY "AWAY" /* AWAY */
#define MSG_CONNECT "CONNECT" /* CONN */ #define MSG_CONNECT "CONNECT" /* CONN */
#define MSG_PING "PING" /* PING */ #define MSG_PING "PING" /* PING */
#define MSG_PONG "PONG" /* PONG */ #define MSG_PONG "PONG" /* PONG */
#define MSG_OPER "OPER" /* OPER */ #define MSG_OPER "OPER" /* OPER */
#define MSG_PASS "PASS" /* PASS */ #define MSG_PASS "PASS" /* PASS */
#define MSG_WALLOPS "WALLOPS" /* WALL */ #define MSG_WALLOPS "WALLOPS" /* WALL */
#define MSG_TIME "TIME" /* TIME */ #define MSG_TIME "TIME" /* TIME */
#define MSG_NAMES "NAMES" /* NAME */ #define MSG_NAMES "NAMES" /* NAME */
#define MSG_ADMIN "ADMIN" /* ADMI */ #define MSG_ADMIN "ADMIN" /* ADMI */
#define MSG_NOTICE "NOTICE" /* NOTI */ #define MSG_NOTICE "NOTICE" /* NOTI */
#define MSG_JOIN "JOIN" /* JOIN */ #define MSG_JOIN "JOIN" /* JOIN */
#define MSG_PART "PART" /* PART */ #define MSG_PART "PART" /* PART */
#define MSG_LUSERS "LUSERS" /* LUSE */ #define MSG_LUSERS "LUSERS" /* LUSE */
#define MSG_MOTD "MOTD" /* MOTD */ #define MSG_MOTD "MOTD" /* MOTD */
#define MSG_MODE "MODE" /* MODE */ #define MSG_MODE "MODE" /* MODE */
#define MSG_KICK "KICK" /* KICK */ #define MSG_KICK "KICK" /* KICK */
#define MSG_SERVICE "SERVICE" /* SERV -> SRVI */ #define MSG_SERVICE "SERVICE" /* SERV -> SRVI */
#define MSG_USERHOST "USERHOST" /* USER -> USRH */ #define MSG_USERHOST "USERHOST" /* USER -> USRH */
#define MSG_ISON "ISON" /* ISON */ #define MSG_ISON "ISON" /* ISON */
#define MSG_SQUERY "SQUERY" /* SQUE */ #define MSG_SQUERY "SQUERY" /* SQUE */
#define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */ #define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */
#define MSG_SERVSET "SERVSET" /* SERV -> SSET */ #define MSG_SERVSET "SERVSET" /* SERV -> SSET */
#define MSG_REHASH "REHASH" /* REHA */ #define MSG_REHASH "REHASH" /* REHA */
#define MSG_RESTART "RESTART" /* REST */ #define MSG_RESTART "RESTART" /* REST */
#define MSG_CLOSE "CLOSE" /* CLOS */ #define MSG_CLOSE "CLOSE" /* CLOS */
#define MSG_DIE "DIE" /* DIE */ #define MSG_DIE "DIE" /* DIE */
#define MSG_HASH "HASH" /* HASH */ #define MSG_HASH "HASH" /* HASH */
#define MSG_DNS "DNS" /* DNS -> DNSS */ #define MSG_DNS "DNS" /* DNS -> DNSS */
#define MSG_SILENCE "SILENCE" /* SILE */ #define MSG_SILENCE "SILENCE" /* SILE */
#define MSG_AKILL "AKILL" /* AKILL */ #define MSG_AKILL "AKILL" /* AKILL */
#define MSG_KLINE "KLINE" /* KLINE */ #define MSG_KLINE "KLINE" /* KLINE */
#define MSG_UNKLINE "UNKLINE" /* UNKLINE */ #define MSG_UNKLINE "UNKLINE" /* UNKLINE */
#define MSG_RAKILL "RAKILL" /* RAKILL */ #define MSG_RAKILL "RAKILL" /* RAKILL */
#define MSG_GNOTICE "GNOTICE" /* GNOTICE */ #define MSG_GNOTICE "GNOTICE" /* GNOTICE */
#define MSG_GOPER "GOPER" /* GOPER */ #define MSG_GOPER "GOPER" /* GOPER */
#define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */ #define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */
#define MSG_LOCOPS "LOCOPS" /* LOCOPS */ #define MSG_LOCOPS "LOCOPS" /* LOCOPS */
#define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */ #define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */
#define MSG_TRACE "TRACE" /* TRAC */ #define MSG_TRACE "TRACE" /* TRAC */
#define MSG_SQLINE "SQLINE" /* SQLINE */ #define MSG_SQLINE "SQLINE" /* SQLINE */
#define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */ #define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */
#define MSG_SVSNICK "SVSNICK" /* SVSNICK */ #define MSG_SVSNICK "SVSNICK" /* SVSNICK */
@ -99,14 +99,14 @@
#define MSG_SVSMODE "SVSMODE" /* SVSMODE */ #define MSG_SVSMODE "SVSMODE" /* SVSMODE */
#define MSG_SAMODE "SAMODE" /* SAMODE */ #define MSG_SAMODE "SAMODE" /* SAMODE */
#define MSG_CHATOPS "CHATOPS" /* CHATOPS */ #define MSG_CHATOPS "CHATOPS" /* CHATOPS */
#define MSG_HELPSERV "HELPSERV" /* HELPSERV */ #define MSG_HELPSERV "HELPSERV" /* HELPSERV */
#define MSG_ZLINE "ZLINE" /* ZLINE */ #define MSG_ZLINE "ZLINE" /* ZLINE */
#define MSG_UNZLINE "UNZLINE" /* UNZLINE */ #define MSG_UNZLINE "UNZLINE" /* UNZLINE */
#define MSG_NETINFO "NETINFO" /* NETINFO */ #define MSG_NETINFO "NETINFO" /* NETINFO */
#define MSG_RULES "RULES" /* RULES */ #define MSG_RULES "RULES" /* RULES */
#define MSG_MAP "MAP" /* MAP */ #define MSG_MAP "MAP" /* MAP */
#define MSG_NETG "NETG" /* NETG */ #define MSG_NETG "NETG" /* NETG */
#define MSG_ADCHAT "ADCHAT" /* Adchat */ #define MSG_ADCHAT "ADCHAT" /* Adchat */
#define MSG_MAKEPASS "MAKEPASS" /* MAKEPASS */ #define MSG_MAKEPASS "MAKEPASS" /* MAKEPASS */
#define MSG_ADDHUB "ADDHUB" /* ADDHUB */ #define MSG_ADDHUB "ADDHUB" /* ADDHUB */
#define MSG_DELHUB "DELHUB" /* DELHUB */ #define MSG_DELHUB "DELHUB" /* DELHUB */
@ -116,28 +116,28 @@
#define MSG_DELOPER "DELOPER" /* DELOPER */ #define MSG_DELOPER "DELOPER" /* DELOPER */
#define MSG_ADDQLINE "ADDQLINE" /* ADDQLINE */ #define MSG_ADDQLINE "ADDQLINE" /* ADDQLINE */
#define MSG_DELQLINE "DELQLINE" /* DELQLINE */ #define MSG_DELQLINE "DELQLINE" /* DELQLINE */
#define MSG_GSOP "GSOP" /* GSOP */ #define MSG_GSOP "GSOP" /* GSOP */
#define MSG_ISOPER "ISOPER" /* ISOPER */ #define MSG_ISOPER "ISOPER" /* ISOPER */
#define MSG_ADG "ADG" /* ADG */ #define MSG_ADG "ADG" /* ADG */
#define MSG_NMON "NMON" /* NMON */ #define MSG_NMON "NMON" /* NMON */
#define MSG_DALINFO "DALINFO" /* DALnet Credits */ #define MSG_DALINFO "DALINFO" /* DALnet Credits */
#define MSG_CREDITS "CREDITS" /* UltimateIRCd Credits and "Thanks To" */ #define MSG_CREDITS "CREDITS" /* UltimateIRCd Credits and "Thanks To" */
#define MSG_OPERMOTD "OPERMOTD" /* OPERMOTD */ #define MSG_OPERMOTD "OPERMOTD" /* OPERMOTD */
#define MSG_REMREHASH "REMREHASH" /* Remote Rehash */ #define MSG_REMREHASH "REMREHASH" /* Remote Rehash */
#define MSG_MONITOR "MONITOR" /* MONITOR */ #define MSG_MONITOR "MONITOR" /* MONITOR */
#define MSG_GLINE "GLINE" /* The awesome g-line */ #define MSG_GLINE "GLINE" /* The awesome g-line */
#define MSG_REMGLINE "REMGLINE" /* remove g-line */ #define MSG_REMGLINE "REMGLINE" /* remove g-line */
#define MSG_STATSERV "STATSERV" /* StatServ */ #define MSG_STATSERV "STATSERV" /* StatServ */
#define MSG_RULESERV "RULESERV" /* RuleServ */ #define MSG_RULESERV "RULESERV" /* RuleServ */
#define MSG_SNETINFO "SNETINFO" /* SNetInfo */ #define MSG_SNETINFO "SNETINFO" /* SNetInfo */
#define MSG_TSCTL "TSCTL" /* TSCTL */ #define MSG_TSCTL "TSCTL" /* TSCTL */
#define MSG_SVSJOIN "SVSJOIN" /* SVSJOIN */ #define MSG_SVSJOIN "SVSJOIN" /* SVSJOIN */
#define MSG_SAJOIN "SAJOIN" /* SAJOIN */ #define MSG_SAJOIN "SAJOIN" /* SAJOIN */
#define MSG_SDESC "SDESC" /* SDESC */ #define MSG_SDESC "SDESC" /* SDESC */
#define MSG_UNREALINFO "UNREALINFO" /* Unreal Info */ #define MSG_UNREALINFO "UNREALINFO" /* Unreal Info */
#define MSG_SETHOST "SETHOST" /* sethost */ #define MSG_SETHOST "SETHOST" /* sethost */
#define MSG_SETIDENT "SETIDENT" /* set ident */ #define MSG_SETIDENT "SETIDENT" /* set ident */
#define MSG_SETNAME "SETNAME" /* set Realname */ #define MSG_SETNAME "SETNAME" /* set Realname */
#define MSG_CHGHOST "CHGHOST" /* Changehost */ #define MSG_CHGHOST "CHGHOST" /* Changehost */
#define MSG_CHGIDENT "CHGIDENT" /* Change Ident */ #define MSG_CHGIDENT "CHGIDENT" /* Change Ident */
#define MSG_RANDQUOTE "RANDQUOTE" /* Random Quote */ #define MSG_RANDQUOTE "RANDQUOTE" /* Random Quote */
@ -145,19 +145,19 @@
#define MSG_ADDGQUOTE "ADDGQUOTE" /* Add Global Quote */ #define MSG_ADDGQUOTE "ADDGQUOTE" /* Add Global Quote */
#define MSG_ADDULINE "ADDULINE" /* Adds an U Line to ircd.conf file */ #define MSG_ADDULINE "ADDULINE" /* Adds an U Line to ircd.conf file */
#define MSG_DELULINE "DELULINE" /* Removes an U line from the ircd.conf */ #define MSG_DELULINE "DELULINE" /* Removes an U line from the ircd.conf */
#define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */ #define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */
#define MSG_SETTINGS "SETTINGS" /* Settings */ #define MSG_SETTINGS "SETTINGS" /* Settings */
#define MSG_IRCOPS "IRCOPS" /* Shows Online IRCOps */ #define MSG_IRCOPS "IRCOPS" /* Shows Online IRCOps */
#define MSG_SVSPART "SVSPART" /* SVSPART */ #define MSG_SVSPART "SVSPART" /* SVSPART */
#define MSG_SAPART "SAPART" /* SAPART */ #define MSG_SAPART "SAPART" /* SAPART */
#define MSG_VCTRL "VCTRL" /* VCTRL */ #define MSG_VCTRL "VCTRL" /* VCTRL */
#define MSG_GCLIENT "GCLIENT" /* GLIENT */ #define MSG_GCLIENT "GCLIENT" /* GLIENT */
#define MSG_CHANNEL "CHANNEL" /* CHANNEL */ #define MSG_CHANNEL "CHANNEL" /* CHANNEL */
#define MSG_UPTIME "UPTIME" /* UPTIME */ #define MSG_UPTIME "UPTIME" /* UPTIME */
#define MSG_FAILOPS "FAILOPS" /* FAILOPS */ #define MSG_FAILOPS "FAILOPS" /* FAILOPS */
#define MSG_RPING "RPING" /* RPING */ #define MSG_RPING "RPING" /* RPING */
#define MSG_RPONG "RPONG" /* RPONG */ #define MSG_RPONG "RPONG" /* RPONG */
#define MSG_UPING "UPING" /* UPING */ #define MSG_UPING "UPING" /* UPING */
#define MSG_COPYRIGHT "COPYRIGHT" /* Copyright */ #define MSG_COPYRIGHT "COPYRIGHT" /* Copyright */
#define MSG_BOTSERV "BOTSERV" /* BOTSERV */ #define MSG_BOTSERV "BOTSERV" /* BOTSERV */
#define MSG_ROOTSERV "ROOTSERV" /* ROOTSERV */ #define MSG_ROOTSERV "ROOTSERV" /* ROOTSERV */
@ -171,14 +171,14 @@
#define UMODE_INVISIBLE 0x0001 /* makes user invisible */ #define UMODE_INVISIBLE 0x0001 /* makes user invisible */
#define UMODE_OPER 0x0002 /* Operator */ #define UMODE_OPER 0x0002 /* Operator */
/* UMODE_SERVICES is actually UMODE_OPER on Bahamut !*/ /* UMODE_SERVICES is actually UMODE_OPER on Bahamut !*/
#define UMODE_SERVICES UMODE_OPER #define UMODE_SERVICES UMODE_OPER
#define UMODE_REGONLY 0x0010 /* only registered nicks may PM */ #define UMODE_REGONLY 0x0010 /* only registered nicks may PM */
#define UMODE_REGNICK 0x0020 /* Nick set by services as registered */ #define UMODE_REGNICK 0x0020 /* Nick set by services as registered */
#define UMODE_SERVADMIN 0x0040 /* server admin */ #define UMODE_SERVADMIN 0x0040 /* server admin */
#define UMODE_SERVICESADMIN 0x0080 /* Marks the client as a Services Administrator */ #define UMODE_SERVICESADMIN 0x0080 /* Marks the client as a Services Administrator */
@ -219,8 +219,8 @@ struct ircd_srv_ {
typedef struct { typedef struct {
long mode; long mode;
char flag; char flag;
unsigned nickparam : 1; /* 1 = yes 0 = no */ unsigned nickparam:1; /* 1 = yes 0 = no */
unsigned parameters : 1; unsigned parameters:1;
char sjoin; char sjoin;
} aCtab; } aCtab;
@ -242,77 +242,77 @@ Oper_Modes susr_mds[9];
/* function declarations */ /* function declarations */
extern void init_ircd(); extern void init_ircd ();
extern void chanalert(char *,char *, ...); extern void chanalert (char *, char *, ...);
extern int sserver_cmd(const char *, const int numeric, const char *); extern int sserver_cmd (const char *, const int numeric, const char *);
extern int slogin_cmd(const char *, const int numeric, const char *, const char *); extern int slogin_cmd (const char *, const int numeric, const char *, const char *);
extern int ssquit_cmd(const char *); extern int ssquit_cmd (const char *);
extern int sprotocol_cmd(const char *); extern int sprotocol_cmd (const char *);
extern int squit_cmd(const char *, const char *); extern int squit_cmd (const char *, const char *);
extern int spart_cmd(const char *, const char *); extern int spart_cmd (const char *, const char *);
extern int sjoin_cmd(const char *, const char *, unsigned long flag); extern int sjoin_cmd (const char *, const char *, unsigned long flag);
extern int schmode_cmd(const char *, const char *, const char *, const char *); extern int schmode_cmd (const char *, const char *, const char *, const char *);
extern int snewnick_cmd(const char *, const char *, const char *, const char *, long); extern int snewnick_cmd (const char *, const char *, const char *, const char *, long);
extern int sping_cmd(const char *from, const char *reply, const char *to); extern int sping_cmd (const char *from, const char *reply, const char *to);
extern int sumode_cmd(const char *who, const char *target, long mode); extern int sumode_cmd (const char *who, const char *target, long mode);
extern int snumeric_cmd(const int numeric, const char *target, const char *data,...); extern int snumeric_cmd (const int numeric, const char *target, const char *data, ...);
extern int spong_cmd(const char *reply); extern int spong_cmd (const char *reply);
extern int snetinfo_cmd(); extern int snetinfo_cmd ();
extern int skill_cmd(const char *from, const char *target, const char *reason,...); extern int skill_cmd (const char *from, const char *target, const char *reason, ...);
extern int ssmo_cmd(const char *from, const char *umodetarget, const char *msg); extern int ssmo_cmd (const char *from, const char *umodetarget, const char *msg);
extern int snick_cmd(const char *oldnick, const char *newnick); extern int snick_cmd (const char *oldnick, const char *newnick);
extern int sswhois_cmd(const char *target, const char *swhois); extern int sswhois_cmd (const char *target, const char *swhois);
extern int ssvsnick_cmd(const char *target, const char *newnick); extern int ssvsnick_cmd (const char *target, const char *newnick);
extern int ssvsjoin_cmd(const char *target, const char *chan); extern int ssvsjoin_cmd (const char *target, const char *chan);
extern int ssvspart_cmd(const char *target, const char *chan); extern int ssvspart_cmd (const char *target, const char *chan);
extern int ssvshost_cmd(const char *who, const char *vhost); extern int ssvshost_cmd (const char *who, const char *vhost);
extern int skick_cmd(const char *who, const char *target, const char *chan, const char *reason); extern int skick_cmd (const char *who, const char *target, const char *chan, const char *reason);
extern int swallops_cmd(const char *who, const char *msg,...); extern int swallops_cmd (const char *who, const char *msg, ...);
extern int vctrl_cmd(); extern int vctrl_cmd ();
extern int ssvinfo_cmd(); extern int ssvinfo_cmd ();
extern int sburst_cmd(int b); extern int sburst_cmd (int b);
extern int sakill_cmd(const char *host, const char *ident, const char *setby, const int length, const char *reason,...); extern int sakill_cmd (const char *host, const char *ident, const char *setby, const int length, const char *reason, ...);
extern int srakill_cmd(const char *host, const char *ident); extern int srakill_cmd (const char *host, const char *ident);
extern int ssvshost_cmd(const char *who, const char *vhost); extern int ssvshost_cmd (const char *who, const char *vhost);
extern int ssvskill_cmd(const char *who, const char *reason, ...); extern int ssvskill_cmd (const char *who, const char *reason, ...);
void Usr_Version(char *, char **, int argc); void Usr_Version (char *, char **, int argc);
void Usr_ShowMOTD(char *, char **, int argc); void Usr_ShowMOTD (char *, char **, int argc);
void Usr_ShowADMIN(char *, char **, int argc); void Usr_ShowADMIN (char *, char **, int argc);
void Usr_Showcredits(char *, char **, int argc); void Usr_Showcredits (char *, char **, int argc);
void Usr_AddServer(char *, char **, int argc); void Usr_AddServer (char *, char **, int argc);
void Usr_DelServer(char *, char **, int argc); void Usr_DelServer (char *, char **, int argc);
void Usr_DelUser(char *, char **, int argc); void Usr_DelUser (char *, char **, int argc);
void Usr_Mode(char *, char **, int argc); void Usr_Mode (char *, char **, int argc);
void Usr_Smode(char *, char **, int argc); void Usr_Smode (char *, char **, int argc);
void Usr_Kill(char *, char **, int argc); void Usr_Kill (char *, char **, int argc);
void Usr_Pong(char *, char **, int argc); void Usr_Pong (char *, char **, int argc);
void Usr_Away(char *, char **, int argc); void Usr_Away (char *, char **, int argc);
void Usr_Nick(char *, char **, int argc); void Usr_Nick (char *, char **, int argc);
void Usr_Topic(char *, char **, int argc); void Usr_Topic (char *, char **, int argc);
void Usr_Kick(char *, char **, int argc); void Usr_Kick (char *, char **, int argc);
void Usr_Join(char *, char **, int argc); void Usr_Join (char *, char **, int argc);
void Usr_Part(char *, char **, int argc); void Usr_Part (char *, char **, int argc);
void Usr_Stats(char *, char **, int argc); void Usr_Stats (char *, char **, int argc);
void Usr_Vhost(char *, char **, int argc); void Usr_Vhost (char *, char **, int argc);
void Srv_Topic(char *, char **, int argc); void Srv_Topic (char *, char **, int argc);
void Srv_Ping(char *, char **, int argc); void Srv_Ping (char *, char **, int argc);
void Srv_Netinfo(char *, char **, int argc); void Srv_Netinfo (char *, char **, int argc);
void Srv_Pass(char *, char **, int argc); void Srv_Pass (char *, char **, int argc);
void Srv_Server(char *, char **, int argc); void Srv_Server (char *, char **, int argc);
void Srv_Squit(char *, char **, int argc); void Srv_Squit (char *, char **, int argc);
void Srv_Nick(char *, char **, int argc); void Srv_Nick (char *, char **, int argc);
void Srv_Svsnick(char *, char **, int argc); void Srv_Svsnick (char *, char **, int argc);
void Srv_Kill(char *, char **, int argc); void Srv_Kill (char *, char **, int argc);
void Srv_Connect(char *, char **, int argc); void Srv_Connect (char *, char **, int argc);
void Srv_Svinfo(char *, char **, int argc); void Srv_Svinfo (char *, char **, int argc);
void Srv_Burst(char *origin, char **argv, int argc); void Srv_Burst (char *origin, char **argv, int argc);
void Srv_Sjoin(char *origin, char **argv, int argc); void Srv_Sjoin (char *origin, char **argv, int argc);
void Srv_Tburst(char *origin, char **argv, int argc); void Srv_Tburst (char *origin, char **argv, int argc);
void Srv_Vctrl(char *origin, char **argv, int argc); void Srv_Vctrl (char *origin, char **argv, int argc);
void Srv_Client(char *origin, char **argv, int argc); void Srv_Client (char *origin, char **argv, int argc);
void Srv_Smode(char *origin, char **argv, int argc); void Srv_Smode (char *origin, char **argv, int argc);
int SignOn_NewBot(const char *, const char *, const char *, const char *, long); int SignOn_NewBot (const char *, const char *, const char *, const char *, long);
#endif #endif

View file

@ -3,6 +3,8 @@ NeoStats ChangeLog - Anything we add/remove/fix/change is in here (even our rant
- Fixed a core with using strcasecmp instead of strcmp in the parse function. - Fixed a core with using strcasecmp instead of strcmp in the parse function.
- Moved is_pub_chan from SecureServ to NeoStats - Moved is_pub_chan from SecureServ to NeoStats
- Implemented Bahamut support and necessary functions - Implemented Bahamut support and necessary functions
- make the ping time configurable.
- Make Timers deletable from inside the timer function!
* NeoStats * Fish * Version 2.5.4 Pre2 * NeoStats * Fish * Version 2.5.4 Pre2
- Fixed a problem with statserv and the HTML settings - Fixed a problem with statserv and the HTML settings

707
Ircu.c

File diff suppressed because it is too large Load diff

268
Ircu.h
View file

@ -18,7 +18,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: Ircu.h,v 1.1 2003/06/30 15:18:23 fishwaldo Exp $ ** $Id: Ircu.h,v 1.2 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
@ -28,68 +28,68 @@
#define MSG_EOB "EOB" /* end of burst */ #define MSG_EOB "EOB" /* end of burst */
#define MSG_PRIVATE "PRIVMSG" /* PRIV */ #define MSG_PRIVATE "PRIVMSG" /* PRIV */
#define MSG_WHO "WHO" /* WHO -> WHOC */ #define MSG_WHO "WHO" /* WHO -> WHOC */
#define MSG_WHOIS "WHOIS" /* WHOI */ #define MSG_WHOIS "WHOIS" /* WHOI */
#define MSG_WHOWAS "WHOWAS" /* WHOW */ #define MSG_WHOWAS "WHOWAS" /* WHOW */
#define MSG_USER "USER" /* USER */ #define MSG_USER "USER" /* USER */
#define MSG_NICK "NICK" /* NICK */ #define MSG_NICK "NICK" /* NICK */
#define MSG_SERVER "SERVER" /* SERV */ #define MSG_SERVER "SERVER" /* SERV */
#define MSG_LIST "LIST" /* LIST */ #define MSG_LIST "LIST" /* LIST */
#define MSG_TOPIC "TOPIC" /* TOPI */ #define MSG_TOPIC "TOPIC" /* TOPI */
#define MSG_INVITE "INVITE" /* INVI */ #define MSG_INVITE "INVITE" /* INVI */
#define MSG_VERSION "VERSION" /* VERS */ #define MSG_VERSION "VERSION" /* VERS */
#define MSG_QUIT "QUIT" /* QUIT */ #define MSG_QUIT "QUIT" /* QUIT */
#define MSG_SQUIT "SQUIT" /* SQUI */ #define MSG_SQUIT "SQUIT" /* SQUI */
#define MSG_KILL "KILL" /* KILL */ #define MSG_KILL "KILL" /* KILL */
#define MSG_INFO "INFO" /* INFO */ #define MSG_INFO "INFO" /* INFO */
#define MSG_LINKS "LINKS" /* LINK */ #define MSG_LINKS "LINKS" /* LINK */
#define MSG_WATCH "WATCH" /* WATCH */ #define MSG_WATCH "WATCH" /* WATCH */
#define MSG_STATS "STATS" /* STAT */ #define MSG_STATS "STATS" /* STAT */
#define MSG_HELP "HELP" /* HELP */ #define MSG_HELP "HELP" /* HELP */
#define MSG_HELPOP "HELPOP" /* HELP */ #define MSG_HELPOP "HELPOP" /* HELP */
#define MSG_ERROR "ERROR" /* ERRO */ #define MSG_ERROR "ERROR" /* ERRO */
#define MSG_AWAY "AWAY" /* AWAY */ #define MSG_AWAY "AWAY" /* AWAY */
#define MSG_CONNECT "CONNECT" /* CONN */ #define MSG_CONNECT "CONNECT" /* CONN */
#define MSG_PING "PING" /* PING */ #define MSG_PING "PING" /* PING */
#define MSG_PONG "PONG" /* PONG */ #define MSG_PONG "PONG" /* PONG */
#define MSG_OPER "OPER" /* OPER */ #define MSG_OPER "OPER" /* OPER */
#define MSG_PASS "PASS" /* PASS */ #define MSG_PASS "PASS" /* PASS */
#define MSG_WALLOPS "WALLOPS" /* WALL */ #define MSG_WALLOPS "WALLOPS" /* WALL */
#define MSG_TIME "TIME" /* TIME */ #define MSG_TIME "TIME" /* TIME */
#define MSG_NAMES "NAMES" /* NAME */ #define MSG_NAMES "NAMES" /* NAME */
#define MSG_ADMIN "ADMIN" /* ADMI */ #define MSG_ADMIN "ADMIN" /* ADMI */
#define MSG_NOTICE "NOTICE" /* NOTI */ #define MSG_NOTICE "NOTICE" /* NOTI */
#define MSG_JOIN "JOIN" /* JOIN */ #define MSG_JOIN "JOIN" /* JOIN */
#define MSG_PART "PART" /* PART */ #define MSG_PART "PART" /* PART */
#define MSG_LUSERS "LUSERS" /* LUSE */ #define MSG_LUSERS "LUSERS" /* LUSE */
#define MSG_MOTD "MOTD" /* MOTD */ #define MSG_MOTD "MOTD" /* MOTD */
#define MSG_MODE "MODE" /* MODE */ #define MSG_MODE "MODE" /* MODE */
#define MSG_KICK "KICK" /* KICK */ #define MSG_KICK "KICK" /* KICK */
#define MSG_SERVICE "SERVICE" /* SERV -> SRVI */ #define MSG_SERVICE "SERVICE" /* SERV -> SRVI */
#define MSG_USERHOST "USERHOST" /* USER -> USRH */ #define MSG_USERHOST "USERHOST" /* USER -> USRH */
#define MSG_ISON "ISON" /* ISON */ #define MSG_ISON "ISON" /* ISON */
#define MSG_SQUERY "SQUERY" /* SQUE */ #define MSG_SQUERY "SQUERY" /* SQUE */
#define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */ #define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */
#define MSG_SERVSET "SERVSET" /* SERV -> SSET */ #define MSG_SERVSET "SERVSET" /* SERV -> SSET */
#define MSG_REHASH "REHASH" /* REHA */ #define MSG_REHASH "REHASH" /* REHA */
#define MSG_RESTART "RESTART" /* REST */ #define MSG_RESTART "RESTART" /* REST */
#define MSG_CLOSE "CLOSE" /* CLOS */ #define MSG_CLOSE "CLOSE" /* CLOS */
#define MSG_DIE "DIE" /* DIE */ #define MSG_DIE "DIE" /* DIE */
#define MSG_HASH "HASH" /* HASH */ #define MSG_HASH "HASH" /* HASH */
#define MSG_DNS "DNS" /* DNS -> DNSS */ #define MSG_DNS "DNS" /* DNS -> DNSS */
#define MSG_SILENCE "SILENCE" /* SILE */ #define MSG_SILENCE "SILENCE" /* SILE */
#define MSG_AKILL "AKILL" /* AKILL */ #define MSG_AKILL "AKILL" /* AKILL */
#define MSG_KLINE "KLINE" /* KLINE */ #define MSG_KLINE "KLINE" /* KLINE */
#define MSG_UNKLINE "UNKLINE" /* UNKLINE */ #define MSG_UNKLINE "UNKLINE" /* UNKLINE */
#define MSG_RAKILL "RAKILL" /* RAKILL */ #define MSG_RAKILL "RAKILL" /* RAKILL */
#define MSG_GNOTICE "GNOTICE" /* GNOTICE */ #define MSG_GNOTICE "GNOTICE" /* GNOTICE */
#define MSG_GOPER "GOPER" /* GOPER */ #define MSG_GOPER "GOPER" /* GOPER */
#define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */ #define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */
#define MSG_LOCOPS "LOCOPS" /* LOCOPS */ #define MSG_LOCOPS "LOCOPS" /* LOCOPS */
#define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */ #define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */
#define MSG_TRACE "TRACE" /* TRAC */ #define MSG_TRACE "TRACE" /* TRAC */
#define MSG_SQLINE "SQLINE" /* SQLINE */ #define MSG_SQLINE "SQLINE" /* SQLINE */
#define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */ #define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */
#define MSG_SVSNICK "SVSNICK" /* SVSNICK */ #define MSG_SVSNICK "SVSNICK" /* SVSNICK */
@ -108,14 +108,14 @@
#define MSG_SVSMODE "SVSMODE" /* SVSMODE */ #define MSG_SVSMODE "SVSMODE" /* SVSMODE */
#define MSG_SAMODE "SAMODE" /* SAMODE */ #define MSG_SAMODE "SAMODE" /* SAMODE */
#define MSG_CHATOPS "CHATOPS" /* CHATOPS */ #define MSG_CHATOPS "CHATOPS" /* CHATOPS */
#define MSG_HELPSERV "HELPSERV" /* HELPSERV */ #define MSG_HELPSERV "HELPSERV" /* HELPSERV */
#define MSG_ZLINE "ZLINE" /* ZLINE */ #define MSG_ZLINE "ZLINE" /* ZLINE */
#define MSG_UNZLINE "UNZLINE" /* UNZLINE */ #define MSG_UNZLINE "UNZLINE" /* UNZLINE */
#define MSG_NETINFO "NETINFO" /* NETINFO */ #define MSG_NETINFO "NETINFO" /* NETINFO */
#define MSG_RULES "RULES" /* RULES */ #define MSG_RULES "RULES" /* RULES */
#define MSG_MAP "MAP" /* MAP */ #define MSG_MAP "MAP" /* MAP */
#define MSG_NETG "NETG" /* NETG */ #define MSG_NETG "NETG" /* NETG */
#define MSG_ADCHAT "ADCHAT" /* Adchat */ #define MSG_ADCHAT "ADCHAT" /* Adchat */
#define MSG_MAKEPASS "MAKEPASS" /* MAKEPASS */ #define MSG_MAKEPASS "MAKEPASS" /* MAKEPASS */
#define MSG_ADDHUB "ADDHUB" /* ADDHUB */ #define MSG_ADDHUB "ADDHUB" /* ADDHUB */
#define MSG_DELHUB "DELHUB" /* DELHUB */ #define MSG_DELHUB "DELHUB" /* DELHUB */
@ -125,28 +125,28 @@
#define MSG_DELOPER "DELOPER" /* DELOPER */ #define MSG_DELOPER "DELOPER" /* DELOPER */
#define MSG_ADDQLINE "ADDQLINE" /* ADDQLINE */ #define MSG_ADDQLINE "ADDQLINE" /* ADDQLINE */
#define MSG_DELQLINE "DELQLINE" /* DELQLINE */ #define MSG_DELQLINE "DELQLINE" /* DELQLINE */
#define MSG_GSOP "GSOP" /* GSOP */ #define MSG_GSOP "GSOP" /* GSOP */
#define MSG_ISOPER "ISOPER" /* ISOPER */ #define MSG_ISOPER "ISOPER" /* ISOPER */
#define MSG_ADG "ADG" /* ADG */ #define MSG_ADG "ADG" /* ADG */
#define MSG_NMON "NMON" /* NMON */ #define MSG_NMON "NMON" /* NMON */
#define MSG_DALINFO "DALINFO" /* DALnet Credits */ #define MSG_DALINFO "DALINFO" /* DALnet Credits */
#define MSG_CREDITS "CREDITS" /* UltimateIRCd Credits and "Thanks To" */ #define MSG_CREDITS "CREDITS" /* UltimateIRCd Credits and "Thanks To" */
#define MSG_OPERMOTD "OPERMOTD" /* OPERMOTD */ #define MSG_OPERMOTD "OPERMOTD" /* OPERMOTD */
#define MSG_REMREHASH "REMREHASH" /* Remote Rehash */ #define MSG_REMREHASH "REMREHASH" /* Remote Rehash */
#define MSG_MONITOR "MONITOR" /* MONITOR */ #define MSG_MONITOR "MONITOR" /* MONITOR */
#define MSG_GLINE "GLINE" /* The awesome g-line */ #define MSG_GLINE "GLINE" /* The awesome g-line */
#define MSG_REMGLINE "REMGLINE" /* remove g-line */ #define MSG_REMGLINE "REMGLINE" /* remove g-line */
#define MSG_STATSERV "STATSERV" /* StatServ */ #define MSG_STATSERV "STATSERV" /* StatServ */
#define MSG_RULESERV "RULESERV" /* RuleServ */ #define MSG_RULESERV "RULESERV" /* RuleServ */
#define MSG_SNETINFO "SNETINFO" /* SNetInfo */ #define MSG_SNETINFO "SNETINFO" /* SNetInfo */
#define MSG_TSCTL "TSCTL" /* TSCTL */ #define MSG_TSCTL "TSCTL" /* TSCTL */
#define MSG_SVSJOIN "SVSJOIN" /* SVSJOIN */ #define MSG_SVSJOIN "SVSJOIN" /* SVSJOIN */
#define MSG_SAJOIN "SAJOIN" /* SAJOIN */ #define MSG_SAJOIN "SAJOIN" /* SAJOIN */
#define MSG_SDESC "SDESC" /* SDESC */ #define MSG_SDESC "SDESC" /* SDESC */
#define MSG_UNREALINFO "UNREALINFO" /* Unreal Info */ #define MSG_UNREALINFO "UNREALINFO" /* Unreal Info */
#define MSG_SETHOST "SETHOST" /* sethost */ #define MSG_SETHOST "SETHOST" /* sethost */
#define MSG_SETIDENT "SETIDENT" /* set ident */ #define MSG_SETIDENT "SETIDENT" /* set ident */
#define MSG_SETNAME "SETNAME" /* set Realname */ #define MSG_SETNAME "SETNAME" /* set Realname */
#define MSG_CHGHOST "CHGHOST" /* Changehost */ #define MSG_CHGHOST "CHGHOST" /* Changehost */
#define MSG_CHGIDENT "CHGIDENT" /* Change Ident */ #define MSG_CHGIDENT "CHGIDENT" /* Change Ident */
#define MSG_RANDQUOTE "RANDQUOTE" /* Random Quote */ #define MSG_RANDQUOTE "RANDQUOTE" /* Random Quote */
@ -154,19 +154,19 @@
#define MSG_ADDGQUOTE "ADDGQUOTE" /* Add Global Quote */ #define MSG_ADDGQUOTE "ADDGQUOTE" /* Add Global Quote */
#define MSG_ADDULINE "ADDULINE" /* Adds an U Line to ircd.conf file */ #define MSG_ADDULINE "ADDULINE" /* Adds an U Line to ircd.conf file */
#define MSG_DELULINE "DELULINE" /* Removes an U line from the ircd.conf */ #define MSG_DELULINE "DELULINE" /* Removes an U line from the ircd.conf */
#define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */ #define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */
#define MSG_SETTINGS "SETTINGS" /* Settings */ #define MSG_SETTINGS "SETTINGS" /* Settings */
#define MSG_IRCOPS "IRCOPS" /* Shows Online IRCOps */ #define MSG_IRCOPS "IRCOPS" /* Shows Online IRCOps */
#define MSG_SVSPART "SVSPART" /* SVSPART */ #define MSG_SVSPART "SVSPART" /* SVSPART */
#define MSG_SAPART "SAPART" /* SAPART */ #define MSG_SAPART "SAPART" /* SAPART */
#define MSG_VCTRL "VCTRL" /* VCTRL */ #define MSG_VCTRL "VCTRL" /* VCTRL */
#define MSG_GCLIENT "GCLIENT" /* GLIENT */ #define MSG_GCLIENT "GCLIENT" /* GLIENT */
#define MSG_CHANNEL "CHANNEL" /* CHANNEL */ #define MSG_CHANNEL "CHANNEL" /* CHANNEL */
#define MSG_UPTIME "UPTIME" /* UPTIME */ #define MSG_UPTIME "UPTIME" /* UPTIME */
#define MSG_FAILOPS "FAILOPS" /* FAILOPS */ #define MSG_FAILOPS "FAILOPS" /* FAILOPS */
#define MSG_RPING "RPING" /* RPING */ #define MSG_RPING "RPING" /* RPING */
#define MSG_RPONG "RPONG" /* RPONG */ #define MSG_RPONG "RPONG" /* RPONG */
#define MSG_UPING "UPING" /* UPING */ #define MSG_UPING "UPING" /* UPING */
#define MSG_COPYRIGHT "COPYRIGHT" /* Copyright */ #define MSG_COPYRIGHT "COPYRIGHT" /* Copyright */
#define MSG_BOTSERV "BOTSERV" /* BOTSERV */ #define MSG_BOTSERV "BOTSERV" /* BOTSERV */
#define MSG_BS "BS" #define MSG_BS "BS"
@ -191,14 +191,14 @@
#define UMODE_SKILL 0x0100 /* client see's server kills */ #define UMODE_SKILL 0x0100 /* client see's server kills */
#define UMODE_LOCOPS 0x0200 /* client is localop */ #define UMODE_LOCOPS 0x0200 /* client is localop */
#define UMODE_NCHANGE 0x0400 /* client can see nick change notices */ #define UMODE_NCHANGE 0x0400 /* client can see nick change notices */
#define UMODE_REJ 0x0800 /* client is registered */ #define UMODE_REJ 0x0800 /* client is registered */
#define UMODE_SERVNOTICE 0x1000 /* client can see server notices */ #define UMODE_SERVNOTICE 0x1000 /* client can see server notices */
#define UMODE_UNAUTH 0x2000 /* client can see unauthd connections */ #define UMODE_UNAUTH 0x2000 /* client can see unauthd connections */
#define UMODE_WALLOP 0x4000 /* client can get wallop messages */ #define UMODE_WALLOP 0x4000 /* client can get wallop messages */
#define UMODE_EXTERNAL 0x8000 /* client can see server joins/splits */ #define UMODE_EXTERNAL 0x8000 /* client can see server joins/splits */
#define UMODE_SPY 0x10000 /* client can spy on user commands */ #define UMODE_SPY 0x10000 /* client can spy on user commands */
#define UMODE_OPERWALL 0x20000 /* client gets operwalls */ #define UMODE_OPERWALL 0x20000 /* client gets operwalls */
#define UMODE_SERVICES 0x40000 /* client is services */ #define UMODE_SERVICES 0x40000 /* client is services */
#define MODE_CHANOP 0x0001 #define MODE_CHANOP 0x0001
@ -234,8 +234,8 @@ struct ircd_srv_ {
typedef struct { typedef struct {
long mode; long mode;
char flag; char flag;
unsigned nickparam : 1; /* 1 = yes 0 = no */ unsigned nickparam:1; /* 1 = yes 0 = no */
unsigned parameters : 1; unsigned parameters:1;
char sjoin; char sjoin;
} aCtab; } aCtab;
@ -257,74 +257,74 @@ Oper_Modes susr_mds[0];
/* function declarations */ /* function declarations */
extern void init_ircd(); extern void init_ircd ();
extern void chanalert(char *,char *, ...); extern void chanalert (char *, char *, ...);
extern int sserver_cmd(const char *, const int numeric, const char *); extern int sserver_cmd (const char *, const int numeric, const char *);
extern int slogin_cmd(const char *, const int numeric, const char *, const char *); extern int slogin_cmd (const char *, const int numeric, const char *, const char *);
extern int ssquit_cmd(const char *); extern int ssquit_cmd (const char *);
extern int sprotocol_cmd(const char *); extern int sprotocol_cmd (const char *);
extern int squit_cmd(const char *, const char *); extern int squit_cmd (const char *, const char *);
extern int spart_cmd(const char *, const char *); extern int spart_cmd (const char *, const char *);
extern int sjoin_cmd(const char *, const char *); extern int sjoin_cmd (const char *, const char *);
extern int schmode_cmd(const char *, const char *, const char *, const char *); extern int schmode_cmd (const char *, const char *, const char *, const char *);
extern int snewnick_cmd(const char *, const char *, const char *, const char *, long mode); extern int snewnick_cmd (const char *, const char *, const char *, const char *, long mode);
extern int sping_cmd(const char *from, const char *reply, const char *to); extern int sping_cmd (const char *from, const char *reply, const char *to);
extern int sumode_cmd(const char *who, const char *target, long mode); extern int sumode_cmd (const char *who, const char *target, long mode);
extern int snumeric_cmd(const int numeric, const char *target, const char *data,...); extern int snumeric_cmd (const int numeric, const char *target, const char *data, ...);
extern int spong_cmd(const char *reply); extern int spong_cmd (const char *reply);
extern int snetinfo_cmd(); extern int snetinfo_cmd ();
extern int skill_cmd(const char *from, const char *target, const char *reason,...); extern int skill_cmd (const char *from, const char *target, const char *reason, ...);
extern int ssvskill_cmd(const char *who, const char *reason, ...); extern int ssvskill_cmd (const char *who, const char *reason, ...);
extern int ssmo_cmd(const char *from, const char *umodetarget, const char *msg); extern int ssmo_cmd (const char *from, const char *umodetarget, const char *msg);
extern int snick_cmd(const char *oldnick, const char *newnick); extern int snick_cmd (const char *oldnick, const char *newnick);
extern int sswhois_cmd(const char *target, const char *swhois); extern int sswhois_cmd (const char *target, const char *swhois);
extern int ssvsnick_cmd(const char *target, const char *newnick); extern int ssvsnick_cmd (const char *target, const char *newnick);
extern int ssvsjoin_cmd(const char *target, const char *chan); extern int ssvsjoin_cmd (const char *target, const char *chan);
extern int ssvspart_cmd(const char *target, const char *chan); extern int ssvspart_cmd (const char *target, const char *chan);
extern int ssvshost_cmd(const char *who, const char *vhost); extern int ssvshost_cmd (const char *who, const char *vhost);
extern int skick_cmd(const char *who, const char *target, const char *chan, const char *reason); extern int skick_cmd (const char *who, const char *target, const char *chan, const char *reason);
extern int swallops_cmd(const char *who, const char *msg,...); extern int swallops_cmd (const char *who, const char *msg, ...);
extern int vctrl_cmd(); extern int vctrl_cmd ();
extern int ssvinfo_cmd(); extern int ssvinfo_cmd ();
extern int sburst_cmd(int b); extern int sburst_cmd (int b);
extern int seob_cmd(const char *server); extern int seob_cmd (const char *server);
extern int sakill_cmd(const char *host, const char *ident, const char *setby, const int length, const char *reason,...); extern int sakill_cmd (const char *host, const char *ident, const char *setby, const int length, const char *reason, ...);
extern int srakill_cmd(const char *host, const char *ident); extern int srakill_cmd (const char *host, const char *ident);
void Usr_Version(char *, char **, int argc); void Usr_Version (char *, char **, int argc);
void Usr_ShowMOTD(char *, char **, int argc); void Usr_ShowMOTD (char *, char **, int argc);
void Usr_ShowADMIN(char *, char **, int argc); void Usr_ShowADMIN (char *, char **, int argc);
void Usr_Showcredits(char *, char **, int argc); void Usr_Showcredits (char *, char **, int argc);
void Usr_AddServer(char *, char **, int argc); void Usr_AddServer (char *, char **, int argc);
void Usr_DelServer(char *, char **, int argc); void Usr_DelServer (char *, char **, int argc);
void Usr_DelUser(char *, char **, int argc); void Usr_DelUser (char *, char **, int argc);
void Usr_Mode(char *, char **, int argc); void Usr_Mode (char *, char **, int argc);
void Usr_Smode(char *, char **, int argc); void Usr_Smode (char *, char **, int argc);
void Usr_Kill(char *, char **, int argc); void Usr_Kill (char *, char **, int argc);
void Usr_Pong(char *, char **, int argc); void Usr_Pong (char *, char **, int argc);
void Usr_Away(char *, char **, int argc); void Usr_Away (char *, char **, int argc);
void Usr_Nick(char *, char **, int argc); void Usr_Nick (char *, char **, int argc);
void Usr_Topic(char *, char **, int argc); void Usr_Topic (char *, char **, int argc);
void Usr_Kick(char *, char **, int argc); void Usr_Kick (char *, char **, int argc);
void Usr_Join(char *, char **, int argc); void Usr_Join (char *, char **, int argc);
void Usr_Part(char *, char **, int argc); void Usr_Part (char *, char **, int argc);
void Usr_Stats(char *, char **, int argc); void Usr_Stats (char *, char **, int argc);
void Usr_Vhost(char *, char **, int argc); void Usr_Vhost (char *, char **, int argc);
void Srv_Topic(char *, char **, int argc); void Srv_Topic (char *, char **, int argc);
void Srv_Ping(char *, char **, int argc); void Srv_Ping (char *, char **, int argc);
void Srv_Netinfo(char *, char **, int argc); void Srv_Netinfo (char *, char **, int argc);
void Srv_Pass(char *, char **, int argc); void Srv_Pass (char *, char **, int argc);
void Srv_Server(char *, char **, int argc); void Srv_Server (char *, char **, int argc);
void Srv_Squit(char *, char **, int argc); void Srv_Squit (char *, char **, int argc);
void Srv_Nick(char *, char **, int argc); void Srv_Nick (char *, char **, int argc);
void Srv_Svsnick(char *, char **, int argc); void Srv_Svsnick (char *, char **, int argc);
void Srv_Kill(char *, char **, int argc); void Srv_Kill (char *, char **, int argc);
void Srv_Connect(char *, char **, int argc); void Srv_Connect (char *, char **, int argc);
void Srv_Svinfo(char *, char **, int argc); void Srv_Svinfo (char *, char **, int argc);
void Srv_Burst(char *origin, char **argv, int argc); void Srv_Burst (char *origin, char **argv, int argc);
void Srv_Sjoin(char *origin, char **argv, int argc); void Srv_Sjoin (char *origin, char **argv, int argc);
void Srv_Tburst(char *origin, char **argv, int argc); void Srv_Tburst (char *origin, char **argv, int argc);
int SignOn_NewBot(const char *, const char *, const char *, const char *, long); int SignOn_NewBot (const char *, const char *, const char *, const char *, long);
#endif #endif

File diff suppressed because it is too large Load diff

View file

@ -20,7 +20,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: QuantumIRCd.h,v 1.3 2003/07/23 10:35:47 fishwaldo Exp $ ** $Id: QuantumIRCd.h,v 1.4 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
#ifndef QUANTUM_H #ifndef QUANTUM_H
#define QUANTUM_H #define QUANTUM_H
@ -33,285 +33,285 @@
#define MSG_PRIVATE "PRIVMSG" /* PRIV */ #define MSG_PRIVATE "PRIVMSG" /* PRIV */
#define TOK_PRIVATE "!" /* 33 */ #define TOK_PRIVATE "!" /* 33 */
#define MSG_WHO "WHO" /* WHO -> WHOC */ #define MSG_WHO "WHO" /* WHO -> WHOC */
#define TOK_WHO "\"" /* 34 */ #define TOK_WHO "\"" /* 34 */
#define MSG_WHOIS "WHOIS" /* WHOI */ #define MSG_WHOIS "WHOIS" /* WHOI */
#define TOK_WHOIS "#" /* 35 */ #define TOK_WHOIS "#" /* 35 */
#define MSG_WHOWAS "WHOWAS" /* WHOW */ #define MSG_WHOWAS "WHOWAS" /* WHOW */
#define TOK_WHOWAS "$" /* 36 */ #define TOK_WHOWAS "$" /* 36 */
#define MSG_USER "USER" /* USER */ #define MSG_USER "USER" /* USER */
#define TOK_USER "%" /* 37 */ #define TOK_USER "%" /* 37 */
#define MSG_NICK "NICK" /* NICK */ #define MSG_NICK "NICK" /* NICK */
#define TOK_NICK "&" /* 38 */ #define TOK_NICK "&" /* 38 */
#define MSG_SERVER "SERVER" /* SERV */ #define MSG_SERVER "SERVER" /* SERV */
#define TOK_SERVER "'" /* 39 */ #define TOK_SERVER "'" /* 39 */
#define MSG_LIST "LIST" /* LIST */ #define MSG_LIST "LIST" /* LIST */
#define TOK_LIST "(" /* 40 */ #define TOK_LIST "(" /* 40 */
#define MSG_TOPIC "TOPIC" /* TOPI */ #define MSG_TOPIC "TOPIC" /* TOPI */
#define TOK_TOPIC ")" /* 41 */ #define TOK_TOPIC ")" /* 41 */
#define MSG_INVITE "INVITE" /* INVI */ #define MSG_INVITE "INVITE" /* INVI */
#define TOK_INVITE "*" /* 42 */ #define TOK_INVITE "*" /* 42 */
#define MSG_VERSION "VERSION" /* VERS */ #define MSG_VERSION "VERSION" /* VERS */
#define TOK_VERSION "+" /* 43 */ #define TOK_VERSION "+" /* 43 */
#define MSG_QUIT "QUIT" /* QUIT */ #define MSG_QUIT "QUIT" /* QUIT */
#define TOK_QUIT "," /* 44 */ #define TOK_QUIT "," /* 44 */
#define MSG_SQUIT "SQUIT" /* SQUI */ #define MSG_SQUIT "SQUIT" /* SQUI */
#define TOK_SQUIT "-" /* 45 */ #define TOK_SQUIT "-" /* 45 */
#define MSG_KILL "KILL" /* KILL */ #define MSG_KILL "KILL" /* KILL */
#define TOK_KILL "." /* 46 */ #define TOK_KILL "." /* 46 */
#define MSG_INFO "INFO" /* INFO */ #define MSG_INFO "INFO" /* INFO */
#define TOK_INFO "/" /* 47 */ #define TOK_INFO "/" /* 47 */
#define MSG_LINKS "LINKS" /* LINK */ #define MSG_LINKS "LINKS" /* LINK */
#define TOK_LINKS "0" /* 48 */ #define TOK_LINKS "0" /* 48 */
#define MSG_WATCH "WATCH" /* WATCH */ #define MSG_WATCH "WATCH" /* WATCH */
#define TOK_WATCH "1" /* 49 */ #define TOK_WATCH "1" /* 49 */
#define MSG_STATS "STATS" /* STAT */ #define MSG_STATS "STATS" /* STAT */
#define TOK_STATS "2" /* 50 */ #define TOK_STATS "2" /* 50 */
#define MSG_HELP "HELP" /* HELP */ #define MSG_HELP "HELP" /* HELP */
#define MSG_HELPOP "HELPOP" /* HELP */ #define MSG_HELPOP "HELPOP" /* HELP */
#define TOK_HELP "4" /* 52 */ #define TOK_HELP "4" /* 52 */
#define MSG_ERROR "ERROR" /* ERRO */ #define MSG_ERROR "ERROR" /* ERRO */
#define TOK_ERROR "5" /* 53 */ #define TOK_ERROR "5" /* 53 */
#define MSG_AWAY "AWAY" /* AWAY */ #define MSG_AWAY "AWAY" /* AWAY */
#define TOK_AWAY "6" /* 54 */ #define TOK_AWAY "6" /* 54 */
#define MSG_CONNECT "CONNECT" /* CONN */ #define MSG_CONNECT "CONNECT" /* CONN */
#define TOK_CONNECT "7" /* 55 */ #define TOK_CONNECT "7" /* 55 */
#define MSG_PING "PING" /* PING */ #define MSG_PING "PING" /* PING */
#define TOK_PING "8" /* 56 */ #define TOK_PING "8" /* 56 */
#define MSG_PONG "PONG" /* PONG */ #define MSG_PONG "PONG" /* PONG */
#define TOK_PONG "9" /* 57 */ #define TOK_PONG "9" /* 57 */
#define MSG_OPER "OPER" /* OPER */ #define MSG_OPER "OPER" /* OPER */
#define TOK_OPER ";" /* 59 */ #define TOK_OPER ";" /* 59 */
#define MSG_PASS "PASS" /* PASS */ #define MSG_PASS "PASS" /* PASS */
#define TOK_PASS "<" /* 60 */ #define TOK_PASS "<" /* 60 */
#define MSG_WALLOPS "WALLOPS" /* WALL */ #define MSG_WALLOPS "WALLOPS" /* WALL */
#define TOK_WALLOPS "=" /* 61 */ #define TOK_WALLOPS "=" /* 61 */
#define MSG_TIME "TIME" /* TIME */ #define MSG_TIME "TIME" /* TIME */
#define TOK_TIME ">" /* 62 */ #define TOK_TIME ">" /* 62 */
#define MSG_NAMES "NAMES" /* NAME */ #define MSG_NAMES "NAMES" /* NAME */
#define TOK_NAMES "?" /* 63 */ #define TOK_NAMES "?" /* 63 */
#define MSG_ADMIN "ADMIN" /* ADMI */ #define MSG_ADMIN "ADMIN" /* ADMI */
#define TOK_ADMIN "@" /* 64 */ #define TOK_ADMIN "@" /* 64 */
#define MSG_NOTICE "NOTICE" /* NOTI */ #define MSG_NOTICE "NOTICE" /* NOTI */
#define TOK_NOTICE "B" /* 66 */ #define TOK_NOTICE "B" /* 66 */
#define MSG_JOIN "JOIN" /* JOIN */ #define MSG_JOIN "JOIN" /* JOIN */
#define TOK_JOIN "C" /* 67 */ #define TOK_JOIN "C" /* 67 */
#define MSG_PART "PART" /* PART */ #define MSG_PART "PART" /* PART */
#define TOK_PART "D" /* 68 */ #define TOK_PART "D" /* 68 */
#define MSG_LUSERS "LUSERS" /* LUSE */ #define MSG_LUSERS "LUSERS" /* LUSE */
#define TOK_LUSERS "E" /* 69 */ #define TOK_LUSERS "E" /* 69 */
#define MSG_MOTD "MOTD" /* MOTD */ #define MSG_MOTD "MOTD" /* MOTD */
#define TOK_MOTD "F" /* 70 */ #define TOK_MOTD "F" /* 70 */
#define MSG_MODE "MODE" /* MODE */ #define MSG_MODE "MODE" /* MODE */
#define TOK_MODE "G" /* 71 */ #define TOK_MODE "G" /* 71 */
#define MSG_KICK "KICK" /* KICK */ #define MSG_KICK "KICK" /* KICK */
#define TOK_KICK "H" /* 72 */ #define TOK_KICK "H" /* 72 */
#define MSG_SERVICE "SERVICE" /* SERV -> SRVI */ #define MSG_SERVICE "SERVICE" /* SERV -> SRVI */
#define TOK_SERVICE "I" /* 73 */ #define TOK_SERVICE "I" /* 73 */
#define MSG_USERHOST "USERHOST" /* USER -> USRH */ #define MSG_USERHOST "USERHOST" /* USER -> USRH */
#define TOK_USERHOST "J" /* 74 */ #define TOK_USERHOST "J" /* 74 */
#define MSG_ISON "ISON" /* ISON */ #define MSG_ISON "ISON" /* ISON */
#define TOK_ISON "K" /* 75 */ #define TOK_ISON "K" /* 75 */
#define MSG_SQUERY "SQUERY" /* SQUE */ #define MSG_SQUERY "SQUERY" /* SQUE */
#define TOK_SQUERY "L" /* 76 */ #define TOK_SQUERY "L" /* 76 */
#define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */ #define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */
#define TOK_SERVLIST "M" /* 77 */ #define TOK_SERVLIST "M" /* 77 */
#define MSG_SERVSET "SERVSET" /* SERV -> SSET */ #define MSG_SERVSET "SERVSET" /* SERV -> SSET */
#define TOK_SERVSET "N" /* 78 */ #define TOK_SERVSET "N" /* 78 */
#define MSG_REHASH "REHASH" /* REHA */ #define MSG_REHASH "REHASH" /* REHA */
#define TOK_REHASH "O" /* 79 */ #define TOK_REHASH "O" /* 79 */
#define MSG_RESTART "RESTART" /* REST */ #define MSG_RESTART "RESTART" /* REST */
#define TOK_RESTART "P" /* 80 */ #define TOK_RESTART "P" /* 80 */
#define MSG_CLOSE "CLOSE" /* CLOS */ #define MSG_CLOSE "CLOSE" /* CLOS */
#define TOK_CLOSE "Q" /* 81 */ #define TOK_CLOSE "Q" /* 81 */
#define MSG_DIE "DIE" /* DIE */ #define MSG_DIE "DIE" /* DIE */
#define TOK_DIE "R" /* 82 */ #define TOK_DIE "R" /* 82 */
#define MSG_HASH "HASH" /* HASH */ #define MSG_HASH "HASH" /* HASH */
#define TOK_HASH "S" /* 83 */ #define TOK_HASH "S" /* 83 */
#define MSG_DNS "DNS" /* DNS -> DNSS */ #define MSG_DNS "DNS" /* DNS -> DNSS */
#define TOK_DNS "T" /* 84 */ #define TOK_DNS "T" /* 84 */
#define MSG_SILENCE "SILENCE" /* SILE */ #define MSG_SILENCE "SILENCE" /* SILE */
#define TOK_SILENCE "U" /* 85 */ #define TOK_SILENCE "U" /* 85 */
#define MSG_AKILL "AKILL" /* AKILL */ #define MSG_AKILL "AKILL" /* AKILL */
#define TOK_AKILL "V" /* 86 */ #define TOK_AKILL "V" /* 86 */
#define MSG_KLINE "KLINE" /* KLINE */ #define MSG_KLINE "KLINE" /* KLINE */
#define TOK_KLINE "W" /* 87 */ #define TOK_KLINE "W" /* 87 */
#define MSG_UNKLINE "UNKLINE" /* UNKLINE */ #define MSG_UNKLINE "UNKLINE" /* UNKLINE */
#define TOK_UNKLINE "X" /* 88 */ #define TOK_UNKLINE "X" /* 88 */
#define MSG_RAKILL "RAKILL" /* RAKILL */ #define MSG_RAKILL "RAKILL" /* RAKILL */
#define TOK_RAKILL "Y" /* 89 */ #define TOK_RAKILL "Y" /* 89 */
#define MSG_GNOTICE "GNOTICE" /* GNOTICE */ #define MSG_GNOTICE "GNOTICE" /* GNOTICE */
#define TOK_GNOTICE "Z" /* 90 */ #define TOK_GNOTICE "Z" /* 90 */
#define MSG_GOPER "GOPER" /* GOPER */ #define MSG_GOPER "GOPER" /* GOPER */
#define TOK_GOPER "[" /* 91 */ #define TOK_GOPER "[" /* 91 */
#define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */ #define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */
#define TOK_GLOBOPS "]" /* 93 */ #define TOK_GLOBOPS "]" /* 93 */
#define MSG_LOCOPS "LOCOPS" /* LOCOPS */ #define MSG_LOCOPS "LOCOPS" /* LOCOPS */
#define TOK_LOCOPS "^" /* 94 */ #define TOK_LOCOPS "^" /* 94 */
#define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */ #define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */
#define TOK_PROTOCTL "_" /* 95 */ #define TOK_PROTOCTL "_" /* 95 */
#define MSG_TRACE "TRACE" /* TRAC */ #define MSG_TRACE "TRACE" /* TRAC */
#define TOK_TRACE "b" /* 98 */ #define TOK_TRACE "b" /* 98 */
#define MSG_SQLINE "SQLINE" /* SQLINE */ #define MSG_SQLINE "SQLINE" /* SQLINE */
#define TOK_SQLINE "c" /* 99 */ #define TOK_SQLINE "c" /* 99 */
#define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */ #define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */
#define TOK_UNSQLINE "d" /* 100 */ #define TOK_UNSQLINE "d" /* 100 */
#define MSG_SVSNICK "SVSNICK" /* SVSNICK */ #define MSG_SVSNICK "SVSNICK" /* SVSNICK */
#define TOK_SVSNICK "e" /* 101 */ #define TOK_SVSNICK "e" /* 101 */
#define MSG_SVSNOOP "SVSNOOP" /* SVSNOOP */ #define MSG_SVSNOOP "SVSNOOP" /* SVSNOOP */
#define TOK_SVSNOOP "f" /* 101 */ #define TOK_SVSNOOP "f" /* 101 */
#define MSG_IDENTIFY "IDENTIFY" /* IDENTIFY */ #define MSG_IDENTIFY "IDENTIFY" /* IDENTIFY */
#define TOK_IDENTIFY "g" /* 103 */ #define TOK_IDENTIFY "g" /* 103 */
#define MSG_SVSKILL "SVSKILL" /* SVSKILL */ #define MSG_SVSKILL "SVSKILL" /* SVSKILL */
#define TOK_SVSKILL "h" /* 104 */ #define TOK_SVSKILL "h" /* 104 */
#define MSG_NICKSERV "NICKSERV" /* NICKSERV */ #define MSG_NICKSERV "NICKSERV" /* NICKSERV */
#define MSG_NS "NS" #define MSG_NS "NS"
#define TOK_NICKSERV "i" /* 105 */ #define TOK_NICKSERV "i" /* 105 */
#define MSG_CHANSERV "CHANSERV" /* CHANSERV */ #define MSG_CHANSERV "CHANSERV" /* CHANSERV */
#define MSG_CS "CS" #define MSG_CS "CS"
#define TOK_CHANSERV "j" /* 106 */ #define TOK_CHANSERV "j" /* 106 */
#define MSG_OPERSERV "OPERSERV" /* OPERSERV */ #define MSG_OPERSERV "OPERSERV" /* OPERSERV */
#define MSG_OS "OS" #define MSG_OS "OS"
#define TOK_OPERSERV "k" /* 107 */ #define TOK_OPERSERV "k" /* 107 */
#define MSG_MEMOSERV "MEMOSERV" /* MEMOSERV */ #define MSG_MEMOSERV "MEMOSERV" /* MEMOSERV */
#define MSG_MS "MS" #define MSG_MS "MS"
#define TOK_MEMOSERV "l" /* 108 */ #define TOK_MEMOSERV "l" /* 108 */
#define MSG_SERVICES "SERVICES" /* SERVICES */ #define MSG_SERVICES "SERVICES" /* SERVICES */
#define TOK_SERVICES "m" /* 109 */ #define TOK_SERVICES "m" /* 109 */
#define MSG_SVSMODE "SVSMODE" /* SVSMODE */ #define MSG_SVSMODE "SVSMODE" /* SVSMODE */
#define TOK_SVSMODE "n" /* 110 */ #define TOK_SVSMODE "n" /* 110 */
#define MSG_SAMODE "SAMODE" /* SAMODE */ #define MSG_SAMODE "SAMODE" /* SAMODE */
#define TOK_SAMODE "o" /* 111 */ #define TOK_SAMODE "o" /* 111 */
#define MSG_CHATOPS "CHATOPS" /* CHATOPS */ #define MSG_CHATOPS "CHATOPS" /* CHATOPS */
#define TOK_CHATOPS "p" /* 112 */ #define TOK_CHATOPS "p" /* 112 */
#define MSG_HELPSERV "HELPSERV" /* HELPSERV */ #define MSG_HELPSERV "HELPSERV" /* HELPSERV */
#define TOK_HELPSERV "r" /* 114 */ #define TOK_HELPSERV "r" /* 114 */
#define MSG_ZLINE "ZLINE" /* ZLINE */ #define MSG_ZLINE "ZLINE" /* ZLINE */
#define TOK_ZLINE "s" /* 115 */ #define TOK_ZLINE "s" /* 115 */
#define MSG_UNZLINE "UNZLINE" /* UNZLINE */ #define MSG_UNZLINE "UNZLINE" /* UNZLINE */
#define TOK_UNZLINE "t" /* 116 */ #define TOK_UNZLINE "t" /* 116 */
#define MSG_NETINFO "NETINFO" /* NETINFO */ #define MSG_NETINFO "NETINFO" /* NETINFO */
#define TOK_NETINFO "u" /* 117 */ #define TOK_NETINFO "u" /* 117 */
#define MSG_RULES "RULES" /* RULES */ #define MSG_RULES "RULES" /* RULES */
#define TOK_RULES "v" /* 118 */ #define TOK_RULES "v" /* 118 */
#define MSG_MAP "MAP" /* MAP */ #define MSG_MAP "MAP" /* MAP */
#define TOK_MAP "w" /* 119 */ #define TOK_MAP "w" /* 119 */
#define MSG_NETG "NETG" /* NETG */ #define MSG_NETG "NETG" /* NETG */
#define TOK_NETG "x" /* 120 */ #define TOK_NETG "x" /* 120 */
#define MSG_ADCHAT "ADCHAT" /* Adchat */ #define MSG_ADCHAT "ADCHAT" /* Adchat */
#define TOK_ADCHAT "y" /* 121 */ #define TOK_ADCHAT "y" /* 121 */
#define MSG_MAKEPASS "MAKEPASS" /* MAKEPASS */ #define MSG_MAKEPASS "MAKEPASS" /* MAKEPASS */
#define TOK_MAKEPASS "z" /* 122 */ #define TOK_MAKEPASS "z" /* 122 */
#define MSG_ADDHUB "ADDHUB" /* ADDHUB */ #define MSG_ADDHUB "ADDHUB" /* ADDHUB */
#define TOK_ADDHUB "{" /* 123 */ #define TOK_ADDHUB "{" /* 123 */
#define MSG_DELHUB "DELHUB" /* DELHUB */ #define MSG_DELHUB "DELHUB" /* DELHUB */
#define TOK_DELHUB "|" /* 124 */ #define TOK_DELHUB "|" /* 124 */
#define MSG_ADDCNLINE "ADDCNLINE" /* ADDCNLINE */ #define MSG_ADDCNLINE "ADDCNLINE" /* ADDCNLINE */
#define TOK_ADDCNLINE "}" /* 125 */ #define TOK_ADDCNLINE "}" /* 125 */
#define MSG_DELCNLINE "DELCNLINE" /* DELCNLINE */ #define MSG_DELCNLINE "DELCNLINE" /* DELCNLINE */
#define TOK_DELCNLINE "~" /* 126 */ #define TOK_DELCNLINE "~" /* 126 */
#define MSG_ADDOPER "ADDOPER" /* ADDOPER */ #define MSG_ADDOPER "ADDOPER" /* ADDOPER */
#define TOK_ADDOPER "" /* 127 */ #define TOK_ADDOPER "" /* 127 */
#define MSG_DELOPER "DELOPER" /* DELOPER */ #define MSG_DELOPER "DELOPER" /* DELOPER */
#define TOK_DELOPER "!!" /* 33 + 33 */ #define TOK_DELOPER "!!" /* 33 + 33 */
#define MSG_ADDQLINE "ADDQLINE" /* ADDQLINE */ #define MSG_ADDQLINE "ADDQLINE" /* ADDQLINE */
#define TOK_ADDQLINE "!\"" /* 33 + 34 */ #define TOK_ADDQLINE "!\"" /* 33 + 34 */
#define MSG_DELQLINE "DELQLINE" /* DELQLINE */ #define MSG_DELQLINE "DELQLINE" /* DELQLINE */
#define TOK_DELQLINE "!#" /* 33 + 35 */ #define TOK_DELQLINE "!#" /* 33 + 35 */
#define MSG_GSOP "GSOP" /* GSOP */ #define MSG_GSOP "GSOP" /* GSOP */
#define TOK_GSOP "!$" /* 33 + 36 */ #define TOK_GSOP "!$" /* 33 + 36 */
#define MSG_ISOPER "ISOPER" /* ISOPER */ #define MSG_ISOPER "ISOPER" /* ISOPER */
#define TOK_ISOPER "!%" /* 33 + 37 */ #define TOK_ISOPER "!%" /* 33 + 37 */
#define MSG_ADG "ADG" /* ADG */ #define MSG_ADG "ADG" /* ADG */
#define TOK_ADG "!&" /* 33 + 38 */ #define TOK_ADG "!&" /* 33 + 38 */
#define MSG_NMON "NMON" /* NMON */ #define MSG_NMON "NMON" /* NMON */
#define TOK_NMON "!'" /* 33 + 39 */ #define TOK_NMON "!'" /* 33 + 39 */
#define MSG_DALINFO "DALINFO" /* DALnet Credits */ #define MSG_DALINFO "DALINFO" /* DALnet Credits */
#define TOK_DALINFO "!(" /* 33 + 40 */ #define TOK_DALINFO "!(" /* 33 + 40 */
#define MSG_CREDITS "CREDITS" /* UltimateIRCd Credits and "Thanks To" */ #define MSG_CREDITS "CREDITS" /* UltimateIRCd Credits and "Thanks To" */
#define TOK_CREDITS "!)" /* 33 + 41 */ #define TOK_CREDITS "!)" /* 33 + 41 */
#define MSG_OPERMOTD "OPERMOTD" /* OPERMOTD */ #define MSG_OPERMOTD "OPERMOTD" /* OPERMOTD */
#define TOK_OPERMOTD "!*" /* 33 + 42 */ #define TOK_OPERMOTD "!*" /* 33 + 42 */
#define MSG_REMREHASH "REMREHASH" /* Remote Rehash */ #define MSG_REMREHASH "REMREHASH" /* Remote Rehash */
#define TOK_REMREHASH "!+" /* 33 + 43 */ #define TOK_REMREHASH "!+" /* 33 + 43 */
#define MSG_MONITOR "MONITOR" /* MONITOR */ #define MSG_MONITOR "MONITOR" /* MONITOR */
#define TOK_MONITOR "!," /* 33 + 44 */ #define TOK_MONITOR "!," /* 33 + 44 */
#define MSG_GLINE "GLINE" /* The awesome g-line */ #define MSG_GLINE "GLINE" /* The awesome g-line */
#define TOK_GLINE "!-" /* 33 + 45 */ #define TOK_GLINE "!-" /* 33 + 45 */
#define MSG_REMGLINE "REMGLINE" /* remove g-line */ #define MSG_REMGLINE "REMGLINE" /* remove g-line */
#define TOK_REMGLINE "!." /* 33 + 46 */ #define TOK_REMGLINE "!." /* 33 + 46 */
#define MSG_STATSERV "STATSERV" /* StatServ */ #define MSG_STATSERV "STATSERV" /* StatServ */
#define TOK_STATSERV "!/" /* 33 + 47 */ #define TOK_STATSERV "!/" /* 33 + 47 */
#define MSG_RULESERV "RULESERV" /* RuleServ */ #define MSG_RULESERV "RULESERV" /* RuleServ */
#define TOK_RULESERV "!0" /* 33 + 48 */ #define TOK_RULESERV "!0" /* 33 + 48 */
#define MSG_SNETINFO "SNETINFO" /* SNetInfo */ #define MSG_SNETINFO "SNETINFO" /* SNetInfo */
#define TOK_SNETINFO "!1" /* 33 + 49 */ #define TOK_SNETINFO "!1" /* 33 + 49 */
#define MSG_TSCTL "TSCTL" /* TSCTL */ #define MSG_TSCTL "TSCTL" /* TSCTL */
#define TOK_TSCTL "!3" /* 33 + 51 */ #define TOK_TSCTL "!3" /* 33 + 51 */
#define MSG_SVSJOIN "SVSJOIN" /* SVSJOIN */ #define MSG_SVSJOIN "SVSJOIN" /* SVSJOIN */
#define TOK_SVSJOIN "!4" /* 33 + 52 */ #define TOK_SVSJOIN "!4" /* 33 + 52 */
#define MSG_SAJOIN "SAJOIN" /* SAJOIN */ #define MSG_SAJOIN "SAJOIN" /* SAJOIN */
#define TOK_SAJOIN "!5" /* 33 + 53 */ #define TOK_SAJOIN "!5" /* 33 + 53 */
#define MSG_SDESC "SDESC" /* SDESC */ #define MSG_SDESC "SDESC" /* SDESC */
#define TOK_SDESC "!6" /* 33 + 54 */ #define TOK_SDESC "!6" /* 33 + 54 */
#define MSG_UNREALINFO "UNREALINFO" /* Unreal Info */ #define MSG_UNREALINFO "UNREALINFO" /* Unreal Info */
#define TOK_UNREALINFO "!7" /* 33 + 55 */ #define TOK_UNREALINFO "!7" /* 33 + 55 */
#define MSG_SETHOST "SETHOST" /* sethost */ #define MSG_SETHOST "SETHOST" /* sethost */
#define TOK_SETHOST "!8" /* 33 + 56 */ #define TOK_SETHOST "!8" /* 33 + 56 */
#define MSG_SETIDENT "SETIDENT" /* set ident */ #define MSG_SETIDENT "SETIDENT" /* set ident */
#define TOK_SETIDENT "!9" /* 33 + 57 */ #define TOK_SETIDENT "!9" /* 33 + 57 */
#define MSG_SETNAME "SETNAME" /* set Realname */ #define MSG_SETNAME "SETNAME" /* set Realname */
#define TOK_SETNAME "!;" /* 33 + 59 */ #define TOK_SETNAME "!;" /* 33 + 59 */
#define MSG_CHGHOST "CHGHOST" /* Changehost */ #define MSG_CHGHOST "CHGHOST" /* Changehost */
#define TOK_CHGHOST "!<" /* 33 + 60 */ #define TOK_CHGHOST "!<" /* 33 + 60 */
#define MSG_CHGIDENT "CHGIDENT" /* Change Ident */ #define MSG_CHGIDENT "CHGIDENT" /* Change Ident */
#define TOK_CHGIDENT "!=" /* 33 + 61 */ #define TOK_CHGIDENT "!=" /* 33 + 61 */
#define MSG_RANDQUOTE "RANDQUOTE" /* Random Quote */ #define MSG_RANDQUOTE "RANDQUOTE" /* Random Quote */
#define TOK_RANDQUOTE "!>" /* 33 + 62 */ #define TOK_RANDQUOTE "!>" /* 33 + 62 */
#define MSG_ADDQUOTE "ADDQUOTE" /* Add Quote */ #define MSG_ADDQUOTE "ADDQUOTE" /* Add Quote */
#define TOK_ADDQUOTE "!?" /* 33 + 63 */ #define TOK_ADDQUOTE "!?" /* 33 + 63 */
#define MSG_ADDGQUOTE "ADDGQUOTE" /* Add Global Quote */ #define MSG_ADDGQUOTE "ADDGQUOTE" /* Add Global Quote */
#define TOK_ADDGQUOTE "!@" /* 33 + 64 */ #define TOK_ADDGQUOTE "!@" /* 33 + 64 */
#define MSG_ADDULINE "ADDULINE" /* Adds an U Line to ircd.conf file */ #define MSG_ADDULINE "ADDULINE" /* Adds an U Line to ircd.conf file */
#define TOK_ADDULINE "!B" /* 33 + 66 */ #define TOK_ADDULINE "!B" /* 33 + 66 */
#define MSG_DELULINE "DELULINE" /* Removes an U line from the ircd.conf */ #define MSG_DELULINE "DELULINE" /* Removes an U line from the ircd.conf */
#define TOK_DELULINE "!C" /* 33 + 67 */ #define TOK_DELULINE "!C" /* 33 + 67 */
#define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */ #define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */
#define TOK_KNOCK "!D" /* 33 + 68 */ #define TOK_KNOCK "!D" /* 33 + 68 */
#define MSG_SETTINGS "SETTINGS" /* Settings */ #define MSG_SETTINGS "SETTINGS" /* Settings */
#define TOK_SETTINGS "!E" /* 33 + 69 */ #define TOK_SETTINGS "!E" /* 33 + 69 */
#define MSG_IRCOPS "IRCOPS" /* Shows Online IRCOps */ #define MSG_IRCOPS "IRCOPS" /* Shows Online IRCOps */
#define TOK_IRCOPS "!F" /* 33 + 70 */ #define TOK_IRCOPS "!F" /* 33 + 70 */
#define MSG_SVSPART "SVSPART" /* SVSPART */ #define MSG_SVSPART "SVSPART" /* SVSPART */
#define TOK_SVSPART "!G" /* 33 + 71 */ #define TOK_SVSPART "!G" /* 33 + 71 */
#define MSG_SAPART "SAPART" /* SAPART */ #define MSG_SAPART "SAPART" /* SAPART */
#define TOK_SAPART "!H" /* 33 + 72 */ #define TOK_SAPART "!H" /* 33 + 72 */
#define MSG_VCTRL "VCTRL" /* VCTRL */ #define MSG_VCTRL "VCTRL" /* VCTRL */
#define TOK_VCTRL "!I" /* 33 + 73 */ #define TOK_VCTRL "!I" /* 33 + 73 */
#define MSG_GCLIENT "GCLIENT" /* GLIENT */ #define MSG_GCLIENT "GCLIENT" /* GLIENT */
#define TOK_GCLIENT "!J" /* 33 + 74 */ #define TOK_GCLIENT "!J" /* 33 + 74 */
#define MSG_CHANNEL "CHANNEL" /* CHANNEL */ #define MSG_CHANNEL "CHANNEL" /* CHANNEL */
#define TOK_CHANNEL "!K" /* 33 + 75 */ #define TOK_CHANNEL "!K" /* 33 + 75 */
#define MSG_UPTIME "UPTIME" /* UPTIME */ #define MSG_UPTIME "UPTIME" /* UPTIME */
#define TOK_UPTIME "!L" /* 33 + 76 */ #define TOK_UPTIME "!L" /* 33 + 76 */
#define MSG_FAILOPS "FAILOPS" /* FAILOPS */ #define MSG_FAILOPS "FAILOPS" /* FAILOPS */
#define TOK_FAILOPS "!M" /* 33 + 77 */ #define TOK_FAILOPS "!M" /* 33 + 77 */
#define MSG_RPING "RPING" /* RPING */ #define MSG_RPING "RPING" /* RPING */
#define TOK_RPING "!P" /* 33 + 80 */ #define TOK_RPING "!P" /* 33 + 80 */
#define MSG_RPONG "RPONG" /* RPONG */ #define MSG_RPONG "RPONG" /* RPONG */
#define TOK_RPONG "!Q" /* 33 + 81 */ #define TOK_RPONG "!Q" /* 33 + 81 */
#define MSG_UPING "UPING" /* UPING */ #define MSG_UPING "UPING" /* UPING */
#define TOK_UPING "!R" /* 33 + 82 */ #define TOK_UPING "!R" /* 33 + 82 */
#define MSG_COPYRIGHT "COPYRIGHT" /* Copyright */ #define MSG_COPYRIGHT "COPYRIGHT" /* Copyright */
#define TOK_COPYRIGHT "!S" /* 33 + 83 */ #define TOK_COPYRIGHT "!S" /* 33 + 83 */
#define MSG_BOTSERV "BOTSERV" /* BOTSERV */ #define MSG_BOTSERV "BOTSERV" /* BOTSERV */
#define MSG_BS "BS" #define MSG_BS "BS"
#define TOK_BOTSERV "!T" /* 33 + 84 */ #define TOK_BOTSERV "!T" /* 33 + 84 */
#define MSG_ROOTSERV "ROOTSERV" /* ROOTSERV */ #define MSG_ROOTSERV "ROOTSERV" /* ROOTSERV */
#define MSG_RS "RS" #define MSG_RS "RS"
#define TOK_ROOTSERV "!U" /* 33 + 85 */ #define TOK_ROOTSERV "!U" /* 33 + 85 */
#define MSG_SVINFO "SVINFO" #define MSG_SVINFO "SVINFO"
#define MSG_CAPAB "CAPAB" #define MSG_CAPAB "CAPAB"
#define MSG_BURST "BURST" #define MSG_BURST "BURST"
@ -321,46 +321,46 @@
#define UMODE_INVISIBLE 0x0001 /* makes user invisible */ #define UMODE_INVISIBLE 0x0001 /* makes user invisible */
#define UMODE_OPER 0x0002 /* Operator */ #define UMODE_OPER 0x0002 /* Operator */
#define UMODE_WALLOP 0x0004 /* send wallops to them */ #define UMODE_WALLOP 0x0004 /* send wallops to them */
#define UMODE_FAILOP 0x0008 /* Shows some global messages */ #define UMODE_FAILOP 0x0008 /* Shows some global messages */
#define UMODE_HELPOP 0x0010 /* Help system operator */ #define UMODE_HELPOP 0x0010 /* Help system operator */
#define UMODE_REGNICK 0x0020 /* Nick set by services as registered */ #define UMODE_REGNICK 0x0020 /* Nick set by services as registered */
#define UMODE_SERVICESOPER 0x0040 /* Services Oper */ #define UMODE_SERVICESOPER 0x0040 /* Services Oper */
#define UMODE_SPY 0x0080 /* Oper Spy */ #define UMODE_SPY 0x0080 /* Oper Spy */
#define UMODE_DCC 0x10000 /* Oper DCC Notices */ #define UMODE_DCC 0x10000 /* Oper DCC Notices */
#define UMODE_GLOBOPS 0x20000 /* send/recv global notices */ #define UMODE_GLOBOPS 0x20000 /* send/recv global notices */
#define UMODE_REJ 0x40000 /* see DCC reject notices */ #define UMODE_REJ 0x40000 /* see DCC reject notices */
#define UMODE_ROUTE 0x80000 /* see Routing Notices */ #define UMODE_ROUTE 0x80000 /* see Routing Notices */
#define UMODE_SPAM 0x100000 /* see spambot warnings */ #define UMODE_SPAM 0x100000 /* see spambot warnings */
#define UMODE_PROT 0x400000 /* protected IRC op */ #define UMODE_PROT 0x400000 /* protected IRC op */
#define UMODE_GLOBCON 0x800000 /* Global Connect notices */ #define UMODE_GLOBCON 0x800000 /* Global Connect notices */
#define UMODE_DEBUG 0x4000000 /* see debug notices */ #define UMODE_DEBUG 0x4000000 /* see debug notices */
#define UMODE_DCCWARN 0x8000000 /* see DCC warnings */ #define UMODE_DCCWARN 0x8000000 /* see DCC warnings */
#define UMODE_SERVNOTICE 0x0100 /* server notices such as kill */ #define UMODE_SERVNOTICE 0x0100 /* server notices such as kill */
#define UMODE_LOCOP 0x0200 /* Local operator -- SRB */ #define UMODE_LOCOP 0x0200 /* Local operator -- SRB */
#define UMODE_KILLS 0x0400 /* Show server-kills... */ #define UMODE_KILLS 0x0400 /* Show server-kills... */
#define UMODE_CLIENT 0x0800 /* Show client information */ #define UMODE_CLIENT 0x0800 /* Show client information */
#define UMODE_FLOOD 0x1000 /* Receive flood warnings */ #define UMODE_FLOOD 0x1000 /* Receive flood warnings */
#define UMODE_CHATOP 0x2000 /* can receive chatops */ #define UMODE_CHATOP 0x2000 /* can receive chatops */
#define UMODE_SERVICES 0x4000 /* services */ #define UMODE_SERVICES 0x4000 /* services */
#define UMODE_HIDE 0x8000 /* Hide from Nukes */ #define UMODE_HIDE 0x8000 /* Hide from Nukes */
#define UMODE_WHOIS 0x200000 /* Lets Opers see when people do a /WhoIs on them */ #define UMODE_WHOIS 0x200000 /* Lets Opers see when people do a /WhoIs on them */
#define UMODE_IRCADMIN 0x1000000 /* Marks the client as an IRC Administrator */ #define UMODE_IRCADMIN 0x1000000 /* Marks the client as an IRC Administrator */
#define UMODE_SERVICESADMIN 0x2000000 /* Marks the client as a Services Administrator */ #define UMODE_SERVICESADMIN 0x2000000 /* Marks the client as a Services Administrator */
#define SMODE_SSL 0x1 /* ssl client */ #define SMODE_SSL 0x1 /* ssl client */
#define SMODE_COADMIN 0x2 /* co admin on a server */ #define SMODE_COADMIN 0x2 /* co admin on a server */
#define SMODE_SERVADMIN 0x4 /* server admin */ #define SMODE_SERVADMIN 0x4 /* server admin */
#define SMODE_COTECH 0x8 /* co-tech admin */ #define SMODE_COTECH 0x8 /* co-tech admin */
#define SMODE_TECHADMIN 0x10 /* tech administrator */ #define SMODE_TECHADMIN 0x10 /* tech administrator */
#define SMODE_CONET 0x20 /* Co-Network Admin */ #define SMODE_CONET 0x20 /* Co-Network Admin */
#define SMODE_NETADMIN 0x40 /* Network Admin */ #define SMODE_NETADMIN 0x40 /* Network Admin */
#define SMODE_GUEST 0x80 /* Guest Admin */ #define SMODE_GUEST 0x80 /* Guest Admin */
#define MODE_CHANOP 0x0001 #define MODE_CHANOP 0x0001
@ -410,8 +410,8 @@ struct ircd_srv_ {
typedef struct { typedef struct {
long mode; long mode;
char flag; char flag;
unsigned nickparam : 1; /* 1 = yes 0 = no */ unsigned nickparam:1; /* 1 = yes 0 = no */
unsigned parameters : 1; unsigned parameters:1;
char sjoin; char sjoin;
} aCtab; } aCtab;
@ -433,77 +433,77 @@ Oper_Modes susr_mds[9];
/* function declarations */ /* function declarations */
extern void init_ircd(); extern void init_ircd ();
extern void chanalert(char *,char *, ...); extern void chanalert (char *, char *, ...);
extern int sserver_cmd(const char *, const int numeric, const char *); extern int sserver_cmd (const char *, const int numeric, const char *);
extern int slogin_cmd(const char *, const int numeric, const char *, const char *); extern int slogin_cmd (const char *, const int numeric, const char *, const char *);
extern int ssquit_cmd(const char *); extern int ssquit_cmd (const char *);
extern int sprotocol_cmd(const char *); extern int sprotocol_cmd (const char *);
extern int squit_cmd(const char *, const char *); extern int squit_cmd (const char *, const char *);
extern int spart_cmd(const char *, const char *); extern int spart_cmd (const char *, const char *);
extern int sjoin_cmd(const char *, const char *, unsigned long flag); extern int sjoin_cmd (const char *, const char *, unsigned long flag);
extern int schmode_cmd(const char *, const char *, const char *, const char *); extern int schmode_cmd (const char *, const char *, const char *, const char *);
extern int snewnick_cmd(const char *, const char *, const char *, const char *, long mode); extern int snewnick_cmd (const char *, const char *, const char *, const char *, long mode);
extern int sping_cmd(const char *from, const char *reply, const char *to); extern int sping_cmd (const char *from, const char *reply, const char *to);
extern int sumode_cmd(const char *who, const char *target, long mode); extern int sumode_cmd (const char *who, const char *target, long mode);
extern int snumeric_cmd(const int numeric, const char *target, const char *data,...); extern int snumeric_cmd (const int numeric, const char *target, const char *data, ...);
extern int spong_cmd(const char *reply); extern int spong_cmd (const char *reply);
extern int snetinfo_cmd(); extern int snetinfo_cmd ();
extern int skill_cmd(const char *from, const char *target, const char *reason,...); extern int skill_cmd (const char *from, const char *target, const char *reason, ...);
extern int ssmo_cmd(const char *from, const char *umodetarget, const char *msg); extern int ssmo_cmd (const char *from, const char *umodetarget, const char *msg);
extern int snick_cmd(const char *oldnick, const char *newnick); extern int snick_cmd (const char *oldnick, const char *newnick);
extern int sswhois_cmd(const char *target, const char *swhois); extern int sswhois_cmd (const char *target, const char *swhois);
extern int ssvsnick_cmd(const char *target, const char *newnick); extern int ssvsnick_cmd (const char *target, const char *newnick);
extern int ssvsjoin_cmd(const char *target, const char *chan); extern int ssvsjoin_cmd (const char *target, const char *chan);
extern int ssvspart_cmd(const char *target, const char *chan); extern int ssvspart_cmd (const char *target, const char *chan);
extern int ssvshost_cmd(const char *who, const char *vhost); extern int ssvshost_cmd (const char *who, const char *vhost);
extern int skick_cmd(const char *who, const char *target, const char *chan, const char *reason); extern int skick_cmd (const char *who, const char *target, const char *chan, const char *reason);
extern int swallops_cmd(const char *who, const char *msg,...); extern int swallops_cmd (const char *who, const char *msg, ...);
extern int vctrl_cmd(); extern int vctrl_cmd ();
extern int ssvinfo_cmd(); extern int ssvinfo_cmd ();
extern int sburst_cmd(int b); extern int sburst_cmd (int b);
extern int sakill_cmd(const char *host, const char *ident, const char *setby, const int length, const char *reason,...); extern int sakill_cmd (const char *host, const char *ident, const char *setby, const int length, const char *reason, ...);
extern int srakill_cmd(const char *host, const char *ident); extern int srakill_cmd (const char *host, const char *ident);
extern int ssvshost_cmd(const char *who, const char *vhost); extern int ssvshost_cmd (const char *who, const char *vhost);
extern int ssvskill_cmd(const char *who, const char *reason, ...); extern int ssvskill_cmd (const char *who, const char *reason, ...);
void Usr_Version(char *, char **, int argc); void Usr_Version (char *, char **, int argc);
void Usr_ShowMOTD(char *, char **, int argc); void Usr_ShowMOTD (char *, char **, int argc);
void Usr_ShowADMIN(char *, char **, int argc); void Usr_ShowADMIN (char *, char **, int argc);
void Usr_Showcredits(char *, char **, int argc); void Usr_Showcredits (char *, char **, int argc);
void Usr_AddServer(char *, char **, int argc); void Usr_AddServer (char *, char **, int argc);
void Usr_DelServer(char *, char **, int argc); void Usr_DelServer (char *, char **, int argc);
void Usr_DelUser(char *, char **, int argc); void Usr_DelUser (char *, char **, int argc);
void Usr_Mode(char *, char **, int argc); void Usr_Mode (char *, char **, int argc);
void Usr_Smode(char *, char **, int argc); void Usr_Smode (char *, char **, int argc);
void Usr_Kill(char *, char **, int argc); void Usr_Kill (char *, char **, int argc);
void Usr_Pong(char *, char **, int argc); void Usr_Pong (char *, char **, int argc);
void Usr_Away(char *, char **, int argc); void Usr_Away (char *, char **, int argc);
void Usr_Nick(char *, char **, int argc); void Usr_Nick (char *, char **, int argc);
void Usr_Topic(char *, char **, int argc); void Usr_Topic (char *, char **, int argc);
void Usr_Kick(char *, char **, int argc); void Usr_Kick (char *, char **, int argc);
void Usr_Join(char *, char **, int argc); void Usr_Join (char *, char **, int argc);
void Usr_Part(char *, char **, int argc); void Usr_Part (char *, char **, int argc);
void Usr_Stats(char *, char **, int argc); void Usr_Stats (char *, char **, int argc);
void Usr_Vhost(char *, char **, int argc); void Usr_Vhost (char *, char **, int argc);
void Srv_Topic(char *, char **, int argc); void Srv_Topic (char *, char **, int argc);
void Srv_Ping(char *, char **, int argc); void Srv_Ping (char *, char **, int argc);
void Srv_Netinfo(char *, char **, int argc); void Srv_Netinfo (char *, char **, int argc);
void Srv_Pass(char *, char **, int argc); void Srv_Pass (char *, char **, int argc);
void Srv_Server(char *, char **, int argc); void Srv_Server (char *, char **, int argc);
void Srv_Squit(char *, char **, int argc); void Srv_Squit (char *, char **, int argc);
void Srv_Nick(char *, char **, int argc); void Srv_Nick (char *, char **, int argc);
void Srv_Svsnick(char *, char **, int argc); void Srv_Svsnick (char *, char **, int argc);
void Srv_Kill(char *, char **, int argc); void Srv_Kill (char *, char **, int argc);
void Srv_Connect(char *, char **, int argc); void Srv_Connect (char *, char **, int argc);
void Srv_Svinfo(char *, char **, int argc); void Srv_Svinfo (char *, char **, int argc);
void Srv_Burst(char *origin, char **argv, int argc); void Srv_Burst (char *origin, char **argv, int argc);
void Srv_Sjoin(char *origin, char **argv, int argc); void Srv_Sjoin (char *origin, char **argv, int argc);
void Srv_Tburst(char *origin, char **argv, int argc); void Srv_Tburst (char *origin, char **argv, int argc);
void Srv_Vctrl(char *origin, char **argv, int argc); void Srv_Vctrl (char *origin, char **argv, int argc);
void Srv_Client(char *origin, char **argv, int argc); void Srv_Client (char *origin, char **argv, int argc);
void Srv_Smode(char *origin, char **argv, int argc); void Srv_Smode (char *origin, char **argv, int argc);
int SignOn_NewBot(const char *, const char *, const char *, const char *, long); int SignOn_NewBot (const char *, const char *, const char *, const char *, long);
#endif #endif

File diff suppressed because it is too large Load diff

View file

@ -20,7 +20,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: Ultimate.h,v 1.24 2003/07/23 10:35:47 fishwaldo Exp $ ** $Id: Ultimate.h,v 1.25 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
#ifndef ULTIMATE_H #ifndef ULTIMATE_H
#define ULTIMATE_H #define ULTIMATE_H
@ -34,285 +34,285 @@
#define MSG_PRIVATE "PRIVMSG" /* PRIV */ #define MSG_PRIVATE "PRIVMSG" /* PRIV */
#define TOK_PRIVATE "!" /* 33 */ #define TOK_PRIVATE "!" /* 33 */
#define MSG_WHO "WHO" /* WHO -> WHOC */ #define MSG_WHO "WHO" /* WHO -> WHOC */
#define TOK_WHO "\"" /* 34 */ #define TOK_WHO "\"" /* 34 */
#define MSG_WHOIS "WHOIS" /* WHOI */ #define MSG_WHOIS "WHOIS" /* WHOI */
#define TOK_WHOIS "#" /* 35 */ #define TOK_WHOIS "#" /* 35 */
#define MSG_WHOWAS "WHOWAS" /* WHOW */ #define MSG_WHOWAS "WHOWAS" /* WHOW */
#define TOK_WHOWAS "$" /* 36 */ #define TOK_WHOWAS "$" /* 36 */
#define MSG_USER "USER" /* USER */ #define MSG_USER "USER" /* USER */
#define TOK_USER "%" /* 37 */ #define TOK_USER "%" /* 37 */
#define MSG_NICK "NICK" /* NICK */ #define MSG_NICK "NICK" /* NICK */
#define TOK_NICK "&" /* 38 */ #define TOK_NICK "&" /* 38 */
#define MSG_SERVER "SERVER" /* SERV */ #define MSG_SERVER "SERVER" /* SERV */
#define TOK_SERVER "'" /* 39 */ #define TOK_SERVER "'" /* 39 */
#define MSG_LIST "LIST" /* LIST */ #define MSG_LIST "LIST" /* LIST */
#define TOK_LIST "(" /* 40 */ #define TOK_LIST "(" /* 40 */
#define MSG_TOPIC "TOPIC" /* TOPI */ #define MSG_TOPIC "TOPIC" /* TOPI */
#define TOK_TOPIC ")" /* 41 */ #define TOK_TOPIC ")" /* 41 */
#define MSG_INVITE "INVITE" /* INVI */ #define MSG_INVITE "INVITE" /* INVI */
#define TOK_INVITE "*" /* 42 */ #define TOK_INVITE "*" /* 42 */
#define MSG_VERSION "VERSION" /* VERS */ #define MSG_VERSION "VERSION" /* VERS */
#define TOK_VERSION "+" /* 43 */ #define TOK_VERSION "+" /* 43 */
#define MSG_QUIT "QUIT" /* QUIT */ #define MSG_QUIT "QUIT" /* QUIT */
#define TOK_QUIT "," /* 44 */ #define TOK_QUIT "," /* 44 */
#define MSG_SQUIT "SQUIT" /* SQUI */ #define MSG_SQUIT "SQUIT" /* SQUI */
#define TOK_SQUIT "-" /* 45 */ #define TOK_SQUIT "-" /* 45 */
#define MSG_KILL "KILL" /* KILL */ #define MSG_KILL "KILL" /* KILL */
#define TOK_KILL "." /* 46 */ #define TOK_KILL "." /* 46 */
#define MSG_INFO "INFO" /* INFO */ #define MSG_INFO "INFO" /* INFO */
#define TOK_INFO "/" /* 47 */ #define TOK_INFO "/" /* 47 */
#define MSG_LINKS "LINKS" /* LINK */ #define MSG_LINKS "LINKS" /* LINK */
#define TOK_LINKS "0" /* 48 */ #define TOK_LINKS "0" /* 48 */
#define MSG_WATCH "WATCH" /* WATCH */ #define MSG_WATCH "WATCH" /* WATCH */
#define TOK_WATCH "1" /* 49 */ #define TOK_WATCH "1" /* 49 */
#define MSG_STATS "STATS" /* STAT */ #define MSG_STATS "STATS" /* STAT */
#define TOK_STATS "2" /* 50 */ #define TOK_STATS "2" /* 50 */
#define MSG_HELP "HELP" /* HELP */ #define MSG_HELP "HELP" /* HELP */
#define MSG_HELPOP "HELPOP" /* HELP */ #define MSG_HELPOP "HELPOP" /* HELP */
#define TOK_HELP "4" /* 52 */ #define TOK_HELP "4" /* 52 */
#define MSG_ERROR "ERROR" /* ERRO */ #define MSG_ERROR "ERROR" /* ERRO */
#define TOK_ERROR "5" /* 53 */ #define TOK_ERROR "5" /* 53 */
#define MSG_AWAY "AWAY" /* AWAY */ #define MSG_AWAY "AWAY" /* AWAY */
#define TOK_AWAY "6" /* 54 */ #define TOK_AWAY "6" /* 54 */
#define MSG_CONNECT "CONNECT" /* CONN */ #define MSG_CONNECT "CONNECT" /* CONN */
#define TOK_CONNECT "7" /* 55 */ #define TOK_CONNECT "7" /* 55 */
#define MSG_PING "PING" /* PING */ #define MSG_PING "PING" /* PING */
#define TOK_PING "8" /* 56 */ #define TOK_PING "8" /* 56 */
#define MSG_PONG "PONG" /* PONG */ #define MSG_PONG "PONG" /* PONG */
#define TOK_PONG "9" /* 57 */ #define TOK_PONG "9" /* 57 */
#define MSG_OPER "OPER" /* OPER */ #define MSG_OPER "OPER" /* OPER */
#define TOK_OPER ";" /* 59 */ #define TOK_OPER ";" /* 59 */
#define MSG_PASS "PASS" /* PASS */ #define MSG_PASS "PASS" /* PASS */
#define TOK_PASS "<" /* 60 */ #define TOK_PASS "<" /* 60 */
#define MSG_WALLOPS "WALLOPS" /* WALL */ #define MSG_WALLOPS "WALLOPS" /* WALL */
#define TOK_WALLOPS "=" /* 61 */ #define TOK_WALLOPS "=" /* 61 */
#define MSG_TIME "TIME" /* TIME */ #define MSG_TIME "TIME" /* TIME */
#define TOK_TIME ">" /* 62 */ #define TOK_TIME ">" /* 62 */
#define MSG_NAMES "NAMES" /* NAME */ #define MSG_NAMES "NAMES" /* NAME */
#define TOK_NAMES "?" /* 63 */ #define TOK_NAMES "?" /* 63 */
#define MSG_ADMIN "ADMIN" /* ADMI */ #define MSG_ADMIN "ADMIN" /* ADMI */
#define TOK_ADMIN "@" /* 64 */ #define TOK_ADMIN "@" /* 64 */
#define MSG_NOTICE "NOTICE" /* NOTI */ #define MSG_NOTICE "NOTICE" /* NOTI */
#define TOK_NOTICE "B" /* 66 */ #define TOK_NOTICE "B" /* 66 */
#define MSG_JOIN "JOIN" /* JOIN */ #define MSG_JOIN "JOIN" /* JOIN */
#define TOK_JOIN "C" /* 67 */ #define TOK_JOIN "C" /* 67 */
#define MSG_PART "PART" /* PART */ #define MSG_PART "PART" /* PART */
#define TOK_PART "D" /* 68 */ #define TOK_PART "D" /* 68 */
#define MSG_LUSERS "LUSERS" /* LUSE */ #define MSG_LUSERS "LUSERS" /* LUSE */
#define TOK_LUSERS "E" /* 69 */ #define TOK_LUSERS "E" /* 69 */
#define MSG_MOTD "MOTD" /* MOTD */ #define MSG_MOTD "MOTD" /* MOTD */
#define TOK_MOTD "F" /* 70 */ #define TOK_MOTD "F" /* 70 */
#define MSG_MODE "MODE" /* MODE */ #define MSG_MODE "MODE" /* MODE */
#define TOK_MODE "G" /* 71 */ #define TOK_MODE "G" /* 71 */
#define MSG_KICK "KICK" /* KICK */ #define MSG_KICK "KICK" /* KICK */
#define TOK_KICK "H" /* 72 */ #define TOK_KICK "H" /* 72 */
#define MSG_SERVICE "SERVICE" /* SERV -> SRVI */ #define MSG_SERVICE "SERVICE" /* SERV -> SRVI */
#define TOK_SERVICE "I" /* 73 */ #define TOK_SERVICE "I" /* 73 */
#define MSG_USERHOST "USERHOST" /* USER -> USRH */ #define MSG_USERHOST "USERHOST" /* USER -> USRH */
#define TOK_USERHOST "J" /* 74 */ #define TOK_USERHOST "J" /* 74 */
#define MSG_ISON "ISON" /* ISON */ #define MSG_ISON "ISON" /* ISON */
#define TOK_ISON "K" /* 75 */ #define TOK_ISON "K" /* 75 */
#define MSG_SQUERY "SQUERY" /* SQUE */ #define MSG_SQUERY "SQUERY" /* SQUE */
#define TOK_SQUERY "L" /* 76 */ #define TOK_SQUERY "L" /* 76 */
#define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */ #define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */
#define TOK_SERVLIST "M" /* 77 */ #define TOK_SERVLIST "M" /* 77 */
#define MSG_SERVSET "SERVSET" /* SERV -> SSET */ #define MSG_SERVSET "SERVSET" /* SERV -> SSET */
#define TOK_SERVSET "N" /* 78 */ #define TOK_SERVSET "N" /* 78 */
#define MSG_REHASH "REHASH" /* REHA */ #define MSG_REHASH "REHASH" /* REHA */
#define TOK_REHASH "O" /* 79 */ #define TOK_REHASH "O" /* 79 */
#define MSG_RESTART "RESTART" /* REST */ #define MSG_RESTART "RESTART" /* REST */
#define TOK_RESTART "P" /* 80 */ #define TOK_RESTART "P" /* 80 */
#define MSG_CLOSE "CLOSE" /* CLOS */ #define MSG_CLOSE "CLOSE" /* CLOS */
#define TOK_CLOSE "Q" /* 81 */ #define TOK_CLOSE "Q" /* 81 */
#define MSG_DIE "DIE" /* DIE */ #define MSG_DIE "DIE" /* DIE */
#define TOK_DIE "R" /* 82 */ #define TOK_DIE "R" /* 82 */
#define MSG_HASH "HASH" /* HASH */ #define MSG_HASH "HASH" /* HASH */
#define TOK_HASH "S" /* 83 */ #define TOK_HASH "S" /* 83 */
#define MSG_DNS "DNS" /* DNS -> DNSS */ #define MSG_DNS "DNS" /* DNS -> DNSS */
#define TOK_DNS "T" /* 84 */ #define TOK_DNS "T" /* 84 */
#define MSG_SILENCE "SILENCE" /* SILE */ #define MSG_SILENCE "SILENCE" /* SILE */
#define TOK_SILENCE "U" /* 85 */ #define TOK_SILENCE "U" /* 85 */
#define MSG_AKILL "AKILL" /* AKILL */ #define MSG_AKILL "AKILL" /* AKILL */
#define TOK_AKILL "V" /* 86 */ #define TOK_AKILL "V" /* 86 */
#define MSG_KLINE "KLINE" /* KLINE */ #define MSG_KLINE "KLINE" /* KLINE */
#define TOK_KLINE "W" /* 87 */ #define TOK_KLINE "W" /* 87 */
#define MSG_UNKLINE "UNKLINE" /* UNKLINE */ #define MSG_UNKLINE "UNKLINE" /* UNKLINE */
#define TOK_UNKLINE "X" /* 88 */ #define TOK_UNKLINE "X" /* 88 */
#define MSG_RAKILL "RAKILL" /* RAKILL */ #define MSG_RAKILL "RAKILL" /* RAKILL */
#define TOK_RAKILL "Y" /* 89 */ #define TOK_RAKILL "Y" /* 89 */
#define MSG_GNOTICE "GNOTICE" /* GNOTICE */ #define MSG_GNOTICE "GNOTICE" /* GNOTICE */
#define TOK_GNOTICE "Z" /* 90 */ #define TOK_GNOTICE "Z" /* 90 */
#define MSG_GOPER "GOPER" /* GOPER */ #define MSG_GOPER "GOPER" /* GOPER */
#define TOK_GOPER "[" /* 91 */ #define TOK_GOPER "[" /* 91 */
#define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */ #define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */
#define TOK_GLOBOPS "]" /* 93 */ #define TOK_GLOBOPS "]" /* 93 */
#define MSG_LOCOPS "LOCOPS" /* LOCOPS */ #define MSG_LOCOPS "LOCOPS" /* LOCOPS */
#define TOK_LOCOPS "^" /* 94 */ #define TOK_LOCOPS "^" /* 94 */
#define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */ #define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */
#define TOK_PROTOCTL "_" /* 95 */ #define TOK_PROTOCTL "_" /* 95 */
#define MSG_TRACE "TRACE" /* TRAC */ #define MSG_TRACE "TRACE" /* TRAC */
#define TOK_TRACE "b" /* 98 */ #define TOK_TRACE "b" /* 98 */
#define MSG_SQLINE "SQLINE" /* SQLINE */ #define MSG_SQLINE "SQLINE" /* SQLINE */
#define TOK_SQLINE "c" /* 99 */ #define TOK_SQLINE "c" /* 99 */
#define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */ #define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */
#define TOK_UNSQLINE "d" /* 100 */ #define TOK_UNSQLINE "d" /* 100 */
#define MSG_SVSNICK "SVSNICK" /* SVSNICK */ #define MSG_SVSNICK "SVSNICK" /* SVSNICK */
#define TOK_SVSNICK "e" /* 101 */ #define TOK_SVSNICK "e" /* 101 */
#define MSG_SVSNOOP "SVSNOOP" /* SVSNOOP */ #define MSG_SVSNOOP "SVSNOOP" /* SVSNOOP */
#define TOK_SVSNOOP "f" /* 101 */ #define TOK_SVSNOOP "f" /* 101 */
#define MSG_IDENTIFY "IDENTIFY" /* IDENTIFY */ #define MSG_IDENTIFY "IDENTIFY" /* IDENTIFY */
#define TOK_IDENTIFY "g" /* 103 */ #define TOK_IDENTIFY "g" /* 103 */
#define MSG_SVSKILL "SVSKILL" /* SVSKILL */ #define MSG_SVSKILL "SVSKILL" /* SVSKILL */
#define TOK_SVSKILL "h" /* 104 */ #define TOK_SVSKILL "h" /* 104 */
#define MSG_NICKSERV "NICKSERV" /* NICKSERV */ #define MSG_NICKSERV "NICKSERV" /* NICKSERV */
#define MSG_NS "NS" #define MSG_NS "NS"
#define TOK_NICKSERV "i" /* 105 */ #define TOK_NICKSERV "i" /* 105 */
#define MSG_CHANSERV "CHANSERV" /* CHANSERV */ #define MSG_CHANSERV "CHANSERV" /* CHANSERV */
#define MSG_CS "CS" #define MSG_CS "CS"
#define TOK_CHANSERV "j" /* 106 */ #define TOK_CHANSERV "j" /* 106 */
#define MSG_OPERSERV "OPERSERV" /* OPERSERV */ #define MSG_OPERSERV "OPERSERV" /* OPERSERV */
#define MSG_OS "OS" #define MSG_OS "OS"
#define TOK_OPERSERV "k" /* 107 */ #define TOK_OPERSERV "k" /* 107 */
#define MSG_MEMOSERV "MEMOSERV" /* MEMOSERV */ #define MSG_MEMOSERV "MEMOSERV" /* MEMOSERV */
#define MSG_MS "MS" #define MSG_MS "MS"
#define TOK_MEMOSERV "l" /* 108 */ #define TOK_MEMOSERV "l" /* 108 */
#define MSG_SERVICES "SERVICES" /* SERVICES */ #define MSG_SERVICES "SERVICES" /* SERVICES */
#define TOK_SERVICES "m" /* 109 */ #define TOK_SERVICES "m" /* 109 */
#define MSG_SVSMODE "SVSMODE" /* SVSMODE */ #define MSG_SVSMODE "SVSMODE" /* SVSMODE */
#define TOK_SVSMODE "n" /* 110 */ #define TOK_SVSMODE "n" /* 110 */
#define MSG_SAMODE "SAMODE" /* SAMODE */ #define MSG_SAMODE "SAMODE" /* SAMODE */
#define TOK_SAMODE "o" /* 111 */ #define TOK_SAMODE "o" /* 111 */
#define MSG_CHATOPS "CHATOPS" /* CHATOPS */ #define MSG_CHATOPS "CHATOPS" /* CHATOPS */
#define TOK_CHATOPS "p" /* 112 */ #define TOK_CHATOPS "p" /* 112 */
#define MSG_HELPSERV "HELPSERV" /* HELPSERV */ #define MSG_HELPSERV "HELPSERV" /* HELPSERV */
#define TOK_HELPSERV "r" /* 114 */ #define TOK_HELPSERV "r" /* 114 */
#define MSG_ZLINE "ZLINE" /* ZLINE */ #define MSG_ZLINE "ZLINE" /* ZLINE */
#define TOK_ZLINE "s" /* 115 */ #define TOK_ZLINE "s" /* 115 */
#define MSG_UNZLINE "UNZLINE" /* UNZLINE */ #define MSG_UNZLINE "UNZLINE" /* UNZLINE */
#define TOK_UNZLINE "t" /* 116 */ #define TOK_UNZLINE "t" /* 116 */
#define MSG_NETINFO "NETINFO" /* NETINFO */ #define MSG_NETINFO "NETINFO" /* NETINFO */
#define TOK_NETINFO "u" /* 117 */ #define TOK_NETINFO "u" /* 117 */
#define MSG_RULES "RULES" /* RULES */ #define MSG_RULES "RULES" /* RULES */
#define TOK_RULES "v" /* 118 */ #define TOK_RULES "v" /* 118 */
#define MSG_MAP "MAP" /* MAP */ #define MSG_MAP "MAP" /* MAP */
#define TOK_MAP "w" /* 119 */ #define TOK_MAP "w" /* 119 */
#define MSG_NETG "NETG" /* NETG */ #define MSG_NETG "NETG" /* NETG */
#define TOK_NETG "x" /* 120 */ #define TOK_NETG "x" /* 120 */
#define MSG_ADCHAT "ADCHAT" /* Adchat */ #define MSG_ADCHAT "ADCHAT" /* Adchat */
#define TOK_ADCHAT "y" /* 121 */ #define TOK_ADCHAT "y" /* 121 */
#define MSG_MAKEPASS "MAKEPASS" /* MAKEPASS */ #define MSG_MAKEPASS "MAKEPASS" /* MAKEPASS */
#define TOK_MAKEPASS "z" /* 122 */ #define TOK_MAKEPASS "z" /* 122 */
#define MSG_ADDHUB "ADDHUB" /* ADDHUB */ #define MSG_ADDHUB "ADDHUB" /* ADDHUB */
#define TOK_ADDHUB "{" /* 123 */ #define TOK_ADDHUB "{" /* 123 */
#define MSG_DELHUB "DELHUB" /* DELHUB */ #define MSG_DELHUB "DELHUB" /* DELHUB */
#define TOK_DELHUB "|" /* 124 */ #define TOK_DELHUB "|" /* 124 */
#define MSG_ADDCNLINE "ADDCNLINE" /* ADDCNLINE */ #define MSG_ADDCNLINE "ADDCNLINE" /* ADDCNLINE */
#define TOK_ADDCNLINE "}" /* 125 */ #define TOK_ADDCNLINE "}" /* 125 */
#define MSG_DELCNLINE "DELCNLINE" /* DELCNLINE */ #define MSG_DELCNLINE "DELCNLINE" /* DELCNLINE */
#define TOK_DELCNLINE "~" /* 126 */ #define TOK_DELCNLINE "~" /* 126 */
#define MSG_ADDOPER "ADDOPER" /* ADDOPER */ #define MSG_ADDOPER "ADDOPER" /* ADDOPER */
#define TOK_ADDOPER "" /* 127 */ #define TOK_ADDOPER "" /* 127 */
#define MSG_DELOPER "DELOPER" /* DELOPER */ #define MSG_DELOPER "DELOPER" /* DELOPER */
#define TOK_DELOPER "!!" /* 33 + 33 */ #define TOK_DELOPER "!!" /* 33 + 33 */
#define MSG_ADDQLINE "ADDQLINE" /* ADDQLINE */ #define MSG_ADDQLINE "ADDQLINE" /* ADDQLINE */
#define TOK_ADDQLINE "!\"" /* 33 + 34 */ #define TOK_ADDQLINE "!\"" /* 33 + 34 */
#define MSG_DELQLINE "DELQLINE" /* DELQLINE */ #define MSG_DELQLINE "DELQLINE" /* DELQLINE */
#define TOK_DELQLINE "!#" /* 33 + 35 */ #define TOK_DELQLINE "!#" /* 33 + 35 */
#define MSG_GSOP "GSOP" /* GSOP */ #define MSG_GSOP "GSOP" /* GSOP */
#define TOK_GSOP "!$" /* 33 + 36 */ #define TOK_GSOP "!$" /* 33 + 36 */
#define MSG_ISOPER "ISOPER" /* ISOPER */ #define MSG_ISOPER "ISOPER" /* ISOPER */
#define TOK_ISOPER "!%" /* 33 + 37 */ #define TOK_ISOPER "!%" /* 33 + 37 */
#define MSG_ADG "ADG" /* ADG */ #define MSG_ADG "ADG" /* ADG */
#define TOK_ADG "!&" /* 33 + 38 */ #define TOK_ADG "!&" /* 33 + 38 */
#define MSG_NMON "NMON" /* NMON */ #define MSG_NMON "NMON" /* NMON */
#define TOK_NMON "!'" /* 33 + 39 */ #define TOK_NMON "!'" /* 33 + 39 */
#define MSG_DALINFO "DALINFO" /* DALnet Credits */ #define MSG_DALINFO "DALINFO" /* DALnet Credits */
#define TOK_DALINFO "!(" /* 33 + 40 */ #define TOK_DALINFO "!(" /* 33 + 40 */
#define MSG_CREDITS "CREDITS" /* UltimateIRCd Credits and "Thanks To" */ #define MSG_CREDITS "CREDITS" /* UltimateIRCd Credits and "Thanks To" */
#define TOK_CREDITS "!)" /* 33 + 41 */ #define TOK_CREDITS "!)" /* 33 + 41 */
#define MSG_OPERMOTD "OPERMOTD" /* OPERMOTD */ #define MSG_OPERMOTD "OPERMOTD" /* OPERMOTD */
#define TOK_OPERMOTD "!*" /* 33 + 42 */ #define TOK_OPERMOTD "!*" /* 33 + 42 */
#define MSG_REMREHASH "REMREHASH" /* Remote Rehash */ #define MSG_REMREHASH "REMREHASH" /* Remote Rehash */
#define TOK_REMREHASH "!+" /* 33 + 43 */ #define TOK_REMREHASH "!+" /* 33 + 43 */
#define MSG_MONITOR "MONITOR" /* MONITOR */ #define MSG_MONITOR "MONITOR" /* MONITOR */
#define TOK_MONITOR "!," /* 33 + 44 */ #define TOK_MONITOR "!," /* 33 + 44 */
#define MSG_GLINE "GLINE" /* The awesome g-line */ #define MSG_GLINE "GLINE" /* The awesome g-line */
#define TOK_GLINE "!-" /* 33 + 45 */ #define TOK_GLINE "!-" /* 33 + 45 */
#define MSG_REMGLINE "REMGLINE" /* remove g-line */ #define MSG_REMGLINE "REMGLINE" /* remove g-line */
#define TOK_REMGLINE "!." /* 33 + 46 */ #define TOK_REMGLINE "!." /* 33 + 46 */
#define MSG_STATSERV "STATSERV" /* StatServ */ #define MSG_STATSERV "STATSERV" /* StatServ */
#define TOK_STATSERV "!/" /* 33 + 47 */ #define TOK_STATSERV "!/" /* 33 + 47 */
#define MSG_RULESERV "RULESERV" /* RuleServ */ #define MSG_RULESERV "RULESERV" /* RuleServ */
#define TOK_RULESERV "!0" /* 33 + 48 */ #define TOK_RULESERV "!0" /* 33 + 48 */
#define MSG_SNETINFO "SNETINFO" /* SNetInfo */ #define MSG_SNETINFO "SNETINFO" /* SNetInfo */
#define TOK_SNETINFO "!1" /* 33 + 49 */ #define TOK_SNETINFO "!1" /* 33 + 49 */
#define MSG_TSCTL "TSCTL" /* TSCTL */ #define MSG_TSCTL "TSCTL" /* TSCTL */
#define TOK_TSCTL "!3" /* 33 + 51 */ #define TOK_TSCTL "!3" /* 33 + 51 */
#define MSG_SVSJOIN "SVSJOIN" /* SVSJOIN */ #define MSG_SVSJOIN "SVSJOIN" /* SVSJOIN */
#define TOK_SVSJOIN "!4" /* 33 + 52 */ #define TOK_SVSJOIN "!4" /* 33 + 52 */
#define MSG_SAJOIN "SAJOIN" /* SAJOIN */ #define MSG_SAJOIN "SAJOIN" /* SAJOIN */
#define TOK_SAJOIN "!5" /* 33 + 53 */ #define TOK_SAJOIN "!5" /* 33 + 53 */
#define MSG_SDESC "SDESC" /* SDESC */ #define MSG_SDESC "SDESC" /* SDESC */
#define TOK_SDESC "!6" /* 33 + 54 */ #define TOK_SDESC "!6" /* 33 + 54 */
#define MSG_UNREALINFO "UNREALINFO" /* Unreal Info */ #define MSG_UNREALINFO "UNREALINFO" /* Unreal Info */
#define TOK_UNREALINFO "!7" /* 33 + 55 */ #define TOK_UNREALINFO "!7" /* 33 + 55 */
#define MSG_SETHOST "SETHOST" /* sethost */ #define MSG_SETHOST "SETHOST" /* sethost */
#define TOK_SETHOST "!8" /* 33 + 56 */ #define TOK_SETHOST "!8" /* 33 + 56 */
#define MSG_SETIDENT "SETIDENT" /* set ident */ #define MSG_SETIDENT "SETIDENT" /* set ident */
#define TOK_SETIDENT "!9" /* 33 + 57 */ #define TOK_SETIDENT "!9" /* 33 + 57 */
#define MSG_SETNAME "SETNAME" /* set Realname */ #define MSG_SETNAME "SETNAME" /* set Realname */
#define TOK_SETNAME "!;" /* 33 + 59 */ #define TOK_SETNAME "!;" /* 33 + 59 */
#define MSG_CHGHOST "CHGHOST" /* Changehost */ #define MSG_CHGHOST "CHGHOST" /* Changehost */
#define TOK_CHGHOST "!<" /* 33 + 60 */ #define TOK_CHGHOST "!<" /* 33 + 60 */
#define MSG_CHGIDENT "CHGIDENT" /* Change Ident */ #define MSG_CHGIDENT "CHGIDENT" /* Change Ident */
#define TOK_CHGIDENT "!=" /* 33 + 61 */ #define TOK_CHGIDENT "!=" /* 33 + 61 */
#define MSG_RANDQUOTE "RANDQUOTE" /* Random Quote */ #define MSG_RANDQUOTE "RANDQUOTE" /* Random Quote */
#define TOK_RANDQUOTE "!>" /* 33 + 62 */ #define TOK_RANDQUOTE "!>" /* 33 + 62 */
#define MSG_ADDQUOTE "ADDQUOTE" /* Add Quote */ #define MSG_ADDQUOTE "ADDQUOTE" /* Add Quote */
#define TOK_ADDQUOTE "!?" /* 33 + 63 */ #define TOK_ADDQUOTE "!?" /* 33 + 63 */
#define MSG_ADDGQUOTE "ADDGQUOTE" /* Add Global Quote */ #define MSG_ADDGQUOTE "ADDGQUOTE" /* Add Global Quote */
#define TOK_ADDGQUOTE "!@" /* 33 + 64 */ #define TOK_ADDGQUOTE "!@" /* 33 + 64 */
#define MSG_ADDULINE "ADDULINE" /* Adds an U Line to ircd.conf file */ #define MSG_ADDULINE "ADDULINE" /* Adds an U Line to ircd.conf file */
#define TOK_ADDULINE "!B" /* 33 + 66 */ #define TOK_ADDULINE "!B" /* 33 + 66 */
#define MSG_DELULINE "DELULINE" /* Removes an U line from the ircd.conf */ #define MSG_DELULINE "DELULINE" /* Removes an U line from the ircd.conf */
#define TOK_DELULINE "!C" /* 33 + 67 */ #define TOK_DELULINE "!C" /* 33 + 67 */
#define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */ #define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */
#define TOK_KNOCK "!D" /* 33 + 68 */ #define TOK_KNOCK "!D" /* 33 + 68 */
#define MSG_SETTINGS "SETTINGS" /* Settings */ #define MSG_SETTINGS "SETTINGS" /* Settings */
#define TOK_SETTINGS "!E" /* 33 + 69 */ #define TOK_SETTINGS "!E" /* 33 + 69 */
#define MSG_IRCOPS "IRCOPS" /* Shows Online IRCOps */ #define MSG_IRCOPS "IRCOPS" /* Shows Online IRCOps */
#define TOK_IRCOPS "!F" /* 33 + 70 */ #define TOK_IRCOPS "!F" /* 33 + 70 */
#define MSG_SVSPART "SVSPART" /* SVSPART */ #define MSG_SVSPART "SVSPART" /* SVSPART */
#define TOK_SVSPART "!G" /* 33 + 71 */ #define TOK_SVSPART "!G" /* 33 + 71 */
#define MSG_SAPART "SAPART" /* SAPART */ #define MSG_SAPART "SAPART" /* SAPART */
#define TOK_SAPART "!H" /* 33 + 72 */ #define TOK_SAPART "!H" /* 33 + 72 */
#define MSG_VCTRL "VCTRL" /* VCTRL */ #define MSG_VCTRL "VCTRL" /* VCTRL */
#define TOK_VCTRL "!I" /* 33 + 73 */ #define TOK_VCTRL "!I" /* 33 + 73 */
#define MSG_GCLIENT "GCLIENT" /* GLIENT */ #define MSG_GCLIENT "GCLIENT" /* GLIENT */
#define TOK_GCLIENT "!J" /* 33 + 74 */ #define TOK_GCLIENT "!J" /* 33 + 74 */
#define MSG_CHANNEL "CHANNEL" /* CHANNEL */ #define MSG_CHANNEL "CHANNEL" /* CHANNEL */
#define TOK_CHANNEL "!K" /* 33 + 75 */ #define TOK_CHANNEL "!K" /* 33 + 75 */
#define MSG_UPTIME "UPTIME" /* UPTIME */ #define MSG_UPTIME "UPTIME" /* UPTIME */
#define TOK_UPTIME "!L" /* 33 + 76 */ #define TOK_UPTIME "!L" /* 33 + 76 */
#define MSG_FAILOPS "FAILOPS" /* FAILOPS */ #define MSG_FAILOPS "FAILOPS" /* FAILOPS */
#define TOK_FAILOPS "!M" /* 33 + 77 */ #define TOK_FAILOPS "!M" /* 33 + 77 */
#define MSG_RPING "RPING" /* RPING */ #define MSG_RPING "RPING" /* RPING */
#define TOK_RPING "!P" /* 33 + 80 */ #define TOK_RPING "!P" /* 33 + 80 */
#define MSG_RPONG "RPONG" /* RPONG */ #define MSG_RPONG "RPONG" /* RPONG */
#define TOK_RPONG "!Q" /* 33 + 81 */ #define TOK_RPONG "!Q" /* 33 + 81 */
#define MSG_UPING "UPING" /* UPING */ #define MSG_UPING "UPING" /* UPING */
#define TOK_UPING "!R" /* 33 + 82 */ #define TOK_UPING "!R" /* 33 + 82 */
#define MSG_COPYRIGHT "COPYRIGHT" /* Copyright */ #define MSG_COPYRIGHT "COPYRIGHT" /* Copyright */
#define TOK_COPYRIGHT "!S" /* 33 + 83 */ #define TOK_COPYRIGHT "!S" /* 33 + 83 */
#define MSG_BOTSERV "BOTSERV" /* BOTSERV */ #define MSG_BOTSERV "BOTSERV" /* BOTSERV */
#define MSG_BS "BS" #define MSG_BS "BS"
#define TOK_BOTSERV "!T" /* 33 + 84 */ #define TOK_BOTSERV "!T" /* 33 + 84 */
#define MSG_ROOTSERV "ROOTSERV" /* ROOTSERV */ #define MSG_ROOTSERV "ROOTSERV" /* ROOTSERV */
#define MSG_RS "RS" #define MSG_RS "RS"
#define TOK_ROOTSERV "!U" /* 33 + 85 */ #define TOK_ROOTSERV "!U" /* 33 + 85 */
#define MSG_SVINFO "SVINFO" #define MSG_SVINFO "SVINFO"
#define MSG_CAPAB "CAPAB" #define MSG_CAPAB "CAPAB"
#define MSG_BURST "BURST" #define MSG_BURST "BURST"
@ -322,62 +322,62 @@
#define UMODE_INVISIBLE 0x0001 /* makes user invisible */ #define UMODE_INVISIBLE 0x0001 /* makes user invisible */
#define UMODE_OPER 0x0002 /* Operator */ #define UMODE_OPER 0x0002 /* Operator */
#define UMODE_WALLOP 0x0004 /* send wallops to them */ #define UMODE_WALLOP 0x0004 /* send wallops to them */
#define UMODE_FAILOP 0x0008 /* Shows some global messages */ #define UMODE_FAILOP 0x0008 /* Shows some global messages */
#define UMODE_HELPOP 0x0010 /* Help system operator */ #define UMODE_HELPOP 0x0010 /* Help system operator */
#define UMODE_REGNICK 0x0020 /* Nick set by services as registered */ #define UMODE_REGNICK 0x0020 /* Nick set by services as registered */
#define UMODE_SERVICESOPER 0x0040 /* Services Oper */ #define UMODE_SERVICESOPER 0x0040 /* Services Oper */
#ifndef ULTIMATE3 #ifndef ULTIMATE3
#define UMODE_ADMIN 0x0080 /* Admin */ #define UMODE_ADMIN 0x0080 /* Admin */
#define UMODE_NETADMIN 0x10000 /* Network Admin */ #define UMODE_NETADMIN 0x10000 /* Network Admin */
#define UMODE_SUPER 0x20000 /* Oper Is Protected from Kick's and Kill's */ #define UMODE_SUPER 0x20000 /* Oper Is Protected from Kick's and Kill's */
#define UMODE_RBOT 0x40000 /* Marks the client as a Registered Bot */ #define UMODE_RBOT 0x40000 /* Marks the client as a Registered Bot */
#define UMODE_SBOT 0x80000 /* Marks the client as a Server Bot */ #define UMODE_SBOT 0x80000 /* Marks the client as a Server Bot */
#define UMODE_NGLOBAL 0x100000 /* See Network Globals */ #define UMODE_NGLOBAL 0x100000 /* See Network Globals */
#define UMODE_NETINFO 0x400000 /* Server link, Delink Notces etc. */ #define UMODE_NETINFO 0x400000 /* Server link, Delink Notces etc. */
#define UMODE_MAGICK 0x800000 /* Allows Opers To See +s and +p Channels */ #define UMODE_MAGICK 0x800000 /* Allows Opers To See +s and +p Channels */
#define UMODE_WATCHER 0x4000000 /* Recive Monitor Globals */ #define UMODE_WATCHER 0x4000000 /* Recive Monitor Globals */
#define UMODE_NETMON 0x8000000 /* Marks the client as an Network Monitor */ #define UMODE_NETMON 0x8000000 /* Marks the client as an Network Monitor */
#define UMODE_SERVADMIN 0x40000000 /* Marks the client as a Server Admin */ #define UMODE_SERVADMIN 0x40000000 /* Marks the client as a Server Admin */
#define UMODE_TECHADMIN 0x80000000 /* Marks the client as a Technical Admin */ #define UMODE_TECHADMIN 0x80000000 /* Marks the client as a Technical Admin */
#define UMODE_DEAF 0x100000000 /* client is deaf on channels */ #define UMODE_DEAF 0x100000000 /* client is deaf on channels */
#else #else
#define UMODE_SPY 0x0080 /* Oper Spy */ #define UMODE_SPY 0x0080 /* Oper Spy */
#define UMODE_DCC 0x10000 /* Oper DCC Notices */ #define UMODE_DCC 0x10000 /* Oper DCC Notices */
#define UMODE_GLOBOPS 0x20000 /* send/recv global notices */ #define UMODE_GLOBOPS 0x20000 /* send/recv global notices */
#define UMODE_REJ 0x40000 /* see DCC reject notices */ #define UMODE_REJ 0x40000 /* see DCC reject notices */
#define UMODE_ROUTE 0x80000 /* see Routing Notices */ #define UMODE_ROUTE 0x80000 /* see Routing Notices */
#define UMODE_SPAM 0x100000 /* see spambot warnings */ #define UMODE_SPAM 0x100000 /* see spambot warnings */
#define UMODE_PROT 0x400000 /* protected IRC op */ #define UMODE_PROT 0x400000 /* protected IRC op */
#define UMODE_GLOBCON 0x800000 /* Global Connect notices */ #define UMODE_GLOBCON 0x800000 /* Global Connect notices */
#define UMODE_DEBUG 0x4000000 /* see debug notices */ #define UMODE_DEBUG 0x4000000 /* see debug notices */
#define UMODE_DCCWARN 0x8000000 /* see DCC warnings */ #define UMODE_DCCWARN 0x8000000 /* see DCC warnings */
#endif #endif
#define UMODE_SERVNOTICE 0x0100 /* server notices such as kill */ #define UMODE_SERVNOTICE 0x0100 /* server notices such as kill */
#define UMODE_LOCOP 0x0200 /* Local operator -- SRB */ #define UMODE_LOCOP 0x0200 /* Local operator -- SRB */
#define UMODE_KILLS 0x0400 /* Show server-kills... */ #define UMODE_KILLS 0x0400 /* Show server-kills... */
#define UMODE_CLIENT 0x0800 /* Show client information */ #define UMODE_CLIENT 0x0800 /* Show client information */
#define UMODE_FLOOD 0x1000 /* Receive flood warnings */ #define UMODE_FLOOD 0x1000 /* Receive flood warnings */
#define UMODE_CHATOP 0x2000 /* can receive chatops */ #define UMODE_CHATOP 0x2000 /* can receive chatops */
#define UMODE_SERVICES 0x4000 /* services */ #define UMODE_SERVICES 0x4000 /* services */
#define UMODE_HIDE 0x8000 /* Hide from Nukes */ #define UMODE_HIDE 0x8000 /* Hide from Nukes */
#define UMODE_WHOIS 0x200000 /* Lets Opers see when people do a /WhoIs on them */ #define UMODE_WHOIS 0x200000 /* Lets Opers see when people do a /WhoIs on them */
#define UMODE_IRCADMIN 0x1000000 /* Marks the client as an IRC Administrator */ #define UMODE_IRCADMIN 0x1000000 /* Marks the client as an IRC Administrator */
#define UMODE_SERVICESADMIN 0x2000000 /* Marks the client as a Services Administrator */ #define UMODE_SERVICESADMIN 0x2000000 /* Marks the client as a Services Administrator */
#define SMODE_SSL 0x1 /* ssl client */ #define SMODE_SSL 0x1 /* ssl client */
#define SMODE_COADMIN 0x2 /* co admin on a server */ #define SMODE_COADMIN 0x2 /* co admin on a server */
#define SMODE_SERVADMIN 0x4 /* server admin */ #define SMODE_SERVADMIN 0x4 /* server admin */
#define SMODE_COTECH 0x8 /* co-tech admin */ #define SMODE_COTECH 0x8 /* co-tech admin */
#define SMODE_TECHADMIN 0x10 /* tech administrator */ #define SMODE_TECHADMIN 0x10 /* tech administrator */
#define SMODE_CONET 0x20 /* Co-Network Admin */ #define SMODE_CONET 0x20 /* Co-Network Admin */
#define SMODE_NETADMIN 0x40 /* Network Admin */ #define SMODE_NETADMIN 0x40 /* Network Admin */
#define SMODE_GUEST 0x80 /* Guest Admin */ #define SMODE_GUEST 0x80 /* Guest Admin */
#define MODE_CHANOP 0x0001 #define MODE_CHANOP 0x0001
@ -423,8 +423,8 @@ struct ircd_srv_ {
typedef struct { typedef struct {
long mode; long mode;
char flag; char flag;
unsigned nickparam : 1; /* 1 = yes 0 = no */ unsigned nickparam:1; /* 1 = yes 0 = no */
unsigned parameters : 1; unsigned parameters:1;
char sjoin; char sjoin;
} aCtab; } aCtab;
@ -446,85 +446,85 @@ Oper_Modes susr_mds[9];
/* function declarations */ /* function declarations */
extern void init_ircd(); extern void init_ircd ();
extern void chanalert(char *,char *, ...); extern void chanalert (char *, char *, ...);
extern int sserver_cmd(const char *, const int numeric, const char *); extern int sserver_cmd (const char *, const int numeric, const char *);
extern int slogin_cmd(const char *, const int numeric, const char *, const char *); extern int slogin_cmd (const char *, const int numeric, const char *, const char *);
extern int ssquit_cmd(const char *); extern int ssquit_cmd (const char *);
extern int sprotocol_cmd(const char *); extern int sprotocol_cmd (const char *);
extern int squit_cmd(const char *, const char *); extern int squit_cmd (const char *, const char *);
extern int spart_cmd(const char *, const char *); extern int spart_cmd (const char *, const char *);
#ifdef ULTIMATE3 #ifdef ULTIMATE3
extern int sjoin_cmd(const char *, const char *, unsigned long flag); extern int sjoin_cmd (const char *, const char *, unsigned long flag);
#else #else
extern int sjoin_cmd(const char *, const char *); extern int sjoin_cmd (const char *, const char *);
#endif #endif
extern int schmode_cmd(const char *, const char *, const char *, const char *); extern int schmode_cmd (const char *, const char *, const char *, const char *);
#ifndef ULTIMATE3 #ifndef ULTIMATE3
extern int snewnick_cmd(const char *, const char *, const char *, const char *); extern int snewnick_cmd (const char *, const char *, const char *, const char *);
#else #else
extern int snewnick_cmd(const char *, const char *, const char *, const char *, long mode); extern int snewnick_cmd (const char *, const char *, const char *, const char *, long mode);
#endif #endif
extern int sping_cmd(const char *from, const char *reply, const char *to); extern int sping_cmd (const char *from, const char *reply, const char *to);
extern int sumode_cmd(const char *who, const char *target, long mode); extern int sumode_cmd (const char *who, const char *target, long mode);
extern int snumeric_cmd(const int numeric, const char *target, const char *data,...); extern int snumeric_cmd (const int numeric, const char *target, const char *data, ...);
extern int spong_cmd(const char *reply); extern int spong_cmd (const char *reply);
extern int snetinfo_cmd(); extern int snetinfo_cmd ();
extern int skill_cmd(const char *from, const char *target, const char *reason,...); extern int skill_cmd (const char *from, const char *target, const char *reason, ...);
extern int ssmo_cmd(const char *from, const char *umodetarget, const char *msg); extern int ssmo_cmd (const char *from, const char *umodetarget, const char *msg);
extern int snick_cmd(const char *oldnick, const char *newnick); extern int snick_cmd (const char *oldnick, const char *newnick);
extern int sswhois_cmd(const char *target, const char *swhois); extern int sswhois_cmd (const char *target, const char *swhois);
extern int ssvsnick_cmd(const char *target, const char *newnick); extern int ssvsnick_cmd (const char *target, const char *newnick);
extern int ssvsjoin_cmd(const char *target, const char *chan); extern int ssvsjoin_cmd (const char *target, const char *chan);
extern int ssvspart_cmd(const char *target, const char *chan); extern int ssvspart_cmd (const char *target, const char *chan);
extern int ssvshost_cmd(const char *who, const char *vhost); extern int ssvshost_cmd (const char *who, const char *vhost);
extern int skick_cmd(const char *who, const char *target, const char *chan, const char *reason); extern int skick_cmd (const char *who, const char *target, const char *chan, const char *reason);
extern int swallops_cmd(const char *who, const char *msg,...); extern int swallops_cmd (const char *who, const char *msg, ...);
extern int vctrl_cmd(); extern int vctrl_cmd ();
extern int ssvinfo_cmd(); extern int ssvinfo_cmd ();
extern int sburst_cmd(int b); extern int sburst_cmd (int b);
extern int sakill_cmd(const char *host, const char *ident, const char *setby, const int length, const char *reason,...); extern int sakill_cmd (const char *host, const char *ident, const char *setby, const int length, const char *reason, ...);
extern int srakill_cmd(const char *host, const char *ident); extern int srakill_cmd (const char *host, const char *ident);
extern int ssvshost_cmd(const char *who, const char *vhost); extern int ssvshost_cmd (const char *who, const char *vhost);
extern int ssvskill_cmd(const char *who, const char *reason, ...); extern int ssvskill_cmd (const char *who, const char *reason, ...);
void Usr_Version(char *, char **, int argc); void Usr_Version (char *, char **, int argc);
void Usr_ShowMOTD(char *, char **, int argc); void Usr_ShowMOTD (char *, char **, int argc);
void Usr_ShowADMIN(char *, char **, int argc); void Usr_ShowADMIN (char *, char **, int argc);
void Usr_Showcredits(char *, char **, int argc); void Usr_Showcredits (char *, char **, int argc);
void Usr_AddServer(char *, char **, int argc); void Usr_AddServer (char *, char **, int argc);
void Usr_DelServer(char *, char **, int argc); void Usr_DelServer (char *, char **, int argc);
void Usr_DelUser(char *, char **, int argc); void Usr_DelUser (char *, char **, int argc);
void Usr_Mode(char *, char **, int argc); void Usr_Mode (char *, char **, int argc);
void Usr_Smode(char *, char **, int argc); void Usr_Smode (char *, char **, int argc);
void Usr_Kill(char *, char **, int argc); void Usr_Kill (char *, char **, int argc);
void Usr_Pong(char *, char **, int argc); void Usr_Pong (char *, char **, int argc);
void Usr_Away(char *, char **, int argc); void Usr_Away (char *, char **, int argc);
void Usr_Nick(char *, char **, int argc); void Usr_Nick (char *, char **, int argc);
void Usr_Topic(char *, char **, int argc); void Usr_Topic (char *, char **, int argc);
void Usr_Kick(char *, char **, int argc); void Usr_Kick (char *, char **, int argc);
void Usr_Join(char *, char **, int argc); void Usr_Join (char *, char **, int argc);
void Usr_Part(char *, char **, int argc); void Usr_Part (char *, char **, int argc);
void Usr_Stats(char *, char **, int argc); void Usr_Stats (char *, char **, int argc);
void Usr_Vhost(char *, char **, int argc); void Usr_Vhost (char *, char **, int argc);
void Srv_Topic(char *, char **, int argc); void Srv_Topic (char *, char **, int argc);
void Srv_Ping(char *, char **, int argc); void Srv_Ping (char *, char **, int argc);
void Srv_Netinfo(char *, char **, int argc); void Srv_Netinfo (char *, char **, int argc);
void Srv_Pass(char *, char **, int argc); void Srv_Pass (char *, char **, int argc);
void Srv_Server(char *, char **, int argc); void Srv_Server (char *, char **, int argc);
void Srv_Squit(char *, char **, int argc); void Srv_Squit (char *, char **, int argc);
void Srv_Nick(char *, char **, int argc); void Srv_Nick (char *, char **, int argc);
void Srv_Svsnick(char *, char **, int argc); void Srv_Svsnick (char *, char **, int argc);
void Srv_Kill(char *, char **, int argc); void Srv_Kill (char *, char **, int argc);
void Srv_Connect(char *, char **, int argc); void Srv_Connect (char *, char **, int argc);
void Srv_Svinfo(char *, char **, int argc); void Srv_Svinfo (char *, char **, int argc);
void Srv_Burst(char *origin, char **argv, int argc); void Srv_Burst (char *origin, char **argv, int argc);
void Srv_Sjoin(char *origin, char **argv, int argc); void Srv_Sjoin (char *origin, char **argv, int argc);
void Srv_Tburst(char *origin, char **argv, int argc); void Srv_Tburst (char *origin, char **argv, int argc);
void Srv_Vctrl(char *origin, char **argv, int argc); void Srv_Vctrl (char *origin, char **argv, int argc);
void Srv_Client(char *origin, char **argv, int argc); void Srv_Client (char *origin, char **argv, int argc);
void Srv_Smode(char *origin, char **argv, int argc); void Srv_Smode (char *origin, char **argv, int argc);
int SignOn_NewBot(const char *, const char *, const char *, const char *, long); int SignOn_NewBot (const char *, const char *, const char *, const char *, long);
#endif #endif

627
Unreal.c
View file

@ -20,7 +20,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: Unreal.c,v 1.49 2003/07/11 13:43:27 fishwaldo Exp $ ** $Id: Unreal.c,v 1.50 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
#include "stats.h" #include "stats.h"
@ -294,101 +294,105 @@ Oper_Modes usr_mds[] = {
void init_ircd() void
init_ircd ()
{ {
/* count the number of commands */ /* count the number of commands */
ircd_srv.cmdcount = ((sizeof(cmd_list) / sizeof(cmd_list[0])) - 1); ircd_srv.cmdcount = ((sizeof (cmd_list) / sizeof (cmd_list[0])) - 1);
}; };
int sserver_cmd(const char *name, const int numeric, const char *infoline) int
sserver_cmd (const char *name, const int numeric, const char *infoline)
{ {
sts(":%s %s %s %d :%s", me.name, sts (":%s %s %s %d :%s", me.name, (me.token ? TOK_SERVER : MSG_SERVER), name, numeric, infoline);
(me.token ? TOK_SERVER : MSG_SERVER), name, numeric, infoline);
return 1; return 1;
} }
int slogin_cmd(const char *name, const int numeric, const char *infoline, int
const char *pass) slogin_cmd (const char *name, const int numeric, const char *infoline, const char *pass)
{ {
sts("%s %s", (me.token ? TOK_PASS : MSG_PASS), pass); sts ("%s %s", (me.token ? TOK_PASS : MSG_PASS), pass);
sts("%s %s %d :%s", (me.token ? TOK_SERVER : MSG_SERVER), name, sts ("%s %s %d :%s", (me.token ? TOK_SERVER : MSG_SERVER), name, numeric, infoline);
numeric, infoline);
return 1; return 1;
} }
int ssquit_cmd(const char *server) int
ssquit_cmd (const char *server)
{ {
sts("%s %s", (me.token ? TOK_SQUIT : MSG_SQUIT), server); sts ("%s %s", (me.token ? TOK_SQUIT : MSG_SQUIT), server);
return 1; return 1;
} }
int sprotocol_cmd(const char *option) int
sprotocol_cmd (const char *option)
{ {
sts("%s %s", (me.token ? TOK_PROTOCTL : MSG_PROTOCTL), option); sts ("%s %s", (me.token ? TOK_PROTOCTL : MSG_PROTOCTL), option);
return 1; return 1;
} }
int squit_cmd(const char *who, const char *quitmsg) int
squit_cmd (const char *who, const char *quitmsg)
{ {
sts(":%s %s :%s", who, (me.token ? TOK_QUIT : MSG_QUIT), quitmsg); sts (":%s %s :%s", who, (me.token ? TOK_QUIT : MSG_QUIT), quitmsg);
DelUser(who); DelUser (who);
return 1; return 1;
} }
int spart_cmd(const char *who, const char *chan) int
spart_cmd (const char *who, const char *chan)
{ {
sts(":%s %s %s", who, (me.token ? TOK_PART : MSG_PART), chan); sts (":%s %s %s", who, (me.token ? TOK_PART : MSG_PART), chan);
part_chan(finduser(who), (char *) chan); part_chan (finduser (who), (char *) chan);
return 1; return 1;
} }
int sjoin_cmd(const char *who, const char *chan) int
sjoin_cmd (const char *who, const char *chan)
{ {
sts(":%s %s %s", who, (me.token ? TOK_JOIN : MSG_JOIN), chan); sts (":%s %s %s", who, (me.token ? TOK_JOIN : MSG_JOIN), chan);
join_chan(finduser(who), (char *) chan); join_chan (finduser (who), (char *) chan);
return 1; return 1;
} }
int schmode_cmd(const char *who, const char *chan, const char *mode, int
const char *args) schmode_cmd (const char *who, const char *chan, const char *mode, const char *args)
{ {
char **av; char **av;
int ac; int ac;
char tmp[512]; char tmp[512];
sts(":%s %s %s %s %s %lu", who, (me.token ? TOK_MODE : MSG_MODE), sts (":%s %s %s %s %s %lu", who, (me.token ? TOK_MODE : MSG_MODE), chan, mode, args, time (NULL));
chan, mode, args, time(NULL)); snprintf (tmp, 512, "%s %s %s", chan, mode, args);
snprintf(tmp, 512, "%s %s %s", chan, mode, args); ac = split_buf (tmp, &av, 0);
ac = split_buf(tmp, &av, 0); ChanMode ("", av, ac);
ChanMode("", av, ac);
return 1; return 1;
} }
int snewnick_cmd(const char *nick, const char *ident, const char *host, int
const char *realname) snewnick_cmd (const char *nick, const char *ident, const char *host, const char *realname)
{ {
sts("%s %s 1 %lu %s %s %s 0 :%s", (me.token ? TOK_NICK : MSG_NICK), sts ("%s %s 1 %lu %s %s %s 0 :%s", (me.token ? TOK_NICK : MSG_NICK), nick, time (NULL), ident, host, me.name, realname);
nick, time(NULL), ident, host, me.name, realname); AddUser (nick, ident, host, me.name, 0, time (NULL));
AddUser(nick, ident, host, me.name, 0, time(NULL));
return 1; return 1;
} }
int sping_cmd(const char *from, const char *reply, const char *to) int
sping_cmd (const char *from, const char *reply, const char *to)
{ {
sts(":%s %s %s :%s", from, (me.token ? TOK_PING : MSG_PING), reply, sts (":%s %s %s :%s", from, (me.token ? TOK_PING : MSG_PING), reply, to);
to);
return 1; return 1;
} }
int sumode_cmd(const char *who, const char *target, long mode) int
sumode_cmd (const char *who, const char *target, long mode)
{ {
int i, j; int i, j;
char newmode[20]; char newmode[20];
newmode[0] = '+'; newmode[0] = '+';
j = 1; j = 1;
for (i = 0; i < ((sizeof(usr_mds) / sizeof(usr_mds[0])) - 1); i++) { for (i = 0; i < ((sizeof (usr_mds) / sizeof (usr_mds[0])) - 1); i++) {
if (mode & usr_mds[i].umodes) { if (mode & usr_mds[i].umodes) {
newmode[j] = usr_mds[i].mode; newmode[j] = usr_mds[i].mode;
j++; j++;
@ -396,561 +400,582 @@ int sumode_cmd(const char *who, const char *target, long mode)
} }
newmode[j] = '\0'; newmode[j] = '\0';
sts(":%s %s %s :%s", who, (me.token ? TOK_MODE : MSG_MODE), target, sts (":%s %s %s :%s", who, (me.token ? TOK_MODE : MSG_MODE), target, newmode);
newmode); UserMode (target, newmode, 0);
UserMode(target, newmode, 0);
return 1; return 1;
} }
int snumeric_cmd(const int numeric, const char *target, const char *data, int
...) snumeric_cmd (const int numeric, const char *target, const char *data, ...)
{ {
va_list ap; va_list ap;
char buf[512]; char buf[512];
va_start(ap, data); va_start (ap, data);
vsnprintf(buf, 512, data, ap); vsnprintf (buf, 512, data, ap);
sts(":%s %d %s :%s", me.name, numeric, target, buf); sts (":%s %d %s :%s", me.name, numeric, target, buf);
va_end(ap); va_end (ap);
return 1; return 1;
} }
int spong_cmd(const char *reply) int
spong_cmd (const char *reply)
{ {
sts("%s %s", (me.token ? TOK_PONG : MSG_PONG), reply); sts ("%s %s", (me.token ? TOK_PONG : MSG_PONG), reply);
return 1; return 1;
} }
int snetinfo_cmd() int
snetinfo_cmd ()
{ {
sts(":%s %s 0 %d %d %s 0 0 0 :%s", me.name, sts (":%s %s 0 %d %d %s 0 0 0 :%s", me.name, (me.token ? TOK_NETINFO : MSG_NETINFO), time (NULL), ircd_srv.uprot, ircd_srv.cloak, me.netname);
(me.token ? TOK_NETINFO : MSG_NETINFO), time(NULL),
ircd_srv.uprot, ircd_srv.cloak, me.netname);
return 1; return 1;
} }
int skill_cmd(const char *from, const char *target, const char *reason, int
...) skill_cmd (const char *from, const char *target, const char *reason, ...)
{ {
va_list ap; va_list ap;
char buf[512]; char buf[512];
va_start(ap, reason); va_start (ap, reason);
vsnprintf(buf, 512, reason, ap); vsnprintf (buf, 512, reason, ap);
sts(":%s %s %s :%s", from, (me.token ? TOK_KILL : MSG_KILL), sts (":%s %s %s :%s", from, (me.token ? TOK_KILL : MSG_KILL), target, buf);
target, buf); va_end (ap);
va_end(ap); DelUser (target);
DelUser(target);
return 1;
}
int ssmo_cmd(const char *from, const char *umodetarget, const char *msg)
{
sts(":%s %s %s :%s", from, (me.token ? TOK_SMO : MSG_SMO),
umodetarget, msg);
return 1; return 1;
} }
int snick_cmd(const char *oldnick, const char *newnick) int
ssmo_cmd (const char *from, const char *umodetarget, const char *msg)
{ {
Change_User(finduser(oldnick), newnick); sts (":%s %s %s :%s", from, (me.token ? TOK_SMO : MSG_SMO), umodetarget, msg);
sts(":%s %s %s %d", oldnick, (me.token ? TOK_NICK : MSG_NICK),
newnick, time(NULL));
return 1;
}
int sswhois_cmd(const char *target, const char *swhois)
{
sts("%s %s :%s", (me.token ? TOK_SWHOIS : MSG_SWHOIS), target,
swhois);
return 1;
}
int ssvsnick_cmd(const char *target, const char *newnick)
{
sts("%s %s %s :%d", (me.token ? TOK_SVSNICK : MSG_SVSNICK), target,
newnick, time(NULL));
return 1; return 1;
} }
int ssvsjoin_cmd(const char *target, const char *chan) int
snick_cmd (const char *oldnick, const char *newnick)
{ {
sts("%s %s %s", (me.token ? TOK_SVSJOIN : MSG_SVSJOIN), target, Change_User (finduser (oldnick), newnick);
chan); sts (":%s %s %s %d", oldnick, (me.token ? TOK_NICK : MSG_NICK), newnick, time (NULL));
return 1; return 1;
} }
int ssvspart_cmd(const char *target, const char *chan) int
sswhois_cmd (const char *target, const char *swhois)
{ {
sts("%s %s %s", (me.token ? TOK_SVSPART : MSG_SVSPART), target, sts ("%s %s :%s", (me.token ? TOK_SWHOIS : MSG_SWHOIS), target, swhois);
chan);
return 1; return 1;
} }
int skick_cmd(const char *who, const char *target, const char *chan, int
const char *reason) ssvsnick_cmd (const char *target, const char *newnick)
{ {
sts(":%s %s %s %s :%s", who, (me.token ? TOK_KICK : MSG_KICK), sts ("%s %s %s :%d", (me.token ? TOK_SVSNICK : MSG_SVSNICK), target, newnick, time (NULL));
chan, target, (reason ? reason : "No Reason Given"));
part_chan(finduser(target), (char *) chan);
return 1; return 1;
} }
int swallops_cmd(const char *who, const char *msg, ...)
int
ssvsjoin_cmd (const char *target, const char *chan)
{
sts ("%s %s %s", (me.token ? TOK_SVSJOIN : MSG_SVSJOIN), target, chan);
return 1;
}
int
ssvspart_cmd (const char *target, const char *chan)
{
sts ("%s %s %s", (me.token ? TOK_SVSPART : MSG_SVSPART), target, chan);
return 1;
}
int
skick_cmd (const char *who, const char *target, const char *chan, const char *reason)
{
sts (":%s %s %s %s :%s", who, (me.token ? TOK_KICK : MSG_KICK), chan, target, (reason ? reason : "No Reason Given"));
part_chan (finduser (target), (char *) chan);
return 1;
}
int
swallops_cmd (const char *who, const char *msg, ...)
{ {
va_list ap; va_list ap;
char buf[512]; char buf[512];
va_start(ap, msg); va_start (ap, msg);
vsnprintf(buf, 512, msg, ap); vsnprintf (buf, 512, msg, ap);
sts(":%s %s :%s", who, (me.token ? TOK_WALLOPS : MSG_WALLOPS), sts (":%s %s :%s", who, (me.token ? TOK_WALLOPS : MSG_WALLOPS), buf);
buf); va_end (ap);
va_end(ap);
return 1; return 1;
} }
int ssvshost_cmd(const char *who, const char *vhost) int
ssvshost_cmd (const char *who, const char *vhost)
{ {
User *u; User *u;
u = finduser(who); u = finduser (who);
if (!u) { if (!u) {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "Can't Find user %s for ssvshost_cmd", who);
"Can't Find user %s for ssvshost_cmd", who);
return 0; return 0;
} else { } else {
strcpy(u->vhost, vhost); strcpy (u->vhost, vhost);
sts(":%s %s %s %s", me.name, sts (":%s %s %s %s", me.name, (me.token ? TOK_CHGHOST : MSG_CHGHOST), who, vhost);
(me.token ? TOK_CHGHOST : MSG_CHGHOST), who, vhost);
return 1; return 1;
} }
} }
int ssvsmode_cmd(const char *target, const char *modes) int
ssvsmode_cmd (const char *target, const char *modes)
{ {
User *u; User *u;
u = finduser(target); u = finduser (target);
if (!u) { if (!u) {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "Can't find user %s for ssvsmode_cmd", target);
"Can't find user %s for ssvsmode_cmd", target);
return 0; return 0;
} else { } else {
sts(":%s %s %s %s", me.name, sts (":%s %s %s %s", me.name, (me.token ? TOK_SVSMODE : MSG_SVSMODE), target, modes);
(me.token ? TOK_SVSMODE : MSG_SVSMODE), target, modes); UserMode (target, modes, 0);
UserMode(target, modes, 0);
} }
return 1; return 1;
} }
int ssvskill_cmd(const char *target, const char *reason, ...) int
ssvskill_cmd (const char *target, const char *reason, ...)
{ {
User *u; User *u;
va_list ap; va_list ap;
char buf[512]; char buf[512];
u = finduser(target); u = finduser (target);
if (!u) { if (!u) {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "Cant find user %s for ssvskill_cmd", target);
"Cant find user %s for ssvskill_cmd", target);
return 0; return 0;
} else { } else {
va_start(ap, reason); va_start (ap, reason);
vsnprintf(buf, 512, reason, ap); vsnprintf (buf, 512, reason, ap);
sts(":%s %s %s :%s", me.name, sts (":%s %s %s :%s", me.name, (me.token ? TOK_SVSKILL : MSG_SVSKILL), target, buf);
(me.token ? TOK_SVSKILL : MSG_SVSKILL), target, buf); va_end (ap);
va_end(ap);
return 1; return 1;
} }
} }
/* akill is gone in the latest Unreals, so we set Glines instead */ /* akill is gone in the latest Unreals, so we set Glines instead */
int sakill_cmd(const char *host, const char *ident, const char *setby, int
const int length, const char *reason, ...) sakill_cmd (const char *host, const char *ident, const char *setby, const int length, const char *reason, ...)
{ {
va_list ap; va_list ap;
char buf[512]; char buf[512];
va_start(ap, reason); va_start (ap, reason);
vsnprintf(buf, 512, reason, ap); vsnprintf (buf, 512, reason, ap);
sts(":%s %s + G %s %s %s %d %d :%s", me.name, sts (":%s %s + G %s %s %s %d %d :%s", me.name, (me.token ? TOK_TKL : MSG_TKL), ident, host, setby, time (NULL) + length, time (NULL), buf);
(me.token ? TOK_TKL : MSG_TKL), ident, host, setby, va_end (ap);
time(NULL) + length, time(NULL), buf);
va_end(ap);
return 1; return 1;
} }
int srakill_cmd(const char *host, const char *ident) int
srakill_cmd (const char *host, const char *ident)
{ {
sts(":%s %s - G %s %s %s", me.name, (me.token ? TOK_TKL : MSG_TKL), sts (":%s %s - G %s %s %s", me.name, (me.token ? TOK_TKL : MSG_TKL), ident, host, me.name);
ident, host, me.name);
return 1; return 1;
} }
void chanalert(char *who, char *buf, ...) void
chanalert (char *who, char *buf, ...)
{ {
va_list ap; va_list ap;
char tmp[512]; char tmp[512];
char out[512]; char out[512];
va_start(ap, buf); va_start (ap, buf);
vsnprintf(tmp, 512, buf, ap); vsnprintf (tmp, 512, buf, ap);
if (me.onchan) { if (me.onchan) {
snprintf(out, 512, ":%s PRIVMSG %s :%s", who, me.chan, snprintf (out, 512, ":%s PRIVMSG %s :%s", who, me.chan, tmp);
tmp); sts ("%s", out);
sts("%s", out);
} }
va_end(ap); va_end (ap);
} }
void notice(char *to, const char *from, char *fmt, ...)
void
notice (char *to, const char *from, char *fmt, ...)
{ {
va_list ap; va_list ap;
char buf[512], buf2[512]; char buf[512], buf2[512];
if (findbot(to)) { if (findbot (to)) {
chanalert(s_Services, chanalert (s_Services, "Message From our Bot(%s) to Our Bot(%s), Dropping Message", from, to);
"Message From our Bot(%s) to Our Bot(%s), Dropping Message",
from, to);
return; return;
} }
va_start(ap, fmt); va_start (ap, fmt);
vsnprintf(buf2, sizeof(buf2), fmt, ap); vsnprintf (buf2, sizeof (buf2), fmt, ap);
snprintf(buf, 512, ":%s NOTICE %s :%s", from, to, buf2); snprintf (buf, 512, ":%s NOTICE %s :%s", from, to, buf2);
sts("%s", buf); sts ("%s", buf);
va_end(ap); va_end (ap);
} }
void privmsg(char *to, const char *from, char *fmt, ...)
void
privmsg (char *to, const char *from, char *fmt, ...)
{ {
va_list ap; va_list ap;
char buf[512], buf2[512]; char buf[512], buf2[512];
if (findbot(to)) { if (findbot (to)) {
chanalert(s_Services, chanalert (s_Services, "Message From our Bot(%s) to Our Bot(%s), Dropping Message", from, to);
"Message From our Bot(%s) to Our Bot(%s), Dropping Message",
from, to);
return; return;
} }
va_start(ap, fmt); va_start (ap, fmt);
vsnprintf(buf2, sizeof(buf2), fmt, ap); vsnprintf (buf2, sizeof (buf2), fmt, ap);
snprintf(buf, 512, ":%s PRIVMSG %s :%s", from, to, buf2); snprintf (buf, 512, ":%s PRIVMSG %s :%s", from, to, buf2);
sts("%s", buf); sts ("%s", buf);
va_end(ap); va_end (ap);
} }
void prefmsg(char *to, const char *from, char *fmt, ...) void
prefmsg (char *to, const char *from, char *fmt, ...)
{ {
va_list ap; va_list ap;
char buf[512], buf2[512]; char buf[512], buf2[512];
va_start(ap, fmt); va_start (ap, fmt);
vsnprintf(buf2, sizeof(buf2), fmt, ap); vsnprintf (buf2, sizeof (buf2), fmt, ap);
if (findbot(to)) { if (findbot (to)) {
chanalert(s_Services, chanalert (s_Services, "Message From our Bot(%s) to Our Bot(%s), Dropping Message", from, to);
"Message From our Bot(%s) to Our Bot(%s), Dropping Message",
from, to);
return; return;
} }
if (me.want_privmsg) { if (me.want_privmsg) {
snprintf(buf, 512, ":%s PRIVMSG %s :%s", from, to, buf2); snprintf (buf, 512, ":%s PRIVMSG %s :%s", from, to, buf2);
} else { } else {
snprintf(buf, 512, ":%s NOTICE %s :%s", from, to, buf2); snprintf (buf, 512, ":%s NOTICE %s :%s", from, to, buf2);
} }
sts("%s", buf); sts ("%s", buf);
va_end(ap); va_end (ap);
} }
void privmsg_list(char *to, char *from, const char **text) void
privmsg_list (char *to, char *from, const char **text)
{ {
while (*text) { while (*text) {
if (**text) if (**text)
prefmsg(to, from, "%s", *text); prefmsg (to, from, "%s", *text);
else else
prefmsg(to, from, " "); prefmsg (to, from, " ");
text++; text++;
} }
} }
void globops(char *from, char *fmt, ...) void
globops (char *from, char *fmt, ...)
{ {
va_list ap; va_list ap;
char buf[512], buf2[512]; char buf[512], buf2[512];
va_start(ap, fmt); va_start (ap, fmt);
vsnprintf(buf2, sizeof(buf2), fmt, ap); vsnprintf (buf2, sizeof (buf2), fmt, ap);
/* Shmad - have to get rid of nasty term echos :-) */ /* Shmad - have to get rid of nasty term echos :-) */
/* Fish - now that was crackhead coding! */ /* Fish - now that was crackhead coding! */
if (me.onchan) { if (me.onchan) {
snprintf(buf, 512, ":%s GLOBOPS :%s", from, buf2); snprintf (buf, 512, ":%s GLOBOPS :%s", from, buf2);
sts("%s", buf); sts ("%s", buf);
} else { } else {
nlog(LOG_NORMAL, LOG_CORE, "%s", buf2); nlog (LOG_NORMAL, LOG_CORE, "%s", buf2);
} }
va_end(ap); va_end (ap);
} }
void Srv_Connect(char *origin, char **argv, int argc) void
Srv_Connect (char *origin, char **argv, int argc)
{ {
int i; int i;
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
if (!strcasecmp("TOKEN", argv[i])) { if (!strcasecmp ("TOKEN", argv[i])) {
me.token = 1; me.token = 1;
} }
} }
} }
void Usr_Stats(char *origin, char **argv, int argc) void
Usr_Stats (char *origin, char **argv, int argc)
{ {
User *u; User *u;
u = finduser(origin); u = finduser (origin);
if (!u) { if (!u) {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "Recieved a Message from a Unknown User! (%s)", origin);
"Recieved a Message from a Unknown User! (%s)",
origin);
return; return;
} }
ShowStats(argv[0], u); ShowStats (argv[0], u);
} }
void Usr_Version(char *origin, char **argv, int argc) void
Usr_Version (char *origin, char **argv, int argc)
{ {
snumeric_cmd(351, origin, "%d.%d.%d%s :%s -> %s %s", MAJOR, MINOR, snumeric_cmd (351, origin, "%d.%d.%d%s :%s -> %s %s", MAJOR, MINOR, REV, version, me.name, version_date, version_time);
REV, version, me.name, version_date, version_time);
} }
void Usr_ShowMOTD(char *origin, char **argv, int argc)
void
Usr_ShowMOTD (char *origin, char **argv, int argc)
{ {
ShowMOTD(origin); ShowMOTD (origin);
} }
void Usr_ShowADMIN(char *origin, char **argv, int argc)
void
Usr_ShowADMIN (char *origin, char **argv, int argc)
{ {
ShowADMIN(origin); ShowADMIN (origin);
} }
void Usr_Showcredits(char *origin, char **argv, int argc)
void
Usr_Showcredits (char *origin, char **argv, int argc)
{ {
Showcredits(origin); Showcredits (origin);
} }
void Usr_AddServer(char *origin, char **argv, int argc)
void
Usr_AddServer (char *origin, char **argv, int argc)
{ {
AddServer(argv[0], origin, atoi(argv[1])); AddServer (argv[0], origin, atoi (argv[1]));
} }
void Usr_DelServer(char *origin, char **argv, int argc)
void
Usr_DelServer (char *origin, char **argv, int argc)
{ {
DelServer(argv[0]); DelServer (argv[0]);
} }
void Usr_DelUser(char *origin, char **argv, int argc)
void
Usr_DelUser (char *origin, char **argv, int argc)
{ {
DelUser(origin); DelUser (origin);
} }
void Usr_Smode(char *origin, char **argv, int argc)
void
Usr_Smode (char *origin, char **argv, int argc)
{ {
if (!strchr(argv[0], '#')) { if (!strchr (argv[0], '#')) {
/* its user svsmode change */ /* its user svsmode change */
UserMode(argv[0], argv[1], 0); UserMode (argv[0], argv[1], 0);
} else { } else {
/* its a channel svsmode change */ /* its a channel svsmode change */
ChanMode(origin, argv, argc); ChanMode (origin, argv, argc);
} }
} }
void Usr_Mode(char *origin, char **argv, int argc) void
Usr_Mode (char *origin, char **argv, int argc)
{ {
if (!strchr(argv[0], '#')) { if (!strchr (argv[0], '#')) {
UserMode(argv[0], argv[1], 0); UserMode (argv[0], argv[1], 0);
} else { } else {
ChanMode(origin, argv, argc); ChanMode (origin, argv, argc);
} }
} }
void Usr_Kill(char *origin, char **argv, int argc) void
Usr_Kill (char *origin, char **argv, int argc)
{ {
User *u; User *u;
u = finduser(argv[0]); u = finduser (argv[0]);
if (u) { if (u) {
KillUser(argv[0]); KillUser (argv[0]);
} else { } else {
nlog(LOG_WARNING, LOG_CORE, "Can't find user %s for Kill", nlog (LOG_WARNING, LOG_CORE, "Can't find user %s for Kill", argv[0]);
argv[0]);
} }
} }
void Usr_Vhost(char *origin, char **argv, int argc) void
Usr_Vhost (char *origin, char **argv, int argc)
{ {
User *u; User *u;
u = finduser(origin); u = finduser (origin);
if (u) { if (u) {
strncpy(u->vhost, argv[0], MAXHOST); strncpy (u->vhost, argv[0], MAXHOST);
} }
} }
void Usr_Pong(char *origin, char **argv, int argc) void
Usr_Pong (char *origin, char **argv, int argc)
{ {
Server *s; Server *s;
s = findserver(argv[0]); s = findserver (argv[0]);
if (s) { if (s) {
dopong(s); dopong (s);
} else { } else {
nlog(LOG_NOTICE, LOG_CORE, nlog (LOG_NOTICE, LOG_CORE, "Received PONG from unknown server: %s", argv[0]);
"Received PONG from unknown server: %s", argv[0]);
} }
} }
void Usr_Away(char *origin, char **argv, int argc) void
Usr_Away (char *origin, char **argv, int argc)
{ {
char *buf; char *buf;
User *u = finduser(origin); User *u = finduser (origin);
if (u) { if (u) {
if (argc > 0) { if (argc > 0) {
buf = joinbuf(argv, argc, 0); buf = joinbuf (argv, argc, 0);
} else { } else {
buf = NULL; buf = NULL;
} }
Do_Away(u, buf); Do_Away (u, buf);
if (argc > 0) { if (argc > 0) {
free(buf); free (buf);
} }
} else { } else {
nlog(LOG_NOTICE, LOG_CORE, nlog (LOG_NOTICE, LOG_CORE, "Warning, Unable to find User %s for Away", origin);
"Warning, Unable to find User %s for Away", origin);
} }
} }
void Usr_Nick(char *origin, char **argv, int argc) void
Usr_Nick (char *origin, char **argv, int argc)
{ {
User *u = finduser(origin); User *u = finduser (origin);
if (u) { if (u) {
Change_User(u, argv[0]); Change_User (u, argv[0]);
} else { } else {
nlog(LOG_NOTICE, LOG_CORE, nlog (LOG_NOTICE, LOG_CORE, "Warning, Unable to find user %s for User_nick", origin);
"Warning, Unable to find user %s for User_nick",
origin);
} }
} }
void Usr_Topic(char *origin, char **argv, int argc) void
Usr_Topic (char *origin, char **argv, int argc)
{ {
char *buf; char *buf;
Chans *c; Chans *c;
c = findchan(argv[0]); c = findchan (argv[0]);
if (c) { if (c) {
buf = joinbuf(argv, argc, 3); buf = joinbuf (argv, argc, 3);
Change_Topic(argv[1], c, atoi(argv[2]), buf); Change_Topic (argv[1], c, atoi (argv[2]), buf);
free(buf); free (buf);
} else { } else {
nlog(LOG_WARNING, LOG_CORE, "Ehhh, Can't find Channel %s", nlog (LOG_WARNING, LOG_CORE, "Ehhh, Can't find Channel %s", argv[0]);
argv[0]);
} }
} }
void Usr_Kick(char *origin, char **argv, int argc) void
Usr_Kick (char *origin, char **argv, int argc)
{ {
User *u, *k; User *u, *k;
u = finduser(argv[1]); u = finduser (argv[1]);
k = finduser(origin); k = finduser (origin);
if (u) { if (u) {
kick_chan(u, argv[0], k); kick_chan (u, argv[0], k);
} else { } else {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "Waring, Can't find user %s for Kick %s", argv[1], argv[0]);
"Waring, Can't find user %s for Kick %s", argv[1],
argv[0]);
} }
} }
void Usr_Join(char *origin, char **argv, int argc) void
Usr_Join (char *origin, char **argv, int argc)
{ {
char *s, *t; char *s, *t;
t = argv[0]; t = argv[0];
while (*(s = t)) { while (*(s = t)) {
t = s + strcspn(s, ","); t = s + strcspn (s, ",");
if (*t) if (*t)
*t++ = 0; *t++ = 0;
join_chan(finduser(origin), s); join_chan (finduser (origin), s);
} }
} }
void Usr_Part(char *origin, char **argv, int argc) void
Usr_Part (char *origin, char **argv, int argc)
{ {
part_chan(finduser(origin), argv[0]); part_chan (finduser (origin), argv[0]);
} }
void Srv_Ping(char *origin, char **argv, int argc)
void
Srv_Ping (char *origin, char **argv, int argc)
{ {
spong_cmd(argv[0]); spong_cmd (argv[0]);
} }
void Srv_Netinfo(char *origin, char **argv, int argc)
void
Srv_Netinfo (char *origin, char **argv, int argc)
{ {
me.onchan = 1; me.onchan = 1;
ircd_srv.uprot = atoi(argv[2]); ircd_srv.uprot = atoi (argv[2]);
strncpy(ircd_srv.cloak, argv[3], 10); strncpy (ircd_srv.cloak, argv[3], 10);
strncpy(me.netname, argv[7], MAXPASS); strncpy (me.netname, argv[7], MAXPASS);
snetinfo_cmd(); snetinfo_cmd ();
init_ServBot(); init_ServBot ();
globops(me.name, "Link with Network \2Complete!\2"); globops (me.name, "Link with Network \2Complete!\2");
if (ircd_srv.uprot == 2109) { if (ircd_srv.uprot == 2109) {
me.usesmo = 1; me.usesmo = 1;
} }
Module_Event("NETINFO", NULL, 0); Module_Event ("NETINFO", NULL, 0);
me.synced = 1; me.synced = 1;
} }
void Srv_Pass(char *origin, char **argv, int argc) void
Srv_Pass (char *origin, char **argv, int argc)
{ {
} }
void Srv_Server(char *origin, char **argv, int argc) void
Srv_Server (char *origin, char **argv, int argc)
{ {
Server *s; Server *s;
if (*origin == 0) { if (*origin == 0) {
AddServer(argv[0], me.name, atoi(argv[1])); AddServer (argv[0], me.name, atoi (argv[1]));
} else { } else {
AddServer(argv[0], origin, atoi(argv[1])); AddServer (argv[0], origin, atoi (argv[1]));
} }
s = findserver(argv[0]); s = findserver (argv[0]);
me.s = s; me.s = s;
} }
void Srv_Squit(char *origin, char **argv, int argc)
void
Srv_Squit (char *origin, char **argv, int argc)
{ {
Server *s; Server *s;
s = findserver(argv[0]); s = findserver (argv[0]);
if (s) { if (s) {
DelServer(argv[0]); DelServer (argv[0]);
} else { } else {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "Waring, Squit from Unknown Server %s", argv[0]);
"Waring, Squit from Unknown Server %s", argv[0]);
} }
} }
/* BE REALLY CAREFULL ABOUT THE ORDER OF THESE ifdef's */ /* BE REALLY CAREFULL ABOUT THE ORDER OF THESE ifdef's */
void Srv_Nick(char *origin, char **argv, int argc) void
Srv_Nick (char *origin, char **argv, int argc)
{ {
char **av; char **av;
int ac = 0; int ac = 0;
char *realname; char *realname;
AddStringToList(&av, argv[0], &ac); AddStringToList (&av, argv[0], &ac);
AddUser(argv[0], argv[3], argv[4], argv[5], 0, AddUser (argv[0], argv[3], argv[4], argv[5], 0, strtol (argv[2], NULL, 10));
strtol(argv[2], NULL, 10)); realname = joinbuf (argv, argc, 7);
realname = joinbuf(argv, argc, 7); AddRealName (argv[0], realname);
AddRealName(argv[0], realname); free (realname);
free(realname);
} }
void Srv_Svsnick(char *origin, char **argv, int argc) void
Srv_Svsnick (char *origin, char **argv, int argc)
{ {
User *u; User *u;
u = finduser(argv[0]); u = finduser (argv[0]);
if (u) { if (u) {
Change_User(u, argv[1]); Change_User (u, argv[1]);
} else { } else {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "Can't find user %s for svsnick", argv[0]);
"Can't find user %s for svsnick", argv[0]);
} }
} }
void Srv_Kill(char *origin, char **argv, int argc) void
Srv_Kill (char *origin, char **argv, int argc)
{ {
nlog(LOG_WARNING, LOG_CORE, "Got Kill, but its unhandled."); nlog (LOG_WARNING, LOG_CORE, "Got Kill, but its unhandled.");
} }
extern int SignOn_NewBot(const char *nick, const char *user, extern int
const char *host, const char *rname, long Umode) SignOn_NewBot (const char *nick, const char *user, const char *host, const char *rname, long Umode)
{ {
snewnick_cmd(nick, user, host, rname); snewnick_cmd (nick, user, host, rname);
sumode_cmd(nick, nick, Umode); sumode_cmd (nick, nick, Umode);
if ((me.allbots > 0) || (Umode & UMODE_SERVICES)) { if ((me.allbots > 0) || (Umode & UMODE_SERVICES)) {
sjoin_cmd(nick, me.chan); sjoin_cmd (nick, me.chan);
schmode_cmd(me.name, me.chan, "+o", nick); schmode_cmd (me.name, me.chan, "+o", nick);
} }
return 1; return 1;
} }

511
Unreal.h
View file

@ -44,7 +44,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* *
* $Id: Unreal.h,v 1.32 2003/07/23 10:35:47 fishwaldo Exp $ * $Id: Unreal.h,v 1.33 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
@ -94,207 +94,207 @@
#define MSG_PRIVATE "PRIVMSG" /* PRIV */ #define MSG_PRIVATE "PRIVMSG" /* PRIV */
#define TOK_PRIVATE "!" /* 33 */ #define TOK_PRIVATE "!" /* 33 */
#define MSG_WHO "WHO" /* WHO -> WHOC */ #define MSG_WHO "WHO" /* WHO -> WHOC */
#define TOK_WHO "\"" /* 34 */ #define TOK_WHO "\"" /* 34 */
#define MSG_WHOIS "WHOIS" /* WHOI */ #define MSG_WHOIS "WHOIS" /* WHOI */
#define TOK_WHOIS "#" /* 35 */ #define TOK_WHOIS "#" /* 35 */
#define MSG_WHOWAS "WHOWAS" /* WHOW */ #define MSG_WHOWAS "WHOWAS" /* WHOW */
#define TOK_WHOWAS "$" /* 36 */ #define TOK_WHOWAS "$" /* 36 */
#define MSG_USER "USER" /* USER */ #define MSG_USER "USER" /* USER */
#define TOK_USER "%" /* 37 */ #define TOK_USER "%" /* 37 */
#define MSG_NICK "NICK" /* NICK */ #define MSG_NICK "NICK" /* NICK */
#define TOK_NICK "&" /* 38 */ #define TOK_NICK "&" /* 38 */
#define MSG_SERVER "SERVER" /* SERV */ #define MSG_SERVER "SERVER" /* SERV */
#define TOK_SERVER "'" /* 39 */ #define TOK_SERVER "'" /* 39 */
#define MSG_LIST "LIST" /* LIST */ #define MSG_LIST "LIST" /* LIST */
#define TOK_LIST "(" /* 40 */ #define TOK_LIST "(" /* 40 */
#define MSG_TOPIC "TOPIC" /* TOPI */ #define MSG_TOPIC "TOPIC" /* TOPI */
#define TOK_TOPIC ")" /* 41 */ #define TOK_TOPIC ")" /* 41 */
#define MSG_INVITE "INVITE" /* INVI */ #define MSG_INVITE "INVITE" /* INVI */
#define TOK_INVITE "*" /* 42 */ #define TOK_INVITE "*" /* 42 */
#define MSG_VERSION "VERSION" /* VERS */ #define MSG_VERSION "VERSION" /* VERS */
#define TOK_VERSION "+" /* 43 */ #define TOK_VERSION "+" /* 43 */
#define MSG_QUIT "QUIT" /* QUIT */ #define MSG_QUIT "QUIT" /* QUIT */
#define TOK_QUIT "," /* 44 */ #define TOK_QUIT "," /* 44 */
#define MSG_SQUIT "SQUIT" /* SQUI */ #define MSG_SQUIT "SQUIT" /* SQUI */
#define TOK_SQUIT "-" /* 45 */ #define TOK_SQUIT "-" /* 45 */
#define MSG_KILL "KILL" /* KILL */ #define MSG_KILL "KILL" /* KILL */
#define TOK_KILL "." /* 46 */ #define TOK_KILL "." /* 46 */
#define MSG_INFO "INFO" /* INFO */ #define MSG_INFO "INFO" /* INFO */
#define TOK_INFO "/" /* 47 */ #define TOK_INFO "/" /* 47 */
#define MSG_LINKS "LINKS" /* LINK */ #define MSG_LINKS "LINKS" /* LINK */
#define TOK_LINKS "0" /* 48 */ #define TOK_LINKS "0" /* 48 */
#define MSG_SUMMON "SUMMON" /* SUMM */ #define MSG_SUMMON "SUMMON" /* SUMM */
#define TOK_SUMMON "1" /* 49 */ #define TOK_SUMMON "1" /* 49 */
#define MSG_STATS "STATS" /* STAT */ #define MSG_STATS "STATS" /* STAT */
#define TOK_STATS "2" /* 50 */ #define TOK_STATS "2" /* 50 */
#define MSG_USERS "USERS" /* USER -> USRS */ #define MSG_USERS "USERS" /* USER -> USRS */
#define TOK_USERS "3" /* 51 */ #define TOK_USERS "3" /* 51 */
#define MSG_HELP "HELP" /* HELP */ #define MSG_HELP "HELP" /* HELP */
#define MSG_HELPOP "HELPOP" /* HELP */ #define MSG_HELPOP "HELPOP" /* HELP */
#define MSG_IRCDHELP "IRCDHELP" /* HELP */ #define MSG_IRCDHELP "IRCDHELP" /* HELP */
#define TOK_HELP "4" /* 52 */ #define TOK_HELP "4" /* 52 */
#define MSG_ERROR "ERROR" /* ERRO */ #define MSG_ERROR "ERROR" /* ERRO */
#define TOK_ERROR "5" /* 53 */ #define TOK_ERROR "5" /* 53 */
#define MSG_AWAY "AWAY" /* AWAY */ #define MSG_AWAY "AWAY" /* AWAY */
#define TOK_AWAY "6" /* 54 */ #define TOK_AWAY "6" /* 54 */
#define MSG_CONNECT "CONNECT" /* CONN */ #define MSG_CONNECT "CONNECT" /* CONN */
#define TOK_CONNECT "7" /* 55 */ #define TOK_CONNECT "7" /* 55 */
#define MSG_PING "PING" /* PING */ #define MSG_PING "PING" /* PING */
#define TOK_PING "8" /* 56 */ #define TOK_PING "8" /* 56 */
#define MSG_PONG "PONG" /* PONG */ #define MSG_PONG "PONG" /* PONG */
#define TOK_PONG "9" /* 57 */ #define TOK_PONG "9" /* 57 */
#define MSG_OPER "OPER" /* OPER */ #define MSG_OPER "OPER" /* OPER */
#define TOK_OPER ";" /* 59 */ #define TOK_OPER ";" /* 59 */
#define MSG_PASS "PASS" /* PASS */ #define MSG_PASS "PASS" /* PASS */
#define TOK_PASS "<" /* 60 */ #define TOK_PASS "<" /* 60 */
#define MSG_WALLOPS "WALLOPS" /* WALL */ #define MSG_WALLOPS "WALLOPS" /* WALL */
#define TOK_WALLOPS "=" /* 61 */ #define TOK_WALLOPS "=" /* 61 */
#define MSG_TIME "TIME" /* TIME */ #define MSG_TIME "TIME" /* TIME */
#define TOK_TIME ">" /* 62 */ #define TOK_TIME ">" /* 62 */
#define MSG_NAMES "NAMES" /* NAME */ #define MSG_NAMES "NAMES" /* NAME */
#define TOK_NAMES "?" /* 63 */ #define TOK_NAMES "?" /* 63 */
#define MSG_ADMIN "ADMIN" /* ADMI */ #define MSG_ADMIN "ADMIN" /* ADMI */
#define TOK_ADMIN "@" /* 64 */ #define TOK_ADMIN "@" /* 64 */
#define MSG_NOTICE "NOTICE" /* NOTI */ #define MSG_NOTICE "NOTICE" /* NOTI */
#define TOK_NOTICE "B" /* 66 */ #define TOK_NOTICE "B" /* 66 */
#define MSG_JOIN "JOIN" /* JOIN */ #define MSG_JOIN "JOIN" /* JOIN */
#define TOK_JOIN "C" /* 67 */ #define TOK_JOIN "C" /* 67 */
#define MSG_PART "PART" /* PART */ #define MSG_PART "PART" /* PART */
#define TOK_PART "D" /* 68 */ #define TOK_PART "D" /* 68 */
#define MSG_LUSERS "LUSERS" /* LUSE */ #define MSG_LUSERS "LUSERS" /* LUSE */
#define TOK_LUSERS "E" /* 69 */ #define TOK_LUSERS "E" /* 69 */
#define MSG_MOTD "MOTD" /* MOTD */ #define MSG_MOTD "MOTD" /* MOTD */
#define TOK_MOTD "F" /* 70 */ #define TOK_MOTD "F" /* 70 */
#define MSG_MODE "MODE" /* MODE */ #define MSG_MODE "MODE" /* MODE */
#define TOK_MODE "G" /* 71 */ #define TOK_MODE "G" /* 71 */
#define MSG_KICK "KICK" /* KICK */ #define MSG_KICK "KICK" /* KICK */
#define TOK_KICK "H" /* 72 */ #define TOK_KICK "H" /* 72 */
#define MSG_SERVICE "SERVICE" /* SERV -> SRVI */ #define MSG_SERVICE "SERVICE" /* SERV -> SRVI */
#define TOK_SERVICE "I" /* 73 */ #define TOK_SERVICE "I" /* 73 */
#define MSG_USERHOST "USERHOST" /* USER -> USRH */ #define MSG_USERHOST "USERHOST" /* USER -> USRH */
#define TOK_USERHOST "J" /* 74 */ #define TOK_USERHOST "J" /* 74 */
#define MSG_ISON "ISON" /* ISON */ #define MSG_ISON "ISON" /* ISON */
#define TOK_ISON "K" /* 75 */ #define TOK_ISON "K" /* 75 */
#define MSG_SQUERY "SQUERY" /* SQUE */ #define MSG_SQUERY "SQUERY" /* SQUE */
#define TOK_SQUERY "L" /* 76 */ #define TOK_SQUERY "L" /* 76 */
#define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */ #define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */
#define TOK_SERVLIST "M" /* 77 */ #define TOK_SERVLIST "M" /* 77 */
#define MSG_SERVSET "SERVSET" /* SERV -> SSET */ #define MSG_SERVSET "SERVSET" /* SERV -> SSET */
#define TOK_SERVSET "N" /* 78 */ #define TOK_SERVSET "N" /* 78 */
#define MSG_REHASH "REHASH" /* REHA */ #define MSG_REHASH "REHASH" /* REHA */
#define TOK_REHASH "O" /* 79 */ #define TOK_REHASH "O" /* 79 */
#define MSG_RESTART "RESTART" /* REST */ #define MSG_RESTART "RESTART" /* REST */
#define TOK_RESTART "P" /* 80 */ #define TOK_RESTART "P" /* 80 */
#define MSG_CLOSE "CLOSE" /* CLOS */ #define MSG_CLOSE "CLOSE" /* CLOS */
#define TOK_CLOSE "Q" /* 81 */ #define TOK_CLOSE "Q" /* 81 */
#define MSG_DIE "DIE" /* DIE */ #define MSG_DIE "DIE" /* DIE */
#define TOK_DIE "R" /* 82 */ #define TOK_DIE "R" /* 82 */
#define MSG_HASH "HASH" /* HASH */ #define MSG_HASH "HASH" /* HASH */
#define TOK_HASH "S" /* 83 */ #define TOK_HASH "S" /* 83 */
#define MSG_DNS "DNS" /* DNS -> DNSS */ #define MSG_DNS "DNS" /* DNS -> DNSS */
#define TOK_DNS "T" /* 84 */ #define TOK_DNS "T" /* 84 */
#define MSG_SILENCE "SILENCE" /* SILE */ #define MSG_SILENCE "SILENCE" /* SILE */
#define TOK_SILENCE "U" /* 85 */ #define TOK_SILENCE "U" /* 85 */
#define MSG_AKILL "AKILL" /* AKILL */ #define MSG_AKILL "AKILL" /* AKILL */
#define TOK_AKILL "V" /* 86 */ #define TOK_AKILL "V" /* 86 */
#define MSG_KLINE "KLINE" /* KLINE */ #define MSG_KLINE "KLINE" /* KLINE */
#define TOK_KLINE "W" /* 87 */ #define TOK_KLINE "W" /* 87 */
#define MSG_UNKLINE "UNKLINE" /* UNKLINE */ #define MSG_UNKLINE "UNKLINE" /* UNKLINE */
#define TOK_UNKLINE "X" /* 88 */ #define TOK_UNKLINE "X" /* 88 */
#define MSG_RAKILL "RAKILL" /* RAKILL */ #define MSG_RAKILL "RAKILL" /* RAKILL */
#define TOK_RAKILL "Y" /* 89 */ #define TOK_RAKILL "Y" /* 89 */
#define MSG_GNOTICE "GNOTICE" /* GNOTICE */ #define MSG_GNOTICE "GNOTICE" /* GNOTICE */
#define TOK_GNOTICE "Z" /* 90 */ #define TOK_GNOTICE "Z" /* 90 */
#define MSG_GOPER "GOPER" /* GOPER */ #define MSG_GOPER "GOPER" /* GOPER */
#define TOK_GOPER "[" /* 91 */ #define TOK_GOPER "[" /* 91 */
#define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */ #define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */
#define TOK_GLOBOPS "]" /* 93 */ #define TOK_GLOBOPS "]" /* 93 */
#define MSG_LOCOPS "LOCOPS" /* LOCOPS */ #define MSG_LOCOPS "LOCOPS" /* LOCOPS */
#define TOK_LOCOPS "^" /* 94 */ #define TOK_LOCOPS "^" /* 94 */
#define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */ #define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */
#define TOK_PROTOCTL "_" /* 95 */ #define TOK_PROTOCTL "_" /* 95 */
#define MSG_WATCH "WATCH" /* WATCH */ #define MSG_WATCH "WATCH" /* WATCH */
#define TOK_WATCH "`" /* 96 */ #define TOK_WATCH "`" /* 96 */
#define MSG_TRACE "TRACE" /* TRAC */ #define MSG_TRACE "TRACE" /* TRAC */
#define TOK_TRACE "b" /* 97 */ #define TOK_TRACE "b" /* 97 */
#define MSG_SQLINE "SQLINE" /* SQLINE */ #define MSG_SQLINE "SQLINE" /* SQLINE */
#define TOK_SQLINE "c" /* 98 */ #define TOK_SQLINE "c" /* 98 */
#define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */ #define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */
#define TOK_UNSQLINE "d" /* 99 */ #define TOK_UNSQLINE "d" /* 99 */
#define MSG_SVSNICK "SVSNICK" /* SVSNICK */ #define MSG_SVSNICK "SVSNICK" /* SVSNICK */
#define TOK_SVSNICK "e" /* 100 */ #define TOK_SVSNICK "e" /* 100 */
#define MSG_SVSNOOP "SVSNOOP" /* SVSNOOP */ #define MSG_SVSNOOP "SVSNOOP" /* SVSNOOP */
#define TOK_SVSNOOP "f" /* 101 */ #define TOK_SVSNOOP "f" /* 101 */
#define MSG_IDENTIFY "IDENTIFY" /* IDENTIFY */ #define MSG_IDENTIFY "IDENTIFY" /* IDENTIFY */
#define TOK_IDENTIFY "g" /* 102 */ #define TOK_IDENTIFY "g" /* 102 */
#define MSG_SVSKILL "SVSKILL" /* SVSKILL */ #define MSG_SVSKILL "SVSKILL" /* SVSKILL */
#define TOK_SVSKILL "h" /* 103 */ #define TOK_SVSKILL "h" /* 103 */
#define MSG_NICKSERV "NICKSERV" /* NICKSERV */ #define MSG_NICKSERV "NICKSERV" /* NICKSERV */
#define MSG_NS "NS" #define MSG_NS "NS"
#define TOK_NICKSERV "i" /* 104 */ #define TOK_NICKSERV "i" /* 104 */
#define MSG_CHANSERV "CHANSERV" /* CHANSERV */ #define MSG_CHANSERV "CHANSERV" /* CHANSERV */
#define MSG_CS "CS" #define MSG_CS "CS"
#define TOK_CHANSERV "j" /* 105 */ #define TOK_CHANSERV "j" /* 105 */
#define MSG_OPERSERV "OPERSERV" /* OPERSERV */ #define MSG_OPERSERV "OPERSERV" /* OPERSERV */
#define MSG_OS "OS" #define MSG_OS "OS"
#define TOK_OPERSERV "k" /* 106 */ #define TOK_OPERSERV "k" /* 106 */
#define MSG_MEMOSERV "MEMOSERV" /* MEMOSERV */ #define MSG_MEMOSERV "MEMOSERV" /* MEMOSERV */
#define MSG_MS "MS" #define MSG_MS "MS"
#define TOK_MEMOSERV "l" /* 107 */ #define TOK_MEMOSERV "l" /* 107 */
#define MSG_SERVICES "SERVICES" /* SERVICES */ #define MSG_SERVICES "SERVICES" /* SERVICES */
#define TOK_SERVICES "m" /* 108 */ #define TOK_SERVICES "m" /* 108 */
#define MSG_SVSMODE "SVSMODE" /* SVSMODE */ #define MSG_SVSMODE "SVSMODE" /* SVSMODE */
#define TOK_SVSMODE "n" /* 109 */ #define TOK_SVSMODE "n" /* 109 */
#define MSG_SAMODE "SAMODE" /* SAMODE */ #define MSG_SAMODE "SAMODE" /* SAMODE */
#define TOK_SAMODE "o" /* 110 */ #define TOK_SAMODE "o" /* 110 */
#define MSG_CHATOPS "CHATOPS" /* CHATOPS */ #define MSG_CHATOPS "CHATOPS" /* CHATOPS */
#define TOK_CHATOPS "p" /* 111 */ #define TOK_CHATOPS "p" /* 111 */
#define MSG_ZLINE "ZLINE" /* ZLINE */ #define MSG_ZLINE "ZLINE" /* ZLINE */
#define TOK_ZLINE "q" /* 112 */ #define TOK_ZLINE "q" /* 112 */
#define MSG_UNZLINE "UNZLINE" /* UNZLINE */ #define MSG_UNZLINE "UNZLINE" /* UNZLINE */
#define TOK_UNZLINE "r" /* 113 */ #define TOK_UNZLINE "r" /* 113 */
#define MSG_HELPSERV "HELPSERV" /* HELPSERV */ #define MSG_HELPSERV "HELPSERV" /* HELPSERV */
#define MSG_HS "HS" #define MSG_HS "HS"
#define TOK_HELPSERV "s" /* 114 */ #define TOK_HELPSERV "s" /* 114 */
#define MSG_RULES "RULES" /* RULES */ #define MSG_RULES "RULES" /* RULES */
#define TOK_RULES "t" /* 115 */ #define TOK_RULES "t" /* 115 */
#define MSG_MAP "MAP" /* MAP */ #define MSG_MAP "MAP" /* MAP */
#define TOK_MAP "u" /* 117 */ #define TOK_MAP "u" /* 117 */
#define MSG_SVS2MODE "SVS2MODE" /* SVS2MODE */ #define MSG_SVS2MODE "SVS2MODE" /* SVS2MODE */
#define TOK_SVS2MODE "v" /* 118 */ #define TOK_SVS2MODE "v" /* 118 */
#define MSG_DALINFO "DALINFO" /* dalinfo */ #define MSG_DALINFO "DALINFO" /* dalinfo */
#define TOK_DALINFO "w" /* 119 */ #define TOK_DALINFO "w" /* 119 */
#define MSG_ADMINCHAT "ADCHAT" /* Admin chat */ #define MSG_ADMINCHAT "ADCHAT" /* Admin chat */
#define TOK_ADMINCHAT "x" /* 120 */ #define TOK_ADMINCHAT "x" /* 120 */
#define MSG_MKPASSWD "MKPASSWD" /* MKPASSWD */ #define MSG_MKPASSWD "MKPASSWD" /* MKPASSWD */
#define TOK_MKPASSWD "y" /* 121 */ #define TOK_MKPASSWD "y" /* 121 */
#define MSG_ADDLINE "ADDLINE" /* ADDLINE */ #define MSG_ADDLINE "ADDLINE" /* ADDLINE */
#define TOK_ADDLINE "z" /* 122 */ #define TOK_ADDLINE "z" /* 122 */
#define MSG_SNOTES "SNOTES" /* Read server notes */ #define MSG_SNOTES "SNOTES" /* Read server notes */
#define TOK_SNOTES "{" /* 123 */ #define TOK_SNOTES "{" /* 123 */
#define MSG_SNOTE "SNOTE" /* Write server note */ #define MSG_SNOTE "SNOTE" /* Write server note */
#define TOK_SNOTE "|" /* 124 */ #define TOK_SNOTE "|" /* 124 */
#define MSG_GLINE "GLINE" /* The awesome g-line */ #define MSG_GLINE "GLINE" /* The awesome g-line */
#define TOK_GLINE "}" /* 125 */ #define TOK_GLINE "}" /* 125 */
#define MSG_REMGLINE "REMGLINE" /* remove g-line */ #define MSG_REMGLINE "REMGLINE" /* remove g-line */
#define TOK_REMGLINE "~" /* 126 */ #define TOK_REMGLINE "~" /* 126 */
#define MSG_SETHOST "SETHOST" /* sethost */ #define MSG_SETHOST "SETHOST" /* sethost */
#define TOK_SETHOST "AA" /* 127 4ever !;) */ #define TOK_SETHOST "AA" /* 127 4ever !;) */
#define MSG_TECHAT "TECHAT" /* techadmin chat */ #define MSG_TECHAT "TECHAT" /* techadmin chat */
#define TOK_TECHAT "AB" /* questionmark? */ #define TOK_TECHAT "AB" /* questionmark? */
#define MSG_NACHAT "NACHAT" /* netadmin chat */ #define MSG_NACHAT "NACHAT" /* netadmin chat */
#define TOK_NACHAT "AC" /* *beep* */ #define TOK_NACHAT "AC" /* *beep* */
#define MSG_SETIDENT "SETIDENT" /* set ident */ #define MSG_SETIDENT "SETIDENT" /* set ident */
#define TOK_SETIDENT "AD" /* good old BASIC ;P */ #define TOK_SETIDENT "AD" /* good old BASIC ;P */
#define MSG_SETNAME "SETNAME" /* set GECOS */ #define MSG_SETNAME "SETNAME" /* set GECOS */
#define TOK_SETNAME "AE" /* its almost unreeaaall... */ #define TOK_SETNAME "AE" /* its almost unreeaaall... */
#define MSG_LAG "LAG" /* Lag detect */ #define MSG_LAG "LAG" /* Lag detect */
#define TOK_LAG "AF" /* a or ? */ #define TOK_LAG "AF" /* a or ? */
#define MSG_SDESC "SDESC" /* set description */ #define MSG_SDESC "SDESC" /* set description */
#define TOK_SDESC "AG" #define TOK_SDESC "AG"
#define MSG_STATSERV "STATSERV" /* alias */ #define MSG_STATSERV "STATSERV" /* alias */
#define TOK_STATSERV "AH" #define TOK_STATSERV "AH"
#define MSG_KNOCK "KNOCK" #define MSG_KNOCK "KNOCK"
#define TOK_KNOCK "AI" #define TOK_KNOCK "AI"
@ -345,38 +345,38 @@
#define UMODE_INVISIBLE 0x0001 /* makes user invisible */ #define UMODE_INVISIBLE 0x0001 /* makes user invisible */
#define UMODE_OPER 0x0002 /* Operator */ #define UMODE_OPER 0x0002 /* Operator */
#define UMODE_WALLOP 0x0004 /* send wallops to them */ #define UMODE_WALLOP 0x0004 /* send wallops to them */
#define UMODE_FAILOP 0x0008 /* Shows some global messages */ #define UMODE_FAILOP 0x0008 /* Shows some global messages */
#define UMODE_HELPOP 0x0010 /* Help system operator */ #define UMODE_HELPOP 0x0010 /* Help system operator */
#define UMODE_REGNICK 0x0020 /* Nick set by services as registered */ #define UMODE_REGNICK 0x0020 /* Nick set by services as registered */
#define UMODE_SADMIN 0x0040 /* Services Admin */ #define UMODE_SADMIN 0x0040 /* Services Admin */
#define UMODE_ADMIN 0x0080 /* Admin */ #define UMODE_ADMIN 0x0080 /* Admin */
#define UMODE_SERVNOTICE 0x0100 /* server notices such as kill */ #define UMODE_SERVNOTICE 0x0100 /* server notices such as kill */
#define UMODE_LOCOP 0x0200 /* Local operator -- SRB */ #define UMODE_LOCOP 0x0200 /* Local operator -- SRB */
#define UMODE_KILLS 0x0400 /* Show server-kills... */ #define UMODE_KILLS 0x0400 /* Show server-kills... */
#define UMODE_CLIENT 0x0800 /* Show client information */ #define UMODE_CLIENT 0x0800 /* Show client information */
#define UMODE_FLOOD 0x1000 /* Receive flood warnings */ #define UMODE_FLOOD 0x1000 /* Receive flood warnings */
#define UMODE_CHATOP 0x2000 /* can receive chatops */ #define UMODE_CHATOP 0x2000 /* can receive chatops */
#define UMODE_SERVICES 0x4000 /* services */ #define UMODE_SERVICES 0x4000 /* services */
#define UMODE_HIDE 0x8000 /* Hide from Nukes */ #define UMODE_HIDE 0x8000 /* Hide from Nukes */
#define UMODE_NETADMIN 0x10000 /* Network Admin */ #define UMODE_NETADMIN 0x10000 /* Network Admin */
#define UMODE_EYES 0x20000 /* Mode to see server stuff */ #define UMODE_EYES 0x20000 /* Mode to see server stuff */
#define UMODE_TECHADMIN 0x40000 /* Tech Admin */ #define UMODE_TECHADMIN 0x40000 /* Tech Admin */
#define UMODE_COADMIN 0x80000 /* Co Admin */ #define UMODE_COADMIN 0x80000 /* Co Admin */
#define UMODE_WHOIS 0x100000 /* gets notice on /whois */ #define UMODE_WHOIS 0x100000 /* gets notice on /whois */
#define UMODE_KIX 0x200000 /* usermode +q #define UMODE_KIX 0x200000 /* usermode +q
cannot be kicked from any channel cannot be kicked from any channel
except by U:Lines except by U:Lines
*/ */
#define UMODE_BOT 0x400000 /* User is a bot */ #define UMODE_BOT 0x400000 /* User is a bot */
#define UMODE_CODER 0x800000 /* User is a network coder */ #define UMODE_CODER 0x800000 /* User is a network coder */
#define UMODE_FCLIENT 0x1000000 /* recieve client on far connects.. */ #define UMODE_FCLIENT 0x1000000 /* recieve client on far connects.. */
#define UMODE_HIDING 0x2000000 /* Totally invisible .. */ #define UMODE_HIDING 0x2000000 /* Totally invisible .. */
#define UMODE_AGENT 0x4000000 /* Is an IRCd Agent local only */ #define UMODE_AGENT 0x4000000 /* Is an IRCd Agent local only */
#define UMODE_DEAF 0x8000000 /* User can't here anything in channel */ #define UMODE_DEAF 0x8000000 /* User can't here anything in channel */
@ -428,8 +428,8 @@ struct ircd_srv_ {
typedef struct { typedef struct {
long mode; long mode;
char flag; char flag;
unsigned nickparam : 1; /* 1 = yes 0 = no */ unsigned nickparam:1; /* 1 = yes 0 = no */
unsigned parameters : 1; unsigned parameters:1;
char sjoin; char sjoin;
} aCtab; } aCtab;
@ -451,74 +451,73 @@ Oper_Modes susr_mds[0];
/* function declarations */ /* function declarations */
extern void init_ircd(); extern void init_ircd ();
extern void chanalert(char *,char *, ...); extern void chanalert (char *, char *, ...);
extern int sserver_cmd(const char *, const int numeric, const char *); extern int sserver_cmd (const char *, const int numeric, const char *);
extern int slogin_cmd(const char *, const int numeric, const char *, const char *); extern int slogin_cmd (const char *, const int numeric, const char *, const char *);
extern int ssquit_cmd(const char *); extern int ssquit_cmd (const char *);
extern int sprotocol_cmd(const char *); extern int sprotocol_cmd (const char *);
extern int squit_cmd(const char *, const char *); extern int squit_cmd (const char *, const char *);
extern int spart_cmd(const char *, const char *); extern int spart_cmd (const char *, const char *);
extern int sjoin_cmd(const char *, const char *); extern int sjoin_cmd (const char *, const char *);
extern int schmode_cmd(const char *, const char *, const char *, const char *); extern int schmode_cmd (const char *, const char *, const char *, const char *);
extern int snewnick_cmd(const char *, const char *, const char *, const char *); extern int snewnick_cmd (const char *, const char *, const char *, const char *);
extern int sping_cmd(const char *from, const char *reply, const char *to); extern int sping_cmd (const char *from, const char *reply, const char *to);
extern int sumode_cmd(const char *who, const char *target, long mode); extern int sumode_cmd (const char *who, const char *target, long mode);
extern int snumeric_cmd(const int numeric, const char *target, const char *data,...); extern int snumeric_cmd (const int numeric, const char *target, const char *data, ...);
extern int spong_cmd(const char *reply); extern int spong_cmd (const char *reply);
extern int snetinfo_cmd(); extern int snetinfo_cmd ();
extern int skill_cmd(const char *from, const char *target, const char *reason,...); extern int skill_cmd (const char *from, const char *target, const char *reason, ...);
extern int ssvskill_cmd(const char *who, const char *reason, ...); extern int ssvskill_cmd (const char *who, const char *reason, ...);
extern int ssmo_cmd(const char *from, const char *umodetarget, const char *msg); extern int ssmo_cmd (const char *from, const char *umodetarget, const char *msg);
extern int snick_cmd(const char *oldnick, const char *newnick); extern int snick_cmd (const char *oldnick, const char *newnick);
extern int sswhois_cmd(const char *target, const char *swhois); extern int sswhois_cmd (const char *target, const char *swhois);
extern int ssvsnick_cmd(const char *target, const char *newnick); extern int ssvsnick_cmd (const char *target, const char *newnick);
extern int ssvsjoin_cmd(const char *target, const char *chan); extern int ssvsjoin_cmd (const char *target, const char *chan);
extern int ssvspart_cmd(const char *target, const char *chan); extern int ssvspart_cmd (const char *target, const char *chan);
extern int ssvshost_cmd(const char *who, const char *vhost); extern int ssvshost_cmd (const char *who, const char *vhost);
extern int skick_cmd(const char *who, const char *target, const char *chan, const char *reason); extern int skick_cmd (const char *who, const char *target, const char *chan, const char *reason);
extern int swallops_cmd(const char *who, const char *msg,...); extern int swallops_cmd (const char *who, const char *msg, ...);
extern int ssvsmode_cmd(const char *target, const char *modes); extern int ssvsmode_cmd (const char *target, const char *modes);
extern int ssvshost_cmd(const char *who, const char *vhost); extern int ssvshost_cmd (const char *who, const char *vhost);
extern int ssvskill_cmd(const char *target, const char *reason, ...); extern int ssvskill_cmd (const char *target, const char *reason, ...);
extern int sakill_cmd(const char *host, const char *ident, const char *setby, const int length, const char *reason,...); extern int sakill_cmd (const char *host, const char *ident, const char *setby, const int length, const char *reason, ...);
extern int srakill_cmd(const char *host, const char *ident); extern int srakill_cmd (const char *host, const char *ident);
extern int SignOn_NewBot(const char *, const char *, const char *, const char *, long); extern int SignOn_NewBot (const char *, const char *, const char *, const char *, long);
void Usr_Version(char *, char **, int argc); void Usr_Version (char *, char **, int argc);
void Usr_ShowMOTD(char *, char **, int argc); void Usr_ShowMOTD (char *, char **, int argc);
void Usr_ShowADMIN(char *, char **, int argc); void Usr_ShowADMIN (char *, char **, int argc);
void Usr_Showcredits(char *, char **, int argc); void Usr_Showcredits (char *, char **, int argc);
void Usr_AddServer(char *, char **, int argc); void Usr_AddServer (char *, char **, int argc);
void Usr_DelServer(char *, char **, int argc); void Usr_DelServer (char *, char **, int argc);
void Usr_DelUser(char *, char **, int argc); void Usr_DelUser (char *, char **, int argc);
void Usr_Mode(char *, char **, int argc); void Usr_Mode (char *, char **, int argc);
void Usr_Smode(char *, char **, int argc); void Usr_Smode (char *, char **, int argc);
void Usr_Kill(char *, char **, int argc); void Usr_Kill (char *, char **, int argc);
void Usr_Pong(char *, char **, int argc); void Usr_Pong (char *, char **, int argc);
void Usr_Away(char *, char **, int argc); void Usr_Away (char *, char **, int argc);
void Usr_Nick(char *, char **, int argc); void Usr_Nick (char *, char **, int argc);
void Usr_Topic(char *, char **, int argc); void Usr_Topic (char *, char **, int argc);
void Usr_Kick(char *, char **, int argc); void Usr_Kick (char *, char **, int argc);
void Usr_Join(char *, char **, int argc); void Usr_Join (char *, char **, int argc);
void Usr_Part(char *, char **, int argc); void Usr_Part (char *, char **, int argc);
void Usr_Stats(char *, char **, int argc); void Usr_Stats (char *, char **, int argc);
void Usr_Vhost(char *, char **, int argc); void Usr_Vhost (char *, char **, int argc);
void Srv_Topic(char *, char **, int argc); void Srv_Topic (char *, char **, int argc);
void Srv_Ping(char *, char **, int argc); void Srv_Ping (char *, char **, int argc);
void Srv_Netinfo(char *, char **, int argc); void Srv_Netinfo (char *, char **, int argc);
void Srv_Pass(char *, char **, int argc); void Srv_Pass (char *, char **, int argc);
void Srv_Server(char *, char **, int argc); void Srv_Server (char *, char **, int argc);
void Srv_Squit(char *, char **, int argc); void Srv_Squit (char *, char **, int argc);
void Srv_Nick(char *, char **, int argc); void Srv_Nick (char *, char **, int argc);
void Srv_Svsnick(char *, char **, int argc); void Srv_Svsnick (char *, char **, int argc);
void Srv_Kill(char *, char **, int argc); void Srv_Kill (char *, char **, int argc);
void Srv_Connect(char *, char **, int argc); void Srv_Connect (char *, char **, int argc);
void Srv_Svinfo(char *, char **, int argc); void Srv_Svinfo (char *, char **, int argc);
void Srv_Burst(char *origin, char **argv, int argc); void Srv_Burst (char *origin, char **argv, int argc);
void Srv_Sjoin(char *origin, char **argv, int argc); void Srv_Sjoin (char *origin, char **argv, int argc);
int SignOn_NewBot(const char *, const char *, const char *, const char *, long); int SignOn_NewBot (const char *, const char *, const char *, const char *, long);
#endif /* UNREAL_H Define */ #endif /* UNREAL_H Define */

View file

@ -17,19 +17,20 @@
/* Define if we want to include rpc/types.h. Crap BSDs put INADDR_LOOPBACK there. */ /* Define if we want to include rpc/types.h. Crap BSDs put INADDR_LOOPBACK there. */
#undef HAVEUSE_RPCTYPES_H #undef HAVEUSE_RPCTYPES_H
@BOTTOM@ @ BOTTOM @
/* Use the definitions: */ /* Use the definitions: */
#ifndef HAVE_INLINE #ifndef HAVE_INLINE
#define inline #define inline
#endif #endif
#ifdef HAVE_POLL #ifdef HAVE_POLL
#include <sys/poll.h> #include <sys/poll.h>
#else #else
/* kludge it up */ /* kludge it up */
struct pollfd { int fd; short events; short revents; }; struct pollfd {
int fd;
short events;
short revents;
};
#define POLLIN 1 #define POLLIN 1
#define POLLPRI 2 #define POLLPRI 2
#define POLLOUT 4 #define POLLOUT 4

675
chans.c

File diff suppressed because it is too large Load diff

116
conf.c
View file

@ -20,7 +20,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: conf.c,v 1.25 2003/06/13 13:11:48 fishwaldo Exp $ ** $Id: conf.c,v 1.26 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
#include "stats.h" #include "stats.h"
@ -29,8 +29,8 @@
#include "dl.h" #include "dl.h"
#include "log.h" #include "log.h"
static void cb_Server(char *, int); static void cb_Server (char *, int);
static void cb_Module(char *, int); static void cb_Module (char *, int);
/** @brief The list of modules to load /** @brief The list of modules to load
*/ */
static void *load_mods[NUM_MODULES]; static void *load_mods[NUM_MODULES];
@ -68,7 +68,8 @@ static config_option options[] = {
* @return Nothing * @return Nothing
*/ */
void init_conf() void
init_conf ()
{ {
} }
@ -80,12 +81,13 @@ void init_conf()
* @retval line the stripped line * @retval line the stripped line
*/ */
void strip(char *line) void
strip (char *line)
{ {
char *c; char *c;
if ((c = strchr(line, '\n'))) if ((c = strchr (line, '\n')))
*c = '\0'; *c = '\0';
if ((c = strchr(line, '\r'))) if ((c = strchr (line, '\r')))
*c = '\0'; *c = '\0';
} }
@ -98,39 +100,35 @@ void strip(char *line)
*/ */
void ConfLoad() void
ConfLoad ()
{ {
/* Read in the Config File */ /* Read in the Config File */
printf("Reading the Config File. Please wait.....\n"); printf ("Reading the Config File. Please wait.....\n");
if (!config_read("neostats.cfg", options) == 0) { if (!config_read ("neostats.cfg", options) == 0) {
printf printf ("***************************************************\n");
("***************************************************\n"); printf ("* Error! *\n");
printf printf ("* *\n");
("* Error! *\n"); printf ("* Config File not found, or Unable to Open *\n");
printf printf ("* Please check its Location, and try again *\n");
("* *\n"); printf ("* *\n");
printf printf ("* NeoStats NOT Started *\n");
("* Config File not found, or Unable to Open *\n"); printf ("***************************************************\n");
printf
("* Please check its Location, and try again *\n");
printf
("* *\n");
printf
("* NeoStats NOT Started *\n");
printf
("***************************************************\n");
/* no need to call do_exit, we havn't even started! */ /* no need to call do_exit, we havn't even started! */
exit(0); exit (0);
} }
printf("Sucessfully Loaded Config File, Now Booting NeoStats\n"); printf ("Sucessfully Loaded Config File, Now Booting NeoStats\n");
#ifdef EXTAUTH #ifdef EXTAUTH
load_module("extauth", NULL); load_module ("extauth", NULL);
#endif #endif
/* if all bots should join the chan */ /* if all bots should join the chan */
if (GetConf((void *) &me.allbots, CFGBOOL, "AllBotsJoinChan") <= 0) { if (GetConf ((void *) &me.allbots, CFGBOOL, "AllBotsJoinChan") <= 0) {
me.allbots = 0; me.allbots = 0;
} }
if (GetConf ((void *) &me.pingtime, CFGINT, "PingServerTime") <= 0) {
me.pingtime = 120;
}
done_mods = 0; done_mods = 0;
} }
@ -144,19 +142,19 @@ void ConfLoad()
* @returns Nothing * @returns Nothing
*/ */
void cb_Module(char *arg, int configtype) void
cb_Module (char *arg, int configtype)
{ {
int i; int i;
strcpy(segv_location, "cb_Module"); strcpy (segv_location, "cb_Module");
if (!config.modnoload) { if (!config.modnoload) {
for (i = 1; (i < NUM_MODULES) && (load_mods[i] != 0); i++) { for (i = 1; (i < NUM_MODULES) && (load_mods[i] != 0); i++) {
if (!strcasecmp(load_mods[i], arg)) { if (!strcasecmp (load_mods[i], arg)) {
return; return;
} }
} }
load_mods[i] = sstrdup(arg); load_mods[i] = sstrdup (arg);
nlog(LOG_NORMAL, LOG_CORE, "Added Module %d :%s", i, nlog (LOG_NORMAL, LOG_CORE, "Added Module %d :%s", i, load_mods[i]);
load_mods[i]);
} }
} }
@ -168,25 +166,21 @@ void cb_Module(char *arg, int configtype)
* @bugs if a single module fails to load, it stops trying to load any other modules * @bugs if a single module fails to load, it stops trying to load any other modules
*/ */
int init_modules() int
init_modules ()
{ {
int i; int i;
int rval; int rval;
strcpy(segv_location, "init_modules"); strcpy (segv_location, "init_modules");
for (i = 1; (i < NUM_MODULES) && (load_mods[i] != 0); i++) { for (i = 1; (i < NUM_MODULES) && (load_mods[i] != 0); i++) {
nlog(LOG_DEBUG1, LOG_CORE, "Loading Module %s", nlog (LOG_DEBUG1, LOG_CORE, "Loading Module %s", load_mods[i]);
load_mods[i]); rval = load_module (load_mods[i], NULL);
rval = load_module(load_mods[i], NULL);
if (!rval) { if (!rval) {
nlog(LOG_NORMAL, LOG_CORE, nlog (LOG_NORMAL, LOG_CORE, "Successfully Loaded Module %s", load_mods[i]);
"Successfully Loaded Module %s",
load_mods[i]);
} else { } else {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "Could Not Load Module %s, Please check above error Messages", load_mods[i]);
"Could Not Load Module %s, Please check above error Messages",
load_mods[i]);
} }
} }
return 1; return 1;
@ -201,46 +195,47 @@ int init_modules()
* @param configtype the index of the variable being called now * @param configtype the index of the variable being called now
* @returns Nothing * @returns Nothing
*/ */
void cb_Server(char *arg, int configtype) void
cb_Server (char *arg, int configtype)
{ {
if (configtype == 0) { if (configtype == 0) {
/* Server name */ /* Server name */
memcpy(me.name, arg, sizeof(me.name)); memcpy (me.name, arg, sizeof (me.name));
} else if (configtype == 1) { } else if (configtype == 1) {
/* Server Port */ /* Server Port */
me.port = atoi(arg); me.port = atoi (arg);
} else if (configtype == 2) { } else if (configtype == 2) {
/* Connect To */ /* Connect To */
memcpy(me.uplink, arg, sizeof(me.uplink)); memcpy (me.uplink, arg, sizeof (me.uplink));
} else if (configtype == 3) { } else if (configtype == 3) {
/* Connect Pass */ /* Connect Pass */
memcpy(me.pass, arg, sizeof(me.pass)); memcpy (me.pass, arg, sizeof (me.pass));
} else if (configtype == 4) { } else if (configtype == 4) {
/* Server InfoLine */ /* Server InfoLine */
memcpy(me.infoline, arg, sizeof(me.infoline)); memcpy (me.infoline, arg, sizeof (me.infoline));
} else if (configtype == 5) { } else if (configtype == 5) {
/* NetName */ /* NetName */
memcpy(me.netname, arg, sizeof(me.netname)); memcpy (me.netname, arg, sizeof (me.netname));
} else if (configtype == 6) { } else if (configtype == 6) {
/* Reconnect time */ /* Reconnect time */
me.r_time = atoi(arg); me.r_time = atoi (arg);
} else if (configtype == 7) { } else if (configtype == 7) {
/* NeoStat Host */ /* NeoStat Host */
memcpy(Servbot.host, arg, sizeof(Servbot.host)); memcpy (Servbot.host, arg, sizeof (Servbot.host));
} else if (configtype == 8) { } else if (configtype == 8) {
/* NeoStat User */ /* NeoStat User */
memcpy(Servbot.user, arg, sizeof(Servbot.user)); memcpy (Servbot.user, arg, sizeof (Servbot.user));
} else if (configtype == 9) { } else if (configtype == 9) {
me.want_privmsg = 1; me.want_privmsg = 1;
} else if (configtype == 10) { } else if (configtype == 10) {
memcpy(me.chan, arg, sizeof(me.chan)); memcpy (me.chan, arg, sizeof (me.chan));
} else if (configtype == 11) { } else if (configtype == 11) {
me.onlyopers = 1; me.onlyopers = 1;
} else if (configtype == 12) { } else if (configtype == 12) {
me.die = 1; me.die = 1;
} else if (configtype == 13) { } else if (configtype == 13) {
memcpy(me.local, arg, sizeof(me.local)); memcpy (me.local, arg, sizeof (me.local));
} }
} }
@ -253,7 +248,8 @@ void cb_Server(char *arg, int configtype)
* @returns Nothing * @returns Nothing
*/ */
void rehash() void
rehash ()
{ {
/* nothing, yet */ /* nothing, yet */
} }

16
conf.h
View file

@ -20,7 +20,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: conf.h,v 1.5 2003/05/26 09:18:28 fishwaldo Exp $ ** $Id: conf.h,v 1.6 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
@ -45,17 +45,17 @@ struct config {
/* debug level */ /* debug level */
unsigned int debug; unsigned int debug;
/* enable recv.log */ /* enable recv.log */
unsigned int recvlog : 1; unsigned int recvlog:1;
/* dont load modules on startup */ /* dont load modules on startup */
unsigned int modnoload : 1; unsigned int modnoload:1;
/* dont output anything on start */ /* dont output anything on start */
unsigned int quiet : 1; unsigned int quiet:1;
/* dont detach into background */ /* dont detach into background */
unsigned int foreground : 1; unsigned int foreground:1;
} config; } config;
int GetConf(void **data, int type, const char *item); int GetConf (void **data, int type, const char *item);
int SetConf(void *data, int type, char *item); int SetConf (void *data, int type, char *item);
int GetDir(char *item, char ***data); int GetDir (char *item, char ***data);
#endif #endif

733
dl.c

File diff suppressed because it is too large Load diff

64
dl.h
View file

@ -20,7 +20,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: dl.h,v 1.27 2003/07/11 13:43:27 fishwaldo Exp $ ** $Id: dl.h,v 1.28 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
@ -40,22 +40,22 @@
#include "stats.h" #include "stats.h"
#ifndef RTLD_NOW #ifndef RTLD_NOW
#define RTLD_NOW RTLD_LAZY /* openbsd deficiency */ #define RTLD_NOW RTLD_LAZY /* openbsd deficiency */
#endif #endif
#ifndef RTLD_GLOBAL #ifndef RTLD_GLOBAL
#define RTLD_GLOBAL 0 #define RTLD_GLOBAL 0
#endif #endif
extern char *sftime(time_t); extern char *sftime (time_t);
struct sock_list_struct { struct sock_list_struct {
long hash; long hash;
int sock_no; int sock_no;
char sockname[MAXHOST]; char sockname[MAXHOST];
int (*readfnc)(int sock_no, char *sockname); int (*readfnc) (int sock_no, char *sockname);
int (*writefnc)(int sock_no, char *sockname); int (*writefnc) (int sock_no, char *sockname);
int (*errfnc)(int sock_no, char *sockname); int (*errfnc) (int sock_no, char *sockname);
char modname[MAXHOST]; char modname[MAXHOST];
long rmsgs; long rmsgs;
long rbytes; long rbytes;
@ -69,7 +69,7 @@ struct mod_timer_list {
char timername[MAXHOST]; char timername[MAXHOST];
int interval; int interval;
time_t lastrun; time_t lastrun;
int (*function)(); int (*function) ();
}; };
typedef struct mod_timer_list Mod_Timer; typedef struct mod_timer_list Mod_Timer;
hash_t *th; hash_t *th;
@ -78,8 +78,8 @@ struct mod_user_list {
long hash; long hash;
char nick[MAXNICK]; char nick[MAXNICK];
char modname[MAXHOST]; char modname[MAXHOST];
int (*function)(char *origin, char **av, int ac); int (*function) (char *origin, char **av, int ac);
int (*chanfunc)(char *origin, char *chan, char **av, int ac); int (*chanfunc) (char *origin, char *chan, char **av, int ac);
hash_t *chanlist; hash_t *chanlist;
}; };
@ -97,13 +97,13 @@ hash_t *bch;
struct functions { struct functions {
char *cmd_name; char *cmd_name;
int (*function)(char *origin, char **av, int ac); int (*function) (char *origin, char **av, int ac);
int srvmsg; int srvmsg;
}; };
struct evtfunctions { struct evtfunctions {
char *cmd_name; char *cmd_name;
int (*function)(char **av, int ac); int (*function) (char **av, int ac);
}; };
@ -138,25 +138,25 @@ struct mod_num {
struct mod_num ModNum[NUM_MODULES]; struct mod_num ModNum[NUM_MODULES];
extern void __init_mod_list(); extern void __init_mod_list ();
extern int load_module(char *path,User *u); extern int load_module (char *path, User * u);
extern int unload_module(char *module_name,User *u); extern int unload_module (char *module_name, User * u);
extern int add_ld_path(char *path); extern int add_ld_path (char *path);
extern void list_module(User *); extern void list_module (User *);
extern void list_module_bots(User *); extern void list_module_bots (User *);
extern int add_mod_user(char *nick, char *mod_name); extern int add_mod_user (char *nick, char *mod_name);
extern int del_mod_user(char *nick); extern int del_mod_user (char *nick);
extern int add_mod_timer(char *func_name, char *timer_name, char *mod_name, int interval); extern int add_mod_timer (char *func_name, char *timer_name, char *mod_name, int interval);
extern int del_mod_timer(char *timer_name); extern int del_mod_timer (char *timer_name);
extern void list_module_timer(User *); extern void list_module_timer (User *);
extern int add_socket(char *readfunc, char *writefunc, char *errfunc, char *sock_name, int socknum, char *mod_name); extern int add_socket (char *readfunc, char *writefunc, char *errfunc, char *sock_name, int socknum, char *mod_name);
extern int del_socket(char *sockname); extern int del_socket (char *sockname);
extern void list_sockets(User *); extern void list_sockets (User *);
extern Sock_List *findsock(char *sock_name); extern Sock_List *findsock (char *sock_name);
extern Mod_User *findbot(char *); extern Mod_User *findbot (char *);
extern int get_dl_handle(char *mod_name); extern int get_dl_handle (char *mod_name);
extern void add_bot_to_chan(char *, char *); extern void add_bot_to_chan (char *, char *);
extern void del_bot_from_chan(char *, char *); extern void del_bot_from_chan (char *, char *);
extern void bot_chan_message(char *origin, char *chan, char **av, int ac); extern void bot_chan_message (char *origin, char *chan, char **av, int ac);
extern void botchandump(User *u); extern void botchandump (User * u);
#endif /* !_dl_h_ */ #endif /* !_dl_h_ */

125
dns.c
View file

@ -20,7 +20,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: dns.c,v 1.14 2003/06/13 13:11:48 fishwaldo Exp $ ** $Id: dns.c,v 1.15 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
@ -72,56 +72,46 @@ list_t *dnslist;
* @return returns 1 on success, 0 on failure (to add the lookup, not a successfull lookup * @return returns 1 on success, 0 on failure (to add the lookup, not a successfull lookup
*/ */
int dns_lookup(char *str, adns_rrtype type, int
void (*callback) (char *data, adns_answer * a), char *data) dns_lookup (char *str, adns_rrtype type, void (*callback) (char *data, adns_answer * a), char *data)
{ {
lnode_t *dnsnode; lnode_t *dnsnode;
DnsLookup *dnsdata; DnsLookup *dnsdata;
int status; int status;
struct sockaddr_in sa; struct sockaddr_in sa;
strcpy(segv_location, "dns_lookup"); strcpy (segv_location, "dns_lookup");
if (list_isfull(dnslist)) { if (list_isfull (dnslist)) {
nlog(LOG_ERROR, LOG_CORE, "DNS: Lookup list is full"); nlog (LOG_ERROR, LOG_CORE, "DNS: Lookup list is full");
return 0; return 0;
} }
dnsdata = malloc(sizeof(DnsLookup)); dnsdata = malloc (sizeof (DnsLookup));
if (!dnsdata) { if (!dnsdata) {
nlog(LOG_CRITICAL, LOG_CORE, "DNS: Out of Memory"); nlog (LOG_CRITICAL, LOG_CORE, "DNS: Out of Memory");
return 0; return 0;
} }
/* set the module name */ /* set the module name */
strncpy(dnsdata->mod_name, segvinmodule, MAXHOST); strncpy (dnsdata->mod_name, segvinmodule, MAXHOST);
strncpy(dnsdata->data, data, 254); strncpy (dnsdata->data, data, 254);
dnsdata->callback = callback; dnsdata->callback = callback;
if (type == adns_r_ptr) { if (type == adns_r_ptr) {
sa.sin_family = AF_INET; sa.sin_family = AF_INET;
sa.sin_addr.s_addr = inet_addr(str); sa.sin_addr.s_addr = inet_addr (str);
status = status = adns_submit_reverse (ads, (const struct sockaddr *) &sa, type, adns_qf_owner | adns_qf_cname_loose, NULL, &dnsdata->q);
adns_submit_reverse(ads, (const struct sockaddr *) &sa,
type,
adns_qf_owner |
adns_qf_cname_loose, NULL,
&dnsdata->q);
} else { } else {
status = status = adns_submit (ads, str, type, adns_qf_owner | adns_qf_cname_loose, NULL, &dnsdata->q);
adns_submit(ads, str, type,
adns_qf_owner | adns_qf_cname_loose, NULL,
&dnsdata->q);
} }
if (status) { if (status) {
nlog(LOG_WARNING, LOG_CORE, "DNS: adns_submit error: %s", nlog (LOG_WARNING, LOG_CORE, "DNS: adns_submit error: %s", strerror (status));
strerror(status)); free (dnsdata);
free(dnsdata);
return 0; return 0;
} }
nlog(LOG_DEBUG1, LOG_CORE, "DNS: Added dns query %s to list", nlog (LOG_DEBUG1, LOG_CORE, "DNS: Added dns query %s to list", data);
data);
/* if we get here, then the submit was successfull. Add it to the list of queryies */ /* if we get here, then the submit was successfull. Add it to the list of queryies */
dnsnode = lnode_create(dnsdata); dnsnode = lnode_create (dnsdata);
list_append(dnslist, dnsnode); list_append (dnslist, dnsnode);
return 1; return 1;
} }
@ -134,25 +124,24 @@ int dns_lookup(char *str, adns_rrtype type,
* @return returns 1 on success, 0 on failure * @return returns 1 on success, 0 on failure
*/ */
int init_dns() int
init_dns ()
{ {
int adnsstart; int adnsstart;
strcpy(segv_location, "init_dns"); strcpy (segv_location, "init_dns");
dnslist = list_create(DNS_QUEUE_SIZE); dnslist = list_create (DNS_QUEUE_SIZE);
if (!dnslist) if (!dnslist)
return 0; return 0;
#ifndef DEBUG #ifndef DEBUG
adnsstart = adnsstart = adns_init (&ads, adns_if_noerrprint | adns_if_noautosys, 0);
adns_init(&ads, adns_if_noerrprint | adns_if_noautosys, 0);
#else #else
adnsstart = adns_init(&ads, adns_if_debug | adns_if_noautosys, 0); adnsstart = adns_init (&ads, adns_if_debug | adns_if_noautosys, 0);
#endif #endif
if (adnsstart) { if (adnsstart) {
printf("ADNS init failed: %s\n", strerror(adnsstart)); printf ("ADNS init failed: %s\n", strerror (adnsstart));
nlog(LOG_CRITICAL, LOG_CORE, "ADNS init failed: %s", nlog (LOG_CRITICAL, LOG_CORE, "ADNS init failed: %s", strerror (adnsstart));
strerror(adnsstart));
return 0; return 0;
} }
return 1; return 1;
@ -168,66 +157,60 @@ int init_dns()
* @return Nothing * @return Nothing
*/ */
void do_dns() void
do_dns ()
{ {
lnode_t *dnsnode, *dnsnode1; lnode_t *dnsnode, *dnsnode1;
int status; int status;
DnsLookup *dnsdata; DnsLookup *dnsdata;
strcpy(segv_location, "do_dns"); strcpy (segv_location, "do_dns");
/* if the list is empty, no use doing anything */ /* if the list is empty, no use doing anything */
if (list_isempty(dnslist)) if (list_isempty (dnslist))
return; return;
dnsnode = list_first(dnslist); dnsnode = list_first (dnslist);
while (dnsnode) { while (dnsnode) {
/* loop through the list */ /* loop through the list */
dnsdata = lnode_get(dnsnode); dnsdata = lnode_get (dnsnode);
status = adns_check(ads, &dnsdata->q, &dnsdata->a, NULL); status = adns_check (ads, &dnsdata->q, &dnsdata->a, NULL);
/* if status == eagain, the lookup hasn't completed yet */ /* if status == eagain, the lookup hasn't completed yet */
if (status == EAGAIN) { if (status == EAGAIN) {
nlog(LOG_DEBUG2, LOG_CORE, nlog (LOG_DEBUG2, LOG_CORE, "DNS: Lookup hasn't completed for %s", &dnsdata->data);
"DNS: Lookup hasn't completed for %s", dnsnode = list_next (dnslist, dnsnode);
&dnsdata->data);
dnsnode = list_next(dnslist, dnsnode);
break; break;
} }
/* there was a error */ /* there was a error */
if (status) { if (status) {
nlog(LOG_CRITICAL, LOG_CORE, nlog (LOG_CRITICAL, LOG_CORE, "DNS: Baaaad error on adns_check: %s. Please report to NeoStats Group", strerror (status));
"DNS: Baaaad error on adns_check: %s. Please report to NeoStats Group", chanalert (s_Services, "Bad Error on DNS lookup. Please check logfile");
strerror(status));
chanalert(s_Services,
"Bad Error on DNS lookup. Please check logfile");
/* set this so nlog works good */ /* set this so nlog works good */
strncpy(segvinmodule, dnsdata->mod_name, MAXHOST); strncpy (segvinmodule, dnsdata->mod_name, MAXHOST);
/* call the callback function with answer set to NULL */ /* call the callback function with answer set to NULL */
dnsdata->callback(dnsdata->data, NULL); dnsdata->callback (dnsdata->data, NULL);
strcpy(segvinmodule, ""); strcpy (segvinmodule, "");
/* delete from list */ /* delete from list */
dnsnode1 = list_delete(dnslist, dnsnode); dnsnode1 = list_delete (dnslist, dnsnode);
dnsnode = list_next(dnslist, dnsnode1); dnsnode = list_next (dnslist, dnsnode1);
free(dnsdata->a); free (dnsdata->a);
free(dnsdata); free (dnsdata);
lnode_destroy(dnsnode1); lnode_destroy (dnsnode1);
break; break;
} }
nlog(LOG_DEBUG2, LOG_CORE, nlog (LOG_DEBUG2, LOG_CORE, "DNS: Calling callback function with data %s", dnsdata->data);
"DNS: Calling callback function with data %s", strncpy (segvinmodule, dnsdata->mod_name, MAXHOST);
dnsdata->data);
strncpy(segvinmodule, dnsdata->mod_name, MAXHOST);
/* call the callback function */ /* call the callback function */
dnsdata->callback(dnsdata->data, dnsdata->a); dnsdata->callback (dnsdata->data, dnsdata->a);
strcpy(segvinmodule, ""); strcpy (segvinmodule, "");
/* delete from list */ /* delete from list */
dnsnode1 = list_delete(dnslist, dnsnode); dnsnode1 = list_delete (dnslist, dnsnode);
dnsnode = list_next(dnslist, dnsnode1); dnsnode = list_next (dnslist, dnsnode1);
free(dnsdata->a); free (dnsdata->a);
free(dnsdata); free (dnsdata);
lnode_destroy(dnsnode1); lnode_destroy (dnsnode1);
} }
} }

211
dotconf.c
View file

@ -42,7 +42,7 @@
/* /*
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: dotconf.c,v 1.9 2003/06/13 13:11:48 fishwaldo Exp $ ** $Id: dotconf.c,v 1.10 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
#include <time.h> #include <time.h>
@ -74,16 +74,16 @@ static config_option *config_options[CFG_MODULES];
* some 'magic' options that are predefined by dot.conf itself for * some 'magic' options that are predefined by dot.conf itself for
* advanced functionality * advanced functionality
*/ */
static void dotconf_cb_include(char *); /* magic 'Include' */ static void dotconf_cb_include (char *); /* magic 'Include' */
static void dotconf_cb_includepath(char *); /* magic 'IncludePath' */ static void dotconf_cb_includepath (char *); /* magic 'IncludePath' */
static config_option dotconf_options[] = static config_option dotconf_options[] = { {"Include", ARG_STR, dotconf_cb_include, 0},
{ {"Include", ARG_STR, dotconf_cb_include, 0},
{"IncludePath", ARG_STR, dotconf_cb_includepath, 0}, {"IncludePath", ARG_STR, dotconf_cb_includepath, 0},
LAST_OPTION LAST_OPTION
}; };
void config_substitute_env(char *str) void
config_substitute_env (char *str)
{ {
char *cp1, *cp2, *cp3, *eos, *eob; char *cp1, *cp2, *cp3, *eos, *eob;
char *env_value; char *env_value;
@ -91,9 +91,9 @@ void config_substitute_env(char *str)
char env_default[CFG_MAX_VALUE + 1]; char env_default[CFG_MAX_VALUE + 1];
char tmp_value[CFG_MAX_VALUE + 1]; char tmp_value[CFG_MAX_VALUE + 1];
bzero(env_name, CFG_MAX_VALUE + 1); bzero (env_name, CFG_MAX_VALUE + 1);
bzero(env_default, CFG_MAX_VALUE + 1); bzero (env_default, CFG_MAX_VALUE + 1);
bzero(tmp_value, CFG_MAX_VALUE + 1); bzero (tmp_value, CFG_MAX_VALUE + 1);
cp1 = str; cp1 = str;
eob = cp1 + CFG_MAX_VALUE + 1; eob = cp1 + CFG_MAX_VALUE + 1;
cp2 = tmp_value; cp2 = tmp_value;
@ -122,17 +122,15 @@ void config_substitute_env(char *str)
cp1++; cp1++;
if (*cp1 != '}') if (*cp1 != '}')
fprintf(stderr, "%s:%d: Unbalanced '{'\n", fprintf (stderr, "%s:%d: Unbalanced '{'\n", dotconf_file, dotconf_line);
dotconf_file, dotconf_line);
else { else {
cp1++; /* skip } */ cp1++; /* skip } */
if ((env_value = getenv(env_name)) != NULL) { if ((env_value = getenv (env_name)) != NULL) {
strncat(cp2, env_value, eos - cp2); strncat (cp2, env_value, eos - cp2);
cp2 += strlen(env_value); cp2 += strlen (env_value);
} else { } else {
strncat(cp2, env_default, strncat (cp2, env_default, eos - cp2);
eos - cp2); cp2 += strlen (env_default);
cp2 += strlen(env_default);
} }
} }
@ -142,10 +140,11 @@ void config_substitute_env(char *str)
} }
*cp2 = '\0'; /* terminate buffer */ *cp2 = '\0'; /* terminate buffer */
strncpy(str, tmp_value, CFG_MAX_VALUE + 1); strncpy (str, tmp_value, CFG_MAX_VALUE + 1);
} }
void config_register_options(config_option * options) void
config_register_options (config_option * options)
{ {
int i; int i;
for (i = 0; i < CFG_MODULES && config_options[i]; i++) { for (i = 0; i < CFG_MODULES && config_options[i]; i++) {
@ -153,14 +152,15 @@ void config_register_options(config_option * options)
config_options[i] = options; config_options[i] = options;
} }
int config_parse(FILE * config) int
config_parse (FILE * config)
{ {
static char buffer[CFG_BUFSIZE]; static char buffer[CFG_BUFSIZE];
static char *here_string; /* Damn FreeBSD */ static char *here_string; /* Damn FreeBSD */
static char *here_limit; static char *here_limit;
static char *here_doc; static char *here_doc;
while ((fgets(buffer, CFG_BUFSIZE, config)) != NULL) { /* for each line */ while ((fgets (buffer, CFG_BUFSIZE, config)) != NULL) { /* for each line */
char *cp1, *cp2; /* generic char pointer */ char *cp1, *cp2; /* generic char pointer */
char *eob, *eos; /* end of buffer; end of string */ char *eob, *eos; /* end of buffer; end of string */
char sq, dq; /* state flags: single/double quote */ char sq, dq; /* state flags: single/double quote */
@ -181,10 +181,10 @@ int config_parse(FILE * config)
/* initialize char pointer */ /* initialize char pointer */
cp1 = buffer; cp1 = buffer;
eob = cp1 + strlen(cp1); /* calculate end of buffer */ eob = cp1 + strlen (cp1); /* calculate end of buffer */
/* skip any whitspace of indented lines */ /* skip any whitspace of indented lines */
while ((cp1 != eob) && (isspace(*cp1))) while ((cp1 != eob) && (isspace (*cp1)))
cp1++; cp1++;
/* skip line if it only contains whitespace */ /* skip line if it only contains whitespace */
if (cp1 == eob) if (cp1 == eob)
@ -192,18 +192,15 @@ int config_parse(FILE * config)
/* get first token: read the name of a possible option */ /* get first token: read the name of a possible option */
cp2 = name; cp2 = name;
while ((*cp1 != '\0') && (!isspace(*cp1))) while ((*cp1 != '\0') && (!isspace (*cp1)))
*cp2++ = *cp1++; *cp2++ = *cp1++;
*cp2 = '\0'; *cp2 = '\0';
/* and now find the entry in the option table, and call the callback */ /* and now find the entry in the option table, and call the callback */
bzero(&opt, sizeof(config_option)); bzero (&opt, sizeof (config_option));
for (mod = 0; mod < CFG_MODULES && config_options[mod]; for (mod = 0; mod < CFG_MODULES && config_options[mod]; mod++)
mod++)
for (i = 0; config_options[mod][i].name[0]; i++) for (i = 0; config_options[mod][i].name[0]; i++)
if (!strncmp if (!strncmp (name, config_options[mod][i].name, CFG_MAX_OPTION)) {
(name, config_options[mod][i].name,
CFG_MAX_OPTION)) {
opt = config_options[mod][i]; opt = config_options[mod][i];
break; /* found it; break out of for */ break; /* found it; break out of for */
} }
@ -216,58 +213,54 @@ int config_parse(FILE * config)
} else if (opt.type == ARG_RAW) { } else if (opt.type == ARG_RAW) {
/* if it is an ARG_RAW type, save some time and call the /* if it is an ARG_RAW type, save some time and call the
callback now */ callback now */
opt.callback(cp1, opt.userdata); opt.callback (cp1, opt.userdata);
continue; continue;
} else if (opt.type == ARG_STR) { } else if (opt.type == ARG_STR) {
/* check if it's a here-document and act accordingly */ /* check if it's a here-document and act accordingly */
char *cp3 = cp1; char *cp3 = cp1;
bzero(&here_limit, 9); bzero (&here_limit, 9);
/* skip whitespace */ /* skip whitespace */
while ((cp3 < eob) && (*cp3 != '\0') while ((cp3 < eob) && (*cp3 != '\0')
&& (isspace(*cp3))) && (isspace (*cp3)))
cp3++; cp3++;
if (!strncmp("<<", cp3, 2)) { /* here string sign */ if (!strncmp ("<<", cp3, 2)) { /* here string sign */
/* it's a here-document: yeah, what a cool feature ;) */ /* it's a here-document: yeah, what a cool feature ;) */
struct stat finfo; struct stat finfo;
stat(dotconf_file, &finfo); stat (dotconf_file, &finfo);
/* /*
* allocate a buffer of filesize bytes; should be enough to * allocate a buffer of filesize bytes; should be enough to
* prevent buffer overflows * prevent buffer overflows
*/ */
here_doc = malloc(finfo.st_size + 1); /* allocate buffer memory */ here_doc = malloc (finfo.st_size + 1); /* allocate buffer memory */
bzero(here_doc, finfo.st_size + 1); bzero (here_doc, finfo.st_size + 1);
strncpy(here_limit, cp3 + 2, 8); /* copy here-delimiter */ strncpy (here_limit, cp3 + 2, 8); /* copy here-delimiter */
while (fgets(buffer, CFG_BUFSIZE, config)) { while (fgets (buffer, CFG_BUFSIZE, config)) {
if (!strncmp if (!strncmp (here_limit, buffer, strlen (here_limit))) {
(here_limit, buffer,
strlen(here_limit))) {
here_string = 0; here_string = 0;
break; break;
} }
strcat(here_doc, buffer); /* append to buffer */ strcat (here_doc, buffer); /* append to buffer */
} }
if (here_string) if (here_string)
fprintf(stderr, fprintf (stderr, "Line %d: Unterminated here-document!\n", dotconf_line);
"Line %d: Unterminated here-document!\n", here_doc[strlen (here_doc) - 1] = '\0'; /* strip newline */
dotconf_line); opt.callback (here_doc, opt.userdata); /* call back */
here_doc[strlen(here_doc) - 1] = '\0'; /* strip newline */
opt.callback(here_doc, opt.userdata); /* call back */
free(here_doc); /* free buffer memory */ free (here_doc); /* free buffer memory */
continue; continue;
} }
} }
free(here_doc); free (here_doc);
/* skip whitespace */ /* skip whitespace */
while ((cp1 < eob) && (*cp1 != '\0') && (isspace(*cp1))) while ((cp1 < eob) && (*cp1 != '\0') && (isspace (*cp1)))
cp1++; cp1++;
/* start reading option arguments */ /* start reading option arguments */
@ -302,18 +295,17 @@ int config_parse(FILE * config)
break; break;
} }
/* unquoted space: start a new option argument */ /* unquoted space: start a new option argument */
if (isspace(*cp1) && !dq && !sq) { if (isspace (*cp1) && !dq && !sq) {
*cp2 = '\0'; /* terminate current argument */ *cp2 = '\0'; /* terminate current argument */
/* increment word counter and update char pointer */ /* increment word counter and update char pointer */
cp2 = values[++word_count]; cp2 = values[++word_count];
/* skip all whitespace between 2 arguments */ /* skip all whitespace between 2 arguments */
while (isspace(*(cp1 + 1)) while (isspace (*(cp1 + 1))
&& (*cp1 != '\0')) && (*cp1 != '\0'))
cp1++; cp1++;
} }
/* not space or quoted ; eat it: */ /* not space or quoted ; eat it: */
else if ((((!isspace(*cp1) && !dq && !sq else if ((((!isspace (*cp1) && !dq && !sq && *cp1 != '"' && *cp1 != '\'')
&& *cp1 != '"' && *cp1 != '\'')
/* dont take quote if quoting: */ /* dont take quote if quoting: */
|| (dq && (*cp1 != '"')) || (dq && (*cp1 != '"'))
|| (sq && *cp1 != '\'')))) || (sq && *cp1 != '\''))))
@ -329,29 +321,24 @@ int config_parse(FILE * config)
{ {
/* the value is true if the argument is Yes, On or 1 */ /* the value is true if the argument is Yes, On or 1 */
/* kludge code follows ;) */ /* kludge code follows ;) */
int arg = ((values[0][0] == 'Y' int arg = ((values[0][0] == 'Y' || values[0][1] == 'y')
|| values[0][1] == 'y')
|| (values[0][0] == '1') || (values[0][0] == '1')
|| ((values[0][0] == 'o' || ((values[0][0] == 'o' || values[0][0] == 'O')
|| values[0][0] == && (values[0][1] == 'n' || values[0][1]
'O')
&& (values[0][1] ==
'n'
|| values[0][1]
== 'N'))); == 'N')));
opt.callback(arg, USER_DATA); opt.callback (arg, USER_DATA);
break; break;
} }
case ARG_INT: case ARG_INT:
{ {
int arg = atoi(values[0]); int arg = atoi (values[0]);
opt.callback(arg, USER_DATA); opt.callback (arg, USER_DATA);
break; break;
} }
case ARG_STR: case ARG_STR:
{ {
config_substitute_env(values[0]); config_substitute_env (values[0]);
opt.callback(values[0], USER_DATA); opt.callback (values[0], USER_DATA);
break; break;
} }
case ARG_LIST: case ARG_LIST:
@ -359,22 +346,19 @@ int config_parse(FILE * config)
char *data[CFG_VALUES]; char *data[CFG_VALUES];
int i; int i;
for (i = 0; i < word_count; i++) { /* prepare list */ for (i = 0; i < word_count; i++) { /* prepare list */
config_substitute_env config_substitute_env (values[i]);
(values[i]); data[i] = strdup (values[i]);
data[i] =
strdup(values[i]);
} }
opt.callback(data, word_count, opt.callback (data, word_count, USER_DATA);
USER_DATA);
for (i = 0; i < word_count; i++) /* dump list */ for (i = 0; i < word_count; i++) /* dump list */
free(data[i]); free (data[i]);
break; break;
} }
case ARG_NONE: case ARG_NONE:
{ {
opt.callback(); opt.callback ();
break; break;
} }
case ARG_RAW: /* this has been handled before */ case ARG_RAW: /* this has been handled before */
@ -392,83 +376,78 @@ int config_parse(FILE * config)
* open and parse the config-file using the config_options list * open and parse the config-file using the config_options list
* as reference for what callback to call and what type of arguments to provide * as reference for what callback to call and what type of arguments to provide
*/ */
int config_read(char *fname, config_option * options) int
config_read (char *fname, config_option * options)
{ {
FILE *config; FILE *config;
char *dc_env; /* pointer to DC_INCLUDEPATH */ char *dc_env; /* pointer to DC_INCLUDEPATH */
if (access(fname, R_OK)) { if (access (fname, R_OK)) {
fprintf(stderr, "Error opening configuration file '%s'\n", fprintf (stderr, "Error opening configuration file '%s'\n", fname);
fname);
return 1; return 1;
} }
dotconf_file = malloc(CFG_MAX_FILENAME + 1); /* allocate fname buffer */ dotconf_file = malloc (CFG_MAX_FILENAME + 1); /* allocate fname buffer */
bzero(dotconf_file, CFG_MAX_FILENAME + 1); bzero (dotconf_file, CFG_MAX_FILENAME + 1);
bzero(dotconf_includepath, CFG_MAX_FILENAME + 1); bzero (dotconf_includepath, CFG_MAX_FILENAME + 1);
strncpy(dotconf_file, fname, CFG_MAX_FILENAME); /* fill fname buffer */ strncpy (dotconf_file, fname, CFG_MAX_FILENAME); /* fill fname buffer */
/* take includepath from environment if present */ /* take includepath from environment if present */
if ((dc_env = getenv(CFG_INCLUDEPATH_ENV)) != NULL) if ((dc_env = getenv (CFG_INCLUDEPATH_ENV)) != NULL)
strncpy(dotconf_includepath, dc_env, CFG_MAX_FILENAME); strncpy (dotconf_includepath, dc_env, CFG_MAX_FILENAME);
config_register_options(dotconf_options); /* internal options */ config_register_options (dotconf_options); /* internal options */
config_register_options(options); /* register main options */ config_register_options (options); /* register main options */
config = fopen(dotconf_file, "r"); config = fopen (dotconf_file, "r");
config_parse(config); /* fire off parser */ config_parse (config); /* fire off parser */
fclose(config); fclose (config);
free(dotconf_file); /* free fname buffer */ free (dotconf_file); /* free fname buffer */
return 0; return 0;
} }
/* callbacks for internal options */ /* callbacks for internal options */
void dotconf_cb_include(char *str) void
dotconf_cb_include (char *str)
{ {
FILE *config; FILE *config;
char old_fname[CFG_MAX_FILENAME]; char old_fname[CFG_MAX_FILENAME];
bzero(&old_fname, CFG_MAX_FILENAME); bzero (&old_fname, CFG_MAX_FILENAME);
strcpy(old_fname, dotconf_file); strcpy (old_fname, dotconf_file);
if (str[0] != '/' && dotconf_includepath[0] != '\0') { if (str[0] != '/' && dotconf_includepath[0] != '\0') {
/* relative file AND include path is used */ /* relative file AND include path is used */
/* check for length of fully qualified filename */ /* check for length of fully qualified filename */
if ((strlen(str) + strlen(dotconf_includepath) + 1) == if ((strlen (str) + strlen (dotconf_includepath) + 1) == CFG_MAX_FILENAME) {
CFG_MAX_FILENAME) { fprintf (stderr, "%s:%d: Absolute filename too long (>%d)\n", dotconf_file, dotconf_line, CFG_MAX_FILENAME);
fprintf(stderr,
"%s:%d: Absolute filename too long (>%d)\n",
dotconf_file, dotconf_line,
CFG_MAX_FILENAME);
return; return;
} }
snprintf(dotconf_file, CFG_MAX_FILENAME + 1, "%s/%s", snprintf (dotconf_file, CFG_MAX_FILENAME + 1, "%s/%s", dotconf_includepath, str);
dotconf_includepath, str);
} else /* fully qualified, or no includepath */ } else /* fully qualified, or no includepath */
strncpy(dotconf_file, str, CFG_MAX_FILENAME); strncpy (dotconf_file, str, CFG_MAX_FILENAME);
if (access(dotconf_file, R_OK)) { if (access (dotconf_file, R_OK)) {
fprintf(stderr, fprintf (stderr, "Error in %s line %d: Cannot open %s for inclusion\n", old_fname, dotconf_line, dotconf_file);
"Error in %s line %d: Cannot open %s for inclusion\n", strcpy (dotconf_file, old_fname); /* restore settings */
old_fname, dotconf_line, dotconf_file);
strcpy(dotconf_file, old_fname); /* restore settings */
return; return;
} }
config = fopen(dotconf_file, "r"); config = fopen (dotconf_file, "r");
config_parse(config); config_parse (config);
fclose(config); fclose (config);
strcpy(dotconf_file, old_fname); strcpy (dotconf_file, old_fname);
} }
void dotconf_cb_includepath(char *str) void
dotconf_cb_includepath (char *str)
{ {
char *env = getenv("DC_INCLUDEPATH"); char *env = getenv ("DC_INCLUDEPATH");
if (!env) /* environment overrides configuration file setting */ if (!env) /* environment overrides configuration file setting */
strncpy(dotconf_includepath, str, CFG_MAX_FILENAME - 1); strncpy (dotconf_includepath, str, CFG_MAX_FILENAME - 1);
} }

View file

@ -20,7 +20,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: dotconf.h,v 1.3 2003/05/26 09:18:28 fishwaldo Exp $ ** $Id: dotconf.h,v 1.4 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
@ -28,32 +28,32 @@
#define HAVE_CFG_H #define HAVE_CFG_H
/* some buffersize definitions */ /* some buffersize definitions */
#define CFG_BUFSIZE 4096 /* max length of one line */ #define CFG_BUFSIZE 4096 /* max length of one line */
#define CFG_MAX_OPTION 32 /* max length of any option name */ #define CFG_MAX_OPTION 32 /* max length of any option name */
#define CFG_MAX_VALUE 4064 /* max length of any options value */ #define CFG_MAX_VALUE 4064 /* max length of any options value */
#define CFG_MAX_FILENAME 256 /* max length of a filename */ #define CFG_MAX_FILENAME 256 /* max length of a filename */
#define CFG_VALUES 16 /* max # of arguments an option takes */ #define CFG_VALUES 16 /* max # of arguments an option takes */
#define CFG_MODULES 64 /* max # of dynamically loadable modules */ #define CFG_MODULES 64 /* max # of dynamically loadable modules */
#define CFG_INCLUDEPATH_ENV "DC_INCLUDEPATH" #define CFG_INCLUDEPATH_ENV "DC_INCLUDEPATH"
/* constants for type of option */ /* constants for type of option */
#define ARG_TOGGLE 0 /* TOGGLE on,off; yes,no; 1, 0; */ #define ARG_TOGGLE 0 /* TOGGLE on,off; yes,no; 1, 0; */
#define ARG_INT 1 /* callback wants an integer */ #define ARG_INT 1 /* callback wants an integer */
#define ARG_STR 2 /* callback expects a \0 terminated str */ #define ARG_STR 2 /* callback expects a \0 terminated str */
#define ARG_LIST 3 /* wants list of strings */ #define ARG_LIST 3 /* wants list of strings */
#define ARG_NAME 4 /* wants option name */ #define ARG_NAME 4 /* wants option name */
#define ARG_RAW 5 /* wants raw argument data */ #define ARG_RAW 5 /* wants raw argument data */
#define ARG_NONE 6 /* does not expect ANY args */ #define ARG_NONE 6 /* does not expect ANY args */
/* for convenience of terminating the config_options list */ /* for convenience of terminating the config_options list */
#define LAST_OPTION { "", 0, NULL, 0 } #define LAST_OPTION { "", 0, NULL, 0 }
typedef struct _cfgoption { typedef struct _cfgoption {
char name[CFG_MAX_OPTION]; /* name of configuration option */ char name[CFG_MAX_OPTION]; /* name of configuration option */
int type; /* for possible values, see above */ int type; /* for possible values, see above */
void (*callback)(); /* callback function */ void (*callback) (); /* callback function */
int userdata; /* userdefinable value/flag */ int userdata; /* userdefinable value/flag */
} config_option; } config_option;
@ -62,7 +62,7 @@ typedef struct _cfgoption {
* 2. the list of optionnames to recognize * 2. the list of optionnames to recognize
* *
* returns 0 on success; !0 on error */ * returns 0 on success; !0 on error */
int config_read(char *, config_option *); int config_read (char *, config_option *);
void config_register_options(config_option *); void config_register_options (config_option *);
#endif /* HAVE_CFG_H */ #endif /* HAVE_CFG_H */

433
hash.c
View file

@ -39,7 +39,7 @@
* into proprietary software; there is no requirement for such software to * into proprietary software; there is no requirement for such software to
* contain a copyright notice related to this source. * contain a copyright notice related to this source.
* *
* $Id: hash.c,v 1.10 2003/07/17 10:13:51 fishwaldo Exp $ * $Id: hash.c,v 1.11 2003/07/30 13:58:22 fishwaldo Exp $
* $Name: $ * $Name: $
*/ */
@ -54,8 +54,7 @@
#ifdef KAZLIB_RCSID #ifdef KAZLIB_RCSID
static const char rcsid[] = static const char rcsid[] = "$Id: hash.c,v 1.11 2003/07/30 13:58:22 fishwaldo Exp $";
"$Id: hash.c,v 1.10 2003/07/17 10:13:51 fishwaldo Exp $";
#endif #endif
#define INIT_BITS 6 #define INIT_BITS 6
@ -84,10 +83,10 @@ static const char rcsid[] =
#define table hash_table #define table hash_table
#define chain hash_chain #define chain hash_chain
static hnode_t *hnode_alloc(void *context); static hnode_t *hnode_alloc (void *context);
static void hnode_free(hnode_t * node, void *context); static void hnode_free (hnode_t * node, void *context);
static hash_val_t hash_fun_default(const void *key); static hash_val_t hash_fun_default (const void *key);
static int hash_comp_default(const void *key1, const void *key2); static int hash_comp_default (const void *key1, const void *key2);
int hash_val_t_bit; int hash_val_t_bit;
@ -104,7 +103,8 @@ int hash_val_t_bit;
* right, replacing the topmost bit by zero. * right, replacing the topmost bit by zero.
*/ */
static void compute_bits(void) static void
compute_bits (void)
{ {
hash_val_t val = HASH_VAL_T_MAX; /* 1 */ hash_val_t val = HASH_VAL_T_MAX; /* 1 */
int bits = 0; int bits = 0;
@ -121,7 +121,8 @@ static void compute_bits(void)
* Verify whether the given argument is a power of two. * Verify whether the given argument is a power of two.
*/ */
static int is_power_of_two(hash_val_t arg) static int
is_power_of_two (hash_val_t arg)
{ {
if (arg == 0) if (arg == 0)
return 0; return 0;
@ -134,10 +135,11 @@ static int is_power_of_two(hash_val_t arg)
* Compute a shift amount from a given table size * Compute a shift amount from a given table size
*/ */
static hash_val_t compute_mask(hashcount_t size) static hash_val_t
compute_mask (hashcount_t size)
{ {
nassert(is_power_of_two(size)); nassert (is_power_of_two (size));
nassert(size >= 2); nassert (size >= 2);
return size - 1; return size - 1;
} }
@ -146,7 +148,8 @@ static hash_val_t compute_mask(hashcount_t size)
* Initialize the table of pointers to null. * Initialize the table of pointers to null.
*/ */
static void clear_table(hash_t * hash) static void
clear_table (hash_t * hash)
{ {
hash_val_t i; hash_val_t i;
@ -182,27 +185,26 @@ static void clear_table(hash_t * hash)
* the various bookeeping fields of the hash structure. * the various bookeeping fields of the hash structure.
*/ */
static void grow_table(hash_t * hash) static void
grow_table (hash_t * hash)
{ {
hnode_t **newtable; hnode_t **newtable;
nassert(2 * hash->nchains > hash->nchains); /* 1 */ nassert (2 * hash->nchains > hash->nchains); /* 1 */
newtable = realloc(hash->table, sizeof *newtable * hash->nchains * 2); /* 4 */ newtable = realloc (hash->table, sizeof *newtable * hash->nchains * 2); /* 4 */
if (newtable) { /* 5 */ if (newtable) { /* 5 */
hash_val_t mask = (hash->mask << 1) | 1; /* 3 */ hash_val_t mask = (hash->mask << 1) | 1; /* 3 */
hash_val_t exposed_bit = mask ^ hash->mask; /* 6 */ hash_val_t exposed_bit = mask ^ hash->mask; /* 6 */
hash_val_t chain; hash_val_t chain;
nassert(mask != hash->mask); nassert (mask != hash->mask);
for (chain = 0; chain < hash->nchains; chain++) { /* 7 */ for (chain = 0; chain < hash->nchains; chain++) { /* 7 */
hnode_t *low_chain = 0, *high_chain = hnode_t *low_chain = 0, *high_chain = 0, *hptr, *next;
0, *hptr, *next;
for (hptr = newtable[chain]; hptr != 0; for (hptr = newtable[chain]; hptr != 0; hptr = next) {
hptr = next) {
next = hptr->next; next = hptr->next;
if (hptr->hkey & exposed_bit) { if (hptr->hkey & exposed_bit) {
@ -224,7 +226,7 @@ static void grow_table(hash_t * hash)
hash->lowmark *= 2; hash->lowmark *= 2;
hash->highmark *= 2; hash->highmark *= 2;
} }
nassert(hash_verify(hash)); nassert (hash_verify (hash));
} }
/* /*
@ -257,12 +259,13 @@ static void grow_table(hash_t * hash)
* 9. Finally, update the various table parameters to reflect the new size. * 9. Finally, update the various table parameters to reflect the new size.
*/ */
static void shrink_table(hash_t * hash) static void
shrink_table (hash_t * hash)
{ {
hash_val_t chain, nchains; hash_val_t chain, nchains;
hnode_t **newtable, *low_tail, *low_chain, *high_chain; hnode_t **newtable, *low_tail, *low_chain, *high_chain;
nassert(hash->nchains >= 2); /* 1 */ nassert (hash->nchains >= 2); /* 1 */
nchains = hash->nchains / 2; nchains = hash->nchains / 2;
for (chain = 0; chain < nchains; chain++) { for (chain = 0; chain < nchains; chain++) {
@ -274,16 +277,16 @@ static void shrink_table(hash_t * hash)
else if (high_chain != 0) /* 5 */ else if (high_chain != 0) /* 5 */
hash->table[chain] = high_chain; hash->table[chain] = high_chain;
else else
nassert(hash->table[chain] == NULL); /* 6 */ nassert (hash->table[chain] == NULL); /* 6 */
} }
newtable = realloc(hash->table, sizeof *newtable * nchains); /* 7 */ newtable = realloc (hash->table, sizeof *newtable * nchains); /* 7 */
if (newtable) /* 8 */ if (newtable) /* 8 */
hash->table = newtable; hash->table = newtable;
hash->mask >>= 1; /* 9 */ hash->mask >>= 1; /* 9 */
hash->nchains = nchains; hash->nchains = nchains;
hash->lowmark /= 2; hash->lowmark /= 2;
hash->highmark /= 2; hash->highmark /= 2;
nassert(hash_verify(hash)); nassert (hash_verify (hash));
} }
@ -316,38 +319,36 @@ static void shrink_table(hash_t * hash)
* 8. The table of chains must be properly reset to all null pointers. * 8. The table of chains must be properly reset to all null pointers.
*/ */
hash_t *hash_create(hashcount_t maxcount, hash_comp_t compfun, hash_t *
hash_fun_t hashfun) hash_create (hashcount_t maxcount, hash_comp_t compfun, hash_fun_t hashfun)
{ {
hash_t *hash; hash_t *hash;
if (hash_val_t_bit == 0) /* 1 */ if (hash_val_t_bit == 0) /* 1 */
compute_bits(); compute_bits ();
hash = malloc(sizeof *hash); /* 2 */ hash = malloc (sizeof *hash); /* 2 */
if (hash) { /* 3 */ if (hash) { /* 3 */
hash->table = malloc(sizeof *hash->table * INIT_SIZE); /* 4 */ hash->table = malloc (sizeof *hash->table * INIT_SIZE); /* 4 */
if (hash->table) { /* 5 */ if (hash->table) { /* 5 */
hash->nchains = INIT_SIZE; /* 6 */ hash->nchains = INIT_SIZE; /* 6 */
hash->highmark = INIT_SIZE * 2; hash->highmark = INIT_SIZE * 2;
hash->lowmark = INIT_SIZE / 2; hash->lowmark = INIT_SIZE / 2;
hash->nodecount = 0; hash->nodecount = 0;
hash->maxcount = maxcount; hash->maxcount = maxcount;
hash->compare = hash->compare = compfun ? compfun : hash_comp_default;
compfun ? compfun : hash_comp_default; hash->function = hashfun ? hashfun : hash_fun_default;
hash->function =
hashfun ? hashfun : hash_fun_default;
hash->allocnode = hnode_alloc; hash->allocnode = hnode_alloc;
hash->freenode = hnode_free; hash->freenode = hnode_free;
hash->context = NULL; hash->context = NULL;
hash->mask = INIT_MASK; hash->mask = INIT_MASK;
hash->dynamic = 1; /* 7 */ hash->dynamic = 1; /* 7 */
clear_table(hash); /* 8 */ clear_table (hash); /* 8 */
nassert(hash_verify(hash)); nassert (hash_verify (hash));
return hash; return hash;
} }
free(hash); free (hash);
} }
return NULL; return NULL;
@ -357,11 +358,11 @@ hash_t *hash_create(hashcount_t maxcount, hash_comp_t compfun,
* Select a different set of node allocator routines. * Select a different set of node allocator routines.
*/ */
void hash_set_allocator(hash_t * hash, hnode_alloc_t al, void
hnode_free_t fr, void *context) hash_set_allocator (hash_t * hash, hnode_alloc_t al, hnode_free_t fr, void *context)
{ {
nassert(hash_count(hash) == 0); nassert (hash_count (hash) == 0);
nassert((al == 0 && fr == 0) || (al != 0 && fr != 0)); nassert ((al == 0 && fr == 0) || (al != 0 && fr != 0));
hash->allocnode = al ? al : hnode_alloc; hash->allocnode = al ? al : hnode_alloc;
hash->freenode = fr ? fr : hnode_free; hash->freenode = fr ? fr : hnode_free;
@ -373,17 +374,18 @@ void hash_set_allocator(hash_t * hash, hnode_alloc_t al,
* cause the hash to become empty. * cause the hash to become empty.
*/ */
void hash_free_nodes(hash_t * hash) void
hash_free_nodes (hash_t * hash)
{ {
hscan_t hs; hscan_t hs;
hnode_t *node; hnode_t *node;
hash_scan_begin(&hs, hash); hash_scan_begin (&hs, hash);
while ((node = hash_scan_next(&hs))) { while ((node = hash_scan_next (&hs))) {
hash_scan_delete(hash, node); hash_scan_delete (hash, node);
hash->freenode(node, hash->context); hash->freenode (node, hash->context);
} }
hash->nodecount = 0; hash->nodecount = 0;
clear_table(hash); clear_table (hash);
} }
/* /*
@ -391,25 +393,27 @@ void hash_free_nodes(hash_t * hash)
* freeing them and then freeing the table all in one step. * freeing them and then freeing the table all in one step.
*/ */
void hash_free(hash_t * hash) void
hash_free (hash_t * hash)
{ {
#ifdef KAZLIB_OBSOLESCENT_DEBUG #ifdef KAZLIB_OBSOLESCENT_DEBUG
nassert("call to obsolescent function hash_free()" && 0); nassert ("call to obsolescent function hash_free()" && 0);
#endif #endif
hash_free_nodes(hash); hash_free_nodes (hash);
hash_destroy(hash); hash_destroy (hash);
} }
/* /*
* Free a dynamic hash table structure. * Free a dynamic hash table structure.
*/ */
void hash_destroy(hash_t * hash) void
hash_destroy (hash_t * hash)
{ {
nassert(hash_val_t_bit != 0); nassert (hash_val_t_bit != 0);
nassert(hash_isempty(hash)); nassert (hash_isempty (hash));
free(hash->table); free (hash->table);
free(hash); free (hash);
} }
/* /*
@ -425,14 +429,13 @@ void hash_destroy(hash_t * hash)
* so we reset it here. * so we reset it here.
*/ */
hash_t *hash_init(hash_t * hash, hashcount_t maxcount, hash_t *
hash_comp_t compfun, hash_fun_t hashfun, hash_init (hash_t * hash, hashcount_t maxcount, hash_comp_t compfun, hash_fun_t hashfun, hnode_t ** table, hashcount_t nchains)
hnode_t ** table, hashcount_t nchains)
{ {
if (hash_val_t_bit == 0) /* 1 */ if (hash_val_t_bit == 0) /* 1 */
compute_bits(); compute_bits ();
nassert(is_power_of_two(nchains)); nassert (is_power_of_two (nchains));
hash->table = table; /* 2 */ hash->table = table; /* 2 */
hash->nchains = nchains; hash->nchains = nchains;
@ -441,10 +444,10 @@ hash_t *hash_init(hash_t * hash, hashcount_t maxcount,
hash->compare = compfun ? compfun : hash_comp_default; hash->compare = compfun ? compfun : hash_comp_default;
hash->function = hashfun ? hashfun : hash_fun_default; hash->function = hashfun ? hashfun : hash_fun_default;
hash->dynamic = 0; /* 3 */ hash->dynamic = 0; /* 3 */
hash->mask = compute_mask(nchains); /* 4 */ hash->mask = compute_mask (nchains); /* 4 */
clear_table(hash); /* 5 */ clear_table (hash); /* 5 */
nassert(hash_verify(hash)); nassert (hash_verify (hash));
return hash; return hash;
} }
@ -460,7 +463,8 @@ hash_t *hash_init(hash_t * hash, hashcount_t maxcount,
* so that hash_scan_next() shall indicate failure. * so that hash_scan_next() shall indicate failure.
*/ */
void hash_scan_begin(hscan_t * scan, hash_t * hash) void
hash_scan_begin (hscan_t * scan, hash_t * hash)
{ {
hash_val_t nchains = hash->nchains; hash_val_t nchains = hash->nchains;
hash_val_t chain; hash_val_t chain;
@ -469,8 +473,7 @@ void hash_scan_begin(hscan_t * scan, hash_t * hash)
/* 1 */ /* 1 */
for (chain = 0; chain < nchains && hash->table[chain] == 0; for (chain = 0; chain < nchains && hash->table[chain] == 0; chain++);
chain++);
if (chain < nchains) { /* 2 */ if (chain < nchains) { /* 2 */
scan->chain = chain; scan->chain = chain;
@ -506,14 +509,15 @@ void hash_scan_begin(hscan_t * scan, hash_t * hash)
*/ */
hnode_t *hash_scan_next(hscan_t * scan) hnode_t *
hash_scan_next (hscan_t * scan)
{ {
hnode_t *next = scan->next; /* 1 */ hnode_t *next = scan->next; /* 1 */
hash_t *hash = scan->table; hash_t *hash = scan->table;
hash_val_t chain = scan->chain + 1; hash_val_t chain = scan->chain + 1;
hash_val_t nchains = hash->nchains; hash_val_t nchains = hash->nchains;
nassert(hash_val_t_bit != 0); /* 2 */ nassert (hash_val_t_bit != 0); /* 2 */
if (next) { /* 3 */ if (next) { /* 3 */
if (next->next) { /* 4 */ if (next->next) { /* 4 */
@ -545,19 +549,20 @@ hnode_t *hash_scan_next(hscan_t * scan)
* where N is the base 2 logarithm of the size of the hash table. * where N is the base 2 logarithm of the size of the hash table.
*/ */
void hash_insert(hash_t * hash, hnode_t * node, const void *key) void
hash_insert (hash_t * hash, hnode_t * node, const void *key)
{ {
hash_val_t hkey, chain; hash_val_t hkey, chain;
nassert(hash_val_t_bit != 0); nassert (hash_val_t_bit != 0);
nassert(node->next == NULL); nassert (node->next == NULL);
nassert(hash->nodecount < hash->maxcount); /* 1 */ nassert (hash->nodecount < hash->maxcount); /* 1 */
nassert(hash_lookup(hash, key) == NULL); /* 2 */ nassert (hash_lookup (hash, key) == NULL); /* 2 */
if (hash->dynamic && hash->nodecount >= hash->highmark) /* 3 */ if (hash->dynamic && hash->nodecount >= hash->highmark) /* 3 */
grow_table(hash); grow_table (hash);
hkey = hash->function(key); hkey = hash->function (key);
chain = hkey & hash->mask; /* 4 */ chain = hkey & hash->mask; /* 4 */
node->key = key; node->key = key;
@ -566,7 +571,7 @@ void hash_insert(hash_t * hash, hnode_t * node, const void *key)
hash->table[chain] = node; hash->table[chain] = node;
hash->nodecount++; hash->nodecount++;
nassert(hash_verify(hash)); nassert (hash_verify (hash));
} }
/* /*
@ -583,17 +588,17 @@ void hash_insert(hash_t * hash, hnode_t * node, const void *key)
* entry. * entry.
*/ */
hnode_t *hash_lookup(hash_t * hash, const void *key) hnode_t *
hash_lookup (hash_t * hash, const void *key)
{ {
hash_val_t hkey, chain; hash_val_t hkey, chain;
hnode_t *nptr; hnode_t *nptr;
hkey = hash->function(key); /* 1 */ hkey = hash->function (key); /* 1 */
chain = hkey & hash->mask; /* 2 */ chain = hkey & hash->mask; /* 2 */
for (nptr = hash->table[chain]; nptr; nptr = nptr->next) { /* 3 */ for (nptr = hash->table[chain]; nptr; nptr = nptr->next) { /* 3 */
if (nptr->hkey == hkey if (nptr->hkey == hkey && hash->compare (nptr->key, key) == 0)
&& hash->compare(nptr->key, key) == 0)
return nptr; return nptr;
} }
@ -618,17 +623,17 @@ hnode_t *hash_lookup(hash_t * hash, const void *key)
* 6. Indicate that the node is no longer in a hash table. * 6. Indicate that the node is no longer in a hash table.
*/ */
hnode_t *hash_delete(hash_t * hash, hnode_t * node) hnode_t *
hash_delete (hash_t * hash, hnode_t * node)
{ {
hash_val_t chain; hash_val_t chain;
hnode_t *hptr; hnode_t *hptr;
nassert(hash_lookup(hash, node->key) == node); /* 1 */ nassert (hash_lookup (hash, node->key) == node); /* 1 */
nassert(hash_val_t_bit != 0); nassert (hash_val_t_bit != 0);
if (hash->dynamic && hash->nodecount <= hash->lowmark if (hash->dynamic && hash->nodecount <= hash->lowmark && hash->nodecount > INIT_SIZE)
&& hash->nodecount > INIT_SIZE) shrink_table (hash); /* 2 */
shrink_table(hash); /* 2 */
chain = node->hkey & hash->mask; /* 3 */ chain = node->hkey & hash->mask; /* 3 */
hptr = hash->table[chain]; hptr = hash->table[chain];
@ -637,36 +642,38 @@ hnode_t *hash_delete(hash_t * hash, hnode_t * node)
hash->table[chain] = node->next; hash->table[chain] = node->next;
} else { } else {
while (hptr->next != node) { /* 5 */ while (hptr->next != node) { /* 5 */
nassert(hptr != 0); nassert (hptr != 0);
hptr = hptr->next; hptr = hptr->next;
} }
nassert(hptr->next == node); nassert (hptr->next == node);
hptr->next = node->next; hptr->next = node->next;
} }
hash->nodecount--; hash->nodecount--;
nassert(hash_verify(hash)); nassert (hash_verify (hash));
node->next = NULL; /* 6 */ node->next = NULL; /* 6 */
return node; return node;
} }
int hash_alloc_insert(hash_t * hash, const void *key, void *data) int
hash_alloc_insert (hash_t * hash, const void *key, void *data)
{ {
hnode_t *node = hash->allocnode(hash->context); hnode_t *node = hash->allocnode (hash->context);
if (node) { if (node) {
hnode_init(node, data); hnode_init (node, data);
hash_insert(hash, node, key); hash_insert (hash, node, key);
return 1; return 1;
} }
return 0; return 0;
} }
void hash_delete_free(hash_t * hash, hnode_t * node) void
hash_delete_free (hash_t * hash, hnode_t * node)
{ {
hash_delete(hash, node); hash_delete (hash, node);
hash->freenode(node, hash->context); hash->freenode (node, hash->context);
} }
/* /*
@ -674,13 +681,14 @@ void hash_delete_free(hash_t * hash, hnode_t * node)
* used from within a hash table scan operation. See notes for hash_delete. * used from within a hash table scan operation. See notes for hash_delete.
*/ */
hnode_t *hash_scan_delete(hash_t * hash, hnode_t * node) hnode_t *
hash_scan_delete (hash_t * hash, hnode_t * node)
{ {
hash_val_t chain; hash_val_t chain;
hnode_t *hptr; hnode_t *hptr;
nassert(hash_lookup(hash, node->key) == node); nassert (hash_lookup (hash, node->key) == node);
nassert(hash_val_t_bit != 0); nassert (hash_val_t_bit != 0);
chain = node->hkey & hash->mask; chain = node->hkey & hash->mask;
hptr = hash->table[chain]; hptr = hash->table[chain];
@ -694,7 +702,7 @@ hnode_t *hash_scan_delete(hash_t * hash, hnode_t * node)
} }
hash->nodecount--; hash->nodecount--;
nassert(hash_verify(hash)); nassert (hash_verify (hash));
node->next = NULL; node->next = NULL;
return node; return node;
@ -704,10 +712,11 @@ hnode_t *hash_scan_delete(hash_t * hash, hnode_t * node)
* Like hash_delete_free but based on hash_scan_delete. * Like hash_delete_free but based on hash_scan_delete.
*/ */
void hash_scan_delfree(hash_t * hash, hnode_t * node) void
hash_scan_delfree (hash_t * hash, hnode_t * node)
{ {
hash_scan_delete(hash, node); hash_scan_delete (hash, node);
hash->freenode(node, hash->context); hash->freenode (node, hash->context);
} }
/* /*
@ -719,7 +728,8 @@ void hash_scan_delfree(hash_t * hash, hnode_t * node)
* to see whether it is correct for the node's chain. * to see whether it is correct for the node's chain.
*/ */
int hash_verify(hash_t * hash) int
hash_verify (hash_t * hash)
{ {
hashcount_t count = 0; hashcount_t count = 0;
hash_val_t chain; hash_val_t chain;
@ -728,15 +738,14 @@ int hash_verify(hash_t * hash)
if (hash->dynamic) { /* 1 */ if (hash->dynamic) { /* 1 */
if (hash->lowmark >= hash->highmark) if (hash->lowmark >= hash->highmark)
return 0; return 0;
if (!is_power_of_two(hash->highmark)) if (!is_power_of_two (hash->highmark))
return 0; return 0;
if (!is_power_of_two(hash->lowmark)) if (!is_power_of_two (hash->lowmark))
return 0; return 0;
} }
for (chain = 0; chain < hash->nchains; chain++) { /* 2 */ for (chain = 0; chain < hash->nchains; chain++) { /* 2 */
for (hptr = hash->table[chain]; hptr != 0; for (hptr = hash->table[chain]; hptr != 0; hptr = hptr->next) {
hptr = hptr->next) {
if ((hptr->hkey & hash->mask) != chain) if ((hptr->hkey & hash->mask) != chain)
return 0; return 0;
count++; count++;
@ -755,7 +764,8 @@ int hash_verify(hash_t * hash)
*/ */
#undef hash_isfull #undef hash_isfull
int hash_isfull(hash_t * hash) int
hash_isfull (hash_t * hash)
{ {
return hash->nodecount == hash->maxcount; return hash->nodecount == hash->maxcount;
} }
@ -766,19 +776,22 @@ int hash_isfull(hash_t * hash)
*/ */
#undef hash_isempty #undef hash_isempty
int hash_isempty(hash_t * hash) int
hash_isempty (hash_t * hash)
{ {
return hash->nodecount == 0; return hash->nodecount == 0;
} }
static hnode_t *hnode_alloc(void *context) static hnode_t *
hnode_alloc (void *context)
{ {
return malloc(sizeof *hnode_alloc(NULL)); return malloc (sizeof *hnode_alloc (NULL));
} }
static void hnode_free(hnode_t * node, void *context) static void
hnode_free (hnode_t * node, void *context)
{ {
free(node); free (node);
} }
@ -786,9 +799,10 @@ static void hnode_free(hnode_t * node, void *context)
* Create a hash table node dynamically and assign it the given data. * Create a hash table node dynamically and assign it the given data.
*/ */
hnode_t *hnode_create(void *data) hnode_t *
hnode_create (void *data)
{ {
hnode_t *node = malloc(sizeof *node); hnode_t *node = malloc (sizeof *node);
if (node) { if (node) {
node->data = data; node->data = data;
node->next = NULL; node->next = NULL;
@ -800,7 +814,8 @@ hnode_t *hnode_create(void *data)
* Initialize a client-supplied node * Initialize a client-supplied node
*/ */
hnode_t *hnode_init(hnode_t * hnode, void *data) hnode_t *
hnode_init (hnode_t * hnode, void *data)
{ {
hnode->data = data; hnode->data = data;
hnode->next = NULL; hnode->next = NULL;
@ -811,42 +826,49 @@ hnode_t *hnode_init(hnode_t * hnode, void *data)
* Destroy a dynamically allocated node. * Destroy a dynamically allocated node.
*/ */
void hnode_destroy(hnode_t * hnode) void
hnode_destroy (hnode_t * hnode)
{ {
free(hnode); free (hnode);
} }
#undef hnode_put #undef hnode_put
void hnode_put(hnode_t * node, void *data) void
hnode_put (hnode_t * node, void *data)
{ {
node->data = data; node->data = data;
} }
#undef hnode_get #undef hnode_get
void *hnode_get(hnode_t * node) void *
hnode_get (hnode_t * node)
{ {
return node->data; return node->data;
} }
#undef hnode_getkey #undef hnode_getkey
const void *hnode_getkey(hnode_t * node) const void *
hnode_getkey (hnode_t * node)
{ {
return node->key; return node->key;
} }
#undef hash_count #undef hash_count
hashcount_t hash_count(hash_t * hash) hashcount_t
hash_count (hash_t * hash)
{ {
return hash->nodecount; return hash->nodecount;
} }
#undef hash_size #undef hash_size
hashcount_t hash_size(hash_t * hash) hashcount_t
hash_size (hash_t * hash)
{ {
return hash->nchains; return hash->nchains;
} }
static hash_val_t hash_fun_default(const void *key) static hash_val_t
hash_fun_default (const void *key)
{ {
static unsigned long randbox[] = { static unsigned long randbox[] = {
0x49848f1bU, 0xe6255dbaU, 0x36da5bdcU, 0x47bf94e9U, 0x49848f1bU, 0xe6255dbaU, 0x36da5bdcU, 0x47bf94e9U,
@ -859,19 +881,20 @@ static hash_val_t hash_fun_default(const void *key)
hash_val_t acc = 0; hash_val_t acc = 0;
while (*str) { while (*str) {
acc ^= randbox[(tolower(*str) + acc) & 0xf]; acc ^= randbox[(tolower (*str) + acc) & 0xf];
acc = (acc << 1) | (acc >> 31); acc = (acc << 1) | (acc >> 31);
acc &= 0xffffffffU; acc &= 0xffffffffU;
acc ^= randbox[((tolower(*str++) >> 4) + acc) & 0xf]; acc ^= randbox[((tolower (*str++) >> 4) + acc) & 0xf];
acc = (acc << 2) | (acc >> 30); acc = (acc << 2) | (acc >> 30);
acc &= 0xffffffffU; acc &= 0xffffffffU;
} }
return acc; return acc;
} }
static int hash_comp_default(const void *key1, const void *key2) static int
hash_comp_default (const void *key1, const void *key2)
{ {
return strcasecmp(key1, key2); return strcasecmp (key1, key2);
} }
#ifdef KAZLIB_TEST_MAIN #ifdef KAZLIB_TEST_MAIN
@ -882,43 +905,46 @@ static int hash_comp_default(const void *key1, const void *key2)
typedef char input_t[256]; typedef char input_t[256];
static int tokenize(char *string, ...) static int
tokenize (char *string, ...)
{ {
char **tokptr; char **tokptr;
va_list arglist; va_list arglist;
int tokcount = 0; int tokcount = 0;
va_start(arglist, string); va_start (arglist, string);
tokptr = va_arg(arglist, char **); tokptr = va_arg (arglist, char **);
while (tokptr) { while (tokptr) {
while (*string && isspace((unsigned char) *string)) while (*string && isspace ((unsigned char) *string))
string++; string++;
if (!*string) if (!*string)
break; break;
*tokptr = string; *tokptr = string;
while (*string && !isspace((unsigned char) *string)) while (*string && !isspace ((unsigned char) *string))
string++; string++;
tokptr = va_arg(arglist, char **); tokptr = va_arg (arglist, char **);
tokcount++; tokcount++;
if (!*string) if (!*string)
break; break;
*string++ = 0; *string++ = 0;
} }
va_end(arglist); va_end (arglist);
return tokcount; return tokcount;
} }
static char *dupstring(char *str) static char *
dupstring (char *str)
{ {
int sz = strlen(str) + 1; int sz = strlen (str) + 1;
char *new = malloc(sz); char *new = malloc (sz);
if (new) if (new)
memcpy(new, str, sz); memcpy (new, str, sz);
return new; return new;
} }
static hnode_t *new_node(void *c) static hnode_t *
new_node (void *c)
{ {
static hnode_t few[5]; static hnode_t few[5];
static int count; static int count;
@ -929,14 +955,16 @@ static hnode_t *new_node(void *c)
return NULL; return NULL;
} }
static void del_node(hnode_t * n, void *c) static void
del_node (hnode_t * n, void *c)
{ {
} }
int main(void) int
main (void)
{ {
input_t in; input_t in;
hash_t *h = hash_create(HASHCOUNT_T_MAX, 0, 0); hash_t *h = hash_create (HASHCOUNT_T_MAX, 0, 0);
hnode_t *hn; hnode_t *hn;
hscan_t hs; hscan_t hs;
char *tok1, *tok2, *val; char *tok1, *tok2, *val;
@ -944,109 +972,104 @@ int main(void)
int prompt = 0; int prompt = 0;
char *help = char *help =
"a <key> <val> add value to hash table\n" "a <key> <val> add value to hash table\n"
"d <key> delete value from hash table\n" "d <key> delete value from hash table\n"
"l <key> lookup value in hash table\n" "l <key> lookup value in hash table\n"
"n show size of hash table\n" "n show size of hash table\n"
"c show number of entries\n" "c show number of entries\n"
"t dump whole hash table\n" "t dump whole hash table\n"
"+ increase hash table (private func)\n" "+ increase hash table (private func)\n"
"- decrease hash table (private func)\n" "- decrease hash table (private func)\n"
"b print hash_t_bit value\n" "b print hash_t_bit value\n"
"p turn prompt on\n" "p turn prompt on\n" "s switch to non-functioning allocator\n" "q quit";
"s switch to non-functioning allocator\n"
"q quit";
if (!h) if (!h)
puts("hash_create failed"); puts ("hash_create failed");
for (;;) { for (;;) {
if (prompt) if (prompt)
putchar('>'); putchar ('>');
fflush(stdout); fflush (stdout);
if (!fgets(in, sizeof(input_t), stdin)) if (!fgets (in, sizeof (input_t), stdin))
break; break;
switch (in[0]) { switch (in[0]) {
case '?': case '?':
puts(help); puts (help);
break; break;
case 'b': case 'b':
printf("%d\n", hash_val_t_bit); printf ("%d\n", hash_val_t_bit);
break; break;
case 'a': case 'a':
if (tokenize(in + 1, &tok1, &tok2, (char **) 0) != if (tokenize (in + 1, &tok1, &tok2, (char **) 0) != 2) {
2) { puts ("what?");
puts("what?");
break; break;
} }
key = dupstring(tok1); key = dupstring (tok1);
val = dupstring(tok2); val = dupstring (tok2);
if (!key || !val) { if (!key || !val) {
puts("out of memory"); puts ("out of memory");
free((void *) key); free ((void *) key);
free(val); free (val);
} }
if (!hash_alloc_insert(h, key, val)) { if (!hash_alloc_insert (h, key, val)) {
puts("hash_alloc_insert failed"); puts ("hash_alloc_insert failed");
free((void *) key); free ((void *) key);
free(val); free (val);
break; break;
} }
break; break;
case 'd': case 'd':
if (tokenize(in + 1, &tok1, (char **) 0) != 1) { if (tokenize (in + 1, &tok1, (char **) 0) != 1) {
puts("what?"); puts ("what?");
break; break;
} }
hn = hash_lookup(h, tok1); hn = hash_lookup (h, tok1);
if (!hn) { if (!hn) {
puts("hash_lookup failed"); puts ("hash_lookup failed");
break; break;
} }
val = hnode_get(hn); val = hnode_get (hn);
key = hnode_getkey(hn); key = hnode_getkey (hn);
hash_scan_delfree(h, hn); hash_scan_delfree (h, hn);
free((void *) key); free ((void *) key);
free(val); free (val);
break; break;
case 'l': case 'l':
if (tokenize(in + 1, &tok1, (char **) 0) != 1) { if (tokenize (in + 1, &tok1, (char **) 0) != 1) {
puts("what?"); puts ("what?");
break; break;
} }
hn = hash_lookup(h, tok1); hn = hash_lookup (h, tok1);
if (!hn) { if (!hn) {
puts("hash_lookup failed"); puts ("hash_lookup failed");
break; break;
} }
val = hnode_get(hn); val = hnode_get (hn);
puts(val); puts (val);
break; break;
case 'n': case 'n':
printf("%lu\n", (unsigned long) hash_size(h)); printf ("%lu\n", (unsigned long) hash_size (h));
break; break;
case 'c': case 'c':
printf("%lu\n", (unsigned long) hash_count(h)); printf ("%lu\n", (unsigned long) hash_count (h));
break; break;
case 't': case 't':
hash_scan_begin(&hs, h); hash_scan_begin (&hs, h);
while ((hn = hash_scan_next(&hs))) while ((hn = hash_scan_next (&hs)))
printf("%s\t%s\n", printf ("%s\t%s\n", (char *) hnode_getkey (hn), (char *) hnode_get (hn));
(char *) hnode_getkey(hn),
(char *) hnode_get(hn));
break; break;
case '+': case '+':
grow_table(h); /* private function */ grow_table (h); /* private function */
break; break;
case '-': case '-':
shrink_table(h); /* private function */ shrink_table (h); /* private function */
break; break;
case 'q': case 'q':
exit(0); exit (0);
break; break;
case '\0': case '\0':
break; break;
@ -1054,11 +1077,11 @@ int main(void)
prompt = 1; prompt = 1;
break; break;
case 's': case 's':
hash_set_allocator(h, new_node, del_node, NULL); hash_set_allocator (h, new_node, del_node, NULL);
break; break;
default: default:
putchar('?'); putchar ('?');
putchar('\n'); putchar ('\n');
break; break;
} }
} }

146
hash.h
View file

@ -37,7 +37,7 @@
* into proprietary software; there is no requirement for such software to * into proprietary software; there is no requirement for such software to
* contain a copyright notice related to this source. * contain a copyright notice related to this source.
* *
* $Id: hash.h,v 1.3 2003/05/26 09:18:28 fishwaldo Exp $ * $Id: hash.h,v 1.4 2003/07/30 13:58:22 fishwaldo Exp $
* $Name: $ * $Name: $
*/ */
@ -57,13 +57,13 @@
extern "C" { extern "C" {
#endif #endif
typedef unsigned long hashcount_t; typedef unsigned long hashcount_t;
#define HASHCOUNT_T_MAX ULONG_MAX #define HASHCOUNT_T_MAX ULONG_MAX
typedef unsigned long hash_val_t; typedef unsigned long hash_val_t;
#define HASH_VAL_T_MAX ULONG_MAX #define HASH_VAL_T_MAX ULONG_MAX
extern int hash_val_t_bit; extern int hash_val_t_bit;
#ifndef HASH_VAL_T_BIT #ifndef HASH_VAL_T_BIT
#define HASH_VAL_T_BIT ((int) hash_val_t_bit) #define HASH_VAL_T_BIT ((int) hash_val_t_bit)
@ -93,16 +93,16 @@ extern int hash_val_t_bit;
* each key when the table must grow or shrink. * each key when the table must grow or shrink.
*/ */
typedef struct hnode_t { typedef struct hnode_t {
#if defined(HASH_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG) /* 1 */ #if defined(HASH_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG) /* 1 */
struct hnode_t *hash_next; /* 2 */ struct hnode_t *hash_next; /* 2 */
const void *hash_key; /* 3 */ const void *hash_key; /* 3 */
void *hash_data; /* 4 */ void *hash_data; /* 4 */
hash_val_t hash_hkey; /* 5 */ hash_val_t hash_hkey; /* 5 */
#else #else
int hash_dummy; int hash_dummy;
#endif #endif
} hnode_t; } hnode_t;
/* /*
* The comparison function pointer type. A comparison function takes two keys * The comparison function pointer type. A comparison function takes two keys
@ -111,7 +111,7 @@ typedef struct hnode_t {
* greater than the right key. * greater than the right key.
*/ */
typedef int (*hash_comp_t)(const void *, const void *); typedef int (*hash_comp_t) (const void *, const void *);
/* /*
* The hashing function performs some computation on a key and produces an * The hashing function performs some computation on a key and produces an
@ -125,14 +125,14 @@ typedef int (*hash_comp_t)(const void *, const void *);
* but not the lower ones. * but not the lower ones.
*/ */
typedef hash_val_t (*hash_fun_t)(const void *); typedef hash_val_t (*hash_fun_t) (const void *);
/* /*
* allocator functions * allocator functions
*/ */
typedef hnode_t *(*hnode_alloc_t)(void *); typedef hnode_t *(*hnode_alloc_t) (void *);
typedef void (*hnode_free_t)(hnode_t *, void *); typedef void (*hnode_free_t) (hnode_t *, void *);
/* /*
* This is the hash table control structure. It keeps track of information * This is the hash table control structure. It keeps track of information
@ -169,25 +169,25 @@ typedef void (*hnode_free_t)(hnode_t *, void *);
* statically allocated. * statically allocated.
*/ */
typedef struct hash_t { typedef struct hash_t {
#if defined(HASH_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG) #if defined(HASH_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
struct hnode_t **hash_table; /* 1 */ struct hnode_t **hash_table; /* 1 */
hashcount_t hash_nchains; /* 2 */ hashcount_t hash_nchains; /* 2 */
hashcount_t hash_nodecount; /* 3 */ hashcount_t hash_nodecount; /* 3 */
hashcount_t hash_maxcount; /* 4 */ hashcount_t hash_maxcount; /* 4 */
hashcount_t hash_highmark; /* 5 */ hashcount_t hash_highmark; /* 5 */
hashcount_t hash_lowmark; /* 6 */ hashcount_t hash_lowmark; /* 6 */
hash_comp_t hash_compare; /* 7 */ hash_comp_t hash_compare; /* 7 */
hash_fun_t hash_function; /* 8 */ hash_fun_t hash_function; /* 8 */
hnode_alloc_t hash_allocnode; hnode_alloc_t hash_allocnode;
hnode_free_t hash_freenode; hnode_free_t hash_freenode;
void *hash_context; void *hash_context;
hash_val_t hash_mask; /* 9 */ hash_val_t hash_mask; /* 9 */
int hash_dynamic; /* 10 */ int hash_dynamic; /* 10 */
#else #else
int hash_dummy; int hash_dummy;
#endif #endif
} hash_t; } hash_t;
/* /*
* Hash scanner structure, used for traversals of the data structure. * Hash scanner structure, used for traversals of the data structure.
@ -199,48 +199,47 @@ typedef struct hash_t {
* hash_scan_next(). * hash_scan_next().
*/ */
typedef struct hscan_t { typedef struct hscan_t {
#if defined(HASH_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG) #if defined(HASH_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
hash_t *hash_table; /* 1 */ hash_t *hash_table; /* 1 */
hash_val_t hash_chain; /* 2 */ hash_val_t hash_chain; /* 2 */
hnode_t *hash_next; /* 3 */ hnode_t *hash_next; /* 3 */
#else #else
int hash_dummy; int hash_dummy;
#endif #endif
} hscan_t; } hscan_t;
extern hash_t *hash_create(hashcount_t, hash_comp_t, hash_fun_t); extern hash_t *hash_create (hashcount_t, hash_comp_t, hash_fun_t);
extern void hash_set_allocator(hash_t *, hnode_alloc_t, hnode_free_t, void *); extern void hash_set_allocator (hash_t *, hnode_alloc_t, hnode_free_t, void *);
extern void hash_destroy(hash_t *); extern void hash_destroy (hash_t *);
extern void hash_free_nodes(hash_t *); extern void hash_free_nodes (hash_t *);
extern void hash_free(hash_t *); extern void hash_free (hash_t *);
extern hash_t *hash_init(hash_t *, hashcount_t, hash_comp_t, extern hash_t *hash_init (hash_t *, hashcount_t, hash_comp_t, hash_fun_t, hnode_t **, hashcount_t);
hash_fun_t, hnode_t **, hashcount_t); extern void hash_insert (hash_t *, hnode_t *, const void *);
extern void hash_insert(hash_t *, hnode_t *, const void *); extern hnode_t *hash_lookup (hash_t *, const void *);
extern hnode_t *hash_lookup(hash_t *, const void *); extern hnode_t *hash_delete (hash_t *, hnode_t *);
extern hnode_t *hash_delete(hash_t *, hnode_t *); extern int hash_alloc_insert (hash_t *, const void *, void *);
extern int hash_alloc_insert(hash_t *, const void *, void *); extern void hash_delete_free (hash_t *, hnode_t *);
extern void hash_delete_free(hash_t *, hnode_t *);
extern void hnode_put(hnode_t *, void *); extern void hnode_put (hnode_t *, void *);
extern void *hnode_get(hnode_t *); extern void *hnode_get (hnode_t *);
extern const void *hnode_getkey(hnode_t *); extern const void *hnode_getkey (hnode_t *);
extern hashcount_t hash_count(hash_t *); extern hashcount_t hash_count (hash_t *);
extern hashcount_t hash_size(hash_t *); extern hashcount_t hash_size (hash_t *);
extern int hash_isfull(hash_t *); extern int hash_isfull (hash_t *);
extern int hash_isempty(hash_t *); extern int hash_isempty (hash_t *);
extern void hash_scan_begin(hscan_t *, hash_t *); extern void hash_scan_begin (hscan_t *, hash_t *);
extern hnode_t *hash_scan_next(hscan_t *); extern hnode_t *hash_scan_next (hscan_t *);
extern hnode_t *hash_scan_delete(hash_t *, hnode_t *); extern hnode_t *hash_scan_delete (hash_t *, hnode_t *);
extern void hash_scan_delfree(hash_t *, hnode_t *); extern void hash_scan_delfree (hash_t *, hnode_t *);
extern int hash_verify(hash_t *); extern int hash_verify (hash_t *);
extern hnode_t *hnode_create(void *); extern hnode_t *hnode_create (void *);
extern hnode_t *hnode_init(hnode_t *, void *); extern hnode_t *hnode_init (hnode_t *, void *);
extern void hnode_destroy(hnode_t *); extern void hnode_destroy (hnode_t *);
#if defined(HASH_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG) #if defined(HASH_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
#ifdef KAZLIB_SIDEEFFECT_DEBUG #ifdef KAZLIB_SIDEEFFECT_DEBUG
@ -259,5 +258,4 @@ extern void hnode_destroy(hnode_t *);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

709
hybrid7.c

File diff suppressed because it is too large Load diff

268
hybrid7.h
View file

@ -18,7 +18,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: hybrid7.h,v 1.12 2003/07/23 10:35:47 fishwaldo Exp $ ** $Id: hybrid7.h,v 1.13 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
@ -28,68 +28,68 @@
#define MSG_EOB "EOB" /* end of burst */ #define MSG_EOB "EOB" /* end of burst */
#define MSG_PRIVATE "PRIVMSG" /* PRIV */ #define MSG_PRIVATE "PRIVMSG" /* PRIV */
#define MSG_WHO "WHO" /* WHO -> WHOC */ #define MSG_WHO "WHO" /* WHO -> WHOC */
#define MSG_WHOIS "WHOIS" /* WHOI */ #define MSG_WHOIS "WHOIS" /* WHOI */
#define MSG_WHOWAS "WHOWAS" /* WHOW */ #define MSG_WHOWAS "WHOWAS" /* WHOW */
#define MSG_USER "USER" /* USER */ #define MSG_USER "USER" /* USER */
#define MSG_NICK "NICK" /* NICK */ #define MSG_NICK "NICK" /* NICK */
#define MSG_SERVER "SERVER" /* SERV */ #define MSG_SERVER "SERVER" /* SERV */
#define MSG_LIST "LIST" /* LIST */ #define MSG_LIST "LIST" /* LIST */
#define MSG_TOPIC "TOPIC" /* TOPI */ #define MSG_TOPIC "TOPIC" /* TOPI */
#define MSG_INVITE "INVITE" /* INVI */ #define MSG_INVITE "INVITE" /* INVI */
#define MSG_VERSION "VERSION" /* VERS */ #define MSG_VERSION "VERSION" /* VERS */
#define MSG_QUIT "QUIT" /* QUIT */ #define MSG_QUIT "QUIT" /* QUIT */
#define MSG_SQUIT "SQUIT" /* SQUI */ #define MSG_SQUIT "SQUIT" /* SQUI */
#define MSG_KILL "KILL" /* KILL */ #define MSG_KILL "KILL" /* KILL */
#define MSG_INFO "INFO" /* INFO */ #define MSG_INFO "INFO" /* INFO */
#define MSG_LINKS "LINKS" /* LINK */ #define MSG_LINKS "LINKS" /* LINK */
#define MSG_WATCH "WATCH" /* WATCH */ #define MSG_WATCH "WATCH" /* WATCH */
#define MSG_STATS "STATS" /* STAT */ #define MSG_STATS "STATS" /* STAT */
#define MSG_HELP "HELP" /* HELP */ #define MSG_HELP "HELP" /* HELP */
#define MSG_HELPOP "HELPOP" /* HELP */ #define MSG_HELPOP "HELPOP" /* HELP */
#define MSG_ERROR "ERROR" /* ERRO */ #define MSG_ERROR "ERROR" /* ERRO */
#define MSG_AWAY "AWAY" /* AWAY */ #define MSG_AWAY "AWAY" /* AWAY */
#define MSG_CONNECT "CONNECT" /* CONN */ #define MSG_CONNECT "CONNECT" /* CONN */
#define MSG_PING "PING" /* PING */ #define MSG_PING "PING" /* PING */
#define MSG_PONG "PONG" /* PONG */ #define MSG_PONG "PONG" /* PONG */
#define MSG_OPER "OPER" /* OPER */ #define MSG_OPER "OPER" /* OPER */
#define MSG_PASS "PASS" /* PASS */ #define MSG_PASS "PASS" /* PASS */
#define MSG_WALLOPS "WALLOPS" /* WALL */ #define MSG_WALLOPS "WALLOPS" /* WALL */
#define MSG_TIME "TIME" /* TIME */ #define MSG_TIME "TIME" /* TIME */
#define MSG_NAMES "NAMES" /* NAME */ #define MSG_NAMES "NAMES" /* NAME */
#define MSG_ADMIN "ADMIN" /* ADMI */ #define MSG_ADMIN "ADMIN" /* ADMI */
#define MSG_NOTICE "NOTICE" /* NOTI */ #define MSG_NOTICE "NOTICE" /* NOTI */
#define MSG_JOIN "JOIN" /* JOIN */ #define MSG_JOIN "JOIN" /* JOIN */
#define MSG_PART "PART" /* PART */ #define MSG_PART "PART" /* PART */
#define MSG_LUSERS "LUSERS" /* LUSE */ #define MSG_LUSERS "LUSERS" /* LUSE */
#define MSG_MOTD "MOTD" /* MOTD */ #define MSG_MOTD "MOTD" /* MOTD */
#define MSG_MODE "MODE" /* MODE */ #define MSG_MODE "MODE" /* MODE */
#define MSG_KICK "KICK" /* KICK */ #define MSG_KICK "KICK" /* KICK */
#define MSG_SERVICE "SERVICE" /* SERV -> SRVI */ #define MSG_SERVICE "SERVICE" /* SERV -> SRVI */
#define MSG_USERHOST "USERHOST" /* USER -> USRH */ #define MSG_USERHOST "USERHOST" /* USER -> USRH */
#define MSG_ISON "ISON" /* ISON */ #define MSG_ISON "ISON" /* ISON */
#define MSG_SQUERY "SQUERY" /* SQUE */ #define MSG_SQUERY "SQUERY" /* SQUE */
#define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */ #define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */
#define MSG_SERVSET "SERVSET" /* SERV -> SSET */ #define MSG_SERVSET "SERVSET" /* SERV -> SSET */
#define MSG_REHASH "REHASH" /* REHA */ #define MSG_REHASH "REHASH" /* REHA */
#define MSG_RESTART "RESTART" /* REST */ #define MSG_RESTART "RESTART" /* REST */
#define MSG_CLOSE "CLOSE" /* CLOS */ #define MSG_CLOSE "CLOSE" /* CLOS */
#define MSG_DIE "DIE" /* DIE */ #define MSG_DIE "DIE" /* DIE */
#define MSG_HASH "HASH" /* HASH */ #define MSG_HASH "HASH" /* HASH */
#define MSG_DNS "DNS" /* DNS -> DNSS */ #define MSG_DNS "DNS" /* DNS -> DNSS */
#define MSG_SILENCE "SILENCE" /* SILE */ #define MSG_SILENCE "SILENCE" /* SILE */
#define MSG_AKILL "AKILL" /* AKILL */ #define MSG_AKILL "AKILL" /* AKILL */
#define MSG_KLINE "KLINE" /* KLINE */ #define MSG_KLINE "KLINE" /* KLINE */
#define MSG_UNKLINE "UNKLINE" /* UNKLINE */ #define MSG_UNKLINE "UNKLINE" /* UNKLINE */
#define MSG_RAKILL "RAKILL" /* RAKILL */ #define MSG_RAKILL "RAKILL" /* RAKILL */
#define MSG_GNOTICE "GNOTICE" /* GNOTICE */ #define MSG_GNOTICE "GNOTICE" /* GNOTICE */
#define MSG_GOPER "GOPER" /* GOPER */ #define MSG_GOPER "GOPER" /* GOPER */
#define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */ #define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */
#define MSG_LOCOPS "LOCOPS" /* LOCOPS */ #define MSG_LOCOPS "LOCOPS" /* LOCOPS */
#define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */ #define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */
#define MSG_TRACE "TRACE" /* TRAC */ #define MSG_TRACE "TRACE" /* TRAC */
#define MSG_SQLINE "SQLINE" /* SQLINE */ #define MSG_SQLINE "SQLINE" /* SQLINE */
#define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */ #define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */
#define MSG_SVSNICK "SVSNICK" /* SVSNICK */ #define MSG_SVSNICK "SVSNICK" /* SVSNICK */
@ -108,14 +108,14 @@
#define MSG_SVSMODE "SVSMODE" /* SVSMODE */ #define MSG_SVSMODE "SVSMODE" /* SVSMODE */
#define MSG_SAMODE "SAMODE" /* SAMODE */ #define MSG_SAMODE "SAMODE" /* SAMODE */
#define MSG_CHATOPS "CHATOPS" /* CHATOPS */ #define MSG_CHATOPS "CHATOPS" /* CHATOPS */
#define MSG_HELPSERV "HELPSERV" /* HELPSERV */ #define MSG_HELPSERV "HELPSERV" /* HELPSERV */
#define MSG_ZLINE "ZLINE" /* ZLINE */ #define MSG_ZLINE "ZLINE" /* ZLINE */
#define MSG_UNZLINE "UNZLINE" /* UNZLINE */ #define MSG_UNZLINE "UNZLINE" /* UNZLINE */
#define MSG_NETINFO "NETINFO" /* NETINFO */ #define MSG_NETINFO "NETINFO" /* NETINFO */
#define MSG_RULES "RULES" /* RULES */ #define MSG_RULES "RULES" /* RULES */
#define MSG_MAP "MAP" /* MAP */ #define MSG_MAP "MAP" /* MAP */
#define MSG_NETG "NETG" /* NETG */ #define MSG_NETG "NETG" /* NETG */
#define MSG_ADCHAT "ADCHAT" /* Adchat */ #define MSG_ADCHAT "ADCHAT" /* Adchat */
#define MSG_MAKEPASS "MAKEPASS" /* MAKEPASS */ #define MSG_MAKEPASS "MAKEPASS" /* MAKEPASS */
#define MSG_ADDHUB "ADDHUB" /* ADDHUB */ #define MSG_ADDHUB "ADDHUB" /* ADDHUB */
#define MSG_DELHUB "DELHUB" /* DELHUB */ #define MSG_DELHUB "DELHUB" /* DELHUB */
@ -125,28 +125,28 @@
#define MSG_DELOPER "DELOPER" /* DELOPER */ #define MSG_DELOPER "DELOPER" /* DELOPER */
#define MSG_ADDQLINE "ADDQLINE" /* ADDQLINE */ #define MSG_ADDQLINE "ADDQLINE" /* ADDQLINE */
#define MSG_DELQLINE "DELQLINE" /* DELQLINE */ #define MSG_DELQLINE "DELQLINE" /* DELQLINE */
#define MSG_GSOP "GSOP" /* GSOP */ #define MSG_GSOP "GSOP" /* GSOP */
#define MSG_ISOPER "ISOPER" /* ISOPER */ #define MSG_ISOPER "ISOPER" /* ISOPER */
#define MSG_ADG "ADG" /* ADG */ #define MSG_ADG "ADG" /* ADG */
#define MSG_NMON "NMON" /* NMON */ #define MSG_NMON "NMON" /* NMON */
#define MSG_DALINFO "DALINFO" /* DALnet Credits */ #define MSG_DALINFO "DALINFO" /* DALnet Credits */
#define MSG_CREDITS "CREDITS" /* UltimateIRCd Credits and "Thanks To" */ #define MSG_CREDITS "CREDITS" /* UltimateIRCd Credits and "Thanks To" */
#define MSG_OPERMOTD "OPERMOTD" /* OPERMOTD */ #define MSG_OPERMOTD "OPERMOTD" /* OPERMOTD */
#define MSG_REMREHASH "REMREHASH" /* Remote Rehash */ #define MSG_REMREHASH "REMREHASH" /* Remote Rehash */
#define MSG_MONITOR "MONITOR" /* MONITOR */ #define MSG_MONITOR "MONITOR" /* MONITOR */
#define MSG_GLINE "GLINE" /* The awesome g-line */ #define MSG_GLINE "GLINE" /* The awesome g-line */
#define MSG_REMGLINE "REMGLINE" /* remove g-line */ #define MSG_REMGLINE "REMGLINE" /* remove g-line */
#define MSG_STATSERV "STATSERV" /* StatServ */ #define MSG_STATSERV "STATSERV" /* StatServ */
#define MSG_RULESERV "RULESERV" /* RuleServ */ #define MSG_RULESERV "RULESERV" /* RuleServ */
#define MSG_SNETINFO "SNETINFO" /* SNetInfo */ #define MSG_SNETINFO "SNETINFO" /* SNetInfo */
#define MSG_TSCTL "TSCTL" /* TSCTL */ #define MSG_TSCTL "TSCTL" /* TSCTL */
#define MSG_SVSJOIN "SVSJOIN" /* SVSJOIN */ #define MSG_SVSJOIN "SVSJOIN" /* SVSJOIN */
#define MSG_SAJOIN "SAJOIN" /* SAJOIN */ #define MSG_SAJOIN "SAJOIN" /* SAJOIN */
#define MSG_SDESC "SDESC" /* SDESC */ #define MSG_SDESC "SDESC" /* SDESC */
#define MSG_UNREALINFO "UNREALINFO" /* Unreal Info */ #define MSG_UNREALINFO "UNREALINFO" /* Unreal Info */
#define MSG_SETHOST "SETHOST" /* sethost */ #define MSG_SETHOST "SETHOST" /* sethost */
#define MSG_SETIDENT "SETIDENT" /* set ident */ #define MSG_SETIDENT "SETIDENT" /* set ident */
#define MSG_SETNAME "SETNAME" /* set Realname */ #define MSG_SETNAME "SETNAME" /* set Realname */
#define MSG_CHGHOST "CHGHOST" /* Changehost */ #define MSG_CHGHOST "CHGHOST" /* Changehost */
#define MSG_CHGIDENT "CHGIDENT" /* Change Ident */ #define MSG_CHGIDENT "CHGIDENT" /* Change Ident */
#define MSG_RANDQUOTE "RANDQUOTE" /* Random Quote */ #define MSG_RANDQUOTE "RANDQUOTE" /* Random Quote */
@ -154,19 +154,19 @@
#define MSG_ADDGQUOTE "ADDGQUOTE" /* Add Global Quote */ #define MSG_ADDGQUOTE "ADDGQUOTE" /* Add Global Quote */
#define MSG_ADDULINE "ADDULINE" /* Adds an U Line to ircd.conf file */ #define MSG_ADDULINE "ADDULINE" /* Adds an U Line to ircd.conf file */
#define MSG_DELULINE "DELULINE" /* Removes an U line from the ircd.conf */ #define MSG_DELULINE "DELULINE" /* Removes an U line from the ircd.conf */
#define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */ #define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */
#define MSG_SETTINGS "SETTINGS" /* Settings */ #define MSG_SETTINGS "SETTINGS" /* Settings */
#define MSG_IRCOPS "IRCOPS" /* Shows Online IRCOps */ #define MSG_IRCOPS "IRCOPS" /* Shows Online IRCOps */
#define MSG_SVSPART "SVSPART" /* SVSPART */ #define MSG_SVSPART "SVSPART" /* SVSPART */
#define MSG_SAPART "SAPART" /* SAPART */ #define MSG_SAPART "SAPART" /* SAPART */
#define MSG_VCTRL "VCTRL" /* VCTRL */ #define MSG_VCTRL "VCTRL" /* VCTRL */
#define MSG_GCLIENT "GCLIENT" /* GLIENT */ #define MSG_GCLIENT "GCLIENT" /* GLIENT */
#define MSG_CHANNEL "CHANNEL" /* CHANNEL */ #define MSG_CHANNEL "CHANNEL" /* CHANNEL */
#define MSG_UPTIME "UPTIME" /* UPTIME */ #define MSG_UPTIME "UPTIME" /* UPTIME */
#define MSG_FAILOPS "FAILOPS" /* FAILOPS */ #define MSG_FAILOPS "FAILOPS" /* FAILOPS */
#define MSG_RPING "RPING" /* RPING */ #define MSG_RPING "RPING" /* RPING */
#define MSG_RPONG "RPONG" /* RPONG */ #define MSG_RPONG "RPONG" /* RPONG */
#define MSG_UPING "UPING" /* UPING */ #define MSG_UPING "UPING" /* UPING */
#define MSG_COPYRIGHT "COPYRIGHT" /* Copyright */ #define MSG_COPYRIGHT "COPYRIGHT" /* Copyright */
#define MSG_BOTSERV "BOTSERV" /* BOTSERV */ #define MSG_BOTSERV "BOTSERV" /* BOTSERV */
#define MSG_BS "BS" #define MSG_BS "BS"
@ -191,14 +191,14 @@
#define UMODE_SKILL 0x0100 /* client see's server kills */ #define UMODE_SKILL 0x0100 /* client see's server kills */
#define UMODE_LOCOPS 0x0200 /* client is localop */ #define UMODE_LOCOPS 0x0200 /* client is localop */
#define UMODE_NCHANGE 0x0400 /* client can see nick change notices */ #define UMODE_NCHANGE 0x0400 /* client can see nick change notices */
#define UMODE_REJ 0x0800 /* client is registered */ #define UMODE_REJ 0x0800 /* client is registered */
#define UMODE_SERVNOTICE 0x1000 /* client can see server notices */ #define UMODE_SERVNOTICE 0x1000 /* client can see server notices */
#define UMODE_UNAUTH 0x2000 /* client can see unauthd connections */ #define UMODE_UNAUTH 0x2000 /* client can see unauthd connections */
#define UMODE_WALLOP 0x4000 /* client can get wallop messages */ #define UMODE_WALLOP 0x4000 /* client can get wallop messages */
#define UMODE_EXTERNAL 0x8000 /* client can see server joins/splits */ #define UMODE_EXTERNAL 0x8000 /* client can see server joins/splits */
#define UMODE_SPY 0x10000 /* client can spy on user commands */ #define UMODE_SPY 0x10000 /* client can spy on user commands */
#define UMODE_OPERWALL 0x20000 /* client gets operwalls */ #define UMODE_OPERWALL 0x20000 /* client gets operwalls */
#define UMODE_SERVICES 0x40000 /* client is services */ #define UMODE_SERVICES 0x40000 /* client is services */
#define MODE_CHANOP 0x0001 #define MODE_CHANOP 0x0001
@ -235,8 +235,8 @@ struct ircd_srv_ {
typedef struct { typedef struct {
long mode; long mode;
char flag; char flag;
unsigned nickparam : 1; /* 1 = yes 0 = no */ unsigned nickparam:1; /* 1 = yes 0 = no */
unsigned parameters : 1; unsigned parameters:1;
char sjoin; char sjoin;
} aCtab; } aCtab;
@ -258,74 +258,74 @@ Oper_Modes susr_mds[0];
/* function declarations */ /* function declarations */
extern void init_ircd(); extern void init_ircd ();
extern void chanalert(char *,char *, ...); extern void chanalert (char *, char *, ...);
extern int sserver_cmd(const char *, const int numeric, const char *); extern int sserver_cmd (const char *, const int numeric, const char *);
extern int slogin_cmd(const char *, const int numeric, const char *, const char *); extern int slogin_cmd (const char *, const int numeric, const char *, const char *);
extern int ssquit_cmd(const char *); extern int ssquit_cmd (const char *);
extern int sprotocol_cmd(const char *); extern int sprotocol_cmd (const char *);
extern int squit_cmd(const char *, const char *); extern int squit_cmd (const char *, const char *);
extern int spart_cmd(const char *, const char *); extern int spart_cmd (const char *, const char *);
extern int sjoin_cmd(const char *, const char *); extern int sjoin_cmd (const char *, const char *);
extern int schmode_cmd(const char *, const char *, const char *, const char *); extern int schmode_cmd (const char *, const char *, const char *, const char *);
extern int snewnick_cmd(const char *, const char *, const char *, const char *, long mode); extern int snewnick_cmd (const char *, const char *, const char *, const char *, long mode);
extern int sping_cmd(const char *from, const char *reply, const char *to); extern int sping_cmd (const char *from, const char *reply, const char *to);
extern int sumode_cmd(const char *who, const char *target, long mode); extern int sumode_cmd (const char *who, const char *target, long mode);
extern int snumeric_cmd(const int numeric, const char *target, const char *data,...); extern int snumeric_cmd (const int numeric, const char *target, const char *data, ...);
extern int spong_cmd(const char *reply); extern int spong_cmd (const char *reply);
extern int snetinfo_cmd(); extern int snetinfo_cmd ();
extern int skill_cmd(const char *from, const char *target, const char *reason,...); extern int skill_cmd (const char *from, const char *target, const char *reason, ...);
extern int ssvskill_cmd(const char *who, const char *reason, ...); extern int ssvskill_cmd (const char *who, const char *reason, ...);
extern int ssmo_cmd(const char *from, const char *umodetarget, const char *msg); extern int ssmo_cmd (const char *from, const char *umodetarget, const char *msg);
extern int snick_cmd(const char *oldnick, const char *newnick); extern int snick_cmd (const char *oldnick, const char *newnick);
extern int sswhois_cmd(const char *target, const char *swhois); extern int sswhois_cmd (const char *target, const char *swhois);
extern int ssvsnick_cmd(const char *target, const char *newnick); extern int ssvsnick_cmd (const char *target, const char *newnick);
extern int ssvsjoin_cmd(const char *target, const char *chan); extern int ssvsjoin_cmd (const char *target, const char *chan);
extern int ssvspart_cmd(const char *target, const char *chan); extern int ssvspart_cmd (const char *target, const char *chan);
extern int ssvshost_cmd(const char *who, const char *vhost); extern int ssvshost_cmd (const char *who, const char *vhost);
extern int skick_cmd(const char *who, const char *target, const char *chan, const char *reason); extern int skick_cmd (const char *who, const char *target, const char *chan, const char *reason);
extern int swallops_cmd(const char *who, const char *msg,...); extern int swallops_cmd (const char *who, const char *msg, ...);
extern int vctrl_cmd(); extern int vctrl_cmd ();
extern int ssvinfo_cmd(); extern int ssvinfo_cmd ();
extern int sburst_cmd(int b); extern int sburst_cmd (int b);
extern int seob_cmd(const char *server); extern int seob_cmd (const char *server);
extern int sakill_cmd(const char *host, const char *ident, const char *setby, const int length, const char *reason,...); extern int sakill_cmd (const char *host, const char *ident, const char *setby, const int length, const char *reason, ...);
extern int srakill_cmd(const char *host, const char *ident); extern int srakill_cmd (const char *host, const char *ident);
void Usr_Version(char *, char **, int argc); void Usr_Version (char *, char **, int argc);
void Usr_ShowMOTD(char *, char **, int argc); void Usr_ShowMOTD (char *, char **, int argc);
void Usr_ShowADMIN(char *, char **, int argc); void Usr_ShowADMIN (char *, char **, int argc);
void Usr_Showcredits(char *, char **, int argc); void Usr_Showcredits (char *, char **, int argc);
void Usr_AddServer(char *, char **, int argc); void Usr_AddServer (char *, char **, int argc);
void Usr_DelServer(char *, char **, int argc); void Usr_DelServer (char *, char **, int argc);
void Usr_DelUser(char *, char **, int argc); void Usr_DelUser (char *, char **, int argc);
void Usr_Mode(char *, char **, int argc); void Usr_Mode (char *, char **, int argc);
void Usr_Smode(char *, char **, int argc); void Usr_Smode (char *, char **, int argc);
void Usr_Kill(char *, char **, int argc); void Usr_Kill (char *, char **, int argc);
void Usr_Pong(char *, char **, int argc); void Usr_Pong (char *, char **, int argc);
void Usr_Away(char *, char **, int argc); void Usr_Away (char *, char **, int argc);
void Usr_Nick(char *, char **, int argc); void Usr_Nick (char *, char **, int argc);
void Usr_Topic(char *, char **, int argc); void Usr_Topic (char *, char **, int argc);
void Usr_Kick(char *, char **, int argc); void Usr_Kick (char *, char **, int argc);
void Usr_Join(char *, char **, int argc); void Usr_Join (char *, char **, int argc);
void Usr_Part(char *, char **, int argc); void Usr_Part (char *, char **, int argc);
void Usr_Stats(char *, char **, int argc); void Usr_Stats (char *, char **, int argc);
void Usr_Vhost(char *, char **, int argc); void Usr_Vhost (char *, char **, int argc);
void Srv_Topic(char *, char **, int argc); void Srv_Topic (char *, char **, int argc);
void Srv_Ping(char *, char **, int argc); void Srv_Ping (char *, char **, int argc);
void Srv_Netinfo(char *, char **, int argc); void Srv_Netinfo (char *, char **, int argc);
void Srv_Pass(char *, char **, int argc); void Srv_Pass (char *, char **, int argc);
void Srv_Server(char *, char **, int argc); void Srv_Server (char *, char **, int argc);
void Srv_Squit(char *, char **, int argc); void Srv_Squit (char *, char **, int argc);
void Srv_Nick(char *, char **, int argc); void Srv_Nick (char *, char **, int argc);
void Srv_Svsnick(char *, char **, int argc); void Srv_Svsnick (char *, char **, int argc);
void Srv_Kill(char *, char **, int argc); void Srv_Kill (char *, char **, int argc);
void Srv_Connect(char *, char **, int argc); void Srv_Connect (char *, char **, int argc);
void Srv_Svinfo(char *, char **, int argc); void Srv_Svinfo (char *, char **, int argc);
void Srv_Burst(char *origin, char **argv, int argc); void Srv_Burst (char *origin, char **argv, int argc);
void Srv_Sjoin(char *origin, char **argv, int argc); void Srv_Sjoin (char *origin, char **argv, int argc);
void Srv_Tburst(char *origin, char **argv, int argc); void Srv_Tburst (char *origin, char **argv, int argc);
int SignOn_NewBot(const char *, const char *, const char *, const char *, long); int SignOn_NewBot (const char *, const char *, const char *, const char *, long);
#endif #endif

490
ircd.c
View file

@ -22,7 +22,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: ircd.c,v 1.134 2003/07/22 11:50:51 fishwaldo Exp $ ** $Id: ircd.c,v 1.135 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
#include <setjmp.h> #include <setjmp.h>
#include "stats.h" #include "stats.h"
@ -34,8 +34,8 @@ extern const char protocol_version[];
extern IntCommands cmd_list[]; extern IntCommands cmd_list[];
int init_bot(char *nick, char *user, char *host, char *rname, char *modes, int
char *mod_name) init_bot (char *nick, char *user, char *host, char *rname, char *modes, char *mod_name)
{ {
User *u; User *u;
char **av; char **av;
@ -46,20 +46,16 @@ int init_bot(char *nick, char *user, char *host, char *rname, char *modes,
char tmpmode; char tmpmode;
strcpy(segv_location, "init_bot"); strcpy (segv_location, "init_bot");
u = finduser(nick); u = finduser (nick);
if (u) { if (u) {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "Attempting to Login with a Nickname that already Exists: %s", nick);
"Attempting to Login with a Nickname that already Exists: %s",
nick);
return -1; return -1;
} }
if (strlen(user) > 8) { if (strlen (user) > 8) {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "Warning, %s bot %s has a username longer than 8 chars. Some IRCd's don't like that", mod_name, nick);
"Warning, %s bot %s has a username longer than 8 chars. Some IRCd's don't like that",
mod_name, nick);
} }
add_mod_user(nick, mod_name); add_mod_user (nick, mod_name);
Umode = 0; Umode = 0;
tmpmode = *(modes); tmpmode = *(modes);
while (tmpmode) { while (tmpmode) {
@ -71,17 +67,13 @@ int init_bot(char *nick, char *user, char *host, char *rname, char *modes,
add = 0; add = 0;
break; break;
default: default:
for (i = 0; for (i = 0; i < ((sizeof (usr_mds) / sizeof (usr_mds[0])) - 1); i++) {
i <
((sizeof(usr_mds) / sizeof(usr_mds[0])) - 1);
i++) {
if (usr_mds[i].mode == tmpmode) { if (usr_mds[i].mode == tmpmode) {
if (add) { if (add) {
Umode |= usr_mds[i].umodes; Umode |= usr_mds[i].umodes;
break; break;
} else { } else {
Umode &= Umode &= ~usr_mds[i].umodes;
~usr_mds[i].umodes;
break; break;
} }
} }
@ -89,73 +81,61 @@ int init_bot(char *nick, char *user, char *host, char *rname, char *modes,
} }
tmpmode = *modes++; tmpmode = *modes++;
} }
SignOn_NewBot(nick, user, host, rname, Umode); SignOn_NewBot (nick, user, host, rname, Umode);
AddStringToList(&av, nick, &ac); AddStringToList (&av, nick, &ac);
Module_Event("SIGNON", av, ac); Module_Event ("SIGNON", av, ac);
free(av); free (av);
/* restore segvinmodule from SIGNON */ /* restore segvinmodule from SIGNON */
strcpy(segvinmodule, mod_name); strcpy (segvinmodule, mod_name);
return 1; return 1;
} }
int del_bot(char *nick, char *reason) int
del_bot (char *nick, char *reason)
{ {
User *u; User *u;
strcpy(segv_location, "del_bot"); strcpy (segv_location, "del_bot");
u = finduser(nick); u = finduser (nick);
nlog(LOG_DEBUG1, LOG_CORE, "Killing %s for %s", nick, reason); nlog (LOG_DEBUG1, LOG_CORE, "Killing %s for %s", nick, reason);
if (!u) { if (!u) {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "Attempting to Logoff with a Nickname that does not Exists: %s", nick);
"Attempting to Logoff with a Nickname that does not Exists: %s",
nick);
return -1; return -1;
} }
squit_cmd(nick, reason); squit_cmd (nick, reason);
del_mod_user(nick); del_mod_user (nick);
return 1; return 1;
} }
void Module_Event(char *event, char **av, int ac) void
Module_Event (char *event, char **av, int ac)
{ {
Module *module_ptr; Module *module_ptr;
EventFnList *ev_list; EventFnList *ev_list;
hscan_t ms; hscan_t ms;
hnode_t *mn; hnode_t *mn;
strcpy(segv_location, "Module_Event"); strcpy (segv_location, "Module_Event");
hash_scan_begin(&ms, mh); hash_scan_begin (&ms, mh);
while ((mn = hash_scan_next(&ms)) != NULL) { while ((mn = hash_scan_next (&ms)) != NULL) {
module_ptr = hnode_get(mn); module_ptr = hnode_get (mn);
ev_list = module_ptr->other_funcs; ev_list = module_ptr->other_funcs;
if (ev_list) { if (ev_list) {
while (ev_list->cmd_name != NULL) { while (ev_list->cmd_name != NULL) {
/* This goes through each Command */ /* This goes through each Command */
if (!strcasecmp(ev_list->cmd_name, event)) { if (!strcasecmp (ev_list->cmd_name, event)) {
nlog(LOG_DEBUG1, LOG_CORE, nlog (LOG_DEBUG1, LOG_CORE, "Running Module %s for Comamnd %s -> %s", module_ptr->info->module_name, event, ev_list->cmd_name);
"Running Module %s for Comamnd %s -> %s", strcpy (segv_location, module_ptr->info->module_name);
module_ptr->info->module_name, strcpy (segvinmodule, module_ptr->info->module_name);
event, ev_list->cmd_name); if (setjmp (sigvbuf) == 0) {
strcpy(segv_location, ev_list->function (av, ac);
module_ptr->info->
module_name);
strcpy(segvinmodule,
module_ptr->info->
module_name);
if (setjmp(sigvbuf) == 0) {
ev_list->function(av, ac);
} else { } else {
nlog(LOG_CRITICAL, nlog (LOG_CRITICAL, LOG_CORE, "setjmp() Failed, Can't call Module %s\n", module_ptr->info->module_name);
LOG_CORE,
"setjmp() Failed, Can't call Module %s\n",
module_ptr->info->
module_name);
} }
strcpy(segvinmodule, ""); strcpy (segvinmodule, "");
strcpy(segv_location, strcpy (segv_location, "Module_Event_Return");
"Module_Event_Return");
break; break;
} }
ev_list++; ev_list++;
@ -178,7 +158,8 @@ void Module_Event(char *event, char **av, int ac)
* the buffer by side effect. * the buffer by side effect.
*/ */
extern int split_buf(char *buf, char ***argv, int colon_special) extern int
split_buf (char *buf, char ***argv, int colon_special)
{ {
int argvsize = 8; int argvsize = 8;
int argc; int argc;
@ -186,14 +167,14 @@ extern int split_buf(char *buf, char ***argv, int colon_special)
int flag = 0; int flag = 0;
int colcount = 0; int colcount = 0;
*argv = calloc(sizeof(char *) * argvsize, 1); *argv = calloc (sizeof (char *) * argvsize, 1);
argc = 0; argc = 0;
if (*buf == ':') if (*buf == ':')
buf++; buf++;
while (*buf) { while (*buf) {
if (argc == argvsize) { if (argc == argvsize) {
argvsize += 8; argvsize += 8;
*argv = realloc(*argv, sizeof(char *) * argvsize); *argv = realloc (*argv, sizeof (char *) * argvsize);
} }
#if 0 #if 0
if ((colon_special == 1) && (*buf == ':')) { if ((colon_special == 1) && (*buf == ':')) {
@ -206,13 +187,13 @@ extern int split_buf(char *buf, char ***argv, int colon_special)
buf++; buf++;
colcount++; colcount++;
} }
s = strpbrk(buf, " "); s = strpbrk (buf, " ");
if (s) { if (s) {
*s++ = 0; *s++ = 0;
while (isspace(*s)) while (isspace (*s))
s++; s++;
} else { } else {
s = buf + strlen(buf); s = buf + strlen (buf);
} }
if (*buf == 0) { if (*buf == 0) {
buf++; buf++;
@ -223,23 +204,25 @@ extern int split_buf(char *buf, char ***argv, int colon_special)
return argc - flag; return argc - flag;
} }
extern char *joinbuf(char **av, int ac, int from) extern char *
joinbuf (char **av, int ac, int from)
{ {
int i; int i;
char *buf; char *buf;
char buf1[512]; char buf1[512];
buf = malloc(512); buf = malloc (512);
snprintf(buf, 512, "%s", av[from]); snprintf (buf, 512, "%s", av[from]);
for (i = from + 1; i < ac; i++) { for (i = from + 1; i < ac; i++) {
snprintf(buf1, 512, "%s %s", buf, av[i]); snprintf (buf1, 512, "%s %s", buf, av[i]);
strncpy(buf, buf1, 512); strncpy (buf, buf1, 512);
} }
return (char *) buf; return (char *) buf;
} }
void parse(char *line) void
parse (char *line)
{ {
char origin[64], cmd[64], *coreLine; char origin[64], cmd[64], *coreLine;
char *nick; char *nick;
@ -253,22 +236,22 @@ void parse(char *line)
hscan_t ms; hscan_t ms;
hnode_t *mn; hnode_t *mn;
strcpy(segv_location, "parse"); strcpy (segv_location, "parse");
strip(line); strip (line);
strncpy(recbuf, line, BUFSIZE); strncpy (recbuf, line, BUFSIZE);
if (!(*line)) if (!(*line))
return; return;
nlog(LOG_DEBUG1, LOG_CORE, "R: %s", line); nlog (LOG_DEBUG1, LOG_CORE, "R: %s", line);
if (*line == ':') { if (*line == ':') {
coreLine = strpbrk(line, " "); coreLine = strpbrk (line, " ");
if (!coreLine) if (!coreLine)
return; return;
*coreLine = 0; *coreLine = 0;
while (isspace(*++coreLine)); while (isspace (*++coreLine));
strncpy(origin, line + 1, sizeof(origin)); strncpy (origin, line + 1, sizeof (origin));
memmove(line, coreLine, strlen(coreLine) + 1); memmove (line, coreLine, strlen (coreLine) + 1);
cmdptr = 1; cmdptr = 1;
} else { } else {
cmdptr = 0; cmdptr = 0;
@ -276,140 +259,126 @@ void parse(char *line)
} }
if (!*line) if (!*line)
return; return;
coreLine = strpbrk(line, " "); coreLine = strpbrk (line, " ");
if (coreLine) { if (coreLine) {
*coreLine = 0; *coreLine = 0;
while (isspace(*++coreLine)); while (isspace (*++coreLine));
} else } else
coreLine = line + strlen(line); coreLine = line + strlen (line);
strncpy(cmd, line, sizeof(cmd)); strncpy (cmd, line, sizeof (cmd));
ac = split_buf(coreLine, &av, 1); ac = split_buf (coreLine, &av, 1);
/* First, check if its a privmsg, and if so, handle it in the correct Function */ /* First, check if its a privmsg, and if so, handle it in the correct Function */
if (!strcmp("PRIVMSG", cmd) || (!strcmp("!", cmd))) { if (!strcmp ("PRIVMSG", cmd) || (!strcmp ("!", cmd))) {
/* its a privmsg, now lets see who too... */ /* its a privmsg, now lets see who too... */
if (strstr(av[0], "!")) { if (strstr (av[0], "!")) {
strncpy(cmd, av[0], 64); strncpy (cmd, av[0], 64);
nick = strtok(cmd, "!"); nick = strtok (cmd, "!");
} else if (strstr(av[0], "@")) { } else if (strstr (av[0], "@")) {
strncpy(cmd, av[0], 64); strncpy (cmd, av[0], 64);
nick = strtok(cmd, "@"); nick = strtok (cmd, "@");
} else { } else {
nick = malloc(64); nick = malloc (64);
strncpy(nick, av[0], 64); strncpy (nick, av[0], 64);
I = 1; I = 1;
} }
if (!strcasecmp(s_Services, nick)) { if (!strcasecmp (s_Services, nick)) {
if (flood(finduser(origin))) { if (flood (finduser (origin))) {
free(av); free (av);
return; return;
} }
/* its to the Internal Services Bot */ /* its to the Internal Services Bot */
strcpy(segv_location, "servicesbot"); strcpy (segv_location, "servicesbot");
servicesbot(origin, av, ac); servicesbot (origin, av, ac);
strcpy(segv_location, "ServicesBot_return"); strcpy (segv_location, "ServicesBot_return");
if (I == 1) if (I == 1)
free(nick); free (nick);
free(av); free (av);
return; return;
} else { } else {
list = findbot(nick); list = findbot (nick);
/* Check to see if any of the Modules have this nick Registered */ /* Check to see if any of the Modules have this nick Registered */
if (list) { if (list) {
nlog(LOG_DEBUG1, LOG_CORE, "nicks: %s", nlog (LOG_DEBUG1, LOG_CORE, "nicks: %s", list->nick);
list->nick); if (flood (finduser (origin))) {
if (flood(finduser(origin))) { free (av);
free(av);
return; return;
} }
/* Check to make sure there are no blank spaces so we dont crash */ /* Check to make sure there are no blank spaces so we dont crash */
if (strlen(av[1]) >= 350) { if (strlen (av[1]) >= 350) {
prefmsg(origin, s_Services, prefmsg (origin, s_Services, "command line too long!");
"command line too long!"); notice (s_Services, "%s tried to send a very LARGE command, we told them to shove it!", origin);
notice(s_Services, free (av);
"%s tried to send a very LARGE command, we told them to shove it!",
origin);
free(av);
return; return;
} }
strcpy(segv_location, list->modname); strcpy (segv_location, list->modname);
strcpy(segvinmodule, list->modname); strcpy (segvinmodule, list->modname);
if (setjmp(sigvbuf) == 0) { if (setjmp (sigvbuf) == 0) {
list->function(origin, av, ac); list->function (origin, av, ac);
} }
strcpy(segvinmodule, ""); strcpy (segvinmodule, "");
strcpy(segv_location, strcpy (segv_location, "Return from Module Message");
"Return from Module Message"); free (av);
free(av);
if (I == 1) if (I == 1)
free(nick); free (nick);
return; return;
} else { } else {
bot_chan_message(origin, av[0], av, ac); bot_chan_message (origin, av[0], av, ac);
if (I == 1) if (I == 1)
free(nick); free (nick);
free(av); free (av);
return; return;
} }
} }
} }
/* now, Parse the Command to the Internal Functions... */ /* now, Parse the Command to the Internal Functions... */
strcpy(segv_location, "Parse - Internal Functions"); strcpy (segv_location, "Parse - Internal Functions");
for (I = 0; I < ircd_srv.cmdcount; I++) { for (I = 0; I < ircd_srv.cmdcount; I++) {
if (!strcmp(cmd_list[I].name, cmd)) { if (!strcmp (cmd_list[I].name, cmd)) {
if (cmd_list[I].srvmsg == cmdptr) { if (cmd_list[I].srvmsg == cmdptr) {
strcpy(segv_location, cmd_list[I].name); strcpy (segv_location, cmd_list[I].name);
cmd_list[I].function(origin, av, ac); cmd_list[I].function (origin, av, ac);
cmd_list[I].usage++; cmd_list[I].usage++;
break; break;
} }
} }
} }
/* K, now Parse it to the Module functions */ /* K, now Parse it to the Module functions */
strcpy(segv_location, "Parse - Module Functions"); strcpy (segv_location, "Parse - Module Functions");
hash_scan_begin(&ms, mh); hash_scan_begin (&ms, mh);
while ((mn = hash_scan_next(&ms)) != NULL) { while ((mn = hash_scan_next (&ms)) != NULL) {
module_ptr = hnode_get(mn); module_ptr = hnode_get (mn);
fn_list = module_ptr->function_list; fn_list = module_ptr->function_list;
while (fn_list->cmd_name != NULL) { while (fn_list->cmd_name != NULL) {
/* This goes through each Command */ /* This goes through each Command */
if (!strcmp(fn_list->cmd_name, cmd)) { if (!strcmp (fn_list->cmd_name, cmd)) {
if (fn_list->srvmsg == cmdptr) { if (fn_list->srvmsg == cmdptr) {
nlog(LOG_DEBUG1, LOG_CORE, nlog (LOG_DEBUG1, LOG_CORE, "Running Module %s for Function %s", module_ptr->info->module_name, fn_list->cmd_name);
"Running Module %s for Function %s", strcpy (segv_location, module_ptr->info->module_name);
module_ptr->info->module_name, strcpy (segvinmodule, module_ptr->info->module_name);
fn_list->cmd_name); if (setjmp (sigvbuf) == 0) {
strcpy(segv_location, fn_list->function (origin, av, ac);
module_ptr->info->
module_name);
strcpy(segvinmodule,
module_ptr->info->
module_name);
if (setjmp(sigvbuf) == 0) {
fn_list->function(origin,
av, ac);
} }
strcpy(segvinmodule, ""); strcpy (segvinmodule, "");
strcpy(segv_location, strcpy (segv_location, "Parse_Return_Module");
"Parse_Return_Module");
break; break;
} }
} }
fn_list++; fn_list++;
} }
} }
free(av); free (av);
} }
@ -423,71 +392,69 @@ void parse(char *line)
/* Here are the Following Internal Functions. /* Here are the Following Internal Functions.
they should update the internal Structures */ they should update the internal Structures */
void init_ServBot() void
init_ServBot ()
{ {
char rname[63]; char rname[63];
char **av; char **av;
int ac = 0; int ac = 0;
strcpy(segv_location, "init_ServBot"); strcpy (segv_location, "init_ServBot");
if (finduser(s_Services)) if (finduser (s_Services))
/* nick already exists on the network */ /* nick already exists on the network */
snprintf(s_Services, MAXNICK, "NeoStats1"); snprintf (s_Services, MAXNICK, "NeoStats1");
snprintf(rname, 63, "/msg %s \2HELP\2", s_Services); snprintf (rname, 63, "/msg %s \2HELP\2", s_Services);
SignOn_NewBot(s_Services, Servbot.user, Servbot.host, rname, SignOn_NewBot (s_Services, Servbot.user, Servbot.host, rname, UMODE_SERVICES);
UMODE_SERVICES);
me.onchan = 1; me.onchan = 1;
AddStringToList(&av, me.uplink, &ac); AddStringToList (&av, me.uplink, &ac);
Module_Event("ONLINE", av, ac); Module_Event ("ONLINE", av, ac);
free(av); free (av);
ac = 0; ac = 0;
AddStringToList(&av, s_Services, &ac); AddStringToList (&av, s_Services, &ac);
Module_Event("SIGNON", av, ac); Module_Event ("SIGNON", av, ac);
free(av); free (av);
} }
void dopong(Server * s) void
dopong (Server * s)
{ {
char **av; char **av;
int ac = 0; int ac = 0;
if (s) { if (s) {
s->ping = time(NULL) - ping.last_sent; s->ping = time (NULL) - ping.last_sent;
if (ping.ulag > 1) if (ping.ulag > 1)
s->ping -= (float) ping.ulag; s->ping -= (float) ping.ulag;
if (!strcmp(me.s->name, s->name)) if (!strcmp (me.s->name, s->name))
ping.ulag = me.s->ping; ping.ulag = me.s->ping;
AddStringToList(&av, s->name, &ac); AddStringToList (&av, s->name, &ac);
Module_Event("PONG", av, ac); Module_Event ("PONG", av, ac);
free(av); free (av);
} else { } else {
nlog(LOG_NOTICE, LOG_CORE, nlog (LOG_NOTICE, LOG_CORE, "Received PONG from unknown server: %s", recbuf);
"Received PONG from unknown server: %s", recbuf);
} }
} }
int flood(User * u) int
flood (User * u)
{ {
time_t current = time(NULL); time_t current = time (NULL);
if (!u) { if (!u) {
nlog(LOG_WARNING, LOG_CORE, "Warning, Can't find user for FLOODcheck"); nlog (LOG_WARNING, LOG_CORE, "Warning, Can't find user for FLOODcheck");
return 0; return 0;
} }
if (UserLevel(u) >= 40) /* locop or higher */ if (UserLevel (u) >= 40) /* locop or higher */
return 0; return 0;
if (current - u->t_flood > 10) { if (current - u->t_flood > 10) {
u->t_flood = time(NULL); u->t_flood = time (NULL);
u->flood = 0; u->flood = 0;
return 0; return 0;
} }
if (u->flood >= 5) { if (u->flood >= 5) {
nlog(LOG_NORMAL, LOG_CORE, "FLOODING: %s!%s@%s", u->nick, nlog (LOG_NORMAL, LOG_CORE, "FLOODING: %s!%s@%s", u->nick, u->username, u->hostname);
u->username, u->hostname); ssvskill_cmd (u->nick, "%s!%s (Flooding Services.)", Servbot.host, s_Services);
ssvskill_cmd(u->nick,
"%s!%s (Flooding Services.)", Servbot.host,
s_Services);
return 1; return 1;
} else { } else {
u->flood++; u->flood++;
@ -496,98 +463,81 @@ int flood(User * u)
} }
/* Display our MOTD Message of the Day from the external neostats.motd file */ /* Display our MOTD Message of the Day from the external neostats.motd file */
void ShowMOTD(char *nick) void
ShowMOTD (char *nick)
{ {
FILE *fp; FILE *fp;
char buf[BUFSIZE]; char buf[BUFSIZE];
snumeric_cmd(375, nick, ":- %s Message of the Day -", me.name); snumeric_cmd (375, nick, ":- %s Message of the Day -", me.name);
snumeric_cmd(372, nick, snumeric_cmd (372, nick, ":- %d.%d.%d%s. Copyright (c) 1999 - 2002 The NeoStats Group", MAJOR, MINOR, REV, version);
":- %d.%d.%d%s. Copyright (c) 1999 - 2002 The NeoStats Group", snumeric_cmd (372, nick, ":-");
MAJOR, MINOR, REV, version);
snumeric_cmd(372, nick, ":-");
fp = fopen("neostats.motd", "r"); fp = fopen ("neostats.motd", "r");
if (fp) { if (fp) {
while (fgets(buf, sizeof(buf), fp)) { while (fgets (buf, sizeof (buf), fp)) {
buf[strlen(buf) - 1] = 0; buf[strlen (buf) - 1] = 0;
snumeric_cmd(372, nick, ":- %s", buf); snumeric_cmd (372, nick, ":- %s", buf);
} }
fclose(fp); fclose (fp);
} else { } else {
snumeric_cmd(372, nick, ":- MOTD file Missing"); snumeric_cmd (372, nick, ":- MOTD file Missing");
} }
snumeric_cmd(376, nick, ":End of /MOTD command."); snumeric_cmd (376, nick, ":End of /MOTD command.");
} }
/* Display the ADMIN Message from the external stats.admin file */ /* Display the ADMIN Message from the external stats.admin file */
void ShowADMIN(char *nick) void
ShowADMIN (char *nick)
{ {
FILE *fp; FILE *fp;
char buf[BUFSIZE]; char buf[BUFSIZE];
snumeric_cmd(256, nick, ":- %s NeoStats Admins -", me.name); snumeric_cmd (256, nick, ":- %s NeoStats Admins -", me.name);
snumeric_cmd(256, nick, snumeric_cmd (256, nick, ":- %d.%d.%d%s. Copyright (c) 1999 - 2002 The NeoStats Group", MAJOR, MINOR, REV, version);
":- %d.%d.%d%s. Copyright (c) 1999 - 2002 The NeoStats Group",
MAJOR, MINOR, REV, version);
fp = fopen("stats.admin", "r"); fp = fopen ("stats.admin", "r");
if (fp) { if (fp) {
while (fgets(buf, sizeof(buf), fp)) { while (fgets (buf, sizeof (buf), fp)) {
buf[strlen(buf) - 1] = 0; buf[strlen (buf) - 1] = 0;
snumeric_cmd(257, nick, ":- %s", buf); snumeric_cmd (257, nick, ":- %s", buf);
} }
fclose(fp); fclose (fp);
} }
snumeric_cmd(258, nick, ":End of /ADMIN command."); snumeric_cmd (258, nick, ":End of /ADMIN command.");
} }
void Showcredits(char *nick) void
Showcredits (char *nick)
{ {
snumeric_cmd(351, nick, ":- NeoStats %d.%d.%d%s Credits ", MAJOR, snumeric_cmd (351, nick, ":- NeoStats %d.%d.%d%s Credits ", MAJOR, MINOR, REV, version);
MINOR, REV, version); snumeric_cmd (351, nick, ":- Now Maintained by Shmad (shmad@neostats.net) and ^Enigma^ (enigma@neostats.net)");
snumeric_cmd(351, nick, snumeric_cmd (351, nick, ":- For Support, you can find ^Enigma^ or Shmad at");
":- Now Maintained by Shmad (shmad@neostats.net) and ^Enigma^ (enigma@neostats.net)"); snumeric_cmd (351, nick, ":- irc.irc-chat.net #NeoStats");
snumeric_cmd(351, nick, snumeric_cmd (351, nick, ":- Thanks to:");
":- For Support, you can find ^Enigma^ or Shmad at"); snumeric_cmd (351, nick, ":- \2Fish\2 still part of the team with patch submissions.");
snumeric_cmd(351, nick, ":- irc.irc-chat.net #NeoStats"); snumeric_cmd (351, nick, ":- Stskeeps for Writting the best IRCD ever!");
snumeric_cmd(351, nick, ":- Thanks to:"); snumeric_cmd (351, nick, ":- chrisv@b0rked.dhs.org for the Code for Dynamically Loading Modules (Hurrican IRCD)");
snumeric_cmd(351, nick, snumeric_cmd (351, nick, ":- monkeyIRCD for the Module Segv Catching code");
":- \2Fish\2 still part of the team with patch submissions."); snumeric_cmd (351, nick, ":- the Users of Global-irc.net and Dreaming.org for being our Guinea Pigs!");
snumeric_cmd(351, nick, snumeric_cmd (351, nick, ":- Andy For Ideas");
":- Stskeeps for Writting the best IRCD ever!"); snumeric_cmd (351, nick, ":- HeadBang for BetaTesting, and Ideas, And Hassling us for Beta Copies");
snumeric_cmd(351, nick, snumeric_cmd (351, nick, ":- sre and Jacob for development systems and access");
":- chrisv@b0rked.dhs.org for the Code for Dynamically Loading Modules (Hurrican IRCD)"); snumeric_cmd (351, nick, ":- Error51 for Translating our FAQ and README files");
snumeric_cmd(351, nick, snumeric_cmd (351, nick, ":- users and opers of irc.irc-chat.net/org for putting up with our constant coding crashes!");
":- monkeyIRCD for the Module Segv Catching code"); snumeric_cmd (351, nick, ":- Eggy for proving to use our code still had bugs when we thought it didn't (and all the bug reports!)");
snumeric_cmd(351, nick, snumeric_cmd (351, nick, ":- Hwy - Helping us even though he also has a similar project, and providing solaris porting tips :)");
":- the Users of Global-irc.net and Dreaming.org for being our Guinea Pigs!"); snumeric_cmd (351, nick, ":- M - Updating lots of Doco and code and providing lots of great feedback");
snumeric_cmd(351, nick, ":- Andy For Ideas"); snumeric_cmd (351, nick, ":- J Michael Jones - Giving us Patches to support QuantumIRCd");
snumeric_cmd(351, nick, snumeric_cmd (351, nick, ":- Blud - Giving us patches for Mystic IRCd");
":- HeadBang for BetaTesting, and Ideas, And Hassling us for Beta Copies");
snumeric_cmd(351, nick,
":- sre and Jacob for development systems and access");
snumeric_cmd(351, nick,
":- Error51 for Translating our FAQ and README files");
snumeric_cmd(351, nick,
":- users and opers of irc.irc-chat.net/org for putting up with our constant coding crashes!");
snumeric_cmd(351, nick,
":- Eggy for proving to use our code still had bugs when we thought it didn't (and all the bug reports!)");
snumeric_cmd(351, nick,
":- Hwy - Helping us even though he also has a similar project, and providing solaris porting tips :)");
snumeric_cmd(351, nick,
":- M - Updating lots of Doco and code and providing lots of great feedback");
snumeric_cmd(351, nick,
":- J Michael Jones - Giving us Patches to support QuantumIRCd");
snumeric_cmd(351, nick,
":- Blud - Giving us patches for Mystic IRCd");
} }
void ShowStats(char *what, User * u) void
ShowStats (char *what, User * u)
{ {
time_t tmp; time_t tmp;
time_t tmp2; time_t tmp2;
@ -600,49 +550,37 @@ void ShowStats(char *what, User * u)
if (!u) { if (!u) {
return; return;
} }
if (!strcasecmp(what, "u")) { if (!strcasecmp (what, "u")) {
/* server uptime - Shmad */ /* server uptime - Shmad */
int uptime = time(NULL) - me.t_start; int uptime = time (NULL) - me.t_start;
snumeric_cmd(242, u->nick, snumeric_cmd (242, u->nick, "Statistical Server up %d days, %d:%02d:%02d", uptime / 86400, (uptime / 3600) % 24, (uptime / 60) % 60, uptime % 60);
"Statistical Server up %d days, %d:%02d:%02d", } else if (!strcasecmp (what, "c")) {
uptime / 86400, (uptime / 3600) % 24,
(uptime / 60) % 60, uptime % 60);
} else if (!strcasecmp(what, "c")) {
/* Connections */ /* Connections */
snumeric_cmd(214, u->nick, "N *@%s * * %d 50", me.uplink, snumeric_cmd (214, u->nick, "N *@%s * * %d 50", me.uplink, me.port);
me.port); snumeric_cmd (213, u->nick, "C *@%s * * %d 50", me.uplink, me.port);
snumeric_cmd(213, u->nick, "C *@%s * * %d 50", me.uplink, } else if (!strcasecmp (what, "o")) {
me.port);
} else if (!strcasecmp(what, "o")) {
/* Operators */ /* Operators */
#ifdef EXTAUTH #ifdef EXTAUTH
dl = get_dl_handle("extauth"); dl = get_dl_handle ("extauth");
if (dl > 0) { if (dl > 0) {
listauth = dlsym((int *) dl, "__list_auth"); listauth = dlsym ((int *) dl, "__list_auth");
if (listauth) if (listauth)
(*listauth) (u); (*listauth) (u);
} else } else
#endif #endif
snumeric_cmd(243, u->nick, snumeric_cmd (243, u->nick, "Operators think they are God, but you and I know they are not!");
"Operators think they are God, but you and I know they are not!"); } else if (!strcasecmp (what, "l")) {
} else if (!strcasecmp(what, "l")) {
/* Port Lists */ /* Port Lists */
tmp = time(NULL) - me.lastmsg; tmp = time (NULL) - me.lastmsg;
tmp2 = time(NULL) - me.t_start; tmp2 = time (NULL) - me.t_start;
snumeric_cmd(211, u->nick, snumeric_cmd (211, u->nick, "l SendQ SendM SendBytes RcveM RcveBytes Open_Since CPU :IDLE");
"l SendQ SendM SendBytes RcveM RcveBytes Open_Since CPU :IDLE"); snumeric_cmd (241, u->nick, "%s 0 %d %d %d %d %d 0 :%d", me.uplink, me.SendM, me.SendBytes, me.RcveM, me.RcveBytes, tmp2, tmp);
snumeric_cmd(241, u->nick, "%s 0 %d %d %d %d %d 0 :%d", } else if (!strcasecmp (what, "M")) {
me.uplink, me.SendM, me.SendBytes, me.RcveM,
me.RcveBytes, tmp2, tmp);
} else if (!strcasecmp(what, "M")) {
for (I = 0; I < ircd_srv.cmdcount; I++) { for (I = 0; I < ircd_srv.cmdcount; I++) {
if (cmd_list[I].usage > 0) if (cmd_list[I].usage > 0)
snumeric_cmd(212, u->nick, snumeric_cmd (212, u->nick, "Command %s Usage %d", cmd_list[I].name, cmd_list[I].usage);
"Command %s Usage %d",
cmd_list[I].name,
cmd_list[I].usage);
} }
} }
snumeric_cmd(219, u->nick, "%s :End of /STATS report", what); snumeric_cmd (219, u->nick, "%s :End of /STATS report", what);
chanalert(s_Services, "%s Requested Stats %s", u->nick, what); chanalert (s_Services, "%s Requested Stats %s", u->nick, what);
}; };

16
ircd.h
View file

@ -18,15 +18,15 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: ircd.h,v 1.2 2003/06/26 05:14:16 fishwaldo Exp $ ** $Id: ircd.h,v 1.3 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
#ifndef IRCD_H #ifndef IRCD_H
#define IRCD_H #define IRCD_H
struct int_cmds { struct int_cmds {
char *name; char *name;
void (*function)(char *origin, char **argv, int argc); void (*function) (char *origin, char **argv, int argc);
int srvmsg; /* Should this be a Server Message(1), or a User Message?(0) */ int srvmsg; /* Should this be a Server Message(1), or a User Message?(0) */
int usage; int usage;
} int_cmds; } int_cmds;
@ -35,11 +35,11 @@ typedef struct int_cmds IntCommands;
void ShowMOTD(char *); void ShowMOTD (char *);
void ShowADMIN(char *); void ShowADMIN (char *);
void Showcredits(char *); void Showcredits (char *);
void ShowStats(char *, User *); void ShowStats (char *, User *);
void dopong(Server *); void dopong (Server *);

View file

@ -20,7 +20,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: keeper.c,v 1.10 2003/06/13 13:11:49 fishwaldo Exp $ ** $Id: keeper.c,v 1.11 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
#include "stats.h" #include "stats.h"
@ -30,35 +30,34 @@
/** @brief Gets Config Data of Type /** @brief Gets Config Data of Type
*/ */
int GetConf(void **data, int type, const char *item) int
GetConf (void **data, int type, const char *item)
{ {
char keypath[255]; char keypath[255];
int i = 0; int i = 0;
/* determine if its a module setting */ /* determine if its a module setting */
if (strlen(segvinmodule) > 0) { if (strlen (segvinmodule) > 0) {
snprintf(keypath, 255, "g/%s:/%s", segvinmodule, item); snprintf (keypath, 255, "g/%s:/%s", segvinmodule, item);
} else { } else {
snprintf(keypath, 255, "g/core:/%s", item); snprintf (keypath, 255, "g/core:/%s", item);
} }
switch (type) { switch (type) {
case CFGSTR: case CFGSTR:
i = kp_get_string(keypath, (char **) *&data); i = kp_get_string (keypath, (char **) *&data);
break; break;
case CFGINT: case CFGINT:
i = kp_get_int(keypath, (int *) *&data); i = kp_get_int (keypath, (int *) *&data);
break; break;
case CFGFLOAT: case CFGFLOAT:
i = kp_get_float(keypath, (double *) *&data); i = kp_get_float (keypath, (double *) *&data);
break; break;
case CFGBOOL: case CFGBOOL:
i = kp_get_bool(keypath, (int *) *&data); i = kp_get_bool (keypath, (int *) *&data);
break; break;
default: default:
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "Keeper: Called GetConf with invalid datatype %d", type);
"Keeper: Called GetConf with invalid datatype %d",
type);
return -1; return -1;
} }
/* check for errors */ /* check for errors */
@ -66,8 +65,7 @@ int GetConf(void **data, int type, const char *item)
/* /*
data = malloc(255); data = malloc(255);
*/ */
nlog(LOG_DEBUG1, LOG_CORE, "GetConf: %s - Path: %s", nlog (LOG_DEBUG1, LOG_CORE, "GetConf: %s - Path: %s", kp_strerror (i), keypath);
kp_strerror(i), keypath);
return -1; return -1;
} }
return 1; return 1;
@ -75,26 +73,26 @@ int GetConf(void **data, int type, const char *item)
/* @brief return a array of strings containing all subkeys in a directory */ /* @brief return a array of strings containing all subkeys in a directory */
int GetDir(char *item, char ***data) int
GetDir (char *item, char ***data)
{ {
int i; int i;
char keypath[255]; char keypath[255];
char **data1; char **data1;
/* determine if its a module setting */ /* determine if its a module setting */
if (strlen(segvinmodule) > 0) { if (strlen (segvinmodule) > 0) {
snprintf(keypath, 255, "g/%s:/%s", segvinmodule, item); snprintf (keypath, 255, "g/%s:/%s", segvinmodule, item);
} else { } else {
snprintf(keypath, 255, "g/core:/%s", item); snprintf (keypath, 255, "g/core:/%s", item);
} }
i = kp_get_dir(keypath, &data1, NULL); i = kp_get_dir (keypath, &data1, NULL);
if (i == 0) { if (i == 0) {
*data = data1; *data = data1;
return 1; return 1;
} }
*data = NULL; *data = NULL;
nlog(LOG_DEBUG1, LOG_CORE, "GetDir: %s - Path: %s", kp_strerror(i), nlog (LOG_DEBUG1, LOG_CORE, "GetDir: %s - Path: %s", kp_strerror (i), keypath);
keypath);
return -1; return -1;
} }
@ -103,24 +101,25 @@ int GetDir(char *item, char ***data)
/** @brief Sets Config Data of Type /** @brief Sets Config Data of Type
*/ */
int SetConf(void *data, int type, char *item) int
SetConf (void *data, int type, char *item)
{ {
char keypath[255]; char keypath[255];
int i = 0; int i = 0;
/* determine if its a module setting */ /* determine if its a module setting */
if (strlen(segvinmodule) > 0) { if (strlen (segvinmodule) > 0) {
snprintf(keypath, 255, "g/%s:/%s", segvinmodule, item); snprintf (keypath, 255, "g/%s:/%s", segvinmodule, item);
} else { } else {
snprintf(keypath, 255, "g/core:/%s", item); snprintf (keypath, 255, "g/core:/%s", item);
} }
switch (type) { switch (type) {
case CFGSTR: case CFGSTR:
i = kp_set_string(keypath, (char *) data); i = kp_set_string (keypath, (char *) data);
break; break;
case CFGINT: case CFGINT:
i = kp_set_int(keypath, (int) data); i = kp_set_int (keypath, (int) data);
break; break;
case CFGFLOAT: case CFGFLOAT:
/* /*
@ -128,20 +127,18 @@ int SetConf(void *data, int type, char *item)
*/ */
break; break;
case CFGBOOL: case CFGBOOL:
i = kp_set_bool(keypath, (int) data); i = kp_set_bool (keypath, (int) data);
break; break;
default: default:
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "Keeper: Called SetConf with invalid datatype %d", type);
"Keeper: Called SetConf with invalid datatype %d",
type);
return -1; return -1;
} }
/* check for errors */ /* check for errors */
if (i != 0) { if (i != 0) {
nlog(LOG_WARNING, LOG_CORE, "SetConf: %s", kp_strerror(i)); nlog (LOG_WARNING, LOG_CORE, "SetConf: %s", kp_strerror (i));
return -1; return -1;
} }
kp_flush(); kp_flush ();
return 1; return 1;
} }

444
list.c
View file

@ -37,7 +37,7 @@
* into proprietary software; there is no requirement for such software to * into proprietary software; there is no requirement for such software to
* contain a copyright notice related to this source. * contain a copyright notice related to this source.
* *
* $Id: list.c,v 1.9 2003/07/17 10:13:51 fishwaldo Exp $ * $Id: list.c,v 1.10 2003/07/30 13:58:22 fishwaldo Exp $
* $Name: $ * $Name: $
*/ */
@ -69,8 +69,7 @@
#define lnode_prev(N) ((N)->prev) #define lnode_prev(N) ((N)->prev)
#ifdef KAZLIB_RCSID #ifdef KAZLIB_RCSID
static const char rcsid[] = static const char rcsid[] = "$Id: list.c,v 1.10 2003/07/30 13:58:22 fishwaldo Exp $";
"$Id: list.c,v 1.9 2003/07/17 10:13:51 fishwaldo Exp $";
#endif #endif
/* /*
@ -80,9 +79,10 @@ static const char rcsid[] =
* is not permitted. * is not permitted.
*/ */
list_t *list_init(list_t * list, listcount_t maxcount) list_t *
list_init (list_t * list, listcount_t maxcount)
{ {
nassert(maxcount != 0); nassert (maxcount != 0);
list->nilnode.next = &list->nilnode; list->nilnode.next = &list->nilnode;
list->nilnode.prev = &list->nilnode; list->nilnode.prev = &list->nilnode;
list->nodecount = 0; list->nodecount = 0;
@ -96,11 +96,12 @@ list_t *list_init(list_t * list, listcount_t maxcount)
* should be specified as LISTCOUNT_T_MAX, or, alternately, as -1. * should be specified as LISTCOUNT_T_MAX, or, alternately, as -1.
*/ */
list_t *list_create(listcount_t maxcount) list_t *
list_create (listcount_t maxcount)
{ {
list_t *new = malloc(sizeof *new); list_t *new = malloc (sizeof *new);
if (new) { if (new) {
nassert(maxcount != 0); nassert (maxcount != 0);
new->nilnode.next = &new->nilnode; new->nilnode.next = &new->nilnode;
new->nilnode.prev = &new->nilnode; new->nilnode.prev = &new->nilnode;
new->nodecount = 0; new->nodecount = 0;
@ -114,10 +115,11 @@ list_t *list_create(listcount_t maxcount)
* The client must remove the nodes first. * The client must remove the nodes first.
*/ */
void list_destroy(list_t * list) void
list_destroy (list_t * list)
{ {
nassert(list_isempty(list)); nassert (list_isempty (list));
free(list); free (list);
} }
/* /*
@ -126,20 +128,20 @@ void list_destroy(list_t * list)
* is empty. * is empty.
*/ */
void list_destroy_nodes(list_t * list) void
list_destroy_nodes (list_t * list)
{ {
lnode_t *lnode = list_first_priv(list), *nil = lnode_t *lnode = list_first_priv (list), *nil = list_nil (list), *tmp;
list_nil(list), *tmp;
while (lnode != nil) { while (lnode != nil) {
tmp = lnode->next; tmp = lnode->next;
lnode->next = NULL; lnode->next = NULL;
lnode->prev = NULL; lnode->prev = NULL;
lnode_destroy(lnode); lnode_destroy (lnode);
lnode = tmp; lnode = tmp;
} }
list_init(list, list->maxcount); list_init (list, list->maxcount);
} }
/* /*
@ -147,35 +149,36 @@ void list_destroy_nodes(list_t * list)
* the list must all have come from the same pool. * the list must all have come from the same pool.
*/ */
void list_return_nodes(list_t * list, lnodepool_t * pool) void
list_return_nodes (list_t * list, lnodepool_t * pool)
{ {
lnode_t *lnode = list_first_priv(list), *tmp, *nil = lnode_t *lnode = list_first_priv (list), *tmp, *nil = list_nil (list);
list_nil(list);
while (lnode != nil) { while (lnode != nil) {
tmp = lnode->next; tmp = lnode->next;
lnode->next = NULL; lnode->next = NULL;
lnode->prev = NULL; lnode->prev = NULL;
lnode_return(pool, lnode); lnode_return (pool, lnode);
lnode = tmp; lnode = tmp;
} }
list_init(list, list->maxcount); list_init (list, list->maxcount);
} }
/* /*
* Insert the node ``new'' into the list immediately after ``this'' node. * Insert the node ``new'' into the list immediately after ``this'' node.
*/ */
void list_ins_after(list_t * list, lnode_t * new, lnode_t * this) void
list_ins_after (list_t * list, lnode_t * new, lnode_t * this)
{ {
lnode_t *that = this->next; lnode_t *that = this->next;
nassert(new != NULL); nassert (new != NULL);
nassert(!list_contains(list, new)); nassert (!list_contains (list, new));
nassert(!lnode_is_in_a_list(new)); nassert (!lnode_is_in_a_list (new));
nassert(this == list_nil(list) || list_contains(list, this)); nassert (this == list_nil (list) || list_contains (list, this));
nassert(list->nodecount + 1 > list->nodecount); nassert (list->nodecount + 1 > list->nodecount);
new->prev = this; new->prev = this;
new->next = that; new->next = that;
@ -183,22 +186,23 @@ void list_ins_after(list_t * list, lnode_t * new, lnode_t * this)
this->next = new; this->next = new;
list->nodecount++; list->nodecount++;
nassert(list->nodecount <= list->maxcount); nassert (list->nodecount <= list->maxcount);
} }
/* /*
* Insert the node ``new'' into the list immediately before ``this'' node. * Insert the node ``new'' into the list immediately before ``this'' node.
*/ */
void list_ins_before(list_t * list, lnode_t * new, lnode_t * this) void
list_ins_before (list_t * list, lnode_t * new, lnode_t * this)
{ {
lnode_t *that = this->prev; lnode_t *that = this->prev;
nassert(new != NULL); nassert (new != NULL);
nassert(!list_contains(list, new)); nassert (!list_contains (list, new));
nassert(!lnode_is_in_a_list(new)); nassert (!lnode_is_in_a_list (new));
nassert(this == list_nil(list) || list_contains(list, this)); nassert (this == list_nil (list) || list_contains (list, this));
nassert(list->nodecount + 1 > list->nodecount); nassert (list->nodecount + 1 > list->nodecount);
new->next = this; new->next = this;
new->prev = that; new->prev = that;
@ -206,19 +210,20 @@ void list_ins_before(list_t * list, lnode_t * new, lnode_t * this)
this->prev = new; this->prev = new;
list->nodecount++; list->nodecount++;
nassert(list->nodecount <= list->maxcount); nassert (list->nodecount <= list->maxcount);
} }
/* /*
* Delete the given node from the list. * Delete the given node from the list.
*/ */
lnode_t *list_delete(list_t * list, lnode_t * del) lnode_t *
list_delete (list_t * list, lnode_t * del)
{ {
lnode_t *next = del->next; lnode_t *next = del->next;
lnode_t *prev = del->prev; lnode_t *prev = del->prev;
nassert(list_contains(list, del)); nassert (list_contains (list, del));
prev->next = next; prev->next = next;
next->prev = prev; next->prev = prev;
@ -235,19 +240,17 @@ lnode_t *list_delete(list_t * list, lnode_t * del)
* call to the function. * call to the function.
*/ */
void list_process(list_t * list, void *context, void
void (*function) (list_t * list, lnode_t * lnode, list_process (list_t * list, void *context, void (*function) (list_t * list, lnode_t * lnode, void *context))
void *context))
{ {
lnode_t *node = list_first_priv(list), *next, *nil = lnode_t *node = list_first_priv (list), *next, *nil = list_nil (list);
list_nil(list);
while (node != nil) { while (node != nil) {
/* check for callback function deleting */ /* check for callback function deleting */
/* the next node from under us */ /* the next node from under us */
nassert(list_contains(list, node)); nassert (list_contains (list, node));
next = node->next; next = node->next;
function(list, node, context); function (list, node, context);
node = next; node = next;
} }
} }
@ -256,9 +259,10 @@ void list_process(list_t * list, void *context,
* Dynamically allocate a list node and assign it the given piece of data. * Dynamically allocate a list node and assign it the given piece of data.
*/ */
lnode_t *lnode_create(void *data) lnode_t *
lnode_create (void *data)
{ {
lnode_t *new = malloc(sizeof *new); lnode_t *new = malloc (sizeof *new);
if (new) { if (new) {
new->data = data; new->data = data;
new->next = NULL; new->next = NULL;
@ -271,7 +275,8 @@ lnode_t *lnode_create(void *data)
* Initialize a user-supplied lnode. * Initialize a user-supplied lnode.
*/ */
lnode_t *lnode_init(lnode_t * lnode, void *data) lnode_t *
lnode_init (lnode_t * lnode, void *data)
{ {
lnode->data = data; lnode->data = data;
lnode->next = NULL; lnode->next = NULL;
@ -283,10 +288,11 @@ lnode_t *lnode_init(lnode_t * lnode, void *data)
* Destroy a dynamically allocated node. * Destroy a dynamically allocated node.
*/ */
void lnode_destroy(lnode_t * lnode) void
lnode_destroy (lnode_t * lnode)
{ {
nassert(!lnode_is_in_a_list(lnode)); nassert (!lnode_is_in_a_list (lnode));
free(lnode); free (lnode);
} }
/* /*
@ -295,12 +301,12 @@ void lnode_destroy(lnode_t * lnode)
* ``n'' elements. * ``n'' elements.
*/ */
lnodepool_t *lnode_pool_init(lnodepool_t * pool, lnode_t * nodes, lnodepool_t *
listcount_t n) lnode_pool_init (lnodepool_t * pool, lnode_t * nodes, listcount_t n)
{ {
listcount_t i; listcount_t i;
nassert(n != 0); nassert (n != 0);
pool->pool = nodes; pool->pool = nodes;
pool->fre = nodes; pool->fre = nodes;
@ -317,22 +323,23 @@ lnodepool_t *lnode_pool_init(lnodepool_t * pool, lnode_t * nodes,
* Create a dynamically allocated pool of n nodes. * Create a dynamically allocated pool of n nodes.
*/ */
lnodepool_t *lnode_pool_create(listcount_t n) lnodepool_t *
lnode_pool_create (listcount_t n)
{ {
lnodepool_t *pool; lnodepool_t *pool;
lnode_t *nodes; lnode_t *nodes;
nassert(n != 0); nassert (n != 0);
pool = malloc(sizeof *pool); pool = malloc (sizeof *pool);
if (!pool) if (!pool)
return NULL; return NULL;
nodes = malloc(n * sizeof *nodes); nodes = malloc (n * sizeof *nodes);
if (!nodes) { if (!nodes) {
free(pool); free (pool);
return NULL; return NULL;
} }
lnode_pool_init(pool, nodes, n); lnode_pool_init (pool, nodes, n);
return pool; return pool;
} }
@ -340,7 +347,8 @@ lnodepool_t *lnode_pool_create(listcount_t n)
* Determine whether the given pool is from this pool. * Determine whether the given pool is from this pool.
*/ */
int lnode_pool_isfrom(lnodepool_t * pool, lnode_t * node) int
lnode_pool_isfrom (lnodepool_t * pool, lnode_t * node)
{ {
listcount_t i; listcount_t i;
@ -359,10 +367,11 @@ int lnode_pool_isfrom(lnodepool_t * pool, lnode_t * node)
* Destroy a dynamically allocated pool of nodes. * Destroy a dynamically allocated pool of nodes.
*/ */
void lnode_pool_destroy(lnodepool_t * p) void
lnode_pool_destroy (lnodepool_t * p)
{ {
free(p->pool); free (p->pool);
free(p); free (p);
} }
/* /*
@ -370,7 +379,8 @@ void lnode_pool_destroy(lnodepool_t * p)
* is exhausted. * is exhausted.
*/ */
lnode_t *lnode_borrow(lnodepool_t * pool, void *data) lnode_t *
lnode_borrow (lnodepool_t * pool, void *data)
{ {
lnode_t *new = pool->fre; lnode_t *new = pool->fre;
if (new) { if (new) {
@ -387,10 +397,11 @@ lnode_t *lnode_borrow(lnodepool_t * pool, void *data)
* from which it came. * from which it came.
*/ */
void lnode_return(lnodepool_t * pool, lnode_t * node) void
lnode_return (lnodepool_t * pool, lnode_t * node)
{ {
nassert(lnode_pool_isfrom(pool, node)); nassert (lnode_pool_isfrom (pool, node));
nassert(!lnode_is_in_a_list(node)); nassert (!lnode_is_in_a_list (node));
node->next = pool->fre; node->next = pool->fre;
node->prev = node; node->prev = node;
@ -402,11 +413,12 @@ void lnode_return(lnodepool_t * pool, lnode_t * node)
* According to this function, a list does not contain its nilnode. * According to this function, a list does not contain its nilnode.
*/ */
int list_contains(list_t * list, lnode_t * node) int
list_contains (list_t * list, lnode_t * node)
{ {
lnode_t *n, *nil = list_nil(list); lnode_t *n, *nil = list_nil (list);
for (n = list_first_priv(list); n != nil; n = lnode_next(n)) { for (n = list_first_priv (list); n != nil; n = lnode_next (n)) {
if (node == n) if (node == n)
return 1; return 1;
} }
@ -420,13 +432,13 @@ int list_contains(list_t * list, lnode_t * node)
* list. * list.
*/ */
void list_extract(list_t * dest, list_t * source, lnode_t * first, void
lnode_t * last) list_extract (list_t * dest, list_t * source, lnode_t * first, lnode_t * last)
{ {
listcount_t moved = 1; listcount_t moved = 1;
nassert(first == NULL || list_contains(source, first)); nassert (first == NULL || list_contains (source, first));
nassert(last == NULL || list_contains(source, last)); nassert (last == NULL || list_contains (source, last));
if (first == NULL || last == NULL) if (first == NULL || last == NULL)
return; return;
@ -445,23 +457,23 @@ void list_extract(list_t * dest, list_t * source, lnode_t * first,
while (first != last) { while (first != last) {
first = first->next; first = first->next;
nassert(first != list_nil(source)); /* oops, last before first! */ nassert (first != list_nil (source)); /* oops, last before first! */
moved++; moved++;
} }
/* nassert no overflows */ /* nassert no overflows */
nassert(source->nodecount - moved <= source->nodecount); nassert (source->nodecount - moved <= source->nodecount);
nassert(dest->nodecount + moved >= dest->nodecount); nassert (dest->nodecount + moved >= dest->nodecount);
/* nassert no weirdness */ /* nassert no weirdness */
nassert(moved <= source->nodecount); nassert (moved <= source->nodecount);
source->nodecount -= moved; source->nodecount -= moved;
dest->nodecount += moved; dest->nodecount += moved;
/* nassert list sanity */ /* nassert list sanity */
nassert(list_verify(source)); nassert (list_verify (source));
nassert(list_verify(dest)); nassert (list_verify (dest));
} }
@ -473,12 +485,13 @@ void list_extract(list_t * dest, list_t * source, lnode_t * first,
* order. * order.
*/ */
void list_transfer(list_t * dest, list_t * source, lnode_t * first) void
list_transfer (list_t * dest, list_t * source, lnode_t * first)
{ {
listcount_t moved = 1; listcount_t moved = 1;
lnode_t *last; lnode_t *last;
nassert(first == NULL || list_contains(source, first)); nassert (first == NULL || list_contains (source, first));
if (first == NULL) if (first == NULL)
return; return;
@ -499,48 +512,48 @@ void list_transfer(list_t * dest, list_t * source, lnode_t * first)
} }
/* nassert no overflows */ /* nassert no overflows */
nassert(source->nodecount - moved <= source->nodecount); nassert (source->nodecount - moved <= source->nodecount);
nassert(dest->nodecount + moved >= dest->nodecount); nassert (dest->nodecount + moved >= dest->nodecount);
/* nassert no weirdness */ /* nassert no weirdness */
nassert(moved <= source->nodecount); nassert (moved <= source->nodecount);
source->nodecount -= moved; source->nodecount -= moved;
dest->nodecount += moved; dest->nodecount += moved;
/* nassert list sanity */ /* nassert list sanity */
nassert(list_verify(source)); nassert (list_verify (source));
nassert(list_verify(dest)); nassert (list_verify (dest));
} }
void list_merge(list_t * dest, list_t * sour, void
int compare(const void *, const void *)) list_merge (list_t * dest, list_t * sour, int compare (const void *, const void *))
{ {
lnode_t *dn, *sn, *tn; lnode_t *dn, *sn, *tn;
lnode_t *d_nil = list_nil(dest), *s_nil = list_nil(sour); lnode_t *d_nil = list_nil (dest), *s_nil = list_nil (sour);
/* Nothing to do if source and destination list are the same. */ /* Nothing to do if source and destination list are the same. */
if (dest == sour) if (dest == sour)
return; return;
/* overflow check */ /* overflow check */
nassert(list_count(sour) + list_count(dest) >= list_count(sour)); nassert (list_count (sour) + list_count (dest) >= list_count (sour));
/* lists must be sorted */ /* lists must be sorted */
nassert(list_is_sorted(sour, compare)); nassert (list_is_sorted (sour, compare));
nassert(list_is_sorted(dest, compare)); nassert (list_is_sorted (dest, compare));
dn = list_first_priv(dest); dn = list_first_priv (dest);
sn = list_first_priv(sour); sn = list_first_priv (sour);
while (dn != d_nil && sn != s_nil) { while (dn != d_nil && sn != s_nil) {
if (compare(lnode_get(dn), lnode_get(sn)) >= 0) { if (compare (lnode_get (dn), lnode_get (sn)) >= 0) {
tn = lnode_next(sn); tn = lnode_next (sn);
list_delete(sour, sn); list_delete (sour, sn);
list_ins_before(dest, sn, dn); list_ins_before (dest, sn, dn);
sn = tn; sn = tn;
} else { } else {
dn = lnode_next(dn); dn = lnode_next (dn);
} }
} }
@ -548,40 +561,40 @@ void list_merge(list_t * dest, list_t * sour,
return; return;
if (sn != s_nil) if (sn != s_nil)
list_transfer(dest, sour, sn); list_transfer (dest, sour, sn);
} }
void list_sort(list_t * list, int compare(const void *, const void *)) void
list_sort (list_t * list, int compare (const void *, const void *))
{ {
list_t extra; list_t extra;
listcount_t middle; listcount_t middle;
lnode_t *node; lnode_t *node;
if (list_count(list) > 1) { if (list_count (list) > 1) {
middle = list_count(list) / 2; middle = list_count (list) / 2;
node = list_first_priv(list); node = list_first_priv (list);
list_init(&extra, list_count(list) - middle); list_init (&extra, list_count (list) - middle);
while (middle--) while (middle--)
node = lnode_next(node); node = lnode_next (node);
list_transfer(&extra, list, node); list_transfer (&extra, list, node);
list_sort(list, compare); list_sort (list, compare);
list_sort(&extra, compare); list_sort (&extra, compare);
list_merge(list, &extra, compare); list_merge (list, &extra, compare);
} }
nassert(list_is_sorted(list, compare)); nassert (list_is_sorted (list, compare));
} }
lnode_t *list_find(list_t * list, const void *key, lnode_t *
int compare(const void *, const void *)) list_find (list_t * list, const void *key, int compare (const void *, const void *))
{ {
lnode_t *node; lnode_t *node;
for (node = list_first_priv(list); node != list_nil(list); for (node = list_first_priv (list); node != list_nil (list); node = node->next) {
node = node->next) { if (compare (lnode_get (node), key) == 0)
if (compare(lnode_get(node), key) == 0)
return node; return node;
} }
@ -593,18 +606,19 @@ lnode_t *list_find(list_t * list, const void *key,
* Return 1 if the list is in sorted order, 0 otherwise * Return 1 if the list is in sorted order, 0 otherwise
*/ */
int list_is_sorted(list_t * list, int compare(const void *, const void *)) int
list_is_sorted (list_t * list, int compare (const void *, const void *))
{ {
lnode_t *node, *next, *nil; lnode_t *node, *next, *nil;
next = nil = list_nil(list); next = nil = list_nil (list);
node = list_first_priv(list); node = list_first_priv (list);
if (node != nil) if (node != nil)
next = lnode_next(node); next = lnode_next (node);
for (; next != nil; node = next, next = lnode_next(next)) { for (; next != nil; node = next, next = lnode_next (next)) {
if (compare(lnode_get(node), lnode_get(next)) > 0) if (compare (lnode_get (node), lnode_get (next)) > 0)
return 0; return 0;
} }
@ -635,7 +649,8 @@ int list_is_sorted(list_t * list, int compare(const void *, const void *))
* Return 1 if the list is empty, 0 otherwise * Return 1 if the list is empty, 0 otherwise
*/ */
int list_isempty(list_t * list) int
list_isempty (list_t * list)
{ {
return list->nodecount == 0; return list->nodecount == 0;
} }
@ -645,7 +660,8 @@ int list_isempty(list_t * list)
* Permitted only on bounded lists. * Permitted only on bounded lists.
*/ */
int list_isfull(list_t * list) int
list_isfull (list_t * list)
{ {
return list->nodecount == list->maxcount; return list->nodecount == list->maxcount;
} }
@ -654,7 +670,8 @@ int list_isfull(list_t * list)
* Check if the node pool is empty. * Check if the node pool is empty.
*/ */
int lnode_pool_isempty(lnodepool_t * pool) int
lnode_pool_isempty (lnodepool_t * pool)
{ {
return (pool->fre == NULL); return (pool->fre == NULL);
} }
@ -663,25 +680,28 @@ int lnode_pool_isempty(lnodepool_t * pool)
* Add the given node at the end of the list * Add the given node at the end of the list
*/ */
void list_append(list_t * list, lnode_t * node) void
list_append (list_t * list, lnode_t * node)
{ {
list_ins_before(list, node, &list->nilnode); list_ins_before (list, node, &list->nilnode);
} }
/* /*
* Add the given node at the beginning of the list. * Add the given node at the beginning of the list.
*/ */
void list_prepend(list_t * list, lnode_t * node) void
list_prepend (list_t * list, lnode_t * node)
{ {
list_ins_after(list, node, &list->nilnode); list_ins_after (list, node, &list->nilnode);
} }
/* /*
* Retrieve the first node of the list * Retrieve the first node of the list
*/ */
lnode_t *list_first(list_t * list) lnode_t *
list_first (list_t * list)
{ {
if (list->nilnode.next == &list->nilnode) if (list->nilnode.next == &list->nilnode)
return NULL; return NULL;
@ -692,7 +712,8 @@ lnode_t *list_first(list_t * list)
* Retrieve the last node of the list * Retrieve the last node of the list
*/ */
lnode_t *list_last(list_t * list) lnode_t *
list_last (list_t * list)
{ {
if (list->nilnode.prev == &list->nilnode) if (list->nilnode.prev == &list->nilnode)
return NULL; return NULL;
@ -703,7 +724,8 @@ lnode_t *list_last(list_t * list)
* Retrieve the count of nodes in the list * Retrieve the count of nodes in the list
*/ */
listcount_t list_count(list_t * list) listcount_t
list_count (list_t * list)
{ {
return list->nodecount; return list->nodecount;
} }
@ -712,18 +734,20 @@ listcount_t list_count(list_t * list)
* Remove the first node from the list and return it. * Remove the first node from the list and return it.
*/ */
lnode_t *list_del_first(list_t * list) lnode_t *
list_del_first (list_t * list)
{ {
return list_delete(list, list->nilnode.next); return list_delete (list, list->nilnode.next);
} }
/* /*
* Remove the last node from the list and return it. * Remove the last node from the list and return it.
*/ */
lnode_t *list_del_last(list_t * list) lnode_t *
list_del_last (list_t * list)
{ {
return list_delete(list, list->nilnode.prev); return list_delete (list, list->nilnode.prev);
} }
@ -731,7 +755,8 @@ lnode_t *list_del_last(list_t * list)
* Associate a data item with the given node. * Associate a data item with the given node.
*/ */
void lnode_put(lnode_t * lnode, void *data) void
lnode_put (lnode_t * lnode, void *data)
{ {
lnode->data = data; lnode->data = data;
} }
@ -740,7 +765,8 @@ void lnode_put(lnode_t * lnode, void *data)
* Retrieve the data item associated with the node. * Retrieve the data item associated with the node.
*/ */
void *lnode_get(lnode_t * lnode) void *
lnode_get (lnode_t * lnode)
{ {
return lnode->data; return lnode->data;
} }
@ -750,11 +776,12 @@ void *lnode_get(lnode_t * lnode)
* NULL is returned. * NULL is returned.
*/ */
lnode_t *list_next(list_t * list, lnode_t * lnode) lnode_t *
list_next (list_t * list, lnode_t * lnode)
{ {
nassert(list_contains(list, lnode)); nassert (list_contains (list, lnode));
if (lnode->next == list_nil(list)) if (lnode->next == list_nil (list))
return NULL; return NULL;
return lnode->next; return lnode->next;
} }
@ -763,11 +790,12 @@ lnode_t *list_next(list_t * list, lnode_t * lnode)
* Retrieve the node's predecessor. See comment for lnode_next(). * Retrieve the node's predecessor. See comment for lnode_next().
*/ */
lnode_t *list_prev(list_t * list, lnode_t * lnode) lnode_t *
list_prev (list_t * list, lnode_t * lnode)
{ {
nassert(list_contains(list, lnode)); nassert (list_contains (list, lnode));
if (lnode->prev == list_nil(list)) if (lnode->prev == list_nil (list))
return NULL; return NULL;
return lnode->prev; return lnode->prev;
} }
@ -776,16 +804,18 @@ lnode_t *list_prev(list_t * list, lnode_t * lnode)
* Return 1 if the lnode is in some list, otherwise return 0. * Return 1 if the lnode is in some list, otherwise return 0.
*/ */
int lnode_is_in_a_list(lnode_t * lnode) int
lnode_is_in_a_list (lnode_t * lnode)
{ {
return (lnode->next != NULL || lnode->prev != NULL); return (lnode->next != NULL || lnode->prev != NULL);
} }
int list_verify(list_t * list) int
list_verify (list_t * list)
{ {
lnode_t *node = list_first_priv(list), *nil = list_nil(list); lnode_t *node = list_first_priv (list), *nil = list_nil (list);
listcount_t count = list_count(list); listcount_t count = list_count (list);
if (node->prev != nil) { if (node->prev != nil) {
return 0; return 0;
@ -808,9 +838,10 @@ int list_verify(list_t * list)
return 1; return 1;
} }
int comparef(const void *key1, const void *key2) int
comparef (const void *key1, const void *key2)
{ {
return strcasecmp(key1, key2); return strcasecmp (key1, key2);
} }
@ -824,133 +855,132 @@ int comparef(const void *key1, const void *key2)
typedef char input_t[256]; typedef char input_t[256];
static int tokenize(char *string, ...) static int
tokenize (char *string, ...)
{ {
char **tokptr; char **tokptr;
va_list arglist; va_list arglist;
int tokcount = 0; int tokcount = 0;
va_start(arglist, string); va_start (arglist, string);
tokptr = va_arg(arglist, char **); tokptr = va_arg (arglist, char **);
while (tokptr) { while (tokptr) {
while (*string && isspace((unsigned char) *string)) while (*string && isspace ((unsigned char) *string))
string++; string++;
if (!*string) if (!*string)
break; break;
*tokptr = string; *tokptr = string;
while (*string && !isspace((unsigned char) *string)) while (*string && !isspace ((unsigned char) *string))
string++; string++;
tokptr = va_arg(arglist, char **); tokptr = va_arg (arglist, char **);
tokcount++; tokcount++;
if (!*string) if (!*string)
break; break;
*string++ = 0; *string++ = 0;
} }
va_end(arglist); va_end (arglist);
return tokcount; return tokcount;
} }
static char *dupstring(char *str) static char *
dupstring (char *str)
{ {
int sz = strlen(str) + 1; int sz = strlen (str) + 1;
char *new = malloc(sz); char *new = malloc (sz);
if (new) if (new)
memcpy(new, str, sz); memcpy (new, str, sz);
return new; return new;
} }
int main(void) int
main (void)
{ {
input_t in; input_t in;
list_t *l = list_create(LISTCOUNT_T_MAX); list_t *l = list_create (LISTCOUNT_T_MAX);
lnode_t *ln; lnode_t *ln;
char *tok1, *val; char *tok1, *val;
int prompt = 0; int prompt = 0;
char *help = char *help =
"a <val> append value to list\n" "a <val> append value to list\n"
"d <val> delete value from list\n" "d <val> delete value from list\n"
"l <val> lookup value in list\n" "l <val> lookup value in list\n"
"s sort list\n" "s sort list\n"
"c show number of entries\n" "c show number of entries\n" "t dump whole list\n" "p turn prompt on\n" "q quit";
"t dump whole list\n"
"p turn prompt on\n"
"q quit";
if (!l) if (!l)
puts("list_create failed"); puts ("list_create failed");
for (;;) { for (;;) {
if (prompt) if (prompt)
putchar('>'); putchar ('>');
fflush(stdout); fflush (stdout);
if (!fgets(in, sizeof(input_t), stdin)) if (!fgets (in, sizeof (input_t), stdin))
break; break;
switch (in[0]) { switch (in[0]) {
case '?': case '?':
puts(help); puts (help);
break; break;
case 'a': case 'a':
if (tokenize(in + 1, &tok1, (char **) 0) != 1) { if (tokenize (in + 1, &tok1, (char **) 0) != 1) {
puts("what?"); puts ("what?");
break; break;
} }
val = dupstring(tok1); val = dupstring (tok1);
ln = lnode_create(val); ln = lnode_create (val);
if (!val || !ln) { if (!val || !ln) {
puts("allocation failure"); puts ("allocation failure");
if (ln) if (ln)
lnode_destroy(ln); lnode_destroy (ln);
free(val); free (val);
break; break;
} }
list_append(l, ln); list_append (l, ln);
break; break;
case 'd': case 'd':
if (tokenize(in + 1, &tok1, (char **) 0) != 1) { if (tokenize (in + 1, &tok1, (char **) 0) != 1) {
puts("what?"); puts ("what?");
break; break;
} }
ln = list_find(l, tok1, comparef); ln = list_find (l, tok1, comparef);
if (!ln) { if (!ln) {
puts("list_find failed"); puts ("list_find failed");
break; break;
} }
list_delete(l, ln); list_delete (l, ln);
val = lnode_get(ln); val = lnode_get (ln);
lnode_destroy(ln); lnode_destroy (ln);
free(val); free (val);
break; break;
case 'l': case 'l':
if (tokenize(in + 1, &tok1, (char **) 0) != 1) { if (tokenize (in + 1, &tok1, (char **) 0) != 1) {
puts("what?"); puts ("what?");
break; break;
} }
ln = list_find(l, tok1, comparef); ln = list_find (l, tok1, comparef);
if (!ln) if (!ln)
puts("list_find failed"); puts ("list_find failed");
else else
puts("found"); puts ("found");
break; break;
case 's': case 's':
list_sort(l, comparef); list_sort (l, comparef);
break; break;
case 'c': case 'c':
printf("%lu\n", (unsigned long) list_count(l)); printf ("%lu\n", (unsigned long) list_count (l));
break; break;
case 't': case 't':
for (ln = list_first(l); ln != 0; for (ln = list_first (l); ln != 0; ln = list_next (l, ln))
ln = list_next(l, ln)) puts (lnode_get (ln));
puts(lnode_get(ln));
break; break;
case 'q': case 'q':
exit(0); exit (0);
break; break;
case '\0': case '\0':
break; break;
@ -958,8 +988,8 @@ int main(void)
prompt = 1; prompt = 1;
break; break;
default: default:
putchar('?'); putchar ('?');
putchar('\n'); putchar ('\n');
break; break;
} }
} }
@ -967,4 +997,4 @@ int main(void)
return 0; return 0;
} }
#endif /* defined TEST_MAIN */ #endif /* defined TEST_MAIN */

143
list.h
View file

@ -37,7 +37,7 @@
* into proprietary software; there is no requirement for such software to * into proprietary software; there is no requirement for such software to
* contain a copyright notice related to this source. * contain a copyright notice related to this source.
* *
* $Id: list.h,v 1.3 2002/09/04 08:40:27 fishwaldo Exp $ * $Id: list.h,v 1.4 2003/07/30 13:58:22 fishwaldo Exp $
* $Name: $ * $Name: $
*/ */
@ -61,90 +61,90 @@
extern "C" { extern "C" {
#endif #endif
typedef unsigned long listcount_t; typedef unsigned long listcount_t;
#define LISTCOUNT_T_MAX ULONG_MAX #define LISTCOUNT_T_MAX ULONG_MAX
typedef struct lnode_t { typedef struct lnode_t {
#if defined(LIST_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG) #if defined(LIST_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
struct lnode_t *list_next; struct lnode_t *list_next;
struct lnode_t *list_prev; struct lnode_t *list_prev;
void *list_data; void *list_data;
#else #else
int list_dummy; int list_dummy;
#endif #endif
} lnode_t; } lnode_t;
typedef struct lnodepool_t { typedef struct lnodepool_t {
#if defined(LIST_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG) #if defined(LIST_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
struct lnode_t *list_pool; struct lnode_t *list_pool;
struct lnode_t *list_free; struct lnode_t *list_free;
listcount_t list_size; listcount_t list_size;
#else #else
int list_dummy; int list_dummy;
#endif #endif
} lnodepool_t; } lnodepool_t;
typedef struct list_t { typedef struct list_t {
#if defined(LIST_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG) #if defined(LIST_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
lnode_t list_nilnode; lnode_t list_nilnode;
listcount_t list_nodecount; listcount_t list_nodecount;
listcount_t list_maxcount; listcount_t list_maxcount;
#else #else
int list_dummy; int list_dummy;
#endif #endif
} list_t; } list_t;
lnode_t *lnode_create(void *); lnode_t *lnode_create (void *);
lnode_t *lnode_init(lnode_t *, void *); lnode_t *lnode_init (lnode_t *, void *);
void lnode_destroy(lnode_t *); void lnode_destroy (lnode_t *);
void lnode_put(lnode_t *, void *); void lnode_put (lnode_t *, void *);
void *lnode_get(lnode_t *); void *lnode_get (lnode_t *);
int lnode_is_in_a_list(lnode_t *); int lnode_is_in_a_list (lnode_t *);
#if defined(LIST_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG) #if defined(LIST_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
#define lnode_put(N, D) ((N)->list_data = (D)) #define lnode_put(N, D) ((N)->list_data = (D))
#define lnode_get(N) ((N)->list_data) #define lnode_get(N) ((N)->list_data)
#endif #endif
lnodepool_t *lnode_pool_init(lnodepool_t *, lnode_t *, listcount_t); lnodepool_t *lnode_pool_init (lnodepool_t *, lnode_t *, listcount_t);
lnodepool_t *lnode_pool_create(listcount_t); lnodepool_t *lnode_pool_create (listcount_t);
void lnode_pool_destroy(lnodepool_t *); void lnode_pool_destroy (lnodepool_t *);
lnode_t *lnode_borrow(lnodepool_t *, void *); lnode_t *lnode_borrow (lnodepool_t *, void *);
void lnode_return(lnodepool_t *, lnode_t *); void lnode_return (lnodepool_t *, lnode_t *);
int lnode_pool_isempty(lnodepool_t *); int lnode_pool_isempty (lnodepool_t *);
int lnode_pool_isfrom(lnodepool_t *, lnode_t *); int lnode_pool_isfrom (lnodepool_t *, lnode_t *);
int comparef(const void *, const void *); int comparef (const void *, const void *);
list_t *list_init(list_t *, listcount_t); list_t *list_init (list_t *, listcount_t);
list_t *list_create(listcount_t); list_t *list_create (listcount_t);
void list_destroy(list_t *); void list_destroy (list_t *);
void list_destroy_nodes(list_t *); void list_destroy_nodes (list_t *);
void list_return_nodes(list_t *, lnodepool_t *); void list_return_nodes (list_t *, lnodepool_t *);
listcount_t list_count(list_t *); listcount_t list_count (list_t *);
int list_isempty(list_t *); int list_isempty (list_t *);
int list_isfull(list_t *); int list_isfull (list_t *);
int list_contains(list_t *, lnode_t *); int list_contains (list_t *, lnode_t *);
void list_append(list_t *, lnode_t *); void list_append (list_t *, lnode_t *);
void list_prepend(list_t *, lnode_t *); void list_prepend (list_t *, lnode_t *);
void list_ins_before(list_t *, lnode_t *, lnode_t *); void list_ins_before (list_t *, lnode_t *, lnode_t *);
void list_ins_after(list_t *, lnode_t *, lnode_t *); void list_ins_after (list_t *, lnode_t *, lnode_t *);
lnode_t *list_first(list_t *); lnode_t *list_first (list_t *);
lnode_t *list_last(list_t *); lnode_t *list_last (list_t *);
lnode_t *list_next(list_t *, lnode_t *); lnode_t *list_next (list_t *, lnode_t *);
lnode_t *list_prev(list_t *, lnode_t *); lnode_t *list_prev (list_t *, lnode_t *);
lnode_t *list_del_first(list_t *); lnode_t *list_del_first (list_t *);
lnode_t *list_del_last(list_t *); lnode_t *list_del_last (list_t *);
lnode_t *list_delete(list_t *, lnode_t *); lnode_t *list_delete (list_t *, lnode_t *);
void list_process(list_t *, void *, void (*)(list_t *, lnode_t *, void *)); void list_process (list_t *, void *, void (*)(list_t *, lnode_t *, void *));
int list_verify(list_t *); int list_verify (list_t *);
#if defined(LIST_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG) #if defined(LIST_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
#define lnode_pool_isempty(P) ((P)->list_free == 0) #define lnode_pool_isempty(P) ((P)->list_free == 0)
@ -166,15 +166,14 @@ int list_verify(list_t *);
/* destination list on the left, source on the right */ /* destination list on the left, source on the right */
void list_extract(list_t *, list_t *, lnode_t *, lnode_t *); void list_extract (list_t *, list_t *, lnode_t *, lnode_t *);
void list_transfer(list_t *, list_t *, lnode_t *first); void list_transfer (list_t *, list_t *, lnode_t * first);
void list_merge(list_t *, list_t *, int (const void *, const void *)); void list_merge (list_t *, list_t *, int (const void *, const void *));
void list_sort(list_t *, int (const void *, const void *)); void list_sort (list_t *, int (const void *, const void *));
lnode_t *list_find(list_t *, const void *, int (const void *, const void *)); lnode_t *list_find (list_t *, const void *, int (const void *, const void *));
int list_is_sorted(list_t *, int (const void *, const void *)); int list_is_sorted (list_t *, int (const void *, const void *));
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

160
log.c
View file

@ -20,7 +20,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: log.c,v 1.11 2003/07/17 10:13:51 fishwaldo Exp $ ** $Id: log.c,v 1.12 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
#include "stats.h" #include "stats.h"
@ -51,17 +51,18 @@ struct logs_ {
hash_t *logs; hash_t *logs;
void *close_logs(); void *close_logs ();
/** @brief Initilize the logging functions /** @brief Initilize the logging functions
*/ */
void init_logs() void
init_logs ()
{ {
logs = hash_create(-1, 0, 0); logs = hash_create (-1, 0, 0);
if (!logs) { if (!logs) {
printf("ERROR: Can't Initilize Log SubSystem. Exiting!"); printf ("ERROR: Can't Initilize Log SubSystem. Exiting!");
/* if this fails, no need to call do_exit, as this is the first thing that runs... so nothing to do! */ /* if this fails, no need to call do_exit, as this is the first thing that runs... so nothing to do! */
exit(-1); exit (-1);
} }
} }
@ -69,25 +70,25 @@ void init_logs()
*/ */
void *close_logs() void *
close_logs ()
{ {
hscan_t hs; hscan_t hs;
hnode_t *hn; hnode_t *hn;
struct logs_ *logentry; struct logs_ *logentry;
hash_scan_begin(&hs, logs); hash_scan_begin (&hs, logs);
while ((hn = hash_scan_next(&hs)) != NULL) { while ((hn = hash_scan_next (&hs)) != NULL) {
logentry = hnode_get(hn); logentry = hnode_get (hn);
fflush(logentry->logfile); fflush (logentry->logfile);
logentry->flush = 0; logentry->flush = 0;
#ifdef DEBUG #ifdef DEBUG
printf("Closing Logfile %s (%s)\n", logentry->name, printf ("Closing Logfile %s (%s)\n", logentry->name, (char *) hnode_getkey (hn));
(char *) hnode_getkey(hn));
#endif #endif
fclose(logentry->logfile); fclose (logentry->logfile);
hash_scan_delete(logs, hn); hash_scan_delete (logs, hn);
hnode_destroy(hn); hnode_destroy (hn);
free(logentry); free (logentry);
} }
return NULL; return NULL;
} }
@ -95,113 +96,101 @@ void *close_logs()
/** @Configurable logging function /** @Configurable logging function
*/ */
void nlog(int level, int scope, char *fmt, ...) void
nlog (int level, int scope, char *fmt, ...)
{ {
va_list ap; va_list ap;
char buf[512], fmttime[80]; char buf[512], fmttime[80];
int gotlog; int gotlog;
hnode_t *hn; hnode_t *hn;
struct logs_ *logentry; struct logs_ *logentry;
time_t ts = time(NULL); time_t ts = time (NULL);
if (level <= config.debug) { if (level <= config.debug) {
/* if scope is > 0, then log to a diff file */ /* if scope is > 0, then log to a diff file */
if (scope > 0) { if (scope > 0) {
if (strlen(segvinmodule) > 1) { if (strlen (segvinmodule) > 1) {
hn = hash_lookup(logs, segvinmodule); hn = hash_lookup (logs, segvinmodule);
} else { } else {
nlog(LOG_ERROR, LOG_CORE, nlog (LOG_ERROR, LOG_CORE, "Warning, nlog called with LOG_MOD, but segvinmodule is blank! Logging to Core");
"Warning, nlog called with LOG_MOD, but segvinmodule is blank! Logging to Core"); hn = hash_lookup (logs, "core");
hn = hash_lookup(logs, "core");
} }
} else { } else {
hn = hash_lookup(logs, "core"); hn = hash_lookup (logs, "core");
} }
if (hn) { if (hn) {
/* we found our log entry */ /* we found our log entry */
logentry = hnode_get(hn); logentry = hnode_get (hn);
gotlog = 1; gotlog = 1;
} else { } else {
/* log file not found */ /* log file not found */
if ((strlen(segvinmodule) <= 1) && (scope > 0)) { if ((strlen (segvinmodule) <= 1) && (scope > 0)) {
#ifdef DEBUG #ifdef DEBUG
printf printf ("segvinmodule is blank, but scope is for Modules!\n");
("segvinmodule is blank, but scope is for Modules!\n");
#endif #endif
/* bad, but hey ! */ /* bad, but hey ! */
scope = 0; scope = 0;
} }
logentry = malloc(sizeof(struct logs_)); logentry = malloc (sizeof (struct logs_));
strncpy(logentry->name, strncpy (logentry->name, scope > 0 ? segvinmodule : "core", 30);
scope > 0 ? segvinmodule : "core", 30); snprintf (buf, 40, "logs/%s.log", scope > 0 ? segvinmodule : "NeoStats");
snprintf(buf, 40, "logs/%s.log", logentry->logfile = fopen (buf, "a");
scope > 0 ? segvinmodule : "NeoStats");
logentry->logfile = fopen(buf, "a");
logentry->flush = 0; logentry->flush = 0;
hn = hnode_create(logentry); hn = hnode_create (logentry);
hash_insert(logs, hn, logentry->name); hash_insert (logs, hn, logentry->name);
} }
if (!logentry->logfile) { if (!logentry->logfile) {
#ifdef DEBUG #ifdef DEBUG
printf("%s\n", strerror(errno)); printf ("%s\n", strerror (errno));
do_exit(0); do_exit (0);
#endif #endif
} }
strftime(fmttime, 80, "%d/%m/%Y[%H:%M]", localtime(&ts)); strftime (fmttime, 80, "%d/%m/%Y[%H:%M]", localtime (&ts));
va_start(ap, fmt); va_start (ap, fmt);
vsnprintf(buf, 512, fmt, ap); vsnprintf (buf, 512, fmt, ap);
fprintf(logentry->logfile, "(%s) %s %s - %s\n", fmttime, fprintf (logentry->logfile, "(%s) %s %s - %s\n", fmttime, loglevels[level - 1], scope > 0 ? segvinmodule : "CORE", buf);
loglevels[level - 1],
scope > 0 ? segvinmodule : "CORE", buf);
logentry->flush = 1; logentry->flush = 1;
#ifndef DEBUG #ifndef DEBUG
if (config.foreground) if (config.foreground)
#endif #endif
printf("%s %s - %s\n", loglevels[level - 1], printf ("%s %s - %s\n", loglevels[level - 1], scope > 0 ? segvinmodule : "CORE", buf);
scope > 0 ? segvinmodule : "CORE", buf); va_end (ap);
va_end(ap);
} }
} }
void ResetLogs() void
ResetLogs ()
{ {
char tmp[255], tmp2[255]; char tmp[255], tmp2[255];
time_t t = time(NULL); time_t t = time (NULL);
hscan_t hs; hscan_t hs;
hnode_t *hn; hnode_t *hn;
struct logs_ *logentry; struct logs_ *logentry;
strcpy(segv_location, "ResetLogs"); strcpy (segv_location, "ResetLogs");
hash_scan_begin(&hs, logs); hash_scan_begin (&hs, logs);
while ((hn = hash_scan_next(&hs)) != NULL) { while ((hn = hash_scan_next (&hs)) != NULL) {
logentry = hnode_get(hn); logentry = hnode_get (hn);
if (logentry->flush > 0) { if (logentry->flush > 0) {
fflush(logentry->logfile); fflush (logentry->logfile);
logentry->flush = 0; logentry->flush = 0;
#ifdef DEBUG #ifdef DEBUG
printf("Closing Logfile %s (%s)\n", logentry->name, printf ("Closing Logfile %s (%s)\n", logentry->name, (char *) hnode_getkey (hn));
(char *) hnode_getkey(hn));
#endif #endif
fclose(logentry->logfile); fclose (logentry->logfile);
if (!strcasecmp(logentry->name, "core")) { if (!strcasecmp (logentry->name, "core")) {
strftime(tmp, 255, strftime (tmp, 255, "logs/NeoStats-%m-%d.log", localtime (&t));
"logs/NeoStats-%m-%d.log", rename ("logs/NeoStats.log", tmp);
localtime(&t)); logentry->logfile = fopen ("logs/NeoStats.log", "a");
rename("logs/NeoStats.log", tmp);
logentry->logfile =
fopen("logs/NeoStats.log", "a");
} else { } else {
strftime(tmp2, 255, "%m-%d.log", strftime (tmp2, 255, "%m-%d.log", localtime (&t));
localtime(&t)); snprintf (tmp, 255, "logs/%s-%s", logentry->name, tmp2);
snprintf(tmp, 255, "logs/%s-%s", snprintf (tmp2, 255, "logs/%s.log", logentry->name);
logentry->name, tmp2); rename (tmp2, tmp);
snprintf(tmp2, 255, "logs/%s.log", logentry->logfile = fopen (tmp2, "a");
logentry->name);
rename(tmp2, tmp);
logentry->logfile = fopen(tmp2, "a");
} }
} }
} }
@ -210,26 +199,27 @@ void ResetLogs()
/* this is for printing out details during a assertion failure */ /* this is for printing out details during a assertion failure */
extern void nassert_fail(const char *expr, const char *file, const int line, const char *infunk) { extern void
nassert_fail (const char *expr, const char *file, const int line, const char *infunk)
{
#ifdef HAVE_BACKTRACE #ifdef HAVE_BACKTRACE
void *array[50]; void *array[50];
size_t size; size_t size;
char **strings; char **strings;
size_t i; size_t i;
/* thanks to gnulibc libary for letting me find this usefull function */ /* thanks to gnulibc libary for letting me find this usefull function */
size = backtrace(array, 10); size = backtrace (array, 10);
strings = backtrace_symbols(array, size); strings = backtrace_symbols (array, size);
#endif #endif
nlog(LOG_CRITICAL, LOG_CORE, "Assertion Failure!!!!!!!!!!!"); nlog (LOG_CRITICAL, LOG_CORE, "Assertion Failure!!!!!!!!!!!");
nlog(LOG_CRITICAL, LOG_CORE, "Function: %s (%s:%d)", infunk, file, line); nlog (LOG_CRITICAL, LOG_CORE, "Function: %s (%s:%d)", infunk, file, line);
nlog(LOG_CRITICAL, LOG_CORE, "Expression: %s", expr); nlog (LOG_CRITICAL, LOG_CORE, "Expression: %s", expr);
#ifdef HAVE_BACKTRACE #ifdef HAVE_BACKTRACE
for (i = 1; i < size; i++) { for (i = 1; i < size; i++) {
nlog(LOG_CRITICAL, LOG_CORE, "BackTrace(%d): %s", nlog (LOG_CRITICAL, LOG_CORE, "BackTrace(%d): %s", i - 1, strings[i]);
i - 1, strings[i]); }
}
#endif #endif
nlog(LOG_CRITICAL, LOG_CORE, "Shutting Down!"); nlog (LOG_CRITICAL, LOG_CORE, "Shutting Down!");
exit(-1); exit (-1);
} }

10
log.h
View file

@ -20,7 +20,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: log.h,v 1.5 2003/07/18 06:09:17 fishwaldo Exp $ ** $Id: log.h,v 1.6 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
@ -74,7 +74,7 @@
#ifndef __ASSERT_VOID_CAST #ifndef __ASSERT_VOID_CAST
#define __ASSERT_VOID_CAST (void) #define __ASSERT_VOID_CAST (void)
#endif #endif
extern void nassert_fail(const char *expr, const char *file, const int line, const char *infunk); extern void nassert_fail (const char *expr, const char *file, const int line, const char *infunk);
#define nassert(expr) \ #define nassert(expr) \
(__ASSERT_VOID_CAST ((expr) ? 0 : \ (__ASSERT_VOID_CAST ((expr) ? 0 : \
@ -83,8 +83,8 @@ extern void nassert_fail(const char *expr, const char *file, const int line, con
extern void nlog(int level, int scope, char *fmt, ...); extern void nlog (int level, int scope, char *fmt, ...);
void *close_logs(); void *close_logs ();
void init_logs(); void init_logs ();
#endif #endif

454
main.c
View file

@ -22,7 +22,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: main.c,v 1.98 2003/07/18 06:09:17 fishwaldo Exp $ ** $Id: main.c,v 1.99 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
#include <setjmp.h> #include <setjmp.h>
@ -69,9 +69,9 @@ const char version_date[] = __DATE__;
/*! Time we were compiled */ /*! Time we were compiled */
const char version_time[] = __TIME__; const char version_time[] = __TIME__;
static void start(); static void start ();
static void setup_signals(); static void setup_signals ();
void get_options(int argc, char **argv); void get_options (int argc, char **argv);
/*! have we forked */ /*! have we forked */
@ -87,43 +87,41 @@ int forked = 0;
* *
* @todo Close STDIN etc correctly * @todo Close STDIN etc correctly
*/ */
int main(int argc, char *argv[]) int
main (int argc, char *argv[])
{ {
FILE *fp; FILE *fp;
/* get our commandline options */ /* get our commandline options */
get_options(argc, argv); get_options (argc, argv);
/* Change to the working Directory */ /* Change to the working Directory */
if (chdir(NEO_PREFIX) < 0) { if (chdir (NEO_PREFIX) < 0) {
printf("NeoStats Could not change to %s\n", NEO_PREFIX); printf ("NeoStats Could not change to %s\n", NEO_PREFIX);
printf("Did you 'make install' after compiling?\n"); printf ("Did you 'make install' after compiling?\n");
printf("Error Was: %s\n", strerror(errno)); printf ("Error Was: %s\n", strerror (errno));
exit(-1); exit (-1);
} }
/* before we do anything, make sure logging is setup */ /* before we do anything, make sure logging is setup */
init_logs(); init_logs ();
/* our crash trace variables */ /* our crash trace variables */
strcpy(segv_location, "main"); strcpy (segv_location, "main");
strcpy(segvinmodule, ""); strcpy (segvinmodule, "");
/* for modules, let them know we are not ready */ /* for modules, let them know we are not ready */
me.onchan = 0; me.onchan = 0;
/* keep quiet if we are told to :) */ /* keep quiet if we are told to :) */
if (!config.quiet) { if (!config.quiet) {
printf("NeoStats %d.%d.%d%s Loading...\n", MAJOR, MINOR, printf ("NeoStats %d.%d.%d%s Loading...\n", MAJOR, MINOR, REV, version);
REV, version); printf ("-----------------------------------------------\n");
printf printf ("Copyright: NeoStats Group. 2000-2003\n");
("-----------------------------------------------\n"); printf ("Justin Hammond (fish@neostats.net)\n");
printf("Copyright: NeoStats Group. 2000-2003\n"); printf ("Adam Rutter (shmad@neostats.net)\n");
printf("Justin Hammond (fish@neostats.net)\n"); printf ("^Enigma^ (enigma@neostats.net)\n");
printf("Adam Rutter (shmad@neostats.net)\n"); printf ("-----------------------------------------------\n\n");
printf("^Enigma^ (enigma@neostats.net)\n");
printf
("-----------------------------------------------\n\n");
} }
/* set some defaults before we parse the config file */ /* set some defaults before we parse the config file */
me.t_start = time(NULL); me.t_start = time (NULL);
me.want_privmsg = 0; me.want_privmsg = 0;
me.enable_spam = 0; me.enable_spam = 0;
me.die = 0; me.die = 0;
@ -132,85 +130,78 @@ int main(int argc, char *argv[])
me.noticelag = 0; me.noticelag = 0;
me.usesmo = 0; me.usesmo = 0;
me.r_time = 10; me.r_time = 10;
me.lastmsg = time(NULL); me.lastmsg = time (NULL);
me.SendM = me.SendBytes = me.RcveM = me.RcveBytes = 0; me.SendM = me.SendBytes = me.RcveM = me.RcveBytes = 0;
me.synced = 0; me.synced = 0;
me.onchan = 0; me.onchan = 0;
me.maxsocks = getmaxsock(); me.maxsocks = getmaxsock ();
#ifdef ULTIMATE3 #ifdef ULTIMATE3
me.client = 0; me.client = 0;
#endif #endif
strcpy(me.modpath, "dl"); strcpy (me.modpath, "dl");
/* if we are doing recv.log, remove the previous version */ /* if we are doing recv.log, remove the previous version */
if (config.recvlog) if (config.recvlog)
remove("logs/recv.log"); remove ("logs/recv.log");
/* initilze our Module subsystem */ /* initilze our Module subsystem */
__init_mod_list(); __init_mod_list ();
/* prepare to catch errors */ /* prepare to catch errors */
setup_signals(); setup_signals ();
/* load the config files */ /* load the config files */
ConfLoad(); ConfLoad ();
if (me.die) { if (me.die) {
printf printf ("\n-----> ERROR: Read the README file then edit neostats.cfg! <-----\n\n");
("\n-----> ERROR: Read the README file then edit neostats.cfg! <-----\n\n"); nlog (LOG_CRITICAL, LOG_CORE, "Read the README file and edit your neostats.cfg");
nlog(LOG_CRITICAL, LOG_CORE, sleep (1);
"Read the README file and edit your neostats.cfg"); close (servsock);
sleep(1); remove ("neostats.pid");
close(servsock);
remove("neostats.pid");
/* we are exiting the parent, not the program, don't call do_exit() */ /* we are exiting the parent, not the program, don't call do_exit() */
exit(0); exit (0);
} }
/* initilize the rest of the subsystems */ /* initilize the rest of the subsystems */
TimerReset(); TimerReset ();
init_dns(); init_dns ();
init_server_hash(); init_server_hash ();
init_user_hash(); init_user_hash ();
init_chan_hash(); init_chan_hash ();
init_ircd(); init_ircd ();
#ifndef DEBUG #ifndef DEBUG
/* if we are compiled with debug, or forground switch was specified, DONT FORK */ /* if we are compiled with debug, or forground switch was specified, DONT FORK */
if (!config.foreground) { if (!config.foreground) {
forked = fork(); forked = fork ();
#endif #endif
if (forked) { if (forked) {
/* write out our PID */ /* write out our PID */
fp = fopen("neostats.pid", "w"); fp = fopen ("neostats.pid", "w");
fprintf(fp, "%i", forked); fprintf (fp, "%i", forked);
fclose(fp); fclose (fp);
if (!config.quiet) { if (!config.quiet) {
printf("\n"); printf ("\n");
printf printf ("NeoStats %d.%d.%d%s Successfully Launched into Background\n", MAJOR, MINOR, REV, version);
("NeoStats %d.%d.%d%s Successfully Launched into Background\n", printf ("PID: %i - Wrote to neostats.pid\n", forked);
MAJOR, MINOR, REV, version);
printf("PID: %i - Wrote to neostats.pid\n",
forked);
} }
return 0; return 0;
} }
#ifndef DEBUG #ifndef DEBUG
/* detach from parent process */ /* detach from parent process */
if (setpgid(0, 0) < 0) { if (setpgid (0, 0) < 0) {
nlog(LOG_WARNING, LOG_CORE, "setpgid() failed"); nlog (LOG_WARNING, LOG_CORE, "setpgid() failed");
} }
} }
#endif #endif
nlog(LOG_NOTICE, LOG_CORE, nlog (LOG_NOTICE, LOG_CORE, "Statistics Started (NeoStats %d.%d.%d%s).", MAJOR, MINOR, REV, version);
"Statistics Started (NeoStats %d.%d.%d%s).", MAJOR, MINOR,
REV, version);
/* don't init_modules till after we fork. This fixes the load->fork-exit->call _fini problems when we fork */ /* don't init_modules till after we fork. This fixes the load->fork-exit->call _fini problems when we fork */
init_modules(); init_modules ();
/* we are ready to start now Duh! */ /* we are ready to start now Duh! */
start(); start ();
return 1; return 1;
} }
@ -219,7 +210,8 @@ int main(int argc, char *argv[])
* *
* Processes commandline options * Processes commandline options
*/ */
void get_options(int argc, char **argv) void
get_options (int argc, char **argv)
{ {
int c; int c;
int dbg; int dbg;
@ -234,44 +226,35 @@ void get_options(int argc, char **argv)
#endif #endif
while ((c = getopt(argc, argv, "hvrd:nqf")) != -1) { while ((c = getopt (argc, argv, "hvrd:nqf")) != -1) {
switch (c) { switch (c) {
case 'h': case 'h':
printf printf ("NeoStats: Usage: \"neostats [options]\"\n");
("NeoStats: Usage: \"neostats [options]\"\n"); printf (" -h (Show this screen)\n");
printf(" -h (Show this screen)\n"); printf (" -v (Show Version Number)\n");
printf(" -v (Show Version Number)\n"); printf (" -r (Enable Recv.log)\n");
printf(" -r (Enable Recv.log)\n"); printf (" -d 1-10 (Enable Debuging output 1= lowest, 10 = highest)\n");
printf printf (" -n (Do not load any modules on startup)\n");
(" -d 1-10 (Enable Debuging output 1= lowest, 10 = highest)\n"); printf (" -q (Quiet Start - For Cron Scripts)\n");
printf printf (" -f (Do NOt fork into BackGround\n");
(" -n (Do not load any modules on startup)\n"); exit (1);
printf
(" -q (Quiet Start - For Cron Scripts)\n");
printf
(" -f (Do NOt fork into BackGround\n");
exit(1);
case 'v': case 'v':
printf("NeoStats Version %d.%d.%d%s\n", MAJOR, printf ("NeoStats Version %d.%d.%d%s\n", MAJOR, MINOR, REV, version);
MINOR, REV, version); printf ("Compiled: %s at %s\n", version_date, version_time);
printf("Compiled: %s at %s\n", version_date, printf ("Flag after version number indicates what IRCd NeoStats is compiled for:\n");
version_time); printf ("(U) - Unreal IRCd\n");
printf printf ("(UL3)- Ultimate 3.x.x IRCd\n");
("Flag after version number indicates what IRCd NeoStats is compiled for:\n"); printf ("(UL) - Ultimate 2.x.x IRCd (Depriciated)\n");
printf("(U) - Unreal IRCd\n"); printf ("(H) - Hybrid 7.x IRCd\n");
printf("(UL3)- Ultimate 3.x.x IRCd\n"); printf ("(N) - NeoIRCd IRCd\n");
printf printf ("(M) - Mystic IRCd\n");
("(UL) - Ultimate 2.x.x IRCd (Depriciated)\n"); printf ("(Q) - Quantum IRCd\n");
printf("(H) - Hybrid 7.x IRCd\n"); printf ("(B) - Bahamut IRCd\n");
printf("(N) - NeoIRCd IRCd\n"); printf ("(IRCu) - IRCu (P10) IRCd\n");
printf("(M) - Mystic IRCd\n"); printf ("\nNeoStats: http://www.neostats.net\n");
printf("(Q) - Quantum IRCd\n"); exit (1);
printf("(B) - Bahamut IRCd\n");
printf("(IRCu) - IRCu (P10) IRCd\n");
printf("\nNeoStats: http://www.neostats.net\n");
exit(1);
case 'r': case 'r':
printf("Recv.log enabled. Watch your DiskSpace\n"); printf ("Recv.log enabled. Watch your DiskSpace\n");
config.recvlog = 1; config.recvlog = 1;
break; break;
case 'n': case 'n':
@ -281,10 +264,10 @@ void get_options(int argc, char **argv)
config.quiet = 1; config.quiet = 1;
break; break;
case 'd': case 'd':
dbg = atoi(optarg); dbg = atoi (optarg);
if ((dbg > 10) || (dbg < 1)) { if ((dbg > 10) || (dbg < 1)) {
printf("Invalid Debug Level %d\n", dbg); printf ("Invalid Debug Level %d\n", dbg);
exit(1); exit (1);
} }
config.debug = dbg; config.debug = dbg;
break; break;
@ -292,7 +275,7 @@ void get_options(int argc, char **argv)
config.foreground = 1; config.foreground = 1;
break; break;
default: default:
printf("Unknown Commandline switch %c\n", optopt); printf ("Unknown Commandline switch %c\n", optopt);
} }
} }
@ -310,14 +293,14 @@ void get_options(int argc, char **argv)
* *
* @todo Do a nice shutdown, no thtis crap :) * @todo Do a nice shutdown, no thtis crap :)
*/ */
RETSIGTYPE serv_die() RETSIGTYPE
serv_die ()
{ {
User *u; User *u;
u = finduser(s_Services); u = finduser (s_Services);
nlog(LOG_CRITICAL, LOG_CORE, nlog (LOG_CRITICAL, LOG_CORE, "Sigterm Recieved, Shuting Down Server!!!!");
"Sigterm Recieved, Shuting Down Server!!!!"); ns_shutdown (u, "SigTerm Recieved");
ns_shutdown(u, "SigTerm Recieved"); ssquit_cmd (me.name);
ssquit_cmd(me.name);
} }
@ -330,18 +313,19 @@ RETSIGTYPE serv_die()
* *
* @todo Implement a Rehash function. What can we actually rehash? * @todo Implement a Rehash function. What can we actually rehash?
*/ */
RETSIGTYPE conf_rehash() RETSIGTYPE
conf_rehash ()
{ {
/* struct sigaction act; */ /* struct sigaction act; */
chanalert(s_Services, "Recieved SIGHUP, Attempting to Rehash"); chanalert (s_Services, "Recieved SIGHUP, Attempting to Rehash");
globops(me.name, "Received SIGHUP, Attempted to Rehash"); globops (me.name, "Received SIGHUP, Attempted to Rehash");
/* act.sa_handler = conf_rehash; /* act.sa_handler = conf_rehash;
act.sa_flags=0; act.sa_flags=0;
(void)sigemptyset(&act.sa_mask); (void)sigemptyset(&act.sa_mask);
(void)sigaddset(&act.sa_mask, SIGHUP); (void)sigaddset(&act.sa_mask, SIGHUP);
(void)sigaction(SIGHUP, &act, NULL); (void)sigaction(SIGHUP, &act, NULL);
*/ */
globops(me.name, "REHASH not completed in this version!"); globops (me.name, "REHASH not completed in this version!");
/* gotta do the rehash code dun I? */ /* gotta do the rehash code dun I? */
@ -362,7 +346,8 @@ RETSIGTYPE conf_rehash()
* *
*/ */
RETSIGTYPE serv_segv() RETSIGTYPE
serv_segv ()
{ {
char name[30]; char name[30];
#ifdef HAVE_BACKTRACE #ifdef HAVE_BACKTRACE
@ -371,87 +356,61 @@ RETSIGTYPE serv_segv()
char **strings; char **strings;
size_t i; size_t i;
/* thanks to gnulibc libary for letting me find this usefull function */ /* thanks to gnulibc libary for letting me find this usefull function */
size = backtrace(array, 10); size = backtrace (array, 10);
strings = backtrace_symbols(array, size); strings = backtrace_symbols (array, size);
#endif #endif
/** if the segv happened while we were inside a module, unload and try to restore /** if the segv happened while we were inside a module, unload and try to restore
* the stack to where we were before we jumped into the module * the stack to where we were before we jumped into the module
* and continue on * and continue on
*/ */
if (strlen(segvinmodule) > 1) { if (strlen (segvinmodule) > 1) {
globops(me.name, globops (me.name, "Oh Damn, Module %s Segv'd, Unloading Module", segvinmodule);
"Oh Damn, Module %s Segv'd, Unloading Module", chanalert (s_Services, "Oh Damn, Module %s Segv'd, Unloading Module", segvinmodule);
segvinmodule); nlog (LOG_CRITICAL, LOG_CORE, "Uh Oh, Segmentation Fault in Modules Code %s", segvinmodule);
chanalert(s_Services, nlog (LOG_CRITICAL, LOG_CORE, "Location could be %s", segv_location);
"Oh Damn, Module %s Segv'd, Unloading Module", nlog (LOG_CRITICAL, LOG_CORE, "Unloading Module and restoring stacks. Doing Backtrace:");
segvinmodule); chanalert (s_Services, "Location *could* be %s. Doing Backtrace:", segv_location);
nlog(LOG_CRITICAL, LOG_CORE,
"Uh Oh, Segmentation Fault in Modules Code %s",
segvinmodule);
nlog(LOG_CRITICAL, LOG_CORE, "Location could be %s",
segv_location);
nlog(LOG_CRITICAL, LOG_CORE,
"Unloading Module and restoring stacks. Doing Backtrace:");
chanalert(s_Services,
"Location *could* be %s. Doing Backtrace:",
segv_location);
#ifdef HAVE_BACKTRACE #ifdef HAVE_BACKTRACE
for (i = 1; i < size; i++) { for (i = 1; i < size; i++) {
chanalert(s_Services, "Backtrace(%d): %s", i, chanalert (s_Services, "Backtrace(%d): %s", i, strings[i]);
strings[i]); nlog (LOG_CRITICAL, LOG_CORE, "BackTrace(%d): %s", i - 1, strings[i]);
nlog(LOG_CRITICAL, LOG_CORE, "BackTrace(%d): %s",
i - 1, strings[i]);
} }
#else #else
chanalert(s_Services, chanalert (s_Services, "Backtrace not available on this platform");
"Backtrace not available on this platform"); nlog (LOG_CRITICAL, LOG_CORE, "Backtrace not available on this platform");
nlog(LOG_CRITICAL, LOG_CORE,
"Backtrace not available on this platform");
#endif #endif
strcpy(name, segvinmodule); strcpy (name, segvinmodule);
strcpy(segvinmodule, ""); strcpy (segvinmodule, "");
unload_module(name, NULL); unload_module (name, NULL);
chanalert(s_Services, "Restoring Stack to before Crash"); chanalert (s_Services, "Restoring Stack to before Crash");
longjmp(sigvbuf, -1); longjmp (sigvbuf, -1);
chanalert(s_Services, "Done"); chanalert (s_Services, "Done");
#ifdef HAVE_BACKTRACE #ifdef HAVE_BACKTRACE
free(strings); free (strings);
#endif #endif
} else { } else {
/** The segv happened in our core, damn it */ /** The segv happened in our core, damn it */
/* Thanks to Stskeeps and Unreal for this stuff :) */ /* Thanks to Stskeeps and Unreal for this stuff :) */
nlog(LOG_CRITICAL, LOG_CORE, nlog (LOG_CRITICAL, LOG_CORE, "Uh Oh, Segmentation Fault.. Server Terminating");
"Uh Oh, Segmentation Fault.. Server Terminating"); nlog (LOG_CRITICAL, LOG_CORE, "Details: Buffer: %s", recbuf);
nlog(LOG_CRITICAL, LOG_CORE, "Details: Buffer: %s", nlog (LOG_CRITICAL, LOG_CORE, "Approx Location: %s Backtrace:", segv_location);
recbuf);
nlog(LOG_CRITICAL, LOG_CORE,
"Approx Location: %s Backtrace:", segv_location);
/* Broadcast it out! */ /* Broadcast it out! */
globops(me.name, globops (me.name, "Ohhh Crap, Server Terminating, Segmentation Fault. Buffer: %s, Approx Location %s", recbuf, segv_location);
"Ohhh Crap, Server Terminating, Segmentation Fault. Buffer: %s, Approx Location %s", chanalert (s_Services, "Damn IT, Server Terminating (%d%d%d%s), Segmentation Fault. Buffer: %s, Approx Location: %s Backtrace:", MAJOR, MINOR, REV, version, recbuf, segv_location);
recbuf, segv_location);
chanalert(s_Services,
"Damn IT, Server Terminating (%d%d%d%s), Segmentation Fault. Buffer: %s, Approx Location: %s Backtrace:",
MAJOR, MINOR, REV, version, recbuf,
segv_location);
#ifdef HAVE_BACKTRACE #ifdef HAVE_BACKTRACE
for (i = 1; i < size; i++) { for (i = 1; i < size; i++) {
chanalert(s_Services, "Backtrace(%d): %s", i, chanalert (s_Services, "Backtrace(%d): %s", i, strings[i]);
strings[i]); nlog (LOG_CRITICAL, LOG_CORE, "BackTrace(%d): %s", i - 1, strings[i]);
nlog(LOG_CRITICAL, LOG_CORE, "BackTrace(%d): %s",
i - 1, strings[i]);
} }
#else #else
chanalert(s_Services, chanalert (s_Services, "Backtrace not available on this platform");
"Backtrace not available on this platform"); nlog (LOG_CRITICAL, LOG_CORE, "Backtrace not available on this platform");
nlog(LOG_CRITICAL, LOG_CORE,
"Backtrace not available on this platform");
#endif #endif
sleep(2); sleep (2);
kill(forked, 3); kill (forked, 3);
kill(forked, 9); kill (forked, 9);
/* clean up */ /* clean up */
do_exit(1); do_exit (1);
} }
} }
@ -464,38 +423,39 @@ RETSIGTYPE serv_segv()
* @return Nothing * @return Nothing
* *
*/ */
static void setup_signals() static void
setup_signals ()
{ {
struct sigaction act; struct sigaction act;
act.sa_handler = SIG_IGN; act.sa_handler = SIG_IGN;
act.sa_flags = 0; act.sa_flags = 0;
(void) sigemptyset(&act.sa_mask); (void) sigemptyset (&act.sa_mask);
(void) sigaddset(&act.sa_mask, SIGPIPE); (void) sigaddset (&act.sa_mask, SIGPIPE);
(void) sigaddset(&act.sa_mask, SIGALRM); (void) sigaddset (&act.sa_mask, SIGALRM);
(void) sigaction(SIGPIPE, &act, NULL); (void) sigaction (SIGPIPE, &act, NULL);
(void) sigaction(SIGALRM, &act, NULL); (void) sigaction (SIGALRM, &act, NULL);
act.sa_handler = conf_rehash; act.sa_handler = conf_rehash;
(void) sigemptyset(&act.sa_mask); (void) sigemptyset (&act.sa_mask);
(void) sigaddset(&act.sa_mask, SIGHUP); (void) sigaddset (&act.sa_mask, SIGHUP);
(void) sigaction(SIGHUP, &act, NULL); (void) sigaction (SIGHUP, &act, NULL);
act.sa_handler = serv_die; act.sa_handler = serv_die;
(void) sigaddset(&act.sa_mask, SIGTERM); (void) sigaddset (&act.sa_mask, SIGTERM);
(void) sigaction(SIGTERM, &act, NULL); (void) sigaction (SIGTERM, &act, NULL);
(void) sigaddset(&act.sa_mask, SIGINT); (void) sigaddset (&act.sa_mask, SIGINT);
(void) sigaction(SIGINT, &act, NULL); (void) sigaction (SIGINT, &act, NULL);
/* handling of SIGSEGV as well -sts */ /* handling of SIGSEGV as well -sts */
act.sa_handler = serv_segv; act.sa_handler = serv_segv;
(void) sigaddset(&act.sa_mask, SIGSEGV); (void) sigaddset (&act.sa_mask, SIGSEGV);
(void) sigaction(SIGSEGV, &act, NULL); (void) sigaction (SIGSEGV, &act, NULL);
(void) signal(SIGHUP, conf_rehash); (void) signal (SIGHUP, conf_rehash);
(void) signal(SIGTERM, serv_die); (void) signal (SIGTERM, serv_die);
(void) signal(SIGSEGV, serv_segv); (void) signal (SIGSEGV, serv_segv);
(void) signal(SIGINT, serv_die); (void) signal (SIGINT, serv_die);
} }
/** @brief Connects to IRC and starts the main loop /** @brief Connects to IRC and starts the main loop
@ -508,45 +468,41 @@ static void setup_signals()
* *
* @todo make the restart code nicer so it doesn't go mad when we can't connect * @todo make the restart code nicer so it doesn't go mad when we can't connect
*/ */
void start() void
start ()
{ {
static int attempts = 0; static int attempts = 0;
Module *mod_ptr = NULL; Module *mod_ptr = NULL;
hscan_t ms; hscan_t ms;
hnode_t *mn; hnode_t *mn;
strcpy(segv_location, "start"); strcpy (segv_location, "start");
nlog(LOG_NOTICE, LOG_CORE, "Connecting to %s:%d", me.uplink, nlog (LOG_NOTICE, LOG_CORE, "Connecting to %s:%d", me.uplink, me.port);
me.port);
if (servsock > 0) if (servsock > 0)
close(servsock); close (servsock);
servsock = ConnectTo(me.uplink, me.port); servsock = ConnectTo (me.uplink, me.port);
if (servsock <= 0) { if (servsock <= 0) {
nlog(LOG_WARNING, LOG_CORE, "Unable to connect to %s", nlog (LOG_WARNING, LOG_CORE, "Unable to connect to %s", me.uplink);
me.uplink);
} else { } else {
attempts = 0; attempts = 0;
login(); login ();
read_loop(); read_loop ();
} }
nlog(LOG_NOTICE, LOG_CORE, nlog (LOG_NOTICE, LOG_CORE, "Reconnecting to the server in %d seconds (Attempt %i)", me.r_time, attempts);
"Reconnecting to the server in %d seconds (Attempt %i)", close (servsock);
me.r_time, attempts);
close(servsock);
/* Unload the Modules */ /* Unload the Modules */
hash_scan_begin(&ms, mh); hash_scan_begin (&ms, mh);
while ((mn = hash_scan_next(&ms)) != NULL) { while ((mn = hash_scan_next (&ms)) != NULL) {
mod_ptr = hnode_get(mn); mod_ptr = hnode_get (mn);
unload_module(mod_ptr->info->module_name, unload_module (mod_ptr->info->module_name, finduser (s_Services));
finduser(s_Services));
} }
sleep(5); sleep (5);
do_exit(2); do_exit (2);
} }
/** @brief Login to IRC /** @brief Login to IRC
@ -557,11 +513,12 @@ void start()
* *
*/ */
void login() void
login ()
{ {
strcpy(segv_location, "login"); strcpy (segv_location, "login");
slogin_cmd(me.name, 1, me.infoline, me.pass); slogin_cmd (me.name, 1, me.infoline, me.pass);
sprotocol_cmd("TOKEN CLIENT"); sprotocol_cmd ("TOKEN CLIENT");
} }
/** @brief Our Own implementation of Malloc. /** @brief Our Own implementation of Malloc.
@ -576,20 +533,20 @@ void login()
* @todo move this to a util type file, as it being in main is crazy * @todo move this to a util type file, as it being in main is crazy
*/ */
void *smalloc(long size) void *
smalloc (long size)
{ {
void *buf; void *buf;
strcpy(segv_location, "smalloc"); strcpy (segv_location, "smalloc");
if (!size) { if (!size) {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "smalloc(): illegal attempt to allocate 0 bytes!");
"smalloc(): illegal attempt to allocate 0 bytes!");
size = 1; size = 1;
} }
buf = malloc(size); buf = malloc (size);
if (!buf) { if (!buf) {
nlog(LOG_CRITICAL, LOG_CORE, "smalloc(): out of memory."); nlog (LOG_CRITICAL, LOG_CORE, "smalloc(): out of memory.");
do_exit(1); do_exit (1);
} }
return buf; return buf;
} }
@ -606,12 +563,13 @@ void *smalloc(long size)
* *
*/ */
char *sstrdup(const char *s) char *
sstrdup (const char *s)
{ {
char *t = strdup(s); char *t = strdup (s);
if (!t) { if (!t) {
nlog(LOG_CRITICAL, LOG_CORE, "sstrdup(): out of memory."); nlog (LOG_CRITICAL, LOG_CORE, "sstrdup(): out of memory.");
do_exit(1); do_exit (1);
} }
return t; return t;
} }
@ -630,7 +588,8 @@ char *sstrdup(const char *s)
* *
*/ */
unsigned long HASH(const unsigned char *name, int size_of_table) unsigned long
HASH (const unsigned char *name, int size_of_table)
{ {
unsigned long h = 0, g; unsigned long h = 0, g;
@ -653,13 +612,14 @@ unsigned long HASH(const unsigned char *name, int size_of_table)
* *
*/ */
char *strlower(char *s) char *
strlower (char *s)
{ {
char *t; char *t;
t = malloc(strlen(s)); t = malloc (strlen (s));
strncpy(t, s, strlen(s)); strncpy (t, s, strlen (s));
while (*t) { while (*t) {
*t++ = tolower(*t); *t++ = tolower (*t);
} }
return t; return t;
} }
@ -676,10 +636,11 @@ char *strlower(char *s)
* *
*/ */
void AddStringToList(char ***List, char S[], int *C) void
AddStringToList (char ***List, char S[], int *C)
{ {
if (*C == 0) { if (*C == 0) {
*List = calloc(sizeof(char *) * 8, 1); *List = calloc (sizeof (char *) * 8, 1);
} }
++*C; ++*C;
(*List)[*C - 1] = S; (*List)[*C - 1] = S;
@ -695,11 +656,12 @@ void AddStringToList(char ***List, char S[], int *C)
* @returns Nothing * @returns Nothing
* *
*/ */
void FreeList(char **List, int C) void
FreeList (char **List, int C)
{ {
int i; int i;
for (i = 0; i == C; i++) for (i = 0; i == C; i++)
free(List[i]); free (List[i]);
C = 0; C = 0;
} }
@ -709,30 +671,28 @@ void FreeList(char **List, int C)
* @parm segv 1 = we are exiting because of a segv fault, 0, we are not. * @parm segv 1 = we are exiting because of a segv fault, 0, we are not.
* if 1, we don't prompt to save data * if 1, we don't prompt to save data
*/ */
void do_exit(int segv) void
do_exit (int segv)
{ {
switch (segv) { switch (segv) {
case 0: case 0:
nlog(LOG_CRITICAL, LOG_CORE, nlog (LOG_CRITICAL, LOG_CORE, "Normal shut down SubSystems");
"Normal shut down SubSystems");
break; break;
case 2: case 2:
nlog(LOG_CRITICAL, LOG_CORE, nlog (LOG_CRITICAL, LOG_CORE, "Restarting NeoStats SubSystems");
"Restarting NeoStats SubSystems");
break; break;
case 1: case 1:
nlog(LOG_CRITICAL, LOG_CORE, nlog (LOG_CRITICAL, LOG_CORE, "Shutting Down SubSystems without saving data due to core");
"Shutting Down SubSystems without saving data due to core");
break; break;
} }
close_logs(); close_logs ();
if (segv == 1) { if (segv == 1) {
exit(-1); exit (-1);
} else if (segv == 2) { } else if (segv == 2) {
execve("./neostats", NULL, NULL); execve ("./neostats", NULL, NULL);
} else { } else {
exit(1); exit (1);
} }
} }

714
mystic.c

File diff suppressed because it is too large Load diff

598
mystic.h
View file

@ -20,7 +20,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: mystic.h,v 1.4 2003/07/23 10:35:47 fishwaldo Exp $ ** $Id: mystic.h,v 1.5 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
#ifndef MYSTIC_H #ifndef MYSTIC_H
#define MYSTIC_H #define MYSTIC_H
@ -32,285 +32,285 @@
#define GOTSVSVHOST #define GOTSVSVHOST
#define MSG_PRIVATE "PRIVMSG" /* PRIV */ #define MSG_PRIVATE "PRIVMSG" /* PRIV */
#define TOK_PRIVATE "!" /* 33 */ #define TOK_PRIVATE "!" /* 33 */
#define MSG_WHO "WHO" /* WHO -> WHOC */ #define MSG_WHO "WHO" /* WHO -> WHOC */
#define TOK_WHO "\"" /* 34 */ #define TOK_WHO "\"" /* 34 */
#define MSG_WHOIS "WHOIS" /* WHOI */ #define MSG_WHOIS "WHOIS" /* WHOI */
#define TOK_WHOIS "#" /* 35 */ #define TOK_WHOIS "#" /* 35 */
#define MSG_WHOWAS "WHOWAS" /* WHOW */ #define MSG_WHOWAS "WHOWAS" /* WHOW */
#define TOK_WHOWAS "$" /* 36 */ #define TOK_WHOWAS "$" /* 36 */
#define MSG_USER "USER" /* USER */ #define MSG_USER "USER" /* USER */
#define TOK_USER "%" /* 37 */ #define TOK_USER "%" /* 37 */
#define MSG_NICK "NICK" /* NICK */ #define MSG_NICK "NICK" /* NICK */
#define TOK_NICK "&" /* 38 */ #define TOK_NICK "&" /* 38 */
#define MSG_SERVER "SERVER" /* SERV */ #define MSG_SERVER "SERVER" /* SERV */
#define TOK_SERVER "'" /* 39 */ #define TOK_SERVER "'" /* 39 */
#define MSG_LIST "LIST" /* LIST */ #define MSG_LIST "LIST" /* LIST */
#define TOK_LIST "(" /* 40 */ #define TOK_LIST "(" /* 40 */
#define MSG_TOPIC "TOPIC" /* TOPI */ #define MSG_TOPIC "TOPIC" /* TOPI */
#define TOK_TOPIC ")" /* 41 */ #define TOK_TOPIC ")" /* 41 */
#define MSG_INVITE "INVITE" /* INVI */ #define MSG_INVITE "INVITE" /* INVI */
#define TOK_INVITE "*" /* 42 */ #define TOK_INVITE "*" /* 42 */
#define MSG_VERSION "VERSION" /* VERS */ #define MSG_VERSION "VERSION" /* VERS */
#define TOK_VERSION "+" /* 43 */ #define TOK_VERSION "+" /* 43 */
#define MSG_QUIT "QUIT" /* QUIT */ #define MSG_QUIT "QUIT" /* QUIT */
#define TOK_QUIT "," /* 44 */ #define TOK_QUIT "," /* 44 */
#define MSG_SQUIT "SQUIT" /* SQUI */ #define MSG_SQUIT "SQUIT" /* SQUI */
#define TOK_SQUIT "-" /* 45 */ #define TOK_SQUIT "-" /* 45 */
#define MSG_KILL "KILL" /* KILL */ #define MSG_KILL "KILL" /* KILL */
#define TOK_KILL "." /* 46 */ #define TOK_KILL "." /* 46 */
#define MSG_INFO "INFO" /* INFO */ #define MSG_INFO "INFO" /* INFO */
#define TOK_INFO "/" /* 47 */ #define TOK_INFO "/" /* 47 */
#define MSG_LINKS "LINKS" /* LINK */ #define MSG_LINKS "LINKS" /* LINK */
#define TOK_LINKS "0" /* 48 */ #define TOK_LINKS "0" /* 48 */
#define MSG_WATCH "WATCH" /* WATCH */ #define MSG_WATCH "WATCH" /* WATCH */
#define TOK_WATCH "1" /* 49 */ #define TOK_WATCH "1" /* 49 */
#define MSG_STATS "STATS" /* STAT */ #define MSG_STATS "STATS" /* STAT */
#define TOK_STATS "2" /* 50 */ #define TOK_STATS "2" /* 50 */
#define MSG_HELP "HELP" /* HELP */ #define MSG_HELP "HELP" /* HELP */
#define MSG_HELPOP "HELPOP" /* HELP */ #define MSG_HELPOP "HELPOP" /* HELP */
#define TOK_HELP "4" /* 52 */ #define TOK_HELP "4" /* 52 */
#define MSG_ERROR "ERROR" /* ERRO */ #define MSG_ERROR "ERROR" /* ERRO */
#define TOK_ERROR "5" /* 53 */ #define TOK_ERROR "5" /* 53 */
#define MSG_AWAY "AWAY" /* AWAY */ #define MSG_AWAY "AWAY" /* AWAY */
#define TOK_AWAY "6" /* 54 */ #define TOK_AWAY "6" /* 54 */
#define MSG_CONNECT "CONNECT" /* CONN */ #define MSG_CONNECT "CONNECT" /* CONN */
#define TOK_CONNECT "7" /* 55 */ #define TOK_CONNECT "7" /* 55 */
#define MSG_PING "PING" /* PING */ #define MSG_PING "PING" /* PING */
#define TOK_PING "8" /* 56 */ #define TOK_PING "8" /* 56 */
#define MSG_PONG "PONG" /* PONG */ #define MSG_PONG "PONG" /* PONG */
#define TOK_PONG "9" /* 57 */ #define TOK_PONG "9" /* 57 */
#define MSG_OPER "OPER" /* OPER */ #define MSG_OPER "OPER" /* OPER */
#define TOK_OPER ";" /* 59 */ #define TOK_OPER ";" /* 59 */
#define MSG_PASS "PASS" /* PASS */ #define MSG_PASS "PASS" /* PASS */
#define TOK_PASS "<" /* 60 */ #define TOK_PASS "<" /* 60 */
#define MSG_WALLOPS "WALLOPS" /* WALL */ #define MSG_WALLOPS "WALLOPS" /* WALL */
#define TOK_WALLOPS "=" /* 61 */ #define TOK_WALLOPS "=" /* 61 */
#define MSG_TIME "TIME" /* TIME */ #define MSG_TIME "TIME" /* TIME */
#define TOK_TIME ">" /* 62 */ #define TOK_TIME ">" /* 62 */
#define MSG_NAMES "NAMES" /* NAME */ #define MSG_NAMES "NAMES" /* NAME */
#define TOK_NAMES "?" /* 63 */ #define TOK_NAMES "?" /* 63 */
#define MSG_ADMIN "ADMIN" /* ADMI */ #define MSG_ADMIN "ADMIN" /* ADMI */
#define TOK_ADMIN "@" /* 64 */ #define TOK_ADMIN "@" /* 64 */
#define MSG_NOTICE "NOTICE" /* NOTI */ #define MSG_NOTICE "NOTICE" /* NOTI */
#define TOK_NOTICE "B" /* 66 */ #define TOK_NOTICE "B" /* 66 */
#define MSG_JOIN "JOIN" /* JOIN */ #define MSG_JOIN "JOIN" /* JOIN */
#define TOK_JOIN "C" /* 67 */ #define TOK_JOIN "C" /* 67 */
#define MSG_PART "PART" /* PART */ #define MSG_PART "PART" /* PART */
#define TOK_PART "D" /* 68 */ #define TOK_PART "D" /* 68 */
#define MSG_LUSERS "LUSERS" /* LUSE */ #define MSG_LUSERS "LUSERS" /* LUSE */
#define TOK_LUSERS "E" /* 69 */ #define TOK_LUSERS "E" /* 69 */
#define MSG_MOTD "MOTD" /* MOTD */ #define MSG_MOTD "MOTD" /* MOTD */
#define TOK_MOTD "F" /* 70 */ #define TOK_MOTD "F" /* 70 */
#define MSG_MODE "MODE" /* MODE */ #define MSG_MODE "MODE" /* MODE */
#define TOK_MODE "G" /* 71 */ #define TOK_MODE "G" /* 71 */
#define MSG_KICK "KICK" /* KICK */ #define MSG_KICK "KICK" /* KICK */
#define TOK_KICK "H" /* 72 */ #define TOK_KICK "H" /* 72 */
#define MSG_SERVICE "SERVICE" /* SERV -> SRVI */ #define MSG_SERVICE "SERVICE" /* SERV -> SRVI */
#define TOK_SERVICE "I" /* 73 */ #define TOK_SERVICE "I" /* 73 */
#define MSG_USERHOST "USERHOST" /* USER -> USRH */ #define MSG_USERHOST "USERHOST" /* USER -> USRH */
#define TOK_USERHOST "J" /* 74 */ #define TOK_USERHOST "J" /* 74 */
#define MSG_ISON "ISON" /* ISON */ #define MSG_ISON "ISON" /* ISON */
#define TOK_ISON "K" /* 75 */ #define TOK_ISON "K" /* 75 */
#define MSG_SQUERY "SQUERY" /* SQUE */ #define MSG_SQUERY "SQUERY" /* SQUE */
#define TOK_SQUERY "L" /* 76 */ #define TOK_SQUERY "L" /* 76 */
#define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */ #define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */
#define TOK_SERVLIST "M" /* 77 */ #define TOK_SERVLIST "M" /* 77 */
#define MSG_SERVSET "SERVSET" /* SERV -> SSET */ #define MSG_SERVSET "SERVSET" /* SERV -> SSET */
#define TOK_SERVSET "N" /* 78 */ #define TOK_SERVSET "N" /* 78 */
#define MSG_REHASH "REHASH" /* REHA */ #define MSG_REHASH "REHASH" /* REHA */
#define TOK_REHASH "O" /* 79 */ #define TOK_REHASH "O" /* 79 */
#define MSG_RESTART "RESTART" /* REST */ #define MSG_RESTART "RESTART" /* REST */
#define TOK_RESTART "P" /* 80 */ #define TOK_RESTART "P" /* 80 */
#define MSG_CLOSE "CLOSE" /* CLOS */ #define MSG_CLOSE "CLOSE" /* CLOS */
#define TOK_CLOSE "Q" /* 81 */ #define TOK_CLOSE "Q" /* 81 */
#define MSG_DIE "DIE" /* DIE */ #define MSG_DIE "DIE" /* DIE */
#define TOK_DIE "R" /* 82 */ #define TOK_DIE "R" /* 82 */
#define MSG_HASH "HASH" /* HASH */ #define MSG_HASH "HASH" /* HASH */
#define TOK_HASH "S" /* 83 */ #define TOK_HASH "S" /* 83 */
#define MSG_DNS "DNS" /* DNS -> DNSS */ #define MSG_DNS "DNS" /* DNS -> DNSS */
#define TOK_DNS "T" /* 84 */ #define TOK_DNS "T" /* 84 */
#define MSG_SILENCE "SILENCE" /* SILE */ #define MSG_SILENCE "SILENCE" /* SILE */
#define TOK_SILENCE "U" /* 85 */ #define TOK_SILENCE "U" /* 85 */
#define MSG_AKILL "AKILL" /* AKILL */ #define MSG_AKILL "AKILL" /* AKILL */
#define TOK_AKILL "V" /* 86 */ #define TOK_AKILL "V" /* 86 */
#define MSG_KLINE "KLINE" /* KLINE */ #define MSG_KLINE "KLINE" /* KLINE */
#define TOK_KLINE "W" /* 87 */ #define TOK_KLINE "W" /* 87 */
#define MSG_UNKLINE "UNKLINE" /* UNKLINE */ #define MSG_UNKLINE "UNKLINE" /* UNKLINE */
#define TOK_UNKLINE "X" /* 88 */ #define TOK_UNKLINE "X" /* 88 */
#define MSG_RAKILL "RAKILL" /* RAKILL */ #define MSG_RAKILL "RAKILL" /* RAKILL */
#define TOK_RAKILL "Y" /* 89 */ #define TOK_RAKILL "Y" /* 89 */
#define MSG_GNOTICE "GNOTICE" /* GNOTICE */ #define MSG_GNOTICE "GNOTICE" /* GNOTICE */
#define TOK_GNOTICE "Z" /* 90 */ #define TOK_GNOTICE "Z" /* 90 */
#define MSG_GOPER "GOPER" /* GOPER */ #define MSG_GOPER "GOPER" /* GOPER */
#define TOK_GOPER "[" /* 91 */ #define TOK_GOPER "[" /* 91 */
#define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */ #define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */
#define TOK_GLOBOPS "]" /* 93 */ #define TOK_GLOBOPS "]" /* 93 */
#define MSG_LOCOPS "LOCOPS" /* LOCOPS */ #define MSG_LOCOPS "LOCOPS" /* LOCOPS */
#define TOK_LOCOPS "^" /* 94 */ #define TOK_LOCOPS "^" /* 94 */
#define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */ #define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */
#define TOK_PROTOCTL "_" /* 95 */ #define TOK_PROTOCTL "_" /* 95 */
#define MSG_TRACE "TRACE" /* TRAC */ #define MSG_TRACE "TRACE" /* TRAC */
#define TOK_TRACE "b" /* 98 */ #define TOK_TRACE "b" /* 98 */
#define MSG_SQLINE "SQLINE" /* SQLINE */ #define MSG_SQLINE "SQLINE" /* SQLINE */
#define TOK_SQLINE "c" /* 99 */ #define TOK_SQLINE "c" /* 99 */
#define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */ #define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */
#define TOK_UNSQLINE "d" /* 100 */ #define TOK_UNSQLINE "d" /* 100 */
#define MSG_SVSNICK "SVSNICK" /* SVSNICK */ #define MSG_SVSNICK "SVSNICK" /* SVSNICK */
#define TOK_SVSNICK "e" /* 101 */ #define TOK_SVSNICK "e" /* 101 */
#define MSG_SVSNOOP "SVSNOOP" /* SVSNOOP */ #define MSG_SVSNOOP "SVSNOOP" /* SVSNOOP */
#define TOK_SVSNOOP "f" /* 101 */ #define TOK_SVSNOOP "f" /* 101 */
#define MSG_IDENTIFY "IDENTIFY" /* IDENTIFY */ #define MSG_IDENTIFY "IDENTIFY" /* IDENTIFY */
#define TOK_IDENTIFY "g" /* 103 */ #define TOK_IDENTIFY "g" /* 103 */
#define MSG_SVSKILL "SVSKILL" /* SVSKILL */ #define MSG_SVSKILL "SVSKILL" /* SVSKILL */
#define TOK_SVSKILL "h" /* 104 */ #define TOK_SVSKILL "h" /* 104 */
#define MSG_NICKSERV "NICKSERV" /* NICKSERV */ #define MSG_NICKSERV "NICKSERV" /* NICKSERV */
#define MSG_NS "NS" #define MSG_NS "NS"
#define TOK_NICKSERV "i" /* 105 */ #define TOK_NICKSERV "i" /* 105 */
#define MSG_CHANSERV "CHANSERV" /* CHANSERV */ #define MSG_CHANSERV "CHANSERV" /* CHANSERV */
#define MSG_CS "CS" #define MSG_CS "CS"
#define TOK_CHANSERV "j" /* 106 */ #define TOK_CHANSERV "j" /* 106 */
#define MSG_OPERSERV "OPERSERV" /* OPERSERV */ #define MSG_OPERSERV "OPERSERV" /* OPERSERV */
#define MSG_OS "OS" #define MSG_OS "OS"
#define TOK_OPERSERV "k" /* 107 */ #define TOK_OPERSERV "k" /* 107 */
#define MSG_MEMOSERV "MEMOSERV" /* MEMOSERV */ #define MSG_MEMOSERV "MEMOSERV" /* MEMOSERV */
#define MSG_MS "MS" #define MSG_MS "MS"
#define TOK_MEMOSERV "l" /* 108 */ #define TOK_MEMOSERV "l" /* 108 */
#define MSG_SERVICES "SERVICES" /* SERVICES */ #define MSG_SERVICES "SERVICES" /* SERVICES */
#define TOK_SERVICES "m" /* 109 */ #define TOK_SERVICES "m" /* 109 */
#define MSG_SVSMODE "SVSMODE" /* SVSMODE */ #define MSG_SVSMODE "SVSMODE" /* SVSMODE */
#define TOK_SVSMODE "n" /* 110 */ #define TOK_SVSMODE "n" /* 110 */
#define MSG_SAMODE "SAMODE" /* SAMODE */ #define MSG_SAMODE "SAMODE" /* SAMODE */
#define TOK_SAMODE "o" /* 111 */ #define TOK_SAMODE "o" /* 111 */
#define MSG_CHATOPS "CHATOPS" /* CHATOPS */ #define MSG_CHATOPS "CHATOPS" /* CHATOPS */
#define TOK_CHATOPS "p" /* 112 */ #define TOK_CHATOPS "p" /* 112 */
#define MSG_HELPSERV "HELPSERV" /* HELPSERV */ #define MSG_HELPSERV "HELPSERV" /* HELPSERV */
#define TOK_HELPSERV "r" /* 114 */ #define TOK_HELPSERV "r" /* 114 */
#define MSG_ZLINE "ZLINE" /* ZLINE */ #define MSG_ZLINE "ZLINE" /* ZLINE */
#define TOK_ZLINE "s" /* 115 */ #define TOK_ZLINE "s" /* 115 */
#define MSG_UNZLINE "UNZLINE" /* UNZLINE */ #define MSG_UNZLINE "UNZLINE" /* UNZLINE */
#define TOK_UNZLINE "t" /* 116 */ #define TOK_UNZLINE "t" /* 116 */
#define MSG_NETINFO "NETINFO" /* NETINFO */ #define MSG_NETINFO "NETINFO" /* NETINFO */
#define TOK_NETINFO "u" /* 117 */ #define TOK_NETINFO "u" /* 117 */
#define MSG_RULES "RULES" /* RULES */ #define MSG_RULES "RULES" /* RULES */
#define TOK_RULES "v" /* 118 */ #define TOK_RULES "v" /* 118 */
#define MSG_MAP "MAP" /* MAP */ #define MSG_MAP "MAP" /* MAP */
#define TOK_MAP "w" /* 119 */ #define TOK_MAP "w" /* 119 */
#define MSG_NETG "NETG" /* NETG */ #define MSG_NETG "NETG" /* NETG */
#define TOK_NETG "x" /* 120 */ #define TOK_NETG "x" /* 120 */
#define MSG_ADCHAT "ADCHAT" /* Adchat */ #define MSG_ADCHAT "ADCHAT" /* Adchat */
#define TOK_ADCHAT "y" /* 121 */ #define TOK_ADCHAT "y" /* 121 */
#define MSG_MAKEPASS "MAKEPASS" /* MAKEPASS */ #define MSG_MAKEPASS "MAKEPASS" /* MAKEPASS */
#define TOK_MAKEPASS "z" /* 122 */ #define TOK_MAKEPASS "z" /* 122 */
#define MSG_ADDHUB "ADDHUB" /* ADDHUB */ #define MSG_ADDHUB "ADDHUB" /* ADDHUB */
#define TOK_ADDHUB "{" /* 123 */ #define TOK_ADDHUB "{" /* 123 */
#define MSG_DELHUB "DELHUB" /* DELHUB */ #define MSG_DELHUB "DELHUB" /* DELHUB */
#define TOK_DELHUB "|" /* 124 */ #define TOK_DELHUB "|" /* 124 */
#define MSG_ADDCNLINE "ADDCNLINE" /* ADDCNLINE */ #define MSG_ADDCNLINE "ADDCNLINE" /* ADDCNLINE */
#define TOK_ADDCNLINE "}" /* 125 */ #define TOK_ADDCNLINE "}" /* 125 */
#define MSG_DELCNLINE "DELCNLINE" /* DELCNLINE */ #define MSG_DELCNLINE "DELCNLINE" /* DELCNLINE */
#define TOK_DELCNLINE "~" /* 126 */ #define TOK_DELCNLINE "~" /* 126 */
#define MSG_ADDOPER "ADDOPER" /* ADDOPER */ #define MSG_ADDOPER "ADDOPER" /* ADDOPER */
#define TOK_ADDOPER "" /* 127 */ #define TOK_ADDOPER "" /* 127 */
#define MSG_DELOPER "DELOPER" /* DELOPER */ #define MSG_DELOPER "DELOPER" /* DELOPER */
#define TOK_DELOPER "!!" /* 33 + 33 */ #define TOK_DELOPER "!!" /* 33 + 33 */
#define MSG_ADDQLINE "ADDQLINE" /* ADDQLINE */ #define MSG_ADDQLINE "ADDQLINE" /* ADDQLINE */
#define TOK_ADDQLINE "!\"" /* 33 + 34 */ #define TOK_ADDQLINE "!\"" /* 33 + 34 */
#define MSG_DELQLINE "DELQLINE" /* DELQLINE */ #define MSG_DELQLINE "DELQLINE" /* DELQLINE */
#define TOK_DELQLINE "!#" /* 33 + 35 */ #define TOK_DELQLINE "!#" /* 33 + 35 */
#define MSG_GSOP "GSOP" /* GSOP */ #define MSG_GSOP "GSOP" /* GSOP */
#define TOK_GSOP "!$" /* 33 + 36 */ #define TOK_GSOP "!$" /* 33 + 36 */
#define MSG_ISOPER "ISOPER" /* ISOPER */ #define MSG_ISOPER "ISOPER" /* ISOPER */
#define TOK_ISOPER "!%" /* 33 + 37 */ #define TOK_ISOPER "!%" /* 33 + 37 */
#define MSG_ADG "ADG" /* ADG */ #define MSG_ADG "ADG" /* ADG */
#define TOK_ADG "!&" /* 33 + 38 */ #define TOK_ADG "!&" /* 33 + 38 */
#define MSG_NMON "NMON" /* NMON */ #define MSG_NMON "NMON" /* NMON */
#define TOK_NMON "!'" /* 33 + 39 */ #define TOK_NMON "!'" /* 33 + 39 */
#define MSG_DALINFO "DALINFO" /* DALnet Credits */ #define MSG_DALINFO "DALINFO" /* DALnet Credits */
#define TOK_DALINFO "!(" /* 33 + 40 */ #define TOK_DALINFO "!(" /* 33 + 40 */
#define MSG_CREDITS "CREDITS" /* MysticIRCd Credits and "Thanks To" */ #define MSG_CREDITS "CREDITS" /* MysticIRCd Credits and "Thanks To" */
#define TOK_CREDITS "!)" /* 33 + 41 */ #define TOK_CREDITS "!)" /* 33 + 41 */
#define MSG_OPERMOTD "OPERMOTD" /* OPERMOTD */ #define MSG_OPERMOTD "OPERMOTD" /* OPERMOTD */
#define TOK_OPERMOTD "!*" /* 33 + 42 */ #define TOK_OPERMOTD "!*" /* 33 + 42 */
#define MSG_REMREHASH "REMREHASH" /* Remote Rehash */ #define MSG_REMREHASH "REMREHASH" /* Remote Rehash */
#define TOK_REMREHASH "!+" /* 33 + 43 */ #define TOK_REMREHASH "!+" /* 33 + 43 */
#define MSG_MONITOR "MONITOR" /* MONITOR */ #define MSG_MONITOR "MONITOR" /* MONITOR */
#define TOK_MONITOR "!," /* 33 + 44 */ #define TOK_MONITOR "!," /* 33 + 44 */
#define MSG_GLINE "GLINE" /* The awesome g-line */ #define MSG_GLINE "GLINE" /* The awesome g-line */
#define TOK_GLINE "!-" /* 33 + 45 */ #define TOK_GLINE "!-" /* 33 + 45 */
#define MSG_REMGLINE "REMGLINE" /* remove g-line */ #define MSG_REMGLINE "REMGLINE" /* remove g-line */
#define TOK_REMGLINE "!." /* 33 + 46 */ #define TOK_REMGLINE "!." /* 33 + 46 */
#define MSG_STATSERV "STATSERV" /* StatServ */ #define MSG_STATSERV "STATSERV" /* StatServ */
#define TOK_STATSERV "!/" /* 33 + 47 */ #define TOK_STATSERV "!/" /* 33 + 47 */
#define MSG_RULESERV "RULESERV" /* RuleServ */ #define MSG_RULESERV "RULESERV" /* RuleServ */
#define TOK_RULESERV "!0" /* 33 + 48 */ #define TOK_RULESERV "!0" /* 33 + 48 */
#define MSG_SNETINFO "SNETINFO" /* SNetInfo */ #define MSG_SNETINFO "SNETINFO" /* SNetInfo */
#define TOK_SNETINFO "!1" /* 33 + 49 */ #define TOK_SNETINFO "!1" /* 33 + 49 */
#define MSG_TSCTL "TSCTL" /* TSCTL */ #define MSG_TSCTL "TSCTL" /* TSCTL */
#define TOK_TSCTL "!3" /* 33 + 51 */ #define TOK_TSCTL "!3" /* 33 + 51 */
#define MSG_SVSJOIN "SVSJOIN" /* SVSJOIN */ #define MSG_SVSJOIN "SVSJOIN" /* SVSJOIN */
#define TOK_SVSJOIN "!4" /* 33 + 52 */ #define TOK_SVSJOIN "!4" /* 33 + 52 */
#define MSG_SAJOIN "SAJOIN" /* SAJOIN */ #define MSG_SAJOIN "SAJOIN" /* SAJOIN */
#define TOK_SAJOIN "!5" /* 33 + 53 */ #define TOK_SAJOIN "!5" /* 33 + 53 */
#define MSG_SDESC "SDESC" /* SDESC */ #define MSG_SDESC "SDESC" /* SDESC */
#define TOK_SDESC "!6" /* 33 + 54 */ #define TOK_SDESC "!6" /* 33 + 54 */
#define MSG_UNREALINFO "UNREALINFO" /* Unreal Info */ #define MSG_UNREALINFO "UNREALINFO" /* Unreal Info */
#define TOK_UNREALINFO "!7" /* 33 + 55 */ #define TOK_UNREALINFO "!7" /* 33 + 55 */
#define MSG_SETHOST "SETHOST" /* sethost */ #define MSG_SETHOST "SETHOST" /* sethost */
#define TOK_SETHOST "!8" /* 33 + 56 */ #define TOK_SETHOST "!8" /* 33 + 56 */
#define MSG_SETIDENT "SETIDENT" /* set ident */ #define MSG_SETIDENT "SETIDENT" /* set ident */
#define TOK_SETIDENT "!9" /* 33 + 57 */ #define TOK_SETIDENT "!9" /* 33 + 57 */
#define MSG_SETNAME "SETNAME" /* set Realname */ #define MSG_SETNAME "SETNAME" /* set Realname */
#define TOK_SETNAME "!;" /* 33 + 59 */ #define TOK_SETNAME "!;" /* 33 + 59 */
#define MSG_CHGHOST "CHGHOST" /* Changehost */ #define MSG_CHGHOST "CHGHOST" /* Changehost */
#define TOK_CHGHOST "!<" /* 33 + 60 */ #define TOK_CHGHOST "!<" /* 33 + 60 */
#define MSG_CHGIDENT "CHGIDENT" /* Change Ident */ #define MSG_CHGIDENT "CHGIDENT" /* Change Ident */
#define TOK_CHGIDENT "!=" /* 33 + 61 */ #define TOK_CHGIDENT "!=" /* 33 + 61 */
#define MSG_RANDQUOTE "RANDQUOTE" /* Random Quote */ #define MSG_RANDQUOTE "RANDQUOTE" /* Random Quote */
#define TOK_RANDQUOTE "!>" /* 33 + 62 */ #define TOK_RANDQUOTE "!>" /* 33 + 62 */
#define MSG_ADDQUOTE "ADDQUOTE" /* Add Quote */ #define MSG_ADDQUOTE "ADDQUOTE" /* Add Quote */
#define TOK_ADDQUOTE "!?" /* 33 + 63 */ #define TOK_ADDQUOTE "!?" /* 33 + 63 */
#define MSG_ADDGQUOTE "ADDGQUOTE" /* Add Global Quote */ #define MSG_ADDGQUOTE "ADDGQUOTE" /* Add Global Quote */
#define TOK_ADDGQUOTE "!@" /* 33 + 64 */ #define TOK_ADDGQUOTE "!@" /* 33 + 64 */
#define MSG_ADDULINE "ADDULINE" /* Adds an U Line to ircd.conf file */ #define MSG_ADDULINE "ADDULINE" /* Adds an U Line to ircd.conf file */
#define TOK_ADDULINE "!B" /* 33 + 66 */ #define TOK_ADDULINE "!B" /* 33 + 66 */
#define MSG_DELULINE "DELULINE" /* Removes an U line from the ircd.conf */ #define MSG_DELULINE "DELULINE" /* Removes an U line from the ircd.conf */
#define TOK_DELULINE "!C" /* 33 + 67 */ #define TOK_DELULINE "!C" /* 33 + 67 */
#define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */ #define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */
#define TOK_KNOCK "!D" /* 33 + 68 */ #define TOK_KNOCK "!D" /* 33 + 68 */
#define MSG_SETTINGS "SETTINGS" /* Settings */ #define MSG_SETTINGS "SETTINGS" /* Settings */
#define TOK_SETTINGS "!E" /* 33 + 69 */ #define TOK_SETTINGS "!E" /* 33 + 69 */
#define MSG_IRCOPS "IRCOPS" /* Shows Online IRCOps */ #define MSG_IRCOPS "IRCOPS" /* Shows Online IRCOps */
#define TOK_IRCOPS "!F" /* 33 + 70 */ #define TOK_IRCOPS "!F" /* 33 + 70 */
#define MSG_SVSPART "SVSPART" /* SVSPART */ #define MSG_SVSPART "SVSPART" /* SVSPART */
#define TOK_SVSPART "!G" /* 33 + 71 */ #define TOK_SVSPART "!G" /* 33 + 71 */
#define MSG_SAPART "SAPART" /* SAPART */ #define MSG_SAPART "SAPART" /* SAPART */
#define TOK_SAPART "!H" /* 33 + 72 */ #define TOK_SAPART "!H" /* 33 + 72 */
#define MSG_VCTRL "VCTRL" /* VCTRL */ #define MSG_VCTRL "VCTRL" /* VCTRL */
#define TOK_VCTRL "!I" /* 33 + 73 */ #define TOK_VCTRL "!I" /* 33 + 73 */
#define MSG_GCLIENT "GCLIENT" /* GLIENT */ #define MSG_GCLIENT "GCLIENT" /* GLIENT */
#define TOK_GCLIENT "!J" /* 33 + 74 */ #define TOK_GCLIENT "!J" /* 33 + 74 */
#define MSG_CHANNEL "CHANNEL" /* CHANNEL */ #define MSG_CHANNEL "CHANNEL" /* CHANNEL */
#define TOK_CHANNEL "!K" /* 33 + 75 */ #define TOK_CHANNEL "!K" /* 33 + 75 */
#define MSG_UPTIME "UPTIME" /* UPTIME */ #define MSG_UPTIME "UPTIME" /* UPTIME */
#define TOK_UPTIME "!L" /* 33 + 76 */ #define TOK_UPTIME "!L" /* 33 + 76 */
#define MSG_FAILOPS "FAILOPS" /* FAILOPS */ #define MSG_FAILOPS "FAILOPS" /* FAILOPS */
#define TOK_FAILOPS "!M" /* 33 + 77 */ #define TOK_FAILOPS "!M" /* 33 + 77 */
#define MSG_RPING "RPING" /* RPING */ #define MSG_RPING "RPING" /* RPING */
#define TOK_RPING "!P" /* 33 + 80 */ #define TOK_RPING "!P" /* 33 + 80 */
#define MSG_RPONG "RPONG" /* RPONG */ #define MSG_RPONG "RPONG" /* RPONG */
#define TOK_RPONG "!Q" /* 33 + 81 */ #define TOK_RPONG "!Q" /* 33 + 81 */
#define MSG_UPING "UPING" /* UPING */ #define MSG_UPING "UPING" /* UPING */
#define TOK_UPING "!R" /* 33 + 82 */ #define TOK_UPING "!R" /* 33 + 82 */
#define MSG_COPYRIGHT "COPYRIGHT" /* Copyright */ #define MSG_COPYRIGHT "COPYRIGHT" /* Copyright */
#define TOK_COPYRIGHT "!S" /* 33 + 83 */ #define TOK_COPYRIGHT "!S" /* 33 + 83 */
#define MSG_BOTSERV "BOTSERV" /* BOTSERV */ #define MSG_BOTSERV "BOTSERV" /* BOTSERV */
#define MSG_BS "BS" #define MSG_BS "BS"
#define TOK_BOTSERV "!T" /* 33 + 84 */ #define TOK_BOTSERV "!T" /* 33 + 84 */
#define MSG_ROOTSERV "ROOTSERV" /* ROOTSERV */ #define MSG_ROOTSERV "ROOTSERV" /* ROOTSERV */
#define MSG_RS "RS" #define MSG_RS "RS"
#define TOK_ROOTSERV "!U" /* 33 + 85 */ #define TOK_ROOTSERV "!U" /* 33 + 85 */
#define MSG_SVINFO "SVINFO" #define MSG_SVINFO "SVINFO"
#define MSG_CAPAB "CAPAB" #define MSG_CAPAB "CAPAB"
#define MSG_BURST "BURST" #define MSG_BURST "BURST"
@ -320,37 +320,37 @@
#define UMODE_INVISIBLE 0x0001 /* makes user invisible */ #define UMODE_INVISIBLE 0x0001 /* makes user invisible */
#define UMODE_OPER 0x0002 /* Operator */ #define UMODE_OPER 0x0002 /* Operator */
#define UMODE_WALLOP 0x0004 /* send wallops to them */ #define UMODE_WALLOP 0x0004 /* send wallops to them */
#define UMODE_FAILOP 0x0008 /* Shows some global messages */ #define UMODE_FAILOP 0x0008 /* Shows some global messages */
#define UMODE_HELPOP 0x0010 /* Help system operator */ #define UMODE_HELPOP 0x0010 /* Help system operator */
#define UMODE_REGNICK 0x0020 /* Nick set by services as registered */ #define UMODE_REGNICK 0x0020 /* Nick set by services as registered */
#define UMODE_SERVICESOPER 0x0040 /* Services Oper */ #define UMODE_SERVICESOPER 0x0040 /* Services Oper */
#define UMODE_COADMIN 0x0080 /* Server CoAdmin */ #define UMODE_COADMIN 0x0080 /* Server CoAdmin */
#define UMODE_NETADMIN 0x10000 /* Network Admin */ #define UMODE_NETADMIN 0x10000 /* Network Admin */
#define UMODE_SUPER 0x20000 /* Oper Is Protected from Kick's and Kill's */ #define UMODE_SUPER 0x20000 /* Oper Is Protected from Kick's and Kill's */
#define UMODE_RBOT 0x40000 /* Marks the client as a Registered Bot */ #define UMODE_RBOT 0x40000 /* Marks the client as a Registered Bot */
#define UMODE_SBOT 0x80000 /* Marks the client as a Server Bot */ #define UMODE_SBOT 0x80000 /* Marks the client as a Server Bot */
#define UMODE_NGLOBAL 0x100000 /* See Network Globals */ #define UMODE_NGLOBAL 0x100000 /* See Network Globals */
#define UMODE_NETINFO 0x400000 /* Server link, Delink Notces etc. */ #define UMODE_NETINFO 0x400000 /* Server link, Delink Notces etc. */
#define UMODE_MAGICK 0x800000 /* Allows Opers To See +s and +p Channels */ #define UMODE_MAGICK 0x800000 /* Allows Opers To See +s and +p Channels */
#define UMODE_WATCHER 0x4000000 /* Recive Monitor Globals */ #define UMODE_WATCHER 0x4000000 /* Recive Monitor Globals */
#define UMODE_NETMON 0x8000000 /* Marks the client as an Network Monitor */ #define UMODE_NETMON 0x8000000 /* Marks the client as an Network Monitor */
#define UMODE_SERVADMIN 0x40000000 /* Marks the client as a Server Admin */ #define UMODE_SERVADMIN 0x40000000 /* Marks the client as a Server Admin */
#define UMODE_TECHADMIN 0x80000000 /* Marks the client as a Technical Admin */ #define UMODE_TECHADMIN 0x80000000 /* Marks the client as a Technical Admin */
#define UMODE_DEAF 0x100000000 /* client is deaf on channels */ #define UMODE_DEAF 0x100000000 /* client is deaf on channels */
#define UMODE_SERVNOTICE 0x0100 /* server notices such as kill */ #define UMODE_SERVNOTICE 0x0100 /* server notices such as kill */
#define UMODE_LOCOP 0x0200 /* Local operator -- SRB */ #define UMODE_LOCOP 0x0200 /* Local operator -- SRB */
#define UMODE_KILLS 0x0400 /* Show server-kills... */ #define UMODE_KILLS 0x0400 /* Show server-kills... */
#define UMODE_CLIENT 0x0800 /* Show client information */ #define UMODE_CLIENT 0x0800 /* Show client information */
#define UMODE_FLOOD 0x1000 /* Receive flood warnings */ #define UMODE_FLOOD 0x1000 /* Receive flood warnings */
#define UMODE_CHATOP 0x2000 /* can receive chatops */ #define UMODE_CHATOP 0x2000 /* can receive chatops */
#define UMODE_SERVICES 0x4000 /* services */ #define UMODE_SERVICES 0x4000 /* services */
#define UMODE_HIDE 0x8000 /* Hide from Nukes */ #define UMODE_HIDE 0x8000 /* Hide from Nukes */
#define UMODE_WHOIS 0x200000 /* Lets Opers see when people do a /WhoIs on them */ #define UMODE_WHOIS 0x200000 /* Lets Opers see when people do a /WhoIs on them */
#define UMODE_IRCADMIN 0x1000000 /* Marks the client as an IRC Administrator */ #define UMODE_IRCADMIN 0x1000000 /* Marks the client as an IRC Administrator */
#define UMODE_SERVICESADMIN 0x2000000 /* Marks the client as a Services Administrator */ #define UMODE_SERVICESADMIN 0x2000000 /* Marks the client as a Services Administrator */
#define MODE_CHANOP 0x0001 #define MODE_CHANOP 0x0001
@ -395,8 +395,8 @@ struct ircd_srv_ {
typedef struct { typedef struct {
long mode; long mode;
char flag; char flag;
unsigned nickparam : 1; /* 1 = yes 0 = no */ unsigned nickparam:1; /* 1 = yes 0 = no */
unsigned parameters : 1; unsigned parameters:1;
char sjoin; char sjoin;
} aCtab; } aCtab;
@ -418,77 +418,77 @@ Oper_Modes susr_mds[9];
/* function declarations */ /* function declarations */
extern void init_ircd(); extern void init_ircd ();
extern void chanalert(char *,char *, ...); extern void chanalert (char *, char *, ...);
extern int sserver_cmd(const char *, const int numeric, const char *); extern int sserver_cmd (const char *, const int numeric, const char *);
extern int slogin_cmd(const char *, const int numeric, const char *, const char *); extern int slogin_cmd (const char *, const int numeric, const char *, const char *);
extern int ssquit_cmd(const char *); extern int ssquit_cmd (const char *);
extern int sprotocol_cmd(const char *); extern int sprotocol_cmd (const char *);
extern int squit_cmd(const char *, const char *); extern int squit_cmd (const char *, const char *);
extern int spart_cmd(const char *, const char *); extern int spart_cmd (const char *, const char *);
extern int sjoin_cmd(const char *, const char *); extern int sjoin_cmd (const char *, const char *);
extern int schmode_cmd(const char *, const char *, const char *, const char *); extern int schmode_cmd (const char *, const char *, const char *, const char *);
extern int snewnick_cmd(const char *, const char *, const char *, const char *); extern int snewnick_cmd (const char *, const char *, const char *, const char *);
extern int sping_cmd(const char *from, const char *reply, const char *to); extern int sping_cmd (const char *from, const char *reply, const char *to);
extern int sumode_cmd(const char *who, const char *target, long mode); extern int sumode_cmd (const char *who, const char *target, long mode);
extern int snumeric_cmd(const int numeric, const char *target, const char *data,...); extern int snumeric_cmd (const int numeric, const char *target, const char *data, ...);
extern int spong_cmd(const char *reply); extern int spong_cmd (const char *reply);
extern int snetinfo_cmd(); extern int snetinfo_cmd ();
extern int ssvskill_cmd(const char *who, const char *reason, ...); extern int ssvskill_cmd (const char *who, const char *reason, ...);
extern int skill_cmd(const char *from, const char *target, const char *reason,...); extern int skill_cmd (const char *from, const char *target, const char *reason, ...);
extern int ssmo_cmd(const char *from, const char *umodetarget, const char *msg); extern int ssmo_cmd (const char *from, const char *umodetarget, const char *msg);
extern int snick_cmd(const char *oldnick, const char *newnick); extern int snick_cmd (const char *oldnick, const char *newnick);
extern int sswhois_cmd(const char *target, const char *swhois); extern int sswhois_cmd (const char *target, const char *swhois);
extern int ssvsnick_cmd(const char *target, const char *newnick); extern int ssvsnick_cmd (const char *target, const char *newnick);
extern int ssvsjoin_cmd(const char *target, const char *chan); extern int ssvsjoin_cmd (const char *target, const char *chan);
extern int ssvspart_cmd(const char *target, const char *chan); extern int ssvspart_cmd (const char *target, const char *chan);
extern int ssvshost_cmd(const char *who, const char *vhost); extern int ssvshost_cmd (const char *who, const char *vhost);
extern int skick_cmd(const char *who, const char *target, const char *chan, const char *reason); extern int skick_cmd (const char *who, const char *target, const char *chan, const char *reason);
extern int swallops_cmd(const char *who, const char *msg,...); extern int swallops_cmd (const char *who, const char *msg, ...);
extern int vctrl_cmd(); extern int vctrl_cmd ();
extern int ssvinfo_cmd(); extern int ssvinfo_cmd ();
extern int sburst_cmd(int b); extern int sburst_cmd (int b);
extern int sakill_cmd(const char *host, const char *ident, const char *setby, const int length, const char *reason,...); extern int sakill_cmd (const char *host, const char *ident, const char *setby, const int length, const char *reason, ...);
extern int srakill_cmd(const char *host, const char *ident); extern int srakill_cmd (const char *host, const char *ident);
extern int ssvshost_cmd(const char *who, const char *vhost); extern int ssvshost_cmd (const char *who, const char *vhost);
void Usr_Version(char *, char **, int argc); void Usr_Version (char *, char **, int argc);
void Usr_ShowMOTD(char *, char **, int argc); void Usr_ShowMOTD (char *, char **, int argc);
void Usr_ShowADMIN(char *, char **, int argc); void Usr_ShowADMIN (char *, char **, int argc);
void Usr_Showcredits(char *, char **, int argc); void Usr_Showcredits (char *, char **, int argc);
void Usr_AddServer(char *, char **, int argc); void Usr_AddServer (char *, char **, int argc);
void Usr_DelServer(char *, char **, int argc); void Usr_DelServer (char *, char **, int argc);
void Usr_DelUser(char *, char **, int argc); void Usr_DelUser (char *, char **, int argc);
void Usr_Mode(char *, char **, int argc); void Usr_Mode (char *, char **, int argc);
void Usr_Smode(char *, char **, int argc); void Usr_Smode (char *, char **, int argc);
void Usr_Kill(char *, char **, int argc); void Usr_Kill (char *, char **, int argc);
void Usr_Pong(char *, char **, int argc); void Usr_Pong (char *, char **, int argc);
void Usr_Away(char *, char **, int argc); void Usr_Away (char *, char **, int argc);
void Usr_Nick(char *, char **, int argc); void Usr_Nick (char *, char **, int argc);
void Usr_Topic(char *, char **, int argc); void Usr_Topic (char *, char **, int argc);
void Usr_Kick(char *, char **, int argc); void Usr_Kick (char *, char **, int argc);
void Usr_Join(char *, char **, int argc); void Usr_Join (char *, char **, int argc);
void Usr_Part(char *, char **, int argc); void Usr_Part (char *, char **, int argc);
void Usr_Stats(char *, char **, int argc); void Usr_Stats (char *, char **, int argc);
void Usr_Vhost(char *, char **, int argc); void Usr_Vhost (char *, char **, int argc);
void Srv_Topic(char *, char **, int argc); void Srv_Topic (char *, char **, int argc);
void Srv_Ping(char *, char **, int argc); void Srv_Ping (char *, char **, int argc);
void Srv_Netinfo(char *, char **, int argc); void Srv_Netinfo (char *, char **, int argc);
void Srv_Pass(char *, char **, int argc); void Srv_Pass (char *, char **, int argc);
void Srv_Server(char *, char **, int argc); void Srv_Server (char *, char **, int argc);
void Srv_Squit(char *, char **, int argc); void Srv_Squit (char *, char **, int argc);
void Srv_Nick(char *, char **, int argc); void Srv_Nick (char *, char **, int argc);
void Srv_Svsnick(char *, char **, int argc); void Srv_Svsnick (char *, char **, int argc);
void Srv_Kill(char *, char **, int argc); void Srv_Kill (char *, char **, int argc);
void Srv_Connect(char *, char **, int argc); void Srv_Connect (char *, char **, int argc);
void Srv_Svinfo(char *, char **, int argc); void Srv_Svinfo (char *, char **, int argc);
void Srv_Burst(char *origin, char **argv, int argc); void Srv_Burst (char *origin, char **argv, int argc);
void Srv_Sjoin(char *origin, char **argv, int argc); void Srv_Sjoin (char *origin, char **argv, int argc);
void Srv_Tburst(char *origin, char **argv, int argc); void Srv_Tburst (char *origin, char **argv, int argc);
void Srv_Vctrl(char *origin, char **argv, int argc); void Srv_Vctrl (char *origin, char **argv, int argc);
void Srv_Client(char *origin, char **argv, int argc); void Srv_Client (char *origin, char **argv, int argc);
void Srv_Smode(char *origin, char **argv, int argc); void Srv_Smode (char *origin, char **argv, int argc);
int SignOn_NewBot(const char *, const char *, const char *, const char *, long); int SignOn_NewBot (const char *, const char *, const char *, const char *, long);
#endif #endif

701
neoircd.c

File diff suppressed because it is too large Load diff

272
neoircd.h
View file

@ -18,7 +18,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: neoircd.h,v 1.9 2003/07/23 10:35:47 fishwaldo Exp $ ** $Id: neoircd.h,v 1.10 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
@ -31,68 +31,68 @@
#define MSG_EOB "EOB" /* end of burst */ #define MSG_EOB "EOB" /* end of burst */
#define MSG_PRIVATE "PRIVMSG" /* PRIV */ #define MSG_PRIVATE "PRIVMSG" /* PRIV */
#define MSG_WHO "WHO" /* WHO -> WHOC */ #define MSG_WHO "WHO" /* WHO -> WHOC */
#define MSG_WHOIS "WHOIS" /* WHOI */ #define MSG_WHOIS "WHOIS" /* WHOI */
#define MSG_WHOWAS "WHOWAS" /* WHOW */ #define MSG_WHOWAS "WHOWAS" /* WHOW */
#define MSG_USER "USER" /* USER */ #define MSG_USER "USER" /* USER */
#define MSG_NICK "NICK" /* NICK */ #define MSG_NICK "NICK" /* NICK */
#define MSG_SERVER "SERVER" /* SERV */ #define MSG_SERVER "SERVER" /* SERV */
#define MSG_LIST "LIST" /* LIST */ #define MSG_LIST "LIST" /* LIST */
#define MSG_TOPIC "TOPIC" /* TOPI */ #define MSG_TOPIC "TOPIC" /* TOPI */
#define MSG_INVITE "INVITE" /* INVI */ #define MSG_INVITE "INVITE" /* INVI */
#define MSG_VERSION "VERSION" /* VERS */ #define MSG_VERSION "VERSION" /* VERS */
#define MSG_QUIT "QUIT" /* QUIT */ #define MSG_QUIT "QUIT" /* QUIT */
#define MSG_SQUIT "SQUIT" /* SQUI */ #define MSG_SQUIT "SQUIT" /* SQUI */
#define MSG_KILL "KILL" /* KILL */ #define MSG_KILL "KILL" /* KILL */
#define MSG_INFO "INFO" /* INFO */ #define MSG_INFO "INFO" /* INFO */
#define MSG_LINKS "LINKS" /* LINK */ #define MSG_LINKS "LINKS" /* LINK */
#define MSG_WATCH "WATCH" /* WATCH */ #define MSG_WATCH "WATCH" /* WATCH */
#define MSG_STATS "STATS" /* STAT */ #define MSG_STATS "STATS" /* STAT */
#define MSG_HELP "HELP" /* HELP */ #define MSG_HELP "HELP" /* HELP */
#define MSG_HELPOP "HELPOP" /* HELP */ #define MSG_HELPOP "HELPOP" /* HELP */
#define MSG_ERROR "ERROR" /* ERRO */ #define MSG_ERROR "ERROR" /* ERRO */
#define MSG_AWAY "AWAY" /* AWAY */ #define MSG_AWAY "AWAY" /* AWAY */
#define MSG_CONNECT "CONNECT" /* CONN */ #define MSG_CONNECT "CONNECT" /* CONN */
#define MSG_PING "PING" /* PING */ #define MSG_PING "PING" /* PING */
#define MSG_PONG "PONG" /* PONG */ #define MSG_PONG "PONG" /* PONG */
#define MSG_OPER "OPER" /* OPER */ #define MSG_OPER "OPER" /* OPER */
#define MSG_PASS "PASS" /* PASS */ #define MSG_PASS "PASS" /* PASS */
#define MSG_WALLOPS "WALLOPS" /* WALL */ #define MSG_WALLOPS "WALLOPS" /* WALL */
#define MSG_TIME "TIME" /* TIME */ #define MSG_TIME "TIME" /* TIME */
#define MSG_NAMES "NAMES" /* NAME */ #define MSG_NAMES "NAMES" /* NAME */
#define MSG_ADMIN "ADMIN" /* ADMI */ #define MSG_ADMIN "ADMIN" /* ADMI */
#define MSG_NOTICE "NOTICE" /* NOTI */ #define MSG_NOTICE "NOTICE" /* NOTI */
#define MSG_JOIN "JOIN" /* JOIN */ #define MSG_JOIN "JOIN" /* JOIN */
#define MSG_PART "PART" /* PART */ #define MSG_PART "PART" /* PART */
#define MSG_LUSERS "LUSERS" /* LUSE */ #define MSG_LUSERS "LUSERS" /* LUSE */
#define MSG_MOTD "MOTD" /* MOTD */ #define MSG_MOTD "MOTD" /* MOTD */
#define MSG_MODE "MODE" /* MODE */ #define MSG_MODE "MODE" /* MODE */
#define MSG_KICK "KICK" /* KICK */ #define MSG_KICK "KICK" /* KICK */
#define MSG_SERVICE "SERVICE" /* SERV -> SRVI */ #define MSG_SERVICE "SERVICE" /* SERV -> SRVI */
#define MSG_USERHOST "USERHOST" /* USER -> USRH */ #define MSG_USERHOST "USERHOST" /* USER -> USRH */
#define MSG_ISON "ISON" /* ISON */ #define MSG_ISON "ISON" /* ISON */
#define MSG_SQUERY "SQUERY" /* SQUE */ #define MSG_SQUERY "SQUERY" /* SQUE */
#define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */ #define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */
#define MSG_SERVSET "SERVSET" /* SERV -> SSET */ #define MSG_SERVSET "SERVSET" /* SERV -> SSET */
#define MSG_REHASH "REHASH" /* REHA */ #define MSG_REHASH "REHASH" /* REHA */
#define MSG_RESTART "RESTART" /* REST */ #define MSG_RESTART "RESTART" /* REST */
#define MSG_CLOSE "CLOSE" /* CLOS */ #define MSG_CLOSE "CLOSE" /* CLOS */
#define MSG_DIE "DIE" /* DIE */ #define MSG_DIE "DIE" /* DIE */
#define MSG_HASH "HASH" /* HASH */ #define MSG_HASH "HASH" /* HASH */
#define MSG_DNS "DNS" /* DNS -> DNSS */ #define MSG_DNS "DNS" /* DNS -> DNSS */
#define MSG_SILENCE "SILENCE" /* SILE */ #define MSG_SILENCE "SILENCE" /* SILE */
#define MSG_AKILL "AKILL" /* AKILL */ #define MSG_AKILL "AKILL" /* AKILL */
#define MSG_KLINE "KLINE" /* KLINE */ #define MSG_KLINE "KLINE" /* KLINE */
#define MSG_UNKLINE "UNKLINE" /* UNKLINE */ #define MSG_UNKLINE "UNKLINE" /* UNKLINE */
#define MSG_RAKILL "RAKILL" /* RAKILL */ #define MSG_RAKILL "RAKILL" /* RAKILL */
#define MSG_GNOTICE "GNOTICE" /* GNOTICE */ #define MSG_GNOTICE "GNOTICE" /* GNOTICE */
#define MSG_GOPER "GOPER" /* GOPER */ #define MSG_GOPER "GOPER" /* GOPER */
#define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */ #define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */
#define MSG_LOCOPS "LOCOPS" /* LOCOPS */ #define MSG_LOCOPS "LOCOPS" /* LOCOPS */
#define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */ #define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */
#define MSG_TRACE "TRACE" /* TRAC */ #define MSG_TRACE "TRACE" /* TRAC */
#define MSG_SQLINE "SQLINE" /* SQLINE */ #define MSG_SQLINE "SQLINE" /* SQLINE */
#define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */ #define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */
#define MSG_SVSNICK "SVSNICK" /* SVSNICK */ #define MSG_SVSNICK "SVSNICK" /* SVSNICK */
@ -111,14 +111,14 @@
#define MSG_SVSMODE "SVSMODE" /* SVSMODE */ #define MSG_SVSMODE "SVSMODE" /* SVSMODE */
#define MSG_SAMODE "SAMODE" /* SAMODE */ #define MSG_SAMODE "SAMODE" /* SAMODE */
#define MSG_CHATOPS "CHATOPS" /* CHATOPS */ #define MSG_CHATOPS "CHATOPS" /* CHATOPS */
#define MSG_HELPSERV "HELPSERV" /* HELPSERV */ #define MSG_HELPSERV "HELPSERV" /* HELPSERV */
#define MSG_ZLINE "ZLINE" /* ZLINE */ #define MSG_ZLINE "ZLINE" /* ZLINE */
#define MSG_UNZLINE "UNZLINE" /* UNZLINE */ #define MSG_UNZLINE "UNZLINE" /* UNZLINE */
#define MSG_NETINFO "NETINFO" /* NETINFO */ #define MSG_NETINFO "NETINFO" /* NETINFO */
#define MSG_RULES "RULES" /* RULES */ #define MSG_RULES "RULES" /* RULES */
#define MSG_MAP "MAP" /* MAP */ #define MSG_MAP "MAP" /* MAP */
#define MSG_NETG "NETG" /* NETG */ #define MSG_NETG "NETG" /* NETG */
#define MSG_ADCHAT "ADCHAT" /* Adchat */ #define MSG_ADCHAT "ADCHAT" /* Adchat */
#define MSG_MAKEPASS "MAKEPASS" /* MAKEPASS */ #define MSG_MAKEPASS "MAKEPASS" /* MAKEPASS */
#define MSG_ADDHUB "ADDHUB" /* ADDHUB */ #define MSG_ADDHUB "ADDHUB" /* ADDHUB */
#define MSG_DELHUB "DELHUB" /* DELHUB */ #define MSG_DELHUB "DELHUB" /* DELHUB */
@ -128,28 +128,28 @@
#define MSG_DELOPER "DELOPER" /* DELOPER */ #define MSG_DELOPER "DELOPER" /* DELOPER */
#define MSG_ADDQLINE "ADDQLINE" /* ADDQLINE */ #define MSG_ADDQLINE "ADDQLINE" /* ADDQLINE */
#define MSG_DELQLINE "DELQLINE" /* DELQLINE */ #define MSG_DELQLINE "DELQLINE" /* DELQLINE */
#define MSG_GSOP "GSOP" /* GSOP */ #define MSG_GSOP "GSOP" /* GSOP */
#define MSG_ISOPER "ISOPER" /* ISOPER */ #define MSG_ISOPER "ISOPER" /* ISOPER */
#define MSG_ADG "ADG" /* ADG */ #define MSG_ADG "ADG" /* ADG */
#define MSG_NMON "NMON" /* NMON */ #define MSG_NMON "NMON" /* NMON */
#define MSG_DALINFO "DALINFO" /* DALnet Credits */ #define MSG_DALINFO "DALINFO" /* DALnet Credits */
#define MSG_CREDITS "CREDITS" /* UltimateIRCd Credits and "Thanks To" */ #define MSG_CREDITS "CREDITS" /* UltimateIRCd Credits and "Thanks To" */
#define MSG_OPERMOTD "OPERMOTD" /* OPERMOTD */ #define MSG_OPERMOTD "OPERMOTD" /* OPERMOTD */
#define MSG_REMREHASH "REMREHASH" /* Remote Rehash */ #define MSG_REMREHASH "REMREHASH" /* Remote Rehash */
#define MSG_MONITOR "MONITOR" /* MONITOR */ #define MSG_MONITOR "MONITOR" /* MONITOR */
#define MSG_GLINE "GLINE" /* The awesome g-line */ #define MSG_GLINE "GLINE" /* The awesome g-line */
#define MSG_REMGLINE "REMGLINE" /* remove g-line */ #define MSG_REMGLINE "REMGLINE" /* remove g-line */
#define MSG_STATSERV "STATSERV" /* StatServ */ #define MSG_STATSERV "STATSERV" /* StatServ */
#define MSG_RULESERV "RULESERV" /* RuleServ */ #define MSG_RULESERV "RULESERV" /* RuleServ */
#define MSG_SNETINFO "SNETINFO" /* SNetInfo */ #define MSG_SNETINFO "SNETINFO" /* SNetInfo */
#define MSG_TSCTL "TSCTL" /* TSCTL */ #define MSG_TSCTL "TSCTL" /* TSCTL */
#define MSG_SVSJOIN "SVSJOIN" /* SVSJOIN */ #define MSG_SVSJOIN "SVSJOIN" /* SVSJOIN */
#define MSG_SAJOIN "SAJOIN" /* SAJOIN */ #define MSG_SAJOIN "SAJOIN" /* SAJOIN */
#define MSG_SDESC "SDESC" /* SDESC */ #define MSG_SDESC "SDESC" /* SDESC */
#define MSG_UNREALINFO "UNREALINFO" /* Unreal Info */ #define MSG_UNREALINFO "UNREALINFO" /* Unreal Info */
#define MSG_SETHOST "SETHOST" /* sethost */ #define MSG_SETHOST "SETHOST" /* sethost */
#define MSG_SETIDENT "SETIDENT" /* set ident */ #define MSG_SETIDENT "SETIDENT" /* set ident */
#define MSG_SETNAME "SETNAME" /* set Realname */ #define MSG_SETNAME "SETNAME" /* set Realname */
#define MSG_CHGHOST "CHGHOST" /* Changehost */ #define MSG_CHGHOST "CHGHOST" /* Changehost */
#define MSG_CHGIDENT "CHGIDENT" /* Change Ident */ #define MSG_CHGIDENT "CHGIDENT" /* Change Ident */
#define MSG_RANDQUOTE "RANDQUOTE" /* Random Quote */ #define MSG_RANDQUOTE "RANDQUOTE" /* Random Quote */
@ -157,19 +157,19 @@
#define MSG_ADDGQUOTE "ADDGQUOTE" /* Add Global Quote */ #define MSG_ADDGQUOTE "ADDGQUOTE" /* Add Global Quote */
#define MSG_ADDULINE "ADDULINE" /* Adds an U Line to ircd.conf file */ #define MSG_ADDULINE "ADDULINE" /* Adds an U Line to ircd.conf file */
#define MSG_DELULINE "DELULINE" /* Removes an U line from the ircd.conf */ #define MSG_DELULINE "DELULINE" /* Removes an U line from the ircd.conf */
#define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */ #define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */
#define MSG_SETTINGS "SETTINGS" /* Settings */ #define MSG_SETTINGS "SETTINGS" /* Settings */
#define MSG_IRCOPS "IRCOPS" /* Shows Online IRCOps */ #define MSG_IRCOPS "IRCOPS" /* Shows Online IRCOps */
#define MSG_SVSPART "SVSPART" /* SVSPART */ #define MSG_SVSPART "SVSPART" /* SVSPART */
#define MSG_SAPART "SAPART" /* SAPART */ #define MSG_SAPART "SAPART" /* SAPART */
#define MSG_VCTRL "VCTRL" /* VCTRL */ #define MSG_VCTRL "VCTRL" /* VCTRL */
#define MSG_GCLIENT "GCLIENT" /* GLIENT */ #define MSG_GCLIENT "GCLIENT" /* GLIENT */
#define MSG_CHANNEL "CHANNEL" /* CHANNEL */ #define MSG_CHANNEL "CHANNEL" /* CHANNEL */
#define MSG_UPTIME "UPTIME" /* UPTIME */ #define MSG_UPTIME "UPTIME" /* UPTIME */
#define MSG_FAILOPS "FAILOPS" /* FAILOPS */ #define MSG_FAILOPS "FAILOPS" /* FAILOPS */
#define MSG_RPING "RPING" /* RPING */ #define MSG_RPING "RPING" /* RPING */
#define MSG_RPONG "RPONG" /* RPONG */ #define MSG_RPONG "RPONG" /* RPONG */
#define MSG_UPING "UPING" /* UPING */ #define MSG_UPING "UPING" /* UPING */
#define MSG_COPYRIGHT "COPYRIGHT" /* Copyright */ #define MSG_COPYRIGHT "COPYRIGHT" /* Copyright */
#define MSG_BOTSERV "BOTSERV" /* BOTSERV */ #define MSG_BOTSERV "BOTSERV" /* BOTSERV */
#define MSG_BS "BS" #define MSG_BS "BS"
@ -194,15 +194,15 @@
#define UMODE_SKILL 0x0100 /* client see's server kills */ #define UMODE_SKILL 0x0100 /* client see's server kills */
#define UMODE_LOCOPS 0x0200 /* client is localop */ #define UMODE_LOCOPS 0x0200 /* client is localop */
#define UMODE_NCHANGE 0x0400 /* client can see nick change notices */ #define UMODE_NCHANGE 0x0400 /* client can see nick change notices */
#define UMODE_REJ 0x0800 /* client is registered */ #define UMODE_REJ 0x0800 /* client is registered */
#define UMODE_SERVNOTICE 0x1000 /* client can see server notices */ #define UMODE_SERVNOTICE 0x1000 /* client can see server notices */
#define UMODE_UNAUTH 0x2000 /* client can see unauthd connections */ #define UMODE_UNAUTH 0x2000 /* client can see unauthd connections */
#define UMODE_WALLOP 0x4000 /* client can get wallop messages */ #define UMODE_WALLOP 0x4000 /* client can get wallop messages */
#define UMODE_EXTERNAL 0x8000 /* client can see server joins/splits */ #define UMODE_EXTERNAL 0x8000 /* client can see server joins/splits */
#define UMODE_SPY 0x10000 /* client can spy on user commands */ #define UMODE_SPY 0x10000 /* client can spy on user commands */
#define UMODE_OPERWALL 0x20000 /* client gets operwalls */ #define UMODE_OPERWALL 0x20000 /* client gets operwalls */
#define UMODE_SERVICES 0x40000 /* client is services */ #define UMODE_SERVICES 0x40000 /* client is services */
#define UMODE_REGNICK 0x80000 /* registered nickname */ #define UMODE_REGNICK 0x80000 /* registered nickname */
#define MODE_CHANOP 0x0001 #define MODE_CHANOP 0x0001
#define MODE_HALFOP 0x0002 #define MODE_HALFOP 0x0002
@ -241,8 +241,8 @@ struct ircd_srv_ {
typedef struct { typedef struct {
long mode; long mode;
char flag; char flag;
unsigned nickparam : 1; /* 1 = yes 0 = no */ unsigned nickparam:1; /* 1 = yes 0 = no */
unsigned parameters : 1; unsigned parameters:1;
char sjoin; char sjoin;
} aCtab; } aCtab;
@ -264,74 +264,74 @@ Oper_Modes susr_mds[0];
/* function declarations */ /* function declarations */
extern void init_ircd(); extern void init_ircd ();
extern void chanalert(char *,char *, ...); extern void chanalert (char *, char *, ...);
extern int sserver_cmd(const char *, const int numeric, const char *); extern int sserver_cmd (const char *, const int numeric, const char *);
extern int slogin_cmd(const char *, const int numeric, const char *, const char *); extern int slogin_cmd (const char *, const int numeric, const char *, const char *);
extern int ssquit_cmd(const char *); extern int ssquit_cmd (const char *);
extern int sprotocol_cmd(const char *); extern int sprotocol_cmd (const char *);
extern int squit_cmd(const char *, const char *); extern int squit_cmd (const char *, const char *);
extern int spart_cmd(const char *, const char *); extern int spart_cmd (const char *, const char *);
extern int sjoin_cmd(const char *, const char *); extern int sjoin_cmd (const char *, const char *);
extern int schmode_cmd(const char *, const char *, const char *, const char *); extern int schmode_cmd (const char *, const char *, const char *, const char *);
extern int snewnick_cmd(const char *, const char *, const char *, const char *, long mode); extern int snewnick_cmd (const char *, const char *, const char *, const char *, long mode);
extern int sping_cmd(const char *from, const char *reply, const char *to); extern int sping_cmd (const char *from, const char *reply, const char *to);
extern int sumode_cmd(const char *who, const char *target, long mode); extern int sumode_cmd (const char *who, const char *target, long mode);
extern int snumeric_cmd(const int numeric, const char *target, const char *data,...); extern int snumeric_cmd (const int numeric, const char *target, const char *data, ...);
extern int spong_cmd(const char *reply); extern int spong_cmd (const char *reply);
extern int snetinfo_cmd(); extern int snetinfo_cmd ();
extern int skill_cmd(const char *from, const char *target, const char *reason,...); extern int skill_cmd (const char *from, const char *target, const char *reason, ...);
extern int ssvskill_cmd(const char *who, const char *reason, ...); extern int ssvskill_cmd (const char *who, const char *reason, ...);
extern int ssmo_cmd(const char *from, const char *umodetarget, const char *msg); extern int ssmo_cmd (const char *from, const char *umodetarget, const char *msg);
extern int snick_cmd(const char *oldnick, const char *newnick); extern int snick_cmd (const char *oldnick, const char *newnick);
extern int sswhois_cmd(const char *target, const char *swhois); extern int sswhois_cmd (const char *target, const char *swhois);
extern int ssvsnick_cmd(const char *target, const char *newnick); extern int ssvsnick_cmd (const char *target, const char *newnick);
extern int ssvsjoin_cmd(const char *target, const char *chan); extern int ssvsjoin_cmd (const char *target, const char *chan);
extern int ssvspart_cmd(const char *target, const char *chan); extern int ssvspart_cmd (const char *target, const char *chan);
extern int ssvshost_cmd(const char *who, const char *vhost); extern int ssvshost_cmd (const char *who, const char *vhost);
extern int skick_cmd(const char *who, const char *target, const char *chan, const char *reason); extern int skick_cmd (const char *who, const char *target, const char *chan, const char *reason);
extern int swallops_cmd(const char *who, const char *msg,...); extern int swallops_cmd (const char *who, const char *msg, ...);
extern int vctrl_cmd(); extern int vctrl_cmd ();
extern int ssvinfo_cmd(); extern int ssvinfo_cmd ();
extern int sburst_cmd(int b); extern int sburst_cmd (int b);
extern int seob_cmd(const char *server); extern int seob_cmd (const char *server);
extern int sakill_cmd(const char *host, const char *ident, const char *setby, const int length, const char *reason,...); extern int sakill_cmd (const char *host, const char *ident, const char *setby, const int length, const char *reason, ...);
extern int srakill_cmd(const char *host, const char *ident); extern int srakill_cmd (const char *host, const char *ident);
extern int SignOn_NewBot(const char *, const char *, const char *, const char *, long); extern int SignOn_NewBot (const char *, const char *, const char *, const char *, long);
void Usr_Version(char *, char **, int argc); void Usr_Version (char *, char **, int argc);
void Usr_ShowMOTD(char *, char **, int argc); void Usr_ShowMOTD (char *, char **, int argc);
void Usr_ShowADMIN(char *, char **, int argc); void Usr_ShowADMIN (char *, char **, int argc);
void Usr_Showcredits(char *, char **, int argc); void Usr_Showcredits (char *, char **, int argc);
void Usr_AddServer(char *, char **, int argc); void Usr_AddServer (char *, char **, int argc);
void Usr_DelServer(char *, char **, int argc); void Usr_DelServer (char *, char **, int argc);
void Usr_DelUser(char *, char **, int argc); void Usr_DelUser (char *, char **, int argc);
void Usr_Mode(char *, char **, int argc); void Usr_Mode (char *, char **, int argc);
void Usr_Smode(char *, char **, int argc); void Usr_Smode (char *, char **, int argc);
void Usr_Kill(char *, char **, int argc); void Usr_Kill (char *, char **, int argc);
void Usr_Pong(char *, char **, int argc); void Usr_Pong (char *, char **, int argc);
void Usr_Away(char *, char **, int argc); void Usr_Away (char *, char **, int argc);
void Usr_Nick(char *, char **, int argc); void Usr_Nick (char *, char **, int argc);
void Usr_Topic(char *, char **, int argc); void Usr_Topic (char *, char **, int argc);
void Usr_Kick(char *, char **, int argc); void Usr_Kick (char *, char **, int argc);
void Usr_Join(char *, char **, int argc); void Usr_Join (char *, char **, int argc);
void Usr_Part(char *, char **, int argc); void Usr_Part (char *, char **, int argc);
void Usr_Stats(char *, char **, int argc); void Usr_Stats (char *, char **, int argc);
void Usr_Vhost(char *, char **, int argc); void Usr_Vhost (char *, char **, int argc);
void Srv_Topic(char *, char **, int argc); void Srv_Topic (char *, char **, int argc);
void Srv_Ping(char *, char **, int argc); void Srv_Ping (char *, char **, int argc);
void Srv_Netinfo(char *, char **, int argc); void Srv_Netinfo (char *, char **, int argc);
void Srv_Pass(char *, char **, int argc); void Srv_Pass (char *, char **, int argc);
void Srv_Server(char *, char **, int argc); void Srv_Server (char *, char **, int argc);
void Srv_Squit(char *, char **, int argc); void Srv_Squit (char *, char **, int argc);
void Srv_Nick(char *, char **, int argc); void Srv_Nick (char *, char **, int argc);
void Srv_Svsnick(char *, char **, int argc); void Srv_Svsnick (char *, char **, int argc);
void Srv_Kill(char *, char **, int argc); void Srv_Kill (char *, char **, int argc);
void Srv_Connect(char *, char **, int argc); void Srv_Connect (char *, char **, int argc);
void Srv_Svinfo(char *, char **, int argc); void Srv_Svinfo (char *, char **, int argc);
void Srv_Burst(char *origin, char **argv, int argc); void Srv_Burst (char *origin, char **argv, int argc);
void Srv_Sjoin(char *origin, char **argv, int argc); void Srv_Sjoin (char *origin, char **argv, int argc);
void Srv_Tburst(char *origin, char **argv, int argc); void Srv_Tburst (char *origin, char **argv, int argc);
int SignOn_NewBot(const char *, const char *, const char *, const char *, long); int SignOn_NewBot (const char *, const char *, const char *, const char *, long);
#endif #endif

View file

@ -22,12 +22,13 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: ns_help.c,v 1.8 2003/06/13 13:11:49 fishwaldo Exp $ ** $Id: ns_help.c,v 1.9 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
#include "stats.h" #include "stats.h"
void init_ns_help() void
init_ns_help ()
{ {
if (usr_mds); if (usr_mds);
} }

120
server.c
View file

@ -22,7 +22,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: server.c,v 1.20 2003/07/15 09:16:15 fishwaldo Exp $ ** $Id: server.c,v 1.21 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
#include <fnmatch.h> #include <fnmatch.h>
@ -31,64 +31,67 @@
#include "hash.h" #include "hash.h"
#include "log.h" #include "log.h"
int fnmatch(const char *, const char *, int flags); int fnmatch (const char *, const char *, int flags);
Server *new_server(char *); Server *new_server (char *);
void init_server() void
init_server ()
{ {
if (usr_mds); if (usr_mds);
} }
Server *new_server(char *name) Server *
new_server (char *name)
{ {
Server *s; Server *s;
hnode_t *sn; hnode_t *sn;
s = calloc(sizeof(Server), 1); s = calloc (sizeof (Server), 1);
if (!name) if (!name)
name = ""; name = "";
memcpy(s->name, name, MAXHOST); memcpy (s->name, name, MAXHOST);
sn = hnode_create(s); sn = hnode_create (s);
if (!sn) { if (!sn) {
nlog(LOG_WARNING, LOG_CORE, "Eeek, Hash is broken\n"); nlog (LOG_WARNING, LOG_CORE, "Eeek, Hash is broken\n");
} }
if (hash_isfull(sh)) { if (hash_isfull (sh)) {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "Eeek, Server Hash is full!\n");
"Eeek, Server Hash is full!\n");
} else { } else {
hash_insert(sh, sn, s->name); hash_insert (sh, sn, s->name);
} }
return s; return s;
} }
void AddServer(char *name, char *uplink, int hops) void
AddServer (char *name, char *uplink, int hops)
{ {
Server *s; Server *s;
char **av; char **av;
int ac = 0; int ac = 0;
nlog(LOG_DEBUG1, LOG_CORE, "New Server: %s", name); nlog (LOG_DEBUG1, LOG_CORE, "New Server: %s", name);
s = new_server(name); s = new_server (name);
s->hops = hops; s->hops = hops;
s->connected_since = time(NULL); s->connected_since = time (NULL);
/* this is kionda useless right ? */ /* this is kionda useless right ? */
/* s->last_announce = time(NULL); */ /* s->last_announce = time(NULL); */
if (uplink) { if (uplink) {
memcpy(s->uplink, uplink, MAXHOST); memcpy (s->uplink, uplink, MAXHOST);
} else { } else {
strcpy(s->uplink, "\0"); strcpy (s->uplink, "\0");
} }
s->ping = 0; s->ping = 0;
/* run the module event for a new server. */ /* run the module event for a new server. */
AddStringToList(&av, s->name, &ac); AddStringToList (&av, s->name, &ac);
Module_Event("NEWSERVER", av, ac); Module_Event ("NEWSERVER", av, ac);
free(av); free (av);
} }
void DelServer(char *name) void
DelServer (char *name)
{ {
Server *s; Server *s;
hnode_t *sn; hnode_t *sn;
@ -98,83 +101,84 @@ void DelServer(char *name)
if (!name) { if (!name) {
return; return;
} }
sn = hash_lookup(sh, name); sn = hash_lookup (sh, name);
if (!sn) { if (!sn) {
nlog(LOG_DEBUG1, LOG_CORE, "DelServer(): %s not found!", nlog (LOG_DEBUG1, LOG_CORE, "DelServer(): %s not found!", name);
name);
return; return;
} }
s = hnode_get(sn); s = hnode_get (sn);
/* run the event for delete server */ /* run the event for delete server */
AddStringToList(&av, s->name, &ac); AddStringToList (&av, s->name, &ac);
Module_Event("SQUIT", av, ac); Module_Event ("SQUIT", av, ac);
free(av); free (av);
hash_delete(sh, sn); hash_delete (sh, sn);
hnode_destroy(sn); hnode_destroy (sn);
free(s); free (s);
} }
Server *findserver(const char *name) Server *
findserver (const char *name)
{ {
Server *s; Server *s;
hnode_t *sn; hnode_t *sn;
sn = hash_lookup(sh, name); sn = hash_lookup (sh, name);
if (sn) { if (sn) {
s = hnode_get(sn); s = hnode_get (sn);
return s; return s;
} else { } else {
nlog(LOG_DEBUG2, LOG_CORE, "FindServer(): %s not found!", nlog (LOG_DEBUG2, LOG_CORE, "FindServer(): %s not found!", name);
name);
return NULL; return NULL;
} }
} }
void ServerDump() void
ServerDump ()
{ {
Server *s; Server *s;
hscan_t ss; hscan_t ss;
hnode_t *sn; hnode_t *sn;
sendcoders("Server Listing:"); sendcoders ("Server Listing:");
hash_scan_begin(&ss, sh); hash_scan_begin (&ss, sh);
while ((sn = hash_scan_next(&ss)) != NULL) { while ((sn = hash_scan_next (&ss)) != NULL) {
s = hnode_get(sn); s = hnode_get (sn);
sendcoders("Server Entry: %s", s->name); sendcoders ("Server Entry: %s", s->name);
} }
sendcoders("End of Listing."); sendcoders ("End of Listing.");
} }
void init_server_hash() void
init_server_hash ()
{ {
sh = hash_create(S_TABLE_SIZE, 0, 0); sh = hash_create (S_TABLE_SIZE, 0, 0);
if (!sh) { if (!sh) {
nlog(LOG_CRITICAL, LOG_CORE, nlog (LOG_CRITICAL, LOG_CORE, "Create Server Hash Failed\n");
"Create Server Hash Failed\n"); do_exit (1);
do_exit(1);
} }
AddServer(me.name, NULL, 0); AddServer (me.name, NULL, 0);
} }
void TimerPings() void
TimerPings ()
{ {
Server *s; Server *s;
hscan_t ss; hscan_t ss;
hnode_t *sn; hnode_t *sn;
nlog(LOG_DEBUG3, LOG_CORE, "Sendings pings..."); nlog (LOG_DEBUG3, LOG_CORE, "Sendings pings...");
ping.ulag = 0; ping.ulag = 0;
hash_scan_begin(&ss, sh); hash_scan_begin (&ss, sh);
while ((sn = hash_scan_next(&ss)) != NULL) { while ((sn = hash_scan_next (&ss)) != NULL) {
s = hnode_get(sn); s = hnode_get (sn);
if (!strcmp(me.name, s->name)) { if (!strcmp (me.name, s->name)) {
s->ping = 0; s->ping = 0;
continue; continue;
} }
sping_cmd(me.name, me.name, s->name); sping_cmd (me.name, me.name, s->name);
} }
} }

View file

@ -22,7 +22,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: services.c,v 1.55 2003/06/13 13:11:49 fishwaldo Exp $ ** $Id: services.c,v 1.56 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
#include "stats.h" #include "stats.h"
@ -34,544 +34,458 @@ extern const char version_date[], version_time[];
extern const char protocol_version[]; extern const char protocol_version[];
static void ns_reload(User * u, char *reason); static void ns_reload (User * u, char *reason);
static void ns_logs(User *); static void ns_logs (User *);
static void ns_jupe(User *, char *); static void ns_jupe (User *, char *);
void ns_debug_to_coders(char *); void ns_debug_to_coders (char *);
#ifdef USE_RAW #ifdef USE_RAW
static void ns_raw(User *, char *); static void ns_raw (User *, char *);
#endif #endif
static void ns_user_dump(User *, char *); static void ns_user_dump (User *, char *);
static void ns_server_dump(User *); static void ns_server_dump (User *);
static void ns_chan_dump(User *, char *); static void ns_chan_dump (User *, char *);
static void ns_uptime(User *); static void ns_uptime (User *);
static void ns_version(User *); static void ns_version (User *);
void servicesbot(char *nick, char **av, int ac) void
servicesbot (char *nick, char **av, int ac)
{ {
User *u; User *u;
int rval; int rval;
char *tmp; char *tmp;
u = finduser(nick); u = finduser (nick);
if (!u) { if (!u) {
nlog(LOG_WARNING, LOG_CORE, "Unable to finduser %s (%s)", nlog (LOG_WARNING, LOG_CORE, "Unable to finduser %s (%s)", nick, s_Services);
nick, s_Services);
return; return;
} }
me.requests++; me.requests++;
if (me.onlyopers && (UserLevel(u) < 40)) { if (me.onlyopers && (UserLevel (u) < 40)) {
prefmsg(u->nick, s_Services, prefmsg (u->nick, s_Services, "This service is only available to IRCops.");
"This service is only available to IRCops."); chanalert (s_Services, "%s Requested %s, but he is Not a Operator!", u->nick, av[1]);
chanalert(s_Services,
"%s Requested %s, but he is Not a Operator!",
u->nick, av[1]);
return; return;
} }
if (!strcasecmp(av[1], "HELP")) { if (!strcasecmp (av[1], "HELP")) {
if (ac > 2) { if (ac > 2) {
chanalert(s_Services, "%s Requested %s Help on %s", chanalert (s_Services, "%s Requested %s Help on %s", u->nick, s_Services, av[2]);
u->nick, s_Services, av[2]);
} else { } else {
chanalert(s_Services, "%s Requested %s Help", chanalert (s_Services, "%s Requested %s Help", u->nick, s_Services);
u->nick, s_Services);
} }
if (ac < 3) { if (ac < 3) {
privmsg_list(nick, s_Services, ns_help); privmsg_list (nick, s_Services, ns_help);
if (UserLevel(u) >= 180) if (UserLevel (u) >= 180)
privmsg_list(nick, s_Services, privmsg_list (nick, s_Services, ns_myuser_help);
ns_myuser_help); } else if (!strcasecmp (av[2], "VERSION"))
} else if (!strcasecmp(av[2], "VERSION")) privmsg_list (nick, s_Services, ns_version_help);
privmsg_list(nick, s_Services, ns_version_help); else if (!strcasecmp (av[2], "SHUTDOWN")
else if (!strcasecmp(av[2], "SHUTDOWN") && (UserLevel (u) >= 180))
&& (UserLevel(u) >= 180)) privmsg_list (nick, s_Services, ns_shutdown_help);
privmsg_list(nick, s_Services, ns_shutdown_help); else if (!strcasecmp (av[2], "RELOAD")
else if (!strcasecmp(av[2], "RELOAD") && (UserLevel (u) >= 180))
&& (UserLevel(u) >= 180)) privmsg_list (nick, s_Services, ns_reload_help);
privmsg_list(nick, s_Services, ns_reload_help); else if (!strcasecmp (av[2], "LOGS")
else if (!strcasecmp(av[2], "LOGS") && (UserLevel (u) >= 180))
&& (UserLevel(u) >= 180)) privmsg_list (nick, s_Services, ns_logs_help);
privmsg_list(nick, s_Services, ns_logs_help); else if (!strcasecmp (av[2], "LOAD")
else if (!strcasecmp(av[2], "LOAD") && (UserLevel (u) >= 180))
&& (UserLevel(u) >= 180)) privmsg_list (nick, s_Services, ns_load_help);
privmsg_list(nick, s_Services, ns_load_help); else if (!strcasecmp (av[2], "UNLOAD")
else if (!strcasecmp(av[2], "UNLOAD") && (UserLevel (u) >= 180))
&& (UserLevel(u) >= 180)) privmsg_list (nick, s_Services, ns_unload_help);
privmsg_list(nick, s_Services, ns_unload_help); else if (!strcasecmp (av[2], "MODLIST")
else if (!strcasecmp(av[2], "MODLIST") && (UserLevel (u) >= 180))
&& (UserLevel(u) >= 180)) privmsg_list (nick, s_Services, ns_modlist_help);
privmsg_list(nick, s_Services, ns_modlist_help); else if (!strcasecmp (av[2], "USERDUMP")
else if (!strcasecmp(av[2], "USERDUMP") && (UserLevel (u) >= 180) && (me.coder_debug))
&& (UserLevel(u) >= 180) && (me.coder_debug)) privmsg_list (nick, s_Services, ns_userdump_help);
privmsg_list(nick, s_Services, ns_userdump_help); else if (!strcasecmp (av[2], "CHANDUMP")
else if (!strcasecmp(av[2], "CHANDUMP") && (UserLevel (u) >= 180) && (me.coder_debug))
&& (UserLevel(u) >= 180) && (me.coder_debug)) privmsg_list (nick, s_Services, ns_chandump_help);
privmsg_list(nick, s_Services, ns_chandump_help); else if (!strcasecmp (av[2], "SERVERDUMP")
else if (!strcasecmp(av[2], "SERVERDUMP") && (UserLevel (u) >= 180) && (me.coder_debug))
&& (UserLevel(u) >= 180) && (me.coder_debug)) privmsg_list (nick, s_Services, ns_serverdump_help);
privmsg_list(nick, s_Services, ns_serverdump_help); else if (!strcasecmp (av[2], "JUPE")
else if (!strcasecmp(av[2], "JUPE") && (UserLevel (u) >= 180))
&& (UserLevel(u) >= 180)) privmsg_list (nick, s_Services, ns_jupe_help);
privmsg_list(nick, s_Services, ns_jupe_help);
#ifdef USE_RAW #ifdef USE_RAW
else if (!strcasecmp(av[2], "RAW") else if (!strcasecmp (av[2], "RAW")
&& (UserLevel(u) >= 180)) && (UserLevel (u) >= 180))
privmsg_list(nick, s_Services, ns_raw_help); privmsg_list (nick, s_Services, ns_raw_help);
#endif #endif
else if (!strcasecmp(av[2], "LEVEL")) else if (!strcasecmp (av[2], "LEVEL"))
privmsg_list(nick, s_Services, ns_level_help); privmsg_list (nick, s_Services, ns_level_help);
else else
prefmsg(nick, s_Services, prefmsg (nick, s_Services, "Unknown Help Topic: \2%s\2", av[2]);
"Unknown Help Topic: \2%s\2", av[2]); } else if (!strcasecmp (av[1], "LEVEL")) {
} else if (!strcasecmp(av[1], "LEVEL")) { prefmsg (nick, s_Services, "Your Level is %d", UserLevel (u));
prefmsg(nick, s_Services, "Your Level is %d", } else if (!strcasecmp (av[1], "LOAD")) {
UserLevel(u)); if (!(UserLevel (u) >= 180)) {
} else if (!strcasecmp(av[1], "LOAD")) { prefmsg (nick, s_Services, "Permission Denied");
if (!(UserLevel(u) >= 180)) { chanalert (s_Services, "%s Tried to LOAD, but is not at least a NetAdmin", nick);
prefmsg(nick, s_Services, "Permission Denied");
chanalert(s_Services,
"%s Tried to LOAD, but is not at least a NetAdmin",
nick);
return; return;
} }
if (ac <= 2) { if (ac <= 2) {
prefmsg(nick, s_Services, prefmsg (nick, s_Services, "Please Specify a Module");
"Please Specify a Module");
return; return;
} }
rval = load_module(av[2], u); rval = load_module (av[2], u);
if (!rval) { if (!rval) {
chanalert(s_Services, "%s Loaded Module %s", chanalert (s_Services, "%s Loaded Module %s", u->nick, av[2]);
u->nick, av[2]);
} else { } else {
chanalert(s_Services, chanalert (s_Services, "%s Tried to Load Module %s, but Failed", u->nick, av[2]);
"%s Tried to Load Module %s, but Failed",
u->nick, av[2]);
} }
} else if (!strcasecmp(av[1], "MODLIST")) { } else if (!strcasecmp (av[1], "MODLIST")) {
if (!(UserLevel(u) >= 180)) { if (!(UserLevel (u) >= 180)) {
prefmsg(nick, s_Services, "Permission Denied"); prefmsg (nick, s_Services, "Permission Denied");
chanalert(s_Services, chanalert (s_Services, "%s Tried to MODLIST, but is not a Techadmin", nick);
"%s Tried to MODLIST, but is not a Techadmin",
nick);
return; return;
} }
list_module(u); list_module (u);
} else if (!strcasecmp(av[1], "UNLOAD")) { } else if (!strcasecmp (av[1], "UNLOAD")) {
if (!(UserLevel(u) >= 180)) { if (!(UserLevel (u) >= 180)) {
prefmsg(nick, s_Services, "Permission Denied"); prefmsg (nick, s_Services, "Permission Denied");
chanalert(s_Services, chanalert (s_Services, "%s Tried to UNLOAD, but is not a Techadmin", nick);
"%s Tried to UNLOAD, but is not a Techadmin",
nick);
return; return;
} }
if (ac <= 2) { if (ac <= 2) {
prefmsg(nick, s_Services, prefmsg (nick, s_Services, " Please Specify a Module Name");
" Please Specify a Module Name");
return; return;
} }
rval = unload_module(av[2], u); rval = unload_module (av[2], u);
if (rval > 0) { if (rval > 0) {
chanalert(s_Services, "%s Unloaded Module %s", chanalert (s_Services, "%s Unloaded Module %s", u->nick, av[2]);
u->nick, av[2]);
} }
return; return;
} else if (!strcasecmp(av[1], "MODBOTLIST")) { } else if (!strcasecmp (av[1], "MODBOTLIST")) {
if (!(UserLevel(u) >= 180)) { if (!(UserLevel (u) >= 180)) {
prefmsg(nick, s_Services, "Permission Denied"); prefmsg (nick, s_Services, "Permission Denied");
chanalert(s_Services, chanalert (s_Services, "%s Tried to MODBOTLIST, but is not a Techadmin", nick);
"%s Tried to MODBOTLIST, but is not a Techadmin",
nick);
return; return;
} }
list_module_bots(u); list_module_bots (u);
} else if (!strcasecmp(av[1], "MODSOCKLIST")) { } else if (!strcasecmp (av[1], "MODSOCKLIST")) {
if (!(UserLevel(u) >= 180)) { if (!(UserLevel (u) >= 180)) {
prefmsg(nick, s_Services, "Permission Denied"); prefmsg (nick, s_Services, "Permission Denied");
chanalert(s_Services, chanalert (s_Services, "%s Tried to MODSOCKLIST, but is not a Techadmin", nick);
"%s Tried to MODSOCKLIST, but is not a Techadmin",
nick);
return; return;
} }
list_sockets(u); list_sockets (u);
} else if (!strcasecmp(av[1], "MODTIMERLIST")) { } else if (!strcasecmp (av[1], "MODTIMERLIST")) {
if (!(UserLevel(u) >= 180)) { if (!(UserLevel (u) >= 180)) {
prefmsg(nick, s_Services, "Permission Denied"); prefmsg (nick, s_Services, "Permission Denied");
chanalert(s_Services, chanalert (s_Services, "%s Tried to MODTIMERLIST, but is not a Techadmin", nick);
"%s Tried to MODTIMERLIST, but is not a Techadmin",
nick);
return; return;
} }
list_module_timer(u); list_module_timer (u);
} else if (!strcasecmp(av[1], "MODBOTCHANLIST")) { } else if (!strcasecmp (av[1], "MODBOTCHANLIST")) {
if (!(UserLevel(u) >= 180)) { if (!(UserLevel (u) >= 180)) {
prefmsg(nick, s_Services, "Permission Denied"); prefmsg (nick, s_Services, "Permission Denied");
chanalert(s_Services, chanalert (s_Services, "%s tried to MODBOTCHANLIST, but is not a techadmin", nick);
"%s tried to MODBOTCHANLIST, but is not a techadmin",
nick);
return; return;
} }
botchandump(u); botchandump (u);
} else if (!strcasecmp(av[1], "INFO")) { } else if (!strcasecmp (av[1], "INFO")) {
ns_uptime(u); ns_uptime (u);
chanalert(s_Services, "%s Wanted to see %s's info", chanalert (s_Services, "%s Wanted to see %s's info", u->nick, me.name);
u->nick, me.name); } else if (!strcasecmp (av[1], "SHUTDOWN")) {
} else if (!strcasecmp(av[1], "SHUTDOWN")) { if (!(UserLevel (u) >= 180)) {
if (!(UserLevel(u) >= 180)) { prefmsg (nick, s_Services, "Permission Denied");
prefmsg(nick, s_Services, "Permission Denied"); chanalert (s_Services, "%s Tried to SHUTDOWN, but is not a Techadmin", nick);
chanalert(s_Services,
"%s Tried to SHUTDOWN, but is not a Techadmin",
nick);
return; return;
} }
chanalert(s_Services, chanalert (s_Services, "%s Wants me to Go to BED!!! Good Night!", u->nick);
"%s Wants me to Go to BED!!! Good Night!", tmp = joinbuf (av, ac, 2);
u->nick); ns_shutdown (u, tmp);
tmp = joinbuf(av, ac, 2); free (tmp);
ns_shutdown(u, tmp); } else if (!strcasecmp (av[1], "VERSION")) {
free(tmp); ns_version (u);
} else if (!strcasecmp(av[1], "VERSION")) { chanalert (s_Services, "%s Wanted to know our version number ", u->nick);
ns_version(u); } else if (!strcasecmp (av[1], "RELOAD")) {
chanalert(s_Services, if (!(UserLevel (u) >= 180)) {
"%s Wanted to know our version number ", prefmsg (nick, s_Services, "Permission Denied");
u->nick); chanalert (s_Services, "%s Tried to RELOAD, but is not a Techadmin", nick);
} else if (!strcasecmp(av[1], "RELOAD")) {
if (!(UserLevel(u) >= 180)) {
prefmsg(nick, s_Services, "Permission Denied");
chanalert(s_Services,
"%s Tried to RELOAD, but is not a Techadmin",
nick);
return; return;
} }
if (ac <= 2) { if (ac <= 2) {
prefmsg(nick, s_Services, prefmsg (nick, s_Services, "You must supply a Reason to Reload");
"You must supply a Reason to Reload");
return; return;
} }
tmp = joinbuf(av, ac, 2); tmp = joinbuf (av, ac, 2);
chanalert(s_Services, "%s Wants me to RELOAD! for %s", chanalert (s_Services, "%s Wants me to RELOAD! for %s", u->nick, tmp);
u->nick, tmp); ns_reload (u, tmp);
ns_reload(u, tmp); free (tmp);
free(tmp); } else if (!strcasecmp (av[1], "LOGS")) {
} else if (!strcasecmp(av[1], "LOGS")) { if (!(UserLevel (u) >= 180)) {
if (!(UserLevel(u) >= 180)) { prefmsg (nick, s_Services, "Permission Denied");
prefmsg(nick, s_Services, "Permission Denied"); chanalert (s_Services, "%s Tried to view LOGS, but is not a Techadmin", nick);
chanalert(s_Services,
"%s Tried to view LOGS, but is not a Techadmin",
nick);
return; return;
} }
ns_logs(u); ns_logs (u);
chanalert(s_Services, "%s Wants to Look at my Logs!!", chanalert (s_Services, "%s Wants to Look at my Logs!!", u->nick);
u->nick); } else if (!strcasecmp (av[1], "JUPE")) {
} else if (!strcasecmp(av[1], "JUPE")) { if (!(UserLevel (u) >= 180)) {
if (!(UserLevel(u) >= 180)) { prefmsg (nick, s_Services, "Permission Denied");
prefmsg(nick, s_Services, "Permission Denied"); chanalert (s_Services, "%s Tried to JUPE, but is not a Techadmin", nick);
chanalert(s_Services,
"%s Tried to JUPE, but is not a Techadmin",
nick);
return; return;
} }
if (ac <= 2) { if (ac <= 2) {
prefmsg(nick, s_Services, prefmsg (nick, s_Services, "You must supply a ServerName to Jupe");
"You must supply a ServerName to Jupe");
return; return;
} }
ns_jupe(u, av[2]); ns_jupe (u, av[2]);
chanalert(s_Services, "%s Wants to JUPE this Server %s", chanalert (s_Services, "%s Wants to JUPE this Server %s", u->nick, av[2]);
u->nick, av[2]); } else if (!strcasecmp (av[1], "DEBUG")) {
} else if (!strcasecmp(av[1], "DEBUG")) { if (!(UserLevel (u) >= 180)) {
if (!(UserLevel(u) >= 180)) { prefmsg (u->nick, s_Services, "Permission Denied, you need to be a Techadmin to Enable Debug Mode!");
prefmsg(u->nick, s_Services,
"Permission Denied, you need to be a Techadmin to Enable Debug Mode!");
return; return;
} }
ns_debug_to_coders(u->nick); ns_debug_to_coders (u->nick);
} else if (!strcasecmp(av[1], "USERDUMP")) { } else if (!strcasecmp (av[1], "USERDUMP")) {
if (!me.coder_debug) { if (!me.coder_debug) {
prefmsg(u->nick, s_Services, prefmsg (u->nick, s_Services, "\2Error:\2 Debug Mode Disabled");
"\2Error:\2 Debug Mode Disabled");
return; return;
} }
if (ac <= 2) { if (ac <= 2) {
ns_user_dump(u, NULL); ns_user_dump (u, NULL);
} else { } else {
ns_user_dump(u, av[2]); ns_user_dump (u, av[2]);
} }
} else if (!strcasecmp(av[1], "CHANDUMP")) { } else if (!strcasecmp (av[1], "CHANDUMP")) {
if (!me.coder_debug) { if (!me.coder_debug) {
prefmsg(u->nick, s_Services, prefmsg (u->nick, s_Services, "\2Error:\2 Debug Mode Disabled");
"\2Error:\2 Debug Mode Disabled");
return; return;
} }
if (ac < 3) { if (ac < 3) {
ns_chan_dump(u, NULL); ns_chan_dump (u, NULL);
} else { } else {
ns_chan_dump(u, av[2]); ns_chan_dump (u, av[2]);
} }
} else if (!strcasecmp(av[1], "SERVERDUMP")) { } else if (!strcasecmp (av[1], "SERVERDUMP")) {
if (!me.coder_debug) { if (!me.coder_debug) {
prefmsg(u->nick, s_Services, prefmsg (u->nick, s_Services, "\2Error:\2 Debug Mode Disabled");
"\2Error:\2 Debug Mode Disabled");
return; return;
} }
ns_server_dump(u); ns_server_dump (u);
} else if (!strcasecmp(av[1], "RAW")) { } else if (!strcasecmp (av[1], "RAW")) {
if (!(UserLevel(u) >= 180)) { if (!(UserLevel (u) >= 180)) {
prefmsg(nick, s_Services, "Permission Denied"); prefmsg (nick, s_Services, "Permission Denied");
chanalert(s_Services, chanalert (s_Services, "%s Tried to use RAW, but is not a Techadmin", nick);
"%s Tried to use RAW, but is not a Techadmin",
nick);
return; return;
} }
#ifdef USE_RAW #ifdef USE_RAW
tmp = joinbuf(av, ac, 2); tmp = joinbuf (av, ac, 2);
ns_raw(u, tmp); ns_raw (u, tmp);
free(tmp); free (tmp);
return; return;
#else #else
prefmsg(nick, s_Services, "Raw is disabled"); prefmsg (nick, s_Services, "Raw is disabled");
return; return;
#endif #endif
} else { } else {
prefmsg(nick, s_Services, "Unknown Command: \2%s\2", prefmsg (nick, s_Services, "Unknown Command: \2%s\2", av[1]);
av[1]); chanalert (s_Services, "%s Reqested %s, but that is a Unknown Command", u->nick, av[1]);
chanalert(s_Services,
"%s Reqested %s, but that is a Unknown Command",
u->nick, av[1]);
} }
} }
extern void ns_shutdown(User * u, char *reason) extern void
ns_shutdown (User * u, char *reason)
{ {
Module *mod_ptr = NULL; Module *mod_ptr = NULL;
hscan_t ms; hscan_t ms;
hnode_t *mn; hnode_t *mn;
char quitmsg[255]; char quitmsg[255];
strcpy(segv_location, "ns_shutdown"); strcpy (segv_location, "ns_shutdown");
/* Unload the Modules */ /* Unload the Modules */
hash_scan_begin(&ms, mh); hash_scan_begin (&ms, mh);
while ((mn = hash_scan_next(&ms)) != NULL) { while ((mn = hash_scan_next (&ms)) != NULL) {
mod_ptr = hnode_get(mn); mod_ptr = hnode_get (mn);
chanalert(s_Services, "Module %s Unloaded by %s", chanalert (s_Services, "Module %s Unloaded by %s", mod_ptr->info->module_name, u->nick);
mod_ptr->info->module_name, u->nick); unload_module (mod_ptr->info->module_name, u);
unload_module(mod_ptr->info->module_name, u);
} }
globops(s_Services, "%s requested \2SHUTDOWN\2 for %s", u->nick, globops (s_Services, "%s requested \2SHUTDOWN\2 for %s", u->nick, reason);
reason); snprintf (quitmsg, 255, "%s Set SHUTDOWN: %s", u->nick, (reason ? reason : "No Reason"));
snprintf(quitmsg, 255, "%s Set SHUTDOWN: %s", u->nick, squit_cmd (s_Services, quitmsg);
(reason ? reason : "No Reason")); ssquit_cmd (me.name);
squit_cmd(s_Services, quitmsg); sleep (1);
ssquit_cmd(me.name); close (servsock);
sleep(1); remove ("neostats.pid");
close(servsock); nlog (LOG_NOTICE, LOG_CORE, "%s [%s](%s) requested SHUTDOWN.", u->nick, u->username, u->hostname);
remove("neostats.pid"); do_exit (0);
nlog(LOG_NOTICE, LOG_CORE, "%s [%s](%s) requested SHUTDOWN.",
u->nick, u->username, u->hostname);
do_exit(0);
} }
static void ns_reload(User * u, char *reason) static void
ns_reload (User * u, char *reason)
{ {
Module *mod_ptr = NULL; Module *mod_ptr = NULL;
hscan_t ms; hscan_t ms;
hnode_t *mn; hnode_t *mn;
char quitmsg[255]; char quitmsg[255];
strcpy(segv_location, "ns_reload"); strcpy (segv_location, "ns_reload");
globops(s_Services, "%s requested \2RELOAD\2 for %s", u->nick, globops (s_Services, "%s requested \2RELOAD\2 for %s", u->nick, reason);
reason); nlog (LOG_NOTICE, LOG_CORE, "%s requested RELOAD. -> reason", u->nick);
nlog(LOG_NOTICE, LOG_CORE, "%s requested RELOAD. -> reason", snprintf (quitmsg, 255, "%s Sent RELOAD: %s", u->nick, reason);
u->nick); hash_scan_begin (&ms, mh);
snprintf(quitmsg, 255, "%s Sent RELOAD: %s", u->nick, reason); while ((mn = hash_scan_next (&ms)) != NULL) {
hash_scan_begin(&ms, mh); mod_ptr = hnode_get (mn);
while ((mn = hash_scan_next(&ms)) != NULL) { chanalert (s_Services, "Module %s Unloaded by %s", mod_ptr->info->module_name, u->nick);
mod_ptr = hnode_get(mn); unload_module (mod_ptr->info->module_name, u);
chanalert(s_Services, "Module %s Unloaded by %s",
mod_ptr->info->module_name, u->nick);
unload_module(mod_ptr->info->module_name, u);
} }
squit_cmd(s_Services, quitmsg); squit_cmd (s_Services, quitmsg);
ssquit_cmd(me.name); ssquit_cmd (me.name);
sleep(5); sleep (5);
do_exit(2); do_exit (2);
} }
static void ns_logs(User * u) static void
ns_logs (User * u)
{ {
#ifdef DEBUG #ifdef DEBUG
prefmsg(u->nick, s_Services, prefmsg (u->nick, s_Services, "This command is disabled while in DEBUG.");
"This command is disabled while in DEBUG.");
#else #else
FILE *fp; FILE *fp;
char buf[512]; char buf[512];
strcpy(segv_location, "ns_logs"); strcpy (segv_location, "ns_logs");
fp = fopen("logs/NeoStats.log", "r"); fp = fopen ("logs/NeoStats.log", "r");
if (!fp) { if (!fp) {
prefmsg(u->nick, s_Services, prefmsg (u->nick, s_Services, "Unable to open neostats.log");
"Unable to open neostats.log");
return; return;
} }
while (fgets(buf, sizeof(buf), fp)) { while (fgets (buf, sizeof (buf), fp)) {
buf[strlen(buf)] = '\0'; buf[strlen (buf)] = '\0';
prefmsg(u->nick, s_Services, "%s", buf); prefmsg (u->nick, s_Services, "%s", buf);
} }
fclose(fp); fclose (fp);
#endif #endif
} }
static void ns_jupe(User * u, char *server) static void
ns_jupe (User * u, char *server)
{ {
char infoline[255]; char infoline[255];
strcpy(segv_location, "ns_jupe"); strcpy (segv_location, "ns_jupe");
snprintf(infoline, 255, "[Jupitered by %s]", u->nick); snprintf (infoline, 255, "[Jupitered by %s]", u->nick);
sserver_cmd(server, 1, infoline); sserver_cmd (server, 1, infoline);
nlog(LOG_NOTICE, LOG_CORE, "%s!%s@%s jupitered %s", u->nick, nlog (LOG_NOTICE, LOG_CORE, "%s!%s@%s jupitered %s", u->nick, u->username, u->hostname, server);
u->username, u->hostname, server);
} }
void ns_debug_to_coders(char *u) void
ns_debug_to_coders (char *u)
{ {
strcpy(segv_location, "ns_debug_to_coders"); strcpy (segv_location, "ns_debug_to_coders");
if (!me.coder_debug) { if (!me.coder_debug) {
me.coder_debug = 1; me.coder_debug = 1;
if (u) { if (u) {
globops(me.name, "\2DEBUG MODE\2 Activated by %s", globops (me.name, "\2DEBUG MODE\2 Activated by %s", u);
u); prefmsg (u, s_Services, "Debuging Mode Enabled!");
prefmsg(u, s_Services, "Debuging Mode Enabled!");
} else { } else {
globops(me.name, "\2DEBUG MODE\3 Active"); globops (me.name, "\2DEBUG MODE\3 Active");
} }
} else { } else {
me.coder_debug = 0; me.coder_debug = 0;
if (!u) { if (!u) {
globops(me.name, globops (me.name, "\2DEBUG MODE\2 Deactivated by %s", u);
"\2DEBUG MODE\2 Deactivated by %s", u); prefmsg (u, s_Services, "Debuging Mode Disabled");
prefmsg(u, s_Services, "Debuging Mode Disabled");
} else { } else {
globops(me.name, "\2DEBUG MODE\2 Deactivated"); globops (me.name, "\2DEBUG MODE\2 Deactivated");
} }
} }
} }
#ifdef USE_RAW #ifdef USE_RAW
static void ns_raw(User * u, char *message) static void
ns_raw (User * u, char *message)
{ {
int sent; int sent;
strcpy(segv_location, "ns_raw"); strcpy (segv_location, "ns_raw");
chanalert(s_Services, chanalert (s_Services, "\2RAW COMMAND\2 \2%s\2 Issued a Raw Command!(%s)", u->nick, message);
"\2RAW COMMAND\2 \2%s\2 Issued a Raw Command!(%s)", nlog (LOG_INFO, LOG_CORE, "RAW COMMAND %sIssued a Raw Command!(%s)", u->nick, message);
u->nick, message); strcat (message, "\n");
nlog(LOG_INFO, LOG_CORE, "RAW COMMAND %sIssued a Raw Command!(%s)", sent = write (servsock, message, strlen (message));
u->nick, message);
strcat(message, "\n");
sent = write(servsock, message, strlen(message));
if (sent == -1) { if (sent == -1) {
nlog(LOG_CRITICAL, LOG_CORE, "Write error."); nlog (LOG_CRITICAL, LOG_CORE, "Write error.");
do_exit(0); do_exit (0);
} }
me.SendM++; me.SendM++;
me.SendBytes = me.SendBytes + sent; me.SendBytes = me.SendBytes + sent;
} }
#endif #endif
static void ns_user_dump(User * u, char *nick) static void
ns_user_dump (User * u, char *nick)
{ {
strcpy(segv_location, "ns_user_dump"); strcpy (segv_location, "ns_user_dump");
if (!(UserLevel(u) >= 180)) { if (!(UserLevel (u) >= 180)) {
prefmsg(u->nick, s_Services, prefmsg (u->nick, s_Services, "Permission Denied, you need to be at least a NetAdmin to Enable Debug Mode!");
"Permission Denied, you need to be at least a NetAdmin to Enable Debug Mode!");
return; return;
} }
chanalert(s_Services, "\2DEBUG\2 \2%s\2 Requested a UserDump!", chanalert (s_Services, "\2DEBUG\2 \2%s\2 Requested a UserDump!", u->nick);
u->nick); UserDump (nick);
UserDump(nick);
} }
static void ns_server_dump(User * u) static void
ns_server_dump (User * u)
{ {
strcpy(segv_location, "ns_server_dump"); strcpy (segv_location, "ns_server_dump");
if (!(UserLevel(u) >= 180)) { if (!(UserLevel (u) >= 180)) {
prefmsg(u->nick, s_Services, prefmsg (u->nick, s_Services, "Permission Denied, you need to be at least a NetAdmin to Enable Debug Mode!");
"Permission Denied, you need to be at least a NetAdmin to Enable Debug Mode!");
return; return;
} }
chanalert(s_Services, "\2DEBUG\2 \2%s\2 Requested a ServerDump!", chanalert (s_Services, "\2DEBUG\2 \2%s\2 Requested a ServerDump!", u->nick);
u->nick); ServerDump ();
ServerDump();
} }
static void ns_chan_dump(User * u, char *chan) static void
ns_chan_dump (User * u, char *chan)
{ {
strcpy(segv_location, "ns_chan_dump"); strcpy (segv_location, "ns_chan_dump");
if (!(UserLevel(u) >= 180)) { if (!(UserLevel (u) >= 180)) {
prefmsg(u->nick, s_Services, prefmsg (u->nick, s_Services, "Permission Denied, you need to be at least a NetAdmin to Enable Debug Mode!");
"Permission Denied, you need to be at least a NetAdmin to Enable Debug Mode!");
return; return;
} }
chanalert(s_Services, "\2DEBUG\2 \2%s\2 Requested a ChannelDump!", chanalert (s_Services, "\2DEBUG\2 \2%s\2 Requested a ChannelDump!", u->nick);
u->nick); chandump (chan);
chandump(chan);
} }
static void ns_uptime(User * u) static void
ns_uptime (User * u)
{ {
int uptime = time(NULL) - me.t_start; int uptime = time (NULL) - me.t_start;
strcpy(segv_location, "ns_uptime"); strcpy (segv_location, "ns_uptime");
prefmsg(u->nick, s_Services, "Statistics Information:"); prefmsg (u->nick, s_Services, "Statistics Information:");
if (uptime > 86400) { if (uptime > 86400) {
prefmsg(u->nick, s_Services, prefmsg (u->nick, s_Services, "Statistics up \2%ld\2 day%s, \2%02ld:%02ld\2", uptime / 86400, (uptime / 86400 == 1) ? "" : "s", (uptime / 3600) % 24, (uptime / 60) % 60);
"Statistics up \2%ld\2 day%s, \2%02ld:%02ld\2",
uptime / 86400, (uptime / 86400 == 1) ? "" : "s",
(uptime / 3600) % 24, (uptime / 60) % 60);
} else if (uptime > 3600) { } else if (uptime > 3600) {
prefmsg(u->nick, s_Services, prefmsg (u->nick, s_Services, "Statistics up \2%ld hour%s, %ld minute%s\2", uptime / 3600, uptime / 3600 == 1 ? "" : "s", (uptime / 60) % 60, (uptime / 60) % 60 == 1 ? "" : "s");
"Statistics up \2%ld hour%s, %ld minute%s\2",
uptime / 3600, uptime / 3600 == 1 ? "" : "s",
(uptime / 60) % 60,
(uptime / 60) % 60 == 1 ? "" : "s");
} else if (uptime > 60) { } else if (uptime > 60) {
prefmsg(u->nick, s_Services, prefmsg (u->nick, s_Services, "Statistics up \2%ld minute%s, %ld second%s\2", uptime / 60, uptime / 60 == 1 ? "" : "s", uptime % 60, uptime % 60 == 1 ? "" : "s");
"Statistics up \2%ld minute%s, %ld second%s\2",
uptime / 60, uptime / 60 == 1 ? "" : "s",
uptime % 60, uptime % 60 == 1 ? "" : "s");
} else { } else {
prefmsg(u->nick, s_Services, prefmsg (u->nick, s_Services, "Statistics up \2%ld second%s\2", uptime, uptime == 1 ? "" : "s");
"Statistics up \2%ld second%s\2", uptime,
uptime == 1 ? "" : "s");
} }
prefmsg(u->nick, s_Services, prefmsg (u->nick, s_Services, "Sent %ld Messages Totaling %ld Bytes", me.SendM, me.SendBytes);
"Sent %ld Messages Totaling %ld Bytes", me.SendM, prefmsg (u->nick, s_Services, "Recieved %ld Messages, Totaling %ld Bytes", me.RcveM, me.RcveBytes);
me.SendBytes); prefmsg (u->nick, s_Services, "Reconnect Time: %d", me.r_time);
prefmsg(u->nick, s_Services, prefmsg (u->nick, s_Services, "Statistic Requests: %d", me.requests);
"Recieved %ld Messages, Totaling %ld Bytes", me.RcveM, prefmsg (u->nick, s_Services, "Max Sockets: %d (in use: %d)", me.maxsocks, me.cursocks);
me.RcveBytes); prefmsg (u->nick, s_Services, "Use SMO for Debug?: %s", (me.usesmo) ? "Enabled" : "Disabled");
prefmsg(u->nick, s_Services, "Reconnect Time: %d", me.r_time);
prefmsg(u->nick, s_Services, "Statistic Requests: %d",
me.requests);
prefmsg(u->nick, s_Services, "Max Sockets: %d (in use: %d)",
me.maxsocks, me.cursocks);
prefmsg(u->nick, s_Services, "Use SMO for Debug?: %s",
(me.usesmo) ? "Enabled" : "Disabled");
if (me.coder_debug) if (me.coder_debug)
prefmsg(u->nick, s_Services, "Debugging Mode is \2ON!\2"); prefmsg (u->nick, s_Services, "Debugging Mode is \2ON!\2");
else else
prefmsg(u->nick, s_Services, prefmsg (u->nick, s_Services, "Debugging Mode is Disabled!");
"Debugging Mode is Disabled!"); prefmsg (u->nick, s_Services, "End of Information.");
prefmsg(u->nick, s_Services, "End of Information.");
} }
static void ns_version(User * u) static void
ns_version (User * u)
{ {
strcpy(segv_location, "ns_version"); strcpy (segv_location, "ns_version");
prefmsg(u->nick, s_Services, "\2NeoStats Version Information\2"); prefmsg (u->nick, s_Services, "\2NeoStats Version Information\2");
prefmsg(u->nick, s_Services, "NeoStats Version: %d.%d.%d%s", MAJOR, prefmsg (u->nick, s_Services, "NeoStats Version: %d.%d.%d%s", MAJOR, MINOR, REV, version);
MINOR, REV, version); prefmsg (u->nick, s_Services, "http://www.neostats.net");
prefmsg(u->nick, s_Services, "http://www.neostats.net");
} }

326
sock.c
View file

@ -22,7 +22,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: sock.c,v 1.39 2003/06/26 05:25:09 fishwaldo Exp $ ** $Id: sock.c,v 1.40 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
#include <fcntl.h> #include <fcntl.h>
@ -32,12 +32,13 @@
#include "conf.h" #include "conf.h"
#include "log.h" #include "log.h"
void recvlog(char *line); void recvlog (char *line);
struct sockaddr_in lsa; struct sockaddr_in lsa;
int dobind; int dobind;
int ConnectTo(char *host, int port) int
ConnectTo (char *host, int port)
{ {
struct hostent *hp; struct hostent *hp;
struct sockaddr_in sa; struct sockaddr_in sa;
@ -45,15 +46,12 @@ int ConnectTo(char *host, int port)
dobind = 0; dobind = 0;
/* bind to a local ip */ /* bind to a local ip */
memset(&lsa, 0, sizeof(lsa)); memset (&lsa, 0, sizeof (lsa));
if (strlen(me.local) > 1) { if (strlen (me.local) > 1) {
if ((hp = gethostbyname(me.local)) == NULL) { if ((hp = gethostbyname (me.local)) == NULL) {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "Warning, Couldn't bind to IP address %s", me.local);
"Warning, Couldn't bind to IP address %s",
me.local);
} else { } else {
memcpy((char *) &lsa.sin_addr, hp->h_addr, memcpy ((char *) &lsa.sin_addr, hp->h_addr, hp->h_length);
hp->h_length);
lsa.sin_family = hp->h_addrtype; lsa.sin_family = hp->h_addrtype;
dobind = 1; dobind = 1;
} }
@ -61,35 +59,34 @@ int ConnectTo(char *host, int port)
if ((hp = gethostbyname(host)) == NULL) { if ((hp = gethostbyname (host)) == NULL) {
return (-1); return (-1);
} }
if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) if ((s = socket (AF_INET, SOCK_STREAM, 0)) < 0)
return (-1); return (-1);
if (dobind > 0) { if (dobind > 0) {
if (bind(s, (struct sockaddr *) &lsa, sizeof(lsa)) < 0) { if (bind (s, (struct sockaddr *) &lsa, sizeof (lsa)) < 0) {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "bind(): Warning, Couldn't bind to IP address %s", strerror (errno));
"bind(): Warning, Couldn't bind to IP address %s",
strerror(errno));
} }
} }
bzero(&sa, sizeof(sa)); bzero (&sa, sizeof (sa));
sa.sin_family = AF_INET; sa.sin_family = AF_INET;
sa.sin_port = htons(port); sa.sin_port = htons (port);
bcopy(hp->h_addr, (char *) &sa.sin_addr, hp->h_length); bcopy (hp->h_addr, (char *) &sa.sin_addr, hp->h_length);
if (connect(s, (struct sockaddr *) &sa, sizeof(sa)) < 0) { if (connect (s, (struct sockaddr *) &sa, sizeof (sa)) < 0) {
close(s); close (s);
return (-1); return (-1);
} }
return s; return s;
} }
void read_loop() void
read_loop ()
{ {
register int i, j, SelectResult; register int i, j, SelectResult;
struct timeval *TimeOut, tvbuf; struct timeval *TimeOut, tvbuf;
@ -103,224 +100,174 @@ void read_loop()
hscan_t ms; hscan_t ms;
hnode_t *mn; hnode_t *mn;
TimeOut = malloc(sizeof(struct timeval)); TimeOut = malloc (sizeof (struct timeval));
while (1) { while (1) {
strcpy(segv_location, "Read_Loop"); strcpy (segv_location, "Read_Loop");
memset(buf, '\0', BUFSIZE); memset (buf, '\0', BUFSIZE);
chk(); chk ();
strcpy(segv_location, "Read_Loop2"); strcpy (segv_location, "Read_Loop2");
FD_ZERO(&readfds); FD_ZERO (&readfds);
FD_ZERO(&writefds); FD_ZERO (&writefds);
FD_ZERO(&errfds); FD_ZERO (&errfds);
FD_SET(servsock, &readfds); FD_SET (servsock, &readfds);
hash_scan_begin(&ss, sockh); hash_scan_begin (&ss, sockh);
me.cursocks = 1; /* always one socket for ircd */ me.cursocks = 1; /* always one socket for ircd */
while ((sn = hash_scan_next(&ss)) != NULL) { while ((sn = hash_scan_next (&ss)) != NULL) {
mod_sock = hnode_get(sn); mod_sock = hnode_get (sn);
if (mod_sock->readfnc) if (mod_sock->readfnc)
FD_SET(mod_sock->sock_no, &readfds); FD_SET (mod_sock->sock_no, &readfds);
if (mod_sock->writefnc) if (mod_sock->writefnc)
FD_SET(mod_sock->sock_no, &writefds); FD_SET (mod_sock->sock_no, &writefds);
if (mod_sock->errfnc) if (mod_sock->errfnc)
FD_SET(mod_sock->sock_no, &errfds); FD_SET (mod_sock->sock_no, &errfds);
++me.cursocks; ++me.cursocks;
} }
/* adns stuff... whats its interested in */ /* adns stuff... whats its interested in */
adns_beforeselect(ads, &me.maxsocks, &readfds, &writefds, adns_beforeselect (ads, &me.maxsocks, &readfds, &writefds, &errfds, &TimeOut, &tvbuf, 0);
&errfds, &TimeOut, &tvbuf, 0);
/* adns may change this, but we tell it to go away!!! */ /* adns may change this, but we tell it to go away!!! */
TimeOut->tv_sec = 1; TimeOut->tv_sec = 1;
TimeOut->tv_usec = 0; TimeOut->tv_usec = 0;
SelectResult = SelectResult = select (FD_SETSIZE, &readfds, &writefds, &errfds, TimeOut);
select(FD_SETSIZE, &readfds, &writefds, &errfds,
TimeOut);
if (SelectResult > 0) { if (SelectResult > 0) {
adns_afterselect(ads, me.maxsocks, &readfds, adns_afterselect (ads, me.maxsocks, &readfds, &writefds, &errfds, 0);
&writefds, &errfds, 0);
/* do and dns related callbacks now */ /* do and dns related callbacks now */
do_dns(); do_dns ();
for (j = 0; j < BUFSIZE; j++) { for (j = 0; j < BUFSIZE; j++) {
if (FD_ISSET(servsock, &readfds)) { if (FD_ISSET (servsock, &readfds)) {
i = read(servsock, &c, 1); i = read (servsock, &c, 1);
me.RcveBytes++; me.RcveBytes++;
if (i >= 0) { if (i >= 0) {
buf[j] = c; buf[j] = c;
if ((c == '\n') if ((c == '\n')
|| (c == '\r')) { || (c == '\r')) {
me.RcveM++; me.RcveM++;
me.lastmsg = me.lastmsg = time (NULL);
time(NULL);
if (config.recvlog) if (config.recvlog)
recvlog recvlog (buf);
(buf); parse (buf);
parse(buf);
break; break;
} }
} else { } else {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "read returned a Error");
"read returned a Error");
return; return;
} }
} else { } else {
/* this checks if there is any data waiting on a socket for a module */ /* this checks if there is any data waiting on a socket for a module */
hash_scan_begin(&ss, sockh); hash_scan_begin (&ss, sockh);
while ((sn = while ((sn = hash_scan_next (&ss)) != NULL) {
hash_scan_next(&ss)) != mod_sock = hnode_get (sn);
NULL) { strcpy (segvinmodule, mod_sock->modname);
mod_sock = hnode_get(sn); if (FD_ISSET (mod_sock->sock_no, &readfds)) {
strcpy(segvinmodule, nlog (LOG_DEBUG3, LOG_CORE, "Running module %s readsock function for %s", mod_sock->modname, mod_sock->sockname);
mod_sock->modname); if (mod_sock->readfnc (mod_sock->sock_no, mod_sock->sockname) < 0)
if (FD_ISSET
(mod_sock->sock_no,
&readfds)) {
nlog(LOG_DEBUG3,
LOG_CORE,
"Running module %s readsock function for %s",
mod_sock->
modname,
mod_sock->
sockname);
if (mod_sock->
readfnc
(mod_sock->
sock_no,
mod_sock->
sockname) < 0)
break; break;
} }
if (FD_ISSET if (FD_ISSET (mod_sock->sock_no, &writefds)) {
(mod_sock->sock_no, nlog (LOG_DEBUG3, LOG_CORE, "Running module %s writesock function for %s", mod_sock->modname, mod_sock->sockname);
&writefds)) { if (mod_sock->writefnc (mod_sock->sock_no, mod_sock->sockname) < 0)
nlog(LOG_DEBUG3,
LOG_CORE,
"Running module %s writesock function for %s",
mod_sock->
modname,
mod_sock->
sockname);
if (mod_sock->
writefnc
(mod_sock->
sock_no,
mod_sock->
sockname) < 0)
break; break;
} }
if (FD_ISSET if (FD_ISSET (mod_sock->sock_no, &errfds)) {
(mod_sock->sock_no, nlog (LOG_DEBUG3, LOG_CORE, "Running module %s errorsock function for %s", mod_sock->modname, mod_sock->sockname);
&errfds)) { if (mod_sock->errfnc (mod_sock->sock_no, mod_sock->sockname) < 0)
nlog(LOG_DEBUG3,
LOG_CORE,
"Running module %s errorsock function for %s",
mod_sock->
modname,
mod_sock->
sockname);
if (mod_sock->
errfnc
(mod_sock->
sock_no,
mod_sock->
sockname) < 0)
break; break;
} }
} }
strcpy(segvinmodule, ""); strcpy (segvinmodule, "");
break; break;
} }
} }
} else if (SelectResult == 0) { } else if (SelectResult == 0) {
if ((time(NULL) - me.lastmsg) > 180) { if ((time (NULL) - me.lastmsg) > 180) {
/* if we havnt had a message for 3 minutes, more than likely, we are on a zombie server */ /* if we havnt had a message for 3 minutes, more than likely, we are on a zombie server */
/* disconnect and try to reconnect */ /* disconnect and try to reconnect */
/* Unload the Modules */ /* Unload the Modules */
hash_scan_begin(&ms, mh); hash_scan_begin (&ms, mh);
while ((mn = hash_scan_next(&ms)) != NULL) { while ((mn = hash_scan_next (&ms)) != NULL) {
mod_ptr = hnode_get(mn); mod_ptr = hnode_get (mn);
unload_module(mod_ptr->info-> unload_module (mod_ptr->info->module_name, finduser (s_Services));
module_name,
finduser
(s_Services));
} }
close(servsock); close (servsock);
sleep(5); sleep (5);
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "Eeek, Zombie Server, Reconnecting");
"Eeek, Zombie Server, Reconnecting"); do_exit (2);
do_exit(2);
} }
} else if (SelectResult == -1) { } else if (SelectResult == -1) {
if (errno != EINTR) { if (errno != EINTR) {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "Lost connection to server.");
"Lost connection to server.");
return; return;
} }
} }
} }
nlog(LOG_NORMAL, LOG_CORE, "hu, how did we get here"); nlog (LOG_NORMAL, LOG_CORE, "hu, how did we get here");
} }
extern int getmaxsock() extern int
getmaxsock ()
{ {
struct rlimit *lim; struct rlimit *lim;
int ret; int ret;
lim = malloc(sizeof(struct rlimit)); lim = malloc (sizeof (struct rlimit));
getrlimit(RLIMIT_NOFILE, lim); getrlimit (RLIMIT_NOFILE, lim);
ret = lim->rlim_max; ret = lim->rlim_max;
free(lim); free (lim);
return ret; return ret;
} }
void recvlog(char *line) void
recvlog (char *line)
{ {
FILE *logfile; FILE *logfile;
if ((logfile = fopen("logs/recv.log", "a")) == NULL) if ((logfile = fopen ("logs/recv.log", "a")) == NULL)
return; return;
if (logfile) if (logfile)
fprintf(logfile, "%s", line); fprintf (logfile, "%s", line);
fclose(logfile); fclose (logfile);
} }
#if 0 #if 0
void log(char *fmt, ...) void
log (char *fmt, ...)
{ {
va_list ap; va_list ap;
FILE *logfile; FILE *logfile;
char buf[512], fmtime[80]; char buf[512], fmtime[80];
time_t tmp = time(NULL); time_t tmp = time (NULL);
va_start(ap, fmt); va_start (ap, fmt);
vsnprintf(buf, 512, fmt, ap); vsnprintf (buf, 512, fmt, ap);
strftime(fmtime, 80, "%H:%M[%m/%d/%Y]", localtime(&tmp)); strftime (fmtime, 80, "%H:%M[%m/%d/%Y]", localtime (&tmp));
if ((logfile = fopen("logs/neostats.log", "a")) == NULL) if ((logfile = fopen ("logs/neostats.log", "a")) == NULL)
return; return;
if (logfile) if (logfile)
fprintf(logfile, "(%s) %s\n", fmtime, buf); fprintf (logfile, "(%s) %s\n", fmtime, buf);
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "(%s) %s\n", fmtime, buf); fprintf (stderr, "(%s) %s\n", fmtime, buf);
#endif #endif
fclose(logfile); fclose (logfile);
va_end(ap); va_end (ap);
} }
#endif #endif
char *sctime(time_t stuff) char *
sctime (time_t stuff)
{ {
char *s, *c; char *s, *c;
s = ctime(&stuff); s = ctime (&stuff);
if ((c = strchr(s, '\n'))) if ((c = strchr (s, '\n')))
*c = '\0'; *c = '\0';
return s; return s;
@ -328,119 +275,112 @@ char *sctime(time_t stuff)
char fmtime[80]; char fmtime[80];
char *sftime(time_t stuff) char *
sftime (time_t stuff)
{ {
struct tm *ltm = localtime(&stuff); struct tm *ltm = localtime (&stuff);
strftime(fmtime, 80, "[%b (%a %d) %Y %I:%M [%p/%Z]]", ltm); strftime (fmtime, 80, "[%b (%a %d) %Y %I:%M [%p/%Z]]", ltm);
return fmtime; return fmtime;
} }
int sock_connect(int socktype, unsigned long ipaddr, int port, int
char *sockname, char *module, char *func_read, sock_connect (int socktype, unsigned long ipaddr, int port, char *sockname, char *module, char *func_read, char *func_write, char *func_error)
char *func_write, char *func_error)
{ {
struct sockaddr_in sa; struct sockaddr_in sa;
int s; int s;
int i; int i;
/* socktype = SOCK_STREAM */ /* socktype = SOCK_STREAM */
if ((s = socket(AF_INET, socktype, 0)) < 0) if ((s = socket (AF_INET, socktype, 0)) < 0)
return (-1); return (-1);
/* bind to a IP address */ /* bind to a IP address */
if (dobind > 0) { if (dobind > 0) {
if (bind(s, (struct sockaddr *) &lsa, sizeof(lsa)) < 0) { if (bind (s, (struct sockaddr *) &lsa, sizeof (lsa)) < 0) {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "sock_connect(): Warning, Couldn't bind to IP address %s", strerror (errno));
"sock_connect(): Warning, Couldn't bind to IP address %s",
strerror(errno));
} }
} }
bzero(&sa, sizeof(sa)); bzero (&sa, sizeof (sa));
sa.sin_family = AF_INET; sa.sin_family = AF_INET;
sa.sin_port = htons(port); sa.sin_port = htons (port);
sa.sin_addr.s_addr = ipaddr; sa.sin_addr.s_addr = ipaddr;
/* set non blocking */ /* set non blocking */
if ((i = fcntl(s, F_SETFL, O_NONBLOCK)) < 0) { if ((i = fcntl (s, F_SETFL, O_NONBLOCK)) < 0) {
nlog(LOG_CRITICAL, LOG_CORE, nlog (LOG_CRITICAL, LOG_CORE, "can't set socket %s(%s) non-blocking: %s", sockname, module, strerror (i));
"can't set socket %s(%s) non-blocking: %s", sockname,
module, strerror(i));
return (-1); return (-1);
} }
if ((i = connect(s, (struct sockaddr *) &sa, sizeof(sa))) < 0) { if ((i = connect (s, (struct sockaddr *) &sa, sizeof (sa))) < 0) {
switch (errno) { switch (errno) {
case EINPROGRESS: case EINPROGRESS:
break; break;
default: default:
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "Socket %s(%s) cant connect %s", sockname, module, strerror (errno), i);
"Socket %s(%s) cant connect %s", sockname, close (s);
module, strerror(errno), i);
close(s);
return (-1); return (-1);
} }
} }
add_socket(func_read, func_write, func_error, sockname, s, module); add_socket (func_read, func_write, func_error, sockname, s, module);
return s; return s;
} }
int sock_disconnect(char *sockname) int
sock_disconnect (char *sockname)
{ {
Sock_List *sock; Sock_List *sock;
fd_set fds; fd_set fds;
struct timeval tv; struct timeval tv;
int i; int i;
sock = findsock(sockname); sock = findsock (sockname);
if (!sock) { if (!sock) {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "Warning, Can not find Socket %s in list", sockname);
"Warning, Can not find Socket %s in list", sockname);
return (-1); return (-1);
} }
/* the following code makes sure its a valid file descriptor */ /* the following code makes sure its a valid file descriptor */
FD_ZERO(&fds); FD_ZERO (&fds);
FD_SET(sock->sock_no, &fds); FD_SET (sock->sock_no, &fds);
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = 0; tv.tv_usec = 0;
i = select(1, &fds, NULL, NULL, &tv); i = select (1, &fds, NULL, NULL, &tv);
if (!i && errno == EBADF) { if (!i && errno == EBADF) {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "Warning, Bad File Descriptor %s in list", sockname);
"Warning, Bad File Descriptor %s in list", sockname);
return (-1); return (-1);
} }
nlog(LOG_DEBUG3, LOG_CORE, "Closing Socket %s with Number %d", nlog (LOG_DEBUG3, LOG_CORE, "Closing Socket %s with Number %d", sockname, sock->sock_no);
sockname, sock->sock_no); close (sock->sock_no);
close(sock->sock_no); del_socket (sockname);
del_socket(sockname);
return (1); return (1);
} }
void sts(char *fmt, ...) void
sts (char *fmt, ...)
{ {
va_list ap; va_list ap;
char buf[512]; char buf[512];
int sent; int sent;
va_start(ap, fmt); va_start (ap, fmt);
vsnprintf(buf, 512, fmt, ap); vsnprintf (buf, 512, fmt, ap);
nlog(LOG_DEBUG2, LOG_CORE, "SENT: %s", buf); nlog (LOG_DEBUG2, LOG_CORE, "SENT: %s", buf);
strcat(buf, "\n"); strcat (buf, "\n");
sent = write(servsock, buf, strlen(buf)); sent = write (servsock, buf, strlen (buf));
if (sent == -1) { if (sent == -1) {
nlog(LOG_CRITICAL, LOG_CORE, "Write error."); nlog (LOG_CRITICAL, LOG_CORE, "Write error.");
do_exit(0); do_exit (0);
} }
me.SendM++; me.SendM++;
me.SendBytes = me.SendBytes + sent; me.SendBytes = me.SendBytes + sent;
va_end(ap); va_end (ap);
} }

4
sock.h
View file

@ -20,14 +20,14 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: sock.h,v 1.1 2003/06/26 05:25:09 fishwaldo Exp $ ** $Id: sock.h,v 1.2 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
#ifndef SOCK_H #ifndef SOCK_H
#define SOCK_H #define SOCK_H
void sts(char *fmt, ...); void sts (char *fmt, ...);
#endif #endif

171
stats.h
View file

@ -20,7 +20,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: stats.h,v 1.88 2003/07/23 10:35:47 fishwaldo Exp $ ** $Id: stats.h,v 1.89 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
#ifndef STATS_H #ifndef STATS_H
@ -179,6 +179,7 @@ struct me {
long RcveM; long RcveM;
long RcveBytes; long RcveBytes;
time_t lastmsg; time_t lastmsg;
int pingtime;
} me; } me;
@ -256,84 +257,81 @@ struct ping {
/* sock.c */ /* sock.c */
extern int ConnectTo(char *, int); extern int ConnectTo (char *, int);
extern void read_loop(); extern void read_loop ();
extern void ResetLogs(); extern void ResetLogs ();
extern char *sctime(time_t); extern char *sctime (time_t);
extern char *sftime(time_t); extern char *sftime (time_t);
extern int getmaxsock(); extern int getmaxsock ();
extern int sock_connect(int socktype, unsigned long ipaddr, int port, extern int sock_connect (int socktype, unsigned long ipaddr, int port, char *sockname, char *module, char *func_read, char *func_write, char *func_error);
char *sockname, char *module, char *func_read, extern int sock_disconnect (char *sockname);
char *func_write, char *func_error);
extern int sock_disconnect(char *sockname);
/* conf.c */ /* conf.c */
extern void strip(char *); extern void strip (char *);
extern void ConfLoad(); extern void ConfLoad ();
extern void rehash(); extern void rehash ();
extern int init_modules(); extern int init_modules ();
/* main.c */ /* main.c */
extern void login(); extern void login ();
/* extern void init_statserv(); */ /* extern void init_statserv(); */
extern void init_spam(); extern void init_spam ();
extern void init_ServBot(); extern void init_ServBot ();
extern void *smalloc(long); extern void *smalloc (long);
extern char *sstrdup(const char *); extern char *sstrdup (const char *);
extern unsigned long HASH(const unsigned char *, int); extern unsigned long HASH (const unsigned char *, int);
extern char *strlower(char *); extern char *strlower (char *);
extern void AddStringToList(char ***List, char S[], int *C); extern void AddStringToList (char ***List, char S[], int *C);
void FreeList(char **List, int C); void FreeList (char **List, int C);
void do_exit(int); void do_exit (int);
/* ircd.c */ /* ircd.c */
extern void parse(); extern void parse ();
extern char *joinbuf(char **av, int ac, int from); extern char *joinbuf (char **av, int ac, int from);
extern int split_buf(char *buf, char ***argv, int colon_special); extern int split_buf (char *buf, char ***argv, int colon_special);
extern void prefmsg(char *, const char *, char *, ...); extern void prefmsg (char *, const char *, char *, ...);
extern void privmsg(char *, const char *, char *, ...); extern void privmsg (char *, const char *, char *, ...);
extern void notice(char *, const char *, char *, ...); extern void notice (char *, const char *, char *, ...);
extern void privmsg_list(char *, char *, const char **); extern void privmsg_list (char *, char *, const char **);
extern void globops(char *, char *, ...); extern void globops (char *, char *, ...);
extern int flood(User *); extern int flood (User *);
extern int init_bot(char *, char *, char *, char *, char *, char *); extern int init_bot (char *, char *, char *, char *, char *, char *);
extern int del_bot(char *, char *); extern int del_bot (char *, char *);
extern void Module_Event(char *, char **av, int ac); extern void Module_Event (char *, char **av, int ac);
extern int bot_nick_change(char *, char *); extern int bot_nick_change (char *, char *);
/* timer.c */ /* timer.c */
extern void chk(); extern void chk ();
extern void TimerReset(); extern void TimerReset ();
extern void TimerSpam(); extern void TimerSpam ();
extern void TimerPings(); extern void TimerPings ();
extern void TimerMidnight(); extern void TimerMidnight ();
extern int is_midnight(); extern int is_midnight ();
extern MyUser *myuhead; extern MyUser *myuhead;
extern void AddUser(const char *, const char *, const char *, const char *, extern void AddUser (const char *, const char *, const char *, const char *, const unsigned long ip, const unsigned long TS);
const unsigned long ip, const unsigned long TS); extern void DelUser (const char *);
extern void DelUser(const char *); void AddRealName (const char *, const char *);
void AddRealName(const char *, const char *); extern void Change_User (User *, const char *);
extern void Change_User(User *, const char *); extern void sendcoders (char *message, ...);
extern void sendcoders(char *message, ...); extern User *finduser (const char *);
extern User *finduser(const char *); extern void UserDump (char *);
extern void UserDump(char *); extern void part_u_chan (list_t *, lnode_t *, void *);
extern void part_u_chan(list_t *, lnode_t *, void *); extern void UserMode (const char *, const char *, int);
extern void UserMode(const char *, const char *, int); extern void init_user_hash ();
extern void init_user_hash(); extern void init_chan_hash ();
extern void init_chan_hash(); extern void AddServer (char *, char *, int);
extern void AddServer(char *, char *, int); extern void DelServer (char *);
extern void DelServer(char *); extern Server *findserver (const char *);
extern Server *findserver(const char *); extern void ServerDump ();
extern void ServerDump(); extern void ChanDump ();
extern void ChanDump(); extern void init_server_hash ();
extern void init_server_hash(); extern void LoadMyUsers ();
extern void LoadMyUsers(); extern void SaveMyUsers ();
extern void SaveMyUsers(); extern void DeleteMyUser (char *);
extern void DeleteMyUser(char *); extern MyUser *findmyuser (char *);
extern MyUser *findmyuser(char *); extern int UserLevel (User *);
extern int UserLevel(User *); void Do_Away (User *, const char *);
void Do_Away(User *, const char *);
void KillUser (const char *nick); void KillUser (const char *nick);
@ -361,30 +359,27 @@ extern const char *ns_level_help[];
/* services.c */ /* services.c */
extern void servicesbot(char *nick, char **av, int ac); extern void servicesbot (char *nick, char **av, int ac);
extern void ns_debug_to_coders(char *); extern void ns_debug_to_coders (char *);
extern void ns_shutdown(User *, char *); extern void ns_shutdown (User *, char *);
/* chans.c */ /* chans.c */
extern void chandump(char *chan); extern void chandump (char *chan);
extern void part_chan(User * u, char *chan); extern void part_chan (User * u, char *chan);
extern void join_chan(User * u, char *chan); extern void join_chan (User * u, char *chan);
extern void change_user_nick(Chans * c, char *newnick, char *oldnick); extern void change_user_nick (Chans * c, char *newnick, char *oldnick);
extern Chans *findchan(char *chan); extern Chans *findchan (char *chan);
extern int ChanMode(char *origin, char **av, int ac); extern int ChanMode (char *origin, char **av, int ac);
extern void Change_Topic(char *, Chans *, time_t t, char *); extern void Change_Topic (char *, Chans *, time_t t, char *);
extern void ChangeChanUserMode(Chans * c, User * u, int add, long mode); extern void ChangeChanUserMode (Chans * c, User * u, int add, long mode);
void kick_chan(User *, char *, User *); void kick_chan (User *, char *, User *);
void Change_Chan_Ts(Chans *c, time_t tstime); void Change_Chan_Ts (Chans * c, time_t tstime);
extern int CheckChanMode(Chans *c, long mode); extern int CheckChanMode (Chans * c, long mode);
/* dns.c */ /* dns.c */
extern int dns_lookup(char *str, adns_rrtype type, extern int dns_lookup (char *str, adns_rrtype type, void (*callback) (char *data, adns_answer * a), char *data);
void (*callback) (char *data, adns_answer * a), extern int init_dns ();
char *data); extern void do_dns ();
extern int init_dns();
extern void do_dns();
#endif #endif

92
timer.c
View file

@ -20,7 +20,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: timer.c,v 1.24 2003/06/13 13:11:49 fishwaldo Exp $ ** $Id: timer.c,v 1.25 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
#include "stats.h" #include "stats.h"
@ -33,68 +33,69 @@ static time_t last_cache_save;
static int midnight = 0; static int midnight = 0;
void chk() void
chk ()
{ {
Mod_Timer *mod_ptr = NULL; Mod_Timer *mod_ptr = NULL;
time_t current = time(NULL); time_t current = time (NULL);
hscan_t ts; hscan_t ts;
hnode_t *tn; hnode_t *tn;
strcpy(segv_location, "chk");
/* First, lets see if any modules have a function that is due to run..... */ /* First, lets see if any modules have a function that is due to run..... */
hash_scan_begin(&ts, th); hash_scan_begin (&ts, th);
while ((tn = hash_scan_next(&ts)) != NULL) { while ((tn = hash_scan_next (&ts)) != NULL) {
mod_ptr = hnode_get(tn); strcpy (segv_location, "chk");
mod_ptr = hnode_get (tn);
if (current - mod_ptr->lastrun > mod_ptr->interval) { if (current - mod_ptr->lastrun > mod_ptr->interval) {
strcpy(segv_location, mod_ptr->modname); strcpy (segv_location, mod_ptr->modname);
strcpy(segvinmodule, mod_ptr->modname); strcpy (segvinmodule, mod_ptr->modname);
if (setjmp(sigvbuf) == 0) { if (setjmp (sigvbuf) == 0) {
mod_ptr->function(); if (mod_ptr->function () < 0) {
mod_ptr->lastrun = (int) time(NULL); nlog(LOG_DEBUG2, LOG_CORE, "Deleting Timer %s for Module %s as requested", mod_ptr->timername, mod_ptr->modname);
hash_scan_delete(th, tn);
hnode_destroy(tn);
free(mod_ptr);
} else {
mod_ptr->lastrun = (int) time (NULL);
}
} else { } else {
nlog(LOG_CRITICAL, LOG_CORE, nlog (LOG_CRITICAL, LOG_CORE, "setjmp() Failed, Can't call Module %s\n", mod_ptr->modname);
"setjmp() Failed, Can't call Module %s\n",
mod_ptr->modname);
} }
strcpy(segvinmodule, ""); strcpy (segvinmodule, "");
strcpy(segv_location, "Module_Event_Return");
} }
} }
if (current - ping.last_sent > 60) { if (current - ping.last_sent > me.pingtime) {
TimerPings(); TimerPings ();
ping.last_sent = time(NULL); ping.last_sent = time (NULL);
if (hash_verify(sockh) == 0) { if (hash_verify (sockh) == 0) {
nlog(LOG_CRITICAL, LOG_CORE, nlog (LOG_CRITICAL, LOG_CORE, "Eeeek, Corruption of the socket hash");
"Eeeek, Corruption of the socket hash");
} }
if (hash_verify(mh) == 0) { if (hash_verify (mh) == 0) {
nlog(LOG_CRITICAL, LOG_CORE, nlog (LOG_CRITICAL, LOG_CORE, "Eeeek, Corruption of the Module hash");
"Eeeek, Corruption of the Module hash");
} }
if (hash_verify(bh) == 0) { if (hash_verify (bh) == 0) {
nlog(LOG_CRITICAL, LOG_CORE, nlog (LOG_CRITICAL, LOG_CORE, "Eeeek, Corruption of the Bot hash");
"Eeeek, Corruption of the Bot hash");
} }
if (hash_verify(th) == 0) { if (hash_verify (th) == 0) {
nlog(LOG_CRITICAL, LOG_CORE, nlog (LOG_CRITICAL, LOG_CORE, "Eeeek, Corruption of the Timer hash");
"Eeeek, Corruption of the Timer hash");
} }
/* flush log files */ /* flush log files */
fflush(NULL); fflush (NULL);
} }
if (is_midnight() == 1 && midnight == 0) { if (is_midnight () == 1 && midnight == 0) {
TimerMidnight(); TimerMidnight ();
midnight = 1; midnight = 1;
} else { } else {
if (midnight == 1 && is_midnight() == 0) if (midnight == 1 && is_midnight () == 0)
midnight = 0; midnight = 0;
} }
} }
void TimerReset() void
TimerReset ()
{ {
time_t current = time(NULL); time_t current = time (NULL);
last_stats_save = current; last_stats_save = current;
last_lag_check = current; last_lag_check = current;
last_cache_save = current; last_cache_save = current;
@ -104,17 +105,18 @@ void TimerReset()
void TimerMidnight() void
TimerMidnight ()
{ {
nlog(LOG_DEBUG1, LOG_CORE, "Its midnight!!! -> %s", nlog (LOG_DEBUG1, LOG_CORE, "Its midnight!!! -> %s", sctime (time (NULL)));
sctime(time(NULL))); ResetLogs ();
ResetLogs();
} }
int is_midnight() int
is_midnight ()
{ {
time_t current = time(NULL); time_t current = time (NULL);
struct tm *ltm = localtime(&current); struct tm *ltm = localtime (&current);
if (ltm->tm_hour == 0) if (ltm->tm_hour == 0)
return 1; return 1;

345
users.c
View file

@ -22,7 +22,7 @@
** USA ** USA
** **
** NeoStats CVS Identification ** NeoStats CVS Identification
** $Id: users.c,v 1.57 2003/07/17 15:00:13 fishwaldo Exp $ ** $Id: users.c,v 1.58 2003/07/30 13:58:22 fishwaldo Exp $
*/ */
#include <fnmatch.h> #include <fnmatch.h>
@ -34,8 +34,8 @@
int fnmatch(const char *, const char *, int flags); int fnmatch (const char *, const char *, int flags);
void doDelUser(const char *, int); void doDelUser (const char *, int);
@ -44,55 +44,51 @@ void doDelUser(const char *, int);
MyUser *myuhead; MyUser *myuhead;
static User *new_user(const char *); static User *new_user (const char *);
User *new_user(const char *nick) User *
new_user (const char *nick)
{ {
User *u; User *u;
hnode_t *un; hnode_t *un;
strcpy(segv_location, "new_user"); strcpy (segv_location, "new_user");
u = smalloc(sizeof(User)); u = smalloc (sizeof (User));
if (!nick) if (!nick)
nick = ""; nick = "";
memcpy(u->nick, nick, MAXNICK); memcpy (u->nick, nick, MAXNICK);
un = hnode_create(u); un = hnode_create (u);
if (hash_isfull(uh)) { if (hash_isfull (uh)) {
nlog(LOG_CRITICAL, LOG_CORE, "Eeeek, Hash is full"); nlog (LOG_CRITICAL, LOG_CORE, "Eeeek, Hash is full");
} else { } else {
hash_insert(uh, un, u->nick); hash_insert (uh, un, u->nick);
} }
return (u); return (u);
} }
void AddUser(const char *nick, const char *user, const char *host, void
const char *server, const unsigned long ipaddr, AddUser (const char *nick, const char *user, const char *host, const char *server, const unsigned long ipaddr, const unsigned long TS)
const unsigned long TS)
{ {
User *u; User *u;
nlog(LOG_DEBUG2, LOG_CORE, nlog (LOG_DEBUG2, LOG_CORE, "AddUser(): %s (%s@%s)(%lu) -> %s at %lu", nick, user, host, htonl (ipaddr), server, TS);
"AddUser(): %s (%s@%s)(%lu) -> %s at %lu", nick, user, host, strcpy (segv_location, "AddUser");
htonl(ipaddr), server, TS); u = finduser (nick);
strcpy(segv_location, "AddUser");
u = finduser(nick);
if (u) { if (u) {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "trying to add a user that already exists? (%s)", nick);
"trying to add a user that already exists? (%s)",
nick);
return; return;
} }
u = new_user(nick); u = new_user (nick);
strncpy(u->hostname, host, MAXHOST); strncpy (u->hostname, host, MAXHOST);
strncpy(u->username, user, MAXUSER); strncpy (u->username, user, MAXUSER);
/* its empty for the moment */ /* its empty for the moment */
strncpy(u->realname, "", MAXREALNAME); strncpy (u->realname, "", MAXREALNAME);
u->server = findserver(server); u->server = findserver (server);
u->t_flood = time(NULL); u->t_flood = time (NULL);
u->flood = 0; u->flood = 0;
u->is_away = 0; u->is_away = 0;
u->myuser = NULL; u->myuser = NULL;
@ -100,105 +96,115 @@ void AddUser(const char *nick, const char *user, const char *host,
#ifdef ULTIMATE3 #ifdef ULTIMATE3
u->Smode = 0; u->Smode = 0;
#endif #endif
u->chans = list_create(MAXJOINCHANS); u->chans = list_create (MAXJOINCHANS);
strcpy(u->modes, ""); strcpy (u->modes, "");
u->ipaddr.s_addr = htonl(ipaddr); u->ipaddr.s_addr = htonl (ipaddr);
u->TS = TS; u->TS = TS;
} }
void AddRealName(const char *nick, const char *realname)
void
AddRealName (const char *nick, const char *realname)
{ {
char **av; char **av;
int ac = 0; int ac = 0;
User *u = finduser(nick); User *u = finduser (nick);
if (!u) { if (!u) {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "Warning, Can not find User %s for Realname", nick);
"Warning, Can not find User %s for Realname", nick);
return; return;
} }
nlog(LOG_DEBUG2, LOG_CORE, "RealName(%s): %s", nick, realname); nlog (LOG_DEBUG2, LOG_CORE, "RealName(%s): %s", nick, realname);
strncpy(u->realname, realname, MAXREALNAME); strncpy (u->realname, realname, MAXREALNAME);
AddStringToList(&av, u->nick, &ac); AddStringToList (&av, u->nick, &ac);
Module_Event("SIGNON", av, ac); Module_Event ("SIGNON", av, ac);
free(av); free (av);
} }
void part_u_chan(list_t * list, lnode_t * node, void *v) void
part_u_chan (list_t * list, lnode_t * node, void *v)
{ {
User *u = v; User *u = v;
part_chan(u, lnode_get(node)); part_chan (u, lnode_get (node));
} }
void KillUser(const char *nick)
void
KillUser (const char *nick)
{ {
doDelUser(nick, 1); doDelUser (nick, 1);
} }
void DelUser(const char *nick)
void
DelUser (const char *nick)
{ {
doDelUser(nick, 0); doDelUser (nick, 0);
} }
void doDelUser(const char *nick, int i)
void
doDelUser (const char *nick, int i)
{ {
User *u; User *u;
hnode_t *un; hnode_t *un;
char **av; char **av;
int ac = 0; int ac = 0;
strcpy(segv_location, "DelUser"); strcpy (segv_location, "DelUser");
nlog(LOG_DEBUG2, LOG_CORE, "DelUser(%s)", nick); nlog (LOG_DEBUG2, LOG_CORE, "DelUser(%s)", nick);
un = hash_lookup(uh, nick); un = hash_lookup (uh, nick);
if (!un) { if (!un) {
nlog(LOG_WARNING, LOG_CORE, "DelUser(%s) failed!", nick); nlog (LOG_WARNING, LOG_CORE, "DelUser(%s) failed!", nick);
return; return;
} }
u = hnode_get(un); u = hnode_get (un);
list_process(u->chans, u, part_u_chan); list_process (u->chans, u, part_u_chan);
/* run the event to delete a user */ /* run the event to delete a user */
AddStringToList(&av, u->nick, &ac); AddStringToList (&av, u->nick, &ac);
if (i == 0) { if (i == 0) {
Module_Event("SIGNOFF", av, ac); Module_Event ("SIGNOFF", av, ac);
} else if (i == 1) { } else if (i == 1) {
Module_Event("KILL", av, ac); Module_Event ("KILL", av, ac);
} }
free(av); free (av);
/* if its one of our bots, remove it from the modlist */ /* if its one of our bots, remove it from the modlist */
if (findbot(u->nick)) { if (findbot (u->nick)) {
if (i == 1) if (i == 1)
nlog(LOG_NOTICE, LOG_CORE, "Deleting Bot %s as it was killed", u->nick); nlog (LOG_NOTICE, LOG_CORE, "Deleting Bot %s as it was killed", u->nick);
del_mod_user(u->nick); del_mod_user (u->nick);
} }
hash_delete(uh, un); hash_delete (uh, un);
hnode_destroy(un); hnode_destroy (un);
list_destroy(u->chans); list_destroy (u->chans);
free(u); free (u);
} }
void Do_Away(User * u, const char *awaymsg) void
Do_Away (User * u, const char *awaymsg)
{ {
char **av; char **av;
int ac = 0; int ac = 0;
if (u) { if (u) {
AddStringToList(&av, u->nick, &ac); AddStringToList (&av, u->nick, &ac);
if ((u->is_away == 1) && (!awaymsg)) { if ((u->is_away == 1) && (!awaymsg)) {
u->is_away = 0; u->is_away = 0;
Module_Event("AWAY", av, ac); Module_Event ("AWAY", av, ac);
} else if ((u->is_away == 0) && (awaymsg)) { } else if ((u->is_away == 0) && (awaymsg)) {
u->is_away = 1; u->is_away = 1;
AddStringToList(&av, (char *) awaymsg, &ac); AddStringToList (&av, (char *) awaymsg, &ac);
Module_Event("AWAY", av, ac); Module_Event ("AWAY", av, ac);
} }
free(av); free (av);
} }
} }
void Change_User(User * u, const char *newnick) void
Change_User (User * u, const char *newnick)
{ {
hnode_t *un; hnode_t *un;
lnode_t *cm; lnode_t *cm;
@ -206,153 +212,150 @@ void Change_User(User * u, const char *newnick)
int ac = 0; int ac = 0;
char *oldnick; char *oldnick;
strcpy(segv_location, "Change_User"); strcpy (segv_location, "Change_User");
nlog(LOG_DEBUG2, LOG_CORE, "Change_User(%s, %s)", u->nick, nlog (LOG_DEBUG2, LOG_CORE, "Change_User(%s, %s)", u->nick, newnick);
newnick); un = hash_lookup (uh, u->nick);
un = hash_lookup(uh, u->nick);
if (!un) { if (!un) {
nlog(LOG_WARNING, LOG_CORE, "ChangeUser(%s) Failed!", nlog (LOG_WARNING, LOG_CORE, "ChangeUser(%s) Failed!", u->nick);
u->nick);
return; return;
} }
cm = list_first(u->chans); cm = list_first (u->chans);
while (cm) { while (cm) {
change_user_nick(findchan(lnode_get(cm)), (char *) newnick, change_user_nick (findchan (lnode_get (cm)), (char *) newnick, u->nick);
u->nick); cm = list_next (u->chans, cm);
cm = list_next(u->chans, cm);
} }
strcpy(segv_location, "Change_User_Return"); strcpy (segv_location, "Change_User_Return");
hash_delete(uh, un); hash_delete (uh, un);
oldnick = malloc(MAXNICK); oldnick = malloc (MAXNICK);
strncpy(oldnick, u->nick, MAXNICK); strncpy (oldnick, u->nick, MAXNICK);
AddStringToList(&av, oldnick, &ac); AddStringToList (&av, oldnick, &ac);
strncpy(u->nick, newnick, MAXNICK); strncpy (u->nick, newnick, MAXNICK);
hash_insert(uh, un, u->nick); hash_insert (uh, un, u->nick);
AddStringToList(&av, u->nick, &ac); AddStringToList (&av, u->nick, &ac);
Module_Event("NICK_CHANGE", av, ac); Module_Event ("NICK_CHANGE", av, ac);
free(av); free (av);
free(oldnick); free (oldnick);
} }
void sendcoders(char *message, ...)
void
sendcoders (char *message, ...)
{ {
va_list ap; va_list ap;
char tmp[512]; char tmp[512];
strcpy(segv_location, "sendcoders"); strcpy (segv_location, "sendcoders");
va_start(ap, message); va_start (ap, message);
vsnprintf(tmp, 512, message, ap); vsnprintf (tmp, 512, message, ap);
#ifndef DEBUG #ifndef DEBUG
if (!me.coder_debug) if (!me.coder_debug)
return; return;
#endif #endif
chanalert(s_Services, tmp); chanalert (s_Services, tmp);
va_end(ap); va_end (ap);
} }
User *finduser(const char *nick) User *
finduser (const char *nick)
{ {
User *u; User *u;
hnode_t *un; hnode_t *un;
strcpy(segv_location, "finduser"); strcpy (segv_location, "finduser");
un = hash_lookup(uh, nick); un = hash_lookup (uh, nick);
if (un != NULL) { if (un != NULL) {
u = hnode_get(un); u = hnode_get (un);
return u; return u;
} else { } else {
nlog(LOG_DEBUG2, LOG_CORE, "FindUser(%s) -> NOTFOUND", nlog (LOG_DEBUG2, LOG_CORE, "FindUser(%s) -> NOTFOUND", nick);
nick);
return NULL; return NULL;
} }
} }
void init_user_hash() void
init_user_hash ()
{ {
uh = hash_create(U_TABLE_SIZE, 0, 0); uh = hash_create (U_TABLE_SIZE, 0, 0);
} }
void UserDump(char *nick) void
UserDump (char *nick)
{ {
User *u; User *u;
hnode_t *un; hnode_t *un;
lnode_t *cm; lnode_t *cm;
hscan_t us; hscan_t us;
strcpy(segv_location, "UserDump"); strcpy (segv_location, "UserDump");
if (!nick) { if (!nick) {
sendcoders("Users======================"); sendcoders ("Users======================");
hash_scan_begin(&us, uh); hash_scan_begin (&us, uh);
while ((un = hash_scan_next(&us)) != NULL) { while ((un = hash_scan_next (&us)) != NULL) {
u = hnode_get(un); u = hnode_get (un);
sendcoders("User: %s", u->nick); sendcoders ("User: %s", u->nick);
cm = list_first(u->chans); cm = list_first (u->chans);
while (cm) { while (cm) {
sendcoders(" Chans: %s", sendcoders (" Chans: %s", (char *) lnode_get (cm));
(char *) lnode_get(cm)); cm = list_next (u->chans, cm);
cm = list_next(u->chans, cm);
} }
} }
} else { } else {
un = hash_lookup(uh, nick); un = hash_lookup (uh, nick);
if (un) { if (un) {
u = hnode_get(un); u = hnode_get (un);
sendcoders("User: %s", u->nick); sendcoders ("User: %s", u->nick);
cm = list_first(u->chans); cm = list_first (u->chans);
while (cm) { while (cm) {
sendcoders(" Chans: %s", sendcoders (" Chans: %s", (char *) lnode_get (cm));
(char *) lnode_get(cm)); cm = list_next (u->chans, cm);
cm = list_next(u->chans, cm);
} }
} else { } else {
sendcoders("Can't find user %s", nick); sendcoders ("Can't find user %s", nick);
} }
} }
} }
int UserLevel(User * u) int
UserLevel (User * u)
{ {
int i, tmplvl = 0; int i, tmplvl = 0;
#ifdef EXTAUTH #ifdef EXTAUTH
int (*getauth) (User *, int curlvl); int (*getauth) (User *, int curlvl);
#endif #endif
strcpy(segv_location, "UserLevel"); strcpy (segv_location, "UserLevel");
for (i = 0; i < ((sizeof(usr_mds) / sizeof(usr_mds[0])) - 1); i++) { for (i = 0; i < ((sizeof (usr_mds) / sizeof (usr_mds[0])) - 1); i++) {
if (u->Umode & usr_mds[i].umodes) { if (u->Umode & usr_mds[i].umodes) {
if (usr_mds[i].level > tmplvl) if (usr_mds[i].level > tmplvl)
tmplvl = usr_mds[i].level; tmplvl = usr_mds[i].level;
} }
} }
nlog(LOG_DEBUG1, LOG_CORE, "Umode Level for %s is %d", u->nick, nlog (LOG_DEBUG1, LOG_CORE, "Umode Level for %s is %d", u->nick, tmplvl);
tmplvl);
/* I hate SMODEs damn it */ /* I hate SMODEs damn it */
#ifdef ULTIMATE3 #ifdef ULTIMATE3
for (i = 0; i < ((sizeof(susr_mds) / sizeof(susr_mds[0])) - 1); for (i = 0; i < ((sizeof (susr_mds) / sizeof (susr_mds[0])) - 1); i++) {
i++) {
if (u->Smode & susr_mds[i].umodes) { if (u->Smode & susr_mds[i].umodes) {
if (susr_mds[i].level > tmplvl) if (susr_mds[i].level > tmplvl)
tmplvl = susr_mds[i].level; tmplvl = susr_mds[i].level;
} }
} }
#endif #endif
nlog(LOG_DEBUG1, LOG_CORE, "Smode Level for %s is %d", u->nick, nlog (LOG_DEBUG1, LOG_CORE, "Smode Level for %s is %d", u->nick, tmplvl);
tmplvl);
#ifdef DEBUG #ifdef DEBUG
#ifdef CODERHACK #ifdef CODERHACK
/* this is only cause I dun have the right O lines on some of my "Beta" Networks, so I need to hack this in :) */ /* this is only cause I dun have the right O lines on some of my "Beta" Networks, so I need to hack this in :) */
if (!strcasecmp(u->nick, "FISH")) if (!strcasecmp (u->nick, "FISH"))
tmplvl = 200; tmplvl = 200;
if (!strcasecmp(u->nick, "SHMAD")) if (!strcasecmp (u->nick, "SHMAD"))
tmplvl = 200; tmplvl = 200;
#endif #endif
#endif #endif
#ifdef EXTAUTH #ifdef EXTAUTH
i = get_dl_handle("extauth"); i = get_dl_handle ("extauth");
if (i > 0) { if (i > 0) {
getauth = dlsym((int *) i, "__do_auth"); getauth = dlsym ((int *) i, "__do_auth");
if (getauth) if (getauth)
i = (*getauth) (u, tmplvl); i = (*getauth) (u, tmplvl);
} }
@ -363,13 +366,13 @@ int UserLevel(User * u)
nlog(LOG_DEBUG1, LOG_CORE, "UserLevel for %s is %d (%d)", u->nick, nlog (LOG_DEBUG1, LOG_CORE, "UserLevel for %s is %d (%d)", u->nick, tmplvl, i);
tmplvl, i);
return tmplvl; return tmplvl;
} }
void UserMode(const char *nick, const char *modes, int smode) void
UserMode (const char *nick, const char *modes, int smode)
{ {
/* I don't know why, but I spent like 3 hours trying to make this function work and /* I don't know why, but I spent like 3 hours trying to make this function work and
I finally got it... what a waste of time... gah, oh well... basically, it sets both the User Flags, and also the User Levels.. I finally got it... what a waste of time... gah, oh well... basically, it sets both the User Flags, and also the User Levels..
@ -382,26 +385,24 @@ void UserMode(const char *nick, const char *modes, int smode)
char **av; char **av;
int ac = 0; int ac = 0;
strcpy(segv_location, "UserMode"); strcpy (segv_location, "UserMode");
u = finduser(nick); u = finduser (nick);
if (!u) { if (!u) {
nlog(LOG_WARNING, LOG_CORE, nlog (LOG_WARNING, LOG_CORE, "Warning, Changing Modes for a Unknown User %s!", nick);
"Warning, Changing Modes for a Unknown User %s!", nlog (LOG_DEBUG1, LOG_CORE, "Recbuf: %s", recbuf);
nick);
nlog(LOG_DEBUG1, LOG_CORE, "Recbuf: %s", recbuf);
return; return;
} }
/* support for Smodes */ /* support for Smodes */
if (smode > 0) if (smode > 0)
nlog(LOG_DEBUG1, LOG_CORE, "Smodes: %s", modes); nlog (LOG_DEBUG1, LOG_CORE, "Smodes: %s", modes);
else else
nlog(LOG_DEBUG1, LOG_CORE, "Modes: %s", modes); nlog (LOG_DEBUG1, LOG_CORE, "Modes: %s", modes);
if (smode == 0) if (smode == 0)
strncpy(u->modes, modes, MODESIZE); strncpy (u->modes, modes, MODESIZE);
AddStringToList(&av, u->nick, &ac); AddStringToList (&av, u->nick, &ac);
AddStringToList(&av, (char *) modes, &ac); AddStringToList (&av, (char *) modes, &ac);
tmpmode = *(modes); tmpmode = *(modes);
@ -415,39 +416,25 @@ void UserMode(const char *nick, const char *modes, int smode)
break; break;
default: default:
if (smode > 0) { if (smode > 0) {
for (i = 0; for (i = 0; i < ((sizeof (susr_mds) / sizeof (susr_mds[0])) - 1); i++) {
i <
((sizeof(susr_mds) /
sizeof(susr_mds[0])) - 1); i++) {
if (susr_mds[i].mode == tmpmode) { if (susr_mds[i].mode == tmpmode) {
if (add) { if (add) {
u->Smode |= u->Smode |= susr_mds[i].umodes;
susr_mds[i].
umodes;
break; break;
} else { } else {
u->Smode &= u->Smode &= ~susr_mds[i].umodes;
~susr_mds[i].
umodes;
break; break;
} }
} }
} }
} else { } else {
for (i = 0; for (i = 0; i < ((sizeof (usr_mds) / sizeof (usr_mds[0])) - 1); i++) {
i <
((sizeof(usr_mds) /
sizeof(usr_mds[0])) - 1); i++) {
if (usr_mds[i].mode == tmpmode) { if (usr_mds[i].mode == tmpmode) {
if (add) { if (add) {
u->Umode |= u->Umode |= usr_mds[i].umodes;
usr_mds[i].
umodes;
break; break;
} else { } else {
u->Umode &= u->Umode &= ~usr_mds[i].umodes;
~usr_mds[i].
umodes;
break; break;
} }
} }
@ -457,15 +444,13 @@ void UserMode(const char *nick, const char *modes, int smode)
tmpmode = *modes++; tmpmode = *modes++;
} }
if (smode > 0) { if (smode > 0) {
nlog(LOG_DEBUG1, LOG_CORE, "SMODE for %s is are now %p", nlog (LOG_DEBUG1, LOG_CORE, "SMODE for %s is are now %p", u->nick, u->Smode);
u->nick, u->Smode); Module_Event ("SMODE", av, ac);
Module_Event("SMODE", av, ac);
} else { } else {
nlog(LOG_DEBUG1, LOG_CORE, "Modes for %s are now %p", nlog (LOG_DEBUG1, LOG_CORE, "Modes for %s are now %p", u->nick, u->Umode);
u->nick, u->Umode); Module_Event ("UMODE", av, ac);
Module_Event("UMODE", av, ac);
} }
free(av); free (av);