diff options
-rw-r--r-- | Changes | 1 | ||||
-rw-r--r-- | include/extern.h | 5 | ||||
-rw-r--r-- | include/services.h | 35 | ||||
-rw-r--r-- | include/sysconf.h.in | 10 | ||||
-rw-r--r-- | src/bahamut.c | 17 | ||||
-rw-r--r-- | src/base64.c | 5 | ||||
-rw-r--r-- | src/botserv.c | 2 | ||||
-rw-r--r-- | src/chanserv.c | 86 | ||||
-rw-r--r-- | src/dreamforge.c | 10 | ||||
-rw-r--r-- | src/hostserv.c | 3 | ||||
-rw-r--r-- | src/hybrid.c | 10 | ||||
-rw-r--r-- | src/memory.c | 34 | ||||
-rw-r--r-- | src/memoserv.c | 2 | ||||
-rw-r--r-- | src/misc.c | 288 | ||||
-rw-r--r-- | src/news.c | 2 | ||||
-rw-r--r-- | src/nickserv.c | 4 | ||||
-rw-r--r-- | src/operserv.c | 145 | ||||
-rw-r--r-- | src/process.c | 9 | ||||
-rw-r--r-- | src/ptlink.c | 10 | ||||
-rw-r--r-- | src/rageircd.c | 18 | ||||
-rw-r--r-- | src/servers.c | 8 | ||||
-rw-r--r-- | src/sessions.c | 4 | ||||
-rw-r--r-- | src/slist.c | 94 | ||||
-rw-r--r-- | src/sockutil.c | 179 | ||||
-rw-r--r-- | src/solidircd.c | 17 | ||||
-rw-r--r-- | src/ultimate2.c | 10 | ||||
-rw-r--r-- | src/ultimate3.c | 18 | ||||
-rw-r--r-- | src/unreal31.c | 11 | ||||
-rw-r--r-- | src/unreal32.c | 47 | ||||
-rw-r--r-- | src/users.c | 11 | ||||
-rw-r--r-- | src/viagra.c | 17 | ||||
-rw-r--r-- | version.log | 15 |
32 files changed, 848 insertions, 279 deletions
@@ -13,6 +13,7 @@ Provided by Anope Dev. <dev@anope.org> - 2004 11/19 A Added anope_cmd_ctcp() to code API, for sending CTCP messages. [ #00] 11/18 A Unable to use registered nicknames as bot nicks from now on. [ #00] 11/18 A NSAddAccessOnReg to control access list on registration. [ #00] +12/05 F CS CLEAR OPS strips +a/+q modes, and uses SVSMODE where possible [ #00] 12/05 F Ultimate3 not setting +a on channel admins [ #00] 12/04 F Cleaned up some memory warnings found with Valgrind [ #00] 12/03 F Unreal 391 TIME replies [ #00] diff --git a/include/extern.h b/include/extern.h index 5c8b3b6b9..4513fcf90 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1033,6 +1033,7 @@ extern void anope_cmd_svsinfo(); /* SVSINFO */ extern void anope_cmd_svsjoin(char *source, char *nick,char *chan); /* SVSJOIN */ extern void anope_cmd_svskill(char *source,char *user, const char *fmt, ...); /* SVSKILL */ extern void anope_cmd_svsmode(User * u, int ac, char **av); /* SVSMODE */ +extern void anope_cmd_svsmode_chan(char *name, char *mode, char *nick); /* SVSMODE */ extern void anope_cmd_svsnick(char *nick,char *newnick, time_t when); /* SVSNICK */ extern void anope_cmd_svsnoop(char *server, int set); /* SVSNOOP */ extern void anope_cmd_svso(char *source,char *nick, char *flag); /* SVSO */ @@ -1134,8 +1135,8 @@ extern char *send_token(char *token1, char *token2); extern char *base64enc(long i); extern long base64dec(char *b64); extern long base64dects(char *ts); -extern int b64_encode(unsigned char const *src, size_t srclength, char *target, size_t targsize); -extern int b64_decode(char const *src, unsigned char *target, size_t targsize); +extern int b64_encode(char *src, size_t srclength, char *target, size_t targsize); +extern int b64_decode(char *src, char *target, size_t targsize); extern char *encode_ip(u_char *ip); extern int decode_ip(char *buf); diff --git a/include/services.h b/include/services.h index 26ae68667..f420c0347 100644 --- a/include/services.h +++ b/include/services.h @@ -49,6 +49,7 @@ #include <sys/stat.h> /* for umask() on some systems */ #include <sys/types.h> #include <sys/time.h> +#include <fcntl.h> #ifdef HAVE_BACKTRACE #include <execinfo.h> @@ -258,8 +259,7 @@ struct ircdvars_ { int invitemode; /* +I */ int sjoinbanchar; /* use single quotes to define it */ int sjoinexchar; /* use single quotes to define it */ - uint32 servicesmode; /* Services Mode +S */ - int p10; /* P10 ircd */ + int svsmode_ucmode; /* Can remove User Channel Modes with SVSMODE */ }; struct ircdcapab_ { @@ -308,6 +308,7 @@ struct ircdcapab_ { #define PRE_NICK_VERSION 1 #define OPER_VERSION 13 #define HELP_VERSION 1 +#define HOST_VERSION 3 /*************************************************************************/ @@ -330,7 +331,7 @@ struct ModuleData_ { struct memo_ { uint32 number; /* Index number -- not necessarily array position! */ - int16 flags; + uint16 flags; time_t time; /* When it was sent */ char sender[NICKMAX]; char *text; @@ -338,7 +339,7 @@ struct memo_ { }; typedef struct { - int16 memocount, memomax; + uint16 memocount, memomax; Memo *memos; } MemoInfo; @@ -365,7 +366,7 @@ struct nickalias_ { char *last_usermask; /* Last usermask */ time_t time_registered; /* When the nick was registered */ time_t last_seen; /* When it was seen online for the last time */ - int16 status; /* See NS_* below */ + uint16 status; /* See NS_* below */ NickCore *nc; /* I'm an alias of this */ /* Not saved */ ModuleData *moduleData; /* Module saved data attached to the nick alias */ @@ -383,7 +384,7 @@ struct nickcore_ { char *url; /* URL associated to the nick */ uint32 flags; /* See NI_* below */ uint16 language; /* Language selected by nickname owner (LANG_*) */ - int16 accesscount; /* # of entries */ + uint16 accesscount; /* # of entries */ char **access; /* Array of strings */ MemoInfo memos; uint16 channelcount; /* Number of channels currently registered */ @@ -426,8 +427,8 @@ struct botinfo_ { /* Access levels for users. */ typedef struct { - int16 in_use; /* 1 if this entry is in use, else 0 */ - int16 level; + uint16 in_use; /* 1 if this entry is in use, else 0 */ + uint16 level; NickCore *nc; /* Guaranteed to be non-NULL if in use, NULL if not */ time_t last_seen; } ChanAccess; @@ -451,9 +452,7 @@ typedef struct { typedef struct { int16 in_use; /* Always 0 if not in use */ int16 is_nick; /* 1 if a regged nickname, 0 if a nick!user@host mask */ - - int16 flags; - + uint16 flags; union { char *mask; /* Guaranteed to be non-NULL if in use, NULL if not */ NickCore *nc; /* Same */ @@ -471,9 +470,9 @@ typedef struct { /* Structure used to contain bad words. */ struct badword_ { - int16 in_use; + uint16 in_use; char *word; - int16 type; /* BW_* below */ + uint16 type; /* BW_* below */ }; #define BW_ANY 0 @@ -506,9 +505,9 @@ struct chaninfo_ { int16 bantype; int16 *levels; /* Access levels for commands */ - int16 accesscount; + uint16 accesscount; ChanAccess *access; /* List of authorized users */ - int16 akickcount; + uint16 akickcount; AutoKick *akick; /* List of users to kickban */ uint32 mlock_on, mlock_off; /* See channel modes below */ @@ -532,7 +531,7 @@ struct chaninfo_ { uint32 botflags; /* BS_* below */ int16 *ttb; /* Times to ban for each kicker */ - int16 bwcount; + uint16 bwcount; BadWord *badwords; /* For BADWORDS kicker */ int16 capsmin, capspercent; /* For CAPS kicker */ int16 floodlines, floodsecs; /* For FLOOD kicker */ @@ -904,10 +903,8 @@ struct hostcore_ { /*************************************************************************/ - - struct newsitem_ { - int16 type; + uint16 type; uint32 num; /* Numbering is separate for login and oper news */ char *text; char who[NICKMAX]; diff --git a/include/sysconf.h.in b/include/sysconf.h.in index 472075577..cfd1cd75c 100644 --- a/include/sysconf.h.in +++ b/include/sysconf.h.in @@ -217,6 +217,16 @@ int vfprintf(FILE *stream, const char *format, va_list ap); int vsprintf(char *str, const char *format, va_list ap); int vsnprintf(char *str, size_t size, const char *format, va_list ap); +FILE *popen(const char *command, const char *type); +int pclose(FILE *stream); +FILE *fdopen(int fildes, const char *mode); +int fileno(FILE *stream); +int ftruncate(int fd, off_t length); + +#ifdef HAVE_STRSIGNAL +char *strsignal(int sig); +#endif + /* Freebsd 5.2.1 actually has u_char those it throws more errors having it defined again - TSL */ #undef u_char diff --git a/src/bahamut.c b/src/bahamut.c index d4a2d1a30..772a716c8 100644 --- a/src/bahamut.c +++ b/src/bahamut.c @@ -102,8 +102,7 @@ IRCDVar ircd[] = { 1, /* +I support */ 0, /* SJOIN ban char */ 0, /* SJOIN except char */ - 0, /* Services Client mode */ - 0, /* not p10 */ + 0, /* Can remove User Channel Modes with SVSMODE */ } , {NULL} @@ -485,7 +484,19 @@ void anope_cmd_release_svshold(char *nick) /* SVSMODE -b */ void anope_cmd_unban(char *name, char *nick) { - send_cmd(ServerName, "SVSMODE %s -b %s", name, nick); + anope_cmd_svsmode_chan(name, "-b", nick); +} + + +/* SVSMODE channel modes */ + +void anope_cmd_svsmode_chan(char *name, char *mode, char *nick) +{ + if (nick) { + send_cmd(ServerName, "SVSMODE %s %s %s", name, mode, nick); + } else { + send_cmd(ServerName, "SVSMODE %s %s", name, mode); + } } void anope_cmd_bot_chan_mode(char *nick, char *chan) diff --git a/src/base64.c b/src/base64.c index 6349eebfd..6eb8e57ac 100644 --- a/src/base64.c +++ b/src/base64.c @@ -103,8 +103,7 @@ static const char Pad64 = '='; characters followed by one "=" padding character. */ -int b64_encode(unsigned char const *src, size_t srclength, char *target, - size_t targsize) +int b64_encode(char *src, size_t srclength, char *target, size_t targsize) { size_t datalength = 0; u_char input[3]; @@ -163,7 +162,7 @@ int b64_encode(unsigned char const *src, size_t srclength, char *target, it returns the number of data bytes stored at the target, or -1 on error. */ -int b64_decode(char const *src, unsigned char *target, size_t targsize) +int b64_decode(char *src, char *target, size_t targsize) { int tarindex, state, ch; char *pos; diff --git a/src/botserv.c b/src/botserv.c index 1e9ad3067..8b1fc120f 100644 --- a/src/botserv.c +++ b/src/botserv.c @@ -611,7 +611,7 @@ void load_bs_dbase(void) { dbFILE *f; int c, ver; - int16 tmp16; + uint16 tmp16; uint32 tmp32; BotInfo *bi; int failed = 0; diff --git a/src/chanserv.c b/src/chanserv.c index a4edae96e..7a855e5ee 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -635,7 +635,7 @@ void load_cs_dbase(void) ver = get_file_version(f); for (i = 0; i < 256 && !failed; i++) { - int16 tmp16; + uint16 tmp16; uint32 tmp32; int n_levels; char *s; @@ -6004,18 +6004,62 @@ static int do_clear(User * u) char *av[3]; struct c_userlist *cu, *next; - for (cu = c->users; cu; cu = next) { - next = cu->next; - if (!chan_has_user_status(c, cu->user, CUS_OP)) - continue; + if (ircd->svsmode_ucmode) { av[0] = sstrdup(chan); - av[1] = sstrdup("-o"); - av[2] = sstrdup(cu->user->nick); - anope_cmd_mode(whosends(ci), av[0], "%s :%s", av[1], av[2]); - do_cmode(s_ChanServ, 3, av); - free(av[2]); - free(av[1]); - free(av[0]); + anope_cmd_svsmode_chan(av[0], "-o", NULL); + if (ircd->owner) { + anope_cmd_svsmode_chan(av[0], "-q", NULL); + } + if (ircd->protect || ircd->admin) { + anope_cmd_svsmode_chan(av[0], "-a", NULL); + } + for (cu = c->users; cu; cu = next) { + next = cu->next; + av[0] = sstrdup(chan); + if (!chan_has_user_status(c, cu->user, CUS_OP)) { + if (!chan_has_user_status(c, cu->user, CUS_PROTECT)) { + if (!chan_has_user_status(c, cu->user, CUS_OWNER)) { + continue; + } else { + av[1] = sstrdup("-qo"); + } + } else { + av[1] = sstrdup("-ao"); + } + } else { + av[1] = sstrdup("-o"); + } + av[2] = sstrdup(cu->user->nick); + do_cmode(s_ChanServ, 3, av); + free(av[2]); + free(av[1]); + free(av[0]); + } + } else { + for (cu = c->users; cu; cu = next) { + next = cu->next; + av[0] = sstrdup(chan); + if (!chan_has_user_status(c, cu->user, CUS_OP)) { + if (!chan_has_user_status(c, cu->user, CUS_PROTECT)) { + if (!chan_has_user_status(c, cu->user, CUS_OWNER)) { + continue; + } else { + av[1] = sstrdup("-qo"); + } + } else { + av[1] = sstrdup("-ao"); + } + } else { + av[1] = sstrdup("-o"); + } + av[2] = sstrdup(cu->user->nick); + anope_cmd_mode(whosends(ci), av[0], "%s :%s", av[1], + av[2]); + do_cmode(s_ChanServ, 3, av); + free(av[2]); + free(av[1]); + free(av[0]); + } } notice_lang(s_ChanServ, u, CHAN_CLEARED_OPS, chan); } else if (ircd->halfop && stricmp(what, "hops") == 0) { @@ -6029,7 +6073,14 @@ static int do_clear(User * u) av[0] = sstrdup(chan); av[1] = sstrdup("-h"); av[2] = sstrdup(cu->user->nick); - anope_cmd_mode(whosends(ci), av[0], "%s :%s", av[1], av[2]); + if (ircd->svsmode_ucmode) { + anope_cmd_svsmode_chan(av[0], av[1], NULL); + do_cmode(s_ChanServ, 3, av); + break; + } else { + anope_cmd_mode(whosends(ci), av[0], "%s :%s", av[1], + av[2]); + } do_cmode(s_ChanServ, 3, av); free(av[2]); free(av[1]); @@ -6047,7 +6098,14 @@ static int do_clear(User * u) av[0] = sstrdup(chan); av[1] = sstrdup("-v"); av[2] = sstrdup(cu->user->nick); - anope_cmd_mode(whosends(ci), av[0], "%s :%s", av[1], av[2]); + if (ircd->svsmode_ucmode) { + anope_cmd_svsmode_chan(av[0], av[1], NULL); + do_cmode(s_ChanServ, 3, av); + break; + } else { + anope_cmd_mode(whosends(ci), av[0], "%s :%s", av[1], + av[2]); + } do_cmode(s_ChanServ, 3, av); free(av[2]); free(av[1]); diff --git a/src/dreamforge.c b/src/dreamforge.c index a13e0ca7c..d16e744dd 100644 --- a/src/dreamforge.c +++ b/src/dreamforge.c @@ -100,8 +100,7 @@ IRCDVar ircd[] = { 0, /* +I support */ 0, /* SJOIN ban char */ 0, /* SJOIN except char */ - 0, /* Services Client mode */ - 0, /* not p10 */ + 0, /* Can remove User Channel Modes with SVSMODE */ } , {NULL} @@ -1262,6 +1261,13 @@ void anope_cmd_unban(char *name, char *nick) /* Not Supported by this IRCD */ } +/* SVSMODE channel modes */ + +void anope_cmd_svsmode_chan(char *name, char *mode, char *nick) +{ + /* Not Supported by this IRCD */ +} + void anope_cmd_vhost_off(User * u) { /* Not Supported by this IRCD */ diff --git a/src/hostserv.c b/src/hostserv.c index 11ee42984..1a3feb9b2 100644 --- a/src/hostserv.c +++ b/src/hostserv.c @@ -16,7 +16,6 @@ #include "services.h" #include "pseudo.h" -#define HOST_VERSION 3 #define HASH(nick) ((tolower((nick)[0])&31)<<5 | (tolower((nick)[1])&31)) void load_hs_dbase_v1(dbFILE * f); @@ -700,6 +699,7 @@ int do_setall(User * u) if (!isValidHost(hostmask, 3)) { notice_lang(s_HostServ, u, HOST_SET_ERROR); + free(hostmask); return MOD_CONT; } @@ -708,6 +708,7 @@ int do_setall(User * u) if ((na = findnick(nick))) { if (na->status & NS_VERBOTEN) { notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick); + free(hostmask); return MOD_CONT; } if (vIdent && ircd->vident) { diff --git a/src/hybrid.c b/src/hybrid.c index 265d3260f..64008b387 100644 --- a/src/hybrid.c +++ b/src/hybrid.c @@ -100,8 +100,7 @@ IRCDVar ircd[] = { 0, /* +I support */ 0, /* SJOIN ban char */ 0, /* SJOIN except char */ - 0, /* Services Client mode */ - 0, /* not p10 */ + 0, /* Can remove User Channel Modes with SVSMODE */ } , {NULL} @@ -1374,6 +1373,13 @@ void anope_cmd_unban(char *name, char *nick) /* Not Supported by this IRCD */ } +/* SVSMODE channel modes */ + +void anope_cmd_svsmode_chan(char *name, char *mode, char *nick) +{ + /* Not Supported by this IRCD */ +} + /* SVSMODE +d */ /* sent if svid is something weird */ void anope_cmd_svid_umode(char *nick, time_t ts) diff --git a/src/memory.c b/src/memory.c index 504bbaabe..38e734aab 100644 --- a/src/memory.c +++ b/src/memory.c @@ -14,9 +14,6 @@ #include "services.h" -/*************************************************************************/ -/*************************************************************************/ - /* smalloc, scalloc, srealloc, sstrdup: * Versions of the memory allocation functions which will cause the * program to terminate with an "Out of memory" error if the memory @@ -24,6 +21,13 @@ * is never NULL.) */ +/*************************************************************************/ + +/** + * malloc, replacement so we can trap for "out of memory" + * @param size to allocate + * @return void + */ void *smalloc(long size) { void *buf; @@ -41,6 +45,14 @@ void *smalloc(long size) return buf; } +/*************************************************************************/ + +/** + * calloc, replacement so we can trap for "out of memory" + * @param elsize to allocate + * @param els size of members + * @return void + */ void *scalloc(long elsize, long els) { void *buf; @@ -58,6 +70,14 @@ void *scalloc(long elsize, long els) return buf; } +/*************************************************************************/ + +/** + * realloc, replacement so we can trap for "out of memory" + * @param oldptr Old Pointer + * @param newsize Size of new pointer + * @return void + */ void *srealloc(void *oldptr, long newsize) { void *buf; @@ -75,6 +95,14 @@ void *srealloc(void *oldptr, long newsize) return buf; } +/*************************************************************************/ + +/** + * strdup, replacement so we can trap for "out of memory" + * @param oldptr Old Pointer + * @param newsize Size of new pointer + * @return void + */ char *sstrdup(const char *src) { char *ret = NULL; diff --git a/src/memoserv.c b/src/memoserv.c index 0b32cff83..4210925fe 100644 --- a/src/memoserv.c +++ b/src/memoserv.c @@ -1106,7 +1106,7 @@ static int do_info(User * u) notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMOS_SOME_UNREAD, name, mi->memocount, count); } - if (mi->memomax >= 0) { + if (mi->memomax) { if (hardmax) notice_lang(s_MemoServ, u, MEMO_INFO_X_HARD_LIMIT, name, mi->memomax); diff --git a/src/misc.c b/src/misc.c index b2943a8de..0b2d5af10 100644 --- a/src/misc.c +++ b/src/misc.c @@ -27,38 +27,55 @@ struct arc4_stream { /*************************************************************************/ -/* toupper/tolower: Like the ANSI functions, but make sure we return an +/** + * toupper: Like the ANSI functions, but make sure we return an * int instead of a (signed) char. + * @param c Char + * @return int */ - int toupper(char c) { - if (islower(c)) + if (islower(c)) { return (unsigned char) c - ('a' - 'A'); - else + } else { return (unsigned char) c; + } } +/*************************************************************************/ + +/** + * tolower: Like the ANSI functions, but make sure we return an + * int instead of a (signed) char. + * @param c Char + * @return int + */ int tolower(char c) { - if (isupper(c)) + if (isupper(c)) { return (unsigned char) c + ('a' - 'A'); - else + } else { return (unsigned char) c; + } } /*************************************************************************/ -/* strscpy: Copy at most len-1 characters from a string to a buffer, and +/** + * strscpy: Copy at most len-1 characters from a string to a buffer, and * add a null terminator after the last character copied. + * @param d Buffer to copy into + * @param s Data to copy int + * @param len Length of data + * @return updated buffer */ - char *strscpy(char *d, const char *s, size_t len) { char *d_orig = d; - if (!len) + if (!len) { return d; + } while (--len && (*d++ = *s++)); *d = '\0'; return d_orig; @@ -66,11 +83,14 @@ char *strscpy(char *d, const char *s, size_t len) /*************************************************************************/ -/* stristr: Search case-insensitively for string s2 within string s1, +/** + * stristr: Search case-insensitively for string s2 within string s1, * returning the first occurrence of s2 or NULL if s2 was not * found. + * @param s1 String 1 + * @param s2 String 2 + * @return first occurrence of s2 */ - char *stristr(char *s1, char *s2) { register char *s = s1, *d = s2; @@ -91,12 +111,17 @@ char *stristr(char *s1, char *s2) /*************************************************************************/ -/* strnrepl: Replace occurrences of `old' with `new' in string `s'. Stop +/** + * strnrepl: Replace occurrences of `old' with `new' in string `s'. Stop * replacing if a replacement would cause the string to exceed * `size' bytes (including the null terminator). Return the * string. + * @param s String + * @param size size of s + * @param old character to replace + * @param new character to replace with + * @return updated s */ - char *strnrepl(char *s, int32 size, const char *old, const char *new) { char *ptr = s; @@ -124,13 +149,15 @@ char *strnrepl(char *s, int32 size, const char *old, const char *new) } /*************************************************************************/ -/*************************************************************************/ -/* merge_args: Take an argument count and argument vector and merge them +/** + * merge_args: Take an argument count and argument vector and merge them * into a single string in which each argument is separated by * a space. + * @param int Number of Args + * @param argv Array + * @return string of the merged array */ - char *merge_args(int argc, char **argv) { int i; @@ -145,13 +172,16 @@ char *merge_args(int argc, char **argv) } /*************************************************************************/ -/*************************************************************************/ -/* match_wild: Attempt to match a string to a pattern which might contain +/** + * do_match_wild: Attempt to match a string to a pattern which might contain * '*' or '?' wildcards. Return 1 if the string matches the * pattern, 0 if not. + * @param pattern To be matched + * @param str String in which the pattern is to be matched + * @param docase Case In/Senstive + * @return 1 if the string matches the pattern, 0 if not. */ - static int do_match_wild(const char *pattern, const char *str, int docase) { char c; @@ -195,21 +225,36 @@ static int do_match_wild(const char *pattern, const char *str, int docase) } } +/*************************************************************************/ +/** + * match_wild: Case Senstive wild card search + * @param pattern To be matched + * @param str String in which the pattern is to be matched + * @return 1 if the string matches the pattern, 0 if not. + */ int match_wild(const char *pattern, const char *str) { return do_match_wild(pattern, str, 1); } +/*************************************************************************/ + +/** + * match_wild: Case Insenstive wild card search + * @param pattern To be matched + * @param str String in which the pattern is to be matched + * @return 1 if the string matches the pattern, 0 if not. + */ int match_wild_nocase(const char *pattern, const char *str) { return do_match_wild(pattern, str, 0); } /*************************************************************************/ -/*************************************************************************/ -/* Process a string containing a number/range list in the form +/** + * Process a string containing a number/range list in the form * "n1[-n2][,n3[-n4]]...", calling a caller-specified routine for each * number in the list. If the callback returns -1, stop immediately. * Returns the sum of all nonnegative return values from the callback. @@ -218,8 +263,13 @@ int match_wild_nocase(const char *pattern, const char *str) * * The callback should be of type range_callback_t, which is defined as: * int (*range_callback_t)(User *u, int num, va_list args) + * @param numstr + * @param count_ret + * @param callback Call back function + * @param u User Struct + * @param ... various args + * @return int */ - int process_numlist(const char *numstr, int *count_ret, range_callback_t callback, User * u, ...) { @@ -279,15 +329,17 @@ int process_numlist(const char *numstr, int *count_ret, /*************************************************************************/ -/* dotime: Return the number of seconds corresponding to the given time +/** + * dotime: Return the number of seconds corresponding to the given time * string. If the given string does not represent a valid time, * return -1. * * A time string is either a plain integer (representing a number * of seconds), or an integer followed by one of these characters: * "s" (seconds), "m" (minutes), "h" (hours), or "d" (days). + * @param s String to convert + * @return int */ - int dotime(const char *s) { int amount; @@ -317,9 +369,15 @@ int dotime(const char *s) /*************************************************************************/ -/* Expresses in a string the period of time represented by a given amount - of seconds (with days/hours/minutes). */ - +/** + * Expresses in a string the period of time represented by a given amount + * of seconds (with days/hours/minutes). + * @param na Nick Alias + * @param buf buffer to store result into + * @param bufsize Size of the buffer + * @param seconds time in seconds + * @return buffer + */ char *duration(NickAlias * na, char *buf, int bufsize, time_t seconds) { int days = 0, hours = 0, minutes = 0; @@ -380,8 +438,14 @@ char *duration(NickAlias * na, char *buf, int bufsize, time_t seconds) /*************************************************************************/ -/* Generates a human readable string of type "expires in ..." */ - +/** + * Generates a human readable string of type "expires in ..." + * @param na Nick Alias + * @param buf buffer to store result into + * @param bufsize Size of the buffer + * @param seconds time in seconds + * @return buffer + */ char *expire_left(NickAlias * na, char *buf, int len, time_t expires) { time_t now = time(NULL); @@ -429,17 +493,18 @@ char *expire_left(NickAlias * na, char *buf, int len, time_t expires) return buf; } + +/*************************************************************************/ + /** - * Return 1 if a host is valid, 0 if it isnt. - * host = string to check - * type = format, 1 = ip4addr, 2 = hostname - * + * Validate the host * shortname = ( letter / digit ) *( letter / digit / "-" ) *( letter / digit ) * hostname = shortname *( "." shortname ) * ip4addr = 1*3digit "." 1*3digit "." 1*3digit "." 1*3digit - * - **/ - + * @param host = string to check + * @param type = format, 1 = ip4addr, 2 = hostname + * @return 1 if a host is valid, 0 if it isnt. + */ int doValidHost(const char *host, int type) { int idx = 0; @@ -517,16 +582,14 @@ int doValidHost(const char *host, int type) return 1; } +/*************************************************************************/ + /** - * Return 1 if a host is valid, 0 if it isnt. - * host = string to check - * type = format, 1 = ip4addr, 2 = hostname, 3 = either - * - * shortname = ( letter / digit ) *( letter / digit / "-" ) *( letter / digit ) - * hostname = shortname *( "." shortname ) - * ip4addr = 1*3digit "." 1*3digit "." 1*3digit "." 1*3digit - * - **/ + * Front end to doValidHost + * @param host = string to check + * @param type = format, 1 = ip4addr, 2 = hostname + * @return 1 if a host is valid, 0 if it isnt. + */ int isValidHost(const char *host, int type) { int status = 0; @@ -540,6 +603,13 @@ int isValidHost(const char *host, int type) return status; } +/*************************************************************************/ + +/** + * Valid character check + * @param c Charaacter to check + * @return 1 if a host is valid, 0 if it isnt. + */ int isvalidchar(const char c) { if (((c >= 'A') && (c <= 'Z')) || @@ -550,6 +620,16 @@ int isvalidchar(const char c) return 0; } + +/*************************************************************************/ + +/** + * Get the token + * @param str String to search in + * @param dilim Character to search for + * @param token_number the token number + * @return token + */ char *myStrGetToken(const char *str, const char dilim, int token_number) { int len, idx, counter = 0, start_pos = 0; @@ -572,6 +652,15 @@ char *myStrGetToken(const char *str, const char dilim, int token_number) return substring; } +/*************************************************************************/ + +/** + * Get the token only + * @param str String to search in + * @param dilim Character to search for + * @param token_number the token number + * @return token + */ char *myStrGetOnlyToken(const char *str, const char dilim, int token_number) { @@ -598,6 +687,15 @@ char *myStrGetOnlyToken(const char *str, const char dilim, return substring; } +/*************************************************************************/ + +/** + * Get the Remaining tokens + * @param str String to search in + * @param dilim Character to search for + * @param token_number the token number + * @return token + */ char *myStrGetTokenRemainder(const char *str, const char dilim, int token_number) { @@ -622,6 +720,15 @@ char *myStrGetTokenRemainder(const char *str, const char dilim, return substring; } +/*************************************************************************/ + +/** + * Get the string between point A and point B + * @param str String to search in + * @param start Point A + * @param end Point B + * @return the string in between + */ char *myStrSubString(const char *src, int start, int end) { char *substring = NULL; @@ -640,6 +747,13 @@ char *myStrSubString(const char *src, int start, int end) return substring; } +/*************************************************************************/ + +/** + * Clean up the buffer for extra spaces + * @param str to clean up + * @return void + */ void doCleanBuffer(char *str) { char *in, *out; @@ -669,6 +783,14 @@ void doCleanBuffer(char *str) *out = ch; /* == '\0' */ } +/*************************************************************************/ + +/** + * Kill the user to enforce the sqline + * @param nick to kill + * @param killer whom is doing the killing + * @return void + */ void EnforceQlinedNick(char *nick, char *killer) { User *u2; @@ -681,6 +803,14 @@ void EnforceQlinedNick(char *nick, char *killer) } } +/*************************************************************************/ + +/** + * Is the given nick a network service + * @param nick to check + * @param int Check if botserv bots + * @return int + */ int nickIsServices(char *nick, int bot) { int found = 0; @@ -742,6 +872,12 @@ int nickIsServices(char *nick, int bot) return found; } +/*************************************************************************/ + +/** + * arc4 init + * @return void + */ static void arc4_init(void) { int n; @@ -751,6 +887,14 @@ static void arc4_init(void) rs.j = 0; } +/*************************************************************************/ + +/** + * arc4 addrandom + * @param data + * @param dalen Data Length + * @return void + */ static void arc4_addrandom(void *dat, int datlen) { int n; @@ -766,6 +910,12 @@ static void arc4_addrandom(void *dat, int datlen) } } +/*************************************************************************/ + +/** + * random init + * @return void + */ void rand_init(void) { int n; @@ -797,7 +947,7 @@ void rand_init(void) /* unix/bsd: time */ gettimeofday(&rdat.nowt, NULL); /* unix/bsd: /dev/urandom */ - fd = open("/dev/urandom", "r"); + fd = open("/dev/urandom", O_RDONLY); if (fd) { n = read(fd, &rdat.rnd, sizeof(rdat.rnd)); close(fd); @@ -812,6 +962,12 @@ void rand_init(void) arc4_addrandom(&rdat, sizeof(rdat)); } +/*************************************************************************/ + +/** + * Setup the random numbers + * @return void + */ void add_entropy_userkeys(void) { arc4_addrandom(&UserKey1, sizeof(UserKey1)); @@ -820,6 +976,12 @@ void add_entropy_userkeys(void) /* UserKey3 is also used in mysql_rand() */ } +/*************************************************************************/ + +/** + * Get the random numbers 8 byte deep + * @return char + */ u_char getrandom8(void) { u_char si, sj; @@ -833,6 +995,12 @@ u_char getrandom8(void) return (rs.s[(si + sj) & 0xff]); } +/*************************************************************************/ + +/** + * Get the random numbers 16 byte deep + * @return char + */ u_int16_t getrandom16(void) { u_int16_t val; @@ -842,6 +1010,12 @@ u_int16_t getrandom16(void) return val; } +/*************************************************************************/ + +/** + * Get the random numbers 32 byte deep + * @return char + */ u_int32_t getrandom32(void) { u_int32_t val; @@ -853,6 +1027,14 @@ u_int32_t getrandom32(void) return val; } +/*************************************************************************/ + +/** + * Determine if we need to send the TOKEN + * @param token1 + * @param token2 + * @return token to send + */ char *send_token(char *token1, char *token2) { if (UseTokens && ircd->token && ircdcap->token) { @@ -863,6 +1045,14 @@ char *send_token(char *token1, char *token2) } } +/*************************************************************************/ + +/** + * Number of tokens in a string + * @param str String + * @param dilim Dilimiter + * @return number of tokens + */ int myNumToken(const char *str, const char dilim) { int len, idx, counter = 0, start_pos = 0; @@ -879,7 +1069,13 @@ int myNumToken(const char *str, const char dilim) return counter; } +/*************************************************************************/ +/** + * Resolve a host to an IP + * @param host to convert + * @return ip address + */ char *host_resolve(char *host) { struct hostent *hentp = NULL; diff --git a/src/news.c b/src/news.c index 7a2b5a898..868be1993 100644 --- a/src/news.c +++ b/src/news.c @@ -155,7 +155,7 @@ void load_news() { dbFILE *f; int i; - int16 n; + uint16 n; uint32 tmp32; if (!(f = open_db(s_OperServ, NewsDBName, "r", NEWS_VERSION))) diff --git a/src/nickserv.c b/src/nickserv.c index 2872cd348..0004436ac 100644 --- a/src/nickserv.c +++ b/src/nickserv.c @@ -373,7 +373,7 @@ void load_old_ns_dbase(void) NickCore *nc; int failed = 0; - int16 tmp16; + uint16 tmp16; uint32 tmp32; char bufn[NICKMAX], bufp[PASSMAX]; @@ -662,7 +662,7 @@ void load_ns_dbase(void) NickAlias *na, **nalast, *naprev; NickCore *nc, **nclast, *ncprev; int failed = 0; - int16 tmp16; + uint16 tmp16; uint32 tmp32; char *s; diff --git a/src/operserv.c b/src/operserv.c index f64aca4f9..247e70704 100644 --- a/src/operserv.c +++ b/src/operserv.c @@ -380,7 +380,7 @@ static void load_old_akill(void) { dbFILE *f; int i, j; - int16 tmp16; + uint16 tmp16; uint32 tmp32; char buf[NICKMAX], mask2[BUFSIZE], *mask, *s; Akill *ak, *entry; @@ -492,9 +492,9 @@ static void load_old_akill(void) void load_os_dbase(void) { dbFILE *f; - int16 i, n, ver, c; + int16 i, ver, c; HostCache *hc, **hclast, *hcprev; - int16 tmp16; + uint16 tmp16, n; uint32 tmp32; char *s; int failed = 0; @@ -1627,97 +1627,140 @@ static int do_clearmodes(User * u) } } - if (WallOSClearmodes) + if (WallOSClearmodes) { anope_cmd_global(s_OperServ, "%s used CLEARMODES%s on %s", u->nick, all ? " ALL" : "", chan); - + } if (all) { /* Clear mode +o */ - for (cu = c->users; cu; cu = next) { - next = cu->next; - - if (!chan_has_user_status(c, cu->user, CUS_OP)) - continue; - - argv[0] = sstrdup("-o"); - argv[1] = cu->user->nick; - - anope_cmd_mode(s_OperServ, c->name, "-o %s", - cu->user->nick); - chan_set_modes(s_OperServ, c, 2, argv, 0); - - free(argv[0]); + if (ircd->svsmode_ucmode) { + anope_cmd_svsmode_chan(c->name, "-o", NULL); + for (cu = c->users; cu; cu = next) { + next = cu->next; + if (!chan_has_user_status(c, cu->user, CUS_OP)) { + continue; + } + argv[0] = sstrdup("-o"); + argv[1] = cu->user->nick; + chan_set_modes(s_OperServ, c, 2, argv, 0); + free(argv[0]); + } + } else { + for (cu = c->users; cu; cu = next) { + next = cu->next; + if (!chan_has_user_status(c, cu->user, CUS_OP)) + continue; + argv[0] = sstrdup("-o"); + argv[1] = cu->user->nick; + anope_cmd_mode(s_OperServ, c->name, "-o %s", + cu->user->nick); + chan_set_modes(s_OperServ, c, 2, argv, 0); + free(argv[0]); + } } - /* Clear mode +v */ - for (cu = c->users; cu; cu = next) { - next = cu->next; - - if (!chan_has_user_status(c, cu->user, CUS_VOICE)) - continue; - - argv[0] = sstrdup("-v"); - argv[1] = sstrdup(cu->user->nick); - - anope_cmd_mode(s_OperServ, c->name, "-v %s", - cu->user->nick); - chan_set_modes(s_OperServ, c, 2, argv, 0); - - free(argv[0]); + if (ircd->svsmode_ucmode) { + anope_cmd_svsmode_chan(c->name, "-v", NULL); + for (cu = c->users; cu; cu = next) { + next = cu->next; + if (!chan_has_user_status(c, cu->user, CUS_VOICE)) { + continue; + } + argv[0] = sstrdup("-v"); + argv[1] = cu->user->nick; + chan_set_modes(s_OperServ, c, 2, argv, 0); + free(argv[0]); + } + } else { + /* Clear mode +v */ + for (cu = c->users; cu; cu = next) { + next = cu->next; + if (!chan_has_user_status(c, cu->user, CUS_VOICE)) + continue; + argv[0] = sstrdup("-v"); + argv[1] = sstrdup(cu->user->nick); + anope_cmd_mode(s_OperServ, c->name, "-v %s", + cu->user->nick); + chan_set_modes(s_OperServ, c, 2, argv, 0); + free(argv[0]); + } } + /* Clear mode +h */ - if (ircd->halfop) { + if (ircd->svsmode_ucmode && ircd->halfop) { + anope_cmd_svsmode_chan(c->name, "-h", NULL); + for (cu = c->users; cu; cu = next) { + next = cu->next; + if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) { + continue; + } + argv[0] = sstrdup("-h"); + argv[1] = cu->user->nick; + chan_set_modes(s_OperServ, c, 2, argv, 0); + free(argv[0]); + } + } else { for (cu = c->users; cu; cu = next) { next = cu->next; - if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) continue; - argv[0] = sstrdup("-h"); argv[1] = sstrdup(cu->user->nick); - anope_cmd_mode(s_OperServ, c->name, "-h %s", cu->user->nick); chan_set_modes(s_OperServ, c, 2, argv, 0); - free(argv[0]); } } - /* Clear mode Owners */ - if (ircd->owner) { + if (ircd->svsmode_ucmode && ircd->owner) { + anope_cmd_svsmode_chan(c->name, ircd->ownerunset, NULL); + for (cu = c->users; cu; cu = next) { + next = cu->next; + if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) { + continue; + } + argv[0] = sstrdup(ircd->ownerunset); + argv[1] = cu->user->nick; + chan_set_modes(s_OperServ, c, 2, argv, 0); + free(argv[0]); + } + } else { for (cu = c->users; cu; cu = next) { next = cu->next; - if (!chan_has_user_status(c, cu->user, CUS_OWNER)) continue; - argv[0] = sstrdup(ircd->ownerunset); argv[1] = sstrdup(cu->user->nick); - anope_cmd_mode(s_OperServ, c->name, "%s %s", ircd->ownerunset, cu->user->nick); chan_set_modes(s_OperServ, c, 2, argv, 0); - free(argv[0]); } } - /* Clear mode protected or admins */ - if (ircd->protect || ircd->admin) { + if (ircd->svsmode_ucmode && (ircd->protect || ircd->admin)) { + anope_cmd_svsmode_chan(c->name, "-a", NULL); + for (cu = c->users; cu; cu = next) { + next = cu->next; + if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) { + continue; + } + argv[0] = sstrdup("-a"); + argv[1] = cu->user->nick; + chan_set_modes(s_OperServ, c, 2, argv, 0); + free(argv[0]); + } + } else { for (cu = c->users; cu; cu = next) { next = cu->next; - if (!chan_has_user_status(c, cu->user, CUS_PROTECT)) continue; - argv[0] = sstrdup("-a"); argv[1] = sstrdup(cu->user->nick); - anope_cmd_mode(s_OperServ, c->name, "-a %s", cu->user->nick); chan_set_modes(s_OperServ, c, 2, argv, 0); - free(argv[0]); } } diff --git a/src/process.c b/src/process.c index d0618ffd2..6d8e87d13 100644 --- a/src/process.c +++ b/src/process.c @@ -184,14 +184,19 @@ void process() char **av; Message *m; + /* zero out the buffers before we do much else */ + *buf = '\0'; + *source = '\0'; + *cmd = '\0'; /* If debugging, log the buffer */ - if (debug) + if (debug) { alog("debug: Received: %s", inbuf); + } /* First make a copy of the buffer so we have the original in case we * crash - in that case, we want to know what we crashed on. */ - strscpy(buf, inbuf, sizeof(buf)); + strscpy(buf, inbuf, 513); doCleanBuffer((char *) buf); diff --git a/src/ptlink.c b/src/ptlink.c index 3414936a9..fe5198a9c 100644 --- a/src/ptlink.c +++ b/src/ptlink.c @@ -100,8 +100,7 @@ IRCDVar ircd[] = { 0, /* +I support */ 0, /* SJOIN ban char */ 0, /* SJOIN except char */ - 0, /* Services Client mode */ - 0, /* not p10 */ + 0, /* Can remove User Channel Modes with SVSMODE */ } , {NULL} @@ -1534,6 +1533,13 @@ void anope_cmd_unban(char *name, char *nick) /* Not Supported by this IRCD */ } +/* SVSMODE channel modes */ + +void anope_cmd_svsmode_chan(char *name, char *mode, char *nick) +{ + /* Not Supported by this IRCD */ +} + void anope_cmd_svso(char *source, char *nick, char *flag) { /* Not Supported by this IRCD */ diff --git a/src/rageircd.c b/src/rageircd.c index 8c8045c7f..7bfb2fe58 100644 --- a/src/rageircd.c +++ b/src/rageircd.c @@ -101,8 +101,7 @@ IRCDVar ircd[] = { 1, /* +I support */ 0, /* SJOIN ban char */ 0, /* SJOIN except char */ - 0, /* Services Client mode */ - 0, /* not p10 */ + 0, /* Can remove User Channel Modes with SVSMODE */ }, {NULL} }; @@ -1290,9 +1289,22 @@ void anope_cmd_bot_nick(char *nick, char *user, char *host, char *real, anope_cmd_sqline(nick, "Reserved for services"); } +/* SVSMODE -b */ void anope_cmd_unban(char *name, char *nick) { - send_cmd(ServerName, "SVSMODE %s -b %s", name, nick); + anope_cmd_svsmode_chan(name, "-b", nick); +} + + +/* SVSMODE channel modes */ + +void anope_cmd_svsmode_chan(char *name, char *mode, char *nick) +{ + if (nick) { + send_cmd(ServerName, "SVSMODE %s %s %s", name, mode, nick); + } else { + send_cmd(ServerName, "SVSMODE %s %s", name, mode); + } } void anope_cmd_bot_chan_mode(char *nick, char *chan) diff --git a/src/servers.c b/src/servers.c index b9515e12f..b83dea124 100644 --- a/src/servers.c +++ b/src/servers.c @@ -444,6 +444,14 @@ void capab_parse(int ac, char **av) } } +/*************************************************************************/ + +/** + * Search the uline servers array to find out if the server that just set the + * mode is in our uline list + * @param server Server Setting the mode + * @return int 0 if not found, 1 if found + */ int is_ulined(char *server) { int j; diff --git a/src/sessions.c b/src/sessions.c index 86a440b35..f2726ba10 100644 --- a/src/sessions.c +++ b/src/sessions.c @@ -379,8 +379,8 @@ void load_exceptions() { dbFILE *f; int i; - int16 n; - int16 tmp16; + uint16 n; + uint16 tmp16; uint32 tmp32; if (! diff --git a/src/slist.c b/src/slist.c index ee84335a9..a5fab3c7b 100644 --- a/src/slist.c +++ b/src/slist.c @@ -19,10 +19,14 @@ static SListOpts slist_defopts = { 0, NULL, NULL, NULL }; /*************************************************************************/ -/* Adds a pointer to the list. Returns the index of the new item. - Returns -2 if there are too many items in the list, -3 if the - item already exists when the flags of the list contain SLISTF_NODUP. */ - +/** + * Adds a pointer to the list. Returns the index of the new item. + * Returns -2 if there are too many items in the list, -3 if the + * item already exists when the flags of the list contain SLISTF_NODUP. + * @param slist Slist Struct + * @param item Item being added + * @return int + */ int slist_add(SList * slist, void *item) { if (slist->limit != 0 && slist->count >= slist->limit) @@ -57,10 +61,13 @@ int slist_add(SList * slist, void *item) /*************************************************************************/ -/* Clears the list. If free is 1, the freeitem function will be called +/** + * Clears the list. If free is 1, the freeitem function will be called * for each item before clearing. + * @param slist Slist Struct + * @param mustfree What is being freed + * @return void */ - void slist_clear(SList * slist, int mustfree) { if (mustfree && slist->opts && slist->opts->freeitem && slist->count) { @@ -81,9 +88,13 @@ void slist_clear(SList * slist, int mustfree) /*************************************************************************/ -/* Deletes an item from the list, by index. Returns 1 if successful, - 0 otherwise. */ - +/** + * Deletes an item from the list, by index. Returns 1 if successful, + * 0 otherwise. + * @param slist Slist Struct + * @param index beign deleted + * @return int Returns 1 if successful, 0 otherwise. + */ int slist_delete(SList * slist, int index) { /* Range check */ @@ -107,10 +118,15 @@ int slist_delete(SList * slist, int index) /*************************************************************************/ -/* Deletes a range of entries. Return -1 if the permission was denied, +/** + * Deletes a range of entries. Return -1 if the permission was denied, * 0 if no records were deleted, or the number of records deleted + * @param slist Slist Struct + * @param range Range to delete + * @param cb Call back function + * @param ... various args + * @return int */ - int slist_delete_range(SList * slist, char *range, slist_delcheckcb_t cb, ...) { @@ -164,11 +180,16 @@ int slist_delete_range(SList * slist, char *range, slist_delcheckcb_t cb, /*************************************************************************/ -/* Enumerates all entries of the list. If range is not NULL, will only +/** + * Enumerates all entries of the list. If range is not NULL, will only * enumerate entries that are in the range. Returns the total number * of entries enumerated. + * @param slit Slist struct + * @param range Range to enum + * @param cb Call back function + * @param ... various args + * @return int */ - int slist_enum(SList * slist, char *range, slist_enumcb_t cb, ...) { int count = 0, i, res; @@ -231,8 +252,11 @@ int slist_enum(SList * slist, char *range, slist_enumcb_t cb, ...) /*************************************************************************/ -/* Determines whether the list is full. */ - +/** + * Determines whether the list is full. + * @param slist Slist Struct + * @return int + */ int slist_full(SList * slist) { if (slist->limit != 0 && slist->count >= slist->limit) @@ -243,8 +267,11 @@ int slist_full(SList * slist) /*************************************************************************/ -/* Initialization of the list. */ - +/** + * Initialization of the list. + * @param slist Slist Struct + * @return int + */ void slist_init(SList * slist) { memset(slist, 0, sizeof(SList)); @@ -254,8 +281,12 @@ void slist_init(SList * slist) /*************************************************************************/ -/* Returns the index of an item in the list, -1 if inexistant. */ - +/** + * Returns the index of an item in the list, -1 if inexistant. + * @param slist Slist Struct + * @param item Item index + * @return int + */ int slist_indexof(SList * slist, void *item) { int16 i; @@ -278,8 +309,11 @@ int slist_indexof(SList * slist, void *item) /*************************************************************************/ -/* Removes all NULL pointers from the list. */ - +/** + * Removes all NULL pointers from the list. + * @param slist Slist Struct + * @return void + */ void slist_pack(SList * slist) { int i; @@ -291,9 +325,13 @@ void slist_pack(SList * slist) /*************************************************************************/ -/* Removes a specific item from the list. Returns the old index of the - deleted item, or -1 if the item was not found. */ - +/** + * Removes a specific item from the list. Returns the old index of the + * deleted item, or -1 if the item was not found. + * @param slist Slist Struct + * @param item to remove + * @return int + */ int slist_remove(SList * slist, void *item) { int index = slist_indexof(slist, item); @@ -305,8 +343,12 @@ int slist_remove(SList * slist, void *item) /*************************************************************************/ -/* Sets the maximum capacity of the list */ - +/** + * Sets the maximum capacity of the list + * @param slist Slist Struct + * @param capacity How large the list can be + * @return int + */ int slist_setcapacity(SList * slist, int16 capacity) { if (slist->capacity == capacity) diff --git a/src/sockutil.c b/src/sockutil.c index 7d65c0bab..06453cbf5 100644 --- a/src/sockutil.c +++ b/src/sockutil.c @@ -15,30 +15,44 @@ #include "services.h" /*************************************************************************/ -/*************************************************************************/ - -/* Read from a socket with buffering. */ static char read_netbuf[NET_BUFSIZE]; static char *read_curpos = read_netbuf; /* Next byte to return */ static char *read_bufend = read_netbuf; /* Next position for data from socket */ static char *const read_buftop = read_netbuf + NET_BUFSIZE; int32 total_read = 0; +static char write_netbuf[NET_BUFSIZE]; +static char *write_curpos = write_netbuf; /* Next byte to write to socket */ +static char *write_bufend = write_netbuf; /* Next position for data to socket */ +static char *const write_buftop = write_netbuf + NET_BUFSIZE; +static int write_fd = -1; +int32 total_written; +static int lastchar = EOF; +/*************************************************************************/ -/* Return amount of data in read buffer. */ - +/** + * Return amount of data in read buffer. + * @return int32 + */ int32 read_buffer_len() { - if (read_bufend >= read_curpos) + if (read_bufend >= read_curpos) { return read_bufend - read_curpos; - else + } else { return (read_bufend + NET_BUFSIZE) - read_curpos; + } } +/*************************************************************************/ -/* Read data. */ - +/** + * Read data. + * @param fd File Pointer + * @param buf Buffer + * @param int Length of buffer + * @return int + */ static int buffered_read(int fd, char *buf, int len) { int nread, left = len; @@ -108,9 +122,14 @@ static int buffered_read(int fd, char *buf, int len) return len - left; } -/* Optimized version of the above for reading a single character; returns - * the character in an int or EOF, like fgetc(). */ +/*************************************************************************/ +/** + * Optimized version of the above for reading a single character; returns + * the character in an int or EOF, like fgetc(). + * @param fd File Pointer + * @return int + */ static int buffered_read_one(int fd) { int nread; @@ -166,31 +185,27 @@ static int buffered_read_one(int fd) /*************************************************************************/ -/* Write to a socket with buffering. Note that this assumes only one - * socket. */ - -static char write_netbuf[NET_BUFSIZE]; -static char *write_curpos = write_netbuf; /* Next byte to write to socket */ -static char *write_bufend = write_netbuf; /* Next position for data to socket */ -static char *const write_buftop = write_netbuf + NET_BUFSIZE; -static int write_fd = -1; -int32 total_written; - - -/* Return amount of data in write buffer. */ - +/** + * Return amount of data in write buffer. + * @return int + */ int32 write_buffer_len() { - if (write_bufend >= write_curpos) + if (write_bufend >= write_curpos) { return write_bufend - write_curpos; - else + } else { return (write_bufend + NET_BUFSIZE) - write_curpos; + } } +/*************************************************************************/ -/* Helper routine to try and write up to one chunk of data from the buffer - * to the socket. Return how much was written. */ - +/** + * Helper routine to try and write up to one chunk of data from the buffer + * to the socket. Return how much was written. + * @param wait Wait + * @return int + */ static int flush_write_buffer(int wait) { fd_set fds; @@ -226,9 +241,15 @@ static int flush_write_buffer(int wait) return 0; } +/*************************************************************************/ -/* Write data. */ - +/** + * Write data. + * @param fd File Pointer + * @param buf Buffer to write + * @param len Length to write + * @return int + */ static int buffered_write(int fd, char *buf, int len) { int nwritten, left = len; @@ -293,10 +314,17 @@ static int buffered_write(int fd, char *buf, int len) return len - left; } -/* Optimized version of the above for writing a single character; returns - * the character in an int or EOF, like fputc(). Commented out because it - * isn't currently used. */ +/*************************************************************************/ + +/** + * Optimized version of the above for writing a single character; returns + * the character in an int or EOF, like fputc(). Commented out because it + * isn't currently used. + * @param int to write + * @param fd Pointer + * @return int + */ #if 0 static int buffered_write_one(int c, int fd) { @@ -339,10 +367,12 @@ static int buffered_write_one(int c, int fd) #endif /* 0 */ /*************************************************************************/ -/*************************************************************************/ - -static int lastchar = EOF; +/** + * sgetc ? + * @param int to read + * @return int + */ int sgetc(int s) { int c; @@ -355,6 +385,14 @@ int sgetc(int s) return buffered_read_one(s); } +/*************************************************************************/ + +/** + * sungetc ? + * @param int c + * @param int s + * @return int + */ int sungetc(int c, int s) { return lastchar = c; @@ -362,10 +400,14 @@ int sungetc(int c, int s) /*************************************************************************/ -/* If connection was broken, return NULL. If the read timed out, return +/** + * If connection was broken, return NULL. If the read timed out, return * (char *)-1. + * @param buf Buffer to get + * @param len Length + * @param s Socket + * @return buffer */ - char *sgets(char *buf, int len, int s) { int c = 0; @@ -395,10 +437,14 @@ char *sgets(char *buf, int len, int s) /*************************************************************************/ -/* sgets2: Read a line of text from a socket, and strip newline and +/** + * sgets2: Read a line of text from a socket, and strip newline and * carriage return characters from the end of the line. + * @param buf Buffer to get + * @param len Length + * @param s Socket + * @return buffer */ - char *sgets2(char *buf, int len, int s) { char *str = sgets(buf, len, s); @@ -415,9 +461,14 @@ char *sgets2(char *buf, int len, int s) /*************************************************************************/ -/* Read from a socket. (Use this instead of read() because it has - * buffering.) */ - +/** + * Read from a socket. (Use this instead of read() because it has + * buffering.) + * @param s Socket + * @param buf Buffer to get + * @param len Length + * @return int + */ int sread(int s, char *buf, int len) { return buffered_read(s, buf, len); @@ -425,6 +476,12 @@ int sread(int s, char *buf, int len) /*************************************************************************/ +/** + * sputs : write buffer + * @param s Socket + * @param str Buffer to write + * @return int + */ int sputs(char *str, int s) { return buffered_write(s, str, strlen(str)); @@ -432,25 +489,35 @@ int sputs(char *str, int s) /*************************************************************************/ +/** + * sockprintf : a socket writting printf() + * @param s Socket + * @param fmt format of message + * @param ... various args + * @return int + */ int sockprintf(int s, char *fmt, ...) { va_list args; char buf[16384]; /* Really huge, to try and avoid truncation */ + int value; va_start(args, fmt); - return buffered_write(s, buf, vsnprintf(buf, sizeof(buf), fmt, args)); - /* no va_end() but not sure how to squeeze it in here */ + value = buffered_write(s, buf, vsnprintf(buf, sizeof(buf), fmt, args)); + va_end(args); + return value; } /*************************************************************************/ -/*************************************************************************/ #if !HAVE_GETHOSTBYNAME -/* Translate an IP dotted-quad address to a 4-byte character string. +/** + * Translate an IP dotted-quad address to a 4-byte character string. * Return NULL if the given string is not in dotted-quad format. + * @param ipaddr IP Address + * @return char 4byte ip char string */ - static char *pack_ip(const char *ipaddr) { static char ipbuf[4]; @@ -471,10 +538,15 @@ static char *pack_ip(const char *ipaddr) /*************************************************************************/ -/* lhost/lport specify the local side of the connection. If they are not +/** + * lhost/lport specify the local side of the connection. If they are not * given (lhost==NULL, lport==0), then they are left free to vary. + * @param host Remote Host + * @param port Remote Port + * @param lhost LocalHost + * @param lport LocalPort + * @return int if successful */ - int conn(const char *host, int port, const char *lhost, int lport) { #if HAVE_GETHOSTBYNAME @@ -543,6 +615,11 @@ int conn(const char *host, int port, const char *lhost, int lport) /*************************************************************************/ +/** + * Close up the connection + * @param s Socket + * @return void + */ void disconn(int s) { shutdown(s, 2); diff --git a/src/solidircd.c b/src/solidircd.c index dd4867857..2bfe29d68 100644 --- a/src/solidircd.c +++ b/src/solidircd.c @@ -102,8 +102,7 @@ IRCDVar ircd[] = { 1, /* +I support */ 0, /* SJOIN ban char */ 0, /* SJOIN except char */ - 0, /* Services Client mode */ - 0, /* not p10 */ + 0, /* Can remove User Channel Modes with SVSMODE */ } , {NULL} @@ -512,7 +511,19 @@ void anope_cmd_release_svshold(char *nick) /* SVSMODE -b */ void anope_cmd_unban(char *name, char *nick) { - send_cmd(ServerName, "SVSMODE %s -b %s", name, nick); + anope_cmd_svsmode_chan(name, "-b", nick); +} + + +/* SVSMODE channel modes */ + +void anope_cmd_svsmode_chan(char *name, char *mode, char *nick) +{ + if (nick) { + send_cmd(ServerName, "SVSMODE %s %s %s", name, mode, nick); + } else { + send_cmd(ServerName, "SVSMODE %s %s", name, mode); + } } void anope_cmd_bot_chan_mode(char *nick, char *chan) diff --git a/src/ultimate2.c b/src/ultimate2.c index a6a683359..0b612a8fd 100644 --- a/src/ultimate2.c +++ b/src/ultimate2.c @@ -100,8 +100,7 @@ IRCDVar ircd[] = { 0, /* +I support */ 0, /* SJOIN ban char */ 0, /* SJOIN except char */ - UMODE_S, /* Services Client mode */ - 0, /* not p10 */ + 0, /* Can remove User Channel Modes with SVSMODE */ } , {NULL} @@ -1558,6 +1557,13 @@ void anope_cmd_unban(char *name, char *nick) /* Not Supported by this IRCD */ } +/* SVSMODE channel modes */ + +void anope_cmd_svsmode_chan(char *name, char *mode, char *nick) +{ + /* Not Supported by this IRCD */ +} + /* SVSMODE +d */ /* sent if svid is something weird */ void anope_cmd_svid_umode(char *nick, time_t ts) diff --git a/src/ultimate3.c b/src/ultimate3.c index ffcfc120a..b9f1b43a6 100644 --- a/src/ultimate3.c +++ b/src/ultimate3.c @@ -102,8 +102,7 @@ IRCDVar ircd[] = { 0, /* +I support */ 0, /* SJOIN ban char */ 0, /* SJOIN except char */ - UMODE_S, /* Services Client mode */ - 0, /* not p10 */ + 0, /* Can remove User Channel Modes with SVSMODE */ }, {NULL} }; @@ -466,11 +465,22 @@ CUMode cumodes[128] = { {0}, {0}, {0}, {0}, {0} }; - /* SVSMODE -b */ void anope_cmd_unban(char *name, char *nick) { - send_cmd(ServerName, "SVSMODE %s -b %s", name, nick); + anope_cmd_svsmode_chan(name, "-b", nick); +} + + +/* SVSMODE channel modes */ + +void anope_cmd_svsmode_chan(char *name, char *mode, char *nick) +{ + if (nick) { + send_cmd(ServerName, "SVSMODE %s %s %s", name, mode, nick); + } else { + send_cmd(ServerName, "SVSMODE %s %s", name, mode); + } } int anope_event_sjoin(char *source, int ac, char **av) diff --git a/src/unreal31.c b/src/unreal31.c index 2911f397d..cd3b2e470 100644 --- a/src/unreal31.c +++ b/src/unreal31.c @@ -103,8 +103,7 @@ IRCDVar ircd[] = { 0, /* +I support */ 0, /* SJOIN ban char */ 0, /* SJOIN except char */ - UMODE_S, /* Services Client mode */ - 0, /* not p10 */ + 0, /* Can remove User Channel Modes with SVSMODE */ }, {NULL} }; @@ -1458,6 +1457,14 @@ void anope_cmd_unban(char *name, char *nick) /* Not Supported by this IRCD */ } +/* SVSMODE channel modes */ + +void anope_cmd_svsmode_chan(char *name, char *mode, char *nick) +{ + /* Not Supported by this IRCD */ +} + + /* SVSMODE +d */ /* sent if svid is something weird */ void anope_cmd_svid_umode(char *nick, time_t ts) diff --git a/src/unreal32.c b/src/unreal32.c index 8ecf6824a..59e275009 100644 --- a/src/unreal32.c +++ b/src/unreal32.c @@ -102,8 +102,7 @@ IRCDVar ircd[] = { 0, /* +I support */ '&', /* SJOIN ban char */ '\"', /* SJOIN except char */ - UMODE_S, /* Services Client mode */ - 0, /* not p10 */ + 1, /* Can remove User Channel Modes with SVSMODE */ }, {NULL} }; @@ -430,22 +429,12 @@ void anope_set_umode(User * user, int ac, char **av) case 'o': if (add) { opcnt++; - - /* No need to display news to a services client */ - if (user->mode & ircd->servicesmode) { - if (WallOper) { - anope_cmd_global(s_OperServ, - "\2%s\2 is now a Network Service.", - user->nick); - } - } else { - if (WallOper) { - anope_cmd_global(s_OperServ, - "\2%s\2 is now an IRC operator.", - user->nick); - } - display_news(user, NEWS_OPER); + if (WallOper) { + anope_cmd_global(s_OperServ, + "\2%s\2 is now an IRC operator.", + user->nick); } + display_news(user, NEWS_OPER); } else { opcnt--; } @@ -1087,11 +1076,11 @@ void anope_cmd_pong(char *servname, char *who) } /* JOIN */ -/* Althought Unreal 3.2 does not need the timestamp others do so - we get it in the common function call */ void anope_cmd_join(char *user, char *channel, time_t chantime) { - send_cmd(user, "%s %s", send_token("JOIN", "C"), channel); + send_cmd(ServerName, "SJOIN !%s %s :%s", + base64enc((long int) chantime), channel, user); + /* send_cmd(user, "%s %s", send_token("JOIN", "C"), channel); */ } /* unsqline @@ -1948,10 +1937,24 @@ void anope_cmd_sgline(char *mask, char *reason) /* SVSMODE -b */ void anope_cmd_unban(char *name, char *nick) { - send_cmd(ServerName, "%s %s -b %s", send_token("SVSMODE", "n"), name, - nick); + anope_cmd_svsmode_chan(name, "-b", nick); } + +/* SVSMODE channel modes */ + +void anope_cmd_svsmode_chan(char *name, char *mode, char *nick) +{ + if (nick) { + send_cmd(ServerName, "%s %s %s %s", send_token("SVSMODE", "n"), + name, mode, nick); + } else { + send_cmd(ServerName, "%s %s %s", send_token("SVSMODE", "n"), name, + mode); + } +} + + /* SVSMODE +d */ /* sent if svid is something weird */ void anope_cmd_svid_umode(char *nick, time_t ts) diff --git a/src/users.c b/src/users.c index 5cb355e8f..aef4d9068 100644 --- a/src/users.c +++ b/src/users.c @@ -188,19 +188,20 @@ void change_user_username(User * user, const char *username) /*************************************************************************/ - -/*************************************************************************/ - /* Remove and free a User structure. */ void delete_user(User * user) { struct u_chanlist *c, *c2; struct u_chaninfolist *ci, *ci2; - char *realname; + char *realname = NULL; if (LogUsers) { - realname = normalizeBuffer(user->realname); + if (user->realname) { + realname = normalizeBuffer(user->realname); + } else { + realname = " "; + } if (ircd->vhost) { alog("LOGUSERS: %s (%s@%s => %s) (%s) left the network (%s).", user->nick, user->username, user->host, diff --git a/src/viagra.c b/src/viagra.c index 0db75dc0d..df12451f0 100644 --- a/src/viagra.c +++ b/src/viagra.c @@ -100,8 +100,7 @@ IRCDVar ircd[] = { 0, /* +I support */ 0, /* SJOIN ban char */ 0, /* SJOIN except char */ - UMODE_S, /* Services Client mode */ - 0, /* not p10 */ + 0, /* Can remove User Channel Modes with SVSMODE */ } , {NULL} @@ -1558,9 +1557,21 @@ void anope_cmd_svso(char *source, char *nick, char *flag) } +/* SVSMODE -b */ void anope_cmd_unban(char *name, char *nick) { - /* Not Supported by this IRCD */ + anope_cmd_svsmode_chan(name, "-b", nick); +} + +/* SVSMODE channel modes */ + +void anope_cmd_svsmode_chan(char *name, char *mode, char *nick) +{ + if (nick) { + send_cmd(ServerName, "SVSMODE %s %s %s", name, mode, nick); + } else { + send_cmd(ServerName, "SVSMODE %s %s", name, mode); + } } /* SVSMODE +d */ diff --git a/version.log b/version.log index ad4f46192..284374477 100644 --- a/version.log +++ b/version.log @@ -8,10 +8,23 @@ VERSION_MAJOR="1" VERSION_MINOR="7" VERSION_PATCH="6" -VERSION_BUILD="477" +VERSION_BUILD="478" # $Log$ # +# BUILD : 1.7.6 (478) +# BUGS : N/A +# NOTES : 1. CS CLEAR strips +q/+a +# 2. CS CLEAR uses SVSMODE with Unreal to strip +q/a/o/h/v +# 3. SVSMODE unban works again on Viagra +# 4. Adds anope_cmd_svsmode_chan() to for SVSMODE on channels +# 5. OS CLEARMODES uses SVSMODE with Unreal to strip +q/a/o/h/v +# 6. memory.c, servers.c, slist.c, sockutil.c, misc. is doxygen ready +# 7. Unreal32 pseduo clients use SJOIN now to join the channels +# 8. clean out the process() buffers before we start to use them, maybe less garbage in them when we do bts +# 9. Few memory cleans up in hostserv do_setall() +# 10. Tons of clean up, only a handful left when you make strict +# # BUILD : 1.7.6 (477) # BUGS : N/A # NOTES : list.c and mail.c are doxygen ready now |