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
**
** 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
#define BAHAMUT_H
@ -30,66 +30,66 @@
#define MSG_PRIVATE "PRIVMSG" /* PRIV */
#define MSG_WHO "WHO" /* WHO -> WHOC */
#define MSG_WHOIS "WHOIS" /* WHOI */
#define MSG_WHO "WHO" /* WHO -> WHOC */
#define MSG_WHOIS "WHOIS" /* WHOI */
#define MSG_WHOWAS "WHOWAS" /* WHOW */
#define MSG_USER "USER" /* USER */
#define MSG_NICK "NICK" /* NICK */
#define MSG_USER "USER" /* USER */
#define MSG_NICK "NICK" /* NICK */
#define MSG_SERVER "SERVER" /* SERV */
#define MSG_LIST "LIST" /* LIST */
#define MSG_TOPIC "TOPIC" /* TOPI */
#define MSG_LIST "LIST" /* LIST */
#define MSG_TOPIC "TOPIC" /* TOPI */
#define MSG_INVITE "INVITE" /* INVI */
#define MSG_VERSION "VERSION" /* VERS */
#define MSG_QUIT "QUIT" /* QUIT */
#define MSG_SQUIT "SQUIT" /* SQUI */
#define MSG_KILL "KILL" /* KILL */
#define MSG_INFO "INFO" /* INFO */
#define MSG_LINKS "LINKS" /* LINK */
#define MSG_WATCH "WATCH" /* WATCH */
#define MSG_STATS "STATS" /* STAT */
#define MSG_HELP "HELP" /* HELP */
#define MSG_QUIT "QUIT" /* QUIT */
#define MSG_SQUIT "SQUIT" /* SQUI */
#define MSG_KILL "KILL" /* KILL */
#define MSG_INFO "INFO" /* INFO */
#define MSG_LINKS "LINKS" /* LINK */
#define MSG_WATCH "WATCH" /* WATCH */
#define MSG_STATS "STATS" /* STAT */
#define MSG_HELP "HELP" /* HELP */
#define MSG_HELPOP "HELPOP" /* HELP */
#define MSG_ERROR "ERROR" /* ERRO */
#define MSG_AWAY "AWAY" /* AWAY */
#define MSG_ERROR "ERROR" /* ERRO */
#define MSG_AWAY "AWAY" /* AWAY */
#define MSG_CONNECT "CONNECT" /* CONN */
#define MSG_PING "PING" /* PING */
#define MSG_PONG "PONG" /* PONG */
#define MSG_OPER "OPER" /* OPER */
#define MSG_PASS "PASS" /* PASS */
#define MSG_PING "PING" /* PING */
#define MSG_PONG "PONG" /* PONG */
#define MSG_OPER "OPER" /* OPER */
#define MSG_PASS "PASS" /* PASS */
#define MSG_WALLOPS "WALLOPS" /* WALL */
#define MSG_TIME "TIME" /* TIME */
#define MSG_NAMES "NAMES" /* NAME */
#define MSG_ADMIN "ADMIN" /* ADMI */
#define MSG_TIME "TIME" /* TIME */
#define MSG_NAMES "NAMES" /* NAME */
#define MSG_ADMIN "ADMIN" /* ADMI */
#define MSG_NOTICE "NOTICE" /* NOTI */
#define MSG_JOIN "JOIN" /* JOIN */
#define MSG_PART "PART" /* PART */
#define MSG_JOIN "JOIN" /* JOIN */
#define MSG_PART "PART" /* PART */
#define MSG_LUSERS "LUSERS" /* LUSE */
#define MSG_MOTD "MOTD" /* MOTD */
#define MSG_MODE "MODE" /* MODE */
#define MSG_KICK "KICK" /* KICK */
#define MSG_MOTD "MOTD" /* MOTD */
#define MSG_MODE "MODE" /* MODE */
#define MSG_KICK "KICK" /* KICK */
#define MSG_SERVICE "SERVICE" /* SERV -> SRVI */
#define MSG_USERHOST "USERHOST" /* USER -> USRH */
#define MSG_ISON "ISON" /* ISON */
#define MSG_ISON "ISON" /* ISON */
#define MSG_SQUERY "SQUERY" /* SQUE */
#define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */
#define MSG_SERVSET "SERVSET" /* SERV -> SSET */
#define MSG_REHASH "REHASH" /* REHA */
#define MSG_RESTART "RESTART" /* REST */
#define MSG_CLOSE "CLOSE" /* CLOS */
#define MSG_DIE "DIE" /* DIE */
#define MSG_HASH "HASH" /* HASH */
#define MSG_DNS "DNS" /* DNS -> DNSS */
#define MSG_CLOSE "CLOSE" /* CLOS */
#define MSG_DIE "DIE" /* DIE */
#define MSG_HASH "HASH" /* HASH */
#define MSG_DNS "DNS" /* DNS -> DNSS */
#define MSG_SILENCE "SILENCE" /* SILE */
#define MSG_AKILL "AKILL" /* AKILL */
#define MSG_KLINE "KLINE" /* KLINE */
#define MSG_UNKLINE "UNKLINE" /* UNKLINE */
#define MSG_AKILL "AKILL" /* AKILL */
#define MSG_KLINE "KLINE" /* KLINE */
#define MSG_UNKLINE "UNKLINE" /* UNKLINE */
#define MSG_RAKILL "RAKILL" /* RAKILL */
#define MSG_GNOTICE "GNOTICE" /* GNOTICE */
#define MSG_GOPER "GOPER" /* GOPER */
#define MSG_GOPER "GOPER" /* GOPER */
#define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */
#define MSG_LOCOPS "LOCOPS" /* LOCOPS */
#define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */
#define MSG_TRACE "TRACE" /* TRAC */
#define MSG_TRACE "TRACE" /* TRAC */
#define MSG_SQLINE "SQLINE" /* SQLINE */
#define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */
#define MSG_SVSNICK "SVSNICK" /* SVSNICK */
@ -99,14 +99,14 @@
#define MSG_SVSMODE "SVSMODE" /* SVSMODE */
#define MSG_SAMODE "SAMODE" /* SAMODE */
#define MSG_CHATOPS "CHATOPS" /* CHATOPS */
#define MSG_HELPSERV "HELPSERV" /* HELPSERV */
#define MSG_ZLINE "ZLINE" /* ZLINE */
#define MSG_HELPSERV "HELPSERV" /* HELPSERV */
#define MSG_ZLINE "ZLINE" /* ZLINE */
#define MSG_UNZLINE "UNZLINE" /* UNZLINE */
#define MSG_NETINFO "NETINFO" /* NETINFO */
#define MSG_RULES "RULES" /* RULES */
#define MSG_MAP "MAP" /* MAP */
#define MSG_NETG "NETG" /* NETG */
#define MSG_ADCHAT "ADCHAT" /* Adchat */
#define MSG_RULES "RULES" /* RULES */
#define MSG_MAP "MAP" /* MAP */
#define MSG_NETG "NETG" /* NETG */
#define MSG_ADCHAT "ADCHAT" /* Adchat */
#define MSG_MAKEPASS "MAKEPASS" /* MAKEPASS */
#define MSG_ADDHUB "ADDHUB" /* ADDHUB */
#define MSG_DELHUB "DELHUB" /* DELHUB */
@ -116,28 +116,28 @@
#define MSG_DELOPER "DELOPER" /* DELOPER */
#define MSG_ADDQLINE "ADDQLINE" /* ADDQLINE */
#define MSG_DELQLINE "DELQLINE" /* DELQLINE */
#define MSG_GSOP "GSOP" /* GSOP */
#define MSG_ISOPER "ISOPER" /* ISOPER */
#define MSG_ADG "ADG" /* ADG */
#define MSG_NMON "NMON" /* NMON */
#define MSG_GSOP "GSOP" /* GSOP */
#define MSG_ISOPER "ISOPER" /* ISOPER */
#define MSG_ADG "ADG" /* ADG */
#define MSG_NMON "NMON" /* NMON */
#define MSG_DALINFO "DALINFO" /* DALnet Credits */
#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_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_STATSERV "STATSERV" /* StatServ */
#define MSG_RULESERV "RULESERV" /* RuleServ */
#define MSG_SNETINFO "SNETINFO" /* SNetInfo */
#define MSG_TSCTL "TSCTL" /* TSCTL */
#define MSG_TSCTL "TSCTL" /* TSCTL */
#define MSG_SVSJOIN "SVSJOIN" /* SVSJOIN */
#define MSG_SAJOIN "SAJOIN" /* SAJOIN */
#define MSG_SDESC "SDESC" /* SDESC */
#define MSG_SDESC "SDESC" /* SDESC */
#define MSG_UNREALINFO "UNREALINFO" /* Unreal Info */
#define MSG_SETHOST "SETHOST" /* sethost */
#define MSG_SETIDENT "SETIDENT" /* set ident */
#define MSG_SETNAME "SETNAME" /* set Realname */
#define MSG_SETHOST "SETHOST" /* sethost */
#define MSG_SETIDENT "SETIDENT" /* set ident */
#define MSG_SETNAME "SETNAME" /* set Realname */
#define MSG_CHGHOST "CHGHOST" /* Changehost */
#define MSG_CHGIDENT "CHGIDENT" /* Change Ident */
#define MSG_RANDQUOTE "RANDQUOTE" /* Random Quote */
@ -145,19 +145,19 @@
#define MSG_ADDGQUOTE "ADDGQUOTE" /* Add Global Quote */
#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_KNOCK "KNOCK" /* Knock Knock - Who's there? */
#define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */
#define MSG_SETTINGS "SETTINGS" /* Settings */
#define MSG_IRCOPS "IRCOPS" /* Shows Online IRCOps */
#define MSG_SVSPART "SVSPART" /* SVSPART */
#define MSG_SAPART "SAPART" /* SAPART */
#define MSG_VCTRL "VCTRL" /* VCTRL */
#define MSG_VCTRL "VCTRL" /* VCTRL */
#define MSG_GCLIENT "GCLIENT" /* GLIENT */
#define MSG_CHANNEL "CHANNEL" /* CHANNEL */
#define MSG_UPTIME "UPTIME" /* UPTIME */
#define MSG_FAILOPS "FAILOPS" /* FAILOPS */
#define MSG_RPING "RPING" /* RPING */
#define MSG_RPONG "RPONG" /* RPONG */
#define MSG_UPING "UPING" /* UPING */
#define MSG_RPING "RPING" /* RPING */
#define MSG_RPONG "RPONG" /* RPONG */
#define MSG_UPING "UPING" /* UPING */
#define MSG_COPYRIGHT "COPYRIGHT" /* Copyright */
#define MSG_BOTSERV "BOTSERV" /* BOTSERV */
#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 */
/* UMODE_SERVICES is actually UMODE_OPER on Bahamut !*/
#define UMODE_SERVICES UMODE_OPER
#define UMODE_REGONLY 0x0010 /* only registered nicks may PM */
#define UMODE_REGNICK 0x0020 /* Nick set by services as registered */
#define UMODE_SERVADMIN 0x0040 /* server admin */
#define UMODE_SERVICESADMIN 0x0080 /* Marks the client as a Services Administrator */
#define UMODE_REGONLY 0x0010 /* only registered nicks may PM */
#define UMODE_REGNICK 0x0020 /* Nick set by services as registered */
#define UMODE_SERVADMIN 0x0040 /* server admin */
#define UMODE_SERVICESADMIN 0x0080 /* Marks the client as a Services Administrator */
@ -219,8 +219,8 @@ struct ircd_srv_ {
typedef struct {
long mode;
char flag;
unsigned nickparam : 1; /* 1 = yes 0 = no */
unsigned parameters : 1;
unsigned nickparam:1; /* 1 = yes 0 = no */
unsigned parameters:1;
char sjoin;
} aCtab;
@ -242,77 +242,77 @@ Oper_Modes susr_mds[9];
/* function declarations */
extern void init_ircd();
extern void chanalert(char *,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 ssquit_cmd(const char *);
extern int sprotocol_cmd(const char *);
extern int squit_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 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 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 snumeric_cmd(const int numeric, const char *target, const char *data,...);
extern int spong_cmd(const char *reply);
extern int snetinfo_cmd();
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 snick_cmd(const char *oldnick, const char *newnick);
extern int sswhois_cmd(const char *target, const char *swhois);
extern int ssvsnick_cmd(const char *target, const char *newnick);
extern int ssvsjoin_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 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 vctrl_cmd();
extern int ssvinfo_cmd();
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 srakill_cmd(const char *host, const char *ident);
extern int ssvshost_cmd(const char *who, const char *vhost);
extern int ssvskill_cmd(const char *who, const char *reason, ...);
extern void init_ircd ();
extern void chanalert (char *, 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 ssquit_cmd (const char *);
extern int sprotocol_cmd (const char *);
extern int squit_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 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 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 snumeric_cmd (const int numeric, const char *target, const char *data, ...);
extern int spong_cmd (const char *reply);
extern int snetinfo_cmd ();
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 snick_cmd (const char *oldnick, const char *newnick);
extern int sswhois_cmd (const char *target, const char *swhois);
extern int ssvsnick_cmd (const char *target, const char *newnick);
extern int ssvsjoin_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 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 vctrl_cmd ();
extern int ssvinfo_cmd ();
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 srakill_cmd (const char *host, const char *ident);
extern int ssvshost_cmd (const char *who, const char *vhost);
extern int ssvskill_cmd (const char *who, const char *reason, ...);
void Usr_Version(char *, char **, int argc);
void Usr_ShowMOTD(char *, char **, int argc);
void Usr_ShowADMIN(char *, char **, int argc);
void Usr_Showcredits(char *, char **, int argc);
void Usr_AddServer(char *, char **, int argc);
void Usr_DelServer(char *, char **, int argc);
void Usr_DelUser(char *, char **, int argc);
void Usr_Mode(char *, char **, int argc);
void Usr_Smode(char *, char **, int argc);
void Usr_Kill(char *, char **, int argc);
void Usr_Pong(char *, char **, int argc);
void Usr_Away(char *, char **, int argc);
void Usr_Nick(char *, char **, int argc);
void Usr_Topic(char *, char **, int argc);
void Usr_Kick(char *, char **, int argc);
void Usr_Join(char *, char **, int argc);
void Usr_Part(char *, char **, int argc);
void Usr_Stats(char *, char **, int argc);
void Usr_Vhost(char *, char **, int argc);
void Srv_Topic(char *, char **, int argc);
void Srv_Ping(char *, char **, int argc);
void Srv_Netinfo(char *, char **, int argc);
void Srv_Pass(char *, char **, int argc);
void Srv_Server(char *, char **, int argc);
void Srv_Squit(char *, char **, int argc);
void Srv_Nick(char *, char **, int argc);
void Srv_Svsnick(char *, char **, int argc);
void Srv_Kill(char *, char **, int argc);
void Srv_Connect(char *, char **, int argc);
void Srv_Svinfo(char *, char **, int argc);
void Srv_Burst(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_Vctrl(char *origin, char **argv, int argc);
void Srv_Client(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);
void Usr_Version (char *, char **, int argc);
void Usr_ShowMOTD (char *, char **, int argc);
void Usr_ShowADMIN (char *, char **, int argc);
void Usr_Showcredits (char *, char **, int argc);
void Usr_AddServer (char *, char **, int argc);
void Usr_DelServer (char *, char **, int argc);
void Usr_DelUser (char *, char **, int argc);
void Usr_Mode (char *, char **, int argc);
void Usr_Smode (char *, char **, int argc);
void Usr_Kill (char *, char **, int argc);
void Usr_Pong (char *, char **, int argc);
void Usr_Away (char *, char **, int argc);
void Usr_Nick (char *, char **, int argc);
void Usr_Topic (char *, char **, int argc);
void Usr_Kick (char *, char **, int argc);
void Usr_Join (char *, char **, int argc);
void Usr_Part (char *, char **, int argc);
void Usr_Stats (char *, char **, int argc);
void Usr_Vhost (char *, char **, int argc);
void Srv_Topic (char *, char **, int argc);
void Srv_Ping (char *, char **, int argc);
void Srv_Netinfo (char *, char **, int argc);
void Srv_Pass (char *, char **, int argc);
void Srv_Server (char *, char **, int argc);
void Srv_Squit (char *, char **, int argc);
void Srv_Nick (char *, char **, int argc);
void Srv_Svsnick (char *, char **, int argc);
void Srv_Kill (char *, char **, int argc);
void Srv_Connect (char *, char **, int argc);
void Srv_Svinfo (char *, char **, int argc);
void Srv_Burst (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_Vctrl (char *origin, char **argv, int argc);
void Srv_Client (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);
#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.
- Moved is_pub_chan from SecureServ to NeoStats
- 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
- 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
**
** 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_WHO "WHO" /* WHO -> WHOC */
#define MSG_WHOIS "WHOIS" /* WHOI */
#define MSG_WHO "WHO" /* WHO -> WHOC */
#define MSG_WHOIS "WHOIS" /* WHOI */
#define MSG_WHOWAS "WHOWAS" /* WHOW */
#define MSG_USER "USER" /* USER */
#define MSG_NICK "NICK" /* NICK */
#define MSG_USER "USER" /* USER */
#define MSG_NICK "NICK" /* NICK */
#define MSG_SERVER "SERVER" /* SERV */
#define MSG_LIST "LIST" /* LIST */
#define MSG_TOPIC "TOPIC" /* TOPI */
#define MSG_LIST "LIST" /* LIST */
#define MSG_TOPIC "TOPIC" /* TOPI */
#define MSG_INVITE "INVITE" /* INVI */
#define MSG_VERSION "VERSION" /* VERS */
#define MSG_QUIT "QUIT" /* QUIT */
#define MSG_SQUIT "SQUIT" /* SQUI */
#define MSG_KILL "KILL" /* KILL */
#define MSG_INFO "INFO" /* INFO */
#define MSG_LINKS "LINKS" /* LINK */
#define MSG_WATCH "WATCH" /* WATCH */
#define MSG_STATS "STATS" /* STAT */
#define MSG_HELP "HELP" /* HELP */
#define MSG_QUIT "QUIT" /* QUIT */
#define MSG_SQUIT "SQUIT" /* SQUI */
#define MSG_KILL "KILL" /* KILL */
#define MSG_INFO "INFO" /* INFO */
#define MSG_LINKS "LINKS" /* LINK */
#define MSG_WATCH "WATCH" /* WATCH */
#define MSG_STATS "STATS" /* STAT */
#define MSG_HELP "HELP" /* HELP */
#define MSG_HELPOP "HELPOP" /* HELP */
#define MSG_ERROR "ERROR" /* ERRO */
#define MSG_AWAY "AWAY" /* AWAY */
#define MSG_ERROR "ERROR" /* ERRO */
#define MSG_AWAY "AWAY" /* AWAY */
#define MSG_CONNECT "CONNECT" /* CONN */
#define MSG_PING "PING" /* PING */
#define MSG_PONG "PONG" /* PONG */
#define MSG_OPER "OPER" /* OPER */
#define MSG_PASS "PASS" /* PASS */
#define MSG_PING "PING" /* PING */
#define MSG_PONG "PONG" /* PONG */
#define MSG_OPER "OPER" /* OPER */
#define MSG_PASS "PASS" /* PASS */
#define MSG_WALLOPS "WALLOPS" /* WALL */
#define MSG_TIME "TIME" /* TIME */
#define MSG_NAMES "NAMES" /* NAME */
#define MSG_ADMIN "ADMIN" /* ADMI */
#define MSG_TIME "TIME" /* TIME */
#define MSG_NAMES "NAMES" /* NAME */
#define MSG_ADMIN "ADMIN" /* ADMI */
#define MSG_NOTICE "NOTICE" /* NOTI */
#define MSG_JOIN "JOIN" /* JOIN */
#define MSG_PART "PART" /* PART */
#define MSG_JOIN "JOIN" /* JOIN */
#define MSG_PART "PART" /* PART */
#define MSG_LUSERS "LUSERS" /* LUSE */
#define MSG_MOTD "MOTD" /* MOTD */
#define MSG_MODE "MODE" /* MODE */
#define MSG_KICK "KICK" /* KICK */
#define MSG_MOTD "MOTD" /* MOTD */
#define MSG_MODE "MODE" /* MODE */
#define MSG_KICK "KICK" /* KICK */
#define MSG_SERVICE "SERVICE" /* SERV -> SRVI */
#define MSG_USERHOST "USERHOST" /* USER -> USRH */
#define MSG_ISON "ISON" /* ISON */
#define MSG_ISON "ISON" /* ISON */
#define MSG_SQUERY "SQUERY" /* SQUE */
#define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */
#define MSG_SERVSET "SERVSET" /* SERV -> SSET */
#define MSG_REHASH "REHASH" /* REHA */
#define MSG_RESTART "RESTART" /* REST */
#define MSG_CLOSE "CLOSE" /* CLOS */
#define MSG_DIE "DIE" /* DIE */
#define MSG_HASH "HASH" /* HASH */
#define MSG_DNS "DNS" /* DNS -> DNSS */
#define MSG_CLOSE "CLOSE" /* CLOS */
#define MSG_DIE "DIE" /* DIE */
#define MSG_HASH "HASH" /* HASH */
#define MSG_DNS "DNS" /* DNS -> DNSS */
#define MSG_SILENCE "SILENCE" /* SILE */
#define MSG_AKILL "AKILL" /* AKILL */
#define MSG_KLINE "KLINE" /* KLINE */
#define MSG_UNKLINE "UNKLINE" /* UNKLINE */
#define MSG_AKILL "AKILL" /* AKILL */
#define MSG_KLINE "KLINE" /* KLINE */
#define MSG_UNKLINE "UNKLINE" /* UNKLINE */
#define MSG_RAKILL "RAKILL" /* RAKILL */
#define MSG_GNOTICE "GNOTICE" /* GNOTICE */
#define MSG_GOPER "GOPER" /* GOPER */
#define MSG_GOPER "GOPER" /* GOPER */
#define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */
#define MSG_LOCOPS "LOCOPS" /* LOCOPS */
#define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */
#define MSG_TRACE "TRACE" /* TRAC */
#define MSG_TRACE "TRACE" /* TRAC */
#define MSG_SQLINE "SQLINE" /* SQLINE */
#define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */
#define MSG_SVSNICK "SVSNICK" /* SVSNICK */
@ -108,14 +108,14 @@
#define MSG_SVSMODE "SVSMODE" /* SVSMODE */
#define MSG_SAMODE "SAMODE" /* SAMODE */
#define MSG_CHATOPS "CHATOPS" /* CHATOPS */
#define MSG_HELPSERV "HELPSERV" /* HELPSERV */
#define MSG_ZLINE "ZLINE" /* ZLINE */
#define MSG_HELPSERV "HELPSERV" /* HELPSERV */
#define MSG_ZLINE "ZLINE" /* ZLINE */
#define MSG_UNZLINE "UNZLINE" /* UNZLINE */
#define MSG_NETINFO "NETINFO" /* NETINFO */
#define MSG_RULES "RULES" /* RULES */
#define MSG_MAP "MAP" /* MAP */
#define MSG_NETG "NETG" /* NETG */
#define MSG_ADCHAT "ADCHAT" /* Adchat */
#define MSG_RULES "RULES" /* RULES */
#define MSG_MAP "MAP" /* MAP */
#define MSG_NETG "NETG" /* NETG */
#define MSG_ADCHAT "ADCHAT" /* Adchat */
#define MSG_MAKEPASS "MAKEPASS" /* MAKEPASS */
#define MSG_ADDHUB "ADDHUB" /* ADDHUB */
#define MSG_DELHUB "DELHUB" /* DELHUB */
@ -125,28 +125,28 @@
#define MSG_DELOPER "DELOPER" /* DELOPER */
#define MSG_ADDQLINE "ADDQLINE" /* ADDQLINE */
#define MSG_DELQLINE "DELQLINE" /* DELQLINE */
#define MSG_GSOP "GSOP" /* GSOP */
#define MSG_ISOPER "ISOPER" /* ISOPER */
#define MSG_ADG "ADG" /* ADG */
#define MSG_NMON "NMON" /* NMON */
#define MSG_GSOP "GSOP" /* GSOP */
#define MSG_ISOPER "ISOPER" /* ISOPER */
#define MSG_ADG "ADG" /* ADG */
#define MSG_NMON "NMON" /* NMON */
#define MSG_DALINFO "DALINFO" /* DALnet Credits */
#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_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_STATSERV "STATSERV" /* StatServ */
#define MSG_RULESERV "RULESERV" /* RuleServ */
#define MSG_SNETINFO "SNETINFO" /* SNetInfo */
#define MSG_TSCTL "TSCTL" /* TSCTL */
#define MSG_TSCTL "TSCTL" /* TSCTL */
#define MSG_SVSJOIN "SVSJOIN" /* SVSJOIN */
#define MSG_SAJOIN "SAJOIN" /* SAJOIN */
#define MSG_SDESC "SDESC" /* SDESC */
#define MSG_SDESC "SDESC" /* SDESC */
#define MSG_UNREALINFO "UNREALINFO" /* Unreal Info */
#define MSG_SETHOST "SETHOST" /* sethost */
#define MSG_SETIDENT "SETIDENT" /* set ident */
#define MSG_SETNAME "SETNAME" /* set Realname */
#define MSG_SETHOST "SETHOST" /* sethost */
#define MSG_SETIDENT "SETIDENT" /* set ident */
#define MSG_SETNAME "SETNAME" /* set Realname */
#define MSG_CHGHOST "CHGHOST" /* Changehost */
#define MSG_CHGIDENT "CHGIDENT" /* Change Ident */
#define MSG_RANDQUOTE "RANDQUOTE" /* Random Quote */
@ -154,19 +154,19 @@
#define MSG_ADDGQUOTE "ADDGQUOTE" /* Add Global Quote */
#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_KNOCK "KNOCK" /* Knock Knock - Who's there? */
#define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */
#define MSG_SETTINGS "SETTINGS" /* Settings */
#define MSG_IRCOPS "IRCOPS" /* Shows Online IRCOps */
#define MSG_SVSPART "SVSPART" /* SVSPART */
#define MSG_SAPART "SAPART" /* SAPART */
#define MSG_VCTRL "VCTRL" /* VCTRL */
#define MSG_VCTRL "VCTRL" /* VCTRL */
#define MSG_GCLIENT "GCLIENT" /* GLIENT */
#define MSG_CHANNEL "CHANNEL" /* CHANNEL */
#define MSG_UPTIME "UPTIME" /* UPTIME */
#define MSG_FAILOPS "FAILOPS" /* FAILOPS */
#define MSG_RPING "RPING" /* RPING */
#define MSG_RPONG "RPONG" /* RPONG */
#define MSG_UPING "UPING" /* UPING */
#define MSG_RPING "RPING" /* RPING */
#define MSG_RPONG "RPONG" /* RPONG */
#define MSG_UPING "UPING" /* UPING */
#define MSG_COPYRIGHT "COPYRIGHT" /* Copyright */
#define MSG_BOTSERV "BOTSERV" /* BOTSERV */
#define MSG_BS "BS"
@ -191,14 +191,14 @@
#define UMODE_SKILL 0x0100 /* client see's server kills */
#define UMODE_LOCOPS 0x0200 /* client is localop */
#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_UNAUTH 0x2000 /* client can see unauthd connections */
#define UMODE_WALLOP 0x4000 /* client can get wallop messages */
#define UMODE_EXTERNAL 0x8000 /* client can see server joins/splits */
#define UMODE_SPY 0x10000 /* client can spy on user commands */
#define UMODE_OPERWALL 0x20000 /* client gets operwalls */
#define UMODE_SERVICES 0x40000 /* client is services */
#define UMODE_OPERWALL 0x20000 /* client gets operwalls */
#define UMODE_SERVICES 0x40000 /* client is services */
#define MODE_CHANOP 0x0001
@ -234,8 +234,8 @@ struct ircd_srv_ {
typedef struct {
long mode;
char flag;
unsigned nickparam : 1; /* 1 = yes 0 = no */
unsigned parameters : 1;
unsigned nickparam:1; /* 1 = yes 0 = no */
unsigned parameters:1;
char sjoin;
} aCtab;
@ -257,74 +257,74 @@ Oper_Modes susr_mds[0];
/* function declarations */
extern void init_ircd();
extern void chanalert(char *,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 ssquit_cmd(const char *);
extern int sprotocol_cmd(const char *);
extern int squit_cmd(const char *, const char *);
extern int spart_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 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 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 spong_cmd(const char *reply);
extern int snetinfo_cmd();
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 ssmo_cmd(const char *from, const char *umodetarget, const char *msg);
extern int snick_cmd(const char *oldnick, const char *newnick);
extern int sswhois_cmd(const char *target, const char *swhois);
extern int ssvsnick_cmd(const char *target, const char *newnick);
extern int ssvsjoin_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 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 vctrl_cmd();
extern int ssvinfo_cmd();
extern int sburst_cmd(int b);
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 srakill_cmd(const char *host, const char *ident);
extern void init_ircd ();
extern void chanalert (char *, 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 ssquit_cmd (const char *);
extern int sprotocol_cmd (const char *);
extern int squit_cmd (const char *, const char *);
extern int spart_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 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 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 spong_cmd (const char *reply);
extern int snetinfo_cmd ();
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 ssmo_cmd (const char *from, const char *umodetarget, const char *msg);
extern int snick_cmd (const char *oldnick, const char *newnick);
extern int sswhois_cmd (const char *target, const char *swhois);
extern int ssvsnick_cmd (const char *target, const char *newnick);
extern int ssvsjoin_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 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 vctrl_cmd ();
extern int ssvinfo_cmd ();
extern int sburst_cmd (int b);
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 srakill_cmd (const char *host, const char *ident);
void Usr_Version(char *, char **, int argc);
void Usr_ShowMOTD(char *, char **, int argc);
void Usr_ShowADMIN(char *, char **, int argc);
void Usr_Showcredits(char *, char **, int argc);
void Usr_AddServer(char *, char **, int argc);
void Usr_DelServer(char *, char **, int argc);
void Usr_DelUser(char *, char **, int argc);
void Usr_Mode(char *, char **, int argc);
void Usr_Smode(char *, char **, int argc);
void Usr_Kill(char *, char **, int argc);
void Usr_Pong(char *, char **, int argc);
void Usr_Away(char *, char **, int argc);
void Usr_Nick(char *, char **, int argc);
void Usr_Topic(char *, char **, int argc);
void Usr_Kick(char *, char **, int argc);
void Usr_Join(char *, char **, int argc);
void Usr_Part(char *, char **, int argc);
void Usr_Stats(char *, char **, int argc);
void Usr_Vhost(char *, char **, int argc);
void Srv_Topic(char *, char **, int argc);
void Srv_Ping(char *, char **, int argc);
void Srv_Netinfo(char *, char **, int argc);
void Srv_Pass(char *, char **, int argc);
void Srv_Server(char *, char **, int argc);
void Srv_Squit(char *, char **, int argc);
void Srv_Nick(char *, char **, int argc);
void Srv_Svsnick(char *, char **, int argc);
void Srv_Kill(char *, char **, int argc);
void Srv_Connect(char *, char **, int argc);
void Srv_Svinfo(char *, char **, int argc);
void Srv_Burst(char *origin, char **argv, int argc);
void Srv_Sjoin(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);
void Usr_Version (char *, char **, int argc);
void Usr_ShowMOTD (char *, char **, int argc);
void Usr_ShowADMIN (char *, char **, int argc);
void Usr_Showcredits (char *, char **, int argc);
void Usr_AddServer (char *, char **, int argc);
void Usr_DelServer (char *, char **, int argc);
void Usr_DelUser (char *, char **, int argc);
void Usr_Mode (char *, char **, int argc);
void Usr_Smode (char *, char **, int argc);
void Usr_Kill (char *, char **, int argc);
void Usr_Pong (char *, char **, int argc);
void Usr_Away (char *, char **, int argc);
void Usr_Nick (char *, char **, int argc);
void Usr_Topic (char *, char **, int argc);
void Usr_Kick (char *, char **, int argc);
void Usr_Join (char *, char **, int argc);
void Usr_Part (char *, char **, int argc);
void Usr_Stats (char *, char **, int argc);
void Usr_Vhost (char *, char **, int argc);
void Srv_Topic (char *, char **, int argc);
void Srv_Ping (char *, char **, int argc);
void Srv_Netinfo (char *, char **, int argc);
void Srv_Pass (char *, char **, int argc);
void Srv_Server (char *, char **, int argc);
void Srv_Squit (char *, char **, int argc);
void Srv_Nick (char *, char **, int argc);
void Srv_Svsnick (char *, char **, int argc);
void Srv_Kill (char *, char **, int argc);
void Srv_Connect (char *, char **, int argc);
void Srv_Svinfo (char *, char **, int argc);
void Srv_Burst (char *origin, char **argv, int argc);
void Srv_Sjoin (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);
#endif

File diff suppressed because it is too large Load diff

View file

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

File diff suppressed because it is too large Load diff

View file

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

627
Unreal.c
View file

@ -20,7 +20,7 @@
** USA
**
** 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"
@ -294,101 +294,105 @@ Oper_Modes usr_mds[] = {
void init_ircd()
void
init_ircd ()
{
/* 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,
(me.token ? TOK_SERVER : MSG_SERVER), name, numeric, infoline);
sts (":%s %s %s %d :%s", me.name, (me.token ? TOK_SERVER : MSG_SERVER), name, numeric, infoline);
return 1;
}
int slogin_cmd(const char *name, const int numeric, const char *infoline,
const char *pass)
int
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 %d :%s", (me.token ? TOK_SERVER : MSG_SERVER), name,
numeric, infoline);
sts ("%s %s", (me.token ? TOK_PASS : MSG_PASS), pass);
sts ("%s %s %d :%s", (me.token ? TOK_SERVER : MSG_SERVER), name, numeric, infoline);
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;
}
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;
}
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);
DelUser(who);
sts (":%s %s :%s", who, (me.token ? TOK_QUIT : MSG_QUIT), quitmsg);
DelUser (who);
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);
part_chan(finduser(who), (char *) chan);
sts (":%s %s %s", who, (me.token ? TOK_PART : MSG_PART), chan);
part_chan (finduser (who), (char *) chan);
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);
join_chan(finduser(who), (char *) chan);
sts (":%s %s %s", who, (me.token ? TOK_JOIN : MSG_JOIN), chan);
join_chan (finduser (who), (char *) chan);
return 1;
}
int schmode_cmd(const char *who, const char *chan, const char *mode,
const char *args)
int
schmode_cmd (const char *who, const char *chan, const char *mode, const char *args)
{
char **av;
int ac;
char tmp[512];
sts(":%s %s %s %s %s %lu", who, (me.token ? TOK_MODE : MSG_MODE),
chan, mode, args, time(NULL));
snprintf(tmp, 512, "%s %s %s", chan, mode, args);
ac = split_buf(tmp, &av, 0);
ChanMode("", av, ac);
sts (":%s %s %s %s %s %lu", who, (me.token ? TOK_MODE : MSG_MODE), chan, mode, args, time (NULL));
snprintf (tmp, 512, "%s %s %s", chan, mode, args);
ac = split_buf (tmp, &av, 0);
ChanMode ("", av, ac);
return 1;
}
int snewnick_cmd(const char *nick, const char *ident, const char *host,
const char *realname)
int
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),
nick, time(NULL), ident, host, me.name, realname);
AddUser(nick, ident, host, me.name, 0, time(NULL));
sts ("%s %s 1 %lu %s %s %s 0 :%s", (me.token ? TOK_NICK : MSG_NICK), nick, time (NULL), ident, host, me.name, realname);
AddUser (nick, ident, host, me.name, 0, time (NULL));
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,
to);
sts (":%s %s %s :%s", from, (me.token ? TOK_PING : MSG_PING), reply, to);
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;
char newmode[20];
newmode[0] = '+';
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) {
newmode[j] = usr_mds[i].mode;
j++;
@ -396,561 +400,582 @@ int sumode_cmd(const char *who, const char *target, long mode)
}
newmode[j] = '\0';
sts(":%s %s %s :%s", who, (me.token ? TOK_MODE : MSG_MODE), target,
newmode);
UserMode(target, newmode, 0);
sts (":%s %s %s :%s", who, (me.token ? TOK_MODE : MSG_MODE), target, newmode);
UserMode (target, newmode, 0);
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;
char buf[512];
va_start(ap, data);
vsnprintf(buf, 512, data, ap);
sts(":%s %d %s :%s", me.name, numeric, target, buf);
va_end(ap);
va_start (ap, data);
vsnprintf (buf, 512, data, ap);
sts (":%s %d %s :%s", me.name, numeric, target, buf);
va_end (ap);
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;
}
int snetinfo_cmd()
int
snetinfo_cmd ()
{
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);
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);
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;
char buf[512];
va_start(ap, reason);
vsnprintf(buf, 512, reason, ap);
sts(":%s %s %s :%s", from, (me.token ? TOK_KILL : MSG_KILL),
target, buf);
va_end(ap);
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);
va_start (ap, reason);
vsnprintf (buf, 512, reason, ap);
sts (":%s %s %s :%s", from, (me.token ? TOK_KILL : MSG_KILL), target, buf);
va_end (ap);
DelUser (target);
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 %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));
sts (":%s %s %s :%s", from, (me.token ? TOK_SMO : MSG_SMO), umodetarget, msg);
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,
chan);
Change_User (finduser (oldnick), newnick);
sts (":%s %s %s %d", oldnick, (me.token ? TOK_NICK : MSG_NICK), newnick, time (NULL));
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,
chan);
sts ("%s %s :%s", (me.token ? TOK_SWHOIS : MSG_SWHOIS), target, swhois);
return 1;
}
int skick_cmd(const char *who, const char *target, const char *chan,
const char *reason)
int
ssvsnick_cmd (const char *target, const char *newnick)
{
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);
sts ("%s %s %s :%d", (me.token ? TOK_SVSNICK : MSG_SVSNICK), target, newnick, time (NULL));
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;
char buf[512];
va_start(ap, msg);
vsnprintf(buf, 512, msg, ap);
sts(":%s %s :%s", who, (me.token ? TOK_WALLOPS : MSG_WALLOPS),
buf);
va_end(ap);
va_start (ap, msg);
vsnprintf (buf, 512, msg, ap);
sts (":%s %s :%s", who, (me.token ? TOK_WALLOPS : MSG_WALLOPS), buf);
va_end (ap);
return 1;
}
int ssvshost_cmd(const char *who, const char *vhost)
int
ssvshost_cmd (const char *who, const char *vhost)
{
User *u;
u = finduser(who);
u = finduser (who);
if (!u) {
nlog(LOG_WARNING, LOG_CORE,
"Can't Find user %s for ssvshost_cmd", who);
nlog (LOG_WARNING, LOG_CORE, "Can't Find user %s for ssvshost_cmd", who);
return 0;
} else {
strcpy(u->vhost, vhost);
sts(":%s %s %s %s", me.name,
(me.token ? TOK_CHGHOST : MSG_CHGHOST), who, vhost);
strcpy (u->vhost, vhost);
sts (":%s %s %s %s", me.name, (me.token ? TOK_CHGHOST : MSG_CHGHOST), who, vhost);
return 1;
}
}
int ssvsmode_cmd(const char *target, const char *modes)
int
ssvsmode_cmd (const char *target, const char *modes)
{
User *u;
u = finduser(target);
u = finduser (target);
if (!u) {
nlog(LOG_WARNING, LOG_CORE,
"Can't find user %s for ssvsmode_cmd", target);
nlog (LOG_WARNING, LOG_CORE, "Can't find user %s for ssvsmode_cmd", target);
return 0;
} else {
sts(":%s %s %s %s", me.name,
(me.token ? TOK_SVSMODE : MSG_SVSMODE), target, modes);
UserMode(target, modes, 0);
sts (":%s %s %s %s", me.name, (me.token ? TOK_SVSMODE : MSG_SVSMODE), target, modes);
UserMode (target, modes, 0);
}
return 1;
}
int ssvskill_cmd(const char *target, const char *reason, ...)
int
ssvskill_cmd (const char *target, const char *reason, ...)
{
User *u;
va_list ap;
char buf[512];
u = finduser(target);
u = finduser (target);
if (!u) {
nlog(LOG_WARNING, LOG_CORE,
"Cant find user %s for ssvskill_cmd", target);
nlog (LOG_WARNING, LOG_CORE, "Cant find user %s for ssvskill_cmd", target);
return 0;
} else {
va_start(ap, reason);
vsnprintf(buf, 512, reason, ap);
sts(":%s %s %s :%s", me.name,
(me.token ? TOK_SVSKILL : MSG_SVSKILL), target, buf);
va_end(ap);
va_start (ap, reason);
vsnprintf (buf, 512, reason, ap);
sts (":%s %s %s :%s", me.name, (me.token ? TOK_SVSKILL : MSG_SVSKILL), target, buf);
va_end (ap);
return 1;
}
}
/* akill is gone in the latest Unreals, so we set Glines instead */
int sakill_cmd(const char *host, const char *ident, const char *setby,
const int length, const char *reason, ...)
int
sakill_cmd (const char *host, const char *ident, const char *setby, const int length, const char *reason, ...)
{
va_list ap;
char buf[512];
va_start(ap, reason);
vsnprintf(buf, 512, reason, ap);
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);
va_end(ap);
va_start (ap, reason);
vsnprintf (buf, 512, reason, ap);
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);
va_end (ap);
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),
ident, host, me.name);
sts (":%s %s - G %s %s %s", me.name, (me.token ? TOK_TKL : MSG_TKL), ident, host, me.name);
return 1;
}
void chanalert(char *who, char *buf, ...)
void
chanalert (char *who, char *buf, ...)
{
va_list ap;
char tmp[512];
char out[512];
va_start(ap, buf);
vsnprintf(tmp, 512, buf, ap);
va_start (ap, buf);
vsnprintf (tmp, 512, buf, ap);
if (me.onchan) {
snprintf(out, 512, ":%s PRIVMSG %s :%s", who, me.chan,
tmp);
sts("%s", out);
snprintf (out, 512, ":%s PRIVMSG %s :%s", who, me.chan, tmp);
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;
char buf[512], buf2[512];
if (findbot(to)) {
chanalert(s_Services,
"Message From our Bot(%s) to Our Bot(%s), Dropping Message",
from, to);
if (findbot (to)) {
chanalert (s_Services, "Message From our Bot(%s) to Our Bot(%s), Dropping Message", from, to);
return;
}
va_start(ap, fmt);
vsnprintf(buf2, sizeof(buf2), fmt, ap);
snprintf(buf, 512, ":%s NOTICE %s :%s", from, to, buf2);
sts("%s", buf);
va_end(ap);
va_start (ap, fmt);
vsnprintf (buf2, sizeof (buf2), fmt, ap);
snprintf (buf, 512, ":%s NOTICE %s :%s", from, to, buf2);
sts ("%s", buf);
va_end (ap);
}
void privmsg(char *to, const char *from, char *fmt, ...)
void
privmsg (char *to, const char *from, char *fmt, ...)
{
va_list ap;
char buf[512], buf2[512];
if (findbot(to)) {
chanalert(s_Services,
"Message From our Bot(%s) to Our Bot(%s), Dropping Message",
from, to);
if (findbot (to)) {
chanalert (s_Services, "Message From our Bot(%s) to Our Bot(%s), Dropping Message", from, to);
return;
}
va_start(ap, fmt);
vsnprintf(buf2, sizeof(buf2), fmt, ap);
snprintf(buf, 512, ":%s PRIVMSG %s :%s", from, to, buf2);
sts("%s", buf);
va_end(ap);
va_start (ap, fmt);
vsnprintf (buf2, sizeof (buf2), fmt, ap);
snprintf (buf, 512, ":%s PRIVMSG %s :%s", from, to, buf2);
sts ("%s", buf);
va_end (ap);
}
void prefmsg(char *to, const char *from, char *fmt, ...)
void
prefmsg (char *to, const char *from, char *fmt, ...)
{
va_list ap;
char buf[512], buf2[512];
va_start(ap, fmt);
vsnprintf(buf2, sizeof(buf2), fmt, ap);
if (findbot(to)) {
chanalert(s_Services,
"Message From our Bot(%s) to Our Bot(%s), Dropping Message",
from, to);
va_start (ap, fmt);
vsnprintf (buf2, sizeof (buf2), fmt, ap);
if (findbot (to)) {
chanalert (s_Services, "Message From our Bot(%s) to Our Bot(%s), Dropping Message", from, to);
return;
}
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 {
snprintf(buf, 512, ":%s NOTICE %s :%s", from, to, buf2);
snprintf (buf, 512, ":%s NOTICE %s :%s", from, to, buf2);
}
sts("%s", buf);
va_end(ap);
sts ("%s", buf);
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) {
if (**text)
prefmsg(to, from, "%s", *text);
prefmsg (to, from, "%s", *text);
else
prefmsg(to, from, " ");
prefmsg (to, from, " ");
text++;
}
}
void globops(char *from, char *fmt, ...)
void
globops (char *from, char *fmt, ...)
{
va_list ap;
char buf[512], buf2[512];
va_start(ap, fmt);
vsnprintf(buf2, sizeof(buf2), fmt, ap);
va_start (ap, fmt);
vsnprintf (buf2, sizeof (buf2), fmt, ap);
/* Shmad - have to get rid of nasty term echos :-) */
/* Fish - now that was crackhead coding! */
if (me.onchan) {
snprintf(buf, 512, ":%s GLOBOPS :%s", from, buf2);
sts("%s", buf);
snprintf (buf, 512, ":%s GLOBOPS :%s", from, buf2);
sts ("%s", buf);
} 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;
for (i = 0; i < argc; i++) {
if (!strcasecmp("TOKEN", argv[i])) {
if (!strcasecmp ("TOKEN", argv[i])) {
me.token = 1;
}
}
}
void Usr_Stats(char *origin, char **argv, int argc)
void
Usr_Stats (char *origin, char **argv, int argc)
{
User *u;
u = finduser(origin);
u = finduser (origin);
if (!u) {
nlog(LOG_WARNING, LOG_CORE,
"Recieved a Message from a Unknown User! (%s)",
origin);
nlog (LOG_WARNING, LOG_CORE, "Recieved a Message from a Unknown User! (%s)", origin);
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,
REV, version, me.name, version_date, version_time);
snumeric_cmd (351, origin, "%d.%d.%d%s :%s -> %s %s", MAJOR, MINOR, 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 */
UserMode(argv[0], argv[1], 0);
UserMode (argv[0], argv[1], 0);
} else {
/* 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], '#')) {
UserMode(argv[0], argv[1], 0);
if (!strchr (argv[0], '#')) {
UserMode (argv[0], argv[1], 0);
} 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;
u = finduser(argv[0]);
u = finduser (argv[0]);
if (u) {
KillUser(argv[0]);
KillUser (argv[0]);
} else {
nlog(LOG_WARNING, LOG_CORE, "Can't find user %s for Kill",
argv[0]);
nlog (LOG_WARNING, LOG_CORE, "Can't find user %s for Kill", argv[0]);
}
}
void Usr_Vhost(char *origin, char **argv, int argc)
void
Usr_Vhost (char *origin, char **argv, int argc)
{
User *u;
u = finduser(origin);
u = finduser (origin);
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;
s = findserver(argv[0]);
s = findserver (argv[0]);
if (s) {
dopong(s);
dopong (s);
} else {
nlog(LOG_NOTICE, LOG_CORE,
"Received PONG from unknown server: %s", argv[0]);
nlog (LOG_NOTICE, LOG_CORE, "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;
User *u = finduser(origin);
User *u = finduser (origin);
if (u) {
if (argc > 0) {
buf = joinbuf(argv, argc, 0);
buf = joinbuf (argv, argc, 0);
} else {
buf = NULL;
}
Do_Away(u, buf);
Do_Away (u, buf);
if (argc > 0) {
free(buf);
free (buf);
}
} else {
nlog(LOG_NOTICE, LOG_CORE,
"Warning, Unable to find User %s for Away", origin);
nlog (LOG_NOTICE, LOG_CORE, "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) {
Change_User(u, argv[0]);
Change_User (u, argv[0]);
} else {
nlog(LOG_NOTICE, LOG_CORE,
"Warning, Unable to find user %s for User_nick",
origin);
nlog (LOG_NOTICE, LOG_CORE, "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;
Chans *c;
c = findchan(argv[0]);
c = findchan (argv[0]);
if (c) {
buf = joinbuf(argv, argc, 3);
Change_Topic(argv[1], c, atoi(argv[2]), buf);
free(buf);
buf = joinbuf (argv, argc, 3);
Change_Topic (argv[1], c, atoi (argv[2]), buf);
free (buf);
} else {
nlog(LOG_WARNING, LOG_CORE, "Ehhh, Can't find Channel %s",
argv[0]);
nlog (LOG_WARNING, LOG_CORE, "Ehhh, Can't find Channel %s", argv[0]);
}
}
void Usr_Kick(char *origin, char **argv, int argc)
void
Usr_Kick (char *origin, char **argv, int argc)
{
User *u, *k;
u = finduser(argv[1]);
k = finduser(origin);
u = finduser (argv[1]);
k = finduser (origin);
if (u) {
kick_chan(u, argv[0], k);
kick_chan (u, argv[0], k);
} else {
nlog(LOG_WARNING, LOG_CORE,
"Waring, Can't find user %s for Kick %s", argv[1],
argv[0]);
nlog (LOG_WARNING, LOG_CORE, "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;
t = argv[0];
while (*(s = t)) {
t = s + strcspn(s, ",");
t = s + strcspn (s, ",");
if (*t)
*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;
ircd_srv.uprot = atoi(argv[2]);
strncpy(ircd_srv.cloak, argv[3], 10);
strncpy(me.netname, argv[7], MAXPASS);
ircd_srv.uprot = atoi (argv[2]);
strncpy (ircd_srv.cloak, argv[3], 10);
strncpy (me.netname, argv[7], MAXPASS);
snetinfo_cmd();
init_ServBot();
globops(me.name, "Link with Network \2Complete!\2");
snetinfo_cmd ();
init_ServBot ();
globops (me.name, "Link with Network \2Complete!\2");
if (ircd_srv.uprot == 2109) {
me.usesmo = 1;
}
Module_Event("NETINFO", NULL, 0);
Module_Event ("NETINFO", NULL, 0);
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;
if (*origin == 0) {
AddServer(argv[0], me.name, atoi(argv[1]));
AddServer (argv[0], me.name, atoi (argv[1]));
} 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;
}
void Srv_Squit(char *origin, char **argv, int argc)
void
Srv_Squit (char *origin, char **argv, int argc)
{
Server *s;
s = findserver(argv[0]);
s = findserver (argv[0]);
if (s) {
DelServer(argv[0]);
DelServer (argv[0]);
} else {
nlog(LOG_WARNING, LOG_CORE,
"Waring, Squit from Unknown Server %s", argv[0]);
nlog (LOG_WARNING, LOG_CORE, "Waring, Squit from Unknown Server %s", argv[0]);
}
}
/* 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;
int ac = 0;
char *realname;
AddStringToList(&av, argv[0], &ac);
AddUser(argv[0], argv[3], argv[4], argv[5], 0,
strtol(argv[2], NULL, 10));
realname = joinbuf(argv, argc, 7);
AddRealName(argv[0], realname);
free(realname);
AddStringToList (&av, argv[0], &ac);
AddUser (argv[0], argv[3], argv[4], argv[5], 0, strtol (argv[2], NULL, 10));
realname = joinbuf (argv, argc, 7);
AddRealName (argv[0], realname);
free (realname);
}
void Srv_Svsnick(char *origin, char **argv, int argc)
void
Srv_Svsnick (char *origin, char **argv, int argc)
{
User *u;
u = finduser(argv[0]);
u = finduser (argv[0]);
if (u) {
Change_User(u, argv[1]);
Change_User (u, argv[1]);
} else {
nlog(LOG_WARNING, LOG_CORE,
"Can't find user %s for svsnick", argv[0]);
nlog (LOG_WARNING, LOG_CORE, "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,
const char *host, const char *rname, long Umode)
extern int
SignOn_NewBot (const char *nick, const char *user, const char *host, const char *rname, long Umode)
{
snewnick_cmd(nick, user, host, rname);
sumode_cmd(nick, nick, Umode);
snewnick_cmd (nick, user, host, rname);
sumode_cmd (nick, nick, Umode);
if ((me.allbots > 0) || (Umode & UMODE_SERVICES)) {
sjoin_cmd(nick, me.chan);
schmode_cmd(me.name, me.chan, "+o", nick);
sjoin_cmd (nick, me.chan);
schmode_cmd (me.name, me.chan, "+o", nick);
}
return 1;
}

511
Unreal.h
View file

@ -44,7 +44,7 @@
* along with this program; if not, write to the Free Software
* 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 TOK_PRIVATE "!" /* 33 */
#define MSG_WHO "WHO" /* WHO -> WHOC */
#define TOK_WHO "\"" /* 34 */
#define MSG_WHOIS "WHOIS" /* WHOI */
#define TOK_WHOIS "#" /* 35 */
#define TOK_PRIVATE "!" /* 33 */
#define MSG_WHO "WHO" /* WHO -> WHOC */
#define TOK_WHO "\"" /* 34 */
#define MSG_WHOIS "WHOIS" /* WHOI */
#define TOK_WHOIS "#" /* 35 */
#define MSG_WHOWAS "WHOWAS" /* WHOW */
#define TOK_WHOWAS "$" /* 36 */
#define MSG_USER "USER" /* USER */
#define TOK_USER "%" /* 37 */
#define MSG_NICK "NICK" /* NICK */
#define TOK_NICK "&" /* 38 */
#define TOK_WHOWAS "$" /* 36 */
#define MSG_USER "USER" /* USER */
#define TOK_USER "%" /* 37 */
#define MSG_NICK "NICK" /* NICK */
#define TOK_NICK "&" /* 38 */
#define MSG_SERVER "SERVER" /* SERV */
#define TOK_SERVER "'" /* 39 */
#define MSG_LIST "LIST" /* LIST */
#define TOK_LIST "(" /* 40 */
#define MSG_TOPIC "TOPIC" /* TOPI */
#define TOK_TOPIC ")" /* 41 */
#define TOK_SERVER "'" /* 39 */
#define MSG_LIST "LIST" /* LIST */
#define TOK_LIST "(" /* 40 */
#define MSG_TOPIC "TOPIC" /* TOPI */
#define TOK_TOPIC ")" /* 41 */
#define MSG_INVITE "INVITE" /* INVI */
#define TOK_INVITE "*" /* 42 */
#define TOK_INVITE "*" /* 42 */
#define MSG_VERSION "VERSION" /* VERS */
#define TOK_VERSION "+" /* 43 */
#define MSG_QUIT "QUIT" /* QUIT */
#define TOK_QUIT "," /* 44 */
#define MSG_SQUIT "SQUIT" /* SQUI */
#define TOK_SQUIT "-" /* 45 */
#define MSG_KILL "KILL" /* KILL */
#define TOK_KILL "." /* 46 */
#define MSG_INFO "INFO" /* INFO */
#define TOK_INFO "/" /* 47 */
#define MSG_LINKS "LINKS" /* LINK */
#define TOK_LINKS "0" /* 48 */
#define TOK_VERSION "+" /* 43 */
#define MSG_QUIT "QUIT" /* QUIT */
#define TOK_QUIT "," /* 44 */
#define MSG_SQUIT "SQUIT" /* SQUI */
#define TOK_SQUIT "-" /* 45 */
#define MSG_KILL "KILL" /* KILL */
#define TOK_KILL "." /* 46 */
#define MSG_INFO "INFO" /* INFO */
#define TOK_INFO "/" /* 47 */
#define MSG_LINKS "LINKS" /* LINK */
#define TOK_LINKS "0" /* 48 */
#define MSG_SUMMON "SUMMON" /* SUMM */
#define TOK_SUMMON "1" /* 49 */
#define MSG_STATS "STATS" /* STAT */
#define TOK_STATS "2" /* 50 */
#define MSG_USERS "USERS" /* USER -> USRS */
#define TOK_USERS "3" /* 51 */
#define MSG_HELP "HELP" /* HELP */
#define TOK_SUMMON "1" /* 49 */
#define MSG_STATS "STATS" /* STAT */
#define TOK_STATS "2" /* 50 */
#define MSG_USERS "USERS" /* USER -> USRS */
#define TOK_USERS "3" /* 51 */
#define MSG_HELP "HELP" /* HELP */
#define MSG_HELPOP "HELPOP" /* HELP */
#define MSG_IRCDHELP "IRCDHELP" /* HELP */
#define TOK_HELP "4" /* 52 */
#define MSG_ERROR "ERROR" /* ERRO */
#define TOK_ERROR "5" /* 53 */
#define MSG_AWAY "AWAY" /* AWAY */
#define TOK_AWAY "6" /* 54 */
#define MSG_IRCDHELP "IRCDHELP" /* HELP */
#define TOK_HELP "4" /* 52 */
#define MSG_ERROR "ERROR" /* ERRO */
#define TOK_ERROR "5" /* 53 */
#define MSG_AWAY "AWAY" /* AWAY */
#define TOK_AWAY "6" /* 54 */
#define MSG_CONNECT "CONNECT" /* CONN */
#define TOK_CONNECT "7" /* 55 */
#define MSG_PING "PING" /* PING */
#define TOK_PING "8" /* 56 */
#define MSG_PONG "PONG" /* PONG */
#define TOK_PONG "9" /* 57 */
#define MSG_OPER "OPER" /* OPER */
#define TOK_OPER ";" /* 59 */
#define MSG_PASS "PASS" /* PASS */
#define TOK_PASS "<" /* 60 */
#define TOK_CONNECT "7" /* 55 */
#define MSG_PING "PING" /* PING */
#define TOK_PING "8" /* 56 */
#define MSG_PONG "PONG" /* PONG */
#define TOK_PONG "9" /* 57 */
#define MSG_OPER "OPER" /* OPER */
#define TOK_OPER ";" /* 59 */
#define MSG_PASS "PASS" /* PASS */
#define TOK_PASS "<" /* 60 */
#define MSG_WALLOPS "WALLOPS" /* WALL */
#define TOK_WALLOPS "=" /* 61 */
#define MSG_TIME "TIME" /* TIME */
#define TOK_TIME ">" /* 62 */
#define MSG_NAMES "NAMES" /* NAME */
#define TOK_NAMES "?" /* 63 */
#define MSG_ADMIN "ADMIN" /* ADMI */
#define TOK_ADMIN "@" /* 64 */
#define TOK_WALLOPS "=" /* 61 */
#define MSG_TIME "TIME" /* TIME */
#define TOK_TIME ">" /* 62 */
#define MSG_NAMES "NAMES" /* NAME */
#define TOK_NAMES "?" /* 63 */
#define MSG_ADMIN "ADMIN" /* ADMI */
#define TOK_ADMIN "@" /* 64 */
#define MSG_NOTICE "NOTICE" /* NOTI */
#define TOK_NOTICE "B" /* 66 */
#define MSG_JOIN "JOIN" /* JOIN */
#define TOK_JOIN "C" /* 67 */
#define MSG_PART "PART" /* PART */
#define TOK_PART "D" /* 68 */
#define TOK_NOTICE "B" /* 66 */
#define MSG_JOIN "JOIN" /* JOIN */
#define TOK_JOIN "C" /* 67 */
#define MSG_PART "PART" /* PART */
#define TOK_PART "D" /* 68 */
#define MSG_LUSERS "LUSERS" /* LUSE */
#define TOK_LUSERS "E" /* 69 */
#define MSG_MOTD "MOTD" /* MOTD */
#define TOK_MOTD "F" /* 70 */
#define MSG_MODE "MODE" /* MODE */
#define TOK_MODE "G" /* 71 */
#define MSG_KICK "KICK" /* KICK */
#define TOK_KICK "H" /* 72 */
#define TOK_LUSERS "E" /* 69 */
#define MSG_MOTD "MOTD" /* MOTD */
#define TOK_MOTD "F" /* 70 */
#define MSG_MODE "MODE" /* MODE */
#define TOK_MODE "G" /* 71 */
#define MSG_KICK "KICK" /* KICK */
#define TOK_KICK "H" /* 72 */
#define MSG_SERVICE "SERVICE" /* SERV -> SRVI */
#define TOK_SERVICE "I" /* 73 */
#define TOK_SERVICE "I" /* 73 */
#define MSG_USERHOST "USERHOST" /* USER -> USRH */
#define TOK_USERHOST "J" /* 74 */
#define MSG_ISON "ISON" /* ISON */
#define TOK_ISON "K" /* 75 */
#define TOK_USERHOST "J" /* 74 */
#define MSG_ISON "ISON" /* ISON */
#define TOK_ISON "K" /* 75 */
#define MSG_SQUERY "SQUERY" /* SQUE */
#define TOK_SQUERY "L" /* 76 */
#define TOK_SQUERY "L" /* 76 */
#define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */
#define TOK_SERVLIST "M" /* 77 */
#define TOK_SERVLIST "M" /* 77 */
#define MSG_SERVSET "SERVSET" /* SERV -> SSET */
#define TOK_SERVSET "N" /* 78 */
#define TOK_SERVSET "N" /* 78 */
#define MSG_REHASH "REHASH" /* REHA */
#define TOK_REHASH "O" /* 79 */
#define TOK_REHASH "O" /* 79 */
#define MSG_RESTART "RESTART" /* REST */
#define TOK_RESTART "P" /* 80 */
#define MSG_CLOSE "CLOSE" /* CLOS */
#define TOK_CLOSE "Q" /* 81 */
#define MSG_DIE "DIE" /* DIE */
#define TOK_DIE "R" /* 82 */
#define MSG_HASH "HASH" /* HASH */
#define TOK_HASH "S" /* 83 */
#define MSG_DNS "DNS" /* DNS -> DNSS */
#define TOK_DNS "T" /* 84 */
#define TOK_RESTART "P" /* 80 */
#define MSG_CLOSE "CLOSE" /* CLOS */
#define TOK_CLOSE "Q" /* 81 */
#define MSG_DIE "DIE" /* DIE */
#define TOK_DIE "R" /* 82 */
#define MSG_HASH "HASH" /* HASH */
#define TOK_HASH "S" /* 83 */
#define MSG_DNS "DNS" /* DNS -> DNSS */
#define TOK_DNS "T" /* 84 */
#define MSG_SILENCE "SILENCE" /* SILE */
#define TOK_SILENCE "U" /* 85 */
#define MSG_AKILL "AKILL" /* AKILL */
#define TOK_AKILL "V" /* 86 */
#define MSG_KLINE "KLINE" /* KLINE */
#define TOK_KLINE "W" /* 87 */
#define MSG_UNKLINE "UNKLINE" /* UNKLINE */
#define TOK_UNKLINE "X" /* 88 */
#define TOK_SILENCE "U" /* 85 */
#define MSG_AKILL "AKILL" /* AKILL */
#define TOK_AKILL "V" /* 86 */
#define MSG_KLINE "KLINE" /* KLINE */
#define TOK_KLINE "W" /* 87 */
#define MSG_UNKLINE "UNKLINE" /* UNKLINE */
#define TOK_UNKLINE "X" /* 88 */
#define MSG_RAKILL "RAKILL" /* RAKILL */
#define TOK_RAKILL "Y" /* 89 */
#define TOK_RAKILL "Y" /* 89 */
#define MSG_GNOTICE "GNOTICE" /* GNOTICE */
#define TOK_GNOTICE "Z" /* 90 */
#define MSG_GOPER "GOPER" /* GOPER */
#define TOK_GOPER "[" /* 91 */
#define TOK_GNOTICE "Z" /* 90 */
#define MSG_GOPER "GOPER" /* GOPER */
#define TOK_GOPER "[" /* 91 */
#define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */
#define TOK_GLOBOPS "]" /* 93 */
#define TOK_GLOBOPS "]" /* 93 */
#define MSG_LOCOPS "LOCOPS" /* LOCOPS */
#define TOK_LOCOPS "^" /* 94 */
#define TOK_LOCOPS "^" /* 94 */
#define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */
#define TOK_PROTOCTL "_" /* 95 */
#define MSG_WATCH "WATCH" /* WATCH */
#define TOK_WATCH "`" /* 96 */
#define MSG_TRACE "TRACE" /* TRAC */
#define TOK_TRACE "b" /* 97 */
#define TOK_PROTOCTL "_" /* 95 */
#define MSG_WATCH "WATCH" /* WATCH */
#define TOK_WATCH "`" /* 96 */
#define MSG_TRACE "TRACE" /* TRAC */
#define TOK_TRACE "b" /* 97 */
#define MSG_SQLINE "SQLINE" /* SQLINE */
#define TOK_SQLINE "c" /* 98 */
#define TOK_SQLINE "c" /* 98 */
#define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */
#define TOK_UNSQLINE "d" /* 99 */
#define TOK_UNSQLINE "d" /* 99 */
#define MSG_SVSNICK "SVSNICK" /* SVSNICK */
#define TOK_SVSNICK "e" /* 100 */
#define TOK_SVSNICK "e" /* 100 */
#define MSG_SVSNOOP "SVSNOOP" /* SVSNOOP */
#define TOK_SVSNOOP "f" /* 101 */
#define TOK_SVSNOOP "f" /* 101 */
#define MSG_IDENTIFY "IDENTIFY" /* IDENTIFY */
#define TOK_IDENTIFY "g" /* 102 */
#define TOK_IDENTIFY "g" /* 102 */
#define MSG_SVSKILL "SVSKILL" /* SVSKILL */
#define TOK_SVSKILL "h" /* 103 */
#define TOK_SVSKILL "h" /* 103 */
#define MSG_NICKSERV "NICKSERV" /* NICKSERV */
#define MSG_NS "NS"
#define TOK_NICKSERV "i" /* 104 */
#define TOK_NICKSERV "i" /* 104 */
#define MSG_CHANSERV "CHANSERV" /* CHANSERV */
#define MSG_CS "CS"
#define TOK_CHANSERV "j" /* 105 */
#define TOK_CHANSERV "j" /* 105 */
#define MSG_OPERSERV "OPERSERV" /* OPERSERV */
#define MSG_OS "OS"
#define TOK_OPERSERV "k" /* 106 */
#define TOK_OPERSERV "k" /* 106 */
#define MSG_MEMOSERV "MEMOSERV" /* MEMOSERV */
#define MSG_MS "MS"
#define TOK_MEMOSERV "l" /* 107 */
#define TOK_MEMOSERV "l" /* 107 */
#define MSG_SERVICES "SERVICES" /* SERVICES */
#define TOK_SERVICES "m" /* 108 */
#define TOK_SERVICES "m" /* 108 */
#define MSG_SVSMODE "SVSMODE" /* SVSMODE */
#define TOK_SVSMODE "n" /* 109 */
#define TOK_SVSMODE "n" /* 109 */
#define MSG_SAMODE "SAMODE" /* SAMODE */
#define TOK_SAMODE "o" /* 110 */
#define TOK_SAMODE "o" /* 110 */
#define MSG_CHATOPS "CHATOPS" /* CHATOPS */
#define TOK_CHATOPS "p" /* 111 */
#define MSG_ZLINE "ZLINE" /* ZLINE */
#define TOK_ZLINE "q" /* 112 */
#define TOK_CHATOPS "p" /* 111 */
#define MSG_ZLINE "ZLINE" /* ZLINE */
#define TOK_ZLINE "q" /* 112 */
#define MSG_UNZLINE "UNZLINE" /* UNZLINE */
#define TOK_UNZLINE "r" /* 113 */
#define MSG_HELPSERV "HELPSERV" /* HELPSERV */
#define TOK_UNZLINE "r" /* 113 */
#define MSG_HELPSERV "HELPSERV" /* HELPSERV */
#define MSG_HS "HS"
#define TOK_HELPSERV "s" /* 114 */
#define MSG_RULES "RULES" /* RULES */
#define TOK_RULES "t" /* 115 */
#define MSG_MAP "MAP" /* MAP */
#define TOK_MAP "u" /* 117 */
#define MSG_SVS2MODE "SVS2MODE" /* SVS2MODE */
#define TOK_SVS2MODE "v" /* 118 */
#define MSG_DALINFO "DALINFO" /* dalinfo */
#define TOK_DALINFO "w" /* 119 */
#define MSG_ADMINCHAT "ADCHAT" /* Admin chat */
#define TOK_ADMINCHAT "x" /* 120 */
#define TOK_HELPSERV "s" /* 114 */
#define MSG_RULES "RULES" /* RULES */
#define TOK_RULES "t" /* 115 */
#define MSG_MAP "MAP" /* MAP */
#define TOK_MAP "u" /* 117 */
#define MSG_SVS2MODE "SVS2MODE" /* SVS2MODE */
#define TOK_SVS2MODE "v" /* 118 */
#define MSG_DALINFO "DALINFO" /* dalinfo */
#define TOK_DALINFO "w" /* 119 */
#define MSG_ADMINCHAT "ADCHAT" /* Admin chat */
#define TOK_ADMINCHAT "x" /* 120 */
#define MSG_MKPASSWD "MKPASSWD" /* MKPASSWD */
#define TOK_MKPASSWD "y" /* 121 */
#define MSG_ADDLINE "ADDLINE" /* ADDLINE */
#define TOK_ADDLINE "z" /* 122 */
#define MSG_SNOTES "SNOTES" /* Read server notes */
#define TOK_SNOTES "{" /* 123 */
#define MSG_SNOTE "SNOTE" /* Write server note */
#define TOK_SNOTE "|" /* 124 */
#define MSG_GLINE "GLINE" /* The awesome g-line */
#define TOK_GLINE "}" /* 125 */
#define TOK_MKPASSWD "y" /* 121 */
#define MSG_ADDLINE "ADDLINE" /* ADDLINE */
#define TOK_ADDLINE "z" /* 122 */
#define MSG_SNOTES "SNOTES" /* Read server notes */
#define TOK_SNOTES "{" /* 123 */
#define MSG_SNOTE "SNOTE" /* Write server note */
#define TOK_SNOTE "|" /* 124 */
#define MSG_GLINE "GLINE" /* The awesome g-line */
#define TOK_GLINE "}" /* 125 */
#define MSG_REMGLINE "REMGLINE" /* remove g-line */
#define TOK_REMGLINE "~" /* 126 */
#define MSG_SETHOST "SETHOST" /* sethost */
#define TOK_SETHOST "AA" /* 127 4ever !;) */
#define MSG_TECHAT "TECHAT" /* techadmin chat */
#define TOK_TECHAT "AB" /* questionmark? */
#define MSG_NACHAT "NACHAT" /* netadmin chat */
#define TOK_NACHAT "AC" /* *beep* */
#define MSG_SETIDENT "SETIDENT" /* set ident */
#define TOK_SETIDENT "AD" /* good old BASIC ;P */
#define MSG_SETNAME "SETNAME" /* set GECOS */
#define TOK_SETNAME "AE" /* its almost unreeaaall... */
#define MSG_LAG "LAG" /* Lag detect */
#define TOK_LAG "AF" /* a or ? */
#define MSG_SDESC "SDESC" /* set description */
#define TOK_REMGLINE "~" /* 126 */
#define MSG_SETHOST "SETHOST" /* sethost */
#define TOK_SETHOST "AA" /* 127 4ever !;) */
#define MSG_TECHAT "TECHAT" /* techadmin chat */
#define TOK_TECHAT "AB" /* questionmark? */
#define MSG_NACHAT "NACHAT" /* netadmin chat */
#define TOK_NACHAT "AC" /* *beep* */
#define MSG_SETIDENT "SETIDENT" /* set ident */
#define TOK_SETIDENT "AD" /* good old BASIC ;P */
#define MSG_SETNAME "SETNAME" /* set GECOS */
#define TOK_SETNAME "AE" /* its almost unreeaaall... */
#define MSG_LAG "LAG" /* Lag detect */
#define TOK_LAG "AF" /* a or ? */
#define MSG_SDESC "SDESC" /* set description */
#define TOK_SDESC "AG"
#define MSG_STATSERV "STATSERV" /* alias */
#define MSG_STATSERV "STATSERV" /* alias */
#define TOK_STATSERV "AH"
#define MSG_KNOCK "KNOCK"
#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_WALLOP 0x0004 /* send wallops to them */
#define UMODE_FAILOP 0x0008 /* Shows some global messages */
#define UMODE_HELPOP 0x0010 /* Help system operator */
#define UMODE_REGNICK 0x0020 /* Nick set by services as registered */
#define UMODE_SADMIN 0x0040 /* Services Admin */
#define UMODE_ADMIN 0x0080 /* Admin */
#define UMODE_WALLOP 0x0004 /* send wallops to them */
#define UMODE_FAILOP 0x0008 /* Shows some global messages */
#define UMODE_HELPOP 0x0010 /* Help system operator */
#define UMODE_REGNICK 0x0020 /* Nick set by services as registered */
#define UMODE_SADMIN 0x0040 /* Services Admin */
#define UMODE_ADMIN 0x0080 /* Admin */
#define UMODE_SERVNOTICE 0x0100 /* server notices such as kill */
#define UMODE_LOCOP 0x0200 /* Local operator -- SRB */
#define UMODE_KILLS 0x0400 /* Show server-kills... */
#define UMODE_CLIENT 0x0800 /* Show client information */
#define UMODE_FLOOD 0x1000 /* Receive flood warnings */
#define UMODE_CHATOP 0x2000 /* can receive chatops */
#define UMODE_SERVICES 0x4000 /* services */
#define UMODE_HIDE 0x8000 /* Hide from Nukes */
#define UMODE_NETADMIN 0x10000 /* Network Admin */
#define UMODE_EYES 0x20000 /* Mode to see server stuff */
#define UMODE_TECHADMIN 0x40000 /* Tech Admin */
#define UMODE_COADMIN 0x80000 /* Co Admin */
#define UMODE_WHOIS 0x100000 /* gets notice on /whois */
#define UMODE_KIX 0x200000 /* usermode +q
cannot be kicked from any channel
except by U:Lines
*/
#define UMODE_BOT 0x400000 /* User is a bot */
#define UMODE_CODER 0x800000 /* User is a network coder */
#define UMODE_FCLIENT 0x1000000 /* recieve client on far connects.. */
#define UMODE_HIDING 0x2000000 /* Totally invisible .. */
#define UMODE_AGENT 0x4000000 /* Is an IRCd Agent local only */
#define UMODE_DEAF 0x8000000 /* User can't here anything in channel */
#define UMODE_SERVNOTICE 0x0100 /* server notices such as kill */
#define UMODE_LOCOP 0x0200 /* Local operator -- SRB */
#define UMODE_KILLS 0x0400 /* Show server-kills... */
#define UMODE_CLIENT 0x0800 /* Show client information */
#define UMODE_FLOOD 0x1000 /* Receive flood warnings */
#define UMODE_CHATOP 0x2000 /* can receive chatops */
#define UMODE_SERVICES 0x4000 /* services */
#define UMODE_HIDE 0x8000 /* Hide from Nukes */
#define UMODE_NETADMIN 0x10000 /* Network Admin */
#define UMODE_EYES 0x20000 /* Mode to see server stuff */
#define UMODE_TECHADMIN 0x40000 /* Tech Admin */
#define UMODE_COADMIN 0x80000 /* Co Admin */
#define UMODE_WHOIS 0x100000 /* gets notice on /whois */
#define UMODE_KIX 0x200000 /* usermode +q
cannot be kicked from any channel
except by U:Lines
*/
#define UMODE_BOT 0x400000 /* User is a bot */
#define UMODE_CODER 0x800000 /* User is a network coder */
#define UMODE_FCLIENT 0x1000000 /* recieve client on far connects.. */
#define UMODE_HIDING 0x2000000 /* Totally invisible .. */
#define UMODE_AGENT 0x4000000 /* Is an IRCd Agent local only */
#define UMODE_DEAF 0x8000000 /* User can't here anything in channel */
@ -428,8 +428,8 @@ struct ircd_srv_ {
typedef struct {
long mode;
char flag;
unsigned nickparam : 1; /* 1 = yes 0 = no */
unsigned parameters : 1;
unsigned nickparam:1; /* 1 = yes 0 = no */
unsigned parameters:1;
char sjoin;
} aCtab;
@ -451,74 +451,73 @@ Oper_Modes susr_mds[0];
/* function declarations */
extern void init_ircd();
extern void chanalert(char *,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 ssquit_cmd(const char *);
extern int sprotocol_cmd(const char *);
extern int squit_cmd(const char *, const char *);
extern int spart_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 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 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 spong_cmd(const char *reply);
extern int snetinfo_cmd();
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 ssmo_cmd(const char *from, const char *umodetarget, const char *msg);
extern int snick_cmd(const char *oldnick, const char *newnick);
extern int sswhois_cmd(const char *target, const char *swhois);
extern int ssvsnick_cmd(const char *target, const char *newnick);
extern int ssvsjoin_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 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 ssvsmode_cmd(const char *target, const char *modes);
extern int ssvshost_cmd(const char *who, const char *vhost);
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 srakill_cmd(const char *host, const char *ident);
extern int SignOn_NewBot(const char *, const char *, const char *, const char *, long);
extern void init_ircd ();
extern void chanalert (char *, 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 ssquit_cmd (const char *);
extern int sprotocol_cmd (const char *);
extern int squit_cmd (const char *, const char *);
extern int spart_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 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 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 spong_cmd (const char *reply);
extern int snetinfo_cmd ();
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 ssmo_cmd (const char *from, const char *umodetarget, const char *msg);
extern int snick_cmd (const char *oldnick, const char *newnick);
extern int sswhois_cmd (const char *target, const char *swhois);
extern int ssvsnick_cmd (const char *target, const char *newnick);
extern int ssvsjoin_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 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 ssvsmode_cmd (const char *target, const char *modes);
extern int ssvshost_cmd (const char *who, const char *vhost);
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 srakill_cmd (const char *host, const char *ident);
extern int SignOn_NewBot (const char *, const char *, const char *, const char *, long);
void Usr_Version(char *, char **, int argc);
void Usr_ShowMOTD(char *, char **, int argc);
void Usr_ShowADMIN(char *, char **, int argc);
void Usr_Showcredits(char *, char **, int argc);
void Usr_AddServer(char *, char **, int argc);
void Usr_DelServer(char *, char **, int argc);
void Usr_DelUser(char *, char **, int argc);
void Usr_Mode(char *, char **, int argc);
void Usr_Smode(char *, char **, int argc);
void Usr_Kill(char *, char **, int argc);
void Usr_Pong(char *, char **, int argc);
void Usr_Away(char *, char **, int argc);
void Usr_Nick(char *, char **, int argc);
void Usr_Topic(char *, char **, int argc);
void Usr_Kick(char *, char **, int argc);
void Usr_Join(char *, char **, int argc);
void Usr_Part(char *, char **, int argc);
void Usr_Stats(char *, char **, int argc);
void Usr_Vhost(char *, char **, int argc);
void Srv_Topic(char *, char **, int argc);
void Srv_Ping(char *, char **, int argc);
void Srv_Netinfo(char *, char **, int argc);
void Srv_Pass(char *, char **, int argc);
void Srv_Server(char *, char **, int argc);
void Srv_Squit(char *, char **, int argc);
void Srv_Nick(char *, char **, int argc);
void Srv_Svsnick(char *, char **, int argc);
void Srv_Kill(char *, char **, int argc);
void Srv_Connect(char *, char **, int argc);
void Srv_Svinfo(char *, char **, int argc);
void Srv_Burst(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);
void Usr_Version (char *, char **, int argc);
void Usr_ShowMOTD (char *, char **, int argc);
void Usr_ShowADMIN (char *, char **, int argc);
void Usr_Showcredits (char *, char **, int argc);
void Usr_AddServer (char *, char **, int argc);
void Usr_DelServer (char *, char **, int argc);
void Usr_DelUser (char *, char **, int argc);
void Usr_Mode (char *, char **, int argc);
void Usr_Smode (char *, char **, int argc);
void Usr_Kill (char *, char **, int argc);
void Usr_Pong (char *, char **, int argc);
void Usr_Away (char *, char **, int argc);
void Usr_Nick (char *, char **, int argc);
void Usr_Topic (char *, char **, int argc);
void Usr_Kick (char *, char **, int argc);
void Usr_Join (char *, char **, int argc);
void Usr_Part (char *, char **, int argc);
void Usr_Stats (char *, char **, int argc);
void Usr_Vhost (char *, char **, int argc);
void Srv_Topic (char *, char **, int argc);
void Srv_Ping (char *, char **, int argc);
void Srv_Netinfo (char *, char **, int argc);
void Srv_Pass (char *, char **, int argc);
void Srv_Server (char *, char **, int argc);
void Srv_Squit (char *, char **, int argc);
void Srv_Nick (char *, char **, int argc);
void Srv_Svsnick (char *, char **, int argc);
void Srv_Kill (char *, char **, int argc);
void Srv_Connect (char *, char **, int argc);
void Srv_Svinfo (char *, char **, int argc);
void Srv_Burst (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);
#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. */
#undef HAVEUSE_RPCTYPES_H
@BOTTOM@
@ BOTTOM @
/* Use the definitions: */
#ifndef HAVE_INLINE
#define inline
#endif
#ifdef HAVE_POLL
#include <sys/poll.h>
#else
/* kludge it up */
struct pollfd { int fd; short events; short revents; };
struct pollfd {
int fd;
short events;
short revents;
};
#define POLLIN 1
#define POLLPRI 2
#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
**
** 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"
@ -29,8 +29,8 @@
#include "dl.h"
#include "log.h"
static void cb_Server(char *, int);
static void cb_Module(char *, int);
static void cb_Server (char *, int);
static void cb_Module (char *, int);
/** @brief The list of modules to load
*/
static void *load_mods[NUM_MODULES];
@ -68,7 +68,8 @@ static config_option options[] = {
* @return Nothing
*/
void init_conf()
void
init_conf ()
{
}
@ -80,12 +81,13 @@ void init_conf()
* @retval line the stripped line
*/
void strip(char *line)
void
strip (char *line)
{
char *c;
if ((c = strchr(line, '\n')))
if ((c = strchr (line, '\n')))
*c = '\0';
if ((c = strchr(line, '\r')))
if ((c = strchr (line, '\r')))
*c = '\0';
}
@ -98,39 +100,35 @@ void strip(char *line)
*/
void ConfLoad()
void
ConfLoad ()
{
/* Read in the Config File */
printf("Reading the Config File. Please wait.....\n");
if (!config_read("neostats.cfg", options) == 0) {
printf
("***************************************************\n");
printf
("* Error! *\n");
printf
("* *\n");
printf
("* Config File not found, or Unable to Open *\n");
printf
("* Please check its Location, and try again *\n");
printf
("* *\n");
printf
("* NeoStats NOT Started *\n");
printf
("***************************************************\n");
printf ("Reading the Config File. Please wait.....\n");
if (!config_read ("neostats.cfg", options) == 0) {
printf ("***************************************************\n");
printf ("* Error! *\n");
printf ("* *\n");
printf ("* Config File not found, or Unable to Open *\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! */
exit(0);
exit (0);
}
printf("Sucessfully Loaded Config File, Now Booting NeoStats\n");
printf ("Sucessfully Loaded Config File, Now Booting NeoStats\n");
#ifdef EXTAUTH
load_module("extauth", NULL);
load_module ("extauth", NULL);
#endif
/* 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;
}
if (GetConf ((void *) &me.pingtime, CFGINT, "PingServerTime") <= 0) {
me.pingtime = 120;
}
done_mods = 0;
}
@ -144,19 +142,19 @@ void ConfLoad()
* @returns Nothing
*/
void cb_Module(char *arg, int configtype)
void
cb_Module (char *arg, int configtype)
{
int i;
strcpy(segv_location, "cb_Module");
strcpy (segv_location, "cb_Module");
if (!config.modnoload) {
for (i = 1; (i < NUM_MODULES) && (load_mods[i] != 0); i++) {
if (!strcasecmp(load_mods[i], arg)) {
if (!strcasecmp (load_mods[i], arg)) {
return;
}
}
load_mods[i] = sstrdup(arg);
nlog(LOG_NORMAL, LOG_CORE, "Added Module %d :%s", i,
load_mods[i]);
load_mods[i] = sstrdup (arg);
nlog (LOG_NORMAL, LOG_CORE, "Added Module %d :%s", 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
*/
int init_modules()
int
init_modules ()
{
int i;
int rval;
strcpy(segv_location, "init_modules");
strcpy (segv_location, "init_modules");
for (i = 1; (i < NUM_MODULES) && (load_mods[i] != 0); i++) {
nlog(LOG_DEBUG1, LOG_CORE, "Loading Module %s",
load_mods[i]);
rval = load_module(load_mods[i], NULL);
nlog (LOG_DEBUG1, LOG_CORE, "Loading Module %s", load_mods[i]);
rval = load_module (load_mods[i], NULL);
if (!rval) {
nlog(LOG_NORMAL, LOG_CORE,
"Successfully Loaded Module %s",
load_mods[i]);
nlog (LOG_NORMAL, LOG_CORE, "Successfully Loaded Module %s", load_mods[i]);
} else {
nlog(LOG_WARNING, LOG_CORE,
"Could Not Load Module %s, Please check above error Messages",
load_mods[i]);
nlog (LOG_WARNING, LOG_CORE, "Could Not Load Module %s, Please check above error Messages", load_mods[i]);
}
}
return 1;
@ -201,46 +195,47 @@ int init_modules()
* @param configtype the index of the variable being called now
* @returns Nothing
*/
void cb_Server(char *arg, int configtype)
void
cb_Server (char *arg, int configtype)
{
if (configtype == 0) {
/* Server name */
memcpy(me.name, arg, sizeof(me.name));
memcpy (me.name, arg, sizeof (me.name));
} else if (configtype == 1) {
/* Server Port */
me.port = atoi(arg);
me.port = atoi (arg);
} else if (configtype == 2) {
/* Connect To */
memcpy(me.uplink, arg, sizeof(me.uplink));
memcpy (me.uplink, arg, sizeof (me.uplink));
} else if (configtype == 3) {
/* Connect Pass */
memcpy(me.pass, arg, sizeof(me.pass));
memcpy (me.pass, arg, sizeof (me.pass));
} else if (configtype == 4) {
/* Server InfoLine */
memcpy(me.infoline, arg, sizeof(me.infoline));
memcpy (me.infoline, arg, sizeof (me.infoline));
} else if (configtype == 5) {
/* NetName */
memcpy(me.netname, arg, sizeof(me.netname));
memcpy (me.netname, arg, sizeof (me.netname));
} else if (configtype == 6) {
/* Reconnect time */
me.r_time = atoi(arg);
me.r_time = atoi (arg);
} else if (configtype == 7) {
/* NeoStat Host */
memcpy(Servbot.host, arg, sizeof(Servbot.host));
memcpy (Servbot.host, arg, sizeof (Servbot.host));
} else if (configtype == 8) {
/* NeoStat User */
memcpy(Servbot.user, arg, sizeof(Servbot.user));
memcpy (Servbot.user, arg, sizeof (Servbot.user));
} else if (configtype == 9) {
me.want_privmsg = 1;
} else if (configtype == 10) {
memcpy(me.chan, arg, sizeof(me.chan));
memcpy (me.chan, arg, sizeof (me.chan));
} else if (configtype == 11) {
me.onlyopers = 1;
} else if (configtype == 12) {
me.die = 1;
} 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
*/
void rehash()
void
rehash ()
{
/* nothing, yet */
}

16
conf.h
View file

@ -20,7 +20,7 @@
** USA
**
** 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 */
unsigned int debug;
/* enable recv.log */
unsigned int recvlog : 1;
unsigned int recvlog:1;
/* dont load modules on startup */
unsigned int modnoload : 1;
unsigned int modnoload:1;
/* dont output anything on start */
unsigned int quiet : 1;
unsigned int quiet:1;
/* dont detach into background */
unsigned int foreground : 1;
unsigned int foreground:1;
} config;
int GetConf(void **data, int type, const char *item);
int SetConf(void *data, int type, char *item);
int GetDir(char *item, char ***data);
int GetConf (void **data, int type, const char *item);
int SetConf (void *data, int type, char *item);
int GetDir (char *item, char ***data);
#endif

733
dl.c

File diff suppressed because it is too large Load diff

64
dl.h
View file

@ -20,7 +20,7 @@
** USA
**
** 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"
#ifndef RTLD_NOW
#define RTLD_NOW RTLD_LAZY /* openbsd deficiency */
#define RTLD_NOW RTLD_LAZY /* openbsd deficiency */
#endif
#ifndef RTLD_GLOBAL
#define RTLD_GLOBAL 0
#endif
extern char *sftime(time_t);
extern char *sftime (time_t);
struct sock_list_struct {
long hash;
int sock_no;
char sockname[MAXHOST];
int (*readfnc)(int sock_no, char *sockname);
int (*writefnc)(int sock_no, char *sockname);
int (*errfnc)(int sock_no, char *sockname);
int (*readfnc) (int sock_no, char *sockname);
int (*writefnc) (int sock_no, char *sockname);
int (*errfnc) (int sock_no, char *sockname);
char modname[MAXHOST];
long rmsgs;
long rbytes;
@ -69,7 +69,7 @@ struct mod_timer_list {
char timername[MAXHOST];
int interval;
time_t lastrun;
int (*function)();
int (*function) ();
};
typedef struct mod_timer_list Mod_Timer;
hash_t *th;
@ -78,8 +78,8 @@ struct mod_user_list {
long hash;
char nick[MAXNICK];
char modname[MAXHOST];
int (*function)(char *origin, char **av, int ac);
int (*chanfunc)(char *origin, char *chan, char **av, int ac);
int (*function) (char *origin, char **av, int ac);
int (*chanfunc) (char *origin, char *chan, char **av, int ac);
hash_t *chanlist;
};
@ -97,13 +97,13 @@ hash_t *bch;
struct functions {
char *cmd_name;
int (*function)(char *origin, char **av, int ac);
int (*function) (char *origin, char **av, int ac);
int srvmsg;
};
struct evtfunctions {
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];
extern void __init_mod_list();
extern int load_module(char *path,User *u);
extern int unload_module(char *module_name,User *u);
extern int add_ld_path(char *path);
extern void list_module(User *);
extern void list_module_bots(User *);
extern int add_mod_user(char *nick, char *mod_name);
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 del_mod_timer(char *timer_name);
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 del_socket(char *sockname);
extern void list_sockets(User *);
extern Sock_List *findsock(char *sock_name);
extern Mod_User *findbot(char *);
extern int get_dl_handle(char *mod_name);
extern void add_bot_to_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 botchandump(User *u);
extern void __init_mod_list ();
extern int load_module (char *path, User * u);
extern int unload_module (char *module_name, User * u);
extern int add_ld_path (char *path);
extern void list_module (User *);
extern void list_module_bots (User *);
extern int add_mod_user (char *nick, char *mod_name);
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 del_mod_timer (char *timer_name);
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 del_socket (char *sockname);
extern void list_sockets (User *);
extern Sock_List *findsock (char *sock_name);
extern Mod_User *findbot (char *);
extern int get_dl_handle (char *mod_name);
extern void add_bot_to_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 botchandump (User * u);
#endif /* !_dl_h_ */

125
dns.c
View file

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

211
dotconf.c
View file

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

View file

@ -20,7 +20,7 @@
** USA
**
** 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
/* some buffersize definitions */
#define CFG_BUFSIZE 4096 /* max length of one line */
#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_FILENAME 256 /* max length of a filename */
#define CFG_VALUES 16 /* max # of arguments an option takes */
#define CFG_MODULES 64 /* max # of dynamically loadable modules */
#define CFG_BUFSIZE 4096 /* max length of one line */
#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_FILENAME 256 /* max length of a filename */
#define CFG_VALUES 16 /* max # of arguments an option takes */
#define CFG_MODULES 64 /* max # of dynamically loadable modules */
#define CFG_INCLUDEPATH_ENV "DC_INCLUDEPATH"
/* constants for type of option */
#define ARG_TOGGLE 0 /* TOGGLE on,off; yes,no; 1, 0; */
#define ARG_INT 1 /* callback wants an integer */
#define ARG_STR 2 /* callback expects a \0 terminated str */
#define ARG_LIST 3 /* wants list of strings */
#define ARG_NAME 4 /* wants option name */
#define ARG_RAW 5 /* wants raw argument data */
#define ARG_NONE 6 /* does not expect ANY args */
#define ARG_TOGGLE 0 /* TOGGLE on,off; yes,no; 1, 0; */
#define ARG_INT 1 /* callback wants an integer */
#define ARG_STR 2 /* callback expects a \0 terminated str */
#define ARG_LIST 3 /* wants list of strings */
#define ARG_NAME 4 /* wants option name */
#define ARG_RAW 5 /* wants raw argument data */
#define ARG_NONE 6 /* does not expect ANY args */
/* for convenience of terminating the config_options list */
#define LAST_OPTION { "", 0, NULL, 0 }
typedef struct _cfgoption {
char name[CFG_MAX_OPTION]; /* name of configuration option */
int type; /* for possible values, see above */
void (*callback)(); /* callback function */
int userdata; /* userdefinable value/flag */
char name[CFG_MAX_OPTION]; /* name of configuration option */
int type; /* for possible values, see above */
void (*callback) (); /* callback function */
int userdata; /* userdefinable value/flag */
} config_option;
@ -62,7 +62,7 @@ typedef struct _cfgoption {
* 2. the list of optionnames to recognize
*
* returns 0 on success; !0 on error */
int config_read(char *, config_option *);
void config_register_options(config_option *);
int config_read (char *, 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
* 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: $
*/
@ -54,8 +54,7 @@
#ifdef KAZLIB_RCSID
static const char rcsid[] =
"$Id: hash.c,v 1.10 2003/07/17 10:13:51 fishwaldo Exp $";
static const char rcsid[] = "$Id: hash.c,v 1.11 2003/07/30 13:58:22 fishwaldo Exp $";
#endif
#define INIT_BITS 6
@ -84,10 +83,10 @@ static const char rcsid[] =
#define table hash_table
#define chain hash_chain
static hnode_t *hnode_alloc(void *context);
static void hnode_free(hnode_t * node, void *context);
static hash_val_t hash_fun_default(const void *key);
static int hash_comp_default(const void *key1, const void *key2);
static hnode_t *hnode_alloc (void *context);
static void hnode_free (hnode_t * node, void *context);
static hash_val_t hash_fun_default (const void *key);
static int hash_comp_default (const void *key1, const void *key2);
int hash_val_t_bit;
@ -104,7 +103,8 @@ int hash_val_t_bit;
* 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 */
int bits = 0;
@ -121,7 +121,8 @@ static void compute_bits(void)
* 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)
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
*/
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(size >= 2);
nassert (is_power_of_two (size));
nassert (size >= 2);
return size - 1;
}
@ -146,7 +148,8 @@ static hash_val_t compute_mask(hashcount_t size)
* 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;
@ -182,27 +185,26 @@ static void clear_table(hash_t * hash)
* 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;
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 */
hash_val_t mask = (hash->mask << 1) | 1; /* 3 */
hash_val_t exposed_bit = mask ^ hash->mask; /* 6 */
hash_val_t chain;
nassert(mask != hash->mask);
nassert (mask != hash->mask);
for (chain = 0; chain < hash->nchains; chain++) { /* 7 */
hnode_t *low_chain = 0, *high_chain =
0, *hptr, *next;
hnode_t *low_chain = 0, *high_chain = 0, *hptr, *next;
for (hptr = newtable[chain]; hptr != 0;
hptr = next) {
for (hptr = newtable[chain]; hptr != 0; hptr = next) {
next = hptr->next;
if (hptr->hkey & exposed_bit) {
@ -224,7 +226,7 @@ static void grow_table(hash_t * hash)
hash->lowmark *= 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.
*/
static void shrink_table(hash_t * hash)
static void
shrink_table (hash_t * hash)
{
hash_val_t chain, nchains;
hnode_t **newtable, *low_tail, *low_chain, *high_chain;
nassert(hash->nchains >= 2); /* 1 */
nassert (hash->nchains >= 2); /* 1 */
nchains = hash->nchains / 2;
for (chain = 0; chain < nchains; chain++) {
@ -274,16 +277,16 @@ static void shrink_table(hash_t * hash)
else if (high_chain != 0) /* 5 */
hash->table[chain] = high_chain;
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 */
hash->table = newtable;
hash->mask >>= 1; /* 9 */
hash->nchains = nchains;
hash->lowmark /= 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.
*/
hash_t *hash_create(hashcount_t maxcount, hash_comp_t compfun,
hash_fun_t hashfun)
hash_t *
hash_create (hashcount_t maxcount, hash_comp_t compfun, hash_fun_t hashfun)
{
hash_t *hash;
if (hash_val_t_bit == 0) /* 1 */
compute_bits();
compute_bits ();
hash = malloc(sizeof *hash); /* 2 */
hash = malloc (sizeof *hash); /* 2 */
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 */
hash->nchains = INIT_SIZE; /* 6 */
hash->highmark = INIT_SIZE * 2;
hash->lowmark = INIT_SIZE / 2;
hash->nodecount = 0;
hash->maxcount = maxcount;
hash->compare =
compfun ? compfun : hash_comp_default;
hash->function =
hashfun ? hashfun : hash_fun_default;
hash->compare = compfun ? compfun : hash_comp_default;
hash->function = hashfun ? hashfun : hash_fun_default;
hash->allocnode = hnode_alloc;
hash->freenode = hnode_free;
hash->context = NULL;
hash->mask = INIT_MASK;
hash->dynamic = 1; /* 7 */
clear_table(hash); /* 8 */
nassert(hash_verify(hash));
clear_table (hash); /* 8 */
nassert (hash_verify (hash));
return hash;
}
free(hash);
free (hash);
}
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.
*/
void hash_set_allocator(hash_t * hash, hnode_alloc_t al,
hnode_free_t fr, void *context)
void
hash_set_allocator (hash_t * hash, hnode_alloc_t al, hnode_free_t fr, void *context)
{
nassert(hash_count(hash) == 0);
nassert((al == 0 && fr == 0) || (al != 0 && fr != 0));
nassert (hash_count (hash) == 0);
nassert ((al == 0 && fr == 0) || (al != 0 && fr != 0));
hash->allocnode = al ? al : hnode_alloc;
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.
*/
void hash_free_nodes(hash_t * hash)
void
hash_free_nodes (hash_t * hash)
{
hscan_t hs;
hnode_t *node;
hash_scan_begin(&hs, hash);
while ((node = hash_scan_next(&hs))) {
hash_scan_delete(hash, node);
hash->freenode(node, hash->context);
hash_scan_begin (&hs, hash);
while ((node = hash_scan_next (&hs))) {
hash_scan_delete (hash, node);
hash->freenode (node, hash->context);
}
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.
*/
void hash_free(hash_t * hash)
void
hash_free (hash_t * hash)
{
#ifdef KAZLIB_OBSOLESCENT_DEBUG
nassert("call to obsolescent function hash_free()" && 0);
nassert ("call to obsolescent function hash_free()" && 0);
#endif
hash_free_nodes(hash);
hash_destroy(hash);
hash_free_nodes (hash);
hash_destroy (hash);
}
/*
* 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_isempty(hash));
free(hash->table);
free(hash);
nassert (hash_val_t_bit != 0);
nassert (hash_isempty (hash));
free (hash->table);
free (hash);
}
/*
@ -425,14 +429,13 @@ void hash_destroy(hash_t * hash)
* so we reset it here.
*/
hash_t *hash_init(hash_t * hash, hashcount_t maxcount,
hash_comp_t compfun, hash_fun_t hashfun,
hnode_t ** table, hashcount_t nchains)
hash_t *
hash_init (hash_t * hash, hashcount_t maxcount, hash_comp_t compfun, hash_fun_t hashfun, hnode_t ** table, hashcount_t nchains)
{
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->nchains = nchains;
@ -441,10 +444,10 @@ hash_t *hash_init(hash_t * hash, hashcount_t maxcount,
hash->compare = compfun ? compfun : hash_comp_default;
hash->function = hashfun ? hashfun : hash_fun_default;
hash->dynamic = 0; /* 3 */
hash->mask = compute_mask(nchains); /* 4 */
clear_table(hash); /* 5 */
hash->mask = compute_mask (nchains); /* 4 */
clear_table (hash); /* 5 */
nassert(hash_verify(hash));
nassert (hash_verify (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.
*/
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 chain;
@ -469,8 +473,7 @@ void hash_scan_begin(hscan_t * scan, hash_t * hash)
/* 1 */
for (chain = 0; chain < nchains && hash->table[chain] == 0;
chain++);
for (chain = 0; chain < nchains && hash->table[chain] == 0; chain++);
if (chain < nchains) { /* 2 */
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 */
hash_t *hash = scan->table;
hash_val_t chain = scan->chain + 1;
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->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.
*/
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;
nassert(hash_val_t_bit != 0);
nassert(node->next == NULL);
nassert(hash->nodecount < hash->maxcount); /* 1 */
nassert(hash_lookup(hash, key) == NULL); /* 2 */
nassert (hash_val_t_bit != 0);
nassert (node->next == NULL);
nassert (hash->nodecount < hash->maxcount); /* 1 */
nassert (hash_lookup (hash, key) == NULL); /* 2 */
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 */
node->key = key;
@ -566,7 +571,7 @@ void hash_insert(hash_t * hash, hnode_t * node, const void *key)
hash->table[chain] = node;
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.
*/
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;
hnode_t *nptr;
hkey = hash->function(key); /* 1 */
hkey = hash->function (key); /* 1 */
chain = hkey & hash->mask; /* 2 */
for (nptr = hash->table[chain]; nptr; nptr = nptr->next) { /* 3 */
if (nptr->hkey == hkey
&& hash->compare(nptr->key, key) == 0)
if (nptr->hkey == hkey && hash->compare (nptr->key, key) == 0)
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.
*/
hnode_t *hash_delete(hash_t * hash, hnode_t * node)
hnode_t *
hash_delete (hash_t * hash, hnode_t * node)
{
hash_val_t chain;
hnode_t *hptr;
nassert(hash_lookup(hash, node->key) == node); /* 1 */
nassert(hash_val_t_bit != 0);
nassert (hash_lookup (hash, node->key) == node); /* 1 */
nassert (hash_val_t_bit != 0);
if (hash->dynamic && hash->nodecount <= hash->lowmark
&& hash->nodecount > INIT_SIZE)
shrink_table(hash); /* 2 */
if (hash->dynamic && hash->nodecount <= hash->lowmark && hash->nodecount > INIT_SIZE)
shrink_table (hash); /* 2 */
chain = node->hkey & hash->mask; /* 3 */
hptr = hash->table[chain];
@ -637,36 +642,38 @@ hnode_t *hash_delete(hash_t * hash, hnode_t * node)
hash->table[chain] = node->next;
} else {
while (hptr->next != node) { /* 5 */
nassert(hptr != 0);
nassert (hptr != 0);
hptr = hptr->next;
}
nassert(hptr->next == node);
nassert (hptr->next == node);
hptr->next = node->next;
}
hash->nodecount--;
nassert(hash_verify(hash));
nassert (hash_verify (hash));
node->next = NULL; /* 6 */
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) {
hnode_init(node, data);
hash_insert(hash, node, key);
hnode_init (node, data);
hash_insert (hash, node, key);
return 1;
}
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->freenode(node, hash->context);
hash_delete (hash, node);
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.
*/
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;
hnode_t *hptr;
nassert(hash_lookup(hash, node->key) == node);
nassert(hash_val_t_bit != 0);
nassert (hash_lookup (hash, node->key) == node);
nassert (hash_val_t_bit != 0);
chain = node->hkey & hash->mask;
hptr = hash->table[chain];
@ -694,7 +702,7 @@ hnode_t *hash_scan_delete(hash_t * hash, hnode_t * node)
}
hash->nodecount--;
nassert(hash_verify(hash));
nassert (hash_verify (hash));
node->next = NULL;
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.
*/
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->freenode(node, hash->context);
hash_scan_delete (hash, node);
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.
*/
int hash_verify(hash_t * hash)
int
hash_verify (hash_t * hash)
{
hashcount_t count = 0;
hash_val_t chain;
@ -728,15 +738,14 @@ int hash_verify(hash_t * hash)
if (hash->dynamic) { /* 1 */
if (hash->lowmark >= hash->highmark)
return 0;
if (!is_power_of_two(hash->highmark))
if (!is_power_of_two (hash->highmark))
return 0;
if (!is_power_of_two(hash->lowmark))
if (!is_power_of_two (hash->lowmark))
return 0;
}
for (chain = 0; chain < hash->nchains; chain++) { /* 2 */
for (hptr = hash->table[chain]; hptr != 0;
hptr = hptr->next) {
for (hptr = hash->table[chain]; hptr != 0; hptr = hptr->next) {
if ((hptr->hkey & hash->mask) != chain)
return 0;
count++;
@ -755,7 +764,8 @@ int hash_verify(hash_t * hash)
*/
#undef hash_isfull
int hash_isfull(hash_t * hash)
int
hash_isfull (hash_t * hash)
{
return hash->nodecount == hash->maxcount;
}
@ -766,19 +776,22 @@ int hash_isfull(hash_t * hash)
*/
#undef hash_isempty
int hash_isempty(hash_t * hash)
int
hash_isempty (hash_t * hash)
{
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.
*/
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) {
node->data = data;
node->next = NULL;
@ -800,7 +814,8 @@ hnode_t *hnode_create(void *data)
* 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->next = NULL;
@ -811,42 +826,49 @@ hnode_t *hnode_init(hnode_t * hnode, void *data)
* Destroy a dynamically allocated node.
*/
void hnode_destroy(hnode_t * hnode)
void
hnode_destroy (hnode_t * hnode)
{
free(hnode);
free (hnode);
}
#undef hnode_put
void hnode_put(hnode_t * node, void *data)
void
hnode_put (hnode_t * node, void *data)
{
node->data = data;
}
#undef hnode_get
void *hnode_get(hnode_t * node)
void *
hnode_get (hnode_t * node)
{
return node->data;
}
#undef hnode_getkey
const void *hnode_getkey(hnode_t * node)
const void *
hnode_getkey (hnode_t * node)
{
return node->key;
}
#undef hash_count
hashcount_t hash_count(hash_t * hash)
hashcount_t
hash_count (hash_t * hash)
{
return hash->nodecount;
}
#undef hash_size
hashcount_t hash_size(hash_t * hash)
hashcount_t
hash_size (hash_t * hash)
{
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[] = {
0x49848f1bU, 0xe6255dbaU, 0x36da5bdcU, 0x47bf94e9U,
@ -859,19 +881,20 @@ static hash_val_t hash_fun_default(const void *key)
hash_val_t acc = 0;
while (*str) {
acc ^= randbox[(tolower(*str) + acc) & 0xf];
acc ^= randbox[(tolower (*str) + acc) & 0xf];
acc = (acc << 1) | (acc >> 31);
acc &= 0xffffffffU;
acc ^= randbox[((tolower(*str++) >> 4) + acc) & 0xf];
acc ^= randbox[((tolower (*str++) >> 4) + acc) & 0xf];
acc = (acc << 2) | (acc >> 30);
acc &= 0xffffffffU;
}
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
@ -882,43 +905,46 @@ static int hash_comp_default(const void *key1, const void *key2)
typedef char input_t[256];
static int tokenize(char *string, ...)
static int
tokenize (char *string, ...)
{
char **tokptr;
va_list arglist;
int tokcount = 0;
va_start(arglist, string);
tokptr = va_arg(arglist, char **);
va_start (arglist, string);
tokptr = va_arg (arglist, char **);
while (tokptr) {
while (*string && isspace((unsigned char) *string))
while (*string && isspace ((unsigned char) *string))
string++;
if (!*string)
break;
*tokptr = string;
while (*string && !isspace((unsigned char) *string))
while (*string && !isspace ((unsigned char) *string))
string++;
tokptr = va_arg(arglist, char **);
tokptr = va_arg (arglist, char **);
tokcount++;
if (!*string)
break;
*string++ = 0;
}
va_end(arglist);
va_end (arglist);
return tokcount;
}
static char *dupstring(char *str)
static char *
dupstring (char *str)
{
int sz = strlen(str) + 1;
char *new = malloc(sz);
int sz = strlen (str) + 1;
char *new = malloc (sz);
if (new)
memcpy(new, str, sz);
memcpy (new, str, sz);
return new;
}
static hnode_t *new_node(void *c)
static hnode_t *
new_node (void *c)
{
static hnode_t few[5];
static int count;
@ -929,14 +955,16 @@ static hnode_t *new_node(void *c)
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;
hash_t *h = hash_create(HASHCOUNT_T_MAX, 0, 0);
hash_t *h = hash_create (HASHCOUNT_T_MAX, 0, 0);
hnode_t *hn;
hscan_t hs;
char *tok1, *tok2, *val;
@ -944,109 +972,104 @@ int main(void)
int prompt = 0;
char *help =
"a <key> <val> add value to hash table\n"
"d <key> delete value from hash table\n"
"l <key> lookup value in hash table\n"
"n show size of hash table\n"
"c show number of entries\n"
"t dump whole hash table\n"
"+ increase hash table (private func)\n"
"- decrease hash table (private func)\n"
"b print hash_t_bit value\n"
"p turn prompt on\n"
"s switch to non-functioning allocator\n"
"q quit";
"a <key> <val> add value to hash table\n"
"d <key> delete value from hash table\n"
"l <key> lookup value in hash table\n"
"n show size of hash table\n"
"c show number of entries\n"
"t dump whole hash table\n"
"+ increase hash table (private func)\n"
"- decrease hash table (private func)\n"
"b print hash_t_bit value\n"
"p turn prompt on\n" "s switch to non-functioning allocator\n" "q quit";
if (!h)
puts("hash_create failed");
puts ("hash_create failed");
for (;;) {
if (prompt)
putchar('>');
fflush(stdout);
putchar ('>');
fflush (stdout);
if (!fgets(in, sizeof(input_t), stdin))
if (!fgets (in, sizeof (input_t), stdin))
break;
switch (in[0]) {
case '?':
puts(help);
puts (help);
break;
case 'b':
printf("%d\n", hash_val_t_bit);
printf ("%d\n", hash_val_t_bit);
break;
case 'a':
if (tokenize(in + 1, &tok1, &tok2, (char **) 0) !=
2) {
puts("what?");
if (tokenize (in + 1, &tok1, &tok2, (char **) 0) != 2) {
puts ("what?");
break;
}
key = dupstring(tok1);
val = dupstring(tok2);
key = dupstring (tok1);
val = dupstring (tok2);
if (!key || !val) {
puts("out of memory");
free((void *) key);
free(val);
puts ("out of memory");
free ((void *) key);
free (val);
}
if (!hash_alloc_insert(h, key, val)) {
puts("hash_alloc_insert failed");
free((void *) key);
free(val);
if (!hash_alloc_insert (h, key, val)) {
puts ("hash_alloc_insert failed");
free ((void *) key);
free (val);
break;
}
break;
case 'd':
if (tokenize(in + 1, &tok1, (char **) 0) != 1) {
puts("what?");
if (tokenize (in + 1, &tok1, (char **) 0) != 1) {
puts ("what?");
break;
}
hn = hash_lookup(h, tok1);
hn = hash_lookup (h, tok1);
if (!hn) {
puts("hash_lookup failed");
puts ("hash_lookup failed");
break;
}
val = hnode_get(hn);
key = hnode_getkey(hn);
hash_scan_delfree(h, hn);
free((void *) key);
free(val);
val = hnode_get (hn);
key = hnode_getkey (hn);
hash_scan_delfree (h, hn);
free ((void *) key);
free (val);
break;
case 'l':
if (tokenize(in + 1, &tok1, (char **) 0) != 1) {
puts("what?");
if (tokenize (in + 1, &tok1, (char **) 0) != 1) {
puts ("what?");
break;
}
hn = hash_lookup(h, tok1);
hn = hash_lookup (h, tok1);
if (!hn) {
puts("hash_lookup failed");
puts ("hash_lookup failed");
break;
}
val = hnode_get(hn);
puts(val);
val = hnode_get (hn);
puts (val);
break;
case 'n':
printf("%lu\n", (unsigned long) hash_size(h));
printf ("%lu\n", (unsigned long) hash_size (h));
break;
case 'c':
printf("%lu\n", (unsigned long) hash_count(h));
printf ("%lu\n", (unsigned long) hash_count (h));
break;
case 't':
hash_scan_begin(&hs, h);
while ((hn = hash_scan_next(&hs)))
printf("%s\t%s\n",
(char *) hnode_getkey(hn),
(char *) hnode_get(hn));
hash_scan_begin (&hs, h);
while ((hn = hash_scan_next (&hs)))
printf ("%s\t%s\n", (char *) hnode_getkey (hn), (char *) hnode_get (hn));
break;
case '+':
grow_table(h); /* private function */
grow_table (h); /* private function */
break;
case '-':
shrink_table(h); /* private function */
shrink_table (h); /* private function */
break;
case 'q':
exit(0);
exit (0);
break;
case '\0':
break;
@ -1054,11 +1077,11 @@ int main(void)
prompt = 1;
break;
case 's':
hash_set_allocator(h, new_node, del_node, NULL);
hash_set_allocator (h, new_node, del_node, NULL);
break;
default:
putchar('?');
putchar('\n');
putchar ('?');
putchar ('\n');
break;
}
}

146
hash.h
View file

@ -37,7 +37,7 @@
* into proprietary software; there is no requirement for such software to
* 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: $
*/
@ -57,13 +57,13 @@
extern "C" {
#endif
typedef unsigned long hashcount_t;
typedef unsigned long hashcount_t;
#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
extern int hash_val_t_bit;
extern int hash_val_t_bit;
#ifndef 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.
*/
typedef struct hnode_t {
#if defined(HASH_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG) /* 1 */
struct hnode_t *hash_next; /* 2 */
const void *hash_key; /* 3 */
void *hash_data; /* 4 */
hash_val_t hash_hkey; /* 5 */
#else
int hash_dummy;
#endif
} hnode_t;
typedef struct hnode_t {
#if defined(HASH_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG) /* 1 */
struct hnode_t *hash_next; /* 2 */
const void *hash_key; /* 3 */
void *hash_data; /* 4 */
hash_val_t hash_hkey; /* 5 */
#else
int hash_dummy;
#endif
} hnode_t;
/*
* The comparison function pointer type. A comparison function takes two keys
@ -111,7 +111,7 @@ typedef struct hnode_t {
* 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
@ -125,14 +125,14 @@ typedef int (*hash_comp_t)(const void *, const void *);
* 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
*/
typedef hnode_t *(*hnode_alloc_t)(void *);
typedef void (*hnode_free_t)(hnode_t *, void *);
typedef hnode_t *(*hnode_alloc_t) (void *);
typedef void (*hnode_free_t) (hnode_t *, void *);
/*
* 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.
*/
typedef struct hash_t {
#if defined(HASH_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
struct hnode_t **hash_table; /* 1 */
hashcount_t hash_nchains; /* 2 */
hashcount_t hash_nodecount; /* 3 */
hashcount_t hash_maxcount; /* 4 */
hashcount_t hash_highmark; /* 5 */
hashcount_t hash_lowmark; /* 6 */
hash_comp_t hash_compare; /* 7 */
hash_fun_t hash_function; /* 8 */
hnode_alloc_t hash_allocnode;
hnode_free_t hash_freenode;
void *hash_context;
hash_val_t hash_mask; /* 9 */
int hash_dynamic; /* 10 */
#else
int hash_dummy;
#endif
} hash_t;
typedef struct hash_t {
#if defined(HASH_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
struct hnode_t **hash_table; /* 1 */
hashcount_t hash_nchains; /* 2 */
hashcount_t hash_nodecount; /* 3 */
hashcount_t hash_maxcount; /* 4 */
hashcount_t hash_highmark; /* 5 */
hashcount_t hash_lowmark; /* 6 */
hash_comp_t hash_compare; /* 7 */
hash_fun_t hash_function; /* 8 */
hnode_alloc_t hash_allocnode;
hnode_free_t hash_freenode;
void *hash_context;
hash_val_t hash_mask; /* 9 */
int hash_dynamic; /* 10 */
#else
int hash_dummy;
#endif
} hash_t;
/*
* Hash scanner structure, used for traversals of the data structure.
@ -199,48 +199,47 @@ typedef struct hash_t {
* hash_scan_next().
*/
typedef struct hscan_t {
#if defined(HASH_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
hash_t *hash_table; /* 1 */
hash_val_t hash_chain; /* 2 */
hnode_t *hash_next; /* 3 */
#else
int hash_dummy;
#endif
} hscan_t;
typedef struct hscan_t {
#if defined(HASH_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
hash_t *hash_table; /* 1 */
hash_val_t hash_chain; /* 2 */
hnode_t *hash_next; /* 3 */
#else
int hash_dummy;
#endif
} hscan_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_destroy(hash_t *);
extern void hash_free_nodes(hash_t *);
extern void hash_free(hash_t *);
extern hash_t *hash_init(hash_t *, hashcount_t, hash_comp_t,
hash_fun_t, hnode_t **, hashcount_t);
extern void hash_insert(hash_t *, hnode_t *, const void *);
extern hnode_t *hash_lookup(hash_t *, const void *);
extern hnode_t *hash_delete(hash_t *, hnode_t *);
extern int hash_alloc_insert(hash_t *, const void *, void *);
extern void hash_delete_free(hash_t *, hnode_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_destroy (hash_t *);
extern void hash_free_nodes (hash_t *);
extern void hash_free (hash_t *);
extern hash_t *hash_init (hash_t *, hashcount_t, hash_comp_t, hash_fun_t, hnode_t **, hashcount_t);
extern void hash_insert (hash_t *, hnode_t *, const void *);
extern hnode_t *hash_lookup (hash_t *, const void *);
extern hnode_t *hash_delete (hash_t *, hnode_t *);
extern int hash_alloc_insert (hash_t *, const void *, void *);
extern void hash_delete_free (hash_t *, hnode_t *);
extern void hnode_put(hnode_t *, void *);
extern void *hnode_get(hnode_t *);
extern const void *hnode_getkey(hnode_t *);
extern hashcount_t hash_count(hash_t *);
extern hashcount_t hash_size(hash_t *);
extern void hnode_put (hnode_t *, void *);
extern void *hnode_get (hnode_t *);
extern const void *hnode_getkey (hnode_t *);
extern hashcount_t hash_count (hash_t *);
extern hashcount_t hash_size (hash_t *);
extern int hash_isfull(hash_t *);
extern int hash_isempty(hash_t *);
extern int hash_isfull (hash_t *);
extern int hash_isempty (hash_t *);
extern void hash_scan_begin(hscan_t *, hash_t *);
extern hnode_t *hash_scan_next(hscan_t *);
extern hnode_t *hash_scan_delete(hash_t *, hnode_t *);
extern void hash_scan_delfree(hash_t *, hnode_t *);
extern void hash_scan_begin (hscan_t *, hash_t *);
extern hnode_t *hash_scan_next (hscan_t *);
extern hnode_t *hash_scan_delete (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_init(hnode_t *, void *);
extern void hnode_destroy(hnode_t *);
extern hnode_t *hnode_create (void *);
extern hnode_t *hnode_init (hnode_t *, void *);
extern void hnode_destroy (hnode_t *);
#if defined(HASH_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
#ifdef KAZLIB_SIDEEFFECT_DEBUG
@ -259,5 +258,4 @@ extern void hnode_destroy(hnode_t *);
#ifdef __cplusplus
}
#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
**
** 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_WHO "WHO" /* WHO -> WHOC */
#define MSG_WHOIS "WHOIS" /* WHOI */
#define MSG_WHO "WHO" /* WHO -> WHOC */
#define MSG_WHOIS "WHOIS" /* WHOI */
#define MSG_WHOWAS "WHOWAS" /* WHOW */
#define MSG_USER "USER" /* USER */
#define MSG_NICK "NICK" /* NICK */
#define MSG_USER "USER" /* USER */
#define MSG_NICK "NICK" /* NICK */
#define MSG_SERVER "SERVER" /* SERV */
#define MSG_LIST "LIST" /* LIST */
#define MSG_TOPIC "TOPIC" /* TOPI */
#define MSG_LIST "LIST" /* LIST */
#define MSG_TOPIC "TOPIC" /* TOPI */
#define MSG_INVITE "INVITE" /* INVI */
#define MSG_VERSION "VERSION" /* VERS */
#define MSG_QUIT "QUIT" /* QUIT */
#define MSG_SQUIT "SQUIT" /* SQUI */
#define MSG_KILL "KILL" /* KILL */
#define MSG_INFO "INFO" /* INFO */
#define MSG_LINKS "LINKS" /* LINK */
#define MSG_WATCH "WATCH" /* WATCH */
#define MSG_STATS "STATS" /* STAT */
#define MSG_HELP "HELP" /* HELP */
#define MSG_QUIT "QUIT" /* QUIT */
#define MSG_SQUIT "SQUIT" /* SQUI */
#define MSG_KILL "KILL" /* KILL */
#define MSG_INFO "INFO" /* INFO */
#define MSG_LINKS "LINKS" /* LINK */
#define MSG_WATCH "WATCH" /* WATCH */
#define MSG_STATS "STATS" /* STAT */
#define MSG_HELP "HELP" /* HELP */
#define MSG_HELPOP "HELPOP" /* HELP */
#define MSG_ERROR "ERROR" /* ERRO */
#define MSG_AWAY "AWAY" /* AWAY */
#define MSG_ERROR "ERROR" /* ERRO */
#define MSG_AWAY "AWAY" /* AWAY */
#define MSG_CONNECT "CONNECT" /* CONN */
#define MSG_PING "PING" /* PING */
#define MSG_PONG "PONG" /* PONG */
#define MSG_OPER "OPER" /* OPER */
#define MSG_PASS "PASS" /* PASS */
#define MSG_PING "PING" /* PING */
#define MSG_PONG "PONG" /* PONG */
#define MSG_OPER "OPER" /* OPER */
#define MSG_PASS "PASS" /* PASS */
#define MSG_WALLOPS "WALLOPS" /* WALL */
#define MSG_TIME "TIME" /* TIME */
#define MSG_NAMES "NAMES" /* NAME */
#define MSG_ADMIN "ADMIN" /* ADMI */
#define MSG_TIME "TIME" /* TIME */
#define MSG_NAMES "NAMES" /* NAME */
#define MSG_ADMIN "ADMIN" /* ADMI */
#define MSG_NOTICE "NOTICE" /* NOTI */
#define MSG_JOIN "JOIN" /* JOIN */
#define MSG_PART "PART" /* PART */
#define MSG_JOIN "JOIN" /* JOIN */
#define MSG_PART "PART" /* PART */
#define MSG_LUSERS "LUSERS" /* LUSE */
#define MSG_MOTD "MOTD" /* MOTD */
#define MSG_MODE "MODE" /* MODE */
#define MSG_KICK "KICK" /* KICK */
#define MSG_MOTD "MOTD" /* MOTD */
#define MSG_MODE "MODE" /* MODE */
#define MSG_KICK "KICK" /* KICK */
#define MSG_SERVICE "SERVICE" /* SERV -> SRVI */
#define MSG_USERHOST "USERHOST" /* USER -> USRH */
#define MSG_ISON "ISON" /* ISON */
#define MSG_ISON "ISON" /* ISON */
#define MSG_SQUERY "SQUERY" /* SQUE */
#define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */
#define MSG_SERVSET "SERVSET" /* SERV -> SSET */
#define MSG_REHASH "REHASH" /* REHA */
#define MSG_RESTART "RESTART" /* REST */
#define MSG_CLOSE "CLOSE" /* CLOS */
#define MSG_DIE "DIE" /* DIE */
#define MSG_HASH "HASH" /* HASH */
#define MSG_DNS "DNS" /* DNS -> DNSS */
#define MSG_CLOSE "CLOSE" /* CLOS */
#define MSG_DIE "DIE" /* DIE */
#define MSG_HASH "HASH" /* HASH */
#define MSG_DNS "DNS" /* DNS -> DNSS */
#define MSG_SILENCE "SILENCE" /* SILE */
#define MSG_AKILL "AKILL" /* AKILL */
#define MSG_KLINE "KLINE" /* KLINE */
#define MSG_UNKLINE "UNKLINE" /* UNKLINE */
#define MSG_AKILL "AKILL" /* AKILL */
#define MSG_KLINE "KLINE" /* KLINE */
#define MSG_UNKLINE "UNKLINE" /* UNKLINE */
#define MSG_RAKILL "RAKILL" /* RAKILL */
#define MSG_GNOTICE "GNOTICE" /* GNOTICE */
#define MSG_GOPER "GOPER" /* GOPER */
#define MSG_GOPER "GOPER" /* GOPER */
#define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */
#define MSG_LOCOPS "LOCOPS" /* LOCOPS */
#define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */
#define MSG_TRACE "TRACE" /* TRAC */
#define MSG_TRACE "TRACE" /* TRAC */
#define MSG_SQLINE "SQLINE" /* SQLINE */
#define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */
#define MSG_SVSNICK "SVSNICK" /* SVSNICK */
@ -108,14 +108,14 @@
#define MSG_SVSMODE "SVSMODE" /* SVSMODE */
#define MSG_SAMODE "SAMODE" /* SAMODE */
#define MSG_CHATOPS "CHATOPS" /* CHATOPS */
#define MSG_HELPSERV "HELPSERV" /* HELPSERV */
#define MSG_ZLINE "ZLINE" /* ZLINE */
#define MSG_HELPSERV "HELPSERV" /* HELPSERV */
#define MSG_ZLINE "ZLINE" /* ZLINE */
#define MSG_UNZLINE "UNZLINE" /* UNZLINE */
#define MSG_NETINFO "NETINFO" /* NETINFO */
#define MSG_RULES "RULES" /* RULES */
#define MSG_MAP "MAP" /* MAP */
#define MSG_NETG "NETG" /* NETG */
#define MSG_ADCHAT "ADCHAT" /* Adchat */
#define MSG_RULES "RULES" /* RULES */
#define MSG_MAP "MAP" /* MAP */
#define MSG_NETG "NETG" /* NETG */
#define MSG_ADCHAT "ADCHAT" /* Adchat */
#define MSG_MAKEPASS "MAKEPASS" /* MAKEPASS */
#define MSG_ADDHUB "ADDHUB" /* ADDHUB */
#define MSG_DELHUB "DELHUB" /* DELHUB */
@ -125,28 +125,28 @@
#define MSG_DELOPER "DELOPER" /* DELOPER */
#define MSG_ADDQLINE "ADDQLINE" /* ADDQLINE */
#define MSG_DELQLINE "DELQLINE" /* DELQLINE */
#define MSG_GSOP "GSOP" /* GSOP */
#define MSG_ISOPER "ISOPER" /* ISOPER */
#define MSG_ADG "ADG" /* ADG */
#define MSG_NMON "NMON" /* NMON */
#define MSG_GSOP "GSOP" /* GSOP */
#define MSG_ISOPER "ISOPER" /* ISOPER */
#define MSG_ADG "ADG" /* ADG */
#define MSG_NMON "NMON" /* NMON */
#define MSG_DALINFO "DALINFO" /* DALnet Credits */
#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_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_STATSERV "STATSERV" /* StatServ */
#define MSG_RULESERV "RULESERV" /* RuleServ */
#define MSG_SNETINFO "SNETINFO" /* SNetInfo */
#define MSG_TSCTL "TSCTL" /* TSCTL */
#define MSG_TSCTL "TSCTL" /* TSCTL */
#define MSG_SVSJOIN "SVSJOIN" /* SVSJOIN */
#define MSG_SAJOIN "SAJOIN" /* SAJOIN */
#define MSG_SDESC "SDESC" /* SDESC */
#define MSG_SDESC "SDESC" /* SDESC */
#define MSG_UNREALINFO "UNREALINFO" /* Unreal Info */
#define MSG_SETHOST "SETHOST" /* sethost */
#define MSG_SETIDENT "SETIDENT" /* set ident */
#define MSG_SETNAME "SETNAME" /* set Realname */
#define MSG_SETHOST "SETHOST" /* sethost */
#define MSG_SETIDENT "SETIDENT" /* set ident */
#define MSG_SETNAME "SETNAME" /* set Realname */
#define MSG_CHGHOST "CHGHOST" /* Changehost */
#define MSG_CHGIDENT "CHGIDENT" /* Change Ident */
#define MSG_RANDQUOTE "RANDQUOTE" /* Random Quote */
@ -154,19 +154,19 @@
#define MSG_ADDGQUOTE "ADDGQUOTE" /* Add Global Quote */
#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_KNOCK "KNOCK" /* Knock Knock - Who's there? */
#define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */
#define MSG_SETTINGS "SETTINGS" /* Settings */
#define MSG_IRCOPS "IRCOPS" /* Shows Online IRCOps */
#define MSG_SVSPART "SVSPART" /* SVSPART */
#define MSG_SAPART "SAPART" /* SAPART */
#define MSG_VCTRL "VCTRL" /* VCTRL */
#define MSG_VCTRL "VCTRL" /* VCTRL */
#define MSG_GCLIENT "GCLIENT" /* GLIENT */
#define MSG_CHANNEL "CHANNEL" /* CHANNEL */
#define MSG_UPTIME "UPTIME" /* UPTIME */
#define MSG_FAILOPS "FAILOPS" /* FAILOPS */
#define MSG_RPING "RPING" /* RPING */
#define MSG_RPONG "RPONG" /* RPONG */
#define MSG_UPING "UPING" /* UPING */
#define MSG_RPING "RPING" /* RPING */
#define MSG_RPONG "RPONG" /* RPONG */
#define MSG_UPING "UPING" /* UPING */
#define MSG_COPYRIGHT "COPYRIGHT" /* Copyright */
#define MSG_BOTSERV "BOTSERV" /* BOTSERV */
#define MSG_BS "BS"
@ -191,14 +191,14 @@
#define UMODE_SKILL 0x0100 /* client see's server kills */
#define UMODE_LOCOPS 0x0200 /* client is localop */
#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_UNAUTH 0x2000 /* client can see unauthd connections */
#define UMODE_WALLOP 0x4000 /* client can get wallop messages */
#define UMODE_EXTERNAL 0x8000 /* client can see server joins/splits */
#define UMODE_SPY 0x10000 /* client can spy on user commands */
#define UMODE_OPERWALL 0x20000 /* client gets operwalls */
#define UMODE_SERVICES 0x40000 /* client is services */
#define UMODE_OPERWALL 0x20000 /* client gets operwalls */
#define UMODE_SERVICES 0x40000 /* client is services */
#define MODE_CHANOP 0x0001
@ -235,8 +235,8 @@ struct ircd_srv_ {
typedef struct {
long mode;
char flag;
unsigned nickparam : 1; /* 1 = yes 0 = no */
unsigned parameters : 1;
unsigned nickparam:1; /* 1 = yes 0 = no */
unsigned parameters:1;
char sjoin;
} aCtab;
@ -258,74 +258,74 @@ Oper_Modes susr_mds[0];
/* function declarations */
extern void init_ircd();
extern void chanalert(char *,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 ssquit_cmd(const char *);
extern int sprotocol_cmd(const char *);
extern int squit_cmd(const char *, const char *);
extern int spart_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 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 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 spong_cmd(const char *reply);
extern int snetinfo_cmd();
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 ssmo_cmd(const char *from, const char *umodetarget, const char *msg);
extern int snick_cmd(const char *oldnick, const char *newnick);
extern int sswhois_cmd(const char *target, const char *swhois);
extern int ssvsnick_cmd(const char *target, const char *newnick);
extern int ssvsjoin_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 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 vctrl_cmd();
extern int ssvinfo_cmd();
extern int sburst_cmd(int b);
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 srakill_cmd(const char *host, const char *ident);
extern void init_ircd ();
extern void chanalert (char *, 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 ssquit_cmd (const char *);
extern int sprotocol_cmd (const char *);
extern int squit_cmd (const char *, const char *);
extern int spart_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 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 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 spong_cmd (const char *reply);
extern int snetinfo_cmd ();
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 ssmo_cmd (const char *from, const char *umodetarget, const char *msg);
extern int snick_cmd (const char *oldnick, const char *newnick);
extern int sswhois_cmd (const char *target, const char *swhois);
extern int ssvsnick_cmd (const char *target, const char *newnick);
extern int ssvsjoin_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 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 vctrl_cmd ();
extern int ssvinfo_cmd ();
extern int sburst_cmd (int b);
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 srakill_cmd (const char *host, const char *ident);
void Usr_Version(char *, char **, int argc);
void Usr_ShowMOTD(char *, char **, int argc);
void Usr_ShowADMIN(char *, char **, int argc);
void Usr_Showcredits(char *, char **, int argc);
void Usr_AddServer(char *, char **, int argc);
void Usr_DelServer(char *, char **, int argc);
void Usr_DelUser(char *, char **, int argc);
void Usr_Mode(char *, char **, int argc);
void Usr_Smode(char *, char **, int argc);
void Usr_Kill(char *, char **, int argc);
void Usr_Pong(char *, char **, int argc);
void Usr_Away(char *, char **, int argc);
void Usr_Nick(char *, char **, int argc);
void Usr_Topic(char *, char **, int argc);
void Usr_Kick(char *, char **, int argc);
void Usr_Join(char *, char **, int argc);
void Usr_Part(char *, char **, int argc);
void Usr_Stats(char *, char **, int argc);
void Usr_Vhost(char *, char **, int argc);
void Srv_Topic(char *, char **, int argc);
void Srv_Ping(char *, char **, int argc);
void Srv_Netinfo(char *, char **, int argc);
void Srv_Pass(char *, char **, int argc);
void Srv_Server(char *, char **, int argc);
void Srv_Squit(char *, char **, int argc);
void Srv_Nick(char *, char **, int argc);
void Srv_Svsnick(char *, char **, int argc);
void Srv_Kill(char *, char **, int argc);
void Srv_Connect(char *, char **, int argc);
void Srv_Svinfo(char *, char **, int argc);
void Srv_Burst(char *origin, char **argv, int argc);
void Srv_Sjoin(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);
void Usr_Version (char *, char **, int argc);
void Usr_ShowMOTD (char *, char **, int argc);
void Usr_ShowADMIN (char *, char **, int argc);
void Usr_Showcredits (char *, char **, int argc);
void Usr_AddServer (char *, char **, int argc);
void Usr_DelServer (char *, char **, int argc);
void Usr_DelUser (char *, char **, int argc);
void Usr_Mode (char *, char **, int argc);
void Usr_Smode (char *, char **, int argc);
void Usr_Kill (char *, char **, int argc);
void Usr_Pong (char *, char **, int argc);
void Usr_Away (char *, char **, int argc);
void Usr_Nick (char *, char **, int argc);
void Usr_Topic (char *, char **, int argc);
void Usr_Kick (char *, char **, int argc);
void Usr_Join (char *, char **, int argc);
void Usr_Part (char *, char **, int argc);
void Usr_Stats (char *, char **, int argc);
void Usr_Vhost (char *, char **, int argc);
void Srv_Topic (char *, char **, int argc);
void Srv_Ping (char *, char **, int argc);
void Srv_Netinfo (char *, char **, int argc);
void Srv_Pass (char *, char **, int argc);
void Srv_Server (char *, char **, int argc);
void Srv_Squit (char *, char **, int argc);
void Srv_Nick (char *, char **, int argc);
void Srv_Svsnick (char *, char **, int argc);
void Srv_Kill (char *, char **, int argc);
void Srv_Connect (char *, char **, int argc);
void Srv_Svinfo (char *, char **, int argc);
void Srv_Burst (char *origin, char **argv, int argc);
void Srv_Sjoin (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);
#endif

490
ircd.c
View file

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

16
ircd.h
View file

@ -18,15 +18,15 @@
** USA
**
** 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
#define IRCD_H
struct int_cmds {
char *name;
void (*function)(char *origin, char **argv, int argc);
int srvmsg; /* Should this be a Server Message(1), or a User Message?(0) */
void (*function) (char *origin, char **argv, int argc);
int srvmsg; /* Should this be a Server Message(1), or a User Message?(0) */
int usage;
} int_cmds;
@ -35,11 +35,11 @@ typedef struct int_cmds IntCommands;
void ShowMOTD(char *);
void ShowADMIN(char *);
void Showcredits(char *);
void ShowStats(char *, User *);
void dopong(Server *);
void ShowMOTD (char *);
void ShowADMIN (char *);
void Showcredits (char *);
void ShowStats (char *, User *);
void dopong (Server *);

View file

@ -20,7 +20,7 @@
** USA
**
** 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"
@ -30,35 +30,34 @@
/** @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];
int i = 0;
/* determine if its a module setting */
if (strlen(segvinmodule) > 0) {
snprintf(keypath, 255, "g/%s:/%s", segvinmodule, item);
if (strlen (segvinmodule) > 0) {
snprintf (keypath, 255, "g/%s:/%s", segvinmodule, item);
} else {
snprintf(keypath, 255, "g/core:/%s", item);
snprintf (keypath, 255, "g/core:/%s", item);
}
switch (type) {
case CFGSTR:
i = kp_get_string(keypath, (char **) *&data);
i = kp_get_string (keypath, (char **) *&data);
break;
case CFGINT:
i = kp_get_int(keypath, (int *) *&data);
i = kp_get_int (keypath, (int *) *&data);
break;
case CFGFLOAT:
i = kp_get_float(keypath, (double *) *&data);
i = kp_get_float (keypath, (double *) *&data);
break;
case CFGBOOL:
i = kp_get_bool(keypath, (int *) *&data);
i = kp_get_bool (keypath, (int *) *&data);
break;
default:
nlog(LOG_WARNING, LOG_CORE,
"Keeper: Called GetConf with invalid datatype %d",
type);
nlog (LOG_WARNING, LOG_CORE, "Keeper: Called GetConf with invalid datatype %d", type);
return -1;
}
/* check for errors */
@ -66,8 +65,7 @@ int GetConf(void **data, int type, const char *item)
/*
data = malloc(255);
*/
nlog(LOG_DEBUG1, LOG_CORE, "GetConf: %s - Path: %s",
kp_strerror(i), keypath);
nlog (LOG_DEBUG1, LOG_CORE, "GetConf: %s - Path: %s", kp_strerror (i), keypath);
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 */
int GetDir(char *item, char ***data)
int
GetDir (char *item, char ***data)
{
int i;
char keypath[255];
char **data1;
/* determine if its a module setting */
if (strlen(segvinmodule) > 0) {
snprintf(keypath, 255, "g/%s:/%s", segvinmodule, item);
if (strlen (segvinmodule) > 0) {
snprintf (keypath, 255, "g/%s:/%s", segvinmodule, item);
} 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) {
*data = data1;
return 1;
}
*data = NULL;
nlog(LOG_DEBUG1, LOG_CORE, "GetDir: %s - Path: %s", kp_strerror(i),
keypath);
nlog (LOG_DEBUG1, LOG_CORE, "GetDir: %s - Path: %s", kp_strerror (i), keypath);
return -1;
}
@ -103,24 +101,25 @@ int GetDir(char *item, char ***data)
/** @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];
int i = 0;
/* determine if its a module setting */
if (strlen(segvinmodule) > 0) {
snprintf(keypath, 255, "g/%s:/%s", segvinmodule, item);
if (strlen (segvinmodule) > 0) {
snprintf (keypath, 255, "g/%s:/%s", segvinmodule, item);
} else {
snprintf(keypath, 255, "g/core:/%s", item);
snprintf (keypath, 255, "g/core:/%s", item);
}
switch (type) {
case CFGSTR:
i = kp_set_string(keypath, (char *) data);
i = kp_set_string (keypath, (char *) data);
break;
case CFGINT:
i = kp_set_int(keypath, (int) data);
i = kp_set_int (keypath, (int) data);
break;
case CFGFLOAT:
/*
@ -128,20 +127,18 @@ int SetConf(void *data, int type, char *item)
*/
break;
case CFGBOOL:
i = kp_set_bool(keypath, (int) data);
i = kp_set_bool (keypath, (int) data);
break;
default:
nlog(LOG_WARNING, LOG_CORE,
"Keeper: Called SetConf with invalid datatype %d",
type);
nlog (LOG_WARNING, LOG_CORE, "Keeper: Called SetConf with invalid datatype %d", type);
return -1;
}
/* check for errors */
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;
}
kp_flush();
kp_flush ();
return 1;
}

444
list.c
View file

@ -37,7 +37,7 @@
* into proprietary software; there is no requirement for such software to
* 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: $
*/
@ -69,8 +69,7 @@
#define lnode_prev(N) ((N)->prev)
#ifdef KAZLIB_RCSID
static const char rcsid[] =
"$Id: list.c,v 1.9 2003/07/17 10:13:51 fishwaldo Exp $";
static const char rcsid[] = "$Id: list.c,v 1.10 2003/07/30 13:58:22 fishwaldo Exp $";
#endif
/*
@ -80,9 +79,10 @@ static const char rcsid[] =
* 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.prev = &list->nilnode;
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.
*/
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) {
nassert(maxcount != 0);
nassert (maxcount != 0);
new->nilnode.next = &new->nilnode;
new->nilnode.prev = &new->nilnode;
new->nodecount = 0;
@ -114,10 +115,11 @@ list_t *list_create(listcount_t maxcount)
* The client must remove the nodes first.
*/
void list_destroy(list_t * list)
void
list_destroy (list_t * list)
{
nassert(list_isempty(list));
free(list);
nassert (list_isempty (list));
free (list);
}
/*
@ -126,20 +128,20 @@ void list_destroy(list_t * list)
* is empty.
*/
void list_destroy_nodes(list_t * list)
void
list_destroy_nodes (list_t * list)
{
lnode_t *lnode = list_first_priv(list), *nil =
list_nil(list), *tmp;
lnode_t *lnode = list_first_priv (list), *nil = list_nil (list), *tmp;
while (lnode != nil) {
tmp = lnode->next;
lnode->next = NULL;
lnode->prev = NULL;
lnode_destroy(lnode);
lnode_destroy (lnode);
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.
*/
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 =
list_nil(list);
lnode_t *lnode = list_first_priv (list), *tmp, *nil = list_nil (list);
while (lnode != nil) {
tmp = lnode->next;
lnode->next = NULL;
lnode->prev = NULL;
lnode_return(pool, lnode);
lnode_return (pool, lnode);
lnode = tmp;
}
list_init(list, list->maxcount);
list_init (list, list->maxcount);
}
/*
* 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;
nassert(new != NULL);
nassert(!list_contains(list, new));
nassert(!lnode_is_in_a_list(new));
nassert(this == list_nil(list) || list_contains(list, this));
nassert(list->nodecount + 1 > list->nodecount);
nassert (new != NULL);
nassert (!list_contains (list, new));
nassert (!lnode_is_in_a_list (new));
nassert (this == list_nil (list) || list_contains (list, this));
nassert (list->nodecount + 1 > list->nodecount);
new->prev = this;
new->next = that;
@ -183,22 +186,23 @@ void list_ins_after(list_t * list, lnode_t * new, lnode_t * this)
this->next = new;
list->nodecount++;
nassert(list->nodecount <= list->maxcount);
nassert (list->nodecount <= list->maxcount);
}
/*
* 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;
nassert(new != NULL);
nassert(!list_contains(list, new));
nassert(!lnode_is_in_a_list(new));
nassert(this == list_nil(list) || list_contains(list, this));
nassert(list->nodecount + 1 > list->nodecount);
nassert (new != NULL);
nassert (!list_contains (list, new));
nassert (!lnode_is_in_a_list (new));
nassert (this == list_nil (list) || list_contains (list, this));
nassert (list->nodecount + 1 > list->nodecount);
new->next = this;
new->prev = that;
@ -206,19 +210,20 @@ void list_ins_before(list_t * list, lnode_t * new, lnode_t * this)
this->prev = new;
list->nodecount++;
nassert(list->nodecount <= list->maxcount);
nassert (list->nodecount <= list->maxcount);
}
/*
* 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 *prev = del->prev;
nassert(list_contains(list, del));
nassert (list_contains (list, del));
prev->next = next;
next->prev = prev;
@ -235,19 +240,17 @@ lnode_t *list_delete(list_t * list, lnode_t * del)
* call to the function.
*/
void list_process(list_t * list, void *context,
void (*function) (list_t * list, lnode_t * lnode,
void *context))
void
list_process (list_t * list, void *context, void (*function) (list_t * list, lnode_t * lnode, void *context))
{
lnode_t *node = list_first_priv(list), *next, *nil =
list_nil(list);
lnode_t *node = list_first_priv (list), *next, *nil = list_nil (list);
while (node != nil) {
/* check for callback function deleting */
/* the next node from under us */
nassert(list_contains(list, node));
nassert (list_contains (list, node));
next = node->next;
function(list, node, context);
function (list, node, context);
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.
*/
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) {
new->data = data;
new->next = NULL;
@ -271,7 +275,8 @@ lnode_t *lnode_create(void *data)
* 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->next = NULL;
@ -283,10 +288,11 @@ lnode_t *lnode_init(lnode_t * lnode, void *data)
* Destroy a dynamically allocated node.
*/
void lnode_destroy(lnode_t * lnode)
void
lnode_destroy (lnode_t * lnode)
{
nassert(!lnode_is_in_a_list(lnode));
free(lnode);
nassert (!lnode_is_in_a_list (lnode));
free (lnode);
}
/*
@ -295,12 +301,12 @@ void lnode_destroy(lnode_t * lnode)
* ``n'' elements.
*/
lnodepool_t *lnode_pool_init(lnodepool_t * pool, lnode_t * nodes,
listcount_t n)
lnodepool_t *
lnode_pool_init (lnodepool_t * pool, lnode_t * nodes, listcount_t n)
{
listcount_t i;
nassert(n != 0);
nassert (n != 0);
pool->pool = 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.
*/
lnodepool_t *lnode_pool_create(listcount_t n)
lnodepool_t *
lnode_pool_create (listcount_t n)
{
lnodepool_t *pool;
lnode_t *nodes;
nassert(n != 0);
nassert (n != 0);
pool = malloc(sizeof *pool);
pool = malloc (sizeof *pool);
if (!pool)
return NULL;
nodes = malloc(n * sizeof *nodes);
nodes = malloc (n * sizeof *nodes);
if (!nodes) {
free(pool);
free (pool);
return NULL;
}
lnode_pool_init(pool, nodes, n);
lnode_pool_init (pool, nodes, n);
return pool;
}
@ -340,7 +347,8 @@ lnodepool_t *lnode_pool_create(listcount_t n)
* 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;
@ -359,10 +367,11 @@ int lnode_pool_isfrom(lnodepool_t * pool, lnode_t * node)
* 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);
free (p->pool);
free (p);
}
/*
@ -370,7 +379,8 @@ void lnode_pool_destroy(lnodepool_t * p)
* 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;
if (new) {
@ -387,10 +397,11 @@ lnode_t *lnode_borrow(lnodepool_t * pool, void *data)
* 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_is_in_a_list(node));
nassert (lnode_pool_isfrom (pool, node));
nassert (!lnode_is_in_a_list (node));
node->next = pool->fre;
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.
*/
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)
return 1;
}
@ -420,13 +432,13 @@ int list_contains(list_t * list, lnode_t * node)
* list.
*/
void list_extract(list_t * dest, list_t * source, lnode_t * first,
lnode_t * last)
void
list_extract (list_t * dest, list_t * source, lnode_t * first, lnode_t * last)
{
listcount_t moved = 1;
nassert(first == NULL || list_contains(source, first));
nassert(last == NULL || list_contains(source, last));
nassert (first == NULL || list_contains (source, first));
nassert (last == NULL || list_contains (source, last));
if (first == NULL || last == NULL)
return;
@ -445,23 +457,23 @@ void list_extract(list_t * dest, list_t * source, lnode_t * first,
while (first != last) {
first = first->next;
nassert(first != list_nil(source)); /* oops, last before first! */
nassert (first != list_nil (source)); /* oops, last before first! */
moved++;
}
/* nassert no overflows */
nassert(source->nodecount - moved <= source->nodecount);
nassert(dest->nodecount + moved >= dest->nodecount);
nassert (source->nodecount - moved <= source->nodecount);
nassert (dest->nodecount + moved >= dest->nodecount);
/* nassert no weirdness */
nassert(moved <= source->nodecount);
nassert (moved <= source->nodecount);
source->nodecount -= moved;
dest->nodecount += moved;
/* nassert list sanity */
nassert(list_verify(source));
nassert(list_verify(dest));
nassert (list_verify (source));
nassert (list_verify (dest));
}
@ -473,12 +485,13 @@ void list_extract(list_t * dest, list_t * source, lnode_t * first,
* 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;
lnode_t *last;
nassert(first == NULL || list_contains(source, first));
nassert (first == NULL || list_contains (source, first));
if (first == NULL)
return;
@ -499,48 +512,48 @@ void list_transfer(list_t * dest, list_t * source, lnode_t * first)
}
/* nassert no overflows */
nassert(source->nodecount - moved <= source->nodecount);
nassert(dest->nodecount + moved >= dest->nodecount);
nassert (source->nodecount - moved <= source->nodecount);
nassert (dest->nodecount + moved >= dest->nodecount);
/* nassert no weirdness */
nassert(moved <= source->nodecount);
nassert (moved <= source->nodecount);
source->nodecount -= moved;
dest->nodecount += moved;
/* nassert list sanity */
nassert(list_verify(source));
nassert(list_verify(dest));
nassert (list_verify (source));
nassert (list_verify (dest));
}
void list_merge(list_t * dest, list_t * sour,
int compare(const void *, const void *))
void
list_merge (list_t * dest, list_t * sour, int compare (const void *, const void *))
{
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. */
if (dest == sour)
return;
/* 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 */
nassert(list_is_sorted(sour, compare));
nassert(list_is_sorted(dest, compare));
nassert (list_is_sorted (sour, compare));
nassert (list_is_sorted (dest, compare));
dn = list_first_priv(dest);
sn = list_first_priv(sour);
dn = list_first_priv (dest);
sn = list_first_priv (sour);
while (dn != d_nil && sn != s_nil) {
if (compare(lnode_get(dn), lnode_get(sn)) >= 0) {
tn = lnode_next(sn);
list_delete(sour, sn);
list_ins_before(dest, sn, dn);
if (compare (lnode_get (dn), lnode_get (sn)) >= 0) {
tn = lnode_next (sn);
list_delete (sour, sn);
list_ins_before (dest, sn, dn);
sn = tn;
} else {
dn = lnode_next(dn);
dn = lnode_next (dn);
}
}
@ -548,40 +561,40 @@ void list_merge(list_t * dest, list_t * sour,
return;
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;
listcount_t middle;
lnode_t *node;
if (list_count(list) > 1) {
middle = list_count(list) / 2;
node = list_first_priv(list);
if (list_count (list) > 1) {
middle = list_count (list) / 2;
node = list_first_priv (list);
list_init(&extra, list_count(list) - middle);
list_init (&extra, list_count (list) - middle);
while (middle--)
node = lnode_next(node);
node = lnode_next (node);
list_transfer(&extra, list, node);
list_sort(list, compare);
list_sort(&extra, compare);
list_merge(list, &extra, compare);
list_transfer (&extra, list, node);
list_sort (list, compare);
list_sort (&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,
int compare(const void *, const void *))
lnode_t *
list_find (list_t * list, const void *key, int compare (const void *, const void *))
{
lnode_t *node;
for (node = list_first_priv(list); node != list_nil(list);
node = node->next) {
if (compare(lnode_get(node), key) == 0)
for (node = list_first_priv (list); node != list_nil (list); node = node->next) {
if (compare (lnode_get (node), key) == 0)
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
*/
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;
next = nil = list_nil(list);
node = list_first_priv(list);
next = nil = list_nil (list);
node = list_first_priv (list);
if (node != nil)
next = lnode_next(node);
next = lnode_next (node);
for (; next != nil; node = next, next = lnode_next(next)) {
if (compare(lnode_get(node), lnode_get(next)) > 0)
for (; next != nil; node = next, next = lnode_next (next)) {
if (compare (lnode_get (node), lnode_get (next)) > 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
*/
int list_isempty(list_t * list)
int
list_isempty (list_t * list)
{
return list->nodecount == 0;
}
@ -645,7 +660,8 @@ int list_isempty(list_t * list)
* Permitted only on bounded lists.
*/
int list_isfull(list_t * list)
int
list_isfull (list_t * list)
{
return list->nodecount == list->maxcount;
}
@ -654,7 +670,8 @@ int list_isfull(list_t * list)
* 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);
}
@ -663,25 +680,28 @@ int lnode_pool_isempty(lnodepool_t * pool)
* 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.
*/
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
*/
lnode_t *list_first(list_t * list)
lnode_t *
list_first (list_t * list)
{
if (list->nilnode.next == &list->nilnode)
return NULL;
@ -692,7 +712,8 @@ lnode_t *list_first(list_t * 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)
return NULL;
@ -703,7 +724,8 @@ lnode_t *list_last(list_t * 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;
}
@ -712,18 +734,20 @@ listcount_t list_count(list_t * list)
* 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.
*/
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.
*/
void lnode_put(lnode_t * lnode, void *data)
void
lnode_put (lnode_t * lnode, void *data)
{
lnode->data = data;
}
@ -740,7 +765,8 @@ void lnode_put(lnode_t * lnode, void *data)
* Retrieve the data item associated with the node.
*/
void *lnode_get(lnode_t * lnode)
void *
lnode_get (lnode_t * lnode)
{
return lnode->data;
}
@ -750,11 +776,12 @@ void *lnode_get(lnode_t * lnode)
* 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 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().
*/
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 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.
*/
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);
}
int list_verify(list_t * list)
int
list_verify (list_t * list)
{
lnode_t *node = list_first_priv(list), *nil = list_nil(list);
listcount_t count = list_count(list);
lnode_t *node = list_first_priv (list), *nil = list_nil (list);
listcount_t count = list_count (list);
if (node->prev != nil) {
return 0;
@ -808,9 +838,10 @@ int list_verify(list_t * list)
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];
static int tokenize(char *string, ...)
static int
tokenize (char *string, ...)
{
char **tokptr;
va_list arglist;
int tokcount = 0;
va_start(arglist, string);
tokptr = va_arg(arglist, char **);
va_start (arglist, string);
tokptr = va_arg (arglist, char **);
while (tokptr) {
while (*string && isspace((unsigned char) *string))
while (*string && isspace ((unsigned char) *string))
string++;
if (!*string)
break;
*tokptr = string;
while (*string && !isspace((unsigned char) *string))
while (*string && !isspace ((unsigned char) *string))
string++;
tokptr = va_arg(arglist, char **);
tokptr = va_arg (arglist, char **);
tokcount++;
if (!*string)
break;
*string++ = 0;
}
va_end(arglist);
va_end (arglist);
return tokcount;
}
static char *dupstring(char *str)
static char *
dupstring (char *str)
{
int sz = strlen(str) + 1;
char *new = malloc(sz);
int sz = strlen (str) + 1;
char *new = malloc (sz);
if (new)
memcpy(new, str, sz);
memcpy (new, str, sz);
return new;
}
int main(void)
int
main (void)
{
input_t in;
list_t *l = list_create(LISTCOUNT_T_MAX);
list_t *l = list_create (LISTCOUNT_T_MAX);
lnode_t *ln;
char *tok1, *val;
int prompt = 0;
char *help =
"a <val> append value to list\n"
"d <val> delete value from list\n"
"l <val> lookup value in list\n"
"s sort list\n"
"c show number of entries\n"
"t dump whole list\n"
"p turn prompt on\n"
"q quit";
"a <val> append value to list\n"
"d <val> delete value from list\n"
"l <val> lookup value in list\n"
"s sort list\n"
"c show number of entries\n" "t dump whole list\n" "p turn prompt on\n" "q quit";
if (!l)
puts("list_create failed");
puts ("list_create failed");
for (;;) {
if (prompt)
putchar('>');
fflush(stdout);
putchar ('>');
fflush (stdout);
if (!fgets(in, sizeof(input_t), stdin))
if (!fgets (in, sizeof (input_t), stdin))
break;
switch (in[0]) {
case '?':
puts(help);
puts (help);
break;
case 'a':
if (tokenize(in + 1, &tok1, (char **) 0) != 1) {
puts("what?");
if (tokenize (in + 1, &tok1, (char **) 0) != 1) {
puts ("what?");
break;
}
val = dupstring(tok1);
ln = lnode_create(val);
val = dupstring (tok1);
ln = lnode_create (val);
if (!val || !ln) {
puts("allocation failure");
puts ("allocation failure");
if (ln)
lnode_destroy(ln);
free(val);
lnode_destroy (ln);
free (val);
break;
}
list_append(l, ln);
list_append (l, ln);
break;
case 'd':
if (tokenize(in + 1, &tok1, (char **) 0) != 1) {
puts("what?");
if (tokenize (in + 1, &tok1, (char **) 0) != 1) {
puts ("what?");
break;
}
ln = list_find(l, tok1, comparef);
ln = list_find (l, tok1, comparef);
if (!ln) {
puts("list_find failed");
puts ("list_find failed");
break;
}
list_delete(l, ln);
val = lnode_get(ln);
lnode_destroy(ln);
free(val);
list_delete (l, ln);
val = lnode_get (ln);
lnode_destroy (ln);
free (val);
break;
case 'l':
if (tokenize(in + 1, &tok1, (char **) 0) != 1) {
puts("what?");
if (tokenize (in + 1, &tok1, (char **) 0) != 1) {
puts ("what?");
break;
}
ln = list_find(l, tok1, comparef);
ln = list_find (l, tok1, comparef);
if (!ln)
puts("list_find failed");
puts ("list_find failed");
else
puts("found");
puts ("found");
break;
case 's':
list_sort(l, comparef);
list_sort (l, comparef);
break;
case 'c':
printf("%lu\n", (unsigned long) list_count(l));
printf ("%lu\n", (unsigned long) list_count (l));
break;
case 't':
for (ln = list_first(l); ln != 0;
ln = list_next(l, ln))
puts(lnode_get(ln));
for (ln = list_first (l); ln != 0; ln = list_next (l, ln))
puts (lnode_get (ln));
break;
case 'q':
exit(0);
exit (0);
break;
case '\0':
break;
@ -958,8 +988,8 @@ int main(void)
prompt = 1;
break;
default:
putchar('?');
putchar('\n');
putchar ('?');
putchar ('\n');
break;
}
}
@ -967,4 +997,4 @@ int main(void)
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
* 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: $
*/
@ -61,90 +61,90 @@
extern "C" {
#endif
typedef unsigned long listcount_t;
typedef unsigned long listcount_t;
#define LISTCOUNT_T_MAX ULONG_MAX
typedef struct lnode_t {
#if defined(LIST_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
struct lnode_t *list_next;
struct lnode_t *list_prev;
void *list_data;
#else
int list_dummy;
#endif
} lnode_t;
typedef struct lnode_t {
#if defined(LIST_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
struct lnode_t *list_next;
struct lnode_t *list_prev;
void *list_data;
#else
int list_dummy;
#endif
} lnode_t;
typedef struct lnodepool_t {
#if defined(LIST_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
struct lnode_t *list_pool;
struct lnode_t *list_free;
listcount_t list_size;
#else
int list_dummy;
#endif
} lnodepool_t;
typedef struct lnodepool_t {
#if defined(LIST_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
struct lnode_t *list_pool;
struct lnode_t *list_free;
listcount_t list_size;
#else
int list_dummy;
#endif
} lnodepool_t;
typedef struct list_t {
#if defined(LIST_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
lnode_t list_nilnode;
listcount_t list_nodecount;
listcount_t list_maxcount;
#else
int list_dummy;
#endif
} list_t;
typedef struct list_t {
#if defined(LIST_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
lnode_t list_nilnode;
listcount_t list_nodecount;
listcount_t list_maxcount;
#else
int list_dummy;
#endif
} list_t;
lnode_t *lnode_create(void *);
lnode_t *lnode_init(lnode_t *, void *);
void lnode_destroy(lnode_t *);
void lnode_put(lnode_t *, void *);
void *lnode_get(lnode_t *);
int lnode_is_in_a_list(lnode_t *);
lnode_t *lnode_create (void *);
lnode_t *lnode_init (lnode_t *, void *);
void lnode_destroy (lnode_t *);
void lnode_put (lnode_t *, void *);
void *lnode_get (lnode_t *);
int lnode_is_in_a_list (lnode_t *);
#if defined(LIST_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
#define lnode_put(N, D) ((N)->list_data = (D))
#define lnode_get(N) ((N)->list_data)
#endif
lnodepool_t *lnode_pool_init(lnodepool_t *, lnode_t *, listcount_t);
lnodepool_t *lnode_pool_create(listcount_t);
void lnode_pool_destroy(lnodepool_t *);
lnode_t *lnode_borrow(lnodepool_t *, void *);
void lnode_return(lnodepool_t *, lnode_t *);
int lnode_pool_isempty(lnodepool_t *);
int lnode_pool_isfrom(lnodepool_t *, lnode_t *);
lnodepool_t *lnode_pool_init (lnodepool_t *, lnode_t *, listcount_t);
lnodepool_t *lnode_pool_create (listcount_t);
void lnode_pool_destroy (lnodepool_t *);
lnode_t *lnode_borrow (lnodepool_t *, void *);
void lnode_return (lnodepool_t *, lnode_t *);
int lnode_pool_isempty (lnodepool_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_create(listcount_t);
void list_destroy(list_t *);
void list_destroy_nodes(list_t *);
void list_return_nodes(list_t *, lnodepool_t *);
list_t *list_init (list_t *, listcount_t);
list_t *list_create (listcount_t);
void list_destroy (list_t *);
void list_destroy_nodes (list_t *);
void list_return_nodes (list_t *, lnodepool_t *);
listcount_t list_count(list_t *);
int list_isempty(list_t *);
int list_isfull(list_t *);
int list_contains(list_t *, lnode_t *);
listcount_t list_count (list_t *);
int list_isempty (list_t *);
int list_isfull (list_t *);
int list_contains (list_t *, lnode_t *);
void list_append(list_t *, lnode_t *);
void list_prepend(list_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_append (list_t *, lnode_t *);
void list_prepend (list_t *, lnode_t *);
void list_ins_before (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_last(list_t *);
lnode_t *list_next(list_t *, lnode_t *);
lnode_t *list_prev(list_t *, lnode_t *);
lnode_t *list_first (list_t *);
lnode_t *list_last (list_t *);
lnode_t *list_next (list_t *, lnode_t *);
lnode_t *list_prev (list_t *, lnode_t *);
lnode_t *list_del_first(list_t *);
lnode_t *list_del_last(list_t *);
lnode_t *list_delete(list_t *, lnode_t *);
lnode_t *list_del_first (list_t *);
lnode_t *list_del_last (list_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)
#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 */
void list_extract(list_t *, list_t *, lnode_t *, lnode_t *);
void list_transfer(list_t *, list_t *, lnode_t *first);
void list_merge(list_t *, 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 *));
int list_is_sorted(list_t *, int (const void *, const void *));
void list_extract (list_t *, list_t *, lnode_t *, lnode_t *);
void list_transfer (list_t *, list_t *, lnode_t * first);
void list_merge (list_t *, 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 *));
int list_is_sorted (list_t *, int (const void *, const void *));
#ifdef __cplusplus
}
#endif
#endif

160
log.c
View file

@ -20,7 +20,7 @@
** USA
**
** 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"
@ -51,17 +51,18 @@ struct logs_ {
hash_t *logs;
void *close_logs();
void *close_logs ();
/** @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) {
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! */
exit(-1);
exit (-1);
}
}
@ -69,25 +70,25 @@ void init_logs()
*/
void *close_logs()
void *
close_logs ()
{
hscan_t hs;
hnode_t *hn;
struct logs_ *logentry;
hash_scan_begin(&hs, logs);
while ((hn = hash_scan_next(&hs)) != NULL) {
logentry = hnode_get(hn);
fflush(logentry->logfile);
hash_scan_begin (&hs, logs);
while ((hn = hash_scan_next (&hs)) != NULL) {
logentry = hnode_get (hn);
fflush (logentry->logfile);
logentry->flush = 0;
#ifdef DEBUG
printf("Closing Logfile %s (%s)\n", logentry->name,
(char *) hnode_getkey(hn));
printf ("Closing Logfile %s (%s)\n", logentry->name, (char *) hnode_getkey (hn));
#endif
fclose(logentry->logfile);
hash_scan_delete(logs, hn);
hnode_destroy(hn);
free(logentry);
fclose (logentry->logfile);
hash_scan_delete (logs, hn);
hnode_destroy (hn);
free (logentry);
}
return NULL;
}
@ -95,113 +96,101 @@ void *close_logs()
/** @Configurable logging function
*/
void nlog(int level, int scope, char *fmt, ...)
void
nlog (int level, int scope, char *fmt, ...)
{
va_list ap;
char buf[512], fmttime[80];
int gotlog;
hnode_t *hn;
struct logs_ *logentry;
time_t ts = time(NULL);
time_t ts = time (NULL);
if (level <= config.debug) {
/* if scope is > 0, then log to a diff file */
if (scope > 0) {
if (strlen(segvinmodule) > 1) {
hn = hash_lookup(logs, segvinmodule);
if (strlen (segvinmodule) > 1) {
hn = hash_lookup (logs, segvinmodule);
} else {
nlog(LOG_ERROR, LOG_CORE,
"Warning, nlog called with LOG_MOD, but segvinmodule is blank! Logging to Core");
hn = hash_lookup(logs, "core");
nlog (LOG_ERROR, LOG_CORE, "Warning, nlog called with LOG_MOD, but segvinmodule is blank! Logging to Core");
hn = hash_lookup (logs, "core");
}
} else {
hn = hash_lookup(logs, "core");
hn = hash_lookup (logs, "core");
}
if (hn) {
/* we found our log entry */
logentry = hnode_get(hn);
logentry = hnode_get (hn);
gotlog = 1;
} else {
/* log file not found */
if ((strlen(segvinmodule) <= 1) && (scope > 0)) {
if ((strlen (segvinmodule) <= 1) && (scope > 0)) {
#ifdef DEBUG
printf
("segvinmodule is blank, but scope is for Modules!\n");
printf ("segvinmodule is blank, but scope is for Modules!\n");
#endif
/* bad, but hey ! */
scope = 0;
}
logentry = malloc(sizeof(struct logs_));
strncpy(logentry->name,
scope > 0 ? segvinmodule : "core", 30);
snprintf(buf, 40, "logs/%s.log",
scope > 0 ? segvinmodule : "NeoStats");
logentry->logfile = fopen(buf, "a");
logentry = malloc (sizeof (struct logs_));
strncpy (logentry->name, scope > 0 ? segvinmodule : "core", 30);
snprintf (buf, 40, "logs/%s.log", scope > 0 ? segvinmodule : "NeoStats");
logentry->logfile = fopen (buf, "a");
logentry->flush = 0;
hn = hnode_create(logentry);
hash_insert(logs, hn, logentry->name);
hn = hnode_create (logentry);
hash_insert (logs, hn, logentry->name);
}
if (!logentry->logfile) {
#ifdef DEBUG
printf("%s\n", strerror(errno));
do_exit(0);
printf ("%s\n", strerror (errno));
do_exit (0);
#endif
}
strftime(fmttime, 80, "%d/%m/%Y[%H:%M]", localtime(&ts));
va_start(ap, fmt);
vsnprintf(buf, 512, fmt, ap);
strftime (fmttime, 80, "%d/%m/%Y[%H:%M]", localtime (&ts));
va_start (ap, fmt);
vsnprintf (buf, 512, fmt, ap);
fprintf(logentry->logfile, "(%s) %s %s - %s\n", fmttime,
loglevels[level - 1],
scope > 0 ? segvinmodule : "CORE", buf);
fprintf (logentry->logfile, "(%s) %s %s - %s\n", fmttime, loglevels[level - 1], scope > 0 ? segvinmodule : "CORE", buf);
logentry->flush = 1;
#ifndef DEBUG
if (config.foreground)
#endif
printf("%s %s - %s\n", loglevels[level - 1],
scope > 0 ? segvinmodule : "CORE", buf);
va_end(ap);
printf ("%s %s - %s\n", loglevels[level - 1], scope > 0 ? segvinmodule : "CORE", buf);
va_end (ap);
}
}
void ResetLogs()
void
ResetLogs ()
{
char tmp[255], tmp2[255];
time_t t = time(NULL);
time_t t = time (NULL);
hscan_t hs;
hnode_t *hn;
struct logs_ *logentry;
strcpy(segv_location, "ResetLogs");
hash_scan_begin(&hs, logs);
while ((hn = hash_scan_next(&hs)) != NULL) {
logentry = hnode_get(hn);
strcpy (segv_location, "ResetLogs");
hash_scan_begin (&hs, logs);
while ((hn = hash_scan_next (&hs)) != NULL) {
logentry = hnode_get (hn);
if (logentry->flush > 0) {
fflush(logentry->logfile);
fflush (logentry->logfile);
logentry->flush = 0;
#ifdef DEBUG
printf("Closing Logfile %s (%s)\n", logentry->name,
(char *) hnode_getkey(hn));
printf ("Closing Logfile %s (%s)\n", logentry->name, (char *) hnode_getkey (hn));
#endif
fclose(logentry->logfile);
if (!strcasecmp(logentry->name, "core")) {
strftime(tmp, 255,
"logs/NeoStats-%m-%d.log",
localtime(&t));
rename("logs/NeoStats.log", tmp);
logentry->logfile =
fopen("logs/NeoStats.log", "a");
fclose (logentry->logfile);
if (!strcasecmp (logentry->name, "core")) {
strftime (tmp, 255, "logs/NeoStats-%m-%d.log", localtime (&t));
rename ("logs/NeoStats.log", tmp);
logentry->logfile = fopen ("logs/NeoStats.log", "a");
} else {
strftime(tmp2, 255, "%m-%d.log",
localtime(&t));
snprintf(tmp, 255, "logs/%s-%s",
logentry->name, tmp2);
snprintf(tmp2, 255, "logs/%s.log",
logentry->name);
rename(tmp2, tmp);
logentry->logfile = fopen(tmp2, "a");
strftime (tmp2, 255, "%m-%d.log", localtime (&t));
snprintf (tmp, 255, "logs/%s-%s", logentry->name, tmp2);
snprintf (tmp2, 255, "logs/%s.log", 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 */
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
void *array[50];
size_t size;
char **strings;
size_t i;
/* thanks to gnulibc libary for letting me find this usefull function */
size = backtrace(array, 10);
strings = backtrace_symbols(array, size);
size = backtrace (array, 10);
strings = backtrace_symbols (array, size);
#endif
nlog(LOG_CRITICAL, LOG_CORE, "Assertion Failure!!!!!!!!!!!");
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, "Assertion Failure!!!!!!!!!!!");
nlog (LOG_CRITICAL, LOG_CORE, "Function: %s (%s:%d)", infunk, file, line);
nlog (LOG_CRITICAL, LOG_CORE, "Expression: %s", expr);
#ifdef HAVE_BACKTRACE
for (i = 1; i < size; i++) {
nlog(LOG_CRITICAL, LOG_CORE, "BackTrace(%d): %s",
i - 1, strings[i]);
}
for (i = 1; i < size; i++) {
nlog (LOG_CRITICAL, LOG_CORE, "BackTrace(%d): %s", i - 1, strings[i]);
}
#endif
nlog(LOG_CRITICAL, LOG_CORE, "Shutting Down!");
exit(-1);
nlog (LOG_CRITICAL, LOG_CORE, "Shutting Down!");
exit (-1);
}

10
log.h
View file

@ -20,7 +20,7 @@
** USA
**
** 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
#define __ASSERT_VOID_CAST (void)
#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) \
(__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, ...);
void *close_logs();
void init_logs();
extern void nlog (int level, int scope, char *fmt, ...);
void *close_logs ();
void init_logs ();
#endif

454
main.c
View file

@ -22,7 +22,7 @@
** USA
**
** 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>
@ -69,9 +69,9 @@ const char version_date[] = __DATE__;
/*! Time we were compiled */
const char version_time[] = __TIME__;
static void start();
static void setup_signals();
void get_options(int argc, char **argv);
static void start ();
static void setup_signals ();
void get_options (int argc, char **argv);
/*! have we forked */
@ -87,43 +87,41 @@ int forked = 0;
*
* @todo Close STDIN etc correctly
*/
int main(int argc, char *argv[])
int
main (int argc, char *argv[])
{
FILE *fp;
/* get our commandline options */
get_options(argc, argv);
get_options (argc, argv);
/* Change to the working Directory */
if (chdir(NEO_PREFIX) < 0) {
printf("NeoStats Could not change to %s\n", NEO_PREFIX);
printf("Did you 'make install' after compiling?\n");
printf("Error Was: %s\n", strerror(errno));
exit(-1);
if (chdir (NEO_PREFIX) < 0) {
printf ("NeoStats Could not change to %s\n", NEO_PREFIX);
printf ("Did you 'make install' after compiling?\n");
printf ("Error Was: %s\n", strerror (errno));
exit (-1);
}
/* before we do anything, make sure logging is setup */
init_logs();
init_logs ();
/* our crash trace variables */
strcpy(segv_location, "main");
strcpy(segvinmodule, "");
strcpy (segv_location, "main");
strcpy (segvinmodule, "");
/* for modules, let them know we are not ready */
me.onchan = 0;
/* keep quiet if we are told to :) */
if (!config.quiet) {
printf("NeoStats %d.%d.%d%s Loading...\n", MAJOR, MINOR,
REV, version);
printf
("-----------------------------------------------\n");
printf("Copyright: NeoStats Group. 2000-2003\n");
printf("Justin Hammond (fish@neostats.net)\n");
printf("Adam Rutter (shmad@neostats.net)\n");
printf("^Enigma^ (enigma@neostats.net)\n");
printf
("-----------------------------------------------\n\n");
printf ("NeoStats %d.%d.%d%s Loading...\n", MAJOR, MINOR, REV, version);
printf ("-----------------------------------------------\n");
printf ("Copyright: NeoStats Group. 2000-2003\n");
printf ("Justin Hammond (fish@neostats.net)\n");
printf ("Adam Rutter (shmad@neostats.net)\n");
printf ("^Enigma^ (enigma@neostats.net)\n");
printf ("-----------------------------------------------\n\n");
}
/* set some defaults before we parse the config file */
me.t_start = time(NULL);
me.t_start = time (NULL);
me.want_privmsg = 0;
me.enable_spam = 0;
me.die = 0;
@ -132,85 +130,78 @@ int main(int argc, char *argv[])
me.noticelag = 0;
me.usesmo = 0;
me.r_time = 10;
me.lastmsg = time(NULL);
me.lastmsg = time (NULL);
me.SendM = me.SendBytes = me.RcveM = me.RcveBytes = 0;
me.synced = 0;
me.onchan = 0;
me.maxsocks = getmaxsock();
me.maxsocks = getmaxsock ();
#ifdef ULTIMATE3
me.client = 0;
#endif
strcpy(me.modpath, "dl");
strcpy (me.modpath, "dl");
/* if we are doing recv.log, remove the previous version */
if (config.recvlog)
remove("logs/recv.log");
remove ("logs/recv.log");
/* initilze our Module subsystem */
__init_mod_list();
__init_mod_list ();
/* prepare to catch errors */
setup_signals();
setup_signals ();
/* load the config files */
ConfLoad();
ConfLoad ();
if (me.die) {
printf
("\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");
sleep(1);
close(servsock);
remove("neostats.pid");
printf ("\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");
sleep (1);
close (servsock);
remove ("neostats.pid");
/* we are exiting the parent, not the program, don't call do_exit() */
exit(0);
exit (0);
}
/* initilize the rest of the subsystems */
TimerReset();
init_dns();
init_server_hash();
init_user_hash();
init_chan_hash();
init_ircd();
TimerReset ();
init_dns ();
init_server_hash ();
init_user_hash ();
init_chan_hash ();
init_ircd ();
#ifndef DEBUG
/* if we are compiled with debug, or forground switch was specified, DONT FORK */
if (!config.foreground) {
forked = fork();
forked = fork ();
#endif
if (forked) {
/* write out our PID */
fp = fopen("neostats.pid", "w");
fprintf(fp, "%i", forked);
fclose(fp);
fp = fopen ("neostats.pid", "w");
fprintf (fp, "%i", forked);
fclose (fp);
if (!config.quiet) {
printf("\n");
printf
("NeoStats %d.%d.%d%s Successfully Launched into Background\n",
MAJOR, MINOR, REV, version);
printf("PID: %i - Wrote to neostats.pid\n",
forked);
printf ("\n");
printf ("NeoStats %d.%d.%d%s Successfully Launched into Background\n", MAJOR, MINOR, REV, version);
printf ("PID: %i - Wrote to neostats.pid\n", forked);
}
return 0;
}
#ifndef DEBUG
/* detach from parent process */
if (setpgid(0, 0) < 0) {
nlog(LOG_WARNING, LOG_CORE, "setpgid() failed");
if (setpgid (0, 0) < 0) {
nlog (LOG_WARNING, LOG_CORE, "setpgid() failed");
}
}
#endif
nlog(LOG_NOTICE, LOG_CORE,
"Statistics Started (NeoStats %d.%d.%d%s).", MAJOR, MINOR,
REV, version);
nlog (LOG_NOTICE, LOG_CORE, "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 */
init_modules();
init_modules ();
/* we are ready to start now Duh! */
start();
start ();
return 1;
}
@ -219,7 +210,8 @@ int main(int argc, char *argv[])
*
* Processes commandline options
*/
void get_options(int argc, char **argv)
void
get_options (int argc, char **argv)
{
int c;
int dbg;
@ -234,44 +226,35 @@ void get_options(int argc, char **argv)
#endif
while ((c = getopt(argc, argv, "hvrd:nqf")) != -1) {
while ((c = getopt (argc, argv, "hvrd:nqf")) != -1) {
switch (c) {
case 'h':
printf
("NeoStats: Usage: \"neostats [options]\"\n");
printf(" -h (Show this screen)\n");
printf(" -v (Show Version Number)\n");
printf(" -r (Enable Recv.log)\n");
printf
(" -d 1-10 (Enable Debuging output 1= lowest, 10 = highest)\n");
printf
(" -n (Do not load any modules on startup)\n");
printf
(" -q (Quiet Start - For Cron Scripts)\n");
printf
(" -f (Do NOt fork into BackGround\n");
exit(1);
printf ("NeoStats: Usage: \"neostats [options]\"\n");
printf (" -h (Show this screen)\n");
printf (" -v (Show Version Number)\n");
printf (" -r (Enable Recv.log)\n");
printf (" -d 1-10 (Enable Debuging output 1= lowest, 10 = highest)\n");
printf (" -n (Do not load any modules on startup)\n");
printf (" -q (Quiet Start - For Cron Scripts)\n");
printf (" -f (Do NOt fork into BackGround\n");
exit (1);
case 'v':
printf("NeoStats Version %d.%d.%d%s\n", MAJOR,
MINOR, REV, version);
printf("Compiled: %s at %s\n", version_date,
version_time);
printf
("Flag after version number indicates what IRCd NeoStats is compiled for:\n");
printf("(U) - Unreal IRCd\n");
printf("(UL3)- Ultimate 3.x.x IRCd\n");
printf
("(UL) - Ultimate 2.x.x IRCd (Depriciated)\n");
printf("(H) - Hybrid 7.x IRCd\n");
printf("(N) - NeoIRCd IRCd\n");
printf("(M) - Mystic IRCd\n");
printf("(Q) - Quantum IRCd\n");
printf("(B) - Bahamut IRCd\n");
printf("(IRCu) - IRCu (P10) IRCd\n");
printf("\nNeoStats: http://www.neostats.net\n");
exit(1);
printf ("NeoStats Version %d.%d.%d%s\n", MAJOR, MINOR, REV, version);
printf ("Compiled: %s at %s\n", version_date, version_time);
printf ("Flag after version number indicates what IRCd NeoStats is compiled for:\n");
printf ("(U) - Unreal IRCd\n");
printf ("(UL3)- Ultimate 3.x.x IRCd\n");
printf ("(UL) - Ultimate 2.x.x IRCd (Depriciated)\n");
printf ("(H) - Hybrid 7.x IRCd\n");
printf ("(N) - NeoIRCd IRCd\n");
printf ("(M) - Mystic IRCd\n");
printf ("(Q) - Quantum IRCd\n");
printf ("(B) - Bahamut IRCd\n");
printf ("(IRCu) - IRCu (P10) IRCd\n");
printf ("\nNeoStats: http://www.neostats.net\n");
exit (1);
case 'r':
printf("Recv.log enabled. Watch your DiskSpace\n");
printf ("Recv.log enabled. Watch your DiskSpace\n");
config.recvlog = 1;
break;
case 'n':
@ -281,10 +264,10 @@ void get_options(int argc, char **argv)
config.quiet = 1;
break;
case 'd':
dbg = atoi(optarg);
dbg = atoi (optarg);
if ((dbg > 10) || (dbg < 1)) {
printf("Invalid Debug Level %d\n", dbg);
exit(1);
printf ("Invalid Debug Level %d\n", dbg);
exit (1);
}
config.debug = dbg;
break;
@ -292,7 +275,7 @@ void get_options(int argc, char **argv)
config.foreground = 1;
break;
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 :)
*/
RETSIGTYPE serv_die()
RETSIGTYPE
serv_die ()
{
User *u;
u = finduser(s_Services);
nlog(LOG_CRITICAL, LOG_CORE,
"Sigterm Recieved, Shuting Down Server!!!!");
ns_shutdown(u, "SigTerm Recieved");
ssquit_cmd(me.name);
u = finduser (s_Services);
nlog (LOG_CRITICAL, LOG_CORE, "Sigterm Recieved, Shuting Down Server!!!!");
ns_shutdown (u, "SigTerm Recieved");
ssquit_cmd (me.name);
}
@ -330,18 +313,19 @@ RETSIGTYPE serv_die()
*
* @todo Implement a Rehash function. What can we actually rehash?
*/
RETSIGTYPE conf_rehash()
RETSIGTYPE
conf_rehash ()
{
/* struct sigaction act; */
chanalert(s_Services, "Recieved SIGHUP, Attempting to Rehash");
globops(me.name, "Received SIGHUP, Attempted to Rehash");
chanalert (s_Services, "Recieved SIGHUP, Attempting to Rehash");
globops (me.name, "Received SIGHUP, Attempted to Rehash");
/* act.sa_handler = conf_rehash;
act.sa_flags=0;
(void)sigemptyset(&act.sa_mask);
(void)sigaddset(&act.sa_mask, SIGHUP);
(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? */
@ -362,7 +346,8 @@ RETSIGTYPE conf_rehash()
*
*/
RETSIGTYPE serv_segv()
RETSIGTYPE
serv_segv ()
{
char name[30];
#ifdef HAVE_BACKTRACE
@ -371,87 +356,61 @@ RETSIGTYPE serv_segv()
char **strings;
size_t i;
/* thanks to gnulibc libary for letting me find this usefull function */
size = backtrace(array, 10);
strings = backtrace_symbols(array, size);
size = backtrace (array, 10);
strings = backtrace_symbols (array, size);
#endif
/** 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
* and continue on
*/
if (strlen(segvinmodule) > 1) {
globops(me.name,
"Oh Damn, Module %s Segv'd, Unloading Module",
segvinmodule);
chanalert(s_Services,
"Oh Damn, Module %s Segv'd, Unloading Module",
segvinmodule);
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);
if (strlen (segvinmodule) > 1) {
globops (me.name, "Oh Damn, Module %s Segv'd, Unloading Module", segvinmodule);
chanalert (s_Services, "Oh Damn, Module %s Segv'd, Unloading Module", segvinmodule);
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
for (i = 1; i < size; i++) {
chanalert(s_Services, "Backtrace(%d): %s", i,
strings[i]);
nlog(LOG_CRITICAL, LOG_CORE, "BackTrace(%d): %s",
i - 1, strings[i]);
chanalert (s_Services, "Backtrace(%d): %s", i, strings[i]);
nlog (LOG_CRITICAL, LOG_CORE, "BackTrace(%d): %s", i - 1, strings[i]);
}
#else
chanalert(s_Services,
"Backtrace not available on this platform");
nlog(LOG_CRITICAL, LOG_CORE,
"Backtrace not available on this platform");
chanalert (s_Services, "Backtrace not available on this platform");
nlog (LOG_CRITICAL, LOG_CORE, "Backtrace not available on this platform");
#endif
strcpy(name, segvinmodule);
strcpy(segvinmodule, "");
unload_module(name, NULL);
chanalert(s_Services, "Restoring Stack to before Crash");
longjmp(sigvbuf, -1);
chanalert(s_Services, "Done");
strcpy (name, segvinmodule);
strcpy (segvinmodule, "");
unload_module (name, NULL);
chanalert (s_Services, "Restoring Stack to before Crash");
longjmp (sigvbuf, -1);
chanalert (s_Services, "Done");
#ifdef HAVE_BACKTRACE
free(strings);
free (strings);
#endif
} else {
/** The segv happened in our core, damn it */
/* Thanks to Stskeeps and Unreal for this stuff :) */
nlog(LOG_CRITICAL, LOG_CORE,
"Uh Oh, Segmentation Fault.. Server Terminating");
nlog(LOG_CRITICAL, LOG_CORE, "Details: Buffer: %s",
recbuf);
nlog(LOG_CRITICAL, LOG_CORE,
"Approx Location: %s Backtrace:", segv_location);
nlog (LOG_CRITICAL, LOG_CORE, "Uh Oh, Segmentation Fault.. Server Terminating");
nlog (LOG_CRITICAL, LOG_CORE, "Details: Buffer: %s", recbuf);
nlog (LOG_CRITICAL, LOG_CORE, "Approx Location: %s Backtrace:", segv_location);
/* Broadcast it out! */
globops(me.name,
"Ohhh Crap, Server Terminating, Segmentation Fault. Buffer: %s, Approx Location %s",
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);
globops (me.name, "Ohhh Crap, Server Terminating, Segmentation Fault. Buffer: %s, Approx Location %s", 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
for (i = 1; i < size; i++) {
chanalert(s_Services, "Backtrace(%d): %s", i,
strings[i]);
nlog(LOG_CRITICAL, LOG_CORE, "BackTrace(%d): %s",
i - 1, strings[i]);
chanalert (s_Services, "Backtrace(%d): %s", i, strings[i]);
nlog (LOG_CRITICAL, LOG_CORE, "BackTrace(%d): %s", i - 1, strings[i]);
}
#else
chanalert(s_Services,
"Backtrace not available on this platform");
nlog(LOG_CRITICAL, LOG_CORE,
"Backtrace not available on this platform");
chanalert (s_Services, "Backtrace not available on this platform");
nlog (LOG_CRITICAL, LOG_CORE, "Backtrace not available on this platform");
#endif
sleep(2);
kill(forked, 3);
kill(forked, 9);
sleep (2);
kill (forked, 3);
kill (forked, 9);
/* clean up */
do_exit(1);
do_exit (1);
}
}
@ -464,38 +423,39 @@ RETSIGTYPE serv_segv()
* @return Nothing
*
*/
static void setup_signals()
static void
setup_signals ()
{
struct sigaction act;
act.sa_handler = SIG_IGN;
act.sa_flags = 0;
(void) sigemptyset(&act.sa_mask);
(void) sigaddset(&act.sa_mask, SIGPIPE);
(void) sigaddset(&act.sa_mask, SIGALRM);
(void) sigaction(SIGPIPE, &act, NULL);
(void) sigaction(SIGALRM, &act, NULL);
(void) sigemptyset (&act.sa_mask);
(void) sigaddset (&act.sa_mask, SIGPIPE);
(void) sigaddset (&act.sa_mask, SIGALRM);
(void) sigaction (SIGPIPE, &act, NULL);
(void) sigaction (SIGALRM, &act, NULL);
act.sa_handler = conf_rehash;
(void) sigemptyset(&act.sa_mask);
(void) sigaddset(&act.sa_mask, SIGHUP);
(void) sigaction(SIGHUP, &act, NULL);
(void) sigemptyset (&act.sa_mask);
(void) sigaddset (&act.sa_mask, SIGHUP);
(void) sigaction (SIGHUP, &act, NULL);
act.sa_handler = serv_die;
(void) sigaddset(&act.sa_mask, SIGTERM);
(void) sigaction(SIGTERM, &act, NULL);
(void) sigaddset(&act.sa_mask, SIGINT);
(void) sigaction(SIGINT, &act, NULL);
(void) sigaddset (&act.sa_mask, SIGTERM);
(void) sigaction (SIGTERM, &act, NULL);
(void) sigaddset (&act.sa_mask, SIGINT);
(void) sigaction (SIGINT, &act, NULL);
/* handling of SIGSEGV as well -sts */
act.sa_handler = serv_segv;
(void) sigaddset(&act.sa_mask, SIGSEGV);
(void) sigaction(SIGSEGV, &act, NULL);
(void) sigaddset (&act.sa_mask, SIGSEGV);
(void) sigaction (SIGSEGV, &act, NULL);
(void) signal(SIGHUP, conf_rehash);
(void) signal(SIGTERM, serv_die);
(void) signal(SIGSEGV, serv_segv);
(void) signal(SIGINT, serv_die);
(void) signal (SIGHUP, conf_rehash);
(void) signal (SIGTERM, serv_die);
(void) signal (SIGSEGV, serv_segv);
(void) signal (SIGINT, serv_die);
}
/** @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
*/
void start()
void
start ()
{
static int attempts = 0;
Module *mod_ptr = NULL;
hscan_t ms;
hnode_t *mn;
strcpy(segv_location, "start");
strcpy (segv_location, "start");
nlog(LOG_NOTICE, LOG_CORE, "Connecting to %s:%d", me.uplink,
me.port);
nlog (LOG_NOTICE, LOG_CORE, "Connecting to %s:%d", me.uplink, me.port);
if (servsock > 0)
close(servsock);
close (servsock);
servsock = ConnectTo(me.uplink, me.port);
servsock = ConnectTo (me.uplink, me.port);
if (servsock <= 0) {
nlog(LOG_WARNING, LOG_CORE, "Unable to connect to %s",
me.uplink);
nlog (LOG_WARNING, LOG_CORE, "Unable to connect to %s", me.uplink);
} else {
attempts = 0;
login();
read_loop();
login ();
read_loop ();
}
nlog(LOG_NOTICE, LOG_CORE,
"Reconnecting to the server in %d seconds (Attempt %i)",
me.r_time, attempts);
close(servsock);
nlog (LOG_NOTICE, LOG_CORE, "Reconnecting to the server in %d seconds (Attempt %i)", me.r_time, attempts);
close (servsock);
/* Unload the Modules */
hash_scan_begin(&ms, mh);
while ((mn = hash_scan_next(&ms)) != NULL) {
mod_ptr = hnode_get(mn);
unload_module(mod_ptr->info->module_name,
finduser(s_Services));
hash_scan_begin (&ms, mh);
while ((mn = hash_scan_next (&ms)) != NULL) {
mod_ptr = hnode_get (mn);
unload_module (mod_ptr->info->module_name, finduser (s_Services));
}
sleep(5);
do_exit(2);
sleep (5);
do_exit (2);
}
/** @brief Login to IRC
@ -557,11 +513,12 @@ void start()
*
*/
void login()
void
login ()
{
strcpy(segv_location, "login");
slogin_cmd(me.name, 1, me.infoline, me.pass);
sprotocol_cmd("TOKEN CLIENT");
strcpy (segv_location, "login");
slogin_cmd (me.name, 1, me.infoline, me.pass);
sprotocol_cmd ("TOKEN CLIENT");
}
/** @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
*/
void *smalloc(long size)
void *
smalloc (long size)
{
void *buf;
strcpy(segv_location, "smalloc");
strcpy (segv_location, "smalloc");
if (!size) {
nlog(LOG_WARNING, LOG_CORE,
"smalloc(): illegal attempt to allocate 0 bytes!");
nlog (LOG_WARNING, LOG_CORE, "smalloc(): illegal attempt to allocate 0 bytes!");
size = 1;
}
buf = malloc(size);
buf = malloc (size);
if (!buf) {
nlog(LOG_CRITICAL, LOG_CORE, "smalloc(): out of memory.");
do_exit(1);
nlog (LOG_CRITICAL, LOG_CORE, "smalloc(): out of memory.");
do_exit (1);
}
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) {
nlog(LOG_CRITICAL, LOG_CORE, "sstrdup(): out of memory.");
do_exit(1);
nlog (LOG_CRITICAL, LOG_CORE, "sstrdup(): out of memory.");
do_exit (1);
}
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;
@ -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;
t = malloc(strlen(s));
strncpy(t, s, strlen(s));
t = malloc (strlen (s));
strncpy (t, s, strlen (s));
while (*t) {
*t++ = tolower(*t);
*t++ = tolower (*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) {
*List = calloc(sizeof(char *) * 8, 1);
*List = calloc (sizeof (char *) * 8, 1);
}
++*C;
(*List)[*C - 1] = S;
@ -695,11 +656,12 @@ void AddStringToList(char ***List, char S[], int *C)
* @returns Nothing
*
*/
void FreeList(char **List, int C)
void
FreeList (char **List, int C)
{
int i;
for (i = 0; i == C; i++)
free(List[i]);
free (List[i]);
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.
* if 1, we don't prompt to save data
*/
void do_exit(int segv)
void
do_exit (int segv)
{
switch (segv) {
case 0:
nlog(LOG_CRITICAL, LOG_CORE,
"Normal shut down SubSystems");
nlog (LOG_CRITICAL, LOG_CORE, "Normal shut down SubSystems");
break;
case 2:
nlog(LOG_CRITICAL, LOG_CORE,
"Restarting NeoStats SubSystems");
nlog (LOG_CRITICAL, LOG_CORE, "Restarting NeoStats SubSystems");
break;
case 1:
nlog(LOG_CRITICAL, LOG_CORE,
"Shutting Down SubSystems without saving data due to core");
nlog (LOG_CRITICAL, LOG_CORE, "Shutting Down SubSystems without saving data due to core");
break;
}
close_logs();
close_logs ();
if (segv == 1) {
exit(-1);
exit (-1);
} else if (segv == 2) {
execve("./neostats", NULL, NULL);
execve ("./neostats", NULL, NULL);
} 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
**
** 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
#define MYSTIC_H
@ -32,285 +32,285 @@
#define GOTSVSVHOST
#define MSG_PRIVATE "PRIVMSG" /* PRIV */
#define TOK_PRIVATE "!" /* 33 */
#define MSG_WHO "WHO" /* WHO -> WHOC */
#define TOK_WHO "\"" /* 34 */
#define MSG_WHOIS "WHOIS" /* WHOI */
#define TOK_WHOIS "#" /* 35 */
#define TOK_PRIVATE "!" /* 33 */
#define MSG_WHO "WHO" /* WHO -> WHOC */
#define TOK_WHO "\"" /* 34 */
#define MSG_WHOIS "WHOIS" /* WHOI */
#define TOK_WHOIS "#" /* 35 */
#define MSG_WHOWAS "WHOWAS" /* WHOW */
#define TOK_WHOWAS "$" /* 36 */
#define MSG_USER "USER" /* USER */
#define TOK_USER "%" /* 37 */
#define MSG_NICK "NICK" /* NICK */
#define TOK_NICK "&" /* 38 */
#define TOK_WHOWAS "$" /* 36 */
#define MSG_USER "USER" /* USER */
#define TOK_USER "%" /* 37 */
#define MSG_NICK "NICK" /* NICK */
#define TOK_NICK "&" /* 38 */
#define MSG_SERVER "SERVER" /* SERV */
#define TOK_SERVER "'" /* 39 */
#define MSG_LIST "LIST" /* LIST */
#define TOK_LIST "(" /* 40 */
#define MSG_TOPIC "TOPIC" /* TOPI */
#define TOK_TOPIC ")" /* 41 */
#define TOK_SERVER "'" /* 39 */
#define MSG_LIST "LIST" /* LIST */
#define TOK_LIST "(" /* 40 */
#define MSG_TOPIC "TOPIC" /* TOPI */
#define TOK_TOPIC ")" /* 41 */
#define MSG_INVITE "INVITE" /* INVI */
#define TOK_INVITE "*" /* 42 */
#define TOK_INVITE "*" /* 42 */
#define MSG_VERSION "VERSION" /* VERS */
#define TOK_VERSION "+" /* 43 */
#define MSG_QUIT "QUIT" /* QUIT */
#define TOK_QUIT "," /* 44 */
#define MSG_SQUIT "SQUIT" /* SQUI */
#define TOK_SQUIT "-" /* 45 */
#define MSG_KILL "KILL" /* KILL */
#define TOK_KILL "." /* 46 */
#define MSG_INFO "INFO" /* INFO */
#define TOK_INFO "/" /* 47 */
#define MSG_LINKS "LINKS" /* LINK */
#define TOK_LINKS "0" /* 48 */
#define MSG_WATCH "WATCH" /* WATCH */
#define TOK_WATCH "1" /* 49 */
#define MSG_STATS "STATS" /* STAT */
#define TOK_STATS "2" /* 50 */
#define MSG_HELP "HELP" /* HELP */
#define TOK_VERSION "+" /* 43 */
#define MSG_QUIT "QUIT" /* QUIT */
#define TOK_QUIT "," /* 44 */
#define MSG_SQUIT "SQUIT" /* SQUI */
#define TOK_SQUIT "-" /* 45 */
#define MSG_KILL "KILL" /* KILL */
#define TOK_KILL "." /* 46 */
#define MSG_INFO "INFO" /* INFO */
#define TOK_INFO "/" /* 47 */
#define MSG_LINKS "LINKS" /* LINK */
#define TOK_LINKS "0" /* 48 */
#define MSG_WATCH "WATCH" /* WATCH */
#define TOK_WATCH "1" /* 49 */
#define MSG_STATS "STATS" /* STAT */
#define TOK_STATS "2" /* 50 */
#define MSG_HELP "HELP" /* HELP */
#define MSG_HELPOP "HELPOP" /* HELP */
#define TOK_HELP "4" /* 52 */
#define MSG_ERROR "ERROR" /* ERRO */
#define TOK_ERROR "5" /* 53 */
#define MSG_AWAY "AWAY" /* AWAY */
#define TOK_AWAY "6" /* 54 */
#define TOK_HELP "4" /* 52 */
#define MSG_ERROR "ERROR" /* ERRO */
#define TOK_ERROR "5" /* 53 */
#define MSG_AWAY "AWAY" /* AWAY */
#define TOK_AWAY "6" /* 54 */
#define MSG_CONNECT "CONNECT" /* CONN */
#define TOK_CONNECT "7" /* 55 */
#define MSG_PING "PING" /* PING */
#define TOK_PING "8" /* 56 */
#define MSG_PONG "PONG" /* PONG */
#define TOK_PONG "9" /* 57 */
#define MSG_OPER "OPER" /* OPER */
#define TOK_OPER ";" /* 59 */
#define MSG_PASS "PASS" /* PASS */
#define TOK_PASS "<" /* 60 */
#define TOK_CONNECT "7" /* 55 */
#define MSG_PING "PING" /* PING */
#define TOK_PING "8" /* 56 */
#define MSG_PONG "PONG" /* PONG */
#define TOK_PONG "9" /* 57 */
#define MSG_OPER "OPER" /* OPER */
#define TOK_OPER ";" /* 59 */
#define MSG_PASS "PASS" /* PASS */
#define TOK_PASS "<" /* 60 */
#define MSG_WALLOPS "WALLOPS" /* WALL */
#define TOK_WALLOPS "=" /* 61 */
#define MSG_TIME "TIME" /* TIME */
#define TOK_TIME ">" /* 62 */
#define MSG_NAMES "NAMES" /* NAME */
#define TOK_NAMES "?" /* 63 */
#define MSG_ADMIN "ADMIN" /* ADMI */
#define TOK_ADMIN "@" /* 64 */
#define TOK_WALLOPS "=" /* 61 */
#define MSG_TIME "TIME" /* TIME */
#define TOK_TIME ">" /* 62 */
#define MSG_NAMES "NAMES" /* NAME */
#define TOK_NAMES "?" /* 63 */
#define MSG_ADMIN "ADMIN" /* ADMI */
#define TOK_ADMIN "@" /* 64 */
#define MSG_NOTICE "NOTICE" /* NOTI */
#define TOK_NOTICE "B" /* 66 */
#define MSG_JOIN "JOIN" /* JOIN */
#define TOK_JOIN "C" /* 67 */
#define MSG_PART "PART" /* PART */
#define TOK_PART "D" /* 68 */
#define TOK_NOTICE "B" /* 66 */
#define MSG_JOIN "JOIN" /* JOIN */
#define TOK_JOIN "C" /* 67 */
#define MSG_PART "PART" /* PART */
#define TOK_PART "D" /* 68 */
#define MSG_LUSERS "LUSERS" /* LUSE */
#define TOK_LUSERS "E" /* 69 */
#define MSG_MOTD "MOTD" /* MOTD */
#define TOK_MOTD "F" /* 70 */
#define MSG_MODE "MODE" /* MODE */
#define TOK_MODE "G" /* 71 */
#define MSG_KICK "KICK" /* KICK */
#define TOK_KICK "H" /* 72 */
#define TOK_LUSERS "E" /* 69 */
#define MSG_MOTD "MOTD" /* MOTD */
#define TOK_MOTD "F" /* 70 */
#define MSG_MODE "MODE" /* MODE */
#define TOK_MODE "G" /* 71 */
#define MSG_KICK "KICK" /* KICK */
#define TOK_KICK "H" /* 72 */
#define MSG_SERVICE "SERVICE" /* SERV -> SRVI */
#define TOK_SERVICE "I" /* 73 */
#define TOK_SERVICE "I" /* 73 */
#define MSG_USERHOST "USERHOST" /* USER -> USRH */
#define TOK_USERHOST "J" /* 74 */
#define MSG_ISON "ISON" /* ISON */
#define TOK_ISON "K" /* 75 */
#define TOK_USERHOST "J" /* 74 */
#define MSG_ISON "ISON" /* ISON */
#define TOK_ISON "K" /* 75 */
#define MSG_SQUERY "SQUERY" /* SQUE */
#define TOK_SQUERY "L" /* 76 */
#define TOK_SQUERY "L" /* 76 */
#define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */
#define TOK_SERVLIST "M" /* 77 */
#define TOK_SERVLIST "M" /* 77 */
#define MSG_SERVSET "SERVSET" /* SERV -> SSET */
#define TOK_SERVSET "N" /* 78 */
#define TOK_SERVSET "N" /* 78 */
#define MSG_REHASH "REHASH" /* REHA */
#define TOK_REHASH "O" /* 79 */
#define TOK_REHASH "O" /* 79 */
#define MSG_RESTART "RESTART" /* REST */
#define TOK_RESTART "P" /* 80 */
#define MSG_CLOSE "CLOSE" /* CLOS */
#define TOK_CLOSE "Q" /* 81 */
#define MSG_DIE "DIE" /* DIE */
#define TOK_DIE "R" /* 82 */
#define MSG_HASH "HASH" /* HASH */
#define TOK_HASH "S" /* 83 */
#define MSG_DNS "DNS" /* DNS -> DNSS */
#define TOK_DNS "T" /* 84 */
#define TOK_RESTART "P" /* 80 */
#define MSG_CLOSE "CLOSE" /* CLOS */
#define TOK_CLOSE "Q" /* 81 */
#define MSG_DIE "DIE" /* DIE */
#define TOK_DIE "R" /* 82 */
#define MSG_HASH "HASH" /* HASH */
#define TOK_HASH "S" /* 83 */
#define MSG_DNS "DNS" /* DNS -> DNSS */
#define TOK_DNS "T" /* 84 */
#define MSG_SILENCE "SILENCE" /* SILE */
#define TOK_SILENCE "U" /* 85 */
#define MSG_AKILL "AKILL" /* AKILL */
#define TOK_AKILL "V" /* 86 */
#define MSG_KLINE "KLINE" /* KLINE */
#define TOK_KLINE "W" /* 87 */
#define MSG_UNKLINE "UNKLINE" /* UNKLINE */
#define TOK_UNKLINE "X" /* 88 */
#define TOK_SILENCE "U" /* 85 */
#define MSG_AKILL "AKILL" /* AKILL */
#define TOK_AKILL "V" /* 86 */
#define MSG_KLINE "KLINE" /* KLINE */
#define TOK_KLINE "W" /* 87 */
#define MSG_UNKLINE "UNKLINE" /* UNKLINE */
#define TOK_UNKLINE "X" /* 88 */
#define MSG_RAKILL "RAKILL" /* RAKILL */
#define TOK_RAKILL "Y" /* 89 */
#define TOK_RAKILL "Y" /* 89 */
#define MSG_GNOTICE "GNOTICE" /* GNOTICE */
#define TOK_GNOTICE "Z" /* 90 */
#define MSG_GOPER "GOPER" /* GOPER */
#define TOK_GOPER "[" /* 91 */
#define TOK_GNOTICE "Z" /* 90 */
#define MSG_GOPER "GOPER" /* GOPER */
#define TOK_GOPER "[" /* 91 */
#define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */
#define TOK_GLOBOPS "]" /* 93 */
#define TOK_GLOBOPS "]" /* 93 */
#define MSG_LOCOPS "LOCOPS" /* LOCOPS */
#define TOK_LOCOPS "^" /* 94 */
#define TOK_LOCOPS "^" /* 94 */
#define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */
#define TOK_PROTOCTL "_" /* 95 */
#define MSG_TRACE "TRACE" /* TRAC */
#define TOK_TRACE "b" /* 98 */
#define TOK_PROTOCTL "_" /* 95 */
#define MSG_TRACE "TRACE" /* TRAC */
#define TOK_TRACE "b" /* 98 */
#define MSG_SQLINE "SQLINE" /* SQLINE */
#define TOK_SQLINE "c" /* 99 */
#define TOK_SQLINE "c" /* 99 */
#define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */
#define TOK_UNSQLINE "d" /* 100 */
#define TOK_UNSQLINE "d" /* 100 */
#define MSG_SVSNICK "SVSNICK" /* SVSNICK */
#define TOK_SVSNICK "e" /* 101 */
#define TOK_SVSNICK "e" /* 101 */
#define MSG_SVSNOOP "SVSNOOP" /* SVSNOOP */
#define TOK_SVSNOOP "f" /* 101 */
#define TOK_SVSNOOP "f" /* 101 */
#define MSG_IDENTIFY "IDENTIFY" /* IDENTIFY */
#define TOK_IDENTIFY "g" /* 103 */
#define TOK_IDENTIFY "g" /* 103 */
#define MSG_SVSKILL "SVSKILL" /* SVSKILL */
#define TOK_SVSKILL "h" /* 104 */
#define TOK_SVSKILL "h" /* 104 */
#define MSG_NICKSERV "NICKSERV" /* NICKSERV */
#define MSG_NS "NS"
#define TOK_NICKSERV "i" /* 105 */
#define TOK_NICKSERV "i" /* 105 */
#define MSG_CHANSERV "CHANSERV" /* CHANSERV */
#define MSG_CS "CS"
#define TOK_CHANSERV "j" /* 106 */
#define TOK_CHANSERV "j" /* 106 */
#define MSG_OPERSERV "OPERSERV" /* OPERSERV */
#define MSG_OS "OS"
#define TOK_OPERSERV "k" /* 107 */
#define TOK_OPERSERV "k" /* 107 */
#define MSG_MEMOSERV "MEMOSERV" /* MEMOSERV */
#define MSG_MS "MS"
#define TOK_MEMOSERV "l" /* 108 */
#define TOK_MEMOSERV "l" /* 108 */
#define MSG_SERVICES "SERVICES" /* SERVICES */
#define TOK_SERVICES "m" /* 109 */
#define TOK_SERVICES "m" /* 109 */
#define MSG_SVSMODE "SVSMODE" /* SVSMODE */
#define TOK_SVSMODE "n" /* 110 */
#define TOK_SVSMODE "n" /* 110 */
#define MSG_SAMODE "SAMODE" /* SAMODE */
#define TOK_SAMODE "o" /* 111 */
#define TOK_SAMODE "o" /* 111 */
#define MSG_CHATOPS "CHATOPS" /* CHATOPS */
#define TOK_CHATOPS "p" /* 112 */
#define MSG_HELPSERV "HELPSERV" /* HELPSERV */
#define TOK_HELPSERV "r" /* 114 */
#define MSG_ZLINE "ZLINE" /* ZLINE */
#define TOK_ZLINE "s" /* 115 */
#define TOK_CHATOPS "p" /* 112 */
#define MSG_HELPSERV "HELPSERV" /* HELPSERV */
#define TOK_HELPSERV "r" /* 114 */
#define MSG_ZLINE "ZLINE" /* ZLINE */
#define TOK_ZLINE "s" /* 115 */
#define MSG_UNZLINE "UNZLINE" /* UNZLINE */
#define TOK_UNZLINE "t" /* 116 */
#define TOK_UNZLINE "t" /* 116 */
#define MSG_NETINFO "NETINFO" /* NETINFO */
#define TOK_NETINFO "u" /* 117 */
#define MSG_RULES "RULES" /* RULES */
#define TOK_RULES "v" /* 118 */
#define MSG_MAP "MAP" /* MAP */
#define TOK_MAP "w" /* 119 */
#define MSG_NETG "NETG" /* NETG */
#define TOK_NETG "x" /* 120 */
#define MSG_ADCHAT "ADCHAT" /* Adchat */
#define TOK_ADCHAT "y" /* 121 */
#define TOK_NETINFO "u" /* 117 */
#define MSG_RULES "RULES" /* RULES */
#define TOK_RULES "v" /* 118 */
#define MSG_MAP "MAP" /* MAP */
#define TOK_MAP "w" /* 119 */
#define MSG_NETG "NETG" /* NETG */
#define TOK_NETG "x" /* 120 */
#define MSG_ADCHAT "ADCHAT" /* Adchat */
#define TOK_ADCHAT "y" /* 121 */
#define MSG_MAKEPASS "MAKEPASS" /* MAKEPASS */
#define TOK_MAKEPASS "z" /* 122 */
#define TOK_MAKEPASS "z" /* 122 */
#define MSG_ADDHUB "ADDHUB" /* ADDHUB */
#define TOK_ADDHUB "{" /* 123 */
#define TOK_ADDHUB "{" /* 123 */
#define MSG_DELHUB "DELHUB" /* DELHUB */
#define TOK_DELHUB "|" /* 124 */
#define TOK_DELHUB "|" /* 124 */
#define MSG_ADDCNLINE "ADDCNLINE" /* ADDCNLINE */
#define TOK_ADDCNLINE "}" /* 125 */
#define TOK_ADDCNLINE "}" /* 125 */
#define MSG_DELCNLINE "DELCNLINE" /* DELCNLINE */
#define TOK_DELCNLINE "~" /* 126 */
#define TOK_DELCNLINE "~" /* 126 */
#define MSG_ADDOPER "ADDOPER" /* ADDOPER */
#define TOK_ADDOPER "" /* 127 */
#define TOK_ADDOPER "" /* 127 */
#define MSG_DELOPER "DELOPER" /* DELOPER */
#define TOK_DELOPER "!!" /* 33 + 33 */
#define TOK_DELOPER "!!" /* 33 + 33 */
#define MSG_ADDQLINE "ADDQLINE" /* ADDQLINE */
#define TOK_ADDQLINE "!\"" /* 33 + 34 */
#define TOK_ADDQLINE "!\"" /* 33 + 34 */
#define MSG_DELQLINE "DELQLINE" /* DELQLINE */
#define TOK_DELQLINE "!#" /* 33 + 35 */
#define MSG_GSOP "GSOP" /* GSOP */
#define TOK_GSOP "!$" /* 33 + 36 */
#define MSG_ISOPER "ISOPER" /* ISOPER */
#define TOK_ISOPER "!%" /* 33 + 37 */
#define MSG_ADG "ADG" /* ADG */
#define TOK_ADG "!&" /* 33 + 38 */
#define MSG_NMON "NMON" /* NMON */
#define TOK_NMON "!'" /* 33 + 39 */
#define TOK_DELQLINE "!#" /* 33 + 35 */
#define MSG_GSOP "GSOP" /* GSOP */
#define TOK_GSOP "!$" /* 33 + 36 */
#define MSG_ISOPER "ISOPER" /* ISOPER */
#define TOK_ISOPER "!%" /* 33 + 37 */
#define MSG_ADG "ADG" /* ADG */
#define TOK_ADG "!&" /* 33 + 38 */
#define MSG_NMON "NMON" /* NMON */
#define TOK_NMON "!'" /* 33 + 39 */
#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 TOK_CREDITS "!)" /* 33 + 41 */
#define MSG_OPERMOTD "OPERMOTD" /* OPERMOTD */
#define TOK_OPERMOTD "!*" /* 33 + 42 */
#define TOK_CREDITS "!)" /* 33 + 41 */
#define MSG_OPERMOTD "OPERMOTD" /* OPERMOTD */
#define TOK_OPERMOTD "!*" /* 33 + 42 */
#define MSG_REMREHASH "REMREHASH" /* Remote Rehash */
#define TOK_REMREHASH "!+" /* 33 + 43 */
#define TOK_REMREHASH "!+" /* 33 + 43 */
#define MSG_MONITOR "MONITOR" /* MONITOR */
#define TOK_MONITOR "!," /* 33 + 44 */
#define MSG_GLINE "GLINE" /* The awesome g-line */
#define TOK_GLINE "!-" /* 33 + 45 */
#define TOK_MONITOR "!," /* 33 + 44 */
#define MSG_GLINE "GLINE" /* The awesome g-line */
#define TOK_GLINE "!-" /* 33 + 45 */
#define MSG_REMGLINE "REMGLINE" /* remove g-line */
#define TOK_REMGLINE "!." /* 33 + 46 */
#define TOK_REMGLINE "!." /* 33 + 46 */
#define MSG_STATSERV "STATSERV" /* StatServ */
#define TOK_STATSERV "!/" /* 33 + 47 */
#define TOK_STATSERV "!/" /* 33 + 47 */
#define MSG_RULESERV "RULESERV" /* RuleServ */
#define TOK_RULESERV "!0" /* 33 + 48 */
#define TOK_RULESERV "!0" /* 33 + 48 */
#define MSG_SNETINFO "SNETINFO" /* SNetInfo */
#define TOK_SNETINFO "!1" /* 33 + 49 */
#define MSG_TSCTL "TSCTL" /* TSCTL */
#define TOK_TSCTL "!3" /* 33 + 51 */
#define TOK_SNETINFO "!1" /* 33 + 49 */
#define MSG_TSCTL "TSCTL" /* TSCTL */
#define TOK_TSCTL "!3" /* 33 + 51 */
#define MSG_SVSJOIN "SVSJOIN" /* SVSJOIN */
#define TOK_SVSJOIN "!4" /* 33 + 52 */
#define TOK_SVSJOIN "!4" /* 33 + 52 */
#define MSG_SAJOIN "SAJOIN" /* SAJOIN */
#define TOK_SAJOIN "!5" /* 33 + 53 */
#define MSG_SDESC "SDESC" /* SDESC */
#define TOK_SDESC "!6" /* 33 + 54 */
#define TOK_SAJOIN "!5" /* 33 + 53 */
#define MSG_SDESC "SDESC" /* SDESC */
#define TOK_SDESC "!6" /* 33 + 54 */
#define MSG_UNREALINFO "UNREALINFO" /* Unreal Info */
#define TOK_UNREALINFO "!7" /* 33 + 55 */
#define MSG_SETHOST "SETHOST" /* sethost */
#define TOK_SETHOST "!8" /* 33 + 56 */
#define MSG_SETIDENT "SETIDENT" /* set ident */
#define TOK_SETIDENT "!9" /* 33 + 57 */
#define MSG_SETNAME "SETNAME" /* set Realname */
#define TOK_SETNAME "!;" /* 33 + 59 */
#define TOK_UNREALINFO "!7" /* 33 + 55 */
#define MSG_SETHOST "SETHOST" /* sethost */
#define TOK_SETHOST "!8" /* 33 + 56 */
#define MSG_SETIDENT "SETIDENT" /* set ident */
#define TOK_SETIDENT "!9" /* 33 + 57 */
#define MSG_SETNAME "SETNAME" /* set Realname */
#define TOK_SETNAME "!;" /* 33 + 59 */
#define MSG_CHGHOST "CHGHOST" /* Changehost */
#define TOK_CHGHOST "!<" /* 33 + 60 */
#define TOK_CHGHOST "!<" /* 33 + 60 */
#define MSG_CHGIDENT "CHGIDENT" /* Change Ident */
#define TOK_CHGIDENT "!=" /* 33 + 61 */
#define TOK_CHGIDENT "!=" /* 33 + 61 */
#define MSG_RANDQUOTE "RANDQUOTE" /* Random Quote */
#define TOK_RANDQUOTE "!>" /* 33 + 62 */
#define TOK_RANDQUOTE "!>" /* 33 + 62 */
#define MSG_ADDQUOTE "ADDQUOTE" /* Add Quote */
#define TOK_ADDQUOTE "!?" /* 33 + 63 */
#define TOK_ADDQUOTE "!?" /* 33 + 63 */
#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 TOK_ADDULINE "!B" /* 33 + 66 */
#define TOK_ADDULINE "!B" /* 33 + 66 */
#define MSG_DELULINE "DELULINE" /* Removes an U line from the ircd.conf */
#define TOK_DELULINE "!C" /* 33 + 67 */
#define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */
#define TOK_KNOCK "!D" /* 33 + 68 */
#define TOK_DELULINE "!C" /* 33 + 67 */
#define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */
#define TOK_KNOCK "!D" /* 33 + 68 */
#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 TOK_IRCOPS "!F" /* 33 + 70 */
#define TOK_IRCOPS "!F" /* 33 + 70 */
#define MSG_SVSPART "SVSPART" /* SVSPART */
#define TOK_SVSPART "!G" /* 33 + 71 */
#define TOK_SVSPART "!G" /* 33 + 71 */
#define MSG_SAPART "SAPART" /* SAPART */
#define TOK_SAPART "!H" /* 33 + 72 */
#define MSG_VCTRL "VCTRL" /* VCTRL */
#define TOK_VCTRL "!I" /* 33 + 73 */
#define TOK_SAPART "!H" /* 33 + 72 */
#define MSG_VCTRL "VCTRL" /* VCTRL */
#define TOK_VCTRL "!I" /* 33 + 73 */
#define MSG_GCLIENT "GCLIENT" /* GLIENT */
#define TOK_GCLIENT "!J" /* 33 + 74 */
#define TOK_GCLIENT "!J" /* 33 + 74 */
#define MSG_CHANNEL "CHANNEL" /* CHANNEL */
#define TOK_CHANNEL "!K" /* 33 + 75 */
#define TOK_CHANNEL "!K" /* 33 + 75 */
#define MSG_UPTIME "UPTIME" /* UPTIME */
#define TOK_UPTIME "!L" /* 33 + 76 */
#define TOK_UPTIME "!L" /* 33 + 76 */
#define MSG_FAILOPS "FAILOPS" /* FAILOPS */
#define TOK_FAILOPS "!M" /* 33 + 77 */
#define TOK_FAILOPS "!M" /* 33 + 77 */
#define MSG_RPING "RPING" /* RPING */
#define TOK_RPING "!P" /* 33 + 80 */
#define MSG_RPONG "RPONG" /* RPONG */
#define TOK_RPONG "!Q" /* 33 + 81 */
#define MSG_UPING "UPING" /* UPING */
#define TOK_UPING "!R" /* 33 + 82 */
#define MSG_RPING "RPING" /* RPING */
#define TOK_RPING "!P" /* 33 + 80 */
#define MSG_RPONG "RPONG" /* RPONG */
#define TOK_RPONG "!Q" /* 33 + 81 */
#define MSG_UPING "UPING" /* UPING */
#define TOK_UPING "!R" /* 33 + 82 */
#define MSG_COPYRIGHT "COPYRIGHT" /* Copyright */
#define TOK_COPYRIGHT "!S" /* 33 + 83 */
#define TOK_COPYRIGHT "!S" /* 33 + 83 */
#define MSG_BOTSERV "BOTSERV" /* BOTSERV */
#define MSG_BS "BS"
#define TOK_BOTSERV "!T" /* 33 + 84 */
#define TOK_BOTSERV "!T" /* 33 + 84 */
#define MSG_ROOTSERV "ROOTSERV" /* ROOTSERV */
#define MSG_RS "RS"
#define TOK_ROOTSERV "!U" /* 33 + 85 */
#define TOK_ROOTSERV "!U" /* 33 + 85 */
#define MSG_SVINFO "SVINFO"
#define MSG_CAPAB "CAPAB"
#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_WALLOP 0x0004 /* send wallops to them */
#define UMODE_FAILOP 0x0008 /* Shows some global messages */
#define UMODE_HELPOP 0x0010 /* Help system operator */
#define UMODE_REGNICK 0x0020 /* Nick set by services as registered */
#define UMODE_SERVICESOPER 0x0040 /* Services Oper */
#define UMODE_COADMIN 0x0080 /* Server CoAdmin */
#define UMODE_NETADMIN 0x10000 /* Network Admin */
#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_SBOT 0x80000 /* Marks the client as a Server Bot */
#define UMODE_NGLOBAL 0x100000 /* See Network Globals */
#define UMODE_NETINFO 0x400000 /* Server link, Delink Notces etc. */
#define UMODE_MAGICK 0x800000 /* Allows Opers To See +s and +p Channels */
#define UMODE_WATCHER 0x4000000 /* Recive Monitor Globals */
#define UMODE_NETMON 0x8000000 /* Marks the client as an Network Monitor */
#define UMODE_SERVADMIN 0x40000000 /* Marks the client as a Server Admin */
#define UMODE_TECHADMIN 0x80000000 /* Marks the client as a Technical Admin */
#define UMODE_DEAF 0x100000000 /* client is deaf on channels */
#define UMODE_SERVNOTICE 0x0100 /* server notices such as kill */
#define UMODE_LOCOP 0x0200 /* Local operator -- SRB */
#define UMODE_KILLS 0x0400 /* Show server-kills... */
#define UMODE_CLIENT 0x0800 /* Show client information */
#define UMODE_FLOOD 0x1000 /* Receive flood warnings */
#define UMODE_CHATOP 0x2000 /* can receive chatops */
#define UMODE_SERVICES 0x4000 /* services */
#define UMODE_HIDE 0x8000 /* Hide from Nukes */
#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_SERVICESADMIN 0x2000000 /* Marks the client as a Services Administrator */
#define UMODE_WALLOP 0x0004 /* send wallops to them */
#define UMODE_FAILOP 0x0008 /* Shows some global messages */
#define UMODE_HELPOP 0x0010 /* Help system operator */
#define UMODE_REGNICK 0x0020 /* Nick set by services as registered */
#define UMODE_SERVICESOPER 0x0040 /* Services Oper */
#define UMODE_COADMIN 0x0080 /* Server CoAdmin */
#define UMODE_NETADMIN 0x10000 /* Network Admin */
#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_SBOT 0x80000 /* Marks the client as a Server Bot */
#define UMODE_NGLOBAL 0x100000 /* See Network Globals */
#define UMODE_NETINFO 0x400000 /* Server link, Delink Notces etc. */
#define UMODE_MAGICK 0x800000 /* Allows Opers To See +s and +p Channels */
#define UMODE_WATCHER 0x4000000 /* Recive Monitor Globals */
#define UMODE_NETMON 0x8000000 /* Marks the client as an Network Monitor */
#define UMODE_SERVADMIN 0x40000000 /* Marks the client as a Server Admin */
#define UMODE_TECHADMIN 0x80000000 /* Marks the client as a Technical Admin */
#define UMODE_DEAF 0x100000000 /* client is deaf on channels */
#define UMODE_SERVNOTICE 0x0100 /* server notices such as kill */
#define UMODE_LOCOP 0x0200 /* Local operator -- SRB */
#define UMODE_KILLS 0x0400 /* Show server-kills... */
#define UMODE_CLIENT 0x0800 /* Show client information */
#define UMODE_FLOOD 0x1000 /* Receive flood warnings */
#define UMODE_CHATOP 0x2000 /* can receive chatops */
#define UMODE_SERVICES 0x4000 /* services */
#define UMODE_HIDE 0x8000 /* Hide from Nukes */
#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_SERVICESADMIN 0x2000000 /* Marks the client as a Services Administrator */
#define MODE_CHANOP 0x0001
@ -395,8 +395,8 @@ struct ircd_srv_ {
typedef struct {
long mode;
char flag;
unsigned nickparam : 1; /* 1 = yes 0 = no */
unsigned parameters : 1;
unsigned nickparam:1; /* 1 = yes 0 = no */
unsigned parameters:1;
char sjoin;
} aCtab;
@ -418,77 +418,77 @@ Oper_Modes susr_mds[9];
/* function declarations */
extern void init_ircd();
extern void chanalert(char *,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 ssquit_cmd(const char *);
extern int sprotocol_cmd(const char *);
extern int squit_cmd(const char *, const char *);
extern int spart_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 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 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 spong_cmd(const char *reply);
extern int snetinfo_cmd();
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 ssmo_cmd(const char *from, const char *umodetarget, const char *msg);
extern int snick_cmd(const char *oldnick, const char *newnick);
extern int sswhois_cmd(const char *target, const char *swhois);
extern int ssvsnick_cmd(const char *target, const char *newnick);
extern int ssvsjoin_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 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 vctrl_cmd();
extern int ssvinfo_cmd();
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 srakill_cmd(const char *host, const char *ident);
extern int ssvshost_cmd(const char *who, const char *vhost);
extern void init_ircd ();
extern void chanalert (char *, 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 ssquit_cmd (const char *);
extern int sprotocol_cmd (const char *);
extern int squit_cmd (const char *, const char *);
extern int spart_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 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 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 spong_cmd (const char *reply);
extern int snetinfo_cmd ();
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 ssmo_cmd (const char *from, const char *umodetarget, const char *msg);
extern int snick_cmd (const char *oldnick, const char *newnick);
extern int sswhois_cmd (const char *target, const char *swhois);
extern int ssvsnick_cmd (const char *target, const char *newnick);
extern int ssvsjoin_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 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 vctrl_cmd ();
extern int ssvinfo_cmd ();
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 srakill_cmd (const char *host, const char *ident);
extern int ssvshost_cmd (const char *who, const char *vhost);
void Usr_Version(char *, char **, int argc);
void Usr_ShowMOTD(char *, char **, int argc);
void Usr_ShowADMIN(char *, char **, int argc);
void Usr_Showcredits(char *, char **, int argc);
void Usr_AddServer(char *, char **, int argc);
void Usr_DelServer(char *, char **, int argc);
void Usr_DelUser(char *, char **, int argc);
void Usr_Mode(char *, char **, int argc);
void Usr_Smode(char *, char **, int argc);
void Usr_Kill(char *, char **, int argc);
void Usr_Pong(char *, char **, int argc);
void Usr_Away(char *, char **, int argc);
void Usr_Nick(char *, char **, int argc);
void Usr_Topic(char *, char **, int argc);
void Usr_Kick(char *, char **, int argc);
void Usr_Join(char *, char **, int argc);
void Usr_Part(char *, char **, int argc);
void Usr_Stats(char *, char **, int argc);
void Usr_Vhost(char *, char **, int argc);
void Srv_Topic(char *, char **, int argc);
void Srv_Ping(char *, char **, int argc);
void Srv_Netinfo(char *, char **, int argc);
void Srv_Pass(char *, char **, int argc);
void Srv_Server(char *, char **, int argc);
void Srv_Squit(char *, char **, int argc);
void Srv_Nick(char *, char **, int argc);
void Srv_Svsnick(char *, char **, int argc);
void Srv_Kill(char *, char **, int argc);
void Srv_Connect(char *, char **, int argc);
void Srv_Svinfo(char *, char **, int argc);
void Srv_Burst(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_Vctrl(char *origin, char **argv, int argc);
void Srv_Client(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);
void Usr_Version (char *, char **, int argc);
void Usr_ShowMOTD (char *, char **, int argc);
void Usr_ShowADMIN (char *, char **, int argc);
void Usr_Showcredits (char *, char **, int argc);
void Usr_AddServer (char *, char **, int argc);
void Usr_DelServer (char *, char **, int argc);
void Usr_DelUser (char *, char **, int argc);
void Usr_Mode (char *, char **, int argc);
void Usr_Smode (char *, char **, int argc);
void Usr_Kill (char *, char **, int argc);
void Usr_Pong (char *, char **, int argc);
void Usr_Away (char *, char **, int argc);
void Usr_Nick (char *, char **, int argc);
void Usr_Topic (char *, char **, int argc);
void Usr_Kick (char *, char **, int argc);
void Usr_Join (char *, char **, int argc);
void Usr_Part (char *, char **, int argc);
void Usr_Stats (char *, char **, int argc);
void Usr_Vhost (char *, char **, int argc);
void Srv_Topic (char *, char **, int argc);
void Srv_Ping (char *, char **, int argc);
void Srv_Netinfo (char *, char **, int argc);
void Srv_Pass (char *, char **, int argc);
void Srv_Server (char *, char **, int argc);
void Srv_Squit (char *, char **, int argc);
void Srv_Nick (char *, char **, int argc);
void Srv_Svsnick (char *, char **, int argc);
void Srv_Kill (char *, char **, int argc);
void Srv_Connect (char *, char **, int argc);
void Srv_Svinfo (char *, char **, int argc);
void Srv_Burst (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_Vctrl (char *origin, char **argv, int argc);
void Srv_Client (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);
#endif

701
neoircd.c

File diff suppressed because it is too large Load diff

272
neoircd.h
View file

@ -18,7 +18,7 @@
** USA
**
** 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_WHO "WHO" /* WHO -> WHOC */
#define MSG_WHOIS "WHOIS" /* WHOI */
#define MSG_WHO "WHO" /* WHO -> WHOC */
#define MSG_WHOIS "WHOIS" /* WHOI */
#define MSG_WHOWAS "WHOWAS" /* WHOW */
#define MSG_USER "USER" /* USER */
#define MSG_NICK "NICK" /* NICK */
#define MSG_USER "USER" /* USER */
#define MSG_NICK "NICK" /* NICK */
#define MSG_SERVER "SERVER" /* SERV */
#define MSG_LIST "LIST" /* LIST */
#define MSG_TOPIC "TOPIC" /* TOPI */
#define MSG_LIST "LIST" /* LIST */
#define MSG_TOPIC "TOPIC" /* TOPI */
#define MSG_INVITE "INVITE" /* INVI */
#define MSG_VERSION "VERSION" /* VERS */
#define MSG_QUIT "QUIT" /* QUIT */
#define MSG_SQUIT "SQUIT" /* SQUI */
#define MSG_KILL "KILL" /* KILL */
#define MSG_INFO "INFO" /* INFO */
#define MSG_LINKS "LINKS" /* LINK */
#define MSG_WATCH "WATCH" /* WATCH */
#define MSG_STATS "STATS" /* STAT */
#define MSG_HELP "HELP" /* HELP */
#define MSG_QUIT "QUIT" /* QUIT */
#define MSG_SQUIT "SQUIT" /* SQUI */
#define MSG_KILL "KILL" /* KILL */
#define MSG_INFO "INFO" /* INFO */
#define MSG_LINKS "LINKS" /* LINK */
#define MSG_WATCH "WATCH" /* WATCH */
#define MSG_STATS "STATS" /* STAT */
#define MSG_HELP "HELP" /* HELP */
#define MSG_HELPOP "HELPOP" /* HELP */
#define MSG_ERROR "ERROR" /* ERRO */
#define MSG_AWAY "AWAY" /* AWAY */
#define MSG_ERROR "ERROR" /* ERRO */
#define MSG_AWAY "AWAY" /* AWAY */
#define MSG_CONNECT "CONNECT" /* CONN */
#define MSG_PING "PING" /* PING */
#define MSG_PONG "PONG" /* PONG */
#define MSG_OPER "OPER" /* OPER */
#define MSG_PASS "PASS" /* PASS */
#define MSG_PING "PING" /* PING */
#define MSG_PONG "PONG" /* PONG */
#define MSG_OPER "OPER" /* OPER */
#define MSG_PASS "PASS" /* PASS */
#define MSG_WALLOPS "WALLOPS" /* WALL */
#define MSG_TIME "TIME" /* TIME */
#define MSG_NAMES "NAMES" /* NAME */
#define MSG_ADMIN "ADMIN" /* ADMI */
#define MSG_TIME "TIME" /* TIME */
#define MSG_NAMES "NAMES" /* NAME */
#define MSG_ADMIN "ADMIN" /* ADMI */
#define MSG_NOTICE "NOTICE" /* NOTI */
#define MSG_JOIN "JOIN" /* JOIN */
#define MSG_PART "PART" /* PART */
#define MSG_JOIN "JOIN" /* JOIN */
#define MSG_PART "PART" /* PART */
#define MSG_LUSERS "LUSERS" /* LUSE */
#define MSG_MOTD "MOTD" /* MOTD */
#define MSG_MODE "MODE" /* MODE */
#define MSG_KICK "KICK" /* KICK */
#define MSG_MOTD "MOTD" /* MOTD */
#define MSG_MODE "MODE" /* MODE */
#define MSG_KICK "KICK" /* KICK */
#define MSG_SERVICE "SERVICE" /* SERV -> SRVI */
#define MSG_USERHOST "USERHOST" /* USER -> USRH */
#define MSG_ISON "ISON" /* ISON */
#define MSG_ISON "ISON" /* ISON */
#define MSG_SQUERY "SQUERY" /* SQUE */
#define MSG_SERVLIST "SERVLIST" /* SERV -> SLIS */
#define MSG_SERVSET "SERVSET" /* SERV -> SSET */
#define MSG_REHASH "REHASH" /* REHA */
#define MSG_RESTART "RESTART" /* REST */
#define MSG_CLOSE "CLOSE" /* CLOS */
#define MSG_DIE "DIE" /* DIE */
#define MSG_HASH "HASH" /* HASH */
#define MSG_DNS "DNS" /* DNS -> DNSS */
#define MSG_CLOSE "CLOSE" /* CLOS */
#define MSG_DIE "DIE" /* DIE */
#define MSG_HASH "HASH" /* HASH */
#define MSG_DNS "DNS" /* DNS -> DNSS */
#define MSG_SILENCE "SILENCE" /* SILE */
#define MSG_AKILL "AKILL" /* AKILL */
#define MSG_KLINE "KLINE" /* KLINE */
#define MSG_UNKLINE "UNKLINE" /* UNKLINE */
#define MSG_AKILL "AKILL" /* AKILL */
#define MSG_KLINE "KLINE" /* KLINE */
#define MSG_UNKLINE "UNKLINE" /* UNKLINE */
#define MSG_RAKILL "RAKILL" /* RAKILL */
#define MSG_GNOTICE "GNOTICE" /* GNOTICE */
#define MSG_GOPER "GOPER" /* GOPER */
#define MSG_GOPER "GOPER" /* GOPER */
#define MSG_GLOBOPS "GLOBOPS" /* GLOBOPS */
#define MSG_LOCOPS "LOCOPS" /* LOCOPS */
#define MSG_PROTOCTL "PROTOCTL" /* PROTOCTL */
#define MSG_TRACE "TRACE" /* TRAC */
#define MSG_TRACE "TRACE" /* TRAC */
#define MSG_SQLINE "SQLINE" /* SQLINE */
#define MSG_UNSQLINE "UNSQLINE" /* UNSQLINE */
#define MSG_SVSNICK "SVSNICK" /* SVSNICK */
@ -111,14 +111,14 @@
#define MSG_SVSMODE "SVSMODE" /* SVSMODE */
#define MSG_SAMODE "SAMODE" /* SAMODE */
#define MSG_CHATOPS "CHATOPS" /* CHATOPS */
#define MSG_HELPSERV "HELPSERV" /* HELPSERV */
#define MSG_ZLINE "ZLINE" /* ZLINE */
#define MSG_HELPSERV "HELPSERV" /* HELPSERV */
#define MSG_ZLINE "ZLINE" /* ZLINE */
#define MSG_UNZLINE "UNZLINE" /* UNZLINE */
#define MSG_NETINFO "NETINFO" /* NETINFO */
#define MSG_RULES "RULES" /* RULES */
#define MSG_MAP "MAP" /* MAP */
#define MSG_NETG "NETG" /* NETG */
#define MSG_ADCHAT "ADCHAT" /* Adchat */
#define MSG_RULES "RULES" /* RULES */
#define MSG_MAP "MAP" /* MAP */
#define MSG_NETG "NETG" /* NETG */
#define MSG_ADCHAT "ADCHAT" /* Adchat */
#define MSG_MAKEPASS "MAKEPASS" /* MAKEPASS */
#define MSG_ADDHUB "ADDHUB" /* ADDHUB */
#define MSG_DELHUB "DELHUB" /* DELHUB */
@ -128,28 +128,28 @@
#define MSG_DELOPER "DELOPER" /* DELOPER */
#define MSG_ADDQLINE "ADDQLINE" /* ADDQLINE */
#define MSG_DELQLINE "DELQLINE" /* DELQLINE */
#define MSG_GSOP "GSOP" /* GSOP */
#define MSG_ISOPER "ISOPER" /* ISOPER */
#define MSG_ADG "ADG" /* ADG */
#define MSG_NMON "NMON" /* NMON */
#define MSG_GSOP "GSOP" /* GSOP */
#define MSG_ISOPER "ISOPER" /* ISOPER */
#define MSG_ADG "ADG" /* ADG */
#define MSG_NMON "NMON" /* NMON */
#define MSG_DALINFO "DALINFO" /* DALnet Credits */
#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_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_STATSERV "STATSERV" /* StatServ */
#define MSG_RULESERV "RULESERV" /* RuleServ */
#define MSG_SNETINFO "SNETINFO" /* SNetInfo */
#define MSG_TSCTL "TSCTL" /* TSCTL */
#define MSG_TSCTL "TSCTL" /* TSCTL */
#define MSG_SVSJOIN "SVSJOIN" /* SVSJOIN */
#define MSG_SAJOIN "SAJOIN" /* SAJOIN */
#define MSG_SDESC "SDESC" /* SDESC */
#define MSG_SDESC "SDESC" /* SDESC */
#define MSG_UNREALINFO "UNREALINFO" /* Unreal Info */
#define MSG_SETHOST "SETHOST" /* sethost */
#define MSG_SETIDENT "SETIDENT" /* set ident */
#define MSG_SETNAME "SETNAME" /* set Realname */
#define MSG_SETHOST "SETHOST" /* sethost */
#define MSG_SETIDENT "SETIDENT" /* set ident */
#define MSG_SETNAME "SETNAME" /* set Realname */
#define MSG_CHGHOST "CHGHOST" /* Changehost */
#define MSG_CHGIDENT "CHGIDENT" /* Change Ident */
#define MSG_RANDQUOTE "RANDQUOTE" /* Random Quote */
@ -157,19 +157,19 @@
#define MSG_ADDGQUOTE "ADDGQUOTE" /* Add Global Quote */
#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_KNOCK "KNOCK" /* Knock Knock - Who's there? */
#define MSG_KNOCK "KNOCK" /* Knock Knock - Who's there? */
#define MSG_SETTINGS "SETTINGS" /* Settings */
#define MSG_IRCOPS "IRCOPS" /* Shows Online IRCOps */
#define MSG_SVSPART "SVSPART" /* SVSPART */
#define MSG_SAPART "SAPART" /* SAPART */
#define MSG_VCTRL "VCTRL" /* VCTRL */
#define MSG_VCTRL "VCTRL" /* VCTRL */
#define MSG_GCLIENT "GCLIENT" /* GLIENT */
#define MSG_CHANNEL "CHANNEL" /* CHANNEL */
#define MSG_UPTIME "UPTIME" /* UPTIME */
#define MSG_FAILOPS "FAILOPS" /* FAILOPS */
#define MSG_RPING "RPING" /* RPING */
#define MSG_RPONG "RPONG" /* RPONG */
#define MSG_UPING "UPING" /* UPING */
#define MSG_RPING "RPING" /* RPING */
#define MSG_RPONG "RPONG" /* RPONG */
#define MSG_UPING "UPING" /* UPING */
#define MSG_COPYRIGHT "COPYRIGHT" /* Copyright */
#define MSG_BOTSERV "BOTSERV" /* BOTSERV */
#define MSG_BS "BS"
@ -194,15 +194,15 @@
#define UMODE_SKILL 0x0100 /* client see's server kills */
#define UMODE_LOCOPS 0x0200 /* client is localop */
#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_UNAUTH 0x2000 /* client can see unauthd connections */
#define UMODE_WALLOP 0x4000 /* client can get wallop messages */
#define UMODE_EXTERNAL 0x8000 /* client can see server joins/splits */
#define UMODE_SPY 0x10000 /* client can spy on user commands */
#define UMODE_OPERWALL 0x20000 /* client gets operwalls */
#define UMODE_SERVICES 0x40000 /* client is services */
#define UMODE_REGNICK 0x80000 /* registered nickname */
#define UMODE_OPERWALL 0x20000 /* client gets operwalls */
#define UMODE_SERVICES 0x40000 /* client is services */
#define UMODE_REGNICK 0x80000 /* registered nickname */
#define MODE_CHANOP 0x0001
#define MODE_HALFOP 0x0002
@ -241,8 +241,8 @@ struct ircd_srv_ {
typedef struct {
long mode;
char flag;
unsigned nickparam : 1; /* 1 = yes 0 = no */
unsigned parameters : 1;
unsigned nickparam:1; /* 1 = yes 0 = no */
unsigned parameters:1;
char sjoin;
} aCtab;
@ -264,74 +264,74 @@ Oper_Modes susr_mds[0];
/* function declarations */
extern void init_ircd();
extern void chanalert(char *,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 ssquit_cmd(const char *);
extern int sprotocol_cmd(const char *);
extern int squit_cmd(const char *, const char *);
extern int spart_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 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 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 spong_cmd(const char *reply);
extern int snetinfo_cmd();
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 ssmo_cmd(const char *from, const char *umodetarget, const char *msg);
extern int snick_cmd(const char *oldnick, const char *newnick);
extern int sswhois_cmd(const char *target, const char *swhois);
extern int ssvsnick_cmd(const char *target, const char *newnick);
extern int ssvsjoin_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 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 vctrl_cmd();
extern int ssvinfo_cmd();
extern int sburst_cmd(int b);
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 srakill_cmd(const char *host, const char *ident);
extern int SignOn_NewBot(const char *, const char *, const char *, const char *, long);
extern void init_ircd ();
extern void chanalert (char *, 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 ssquit_cmd (const char *);
extern int sprotocol_cmd (const char *);
extern int squit_cmd (const char *, const char *);
extern int spart_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 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 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 spong_cmd (const char *reply);
extern int snetinfo_cmd ();
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 ssmo_cmd (const char *from, const char *umodetarget, const char *msg);
extern int snick_cmd (const char *oldnick, const char *newnick);
extern int sswhois_cmd (const char *target, const char *swhois);
extern int ssvsnick_cmd (const char *target, const char *newnick);
extern int ssvsjoin_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 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 vctrl_cmd ();
extern int ssvinfo_cmd ();
extern int sburst_cmd (int b);
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 srakill_cmd (const char *host, const char *ident);
extern int SignOn_NewBot (const char *, const char *, const char *, const char *, long);
void Usr_Version(char *, char **, int argc);
void Usr_ShowMOTD(char *, char **, int argc);
void Usr_ShowADMIN(char *, char **, int argc);
void Usr_Showcredits(char *, char **, int argc);
void Usr_AddServer(char *, char **, int argc);
void Usr_DelServer(char *, char **, int argc);
void Usr_DelUser(char *, char **, int argc);
void Usr_Mode(char *, char **, int argc);
void Usr_Smode(char *, char **, int argc);
void Usr_Kill(char *, char **, int argc);
void Usr_Pong(char *, char **, int argc);
void Usr_Away(char *, char **, int argc);
void Usr_Nick(char *, char **, int argc);
void Usr_Topic(char *, char **, int argc);
void Usr_Kick(char *, char **, int argc);
void Usr_Join(char *, char **, int argc);
void Usr_Part(char *, char **, int argc);
void Usr_Stats(char *, char **, int argc);
void Usr_Vhost(char *, char **, int argc);
void Srv_Topic(char *, char **, int argc);
void Srv_Ping(char *, char **, int argc);
void Srv_Netinfo(char *, char **, int argc);
void Srv_Pass(char *, char **, int argc);
void Srv_Server(char *, char **, int argc);
void Srv_Squit(char *, char **, int argc);
void Srv_Nick(char *, char **, int argc);
void Srv_Svsnick(char *, char **, int argc);
void Srv_Kill(char *, char **, int argc);
void Srv_Connect(char *, char **, int argc);
void Srv_Svinfo(char *, char **, int argc);
void Srv_Burst(char *origin, char **argv, int argc);
void Srv_Sjoin(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);
void Usr_Version (char *, char **, int argc);
void Usr_ShowMOTD (char *, char **, int argc);
void Usr_ShowADMIN (char *, char **, int argc);
void Usr_Showcredits (char *, char **, int argc);
void Usr_AddServer (char *, char **, int argc);
void Usr_DelServer (char *, char **, int argc);
void Usr_DelUser (char *, char **, int argc);
void Usr_Mode (char *, char **, int argc);
void Usr_Smode (char *, char **, int argc);
void Usr_Kill (char *, char **, int argc);
void Usr_Pong (char *, char **, int argc);
void Usr_Away (char *, char **, int argc);
void Usr_Nick (char *, char **, int argc);
void Usr_Topic (char *, char **, int argc);
void Usr_Kick (char *, char **, int argc);
void Usr_Join (char *, char **, int argc);
void Usr_Part (char *, char **, int argc);
void Usr_Stats (char *, char **, int argc);
void Usr_Vhost (char *, char **, int argc);
void Srv_Topic (char *, char **, int argc);
void Srv_Ping (char *, char **, int argc);
void Srv_Netinfo (char *, char **, int argc);
void Srv_Pass (char *, char **, int argc);
void Srv_Server (char *, char **, int argc);
void Srv_Squit (char *, char **, int argc);
void Srv_Nick (char *, char **, int argc);
void Srv_Svsnick (char *, char **, int argc);
void Srv_Kill (char *, char **, int argc);
void Srv_Connect (char *, char **, int argc);
void Srv_Svinfo (char *, char **, int argc);
void Srv_Burst (char *origin, char **argv, int argc);
void Srv_Sjoin (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);
#endif

View file

@ -22,12 +22,13 @@
** USA
**
** 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"
void init_ns_help()
void
init_ns_help ()
{
if (usr_mds);
}

120
server.c
View file

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

View file

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

326
sock.c
View file

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

4
sock.h
View file

@ -20,14 +20,14 @@
** USA
**
** 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
#define SOCK_H
void sts(char *fmt, ...);
void sts (char *fmt, ...);
#endif

171
stats.h
View file

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

92
timer.c
View file

@ -20,7 +20,7 @@
** USA
**
** 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"
@ -33,68 +33,69 @@ static time_t last_cache_save;
static int midnight = 0;
void chk()
void
chk ()
{
Mod_Timer *mod_ptr = NULL;
time_t current = time(NULL);
time_t current = time (NULL);
hscan_t ts;
hnode_t *tn;
strcpy(segv_location, "chk");
/* First, lets see if any modules have a function that is due to run..... */
hash_scan_begin(&ts, th);
while ((tn = hash_scan_next(&ts)) != NULL) {
mod_ptr = hnode_get(tn);
hash_scan_begin (&ts, th);
while ((tn = hash_scan_next (&ts)) != NULL) {
strcpy (segv_location, "chk");
mod_ptr = hnode_get (tn);
if (current - mod_ptr->lastrun > mod_ptr->interval) {
strcpy(segv_location, mod_ptr->modname);
strcpy(segvinmodule, mod_ptr->modname);
if (setjmp(sigvbuf) == 0) {
mod_ptr->function();
mod_ptr->lastrun = (int) time(NULL);
strcpy (segv_location, mod_ptr->modname);
strcpy (segvinmodule, mod_ptr->modname);
if (setjmp (sigvbuf) == 0) {
if (mod_ptr->function () < 0) {
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 {
nlog(LOG_CRITICAL, LOG_CORE,
"setjmp() Failed, Can't call Module %s\n",
mod_ptr->modname);
nlog (LOG_CRITICAL, LOG_CORE, "setjmp() Failed, Can't call Module %s\n", mod_ptr->modname);
}
strcpy(segvinmodule, "");
strcpy(segv_location, "Module_Event_Return");
strcpy (segvinmodule, "");
}
}
if (current - ping.last_sent > 60) {
TimerPings();
ping.last_sent = time(NULL);
if (hash_verify(sockh) == 0) {
nlog(LOG_CRITICAL, LOG_CORE,
"Eeeek, Corruption of the socket hash");
if (current - ping.last_sent > me.pingtime) {
TimerPings ();
ping.last_sent = time (NULL);
if (hash_verify (sockh) == 0) {
nlog (LOG_CRITICAL, LOG_CORE, "Eeeek, Corruption of the socket hash");
}
if (hash_verify(mh) == 0) {
nlog(LOG_CRITICAL, LOG_CORE,
"Eeeek, Corruption of the Module hash");
if (hash_verify (mh) == 0) {
nlog (LOG_CRITICAL, LOG_CORE, "Eeeek, Corruption of the Module hash");
}
if (hash_verify(bh) == 0) {
nlog(LOG_CRITICAL, LOG_CORE,
"Eeeek, Corruption of the Bot hash");
if (hash_verify (bh) == 0) {
nlog (LOG_CRITICAL, LOG_CORE, "Eeeek, Corruption of the Bot hash");
}
if (hash_verify(th) == 0) {
nlog(LOG_CRITICAL, LOG_CORE,
"Eeeek, Corruption of the Timer hash");
if (hash_verify (th) == 0) {
nlog (LOG_CRITICAL, LOG_CORE, "Eeeek, Corruption of the Timer hash");
}
/* flush log files */
fflush(NULL);
fflush (NULL);
}
if (is_midnight() == 1 && midnight == 0) {
TimerMidnight();
if (is_midnight () == 1 && midnight == 0) {
TimerMidnight ();
midnight = 1;
} else {
if (midnight == 1 && is_midnight() == 0)
if (midnight == 1 && is_midnight () == 0)
midnight = 0;
}
}
void TimerReset()
void
TimerReset ()
{
time_t current = time(NULL);
time_t current = time (NULL);
last_stats_save = current;
last_lag_check = current;
last_cache_save = current;
@ -104,17 +105,18 @@ void TimerReset()
void TimerMidnight()
void
TimerMidnight ()
{
nlog(LOG_DEBUG1, LOG_CORE, "Its midnight!!! -> %s",
sctime(time(NULL)));
ResetLogs();
nlog (LOG_DEBUG1, LOG_CORE, "Its midnight!!! -> %s", sctime (time (NULL)));
ResetLogs ();
}
int is_midnight()
int
is_midnight ()
{
time_t current = time(NULL);
struct tm *ltm = localtime(&current);
time_t current = time (NULL);
struct tm *ltm = localtime (&current);
if (ltm->tm_hour == 0)
return 1;

345
users.c
View file

@ -22,7 +22,7 @@
** USA
**
** 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>
@ -34,8 +34,8 @@
int fnmatch(const char *, const char *, int flags);
void doDelUser(const char *, int);
int fnmatch (const char *, const char *, int flags);
void doDelUser (const char *, int);
@ -44,55 +44,51 @@ void doDelUser(const char *, int);
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;
hnode_t *un;
strcpy(segv_location, "new_user");
u = smalloc(sizeof(User));
strcpy (segv_location, "new_user");
u = smalloc (sizeof (User));
if (!nick)
nick = "";
memcpy(u->nick, nick, MAXNICK);
un = hnode_create(u);
if (hash_isfull(uh)) {
nlog(LOG_CRITICAL, LOG_CORE, "Eeeek, Hash is full");
memcpy (u->nick, nick, MAXNICK);
un = hnode_create (u);
if (hash_isfull (uh)) {
nlog (LOG_CRITICAL, LOG_CORE, "Eeeek, Hash is full");
} else {
hash_insert(uh, un, u->nick);
hash_insert (uh, un, u->nick);
}
return (u);
}
void AddUser(const char *nick, const char *user, const char *host,
const char *server, const unsigned long ipaddr,
const unsigned long TS)
void
AddUser (const char *nick, const char *user, const char *host, const char *server, const unsigned long ipaddr, const unsigned long TS)
{
User *u;
nlog(LOG_DEBUG2, LOG_CORE,
"AddUser(): %s (%s@%s)(%lu) -> %s at %lu", nick, user, host,
htonl(ipaddr), server, TS);
strcpy(segv_location, "AddUser");
u = finduser(nick);
nlog (LOG_DEBUG2, LOG_CORE, "AddUser(): %s (%s@%s)(%lu) -> %s at %lu", nick, user, host, htonl (ipaddr), server, TS);
strcpy (segv_location, "AddUser");
u = finduser (nick);
if (u) {
nlog(LOG_WARNING, LOG_CORE,
"trying to add a user that already exists? (%s)",
nick);
nlog (LOG_WARNING, LOG_CORE, "trying to add a user that already exists? (%s)", nick);
return;
}
u = new_user(nick);
strncpy(u->hostname, host, MAXHOST);
strncpy(u->username, user, MAXUSER);
u = new_user (nick);
strncpy (u->hostname, host, MAXHOST);
strncpy (u->username, user, MAXUSER);
/* its empty for the moment */
strncpy(u->realname, "", MAXREALNAME);
u->server = findserver(server);
u->t_flood = time(NULL);
strncpy (u->realname, "", MAXREALNAME);
u->server = findserver (server);
u->t_flood = time (NULL);
u->flood = 0;
u->is_away = 0;
u->myuser = NULL;
@ -100,105 +96,115 @@ void AddUser(const char *nick, const char *user, const char *host,
#ifdef ULTIMATE3
u->Smode = 0;
#endif
u->chans = list_create(MAXJOINCHANS);
strcpy(u->modes, "");
u->ipaddr.s_addr = htonl(ipaddr);
u->chans = list_create (MAXJOINCHANS);
strcpy (u->modes, "");
u->ipaddr.s_addr = htonl (ipaddr);
u->TS = TS;
}
void AddRealName(const char *nick, const char *realname)
void
AddRealName (const char *nick, const char *realname)
{
char **av;
int ac = 0;
User *u = finduser(nick);
User *u = finduser (nick);
if (!u) {
nlog(LOG_WARNING, LOG_CORE,
"Warning, Can not find User %s for Realname", nick);
nlog (LOG_WARNING, LOG_CORE, "Warning, Can not find User %s for Realname", nick);
return;
}
nlog(LOG_DEBUG2, LOG_CORE, "RealName(%s): %s", nick, realname);
strncpy(u->realname, realname, MAXREALNAME);
AddStringToList(&av, u->nick, &ac);
Module_Event("SIGNON", av, ac);
free(av);
nlog (LOG_DEBUG2, LOG_CORE, "RealName(%s): %s", nick, realname);
strncpy (u->realname, realname, MAXREALNAME);
AddStringToList (&av, u->nick, &ac);
Module_Event ("SIGNON", av, ac);
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;
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;
hnode_t *un;
char **av;
int ac = 0;
strcpy(segv_location, "DelUser");
nlog(LOG_DEBUG2, LOG_CORE, "DelUser(%s)", nick);
strcpy (segv_location, "DelUser");
nlog (LOG_DEBUG2, LOG_CORE, "DelUser(%s)", nick);
un = hash_lookup(uh, nick);
un = hash_lookup (uh, nick);
if (!un) {
nlog(LOG_WARNING, LOG_CORE, "DelUser(%s) failed!", nick);
nlog (LOG_WARNING, LOG_CORE, "DelUser(%s) failed!", nick);
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 */
AddStringToList(&av, u->nick, &ac);
AddStringToList (&av, u->nick, &ac);
if (i == 0) {
Module_Event("SIGNOFF", av, ac);
Module_Event ("SIGNOFF", av, ac);
} 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 (findbot(u->nick)) {
if (findbot (u->nick)) {
if (i == 1)
nlog(LOG_NOTICE, LOG_CORE, "Deleting Bot %s as it was killed", u->nick);
del_mod_user(u->nick);
nlog (LOG_NOTICE, LOG_CORE, "Deleting Bot %s as it was killed", u->nick);
del_mod_user (u->nick);
}
hash_delete(uh, un);
hnode_destroy(un);
list_destroy(u->chans);
free(u);
hash_delete (uh, un);
hnode_destroy (un);
list_destroy (u->chans);
free (u);
}
void Do_Away(User * u, const char *awaymsg)
void
Do_Away (User * u, const char *awaymsg)
{
char **av;
int ac = 0;
if (u) {
AddStringToList(&av, u->nick, &ac);
AddStringToList (&av, u->nick, &ac);
if ((u->is_away == 1) && (!awaymsg)) {
u->is_away = 0;
Module_Event("AWAY", av, ac);
Module_Event ("AWAY", av, ac);
} else if ((u->is_away == 0) && (awaymsg)) {
u->is_away = 1;
AddStringToList(&av, (char *) awaymsg, &ac);
Module_Event("AWAY", av, ac);
AddStringToList (&av, (char *) awaymsg, &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;
lnode_t *cm;
@ -206,153 +212,150 @@ void Change_User(User * u, const char *newnick)
int ac = 0;
char *oldnick;
strcpy(segv_location, "Change_User");
nlog(LOG_DEBUG2, LOG_CORE, "Change_User(%s, %s)", u->nick,
newnick);
un = hash_lookup(uh, u->nick);
strcpy (segv_location, "Change_User");
nlog (LOG_DEBUG2, LOG_CORE, "Change_User(%s, %s)", u->nick, newnick);
un = hash_lookup (uh, u->nick);
if (!un) {
nlog(LOG_WARNING, LOG_CORE, "ChangeUser(%s) Failed!",
u->nick);
nlog (LOG_WARNING, LOG_CORE, "ChangeUser(%s) Failed!", u->nick);
return;
}
cm = list_first(u->chans);
cm = list_first (u->chans);
while (cm) {
change_user_nick(findchan(lnode_get(cm)), (char *) newnick,
u->nick);
cm = list_next(u->chans, cm);
change_user_nick (findchan (lnode_get (cm)), (char *) newnick, u->nick);
cm = list_next (u->chans, cm);
}
strcpy(segv_location, "Change_User_Return");
hash_delete(uh, un);
oldnick = malloc(MAXNICK);
strncpy(oldnick, u->nick, MAXNICK);
AddStringToList(&av, oldnick, &ac);
strncpy(u->nick, newnick, MAXNICK);
hash_insert(uh, un, u->nick);
strcpy (segv_location, "Change_User_Return");
hash_delete (uh, un);
oldnick = malloc (MAXNICK);
strncpy (oldnick, u->nick, MAXNICK);
AddStringToList (&av, oldnick, &ac);
strncpy (u->nick, newnick, MAXNICK);
hash_insert (uh, un, u->nick);
AddStringToList(&av, u->nick, &ac);
Module_Event("NICK_CHANGE", av, ac);
free(av);
free(oldnick);
AddStringToList (&av, u->nick, &ac);
Module_Event ("NICK_CHANGE", av, ac);
free (av);
free (oldnick);
}
void sendcoders(char *message, ...)
void
sendcoders (char *message, ...)
{
va_list ap;
char tmp[512];
strcpy(segv_location, "sendcoders");
va_start(ap, message);
vsnprintf(tmp, 512, message, ap);
strcpy (segv_location, "sendcoders");
va_start (ap, message);
vsnprintf (tmp, 512, message, ap);
#ifndef DEBUG
if (!me.coder_debug)
return;
#endif
chanalert(s_Services, tmp);
va_end(ap);
chanalert (s_Services, tmp);
va_end (ap);
}
User *finduser(const char *nick)
User *
finduser (const char *nick)
{
User *u;
hnode_t *un;
strcpy(segv_location, "finduser");
un = hash_lookup(uh, nick);
strcpy (segv_location, "finduser");
un = hash_lookup (uh, nick);
if (un != NULL) {
u = hnode_get(un);
u = hnode_get (un);
return u;
} else {
nlog(LOG_DEBUG2, LOG_CORE, "FindUser(%s) -> NOTFOUND",
nick);
nlog (LOG_DEBUG2, LOG_CORE, "FindUser(%s) -> NOTFOUND", nick);
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;
hnode_t *un;
lnode_t *cm;
hscan_t us;
strcpy(segv_location, "UserDump");
strcpy (segv_location, "UserDump");
if (!nick) {
sendcoders("Users======================");
hash_scan_begin(&us, uh);
while ((un = hash_scan_next(&us)) != NULL) {
u = hnode_get(un);
sendcoders("User: %s", u->nick);
cm = list_first(u->chans);
sendcoders ("Users======================");
hash_scan_begin (&us, uh);
while ((un = hash_scan_next (&us)) != NULL) {
u = hnode_get (un);
sendcoders ("User: %s", u->nick);
cm = list_first (u->chans);
while (cm) {
sendcoders(" Chans: %s",
(char *) lnode_get(cm));
cm = list_next(u->chans, cm);
sendcoders (" Chans: %s", (char *) lnode_get (cm));
cm = list_next (u->chans, cm);
}
}
} else {
un = hash_lookup(uh, nick);
un = hash_lookup (uh, nick);
if (un) {
u = hnode_get(un);
sendcoders("User: %s", u->nick);
cm = list_first(u->chans);
u = hnode_get (un);
sendcoders ("User: %s", u->nick);
cm = list_first (u->chans);
while (cm) {
sendcoders(" Chans: %s",
(char *) lnode_get(cm));
cm = list_next(u->chans, cm);
sendcoders (" Chans: %s", (char *) lnode_get (cm));
cm = list_next (u->chans, cm);
}
} 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;
#ifdef EXTAUTH
int (*getauth) (User *, int curlvl);
#endif
strcpy(segv_location, "UserLevel");
for (i = 0; i < ((sizeof(usr_mds) / sizeof(usr_mds[0])) - 1); i++) {
strcpy (segv_location, "UserLevel");
for (i = 0; i < ((sizeof (usr_mds) / sizeof (usr_mds[0])) - 1); i++) {
if (u->Umode & usr_mds[i].umodes) {
if (usr_mds[i].level > tmplvl)
tmplvl = usr_mds[i].level;
}
}
nlog(LOG_DEBUG1, LOG_CORE, "Umode Level for %s is %d", u->nick,
tmplvl);
nlog (LOG_DEBUG1, LOG_CORE, "Umode Level for %s is %d", u->nick, tmplvl);
/* I hate SMODEs damn it */
#ifdef ULTIMATE3
for (i = 0; i < ((sizeof(susr_mds) / sizeof(susr_mds[0])) - 1);
i++) {
for (i = 0; i < ((sizeof (susr_mds) / sizeof (susr_mds[0])) - 1); i++) {
if (u->Smode & susr_mds[i].umodes) {
if (susr_mds[i].level > tmplvl)
tmplvl = susr_mds[i].level;
}
}
#endif
nlog(LOG_DEBUG1, LOG_CORE, "Smode Level for %s is %d", u->nick,
tmplvl);
nlog (LOG_DEBUG1, LOG_CORE, "Smode Level for %s is %d", u->nick, tmplvl);
#ifdef DEBUG
#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 :) */
if (!strcasecmp(u->nick, "FISH"))
if (!strcasecmp (u->nick, "FISH"))
tmplvl = 200;
if (!strcasecmp(u->nick, "SHMAD"))
if (!strcasecmp (u->nick, "SHMAD"))
tmplvl = 200;
#endif
#endif
#ifdef EXTAUTH
i = get_dl_handle("extauth");
i = get_dl_handle ("extauth");
if (i > 0) {
getauth = dlsym((int *) i, "__do_auth");
getauth = dlsym ((int *) i, "__do_auth");
if (getauth)
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,
tmplvl, i);
nlog (LOG_DEBUG1, LOG_CORE, "UserLevel for %s is %d (%d)", u->nick, tmplvl, i);
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 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;
int ac = 0;
strcpy(segv_location, "UserMode");
u = finduser(nick);
strcpy (segv_location, "UserMode");
u = finduser (nick);
if (!u) {
nlog(LOG_WARNING, LOG_CORE,
"Warning, Changing Modes for a Unknown User %s!",
nick);
nlog(LOG_DEBUG1, LOG_CORE, "Recbuf: %s", recbuf);
nlog (LOG_WARNING, LOG_CORE, "Warning, Changing Modes for a Unknown User %s!", nick);
nlog (LOG_DEBUG1, LOG_CORE, "Recbuf: %s", recbuf);
return;
}
/* support for Smodes */
if (smode > 0)
nlog(LOG_DEBUG1, LOG_CORE, "Smodes: %s", modes);
nlog (LOG_DEBUG1, LOG_CORE, "Smodes: %s", modes);
else
nlog(LOG_DEBUG1, LOG_CORE, "Modes: %s", modes);
nlog (LOG_DEBUG1, LOG_CORE, "Modes: %s", modes);
if (smode == 0)
strncpy(u->modes, modes, MODESIZE);
strncpy (u->modes, modes, MODESIZE);
AddStringToList(&av, u->nick, &ac);
AddStringToList(&av, (char *) modes, &ac);
AddStringToList (&av, u->nick, &ac);
AddStringToList (&av, (char *) modes, &ac);
tmpmode = *(modes);
@ -415,39 +416,25 @@ void UserMode(const char *nick, const char *modes, int smode)
break;
default:
if (smode > 0) {
for (i = 0;
i <
((sizeof(susr_mds) /
sizeof(susr_mds[0])) - 1); i++) {
for (i = 0; i < ((sizeof (susr_mds) / sizeof (susr_mds[0])) - 1); i++) {
if (susr_mds[i].mode == tmpmode) {
if (add) {
u->Smode |=
susr_mds[i].
umodes;
u->Smode |= susr_mds[i].umodes;
break;
} else {
u->Smode &=
~susr_mds[i].
umodes;
u->Smode &= ~susr_mds[i].umodes;
break;
}
}
}
} else {
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 (usr_mds[i].mode == tmpmode) {
if (add) {
u->Umode |=
usr_mds[i].
umodes;
u->Umode |= usr_mds[i].umodes;
break;
} else {
u->Umode &=
~usr_mds[i].
umodes;
u->Umode &= ~usr_mds[i].umodes;
break;
}
}
@ -457,15 +444,13 @@ void UserMode(const char *nick, const char *modes, int smode)
tmpmode = *modes++;
}
if (smode > 0) {
nlog(LOG_DEBUG1, LOG_CORE, "SMODE for %s is are now %p",
u->nick, u->Smode);
Module_Event("SMODE", av, ac);
nlog (LOG_DEBUG1, LOG_CORE, "SMODE for %s is are now %p", u->nick, u->Smode);
Module_Event ("SMODE", av, ac);
} else {
nlog(LOG_DEBUG1, LOG_CORE, "Modes for %s are now %p",
u->nick, u->Umode);
Module_Event("UMODE", av, ac);
nlog (LOG_DEBUG1, LOG_CORE, "Modes for %s are now %p", u->nick, u->Umode);
Module_Event ("UMODE", av, ac);
}
free(av);
free (av);