diff options
Diffstat (limited to 'src')
199 files changed, 43387 insertions, 43387 deletions
diff --git a/src/actions.c b/src/actions.c index 2a4a9a1de..c455dfa61 100644 --- a/src/actions.c +++ b/src/actions.c @@ -24,20 +24,20 @@ */ void bad_password(User * u) { - time_t now = time(NULL); - - if (!u || !BadPassLimit) { - return; - } - - if (BadPassTimeout > 0 && u->invalid_pw_time > 0 - && u->invalid_pw_time < now - BadPassTimeout) - u->invalid_pw_count = 0; - u->invalid_pw_count++; - u->invalid_pw_time = now; - if (u->invalid_pw_count >= BadPassLimit) { - kill_user(NULL, u->nick, "Too many invalid passwords"); - } + time_t now = time(NULL); + + if (!u || !BadPassLimit) { + return; + } + + if (BadPassTimeout > 0 && u->invalid_pw_time > 0 + && u->invalid_pw_time < now - BadPassTimeout) + u->invalid_pw_count = 0; + u->invalid_pw_count++; + u->invalid_pw_time = now; + if (u->invalid_pw_count >= BadPassLimit) { + kill_user(NULL, u->nick, "Too many invalid passwords"); + } } /*************************************************************************/ @@ -51,25 +51,25 @@ void bad_password(User * u) */ void kill_user(const char *source, const char *user, const char *reason) { - char buf[BUFSIZE]; + char buf[BUFSIZE]; - if (!user || !*user) { - return; - } - if (!source || !*source) { - source = ServerName; - } - if (!reason) { - reason = ""; - } + if (!user || !*user) { + return; + } + if (!source || !*source) { + source = ServerName; + } + if (!reason) { + reason = ""; + } - snprintf(buf, sizeof(buf), "%s (%s)", source, reason); + snprintf(buf, sizeof(buf), "%s (%s)", source, reason); - ircdproto->SendSVSKill(source, user, buf); + ircdproto->SendSVSKill(source, user, buf); - if (!ircd->quitonkill && finduser(user)) { - do_kill(user, buf); - } + if (!ircd->quitonkill && finduser(user)) { + do_kill(user, buf); + } } /*************************************************************************/ @@ -82,42 +82,42 @@ void kill_user(const char *source, const char *user, const char *reason) */ void sqline(char *mask, char *reason) { - int i; - Channel *c, *next; - const char *av[3]; - struct c_userlist *cu, *cunext; - - if (ircd->chansqline) { - if (*mask == '#') { - ircdproto->SendSQLine(mask, reason); - - for (i = 0; i < 1024; i++) { - for (c = chanlist[i]; c; c = next) { - next = c->next; - - if (!match_wild_nocase(mask, c->name)) { - continue; - } - for (cu = c->users; cu; cu = cunext) { - cunext = cu->next; - if (is_oper(cu->user)) { - continue; - } - av[0] = c->name; - av[1] = cu->user->nick; - av[2] = reason; - ircdproto->SendKick(findbot(s_OperServ), av[0], av[1], - "Q-Lined: %s", av[2]); - do_kick(s_ChanServ, 3, av); - } - } - } - } else { - ircdproto->SendSQLine(mask, reason); - } - } else { - ircdproto->SendSQLine(mask, reason); - } + int i; + Channel *c, *next; + const char *av[3]; + struct c_userlist *cu, *cunext; + + if (ircd->chansqline) { + if (*mask == '#') { + ircdproto->SendSQLine(mask, reason); + + for (i = 0; i < 1024; i++) { + for (c = chanlist[i]; c; c = next) { + next = c->next; + + if (!match_wild_nocase(mask, c->name)) { + continue; + } + for (cu = c->users; cu; cu = cunext) { + cunext = cu->next; + if (is_oper(cu->user)) { + continue; + } + av[0] = c->name; + av[1] = cu->user->nick; + av[2] = reason; + ircdproto->SendKick(findbot(s_OperServ), av[0], av[1], + "Q-Lined: %s", av[2]); + do_kick(s_ChanServ, 3, av); + } + } + } + } else { + ircdproto->SendSQLine(mask, reason); + } + } else { + ircdproto->SendSQLine(mask, reason); + } } /*************************************************************************/ @@ -130,72 +130,72 @@ void sqline(char *mask, char *reason) */ void common_unban(ChannelInfo * ci, char *nick) { - const char *av[4]; - char *host = NULL; - char buf[BUFSIZE]; - int ac; - uint32 ip = 0; - User *u; - Entry *ban, *next; - - if (!ci || !ci->c || !nick) { - return; - } - - if (!(u = finduser(nick))) { - return; - } - - if (!ci->c->bans || (ci->c->bans->count == 0)) - return; - - if (u->hostip == NULL) { - host = host_resolve(u->host); - /* we store the just resolved hostname so we don't - * need to do this again */ - if (host) { - u->hostip = sstrdup(host); - } - } else { - host = sstrdup(u->hostip); - } - /* Convert the host to an IP.. */ - if (host) - ip = str_is_ip(host); - - if (ircd->svsmode_unban) { - ircdproto->SendBanDel(ci->name, nick); - } else { - if (ircdcap->tsmode) { - snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); - av[0] = ci->name; - av[1] = buf; - av[2] = "-b"; - ac = 4; - } else { - av[0] = ci->name; - av[1] = "-b"; - ac = 3; - } - - for (ban = ci->c->bans->entries; ban; ban = next) { - next = ban->next; - if (entry_match(ban, u->nick, u->username, u->host, ip) || - entry_match(ban, u->nick, u->username, u->vhost, ip)) { - ircdproto->SendMode(whosends(ci), ci->name, "-b %s", ban->mask); - if (ircdcap->tsmode) - av[3] = ban->mask; - else - av[2] = ban->mask; - - do_cmode(whosends(ci)->nick, ac, av); - } - } - } - /* host_resolve() sstrdup us this info so we gotta free it */ - if (host) { - free(host); - } + const char *av[4]; + char *host = NULL; + char buf[BUFSIZE]; + int ac; + uint32 ip = 0; + User *u; + Entry *ban, *next; + + if (!ci || !ci->c || !nick) { + return; + } + + if (!(u = finduser(nick))) { + return; + } + + if (!ci->c->bans || (ci->c->bans->count == 0)) + return; + + if (u->hostip == NULL) { + host = host_resolve(u->host); + /* we store the just resolved hostname so we don't + * need to do this again */ + if (host) { + u->hostip = sstrdup(host); + } + } else { + host = sstrdup(u->hostip); + } + /* Convert the host to an IP.. */ + if (host) + ip = str_is_ip(host); + + if (ircd->svsmode_unban) { + ircdproto->SendBanDel(ci->name, nick); + } else { + if (ircdcap->tsmode) { + snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); + av[0] = ci->name; + av[1] = buf; + av[2] = "-b"; + ac = 4; + } else { + av[0] = ci->name; + av[1] = "-b"; + ac = 3; + } + + for (ban = ci->c->bans->entries; ban; ban = next) { + next = ban->next; + if (entry_match(ban, u->nick, u->username, u->host, ip) || + entry_match(ban, u->nick, u->username, u->vhost, ip)) { + ircdproto->SendMode(whosends(ci), ci->name, "-b %s", ban->mask); + if (ircdcap->tsmode) + av[3] = ban->mask; + else + av[2] = ban->mask; + + do_cmode(whosends(ci)->nick, ac, av); + } + } + } + /* host_resolve() sstrdup us this info so we gotta free it */ + if (host) { + free(host); + } } /*************************************************************************/ @@ -209,17 +209,17 @@ void common_unban(ChannelInfo * ci, char *nick) */ void common_svsmode(User * u, const char *modes, const char *arg) { - int ac = 1; - const char *av[2]; + int ac = 1; + const char *av[2]; - av[0] = modes; - if (arg) { - av[1] = arg; - ac++; - } + av[0] = modes; + if (arg) { + av[1] = arg; + ac++; + } - ircdproto->SendSVSMode(u, ac, av); - ircdproto->ProcessUsermodes(u, ac, av); + ircdproto->SendSVSMode(u, ac, av); + ircdproto->ProcessUsermodes(u, ac, av); } /*************************************************************************/ @@ -232,15 +232,15 @@ void common_svsmode(User * u, const char *modes, const char *arg) */ char *common_get_vhost(User * u) { - if (!u) - return NULL; - - if (ircd->vhostmode && (u->mode & ircd->vhostmode)) - return u->vhost; - else if (ircd->vhost && u->vhost) - return u->vhost; - else - return u->host; + if (!u) + return NULL; + + if (ircd->vhostmode && (u->mode & ircd->vhostmode)) + return u->vhost; + else if (ircd->vhost && u->vhost) + return u->vhost; + else + return u->host; } /*************************************************************************/ @@ -253,13 +253,13 @@ char *common_get_vhost(User * u) */ char *common_get_vident(User * u) { - if (!u) - return NULL; - - if (ircd->vhostmode && (u->mode & ircd->vhostmode)) - return u->vident; - else if (ircd->vident && u->vident) - return u->vident; - else - return u->username; + if (!u) + return NULL; + + if (ircd->vhostmode && (u->mode & ircd->vhostmode)) + return u->vident; + else if (ircd->vident && u->vident) + return u->vident; + else + return u->username; } diff --git a/src/base64.c b/src/base64.c index af3378cf4..5a11b9237 100644 --- a/src/base64.c +++ b/src/base64.c @@ -22,22 +22,22 @@ static long base64_to_int(char *); const char* base64enc(long i) { - if (i < 0) - return ("0"); - return int_to_base64(i); + if (i < 0) + return ("0"); + return int_to_base64(i); } long base64dec(char* b64) { - if (b64) - return base64_to_int(b64); - else - return 0; + if (b64) + return base64_to_int(b64); + else + return 0; } static const char Base64[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static const char Pad64 = '='; /* (From RFC1521 and draft-ietf-dnssec-secext-03.txt) @@ -59,26 +59,26 @@ static const char Pad64 = '='; characters. The character referenced by the index is placed in the output string. - Table 1: The Base64 Alphabet - - Value Encoding Value Encoding Value Encoding Value Encoding - 0 A 17 R 34 i 51 z - 1 B 18 S 35 j 52 0 - 2 C 19 T 36 k 53 1 - 3 D 20 U 37 l 54 2 - 4 E 21 V 38 m 55 3 - 5 F 22 W 39 n 56 4 - 6 G 23 X 40 o 57 5 - 7 H 24 Y 41 p 58 6 - 8 I 25 Z 42 q 59 7 - 9 J 26 a 43 r 60 8 - 10 K 27 b 44 s 61 9 - 11 L 28 c 45 t 62 + - 12 M 29 d 46 u 63 / - 13 N 30 e 47 v - 14 O 31 f 48 w (pad) = - 15 P 32 g 49 x - 16 Q 33 h 50 y + Table 1: The Base64 Alphabet + + Value Encoding Value Encoding Value Encoding Value Encoding + 0 A 17 R 34 i 51 z + 1 B 18 S 35 j 52 0 + 2 C 19 T 36 k 53 1 + 3 D 20 U 37 l 54 2 + 4 E 21 V 38 m 55 3 + 5 F 22 W 39 n 56 4 + 6 G 23 X 40 o 57 5 + 7 H 24 Y 41 p 58 6 + 8 I 25 Z 42 q 59 7 + 9 J 26 a 43 r 60 8 + 10 K 27 b 44 s 61 9 + 11 L 28 c 45 t 62 + + 12 M 29 d 46 u 63 / + 13 N 30 e 47 v + 14 O 31 f 48 w (pad) = + 15 P 32 g 49 x + 16 Q 33 h 50 y Special processing is performed if fewer than 24 bits are available at the end of the data being encoded. A full encoding quantum is @@ -88,72 +88,72 @@ static const char Pad64 = '='; end of the data is performed using the '=' character. Since all base64 input is an integral number of octets, only the - ------------------------------------------------- + ------------------------------------------------- following cases can arise: - (1) the final quantum of encoding input is an integral - multiple of 24 bits; here, the final unit of encoded + (1) the final quantum of encoding input is an integral + multiple of 24 bits; here, the final unit of encoded output will be an integral multiple of 4 characters with no "=" padding, - (2) the final quantum of encoding input is exactly 8 bits; - here, the final unit of encoded output will be two + (2) the final quantum of encoding input is exactly 8 bits; + here, the final unit of encoded output will be two characters followed by two "=" padding characters, or - (3) the final quantum of encoding input is exactly 16 bits; - here, the final unit of encoded output will be three + (3) the final quantum of encoding input is exactly 16 bits; + here, the final unit of encoded output will be three characters followed by one "=" padding character. */ int b64_encode(char *src, size_t srclength, char *target, size_t targsize) { - size_t datalength = 0; - unsigned char input[3]; - unsigned char output[4]; - size_t i; - - while (2 < srclength) { - input[0] = *src++; - input[1] = *src++; - input[2] = *src++; - srclength -= 3; - - output[0] = input[0] >> 2; - output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); - output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); - output[3] = input[2] & 0x3f; - - if (datalength + 4 > targsize) - return (-1); - target[datalength++] = Base64[output[0]]; - target[datalength++] = Base64[output[1]]; - target[datalength++] = Base64[output[2]]; - target[datalength++] = Base64[output[3]]; - } - - /* Now we worry about padding. */ - if (0 != srclength) { - /* Get what's left. */ - input[0] = input[1] = input[2] = '\0'; - for (i = 0; i < srclength; i++) - input[i] = *src++; - - output[0] = input[0] >> 2; - output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); - output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); - - if (datalength + 4 > targsize) - return (-1); - target[datalength++] = Base64[output[0]]; - target[datalength++] = Base64[output[1]]; - if (srclength == 1) - target[datalength++] = Pad64; - else - target[datalength++] = Base64[output[2]]; - target[datalength++] = Pad64; - } - if (datalength >= targsize) - return (-1); - target[datalength] = '\0'; /* Returned value doesn't count \0. */ - return (datalength); + size_t datalength = 0; + unsigned char input[3]; + unsigned char output[4]; + size_t i; + + while (2 < srclength) { + input[0] = *src++; + input[1] = *src++; + input[2] = *src++; + srclength -= 3; + + output[0] = input[0] >> 2; + output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); + output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); + output[3] = input[2] & 0x3f; + + if (datalength + 4 > targsize) + return (-1); + target[datalength++] = Base64[output[0]]; + target[datalength++] = Base64[output[1]]; + target[datalength++] = Base64[output[2]]; + target[datalength++] = Base64[output[3]]; + } + + /* Now we worry about padding. */ + if (0 != srclength) { + /* Get what's left. */ + input[0] = input[1] = input[2] = '\0'; + for (i = 0; i < srclength; i++) + input[i] = *src++; + + output[0] = input[0] >> 2; + output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); + output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); + + if (datalength + 4 > targsize) + return (-1); + target[datalength++] = Base64[output[0]]; + target[datalength++] = Base64[output[1]]; + if (srclength == 1) + target[datalength++] = Pad64; + else + target[datalength++] = Base64[output[2]]; + target[datalength++] = Pad64; + } + if (datalength >= targsize) + return (-1); + target[datalength] = '\0'; /* Returned value doesn't count \0. */ + return (datalength); } /* skips all whitespace anywhere. @@ -164,247 +164,247 @@ int b64_encode(char *src, size_t srclength, char *target, size_t targsize) int b64_decode(const char *src, char *target, size_t targsize) { - int tarindex, state, ch; - char *pos; - - state = 0; - tarindex = 0; - - while ((ch = *src++) != '\0') { - if (isspace(ch)) /* Skip whitespace anywhere. */ - continue; - - if (ch == Pad64) - break; - - pos = strchr(Base64, ch); - if (pos == 0) /* A non-base64 character. */ - return (-1); - - switch (state) { - case 0: - if (target) { - if ((size_t) tarindex >= targsize) - return (-1); - target[tarindex] = (pos - Base64) << 2; - } - state = 1; - break; - case 1: - if (target) { - if ((size_t) tarindex + 1 >= targsize) - return (-1); - target[tarindex] |= (pos - Base64) >> 4; - target[tarindex + 1] = ((pos - Base64) & 0x0f) - << 4; - } - tarindex++; - state = 2; - break; - case 2: - if (target) { - if ((size_t) tarindex + 1 >= targsize) - return (-1); - target[tarindex] |= (pos - Base64) >> 2; - target[tarindex + 1] = ((pos - Base64) & 0x03) - << 6; - } - tarindex++; - state = 3; - break; - case 3: - if (target) { - if ((size_t) tarindex >= targsize) - return (-1); - target[tarindex] |= (pos - Base64); - } - tarindex++; - state = 0; - break; - default: - abort(); - } - } - - /* - * We are done decoding Base-64 chars. Let's see if we ended - * on a byte boundary, and/or with erroneous trailing characters. - */ - - if (ch == Pad64) { /* We got a pad char. */ - ch = *src++; /* Skip it, get next. */ - switch (state) { - case 0: /* Invalid = in first position */ - case 1: /* Invalid = in second position */ - return (-1); - - case 2: /* Valid, means one byte of info */ - /* Skip any number of spaces. */ - for ((void) NULL; ch != '\0'; ch = *src++) - if (!isspace(ch)) - break; - /* Make sure there is another trailing = sign. */ - if (ch != Pad64) - return (-1); - ch = *src++; /* Skip the = */ - /* Fall through to "single trailing =" case. */ - /* FALLTHROUGH */ - - case 3: /* Valid, means two bytes of info */ - /* - * We know this char is an =. Is there anything but - * whitespace after it? - */ - for ((void) NULL; ch != '\0'; ch = *src++) - if (!isspace(ch)) - return (-1); - - /* - * Now make sure for cases 2 and 3 that the "extra" - * bits that slopped past the last full byte were - * zeros. If we don't check them, they become a - * subliminal channel. - */ - if (target && target[tarindex] != 0) - return (-1); - } - } else { - /* - * We ended by seeing the end of the string. Make sure we - * have no partial bytes lying around. - */ - if (state != 0) - return (-1); - } - - return (tarindex); + int tarindex, state, ch; + char *pos; + + state = 0; + tarindex = 0; + + while ((ch = *src++) != '\0') { + if (isspace(ch)) /* Skip whitespace anywhere. */ + continue; + + if (ch == Pad64) + break; + + pos = strchr(Base64, ch); + if (pos == 0) /* A non-base64 character. */ + return (-1); + + switch (state) { + case 0: + if (target) { + if ((size_t) tarindex >= targsize) + return (-1); + target[tarindex] = (pos - Base64) << 2; + } + state = 1; + break; + case 1: + if (target) { + if ((size_t) tarindex + 1 >= targsize) + return (-1); + target[tarindex] |= (pos - Base64) >> 4; + target[tarindex + 1] = ((pos - Base64) & 0x0f) + << 4; + } + tarindex++; + state = 2; + break; + case 2: + if (target) { + if ((size_t) tarindex + 1 >= targsize) + return (-1); + target[tarindex] |= (pos - Base64) >> 2; + target[tarindex + 1] = ((pos - Base64) & 0x03) + << 6; + } + tarindex++; + state = 3; + break; + case 3: + if (target) { + if ((size_t) tarindex >= targsize) + return (-1); + target[tarindex] |= (pos - Base64); + } + tarindex++; + state = 0; + break; + default: + abort(); + } + } + + /* + * We are done decoding Base-64 chars. Let's see if we ended + * on a byte boundary, and/or with erroneous trailing characters. + */ + + if (ch == Pad64) { /* We got a pad char. */ + ch = *src++; /* Skip it, get next. */ + switch (state) { + case 0: /* Invalid = in first position */ + case 1: /* Invalid = in second position */ + return (-1); + + case 2: /* Valid, means one byte of info */ + /* Skip any number of spaces. */ + for ((void) NULL; ch != '\0'; ch = *src++) + if (!isspace(ch)) + break; + /* Make sure there is another trailing = sign. */ + if (ch != Pad64) + return (-1); + ch = *src++; /* Skip the = */ + /* Fall through to "single trailing =" case. */ + /* FALLTHROUGH */ + + case 3: /* Valid, means two bytes of info */ + /* + * We know this char is an =. Is there anything but + * whitespace after it? + */ + for ((void) NULL; ch != '\0'; ch = *src++) + if (!isspace(ch)) + return (-1); + + /* + * Now make sure for cases 2 and 3 that the "extra" + * bits that slopped past the last full byte were + * zeros. If we don't check them, they become a + * subliminal channel. + */ + if (target && target[tarindex] != 0) + return (-1); + } + } else { + /* + * We ended by seeing the end of the string. Make sure we + * have no partial bytes lying around. + */ + if (state != 0) + return (-1); + } + + return (tarindex); } const char* encode_ip(unsigned char *ip) { - static char buf[25]; - unsigned char *cp; - struct in_addr ia; /* For IPv4 */ - char *s_ip; /* Signed ip string */ - - if (!ip) - return "*"; - - if (strchr((char *) ip, ':')) { - return NULL; - } else { - s_ip = str_signed(ip); - ia.s_addr = inet_addr(s_ip); - cp = (unsigned char *) ia.s_addr; - b64_encode((char *) &cp, sizeof(struct in_addr), buf, 25); - } - return buf; + static char buf[25]; + unsigned char *cp; + struct in_addr ia; /* For IPv4 */ + char *s_ip; /* Signed ip string */ + + if (!ip) + return "*"; + + if (strchr((char *) ip, ':')) { + return NULL; + } else { + s_ip = str_signed(ip); + ia.s_addr = inet_addr(s_ip); + cp = (unsigned char *) ia.s_addr; + b64_encode((char *) &cp, sizeof(struct in_addr), buf, 25); + } + return buf; } int decode_ip(const char *buf) { - int len = strlen(buf); - char targ[25]; - struct in_addr ia; - - b64_decode(buf, targ, 25); - ia = *(struct in_addr *) targ; - if (len == 24) { /* IPv6 */ - return 0; - } else if (len == 8) /* IPv4 */ - return ia.s_addr; - else /* Error?? */ - return 0; + int len = strlen(buf); + char targ[25]; + struct in_addr ia; + + b64_decode(buf, targ, 25); + ia = *(struct in_addr *) targ; + if (len == 24) { /* IPv6 */ + return 0; + } else if (len == 8) /* IPv4 */ + return ia.s_addr; + else /* Error?? */ + return 0; } /* ':' and '#' and '&' and '+' and '@' must never be in this table. */ /* these tables must NEVER CHANGE! >) */ char int6_to_base64_map[] = { - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', - 'E', 'F', - 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', - 'U', 'V', - 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', - 'k', 'l', - 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', - '{', '}' + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', + 'E', 'F', + 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', + 'U', 'V', + 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', + 'k', 'l', + 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + '{', '}' }; char base64_to_int6_map[] = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, - -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, - -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, -1, 63, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, + -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, + -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, -1, 63, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; static char *int_to_base64(long val) { - /* 32/6 == max 6 bytes for representation, - * +1 for the null, +1 for byte boundaries - */ - static char base64buf[8]; - long i = 7; - - base64buf[i] = '\0'; - - /* Temporary debugging code.. remove before 2038 ;p. - * This might happen in case of 64bit longs (opteron/ia64), - * if the value is then too large it can easily lead to - * a buffer underflow and thus to a crash. -- Syzop - */ - if (val > 2147483647L) { - abort(); - } - - do { - base64buf[--i] = int6_to_base64_map[val & 63]; - } - while (val >>= 6); - - return base64buf + i; + /* 32/6 == max 6 bytes for representation, + * +1 for the null, +1 for byte boundaries + */ + static char base64buf[8]; + long i = 7; + + base64buf[i] = '\0'; + + /* Temporary debugging code.. remove before 2038 ;p. + * This might happen in case of 64bit longs (opteron/ia64), + * if the value is then too large it can easily lead to + * a buffer underflow and thus to a crash. -- Syzop + */ + if (val > 2147483647L) { + abort(); + } + + do { + base64buf[--i] = int6_to_base64_map[val & 63]; + } + while (val >>= 6); + + return base64buf + i; } static long base64_to_int(char *b64) { - int v = base64_to_int6_map[(unsigned char) *b64++]; + int v = base64_to_int6_map[(unsigned char) *b64++]; - if (!b64) - return 0; + if (!b64) + return 0; - while (*b64) { - v <<= 6; - v += base64_to_int6_map[(unsigned char) *b64++]; - } + while (*b64) { + v <<= 6; + v += base64_to_int6_map[(unsigned char) *b64++]; + } - return v; + return v; } long base64dects(const char *ts) { - char *token; - long value; - - if (!ts) { - return 0; - } - token = myStrGetToken(ts, '!', 1); - - if (!token) { - return strtoul(ts, NULL, 10); - } - value = base64dec(token); - Anope_Free(token); - return value; + char *token; + long value; + + if (!ts) { + return 0; + } + token = myStrGetToken(ts, '!', 1); + + if (!token) { + return strtoul(ts, NULL, 10); + } + value = base64dec(token); + Anope_Free(token); + return value; } diff --git a/src/bots.cpp b/src/bots.cpp index 98c903ebe..a86f37076 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -34,27 +34,27 @@ BotInfo::BotInfo(const char *nnick, const char *nuser, const char *nhost, const BotInfo::~BotInfo() { - int i; - ChannelInfo *ci; - - for (i = 0; i < 256; i++) - for (ci = chanlists[i]; ci; ci = ci->next) - if (ci->bi == this) - ci->bi = NULL; - - if (this->next) - this->next->prev = this->prev; - if (this->prev) - this->prev->next = this->next; - else - botlists[tolower(*this->nick)] = this->next; - - nbots--; - - free(this->nick); - free(this->user); - free(this->host); - free(this->real); + int i; + ChannelInfo *ci; + + for (i = 0; i < 256; i++) + for (ci = chanlists[i]; ci; ci = ci->next) + if (ci->bi == this) + ci->bi = NULL; + + if (this->next) + this->next->prev = this->prev; + if (this->prev) + this->prev->next = this->next; + else + botlists[tolower(*this->nick)] = this->next; + + nbots--; + + free(this->nick); + free(this->user); + free(this->host); + free(this->real); } diff --git a/src/botserv.c b/src/botserv.c index 13d483114..62b19fb1a 100644 --- a/src/botserv.c +++ b/src/botserv.c @@ -19,7 +19,7 @@ /*************************************************************************/ -BotInfo *botlists[256]; /* Hash list of bots */ +BotInfo *botlists[256]; /* Hash list of bots */ int nbots = 0; /*************************************************************************/ @@ -34,7 +34,7 @@ E void moduleAddBotServCmds(void); /*************************************************************************/ /* *INDENT-OFF* */ void moduleAddBotServCmds(void) { - ModuleManager::LoadModuleList(BotServCoreNumber, BotServCoreModules); + ModuleManager::LoadModuleList(BotServCoreNumber, BotServCoreModules); } /* *INDENT-ON* */ /*************************************************************************/ @@ -44,23 +44,23 @@ void moduleAddBotServCmds(void) { void get_botserv_stats(long *nrec, long *memuse) { - long count = 0, mem = 0; - int i; - BotInfo *bi; - - for (i = 0; i < 256; i++) { - for (bi = botlists[i]; bi; bi = bi->next) { - count++; - mem += sizeof(*bi); - mem += strlen(bi->nick) + 1; - mem += strlen(bi->user) + 1; - mem += strlen(bi->host) + 1; - mem += strlen(bi->real) + 1; - } - } - - *nrec = count; - *memuse = mem; + long count = 0, mem = 0; + int i; + BotInfo *bi; + + for (i = 0; i < 256; i++) { + for (bi = botlists[i]; bi; bi = bi->next) { + count++; + mem += sizeof(*bi); + mem += strlen(bi->nick) + 1; + mem += strlen(bi->user) + 1; + mem += strlen(bi->host) + 1; + mem += strlen(bi->real) + 1; + } + } + + *nrec = count; + *memuse = mem; } /*************************************************************************/ @@ -70,9 +70,9 @@ void get_botserv_stats(long *nrec, long *memuse) void bs_init(void) { - if (s_BotServ) { - moduleAddBotServCmds(); - } + if (s_BotServ) { + moduleAddBotServCmds(); + } } /*************************************************************************/ @@ -81,20 +81,20 @@ void bs_init(void) void botserv(User * u, char *buf) { - char *cmd, *s; + char *cmd, *s; - cmd = strtok(buf, " "); + cmd = strtok(buf, " "); - if (!cmd) { - return; - } else if (stricmp(cmd, "\1PING") == 0) { - if (!(s = strtok(NULL, ""))) { - *s = 0; - } - ircdproto->SendCTCP(findbot(s_BotServ), u->nick, "PING %s", s); - } else { - mod_run_cmd(s_BotServ, u, BOTSERV, cmd); - } + if (!cmd) { + return; + } else if (stricmp(cmd, "\1PING") == 0) { + if (!(s = strtok(NULL, ""))) { + *s = 0; + } + ircdproto->SendCTCP(findbot(s_BotServ), u->nick, "PING %s", s); + } else { + mod_run_cmd(s_BotServ, u, BOTSERV, cmd); + } } @@ -104,18 +104,18 @@ void botserv(User * u, char *buf) void botmsgs(User * u, BotInfo * bi, char *buf) { - char *cmd = strtok(buf, " "); - char *s; - - if (!cmd || !u) - return; - - if (!stricmp(cmd, "\1PING")) { - if (!(s = strtok(NULL, ""))) { - *s = 0; - } - ircdproto->SendCTCP(bi, u->nick, "PING %s", s); - } + char *cmd = strtok(buf, " "); + char *s; + + if (!cmd || !u) + return; + + if (!stricmp(cmd, "\1PING")) { + if (!(s = strtok(NULL, ""))) { + *s = 0; + } + ircdproto->SendCTCP(bi, u->nick, "PING %s", s); + } } /*************************************************************************/ @@ -127,305 +127,305 @@ void botmsgs(User * u, BotInfo * bi, char *buf) void botchanmsgs(User * u, ChannelInfo * ci, char *buf) { - int c; - int16 cstatus = 0; - char *cmd; - UserData *ud; - - if (!u || !buf || !ci) { - return; - } - - /* Answer to ping if needed, without breaking the buffer. */ - if (!strnicmp(buf, "\1PING", 5)) { - ircdproto->SendCTCP(ci->bi, u->nick, "PING %s", buf); - } - - /* If it's a /me, cut the CTCP part at the beginning (not - * at the end, because one character just doesn't matter, - * but the ACTION may create strange behaviours with the - * caps or badwords kickers */ - if (!strnicmp(buf, "\1ACTION ", 8)) - buf += 8; - - /* Now we can make kicker stuff. We try to order the checks - * from the fastest one to the slowest one, since there's - * no need to process other kickers if an user is kicked before - * the last kicker check. - * - * But FIRST we check whether the user is protected in any - * way. - */ - - /* We first retrieve the user status on the channel if needed */ - if (ci->botflags & (BS_DONTKICKOPS | BS_DONTKICKVOICES)) - cstatus = chan_get_user_status(ci->c, u); - - if (buf && !check_access(u, ci, CA_NOKICK) && - (!(ci->botflags & BS_DONTKICKOPS) - || !(cstatus & (CUS_HALFOP | CUS_OP | CUS_OWNER | CUS_PROTECT))) - - && (!(ci->botflags & BS_DONTKICKVOICES) || !(cstatus & CUS_VOICE))) { - /* Bolds kicker */ - if ((ci->botflags & BS_KICK_BOLDS) && strchr(buf, 2)) { - check_ban(ci, u, TTB_BOLDS); - bot_kick(ci, u, BOT_REASON_BOLD); - return; - } - - /* Color kicker */ - if ((ci->botflags & BS_KICK_COLORS) && strchr(buf, 3)) { - check_ban(ci, u, TTB_COLORS); - bot_kick(ci, u, BOT_REASON_COLOR); - return; - } - - /* Reverses kicker */ - if ((ci->botflags & BS_KICK_REVERSES) && strchr(buf, 22)) { - check_ban(ci, u, TTB_REVERSES); - bot_kick(ci, u, BOT_REASON_REVERSE); - return; - } - - /* Underlines kicker */ - if ((ci->botflags & BS_KICK_UNDERLINES) && strchr(buf, 31)) { - check_ban(ci, u, TTB_UNDERLINES); - bot_kick(ci, u, BOT_REASON_UNDERLINE); - return; - } - - /* Caps kicker */ - if ((ci->botflags & BS_KICK_CAPS) - && ((c = strlen(buf)) >= ci->capsmin)) { - int i = 0; - int l = 0; - char *s = buf; - - do { - if (isupper(*s)) - i++; - else if (islower(*s)) - l++; - } while (*s++); - - /* i counts uppercase chars, l counts lowercase chars. Only - * alphabetic chars (so islower || isupper) qualify for the - * percentage of caps to kick for; the rest is ignored. -GD - */ - - if (i >= ci->capsmin && i * 100 / (i + l) >= ci->capspercent) { - check_ban(ci, u, TTB_CAPS); - bot_kick(ci, u, BOT_REASON_CAPS); - return; - } - } - - /* Bad words kicker */ - if (ci->botflags & BS_KICK_BADWORDS) { - int i; - int mustkick = 0; - char *nbuf; - BadWord *bw; - - /* Normalize the buffer */ - nbuf = normalizeBuffer(buf); - - for (i = 0, bw = ci->badwords; i < ci->bwcount; i++, bw++) { - if (!bw->in_use) - continue; - - if (bw->type == BW_ANY - && ((BSCaseSensitive && strstr(nbuf, bw->word)) - || (!BSCaseSensitive && stristr(nbuf, bw->word)))) { - mustkick = 1; - } else if (bw->type == BW_SINGLE) { - int len = strlen(bw->word); - - if ((BSCaseSensitive && !strcmp(nbuf, bw->word)) - || (!BSCaseSensitive - && (!stricmp(nbuf, bw->word)))) { - mustkick = 1; - /* two next if are quite odd isn't it? =) */ - } else if ((strchr(nbuf, ' ') == nbuf + len) - && - ((BSCaseSensitive - && !strcmp(nbuf, bw->word)) - || (!BSCaseSensitive - && (stristr(nbuf, bw->word) == - nbuf)))) { - mustkick = 1; - } else { - if ((strrchr(nbuf, ' ') == - nbuf + strlen(nbuf) - len - 1) - && - ((BSCaseSensitive - && (strstr(nbuf, bw->word) == - nbuf + strlen(nbuf) - len)) - || (!BSCaseSensitive - && (stristr(nbuf, bw->word) == - nbuf + strlen(nbuf) - len)))) { - mustkick = 1; - } else { - char *wordbuf = (char *)scalloc(len + 3, 1); - - wordbuf[0] = ' '; - wordbuf[len + 1] = ' '; - wordbuf[len + 2] = '\0'; - memcpy(wordbuf + 1, bw->word, len); - - if ((BSCaseSensitive - && (strstr(nbuf, wordbuf))) - || (!BSCaseSensitive - && (stristr(nbuf, wordbuf)))) { - mustkick = 1; - } - - /* free previous (sc)allocated memory (#850) */ - free(wordbuf); - } - } - } else if (bw->type == BW_START) { - int len = strlen(bw->word); - - if ((BSCaseSensitive - && (!strncmp(nbuf, bw->word, len))) - || (!BSCaseSensitive - && (!strnicmp(nbuf, bw->word, len)))) { - mustkick = 1; - } else { - char *wordbuf = (char *)scalloc(len + 2, 1); - - memcpy(wordbuf + 1, bw->word, len); - wordbuf[0] = ' '; - wordbuf[len + 1] = '\0'; - - if ((BSCaseSensitive && (strstr(nbuf, wordbuf))) - || (!BSCaseSensitive - && (stristr(nbuf, wordbuf)))) - mustkick = 1; - - free(wordbuf); - } - } else if (bw->type == BW_END) { - int len = strlen(bw->word); - - if ((BSCaseSensitive - && - (!strncmp - (nbuf + strlen(nbuf) - len, bw->word, len))) - || (!BSCaseSensitive - && - (!strnicmp - (nbuf + strlen(nbuf) - len, bw->word, - len)))) { - mustkick = 1; - } else { - char *wordbuf = (char *)scalloc(len + 2, 1); - - memcpy(wordbuf, bw->word, len); - wordbuf[len] = ' '; - wordbuf[len + 1] = '\0'; - - if ((BSCaseSensitive && (strstr(nbuf, wordbuf))) - || (!BSCaseSensitive - && (stristr(nbuf, wordbuf)))) - mustkick = 1; - - free(wordbuf); - } - } - - if (mustkick) { - check_ban(ci, u, TTB_BADWORDS); - if (BSGentleBWReason) - bot_kick(ci, u, BOT_REASON_BADWORD_GENTLE); - else - bot_kick(ci, u, BOT_REASON_BADWORD, bw->word); - - /* free the normalized buffer before return (#850) */ - Anope_Free(nbuf); - - return; - } - } - - /* Free the normalized buffer */ - Anope_Free(nbuf); - } - - /* Flood kicker */ - if (ci->botflags & BS_KICK_FLOOD) { - time_t now = time(NULL); - - ud = get_user_data(ci->c, u); - if (!ud) { - return; - } - - if (now - ud->last_start > ci->floodsecs) { - ud->last_start = time(NULL); - ud->lines = 0; - } - - ud->lines++; - if (ud->lines >= ci->floodlines) { - check_ban(ci, u, TTB_FLOOD); - bot_kick(ci, u, BOT_REASON_FLOOD); - return; - } - } - - /* Repeat kicker */ - if (ci->botflags & BS_KICK_REPEAT) { - ud = get_user_data(ci->c, u); - if (!ud) { - return; - } - if (ud->lastline && stricmp(ud->lastline, buf)) { - free(ud->lastline); - ud->lastline = sstrdup(buf); - ud->times = 0; - } else { - if (!ud->lastline) - ud->lastline = sstrdup(buf); - ud->times++; - } - - if (ud->times >= ci->repeattimes) { - check_ban(ci, u, TTB_REPEAT); - bot_kick(ci, u, BOT_REASON_REPEAT); - return; - } - } - } - - - /* return if the user is on the ignore list */ - if (get_ignore(u->nick) != NULL) { - return; - } - - /* Fantaisist commands */ - - if (buf && (ci->botflags & BS_FANTASY) && *buf == *BSFantasyCharacter) { - cmd = strtok(buf, " "); - - if (cmd && (cmd[0] == *BSFantasyCharacter)) { - char *params = strtok(NULL, ""); - const char *event_name = EVENT_BOT_FANTASY_NO_ACCESS; - - /* Strip off the fantasy character */ - cmd++; - - if (check_access(u, ci, CA_FANTASIA)) - event_name = EVENT_BOT_FANTASY; - - if (params) - send_event(event_name, 4, cmd, u->nick, ci->name, params); - else - send_event(event_name, 3, cmd, u->nick, ci->name); - } - } + int c; + int16 cstatus = 0; + char *cmd; + UserData *ud; + + if (!u || !buf || !ci) { + return; + } + + /* Answer to ping if needed, without breaking the buffer. */ + if (!strnicmp(buf, "\1PING", 5)) { + ircdproto->SendCTCP(ci->bi, u->nick, "PING %s", buf); + } + + /* If it's a /me, cut the CTCP part at the beginning (not + * at the end, because one character just doesn't matter, + * but the ACTION may create strange behaviours with the + * caps or badwords kickers */ + if (!strnicmp(buf, "\1ACTION ", 8)) + buf += 8; + + /* Now we can make kicker stuff. We try to order the checks + * from the fastest one to the slowest one, since there's + * no need to process other kickers if an user is kicked before + * the last kicker check. + * + * But FIRST we check whether the user is protected in any + * way. + */ + + /* We first retrieve the user status on the channel if needed */ + if (ci->botflags & (BS_DONTKICKOPS | BS_DONTKICKVOICES)) + cstatus = chan_get_user_status(ci->c, u); + + if (buf && !check_access(u, ci, CA_NOKICK) && + (!(ci->botflags & BS_DONTKICKOPS) + || !(cstatus & (CUS_HALFOP | CUS_OP | CUS_OWNER | CUS_PROTECT))) + + && (!(ci->botflags & BS_DONTKICKVOICES) || !(cstatus & CUS_VOICE))) { + /* Bolds kicker */ + if ((ci->botflags & BS_KICK_BOLDS) && strchr(buf, 2)) { + check_ban(ci, u, TTB_BOLDS); + bot_kick(ci, u, BOT_REASON_BOLD); + return; + } + + /* Color kicker */ + if ((ci->botflags & BS_KICK_COLORS) && strchr(buf, 3)) { + check_ban(ci, u, TTB_COLORS); + bot_kick(ci, u, BOT_REASON_COLOR); + return; + } + + /* Reverses kicker */ + if ((ci->botflags & BS_KICK_REVERSES) && strchr(buf, 22)) { + check_ban(ci, u, TTB_REVERSES); + bot_kick(ci, u, BOT_REASON_REVERSE); + return; + } + + /* Underlines kicker */ + if ((ci->botflags & BS_KICK_UNDERLINES) && strchr(buf, 31)) { + check_ban(ci, u, TTB_UNDERLINES); + bot_kick(ci, u, BOT_REASON_UNDERLINE); + return; + } + + /* Caps kicker */ + if ((ci->botflags & BS_KICK_CAPS) + && ((c = strlen(buf)) >= ci->capsmin)) { + int i = 0; + int l = 0; + char *s = buf; + + do { + if (isupper(*s)) + i++; + else if (islower(*s)) + l++; + } while (*s++); + + /* i counts uppercase chars, l counts lowercase chars. Only + * alphabetic chars (so islower || isupper) qualify for the + * percentage of caps to kick for; the rest is ignored. -GD + */ + + if (i >= ci->capsmin && i * 100 / (i + l) >= ci->capspercent) { + check_ban(ci, u, TTB_CAPS); + bot_kick(ci, u, BOT_REASON_CAPS); + return; + } + } + + /* Bad words kicker */ + if (ci->botflags & BS_KICK_BADWORDS) { + int i; + int mustkick = 0; + char *nbuf; + BadWord *bw; + + /* Normalize the buffer */ + nbuf = normalizeBuffer(buf); + + for (i = 0, bw = ci->badwords; i < ci->bwcount; i++, bw++) { + if (!bw->in_use) + continue; + + if (bw->type == BW_ANY + && ((BSCaseSensitive && strstr(nbuf, bw->word)) + || (!BSCaseSensitive && stristr(nbuf, bw->word)))) { + mustkick = 1; + } else if (bw->type == BW_SINGLE) { + int len = strlen(bw->word); + + if ((BSCaseSensitive && !strcmp(nbuf, bw->word)) + || (!BSCaseSensitive + && (!stricmp(nbuf, bw->word)))) { + mustkick = 1; + /* two next if are quite odd isn't it? =) */ + } else if ((strchr(nbuf, ' ') == nbuf + len) + && + ((BSCaseSensitive + && !strcmp(nbuf, bw->word)) + || (!BSCaseSensitive + && (stristr(nbuf, bw->word) == + nbuf)))) { + mustkick = 1; + } else { + if ((strrchr(nbuf, ' ') == + nbuf + strlen(nbuf) - len - 1) + && + ((BSCaseSensitive + && (strstr(nbuf, bw->word) == + nbuf + strlen(nbuf) - len)) + || (!BSCaseSensitive + && (stristr(nbuf, bw->word) == + nbuf + strlen(nbuf) - len)))) { + mustkick = 1; + } else { + char *wordbuf = (char *)scalloc(len + 3, 1); + + wordbuf[0] = ' '; + wordbuf[len + 1] = ' '; + wordbuf[len + 2] = '\0'; + memcpy(wordbuf + 1, bw->word, len); + + if ((BSCaseSensitive + && (strstr(nbuf, wordbuf))) + || (!BSCaseSensitive + && (stristr(nbuf, wordbuf)))) { + mustkick = 1; + } + + /* free previous (sc)allocated memory (#850) */ + free(wordbuf); + } + } + } else if (bw->type == BW_START) { + int len = strlen(bw->word); + + if ((BSCaseSensitive + && (!strncmp(nbuf, bw->word, len))) + || (!BSCaseSensitive + && (!strnicmp(nbuf, bw->word, len)))) { + mustkick = 1; + } else { + char *wordbuf = (char *)scalloc(len + 2, 1); + + memcpy(wordbuf + 1, bw->word, len); + wordbuf[0] = ' '; + wordbuf[len + 1] = '\0'; + + if ((BSCaseSensitive && (strstr(nbuf, wordbuf))) + || (!BSCaseSensitive + && (stristr(nbuf, wordbuf)))) + mustkick = 1; + + free(wordbuf); + } + } else if (bw->type == BW_END) { + int len = strlen(bw->word); + + if ((BSCaseSensitive + && + (!strncmp + (nbuf + strlen(nbuf) - len, bw->word, len))) + || (!BSCaseSensitive + && + (!strnicmp + (nbuf + strlen(nbuf) - len, bw->word, + len)))) { + mustkick = 1; + } else { + char *wordbuf = (char *)scalloc(len + 2, 1); + + memcpy(wordbuf, bw->word, len); + wordbuf[len] = ' '; + wordbuf[len + 1] = '\0'; + + if ((BSCaseSensitive && (strstr(nbuf, wordbuf))) + || (!BSCaseSensitive + && (stristr(nbuf, wordbuf)))) + mustkick = 1; + + free(wordbuf); + } + } + + if (mustkick) { + check_ban(ci, u, TTB_BADWORDS); + if (BSGentleBWReason) + bot_kick(ci, u, BOT_REASON_BADWORD_GENTLE); + else + bot_kick(ci, u, BOT_REASON_BADWORD, bw->word); + + /* free the normalized buffer before return (#850) */ + Anope_Free(nbuf); + + return; + } + } + + /* Free the normalized buffer */ + Anope_Free(nbuf); + } + + /* Flood kicker */ + if (ci->botflags & BS_KICK_FLOOD) { + time_t now = time(NULL); + + ud = get_user_data(ci->c, u); + if (!ud) { + return; + } + + if (now - ud->last_start > ci->floodsecs) { + ud->last_start = time(NULL); + ud->lines = 0; + } + + ud->lines++; + if (ud->lines >= ci->floodlines) { + check_ban(ci, u, TTB_FLOOD); + bot_kick(ci, u, BOT_REASON_FLOOD); + return; + } + } + + /* Repeat kicker */ + if (ci->botflags & BS_KICK_REPEAT) { + ud = get_user_data(ci->c, u); + if (!ud) { + return; + } + if (ud->lastline && stricmp(ud->lastline, buf)) { + free(ud->lastline); + ud->lastline = sstrdup(buf); + ud->times = 0; + } else { + if (!ud->lastline) + ud->lastline = sstrdup(buf); + ud->times++; + } + + if (ud->times >= ci->repeattimes) { + check_ban(ci, u, TTB_REPEAT); + bot_kick(ci, u, BOT_REASON_REPEAT); + return; + } + } + } + + + /* return if the user is on the ignore list */ + if (get_ignore(u->nick) != NULL) { + return; + } + + /* Fantaisist commands */ + + if (buf && (ci->botflags & BS_FANTASY) && *buf == *BSFantasyCharacter) { + cmd = strtok(buf, " "); + + if (cmd && (cmd[0] == *BSFantasyCharacter)) { + char *params = strtok(NULL, ""); + const char *event_name = EVENT_BOT_FANTASY_NO_ACCESS; + + /* Strip off the fantasy character */ + cmd++; + + if (check_access(u, ci, CA_FANTASIA)) + event_name = EVENT_BOT_FANTASY; + + if (params) + send_event(event_name, 4, cmd, u->nick, ci->name, params); + else + send_event(event_name, 3, cmd, u->nick, ci->name); + } + } } /*************************************************************************/ @@ -434,51 +434,51 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf) #define SAFE(x) do { \ - if ((x) < 0) { \ + if ((x) < 0) { \ if (!forceload) \ - fatal("Read error on %s", BotDBName); \ + fatal("Read error on %s", BotDBName); \ failed = 1; \ break; \ - } \ + } \ } while (0) void load_bs_dbase(void) { - dbFILE *f; - int c, ver; - uint16 tmp16; - uint32 tmp32; - BotInfo *bi; - int failed = 0; - - if (!(f = open_db(s_BotServ, BotDBName, "r", BOT_VERSION))) - return; - - ver = get_file_version(f); - - while (!failed && (c = getc_db(f)) != 0) { - char *s; - - if (c != 1) - fatal("Invalid format in %s %d", BotDBName, c); - - SAFE(read_string(&s, f)); - bi = new BotInfo(s); - free(s); - SAFE(read_string(&bi->user, f)); - SAFE(read_string(&bi->host, f)); - SAFE(read_string(&bi->real, f)); - if (ver >= 10) { - SAFE(read_int16(&tmp16, f)); - bi->flags = tmp16; - } - SAFE(read_int32(&tmp32, f)); - bi->created = tmp32; - SAFE(read_int16(&tmp16, f)); - bi->chancount = tmp16; - } - - close_db(f); + dbFILE *f; + int c, ver; + uint16 tmp16; + uint32 tmp32; + BotInfo *bi; + int failed = 0; + + if (!(f = open_db(s_BotServ, BotDBName, "r", BOT_VERSION))) + return; + + ver = get_file_version(f); + + while (!failed && (c = getc_db(f)) != 0) { + char *s; + + if (c != 1) + fatal("Invalid format in %s %d", BotDBName, c); + + SAFE(read_string(&s, f)); + bi = new BotInfo(s); + free(s); + SAFE(read_string(&bi->user, f)); + SAFE(read_string(&bi->host, f)); + SAFE(read_string(&bi->real, f)); + if (ver >= 10) { + SAFE(read_int16(&tmp16, f)); + bi->flags = tmp16; + } + SAFE(read_int32(&tmp32, f)); + bi->created = tmp32; + SAFE(read_int16(&tmp16, f)); + bi->chancount = tmp16; + } + + close_db(f); } #undef SAFE @@ -486,43 +486,43 @@ void load_bs_dbase(void) /*************************************************************************/ #define SAFE(x) do { \ - if ((x) < 0) { \ + if ((x) < 0) { \ restore_db(f); \ log_perror("Write error on %s", BotDBName); \ if (time(NULL) - lastwarn > WarningTimeout) { \ - ircdproto->SendGlobops(NULL, "Write error on %s: %s", BotDBName, \ + ircdproto->SendGlobops(NULL, "Write error on %s: %s", BotDBName, \ strerror(errno)); \ - lastwarn = time(NULL); \ + lastwarn = time(NULL); \ } \ return; \ - } \ + } \ } while (0) void save_bs_dbase(void) { - dbFILE *f; - BotInfo *bi; - static time_t lastwarn = 0; - int i; - - if (!(f = open_db(s_BotServ, BotDBName, "w", BOT_VERSION))) - return; - - for (i = 0; i < 256; i++) { - for (bi = botlists[i]; bi; bi = bi->next) { - SAFE(write_int8(1, f)); - SAFE(write_string(bi->nick, f)); - SAFE(write_string(bi->user, f)); - SAFE(write_string(bi->host, f)); - SAFE(write_string(bi->real, f)); - SAFE(write_int16(bi->flags, f)); - SAFE(write_int32(bi->created, f)); - SAFE(write_int16(bi->chancount, f)); - } - } - SAFE(write_int8(0, f)); - - close_db(f); + dbFILE *f; + BotInfo *bi; + static time_t lastwarn = 0; + int i; + + if (!(f = open_db(s_BotServ, BotDBName, "w", BOT_VERSION))) + return; + + for (i = 0; i < 256; i++) { + for (bi = botlists[i]; bi; bi = bi->next) { + SAFE(write_int8(1, f)); + SAFE(write_string(bi->nick, f)); + SAFE(write_string(bi->user, f)); + SAFE(write_string(bi->host, f)); + SAFE(write_string(bi->real, f)); + SAFE(write_int16(bi->flags, f)); + SAFE(write_int32(bi->created, f)); + SAFE(write_int16(bi->chancount, f)); + } + } + SAFE(write_int8(0, f)); + + close_db(f); } @@ -534,19 +534,19 @@ void save_bs_dbase(void) void insert_bot(BotInfo * bi) { - BotInfo *ptr, *prev; - - for (prev = NULL, ptr = botlists[tolower(*bi->nick)]; - ptr != NULL && stricmp(ptr->nick, bi->nick) < 0; - prev = ptr, ptr = ptr->next); - bi->prev = prev; - bi->next = ptr; - if (!prev) - botlists[tolower(*bi->nick)] = bi; - else - prev->next = bi; - if (ptr) - ptr->prev = bi; + BotInfo *ptr, *prev; + + for (prev = NULL, ptr = botlists[tolower(*bi->nick)]; + ptr != NULL && stricmp(ptr->nick, bi->nick) < 0; + prev = ptr, ptr = ptr->next); + bi->prev = prev; + bi->next = ptr; + if (!prev) + botlists[tolower(*bi->nick)] = bi; + else + prev->next = bi; + if (ptr) + ptr->prev = bi; } /*************************************************************************/ @@ -585,49 +585,49 @@ BotInfo *findbot(const char *nick) static BanData *get_ban_data(Channel * c, User * u) { - char mask[BUFSIZE]; - BanData *bd, *next; - time_t now = time(NULL); - - if (!c || !u) - return NULL; - - snprintf(mask, sizeof(mask), "%s@%s", u->username, - common_get_vhost(u)); - - for (bd = c->bd; bd; bd = next) { - if (now - bd->last_use > BSKeepData) { - if (bd->next) - bd->next->prev = bd->prev; - if (bd->prev) - bd->prev->next = bd->next; - else - c->bd = bd->next; - if (bd->mask) - free(bd->mask); - next = bd->next; - free(bd); - continue; - } - if (!stricmp(bd->mask, mask)) { - bd->last_use = now; - return bd; - } - next = bd->next; - } - - /* If we fall here it is that we haven't found the record */ - bd = (BanData *)scalloc(sizeof(BanData), 1); - bd->mask = sstrdup(mask); - bd->last_use = now; - - bd->prev = NULL; - bd->next = c->bd; - if (bd->next) - bd->next->prev = bd; - c->bd = bd; - - return bd; + char mask[BUFSIZE]; + BanData *bd, *next; + time_t now = time(NULL); + + if (!c || !u) + return NULL; + + snprintf(mask, sizeof(mask), "%s@%s", u->username, + common_get_vhost(u)); + + for (bd = c->bd; bd; bd = next) { + if (now - bd->last_use > BSKeepData) { + if (bd->next) + bd->next->prev = bd->prev; + if (bd->prev) + bd->prev->next = bd->next; + else + c->bd = bd->next; + if (bd->mask) + free(bd->mask); + next = bd->next; + free(bd); + continue; + } + if (!stricmp(bd->mask, mask)) { + bd->last_use = now; + return bd; + } + next = bd->next; + } + + /* If we fall here it is that we haven't found the record */ + bd = (BanData *)scalloc(sizeof(BanData), 1); + bd->mask = sstrdup(mask); + bd->last_use = now; + + bd->prev = NULL; + bd->next = c->bd; + if (bd->next) + bd->next->prev = bd; + c->bd = bd; + + return bd; } /*************************************************************************/ @@ -638,36 +638,36 @@ static BanData *get_ban_data(Channel * c, User * u) static UserData *get_user_data(Channel * c, User * u) { - struct c_userlist *user; - - if (!c || !u) - return NULL; - - for (user = c->users; user; user = user->next) { - if (user->user == u) { - if (user->ud) { - time_t now = time(NULL); - - /* Checks whether data is obsolete */ - if (now - user->ud->last_use > BSKeepData) { - if (user->ud->lastline) - free(user->ud->lastline); - /* We should not free and realloc, but reset to 0 - instead. */ - memset(user->ud, 0, sizeof(UserData)); - user->ud->last_use = now; - } - - return user->ud; - } else { - user->ud = (UserData *)scalloc(sizeof(UserData), 1); - user->ud->last_use = time(NULL); - return user->ud; - } - } - } - - return NULL; + struct c_userlist *user; + + if (!c || !u) + return NULL; + + for (user = c->users; user; user = user->next) { + if (user->user == u) { + if (user->ud) { + time_t now = time(NULL); + + /* Checks whether data is obsolete */ + if (now - user->ud->last_use > BSKeepData) { + if (user->ud->lastline) + free(user->ud->lastline); + /* We should not free and realloc, but reset to 0 + instead. */ + memset(user->ud, 0, sizeof(UserData)); + user->ud->last_use = now; + } + + return user->ud; + } else { + user->ud = (UserData *)scalloc(sizeof(UserData), 1); + user->ud->last_use = time(NULL); + return user->ud; + } + } + } + + return NULL; } /*************************************************************************/ @@ -676,55 +676,55 @@ static UserData *get_user_data(Channel * c, User * u) void bot_join(ChannelInfo * ci) { - if (!ci || !ci->c || !ci->bi) - return; - - if (BSSmartJoin) { - /* We check for bans */ - if (ci->c->bans && ci->c->bans->count) { - char buf[BUFSIZE]; - const char *av[4]; - Entry *ban, *next; - int ac; - - if (ircdcap->tsmode) { - snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); - av[0] = ci->c->name; - av[1] = buf; - av[2] = "-b"; - ac = 4; - } else { - av[0] = ci->c->name; - av[1] = "-b"; - ac = 3; - } - - for (ban = ci->c->bans->entries; ban; ban = next) { - next = ban->next; - if (entry_match - (ban, ci->bi->nick, ci->bi->user, ci->bi->host, 0)) { - ircdproto->SendMode(whosends(ci), ci->name, "-b %s", - ban->mask); - if (ircdcap->tsmode) - av[3] = ban->mask; - else - av[2] = ban->mask; - - do_cmode(whosends(ci)->nick, ac, av); - } - } - } - - /* Should we be invited? */ - if ((ci->c->mode & anope_get_invite_mode()) - || (ci->c->limit && (unsigned int)ci->c->usercount >= ci->c->limit)) - ircdproto->SendNoticeChanops(NULL, ci->c->name, - "%s invited %s into the channel.", - ci->bi->nick, ci->bi->nick); - } - ircdproto->SendJoin(ci->bi, ci->c->name, ci->c->creation_time); - ircdproto->SendBotOp(ci->bi->nick, ci->c->name); - send_event(EVENT_BOT_JOIN, 2, ci->name, ci->bi->nick); + if (!ci || !ci->c || !ci->bi) + return; + + if (BSSmartJoin) { + /* We check for bans */ + if (ci->c->bans && ci->c->bans->count) { + char buf[BUFSIZE]; + const char *av[4]; + Entry *ban, *next; + int ac; + + if (ircdcap->tsmode) { + snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); + av[0] = ci->c->name; + av[1] = buf; + av[2] = "-b"; + ac = 4; + } else { + av[0] = ci->c->name; + av[1] = "-b"; + ac = 3; + } + + for (ban = ci->c->bans->entries; ban; ban = next) { + next = ban->next; + if (entry_match + (ban, ci->bi->nick, ci->bi->user, ci->bi->host, 0)) { + ircdproto->SendMode(whosends(ci), ci->name, "-b %s", + ban->mask); + if (ircdcap->tsmode) + av[3] = ban->mask; + else + av[2] = ban->mask; + + do_cmode(whosends(ci)->nick, ac, av); + } + } + } + + /* Should we be invited? */ + if ((ci->c->mode & anope_get_invite_mode()) + || (ci->c->limit && (unsigned int)ci->c->usercount >= ci->c->limit)) + ircdproto->SendNoticeChanops(NULL, ci->c->name, + "%s invited %s into the channel.", + ci->bi->nick, ci->bi->nick); + } + ircdproto->SendJoin(ci->bi, ci->c->name, ci->c->creation_time); + ircdproto->SendBotOp(ci->bi->nick, ci->c->name); + send_event(EVENT_BOT_JOIN, 2, ci->name, ci->bi->nick); } /*************************************************************************/ @@ -734,40 +734,40 @@ void bot_join(ChannelInfo * ci) static void check_ban(ChannelInfo * ci, User * u, int ttbtype) { - BanData *bd = get_ban_data(ci->c, u); - - if (!bd) - return; - - bd->ttb[ttbtype]++; - if (bd->ttb[ttbtype] == ci->ttb[ttbtype]) { - const char *av[4]; - int ac; - char mask[BUFSIZE]; - char buf[BUFSIZE]; - - bd->ttb[ttbtype] = 0; - - get_idealban(ci, u, mask, sizeof(mask)); - - if (ircdcap->tsmode) { - snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); - av[0] = ci->name; - av[1] = buf; - av[2] = "+b"; - av[3] = mask; - ac = 4; - } else { - av[0] = ci->name; - av[1] = "+b"; - av[2] = mask; - ac = 3; - } - - ircdproto->SendMode(ci->bi, ci->name, "+b %s", mask); - do_cmode(ci->bi->nick, ac, av); - send_event(EVENT_BOT_BAN, 3, u->nick, ci->name, mask); - } + BanData *bd = get_ban_data(ci->c, u); + + if (!bd) + return; + + bd->ttb[ttbtype]++; + if (bd->ttb[ttbtype] == ci->ttb[ttbtype]) { + const char *av[4]; + int ac; + char mask[BUFSIZE]; + char buf[BUFSIZE]; + + bd->ttb[ttbtype] = 0; + + get_idealban(ci, u, mask, sizeof(mask)); + + if (ircdcap->tsmode) { + snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); + av[0] = ci->name; + av[1] = buf; + av[2] = "+b"; + av[3] = mask; + ac = 4; + } else { + av[0] = ci->name; + av[1] = "+b"; + av[2] = mask; + ac = 3; + } + + ircdproto->SendMode(ci->bi, ci->name, "+b %s", mask); + do_cmode(ci->bi->nick, ac, av); + send_event(EVENT_BOT_BAN, 3, u->nick, ci->name, mask); + } } /*************************************************************************/ @@ -776,27 +776,27 @@ static void check_ban(ChannelInfo * ci, User * u, int ttbtype) static void bot_kick(ChannelInfo * ci, User * u, int message, ...) { - va_list args; - char buf[1024]; - const char *fmt; - const char *av[3]; - - if (!ci || !ci->bi || !ci->c || !u) - return; - - va_start(args, message); - fmt = getstring(u->na, message); - if (!fmt) - return; - vsnprintf(buf, sizeof(buf), fmt, args); - va_end(args); - - av[0] = ci->name; - av[1] = u->nick; - av[2] = buf; - ircdproto->SendKick(ci->bi, av[0], av[1], "%s", av[2]); - do_kick(ci->bi->nick, 3, av); - send_event(EVENT_BOT_KICK, 3, u->nick, ci->name, buf); + va_list args; + char buf[1024]; + const char *fmt; + const char *av[3]; + + if (!ci || !ci->bi || !ci->c || !u) + return; + + va_start(args, message); + fmt = getstring(u->na, message); + if (!fmt) + return; + vsnprintf(buf, sizeof(buf), fmt, args); + va_end(args); + + av[0] = ci->name; + av[1] = u->nick; + av[2] = buf; + ircdproto->SendKick(ci->bi, av[0], av[1], "%s", av[2]); + do_kick(ci->bi->nick, 3, av); + send_event(EVENT_BOT_KICK, 3, u->nick, ci->name, buf); } /*************************************************************************/ @@ -804,79 +804,79 @@ static void bot_kick(ChannelInfo * ci, User * u, int message, ...) /* Makes a simple ban and kicks the target */ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick, - const char *reason) + const char *reason) { - int ac; - const char *av[4]; + int ac; + const char *av[4]; const char *kav[4]; // seperate as not everything is constified XXX -- w00t - char mask[BUFSIZE]; - char buf[BUFSIZE]; - User *u = finduser(nick); - - if (!u) - return; - - if (ircd->protectedumode) { - if (is_protected(u) && (requester != u)) { - ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", - getstring2(NULL, PERMISSION_DENIED)); - return; - } - } - - if ((ci->flags & CI_PEACE) && stricmp(requester->nick, nick) - && (get_access(u, ci) >= get_access(requester, ci))) - return; - - if (ircd->except) { - if (is_excepted(ci, u) == 1) { - ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", - getstring2(NULL, BOT_EXCEPT)); - return; - } - } - - get_idealban(ci, u, mask, sizeof(mask)); - - if (ircdcap->tsmode) { - snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); - av[0] = ci->name; - av[1] = buf; - av[2] = "+b"; - av[3] = mask; - ac = 4; - } else { - av[0] = ci->name; - av[1] = "+b"; - av[2] = mask; - ac = 3; - } - - ircdproto->SendMode(ci->bi, ci->name, "+b %s", mask); - do_cmode(ci->bi->nick, ac, av); - - kav[0] = ci->name; - kav[1] = nick; - - if (!reason) { - kav[2] = ci->bi->nick; - } else { - if (strlen(reason) > 200) - *((char **)&reason[200]) = '\0'; // Unsafe cast -- will review later -- CyberBotX - kav[2] = reason; - } - - /* Check if we need to do a signkick or not -GD */ - if ((ci->flags & CI_SIGNKICK) - || ((ci->flags & CI_SIGNKICK_LEVEL) - && !check_access(requester, ci, CA_SIGNKICK))) - ircdproto->SendKick(ci->bi, kav[0], kav[1], "%s (%s)", kav[2], - requester->nick); - else - ircdproto->SendKick(ci->bi, kav[0], kav[1], "%s", kav[2]); - - do_kick(ci->bi->nick, 3, kav); - send_event(EVENT_BOT_KICK, 3, kav[1], kav[0], kav[2]); + char mask[BUFSIZE]; + char buf[BUFSIZE]; + User *u = finduser(nick); + + if (!u) + return; + + if (ircd->protectedumode) { + if (is_protected(u) && (requester != u)) { + ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", + getstring2(NULL, PERMISSION_DENIED)); + return; + } + } + + if ((ci->flags & CI_PEACE) && stricmp(requester->nick, nick) + && (get_access(u, ci) >= get_access(requester, ci))) + return; + + if (ircd->except) { + if (is_excepted(ci, u) == 1) { + ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", + getstring2(NULL, BOT_EXCEPT)); + return; + } + } + + get_idealban(ci, u, mask, sizeof(mask)); + + if (ircdcap->tsmode) { + snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); + av[0] = ci->name; + av[1] = buf; + av[2] = "+b"; + av[3] = mask; + ac = 4; + } else { + av[0] = ci->name; + av[1] = "+b"; + av[2] = mask; + ac = 3; + } + + ircdproto->SendMode(ci->bi, ci->name, "+b %s", mask); + do_cmode(ci->bi->nick, ac, av); + + kav[0] = ci->name; + kav[1] = nick; + + if (!reason) { + kav[2] = ci->bi->nick; + } else { + if (strlen(reason) > 200) + *((char **)&reason[200]) = '\0'; // Unsafe cast -- will review later -- CyberBotX + kav[2] = reason; + } + + /* Check if we need to do a signkick or not -GD */ + if ((ci->flags & CI_SIGNKICK) + || ((ci->flags & CI_SIGNKICK_LEVEL) + && !check_access(requester, ci, CA_SIGNKICK))) + ircdproto->SendKick(ci->bi, kav[0], kav[1], "%s (%s)", kav[2], + requester->nick); + else + ircdproto->SendKick(ci->bi, kav[0], kav[1], "%s", kav[2]); + + do_kick(ci->bi->nick, 3, kav); + send_event(EVENT_BOT_KICK, 3, kav[1], kav[0], kav[2]); } /*************************************************************************/ @@ -884,46 +884,46 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick, /* Makes a kick with a "dynamic" reason ;) */ void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick, - const char *reason) + const char *reason) { - const char *av[3]; - User *u = finduser(nick); - - if (!u || !is_on_chan(ci->c, u)) - return; - - if (ircd->protectedumode) { - if (is_protected(u) && (requester != u)) { - ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", - getstring2(NULL, PERMISSION_DENIED)); - return; - } - } - - if ((ci->flags & CI_PEACE) && stricmp(requester->nick, nick) - && (get_access(u, ci) >= get_access(requester, ci))) - return; - - av[0] = ci->name; - av[1] = nick; - - if (!reason) { - av[2] = ci->bi->nick; - } else { - if (strlen(reason) > 200) - *((char **)&reason[200]) = '\0'; // Unsafe cast -- will review later -- CyberBotX - av[2] = reason; - } - - if ((ci->flags & CI_SIGNKICK) - || ((ci->flags & CI_SIGNKICK_LEVEL) - && !check_access(requester, ci, CA_SIGNKICK))) - ircdproto->SendKick(ci->bi, av[0], av[1], "%s (%s)", av[2], - requester->nick); - else - ircdproto->SendKick(ci->bi, av[0], av[1], "%s", av[2]); - do_kick(ci->bi->nick, 3, av); - send_event(EVENT_BOT_KICK, 3, av[1], av[0], av[2]); + const char *av[3]; + User *u = finduser(nick); + + if (!u || !is_on_chan(ci->c, u)) + return; + + if (ircd->protectedumode) { + if (is_protected(u) && (requester != u)) { + ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", + getstring2(NULL, PERMISSION_DENIED)); + return; + } + } + + if ((ci->flags & CI_PEACE) && stricmp(requester->nick, nick) + && (get_access(u, ci) >= get_access(requester, ci))) + return; + + av[0] = ci->name; + av[1] = nick; + + if (!reason) { + av[2] = ci->bi->nick; + } else { + if (strlen(reason) > 200) + *((char **)&reason[200]) = '\0'; // Unsafe cast -- will review later -- CyberBotX + av[2] = reason; + } + + if ((ci->flags & CI_SIGNKICK) + || ((ci->flags & CI_SIGNKICK_LEVEL) + && !check_access(requester, ci, CA_SIGNKICK))) + ircdproto->SendKick(ci->bi, av[0], av[1], "%s (%s)", av[2], + requester->nick); + else + ircdproto->SendKick(ci->bi, av[0], av[1], "%s", av[2]); + do_kick(ci->bi->nick, 3, av); + send_event(EVENT_BOT_KICK, 3, av[1], av[0], av[2]); } /*************************************************************************/ @@ -931,50 +931,50 @@ void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick, /* Makes a mode operation on a channel for a nick */ void bot_raw_mode(User * requester, ChannelInfo * ci, const char *mode, - char *nick) + char *nick) { - const char *av[4]; - int ac; - char buf[BUFSIZE]; - User *u; - - *buf = '\0'; - u = finduser(nick); - - if (!u || !is_on_chan(ci->c, u)) - return; - - snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); - - if (ircd->protectedumode) { - if (is_protected(u) && *mode == '-' && (requester != u)) { - ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", - getstring2(NULL, PERMISSION_DENIED)); - return; - } - } - - if (*mode == '-' && (ci->flags & CI_PEACE) - && stricmp(requester->nick, nick) - && (get_access(u, ci) >= get_access(requester, ci))) - return; - - if (ircdcap->tsmode) { - av[0] = ci->name; - av[1] = buf; - av[2] = mode; - av[3] = nick; - ac = 4; - ircdproto->SendMode(ci->bi, av[0], "%s %s", av[2], av[3]); - } else { - av[0] = ci->name; - av[1] = mode; - av[2] = nick; - ac = 3; - ircdproto->SendMode(ci->bi, av[0], "%s %s", av[1], av[2]); - } - - do_cmode(ci->bi->nick, ac, av); + const char *av[4]; + int ac; + char buf[BUFSIZE]; + User *u; + + *buf = '\0'; + u = finduser(nick); + + if (!u || !is_on_chan(ci->c, u)) + return; + + snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); + + if (ircd->protectedumode) { + if (is_protected(u) && *mode == '-' && (requester != u)) { + ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", + getstring2(NULL, PERMISSION_DENIED)); + return; + } + } + + if (*mode == '-' && (ci->flags & CI_PEACE) + && stricmp(requester->nick, nick) + && (get_access(u, ci) >= get_access(requester, ci))) + return; + + if (ircdcap->tsmode) { + av[0] = ci->name; + av[1] = buf; + av[2] = mode; + av[3] = nick; + ac = 4; + ircdproto->SendMode(ci->bi, av[0], "%s %s", av[2], av[3]); + } else { + av[0] = ci->name; + av[1] = mode; + av[2] = nick; + ac = 3; + ircdproto->SendMode(ci->bi, av[0], "%s %s", av[1], av[2]); + } + + do_cmode(ci->bi->nick, ac, av); } /*************************************************************************/ @@ -985,75 +985,75 @@ void bot_raw_mode(User * requester, ChannelInfo * ci, const char *mode, */ char *normalizeBuffer(const char *buf) { - char *newbuf; - int i, len, j = 0; - - len = strlen(buf); - newbuf = (char *) smalloc(sizeof(char) * len + 1); - - for (i = 0; i < len; i++) { - switch (buf[i]) { - /* ctrl char */ - case 1: - break; - /* Bold ctrl char */ - case 2: - break; - /* Color ctrl char */ - case 3: - /* If the next character is a digit, its also removed */ - if (isdigit(buf[i + 1])) { - i++; - - /* not the best way to remove colors - * which are two digit but no worse then - * how the Unreal does with +S - TSL - */ - if (isdigit(buf[i + 1])) { - i++; - } - - /* Check for background color code - * and remove it as well - */ - if (buf[i + 1] == ',') { - i++; - - if (isdigit(buf[i + 1])) { - i++; - } - /* not the best way to remove colors - * which are two digit but no worse then - * how the Unreal does with +S - TSL - */ - if (isdigit(buf[i + 1])) { - i++; - } - } - } - - break; - /* line feed char */ - case 10: - break; - /* carriage returns char */ - case 13: - break; - /* Reverse ctrl char */ - case 22: - break; - /* Underline ctrl char */ - case 31: - break; - /* A valid char gets copied into the new buffer */ - default: - newbuf[j] = buf[i]; - j++; - } - } - - /* Terminate the string */ - newbuf[j] = 0; - - return (newbuf); + char *newbuf; + int i, len, j = 0; + + len = strlen(buf); + newbuf = (char *) smalloc(sizeof(char) * len + 1); + + for (i = 0; i < len; i++) { + switch (buf[i]) { + /* ctrl char */ + case 1: + break; + /* Bold ctrl char */ + case 2: + break; + /* Color ctrl char */ + case 3: + /* If the next character is a digit, its also removed */ + if (isdigit(buf[i + 1])) { + i++; + + /* not the best way to remove colors + * which are two digit but no worse then + * how the Unreal does with +S - TSL + */ + if (isdigit(buf[i + 1])) { + i++; + } + + /* Check for background color code + * and remove it as well + */ + if (buf[i + 1] == ',') { + i++; + + if (isdigit(buf[i + 1])) { + i++; + } + /* not the best way to remove colors + * which are two digit but no worse then + * how the Unreal does with +S - TSL + */ + if (isdigit(buf[i + 1])) { + i++; + } + } + } + + break; + /* line feed char */ + case 10: + break; + /* carriage returns char */ + case 13: + break; + /* Reverse ctrl char */ + case 22: + break; + /* Underline ctrl char */ + case 31: + break; + /* A valid char gets copied into the new buffer */ + default: + newbuf[j] = buf[i]; + j++; + } + } + + /* Terminate the string */ + newbuf[j] = 0; + + return (newbuf); } diff --git a/src/channels.c b/src/channels.c index 5fdd6b73b..2cce6266c 100644 --- a/src/channels.c +++ b/src/channels.c @@ -24,36 +24,36 @@ Channel *chanlist[1024]; void chan_deluser(User * user, Channel * c) { - struct c_userlist *u; - - if (c->ci) - update_cs_lastseen(user, c->ci); - - for (u = c->users; u && u->user != user; u = u->next); - if (!u) - return; - - if (u->ud) { - if (u->ud->lastline) - free(u->ud->lastline); - free(u->ud); - } - - if (u->next) - u->next->prev = u->prev; - if (u->prev) - u->prev->next = u->next; - else - c->users = u->next; - free(u); - c->usercount--; - - if (s_BotServ && c->ci && c->ci->bi && c->usercount == BSMinUsers - 1) { - ircdproto->SendPart(c->ci->bi, c->name, NULL); - } - - if (!c->users) - chan_delete(c); + struct c_userlist *u; + + if (c->ci) + update_cs_lastseen(user, c->ci); + + for (u = c->users; u && u->user != user; u = u->next); + if (!u) + return; + + if (u->ud) { + if (u->ud->lastline) + free(u->ud->lastline); + free(u->ud); + } + + if (u->next) + u->next->prev = u->prev; + if (u->prev) + u->prev->next = u->next; + else + c->users = u->next; + free(u); + c->usercount--; + + if (s_BotServ && c->ci && c->ci->bi && c->usercount == BSMinUsers - 1) { + ircdproto->SendPart(c->ci->bi, c->name, NULL); + } + + if (!c->users) + chan_delete(c); } /*************************************************************************/ @@ -64,39 +64,39 @@ void chan_deluser(User * user, Channel * c) char *chan_get_modes(Channel * chan, int complete, int plus) { - static char res[BUFSIZE]; - char *end = res; - - if (chan->mode) { - unsigned int n = 0; - CBModeInfo *cbmi = cbmodeinfos; - - do { - if (chan->mode & cbmi->flag) - *end++ = cbmi->mode; - } while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1); - - if (complete) { - cbmi = cbmodeinfos; - - do { - if (cbmi->getvalue && (chan->mode & cbmi->flag) && - (plus || !(cbmi->flags & CBM_MINUS_NO_ARG))) { - char *value = cbmi->getvalue(chan); - - if (value) { - *end++ = ' '; - while (*value) - *end++ = *value++; - } - } - } while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1); - } - } - - *end = 0; - - return res; + static char res[BUFSIZE]; + char *end = res; + + if (chan->mode) { + unsigned int n = 0; + CBModeInfo *cbmi = cbmodeinfos; + + do { + if (chan->mode & cbmi->flag) + *end++ = cbmi->mode; + } while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1); + + if (complete) { + cbmi = cbmodeinfos; + + do { + if (cbmi->getvalue && (chan->mode & cbmi->flag) && + (plus || !(cbmi->flags & CBM_MINUS_NO_ARG))) { + char *value = cbmi->getvalue(chan); + + if (value) { + *end++ = ' '; + while (*value) + *end++ = *value++; + } + } + } while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1); + } + } + + *end = 0; + + return res; } /*************************************************************************/ @@ -105,13 +105,13 @@ char *chan_get_modes(Channel * chan, int complete, int plus) int chan_get_user_status(Channel * chan, User * user) { - struct u_chanlist *uc; + struct u_chanlist *uc; - for (uc = user->chans; uc; uc = uc->next) - if (uc->chan == chan) - return uc->status; + for (uc = user->chans; uc; uc = uc->next) + if (uc->chan == chan) + return uc->status; - return 0; + return 0; } /*************************************************************************/ @@ -120,17 +120,17 @@ int chan_get_user_status(Channel * chan, User * user) int chan_has_user_status(Channel * chan, User * user, int16 status) { - struct u_chanlist *uc; - - for (uc = user->chans; uc; uc = uc->next) { - if (uc->chan == chan) { - if (debug) { - alog("debug: chan_has_user_status wanted %d the user is %d", status, uc->status); - } - return (uc->status & status); - } - } - return 0; + struct u_chanlist *uc; + + for (uc = user->chans; uc; uc = uc->next) { + if (uc->chan == chan) { + if (debug) { + alog("debug: chan_has_user_status wanted %d the user is %d", status, uc->status); + } + return (uc->status & status); + } + } + return 0; } /*************************************************************************/ @@ -139,186 +139,186 @@ int chan_has_user_status(Channel * chan, User * user, int16 status) void chan_remove_user_status(Channel * chan, User * user, int16 status) { - struct u_chanlist *uc; - - if (debug >= 2) - alog("debug: removing user status (%d) from %s for %s", status, - user->nick, chan->name); - - for (uc = user->chans; uc; uc = uc->next) { - if (uc->chan == chan) { - uc->status &= ~status; - break; - } - } + struct u_chanlist *uc; + + if (debug >= 2) + alog("debug: removing user status (%d) from %s for %s", status, + user->nick, chan->name); + + for (uc = user->chans; uc; uc = uc->next) { + if (uc->chan == chan) { + uc->status &= ~status; + break; + } + } } /*************************************************************************/ void chan_set_modes(const char *source, Channel * chan, int ac, const char **av, - int check) + int check) { - int add = 1; - const char *modes = av[0]; + int add = 1; + const char *modes = av[0]; char mode; - CBMode *cbm; - CMMode *cmm; - CUMode *cum; - unsigned char botmode = 0; - BotInfo *bi; - User *u, *user; - int i, real_ac = ac; - const char **real_av = av; - - if (debug) - alog("debug: Changing modes for %s to %s", chan->name, - merge_args(ac, av)); - - u = finduser(source); - if (u && (chan_get_user_status(chan, u) & CUS_DEOPPED)) { - char *s; - - if (debug) - alog("debug: Removing instead of setting due to DEOPPED flag"); - - /* Swap adding and removing of the modes */ - for (s = (char *)av[0]; *s; s++) { // XXX Unsafe cast, this needs reviewing -- CyberBotX - if (*s == '+') - *s = '-'; - else if (*s == '-') - *s = '+'; - } - - /* Set the resulting mode buffer */ - ircdproto->SendMode(whosends(chan->ci), chan->name, merge_args(ac, av)); - - return; - } - - ac--; - - while ((mode = *modes++)) { - - switch (mode) { - case '+': - add = 1; - continue; - case '-': - add = 0; - continue; - } - - if (((int) mode) < 0) { - if (debug) - alog("Debug: Malformed mode detected on %s.", chan->name); - continue; - } - - if ((cum = &cumodes[(int) mode])->status != 0) { - if (ac == 0) { - alog("channel: mode %c%c with no parameter (?) for channel %s", add ? '+' : '-', mode, chan->name); - continue; - } - ac--; - av++; - - if ((cum->flags & CUF_PROTECT_BOTSERV) && !add) { - if ((bi = findbot(*av))) { - if (!botmode || botmode != mode) { - ircdproto->SendMode(bi, chan->name, "+%c %s", - mode, bi->nick); - botmode = mode; - continue; - } else { - botmode = mode; - continue; - } - } - } else { - if ((bi = findbot(*av))) { - continue; - } - } - - if (!(user = finduser(*av)) - && !(UseTS6 && ircd->ts6 && (user = find_byuid(*av)))) { - if (debug) { - alog("debug: MODE %s %c%c for nonexistent user %s", - chan->name, (add ? '+' : '-'), mode, *av); - } - continue; - } - - if (debug) - alog("debug: Setting %c%c on %s for %s", (add ? '+' : '-'), - mode, chan->name, user->nick); - - if (add) { - chan_set_user_status(chan, user, cum->status); - /* If this does +o, remove any DEOPPED flag */ - if (cum->status & CUS_OP) - chan_remove_user_status(chan, user, CUS_DEOPPED); - } else { - chan_remove_user_status(chan, user, cum->status); - } - - } else if ((cbm = &cbmodes[(int) mode])->flag != 0) { - if (check >= 0) { - if (add) - chan->mode |= cbm->flag; - else - chan->mode &= ~cbm->flag; - } - - if (cbm->setvalue) { - if (add || !(cbm->flags & CBM_MINUS_NO_ARG)) { - if (ac == 0) { - alog("channel: mode %c%c with no parameter (?) for channel %s", add ? '+' : '-', mode, chan->name); - continue; - } - ac--; - av++; - } - cbm->setvalue(chan, add ? *av : NULL); - } - - if (check < 0) { - if (add) - chan->mode |= cbm->flag; - else - chan->mode &= ~cbm->flag; - } - } else if ((cmm = &cmmodes[(int) mode])->addmask) { - if (ac == 0) { - alog("channel: mode %c%c with no parameter (?) for channel %s", add ? '+' : '-', mode, chan->name); - continue; - } - - ac--; - av++; - if (add) - cmm->addmask(chan, *av); - else - cmm->delmask(chan, *av); - } - } - - if (check > 0) { - check_modes(chan); - - if (check < 2) { - /* Walk through all users we've set modes for and see if they are - * valid. Invalid modes (like +o with SECUREOPS on) will be removed - */ - real_ac--; - real_av++; - for (i = 0; i < real_ac; i++) { - if ((user = finduser(*real_av)) && is_on_chan(chan, user)) - chan_set_correct_modes(user, chan, 0); - real_av++; - } - } - } + CBMode *cbm; + CMMode *cmm; + CUMode *cum; + unsigned char botmode = 0; + BotInfo *bi; + User *u, *user; + int i, real_ac = ac; + const char **real_av = av; + + if (debug) + alog("debug: Changing modes for %s to %s", chan->name, + merge_args(ac, av)); + + u = finduser(source); + if (u && (chan_get_user_status(chan, u) & CUS_DEOPPED)) { + char *s; + + if (debug) + alog("debug: Removing instead of setting due to DEOPPED flag"); + + /* Swap adding and removing of the modes */ + for (s = (char *)av[0]; *s; s++) { // XXX Unsafe cast, this needs reviewing -- CyberBotX + if (*s == '+') + *s = '-'; + else if (*s == '-') + *s = '+'; + } + + /* Set the resulting mode buffer */ + ircdproto->SendMode(whosends(chan->ci), chan->name, merge_args(ac, av)); + + return; + } + + ac--; + + while ((mode = *modes++)) { + + switch (mode) { + case '+': + add = 1; + continue; + case '-': + add = 0; + continue; + } + + if (((int) mode) < 0) { + if (debug) + alog("Debug: Malformed mode detected on %s.", chan->name); + continue; + } + + if ((cum = &cumodes[(int) mode])->status != 0) { + if (ac == 0) { + alog("channel: mode %c%c with no parameter (?) for channel %s", add ? '+' : '-', mode, chan->name); + continue; + } + ac--; + av++; + + if ((cum->flags & CUF_PROTECT_BOTSERV) && !add) { + if ((bi = findbot(*av))) { + if (!botmode || botmode != mode) { + ircdproto->SendMode(bi, chan->name, "+%c %s", + mode, bi->nick); + botmode = mode; + continue; + } else { + botmode = mode; + continue; + } + } + } else { + if ((bi = findbot(*av))) { + continue; + } + } + + if (!(user = finduser(*av)) + && !(UseTS6 && ircd->ts6 && (user = find_byuid(*av)))) { + if (debug) { + alog("debug: MODE %s %c%c for nonexistent user %s", + chan->name, (add ? '+' : '-'), mode, *av); + } + continue; + } + + if (debug) + alog("debug: Setting %c%c on %s for %s", (add ? '+' : '-'), + mode, chan->name, user->nick); + + if (add) { + chan_set_user_status(chan, user, cum->status); + /* If this does +o, remove any DEOPPED flag */ + if (cum->status & CUS_OP) + chan_remove_user_status(chan, user, CUS_DEOPPED); + } else { + chan_remove_user_status(chan, user, cum->status); + } + + } else if ((cbm = &cbmodes[(int) mode])->flag != 0) { + if (check >= 0) { + if (add) + chan->mode |= cbm->flag; + else + chan->mode &= ~cbm->flag; + } + + if (cbm->setvalue) { + if (add || !(cbm->flags & CBM_MINUS_NO_ARG)) { + if (ac == 0) { + alog("channel: mode %c%c with no parameter (?) for channel %s", add ? '+' : '-', mode, chan->name); + continue; + } + ac--; + av++; + } + cbm->setvalue(chan, add ? *av : NULL); + } + + if (check < 0) { + if (add) + chan->mode |= cbm->flag; + else + chan->mode &= ~cbm->flag; + } + } else if ((cmm = &cmmodes[(int) mode])->addmask) { + if (ac == 0) { + alog("channel: mode %c%c with no parameter (?) for channel %s", add ? '+' : '-', mode, chan->name); + continue; + } + + ac--; + av++; + if (add) + cmm->addmask(chan, *av); + else + cmm->delmask(chan, *av); + } + } + + if (check > 0) { + check_modes(chan); + + if (check < 2) { + /* Walk through all users we've set modes for and see if they are + * valid. Invalid modes (like +o with SECUREOPS on) will be removed + */ + real_ac--; + real_av++; + for (i = 0; i < real_ac; i++) { + if ((user = finduser(*real_av)) && is_on_chan(chan, user)) + chan_set_correct_modes(user, chan, 0); + real_av++; + } + } + } } /*************************************************************************/ @@ -327,28 +327,28 @@ void chan_set_modes(const char *source, Channel * chan, int ac, const char **av, void chan_set_user_status(Channel * chan, User * user, int16 status) { - struct u_chanlist *uc; - - if (debug >= 2) - alog("debug: setting user status (%d) on %s for %s", status, - user->nick, chan->name); - - if (HelpChannel && ircd->supporthelper && (status & CUS_OP) - && (stricmp(chan->name, HelpChannel) == 0) - && (!chan->ci || check_access(user, chan->ci, CA_AUTOOP))) { - if (debug) { - alog("debug: %s being given +h for having %d status in %s", - user->nick, status, chan->name); - } - common_svsmode(user, "+h", NULL); - } - - for (uc = user->chans; uc; uc = uc->next) { - if (uc->chan == chan) { - uc->status |= status; - break; - } - } + struct u_chanlist *uc; + + if (debug >= 2) + alog("debug: setting user status (%d) on %s for %s", status, + user->nick, chan->name); + + if (HelpChannel && ircd->supporthelper && (status & CUS_OP) + && (stricmp(chan->name, HelpChannel) == 0) + && (!chan->ci || check_access(user, chan->ci, CA_AUTOOP))) { + if (debug) { + alog("debug: %s being given +h for having %d status in %s", + user->nick, status, chan->name); + } + common_svsmode(user, "+h", NULL); + } + + for (uc = user->chans; uc; uc = uc->next) { + if (uc->chan == chan) { + uc->status |= status; + break; + } + } } /*************************************************************************/ @@ -359,29 +359,29 @@ void chan_set_user_status(Channel * chan, User * user, int16 status) Channel *findchan(const char *chan) { - Channel *c; - - if (!chan || !*chan) { - if (debug) { - alog("debug: findchan() called with NULL values"); - } - return NULL; - } - - if (debug >= 3) - alog("debug: findchan(%p)", chan); - c = chanlist[HASH(chan)]; - while (c) { - if (stricmp(c->name, chan) == 0) { - if (debug >= 3) - alog("debug: findchan(%s) -> %p", chan, (void *) c); - return c; - } - c = c->next; - } - if (debug >= 3) - alog("debug: findchan(%s) -> %p", chan, (void *) c); - return NULL; + Channel *c; + + if (!chan || !*chan) { + if (debug) { + alog("debug: findchan() called with NULL values"); + } + return NULL; + } + + if (debug >= 3) + alog("debug: findchan(%p)", chan); + c = chanlist[HASH(chan)]; + while (c) { + if (stricmp(c->name, chan) == 0) { + if (debug >= 3) + alog("debug: findchan(%s) -> %p", chan, (void *) c); + return c; + } + c = c->next; + } + if (debug >= 3) + alog("debug: findchan(%s) -> %p", chan, (void *) c); + return NULL; } /*************************************************************************/ @@ -395,27 +395,27 @@ static int next_index; Channel *firstchan(void) { - next_index = 0; - while (next_index < 1024 && current == NULL) - current = chanlist[next_index++]; - if (debug >= 3) - alog("debug: firstchan() returning %s", - current ? current->name : "NULL (end of list)"); - return current; + next_index = 0; + while (next_index < 1024 && current == NULL) + current = chanlist[next_index++]; + if (debug >= 3) + alog("debug: firstchan() returning %s", + current ? current->name : "NULL (end of list)"); + return current; } Channel *nextchan(void) { - if (current) - current = current->next; - if (!current && next_index < 1024) { - while (next_index < 1024 && current == NULL) - current = chanlist[next_index++]; - } - if (debug >= 3) - alog("debug: nextchan() returning %s", - current ? current->name : "NULL (end of list)"); - return current; + if (current) + current = current->next; + if (!current && next_index < 1024) { + while (next_index < 1024 && current == NULL) + current = chanlist[next_index++]; + } + if (debug >= 3) + alog("debug: nextchan() returning %s", + current ? current->name : "NULL (end of list)"); + return current; } /*************************************************************************/ @@ -424,52 +424,52 @@ Channel *nextchan(void) void get_channel_stats(long *nrec, long *memuse) { - long count = 0, mem = 0; - Channel *chan; - struct c_userlist *cu; - BanData *bd; - int i; - - for (i = 0; i < 1024; i++) { - for (chan = chanlist[i]; chan; chan = chan->next) { - count++; - mem += sizeof(*chan); - if (chan->topic) - mem += strlen(chan->topic) + 1; - if (chan->key) - mem += strlen(chan->key) + 1; - if (ircd->fmode) { - if (chan->flood) - mem += strlen(chan->flood) + 1; - } - if (ircd->Lmode) { - if (chan->redirect) - mem += strlen(chan->redirect) + 1; - } - mem += get_memuse(chan->bans); - if (ircd->except) { - mem += get_memuse(chan->excepts); - } - if (ircd->invitemode) { - mem += get_memuse(chan->invites); - } - for (cu = chan->users; cu; cu = cu->next) { - mem += sizeof(*cu); - if (cu->ud) { - mem += sizeof(*cu->ud); - if (cu->ud->lastline) - mem += strlen(cu->ud->lastline) + 1; - } - } - for (bd = chan->bd; bd; bd = bd->next) { - if (bd->mask) - mem += strlen(bd->mask) + 1; - mem += sizeof(*bd); - } - } - } - *nrec = count; - *memuse = mem; + long count = 0, mem = 0; + Channel *chan; + struct c_userlist *cu; + BanData *bd; + int i; + + for (i = 0; i < 1024; i++) { + for (chan = chanlist[i]; chan; chan = chan->next) { + count++; + mem += sizeof(*chan); + if (chan->topic) + mem += strlen(chan->topic) + 1; + if (chan->key) + mem += strlen(chan->key) + 1; + if (ircd->fmode) { + if (chan->flood) + mem += strlen(chan->flood) + 1; + } + if (ircd->Lmode) { + if (chan->redirect) + mem += strlen(chan->redirect) + 1; + } + mem += get_memuse(chan->bans); + if (ircd->except) { + mem += get_memuse(chan->excepts); + } + if (ircd->invitemode) { + mem += get_memuse(chan->invites); + } + for (cu = chan->users; cu; cu = cu->next) { + mem += sizeof(*cu); + if (cu->ud) { + mem += sizeof(*cu->ud); + if (cu->ud->lastline) + mem += strlen(cu->ud->lastline) + 1; + } + } + for (bd = chan->bd; bd; bd = bd->next) { + if (bd->mask) + mem += strlen(bd->mask) + 1; + mem += sizeof(*bd); + } + } + } + *nrec = count; + *memuse = mem; } /*************************************************************************/ @@ -478,13 +478,13 @@ void get_channel_stats(long *nrec, long *memuse) int is_on_chan(Channel * c, User * u) { - struct u_chanlist *uc; + struct u_chanlist *uc; - for (uc = u->chans; uc; uc = uc->next) - if (uc->chan == c) - return 1; + for (uc = u->chans; uc; uc = uc->next) + if (uc->chan == c) + return 1; - return 0; + return 0; } /*************************************************************************/ @@ -494,17 +494,17 @@ int is_on_chan(Channel * c, User * u) User *nc_on_chan(Channel * c, NickCore * nc) { - struct c_userlist *u; + struct c_userlist *u; - if (!c || !nc) - return NULL; + if (!c || !nc) + return NULL; - for (u = c->users; u; u = u->next) { - if (u->user->na && u->user->na->nc == nc - && nick_recognized(u->user)) - return u->user; - } - return NULL; + for (u = c->users; u; u = u->next) { + if (u->user->na && u->user->na->nc == nc + && nick_recognized(u->user)) + return u->user; + } + return NULL; } /*************************************************************************/ @@ -517,76 +517,76 @@ User *nc_on_chan(Channel * c, NickCore * nc) void do_join(const char *source, int ac, const char **av) { - User *user; - Channel *chan; - char *s, *t; - struct u_chanlist *c, *nextc; - char *channame; - time_t ts = time(NULL); - - if (UseTS6 && ircd->ts6) { - user = find_byuid(source); - if (!user) - user = finduser(source); - } else { - user = finduser(source); - } - if (!user) { - if (debug) { - alog("debug: JOIN from nonexistent user %s: %s", source, - merge_args(ac, av)); - } - return; - } - - t = (char *)av[0]; // XXX Unsafe cast, this needs reviewing -- CyberBotX - while (*(s = t)) { - t = s + strcspn(s, ","); - if (*t) - *t++ = 0; - - if (*s == '0') { - c = user->chans; - while (c) { - nextc = c->next; - channame = sstrdup(c->chan->name); - send_event(EVENT_PART_CHANNEL, 3, EVENT_START, user->nick, - channame); - chan_deluser(user, c->chan); - send_event(EVENT_PART_CHANNEL, 3, EVENT_STOP, user->nick, - channame); - free(channame); - free(c); - c = nextc; - } - user->chans = NULL; - continue; - } - - /* how about not triggering the JOIN event on an actual /part :) -certus */ - send_event(EVENT_JOIN_CHANNEL, 3, EVENT_START, source, s); - - /* Make sure check_kick comes before chan_adduser, so banned users - * don't get to see things like channel keys. */ - /* If channel already exists, check_kick() will use correct TS. - * Otherwise, we lose. */ - if (check_kick(user, s, ts)) - continue; - - if (ac == 2) { - if (debug) { - alog("debug: recieved a new TS for JOIN: %ld", - (long int) ts); - } - ts = strtoul(av[1], NULL, 10); - } - - chan = findchan(s); - chan = join_user_update(user, chan, s, ts); - chan_set_correct_modes(user, chan, 1); - - send_event(EVENT_JOIN_CHANNEL, 3, EVENT_STOP, source, s); - } + User *user; + Channel *chan; + char *s, *t; + struct u_chanlist *c, *nextc; + char *channame; + time_t ts = time(NULL); + + if (UseTS6 && ircd->ts6) { + user = find_byuid(source); + if (!user) + user = finduser(source); + } else { + user = finduser(source); + } + if (!user) { + if (debug) { + alog("debug: JOIN from nonexistent user %s: %s", source, + merge_args(ac, av)); + } + return; + } + + t = (char *)av[0]; // XXX Unsafe cast, this needs reviewing -- CyberBotX + while (*(s = t)) { + t = s + strcspn(s, ","); + if (*t) + *t++ = 0; + + if (*s == '0') { + c = user->chans; + while (c) { + nextc = c->next; + channame = sstrdup(c->chan->name); + send_event(EVENT_PART_CHANNEL, 3, EVENT_START, user->nick, + channame); + chan_deluser(user, c->chan); + send_event(EVENT_PART_CHANNEL, 3, EVENT_STOP, user->nick, + channame); + free(channame); + free(c); + c = nextc; + } + user->chans = NULL; + continue; + } + + /* how about not triggering the JOIN event on an actual /part :) -certus */ + send_event(EVENT_JOIN_CHANNEL, 3, EVENT_START, source, s); + + /* Make sure check_kick comes before chan_adduser, so banned users + * don't get to see things like channel keys. */ + /* If channel already exists, check_kick() will use correct TS. + * Otherwise, we lose. */ + if (check_kick(user, s, ts)) + continue; + + if (ac == 2) { + if (debug) { + alog("debug: recieved a new TS for JOIN: %ld", + (long int) ts); + } + ts = strtoul(av[1], NULL, 10); + } + + chan = findchan(s); + chan = join_user_update(user, chan, s, ts); + chan_set_correct_modes(user, chan, 1); + + send_event(EVENT_JOIN_CHANNEL, 3, EVENT_STOP, source, s); + } } /*************************************************************************/ @@ -599,59 +599,59 @@ void do_join(const char *source, int ac, const char **av) void do_kick(const char *source, int ac, const char **av) { - BotInfo *bi; - ChannelInfo *ci; - User *user; - char *s, *t; - struct u_chanlist *c; - - t = (char *)av[1]; // XXX unsafe cast, this needs reviewing -- w00t - while (*(s = t)) { - t = s + strcspn(s, ","); - if (*t) - *t++ = 0; - - /* If it is the bot that is being kicked, we make it rejoin the - * channel and stop immediately. - * --lara - */ - if (s_BotServ && (bi = findbot(s)) && (ci = cs_findchan(av[0]))) { - bot_join(ci); - continue; - } - - if (UseTS6 && ircd->ts6) { - user = find_byuid(s); - if (!user) { - user = finduser(s); - } - } else { - user = finduser(s); - } - if (!user) { - if (debug) { - alog("debug: KICK for nonexistent user %s on %s: %s", s, - av[0], merge_args(ac - 2, av + 2)); - } - continue; - } - if (debug) { - alog("debug: kicking %s from %s", user->nick, av[0]); - } - for (c = user->chans; c && stricmp(av[0], c->chan->name) != 0; - c = c->next); - if (c) { - send_event(EVENT_CHAN_KICK, 2, user->nick, av[0]); - chan_deluser(user, c->chan); - if (c->next) - c->next->prev = c->prev; - if (c->prev) - c->prev->next = c->next; - else - user->chans = c->next; - free(c); - } - } + BotInfo *bi; + ChannelInfo *ci; + User *user; + char *s, *t; + struct u_chanlist *c; + + t = (char *)av[1]; // XXX unsafe cast, this needs reviewing -- w00t + while (*(s = t)) { + t = s + strcspn(s, ","); + if (*t) + *t++ = 0; + + /* If it is the bot that is being kicked, we make it rejoin the + * channel and stop immediately. + * --lara + */ + if (s_BotServ && (bi = findbot(s)) && (ci = cs_findchan(av[0]))) { + bot_join(ci); + continue; + } + + if (UseTS6 && ircd->ts6) { + user = find_byuid(s); + if (!user) { + user = finduser(s); + } + } else { + user = finduser(s); + } + if (!user) { + if (debug) { + alog("debug: KICK for nonexistent user %s on %s: %s", s, + av[0], merge_args(ac - 2, av + 2)); + } + continue; + } + if (debug) { + alog("debug: kicking %s from %s", user->nick, av[0]); + } + for (c = user->chans; c && stricmp(av[0], c->chan->name) != 0; + c = c->next); + if (c) { + send_event(EVENT_CHAN_KICK, 2, user->nick, av[0]); + chan_deluser(user, c->chan); + if (c->next) + c->next->prev = c->prev; + if (c->prev) + c->prev->next = c->next; + else + user->chans = c->next; + free(c); + } + } } /*************************************************************************/ @@ -663,57 +663,57 @@ void do_kick(const char *source, int ac, const char **av) void do_part(const char *source, int ac, const char **av) { - User *user; - char *s, *t; - struct u_chanlist *c; - char *channame; - - if (UseTS6 && ircd->ts6) { - user = find_byuid(source); - if (!user) - user = finduser(source); - } else { - user = finduser(source); - } - if (!user) { - if (debug) { - alog("debug: PART from nonexistent user %s: %s", source, - merge_args(ac, av)); - } - return; - } - t = (char *)av[0]; // XXX Unsafe cast, this needs reviewing -- CyberBotX - while (*(s = t)) { - t = s + strcspn(s, ","); - if (*t) - *t++ = 0; - if (debug) - alog("debug: %s leaves %s", source, s); - for (c = user->chans; c && stricmp(s, c->chan->name) != 0; - c = c->next); - if (c) { - if (!c->chan) { - alog("user: BUG parting %s: channel entry found but c->chan NULL", s); - return; - } - channame = sstrdup(c->chan->name); - send_event(EVENT_PART_CHANNEL, (ac >= 2 ? 4 : 3), EVENT_START, - user->nick, channame, (ac >= 2 ? av[1] : "")); - - chan_deluser(user, c->chan); - if (c->next) - c->next->prev = c->prev; - if (c->prev) - c->prev->next = c->next; - else - user->chans = c->next; - free(c); - - send_event(EVENT_PART_CHANNEL, (ac >= 2 ? 4 : 3), EVENT_STOP, - user->nick, channame, (ac >= 2 ? av[1] : "")); - free(channame); - } - } + User *user; + char *s, *t; + struct u_chanlist *c; + char *channame; + + if (UseTS6 && ircd->ts6) { + user = find_byuid(source); + if (!user) + user = finduser(source); + } else { + user = finduser(source); + } + if (!user) { + if (debug) { + alog("debug: PART from nonexistent user %s: %s", source, + merge_args(ac, av)); + } + return; + } + t = (char *)av[0]; // XXX Unsafe cast, this needs reviewing -- CyberBotX + while (*(s = t)) { + t = s + strcspn(s, ","); + if (*t) + *t++ = 0; + if (debug) + alog("debug: %s leaves %s", source, s); + for (c = user->chans; c && stricmp(s, c->chan->name) != 0; + c = c->next); + if (c) { + if (!c->chan) { + alog("user: BUG parting %s: channel entry found but c->chan NULL", s); + return; + } + channame = sstrdup(c->chan->name); + send_event(EVENT_PART_CHANNEL, (ac >= 2 ? 4 : 3), EVENT_START, + user->nick, channame, (ac >= 2 ? av[1] : "")); + + chan_deluser(user, c->chan); + if (c->next) + c->next->prev = c->prev; + if (c->prev) + c->prev->next = c->next; + else + user->chans = c->next; + free(c); + + send_event(EVENT_PART_CHANNEL, (ac >= 2 ? 4 : 3), EVENT_STOP, + user->nick, channame, (ac >= 2 ? av[1] : "")); + free(channame); + } + } } /*************************************************************************/ @@ -756,357 +756,357 @@ void do_part(const char *source, int ac, const char **av) void do_sjoin(const char *source, int ac, const char **av) { - Channel *c; - User *user; - Server *serv; - struct c_userlist *cu; - const char *s = NULL; - char *end, cubuf[7], *end2; + Channel *c; + User *user; + Server *serv; + struct c_userlist *cu; + const char *s = NULL; + char *end, cubuf[7], *end2; const char *modes[6]; - int is_sqlined = 0; - int ts = 0; - int is_created = 0; - int keep_their_modes = 1; - - serv = findserver(servlist, source); - - if (ircd->sjb64) { - ts = base64dects(av[0]); - } else { - ts = strtoul(av[0], NULL, 10); - } - c = findchan(av[1]); - if (c != NULL) { - if (c->creation_time == 0 || ts == 0) - c->creation_time = 0; - else if (c->creation_time > ts) { - c->creation_time = ts; - for (cu = c->users; cu; cu = cu->next) { - /* XXX */ - modes[0] = "-ov"; - modes[1] = cu->user->nick; - modes[2] = cu->user->nick; - chan_set_modes(source, c, 3, modes, 2); - } - if (c->ci && c->ci->bi) { - /* This is ugly, but it always works */ - ircdproto->SendPart(c->ci->bi, c->name, "TS reop"); - bot_join(c->ci); - } - /* XXX simple modes and bans */ - } else if (c->creation_time < ts) - keep_their_modes = 0; - } else - is_created = 1; - - /* Double check to avoid unknown modes that need parameters */ - if (ac >= 4) { - if (ircd->chansqline) { - if (!c) - is_sqlined = check_chan_sqline(av[1]); - } - - cubuf[0] = '+'; - modes[0] = cubuf; - - /* We make all the users join */ - s = av[ac - 1]; /* Users are always the last element */ - - while (*s) { - end = strchr(s, ' '); - if (end) - *end = 0; - - end2 = cubuf + 1; - - - if (ircd->sjoinbanchar) { - if (*s == ircd->sjoinbanchar && keep_their_modes) { - add_ban(c, myStrGetToken(s, ircd->sjoinbanchar, 1)); - if (!end) - break; - s = end + 1; - continue; - } - } - if (ircd->sjoinexchar) { - if (*s == ircd->sjoinexchar && keep_their_modes) { - add_exception(c, - myStrGetToken(s, ircd->sjoinexchar, 1)); - if (!end) - break; - s = end + 1; - continue; - } - } - - if (ircd->sjoininvchar) { - if (*s == ircd->sjoininvchar && keep_their_modes) { - add_invite(c, myStrGetToken(s, ircd->sjoininvchar, 1)); - if (!end) - break; - s = end + 1; - continue; - } - } - - while (csmodes[(int) *s] != 0) - *end2++ = csmodes[(int) *s++]; - *end2 = 0; - - - if (UseTS6 && ircd->ts6) { - user = find_byuid(s); - if (!user) - user = finduser(s); - } else { - user = finduser(s); - } - - if (!user) { - if (debug) { - alog("debug: SJOIN for nonexistent user %s on %s", s, - av[1]); - } - return; - } - - if (is_sqlined && !is_oper(user)) { - ircdproto->SendKick(findbot(s_OperServ), av[1], s, "Q-Lined"); - } else { - if (!check_kick(user, av[1], ts)) { - send_event(EVENT_JOIN_CHANNEL, 3, EVENT_START, - user->nick, av[1]); - - /* Make the user join; if the channel does not exist it - * will be created there. This ensures that the channel - * is not created to be immediately destroyed, and - * that the locked key or topic is not shown to anyone - * who joins the channel when empty. - */ - c = join_user_update(user, c, av[1], ts); - - /* We update user mode on the channel */ - if (end2 - cubuf > 1 && keep_their_modes) { - int i; - - for (i = 1; i < end2 - cubuf; i++) - modes[i] = user->nick; - chan_set_modes(source, c, 1 + (end2 - cubuf - 1), - modes, 2); - } - - if (c->ci && (!serv || is_sync(serv)) - && !c->topic_sync) - restore_topic(c->name); - chan_set_correct_modes(user, c, 1); - - send_event(EVENT_JOIN_CHANNEL, 3, EVENT_STOP, - user->nick, av[1]); - } - } - - if (!end) - break; - s = end + 1; - } - - if (c && keep_their_modes) { - /* We now update the channel mode. */ - chan_set_modes(source, c, ac - 3, &av[2], 2); - } - - /* Unreal just had to be different */ - } else if (ac == 3 && !ircd->ts6) { - if (ircd->chansqline) { - if (!c) - is_sqlined = check_chan_sqline(av[1]); - } - - cubuf[0] = '+'; - modes[0] = cubuf; - - /* We make all the users join */ - s = av[2]; /* Users are always the last element */ - - while (*s) { - end = strchr(s, ' '); - if (end) - *end = 0; - - end2 = cubuf + 1; - - while (csmodes[(int) *s] != 0) - *end2++ = csmodes[(int) *s++]; - *end2 = 0; - - if (UseTS6 && ircd->ts6) { - user = find_byuid(s); - if (!user) - user = finduser(s); - } else { - user = finduser(s); - } - - if (!user) { - if (debug) { - alog("debug: SJOIN for nonexistent user %s on %s", s, - av[1]); - } - return; - } - - if (is_sqlined && !is_oper(user)) { - ircdproto->SendKick(findbot(s_OperServ), av[1], s, "Q-Lined"); - } else { - if (!check_kick(user, av[1], ts)) { - send_event(EVENT_JOIN_CHANNEL, 3, EVENT_START, - user->nick, av[1]); - - /* Make the user join; if the channel does not exist it - * will be created there. This ensures that the channel - * is not created to be immediately destroyed, and - * that the locked key or topic is not shown to anyone - * who joins the channel when empty. - */ - c = join_user_update(user, c, av[1], ts); - - /* We update user mode on the channel */ - if (end2 - cubuf > 1 && keep_their_modes) { - int i; - - for (i = 1; i < end2 - cubuf; i++) - modes[i] = user->nick; - chan_set_modes(source, c, 1 + (end2 - cubuf - 1), - modes, 2); - } - - chan_set_correct_modes(user, c, 1); - - send_event(EVENT_JOIN_CHANNEL, 3, EVENT_STOP, - user->nick, av[1]); - } - } - - if (!end) - break; - s = end + 1; - } - } else if (ac == 3 && ircd->ts6) { - if (ircd->chansqline) { - if (!c) - is_sqlined = check_chan_sqline(av[1]); - } - - cubuf[0] = '+'; - modes[0] = cubuf; - - /* We make all the users join */ - s = sstrdup(source); /* Users are always the last element */ - - while (*s) { - end = strchr(s, ' '); - if (end) - *end = 0; - - end2 = cubuf + 1; - - while (csmodes[(int) *s] != 0) - *end2++ = csmodes[(int) *s++]; - *end2 = 0; - - if (UseTS6 && ircd->ts6) { - user = find_byuid(s); - if (!user) - user = finduser(s); - } else { - user = finduser(s); - } - if (!user) { - if (debug) { - alog("debug: SJOIN for nonexistent user %s on %s", s, - av[1]); - } - free((char *)s); - return; - } - - if (is_sqlined && !is_oper(user)) { - ircdproto->SendKick(findbot(s_OperServ), av[1], s, "Q-Lined"); - } else { - if (!check_kick(user, av[1], ts)) { - send_event(EVENT_JOIN_CHANNEL, 3, EVENT_START, - user->nick, av[1]); - - /* Make the user join; if the channel does not exist it - * will be created there. This ensures that the channel - * is not created to be immediately destroyed, and - * that the locked key or topic is not shown to anyone - * who joins the channel when empty. - */ - c = join_user_update(user, c, av[1], ts); - - /* We update user mode on the channel */ - if (end2 - cubuf > 1 && keep_their_modes) { - int i; - - for (i = 1; i < end2 - cubuf; i++) - modes[i] = user->nick; - chan_set_modes(source, c, 1 + (end2 - cubuf - 1), - modes, 2); - } - - chan_set_correct_modes(user, c, 1); - - send_event(EVENT_JOIN_CHANNEL, 3, EVENT_STOP, - user->nick, av[1]); - } - } - - if (!end) - break; - s = end + 1; - } - free((char *)s); - } else if (ac == 2) { - if (UseTS6 && ircd->ts6) { - user = find_byuid(source); - if (!user) - user = finduser(source); - } else { - user = finduser(source); - } - if (!user) { - if (debug) { - alog("debug: SJOIN for nonexistent user %s on %s", source, - av[1]); - } - return; - } - - if (check_kick(user, av[1], ts)) - return; - - if (ircd->chansqline) { - if (!c) - is_sqlined = check_chan_sqline(av[1]); - } - - if (is_sqlined && !is_oper(user)) { - ircdproto->SendKick(findbot(s_OperServ), av[1], user->nick, "Q-Lined"); - } else { - send_event(EVENT_JOIN_CHANNEL, 3, EVENT_START, user->nick, - av[1]); - - c = join_user_update(user, c, av[1], ts); - if (is_created && c->ci) - restore_topic(c->name); - chan_set_correct_modes(user, c, 1); - - send_event(EVENT_JOIN_CHANNEL, 3, EVENT_STOP, user->nick, - av[1]); - } - } + int is_sqlined = 0; + int ts = 0; + int is_created = 0; + int keep_their_modes = 1; + + serv = findserver(servlist, source); + + if (ircd->sjb64) { + ts = base64dects(av[0]); + } else { + ts = strtoul(av[0], NULL, 10); + } + c = findchan(av[1]); + if (c != NULL) { + if (c->creation_time == 0 || ts == 0) + c->creation_time = 0; + else if (c->creation_time > ts) { + c->creation_time = ts; + for (cu = c->users; cu; cu = cu->next) { + /* XXX */ + modes[0] = "-ov"; + modes[1] = cu->user->nick; + modes[2] = cu->user->nick; + chan_set_modes(source, c, 3, modes, 2); + } + if (c->ci && c->ci->bi) { + /* This is ugly, but it always works */ + ircdproto->SendPart(c->ci->bi, c->name, "TS reop"); + bot_join(c->ci); + } + /* XXX simple modes and bans */ + } else if (c->creation_time < ts) + keep_their_modes = 0; + } else + is_created = 1; + + /* Double check to avoid unknown modes that need parameters */ + if (ac >= 4) { + if (ircd->chansqline) { + if (!c) + is_sqlined = check_chan_sqline(av[1]); + } + + cubuf[0] = '+'; + modes[0] = cubuf; + + /* We make all the users join */ + s = av[ac - 1]; /* Users are always the last element */ + + while (*s) { + end = strchr(s, ' '); + if (end) + *end = 0; + + end2 = cubuf + 1; + + + if (ircd->sjoinbanchar) { + if (*s == ircd->sjoinbanchar && keep_their_modes) { + add_ban(c, myStrGetToken(s, ircd->sjoinbanchar, 1)); + if (!end) + break; + s = end + 1; + continue; + } + } + if (ircd->sjoinexchar) { + if (*s == ircd->sjoinexchar && keep_their_modes) { + add_exception(c, + myStrGetToken(s, ircd->sjoinexchar, 1)); + if (!end) + break; + s = end + 1; + continue; + } + } + + if (ircd->sjoininvchar) { + if (*s == ircd->sjoininvchar && keep_their_modes) { + add_invite(c, myStrGetToken(s, ircd->sjoininvchar, 1)); + if (!end) + break; + s = end + 1; + continue; + } + } + + while (csmodes[(int) *s] != 0) + *end2++ = csmodes[(int) *s++]; + *end2 = 0; + + + if (UseTS6 && ircd->ts6) { + user = find_byuid(s); + if (!user) + user = finduser(s); + } else { + user = finduser(s); + } + + if (!user) { + if (debug) { + alog("debug: SJOIN for nonexistent user %s on %s", s, + av[1]); + } + return; + } + + if (is_sqlined && !is_oper(user)) { + ircdproto->SendKick(findbot(s_OperServ), av[1], s, "Q-Lined"); + } else { + if (!check_kick(user, av[1], ts)) { + send_event(EVENT_JOIN_CHANNEL, 3, EVENT_START, + user->nick, av[1]); + + /* Make the user join; if the channel does not exist it + * will be created there. This ensures that the channel + * is not created to be immediately destroyed, and + * that the locked key or topic is not shown to anyone + * who joins the channel when empty. + */ + c = join_user_update(user, c, av[1], ts); + + /* We update user mode on the channel */ + if (end2 - cubuf > 1 && keep_their_modes) { + int i; + + for (i = 1; i < end2 - cubuf; i++) + modes[i] = user->nick; + chan_set_modes(source, c, 1 + (end2 - cubuf - 1), + modes, 2); + } + + if (c->ci && (!serv || is_sync(serv)) + && !c->topic_sync) + restore_topic(c->name); + chan_set_correct_modes(user, c, 1); + + send_event(EVENT_JOIN_CHANNEL, 3, EVENT_STOP, + user->nick, av[1]); + } + } + + if (!end) + break; + s = end + 1; + } + + if (c && keep_their_modes) { + /* We now update the channel mode. */ + chan_set_modes(source, c, ac - 3, &av[2], 2); + } + + /* Unreal just had to be different */ + } else if (ac == 3 && !ircd->ts6) { + if (ircd->chansqline) { + if (!c) + is_sqlined = check_chan_sqline(av[1]); + } + + cubuf[0] = '+'; + modes[0] = cubuf; + + /* We make all the users join */ + s = av[2]; /* Users are always the last element */ + + while (*s) { + end = strchr(s, ' '); + if (end) + *end = 0; + + end2 = cubuf + 1; + + while (csmodes[(int) *s] != 0) + *end2++ = csmodes[(int) *s++]; + *end2 = 0; + + if (UseTS6 && ircd->ts6) { + user = find_byuid(s); + if (!user) + user = finduser(s); + } else { + user = finduser(s); + } + + if (!user) { + if (debug) { + alog("debug: SJOIN for nonexistent user %s on %s", s, + av[1]); + } + return; + } + + if (is_sqlined && !is_oper(user)) { + ircdproto->SendKick(findbot(s_OperServ), av[1], s, "Q-Lined"); + } else { + if (!check_kick(user, av[1], ts)) { + send_event(EVENT_JOIN_CHANNEL, 3, EVENT_START, + user->nick, av[1]); + + /* Make the user join; if the channel does not exist it + * will be created there. This ensures that the channel + * is not created to be immediately destroyed, and + * that the locked key or topic is not shown to anyone + * who joins the channel when empty. + */ + c = join_user_update(user, c, av[1], ts); + + /* We update user mode on the channel */ + if (end2 - cubuf > 1 && keep_their_modes) { + int i; + + for (i = 1; i < end2 - cubuf; i++) + modes[i] = user->nick; + chan_set_modes(source, c, 1 + (end2 - cubuf - 1), + modes, 2); + } + + chan_set_correct_modes(user, c, 1); + + send_event(EVENT_JOIN_CHANNEL, 3, EVENT_STOP, + user->nick, av[1]); + } + } + + if (!end) + break; + s = end + 1; + } + } else if (ac == 3 && ircd->ts6) { + if (ircd->chansqline) { + if (!c) + is_sqlined = check_chan_sqline(av[1]); + } + + cubuf[0] = '+'; + modes[0] = cubuf; + + /* We make all the users join */ + s = sstrdup(source); /* Users are always the last element */ + + while (*s) { + end = strchr(s, ' '); + if (end) + *end = 0; + + end2 = cubuf + 1; + + while (csmodes[(int) *s] != 0) + *end2++ = csmodes[(int) *s++]; + *end2 = 0; + + if (UseTS6 && ircd->ts6) { + user = find_byuid(s); + if (!user) + user = finduser(s); + } else { + user = finduser(s); + } + if (!user) { + if (debug) { + alog("debug: SJOIN for nonexistent user %s on %s", s, + av[1]); + } + free((char *)s); + return; + } + + if (is_sqlined && !is_oper(user)) { + ircdproto->SendKick(findbot(s_OperServ), av[1], s, "Q-Lined"); + } else { + if (!check_kick(user, av[1], ts)) { + send_event(EVENT_JOIN_CHANNEL, 3, EVENT_START, + user->nick, av[1]); + + /* Make the user join; if the channel does not exist it + * will be created there. This ensures that the channel + * is not created to be immediately destroyed, and + * that the locked key or topic is not shown to anyone + * who joins the channel when empty. + */ + c = join_user_update(user, c, av[1], ts); + + /* We update user mode on the channel */ + if (end2 - cubuf > 1 && keep_their_modes) { + int i; + + for (i = 1; i < end2 - cubuf; i++) + modes[i] = user->nick; + chan_set_modes(source, c, 1 + (end2 - cubuf - 1), + modes, 2); + } + + chan_set_correct_modes(user, c, 1); + + send_event(EVENT_JOIN_CHANNEL, 3, EVENT_STOP, + user->nick, av[1]); + } + } + + if (!end) + break; + s = end + 1; + } + free((char *)s); + } else if (ac == 2) { + if (UseTS6 && ircd->ts6) { + user = find_byuid(source); + if (!user) + user = finduser(source); + } else { + user = finduser(source); + } + if (!user) { + if (debug) { + alog("debug: SJOIN for nonexistent user %s on %s", source, + av[1]); + } + return; + } + + if (check_kick(user, av[1], ts)) + return; + + if (ircd->chansqline) { + if (!c) + is_sqlined = check_chan_sqline(av[1]); + } + + if (is_sqlined && !is_oper(user)) { + ircdproto->SendKick(findbot(s_OperServ), av[1], user->nick, "Q-Lined"); + } else { + send_event(EVENT_JOIN_CHANNEL, 3, EVENT_START, user->nick, + av[1]); + + c = join_user_update(user, c, av[1], ts); + if (is_created && c->ci) + restore_topic(c->name); + chan_set_correct_modes(user, c, 1); + + send_event(EVENT_JOIN_CHANNEL, 3, EVENT_STOP, user->nick, + av[1]); + } + } } @@ -1116,64 +1116,64 @@ void do_sjoin(const char *source, int ac, const char **av) void do_cmode(const char *source, int ac, const char **av) { - Channel *chan; - ChannelInfo *ci = NULL; - unsigned int i; - const char *t; - - if (ircdcap->tsmode) { - /* TSMODE for bahamut - leave this code out to break MODEs. -GD */ - /* if they don't send it in CAPAB check if we just want to enable it */ - if (uplink_capab & ircdcap->tsmode || UseTSMODE) { - for (i = 0; i < strlen(av[1]); i++) { - if (!isdigit(av[1][i])) - break; - } - if (av[1][i] == '\0') { - /* We have a valid TS field in av[1] now, so we can strip it off */ - /* After we swap av[0] and av[1] ofcourse to not break stuff! :) */ - t = av[0]; - av[0] = av[1]; - av[1] = t; - ac--; - av++; - } else { - alog("TSMODE enabled but MODE has no valid TS"); - } - } - } - - /* :42XAAAAAO TMODE 1106409026 #ircops +b *!*@*.aol.com */ - if (UseTS6 && ircd->ts6) { - if (isdigit(av[0][0])) { - ac--; - av++; - } - } - - chan = findchan(av[0]); - if (!chan) { - if (debug) { - ci = cs_findchan(av[0]); - if (!(ci && (ci->flags & CI_VERBOTEN))) - alog("debug: MODE %s for nonexistent channel %s", - merge_args(ac - 1, av + 1), av[0]); - } - return; - } - - /* This shouldn't trigger on +o, etc. */ - if (strchr(source, '.') && !av[1][strcspn(av[1], "bovahq")]) { - if (time(NULL) != chan->server_modetime) { - chan->server_modecount = 0; - chan->server_modetime = time(NULL); - } - chan->server_modecount++; - } - - ac--; - av++; - chan_set_modes(source, chan, ac, av, 1); + Channel *chan; + ChannelInfo *ci = NULL; + unsigned int i; + const char *t; + + if (ircdcap->tsmode) { + /* TSMODE for bahamut - leave this code out to break MODEs. -GD */ + /* if they don't send it in CAPAB check if we just want to enable it */ + if (uplink_capab & ircdcap->tsmode || UseTSMODE) { + for (i = 0; i < strlen(av[1]); i++) { + if (!isdigit(av[1][i])) + break; + } + if (av[1][i] == '\0') { + /* We have a valid TS field in av[1] now, so we can strip it off */ + /* After we swap av[0] and av[1] ofcourse to not break stuff! :) */ + t = av[0]; + av[0] = av[1]; + av[1] = t; + ac--; + av++; + } else { + alog("TSMODE enabled but MODE has no valid TS"); + } + } + } + + /* :42XAAAAAO TMODE 1106409026 #ircops +b *!*@*.aol.com */ + if (UseTS6 && ircd->ts6) { + if (isdigit(av[0][0])) { + ac--; + av++; + } + } + + chan = findchan(av[0]); + if (!chan) { + if (debug) { + ci = cs_findchan(av[0]); + if (!(ci && (ci->flags & CI_VERBOTEN))) + alog("debug: MODE %s for nonexistent channel %s", + merge_args(ac - 1, av + 1), av[0]); + } + return; + } + + /* This shouldn't trigger on +o, etc. */ + if (strchr(source, '.') && !av[1][strcspn(av[1], "bovahq")]) { + if (time(NULL) != chan->server_modetime) { + chan->server_modecount = 0; + chan->server_modetime = time(NULL); + } + chan->server_modecount++; + } + + ac--; + av++; + chan_set_modes(source, chan, ac, av, 1); } /*************************************************************************/ @@ -1182,76 +1182,76 @@ void do_cmode(const char *source, int ac, const char **av) void do_topic(const char *source, int ac, const char **av) { - Channel *c = findchan(av[0]); - ChannelInfo *ci; - int ts; - time_t topic_time; - char *topicsetter; - - if (ircd->sjb64) { - ts = base64dects(av[2]); - if (debug) { - alog("debug: encoded TOPIC TS %s converted to %d", av[2], ts); - } - } else { - ts = strtoul(av[2], NULL, 10); - } - - topic_time = ts; - - if (!c) { - if (debug) { - alog("debug: TOPIC %s for nonexistent channel %s", - merge_args(ac - 1, av + 1), av[0]); - } - return; - } - - /* We can be sure that the topic will be in sync here -GD */ - c->topic_sync = 1; - - ci = c->ci; - - /* For Unreal, cut off the ! and any futher part of the topic setter. - * This way, nick!ident@host setters will only show the nick. -GD - */ - topicsetter = myStrGetToken(av[1], '!', 0); - - /* If the current topic we have matches the last known topic for this - * channel exactly, there's no need to update anything and we can as - * well just return silently without updating anything. -GD - */ - if ((ac > 3) && *av[3] && ci && ci->last_topic - && (strcmp(av[3], ci->last_topic) == 0) - && (strcmp(topicsetter, ci->last_topic_setter) == 0)) { - free(topicsetter); - return; - } - - if (check_topiclock(c, topic_time)) { - free(topicsetter); - return; - } - - if (c->topic) { - free(c->topic); - c->topic = NULL; - } - if (ac > 3 && *av[3]) { - c->topic = sstrdup(av[3]); - } - - strscpy(c->topic_setter, topicsetter, sizeof(c->topic_setter)); - c->topic_time = topic_time; - free(topicsetter); - - record_topic(av[0]); - - if (ci && ci->last_topic) { - send_event(EVENT_TOPIC_UPDATED, 2, av[0], ci->last_topic); - } else { - send_event(EVENT_TOPIC_UPDATED, 2, av[0], ""); - } + Channel *c = findchan(av[0]); + ChannelInfo *ci; + int ts; + time_t topic_time; + char *topicsetter; + + if (ircd->sjb64) { + ts = base64dects(av[2]); + if (debug) { + alog("debug: encoded TOPIC TS %s converted to %d", av[2], ts); + } + } else { + ts = strtoul(av[2], NULL, 10); + } + + topic_time = ts; + + if (!c) { + if (debug) { + alog("debug: TOPIC %s for nonexistent channel %s", + merge_args(ac - 1, av + 1), av[0]); + } + return; + } + + /* We can be sure that the topic will be in sync here -GD */ + c->topic_sync = 1; + + ci = c->ci; + + /* For Unreal, cut off the ! and any futher part of the topic setter. + * This way, nick!ident@host setters will only show the nick. -GD + */ + topicsetter = myStrGetToken(av[1], '!', 0); + + /* If the current topic we have matches the last known topic for this + * channel exactly, there's no need to update anything and we can as + * well just return silently without updating anything. -GD + */ + if ((ac > 3) && *av[3] && ci && ci->last_topic + && (strcmp(av[3], ci->last_topic) == 0) + && (strcmp(topicsetter, ci->last_topic_setter) == 0)) { + free(topicsetter); + return; + } + + if (check_topiclock(c, topic_time)) { + free(topicsetter); + return; + } + + if (c->topic) { + free(c->topic); + c->topic = NULL; + } + if (ac > 3 && *av[3]) { + c->topic = sstrdup(av[3]); + } + + strscpy(c->topic_setter, topicsetter, sizeof(c->topic_setter)); + c->topic_time = topic_time; + free(topicsetter); + + record_topic(av[0]); + + if (ci && ci->last_topic) { + send_event(EVENT_TOPIC_UPDATED, 2, av[0], ci->last_topic); + } else { + send_event(EVENT_TOPIC_UPDATED, 2, av[0], ""); + } } /*************************************************************************/ @@ -1260,89 +1260,89 @@ void do_topic(const char *source, int ac, const char **av) void add_ban(Channel * chan, const char *mask) { - Entry *ban; - /* check for NULL values otherwise we will segfault */ - if (!chan || !mask) { - if (debug) { - alog("debug: add_ban called with NULL values"); - } - return; - } - - /* Check if the list already exists, if not create it. - * Create a new ban and add it to the list.. ~ Viper */ - if (!chan->bans) - chan->bans = list_create(); - ban = entry_add(chan->bans, mask); - - if (!ban) - fatal("Creating new ban entry failed"); - - /* Check whether it matches a botserv bot after adding internally - * and parsing it through cidr support. ~ Viper */ - if (s_BotServ && BSSmartJoin && chan->ci && chan->ci->bi - && chan->usercount >= BSMinUsers) { - BotInfo *bi = chan->ci->bi; - - if (entry_match(ban, bi->nick, bi->user, bi->host, 0)) { - ircdproto->SendMode(bi, chan->name, "-b %s", mask); - entry_delete(chan->bans, ban); - return; - } - } - - if (debug) - alog("debug: Added ban %s to channel %s", mask, chan->name); + Entry *ban; + /* check for NULL values otherwise we will segfault */ + if (!chan || !mask) { + if (debug) { + alog("debug: add_ban called with NULL values"); + } + return; + } + + /* Check if the list already exists, if not create it. + * Create a new ban and add it to the list.. ~ Viper */ + if (!chan->bans) + chan->bans = list_create(); + ban = entry_add(chan->bans, mask); + + if (!ban) + fatal("Creating new ban entry failed"); + + /* Check whether it matches a botserv bot after adding internally + * and parsing it through cidr support. ~ Viper */ + if (s_BotServ && BSSmartJoin && chan->ci && chan->ci->bi + && chan->usercount >= BSMinUsers) { + BotInfo *bi = chan->ci->bi; + + if (entry_match(ban, bi->nick, bi->user, bi->host, 0)) { + ircdproto->SendMode(bi, chan->name, "-b %s", mask); + entry_delete(chan->bans, ban); + return; + } + } + + if (debug) + alog("debug: Added ban %s to channel %s", mask, chan->name); } /*************************************************************************/ void add_exception(Channel * chan, const char *mask) { - Entry *exception; + Entry *exception; - if (!chan || !mask) { - if (debug) - alog("debug: add_exception called with NULL values"); - return; - } + if (!chan || !mask) { + if (debug) + alog("debug: add_exception called with NULL values"); + return; + } - /* Check if the list already exists, if not create it. - * Create a new exception and add it to the list.. ~ Viper */ - if (!chan->excepts) - chan->excepts = list_create(); - exception = entry_add(chan->excepts, mask); + /* Check if the list already exists, if not create it. + * Create a new exception and add it to the list.. ~ Viper */ + if (!chan->excepts) + chan->excepts = list_create(); + exception = entry_add(chan->excepts, mask); - if (!exception) - fatal("Creating new exception entry failed"); + if (!exception) + fatal("Creating new exception entry failed"); - if (debug) - alog("debug: Added except %s to channel %s", mask, chan->name); + if (debug) + alog("debug: Added except %s to channel %s", mask, chan->name); } /*************************************************************************/ void add_invite(Channel * chan, const char *mask) { - Entry *invite; + Entry *invite; - if (!chan || !mask) { - if (debug) - alog("debug: add_invite called with NULL values"); - return; - } + if (!chan || !mask) { + if (debug) + alog("debug: add_invite called with NULL values"); + return; + } - /* Check if the list already exists, if not create it. - * Create a new invite and add it to the list.. ~ Viper */ - if (!chan->invites) - chan->invites = list_create(); - invite = entry_add(chan->invites, mask); + /* Check if the list already exists, if not create it. + * Create a new invite and add it to the list.. ~ Viper */ + if (!chan->invites) + chan->invites = list_create(); + invite = entry_add(chan->invites, mask); - if (!invite) - fatal("Creating new exception entry failed"); + if (!invite) + fatal("Creating new exception entry failed"); - if (debug) - alog("debug: Added invite %s to channel %s", mask, chan->name); + if (debug) + alog("debug: Added invite %s to channel %s", mask, chan->name); } /*************************************************************************/ @@ -1358,161 +1358,161 @@ void add_invite(Channel * chan, const char *mask) **/ void chan_set_correct_modes(User * user, Channel * c, int give_modes) { - char *tmp; - char modebuf[BUFSIZE]; - char userbuf[BUFSIZE]; - int status; - int add_modes = 0; - int rem_modes = 0; - ChannelInfo *ci; - - if (!c || !(ci = c->ci)) - return; - - if ((ci->flags & CI_VERBOTEN) || (*(c->name) == '+')) - return; - - status = chan_get_user_status(c, user); - - if (debug) - alog("debug: Setting correct user modes for %s on %s (current status: %d, %sgiving modes)", user->nick, c->name, status, (give_modes ? "" : "not ")); - - /* Changed the second line of this if a bit, to make sure unregistered - * users can always get modes (IE: they always have autoop enabled). Before - * this change, you were required to have a registered nick to be able - * to receive modes. I wonder who added that... *looks at Rob* ;) -GD - */ - if (give_modes && (get_ignore(user->nick) == NULL) - && (!user->na || !(user->na->nc->flags & NI_AUTOOP))) { - if (ircd->owner && is_founder(user, ci)) - add_modes |= CUS_OWNER; - else if ((ircd->protect || ircd->admin) - && check_access(user, ci, CA_AUTOPROTECT)) - add_modes |= CUS_PROTECT; - if (check_access(user, ci, CA_AUTOOP)) - add_modes |= CUS_OP; - else if (ircd->halfop && check_access(user, ci, CA_AUTOHALFOP)) - add_modes |= CUS_HALFOP; - else if (check_access(user, ci, CA_AUTOVOICE)) - add_modes |= CUS_VOICE; - } - - /* We check if every mode they have is legally acquired here, and remove - * the modes that they're not allowed to have. But only if SECUREOPS is - * on, because else every mode is legal. -GD - * Unless the channel has just been created. -heinz - * Or the user matches CA_AUTODEOP... -GD - */ - if (((ci->flags & CI_SECUREOPS) || (c->usercount == 1) - || check_access(user, ci, CA_AUTODEOP)) - && !is_ulined(user->server->name)) { - if (ircd->owner && (status & CUS_OWNER) && !is_founder(user, ci)) - rem_modes |= CUS_OWNER; - if ((ircd->protect || ircd->admin) && (status & CUS_PROTECT) - && !check_access(user, ci, CA_AUTOPROTECT) - && !check_access(user, ci, CA_PROTECTME)) - rem_modes |= CUS_PROTECT; - if ((status & CUS_OP) && !check_access(user, ci, CA_AUTOOP) - && !check_access(user, ci, CA_OPDEOPME)) - rem_modes |= CUS_OP; - if (ircd->halfop && (status & CUS_HALFOP) - && !check_access(user, ci, CA_AUTOHALFOP) - && !check_access(user, ci, CA_HALFOPME)) - rem_modes |= CUS_HALFOP; - } - - /* No modes to add or remove, exit function -GD */ - if (!add_modes && !rem_modes) - return; - - /* No need for strn* functions for modebuf, as every possible string - * will always fit in. -GD - */ - strcpy(modebuf, ""); - strcpy(userbuf, ""); - if (add_modes > 0) { - strcat(modebuf, "+"); - if ((add_modes & CUS_OWNER) && !(status & CUS_OWNER)) { - tmp = stripModePrefix(ircd->ownerset); - strcat(modebuf, tmp); - free(tmp); - strcat(userbuf, " "); - strcat(userbuf, user->nick); - } else { - add_modes &= ~CUS_OWNER; - } - if ((add_modes & CUS_PROTECT) && !(status & CUS_PROTECT)) { - tmp = stripModePrefix(ircd->adminset); - strcat(modebuf, tmp); - free(tmp); - strcat(userbuf, " "); - strcat(userbuf, user->nick); - } else { - add_modes &= ~CUS_PROTECT; - } - if ((add_modes & CUS_OP) && !(status & CUS_OP)) { - strcat(modebuf, "o"); - strcat(userbuf, " "); - strcat(userbuf, user->nick); - rem_modes |= CUS_DEOPPED; - } else { - add_modes &= ~CUS_OP; - } - if ((add_modes & CUS_HALFOP) && !(status & CUS_HALFOP)) { - strcat(modebuf, "h"); - strcat(userbuf, " "); - strcat(userbuf, user->nick); - } else { - add_modes &= ~CUS_HALFOP; - } - if ((add_modes & CUS_VOICE) && !(status & CUS_VOICE)) { - strcat(modebuf, "v"); - strcat(userbuf, " "); - strcat(userbuf, user->nick); - } else { - add_modes &= ~CUS_VOICE; - } - } - if (rem_modes > 0) { - strcat(modebuf, "-"); - if (rem_modes & CUS_OWNER) { - tmp = stripModePrefix(ircd->ownerset); - strcat(modebuf, tmp); - free(tmp); - strcat(userbuf, " "); - strcat(userbuf, user->nick); - } - if (rem_modes & CUS_PROTECT) { - tmp = stripModePrefix(ircd->adminset); - strcat(modebuf, tmp); - free(tmp); - strcat(userbuf, " "); - strcat(userbuf, user->nick); - } - if (rem_modes & CUS_OP) { - strcat(modebuf, "o"); - strcat(userbuf, " "); - strcat(userbuf, user->nick); - add_modes |= CUS_DEOPPED; - } - if (rem_modes & CUS_HALFOP) { - strcat(modebuf, "h"); - strcat(userbuf, " "); - strcat(userbuf, user->nick); - } - } - - /* Here, both can be empty again due to the "isn't it set already?" - * checks above. -GD - */ - if (!add_modes && !rem_modes) - return; - - ircdproto->SendMode(whosends(ci), c->name, "%s%s", modebuf, userbuf); - if (add_modes > 0) - chan_set_user_status(c, user, add_modes); - if (rem_modes > 0) - chan_remove_user_status(c, user, rem_modes); + char *tmp; + char modebuf[BUFSIZE]; + char userbuf[BUFSIZE]; + int status; + int add_modes = 0; + int rem_modes = 0; + ChannelInfo *ci; + + if (!c || !(ci = c->ci)) + return; + + if ((ci->flags & CI_VERBOTEN) || (*(c->name) == '+')) + return; + + status = chan_get_user_status(c, user); + + if (debug) + alog("debug: Setting correct user modes for %s on %s (current status: %d, %sgiving modes)", user->nick, c->name, status, (give_modes ? "" : "not ")); + + /* Changed the second line of this if a bit, to make sure unregistered + * users can always get modes (IE: they always have autoop enabled). Before + * this change, you were required to have a registered nick to be able + * to receive modes. I wonder who added that... *looks at Rob* ;) -GD + */ + if (give_modes && (get_ignore(user->nick) == NULL) + && (!user->na || !(user->na->nc->flags & NI_AUTOOP))) { + if (ircd->owner && is_founder(user, ci)) + add_modes |= CUS_OWNER; + else if ((ircd->protect || ircd->admin) + && check_access(user, ci, CA_AUTOPROTECT)) + add_modes |= CUS_PROTECT; + if (check_access(user, ci, CA_AUTOOP)) + add_modes |= CUS_OP; + else if (ircd->halfop && check_access(user, ci, CA_AUTOHALFOP)) + add_modes |= CUS_HALFOP; + else if (check_access(user, ci, CA_AUTOVOICE)) + add_modes |= CUS_VOICE; + } + + /* We check if every mode they have is legally acquired here, and remove + * the modes that they're not allowed to have. But only if SECUREOPS is + * on, because else every mode is legal. -GD + * Unless the channel has just been created. -heinz + * Or the user matches CA_AUTODEOP... -GD + */ + if (((ci->flags & CI_SECUREOPS) || (c->usercount == 1) + || check_access(user, ci, CA_AUTODEOP)) + && !is_ulined(user->server->name)) { + if (ircd->owner && (status & CUS_OWNER) && !is_founder(user, ci)) + rem_modes |= CUS_OWNER; + if ((ircd->protect || ircd->admin) && (status & CUS_PROTECT) + && !check_access(user, ci, CA_AUTOPROTECT) + && !check_access(user, ci, CA_PROTECTME)) + rem_modes |= CUS_PROTECT; + if ((status & CUS_OP) && !check_access(user, ci, CA_AUTOOP) + && !check_access(user, ci, CA_OPDEOPME)) + rem_modes |= CUS_OP; + if (ircd->halfop && (status & CUS_HALFOP) + && !check_access(user, ci, CA_AUTOHALFOP) + && !check_access(user, ci, CA_HALFOPME)) + rem_modes |= CUS_HALFOP; + } + + /* No modes to add or remove, exit function -GD */ + if (!add_modes && !rem_modes) + return; + + /* No need for strn* functions for modebuf, as every possible string + * will always fit in. -GD + */ + strcpy(modebuf, ""); + strcpy(userbuf, ""); + if (add_modes > 0) { + strcat(modebuf, "+"); + if ((add_modes & CUS_OWNER) && !(status & CUS_OWNER)) { + tmp = stripModePrefix(ircd->ownerset); + strcat(modebuf, tmp); + free(tmp); + strcat(userbuf, " "); + strcat(userbuf, user->nick); + } else { + add_modes &= ~CUS_OWNER; + } + if ((add_modes & CUS_PROTECT) && !(status & CUS_PROTECT)) { + tmp = stripModePrefix(ircd->adminset); + strcat(modebuf, tmp); + free(tmp); + strcat(userbuf, " "); + strcat(userbuf, user->nick); + } else { + add_modes &= ~CUS_PROTECT; + } + if ((add_modes & CUS_OP) && !(status & CUS_OP)) { + strcat(modebuf, "o"); + strcat(userbuf, " "); + strcat(userbuf, user->nick); + rem_modes |= CUS_DEOPPED; + } else { + add_modes &= ~CUS_OP; + } + if ((add_modes & CUS_HALFOP) && !(status & CUS_HALFOP)) { + strcat(modebuf, "h"); + strcat(userbuf, " "); + strcat(userbuf, user->nick); + } else { + add_modes &= ~CUS_HALFOP; + } + if ((add_modes & CUS_VOICE) && !(status & CUS_VOICE)) { + strcat(modebuf, "v"); + strcat(userbuf, " "); + strcat(userbuf, user->nick); + } else { + add_modes &= ~CUS_VOICE; + } + } + if (rem_modes > 0) { + strcat(modebuf, "-"); + if (rem_modes & CUS_OWNER) { + tmp = stripModePrefix(ircd->ownerset); + strcat(modebuf, tmp); + free(tmp); + strcat(userbuf, " "); + strcat(userbuf, user->nick); + } + if (rem_modes & CUS_PROTECT) { + tmp = stripModePrefix(ircd->adminset); + strcat(modebuf, tmp); + free(tmp); + strcat(userbuf, " "); + strcat(userbuf, user->nick); + } + if (rem_modes & CUS_OP) { + strcat(modebuf, "o"); + strcat(userbuf, " "); + strcat(userbuf, user->nick); + add_modes |= CUS_DEOPPED; + } + if (rem_modes & CUS_HALFOP) { + strcat(modebuf, "h"); + strcat(userbuf, " "); + strcat(userbuf, user->nick); + } + } + + /* Here, both can be empty again due to the "isn't it set already?" + * checks above. -GD + */ + if (!add_modes && !rem_modes) + return; + + ircdproto->SendMode(whosends(ci), c->name, "%s%s", modebuf, userbuf); + if (add_modes > 0) + chan_set_user_status(c, user, add_modes); + if (rem_modes > 0) + chan_remove_user_status(c, user, rem_modes); } /*************************************************************************/ @@ -1524,57 +1524,57 @@ void chan_set_correct_modes(User * user, Channel * c, int give_modes) void chan_adduser2(User * user, Channel * c) { - struct c_userlist *u; - - u = (struct c_userlist *)scalloc(sizeof(struct c_userlist), 1); - u->next = c->users; - if (c->users) - c->users->prev = u; - c->users = u; - u->user = user; - c->usercount++; - - if (get_ignore(user->nick) == NULL) { - if (c->ci && (check_access(user, c->ci, CA_MEMO)) - && (c->ci->memos.memocount > 0)) { - if (c->ci->memos.memocount == 1) { - notice_lang(s_MemoServ, user, MEMO_X_ONE_NOTICE, - c->ci->memos.memocount, c->ci->name); - } else { - notice_lang(s_MemoServ, user, MEMO_X_MANY_NOTICE, - c->ci->memos.memocount, c->ci->name); - } - } - /* Added channelname to entrymsg - 30.03.2004, Certus */ - /* Also, don't send the entrymsg when bursting -GD */ - if (c->ci && c->ci->entry_message && is_sync(user->server)) - notice_user(whosends(c->ci)->nick, user, "[%s] %s", c->name, - c->ci->entry_message); - } - - /** - * We let the bot join even if it was an ignored user, as if we don't, - * and the ignored user dosnt just leave, the bot will never - * make it into the channel, leaving the channel botless even for - * legit users - Rob - **/ - if (s_BotServ && c->ci && c->ci->bi) { - if (c->usercount == BSMinUsers) - bot_join(c->ci); - if (c->usercount >= BSMinUsers && (c->ci->botflags & BS_GREET) - && user->na && user->na->nc->greet - && check_access(user, c->ci, CA_GREET)) { - /* Only display the greet if the main uplink we're connected - * to has synced, or we'll get greet-floods when the net - * recovers from a netsplit. -GD - */ - if (is_sync(user->server)) { - ircdproto->SendPrivmsg(c->ci->bi, c->name, "[%s] %s", - user->na->nick, user->na->nc->greet); - c->ci->bi->lastmsg = time(NULL); - } - } - } + struct c_userlist *u; + + u = (struct c_userlist *)scalloc(sizeof(struct c_userlist), 1); + u->next = c->users; + if (c->users) + c->users->prev = u; + c->users = u; + u->user = user; + c->usercount++; + + if (get_ignore(user->nick) == NULL) { + if (c->ci && (check_access(user, c->ci, CA_MEMO)) + && (c->ci->memos.memocount > 0)) { + if (c->ci->memos.memocount == 1) { + notice_lang(s_MemoServ, user, MEMO_X_ONE_NOTICE, + c->ci->memos.memocount, c->ci->name); + } else { + notice_lang(s_MemoServ, user, MEMO_X_MANY_NOTICE, + c->ci->memos.memocount, c->ci->name); + } + } + /* Added channelname to entrymsg - 30.03.2004, Certus */ + /* Also, don't send the entrymsg when bursting -GD */ + if (c->ci && c->ci->entry_message && is_sync(user->server)) + notice_user(whosends(c->ci)->nick, user, "[%s] %s", c->name, + c->ci->entry_message); + } + + /** + * We let the bot join even if it was an ignored user, as if we don't, + * and the ignored user dosnt just leave, the bot will never + * make it into the channel, leaving the channel botless even for + * legit users - Rob + **/ + if (s_BotServ && c->ci && c->ci->bi) { + if (c->usercount == BSMinUsers) + bot_join(c->ci); + if (c->usercount >= BSMinUsers && (c->ci->botflags & BS_GREET) + && user->na && user->na->nc->greet + && check_access(user, c->ci, CA_GREET)) { + /* Only display the greet if the main uplink we're connected + * to has synced, or we'll get greet-floods when the net + * recovers from a netsplit. -GD + */ + if (is_sync(user->server)) { + ircdproto->SendPrivmsg(c->ci->bi, c->name, "[%s] %s", + user->na->nick, user->na->nc->greet); + c->ci->bi->lastmsg = time(NULL); + } + } + } } /*************************************************************************/ @@ -1585,35 +1585,35 @@ void chan_adduser2(User * user, Channel * c) Channel *chan_create(const char *chan, time_t ts) { - Channel *c; - Channel **list; - - if (debug) - alog("debug: Creating channel %s", chan); - /* Allocate pre-cleared memory */ - c = (Channel *)scalloc(sizeof(Channel), 1); - strscpy(c->name, chan, sizeof(c->name)); - list = &chanlist[HASH(c->name)]; - c->next = *list; - if (*list) - (*list)->prev = c; - *list = c; - c->creation_time = ts; - /* Store ChannelInfo pointer in channel record */ - c->ci = cs_findchan(chan); - if (c->ci) - c->ci->c = c; - /* Restore locked modes and saved topic */ - if (c->ci) { - check_modes(c); - stick_all(c->ci); - } - - if (serv_uplink && is_sync(serv_uplink) && (!(c->topic_sync))) { - restore_topic(chan); - } - - return c; + Channel *c; + Channel **list; + + if (debug) + alog("debug: Creating channel %s", chan); + /* Allocate pre-cleared memory */ + c = (Channel *)scalloc(sizeof(Channel), 1); + strscpy(c->name, chan, sizeof(c->name)); + list = &chanlist[HASH(c->name)]; + c->next = *list; + if (*list) + (*list)->prev = c; + *list = c; + c->creation_time = ts; + /* Store ChannelInfo pointer in channel record */ + c->ci = cs_findchan(chan); + if (c->ci) + c->ci->c = c; + /* Restore locked modes and saved topic */ + if (c->ci) { + check_modes(c); + stick_all(c->ci); + } + + if (serv_uplink && is_sync(serv_uplink) && (!(c->topic_sync))) { + restore_topic(chan); + } + + return c; } /*************************************************************************/ @@ -1622,133 +1622,133 @@ Channel *chan_create(const char *chan, time_t ts) void chan_delete(Channel * c) { - BanData *bd, *next; - - if (debug) - alog("debug: Deleting channel %s", c->name); - - for (bd = c->bd; bd; bd = next) { - if (bd->mask) - free(bd->mask); - next = bd->next; - free(bd); - } - - if (c->ci) - c->ci->c = NULL; - - if (c->topic) - free(c->topic); - - if (c->key) - free(c->key); - if (ircd->fmode) { - if (c->flood) - free(c->flood); - } - if (ircd->Lmode) { - if (c->redirect) - free(c->redirect); - } - - if (c->bans && c->bans->count) { - while (c->bans->entries) { - entry_delete(c->bans, c->bans->entries); - } - } - - if (ircd->except) { - if (c->excepts && c->excepts->count) { - while (c->excepts->entries) { - entry_delete(c->excepts, c->excepts->entries); - } - } - } - - if (ircd->invitemode) { - if (c->invites && c->invites->count) { - while (c->invites->entries) { - entry_delete(c->invites, c->invites->entries); - } - } - } - - if (c->next) - c->next->prev = c->prev; - if (c->prev) - c->prev->next = c->next; - else - chanlist[HASH(c->name)] = c->next; - - free(c); + BanData *bd, *next; + + if (debug) + alog("debug: Deleting channel %s", c->name); + + for (bd = c->bd; bd; bd = next) { + if (bd->mask) + free(bd->mask); + next = bd->next; + free(bd); + } + + if (c->ci) + c->ci->c = NULL; + + if (c->topic) + free(c->topic); + + if (c->key) + free(c->key); + if (ircd->fmode) { + if (c->flood) + free(c->flood); + } + if (ircd->Lmode) { + if (c->redirect) + free(c->redirect); + } + + if (c->bans && c->bans->count) { + while (c->bans->entries) { + entry_delete(c->bans, c->bans->entries); + } + } + + if (ircd->except) { + if (c->excepts && c->excepts->count) { + while (c->excepts->entries) { + entry_delete(c->excepts, c->excepts->entries); + } + } + } + + if (ircd->invitemode) { + if (c->invites && c->invites->count) { + while (c->invites->entries) { + entry_delete(c->invites, c->invites->entries); + } + } + } + + if (c->next) + c->next->prev = c->prev; + if (c->prev) + c->prev->next = c->next; + else + chanlist[HASH(c->name)] = c->next; + + free(c); } /*************************************************************************/ void del_ban(Channel * chan, const char *mask) { - AutoKick *akick; - Entry *ban; + AutoKick *akick; + Entry *ban; - /* Sanity check as it seems some IRCD will just send -b without a mask */ - if (!mask || !chan->bans || (chan->bans->count == 0)) - return; + /* Sanity check as it seems some IRCD will just send -b without a mask */ + if (!mask || !chan->bans || (chan->bans->count == 0)) + return; - ban = elist_find_mask(chan->bans, mask); + ban = elist_find_mask(chan->bans, mask); - if (ban) { - entry_delete(chan->bans, ban); + if (ban) { + entry_delete(chan->bans, ban); - if (debug) - alog("debug: Deleted ban %s from channel %s", mask, - chan->name); - } + if (debug) + alog("debug: Deleted ban %s from channel %s", mask, + chan->name); + } - if (chan->ci && (akick = is_stuck(chan->ci, mask))) - stick_mask(chan->ci, akick); + if (chan->ci && (akick = is_stuck(chan->ci, mask))) + stick_mask(chan->ci, akick); } /*************************************************************************/ void del_exception(Channel * chan, const char *mask) { - Entry *exception; + Entry *exception; - /* Sanity check as it seems some IRCD will just send -e without a mask */ - if (!mask || !chan->excepts || (chan->excepts->count == 0)) - return; + /* Sanity check as it seems some IRCD will just send -e without a mask */ + if (!mask || !chan->excepts || (chan->excepts->count == 0)) + return; - exception = elist_find_mask(chan->excepts, mask); + exception = elist_find_mask(chan->excepts, mask); - if (exception) { - entry_delete(chan->excepts, exception); + if (exception) { + entry_delete(chan->excepts, exception); - if (debug) - alog("debug: Deleted except %s to channel %s", mask, - chan->name); - } + if (debug) + alog("debug: Deleted except %s to channel %s", mask, + chan->name); + } } /*************************************************************************/ void del_invite(Channel * chan, const char *mask) { - Entry *invite; + Entry *invite; - /* Sanity check as it seems some IRCD will just send -I without a mask */ - if (!mask || !chan->invites || (chan->invites->count == 0)) { - return; - } + /* Sanity check as it seems some IRCD will just send -I without a mask */ + if (!mask || !chan->invites || (chan->invites->count == 0)) { + return; + } - invite = elist_find_mask(chan->invites, mask); + invite = elist_find_mask(chan->invites, mask); - if (invite) { - entry_delete(chan->invites, invite); + if (invite) { + entry_delete(chan->invites, invite); - if (debug) - alog("debug: Deleted invite %s to channel %s", mask, - chan->name); - } + if (debug) + alog("debug: Deleted invite %s to channel %s", mask, + chan->name); + } } @@ -1756,151 +1756,151 @@ void del_invite(Channel * chan, const char *mask) char *get_flood(Channel * chan) { - return chan->flood; + return chan->flood; } /*************************************************************************/ char *get_key(Channel * chan) { - return chan->key; + return chan->key; } /*************************************************************************/ char *get_limit(Channel * chan) { - static char limit[16]; + static char limit[16]; - if (chan->limit == 0) - return NULL; + if (chan->limit == 0) + return NULL; - snprintf(limit, sizeof(limit), "%lu", (unsigned long int) chan->limit); - return limit; + snprintf(limit, sizeof(limit), "%lu", (unsigned long int) chan->limit); + return limit; } /*************************************************************************/ char *get_redirect(Channel * chan) { - return chan->redirect; + return chan->redirect; } /*************************************************************************/ Channel *join_user_update(User * user, Channel * chan, const char *name, - time_t chants) + time_t chants) { - struct u_chanlist *c; + struct u_chanlist *c; - /* If it's a new channel, so we need to create it first. */ - if (!chan) - chan = chan_create(name, chants); + /* If it's a new channel, so we need to create it first. */ + if (!chan) + chan = chan_create(name, chants); - if (debug) - alog("debug: %s joins %s", user->nick, chan->name); + if (debug) + alog("debug: %s joins %s", user->nick, chan->name); - c = (u_chanlist *)scalloc(sizeof(*c), 1); - c->next = user->chans; - if (user->chans) - user->chans->prev = c; - user->chans = c; - c->chan = chan; + c = (u_chanlist *)scalloc(sizeof(*c), 1); + c->next = user->chans; + if (user->chans) + user->chans->prev = c; + user->chans = c; + c->chan = chan; - chan_adduser2(user, chan); + chan_adduser2(user, chan); - return chan; + return chan; } /*************************************************************************/ void set_flood(Channel * chan, const char *value) { - if (chan->flood) - free(chan->flood); - chan->flood = value ? sstrdup(value) : NULL; + if (chan->flood) + free(chan->flood); + chan->flood = value ? sstrdup(value) : NULL; - if (debug) - alog("debug: Flood mode for channel %s set to %s", chan->name, - chan->flood ? chan->flood : "no flood settings"); + if (debug) + alog("debug: Flood mode for channel %s set to %s", chan->name, + chan->flood ? chan->flood : "no flood settings"); } /*************************************************************************/ void chan_set_key(Channel * chan, const char *value) { - if (chan->key) - free(chan->key); - chan->key = value ? sstrdup(value) : NULL; + if (chan->key) + free(chan->key); + chan->key = value ? sstrdup(value) : NULL; - if (debug) - alog("debug: Key of channel %s set to %s", chan->name, - chan->key ? chan->key : "no key"); + if (debug) + alog("debug: Key of channel %s set to %s", chan->name, + chan->key ? chan->key : "no key"); } /*************************************************************************/ void set_limit(Channel * chan, const char *value) { - chan->limit = value ? strtoul(value, NULL, 10) : 0; + chan->limit = value ? strtoul(value, NULL, 10) : 0; - if (debug) - alog("debug: Limit of channel %s set to %u", chan->name, - chan->limit); + if (debug) + alog("debug: Limit of channel %s set to %u", chan->name, + chan->limit); } /*************************************************************************/ void set_redirect(Channel * chan, const char *value) { - if (chan->redirect) - free(chan->redirect); - chan->redirect = value ? sstrdup(value) : NULL; + if (chan->redirect) + free(chan->redirect); + chan->redirect = value ? sstrdup(value) : NULL; - if (debug) - alog("debug: Redirect of channel %s set to %s", chan->name, - chan->redirect ? chan->redirect : "no redirect"); + if (debug) + alog("debug: Redirect of channel %s set to %s", chan->name, + chan->redirect ? chan->redirect : "no redirect"); } void do_mass_mode(char *modes) { - int ac; - const char **av; - Channel *c; - char *myModes; - - if (!modes) { - return; - } - - /* Prevent modes being altered by split_buf */ - myModes = sstrdup(modes); - ac = split_buf(myModes, &av, 1); - - for (c = firstchan(); c; c = nextchan()) { - if (c->bouncy_modes) { - free(av); - free(myModes); - return; - } else { - ircdproto->SendMode(findbot(s_OperServ), c->name, "%s", modes); - chan_set_modes(s_OperServ, c, ac, av, 1); - } - } - free(av); - free(myModes); + int ac; + const char **av; + Channel *c; + char *myModes; + + if (!modes) { + return; + } + + /* Prevent modes being altered by split_buf */ + myModes = sstrdup(modes); + ac = split_buf(myModes, &av, 1); + + for (c = firstchan(); c; c = nextchan()) { + if (c->bouncy_modes) { + free(av); + free(myModes); + return; + } else { + ircdproto->SendMode(findbot(s_OperServ), c->name, "%s", modes); + chan_set_modes(s_OperServ, c, ac, av, 1); + } + } + free(av); + free(myModes); } /*************************************************************************/ void restore_unsynced_topics(void) { - Channel *c; + Channel *c; - for (c = firstchan(); c; c = nextchan()) { - if (!(c->topic_sync)) - restore_topic(c->name); - } + for (c = firstchan(); c; c = nextchan()) { + if (!(c->topic_sync)) + restore_topic(c->name); + } } /*************************************************************************/ @@ -1913,97 +1913,97 @@ void restore_unsynced_topics(void) */ Entry *entry_create(char *mask) { - Entry *entry; - char *nick = NULL, *user, *host, *cidrhost; - int do_free; - uint32 ip, cidr; - - entry = (Entry *)scalloc(1, sizeof(Entry)); - entry->type = ENTRYTYPE_NONE; - entry->prev = NULL; - entry->next = NULL; - entry->nick = NULL; - entry->user = NULL; - entry->host = NULL; - entry->mask = sstrdup(mask); - - host = strchr(mask, '@'); - if (host) { - *host++ = '\0'; - /* If the user is purely a wildcard, ignore it */ - if (str_is_pure_wildcard(mask)) - user = NULL; - else { - - /* There might be a nick too */ - user = strchr(mask, '!'); - if (user) { - *user++ = '\0'; - /* If the nick is purely a wildcard, ignore it */ - if (str_is_pure_wildcard(mask)) - nick = NULL; - else - nick = mask; - } else { - nick = NULL; - user = mask; - } - } - } else { - /* It is possibly an extended ban/invite mask, but we do - * not support these at this point.. ~ Viper */ - /* If there's no user in the mask, assume a pure wildcard */ - user = NULL; - host = mask; - } - - if (nick) { - entry->nick = sstrdup(nick); - /* Check if we have a wildcard user */ - if (str_is_wildcard(nick)) - entry->type |= ENTRYTYPE_NICK_WILD; - else - entry->type |= ENTRYTYPE_NICK; - } - - if (user) { - entry->user = sstrdup(user); - /* Check if we have a wildcard user */ - if (str_is_wildcard(user)) - entry->type |= ENTRYTYPE_USER_WILD; - else - entry->type |= ENTRYTYPE_USER; - } - - /* Only check the host if it's not a pure wildcard */ - if (*host && !str_is_pure_wildcard(host)) { - if (ircd->cidrchanbei && str_is_cidr(host, &ip, &cidr, &cidrhost)) { - entry->cidr_ip = ip; - entry->cidr_mask = cidr; - entry->type |= ENTRYTYPE_CIDR4; - host = cidrhost; - do_free = 1; - } else if (ircd->cidrchanbei && strchr(host, '/')) { - /* Most IRCd's don't enforce sane bans therefore it is not - * so unlikely we will encounter this. - * Currently we only support strict CIDR without taking into - * account quirks of every single ircd (nef) that ignore everything - * after the first /cidr. To add this, sanitaze before sending to - * str_is_cidr() as this expects a standard cidr. - * Add it to the internal list (so it is included in for example clear) - * but do not use if during matching.. ~ Viper */ - entry->type = ENTRYTYPE_NONE; - } else { - entry->host = sstrdup(host); - if (str_is_wildcard(host)) - entry->type |= ENTRYTYPE_HOST_WILD; - else - entry->type |= ENTRYTYPE_HOST; - } - } - free(mask); - - return entry; + Entry *entry; + char *nick = NULL, *user, *host, *cidrhost; + int do_free; + uint32 ip, cidr; + + entry = (Entry *)scalloc(1, sizeof(Entry)); + entry->type = ENTRYTYPE_NONE; + entry->prev = NULL; + entry->next = NULL; + entry->nick = NULL; + entry->user = NULL; + entry->host = NULL; + entry->mask = sstrdup(mask); + + host = strchr(mask, '@'); + if (host) { + *host++ = '\0'; + /* If the user is purely a wildcard, ignore it */ + if (str_is_pure_wildcard(mask)) + user = NULL; + else { + + /* There might be a nick too */ + user = strchr(mask, '!'); + if (user) { + *user++ = '\0'; + /* If the nick is purely a wildcard, ignore it */ + if (str_is_pure_wildcard(mask)) + nick = NULL; + else + nick = mask; + } else { + nick = NULL; + user = mask; + } + } + } else { + /* It is possibly an extended ban/invite mask, but we do + * not support these at this point.. ~ Viper */ + /* If there's no user in the mask, assume a pure wildcard */ + user = NULL; + host = mask; + } + + if (nick) { + entry->nick = sstrdup(nick); + /* Check if we have a wildcard user */ + if (str_is_wildcard(nick)) + entry->type |= ENTRYTYPE_NICK_WILD; + else + entry->type |= ENTRYTYPE_NICK; + } + + if (user) { + entry->user = sstrdup(user); + /* Check if we have a wildcard user */ + if (str_is_wildcard(user)) + entry->type |= ENTRYTYPE_USER_WILD; + else + entry->type |= ENTRYTYPE_USER; + } + + /* Only check the host if it's not a pure wildcard */ + if (*host && !str_is_pure_wildcard(host)) { + if (ircd->cidrchanbei && str_is_cidr(host, &ip, &cidr, &cidrhost)) { + entry->cidr_ip = ip; + entry->cidr_mask = cidr; + entry->type |= ENTRYTYPE_CIDR4; + host = cidrhost; + do_free = 1; + } else if (ircd->cidrchanbei && strchr(host, '/')) { + /* Most IRCd's don't enforce sane bans therefore it is not + * so unlikely we will encounter this. + * Currently we only support strict CIDR without taking into + * account quirks of every single ircd (nef) that ignore everything + * after the first /cidr. To add this, sanitaze before sending to + * str_is_cidr() as this expects a standard cidr. + * Add it to the internal list (so it is included in for example clear) + * but do not use if during matching.. ~ Viper */ + entry->type = ENTRYTYPE_NONE; + } else { + entry->host = sstrdup(host); + if (str_is_wildcard(host)) + entry->type |= ENTRYTYPE_HOST_WILD; + else + entry->type |= ENTRYTYPE_HOST; + } + } + free(mask); + + return entry; } @@ -2015,24 +2015,24 @@ Entry *entry_create(char *mask) */ Entry *entry_add(EList * list, const char *mask) { - Entry *e; - char *hostmask; + Entry *e; + char *hostmask; - hostmask = sstrdup(mask); - e = entry_create(hostmask); + hostmask = sstrdup(mask); + e = entry_create(hostmask); - if (!e) - return NULL; + if (!e) + return NULL; - e->next = list->entries; - e->prev = NULL; + e->next = list->entries; + e->prev = NULL; - if (list->entries) - list->entries->prev = e; - list->entries = e; - list->count++; + if (list->entries) + list->entries->prev = e; + list->entries = e; + list->count++; - return e; + return e; } @@ -2043,27 +2043,27 @@ Entry *entry_add(EList * list, const char *mask) */ void entry_delete(EList * list, Entry * e) { - if (!list || !e) - return; - - if (e->next) - e->next->prev = e->prev; - if (e->prev) - e->prev->next = e->next; - - if (list->entries == e) - list->entries = e->next; - - if (e->nick) - free(e->nick); - if (e->user) - free(e->user); - if (e->host) - free(e->host); - free(e->mask); - free(e); - - list->count--; + if (!list || !e) + return; + + if (e->next) + e->next->prev = e->prev; + if (e->prev) + e->prev->next = e->next; + + if (list->entries == e) + list->entries = e->next; + + if (e->nick) + free(e->nick); + if (e->user) + free(e->user); + if (e->host) + free(e->host); + free(e->mask); + free(e); + + list->count--; } @@ -2073,13 +2073,13 @@ void entry_delete(EList * list, Entry * e) **/ EList *list_create() { - EList *list; + EList *list; - list = (EList *)scalloc(1, sizeof(EList)); - list->entries = NULL; - list->count = 0; + list = (EList *)scalloc(1, sizeof(EList)); + list->entries = NULL; + list->count = 0; - return list; + return list; } @@ -2094,33 +2094,33 @@ EList *list_create() */ int entry_match(Entry * e, char *nick, char *user, char *host, uint32 ip) { - /* If we don't get an entry, or it s an invalid one, no match ~ Viper */ - if (!e || e->type == ENTRYTYPE_NONE) - return 0; - - if (ircd->cidrchanbei && (e->type & ENTRYTYPE_CIDR4) && - (!ip || (ip && ((ip & e->cidr_mask) != e->cidr_ip)))) - return 0; - if ((e->type & ENTRYTYPE_NICK) - && (!nick || stricmp(e->nick, nick) != 0)) - return 0; - if ((e->type & ENTRYTYPE_USER) - && (!user || stricmp(e->user, user) != 0)) - return 0; - if ((e->type & ENTRYTYPE_HOST) - && (!user || stricmp(e->host, host) != 0)) - return 0; - if ((e->type & ENTRYTYPE_NICK_WILD) - && !match_wild_nocase(e->nick, nick)) - return 0; - if ((e->type & ENTRYTYPE_USER_WILD) - && !match_wild_nocase(e->user, user)) - return 0; - if ((e->type & ENTRYTYPE_HOST_WILD) - && !match_wild_nocase(e->host, host)) - return 0; - - return 1; + /* If we don't get an entry, or it s an invalid one, no match ~ Viper */ + if (!e || e->type == ENTRYTYPE_NONE) + return 0; + + if (ircd->cidrchanbei && (e->type & ENTRYTYPE_CIDR4) && + (!ip || (ip && ((ip & e->cidr_mask) != e->cidr_ip)))) + return 0; + if ((e->type & ENTRYTYPE_NICK) + && (!nick || stricmp(e->nick, nick) != 0)) + return 0; + if ((e->type & ENTRYTYPE_USER) + && (!user || stricmp(e->user, user) != 0)) + return 0; + if ((e->type & ENTRYTYPE_HOST) + && (!user || stricmp(e->host, host) != 0)) + return 0; + if ((e->type & ENTRYTYPE_NICK_WILD) + && !match_wild_nocase(e->nick, nick)) + return 0; + if ((e->type & ENTRYTYPE_USER_WILD) + && !match_wild_nocase(e->user, user)) + return 0; + if ((e->type & ENTRYTYPE_HOST_WILD) + && !match_wild_nocase(e->host, host)) + return 0; + + return 1; } /** @@ -2132,34 +2132,34 @@ int entry_match(Entry * e, char *nick, char *user, char *host, uint32 ip) */ int entry_match_mask(Entry * e, char *mask, uint32 ip) { - char *hostmask, *nick, *user, *host; - int res; - - hostmask = sstrdup(mask); - - host = strchr(hostmask, '@'); - if (host) { - *host++ = '\0'; - user = strchr(hostmask, '!'); - if (user) { - *user++ = '\0'; - nick = hostmask; - } else { - nick = NULL; - user = hostmask; - } - } else { - nick = NULL; - user = NULL; - host = hostmask; - } - - res = entry_match(e, nick, user, host, ip); - - /* Free the destroyed mask. */ - free(hostmask); - - return res; + char *hostmask, *nick, *user, *host; + int res; + + hostmask = sstrdup(mask); + + host = strchr(hostmask, '@'); + if (host) { + *host++ = '\0'; + user = strchr(hostmask, '!'); + if (user) { + *user++ = '\0'; + nick = hostmask; + } else { + nick = NULL; + user = hostmask; + } + } else { + nick = NULL; + user = NULL; + host = hostmask; + } + + res = entry_match(e, nick, user, host, ip); + + /* Free the destroyed mask. */ + free(hostmask); + + return res; } /** @@ -2172,20 +2172,20 @@ int entry_match_mask(Entry * e, char *mask, uint32 ip) * @return Returns the first matching entry, if none, NULL is returned. */ Entry *elist_match(EList * list, char *nick, char *user, char *host, - uint32 ip) + uint32 ip) { - Entry *e; + Entry *e; - if (!list || !list->entries) - return NULL; + if (!list || !list->entries) + return NULL; - for (e = list->entries; e; e = e->next) { - if (entry_match(e, nick, user, host, ip)) - return e; - } + for (e = list->entries; e; e = e->next) { + if (entry_match(e, nick, user, host, ip)) + return e; + } - /* We matched none */ - return NULL; + /* We matched none */ + return NULL; } /** @@ -2197,37 +2197,37 @@ Entry *elist_match(EList * list, char *nick, char *user, char *host, */ Entry *elist_match_mask(EList * list, char *mask, uint32 ip) { - char *hostmask, *nick, *user, *host; - Entry *res; - - if (!list || !list->entries || !mask) - return NULL; - - hostmask = sstrdup(mask); - - host = strchr(hostmask, '@'); - if (host) { - *host++ = '\0'; - user = strchr(hostmask, '!'); - if (user) { - *user++ = '\0'; - nick = hostmask; - } else { - nick = NULL; - user = hostmask; - } - } else { - nick = NULL; - user = NULL; - host = hostmask; - } - - res = elist_match(list, nick, user, host, ip); - - /* Free the destroyed mask. */ - free(hostmask); - - return res; + char *hostmask, *nick, *user, *host; + Entry *res; + + if (!list || !list->entries || !mask) + return NULL; + + hostmask = sstrdup(mask); + + host = strchr(hostmask, '@'); + if (host) { + *host++ = '\0'; + user = strchr(hostmask, '!'); + if (user) { + *user++ = '\0'; + nick = hostmask; + } else { + nick = NULL; + user = hostmask; + } + } else { + nick = NULL; + user = NULL; + host = hostmask; + } + + res = elist_match(list, nick, user, host, ip); + + /* Free the destroyed mask. */ + free(hostmask); + + return res; } /** @@ -2238,37 +2238,37 @@ Entry *elist_match_mask(EList * list, char *mask, uint32 ip) */ Entry *elist_match_user(EList * list, User * u) { - Entry *res; - char *host; - uint32 ip = 0; - - if (!list || !list->entries || !u) - return NULL; - - if (u->hostip == NULL) { - host = host_resolve(u->host); - /* we store the just resolved hostname so we don't - * need to do this again */ - if (host) { - u->hostip = sstrdup(host); - } - } else { - host = sstrdup(u->hostip); - } - - /* Convert the host to an IP.. */ - if (host) - ip = str_is_ip(host); - - /* Match what we ve got against the lists.. */ - res = elist_match(list, u->nick, u->username, u->host, ip); - if (!res) - elist_match(list, u->nick, u->username, u->vhost, ip); - - if (host) - free(host); - - return res; + Entry *res; + char *host; + uint32 ip = 0; + + if (!list || !list->entries || !u) + return NULL; + + if (u->hostip == NULL) { + host = host_resolve(u->host); + /* we store the just resolved hostname so we don't + * need to do this again */ + if (host) { + u->hostip = sstrdup(host); + } + } else { + host = sstrdup(u->hostip); + } + + /* Convert the host to an IP.. */ + if (host) + ip = str_is_ip(host); + + /* Match what we ve got against the lists.. */ + res = elist_match(list, u->nick, u->username, u->host, ip); + if (!res) + elist_match(list, u->nick, u->username, u->vhost, ip); + + if (host) + free(host); + + return res; } /** @@ -2279,17 +2279,17 @@ Entry *elist_match_user(EList * list, User * u) */ Entry *elist_find_mask(EList * list, const char *mask) { - Entry *e; + Entry *e; - if (!list || !list->entries || !mask) - return NULL; + if (!list || !list->entries || !mask) + return NULL; - for (e = list->entries; e; e = e->next) { - if (!stricmp(e->mask, mask)) - return e; - } + for (e = list->entries; e; e = e->next) { + if (!stricmp(e->mask, mask)) + return e; + } - return NULL; + return NULL; } /** @@ -2299,28 +2299,28 @@ Entry *elist_find_mask(EList * list, const char *mask) */ long get_memuse(EList * list) { - Entry *e; - long mem = 0; - - if (!list) - return 0; - - mem += sizeof(EList *); - mem += sizeof(Entry *) * list->count; - if (list->entries) { - for (e = list->entries; e; e = e->next) { - if (e->nick) - mem += strlen(e->nick) + 1; - if (e->user) - mem += strlen(e->user) + 1; - if (e->host) - mem += strlen(e->host) + 1; - if (e->mask) - mem += strlen(e->mask) + 1; - } - } - - return mem; + Entry *e; + long mem = 0; + + if (!list) + return 0; + + mem += sizeof(EList *); + mem += sizeof(Entry *) * list->count; + if (list->entries) { + for (e = list->entries; e; e = e->next) { + if (e->nick) + mem += strlen(e->nick) + 1; + if (e->user) + mem += strlen(e->user) + 1; + if (e->host) + mem += strlen(e->host) + 1; + if (e->mask) + mem += strlen(e->mask) + 1; + } + } + + return mem; } /*************************************************************************/ diff --git a/src/chanserv.c b/src/chanserv.c index 5e92ce3dc..e95a2a238 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -23,97 +23,97 @@ ChannelInfo *chanlists[256]; static int def_levels[][2] = { - { CA_AUTOOP, 5 }, - { CA_AUTOVOICE, 3 }, - { CA_AUTODEOP, -1 }, - { CA_NOJOIN, -2 }, - { CA_INVITE, 5 }, - { CA_AKICK, 10 }, - { CA_SET, ACCESS_INVALID }, - { CA_CLEAR, ACCESS_INVALID }, - { CA_UNBAN, 5 }, - { CA_OPDEOP, 5 }, - { CA_ACCESS_LIST, 1 }, - { CA_ACCESS_CHANGE, 10 }, - { CA_MEMO, 10 }, - { CA_ASSIGN, ACCESS_INVALID }, - { CA_BADWORDS, 10 }, - { CA_NOKICK, 1 }, - { CA_FANTASIA, 3 }, - { CA_SAY, 5 }, - { CA_GREET, 5 }, - { CA_VOICEME, 3 }, - { CA_VOICE, 5 }, - { CA_GETKEY, 5 }, - { CA_AUTOHALFOP, 4 }, - { CA_AUTOPROTECT, 10 }, - { CA_OPDEOPME, 5 }, - { CA_HALFOPME, 4 }, - { CA_HALFOP, 5 }, - { CA_PROTECTME, 10 }, - { CA_PROTECT, ACCESS_INVALID }, - { CA_KICKME, 5 }, - { CA_KICK, 5 }, - { CA_SIGNKICK, ACCESS_INVALID }, - { CA_BANME, 5 }, - { CA_BAN, 5 }, - { CA_TOPIC, ACCESS_INVALID }, - { CA_INFO, ACCESS_INVALID }, - { -1 } + { CA_AUTOOP, 5 }, + { CA_AUTOVOICE, 3 }, + { CA_AUTODEOP, -1 }, + { CA_NOJOIN, -2 }, + { CA_INVITE, 5 }, + { CA_AKICK, 10 }, + { CA_SET, ACCESS_INVALID }, + { CA_CLEAR, ACCESS_INVALID }, + { CA_UNBAN, 5 }, + { CA_OPDEOP, 5 }, + { CA_ACCESS_LIST, 1 }, + { CA_ACCESS_CHANGE, 10 }, + { CA_MEMO, 10 }, + { CA_ASSIGN, ACCESS_INVALID }, + { CA_BADWORDS, 10 }, + { CA_NOKICK, 1 }, + { CA_FANTASIA, 3 }, + { CA_SAY, 5 }, + { CA_GREET, 5 }, + { CA_VOICEME, 3 }, + { CA_VOICE, 5 }, + { CA_GETKEY, 5 }, + { CA_AUTOHALFOP, 4 }, + { CA_AUTOPROTECT, 10 }, + { CA_OPDEOPME, 5 }, + { CA_HALFOPME, 4 }, + { CA_HALFOP, 5 }, + { CA_PROTECTME, 10 }, + { CA_PROTECT, ACCESS_INVALID }, + { CA_KICKME, 5 }, + { CA_KICK, 5 }, + { CA_SIGNKICK, ACCESS_INVALID }, + { CA_BANME, 5 }, + { CA_BAN, 5 }, + { CA_TOPIC, ACCESS_INVALID }, + { CA_INFO, ACCESS_INVALID }, + { -1 } }; LevelInfo levelinfo[] = { - { CA_AUTODEOP, "AUTODEOP", CHAN_LEVEL_AUTODEOP }, - { CA_AUTOHALFOP, "AUTOHALFOP", CHAN_LEVEL_AUTOHALFOP }, - { CA_AUTOOP, "AUTOOP", CHAN_LEVEL_AUTOOP }, + { CA_AUTODEOP, "AUTODEOP", CHAN_LEVEL_AUTODEOP }, + { CA_AUTOHALFOP, "AUTOHALFOP", CHAN_LEVEL_AUTOHALFOP }, + { CA_AUTOOP, "AUTOOP", CHAN_LEVEL_AUTOOP }, { CA_AUTOPROTECT, "", CHAN_LEVEL_AUTOPROTECT }, - { CA_AUTOVOICE, "AUTOVOICE", CHAN_LEVEL_AUTOVOICE }, - { CA_NOJOIN, "NOJOIN", CHAN_LEVEL_NOJOIN }, - { CA_SIGNKICK, "SIGNKICK", CHAN_LEVEL_SIGNKICK }, - { CA_ACCESS_LIST, "ACC-LIST", CHAN_LEVEL_ACCESS_LIST }, + { CA_AUTOVOICE, "AUTOVOICE", CHAN_LEVEL_AUTOVOICE }, + { CA_NOJOIN, "NOJOIN", CHAN_LEVEL_NOJOIN }, + { CA_SIGNKICK, "SIGNKICK", CHAN_LEVEL_SIGNKICK }, + { CA_ACCESS_LIST, "ACC-LIST", CHAN_LEVEL_ACCESS_LIST }, { CA_ACCESS_CHANGE, "ACC-CHANGE", CHAN_LEVEL_ACCESS_CHANGE }, - { CA_AKICK, "AKICK", CHAN_LEVEL_AKICK }, - { CA_SET, "SET", CHAN_LEVEL_SET }, - { CA_BAN, "BAN", CHAN_LEVEL_BAN }, - { CA_BANME, "BANME", CHAN_LEVEL_BANME }, - { CA_CLEAR, "CLEAR", CHAN_LEVEL_CLEAR }, - { CA_GETKEY, "GETKEY", CHAN_LEVEL_GETKEY }, - { CA_HALFOP, "HALFOP", CHAN_LEVEL_HALFOP }, - { CA_HALFOPME, "HALFOPME", CHAN_LEVEL_HALFOPME }, - { CA_INFO, "INFO", CHAN_LEVEL_INFO }, - { CA_KICK, "KICK", CHAN_LEVEL_KICK }, - { CA_KICKME, "KICKME", CHAN_LEVEL_KICKME }, - { CA_INVITE, "INVITE", CHAN_LEVEL_INVITE }, - { CA_OPDEOP, "OPDEOP", CHAN_LEVEL_OPDEOP }, - { CA_OPDEOPME, "OPDEOPME", CHAN_LEVEL_OPDEOPME }, - { CA_PROTECT, "", CHAN_LEVEL_PROTECT }, - { CA_PROTECTME, "", CHAN_LEVEL_PROTECTME }, - { CA_TOPIC, "TOPIC", CHAN_LEVEL_TOPIC }, - { CA_UNBAN, "UNBAN", CHAN_LEVEL_UNBAN }, - { CA_VOICE, "VOICE", CHAN_LEVEL_VOICE }, - { CA_VOICEME, "VOICEME", CHAN_LEVEL_VOICEME }, - { CA_MEMO, "MEMO", CHAN_LEVEL_MEMO }, - { CA_ASSIGN, "ASSIGN", CHAN_LEVEL_ASSIGN }, - { CA_BADWORDS, "BADWORDS", CHAN_LEVEL_BADWORDS }, - { CA_FANTASIA, "FANTASIA", CHAN_LEVEL_FANTASIA }, - { CA_GREET, "GREET", CHAN_LEVEL_GREET }, - { CA_NOKICK, "NOKICK", CHAN_LEVEL_NOKICK }, - { CA_SAY, "SAY", CHAN_LEVEL_SAY }, - { -1 } + { CA_AKICK, "AKICK", CHAN_LEVEL_AKICK }, + { CA_SET, "SET", CHAN_LEVEL_SET }, + { CA_BAN, "BAN", CHAN_LEVEL_BAN }, + { CA_BANME, "BANME", CHAN_LEVEL_BANME }, + { CA_CLEAR, "CLEAR", CHAN_LEVEL_CLEAR }, + { CA_GETKEY, "GETKEY", CHAN_LEVEL_GETKEY }, + { CA_HALFOP, "HALFOP", CHAN_LEVEL_HALFOP }, + { CA_HALFOPME, "HALFOPME", CHAN_LEVEL_HALFOPME }, + { CA_INFO, "INFO", CHAN_LEVEL_INFO }, + { CA_KICK, "KICK", CHAN_LEVEL_KICK }, + { CA_KICKME, "KICKME", CHAN_LEVEL_KICKME }, + { CA_INVITE, "INVITE", CHAN_LEVEL_INVITE }, + { CA_OPDEOP, "OPDEOP", CHAN_LEVEL_OPDEOP }, + { CA_OPDEOPME, "OPDEOPME", CHAN_LEVEL_OPDEOPME }, + { CA_PROTECT, "", CHAN_LEVEL_PROTECT }, + { CA_PROTECTME, "", CHAN_LEVEL_PROTECTME }, + { CA_TOPIC, "TOPIC", CHAN_LEVEL_TOPIC }, + { CA_UNBAN, "UNBAN", CHAN_LEVEL_UNBAN }, + { CA_VOICE, "VOICE", CHAN_LEVEL_VOICE }, + { CA_VOICEME, "VOICEME", CHAN_LEVEL_VOICEME }, + { CA_MEMO, "MEMO", CHAN_LEVEL_MEMO }, + { CA_ASSIGN, "ASSIGN", CHAN_LEVEL_ASSIGN }, + { CA_BADWORDS, "BADWORDS", CHAN_LEVEL_BADWORDS }, + { CA_FANTASIA, "FANTASIA", CHAN_LEVEL_FANTASIA }, + { CA_GREET, "GREET", CHAN_LEVEL_GREET }, + { CA_NOKICK, "NOKICK", CHAN_LEVEL_NOKICK }, + { CA_SAY, "SAY", CHAN_LEVEL_SAY }, + { -1 } }; int levelinfo_maxwidth = 0; CSModeUtil csmodeutils[] = { - { "DEOP", "deop", "-o", CI_OPNOTICE, CA_OPDEOP, CA_OPDEOPME }, - { "OP", "op", "+o", CI_OPNOTICE, CA_OPDEOP, CA_OPDEOPME }, - { "DEVOICE", "devoice", "-v", 0, CA_VOICE, CA_VOICEME }, - { "VOICE", "voice", "+v", 0, CA_VOICE, CA_VOICEME }, - { "DEHALFOP", "dehalfop", "-h", 0, CA_HALFOP, CA_HALFOPME }, - { "HALFOP", "halfop", "+h", 0, CA_HALFOP, CA_HALFOPME }, - { "DEPROTECT", "", "", 0, CA_PROTECT, CA_PROTECTME }, - { "PROTECT", "", "", 0, CA_PROTECT, CA_PROTECTME }, - { NULL } + { "DEOP", "deop", "-o", CI_OPNOTICE, CA_OPDEOP, CA_OPDEOPME }, + { "OP", "op", "+o", CI_OPNOTICE, CA_OPDEOP, CA_OPDEOPME }, + { "DEVOICE", "devoice", "-v", 0, CA_VOICE, CA_VOICEME }, + { "VOICE", "voice", "+v", 0, CA_VOICE, CA_VOICEME }, + { "DEHALFOP", "dehalfop", "-h", 0, CA_HALFOP, CA_HALFOPME }, + { "HALFOP", "halfop", "+h", 0, CA_HALFOP, CA_HALFOPME }, + { "DEPROTECT", "", "", 0, CA_PROTECT, CA_PROTECTME }, + { "PROTECT", "", "", 0, CA_PROTECT, CA_PROTECTME }, + { NULL } }; /*************************************************************************/ @@ -130,56 +130,56 @@ void moduleAddChanServCmds(void) { char *get_mlock_modes(ChannelInfo * ci, int complete) { - static char res[BUFSIZE]; + static char res[BUFSIZE]; - char *end = res; + char *end = res; - if (ci->mlock_on || ci->mlock_off) { - unsigned int n = 0; - CBModeInfo *cbmi = cbmodeinfos; + if (ci->mlock_on || ci->mlock_off) { + unsigned int n = 0; + CBModeInfo *cbmi = cbmodeinfos; - if (ci->mlock_on) { - *end++ = '+'; - n++; + if (ci->mlock_on) { + *end++ = '+'; + n++; - do { - if (ci->mlock_on & cbmi->flag) - *end++ = cbmi->mode; - } while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1); + do { + if (ci->mlock_on & cbmi->flag) + *end++ = cbmi->mode; + } while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1); - cbmi = cbmodeinfos; - } + cbmi = cbmodeinfos; + } - if (ci->mlock_off) { - *end++ = '-'; - n++; + if (ci->mlock_off) { + *end++ = '-'; + n++; - do { - if (ci->mlock_off & cbmi->flag) - *end++ = cbmi->mode; - } while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1); + do { + if (ci->mlock_off & cbmi->flag) + *end++ = cbmi->mode; + } while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1); - cbmi = cbmodeinfos; - } + cbmi = cbmodeinfos; + } - if (ci->mlock_on && complete) { - do { - if (cbmi->csgetvalue && (ci->mlock_on & cbmi->flag)) { - char *value = cbmi->csgetvalue(ci); + if (ci->mlock_on && complete) { + do { + if (cbmi->csgetvalue && (ci->mlock_on & cbmi->flag)) { + char *value = cbmi->csgetvalue(ci); - if (value) { - *end++ = ' '; - while (*value) - *end++ = *value++; - } - } - } while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1); - } - } + if (value) { + *end++ = ' '; + while (*value) + *end++ = *value++; + } + } + } while ((++cbmi)->flag != 0 && ++n < sizeof(res) - 1); + } + } - *end = 0; + *end = 0; - return res; + return res; } /*************************************************************************/ @@ -188,66 +188,66 @@ char *get_mlock_modes(ChannelInfo * ci, int complete) void get_chanserv_stats(long *nrec, long *memuse) { - long count = 0, mem = 0; - int i, j; - ChannelInfo *ci; - - for (i = 0; i < 256; i++) { - for (ci = chanlists[i]; ci; ci = ci->next) { - count++; - mem += sizeof(*ci); - if (ci->desc) - mem += strlen(ci->desc) + 1; - if (ci->url) - mem += strlen(ci->url) + 1; - if (ci->email) - mem += strlen(ci->email) + 1; - mem += ci->accesscount * sizeof(ChanAccess); - mem += ci->akickcount * sizeof(AutoKick); - for (j = 0; j < ci->akickcount; j++) { - if (!(ci->akick[j].flags & AK_ISNICK) - && ci->akick[j].u.mask) - mem += strlen(ci->akick[j].u.mask) + 1; - if (ci->akick[j].reason) - mem += strlen(ci->akick[j].reason) + 1; - if (ci->akick[j].creator) - mem += strlen(ci->akick[j].creator) + 1; - } - if (ci->mlock_key) - mem += strlen(ci->mlock_key) + 1; - if (ircd->fmode) { - if (ci->mlock_flood) - mem += strlen(ci->mlock_flood) + 1; - } - if (ircd->Lmode) { - if (ci->mlock_redirect) - mem += strlen(ci->mlock_redirect) + 1; - } - if (ci->last_topic) - mem += strlen(ci->last_topic) + 1; - if (ci->entry_message) - mem += strlen(ci->entry_message) + 1; - if (ci->forbidby) - mem += strlen(ci->forbidby) + 1; - if (ci->forbidreason) - mem += strlen(ci->forbidreason) + 1; - if (ci->levels) - mem += sizeof(*ci->levels) * CA_SIZE; - mem += ci->memos.memocount * sizeof(Memo); - for (j = 0; j < ci->memos.memocount; j++) { - if (ci->memos.memos[j].text) - mem += strlen(ci->memos.memos[j].text) + 1; - } - if (ci->ttb) - mem += sizeof(*ci->ttb) * TTB_SIZE; - mem += ci->bwcount * sizeof(BadWord); - for (j = 0; j < ci->bwcount; j++) - if (ci->badwords[j].word) - mem += strlen(ci->badwords[j].word) + 1; - } - } - *nrec = count; - *memuse = mem; + long count = 0, mem = 0; + int i, j; + ChannelInfo *ci; + + for (i = 0; i < 256; i++) { + for (ci = chanlists[i]; ci; ci = ci->next) { + count++; + mem += sizeof(*ci); + if (ci->desc) + mem += strlen(ci->desc) + 1; + if (ci->url) + mem += strlen(ci->url) + 1; + if (ci->email) + mem += strlen(ci->email) + 1; + mem += ci->accesscount * sizeof(ChanAccess); + mem += ci->akickcount * sizeof(AutoKick); + for (j = 0; j < ci->akickcount; j++) { + if (!(ci->akick[j].flags & AK_ISNICK) + && ci->akick[j].u.mask) + mem += strlen(ci->akick[j].u.mask) + 1; + if (ci->akick[j].reason) + mem += strlen(ci->akick[j].reason) + 1; + if (ci->akick[j].creator) + mem += strlen(ci->akick[j].creator) + 1; + } + if (ci->mlock_key) + mem += strlen(ci->mlock_key) + 1; + if (ircd->fmode) { + if (ci->mlock_flood) + mem += strlen(ci->mlock_flood) + 1; + } + if (ircd->Lmode) { + if (ci->mlock_redirect) + mem += strlen(ci->mlock_redirect) + 1; + } + if (ci->last_topic) + mem += strlen(ci->last_topic) + 1; + if (ci->entry_message) + mem += strlen(ci->entry_message) + 1; + if (ci->forbidby) + mem += strlen(ci->forbidby) + 1; + if (ci->forbidreason) + mem += strlen(ci->forbidreason) + 1; + if (ci->levels) + mem += sizeof(*ci->levels) * CA_SIZE; + mem += ci->memos.memocount * sizeof(Memo); + for (j = 0; j < ci->memos.memocount; j++) { + if (ci->memos.memos[j].text) + mem += strlen(ci->memos.memos[j].text) + 1; + } + if (ci->ttb) + mem += sizeof(*ci->ttb) * TTB_SIZE; + mem += ci->bwcount * sizeof(BadWord); + for (j = 0; j < ci->bwcount; j++) + if (ci->badwords[j].word) + mem += strlen(ci->badwords[j].word) + 1; + } + } + *nrec = count; + *memuse = mem; } /*************************************************************************/ @@ -257,7 +257,7 @@ void get_chanserv_stats(long *nrec, long *memuse) void cs_init(void) { - moduleAddChanServCmds(); + moduleAddChanServCmds(); } /*************************************************************************/ @@ -266,20 +266,20 @@ void cs_init(void) void chanserv(User * u, char *buf) { - char *cmd, *s; - - cmd = strtok(buf, " "); - - if (!cmd) { - return; - } else if (stricmp(cmd, "\1PING") == 0) { - if (!(s = strtok(NULL, ""))) { - *s = 0; - } - ircdproto->SendCTCP(findbot(s_ChanServ), u->nick, "PING %s", s); - } else { - mod_run_cmd(s_ChanServ, u, CHANSERV, cmd); - } + char *cmd, *s; + + cmd = strtok(buf, " "); + + if (!cmd) { + return; + } else if (stricmp(cmd, "\1PING") == 0) { + if (!(s = strtok(NULL, ""))) { + *s = 0; + } + ircdproto->SendCTCP(findbot(s_ChanServ), u->nick, "PING %s", s); + } else { + mod_run_cmd(s_ChanServ, u, CHANSERV, cmd); + } } /*************************************************************************/ @@ -288,319 +288,319 @@ void chanserv(User * u, char *buf) #define SAFE(x) do { \ - if ((x) < 0) { \ + if ((x) < 0) { \ if (!forceload) \ - fatal("Read error on %s", ChanDBName); \ + fatal("Read error on %s", ChanDBName); \ failed = 1; \ break; \ - } \ + } \ } while (0) void load_cs_dbase(void) { - dbFILE *f; - int ver, i, j, c; - ChannelInfo *ci, **last, *prev; - int failed = 0; + dbFILE *f; + int ver, i, j, c; + ChannelInfo *ci, **last, *prev; + int failed = 0; - if (!(f = open_db(s_ChanServ, ChanDBName, "r", CHAN_VERSION))) - return; + if (!(f = open_db(s_ChanServ, ChanDBName, "r", CHAN_VERSION))) + return; - ver = get_file_version(f); + ver = get_file_version(f); if (ver != 16) fatal("Invalid database version! (I only understand %d)", CHAN_VERSION); - for (i = 0; i < 256 && !failed; i++) { - uint16 tmp16; - uint32 tmp32; - unsigned int read; - int n_levels; - char *s; - NickAlias *na; - - last = &chanlists[i]; - prev = NULL; - while ((c = getc_db(f)) != 0) { - if (c != 1) - fatal("Invalid format in %s", ChanDBName); - ci = (ChannelInfo *)scalloc(sizeof(ChannelInfo), 1); - *last = ci; - last = &ci->next; - ci->prev = prev; - prev = ci; - SAFE(read = read_buffer(ci->name, f)); - SAFE(read_string(&s, f)); - if (s) { - ci->founder = findcore(s); - free(s); - } else - ci->founder = NULL; - if (ver >= 7) { - SAFE(read_string(&s, f)); - if (s) { - if (ver >= 13) - ci->successor = findcore(s); - else { - na = findnick(s); - if (na) - ci->successor = na->nc; - else - ci->successor = NULL; - } - free(s); - } else - ci->successor = NULL; - } else { - ci->successor = NULL; - } - SAFE(read = read_buffer(ci->founderpass, f)); - SAFE(read_string(&ci->desc, f)); - if (!ci->desc) - ci->desc = sstrdup(""); - SAFE(read_string(&ci->url, f)); - SAFE(read_string(&ci->email, f)); - SAFE(read_int32(&tmp32, f)); - ci->time_registered = tmp32; - SAFE(read_int32(&tmp32, f)); - ci->last_used = tmp32; - SAFE(read_string(&ci->last_topic, f)); - SAFE(read = read_buffer(ci->last_topic_setter, f)); - SAFE(read_int32(&tmp32, f)); - ci->last_topic_time = tmp32; - SAFE(read_int32(&ci->flags, f)); - - /* Leaveops cleanup */ - if (ver <= 13 && (ci->flags & 0x00000020)) - ci->flags &= ~0x00000020; - /* Temporary flags cleanup */ - ci->flags &= ~CI_INHABIT; - - SAFE(read_string(&ci->forbidby, f)); - SAFE(read_string(&ci->forbidreason, f)); - SAFE(read_int16(&tmp16, f)); - ci->bantype = tmp16; - SAFE(read_int16(&tmp16, f)); - n_levels = tmp16; - ci->levels = (int16 *)scalloc(2 * CA_SIZE, 1); - reset_levels(ci); - for (j = 0; j < n_levels; j++) { - SAFE(read_int16(&tmp16, f)); - if (j < CA_SIZE) - ci->levels[j] = (int16) tmp16; - } - - SAFE(read_int16(&ci->accesscount, f)); - if (ci->accesscount) { - ci->access = (ChanAccess *)scalloc(ci->accesscount, sizeof(ChanAccess)); - for (j = 0; j < ci->accesscount; j++) { - SAFE(read_int16(&ci->access[j].in_use, f)); - if (ci->access[j].in_use) { - SAFE(read_int16(&tmp16, f)); - ci->access[j].level = (int16) tmp16; - SAFE(read_string(&s, f)); - if (s) { - ci->access[j].nc = findcore(s); - free(s); - } - if (ci->access[j].nc == NULL) - ci->access[j].in_use = 0; - SAFE(read_int32(&tmp32, f)); - ci->access[j].last_seen = tmp32; - } - } - } else { - ci->access = NULL; - } - - SAFE(read_int16(&ci->akickcount, f)); - if (ci->akickcount) { - ci->akick = (AutoKick *)scalloc(ci->akickcount, sizeof(AutoKick)); - for (j = 0; j < ci->akickcount; j++) { - SAFE(read_int16(&ci->akick[j].flags, f)); - if (ci->akick[j].flags & AK_USED) { - SAFE(read_string(&s, f)); - if (ci->akick[j].flags & AK_ISNICK) { - ci->akick[j].u.nc = findcore(s); - if (!ci->akick[j].u.nc) - ci->akick[j].flags &= ~AK_USED; - free(s); - } else { - ci->akick[j].u.mask = s; - } - SAFE(read_string(&s, f)); - if (ci->akick[j].flags & AK_USED) - ci->akick[j].reason = s; - else if (s) - free(s); - SAFE(read_string(&s, f)); - if (ci->akick[j].flags & AK_USED) { - ci->akick[j].creator = s; - } else if (s) { - free(s); - } - SAFE(read_int32(&tmp32, f)); - if (ci->akick[j].flags & AK_USED) - ci->akick[j].addtime = tmp32; - } - } - } else { - ci->akick = NULL; - } - - SAFE(read_int32(&ci->mlock_on, f)); - SAFE(read_int32(&ci->mlock_off, f)); - SAFE(read_int32(&ci->mlock_limit, f)); - SAFE(read_string(&ci->mlock_key, f)); - if (ircd->fmode) { - SAFE(read_string(&ci->mlock_flood, f)); - } else { - SAFE(read_string(&s, f)); - if (s) - free(s); - } - if (ircd->Lmode) { - SAFE(read_string(&ci->mlock_redirect, f)); - } else { - SAFE(read_string(&s, f)); - if (s) - free(s); - } - - SAFE(read_int16(&tmp16, f)); - ci->memos.memocount = (int16) tmp16; - SAFE(read_int16(&tmp16, f)); - ci->memos.memomax = (int16) tmp16; - if (ci->memos.memocount) { - Memo *memos; - memos = (Memo *)scalloc(sizeof(Memo) * ci->memos.memocount, 1); - ci->memos.memos = memos; - for (j = 0; j < ci->memos.memocount; j++, memos++) { - SAFE(read_int32(&memos->number, f)); - SAFE(read_int16(&memos->flags, f)); - SAFE(read_int32(&tmp32, f)); - memos->time = tmp32; - SAFE(read = read_buffer(memos->sender, f)); - SAFE(read_string(&memos->text, f)); - memos->moduleData = NULL; - } - } - - SAFE(read_string(&ci->entry_message, f)); - - ci->c = NULL; - - /* BotServ options */ - int n_ttb; - - SAFE(read_string(&s, f)); - if (s) { - ci->bi = findbot(s); - free(s); - } else - ci->bi = NULL; - - SAFE(read_int32(&tmp32, f)); - ci->botflags = tmp32; - SAFE(read_int16(&tmp16, f)); - n_ttb = tmp16; - ci->ttb = (int16 *)scalloc(2 * TTB_SIZE, 1); - for (j = 0; j < n_ttb; j++) { - SAFE(read_int16(&tmp16, f)); - if (j < TTB_SIZE) - ci->ttb[j] = (int16) tmp16; - } - for (j = n_ttb; j < TTB_SIZE; j++) - ci->ttb[j] = 0; - SAFE(read_int16(&tmp16, f)); - ci->capsmin = tmp16; - SAFE(read_int16(&tmp16, f)); - ci->capspercent = tmp16; - SAFE(read_int16(&tmp16, f)); - ci->floodlines = tmp16; - SAFE(read_int16(&tmp16, f)); - ci->floodsecs = tmp16; - SAFE(read_int16(&tmp16, f)); - ci->repeattimes = tmp16; - - SAFE(read_int16(&ci->bwcount, f)); - if (ci->bwcount) { - ci->badwords = (BadWord *)scalloc(ci->bwcount, sizeof(BadWord)); - for (j = 0; j < ci->bwcount; j++) { - SAFE(read_int16(&ci->badwords[j].in_use, f)); - if (ci->badwords[j].in_use) { - SAFE(read_string(&ci->badwords[j].word, f)); - SAFE(read_int16(&ci->badwords[j].type, f)); - } - } - } else { - ci->badwords = NULL; - } - } /* while (getc_db(f) != 0) */ - - *last = NULL; - - } /* for (i) */ - - close_db(f); - - /* Check for non-forbidden channels with no founder. - Makes also other essential tasks. */ - for (i = 0; i < 256; i++) { - ChannelInfo *next; - for (ci = chanlists[i]; ci; ci = next) { - next = ci->next; - if (!(ci->flags & CI_VERBOTEN) && !ci->founder) { - alog("%s: database load: Deleting founderless channel %s", - s_ChanServ, ci->name); - delchan(ci); - continue; - } - if (ver < 13) { - ChanAccess *access, *access2; - AutoKick *akick, *akick2; - int k; - - if (ci->flags & CI_VERBOTEN) - continue; - /* Need to regenerate the channel count for the founder */ - ci->founder->channelcount++; - /* Check for eventual double entries in access/akick lists. */ - for (j = 0, access = ci->access; j < ci->accesscount; - j++, access++) { - if (!access->in_use) - continue; - for (k = 0, access2 = ci->access; k < j; - k++, access2++) { - if (access2->in_use && access2->nc == access->nc) { - alog("%s: deleting %s channel access entry of %s because it is already in the list (this is OK).", s_ChanServ, access->nc->display, ci->name); - memset(access, 0, sizeof(ChanAccess)); - break; - } - } - } - for (j = 0, akick = ci->akick; j < ci->akickcount; - j++, akick++) { - if (!(akick->flags & AK_USED) - || !(akick->flags & AK_ISNICK)) - continue; - for (k = 0, akick2 = ci->akick; k < j; k++, akick2++) { - if ((akick2->flags & AK_USED) - && (akick2->flags & AK_ISNICK) - && akick2->u.nc == akick->u.nc) { - alog("%s: deleting %s channel akick entry of %s because it is already in the list (this is OK).", s_ChanServ, akick->u.nc->display, ci->name); - if (akick->reason) - free(akick->reason); - if (akick->creator) - free(akick->creator); - memset(akick, 0, sizeof(AutoKick)); - break; - } - } - } - } - } - } + for (i = 0; i < 256 && !failed; i++) { + uint16 tmp16; + uint32 tmp32; + unsigned int read; + int n_levels; + char *s; + NickAlias *na; + + last = &chanlists[i]; + prev = NULL; + while ((c = getc_db(f)) != 0) { + if (c != 1) + fatal("Invalid format in %s", ChanDBName); + ci = (ChannelInfo *)scalloc(sizeof(ChannelInfo), 1); + *last = ci; + last = &ci->next; + ci->prev = prev; + prev = ci; + SAFE(read = read_buffer(ci->name, f)); + SAFE(read_string(&s, f)); + if (s) { + ci->founder = findcore(s); + free(s); + } else + ci->founder = NULL; + if (ver >= 7) { + SAFE(read_string(&s, f)); + if (s) { + if (ver >= 13) + ci->successor = findcore(s); + else { + na = findnick(s); + if (na) + ci->successor = na->nc; + else + ci->successor = NULL; + } + free(s); + } else + ci->successor = NULL; + } else { + ci->successor = NULL; + } + SAFE(read = read_buffer(ci->founderpass, f)); + SAFE(read_string(&ci->desc, f)); + if (!ci->desc) + ci->desc = sstrdup(""); + SAFE(read_string(&ci->url, f)); + SAFE(read_string(&ci->email, f)); + SAFE(read_int32(&tmp32, f)); + ci->time_registered = tmp32; + SAFE(read_int32(&tmp32, f)); + ci->last_used = tmp32; + SAFE(read_string(&ci->last_topic, f)); + SAFE(read = read_buffer(ci->last_topic_setter, f)); + SAFE(read_int32(&tmp32, f)); + ci->last_topic_time = tmp32; + SAFE(read_int32(&ci->flags, f)); + + /* Leaveops cleanup */ + if (ver <= 13 && (ci->flags & 0x00000020)) + ci->flags &= ~0x00000020; + /* Temporary flags cleanup */ + ci->flags &= ~CI_INHABIT; + + SAFE(read_string(&ci->forbidby, f)); + SAFE(read_string(&ci->forbidreason, f)); + SAFE(read_int16(&tmp16, f)); + ci->bantype = tmp16; + SAFE(read_int16(&tmp16, f)); + n_levels = tmp16; + ci->levels = (int16 *)scalloc(2 * CA_SIZE, 1); + reset_levels(ci); + for (j = 0; j < n_levels; j++) { + SAFE(read_int16(&tmp16, f)); + if (j < CA_SIZE) + ci->levels[j] = (int16) tmp16; + } + + SAFE(read_int16(&ci->accesscount, f)); + if (ci->accesscount) { + ci->access = (ChanAccess *)scalloc(ci->accesscount, sizeof(ChanAccess)); + for (j = 0; j < ci->accesscount; j++) { + SAFE(read_int16(&ci->access[j].in_use, f)); + if (ci->access[j].in_use) { + SAFE(read_int16(&tmp16, f)); + ci->access[j].level = (int16) tmp16; + SAFE(read_string(&s, f)); + if (s) { + ci->access[j].nc = findcore(s); + free(s); + } + if (ci->access[j].nc == NULL) + ci->access[j].in_use = 0; + SAFE(read_int32(&tmp32, f)); + ci->access[j].last_seen = tmp32; + } + } + } else { + ci->access = NULL; + } + + SAFE(read_int16(&ci->akickcount, f)); + if (ci->akickcount) { + ci->akick = (AutoKick *)scalloc(ci->akickcount, sizeof(AutoKick)); + for (j = 0; j < ci->akickcount; j++) { + SAFE(read_int16(&ci->akick[j].flags, f)); + if (ci->akick[j].flags & AK_USED) { + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & AK_ISNICK) { + ci->akick[j].u.nc = findcore(s); + if (!ci->akick[j].u.nc) + ci->akick[j].flags &= ~AK_USED; + free(s); + } else { + ci->akick[j].u.mask = s; + } + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & AK_USED) + ci->akick[j].reason = s; + else if (s) + free(s); + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & AK_USED) { + ci->akick[j].creator = s; + } else if (s) { + free(s); + } + SAFE(read_int32(&tmp32, f)); + if (ci->akick[j].flags & AK_USED) + ci->akick[j].addtime = tmp32; + } + } + } else { + ci->akick = NULL; + } + + SAFE(read_int32(&ci->mlock_on, f)); + SAFE(read_int32(&ci->mlock_off, f)); + SAFE(read_int32(&ci->mlock_limit, f)); + SAFE(read_string(&ci->mlock_key, f)); + if (ircd->fmode) { + SAFE(read_string(&ci->mlock_flood, f)); + } else { + SAFE(read_string(&s, f)); + if (s) + free(s); + } + if (ircd->Lmode) { + SAFE(read_string(&ci->mlock_redirect, f)); + } else { + SAFE(read_string(&s, f)); + if (s) + free(s); + } + + SAFE(read_int16(&tmp16, f)); + ci->memos.memocount = (int16) tmp16; + SAFE(read_int16(&tmp16, f)); + ci->memos.memomax = (int16) tmp16; + if (ci->memos.memocount) { + Memo *memos; + memos = (Memo *)scalloc(sizeof(Memo) * ci->memos.memocount, 1); + ci->memos.memos = memos; + for (j = 0; j < ci->memos.memocount; j++, memos++) { + SAFE(read_int32(&memos->number, f)); + SAFE(read_int16(&memos->flags, f)); + SAFE(read_int32(&tmp32, f)); + memos->time = tmp32; + SAFE(read = read_buffer(memos->sender, f)); + SAFE(read_string(&memos->text, f)); + memos->moduleData = NULL; + } + } + + SAFE(read_string(&ci->entry_message, f)); + + ci->c = NULL; + + /* BotServ options */ + int n_ttb; + + SAFE(read_string(&s, f)); + if (s) { + ci->bi = findbot(s); + free(s); + } else + ci->bi = NULL; + + SAFE(read_int32(&tmp32, f)); + ci->botflags = tmp32; + SAFE(read_int16(&tmp16, f)); + n_ttb = tmp16; + ci->ttb = (int16 *)scalloc(2 * TTB_SIZE, 1); + for (j = 0; j < n_ttb; j++) { + SAFE(read_int16(&tmp16, f)); + if (j < TTB_SIZE) + ci->ttb[j] = (int16) tmp16; + } + for (j = n_ttb; j < TTB_SIZE; j++) + ci->ttb[j] = 0; + SAFE(read_int16(&tmp16, f)); + ci->capsmin = tmp16; + SAFE(read_int16(&tmp16, f)); + ci->capspercent = tmp16; + SAFE(read_int16(&tmp16, f)); + ci->floodlines = tmp16; + SAFE(read_int16(&tmp16, f)); + ci->floodsecs = tmp16; + SAFE(read_int16(&tmp16, f)); + ci->repeattimes = tmp16; + + SAFE(read_int16(&ci->bwcount, f)); + if (ci->bwcount) { + ci->badwords = (BadWord *)scalloc(ci->bwcount, sizeof(BadWord)); + for (j = 0; j < ci->bwcount; j++) { + SAFE(read_int16(&ci->badwords[j].in_use, f)); + if (ci->badwords[j].in_use) { + SAFE(read_string(&ci->badwords[j].word, f)); + SAFE(read_int16(&ci->badwords[j].type, f)); + } + } + } else { + ci->badwords = NULL; + } + } /* while (getc_db(f) != 0) */ + + *last = NULL; + + } /* for (i) */ + + close_db(f); + + /* Check for non-forbidden channels with no founder. + Makes also other essential tasks. */ + for (i = 0; i < 256; i++) { + ChannelInfo *next; + for (ci = chanlists[i]; ci; ci = next) { + next = ci->next; + if (!(ci->flags & CI_VERBOTEN) && !ci->founder) { + alog("%s: database load: Deleting founderless channel %s", + s_ChanServ, ci->name); + delchan(ci); + continue; + } + if (ver < 13) { + ChanAccess *access, *access2; + AutoKick *akick, *akick2; + int k; + + if (ci->flags & CI_VERBOTEN) + continue; + /* Need to regenerate the channel count for the founder */ + ci->founder->channelcount++; + /* Check for eventual double entries in access/akick lists. */ + for (j = 0, access = ci->access; j < ci->accesscount; + j++, access++) { + if (!access->in_use) + continue; + for (k = 0, access2 = ci->access; k < j; + k++, access2++) { + if (access2->in_use && access2->nc == access->nc) { + alog("%s: deleting %s channel access entry of %s because it is already in the list (this is OK).", s_ChanServ, access->nc->display, ci->name); + memset(access, 0, sizeof(ChanAccess)); + break; + } + } + } + for (j = 0, akick = ci->akick; j < ci->akickcount; + j++, akick++) { + if (!(akick->flags & AK_USED) + || !(akick->flags & AK_ISNICK)) + continue; + for (k = 0, akick2 = ci->akick; k < j; k++, akick2++) { + if ((akick2->flags & AK_USED) + && (akick2->flags & AK_ISNICK) + && akick2->u.nc == akick->u.nc) { + alog("%s: deleting %s channel akick entry of %s because it is already in the list (this is OK).", s_ChanServ, akick->u.nc->display, ci->name); + if (akick->reason) + free(akick->reason); + if (akick->creator) + free(akick->creator); + memset(akick, 0, sizeof(AutoKick)); + break; + } + } + } + } + } + } } #undef SAFE @@ -608,147 +608,147 @@ void load_cs_dbase(void) /*************************************************************************/ #define SAFE(x) do { \ - if ((x) < 0) { \ + if ((x) < 0) { \ restore_db(f); \ log_perror("Write error on %s", ChanDBName); \ if (time(NULL) - lastwarn > WarningTimeout) { \ - ircdproto->SendGlobops(NULL, "Write error on %s: %s", ChanDBName, \ + ircdproto->SendGlobops(NULL, "Write error on %s: %s", ChanDBName, \ strerror(errno)); \ - lastwarn = time(NULL); \ + lastwarn = time(NULL); \ } \ return; \ - } \ + } \ } while (0) void save_cs_dbase(void) { - dbFILE *f; - int i, j; - ChannelInfo *ci; - Memo *memos; - static time_t lastwarn = 0; - - if (!(f = open_db(s_ChanServ, ChanDBName, "w", CHAN_VERSION))) - return; - - for (i = 0; i < 256; i++) { - int16 tmp16; - unsigned int written; - - for (ci = chanlists[i]; ci; ci = ci->next) { - SAFE(write_int8(1, f)); - SAFE(written = write_buffer(ci->name, f)); - if (ci->founder) - SAFE(write_string(ci->founder->display, f)); - else - SAFE(write_string(NULL, f)); - if (ci->successor) - SAFE(write_string(ci->successor->display, f)); - else - SAFE(write_string(NULL, f)); - SAFE(written = write_buffer(ci->founderpass, f)); - SAFE(write_string(ci->desc, f)); - SAFE(write_string(ci->url, f)); - SAFE(write_string(ci->email, f)); - SAFE(write_int32(ci->time_registered, f)); - SAFE(write_int32(ci->last_used, f)); - SAFE(write_string(ci->last_topic, f)); - SAFE(written = write_buffer(ci->last_topic_setter, f)); - SAFE(write_int32(ci->last_topic_time, f)); - SAFE(write_int32(ci->flags, f)); - SAFE(write_string(ci->forbidby, f)); - SAFE(write_string(ci->forbidreason, f)); - SAFE(write_int16(ci->bantype, f)); - - tmp16 = CA_SIZE; - SAFE(write_int16(tmp16, f)); - for (j = 0; j < CA_SIZE; j++) - SAFE(write_int16(ci->levels[j], f)); - - SAFE(write_int16(ci->accesscount, f)); - for (j = 0; j < ci->accesscount; j++) { - SAFE(write_int16(ci->access[j].in_use, f)); - if (ci->access[j].in_use) { - SAFE(write_int16(ci->access[j].level, f)); - SAFE(write_string(ci->access[j].nc->display, f)); - SAFE(write_int32(ci->access[j].last_seen, f)); - } - } - - SAFE(write_int16(ci->akickcount, f)); - for (j = 0; j < ci->akickcount; j++) { - SAFE(write_int16(ci->akick[j].flags, f)); - if (ci->akick[j].flags & AK_USED) { - if (ci->akick[j].flags & AK_ISNICK) - SAFE(write_string(ci->akick[j].u.nc->display, f)); - else - SAFE(write_string(ci->akick[j].u.mask, f)); - SAFE(write_string(ci->akick[j].reason, f)); - SAFE(write_string(ci->akick[j].creator, f)); - SAFE(write_int32(ci->akick[j].addtime, f)); - } - } - - SAFE(write_int32(ci->mlock_on, f)); - SAFE(write_int32(ci->mlock_off, f)); - SAFE(write_int32(ci->mlock_limit, f)); - SAFE(write_string(ci->mlock_key, f)); - if (ircd->fmode) { - SAFE(write_string(ci->mlock_flood, f)); - } else { - SAFE(write_string(NULL, f)); - } - if (ircd->Lmode) { - SAFE(write_string(ci->mlock_redirect, f)); - } else { - SAFE(write_string(NULL, f)); - } - SAFE(write_int16(ci->memos.memocount, f)); - SAFE(write_int16(ci->memos.memomax, f)); - memos = ci->memos.memos; - for (j = 0; j < ci->memos.memocount; j++, memos++) { - SAFE(write_int32(memos->number, f)); - SAFE(write_int16(memos->flags, f)); - SAFE(write_int32(memos->time, f)); - SAFE(written = write_buffer(memos->sender, f)); - SAFE(write_string(memos->text, f)); - } - - SAFE(write_string(ci->entry_message, f)); - - if (ci->bi) - SAFE(write_string(ci->bi->nick, f)); - else - SAFE(write_string(NULL, f)); - - SAFE(write_int32(ci->botflags, f)); - - tmp16 = TTB_SIZE; - SAFE(write_int16(tmp16, f)); - for (j = 0; j < TTB_SIZE; j++) - SAFE(write_int16(ci->ttb[j], f)); - - SAFE(write_int16(ci->capsmin, f)); - SAFE(write_int16(ci->capspercent, f)); - SAFE(write_int16(ci->floodlines, f)); - SAFE(write_int16(ci->floodsecs, f)); - SAFE(write_int16(ci->repeattimes, f)); - - SAFE(write_int16(ci->bwcount, f)); - for (j = 0; j < ci->bwcount; j++) { - SAFE(write_int16(ci->badwords[j].in_use, f)); - if (ci->badwords[j].in_use) { - SAFE(write_string(ci->badwords[j].word, f)); - SAFE(write_int16(ci->badwords[j].type, f)); - } - } - } /* for (chanlists[i]) */ - - SAFE(write_int8(0, f)); - - } /* for (i) */ - - close_db(f); + dbFILE *f; + int i, j; + ChannelInfo *ci; + Memo *memos; + static time_t lastwarn = 0; + + if (!(f = open_db(s_ChanServ, ChanDBName, "w", CHAN_VERSION))) + return; + + for (i = 0; i < 256; i++) { + int16 tmp16; + unsigned int written; + + for (ci = chanlists[i]; ci; ci = ci->next) { + SAFE(write_int8(1, f)); + SAFE(written = write_buffer(ci->name, f)); + if (ci->founder) + SAFE(write_string(ci->founder->display, f)); + else + SAFE(write_string(NULL, f)); + if (ci->successor) + SAFE(write_string(ci->successor->display, f)); + else + SAFE(write_string(NULL, f)); + SAFE(written = write_buffer(ci->founderpass, f)); + SAFE(write_string(ci->desc, f)); + SAFE(write_string(ci->url, f)); + SAFE(write_string(ci->email, f)); + SAFE(write_int32(ci->time_registered, f)); + SAFE(write_int32(ci->last_used, f)); + SAFE(write_string(ci->last_topic, f)); + SAFE(written = write_buffer(ci->last_topic_setter, f)); + SAFE(write_int32(ci->last_topic_time, f)); + SAFE(write_int32(ci->flags, f)); + SAFE(write_string(ci->forbidby, f)); + SAFE(write_string(ci->forbidreason, f)); + SAFE(write_int16(ci->bantype, f)); + + tmp16 = CA_SIZE; + SAFE(write_int16(tmp16, f)); + for (j = 0; j < CA_SIZE; j++) + SAFE(write_int16(ci->levels[j], f)); + + SAFE(write_int16(ci->accesscount, f)); + for (j = 0; j < ci->accesscount; j++) { + SAFE(write_int16(ci->access[j].in_use, f)); + if (ci->access[j].in_use) { + SAFE(write_int16(ci->access[j].level, f)); + SAFE(write_string(ci->access[j].nc->display, f)); + SAFE(write_int32(ci->access[j].last_seen, f)); + } + } + + SAFE(write_int16(ci->akickcount, f)); + for (j = 0; j < ci->akickcount; j++) { + SAFE(write_int16(ci->akick[j].flags, f)); + if (ci->akick[j].flags & AK_USED) { + if (ci->akick[j].flags & AK_ISNICK) + SAFE(write_string(ci->akick[j].u.nc->display, f)); + else + SAFE(write_string(ci->akick[j].u.mask, f)); + SAFE(write_string(ci->akick[j].reason, f)); + SAFE(write_string(ci->akick[j].creator, f)); + SAFE(write_int32(ci->akick[j].addtime, f)); + } + } + + SAFE(write_int32(ci->mlock_on, f)); + SAFE(write_int32(ci->mlock_off, f)); + SAFE(write_int32(ci->mlock_limit, f)); + SAFE(write_string(ci->mlock_key, f)); + if (ircd->fmode) { + SAFE(write_string(ci->mlock_flood, f)); + } else { + SAFE(write_string(NULL, f)); + } + if (ircd->Lmode) { + SAFE(write_string(ci->mlock_redirect, f)); + } else { + SAFE(write_string(NULL, f)); + } + SAFE(write_int16(ci->memos.memocount, f)); + SAFE(write_int16(ci->memos.memomax, f)); + memos = ci->memos.memos; + for (j = 0; j < ci->memos.memocount; j++, memos++) { + SAFE(write_int32(memos->number, f)); + SAFE(write_int16(memos->flags, f)); + SAFE(write_int32(memos->time, f)); + SAFE(written = write_buffer(memos->sender, f)); + SAFE(write_string(memos->text, f)); + } + + SAFE(write_string(ci->entry_message, f)); + + if (ci->bi) + SAFE(write_string(ci->bi->nick, f)); + else + SAFE(write_string(NULL, f)); + + SAFE(write_int32(ci->botflags, f)); + + tmp16 = TTB_SIZE; + SAFE(write_int16(tmp16, f)); + for (j = 0; j < TTB_SIZE; j++) + SAFE(write_int16(ci->ttb[j], f)); + + SAFE(write_int16(ci->capsmin, f)); + SAFE(write_int16(ci->capspercent, f)); + SAFE(write_int16(ci->floodlines, f)); + SAFE(write_int16(ci->floodsecs, f)); + SAFE(write_int16(ci->repeattimes, f)); + + SAFE(write_int16(ci->bwcount, f)); + for (j = 0; j < ci->bwcount; j++) { + SAFE(write_int16(ci->badwords[j].in_use, f)); + if (ci->badwords[j].in_use) { + SAFE(write_string(ci->badwords[j].word, f)); + SAFE(write_int16(ci->badwords[j].type, f)); + } + } + } /* for (chanlists[i]) */ + + SAFE(write_int8(0, f)); + + } /* for (i) */ + + close_db(f); } @@ -766,186 +766,186 @@ void save_cs_dbase(void) void check_modes(Channel * c) { - char modebuf[64], argbuf[BUFSIZE], *end = modebuf, *end2 = argbuf; - uint32 modes; - ChannelInfo *ci; - CBModeInfo *cbmi; - CBMode *cbm; - - if (!c) { - if (debug) { - alog("debug: check_modes called with NULL values"); - } - return; - } - - if (c->bouncy_modes) - return; - - /* Check for mode bouncing */ - if (c->server_modecount >= 3 && c->chanserv_modecount >= 3) { - ircdproto->SendGlobops(NULL, - "Warning: unable to set modes on channel %s. " - "Are your servers' U:lines configured correctly?", - c->name); - alog("%s: Bouncy modes on channel %s", s_ChanServ, c->name); - c->bouncy_modes = 1; - return; - } - - if (c->chanserv_modetime != time(NULL)) { - c->chanserv_modecount = 0; - c->chanserv_modetime = time(NULL); - } - c->chanserv_modecount++; - - /* Check if the channel is registered; if not remove mode -r */ - if (!(ci = c->ci)) { - if (ircd->regmode) { - if (c->mode & ircd->regmode) { - c->mode &= ~ircd->regmode; - ircdproto->SendMode(whosends(ci), c->name, "-r"); - } - } - return; - } - - /* Initialize te modes-var to set all modes not set yet but which should - * be set as by mlock and defcon. - */ - modes = ~c->mode & ci->mlock_on; - if (DefConModesSet) - modes |= (~c->mode & DefConModesOn); - - /* Initialize the buffers */ - *end++ = '+'; - cbmi = cbmodeinfos; - - do { - if (modes & cbmi->flag) { - *end++ = cbmi->mode; - c->mode |= cbmi->flag; - - /* Add the eventual parameter and modify the Channel structure */ - if (cbmi->getvalue && cbmi->csgetvalue) { - char *value; - /* Check if it's a defcon or mlock mode */ - if (DefConModesOn & cbmi->flag) - value = cbmi->csgetvalue(&DefConModesCI); - else - value = cbmi->csgetvalue(ci); - - cbm = &cbmodes[(int) cbmi->mode]; - cbm->setvalue(c, value); - - if (value) { - *end2++ = ' '; - while (*value) - *end2++ = *value++; - } - } - } else if (cbmi->getvalue && cbmi->csgetvalue - && ((ci->mlock_on & cbmi->flag) - || (DefConModesOn & cbmi->flag)) - && (c->mode & cbmi->flag)) { - char *value = cbmi->getvalue(c); - char *csvalue; - - /* Check if it's a defcon or mlock mode */ - if (DefConModesOn & cbmi->flag) - csvalue = cbmi->csgetvalue(&DefConModesCI); - else - csvalue = cbmi->csgetvalue(ci); - - /* Lock and actual values don't match, so fix the mode */ - if (value && csvalue && strcmp(value, csvalue)) { - *end++ = cbmi->mode; - - cbm = &cbmodes[(int) cbmi->mode]; - cbm->setvalue(c, csvalue); - - *end2++ = ' '; - while (*csvalue) - *end2++ = *csvalue++; - } - } - } while ((++cbmi)->flag != 0); - - if (*(end - 1) == '+') - end--; - - modes = c->mode & ci->mlock_off; - if (DefConModesSet) - modes |= (~c->mode & DefConModesOff); - - if (modes) { - *end++ = '-'; - cbmi = cbmodeinfos; - - do { - if (modes & cbmi->flag) { - *end++ = cbmi->mode; - c->mode &= ~cbmi->flag; - - /* Add the eventual parameter and clean up the Channel structure */ - if (cbmi->getvalue) { - cbm = &cbmodes[(int) cbmi->mode]; - - if (!(cbm->flags & CBM_MINUS_NO_ARG)) { - char *value = cbmi->getvalue(c); - - if (value) { - *end2++ = ' '; - while (*value) - *end2++ = *value++; - } - } - - cbm->setvalue(c, NULL); - } - } - } while ((++cbmi)->flag != 0); - } - - if (end == modebuf) - return; - - *end = 0; - *end2 = 0; - - ircdproto->SendMode(whosends(ci), c->name, "%s%s", modebuf, - (end2 == argbuf ? "" : argbuf)); + char modebuf[64], argbuf[BUFSIZE], *end = modebuf, *end2 = argbuf; + uint32 modes; + ChannelInfo *ci; + CBModeInfo *cbmi; + CBMode *cbm; + + if (!c) { + if (debug) { + alog("debug: check_modes called with NULL values"); + } + return; + } + + if (c->bouncy_modes) + return; + + /* Check for mode bouncing */ + if (c->server_modecount >= 3 && c->chanserv_modecount >= 3) { + ircdproto->SendGlobops(NULL, + "Warning: unable to set modes on channel %s. " + "Are your servers' U:lines configured correctly?", + c->name); + alog("%s: Bouncy modes on channel %s", s_ChanServ, c->name); + c->bouncy_modes = 1; + return; + } + + if (c->chanserv_modetime != time(NULL)) { + c->chanserv_modecount = 0; + c->chanserv_modetime = time(NULL); + } + c->chanserv_modecount++; + + /* Check if the channel is registered; if not remove mode -r */ + if (!(ci = c->ci)) { + if (ircd->regmode) { + if (c->mode & ircd->regmode) { + c->mode &= ~ircd->regmode; + ircdproto->SendMode(whosends(ci), c->name, "-r"); + } + } + return; + } + + /* Initialize te modes-var to set all modes not set yet but which should + * be set as by mlock and defcon. + */ + modes = ~c->mode & ci->mlock_on; + if (DefConModesSet) + modes |= (~c->mode & DefConModesOn); + + /* Initialize the buffers */ + *end++ = '+'; + cbmi = cbmodeinfos; + + do { + if (modes & cbmi->flag) { + *end++ = cbmi->mode; + c->mode |= cbmi->flag; + + /* Add the eventual parameter and modify the Channel structure */ + if (cbmi->getvalue && cbmi->csgetvalue) { + char *value; + /* Check if it's a defcon or mlock mode */ + if (DefConModesOn & cbmi->flag) + value = cbmi->csgetvalue(&DefConModesCI); + else + value = cbmi->csgetvalue(ci); + + cbm = &cbmodes[(int) cbmi->mode]; + cbm->setvalue(c, value); + + if (value) { + *end2++ = ' '; + while (*value) + *end2++ = *value++; + } + } + } else if (cbmi->getvalue && cbmi->csgetvalue + && ((ci->mlock_on & cbmi->flag) + || (DefConModesOn & cbmi->flag)) + && (c->mode & cbmi->flag)) { + char *value = cbmi->getvalue(c); + char *csvalue; + + /* Check if it's a defcon or mlock mode */ + if (DefConModesOn & cbmi->flag) + csvalue = cbmi->csgetvalue(&DefConModesCI); + else + csvalue = cbmi->csgetvalue(ci); + + /* Lock and actual values don't match, so fix the mode */ + if (value && csvalue && strcmp(value, csvalue)) { + *end++ = cbmi->mode; + + cbm = &cbmodes[(int) cbmi->mode]; + cbm->setvalue(c, csvalue); + + *end2++ = ' '; + while (*csvalue) + *end2++ = *csvalue++; + } + } + } while ((++cbmi)->flag != 0); + + if (*(end - 1) == '+') + end--; + + modes = c->mode & ci->mlock_off; + if (DefConModesSet) + modes |= (~c->mode & DefConModesOff); + + if (modes) { + *end++ = '-'; + cbmi = cbmodeinfos; + + do { + if (modes & cbmi->flag) { + *end++ = cbmi->mode; + c->mode &= ~cbmi->flag; + + /* Add the eventual parameter and clean up the Channel structure */ + if (cbmi->getvalue) { + cbm = &cbmodes[(int) cbmi->mode]; + + if (!(cbm->flags & CBM_MINUS_NO_ARG)) { + char *value = cbmi->getvalue(c); + + if (value) { + *end2++ = ' '; + while (*value) + *end2++ = *value++; + } + } + + cbm->setvalue(c, NULL); + } + } + } while ((++cbmi)->flag != 0); + } + + if (end == modebuf) + return; + + *end = 0; + *end2 = 0; + + ircdproto->SendMode(whosends(ci), c->name, "%s%s", modebuf, + (end2 == argbuf ? "" : argbuf)); } /*************************************************************************/ int check_valid_admin(User * user, Channel * chan, int servermode) { - if (!chan || !chan->ci) - return 1; - - if (!ircd->admin) { - return 0; - } - - /* They will be kicked; no need to deop, no need to update our internal struct too */ - if (chan->ci->flags & CI_VERBOTEN) - return 0; - - if (servermode && !check_access(user, chan->ci, CA_AUTOPROTECT)) { - notice_lang(s_ChanServ, user, CHAN_IS_REGISTERED, s_ChanServ); - ircdproto->SendMode(whosends(chan->ci), chan->name, "%s %s", - ircd->adminunset, user->nick); - return 0; - } - - if (check_access(user, chan->ci, CA_AUTODEOP)) { - ircdproto->SendMode(whosends(chan->ci), chan->name, "%s %s", - ircd->adminunset, user->nick); - return 0; - } - - return 1; + if (!chan || !chan->ci) + return 1; + + if (!ircd->admin) { + return 0; + } + + /* They will be kicked; no need to deop, no need to update our internal struct too */ + if (chan->ci->flags & CI_VERBOTEN) + return 0; + + if (servermode && !check_access(user, chan->ci, CA_AUTOPROTECT)) { + notice_lang(s_ChanServ, user, CHAN_IS_REGISTERED, s_ChanServ); + ircdproto->SendMode(whosends(chan->ci), chan->name, "%s %s", + ircd->adminunset, user->nick); + return 0; + } + + if (check_access(user, chan->ci, CA_AUTODEOP)) { + ircdproto->SendMode(whosends(chan->ci), chan->name, "%s %s", + ircd->adminunset, user->nick); + return 0; + } + + return 1; } /*************************************************************************/ @@ -956,81 +956,81 @@ int check_valid_admin(User * user, Channel * chan, int servermode) int check_valid_op(User * user, Channel * chan, int servermode) { - char *tmp; - if (!chan || !chan->ci) - return 1; - - /* They will be kicked; no need to deop, no need to update our internal struct too */ - if (chan->ci->flags & CI_VERBOTEN) - return 0; - - if (servermode && !check_access(user, chan->ci, CA_AUTOOP)) { - notice_lang(s_ChanServ, user, CHAN_IS_REGISTERED, s_ChanServ); - if (ircd->halfop) { - if (ircd->owner && ircd->protect) { - if (check_access(user, chan->ci, CA_AUTOHALFOP)) { - tmp = stripModePrefix(ircd->ownerunset); - ircdproto->SendMode(whosends(chan->ci), chan->name, - "%so%s %s %s %s", ircd->adminunset, - tmp, user->nick, - user->nick, user->nick); - free(tmp); - } else { - tmp = stripModePrefix(ircd->ownerunset); - ircdproto->SendMode(whosends(chan->ci), chan->name, - "%sho%s %s %s %s %s", - ircd->adminunset, tmp, - user->nick, user->nick, user->nick, - user->nick); - free(tmp); - } - } else if (!ircd->owner && ircd->protect) { - if (check_access(user, chan->ci, CA_AUTOHALFOP)) { - ircdproto->SendMode(whosends(chan->ci), chan->name, - "%so %s %s", ircd->adminunset, - user->nick, user->nick); - } else { - ircdproto->SendMode(whosends(chan->ci), chan->name, - "%soh %s %s %s", ircd->adminunset, - user->nick, user->nick, user->nick); - } - } else { - if (check_access(user, chan->ci, CA_AUTOHALFOP)) { - ircdproto->SendMode(whosends(chan->ci), chan->name, "-o %s", - user->nick); - } else { - ircdproto->SendMode(whosends(chan->ci), chan->name, - "-ho %s %s", user->nick, user->nick); - } - } - } else { - ircdproto->SendMode(whosends(chan->ci), chan->name, "-o %s", - user->nick); - } - return 0; - } - - if (check_access(user, chan->ci, CA_AUTODEOP)) { - if (ircd->halfop) { - if (ircd->owner && ircd->protect) { - tmp = stripModePrefix(ircd->ownerunset); - ircdproto->SendMode(whosends(chan->ci), chan->name, - "%sho%s %s %s %s %s", ircd->adminunset, - tmp, user->nick, user->nick, - user->nick, user->nick); - free(tmp); - } else { - ircdproto->SendMode(whosends(chan->ci), chan->name, "-ho %s %s", - user->nick, user->nick); - } - } else { - ircdproto->SendMode(whosends(chan->ci), chan->name, "-o %s", - user->nick); - } - return 0; - } - - return 1; + char *tmp; + if (!chan || !chan->ci) + return 1; + + /* They will be kicked; no need to deop, no need to update our internal struct too */ + if (chan->ci->flags & CI_VERBOTEN) + return 0; + + if (servermode && !check_access(user, chan->ci, CA_AUTOOP)) { + notice_lang(s_ChanServ, user, CHAN_IS_REGISTERED, s_ChanServ); + if (ircd->halfop) { + if (ircd->owner && ircd->protect) { + if (check_access(user, chan->ci, CA_AUTOHALFOP)) { + tmp = stripModePrefix(ircd->ownerunset); + ircdproto->SendMode(whosends(chan->ci), chan->name, + "%so%s %s %s %s", ircd->adminunset, + tmp, user->nick, + user->nick, user->nick); + free(tmp); + } else { + tmp = stripModePrefix(ircd->ownerunset); + ircdproto->SendMode(whosends(chan->ci), chan->name, + "%sho%s %s %s %s %s", + ircd->adminunset, tmp, + user->nick, user->nick, user->nick, + user->nick); + free(tmp); + } + } else if (!ircd->owner && ircd->protect) { + if (check_access(user, chan->ci, CA_AUTOHALFOP)) { + ircdproto->SendMode(whosends(chan->ci), chan->name, + "%so %s %s", ircd->adminunset, + user->nick, user->nick); + } else { + ircdproto->SendMode(whosends(chan->ci), chan->name, + "%soh %s %s %s", ircd->adminunset, + user->nick, user->nick, user->nick); + } + } else { + if (check_access(user, chan->ci, CA_AUTOHALFOP)) { + ircdproto->SendMode(whosends(chan->ci), chan->name, "-o %s", + user->nick); + } else { + ircdproto->SendMode(whosends(chan->ci), chan->name, + "-ho %s %s", user->nick, user->nick); + } + } + } else { + ircdproto->SendMode(whosends(chan->ci), chan->name, "-o %s", + user->nick); + } + return 0; + } + + if (check_access(user, chan->ci, CA_AUTODEOP)) { + if (ircd->halfop) { + if (ircd->owner && ircd->protect) { + tmp = stripModePrefix(ircd->ownerunset); + ircdproto->SendMode(whosends(chan->ci), chan->name, + "%sho%s %s %s %s %s", ircd->adminunset, + tmp, user->nick, user->nick, + user->nick, user->nick); + free(tmp); + } else { + ircdproto->SendMode(whosends(chan->ci), chan->name, "-ho %s %s", + user->nick, user->nick); + } + } else { + ircdproto->SendMode(whosends(chan->ci), chan->name, "-o %s", + user->nick); + } + return 0; + } + + return 1; } /*************************************************************************/ @@ -1041,20 +1041,20 @@ int check_valid_op(User * user, Channel * chan, int servermode) int check_should_op(User * user, char *chan) { - ChannelInfo *ci = cs_findchan(chan); + ChannelInfo *ci = cs_findchan(chan); - if (!ci || (ci->flags & CI_VERBOTEN) || *chan == '+') - return 0; + if (!ci || (ci->flags & CI_VERBOTEN) || *chan == '+') + return 0; - if ((ci->flags & CI_SECURE) && !nick_identified(user)) - return 0; + if ((ci->flags & CI_SECURE) && !nick_identified(user)) + return 0; - if (check_access(user, ci, CA_AUTOOP)) { - ircdproto->SendMode(whosends(ci), chan, "+o %s", user->nick); - return 1; - } + if (check_access(user, ci, CA_AUTOOP)) { + ircdproto->SendMode(whosends(ci), chan, "+o %s", user->nick); + return 1; + } - return 0; + return 0; } /*************************************************************************/ @@ -1064,80 +1064,80 @@ int check_should_op(User * user, char *chan) int check_should_voice(User * user, char *chan) { - ChannelInfo *ci = cs_findchan(chan); + ChannelInfo *ci = cs_findchan(chan); - if (!ci || (ci->flags & CI_VERBOTEN) || *chan == '+') - return 0; + if (!ci || (ci->flags & CI_VERBOTEN) || *chan == '+') + return 0; - if ((ci->flags & CI_SECURE) && !nick_identified(user)) - return 0; + if ((ci->flags & CI_SECURE) && !nick_identified(user)) + return 0; - if (check_access(user, ci, CA_AUTOVOICE)) { - ircdproto->SendMode(whosends(ci), chan, "+v %s", user->nick); - return 1; - } + if (check_access(user, ci, CA_AUTOVOICE)) { + ircdproto->SendMode(whosends(ci), chan, "+v %s", user->nick); + return 1; + } - return 0; + return 0; } /*************************************************************************/ int check_should_halfop(User * user, char *chan) { - ChannelInfo *ci = cs_findchan(chan); + ChannelInfo *ci = cs_findchan(chan); - if (!ci || (ci->flags & CI_VERBOTEN) || *chan == '+') - return 0; + if (!ci || (ci->flags & CI_VERBOTEN) || *chan == '+') + return 0; - if (check_access(user, ci, CA_AUTOHALFOP)) { - ircdproto->SendMode(whosends(ci), chan, "+h %s", user->nick); - return 1; - } + if (check_access(user, ci, CA_AUTOHALFOP)) { + ircdproto->SendMode(whosends(ci), chan, "+h %s", user->nick); + return 1; + } - return 0; + return 0; } /*************************************************************************/ int check_should_owner(User * user, char *chan) { - char *tmp; - ChannelInfo *ci = cs_findchan(chan); - - if (!ci || (ci->flags & CI_VERBOTEN) || *chan == '+') - return 0; - - if (((ci->flags & CI_SECUREFOUNDER) && is_real_founder(user, ci)) - || (!(ci->flags & CI_SECUREFOUNDER) && is_founder(user, ci))) { - tmp = stripModePrefix(ircd->ownerset); - ircdproto->SendMode(whosends(ci), chan, "+o%s %s %s", tmp, user->nick, - user->nick); - free(tmp); - return 1; - } - - return 0; + char *tmp; + ChannelInfo *ci = cs_findchan(chan); + + if (!ci || (ci->flags & CI_VERBOTEN) || *chan == '+') + return 0; + + if (((ci->flags & CI_SECUREFOUNDER) && is_real_founder(user, ci)) + || (!(ci->flags & CI_SECUREFOUNDER) && is_founder(user, ci))) { + tmp = stripModePrefix(ircd->ownerset); + ircdproto->SendMode(whosends(ci), chan, "+o%s %s %s", tmp, user->nick, + user->nick); + free(tmp); + return 1; + } + + return 0; } /*************************************************************************/ int check_should_protect(User * user, char *chan) { - char *tmp; - ChannelInfo *ci = cs_findchan(chan); + char *tmp; + ChannelInfo *ci = cs_findchan(chan); - if (!ci || (ci->flags & CI_VERBOTEN) || *chan == '+') - return 0; + if (!ci || (ci->flags & CI_VERBOTEN) || *chan == '+') + return 0; - if (check_access(user, ci, CA_AUTOPROTECT)) { - tmp = stripModePrefix(ircd->adminset); - ircdproto->SendMode(whosends(ci), chan, "+o%s %s %s", tmp, user->nick, - user->nick); - free(tmp); - return 1; - } + if (check_access(user, ci, CA_AUTOPROTECT)) { + tmp = stripModePrefix(ircd->adminset); + ircdproto->SendMode(whosends(ci), chan, "+o%s %s %s", tmp, user->nick, + user->nick); + free(tmp); + return 1; + } - return 0; + return 0; } /*************************************************************************/ @@ -1146,14 +1146,14 @@ int check_should_protect(User * user, char *chan) static void timeout_leave(Timeout * to) { - const char *chan = (const char *)to->data; - ChannelInfo *ci = cs_findchan(chan); + const char *chan = (const char *)to->data; + ChannelInfo *ci = cs_findchan(chan); - if (ci) /* Check cos the channel may be dropped in the meantime */ - ci->flags &= ~CI_INHABIT; + if (ci) /* Check cos the channel may be dropped in the meantime */ + ci->flags &= ~CI_INHABIT; - ircdproto->SendPart(findbot(s_ChanServ), chan, NULL); - free(to->data); + ircdproto->SendPart(findbot(s_ChanServ), chan, NULL); + free(to->data); } @@ -1166,132 +1166,132 @@ static void timeout_leave(Timeout * to) int check_kick(User * user, const char *chan, time_t chants) { - ChannelInfo *ci = cs_findchan(chan); - Channel *c; - AutoKick *akick; - int i; - NickCore *nc; - const char *av[4]; - int ac; - char buf[BUFSIZE]; - char mask[BUFSIZE]; - const char *reason; - Timeout *t; - - if (!ci) - return 0; - - if (user->isSuperAdmin == 1) - return 0; - - if (ci->flags & CI_VERBOTEN) { - get_idealban(ci, user, mask, sizeof(mask)); - reason = - ci->forbidreason ? ci->forbidreason : getstring(user->na, - CHAN_MAY_NOT_BE_USED); - goto kick; - } - - if (ci->flags & CI_SUSPENDED) { - get_idealban(ci, user, mask, sizeof(mask)); - reason = - ci->forbidreason ? ci->forbidreason : getstring(user->na, - CHAN_MAY_NOT_BE_USED); - goto kick; - } - - if (nick_recognized(user)) - nc = user->na->nc; - else - nc = NULL; - - /* - * Before we go through akick lists, see if they're excepted FIRST - * We cannot kick excempted users that are akicked or not on the channel access list - * as that will start services <-> server wars which ends up as a DoS against services. - * - * UltimateIRCd 3.x at least informs channel staff when a joining user is matching an exempt. - */ - if (ircd->except && is_excepted(ci, user) == 1) { - return 0; - } - - for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { - if (!(akick->flags & AK_USED)) - continue; - if ((akick->flags & AK_ISNICK && akick->u.nc == nc) - || (!(akick->flags & AK_ISNICK) - && match_usermask(akick->u.mask, user))) { - if (debug >= 2) - alog("debug: %s matched akick %s", user->nick, - (akick->flags & AK_ISNICK) ? akick->u.nc-> - display : akick->u.mask); - if (akick->flags & AK_ISNICK) - get_idealban(ci, user, mask, sizeof(mask)); - else - strcpy(mask, akick->u.mask); - reason = akick->reason ? akick->reason : CSAutokickReason; - goto kick; - } - } - - if (is_ulined(user->server->name)) { - return 0; - } - - if (check_access(user, ci, CA_NOJOIN)) { - get_idealban(ci, user, mask, sizeof(mask)); - reason = getstring(user->na, CHAN_NOT_ALLOWED_TO_JOIN); - goto kick; - } - - return 0; + ChannelInfo *ci = cs_findchan(chan); + Channel *c; + AutoKick *akick; + int i; + NickCore *nc; + const char *av[4]; + int ac; + char buf[BUFSIZE]; + char mask[BUFSIZE]; + const char *reason; + Timeout *t; + + if (!ci) + return 0; + + if (user->isSuperAdmin == 1) + return 0; + + if (ci->flags & CI_VERBOTEN) { + get_idealban(ci, user, mask, sizeof(mask)); + reason = + ci->forbidreason ? ci->forbidreason : getstring(user->na, + CHAN_MAY_NOT_BE_USED); + goto kick; + } + + if (ci->flags & CI_SUSPENDED) { + get_idealban(ci, user, mask, sizeof(mask)); + reason = + ci->forbidreason ? ci->forbidreason : getstring(user->na, + CHAN_MAY_NOT_BE_USED); + goto kick; + } + + if (nick_recognized(user)) + nc = user->na->nc; + else + nc = NULL; + + /* + * Before we go through akick lists, see if they're excepted FIRST + * We cannot kick excempted users that are akicked or not on the channel access list + * as that will start services <-> server wars which ends up as a DoS against services. + * + * UltimateIRCd 3.x at least informs channel staff when a joining user is matching an exempt. + */ + if (ircd->except && is_excepted(ci, user) == 1) { + return 0; + } + + for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { + if (!(akick->flags & AK_USED)) + continue; + if ((akick->flags & AK_ISNICK && akick->u.nc == nc) + || (!(akick->flags & AK_ISNICK) + && match_usermask(akick->u.mask, user))) { + if (debug >= 2) + alog("debug: %s matched akick %s", user->nick, + (akick->flags & AK_ISNICK) ? akick->u.nc-> + display : akick->u.mask); + if (akick->flags & AK_ISNICK) + get_idealban(ci, user, mask, sizeof(mask)); + else + strcpy(mask, akick->u.mask); + reason = akick->reason ? akick->reason : CSAutokickReason; + goto kick; + } + } + + if (is_ulined(user->server->name)) { + return 0; + } + + if (check_access(user, ci, CA_NOJOIN)) { + get_idealban(ci, user, mask, sizeof(mask)); + reason = getstring(user->na, CHAN_NOT_ALLOWED_TO_JOIN); + goto kick; + } + + return 0; kick: - if (debug) - alog("debug: channel: AutoKicking %s!%s@%s from %s", user->nick, - user->username, user->host, chan); - - /* Remember that the user has not been added to our channel user list - * yet, so we check whether the channel does not exist OR has no user - * on it (before SJOIN would have created the channel structure, while - * JOIN would not). */ - /* Don't check for CI_INHABIT before for the Channel record cos else - * c may be NULL even if it exists */ - if ((!(c = findchan(chan)) || c->usercount == 0) - && !(ci->flags & CI_INHABIT)) { - ircdproto->SendJoin(findbot(s_ChanServ), chan, (c ? c->creation_time : chants)); - /* Lets hide the channel from /list just incase someone does /list - * while we are here. - katsklaw - */ - ircdproto->SendMode(findbot(s_ChanServ), chan, "+ntsi"); - t = add_timeout(CSInhabit, timeout_leave, 0); - t->data = sstrdup(chan); - ci->flags |= CI_INHABIT; - } - - if (c) { - if (ircdcap->tsmode) { - snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); - av[0] = chan; - av[1] = buf; - av[2] = "+b"; - av[3] = mask; - ac = 4; - } else { - av[0] = chan; - av[1] = "+b"; - av[2] = mask; - ac = 3; - } - - do_cmode(whosends(ci)->nick, ac, av); - } - - ircdproto->SendMode(whosends(ci), chan, "+b %s", mask); - ircdproto->SendKick(whosends(ci), chan, user->nick, "%s", reason); - - return 1; + if (debug) + alog("debug: channel: AutoKicking %s!%s@%s from %s", user->nick, + user->username, user->host, chan); + + /* Remember that the user has not been added to our channel user list + * yet, so we check whether the channel does not exist OR has no user + * on it (before SJOIN would have created the channel structure, while + * JOIN would not). */ + /* Don't check for CI_INHABIT before for the Channel record cos else + * c may be NULL even if it exists */ + if ((!(c = findchan(chan)) || c->usercount == 0) + && !(ci->flags & CI_INHABIT)) { + ircdproto->SendJoin(findbot(s_ChanServ), chan, (c ? c->creation_time : chants)); + /* Lets hide the channel from /list just incase someone does /list + * while we are here. - katsklaw + */ + ircdproto->SendMode(findbot(s_ChanServ), chan, "+ntsi"); + t = add_timeout(CSInhabit, timeout_leave, 0); + t->data = sstrdup(chan); + ci->flags |= CI_INHABIT; + } + + if (c) { + if (ircdcap->tsmode) { + snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); + av[0] = chan; + av[1] = buf; + av[2] = "+b"; + av[3] = mask; + ac = 4; + } else { + av[0] = chan; + av[1] = "+b"; + av[2] = mask; + ac = 3; + } + + do_cmode(whosends(ci)->nick, ac, av); + } + + ircdproto->SendMode(whosends(ci), chan, "+b %s", mask); + ircdproto->SendKick(whosends(ci), chan, user->nick, "%s", reason); + + return 1; } /*************************************************************************/ @@ -1300,26 +1300,26 @@ int check_kick(User * user, const char *chan, time_t chants) void record_topic(const char *chan) { - Channel *c; - ChannelInfo *ci; + Channel *c; + ChannelInfo *ci; - if (readonly) - return; + if (readonly) + return; - c = findchan(chan); - if (!c || !(ci = c->ci)) - return; + c = findchan(chan); + if (!c || !(ci = c->ci)) + return; - if (ci->last_topic) - free(ci->last_topic); + if (ci->last_topic) + free(ci->last_topic); - if (c->topic) - ci->last_topic = sstrdup(c->topic); - else - ci->last_topic = NULL; + if (c->topic) + ci->last_topic = sstrdup(c->topic); + else + ci->last_topic = NULL; - strscpy(ci->last_topic_setter, c->topic_setter, NICKMAX); - ci->last_topic_time = c->topic_time; + strscpy(ci->last_topic_setter, c->topic_setter, NICKMAX); + ci->last_topic_time = c->topic_time; } /*************************************************************************/ @@ -1328,45 +1328,45 @@ void record_topic(const char *chan) void restore_topic(const char *chan) { - Channel *c = findchan(chan); - ChannelInfo *ci; - - if (!c || !(ci = c->ci)) - return; - /* We can be sure that the topic will be in sync when we return -GD */ - c->topic_sync = 1; - if (!(ci->flags & CI_KEEPTOPIC)) { - /* We need to reset the topic here, since it's currently empty and - * should be updated with a TOPIC from the IRCd soon. -GD - */ - ci->last_topic = NULL; - strscpy(ci->last_topic_setter, whosends(ci)->nick, NICKMAX); - ci->last_topic_time = time(NULL); - return; - } - if (c->topic) - free(c->topic); - if (ci->last_topic) { - c->topic = sstrdup(ci->last_topic); - strscpy(c->topic_setter, ci->last_topic_setter, NICKMAX); - c->topic_time = ci->last_topic_time; - } else { - c->topic = NULL; - strscpy(c->topic_setter, whosends(ci)->nick, NICKMAX); - } - if (ircd->join2set) { - if (whosends(ci) == findbot(s_ChanServ)) { - ircdproto->SendJoin(findbot(s_ChanServ), chan, c->creation_time); - ircdproto->SendMode(NULL, chan, "+o %s", s_ChanServ); - } - } - ircdproto->SendTopic(whosends(ci), c->name, c->topic_setter, - c->topic ? c->topic : "", c->topic_time); - if (ircd->join2set) { - if (whosends(ci) == findbot(s_ChanServ)) { - ircdproto->SendPart(findbot(s_ChanServ), c->name, NULL); - } - } + Channel *c = findchan(chan); + ChannelInfo *ci; + + if (!c || !(ci = c->ci)) + return; + /* We can be sure that the topic will be in sync when we return -GD */ + c->topic_sync = 1; + if (!(ci->flags & CI_KEEPTOPIC)) { + /* We need to reset the topic here, since it's currently empty and + * should be updated with a TOPIC from the IRCd soon. -GD + */ + ci->last_topic = NULL; + strscpy(ci->last_topic_setter, whosends(ci)->nick, NICKMAX); + ci->last_topic_time = time(NULL); + return; + } + if (c->topic) + free(c->topic); + if (ci->last_topic) { + c->topic = sstrdup(ci->last_topic); + strscpy(c->topic_setter, ci->last_topic_setter, NICKMAX); + c->topic_time = ci->last_topic_time; + } else { + c->topic = NULL; + strscpy(c->topic_setter, whosends(ci)->nick, NICKMAX); + } + if (ircd->join2set) { + if (whosends(ci) == findbot(s_ChanServ)) { + ircdproto->SendJoin(findbot(s_ChanServ), chan, c->creation_time); + ircdproto->SendMode(NULL, chan, "+o %s", s_ChanServ); + } + } + ircdproto->SendTopic(whosends(ci), c->name, c->topic_setter, + c->topic ? c->topic : "", c->topic_time); + if (ircd->join2set) { + if (whosends(ci) == findbot(s_ChanServ)) { + ircdproto->SendPart(findbot(s_ChanServ), c->name, NULL); + } + } } /*************************************************************************/ @@ -1376,62 +1376,62 @@ void restore_topic(const char *chan) int check_topiclock(Channel * c, time_t topic_time) { - ChannelInfo *ci; - - if (!c) { - if (debug) { - alog("debug: check_topiclock called with NULL values"); - } - return 0; - } - - if (!(ci = c->ci) || !(ci->flags & CI_TOPICLOCK)) - return 0; - - if (c->topic) - free(c->topic); - if (ci->last_topic) { - c->topic = sstrdup(ci->last_topic); - strscpy(c->topic_setter, ci->last_topic_setter, NICKMAX); - } else { - c->topic = NULL; - /* Bot assigned & Symbiosis ON?, the bot will set the topic - doc */ - /* Altough whosends() also checks for BSMinUsers -GD */ - strscpy(c->topic_setter, whosends(ci)->nick, NICKMAX); - } - - if (ircd->topictsforward) { - /* Because older timestamps are rejected */ - /* Some how the topic_time from do_topic is 0 set it to current + 1 */ - if (!topic_time) { - c->topic_time = time(NULL) + 1; - } else { - c->topic_time = topic_time + 1; - } - } else { - /* If no last topic, we can't use last topic time! - doc */ - if (ci->last_topic) - c->topic_time = ci->last_topic_time; - else - c->topic_time = time(NULL) + 1; - } - - if (ircd->join2set) { - if (whosends(ci) == findbot(s_ChanServ)) { - ircdproto->SendJoin(findbot(s_ChanServ), c->name, c->creation_time); - ircdproto->SendMode(NULL, c->name, "+o %s", s_ChanServ); - } - } - - ircdproto->SendTopic(whosends(ci), c->name, c->topic_setter, - c->topic ? c->topic : "", c->topic_time); - - if (ircd->join2set) { - if (whosends(ci) == findbot(s_ChanServ)) { - ircdproto->SendPart(findbot(s_ChanServ), c->ci->name, NULL); - } - } - return 1; + ChannelInfo *ci; + + if (!c) { + if (debug) { + alog("debug: check_topiclock called with NULL values"); + } + return 0; + } + + if (!(ci = c->ci) || !(ci->flags & CI_TOPICLOCK)) + return 0; + + if (c->topic) + free(c->topic); + if (ci->last_topic) { + c->topic = sstrdup(ci->last_topic); + strscpy(c->topic_setter, ci->last_topic_setter, NICKMAX); + } else { + c->topic = NULL; + /* Bot assigned & Symbiosis ON?, the bot will set the topic - doc */ + /* Altough whosends() also checks for BSMinUsers -GD */ + strscpy(c->topic_setter, whosends(ci)->nick, NICKMAX); + } + + if (ircd->topictsforward) { + /* Because older timestamps are rejected */ + /* Some how the topic_time from do_topic is 0 set it to current + 1 */ + if (!topic_time) { + c->topic_time = time(NULL) + 1; + } else { + c->topic_time = topic_time + 1; + } + } else { + /* If no last topic, we can't use last topic time! - doc */ + if (ci->last_topic) + c->topic_time = ci->last_topic_time; + else + c->topic_time = time(NULL) + 1; + } + + if (ircd->join2set) { + if (whosends(ci) == findbot(s_ChanServ)) { + ircdproto->SendJoin(findbot(s_ChanServ), c->name, c->creation_time); + ircdproto->SendMode(NULL, c->name, "+o %s", s_ChanServ); + } + } + + ircdproto->SendTopic(whosends(ci), c->name, c->topic_setter, + c->topic ? c->topic : "", c->topic_time); + + if (ircd->join2set) { + if (whosends(ci) == findbot(s_ChanServ)) { + ircdproto->SendPart(findbot(s_ChanServ), c->ci->name, NULL); + } + } + return 1; } /*************************************************************************/ @@ -1440,27 +1440,27 @@ int check_topiclock(Channel * c, time_t topic_time) void expire_chans() { - ChannelInfo *ci, *next; - int i; - time_t now = time(NULL); - - if (!CSExpire) - return; - - for (i = 0; i < 256; i++) { - for (ci = chanlists[i]; ci; ci = next) { - next = ci->next; - if (!ci->c && now - ci->last_used >= CSExpire - && !(ci-> - flags & (CI_VERBOTEN | CI_NO_EXPIRE | CI_SUSPENDED))) - { - send_event(EVENT_CHAN_EXPIRE, 1, ci->name); - alog("Expiring channel %s (founder: %s)", ci->name, - (ci->founder ? ci->founder->display : "(none)")); - delchan(ci); - } - } - } + ChannelInfo *ci, *next; + int i; + time_t now = time(NULL); + + if (!CSExpire) + return; + + for (i = 0; i < 256; i++) { + for (ci = chanlists[i]; ci; ci = next) { + next = ci->next; + if (!ci->c && now - ci->last_used >= CSExpire + && !(ci-> + flags & (CI_VERBOTEN | CI_NO_EXPIRE | CI_SUSPENDED))) + { + send_event(EVENT_CHAN_EXPIRE, 1, ci->name); + alog("Expiring channel %s (founder: %s)", ci->name, + (ci->founder ? ci->founder->display : "(none)")); + delchan(ci); + } + } + } } /*************************************************************************/ @@ -1469,70 +1469,70 @@ void expire_chans() void cs_remove_nick(const NickCore * nc) { - int i, j; - ChannelInfo *ci, *next; - ChanAccess *ca; - AutoKick *akick; - - for (i = 0; i < 256; i++) { - for (ci = chanlists[i]; ci; ci = next) { - next = ci->next; - if (ci->founder == nc) { - if (ci->successor) { - NickCore *nc2 = ci->successor; - if (!nick_is_services_admin(nc2) && CSMaxReg && nc2->channelcount >= CSMaxReg) { - alog("%s: Successor (%s) of %s owns too many channels, " "deleting channel", s_ChanServ, nc2->display, ci->name); - delchan(ci); - continue; - } else { - alog("%s: Transferring foundership of %s from deleted " "nick %s to successor %s", s_ChanServ, ci->name, nc->display, nc2->display); - ci->founder = nc2; - ci->successor = NULL; - nc2->channelcount++; - } - } else { - alog("%s: Deleting channel %s owned by deleted nick %s", s_ChanServ, ci->name, nc->display); - if (ircd->regmode) { - /* Maybe move this to delchan() ? */ - if ((ci->c) && (ci->c->mode & ircd->regmode)) { - ci->c->mode &= ~ircd->regmode; - ircdproto->SendMode(whosends(ci), ci->name, "-r"); - } - } - - delchan(ci); - continue; - } - } - - if (ci->successor == nc) - ci->successor = NULL; - - for (ca = ci->access, j = ci->accesscount; j > 0; ca++, j--) { - if (ca->in_use && ca->nc == nc) { - ca->in_use = 0; - ca->nc = NULL; - } - } - - for (akick = ci->akick, j = ci->akickcount; j > 0; - akick++, j--) { - if ((akick->flags & AK_USED) && (akick->flags & AK_ISNICK) - && akick->u.nc == nc) { - if (akick->creator) { - free(akick->creator); - akick->creator = NULL; - } - if (akick->reason) { - free(akick->reason); - akick->reason = NULL; - } - akick->flags = 0; - akick->u.nc = NULL; - } - } - } - } + int i, j; + ChannelInfo *ci, *next; + ChanAccess *ca; + AutoKick *akick; + + for (i = 0; i < 256; i++) { + for (ci = chanlists[i]; ci; ci = next) { + next = ci->next; + if (ci->founder == nc) { + if (ci->successor) { + NickCore *nc2 = ci->successor; + if (!nick_is_services_admin(nc2) && CSMaxReg && nc2->channelcount >= CSMaxReg) { + alog("%s: Successor (%s) of %s owns too many channels, " "deleting channel", s_ChanServ, nc2->display, ci->name); + delchan(ci); + continue; + } else { + alog("%s: Transferring foundership of %s from deleted " "nick %s to successor %s", s_ChanServ, ci->name, nc->display, nc2->display); + ci->founder = nc2; + ci->successor = NULL; + nc2->channelcount++; + } + } else { + alog("%s: Deleting channel %s owned by deleted nick %s", s_ChanServ, ci->name, nc->display); + if (ircd->regmode) { + /* Maybe move this to delchan() ? */ + if ((ci->c) && (ci->c->mode & ircd->regmode)) { + ci->c->mode &= ~ircd->regmode; + ircdproto->SendMode(whosends(ci), ci->name, "-r"); + } + } + + delchan(ci); + continue; + } + } + + if (ci->successor == nc) + ci->successor = NULL; + + for (ca = ci->access, j = ci->accesscount; j > 0; ca++, j--) { + if (ca->in_use && ca->nc == nc) { + ca->in_use = 0; + ca->nc = NULL; + } + } + + for (akick = ci->akick, j = ci->akickcount; j > 0; + akick++, j--) { + if ((akick->flags & AK_USED) && (akick->flags & AK_ISNICK) + && akick->u.nc == nc) { + if (akick->creator) { + free(akick->creator); + akick->creator = NULL; + } + if (akick->reason) { + free(akick->reason); + akick->reason = NULL; + } + akick->flags = 0; + akick->u.nc = NULL; + } + } + } + } } /*************************************************************************/ @@ -1542,21 +1542,21 @@ void cs_remove_nick(const NickCore * nc) ChannelInfo *cs_findchan(const char *chan) { - ChannelInfo *ci; - - if (!chan || !*chan) { - if (debug) { - alog("debug: cs_findchan() called with NULL values"); - } - return NULL; - } - - for (ci = chanlists[(unsigned char) tolower(chan[1])]; ci; - ci = ci->next) { - if (stricmp(ci->name, chan) == 0) - return ci; - } - return NULL; + ChannelInfo *ci; + + if (!chan || !*chan) { + if (debug) { + alog("debug: cs_findchan() called with NULL values"); + } + return NULL; + } + + for (ci = chanlists[(unsigned char) tolower(chan[1])]; ci; + ci = ci->next) { + if (stricmp(ci->name, chan) == 0) + return ci; + } + return NULL; } /*************************************************************************/ @@ -1569,31 +1569,31 @@ ChannelInfo *cs_findchan(const char *chan) int check_access(User * user, ChannelInfo * ci, int what) { - int level; - int limit; - - if (!user || !ci) { - return 0; - } - - level = get_access(user, ci); - limit = ci->levels[what]; - - /* Resetting the last used time */ - if (level > 0) - ci->last_used = time(NULL); - - if (level >= ACCESS_FOUNDER) - return (what == CA_AUTODEOP || what == CA_NOJOIN) ? 0 : 1; - /* Hacks to make flags work */ - if (what == CA_AUTODEOP && (ci->flags & CI_SECUREOPS) && level == 0) - return 1; - if (limit == ACCESS_INVALID) - return 0; - if (what == CA_AUTODEOP || what == CA_NOJOIN) - return level <= ci->levels[what]; - else - return level >= ci->levels[what]; + int level; + int limit; + + if (!user || !ci) { + return 0; + } + + level = get_access(user, ci); + limit = ci->levels[what]; + + /* Resetting the last used time */ + if (level > 0) + ci->last_used = time(NULL); + + if (level >= ACCESS_FOUNDER) + return (what == CA_AUTODEOP || what == CA_NOJOIN) ? 0 : 1; + /* Hacks to make flags work */ + if (what == CA_AUTODEOP && (ci->flags & CI_SECUREOPS) && level == 0) + return 1; + if (limit == ACCESS_INVALID) + return 0; + if (what == CA_AUTODEOP || what == CA_NOJOIN) + return level <= ci->levels[what]; + else + return level >= ci->levels[what]; } /*************************************************************************/ @@ -1604,29 +1604,29 @@ int check_access(User * user, ChannelInfo * ci, int what) void alpha_insert_chan(ChannelInfo * ci) { - ChannelInfo *ptr, *prev; - char *chan; - - if (!ci) { - if (debug) { - alog("debug: alpha_insert_chan called with NULL values"); - } - return; - } - - chan = ci->name; - - for (prev = NULL, ptr = chanlists[(unsigned char) tolower(chan[1])]; - ptr != NULL && stricmp(ptr->name, chan) < 0; - prev = ptr, ptr = ptr->next); - ci->prev = prev; - ci->next = ptr; - if (!prev) - chanlists[(unsigned char) tolower(chan[1])] = ci; - else - prev->next = ci; - if (ptr) - ptr->prev = ci; + ChannelInfo *ptr, *prev; + char *chan; + + if (!ci) { + if (debug) { + alog("debug: alpha_insert_chan called with NULL values"); + } + return; + } + + chan = ci->name; + + for (prev = NULL, ptr = chanlists[(unsigned char) tolower(chan[1])]; + ptr != NULL && stricmp(ptr->name, chan) < 0; + prev = ptr, ptr = ptr->next); + ci->prev = prev; + ci->next = ptr; + if (!prev) + chanlists[(unsigned char) tolower(chan[1])] = ci; + else + prev->next = ci; + if (ptr) + ptr->prev = ci; } /*************************************************************************/ @@ -1637,18 +1637,18 @@ void alpha_insert_chan(ChannelInfo * ci) ChannelInfo *makechan(const char *chan) { - int i; - ChannelInfo *ci; - - ci = (ChannelInfo *)scalloc(sizeof(ChannelInfo), 1); - strscpy(ci->name, chan, CHANMAX); - ci->time_registered = time(NULL); - reset_levels(ci); - ci->ttb = (int16 *)scalloc(2 * TTB_SIZE, 1); - for (i = 0; i < TTB_SIZE; i++) - ci->ttb[i] = 0; - alpha_insert_chan(ci); - return ci; + int i; + ChannelInfo *ci; + + ci = (ChannelInfo *)scalloc(sizeof(ChannelInfo), 1); + strscpy(ci->name, chan, CHANMAX); + ci->time_registered = time(NULL); + reset_levels(ci); + ci->ttb = (int16 *)scalloc(2 * TTB_SIZE, 1); + for (i = 0; i < TTB_SIZE; i++) + ci->ttb[i] = 0; + alpha_insert_chan(ci); + return ci; } /*************************************************************************/ @@ -1658,164 +1658,164 @@ ChannelInfo *makechan(const char *chan) int delchan(ChannelInfo * ci) { - int i; - NickCore *nc; - User *u; - struct u_chaninfolist *cilist, *cilist_next; - - if (!ci) { - if (debug) { - alog("debug: delchan called with NULL values"); - } - return 0; - } - - nc = ci->founder; - - if (debug >= 2) { - alog("debug: delchan removing %s", ci->name); - } - - if (ci->bi) { - ci->bi->chancount--; - } - - if (debug >= 2) { - alog("debug: delchan top of removing the bot"); - } - if (ci->c) { - if (ci->bi && ci->c->usercount >= BSMinUsers) { - ircdproto->SendPart(ci->bi, ci->c->name, NULL); - } - ci->c->ci = NULL; - } - if (debug >= 2) { - alog("debug: delchan() Bot has been removed moving on"); - } - - if (debug >= 2) { - alog("debug: delchan() founder cleanup"); - } - for (i = 0; i < 1024; i++) { - for (u = userlist[i]; u; u = u->next) { - cilist = u->founder_chans; - while (cilist) { - cilist_next = cilist->next; - if (cilist->chan == ci) { - if (debug) - alog("debug: Dropping founder login of %s for %s", - u->nick, ci->name); - if (cilist->next) - cilist->next->prev = cilist->prev; - if (cilist->prev) - cilist->prev->next = cilist->next; - else - u->founder_chans = cilist->next; - free(cilist); - } - cilist = cilist_next; - } - } - } - if (debug >= 2) { - alog("debug: delchan() founder cleanup done"); - } - - if (ci->next) - ci->next->prev = ci->prev; - if (ci->prev) - ci->prev->next = ci->next; - else - chanlists[(unsigned char) tolower(ci->name[1])] = ci->next; - if (ci->desc) - free(ci->desc); - if (ci->url) - free(ci->url); - if (ci->email) - free(ci->email); - if (ci->entry_message) - free(ci->entry_message); - - if (ci->mlock_key) - free(ci->mlock_key); - if (ircd->fmode) { - if (ci->mlock_flood) - free(ci->mlock_flood); - } - if (ircd->Lmode) { - if (ci->mlock_redirect) - free(ci->mlock_redirect); - } - if (ci->last_topic) - free(ci->last_topic); - if (ci->forbidby) - free(ci->forbidby); - if (ci->forbidreason) - free(ci->forbidreason); - if (ci->access) - free(ci->access); - if (debug >= 2) { - alog("debug: delchan() top of the akick list"); - } - for (i = 0; i < ci->akickcount; i++) { - if (!(ci->akick[i].flags & AK_ISNICK) && ci->akick[i].u.mask) - free(ci->akick[i].u.mask); - if (ci->akick[i].reason) - free(ci->akick[i].reason); - if (ci->akick[i].creator) - free(ci->akick[i].creator); - } - if (debug >= 2) { - alog("debug: delchan() done with the akick list"); - } - if (ci->akick) - free(ci->akick); - if (ci->levels) - free(ci->levels); - if (debug >= 2) { - alog("debug: delchan() top of the memo list"); - } - if (ci->memos.memos) { - for (i = 0; i < ci->memos.memocount; i++) { - if (ci->memos.memos[i].text) - free(ci->memos.memos[i].text); - moduleCleanStruct(&ci->memos.memos[i].moduleData); - } - free(ci->memos.memos); - } - if (debug >= 2) { - alog("debug: delchan() done with the memo list"); - } - if (ci->ttb) - free(ci->ttb); - - if (debug >= 2) { - alog("debug: delchan() top of the badword list"); - } - for (i = 0; i < ci->bwcount; i++) { - if (ci->badwords[i].word) - free(ci->badwords[i].word); - } - if (ci->badwords) - free(ci->badwords); - if (debug >= 2) { - alog("debug: delchan() done with the badword list"); - } - - - if (debug >= 2) { - alog("debug: delchan() calling on moduleCleanStruct()"); - } - moduleCleanStruct(&ci->moduleData); - - free(ci); - if (nc) - nc->channelcount--; - - if (debug >= 2) { - alog("debug: delchan() all done"); - } - return 1; + int i; + NickCore *nc; + User *u; + struct u_chaninfolist *cilist, *cilist_next; + + if (!ci) { + if (debug) { + alog("debug: delchan called with NULL values"); + } + return 0; + } + + nc = ci->founder; + + if (debug >= 2) { + alog("debug: delchan removing %s", ci->name); + } + + if (ci->bi) { + ci->bi->chancount--; + } + + if (debug >= 2) { + alog("debug: delchan top of removing the bot"); + } + if (ci->c) { + if (ci->bi && ci->c->usercount >= BSMinUsers) { + ircdproto->SendPart(ci->bi, ci->c->name, NULL); + } + ci->c->ci = NULL; + } + if (debug >= 2) { + alog("debug: delchan() Bot has been removed moving on"); + } + + if (debug >= 2) { + alog("debug: delchan() founder cleanup"); + } + for (i = 0; i < 1024; i++) { + for (u = userlist[i]; u; u = u->next) { + cilist = u->founder_chans; + while (cilist) { + cilist_next = cilist->next; + if (cilist->chan == ci) { + if (debug) + alog("debug: Dropping founder login of %s for %s", + u->nick, ci->name); + if (cilist->next) + cilist->next->prev = cilist->prev; + if (cilist->prev) + cilist->prev->next = cilist->next; + else + u->founder_chans = cilist->next; + free(cilist); + } + cilist = cilist_next; + } + } + } + if (debug >= 2) { + alog("debug: delchan() founder cleanup done"); + } + + if (ci->next) + ci->next->prev = ci->prev; + if (ci->prev) + ci->prev->next = ci->next; + else + chanlists[(unsigned char) tolower(ci->name[1])] = ci->next; + if (ci->desc) + free(ci->desc); + if (ci->url) + free(ci->url); + if (ci->email) + free(ci->email); + if (ci->entry_message) + free(ci->entry_message); + + if (ci->mlock_key) + free(ci->mlock_key); + if (ircd->fmode) { + if (ci->mlock_flood) + free(ci->mlock_flood); + } + if (ircd->Lmode) { + if (ci->mlock_redirect) + free(ci->mlock_redirect); + } + if (ci->last_topic) + free(ci->last_topic); + if (ci->forbidby) + free(ci->forbidby); + if (ci->forbidreason) + free(ci->forbidreason); + if (ci->access) + free(ci->access); + if (debug >= 2) { + alog("debug: delchan() top of the akick list"); + } + for (i = 0; i < ci->akickcount; i++) { + if (!(ci->akick[i].flags & AK_ISNICK) && ci->akick[i].u.mask) + free(ci->akick[i].u.mask); + if (ci->akick[i].reason) + free(ci->akick[i].reason); + if (ci->akick[i].creator) + free(ci->akick[i].creator); + } + if (debug >= 2) { + alog("debug: delchan() done with the akick list"); + } + if (ci->akick) + free(ci->akick); + if (ci->levels) + free(ci->levels); + if (debug >= 2) { + alog("debug: delchan() top of the memo list"); + } + if (ci->memos.memos) { + for (i = 0; i < ci->memos.memocount; i++) { + if (ci->memos.memos[i].text) + free(ci->memos.memos[i].text); + moduleCleanStruct(&ci->memos.memos[i].moduleData); + } + free(ci->memos.memos); + } + if (debug >= 2) { + alog("debug: delchan() done with the memo list"); + } + if (ci->ttb) + free(ci->ttb); + + if (debug >= 2) { + alog("debug: delchan() top of the badword list"); + } + for (i = 0; i < ci->bwcount; i++) { + if (ci->badwords[i].word) + free(ci->badwords[i].word); + } + if (ci->badwords) + free(ci->badwords); + if (debug >= 2) { + alog("debug: delchan() done with the badword list"); + } + + + if (debug >= 2) { + alog("debug: delchan() calling on moduleCleanStruct()"); + } + moduleCleanStruct(&ci->moduleData); + + free(ci); + if (nc) + nc->channelcount--; + + if (debug >= 2) { + alog("debug: delchan() all done"); + } + return 1; } /*************************************************************************/ @@ -1824,20 +1824,20 @@ int delchan(ChannelInfo * ci) void reset_levels(ChannelInfo * ci) { - int i; - - if (!ci) { - if (debug) { - alog("debug: reset_levels called with NULL values"); - } - return; - } - - if (ci->levels) - free(ci->levels); - ci->levels = (int16 *)scalloc(CA_SIZE * sizeof(*ci->levels), 1); - for (i = 0; def_levels[i][0] >= 0; i++) - ci->levels[def_levels[i][0]] = def_levels[i][1]; + int i; + + if (!ci) { + if (debug) { + alog("debug: reset_levels called with NULL values"); + } + return; + } + + if (ci->levels) + free(ci->levels); + ci->levels = (int16 *)scalloc(CA_SIZE * sizeof(*ci->levels), 1); + for (i = 0; def_levels[i][0] >= 0; i++) + ci->levels[def_levels[i][0]] = def_levels[i][1]; } /*************************************************************************/ @@ -1846,38 +1846,38 @@ void reset_levels(ChannelInfo * ci) int is_founder(User * user, ChannelInfo * ci) { - if (!user || !ci) { - return 0; - } - - if (user->isSuperAdmin) { - return 1; - } - - if (user->na && user->na->nc == ci->founder) { - if ((nick_identified(user) - || (nick_recognized(user) && !(ci->flags & CI_SECURE)))) - return 1; - } - if (is_identified(user, ci)) - return 1; - return 0; + if (!user || !ci) { + return 0; + } + + if (user->isSuperAdmin) { + return 1; + } + + if (user->na && user->na->nc == ci->founder) { + if ((nick_identified(user) + || (nick_recognized(user) && !(ci->flags & CI_SECURE)))) + return 1; + } + if (is_identified(user, ci)) + return 1; + return 0; } /*************************************************************************/ int is_real_founder(User * user, ChannelInfo * ci) { - if (user->isSuperAdmin) { - return 1; - } - - if (user->na && user->na->nc == ci->founder) { - if ((nick_identified(user) - || (nick_recognized(user) && !(ci->flags & CI_SECURE)))) - return 1; - } - return 0; + if (user->isSuperAdmin) { + return 1; + } + + if (user->na && user->na->nc == ci->founder) { + if ((nick_identified(user) + || (nick_recognized(user) && !(ci->flags & CI_SECURE)))) + return 1; + } + return 0; } /*************************************************************************/ @@ -1886,13 +1886,13 @@ int is_real_founder(User * user, ChannelInfo * ci) int is_identified(User * user, ChannelInfo * ci) { - struct u_chaninfolist *c; + struct u_chaninfolist *c; - for (c = user->founder_chans; c; c = c->next) { - if (c->chan == ci) - return 1; - } - return 0; + for (c = user->founder_chans; c; c = c->next) { + if (c->chan == ci) + return 1; + } + return 0; } /*************************************************************************/ @@ -1901,18 +1901,18 @@ int is_identified(User * user, ChannelInfo * ci) ChanAccess *get_access_entry(NickCore * nc, ChannelInfo * ci) { - ChanAccess *access; - int i; + ChanAccess *access; + int i; - if (!ci || !nc) { - return NULL; - } + if (!ci || !nc) { + return NULL; + } - for (access = ci->access, i = 0; i < ci->accesscount; access++, i++) - if (access->in_use && access->nc == nc) - return access; + for (access = ci->access, i = 0; i < ci->accesscount; access++, i++) + if (access->in_use && access->nc == nc) + return access; - return NULL; + return NULL; } /*************************************************************************/ @@ -1923,45 +1923,45 @@ ChanAccess *get_access_entry(NickCore * nc, ChannelInfo * ci) int get_access(User * user, ChannelInfo * ci) { - ChanAccess *access; + ChanAccess *access; - if (!ci || !user) - return 0; + if (!ci || !user) + return 0; - /* SuperAdmin always has highest level */ - if (user->isSuperAdmin) - return ACCESS_SUPERADMIN; + /* SuperAdmin always has highest level */ + if (user->isSuperAdmin) + return ACCESS_SUPERADMIN; - if (is_founder(user, ci)) - return ACCESS_FOUNDER; + if (is_founder(user, ci)) + return ACCESS_FOUNDER; - if (!user->na) - return 0; + if (!user->na) + return 0; - if (nick_identified(user) - || (nick_recognized(user) && !(ci->flags & CI_SECURE))) - if ((access = get_access_entry(user->na->nc, ci))) - return access->level; + if (nick_identified(user) + || (nick_recognized(user) && !(ci->flags & CI_SECURE))) + if ((access = get_access_entry(user->na->nc, ci))) + return access->level; - if (nick_identified(user)) - return 0; + if (nick_identified(user)) + return 0; - return 0; + return 0; } /*************************************************************************/ void update_cs_lastseen(User * user, ChannelInfo * ci) { - ChanAccess *access; + ChanAccess *access; - if (!ci || !user || !user->na) - return; + if (!ci || !user || !user->na) + return; - if (is_founder(user, ci) || nick_identified(user) - || (nick_recognized(user) && !(ci->flags & CI_SECURE))) - if ((access = get_access_entry(user->na->nc, ci))) - access->last_seen = time(NULL); + if (is_founder(user, ci) || nick_identified(user) + || (nick_recognized(user) && !(ci->flags & CI_SECURE))) + if ((access = get_access_entry(user->na->nc, ci))) + access->last_seen = time(NULL); } /*************************************************************************/ @@ -1971,208 +1971,208 @@ void update_cs_lastseen(User * user, ChannelInfo * ci) int get_idealban(ChannelInfo * ci, User * u, char *ret, int retlen) { - char *mask; - - if (!ci || !u || !ret || retlen == 0) - return 0; - - switch (ci->bantype) { - case 0: - snprintf(ret, retlen, "*!%s@%s", common_get_vident(u), - common_get_vhost(u)); - return 1; - case 1: - snprintf(ret, retlen, "*!%s%s@%s", - (strlen(common_get_vident(u)) < - (*(common_get_vident(u)) == - '~' ? USERMAX + 1 : USERMAX) ? "*" : ""), - (*(common_get_vident(u)) == - '~' ? common_get_vident(u) + 1 : common_get_vident(u)), - common_get_vhost(u)); - return 1; - case 2: - snprintf(ret, retlen, "*!*@%s", common_get_vhost(u)); - return 1; - case 3: - mask = create_mask(u); - snprintf(ret, retlen, "*!%s", mask); - free(mask); - return 1; - - default: - return 0; - } + char *mask; + + if (!ci || !u || !ret || retlen == 0) + return 0; + + switch (ci->bantype) { + case 0: + snprintf(ret, retlen, "*!%s@%s", common_get_vident(u), + common_get_vhost(u)); + return 1; + case 1: + snprintf(ret, retlen, "*!%s%s@%s", + (strlen(common_get_vident(u)) < + (*(common_get_vident(u)) == + '~' ? USERMAX + 1 : USERMAX) ? "*" : ""), + (*(common_get_vident(u)) == + '~' ? common_get_vident(u) + 1 : common_get_vident(u)), + common_get_vhost(u)); + return 1; + case 2: + snprintf(ret, retlen, "*!*@%s", common_get_vhost(u)); + return 1; + case 3: + mask = create_mask(u); + snprintf(ret, retlen, "*!%s", mask); + free(mask); + return 1; + + default: + return 0; + } } /*************************************************************************/ char *cs_get_flood(ChannelInfo * ci) { - if (!ci) { - return NULL; - } else { - return ci->mlock_flood; - } + if (!ci) { + return NULL; + } else { + return ci->mlock_flood; + } } /*************************************************************************/ char *cs_get_key(ChannelInfo * ci) { - if (!ci) { - return NULL; - } else { - return ci->mlock_key; - } + if (!ci) { + return NULL; + } else { + return ci->mlock_key; + } } /*************************************************************************/ char *cs_get_limit(ChannelInfo * ci) { - static char limit[16]; + static char limit[16]; - if (!ci) { - return NULL; - } + if (!ci) { + return NULL; + } - if (ci->mlock_limit == 0) - return NULL; + if (ci->mlock_limit == 0) + return NULL; - snprintf(limit, sizeof(limit), "%lu", - (unsigned long int) ci->mlock_limit); - return limit; + snprintf(limit, sizeof(limit), "%lu", + (unsigned long int) ci->mlock_limit); + return limit; } /*************************************************************************/ char *cs_get_redirect(ChannelInfo * ci) { - if (!ci) { - return NULL; - } else { - return ci->mlock_redirect; - } + if (!ci) { + return NULL; + } else { + return ci->mlock_redirect; + } } /*************************************************************************/ void cs_set_flood(ChannelInfo * ci, const char *value) { - if (!ci) { - return; - } - - if (ci->mlock_flood) - free(ci->mlock_flood); - - /* This looks ugly, but it works ;) */ - if (ircdproto->IsFloodModeParamValid(value)) { - ci->mlock_flood = sstrdup(value); - } else { - ci->mlock_on &= ~ircd->chan_fmode; - ci->mlock_flood = NULL; - } + if (!ci) { + return; + } + + if (ci->mlock_flood) + free(ci->mlock_flood); + + /* This looks ugly, but it works ;) */ + if (ircdproto->IsFloodModeParamValid(value)) { + ci->mlock_flood = sstrdup(value); + } else { + ci->mlock_on &= ~ircd->chan_fmode; + ci->mlock_flood = NULL; + } } /*************************************************************************/ void cs_set_key(ChannelInfo * ci, const char *value) { - if (!ci) { - return; - } - - if (ci->mlock_key) - free(ci->mlock_key); - - /* Don't allow keys with a coma */ - if (value && *value != ':' && !strchr(value, ',')) { - ci->mlock_key = sstrdup(value); - } else { - ci->mlock_on &= ~anope_get_key_mode(); - ci->mlock_key = NULL; - } + if (!ci) { + return; + } + + if (ci->mlock_key) + free(ci->mlock_key); + + /* Don't allow keys with a coma */ + if (value && *value != ':' && !strchr(value, ',')) { + ci->mlock_key = sstrdup(value); + } else { + ci->mlock_on &= ~anope_get_key_mode(); + ci->mlock_key = NULL; + } } /*************************************************************************/ void cs_set_limit(ChannelInfo * ci, const char *value) { - if (!ci) { - return; - } + if (!ci) { + return; + } - ci->mlock_limit = value ? strtoul(value, NULL, 10) : 0; + ci->mlock_limit = value ? strtoul(value, NULL, 10) : 0; - if (ci->mlock_limit <= 0) - ci->mlock_on &= ~anope_get_limit_mode(); + if (ci->mlock_limit <= 0) + ci->mlock_on &= ~anope_get_limit_mode(); } /*************************************************************************/ void cs_set_redirect(ChannelInfo * ci, const char *value) { - if (!ci) { - return; - } - - if (ci->mlock_redirect) - free(ci->mlock_redirect); - - /* Don't allow keys with a coma */ - if (value && *value == '#') { - ci->mlock_redirect = sstrdup(value); - } else { - ci->mlock_on &= ~ircd->chan_lmode; - ci->mlock_redirect = NULL; - } + if (!ci) { + return; + } + + if (ci->mlock_redirect) + free(ci->mlock_redirect); + + /* Don't allow keys with a coma */ + if (value && *value == '#') { + ci->mlock_redirect = sstrdup(value); + } else { + ci->mlock_on &= ~ircd->chan_lmode; + ci->mlock_redirect = NULL; + } } int get_access_level(ChannelInfo * ci, NickAlias * na) { - ChanAccess *access; - int num; + ChanAccess *access; + int num; - if (!ci || !na) { - return 0; - } + if (!ci || !na) { + return 0; + } - if (na->nc == ci->founder) { - return ACCESS_FOUNDER; - } + if (na->nc == ci->founder) { + return ACCESS_FOUNDER; + } - for (num = 0; num < ci->accesscount; num++) { + for (num = 0; num < ci->accesscount; num++) { - access = &ci->access[num]; + access = &ci->access[num]; - if (access->nc && access->nc == na->nc && access->in_use) { - return access->level; - } + if (access->nc && access->nc == na->nc && access->in_use) { + return access->level; + } - } + } - return 0; + return 0; } const char *get_xop_level(int level) { - if (level < ACCESS_VOP) { - return "Err"; - } else if (ircd->halfop && level < ACCESS_HOP) { - return "VOP"; - } else if (!ircd->halfop && level < ACCESS_AOP) { - return "VOP"; - } else if (ircd->halfop && level < ACCESS_AOP) { - return "HOP"; - } else if (level < ACCESS_SOP) { - return "AOP"; - } else if (level < ACCESS_FOUNDER) { - return "SOP"; - } else { - return "Founder"; - } + if (level < ACCESS_VOP) { + return "Err"; + } else if (ircd->halfop && level < ACCESS_HOP) { + return "VOP"; + } else if (!ircd->halfop && level < ACCESS_AOP) { + return "VOP"; + } else if (ircd->halfop && level < ACCESS_AOP) { + return "HOP"; + } else if (level < ACCESS_SOP) { + return "AOP"; + } else if (level < ACCESS_FOUNDER) { + return "SOP"; + } else { + return "Founder"; + } } @@ -2196,84 +2196,84 @@ const char *get_xop_level(int level) AutoKick *is_stuck(ChannelInfo * ci, const char *mask) { - int i; - AutoKick *akick; - - if (!ci) { - return NULL; - } - - for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { - if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK) - || !(akick->flags & AK_STUCK)) - continue; - /* Example: mask = *!*@*.org and akick->u.mask = *!*@*.anope.org */ - if (match_wild_nocase(mask, akick->u.mask)) - return akick; - if (ircd->reversekickcheck) { - /* Example: mask = *!*@irc.anope.org and akick->u.mask = *!*@*.anope.org */ - if (match_wild_nocase(akick->u.mask, mask)) - return akick; - } - } - - return NULL; + int i; + AutoKick *akick; + + if (!ci) { + return NULL; + } + + for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { + if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK) + || !(akick->flags & AK_STUCK)) + continue; + /* Example: mask = *!*@*.org and akick->u.mask = *!*@*.anope.org */ + if (match_wild_nocase(mask, akick->u.mask)) + return akick; + if (ircd->reversekickcheck) { + /* Example: mask = *!*@irc.anope.org and akick->u.mask = *!*@*.anope.org */ + if (match_wild_nocase(akick->u.mask, mask)) + return akick; + } + } + + return NULL; } /* Ban the stuck mask in a safe manner. */ void stick_mask(ChannelInfo * ci, AutoKick * akick) { - const char *av[2]; - Entry *ban; - - if (!ci) { - return; - } - - if (ci->c->bans && ci->c->bans->entries != 0) { - for (ban = ci->c->bans->entries; ban; ban = ban->next) { - /* If akick is already covered by a wider ban. - Example: c->bans[i] = *!*@*.org and akick->u.mask = *!*@*.epona.org */ - if (entry_match_mask(ban, sstrdup(akick->u.mask), 0)) - return; - - if (ircd->reversekickcheck) { - /* If akick is wider than a ban already in place. - Example: c->bans[i] = *!*@irc.epona.org and akick->u.mask = *!*@*.epona.org */ - if (match_wild_nocase(akick->u.mask, ban->mask)) - return; - } - } - } - - /* Falling there means set the ban */ - av[0] = "+b"; - av[1] = akick->u.mask; - ircdproto->SendMode(whosends(ci), ci->c->name, "+b %s", akick->u.mask); - chan_set_modes(s_ChanServ, ci->c, 2, av, 1); + const char *av[2]; + Entry *ban; + + if (!ci) { + return; + } + + if (ci->c->bans && ci->c->bans->entries != 0) { + for (ban = ci->c->bans->entries; ban; ban = ban->next) { + /* If akick is already covered by a wider ban. + Example: c->bans[i] = *!*@*.org and akick->u.mask = *!*@*.epona.org */ + if (entry_match_mask(ban, sstrdup(akick->u.mask), 0)) + return; + + if (ircd->reversekickcheck) { + /* If akick is wider than a ban already in place. + Example: c->bans[i] = *!*@irc.epona.org and akick->u.mask = *!*@*.epona.org */ + if (match_wild_nocase(akick->u.mask, ban->mask)) + return; + } + } + } + + /* Falling there means set the ban */ + av[0] = "+b"; + av[1] = akick->u.mask; + ircdproto->SendMode(whosends(ci), ci->c->name, "+b %s", akick->u.mask); + chan_set_modes(s_ChanServ, ci->c, 2, av, 1); } /* Ban the stuck mask in a safe manner. */ void stick_all(ChannelInfo * ci) { - int i; - const char *av[2]; - AutoKick *akick; - - if (!ci) { - return; - } - - for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { - if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK) - || !(akick->flags & AK_STUCK)) - continue; - - av[0] = "+b"; - av[1] = akick->u.mask; - ircdproto->SendMode(whosends(ci), ci->c->name, "+b %s", akick->u.mask); - chan_set_modes(s_ChanServ, ci->c, 2, av, 1); - } + int i; + const char *av[2]; + AutoKick *akick; + + if (!ci) { + return; + } + + for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { + if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK) + || !(akick->flags & AK_STUCK)) + continue; + + av[0] = "+b"; + av[1] = akick->u.mask; + ircdproto->SendMode(whosends(ci), ci->c->name, "+b %s", akick->u.mask); + chan_set_modes(s_ChanServ, ci->c, 2, av, 1); + } } diff --git a/src/commands.c b/src/commands.c index a7851423d..9481e37d9 100644 --- a/src/commands.c +++ b/src/commands.c @@ -27,14 +27,14 @@ */ Command *lookup_cmd(Command * list, char *cmd) { - Command *c; + Command *c; - for (c = list; c->name; c++) { - if (stricmp(c->name, cmd) == 0) { - return c; - } - } - return NULL; + for (c = list; c->name; c++) { + if (stricmp(c->name, cmd) == 0) { + return c; + } + } + return NULL; } /*************************************************************************/ @@ -49,46 +49,46 @@ Command *lookup_cmd(Command * list, char *cmd) * @return void */ void mod_run_cmd(char *service, User * u, CommandHash * cmdTable[], - const char *cmd) + const char *cmd) { - Command *c = findCommand(cmdTable, cmd); - int retVal = 0; - Command *current; + Command *c = findCommand(cmdTable, cmd); + int retVal = 0; + Command *current; - if (c && c->routine) { - if ((checkDefCon(DEFCON_OPER_ONLY) - || checkDefCon(DEFCON_SILENT_OPER_ONLY)) && !is_oper(u)) { - if (!checkDefCon(DEFCON_SILENT_OPER_ONLY)) { - notice_lang(service, u, OPER_DEFCON_DENIED); - } - } else { - mod_current_module_name = c->mod_name; - mod_current_module = NULL; - if ((c->has_priv == NULL) || c->has_priv(u)) { - retVal = c->routine(u); - mod_current_module_name = NULL; - if (retVal == MOD_CONT) { - current = c->next; - while (current && retVal == MOD_CONT) { - mod_current_module_name = current->mod_name; - mod_current_module = NULL; - retVal = current->routine(u); - mod_current_module_name = NULL; - current = current->next; - } - } - } else { - notice_lang(service, u, ACCESS_DENIED); - alog("Access denied for %s with service %s and command %s", - u->nick, service, cmd); - } - mod_current_module_name = NULL; - } - } else { - if ((!checkDefCon(DEFCON_SILENT_OPER_ONLY)) || is_oper(u)) { - notice_lang(service, u, UNKNOWN_COMMAND_HELP, cmd, service); - } - } + if (c && c->routine) { + if ((checkDefCon(DEFCON_OPER_ONLY) + || checkDefCon(DEFCON_SILENT_OPER_ONLY)) && !is_oper(u)) { + if (!checkDefCon(DEFCON_SILENT_OPER_ONLY)) { + notice_lang(service, u, OPER_DEFCON_DENIED); + } + } else { + mod_current_module_name = c->mod_name; + mod_current_module = NULL; + if ((c->has_priv == NULL) || c->has_priv(u)) { + retVal = c->routine(u); + mod_current_module_name = NULL; + if (retVal == MOD_CONT) { + current = c->next; + while (current && retVal == MOD_CONT) { + mod_current_module_name = current->mod_name; + mod_current_module = NULL; + retVal = current->routine(u); + mod_current_module_name = NULL; + current = current->next; + } + } + } else { + notice_lang(service, u, ACCESS_DENIED); + alog("Access denied for %s with service %s and command %s", + u->nick, service, cmd); + } + mod_current_module_name = NULL; + } + } else { + if ((!checkDefCon(DEFCON_SILENT_OPER_ONLY)) || is_oper(u)) { + notice_lang(service, u, UNKNOWN_COMMAND_HELP, cmd, service); + } + } } /*************************************************************************/ @@ -102,18 +102,18 @@ void mod_run_cmd(char *service, User * u, CommandHash * cmdTable[], */ void do_help_limited(char *service, User * u, Command * c) { - if (c->has_priv == is_services_oper) - notice_lang(service, u, HELP_LIMIT_SERV_OPER); - else if (c->has_priv == is_services_admin) - notice_lang(service, u, HELP_LIMIT_SERV_ADMIN); - else if (c->has_priv == is_services_root) - notice_lang(service, u, HELP_LIMIT_SERV_ROOT); - else if (c->has_priv == is_oper) - notice_lang(service, u, HELP_LIMIT_IRC_OPER); - else if (c->has_priv == is_host_setter) - notice_lang(service, u, HELP_LIMIT_HOST_SETTER); - else if (c->has_priv == is_host_remover) - notice_lang(service, u, HELP_LIMIT_HOST_REMOVER); + if (c->has_priv == is_services_oper) + notice_lang(service, u, HELP_LIMIT_SERV_OPER); + else if (c->has_priv == is_services_admin) + notice_lang(service, u, HELP_LIMIT_SERV_ADMIN); + else if (c->has_priv == is_services_root) + notice_lang(service, u, HELP_LIMIT_SERV_ROOT); + else if (c->has_priv == is_oper) + notice_lang(service, u, HELP_LIMIT_IRC_OPER); + else if (c->has_priv == is_host_setter) + notice_lang(service, u, HELP_LIMIT_HOST_SETTER); + else if (c->has_priv == is_host_remover) + notice_lang(service, u, HELP_LIMIT_HOST_REMOVER); } /*************************************************************************/ @@ -127,81 +127,81 @@ void do_help_limited(char *service, User * u, Command * c) * @return void */ void mod_help_cmd(char *service, User * u, CommandHash * cmdTable[], - const char *cmd) + const char *cmd) { - Command *c = findCommand(cmdTable, cmd); - Command *current; - int has_had_help = 0; - int cont = MOD_CONT; - const char *p1 = NULL, *p2 = NULL, *p3 = NULL, *p4 = NULL; - Module *calling_module = mod_current_module; - const char *calling_module_name = mod_current_module_name; + Command *c = findCommand(cmdTable, cmd); + Command *current; + int has_had_help = 0; + int cont = MOD_CONT; + const char *p1 = NULL, *p2 = NULL, *p3 = NULL, *p4 = NULL; + Module *calling_module = mod_current_module; + const char *calling_module_name = mod_current_module_name; - for (current = c; (current) && (cont == MOD_CONT); - current = current->next) { - mod_current_module_name = current->mod_name; - if (mod_current_module_name) - mod_current_module = findModule(mod_current_module_name); - else - mod_current_module = NULL; + for (current = c; (current) && (cont == MOD_CONT); + current = current->next) { + mod_current_module_name = current->mod_name; + if (mod_current_module_name) + mod_current_module = findModule(mod_current_module_name); + else + mod_current_module = NULL; - p1 = current->help_param1; - p2 = current->help_param2; - p3 = current->help_param3; - p4 = current->help_param4; - if (current->helpmsg_all >= 0) { - notice_help(service, u, current->helpmsg_all, p1, p2, p3, p4); - has_had_help = 1; - } else if (current->all_help) { - cont = current->all_help(u); - has_had_help = 1; - } - if (is_services_root(u)) { - if (current->helpmsg_root >= 0) { - notice_help(service, u, current->helpmsg_root, p1, p2, p3, - p4); - has_had_help = 1; - } else if (current->root_help) { - cont = current->root_help(u); - has_had_help = 1; - } - } else if (is_services_admin(u)) { - if (current->helpmsg_admin >= 0) { - notice_help(service, u, current->helpmsg_admin, p1, p2, p3, - p4); - has_had_help = 1; - } else if (current->admin_help) { - cont = current->admin_help(u); - has_had_help = 1; - } - } else if (is_services_oper(u)) { - if (current->helpmsg_oper >= 0) { - notice_help(service, u, current->helpmsg_oper, p1, p2, p3, - p4); - has_had_help = 1; - } else if (current->oper_help) { - cont = current->oper_help(u); - has_had_help = 1; - } - } else { - if (current->helpmsg_reg >= 0) { - notice_help(service, u, current->helpmsg_reg, p1, p2, p3, - p4); - has_had_help = 1; - } else if (current->regular_help) { - cont = current->regular_help(u); - has_had_help = 1; - } - } - } - if (has_had_help == 0) { - notice_lang(service, u, NO_HELP_AVAILABLE, cmd); - } else { - do_help_limited(service, u, c); - } + p1 = current->help_param1; + p2 = current->help_param2; + p3 = current->help_param3; + p4 = current->help_param4; + if (current->helpmsg_all >= 0) { + notice_help(service, u, current->helpmsg_all, p1, p2, p3, p4); + has_had_help = 1; + } else if (current->all_help) { + cont = current->all_help(u); + has_had_help = 1; + } + if (is_services_root(u)) { + if (current->helpmsg_root >= 0) { + notice_help(service, u, current->helpmsg_root, p1, p2, p3, + p4); + has_had_help = 1; + } else if (current->root_help) { + cont = current->root_help(u); + has_had_help = 1; + } + } else if (is_services_admin(u)) { + if (current->helpmsg_admin >= 0) { + notice_help(service, u, current->helpmsg_admin, p1, p2, p3, + p4); + has_had_help = 1; + } else if (current->admin_help) { + cont = current->admin_help(u); + has_had_help = 1; + } + } else if (is_services_oper(u)) { + if (current->helpmsg_oper >= 0) { + notice_help(service, u, current->helpmsg_oper, p1, p2, p3, + p4); + has_had_help = 1; + } else if (current->oper_help) { + cont = current->oper_help(u); + has_had_help = 1; + } + } else { + if (current->helpmsg_reg >= 0) { + notice_help(service, u, current->helpmsg_reg, p1, p2, p3, + p4); + has_had_help = 1; + } else if (current->regular_help) { + cont = current->regular_help(u); + has_had_help = 1; + } + } + } + if (has_had_help == 0) { + notice_lang(service, u, NO_HELP_AVAILABLE, cmd); + } else { + do_help_limited(service, u, c); + } - mod_current_module = calling_module; - mod_current_module_name = calling_module_name; + mod_current_module = calling_module; + mod_current_module_name = calling_module_name; } /*************************************************************************/ diff --git a/src/compat.c b/src/compat.c index 0279efec8..5b1a6f665 100644 --- a/src/compat.c +++ b/src/compat.c @@ -19,39 +19,39 @@ #if !HAVE_STRICMP && !HAVE_STRCASECMP /* stricmp, strnicmp: Case-insensitive versions of strcmp() and - * strncmp(). + * strncmp(). */ int stricmp(const char *s1, const char *s2) { - register int c; - - while ((c = tolower(*s1)) == tolower(*s2)) { - if (c == 0) - return 0; - s1++; - s2++; - } - if (c < tolower(*s2)) - return -1; - return 1; + register int c; + + while ((c = tolower(*s1)) == tolower(*s2)) { + if (c == 0) + return 0; + s1++; + s2++; + } + if (c < tolower(*s2)) + return -1; + return 1; } int strnicmp(const char *s1, const char *s2, size_t len) { - register int c; - - if (!len) - return 0; - while ((c = tolower(*s1)) == tolower(*s2) && len > 0) { - if (c == 0 || --len == 0) - return 0; - s1++; - s2++; - } - if (c < tolower(*s2)) - return -1; - return 1; + register int c; + + if (!len) + return 0; + while ((c = tolower(*s1)) == tolower(*s2) && len > 0) { + if (c == 0 || --len == 0) + return 0; + s1++; + s2++; + } + if (c < tolower(*s2)) + return -1; + return 1; } #endif diff --git a/src/config.c b/src/config.c index 66b880163..73660d286 100644 --- a/src/config.c +++ b/src/config.c @@ -67,9 +67,9 @@ char *desc_HelpServ; char *desc_OperServ; char *desc_GlobalNoticer; -char *HostDBName; /* Name of HostServ DB File */ -char *s_HostServ; /* HostServ Name */ -char *desc_HostServ; /* HostServ Description */ +char *HostDBName; /* Name of HostServ DB File */ +char *s_HostServ; /* HostServ Name */ +char *desc_HostServ; /* HostServ Description */ char *PIDFilename; char *MOTDFilename; @@ -83,7 +83,7 @@ char *NewsDBName; static char *HostSetter; char **HostSetters; -int HostNumber = 0; /* needs to be set to 0 */ +int HostNumber = 0; /* needs to be set to 0 */ int NoBackupOkay; int StrictPasswords; @@ -1330,57 +1330,57 @@ bool ValueItem::GetBool() /*************************************************************************/ Directive directives[] = { - {"BadPassLimit", {{PARAM_POSINT, PARAM_RELOAD, &BadPassLimit}}}, - {"BadPassTimeout", {{PARAM_TIME, PARAM_RELOAD, &BadPassTimeout}}}, - {"DumpCore", {{PARAM_SET, 0, &DumpCore}}}, - {"EncModule", {{PARAM_STRING, 0, &EncModule}}}, - {"ExpireTimeout", {{PARAM_TIME, PARAM_RELOAD, &ExpireTimeout}}}, - {"ForceForbidReason", {{PARAM_SET, PARAM_RELOAD, &ForceForbidReason}}}, - {"KeepBackups", {{PARAM_INT, PARAM_RELOAD, &KeepBackups}}}, - {"KeepLogs", {{PARAM_INT, PARAM_RELOAD, &KeepLogs}}}, - {"LocalAddress", {{PARAM_STRING, 0, &LocalHost}, - {PARAM_PORT, PARAM_OPTIONAL, &LocalPort}}}, - {"LogUsers", {{PARAM_SET, PARAM_RELOAD, &LogUsers}}}, - {"MysqlHost", {{PARAM_STRING, PARAM_RELOAD, &MysqlHost}}}, - {"MysqlUser", {{PARAM_STRING, PARAM_RELOAD, &MysqlUser}}}, - {"MysqlPass", {{PARAM_STRING, PARAM_RELOAD, &MysqlPass}}}, - {"MysqlName", {{PARAM_STRING, PARAM_RELOAD, &MysqlName}}}, - {"MysqlPort", {{PARAM_PORT, PARAM_RELOAD, &MysqlPort}}}, - {"MysqlSecure", {{PARAM_STRING, PARAM_RELOAD, &MysqlSecure}}}, - {"MysqlSock", {{PARAM_STRING, PARAM_RELOAD, &MysqlSock}}}, - {"MysqlRetries", {{PARAM_POSINT, PARAM_RELOAD, &MysqlRetries}}}, - {"MysqlRetryGap", {{PARAM_POSINT, PARAM_RELOAD, &MysqlRetryGap}}}, - {"ModuleAutoload", {{PARAM_STRING, PARAM_RELOAD, &Modules}}}, - {"NewsCount", {{PARAM_POSINT, PARAM_RELOAD, &NewsCount}}}, - {"NickRegDelay", {{PARAM_POSINT, PARAM_RELOAD, &NickRegDelay}}}, - {"NoBackupOkay", {{PARAM_SET, PARAM_RELOAD, &NoBackupOkay}}}, - {"ReadTimeout", {{PARAM_TIME, PARAM_RELOAD, &ReadTimeout}}}, - {"RemoteServer2", {{PARAM_STRING, 0, &RemoteServer2}, - {PARAM_PORT, 0, &RemotePort2}, - {PARAM_STRING, 0, &RemotePassword2}}}, - {"RemoteServer3", {{PARAM_STRING, 0, &RemoteServer3}, - {PARAM_PORT, 0, &RemotePort3}, - {PARAM_STRING, 0, &RemotePassword3}}}, - {"RestrictOperNicks", {{PARAM_SET, PARAM_RELOAD, &RestrictOperNicks}}}, - {"HideStatsO", {{PARAM_SET, PARAM_RELOAD, &HideStatsO}}}, - {"GlobalOnCycle", {{PARAM_SET, PARAM_RELOAD, &GlobalOnCycle}}}, - {"AnonymousGlobal", {{PARAM_SET, PARAM_RELOAD, &AnonymousGlobal}}}, - {"GlobalOnCycleMessage", - {{PARAM_STRING, PARAM_RELOAD, &GlobalOnCycleMessage}}}, - {"GlobalOnCycleUP", {{PARAM_STRING, PARAM_RELOAD, &GlobalOnCycleUP}}}, - {"StrictPasswords", {{PARAM_SET, PARAM_RELOAD, &StrictPasswords}}}, - {"TimeoutCheck", {{PARAM_TIME, PARAM_RELOAD, &TimeoutCheck}}}, - {"UpdateTimeout", {{PARAM_TIME, PARAM_RELOAD, &UpdateTimeout}}}, - {"UsePrivmsg", {{PARAM_SET, PARAM_RELOAD, &UsePrivmsg}}}, - {"UseStrictPrivMsg", {{PARAM_SET, PARAM_RELOAD, &UseStrictPrivMsg}}}, - {"UserKey1", {{PARAM_POSINT, PARAM_RELOAD, &UserKey1}}}, - {"UserKey2", {{PARAM_POSINT, PARAM_RELOAD, &UserKey2}}}, - {"UserKey3", {{PARAM_POSINT, PARAM_RELOAD, &UserKey3}}}, - {"UseSVSHOLD", {{PARAM_SET, PARAM_RELOAD, &UseSVSHOLD}}}, - {"UseTS6", {{PARAM_SET, 0, &UseTS6}}}, - {"UnRestrictSAdmin", {{PARAM_SET, PARAM_RELOAD, &UnRestrictSAdmin}}}, - {"WarningTimeout", {{PARAM_TIME, PARAM_RELOAD, &WarningTimeout}}}, - {"UlineServers", {{PARAM_STRING, PARAM_RELOAD, &UlineServers}}}, + {"BadPassLimit", {{PARAM_POSINT, PARAM_RELOAD, &BadPassLimit}}}, + {"BadPassTimeout", {{PARAM_TIME, PARAM_RELOAD, &BadPassTimeout}}}, + {"DumpCore", {{PARAM_SET, 0, &DumpCore}}}, + {"EncModule", {{PARAM_STRING, 0, &EncModule}}}, + {"ExpireTimeout", {{PARAM_TIME, PARAM_RELOAD, &ExpireTimeout}}}, + {"ForceForbidReason", {{PARAM_SET, PARAM_RELOAD, &ForceForbidReason}}}, + {"KeepBackups", {{PARAM_INT, PARAM_RELOAD, &KeepBackups}}}, + {"KeepLogs", {{PARAM_INT, PARAM_RELOAD, &KeepLogs}}}, + {"LocalAddress", {{PARAM_STRING, 0, &LocalHost}, + {PARAM_PORT, PARAM_OPTIONAL, &LocalPort}}}, + {"LogUsers", {{PARAM_SET, PARAM_RELOAD, &LogUsers}}}, + {"MysqlHost", {{PARAM_STRING, PARAM_RELOAD, &MysqlHost}}}, + {"MysqlUser", {{PARAM_STRING, PARAM_RELOAD, &MysqlUser}}}, + {"MysqlPass", {{PARAM_STRING, PARAM_RELOAD, &MysqlPass}}}, + {"MysqlName", {{PARAM_STRING, PARAM_RELOAD, &MysqlName}}}, + {"MysqlPort", {{PARAM_PORT, PARAM_RELOAD, &MysqlPort}}}, + {"MysqlSecure", {{PARAM_STRING, PARAM_RELOAD, &MysqlSecure}}}, + {"MysqlSock", {{PARAM_STRING, PARAM_RELOAD, &MysqlSock}}}, + {"MysqlRetries", {{PARAM_POSINT, PARAM_RELOAD, &MysqlRetries}}}, + {"MysqlRetryGap", {{PARAM_POSINT, PARAM_RELOAD, &MysqlRetryGap}}}, + {"ModuleAutoload", {{PARAM_STRING, PARAM_RELOAD, &Modules}}}, + {"NewsCount", {{PARAM_POSINT, PARAM_RELOAD, &NewsCount}}}, + {"NickRegDelay", {{PARAM_POSINT, PARAM_RELOAD, &NickRegDelay}}}, + {"NoBackupOkay", {{PARAM_SET, PARAM_RELOAD, &NoBackupOkay}}}, + {"ReadTimeout", {{PARAM_TIME, PARAM_RELOAD, &ReadTimeout}}}, + {"RemoteServer2", {{PARAM_STRING, 0, &RemoteServer2}, + {PARAM_PORT, 0, &RemotePort2}, + {PARAM_STRING, 0, &RemotePassword2}}}, + {"RemoteServer3", {{PARAM_STRING, 0, &RemoteServer3}, + {PARAM_PORT, 0, &RemotePort3}, + {PARAM_STRING, 0, &RemotePassword3}}}, + {"RestrictOperNicks", {{PARAM_SET, PARAM_RELOAD, &RestrictOperNicks}}}, + {"HideStatsO", {{PARAM_SET, PARAM_RELOAD, &HideStatsO}}}, + {"GlobalOnCycle", {{PARAM_SET, PARAM_RELOAD, &GlobalOnCycle}}}, + {"AnonymousGlobal", {{PARAM_SET, PARAM_RELOAD, &AnonymousGlobal}}}, + {"GlobalOnCycleMessage", + {{PARAM_STRING, PARAM_RELOAD, &GlobalOnCycleMessage}}}, + {"GlobalOnCycleUP", {{PARAM_STRING, PARAM_RELOAD, &GlobalOnCycleUP}}}, + {"StrictPasswords", {{PARAM_SET, PARAM_RELOAD, &StrictPasswords}}}, + {"TimeoutCheck", {{PARAM_TIME, PARAM_RELOAD, &TimeoutCheck}}}, + {"UpdateTimeout", {{PARAM_TIME, PARAM_RELOAD, &UpdateTimeout}}}, + {"UsePrivmsg", {{PARAM_SET, PARAM_RELOAD, &UsePrivmsg}}}, + {"UseStrictPrivMsg", {{PARAM_SET, PARAM_RELOAD, &UseStrictPrivMsg}}}, + {"UserKey1", {{PARAM_POSINT, PARAM_RELOAD, &UserKey1}}}, + {"UserKey2", {{PARAM_POSINT, PARAM_RELOAD, &UserKey2}}}, + {"UserKey3", {{PARAM_POSINT, PARAM_RELOAD, &UserKey3}}}, + {"UseSVSHOLD", {{PARAM_SET, PARAM_RELOAD, &UseSVSHOLD}}}, + {"UseTS6", {{PARAM_SET, 0, &UseTS6}}}, + {"UnRestrictSAdmin", {{PARAM_SET, PARAM_RELOAD, &UnRestrictSAdmin}}}, + {"WarningTimeout", {{PARAM_TIME, PARAM_RELOAD, &WarningTimeout}}}, + {"UlineServers", {{PARAM_STRING, PARAM_RELOAD, &UlineServers}}}, }; /*************************************************************************/ @@ -1389,24 +1389,24 @@ Directive directives[] = { void error(int linenum, const char *message, ...) { - char buf[4096]; - va_list args; + char buf[4096]; + va_list args; - va_start(args, message); - vsnprintf(buf, sizeof(buf), message, args); - va_end(args); + va_start(args, message); + vsnprintf(buf, sizeof(buf), message, args); + va_end(args); - if (linenum) - alog("%s:%d: %s", SERVICES_CONF, linenum, buf); - else - alog("%s: %s", SERVICES_CONF, buf); + if (linenum) + alog("%s:%d: %s", SERVICES_CONF, linenum, buf); + else + alog("%s: %s", SERVICES_CONF, buf); if (!nofork && isatty(2)) { - if (linenum) - fprintf(stderr, "%s:%d: %s\n", SERVICES_CONF, linenum, buf); - else - fprintf(stderr, "%s: %s\n", SERVICES_CONF, buf); - } + if (linenum) + fprintf(stderr, "%s:%d: %s\n", SERVICES_CONF, linenum, buf); + else + fprintf(stderr, "%s: %s\n", SERVICES_CONF, buf); + } } /*************************************************************************/ @@ -1417,191 +1417,191 @@ void error(int linenum, const char *message, ...) */ int parse_directive(Directive * d, char *dir, int ac, char *av[MAXPARAMS], - int linenum, int reload, char *s) + int linenum, int reload, char *s) { - int retval = 1; - int i; - long val; - int myoptind; - - if (stricmp(dir, d->name) != 0) - return 1; - myoptind = 0; - for (i = 0; i < MAXPARAMS && d->params[i].type != PARAM_NONE; i++) { - if (reload && !(d->params[i].flags & PARAM_RELOAD)) - continue; - - if (d->params[i].type == PARAM_SET) { - *(int *) d->params[i].ptr = 1; - continue; - } - - /* Should we remove PARAM_DEPRECATED because it's - * useless right now? -GD */ - if (d->params[i].type == PARAM_DEPRECATED) { - void (*func) (void); - error(linenum, "Deprecated directive `%s' used", d->name); - func = (void (*)(void)) (d->params[i].ptr); - func(); /* For clarity */ - continue; - } - if (myoptind >= ac) { - if (!(d->params[i].flags & PARAM_OPTIONAL)) { - error(linenum, "Not enough parameters for `%s'", d->name); - retval = 0; - } - break; - } - switch (d->params[i].type) { - case PARAM_INT: - val = strtol(av[myoptind++], &s, 0); - if (*s) { - error(linenum, - "%s: Expected an integer for parameter %d", - d->name, myoptind); - retval = 0; - break; - } - *(int *) d->params[i].ptr = val; - break; - case PARAM_POSINT: - val = strtol(av[myoptind++], &s, 0); - if (*s || val <= 0) { - error(linenum, - "%s: Expected a positive integer for parameter %d", - d->name, myoptind); - retval = 0; - break; - } - if (errno == ERANGE && val == LONG_MAX) { - /* well the true top off is 2,147,483,647 but lets not give them the real top */ - error(linenum, - "%s: paramter %d is to large, reduce this value (0 to 2,147,483,646)", - d->name, myoptind); - } - *(int *) d->params[i].ptr = val; - break; - case PARAM_PORT: - val = strtol(av[myoptind++], &s, 0); - if (*s) { - error(linenum, - "%s: Expected a port number for parameter %d", - d->name, myoptind); - retval = 0; - break; - } - if (val < 1 || val > 65535) { - error(linenum, - "Port numbers must be in the range 1..65535"); - retval = 0; - break; - } - *(int *) d->params[i].ptr = val; - break; - case PARAM_STRING: -/* if (reload && *(char **)d->params[i].ptr) - free(*(char **)d->params[i].ptr); */ - *(char **) d->params[i].ptr = sstrdup(av[myoptind++]); - if (!d->params[i].ptr) { - error(linenum, "%s: Out of memory", d->name); - return 0; - } - break; - case PARAM_TIME: - val = dotime(av[myoptind++]); - if (val < 0) { - error(linenum, - "%s: Expected a time value for parameter %d", - d->name, myoptind); - retval = 0; - break; - } - *(int *) d->params[i].ptr = val; - break; - default: - error(linenum, "%s: Unknown type %d for param %d", - d->name, d->params[i].type, i + 1); - retval = 0; /* don't bother continuing--something's bizarre */ - break; - } - } - return retval;; + int retval = 1; + int i; + long val; + int myoptind; + + if (stricmp(dir, d->name) != 0) + return 1; + myoptind = 0; + for (i = 0; i < MAXPARAMS && d->params[i].type != PARAM_NONE; i++) { + if (reload && !(d->params[i].flags & PARAM_RELOAD)) + continue; + + if (d->params[i].type == PARAM_SET) { + *(int *) d->params[i].ptr = 1; + continue; + } + + /* Should we remove PARAM_DEPRECATED because it's + * useless right now? -GD */ + if (d->params[i].type == PARAM_DEPRECATED) { + void (*func) (void); + error(linenum, "Deprecated directive `%s' used", d->name); + func = (void (*)(void)) (d->params[i].ptr); + func(); /* For clarity */ + continue; + } + if (myoptind >= ac) { + if (!(d->params[i].flags & PARAM_OPTIONAL)) { + error(linenum, "Not enough parameters for `%s'", d->name); + retval = 0; + } + break; + } + switch (d->params[i].type) { + case PARAM_INT: + val = strtol(av[myoptind++], &s, 0); + if (*s) { + error(linenum, + "%s: Expected an integer for parameter %d", + d->name, myoptind); + retval = 0; + break; + } + *(int *) d->params[i].ptr = val; + break; + case PARAM_POSINT: + val = strtol(av[myoptind++], &s, 0); + if (*s || val <= 0) { + error(linenum, + "%s: Expected a positive integer for parameter %d", + d->name, myoptind); + retval = 0; + break; + } + if (errno == ERANGE && val == LONG_MAX) { + /* well the true top off is 2,147,483,647 but lets not give them the real top */ + error(linenum, + "%s: paramter %d is to large, reduce this value (0 to 2,147,483,646)", + d->name, myoptind); + } + *(int *) d->params[i].ptr = val; + break; + case PARAM_PORT: + val = strtol(av[myoptind++], &s, 0); + if (*s) { + error(linenum, + "%s: Expected a port number for parameter %d", + d->name, myoptind); + retval = 0; + break; + } + if (val < 1 || val > 65535) { + error(linenum, + "Port numbers must be in the range 1..65535"); + retval = 0; + break; + } + *(int *) d->params[i].ptr = val; + break; + case PARAM_STRING: +/* if (reload && *(char **)d->params[i].ptr) + free(*(char **)d->params[i].ptr); */ + *(char **) d->params[i].ptr = sstrdup(av[myoptind++]); + if (!d->params[i].ptr) { + error(linenum, "%s: Out of memory", d->name); + return 0; + } + break; + case PARAM_TIME: + val = dotime(av[myoptind++]); + if (val < 0) { + error(linenum, + "%s: Expected a time value for parameter %d", + d->name, myoptind); + retval = 0; + break; + } + *(int *) d->params[i].ptr = val; + break; + default: + error(linenum, "%s: Unknown type %d for param %d", + d->name, d->params[i].type, i + 1); + retval = 0; /* don't bother continuing--something's bizarre */ + break; + } + } + return retval;; } int parse(char *buf, int linenum, int reload) { - char *s, *t, *dir; - unsigned int n; - int retval = 1; - int ac = 0; - char *av[MAXPARAMS]; - - dir = strtok(buf, " \t\r\n"); - s = strtok(NULL, ""); - if (s) { - while (isspace(*s)) - s++; - while (*s) { - if (ac >= MAXPARAMS) { - error(linenum, "Warning: too many parameters (%d max)", - MAXPARAMS); - break; - } - t = s; - if (*s == '"') { - t++; - s++; - while (*s && *s != '"') { - if (*s == '\\' && s[1] != 0) - s++; - s++; - } - if (!*s) - error(linenum, - "Warning: unterminated double-quoted string"); - else - *s++ = 0; - } else { - s += strcspn(s, " \t\r\n"); - if (*s) - *s++ = 0; - } - av[ac++] = t; - while (isspace(*s)) - s++; - } - } - - if (!dir) - return 1; - - for (n = 0; n < lenof(directives); n++) { - Directive *d = &directives[n]; - retval = parse_directive(d, dir, ac, av, linenum, reload, s); - if (!retval) { - break; - } - } - - return retval; + char *s, *t, *dir; + unsigned int n; + int retval = 1; + int ac = 0; + char *av[MAXPARAMS]; + + dir = strtok(buf, " \t\r\n"); + s = strtok(NULL, ""); + if (s) { + while (isspace(*s)) + s++; + while (*s) { + if (ac >= MAXPARAMS) { + error(linenum, "Warning: too many parameters (%d max)", + MAXPARAMS); + break; + } + t = s; + if (*s == '"') { + t++; + s++; + while (*s && *s != '"') { + if (*s == '\\' && s[1] != 0) + s++; + s++; + } + if (!*s) + error(linenum, + "Warning: unterminated double-quoted string"); + else + *s++ = 0; + } else { + s += strcspn(s, " \t\r\n"); + if (*s) + *s++ = 0; + } + av[ac++] = t; + while (isspace(*s)) + s++; + } + } + + if (!dir) + return 1; + + for (n = 0; n < lenof(directives); n++) { + Directive *d = &directives[n]; + retval = parse_directive(d, dir, ac, av, linenum, reload, s); + if (!retval) { + break; + } + } + + return retval; } /*************************************************************************/ #define CHECK(v) do { \ - if (!v) { \ + if (!v) { \ error(0, #v " missing"); \ retval = 0; \ - } \ + } \ } while (0) #define CHEK2(v,n) do { \ - if (!v) { \ + if (!v) { \ error(0, #n " missing"); \ retval = 0; \ - } \ + } \ } while (0) /* Read the entire configuration file. If an error occurs while reading @@ -1615,95 +1615,95 @@ int parse(char *buf, int linenum, int reload) int read_config(int reload) { - FILE *config; - int linenum = 0, retval = 1; - char buf[1024], *s; - int defconCount = 0; - - if (reload) { - unsigned int i, n; - - /* Reset all the reloadable settings */ - - for (n = 0; n < lenof(directives); n++) { - Directive *d = &directives[n]; - - for (i = 0; i < MAXPARAMS && d->params[i].type != PARAM_NONE; - i++) { - if (!(d->params[i].flags & PARAM_RELOAD)) - continue; - - if (d->params[i].type == PARAM_SET - || d->params[i].type == PARAM_INT - || d->params[i].type == PARAM_POSINT - || d->params[i].type == PARAM_TIME) { - *(int *) d->params[i].ptr = 0; - } else if (d->params[i].type == PARAM_STRING) { - if (*(char **) d->params[i].ptr) - free(*(char **) d->params[i].ptr); - (*(char **) d->params[i].ptr) = NULL; - } - } - } - } + FILE *config; + int linenum = 0, retval = 1; + char buf[1024], *s; + int defconCount = 0; + + if (reload) { + unsigned int i, n; + + /* Reset all the reloadable settings */ + + for (n = 0; n < lenof(directives); n++) { + Directive *d = &directives[n]; + + for (i = 0; i < MAXPARAMS && d->params[i].type != PARAM_NONE; + i++) { + if (!(d->params[i].flags & PARAM_RELOAD)) + continue; + + if (d->params[i].type == PARAM_SET + || d->params[i].type == PARAM_INT + || d->params[i].type == PARAM_POSINT + || d->params[i].type == PARAM_TIME) { + *(int *) d->params[i].ptr = 0; + } else if (d->params[i].type == PARAM_STRING) { + if (*(char **) d->params[i].ptr) + free(*(char **) d->params[i].ptr); + (*(char **) d->params[i].ptr) = NULL; + } + } + } + } retval = serverConfig.Read(reload); if (!retval) return 0; // Temporary until most of the below is modified to use the new parser -- CyberBotX - config = fopen(SERVICES_CONF, "r"); - if (!config) { - log_perror("Can't open " SERVICES_CONF); - if (!nofork && isatty(2)) { - if (!reload) - perror("Can't open " SERVICES_CONF); - else - alog("Can't open %s", SERVICES_CONF); - } - return 0; - } - while (fgets(buf, sizeof(buf), config)) { - linenum++; - if (*buf == '#' || *buf == '\r' || *buf == '\n') - continue; - if (!parse(buf, linenum, reload)) - retval = 0; - } - fclose(config); - - if (!reload) { - if (RemoteServer3) - CHECK(RemoteServer2); - - if (LocalHost && RemoteServer) { - if ((!stricmp(LocalHost, RemoteServer)) - && LocalPort == RemotePort) { - printf - ("\n*** LocalAddress and RemoteServer are set to use the same IP address\n" - "*** (%s) and port (%d). This would have resulted in errors.\n" - "*** Change the LocalAddress to bind to another port.\n", - RemoteServer, LocalPort); - retval = 0; - } - } - } - - CHECK(EncModule); - - CHECK(UpdateTimeout); - CHECK(ExpireTimeout); - CHECK(ReadTimeout); - CHECK(WarningTimeout); - CHECK(TimeoutCheck); - - if (temp_nsuserhost) { - if (!(s = strchr(temp_nsuserhost, '@'))) { - NSEnforcerUser = temp_nsuserhost; - NSEnforcerHost = ServiceHost; - } else { - *s++ = 0; - NSEnforcerUser = temp_nsuserhost; - NSEnforcerHost = s; - } - } + config = fopen(SERVICES_CONF, "r"); + if (!config) { + log_perror("Can't open " SERVICES_CONF); + if (!nofork && isatty(2)) { + if (!reload) + perror("Can't open " SERVICES_CONF); + else + alog("Can't open %s", SERVICES_CONF); + } + return 0; + } + while (fgets(buf, sizeof(buf), config)) { + linenum++; + if (*buf == '#' || *buf == '\r' || *buf == '\n') + continue; + if (!parse(buf, linenum, reload)) + retval = 0; + } + fclose(config); + + if (!reload) { + if (RemoteServer3) + CHECK(RemoteServer2); + + if (LocalHost && RemoteServer) { + if ((!stricmp(LocalHost, RemoteServer)) + && LocalPort == RemotePort) { + printf + ("\n*** LocalAddress and RemoteServer are set to use the same IP address\n" + "*** (%s) and port (%d). This would have resulted in errors.\n" + "*** Change the LocalAddress to bind to another port.\n", + RemoteServer, LocalPort); + retval = 0; + } + } + } + + CHECK(EncModule); + + CHECK(UpdateTimeout); + CHECK(ExpireTimeout); + CHECK(ReadTimeout); + CHECK(WarningTimeout); + CHECK(TimeoutCheck); + + if (temp_nsuserhost) { + if (!(s = strchr(temp_nsuserhost, '@'))) { + NSEnforcerUser = temp_nsuserhost; + NSEnforcerHost = ServiceHost; + } else { + *s++ = 0; + NSEnforcerUser = temp_nsuserhost; + NSEnforcerHost = s; + } + } NSDefFlags = 0; if (NSDefaults.empty()) NSDefFlags = NI_SECURE | NI_MEMO_SIGNON | NI_MEMO_RECEIVE; @@ -1730,30 +1730,30 @@ int read_config(int reload) if (!hadAutoop) NSDefFlags |= NI_AUTOOP; } - if (!NewsCount) { - NewsCount = 3; - } - - if (reload) { - if ((NSDefLanguage = langlist[NSDefLanguage]) < 0) - NSDefLanguage = DEF_LANGUAGE; - } - - if (CSDefBantype < 0 || CSDefBantype > 3) { - error(0, "Value of CSDefBantype must be between 0 and 3 included"); - retval = 0; - } - - if (!MysqlRetries || !MysqlRetryGap) { - MysqlRetries = 5; - MysqlRetryGap = 1; - } else if (((MysqlRetries * MysqlRetryGap) > 60) - || ((MysqlRetries * MysqlRetryGap) < 1)) { - error(0, - "MysqlRetries * MysqlRetryGap must be between 1 and 60, using standard values."); - MysqlRetries = 5; - MysqlRetryGap = 1; - } + if (!NewsCount) { + NewsCount = 3; + } + + if (reload) { + if ((NSDefLanguage = langlist[NSDefLanguage]) < 0) + NSDefLanguage = DEF_LANGUAGE; + } + + if (CSDefBantype < 0 || CSDefBantype > 3) { + error(0, "Value of CSDefBantype must be between 0 and 3 included"); + retval = 0; + } + + if (!MysqlRetries || !MysqlRetryGap) { + MysqlRetries = 5; + MysqlRetryGap = 1; + } else if (((MysqlRetries * MysqlRetryGap) > 60) + || ((MysqlRetries * MysqlRetryGap) < 1)) { + error(0, + "MysqlRetries * MysqlRetryGap must be between 1 and 60, using standard values."); + MysqlRetries = 5; + MysqlRetryGap = 1; + } CSDefFlags = 0; if (CSDefaults.empty()) CSDefFlags = CI_KEEPTOPIC | CI_SECURE | CI_SECUREFOUNDER | CI_SIGNKICK; @@ -1821,101 +1821,101 @@ int read_config(int reload) } } - /* Services Root building */ - - if (ServicesRoot && !reload) { /* Check to prevent segmentation fault if it's missing */ - RootNumber = 0; - - s = strtok(ServicesRoot, " "); - do { - if (s) { - RootNumber++; - ServicesRoots = - (char **)realloc(ServicesRoots, sizeof(char *) * RootNumber); - ServicesRoots[RootNumber - 1] = sstrdup(s); - } - } while ((s = strtok(NULL, " "))); - } - - if (!RootNumber) { - error(0, "No ServicesRoot defined"); - retval = 0; - } - - /* Ulines */ - - if (UlineServers) { - NumUlines = 0; - - s = strtok(UlineServers, " "); - do { - if (s) { - NumUlines++; - Ulines = (char **)realloc(Ulines, sizeof(char *) * NumUlines); - Ulines[NumUlines - 1] = sstrdup(s); - } - } while ((s = strtok(NULL, " "))); - } - - /* Host Setters building... :P */ - HostSetters = buildStringList(HostSetter, &HostNumber); - - /* Modules Autoload building... :P */ - ModulesAutoload = buildStringList(Modules, &ModulesNumber); - HostServCoreModules = - buildStringList(HostCoreModules, &HostServCoreNumber); - MemoServCoreModules = - buildStringList(MemoCoreModules, &MemoServCoreNumber); - HelpServCoreModules = - buildStringList(HelpCoreModules, &HelpServCoreNumber); - - BotServCoreModules = - buildStringList(BotCoreModules, &BotServCoreNumber); - - OperServCoreModules = - buildStringList(OperCoreModules, &OperServCoreNumber); - - ChanServCoreModules = - buildStringList(ChanCoreModules, &ChanServCoreNumber); - - NickServCoreModules = - buildStringList(NickCoreModules, &NickServCoreNumber); - - - if (LimitSessions) { - if (MaxSessionKill && !SessionAutoKillExpiry) - SessionAutoKillExpiry = 1800; /* 30 minutes */ - } - - if (s_BotServ) { - if (!BSFantasyCharacter || !*BSFantasyCharacter) - BSFantasyCharacter = sstrdup("!"); - if (*BSFantasyCharacter && (strlen(BSFantasyCharacter) > 1)) { - printf - ("*** BSFantasyCharacter is more than 1 character long. Only the first\n" - "*** character ('%c') will be used. The others will be ignored.\n", - *BSFantasyCharacter); - } - } - - if (GlobalOnCycle) { - if (!GlobalOnCycleMessage && !GlobalOnCycleUP) { - alog("GlobalOnCycleMessage and GlobalOnCycleUP are not defined; disabling GlobalOnCycle"); - GlobalOnCycle = 0; - } - } - - /* Check the user keys */ - if ((UserKey1 == UserKey2) || (UserKey1 == UserKey3) - || (UserKey3 == UserKey2)) - alog("Every UserKey must be different. It's for YOUR safety! Remember that!"); - - /** - * Check all DEFCON dependiencies... - **/ - if (DefConLevel) { - /* Build DefCon's */ - DefCon[0] = 0; + /* Services Root building */ + + if (ServicesRoot && !reload) { /* Check to prevent segmentation fault if it's missing */ + RootNumber = 0; + + s = strtok(ServicesRoot, " "); + do { + if (s) { + RootNumber++; + ServicesRoots = + (char **)realloc(ServicesRoots, sizeof(char *) * RootNumber); + ServicesRoots[RootNumber - 1] = sstrdup(s); + } + } while ((s = strtok(NULL, " "))); + } + + if (!RootNumber) { + error(0, "No ServicesRoot defined"); + retval = 0; + } + + /* Ulines */ + + if (UlineServers) { + NumUlines = 0; + + s = strtok(UlineServers, " "); + do { + if (s) { + NumUlines++; + Ulines = (char **)realloc(Ulines, sizeof(char *) * NumUlines); + Ulines[NumUlines - 1] = sstrdup(s); + } + } while ((s = strtok(NULL, " "))); + } + + /* Host Setters building... :P */ + HostSetters = buildStringList(HostSetter, &HostNumber); + + /* Modules Autoload building... :P */ + ModulesAutoload = buildStringList(Modules, &ModulesNumber); + HostServCoreModules = + buildStringList(HostCoreModules, &HostServCoreNumber); + MemoServCoreModules = + buildStringList(MemoCoreModules, &MemoServCoreNumber); + HelpServCoreModules = + buildStringList(HelpCoreModules, &HelpServCoreNumber); + + BotServCoreModules = + buildStringList(BotCoreModules, &BotServCoreNumber); + + OperServCoreModules = + buildStringList(OperCoreModules, &OperServCoreNumber); + + ChanServCoreModules = + buildStringList(ChanCoreModules, &ChanServCoreNumber); + + NickServCoreModules = + buildStringList(NickCoreModules, &NickServCoreNumber); + + + if (LimitSessions) { + if (MaxSessionKill && !SessionAutoKillExpiry) + SessionAutoKillExpiry = 1800; /* 30 minutes */ + } + + if (s_BotServ) { + if (!BSFantasyCharacter || !*BSFantasyCharacter) + BSFantasyCharacter = sstrdup("!"); + if (*BSFantasyCharacter && (strlen(BSFantasyCharacter) > 1)) { + printf + ("*** BSFantasyCharacter is more than 1 character long. Only the first\n" + "*** character ('%c') will be used. The others will be ignored.\n", + *BSFantasyCharacter); + } + } + + if (GlobalOnCycle) { + if (!GlobalOnCycleMessage && !GlobalOnCycleUP) { + alog("GlobalOnCycleMessage and GlobalOnCycleUP are not defined; disabling GlobalOnCycle"); + GlobalOnCycle = 0; + } + } + + /* Check the user keys */ + if ((UserKey1 == UserKey2) || (UserKey1 == UserKey3) + || (UserKey3 == UserKey2)) + alog("Every UserKey must be different. It's for YOUR safety! Remember that!"); + + /** + * Check all DEFCON dependiencies... + **/ + if (DefConLevel) { + /* Build DefCon's */ + DefCon[0] = 0; for (int level = 1; level < 5; ++level) { DefCon[level] = 0; std::string *levelDefinition = NULL; @@ -1947,39 +1947,39 @@ int read_config(int reload) else if (operation == "nonewmemos") DefCon[level] |= DEFCON_NO_NEW_MEMOS; } } - DefCon[5] = 0; /* DefCon level 5 is always normal operation */ - for (defconCount = 1; defconCount <= 5; defconCount++) { /* Check any defcon needed settings */ - if (DefCon[defconCount] & DEFCON_REDUCE_SESSION) { - CHECK(DefConSessionLimit); - } - if (DefCon[defconCount] & DEFCON_AKILL_NEW_CLIENTS) { - CHECK(DefConAKILL); - CHECK(DefConAkillReason); - } - if (DefCon[defconCount] & DEFCON_FORCE_CHAN_MODES) { - CHECK(DefConChanModes); - } - } - } - - /** - * If they try to enable any email registration option, - * make sure they have everything else they need too... - * - * rob - **/ - if (!NSEmailReg) { + DefCon[5] = 0; /* DefCon level 5 is always normal operation */ + for (defconCount = 1; defconCount <= 5; defconCount++) { /* Check any defcon needed settings */ + if (DefCon[defconCount] & DEFCON_REDUCE_SESSION) { + CHECK(DefConSessionLimit); + } + if (DefCon[defconCount] & DEFCON_AKILL_NEW_CLIENTS) { + CHECK(DefConAKILL); + CHECK(DefConAkillReason); + } + if (DefCon[defconCount] & DEFCON_FORCE_CHAN_MODES) { + CHECK(DefConChanModes); + } + } + } + + /** + * If they try to enable any email registration option, + * make sure they have everything else they need too... + * + * rob + **/ + if (!NSEmailReg) { delete [] PreNickDBName; - PreNickDBName = NULL; - NSRExpire = 0; - } + PreNickDBName = NULL; + NSRExpire = 0; + } - if (!retval) { - printf - ("\n*** Support resources: Read through the services.conf self-contained \n*** documentation. Read the documentation files found in the 'docs' \n*** folder. Visit our portal located at http://www.anope.org/. Join \n*** our support channel on /server irc.anope.org channel #anope.\n\n"); - } + if (!retval) { + printf + ("\n*** Support resources: Read through the services.conf self-contained \n*** documentation. Read the documentation files found in the 'docs' \n*** folder. Visit our portal located at http://www.anope.org/. Join \n*** our support channel on /server irc.anope.org channel #anope.\n\n"); + } - return retval; + return retval; } diff --git a/src/core/bs_act.c b/src/core/bs_act.c index a5c8864da..87cd3d21d 100644 --- a/src/core/bs_act.c +++ b/src/core/bs_act.c @@ -23,15 +23,15 @@ class BSAct : public Module public: BSAct(const std::string &modname, const std::string &creator) : Module(modname, creator) { - Command *c; + Command *c; - this->SetAuthor("Anope"); - this->SetVersion("$Id$"); - this->SetType(CORE); - c = createCommand("ACT", do_act, NULL, BOT_HELP_ACT, -1, -1, -1, -1); - this->AddCommand(BOTSERV, c, MOD_UNIQUE); + this->SetAuthor("Anope"); + this->SetVersion("$Id$"); + this->SetType(CORE); + c = createCommand("ACT", do_act, NULL, BOT_HELP_ACT, -1, -1, -1, -1); + this->AddCommand(BOTSERV, c, MOD_UNIQUE); - moduleSetBotHelp(myBotServHelp); + moduleSetBotHelp(myBotServHelp); } }; @@ -42,7 +42,7 @@ class BSAct : public Module **/ void myBotServHelp(User * u) { - notice_lang(s_BotServ, u, BOT_HELP_CMD_ACT); + notice_lang(s_BotServ, u, BOT_HELP_CMD_ACT); } /** @@ -52,32 +52,32 @@ void myBotServHelp(User * u) **/ int do_act(User * u) { - ChannelInfo *ci; + ChannelInfo *ci; - char *chan = strtok(NULL, " "); - char *text = strtok(NULL, ""); + char *chan = strtok(NULL, " "); + char *text = strtok(NULL, ""); - if (!chan || !text) - syntax_error(s_BotServ, u, "ACT", BOT_ACT_SYNTAX); - else if (!(ci = cs_findchan(chan))) - notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); - else if (ci->flags & CI_VERBOTEN) - notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); - else if (!ci->bi) - notice_help(s_BotServ, u, BOT_NOT_ASSIGNED); - else if (!ci->c || ci->c->usercount < BSMinUsers) - notice_lang(s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name); - else if (!check_access(u, ci, CA_SAY)) - notice_lang(s_BotServ, u, ACCESS_DENIED); - else { - strnrepl(text, BUFSIZE, "\001", ""); - ircdproto->SendAction(ci->bi, ci->name, "%s", text); - ci->bi->lastmsg = time(NULL); - if (LogBot && LogChannel && logchan && !debug && findchan(LogChannel)) - ircdproto->SendPrivmsg(ci->bi, LogChannel, "ACT %s %s %s", - u->nick, ci->name, text); - } - return MOD_CONT; + if (!chan || !text) + syntax_error(s_BotServ, u, "ACT", BOT_ACT_SYNTAX); + else if (!(ci = cs_findchan(chan))) + notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); + else if (ci->flags & CI_VERBOTEN) + notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); + else if (!ci->bi) + notice_help(s_BotServ, u, BOT_NOT_ASSIGNED); + else if (!ci->c || ci->c->usercount < BSMinUsers) + notice_lang(s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name); + else if (!check_access(u, ci, CA_SAY)) + notice_lang(s_BotServ, u, ACCESS_DENIED); + else { + strnrepl(text, BUFSIZE, "\001", ""); + ircdproto->SendAction(ci->bi, ci->name, "%s", text); + ci->bi->lastmsg = time(NULL); + if (LogBot && LogChannel && logchan && !debug && findchan(LogChannel)) + ircdproto->SendPrivmsg(ci->bi, LogChannel, "ACT %s %s %s", + u->nick, ci->name, text); + } + return MOD_CONT; } MODULE_INIT("bs_act", BSAct) diff --git a/src/core/bs_assign.c b/src/core/bs_assign.c index 7cb6e3887..030a3c215 100644 --- a/src/core/bs_assign.c +++ b/src/core/bs_assign.c @@ -41,7 +41,7 @@ class BSAssign : public Module **/ void myBotServHelp(User * u) { - notice_lang(s_BotServ, u, BOT_HELP_CMD_ASSIGN); + notice_lang(s_BotServ, u, BOT_HELP_CMD_ASSIGN); } /** @@ -51,33 +51,33 @@ void myBotServHelp(User * u) **/ int do_assign(User * u) { - char *chan = strtok(NULL, " "); - char *nick = strtok(NULL, " "); - BotInfo *bi; - ChannelInfo *ci; + char *chan = strtok(NULL, " "); + char *nick = strtok(NULL, " "); + BotInfo *bi; + ChannelInfo *ci; - if (readonly) - notice_lang(s_BotServ, u, BOT_ASSIGN_READONLY); - else if (!chan || !nick) - syntax_error(s_BotServ, u, "ASSIGN", BOT_ASSIGN_SYNTAX); - else if (!(bi = findbot(nick))) - notice_lang(s_BotServ, u, BOT_DOES_NOT_EXIST, nick); - else if (bi->flags & BI_PRIVATE && !is_oper(u)) - notice_lang(s_BotServ, u, PERMISSION_DENIED); - else if (!(ci = cs_findchan(chan))) - notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); - else if (ci->flags & CI_VERBOTEN) - notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); - else if ((ci->bi) && (stricmp(ci->bi->nick, nick) == 0)) - notice_lang(s_BotServ, u, BOT_ASSIGN_ALREADY, ci->bi->nick, chan); - else if ((ci->botflags & BS_NOBOT) - || (!check_access(u, ci, CA_ASSIGN) && !is_services_admin(u))) - notice_lang(s_BotServ, u, PERMISSION_DENIED); - else { + if (readonly) + notice_lang(s_BotServ, u, BOT_ASSIGN_READONLY); + else if (!chan || !nick) + syntax_error(s_BotServ, u, "ASSIGN", BOT_ASSIGN_SYNTAX); + else if (!(bi = findbot(nick))) + notice_lang(s_BotServ, u, BOT_DOES_NOT_EXIST, nick); + else if (bi->flags & BI_PRIVATE && !is_oper(u)) + notice_lang(s_BotServ, u, PERMISSION_DENIED); + else if (!(ci = cs_findchan(chan))) + notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); + else if (ci->flags & CI_VERBOTEN) + notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); + else if ((ci->bi) && (stricmp(ci->bi->nick, nick) == 0)) + notice_lang(s_BotServ, u, BOT_ASSIGN_ALREADY, ci->bi->nick, chan); + else if ((ci->botflags & BS_NOBOT) + || (!check_access(u, ci, CA_ASSIGN) && !is_services_admin(u))) + notice_lang(s_BotServ, u, PERMISSION_DENIED); + else { bi->Assign(u, ci); - notice_lang(s_BotServ, u, BOT_ASSIGN_ASSIGNED, bi->nick, ci->name); - } - return MOD_CONT; + notice_lang(s_BotServ, u, BOT_ASSIGN_ASSIGNED, bi->nick, ci->name); + } + return MOD_CONT; } MODULE_INIT("bs_assign", BSAssign) diff --git a/src/core/bs_badwords.c b/src/core/bs_badwords.c index 65190c286..e1518c51c 100644 --- a/src/core/bs_badwords.c +++ b/src/core/bs_badwords.c @@ -46,7 +46,7 @@ class BSBadwords : public Module **/ void myBotServHelp(User * u) { - notice_lang(s_BotServ, u, BOT_HELP_CMD_BADWORDS); + notice_lang(s_BotServ, u, BOT_HELP_CMD_BADWORDS); } /** @@ -56,259 +56,259 @@ void myBotServHelp(User * u) **/ int do_badwords(User * u) { - char *chan = strtok(NULL, " "); - char *cmd = strtok(NULL, " "); - char *word = strtok(NULL, ""); - ChannelInfo *ci; - BadWord *bw; - - int i; - int need_args = (cmd - && (!stricmp(cmd, "LIST") || !stricmp(cmd, "CLEAR"))); - - if (!cmd || (need_args ? 0 : !word)) { - syntax_error(s_BotServ, u, "BADWORDS", BOT_BADWORDS_SYNTAX); - } else if (!(ci = cs_findchan(chan))) { - notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); - } else if (!check_access(u, ci, CA_BADWORDS) - && (!need_args || !is_services_admin(u))) { - notice_lang(s_BotServ, u, ACCESS_DENIED); - } else if (stricmp(cmd, "ADD") == 0) { - - char *opt, *pos; - int type = BW_ANY; - - if (readonly) { - notice_lang(s_BotServ, u, BOT_BADWORDS_DISABLED); - return MOD_CONT; - } - - pos = strrchr(word, ' '); - if (pos) { - opt = pos + 1; - if (*opt) { - if (!stricmp(opt, "SINGLE")) - type = BW_SINGLE; - else if (!stricmp(opt, "START")) - type = BW_START; - else if (!stricmp(opt, "END")) - type = BW_END; - if (type != BW_ANY) - *pos = 0; - } - } - - for (bw = ci->badwords, i = 0; i < ci->bwcount; bw++, i++) { - if (bw->word && ((BSCaseSensitive && (!strcmp(bw->word, word))) - || (!BSCaseSensitive - && (!stricmp(bw->word, word))))) { - notice_lang(s_BotServ, u, BOT_BADWORDS_ALREADY_EXISTS, - bw->word, ci->name); - return MOD_CONT; - } - } - - for (i = 0; i < ci->bwcount; i++) { - if (!ci->badwords[i].in_use) - break; - } - if (i == ci->bwcount) { - if (i < BSBadWordsMax) { - ci->bwcount++; - ci->badwords = - (BadWord *)srealloc(ci->badwords, sizeof(BadWord) * ci->bwcount); - } else { - notice_lang(s_BotServ, u, BOT_BADWORDS_REACHED_LIMIT, - BSBadWordsMax); - return MOD_CONT; - } - } - bw = &ci->badwords[i]; - bw->in_use = 1; - bw->word = sstrdup(word); - bw->type = type; - - notice_lang(s_BotServ, u, BOT_BADWORDS_ADDED, bw->word, ci->name); - - } else if (stricmp(cmd, "DEL") == 0) { - int deleted = 0, a, b; - - if (readonly) { - notice_lang(s_BotServ, u, BOT_BADWORDS_DISABLED); - return MOD_CONT; - } - - /* Special case: is it a number/list? Only do search if it isn't. */ - if (isdigit(*word) && strspn(word, "1234567890,-") == strlen(word)) { - int count, last = -1; - deleted = - process_numlist(word, &count, badwords_del_callback, u, ci, - &last); - if (!deleted) { - if (count == 1) { - notice_lang(s_BotServ, u, BOT_BADWORDS_NO_SUCH_ENTRY, - last, ci->name); - } else { - notice_lang(s_BotServ, u, BOT_BADWORDS_NO_MATCH, - ci->name); - } - } else if (deleted == 1) { - notice_lang(s_BotServ, u, BOT_BADWORDS_DELETED_ONE, - ci->name); - } else { - notice_lang(s_BotServ, u, BOT_BADWORDS_DELETED_SEVERAL, - deleted, ci->name); - } - } else { - for (i = 0; i < ci->bwcount; i++) { - if (ci->badwords[i].in_use - && !stricmp(ci->badwords[i].word, word)) - break; - } - if (i == ci->bwcount) { - notice_lang(s_BotServ, u, BOT_BADWORDS_NOT_FOUND, word, - chan); - return MOD_CONT; - } - bw = &ci->badwords[i]; - notice_lang(s_BotServ, u, BOT_BADWORDS_DELETED, bw->word, - ci->name); - if (bw->word) - free(bw->word); - bw->word = NULL; - bw->in_use = 0; - deleted = 1; - } - - if (deleted) { - /* Reordering - DrStein */ - for (b = 0; b < ci->bwcount; b++) { - if (ci->badwords[b].in_use) { - for (a = 0; a < ci->bwcount; a++) { - if (a > b) - break; - if (!(ci->badwords[a].in_use)) { - ci->badwords[a].in_use = ci->badwords[b].in_use; - ci->badwords[a].type = ci->badwords[b].type; - if (ci->badwords[b].word) { - ci->badwords[a].word = sstrdup(ci->badwords[b].word); - free(ci->badwords[b].word); - } - ci->badwords[b].word = NULL; - ci->badwords[b].in_use = 0; - break; - } - } - } - } - /* After reordering only the entries at the end could still be empty. - * We ll free the places no longer in use... - Viper */ - for (i = ci->bwcount - 1; i >= 0; i--) { - if (ci->badwords[i].in_use) - break; - ci->bwcount--; - } - ci->badwords = - (BadWord *)srealloc(ci->badwords,sizeof(BadWord) * ci->bwcount); - } - - } else if (stricmp(cmd, "LIST") == 0) { - int sent_header = 0; - - if (ci->bwcount == 0) { - notice_lang(s_BotServ, u, BOT_BADWORDS_LIST_EMPTY, chan); - return MOD_CONT; - } - if (word && strspn(word, "1234567890,-") == strlen(word)) { - process_numlist(word, NULL, badwords_list_callback, u, ci, - &sent_header); - } else { - for (i = 0; i < ci->bwcount; i++) { - if (!(ci->badwords[i].in_use)) - continue; - if (word && ci->badwords[i].word - && !match_wild_nocase(word, ci->badwords[i].word)) - continue; - badwords_list(u, i, ci, &sent_header); - } - } - if (!sent_header) - notice_lang(s_BotServ, u, BOT_BADWORDS_NO_MATCH, chan); - - } else if (stricmp(cmd, "CLEAR") == 0) { - - if (readonly) { - notice_lang(s_BotServ, u, BOT_BADWORDS_DISABLED); - return MOD_CONT; - } - - for (i = 0; i < ci->bwcount; i++) - if (ci->badwords[i].word) - free(ci->badwords[i].word); - - free(ci->badwords); - ci->badwords = NULL; - ci->bwcount = 0; - - notice_lang(s_BotServ, u, BOT_BADWORDS_CLEAR); - - } else { - syntax_error(s_BotServ, u, "BADWORDS", BOT_BADWORDS_SYNTAX); - } - return MOD_CONT; + char *chan = strtok(NULL, " "); + char *cmd = strtok(NULL, " "); + char *word = strtok(NULL, ""); + ChannelInfo *ci; + BadWord *bw; + + int i; + int need_args = (cmd + && (!stricmp(cmd, "LIST") || !stricmp(cmd, "CLEAR"))); + + if (!cmd || (need_args ? 0 : !word)) { + syntax_error(s_BotServ, u, "BADWORDS", BOT_BADWORDS_SYNTAX); + } else if (!(ci = cs_findchan(chan))) { + notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); + } else if (!check_access(u, ci, CA_BADWORDS) + && (!need_args || !is_services_admin(u))) { + notice_lang(s_BotServ, u, ACCESS_DENIED); + } else if (stricmp(cmd, "ADD") == 0) { + + char *opt, *pos; + int type = BW_ANY; + + if (readonly) { + notice_lang(s_BotServ, u, BOT_BADWORDS_DISABLED); + return MOD_CONT; + } + + pos = strrchr(word, ' '); + if (pos) { + opt = pos + 1; + if (*opt) { + if (!stricmp(opt, "SINGLE")) + type = BW_SINGLE; + else if (!stricmp(opt, "START")) + type = BW_START; + else if (!stricmp(opt, "END")) + type = BW_END; + if (type != BW_ANY) + *pos = 0; + } + } + + for (bw = ci->badwords, i = 0; i < ci->bwcount; bw++, i++) { + if (bw->word && ((BSCaseSensitive && (!strcmp(bw->word, word))) + || (!BSCaseSensitive + && (!stricmp(bw->word, word))))) { + notice_lang(s_BotServ, u, BOT_BADWORDS_ALREADY_EXISTS, + bw->word, ci->name); + return MOD_CONT; + } + } + + for (i = 0; i < ci->bwcount; i++) { + if (!ci->badwords[i].in_use) + break; + } + if (i == ci->bwcount) { + if (i < BSBadWordsMax) { + ci->bwcount++; + ci->badwords = + (BadWord *)srealloc(ci->badwords, sizeof(BadWord) * ci->bwcount); + } else { + notice_lang(s_BotServ, u, BOT_BADWORDS_REACHED_LIMIT, + BSBadWordsMax); + return MOD_CONT; + } + } + bw = &ci->badwords[i]; + bw->in_use = 1; + bw->word = sstrdup(word); + bw->type = type; + + notice_lang(s_BotServ, u, BOT_BADWORDS_ADDED, bw->word, ci->name); + + } else if (stricmp(cmd, "DEL") == 0) { + int deleted = 0, a, b; + + if (readonly) { + notice_lang(s_BotServ, u, BOT_BADWORDS_DISABLED); + return MOD_CONT; + } + + /* Special case: is it a number/list? Only do search if it isn't. */ + if (isdigit(*word) && strspn(word, "1234567890,-") == strlen(word)) { + int count, last = -1; + deleted = + process_numlist(word, &count, badwords_del_callback, u, ci, + &last); + if (!deleted) { + if (count == 1) { + notice_lang(s_BotServ, u, BOT_BADWORDS_NO_SUCH_ENTRY, + last, ci->name); + } else { + notice_lang(s_BotServ, u, BOT_BADWORDS_NO_MATCH, + ci->name); + } + } else if (deleted == 1) { + notice_lang(s_BotServ, u, BOT_BADWORDS_DELETED_ONE, + ci->name); + } else { + notice_lang(s_BotServ, u, BOT_BADWORDS_DELETED_SEVERAL, + deleted, ci->name); + } + } else { + for (i = 0; i < ci->bwcount; i++) { + if (ci->badwords[i].in_use + && !stricmp(ci->badwords[i].word, word)) + break; + } + if (i == ci->bwcount) { + notice_lang(s_BotServ, u, BOT_BADWORDS_NOT_FOUND, word, + chan); + return MOD_CONT; + } + bw = &ci->badwords[i]; + notice_lang(s_BotServ, u, BOT_BADWORDS_DELETED, bw->word, + ci->name); + if (bw->word) + free(bw->word); + bw->word = NULL; + bw->in_use = 0; + deleted = 1; + } + + if (deleted) { + /* Reordering - DrStein */ + for (b = 0; b < ci->bwcount; b++) { + if (ci->badwords[b].in_use) { + for (a = 0; a < ci->bwcount; a++) { + if (a > b) + break; + if (!(ci->badwords[a].in_use)) { + ci->badwords[a].in_use = ci->badwords[b].in_use; + ci->badwords[a].type = ci->badwords[b].type; + if (ci->badwords[b].word) { + ci->badwords[a].word = sstrdup(ci->badwords[b].word); + free(ci->badwords[b].word); + } + ci->badwords[b].word = NULL; + ci->badwords[b].in_use = 0; + break; + } + } + } + } + /* After reordering only the entries at the end could still be empty. + * We ll free the places no longer in use... - Viper */ + for (i = ci->bwcount - 1; i >= 0; i--) { + if (ci->badwords[i].in_use) + break; + ci->bwcount--; + } + ci->badwords = + (BadWord *)srealloc(ci->badwords,sizeof(BadWord) * ci->bwcount); + } + + } else if (stricmp(cmd, "LIST") == 0) { + int sent_header = 0; + + if (ci->bwcount == 0) { + notice_lang(s_BotServ, u, BOT_BADWORDS_LIST_EMPTY, chan); + return MOD_CONT; + } + if (word && strspn(word, "1234567890,-") == strlen(word)) { + process_numlist(word, NULL, badwords_list_callback, u, ci, + &sent_header); + } else { + for (i = 0; i < ci->bwcount; i++) { + if (!(ci->badwords[i].in_use)) + continue; + if (word && ci->badwords[i].word + && !match_wild_nocase(word, ci->badwords[i].word)) + continue; + badwords_list(u, i, ci, &sent_header); + } + } + if (!sent_header) + notice_lang(s_BotServ, u, BOT_BADWORDS_NO_MATCH, chan); + + } else if (stricmp(cmd, "CLEAR") == 0) { + + if (readonly) { + notice_lang(s_BotServ, u, BOT_BADWORDS_DISABLED); + return MOD_CONT; + } + + for (i = 0; i < ci->bwcount; i++) + if (ci->badwords[i].word) + free(ci->badwords[i].word); + + free(ci->badwords); + ci->badwords = NULL; + ci->bwcount = 0; + + notice_lang(s_BotServ, u, BOT_BADWORDS_CLEAR); + + } else { + syntax_error(s_BotServ, u, "BADWORDS", BOT_BADWORDS_SYNTAX); + } + return MOD_CONT; } int badwords_del_callback(User * u, int num, va_list args) { - BadWord *bw; - ChannelInfo *ci = va_arg(args, ChannelInfo *); - int *last = va_arg(args, int *); + BadWord *bw; + ChannelInfo *ci = va_arg(args, ChannelInfo *); + int *last = va_arg(args, int *); - *last = num; + *last = num; - if (num < 1 || num > ci->bwcount) - return 0; + if (num < 1 || num > ci->bwcount) + return 0; - bw = &ci->badwords[num - 1]; - if (bw->word) - free(bw->word); - bw->word = NULL; - bw->in_use = 0; + bw = &ci->badwords[num - 1]; + if (bw->word) + free(bw->word); + bw->word = NULL; + bw->in_use = 0; - return 1; + return 1; } int badwords_list(User * u, int index, ChannelInfo * ci, int *sent_header) { - BadWord *bw = &ci->badwords[index]; - - if (!bw->in_use) - return 0; - if (!*sent_header) { - notice_lang(s_BotServ, u, BOT_BADWORDS_LIST_HEADER, ci->name); - *sent_header = 1; - } - - notice_lang(s_BotServ, u, BOT_BADWORDS_LIST_FORMAT, index + 1, - bw->word, - ((bw->type == - BW_SINGLE) ? "(SINGLE)" : ((bw->type == - BW_START) ? "(START)" - : ((bw->type == - BW_END) ? "(END)" : ""))) - ); - return 1; + BadWord *bw = &ci->badwords[index]; + + if (!bw->in_use) + return 0; + if (!*sent_header) { + notice_lang(s_BotServ, u, BOT_BADWORDS_LIST_HEADER, ci->name); + *sent_header = 1; + } + + notice_lang(s_BotServ, u, BOT_BADWORDS_LIST_FORMAT, index + 1, + bw->word, + ((bw->type == + BW_SINGLE) ? "(SINGLE)" : ((bw->type == + BW_START) ? "(START)" + : ((bw->type == + BW_END) ? "(END)" : ""))) + ); + return 1; } int badwords_list_callback(User * u, int num, va_list args) { - ChannelInfo *ci = va_arg(args, ChannelInfo *); - int *sent_header = va_arg(args, int *); - if (num < 1 || num > ci->bwcount) - return 0; - return badwords_list(u, num - 1, ci, sent_header); + ChannelInfo *ci = va_arg(args, ChannelInfo *); + int *sent_header = va_arg(args, int *); + if (num < 1 || num > ci->bwcount) + return 0; + return badwords_list(u, num - 1, ci, sent_header); } MODULE_INIT("bs_badwords", BSBadwords) diff --git a/src/core/bs_bot.c b/src/core/bs_bot.c index 69f7e23a7..946dd2d96 100644 --- a/src/core/bs_bot.c +++ b/src/core/bs_bot.c @@ -43,9 +43,9 @@ class BSBot : public Module **/ void myBotServHelp(User * u) { - if (is_services_admin(u)) { - notice_lang(s_BotServ, u, BOT_HELP_CMD_BOT); - } + if (is_services_admin(u)) { + notice_lang(s_BotServ, u, BOT_HELP_CMD_BOT); + } } /** @@ -61,7 +61,7 @@ int do_bot(User * u) if (!cmd) { - syntax_error(s_BotServ, u, "BOT", BOT_BOT_SYNTAX); + syntax_error(s_BotServ, u, "BOT", BOT_BOT_SYNTAX); return MOD_CONT; } diff --git a/src/core/bs_botlist.c b/src/core/bs_botlist.c index 7173a7807..75cbe1a90 100644 --- a/src/core/bs_botlist.c +++ b/src/core/bs_botlist.c @@ -42,7 +42,7 @@ class BSBotList : public Module **/ void myBotServHelp(User * u) { - notice_lang(s_BotServ, u, BOT_HELP_CMD_BOTLIST); + notice_lang(s_BotServ, u, BOT_HELP_CMD_BOTLIST); } /** @@ -52,45 +52,45 @@ void myBotServHelp(User * u) **/ int do_botlist(User * u) { - int i, count = 0; - BotInfo *bi; + int i, count = 0; + BotInfo *bi; - if (!nbots) { - notice_lang(s_BotServ, u, BOT_BOTLIST_EMPTY); - return MOD_CONT; - } + if (!nbots) { + notice_lang(s_BotServ, u, BOT_BOTLIST_EMPTY); + return MOD_CONT; + } - for (i = 0; i < 256; i++) { - for (bi = botlists[i]; bi; bi = bi->next) { - if (!(bi->flags & BI_PRIVATE)) { - if (!count) - notice_lang(s_BotServ, u, BOT_BOTLIST_HEADER); - count++; - notice_user(s_BotServ, u, " %-15s (%s@%s)", bi->nick, - bi->user, bi->host); - } - } - } + for (i = 0; i < 256; i++) { + for (bi = botlists[i]; bi; bi = bi->next) { + if (!(bi->flags & BI_PRIVATE)) { + if (!count) + notice_lang(s_BotServ, u, BOT_BOTLIST_HEADER); + count++; + notice_user(s_BotServ, u, " %-15s (%s@%s)", bi->nick, + bi->user, bi->host); + } + } + } - if (is_oper(u) && count < nbots) { - notice_lang(s_BotServ, u, BOT_BOTLIST_PRIVATE_HEADER); + if (is_oper(u) && count < nbots) { + notice_lang(s_BotServ, u, BOT_BOTLIST_PRIVATE_HEADER); - for (i = 0; i < 256; i++) { - for (bi = botlists[i]; bi; bi = bi->next) { - if (bi->flags & BI_PRIVATE) { - notice_user(s_BotServ, u, " %-15s (%s@%s)", - bi->nick, bi->user, bi->host); - count++; - } - } - } - } + for (i = 0; i < 256; i++) { + for (bi = botlists[i]; bi; bi = bi->next) { + if (bi->flags & BI_PRIVATE) { + notice_user(s_BotServ, u, " %-15s (%s@%s)", + bi->nick, bi->user, bi->host); + count++; + } + } + } + } - if (!count) - notice_lang(s_BotServ, u, BOT_BOTLIST_EMPTY); - else - notice_lang(s_BotServ, u, BOT_BOTLIST_FOOTER, count); - return MOD_CONT; + if (!count) + notice_lang(s_BotServ, u, BOT_BOTLIST_EMPTY); + else + notice_lang(s_BotServ, u, BOT_BOTLIST_FOOTER, count); + return MOD_CONT; } MODULE_INIT("bs_botlist", BSBotList) diff --git a/src/core/bs_fantasy.c b/src/core/bs_fantasy.c index 20e7aaeb7..2885db065 100644 --- a/src/core/bs_fantasy.c +++ b/src/core/bs_fantasy.c @@ -48,40 +48,40 @@ void AnopeFini(void) **/ int do_fantasy(int argc, char **argv) { - User *u; - ChannelInfo *ci; - CSModeUtil *util = csmodeutils; - char *target; + User *u; + ChannelInfo *ci; + CSModeUtil *util = csmodeutils; + char *target; - if (argc < 3) - return MOD_CONT; + if (argc < 3) + return MOD_CONT; - do { - if (stricmp(argv[0], util->bsname) == 0) { - /* This could have been moved to its own module
- however it would require more coding to handle the pass holders
- similar to how PROTECT is done
- */
- if (!ircd->halfop) {
- if (!stricmp(argv[0], "halfop") || !stricmp(argv[0], "dehalfop")) {
- return MOD_CONT;
- }
- } - u = finduser(argv[1]); - ci = cs_findchan(argv[2]); - if (!u || !ci) - return MOD_CONT; + do { + if (stricmp(argv[0], util->bsname) == 0) { + /* This could have been moved to its own module
+ however it would require more coding to handle the pass holders
+ similar to how PROTECT is done
+ */
+ if (!ircd->halfop) {
+ if (!stricmp(argv[0], "halfop") || !stricmp(argv[0], "dehalfop")) {
+ return MOD_CONT;
+ }
+ } + u = finduser(argv[1]); + ci = cs_findchan(argv[2]); + if (!u || !ci) + return MOD_CONT; - target = ((argc == 4) ? argv[3] : NULL); + target = ((argc == 4) ? argv[3] : NULL); - if (!target && check_access(u, ci, util->levelself)) - bot_raw_mode(u, ci, util->mode, u->nick); - else if (target && check_access(u, ci, util->level)) - bot_raw_mode(u, ci, util->mode, target); - } - } while ((++util)->name != NULL); + if (!target && check_access(u, ci, util->levelself)) + bot_raw_mode(u, ci, util->mode, u->nick); + else if (target && check_access(u, ci, util->level)) + bot_raw_mode(u, ci, util->mode, target); + } + } while ((++util)->name != NULL); - return MOD_CONT; + return MOD_CONT; } MODULE_INIT("bs_fantasy", BSFantasy) diff --git a/src/core/bs_fantasy_kick.c b/src/core/bs_fantasy_kick.c index e1e92e161..f5c3018b6 100644 --- a/src/core/bs_fantasy_kick.c +++ b/src/core/bs_fantasy_kick.c @@ -41,47 +41,47 @@ class BSFantasyKick : public Module **/ int do_fantasy(int argc, char **argv) { - User *u, *u2; - ChannelInfo *ci; - char *target = NULL; - char *reason = NULL; + User *u, *u2; + ChannelInfo *ci; + char *target = NULL; + char *reason = NULL; - if (argc < 3) - return MOD_CONT; + if (argc < 3) + return MOD_CONT; - if ((stricmp(argv[0], "kick") == 0) || (stricmp(argv[0], "k") == 0)) { - u = finduser(argv[1]); - ci = cs_findchan(argv[2]); - if (!u || !ci) - return MOD_CONT; + if ((stricmp(argv[0], "kick") == 0) || (stricmp(argv[0], "k") == 0)) { + u = finduser(argv[1]); + ci = cs_findchan(argv[2]); + if (!u || !ci) + return MOD_CONT; - if (argc >= 4) { - target = myStrGetToken(argv[3], ' ', 0); - reason = myStrGetTokenRemainder(argv[3], ' ', 1); - } - if (!target && check_access(u, ci, CA_KICKME)) { - bot_raw_kick(u, ci, u->nick, "Requested"); - } else if (target && check_access(u, ci, CA_KICK)) { - if (!stricmp(target, ci->bi->nick)) - bot_raw_kick(u, ci, u->nick, "Oops!"); - else { - u2 = finduser(target); - if (u2 && ci->c && is_on_chan(ci->c, u2)) { - if (!reason && !is_protected(u2)) - bot_raw_kick(u, ci, target, "Requested"); - else if (!is_protected(u2)) - bot_raw_kick(u, ci, target, reason); - } - } - } - } + if (argc >= 4) { + target = myStrGetToken(argv[3], ' ', 0); + reason = myStrGetTokenRemainder(argv[3], ' ', 1); + } + if (!target && check_access(u, ci, CA_KICKME)) { + bot_raw_kick(u, ci, u->nick, "Requested"); + } else if (target && check_access(u, ci, CA_KICK)) { + if (!stricmp(target, ci->bi->nick)) + bot_raw_kick(u, ci, u->nick, "Oops!"); + else { + u2 = finduser(target); + if (u2 && ci->c && is_on_chan(ci->c, u2)) { + if (!reason && !is_protected(u2)) + bot_raw_kick(u, ci, target, "Requested"); + else if (!is_protected(u2)) + bot_raw_kick(u, ci, target, reason); + } + } + } + } - if (target) - free(target); - if (reason) - free(reason); + if (target) + free(target); + if (reason) + free(reason); - return MOD_CONT; + return MOD_CONT; } MODULE_INIT("bs_fantasy_kick", BSFantasyKick) diff --git a/src/core/bs_fantasy_kickban.c b/src/core/bs_fantasy_kickban.c index b0514ff84..1281d938b 100644 --- a/src/core/bs_fantasy_kickban.c +++ b/src/core/bs_fantasy_kickban.c @@ -42,48 +42,48 @@ class BSFantasyKickBan : public Module **/ int do_fantasy(int argc, char **argv) { - User *u, *u2; - ChannelInfo *ci; - char *target = NULL; - char *reason = NULL; + User *u, *u2; + ChannelInfo *ci; + char *target = NULL; + char *reason = NULL; - if (argc < 3) - return MOD_CONT; + if (argc < 3) + return MOD_CONT; - if ((stricmp(argv[0], "kickban") == 0) - || (stricmp(argv[0], "kb") == 0)) { - u = finduser(argv[1]); - ci = cs_findchan(argv[2]); - if (!u || !ci) - return MOD_CONT; + if ((stricmp(argv[0], "kickban") == 0) + || (stricmp(argv[0], "kb") == 0)) { + u = finduser(argv[1]); + ci = cs_findchan(argv[2]); + if (!u || !ci) + return MOD_CONT; - if (argc >= 4) { - target = myStrGetToken(argv[3], ' ', 0); - reason = myStrGetTokenRemainder(argv[3], ' ', 1); - } - if (!target && check_access(u, ci, CA_BANME)) { - bot_raw_ban(u, ci, u->nick, "Requested"); - } else if (target && check_access(u, ci, CA_BAN)) { - if (stricmp(target, ci->bi->nick) == 0) { - bot_raw_ban(u, ci, u->nick, "Oops!"); - } else { - u2 = finduser(target); - if (u2 && ci->c && is_on_chan(ci->c, u2)) { - if (!reason && !is_protected(u2)) - bot_raw_ban(u, ci, target, "Requested"); - else if (!is_protected(u2)) - bot_raw_ban(u, ci, target, reason); - } - } - } - } + if (argc >= 4) { + target = myStrGetToken(argv[3], ' ', 0); + reason = myStrGetTokenRemainder(argv[3], ' ', 1); + } + if (!target && check_access(u, ci, CA_BANME)) { + bot_raw_ban(u, ci, u->nick, "Requested"); + } else if (target && check_access(u, ci, CA_BAN)) { + if (stricmp(target, ci->bi->nick) == 0) { + bot_raw_ban(u, ci, u->nick, "Oops!"); + } else { + u2 = finduser(target); + if (u2 && ci->c && is_on_chan(ci->c, u2)) { + if (!reason && !is_protected(u2)) + bot_raw_ban(u, ci, target, "Requested"); + else if (!is_protected(u2)) + bot_raw_ban(u, ci, target, reason); + } + } + } + } - if (target) - free(target); - if (reason) - free(reason); + if (target) + free(target); + if (reason) + free(reason); - return MOD_CONT; + return MOD_CONT; } MODULE_INIT("bs_fantasy_kickban", BSFantasyKickBan) diff --git a/src/core/bs_fantasy_owner.c b/src/core/bs_fantasy_owner.c index 3501f6c08..b521baaa9 100644 --- a/src/core/bs_fantasy_owner.c +++ b/src/core/bs_fantasy_owner.c @@ -48,31 +48,31 @@ class BSFantasyOwner : public Module **/ int do_fantasy(int argc, char **argv) { - User *u; - ChannelInfo *ci; + User *u; + ChannelInfo *ci; - if (argc < 3) - return MOD_CONT; + if (argc < 3) + return MOD_CONT; - if (stricmp(argv[0], "deowner") == 0) { - u = finduser(argv[1]); - ci = cs_findchan(argv[2]); - if (!u || !ci) - return MOD_CONT; + if (stricmp(argv[0], "deowner") == 0) { + u = finduser(argv[1]); + ci = cs_findchan(argv[2]); + if (!u || !ci) + return MOD_CONT; - if (is_founder(u, ci)) - bot_raw_mode(u, ci, ircd->ownerunset, u->nick); - } else if (stricmp(argv[0], "owner") == 0) { - u = finduser(argv[1]); - ci = cs_findchan(argv[2]); - if (!u || !ci) - return MOD_CONT; + if (is_founder(u, ci)) + bot_raw_mode(u, ci, ircd->ownerunset, u->nick); + } else if (stricmp(argv[0], "owner") == 0) { + u = finduser(argv[1]); + ci = cs_findchan(argv[2]); + if (!u || !ci) + return MOD_CONT; - if (is_founder(u, ci)) - bot_raw_mode(u, ci, ircd->ownerset, u->nick); - } + if (is_founder(u, ci)) + bot_raw_mode(u, ci, ircd->ownerset, u->nick); + } - return MOD_CONT; + return MOD_CONT; } MODULE_INIT("bs_fantasy_owner", BSFantasyOwner) diff --git a/src/core/bs_fantasy_seen.c b/src/core/bs_fantasy_seen.c index 5173a7695..76e9a0273 100644 --- a/src/core/bs_fantasy_seen.c +++ b/src/core/bs_fantasy_seen.c @@ -49,88 +49,88 @@ void AnopeFini(void) **/ int do_fantasy(int argc, char **argv) { - User *u; - ChannelInfo *ci; - User *u2; - NickAlias *na; - ChanAccess *access; - char buf[BUFSIZE]; - char *target = NULL; + User *u; + ChannelInfo *ci; + User *u2; + NickAlias *na; + ChanAccess *access; + char buf[BUFSIZE]; + char *target = NULL; - if (argc < 4) - return MOD_CONT; + if (argc < 4) + return MOD_CONT; - if (stricmp(argv[0], "seen") == 0) { - u = finduser(argv[1]); - ci = cs_findchan(argv[2]); - if (!u || !ci) - return MOD_CONT; + if (stricmp(argv[0], "seen") == 0) { + u = finduser(argv[1]); + ci = cs_findchan(argv[2]); + if (!u || !ci) + return MOD_CONT; - target = myStrGetToken(argv[3], ' ', 0); + target = myStrGetToken(argv[3], ' ', 0); - if (stricmp(ci->bi->nick, target) == 0) { - /* If we look for the bot */ - snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_BOT), - u->nick); - ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); - } else if (!(na = findnick(target)) || (na->status & NS_VERBOTEN)) { - /* If the nick is not registered or forbidden */ - snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_UNKNOWN), - target); - ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); - } else if ((u2 = nc_on_chan(ci->c, na->nc))) { - /* If the nick we're looking for is on the channel, - * there are three possibilities: it's yourself, - * it's the nick we look for, it's an alias of the - * nick we look for. - */ - if (u == u2 || (u->na && u->na->nc == na->nc)) - snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_YOU), - u->nick); - else if (!stricmp(u2->nick, target)) - snprintf(buf, sizeof(buf), - getstring(u->na, BOT_SEEN_ON_CHANNEL), u2->nick); - else - snprintf(buf, sizeof(buf), - getstring(u->na, BOT_SEEN_ON_CHANNEL_AS), target, - u2->nick); + if (stricmp(ci->bi->nick, target) == 0) { + /* If we look for the bot */ + snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_BOT), + u->nick); + ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); + } else if (!(na = findnick(target)) || (na->status & NS_VERBOTEN)) { + /* If the nick is not registered or forbidden */ + snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_UNKNOWN), + target); + ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); + } else if ((u2 = nc_on_chan(ci->c, na->nc))) { + /* If the nick we're looking for is on the channel, + * there are three possibilities: it's yourself, + * it's the nick we look for, it's an alias of the + * nick we look for. + */ + if (u == u2 || (u->na && u->na->nc == na->nc)) + snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_YOU), + u->nick); + else if (!stricmp(u2->nick, target)) + snprintf(buf, sizeof(buf), + getstring(u->na, BOT_SEEN_ON_CHANNEL), u2->nick); + else + snprintf(buf, sizeof(buf), + getstring(u->na, BOT_SEEN_ON_CHANNEL_AS), target, + u2->nick); - ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); - } else if ((access = get_access_entry(na->nc, ci))) { - /* User is on the access list but not present actually. - Special case: if access->last_seen is 0 it's that we - never seen the user. - */ - if (access->last_seen) { - char durastr[192]; - duration(u->na, durastr, sizeof(durastr), - time(NULL) - access->last_seen); - snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_ON), - target, durastr); - } else { - snprintf(buf, sizeof(buf), - getstring(u->na, BOT_SEEN_NEVER), target); - } - ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); - } else if (na->nc == ci->founder) { - /* User is the founder of the channel */ - char durastr[192]; - duration(u->na, durastr, sizeof(durastr), - time(NULL) - na->last_seen); - snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_ON), - target, durastr); - ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); - } else { - /* All other cases */ - snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_UNKNOWN), - target); - ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); - } - /* free myStrGetToken(ed) variable target (#851) */ - Anope_Free(target); - } + ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); + } else if ((access = get_access_entry(na->nc, ci))) { + /* User is on the access list but not present actually. + Special case: if access->last_seen is 0 it's that we + never seen the user. + */ + if (access->last_seen) { + char durastr[192]; + duration(u->na, durastr, sizeof(durastr), + time(NULL) - access->last_seen); + snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_ON), + target, durastr); + } else { + snprintf(buf, sizeof(buf), + getstring(u->na, BOT_SEEN_NEVER), target); + } + ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); + } else if (na->nc == ci->founder) { + /* User is the founder of the channel */ + char durastr[192]; + duration(u->na, durastr, sizeof(durastr), + time(NULL) - na->last_seen); + snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_ON), + target, durastr); + ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); + } else { + /* All other cases */ + snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_UNKNOWN), + target); + ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", buf); + } + /* free myStrGetToken(ed) variable target (#851) */ + Anope_Free(target); + } - return MOD_CONT; + return MOD_CONT; } MODULE_INIT("bs_fantasy_seen", BSFantasySeen) diff --git a/src/core/bs_help.c b/src/core/bs_help.c index 3c807275c..d838f9d85 100644 --- a/src/core/bs_help.c +++ b/src/core/bs_help.c @@ -40,16 +40,16 @@ class BSHelp : public Module **/ int do_help(User * u) { - char *cmd = strtok(NULL, ""); - - if (!cmd) { - notice_help(s_BotServ, u, BOT_HELP); - moduleDisplayHelp(4, u); - notice_help(s_BotServ, u, BOT_HELP_FOOTER, BSMinUsers); - } else { - mod_help_cmd(s_BotServ, u, BOTSERV, cmd); - } - return MOD_CONT; + char *cmd = strtok(NULL, ""); + + if (!cmd) { + notice_help(s_BotServ, u, BOT_HELP); + moduleDisplayHelp(4, u); + notice_help(s_BotServ, u, BOT_HELP_FOOTER, BSMinUsers); + } else { + mod_help_cmd(s_BotServ, u, BOTSERV, cmd); + } + return MOD_CONT; } MODULE_INIT("bs_help", BSHelp) diff --git a/src/core/bs_info.c b/src/core/bs_info.c index ce802db3c..d3590f624 100644 --- a/src/core/bs_info.c +++ b/src/core/bs_info.c @@ -43,7 +43,7 @@ class BSInfo : public Module **/ void myBotServHelp(User * u) { - notice_lang(s_BotServ, u, BOT_HELP_CMD_INFO); + notice_lang(s_BotServ, u, BOT_HELP_CMD_INFO); } /** @@ -53,217 +53,217 @@ void myBotServHelp(User * u) **/ int do_info(User * u) { - BotInfo *bi; - ChannelInfo *ci; - char *query = strtok(NULL, " "); + BotInfo *bi; + ChannelInfo *ci; + char *query = strtok(NULL, " "); - int need_comma = 0, is_servadmin = is_services_admin(u); - char buf[BUFSIZE], *end; - const char *commastr = getstring(u->na, COMMA_SPACE); + int need_comma = 0, is_servadmin = is_services_admin(u); + char buf[BUFSIZE], *end; + const char *commastr = getstring(u->na, COMMA_SPACE); - if (!query) - syntax_error(s_BotServ, u, "INFO", BOT_INFO_SYNTAX); - else if ((bi = findbot(query))) { - struct tm *tm; + if (!query) + syntax_error(s_BotServ, u, "INFO", BOT_INFO_SYNTAX); + else if ((bi = findbot(query))) { + struct tm *tm; - notice_lang(s_BotServ, u, BOT_INFO_BOT_HEADER, bi->nick); - notice_lang(s_BotServ, u, BOT_INFO_BOT_MASK, bi->user, bi->host); - notice_lang(s_BotServ, u, BOT_INFO_BOT_REALNAME, bi->real); - tm = localtime(&bi->created); - strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm); - notice_lang(s_BotServ, u, BOT_INFO_BOT_CREATED, buf); - notice_lang(s_BotServ, u, BOT_INFO_BOT_OPTIONS, - getstring(u->na, - (bi-> - flags & BI_PRIVATE) ? BOT_INFO_OPT_PRIVATE : - BOT_INFO_OPT_NONE)); - notice_lang(s_BotServ, u, BOT_INFO_BOT_USAGE, bi->chancount); + notice_lang(s_BotServ, u, BOT_INFO_BOT_HEADER, bi->nick); + notice_lang(s_BotServ, u, BOT_INFO_BOT_MASK, bi->user, bi->host); + notice_lang(s_BotServ, u, BOT_INFO_BOT_REALNAME, bi->real); + tm = localtime(&bi->created); + strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm); + notice_lang(s_BotServ, u, BOT_INFO_BOT_CREATED, buf); + notice_lang(s_BotServ, u, BOT_INFO_BOT_OPTIONS, + getstring(u->na, + (bi-> + flags & BI_PRIVATE) ? BOT_INFO_OPT_PRIVATE : + BOT_INFO_OPT_NONE)); + notice_lang(s_BotServ, u, BOT_INFO_BOT_USAGE, bi->chancount); - if (is_services_admin(u)) - send_bot_channels(u, bi); - } else if ((ci = cs_findchan(query))) { - if (!is_servadmin && !is_founder(u, ci)) { - notice_lang(s_BotServ, u, PERMISSION_DENIED); - return MOD_CONT; - } - if (ci->flags & CI_VERBOTEN) { - notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, query); - return MOD_CONT; - } + if (is_services_admin(u)) + send_bot_channels(u, bi); + } else if ((ci = cs_findchan(query))) { + if (!is_servadmin && !is_founder(u, ci)) { + notice_lang(s_BotServ, u, PERMISSION_DENIED); + return MOD_CONT; + } + if (ci->flags & CI_VERBOTEN) { + notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, query); + return MOD_CONT; + } - notice_lang(s_BotServ, u, BOT_INFO_CHAN_HEADER, ci->name); - if (ci->bi) - notice_lang(s_BotServ, u, BOT_INFO_CHAN_BOT, ci->bi->nick); - else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_BOT_NONE); + notice_lang(s_BotServ, u, BOT_INFO_CHAN_HEADER, ci->name); + if (ci->bi) + notice_lang(s_BotServ, u, BOT_INFO_CHAN_BOT, ci->bi->nick); + else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_BOT_NONE); - if (ci->botflags & BS_KICK_BADWORDS) { - if (ci->ttb[TTB_BADWORDS]) - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS_BAN, - getstring(u->na, BOT_INFO_ACTIVE), - ci->ttb[TTB_BADWORDS]); - else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS, - getstring(u->na, BOT_INFO_ACTIVE)); - } else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS, - getstring(u->na, BOT_INFO_INACTIVE)); - if (ci->botflags & BS_KICK_BOLDS) { - if (ci->ttb[TTB_BOLDS]) - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS_BAN, - getstring(u->na, BOT_INFO_ACTIVE), - ci->ttb[TTB_BOLDS]); - else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS, - getstring(u->na, BOT_INFO_ACTIVE)); - } else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS, - getstring(u->na, BOT_INFO_INACTIVE)); - if (ci->botflags & BS_KICK_CAPS) { - if (ci->ttb[TTB_CAPS]) - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_BAN, - getstring(u->na, BOT_INFO_ACTIVE), - ci->ttb[TTB_CAPS], ci->capsmin, - ci->capspercent); - else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_ON, - getstring(u->na, BOT_INFO_ACTIVE), ci->capsmin, - ci->capspercent); - } else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_OFF, - getstring(u->na, BOT_INFO_INACTIVE)); - if (ci->botflags & BS_KICK_COLORS) { - if (ci->ttb[TTB_COLORS]) - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS_BAN, - getstring(u->na, BOT_INFO_ACTIVE), - ci->ttb[TTB_COLORS]); - else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS, - getstring(u->na, BOT_INFO_ACTIVE)); - } else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS, - getstring(u->na, BOT_INFO_INACTIVE)); - if (ci->botflags & BS_KICK_FLOOD) { - if (ci->ttb[TTB_FLOOD]) - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_BAN, - getstring(u->na, BOT_INFO_ACTIVE), - ci->ttb[TTB_FLOOD], ci->floodlines, - ci->floodsecs); - else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_ON, - getstring(u->na, BOT_INFO_ACTIVE), - ci->floodlines, ci->floodsecs); - } else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_OFF, - getstring(u->na, BOT_INFO_INACTIVE)); - if (ci->botflags & BS_KICK_REPEAT) { - if (ci->ttb[TTB_REPEAT]) - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_BAN, - getstring(u->na, BOT_INFO_ACTIVE), - ci->ttb[TTB_REPEAT], ci->repeattimes); - else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_ON, - getstring(u->na, BOT_INFO_ACTIVE), - ci->repeattimes); - } else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_OFF, - getstring(u->na, BOT_INFO_INACTIVE)); - if (ci->botflags & BS_KICK_REVERSES) { - if (ci->ttb[TTB_REVERSES]) - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES_BAN, - getstring(u->na, BOT_INFO_ACTIVE), - ci->ttb[TTB_REVERSES]); - else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES, - getstring(u->na, BOT_INFO_ACTIVE)); - } else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES, - getstring(u->na, BOT_INFO_INACTIVE)); - if (ci->botflags & BS_KICK_UNDERLINES) { - if (ci->ttb[TTB_UNDERLINES]) - notice_lang(s_BotServ, u, - BOT_INFO_CHAN_KICK_UNDERLINES_BAN, - getstring(u->na, BOT_INFO_ACTIVE), - ci->ttb[TTB_UNDERLINES]); - else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES, - getstring(u->na, BOT_INFO_ACTIVE)); - } else - notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES, - getstring(u->na, BOT_INFO_INACTIVE)); + if (ci->botflags & BS_KICK_BADWORDS) { + if (ci->ttb[TTB_BADWORDS]) + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS_BAN, + getstring(u->na, BOT_INFO_ACTIVE), + ci->ttb[TTB_BADWORDS]); + else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS, + getstring(u->na, BOT_INFO_ACTIVE)); + } else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS, + getstring(u->na, BOT_INFO_INACTIVE)); + if (ci->botflags & BS_KICK_BOLDS) { + if (ci->ttb[TTB_BOLDS]) + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS_BAN, + getstring(u->na, BOT_INFO_ACTIVE), + ci->ttb[TTB_BOLDS]); + else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS, + getstring(u->na, BOT_INFO_ACTIVE)); + } else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS, + getstring(u->na, BOT_INFO_INACTIVE)); + if (ci->botflags & BS_KICK_CAPS) { + if (ci->ttb[TTB_CAPS]) + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_BAN, + getstring(u->na, BOT_INFO_ACTIVE), + ci->ttb[TTB_CAPS], ci->capsmin, + ci->capspercent); + else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_ON, + getstring(u->na, BOT_INFO_ACTIVE), ci->capsmin, + ci->capspercent); + } else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_OFF, + getstring(u->na, BOT_INFO_INACTIVE)); + if (ci->botflags & BS_KICK_COLORS) { + if (ci->ttb[TTB_COLORS]) + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS_BAN, + getstring(u->na, BOT_INFO_ACTIVE), + ci->ttb[TTB_COLORS]); + else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS, + getstring(u->na, BOT_INFO_ACTIVE)); + } else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS, + getstring(u->na, BOT_INFO_INACTIVE)); + if (ci->botflags & BS_KICK_FLOOD) { + if (ci->ttb[TTB_FLOOD]) + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_BAN, + getstring(u->na, BOT_INFO_ACTIVE), + ci->ttb[TTB_FLOOD], ci->floodlines, + ci->floodsecs); + else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_ON, + getstring(u->na, BOT_INFO_ACTIVE), + ci->floodlines, ci->floodsecs); + } else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_OFF, + getstring(u->na, BOT_INFO_INACTIVE)); + if (ci->botflags & BS_KICK_REPEAT) { + if (ci->ttb[TTB_REPEAT]) + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_BAN, + getstring(u->na, BOT_INFO_ACTIVE), + ci->ttb[TTB_REPEAT], ci->repeattimes); + else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_ON, + getstring(u->na, BOT_INFO_ACTIVE), + ci->repeattimes); + } else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_OFF, + getstring(u->na, BOT_INFO_INACTIVE)); + if (ci->botflags & BS_KICK_REVERSES) { + if (ci->ttb[TTB_REVERSES]) + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES_BAN, + getstring(u->na, BOT_INFO_ACTIVE), + ci->ttb[TTB_REVERSES]); + else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES, + getstring(u->na, BOT_INFO_ACTIVE)); + } else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES, + getstring(u->na, BOT_INFO_INACTIVE)); + if (ci->botflags & BS_KICK_UNDERLINES) { + if (ci->ttb[TTB_UNDERLINES]) + notice_lang(s_BotServ, u, + BOT_INFO_CHAN_KICK_UNDERLINES_BAN, + getstring(u->na, BOT_INFO_ACTIVE), + ci->ttb[TTB_UNDERLINES]); + else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES, + getstring(u->na, BOT_INFO_ACTIVE)); + } else + notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES, + getstring(u->na, BOT_INFO_INACTIVE)); - end = buf; - *end = 0; - if (ci->botflags & BS_DONTKICKOPS) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s", - getstring(u->na, BOT_INFO_OPT_DONTKICKOPS)); - need_comma = 1; - } - if (ci->botflags & BS_DONTKICKVOICES) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, BOT_INFO_OPT_DONTKICKVOICES)); - need_comma = 1; - } - if (ci->botflags & BS_FANTASY) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, BOT_INFO_OPT_FANTASY)); - need_comma = 1; - } - if (ci->botflags & BS_GREET) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, BOT_INFO_OPT_GREET)); - need_comma = 1; - } - if (ci->botflags & BS_NOBOT) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, BOT_INFO_OPT_NOBOT)); - need_comma = 1; - } - if (ci->botflags & BS_SYMBIOSIS) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, BOT_INFO_OPT_SYMBIOSIS)); - need_comma = 1; - } - notice_lang(s_BotServ, u, BOT_INFO_CHAN_OPTIONS, - *buf ? buf : getstring(u->na, BOT_INFO_OPT_NONE)); + end = buf; + *end = 0; + if (ci->botflags & BS_DONTKICKOPS) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s", + getstring(u->na, BOT_INFO_OPT_DONTKICKOPS)); + need_comma = 1; + } + if (ci->botflags & BS_DONTKICKVOICES) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, BOT_INFO_OPT_DONTKICKVOICES)); + need_comma = 1; + } + if (ci->botflags & BS_FANTASY) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, BOT_INFO_OPT_FANTASY)); + need_comma = 1; + } + if (ci->botflags & BS_GREET) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, BOT_INFO_OPT_GREET)); + need_comma = 1; + } + if (ci->botflags & BS_NOBOT) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, BOT_INFO_OPT_NOBOT)); + need_comma = 1; + } + if (ci->botflags & BS_SYMBIOSIS) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, BOT_INFO_OPT_SYMBIOSIS)); + need_comma = 1; + } + notice_lang(s_BotServ, u, BOT_INFO_CHAN_OPTIONS, + *buf ? buf : getstring(u->na, BOT_INFO_OPT_NONE)); - } else - notice_lang(s_BotServ, u, BOT_INFO_NOT_FOUND, query); - return MOD_CONT; + } else + notice_lang(s_BotServ, u, BOT_INFO_NOT_FOUND, query); + return MOD_CONT; } void send_bot_channels(User * u, BotInfo * bi) { - int i; - ChannelInfo *ci; - char buf[307], *end; + int i; + ChannelInfo *ci; + char buf[307], *end; - *buf = 0; - end = buf; + *buf = 0; + end = buf; - for (i = 0; i < 256; i++) { - for (ci = chanlists[i]; ci; ci = ci->next) { - if (ci->bi == bi) { - if (strlen(buf) + strlen(ci->name) > 300) { - notice_user(s_BotServ, u, "%s", buf); - *buf = 0; - end = buf; - } - end += - snprintf(end, sizeof(buf) - (end - buf), " %s ", - ci->name); - } - } - } + for (i = 0; i < 256; i++) { + for (ci = chanlists[i]; ci; ci = ci->next) { + if (ci->bi == bi) { + if (strlen(buf) + strlen(ci->name) > 300) { + notice_user(s_BotServ, u, "%s", buf); + *buf = 0; + end = buf; + } + end += + snprintf(end, sizeof(buf) - (end - buf), " %s ", + ci->name); + } + } + } - if (*buf) - notice_user(s_BotServ, u, "%s", buf); - return; + if (*buf) + notice_user(s_BotServ, u, "%s", buf); + return; } MODULE_INIT("bs_info", BSInfo) diff --git a/src/core/bs_kick.c b/src/core/bs_kick.c index fb48c9413..229b4dba2 100644 --- a/src/core/bs_kick.c +++ b/src/core/bs_kick.c @@ -59,7 +59,7 @@ class BSKick : public Module **/ void myBotServHelp(User * u) { - notice_lang(s_BotServ, u, BOT_HELP_CMD_KICK); + notice_lang(s_BotServ, u, BOT_HELP_CMD_KICK); } /** @@ -69,290 +69,290 @@ void myBotServHelp(User * u) **/ int do_kickcmd(User * u) { - char *chan = strtok(NULL, " "); - char *option = strtok(NULL, " "); - char *value = strtok(NULL, " "); - char *ttb = strtok(NULL, " "); + char *chan = strtok(NULL, " "); + char *option = strtok(NULL, " "); + char *value = strtok(NULL, " "); + char *ttb = strtok(NULL, " "); - ChannelInfo *ci; + ChannelInfo *ci; - if (readonly) - notice_lang(s_BotServ, u, BOT_KICK_DISABLED); - else if (!chan || !option || !value) - syntax_error(s_BotServ, u, "KICK", BOT_KICK_SYNTAX); - else if (stricmp(value, "ON") && stricmp(value, "OFF")) - syntax_error(s_BotServ, u, "KICK", BOT_KICK_SYNTAX); - else if (!(ci = cs_findchan(chan))) - notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); - else if (ci->flags & CI_VERBOTEN) - notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); - else if (!is_services_admin(u) && !check_access(u, ci, CA_SET)) - notice_lang(s_BotServ, u, ACCESS_DENIED); - else if (!ci->bi) - notice_help(s_BotServ, u, BOT_NOT_ASSIGNED); - else { - if (!stricmp(option, "BADWORDS")) { - if (!stricmp(value, "ON")) { - if (ttb) { - ci->ttb[TTB_BADWORDS] = - strtol(ttb, (char **) NULL, 10); - /* Only error if errno returns ERANGE or EINVAL or we are less then 0 - TSL */ - if (errno == ERANGE || errno == EINVAL - || ci->ttb[TTB_BADWORDS] < 0) { - /* leaving the debug behind since we might want to know what these are */ - if (debug) { - alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_BADWORDS]); - } - /* reset the value back to 0 - TSL */ - ci->ttb[TTB_BADWORDS] = 0; - notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb); - return MOD_CONT; - } - } else { - ci->ttb[TTB_BADWORDS] = 0; - } - ci->botflags |= BS_KICK_BADWORDS; - if (ci->ttb[TTB_BADWORDS]) - notice_lang(s_BotServ, u, BOT_KICK_BADWORDS_ON_BAN, - ci->ttb[TTB_BADWORDS]); - else - notice_lang(s_BotServ, u, BOT_KICK_BADWORDS_ON); - } else { - ci->botflags &= ~BS_KICK_BADWORDS; - notice_lang(s_BotServ, u, BOT_KICK_BADWORDS_OFF); - } - } else if (!stricmp(option, "BOLDS")) { - if (!stricmp(value, "ON")) { - if (ttb) { - ci->ttb[TTB_BOLDS] = strtol(ttb, (char **) NULL, 10); - if (errno == ERANGE || errno == EINVAL - || ci->ttb[TTB_BOLDS] < 0) { - if (debug) { - alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_BOLDS]); - } - ci->ttb[TTB_BOLDS] = 0; - notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb); - return MOD_CONT; - } - } else - ci->ttb[TTB_BOLDS] = 0; - ci->botflags |= BS_KICK_BOLDS; - if (ci->ttb[TTB_BOLDS]) - notice_lang(s_BotServ, u, BOT_KICK_BOLDS_ON_BAN, - ci->ttb[TTB_BOLDS]); - else - notice_lang(s_BotServ, u, BOT_KICK_BOLDS_ON); - } else { - ci->botflags &= ~BS_KICK_BOLDS; - notice_lang(s_BotServ, u, BOT_KICK_BOLDS_OFF); - } - } else if (!stricmp(option, "CAPS")) { - if (!stricmp(value, "ON")) { - char *min = strtok(NULL, " "); - char *percent = strtok(NULL, " "); + if (readonly) + notice_lang(s_BotServ, u, BOT_KICK_DISABLED); + else if (!chan || !option || !value) + syntax_error(s_BotServ, u, "KICK", BOT_KICK_SYNTAX); + else if (stricmp(value, "ON") && stricmp(value, "OFF")) + syntax_error(s_BotServ, u, "KICK", BOT_KICK_SYNTAX); + else if (!(ci = cs_findchan(chan))) + notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); + else if (ci->flags & CI_VERBOTEN) + notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); + else if (!is_services_admin(u) && !check_access(u, ci, CA_SET)) + notice_lang(s_BotServ, u, ACCESS_DENIED); + else if (!ci->bi) + notice_help(s_BotServ, u, BOT_NOT_ASSIGNED); + else { + if (!stricmp(option, "BADWORDS")) { + if (!stricmp(value, "ON")) { + if (ttb) { + ci->ttb[TTB_BADWORDS] = + strtol(ttb, (char **) NULL, 10); + /* Only error if errno returns ERANGE or EINVAL or we are less then 0 - TSL */ + if (errno == ERANGE || errno == EINVAL + || ci->ttb[TTB_BADWORDS] < 0) { + /* leaving the debug behind since we might want to know what these are */ + if (debug) { + alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_BADWORDS]); + } + /* reset the value back to 0 - TSL */ + ci->ttb[TTB_BADWORDS] = 0; + notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb); + return MOD_CONT; + } + } else { + ci->ttb[TTB_BADWORDS] = 0; + } + ci->botflags |= BS_KICK_BADWORDS; + if (ci->ttb[TTB_BADWORDS]) + notice_lang(s_BotServ, u, BOT_KICK_BADWORDS_ON_BAN, + ci->ttb[TTB_BADWORDS]); + else + notice_lang(s_BotServ, u, BOT_KICK_BADWORDS_ON); + } else { + ci->botflags &= ~BS_KICK_BADWORDS; + notice_lang(s_BotServ, u, BOT_KICK_BADWORDS_OFF); + } + } else if (!stricmp(option, "BOLDS")) { + if (!stricmp(value, "ON")) { + if (ttb) { + ci->ttb[TTB_BOLDS] = strtol(ttb, (char **) NULL, 10); + if (errno == ERANGE || errno == EINVAL + || ci->ttb[TTB_BOLDS] < 0) { + if (debug) { + alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_BOLDS]); + } + ci->ttb[TTB_BOLDS] = 0; + notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb); + return MOD_CONT; + } + } else + ci->ttb[TTB_BOLDS] = 0; + ci->botflags |= BS_KICK_BOLDS; + if (ci->ttb[TTB_BOLDS]) + notice_lang(s_BotServ, u, BOT_KICK_BOLDS_ON_BAN, + ci->ttb[TTB_BOLDS]); + else + notice_lang(s_BotServ, u, BOT_KICK_BOLDS_ON); + } else { + ci->botflags &= ~BS_KICK_BOLDS; + notice_lang(s_BotServ, u, BOT_KICK_BOLDS_OFF); + } + } else if (!stricmp(option, "CAPS")) { + if (!stricmp(value, "ON")) { + char *min = strtok(NULL, " "); + char *percent = strtok(NULL, " "); - if (ttb) { - ci->ttb[TTB_CAPS] = strtol(ttb, (char **) NULL, 10); - if (errno == ERANGE || errno == EINVAL - || ci->ttb[TTB_CAPS] < 0) { - if (debug) { - alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_CAPS]); - } - ci->ttb[TTB_CAPS] = 0; - notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb); - return MOD_CONT; - } - } else - ci->ttb[TTB_CAPS] = 0; + if (ttb) { + ci->ttb[TTB_CAPS] = strtol(ttb, (char **) NULL, 10); + if (errno == ERANGE || errno == EINVAL + || ci->ttb[TTB_CAPS] < 0) { + if (debug) { + alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_CAPS]); + } + ci->ttb[TTB_CAPS] = 0; + notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb); + return MOD_CONT; + } + } else + ci->ttb[TTB_CAPS] = 0; - if (!min) - ci->capsmin = 10; - else - ci->capsmin = atol(min); - if (ci->capsmin < 1) - ci->capsmin = 10; + if (!min) + ci->capsmin = 10; + else + ci->capsmin = atol(min); + if (ci->capsmin < 1) + ci->capsmin = 10; - if (!percent) - ci->capspercent = 25; - else - ci->capspercent = atol(percent); - if (ci->capspercent < 1 || ci->capspercent > 100) - ci->capspercent = 25; + if (!percent) + ci->capspercent = 25; + else + ci->capspercent = atol(percent); + if (ci->capspercent < 1 || ci->capspercent > 100) + ci->capspercent = 25; - ci->botflags |= BS_KICK_CAPS; - if (ci->ttb[TTB_CAPS]) - notice_lang(s_BotServ, u, BOT_KICK_CAPS_ON_BAN, - ci->capsmin, ci->capspercent, - ci->ttb[TTB_CAPS]); - else - notice_lang(s_BotServ, u, BOT_KICK_CAPS_ON, - ci->capsmin, ci->capspercent); - } else { - ci->botflags &= ~BS_KICK_CAPS; - notice_lang(s_BotServ, u, BOT_KICK_CAPS_OFF); - } - } else if (!stricmp(option, "COLORS")) { - if (!stricmp(value, "ON")) { - if (ttb) { - ci->ttb[TTB_COLORS] = strtol(ttb, (char **) NULL, 10); - if (errno == ERANGE || errno == EINVAL - || ci->ttb[TTB_COLORS] < 0) { - if (debug) { - alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_COLORS]); - } - ci->ttb[TTB_COLORS] = 0; - notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb); - return MOD_CONT; - } - } else - ci->ttb[TTB_COLORS] = 0; - ci->botflags |= BS_KICK_COLORS; - if (ci->ttb[TTB_COLORS]) - notice_lang(s_BotServ, u, BOT_KICK_COLORS_ON_BAN, - ci->ttb[TTB_COLORS]); - else - notice_lang(s_BotServ, u, BOT_KICK_COLORS_ON); - } else { - ci->botflags &= ~BS_KICK_COLORS; - notice_lang(s_BotServ, u, BOT_KICK_COLORS_OFF); - } - } else if (!stricmp(option, "FLOOD")) { - if (!stricmp(value, "ON")) { - char *lines = strtok(NULL, " "); - char *secs = strtok(NULL, " "); + ci->botflags |= BS_KICK_CAPS; + if (ci->ttb[TTB_CAPS]) + notice_lang(s_BotServ, u, BOT_KICK_CAPS_ON_BAN, + ci->capsmin, ci->capspercent, + ci->ttb[TTB_CAPS]); + else + notice_lang(s_BotServ, u, BOT_KICK_CAPS_ON, + ci->capsmin, ci->capspercent); + } else { + ci->botflags &= ~BS_KICK_CAPS; + notice_lang(s_BotServ, u, BOT_KICK_CAPS_OFF); + } + } else if (!stricmp(option, "COLORS")) { + if (!stricmp(value, "ON")) { + if (ttb) { + ci->ttb[TTB_COLORS] = strtol(ttb, (char **) NULL, 10); + if (errno == ERANGE || errno == EINVAL + || ci->ttb[TTB_COLORS] < 0) { + if (debug) { + alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_COLORS]); + } + ci->ttb[TTB_COLORS] = 0; + notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb); + return MOD_CONT; + } + } else + ci->ttb[TTB_COLORS] = 0; + ci->botflags |= BS_KICK_COLORS; + if (ci->ttb[TTB_COLORS]) + notice_lang(s_BotServ, u, BOT_KICK_COLORS_ON_BAN, + ci->ttb[TTB_COLORS]); + else + notice_lang(s_BotServ, u, BOT_KICK_COLORS_ON); + } else { + ci->botflags &= ~BS_KICK_COLORS; + notice_lang(s_BotServ, u, BOT_KICK_COLORS_OFF); + } + } else if (!stricmp(option, "FLOOD")) { + if (!stricmp(value, "ON")) { + char *lines = strtok(NULL, " "); + char *secs = strtok(NULL, " "); - if (ttb) { - ci->ttb[TTB_FLOOD] = strtol(ttb, (char **) NULL, 10); - if (errno == ERANGE || errno == EINVAL - || ci->ttb[TTB_FLOOD] < 0) { - if (debug) { - alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_FLOOD]); - } - ci->ttb[TTB_FLOOD] = 0; - notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb); - return MOD_CONT; - } - } else - ci->ttb[TTB_FLOOD] = 0; + if (ttb) { + ci->ttb[TTB_FLOOD] = strtol(ttb, (char **) NULL, 10); + if (errno == ERANGE || errno == EINVAL + || ci->ttb[TTB_FLOOD] < 0) { + if (debug) { + alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_FLOOD]); + } + ci->ttb[TTB_FLOOD] = 0; + notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb); + return MOD_CONT; + } + } else + ci->ttb[TTB_FLOOD] = 0; - if (!lines) - ci->floodlines = 6; - else - ci->floodlines = atol(lines); - if (ci->floodlines < 2) - ci->floodlines = 6; + if (!lines) + ci->floodlines = 6; + else + ci->floodlines = atol(lines); + if (ci->floodlines < 2) + ci->floodlines = 6; - if (!secs) - ci->floodsecs = 10; - else - ci->floodsecs = atol(secs); - if (ci->floodsecs < 1 || ci->floodsecs > BSKeepData) - ci->floodsecs = 10; + if (!secs) + ci->floodsecs = 10; + else + ci->floodsecs = atol(secs); + if (ci->floodsecs < 1 || ci->floodsecs > BSKeepData) + ci->floodsecs = 10; - ci->botflags |= BS_KICK_FLOOD; - if (ci->ttb[TTB_FLOOD]) - notice_lang(s_BotServ, u, BOT_KICK_FLOOD_ON_BAN, - ci->floodlines, ci->floodsecs, - ci->ttb[TTB_FLOOD]); - else - notice_lang(s_BotServ, u, BOT_KICK_FLOOD_ON, - ci->floodlines, ci->floodsecs); - } else { - ci->botflags &= ~BS_KICK_FLOOD; - notice_lang(s_BotServ, u, BOT_KICK_FLOOD_OFF); - } - } else if (!stricmp(option, "REPEAT")) { - if (!stricmp(value, "ON")) { - char *times = strtok(NULL, " "); + ci->botflags |= BS_KICK_FLOOD; + if (ci->ttb[TTB_FLOOD]) + notice_lang(s_BotServ, u, BOT_KICK_FLOOD_ON_BAN, + ci->floodlines, ci->floodsecs, + ci->ttb[TTB_FLOOD]); + else + notice_lang(s_BotServ, u, BOT_KICK_FLOOD_ON, + ci->floodlines, ci->floodsecs); + } else { + ci->botflags &= ~BS_KICK_FLOOD; + notice_lang(s_BotServ, u, BOT_KICK_FLOOD_OFF); + } + } else if (!stricmp(option, "REPEAT")) { + if (!stricmp(value, "ON")) { + char *times = strtok(NULL, " "); - if (ttb) { - ci->ttb[TTB_REPEAT] = strtol(ttb, (char **) NULL, 10); - if (errno == ERANGE || errno == EINVAL - || ci->ttb[TTB_REPEAT] < 0) { - if (debug) { - alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_REPEAT]); - } - ci->ttb[TTB_REPEAT] = 0; - notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb); - return MOD_CONT; - } - } else - ci->ttb[TTB_REPEAT] = 0; + if (ttb) { + ci->ttb[TTB_REPEAT] = strtol(ttb, (char **) NULL, 10); + if (errno == ERANGE || errno == EINVAL + || ci->ttb[TTB_REPEAT] < 0) { + if (debug) { + alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_REPEAT]); + } + ci->ttb[TTB_REPEAT] = 0; + notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb); + return MOD_CONT; + } + } else + ci->ttb[TTB_REPEAT] = 0; - if (!times) - ci->repeattimes = 3; - else - ci->repeattimes = atol(times); - if (ci->repeattimes < 2) - ci->repeattimes = 3; + if (!times) + ci->repeattimes = 3; + else + ci->repeattimes = atol(times); + if (ci->repeattimes < 2) + ci->repeattimes = 3; - ci->botflags |= BS_KICK_REPEAT; - if (ci->ttb[TTB_REPEAT]) - notice_lang(s_BotServ, u, BOT_KICK_REPEAT_ON_BAN, - ci->repeattimes, ci->ttb[TTB_REPEAT]); - else - notice_lang(s_BotServ, u, BOT_KICK_REPEAT_ON, - ci->repeattimes); - } else { - ci->botflags &= ~BS_KICK_REPEAT; - notice_lang(s_BotServ, u, BOT_KICK_REPEAT_OFF); - } - } else if (!stricmp(option, "REVERSES")) { - if (!stricmp(value, "ON")) { - if (ttb) { - ci->ttb[TTB_REVERSES] = - strtol(ttb, (char **) NULL, 10); - if (errno == ERANGE || errno == EINVAL - || ci->ttb[TTB_REVERSES] < 0) { - if (debug) { - alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_REVERSES]); - } - ci->ttb[TTB_REVERSES] = 0; - notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb); - return MOD_CONT; - } - } else - ci->ttb[TTB_REVERSES] = 0; - ci->botflags |= BS_KICK_REVERSES; - if (ci->ttb[TTB_REVERSES]) - notice_lang(s_BotServ, u, BOT_KICK_REVERSES_ON_BAN, - ci->ttb[TTB_REVERSES]); - else - notice_lang(s_BotServ, u, BOT_KICK_REVERSES_ON); - } else { - ci->botflags &= ~BS_KICK_REVERSES; - notice_lang(s_BotServ, u, BOT_KICK_REVERSES_OFF); - } - } else if (!stricmp(option, "UNDERLINES")) { - if (!stricmp(value, "ON")) { - if (ttb) { - ci->ttb[TTB_UNDERLINES] = - strtol(ttb, (char **) NULL, 10); - if (errno == ERANGE || errno == EINVAL - || ci->ttb[TTB_UNDERLINES] < 0) { - if (debug) { - alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_UNDERLINES]); - } - ci->ttb[TTB_UNDERLINES] = 0; - notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb); - return MOD_CONT; - } - } else - ci->ttb[TTB_UNDERLINES] = 0; - ci->botflags |= BS_KICK_UNDERLINES; - if (ci->ttb[TTB_UNDERLINES]) - notice_lang(s_BotServ, u, BOT_KICK_UNDERLINES_ON_BAN, - ci->ttb[TTB_UNDERLINES]); - else - notice_lang(s_BotServ, u, BOT_KICK_UNDERLINES_ON); - } else { - ci->botflags &= ~BS_KICK_UNDERLINES; - notice_lang(s_BotServ, u, BOT_KICK_UNDERLINES_OFF); - } - } else - notice_help(s_BotServ, u, BOT_KICK_UNKNOWN, option); - } - return MOD_CONT; + ci->botflags |= BS_KICK_REPEAT; + if (ci->ttb[TTB_REPEAT]) + notice_lang(s_BotServ, u, BOT_KICK_REPEAT_ON_BAN, + ci->repeattimes, ci->ttb[TTB_REPEAT]); + else + notice_lang(s_BotServ, u, BOT_KICK_REPEAT_ON, + ci->repeattimes); + } else { + ci->botflags &= ~BS_KICK_REPEAT; + notice_lang(s_BotServ, u, BOT_KICK_REPEAT_OFF); + } + } else if (!stricmp(option, "REVERSES")) { + if (!stricmp(value, "ON")) { + if (ttb) { + ci->ttb[TTB_REVERSES] = + strtol(ttb, (char **) NULL, 10); + if (errno == ERANGE || errno == EINVAL + || ci->ttb[TTB_REVERSES] < 0) { + if (debug) { + alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_REVERSES]); + } + ci->ttb[TTB_REVERSES] = 0; + notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb); + return MOD_CONT; + } + } else + ci->ttb[TTB_REVERSES] = 0; + ci->botflags |= BS_KICK_REVERSES; + if (ci->ttb[TTB_REVERSES]) + notice_lang(s_BotServ, u, BOT_KICK_REVERSES_ON_BAN, + ci->ttb[TTB_REVERSES]); + else + notice_lang(s_BotServ, u, BOT_KICK_REVERSES_ON); + } else { + ci->botflags &= ~BS_KICK_REVERSES; + notice_lang(s_BotServ, u, BOT_KICK_REVERSES_OFF); + } + } else if (!stricmp(option, "UNDERLINES")) { + if (!stricmp(value, "ON")) { + if (ttb) { + ci->ttb[TTB_UNDERLINES] = + strtol(ttb, (char **) NULL, 10); + if (errno == ERANGE || errno == EINVAL + || ci->ttb[TTB_UNDERLINES] < 0) { + if (debug) { + alog("debug: errno is %d ERANGE %d EINVAL %d ttb %d", errno, ERANGE, EINVAL, ci->ttb[TTB_UNDERLINES]); + } + ci->ttb[TTB_UNDERLINES] = 0; + notice_lang(s_BotServ, u, BOT_KICK_BAD_TTB, ttb); + return MOD_CONT; + } + } else + ci->ttb[TTB_UNDERLINES] = 0; + ci->botflags |= BS_KICK_UNDERLINES; + if (ci->ttb[TTB_UNDERLINES]) + notice_lang(s_BotServ, u, BOT_KICK_UNDERLINES_ON_BAN, + ci->ttb[TTB_UNDERLINES]); + else + notice_lang(s_BotServ, u, BOT_KICK_UNDERLINES_ON); + } else { + ci->botflags &= ~BS_KICK_UNDERLINES; + notice_lang(s_BotServ, u, BOT_KICK_UNDERLINES_OFF); + } + } else + notice_help(s_BotServ, u, BOT_KICK_UNKNOWN, option); + } + return MOD_CONT; } MODULE_INIT("bs_kick", BSKick) diff --git a/src/core/bs_say.c b/src/core/bs_say.c index 85ec7d40d..a4f778257 100644 --- a/src/core/bs_say.c +++ b/src/core/bs_say.c @@ -42,7 +42,7 @@ class BSSay : public Module **/ void myBotServHelp(User * u) { - notice_lang(s_BotServ, u, BOT_HELP_CMD_SAY); + notice_lang(s_BotServ, u, BOT_HELP_CMD_SAY); } /** @@ -52,35 +52,35 @@ void myBotServHelp(User * u) **/ int do_say(User * u) { - ChannelInfo *ci; + ChannelInfo *ci; - char *chan = strtok(NULL, " "); - char *text = strtok(NULL, ""); + char *chan = strtok(NULL, " "); + char *text = strtok(NULL, ""); - if (!chan || !text) - syntax_error(s_BotServ, u, "SAY", BOT_SAY_SYNTAX); - else if (!(ci = cs_findchan(chan))) - notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); - else if (ci->flags & CI_VERBOTEN) - notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); - else if (!ci->bi) - notice_help(s_BotServ, u, BOT_NOT_ASSIGNED); - else if (!ci->c || ci->c->usercount < BSMinUsers) - notice_lang(s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name); - else if (!check_access(u, ci, CA_SAY)) - notice_lang(s_BotServ, u, ACCESS_DENIED); - else { - if (text[0] != '\001') { - ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", text); - ci->bi->lastmsg = time(NULL); - if (LogBot && LogChannel && logchan && !debug && findchan(LogChannel)) - ircdproto->SendPrivmsg(ci->bi, LogChannel, - "SAY %s %s %s", u->nick, ci->name, text); - } else { - syntax_error(s_BotServ, u, "SAY", BOT_SAY_SYNTAX); - } - } - return MOD_CONT; + if (!chan || !text) + syntax_error(s_BotServ, u, "SAY", BOT_SAY_SYNTAX); + else if (!(ci = cs_findchan(chan))) + notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); + else if (ci->flags & CI_VERBOTEN) + notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); + else if (!ci->bi) + notice_help(s_BotServ, u, BOT_NOT_ASSIGNED); + else if (!ci->c || ci->c->usercount < BSMinUsers) + notice_lang(s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name); + else if (!check_access(u, ci, CA_SAY)) + notice_lang(s_BotServ, u, ACCESS_DENIED); + else { + if (text[0] != '\001') { + ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", text); + ci->bi->lastmsg = time(NULL); + if (LogBot && LogChannel && logchan && !debug && findchan(LogChannel)) + ircdproto->SendPrivmsg(ci->bi, LogChannel, + "SAY %s %s %s", u->nick, ci->name, text); + } else { + syntax_error(s_BotServ, u, "SAY", BOT_SAY_SYNTAX); + } + } + return MOD_CONT; } MODULE_INIT("bs_say", BSSay) diff --git a/src/core/bs_set.c b/src/core/bs_set.c index 17a141360..4efa9740c 100644 --- a/src/core/bs_set.c +++ b/src/core/bs_set.c @@ -60,7 +60,7 @@ class BSSet : public Module **/ void myBotServHelp(User * u) { - notice_lang(s_BotServ, u, BOT_HELP_CMD_SET); + notice_lang(s_BotServ, u, BOT_HELP_CMD_SET); } /** @@ -70,119 +70,119 @@ void myBotServHelp(User * u) **/ int do_set(User * u) { - char *chan = strtok(NULL, " "); - char *option = strtok(NULL, " "); - char *value = strtok(NULL, " "); - int is_servadmin = is_services_admin(u); + char *chan = strtok(NULL, " "); + char *option = strtok(NULL, " "); + char *value = strtok(NULL, " "); + int is_servadmin = is_services_admin(u); - ChannelInfo *ci; + ChannelInfo *ci; - if (readonly) - notice_lang(s_BotServ, u, BOT_SET_DISABLED); - else if (!chan || !option || !value) - syntax_error(s_BotServ, u, "SET", BOT_SET_SYNTAX); - else if (is_servadmin && !stricmp(option, "PRIVATE")) { - BotInfo *bi; + if (readonly) + notice_lang(s_BotServ, u, BOT_SET_DISABLED); + else if (!chan || !option || !value) + syntax_error(s_BotServ, u, "SET", BOT_SET_SYNTAX); + else if (is_servadmin && !stricmp(option, "PRIVATE")) { + BotInfo *bi; - if ((bi = findbot(chan))) { - if (!stricmp(value, "ON")) { - bi->flags |= BI_PRIVATE; - notice_lang(s_BotServ, u, BOT_SET_PRIVATE_ON, bi->nick); - } else if (!stricmp(value, "OFF")) { - bi->flags &= ~BI_PRIVATE; - notice_lang(s_BotServ, u, BOT_SET_PRIVATE_OFF, bi->nick); - } else { - syntax_error(s_BotServ, u, "SET PRIVATE", - BOT_SET_PRIVATE_SYNTAX); - } - } else { - notice_lang(s_BotServ, u, BOT_DOES_NOT_EXIST, chan); - } - return MOD_CONT; - } else if (!(ci = cs_findchan(chan))) - notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); - else if (ci->flags & CI_VERBOTEN) - notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); - else if (!is_servadmin && !check_access(u, ci, CA_SET)) - notice_lang(s_BotServ, u, ACCESS_DENIED); - else { - if (!stricmp(option, "DONTKICKOPS")) { - if (!stricmp(value, "ON")) { - ci->botflags |= BS_DONTKICKOPS; - notice_lang(s_BotServ, u, BOT_SET_DONTKICKOPS_ON, - ci->name); - } else if (!stricmp(value, "OFF")) { - ci->botflags &= ~BS_DONTKICKOPS; - notice_lang(s_BotServ, u, BOT_SET_DONTKICKOPS_OFF, - ci->name); - } else { - syntax_error(s_BotServ, u, "SET DONTKICKOPS", - BOT_SET_DONTKICKOPS_SYNTAX); - } - } else if (!stricmp(option, "DONTKICKVOICES")) { - if (!stricmp(value, "ON")) { - ci->botflags |= BS_DONTKICKVOICES; - notice_lang(s_BotServ, u, BOT_SET_DONTKICKVOICES_ON, - ci->name); - } else if (!stricmp(value, "OFF")) { - ci->botflags &= ~BS_DONTKICKVOICES; - notice_lang(s_BotServ, u, BOT_SET_DONTKICKVOICES_OFF, - ci->name); - } else { - syntax_error(s_BotServ, u, "SET DONTKICKVOICES", - BOT_SET_DONTKICKVOICES_SYNTAX); - } - } else if (!stricmp(option, "FANTASY")) { - if (!stricmp(value, "ON")) { - ci->botflags |= BS_FANTASY; - notice_lang(s_BotServ, u, BOT_SET_FANTASY_ON, ci->name); - } else if (!stricmp(value, "OFF")) { - ci->botflags &= ~BS_FANTASY; - notice_lang(s_BotServ, u, BOT_SET_FANTASY_OFF, ci->name); - } else { - syntax_error(s_BotServ, u, "SET FANTASY", - BOT_SET_FANTASY_SYNTAX); - } - } else if (!stricmp(option, "GREET")) { - if (!stricmp(value, "ON")) { - ci->botflags |= BS_GREET; - notice_lang(s_BotServ, u, BOT_SET_GREET_ON, ci->name); - } else if (!stricmp(value, "OFF")) { - ci->botflags &= ~BS_GREET; - notice_lang(s_BotServ, u, BOT_SET_GREET_OFF, ci->name); - } else { - syntax_error(s_BotServ, u, "SET GREET", - BOT_SET_GREET_SYNTAX); - } - } else if (is_servadmin && !stricmp(option, "NOBOT")) { - if (!stricmp(value, "ON")) { - ci->botflags |= BS_NOBOT; - if (ci->bi) - ci->bi->UnAssign(u, ci); - notice_lang(s_BotServ, u, BOT_SET_NOBOT_ON, ci->name); - } else if (!stricmp(value, "OFF")) { - ci->botflags &= ~BS_NOBOT; - notice_lang(s_BotServ, u, BOT_SET_NOBOT_OFF, ci->name); - } else { - syntax_error(s_BotServ, u, "SET NOBOT", - BOT_SET_NOBOT_SYNTAX); - } - } else if (!stricmp(option, "SYMBIOSIS")) { - if (!stricmp(value, "ON")) { - ci->botflags |= BS_SYMBIOSIS; - notice_lang(s_BotServ, u, BOT_SET_SYMBIOSIS_ON, ci->name); - } else if (!stricmp(value, "OFF")) { - ci->botflags &= ~BS_SYMBIOSIS; - notice_lang(s_BotServ, u, BOT_SET_SYMBIOSIS_OFF, ci->name); - } else { - syntax_error(s_BotServ, u, "SET SYMBIOSIS", - BOT_SET_SYMBIOSIS_SYNTAX); - } - } else { - notice_help(s_BotServ, u, BOT_SET_UNKNOWN, option); - } - } - return MOD_CONT; + if ((bi = findbot(chan))) { + if (!stricmp(value, "ON")) { + bi->flags |= BI_PRIVATE; + notice_lang(s_BotServ, u, BOT_SET_PRIVATE_ON, bi->nick); + } else if (!stricmp(value, "OFF")) { + bi->flags &= ~BI_PRIVATE; + notice_lang(s_BotServ, u, BOT_SET_PRIVATE_OFF, bi->nick); + } else { + syntax_error(s_BotServ, u, "SET PRIVATE", + BOT_SET_PRIVATE_SYNTAX); + } + } else { + notice_lang(s_BotServ, u, BOT_DOES_NOT_EXIST, chan); + } + return MOD_CONT; + } else if (!(ci = cs_findchan(chan))) + notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); + else if (ci->flags & CI_VERBOTEN) + notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); + else if (!is_servadmin && !check_access(u, ci, CA_SET)) + notice_lang(s_BotServ, u, ACCESS_DENIED); + else { + if (!stricmp(option, "DONTKICKOPS")) { + if (!stricmp(value, "ON")) { + ci->botflags |= BS_DONTKICKOPS; + notice_lang(s_BotServ, u, BOT_SET_DONTKICKOPS_ON, + ci->name); + } else if (!stricmp(value, "OFF")) { + ci->botflags &= ~BS_DONTKICKOPS; + notice_lang(s_BotServ, u, BOT_SET_DONTKICKOPS_OFF, + ci->name); + } else { + syntax_error(s_BotServ, u, "SET DONTKICKOPS", + BOT_SET_DONTKICKOPS_SYNTAX); + } + } else if (!stricmp(option, "DONTKICKVOICES")) { + if (!stricmp(value, "ON")) { + ci->botflags |= BS_DONTKICKVOICES; + notice_lang(s_BotServ, u, BOT_SET_DONTKICKVOICES_ON, + ci->name); + } else if (!stricmp(value, "OFF")) { + ci->botflags &= ~BS_DONTKICKVOICES; + notice_lang(s_BotServ, u, BOT_SET_DONTKICKVOICES_OFF, + ci->name); + } else { + syntax_error(s_BotServ, u, "SET DONTKICKVOICES", + BOT_SET_DONTKICKVOICES_SYNTAX); + } + } else if (!stricmp(option, "FANTASY")) { + if (!stricmp(value, "ON")) { + ci->botflags |= BS_FANTASY; + notice_lang(s_BotServ, u, BOT_SET_FANTASY_ON, ci->name); + } else if (!stricmp(value, "OFF")) { + ci->botflags &= ~BS_FANTASY; + notice_lang(s_BotServ, u, BOT_SET_FANTASY_OFF, ci->name); + } else { + syntax_error(s_BotServ, u, "SET FANTASY", + BOT_SET_FANTASY_SYNTAX); + } + } else if (!stricmp(option, "GREET")) { + if (!stricmp(value, "ON")) { + ci->botflags |= BS_GREET; + notice_lang(s_BotServ, u, BOT_SET_GREET_ON, ci->name); + } else if (!stricmp(value, "OFF")) { + ci->botflags &= ~BS_GREET; + notice_lang(s_BotServ, u, BOT_SET_GREET_OFF, ci->name); + } else { + syntax_error(s_BotServ, u, "SET GREET", + BOT_SET_GREET_SYNTAX); + } + } else if (is_servadmin && !stricmp(option, "NOBOT")) { + if (!stricmp(value, "ON")) { + ci->botflags |= BS_NOBOT; + if (ci->bi) + ci->bi->UnAssign(u, ci); + notice_lang(s_BotServ, u, BOT_SET_NOBOT_ON, ci->name); + } else if (!stricmp(value, "OFF")) { + ci->botflags &= ~BS_NOBOT; + notice_lang(s_BotServ, u, BOT_SET_NOBOT_OFF, ci->name); + } else { + syntax_error(s_BotServ, u, "SET NOBOT", + BOT_SET_NOBOT_SYNTAX); + } + } else if (!stricmp(option, "SYMBIOSIS")) { + if (!stricmp(value, "ON")) { + ci->botflags |= BS_SYMBIOSIS; + notice_lang(s_BotServ, u, BOT_SET_SYMBIOSIS_ON, ci->name); + } else if (!stricmp(value, "OFF")) { + ci->botflags &= ~BS_SYMBIOSIS; + notice_lang(s_BotServ, u, BOT_SET_SYMBIOSIS_OFF, ci->name); + } else { + syntax_error(s_BotServ, u, "SET SYMBIOSIS", + BOT_SET_SYMBIOSIS_SYNTAX); + } + } else { + notice_help(s_BotServ, u, BOT_SET_UNKNOWN, option); + } + } + return MOD_CONT; } MODULE_INIT("bs_set", BSSet) diff --git a/src/core/bs_unassign.c b/src/core/bs_unassign.c index d7a6fb348..984026c7b 100644 --- a/src/core/bs_unassign.c +++ b/src/core/bs_unassign.c @@ -43,7 +43,7 @@ class BSUnassign : public Module **/ void myBotServHelp(User * u) { - notice_lang(s_BotServ, u, BOT_HELP_CMD_UNASSIGN); + notice_lang(s_BotServ, u, BOT_HELP_CMD_UNASSIGN); } /** @@ -53,26 +53,26 @@ void myBotServHelp(User * u) **/ int do_unassign(User * u) { - char *chan = strtok(NULL, " "); - ChannelInfo *ci; + char *chan = strtok(NULL, " "); + ChannelInfo *ci; - if (readonly) - notice_lang(s_BotServ, u, BOT_ASSIGN_READONLY); - else if (!chan) - syntax_error(s_BotServ, u, "UNASSIGN", BOT_UNASSIGN_SYNTAX); - else if (!(ci = cs_findchan(chan))) - notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); - else if (ci->flags & CI_VERBOTEN) - notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); - else if (!is_services_admin(u) && !check_access(u, ci, CA_ASSIGN)) - notice_lang(s_BotServ, u, ACCESS_DENIED); - else if (!ci->bi) - notice_help(s_BotServ, u, BOT_NOT_ASSIGNED); - else { - ci->bi->UnAssign(u, ci); - notice_lang(s_BotServ, u, BOT_UNASSIGN_UNASSIGNED, ci->name); - } - return MOD_CONT; + if (readonly) + notice_lang(s_BotServ, u, BOT_ASSIGN_READONLY); + else if (!chan) + syntax_error(s_BotServ, u, "UNASSIGN", BOT_UNASSIGN_SYNTAX); + else if (!(ci = cs_findchan(chan))) + notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); + else if (ci->flags & CI_VERBOTEN) + notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); + else if (!is_services_admin(u) && !check_access(u, ci, CA_ASSIGN)) + notice_lang(s_BotServ, u, ACCESS_DENIED); + else if (!ci->bi) + notice_help(s_BotServ, u, BOT_NOT_ASSIGNED); + else { + ci->bi->UnAssign(u, ci); + notice_lang(s_BotServ, u, BOT_UNASSIGN_UNASSIGNED, ci->name); + } + return MOD_CONT; } MODULE_INIT("bs_unassign", BSUnassign) diff --git a/src/core/cs_access.c b/src/core/cs_access.c index 31e8df133..b70192c02 100644 --- a/src/core/cs_access.c +++ b/src/core/cs_access.c @@ -51,72 +51,72 @@ class CSAccess : public Module **/ void myChanServHelp(User * u) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_ACCESS); - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_LEVELS); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_ACCESS); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_LEVELS); } static int access_del(User * u, ChannelInfo *ci, ChanAccess * access, int *perm, int uacc) { char *nick; - if (!access->in_use) - return 0; - if (!is_services_admin(u) && uacc <= access->level) { - (*perm)++; - return 0; - } - nick = access->nc->display; - access->nc = NULL; - access->in_use = 0; - send_event(EVENT_ACCESS_DEL, 3, ci->name, u->nick, nick); - return 1; + if (!access->in_use) + return 0; + if (!is_services_admin(u) && uacc <= access->level) { + (*perm)++; + return 0; + } + nick = access->nc->display; + access->nc = NULL; + access->in_use = 0; + send_event(EVENT_ACCESS_DEL, 3, ci->name, u->nick, nick); + return 1; } static int access_del_callback(User * u, int num, va_list args) { - ChannelInfo *ci = va_arg(args, ChannelInfo *); - int *last = va_arg(args, int *); - int *perm = va_arg(args, int *); - int uacc = va_arg(args, int); - if (num < 1 || num > ci->accesscount) - return 0; - *last = num; - return access_del(u, ci, &ci->access[num - 1], perm, uacc); + ChannelInfo *ci = va_arg(args, ChannelInfo *); + int *last = va_arg(args, int *); + int *perm = va_arg(args, int *); + int uacc = va_arg(args, int); + if (num < 1 || num > ci->accesscount) + return 0; + *last = num; + return access_del(u, ci, &ci->access[num - 1], perm, uacc); } static int access_list(User * u, int index, ChannelInfo * ci, - int *sent_header) + int *sent_header) { - ChanAccess *access = &ci->access[index]; - const char *xop; - - if (!access->in_use) - return 0; - - if (!*sent_header) { - notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_HEADER, ci->name); - *sent_header = 1; - } - - if (ci->flags & CI_XOP) { - xop = get_xop_level(access->level); - notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_XOP_FORMAT, index + 1, - xop, access->nc->display); - } else { - notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_AXS_FORMAT, index + 1, - access->level, access->nc->display); - } - return 1; + ChanAccess *access = &ci->access[index]; + const char *xop; + + if (!access->in_use) + return 0; + + if (!*sent_header) { + notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_HEADER, ci->name); + *sent_header = 1; + } + + if (ci->flags & CI_XOP) { + xop = get_xop_level(access->level); + notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_XOP_FORMAT, index + 1, + xop, access->nc->display); + } else { + notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_AXS_FORMAT, index + 1, + access->level, access->nc->display); + } + return 1; } static int access_list_callback(User * u, int num, va_list args) { - ChannelInfo *ci = va_arg(args, ChannelInfo *); - int *sent_header = va_arg(args, int *); - if (num < 1 || num > ci->accesscount) - return 0; - return access_list(u, num - 1, ci, sent_header); + ChannelInfo *ci = va_arg(args, ChannelInfo *); + int *sent_header = va_arg(args, int *); + if (num < 1 || num > ci->accesscount) + return 0; + return access_list(u, num - 1, ci, sent_header); } @@ -127,402 +127,402 @@ static int access_list_callback(User * u, int num, va_list args) **/ int do_access(User * u) { - char *chan = strtok(NULL, " "); - char *cmd = strtok(NULL, " "); - char *nick = strtok(NULL, " "); - char *s = strtok(NULL, " "); - char event_access[BUFSIZE]; - - ChannelInfo *ci; - NickAlias *na = NULL; - NickCore *nc; - ChanAccess *access; - - int i; - int level = 0, ulev; - int is_list = (cmd && stricmp(cmd, "LIST") == 0); - int is_servadmin = is_services_admin(u); - - /* If LIST, we don't *require* any parameters, but we can take any. - * If DEL, we require a nick and no level. - * Else (ADD), we require a level (which implies a nick). */ - if (!cmd || ((is_list || !stricmp(cmd, "CLEAR")) ? 0 : - (stricmp(cmd, "DEL") == 0) ? (!nick || s) : !s)) { - syntax_error(s_ChanServ, u, "ACCESS", CHAN_ACCESS_SYNTAX); - } else if (!(ci = cs_findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); - /* We still allow LIST in xOP mode, but not others */ - } else if ((ci->flags & CI_XOP) && !is_list) { + char *chan = strtok(NULL, " "); + char *cmd = strtok(NULL, " "); + char *nick = strtok(NULL, " "); + char *s = strtok(NULL, " "); + char event_access[BUFSIZE]; + + ChannelInfo *ci; + NickAlias *na = NULL; + NickCore *nc; + ChanAccess *access; + + int i; + int level = 0, ulev; + int is_list = (cmd && stricmp(cmd, "LIST") == 0); + int is_servadmin = is_services_admin(u); + + /* If LIST, we don't *require* any parameters, but we can take any. + * If DEL, we require a nick and no level. + * Else (ADD), we require a level (which implies a nick). */ + if (!cmd || ((is_list || !stricmp(cmd, "CLEAR")) ? 0 : + (stricmp(cmd, "DEL") == 0) ? (!nick || s) : !s)) { + syntax_error(s_ChanServ, u, "ACCESS", CHAN_ACCESS_SYNTAX); + } else if (!(ci = cs_findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); + /* We still allow LIST in xOP mode, but not others */ + } else if ((ci->flags & CI_XOP) && !is_list) { if (ircd->halfop) - notice_lang(s_ChanServ, u, CHAN_ACCESS_XOP_HOP, s_ChanServ); + notice_lang(s_ChanServ, u, CHAN_ACCESS_XOP_HOP, s_ChanServ); else - notice_lang(s_ChanServ, u, CHAN_ACCESS_XOP, s_ChanServ); - } else if (((is_list && !check_access(u, ci, CA_ACCESS_LIST)) - || (!is_list && !check_access(u, ci, CA_ACCESS_CHANGE))) - && !is_servadmin) { - notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else if (stricmp(cmd, "ADD") == 0) { - if (readonly) { - notice_lang(s_ChanServ, u, CHAN_ACCESS_DISABLED); - return MOD_CONT; - } - - level = atoi(s); - ulev = get_access(u, ci); - - if (!is_servadmin && level >= ulev) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - return MOD_CONT; - } - - if (level == 0) { - notice_lang(s_ChanServ, u, CHAN_ACCESS_LEVEL_NONZERO); - return MOD_CONT; - } else if (level <= ACCESS_INVALID || level >= ACCESS_FOUNDER) { - notice_lang(s_ChanServ, u, CHAN_ACCESS_LEVEL_RANGE, - ACCESS_INVALID + 1, ACCESS_FOUNDER - 1); - return MOD_CONT; - } - - na = findnick(nick); - if (!na) { - notice_lang(s_ChanServ, u, CHAN_ACCESS_NICKS_ONLY); - return MOD_CONT; - } - if (na->status & NS_VERBOTEN) { - notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, nick); - return MOD_CONT; - } - - nc = na->nc; - for (access = ci->access, i = 0; i < ci->accesscount; - access++, i++) { - if (access->nc == nc) { - /* Don't allow lowering from a level >= ulev */ - if (!is_servadmin && access->level >= ulev) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - return MOD_CONT; - } - if (access->level == level) { - notice_lang(s_ChanServ, u, CHAN_ACCESS_LEVEL_UNCHANGED, - access->nc->display, chan, level); - return MOD_CONT; - } - access->level = level; - snprintf(event_access, BUFSIZE, "%d", access->level); - send_event(EVENT_ACCESS_CHANGE, 4, ci->name, u->nick, - na->nick, event_access); - alog("%s: %s!%s@%s (level %d) set access level %d to %s (group %s) on channel %s", s_ChanServ, u->nick, u->username, u->host, ulev, access->level, na->nick, nc->display, ci->name); - notice_lang(s_ChanServ, u, CHAN_ACCESS_LEVEL_CHANGED, - access->nc->display, chan, level); - return MOD_CONT; - } - } - - /* All entries should be in use so we no longer need - * to go over the entire list.. - for (i = 0; i < ci->accesscount; i++) { - if (!ci->access[i].in_use) - break; - } - */ - - if (i < CSAccessMax) { - ci->accesscount++; - ci->access = - (ChanAccess *)srealloc(ci->access, - sizeof(ChanAccess) * ci->accesscount); - } else { - notice_lang(s_ChanServ, u, CHAN_ACCESS_REACHED_LIMIT, - CSAccessMax); - return MOD_CONT; - } - - access = &ci->access[i]; - access->nc = nc; - access->in_use = 1; - access->level = level; - access->last_seen = 0; - - snprintf(event_access, BUFSIZE, "%d", access->level); - send_event(EVENT_ACCESS_ADD, 4, ci->name, u->nick, na->nick, - event_access); - alog("%s: %s!%s@%s (level %d) set access level %d to %s (group %s) on channel %s", s_ChanServ, u->nick, u->username, u->host, ulev, access->level, na->nick, nc->display, ci->name); - notice_lang(s_ChanServ, u, CHAN_ACCESS_ADDED, nc->display, - ci->name, access->level); - } else if (stricmp(cmd, "DEL") == 0) { - int deleted, a, b; - if (readonly) { - notice_lang(s_ChanServ, u, CHAN_ACCESS_DISABLED); - return MOD_CONT; - } - - if (ci->accesscount == 0) { - notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_EMPTY, chan); - return MOD_CONT; - } - - /* Special case: is it a number/list? Only do search if it isn't. */ - if (isdigit(*nick) && strspn(nick, "1234567890,-") == strlen(nick)) { - int count, last = -1, perm = 0; - deleted = process_numlist(nick, &count, access_del_callback, u, - ci, &last, &perm, get_access(u, ci)); - if (!deleted) { - if (perm) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - } else if (count == 1) { - notice_lang(s_ChanServ, u, CHAN_ACCESS_NO_SUCH_ENTRY, - last, ci->name); - } else { - notice_lang(s_ChanServ, u, CHAN_ACCESS_NO_MATCH, - ci->name); - } - } else if (deleted == 1) { - notice_lang(s_ChanServ, u, CHAN_ACCESS_DELETED_ONE, - ci->name); - } else { - notice_lang(s_ChanServ, u, CHAN_ACCESS_DELETED_SEVERAL, - deleted, ci->name); - } - } else { - na = findnick(nick); - if (!na) { - notice_lang(s_ChanServ, u, NICK_X_NOT_REGISTERED, nick); - return MOD_CONT; - } - nc = na->nc; - for (i = 0; i < ci->accesscount; i++) { - if (ci->access[i].nc == nc) - break; - } - if (i == ci->accesscount) { - notice_lang(s_ChanServ, u, CHAN_ACCESS_NOT_FOUND, nick, - chan); - return MOD_CONT; - } - access = &ci->access[i]; - if (!is_servadmin && get_access(u, ci) <= access->level) { - deleted = 0; - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - } else { - notice_lang(s_ChanServ, u, CHAN_ACCESS_DELETED, - access->nc->display, ci->name); - alog("%s: %s!%s@%s (level %d) deleted access of %s (group %s) on %s", s_ChanServ, u->nick, u->username, u->host, get_access(u, ci), na->nick, access->nc->display, chan); - access->nc = NULL; - access->in_use = 0; - deleted = 1; - } - } - - if (deleted) { - /* Reordering - DrStein */ - for (b = 0; b < ci->accesscount; b++) { - if (ci->access[b].in_use) { - for (a = 0; a < ci->accesscount; a++) { - if (a > b) - break; - if (!ci->access[a].in_use) { - ci->access[a].in_use = 1; - ci->access[a].level = ci->access[b].level; - ci->access[a].nc = ci->access[b].nc; - ci->access[a].last_seen = - ci->access[b].last_seen; - ci->access[b].nc = NULL; - ci->access[b].in_use = 0; - break; - } - } - } - } - - /* After reordering only the entries at the end could still be empty. - * We ll free the places no longer in use... */ - for (i = ci->accesscount - 1; i >= 0; i--) { - if (ci->access[i].in_use == 1) - break; - - ci->accesscount--; - } - ci->access = - (ChanAccess *)srealloc(ci->access,sizeof(ChanAccess) * ci->accesscount); - - /* We don't know the nick if someone used numbers, so we trigger the event without - * nick param. We just do this once, even if someone enters a range. -Certus */ - if (na) - send_event(EVENT_ACCESS_DEL, 3, ci->name, u->nick, na->nick); - else - send_event(EVENT_ACCESS_DEL, 2, ci->name, u->nick); - } - } else if (stricmp(cmd, "LIST") == 0) { - int sent_header = 0; - - if (ci->accesscount == 0) { - notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_EMPTY, chan); - return MOD_CONT; - } - if (nick && strspn(nick, "1234567890,-") == strlen(nick)) { - process_numlist(nick, NULL, access_list_callback, u, ci, - &sent_header); - } else { - for (i = 0; i < ci->accesscount; i++) { - if (nick && ci->access[i].nc - && !match_wild_nocase(nick, ci->access[i].nc->display)) - continue; - access_list(u, i, ci, &sent_header); - } - } - if (!sent_header) { - notice_lang(s_ChanServ, u, CHAN_ACCESS_NO_MATCH, chan); - } else { - notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_FOOTER, ci->name); - } - } else if (stricmp(cmd, "CLEAR") == 0) { - - if (readonly) { - notice_lang(s_ChanServ, u, CHAN_ACCESS_DISABLED); - return MOD_CONT; - } - - if (!is_servadmin && !is_founder(u, ci)) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - return MOD_CONT; - } - - free(ci->access); - ci->access = NULL; - ci->accesscount = 0; - - send_event(EVENT_ACCESS_CLEAR, 2, ci->name, u->nick); - - notice_lang(s_ChanServ, u, CHAN_ACCESS_CLEAR, ci->name); - alog("%s: %s!%s@%s (level %d) cleared access list on %s", - s_ChanServ, u->nick, u->username, u->host, - get_access(u, ci), chan); - - } else { - syntax_error(s_ChanServ, u, "ACCESS", CHAN_ACCESS_SYNTAX); - } - return MOD_CONT; + notice_lang(s_ChanServ, u, CHAN_ACCESS_XOP, s_ChanServ); + } else if (((is_list && !check_access(u, ci, CA_ACCESS_LIST)) + || (!is_list && !check_access(u, ci, CA_ACCESS_CHANGE))) + && !is_servadmin) { + notice_lang(s_ChanServ, u, ACCESS_DENIED); + } else if (stricmp(cmd, "ADD") == 0) { + if (readonly) { + notice_lang(s_ChanServ, u, CHAN_ACCESS_DISABLED); + return MOD_CONT; + } + + level = atoi(s); + ulev = get_access(u, ci); + + if (!is_servadmin && level >= ulev) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + return MOD_CONT; + } + + if (level == 0) { + notice_lang(s_ChanServ, u, CHAN_ACCESS_LEVEL_NONZERO); + return MOD_CONT; + } else if (level <= ACCESS_INVALID || level >= ACCESS_FOUNDER) { + notice_lang(s_ChanServ, u, CHAN_ACCESS_LEVEL_RANGE, + ACCESS_INVALID + 1, ACCESS_FOUNDER - 1); + return MOD_CONT; + } + + na = findnick(nick); + if (!na) { + notice_lang(s_ChanServ, u, CHAN_ACCESS_NICKS_ONLY); + return MOD_CONT; + } + if (na->status & NS_VERBOTEN) { + notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, nick); + return MOD_CONT; + } + + nc = na->nc; + for (access = ci->access, i = 0; i < ci->accesscount; + access++, i++) { + if (access->nc == nc) { + /* Don't allow lowering from a level >= ulev */ + if (!is_servadmin && access->level >= ulev) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + return MOD_CONT; + } + if (access->level == level) { + notice_lang(s_ChanServ, u, CHAN_ACCESS_LEVEL_UNCHANGED, + access->nc->display, chan, level); + return MOD_CONT; + } + access->level = level; + snprintf(event_access, BUFSIZE, "%d", access->level); + send_event(EVENT_ACCESS_CHANGE, 4, ci->name, u->nick, + na->nick, event_access); + alog("%s: %s!%s@%s (level %d) set access level %d to %s (group %s) on channel %s", s_ChanServ, u->nick, u->username, u->host, ulev, access->level, na->nick, nc->display, ci->name); + notice_lang(s_ChanServ, u, CHAN_ACCESS_LEVEL_CHANGED, + access->nc->display, chan, level); + return MOD_CONT; + } + } + + /* All entries should be in use so we no longer need + * to go over the entire list.. + for (i = 0; i < ci->accesscount; i++) { + if (!ci->access[i].in_use) + break; + } + */ + + if (i < CSAccessMax) { + ci->accesscount++; + ci->access = + (ChanAccess *)srealloc(ci->access, + sizeof(ChanAccess) * ci->accesscount); + } else { + notice_lang(s_ChanServ, u, CHAN_ACCESS_REACHED_LIMIT, + CSAccessMax); + return MOD_CONT; + } + + access = &ci->access[i]; + access->nc = nc; + access->in_use = 1; + access->level = level; + access->last_seen = 0; + + snprintf(event_access, BUFSIZE, "%d", access->level); + send_event(EVENT_ACCESS_ADD, 4, ci->name, u->nick, na->nick, + event_access); + alog("%s: %s!%s@%s (level %d) set access level %d to %s (group %s) on channel %s", s_ChanServ, u->nick, u->username, u->host, ulev, access->level, na->nick, nc->display, ci->name); + notice_lang(s_ChanServ, u, CHAN_ACCESS_ADDED, nc->display, + ci->name, access->level); + } else if (stricmp(cmd, "DEL") == 0) { + int deleted, a, b; + if (readonly) { + notice_lang(s_ChanServ, u, CHAN_ACCESS_DISABLED); + return MOD_CONT; + } + + if (ci->accesscount == 0) { + notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_EMPTY, chan); + return MOD_CONT; + } + + /* Special case: is it a number/list? Only do search if it isn't. */ + if (isdigit(*nick) && strspn(nick, "1234567890,-") == strlen(nick)) { + int count, last = -1, perm = 0; + deleted = process_numlist(nick, &count, access_del_callback, u, + ci, &last, &perm, get_access(u, ci)); + if (!deleted) { + if (perm) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + } else if (count == 1) { + notice_lang(s_ChanServ, u, CHAN_ACCESS_NO_SUCH_ENTRY, + last, ci->name); + } else { + notice_lang(s_ChanServ, u, CHAN_ACCESS_NO_MATCH, + ci->name); + } + } else if (deleted == 1) { + notice_lang(s_ChanServ, u, CHAN_ACCESS_DELETED_ONE, + ci->name); + } else { + notice_lang(s_ChanServ, u, CHAN_ACCESS_DELETED_SEVERAL, + deleted, ci->name); + } + } else { + na = findnick(nick); + if (!na) { + notice_lang(s_ChanServ, u, NICK_X_NOT_REGISTERED, nick); + return MOD_CONT; + } + nc = na->nc; + for (i = 0; i < ci->accesscount; i++) { + if (ci->access[i].nc == nc) + break; + } + if (i == ci->accesscount) { + notice_lang(s_ChanServ, u, CHAN_ACCESS_NOT_FOUND, nick, + chan); + return MOD_CONT; + } + access = &ci->access[i]; + if (!is_servadmin && get_access(u, ci) <= access->level) { + deleted = 0; + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + } else { + notice_lang(s_ChanServ, u, CHAN_ACCESS_DELETED, + access->nc->display, ci->name); + alog("%s: %s!%s@%s (level %d) deleted access of %s (group %s) on %s", s_ChanServ, u->nick, u->username, u->host, get_access(u, ci), na->nick, access->nc->display, chan); + access->nc = NULL; + access->in_use = 0; + deleted = 1; + } + } + + if (deleted) { + /* Reordering - DrStein */ + for (b = 0; b < ci->accesscount; b++) { + if (ci->access[b].in_use) { + for (a = 0; a < ci->accesscount; a++) { + if (a > b) + break; + if (!ci->access[a].in_use) { + ci->access[a].in_use = 1; + ci->access[a].level = ci->access[b].level; + ci->access[a].nc = ci->access[b].nc; + ci->access[a].last_seen = + ci->access[b].last_seen; + ci->access[b].nc = NULL; + ci->access[b].in_use = 0; + break; + } + } + } + } + + /* After reordering only the entries at the end could still be empty. + * We ll free the places no longer in use... */ + for (i = ci->accesscount - 1; i >= 0; i--) { + if (ci->access[i].in_use == 1) + break; + + ci->accesscount--; + } + ci->access = + (ChanAccess *)srealloc(ci->access,sizeof(ChanAccess) * ci->accesscount); + + /* We don't know the nick if someone used numbers, so we trigger the event without + * nick param. We just do this once, even if someone enters a range. -Certus */ + if (na) + send_event(EVENT_ACCESS_DEL, 3, ci->name, u->nick, na->nick); + else + send_event(EVENT_ACCESS_DEL, 2, ci->name, u->nick); + } + } else if (stricmp(cmd, "LIST") == 0) { + int sent_header = 0; + + if (ci->accesscount == 0) { + notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_EMPTY, chan); + return MOD_CONT; + } + if (nick && strspn(nick, "1234567890,-") == strlen(nick)) { + process_numlist(nick, NULL, access_list_callback, u, ci, + &sent_header); + } else { + for (i = 0; i < ci->accesscount; i++) { + if (nick && ci->access[i].nc + && !match_wild_nocase(nick, ci->access[i].nc->display)) + continue; + access_list(u, i, ci, &sent_header); + } + } + if (!sent_header) { + notice_lang(s_ChanServ, u, CHAN_ACCESS_NO_MATCH, chan); + } else { + notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_FOOTER, ci->name); + } + } else if (stricmp(cmd, "CLEAR") == 0) { + + if (readonly) { + notice_lang(s_ChanServ, u, CHAN_ACCESS_DISABLED); + return MOD_CONT; + } + + if (!is_servadmin && !is_founder(u, ci)) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + return MOD_CONT; + } + + free(ci->access); + ci->access = NULL; + ci->accesscount = 0; + + send_event(EVENT_ACCESS_CLEAR, 2, ci->name, u->nick); + + notice_lang(s_ChanServ, u, CHAN_ACCESS_CLEAR, ci->name); + alog("%s: %s!%s@%s (level %d) cleared access list on %s", + s_ChanServ, u->nick, u->username, u->host, + get_access(u, ci), chan); + + } else { + syntax_error(s_ChanServ, u, "ACCESS", CHAN_ACCESS_SYNTAX); + } + return MOD_CONT; } int do_levels(User * u) { - char *chan = strtok(NULL, " "); - char *cmd = strtok(NULL, " "); - char *what = strtok(NULL, " "); - char *s = strtok(NULL, " "); - char *error; - - ChannelInfo *ci; - int level; - int i; - - /* If SET, we want two extra parameters; if DIS[ABLE] or FOUNDER, we want only - * one; else, we want none. - */ - if (!cmd - || ((stricmp(cmd, "SET") == 0) ? !s - : ((strnicmp(cmd, "DIS", 3) == 0)) ? (!what || s) : !!what)) { - syntax_error(s_ChanServ, u, "LEVELS", CHAN_LEVELS_SYNTAX); - } else if (!(ci = cs_findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); - } else if (ci->flags & CI_XOP) { - notice_lang(s_ChanServ, u, CHAN_LEVELS_XOP); - } else if (!is_founder(u, ci) && !is_services_admin(u)) { - notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else if (stricmp(cmd, "SET") == 0) { - level = strtol(s, &error, 10); - - if (*error != '\0') { - syntax_error(s_ChanServ, u, "LEVELS", CHAN_LEVELS_SYNTAX); - return MOD_CONT; - } - - if (level <= ACCESS_INVALID || level >= ACCESS_FOUNDER) { - notice_lang(s_ChanServ, u, CHAN_LEVELS_RANGE, - ACCESS_INVALID + 1, ACCESS_FOUNDER - 1); - return MOD_CONT; - } - - for (i = 0; levelinfo[i].what >= 0; i++) { - if (stricmp(levelinfo[i].name, what) == 0) { - ci->levels[levelinfo[i].what] = level; - - alog("%s: %s!%s@%s set level %s on channel %s to %d", - s_ChanServ, u->nick, u->username, u->host, - levelinfo[i].name, ci->name, level); - notice_lang(s_ChanServ, u, CHAN_LEVELS_CHANGED, - levelinfo[i].name, chan, level); - return MOD_CONT; - } - } - - notice_lang(s_ChanServ, u, CHAN_LEVELS_UNKNOWN, what, s_ChanServ); - - } else if (stricmp(cmd, "DIS") == 0 || stricmp(cmd, "DISABLE") == 0) { - for (i = 0; levelinfo[i].what >= 0; i++) { - if (stricmp(levelinfo[i].name, what) == 0) { - ci->levels[levelinfo[i].what] = ACCESS_INVALID; - - alog("%s: %s!%s@%s disabled level %s on channel %s", - s_ChanServ, u->nick, u->username, u->host, - levelinfo[i].name, ci->name); - notice_lang(s_ChanServ, u, CHAN_LEVELS_DISABLED, - levelinfo[i].name, chan); - return MOD_CONT; - } - } - - notice_lang(s_ChanServ, u, CHAN_LEVELS_UNKNOWN, what, s_ChanServ); - } else if (stricmp(cmd, "LIST") == 0) { - notice_lang(s_ChanServ, u, CHAN_LEVELS_LIST_HEADER, chan); - - if (!levelinfo_maxwidth) { - for (i = 0; levelinfo[i].what >= 0; i++) { - int len = strlen(levelinfo[i].name); - if (len > levelinfo_maxwidth) - levelinfo_maxwidth = len; - } - } - - for (i = 0; levelinfo[i].what >= 0; i++) { - int j = ci->levels[levelinfo[i].what]; - - if (j == ACCESS_INVALID) { - j = levelinfo[i].what; - - if (j == CA_AUTOOP || j == CA_AUTODEOP || j == CA_AUTOVOICE - || j == CA_NOJOIN) { - notice_lang(s_ChanServ, u, CHAN_LEVELS_LIST_DISABLED, - levelinfo_maxwidth, levelinfo[i].name); - } else { - notice_lang(s_ChanServ, u, CHAN_LEVELS_LIST_DISABLED, - levelinfo_maxwidth, levelinfo[i].name); - } - } else if (j == ACCESS_FOUNDER) { - notice_lang(s_ChanServ, u, CHAN_LEVELS_LIST_FOUNDER, - levelinfo_maxwidth, levelinfo[i].name); - } else { - notice_lang(s_ChanServ, u, CHAN_LEVELS_LIST_NORMAL, - levelinfo_maxwidth, levelinfo[i].name, j); - } - } - - } else if (stricmp(cmd, "RESET") == 0) { - reset_levels(ci); - - alog("%s: %s!%s@%s reset levels definitions on channel %s", - s_ChanServ, u->nick, u->username, u->host, ci->name); - notice_lang(s_ChanServ, u, CHAN_LEVELS_RESET, chan); - } else { - syntax_error(s_ChanServ, u, "LEVELS", CHAN_LEVELS_SYNTAX); - } - return MOD_CONT; + char *chan = strtok(NULL, " "); + char *cmd = strtok(NULL, " "); + char *what = strtok(NULL, " "); + char *s = strtok(NULL, " "); + char *error; + + ChannelInfo *ci; + int level; + int i; + + /* If SET, we want two extra parameters; if DIS[ABLE] or FOUNDER, we want only + * one; else, we want none. + */ + if (!cmd + || ((stricmp(cmd, "SET") == 0) ? !s + : ((strnicmp(cmd, "DIS", 3) == 0)) ? (!what || s) : !!what)) { + syntax_error(s_ChanServ, u, "LEVELS", CHAN_LEVELS_SYNTAX); + } else if (!(ci = cs_findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); + } else if (ci->flags & CI_XOP) { + notice_lang(s_ChanServ, u, CHAN_LEVELS_XOP); + } else if (!is_founder(u, ci) && !is_services_admin(u)) { + notice_lang(s_ChanServ, u, ACCESS_DENIED); + } else if (stricmp(cmd, "SET") == 0) { + level = strtol(s, &error, 10); + + if (*error != '\0') { + syntax_error(s_ChanServ, u, "LEVELS", CHAN_LEVELS_SYNTAX); + return MOD_CONT; + } + + if (level <= ACCESS_INVALID || level >= ACCESS_FOUNDER) { + notice_lang(s_ChanServ, u, CHAN_LEVELS_RANGE, + ACCESS_INVALID + 1, ACCESS_FOUNDER - 1); + return MOD_CONT; + } + + for (i = 0; levelinfo[i].what >= 0; i++) { + if (stricmp(levelinfo[i].name, what) == 0) { + ci->levels[levelinfo[i].what] = level; + + alog("%s: %s!%s@%s set level %s on channel %s to %d", + s_ChanServ, u->nick, u->username, u->host, + levelinfo[i].name, ci->name, level); + notice_lang(s_ChanServ, u, CHAN_LEVELS_CHANGED, + levelinfo[i].name, chan, level); + return MOD_CONT; + } + } + + notice_lang(s_ChanServ, u, CHAN_LEVELS_UNKNOWN, what, s_ChanServ); + + } else if (stricmp(cmd, "DIS") == 0 || stricmp(cmd, "DISABLE") == 0) { + for (i = 0; levelinfo[i].what >= 0; i++) { + if (stricmp(levelinfo[i].name, what) == 0) { + ci->levels[levelinfo[i].what] = ACCESS_INVALID; + + alog("%s: %s!%s@%s disabled level %s on channel %s", + s_ChanServ, u->nick, u->username, u->host, + levelinfo[i].name, ci->name); + notice_lang(s_ChanServ, u, CHAN_LEVELS_DISABLED, + levelinfo[i].name, chan); + return MOD_CONT; + } + } + + notice_lang(s_ChanServ, u, CHAN_LEVELS_UNKNOWN, what, s_ChanServ); + } else if (stricmp(cmd, "LIST") == 0) { + notice_lang(s_ChanServ, u, CHAN_LEVELS_LIST_HEADER, chan); + + if (!levelinfo_maxwidth) { + for (i = 0; levelinfo[i].what >= 0; i++) { + int len = strlen(levelinfo[i].name); + if (len > levelinfo_maxwidth) + levelinfo_maxwidth = len; + } + } + + for (i = 0; levelinfo[i].what >= 0; i++) { + int j = ci->levels[levelinfo[i].what]; + + if (j == ACCESS_INVALID) { + j = levelinfo[i].what; + + if (j == CA_AUTOOP || j == CA_AUTODEOP || j == CA_AUTOVOICE + || j == CA_NOJOIN) { + notice_lang(s_ChanServ, u, CHAN_LEVELS_LIST_DISABLED, + levelinfo_maxwidth, levelinfo[i].name); + } else { + notice_lang(s_ChanServ, u, CHAN_LEVELS_LIST_DISABLED, + levelinfo_maxwidth, levelinfo[i].name); + } + } else if (j == ACCESS_FOUNDER) { + notice_lang(s_ChanServ, u, CHAN_LEVELS_LIST_FOUNDER, + levelinfo_maxwidth, levelinfo[i].name); + } else { + notice_lang(s_ChanServ, u, CHAN_LEVELS_LIST_NORMAL, + levelinfo_maxwidth, levelinfo[i].name, j); + } + } + + } else if (stricmp(cmd, "RESET") == 0) { + reset_levels(ci); + + alog("%s: %s!%s@%s reset levels definitions on channel %s", + s_ChanServ, u->nick, u->username, u->host, ci->name); + notice_lang(s_ChanServ, u, CHAN_LEVELS_RESET, chan); + } else { + syntax_error(s_ChanServ, u, "LEVELS", CHAN_LEVELS_SYNTAX); + } + return MOD_CONT; } MODULE_INIT("cs_access", CSAccess) diff --git a/src/core/cs_akick.c b/src/core/cs_akick.c index 09584ef5b..94fa7c826 100644 --- a/src/core/cs_akick.c +++ b/src/core/cs_akick.c @@ -46,7 +46,7 @@ class CSAKick : public Module **/ void myChanServHelp(User * u) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_AKICK); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_AKICK); } /** @@ -57,598 +57,598 @@ void myChanServHelp(User * u) /* `last' is set to the last index this routine was called with */ int akick_del(User * u, AutoKick * akick) { - if (!(akick->flags & AK_USED)) - return 0; - if (akick->flags & AK_ISNICK) { - akick->u.nc = NULL; - } else { - free(akick->u.mask); - akick->u.mask = NULL; - } - if (akick->reason) { - free(akick->reason); - akick->reason = NULL; - } - if (akick->creator) { - free(akick->creator); - akick->creator = NULL; - } - akick->addtime = 0; - akick->flags = 0; - return 1; + if (!(akick->flags & AK_USED)) + return 0; + if (akick->flags & AK_ISNICK) { + akick->u.nc = NULL; + } else { + free(akick->u.mask); + akick->u.mask = NULL; + } + if (akick->reason) { + free(akick->reason); + akick->reason = NULL; + } + if (akick->creator) { + free(akick->creator); + akick->creator = NULL; + } + akick->addtime = 0; + akick->flags = 0; + return 1; } int akick_del_callback(User * u, int num, va_list args) { - ChannelInfo *ci = va_arg(args, ChannelInfo *); - int *last = va_arg(args, int *); + ChannelInfo *ci = va_arg(args, ChannelInfo *); + int *last = va_arg(args, int *); - *last = num; + *last = num; - if (num < 1 || num > ci->akickcount) - return 0; + if (num < 1 || num > ci->akickcount) + return 0; - return akick_del(u, &ci->akick[num - 1]); + return akick_del(u, &ci->akick[num - 1]); } int akick_list(User * u, int index, ChannelInfo * ci, int *sent_header) { - AutoKick *akick = &ci->akick[index]; - - if (!(akick->flags & AK_USED)) - return 0; - if (!*sent_header) { - notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_HEADER, ci->name); - *sent_header = 1; - } - - notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_FORMAT, index + 1, - ((akick->flags & AK_ISNICK) ? akick->u.nc-> - display : akick->u.mask), - (akick->reason ? akick-> - reason : getstring(u->na, NO_REASON))); - return 1; + AutoKick *akick = &ci->akick[index]; + + if (!(akick->flags & AK_USED)) + return 0; + if (!*sent_header) { + notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_HEADER, ci->name); + *sent_header = 1; + } + + notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_FORMAT, index + 1, + ((akick->flags & AK_ISNICK) ? akick->u.nc-> + display : akick->u.mask), + (akick->reason ? akick-> + reason : getstring(u->na, NO_REASON))); + return 1; } int akick_list_callback(User * u, int num, va_list args) { - ChannelInfo *ci = va_arg(args, ChannelInfo *); - int *sent_header = va_arg(args, int *); - if (num < 1 || num > ci->akickcount) - return 0; - return akick_list(u, num - 1, ci, sent_header); + ChannelInfo *ci = va_arg(args, ChannelInfo *); + int *sent_header = va_arg(args, int *); + if (num < 1 || num > ci->akickcount) + return 0; + return akick_list(u, num - 1, ci, sent_header); } int akick_view(User * u, int index, ChannelInfo * ci, int *sent_header) { - AutoKick *akick = &ci->akick[index]; - char timebuf[64]; - struct tm tm; - - if (!(akick->flags & AK_USED)) - return 0; - if (!*sent_header) { - notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_HEADER, ci->name); - *sent_header = 1; - } - - if (akick->addtime) { - tm = *localtime(&akick->addtime); - strftime_lang(timebuf, sizeof(timebuf), u, - STRFTIME_SHORT_DATE_FORMAT, &tm); - } else { - snprintf(timebuf, sizeof(timebuf), "%s", getstring(u->na, UNKNOWN)); - } - - notice_lang(s_ChanServ, u, - ((akick-> - flags & AK_STUCK) ? CHAN_AKICK_VIEW_FORMAT_STUCK : - CHAN_AKICK_VIEW_FORMAT), index + 1, - ((akick->flags & AK_ISNICK) ? akick->u.nc-> - display : akick->u.mask), - akick->creator ? akick->creator : getstring(u->na, - UNKNOWN), - timebuf, - (akick->reason ? akick-> - reason : getstring(u->na, NO_REASON))); - return 1; + AutoKick *akick = &ci->akick[index]; + char timebuf[64]; + struct tm tm; + + if (!(akick->flags & AK_USED)) + return 0; + if (!*sent_header) { + notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_HEADER, ci->name); + *sent_header = 1; + } + + if (akick->addtime) { + tm = *localtime(&akick->addtime); + strftime_lang(timebuf, sizeof(timebuf), u, + STRFTIME_SHORT_DATE_FORMAT, &tm); + } else { + snprintf(timebuf, sizeof(timebuf), "%s", getstring(u->na, UNKNOWN)); + } + + notice_lang(s_ChanServ, u, + ((akick-> + flags & AK_STUCK) ? CHAN_AKICK_VIEW_FORMAT_STUCK : + CHAN_AKICK_VIEW_FORMAT), index + 1, + ((akick->flags & AK_ISNICK) ? akick->u.nc-> + display : akick->u.mask), + akick->creator ? akick->creator : getstring(u->na, + UNKNOWN), + timebuf, + (akick->reason ? akick-> + reason : getstring(u->na, NO_REASON))); + return 1; } int akick_view_callback(User * u, int num, va_list args) { - ChannelInfo *ci = va_arg(args, ChannelInfo *); - int *sent_header = va_arg(args, int *); - if (num < 1 || num > ci->akickcount) - return 0; - return akick_view(u, num - 1, ci, sent_header); + ChannelInfo *ci = va_arg(args, ChannelInfo *); + int *sent_header = va_arg(args, int *); + if (num < 1 || num > ci->akickcount) + return 0; + return akick_view(u, num - 1, ci, sent_header); } int do_akick(User * u) { - char *chan = strtok(NULL, " "); - char *cmd = strtok(NULL, " "); - char *mask = strtok(NULL, " "); - char *reason = strtok(NULL, ""); - ChannelInfo *ci; - AutoKick *akick; - int i; - Channel *c; - struct c_userlist *cu = NULL; - struct c_userlist *next; - User *u2; - const char *argv[3]; - int count = 0; - - if (!cmd || (!mask && (!stricmp(cmd, "ADD") || !stricmp(cmd, "STICK") - || !stricmp(cmd, "UNSTICK") - || !stricmp(cmd, "DEL")))) { - - syntax_error(s_ChanServ, u, "AKICK", CHAN_AKICK_SYNTAX); - } else if (!(ci = cs_findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); - } else if (!check_access(u, ci, CA_AKICK) && !is_services_admin(u)) { - notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else if (stricmp(cmd, "ADD") == 0) { - NickAlias *na = findnick(mask), *na2; - NickCore *nc = NULL; - char *nick, *user, *host; - int freemask = 0; - - if (readonly) { - notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED); - return MOD_CONT; - } - - if (!na) { - split_usermask(mask, &nick, &user, &host); - mask = - (char *)scalloc(strlen(nick) + strlen(user) + strlen(host) + 3, 1); - freemask = 1; - sprintf(mask, "%s!%s@%s", nick, user, host); - free(nick); - free(user); - free(host); - } else { - if (na->status & NS_VERBOTEN) { - notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, mask); - return MOD_CONT; - } - nc = na->nc; - } - - /* Check excepts BEFORE we get this far */ - if (ircd->except) { - if (is_excepted_mask(ci, mask) == 1) { - notice_lang(s_ChanServ, u, CHAN_EXCEPTED, mask, chan); - if (freemask) - free(mask); - return MOD_CONT; - } - } - - /* Check whether target nick has equal/higher access - * or whether the mask matches a user with higher/equal access - Viper */ - if ((ci->flags & CI_PEACE) && nc) { - if ((nc == ci->founder) || (get_access_nc(nc, ci) >= get_access(u, ci))) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - if (freemask) - free(mask); - return MOD_CONT; - } - } else if ((ci->flags & CI_PEACE)) { - char buf[BUFSIZE]; - /* Match against all currently online users with equal or - * higher access. - Viper */ - for (i = 0; i < 1024; i++) { - for (u2 = userlist[i]; u2; u2 = u2->next) { - if (is_founder(u2, ci) || (get_access(u2, ci) >= get_access(u, ci))) { - if (match_usermask(mask, u2)) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - free(mask); - return MOD_CONT; - } - } - } - } - - /* Match against the lastusermask of all nickalias's with equal - * or higher access. - Viper */ - for (i = 0; i < 1024; i++) { - for (na2 = nalists[i]; na2; na2 = na2->next) { - if (na2->status & NS_VERBOTEN) - continue; - - if (na2->nc && ((na2->nc == ci->founder) || (get_access_nc(na2->nc, ci) - >= get_access(u, ci)))) { - snprintf(buf, BUFSIZE, "%s!%s", na2->nick, na2->last_usermask); - if (match_wild_nocase(mask, buf)) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - free(mask); - return MOD_CONT; - } - } - } - } - } - - for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { - if (!(akick->flags & AK_USED)) - continue; - if ((akick->flags & AK_ISNICK) ? akick->u.nc == nc - : stricmp(akick->u.mask, mask) == 0) { - notice_lang(s_ChanServ, u, CHAN_AKICK_ALREADY_EXISTS, - (akick->flags & AK_ISNICK) ? akick->u.nc-> - display : akick->u.mask, chan); - if (freemask) - free(mask); - return MOD_CONT; - } - } - - /* All entries should be in use so we don't have to go over - * the entire list. We simply add new entries at the end. */ - if (ci->akickcount >= CSAutokickMax) { - notice_lang(s_ChanServ, u, CHAN_AKICK_REACHED_LIMIT, CSAutokickMax); - if (freemask) - free(mask); - return MOD_CONT; - } - ci->akickcount++; - ci->akick = - (AutoKick *)srealloc(ci->akick, sizeof(AutoKick) * ci->akickcount); - akick = &ci->akick[i]; - akick->flags = AK_USED; - if (nc) { - akick->flags |= AK_ISNICK; - akick->u.nc = nc; - } else { - akick->u.mask = sstrdup(mask); - } - akick->creator = sstrdup(u->nick); - akick->addtime = time(NULL); - if (reason) { - if (strlen(reason) > 200) - reason[200] = '\0'; - akick->reason = sstrdup(reason); - } else { - akick->reason = NULL; - } - - /* Auto ENFORCE #63 */ - c = findchan(ci->name); - if (c) { - cu = c->users; - while (cu) { - next = cu->next; - if (check_kick(cu->user, c->name, c->creation_time)) { - argv[0] = sstrdup(c->name); - argv[1] = sstrdup(cu->user->nick); - if (akick->reason) - argv[2] = sstrdup(akick->reason); - else - argv[2] = sstrdup("none"); - - do_kick(s_ChanServ, 3, argv); + char *chan = strtok(NULL, " "); + char *cmd = strtok(NULL, " "); + char *mask = strtok(NULL, " "); + char *reason = strtok(NULL, ""); + ChannelInfo *ci; + AutoKick *akick; + int i; + Channel *c; + struct c_userlist *cu = NULL; + struct c_userlist *next; + User *u2; + const char *argv[3]; + int count = 0; + + if (!cmd || (!mask && (!stricmp(cmd, "ADD") || !stricmp(cmd, "STICK") + || !stricmp(cmd, "UNSTICK") + || !stricmp(cmd, "DEL")))) { + + syntax_error(s_ChanServ, u, "AKICK", CHAN_AKICK_SYNTAX); + } else if (!(ci = cs_findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); + } else if (!check_access(u, ci, CA_AKICK) && !is_services_admin(u)) { + notice_lang(s_ChanServ, u, ACCESS_DENIED); + } else if (stricmp(cmd, "ADD") == 0) { + NickAlias *na = findnick(mask), *na2; + NickCore *nc = NULL; + char *nick, *user, *host; + int freemask = 0; + + if (readonly) { + notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED); + return MOD_CONT; + } + + if (!na) { + split_usermask(mask, &nick, &user, &host); + mask = + (char *)scalloc(strlen(nick) + strlen(user) + strlen(host) + 3, 1); + freemask = 1; + sprintf(mask, "%s!%s@%s", nick, user, host); + free(nick); + free(user); + free(host); + } else { + if (na->status & NS_VERBOTEN) { + notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, mask); + return MOD_CONT; + } + nc = na->nc; + } + + /* Check excepts BEFORE we get this far */ + if (ircd->except) { + if (is_excepted_mask(ci, mask) == 1) { + notice_lang(s_ChanServ, u, CHAN_EXCEPTED, mask, chan); + if (freemask) + free(mask); + return MOD_CONT; + } + } + + /* Check whether target nick has equal/higher access + * or whether the mask matches a user with higher/equal access - Viper */ + if ((ci->flags & CI_PEACE) && nc) { + if ((nc == ci->founder) || (get_access_nc(nc, ci) >= get_access(u, ci))) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + if (freemask) + free(mask); + return MOD_CONT; + } + } else if ((ci->flags & CI_PEACE)) { + char buf[BUFSIZE]; + /* Match against all currently online users with equal or + * higher access. - Viper */ + for (i = 0; i < 1024; i++) { + for (u2 = userlist[i]; u2; u2 = u2->next) { + if (is_founder(u2, ci) || (get_access(u2, ci) >= get_access(u, ci))) { + if (match_usermask(mask, u2)) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + free(mask); + return MOD_CONT; + } + } + } + } + + /* Match against the lastusermask of all nickalias's with equal + * or higher access. - Viper */ + for (i = 0; i < 1024; i++) { + for (na2 = nalists[i]; na2; na2 = na2->next) { + if (na2->status & NS_VERBOTEN) + continue; + + if (na2->nc && ((na2->nc == ci->founder) || (get_access_nc(na2->nc, ci) + >= get_access(u, ci)))) { + snprintf(buf, BUFSIZE, "%s!%s", na2->nick, na2->last_usermask); + if (match_wild_nocase(mask, buf)) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + free(mask); + return MOD_CONT; + } + } + } + } + } + + for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { + if (!(akick->flags & AK_USED)) + continue; + if ((akick->flags & AK_ISNICK) ? akick->u.nc == nc + : stricmp(akick->u.mask, mask) == 0) { + notice_lang(s_ChanServ, u, CHAN_AKICK_ALREADY_EXISTS, + (akick->flags & AK_ISNICK) ? akick->u.nc-> + display : akick->u.mask, chan); + if (freemask) + free(mask); + return MOD_CONT; + } + } + + /* All entries should be in use so we don't have to go over + * the entire list. We simply add new entries at the end. */ + if (ci->akickcount >= CSAutokickMax) { + notice_lang(s_ChanServ, u, CHAN_AKICK_REACHED_LIMIT, CSAutokickMax); + if (freemask) + free(mask); + return MOD_CONT; + } + ci->akickcount++; + ci->akick = + (AutoKick *)srealloc(ci->akick, sizeof(AutoKick) * ci->akickcount); + akick = &ci->akick[i]; + akick->flags = AK_USED; + if (nc) { + akick->flags |= AK_ISNICK; + akick->u.nc = nc; + } else { + akick->u.mask = sstrdup(mask); + } + akick->creator = sstrdup(u->nick); + akick->addtime = time(NULL); + if (reason) { + if (strlen(reason) > 200) + reason[200] = '\0'; + akick->reason = sstrdup(reason); + } else { + akick->reason = NULL; + } + + /* Auto ENFORCE #63 */ + c = findchan(ci->name); + if (c) { + cu = c->users; + while (cu) { + next = cu->next; + if (check_kick(cu->user, c->name, c->creation_time)) { + argv[0] = sstrdup(c->name); + argv[1] = sstrdup(cu->user->nick); + if (akick->reason) + argv[2] = sstrdup(akick->reason); + else + argv[2] = sstrdup("none"); + + do_kick(s_ChanServ, 3, argv); // XXX: casting is necessary thanks to strict g++ stuff, really, we should be using std::string here though. - free((void *)argv[2]); - free((void *)argv[1]); - free((void *)argv[0]); - count++; - - } - cu = next; - } - } - notice_lang(s_ChanServ, u, CHAN_AKICK_ADDED, mask, chan); - - if (count) - notice_lang(s_ChanServ, u, CHAN_AKICK_ENFORCE_DONE, chan, - count); - - if (freemask) - free(mask); - - } else if (stricmp(cmd, "STICK") == 0) { - NickAlias *na; - NickCore *nc; - - if (readonly) { - notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED); - return MOD_CONT; - } - - if (ci->akickcount == 0) { - notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name); - return MOD_CONT; - } - - na = findnick(mask); - nc = (na ? na->nc : NULL); - - for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { - if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK)) - continue; - if (!stricmp(akick->u.mask, mask)) - break; - } - - if (i == ci->akickcount) { - notice_lang(s_ChanServ, u, CHAN_AKICK_NOT_FOUND, mask, - ci->name); - return MOD_CONT; - } - - akick->flags |= AK_STUCK; - notice_lang(s_ChanServ, u, CHAN_AKICK_STUCK, akick->u.mask, - ci->name); - - if (ci->c) - stick_mask(ci, akick); - } else if (stricmp(cmd, "UNSTICK") == 0) { - NickAlias *na; - NickCore *nc; - - if (readonly) { - notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED); - return MOD_CONT; - } - - if (ci->akickcount == 0) { - notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name); - return MOD_CONT; - } - - na = findnick(mask); - nc = (na ? na->nc : NULL); - - for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { - if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK)) - continue; - if (!stricmp(akick->u.mask, mask)) - break; - } - - if (i == ci->akickcount) { - notice_lang(s_ChanServ, u, CHAN_AKICK_NOT_FOUND, mask, - ci->name); - return MOD_CONT; - } - - akick->flags &= ~AK_STUCK; - notice_lang(s_ChanServ, u, CHAN_AKICK_UNSTUCK, akick->u.mask, - ci->name); - - } else if (stricmp(cmd, "DEL") == 0) { - int deleted, a, b; - - if (readonly) { - notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED); - return MOD_CONT; - } - - if (ci->akickcount == 0) { - notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, chan); - return MOD_CONT; - } - - /* Special case: is it a number/list? Only do search if it isn't. */ - if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) { - int last = -1; - deleted = process_numlist(mask, &count, akick_del_callback, u, - ci, &last); - if (!deleted) { - if (count == 1) { - notice_lang(s_ChanServ, u, CHAN_AKICK_NO_SUCH_ENTRY, - last, ci->name); - } else { - notice_lang(s_ChanServ, u, CHAN_AKICK_NO_MATCH, - ci->name); - } - } else if (deleted == 1) { - notice_lang(s_ChanServ, u, CHAN_AKICK_DELETED_ONE, - ci->name); - } else { - notice_lang(s_ChanServ, u, CHAN_AKICK_DELETED_SEVERAL, - deleted, ci->name); - } - } else { - NickAlias *na = findnick(mask); - NickCore *nc = (na ? na->nc : NULL); - - for (akick = ci->akick, i = 0; i < ci->akickcount; - akick++, i++) { - if (!(akick->flags & AK_USED)) - continue; - if (((akick->flags & AK_ISNICK) && akick->u.nc == nc) - || (!(akick->flags & AK_ISNICK) - && stricmp(akick->u.mask, mask) == 0)) - break; - } - if (i == ci->akickcount) { - notice_lang(s_ChanServ, u, CHAN_AKICK_NOT_FOUND, mask, - chan); - return MOD_CONT; - } - notice_lang(s_ChanServ, u, CHAN_AKICK_DELETED, mask, chan); - akick_del(u, akick); - deleted = 1; - } - if (deleted) { - /* Reordering - DrStein */ - for (b = 0; b < ci->akickcount; b++) { - if (ci->akick[b].flags & AK_USED) { - for (a = 0; a < ci->akickcount; a++) { - if (a > b) - break; - if (!(ci->akick[a].flags & AK_USED)) { - ci->akick[a].flags = ci->akick[b].flags; - if (ci->akick[b].flags & AK_ISNICK) { - ci->akick[a].u.nc = ci->akick[b].u.nc; - } else { - ci->akick[a].u.mask = - sstrdup(ci->akick[b].u.mask); - } - /* maybe we should first check whether there - is a reason before we sstdrup it -Certus */ - if (ci->akick[b].reason) - ci->akick[a].reason = - sstrdup(ci->akick[b].reason); - else - ci->akick[a].reason = NULL; - ci->akick[a].creator = - sstrdup(ci->akick[b].creator); - ci->akick[a].addtime = ci->akick[b].addtime; - - akick_del(u, &ci->akick[b]); - break; - } - } - } - } - /* After reordering only the entries at the end could still be empty. - * We ll free the places no longer in use... - Viper */ - for (i = ci->akickcount - 1; i >= 0; i--) { - if (ci->akick[i].flags & AK_USED) - break; - - ci->akickcount--; - } - ci->akick = - (AutoKick *)srealloc(ci->akick,sizeof(AutoKick) * ci->akickcount); - } - } else if (stricmp(cmd, "LIST") == 0) { - int sent_header = 0; - - if (ci->akickcount == 0) { - notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, chan); - return MOD_CONT; - } - if (mask && isdigit(*mask) && - strspn(mask, "1234567890,-") == strlen(mask)) { - process_numlist(mask, NULL, akick_list_callback, u, ci, - &sent_header); - } else { - for (akick = ci->akick, i = 0; i < ci->akickcount; - akick++, i++) { - if (!(akick->flags & AK_USED)) - continue; - if (mask) { - if (!(akick->flags & AK_ISNICK) - && !match_wild_nocase(mask, akick->u.mask)) - continue; - if ((akick->flags & AK_ISNICK) - && !match_wild_nocase(mask, akick->u.nc->display)) - continue; - } - akick_list(u, i, ci, &sent_header); - } - } - if (!sent_header) - notice_lang(s_ChanServ, u, CHAN_AKICK_NO_MATCH, chan); - - } else if (stricmp(cmd, "VIEW") == 0) { - int sent_header = 0; - - if (ci->akickcount == 0) { - notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, chan); - return MOD_CONT; - } - if (mask && isdigit(*mask) && - strspn(mask, "1234567890,-") == strlen(mask)) { - process_numlist(mask, NULL, akick_view_callback, u, ci, - &sent_header); - } else { - for (akick = ci->akick, i = 0; i < ci->akickcount; - akick++, i++) { - if (!(akick->flags & AK_USED)) - continue; - if (mask) { - if (!(akick->flags & AK_ISNICK) - && !match_wild_nocase(mask, akick->u.mask)) - continue; - if ((akick->flags & AK_ISNICK) - && !match_wild_nocase(mask, akick->u.nc->display)) - continue; - } - akick_view(u, i, ci, &sent_header); - } - } - if (!sent_header) - notice_lang(s_ChanServ, u, CHAN_AKICK_NO_MATCH, chan); - - } else if (stricmp(cmd, "ENFORCE") == 0) { - c = findchan(ci->name); - cu = NULL; - count = 0; - - if (!c) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, ci->name); - return MOD_CONT; - } - - cu = c->users; - - while (cu) { - next = cu->next; - if (check_kick(cu->user, c->name, c->creation_time)) { - argv[0] = sstrdup(c->name); - argv[1] = sstrdup(cu->user->nick); - argv[2] = sstrdup(CSAutokickReason); - - do_kick(s_ChanServ, 3, argv); - - free((void *)argv[2]); - free((void *)argv[1]); - free((void *)argv[0]); - - count++; - } - cu = next; - } - - notice_lang(s_ChanServ, u, CHAN_AKICK_ENFORCE_DONE, chan, count); - - } else if (stricmp(cmd, "CLEAR") == 0) { - - if (readonly) { - notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED); - return MOD_CONT; - } - - for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { - if (!(akick->flags & AK_USED)) - continue; - akick_del(u, akick); - } - - free(ci->akick); - ci->akick = NULL; - ci->akickcount = 0; - - notice_lang(s_ChanServ, u, CHAN_AKICK_CLEAR, ci->name); - - } else { - syntax_error(s_ChanServ, u, "AKICK", CHAN_AKICK_SYNTAX); - } - return MOD_CONT; + free((void *)argv[2]); + free((void *)argv[1]); + free((void *)argv[0]); + count++; + + } + cu = next; + } + } + notice_lang(s_ChanServ, u, CHAN_AKICK_ADDED, mask, chan); + + if (count) + notice_lang(s_ChanServ, u, CHAN_AKICK_ENFORCE_DONE, chan, + count); + + if (freemask) + free(mask); + + } else if (stricmp(cmd, "STICK") == 0) { + NickAlias *na; + NickCore *nc; + + if (readonly) { + notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED); + return MOD_CONT; + } + + if (ci->akickcount == 0) { + notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name); + return MOD_CONT; + } + + na = findnick(mask); + nc = (na ? na->nc : NULL); + + for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { + if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK)) + continue; + if (!stricmp(akick->u.mask, mask)) + break; + } + + if (i == ci->akickcount) { + notice_lang(s_ChanServ, u, CHAN_AKICK_NOT_FOUND, mask, + ci->name); + return MOD_CONT; + } + + akick->flags |= AK_STUCK; + notice_lang(s_ChanServ, u, CHAN_AKICK_STUCK, akick->u.mask, + ci->name); + + if (ci->c) + stick_mask(ci, akick); + } else if (stricmp(cmd, "UNSTICK") == 0) { + NickAlias *na; + NickCore *nc; + + if (readonly) { + notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED); + return MOD_CONT; + } + + if (ci->akickcount == 0) { + notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, ci->name); + return MOD_CONT; + } + + na = findnick(mask); + nc = (na ? na->nc : NULL); + + for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { + if (!(akick->flags & AK_USED) || (akick->flags & AK_ISNICK)) + continue; + if (!stricmp(akick->u.mask, mask)) + break; + } + + if (i == ci->akickcount) { + notice_lang(s_ChanServ, u, CHAN_AKICK_NOT_FOUND, mask, + ci->name); + return MOD_CONT; + } + + akick->flags &= ~AK_STUCK; + notice_lang(s_ChanServ, u, CHAN_AKICK_UNSTUCK, akick->u.mask, + ci->name); + + } else if (stricmp(cmd, "DEL") == 0) { + int deleted, a, b; + + if (readonly) { + notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED); + return MOD_CONT; + } + + if (ci->akickcount == 0) { + notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, chan); + return MOD_CONT; + } + + /* Special case: is it a number/list? Only do search if it isn't. */ + if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) { + int last = -1; + deleted = process_numlist(mask, &count, akick_del_callback, u, + ci, &last); + if (!deleted) { + if (count == 1) { + notice_lang(s_ChanServ, u, CHAN_AKICK_NO_SUCH_ENTRY, + last, ci->name); + } else { + notice_lang(s_ChanServ, u, CHAN_AKICK_NO_MATCH, + ci->name); + } + } else if (deleted == 1) { + notice_lang(s_ChanServ, u, CHAN_AKICK_DELETED_ONE, + ci->name); + } else { + notice_lang(s_ChanServ, u, CHAN_AKICK_DELETED_SEVERAL, + deleted, ci->name); + } + } else { + NickAlias *na = findnick(mask); + NickCore *nc = (na ? na->nc : NULL); + + for (akick = ci->akick, i = 0; i < ci->akickcount; + akick++, i++) { + if (!(akick->flags & AK_USED)) + continue; + if (((akick->flags & AK_ISNICK) && akick->u.nc == nc) + || (!(akick->flags & AK_ISNICK) + && stricmp(akick->u.mask, mask) == 0)) + break; + } + if (i == ci->akickcount) { + notice_lang(s_ChanServ, u, CHAN_AKICK_NOT_FOUND, mask, + chan); + return MOD_CONT; + } + notice_lang(s_ChanServ, u, CHAN_AKICK_DELETED, mask, chan); + akick_del(u, akick); + deleted = 1; + } + if (deleted) { + /* Reordering - DrStein */ + for (b = 0; b < ci->akickcount; b++) { + if (ci->akick[b].flags & AK_USED) { + for (a = 0; a < ci->akickcount; a++) { + if (a > b) + break; + if (!(ci->akick[a].flags & AK_USED)) { + ci->akick[a].flags = ci->akick[b].flags; + if (ci->akick[b].flags & AK_ISNICK) { + ci->akick[a].u.nc = ci->akick[b].u.nc; + } else { + ci->akick[a].u.mask = + sstrdup(ci->akick[b].u.mask); + } + /* maybe we should first check whether there + is a reason before we sstdrup it -Certus */ + if (ci->akick[b].reason) + ci->akick[a].reason = + sstrdup(ci->akick[b].reason); + else + ci->akick[a].reason = NULL; + ci->akick[a].creator = + sstrdup(ci->akick[b].creator); + ci->akick[a].addtime = ci->akick[b].addtime; + + akick_del(u, &ci->akick[b]); + break; + } + } + } + } + /* After reordering only the entries at the end could still be empty. + * We ll free the places no longer in use... - Viper */ + for (i = ci->akickcount - 1; i >= 0; i--) { + if (ci->akick[i].flags & AK_USED) + break; + + ci->akickcount--; + } + ci->akick = + (AutoKick *)srealloc(ci->akick,sizeof(AutoKick) * ci->akickcount); + } + } else if (stricmp(cmd, "LIST") == 0) { + int sent_header = 0; + + if (ci->akickcount == 0) { + notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, chan); + return MOD_CONT; + } + if (mask && isdigit(*mask) && + strspn(mask, "1234567890,-") == strlen(mask)) { + process_numlist(mask, NULL, akick_list_callback, u, ci, + &sent_header); + } else { + for (akick = ci->akick, i = 0; i < ci->akickcount; + akick++, i++) { + if (!(akick->flags & AK_USED)) + continue; + if (mask) { + if (!(akick->flags & AK_ISNICK) + && !match_wild_nocase(mask, akick->u.mask)) + continue; + if ((akick->flags & AK_ISNICK) + && !match_wild_nocase(mask, akick->u.nc->display)) + continue; + } + akick_list(u, i, ci, &sent_header); + } + } + if (!sent_header) + notice_lang(s_ChanServ, u, CHAN_AKICK_NO_MATCH, chan); + + } else if (stricmp(cmd, "VIEW") == 0) { + int sent_header = 0; + + if (ci->akickcount == 0) { + notice_lang(s_ChanServ, u, CHAN_AKICK_LIST_EMPTY, chan); + return MOD_CONT; + } + if (mask && isdigit(*mask) && + strspn(mask, "1234567890,-") == strlen(mask)) { + process_numlist(mask, NULL, akick_view_callback, u, ci, + &sent_header); + } else { + for (akick = ci->akick, i = 0; i < ci->akickcount; + akick++, i++) { + if (!(akick->flags & AK_USED)) + continue; + if (mask) { + if (!(akick->flags & AK_ISNICK) + && !match_wild_nocase(mask, akick->u.mask)) + continue; + if ((akick->flags & AK_ISNICK) + && !match_wild_nocase(mask, akick->u.nc->display)) + continue; + } + akick_view(u, i, ci, &sent_header); + } + } + if (!sent_header) + notice_lang(s_ChanServ, u, CHAN_AKICK_NO_MATCH, chan); + + } else if (stricmp(cmd, "ENFORCE") == 0) { + c = findchan(ci->name); + cu = NULL; + count = 0; + + if (!c) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, ci->name); + return MOD_CONT; + } + + cu = c->users; + + while (cu) { + next = cu->next; + if (check_kick(cu->user, c->name, c->creation_time)) { + argv[0] = sstrdup(c->name); + argv[1] = sstrdup(cu->user->nick); + argv[2] = sstrdup(CSAutokickReason); + + do_kick(s_ChanServ, 3, argv); + + free((void *)argv[2]); + free((void *)argv[1]); + free((void *)argv[0]); + + count++; + } + cu = next; + } + + notice_lang(s_ChanServ, u, CHAN_AKICK_ENFORCE_DONE, chan, count); + + } else if (stricmp(cmd, "CLEAR") == 0) { + + if (readonly) { + notice_lang(s_ChanServ, u, CHAN_AKICK_DISABLED); + return MOD_CONT; + } + + for (akick = ci->akick, i = 0; i < ci->akickcount; akick++, i++) { + if (!(akick->flags & AK_USED)) + continue; + akick_del(u, akick); + } + + free(ci->akick); + ci->akick = NULL; + ci->akickcount = 0; + + notice_lang(s_ChanServ, u, CHAN_AKICK_CLEAR, ci->name); + + } else { + syntax_error(s_ChanServ, u, "AKICK", CHAN_AKICK_SYNTAX); + } + return MOD_CONT; } int get_access_nc(NickCore *nc, ChannelInfo *ci) { - ChanAccess *access; - if (!ci || !nc) - return 0; + ChanAccess *access; + if (!ci || !nc) + return 0; - if ((access = get_access_entry(nc, ci))) - return access->level; - return 0; + if ((access = get_access_entry(nc, ci))) + return access->level; + return 0; } diff --git a/src/core/cs_ban.c b/src/core/cs_ban.c index b5b921900..4f8db1fd0 100644 --- a/src/core/cs_ban.c +++ b/src/core/cs_ban.c @@ -46,8 +46,8 @@ class CSBan : public Module **/ void myChanServHelp(User * u) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_BAN); - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_UNBAN); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_BAN); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_UNBAN); } /** @@ -57,132 +57,132 @@ void myChanServHelp(User * u) **/ int do_ban(User * u) { - char *chan = strtok(NULL, " "); - char *params = strtok(NULL, " "); - char *reason = strtok(NULL, ""); - - Channel *c; - ChannelInfo *ci; - User *u2; - - int is_same; - - if (!reason) { - reason = (char *)"Requested"; // XXX unsafe cast -- w00t - } else { - if (strlen(reason) > 200) - reason[200] = '\0'; - } - - if (!chan) { - struct u_chanlist *uc, *next; - - /* Bans the user on every channels he is on. */ - - for (uc = u->chans; uc; uc = next) { - next = uc->next; - if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN) - && check_access(u, ci, CA_BANME)) { - const char *av[3]; - char mask[BUFSIZE]; - - /* - * Dont ban/kick the user on channels where he is excepted - * to prevent services <-> server wars. - */ - if (ircd->except) { - if (is_excepted(ci, u)) - notice_lang(s_ChanServ, u, CHAN_EXCEPTED, - u->nick, ci->name); - continue; - } - if (is_protected(u)) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - continue; - } - - av[0] = "+b"; - get_idealban(ci, u, mask, sizeof(mask)); - av[1] = mask; - ircdproto->SendMode(whosends(ci), uc->chan->name, "+b %s", - av[1]); - chan_set_modes(s_ChanServ, uc->chan, 2, av, 1); - - if ((ci->flags & CI_SIGNKICK) - || ((ci->flags & CI_SIGNKICK_LEVEL) - && !check_access(u, ci, CA_SIGNKICK))) - ircdproto->SendKick(whosends(ci), ci->name, u->nick, - "%s (%s)", reason, u->nick); - else - ircdproto->SendKick(whosends(ci), ci->name, u->nick, "%s", - reason); + char *chan = strtok(NULL, " "); + char *params = strtok(NULL, " "); + char *reason = strtok(NULL, ""); + + Channel *c; + ChannelInfo *ci; + User *u2; + + int is_same; + + if (!reason) { + reason = (char *)"Requested"; // XXX unsafe cast -- w00t + } else { + if (strlen(reason) > 200) + reason[200] = '\0'; + } + + if (!chan) { + struct u_chanlist *uc, *next; + + /* Bans the user on every channels he is on. */ + + for (uc = u->chans; uc; uc = next) { + next = uc->next; + if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN) + && check_access(u, ci, CA_BANME)) { + const char *av[3]; + char mask[BUFSIZE]; + + /* + * Dont ban/kick the user on channels where he is excepted + * to prevent services <-> server wars. + */ + if (ircd->except) { + if (is_excepted(ci, u)) + notice_lang(s_ChanServ, u, CHAN_EXCEPTED, + u->nick, ci->name); + continue; + } + if (is_protected(u)) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + continue; + } + + av[0] = "+b"; + get_idealban(ci, u, mask, sizeof(mask)); + av[1] = mask; + ircdproto->SendMode(whosends(ci), uc->chan->name, "+b %s", + av[1]); + chan_set_modes(s_ChanServ, uc->chan, 2, av, 1); + + if ((ci->flags & CI_SIGNKICK) + || ((ci->flags & CI_SIGNKICK_LEVEL) + && !check_access(u, ci, CA_SIGNKICK))) + ircdproto->SendKick(whosends(ci), ci->name, u->nick, + "%s (%s)", reason, u->nick); + else + ircdproto->SendKick(whosends(ci), ci->name, u->nick, "%s", + reason); const char *kav[4]; - kav[0] = ci->name; - kav[1] = u->nick; - kav[2] = reason; - do_kick(s_ChanServ, 3, kav); - } - } - - return MOD_CONT; - } else if (!params) { - params = u->nick; - } - - is_same = (params == u->nick) ? 1 : (stricmp(params, u->nick) == 0); - - if (!(c = findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); - } else if (!(ci = c->ci)) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); - } else if (is_same ? !(u2 = u) : !(u2 = finduser(params))) { - notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, params); - } else if (!is_same ? !check_access(u, ci, CA_BAN) : - !check_access(u, ci, CA_BANME)) { - notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else if (!is_same && (ci->flags & CI_PEACE) - && (get_access(u2, ci) >= get_access(u, ci))) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - /* - * Dont ban/kick the user on channels where he is excepted - * to prevent services <-> server wars. - */ - } else if (ircd->except && is_excepted(ci, u2)) { - notice_lang(s_ChanServ, u, CHAN_EXCEPTED, u2->nick, ci->name); - } else if (ircd->protectedumode && is_protected(u2)) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - } else { - const char *av[3]; - char mask[BUFSIZE]; - - av[0] = "+b"; - get_idealban(ci, u2, mask, sizeof(mask)); - av[1] = mask; - ircdproto->SendMode(whosends(ci), c->name, "+b %s", av[1]); - chan_set_modes(s_ChanServ, c, 2, av, 1); - - /* We still allow host banning while not allowing to kick */ - if (!is_on_chan(c, u2)) - return MOD_CONT; - - if ((ci->flags & CI_SIGNKICK) - || ((ci->flags & CI_SIGNKICK_LEVEL) - && !check_access(u, ci, CA_SIGNKICK))) - ircdproto->SendKick(whosends(ci), ci->name, params, "%s (%s)", - reason, u->nick); - else - ircdproto->SendKick(whosends(ci), ci->name, params, "%s", reason); + kav[0] = ci->name; + kav[1] = u->nick; + kav[2] = reason; + do_kick(s_ChanServ, 3, kav); + } + } + + return MOD_CONT; + } else if (!params) { + params = u->nick; + } + + is_same = (params == u->nick) ? 1 : (stricmp(params, u->nick) == 0); + + if (!(c = findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); + } else if (!(ci = c->ci)) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); + } else if (is_same ? !(u2 = u) : !(u2 = finduser(params))) { + notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, params); + } else if (!is_same ? !check_access(u, ci, CA_BAN) : + !check_access(u, ci, CA_BANME)) { + notice_lang(s_ChanServ, u, ACCESS_DENIED); + } else if (!is_same && (ci->flags & CI_PEACE) + && (get_access(u2, ci) >= get_access(u, ci))) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + /* + * Dont ban/kick the user on channels where he is excepted + * to prevent services <-> server wars. + */ + } else if (ircd->except && is_excepted(ci, u2)) { + notice_lang(s_ChanServ, u, CHAN_EXCEPTED, u2->nick, ci->name); + } else if (ircd->protectedumode && is_protected(u2)) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + } else { + const char *av[3]; + char mask[BUFSIZE]; + + av[0] = "+b"; + get_idealban(ci, u2, mask, sizeof(mask)); + av[1] = mask; + ircdproto->SendMode(whosends(ci), c->name, "+b %s", av[1]); + chan_set_modes(s_ChanServ, c, 2, av, 1); + + /* We still allow host banning while not allowing to kick */ + if (!is_on_chan(c, u2)) + return MOD_CONT; + + if ((ci->flags & CI_SIGNKICK) + || ((ci->flags & CI_SIGNKICK_LEVEL) + && !check_access(u, ci, CA_SIGNKICK))) + ircdproto->SendKick(whosends(ci), ci->name, params, "%s (%s)", + reason, u->nick); + else + ircdproto->SendKick(whosends(ci), ci->name, params, "%s", reason); const char *kav[4]; - kav[0] = ci->name; - kav[1] = params; - kav[2] = reason; - do_kick(s_ChanServ, 3, kav); - } - return MOD_CONT; + kav[0] = ci->name; + kav[1] = params; + kav[2] = reason; + do_kick(s_ChanServ, 3, kav); + } + return MOD_CONT; } /** @@ -192,25 +192,25 @@ int do_ban(User * u) **/ int do_unban(User * u) { - char *chan = strtok(NULL, " "); - Channel *c; - ChannelInfo *ci; - - if (!chan) { - syntax_error(s_ChanServ, u, "UNBAN", CHAN_UNBAN_SYNTAX); - } else if (!(c = findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); - } else if (!(ci = c->ci)) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); - } else if (!check_access(u, ci, CA_UNBAN)) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - } else { - common_unban(ci, u->nick); - notice_lang(s_ChanServ, u, CHAN_UNBANNED, chan); - } - return MOD_CONT; + char *chan = strtok(NULL, " "); + Channel *c; + ChannelInfo *ci; + + if (!chan) { + syntax_error(s_ChanServ, u, "UNBAN", CHAN_UNBAN_SYNTAX); + } else if (!(c = findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); + } else if (!(ci = c->ci)) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); + } else if (!check_access(u, ci, CA_UNBAN)) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + } else { + common_unban(ci, u->nick); + notice_lang(s_ChanServ, u, CHAN_UNBANNED, chan); + } + return MOD_CONT; } MODULE_INIT("cs_ban", CSBan) diff --git a/src/core/cs_clear.c b/src/core/cs_clear.c index a1b4bc8e7..9fca88548 100644 --- a/src/core/cs_clear.c +++ b/src/core/cs_clear.c @@ -44,7 +44,7 @@ class CSClear : public Module **/ void myChanServHelp(User * u) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_CLEAR); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_CLEAR); } /** @@ -54,308 +54,308 @@ void myChanServHelp(User * u) **/ int do_clear(User * u) { - char *chan = strtok(NULL, " "); - char *what = strtok(NULL, " "); - Channel *c; - ChannelInfo *ci; - - if (!what) { - syntax_error(s_ChanServ, u, "CLEAR", CHAN_CLEAR_SYNTAX); - } else if (!(c = findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); - } else if (!(ci = c->ci)) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); - } else if (!u || !check_access(u, ci, CA_CLEAR)) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - } else if (stricmp(what, "bans") == 0) { - const char *av[2]; - Entry *ban, *next; - - if (c->bans && c->bans->count) { - for (ban = c->bans->entries; ban; ban = next) { - next = ban->next; - av[0] = "-b"; - av[1] = ban->mask; - ircdproto->SendMode(whosends(ci), chan, "-b %s", ban->mask); - chan_set_modes(whosends(ci)->nick, c, 2, av, 0); - } - } - - notice_lang(s_ChanServ, u, CHAN_CLEARED_BANS, chan); - } else if (ircd->except && stricmp(what, "excepts") == 0) { - const char *av[2]; - Entry *except, *next; - - if (c->excepts && c->excepts->count) { - for (except = c->excepts->entries; except; except = next) { - next = except->next; - av[0] = "-e"; - av[1] = except->mask; - ircdproto->SendMode(whosends(ci), chan, "-e %s", except->mask); - chan_set_modes(whosends(ci)->nick, c, 2, av, 0); - } - } - notice_lang(s_ChanServ, u, CHAN_CLEARED_EXCEPTS, chan); - - } else if (ircd->invitemode && stricmp(what, "invites") == 0) { - const char *av[2]; - Entry *invite, *next; - - if (c->invites && c->invites->count) { - for (invite = c->invites->entries; invite; invite = next) { - next = invite->next; - av[0] = "-I"; - av[1] = invite->mask; - ircdproto->SendMode(whosends(ci), chan, "-I %s", invite->mask); - chan_set_modes(whosends(ci)->nick, c, 2, av, 0); - } - } - notice_lang(s_ChanServ, u, CHAN_CLEARED_INVITES, chan); - - } else if (stricmp(what, "modes") == 0) { - const char *argv[2]; - - if (c->mode) { - /* Clear modes the bulk of the modes */ - ircdproto->SendMode(whosends(ci), c->name, "%s", - ircd->modestoremove); - argv[0] = ircd->modestoremove; - chan_set_modes(whosends(ci)->nick, c, 1, argv, 0); - - /* to prevent the internals from complaining send -k, -L, -f by themselves if we need - to send them - TSL */ - if (c->key) { - ircdproto->SendMode(whosends(ci), c->name, "-k %s", c->key); - argv[0] = "-k"; - argv[1] = c->key; - chan_set_modes(whosends(ci)->nick, c, 2, argv, 0); - } - if (ircd->Lmode && c->redirect) { - ircdproto->SendMode(whosends(ci), c->name, "-L %s", - c->redirect); - argv[0] = "-L"; - argv[1] = c->redirect; - chan_set_modes(whosends(ci)->nick, c, 2, argv, 0); - } - if (ircd->fmode && c->flood) { - if (flood_mode_char_remove) { - ircdproto->SendMode(whosends(ci), c->name, "%s %s", - flood_mode_char_remove, c->flood); - argv[0] = flood_mode_char_remove; - argv[1] = c->flood; - chan_set_modes(whosends(ci)->nick, c, 2, argv, 0); - } else { - if (debug) { - alog("debug: flood_mode_char_remove was not set unable to remove flood/throttle modes"); - } - } - } - check_modes(c); - } - - notice_lang(s_ChanServ, u, CHAN_CLEARED_MODES, chan); - } else if (stricmp(what, "ops") == 0) { - const char *av[6]; /* The max we have to hold: chan, ts, modes(max3), nick, nick, nick */ - int ac, isop, isadmin, isown, count, i; - char buf[BUFSIZE], tmp[BUFSIZE], tmp2[BUFSIZE]; - struct c_userlist *cu, *next; - - if (ircd->svsmode_ucmode) { - av[0] = chan; - ircdproto->SendSVSModeChan(av[0], "-o", NULL); - if (ircd->owner) { - ircdproto->SendSVSModeChan(av[0], ircd->ownerunset, NULL); - } - if (ircd->protect || ircd->admin) { - ircdproto->SendSVSModeChan(av[0], ircd->adminunset, NULL); - } - for (cu = c->users; cu; cu = next) { - next = cu->next; - isop = chan_has_user_status(c, cu->user, CUS_OP); - isadmin = chan_has_user_status(c, cu->user, CUS_PROTECT); - isown = chan_has_user_status(c, cu->user, CUS_OWNER); - count = (isop ? 1 : 0) + (isadmin ? 1 : 0) + (isown ? 1 : 0); - - if (!isop && !isadmin && !isown) - continue; - - snprintf(tmp, BUFSIZE, "-%s%s%s", (isop ? "o" : ""), (isadmin ? - ircd->adminunset+1 : ""), (isown ? ircd->ownerunset+1 : "")); - - if (ircdcap->tsmode) { - snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); - av[1] = buf; - av[2] = tmp; - /* We have to give as much nicks as modes.. - Viper */ - for (i = 0; i < count; i++) - av[i+3] = cu->user->nick; - ac = 3 + i; - } else { - av[1] = tmp; - /* We have to give as much nicks as modes.. - Viper */ - for (i = 0; i < count; i++) - av[i+2] = cu->user->nick; - ac = 2 + i; - } - - do_cmode(s_ChanServ, ac, av); - } - } else { - av[0] = chan; - for (cu = c->users; cu; cu = next) { - next = cu->next; - isop = chan_has_user_status(c, cu->user, CUS_OP); - isadmin = chan_has_user_status(c, cu->user, CUS_PROTECT); - isown = chan_has_user_status(c, cu->user, CUS_OWNER); - count = (isop ? 1 : 0) + (isadmin ? 1 : 0) + (isown ? 1 : 0); - - if (!isop && !isadmin && !isown) - continue; - - snprintf(tmp, BUFSIZE, "-%s%s%s", (isop ? "o" : ""), (isadmin ? - ircd->adminunset+1 : ""), (isown ? ircd->ownerunset+1 : "")); - /* We need to send the IRCd a nick for every mode.. - Viper */ - snprintf(tmp2, BUFSIZE, "%s %s %s", (isop ? cu->user->nick : ""), - (isadmin ? cu->user->nick : ""), (isown ? cu->user->nick : "")); - - if (ircdcap->tsmode) { - snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); - av[1] = buf; - av[2] = tmp; - /* We have to give as much nicks as modes.. - Viper */ - for (i = 0; i < count; i++) - av[i+3] = cu->user->nick; - ac = 3 + i; - - ircdproto->SendMode(whosends(ci), av[0], "%s %s", av[2], tmp2); - } else { - av[1] = tmp; - /* We have to give as much nicks as modes.. - Viper */ - for (i = 0; i < count; i++) - av[i+2] = cu->user->nick; - ac = 2 + i; - - ircdproto->SendMode(whosends(ci), av[0], "%s %s", av[1], tmp2); - } - - do_cmode(s_ChanServ, ac, av); - } - } - notice_lang(s_ChanServ, u, CHAN_CLEARED_OPS, chan); - } else if (ircd->halfop && stricmp(what, "hops") == 0) { - const char *av[4]; - int ac; - char buf[BUFSIZE]; - struct c_userlist *cu, *next; - - for (cu = c->users; cu; cu = next) { - next = cu->next; - if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) - continue; - - if (ircdcap->tsmode) { - snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); - av[0] = chan; - av[1] = buf; - av[2] = "-h"; - av[3] = cu->user->nick; - ac = 4; - } else { - av[0] = chan; - av[1] = "-h"; - av[2] = cu->user->nick; - ac = 3; - } - - if (ircd->svsmode_ucmode) { - if (ircdcap->tsmode) - ircdproto->SendSVSModeChan(av[0], av[2], NULL); - else - ircdproto->SendSVSModeChan(av[0], av[1], NULL); - - do_cmode(s_ChanServ, ac, av); - break; - } else { - if (ircdcap->tsmode) - ircdproto->SendMode(whosends(ci), av[0], "%s %s", av[2], - av[3]); - else - ircdproto->SendMode(whosends(ci), av[0], "%s %s", av[1], - av[2]); - } - do_cmode(s_ChanServ, ac, av); - } - notice_lang(s_ChanServ, u, CHAN_CLEARED_HOPS, chan); - } else if (stricmp(what, "voices") == 0) { - const char *av[4]; - int ac; - char buf[BUFSIZE]; - struct c_userlist *cu, *next; - - for (cu = c->users; cu; cu = next) { - next = cu->next; - if (!chan_has_user_status(c, cu->user, CUS_VOICE)) - continue; - - if (ircdcap->tsmode) { - snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); - av[0] = chan; - av[1] = buf; - av[2] = "-v"; - av[3] = cu->user->nick; - ac = 4; - } else { - av[0] = chan; - av[1] = "-v"; - av[2] = cu->user->nick; - ac = 3; - } - - if (ircd->svsmode_ucmode) { - if (ircdcap->tsmode) - ircdproto->SendSVSModeChan(av[0], av[2], NULL); - else - ircdproto->SendSVSModeChan(av[0], av[1], NULL); - - do_cmode(s_ChanServ, ac, av); - break; - } else { - if (ircdcap->tsmode) { - ircdproto->SendMode(whosends(ci), av[0], "%s %s", av[2], - av[3]); - } else { - ircdproto->SendMode(whosends(ci), av[0], "%s %s", av[1], - av[2]); - } - } - do_cmode(s_ChanServ, ac, av); - } - notice_lang(s_ChanServ, u, CHAN_CLEARED_VOICES, chan); - } else if (stricmp(what, "users") == 0) { - const char *av[3]; - struct c_userlist *cu, *next; - char buf[256]; - - snprintf(buf, sizeof(buf), "CLEAR USERS command from %s", u->nick); - - for (cu = c->users; cu; cu = next) { - next = cu->next; - av[0] = sstrdup(chan); - av[1] = sstrdup(cu->user->nick); - av[2] = sstrdup(buf); - ircdproto->SendKick(whosends(ci), av[0], av[1], av[2]); - do_kick(s_ChanServ, 3, av); - free((void *)av[2]); - free((void *)av[1]); - free((void *)av[0]); - } - notice_lang(s_ChanServ, u, CHAN_CLEARED_USERS, chan); - } else { - syntax_error(s_ChanServ, u, "CLEAR", CHAN_CLEAR_SYNTAX); - } - return MOD_CONT; + char *chan = strtok(NULL, " "); + char *what = strtok(NULL, " "); + Channel *c; + ChannelInfo *ci; + + if (!what) { + syntax_error(s_ChanServ, u, "CLEAR", CHAN_CLEAR_SYNTAX); + } else if (!(c = findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); + } else if (!(ci = c->ci)) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); + } else if (!u || !check_access(u, ci, CA_CLEAR)) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + } else if (stricmp(what, "bans") == 0) { + const char *av[2]; + Entry *ban, *next; + + if (c->bans && c->bans->count) { + for (ban = c->bans->entries; ban; ban = next) { + next = ban->next; + av[0] = "-b"; + av[1] = ban->mask; + ircdproto->SendMode(whosends(ci), chan, "-b %s", ban->mask); + chan_set_modes(whosends(ci)->nick, c, 2, av, 0); + } + } + + notice_lang(s_ChanServ, u, CHAN_CLEARED_BANS, chan); + } else if (ircd->except && stricmp(what, "excepts") == 0) { + const char *av[2]; + Entry *except, *next; + + if (c->excepts && c->excepts->count) { + for (except = c->excepts->entries; except; except = next) { + next = except->next; + av[0] = "-e"; + av[1] = except->mask; + ircdproto->SendMode(whosends(ci), chan, "-e %s", except->mask); + chan_set_modes(whosends(ci)->nick, c, 2, av, 0); + } + } + notice_lang(s_ChanServ, u, CHAN_CLEARED_EXCEPTS, chan); + + } else if (ircd->invitemode && stricmp(what, "invites") == 0) { + const char *av[2]; + Entry *invite, *next; + + if (c->invites && c->invites->count) { + for (invite = c->invites->entries; invite; invite = next) { + next = invite->next; + av[0] = "-I"; + av[1] = invite->mask; + ircdproto->SendMode(whosends(ci), chan, "-I %s", invite->mask); + chan_set_modes(whosends(ci)->nick, c, 2, av, 0); + } + } + notice_lang(s_ChanServ, u, CHAN_CLEARED_INVITES, chan); + + } else if (stricmp(what, "modes") == 0) { + const char *argv[2]; + + if (c->mode) { + /* Clear modes the bulk of the modes */ + ircdproto->SendMode(whosends(ci), c->name, "%s", + ircd->modestoremove); + argv[0] = ircd->modestoremove; + chan_set_modes(whosends(ci)->nick, c, 1, argv, 0); + + /* to prevent the internals from complaining send -k, -L, -f by themselves if we need + to send them - TSL */ + if (c->key) { + ircdproto->SendMode(whosends(ci), c->name, "-k %s", c->key); + argv[0] = "-k"; + argv[1] = c->key; + chan_set_modes(whosends(ci)->nick, c, 2, argv, 0); + } + if (ircd->Lmode && c->redirect) { + ircdproto->SendMode(whosends(ci), c->name, "-L %s", + c->redirect); + argv[0] = "-L"; + argv[1] = c->redirect; + chan_set_modes(whosends(ci)->nick, c, 2, argv, 0); + } + if (ircd->fmode && c->flood) { + if (flood_mode_char_remove) { + ircdproto->SendMode(whosends(ci), c->name, "%s %s", + flood_mode_char_remove, c->flood); + argv[0] = flood_mode_char_remove; + argv[1] = c->flood; + chan_set_modes(whosends(ci)->nick, c, 2, argv, 0); + } else { + if (debug) { + alog("debug: flood_mode_char_remove was not set unable to remove flood/throttle modes"); + } + } + } + check_modes(c); + } + + notice_lang(s_ChanServ, u, CHAN_CLEARED_MODES, chan); + } else if (stricmp(what, "ops") == 0) { + const char *av[6]; /* The max we have to hold: chan, ts, modes(max3), nick, nick, nick */ + int ac, isop, isadmin, isown, count, i; + char buf[BUFSIZE], tmp[BUFSIZE], tmp2[BUFSIZE]; + struct c_userlist *cu, *next; + + if (ircd->svsmode_ucmode) { + av[0] = chan; + ircdproto->SendSVSModeChan(av[0], "-o", NULL); + if (ircd->owner) { + ircdproto->SendSVSModeChan(av[0], ircd->ownerunset, NULL); + } + if (ircd->protect || ircd->admin) { + ircdproto->SendSVSModeChan(av[0], ircd->adminunset, NULL); + } + for (cu = c->users; cu; cu = next) { + next = cu->next; + isop = chan_has_user_status(c, cu->user, CUS_OP); + isadmin = chan_has_user_status(c, cu->user, CUS_PROTECT); + isown = chan_has_user_status(c, cu->user, CUS_OWNER); + count = (isop ? 1 : 0) + (isadmin ? 1 : 0) + (isown ? 1 : 0); + + if (!isop && !isadmin && !isown) + continue; + + snprintf(tmp, BUFSIZE, "-%s%s%s", (isop ? "o" : ""), (isadmin ? + ircd->adminunset+1 : ""), (isown ? ircd->ownerunset+1 : "")); + + if (ircdcap->tsmode) { + snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); + av[1] = buf; + av[2] = tmp; + /* We have to give as much nicks as modes.. - Viper */ + for (i = 0; i < count; i++) + av[i+3] = cu->user->nick; + ac = 3 + i; + } else { + av[1] = tmp; + /* We have to give as much nicks as modes.. - Viper */ + for (i = 0; i < count; i++) + av[i+2] = cu->user->nick; + ac = 2 + i; + } + + do_cmode(s_ChanServ, ac, av); + } + } else { + av[0] = chan; + for (cu = c->users; cu; cu = next) { + next = cu->next; + isop = chan_has_user_status(c, cu->user, CUS_OP); + isadmin = chan_has_user_status(c, cu->user, CUS_PROTECT); + isown = chan_has_user_status(c, cu->user, CUS_OWNER); + count = (isop ? 1 : 0) + (isadmin ? 1 : 0) + (isown ? 1 : 0); + + if (!isop && !isadmin && !isown) + continue; + + snprintf(tmp, BUFSIZE, "-%s%s%s", (isop ? "o" : ""), (isadmin ? + ircd->adminunset+1 : ""), (isown ? ircd->ownerunset+1 : "")); + /* We need to send the IRCd a nick for every mode.. - Viper */ + snprintf(tmp2, BUFSIZE, "%s %s %s", (isop ? cu->user->nick : ""), + (isadmin ? cu->user->nick : ""), (isown ? cu->user->nick : "")); + + if (ircdcap->tsmode) { + snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); + av[1] = buf; + av[2] = tmp; + /* We have to give as much nicks as modes.. - Viper */ + for (i = 0; i < count; i++) + av[i+3] = cu->user->nick; + ac = 3 + i; + + ircdproto->SendMode(whosends(ci), av[0], "%s %s", av[2], tmp2); + } else { + av[1] = tmp; + /* We have to give as much nicks as modes.. - Viper */ + for (i = 0; i < count; i++) + av[i+2] = cu->user->nick; + ac = 2 + i; + + ircdproto->SendMode(whosends(ci), av[0], "%s %s", av[1], tmp2); + } + + do_cmode(s_ChanServ, ac, av); + } + } + notice_lang(s_ChanServ, u, CHAN_CLEARED_OPS, chan); + } else if (ircd->halfop && stricmp(what, "hops") == 0) { + const char *av[4]; + int ac; + char buf[BUFSIZE]; + struct c_userlist *cu, *next; + + for (cu = c->users; cu; cu = next) { + next = cu->next; + if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) + continue; + + if (ircdcap->tsmode) { + snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); + av[0] = chan; + av[1] = buf; + av[2] = "-h"; + av[3] = cu->user->nick; + ac = 4; + } else { + av[0] = chan; + av[1] = "-h"; + av[2] = cu->user->nick; + ac = 3; + } + + if (ircd->svsmode_ucmode) { + if (ircdcap->tsmode) + ircdproto->SendSVSModeChan(av[0], av[2], NULL); + else + ircdproto->SendSVSModeChan(av[0], av[1], NULL); + + do_cmode(s_ChanServ, ac, av); + break; + } else { + if (ircdcap->tsmode) + ircdproto->SendMode(whosends(ci), av[0], "%s %s", av[2], + av[3]); + else + ircdproto->SendMode(whosends(ci), av[0], "%s %s", av[1], + av[2]); + } + do_cmode(s_ChanServ, ac, av); + } + notice_lang(s_ChanServ, u, CHAN_CLEARED_HOPS, chan); + } else if (stricmp(what, "voices") == 0) { + const char *av[4]; + int ac; + char buf[BUFSIZE]; + struct c_userlist *cu, *next; + + for (cu = c->users; cu; cu = next) { + next = cu->next; + if (!chan_has_user_status(c, cu->user, CUS_VOICE)) + continue; + + if (ircdcap->tsmode) { + snprintf(buf, BUFSIZE - 1, "%ld", (long int) time(NULL)); + av[0] = chan; + av[1] = buf; + av[2] = "-v"; + av[3] = cu->user->nick; + ac = 4; + } else { + av[0] = chan; + av[1] = "-v"; + av[2] = cu->user->nick; + ac = 3; + } + + if (ircd->svsmode_ucmode) { + if (ircdcap->tsmode) + ircdproto->SendSVSModeChan(av[0], av[2], NULL); + else + ircdproto->SendSVSModeChan(av[0], av[1], NULL); + + do_cmode(s_ChanServ, ac, av); + break; + } else { + if (ircdcap->tsmode) { + ircdproto->SendMode(whosends(ci), av[0], "%s %s", av[2], + av[3]); + } else { + ircdproto->SendMode(whosends(ci), av[0], "%s %s", av[1], + av[2]); + } + } + do_cmode(s_ChanServ, ac, av); + } + notice_lang(s_ChanServ, u, CHAN_CLEARED_VOICES, chan); + } else if (stricmp(what, "users") == 0) { + const char *av[3]; + struct c_userlist *cu, *next; + char buf[256]; + + snprintf(buf, sizeof(buf), "CLEAR USERS command from %s", u->nick); + + for (cu = c->users; cu; cu = next) { + next = cu->next; + av[0] = sstrdup(chan); + av[1] = sstrdup(cu->user->nick); + av[2] = sstrdup(buf); + ircdproto->SendKick(whosends(ci), av[0], av[1], av[2]); + do_kick(s_ChanServ, 3, av); + free((void *)av[2]); + free((void *)av[1]); + free((void *)av[0]); + } + notice_lang(s_ChanServ, u, CHAN_CLEARED_USERS, chan); + } else { + syntax_error(s_ChanServ, u, "CLEAR", CHAN_CLEAR_SYNTAX); + } + return MOD_CONT; } MODULE_INIT("cs_clear", CSClear) diff --git a/src/core/cs_drop.c b/src/core/cs_drop.c index fdfda2b3d..03de6f2dd 100644 --- a/src/core/cs_drop.c +++ b/src/core/cs_drop.c @@ -45,7 +45,7 @@ class CSDrop : public Module **/ void myChanServHelp(User * u) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DROP); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DROP); } /** @@ -55,64 +55,64 @@ void myChanServHelp(User * u) **/ int do_drop(User * u) { - char *chan = strtok(NULL, " "); - ChannelInfo *ci; - int is_servadmin = is_services_admin(u); - - if (readonly && !is_servadmin) { - notice_lang(s_ChanServ, u, CHAN_DROP_DISABLED); - return MOD_CONT; - } - - if (!chan) { - syntax_error(s_ChanServ, u, "DROP", CHAN_DROP_SYNTAX); - } else if (!(ci = cs_findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); - } else if (!is_servadmin && (ci->flags & CI_VERBOTEN)) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); - } else if (!is_servadmin && (ci->flags & CI_SUSPENDED)) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); - } else if (!is_servadmin - && (ci-> - flags & CI_SECUREFOUNDER ? !is_real_founder(u, - ci) : - !is_founder(u, ci))) { - notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else { - int level = get_access(u, ci); - - if (readonly) /* in this case we know they're a Services admin */ - notice_lang(s_ChanServ, u, READ_ONLY_MODE); - - if (ci->c) { - if (ircd->regmode) { - ci->c->mode &= ~ircd->regmode; - ircdproto->SendMode(whosends(ci), ci->name, "-r"); - } - } - - if (ircd->chansqline && (ci->flags & CI_VERBOTEN)) { - ircdproto->SendSQLineDel(ci->name); - } - - alog("%s: Channel %s dropped by %s!%s@%s (founder: %s)", - s_ChanServ, ci->name, u->nick, u->username, - u->host, (ci->founder ? ci->founder->display : "(none)")); - - delchan(ci); - - /* We must make sure that the Services admin has not normally the right to - * drop the channel before issuing the wallops. - */ - if (WallDrop && is_servadmin && level < ACCESS_FOUNDER) - ircdproto->SendGlobops(s_ChanServ, - "\2%s\2 used DROP on channel \2%s\2", u->nick, - chan); - - notice_lang(s_ChanServ, u, CHAN_DROPPED, chan); - send_event(EVENT_CHAN_DROP, 1, chan); - } - return MOD_CONT; + char *chan = strtok(NULL, " "); + ChannelInfo *ci; + int is_servadmin = is_services_admin(u); + + if (readonly && !is_servadmin) { + notice_lang(s_ChanServ, u, CHAN_DROP_DISABLED); + return MOD_CONT; + } + + if (!chan) { + syntax_error(s_ChanServ, u, "DROP", CHAN_DROP_SYNTAX); + } else if (!(ci = cs_findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + } else if (!is_servadmin && (ci->flags & CI_VERBOTEN)) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); + } else if (!is_servadmin && (ci->flags & CI_SUSPENDED)) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); + } else if (!is_servadmin + && (ci-> + flags & CI_SECUREFOUNDER ? !is_real_founder(u, + ci) : + !is_founder(u, ci))) { + notice_lang(s_ChanServ, u, ACCESS_DENIED); + } else { + int level = get_access(u, ci); + + if (readonly) /* in this case we know they're a Services admin */ + notice_lang(s_ChanServ, u, READ_ONLY_MODE); + + if (ci->c) { + if (ircd->regmode) { + ci->c->mode &= ~ircd->regmode; + ircdproto->SendMode(whosends(ci), ci->name, "-r"); + } + } + + if (ircd->chansqline && (ci->flags & CI_VERBOTEN)) { + ircdproto->SendSQLineDel(ci->name); + } + + alog("%s: Channel %s dropped by %s!%s@%s (founder: %s)", + s_ChanServ, ci->name, u->nick, u->username, + u->host, (ci->founder ? ci->founder->display : "(none)")); + + delchan(ci); + + /* We must make sure that the Services admin has not normally the right to + * drop the channel before issuing the wallops. + */ + if (WallDrop && is_servadmin && level < ACCESS_FOUNDER) + ircdproto->SendGlobops(s_ChanServ, + "\2%s\2 used DROP on channel \2%s\2", u->nick, + chan); + + notice_lang(s_ChanServ, u, CHAN_DROPPED, chan); + send_event(EVENT_CHAN_DROP, 1, chan); + } + return MOD_CONT; } MODULE_INIT("cs_drop", CSDrop) diff --git a/src/core/cs_forbid.c b/src/core/cs_forbid.c index 293c25e40..dea445073 100644 --- a/src/core/cs_forbid.c +++ b/src/core/cs_forbid.c @@ -43,9 +43,9 @@ class CSForbid : public Module **/ void myChanServHelp(User * u) { - if (is_services_admin(u)) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_FORBID); - } + if (is_services_admin(u)) { + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_FORBID); + } } /** @@ -55,74 +55,74 @@ void myChanServHelp(User * u) **/ int do_forbid(User * u) { - ChannelInfo *ci; - char *chan = strtok(NULL, " "); - char *reason = strtok(NULL, ""); - - Channel *c; - - /* Assumes that permission checking has already been done. */ - if (!chan || (ForceForbidReason && !reason)) { - syntax_error(s_ChanServ, u, "FORBID", - (ForceForbidReason ? CHAN_FORBID_SYNTAX_REASON : - CHAN_FORBID_SYNTAX)); - return MOD_CONT; - } - if (*chan != '#') { - notice_lang(s_ChanServ, u, CHAN_SYMBOL_REQUIRED); - return MOD_CONT; - } else if (!ircdproto->IsChannelValid(chan)) { - notice_lang(s_ChanServ, u, CHAN_X_INVALID, chan); - return MOD_CONT; - } - if (readonly) - notice_lang(s_ChanServ, u, READ_ONLY_MODE); - if ((ci = cs_findchan(chan)) != NULL) - delchan(ci); - ci = makechan(chan); - if (ci) { - ci->flags |= CI_VERBOTEN; - ci->forbidby = sstrdup(u->nick); - if (reason) - ci->forbidreason = sstrdup(reason); - - if ((c = findchan(ci->name))) { - struct c_userlist *cu, *next; - const char *av[3]; - - for (cu = c->users; cu; cu = next) { - next = cu->next; - - if (is_oper(cu->user)) - continue; - - av[0] = c->name; - av[1] = cu->user->nick; - av[2] = reason ? reason : "CHAN_FORBID_REASON"; - ircdproto->SendKick(findbot(s_ChanServ), av[0], av[1], av[2]); - do_kick(s_ChanServ, 3, av); - } - } - - if (WallForbid) - ircdproto->SendGlobops(s_ChanServ, - "\2%s\2 used FORBID on channel \2%s\2", - u->nick, ci->name); - - if (ircd->chansqline) { - ircdproto->SendSQLine(ci->name, ((reason) ? reason : "Forbidden")); - } - - alog("%s: %s set FORBID for channel %s", s_ChanServ, u->nick, - ci->name); - notice_lang(s_ChanServ, u, CHAN_FORBID_SUCCEEDED, chan); - send_event(EVENT_CHAN_FORBIDDEN, 1, chan); - } else { - alog("%s: Valid FORBID for %s by %s failed", s_ChanServ, ci->name, - u->nick); - notice_lang(s_ChanServ, u, CHAN_FORBID_FAILED, chan); - } - return MOD_CONT; + ChannelInfo *ci; + char *chan = strtok(NULL, " "); + char *reason = strtok(NULL, ""); + + Channel *c; + + /* Assumes that permission checking has already been done. */ + if (!chan || (ForceForbidReason && !reason)) { + syntax_error(s_ChanServ, u, "FORBID", + (ForceForbidReason ? CHAN_FORBID_SYNTAX_REASON : + CHAN_FORBID_SYNTAX)); + return MOD_CONT; + } + if (*chan != '#') { + notice_lang(s_ChanServ, u, CHAN_SYMBOL_REQUIRED); + return MOD_CONT; + } else if (!ircdproto->IsChannelValid(chan)) { + notice_lang(s_ChanServ, u, CHAN_X_INVALID, chan); + return MOD_CONT; + } + if (readonly) + notice_lang(s_ChanServ, u, READ_ONLY_MODE); + if ((ci = cs_findchan(chan)) != NULL) + delchan(ci); + ci = makechan(chan); + if (ci) { + ci->flags |= CI_VERBOTEN; + ci->forbidby = sstrdup(u->nick); + if (reason) + ci->forbidreason = sstrdup(reason); + + if ((c = findchan(ci->name))) { + struct c_userlist *cu, *next; + const char *av[3]; + + for (cu = c->users; cu; cu = next) { + next = cu->next; + + if (is_oper(cu->user)) + continue; + + av[0] = c->name; + av[1] = cu->user->nick; + av[2] = reason ? reason : "CHAN_FORBID_REASON"; + ircdproto->SendKick(findbot(s_ChanServ), av[0], av[1], av[2]); + do_kick(s_ChanServ, 3, av); + } + } + + if (WallForbid) + ircdproto->SendGlobops(s_ChanServ, + "\2%s\2 used FORBID on channel \2%s\2", + u->nick, ci->name); + + if (ircd->chansqline) { + ircdproto->SendSQLine(ci->name, ((reason) ? reason : "Forbidden")); + } + + alog("%s: %s set FORBID for channel %s", s_ChanServ, u->nick, + ci->name); + notice_lang(s_ChanServ, u, CHAN_FORBID_SUCCEEDED, chan); + send_event(EVENT_CHAN_FORBIDDEN, 1, chan); + } else { + alog("%s: Valid FORBID for %s by %s failed", s_ChanServ, ci->name, + u->nick); + notice_lang(s_ChanServ, u, CHAN_FORBID_FAILED, chan); + } + return MOD_CONT; } MODULE_INIT("cs_forbid", CSForbid) diff --git a/src/core/cs_getkey.c b/src/core/cs_getkey.c index 4fa616e2f..7bf86d6d4 100644 --- a/src/core/cs_getkey.c +++ b/src/core/cs_getkey.c @@ -44,7 +44,7 @@ class CSGetKey : public Module **/ void myChanServHelp(User * u) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_GETKEY); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_GETKEY); } /** @@ -54,24 +54,24 @@ void myChanServHelp(User * u) **/ int do_getkey(User * u) { - char *chan = strtok(NULL, " "); - ChannelInfo *ci; + char *chan = strtok(NULL, " "); + ChannelInfo *ci; - if (!chan) { - syntax_error(s_ChanServ, u, "GETKEY", CHAN_GETKEY_SYNTAX); - } else if (!(ci = cs_findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); - } else if (!check_access(u, ci, CA_GETKEY)) { - notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else if (!ci->c || !ci->c->key) { - notice_lang(s_ChanServ, u, CHAN_GETKEY_NOKEY, chan); - } else { - notice_lang(s_ChanServ, u, CHAN_GETKEY_KEY, chan, ci->c->key); - } + if (!chan) { + syntax_error(s_ChanServ, u, "GETKEY", CHAN_GETKEY_SYNTAX); + } else if (!(ci = cs_findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); + } else if (!check_access(u, ci, CA_GETKEY)) { + notice_lang(s_ChanServ, u, ACCESS_DENIED); + } else if (!ci->c || !ci->c->key) { + notice_lang(s_ChanServ, u, CHAN_GETKEY_NOKEY, chan); + } else { + notice_lang(s_ChanServ, u, CHAN_GETKEY_KEY, chan, ci->c->key); + } - return MOD_CONT; + return MOD_CONT; } MODULE_INIT("cs_getkey", CSGetKey) diff --git a/src/core/cs_getpass.c b/src/core/cs_getpass.c index f8ebfa0db..a4ed46485 100644 --- a/src/core/cs_getpass.c +++ b/src/core/cs_getpass.c @@ -44,9 +44,9 @@ class CSGetPass : public Module **/ void myChanServHelp(User * u) { - if (is_services_admin(u)) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_GETPASS); - } + if (is_services_admin(u)) { + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_GETPASS); + } } /** @@ -57,34 +57,34 @@ void myChanServHelp(User * u) int do_getpass(User * u) { - char *chan = strtok(NULL, " "); - char tmp_pass[PASSMAX]; - ChannelInfo *ci; + char *chan = strtok(NULL, " "); + char tmp_pass[PASSMAX]; + ChannelInfo *ci; - if (!chan) { - syntax_error(s_ChanServ, u, "GETPASS", CHAN_GETPASS_SYNTAX); - } else if (!(ci = cs_findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); - } else if (CSRestrictGetPass && !is_services_root(u)) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - } else { - if(enc_decrypt(ci->founderpass, tmp_pass, PASSMAX - 1)==1) { - alog("%s: %s!%s@%s used GETPASS on %s", - s_ChanServ, u->nick, u->username, u->host, ci->name); - if (WallGetpass) { - ircdproto->SendGlobops(s_ChanServ, - "\2%s\2 used GETPASS on channel \2%s\2", - u->nick, chan); - } - notice_lang(s_ChanServ, u, CHAN_GETPASS_PASSWORD_IS, - chan, tmp_pass); - } else { - notice_lang(s_ChanServ, u, CHAN_GETPASS_UNAVAILABLE); - } - } - return MOD_CONT; + if (!chan) { + syntax_error(s_ChanServ, u, "GETPASS", CHAN_GETPASS_SYNTAX); + } else if (!(ci = cs_findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); + } else if (CSRestrictGetPass && !is_services_root(u)) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + } else { + if(enc_decrypt(ci->founderpass, tmp_pass, PASSMAX - 1)==1) { + alog("%s: %s!%s@%s used GETPASS on %s", + s_ChanServ, u->nick, u->username, u->host, ci->name); + if (WallGetpass) { + ircdproto->SendGlobops(s_ChanServ, + "\2%s\2 used GETPASS on channel \2%s\2", + u->nick, chan); + } + notice_lang(s_ChanServ, u, CHAN_GETPASS_PASSWORD_IS, + chan, tmp_pass); + } else { + notice_lang(s_ChanServ, u, CHAN_GETPASS_UNAVAILABLE); + } + } + return MOD_CONT; } MODULE_INIT("cs_getpass", CSGetPass) diff --git a/src/core/cs_help.c b/src/core/cs_help.c index 75271b35a..c8c34341f 100644 --- a/src/core/cs_help.c +++ b/src/core/cs_help.c @@ -40,35 +40,35 @@ class CSHelp : public Module **/ int do_help(User * u) { - char *cmd = strtok(NULL, ""); + char *cmd = strtok(NULL, ""); - if (!cmd) { - notice_help(s_ChanServ, u, CHAN_HELP); - moduleDisplayHelp(2, u); - if (CSExpire >= 86400) - notice_help(s_ChanServ, u, CHAN_HELP_EXPIRES, - CSExpire / 86400); - if (is_services_oper(u)) - notice_help(s_ChanServ, u, CHAN_SERVADMIN_HELP); - } else if (stricmp(cmd, "LEVELS DESC") == 0) { - int i; - notice_help(s_ChanServ, u, CHAN_HELP_LEVELS_DESC); - if (!levelinfo_maxwidth) { - for (i = 0; levelinfo[i].what >= 0; i++) { - int len = strlen(levelinfo[i].name); - if (len > levelinfo_maxwidth) - levelinfo_maxwidth = len; - } - } - for (i = 0; levelinfo[i].what >= 0; i++) { - notice_help(s_ChanServ, u, CHAN_HELP_LEVELS_DESC_FORMAT, - levelinfo_maxwidth, levelinfo[i].name, - getstring(u->na, levelinfo[i].desc)); - } - } else { - mod_help_cmd(s_ChanServ, u, CHANSERV, cmd); - } - return MOD_CONT; + if (!cmd) { + notice_help(s_ChanServ, u, CHAN_HELP); + moduleDisplayHelp(2, u); + if (CSExpire >= 86400) + notice_help(s_ChanServ, u, CHAN_HELP_EXPIRES, + CSExpire / 86400); + if (is_services_oper(u)) + notice_help(s_ChanServ, u, CHAN_SERVADMIN_HELP); + } else if (stricmp(cmd, "LEVELS DESC") == 0) { + int i; + notice_help(s_ChanServ, u, CHAN_HELP_LEVELS_DESC); + if (!levelinfo_maxwidth) { + for (i = 0; levelinfo[i].what >= 0; i++) { + int len = strlen(levelinfo[i].name); + if (len > levelinfo_maxwidth) + levelinfo_maxwidth = len; + } + } + for (i = 0; levelinfo[i].what >= 0; i++) { + notice_help(s_ChanServ, u, CHAN_HELP_LEVELS_DESC_FORMAT, + levelinfo_maxwidth, levelinfo[i].name, + getstring(u->na, levelinfo[i].desc)); + } + } else { + mod_help_cmd(s_ChanServ, u, CHANSERV, cmd); + } + return MOD_CONT; } MODULE_INIT("cs_help", CSHelp) diff --git a/src/core/cs_identify.c b/src/core/cs_identify.c index 8af3d4bd7..baad140e8 100644 --- a/src/core/cs_identify.c +++ b/src/core/cs_identify.c @@ -47,7 +47,7 @@ class CSIdentify : public Module **/ void myChanServHelp(User * u) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_IDENTIFY); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_IDENTIFY); } /** @@ -57,49 +57,49 @@ void myChanServHelp(User * u) **/ int do_identify(User * u) { - char *chan = strtok(NULL, " "); - char *pass = strtok(NULL, " "); - ChannelInfo *ci; - struct u_chaninfolist *uc; - - if (!pass) { - syntax_error(s_ChanServ, u, "IDENTIFY", CHAN_IDENTIFY_SYNTAX); - } else if (!(ci = cs_findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); - } else if (!nick_identified(u)) { - notice_lang(s_ChanServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); - } else if (is_founder(u, ci)) { - notice_lang(s_ChanServ, u, NICK_ALREADY_IDENTIFIED); - } else { - int res; - - if ((res = enc_check_password(pass, ci->founderpass)) == 1) { - if (!is_identified(u, ci)) { - uc = (struct u_chaninfolist *)scalloc(sizeof(*uc), 1); - uc->next = u->founder_chans; - if (u->founder_chans) - u->founder_chans->prev = uc; - u->founder_chans = uc; - uc->chan = ci; - alog("%s: %s!%s@%s identified for %s", s_ChanServ, u->nick, - u->username, u->host, ci->name); - } - - notice_lang(s_ChanServ, u, CHAN_IDENTIFY_SUCCEEDED, chan); - } else if (res < 0) { - alog("%s: check_password failed for %s", s_ChanServ, ci->name); - notice_lang(s_ChanServ, u, CHAN_IDENTIFY_FAILED); - } else { - alog("%s: Failed IDENTIFY for %s by %s!%s@%s", - s_ChanServ, ci->name, u->nick, u->username, u->host); - notice_lang(s_ChanServ, u, PASSWORD_INCORRECT); - bad_password(u); - } - - } - return MOD_CONT; + char *chan = strtok(NULL, " "); + char *pass = strtok(NULL, " "); + ChannelInfo *ci; + struct u_chaninfolist *uc; + + if (!pass) { + syntax_error(s_ChanServ, u, "IDENTIFY", CHAN_IDENTIFY_SYNTAX); + } else if (!(ci = cs_findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); + } else if (!nick_identified(u)) { + notice_lang(s_ChanServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); + } else if (is_founder(u, ci)) { + notice_lang(s_ChanServ, u, NICK_ALREADY_IDENTIFIED); + } else { + int res; + + if ((res = enc_check_password(pass, ci->founderpass)) == 1) { + if (!is_identified(u, ci)) { + uc = (struct u_chaninfolist *)scalloc(sizeof(*uc), 1); + uc->next = u->founder_chans; + if (u->founder_chans) + u->founder_chans->prev = uc; + u->founder_chans = uc; + uc->chan = ci; + alog("%s: %s!%s@%s identified for %s", s_ChanServ, u->nick, + u->username, u->host, ci->name); + } + + notice_lang(s_ChanServ, u, CHAN_IDENTIFY_SUCCEEDED, chan); + } else if (res < 0) { + alog("%s: check_password failed for %s", s_ChanServ, ci->name); + notice_lang(s_ChanServ, u, CHAN_IDENTIFY_FAILED); + } else { + alog("%s: Failed IDENTIFY for %s by %s!%s@%s", + s_ChanServ, ci->name, u->nick, u->username, u->host); + notice_lang(s_ChanServ, u, PASSWORD_INCORRECT); + bad_password(u); + } + + } + return MOD_CONT; } MODULE_INIT("cs_identify", CSIdentify) diff --git a/src/core/cs_info.c b/src/core/cs_info.c index 549859044..c07d6ebc0 100644 --- a/src/core/cs_info.c +++ b/src/core/cs_info.c @@ -44,7 +44,7 @@ class CSInfo : public Module **/ void myChanServHelp(User * u) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_INFO); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_INFO); } /** @@ -59,179 +59,179 @@ int do_info(User * u) * Syntax: INFO channel [ALL] * -TheShadow (29 Mar 1999) */ - char *chan = strtok(NULL, " "); - char *param = strtok(NULL, " "); - ChannelInfo *ci; - char buf[BUFSIZE], *end; - struct tm *tm; - int need_comma = 0; - const char *commastr = getstring(u->na, COMMA_SPACE); - int is_servadmin = is_services_admin(u); - int show_all = 0; - time_t expt; - - if (!chan) { - syntax_error(s_ChanServ, u, "INFO", CHAN_INFO_SYNTAX); - } else if (!(ci = cs_findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); - } else if (ci->flags & CI_VERBOTEN) { - if (is_oper(u) && ci->forbidby) - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN_OPER, chan, - ci->forbidby, - (ci->forbidreason ? ci-> - forbidreason : getstring(u->na, NO_REASON))); - else - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); - } else if (!ci->founder) { - /* Paranoia... this shouldn't be able to happen */ - delchan(ci); - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); - } else { - - /* Should we show all fields? Only for sadmins and identified users */ - if (param && stricmp(param, "ALL") == 0 && - (check_access(u, ci, CA_INFO) || is_servadmin)) - show_all = 1; - - notice_lang(s_ChanServ, u, CHAN_INFO_HEADER, chan); - notice_lang(s_ChanServ, u, CHAN_INFO_NO_FOUNDER, - ci->founder->display); - - if (show_all && ci->successor) - notice_lang(s_ChanServ, u, CHAN_INFO_NO_SUCCESSOR, - ci->successor->display); - - notice_lang(s_ChanServ, u, CHAN_INFO_DESCRIPTION, ci->desc); - tm = localtime(&ci->time_registered); - strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm); - notice_lang(s_ChanServ, u, CHAN_INFO_TIME_REGGED, buf); - tm = localtime(&ci->last_used); - strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm); - notice_lang(s_ChanServ, u, CHAN_INFO_LAST_USED, buf); - if (ci->last_topic - && (show_all || (!(ci->mlock_on & anope_get_secret_mode()) - && (!ci->c - || !(ci->c-> - mode & anope_get_secret_mode()))))) { - notice_lang(s_ChanServ, u, CHAN_INFO_LAST_TOPIC, - ci->last_topic); - notice_lang(s_ChanServ, u, CHAN_INFO_TOPIC_SET_BY, - ci->last_topic_setter); - } - - if (ci->entry_message && show_all) - notice_lang(s_ChanServ, u, CHAN_INFO_ENTRYMSG, - ci->entry_message); - if (ci->url) - notice_lang(s_ChanServ, u, CHAN_INFO_URL, ci->url); - if (ci->email) - notice_lang(s_ChanServ, u, CHAN_INFO_EMAIL, ci->email); - - if (show_all) { - notice_lang(s_ChanServ, u, CHAN_INFO_BANTYPE, ci->bantype); - - end = buf; - *end = 0; - if (ci->flags & CI_KEEPTOPIC) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s", - getstring(u->na, CHAN_INFO_OPT_KEEPTOPIC)); - need_comma = 1; - } - if (ci->flags & CI_OPNOTICE) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, CHAN_INFO_OPT_OPNOTICE)); - need_comma = 1; - } - if (ci->flags & CI_PEACE) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, CHAN_INFO_OPT_PEACE)); - need_comma = 1; - } - if (ci->flags & CI_PRIVATE) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, CHAN_INFO_OPT_PRIVATE)); - need_comma = 1; - } - if (ci->flags & CI_RESTRICTED) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, - CHAN_INFO_OPT_RESTRICTED)); - need_comma = 1; - } - if (ci->flags & CI_SECURE) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, CHAN_INFO_OPT_SECURE)); - need_comma = 1; - } - if (ci->flags & CI_SECUREOPS) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, CHAN_INFO_OPT_SECUREOPS)); - need_comma = 1; - } - if (ci->flags & CI_SECUREFOUNDER) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, - CHAN_INFO_OPT_SECUREFOUNDER)); - need_comma = 1; - } - if ((ci->flags & CI_SIGNKICK) - || (ci->flags & CI_SIGNKICK_LEVEL)) { - end += - snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", getstring(u->na, - CHAN_INFO_OPT_SIGNKICK)); - need_comma = 1; - } - if (ci->flags & CI_TOPICLOCK) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, CHAN_INFO_OPT_TOPICLOCK)); - need_comma = 1; - } - if (ci->flags & CI_XOP) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, CHAN_INFO_OPT_XOP)); - need_comma = 1; - } - notice_lang(s_ChanServ, u, CHAN_INFO_OPTIONS, - *buf ? buf : getstring(u->na, CHAN_INFO_OPT_NONE)); - notice_lang(s_ChanServ, u, CHAN_INFO_MODE_LOCK, - get_mlock_modes(ci, 1)); - - } - if (show_all) { - if (ci->flags & CI_NO_EXPIRE) { - notice_lang(s_ChanServ, u, CHAN_INFO_NO_EXPIRE); - } else { - if (is_servadmin) { - expt = ci->last_used + CSExpire; - tm = localtime(&expt); - strftime_lang(buf, sizeof(buf), u, - STRFTIME_DATE_TIME_FORMAT, tm); - notice_lang(s_ChanServ, u, CHAN_INFO_EXPIRE, buf); - } - } - } - if (ci->flags & CI_SUSPENDED) { - notice_lang(s_ChanServ, u, CHAN_X_SUSPENDED, ci->forbidby, - (ci->forbidreason ? ci-> - forbidreason : getstring(u->na, NO_REASON))); - } - - if (!show_all && (check_access(u, ci, CA_INFO) || is_servadmin)) - notice_lang(s_ChanServ, u, NICK_INFO_FOR_MORE, s_ChanServ, - ci->name); - - } - return MOD_CONT; + char *chan = strtok(NULL, " "); + char *param = strtok(NULL, " "); + ChannelInfo *ci; + char buf[BUFSIZE], *end; + struct tm *tm; + int need_comma = 0; + const char *commastr = getstring(u->na, COMMA_SPACE); + int is_servadmin = is_services_admin(u); + int show_all = 0; + time_t expt; + + if (!chan) { + syntax_error(s_ChanServ, u, "INFO", CHAN_INFO_SYNTAX); + } else if (!(ci = cs_findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + } else if (ci->flags & CI_VERBOTEN) { + if (is_oper(u) && ci->forbidby) + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN_OPER, chan, + ci->forbidby, + (ci->forbidreason ? ci-> + forbidreason : getstring(u->na, NO_REASON))); + else + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); + } else if (!ci->founder) { + /* Paranoia... this shouldn't be able to happen */ + delchan(ci); + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + } else { + + /* Should we show all fields? Only for sadmins and identified users */ + if (param && stricmp(param, "ALL") == 0 && + (check_access(u, ci, CA_INFO) || is_servadmin)) + show_all = 1; + + notice_lang(s_ChanServ, u, CHAN_INFO_HEADER, chan); + notice_lang(s_ChanServ, u, CHAN_INFO_NO_FOUNDER, + ci->founder->display); + + if (show_all && ci->successor) + notice_lang(s_ChanServ, u, CHAN_INFO_NO_SUCCESSOR, + ci->successor->display); + + notice_lang(s_ChanServ, u, CHAN_INFO_DESCRIPTION, ci->desc); + tm = localtime(&ci->time_registered); + strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm); + notice_lang(s_ChanServ, u, CHAN_INFO_TIME_REGGED, buf); + tm = localtime(&ci->last_used); + strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm); + notice_lang(s_ChanServ, u, CHAN_INFO_LAST_USED, buf); + if (ci->last_topic + && (show_all || (!(ci->mlock_on & anope_get_secret_mode()) + && (!ci->c + || !(ci->c-> + mode & anope_get_secret_mode()))))) { + notice_lang(s_ChanServ, u, CHAN_INFO_LAST_TOPIC, + ci->last_topic); + notice_lang(s_ChanServ, u, CHAN_INFO_TOPIC_SET_BY, + ci->last_topic_setter); + } + + if (ci->entry_message && show_all) + notice_lang(s_ChanServ, u, CHAN_INFO_ENTRYMSG, + ci->entry_message); + if (ci->url) + notice_lang(s_ChanServ, u, CHAN_INFO_URL, ci->url); + if (ci->email) + notice_lang(s_ChanServ, u, CHAN_INFO_EMAIL, ci->email); + + if (show_all) { + notice_lang(s_ChanServ, u, CHAN_INFO_BANTYPE, ci->bantype); + + end = buf; + *end = 0; + if (ci->flags & CI_KEEPTOPIC) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s", + getstring(u->na, CHAN_INFO_OPT_KEEPTOPIC)); + need_comma = 1; + } + if (ci->flags & CI_OPNOTICE) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, CHAN_INFO_OPT_OPNOTICE)); + need_comma = 1; + } + if (ci->flags & CI_PEACE) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, CHAN_INFO_OPT_PEACE)); + need_comma = 1; + } + if (ci->flags & CI_PRIVATE) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, CHAN_INFO_OPT_PRIVATE)); + need_comma = 1; + } + if (ci->flags & CI_RESTRICTED) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, + CHAN_INFO_OPT_RESTRICTED)); + need_comma = 1; + } + if (ci->flags & CI_SECURE) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, CHAN_INFO_OPT_SECURE)); + need_comma = 1; + } + if (ci->flags & CI_SECUREOPS) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, CHAN_INFO_OPT_SECUREOPS)); + need_comma = 1; + } + if (ci->flags & CI_SECUREFOUNDER) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, + CHAN_INFO_OPT_SECUREFOUNDER)); + need_comma = 1; + } + if ((ci->flags & CI_SIGNKICK) + || (ci->flags & CI_SIGNKICK_LEVEL)) { + end += + snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", getstring(u->na, + CHAN_INFO_OPT_SIGNKICK)); + need_comma = 1; + } + if (ci->flags & CI_TOPICLOCK) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, CHAN_INFO_OPT_TOPICLOCK)); + need_comma = 1; + } + if (ci->flags & CI_XOP) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, CHAN_INFO_OPT_XOP)); + need_comma = 1; + } + notice_lang(s_ChanServ, u, CHAN_INFO_OPTIONS, + *buf ? buf : getstring(u->na, CHAN_INFO_OPT_NONE)); + notice_lang(s_ChanServ, u, CHAN_INFO_MODE_LOCK, + get_mlock_modes(ci, 1)); + + } + if (show_all) { + if (ci->flags & CI_NO_EXPIRE) { + notice_lang(s_ChanServ, u, CHAN_INFO_NO_EXPIRE); + } else { + if (is_servadmin) { + expt = ci->last_used + CSExpire; + tm = localtime(&expt); + strftime_lang(buf, sizeof(buf), u, + STRFTIME_DATE_TIME_FORMAT, tm); + notice_lang(s_ChanServ, u, CHAN_INFO_EXPIRE, buf); + } + } + } + if (ci->flags & CI_SUSPENDED) { + notice_lang(s_ChanServ, u, CHAN_X_SUSPENDED, ci->forbidby, + (ci->forbidreason ? ci-> + forbidreason : getstring(u->na, NO_REASON))); + } + + if (!show_all && (check_access(u, ci, CA_INFO) || is_servadmin)) + notice_lang(s_ChanServ, u, NICK_INFO_FOR_MORE, s_ChanServ, + ci->name); + + } + return MOD_CONT; } MODULE_INIT("cs_info", CSInfo) diff --git a/src/core/cs_invite.c b/src/core/cs_invite.c index 191e7dcee..c75afc459 100644 --- a/src/core/cs_invite.c +++ b/src/core/cs_invite.c @@ -44,7 +44,7 @@ class CSInvite : public Module **/ void myChanServHelp(User * u) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_INVITE); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_INVITE); } /** @@ -54,26 +54,26 @@ void myChanServHelp(User * u) **/ int do_invite(User * u) { - char *chan = strtok(NULL, " "); - Channel *c; - ChannelInfo *ci; + char *chan = strtok(NULL, " "); + Channel *c; + ChannelInfo *ci; - if (!chan) { - syntax_error(s_ChanServ, u, "INVITE", CHAN_INVITE_SYNTAX); - } else if (!(c = findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); - } else if (!(ci = c->ci)) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); - } else if (ci->flags & CI_SUSPENDED) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); - } else if (!u || !check_access(u, ci, CA_INVITE)) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - } else { - ircdproto->SendInvite(whosends(ci), chan, u->nick); - } - return MOD_CONT; + if (!chan) { + syntax_error(s_ChanServ, u, "INVITE", CHAN_INVITE_SYNTAX); + } else if (!(c = findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); + } else if (!(ci = c->ci)) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); + } else if (ci->flags & CI_SUSPENDED) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); + } else if (!u || !check_access(u, ci, CA_INVITE)) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + } else { + ircdproto->SendInvite(whosends(ci), chan, u->nick); + } + return MOD_CONT; } MODULE_INIT("cs_invite", CSInvite) diff --git a/src/core/cs_kick.c b/src/core/cs_kick.c index 50f21ba37..a8eb7b2b3 100644 --- a/src/core/cs_kick.c +++ b/src/core/cs_kick.c @@ -42,7 +42,7 @@ class CSKick : public Module **/ void myChanServHelp(User * u) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_KICK); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_KICK); } /** @@ -52,90 +52,90 @@ void myChanServHelp(User * u) **/ int do_cs_kick(User * u) { - char *chan = strtok(NULL, " "); - char *params = strtok(NULL, " "); - char *reason = strtok(NULL, ""); - - Channel *c; - ChannelInfo *ci; - User *u2; - - int is_same; - - if (!reason) { - reason = "Requested"; - } else { - if (strlen(reason) > 200) - reason[200] = '\0'; - } - - if (!chan) { - struct u_chanlist *uc, *next; - - /* Kicks the user on every channels he is on. */ - - for (uc = u->chans; uc; uc = next) { - next = uc->next; - if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN) - && check_access(u, ci, CA_KICKME)) { - const char *av[3]; - - if ((ci->flags & CI_SIGNKICK) - || ((ci->flags & CI_SIGNKICK_LEVEL) - && !check_access(u, ci, CA_SIGNKICK))) - ircdproto->SendKick(whosends(ci), ci->name, u->nick, - "%s (%s)", reason, u->nick); - else - ircdproto->SendKick(whosends(ci), ci->name, u->nick, "%s", - reason); - av[0] = ci->name; - av[1] = u->nick; - av[2] = reason; - do_kick(s_ChanServ, 3, av); - } - } - - return MOD_CONT; - } else if (!params) { - params = u->nick; - } - - is_same = (params == u->nick) ? 1 : (stricmp(params, u->nick) == 0); - - if (!(c = findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); - } else if (!(ci = c->ci)) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); - } else if (is_same ? !(u2 = u) : !(u2 = finduser(params))) { - notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, params); - } else if (!is_on_chan(c, u2)) { - notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u2->nick, c->name); - } else if (!is_same ? !check_access(u, ci, CA_KICK) : - !check_access(u, ci, CA_KICKME)) { - notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else if (!is_same && (ci->flags & CI_PEACE) - && (get_access(u2, ci) >= get_access(u, ci))) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - } else if (is_protected(u2)) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - } else { - const char *av[3]; - - if ((ci->flags & CI_SIGNKICK) - || ((ci->flags & CI_SIGNKICK_LEVEL) - && !check_access(u, ci, CA_SIGNKICK))) - ircdproto->SendKick(whosends(ci), ci->name, params, "%s (%s)", - reason, u->nick); - else - ircdproto->SendKick(whosends(ci), ci->name, params, "%s", reason); - av[0] = ci->name; - av[1] = params; - av[2] = reason; - do_kick(s_ChanServ, 3, av); - } - return MOD_CONT; + char *chan = strtok(NULL, " "); + char *params = strtok(NULL, " "); + char *reason = strtok(NULL, ""); + + Channel *c; + ChannelInfo *ci; + User *u2; + + int is_same; + + if (!reason) { + reason = "Requested"; + } else { + if (strlen(reason) > 200) + reason[200] = '\0'; + } + + if (!chan) { + struct u_chanlist *uc, *next; + + /* Kicks the user on every channels he is on. */ + + for (uc = u->chans; uc; uc = next) { + next = uc->next; + if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN) + && check_access(u, ci, CA_KICKME)) { + const char *av[3]; + + if ((ci->flags & CI_SIGNKICK) + || ((ci->flags & CI_SIGNKICK_LEVEL) + && !check_access(u, ci, CA_SIGNKICK))) + ircdproto->SendKick(whosends(ci), ci->name, u->nick, + "%s (%s)", reason, u->nick); + else + ircdproto->SendKick(whosends(ci), ci->name, u->nick, "%s", + reason); + av[0] = ci->name; + av[1] = u->nick; + av[2] = reason; + do_kick(s_ChanServ, 3, av); + } + } + + return MOD_CONT; + } else if (!params) { + params = u->nick; + } + + is_same = (params == u->nick) ? 1 : (stricmp(params, u->nick) == 0); + + if (!(c = findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); + } else if (!(ci = c->ci)) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); + } else if (is_same ? !(u2 = u) : !(u2 = finduser(params))) { + notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, params); + } else if (!is_on_chan(c, u2)) { + notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u2->nick, c->name); + } else if (!is_same ? !check_access(u, ci, CA_KICK) : + !check_access(u, ci, CA_KICKME)) { + notice_lang(s_ChanServ, u, ACCESS_DENIED); + } else if (!is_same && (ci->flags & CI_PEACE) + && (get_access(u2, ci) >= get_access(u, ci))) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + } else if (is_protected(u2)) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + } else { + const char *av[3]; + + if ((ci->flags & CI_SIGNKICK) + || ((ci->flags & CI_SIGNKICK_LEVEL) + && !check_access(u, ci, CA_SIGNKICK))) + ircdproto->SendKick(whosends(ci), ci->name, params, "%s (%s)", + reason, u->nick); + else + ircdproto->SendKick(whosends(ci), ci->name, params, "%s", reason); + av[0] = ci->name; + av[1] = params; + av[2] = reason; + do_kick(s_ChanServ, 3, av); + } + return MOD_CONT; } MODULE_INIT("cs_kick", CSKick) diff --git a/src/core/cs_list.c b/src/core/cs_list.c index d5eb57fa3..a6e81d33c 100644 --- a/src/core/cs_list.c +++ b/src/core/cs_list.c @@ -45,9 +45,9 @@ class CSList : public Module **/ void myChanServHelp(User * u) { - if (!CSListOpersOnly || (is_oper(u))) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_LIST); - } + if (!CSListOpersOnly || (is_oper(u))) { + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_LIST); + } } /** @@ -57,130 +57,130 @@ void myChanServHelp(User * u) **/ int do_list(User * u) { - char *pattern = strtok(NULL, " "); - int spattern_size; - char *spattern; - ChannelInfo *ci; - int nchans, i; - char buf[BUFSIZE]; - int is_servadmin = is_services_admin(u); - int count = 0, from = 0, to = 0, tofree = 0; - char *tmp = NULL; - char *s = NULL; - char *keyword; - int32 matchflags = 0; - - if (!(!CSListOpersOnly || (is_oper(u)))) { - notice_lang(s_ChanServ, u, ACCESS_DENIED); - return MOD_STOP; - } - - if (!pattern) { - syntax_error(s_ChanServ, u, "LIST", - is_servadmin ? CHAN_LIST_SERVADMIN_SYNTAX : - CHAN_LIST_SYNTAX); - } else { - - if (pattern) { - if (pattern[0] == '#') { - tmp = myStrGetOnlyToken((pattern + 1), '-', 0); /* Read FROM out */ - if (!tmp) { - notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); - notice_lang(s_ChanServ, u, CS_LIST_INCORRECT_RANGE); - return MOD_CONT; - } - for (s = tmp; *s; s++) { - if (!isdigit(*s)) { - free(tmp); - notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); - notice_lang(s_ChanServ, u, CS_LIST_INCORRECT_RANGE); - return MOD_CONT; - } - } - from = atoi(tmp); - free(tmp); - tmp = myStrGetTokenRemainder(pattern, '-', 1); /* Read TO out */ - if (!tmp) { - notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); - notice_lang(s_ChanServ, u, CS_LIST_INCORRECT_RANGE); - return MOD_CONT; - } - for (s = tmp; *s; s++) { - if (!isdigit(*s)) { - free(tmp); - notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); - notice_lang(s_ChanServ, u, CS_LIST_INCORRECT_RANGE); - return MOD_CONT; - } - } - to = atoi(tmp); - free(tmp); - pattern = sstrdup("*"); - tofree = 1; - } - } - - nchans = 0; - - while (is_servadmin && (keyword = strtok(NULL, " "))) { - if (stricmp(keyword, "FORBIDDEN") == 0) - matchflags |= CI_VERBOTEN; - if (stricmp(keyword, "SUSPENDED") == 0) - matchflags |= CI_SUSPENDED; - if (stricmp(keyword, "NOEXPIRE") == 0) - matchflags |= CI_NO_EXPIRE; - } - - spattern_size = (strlen(pattern) + 2) * sizeof(char); - spattern = (char *)smalloc(spattern_size); - snprintf(spattern, spattern_size, "#%s", pattern); - - - notice_lang(s_ChanServ, u, CHAN_LIST_HEADER, pattern); - for (i = 0; i < 256; i++) { - for (ci = chanlists[i]; ci; ci = ci->next) { - if (!is_servadmin && ((ci->flags & CI_PRIVATE) - || (ci->flags & CI_VERBOTEN))) - continue; - if ((matchflags != 0) && !(ci->flags & matchflags)) - continue; - - if ((stricmp(pattern, ci->name) == 0) - || (stricmp(spattern, ci->name) == 0) - || match_wild_nocase(pattern, ci->name) - || match_wild_nocase(spattern, ci->name)) { - if ((((count + 1 >= from) && (count + 1 <= to)) - || ((from == 0) && (to == 0))) - && (++nchans <= CSListMax)) { - char noexpire_char = ' '; - if (is_servadmin && (ci->flags & CI_NO_EXPIRE)) - noexpire_char = '!'; - - if (ci->flags & CI_VERBOTEN) { - snprintf(buf, sizeof(buf), - "%-20s [Forbidden]", ci->name); - } else if (ci->flags & CI_SUSPENDED) { - snprintf(buf, sizeof(buf), - "%-20s [Suspended]", ci->name); - } else { - snprintf(buf, sizeof(buf), "%-20s %s", - ci->name, ci->desc ? ci->desc : ""); - } - - notice_user(s_ChanServ, u, " %c%s", - noexpire_char, buf); - } - count++; - } - } - } - notice_lang(s_ChanServ, u, CHAN_LIST_END, - nchans > CSListMax ? CSListMax : nchans, nchans); - free(spattern); - } - if (tofree) - free(pattern); - return MOD_CONT; + char *pattern = strtok(NULL, " "); + int spattern_size; + char *spattern; + ChannelInfo *ci; + int nchans, i; + char buf[BUFSIZE]; + int is_servadmin = is_services_admin(u); + int count = 0, from = 0, to = 0, tofree = 0; + char *tmp = NULL; + char *s = NULL; + char *keyword; + int32 matchflags = 0; + + if (!(!CSListOpersOnly || (is_oper(u)))) { + notice_lang(s_ChanServ, u, ACCESS_DENIED); + return MOD_STOP; + } + + if (!pattern) { + syntax_error(s_ChanServ, u, "LIST", + is_servadmin ? CHAN_LIST_SERVADMIN_SYNTAX : + CHAN_LIST_SYNTAX); + } else { + + if (pattern) { + if (pattern[0] == '#') { + tmp = myStrGetOnlyToken((pattern + 1), '-', 0); /* Read FROM out */ + if (!tmp) { + notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); + notice_lang(s_ChanServ, u, CS_LIST_INCORRECT_RANGE); + return MOD_CONT; + } + for (s = tmp; *s; s++) { + if (!isdigit(*s)) { + free(tmp); + notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); + notice_lang(s_ChanServ, u, CS_LIST_INCORRECT_RANGE); + return MOD_CONT; + } + } + from = atoi(tmp); + free(tmp); + tmp = myStrGetTokenRemainder(pattern, '-', 1); /* Read TO out */ + if (!tmp) { + notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); + notice_lang(s_ChanServ, u, CS_LIST_INCORRECT_RANGE); + return MOD_CONT; + } + for (s = tmp; *s; s++) { + if (!isdigit(*s)) { + free(tmp); + notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); + notice_lang(s_ChanServ, u, CS_LIST_INCORRECT_RANGE); + return MOD_CONT; + } + } + to = atoi(tmp); + free(tmp); + pattern = sstrdup("*"); + tofree = 1; + } + } + + nchans = 0; + + while (is_servadmin && (keyword = strtok(NULL, " "))) { + if (stricmp(keyword, "FORBIDDEN") == 0) + matchflags |= CI_VERBOTEN; + if (stricmp(keyword, "SUSPENDED") == 0) + matchflags |= CI_SUSPENDED; + if (stricmp(keyword, "NOEXPIRE") == 0) + matchflags |= CI_NO_EXPIRE; + } + + spattern_size = (strlen(pattern) + 2) * sizeof(char); + spattern = (char *)smalloc(spattern_size); + snprintf(spattern, spattern_size, "#%s", pattern); + + + notice_lang(s_ChanServ, u, CHAN_LIST_HEADER, pattern); + for (i = 0; i < 256; i++) { + for (ci = chanlists[i]; ci; ci = ci->next) { + if (!is_servadmin && ((ci->flags & CI_PRIVATE) + || (ci->flags & CI_VERBOTEN))) + continue; + if ((matchflags != 0) && !(ci->flags & matchflags)) + continue; + + if ((stricmp(pattern, ci->name) == 0) + || (stricmp(spattern, ci->name) == 0) + || match_wild_nocase(pattern, ci->name) + || match_wild_nocase(spattern, ci->name)) { + if ((((count + 1 >= from) && (count + 1 <= to)) + || ((from == 0) && (to == 0))) + && (++nchans <= CSListMax)) { + char noexpire_char = ' '; + if (is_servadmin && (ci->flags & CI_NO_EXPIRE)) + noexpire_char = '!'; + + if (ci->flags & CI_VERBOTEN) { + snprintf(buf, sizeof(buf), + "%-20s [Forbidden]", ci->name); + } else if (ci->flags & CI_SUSPENDED) { + snprintf(buf, sizeof(buf), + "%-20s [Suspended]", ci->name); + } else { + snprintf(buf, sizeof(buf), "%-20s %s", + ci->name, ci->desc ? ci->desc : ""); + } + + notice_user(s_ChanServ, u, " %c%s", + noexpire_char, buf); + } + count++; + } + } + } + notice_lang(s_ChanServ, u, CHAN_LIST_END, + nchans > CSListMax ? CSListMax : nchans, nchans); + free(spattern); + } + if (tofree) + free(pattern); + return MOD_CONT; } diff --git a/src/core/cs_logout.c b/src/core/cs_logout.c index e1d8124ee..16e2a8ebc 100644 --- a/src/core/cs_logout.c +++ b/src/core/cs_logout.c @@ -44,7 +44,7 @@ class CSLogout : public Module **/ void myChanServHelp(User * u) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_LOGOUT); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_LOGOUT); } /** @@ -54,65 +54,65 @@ void myChanServHelp(User * u) **/ int do_logout(User * u) { - char *chan = strtok(NULL, " "); - char *nick = strtok(NULL, " "); - ChannelInfo *ci; - User *u2 = NULL; - int is_servadmin = is_services_admin(u); + char *chan = strtok(NULL, " "); + char *nick = strtok(NULL, " "); + ChannelInfo *ci; + User *u2 = NULL; + int is_servadmin = is_services_admin(u); - if (!chan || (!nick && !is_servadmin)) { - syntax_error(s_ChanServ, u, "LOGOUT", - (!is_servadmin ? CHAN_LOGOUT_SYNTAX : - CHAN_LOGOUT_SERVADMIN_SYNTAX)); - } else if (!(ci = cs_findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); - } else if (!is_servadmin && (ci->flags & CI_VERBOTEN)) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); - } else if (nick && !(u2 = finduser(nick))) { - notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, nick); - } else if (!is_servadmin && u2 != u && !is_real_founder(u, ci)) { - notice_lang(s_ChanServ, u, ACCESS_DENIED); + if (!chan || (!nick && !is_servadmin)) { + syntax_error(s_ChanServ, u, "LOGOUT", + (!is_servadmin ? CHAN_LOGOUT_SYNTAX : + CHAN_LOGOUT_SERVADMIN_SYNTAX)); + } else if (!(ci = cs_findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + } else if (!is_servadmin && (ci->flags & CI_VERBOTEN)) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); + } else if (nick && !(u2 = finduser(nick))) { + notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, nick); + } else if (!is_servadmin && u2 != u && !is_real_founder(u, ci)) { + notice_lang(s_ChanServ, u, ACCESS_DENIED); /* Since founders can not logout we should tell them -katsklaw */ - } else if (u2 == u && is_real_founder(u, ci)) { + } else if (u2 == u && is_real_founder(u, ci)) { notice_lang(s_ChanServ, u, CHAN_LOGOUT_FOUNDER_FAILED, chan); - } else { - if (u2) { - make_unidentified(u2, ci); - notice_lang(s_ChanServ, u, CHAN_LOGOUT_SUCCEEDED, nick, chan); - alog("%s: User %s!%s@%s has been logged out of channel %s.", - s_ChanServ, u2->nick, u2->username, u2->host, chan); - } else { - int i; - for (i = 0; i < 1024; i++) - for (u2 = userlist[i]; u2; u2 = u2->next) - make_unidentified(u2, ci); - notice_lang(s_ChanServ, u, CHAN_LOGOUT_ALL_SUCCEEDED, chan); - alog("%s: All users identified have been logged out of channel %s.", s_ChanServ, chan); - } + } else { + if (u2) { + make_unidentified(u2, ci); + notice_lang(s_ChanServ, u, CHAN_LOGOUT_SUCCEEDED, nick, chan); + alog("%s: User %s!%s@%s has been logged out of channel %s.", + s_ChanServ, u2->nick, u2->username, u2->host, chan); + } else { + int i; + for (i = 0; i < 1024; i++) + for (u2 = userlist[i]; u2; u2 = u2->next) + make_unidentified(u2, ci); + notice_lang(s_ChanServ, u, CHAN_LOGOUT_ALL_SUCCEEDED, chan); + alog("%s: All users identified have been logged out of channel %s.", s_ChanServ, chan); + } - } - return MOD_CONT; + } + return MOD_CONT; } void make_unidentified(User * u, ChannelInfo * ci) { - struct u_chaninfolist *uci; + struct u_chaninfolist *uci; - if (!u || !ci) - return; + if (!u || !ci) + return; - for (uci = u->founder_chans; uci; uci = uci->next) { - if (uci->chan == ci) { - if (uci->next) - uci->next->prev = uci->prev; - if (uci->prev) - uci->prev->next = uci->next; - else - u->founder_chans = uci->next; - free(uci); - break; - } - } + for (uci = u->founder_chans; uci; uci = uci->next) { + if (uci->chan == ci) { + if (uci->next) + uci->next->prev = uci->prev; + if (uci->prev) + uci->prev->next = uci->next; + else + u->founder_chans = uci->next; + free(uci); + break; + } + } } MODULE_INIT("cs_logout", CSLogout) diff --git a/src/core/cs_modes.c b/src/core/cs_modes.c index 8a33bc6fd..e84de54bb 100644 --- a/src/core/cs_modes.c +++ b/src/core/cs_modes.c @@ -86,26 +86,26 @@ class CSModes : public Module **/ void myChanServHelp(User * u) { - if (ircd->owner) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_OWNER); - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEOWNER); - } - if (ircd->protect) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_PROTECT); - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEPROTECT); - } else if (ircd->admin) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_ADMIN); - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEADMIN); - } - - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_OP); - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEOP); - if (ircd->halfop) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_HALFOP); - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEHALFOP); - } - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_VOICE); - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEVOICE); + if (ircd->owner) { + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_OWNER); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEOWNER); + } + if (ircd->protect) { + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_PROTECT); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEPROTECT); + } else if (ircd->admin) { + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_ADMIN); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEADMIN); + } + + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_OP); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEOP); + if (ircd->halfop) { + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_HALFOP); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEHALFOP); + } + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_VOICE); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_DEVOICE); } /** @@ -116,256 +116,256 @@ void myChanServHelp(User * u) int do_op(User * u) { - return do_util(u, &csmodeutils[MUT_OP]); + return do_util(u, &csmodeutils[MUT_OP]); } /*************************************************************************/ int do_deop(User * u) { - return do_util(u, &csmodeutils[MUT_DEOP]); + return do_util(u, &csmodeutils[MUT_DEOP]); } /*************************************************************************/ int do_voice(User * u) { - return do_util(u, &csmodeutils[MUT_VOICE]); + return do_util(u, &csmodeutils[MUT_VOICE]); } /*************************************************************************/ int do_devoice(User * u) { - return do_util(u, &csmodeutils[MUT_DEVOICE]); + return do_util(u, &csmodeutils[MUT_DEVOICE]); } /*************************************************************************/ int do_halfop(User * u) { - if (ircd->halfop) { - return do_util(u, &csmodeutils[MUT_HALFOP]); - } else { - return MOD_CONT; - } + if (ircd->halfop) { + return do_util(u, &csmodeutils[MUT_HALFOP]); + } else { + return MOD_CONT; + } } /*************************************************************************/ int do_dehalfop(User * u) { - if (ircd->halfop) { - return do_util(u, &csmodeutils[MUT_DEHALFOP]); - } else { - return MOD_CONT; - } + if (ircd->halfop) { + return do_util(u, &csmodeutils[MUT_DEHALFOP]); + } else { + return MOD_CONT; + } } /*************************************************************************/ int do_protect(User * u) { - if (ircd->protect || ircd->admin) { - return do_util(u, &csmodeutils[MUT_PROTECT]); - } else { - return MOD_CONT; - } + if (ircd->protect || ircd->admin) { + return do_util(u, &csmodeutils[MUT_PROTECT]); + } else { + return MOD_CONT; + } } /*************************************************************************/ int do_deprotect(User * u) { - if (ircd->protect || ircd->admin) { - return do_util(u, &csmodeutils[MUT_DEPROTECT]); - } else { - return MOD_CONT; - } + if (ircd->protect || ircd->admin) { + return do_util(u, &csmodeutils[MUT_DEPROTECT]); + } else { + return MOD_CONT; + } } /*************************************************************************/ int do_owner(User * u) { - const char *av[2]; - char *chan = strtok(NULL, " "); - - Channel *c; - ChannelInfo *ci; - struct u_chanlist *uc; - - if (!ircd->owner) { - return MOD_CONT; - } - - if (!chan) { - av[0] = ircd->ownerset; - av[1] = u->nick; - - /* Sets the mode to the user on every channels he is on. */ - - for (uc = u->chans; uc; uc = uc->next) { - if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN) - && is_founder(u, ci)) { - ircdproto->SendMode(whosends(ci), uc->chan->name, "%s %s", - av[0], u->nick); - chan_set_modes(s_ChanServ, uc->chan, 2, av, 1); - } - } - - return MOD_CONT; - } - - if (!(c = findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); - } else if (!(ci = c->ci)) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name); - } else if (!is_on_chan(c, u)) { - notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u->nick, c->name); - } else if (!is_founder(u, ci)) { - notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else { - ircdproto->SendMode(whosends(ci), c->name, "%s %s", ircd->ownerset, - u->nick); - - av[0] = ircd->ownerset; - av[1] = u->nick; - chan_set_modes(s_ChanServ, c, 2, av, 1); - } - return MOD_CONT; + const char *av[2]; + char *chan = strtok(NULL, " "); + + Channel *c; + ChannelInfo *ci; + struct u_chanlist *uc; + + if (!ircd->owner) { + return MOD_CONT; + } + + if (!chan) { + av[0] = ircd->ownerset; + av[1] = u->nick; + + /* Sets the mode to the user on every channels he is on. */ + + for (uc = u->chans; uc; uc = uc->next) { + if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN) + && is_founder(u, ci)) { + ircdproto->SendMode(whosends(ci), uc->chan->name, "%s %s", + av[0], u->nick); + chan_set_modes(s_ChanServ, uc->chan, 2, av, 1); + } + } + + return MOD_CONT; + } + + if (!(c = findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); + } else if (!(ci = c->ci)) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name); + } else if (!is_on_chan(c, u)) { + notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u->nick, c->name); + } else if (!is_founder(u, ci)) { + notice_lang(s_ChanServ, u, ACCESS_DENIED); + } else { + ircdproto->SendMode(whosends(ci), c->name, "%s %s", ircd->ownerset, + u->nick); + + av[0] = ircd->ownerset; + av[1] = u->nick; + chan_set_modes(s_ChanServ, c, 2, av, 1); + } + return MOD_CONT; } /*************************************************************************/ int do_deowner(User * u) { - const char *av[2]; - char *chan = strtok(NULL, " "); - - Channel *c; - ChannelInfo *ci; - struct u_chanlist *uc; - - if (!ircd->owner) { - return MOD_CONT; - } - - if (!chan) { - av[0] = ircd->ownerunset; - av[1] = u->nick; - - /* Sets the mode to the user on every channels he is on. */ - - for (uc = u->chans; uc; uc = uc->next) { - if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN) - && is_founder(u, ci)) { - ircdproto->SendMode(whosends(ci), uc->chan->name, "%s %s", - av[0], u->nick); - chan_set_modes(s_ChanServ, uc->chan, 2, av, 1); - } - } - - return MOD_CONT; - } - - if (!(c = findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); - } else if (!(ci = c->ci)) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name); - } else if (!is_on_chan(c, u)) { - notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u->nick, c->name); - } else if (!is_founder(u, ci)) { - notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else { - ircdproto->SendMode(whosends(ci), c->name, "%s %s", ircd->ownerunset, - u->nick); - - av[0] = ircd->ownerunset; - av[1] = u->nick; - chan_set_modes(s_ChanServ, c, 2, av, 1); - } - return MOD_CONT; + const char *av[2]; + char *chan = strtok(NULL, " "); + + Channel *c; + ChannelInfo *ci; + struct u_chanlist *uc; + + if (!ircd->owner) { + return MOD_CONT; + } + + if (!chan) { + av[0] = ircd->ownerunset; + av[1] = u->nick; + + /* Sets the mode to the user on every channels he is on. */ + + for (uc = u->chans; uc; uc = uc->next) { + if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN) + && is_founder(u, ci)) { + ircdproto->SendMode(whosends(ci), uc->chan->name, "%s %s", + av[0], u->nick); + chan_set_modes(s_ChanServ, uc->chan, 2, av, 1); + } + } + + return MOD_CONT; + } + + if (!(c = findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); + } else if (!(ci = c->ci)) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name); + } else if (!is_on_chan(c, u)) { + notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u->nick, c->name); + } else if (!is_founder(u, ci)) { + notice_lang(s_ChanServ, u, ACCESS_DENIED); + } else { + ircdproto->SendMode(whosends(ci), c->name, "%s %s", ircd->ownerunset, + u->nick); + + av[0] = ircd->ownerunset; + av[1] = u->nick; + chan_set_modes(s_ChanServ, c, 2, av, 1); + } + return MOD_CONT; } /* do_util: not a command, but does the job of other */ int do_util(User * u, CSModeUtil * util) { - const char *av[2]; - char *chan = strtok(NULL, " "); - char *nick = strtok(NULL, " "); - - Channel *c; - ChannelInfo *ci; - User *u2; - - int is_same; - - if (!chan) { - struct u_chanlist *uc; - - av[0] = util->mode; - av[1] = u->nick; - - /* Sets the mode to the user on every channels he is on. */ - - for (uc = u->chans; uc; uc = uc->next) { - if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN) - && check_access(u, ci, util->levelself)) { - ircdproto->SendMode(whosends(ci), uc->chan->name, "%s %s", - util->mode, u->nick); - chan_set_modes(s_ChanServ, uc->chan, 2, av, 2); - - if (util->notice && ci->flags & util->notice) - ircdproto->SendMessage(whosends(ci), uc->chan->name, - "%s command used for %s by %s", util->name, - u->nick, u->nick); - } - } - - return MOD_CONT; - } else if (!nick) { - nick = u->nick; - } - - is_same = (nick == u->nick) ? 1 : (stricmp(nick, u->nick) == 0); - - if (!(c = findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); - } else if (!(ci = c->ci)) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name); - } else if (is_same ? !(u2 = u) : !(u2 = finduser(nick))) { - notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, nick); - } else if (!is_on_chan(c, u2)) { - notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u2->nick, c->name); - } else if (is_same ? !check_access(u, ci, util->levelself) : - !check_access(u, ci, util->level)) { - notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else if (*util->mode == '-' && !is_same && (ci->flags & CI_PEACE) - && (get_access(u2, ci) >= get_access(u, ci))) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - } else if (*util->mode == '-' && is_protected(u2) && !is_same) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - } else { - ircdproto->SendMode(whosends(ci), c->name, "%s %s", util->mode, - u2->nick); - - av[0] = util->mode; - av[1] = u2->nick; - chan_set_modes(s_ChanServ, c, 2, av, 2); - - if (util->notice && ci->flags & util->notice) - ircdproto->SendMessage(whosends(ci), c->name, "%s command used for %s by %s", - util->name, u2->nick, u->nick); - } - return MOD_CONT; + const char *av[2]; + char *chan = strtok(NULL, " "); + char *nick = strtok(NULL, " "); + + Channel *c; + ChannelInfo *ci; + User *u2; + + int is_same; + + if (!chan) { + struct u_chanlist *uc; + + av[0] = util->mode; + av[1] = u->nick; + + /* Sets the mode to the user on every channels he is on. */ + + for (uc = u->chans; uc; uc = uc->next) { + if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN) + && check_access(u, ci, util->levelself)) { + ircdproto->SendMode(whosends(ci), uc->chan->name, "%s %s", + util->mode, u->nick); + chan_set_modes(s_ChanServ, uc->chan, 2, av, 2); + + if (util->notice && ci->flags & util->notice) + ircdproto->SendMessage(whosends(ci), uc->chan->name, + "%s command used for %s by %s", util->name, + u->nick, u->nick); + } + } + + return MOD_CONT; + } else if (!nick) { + nick = u->nick; + } + + is_same = (nick == u->nick) ? 1 : (stricmp(nick, u->nick) == 0); + + if (!(c = findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); + } else if (!(ci = c->ci)) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name); + } else if (is_same ? !(u2 = u) : !(u2 = finduser(nick))) { + notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, nick); + } else if (!is_on_chan(c, u2)) { + notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u2->nick, c->name); + } else if (is_same ? !check_access(u, ci, util->levelself) : + !check_access(u, ci, util->level)) { + notice_lang(s_ChanServ, u, ACCESS_DENIED); + } else if (*util->mode == '-' && !is_same && (ci->flags & CI_PEACE) + && (get_access(u2, ci) >= get_access(u, ci))) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + } else if (*util->mode == '-' && is_protected(u2) && !is_same) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + } else { + ircdproto->SendMode(whosends(ci), c->name, "%s %s", util->mode, + u2->nick); + + av[0] = util->mode; + av[1] = u2->nick; + chan_set_modes(s_ChanServ, c, 2, av, 2); + + if (util->notice && ci->flags & util->notice) + ircdproto->SendMessage(whosends(ci), c->name, "%s command used for %s by %s", + util->name, u2->nick, u->nick); + } + return MOD_CONT; } MODULE_INIT("cs_modes", CSModes) diff --git a/src/core/cs_register.c b/src/core/cs_register.c index 2fb180b76..524790330 100644 --- a/src/core/cs_register.c +++ b/src/core/cs_register.c @@ -45,7 +45,7 @@ class CSRegister : public Module **/ void myChanServHelp(User * u) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_REGISTER); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_REGISTER); } /** @@ -55,125 +55,125 @@ void myChanServHelp(User * u) **/ int do_register(User * u) { - char *chan = strtok(NULL, " "); - char *pass = strtok(NULL, " "); - char *desc = strtok(NULL, ""); - NickCore *nc; - Channel *c; - ChannelInfo *ci; - struct u_chaninfolist *uc; - int is_servadmin = is_services_admin(u); - char founderpass[PASSMAX]; - char tmp_pass[PASSMAX]; - - if (readonly) { - notice_lang(s_ChanServ, u, CHAN_REGISTER_DISABLED); - return MOD_CONT; - } - - if (checkDefCon(DEFCON_NO_NEW_CHANNELS)) { - notice_lang(s_ChanServ, u, OPER_DEFCON_DENIED); - return MOD_CONT; - } - - if (!desc) { - syntax_error(s_ChanServ, u, "REGISTER", CHAN_REGISTER_SYNTAX); - } else if (*chan == '&') { - notice_lang(s_ChanServ, u, CHAN_REGISTER_NOT_LOCAL); - } else if (*chan != '#') { - notice_lang(s_ChanServ, u, CHAN_SYMBOL_REQUIRED); - } else if (!ircdproto->IsChannelValid(chan)) { - notice_lang(s_ChanServ, u, CHAN_X_INVALID, chan); - } else if (!u->na || !(nc = u->na->nc)) { - notice_lang(s_ChanServ, u, CHAN_MUST_REGISTER_NICK, s_NickServ); - } else if (!nick_recognized(u)) { - notice_lang(s_ChanServ, u, CHAN_MUST_IDENTIFY_NICK, s_NickServ, - s_NickServ); - } else if (!(c = findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_REGISTER_NONE_CHANNEL, chan); - } else if ((ci = cs_findchan(chan)) != NULL) { - if (ci->flags & CI_VERBOTEN) { - alog("%s: Attempt to register FORBIDden channel %s by %s!%s@%s", s_ChanServ, ci->name, u->nick, u->username, u->host); - notice_lang(s_ChanServ, u, CHAN_MAY_NOT_BE_REGISTERED, chan); - } else { - notice_lang(s_ChanServ, u, CHAN_ALREADY_REGISTERED, chan); - } - } else if (!stricmp(chan, "#")) { - notice_lang(s_ChanServ, u, CHAN_MAY_NOT_BE_REGISTERED, chan); - } else if (!chan_has_user_status(c, u, CUS_OP)) { - notice_lang(s_ChanServ, u, CHAN_MUST_BE_CHANOP); - - } else if (!is_servadmin && CSMaxReg && nc->channelcount >= CSMaxReg) { - notice_lang(s_ChanServ, u, nc->channelcount > - CSMaxReg ? CHAN_EXCEEDED_CHANNEL_LIMIT : CHAN_REACHED_CHANNEL_LIMIT, CSMaxReg); - } else if (stricmp(u->nick, pass) == 0 - || (StrictPasswords && strlen(pass) < 5)) { - notice_lang(s_ChanServ, u, MORE_OBSCURE_PASSWORD); - } else if(enc_encrypt_check_len(strlen(pass), PASSMAX - 1)) { - notice_lang(s_ChanServ, u, PASSWORD_TOO_LONG); - } else if (!(ci = makechan(chan))) { - alog("%s: makechan() failed for REGISTER %s", s_ChanServ, chan); - notice_lang(s_ChanServ, u, CHAN_REGISTRATION_FAILED); - - } else if (strscpy(founderpass, pass, PASSMAX), - enc_encrypt_in_place(founderpass, PASSMAX) < 0) { - alog("%s: Couldn't encrypt password for %s (REGISTER)", - s_ChanServ, chan); - notice_lang(s_ChanServ, u, CHAN_REGISTRATION_FAILED); - delchan(ci); - } else { - c->ci = ci; - ci->c = c; - ci->bantype = CSDefBantype; - ci->flags = CSDefFlags; - ci->mlock_on = ircd->defmlock; - ci->memos.memomax = MSMaxMemos; - ci->last_used = ci->time_registered; - ci->founder = nc; - - memset(pass, 0, strlen(pass)); - memcpy(ci->founderpass, founderpass, PASSMAX); - ci->desc = sstrdup(desc); - if (c->topic) { - ci->last_topic = sstrdup(c->topic); - strscpy(ci->last_topic_setter, c->topic_setter, NICKMAX); - ci->last_topic_time = c->topic_time; - } else { - /* Set this to something, otherwise it will maliform the topic */ - strscpy(ci->last_topic_setter, s_ChanServ, NICKMAX); - } - ci->bi = NULL; - ci->botflags = BSDefFlags; - ci->founder->channelcount++; - alog("%s: Channel '%s' registered by %s!%s@%s", s_ChanServ, chan, - u->nick, u->username, u->host); - notice_lang(s_ChanServ, u, CHAN_REGISTERED, chan, u->nick); - - if(enc_decrypt(ci->founderpass,tmp_pass,PASSMAX - 1) == 1) { - notice_lang(s_ChanServ, u, CHAN_PASSWORD_IS, tmp_pass); - } - - uc = (struct u_chaninfolist *)scalloc(sizeof(*uc), 1); - uc->next = u->founder_chans; - uc->prev = NULL; - if (u->founder_chans) - u->founder_chans->prev = uc; - u->founder_chans = uc; - uc->chan = ci; - /* Implement new mode lock */ - check_modes(c); - /* On most ircds you do not receive the admin/owner mode till its registered */ - if (ircd->admin) { - ircdproto->SendMode(findbot(s_ChanServ), chan, "%s %s", ircd->adminset, - u->nick); - } - if (ircd->owner && ircd->ownerset) { - ircdproto->SendMode(findbot(s_ChanServ), chan, "%s %s", ircd->ownerset, - u->nick); - } - send_event(EVENT_CHAN_REGISTERED, 1, chan); - } - return MOD_CONT; + char *chan = strtok(NULL, " "); + char *pass = strtok(NULL, " "); + char *desc = strtok(NULL, ""); + NickCore *nc; + Channel *c; + ChannelInfo *ci; + struct u_chaninfolist *uc; + int is_servadmin = is_services_admin(u); + char founderpass[PASSMAX]; + char tmp_pass[PASSMAX]; + + if (readonly) { + notice_lang(s_ChanServ, u, CHAN_REGISTER_DISABLED); + return MOD_CONT; + } + + if (checkDefCon(DEFCON_NO_NEW_CHANNELS)) { + notice_lang(s_ChanServ, u, OPER_DEFCON_DENIED); + return MOD_CONT; + } + + if (!desc) { + syntax_error(s_ChanServ, u, "REGISTER", CHAN_REGISTER_SYNTAX); + } else if (*chan == '&') { + notice_lang(s_ChanServ, u, CHAN_REGISTER_NOT_LOCAL); + } else if (*chan != '#') { + notice_lang(s_ChanServ, u, CHAN_SYMBOL_REQUIRED); + } else if (!ircdproto->IsChannelValid(chan)) { + notice_lang(s_ChanServ, u, CHAN_X_INVALID, chan); + } else if (!u->na || !(nc = u->na->nc)) { + notice_lang(s_ChanServ, u, CHAN_MUST_REGISTER_NICK, s_NickServ); + } else if (!nick_recognized(u)) { + notice_lang(s_ChanServ, u, CHAN_MUST_IDENTIFY_NICK, s_NickServ, + s_NickServ); + } else if (!(c = findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_REGISTER_NONE_CHANNEL, chan); + } else if ((ci = cs_findchan(chan)) != NULL) { + if (ci->flags & CI_VERBOTEN) { + alog("%s: Attempt to register FORBIDden channel %s by %s!%s@%s", s_ChanServ, ci->name, u->nick, u->username, u->host); + notice_lang(s_ChanServ, u, CHAN_MAY_NOT_BE_REGISTERED, chan); + } else { + notice_lang(s_ChanServ, u, CHAN_ALREADY_REGISTERED, chan); + } + } else if (!stricmp(chan, "#")) { + notice_lang(s_ChanServ, u, CHAN_MAY_NOT_BE_REGISTERED, chan); + } else if (!chan_has_user_status(c, u, CUS_OP)) { + notice_lang(s_ChanServ, u, CHAN_MUST_BE_CHANOP); + + } else if (!is_servadmin && CSMaxReg && nc->channelcount >= CSMaxReg) { + notice_lang(s_ChanServ, u, nc->channelcount > + CSMaxReg ? CHAN_EXCEEDED_CHANNEL_LIMIT : CHAN_REACHED_CHANNEL_LIMIT, CSMaxReg); + } else if (stricmp(u->nick, pass) == 0 + || (StrictPasswords && strlen(pass) < 5)) { + notice_lang(s_ChanServ, u, MORE_OBSCURE_PASSWORD); + } else if(enc_encrypt_check_len(strlen(pass), PASSMAX - 1)) { + notice_lang(s_ChanServ, u, PASSWORD_TOO_LONG); + } else if (!(ci = makechan(chan))) { + alog("%s: makechan() failed for REGISTER %s", s_ChanServ, chan); + notice_lang(s_ChanServ, u, CHAN_REGISTRATION_FAILED); + + } else if (strscpy(founderpass, pass, PASSMAX), + enc_encrypt_in_place(founderpass, PASSMAX) < 0) { + alog("%s: Couldn't encrypt password for %s (REGISTER)", + s_ChanServ, chan); + notice_lang(s_ChanServ, u, CHAN_REGISTRATION_FAILED); + delchan(ci); + } else { + c->ci = ci; + ci->c = c; + ci->bantype = CSDefBantype; + ci->flags = CSDefFlags; + ci->mlock_on = ircd->defmlock; + ci->memos.memomax = MSMaxMemos; + ci->last_used = ci->time_registered; + ci->founder = nc; + + memset(pass, 0, strlen(pass)); + memcpy(ci->founderpass, founderpass, PASSMAX); + ci->desc = sstrdup(desc); + if (c->topic) { + ci->last_topic = sstrdup(c->topic); + strscpy(ci->last_topic_setter, c->topic_setter, NICKMAX); + ci->last_topic_time = c->topic_time; + } else { + /* Set this to something, otherwise it will maliform the topic */ + strscpy(ci->last_topic_setter, s_ChanServ, NICKMAX); + } + ci->bi = NULL; + ci->botflags = BSDefFlags; + ci->founder->channelcount++; + alog("%s: Channel '%s' registered by %s!%s@%s", s_ChanServ, chan, + u->nick, u->username, u->host); + notice_lang(s_ChanServ, u, CHAN_REGISTERED, chan, u->nick); + + if(enc_decrypt(ci->founderpass,tmp_pass,PASSMAX - 1) == 1) { + notice_lang(s_ChanServ, u, CHAN_PASSWORD_IS, tmp_pass); + } + + uc = (struct u_chaninfolist *)scalloc(sizeof(*uc), 1); + uc->next = u->founder_chans; + uc->prev = NULL; + if (u->founder_chans) + u->founder_chans->prev = uc; + u->founder_chans = uc; + uc->chan = ci; + /* Implement new mode lock */ + check_modes(c); + /* On most ircds you do not receive the admin/owner mode till its registered */ + if (ircd->admin) { + ircdproto->SendMode(findbot(s_ChanServ), chan, "%s %s", ircd->adminset, + u->nick); + } + if (ircd->owner && ircd->ownerset) { + ircdproto->SendMode(findbot(s_ChanServ), chan, "%s %s", ircd->ownerset, + u->nick); + } + send_event(EVENT_CHAN_REGISTERED, 1, chan); + } + return MOD_CONT; } MODULE_INIT("cs_register", CSRegister) diff --git a/src/core/cs_sendpass.c b/src/core/cs_sendpass.c index 2e37f2e33..d6cf929f0 100644 --- a/src/core/cs_sendpass.c +++ b/src/core/cs_sendpass.c @@ -51,7 +51,7 @@ class CSSendPass : public Module **/ void myChanServHelp(User * u) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_SENDPASS); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_SENDPASS); } /** @@ -62,56 +62,56 @@ void myChanServHelp(User * u) int do_sendpass(User * u) { - char *chan = strtok(NULL, " "); - ChannelInfo *ci; - NickCore *founder; - - if (!chan) { - syntax_error(s_ChanServ, u, "SENDPASS", CHAN_SENDPASS_SYNTAX); - } else if (RestrictMail && !is_services_oper(u)) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - } else if (!(ci = cs_findchan(chan)) || !(founder = ci->founder)) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); - } else { - char buf[BUFSIZE]; - char tmp_pass[PASSMAX]; - if(enc_decrypt(ci->founderpass,tmp_pass,PASSMAX - 1)==1) { - MailInfo *mail; - - snprintf(buf, sizeof(buf), - getstring2(founder, CHAN_SENDPASS_SUBJECT), ci->name); - mail = MailBegin(u, founder, buf, s_ChanServ); - if (!mail) - return MOD_CONT; - - fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_HEAD)); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_1), - ci->name); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_2), - tmp_pass); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_3)); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_4)); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_5), - NetworkName); - fprintf(mail->pipe, "\n.\n"); + char *chan = strtok(NULL, " "); + ChannelInfo *ci; + NickCore *founder; + + if (!chan) { + syntax_error(s_ChanServ, u, "SENDPASS", CHAN_SENDPASS_SYNTAX); + } else if (RestrictMail && !is_services_oper(u)) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + } else if (!(ci = cs_findchan(chan)) || !(founder = ci->founder)) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); + } else { + char buf[BUFSIZE]; + char tmp_pass[PASSMAX]; + if(enc_decrypt(ci->founderpass,tmp_pass,PASSMAX - 1)==1) { + MailInfo *mail; + + snprintf(buf, sizeof(buf), + getstring2(founder, CHAN_SENDPASS_SUBJECT), ci->name); + mail = MailBegin(u, founder, buf, s_ChanServ); + if (!mail) + return MOD_CONT; + + fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_HEAD)); + fprintf(mail->pipe, "\n\n"); + fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_1), + ci->name); + fprintf(mail->pipe, "\n\n"); + fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_2), + tmp_pass); + fprintf(mail->pipe, "\n\n"); + fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_3)); + fprintf(mail->pipe, "\n\n"); + fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_4)); + fprintf(mail->pipe, "\n\n"); + fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_5), + NetworkName); + fprintf(mail->pipe, "\n.\n"); - MailEnd(mail); - - alog("%s: %s!%s@%s used SENDPASS on %s", s_ChanServ, u->nick, - u->username, u->host, chan); - notice_lang(s_ChanServ, u, CHAN_SENDPASS_OK, chan); - } else { - notice_lang(s_ChanServ, u, CHAN_SENDPASS_UNAVAILABLE); - } - } - return MOD_CONT; + MailEnd(mail); + + alog("%s: %s!%s@%s used SENDPASS on %s", s_ChanServ, u->nick, + u->username, u->host, chan); + notice_lang(s_ChanServ, u, CHAN_SENDPASS_OK, chan); + } else { + notice_lang(s_ChanServ, u, CHAN_SENDPASS_UNAVAILABLE); + } + } + return MOD_CONT; } MODULE_INIT("cs_sendpass", CSSendPass) diff --git a/src/core/cs_set.c b/src/core/cs_set.c index e731f94b4..0a49d259d 100644 --- a/src/core/cs_set.c +++ b/src/core/cs_set.c @@ -109,7 +109,7 @@ class CSSet : public Module **/ void myChanServHelp(User * u) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_SET); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_SET); } /** @@ -128,582 +128,582 @@ void myChanServHelp(User * u) */ int do_set(User * u) { - char *chan = strtok(NULL, " "); - char *cmd = strtok(NULL, " "); - char *param; - ChannelInfo *ci; - int is_servadmin = is_services_admin(u); - - if (readonly) { - notice_lang(s_ChanServ, u, CHAN_SET_DISABLED); - return MOD_CONT; - } - - if (cmd) { - if (stricmp(cmd, "DESC") == 0 || stricmp(cmd, "ENTRYMSG") == 0) - param = strtok(NULL, ""); - else - param = strtok(NULL, " "); - } else { - param = NULL; - } - - if (!param && (!cmd || (stricmp(cmd, "SUCCESSOR") != 0 && - stricmp(cmd, "URL") != 0 && - stricmp(cmd, "EMAIL") != 0 && - stricmp(cmd, "ENTRYMSG") != 0))) { - syntax_error(s_ChanServ, u, "SET", CHAN_SET_SYNTAX); - } else if (!(ci = cs_findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); - } else if (!is_servadmin && !check_access(u, ci, CA_SET)) { - notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else if (stricmp(cmd, "FOUNDER") == 0) { - if (!is_servadmin - && (ci-> - flags & CI_SECUREFOUNDER ? !is_real_founder(u, - ci) : - !is_founder(u, ci))) { - notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else { - do_set_founder(u, ci, param); - } - } else if (stricmp(cmd, "SUCCESSOR") == 0) { - if (!is_servadmin - && (ci-> - flags & CI_SECUREFOUNDER ? !is_real_founder(u, - ci) : - !is_founder(u, ci))) { - notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else { - do_set_successor(u, ci, param); - } - } else if (stricmp(cmd, "PASSWORD") == 0) { - if (!is_servadmin - && (ci-> - flags & CI_SECUREFOUNDER ? !is_real_founder(u, - ci) : - !is_founder(u, ci))) { - notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else { - do_set_password(u, ci, param); - } - } else if (stricmp(cmd, "DESC") == 0) { - do_set_desc(u, ci, param); - } else if (stricmp(cmd, "URL") == 0) { - do_set_url(u, ci, param); - } else if (stricmp(cmd, "EMAIL") == 0) { - do_set_email(u, ci, param); - } else if (stricmp(cmd, "ENTRYMSG") == 0) { - do_set_entrymsg(u, ci, param); - } else if (stricmp(cmd, "TOPIC") == 0) { - notice_lang(s_ChanServ, u, OBSOLETE_COMMAND, "TOPIC"); - } else if (stricmp(cmd, "BANTYPE") == 0) { - do_set_bantype(u, ci, param); - } else if (stricmp(cmd, "MLOCK") == 0) { - do_set_mlock(u, ci, param); - } else if (stricmp(cmd, "KEEPTOPIC") == 0) { - do_set_keeptopic(u, ci, param); - } else if (stricmp(cmd, "TOPICLOCK") == 0) { - do_set_topiclock(u, ci, param); - } else if (stricmp(cmd, "PRIVATE") == 0) { - do_set_private(u, ci, param); - } else if (stricmp(cmd, "SECUREOPS") == 0) { - do_set_secureops(u, ci, param); - } else if (stricmp(cmd, "SECUREFOUNDER") == 0) { - if (!is_servadmin - && (ci-> - flags & CI_SECUREFOUNDER ? !is_real_founder(u, - ci) : - !is_founder(u, ci))) { - notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else { - do_set_securefounder(u, ci, param); - } - } else if (stricmp(cmd, "RESTRICTED") == 0) { - do_set_restricted(u, ci, param); - } else if (stricmp(cmd, "SECURE") == 0) { - do_set_secure(u, ci, param); - } else if (stricmp(cmd, "SIGNKICK") == 0) { - do_set_signkick(u, ci, param); - } else if (stricmp(cmd, "OPNOTICE") == 0) { - do_set_opnotice(u, ci, param); - } else if (stricmp(cmd, "XOP") == 0) { - if (!(findModule("cs_xop"))) { - notice_lang(s_ChanServ, u, CHAN_XOP_NOT_AVAILABLE, cmd); - } else { - do_set_xop(u, ci, param); - } - } else if (stricmp(cmd, "PEACE") == 0) { - do_set_peace(u, ci, param); - } else if (stricmp(cmd, "NOEXPIRE") == 0) { - do_set_noexpire(u, ci, param); - } else { - notice_lang(s_ChanServ, u, CHAN_SET_UNKNOWN_OPTION, cmd); - notice_lang(s_ChanServ, u, MORE_INFO, s_ChanServ, "SET"); - } - return MOD_CONT; + char *chan = strtok(NULL, " "); + char *cmd = strtok(NULL, " "); + char *param; + ChannelInfo *ci; + int is_servadmin = is_services_admin(u); + + if (readonly) { + notice_lang(s_ChanServ, u, CHAN_SET_DISABLED); + return MOD_CONT; + } + + if (cmd) { + if (stricmp(cmd, "DESC") == 0 || stricmp(cmd, "ENTRYMSG") == 0) + param = strtok(NULL, ""); + else + param = strtok(NULL, " "); + } else { + param = NULL; + } + + if (!param && (!cmd || (stricmp(cmd, "SUCCESSOR") != 0 && + stricmp(cmd, "URL") != 0 && + stricmp(cmd, "EMAIL") != 0 && + stricmp(cmd, "ENTRYMSG") != 0))) { + syntax_error(s_ChanServ, u, "SET", CHAN_SET_SYNTAX); + } else if (!(ci = cs_findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); + } else if (!is_servadmin && !check_access(u, ci, CA_SET)) { + notice_lang(s_ChanServ, u, ACCESS_DENIED); + } else if (stricmp(cmd, "FOUNDER") == 0) { + if (!is_servadmin + && (ci-> + flags & CI_SECUREFOUNDER ? !is_real_founder(u, + ci) : + !is_founder(u, ci))) { + notice_lang(s_ChanServ, u, ACCESS_DENIED); + } else { + do_set_founder(u, ci, param); + } + } else if (stricmp(cmd, "SUCCESSOR") == 0) { + if (!is_servadmin + && (ci-> + flags & CI_SECUREFOUNDER ? !is_real_founder(u, + ci) : + !is_founder(u, ci))) { + notice_lang(s_ChanServ, u, ACCESS_DENIED); + } else { + do_set_successor(u, ci, param); + } + } else if (stricmp(cmd, "PASSWORD") == 0) { + if (!is_servadmin + && (ci-> + flags & CI_SECUREFOUNDER ? !is_real_founder(u, + ci) : + !is_founder(u, ci))) { + notice_lang(s_ChanServ, u, ACCESS_DENIED); + } else { + do_set_password(u, ci, param); + } + } else if (stricmp(cmd, "DESC") == 0) { + do_set_desc(u, ci, param); + } else if (stricmp(cmd, "URL") == 0) { + do_set_url(u, ci, param); + } else if (stricmp(cmd, "EMAIL") == 0) { + do_set_email(u, ci, param); + } else if (stricmp(cmd, "ENTRYMSG") == 0) { + do_set_entrymsg(u, ci, param); + } else if (stricmp(cmd, "TOPIC") == 0) { + notice_lang(s_ChanServ, u, OBSOLETE_COMMAND, "TOPIC"); + } else if (stricmp(cmd, "BANTYPE") == 0) { + do_set_bantype(u, ci, param); + } else if (stricmp(cmd, "MLOCK") == 0) { + do_set_mlock(u, ci, param); + } else if (stricmp(cmd, "KEEPTOPIC") == 0) { + do_set_keeptopic(u, ci, param); + } else if (stricmp(cmd, "TOPICLOCK") == 0) { + do_set_topiclock(u, ci, param); + } else if (stricmp(cmd, "PRIVATE") == 0) { + do_set_private(u, ci, param); + } else if (stricmp(cmd, "SECUREOPS") == 0) { + do_set_secureops(u, ci, param); + } else if (stricmp(cmd, "SECUREFOUNDER") == 0) { + if (!is_servadmin + && (ci-> + flags & CI_SECUREFOUNDER ? !is_real_founder(u, + ci) : + !is_founder(u, ci))) { + notice_lang(s_ChanServ, u, ACCESS_DENIED); + } else { + do_set_securefounder(u, ci, param); + } + } else if (stricmp(cmd, "RESTRICTED") == 0) { + do_set_restricted(u, ci, param); + } else if (stricmp(cmd, "SECURE") == 0) { + do_set_secure(u, ci, param); + } else if (stricmp(cmd, "SIGNKICK") == 0) { + do_set_signkick(u, ci, param); + } else if (stricmp(cmd, "OPNOTICE") == 0) { + do_set_opnotice(u, ci, param); + } else if (stricmp(cmd, "XOP") == 0) { + if (!(findModule("cs_xop"))) { + notice_lang(s_ChanServ, u, CHAN_XOP_NOT_AVAILABLE, cmd); + } else { + do_set_xop(u, ci, param); + } + } else if (stricmp(cmd, "PEACE") == 0) { + do_set_peace(u, ci, param); + } else if (stricmp(cmd, "NOEXPIRE") == 0) { + do_set_noexpire(u, ci, param); + } else { + notice_lang(s_ChanServ, u, CHAN_SET_UNKNOWN_OPTION, cmd); + notice_lang(s_ChanServ, u, MORE_INFO, s_ChanServ, "SET"); + } + return MOD_CONT; } /*************************************************************************/ int do_set_founder(User * u, ChannelInfo * ci, char *param) { - NickAlias *na = findnick(param); - NickCore *nc, *nc0 = ci->founder; - - if (!na) { - notice_lang(s_ChanServ, u, NICK_X_NOT_REGISTERED, param); - return MOD_CONT; - } else if (na->status & NS_VERBOTEN) { - notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, param); - return MOD_CONT; - } - - nc = na->nc; - if (CSMaxReg && nc->channelcount >= CSMaxReg && !is_services_admin(u)) { - notice_lang(s_ChanServ, u, CHAN_SET_FOUNDER_TOO_MANY_CHANS, param); - return MOD_CONT; - } - - alog("%s: Changing founder of %s from %s to %s by %s!%s@%s", - s_ChanServ, ci->name, ci->founder->display, nc->display, u->nick, - u->username, u->host); - - /* Founder and successor must not be the same group */ - if (nc == ci->successor) - ci->successor = NULL; - - nc0->channelcount--; - ci->founder = nc; - nc->channelcount++; - - notice_lang(s_ChanServ, u, CHAN_FOUNDER_CHANGED, ci->name, param); - return MOD_CONT; + NickAlias *na = findnick(param); + NickCore *nc, *nc0 = ci->founder; + + if (!na) { + notice_lang(s_ChanServ, u, NICK_X_NOT_REGISTERED, param); + return MOD_CONT; + } else if (na->status & NS_VERBOTEN) { + notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, param); + return MOD_CONT; + } + + nc = na->nc; + if (CSMaxReg && nc->channelcount >= CSMaxReg && !is_services_admin(u)) { + notice_lang(s_ChanServ, u, CHAN_SET_FOUNDER_TOO_MANY_CHANS, param); + return MOD_CONT; + } + + alog("%s: Changing founder of %s from %s to %s by %s!%s@%s", + s_ChanServ, ci->name, ci->founder->display, nc->display, u->nick, + u->username, u->host); + + /* Founder and successor must not be the same group */ + if (nc == ci->successor) + ci->successor = NULL; + + nc0->channelcount--; + ci->founder = nc; + nc->channelcount++; + + notice_lang(s_ChanServ, u, CHAN_FOUNDER_CHANGED, ci->name, param); + return MOD_CONT; } /*************************************************************************/ int do_set_successor(User * u, ChannelInfo * ci, char *param) { - NickAlias *na; - NickCore *nc; - - if (param) { - na = findnick(param); - - if (!na) { - notice_lang(s_ChanServ, u, NICK_X_NOT_REGISTERED, param); - return MOD_CONT; - } - if (na->status & NS_VERBOTEN) { - notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, param); - return MOD_CONT; - } - if (na->nc == ci->founder) { - notice_lang(s_ChanServ, u, CHAN_SUCCESSOR_IS_FOUNDER, param, - ci->name); - return MOD_CONT; - } - nc = na->nc; - - } else { - nc = NULL; - } - - alog("%s: Changing successor of %s from %s to %s by %s!%s@%s", - s_ChanServ, ci->name, - (ci->successor ? ci->successor->display : "none"), - (nc ? nc->display : "none"), u->nick, u->username, u->host); - - ci->successor = nc; - - if (nc) - notice_lang(s_ChanServ, u, CHAN_SUCCESSOR_CHANGED, ci->name, - param); - else - notice_lang(s_ChanServ, u, CHAN_SUCCESSOR_UNSET, ci->name); - return MOD_CONT; + NickAlias *na; + NickCore *nc; + + if (param) { + na = findnick(param); + + if (!na) { + notice_lang(s_ChanServ, u, NICK_X_NOT_REGISTERED, param); + return MOD_CONT; + } + if (na->status & NS_VERBOTEN) { + notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, param); + return MOD_CONT; + } + if (na->nc == ci->founder) { + notice_lang(s_ChanServ, u, CHAN_SUCCESSOR_IS_FOUNDER, param, + ci->name); + return MOD_CONT; + } + nc = na->nc; + + } else { + nc = NULL; + } + + alog("%s: Changing successor of %s from %s to %s by %s!%s@%s", + s_ChanServ, ci->name, + (ci->successor ? ci->successor->display : "none"), + (nc ? nc->display : "none"), u->nick, u->username, u->host); + + ci->successor = nc; + + if (nc) + notice_lang(s_ChanServ, u, CHAN_SUCCESSOR_CHANGED, ci->name, + param); + else + notice_lang(s_ChanServ, u, CHAN_SUCCESSOR_UNSET, ci->name); + return MOD_CONT; } /*************************************************************************/ int do_set_password(User * u, ChannelInfo * ci, char *param) { - int len = strlen(param); - - if (stricmp(u->nick, param) == 0 || (StrictPasswords && len < 5)) { - notice_lang(s_ChanServ, u, MORE_OBSCURE_PASSWORD); - return MOD_CONT; - } - - if (enc_encrypt_check_len(len ,PASSMAX - 1)) { - notice_lang(s_ChanServ, u, PASSWORD_TOO_LONG); - return MOD_CONT; - } - - if (enc_encrypt(param, len, ci->founderpass, PASSMAX -1) < 0) { - memset(param, 0, strlen(param)); - alog("%s: Failed to encrypt password for %s (set)", s_ChanServ, - ci->name); - notice_lang(s_ChanServ, u, CHAN_SET_PASSWORD_FAILED); - return MOD_CONT; - } - - memset(param, 0, strlen(param)); - notice_lang(s_ChanServ, u, CHAN_PASSWORD_CHANGED, ci->name); - - if (get_access(u, ci) < ACCESS_FOUNDER) { - alog("%s: %s!%s@%s set password as Services admin for %s", - s_ChanServ, u->nick, u->username, u->host, ci->name); - if (WallSetpass) - ircdproto->SendGlobops(s_ChanServ, - "\2%s\2 set password as Services admin for channel \2%s\2", - u->nick, ci->name); - } else { - alog("%s: %s!%s@%s changed password of %s (founder: %s)", - s_ChanServ, u->nick, u->username, u->host, - ci->name, ci->founder->display); - } - return MOD_CONT; + int len = strlen(param); + + if (stricmp(u->nick, param) == 0 || (StrictPasswords && len < 5)) { + notice_lang(s_ChanServ, u, MORE_OBSCURE_PASSWORD); + return MOD_CONT; + } + + if (enc_encrypt_check_len(len ,PASSMAX - 1)) { + notice_lang(s_ChanServ, u, PASSWORD_TOO_LONG); + return MOD_CONT; + } + + if (enc_encrypt(param, len, ci->founderpass, PASSMAX -1) < 0) { + memset(param, 0, strlen(param)); + alog("%s: Failed to encrypt password for %s (set)", s_ChanServ, + ci->name); + notice_lang(s_ChanServ, u, CHAN_SET_PASSWORD_FAILED); + return MOD_CONT; + } + + memset(param, 0, strlen(param)); + notice_lang(s_ChanServ, u, CHAN_PASSWORD_CHANGED, ci->name); + + if (get_access(u, ci) < ACCESS_FOUNDER) { + alog("%s: %s!%s@%s set password as Services admin for %s", + s_ChanServ, u->nick, u->username, u->host, ci->name); + if (WallSetpass) + ircdproto->SendGlobops(s_ChanServ, + "\2%s\2 set password as Services admin for channel \2%s\2", + u->nick, ci->name); + } else { + alog("%s: %s!%s@%s changed password of %s (founder: %s)", + s_ChanServ, u->nick, u->username, u->host, + ci->name, ci->founder->display); + } + return MOD_CONT; } /*************************************************************************/ int do_set_desc(User * u, ChannelInfo * ci, char *param) { - if (ci->desc) - free(ci->desc); - ci->desc = sstrdup(param); - notice_lang(s_ChanServ, u, CHAN_DESC_CHANGED, ci->name, param); - return MOD_CONT; + if (ci->desc) + free(ci->desc); + ci->desc = sstrdup(param); + notice_lang(s_ChanServ, u, CHAN_DESC_CHANGED, ci->name, param); + return MOD_CONT; } /*************************************************************************/ int do_set_url(User * u, ChannelInfo * ci, char *param) { - if (ci->url) - free(ci->url); - if (param) { - ci->url = sstrdup(param); - notice_lang(s_ChanServ, u, CHAN_URL_CHANGED, ci->name, param); - } else { - ci->url = NULL; - notice_lang(s_ChanServ, u, CHAN_URL_UNSET, ci->name); - } - return MOD_CONT; + if (ci->url) + free(ci->url); + if (param) { + ci->url = sstrdup(param); + notice_lang(s_ChanServ, u, CHAN_URL_CHANGED, ci->name, param); + } else { + ci->url = NULL; + notice_lang(s_ChanServ, u, CHAN_URL_UNSET, ci->name); + } + return MOD_CONT; } /*************************************************************************/ int do_set_email(User * u, ChannelInfo * ci, char *param) { - if (ci->email) - free(ci->email); - if (param) { - ci->email = sstrdup(param); - notice_lang(s_ChanServ, u, CHAN_EMAIL_CHANGED, ci->name, param); - } else { - ci->email = NULL; - notice_lang(s_ChanServ, u, CHAN_EMAIL_UNSET, ci->name); - } - return MOD_CONT; + if (ci->email) + free(ci->email); + if (param) { + ci->email = sstrdup(param); + notice_lang(s_ChanServ, u, CHAN_EMAIL_CHANGED, ci->name, param); + } else { + ci->email = NULL; + notice_lang(s_ChanServ, u, CHAN_EMAIL_UNSET, ci->name); + } + return MOD_CONT; } /*************************************************************************/ int do_set_entrymsg(User * u, ChannelInfo * ci, char *param) { - if (ci->entry_message) - free(ci->entry_message); - if (param) { - ci->entry_message = sstrdup(param); - notice_lang(s_ChanServ, u, CHAN_ENTRY_MSG_CHANGED, ci->name, - param); - } else { - ci->entry_message = NULL; - notice_lang(s_ChanServ, u, CHAN_ENTRY_MSG_UNSET, ci->name); - } - return MOD_CONT; + if (ci->entry_message) + free(ci->entry_message); + if (param) { + ci->entry_message = sstrdup(param); + notice_lang(s_ChanServ, u, CHAN_ENTRY_MSG_CHANGED, ci->name, + param); + } else { + ci->entry_message = NULL; + notice_lang(s_ChanServ, u, CHAN_ENTRY_MSG_UNSET, ci->name); + } + return MOD_CONT; } /*************************************************************************/ int do_set_mlock(User * u, ChannelInfo * ci, char *param) { - int add = -1; /* 1 if adding, 0 if deleting, -1 if neither */ - unsigned char mode; - CBMode *cbm; - - if (checkDefCon(DEFCON_NO_MLOCK_CHANGE)) { - notice_lang(s_ChanServ, u, OPER_DEFCON_DENIED); - return MOD_CONT; - } - - /* Reinitialize everything */ - if (ircd->chanreg) { - ci->mlock_on = ircd->regmode; - } else { - ci->mlock_on = 0; - } - ci->mlock_off = ci->mlock_limit = 0; - ci->mlock_key = NULL; - if (ircd->fmode) { - ci->mlock_flood = NULL; - } - if (ircd->Lmode) { - ci->mlock_redirect = NULL; - } - - while ((mode = *param++)) { - switch (mode) { - case '+': - add = 1; - continue; - case '-': - add = 0; - continue; - default: - if (add < 0) - continue; - } - - if ((int) mode < 128 && (cbm = &cbmodes[(int) mode])->flag != 0) { - if ((cbm->flags & CBM_NO_MLOCK) - || ((cbm->flags & CBM_NO_USER_MLOCK) && !is_oper(u))) { - notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_IMPOSSIBLE_CHAR, - mode); - } else if (add) { - ci->mlock_on |= cbm->flag; - ci->mlock_off &= ~cbm->flag; - if (cbm->cssetvalue) - cbm->cssetvalue(ci, strtok(NULL, " ")); - } else { - ci->mlock_off |= cbm->flag; - if (ci->mlock_on & cbm->flag) { - ci->mlock_on &= ~cbm->flag; - if (cbm->cssetvalue) - cbm->cssetvalue(ci, NULL); - } - } - } else { - notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_UNKNOWN_CHAR, mode); - } - } /* while (*param) */ - - if (ircd->Lmode) { - /* We can't mlock +L if +l is not mlocked as well. */ - if ((ci->mlock_on & ircd->chan_lmode) - && !(ci->mlock_on & anope_get_limit_mode())) { - ci->mlock_on &= ~ircd->chan_lmode; - free(ci->mlock_redirect); - notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_L_REQUIRED); - } - } - - /* Some ircd we can't set NOKNOCK without INVITE */ - /* So check if we need there is a NOKNOCK MODE and that we need INVITEONLY */ - if (ircd->noknock && ircd->knock_needs_i) { - if ((ci->mlock_on & ircd->noknock) - && !(ci->mlock_on & anope_get_invite_mode())) { - ci->mlock_on &= ~ircd->noknock; - notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_K_REQUIRED); - } - } - - /* Since we always enforce mode r there is no way to have no - * mode lock at all. - */ - if (get_mlock_modes(ci, 0)) { - notice_lang(s_ChanServ, u, CHAN_MLOCK_CHANGED, ci->name, - get_mlock_modes(ci, 0)); - } - - /* Implement the new lock. */ - if (ci->c) - check_modes(ci->c); - return MOD_CONT; + int add = -1; /* 1 if adding, 0 if deleting, -1 if neither */ + unsigned char mode; + CBMode *cbm; + + if (checkDefCon(DEFCON_NO_MLOCK_CHANGE)) { + notice_lang(s_ChanServ, u, OPER_DEFCON_DENIED); + return MOD_CONT; + } + + /* Reinitialize everything */ + if (ircd->chanreg) { + ci->mlock_on = ircd->regmode; + } else { + ci->mlock_on = 0; + } + ci->mlock_off = ci->mlock_limit = 0; + ci->mlock_key = NULL; + if (ircd->fmode) { + ci->mlock_flood = NULL; + } + if (ircd->Lmode) { + ci->mlock_redirect = NULL; + } + + while ((mode = *param++)) { + switch (mode) { + case '+': + add = 1; + continue; + case '-': + add = 0; + continue; + default: + if (add < 0) + continue; + } + + if ((int) mode < 128 && (cbm = &cbmodes[(int) mode])->flag != 0) { + if ((cbm->flags & CBM_NO_MLOCK) + || ((cbm->flags & CBM_NO_USER_MLOCK) && !is_oper(u))) { + notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_IMPOSSIBLE_CHAR, + mode); + } else if (add) { + ci->mlock_on |= cbm->flag; + ci->mlock_off &= ~cbm->flag; + if (cbm->cssetvalue) + cbm->cssetvalue(ci, strtok(NULL, " ")); + } else { + ci->mlock_off |= cbm->flag; + if (ci->mlock_on & cbm->flag) { + ci->mlock_on &= ~cbm->flag; + if (cbm->cssetvalue) + cbm->cssetvalue(ci, NULL); + } + } + } else { + notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_UNKNOWN_CHAR, mode); + } + } /* while (*param) */ + + if (ircd->Lmode) { + /* We can't mlock +L if +l is not mlocked as well. */ + if ((ci->mlock_on & ircd->chan_lmode) + && !(ci->mlock_on & anope_get_limit_mode())) { + ci->mlock_on &= ~ircd->chan_lmode; + free(ci->mlock_redirect); + notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_L_REQUIRED); + } + } + + /* Some ircd we can't set NOKNOCK without INVITE */ + /* So check if we need there is a NOKNOCK MODE and that we need INVITEONLY */ + if (ircd->noknock && ircd->knock_needs_i) { + if ((ci->mlock_on & ircd->noknock) + && !(ci->mlock_on & anope_get_invite_mode())) { + ci->mlock_on &= ~ircd->noknock; + notice_lang(s_ChanServ, u, CHAN_SET_MLOCK_K_REQUIRED); + } + } + + /* Since we always enforce mode r there is no way to have no + * mode lock at all. + */ + if (get_mlock_modes(ci, 0)) { + notice_lang(s_ChanServ, u, CHAN_MLOCK_CHANGED, ci->name, + get_mlock_modes(ci, 0)); + } + + /* Implement the new lock. */ + if (ci->c) + check_modes(ci->c); + return MOD_CONT; } /*************************************************************************/ int do_set_bantype(User * u, ChannelInfo * ci, char *param) { - char *endptr; - - int16 bantype = strtol(param, &endptr, 10); - - if (*endptr != 0 || bantype < 0 || bantype > 3) { - notice_lang(s_ChanServ, u, CHAN_SET_BANTYPE_INVALID, param); - } else { - ci->bantype = bantype; - notice_lang(s_ChanServ, u, CHAN_SET_BANTYPE_CHANGED, ci->name, - ci->bantype); - } - return MOD_CONT; + char *endptr; + + int16 bantype = strtol(param, &endptr, 10); + + if (*endptr != 0 || bantype < 0 || bantype > 3) { + notice_lang(s_ChanServ, u, CHAN_SET_BANTYPE_INVALID, param); + } else { + ci->bantype = bantype; + notice_lang(s_ChanServ, u, CHAN_SET_BANTYPE_CHANGED, ci->name, + ci->bantype); + } + return MOD_CONT; } /*************************************************************************/ int do_set_keeptopic(User * u, ChannelInfo * ci, char *param) { - if (stricmp(param, "ON") == 0) { - ci->flags |= CI_KEEPTOPIC; - notice_lang(s_ChanServ, u, CHAN_SET_KEEPTOPIC_ON, ci->name); - } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~CI_KEEPTOPIC; - notice_lang(s_ChanServ, u, CHAN_SET_KEEPTOPIC_OFF, ci->name); - } else { - syntax_error(s_ChanServ, u, "SET KEEPTOPIC", - CHAN_SET_KEEPTOPIC_SYNTAX); - } - return MOD_CONT; + if (stricmp(param, "ON") == 0) { + ci->flags |= CI_KEEPTOPIC; + notice_lang(s_ChanServ, u, CHAN_SET_KEEPTOPIC_ON, ci->name); + } else if (stricmp(param, "OFF") == 0) { + ci->flags &= ~CI_KEEPTOPIC; + notice_lang(s_ChanServ, u, CHAN_SET_KEEPTOPIC_OFF, ci->name); + } else { + syntax_error(s_ChanServ, u, "SET KEEPTOPIC", + CHAN_SET_KEEPTOPIC_SYNTAX); + } + return MOD_CONT; } /*************************************************************************/ int do_set_topiclock(User * u, ChannelInfo * ci, char *param) { - if (stricmp(param, "ON") == 0) { - ci->flags |= CI_TOPICLOCK; - notice_lang(s_ChanServ, u, CHAN_SET_TOPICLOCK_ON, ci->name); - } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~CI_TOPICLOCK; - notice_lang(s_ChanServ, u, CHAN_SET_TOPICLOCK_OFF, ci->name); - } else { - syntax_error(s_ChanServ, u, "SET TOPICLOCK", - CHAN_SET_TOPICLOCK_SYNTAX); - } - return MOD_CONT; + if (stricmp(param, "ON") == 0) { + ci->flags |= CI_TOPICLOCK; + notice_lang(s_ChanServ, u, CHAN_SET_TOPICLOCK_ON, ci->name); + } else if (stricmp(param, "OFF") == 0) { + ci->flags &= ~CI_TOPICLOCK; + notice_lang(s_ChanServ, u, CHAN_SET_TOPICLOCK_OFF, ci->name); + } else { + syntax_error(s_ChanServ, u, "SET TOPICLOCK", + CHAN_SET_TOPICLOCK_SYNTAX); + } + return MOD_CONT; } /*************************************************************************/ int do_set_private(User * u, ChannelInfo * ci, char *param) { - if (stricmp(param, "ON") == 0) { - ci->flags |= CI_PRIVATE; - notice_lang(s_ChanServ, u, CHAN_SET_PRIVATE_ON, ci->name); - } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~CI_PRIVATE; - notice_lang(s_ChanServ, u, CHAN_SET_PRIVATE_OFF, ci->name); - } else { - syntax_error(s_ChanServ, u, "SET PRIVATE", - CHAN_SET_PRIVATE_SYNTAX); - } - return MOD_CONT; + if (stricmp(param, "ON") == 0) { + ci->flags |= CI_PRIVATE; + notice_lang(s_ChanServ, u, CHAN_SET_PRIVATE_ON, ci->name); + } else if (stricmp(param, "OFF") == 0) { + ci->flags &= ~CI_PRIVATE; + notice_lang(s_ChanServ, u, CHAN_SET_PRIVATE_OFF, ci->name); + } else { + syntax_error(s_ChanServ, u, "SET PRIVATE", + CHAN_SET_PRIVATE_SYNTAX); + } + return MOD_CONT; } /*************************************************************************/ int do_set_secureops(User * u, ChannelInfo * ci, char *param) { - if (stricmp(param, "ON") == 0) { - ci->flags |= CI_SECUREOPS; - notice_lang(s_ChanServ, u, CHAN_SET_SECUREOPS_ON, ci->name); - } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~CI_SECUREOPS; - notice_lang(s_ChanServ, u, CHAN_SET_SECUREOPS_OFF, ci->name); - } else { - syntax_error(s_ChanServ, u, "SET SECUREOPS", - CHAN_SET_SECUREOPS_SYNTAX); - } - return MOD_CONT; + if (stricmp(param, "ON") == 0) { + ci->flags |= CI_SECUREOPS; + notice_lang(s_ChanServ, u, CHAN_SET_SECUREOPS_ON, ci->name); + } else if (stricmp(param, "OFF") == 0) { + ci->flags &= ~CI_SECUREOPS; + notice_lang(s_ChanServ, u, CHAN_SET_SECUREOPS_OFF, ci->name); + } else { + syntax_error(s_ChanServ, u, "SET SECUREOPS", + CHAN_SET_SECUREOPS_SYNTAX); + } + return MOD_CONT; } /*************************************************************************/ int do_set_securefounder(User * u, ChannelInfo * ci, char *param) { - if (stricmp(param, "ON") == 0) { - ci->flags |= CI_SECUREFOUNDER; - notice_lang(s_ChanServ, u, CHAN_SET_SECUREFOUNDER_ON, ci->name); - } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~CI_SECUREFOUNDER; - notice_lang(s_ChanServ, u, CHAN_SET_SECUREFOUNDER_OFF, ci->name); - } else { - syntax_error(s_ChanServ, u, "SET SECUREFOUNDER", - CHAN_SET_SECUREFOUNDER_SYNTAX); - } - return MOD_CONT; + if (stricmp(param, "ON") == 0) { + ci->flags |= CI_SECUREFOUNDER; + notice_lang(s_ChanServ, u, CHAN_SET_SECUREFOUNDER_ON, ci->name); + } else if (stricmp(param, "OFF") == 0) { + ci->flags &= ~CI_SECUREFOUNDER; + notice_lang(s_ChanServ, u, CHAN_SET_SECUREFOUNDER_OFF, ci->name); + } else { + syntax_error(s_ChanServ, u, "SET SECUREFOUNDER", + CHAN_SET_SECUREFOUNDER_SYNTAX); + } + return MOD_CONT; } /*************************************************************************/ int do_set_restricted(User * u, ChannelInfo * ci, char *param) { - if (stricmp(param, "ON") == 0) { - ci->flags |= CI_RESTRICTED; - if (ci->levels[CA_NOJOIN] < 0) - ci->levels[CA_NOJOIN] = 0; - notice_lang(s_ChanServ, u, CHAN_SET_RESTRICTED_ON, ci->name); - } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~CI_RESTRICTED; - if (ci->levels[CA_NOJOIN] >= 0) - ci->levels[CA_NOJOIN] = -2; - notice_lang(s_ChanServ, u, CHAN_SET_RESTRICTED_OFF, ci->name); - } else { - syntax_error(s_ChanServ, u, "SET RESTRICTED", - CHAN_SET_RESTRICTED_SYNTAX); - } - return MOD_CONT; + if (stricmp(param, "ON") == 0) { + ci->flags |= CI_RESTRICTED; + if (ci->levels[CA_NOJOIN] < 0) + ci->levels[CA_NOJOIN] = 0; + notice_lang(s_ChanServ, u, CHAN_SET_RESTRICTED_ON, ci->name); + } else if (stricmp(param, "OFF") == 0) { + ci->flags &= ~CI_RESTRICTED; + if (ci->levels[CA_NOJOIN] >= 0) + ci->levels[CA_NOJOIN] = -2; + notice_lang(s_ChanServ, u, CHAN_SET_RESTRICTED_OFF, ci->name); + } else { + syntax_error(s_ChanServ, u, "SET RESTRICTED", + CHAN_SET_RESTRICTED_SYNTAX); + } + return MOD_CONT; } /*************************************************************************/ int do_set_secure(User * u, ChannelInfo * ci, char *param) { - if (stricmp(param, "ON") == 0) { - ci->flags |= CI_SECURE; - notice_lang(s_ChanServ, u, CHAN_SET_SECURE_ON, ci->name); - } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~CI_SECURE; - notice_lang(s_ChanServ, u, CHAN_SET_SECURE_OFF, ci->name); - } else { - syntax_error(s_ChanServ, u, "SET SECURE", CHAN_SET_SECURE_SYNTAX); - } - return MOD_CONT; + if (stricmp(param, "ON") == 0) { + ci->flags |= CI_SECURE; + notice_lang(s_ChanServ, u, CHAN_SET_SECURE_ON, ci->name); + } else if (stricmp(param, "OFF") == 0) { + ci->flags &= ~CI_SECURE; + notice_lang(s_ChanServ, u, CHAN_SET_SECURE_OFF, ci->name); + } else { + syntax_error(s_ChanServ, u, "SET SECURE", CHAN_SET_SECURE_SYNTAX); + } + return MOD_CONT; } /*************************************************************************/ int do_set_signkick(User * u, ChannelInfo * ci, char *param) { - if (stricmp(param, "ON") == 0) { - ci->flags |= CI_SIGNKICK; - ci->flags &= ~CI_SIGNKICK_LEVEL; - notice_lang(s_ChanServ, u, CHAN_SET_SIGNKICK_ON, ci->name); - } else if (stricmp(param, "LEVEL") == 0) { - ci->flags |= CI_SIGNKICK_LEVEL; - ci->flags &= ~CI_SIGNKICK; - notice_lang(s_ChanServ, u, CHAN_SET_SIGNKICK_LEVEL, ci->name); - } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~(CI_SIGNKICK | CI_SIGNKICK_LEVEL); - notice_lang(s_ChanServ, u, CHAN_SET_SIGNKICK_OFF, ci->name); - } else { - syntax_error(s_ChanServ, u, "SET SIGNKICK", - CHAN_SET_SIGNKICK_SYNTAX); - } - return MOD_CONT; + if (stricmp(param, "ON") == 0) { + ci->flags |= CI_SIGNKICK; + ci->flags &= ~CI_SIGNKICK_LEVEL; + notice_lang(s_ChanServ, u, CHAN_SET_SIGNKICK_ON, ci->name); + } else if (stricmp(param, "LEVEL") == 0) { + ci->flags |= CI_SIGNKICK_LEVEL; + ci->flags &= ~CI_SIGNKICK; + notice_lang(s_ChanServ, u, CHAN_SET_SIGNKICK_LEVEL, ci->name); + } else if (stricmp(param, "OFF") == 0) { + ci->flags &= ~(CI_SIGNKICK | CI_SIGNKICK_LEVEL); + notice_lang(s_ChanServ, u, CHAN_SET_SIGNKICK_OFF, ci->name); + } else { + syntax_error(s_ChanServ, u, "SET SIGNKICK", + CHAN_SET_SIGNKICK_SYNTAX); + } + return MOD_CONT; } /*************************************************************************/ int do_set_opnotice(User * u, ChannelInfo * ci, char *param) { - if (stricmp(param, "ON") == 0) { - ci->flags |= CI_OPNOTICE; - notice_lang(s_ChanServ, u, CHAN_SET_OPNOTICE_ON, ci->name); - } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~CI_OPNOTICE; - notice_lang(s_ChanServ, u, CHAN_SET_OPNOTICE_OFF, ci->name); - } else { - syntax_error(s_ChanServ, u, "SET OPNOTICE", - CHAN_SET_OPNOTICE_SYNTAX); - } - return MOD_CONT; + if (stricmp(param, "ON") == 0) { + ci->flags |= CI_OPNOTICE; + notice_lang(s_ChanServ, u, CHAN_SET_OPNOTICE_ON, ci->name); + } else if (stricmp(param, "OFF") == 0) { + ci->flags &= ~CI_OPNOTICE; + notice_lang(s_ChanServ, u, CHAN_SET_OPNOTICE_OFF, ci->name); + } else { + syntax_error(s_ChanServ, u, "SET OPNOTICE", + CHAN_SET_OPNOTICE_SYNTAX); + } + return MOD_CONT; } /*************************************************************************/ @@ -712,54 +712,54 @@ int do_set_opnotice(User * u, ChannelInfo * ci, char *param) int do_set_xop(User * u, ChannelInfo * ci, char *param) { - if (stricmp(param, "ON") == 0) { - if (!(ci->flags & CI_XOP)) { - int i; - ChanAccess *access; - - for (access = ci->access, i = 0; i < ci->accesscount; - access++, i++) { - if (!access->in_use) - continue; - /* This will probably cause wrong levels to be set, but hey, - * it's better than losing it altogether. - */ - if (CHECKLEV(CA_AKICK) || CHECKLEV(CA_SET)) { - access->level = ACCESS_SOP; - } else if (CHECKLEV(CA_AUTOOP) || CHECKLEV(CA_OPDEOP) - || CHECKLEV(CA_OPDEOPME)) { - access->level = ACCESS_AOP; - } else if (ircd->halfop) { - if (CHECKLEV(CA_AUTOHALFOP) || CHECKLEV(CA_HALFOP) - || CHECKLEV(CA_HALFOPME)) { - access->level = ACCESS_HOP; - } - } else if (CHECKLEV(CA_AUTOVOICE) || CHECKLEV(CA_VOICE) - || CHECKLEV(CA_VOICEME)) { - access->level = ACCESS_VOP; - } else { - access->in_use = 0; - access->nc = NULL; - } - } - - reset_levels(ci); - ci->flags |= CI_XOP; - } - - alog("%s: %s!%s@%s enabled XOP for %s", s_ChanServ, u->nick, - u->username, u->host, ci->name); - notice_lang(s_ChanServ, u, CHAN_SET_XOP_ON, ci->name); - } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~CI_XOP; - - alog("%s: %s!%s@%s disabled XOP for %s", s_ChanServ, u->nick, - u->username, u->host, ci->name); - notice_lang(s_ChanServ, u, CHAN_SET_XOP_OFF, ci->name); - } else { - syntax_error(s_ChanServ, u, "SET XOP", CHAN_SET_XOP_SYNTAX); - } - return MOD_CONT; + if (stricmp(param, "ON") == 0) { + if (!(ci->flags & CI_XOP)) { + int i; + ChanAccess *access; + + for (access = ci->access, i = 0; i < ci->accesscount; + access++, i++) { + if (!access->in_use) + continue; + /* This will probably cause wrong levels to be set, but hey, + * it's better than losing it altogether. + */ + if (CHECKLEV(CA_AKICK) || CHECKLEV(CA_SET)) { + access->level = ACCESS_SOP; + } else if (CHECKLEV(CA_AUTOOP) || CHECKLEV(CA_OPDEOP) + || CHECKLEV(CA_OPDEOPME)) { + access->level = ACCESS_AOP; + } else if (ircd->halfop) { + if (CHECKLEV(CA_AUTOHALFOP) || CHECKLEV(CA_HALFOP) + || CHECKLEV(CA_HALFOPME)) { + access->level = ACCESS_HOP; + } + } else if (CHECKLEV(CA_AUTOVOICE) || CHECKLEV(CA_VOICE) + || CHECKLEV(CA_VOICEME)) { + access->level = ACCESS_VOP; + } else { + access->in_use = 0; + access->nc = NULL; + } + } + + reset_levels(ci); + ci->flags |= CI_XOP; + } + + alog("%s: %s!%s@%s enabled XOP for %s", s_ChanServ, u->nick, + u->username, u->host, ci->name); + notice_lang(s_ChanServ, u, CHAN_SET_XOP_ON, ci->name); + } else if (stricmp(param, "OFF") == 0) { + ci->flags &= ~CI_XOP; + + alog("%s: %s!%s@%s disabled XOP for %s", s_ChanServ, u->nick, + u->username, u->host, ci->name); + notice_lang(s_ChanServ, u, CHAN_SET_XOP_OFF, ci->name); + } else { + syntax_error(s_ChanServ, u, "SET XOP", CHAN_SET_XOP_SYNTAX); + } + return MOD_CONT; } #undef CHECKLEV @@ -768,37 +768,37 @@ int do_set_xop(User * u, ChannelInfo * ci, char *param) int do_set_peace(User * u, ChannelInfo * ci, char *param) { - if (stricmp(param, "ON") == 0) { - ci->flags |= CI_PEACE; - notice_lang(s_ChanServ, u, CHAN_SET_PEACE_ON, ci->name); - } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~CI_PEACE; - notice_lang(s_ChanServ, u, CHAN_SET_PEACE_OFF, ci->name); - } else { - syntax_error(s_ChanServ, u, "SET PEACE", CHAN_SET_PEACE_SYNTAX); - } - return MOD_CONT; + if (stricmp(param, "ON") == 0) { + ci->flags |= CI_PEACE; + notice_lang(s_ChanServ, u, CHAN_SET_PEACE_ON, ci->name); + } else if (stricmp(param, "OFF") == 0) { + ci->flags &= ~CI_PEACE; + notice_lang(s_ChanServ, u, CHAN_SET_PEACE_OFF, ci->name); + } else { + syntax_error(s_ChanServ, u, "SET PEACE", CHAN_SET_PEACE_SYNTAX); + } + return MOD_CONT; } /*************************************************************************/ int do_set_noexpire(User * u, ChannelInfo * ci, char *param) { - if (!is_services_admin(u)) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - return MOD_CONT; - } - if (stricmp(param, "ON") == 0) { - ci->flags |= CI_NO_EXPIRE; - notice_lang(s_ChanServ, u, CHAN_SET_NOEXPIRE_ON, ci->name); - } else if (stricmp(param, "OFF") == 0) { - ci->flags &= ~CI_NO_EXPIRE; - notice_lang(s_ChanServ, u, CHAN_SET_NOEXPIRE_OFF, ci->name); - } else { - syntax_error(s_ChanServ, u, "SET NOEXPIRE", - CHAN_SET_NOEXPIRE_SYNTAX); - } - return MOD_CONT; + if (!is_services_admin(u)) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + return MOD_CONT; + } + if (stricmp(param, "ON") == 0) { + ci->flags |= CI_NO_EXPIRE; + notice_lang(s_ChanServ, u, CHAN_SET_NOEXPIRE_ON, ci->name); + } else if (stricmp(param, "OFF") == 0) { + ci->flags &= ~CI_NO_EXPIRE; + notice_lang(s_ChanServ, u, CHAN_SET_NOEXPIRE_OFF, ci->name); + } else { + syntax_error(s_ChanServ, u, "SET NOEXPIRE", + CHAN_SET_NOEXPIRE_SYNTAX); + } + return MOD_CONT; } MODULE_INIT("cs_set", CSSet) diff --git a/src/core/cs_status.c b/src/core/cs_status.c index 3a3a8301a..419688611 100644 --- a/src/core/cs_status.c +++ b/src/core/cs_status.c @@ -44,9 +44,9 @@ class CSStatus : public Module **/ void myChanServHelp(User * u) { - if (is_services_admin(u)) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_STATUS); - } + if (is_services_admin(u)) { + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_STATUS); + } } /** @@ -56,35 +56,35 @@ void myChanServHelp(User * u) **/ int do_status(User * u) { - ChannelInfo *ci; - User *u2; - char *nick, *chan; - char *temp = NULL; + ChannelInfo *ci; + User *u2; + char *nick, *chan; + char *temp = NULL; - chan = strtok(NULL, " "); - nick = strtok(NULL, " "); - if (!nick || strtok(NULL, " ")) { - notice_lang(s_ChanServ, u, CHAN_STATUS_SYNTAX); - return MOD_CONT; - } - if (!(ci = cs_findchan(chan))) { - temp = chan; - chan = nick; - nick = temp; - ci = cs_findchan(chan); - } - if (!ci) { - notice_lang(s_ChanServ, u, CHAN_STATUS_NOT_REGGED, temp); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_ChanServ, u, CHAN_STATUS_FORBIDDEN, chan); - return MOD_CONT; - } else if ((u2 = finduser(nick)) != NULL) { - notice_lang(s_ChanServ, u, CHAN_STATUS_INFO, chan, nick, - get_access(u2, ci)); - } else { /* !u2 */ - notice_lang(s_ChanServ, u, CHAN_STATUS_NOTONLINE, nick); - } - return MOD_CONT; + chan = strtok(NULL, " "); + nick = strtok(NULL, " "); + if (!nick || strtok(NULL, " ")) { + notice_lang(s_ChanServ, u, CHAN_STATUS_SYNTAX); + return MOD_CONT; + } + if (!(ci = cs_findchan(chan))) { + temp = chan; + chan = nick; + nick = temp; + ci = cs_findchan(chan); + } + if (!ci) { + notice_lang(s_ChanServ, u, CHAN_STATUS_NOT_REGGED, temp); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_STATUS_FORBIDDEN, chan); + return MOD_CONT; + } else if ((u2 = finduser(nick)) != NULL) { + notice_lang(s_ChanServ, u, CHAN_STATUS_INFO, chan, nick, + get_access(u2, ci)); + } else { /* !u2 */ + notice_lang(s_ChanServ, u, CHAN_STATUS_NOTONLINE, nick); + } + return MOD_CONT; } MODULE_INIT("cs_status", CSStatus) diff --git a/src/core/cs_suspend.c b/src/core/cs_suspend.c index 21b4a5f1a..fd9500e90 100644 --- a/src/core/cs_suspend.c +++ b/src/core/cs_suspend.c @@ -46,10 +46,10 @@ class CSSuspend : public Module **/ void myChanServHelp(User * u) { - if (is_services_oper(u)) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_SUSPEND); - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_UNSUSPEND); - } + if (is_services_oper(u)) { + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_SUSPEND); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_UNSUSPEND); + } } /** @@ -59,140 +59,140 @@ void myChanServHelp(User * u) **/ int do_suspend(User * u) { - ChannelInfo *ci; - char *chan = strtok(NULL, " "); - char *reason = strtok(NULL, ""); - - Channel *c; - - /* Assumes that permission checking has already been done. */ - if (!chan || (ForceForbidReason && !reason)) { - syntax_error(s_ChanServ, u, "SUSPEND", - (ForceForbidReason ? CHAN_SUSPEND_SYNTAX_REASON : - CHAN_SUSPEND_SYNTAX)); - return MOD_CONT; - } - - if (chan[0] != '#') { - notice_lang(s_ChanServ, u, CHAN_UNSUSPEND_ERROR); - return MOD_CONT; - } - - /* Only SUSPEND existing channels, otherwise use FORBID (bug #54) */ - if ((ci = cs_findchan(chan)) == NULL) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); - return MOD_CONT; - } - - /* You should not SUSPEND a FORBIDEN channel */ - if (ci->flags & CI_VERBOTEN) { - notice_lang(s_ChanServ, u, CHAN_MAY_NOT_BE_REGISTERED, chan); - return MOD_CONT; - } - - if (readonly) - notice_lang(s_ChanServ, u, READ_ONLY_MODE); - - if (ci) { - ci->flags |= CI_SUSPENDED; - ci->forbidby = sstrdup(u->nick); - if (reason) - ci->forbidreason = sstrdup(reason); - - if ((c = findchan(ci->name))) { - struct c_userlist *cu, *next; - const char *av[3]; - - for (cu = c->users; cu; cu = next) { - next = cu->next; - - if (is_oper(cu->user)) - continue; - - av[0] = c->name; - av[1] = cu->user->nick; - av[2] = reason ? reason : "CHAN_SUSPEND_REASON"; - ircdproto->SendKick(findbot(s_ChanServ), av[0], av[1], av[2]); - do_kick(s_ChanServ, 3, av); - } - } - - if (WallForbid) - ircdproto->SendGlobops(s_ChanServ, - "\2%s\2 used SUSPEND on channel \2%s\2", - u->nick, ci->name); - - alog("%s: %s set SUSPEND for channel %s", s_ChanServ, u->nick, - ci->name); - notice_lang(s_ChanServ, u, CHAN_SUSPEND_SUCCEEDED, chan); - send_event(EVENT_CHAN_SUSPENDED, 1, chan); - } else { - alog("%s: Valid SUSPEND for %s by %s failed", s_ChanServ, ci->name, - u->nick); - notice_lang(s_ChanServ, u, CHAN_SUSPEND_FAILED, chan); - } - return MOD_CONT; + ChannelInfo *ci; + char *chan = strtok(NULL, " "); + char *reason = strtok(NULL, ""); + + Channel *c; + + /* Assumes that permission checking has already been done. */ + if (!chan || (ForceForbidReason && !reason)) { + syntax_error(s_ChanServ, u, "SUSPEND", + (ForceForbidReason ? CHAN_SUSPEND_SYNTAX_REASON : + CHAN_SUSPEND_SYNTAX)); + return MOD_CONT; + } + + if (chan[0] != '#') { + notice_lang(s_ChanServ, u, CHAN_UNSUSPEND_ERROR); + return MOD_CONT; + } + + /* Only SUSPEND existing channels, otherwise use FORBID (bug #54) */ + if ((ci = cs_findchan(chan)) == NULL) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + return MOD_CONT; + } + + /* You should not SUSPEND a FORBIDEN channel */ + if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_MAY_NOT_BE_REGISTERED, chan); + return MOD_CONT; + } + + if (readonly) + notice_lang(s_ChanServ, u, READ_ONLY_MODE); + + if (ci) { + ci->flags |= CI_SUSPENDED; + ci->forbidby = sstrdup(u->nick); + if (reason) + ci->forbidreason = sstrdup(reason); + + if ((c = findchan(ci->name))) { + struct c_userlist *cu, *next; + const char *av[3]; + + for (cu = c->users; cu; cu = next) { + next = cu->next; + + if (is_oper(cu->user)) + continue; + + av[0] = c->name; + av[1] = cu->user->nick; + av[2] = reason ? reason : "CHAN_SUSPEND_REASON"; + ircdproto->SendKick(findbot(s_ChanServ), av[0], av[1], av[2]); + do_kick(s_ChanServ, 3, av); + } + } + + if (WallForbid) + ircdproto->SendGlobops(s_ChanServ, + "\2%s\2 used SUSPEND on channel \2%s\2", + u->nick, ci->name); + + alog("%s: %s set SUSPEND for channel %s", s_ChanServ, u->nick, + ci->name); + notice_lang(s_ChanServ, u, CHAN_SUSPEND_SUCCEEDED, chan); + send_event(EVENT_CHAN_SUSPENDED, 1, chan); + } else { + alog("%s: Valid SUSPEND for %s by %s failed", s_ChanServ, ci->name, + u->nick); + notice_lang(s_ChanServ, u, CHAN_SUSPEND_FAILED, chan); + } + return MOD_CONT; } /*************************************************************************/ int do_unsuspend(User * u) { - ChannelInfo *ci; - char *chan = strtok(NULL, " "); - - /* Assumes that permission checking has already been done. */ - if (!chan) { - syntax_error(s_ChanServ, u, "UNSUSPEND", CHAN_UNSUSPEND_SYNTAX); - return MOD_CONT; - } - if (chan[0] != '#') { - notice_lang(s_ChanServ, u, CHAN_UNSUSPEND_ERROR); - return MOD_CONT; - } - if (readonly) - notice_lang(s_ChanServ, u, READ_ONLY_MODE); - - /* Only UNSUSPEND already suspended channels */ - if ((ci = cs_findchan(chan)) == NULL) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); - return MOD_CONT; - } - - if (!(ci->flags & CI_SUSPENDED)) - { - notice_lang(s_ChanServ, u, CHAN_UNSUSPEND_FAILED, chan); - return MOD_CONT; - } - - if (ci) { - ci->flags &= ~CI_SUSPENDED; - if (ci->forbidreason) - { - free(ci->forbidreason); - ci->forbidreason = NULL; - } - if (ci->forbidby) - { - free(ci->forbidby); - ci->forbidby = NULL; - } - - if (WallForbid) - ircdproto->SendGlobops(s_ChanServ, - "\2%s\2 used UNSUSPEND on channel \2%s\2", - u->nick, ci->name); - - alog("%s: %s set UNSUSPEND for channel %s", s_ChanServ, u->nick, - ci->name); - notice_lang(s_ChanServ, u, CHAN_UNSUSPEND_SUCCEEDED, chan); - send_event(EVENT_CHAN_UNSUSPEND, 1, chan); - } else { - alog("%s: Valid UNSUSPEND for %s by %s failed", s_ChanServ, - chan, u->nick); - notice_lang(s_ChanServ, u, CHAN_UNSUSPEND_FAILED, chan); - } - return MOD_CONT; + ChannelInfo *ci; + char *chan = strtok(NULL, " "); + + /* Assumes that permission checking has already been done. */ + if (!chan) { + syntax_error(s_ChanServ, u, "UNSUSPEND", CHAN_UNSUSPEND_SYNTAX); + return MOD_CONT; + } + if (chan[0] != '#') { + notice_lang(s_ChanServ, u, CHAN_UNSUSPEND_ERROR); + return MOD_CONT; + } + if (readonly) + notice_lang(s_ChanServ, u, READ_ONLY_MODE); + + /* Only UNSUSPEND already suspended channels */ + if ((ci = cs_findchan(chan)) == NULL) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + return MOD_CONT; + } + + if (!(ci->flags & CI_SUSPENDED)) + { + notice_lang(s_ChanServ, u, CHAN_UNSUSPEND_FAILED, chan); + return MOD_CONT; + } + + if (ci) { + ci->flags &= ~CI_SUSPENDED; + if (ci->forbidreason) + { + free(ci->forbidreason); + ci->forbidreason = NULL; + } + if (ci->forbidby) + { + free(ci->forbidby); + ci->forbidby = NULL; + } + + if (WallForbid) + ircdproto->SendGlobops(s_ChanServ, + "\2%s\2 used UNSUSPEND on channel \2%s\2", + u->nick, ci->name); + + alog("%s: %s set UNSUSPEND for channel %s", s_ChanServ, u->nick, + ci->name); + notice_lang(s_ChanServ, u, CHAN_UNSUSPEND_SUCCEEDED, chan); + send_event(EVENT_CHAN_UNSUSPEND, 1, chan); + } else { + alog("%s: Valid UNSUSPEND for %s by %s failed", s_ChanServ, + chan, u->nick); + notice_lang(s_ChanServ, u, CHAN_UNSUSPEND_FAILED, chan); + } + return MOD_CONT; } MODULE_INIT("cs_suspend", CSSuspend) diff --git a/src/core/cs_topic.c b/src/core/cs_topic.c index c73de365c..111042403 100644 --- a/src/core/cs_topic.c +++ b/src/core/cs_topic.c @@ -43,7 +43,7 @@ class CSTopic : public Module **/ void myChanServHelp(User * u) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_TOPIC); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_TOPIC); } /** @@ -53,57 +53,57 @@ void myChanServHelp(User * u) **/ int do_cs_topic(User * u) { - char *chan = strtok(NULL, " "); - char *topic = strtok(NULL, ""); + char *chan = strtok(NULL, " "); + char *topic = strtok(NULL, ""); - Channel *c; - ChannelInfo *ci; + Channel *c; + ChannelInfo *ci; - if (!chan) { - syntax_error(s_ChanServ, u, "TOPIC", CHAN_TOPIC_SYNTAX); - } else if (!(c = findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); - } else if (!(ci = c->ci)) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name); - } else if (!is_services_admin(u) && !check_access(u, ci, CA_TOPIC)) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - } else { - if (ci->last_topic) - free(ci->last_topic); - ci->last_topic = topic ? sstrdup(topic) : NULL; - strscpy(ci->last_topic_setter, u->nick, NICKMAX); - ci->last_topic_time = time(NULL); + if (!chan) { + syntax_error(s_ChanServ, u, "TOPIC", CHAN_TOPIC_SYNTAX); + } else if (!(c = findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); + } else if (!(ci = c->ci)) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name); + } else if (!is_services_admin(u) && !check_access(u, ci, CA_TOPIC)) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + } else { + if (ci->last_topic) + free(ci->last_topic); + ci->last_topic = topic ? sstrdup(topic) : NULL; + strscpy(ci->last_topic_setter, u->nick, NICKMAX); + ci->last_topic_time = time(NULL); - if (c->topic) - free(c->topic); - c->topic = topic ? sstrdup(topic) : NULL; - strscpy(c->topic_setter, u->nick, NICKMAX); - if (ircd->topictsbackward) { - c->topic_time = c->topic_time - 1; - } else { - c->topic_time = ci->last_topic_time; - } + if (c->topic) + free(c->topic); + c->topic = topic ? sstrdup(topic) : NULL; + strscpy(c->topic_setter, u->nick, NICKMAX); + if (ircd->topictsbackward) { + c->topic_time = c->topic_time - 1; + } else { + c->topic_time = ci->last_topic_time; + } - if (is_services_admin(u) && !check_access(u, ci, CA_TOPIC)) - alog("%s: %s!%s@%s changed topic of %s as services admin.", - s_ChanServ, u->nick, u->username, u->host, c->name); - if (ircd->join2set) { - if (whosends(ci) == findbot(s_ChanServ)) { - ircdproto->SendJoin(findbot(s_ChanServ), c->name, c->creation_time); - ircdproto->SendMode(NULL, c->name, "+o %s", s_ChanServ); - } - } - ircdproto->SendTopic(whosends(ci), c->name, u->nick, topic ? topic : "", - c->topic_time); - if (ircd->join2set) { - if (whosends(ci) == findbot(s_ChanServ)) { - ircdproto->SendPart(findbot(s_ChanServ), c->name, NULL); - } - } - } - return MOD_CONT; + if (is_services_admin(u) && !check_access(u, ci, CA_TOPIC)) + alog("%s: %s!%s@%s changed topic of %s as services admin.", + s_ChanServ, u->nick, u->username, u->host, c->name); + if (ircd->join2set) { + if (whosends(ci) == findbot(s_ChanServ)) { + ircdproto->SendJoin(findbot(s_ChanServ), c->name, c->creation_time); + ircdproto->SendMode(NULL, c->name, "+o %s", s_ChanServ); + } + } + ircdproto->SendTopic(whosends(ci), c->name, u->nick, topic ? topic : "", + c->topic_time); + if (ircd->join2set) { + if (whosends(ci) == findbot(s_ChanServ)) { + ircdproto->SendPart(findbot(s_ChanServ), c->name, NULL); + } + } + } + return MOD_CONT; } MODULE_INIT("cs_topic", CSTopic) diff --git a/src/core/cs_xop.c b/src/core/cs_xop.c index 51bf5e71c..bc724913f 100644 --- a/src/core/cs_xop.c +++ b/src/core/cs_xop.c @@ -24,62 +24,62 @@ int do_vop(User * u); void myChanServHelp(User * u); int xop_msgs[4][14] = { - {CHAN_AOP_SYNTAX, - CHAN_AOP_DISABLED, - CHAN_AOP_NICKS_ONLY, - CHAN_AOP_ADDED, - CHAN_AOP_MOVED, - CHAN_AOP_NO_SUCH_ENTRY, - CHAN_AOP_NOT_FOUND, - CHAN_AOP_NO_MATCH, - CHAN_AOP_DELETED, - CHAN_AOP_DELETED_ONE, - CHAN_AOP_DELETED_SEVERAL, - CHAN_AOP_LIST_EMPTY, - CHAN_AOP_LIST_HEADER, - CHAN_AOP_CLEAR}, - {CHAN_SOP_SYNTAX, - CHAN_SOP_DISABLED, - CHAN_SOP_NICKS_ONLY, - CHAN_SOP_ADDED, - CHAN_SOP_MOVED, - CHAN_SOP_NO_SUCH_ENTRY, - CHAN_SOP_NOT_FOUND, - CHAN_SOP_NO_MATCH, - CHAN_SOP_DELETED, - CHAN_SOP_DELETED_ONE, - CHAN_SOP_DELETED_SEVERAL, - CHAN_SOP_LIST_EMPTY, - CHAN_SOP_LIST_HEADER, - CHAN_SOP_CLEAR}, - {CHAN_VOP_SYNTAX, - CHAN_VOP_DISABLED, - CHAN_VOP_NICKS_ONLY, - CHAN_VOP_ADDED, - CHAN_VOP_MOVED, - CHAN_VOP_NO_SUCH_ENTRY, - CHAN_VOP_NOT_FOUND, - CHAN_VOP_NO_MATCH, - CHAN_VOP_DELETED, - CHAN_VOP_DELETED_ONE, - CHAN_VOP_DELETED_SEVERAL, - CHAN_VOP_LIST_EMPTY, - CHAN_VOP_LIST_HEADER, - CHAN_VOP_CLEAR}, - {CHAN_HOP_SYNTAX, - CHAN_HOP_DISABLED, - CHAN_HOP_NICKS_ONLY, - CHAN_HOP_ADDED, - CHAN_HOP_MOVED, - CHAN_HOP_NO_SUCH_ENTRY, - CHAN_HOP_NOT_FOUND, - CHAN_HOP_NO_MATCH, - CHAN_HOP_DELETED, - CHAN_HOP_DELETED_ONE, - CHAN_HOP_DELETED_SEVERAL, - CHAN_HOP_LIST_EMPTY, - CHAN_HOP_LIST_HEADER, - CHAN_HOP_CLEAR} + {CHAN_AOP_SYNTAX, + CHAN_AOP_DISABLED, + CHAN_AOP_NICKS_ONLY, + CHAN_AOP_ADDED, + CHAN_AOP_MOVED, + CHAN_AOP_NO_SUCH_ENTRY, + CHAN_AOP_NOT_FOUND, + CHAN_AOP_NO_MATCH, + CHAN_AOP_DELETED, + CHAN_AOP_DELETED_ONE, + CHAN_AOP_DELETED_SEVERAL, + CHAN_AOP_LIST_EMPTY, + CHAN_AOP_LIST_HEADER, + CHAN_AOP_CLEAR}, + {CHAN_SOP_SYNTAX, + CHAN_SOP_DISABLED, + CHAN_SOP_NICKS_ONLY, + CHAN_SOP_ADDED, + CHAN_SOP_MOVED, + CHAN_SOP_NO_SUCH_ENTRY, + CHAN_SOP_NOT_FOUND, + CHAN_SOP_NO_MATCH, + CHAN_SOP_DELETED, + CHAN_SOP_DELETED_ONE, + CHAN_SOP_DELETED_SEVERAL, + CHAN_SOP_LIST_EMPTY, + CHAN_SOP_LIST_HEADER, + CHAN_SOP_CLEAR}, + {CHAN_VOP_SYNTAX, + CHAN_VOP_DISABLED, + CHAN_VOP_NICKS_ONLY, + CHAN_VOP_ADDED, + CHAN_VOP_MOVED, + CHAN_VOP_NO_SUCH_ENTRY, + CHAN_VOP_NOT_FOUND, + CHAN_VOP_NO_MATCH, + CHAN_VOP_DELETED, + CHAN_VOP_DELETED_ONE, + CHAN_VOP_DELETED_SEVERAL, + CHAN_VOP_LIST_EMPTY, + CHAN_VOP_LIST_HEADER, + CHAN_VOP_CLEAR}, + {CHAN_HOP_SYNTAX, + CHAN_HOP_DISABLED, + CHAN_HOP_NICKS_ONLY, + CHAN_HOP_ADDED, + CHAN_HOP_MOVED, + CHAN_HOP_NO_SUCH_ENTRY, + CHAN_HOP_NOT_FOUND, + CHAN_HOP_NO_MATCH, + CHAN_HOP_DELETED, + CHAN_HOP_DELETED_ONE, + CHAN_HOP_DELETED_SEVERAL, + CHAN_HOP_LIST_EMPTY, + CHAN_HOP_LIST_HEADER, + CHAN_HOP_CLEAR} }; class CSXOP : public Module @@ -117,12 +117,12 @@ class CSXOP : public Module **/ void myChanServHelp(User * u) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_SOP); - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_AOP); - if (ircd->halfop) { - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_HOP); - } - notice_lang(s_ChanServ, u, CHAN_HELP_CMD_VOP); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_SOP); + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_AOP); + if (ircd->halfop) { + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_HOP); + } + notice_lang(s_ChanServ, u, CHAN_HELP_CMD_VOP); } /** @@ -132,28 +132,28 @@ void myChanServHelp(User * u) **/ int do_aop(User * u) { - return do_xop(u, "AOP", ACCESS_AOP, xop_msgs[0]); + return do_xop(u, "AOP", ACCESS_AOP, xop_msgs[0]); } /*************************************************************************/ int do_hop(User * u) { - return do_xop(u, "HOP", ACCESS_HOP, xop_msgs[3]); + return do_xop(u, "HOP", ACCESS_HOP, xop_msgs[3]); } /*************************************************************************/ int do_sop(User * u) { - return do_xop(u, "SOP", ACCESS_SOP, xop_msgs[1]); + return do_xop(u, "SOP", ACCESS_SOP, xop_msgs[1]); } /*************************************************************************/ int do_vop(User * u) { - return do_xop(u, "VOP", ACCESS_VOP, xop_msgs[2]); + return do_xop(u, "VOP", ACCESS_VOP, xop_msgs[2]); } /* `last' is set to the last index this routine was called with @@ -162,338 +162,338 @@ int do_vop(User * u) int xop_del(User * u, ChannelInfo * ci, ChanAccess * access, int *perm, int uacc, int xlev) { - char *nick = access->nc->display; - if (!access->in_use || access->level != xlev) - return 0; - if (!is_services_admin(u) && uacc <= access->level) { - (*perm)++; - return 0; - } - access->nc = NULL; - access->in_use = 0; - send_event(EVENT_ACCESS_DEL, 3, ci->name, u->nick, nick); - return 1; + char *nick = access->nc->display; + if (!access->in_use || access->level != xlev) + return 0; + if (!is_services_admin(u) && uacc <= access->level) { + (*perm)++; + return 0; + } + access->nc = NULL; + access->in_use = 0; + send_event(EVENT_ACCESS_DEL, 3, ci->name, u->nick, nick); + return 1; } int xop_del_callback(User * u, int num, va_list args) { - ChannelInfo *ci = va_arg(args, ChannelInfo *); - int *last = va_arg(args, int *); - int *perm = va_arg(args, int *); - int uacc = va_arg(args, int); - int xlev = va_arg(args, int); + ChannelInfo *ci = va_arg(args, ChannelInfo *); + int *last = va_arg(args, int *); + int *perm = va_arg(args, int *); + int uacc = va_arg(args, int); + int xlev = va_arg(args, int); - if (num < 1 || num > ci->accesscount) - return 0; - *last = num; + if (num < 1 || num > ci->accesscount) + return 0; + *last = num; - return xop_del(u, ci, &ci->access[num - 1], perm, uacc, xlev); + return xop_del(u, ci, &ci->access[num - 1], perm, uacc, xlev); } int xop_list(User * u, int index, ChannelInfo * ci, - int *sent_header, int xlev, int xmsg) + int *sent_header, int xlev, int xmsg) { - ChanAccess *access = &ci->access[index]; + ChanAccess *access = &ci->access[index]; - if (!access->in_use || access->level != xlev) - return 0; + if (!access->in_use || access->level != xlev) + return 0; - if (!*sent_header) { - notice_lang(s_ChanServ, u, xmsg, ci->name); - *sent_header = 1; - } + if (!*sent_header) { + notice_lang(s_ChanServ, u, xmsg, ci->name); + *sent_header = 1; + } - notice_lang(s_ChanServ, u, CHAN_XOP_LIST_FORMAT, index + 1, - access->nc->display); - return 1; + notice_lang(s_ChanServ, u, CHAN_XOP_LIST_FORMAT, index + 1, + access->nc->display); + return 1; } int xop_list_callback(User * u, int num, va_list args) { - ChannelInfo *ci = va_arg(args, ChannelInfo *); - int *sent_header = va_arg(args, int *); - int xlev = va_arg(args, int); - int xmsg = va_arg(args, int); + ChannelInfo *ci = va_arg(args, ChannelInfo *); + int *sent_header = va_arg(args, int *); + int xlev = va_arg(args, int); + int xmsg = va_arg(args, int); - if (num < 1 || num > ci->accesscount) - return 0; + if (num < 1 || num > ci->accesscount) + return 0; - return xop_list(u, num - 1, ci, sent_header, xlev, xmsg); + return xop_list(u, num - 1, ci, sent_header, xlev, xmsg); } int do_xop(User * u, const char *xname, int xlev, int *xmsgs) { - char *chan = strtok(NULL, " "); - char *cmd = strtok(NULL, " "); - char *nick = strtok(NULL, " "); - char event_access[BUFSIZE]; - - ChannelInfo *ci; - NickAlias *na; - NickCore *nc; - - int i; - int change = 0; - short ulev; - int is_list = (cmd && stricmp(cmd, "LIST") == 0); - int is_servadmin = is_services_admin(u); - ChanAccess *access; - - /* If CLEAR, we don't need any parameters. - * If LIST, we don't *require* any parameters, but we can take any. - * If DEL or ADD we require a nick. */ - if (!cmd || ((is_list || !stricmp(cmd, "CLEAR")) ? 0 : !nick)) { - syntax_error(s_ChanServ, u, xname, xmsgs[0]); - } else if (!(ci = cs_findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); - } else if (!(ci->flags & CI_XOP)) { - notice_lang(s_ChanServ, u, CHAN_XOP_ACCESS, s_ChanServ); - } else if (stricmp(cmd, "ADD") == 0) { - if (readonly) { - notice_lang(s_ChanServ, u, xmsgs[1]); - return MOD_CONT; - } - - ulev = get_access(u, ci); - - if ((xlev >= ulev || ulev < ACCESS_AOP) && !is_servadmin) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - return MOD_CONT; - } - - na = findnick(nick); - if (!na) { - notice_lang(s_ChanServ, u, xmsgs[2]); - return MOD_CONT; - } else if (na->status & NS_VERBOTEN) { - notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, na->nick); - return MOD_CONT; - } - - nc = na->nc; - for (access = ci->access, i = 0; i < ci->accesscount; - access++, i++) { - if (access->nc == nc) { - /** - * Patch provided by PopCorn to prevert AOP's reducing SOP's levels - **/ - if ((access->level >= ulev) && (!is_servadmin)) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - return MOD_CONT; - } - change++; - break; - } - } - - if (!change) { - /* All entries should be in use so we no longer need - * to go over the entire list.. - for (i = 0; i < ci->accesscount; i++) - if (!ci->access[i].in_use) - break; - */ - - if (i < CSAccessMax) { - ci->accesscount++; - ci->access = - (ChanAccess *)srealloc(ci->access, - sizeof(ChanAccess) * ci->accesscount); - } else { - notice_lang(s_ChanServ, u, CHAN_XOP_REACHED_LIMIT, - CSAccessMax); - return MOD_CONT; - } - - access = &ci->access[i]; - access->nc = nc; - } - - access->in_use = 1; - access->level = xlev; - access->last_seen = 0; - - alog("%s: %s!%s@%s (level %d) %s access level %d to %s (group %s) on channel %s", s_ChanServ, u->nick, u->username, u->host, ulev, change ? "changed" : "set", access->level, na->nick, nc->display, ci->name); - - snprintf(event_access, BUFSIZE, "%d", access->level); - - if (!change) { - send_event(EVENT_ACCESS_ADD, 4, ci->name, u->nick, na->nick, - event_access); - notice_lang(s_ChanServ, u, xmsgs[3], access->nc->display, - ci->name); - } else { - send_event(EVENT_ACCESS_CHANGE, 4, ci->name, u->nick, na->nick, - event_access); - notice_lang(s_ChanServ, u, xmsgs[4], access->nc->display, - ci->name); - } - - } else if (stricmp(cmd, "DEL") == 0) { - int deleted, a, b; - if (readonly) { - notice_lang(s_ChanServ, u, xmsgs[1]); - return MOD_CONT; - } - - if (ci->accesscount == 0) { - notice_lang(s_ChanServ, u, xmsgs[11], chan); - return MOD_CONT; - } - - ulev = get_access(u, ci); - - if ((xlev >= ulev || ulev < ACCESS_AOP) && !is_servadmin) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - return MOD_CONT; - } - - /* Special case: is it a number/list? Only do search if it isn't. */ - if (isdigit(*nick) && strspn(nick, "1234567890,-") == strlen(nick)) { - int count, last = -1, perm = 0; - deleted = - process_numlist(nick, &count, xop_del_callback, u, ci, - &last, &perm, ulev, xlev); - if (!deleted) { - if (perm) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - } else if (count == 1) { - notice_lang(s_ChanServ, u, xmsgs[5], last, ci->name); - } else { - notice_lang(s_ChanServ, u, xmsgs[7], ci->name); - } - } else if (deleted == 1) { - notice_lang(s_ChanServ, u, xmsgs[9], ci->name); - } else { - notice_lang(s_ChanServ, u, xmsgs[10], deleted, ci->name); - } - } else { - na = findnick(nick); - if (!na) { - notice_lang(s_ChanServ, u, NICK_X_NOT_REGISTERED, nick); - return MOD_CONT; - } - nc = na->nc; - - for (i = 0; i < ci->accesscount; i++) - if (ci->access[i].nc == nc && ci->access[i].level == xlev) - break; - - if (i == ci->accesscount) { - notice_lang(s_ChanServ, u, xmsgs[6], nick, chan); - return MOD_CONT; - } - - access = &ci->access[i]; - if (!is_servadmin && ulev <= access->level) { - deleted = 0; - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - } else { - notice_lang(s_ChanServ, u, xmsgs[8], access->nc->display, - ci->name); - access->nc = NULL; - access->in_use = 0; - send_event(EVENT_ACCESS_DEL, 3, ci->name, u->nick, - na->nick); - deleted = 1; - } - } - if (deleted) { - /* Reordering - DrStein */ - for (b = 0; b < ci->accesscount; b++) { - if (ci->access[b].in_use) { - for (a = 0; a < ci->accesscount; a++) { - if (a > b) - break; - if (!ci->access[a].in_use) { - ci->access[a].in_use = 1; - ci->access[a].level = ci->access[b].level; - ci->access[a].nc = ci->access[b].nc; - ci->access[a].last_seen = - ci->access[b].last_seen; - ci->access[b].nc = NULL; - ci->access[b].in_use = 0; - break; - } - } - } - } - - /* If the patch provided in bug #706 is applied, this should be placed - * before sending the events! */ - /* After reordering only the entries at the end could still be empty. - * We ll free the places no longer in use... */ - for (i = ci->accesscount - 1; i >= 0; i--) { - if (ci->access[i].in_use == 1) - break; - - ci->accesscount--; - } - ci->access = - (ChanAccess *)srealloc(ci->access,sizeof(ChanAccess) * ci->accesscount); - } - } else if (stricmp(cmd, "LIST") == 0) { - int sent_header = 0; - - ulev = get_access(u, ci); - - if (!is_servadmin && ulev < ACCESS_AOP) { - notice_lang(s_ChanServ, u, ACCESS_DENIED); - return MOD_CONT; - } - - if (ci->accesscount == 0) { - notice_lang(s_ChanServ, u, xmsgs[11], ci->name); - return MOD_CONT; - } - - if (nick && strspn(nick, "1234567890,-") == strlen(nick)) { - process_numlist(nick, NULL, xop_list_callback, u, ci, - &sent_header, xlev, xmsgs[12]); - } else { - for (i = 0; i < ci->accesscount; i++) { - if (nick && ci->access[i].nc - && !match_wild_nocase(nick, ci->access[i].nc->display)) - continue; - xop_list(u, i, ci, &sent_header, xlev, xmsgs[12]); - } - } - if (!sent_header) - notice_lang(s_ChanServ, u, xmsgs[7], chan); - } else if (stricmp(cmd, "CLEAR") == 0) { - if (readonly) { - notice_lang(s_ChanServ, u, CHAN_ACCESS_DISABLED); - return MOD_CONT; - } - - if (ci->accesscount == 0) { - notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_EMPTY, chan); - return MOD_CONT; - } - - if (!is_servadmin && !is_founder(u, ci)) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - return MOD_CONT; - } - - for (i = 0; i < ci->accesscount; i++) { - if (ci->access[i].in_use && ci->access[i].level == xlev) { - ci->access[i].nc = NULL; - ci->access[i].in_use = 0; - } - } - - send_event(EVENT_ACCESS_CLEAR, 2, ci->name, u->nick); - - notice_lang(s_ChanServ, u, xmsgs[13], ci->name); - } else { - syntax_error(s_ChanServ, u, xname, xmsgs[0]); - } - return MOD_CONT; + char *chan = strtok(NULL, " "); + char *cmd = strtok(NULL, " "); + char *nick = strtok(NULL, " "); + char event_access[BUFSIZE]; + + ChannelInfo *ci; + NickAlias *na; + NickCore *nc; + + int i; + int change = 0; + short ulev; + int is_list = (cmd && stricmp(cmd, "LIST") == 0); + int is_servadmin = is_services_admin(u); + ChanAccess *access; + + /* If CLEAR, we don't need any parameters. + * If LIST, we don't *require* any parameters, but we can take any. + * If DEL or ADD we require a nick. */ + if (!cmd || ((is_list || !stricmp(cmd, "CLEAR")) ? 0 : !nick)) { + syntax_error(s_ChanServ, u, xname, xmsgs[0]); + } else if (!(ci = cs_findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); + } else if (!(ci->flags & CI_XOP)) { + notice_lang(s_ChanServ, u, CHAN_XOP_ACCESS, s_ChanServ); + } else if (stricmp(cmd, "ADD") == 0) { + if (readonly) { + notice_lang(s_ChanServ, u, xmsgs[1]); + return MOD_CONT; + } + + ulev = get_access(u, ci); + + if ((xlev >= ulev || ulev < ACCESS_AOP) && !is_servadmin) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + return MOD_CONT; + } + + na = findnick(nick); + if (!na) { + notice_lang(s_ChanServ, u, xmsgs[2]); + return MOD_CONT; + } else if (na->status & NS_VERBOTEN) { + notice_lang(s_ChanServ, u, NICK_X_FORBIDDEN, na->nick); + return MOD_CONT; + } + + nc = na->nc; + for (access = ci->access, i = 0; i < ci->accesscount; + access++, i++) { + if (access->nc == nc) { + /** + * Patch provided by PopCorn to prevert AOP's reducing SOP's levels + **/ + if ((access->level >= ulev) && (!is_servadmin)) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + return MOD_CONT; + } + change++; + break; + } + } + + if (!change) { + /* All entries should be in use so we no longer need + * to go over the entire list.. + for (i = 0; i < ci->accesscount; i++) + if (!ci->access[i].in_use) + break; + */ + + if (i < CSAccessMax) { + ci->accesscount++; + ci->access = + (ChanAccess *)srealloc(ci->access, + sizeof(ChanAccess) * ci->accesscount); + } else { + notice_lang(s_ChanServ, u, CHAN_XOP_REACHED_LIMIT, + CSAccessMax); + return MOD_CONT; + } + + access = &ci->access[i]; + access->nc = nc; + } + + access->in_use = 1; + access->level = xlev; + access->last_seen = 0; + + alog("%s: %s!%s@%s (level %d) %s access level %d to %s (group %s) on channel %s", s_ChanServ, u->nick, u->username, u->host, ulev, change ? "changed" : "set", access->level, na->nick, nc->display, ci->name); + + snprintf(event_access, BUFSIZE, "%d", access->level); + + if (!change) { + send_event(EVENT_ACCESS_ADD, 4, ci->name, u->nick, na->nick, + event_access); + notice_lang(s_ChanServ, u, xmsgs[3], access->nc->display, + ci->name); + } else { + send_event(EVENT_ACCESS_CHANGE, 4, ci->name, u->nick, na->nick, + event_access); + notice_lang(s_ChanServ, u, xmsgs[4], access->nc->display, + ci->name); + } + + } else if (stricmp(cmd, "DEL") == 0) { + int deleted, a, b; + if (readonly) { + notice_lang(s_ChanServ, u, xmsgs[1]); + return MOD_CONT; + } + + if (ci->accesscount == 0) { + notice_lang(s_ChanServ, u, xmsgs[11], chan); + return MOD_CONT; + } + + ulev = get_access(u, ci); + + if ((xlev >= ulev || ulev < ACCESS_AOP) && !is_servadmin) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + return MOD_CONT; + } + + /* Special case: is it a number/list? Only do search if it isn't. */ + if (isdigit(*nick) && strspn(nick, "1234567890,-") == strlen(nick)) { + int count, last = -1, perm = 0; + deleted = + process_numlist(nick, &count, xop_del_callback, u, ci, + &last, &perm, ulev, xlev); + if (!deleted) { + if (perm) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + } else if (count == 1) { + notice_lang(s_ChanServ, u, xmsgs[5], last, ci->name); + } else { + notice_lang(s_ChanServ, u, xmsgs[7], ci->name); + } + } else if (deleted == 1) { + notice_lang(s_ChanServ, u, xmsgs[9], ci->name); + } else { + notice_lang(s_ChanServ, u, xmsgs[10], deleted, ci->name); + } + } else { + na = findnick(nick); + if (!na) { + notice_lang(s_ChanServ, u, NICK_X_NOT_REGISTERED, nick); + return MOD_CONT; + } + nc = na->nc; + + for (i = 0; i < ci->accesscount; i++) + if (ci->access[i].nc == nc && ci->access[i].level == xlev) + break; + + if (i == ci->accesscount) { + notice_lang(s_ChanServ, u, xmsgs[6], nick, chan); + return MOD_CONT; + } + + access = &ci->access[i]; + if (!is_servadmin && ulev <= access->level) { + deleted = 0; + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + } else { + notice_lang(s_ChanServ, u, xmsgs[8], access->nc->display, + ci->name); + access->nc = NULL; + access->in_use = 0; + send_event(EVENT_ACCESS_DEL, 3, ci->name, u->nick, + na->nick); + deleted = 1; + } + } + if (deleted) { + /* Reordering - DrStein */ + for (b = 0; b < ci->accesscount; b++) { + if (ci->access[b].in_use) { + for (a = 0; a < ci->accesscount; a++) { + if (a > b) + break; + if (!ci->access[a].in_use) { + ci->access[a].in_use = 1; + ci->access[a].level = ci->access[b].level; + ci->access[a].nc = ci->access[b].nc; + ci->access[a].last_seen = + ci->access[b].last_seen; + ci->access[b].nc = NULL; + ci->access[b].in_use = 0; + break; + } + } + } + } + + /* If the patch provided in bug #706 is applied, this should be placed + * before sending the events! */ + /* After reordering only the entries at the end could still be empty. + * We ll free the places no longer in use... */ + for (i = ci->accesscount - 1; i >= 0; i--) { + if (ci->access[i].in_use == 1) + break; + + ci->accesscount--; + } + ci->access = + (ChanAccess *)srealloc(ci->access,sizeof(ChanAccess) * ci->accesscount); + } + } else if (stricmp(cmd, "LIST") == 0) { + int sent_header = 0; + + ulev = get_access(u, ci); + + if (!is_servadmin && ulev < ACCESS_AOP) { + notice_lang(s_ChanServ, u, ACCESS_DENIED); + return MOD_CONT; + } + + if (ci->accesscount == 0) { + notice_lang(s_ChanServ, u, xmsgs[11], ci->name); + return MOD_CONT; + } + + if (nick && strspn(nick, "1234567890,-") == strlen(nick)) { + process_numlist(nick, NULL, xop_list_callback, u, ci, + &sent_header, xlev, xmsgs[12]); + } else { + for (i = 0; i < ci->accesscount; i++) { + if (nick && ci->access[i].nc + && !match_wild_nocase(nick, ci->access[i].nc->display)) + continue; + xop_list(u, i, ci, &sent_header, xlev, xmsgs[12]); + } + } + if (!sent_header) + notice_lang(s_ChanServ, u, xmsgs[7], chan); + } else if (stricmp(cmd, "CLEAR") == 0) { + if (readonly) { + notice_lang(s_ChanServ, u, CHAN_ACCESS_DISABLED); + return MOD_CONT; + } + + if (ci->accesscount == 0) { + notice_lang(s_ChanServ, u, CHAN_ACCESS_LIST_EMPTY, chan); + return MOD_CONT; + } + + if (!is_servadmin && !is_founder(u, ci)) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + return MOD_CONT; + } + + for (i = 0; i < ci->accesscount; i++) { + if (ci->access[i].in_use && ci->access[i].level == xlev) { + ci->access[i].nc = NULL; + ci->access[i].in_use = 0; + } + } + + send_event(EVENT_ACCESS_CLEAR, 2, ci->name, u->nick); + + notice_lang(s_ChanServ, u, xmsgs[13], ci->name); + } else { + syntax_error(s_ChanServ, u, xname, xmsgs[0]); + } + return MOD_CONT; } MODULE_INIT("cs_xop", CSXOP) diff --git a/src/core/enc_md5.c b/src/core/enc_md5.c index d3f304487..015b4af2e 100644 --- a/src/core/enc_md5.c +++ b/src/core/enc_md5.c @@ -5,7 +5,7 @@ * Contact us at dev@anope.org * * Taken from IRC Services and is copyright (c) 1996-2002 Andrew Church. - * E-mail: <achurch@achurch.org> + * E-mail: <achurch@achurch.org> * Parts written by Andrew Kempe and others. * This program is free but copyrighted software; see the file COPYING for * details. @@ -44,9 +44,9 @@ typedef unsigned int UINT4; /* MD5 context. */ typedef struct { - UINT4 state[4]; /* state (ABCD) */ - UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ - unsigned char buffer[64]; /* input buffer */ + UINT4 state[4]; /* state (ABCD) */ + UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ + unsigned char buffer[64]; /* input buffer */ } MD5_CTX; /* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm @@ -323,60 +323,60 @@ void Decode (UINT4 *output, unsigned char *input, unsigned int len) int md5_encrypt(const char *src, int len, char *dest, int size) { - MD5_CTX context; - char tmp[33]; + MD5_CTX context; + char tmp[33]; - if (size < 16) + if (size < 16) return -1; - MD5Init(&context); - MD5Update(&context, (unsigned char *)src, len); - MD5Final((unsigned char *)dest, &context); - - if(debug) { - memset(tmp,0,33); - binary_to_hex((unsigned char *)dest,tmp,16); + MD5Init(&context); + MD5Update(&context, (unsigned char *)src, len); + MD5Final((unsigned char *)dest, &context); + + if(debug) { + memset(tmp,0,33); + binary_to_hex((unsigned char *)dest,tmp,16); /* Dont log source if we were encrypting in place :) */ - if (memcmp(src, dest, 16) != 0) { - alog("enc_md5: hashed from [%s] to [%s]",src,tmp); + if (memcmp(src, dest, 16) != 0) { + alog("enc_md5: hashed from [%s] to [%s]",src,tmp); } else { - alog("enc_md5: hashed password to [%s]",tmp); + alog("enc_md5: hashed password to [%s]",tmp); } - } - - return 0; + } + + return 0; } int md5_encrypt_in_place(char *buf, int size) { - return md5_encrypt(buf, strlen(buf), buf, size); + return md5_encrypt(buf, strlen(buf), buf, size); } int md5_encrypt_check_len(int passlen, int bufsize) { - if (bufsize < 16) + if (bufsize < 16) fatal("enc_md5: md5_check_len(): buffer too small (%d)", bufsize); - return 0; + return 0; } int md5_decrypt(const char *src, char *dest, int size) { - return 0; + return 0; } int md5_check_password(const char *plaintext, const char *password) { - char buf[BUFSIZE]; + char buf[BUFSIZE]; - if (md5_encrypt(plaintext, strlen(plaintext), buf, sizeof(buf)) < 0) + if (md5_encrypt(plaintext, strlen(plaintext), buf, sizeof(buf)) < 0) return -1; - if (memcmp(buf, password, 16) == 0) + if (memcmp(buf, password, 16) == 0) return 1; - return 0; + return 0; } /*************************************************************************/ diff --git a/src/core/enc_none.c b/src/core/enc_none.c index 16a4a812b..f58ca15e3 100644 --- a/src/core/enc_none.c +++ b/src/core/enc_none.c @@ -42,38 +42,38 @@ class ENone : public Module }; int plain_encrypt(const char *src,int len,char *dest,int size) { - if(size>=len) { - memset(dest,0,size); - strncpy(dest,src,len); - dest[len] = '\0'; - return 0; - } - return -1; + if(size>=len) { + memset(dest,0,size); + strncpy(dest,src,len); + dest[len] = '\0'; + return 0; + } + return -1; } int plain_encrypt_in_place(char *buf, int size) { - return 0; + return 0; } int plain_encrypt_check_len(int passlen, int bufsize) { - if(bufsize>=passlen) { - return 0; - } - return bufsize; + if(bufsize>=passlen) { + return 0; + } + return bufsize; } int plain_decrypt(const char *src, char *dest, int size) { - memset(dest,0,size); - strncpy(dest,src,size); - dest[size] = '\0'; - return 1; + memset(dest,0,size); + strncpy(dest,src,size); + dest[size] = '\0'; + return 1; } int plain_check_password(const char *plaintext, const char *password) { - if(strcmp(plaintext,password)==0) { - return 1; - } - return 0; + if(strcmp(plaintext,password)==0) { + return 1; + } + return 0; } /* EOF */ diff --git a/src/core/enc_old.c b/src/core/enc_old.c index 2fe9ac2d5..befcd105b 100644 --- a/src/core/enc_old.c +++ b/src/core/enc_old.c @@ -16,16 +16,16 @@ void binary_to_hex(unsigned char *bin, char *hex, int length) { - static const char trans[] = "0123456789ABCDEF"; - int i; + static const char trans[] = "0123456789ABCDEF"; + int i; - for(i = 0; i < length; i++) - { - hex[i << 1] = trans[bin[i] >> 4]; - hex[(i << 1) + 1] = trans[bin[i] & 0xf]; - } + for(i = 0; i < length; i++) + { + hex[i << 1] = trans[bin[i] >> 4]; + hex[(i << 1) + 1] = trans[bin[i] & 0xf]; + } - hex[i << 1] = '\0'; + hex[i << 1] = '\0'; } @@ -62,9 +62,9 @@ typedef unsigned int UINT4; /* MD5 context. */ typedef struct { - UINT4 state[4]; /* state (ABCD) */ - UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ - unsigned char buffer[64]; /* input buffer */ + UINT4 state[4]; /* state (ABCD) */ + UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ + unsigned char buffer[64]; /* input buffer */ } MD5_CTX; /* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm @@ -96,9 +96,9 @@ static void Encode(unsigned char *, UINT4 *, unsigned int); static void Decode(UINT4 *, unsigned char *, unsigned int); static unsigned char PADDING[64] = { - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* F, G, H and I are basic MD5 functions. @@ -140,13 +140,13 @@ Rotation is separate from addition to prevent recomputation. */ static void MD5Init(MD5_CTX *context) { - context->count[0] = context->count[1] = 0; - /* Load magic initialization constants. - */ - context->state[0] = 0x67452301; - context->state[1] = 0xefcdab89; - context->state[2] = 0x98badcfe; - context->state[3] = 0x10325476; + context->count[0] = context->count[1] = 0; + /* Load magic initialization constants. + */ + context->state[0] = 0x67452301; + context->state[1] = 0xefcdab89; + context->state[2] = 0x98badcfe; + context->state[3] = 0x10325476; } /* MD5 block update operation. Continues an MD5 message-digest @@ -155,37 +155,37 @@ static void MD5Init(MD5_CTX *context) */ static void MD5Update(MD5_CTX *context, unsigned char *input, unsigned int inputLen) { - unsigned int i, index, partLen; + unsigned int i, index, partLen; - /* Compute number of bytes mod 64 */ - index = (unsigned int) ((context->count[0] >> 3) & 0x3F); + /* Compute number of bytes mod 64 */ + index = (unsigned int) ((context->count[0] >> 3) & 0x3F); - /* Update number of bits */ - if ((context->count[0] += ((UINT4) inputLen << 3)) - < ((UINT4) inputLen << 3)) - context->count[1]++; - context->count[1] += ((UINT4) inputLen >> 29); + /* Update number of bits */ + if ((context->count[0] += ((UINT4) inputLen << 3)) + < ((UINT4) inputLen << 3)) + context->count[1]++; + context->count[1] += ((UINT4) inputLen >> 29); - partLen = 64 - index; + partLen = 64 - index; - /* Transform as many times as possible. - */ - if (inputLen >= partLen) { - memcpy - ((POINTER) & context->buffer[index], (POINTER) input, partLen); - MD5Transform(context->state, context->buffer); + /* Transform as many times as possible. + */ + if (inputLen >= partLen) { + memcpy + ((POINTER) & context->buffer[index], (POINTER) input, partLen); + MD5Transform(context->state, context->buffer); - for (i = partLen; i + 63 < inputLen; i += 64) - MD5Transform(context->state, &input[i]); + for (i = partLen; i + 63 < inputLen; i += 64) + MD5Transform(context->state, &input[i]); - index = 0; - } else - i = 0; + index = 0; + } else + i = 0; - /* Buffer remaining input */ - memcpy - ((POINTER) & context->buffer[index], (POINTER) & input[i], - inputLen - i); + /* Buffer remaining input */ + memcpy + ((POINTER) & context->buffer[index], (POINTER) & input[i], + inputLen - i); } /* MD5 finalization. Ends an MD5 message-digest operation, writing the @@ -193,116 +193,116 @@ static void MD5Update(MD5_CTX *context, unsigned char *input, unsigned int input */ static void MD5Final(unsigned char digest[16], MD5_CTX *context) { - unsigned char bits[8]; - unsigned int index, padLen; - - /* Save number of bits */ - Encode(bits, context->count, 8); - - /* Pad out to 56 mod 64. - */ - index = (unsigned int) ((context->count[0] >> 3) & 0x3f); - padLen = (index < 56) ? (56 - index) : (120 - index); - MD5Update(context, PADDING, padLen); - - /* Append length (before padding) */ - MD5Update(context, bits, 8); - /* Store state in digest */ - Encode(digest, context->state, 16); - - /* Zeroize sensitive information. - */ - memset((POINTER) context, 0, sizeof(*context)); + unsigned char bits[8]; + unsigned int index, padLen; + + /* Save number of bits */ + Encode(bits, context->count, 8); + + /* Pad out to 56 mod 64. + */ + index = (unsigned int) ((context->count[0] >> 3) & 0x3f); + padLen = (index < 56) ? (56 - index) : (120 - index); + MD5Update(context, PADDING, padLen); + + /* Append length (before padding) */ + MD5Update(context, bits, 8); + /* Store state in digest */ + Encode(digest, context->state, 16); + + /* Zeroize sensitive information. + */ + memset((POINTER) context, 0, sizeof(*context)); } /* MD5 basic transformation. Transforms state based on block. */ static void MD5Transform(UINT4 state[4], unsigned char block[64]) { - UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; - - Decode(x, block, 64); - - /* Round 1 */ - FF(a, b, c, d, x[0], S11, 0xd76aa478); /* 1 */ - FF(d, a, b, c, x[1], S12, 0xe8c7b756); /* 2 */ - FF(c, d, a, b, x[2], S13, 0x242070db); /* 3 */ - FF(b, c, d, a, x[3], S14, 0xc1bdceee); /* 4 */ - FF(a, b, c, d, x[4], S11, 0xf57c0faf); /* 5 */ - FF(d, a, b, c, x[5], S12, 0x4787c62a); /* 6 */ - FF(c, d, a, b, x[6], S13, 0xa8304613); /* 7 */ - FF(b, c, d, a, x[7], S14, 0xfd469501); /* 8 */ - FF(a, b, c, d, x[8], S11, 0x698098d8); /* 9 */ - FF(d, a, b, c, x[9], S12, 0x8b44f7af); /* 10 */ - FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ - FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ - FF(a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ - FF(d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ - FF(c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ - FF(b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ - - /* Round 2 */ - GG(a, b, c, d, x[1], S21, 0xf61e2562); /* 17 */ - GG(d, a, b, c, x[6], S22, 0xc040b340); /* 18 */ - GG(c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ - GG(b, c, d, a, x[0], S24, 0xe9b6c7aa); /* 20 */ - GG(a, b, c, d, x[5], S21, 0xd62f105d); /* 21 */ - GG(d, a, b, c, x[10], S22, 0x2441453); /* 22 */ - GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ - GG(b, c, d, a, x[4], S24, 0xe7d3fbc8); /* 24 */ - GG(a, b, c, d, x[9], S21, 0x21e1cde6); /* 25 */ - GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ - GG(c, d, a, b, x[3], S23, 0xf4d50d87); /* 27 */ - GG(b, c, d, a, x[8], S24, 0x455a14ed); /* 28 */ - GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ - GG(d, a, b, c, x[2], S22, 0xfcefa3f8); /* 30 */ - GG(c, d, a, b, x[7], S23, 0x676f02d9); /* 31 */ - GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ - - /* Round 3 */ - HH(a, b, c, d, x[5], S31, 0xfffa3942); /* 33 */ - HH(d, a, b, c, x[8], S32, 0x8771f681); /* 34 */ - HH(c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ - HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ - HH(a, b, c, d, x[1], S31, 0xa4beea44); /* 37 */ - HH(d, a, b, c, x[4], S32, 0x4bdecfa9); /* 38 */ - HH(c, d, a, b, x[7], S33, 0xf6bb4b60); /* 39 */ - HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ - HH(a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ - HH(d, a, b, c, x[0], S32, 0xeaa127fa); /* 42 */ - HH(c, d, a, b, x[3], S33, 0xd4ef3085); /* 43 */ - HH(b, c, d, a, x[6], S34, 0x4881d05); /* 44 */ - HH(a, b, c, d, x[9], S31, 0xd9d4d039); /* 45 */ - HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ - HH(c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ - HH(b, c, d, a, x[2], S34, 0xc4ac5665); /* 48 */ - - /* Round 4 */ - II(a, b, c, d, x[0], S41, 0xf4292244); /* 49 */ - II(d, a, b, c, x[7], S42, 0x432aff97); /* 50 */ - II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ - II(b, c, d, a, x[5], S44, 0xfc93a039); /* 52 */ - II(a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ - II(d, a, b, c, x[3], S42, 0x8f0ccc92); /* 54 */ - II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ - II(b, c, d, a, x[1], S44, 0x85845dd1); /* 56 */ - II(a, b, c, d, x[8], S41, 0x6fa87e4f); /* 57 */ - II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ - II(c, d, a, b, x[6], S43, 0xa3014314); /* 59 */ - II(b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ - II(a, b, c, d, x[4], S41, 0xf7537e82); /* 61 */ - II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ - II(c, d, a, b, x[2], S43, 0x2ad7d2bb); /* 63 */ - II(b, c, d, a, x[9], S44, 0xeb86d391); /* 64 */ - - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - - /* Zeroize sensitive information. - */ - memset((POINTER) x, 0, sizeof(x)); + UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; + + Decode(x, block, 64); + + /* Round 1 */ + FF(a, b, c, d, x[0], S11, 0xd76aa478); /* 1 */ + FF(d, a, b, c, x[1], S12, 0xe8c7b756); /* 2 */ + FF(c, d, a, b, x[2], S13, 0x242070db); /* 3 */ + FF(b, c, d, a, x[3], S14, 0xc1bdceee); /* 4 */ + FF(a, b, c, d, x[4], S11, 0xf57c0faf); /* 5 */ + FF(d, a, b, c, x[5], S12, 0x4787c62a); /* 6 */ + FF(c, d, a, b, x[6], S13, 0xa8304613); /* 7 */ + FF(b, c, d, a, x[7], S14, 0xfd469501); /* 8 */ + FF(a, b, c, d, x[8], S11, 0x698098d8); /* 9 */ + FF(d, a, b, c, x[9], S12, 0x8b44f7af); /* 10 */ + FF(c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ + FF(b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ + FF(a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ + FF(d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ + FF(c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ + FF(b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ + + /* Round 2 */ + GG(a, b, c, d, x[1], S21, 0xf61e2562); /* 17 */ + GG(d, a, b, c, x[6], S22, 0xc040b340); /* 18 */ + GG(c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ + GG(b, c, d, a, x[0], S24, 0xe9b6c7aa); /* 20 */ + GG(a, b, c, d, x[5], S21, 0xd62f105d); /* 21 */ + GG(d, a, b, c, x[10], S22, 0x2441453); /* 22 */ + GG(c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ + GG(b, c, d, a, x[4], S24, 0xe7d3fbc8); /* 24 */ + GG(a, b, c, d, x[9], S21, 0x21e1cde6); /* 25 */ + GG(d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ + GG(c, d, a, b, x[3], S23, 0xf4d50d87); /* 27 */ + GG(b, c, d, a, x[8], S24, 0x455a14ed); /* 28 */ + GG(a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ + GG(d, a, b, c, x[2], S22, 0xfcefa3f8); /* 30 */ + GG(c, d, a, b, x[7], S23, 0x676f02d9); /* 31 */ + GG(b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ + + /* Round 3 */ + HH(a, b, c, d, x[5], S31, 0xfffa3942); /* 33 */ + HH(d, a, b, c, x[8], S32, 0x8771f681); /* 34 */ + HH(c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ + HH(b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ + HH(a, b, c, d, x[1], S31, 0xa4beea44); /* 37 */ + HH(d, a, b, c, x[4], S32, 0x4bdecfa9); /* 38 */ + HH(c, d, a, b, x[7], S33, 0xf6bb4b60); /* 39 */ + HH(b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ + HH(a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ + HH(d, a, b, c, x[0], S32, 0xeaa127fa); /* 42 */ + HH(c, d, a, b, x[3], S33, 0xd4ef3085); /* 43 */ + HH(b, c, d, a, x[6], S34, 0x4881d05); /* 44 */ + HH(a, b, c, d, x[9], S31, 0xd9d4d039); /* 45 */ + HH(d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ + HH(c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ + HH(b, c, d, a, x[2], S34, 0xc4ac5665); /* 48 */ + + /* Round 4 */ + II(a, b, c, d, x[0], S41, 0xf4292244); /* 49 */ + II(d, a, b, c, x[7], S42, 0x432aff97); /* 50 */ + II(c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ + II(b, c, d, a, x[5], S44, 0xfc93a039); /* 52 */ + II(a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ + II(d, a, b, c, x[3], S42, 0x8f0ccc92); /* 54 */ + II(c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ + II(b, c, d, a, x[1], S44, 0x85845dd1); /* 56 */ + II(a, b, c, d, x[8], S41, 0x6fa87e4f); /* 57 */ + II(d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ + II(c, d, a, b, x[6], S43, 0xa3014314); /* 59 */ + II(b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ + II(a, b, c, d, x[4], S41, 0xf7537e82); /* 61 */ + II(d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ + II(c, d, a, b, x[2], S43, 0x2ad7d2bb); /* 63 */ + II(b, c, d, a, x[9], S44, 0xeb86d391); /* 64 */ + + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + + /* Zeroize sensitive information. + */ + memset((POINTER) x, 0, sizeof(x)); } /* Encodes input (UINT4) into output (unsigned char). Assumes len is @@ -310,14 +310,14 @@ static void MD5Transform(UINT4 state[4], unsigned char block[64]) */ static void Encode(unsigned char *output, UINT4 *input, unsigned int len) { - unsigned int i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) { - output[j] = (unsigned char) (input[i] & 0xff); - output[j + 1] = (unsigned char) ((input[i] >> 8) & 0xff); - output[j + 2] = (unsigned char) ((input[i] >> 16) & 0xff); - output[j + 3] = (unsigned char) ((input[i] >> 24) & 0xff); - } + unsigned int i, j; + + for (i = 0, j = 0; j < len; i++, j += 4) { + output[j] = (unsigned char) (input[i] & 0xff); + output[j + 1] = (unsigned char) ((input[i] >> 8) & 0xff); + output[j + 2] = (unsigned char) ((input[i] >> 16) & 0xff); + output[j + 3] = (unsigned char) ((input[i] >> 24) & 0xff); + } } /* Decodes input (unsigned char) into output (UINT4). Assumes len is @@ -325,12 +325,12 @@ static void Encode(unsigned char *output, UINT4 *input, unsigned int len) */ static void Decode(UINT4 *output, unsigned char *input, unsigned int len) { - unsigned int i, j; + unsigned int i, j; - for (i = 0, j = 0; j < len; i++, j += 4) - output[i] = ((UINT4) input[j]) | (((UINT4) input[j + 1]) << 8) | - (((UINT4) input[j + 2]) << 16) | (((UINT4) input[j + 3]) << - 24); + for (i = 0, j = 0; j < len; i++, j += 4) + output[i] = ((UINT4) input[j]) | (((UINT4) input[j + 1]) << 8) | + (((UINT4) input[j + 2]) << 16) | (((UINT4) input[j + 3]) << + 24); } /*************************************************************************/ @@ -348,30 +348,30 @@ static void Decode(UINT4 *output, unsigned char *input, unsigned int len) int old_encrypt(const char *src, int len, char *dest, int size) { - MD5_CTX context; - char digest[33]; - char tmp[33]; - int i; + MD5_CTX context; + char digest[33]; + char tmp[33]; + int i; - if (size < 16) - return -1; + if (size < 16) + return -1; - memset(&context, 0, sizeof(context)); - memset(&digest, 0, sizeof(digest)); + memset(&context, 0, sizeof(context)); + memset(&digest, 0, sizeof(digest)); - MD5Init(&context); - MD5Update(&context, (unsigned char *)src, len); - MD5Final((unsigned char *)digest, &context); - for (i = 0; i < 32; i += 2) - dest[i / 2] = XTOI(digest[i]) << 4 | XTOI(digest[i + 1]); + MD5Init(&context); + MD5Update(&context, (unsigned char *)src, len); + MD5Final((unsigned char *)digest, &context); + for (i = 0; i < 32; i += 2) + dest[i / 2] = XTOI(digest[i]) << 4 | XTOI(digest[i + 1]); - if(debug) { - memset(tmp,0,33); - binary_to_hex((unsigned char *)dest,tmp,16); - alog("enc_old: Converted [%s] to [%s]",src,tmp); - } + if(debug) { + memset(tmp,0,33); + binary_to_hex((unsigned char *)dest,tmp,16); + alog("enc_old: Converted [%s] to [%s]",src,tmp); + } - return 0; + return 0; } @@ -379,14 +379,14 @@ int old_encrypt(const char *src, int len, char *dest, int size) /* Shortcut for encrypting a null-terminated string in place. */ int old_encrypt_in_place(char *buf, int size) { - return old_encrypt(buf, strlen(buf), buf, size); + return old_encrypt(buf, strlen(buf), buf, size); } int old_encrypt_check_len(int passlen, int bufsize) { - if (bufsize < 16) - fatal("enc_old: old_check_len(): buffer too small (%d)", bufsize); - return 0; + if (bufsize < 16) + fatal("enc_old: old_check_len(): buffer too small (%d)", bufsize); + return 0; } @@ -395,19 +395,19 @@ int old_encrypt_check_len(int passlen, int bufsize) int old_check_password(const char *plaintext, const char *password) { - char buf[BUFSIZE]; - - if (old_encrypt(plaintext, strlen(plaintext), buf, sizeof(buf)) < 0) - return -1; - if (memcmp(buf, password, 16) == 0) - return 1; - else - return 0; + char buf[BUFSIZE]; + + if (old_encrypt(plaintext, strlen(plaintext), buf, sizeof(buf)) < 0) + return -1; + if (memcmp(buf, password, 16) == 0) + return 1; + else + return 0; } int old_decrypt(const char *src, char *dest, int size) { - return 0; + return 0; } class EOld : public Module diff --git a/src/core/enc_sha1.c b/src/core/enc_sha1.c index 1c35519fa..675a3f1b6 100644 --- a/src/core/enc_sha1.c +++ b/src/core/enc_sha1.c @@ -20,9 +20,9 @@ A million repetitions of "a" #include <string.h> typedef struct { - uint32 state[5]; - uint32 count[2]; - unsigned char buffer[64]; + uint32 state[5]; + uint32 count[2]; + unsigned char buffer[64]; } SHA1_CTX; void SHA1Transform(uint32 state[5], unsigned char const buffer[64]); @@ -36,12 +36,12 @@ void SHA1Final(unsigned char digest[20], SHA1_CTX* context); /* I got the idea of expanding during the round function from SSLeay */ #ifdef LITTLE_ENDIAN #define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \ - |(rol(block->l[i],8)&0x00FF00FF)) + |(rol(block->l[i],8)&0x00FF00FF)) #else #define blk0(i) block->l[i] #endif #define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \ - ^block->l[(i+2)&15]^block->l[i&15],1)) + ^block->l[(i+2)&15]^block->l[i&15],1)) /* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */ #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30); @@ -57,52 +57,52 @@ void SHA1Transform(uint32 state[5], unsigned char const buffer[64]) { uint32 a, b, c, d, e; typedef union { - unsigned char c[64]; - uint32 l[16]; + unsigned char c[64]; + uint32 l[16]; } CHAR64LONG16; CHAR64LONG16* block; #ifdef SHA1HANDSOFF static unsigned char workspace[64]; - block = (CHAR64LONG16*)workspace; - memcpy(block, buffer, 64); + block = (CHAR64LONG16*)workspace; + memcpy(block, buffer, 64); #else - block = (CHAR64LONG16*)buffer; + block = (CHAR64LONG16*)buffer; #endif - /* Copy context->state[] to working vars */ - a = state[0]; - b = state[1]; - c = state[2]; - d = state[3]; - e = state[4]; - /* 4 rounds of 20 operations each. Loop unrolled. */ - R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3); - R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7); - R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11); - R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15); - R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19); - R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23); - R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27); - R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31); - R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35); - R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39); - R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43); - R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47); - R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51); - R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55); - R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59); - R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63); - R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67); - R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71); - R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75); - R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79); - /* Add the working vars back into context.state[] */ - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - state[4] += e; - /* Wipe variables */ - a = b = c = d = e = 0; + /* Copy context->state[] to working vars */ + a = state[0]; + b = state[1]; + c = state[2]; + d = state[3]; + e = state[4]; + /* 4 rounds of 20 operations each. Loop unrolled. */ + R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3); + R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7); + R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11); + R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15); + R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19); + R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23); + R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27); + R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31); + R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35); + R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39); + R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43); + R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47); + R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51); + R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55); + R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59); + R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63); + R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67); + R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71); + R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75); + R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79); + /* Add the working vars back into context.state[] */ + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + state[4] += e; + /* Wipe variables */ + a = b = c = d = e = 0; } @@ -110,13 +110,13 @@ static unsigned char workspace[64]; void SHA1Init(SHA1_CTX* context) { - /* SHA1 initialization constants */ - context->state[0] = 0x67452301; - context->state[1] = 0xEFCDAB89; - context->state[2] = 0x98BADCFE; - context->state[3] = 0x10325476; - context->state[4] = 0xC3D2E1F0; - context->count[0] = context->count[1] = 0; + /* SHA1 initialization constants */ + context->state[0] = 0x67452301; + context->state[1] = 0xEFCDAB89; + context->state[2] = 0x98BADCFE; + context->state[3] = 0x10325476; + context->state[4] = 0xC3D2E1F0; + context->count[0] = context->count[1] = 0; } @@ -124,21 +124,21 @@ void SHA1Init(SHA1_CTX* context) void SHA1Update(SHA1_CTX* context, unsigned char const * data, uint32 len) { - uint32 i, j; - - j = (context->count[0] >> 3) & 63; - if ((context->count[0] += len << 3) < (len << 3)) context->count[1]++; - context->count[1] += (len >> 29); - if ((j + len) > 63) { - memcpy(&context->buffer[j], data, (i = 64-j)); - SHA1Transform(context->state, context->buffer); - for ( ; i + 63 < len; i += 64) { - SHA1Transform(context->state, &data[i]); - } - j = 0; - } - else i = 0; - memcpy(&context->buffer[j], &data[i], len - i); + uint32 i, j; + + j = (context->count[0] >> 3) & 63; + if ((context->count[0] += len << 3) < (len << 3)) context->count[1]++; + context->count[1] += (len >> 29); + if ((j + len) > 63) { + memcpy(&context->buffer[j], data, (i = 64-j)); + SHA1Transform(context->state, context->buffer); + for ( ; i + 63 < len; i += 64) { + SHA1Transform(context->state, &data[i]); + } + j = 0; + } + else i = 0; + memcpy(&context->buffer[j], &data[i], len - i); } @@ -146,30 +146,30 @@ void SHA1Update(SHA1_CTX* context, unsigned char const * data, uint32 len) void SHA1Final(unsigned char digest[20], SHA1_CTX* context) { - uint32 i; - unsigned char finalcount[8]; - - for (i = 0; i < 8; i++) { - finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)] - >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */ - } - SHA1Update(context, (unsigned char *)"\200", 1); - while ((context->count[0] & 504) != 448) { - SHA1Update(context, (unsigned char *)"\0", 1); - } - SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */ - for (i = 0; i < 20; i++) { - digest[i] = (unsigned char) - ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); - } - /* Wipe variables */ - i = 0; - memset(context->buffer, 0, 64); - memset(context->state, 0, 20); - memset(context->count, 0, 8); - memset(&finalcount, 0, 8); + uint32 i; + unsigned char finalcount[8]; + + for (i = 0; i < 8; i++) { + finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)] + >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */ + } + SHA1Update(context, (unsigned char *)"\200", 1); + while ((context->count[0] & 504) != 448) { + SHA1Update(context, (unsigned char *)"\0", 1); + } + SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */ + for (i = 0; i < 20; i++) { + digest[i] = (unsigned char) + ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); + } + /* Wipe variables */ + i = 0; + memset(context->buffer, 0, 64); + memset(context->state, 0, 20); + memset(context->count, 0, 8); + memset(&finalcount, 0, 8); #ifdef SHA1HANDSOFF /* make SHA1Transform overwrite it's own static vars */ - SHA1Transform(context->state, context->buffer); + SHA1Transform(context->state, context->buffer); #endif } @@ -177,71 +177,71 @@ void SHA1Final(unsigned char digest[20], SHA1_CTX* context) int sha1_encrypt(const char *src, int len, char *dest, int size) { - SHA1_CTX context; - unsigned char tmp[41]; - - if (size < 20) - return -1; - - memset(dest,0,size); - - SHA1Init(&context); - SHA1Update(&context, (unsigned char *)src, len); - SHA1Final((unsigned char *)dest, &context); - - if(debug) { - memset(tmp,0,41); - binary_to_hex((unsigned char *)dest,(char *)tmp,20); - /* Dont log source if we were encrypting in place :) */ - if (memcmp(src, dest, 20) != 0) { - alog("enc_sha1: hashed from [%s] to [%s]",src,tmp); - } else { - alog("enc_sha1: hashed password to [%s]",tmp); - } - } - - return 0; + SHA1_CTX context; + unsigned char tmp[41]; + + if (size < 20) + return -1; + + memset(dest,0,size); + + SHA1Init(&context); + SHA1Update(&context, (unsigned char *)src, len); + SHA1Final((unsigned char *)dest, &context); + + if(debug) { + memset(tmp,0,41); + binary_to_hex((unsigned char *)dest,(char *)tmp,20); + /* Dont log source if we were encrypting in place :) */ + if (memcmp(src, dest, 20) != 0) { + alog("enc_sha1: hashed from [%s] to [%s]",src,tmp); + } else { + alog("enc_sha1: hashed password to [%s]",tmp); + } + } + + return 0; } int sha1_encrypt_in_place(char *buf, int size) { - char tmp[41]; - - memset(tmp,0,41); - if(sha1_encrypt(buf, strlen(buf), tmp, size)==0) { - memcpy(buf, tmp, size); - } else { - return -1; - } - return 0; + char tmp[41]; + + memset(tmp,0,41); + if(sha1_encrypt(buf, strlen(buf), tmp, size)==0) { + memcpy(buf, tmp, size); + } else { + return -1; + } + return 0; } int sha1_encrypt_check_len(int passlen, int bufsize) { - if (bufsize < 20) - fatal("enc_sha1: sha1_check_len(): buffer too small (%d)", bufsize); - return 0; + if (bufsize < 20) + fatal("enc_sha1: sha1_check_len(): buffer too small (%d)", bufsize); + return 0; } int sha1_decrypt(const char *src, char *dest, int size) { - return 0; + return 0; } int sha1_check_password(const char *plaintext, const char *password) { - char buf[BUFSIZE]; + char buf[BUFSIZE]; - if (sha1_encrypt(plaintext, strlen(plaintext), buf, sizeof(buf)) < 0) - return -1; - if (memcmp(buf, password, 20) == 0) - return 1; + if (sha1_encrypt(plaintext, strlen(plaintext), buf, sizeof(buf)) < 0) + return -1; + if (memcmp(buf, password, 20) == 0) + return 1; - return 0; + return 0; } /*************************************************************************/ diff --git a/src/core/he_help.c b/src/core/he_help.c index afcb4c332..7e2604091 100644 --- a/src/core/he_help.c +++ b/src/core/he_help.c @@ -45,22 +45,22 @@ class HEHelp : public Module */ int do_help(User * u) { - char *cmd = strtok(NULL, ""); + char *cmd = strtok(NULL, ""); - if (!cmd) { - notice_help(s_HelpServ, u, HELP_HELP, s_NickServ, s_ChanServ, - s_MemoServ); - if (s_BotServ) { - notice_help(s_HelpServ, u, HELP_HELP_BOT, s_BotServ); - } - if (s_HostServ) { - notice_help(s_HelpServ, u, HELP_HELP_HOST, s_HostServ); - } - moduleDisplayHelp(7, u); - } else { - mod_help_cmd(s_HelpServ, u, HELPSERV, cmd); - } - return MOD_CONT; + if (!cmd) { + notice_help(s_HelpServ, u, HELP_HELP, s_NickServ, s_ChanServ, + s_MemoServ); + if (s_BotServ) { + notice_help(s_HelpServ, u, HELP_HELP_BOT, s_BotServ); + } + if (s_HostServ) { + notice_help(s_HelpServ, u, HELP_HELP_HOST, s_HostServ); + } + moduleDisplayHelp(7, u); + } else { + mod_help_cmd(s_HelpServ, u, HELPSERV, cmd); + } + return MOD_CONT; } MODULE_INIT("he_help", HEHelp) diff --git a/src/core/hs_del.c b/src/core/hs_del.c index d59bb2e2d..b4f7449ae 100644 --- a/src/core/hs_del.c +++ b/src/core/hs_del.c @@ -45,9 +45,9 @@ class HSDel : public Module **/ void myHostServHelp(User * u) { - if (is_host_remover(u)) { - notice_lang(s_HostServ, u, HOST_HELP_CMD_DEL); - } + if (is_host_remover(u)) { + notice_lang(s_HostServ, u, HOST_HELP_CMD_DEL); + } } /** @@ -57,25 +57,25 @@ void myHostServHelp(User * u) **/ int do_del(User * u) { - NickAlias *na; - char *nick = strtok(NULL, " "); - if (nick) { - if ((na = findnick(nick))) { - if (na->status & NS_VERBOTEN) { - notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick); - return MOD_CONT; - } - alog("vHost for user \002%s\002 deleted by oper \002%s\002", - nick, u->nick); - delHostCore(nick); - notice_lang(s_HostServ, u, HOST_DEL, nick); - } else { - notice_lang(s_HostServ, u, HOST_NOREG, nick); - } - } else { - notice_lang(s_HostServ, u, HOST_DEL_SYNTAX, s_HostServ); - } - return MOD_CONT; + NickAlias *na; + char *nick = strtok(NULL, " "); + if (nick) { + if ((na = findnick(nick))) { + if (na->status & NS_VERBOTEN) { + notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick); + return MOD_CONT; + } + alog("vHost for user \002%s\002 deleted by oper \002%s\002", + nick, u->nick); + delHostCore(nick); + notice_lang(s_HostServ, u, HOST_DEL, nick); + } else { + notice_lang(s_HostServ, u, HOST_NOREG, nick); + } + } else { + notice_lang(s_HostServ, u, HOST_DEL_SYNTAX, s_HostServ); + } + return MOD_CONT; } MODULE_INIT("hs_del", HSDel) diff --git a/src/core/hs_delall.c b/src/core/hs_delall.c index e9173b746..c950afe60 100644 --- a/src/core/hs_delall.c +++ b/src/core/hs_delall.c @@ -45,9 +45,9 @@ class HSDelAll : public Module **/ void myHostServHelp(User * u) { - if (is_host_remover(u)) { - notice_lang(s_HostServ, u, HOST_HELP_CMD_DELALL); - } + if (is_host_remover(u)) { + notice_lang(s_HostServ, u, HOST_HELP_CMD_DELALL); + } } /** @@ -57,30 +57,30 @@ void myHostServHelp(User * u) **/ int do_delall(User * u) { - int i; - char *nick = strtok(NULL, " "); - NickAlias *na; - NickCore *nc; - if (!nick) { - notice_lang(s_HostServ, u, HOST_DELALL_SYNTAX, s_HostServ); - return MOD_CONT; - } - if ((na = findnick(nick))) { - if (na->status & NS_VERBOTEN) { - notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick); - return MOD_CONT; - } - nc = na->nc; - for (i = 0; i < nc->aliases.count; i++) { - na = (NickAlias *)nc->aliases.list[i]; - delHostCore(na->nick); - } - alog("vHosts for all nicks in group \002%s\002 deleted by oper \002%s\002", nc->display, u->nick); - notice_lang(s_HostServ, u, HOST_DELALL, nc->display); - } else { - notice_lang(s_HostServ, u, HOST_NOREG, nick); - } - return MOD_CONT; + int i; + char *nick = strtok(NULL, " "); + NickAlias *na; + NickCore *nc; + if (!nick) { + notice_lang(s_HostServ, u, HOST_DELALL_SYNTAX, s_HostServ); + return MOD_CONT; + } + if ((na = findnick(nick))) { + if (na->status & NS_VERBOTEN) { + notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick); + return MOD_CONT; + } + nc = na->nc; + for (i = 0; i < nc->aliases.count; i++) { + na = (NickAlias *)nc->aliases.list[i]; + delHostCore(na->nick); + } + alog("vHosts for all nicks in group \002%s\002 deleted by oper \002%s\002", nc->display, u->nick); + notice_lang(s_HostServ, u, HOST_DELALL, nc->display); + } else { + notice_lang(s_HostServ, u, HOST_NOREG, nick); + } + return MOD_CONT; } MODULE_INIT("hs_delall", HSDelAll) diff --git a/src/core/hs_group.c b/src/core/hs_group.c index 240ee2719..336e5be92 100644 --- a/src/core/hs_group.c +++ b/src/core/hs_group.c @@ -18,7 +18,7 @@ int do_group(User * u); void myHostServHelp(User * u); extern int do_hs_sync(NickCore * nc, char *vIdent, char *hostmask, - char *creator, time_t time); + char *creator, time_t time); class HSGroup : public Module @@ -47,7 +47,7 @@ class HSGroup : public Module **/ void myHostServHelp(User * u) { - notice_lang(s_HostServ, u, HOST_HELP_CMD_GROUP); + notice_lang(s_HostServ, u, HOST_HELP_CMD_GROUP); } /** @@ -57,57 +57,57 @@ void myHostServHelp(User * u) **/ int do_group(User * u) { - NickAlias *na; - HostCore *tmp; - char *vHost = NULL; - char *vIdent = NULL; - char *creator = NULL; - HostCore *head = NULL; - time_t time; - bool found = false; - - head = hostCoreListHead(); - - if ((na = findnick(u->nick))) { - if (na->status & NS_IDENTIFIED) { - - tmp = findHostCore(head, u->nick, &found); - if (found) { - if (tmp == NULL) { - tmp = head; /* incase first in list */ - } else if (tmp->next) { /* we dont want the previous entry were not inserting! */ - tmp = tmp->next; /* jump to the next */ - } - - vHost = sstrdup(tmp->vHost); - if (tmp->vIdent) - vIdent = sstrdup(tmp->vIdent); - creator = sstrdup(tmp->creator); - time = tmp->time; - - do_hs_sync(na->nc, vIdent, vHost, creator, time); - if (tmp->vIdent) { - notice_lang(s_HostServ, u, HOST_IDENT_GROUP, - na->nc->display, vIdent, vHost); - } else { - notice_lang(s_HostServ, u, HOST_GROUP, na->nc->display, - vHost); - } - free(vHost); - if (vIdent) - free(vIdent); - free(creator); - - } else { - notice_lang(s_HostServ, u, HOST_NOT_ASSIGNED); - } - } else { - notice_lang(s_HostServ, u, HOST_ID); - } - } else { - notice_lang(s_HostServ, u, HOST_NOT_REGED); - } - return MOD_CONT; + NickAlias *na; + HostCore *tmp; + char *vHost = NULL; + char *vIdent = NULL; + char *creator = NULL; + HostCore *head = NULL; + time_t time; + bool found = false; + + head = hostCoreListHead(); + + if ((na = findnick(u->nick))) { + if (na->status & NS_IDENTIFIED) { + + tmp = findHostCore(head, u->nick, &found); + if (found) { + if (tmp == NULL) { + tmp = head; /* incase first in list */ + } else if (tmp->next) { /* we dont want the previous entry were not inserting! */ + tmp = tmp->next; /* jump to the next */ + } + + vHost = sstrdup(tmp->vHost); + if (tmp->vIdent) + vIdent = sstrdup(tmp->vIdent); + creator = sstrdup(tmp->creator); + time = tmp->time; + + do_hs_sync(na->nc, vIdent, vHost, creator, time); + if (tmp->vIdent) { + notice_lang(s_HostServ, u, HOST_IDENT_GROUP, + na->nc->display, vIdent, vHost); + } else { + notice_lang(s_HostServ, u, HOST_GROUP, na->nc->display, + vHost); + } + free(vHost); + if (vIdent) + free(vIdent); + free(creator); + + } else { + notice_lang(s_HostServ, u, HOST_NOT_ASSIGNED); + } + } else { + notice_lang(s_HostServ, u, HOST_ID); + } + } else { + notice_lang(s_HostServ, u, HOST_NOT_REGED); + } + return MOD_CONT; } MODULE_INIT("hs_group", HSGroup) diff --git a/src/core/hs_help.c b/src/core/hs_help.c index abc009a6e..4b76c276c 100644 --- a/src/core/hs_help.c +++ b/src/core/hs_help.c @@ -42,15 +42,15 @@ class HSHelp : public Module **/ int do_help(User * u) { - char *cmd = strtok(NULL, ""); - - if (!cmd) { - notice_help(s_HostServ, u, HOST_HELP, s_HostServ); - moduleDisplayHelp(6, u); - } else { - mod_help_cmd(s_HostServ, u, HOSTSERV, cmd); - } - return MOD_CONT; + char *cmd = strtok(NULL, ""); + + if (!cmd) { + notice_help(s_HostServ, u, HOST_HELP, s_HostServ); + moduleDisplayHelp(6, u); + } else { + mod_help_cmd(s_HostServ, u, HOSTSERV, cmd); + } + return MOD_CONT; } MODULE_INIT("hs_help", HSHelp) diff --git a/src/core/hs_list.c b/src/core/hs_list.c index da1ac5103..1fc8d226e 100644 --- a/src/core/hs_list.c +++ b/src/core/hs_list.c @@ -43,9 +43,9 @@ class HSList : public Module **/ void myHostServHelp(User * u) { - if (is_services_oper(u)) { - notice_lang(s_HostServ, u, HOST_HELP_CMD_LIST); - } + if (is_services_oper(u)) { + notice_lang(s_HostServ, u, HOST_HELP_CMD_LIST); + } } /** @@ -55,122 +55,122 @@ void myHostServHelp(User * u) **/ int listOut(User * u) { - char *key = strtok(NULL, ""); - struct tm *tm; - char buf[BUFSIZE]; - int counter = 1; - int from = 0, to = 0; - char *tmp = NULL; - char *s = NULL; - int display_counter = 0; - HostCore *head = NULL; - HostCore *current; + char *key = strtok(NULL, ""); + struct tm *tm; + char buf[BUFSIZE]; + int counter = 1; + int from = 0, to = 0; + char *tmp = NULL; + char *s = NULL; + int display_counter = 0; + HostCore *head = NULL; + HostCore *current; - head = hostCoreListHead(); + head = hostCoreListHead(); - current = head; - if (current == NULL) - notice_lang(s_HostServ, u, HOST_EMPTY); - else { - /** + current = head; + if (current == NULL) + notice_lang(s_HostServ, u, HOST_EMPTY); + else { + /** * Do a check for a range here, then in the next loop * we'll only display what has been requested.. **/ - if (key) { - if (key[0] == '#') { - tmp = myStrGetOnlyToken((key + 1), '-', 0); /* Read FROM out */ - if (!tmp) { - notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); - return MOD_CONT; - } - for (s = tmp; *s; s++) { - if (!isdigit(*s)) { - free(tmp); - notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); - return MOD_CONT; - } - } - from = atoi(tmp); - free(tmp); - tmp = myStrGetTokenRemainder(key, '-', 1); /* Read TO out */ - if (!tmp) { - notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); - return MOD_CONT; - } - for (s = tmp; *s; s++) { - if (!isdigit(*s)) { - free(tmp); - notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); - return MOD_CONT; - } - } - to = atoi(tmp); - free(tmp); - key = NULL; - } - } + if (key) { + if (key[0] == '#') { + tmp = myStrGetOnlyToken((key + 1), '-', 0); /* Read FROM out */ + if (!tmp) { + notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); + return MOD_CONT; + } + for (s = tmp; *s; s++) { + if (!isdigit(*s)) { + free(tmp); + notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); + return MOD_CONT; + } + } + from = atoi(tmp); + free(tmp); + tmp = myStrGetTokenRemainder(key, '-', 1); /* Read TO out */ + if (!tmp) { + notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); + return MOD_CONT; + } + for (s = tmp; *s; s++) { + if (!isdigit(*s)) { + free(tmp); + notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); + return MOD_CONT; + } + } + to = atoi(tmp); + free(tmp); + key = NULL; + } + } - while (current != NULL) { - if (key) { - if (((match_wild_nocase(key, current->nick)) - || (match_wild_nocase(key, current->vHost))) - && (display_counter < NSListMax)) { - display_counter++; - tm = localtime(¤t->time); - strftime_lang(buf, sizeof(buf), u, - STRFTIME_DATE_TIME_FORMAT, tm); - if (current->vIdent) { - notice_lang(s_HostServ, u, HOST_IDENT_ENTRY, - counter, current->nick, - current->vIdent, current->vHost, - current->creator, buf); - } else { - notice_lang(s_HostServ, u, HOST_ENTRY, counter, - current->nick, current->vHost, - current->creator, buf); - } - } - } else { - /** + while (current != NULL) { + if (key) { + if (((match_wild_nocase(key, current->nick)) + || (match_wild_nocase(key, current->vHost))) + && (display_counter < NSListMax)) { + display_counter++; + tm = localtime(¤t->time); + strftime_lang(buf, sizeof(buf), u, + STRFTIME_DATE_TIME_FORMAT, tm); + if (current->vIdent) { + notice_lang(s_HostServ, u, HOST_IDENT_ENTRY, + counter, current->nick, + current->vIdent, current->vHost, + current->creator, buf); + } else { + notice_lang(s_HostServ, u, HOST_ENTRY, counter, + current->nick, current->vHost, + current->creator, buf); + } + } + } else { + /** * List the host if its in the display range, and not more * than NSListMax records have been displayed... **/ - if ((((counter >= from) && (counter <= to)) - || ((from == 0) && (to == 0))) - && (display_counter < NSListMax)) { - display_counter++; - tm = localtime(¤t->time); - strftime_lang(buf, sizeof(buf), u, - STRFTIME_DATE_TIME_FORMAT, tm); - if (current->vIdent) { - notice_lang(s_HostServ, u, HOST_IDENT_ENTRY, - counter, current->nick, - current->vIdent, current->vHost, - current->creator, buf); - } else { - notice_lang(s_HostServ, u, HOST_ENTRY, counter, - current->nick, current->vHost, - current->creator, buf); - } - } - } - counter++; - current = current->next; - } - if (key) { - notice_lang(s_HostServ, u, HOST_LIST_KEY_FOOTER, key, - display_counter); - } else { - if (from != 0) { - notice_lang(s_HostServ, u, HOST_LIST_RANGE_FOOTER, from, - to); - } else { - notice_lang(s_HostServ, u, HOST_LIST_FOOTER, - display_counter); - } - } - } - return MOD_CONT; + if ((((counter >= from) && (counter <= to)) + || ((from == 0) && (to == 0))) + && (display_counter < NSListMax)) { + display_counter++; + tm = localtime(¤t->time); + strftime_lang(buf, sizeof(buf), u, + STRFTIME_DATE_TIME_FORMAT, tm); + if (current->vIdent) { + notice_lang(s_HostServ, u, HOST_IDENT_ENTRY, + counter, current->nick, + current->vIdent, current->vHost, + current->creator, buf); + } else { + notice_lang(s_HostServ, u, HOST_ENTRY, counter, + current->nick, current->vHost, + current->creator, buf); + } + } + } + counter++; + current = current->next; + } + if (key) { + notice_lang(s_HostServ, u, HOST_LIST_KEY_FOOTER, key, + display_counter); + } else { + if (from != 0) { + notice_lang(s_HostServ, u, HOST_LIST_RANGE_FOOTER, from, + to); + } else { + notice_lang(s_HostServ, u, HOST_LIST_FOOTER, + display_counter); + } + } + } + return MOD_CONT; } MODULE_INIT("hs_list", HSList) diff --git a/src/core/hs_off.c b/src/core/hs_off.c index cd215a426..0ae8caf30 100644 --- a/src/core/hs_off.c +++ b/src/core/hs_off.c @@ -44,7 +44,7 @@ class HSOff : public Module **/ void myHostServHelp(User * u) { - notice_lang(s_HostServ, u, HOST_HELP_CMD_OFF); + notice_lang(s_HostServ, u, HOST_HELP_CMD_OFF); } /** @@ -54,24 +54,24 @@ void myHostServHelp(User * u) **/ int do_off(User * u) { - NickAlias *na; - char *vhost; - char *vident = NULL; - if ((na = findnick(u->nick))) { - if (na->status & NS_IDENTIFIED) { - vhost = getvHost(u->nick); - vident = getvIdent(u->nick); - if (vhost == NULL && vident == NULL) - notice_lang(s_HostServ, u, HOST_NOT_ASSIGNED); - else - ircdproto->SendVhostDel(u); - } else { - notice_lang(s_HostServ, u, HOST_ID); - } - } else { - notice_lang(s_HostServ, u, HOST_NOT_REGED); - } - return MOD_CONT; + NickAlias *na; + char *vhost; + char *vident = NULL; + if ((na = findnick(u->nick))) { + if (na->status & NS_IDENTIFIED) { + vhost = getvHost(u->nick); + vident = getvIdent(u->nick); + if (vhost == NULL && vident == NULL) + notice_lang(s_HostServ, u, HOST_NOT_ASSIGNED); + else + ircdproto->SendVhostDel(u); + } else { + notice_lang(s_HostServ, u, HOST_ID); + } + } else { + notice_lang(s_HostServ, u, HOST_NOT_REGED); + } + return MOD_CONT; } MODULE_INIT("hs_off", HSOff) diff --git a/src/core/hs_on.c b/src/core/hs_on.c index aca596df6..0f558e2dc 100644 --- a/src/core/hs_on.c +++ b/src/core/hs_on.c @@ -44,7 +44,7 @@ class HSOn : public Module **/ void myHostServHelp(User * u) { - notice_lang(s_HostServ, u, HOST_HELP_CMD_ON); + notice_lang(s_HostServ, u, HOST_HELP_CMD_ON); } /** @@ -54,39 +54,39 @@ void myHostServHelp(User * u) **/ int do_on(User * u) { - NickAlias *na; - char *vHost; - char *vIdent = NULL; - if ((na = findnick(u->nick))) { - if (na->status & NS_IDENTIFIED) { - vHost = getvHost(u->nick); - vIdent = getvIdent(u->nick); - if (vHost == NULL) { - notice_lang(s_HostServ, u, HOST_NOT_ASSIGNED); - } else { - if (vIdent) { - notice_lang(s_HostServ, u, HOST_IDENT_ACTIVATED, - vIdent, vHost); - } else { - notice_lang(s_HostServ, u, HOST_ACTIVATED, vHost); - } - ircdproto->SendVhost(u->nick, vIdent, vHost); - if (ircd->vhost) { - u->vhost = sstrdup(vHost); - } - if (ircd->vident) { - if (vIdent) - u->vident = sstrdup(vIdent); - } - set_lastmask(u); - } - } else { - notice_lang(s_HostServ, u, HOST_ID); - } - } else { - notice_lang(s_HostServ, u, HOST_NOT_REGED); - } - return MOD_CONT; + NickAlias *na; + char *vHost; + char *vIdent = NULL; + if ((na = findnick(u->nick))) { + if (na->status & NS_IDENTIFIED) { + vHost = getvHost(u->nick); + vIdent = getvIdent(u->nick); + if (vHost == NULL) { + notice_lang(s_HostServ, u, HOST_NOT_ASSIGNED); + } else { + if (vIdent) { + notice_lang(s_HostServ, u, HOST_IDENT_ACTIVATED, + vIdent, vHost); + } else { + notice_lang(s_HostServ, u, HOST_ACTIVATED, vHost); + } + ircdproto->SendVhost(u->nick, vIdent, vHost); + if (ircd->vhost) { + u->vhost = sstrdup(vHost); + } + if (ircd->vident) { + if (vIdent) + u->vident = sstrdup(vIdent); + } + set_lastmask(u); + } + } else { + notice_lang(s_HostServ, u, HOST_ID); + } + } else { + notice_lang(s_HostServ, u, HOST_NOT_REGED); + } + return MOD_CONT; } MODULE_INIT("hs_on", HSOn) diff --git a/src/core/hs_set.c b/src/core/hs_set.c index 56adda848..9886c1ce4 100644 --- a/src/core/hs_set.c +++ b/src/core/hs_set.c @@ -44,9 +44,9 @@ class HSSet : public Module **/ void myHostServHelp(User * u) { - if (is_host_setter(u)) { - notice_lang(s_HostServ, u, HOST_HELP_CMD_SET); - } + if (is_host_setter(u)) { + notice_lang(s_HostServ, u, HOST_HELP_CMD_SET); + } } /** @@ -56,112 +56,112 @@ void myHostServHelp(User * u) **/ int myDoSet(User * u) { - char *nick = strtok(NULL, " "); - char *rawhostmask = strtok(NULL, " "); - char *hostmask = (char *)smalloc(HOSTMAX); - - NickAlias *na; - int32 tmp_time; - char *s; - - char *vIdent = NULL; - - if (!nick || !rawhostmask) { - notice_lang(s_HostServ, u, HOST_SET_SYNTAX, s_HostServ); - free(hostmask); - return MOD_CONT; - } - - vIdent = myStrGetOnlyToken(rawhostmask, '@', 0); /* Get the first substring, @ as delimiter */ - if (vIdent) { - rawhostmask = myStrGetTokenRemainder(rawhostmask, '@', 1); /* get the remaining string */ - if (!rawhostmask) { - notice_lang(s_HostServ, u, HOST_SET_SYNTAX, s_HostServ); - free(vIdent); - free(hostmask); - return MOD_CONT; - } - if (strlen(vIdent) > USERMAX - 1) { - notice_lang(s_HostServ, u, HOST_SET_IDENTTOOLONG, USERMAX); - free(vIdent); - free(rawhostmask); - free(hostmask); - return MOD_CONT; - } else { - for (s = vIdent; *s; s++) { - if (!isvalidchar(*s)) { - notice_lang(s_HostServ, u, HOST_SET_IDENT_ERROR); - free(vIdent); - free(rawhostmask); - free(hostmask); - return MOD_CONT; - } - } - } - if (!ircd->vident) { - notice_lang(s_HostServ, u, HOST_NO_VIDENT); - free(vIdent); - free(rawhostmask); - free(hostmask); - return MOD_CONT; - } - } - if (strlen(rawhostmask) < HOSTMAX - 1) - snprintf(hostmask, HOSTMAX - 1, "%s", rawhostmask); - else { - notice_lang(s_HostServ, u, HOST_SET_TOOLONG, HOSTMAX); - if (vIdent) { - free(vIdent); - free(rawhostmask); - } - free(hostmask); - return MOD_CONT; - } - - if (!isValidHost(hostmask, 3)) { - notice_lang(s_HostServ, u, HOST_SET_ERROR); - if (vIdent) { - free(vIdent); - free(rawhostmask); - } - free(hostmask); - return MOD_CONT; - } - - - tmp_time = time(NULL); - - if ((na = findnick(nick))) { - if (na->status & NS_VERBOTEN) { - notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick); - if (vIdent) { - free(vIdent); - free(rawhostmask); - } - free(hostmask); - return MOD_CONT; - } - if (vIdent && ircd->vident) { - alog("vHost for user \002%s\002 set to \002%s@%s\002 by oper \002%s\002", nick, vIdent, hostmask, u->nick); - } else { - alog("vHost for user \002%s\002 set to \002%s\002 by oper \002%s\002", nick, hostmask, u->nick); - } - addHostCore(nick, vIdent, hostmask, u->nick, tmp_time); - if (vIdent) { - notice_lang(s_HostServ, u, HOST_IDENT_SET, nick, vIdent, - hostmask); - } else { - notice_lang(s_HostServ, u, HOST_SET, nick, hostmask); - } - } else { - notice_lang(s_HostServ, u, HOST_NOREG, nick); - } - free(hostmask); - if (vIdent) { - free(vIdent); - free(rawhostmask); - } - return MOD_CONT; + char *nick = strtok(NULL, " "); + char *rawhostmask = strtok(NULL, " "); + char *hostmask = (char *)smalloc(HOSTMAX); + + NickAlias *na; + int32 tmp_time; + char *s; + + char *vIdent = NULL; + + if (!nick || !rawhostmask) { + notice_lang(s_HostServ, u, HOST_SET_SYNTAX, s_HostServ); + free(hostmask); + return MOD_CONT; + } + + vIdent = myStrGetOnlyToken(rawhostmask, '@', 0); /* Get the first substring, @ as delimiter */ + if (vIdent) { + rawhostmask = myStrGetTokenRemainder(rawhostmask, '@', 1); /* get the remaining string */ + if (!rawhostmask) { + notice_lang(s_HostServ, u, HOST_SET_SYNTAX, s_HostServ); + free(vIdent); + free(hostmask); + return MOD_CONT; + } + if (strlen(vIdent) > USERMAX - 1) { + notice_lang(s_HostServ, u, HOST_SET_IDENTTOOLONG, USERMAX); + free(vIdent); + free(rawhostmask); + free(hostmask); + return MOD_CONT; + } else { + for (s = vIdent; *s; s++) { + if (!isvalidchar(*s)) { + notice_lang(s_HostServ, u, HOST_SET_IDENT_ERROR); + free(vIdent); + free(rawhostmask); + free(hostmask); + return MOD_CONT; + } + } + } + if (!ircd->vident) { + notice_lang(s_HostServ, u, HOST_NO_VIDENT); + free(vIdent); + free(rawhostmask); + free(hostmask); + return MOD_CONT; + } + } + if (strlen(rawhostmask) < HOSTMAX - 1) + snprintf(hostmask, HOSTMAX - 1, "%s", rawhostmask); + else { + notice_lang(s_HostServ, u, HOST_SET_TOOLONG, HOSTMAX); + if (vIdent) { + free(vIdent); + free(rawhostmask); + } + free(hostmask); + return MOD_CONT; + } + + if (!isValidHost(hostmask, 3)) { + notice_lang(s_HostServ, u, HOST_SET_ERROR); + if (vIdent) { + free(vIdent); + free(rawhostmask); + } + free(hostmask); + return MOD_CONT; + } + + + tmp_time = time(NULL); + + if ((na = findnick(nick))) { + if (na->status & NS_VERBOTEN) { + notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick); + if (vIdent) { + free(vIdent); + free(rawhostmask); + } + free(hostmask); + return MOD_CONT; + } + if (vIdent && ircd->vident) { + alog("vHost for user \002%s\002 set to \002%s@%s\002 by oper \002%s\002", nick, vIdent, hostmask, u->nick); + } else { + alog("vHost for user \002%s\002 set to \002%s\002 by oper \002%s\002", nick, hostmask, u->nick); + } + addHostCore(nick, vIdent, hostmask, u->nick, tmp_time); + if (vIdent) { + notice_lang(s_HostServ, u, HOST_IDENT_SET, nick, vIdent, + hostmask); + } else { + notice_lang(s_HostServ, u, HOST_SET, nick, hostmask); + } + } else { + notice_lang(s_HostServ, u, HOST_NOREG, nick); + } + free(hostmask); + if (vIdent) { + free(vIdent); + free(rawhostmask); + } + return MOD_CONT; } MODULE_INIT("hs_set", HSSet) diff --git a/src/core/hs_setall.c b/src/core/hs_setall.c index 88b81d6c5..2c220f638 100644 --- a/src/core/hs_setall.c +++ b/src/core/hs_setall.c @@ -18,7 +18,7 @@ int do_setall(User * u); void myHostServHelp(User * u); extern int do_hs_sync(NickCore * nc, char *vIdent, char *hostmask, - char *creator, time_t time); + char *creator, time_t time); class HSSetAll : public Module { @@ -45,9 +45,9 @@ class HSSetAll : public Module **/ void myHostServHelp(User * u) { - if (is_host_setter(u)) { - notice_lang(s_HostServ, u, HOST_HELP_CMD_SETALL); - } + if (is_host_setter(u)) { + notice_lang(s_HostServ, u, HOST_HELP_CMD_SETALL); + } } /** @@ -57,112 +57,112 @@ void myHostServHelp(User * u) **/ int do_setall(User * u) { - char *nick = (char *)strtok(NULL, " "); - char *rawhostmask = strtok(NULL, " "); - char *hostmask = (char *)smalloc(HOSTMAX); - - NickAlias *na; - int32 tmp_time; - char *s; - - char *vIdent = NULL; - - if (!nick || !rawhostmask) { - notice_lang(s_HostServ, u, HOST_SETALL_SYNTAX, s_HostServ); - free(hostmask); - return MOD_CONT; - } - - vIdent = myStrGetOnlyToken(rawhostmask, '@', 0); /* Get the first substring, @ as delimiter */ - if (vIdent) { - rawhostmask = myStrGetTokenRemainder(rawhostmask, '@', 1); /* get the remaining string */ - if (!rawhostmask) { - notice_lang(s_HostServ, u, HOST_SETALL_SYNTAX, s_HostServ); - free(vIdent); - free(hostmask); - return MOD_CONT; - } - if (strlen(vIdent) > USERMAX - 1) { - notice_lang(s_HostServ, u, HOST_SET_IDENTTOOLONG, USERMAX); - free(vIdent); - free(rawhostmask); - free(hostmask); - return MOD_CONT; - } else { - for (s = vIdent; *s; s++) { - if (!isvalidchar(*s)) { - notice_lang(s_HostServ, u, HOST_SET_IDENT_ERROR); - free(vIdent); - free(rawhostmask); - free(hostmask); - return MOD_CONT; - } - } - } - if (!ircd->vident) { - notice_lang(s_HostServ, u, HOST_NO_VIDENT); - free(vIdent); - free(rawhostmask); - free(hostmask); - return MOD_CONT; - } - } - - if (strlen(rawhostmask) < HOSTMAX - 1) - snprintf(hostmask, HOSTMAX - 1, "%s", rawhostmask); - else { - notice_lang(s_HostServ, u, HOST_SET_TOOLONG, HOSTMAX); - if (vIdent) { - free(vIdent); - free(rawhostmask); - } - free(hostmask); - return MOD_CONT; - } - - if (!isValidHost(hostmask, 3)) { - notice_lang(s_HostServ, u, HOST_SET_ERROR); - if (vIdent) { - free(vIdent); - free(rawhostmask); - } - free(hostmask); - return MOD_CONT; - } - - tmp_time = time(NULL); - - if ((na = findnick(nick))) { - if (na->status & NS_VERBOTEN) { - notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick); - if (vIdent) { - free(vIdent); - free(rawhostmask); - } - free(hostmask); - return MOD_CONT; - } - if (vIdent && ircd->vident) { - alog("vHost for all nicks in group \002%s\002 set to \002%s@%s\002 by oper \002%s\002", nick, vIdent, hostmask, u->nick); - } else { - alog("vHost for all nicks in group \002%s\002 set to \002%s\002 by oper \002%s\002", nick, hostmask, u->nick); - } - do_hs_sync(na->nc, vIdent, hostmask, u->nick, tmp_time); - if (vIdent) { - notice_lang(s_HostServ, u, HOST_IDENT_SETALL, nick, vIdent, - hostmask); - } else { - notice_lang(s_HostServ, u, HOST_SETALL, nick, hostmask); - } - } else { - notice_lang(s_HostServ, u, HOST_NOREG, nick); - } - if (vIdent) { - free(vIdent); - free(rawhostmask); - } - free(hostmask); - return MOD_CONT; + char *nick = (char *)strtok(NULL, " "); + char *rawhostmask = strtok(NULL, " "); + char *hostmask = (char *)smalloc(HOSTMAX); + + NickAlias *na; + int32 tmp_time; + char *s; + + char *vIdent = NULL; + + if (!nick || !rawhostmask) { + notice_lang(s_HostServ, u, HOST_SETALL_SYNTAX, s_HostServ); + free(hostmask); + return MOD_CONT; + } + + vIdent = myStrGetOnlyToken(rawhostmask, '@', 0); /* Get the first substring, @ as delimiter */ + if (vIdent) { + rawhostmask = myStrGetTokenRemainder(rawhostmask, '@', 1); /* get the remaining string */ + if (!rawhostmask) { + notice_lang(s_HostServ, u, HOST_SETALL_SYNTAX, s_HostServ); + free(vIdent); + free(hostmask); + return MOD_CONT; + } + if (strlen(vIdent) > USERMAX - 1) { + notice_lang(s_HostServ, u, HOST_SET_IDENTTOOLONG, USERMAX); + free(vIdent); + free(rawhostmask); + free(hostmask); + return MOD_CONT; + } else { + for (s = vIdent; *s; s++) { + if (!isvalidchar(*s)) { + notice_lang(s_HostServ, u, HOST_SET_IDENT_ERROR); + free(vIdent); + free(rawhostmask); + free(hostmask); + return MOD_CONT; + } + } + } + if (!ircd->vident) { + notice_lang(s_HostServ, u, HOST_NO_VIDENT); + free(vIdent); + free(rawhostmask); + free(hostmask); + return MOD_CONT; + } + } + + if (strlen(rawhostmask) < HOSTMAX - 1) + snprintf(hostmask, HOSTMAX - 1, "%s", rawhostmask); + else { + notice_lang(s_HostServ, u, HOST_SET_TOOLONG, HOSTMAX); + if (vIdent) { + free(vIdent); + free(rawhostmask); + } + free(hostmask); + return MOD_CONT; + } + + if (!isValidHost(hostmask, 3)) { + notice_lang(s_HostServ, u, HOST_SET_ERROR); + if (vIdent) { + free(vIdent); + free(rawhostmask); + } + free(hostmask); + return MOD_CONT; + } + + tmp_time = time(NULL); + + if ((na = findnick(nick))) { + if (na->status & NS_VERBOTEN) { + notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick); + if (vIdent) { + free(vIdent); + free(rawhostmask); + } + free(hostmask); + return MOD_CONT; + } + if (vIdent && ircd->vident) { + alog("vHost for all nicks in group \002%s\002 set to \002%s@%s\002 by oper \002%s\002", nick, vIdent, hostmask, u->nick); + } else { + alog("vHost for all nicks in group \002%s\002 set to \002%s\002 by oper \002%s\002", nick, hostmask, u->nick); + } + do_hs_sync(na->nc, vIdent, hostmask, u->nick, tmp_time); + if (vIdent) { + notice_lang(s_HostServ, u, HOST_IDENT_SETALL, nick, vIdent, + hostmask); + } else { + notice_lang(s_HostServ, u, HOST_SETALL, nick, hostmask); + } + } else { + notice_lang(s_HostServ, u, HOST_NOREG, nick); + } + if (vIdent) { + free(vIdent); + free(rawhostmask); + } + free(hostmask); + return MOD_CONT; } MODULE_INIT("hs_setall", HSSetAll) diff --git a/src/core/ms_cancel.c b/src/core/ms_cancel.c index b988743d1..c7a5402d0 100644 --- a/src/core/ms_cancel.c +++ b/src/core/ms_cancel.c @@ -42,7 +42,7 @@ class MSCancel : public Module **/ void myMemoServHelp(User * u) { - notice_lang(s_MemoServ, u, MEMO_HELP_CMD_CANCEL); + notice_lang(s_MemoServ, u, MEMO_HELP_CMD_CANCEL); } /** @@ -52,43 +52,43 @@ void myMemoServHelp(User * u) **/ int do_cancel(User * u) { - int ischan; - int isforbid; - char *name = strtok(NULL, " "); - MemoInfo *mi; + int ischan; + int isforbid; + char *name = strtok(NULL, " "); + MemoInfo *mi; - if (!name) { - syntax_error(s_MemoServ, u, "CANCEL", MEMO_CANCEL_SYNTAX); + if (!name) { + syntax_error(s_MemoServ, u, "CANCEL", MEMO_CANCEL_SYNTAX); - } else if (!nick_recognized(u)) { - notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); + } else if (!nick_recognized(u)) { + notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); - } else if (!(mi = getmemoinfo(name, &ischan, &isforbid))) { - if (isforbid) { - notice_lang(s_MemoServ, u, - ischan ? CHAN_X_FORBIDDEN : - NICK_X_FORBIDDEN, name); - } else { - notice_lang(s_MemoServ, u, - ischan ? CHAN_X_NOT_REGISTERED : - NICK_X_NOT_REGISTERED, name); - } - } else { - int i; + } else if (!(mi = getmemoinfo(name, &ischan, &isforbid))) { + if (isforbid) { + notice_lang(s_MemoServ, u, + ischan ? CHAN_X_FORBIDDEN : + NICK_X_FORBIDDEN, name); + } else { + notice_lang(s_MemoServ, u, + ischan ? CHAN_X_NOT_REGISTERED : + NICK_X_NOT_REGISTERED, name); + } + } else { + int i; - for (i = mi->memocount - 1; i >= 0; i--) { - if ((mi->memos[i].flags & MF_UNREAD) - && !stricmp(mi->memos[i].sender, u->na->nc->display) - && (!(mi->memos[i].flags & MF_NOTIFYS))) { - delmemo(mi, mi->memos[i].number); - notice_lang(s_MemoServ, u, MEMO_CANCELLED, name); - return MOD_CONT; - } - } + for (i = mi->memocount - 1; i >= 0; i--) { + if ((mi->memos[i].flags & MF_UNREAD) + && !stricmp(mi->memos[i].sender, u->na->nc->display) + && (!(mi->memos[i].flags & MF_NOTIFYS))) { + delmemo(mi, mi->memos[i].number); + notice_lang(s_MemoServ, u, MEMO_CANCELLED, name); + return MOD_CONT; + } + } - notice_lang(s_MemoServ, u, MEMO_CANCEL_NONE); - } - return MOD_CONT; + notice_lang(s_MemoServ, u, MEMO_CANCEL_NONE); + } + return MOD_CONT; } MODULE_INIT("ms_cancel", MSCancel) diff --git a/src/core/ms_check.c b/src/core/ms_check.c index e5410d9b1..383291635 100644 --- a/src/core/ms_check.c +++ b/src/core/ms_check.c @@ -42,7 +42,7 @@ class MSCheck : public Module **/ void myMemoServHelp(User * u) { - notice_lang(s_MemoServ, u, MEMO_HELP_CMD_CHECK); + notice_lang(s_MemoServ, u, MEMO_HELP_CMD_CHECK); } /** @@ -52,56 +52,56 @@ void myMemoServHelp(User * u) **/ int do_memocheck(User * u) { - NickAlias *na = NULL; - MemoInfo *mi = NULL; - int i, found = 0; - char *recipient = strtok(NULL, ""); - struct tm *tm; - char timebuf[64]; - - if (!recipient) { - syntax_error(s_MemoServ, u, "CHECK", MEMO_CHECK_SYNTAX); - return MOD_CONT; - } else if (!nick_recognized(u)) { - notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); - return MOD_CONT; - } else if (!(na = findnick(recipient))) { - notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, recipient); - return MOD_CONT; - } - - if ((na->status & NS_VERBOTEN)) { - notice_lang(s_MemoServ, u, NICK_X_FORBIDDEN, recipient); - return MOD_CONT; - } - - mi = &na->nc->memos; + NickAlias *na = NULL; + MemoInfo *mi = NULL; + int i, found = 0; + char *recipient = strtok(NULL, ""); + struct tm *tm; + char timebuf[64]; + + if (!recipient) { + syntax_error(s_MemoServ, u, "CHECK", MEMO_CHECK_SYNTAX); + return MOD_CONT; + } else if (!nick_recognized(u)) { + notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); + return MOD_CONT; + } else if (!(na = findnick(recipient))) { + notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, recipient); + return MOD_CONT; + } + + if ((na->status & NS_VERBOTEN)) { + notice_lang(s_MemoServ, u, NICK_X_FORBIDDEN, recipient); + return MOD_CONT; + } + + mi = &na->nc->memos; /* Okay, I know this looks strange but we wanna get the LAST memo, so we - have to loop backwards */ - - for (i = (mi->memocount - 1); i >= 0; i--) { - if (!stricmp(mi->memos[i].sender, u->na->nc->display)) { - found = 1; /* Yes, we've found the memo */ - - tm = localtime(&mi->memos[i].time); - strftime_lang(timebuf, sizeof(timebuf), u, - STRFTIME_DATE_TIME_FORMAT, tm); - - if (mi->memos[i].flags & MF_UNREAD) - notice_lang(s_MemoServ, u, MEMO_CHECK_NOT_READ, na->nick, - timebuf); - else - notice_lang(s_MemoServ, u, MEMO_CHECK_READ, na->nick, - timebuf); - break; - } - } - - if (!found) - notice_lang(s_MemoServ, u, MEMO_CHECK_NO_MEMO, na->nick); - - return MOD_CONT; + have to loop backwards */ + + for (i = (mi->memocount - 1); i >= 0; i--) { + if (!stricmp(mi->memos[i].sender, u->na->nc->display)) { + found = 1; /* Yes, we've found the memo */ + + tm = localtime(&mi->memos[i].time); + strftime_lang(timebuf, sizeof(timebuf), u, + STRFTIME_DATE_TIME_FORMAT, tm); + + if (mi->memos[i].flags & MF_UNREAD) + notice_lang(s_MemoServ, u, MEMO_CHECK_NOT_READ, na->nick, + timebuf); + else + notice_lang(s_MemoServ, u, MEMO_CHECK_READ, na->nick, + timebuf); + break; + } + } + + if (!found) + notice_lang(s_MemoServ, u, MEMO_CHECK_NO_MEMO, na->nick); + + return MOD_CONT; } MODULE_INIT("ms_check", MSCheck) diff --git a/src/core/ms_del.c b/src/core/ms_del.c index 3cc877b9e..1f30eb25e 100644 --- a/src/core/ms_del.c +++ b/src/core/ms_del.c @@ -43,7 +43,7 @@ class MSDel : public Module **/ void myMemoServHelp(User * u) { - notice_lang(s_MemoServ, u, MEMO_HELP_CMD_DEL); + notice_lang(s_MemoServ, u, MEMO_HELP_CMD_DEL); } /** @@ -53,105 +53,105 @@ void myMemoServHelp(User * u) **/ int do_del(User * u) { - MemoInfo *mi; - ChannelInfo *ci; - char *numstr = strtok(NULL, ""), *chan = NULL; - int last, last0, i; - char buf[BUFSIZE], *end; - int delcount, count, left; + MemoInfo *mi; + ChannelInfo *ci; + char *numstr = strtok(NULL, ""), *chan = NULL; + int last, last0, i; + char buf[BUFSIZE], *end; + int delcount, count, left; - if (numstr && *numstr == '#') { - chan = strtok(numstr, " "); - numstr = strtok(NULL, ""); - if (!(ci = cs_findchan(chan))) { - notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, chan); - return MOD_CONT; - } else if (readonly) { - notice_lang(s_MemoServ, u, READ_ONLY_MODE); - return MOD_CONT; - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_MemoServ, u, CHAN_X_FORBIDDEN, chan); - return MOD_CONT; - } else if (!check_access(u, ci, CA_MEMO)) { - notice_lang(s_MemoServ, u, ACCESS_DENIED); - return MOD_CONT; - } - mi = &ci->memos; - } else { - if (!nick_identified(u)) { - notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); - return MOD_CONT; - } - mi = &u->na->nc->memos; - } - if (!numstr - || (!isdigit(*numstr) && stricmp(numstr, "ALL") != 0 - && stricmp(numstr, "LAST") != 0)) { - syntax_error(s_MemoServ, u, "DEL", MEMO_DEL_SYNTAX); - } else if (mi->memocount == 0) { - if (chan) - notice_lang(s_MemoServ, u, MEMO_X_HAS_NO_MEMOS, chan); - else - notice_lang(s_MemoServ, u, MEMO_HAVE_NO_MEMOS); - } else { - if (isdigit(*numstr)) { - /* Delete a specific memo or memos. */ - last = -1; /* Last memo deleted */ - last0 = -1; /* Beginning of range of last memos deleted */ - end = buf; - left = sizeof(buf); - delcount = - process_numlist(numstr, &count, del_memo_callback, u, mi, - &last, &last0, &end, &left); - if (last != -1) { - /* Some memos got deleted; tell them which ones. */ - if (delcount > 1) { - if (last0 != last) - end += snprintf(end, sizeof(buf) - (end - buf), - ",%d-%d", last0, last); - else - end += snprintf(end, sizeof(buf) - (end - buf), - ",%d", last); - /* "buf+1" here because *buf == ',' */ - notice_lang(s_MemoServ, u, MEMO_DELETED_SEVERAL, - buf + 1); - } else { - notice_lang(s_MemoServ, u, MEMO_DELETED_ONE, last); - } - } else { - /* No memos were deleted. Tell them so. */ - if (count == 1) - notice_lang(s_MemoServ, u, MEMO_DOES_NOT_EXIST, - atoi(numstr)); - else - notice_lang(s_MemoServ, u, MEMO_DELETED_NONE); - } - } else if (stricmp(numstr, "LAST") == 0) { - /* Delete last memo. */ - for (i = 0; i < mi->memocount; i++) - last = mi->memos[i].number; - delmemo(mi, last); - notice_lang(s_MemoServ, u, MEMO_DELETED_ONE, last); - } else { - /* Delete all memos. */ - for (i = 0; i < mi->memocount; i++) { - free(mi->memos[i].text); - moduleCleanStruct(&mi->memos[i].moduleData); - } - free(mi->memos); - mi->memos = NULL; - mi->memocount = 0; - if (chan) - notice_lang(s_MemoServ, u, MEMO_CHAN_DELETED_ALL, chan); - else - notice_lang(s_MemoServ, u, MEMO_DELETED_ALL); - } + if (numstr && *numstr == '#') { + chan = strtok(numstr, " "); + numstr = strtok(NULL, ""); + if (!(ci = cs_findchan(chan))) { + notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, chan); + return MOD_CONT; + } else if (readonly) { + notice_lang(s_MemoServ, u, READ_ONLY_MODE); + return MOD_CONT; + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_MemoServ, u, CHAN_X_FORBIDDEN, chan); + return MOD_CONT; + } else if (!check_access(u, ci, CA_MEMO)) { + notice_lang(s_MemoServ, u, ACCESS_DENIED); + return MOD_CONT; + } + mi = &ci->memos; + } else { + if (!nick_identified(u)) { + notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); + return MOD_CONT; + } + mi = &u->na->nc->memos; + } + if (!numstr + || (!isdigit(*numstr) && stricmp(numstr, "ALL") != 0 + && stricmp(numstr, "LAST") != 0)) { + syntax_error(s_MemoServ, u, "DEL", MEMO_DEL_SYNTAX); + } else if (mi->memocount == 0) { + if (chan) + notice_lang(s_MemoServ, u, MEMO_X_HAS_NO_MEMOS, chan); + else + notice_lang(s_MemoServ, u, MEMO_HAVE_NO_MEMOS); + } else { + if (isdigit(*numstr)) { + /* Delete a specific memo or memos. */ + last = -1; /* Last memo deleted */ + last0 = -1; /* Beginning of range of last memos deleted */ + end = buf; + left = sizeof(buf); + delcount = + process_numlist(numstr, &count, del_memo_callback, u, mi, + &last, &last0, &end, &left); + if (last != -1) { + /* Some memos got deleted; tell them which ones. */ + if (delcount > 1) { + if (last0 != last) + end += snprintf(end, sizeof(buf) - (end - buf), + ",%d-%d", last0, last); + else + end += snprintf(end, sizeof(buf) - (end - buf), + ",%d", last); + /* "buf+1" here because *buf == ',' */ + notice_lang(s_MemoServ, u, MEMO_DELETED_SEVERAL, + buf + 1); + } else { + notice_lang(s_MemoServ, u, MEMO_DELETED_ONE, last); + } + } else { + /* No memos were deleted. Tell them so. */ + if (count == 1) + notice_lang(s_MemoServ, u, MEMO_DOES_NOT_EXIST, + atoi(numstr)); + else + notice_lang(s_MemoServ, u, MEMO_DELETED_NONE); + } + } else if (stricmp(numstr, "LAST") == 0) { + /* Delete last memo. */ + for (i = 0; i < mi->memocount; i++) + last = mi->memos[i].number; + delmemo(mi, last); + notice_lang(s_MemoServ, u, MEMO_DELETED_ONE, last); + } else { + /* Delete all memos. */ + for (i = 0; i < mi->memocount; i++) { + free(mi->memos[i].text); + moduleCleanStruct(&mi->memos[i].moduleData); + } + free(mi->memos); + mi->memos = NULL; + mi->memocount = 0; + if (chan) + notice_lang(s_MemoServ, u, MEMO_CHAN_DELETED_ALL, chan); + else + notice_lang(s_MemoServ, u, MEMO_DELETED_ALL); + } - /* Reset the order */ - for (i = 0; i < mi->memocount; i++) - mi->memos[i].number = i + 1; - } - return MOD_CONT; + /* Reset the order */ + for (i = 0; i < mi->memocount; i++) + mi->memos[i].number = i + 1; + } + return MOD_CONT; } /** @@ -163,30 +163,30 @@ int do_del(User * u) */ int del_memo_callback(User * u, int num, va_list args) { - MemoInfo *mi = va_arg(args, MemoInfo *); - int *last = va_arg(args, int *); - int *last0 = va_arg(args, int *); - char **end = va_arg(args, char **); - int *left = va_arg(args, int *); + MemoInfo *mi = va_arg(args, MemoInfo *); + int *last = va_arg(args, int *); + int *last0 = va_arg(args, int *); + char **end = va_arg(args, char **); + int *left = va_arg(args, int *); - if (delmemo(mi, num)) { - if (num != (*last) + 1) { - if (*last != -1) { - int len; - if (*last0 != *last) - len = snprintf(*end, *left, ",%d-%d", *last0, *last); - else - len = snprintf(*end, *left, ",%d", *last); - *end += len; - *left -= len; - } - *last0 = num; - } - *last = num; - return 1; - } else { - return 0; - } + if (delmemo(mi, num)) { + if (num != (*last) + 1) { + if (*last != -1) { + int len; + if (*last0 != *last) + len = snprintf(*end, *left, ",%d-%d", *last0, *last); + else + len = snprintf(*end, *left, ",%d", *last); + *end += len; + *left -= len; + } + *last0 = num; + } + *last = num; + return 1; + } else { + return 0; + } } MODULE_INIT("ms_del", MSDel) diff --git a/src/core/ms_help.c b/src/core/ms_help.c index 7a8961190..0b04957a3 100644 --- a/src/core/ms_help.c +++ b/src/core/ms_help.c @@ -42,16 +42,16 @@ class MSHelp : public Module **/ int do_help(User * u) { - char *cmd = strtok(NULL, ""); - - if (!cmd) { - notice_help(s_MemoServ, u, MEMO_HELP_HEADER); - moduleDisplayHelp(3, u); - notice_help(s_MemoServ, u, MEMO_HELP_FOOTER, s_ChanServ); - } else { - mod_help_cmd(s_MemoServ, u, MEMOSERV, cmd); - } - return MOD_CONT; + char *cmd = strtok(NULL, ""); + + if (!cmd) { + notice_help(s_MemoServ, u, MEMO_HELP_HEADER); + moduleDisplayHelp(3, u); + notice_help(s_MemoServ, u, MEMO_HELP_FOOTER, s_ChanServ); + } else { + mod_help_cmd(s_MemoServ, u, MEMOSERV, cmd); + } + return MOD_CONT; } MODULE_INIT("ms_help", MSHelp) diff --git a/src/core/ms_info.c b/src/core/ms_info.c index 74985cb2e..501730416 100644 --- a/src/core/ms_info.c +++ b/src/core/ms_info.c @@ -42,7 +42,7 @@ class MSInfo : public Module **/ void myMemoServHelp(User * u) { - notice_lang(s_MemoServ, u, MEMO_HELP_CMD_INFO); + notice_lang(s_MemoServ, u, MEMO_HELP_CMD_INFO); } /** @@ -52,169 +52,169 @@ void myMemoServHelp(User * u) **/ int do_info(User * u) { - MemoInfo *mi; - NickAlias *na = NULL; - ChannelInfo *ci = NULL; - char *name = strtok(NULL, " "); - int is_servadmin = is_services_admin(u); - int hardmax = 0; - - if (is_servadmin && name && *name != '#') { - na = findnick(name); - if (!na) { - notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, name); - return MOD_CONT; - } else if (na->status & NS_VERBOTEN) { - notice_lang(s_MemoServ, u, NICK_X_FORBIDDEN, name); - return MOD_CONT; - } - mi = &na->nc->memos; - hardmax = na->nc->flags & NI_MEMO_HARDMAX ? 1 : 0; - } else if (name && *name == '#') { - ci = cs_findchan(name); - if (!ci) { - notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, name); - return MOD_CONT; - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_MemoServ, u, CHAN_X_FORBIDDEN, name); - return MOD_CONT; - } else if (!check_access(u, ci, CA_MEMO)) { - notice_lang(s_MemoServ, u, ACCESS_DENIED); - return MOD_CONT; - } - mi = &ci->memos; - hardmax = ci->flags & CI_MEMO_HARDMAX ? 1 : 0; - } else if (name) { /* It's not a chan and we aren't services admin */ - notice_lang(s_MemoServ, u, ACCESS_DENIED); - return MOD_CONT; - } else { /* !name */ - if (!nick_identified(u)) { - notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); - return MOD_CONT; - } - mi = &u->na->nc->memos; - hardmax = u->na->nc->flags & NI_MEMO_HARDMAX ? 1 : 0; - } - - if (name && (ci || na->nc != u->na->nc)) { - - if (!mi->memocount) { - notice_lang(s_MemoServ, u, MEMO_INFO_X_NO_MEMOS, name); - } else if (mi->memocount == 1) { - if (mi->memos[0].flags & MF_UNREAD) - notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMO_UNREAD, name); - else - notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMO, name); - } else { - int count = 0, i; - for (i = 0; i < mi->memocount; i++) { - if (mi->memos[i].flags & MF_UNREAD) - count++; - } - if (count == mi->memocount) - notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMOS_ALL_UNREAD, - name, count); - else if (count == 0) - notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMOS, name, - mi->memocount); - else if (count == 1) - notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMOS_ONE_UNREAD, - name, mi->memocount); - else - notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMOS_SOME_UNREAD, - name, mi->memocount, count); - } - if (mi->memomax == 0) { - if (hardmax) - notice_lang(s_MemoServ, u, MEMO_INFO_X_HARD_LIMIT, name, - mi->memomax); - else - notice_lang(s_MemoServ, u, MEMO_INFO_X_LIMIT, name, - mi->memomax); - } else if (mi->memomax > 0) { - if (hardmax) - notice_lang(s_MemoServ, u, MEMO_INFO_X_HARD_LIMIT, name, - mi->memomax); - else - notice_lang(s_MemoServ, u, MEMO_INFO_X_LIMIT, name, - mi->memomax); - } else { - notice_lang(s_MemoServ, u, MEMO_INFO_X_NO_LIMIT, name); - } - - /* I ripped this code out of ircservices 4.4.5, since I didn't want - to rewrite the whole thing (it pisses me off). */ - if (na) { - if ((na->nc->flags & NI_MEMO_RECEIVE) - && (na->nc->flags & NI_MEMO_SIGNON)) { - notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_ON, name); - } else if (na->nc->flags & NI_MEMO_RECEIVE) { - notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_RECEIVE, - name); - } else if (na->nc->flags & NI_MEMO_SIGNON) { - notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_SIGNON, - name); - } else { - notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_OFF, name); - } - } - - } else { /* !name || (!ci || na->nc == u->na->nc) */ - - if (!mi->memocount) { - notice_lang(s_MemoServ, u, MEMO_INFO_NO_MEMOS); - } else if (mi->memocount == 1) { - if (mi->memos[0].flags & MF_UNREAD) - notice_lang(s_MemoServ, u, MEMO_INFO_MEMO_UNREAD); - else - notice_lang(s_MemoServ, u, MEMO_INFO_MEMO); - } else { - int count = 0, i; - for (i = 0; i < mi->memocount; i++) { - if (mi->memos[i].flags & MF_UNREAD) - count++; - } - if (count == mi->memocount) - notice_lang(s_MemoServ, u, MEMO_INFO_MEMOS_ALL_UNREAD, - count); - else if (count == 0) - notice_lang(s_MemoServ, u, MEMO_INFO_MEMOS, mi->memocount); - else if (count == 1) - notice_lang(s_MemoServ, u, MEMO_INFO_MEMOS_ONE_UNREAD, - mi->memocount); - else - notice_lang(s_MemoServ, u, MEMO_INFO_MEMOS_SOME_UNREAD, - mi->memocount, count); - } - - if (mi->memomax == 0) { - if (!is_servadmin && hardmax) - notice_lang(s_MemoServ, u, MEMO_INFO_HARD_LIMIT_ZERO); - else - notice_lang(s_MemoServ, u, MEMO_INFO_LIMIT_ZERO); - } else if (mi->memomax > 0) { - if (!is_servadmin && hardmax) - notice_lang(s_MemoServ, u, MEMO_INFO_HARD_LIMIT, - mi->memomax); - else - notice_lang(s_MemoServ, u, MEMO_INFO_LIMIT, mi->memomax); - } else { - notice_lang(s_MemoServ, u, MEMO_INFO_NO_LIMIT); - } - - /* Ripped too. But differently because of a seg fault (loughs) */ - if ((u->na->nc->flags & NI_MEMO_RECEIVE) - && (u->na->nc->flags & NI_MEMO_SIGNON)) { - notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_ON); - } else if (u->na->nc->flags & NI_MEMO_RECEIVE) { - notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_RECEIVE); - } else if (u->na->nc->flags & NI_MEMO_SIGNON) { - notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_SIGNON); - } else { - notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_OFF); - } - } - return MOD_CONT; /* if (name && (ci || na->nc != u->na->nc)) */ + MemoInfo *mi; + NickAlias *na = NULL; + ChannelInfo *ci = NULL; + char *name = strtok(NULL, " "); + int is_servadmin = is_services_admin(u); + int hardmax = 0; + + if (is_servadmin && name && *name != '#') { + na = findnick(name); + if (!na) { + notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, name); + return MOD_CONT; + } else if (na->status & NS_VERBOTEN) { + notice_lang(s_MemoServ, u, NICK_X_FORBIDDEN, name); + return MOD_CONT; + } + mi = &na->nc->memos; + hardmax = na->nc->flags & NI_MEMO_HARDMAX ? 1 : 0; + } else if (name && *name == '#') { + ci = cs_findchan(name); + if (!ci) { + notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, name); + return MOD_CONT; + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_MemoServ, u, CHAN_X_FORBIDDEN, name); + return MOD_CONT; + } else if (!check_access(u, ci, CA_MEMO)) { + notice_lang(s_MemoServ, u, ACCESS_DENIED); + return MOD_CONT; + } + mi = &ci->memos; + hardmax = ci->flags & CI_MEMO_HARDMAX ? 1 : 0; + } else if (name) { /* It's not a chan and we aren't services admin */ + notice_lang(s_MemoServ, u, ACCESS_DENIED); + return MOD_CONT; + } else { /* !name */ + if (!nick_identified(u)) { + notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); + return MOD_CONT; + } + mi = &u->na->nc->memos; + hardmax = u->na->nc->flags & NI_MEMO_HARDMAX ? 1 : 0; + } + + if (name && (ci || na->nc != u->na->nc)) { + + if (!mi->memocount) { + notice_lang(s_MemoServ, u, MEMO_INFO_X_NO_MEMOS, name); + } else if (mi->memocount == 1) { + if (mi->memos[0].flags & MF_UNREAD) + notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMO_UNREAD, name); + else + notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMO, name); + } else { + int count = 0, i; + for (i = 0; i < mi->memocount; i++) { + if (mi->memos[i].flags & MF_UNREAD) + count++; + } + if (count == mi->memocount) + notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMOS_ALL_UNREAD, + name, count); + else if (count == 0) + notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMOS, name, + mi->memocount); + else if (count == 1) + notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMOS_ONE_UNREAD, + name, mi->memocount); + else + notice_lang(s_MemoServ, u, MEMO_INFO_X_MEMOS_SOME_UNREAD, + name, mi->memocount, count); + } + if (mi->memomax == 0) { + if (hardmax) + notice_lang(s_MemoServ, u, MEMO_INFO_X_HARD_LIMIT, name, + mi->memomax); + else + notice_lang(s_MemoServ, u, MEMO_INFO_X_LIMIT, name, + mi->memomax); + } else if (mi->memomax > 0) { + if (hardmax) + notice_lang(s_MemoServ, u, MEMO_INFO_X_HARD_LIMIT, name, + mi->memomax); + else + notice_lang(s_MemoServ, u, MEMO_INFO_X_LIMIT, name, + mi->memomax); + } else { + notice_lang(s_MemoServ, u, MEMO_INFO_X_NO_LIMIT, name); + } + + /* I ripped this code out of ircservices 4.4.5, since I didn't want + to rewrite the whole thing (it pisses me off). */ + if (na) { + if ((na->nc->flags & NI_MEMO_RECEIVE) + && (na->nc->flags & NI_MEMO_SIGNON)) { + notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_ON, name); + } else if (na->nc->flags & NI_MEMO_RECEIVE) { + notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_RECEIVE, + name); + } else if (na->nc->flags & NI_MEMO_SIGNON) { + notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_SIGNON, + name); + } else { + notice_lang(s_MemoServ, u, MEMO_INFO_X_NOTIFY_OFF, name); + } + } + + } else { /* !name || (!ci || na->nc == u->na->nc) */ + + if (!mi->memocount) { + notice_lang(s_MemoServ, u, MEMO_INFO_NO_MEMOS); + } else if (mi->memocount == 1) { + if (mi->memos[0].flags & MF_UNREAD) + notice_lang(s_MemoServ, u, MEMO_INFO_MEMO_UNREAD); + else + notice_lang(s_MemoServ, u, MEMO_INFO_MEMO); + } else { + int count = 0, i; + for (i = 0; i < mi->memocount; i++) { + if (mi->memos[i].flags & MF_UNREAD) + count++; + } + if (count == mi->memocount) + notice_lang(s_MemoServ, u, MEMO_INFO_MEMOS_ALL_UNREAD, + count); + else if (count == 0) + notice_lang(s_MemoServ, u, MEMO_INFO_MEMOS, mi->memocount); + else if (count == 1) + notice_lang(s_MemoServ, u, MEMO_INFO_MEMOS_ONE_UNREAD, + mi->memocount); + else + notice_lang(s_MemoServ, u, MEMO_INFO_MEMOS_SOME_UNREAD, + mi->memocount, count); + } + + if (mi->memomax == 0) { + if (!is_servadmin && hardmax) + notice_lang(s_MemoServ, u, MEMO_INFO_HARD_LIMIT_ZERO); + else + notice_lang(s_MemoServ, u, MEMO_INFO_LIMIT_ZERO); + } else if (mi->memomax > 0) { + if (!is_servadmin && hardmax) + notice_lang(s_MemoServ, u, MEMO_INFO_HARD_LIMIT, + mi->memomax); + else + notice_lang(s_MemoServ, u, MEMO_INFO_LIMIT, mi->memomax); + } else { + notice_lang(s_MemoServ, u, MEMO_INFO_NO_LIMIT); + } + + /* Ripped too. But differently because of a seg fault (loughs) */ + if ((u->na->nc->flags & NI_MEMO_RECEIVE) + && (u->na->nc->flags & NI_MEMO_SIGNON)) { + notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_ON); + } else if (u->na->nc->flags & NI_MEMO_RECEIVE) { + notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_RECEIVE); + } else if (u->na->nc->flags & NI_MEMO_SIGNON) { + notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_SIGNON); + } else { + notice_lang(s_MemoServ, u, MEMO_INFO_NOTIFY_OFF); + } + } + return MOD_CONT; /* if (name && (ci || na->nc != u->na->nc)) */ } MODULE_INIT("ms_info", MSInfo) diff --git a/src/core/ms_list.c b/src/core/ms_list.c index 4ea74fbfe..148433ff0 100644 --- a/src/core/ms_list.c +++ b/src/core/ms_list.c @@ -44,7 +44,7 @@ class MSList : public Module **/ void myMemoServHelp(User * u) { - notice_lang(s_MemoServ, u, MEMO_HELP_CMD_LIST); + notice_lang(s_MemoServ, u, MEMO_HELP_CMD_LIST); } /** @@ -54,68 +54,68 @@ void myMemoServHelp(User * u) **/ int do_list(User * u) { - char *param = strtok(NULL, " "), *chan = NULL; - ChannelInfo *ci; - MemoInfo *mi; - Memo *m; - int i; + char *param = strtok(NULL, " "), *chan = NULL; + ChannelInfo *ci; + MemoInfo *mi; + Memo *m; + int i; - if (param && *param == '#') { - chan = param; - param = strtok(NULL, " "); - if (!(ci = cs_findchan(chan))) { - notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, chan); - return MOD_CONT; - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_MemoServ, u, CHAN_X_FORBIDDEN, chan); - return MOD_CONT; - } else if (!check_access(u, ci, CA_MEMO)) { - notice_lang(s_MemoServ, u, ACCESS_DENIED); - return MOD_CONT; - } - mi = &ci->memos; - } else { - if (!nick_identified(u)) { - notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); - return MOD_CONT; - } - mi = &u->na->nc->memos; - } - if (param && !isdigit(*param) && stricmp(param, "NEW") != 0) { - syntax_error(s_MemoServ, u, "LIST", MEMO_LIST_SYNTAX); - } else if (mi->memocount == 0) { - if (chan) - notice_lang(s_MemoServ, u, MEMO_X_HAS_NO_MEMOS, chan); - else - notice_lang(s_MemoServ, u, MEMO_HAVE_NO_MEMOS); - } else { - int sent_header = 0; - if (param && isdigit(*param)) { - process_numlist(param, NULL, list_memo_callback, u, - mi, &sent_header, chan); - } else { - if (param) { - for (i = 0, m = mi->memos; i < mi->memocount; i++, m++) { - if (m->flags & MF_UNREAD) - break; - } - if (i == mi->memocount) { - if (chan) - notice_lang(s_MemoServ, u, MEMO_X_HAS_NO_NEW_MEMOS, - chan); - else - notice_lang(s_MemoServ, u, MEMO_HAVE_NO_NEW_MEMOS); - return MOD_CONT; - } - } - for (i = 0, m = mi->memos; i < mi->memocount; i++, m++) { - if (param && !(m->flags & MF_UNREAD)) - continue; - list_memo(u, i, mi, &sent_header, param != NULL, chan); - } - } - } - return MOD_CONT; + if (param && *param == '#') { + chan = param; + param = strtok(NULL, " "); + if (!(ci = cs_findchan(chan))) { + notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, chan); + return MOD_CONT; + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_MemoServ, u, CHAN_X_FORBIDDEN, chan); + return MOD_CONT; + } else if (!check_access(u, ci, CA_MEMO)) { + notice_lang(s_MemoServ, u, ACCESS_DENIED); + return MOD_CONT; + } + mi = &ci->memos; + } else { + if (!nick_identified(u)) { + notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); + return MOD_CONT; + } + mi = &u->na->nc->memos; + } + if (param && !isdigit(*param) && stricmp(param, "NEW") != 0) { + syntax_error(s_MemoServ, u, "LIST", MEMO_LIST_SYNTAX); + } else if (mi->memocount == 0) { + if (chan) + notice_lang(s_MemoServ, u, MEMO_X_HAS_NO_MEMOS, chan); + else + notice_lang(s_MemoServ, u, MEMO_HAVE_NO_MEMOS); + } else { + int sent_header = 0; + if (param && isdigit(*param)) { + process_numlist(param, NULL, list_memo_callback, u, + mi, &sent_header, chan); + } else { + if (param) { + for (i = 0, m = mi->memos; i < mi->memocount; i++, m++) { + if (m->flags & MF_UNREAD) + break; + } + if (i == mi->memocount) { + if (chan) + notice_lang(s_MemoServ, u, MEMO_X_HAS_NO_NEW_MEMOS, + chan); + else + notice_lang(s_MemoServ, u, MEMO_HAVE_NO_NEW_MEMOS); + return MOD_CONT; + } + } + for (i = 0, m = mi->memos; i < mi->memocount; i++, m++) { + if (param && !(m->flags & MF_UNREAD)) + continue; + list_memo(u, i, mi, &sent_header, param != NULL, chan); + } + } + } + return MOD_CONT; } /** @@ -127,17 +127,17 @@ int do_list(User * u) */ int list_memo_callback(User * u, int num, va_list args) { - MemoInfo *mi = va_arg(args, MemoInfo *); - int *sent_header = va_arg(args, int *); - const char *chan = va_arg(args, const char *); - int i; + MemoInfo *mi = va_arg(args, MemoInfo *); + int *sent_header = va_arg(args, int *); + const char *chan = va_arg(args, const char *); + int i; - for (i = 0; i < mi->memocount; i++) { - if (mi->memos[i].number == num) - break; - } - /* Range checking done by list_memo() */ - return list_memo(u, i, mi, sent_header, 0, chan); + for (i = 0; i < mi->memocount; i++) { + if (mi->memos[i].number == num) + break; + } + /* Range checking done by list_memo() */ + return list_memo(u, i, mi, sent_header, 0, chan); } /** @@ -152,34 +152,34 @@ int list_memo_callback(User * u, int num, va_list args) */ int list_memo(User * u, int index, MemoInfo * mi, int *sent_header, int newi, const char *chan) { - Memo *m; - char timebuf[64]; - struct tm tm; + Memo *m; + char timebuf[64]; + struct tm tm; - if (index < 0 || index >= mi->memocount) - return 0; - if (!*sent_header) { - if (chan) { - notice_lang(s_MemoServ, u, - newi ? MEMO_LIST_CHAN_NEW_MEMOS : - MEMO_LIST_CHAN_MEMOS, chan, s_MemoServ, chan); - } else { - notice_lang(s_MemoServ, u, - newi ? MEMO_LIST_NEW_MEMOS : MEMO_LIST_MEMOS, - u->nick, s_MemoServ); - } - notice_lang(s_MemoServ, u, MEMO_LIST_HEADER); - *sent_header = 1; - } - m = &mi->memos[index]; - tm = *localtime(&m->time); - strftime_lang(timebuf, sizeof(timebuf), - u, STRFTIME_DATE_TIME_FORMAT, &tm); - timebuf[sizeof(timebuf) - 1] = 0; /* just in case */ - notice_lang(s_MemoServ, u, MEMO_LIST_FORMAT, - (m->flags & MF_UNREAD) ? '*' : ' ', - m->number, m->sender, timebuf); - return 1; + if (index < 0 || index >= mi->memocount) + return 0; + if (!*sent_header) { + if (chan) { + notice_lang(s_MemoServ, u, + newi ? MEMO_LIST_CHAN_NEW_MEMOS : + MEMO_LIST_CHAN_MEMOS, chan, s_MemoServ, chan); + } else { + notice_lang(s_MemoServ, u, + newi ? MEMO_LIST_NEW_MEMOS : MEMO_LIST_MEMOS, + u->nick, s_MemoServ); + } + notice_lang(s_MemoServ, u, MEMO_LIST_HEADER); + *sent_header = 1; + } + m = &mi->memos[index]; + tm = *localtime(&m->time); + strftime_lang(timebuf, sizeof(timebuf), + u, STRFTIME_DATE_TIME_FORMAT, &tm); + timebuf[sizeof(timebuf) - 1] = 0; /* just in case */ + notice_lang(s_MemoServ, u, MEMO_LIST_FORMAT, + (m->flags & MF_UNREAD) ? '*' : ' ', + m->number, m->sender, timebuf); + return 1; } MODULE_INIT("ms_list", MSList) diff --git a/src/core/ms_read.c b/src/core/ms_read.c index 3877b7458..07f293156 100644 --- a/src/core/ms_read.c +++ b/src/core/ms_read.c @@ -46,7 +46,7 @@ class MSRead : public Module **/ void myMemoServHelp(User * u) { - notice_lang(s_MemoServ, u, MEMO_HELP_CMD_READ); + notice_lang(s_MemoServ, u, MEMO_HELP_CMD_READ); } /** @@ -56,78 +56,78 @@ void myMemoServHelp(User * u) **/ int do_read(User * u) { - MemoInfo *mi; - ChannelInfo *ci; - char *numstr = strtok(NULL, " "), *chan = NULL; - int num, count; - - if (numstr && *numstr == '#') { - chan = numstr; - numstr = strtok(NULL, " "); - if (!(ci = cs_findchan(chan))) { - notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, chan); - return MOD_CONT; - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_MemoServ, u, CHAN_X_FORBIDDEN, chan); - return MOD_CONT; - } else if (!check_access(u, ci, CA_MEMO)) { - notice_lang(s_MemoServ, u, ACCESS_DENIED); - return MOD_CONT; - } - mi = &ci->memos; - } else { - if (!nick_identified(u)) { - notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); - return MOD_CONT; - } - mi = &u->na->nc->memos; - } - num = numstr ? atoi(numstr) : -1; - if (!numstr - || (stricmp(numstr, "LAST") != 0 && stricmp(numstr, "NEW") != 0 - && num <= 0)) { - syntax_error(s_MemoServ, u, "READ", MEMO_READ_SYNTAX); - - } else if (mi->memocount == 0) { - if (chan) - notice_lang(s_MemoServ, u, MEMO_X_HAS_NO_MEMOS, chan); - else - notice_lang(s_MemoServ, u, MEMO_HAVE_NO_MEMOS); - - } else { - int i; - - if (stricmp(numstr, "NEW") == 0) { - int readcount = 0; - for (i = 0; i < mi->memocount; i++) { - if (mi->memos[i].flags & MF_UNREAD) { - read_memo(u, i, mi, chan); - readcount++; - } - } - if (!readcount) { - if (chan) - notice_lang(s_MemoServ, u, MEMO_X_HAS_NO_NEW_MEMOS, - chan); - else - notice_lang(s_MemoServ, u, MEMO_HAVE_NO_NEW_MEMOS); - } - } else if (stricmp(numstr, "LAST") == 0) { - for (i = 0; i < mi->memocount - 1; i++); - read_memo(u, i, mi, chan); - } else { /* number[s] */ - if (!process_numlist(numstr, &count, read_memo_callback, u, - mi, chan)) { - if (count == 1) - notice_lang(s_MemoServ, u, MEMO_DOES_NOT_EXIST, num); - else - notice_lang(s_MemoServ, u, MEMO_LIST_NOT_FOUND, - numstr); - } - } - - } - return MOD_CONT; + MemoInfo *mi; + ChannelInfo *ci; + char *numstr = strtok(NULL, " "), *chan = NULL; + int num, count; + + if (numstr && *numstr == '#') { + chan = numstr; + numstr = strtok(NULL, " "); + if (!(ci = cs_findchan(chan))) { + notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, chan); + return MOD_CONT; + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_MemoServ, u, CHAN_X_FORBIDDEN, chan); + return MOD_CONT; + } else if (!check_access(u, ci, CA_MEMO)) { + notice_lang(s_MemoServ, u, ACCESS_DENIED); + return MOD_CONT; + } + mi = &ci->memos; + } else { + if (!nick_identified(u)) { + notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); + return MOD_CONT; + } + mi = &u->na->nc->memos; + } + num = numstr ? atoi(numstr) : -1; + if (!numstr + || (stricmp(numstr, "LAST") != 0 && stricmp(numstr, "NEW") != 0 + && num <= 0)) { + syntax_error(s_MemoServ, u, "READ", MEMO_READ_SYNTAX); + + } else if (mi->memocount == 0) { + if (chan) + notice_lang(s_MemoServ, u, MEMO_X_HAS_NO_MEMOS, chan); + else + notice_lang(s_MemoServ, u, MEMO_HAVE_NO_MEMOS); + + } else { + int i; + + if (stricmp(numstr, "NEW") == 0) { + int readcount = 0; + for (i = 0; i < mi->memocount; i++) { + if (mi->memos[i].flags & MF_UNREAD) { + read_memo(u, i, mi, chan); + readcount++; + } + } + if (!readcount) { + if (chan) + notice_lang(s_MemoServ, u, MEMO_X_HAS_NO_NEW_MEMOS, + chan); + else + notice_lang(s_MemoServ, u, MEMO_HAVE_NO_NEW_MEMOS); + } + } else if (stricmp(numstr, "LAST") == 0) { + for (i = 0; i < mi->memocount - 1; i++); + read_memo(u, i, mi, chan); + } else { /* number[s] */ + if (!process_numlist(numstr, &count, read_memo_callback, u, + mi, chan)) { + if (count == 1) + notice_lang(s_MemoServ, u, MEMO_DOES_NOT_EXIST, num); + else + notice_lang(s_MemoServ, u, MEMO_LIST_NOT_FOUND, + numstr); + } + } + + } + return MOD_CONT; } /** @@ -139,16 +139,16 @@ int do_read(User * u) */ int read_memo_callback(User * u, int num, va_list args) { - MemoInfo *mi = va_arg(args, MemoInfo *); - const char *chan = va_arg(args, const char *); - int i; - - for (i = 0; i < mi->memocount; i++) { - if (mi->memos[i].number == num) - break; - } - /* Range check done in read_memo */ - return read_memo(u, i, mi, chan); + MemoInfo *mi = va_arg(args, MemoInfo *); + const char *chan = va_arg(args, const char *); + int i; + + for (i = 0; i < mi->memocount; i++) { + if (mi->memos[i].number == num) + break; + } + /* Range check done in read_memo */ + return read_memo(u, i, mi, chan); } /** @@ -161,32 +161,32 @@ int read_memo_callback(User * u, int num, va_list args) */ int read_memo(User * u, int index, MemoInfo * mi, const char *chan) { - Memo *m; - char timebuf[64]; - struct tm tm; - - if (index < 0 || index >= mi->memocount) - return 0; - m = &mi->memos[index]; - tm = *localtime(&m->time); - strftime_lang(timebuf, sizeof(timebuf), - u, STRFTIME_DATE_TIME_FORMAT, &tm); - timebuf[sizeof(timebuf) - 1] = 0; - if (chan) - notice_lang(s_MemoServ, u, MEMO_CHAN_HEADER, m->number, - m->sender, timebuf, s_MemoServ, chan, m->number); - else - notice_lang(s_MemoServ, u, MEMO_HEADER, m->number, - m->sender, timebuf, s_MemoServ, m->number); - notice_lang(s_MemoServ, u, MEMO_TEXT, m->text); - m->flags &= ~MF_UNREAD; - - /* Check if a receipt notification was requested */ - if (m->flags & MF_RECEIPT) { - rsend_notify(u, m, chan); - } - - return 1; + Memo *m; + char timebuf[64]; + struct tm tm; + + if (index < 0 || index >= mi->memocount) + return 0; + m = &mi->memos[index]; + tm = *localtime(&m->time); + strftime_lang(timebuf, sizeof(timebuf), + u, STRFTIME_DATE_TIME_FORMAT, &tm); + timebuf[sizeof(timebuf) - 1] = 0; + if (chan) + notice_lang(s_MemoServ, u, MEMO_CHAN_HEADER, m->number, + m->sender, timebuf, s_MemoServ, chan, m->number); + else + notice_lang(s_MemoServ, u, MEMO_HEADER, m->number, + m->sender, timebuf, s_MemoServ, m->number); + notice_lang(s_MemoServ, u, MEMO_TEXT, m->text); + m->flags &= ~MF_UNREAD; + + /* Check if a receipt notification was requested */ + if (m->flags & MF_RECEIPT) { + rsend_notify(u, m, chan); + } + + return 1; } MODULE_INIT("ms_read", MSRead) diff --git a/src/core/ms_rsend.c b/src/core/ms_rsend.c index 2ce4f3b7a..2b2f3f985 100644 --- a/src/core/ms_rsend.c +++ b/src/core/ms_rsend.c @@ -51,10 +51,10 @@ void AnopeFini(void) **/ void myMemoServHelp(User * u) { - if (((MSMemoReceipt == 1) && (is_services_oper(u))) - || (MSMemoReceipt == 2)) { - notice_lang(s_MemoServ, u, MEMO_HELP_CMD_RSEND); - } + if (((MSMemoReceipt == 1) && (is_services_oper(u))) + || (MSMemoReceipt == 2)) { + notice_lang(s_MemoServ, u, MEMO_HELP_CMD_RSEND); + } } /** @@ -64,52 +64,52 @@ void myMemoServHelp(User * u) **/ int do_rsend(User * u) { - char *name = strtok(NULL, " "); - char *text = strtok(NULL, ""); - NickAlias *na = NULL; - int z = 3; - - - - /* check if the variables are here */ - if (!name || !text) { - notice_lang(s_MemoServ, u, MEMO_RSEND_SYNTAX); - return MOD_CONT; - } - - /* prevent user from rsend to themselves */ - if ((na = findnick(name))) { - if (u->na) { - if (stricmp(na->nc->display, u->na->nc->display) == 0) { - notice_lang(s_MemoServ, u, MEMO_NO_RSEND_SELF); - return MOD_CONT; - } - } else { - notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, name); - return MOD_CONT; - } - } - - if (MSMemoReceipt == 1) { - /* Services opers and above can use rsend */ - if (is_services_oper(u)) { - memo_send(u, name, text, z); - } else { - notice_lang(s_MemoServ, u, ACCESS_DENIED); - } - } else if (MSMemoReceipt == 2) { - /* Everybody can use rsend */ - memo_send(u, name, text, z); - } else { - /* rsend has been disabled */ - if (debug) { - alog("debug: MSMemoReceipt is set misconfigured to %d", - MSMemoReceipt); - } - notice_lang(s_MemoServ, u, MEMO_RSEND_DISABLED); - } - - return MOD_CONT; + char *name = strtok(NULL, " "); + char *text = strtok(NULL, ""); + NickAlias *na = NULL; + int z = 3; + + + + /* check if the variables are here */ + if (!name || !text) { + notice_lang(s_MemoServ, u, MEMO_RSEND_SYNTAX); + return MOD_CONT; + } + + /* prevent user from rsend to themselves */ + if ((na = findnick(name))) { + if (u->na) { + if (stricmp(na->nc->display, u->na->nc->display) == 0) { + notice_lang(s_MemoServ, u, MEMO_NO_RSEND_SELF); + return MOD_CONT; + } + } else { + notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, name); + return MOD_CONT; + } + } + + if (MSMemoReceipt == 1) { + /* Services opers and above can use rsend */ + if (is_services_oper(u)) { + memo_send(u, name, text, z); + } else { + notice_lang(s_MemoServ, u, ACCESS_DENIED); + } + } else if (MSMemoReceipt == 2) { + /* Everybody can use rsend */ + memo_send(u, name, text, z); + } else { + /* rsend has been disabled */ + if (debug) { + alog("debug: MSMemoReceipt is set misconfigured to %d", + MSMemoReceipt); + } + notice_lang(s_MemoServ, u, MEMO_RSEND_DISABLED); + } + + return MOD_CONT; } MODULE_INIT("ms_rsend", MSRSend) diff --git a/src/core/ms_send.c b/src/core/ms_send.c index 0189603b3..52d386348 100644 --- a/src/core/ms_send.c +++ b/src/core/ms_send.c @@ -42,7 +42,7 @@ class MSSend : public Module **/ void myMemoServHelp(User * u) { - notice_lang(s_MemoServ, u, MEMO_HELP_CMD_SEND); + notice_lang(s_MemoServ, u, MEMO_HELP_CMD_SEND); } /** @@ -52,11 +52,11 @@ void myMemoServHelp(User * u) **/ int do_send(User * u) { - char *name = strtok(NULL, " "); - char *text = strtok(NULL, ""); - int z = 0; - memo_send(u, name, text, z); - return MOD_CONT; + char *name = strtok(NULL, " "); + char *text = strtok(NULL, ""); + int z = 0; + memo_send(u, name, text, z); + return MOD_CONT; } MODULE_INIT("ms_send", MSSend) diff --git a/src/core/ms_sendall.c b/src/core/ms_sendall.c index 9f9d98e37..7668f5009 100644 --- a/src/core/ms_sendall.c +++ b/src/core/ms_sendall.c @@ -42,9 +42,9 @@ class MSSendAll : public Module **/ void myMemoServHelp(User * u) { - if (is_services_admin(u)) { - notice_lang(s_MemoServ, u, MEMO_HELP_CMD_SENDALL); - } + if (is_services_admin(u)) { + notice_lang(s_MemoServ, u, MEMO_HELP_CMD_SENDALL); + } } /** @@ -54,31 +54,31 @@ void myMemoServHelp(User * u) **/ int do_sendall(User * u) { - int i, z = 1; - NickCore *nc; - char *text = strtok(NULL, ""); + int i, z = 1; + NickCore *nc; + char *text = strtok(NULL, ""); - if (readonly) { - notice_lang(s_MemoServ, u, MEMO_SEND_DISABLED); - return MOD_CONT; - } else if (checkDefCon(DEFCON_NO_NEW_MEMOS)) { - notice_lang(s_MemoServ, u, OPER_DEFCON_DENIED); - return MOD_CONT; - } else if (!text) { - syntax_error(s_MemoServ, u, "SENDALL", MEMO_SEND_SYNTAX); - return MOD_CONT; - } + if (readonly) { + notice_lang(s_MemoServ, u, MEMO_SEND_DISABLED); + return MOD_CONT; + } else if (checkDefCon(DEFCON_NO_NEW_MEMOS)) { + notice_lang(s_MemoServ, u, OPER_DEFCON_DENIED); + return MOD_CONT; + } else if (!text) { + syntax_error(s_MemoServ, u, "SENDALL", MEMO_SEND_SYNTAX); + return MOD_CONT; + } - for (i = 0; i < 1024; i++) { - for (nc = nclists[i]; nc; nc = nc->next) { - if (stricmp(u->nick, nc->display) != 0) - memo_send(u, nc->display, text, z); - } /* /nc */ - } /* /i */ + for (i = 0; i < 1024; i++) { + for (nc = nclists[i]; nc; nc = nc->next) { + if (stricmp(u->nick, nc->display) != 0) + memo_send(u, nc->display, text, z); + } /* /nc */ + } /* /i */ - notice_lang(s_MemoServ, u, MEMO_MASS_SENT); - return MOD_CONT; + notice_lang(s_MemoServ, u, MEMO_MASS_SENT); + return MOD_CONT; } MODULE_INIT("ms_sendall", MSSendAll) diff --git a/src/core/ms_set.c b/src/core/ms_set.c index d9cbaf717..a4aebd3e0 100644 --- a/src/core/ms_set.c +++ b/src/core/ms_set.c @@ -53,7 +53,7 @@ class MSSet : public Module **/ void myMemoServHelp(User * u) { - notice_lang(s_MemoServ, u, MEMO_HELP_CMD_SET); + notice_lang(s_MemoServ, u, MEMO_HELP_CMD_SET); } /** @@ -63,28 +63,28 @@ void myMemoServHelp(User * u) **/ int do_set(User * u) { - char *cmd = strtok(NULL, " "); - char *param = strtok(NULL, ""); - MemoInfo *mi = &u->na->nc->memos; - - if (readonly) { - notice_lang(s_MemoServ, u, MEMO_SET_DISABLED); - return MOD_CONT; - } - if (!param) { - syntax_error(s_MemoServ, u, "SET", MEMO_SET_SYNTAX); - } else if (!nick_identified(u)) { - notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); - return MOD_CONT; - } else if (stricmp(cmd, "NOTIFY") == 0) { - do_set_notify(u, mi, param); - } else if (stricmp(cmd, "LIMIT") == 0) { - do_set_limit(u, mi, param); - } else { - notice_lang(s_MemoServ, u, MEMO_SET_UNKNOWN_OPTION, cmd); - notice_lang(s_MemoServ, u, MORE_INFO, s_MemoServ, "SET"); - } - return MOD_CONT; + char *cmd = strtok(NULL, " "); + char *param = strtok(NULL, ""); + MemoInfo *mi = &u->na->nc->memos; + + if (readonly) { + notice_lang(s_MemoServ, u, MEMO_SET_DISABLED); + return MOD_CONT; + } + if (!param) { + syntax_error(s_MemoServ, u, "SET", MEMO_SET_SYNTAX); + } else if (!nick_identified(u)) { + notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); + return MOD_CONT; + } else if (stricmp(cmd, "NOTIFY") == 0) { + do_set_notify(u, mi, param); + } else if (stricmp(cmd, "LIMIT") == 0) { + do_set_limit(u, mi, param); + } else { + notice_lang(s_MemoServ, u, MEMO_SET_UNKNOWN_OPTION, cmd); + notice_lang(s_MemoServ, u, MORE_INFO, s_MemoServ, "SET"); + } + return MOD_CONT; } /** @@ -94,34 +94,34 @@ int do_set(User * u) **/ int do_set_notify(User * u, MemoInfo * mi, char *param) { - if (stricmp(param, "ON") == 0) { - u->na->nc->flags |= NI_MEMO_SIGNON | NI_MEMO_RECEIVE; - notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_ON, s_MemoServ); - } else if (stricmp(param, "LOGON") == 0) { - u->na->nc->flags |= NI_MEMO_SIGNON; - u->na->nc->flags &= ~NI_MEMO_RECEIVE; - notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_LOGON, s_MemoServ); - } else if (stricmp(param, "NEW") == 0) { - u->na->nc->flags &= ~NI_MEMO_SIGNON; - u->na->nc->flags |= NI_MEMO_RECEIVE; - notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_NEW, s_MemoServ); - } else if (stricmp(param, "MAIL") == 0) { - if (u->na->nc->email) { - u->na->nc->flags |= NI_MEMO_MAIL; - notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_MAIL); - } else { - notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_INVALIDMAIL); - } - } else if (stricmp(param, "NOMAIL") == 0) { - u->na->nc->flags &= ~NI_MEMO_MAIL; - notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_NOMAIL); - } else if (stricmp(param, "OFF") == 0) { - u->na->nc->flags &= ~(NI_MEMO_SIGNON | NI_MEMO_RECEIVE); - notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_OFF, s_MemoServ); - } else { - syntax_error(s_MemoServ, u, "SET NOTIFY", MEMO_SET_NOTIFY_SYNTAX); - } - return MOD_CONT; + if (stricmp(param, "ON") == 0) { + u->na->nc->flags |= NI_MEMO_SIGNON | NI_MEMO_RECEIVE; + notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_ON, s_MemoServ); + } else if (stricmp(param, "LOGON") == 0) { + u->na->nc->flags |= NI_MEMO_SIGNON; + u->na->nc->flags &= ~NI_MEMO_RECEIVE; + notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_LOGON, s_MemoServ); + } else if (stricmp(param, "NEW") == 0) { + u->na->nc->flags &= ~NI_MEMO_SIGNON; + u->na->nc->flags |= NI_MEMO_RECEIVE; + notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_NEW, s_MemoServ); + } else if (stricmp(param, "MAIL") == 0) { + if (u->na->nc->email) { + u->na->nc->flags |= NI_MEMO_MAIL; + notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_MAIL); + } else { + notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_INVALIDMAIL); + } + } else if (stricmp(param, "NOMAIL") == 0) { + u->na->nc->flags &= ~NI_MEMO_MAIL; + notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_NOMAIL); + } else if (stricmp(param, "OFF") == 0) { + u->na->nc->flags &= ~(NI_MEMO_SIGNON | NI_MEMO_RECEIVE); + notice_lang(s_MemoServ, u, MEMO_SET_NOTIFY_OFF, s_MemoServ); + } else { + syntax_error(s_MemoServ, u, "SET NOTIFY", MEMO_SET_NOTIFY_SYNTAX); + } + return MOD_CONT; } /** @@ -131,122 +131,122 @@ int do_set_notify(User * u, MemoInfo * mi, char *param) **/ int do_set_limit(User * u, MemoInfo * mi, char *param) { - char *p1 = strtok(param, " "); - char *p2 = strtok(NULL, " "); - char *p3 = strtok(NULL, " "); - char *user = NULL, *chan = NULL; - int32 limit; - NickAlias *na = u->na; - ChannelInfo *ci = NULL; - int is_servadmin = is_services_admin(u); - - if (p1 && *p1 == '#') { - chan = p1; - p1 = p2; - p2 = p3; - p3 = strtok(NULL, " "); - if (!(ci = cs_findchan(chan))) { - notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, chan); - return MOD_CONT; - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_MemoServ, u, CHAN_X_FORBIDDEN, chan); - return MOD_CONT; - } else if (!is_servadmin && !check_access(u, ci, CA_MEMO)) { - notice_lang(s_MemoServ, u, ACCESS_DENIED); - return MOD_CONT; - } - mi = &ci->memos; - } - if (is_servadmin) { - if (p2 && stricmp(p2, "HARD") != 0 && !chan) { - if (!(na = findnick(p1))) { - notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, p1); - return MOD_CONT; - } - user = p1; - mi = &na->nc->memos; - p1 = p2; - p2 = p3; - } else if (!p1) { - syntax_error(s_MemoServ, u, "SET LIMIT", - MEMO_SET_LIMIT_SERVADMIN_SYNTAX); - return MOD_CONT; - } - if ((!isdigit(*p1) && stricmp(p1, "NONE") != 0) || - (p2 && stricmp(p2, "HARD") != 0)) { - syntax_error(s_MemoServ, u, "SET LIMIT", - MEMO_SET_LIMIT_SERVADMIN_SYNTAX); - return MOD_CONT; - } - if (chan) { - if (p2) - ci->flags |= CI_MEMO_HARDMAX; - else - ci->flags &= ~CI_MEMO_HARDMAX; - } else { - if (p2) - na->nc->flags |= NI_MEMO_HARDMAX; - else - na->nc->flags &= ~NI_MEMO_HARDMAX; - } - limit = atoi(p1); - if (limit < 0 || limit > 32767) { - notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_OVERFLOW, 32767); - limit = 32767; - } - if (stricmp(p1, "NONE") == 0) - limit = -1; - } else { - if (!p1 || p2 || !isdigit(*p1)) { - syntax_error(s_MemoServ, u, "SET LIMIT", - MEMO_SET_LIMIT_SYNTAX); - return MOD_CONT; - } - if (chan && (ci->flags & CI_MEMO_HARDMAX)) { - notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_FORBIDDEN, chan); - return MOD_CONT; - } else if (!chan && (na->nc->flags & NI_MEMO_HARDMAX)) { - notice_lang(s_MemoServ, u, MEMO_SET_YOUR_LIMIT_FORBIDDEN); - return MOD_CONT; - } - limit = atoi(p1); - /* The first character is a digit, but we could still go negative - * from overflow... watch out! */ - if (limit < 0 || (MSMaxMemos > 0 && limit > MSMaxMemos)) { - if (chan) { - notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_TOO_HIGH, - chan, MSMaxMemos); - } else { - notice_lang(s_MemoServ, u, MEMO_SET_YOUR_LIMIT_TOO_HIGH, - MSMaxMemos); - } - return MOD_CONT; - } else if (limit > 32767) { - notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_OVERFLOW, 32767); - limit = 32767; - } - } - mi->memomax = limit; - if (limit > 0) { - if (!chan && na->nc == u->na->nc) - notice_lang(s_MemoServ, u, MEMO_SET_YOUR_LIMIT, limit); - else - notice_lang(s_MemoServ, u, MEMO_SET_LIMIT, - chan ? chan : user, limit); - } else if (limit == 0) { - if (!chan && na->nc == u->na->nc) - notice_lang(s_MemoServ, u, MEMO_SET_YOUR_LIMIT_ZERO); - else - notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_ZERO, - chan ? chan : user); - } else { - if (!chan && na->nc == u->na->nc) - notice_lang(s_MemoServ, u, MEMO_UNSET_YOUR_LIMIT); - else - notice_lang(s_MemoServ, u, MEMO_UNSET_LIMIT, - chan ? chan : user); - } - return MOD_CONT; + char *p1 = strtok(param, " "); + char *p2 = strtok(NULL, " "); + char *p3 = strtok(NULL, " "); + char *user = NULL, *chan = NULL; + int32 limit; + NickAlias *na = u->na; + ChannelInfo *ci = NULL; + int is_servadmin = is_services_admin(u); + + if (p1 && *p1 == '#') { + chan = p1; + p1 = p2; + p2 = p3; + p3 = strtok(NULL, " "); + if (!(ci = cs_findchan(chan))) { + notice_lang(s_MemoServ, u, CHAN_X_NOT_REGISTERED, chan); + return MOD_CONT; + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_MemoServ, u, CHAN_X_FORBIDDEN, chan); + return MOD_CONT; + } else if (!is_servadmin && !check_access(u, ci, CA_MEMO)) { + notice_lang(s_MemoServ, u, ACCESS_DENIED); + return MOD_CONT; + } + mi = &ci->memos; + } + if (is_servadmin) { + if (p2 && stricmp(p2, "HARD") != 0 && !chan) { + if (!(na = findnick(p1))) { + notice_lang(s_MemoServ, u, NICK_X_NOT_REGISTERED, p1); + return MOD_CONT; + } + user = p1; + mi = &na->nc->memos; + p1 = p2; + p2 = p3; + } else if (!p1) { + syntax_error(s_MemoServ, u, "SET LIMIT", + MEMO_SET_LIMIT_SERVADMIN_SYNTAX); + return MOD_CONT; + } + if ((!isdigit(*p1) && stricmp(p1, "NONE") != 0) || + (p2 && stricmp(p2, "HARD") != 0)) { + syntax_error(s_MemoServ, u, "SET LIMIT", + MEMO_SET_LIMIT_SERVADMIN_SYNTAX); + return MOD_CONT; + } + if (chan) { + if (p2) + ci->flags |= CI_MEMO_HARDMAX; + else + ci->flags &= ~CI_MEMO_HARDMAX; + } else { + if (p2) + na->nc->flags |= NI_MEMO_HARDMAX; + else + na->nc->flags &= ~NI_MEMO_HARDMAX; + } + limit = atoi(p1); + if (limit < 0 || limit > 32767) { + notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_OVERFLOW, 32767); + limit = 32767; + } + if (stricmp(p1, "NONE") == 0) + limit = -1; + } else { + if (!p1 || p2 || !isdigit(*p1)) { + syntax_error(s_MemoServ, u, "SET LIMIT", + MEMO_SET_LIMIT_SYNTAX); + return MOD_CONT; + } + if (chan && (ci->flags & CI_MEMO_HARDMAX)) { + notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_FORBIDDEN, chan); + return MOD_CONT; + } else if (!chan && (na->nc->flags & NI_MEMO_HARDMAX)) { + notice_lang(s_MemoServ, u, MEMO_SET_YOUR_LIMIT_FORBIDDEN); + return MOD_CONT; + } + limit = atoi(p1); + /* The first character is a digit, but we could still go negative + * from overflow... watch out! */ + if (limit < 0 || (MSMaxMemos > 0 && limit > MSMaxMemos)) { + if (chan) { + notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_TOO_HIGH, + chan, MSMaxMemos); + } else { + notice_lang(s_MemoServ, u, MEMO_SET_YOUR_LIMIT_TOO_HIGH, + MSMaxMemos); + } + return MOD_CONT; + } else if (limit > 32767) { + notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_OVERFLOW, 32767); + limit = 32767; + } + } + mi->memomax = limit; + if (limit > 0) { + if (!chan && na->nc == u->na->nc) + notice_lang(s_MemoServ, u, MEMO_SET_YOUR_LIMIT, limit); + else + notice_lang(s_MemoServ, u, MEMO_SET_LIMIT, + chan ? chan : user, limit); + } else if (limit == 0) { + if (!chan && na->nc == u->na->nc) + notice_lang(s_MemoServ, u, MEMO_SET_YOUR_LIMIT_ZERO); + else + notice_lang(s_MemoServ, u, MEMO_SET_LIMIT_ZERO, + chan ? chan : user); + } else { + if (!chan && na->nc == u->na->nc) + notice_lang(s_MemoServ, u, MEMO_UNSET_YOUR_LIMIT); + else + notice_lang(s_MemoServ, u, MEMO_UNSET_LIMIT, + chan ? chan : user); + } + return MOD_CONT; } MODULE_INIT("ms_set", MSSet) diff --git a/src/core/ms_staff.c b/src/core/ms_staff.c index d5cfcae4a..3dda46217 100644 --- a/src/core/ms_staff.c +++ b/src/core/ms_staff.c @@ -42,9 +42,9 @@ class MSStaff : public Module **/ void myMemoServHelp(User * u) { - if (is_services_oper(u)) { - notice_lang(s_MemoServ, u, MEMO_HELP_CMD_STAFF); - } + if (is_services_oper(u)) { + notice_lang(s_MemoServ, u, MEMO_HELP_CMD_STAFF); + } } /** @@ -54,28 +54,28 @@ void myMemoServHelp(User * u) **/ int do_staff(User * u) { - NickCore *nc; - int i, z = 0; - char *text = strtok(NULL, ""); + NickCore *nc; + int i, z = 0; + char *text = strtok(NULL, ""); - if (readonly) { - notice_lang(s_MemoServ, u, MEMO_SEND_DISABLED); - return MOD_CONT; - } else if (checkDefCon(DEFCON_NO_NEW_MEMOS)) { - notice_lang(s_MemoServ, u, OPER_DEFCON_DENIED); - return MOD_CONT; - } else if (text == NULL) { - syntax_error(s_MemoServ, u, "SEND", MEMO_SEND_SYNTAX); - return MOD_CONT; - } + if (readonly) { + notice_lang(s_MemoServ, u, MEMO_SEND_DISABLED); + return MOD_CONT; + } else if (checkDefCon(DEFCON_NO_NEW_MEMOS)) { + notice_lang(s_MemoServ, u, OPER_DEFCON_DENIED); + return MOD_CONT; + } else if (text == NULL) { + syntax_error(s_MemoServ, u, "SEND", MEMO_SEND_SYNTAX); + return MOD_CONT; + } - for (i = 0; i < 1024; i++) { - for (nc = nclists[i]; nc; nc = nc->next) { - if (nick_is_services_oper(nc)) - memo_send(u, nc->display, text, z); - } - } - return MOD_CONT; + for (i = 0; i < 1024; i++) { + for (nc = nclists[i]; nc; nc = nc->next) { + if (nick_is_services_oper(nc)) + memo_send(u, nc->display, text, z); + } + } + return MOD_CONT; } MODULE_INIT("ms_staff", MSStaff) diff --git a/src/core/ns_access.c b/src/core/ns_access.c index 8e32d9919..502268cdf 100644 --- a/src/core/ns_access.c +++ b/src/core/ns_access.c @@ -44,7 +44,7 @@ class NSAccess : public Module **/ void myNickServHelp(User * u) { - notice_lang(s_NickServ, u, NICK_HELP_CMD_ACCESS); + notice_lang(s_NickServ, u, NICK_HELP_CMD_ACCESS); } /** @@ -54,125 +54,125 @@ void myNickServHelp(User * u) **/ int do_access(User * u) { - char *cmd = strtok(NULL, " "); - char *mask = strtok(NULL, " "); - NickAlias *na; - int i; - char **access; - - if (cmd && stricmp(cmd, "LIST") == 0 && mask && is_services_admin(u) - && (na = findnick(mask))) { - - if (na->nc->accesscount == 0) { - notice_lang(s_NickServ, u, NICK_ACCESS_LIST_X_EMPTY, na->nick); - return MOD_CONT; - } - - if (na->status & NS_VERBOTEN) { - notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); - return MOD_CONT; - } - - if (na->nc->flags & NI_SUSPENDED) { - notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick); - return MOD_CONT; - } - - - notice_lang(s_NickServ, u, NICK_ACCESS_LIST_X, mask); - mask = strtok(NULL, " "); - for (access = na->nc->access, i = 0; i < na->nc->accesscount; - access++, i++) { - if (mask && !match_wild(mask, *access)) - continue; - notice_user(s_NickServ, u, " %s", *access); - } - - } else if (!cmd || ((stricmp(cmd, "LIST") == 0) ? !!mask : !mask)) { - syntax_error(s_NickServ, u, "ACCESS", NICK_ACCESS_SYNTAX); - - } else if (mask && !strchr(mask, '@')) { - notice_lang(s_NickServ, u, BAD_USERHOST_MASK); - notice_lang(s_NickServ, u, MORE_INFO, s_NickServ, "ACCESS"); - - } else if (!(na = u->na)) { - notice_lang(s_NickServ, u, NICK_NOT_REGISTERED); - - } else if (na->status & NS_VERBOTEN) { - notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); - - } else if (na->nc->flags & NI_SUSPENDED) { - notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick); - - } else if (!nick_identified(u)) { - notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); - - } else if (stricmp(cmd, "ADD") == 0) { - if (na->nc->accesscount >= NSAccessMax) { - notice_lang(s_NickServ, u, NICK_ACCESS_REACHED_LIMIT, - NSAccessMax); - return MOD_CONT; - } - - for (access = na->nc->access, i = 0; i < na->nc->accesscount; - access++, i++) { - if (strcmp(*access, mask) == 0) { - notice_lang(s_NickServ, u, NICK_ACCESS_ALREADY_PRESENT, - *access); - return MOD_CONT; - } - } - - na->nc->accesscount++; - na->nc->access = - (char **)srealloc(na->nc->access, sizeof(char *) * na->nc->accesscount); - na->nc->access[na->nc->accesscount - 1] = sstrdup(mask); - notice_lang(s_NickServ, u, NICK_ACCESS_ADDED, mask); - - } else if (stricmp(cmd, "DEL") == 0) { - - for (access = na->nc->access, i = 0; i < na->nc->accesscount; - access++, i++) { - if (stricmp(*access, mask) == 0) - break; - } - if (i == na->nc->accesscount) { - notice_lang(s_NickServ, u, NICK_ACCESS_NOT_FOUND, mask); - return MOD_CONT; - } - - notice_lang(s_NickServ, u, NICK_ACCESS_DELETED, *access); - free(*access); - na->nc->accesscount--; - if (i < na->nc->accesscount) /* if it wasn't the last entry... */ - memmove(access, access + 1, - (na->nc->accesscount - i) * sizeof(char *)); - if (na->nc->accesscount) /* if there are any entries left... */ - na->nc->access = - (char **)srealloc(na->nc->access, - na->nc->accesscount * sizeof(char *)); - else { - free(na->nc->access); - na->nc->access = NULL; - } - } else if (stricmp(cmd, "LIST") == 0) { - if (na->nc->accesscount == 0) { - notice_lang(s_NickServ, u, NICK_ACCESS_LIST_EMPTY, u->nick); - return MOD_CONT; - } - - notice_lang(s_NickServ, u, NICK_ACCESS_LIST); - for (access = na->nc->access, i = 0; i < na->nc->accesscount; - access++, i++) { - if (mask && !match_wild(mask, *access)) - continue; - notice_user(s_NickServ, u, " %s", *access); - } - } else { - syntax_error(s_NickServ, u, "ACCESS", NICK_ACCESS_SYNTAX); - - } - return MOD_CONT; + char *cmd = strtok(NULL, " "); + char *mask = strtok(NULL, " "); + NickAlias *na; + int i; + char **access; + + if (cmd && stricmp(cmd, "LIST") == 0 && mask && is_services_admin(u) + && (na = findnick(mask))) { + + if (na->nc->accesscount == 0) { + notice_lang(s_NickServ, u, NICK_ACCESS_LIST_X_EMPTY, na->nick); + return MOD_CONT; + } + + if (na->status & NS_VERBOTEN) { + notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); + return MOD_CONT; + } + + if (na->nc->flags & NI_SUSPENDED) { + notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick); + return MOD_CONT; + } + + + notice_lang(s_NickServ, u, NICK_ACCESS_LIST_X, mask); + mask = strtok(NULL, " "); + for (access = na->nc->access, i = 0; i < na->nc->accesscount; + access++, i++) { + if (mask && !match_wild(mask, *access)) + continue; + notice_user(s_NickServ, u, " %s", *access); + } + + } else if (!cmd || ((stricmp(cmd, "LIST") == 0) ? !!mask : !mask)) { + syntax_error(s_NickServ, u, "ACCESS", NICK_ACCESS_SYNTAX); + + } else if (mask && !strchr(mask, '@')) { + notice_lang(s_NickServ, u, BAD_USERHOST_MASK); + notice_lang(s_NickServ, u, MORE_INFO, s_NickServ, "ACCESS"); + + } else if (!(na = u->na)) { + notice_lang(s_NickServ, u, NICK_NOT_REGISTERED); + + } else if (na->status & NS_VERBOTEN) { + notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); + + } else if (na->nc->flags & NI_SUSPENDED) { + notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick); + + } else if (!nick_identified(u)) { + notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); + + } else if (stricmp(cmd, "ADD") == 0) { + if (na->nc->accesscount >= NSAccessMax) { + notice_lang(s_NickServ, u, NICK_ACCESS_REACHED_LIMIT, + NSAccessMax); + return MOD_CONT; + } + + for (access = na->nc->access, i = 0; i < na->nc->accesscount; + access++, i++) { + if (strcmp(*access, mask) == 0) { + notice_lang(s_NickServ, u, NICK_ACCESS_ALREADY_PRESENT, + *access); + return MOD_CONT; + } + } + + na->nc->accesscount++; + na->nc->access = + (char **)srealloc(na->nc->access, sizeof(char *) * na->nc->accesscount); + na->nc->access[na->nc->accesscount - 1] = sstrdup(mask); + notice_lang(s_NickServ, u, NICK_ACCESS_ADDED, mask); + + } else if (stricmp(cmd, "DEL") == 0) { + + for (access = na->nc->access, i = 0; i < na->nc->accesscount; + access++, i++) { + if (stricmp(*access, mask) == 0) + break; + } + if (i == na->nc->accesscount) { + notice_lang(s_NickServ, u, NICK_ACCESS_NOT_FOUND, mask); + return MOD_CONT; + } + + notice_lang(s_NickServ, u, NICK_ACCESS_DELETED, *access); + free(*access); + na->nc->accesscount--; + if (i < na->nc->accesscount) /* if it wasn't the last entry... */ + memmove(access, access + 1, + (na->nc->accesscount - i) * sizeof(char *)); + if (na->nc->accesscount) /* if there are any entries left... */ + na->nc->access = + (char **)srealloc(na->nc->access, + na->nc->accesscount * sizeof(char *)); + else { + free(na->nc->access); + na->nc->access = NULL; + } + } else if (stricmp(cmd, "LIST") == 0) { + if (na->nc->accesscount == 0) { + notice_lang(s_NickServ, u, NICK_ACCESS_LIST_EMPTY, u->nick); + return MOD_CONT; + } + + notice_lang(s_NickServ, u, NICK_ACCESS_LIST); + for (access = na->nc->access, i = 0; i < na->nc->accesscount; + access++, i++) { + if (mask && !match_wild(mask, *access)) + continue; + notice_user(s_NickServ, u, " %s", *access); + } + } else { + syntax_error(s_NickServ, u, "ACCESS", NICK_ACCESS_SYNTAX); + + } + return MOD_CONT; } MODULE_INIT("ns_access", NSAccess) diff --git a/src/core/ns_alist.c b/src/core/ns_alist.c index ce0d88546..d71e7d1e9 100644 --- a/src/core/ns_alist.c +++ b/src/core/ns_alist.c @@ -44,7 +44,7 @@ class NSAList : public Module **/ void myNickServHelp(User * u) { - notice_lang(s_NickServ, u, NICK_HELP_CMD_ALIST); + notice_lang(s_NickServ, u, NICK_HELP_CMD_ALIST); } /** @@ -64,111 +64,111 @@ int do_alist(User * u) * -jester */ - char *nick = NULL; - char *lev = NULL; - - NickAlias *na; - - int min_level = 0; - int is_servadmin = is_services_admin(u); - - if (!is_servadmin) { - /* Non service admins can only see their own levels */ - na = u->na; - } else { - /* Services admins can request ALIST on nicks. - * The first argument for service admins must - * always be a nickname. - */ - nick = strtok(NULL, " "); - - /* If an argument was passed, use it as the nick to see levels - * for, else check levels for the user calling the command */ - if (nick) { - na = findnick(nick); - } else { - na = u->na; - } - } - - /* If available, get level from arguments */ - lev = strtok(NULL, " "); - - /* if a level was given, make sure it's an int for later */ - if (lev) { - if (stricmp(lev, "FOUNDER") == 0) { - min_level = ACCESS_FOUNDER; - } else if (stricmp(lev, "SOP") == 0) { - min_level = ACCESS_SOP; - } else if (stricmp(lev, "AOP") == 0) { - min_level = ACCESS_AOP; - } else if (stricmp(lev, "HOP") == 0) { - min_level = ACCESS_HOP; - } else if (stricmp(lev, "VOP") == 0) { - min_level = ACCESS_VOP; - } else { - min_level = atoi(lev); - } - } - - if (!nick_identified(u)) { - notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); - } else if (is_servadmin && nick && !na) { - notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); - } else if (na->status & NS_VERBOTEN) { - notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); - } else if (min_level <= ACCESS_INVALID || min_level > ACCESS_FOUNDER) { - notice_lang(s_NickServ, u, CHAN_ACCESS_LEVEL_RANGE, - ACCESS_INVALID + 1, ACCESS_FOUNDER - 1); - } else { - int i, level; - int chan_count = 0; - int match_count = 0; - ChannelInfo *ci; - - notice_lang(s_NickServ, u, (is_servadmin ? NICK_ALIST_HEADER_X : - NICK_ALIST_HEADER), na->nick); - - for (i = 0; i < 256; i++) { - for ((ci = chanlists[i]); ci; (ci = ci->next)) { - - if ((level = get_access_level(ci, na))) { - chan_count++; - - if (min_level > level) { - continue; - } - - match_count++; - - if ((ci->flags & CI_XOP) || (level == ACCESS_FOUNDER)) { - const char *xop; - - xop = get_xop_level(level); - - notice_lang(s_NickServ, u, NICK_ALIST_XOP_FORMAT, - match_count, - ((ci-> - flags & CI_NO_EXPIRE) ? '!' : ' '), - ci->name, xop, - (ci->desc ? ci->desc : "")); - } else { - notice_lang(s_NickServ, u, - NICK_ALIST_ACCESS_FORMAT, match_count, - ((ci-> - flags & CI_NO_EXPIRE) ? '!' : ' '), - ci->name, level, - (ci->desc ? ci->desc : "")); - - } - } - } - } - - notice_lang(s_NickServ, u, NICK_ALIST_FOOTER, match_count, - chan_count); - } - return MOD_CONT; + char *nick = NULL; + char *lev = NULL; + + NickAlias *na; + + int min_level = 0; + int is_servadmin = is_services_admin(u); + + if (!is_servadmin) { + /* Non service admins can only see their own levels */ + na = u->na; + } else { + /* Services admins can request ALIST on nicks. + * The first argument for service admins must + * always be a nickname. + */ + nick = strtok(NULL, " "); + + /* If an argument was passed, use it as the nick to see levels + * for, else check levels for the user calling the command */ + if (nick) { + na = findnick(nick); + } else { + na = u->na; + } + } + + /* If available, get level from arguments */ + lev = strtok(NULL, " "); + + /* if a level was given, make sure it's an int for later */ + if (lev) { + if (stricmp(lev, "FOUNDER") == 0) { + min_level = ACCESS_FOUNDER; + } else if (stricmp(lev, "SOP") == 0) { + min_level = ACCESS_SOP; + } else if (stricmp(lev, "AOP") == 0) { + min_level = ACCESS_AOP; + } else if (stricmp(lev, "HOP") == 0) { + min_level = ACCESS_HOP; + } else if (stricmp(lev, "VOP") == 0) { + min_level = ACCESS_VOP; + } else { + min_level = atoi(lev); + } + } + + if (!nick_identified(u)) { + notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); + } else if (is_servadmin && nick && !na) { + notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); + } else if (na->status & NS_VERBOTEN) { + notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); + } else if (min_level <= ACCESS_INVALID || min_level > ACCESS_FOUNDER) { + notice_lang(s_NickServ, u, CHAN_ACCESS_LEVEL_RANGE, + ACCESS_INVALID + 1, ACCESS_FOUNDER - 1); + } else { + int i, level; + int chan_count = 0; + int match_count = 0; + ChannelInfo *ci; + + notice_lang(s_NickServ, u, (is_servadmin ? NICK_ALIST_HEADER_X : + NICK_ALIST_HEADER), na->nick); + + for (i = 0; i < 256; i++) { + for ((ci = chanlists[i]); ci; (ci = ci->next)) { + + if ((level = get_access_level(ci, na))) { + chan_count++; + + if (min_level > level) { + continue; + } + + match_count++; + + if ((ci->flags & CI_XOP) || (level == ACCESS_FOUNDER)) { + const char *xop; + + xop = get_xop_level(level); + + notice_lang(s_NickServ, u, NICK_ALIST_XOP_FORMAT, + match_count, + ((ci-> + flags & CI_NO_EXPIRE) ? '!' : ' '), + ci->name, xop, + (ci->desc ? ci->desc : "")); + } else { + notice_lang(s_NickServ, u, + NICK_ALIST_ACCESS_FORMAT, match_count, + ((ci-> + flags & CI_NO_EXPIRE) ? '!' : ' '), + ci->name, level, + (ci->desc ? ci->desc : "")); + + } + } + } + } + + notice_lang(s_NickServ, u, NICK_ALIST_FOOTER, match_count, + chan_count); + } + return MOD_CONT; } MODULE_INIT("ns_alist", NSAList) diff --git a/src/core/ns_drop.c b/src/core/ns_drop.c index fcd2734b6..1d528dd45 100644 --- a/src/core/ns_drop.c +++ b/src/core/ns_drop.c @@ -46,7 +46,7 @@ class NSDrop : public Module **/ void myNickServHelp(User * u) { - notice_lang(s_NickServ, u, NICK_HELP_CMD_DROP); + notice_lang(s_NickServ, u, NICK_HELP_CMD_DROP); } /** @@ -56,89 +56,89 @@ void myNickServHelp(User * u) **/ int do_drop(User * u) { - char *nick = strtok(NULL, " "); - NickAlias *na; - NickRequest *nr = NULL; - int is_servadmin = is_services_admin(u); - int is_mine; /* Does the nick being dropped belong to the user that is dropping? */ - char *my_nick = NULL; - - if (readonly && !is_servadmin) { - notice_lang(s_NickServ, u, NICK_DROP_DISABLED); - return MOD_CONT; - } - - if (!(na = (nick ? findnick(nick) : u->na))) { - if (nick) { - if ((nr = findrequestnick(nick)) && is_servadmin) { - if (readonly) - notice_lang(s_NickServ, u, READ_ONLY_MODE); - if (WallDrop) - ircdproto->SendGlobops(s_NickServ, - "\2%s\2 used DROP on \2%s\2", u->nick, - nick); - alog("%s: %s!%s@%s dropped nickname %s (e-mail: %s)", - s_NickServ, u->nick, u->username, u->host, - nr->nick, nr->email); - delnickrequest(nr); - notice_lang(s_NickServ, u, NICK_X_DROPPED, nick); - } else { - notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); - } - } else - notice_lang(s_NickServ, u, NICK_NOT_REGISTERED); - return MOD_CONT; - } - - is_mine = (u->na && (u->na->nc == na->nc)); - if (is_mine && !nick) - my_nick = sstrdup(na->nick); - - if (is_mine && !nick_identified(u)) { - notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); - } else if (!is_mine && !is_servadmin) { - notice_lang(s_NickServ, u, ACCESS_DENIED); - } else if (NSSecureAdmins && !is_mine && nick_is_services_admin(na->nc) - && !is_services_root(u)) { - notice_lang(s_NickServ, u, PERMISSION_DENIED); - } else { - if (readonly) - notice_lang(s_NickServ, u, READ_ONLY_MODE); - - if (ircd->sqline && (na->status & NS_VERBOTEN)) { - ircdproto->SendSQLineDel(na->nick); - } - - alog("%s: %s!%s@%s dropped nickname %s (group %s) (e-mail: %s)", - s_NickServ, u->nick, u->username, u->host, - na->nick, na->nc->display, - (na->nc->email ? na->nc->email : "none")); - delnick(na); - send_event(EVENT_NICK_DROPPED, 1, (my_nick ? my_nick : nick)); - - if (!is_mine) { - if (WallDrop) - ircdproto->SendGlobops(s_NickServ, "\2%s\2 used DROP on \2%s\2", - u->nick, nick); - notice_lang(s_NickServ, u, NICK_X_DROPPED, nick); - } else { - if (nick) - notice_lang(s_NickServ, u, NICK_X_DROPPED, nick); - else - notice_lang(s_NickServ, u, NICK_DROPPED); - if (my_nick) { - free(my_nick); - } - } - } - return MOD_CONT; + char *nick = strtok(NULL, " "); + NickAlias *na; + NickRequest *nr = NULL; + int is_servadmin = is_services_admin(u); + int is_mine; /* Does the nick being dropped belong to the user that is dropping? */ + char *my_nick = NULL; + + if (readonly && !is_servadmin) { + notice_lang(s_NickServ, u, NICK_DROP_DISABLED); + return MOD_CONT; + } + + if (!(na = (nick ? findnick(nick) : u->na))) { + if (nick) { + if ((nr = findrequestnick(nick)) && is_servadmin) { + if (readonly) + notice_lang(s_NickServ, u, READ_ONLY_MODE); + if (WallDrop) + ircdproto->SendGlobops(s_NickServ, + "\2%s\2 used DROP on \2%s\2", u->nick, + nick); + alog("%s: %s!%s@%s dropped nickname %s (e-mail: %s)", + s_NickServ, u->nick, u->username, u->host, + nr->nick, nr->email); + delnickrequest(nr); + notice_lang(s_NickServ, u, NICK_X_DROPPED, nick); + } else { + notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); + } + } else + notice_lang(s_NickServ, u, NICK_NOT_REGISTERED); + return MOD_CONT; + } + + is_mine = (u->na && (u->na->nc == na->nc)); + if (is_mine && !nick) + my_nick = sstrdup(na->nick); + + if (is_mine && !nick_identified(u)) { + notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); + } else if (!is_mine && !is_servadmin) { + notice_lang(s_NickServ, u, ACCESS_DENIED); + } else if (NSSecureAdmins && !is_mine && nick_is_services_admin(na->nc) + && !is_services_root(u)) { + notice_lang(s_NickServ, u, PERMISSION_DENIED); + } else { + if (readonly) + notice_lang(s_NickServ, u, READ_ONLY_MODE); + + if (ircd->sqline && (na->status & NS_VERBOTEN)) { + ircdproto->SendSQLineDel(na->nick); + } + + alog("%s: %s!%s@%s dropped nickname %s (group %s) (e-mail: %s)", + s_NickServ, u->nick, u->username, u->host, + na->nick, na->nc->display, + (na->nc->email ? na->nc->email : "none")); + delnick(na); + send_event(EVENT_NICK_DROPPED, 1, (my_nick ? my_nick : nick)); + + if (!is_mine) { + if (WallDrop) + ircdproto->SendGlobops(s_NickServ, "\2%s\2 used DROP on \2%s\2", + u->nick, nick); + notice_lang(s_NickServ, u, NICK_X_DROPPED, nick); + } else { + if (nick) + notice_lang(s_NickServ, u, NICK_X_DROPPED, nick); + else + notice_lang(s_NickServ, u, NICK_DROPPED); + if (my_nick) { + free(my_nick); + } + } + } + return MOD_CONT; } int do_unlink(User * u) { - notice_lang(s_NickServ, u, OBSOLETE_COMMAND, "DROP"); - return MOD_CONT; + notice_lang(s_NickServ, u, OBSOLETE_COMMAND, "DROP"); + return MOD_CONT; } MODULE_INIT("ns_drop", NSDrop) diff --git a/src/core/ns_forbid.c b/src/core/ns_forbid.c index 6a6fc87af..cc3ed5b90 100644 --- a/src/core/ns_forbid.c +++ b/src/core/ns_forbid.c @@ -45,9 +45,9 @@ class NSForbid : public Module **/ void myNickServHelp(User * u) { - if (is_services_admin(u)) { - notice_lang(s_NickServ, u, NICK_HELP_CMD_FORBID); - } + if (is_services_admin(u)) { + notice_lang(s_NickServ, u, NICK_HELP_CMD_FORBID); + } } /** @@ -57,87 +57,87 @@ void myNickServHelp(User * u) **/ int do_forbid(User * u) { - NickAlias *na; - char *nick = strtok(NULL, " "); - char *reason = strtok(NULL, ""); - - /* Assumes that permission checking has already been done. */ - if (!nick || (ForceForbidReason && !reason)) { - syntax_error(s_NickServ, u, "FORBID", - (ForceForbidReason ? NICK_FORBID_SYNTAX_REASON : - NICK_FORBID_SYNTAX)); - return MOD_CONT; - } - - if (readonly) - notice_lang(s_NickServ, u, READ_ONLY_MODE); - if (!ircdproto->IsNickValid(nick)) { - notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, nick); - return MOD_CONT; - } - if ((na = findnick(nick)) != NULL) { - if (NSSecureAdmins && nick_is_services_admin(na->nc) - && !is_services_root(u)) { - notice_lang(s_NickServ, u, PERMISSION_DENIED); - return MOD_CONT; - } - delnick(na); - } - na = makenick(nick); - if (na) { - na->status |= NS_VERBOTEN; - na->last_usermask = sstrdup(u->nick); - if (reason) - na->last_realname = sstrdup(reason); - - na->u = finduser(na->nick); - if (na->u) - na->u->na = na; - - if (na->u) { - notice_lang(s_NickServ, na->u, FORCENICKCHANGE_NOW); - collide(na, 0); - } - - - if (ircd->sqline) { - ircdproto->SendSQLine(na->nick, ((reason) ? reason : "Forbidden")); - } - - if (WallForbid) - ircdproto->SendGlobops(s_NickServ, "\2%s\2 used FORBID on \2%s\2", - u->nick, nick); - - alog("%s: %s set FORBID for nick %s", s_NickServ, u->nick, nick); - notice_lang(s_NickServ, u, NICK_FORBID_SUCCEEDED, nick); - send_event(EVENT_NICK_FORBIDDEN, 1, nick); - } else { - alog("%s: Valid FORBID for %s by %s failed", s_NickServ, nick, - u->nick); - notice_lang(s_NickServ, u, NICK_FORBID_FAILED, nick); - } - return MOD_CONT; + NickAlias *na; + char *nick = strtok(NULL, " "); + char *reason = strtok(NULL, ""); + + /* Assumes that permission checking has already been done. */ + if (!nick || (ForceForbidReason && !reason)) { + syntax_error(s_NickServ, u, "FORBID", + (ForceForbidReason ? NICK_FORBID_SYNTAX_REASON : + NICK_FORBID_SYNTAX)); + return MOD_CONT; + } + + if (readonly) + notice_lang(s_NickServ, u, READ_ONLY_MODE); + if (!ircdproto->IsNickValid(nick)) { + notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, nick); + return MOD_CONT; + } + if ((na = findnick(nick)) != NULL) { + if (NSSecureAdmins && nick_is_services_admin(na->nc) + && !is_services_root(u)) { + notice_lang(s_NickServ, u, PERMISSION_DENIED); + return MOD_CONT; + } + delnick(na); + } + na = makenick(nick); + if (na) { + na->status |= NS_VERBOTEN; + na->last_usermask = sstrdup(u->nick); + if (reason) + na->last_realname = sstrdup(reason); + + na->u = finduser(na->nick); + if (na->u) + na->u->na = na; + + if (na->u) { + notice_lang(s_NickServ, na->u, FORCENICKCHANGE_NOW); + collide(na, 0); + } + + + if (ircd->sqline) { + ircdproto->SendSQLine(na->nick, ((reason) ? reason : "Forbidden")); + } + + if (WallForbid) + ircdproto->SendGlobops(s_NickServ, "\2%s\2 used FORBID on \2%s\2", + u->nick, nick); + + alog("%s: %s set FORBID for nick %s", s_NickServ, u->nick, nick); + notice_lang(s_NickServ, u, NICK_FORBID_SUCCEEDED, nick); + send_event(EVENT_NICK_FORBIDDEN, 1, nick); + } else { + alog("%s: Valid FORBID for %s by %s failed", s_NickServ, nick, + u->nick); + notice_lang(s_NickServ, u, NICK_FORBID_FAILED, nick); + } + return MOD_CONT; } NickAlias *makenick(const char *nick) { - NickAlias *na; - NickCore *nc; - - /* First make the core */ - nc = (NickCore *)scalloc(1, sizeof(NickCore)); - nc->display = sstrdup(nick); - slist_init(&nc->aliases); - insert_core(nc); - alog("%s: group %s has been created", s_NickServ, nc->display); - - /* Then make the alias */ - na = (NickAlias *)scalloc(1, sizeof(NickAlias)); - na->nick = sstrdup(nick); - na->nc = nc; - slist_add(&nc->aliases, na); - alpha_insert_alias(na); - return na; + NickAlias *na; + NickCore *nc; + + /* First make the core */ + nc = (NickCore *)scalloc(1, sizeof(NickCore)); + nc->display = sstrdup(nick); + slist_init(&nc->aliases); + insert_core(nc); + alog("%s: group %s has been created", s_NickServ, nc->display); + + /* Then make the alias */ + na = (NickAlias *)scalloc(1, sizeof(NickAlias)); + na->nick = sstrdup(nick); + na->nc = nc; + slist_add(&nc->aliases, na); + alpha_insert_alias(na); + return na; } MODULE_INIT("ns_forbid", NSForbid) diff --git a/src/core/ns_getemail.c b/src/core/ns_getemail.c index 19e51389b..3089470b3 100644 --- a/src/core/ns_getemail.c +++ b/src/core/ns_getemail.c @@ -10,8 +10,8 @@ * * * A simple call to check for all emails that a user may have registered - * with. It returns the nicks that match the email you provide. Wild - * Cards are not excepted. Must use user@email-host. + * with. It returns the nicks that match the email you provide. Wild + * Cards are not excepted. Must use user@email-host. * * $Id$ * @@ -47,9 +47,9 @@ class NSGetEMail : public Module **/ void myNickServHelp(User * u) { - if (is_services_admin(u)) { - notice_lang(s_NickServ, u, NICK_HELP_CMD_GETEMAIL); - } + if (is_services_admin(u)) { + notice_lang(s_NickServ, u, NICK_HELP_CMD_GETEMAIL); + } } /** @@ -59,32 +59,32 @@ void myNickServHelp(User * u) **/ int do_getemail(User * u) { - char *email = strtok(NULL, " "); - int i, j = 0; - NickCore *nc; + char *email = strtok(NULL, " "); + int i, j = 0; + NickCore *nc; - if (!email) { - syntax_error(s_NickServ, u, "GETMAIL", NICK_GETEMAIL_SYNTAX); - return MOD_CONT; - } - alog("%s: %s!%s@%s used GETEMAIL on %s", s_NickServ, u->nick, - u->username, u->host, email); - for (i = 0; i < 1024; i++) { - for (nc = nclists[i]; nc; nc = nc->next) { - if (nc->email) { - if (stricmp(nc->email, email) == 0) { - j++; - notice_lang(s_NickServ, u, NICK_GETEMAIL_EMAILS_ARE, - nc->display, email); - } - } - } - } - if (j <= 0) { - notice_lang(s_NickServ, u, NICK_GETEMAIL_NOT_USED, email); - return MOD_CONT; - } - return MOD_CONT; + if (!email) { + syntax_error(s_NickServ, u, "GETMAIL", NICK_GETEMAIL_SYNTAX); + return MOD_CONT; + } + alog("%s: %s!%s@%s used GETEMAIL on %s", s_NickServ, u->nick, + u->username, u->host, email); + for (i = 0; i < 1024; i++) { + for (nc = nclists[i]; nc; nc = nc->next) { + if (nc->email) { + if (stricmp(nc->email, email) == 0) { + j++; + notice_lang(s_NickServ, u, NICK_GETEMAIL_EMAILS_ARE, + nc->display, email); + } + } + } + } + if (j <= 0) { + notice_lang(s_NickServ, u, NICK_GETEMAIL_NOT_USED, email); + return MOD_CONT; + } + return MOD_CONT; } MODULE_INIT("ns_getemail", NSGetEMail) diff --git a/src/core/ns_getpass.c b/src/core/ns_getpass.c index c741e76c9..90af1aa5f 100644 --- a/src/core/ns_getpass.c +++ b/src/core/ns_getpass.c @@ -42,9 +42,9 @@ class NSGetPass : public Module **/ void myNickServHelp(User * u) { - if (is_services_admin(u)) { - notice_lang(s_NickServ, u, NICK_HELP_CMD_GETPASS); - } + if (is_services_admin(u)) { + notice_lang(s_NickServ, u, NICK_HELP_CMD_GETPASS); + } } /** @@ -54,47 +54,47 @@ void myNickServHelp(User * u) **/ int do_getpass(User * u) { - char *nick = strtok(NULL, " "); - char tmp_pass[PASSMAX]; - NickAlias *na; - NickRequest *nr = NULL; + char *nick = strtok(NULL, " "); + char tmp_pass[PASSMAX]; + NickAlias *na; + NickRequest *nr = NULL; - if (!nick) { - syntax_error(s_NickServ, u, "GETPASS", NICK_GETPASS_SYNTAX); - } else if (!(na = findnick(nick))) { - if ((nr = findrequestnick(nick))) { - alog("%s: %s!%s@%s used GETPASS on %s", s_NickServ, u->nick, - u->username, u->host, nick); - if (WallGetpass) - ircdproto->SendGlobops(s_NickServ, - "\2%s\2 used GETPASS on \2%s\2", u->nick, - nick); - notice_lang(s_NickServ, u, NICK_GETPASS_PASSCODE_IS, nick, - nr->passcode); - } else { - notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); - } - } else if (na->status & NS_VERBOTEN) { - notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); - } else if (NSSecureAdmins && nick_is_services_admin(na->nc) - && !is_services_root(u)) { - notice_lang(s_NickServ, u, PERMISSION_DENIED); - } else if (NSRestrictGetPass && !is_services_root(u)) { - notice_lang(s_NickServ, u, PERMISSION_DENIED); - } else { - if(enc_decrypt(na->nc->pass,tmp_pass,PASSMAX - 1)==1) { - alog("%s: %s!%s@%s used GETPASS on %s", s_NickServ, u->nick, - u->username, u->host, nick); - if (WallGetpass) - ircdproto->SendGlobops(s_NickServ, "\2%s\2 used GETPASS on \2%s\2", - u->nick, nick); - notice_lang(s_NickServ, u, NICK_GETPASS_PASSWORD_IS, nick, - tmp_pass); - } else { - notice_lang(s_NickServ, u, NICK_GETPASS_UNAVAILABLE); - } - } - return MOD_CONT; + if (!nick) { + syntax_error(s_NickServ, u, "GETPASS", NICK_GETPASS_SYNTAX); + } else if (!(na = findnick(nick))) { + if ((nr = findrequestnick(nick))) { + alog("%s: %s!%s@%s used GETPASS on %s", s_NickServ, u->nick, + u->username, u->host, nick); + if (WallGetpass) + ircdproto->SendGlobops(s_NickServ, + "\2%s\2 used GETPASS on \2%s\2", u->nick, + nick); + notice_lang(s_NickServ, u, NICK_GETPASS_PASSCODE_IS, nick, + nr->passcode); + } else { + notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); + } + } else if (na->status & NS_VERBOTEN) { + notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); + } else if (NSSecureAdmins && nick_is_services_admin(na->nc) + && !is_services_root(u)) { + notice_lang(s_NickServ, u, PERMISSION_DENIED); + } else if (NSRestrictGetPass && !is_services_root(u)) { + notice_lang(s_NickServ, u, PERMISSION_DENIED); + } else { + if(enc_decrypt(na->nc->pass,tmp_pass,PASSMAX - 1)==1) { + alog("%s: %s!%s@%s used GETPASS on %s", s_NickServ, u->nick, + u->username, u->host, nick); + if (WallGetpass) + ircdproto->SendGlobops(s_NickServ, "\2%s\2 used GETPASS on \2%s\2", + u->nick, nick); + notice_lang(s_NickServ, u, NICK_GETPASS_PASSWORD_IS, nick, + tmp_pass); + } else { + notice_lang(s_NickServ, u, NICK_GETPASS_UNAVAILABLE); + } + } + return MOD_CONT; } MODULE_INIT("ns_getpass", NSGetPass) diff --git a/src/core/ns_ghost.c b/src/core/ns_ghost.c index 49f036cc6..4eb825a6f 100644 --- a/src/core/ns_ghost.c +++ b/src/core/ns_ghost.c @@ -44,7 +44,7 @@ class NSGhost : public Module **/ void myNickServHelp(User * u) { - notice_lang(s_NickServ, u, NICK_HELP_CMD_GHOST); + notice_lang(s_NickServ, u, NICK_HELP_CMD_GHOST); } /** @@ -54,58 +54,58 @@ void myNickServHelp(User * u) **/ int do_ghost(User * u) { - char *nick = strtok(NULL, " "); - char *pass = strtok(NULL, " "); - NickAlias *na; - User *u2; + char *nick = strtok(NULL, " "); + char *pass = strtok(NULL, " "); + NickAlias *na; + User *u2; - if (!nick) { - syntax_error(s_NickServ, u, "GHOST", NICK_GHOST_SYNTAX); - } else if (!(u2 = finduser(nick))) { - notice_lang(s_NickServ, u, NICK_X_NOT_IN_USE, nick); - } else if (!(na = u2->na)) { - notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); - } else if (na->status & NS_VERBOTEN) { - notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); - } else if (na->nc->flags & NI_SUSPENDED) { - notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick); - } else if (stricmp(nick, u->nick) == 0) { - notice_lang(s_NickServ, u, NICK_NO_GHOST_SELF); - } else if (pass) { - int res = enc_check_password(pass, na->nc->pass); - if (res == 1) { - char buf[NICKMAX + 32]; - snprintf(buf, sizeof(buf), "GHOST command used by %s", - u->nick); - if (LimitSessions) { - del_session(u2->host); - } - kill_user(s_NickServ, nick, buf); - notice_lang(s_NickServ, u, NICK_GHOST_KILLED, nick); - } else { - notice_lang(s_NickServ, u, ACCESS_DENIED); - if (res == 0) { - alog("%s: GHOST: invalid password for %s by %s!%s@%s", - s_NickServ, nick, u->nick, u->username, u->host); - bad_password(u); - } - } - } else { - if (group_identified(u, na->nc) - || (!(na->nc->flags & NI_SECURE) && is_on_access(u, na->nc))) { - char buf[NICKMAX + 32]; - snprintf(buf, sizeof(buf), "GHOST command used by %s", - u->nick); - if (LimitSessions) { - del_session(u2->host); - } - kill_user(s_NickServ, nick, buf); - notice_lang(s_NickServ, u, NICK_GHOST_KILLED, nick); - } else { - notice_lang(s_NickServ, u, ACCESS_DENIED); - } - } - return MOD_CONT; + if (!nick) { + syntax_error(s_NickServ, u, "GHOST", NICK_GHOST_SYNTAX); + } else if (!(u2 = finduser(nick))) { + notice_lang(s_NickServ, u, NICK_X_NOT_IN_USE, nick); + } else if (!(na = u2->na)) { + notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); + } else if (na->status & NS_VERBOTEN) { + notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); + } else if (na->nc->flags & NI_SUSPENDED) { + notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick); + } else if (stricmp(nick, u->nick) == 0) { + notice_lang(s_NickServ, u, NICK_NO_GHOST_SELF); + } else if (pass) { + int res = enc_check_password(pass, na->nc->pass); + if (res == 1) { + char buf[NICKMAX + 32]; + snprintf(buf, sizeof(buf), "GHOST command used by %s", + u->nick); + if (LimitSessions) { + del_session(u2->host); + } + kill_user(s_NickServ, nick, buf); + notice_lang(s_NickServ, u, NICK_GHOST_KILLED, nick); + } else { + notice_lang(s_NickServ, u, ACCESS_DENIED); + if (res == 0) { + alog("%s: GHOST: invalid password for %s by %s!%s@%s", + s_NickServ, nick, u->nick, u->username, u->host); + bad_password(u); + } + } + } else { + if (group_identified(u, na->nc) + || (!(na->nc->flags & NI_SECURE) && is_on_access(u, na->nc))) { + char buf[NICKMAX + 32]; + snprintf(buf, sizeof(buf), "GHOST command used by %s", + u->nick); + if (LimitSessions) { + del_session(u2->host); + } + kill_user(s_NickServ, nick, buf); + notice_lang(s_NickServ, u, NICK_GHOST_KILLED, nick); + } else { + notice_lang(s_NickServ, u, ACCESS_DENIED); + } + } + return MOD_CONT; } MODULE_INIT("ns_ghost", NSGhost) diff --git a/src/core/ns_group.c b/src/core/ns_group.c index b420be531..14ce0386f 100644 --- a/src/core/ns_group.c +++ b/src/core/ns_group.c @@ -60,8 +60,8 @@ class NSGroup : public Module **/ void myNickServHelp(User * u) { - notice_lang(s_NickServ, u, NICK_HELP_CMD_GROUP); - notice_lang(s_NickServ, u, NICK_HELP_CMD_GLIST); + notice_lang(s_NickServ, u, NICK_HELP_CMD_GROUP); + notice_lang(s_NickServ, u, NICK_HELP_CMD_GLIST); } /** @@ -73,162 +73,162 @@ void myNickServHelp(User * u) int do_group(User * u) { - NickAlias *na, *target; - NickCore *nc; - char *nick = strtok(NULL, " "); - char *pass = strtok(NULL, " "); - int i; - char tsbuf[16]; - char modes[512]; - int len; - - if (NSEmailReg && (findrequestnick(u->nick))) { - notice_lang(s_NickServ, u, NICK_REQUESTED); - return MOD_CONT; - } - - if (readonly) { - notice_lang(s_NickServ, u, NICK_GROUP_DISABLED); - return MOD_CONT; - } - if (checkDefCon(DEFCON_NO_NEW_NICKS)) { - notice_lang(s_NickServ, u, OPER_DEFCON_DENIED); - return MOD_CONT; - } - - if (RestrictOperNicks) { - for (i = 0; i < RootNumber; i++) { - if (stristr(u->nick, ServicesRoots[i]) && !is_oper(u)) { - notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, - u->nick); - return MOD_CONT; - } - } - for (i = 0; i < servadmins.count && (nc = (NickCore *)servadmins.list[i]); i++) { - if (stristr(u->nick, nc->display) && !is_oper(u)) { - notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, - u->nick); - return MOD_CONT; - } - } - for (i = 0; i < servopers.count && (nc = (NickCore *)servopers.list[i]); i++) { - if (stristr(u->nick, nc->display) && !is_oper(u)) { - notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, - u->nick); - return MOD_CONT; - } - } - } - - if (!nick || !pass) { - syntax_error(s_NickServ, u, "GROUP", NICK_GROUP_SYNTAX); - } else if (!(target = findnick(nick))) { - notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); - } else if (time(NULL) < u->lastnickreg + NSRegDelay) { - notice_lang(s_NickServ, u, NICK_GROUP_PLEASE_WAIT, NSRegDelay); - } else if (u->na && (u->na->status & NS_VERBOTEN)) { - alog("%s: %s@%s tried to use GROUP from FORBIDden nick %s", - s_NickServ, u->username, u->host, u->nick); - notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, u->nick); - } else if (u->na && (u->na->nc->flags & NI_SUSPENDED)) { - alog("%s: %s!%s@%s tried to use GROUP from SUSPENDED nick %s", - s_NickServ, u->nick, u->username, u->host, target->nick); - notice_lang(s_NickServ, u, NICK_X_SUSPENDED, u->nick); - } else if (u->na && NSNoGroupChange) { - notice_lang(s_NickServ, u, NICK_GROUP_CHANGE_DISABLED, s_NickServ); - } else if (u->na && !nick_identified(u)) { - notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); - } else if (target && (target->nc->flags & NI_SUSPENDED)) { - alog("%s: %s!%s@%s tried to use GROUP from SUSPENDED nick %s", - s_NickServ, u->nick, u->username, u->host, target->nick); - notice_lang(s_NickServ, u, NICK_X_SUSPENDED, target->nick); - } else if (target->status & NS_VERBOTEN) { - notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, nick); - } else if (u->na && target->nc == u->na->nc) { - notice_lang(s_NickServ, u, NICK_GROUP_SAME, target->nick); - } else if (NSMaxAliases && (target->nc->aliases.count >= NSMaxAliases) - && !nick_is_services_admin(target->nc)) { - notice_lang(s_NickServ, u, NICK_GROUP_TOO_MANY, target->nick, - s_NickServ, s_NickServ); - } else if (enc_check_password(pass, target->nc->pass) != 1) { - alog("%s: Failed GROUP for %s!%s@%s (invalid password)", - s_NickServ, u->nick, u->username, u->host); - notice_lang(s_NickServ, u, PASSWORD_INCORRECT); - bad_password(u); - } else { - /* If the nick is already registered, drop it. - * If not, check that it is valid. - */ - if (u->na) { - delnick(u->na); - } else { - int prefixlen = strlen(NSGuestNickPrefix); - int nicklen = strlen(u->nick); - - if (nicklen <= prefixlen + 7 && nicklen >= prefixlen + 1 - && stristr(u->nick, NSGuestNickPrefix) == u->nick - && strspn(u->nick + prefixlen, - "1234567890") == nicklen - prefixlen) { - notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, - u->nick); - return MOD_CONT; - } - } - na = makealias(u->nick, target->nc); - - if (na) { - na->last_usermask = - (char *)scalloc(strlen(common_get_vident(u)) + - strlen(common_get_vhost(u)) + 2, 1); - sprintf(na->last_usermask, "%s@%s", common_get_vident(u), - common_get_vhost(u)); - na->last_realname = sstrdup(u->realname); - na->time_registered = na->last_seen = time(NULL); - na->status = (int16) (NS_IDENTIFIED | NS_RECOGNIZED); - - if (!(na->nc->flags & NI_SERVICES_ROOT)) { - for (i = 0; i < RootNumber; i++) { - if (!stricmp(ServicesRoots[i], u->nick)) { - na->nc->flags |= NI_SERVICES_ROOT; - break; - } - } - } - - u->na = na; - na->u = u; - - send_event(EVENT_GROUP, 1, u->nick); - alog("%s: %s!%s@%s makes %s join group of %s (%s) (e-mail: %s)", s_NickServ, u->nick, u->username, u->host, u->nick, target->nick, target->nc->display, (target->nc->email ? target->nc->email : "none")); - notice_lang(s_NickServ, u, NICK_GROUP_JOINED, target->nick); - - u->lastnickreg = time(NULL); - snprintf(tsbuf, sizeof(tsbuf), "%lu", - (unsigned long int) u->timestamp); - if (ircd->modeonreg) { - len = strlen(ircd->modeonreg); - strncpy(modes,ircd->modeonreg,512); - if(ircd->rootmodeonid && is_services_root(u)) { - strncat(modes,ircd->rootmodeonid,512-len); - } else if(ircd->adminmodeonid && is_services_admin(u)) { - strncat(modes,ircd->adminmodeonid,512-len); - } else if(ircd->opermodeonid && is_services_oper(u)) { - strncat(modes,ircd->opermodeonid,512-len); - } - if (ircd->tsonmode) { - common_svsmode(u, modes, tsbuf); - } else { - common_svsmode(u, modes, NULL); - } - } - - check_memos(u); - } else { - alog("%s: makealias(%s) failed", s_NickServ, u->nick); - notice_lang(s_NickServ, u, NICK_GROUP_FAILED); - } - } - return MOD_CONT; + NickAlias *na, *target; + NickCore *nc; + char *nick = strtok(NULL, " "); + char *pass = strtok(NULL, " "); + int i; + char tsbuf[16]; + char modes[512]; + int len; + + if (NSEmailReg && (findrequestnick(u->nick))) { + notice_lang(s_NickServ, u, NICK_REQUESTED); + return MOD_CONT; + } + + if (readonly) { + notice_lang(s_NickServ, u, NICK_GROUP_DISABLED); + return MOD_CONT; + } + if (checkDefCon(DEFCON_NO_NEW_NICKS)) { + notice_lang(s_NickServ, u, OPER_DEFCON_DENIED); + return MOD_CONT; + } + + if (RestrictOperNicks) { + for (i = 0; i < RootNumber; i++) { + if (stristr(u->nick, ServicesRoots[i]) && !is_oper(u)) { + notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, + u->nick); + return MOD_CONT; + } + } + for (i = 0; i < servadmins.count && (nc = (NickCore *)servadmins.list[i]); i++) { + if (stristr(u->nick, nc->display) && !is_oper(u)) { + notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, + u->nick); + return MOD_CONT; + } + } + for (i = 0; i < servopers.count && (nc = (NickCore *)servopers.list[i]); i++) { + if (stristr(u->nick, nc->display) && !is_oper(u)) { + notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, + u->nick); + return MOD_CONT; + } + } + } + + if (!nick || !pass) { + syntax_error(s_NickServ, u, "GROUP", NICK_GROUP_SYNTAX); + } else if (!(target = findnick(nick))) { + notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); + } else if (time(NULL) < u->lastnickreg + NSRegDelay) { + notice_lang(s_NickServ, u, NICK_GROUP_PLEASE_WAIT, NSRegDelay); + } else if (u->na && (u->na->status & NS_VERBOTEN)) { + alog("%s: %s@%s tried to use GROUP from FORBIDden nick %s", + s_NickServ, u->username, u->host, u->nick); + notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, u->nick); + } else if (u->na && (u->na->nc->flags & NI_SUSPENDED)) { + alog("%s: %s!%s@%s tried to use GROUP from SUSPENDED nick %s", + s_NickServ, u->nick, u->username, u->host, target->nick); + notice_lang(s_NickServ, u, NICK_X_SUSPENDED, u->nick); + } else if (u->na && NSNoGroupChange) { + notice_lang(s_NickServ, u, NICK_GROUP_CHANGE_DISABLED, s_NickServ); + } else if (u->na && !nick_identified(u)) { + notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); + } else if (target && (target->nc->flags & NI_SUSPENDED)) { + alog("%s: %s!%s@%s tried to use GROUP from SUSPENDED nick %s", + s_NickServ, u->nick, u->username, u->host, target->nick); + notice_lang(s_NickServ, u, NICK_X_SUSPENDED, target->nick); + } else if (target->status & NS_VERBOTEN) { + notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, nick); + } else if (u->na && target->nc == u->na->nc) { + notice_lang(s_NickServ, u, NICK_GROUP_SAME, target->nick); + } else if (NSMaxAliases && (target->nc->aliases.count >= NSMaxAliases) + && !nick_is_services_admin(target->nc)) { + notice_lang(s_NickServ, u, NICK_GROUP_TOO_MANY, target->nick, + s_NickServ, s_NickServ); + } else if (enc_check_password(pass, target->nc->pass) != 1) { + alog("%s: Failed GROUP for %s!%s@%s (invalid password)", + s_NickServ, u->nick, u->username, u->host); + notice_lang(s_NickServ, u, PASSWORD_INCORRECT); + bad_password(u); + } else { + /* If the nick is already registered, drop it. + * If not, check that it is valid. + */ + if (u->na) { + delnick(u->na); + } else { + int prefixlen = strlen(NSGuestNickPrefix); + int nicklen = strlen(u->nick); + + if (nicklen <= prefixlen + 7 && nicklen >= prefixlen + 1 + && stristr(u->nick, NSGuestNickPrefix) == u->nick + && strspn(u->nick + prefixlen, + "1234567890") == nicklen - prefixlen) { + notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, + u->nick); + return MOD_CONT; + } + } + na = makealias(u->nick, target->nc); + + if (na) { + na->last_usermask = + (char *)scalloc(strlen(common_get_vident(u)) + + strlen(common_get_vhost(u)) + 2, 1); + sprintf(na->last_usermask, "%s@%s", common_get_vident(u), + common_get_vhost(u)); + na->last_realname = sstrdup(u->realname); + na->time_registered = na->last_seen = time(NULL); + na->status = (int16) (NS_IDENTIFIED | NS_RECOGNIZED); + + if (!(na->nc->flags & NI_SERVICES_ROOT)) { + for (i = 0; i < RootNumber; i++) { + if (!stricmp(ServicesRoots[i], u->nick)) { + na->nc->flags |= NI_SERVICES_ROOT; + break; + } + } + } + + u->na = na; + na->u = u; + + send_event(EVENT_GROUP, 1, u->nick); + alog("%s: %s!%s@%s makes %s join group of %s (%s) (e-mail: %s)", s_NickServ, u->nick, u->username, u->host, u->nick, target->nick, target->nc->display, (target->nc->email ? target->nc->email : "none")); + notice_lang(s_NickServ, u, NICK_GROUP_JOINED, target->nick); + + u->lastnickreg = time(NULL); + snprintf(tsbuf, sizeof(tsbuf), "%lu", + (unsigned long int) u->timestamp); + if (ircd->modeonreg) { + len = strlen(ircd->modeonreg); + strncpy(modes,ircd->modeonreg,512); + if(ircd->rootmodeonid && is_services_root(u)) { + strncat(modes,ircd->rootmodeonid,512-len); + } else if(ircd->adminmodeonid && is_services_admin(u)) { + strncat(modes,ircd->adminmodeonid,512-len); + } else if(ircd->opermodeonid && is_services_oper(u)) { + strncat(modes,ircd->opermodeonid,512-len); + } + if (ircd->tsonmode) { + common_svsmode(u, modes, tsbuf); + } else { + common_svsmode(u, modes, NULL); + } + } + + check_memos(u); + } else { + alog("%s: makealias(%s) failed", s_NickServ, u->nick); + notice_lang(s_NickServ, u, NICK_GROUP_FAILED); + } + } + return MOD_CONT; } @@ -236,79 +236,79 @@ int do_group(User * u) NickAlias *makealias(const char *nick, NickCore * nc) { - NickAlias *na; - - /* Just need to make the alias */ - na = (NickAlias *)scalloc(1, sizeof(NickAlias)); - na->nick = sstrdup(nick); - na->nc = nc; - slist_add(&nc->aliases, na); - alpha_insert_alias(na); - return na; + NickAlias *na; + + /* Just need to make the alias */ + na = (NickAlias *)scalloc(1, sizeof(NickAlias)); + na->nick = sstrdup(nick); + na->nc = nc; + slist_add(&nc->aliases, na); + alpha_insert_alias(na); + return na; } int do_link(User * u) { - notice_lang(s_NickServ, u, OBSOLETE_COMMAND, "GROUP"); - return MOD_CONT; + notice_lang(s_NickServ, u, OBSOLETE_COMMAND, "GROUP"); + return MOD_CONT; } int do_glist(User * u) { - char *nick = strtok(NULL, " "); - - NickAlias *na, *na2; - int is_servadmin = is_services_admin(u); - int nick_ided = nick_identified(u); - int i; - - if ((nick ? (stricmp(nick, u->nick) ? !is_servadmin : !nick_ided) - : !nick_ided)) { - notice_lang(s_NickServ, u, - (nick_ided ? ACCESS_DENIED : - NICK_IDENTIFY_REQUIRED), s_NickServ); - } else if ((!nick ? !(na = u->na) : !(na = findnick(nick)))) { - notice_lang(s_NickServ, u, - (!nick ? NICK_NOT_REGISTERED : NICK_X_NOT_REGISTERED), - nick); - } else if (na->status & NS_VERBOTEN) { - notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); - } else { - time_t expt; - struct tm *tm; - char buf[BUFSIZE]; - int wont_expire; - - notice_lang(s_NickServ, u, - nick ? NICK_GLIST_HEADER_X : NICK_GLIST_HEADER, - na->nc->display); - for (i = 0; i < na->nc->aliases.count; i++) { - na2 = (NickAlias *)na->nc->aliases.list[i]; - if (na2->nc == na->nc) { - if (!(wont_expire = na2->status & NS_NO_EXPIRE)) { - expt = na2->last_seen + NSExpire; - tm = localtime(&expt); - strftime_lang(buf, sizeof(buf), na2->u, - STRFTIME_DATE_TIME_FORMAT, tm); - } - notice_lang(s_NickServ, u, - ((is_services_admin(u) && !wont_expire) - ? NICK_GLIST_REPLY_ADMIN : NICK_GLIST_REPLY), - (wont_expire ? '!' : ' '), na2->nick, buf); - } - } - notice_lang(s_NickServ, u, NICK_GLIST_FOOTER, - na->nc->aliases.count); - } - return MOD_CONT; + char *nick = strtok(NULL, " "); + + NickAlias *na, *na2; + int is_servadmin = is_services_admin(u); + int nick_ided = nick_identified(u); + int i; + + if ((nick ? (stricmp(nick, u->nick) ? !is_servadmin : !nick_ided) + : !nick_ided)) { + notice_lang(s_NickServ, u, + (nick_ided ? ACCESS_DENIED : + NICK_IDENTIFY_REQUIRED), s_NickServ); + } else if ((!nick ? !(na = u->na) : !(na = findnick(nick)))) { + notice_lang(s_NickServ, u, + (!nick ? NICK_NOT_REGISTERED : NICK_X_NOT_REGISTERED), + nick); + } else if (na->status & NS_VERBOTEN) { + notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); + } else { + time_t expt; + struct tm *tm; + char buf[BUFSIZE]; + int wont_expire; + + notice_lang(s_NickServ, u, + nick ? NICK_GLIST_HEADER_X : NICK_GLIST_HEADER, + na->nc->display); + for (i = 0; i < na->nc->aliases.count; i++) { + na2 = (NickAlias *)na->nc->aliases.list[i]; + if (na2->nc == na->nc) { + if (!(wont_expire = na2->status & NS_NO_EXPIRE)) { + expt = na2->last_seen + NSExpire; + tm = localtime(&expt); + strftime_lang(buf, sizeof(buf), na2->u, + STRFTIME_DATE_TIME_FORMAT, tm); + } + notice_lang(s_NickServ, u, + ((is_services_admin(u) && !wont_expire) + ? NICK_GLIST_REPLY_ADMIN : NICK_GLIST_REPLY), + (wont_expire ? '!' : ' '), na2->nick, buf); + } + } + notice_lang(s_NickServ, u, NICK_GLIST_FOOTER, + na->nc->aliases.count); + } + return MOD_CONT; } int do_listlinks(User * u) { - notice_lang(s_NickServ, u, OBSOLETE_COMMAND, "GLIST"); - return MOD_CONT; + notice_lang(s_NickServ, u, OBSOLETE_COMMAND, "GLIST"); + return MOD_CONT; } MODULE_INIT("ns_group", NSGroup) diff --git a/src/core/ns_help.c b/src/core/ns_help.c index ace2384f2..013a0589a 100644 --- a/src/core/ns_help.c +++ b/src/core/ns_help.c @@ -41,28 +41,28 @@ class NSHelp : public Module **/ int do_help(User * u) { - char *cmd = strtok(NULL, ""); + char *cmd = strtok(NULL, ""); - if (!cmd) { - notice_help(s_NickServ, u, NICK_HELP); - moduleDisplayHelp(1, u); - if (is_services_admin(u)) { - notice_help(s_NickServ, u, NICK_SERVADMIN_HELP); - } - if (NSExpire >= 86400) - notice_help(s_NickServ, u, NICK_HELP_EXPIRES, - NSExpire / 86400); - notice_help(s_NickServ, u, NICK_HELP_FOOTER); - } else if (stricmp(cmd, "SET LANGUAGE") == 0) { - int i; - notice_help(s_NickServ, u, NICK_HELP_SET_LANGUAGE); - for (i = 0; i < NUM_LANGS && langlist[i] >= 0; i++) - notice_user(s_NickServ, u, " %2d) %s", i + 1, - langnames[langlist[i]]); - } else { - mod_help_cmd(s_NickServ, u, NICKSERV, cmd); - } - return MOD_CONT; + if (!cmd) { + notice_help(s_NickServ, u, NICK_HELP); + moduleDisplayHelp(1, u); + if (is_services_admin(u)) { + notice_help(s_NickServ, u, NICK_SERVADMIN_HELP); + } + if (NSExpire >= 86400) + notice_help(s_NickServ, u, NICK_HELP_EXPIRES, + NSExpire / 86400); + notice_help(s_NickServ, u, NICK_HELP_FOOTER); + } else if (stricmp(cmd, "SET LANGUAGE") == 0) { + int i; + notice_help(s_NickServ, u, NICK_HELP_SET_LANGUAGE); + for (i = 0; i < NUM_LANGS && langlist[i] >= 0; i++) + notice_user(s_NickServ, u, " %2d) %s", i + 1, + langnames[langlist[i]]); + } else { + mod_help_cmd(s_NickServ, u, NICKSERV, cmd); + } + return MOD_CONT; } /* EOF */ diff --git a/src/core/ns_identify.c b/src/core/ns_identify.c index 89a33a89e..cd92731aa 100644 --- a/src/core/ns_identify.c +++ b/src/core/ns_identify.c @@ -15,8 +15,8 @@ #include "module.h" -#define TO_COLLIDE 0 /* Collide the user with this nick */ -#define TO_RELEASE 1 /* Release a collided nick */ +#define TO_COLLIDE 0 /* Collide the user with this nick */ +#define TO_RELEASE 1 /* Release a collided nick */ int do_identify(User * u); void myNickServHelp(User * u); @@ -51,7 +51,7 @@ class NSIdentify : public Module **/ void myNickServHelp(User * u) { - notice_lang(s_NickServ, u, NICK_HELP_CMD_IDENTIFY); + notice_lang(s_NickServ, u, NICK_HELP_CMD_IDENTIFY); } /** @@ -61,100 +61,100 @@ void myNickServHelp(User * u) **/ int do_identify(User * u) { - char *pass = strtok(NULL, " "); - NickAlias *na; - NickRequest *nr; - int res; - char tsbuf[16]; - char modes[512]; - int len; - - if (!pass) { - syntax_error(s_NickServ, u, "IDENTIFY", NICK_IDENTIFY_SYNTAX); - } else if (!(na = u->na)) { - if ((nr = findrequestnick(u->nick))) { - notice_lang(s_NickServ, u, NICK_IS_PREREG); - } else { - notice_lang(s_NickServ, u, NICK_NOT_REGISTERED); - } - } else if (na->status & NS_VERBOTEN) { - notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); - } else if (na->nc->flags & NI_SUSPENDED) { - notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick); - } else if (nick_identified(u)) { - notice_lang(s_NickServ, u, NICK_ALREADY_IDENTIFIED); - } else if (!(res = enc_check_password(pass, na->nc->pass))) { - alog("%s: Failed IDENTIFY for %s!%s@%s", s_NickServ, u->nick, - u->username, u->host); - notice_lang(s_NickServ, u, PASSWORD_INCORRECT); - bad_password(u); - } else if (res == -1) { - notice_lang(s_NickServ, u, NICK_IDENTIFY_FAILED); - } else { - if (!(na->status & NS_IDENTIFIED) && !(na->status & NS_RECOGNIZED)) { - if (na->last_usermask) - free(na->last_usermask); - na->last_usermask = - (char *)scalloc(strlen(common_get_vident(u)) + - strlen(common_get_vhost(u)) + 2, 1); - sprintf(na->last_usermask, "%s@%s", common_get_vident(u), - common_get_vhost(u)); - if (na->last_realname) - free(na->last_realname); - na->last_realname = sstrdup(u->realname); - } - - na->status |= NS_IDENTIFIED; - na->last_seen = time(NULL); - snprintf(tsbuf, sizeof(tsbuf), "%lu", - (unsigned long int) u->timestamp); - - if (ircd->modeonreg) { - len = strlen(ircd->modeonreg); - strncpy(modes,ircd->modeonreg,512); - if(ircd->rootmodeonid && is_services_root(u)) { - strncat(modes,ircd->rootmodeonid,512-len); - } else if(ircd->adminmodeonid && is_services_admin(u)) { - strncat(modes,ircd->adminmodeonid,512-len); - } else if(ircd->opermodeonid && is_services_oper(u)) { - strncat(modes,ircd->opermodeonid,512-len); - } - if (ircd->tsonmode) { - common_svsmode(u, modes, tsbuf); - } else { - common_svsmode(u, modes, ""); - } - } - send_event(EVENT_NICK_IDENTIFY, 1, u->nick); - alog("%s: %s!%s@%s identified for nick %s", s_NickServ, u->nick, - u->username, u->host, u->nick); - notice_lang(s_NickServ, u, NICK_IDENTIFY_SUCCEEDED); - if (ircd->vhost) { - do_on_id(u); - } - if (NSModeOnID) { - do_setmodes(u); - } - - if (NSForceEmail && u->na && !u->na->nc->email) { - notice_lang(s_NickServ, u, NICK_IDENTIFY_EMAIL_REQUIRED); - notice_help(s_NickServ, u, NICK_IDENTIFY_EMAIL_HOWTO); - } - - if (!(na->status & NS_RECOGNIZED)) - check_memos(u); - - /* Enable nick tracking if enabled */ - if (NSNickTracking) - nsStartNickTracking(u); - - /* Clear any timers */ - if (na->nc->flags & NI_KILLPROTECT) { - del_ns_timeout(na, TO_COLLIDE); - } - - } - return MOD_CONT; + char *pass = strtok(NULL, " "); + NickAlias *na; + NickRequest *nr; + int res; + char tsbuf[16]; + char modes[512]; + int len; + + if (!pass) { + syntax_error(s_NickServ, u, "IDENTIFY", NICK_IDENTIFY_SYNTAX); + } else if (!(na = u->na)) { + if ((nr = findrequestnick(u->nick))) { + notice_lang(s_NickServ, u, NICK_IS_PREREG); + } else { + notice_lang(s_NickServ, u, NICK_NOT_REGISTERED); + } + } else if (na->status & NS_VERBOTEN) { + notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); + } else if (na->nc->flags & NI_SUSPENDED) { + notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick); + } else if (nick_identified(u)) { + notice_lang(s_NickServ, u, NICK_ALREADY_IDENTIFIED); + } else if (!(res = enc_check_password(pass, na->nc->pass))) { + alog("%s: Failed IDENTIFY for %s!%s@%s", s_NickServ, u->nick, + u->username, u->host); + notice_lang(s_NickServ, u, PASSWORD_INCORRECT); + bad_password(u); + } else if (res == -1) { + notice_lang(s_NickServ, u, NICK_IDENTIFY_FAILED); + } else { + if (!(na->status & NS_IDENTIFIED) && !(na->status & NS_RECOGNIZED)) { + if (na->last_usermask) + free(na->last_usermask); + na->last_usermask = + (char *)scalloc(strlen(common_get_vident(u)) + + strlen(common_get_vhost(u)) + 2, 1); + sprintf(na->last_usermask, "%s@%s", common_get_vident(u), + common_get_vhost(u)); + if (na->last_realname) + free(na->last_realname); + na->last_realname = sstrdup(u->realname); + } + + na->status |= NS_IDENTIFIED; + na->last_seen = time(NULL); + snprintf(tsbuf, sizeof(tsbuf), "%lu", + (unsigned long int) u->timestamp); + + if (ircd->modeonreg) { + len = strlen(ircd->modeonreg); + strncpy(modes,ircd->modeonreg,512); + if(ircd->rootmodeonid && is_services_root(u)) { + strncat(modes,ircd->rootmodeonid,512-len); + } else if(ircd->adminmodeonid && is_services_admin(u)) { + strncat(modes,ircd->adminmodeonid,512-len); + } else if(ircd->opermodeonid && is_services_oper(u)) { + strncat(modes,ircd->opermodeonid,512-len); + } + if (ircd->tsonmode) { + common_svsmode(u, modes, tsbuf); + } else { + common_svsmode(u, modes, ""); + } + } + send_event(EVENT_NICK_IDENTIFY, 1, u->nick); + alog("%s: %s!%s@%s identified for nick %s", s_NickServ, u->nick, + u->username, u->host, u->nick); + notice_lang(s_NickServ, u, NICK_IDENTIFY_SUCCEEDED); + if (ircd->vhost) { + do_on_id(u); + } + if (NSModeOnID) { + do_setmodes(u); + } + + if (NSForceEmail && u->na && !u->na->nc->email) { + notice_lang(s_NickServ, u, NICK_IDENTIFY_EMAIL_REQUIRED); + notice_help(s_NickServ, u, NICK_IDENTIFY_EMAIL_HOWTO); + } + + if (!(na->status & NS_RECOGNIZED)) + check_memos(u); + + /* Enable nick tracking if enabled */ + if (NSNickTracking) + nsStartNickTracking(u); + + /* Clear any timers */ + if (na->nc->flags & NI_KILLPROTECT) { + del_ns_timeout(na, TO_COLLIDE); + } + + } + return MOD_CONT; } MODULE_INIT("ns_identify", NSIdentify) diff --git a/src/core/ns_info.c b/src/core/ns_info.c index 9644626ec..0ce3e0894 100644 --- a/src/core/ns_info.c +++ b/src/core/ns_info.c @@ -46,7 +46,7 @@ class NSInfo : public Module **/ void myNickServHelp(User * u) { - notice_lang(s_NickServ, u, NICK_HELP_CMD_INFO); + notice_lang(s_NickServ, u, NICK_HELP_CMD_INFO); } /** @@ -64,210 +64,210 @@ int do_info(User * u) * -TheShadow (13 Mar 1999) */ - char *nick = strtok(NULL, " "); - char *param = strtok(NULL, " "); + char *nick = strtok(NULL, " "); + char *param = strtok(NULL, " "); - NickAlias *na; - NickRequest *nr = NULL; + NickAlias *na; + NickRequest *nr = NULL; /* Being an oper is enough from now on -GD */ - int is_servadmin = is_services_oper(u); - - if (!nick) { - syntax_error(s_NickServ, u, "INFO", NICK_INFO_SYNTAX); - } else if (!(na = findnick(nick))) { - if ((nr = findrequestnick(nick))) { - notice_lang(s_NickServ, u, NICK_IS_PREREG); - if (param && stricmp(param, "ALL") == 0 && is_servadmin) { - notice_lang(s_NickServ, u, NICK_INFO_EMAIL, nr->email); - } else { - if (is_servadmin) { - notice_lang(s_NickServ, u, NICK_INFO_FOR_MORE, - s_NickServ, nr->nick); - } - } - } else if (nickIsServices(nick, 1)) { - notice_lang(s_NickServ, u, NICK_X_IS_SERVICES, nick); - } else { - notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); - } - } else if (na->status & NS_VERBOTEN) { - if (is_oper(u) && na->last_usermask) - notice_lang(s_NickServ, u, NICK_X_FORBIDDEN_OPER, nick, - na->last_usermask, - (na->last_realname ? na-> - last_realname : getstring(u->na, NO_REASON))); - else - notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, nick); - } else { - struct tm *tm; - char buf[BUFSIZE], *end; - const char *commastr = getstring(u->na, COMMA_SPACE); - int need_comma = 0; - int nick_online = 0; - int show_hidden = 0; - time_t expt; - - /* Is the real owner of the nick we're looking up online? -TheShadow */ - if (na->status & (NS_RECOGNIZED | NS_IDENTIFIED)) - nick_online = 1; - - /* Only show hidden fields to owner and sadmins and only when the ALL - * parameter is used. -TheShadow */ - if (param && stricmp(param, "ALL") == 0 && u->na - && ((nick_identified(u) && (na->nc == u->na->nc)) - || is_servadmin)) - show_hidden = 1; - - notice_lang(s_NickServ, u, NICK_INFO_REALNAME, na->nick, - na->last_realname); - - if ((nick_identified(u) && (na->nc == u->na->nc)) || is_servadmin) { - - if (nick_is_services_root(na->nc)) - notice_lang(s_NickServ, u, NICK_INFO_SERVICES_ROOT, - na->nick); - else if (nick_is_services_admin(na->nc)) - notice_lang(s_NickServ, u, NICK_INFO_SERVICES_ADMIN, - na->nick); - else if (nick_is_services_oper(na->nc)) - notice_lang(s_NickServ, u, NICK_INFO_SERVICES_OPER, - na->nick); - - } else { - - if (nick_is_services_root(na->nc) - && !(na->nc->flags & NI_HIDE_STATUS)) - notice_lang(s_NickServ, u, NICK_INFO_SERVICES_ROOT, - na->nick); - else if (nick_is_services_admin(na->nc) - && !(na->nc->flags & NI_HIDE_STATUS)) - notice_lang(s_NickServ, u, NICK_INFO_SERVICES_ADMIN, - na->nick); - else if (nick_is_services_oper(na->nc) - && !(na->nc->flags & NI_HIDE_STATUS)) - notice_lang(s_NickServ, u, NICK_INFO_SERVICES_OPER, - na->nick); - - } - - if (nick_online) { - if (show_hidden || !(na->nc->flags & NI_HIDE_MASK)) - notice_lang(s_NickServ, u, NICK_INFO_ADDRESS_ONLINE, - na->last_usermask); - else - notice_lang(s_NickServ, u, NICK_INFO_ADDRESS_ONLINE_NOHOST, - na->nick); - } else { - if (show_hidden || !(na->nc->flags & NI_HIDE_MASK)) - notice_lang(s_NickServ, u, NICK_INFO_ADDRESS, - na->last_usermask); - } - - tm = localtime(&na->time_registered); - strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm); - notice_lang(s_NickServ, u, NICK_INFO_TIME_REGGED, buf); - - if (!nick_online) { - tm = localtime(&na->last_seen); - strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, - tm); - notice_lang(s_NickServ, u, NICK_INFO_LAST_SEEN, buf); - } - - if (na->last_quit - && (show_hidden || !(na->nc->flags & NI_HIDE_QUIT))) - notice_lang(s_NickServ, u, NICK_INFO_LAST_QUIT, na->last_quit); - - if (na->nc->url) - notice_lang(s_NickServ, u, NICK_INFO_URL, na->nc->url); - if (na->nc->email - && (show_hidden || !(na->nc->flags & NI_HIDE_EMAIL))) - notice_lang(s_NickServ, u, NICK_INFO_EMAIL, na->nc->email); - if (na->nc->icq) - notice_lang(s_NickServ, u, NICK_INFO_ICQ, na->nc->icq); - - if (show_hidden) { - if (s_HostServ && ircd->vhost) { - if (getvHost(na->nick) != NULL) { - if (ircd->vident && getvIdent(na->nick) != NULL) { - notice_lang(s_NickServ, u, NICK_INFO_VHOST2, - getvIdent(na->nick), - getvHost(na->nick)); - } else { - notice_lang(s_NickServ, u, NICK_INFO_VHOST, - getvHost(na->nick)); - } - } - } - if (na->nc->greet) - notice_lang(s_NickServ, u, NICK_INFO_GREET, na->nc->greet); - - *buf = 0; - end = buf; - - if (na->nc->flags & NI_KILLPROTECT) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s", - getstring(u->na, NICK_INFO_OPT_KILL)); - need_comma = 1; - } - if (na->nc->flags & NI_SECURE) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, NICK_INFO_OPT_SECURE)); - need_comma = 1; - } - if (na->nc->flags & NI_PRIVATE) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, NICK_INFO_OPT_PRIVATE)); - need_comma = 1; - } - if (na->nc->flags & NI_MSG) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, NICK_INFO_OPT_MSG)); - need_comma = 1; - } - if (!(na->nc->flags & NI_AUTOOP)) { - end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", - need_comma ? commastr : "", - getstring(u->na, NICK_INFO_OPT_AUTOOP)); - need_comma = 1; - } - - notice_lang(s_NickServ, u, NICK_INFO_OPTIONS, - *buf ? buf : getstring(u->na, NICK_INFO_OPT_NONE)); - - if (na->nc->flags & NI_SUSPENDED) { - if (na->last_quit) { - notice_lang(s_NickServ, u, NICK_INFO_SUSPENDED, - na->last_quit); - } else { - notice_lang(s_NickServ, u, - NICK_INFO_SUSPENDED_NO_REASON); - } - } - - if (na->status & NS_NO_EXPIRE) { - notice_lang(s_NickServ, u, NICK_INFO_NO_EXPIRE); - } else { - if (is_services_admin(u)) { - expt = na->last_seen + NSExpire; - tm = localtime(&expt); - strftime_lang(buf, sizeof(buf), na->u, - STRFTIME_DATE_TIME_FORMAT, tm); - notice_lang(s_NickServ, u, NICK_INFO_EXPIRE, buf); - } - } - } - - if (!show_hidden - && ((u->na && (na->nc == u->na->nc) && nick_identified(u)) - || is_servadmin)) - notice_lang(s_NickServ, u, NICK_INFO_FOR_MORE, s_NickServ, - na->nick); - } - return MOD_CONT; + int is_servadmin = is_services_oper(u); + + if (!nick) { + syntax_error(s_NickServ, u, "INFO", NICK_INFO_SYNTAX); + } else if (!(na = findnick(nick))) { + if ((nr = findrequestnick(nick))) { + notice_lang(s_NickServ, u, NICK_IS_PREREG); + if (param && stricmp(param, "ALL") == 0 && is_servadmin) { + notice_lang(s_NickServ, u, NICK_INFO_EMAIL, nr->email); + } else { + if (is_servadmin) { + notice_lang(s_NickServ, u, NICK_INFO_FOR_MORE, + s_NickServ, nr->nick); + } + } + } else if (nickIsServices(nick, 1)) { + notice_lang(s_NickServ, u, NICK_X_IS_SERVICES, nick); + } else { + notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); + } + } else if (na->status & NS_VERBOTEN) { + if (is_oper(u) && na->last_usermask) + notice_lang(s_NickServ, u, NICK_X_FORBIDDEN_OPER, nick, + na->last_usermask, + (na->last_realname ? na-> + last_realname : getstring(u->na, NO_REASON))); + else + notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, nick); + } else { + struct tm *tm; + char buf[BUFSIZE], *end; + const char *commastr = getstring(u->na, COMMA_SPACE); + int need_comma = 0; + int nick_online = 0; + int show_hidden = 0; + time_t expt; + + /* Is the real owner of the nick we're looking up online? -TheShadow */ + if (na->status & (NS_RECOGNIZED | NS_IDENTIFIED)) + nick_online = 1; + + /* Only show hidden fields to owner and sadmins and only when the ALL + * parameter is used. -TheShadow */ + if (param && stricmp(param, "ALL") == 0 && u->na + && ((nick_identified(u) && (na->nc == u->na->nc)) + || is_servadmin)) + show_hidden = 1; + + notice_lang(s_NickServ, u, NICK_INFO_REALNAME, na->nick, + na->last_realname); + + if ((nick_identified(u) && (na->nc == u->na->nc)) || is_servadmin) { + + if (nick_is_services_root(na->nc)) + notice_lang(s_NickServ, u, NICK_INFO_SERVICES_ROOT, + na->nick); + else if (nick_is_services_admin(na->nc)) + notice_lang(s_NickServ, u, NICK_INFO_SERVICES_ADMIN, + na->nick); + else if (nick_is_services_oper(na->nc)) + notice_lang(s_NickServ, u, NICK_INFO_SERVICES_OPER, + na->nick); + + } else { + + if (nick_is_services_root(na->nc) + && !(na->nc->flags & NI_HIDE_STATUS)) + notice_lang(s_NickServ, u, NICK_INFO_SERVICES_ROOT, + na->nick); + else if (nick_is_services_admin(na->nc) + && !(na->nc->flags & NI_HIDE_STATUS)) + notice_lang(s_NickServ, u, NICK_INFO_SERVICES_ADMIN, + na->nick); + else if (nick_is_services_oper(na->nc) + && !(na->nc->flags & NI_HIDE_STATUS)) + notice_lang(s_NickServ, u, NICK_INFO_SERVICES_OPER, + na->nick); + + } + + if (nick_online) { + if (show_hidden || !(na->nc->flags & NI_HIDE_MASK)) + notice_lang(s_NickServ, u, NICK_INFO_ADDRESS_ONLINE, + na->last_usermask); + else + notice_lang(s_NickServ, u, NICK_INFO_ADDRESS_ONLINE_NOHOST, + na->nick); + } else { + if (show_hidden || !(na->nc->flags & NI_HIDE_MASK)) + notice_lang(s_NickServ, u, NICK_INFO_ADDRESS, + na->last_usermask); + } + + tm = localtime(&na->time_registered); + strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm); + notice_lang(s_NickServ, u, NICK_INFO_TIME_REGGED, buf); + + if (!nick_online) { + tm = localtime(&na->last_seen); + strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, + tm); + notice_lang(s_NickServ, u, NICK_INFO_LAST_SEEN, buf); + } + + if (na->last_quit + && (show_hidden || !(na->nc->flags & NI_HIDE_QUIT))) + notice_lang(s_NickServ, u, NICK_INFO_LAST_QUIT, na->last_quit); + + if (na->nc->url) + notice_lang(s_NickServ, u, NICK_INFO_URL, na->nc->url); + if (na->nc->email + && (show_hidden || !(na->nc->flags & NI_HIDE_EMAIL))) + notice_lang(s_NickServ, u, NICK_INFO_EMAIL, na->nc->email); + if (na->nc->icq) + notice_lang(s_NickServ, u, NICK_INFO_ICQ, na->nc->icq); + + if (show_hidden) { + if (s_HostServ && ircd->vhost) { + if (getvHost(na->nick) != NULL) { + if (ircd->vident && getvIdent(na->nick) != NULL) { + notice_lang(s_NickServ, u, NICK_INFO_VHOST2, + getvIdent(na->nick), + getvHost(na->nick)); + } else { + notice_lang(s_NickServ, u, NICK_INFO_VHOST, + getvHost(na->nick)); + } + } + } + if (na->nc->greet) + notice_lang(s_NickServ, u, NICK_INFO_GREET, na->nc->greet); + + *buf = 0; + end = buf; + + if (na->nc->flags & NI_KILLPROTECT) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s", + getstring(u->na, NICK_INFO_OPT_KILL)); + need_comma = 1; + } + if (na->nc->flags & NI_SECURE) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, NICK_INFO_OPT_SECURE)); + need_comma = 1; + } + if (na->nc->flags & NI_PRIVATE) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, NICK_INFO_OPT_PRIVATE)); + need_comma = 1; + } + if (na->nc->flags & NI_MSG) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, NICK_INFO_OPT_MSG)); + need_comma = 1; + } + if (!(na->nc->flags & NI_AUTOOP)) { + end += snprintf(end, sizeof(buf) - (end - buf), "%s%s", + need_comma ? commastr : "", + getstring(u->na, NICK_INFO_OPT_AUTOOP)); + need_comma = 1; + } + + notice_lang(s_NickServ, u, NICK_INFO_OPTIONS, + *buf ? buf : getstring(u->na, NICK_INFO_OPT_NONE)); + + if (na->nc->flags & NI_SUSPENDED) { + if (na->last_quit) { + notice_lang(s_NickServ, u, NICK_INFO_SUSPENDED, + na->last_quit); + } else { + notice_lang(s_NickServ, u, + NICK_INFO_SUSPENDED_NO_REASON); + } + } + + if (na->status & NS_NO_EXPIRE) { + notice_lang(s_NickServ, u, NICK_INFO_NO_EXPIRE); + } else { + if (is_services_admin(u)) { + expt = na->last_seen + NSExpire; + tm = localtime(&expt); + strftime_lang(buf, sizeof(buf), na->u, + STRFTIME_DATE_TIME_FORMAT, tm); + notice_lang(s_NickServ, u, NICK_INFO_EXPIRE, buf); + } + } + } + + if (!show_hidden + && ((u->na && (na->nc == u->na->nc) && nick_identified(u)) + || is_servadmin)) + notice_lang(s_NickServ, u, NICK_INFO_FOR_MORE, s_NickServ, + na->nick); + } + return MOD_CONT; } MODULE_INIT("ns_info", NSInfo) diff --git a/src/core/ns_list.c b/src/core/ns_list.c index ed4ba9ab4..795eba051 100644 --- a/src/core/ns_list.c +++ b/src/core/ns_list.c @@ -45,9 +45,9 @@ class NSList : public Module **/ void myNickServHelp(User * u) { - if (!NSListOpersOnly || (is_oper(u))) { - notice_lang(s_NickServ, u, NICK_HELP_CMD_LIST); - } + if (!NSListOpersOnly || (is_oper(u))) { + notice_lang(s_NickServ, u, NICK_HELP_CMD_LIST); + } } /** @@ -73,164 +73,164 @@ int do_list(User * u) */ - char *pattern = strtok(NULL, " "); - char *keyword; - NickAlias *na; - NickCore *mync; - int nnicks, i; - char buf[BUFSIZE]; - int is_servadmin = is_services_admin(u); - int16 matchflags = 0; - NickRequest *nr = NULL; - int nronly = 0; - int susp_keyword = 0; - char noexpire_char = ' '; - int count = 0, from = 0, to = 0, tofree = 0; - char *tmp = NULL; - char *s = NULL; - - if (!(!NSListOpersOnly || (is_oper(u)))) { /* reverse the help logic */ - notice_lang(s_NickServ, u, ACCESS_DENIED); - return MOD_STOP; - } - - if (!pattern) { - syntax_error(s_NickServ, u, "LIST", - is_servadmin ? NICK_LIST_SERVADMIN_SYNTAX : - NICK_LIST_SYNTAX); - } else { - - if (pattern) { - if (pattern[0] == '#') { - tmp = myStrGetOnlyToken((pattern + 1), '-', 0); /* Read FROM out */ - if (!tmp) { - notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); - return MOD_CONT; - } - for (s = tmp; *s; s++) { - if (!isdigit(*s)) { - free(tmp); - notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); - return MOD_CONT; - } - } - from = atoi(tmp); - free(tmp); - tmp = myStrGetTokenRemainder(pattern, '-', 1); /* Read TO out */ - if (!tmp) { - notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); - return MOD_CONT; - } - for (s = tmp; *s; s++) { - if (!isdigit(*s)) { - free(tmp); - notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); - return MOD_CONT; - } - } - to = atoi(tmp); - free(tmp); - pattern = sstrdup("*"); - tofree = 1; - } - } - - nnicks = 0; - - while (is_servadmin && (keyword = strtok(NULL, " "))) { - if (stricmp(keyword, "FORBIDDEN") == 0) - matchflags |= NS_VERBOTEN; - if (stricmp(keyword, "NOEXPIRE") == 0) - matchflags |= NS_NO_EXPIRE; - if (stricmp(keyword, "SUSPENDED") == 0) - susp_keyword = 1; - if (stricmp(keyword, "UNCONFIRMED") == 0) - nronly = 1; - } - - mync = (nick_identified(u) ? u->na->nc : NULL); - - notice_lang(s_NickServ, u, NICK_LIST_HEADER, pattern); - if (nronly != 1) { - for (i = 0; i < 1024; i++) { - for (na = nalists[i]; na; na = na->next) { - /* Don't show private and forbidden nicks to non-services admins. */ - if ((na->status & NS_VERBOTEN) && !is_servadmin) - continue; - if ((na->nc->flags & NI_PRIVATE) && !is_servadmin - && na->nc != mync) - continue; - if ((matchflags != 0) && !(na->status & matchflags) && (susp_keyword == 0)) - continue; - else if ((susp_keyword == 1) && !(na->nc->flags & NI_SUSPENDED)) - continue; - - /* We no longer compare the pattern against the output buffer. - * Instead we build a nice nick!user@host buffer to compare. - * The output is then generated separately. -TheShadow */ - snprintf(buf, sizeof(buf), "%s!%s", na->nick, - (na->last_usermask - && !(na->status & NS_VERBOTEN)) ? na-> - last_usermask : "*@*"); - if (stricmp(pattern, na->nick) == 0 - || match_wild_nocase(pattern, buf)) { - - if ((((count + 1 >= from) && (count + 1 <= to)) - || ((from == 0) && (to == 0))) - && (++nnicks <= NSListMax)) { - if (is_servadmin - && (na->status & NS_NO_EXPIRE)) - noexpire_char = '!'; - else { - noexpire_char = ' '; - } - if ((na->nc->flags & NI_HIDE_MASK) - && !is_servadmin && na->nc != mync) { - snprintf(buf, sizeof(buf), - "%-20s [Hostname Hidden]", - na->nick); - } else if (na->status & NS_VERBOTEN) { - snprintf(buf, sizeof(buf), - "%-20s [Forbidden]", na->nick); - } else if (na->nc->flags & NI_SUSPENDED) { - snprintf(buf, sizeof(buf), - "%-20s [Suspended]", na->nick); - } else { - snprintf(buf, sizeof(buf), "%-20s %s", - na->nick, na->last_usermask); - } - notice_user(s_NickServ, u, " %c%s", - noexpire_char, buf); - } - count++; - } - } - } - } - - if (nronly == 1 || (is_servadmin && matchflags == 0)) { - noexpire_char = ' '; - for (i = 0; i < 1024; i++) { - for (nr = nrlists[i]; nr; nr = nr->next) { - snprintf(buf, sizeof(buf), "%s!*@*", nr->nick); - if (stricmp(pattern, nr->nick) == 0 - || match_wild_nocase(pattern, buf)) { - if (++nnicks <= NSListMax) { - snprintf(buf, sizeof(buf), - "%-20s [UNCONFIRMED]", nr->nick); - notice_user(s_NickServ, u, " %c%s", - noexpire_char, buf); - } - } - } - } - } - notice_lang(s_NickServ, u, NICK_LIST_RESULTS, - nnicks > NSListMax ? NSListMax : nnicks, nnicks); - } - if (tofree) - free(pattern); - return MOD_CONT; + char *pattern = strtok(NULL, " "); + char *keyword; + NickAlias *na; + NickCore *mync; + int nnicks, i; + char buf[BUFSIZE]; + int is_servadmin = is_services_admin(u); + int16 matchflags = 0; + NickRequest *nr = NULL; + int nronly = 0; + int susp_keyword = 0; + char noexpire_char = ' '; + int count = 0, from = 0, to = 0, tofree = 0; + char *tmp = NULL; + char *s = NULL; + + if (!(!NSListOpersOnly || (is_oper(u)))) { /* reverse the help logic */ + notice_lang(s_NickServ, u, ACCESS_DENIED); + return MOD_STOP; + } + + if (!pattern) { + syntax_error(s_NickServ, u, "LIST", + is_servadmin ? NICK_LIST_SERVADMIN_SYNTAX : + NICK_LIST_SYNTAX); + } else { + + if (pattern) { + if (pattern[0] == '#') { + tmp = myStrGetOnlyToken((pattern + 1), '-', 0); /* Read FROM out */ + if (!tmp) { + notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); + return MOD_CONT; + } + for (s = tmp; *s; s++) { + if (!isdigit(*s)) { + free(tmp); + notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); + return MOD_CONT; + } + } + from = atoi(tmp); + free(tmp); + tmp = myStrGetTokenRemainder(pattern, '-', 1); /* Read TO out */ + if (!tmp) { + notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); + return MOD_CONT; + } + for (s = tmp; *s; s++) { + if (!isdigit(*s)) { + free(tmp); + notice_lang(s_ChanServ, u, LIST_INCORRECT_RANGE); + return MOD_CONT; + } + } + to = atoi(tmp); + free(tmp); + pattern = sstrdup("*"); + tofree = 1; + } + } + + nnicks = 0; + + while (is_servadmin && (keyword = strtok(NULL, " "))) { + if (stricmp(keyword, "FORBIDDEN") == 0) + matchflags |= NS_VERBOTEN; + if (stricmp(keyword, "NOEXPIRE") == 0) + matchflags |= NS_NO_EXPIRE; + if (stricmp(keyword, "SUSPENDED") == 0) + susp_keyword = 1; + if (stricmp(keyword, "UNCONFIRMED") == 0) + nronly = 1; + } + + mync = (nick_identified(u) ? u->na->nc : NULL); + + notice_lang(s_NickServ, u, NICK_LIST_HEADER, pattern); + if (nronly != 1) { + for (i = 0; i < 1024; i++) { + for (na = nalists[i]; na; na = na->next) { + /* Don't show private and forbidden nicks to non-services admins. */ + if ((na->status & NS_VERBOTEN) && !is_servadmin) + continue; + if ((na->nc->flags & NI_PRIVATE) && !is_servadmin + && na->nc != mync) + continue; + if ((matchflags != 0) && !(na->status & matchflags) && (susp_keyword == 0)) + continue; + else if ((susp_keyword == 1) && !(na->nc->flags & NI_SUSPENDED)) + continue; + + /* We no longer compare the pattern against the output buffer. + * Instead we build a nice nick!user@host buffer to compare. + * The output is then generated separately. -TheShadow */ + snprintf(buf, sizeof(buf), "%s!%s", na->nick, + (na->last_usermask + && !(na->status & NS_VERBOTEN)) ? na-> + last_usermask : "*@*"); + if (stricmp(pattern, na->nick) == 0 + || match_wild_nocase(pattern, buf)) { + + if ((((count + 1 >= from) && (count + 1 <= to)) + || ((from == 0) && (to == 0))) + && (++nnicks <= NSListMax)) { + if (is_servadmin + && (na->status & NS_NO_EXPIRE)) + noexpire_char = '!'; + else { + noexpire_char = ' '; + } + if ((na->nc->flags & NI_HIDE_MASK) + && !is_servadmin && na->nc != mync) { + snprintf(buf, sizeof(buf), + "%-20s [Hostname Hidden]", + na->nick); + } else if (na->status & NS_VERBOTEN) { + snprintf(buf, sizeof(buf), + "%-20s [Forbidden]", na->nick); + } else if (na->nc->flags & NI_SUSPENDED) { + snprintf(buf, sizeof(buf), + "%-20s [Suspended]", na->nick); + } else { + snprintf(buf, sizeof(buf), "%-20s %s", + na->nick, na->last_usermask); + } + notice_user(s_NickServ, u, " %c%s", + noexpire_char, buf); + } + count++; + } + } + } + } + + if (nronly == 1 || (is_servadmin && matchflags == 0)) { + noexpire_char = ' '; + for (i = 0; i < 1024; i++) { + for (nr = nrlists[i]; nr; nr = nr->next) { + snprintf(buf, sizeof(buf), "%s!*@*", nr->nick); + if (stricmp(pattern, nr->nick) == 0 + || match_wild_nocase(pattern, buf)) { + if (++nnicks <= NSListMax) { + snprintf(buf, sizeof(buf), + "%-20s [UNCONFIRMED]", nr->nick); + notice_user(s_NickServ, u, " %c%s", + noexpire_char, buf); + } + } + } + } + } + notice_lang(s_NickServ, u, NICK_LIST_RESULTS, + nnicks > NSListMax ? NSListMax : nnicks, nnicks); + } + if (tofree) + free(pattern); + return MOD_CONT; } MODULE_INIT("ns_list", NSList) diff --git a/src/core/ns_logout.c b/src/core/ns_logout.c index f523dc072..fa7c69d96 100644 --- a/src/core/ns_logout.c +++ b/src/core/ns_logout.c @@ -15,8 +15,8 @@ #include "module.h" -#define TO_COLLIDE 0 /* Collide the user with this nick */ -#define TO_RELEASE 1 /* Release a collided nick */ +#define TO_COLLIDE 0 /* Collide the user with this nick */ +#define TO_RELEASE 1 /* Release a collided nick */ int do_logout(User * u); void myNickServHelp(User * u); @@ -47,7 +47,7 @@ class NSLogout : public Module **/ void myNickServHelp(User * u) { - notice_lang(s_NickServ, u, NICK_HELP_CMD_LOGOUT); + notice_lang(s_NickServ, u, NICK_HELP_CMD_LOGOUT); } /** @@ -57,60 +57,60 @@ void myNickServHelp(User * u) **/ int do_logout(User * u) { - char *nick = strtok(NULL, " "); - char *param = strtok(NULL, " "); - User *u2; - - if (!is_services_admin(u) && nick) { - syntax_error(s_NickServ, u, "LOGOUT", NICK_LOGOUT_SYNTAX); - } else if (!(u2 = (nick ? finduser(nick) : u))) { - notice_lang(s_NickServ, u, NICK_X_NOT_IN_USE, nick); - } else if (!u2->na) { - if (nick) - notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); - else - notice_lang(s_NickServ, u, NICK_NOT_REGISTERED); - } else if (u2->na->status & NS_VERBOTEN) { - notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, u2->na->nick); - } else if (!nick && !nick_identified(u)) { - notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); - } else if (nick && is_services_admin(u2)) { - notice_lang(s_NickServ, u, NICK_LOGOUT_SERVICESADMIN, nick); - } else { - if (nick && param && !stricmp(param, "REVALIDATE")) { - cancel_user(u2); - validate_user(u2); - } else { - u2->na->status &= ~(NS_IDENTIFIED | NS_RECOGNIZED); - } - - if (ircd->modeonreg) { - common_svsmode(u2, ircd->modeonunreg, "1"); - } - - u->isSuperAdmin = 0; /* Dont let people logout and remain a SuperAdmin */ - alog("%s: %s!%s@%s logged out nickname %s", s_NickServ, u->nick, - u->username, u->host, u2->nick); - - if (nick) - notice_lang(s_NickServ, u, NICK_LOGOUT_X_SUCCEEDED, nick); - else - notice_lang(s_NickServ, u, NICK_LOGOUT_SUCCEEDED); - - /* Stop nick tracking if enabled */ - if (NSNickTracking) + char *nick = strtok(NULL, " "); + char *param = strtok(NULL, " "); + User *u2; + + if (!is_services_admin(u) && nick) { + syntax_error(s_NickServ, u, "LOGOUT", NICK_LOGOUT_SYNTAX); + } else if (!(u2 = (nick ? finduser(nick) : u))) { + notice_lang(s_NickServ, u, NICK_X_NOT_IN_USE, nick); + } else if (!u2->na) { + if (nick) + notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); + else + notice_lang(s_NickServ, u, NICK_NOT_REGISTERED); + } else if (u2->na->status & NS_VERBOTEN) { + notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, u2->na->nick); + } else if (!nick && !nick_identified(u)) { + notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); + } else if (nick && is_services_admin(u2)) { + notice_lang(s_NickServ, u, NICK_LOGOUT_SERVICESADMIN, nick); + } else { + if (nick && param && !stricmp(param, "REVALIDATE")) { + cancel_user(u2); + validate_user(u2); + } else { + u2->na->status &= ~(NS_IDENTIFIED | NS_RECOGNIZED); + } + + if (ircd->modeonreg) { + common_svsmode(u2, ircd->modeonunreg, "1"); + } + + u->isSuperAdmin = 0; /* Dont let people logout and remain a SuperAdmin */ + alog("%s: %s!%s@%s logged out nickname %s", s_NickServ, u->nick, + u->username, u->host, u2->nick); + + if (nick) + notice_lang(s_NickServ, u, NICK_LOGOUT_X_SUCCEEDED, nick); + else + notice_lang(s_NickServ, u, NICK_LOGOUT_SUCCEEDED); + + /* Stop nick tracking if enabled */ + if (NSNickTracking) /* Shouldn't this be u2? -GD */ - nsStopNickTracking(u); + nsStopNickTracking(u); - /* Clear any timers again */ - if (u->na->nc->flags & NI_KILLPROTECT) { - del_ns_timeout(u->na, TO_COLLIDE); - } + /* Clear any timers again */ + if (u->na->nc->flags & NI_KILLPROTECT) { + del_ns_timeout(u->na, TO_COLLIDE); + } /* Send out an event */ send_event(EVENT_NICK_LOGOUT, 1, u2->nick); - } - return MOD_CONT; + } + return MOD_CONT; } MODULE_INIT("ns_logout", NSLogout) diff --git a/src/core/ns_recover.c b/src/core/ns_recover.c index 0180ca222..c055cbf93 100644 --- a/src/core/ns_recover.c +++ b/src/core/ns_recover.c @@ -45,7 +45,7 @@ class NSRecover : public Module **/ void myNickServHelp(User * u) { - notice_lang(s_NickServ, u, NICK_HELP_CMD_RECOVER); + notice_lang(s_NickServ, u, NICK_HELP_CMD_RECOVER); } /** @@ -54,15 +54,15 @@ void myNickServHelp(User * u) **/ int myHelpResonse(User * u) { - char relstr[192]; + char relstr[192]; - /* Convert NSReleaseTimeout seconds to string format */ - duration(u->na, relstr, sizeof(relstr), NSReleaseTimeout); - - notice_help(s_NickServ, u, NICK_HELP_RECOVER, relstr); - do_help_limited(s_NickServ, u, c); + /* Convert NSReleaseTimeout seconds to string format */ + duration(u->na, relstr, sizeof(relstr), NSReleaseTimeout); + + notice_help(s_NickServ, u, NICK_HELP_RECOVER, relstr); + do_help_limited(s_NickServ, u, c); - return MOD_CONT; + return MOD_CONT; } /** @@ -72,55 +72,55 @@ int myHelpResonse(User * u) **/ int do_recover(User * u) { - char *nick = strtok(NULL, " "); - char *pass = strtok(NULL, " "); - NickAlias *na; - User *u2; - - if (!nick) { - syntax_error(s_NickServ, u, "RECOVER", NICK_RECOVER_SYNTAX); - } else if (!(u2 = finduser(nick))) { - notice_lang(s_NickServ, u, NICK_X_NOT_IN_USE, nick); - } else if (!(na = u2->na)) { - notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); - } else if (na->status & NS_VERBOTEN) { - notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); - } else if (na->nc->flags & NI_SUSPENDED) { - notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick); - } else if (stricmp(nick, u->nick) == 0) { - notice_lang(s_NickServ, u, NICK_NO_RECOVER_SELF); - } else if (pass) { - int res = enc_check_password(pass, na->nc->pass); - - if (res == 1) { - char relstr[192]; - - notice_lang(s_NickServ, u2, FORCENICKCHANGE_NOW); - collide(na, 0); - - /* Convert NSReleaseTimeout seconds to string format */ - duration(u2->na, relstr, sizeof(relstr), NSReleaseTimeout); - - notice_lang(s_NickServ, u, NICK_RECOVERED, s_NickServ, nick, relstr); - } else { - notice_lang(s_NickServ, u, ACCESS_DENIED); - if (res == 0) { - alog("%s: RECOVER: invalid password for %s by %s!%s@%s", - s_NickServ, nick, u->nick, u->username, u->host); - bad_password(u); - } - } - } else { - if (group_identified(u, na->nc) - || (!(na->nc->flags & NI_SECURE) && is_on_access(u, na->nc))) { - notice_lang(s_NickServ, u2, FORCENICKCHANGE_NOW); - collide(na, 0); - notice_lang(s_NickServ, u, NICK_RECOVERED, s_NickServ, nick); - } else { - notice_lang(s_NickServ, u, ACCESS_DENIED); - } - } - return MOD_CONT; + char *nick = strtok(NULL, " "); + char *pass = strtok(NULL, " "); + NickAlias *na; + User *u2; + + if (!nick) { + syntax_error(s_NickServ, u, "RECOVER", NICK_RECOVER_SYNTAX); + } else if (!(u2 = finduser(nick))) { + notice_lang(s_NickServ, u, NICK_X_NOT_IN_USE, nick); + } else if (!(na = u2->na)) { + notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); + } else if (na->status & NS_VERBOTEN) { + notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); + } else if (na->nc->flags & NI_SUSPENDED) { + notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick); + } else if (stricmp(nick, u->nick) == 0) { + notice_lang(s_NickServ, u, NICK_NO_RECOVER_SELF); + } else if (pass) { + int res = enc_check_password(pass, na->nc->pass); + + if (res == 1) { + char relstr[192]; + + notice_lang(s_NickServ, u2, FORCENICKCHANGE_NOW); + collide(na, 0); + + /* Convert NSReleaseTimeout seconds to string format */ + duration(u2->na, relstr, sizeof(relstr), NSReleaseTimeout); + + notice_lang(s_NickServ, u, NICK_RECOVERED, s_NickServ, nick, relstr); + } else { + notice_lang(s_NickServ, u, ACCESS_DENIED); + if (res == 0) { + alog("%s: RECOVER: invalid password for %s by %s!%s@%s", + s_NickServ, nick, u->nick, u->username, u->host); + bad_password(u); + } + } + } else { + if (group_identified(u, na->nc) + || (!(na->nc->flags & NI_SECURE) && is_on_access(u, na->nc))) { + notice_lang(s_NickServ, u2, FORCENICKCHANGE_NOW); + collide(na, 0); + notice_lang(s_NickServ, u, NICK_RECOVERED, s_NickServ, nick); + } else { + notice_lang(s_NickServ, u, ACCESS_DENIED); + } + } + return MOD_CONT; } /* EOF */ diff --git a/src/core/ns_register.c b/src/core/ns_register.c index f3f08f6fe..a90c0ca0c 100644 --- a/src/core/ns_register.c +++ b/src/core/ns_register.c @@ -58,11 +58,11 @@ class NSRegister : public Module **/ void myNickServHelp(User * u) { - notice_lang(s_NickServ, u, NICK_HELP_CMD_REGISTER); - if (NSEmailReg) { - notice_lang(s_NickServ, u, NICK_HELP_CMD_CONFIRM); - notice_lang(s_NickServ, u, NICK_HELP_CMD_RESEND); - } + notice_lang(s_NickServ, u, NICK_HELP_CMD_REGISTER); + if (NSEmailReg) { + notice_lang(s_NickServ, u, NICK_HELP_CMD_CONFIRM); + notice_lang(s_NickServ, u, NICK_HELP_CMD_RESEND); + } } /** @@ -72,408 +72,408 @@ void myNickServHelp(User * u) **/ int do_register(User * u) { - NickRequest *nr = NULL, *anr = NULL; - NickCore *nc = NULL; - int prefixlen = strlen(NSGuestNickPrefix); - int nicklen = strlen(u->nick); - char *pass = strtok(NULL, " "); - char *email = strtok(NULL, " "); - char passcode[11]; - int idx, min = 1, max = 62, i = 0; - int chars[] = - { ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', - 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', - 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', - 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', - 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' - }; - - if (readonly) { - notice_lang(s_NickServ, u, NICK_REGISTRATION_DISABLED); - return MOD_CONT; - } - - if (checkDefCon(DEFCON_NO_NEW_NICKS)) { - notice_lang(s_NickServ, u, OPER_DEFCON_DENIED); - return MOD_CONT; - } - - if (!is_oper(u) && NickRegDelay - && ((time(NULL) - u->my_signon) < NickRegDelay)) { - notice_lang(s_NickServ, u, NICK_REG_DELAY, NickRegDelay); - return MOD_CONT; - } - - if ((anr = findrequestnick(u->nick))) { - notice_lang(s_NickServ, u, NICK_REQUESTED); - return MOD_CONT; - } - /* Prevent "Guest" nicks from being registered. -TheShadow */ - - /* Guest nick can now have a series of between 1 and 7 digits. - * --lara - */ - if (nicklen <= prefixlen + 7 && nicklen >= prefixlen + 1 && - stristr(u->nick, NSGuestNickPrefix) == u->nick && - strspn(u->nick + prefixlen, "1234567890") == nicklen - prefixlen) { - notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick); - return MOD_CONT; - } - - if (!ircdproto->IsNickValid(u->nick)) { - notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, u->nick); - return MOD_CONT; - } - - if (RestrictOperNicks) { - for (i = 0; i < RootNumber; i++) { - if (stristr(u->nick, ServicesRoots[i]) && !is_oper(u)) { - notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, - u->nick); - return MOD_CONT; - } - } - for (i = 0; i < servadmins.count && (nc = (NickCore *)servadmins.list[i]); i++) { - if (stristr(u->nick, nc->display) && !is_oper(u)) { - notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, - u->nick); - return MOD_CONT; - } - } - for (i = 0; i < servopers.count && (nc = (NickCore *)servopers.list[i]); i++) { - if (stristr(u->nick, nc->display) && !is_oper(u)) { - notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, - u->nick); - return MOD_CONT; - } - } - } - - if (!pass) { - if (NSForceEmail) { - syntax_error(s_NickServ, u, "REGISTER", - NICK_REGISTER_SYNTAX_EMAIL); - } else { - syntax_error(s_NickServ, u, "REGISTER", NICK_REGISTER_SYNTAX); - } - } else if (NSForceEmail && !email) { - syntax_error(s_NickServ, u, "REGISTER", - NICK_REGISTER_SYNTAX_EMAIL); - } else if (time(NULL) < u->lastnickreg + NSRegDelay) { - notice_lang(s_NickServ, u, NICK_REG_PLEASE_WAIT, NSRegDelay); - } else if (u->na) { /* i.e. there's already such a nick regged */ - if (u->na->status & NS_VERBOTEN) { - alog("%s: %s@%s tried to register FORBIDden nick %s", - s_NickServ, u->username, u->host, u->nick); - notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick); - } else { - notice_lang(s_NickServ, u, NICK_ALREADY_REGISTERED, u->nick); - } - } else if (stricmp(u->nick, pass) == 0 - || (StrictPasswords && strlen(pass) < 5)) { - notice_lang(s_NickServ, u, MORE_OBSCURE_PASSWORD); - } else if (enc_encrypt_check_len(strlen(pass), PASSMAX - 1)) { - notice_lang(s_NickServ, u, PASSWORD_TOO_LONG); - } else if (email && !MailValidate(email)) { - notice_lang(s_NickServ, u, MAIL_X_INVALID, email); - } else { - for (idx = 0; idx < 9; idx++) { - passcode[idx] = - chars[(1 + - (int) (((float) (max - min)) * getrandom16() / - (65535 + 1.0)) + min)]; - } passcode[idx] = '\0'; - nr = makerequest(u->nick); - nr->passcode = sstrdup(passcode); - strscpy(nr->password, pass, PASSMAX); - memset(pass, 0, strlen(pass)); - /* We are paranoid about keeping a plain text pass in memory, yet we would write - * it to a database.. - Viper */ - enc_encrypt_in_place(nr->password, PASSMAX); - if (email) { - nr->email = sstrdup(email); - } - nr->requested = time(NULL); - if (NSEmailReg) { - if (do_sendregmail(u, nr) == 0) { - notice_lang(s_NickServ, u, NICK_ENTER_REG_CODE, email, - s_NickServ); - alog("%s: sent registration verification code to %s", - s_NickServ, nr->email); - } else { - alog("%s: Unable to send registration verification mail", - s_NickServ); - notice_lang(s_NickServ, u, NICK_REG_UNABLE); - delnickrequest(nr); /* Delete the NickRequest if we couldnt send the mail */ - return MOD_CONT; - } - } else { - do_confirm(u); - } - - } - return MOD_CONT; + NickRequest *nr = NULL, *anr = NULL; + NickCore *nc = NULL; + int prefixlen = strlen(NSGuestNickPrefix); + int nicklen = strlen(u->nick); + char *pass = strtok(NULL, " "); + char *email = strtok(NULL, " "); + char passcode[11]; + int idx, min = 1, max = 62, i = 0; + int chars[] = + { ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', + 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', + 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', + 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', + 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' + }; + + if (readonly) { + notice_lang(s_NickServ, u, NICK_REGISTRATION_DISABLED); + return MOD_CONT; + } + + if (checkDefCon(DEFCON_NO_NEW_NICKS)) { + notice_lang(s_NickServ, u, OPER_DEFCON_DENIED); + return MOD_CONT; + } + + if (!is_oper(u) && NickRegDelay + && ((time(NULL) - u->my_signon) < NickRegDelay)) { + notice_lang(s_NickServ, u, NICK_REG_DELAY, NickRegDelay); + return MOD_CONT; + } + + if ((anr = findrequestnick(u->nick))) { + notice_lang(s_NickServ, u, NICK_REQUESTED); + return MOD_CONT; + } + /* Prevent "Guest" nicks from being registered. -TheShadow */ + + /* Guest nick can now have a series of between 1 and 7 digits. + * --lara + */ + if (nicklen <= prefixlen + 7 && nicklen >= prefixlen + 1 && + stristr(u->nick, NSGuestNickPrefix) == u->nick && + strspn(u->nick + prefixlen, "1234567890") == nicklen - prefixlen) { + notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick); + return MOD_CONT; + } + + if (!ircdproto->IsNickValid(u->nick)) { + notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, u->nick); + return MOD_CONT; + } + + if (RestrictOperNicks) { + for (i = 0; i < RootNumber; i++) { + if (stristr(u->nick, ServicesRoots[i]) && !is_oper(u)) { + notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, + u->nick); + return MOD_CONT; + } + } + for (i = 0; i < servadmins.count && (nc = (NickCore *)servadmins.list[i]); i++) { + if (stristr(u->nick, nc->display) && !is_oper(u)) { + notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, + u->nick); + return MOD_CONT; + } + } + for (i = 0; i < servopers.count && (nc = (NickCore *)servopers.list[i]); i++) { + if (stristr(u->nick, nc->display) && !is_oper(u)) { + notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, + u->nick); + return MOD_CONT; + } + } + } + + if (!pass) { + if (NSForceEmail) { + syntax_error(s_NickServ, u, "REGISTER", + NICK_REGISTER_SYNTAX_EMAIL); + } else { + syntax_error(s_NickServ, u, "REGISTER", NICK_REGISTER_SYNTAX); + } + } else if (NSForceEmail && !email) { + syntax_error(s_NickServ, u, "REGISTER", + NICK_REGISTER_SYNTAX_EMAIL); + } else if (time(NULL) < u->lastnickreg + NSRegDelay) { + notice_lang(s_NickServ, u, NICK_REG_PLEASE_WAIT, NSRegDelay); + } else if (u->na) { /* i.e. there's already such a nick regged */ + if (u->na->status & NS_VERBOTEN) { + alog("%s: %s@%s tried to register FORBIDden nick %s", + s_NickServ, u->username, u->host, u->nick); + notice_lang(s_NickServ, u, NICK_CANNOT_BE_REGISTERED, u->nick); + } else { + notice_lang(s_NickServ, u, NICK_ALREADY_REGISTERED, u->nick); + } + } else if (stricmp(u->nick, pass) == 0 + || (StrictPasswords && strlen(pass) < 5)) { + notice_lang(s_NickServ, u, MORE_OBSCURE_PASSWORD); + } else if (enc_encrypt_check_len(strlen(pass), PASSMAX - 1)) { + notice_lang(s_NickServ, u, PASSWORD_TOO_LONG); + } else if (email && !MailValidate(email)) { + notice_lang(s_NickServ, u, MAIL_X_INVALID, email); + } else { + for (idx = 0; idx < 9; idx++) { + passcode[idx] = + chars[(1 + + (int) (((float) (max - min)) * getrandom16() / + (65535 + 1.0)) + min)]; + } passcode[idx] = '\0'; + nr = makerequest(u->nick); + nr->passcode = sstrdup(passcode); + strscpy(nr->password, pass, PASSMAX); + memset(pass, 0, strlen(pass)); + /* We are paranoid about keeping a plain text pass in memory, yet we would write + * it to a database.. - Viper */ + enc_encrypt_in_place(nr->password, PASSMAX); + if (email) { + nr->email = sstrdup(email); + } + nr->requested = time(NULL); + if (NSEmailReg) { + if (do_sendregmail(u, nr) == 0) { + notice_lang(s_NickServ, u, NICK_ENTER_REG_CODE, email, + s_NickServ); + alog("%s: sent registration verification code to %s", + s_NickServ, nr->email); + } else { + alog("%s: Unable to send registration verification mail", + s_NickServ); + notice_lang(s_NickServ, u, NICK_REG_UNABLE); + delnickrequest(nr); /* Delete the NickRequest if we couldnt send the mail */ + return MOD_CONT; + } + } else { + do_confirm(u); + } + + } + return MOD_CONT; } /*************************************************************************/ int ns_do_register(User * u) { - return do_register(u); + return do_register(u); } int do_confirm(User * u) { - NickRequest *nr = NULL; - NickAlias *na = NULL; - char *passcode = strtok(NULL, " "); - char *email = NULL; - int forced = 0; - User *utmp = NULL; - char modes[512]; - int len; - - nr = findrequestnick(u->nick); - - if (NSEmailReg) { - if (!passcode) { - notice_lang(s_NickServ, u, NICK_CONFIRM_INVALID); - return MOD_CONT; - } - - if (!nr) { - if (is_services_admin(u)) { + NickRequest *nr = NULL; + NickAlias *na = NULL; + char *passcode = strtok(NULL, " "); + char *email = NULL; + int forced = 0; + User *utmp = NULL; + char modes[512]; + int len; + + nr = findrequestnick(u->nick); + + if (NSEmailReg) { + if (!passcode) { + notice_lang(s_NickServ, u, NICK_CONFIRM_INVALID); + return MOD_CONT; + } + + if (!nr) { + if (is_services_admin(u)) { /* If an admin, their nick is obviously already regged, so look at the passcode to get the nick of the user they are trying to validate, and push that user through regardless of passcode */ - nr = findrequestnick(passcode); - if (nr) { - utmp = finduser(passcode); - if (utmp) { - sprintf(passcode, - "FORCE_ACTIVATION_DUE_TO_OPER_CONFIRM %s", - nr->passcode); - passcode = strtok(passcode, " "); - notice_lang(s_NickServ, u, NICK_FORCE_REG, - nr->nick); - do_confirm(utmp); - return MOD_CONT; - } else { - passcode = sstrdup(nr->passcode); - forced = 1; - } - } else { - notice_lang(s_NickServ, u, NICK_CONFIRM_NOT_FOUND, - s_NickServ); - return MOD_CONT; - } - } else { - notice_lang(s_NickServ, u, NICK_CONFIRM_NOT_FOUND, - s_NickServ); - return MOD_CONT; - } - } - - if (stricmp(nr->passcode, passcode) != 0) { - notice_lang(s_NickServ, u, NICK_CONFIRM_INVALID); - return MOD_CONT; - } - } - - if (!nr) { - notice_lang(s_NickServ, u, NICK_REGISTRATION_FAILED); - return MOD_CONT; - } - - if (nr->email) { - email = sstrdup(nr->email); - } - na = makenick(nr->nick); - - if (na) { - int i; - char tsbuf[16]; - char tmp_pass[PASSMAX]; - - memcpy(na->nc->pass, nr->password, PASSMAX); - na->status = (int16) (NS_IDENTIFIED | NS_RECOGNIZED); -/* na->nc->flags |= NI_ENCRYPTEDPW; */ - - na->nc->flags |= NSDefFlags; - for (i = 0; i < RootNumber; i++) { - if (!stricmp(ServicesRoots[i], nr->nick)) { - na->nc->flags |= NI_SERVICES_ROOT; - break; - } - } - - na->nc->memos.memomax = MSMaxMemos; - - if (forced == 1) { - na->last_usermask = sstrdup("*@*"); - na->last_realname = sstrdup("unknown"); - } else { - na->last_usermask = - (char *)scalloc(strlen(common_get_vident(u)) + - strlen(common_get_vhost(u)) + 2, 1); - sprintf(na->last_usermask, "%s@%s", common_get_vident(u), - common_get_vhost(u)); - na->last_realname = sstrdup(u->realname); - } - na->time_registered = na->last_seen = time(NULL); - if (NSAddAccessOnReg) { - na->nc->accesscount = 1; - na->nc->access = (char **)scalloc(sizeof(char *), 1); - na->nc->access[0] = create_mask(u); - } else { - na->nc->accesscount = 0; - na->nc->access = NULL; - } - na->nc->language = NSDefLanguage; - if (email) - na->nc->email = sstrdup(email); - if (forced != 1) { - u->na = na; - na->u = u; - alog("%s: '%s' registered by %s@%s (e-mail: %s)", s_NickServ, - u->nick, u->username, u->host, (email ? email : "none")); - if (NSAddAccessOnReg) - notice_lang(s_NickServ, u, NICK_REGISTERED, u->nick, - na->nc->access[0]); - else - notice_lang(s_NickServ, u, NICK_REGISTERED_NO_MASK, - u->nick); - send_event(EVENT_NICK_REGISTERED, 1, u->nick); - - if(enc_decrypt(na->nc->pass, tmp_pass, PASSMAX - 1)==1) - notice_lang(s_NickServ, u, NICK_PASSWORD_IS, tmp_pass); - - u->lastnickreg = time(NULL); - if (ircd->modeonreg) { - len = strlen(ircd->modeonreg); - strncpy(modes,ircd->modeonreg,512); - if(ircd->rootmodeonid && is_services_root(u)) { - strncat(modes,ircd->rootmodeonid,512-len); - } else if(ircd->adminmodeonid && is_services_admin(u)) { - strncat(modes,ircd->adminmodeonid,512-len); - } else if(ircd->opermodeonid && is_services_oper(u)) { - strncat(modes,ircd->opermodeonid,512-len); - } - - if (ircd->tsonmode) { - snprintf(tsbuf, sizeof(tsbuf), "%lu", - (unsigned long int) u->timestamp); - common_svsmode(u, modes, tsbuf); - } else { - common_svsmode(u, modes, NULL); - } - } - - } else { - notice_lang(s_NickServ, u, NICK_FORCE_REG, nr->nick); - } - delnickrequest(nr); /* remove the nick request */ - } else { - alog("%s: makenick(%s) failed", s_NickServ, u->nick); - notice_lang(s_NickServ, u, NICK_REGISTRATION_FAILED); - } - - /* Enable nick tracking if enabled */ - if (NSNickTracking) - nsStartNickTracking(u); - - return MOD_CONT; + nr = findrequestnick(passcode); + if (nr) { + utmp = finduser(passcode); + if (utmp) { + sprintf(passcode, + "FORCE_ACTIVATION_DUE_TO_OPER_CONFIRM %s", + nr->passcode); + passcode = strtok(passcode, " "); + notice_lang(s_NickServ, u, NICK_FORCE_REG, + nr->nick); + do_confirm(utmp); + return MOD_CONT; + } else { + passcode = sstrdup(nr->passcode); + forced = 1; + } + } else { + notice_lang(s_NickServ, u, NICK_CONFIRM_NOT_FOUND, + s_NickServ); + return MOD_CONT; + } + } else { + notice_lang(s_NickServ, u, NICK_CONFIRM_NOT_FOUND, + s_NickServ); + return MOD_CONT; + } + } + + if (stricmp(nr->passcode, passcode) != 0) { + notice_lang(s_NickServ, u, NICK_CONFIRM_INVALID); + return MOD_CONT; + } + } + + if (!nr) { + notice_lang(s_NickServ, u, NICK_REGISTRATION_FAILED); + return MOD_CONT; + } + + if (nr->email) { + email = sstrdup(nr->email); + } + na = makenick(nr->nick); + + if (na) { + int i; + char tsbuf[16]; + char tmp_pass[PASSMAX]; + + memcpy(na->nc->pass, nr->password, PASSMAX); + na->status = (int16) (NS_IDENTIFIED | NS_RECOGNIZED); +/* na->nc->flags |= NI_ENCRYPTEDPW; */ + + na->nc->flags |= NSDefFlags; + for (i = 0; i < RootNumber; i++) { + if (!stricmp(ServicesRoots[i], nr->nick)) { + na->nc->flags |= NI_SERVICES_ROOT; + break; + } + } + + na->nc->memos.memomax = MSMaxMemos; + + if (forced == 1) { + na->last_usermask = sstrdup("*@*"); + na->last_realname = sstrdup("unknown"); + } else { + na->last_usermask = + (char *)scalloc(strlen(common_get_vident(u)) + + strlen(common_get_vhost(u)) + 2, 1); + sprintf(na->last_usermask, "%s@%s", common_get_vident(u), + common_get_vhost(u)); + na->last_realname = sstrdup(u->realname); + } + na->time_registered = na->last_seen = time(NULL); + if (NSAddAccessOnReg) { + na->nc->accesscount = 1; + na->nc->access = (char **)scalloc(sizeof(char *), 1); + na->nc->access[0] = create_mask(u); + } else { + na->nc->accesscount = 0; + na->nc->access = NULL; + } + na->nc->language = NSDefLanguage; + if (email) + na->nc->email = sstrdup(email); + if (forced != 1) { + u->na = na; + na->u = u; + alog("%s: '%s' registered by %s@%s (e-mail: %s)", s_NickServ, + u->nick, u->username, u->host, (email ? email : "none")); + if (NSAddAccessOnReg) + notice_lang(s_NickServ, u, NICK_REGISTERED, u->nick, + na->nc->access[0]); + else + notice_lang(s_NickServ, u, NICK_REGISTERED_NO_MASK, + u->nick); + send_event(EVENT_NICK_REGISTERED, 1, u->nick); + + if(enc_decrypt(na->nc->pass, tmp_pass, PASSMAX - 1)==1) + notice_lang(s_NickServ, u, NICK_PASSWORD_IS, tmp_pass); + + u->lastnickreg = time(NULL); + if (ircd->modeonreg) { + len = strlen(ircd->modeonreg); + strncpy(modes,ircd->modeonreg,512); + if(ircd->rootmodeonid && is_services_root(u)) { + strncat(modes,ircd->rootmodeonid,512-len); + } else if(ircd->adminmodeonid && is_services_admin(u)) { + strncat(modes,ircd->adminmodeonid,512-len); + } else if(ircd->opermodeonid && is_services_oper(u)) { + strncat(modes,ircd->opermodeonid,512-len); + } + + if (ircd->tsonmode) { + snprintf(tsbuf, sizeof(tsbuf), "%lu", + (unsigned long int) u->timestamp); + common_svsmode(u, modes, tsbuf); + } else { + common_svsmode(u, modes, NULL); + } + } + + } else { + notice_lang(s_NickServ, u, NICK_FORCE_REG, nr->nick); + } + delnickrequest(nr); /* remove the nick request */ + } else { + alog("%s: makenick(%s) failed", s_NickServ, u->nick); + notice_lang(s_NickServ, u, NICK_REGISTRATION_FAILED); + } + + /* Enable nick tracking if enabled */ + if (NSNickTracking) + nsStartNickTracking(u); + + return MOD_CONT; } NickRequest *makerequest(const char *nick) { - NickRequest *nr; + NickRequest *nr; - nr = (NickRequest *)scalloc(1, sizeof(NickRequest)); - nr->nick = sstrdup(nick); - insert_requestnick(nr); - alog("%s: Nick %s has been requested", s_NickServ, nr->nick); - return nr; + nr = (NickRequest *)scalloc(1, sizeof(NickRequest)); + nr->nick = sstrdup(nick); + insert_requestnick(nr); + alog("%s: Nick %s has been requested", s_NickServ, nr->nick); + return nr; } /* Creates a full new nick (alias + core) in NickServ database. */ NickAlias *makenick(const char *nick) { - NickAlias *na; - NickCore *nc; - - /* First make the core */ - nc = (NickCore *)scalloc(1, sizeof(NickCore)); - nc->display = sstrdup(nick); - slist_init(&nc->aliases); - insert_core(nc); - alog("%s: group %s has been created", s_NickServ, nc->display); - - /* Then make the alias */ - na = (NickAlias *)scalloc(1, sizeof(NickAlias)); - na->nick = sstrdup(nick); - na->nc = nc; - slist_add(&nc->aliases, na); - alpha_insert_alias(na); - return na; + NickAlias *na; + NickCore *nc; + + /* First make the core */ + nc = (NickCore *)scalloc(1, sizeof(NickCore)); + nc->display = sstrdup(nick); + slist_init(&nc->aliases); + insert_core(nc); + alog("%s: group %s has been created", s_NickServ, nc->display); + + /* Then make the alias */ + na = (NickAlias *)scalloc(1, sizeof(NickAlias)); + na->nick = sstrdup(nick); + na->nc = nc; + slist_add(&nc->aliases, na); + alpha_insert_alias(na); + return na; } /* Register a nick. */ int do_resend(User * u) { - NickRequest *nr = NULL; - if (NSEmailReg) { - if ((nr = findrequestnick(u->nick))) { - if (time(NULL) < nr->lastmail + NSResendDelay) { - return MOD_CONT; - } else { - nr->lastmail = time(NULL); - } - if (do_sendregmail(u, nr) == 0) { - notice_lang(s_NickServ, u, NICK_REG_RESENT, nr->email); - alog("%s: re-sent registration verification code for %s to %s", s_NickServ, nr->nick, nr->email); - } else { - alog("%s: Unable to re-send registration verification mail for %s", s_NickServ, nr->nick); - return MOD_CONT; - } - } - } - return MOD_CONT; + NickRequest *nr = NULL; + if (NSEmailReg) { + if ((nr = findrequestnick(u->nick))) { + if (time(NULL) < nr->lastmail + NSResendDelay) { + return MOD_CONT; + } else { + nr->lastmail = time(NULL); + } + if (do_sendregmail(u, nr) == 0) { + notice_lang(s_NickServ, u, NICK_REG_RESENT, nr->email); + alog("%s: re-sent registration verification code for %s to %s", s_NickServ, nr->nick, nr->email); + } else { + alog("%s: Unable to re-send registration verification mail for %s", s_NickServ, nr->nick); + return MOD_CONT; + } + } + } + return MOD_CONT; } int do_sendregmail(User * u, NickRequest * nr) { - MailInfo *mail = NULL; - char buf[BUFSIZE]; - - if (!(nr || u)) { - return -1; - } - snprintf(buf, sizeof(buf), getstring2(NULL, NICK_REG_MAIL_SUBJECT), - nr->nick); - mail = MailRegBegin(u, nr, buf, s_NickServ); - if (!mail) { - return -1; - } - fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_HEAD)); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_LINE_1), nr->nick); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_LINE_2), s_NickServ, - nr->passcode); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_LINE_3)); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_LINE_4)); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_LINE_5), - NetworkName); - fprintf(mail->pipe, "\n.\n"); - MailEnd(mail); - return 0; + MailInfo *mail = NULL; + char buf[BUFSIZE]; + + if (!(nr || u)) { + return -1; + } + snprintf(buf, sizeof(buf), getstring2(NULL, NICK_REG_MAIL_SUBJECT), + nr->nick); + mail = MailRegBegin(u, nr, buf, s_NickServ); + if (!mail) { + return -1; + } + fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_HEAD)); + fprintf(mail->pipe, "\n\n"); + fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_LINE_1), nr->nick); + fprintf(mail->pipe, "\n\n"); + fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_LINE_2), s_NickServ, + nr->passcode); + fprintf(mail->pipe, "\n\n"); + fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_LINE_3)); + fprintf(mail->pipe, "\n\n"); + fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_LINE_4)); + fprintf(mail->pipe, "\n\n"); + fprintf(mail->pipe, getstring2(NULL, NICK_REG_MAIL_LINE_5), + NetworkName); + fprintf(mail->pipe, "\n.\n"); + MailEnd(mail); + return 0; } diff --git a/src/core/ns_release.c b/src/core/ns_release.c index a13bc310d..28173ab36 100644 --- a/src/core/ns_release.c +++ b/src/core/ns_release.c @@ -47,7 +47,7 @@ class NSRelease : public Module **/ void myNickServHelp(User * u) { - notice_lang(s_NickServ, u, NICK_HELP_CMD_RELEASE); + notice_lang(s_NickServ, u, NICK_HELP_CMD_RELEASE); } /** @@ -56,15 +56,15 @@ void myNickServHelp(User * u) **/ int myHelpResonse(User * u) { - char relstr[192]; + char relstr[192]; - /* Convert NSReleaseTimeout seconds to string format */ - duration(u->na, relstr, sizeof(relstr), NSReleaseTimeout); - - notice_help(s_NickServ, u, NICK_HELP_RELEASE, relstr); - do_help_limited(s_NickServ, u, c); + /* Convert NSReleaseTimeout seconds to string format */ + duration(u->na, relstr, sizeof(relstr), NSReleaseTimeout); + + notice_help(s_NickServ, u, NICK_HELP_RELEASE, relstr); + do_help_limited(s_NickServ, u, c); - return MOD_CONT; + return MOD_CONT; } /** @@ -74,43 +74,43 @@ int myHelpResonse(User * u) **/ int do_release(User * u) { - char *nick = strtok(NULL, " "); - char *pass = strtok(NULL, " "); - NickAlias *na; - - if (!nick) { - syntax_error(s_NickServ, u, "RELEASE", NICK_RELEASE_SYNTAX); - } else if (!(na = findnick(nick))) { - notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); - } else if (na->status & NS_VERBOTEN) { - notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); - } else if (na->nc->flags & NI_SUSPENDED) { - notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick); - } else if (!(na->status & NS_KILL_HELD)) { - notice_lang(s_NickServ, u, NICK_RELEASE_NOT_HELD, nick); - } else if (pass) { - int res = enc_check_password(pass, na->nc->pass); - if (res == 1) { - release(na, 0); - notice_lang(s_NickServ, u, NICK_RELEASED); - } else { - notice_lang(s_NickServ, u, ACCESS_DENIED); - if (res == 0) { - alog("%s: RELEASE: invalid password for %s by %s!%s@%s", - s_NickServ, nick, u->nick, u->username, u->host); - bad_password(u); - } - } - } else { - if (group_identified(u, na->nc) - || (!(na->nc->flags & NI_SECURE) && is_on_access(u, na->nc))) { - release(na, 0); - notice_lang(s_NickServ, u, NICK_RELEASED); - } else { - notice_lang(s_NickServ, u, ACCESS_DENIED); - } - } - return MOD_CONT; + char *nick = strtok(NULL, " "); + char *pass = strtok(NULL, " "); + NickAlias *na; + + if (!nick) { + syntax_error(s_NickServ, u, "RELEASE", NICK_RELEASE_SYNTAX); + } else if (!(na = findnick(nick))) { + notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); + } else if (na->status & NS_VERBOTEN) { + notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); + } else if (na->nc->flags & NI_SUSPENDED) { + notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick); + } else if (!(na->status & NS_KILL_HELD)) { + notice_lang(s_NickServ, u, NICK_RELEASE_NOT_HELD, nick); + } else if (pass) { + int res = enc_check_password(pass, na->nc->pass); + if (res == 1) { + release(na, 0); + notice_lang(s_NickServ, u, NICK_RELEASED); + } else { + notice_lang(s_NickServ, u, ACCESS_DENIED); + if (res == 0) { + alog("%s: RELEASE: invalid password for %s by %s!%s@%s", + s_NickServ, nick, u->nick, u->username, u->host); + bad_password(u); + } + } + } else { + if (group_identified(u, na->nc) + || (!(na->nc->flags & NI_SECURE) && is_on_access(u, na->nc))) { + release(na, 0); + notice_lang(s_NickServ, u, NICK_RELEASED); + } else { + notice_lang(s_NickServ, u, ACCESS_DENIED); + } + } + return MOD_CONT; } /* EOF */ diff --git a/src/core/ns_saset.c b/src/core/ns_saset.c index f3e8b8c72..a1e922a4e 100644 --- a/src/core/ns_saset.c +++ b/src/core/ns_saset.c @@ -87,8 +87,8 @@ class NSSASet : public Module **/ void myNickServHelp(User * u) { - if (is_services_oper(u)) - notice_lang(s_NickServ, u, NICK_HELP_CMD_SASET); + if (is_services_oper(u)) + notice_lang(s_NickServ, u, NICK_HELP_CMD_SASET); } /** @@ -98,407 +98,407 @@ void myNickServHelp(User * u) **/ int do_saset(User * u) { - char *nick = strtok(NULL, " "); - char *cmd = strtok(NULL, " "); - char *param = strtok(NULL, " "); + char *nick = strtok(NULL, " "); + char *cmd = strtok(NULL, " "); + char *param = strtok(NULL, " "); - NickAlias *na; + NickAlias *na; - if (readonly) { - notice_lang(s_NickServ, u, NICK_SASET_DISABLED); - return MOD_CONT; - } + if (readonly) { + notice_lang(s_NickServ, u, NICK_SASET_DISABLED); + return MOD_CONT; + } if (!nick) { syntax_error(s_NickServ, u, "SASET", NICK_SASET_SYNTAX); return MOD_CONT; } - if (!(na = findnick(nick))) { - notice_lang(s_NickServ, u, NICK_SASET_BAD_NICK, nick); - return MOD_CONT; - } - - if (!param - && (!cmd - || (stricmp(cmd, "URL") != 0 && stricmp(cmd, "EMAIL") != 0 - && stricmp(cmd, "GREET") != 0 - && stricmp(cmd, "ICQ") != 0))) { - syntax_error(s_NickServ, u, "SASET", NICK_SASET_SYNTAX); - } else if (!na) { - notice_lang(s_NickServ, u, NICK_NOT_REGISTERED, nick); - } else if (na->status & NS_VERBOTEN) { - notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); - } else if (na->nc->flags & NI_SUSPENDED) { - notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick); - } else if (stricmp(cmd, "DISPLAY") == 0) { - do_saset_display(u, na->nc, param); - } else if (stricmp(cmd, "PASSWORD") == 0) { - do_saset_password(u, na->nc, param); - } else if (stricmp(cmd, "URL") == 0) { - do_saset_url(u, na->nc, param); - } else if (stricmp(cmd, "EMAIL") == 0) { - do_saset_email(u, na->nc, param); - } else if (stricmp(cmd, "ICQ") == 0) { - do_saset_icq(u, na->nc, param); - } else if (stricmp(cmd, "GREET") == 0) { - do_saset_greet(u, na->nc, param); - } else if (stricmp(cmd, "KILL") == 0) { - do_saset_kill(u, na->nc, param); - } else if (stricmp(cmd, "SECURE") == 0) { - do_saset_secure(u, na->nc, param); - } else if (stricmp(cmd, "PRIVATE") == 0) { - do_saset_private(u, na->nc, param); - } else if (stricmp(cmd, "MSG") == 0) { - do_saset_msg(u, na->nc, param); - } else if (stricmp(cmd, "HIDE") == 0) { - do_saset_hide(u, na->nc, param); - } else if (stricmp(cmd, "NOEXPIRE") == 0) { - do_saset_noexpire(u, na, param); - } else if (stricmp(cmd, "AUTOOP") == 0) { - do_saset_autoop(u, na->nc, param); - } else if (stricmp(cmd, "LANGUAGE") == 0) { - do_saset_language(u, na->nc, param); - } else { - notice_lang(s_NickServ, u, NICK_SASET_UNKNOWN_OPTION, cmd); - } - return MOD_CONT; + if (!(na = findnick(nick))) { + notice_lang(s_NickServ, u, NICK_SASET_BAD_NICK, nick); + return MOD_CONT; + } + + if (!param + && (!cmd + || (stricmp(cmd, "URL") != 0 && stricmp(cmd, "EMAIL") != 0 + && stricmp(cmd, "GREET") != 0 + && stricmp(cmd, "ICQ") != 0))) { + syntax_error(s_NickServ, u, "SASET", NICK_SASET_SYNTAX); + } else if (!na) { + notice_lang(s_NickServ, u, NICK_NOT_REGISTERED, nick); + } else if (na->status & NS_VERBOTEN) { + notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); + } else if (na->nc->flags & NI_SUSPENDED) { + notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick); + } else if (stricmp(cmd, "DISPLAY") == 0) { + do_saset_display(u, na->nc, param); + } else if (stricmp(cmd, "PASSWORD") == 0) { + do_saset_password(u, na->nc, param); + } else if (stricmp(cmd, "URL") == 0) { + do_saset_url(u, na->nc, param); + } else if (stricmp(cmd, "EMAIL") == 0) { + do_saset_email(u, na->nc, param); + } else if (stricmp(cmd, "ICQ") == 0) { + do_saset_icq(u, na->nc, param); + } else if (stricmp(cmd, "GREET") == 0) { + do_saset_greet(u, na->nc, param); + } else if (stricmp(cmd, "KILL") == 0) { + do_saset_kill(u, na->nc, param); + } else if (stricmp(cmd, "SECURE") == 0) { + do_saset_secure(u, na->nc, param); + } else if (stricmp(cmd, "PRIVATE") == 0) { + do_saset_private(u, na->nc, param); + } else if (stricmp(cmd, "MSG") == 0) { + do_saset_msg(u, na->nc, param); + } else if (stricmp(cmd, "HIDE") == 0) { + do_saset_hide(u, na->nc, param); + } else if (stricmp(cmd, "NOEXPIRE") == 0) { + do_saset_noexpire(u, na, param); + } else if (stricmp(cmd, "AUTOOP") == 0) { + do_saset_autoop(u, na->nc, param); + } else if (stricmp(cmd, "LANGUAGE") == 0) { + do_saset_language(u, na->nc, param); + } else { + notice_lang(s_NickServ, u, NICK_SASET_UNKNOWN_OPTION, cmd); + } + return MOD_CONT; } int do_saset_display(User * u, NickCore * nc, char *param) { - int i; - NickAlias *na; - - /* First check whether param is a valid nick of the group */ - for (i = 0; i < nc->aliases.count; i++) { - na = (NickAlias *)nc->aliases.list[i]; - if (stricmp(na->nick, param) == 0) { - param = na->nick; /* Because case may differ */ - break; - } - } - - if (i == nc->aliases.count) { - notice_lang(s_NickServ, u, NICK_SASET_DISPLAY_INVALID, - nc->display); - return MOD_CONT; - } - - change_core_display(nc, param); - notice_lang(s_NickServ, u, NICK_SASET_DISPLAY_CHANGED, nc->display); - - /* Enable nick tracking if enabled */ - if (NSNickTracking) - nsStartNickTracking(u); - - return MOD_CONT; + int i; + NickAlias *na; + + /* First check whether param is a valid nick of the group */ + for (i = 0; i < nc->aliases.count; i++) { + na = (NickAlias *)nc->aliases.list[i]; + if (stricmp(na->nick, param) == 0) { + param = na->nick; /* Because case may differ */ + break; + } + } + + if (i == nc->aliases.count) { + notice_lang(s_NickServ, u, NICK_SASET_DISPLAY_INVALID, + nc->display); + return MOD_CONT; + } + + change_core_display(nc, param); + notice_lang(s_NickServ, u, NICK_SASET_DISPLAY_CHANGED, nc->display); + + /* Enable nick tracking if enabled */ + if (NSNickTracking) + nsStartNickTracking(u); + + return MOD_CONT; } int do_saset_password(User * u, NickCore * nc, char *param) { - int len = strlen(param); - char tmp_pass[PASSMAX]; - - if (NSSecureAdmins && u->na->nc != nc && nick_is_services_admin(nc) - && !is_services_root(u)) { - notice_lang(s_NickServ, u, PERMISSION_DENIED); - return MOD_CONT; - } else if (stricmp(nc->display, param) == 0 - || (StrictPasswords && len < 5)) { - notice_lang(s_NickServ, u, MORE_OBSCURE_PASSWORD); - return MOD_CONT; - } else if (enc_encrypt_check_len(len ,PASSMAX - 1)) { - notice_lang(s_NickServ, u, PASSWORD_TOO_LONG); - return MOD_CONT; - } - - if (enc_encrypt(param, len, nc->pass, PASSMAX - 1) < 0) { - memset(param, 0, len); - alog("%s: Failed to encrypt password for %s (set)", s_NickServ, - nc->display); - notice_lang(s_NickServ, u, NICK_SASET_PASSWORD_FAILED, - nc->display); - return MOD_CONT; - } - memset(param, 0, len); - - if(enc_decrypt(nc->pass,tmp_pass,PASSMAX - 1)==1) { - notice_lang(s_NickServ, u, NICK_SASET_PASSWORD_CHANGED_TO, nc->display, - tmp_pass); - } else { - notice_lang(s_NickServ, u, NICK_SASET_PASSWORD_CHANGED, nc->display); - } - - alog("%s: %s!%s@%s used SASET PASSWORD on %s (e-mail: %s)", s_NickServ, - u->nick, u->username, u->host, nc->display, - (nc->email ? nc->email : "none")); - if (WallSetpass) - ircdproto->SendGlobops(s_NickServ, - "\2%s\2 used SASET PASSWORD on \2%s\2", - u->nick, nc->display); - return MOD_CONT; + int len = strlen(param); + char tmp_pass[PASSMAX]; + + if (NSSecureAdmins && u->na->nc != nc && nick_is_services_admin(nc) + && !is_services_root(u)) { + notice_lang(s_NickServ, u, PERMISSION_DENIED); + return MOD_CONT; + } else if (stricmp(nc->display, param) == 0 + || (StrictPasswords && len < 5)) { + notice_lang(s_NickServ, u, MORE_OBSCURE_PASSWORD); + return MOD_CONT; + } else if (enc_encrypt_check_len(len ,PASSMAX - 1)) { + notice_lang(s_NickServ, u, PASSWORD_TOO_LONG); + return MOD_CONT; + } + + if (enc_encrypt(param, len, nc->pass, PASSMAX - 1) < 0) { + memset(param, 0, len); + alog("%s: Failed to encrypt password for %s (set)", s_NickServ, + nc->display); + notice_lang(s_NickServ, u, NICK_SASET_PASSWORD_FAILED, + nc->display); + return MOD_CONT; + } + memset(param, 0, len); + + if(enc_decrypt(nc->pass,tmp_pass,PASSMAX - 1)==1) { + notice_lang(s_NickServ, u, NICK_SASET_PASSWORD_CHANGED_TO, nc->display, + tmp_pass); + } else { + notice_lang(s_NickServ, u, NICK_SASET_PASSWORD_CHANGED, nc->display); + } + + alog("%s: %s!%s@%s used SASET PASSWORD on %s (e-mail: %s)", s_NickServ, + u->nick, u->username, u->host, nc->display, + (nc->email ? nc->email : "none")); + if (WallSetpass) + ircdproto->SendGlobops(s_NickServ, + "\2%s\2 used SASET PASSWORD on \2%s\2", + u->nick, nc->display); + return MOD_CONT; } int do_saset_url(User * u, NickCore * nc, char *param) { - if (nc->url) - free(nc->url); - - if (param) { - nc->url = sstrdup(param); - notice_lang(s_NickServ, u, NICK_SASET_URL_CHANGED, nc->display, - param); - } else { - nc->url = NULL; - notice_lang(s_NickServ, u, NICK_SASET_URL_UNSET, nc->display); - } - return MOD_CONT; + if (nc->url) + free(nc->url); + + if (param) { + nc->url = sstrdup(param); + notice_lang(s_NickServ, u, NICK_SASET_URL_CHANGED, nc->display, + param); + } else { + nc->url = NULL; + notice_lang(s_NickServ, u, NICK_SASET_URL_UNSET, nc->display); + } + return MOD_CONT; } int do_saset_email(User * u, NickCore * nc, char *param) { - if (!param && NSForceEmail) { - notice_lang(s_NickServ, u, NICK_SASET_EMAIL_UNSET_IMPOSSIBLE); - return MOD_CONT; - } else if (NSSecureAdmins && u->na->nc != nc - && nick_is_services_admin(nc) - && !is_services_root(u)) { - notice_lang(s_NickServ, u, PERMISSION_DENIED); - return MOD_CONT; - } else if (param && !MailValidate(param)) { - notice_lang(s_NickServ, u, MAIL_X_INVALID, param); - return MOD_CONT; - } - - alog("%s: %s!%s@%s used SASET EMAIL on %s (e-mail: %s)", s_NickServ, - u->nick, u->username, u->host, nc->display, - (nc->email ? nc->email : "none")); - - if (nc->email) - free(nc->email); - - if (param) { - nc->email = sstrdup(param); - notice_lang(s_NickServ, u, NICK_SASET_EMAIL_CHANGED, nc->display, - param); - } else { - nc->email = NULL; - notice_lang(s_NickServ, u, NICK_SASET_EMAIL_UNSET, nc->display); - } - return MOD_CONT; + if (!param && NSForceEmail) { + notice_lang(s_NickServ, u, NICK_SASET_EMAIL_UNSET_IMPOSSIBLE); + return MOD_CONT; + } else if (NSSecureAdmins && u->na->nc != nc + && nick_is_services_admin(nc) + && !is_services_root(u)) { + notice_lang(s_NickServ, u, PERMISSION_DENIED); + return MOD_CONT; + } else if (param && !MailValidate(param)) { + notice_lang(s_NickServ, u, MAIL_X_INVALID, param); + return MOD_CONT; + } + + alog("%s: %s!%s@%s used SASET EMAIL on %s (e-mail: %s)", s_NickServ, + u->nick, u->username, u->host, nc->display, + (nc->email ? nc->email : "none")); + + if (nc->email) + free(nc->email); + + if (param) { + nc->email = sstrdup(param); + notice_lang(s_NickServ, u, NICK_SASET_EMAIL_CHANGED, nc->display, + param); + } else { + nc->email = NULL; + notice_lang(s_NickServ, u, NICK_SASET_EMAIL_UNSET, nc->display); + } + return MOD_CONT; } int do_saset_icq(User * u, NickCore * nc, char *param) { - if (param) { - int32 tmp = atol(param); - if (tmp == 0) { - notice_lang(s_NickServ, u, NICK_SASET_ICQ_INVALID, param); - } else { - nc->icq = tmp; - notice_lang(s_NickServ, u, NICK_SASET_ICQ_CHANGED, nc->display, - param); - } - } else { - nc->icq = 0; - notice_lang(s_NickServ, u, NICK_SASET_ICQ_UNSET, nc->display); - } - return MOD_CONT; + if (param) { + int32 tmp = atol(param); + if (tmp == 0) { + notice_lang(s_NickServ, u, NICK_SASET_ICQ_INVALID, param); + } else { + nc->icq = tmp; + notice_lang(s_NickServ, u, NICK_SASET_ICQ_CHANGED, nc->display, + param); + } + } else { + nc->icq = 0; + notice_lang(s_NickServ, u, NICK_SASET_ICQ_UNSET, nc->display); + } + return MOD_CONT; } int do_saset_greet(User * u, NickCore * nc, char *param) { - if (nc->greet) - free(nc->greet); - - if (param) { - char buf[BUFSIZE]; - char *end = strtok(NULL, ""); - - snprintf(buf, sizeof(buf), "%s%s%s", param, (end ? " " : ""), - (end ? end : "")); - - nc->greet = sstrdup(buf); - notice_lang(s_NickServ, u, NICK_SASET_GREET_CHANGED, nc->display, - buf); - } else { - nc->greet = NULL; - notice_lang(s_NickServ, u, NICK_SASET_GREET_UNSET, nc->display); - } - return MOD_CONT; + if (nc->greet) + free(nc->greet); + + if (param) { + char buf[BUFSIZE]; + char *end = strtok(NULL, ""); + + snprintf(buf, sizeof(buf), "%s%s%s", param, (end ? " " : ""), + (end ? end : "")); + + nc->greet = sstrdup(buf); + notice_lang(s_NickServ, u, NICK_SASET_GREET_CHANGED, nc->display, + buf); + } else { + nc->greet = NULL; + notice_lang(s_NickServ, u, NICK_SASET_GREET_UNSET, nc->display); + } + return MOD_CONT; } int do_saset_kill(User * u, NickCore * nc, char *param) { - if (stricmp(param, "ON") == 0) { - nc->flags |= NI_KILLPROTECT; - nc->flags &= ~(NI_KILL_QUICK | NI_KILL_IMMED); - notice_lang(s_NickServ, u, NICK_SASET_KILL_ON, nc->display); - } else if (stricmp(param, "QUICK") == 0) { - nc->flags |= NI_KILLPROTECT | NI_KILL_QUICK; - nc->flags &= ~NI_KILL_IMMED; - notice_lang(s_NickServ, u, NICK_SASET_KILL_QUICK, nc->display); - } else if (stricmp(param, "IMMED") == 0) { - if (NSAllowKillImmed) { - nc->flags |= NI_KILLPROTECT | NI_KILL_IMMED; - nc->flags &= ~NI_KILL_QUICK; - notice_lang(s_NickServ, u, NICK_SASET_KILL_IMMED, nc->display); - } else { - notice_lang(s_NickServ, u, NICK_SASET_KILL_IMMED_DISABLED); - } - } else if (stricmp(param, "OFF") == 0) { - nc->flags &= ~(NI_KILLPROTECT | NI_KILL_QUICK | NI_KILL_IMMED); - notice_lang(s_NickServ, u, NICK_SASET_KILL_OFF, nc->display); - } else { - syntax_error(s_NickServ, u, "SASET KILL", - NSAllowKillImmed ? NICK_SASET_KILL_IMMED_SYNTAX : - NICK_SASET_KILL_SYNTAX); - } - return MOD_CONT; + if (stricmp(param, "ON") == 0) { + nc->flags |= NI_KILLPROTECT; + nc->flags &= ~(NI_KILL_QUICK | NI_KILL_IMMED); + notice_lang(s_NickServ, u, NICK_SASET_KILL_ON, nc->display); + } else if (stricmp(param, "QUICK") == 0) { + nc->flags |= NI_KILLPROTECT | NI_KILL_QUICK; + nc->flags &= ~NI_KILL_IMMED; + notice_lang(s_NickServ, u, NICK_SASET_KILL_QUICK, nc->display); + } else if (stricmp(param, "IMMED") == 0) { + if (NSAllowKillImmed) { + nc->flags |= NI_KILLPROTECT | NI_KILL_IMMED; + nc->flags &= ~NI_KILL_QUICK; + notice_lang(s_NickServ, u, NICK_SASET_KILL_IMMED, nc->display); + } else { + notice_lang(s_NickServ, u, NICK_SASET_KILL_IMMED_DISABLED); + } + } else if (stricmp(param, "OFF") == 0) { + nc->flags &= ~(NI_KILLPROTECT | NI_KILL_QUICK | NI_KILL_IMMED); + notice_lang(s_NickServ, u, NICK_SASET_KILL_OFF, nc->display); + } else { + syntax_error(s_NickServ, u, "SASET KILL", + NSAllowKillImmed ? NICK_SASET_KILL_IMMED_SYNTAX : + NICK_SASET_KILL_SYNTAX); + } + return MOD_CONT; } int do_saset_secure(User * u, NickCore * nc, char *param) { - if (stricmp(param, "ON") == 0) { - nc->flags |= NI_SECURE; - notice_lang(s_NickServ, u, NICK_SASET_SECURE_ON, nc->display); - } else if (stricmp(param, "OFF") == 0) { - nc->flags &= ~NI_SECURE; - notice_lang(s_NickServ, u, NICK_SASET_SECURE_OFF, nc->display); - } else { - syntax_error(s_NickServ, u, "SASET SECURE", - NICK_SASET_SECURE_SYNTAX); - } - return MOD_CONT; + if (stricmp(param, "ON") == 0) { + nc->flags |= NI_SECURE; + notice_lang(s_NickServ, u, NICK_SASET_SECURE_ON, nc->display); + } else if (stricmp(param, "OFF") == 0) { + nc->flags &= ~NI_SECURE; + notice_lang(s_NickServ, u, NICK_SASET_SECURE_OFF, nc->display); + } else { + syntax_error(s_NickServ, u, "SASET SECURE", + NICK_SASET_SECURE_SYNTAX); + } + return MOD_CONT; } int do_saset_private(User * u, NickCore * nc, char *param) { - if (stricmp(param, "ON") == 0) { - nc->flags |= NI_PRIVATE; - notice_lang(s_NickServ, u, NICK_SASET_PRIVATE_ON, nc->display); - } else if (stricmp(param, "OFF") == 0) { - nc->flags &= ~NI_PRIVATE; - notice_lang(s_NickServ, u, NICK_SASET_PRIVATE_OFF, nc->display); - } else { - syntax_error(s_NickServ, u, "SASET PRIVATE", - NICK_SASET_PRIVATE_SYNTAX); - } - return MOD_CONT; + if (stricmp(param, "ON") == 0) { + nc->flags |= NI_PRIVATE; + notice_lang(s_NickServ, u, NICK_SASET_PRIVATE_ON, nc->display); + } else if (stricmp(param, "OFF") == 0) { + nc->flags &= ~NI_PRIVATE; + notice_lang(s_NickServ, u, NICK_SASET_PRIVATE_OFF, nc->display); + } else { + syntax_error(s_NickServ, u, "SASET PRIVATE", + NICK_SASET_PRIVATE_SYNTAX); + } + return MOD_CONT; } int do_saset_msg(User * u, NickCore * nc, char *param) { - if (!UsePrivmsg) { - notice_lang(s_NickServ, u, NICK_SASET_OPTION_DISABLED, "MSG"); - return MOD_CONT; - } - - if (stricmp(param, "ON") == 0) { - nc->flags |= NI_MSG; - notice_lang(s_NickServ, u, NICK_SASET_MSG_ON, nc->display); - } else if (stricmp(param, "OFF") == 0) { - nc->flags &= ~NI_MSG; - notice_lang(s_NickServ, u, NICK_SASET_MSG_OFF, nc->display); - } else { - syntax_error(s_NickServ, u, "SASET MSG", NICK_SASET_MSG_SYNTAX); - } - return MOD_CONT; + if (!UsePrivmsg) { + notice_lang(s_NickServ, u, NICK_SASET_OPTION_DISABLED, "MSG"); + return MOD_CONT; + } + + if (stricmp(param, "ON") == 0) { + nc->flags |= NI_MSG; + notice_lang(s_NickServ, u, NICK_SASET_MSG_ON, nc->display); + } else if (stricmp(param, "OFF") == 0) { + nc->flags &= ~NI_MSG; + notice_lang(s_NickServ, u, NICK_SASET_MSG_OFF, nc->display); + } else { + syntax_error(s_NickServ, u, "SASET MSG", NICK_SASET_MSG_SYNTAX); + } + return MOD_CONT; } int do_saset_hide(User * u, NickCore * nc, char *param) { - int flag, onmsg, offmsg; - - if (stricmp(param, "EMAIL") == 0) { - flag = NI_HIDE_EMAIL; - onmsg = NICK_SASET_HIDE_EMAIL_ON; - offmsg = NICK_SASET_HIDE_EMAIL_OFF; - } else if (stricmp(param, "USERMASK") == 0) { - flag = NI_HIDE_MASK; - onmsg = NICK_SASET_HIDE_MASK_ON; - offmsg = NICK_SASET_HIDE_MASK_OFF; - } else if (stricmp(param, "STATUS") == 0) { - flag = NI_HIDE_STATUS; - onmsg = NICK_SASET_HIDE_STATUS_ON; - offmsg = NICK_SASET_HIDE_STATUS_OFF; - } else if (stricmp(param, "QUIT") == 0) { - flag = NI_HIDE_QUIT; - onmsg = NICK_SASET_HIDE_QUIT_ON; - offmsg = NICK_SASET_HIDE_QUIT_OFF; - } else { - syntax_error(s_NickServ, u, "SASET HIDE", NICK_SASET_HIDE_SYNTAX); - return MOD_CONT; - } - - param = strtok(NULL, " "); - if (!param) { - syntax_error(s_NickServ, u, "SASET HIDE", NICK_SASET_HIDE_SYNTAX); - } else if (stricmp(param, "ON") == 0) { - nc->flags |= flag; - notice_lang(s_NickServ, u, onmsg, nc->display, s_NickServ); - } else if (stricmp(param, "OFF") == 0) { - nc->flags &= ~flag; - notice_lang(s_NickServ, u, offmsg, nc->display, s_NickServ); - } else { - syntax_error(s_NickServ, u, "SASET HIDE", NICK_SASET_HIDE_SYNTAX); - } - return MOD_CONT; + int flag, onmsg, offmsg; + + if (stricmp(param, "EMAIL") == 0) { + flag = NI_HIDE_EMAIL; + onmsg = NICK_SASET_HIDE_EMAIL_ON; + offmsg = NICK_SASET_HIDE_EMAIL_OFF; + } else if (stricmp(param, "USERMASK") == 0) { + flag = NI_HIDE_MASK; + onmsg = NICK_SASET_HIDE_MASK_ON; + offmsg = NICK_SASET_HIDE_MASK_OFF; + } else if (stricmp(param, "STATUS") == 0) { + flag = NI_HIDE_STATUS; + onmsg = NICK_SASET_HIDE_STATUS_ON; + offmsg = NICK_SASET_HIDE_STATUS_OFF; + } else if (stricmp(param, "QUIT") == 0) { + flag = NI_HIDE_QUIT; + onmsg = NICK_SASET_HIDE_QUIT_ON; + offmsg = NICK_SASET_HIDE_QUIT_OFF; + } else { + syntax_error(s_NickServ, u, "SASET HIDE", NICK_SASET_HIDE_SYNTAX); + return MOD_CONT; + } + + param = strtok(NULL, " "); + if (!param) { + syntax_error(s_NickServ, u, "SASET HIDE", NICK_SASET_HIDE_SYNTAX); + } else if (stricmp(param, "ON") == 0) { + nc->flags |= flag; + notice_lang(s_NickServ, u, onmsg, nc->display, s_NickServ); + } else if (stricmp(param, "OFF") == 0) { + nc->flags &= ~flag; + notice_lang(s_NickServ, u, offmsg, nc->display, s_NickServ); + } else { + syntax_error(s_NickServ, u, "SASET HIDE", NICK_SASET_HIDE_SYNTAX); + } + return MOD_CONT; } int do_saset_noexpire(User * u, NickAlias * na, char *param) { - if (!param) { - syntax_error(s_NickServ, u, "SASET NOEXPIRE", - NICK_SASET_NOEXPIRE_SYNTAX); - return MOD_CONT; - } - if (stricmp(param, "ON") == 0) { - na->status |= NS_NO_EXPIRE; - notice_lang(s_NickServ, u, NICK_SASET_NOEXPIRE_ON, na->nick); - } else if (stricmp(param, "OFF") == 0) { - na->status &= ~NS_NO_EXPIRE; - notice_lang(s_NickServ, u, NICK_SASET_NOEXPIRE_OFF, na->nick); - } else { - syntax_error(s_NickServ, u, "SASET NOEXPIRE", - NICK_SASET_NOEXPIRE_SYNTAX); - } - return MOD_CONT; + if (!param) { + syntax_error(s_NickServ, u, "SASET NOEXPIRE", + NICK_SASET_NOEXPIRE_SYNTAX); + return MOD_CONT; + } + if (stricmp(param, "ON") == 0) { + na->status |= NS_NO_EXPIRE; + notice_lang(s_NickServ, u, NICK_SASET_NOEXPIRE_ON, na->nick); + } else if (stricmp(param, "OFF") == 0) { + na->status &= ~NS_NO_EXPIRE; + notice_lang(s_NickServ, u, NICK_SASET_NOEXPIRE_OFF, na->nick); + } else { + syntax_error(s_NickServ, u, "SASET NOEXPIRE", + NICK_SASET_NOEXPIRE_SYNTAX); + } + return MOD_CONT; } int do_saset_autoop(User * u, NickCore * nc, char *param) { - if (stricmp(param, "ON") == 0) { - nc->flags &= ~NI_AUTOOP; - notice_lang(s_NickServ, u, NICK_SASET_AUTOOP_ON, nc->display); - } else if (stricmp(param, "OFF") == 0) { + if (stricmp(param, "ON") == 0) { + nc->flags &= ~NI_AUTOOP; + notice_lang(s_NickServ, u, NICK_SASET_AUTOOP_ON, nc->display); + } else if (stricmp(param, "OFF") == 0) { nc->flags |= NI_AUTOOP; - notice_lang(s_NickServ, u, NICK_SASET_AUTOOP_OFF, nc->display); - } else { - syntax_error(s_NickServ, u, "SET AUTOOP", NICK_SASET_AUTOOP_SYNTAX); - } + notice_lang(s_NickServ, u, NICK_SASET_AUTOOP_OFF, nc->display); + } else { + syntax_error(s_NickServ, u, "SET AUTOOP", NICK_SASET_AUTOOP_SYNTAX); + } - return MOD_CONT; + return MOD_CONT; } int do_saset_language(User * u, NickCore * nc, char *param) { - int langnum; - - if (param[strspn(param, "0123456789")] != 0) { /* i.e. not a number */ - syntax_error(s_NickServ, u, "SASET LANGUAGE", - NICK_SASET_LANGUAGE_SYNTAX); - return MOD_CONT; - } - langnum = atoi(param) - 1; - if (langnum < 0 || langnum >= NUM_LANGS || langlist[langnum] < 0) { - notice_lang(s_NickServ, u, NICK_SASET_LANGUAGE_UNKNOWN, langnum + 1, - s_NickServ); - return MOD_CONT; - } - nc->language = langlist[langnum]; - notice_lang(s_NickServ, u, NICK_SASET_LANGUAGE_CHANGED); - - return MOD_CONT; + int langnum; + + if (param[strspn(param, "0123456789")] != 0) { /* i.e. not a number */ + syntax_error(s_NickServ, u, "SASET LANGUAGE", + NICK_SASET_LANGUAGE_SYNTAX); + return MOD_CONT; + } + langnum = atoi(param) - 1; + if (langnum < 0 || langnum >= NUM_LANGS || langlist[langnum] < 0) { + notice_lang(s_NickServ, u, NICK_SASET_LANGUAGE_UNKNOWN, langnum + 1, + s_NickServ); + return MOD_CONT; + } + nc->language = langlist[langnum]; + notice_lang(s_NickServ, u, NICK_SASET_LANGUAGE_CHANGED); + + return MOD_CONT; } /* EOF */ diff --git a/src/core/ns_sendpass.c b/src/core/ns_sendpass.c index 03ac69d38..dae1562da 100644 --- a/src/core/ns_sendpass.c +++ b/src/core/ns_sendpass.c @@ -47,7 +47,7 @@ class NSSendPass : public Module **/ void myNickServHelp(User * u) { - notice_lang(s_NickServ, u, NICK_HELP_CMD_SENDPASS); + notice_lang(s_NickServ, u, NICK_HELP_CMD_SENDPASS); } /** @@ -58,55 +58,55 @@ void myNickServHelp(User * u) int do_sendpass(User * u) { - char *nick = strtok(NULL, " "); - NickAlias *na; - - if (!nick) { - syntax_error(s_NickServ, u, "SENDPASS", NICK_SENDPASS_SYNTAX); - } else if (RestrictMail && !is_services_oper(u)) { - notice_lang(s_NickServ, u, PERMISSION_DENIED); - } else if (!(na = findnick(nick))) { - notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); - } else if (na->status & NS_VERBOTEN) { - notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); - } else { - char buf[BUFSIZE]; - char tmp_pass[PASSMAX]; - if(enc_decrypt(na->nc->pass,tmp_pass,PASSMAX - 1)==1) { - MailInfo *mail; - - snprintf(buf, sizeof(buf), getstring(na, NICK_SENDPASS_SUBJECT), - na->nick); - mail = MailBegin(u, na->nc, buf, s_NickServ); - if (!mail) - return MOD_CONT; - - fprintf(mail->pipe, getstring(na, NICK_SENDPASS_HEAD)); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_1), na->nick); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_2), - tmp_pass); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_3)); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_4)); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_5), - NetworkName); - fprintf(mail->pipe, "\n.\n"); - - MailEnd(mail); - - alog("%s: %s!%s@%s used SENDPASS on %s", s_NickServ, u->nick, - u->username, u->host, nick); - notice_lang(s_NickServ, u, NICK_SENDPASS_OK, nick); - } else { - notice_lang(s_NickServ, u, NICK_SENDPASS_UNAVAILABLE); - } - } - - return MOD_CONT; + char *nick = strtok(NULL, " "); + NickAlias *na; + + if (!nick) { + syntax_error(s_NickServ, u, "SENDPASS", NICK_SENDPASS_SYNTAX); + } else if (RestrictMail && !is_services_oper(u)) { + notice_lang(s_NickServ, u, PERMISSION_DENIED); + } else if (!(na = findnick(nick))) { + notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); + } else if (na->status & NS_VERBOTEN) { + notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); + } else { + char buf[BUFSIZE]; + char tmp_pass[PASSMAX]; + if(enc_decrypt(na->nc->pass,tmp_pass,PASSMAX - 1)==1) { + MailInfo *mail; + + snprintf(buf, sizeof(buf), getstring(na, NICK_SENDPASS_SUBJECT), + na->nick); + mail = MailBegin(u, na->nc, buf, s_NickServ); + if (!mail) + return MOD_CONT; + + fprintf(mail->pipe, getstring(na, NICK_SENDPASS_HEAD)); + fprintf(mail->pipe, "\n\n"); + fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_1), na->nick); + fprintf(mail->pipe, "\n\n"); + fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_2), + tmp_pass); + fprintf(mail->pipe, "\n\n"); + fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_3)); + fprintf(mail->pipe, "\n\n"); + fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_4)); + fprintf(mail->pipe, "\n\n"); + fprintf(mail->pipe, getstring(na, NICK_SENDPASS_LINE_5), + NetworkName); + fprintf(mail->pipe, "\n.\n"); + + MailEnd(mail); + + alog("%s: %s!%s@%s used SENDPASS on %s", s_NickServ, u->nick, + u->username, u->host, nick); + notice_lang(s_NickServ, u, NICK_SENDPASS_OK, nick); + } else { + notice_lang(s_NickServ, u, NICK_SENDPASS_UNAVAILABLE); + } + } + + return MOD_CONT; } MODULE_INIT("ns_sendpass", NSSendPass) diff --git a/src/core/ns_set.c b/src/core/ns_set.c index b8af7ebfb..b6c91b281 100644 --- a/src/core/ns_set.c +++ b/src/core/ns_set.c @@ -82,7 +82,7 @@ class NSSet : public Module **/ void myNickServHelp(User * u) { - notice_lang(s_NickServ, u, NICK_HELP_CMD_SET); + notice_lang(s_NickServ, u, NICK_HELP_CMD_SET); } /** @@ -92,359 +92,359 @@ void myNickServHelp(User * u) **/ int do_set(User * u) { - char *cmd = strtok(NULL, " "); - char *param = strtok(NULL, " "); - NickAlias *na = u->na; - - if (readonly) { - notice_lang(s_NickServ, u, NICK_SET_DISABLED); - return MOD_CONT; - } - - if (!param - && (!cmd - || (stricmp(cmd, "URL") != 0 && stricmp(cmd, "EMAIL") != 0 - && stricmp(cmd, "GREET") != 0 - && stricmp(cmd, "ICQ") != 0))) { - syntax_error(s_NickServ, u, "SET", NICK_SET_SYNTAX); - } else if (!na) { - notice_lang(s_NickServ, u, NICK_NOT_REGISTERED); - } else if (na->status & NS_VERBOTEN) { - notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); - } else if (na->nc->flags & NI_SUSPENDED) { - notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick); - } else if (!nick_identified(u)) { - notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); - } else if (stricmp(cmd, "DISPLAY") == 0) { - do_set_display(u, na->nc, param); - } else if (stricmp(cmd, "PASSWORD") == 0) { - do_set_password(u, na->nc, param); - } else if (stricmp(cmd, "LANGUAGE") == 0) { - do_set_language(u, na->nc, param); - } else if (stricmp(cmd, "URL") == 0) { - do_set_url(u, na->nc, param); - } else if (stricmp(cmd, "EMAIL") == 0) { - do_set_email(u, na->nc, param); - } else if (stricmp(cmd, "ICQ") == 0) { - do_set_icq(u, na->nc, param); - } else if (stricmp(cmd, "GREET") == 0) { - do_set_greet(u, na->nc, param); - } else if (stricmp(cmd, "KILL") == 0) { - do_set_kill(u, na->nc, param); - } else if (stricmp(cmd, "SECURE") == 0) { - do_set_secure(u, na->nc, param); - } else if (stricmp(cmd, "PRIVATE") == 0) { - do_set_private(u, na->nc, param); - } else if (stricmp(cmd, "MSG") == 0) { - do_set_msg(u, na->nc, param); - } else if (stricmp(cmd, "HIDE") == 0) { - do_set_hide(u, na->nc, param); - } else if (stricmp(cmd, "AUTOOP") == 0) { - do_set_autoop(u, na->nc, param); - } else { - notice_lang(s_NickServ, u, NICK_SET_UNKNOWN_OPTION, cmd); - } - return MOD_CONT; + char *cmd = strtok(NULL, " "); + char *param = strtok(NULL, " "); + NickAlias *na = u->na; + + if (readonly) { + notice_lang(s_NickServ, u, NICK_SET_DISABLED); + return MOD_CONT; + } + + if (!param + && (!cmd + || (stricmp(cmd, "URL") != 0 && stricmp(cmd, "EMAIL") != 0 + && stricmp(cmd, "GREET") != 0 + && stricmp(cmd, "ICQ") != 0))) { + syntax_error(s_NickServ, u, "SET", NICK_SET_SYNTAX); + } else if (!na) { + notice_lang(s_NickServ, u, NICK_NOT_REGISTERED); + } else if (na->status & NS_VERBOTEN) { + notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); + } else if (na->nc->flags & NI_SUSPENDED) { + notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick); + } else if (!nick_identified(u)) { + notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); + } else if (stricmp(cmd, "DISPLAY") == 0) { + do_set_display(u, na->nc, param); + } else if (stricmp(cmd, "PASSWORD") == 0) { + do_set_password(u, na->nc, param); + } else if (stricmp(cmd, "LANGUAGE") == 0) { + do_set_language(u, na->nc, param); + } else if (stricmp(cmd, "URL") == 0) { + do_set_url(u, na->nc, param); + } else if (stricmp(cmd, "EMAIL") == 0) { + do_set_email(u, na->nc, param); + } else if (stricmp(cmd, "ICQ") == 0) { + do_set_icq(u, na->nc, param); + } else if (stricmp(cmd, "GREET") == 0) { + do_set_greet(u, na->nc, param); + } else if (stricmp(cmd, "KILL") == 0) { + do_set_kill(u, na->nc, param); + } else if (stricmp(cmd, "SECURE") == 0) { + do_set_secure(u, na->nc, param); + } else if (stricmp(cmd, "PRIVATE") == 0) { + do_set_private(u, na->nc, param); + } else if (stricmp(cmd, "MSG") == 0) { + do_set_msg(u, na->nc, param); + } else if (stricmp(cmd, "HIDE") == 0) { + do_set_hide(u, na->nc, param); + } else if (stricmp(cmd, "AUTOOP") == 0) { + do_set_autoop(u, na->nc, param); + } else { + notice_lang(s_NickServ, u, NICK_SET_UNKNOWN_OPTION, cmd); + } + return MOD_CONT; } int do_set_display(User * u, NickCore * nc, char *param) { - int i; - NickAlias *na; - - /* First check whether param is a valid nick of the group */ - for (i = 0; i < nc->aliases.count; i++) { - na = (NickAlias *)nc->aliases.list[i]; - if (!stricmp(na->nick, param)) { - param = na->nick; /* Because case may differ */ - break; - } - } - - if (i == nc->aliases.count) { - notice_lang(s_NickServ, u, NICK_SET_DISPLAY_INVALID); - return MOD_CONT; - } - - change_core_display(nc, param); - notice_lang(s_NickServ, u, NICK_SET_DISPLAY_CHANGED, nc->display); - - /* Enable nick tracking if enabled */ - if (NSNickTracking) - nsStartNickTracking(u); - - return MOD_CONT; + int i; + NickAlias *na; + + /* First check whether param is a valid nick of the group */ + for (i = 0; i < nc->aliases.count; i++) { + na = (NickAlias *)nc->aliases.list[i]; + if (!stricmp(na->nick, param)) { + param = na->nick; /* Because case may differ */ + break; + } + } + + if (i == nc->aliases.count) { + notice_lang(s_NickServ, u, NICK_SET_DISPLAY_INVALID); + return MOD_CONT; + } + + change_core_display(nc, param); + notice_lang(s_NickServ, u, NICK_SET_DISPLAY_CHANGED, nc->display); + + /* Enable nick tracking if enabled */ + if (NSNickTracking) + nsStartNickTracking(u); + + return MOD_CONT; } int do_set_password(User * u, NickCore * nc, char *param) { - int len = strlen(param); - char tmp_pass[PASSMAX]; - - if (stricmp(nc->display, param) == 0 || (StrictPasswords && len < 5)) { - notice_lang(s_NickServ, u, MORE_OBSCURE_PASSWORD); - return MOD_CONT; - } else if (enc_encrypt_check_len(len ,PASSMAX - 1)) { - notice_lang(s_NickServ, u, PASSWORD_TOO_LONG); - return MOD_CONT; - } - - if (enc_encrypt(param, len, nc->pass, PASSMAX - 1) < 0) { - memset(param, 0, len); - alog("%s: Failed to encrypt password for %s (set)", s_NickServ, - nc->display); - notice_lang(s_NickServ, u, NICK_SET_PASSWORD_FAILED); - return MOD_CONT; - } - memset(param, 0, len); - - if(enc_decrypt(nc->pass,tmp_pass,PASSMAX - 1)==1) { - notice_lang(s_NickServ, u, NICK_SET_PASSWORD_CHANGED_TO, tmp_pass); - } else { - notice_lang(s_NickServ, u, NICK_SET_PASSWORD_CHANGED); - } - - alog("%s: %s!%s@%s (e-mail: %s) changed its password.", s_NickServ, - u->nick, u->username, u->host, (nc->email ? nc->email : "none")); - - return MOD_CONT; + int len = strlen(param); + char tmp_pass[PASSMAX]; + + if (stricmp(nc->display, param) == 0 || (StrictPasswords && len < 5)) { + notice_lang(s_NickServ, u, MORE_OBSCURE_PASSWORD); + return MOD_CONT; + } else if (enc_encrypt_check_len(len ,PASSMAX - 1)) { + notice_lang(s_NickServ, u, PASSWORD_TOO_LONG); + return MOD_CONT; + } + + if (enc_encrypt(param, len, nc->pass, PASSMAX - 1) < 0) { + memset(param, 0, len); + alog("%s: Failed to encrypt password for %s (set)", s_NickServ, + nc->display); + notice_lang(s_NickServ, u, NICK_SET_PASSWORD_FAILED); + return MOD_CONT; + } + memset(param, 0, len); + + if(enc_decrypt(nc->pass,tmp_pass,PASSMAX - 1)==1) { + notice_lang(s_NickServ, u, NICK_SET_PASSWORD_CHANGED_TO, tmp_pass); + } else { + notice_lang(s_NickServ, u, NICK_SET_PASSWORD_CHANGED); + } + + alog("%s: %s!%s@%s (e-mail: %s) changed its password.", s_NickServ, + u->nick, u->username, u->host, (nc->email ? nc->email : "none")); + + return MOD_CONT; } int do_set_language(User * u, NickCore * nc, char *param) { - int langnum; - - if (param[strspn(param, "0123456789")] != 0) { /* i.e. not a number */ - syntax_error(s_NickServ, u, "SET LANGUAGE", - NICK_SET_LANGUAGE_SYNTAX); - return MOD_CONT; - } - langnum = atoi(param) - 1; - if (langnum < 0 || langnum >= NUM_LANGS || langlist[langnum] < 0) { - notice_lang(s_NickServ, u, NICK_SET_LANGUAGE_UNKNOWN, langnum + 1, - s_NickServ); - return MOD_CONT; - } - nc->language = langlist[langnum]; - notice_lang(s_NickServ, u, NICK_SET_LANGUAGE_CHANGED); - return MOD_CONT; + int langnum; + + if (param[strspn(param, "0123456789")] != 0) { /* i.e. not a number */ + syntax_error(s_NickServ, u, "SET LANGUAGE", + NICK_SET_LANGUAGE_SYNTAX); + return MOD_CONT; + } + langnum = atoi(param) - 1; + if (langnum < 0 || langnum >= NUM_LANGS || langlist[langnum] < 0) { + notice_lang(s_NickServ, u, NICK_SET_LANGUAGE_UNKNOWN, langnum + 1, + s_NickServ); + return MOD_CONT; + } + nc->language = langlist[langnum]; + notice_lang(s_NickServ, u, NICK_SET_LANGUAGE_CHANGED); + return MOD_CONT; } int do_set_url(User * u, NickCore * nc, char *param) { - if (nc->url) - free(nc->url); - - if (param) { - nc->url = sstrdup(param); - notice_lang(s_NickServ, u, NICK_SET_URL_CHANGED, param); - } else { - nc->url = NULL; - notice_lang(s_NickServ, u, NICK_SET_URL_UNSET); - } - return MOD_CONT; + if (nc->url) + free(nc->url); + + if (param) { + nc->url = sstrdup(param); + notice_lang(s_NickServ, u, NICK_SET_URL_CHANGED, param); + } else { + nc->url = NULL; + notice_lang(s_NickServ, u, NICK_SET_URL_UNSET); + } + return MOD_CONT; } int do_set_email(User * u, NickCore * nc, char *param) { - if (!param && NSForceEmail) { - notice_lang(s_NickServ, u, NICK_SET_EMAIL_UNSET_IMPOSSIBLE); - return MOD_CONT; - } else if (param && !MailValidate(param)) { - notice_lang(s_NickServ, u, MAIL_X_INVALID, param); - return MOD_CONT; - } - - alog("%s: %s!%s@%s (e-mail: %s) changed its e-mail to %s.", - s_NickServ, u->nick, u->username, u->host, - (nc->email ? nc->email : "none"), (param ? param : "none")); - - if (nc->email) - free(nc->email); - - if (param) { - nc->email = sstrdup(param); - notice_lang(s_NickServ, u, NICK_SET_EMAIL_CHANGED, param); - } else { - nc->email = NULL; - notice_lang(s_NickServ, u, NICK_SET_EMAIL_UNSET); - } - return MOD_CONT; + if (!param && NSForceEmail) { + notice_lang(s_NickServ, u, NICK_SET_EMAIL_UNSET_IMPOSSIBLE); + return MOD_CONT; + } else if (param && !MailValidate(param)) { + notice_lang(s_NickServ, u, MAIL_X_INVALID, param); + return MOD_CONT; + } + + alog("%s: %s!%s@%s (e-mail: %s) changed its e-mail to %s.", + s_NickServ, u->nick, u->username, u->host, + (nc->email ? nc->email : "none"), (param ? param : "none")); + + if (nc->email) + free(nc->email); + + if (param) { + nc->email = sstrdup(param); + notice_lang(s_NickServ, u, NICK_SET_EMAIL_CHANGED, param); + } else { + nc->email = NULL; + notice_lang(s_NickServ, u, NICK_SET_EMAIL_UNSET); + } + return MOD_CONT; } int do_set_icq(User * u, NickCore * nc, char *param) { - if (param) { - int32 tmp = atol(param); - if (!tmp) { - notice_lang(s_NickServ, u, NICK_SET_ICQ_INVALID, param); - } else { - nc->icq = tmp; - notice_lang(s_NickServ, u, NICK_SET_ICQ_CHANGED, param); - } - } else { - nc->icq = 0; - notice_lang(s_NickServ, u, NICK_SET_ICQ_UNSET); - } - return MOD_CONT; + if (param) { + int32 tmp = atol(param); + if (!tmp) { + notice_lang(s_NickServ, u, NICK_SET_ICQ_INVALID, param); + } else { + nc->icq = tmp; + notice_lang(s_NickServ, u, NICK_SET_ICQ_CHANGED, param); + } + } else { + nc->icq = 0; + notice_lang(s_NickServ, u, NICK_SET_ICQ_UNSET); + } + return MOD_CONT; } int do_set_greet(User * u, NickCore * nc, char *param) { - if (nc->greet) - free(nc->greet); - - if (param) { - char buf[BUFSIZE]; - char *end = strtok(NULL, ""); - - snprintf(buf, sizeof(buf), "%s%s%s", param, (end ? " " : ""), - (end ? end : "")); - - nc->greet = sstrdup(buf); - notice_lang(s_NickServ, u, NICK_SET_GREET_CHANGED, buf); - } else { - nc->greet = NULL; - notice_lang(s_NickServ, u, NICK_SET_GREET_UNSET); - } - return MOD_CONT; + if (nc->greet) + free(nc->greet); + + if (param) { + char buf[BUFSIZE]; + char *end = strtok(NULL, ""); + + snprintf(buf, sizeof(buf), "%s%s%s", param, (end ? " " : ""), + (end ? end : "")); + + nc->greet = sstrdup(buf); + notice_lang(s_NickServ, u, NICK_SET_GREET_CHANGED, buf); + } else { + nc->greet = NULL; + notice_lang(s_NickServ, u, NICK_SET_GREET_UNSET); + } + return MOD_CONT; } int do_set_kill(User * u, NickCore * nc, char *param) { - if (stricmp(param, "ON") == 0) { - nc->flags |= NI_KILLPROTECT; - nc->flags &= ~(NI_KILL_QUICK | NI_KILL_IMMED); - notice_lang(s_NickServ, u, NICK_SET_KILL_ON); - } else if (stricmp(param, "QUICK") == 0) { - nc->flags |= NI_KILLPROTECT | NI_KILL_QUICK; - nc->flags &= ~NI_KILL_IMMED; - notice_lang(s_NickServ, u, NICK_SET_KILL_QUICK); - } else if (stricmp(param, "IMMED") == 0) { - if (NSAllowKillImmed) { - nc->flags |= NI_KILLPROTECT | NI_KILL_IMMED; - nc->flags &= ~NI_KILL_QUICK; - notice_lang(s_NickServ, u, NICK_SET_KILL_IMMED); - } else { - notice_lang(s_NickServ, u, NICK_SET_KILL_IMMED_DISABLED); - } - } else if (stricmp(param, "OFF") == 0) { - nc->flags &= ~(NI_KILLPROTECT | NI_KILL_QUICK | NI_KILL_IMMED); - notice_lang(s_NickServ, u, NICK_SET_KILL_OFF); - } else { - syntax_error(s_NickServ, u, "SET KILL", - NSAllowKillImmed ? NICK_SET_KILL_IMMED_SYNTAX : - NICK_SET_KILL_SYNTAX); - } - return MOD_CONT; + if (stricmp(param, "ON") == 0) { + nc->flags |= NI_KILLPROTECT; + nc->flags &= ~(NI_KILL_QUICK | NI_KILL_IMMED); + notice_lang(s_NickServ, u, NICK_SET_KILL_ON); + } else if (stricmp(param, "QUICK") == 0) { + nc->flags |= NI_KILLPROTECT | NI_KILL_QUICK; + nc->flags &= ~NI_KILL_IMMED; + notice_lang(s_NickServ, u, NICK_SET_KILL_QUICK); + } else if (stricmp(param, "IMMED") == 0) { + if (NSAllowKillImmed) { + nc->flags |= NI_KILLPROTECT | NI_KILL_IMMED; + nc->flags &= ~NI_KILL_QUICK; + notice_lang(s_NickServ, u, NICK_SET_KILL_IMMED); + } else { + notice_lang(s_NickServ, u, NICK_SET_KILL_IMMED_DISABLED); + } + } else if (stricmp(param, "OFF") == 0) { + nc->flags &= ~(NI_KILLPROTECT | NI_KILL_QUICK | NI_KILL_IMMED); + notice_lang(s_NickServ, u, NICK_SET_KILL_OFF); + } else { + syntax_error(s_NickServ, u, "SET KILL", + NSAllowKillImmed ? NICK_SET_KILL_IMMED_SYNTAX : + NICK_SET_KILL_SYNTAX); + } + return MOD_CONT; } int do_set_secure(User * u, NickCore * nc, char *param) { - if (stricmp(param, "ON") == 0) { - nc->flags |= NI_SECURE; - notice_lang(s_NickServ, u, NICK_SET_SECURE_ON); - } else if (stricmp(param, "OFF") == 0) { - nc->flags &= ~NI_SECURE; - notice_lang(s_NickServ, u, NICK_SET_SECURE_OFF); - } else { - syntax_error(s_NickServ, u, "SET SECURE", NICK_SET_SECURE_SYNTAX); - } - return MOD_CONT; + if (stricmp(param, "ON") == 0) { + nc->flags |= NI_SECURE; + notice_lang(s_NickServ, u, NICK_SET_SECURE_ON); + } else if (stricmp(param, "OFF") == 0) { + nc->flags &= ~NI_SECURE; + notice_lang(s_NickServ, u, NICK_SET_SECURE_OFF); + } else { + syntax_error(s_NickServ, u, "SET SECURE", NICK_SET_SECURE_SYNTAX); + } + return MOD_CONT; } int do_set_private(User * u, NickCore * nc, char *param) { - if (stricmp(param, "ON") == 0) { - nc->flags |= NI_PRIVATE; - notice_lang(s_NickServ, u, NICK_SET_PRIVATE_ON); - } else if (stricmp(param, "OFF") == 0) { - nc->flags &= ~NI_PRIVATE; - notice_lang(s_NickServ, u, NICK_SET_PRIVATE_OFF); - } else { - syntax_error(s_NickServ, u, "SET PRIVATE", - NICK_SET_PRIVATE_SYNTAX); - } - return MOD_CONT; + if (stricmp(param, "ON") == 0) { + nc->flags |= NI_PRIVATE; + notice_lang(s_NickServ, u, NICK_SET_PRIVATE_ON); + } else if (stricmp(param, "OFF") == 0) { + nc->flags &= ~NI_PRIVATE; + notice_lang(s_NickServ, u, NICK_SET_PRIVATE_OFF); + } else { + syntax_error(s_NickServ, u, "SET PRIVATE", + NICK_SET_PRIVATE_SYNTAX); + } + return MOD_CONT; } int do_set_msg(User * u, NickCore * nc, char *param) { - if (!UsePrivmsg) { - notice_lang(s_NickServ, u, NICK_SET_OPTION_DISABLED, "MSG"); - return MOD_CONT; - } - - if (stricmp(param, "ON") == 0) { - nc->flags |= NI_MSG; - notice_lang(s_NickServ, u, NICK_SET_MSG_ON); - } else if (stricmp(param, "OFF") == 0) { - nc->flags &= ~NI_MSG; - notice_lang(s_NickServ, u, NICK_SET_MSG_OFF); - } else { - syntax_error(s_NickServ, u, "SET MSG", NICK_SET_MSG_SYNTAX); - } - return MOD_CONT; + if (!UsePrivmsg) { + notice_lang(s_NickServ, u, NICK_SET_OPTION_DISABLED, "MSG"); + return MOD_CONT; + } + + if (stricmp(param, "ON") == 0) { + nc->flags |= NI_MSG; + notice_lang(s_NickServ, u, NICK_SET_MSG_ON); + } else if (stricmp(param, "OFF") == 0) { + nc->flags &= ~NI_MSG; + notice_lang(s_NickServ, u, NICK_SET_MSG_OFF); + } else { + syntax_error(s_NickServ, u, "SET MSG", NICK_SET_MSG_SYNTAX); + } + return MOD_CONT; } int do_set_hide(User * u, NickCore * nc, char *param) { - int flag, onmsg, offmsg; - - if (stricmp(param, "EMAIL") == 0) { - flag = NI_HIDE_EMAIL; - onmsg = NICK_SET_HIDE_EMAIL_ON; - offmsg = NICK_SET_HIDE_EMAIL_OFF; - } else if (stricmp(param, "USERMASK") == 0) { - flag = NI_HIDE_MASK; - onmsg = NICK_SET_HIDE_MASK_ON; - offmsg = NICK_SET_HIDE_MASK_OFF; - } else if (stricmp(param, "STATUS") == 0) { - flag = NI_HIDE_STATUS; - onmsg = NICK_SET_HIDE_STATUS_ON; - offmsg = NICK_SET_HIDE_STATUS_OFF; - } else if (stricmp(param, "QUIT") == 0) { - flag = NI_HIDE_QUIT; - onmsg = NICK_SET_HIDE_QUIT_ON; - offmsg = NICK_SET_HIDE_QUIT_OFF; - } else { - syntax_error(s_NickServ, u, "SET HIDE", NICK_SET_HIDE_SYNTAX); - return MOD_CONT; - } - - param = strtok(NULL, " "); - if (!param) { - syntax_error(s_NickServ, u, "SET HIDE", NICK_SET_HIDE_SYNTAX); - } else if (stricmp(param, "ON") == 0) { - nc->flags |= flag; - notice_lang(s_NickServ, u, onmsg, s_NickServ); - } else if (stricmp(param, "OFF") == 0) { - nc->flags &= ~flag; - notice_lang(s_NickServ, u, offmsg, s_NickServ); - } else { - syntax_error(s_NickServ, u, "SET HIDE", NICK_SET_HIDE_SYNTAX); - } - return MOD_CONT; + int flag, onmsg, offmsg; + + if (stricmp(param, "EMAIL") == 0) { + flag = NI_HIDE_EMAIL; + onmsg = NICK_SET_HIDE_EMAIL_ON; + offmsg = NICK_SET_HIDE_EMAIL_OFF; + } else if (stricmp(param, "USERMASK") == 0) { + flag = NI_HIDE_MASK; + onmsg = NICK_SET_HIDE_MASK_ON; + offmsg = NICK_SET_HIDE_MASK_OFF; + } else if (stricmp(param, "STATUS") == 0) { + flag = NI_HIDE_STATUS; + onmsg = NICK_SET_HIDE_STATUS_ON; + offmsg = NICK_SET_HIDE_STATUS_OFF; + } else if (stricmp(param, "QUIT") == 0) { + flag = NI_HIDE_QUIT; + onmsg = NICK_SET_HIDE_QUIT_ON; + offmsg = NICK_SET_HIDE_QUIT_OFF; + } else { + syntax_error(s_NickServ, u, "SET HIDE", NICK_SET_HIDE_SYNTAX); + return MOD_CONT; + } + + param = strtok(NULL, " "); + if (!param) { + syntax_error(s_NickServ, u, "SET HIDE", NICK_SET_HIDE_SYNTAX); + } else if (stricmp(param, "ON") == 0) { + nc->flags |= flag; + notice_lang(s_NickServ, u, onmsg, s_NickServ); + } else if (stricmp(param, "OFF") == 0) { + nc->flags &= ~flag; + notice_lang(s_NickServ, u, offmsg, s_NickServ); + } else { + syntax_error(s_NickServ, u, "SET HIDE", NICK_SET_HIDE_SYNTAX); + } + return MOD_CONT; } int do_set_autoop(User *u, NickCore *nc, char *param) { - /** - * This works the other way around, the absence of this flag denotes ON - * This is so when people upgrade, and dont have the flag - * the default is on - **/ - if (stricmp(param, "ON") == 0) { - nc->flags &= ~NI_AUTOOP; - notice_lang(s_NickServ, u, NICK_SET_AUTOOP_ON); - } else if (stricmp(param, "OFF") == 0) { + /** + * This works the other way around, the absence of this flag denotes ON + * This is so when people upgrade, and dont have the flag + * the default is on + **/ + if (stricmp(param, "ON") == 0) { + nc->flags &= ~NI_AUTOOP; + notice_lang(s_NickServ, u, NICK_SET_AUTOOP_ON); + } else if (stricmp(param, "OFF") == 0) { nc->flags |= NI_AUTOOP; - notice_lang(s_NickServ, u, NICK_SET_AUTOOP_OFF); - } else { - syntax_error(s_NickServ, u, "SET AUTOOP", NICK_SET_AUTOOP_SYNTAX); - } + notice_lang(s_NickServ, u, NICK_SET_AUTOOP_OFF); + } else { + syntax_error(s_NickServ, u, "SET AUTOOP", NICK_SET_AUTOOP_SYNTAX); + } - return MOD_CONT; + return MOD_CONT; } diff --git a/src/core/ns_status.c b/src/core/ns_status.c index 45fb1c3e8..a67d12c3c 100644 --- a/src/core/ns_status.c +++ b/src/core/ns_status.c @@ -42,7 +42,7 @@ class NSStatus : public Module **/ void myNickServHelp(User * u) { - notice_lang(s_NickServ, u, NICK_HELP_CMD_STATUS); + notice_lang(s_NickServ, u, NICK_HELP_CMD_STATUS); } /** @@ -52,32 +52,32 @@ void myNickServHelp(User * u) **/ int do_status(User * u) { - User *u2; - NickAlias *na = NULL; - int i = 0; - char *nick = strtok(NULL, " "); + User *u2; + NickAlias *na = NULL; + int i = 0; + char *nick = strtok(NULL, " "); - /* If no nickname is given, we assume that the user - * is asking for himself */ - if (!nick) - nick = u->nick; + /* If no nickname is given, we assume that the user + * is asking for himself */ + if (!nick) + nick = u->nick; - while (nick && (i++ < 16)) { - if (!(u2 = finduser(nick))) /* Nick is not online */ - notice_lang(s_NickServ, u, NICK_STATUS_0, nick); - else if (nick_identified(u2)) /* Nick is identified */ - notice_lang(s_NickServ, u, NICK_STATUS_3, nick); - else if (nick_recognized(u2)) /* Nick is recognised, but NOT identified */ - notice_lang(s_NickServ, u, NICK_STATUS_2, nick); - else if ((na = findnick(nick)) == NULL) /* Nick is online, but NOT a registered */ - notice_lang(s_NickServ, u, NICK_STATUS_0, nick); - else - notice_lang(s_NickServ, u, NICK_STATUS_1, nick); + while (nick && (i++ < 16)) { + if (!(u2 = finduser(nick))) /* Nick is not online */ + notice_lang(s_NickServ, u, NICK_STATUS_0, nick); + else if (nick_identified(u2)) /* Nick is identified */ + notice_lang(s_NickServ, u, NICK_STATUS_3, nick); + else if (nick_recognized(u2)) /* Nick is recognised, but NOT identified */ + notice_lang(s_NickServ, u, NICK_STATUS_2, nick); + else if ((na = findnick(nick)) == NULL) /* Nick is online, but NOT a registered */ + notice_lang(s_NickServ, u, NICK_STATUS_0, nick); + else + notice_lang(s_NickServ, u, NICK_STATUS_1, nick); - /* Get the next nickname */ - nick = strtok(NULL, " "); - } - return MOD_CONT; + /* Get the next nickname */ + nick = strtok(NULL, " "); + } + return MOD_CONT; } MODULE_INIT("ns_status", NSStatus) diff --git a/src/core/ns_suspend.c b/src/core/ns_suspend.c index 76966b149..4428e710e 100644 --- a/src/core/ns_suspend.c +++ b/src/core/ns_suspend.c @@ -45,10 +45,10 @@ class NSSuspend : public Module **/ void myNickServHelp(User * u) { - if (is_services_oper(u)) { - notice_lang(s_NickServ, u, NICK_HELP_CMD_SUSPEND); - notice_lang(s_NickServ, u, NICK_HELP_CMD_UNSUSPEND); - } + if (is_services_oper(u)) { + notice_lang(s_NickServ, u, NICK_HELP_CMD_SUSPEND); + notice_lang(s_NickServ, u, NICK_HELP_CMD_UNSUSPEND); + } } /** @@ -58,121 +58,121 @@ void myNickServHelp(User * u) **/ int do_suspend(User * u) { - NickAlias *na, *na2; - char *nick = strtok(NULL, " "); - char *reason = strtok(NULL, ""); - int i; - - if (!nick || !reason) { - syntax_error(s_NickServ, u, "SUSPEND", NICK_SUSPEND_SYNTAX); - return MOD_CONT; - } - - if (readonly) { - notice_lang(s_NickServ, u, READ_ONLY_MODE); - return MOD_CONT; - } - - if ((na = findnick(nick)) == NULL) { - notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); - return MOD_CONT; - } - - if (na->status & NS_VERBOTEN) { - notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); - return MOD_CONT; - } - - if (NSSecureAdmins && nick_is_services_admin(na->nc) - && !is_services_root(u)) { - notice_lang(s_NickServ, u, PERMISSION_DENIED); - return MOD_CONT; - } - - if (na) { - na->nc->flags |= NI_SUSPENDED; - na->nc->flags |= NI_SECURE; - na->nc->flags &= ~(NI_KILLPROTECT | NI_KILL_QUICK | NI_KILL_IMMED); - - for (i = 0; i < na->nc->aliases.count; i++) { - na2 = (NickAlias *)na->nc->aliases.list[i]; - if (na2->nc == na->nc) { - na2->status &= ~(NS_IDENTIFIED | NS_RECOGNIZED); - na2->last_quit = sstrdup(reason); - } - } - - if (WallForbid) - ircdproto->SendGlobops(s_NickServ, "\2%s\2 used SUSPEND on \2%s\2", - u->nick, nick); - - alog("%s: %s set SUSPEND for nick %s", s_NickServ, u->nick, nick); - notice_lang(s_NickServ, u, NICK_SUSPEND_SUCCEEDED, nick); - send_event(EVENT_NICK_SUSPENDED, 1, nick); - - } else { - - alog("%s: Valid SUSPEND for %s by %s failed", s_NickServ, nick, - u->nick); - notice_lang(s_NickServ, u, NICK_SUSPEND_FAILED, nick); - - } - return MOD_CONT; + NickAlias *na, *na2; + char *nick = strtok(NULL, " "); + char *reason = strtok(NULL, ""); + int i; + + if (!nick || !reason) { + syntax_error(s_NickServ, u, "SUSPEND", NICK_SUSPEND_SYNTAX); + return MOD_CONT; + } + + if (readonly) { + notice_lang(s_NickServ, u, READ_ONLY_MODE); + return MOD_CONT; + } + + if ((na = findnick(nick)) == NULL) { + notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); + return MOD_CONT; + } + + if (na->status & NS_VERBOTEN) { + notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); + return MOD_CONT; + } + + if (NSSecureAdmins && nick_is_services_admin(na->nc) + && !is_services_root(u)) { + notice_lang(s_NickServ, u, PERMISSION_DENIED); + return MOD_CONT; + } + + if (na) { + na->nc->flags |= NI_SUSPENDED; + na->nc->flags |= NI_SECURE; + na->nc->flags &= ~(NI_KILLPROTECT | NI_KILL_QUICK | NI_KILL_IMMED); + + for (i = 0; i < na->nc->aliases.count; i++) { + na2 = (NickAlias *)na->nc->aliases.list[i]; + if (na2->nc == na->nc) { + na2->status &= ~(NS_IDENTIFIED | NS_RECOGNIZED); + na2->last_quit = sstrdup(reason); + } + } + + if (WallForbid) + ircdproto->SendGlobops(s_NickServ, "\2%s\2 used SUSPEND on \2%s\2", + u->nick, nick); + + alog("%s: %s set SUSPEND for nick %s", s_NickServ, u->nick, nick); + notice_lang(s_NickServ, u, NICK_SUSPEND_SUCCEEDED, nick); + send_event(EVENT_NICK_SUSPENDED, 1, nick); + + } else { + + alog("%s: Valid SUSPEND for %s by %s failed", s_NickServ, nick, + u->nick); + notice_lang(s_NickServ, u, NICK_SUSPEND_FAILED, nick); + + } + return MOD_CONT; } /*************************************************************************/ int do_unsuspend(User * u) { - NickAlias *na; - char *nick = strtok(NULL, " "); - - if (!nick) { - syntax_error(s_NickServ, u, "UNSUSPEND", NICK_UNSUSPEND_SYNTAX); - return MOD_CONT; - } - - if (readonly) { - notice_lang(s_NickServ, u, READ_ONLY_MODE); - return MOD_CONT; - } - - if ((na = findnick(nick)) == NULL) { - notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); - return MOD_CONT; - } - - if (na->status & NS_VERBOTEN) { - notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); - return MOD_CONT; - } - if (NSSecureAdmins && nick_is_services_admin(na->nc) - && !is_services_root(u)) { - notice_lang(s_NickServ, u, PERMISSION_DENIED); - return MOD_CONT; - } - - if (na) { - na->nc->flags &= ~NI_SUSPENDED; - - if (WallForbid) - ircdproto->SendGlobops(s_NickServ, "\2%s\2 used UNSUSPEND on \2%s\2", - u->nick, nick); - - alog("%s: %s set UNSUSPEND for nick %s", s_NickServ, u->nick, - nick); - notice_lang(s_NickServ, u, NICK_UNSUSPEND_SUCCEEDED, nick); - send_event(EVENT_NICK_UNSUSPEND, 1, nick); - - } else { - - alog("%s: Valid UNSUSPEND for %s by %s failed", s_NickServ, nick, - u->nick); - notice_lang(s_NickServ, u, NICK_UNSUSPEND_FAILED, nick); - - } - - return MOD_CONT; + NickAlias *na; + char *nick = strtok(NULL, " "); + + if (!nick) { + syntax_error(s_NickServ, u, "UNSUSPEND", NICK_UNSUSPEND_SYNTAX); + return MOD_CONT; + } + + if (readonly) { + notice_lang(s_NickServ, u, READ_ONLY_MODE); + return MOD_CONT; + } + + if ((na = findnick(nick)) == NULL) { + notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, nick); + return MOD_CONT; + } + + if (na->status & NS_VERBOTEN) { + notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick); + return MOD_CONT; + } + if (NSSecureAdmins && nick_is_services_admin(na->nc) + && !is_services_root(u)) { + notice_lang(s_NickServ, u, PERMISSION_DENIED); + return MOD_CONT; + } + + if (na) { + na->nc->flags &= ~NI_SUSPENDED; + + if (WallForbid) + ircdproto->SendGlobops(s_NickServ, "\2%s\2 used UNSUSPEND on \2%s\2", + u->nick, nick); + + alog("%s: %s set UNSUSPEND for nick %s", s_NickServ, u->nick, + nick); + notice_lang(s_NickServ, u, NICK_UNSUSPEND_SUCCEEDED, nick); + send_event(EVENT_NICK_UNSUSPEND, 1, nick); + + } else { + + alog("%s: Valid UNSUSPEND for %s by %s failed", s_NickServ, nick, + u->nick); + notice_lang(s_NickServ, u, NICK_UNSUSPEND_FAILED, nick); + + } + + return MOD_CONT; } diff --git a/src/core/ns_update.c b/src/core/ns_update.c index 851339943..76794a86d 100644 --- a/src/core/ns_update.c +++ b/src/core/ns_update.c @@ -44,7 +44,7 @@ class NSUpdate : public Module **/ void myNickServHelp(User * u) { - notice_lang(s_NickServ, u, NICK_HELP_CMD_UPDATE); + notice_lang(s_NickServ, u, NICK_HELP_CMD_UPDATE); } /** @@ -54,26 +54,26 @@ void myNickServHelp(User * u) **/ int do_nickupdate(User * u) { - NickAlias *na; + NickAlias *na; - if (!nick_identified(u)) { - notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); - } else { - na = u->na; - if (NSModeOnID) - do_setmodes(u); - check_memos(u); - if (na->last_realname) - free(na->last_realname); - na->last_realname = sstrdup(u->realname); - na->status |= NS_IDENTIFIED; - na->last_seen = time(NULL); - if (ircd->vhost) { - do_on_id(u); - } - notice_lang(s_NickServ, u, NICK_UPDATE_SUCCESS, s_NickServ); - } - return MOD_CONT; + if (!nick_identified(u)) { + notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); + } else { + na = u->na; + if (NSModeOnID) + do_setmodes(u); + check_memos(u); + if (na->last_realname) + free(na->last_realname); + na->last_realname = sstrdup(u->realname); + na->status |= NS_IDENTIFIED; + na->last_seen = time(NULL); + if (ircd->vhost) { + do_on_id(u); + } + notice_lang(s_NickServ, u, NICK_UPDATE_SUCCESS, s_NickServ); + } + return MOD_CONT; } MODULE_INIT("ns_update", NSUpdate) diff --git a/src/core/os_admin.c b/src/core/os_admin.c index d394b526c..d7e8c3c75 100644 --- a/src/core/os_admin.c +++ b/src/core/os_admin.c @@ -17,7 +17,7 @@ int do_admin(User * u); int admin_list_callback(SList * slist, int number, void *item, - va_list args); + va_list args); int admin_list(int number, NickCore * nc, User * u, int *sent_header); void myOperServHelp(User * u); @@ -49,7 +49,7 @@ class OSAdmin : public Module **/ void myOperServHelp(User * u) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_ADMIN); + notice_lang(s_OperServ, u, OPER_HELP_CMD_ADMIN); } /** @@ -59,176 +59,176 @@ void myOperServHelp(User * u) **/ int do_admin(User * u) { - char *cmd = strtok(NULL, " "); - char *nick = strtok(NULL, " "); - NickAlias *na; - int res = 0; - - if (!cmd || (!nick && stricmp(cmd, "LIST") && stricmp(cmd, "CLEAR"))) { - syntax_error(s_OperServ, u, "ADMIN", OPER_ADMIN_SYNTAX); - } else if (!stricmp(cmd, "ADD")) { - if (!is_services_root(u)) { - notice_lang(s_OperServ, u, PERMISSION_DENIED); - return MOD_CONT; - } - - if (!(na = findnick(nick))) { - notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick); - return MOD_CONT; - } - - if (na->status & NS_VERBOTEN) { - notice_lang(s_OperServ, u, NICK_X_FORBIDDEN, nick); - return MOD_CONT; - } - - if (na->nc->flags & NI_SERVICES_ADMIN - || slist_indexof(&servadmins, na->nc) != -1) { - notice_lang(s_OperServ, u, OPER_ADMIN_EXISTS, nick); - return MOD_CONT; - } - - res = slist_add(&servadmins, na->nc); - if (res == -2) { - notice_lang(s_OperServ, u, OPER_ADMIN_REACHED_LIMIT, nick); - return MOD_CONT; - } else { - if (na->nc->flags & NI_SERVICES_OPER - && (res = slist_indexof(&servopers, na->nc)) != -1) { - slist_delete(&servopers, res); - na->nc->flags |= NI_SERVICES_ADMIN; - notice_lang(s_OperServ, u, OPER_ADMIN_MOVED, nick); - } else { - na->nc->flags |= NI_SERVICES_ADMIN; - notice_lang(s_OperServ, u, OPER_ADMIN_ADDED, nick); - } - } - - if (readonly) - notice_lang(s_OperServ, u, READ_ONLY_MODE); - } else if (!stricmp(cmd, "DEL")) { - if (!is_services_root(u)) { - notice_lang(s_OperServ, u, PERMISSION_DENIED); - return MOD_CONT; - } - - if (servadmins.count == 0) { - notice_lang(s_OperServ, u, OPER_ADMIN_LIST_EMPTY); - return MOD_CONT; - } - - if (isdigit(*nick) && strspn(nick, "1234567890,-") == strlen(nick)) { - /* Deleting a range */ - res = slist_delete_range(&servadmins, nick, NULL); - if (res == 0) { - notice_lang(s_OperServ, u, OPER_ADMIN_NO_MATCH); - return MOD_CONT; - } else if (res == 1) { - notice_lang(s_OperServ, u, OPER_ADMIN_DELETED_ONE); - } else { - notice_lang(s_OperServ, u, OPER_ADMIN_DELETED_SEVERAL, - res); - } - } else { - if (!(na = findnick(nick))) { - notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick); - return MOD_CONT; - } - - if (na->status & NS_VERBOTEN) { - notice_lang(s_OperServ, u, NICK_X_FORBIDDEN, nick); - return MOD_CONT; - } - - if (!(na->nc->flags & NI_SERVICES_ADMIN) - || (res = slist_indexof(&servadmins, na->nc)) == -1) { - notice_lang(s_OperServ, u, OPER_ADMIN_NOT_FOUND, nick); - return MOD_CONT; - } - - slist_delete(&servadmins, res); - notice_lang(s_OperServ, u, OPER_ADMIN_DELETED, nick); - } - - if (readonly) - notice_lang(s_OperServ, u, READ_ONLY_MODE); - } else if (!stricmp(cmd, "LIST")) { - int sent_header = 0; + char *cmd = strtok(NULL, " "); + char *nick = strtok(NULL, " "); + NickAlias *na; + int res = 0; + + if (!cmd || (!nick && stricmp(cmd, "LIST") && stricmp(cmd, "CLEAR"))) { + syntax_error(s_OperServ, u, "ADMIN", OPER_ADMIN_SYNTAX); + } else if (!stricmp(cmd, "ADD")) { + if (!is_services_root(u)) { + notice_lang(s_OperServ, u, PERMISSION_DENIED); + return MOD_CONT; + } + + if (!(na = findnick(nick))) { + notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick); + return MOD_CONT; + } + + if (na->status & NS_VERBOTEN) { + notice_lang(s_OperServ, u, NICK_X_FORBIDDEN, nick); + return MOD_CONT; + } + + if (na->nc->flags & NI_SERVICES_ADMIN + || slist_indexof(&servadmins, na->nc) != -1) { + notice_lang(s_OperServ, u, OPER_ADMIN_EXISTS, nick); + return MOD_CONT; + } + + res = slist_add(&servadmins, na->nc); + if (res == -2) { + notice_lang(s_OperServ, u, OPER_ADMIN_REACHED_LIMIT, nick); + return MOD_CONT; + } else { + if (na->nc->flags & NI_SERVICES_OPER + && (res = slist_indexof(&servopers, na->nc)) != -1) { + slist_delete(&servopers, res); + na->nc->flags |= NI_SERVICES_ADMIN; + notice_lang(s_OperServ, u, OPER_ADMIN_MOVED, nick); + } else { + na->nc->flags |= NI_SERVICES_ADMIN; + notice_lang(s_OperServ, u, OPER_ADMIN_ADDED, nick); + } + } + + if (readonly) + notice_lang(s_OperServ, u, READ_ONLY_MODE); + } else if (!stricmp(cmd, "DEL")) { + if (!is_services_root(u)) { + notice_lang(s_OperServ, u, PERMISSION_DENIED); + return MOD_CONT; + } + + if (servadmins.count == 0) { + notice_lang(s_OperServ, u, OPER_ADMIN_LIST_EMPTY); + return MOD_CONT; + } + + if (isdigit(*nick) && strspn(nick, "1234567890,-") == strlen(nick)) { + /* Deleting a range */ + res = slist_delete_range(&servadmins, nick, NULL); + if (res == 0) { + notice_lang(s_OperServ, u, OPER_ADMIN_NO_MATCH); + return MOD_CONT; + } else if (res == 1) { + notice_lang(s_OperServ, u, OPER_ADMIN_DELETED_ONE); + } else { + notice_lang(s_OperServ, u, OPER_ADMIN_DELETED_SEVERAL, + res); + } + } else { + if (!(na = findnick(nick))) { + notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick); + return MOD_CONT; + } + + if (na->status & NS_VERBOTEN) { + notice_lang(s_OperServ, u, NICK_X_FORBIDDEN, nick); + return MOD_CONT; + } + + if (!(na->nc->flags & NI_SERVICES_ADMIN) + || (res = slist_indexof(&servadmins, na->nc)) == -1) { + notice_lang(s_OperServ, u, OPER_ADMIN_NOT_FOUND, nick); + return MOD_CONT; + } + + slist_delete(&servadmins, res); + notice_lang(s_OperServ, u, OPER_ADMIN_DELETED, nick); + } + + if (readonly) + notice_lang(s_OperServ, u, READ_ONLY_MODE); + } else if (!stricmp(cmd, "LIST")) { + int sent_header = 0; - if (servadmins.count == 0) { - notice_lang(s_OperServ, u, OPER_ADMIN_LIST_EMPTY); - return MOD_CONT; - } - - if (!nick || (isdigit(*nick) - && strspn(nick, "1234567890,-") == strlen(nick))) { - res = - slist_enum(&servadmins, nick, &admin_list_callback, u, - &sent_header); - if (res == 0) { - notice_lang(s_OperServ, u, OPER_ADMIN_NO_MATCH); - return MOD_CONT; - } else { - notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Admin"); - } - } else { - int i; - - for (i = 0; i < servadmins.count; i++) - if (!stricmp - (nick, ((NickCore *) servadmins.list[i])->display) - || match_wild_nocase(nick, - ((NickCore *) servadmins. - list[i])->display)) - admin_list(i + 1, (NickCore *)servadmins.list[i], u, &sent_header); - - if (!sent_header) - notice_lang(s_OperServ, u, OPER_ADMIN_NO_MATCH); - else { - notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Admin"); - } - } - } else if (!stricmp(cmd, "CLEAR")) { - if (!is_services_root(u)) { - notice_lang(s_OperServ, u, PERMISSION_DENIED); - return MOD_CONT; - } - - if (servadmins.count == 0) { - notice_lang(s_OperServ, u, OPER_ADMIN_LIST_EMPTY); - return MOD_CONT; - } - - slist_clear(&servadmins, 1); - notice_lang(s_OperServ, u, OPER_ADMIN_CLEAR); - } else { - syntax_error(s_OperServ, u, "ADMIN", OPER_ADMIN_SYNTAX); - } - return MOD_CONT; + if (servadmins.count == 0) { + notice_lang(s_OperServ, u, OPER_ADMIN_LIST_EMPTY); + return MOD_CONT; + } + + if (!nick || (isdigit(*nick) + && strspn(nick, "1234567890,-") == strlen(nick))) { + res = + slist_enum(&servadmins, nick, &admin_list_callback, u, + &sent_header); + if (res == 0) { + notice_lang(s_OperServ, u, OPER_ADMIN_NO_MATCH); + return MOD_CONT; + } else { + notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Admin"); + } + } else { + int i; + + for (i = 0; i < servadmins.count; i++) + if (!stricmp + (nick, ((NickCore *) servadmins.list[i])->display) + || match_wild_nocase(nick, + ((NickCore *) servadmins. + list[i])->display)) + admin_list(i + 1, (NickCore *)servadmins.list[i], u, &sent_header); + + if (!sent_header) + notice_lang(s_OperServ, u, OPER_ADMIN_NO_MATCH); + else { + notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Admin"); + } + } + } else if (!stricmp(cmd, "CLEAR")) { + if (!is_services_root(u)) { + notice_lang(s_OperServ, u, PERMISSION_DENIED); + return MOD_CONT; + } + + if (servadmins.count == 0) { + notice_lang(s_OperServ, u, OPER_ADMIN_LIST_EMPTY); + return MOD_CONT; + } + + slist_clear(&servadmins, 1); + notice_lang(s_OperServ, u, OPER_ADMIN_CLEAR); + } else { + syntax_error(s_OperServ, u, "ADMIN", OPER_ADMIN_SYNTAX); + } + return MOD_CONT; } int admin_list_callback(SList * slist, int number, void *item, - va_list args) + va_list args) { - User *u = va_arg(args, User *); - int *sent_header = va_arg(args, int *); + User *u = va_arg(args, User *); + int *sent_header = va_arg(args, int *); - return admin_list(number, (NickCore *)item, u, sent_header); + return admin_list(number, (NickCore *)item, u, sent_header); } int admin_list(int number, NickCore * nc, User * u, int *sent_header) { - if (!nc) - return 0; + if (!nc) + return 0; - if (!*sent_header) { - notice_lang(s_OperServ, u, OPER_ADMIN_LIST_HEADER); - *sent_header = 1; - } + if (!*sent_header) { + notice_lang(s_OperServ, u, OPER_ADMIN_LIST_HEADER); + *sent_header = 1; + } - notice_lang(s_OperServ, u, OPER_ADMIN_LIST_FORMAT, number, - nc->display); - return 1; + notice_lang(s_OperServ, u, OPER_ADMIN_LIST_FORMAT, number, + nc->display); + return 1; } MODULE_INIT("os_admin", OSAdmin) diff --git a/src/core/os_akill.c b/src/core/os_akill.c index 3762ca286..c67433013 100644 --- a/src/core/os_akill.c +++ b/src/core/os_akill.c @@ -17,10 +17,10 @@ int do_akill(User * u); int akill_view_callback(SList * slist, int number, void *item, - va_list args); + va_list args); int akill_view(int number, Akill * ak, User * u, int *sent_header); int akill_list_callback(SList * slist, int number, void *item, - va_list args); + va_list args); int akill_list(int number, Akill * ak, User * u, int *sent_header); void myOperServHelp(User * u); @@ -49,9 +49,9 @@ class OSAKill : public Module **/ void myOperServHelp(User * u) { - if (is_services_oper(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_AKILL); - } + if (is_services_oper(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_AKILL); + } } /** @@ -63,8 +63,8 @@ void myOperServHelp(User * u) int do_akill(User * u) { - char *cmd = strtok(NULL, " "); - char breason[BUFSIZE]; + char *cmd = strtok(NULL, " "); + char breason[BUFSIZE]; if (!cmd) { @@ -72,306 +72,306 @@ int do_akill(User * u) return MOD_CONT; } - if (!stricmp(cmd, "ADD")) { - int deleted = 0; - char *expiry, *mask, *reason; - time_t expires; - - mask = strtok(NULL, " "); - if (mask && *mask == '+') { - expiry = mask; - mask = strtok(NULL, " "); - } else { - expiry = NULL; - } - - expires = expiry ? dotime(expiry) : AutokillExpiry; - /* If the expiry given does not contain a final letter, it's in days, - * said the doc. Ah well. - */ - if (expiry && isdigit(expiry[strlen(expiry) - 1])) - expires *= 86400; - /* Do not allow less than a minute expiry time */ - if (expires != 0 && expires < 60) { - notice_lang(s_OperServ, u, BAD_EXPIRY_TIME); - return MOD_CONT; - } else if (expires > 0) { - expires += time(NULL); - } - - if (mask && (reason = strtok(NULL, ""))) { - /* We first do some sanity check on the proposed mask. */ - if (strchr(mask, '!')) { - notice_lang(s_OperServ, u, OPER_AKILL_NO_NICK); - return MOD_CONT; - } - - if (!strchr(mask, '@')) { - notice_lang(s_OperServ, u, BAD_USERHOST_MASK); - return MOD_CONT; - } - - if (mask && strspn(mask, "~@.*?") == strlen(mask)) { - notice_lang(s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask); - return MOD_CONT; - } - - /** - * Changed sprintf() to snprintf()and increased the size of - * breason to match bufsize - * -Rob - **/ - if (AddAkiller) { - snprintf(breason, sizeof(breason), "[%s] %s", u->nick, - reason); - reason = sstrdup(breason); - } - - deleted = add_akill(u, mask, u->nick, expires, reason); - if (deleted < 0) { - if (AddAkiller) { - free(reason); - } - return MOD_CONT; - } else if (deleted) { - notice_lang(s_OperServ, u, OPER_AKILL_DELETED_SEVERAL, - deleted); - } - notice_lang(s_OperServ, u, OPER_AKILL_ADDED, mask); - - if (WallOSAkill) { - char buf[128]; - - if (!expires) { - strcpy(buf, "does not expire"); - } else { - int wall_expiry = expires - time(NULL); - char *s = NULL; - - if (wall_expiry >= 86400) { - wall_expiry /= 86400; - s = "day"; - } else if (wall_expiry >= 3600) { - wall_expiry /= 3600; - s = "hour"; - } else if (wall_expiry >= 60) { - wall_expiry /= 60; - s = "minute"; - } - - snprintf(buf, sizeof(buf), "expires in %d %s%s", - wall_expiry, s, - (wall_expiry == 1) ? "" : "s"); - } - - ircdproto->SendGlobops(s_OperServ, - "%s added an AKILL for %s (%s) (%s)", - u->nick, mask, reason, buf); - } - - if (readonly) { - notice_lang(s_OperServ, u, READ_ONLY_MODE); - } - if (AddAkiller) { - free(reason); - } - } else { - syntax_error(s_OperServ, u, "AKILL", OPER_AKILL_SYNTAX); - } - - } else if (!stricmp(cmd, "DEL")) { - - char *mask; - int res = 0; - - mask = strtok(NULL, " "); - - if (!mask) { - syntax_error(s_OperServ, u, "AKILL", OPER_AKILL_SYNTAX); - return MOD_CONT; - } - - if (akills.count == 0) { - notice_lang(s_OperServ, u, OPER_AKILL_LIST_EMPTY); - return MOD_CONT; - } - - if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) { - /* Deleting a range */ - res = slist_delete_range(&akills, mask, NULL); - if (res == 0) { - notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH); - return MOD_CONT; - } else if (res == 1) { - notice_lang(s_OperServ, u, OPER_AKILL_DELETED_ONE); - } else { - notice_lang(s_OperServ, u, OPER_AKILL_DELETED_SEVERAL, - res); - } - } else { - if ((res = slist_indexof(&akills, mask)) == -1) { - notice_lang(s_OperServ, u, OPER_AKILL_NOT_FOUND, mask); - return MOD_CONT; - } - - slist_delete(&akills, res); - notice_lang(s_OperServ, u, OPER_AKILL_DELETED, mask); - } - - if (readonly) - notice_lang(s_OperServ, u, READ_ONLY_MODE); - - } else if (!stricmp(cmd, "LIST")) { - char *mask; - int res, sent_header = 0; - - if (akills.count == 0) { - notice_lang(s_OperServ, u, OPER_AKILL_LIST_EMPTY); - return MOD_CONT; - } - - mask = strtok(NULL, " "); - - if (!mask || (isdigit(*mask) - && strspn(mask, "1234567890,-") == strlen(mask))) { - res = - slist_enum(&akills, mask, &akill_list_callback, u, - &sent_header); - if (res == 0) { - notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH); - return MOD_CONT; - } else { - notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Akill"); - } - } else { - int i; - char amask[BUFSIZE]; - - for (i = 0; i < akills.count; i++) { - snprintf(amask, sizeof(amask), "%s@%s", - ((Akill *) akills.list[i])->user, - ((Akill *) akills.list[i])->host); - if (!stricmp(mask, amask) - || match_wild_nocase(mask, amask)) - akill_list(i + 1, (Akill *)akills.list[i], u, &sent_header); - } - - if (!sent_header) - notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH); - else { - notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Akill"); - } - } - } else if (!stricmp(cmd, "VIEW")) { - char *mask; - int res, sent_header = 0; - - if (akills.count == 0) { - notice_lang(s_OperServ, u, OPER_AKILL_LIST_EMPTY); - return MOD_CONT; - } - - mask = strtok(NULL, " "); - - if (!mask || (isdigit(*mask) - && strspn(mask, "1234567890,-") == strlen(mask))) { - res = - slist_enum(&akills, mask, &akill_view_callback, u, - &sent_header); - if (res == 0) { - notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH); - return MOD_CONT; - } - } else { - int i; - char amask[BUFSIZE]; - - for (i = 0; i < akills.count; i++) { - snprintf(amask, sizeof(amask), "%s@%s", - ((Akill *) akills.list[i])->user, - ((Akill *) akills.list[i])->host); - if (!stricmp(mask, amask) - || match_wild_nocase(mask, amask)) - akill_view(i + 1, (Akill *)akills.list[i], u, &sent_header); - } - - if (!sent_header) - notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH); - } - } else if (!stricmp(cmd, "CLEAR")) { - slist_clear(&akills, 1); - notice_lang(s_OperServ, u, OPER_AKILL_CLEAR); - } else { - syntax_error(s_OperServ, u, "AKILL", OPER_AKILL_SYNTAX); - } - return MOD_CONT; + if (!stricmp(cmd, "ADD")) { + int deleted = 0; + char *expiry, *mask, *reason; + time_t expires; + + mask = strtok(NULL, " "); + if (mask && *mask == '+') { + expiry = mask; + mask = strtok(NULL, " "); + } else { + expiry = NULL; + } + + expires = expiry ? dotime(expiry) : AutokillExpiry; + /* If the expiry given does not contain a final letter, it's in days, + * said the doc. Ah well. + */ + if (expiry && isdigit(expiry[strlen(expiry) - 1])) + expires *= 86400; + /* Do not allow less than a minute expiry time */ + if (expires != 0 && expires < 60) { + notice_lang(s_OperServ, u, BAD_EXPIRY_TIME); + return MOD_CONT; + } else if (expires > 0) { + expires += time(NULL); + } + + if (mask && (reason = strtok(NULL, ""))) { + /* We first do some sanity check on the proposed mask. */ + if (strchr(mask, '!')) { + notice_lang(s_OperServ, u, OPER_AKILL_NO_NICK); + return MOD_CONT; + } + + if (!strchr(mask, '@')) { + notice_lang(s_OperServ, u, BAD_USERHOST_MASK); + return MOD_CONT; + } + + if (mask && strspn(mask, "~@.*?") == strlen(mask)) { + notice_lang(s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask); + return MOD_CONT; + } + + /** + * Changed sprintf() to snprintf()and increased the size of + * breason to match bufsize + * -Rob + **/ + if (AddAkiller) { + snprintf(breason, sizeof(breason), "[%s] %s", u->nick, + reason); + reason = sstrdup(breason); + } + + deleted = add_akill(u, mask, u->nick, expires, reason); + if (deleted < 0) { + if (AddAkiller) { + free(reason); + } + return MOD_CONT; + } else if (deleted) { + notice_lang(s_OperServ, u, OPER_AKILL_DELETED_SEVERAL, + deleted); + } + notice_lang(s_OperServ, u, OPER_AKILL_ADDED, mask); + + if (WallOSAkill) { + char buf[128]; + + if (!expires) { + strcpy(buf, "does not expire"); + } else { + int wall_expiry = expires - time(NULL); + char *s = NULL; + + if (wall_expiry >= 86400) { + wall_expiry /= 86400; + s = "day"; + } else if (wall_expiry >= 3600) { + wall_expiry /= 3600; + s = "hour"; + } else if (wall_expiry >= 60) { + wall_expiry /= 60; + s = "minute"; + } + + snprintf(buf, sizeof(buf), "expires in %d %s%s", + wall_expiry, s, + (wall_expiry == 1) ? "" : "s"); + } + + ircdproto->SendGlobops(s_OperServ, + "%s added an AKILL for %s (%s) (%s)", + u->nick, mask, reason, buf); + } + + if (readonly) { + notice_lang(s_OperServ, u, READ_ONLY_MODE); + } + if (AddAkiller) { + free(reason); + } + } else { + syntax_error(s_OperServ, u, "AKILL", OPER_AKILL_SYNTAX); + } + + } else if (!stricmp(cmd, "DEL")) { + + char *mask; + int res = 0; + + mask = strtok(NULL, " "); + + if (!mask) { + syntax_error(s_OperServ, u, "AKILL", OPER_AKILL_SYNTAX); + return MOD_CONT; + } + + if (akills.count == 0) { + notice_lang(s_OperServ, u, OPER_AKILL_LIST_EMPTY); + return MOD_CONT; + } + + if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) { + /* Deleting a range */ + res = slist_delete_range(&akills, mask, NULL); + if (res == 0) { + notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH); + return MOD_CONT; + } else if (res == 1) { + notice_lang(s_OperServ, u, OPER_AKILL_DELETED_ONE); + } else { + notice_lang(s_OperServ, u, OPER_AKILL_DELETED_SEVERAL, + res); + } + } else { + if ((res = slist_indexof(&akills, mask)) == -1) { + notice_lang(s_OperServ, u, OPER_AKILL_NOT_FOUND, mask); + return MOD_CONT; + } + + slist_delete(&akills, res); + notice_lang(s_OperServ, u, OPER_AKILL_DELETED, mask); + } + + if (readonly) + notice_lang(s_OperServ, u, READ_ONLY_MODE); + + } else if (!stricmp(cmd, "LIST")) { + char *mask; + int res, sent_header = 0; + + if (akills.count == 0) { + notice_lang(s_OperServ, u, OPER_AKILL_LIST_EMPTY); + return MOD_CONT; + } + + mask = strtok(NULL, " "); + + if (!mask || (isdigit(*mask) + && strspn(mask, "1234567890,-") == strlen(mask))) { + res = + slist_enum(&akills, mask, &akill_list_callback, u, + &sent_header); + if (res == 0) { + notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH); + return MOD_CONT; + } else { + notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Akill"); + } + } else { + int i; + char amask[BUFSIZE]; + + for (i = 0; i < akills.count; i++) { + snprintf(amask, sizeof(amask), "%s@%s", + ((Akill *) akills.list[i])->user, + ((Akill *) akills.list[i])->host); + if (!stricmp(mask, amask) + || match_wild_nocase(mask, amask)) + akill_list(i + 1, (Akill *)akills.list[i], u, &sent_header); + } + + if (!sent_header) + notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH); + else { + notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Akill"); + } + } + } else if (!stricmp(cmd, "VIEW")) { + char *mask; + int res, sent_header = 0; + + if (akills.count == 0) { + notice_lang(s_OperServ, u, OPER_AKILL_LIST_EMPTY); + return MOD_CONT; + } + + mask = strtok(NULL, " "); + + if (!mask || (isdigit(*mask) + && strspn(mask, "1234567890,-") == strlen(mask))) { + res = + slist_enum(&akills, mask, &akill_view_callback, u, + &sent_header); + if (res == 0) { + notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH); + return MOD_CONT; + } + } else { + int i; + char amask[BUFSIZE]; + + for (i = 0; i < akills.count; i++) { + snprintf(amask, sizeof(amask), "%s@%s", + ((Akill *) akills.list[i])->user, + ((Akill *) akills.list[i])->host); + if (!stricmp(mask, amask) + || match_wild_nocase(mask, amask)) + akill_view(i + 1, (Akill *)akills.list[i], u, &sent_header); + } + + if (!sent_header) + notice_lang(s_OperServ, u, OPER_AKILL_NO_MATCH); + } + } else if (!stricmp(cmd, "CLEAR")) { + slist_clear(&akills, 1); + notice_lang(s_OperServ, u, OPER_AKILL_CLEAR); + } else { + syntax_error(s_OperServ, u, "AKILL", OPER_AKILL_SYNTAX); + } + return MOD_CONT; } int akill_view(int number, Akill * ak, User * u, int *sent_header) { - char mask[BUFSIZE]; - char timebuf[32], expirebuf[256]; - struct tm tm; - - if (!ak) - return 0; - - if (!*sent_header) { - notice_lang(s_OperServ, u, OPER_AKILL_VIEW_HEADER); - *sent_header = 1; - } - - snprintf(mask, sizeof(mask), "%s@%s", ak->user, ak->host); - tm = *localtime(&ak->seton); - strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_SHORT_DATE_FORMAT, - &tm); - expire_left(u->na, expirebuf, sizeof(expirebuf), ak->expires); - notice_lang(s_OperServ, u, OPER_AKILL_VIEW_FORMAT, number, mask, - ak->by, timebuf, expirebuf, ak->reason); - - return 1; + char mask[BUFSIZE]; + char timebuf[32], expirebuf[256]; + struct tm tm; + + if (!ak) + return 0; + + if (!*sent_header) { + notice_lang(s_OperServ, u, OPER_AKILL_VIEW_HEADER); + *sent_header = 1; + } + + snprintf(mask, sizeof(mask), "%s@%s", ak->user, ak->host); + tm = *localtime(&ak->seton); + strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_SHORT_DATE_FORMAT, + &tm); + expire_left(u->na, expirebuf, sizeof(expirebuf), ak->expires); + notice_lang(s_OperServ, u, OPER_AKILL_VIEW_FORMAT, number, mask, + ak->by, timebuf, expirebuf, ak->reason); + + return 1; } /* Lists an AKILL entry, prefixing it with the header if needed */ int akill_list_callback(SList * slist, int number, void *item, - va_list args) + va_list args) { - User *u = va_arg(args, User *); - int *sent_header = va_arg(args, int *); + User *u = va_arg(args, User *); + int *sent_header = va_arg(args, int *); - return akill_list(number, (Akill *)item, u, sent_header); + return akill_list(number, (Akill *)item, u, sent_header); } /* Callback for enumeration purposes */ int akill_view_callback(SList * slist, int number, void *item, - va_list args) + va_list args) { - User *u = va_arg(args, User *); - int *sent_header = va_arg(args, int *); + User *u = va_arg(args, User *); + int *sent_header = va_arg(args, int *); - return akill_view(number, (Akill *)item, u, sent_header); + return akill_view(number, (Akill *)item, u, sent_header); } /* Lists an AKILL entry, prefixing it with the header if needed */ int akill_list(int number, Akill * ak, User * u, int *sent_header) { - char mask[BUFSIZE]; + char mask[BUFSIZE]; - if (!ak) - return 0; + if (!ak) + return 0; - if (!*sent_header) { - notice_lang(s_OperServ, u, OPER_AKILL_LIST_HEADER); - *sent_header = 1; - } + if (!*sent_header) { + notice_lang(s_OperServ, u, OPER_AKILL_LIST_HEADER); + *sent_header = 1; + } - snprintf(mask, sizeof(mask), "%s@%s", ak->user, ak->host); - notice_lang(s_OperServ, u, OPER_AKILL_LIST_FORMAT, number, mask, - ak->reason); + snprintf(mask, sizeof(mask), "%s@%s", ak->user, ak->host); + notice_lang(s_OperServ, u, OPER_AKILL_LIST_FORMAT, number, mask, + ak->reason); - return 1; + return 1; } MODULE_INIT("os_akill", OSAKill) diff --git a/src/core/os_chankill.c b/src/core/os_chankill.c index ef35e2432..881dee421 100644 --- a/src/core/os_chankill.c +++ b/src/core/os_chankill.c @@ -44,9 +44,9 @@ class OSChanKill : public Module **/ void myOperServHelp(User * u) { - if (is_services_admin(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_CHANKILL); - } + if (is_services_admin(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_CHANKILL); + } } /** @@ -59,64 +59,64 @@ void myOperServHelp(User * u) **/ int do_chankill(User * u) { - char *expiry, *channel, *reason; - time_t expires; - char breason[BUFSIZE]; - char mask[USERMAX + HOSTMAX + 2]; - struct c_userlist *cu, *next; - Channel *c; - - channel = strtok(NULL, " "); - if (channel && *channel == '+') { - expiry = channel; - channel = strtok(NULL, " "); - } else { - expiry = NULL; - } - - expires = expiry ? dotime(expiry) : ChankillExpiry; - if (expiry && isdigit(expiry[strlen(expiry) - 1])) - expires *= 86400; - if (expires != 0 && expires < 60) { - notice_lang(s_OperServ, u, BAD_EXPIRY_TIME); - return MOD_CONT; - } else if (expires > 0) { - expires += time(NULL); - } - - if (channel && (reason = strtok(NULL, ""))) { - - if (AddAkiller) { - snprintf(breason, sizeof(breason), "[%s] %s", u->nick, reason); - reason = sstrdup(breason); - } - - if ((c = findchan(channel))) { - for (cu = c->users; cu; cu = next) { - next = cu->next; - if (is_oper(cu->user)) { - continue; - } - (void) strncpy(mask, "*@", 3); /* Use *@" for the akill's, */ - strncat(mask, cu->user->host, HOSTMAX); - add_akill(NULL, mask, s_OperServ, expires, reason); - check_akill(cu->user->nick, cu->user->username, - cu->user->host, NULL, NULL); - } - if (WallOSAkill) { - ircdproto->SendGlobops(s_OperServ, "%s used CHANKILL on %s (%s)", - u->nick, channel, reason); - } - } else { - notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, channel); - } - if (AddAkiller) { - free(reason); - } - } else { - syntax_error(s_OperServ, u, "CHANKILL", OPER_CHANKILL_SYNTAX); - } - return MOD_CONT; + char *expiry, *channel, *reason; + time_t expires; + char breason[BUFSIZE]; + char mask[USERMAX + HOSTMAX + 2]; + struct c_userlist *cu, *next; + Channel *c; + + channel = strtok(NULL, " "); + if (channel && *channel == '+') { + expiry = channel; + channel = strtok(NULL, " "); + } else { + expiry = NULL; + } + + expires = expiry ? dotime(expiry) : ChankillExpiry; + if (expiry && isdigit(expiry[strlen(expiry) - 1])) + expires *= 86400; + if (expires != 0 && expires < 60) { + notice_lang(s_OperServ, u, BAD_EXPIRY_TIME); + return MOD_CONT; + } else if (expires > 0) { + expires += time(NULL); + } + + if (channel && (reason = strtok(NULL, ""))) { + + if (AddAkiller) { + snprintf(breason, sizeof(breason), "[%s] %s", u->nick, reason); + reason = sstrdup(breason); + } + + if ((c = findchan(channel))) { + for (cu = c->users; cu; cu = next) { + next = cu->next; + if (is_oper(cu->user)) { + continue; + } + (void) strncpy(mask, "*@", 3); /* Use *@" for the akill's, */ + strncat(mask, cu->user->host, HOSTMAX); + add_akill(NULL, mask, s_OperServ, expires, reason); + check_akill(cu->user->nick, cu->user->username, + cu->user->host, NULL, NULL); + } + if (WallOSAkill) { + ircdproto->SendGlobops(s_OperServ, "%s used CHANKILL on %s (%s)", + u->nick, channel, reason); + } + } else { + notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, channel); + } + if (AddAkiller) { + free(reason); + } + } else { + syntax_error(s_OperServ, u, "CHANKILL", OPER_CHANKILL_SYNTAX); + } + return MOD_CONT; } MODULE_INIT("os_chankill", OSChanKill) diff --git a/src/core/os_chanlist.c b/src/core/os_chanlist.c index 4725eb4bf..c51d87385 100644 --- a/src/core/os_chanlist.c +++ b/src/core/os_chanlist.c @@ -47,7 +47,7 @@ class OSChanList : public Module **/ void myOperServHelp(User * u) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_CHANLIST); + notice_lang(s_OperServ, u, OPER_HELP_CMD_CHANLIST); } /** @@ -57,49 +57,49 @@ void myOperServHelp(User * u) **/ int do_chanlist(User * u) { - char *pattern = strtok(NULL, " "); - char *opt = strtok(NULL, " "); - - int modes = 0; - User *u2; - - if (opt && !stricmp(opt, "SECRET")) - modes |= (anope_get_secret_mode() | anope_get_private_mode()); - - if (pattern && (u2 = finduser(pattern))) { - struct u_chanlist *uc; - - notice_lang(s_OperServ, u, OPER_CHANLIST_HEADER_USER, u2->nick); - - for (uc = u2->chans; uc; uc = uc->next) { - if (modes && !(uc->chan->mode & modes)) - continue; - notice_lang(s_OperServ, u, OPER_CHANLIST_RECORD, - uc->chan->name, uc->chan->usercount, - chan_get_modes(uc->chan, 1, 1), - (uc->chan->topic ? uc->chan->topic : "")); - } - } else { - int i; - Channel *c; - - notice_lang(s_OperServ, u, OPER_CHANLIST_HEADER); - - for (i = 0; i < 1024; i++) { - for (c = chanlist[i]; c; c = c->next) { - if (pattern && !match_wild_nocase(pattern, c->name)) - continue; - if (modes && !(c->mode & modes)) - continue; - notice_lang(s_OperServ, u, OPER_CHANLIST_RECORD, c->name, - c->usercount, chan_get_modes(c, 1, 1), - (c->topic ? c->topic : "")); - } - } - } - - notice_lang(s_OperServ, u, OPER_CHANLIST_END); - return MOD_CONT; + char *pattern = strtok(NULL, " "); + char *opt = strtok(NULL, " "); + + int modes = 0; + User *u2; + + if (opt && !stricmp(opt, "SECRET")) + modes |= (anope_get_secret_mode() | anope_get_private_mode()); + + if (pattern && (u2 = finduser(pattern))) { + struct u_chanlist *uc; + + notice_lang(s_OperServ, u, OPER_CHANLIST_HEADER_USER, u2->nick); + + for (uc = u2->chans; uc; uc = uc->next) { + if (modes && !(uc->chan->mode & modes)) + continue; + notice_lang(s_OperServ, u, OPER_CHANLIST_RECORD, + uc->chan->name, uc->chan->usercount, + chan_get_modes(uc->chan, 1, 1), + (uc->chan->topic ? uc->chan->topic : "")); + } + } else { + int i; + Channel *c; + + notice_lang(s_OperServ, u, OPER_CHANLIST_HEADER); + + for (i = 0; i < 1024; i++) { + for (c = chanlist[i]; c; c = c->next) { + if (pattern && !match_wild_nocase(pattern, c->name)) + continue; + if (modes && !(c->mode & modes)) + continue; + notice_lang(s_OperServ, u, OPER_CHANLIST_RECORD, c->name, + c->usercount, chan_get_modes(c, 1, 1), + (c->topic ? c->topic : "")); + } + } + } + + notice_lang(s_OperServ, u, OPER_CHANLIST_END); + return MOD_CONT; } MODULE_INIT("os_chanlist", OSChanList) diff --git a/src/core/os_clearmodes.c b/src/core/os_clearmodes.c index 8fb27f5ff..fce9efc57 100644 --- a/src/core/os_clearmodes.c +++ b/src/core/os_clearmodes.c @@ -44,9 +44,9 @@ class OSClearModes : public Module **/ void myOperServHelp(User * u) { - if (is_services_oper(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_CLEARMODES); - } + if (is_services_oper(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_CLEARMODES); + } } /** @@ -56,242 +56,242 @@ void myOperServHelp(User * u) **/ int do_clearmodes(User * u) { - char *s; - const char *argv[2]; - char *chan = strtok(NULL, " "); - Channel *c; - int all = 0; - struct c_userlist *cu, *next; - Entry *entry, *nexte; + char *s; + const char *argv[2]; + char *chan = strtok(NULL, " "); + Channel *c; + int all = 0; + struct c_userlist *cu, *next; + Entry *entry, *nexte; - if (!chan) { - syntax_error(s_OperServ, u, "CLEARMODES", OPER_CLEARMODES_SYNTAX); - return MOD_CONT; - } else if (!(c = findchan(chan))) { - notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan); - return MOD_CONT; - } else if (c->bouncy_modes) { - notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE); - return MOD_CONT; - } else { - s = strtok(NULL, " "); - if (s) { - if (stricmp(s, "ALL") == 0) { - all = 1; - } else { - syntax_error(s_OperServ, u, "CLEARMODES", - OPER_CLEARMODES_SYNTAX); - return MOD_CONT; - } - } + if (!chan) { + syntax_error(s_OperServ, u, "CLEARMODES", OPER_CLEARMODES_SYNTAX); + return MOD_CONT; + } else if (!(c = findchan(chan))) { + notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan); + return MOD_CONT; + } else if (c->bouncy_modes) { + notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE); + return MOD_CONT; + } else { + s = strtok(NULL, " "); + if (s) { + if (stricmp(s, "ALL") == 0) { + all = 1; + } else { + syntax_error(s_OperServ, u, "CLEARMODES", + OPER_CLEARMODES_SYNTAX); + return MOD_CONT; + } + } - if (WallOSClearmodes) { - ircdproto->SendGlobops(s_OperServ, "%s used CLEARMODES%s on %s", - u->nick, all ? " ALL" : "", chan); - } - if (all) { - /* Clear mode +o */ - if (ircd->svsmode_ucmode) { - ircdproto->SendSVSModeChan(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] = "-o"; - argv[1] = cu->user->nick; - chan_set_modes(s_OperServ, c, 2, 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] = "-o"; - argv[1] = cu->user->nick; - ircdproto->SendMode(findbot(s_OperServ), c->name, "-o %s", - cu->user->nick); - chan_set_modes(s_OperServ, c, 2, argv, 0); - } - } + if (WallOSClearmodes) { + ircdproto->SendGlobops(s_OperServ, "%s used CLEARMODES%s on %s", + u->nick, all ? " ALL" : "", chan); + } + if (all) { + /* Clear mode +o */ + if (ircd->svsmode_ucmode) { + ircdproto->SendSVSModeChan(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] = "-o"; + argv[1] = cu->user->nick; + chan_set_modes(s_OperServ, c, 2, 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] = "-o"; + argv[1] = cu->user->nick; + ircdproto->SendMode(findbot(s_OperServ), c->name, "-o %s", + cu->user->nick); + chan_set_modes(s_OperServ, c, 2, argv, 0); + } + } - if (ircd->svsmode_ucmode) { - ircdproto->SendSVSModeChan(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] = "-v"; - argv[1] = cu->user->nick; - chan_set_modes(s_OperServ, c, 2, 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] = "-v"; - argv[1] = cu->user->nick; - ircdproto->SendMode(findbot(s_OperServ), c->name, "-v %s", - cu->user->nick); - chan_set_modes(s_OperServ, c, 2, argv, 0); - } - } + if (ircd->svsmode_ucmode) { + ircdproto->SendSVSModeChan(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] = "-v"; + argv[1] = cu->user->nick; + chan_set_modes(s_OperServ, c, 2, 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] = "-v"; + argv[1] = cu->user->nick; + ircdproto->SendMode(findbot(s_OperServ), c->name, "-v %s", + cu->user->nick); + chan_set_modes(s_OperServ, c, 2, argv, 0); + } + } - /* Clear mode +h */ - if (ircd->svsmode_ucmode && ircd->halfop) { - ircdproto->SendSVSModeChan(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] = "-h"; - argv[1] = cu->user->nick; - chan_set_modes(s_OperServ, c, 2, 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] = "-h"; - argv[1] = cu->user->nick; - ircdproto->SendMode(findbot(s_OperServ), c->name, "-h %s", - cu->user->nick); - chan_set_modes(s_OperServ, c, 2, argv, 0); - } - } - /* Clear mode Owners */ - if (ircd->svsmode_ucmode && ircd->owner) { - ircdproto->SendSVSModeChan(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] = ircd->ownerunset; - argv[1] = cu->user->nick; - chan_set_modes(s_OperServ, c, 2, 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] = ircd->ownerunset; - argv[1] = cu->user->nick; - ircdproto->SendMode(findbot(s_OperServ), c->name, "%s %s", - ircd->ownerunset, cu->user->nick); - chan_set_modes(s_OperServ, c, 2, argv, 0); - } - } - /* Clear mode protected or admins */ - if (ircd->svsmode_ucmode && (ircd->protect || ircd->admin)) { + /* Clear mode +h */ + if (ircd->svsmode_ucmode && ircd->halfop) { + ircdproto->SendSVSModeChan(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] = "-h"; + argv[1] = cu->user->nick; + chan_set_modes(s_OperServ, c, 2, 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] = "-h"; + argv[1] = cu->user->nick; + ircdproto->SendMode(findbot(s_OperServ), c->name, "-h %s", + cu->user->nick); + chan_set_modes(s_OperServ, c, 2, argv, 0); + } + } + /* Clear mode Owners */ + if (ircd->svsmode_ucmode && ircd->owner) { + ircdproto->SendSVSModeChan(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] = ircd->ownerunset; + argv[1] = cu->user->nick; + chan_set_modes(s_OperServ, c, 2, 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] = ircd->ownerunset; + argv[1] = cu->user->nick; + ircdproto->SendMode(findbot(s_OperServ), c->name, "%s %s", + ircd->ownerunset, cu->user->nick); + chan_set_modes(s_OperServ, c, 2, argv, 0); + } + } + /* Clear mode protected or admins */ + if (ircd->svsmode_ucmode && (ircd->protect || ircd->admin)) { - ircdproto->SendSVSModeChan(c->name, ircd->adminunset, NULL); - for (cu = c->users; cu; cu = next) { - next = cu->next; - if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) { - continue; - } - argv[0] = ircd->adminunset; - argv[1] = cu->user->nick; - chan_set_modes(s_OperServ, c, 2, 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] = ircd->adminunset; - argv[1] = cu->user->nick; - ircdproto->SendMode(findbot(s_OperServ), c->name, "%s %s", - ircd->adminunset, cu->user->nick); - chan_set_modes(s_OperServ, c, 2, argv, 0); - } - } + ircdproto->SendSVSModeChan(c->name, ircd->adminunset, NULL); + for (cu = c->users; cu; cu = next) { + next = cu->next; + if (!chan_has_user_status(c, cu->user, CUS_HALFOP)) { + continue; + } + argv[0] = ircd->adminunset; + argv[1] = cu->user->nick; + chan_set_modes(s_OperServ, c, 2, 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] = ircd->adminunset; + argv[1] = cu->user->nick; + ircdproto->SendMode(findbot(s_OperServ), c->name, "%s %s", + ircd->adminunset, cu->user->nick); + chan_set_modes(s_OperServ, c, 2, argv, 0); + } + } - } + } - if (c->mode) { - /* Clear modes the bulk of the modes */ - ircdproto->SendMode(findbot(s_OperServ), c->name, "%s", ircd->modestoremove); - argv[0] = ircd->modestoremove; - chan_set_modes(s_OperServ, c, 1, argv, 0); + if (c->mode) { + /* Clear modes the bulk of the modes */ + ircdproto->SendMode(findbot(s_OperServ), c->name, "%s", ircd->modestoremove); + argv[0] = ircd->modestoremove; + chan_set_modes(s_OperServ, c, 1, argv, 0); - /* to prevent the internals from complaining send -k, -L, -f by themselves if we need - to send them - TSL */ - if (c->key) { - ircdproto->SendMode(findbot(s_OperServ), c->name, "-k %s", c->key); - argv[0] = "-k"; - argv[1] = c->key; - chan_set_modes(s_OperServ, c, 2, argv, 0); - } - if (ircd->Lmode && c->redirect) { - ircdproto->SendMode(findbot(s_OperServ), c->name, "-L %s", c->redirect); - argv[0] = "-L"; - argv[1] = c->redirect; - chan_set_modes(s_OperServ, c, 2, argv, 0); - } - if (ircd->fmode && c->flood) { - if (flood_mode_char_remove) { - ircdproto->SendMode(findbot(s_OperServ), c->name, "%s %s", - flood_mode_char_remove, c->flood); - argv[0] = flood_mode_char_remove; - argv[1] = c->flood; - chan_set_modes(s_OperServ, c, 2, argv, 0); - } else { - if (debug) { - alog("debug: flood_mode_char_remove was not set unable to remove flood/throttle modes"); - } - } - } - } + /* to prevent the internals from complaining send -k, -L, -f by themselves if we need + to send them - TSL */ + if (c->key) { + ircdproto->SendMode(findbot(s_OperServ), c->name, "-k %s", c->key); + argv[0] = "-k"; + argv[1] = c->key; + chan_set_modes(s_OperServ, c, 2, argv, 0); + } + if (ircd->Lmode && c->redirect) { + ircdproto->SendMode(findbot(s_OperServ), c->name, "-L %s", c->redirect); + argv[0] = "-L"; + argv[1] = c->redirect; + chan_set_modes(s_OperServ, c, 2, argv, 0); + } + if (ircd->fmode && c->flood) { + if (flood_mode_char_remove) { + ircdproto->SendMode(findbot(s_OperServ), c->name, "%s %s", + flood_mode_char_remove, c->flood); + argv[0] = flood_mode_char_remove; + argv[1] = c->flood; + chan_set_modes(s_OperServ, c, 2, argv, 0); + } else { + if (debug) { + alog("debug: flood_mode_char_remove was not set unable to remove flood/throttle modes"); + } + } + } + } - /* Clear bans */ - if (c->bans && c->bans->count) { - for (entry = c->bans->entries; entry; entry = nexte) { - nexte = entry->next; - argv[0] = "-b"; - argv[1] = entry->mask; - ircdproto->SendMode(findbot(s_OperServ), c->name, "-b %s", entry->mask); - chan_set_modes(s_OperServ, c, 2, argv, 0); - } - } + /* Clear bans */ + if (c->bans && c->bans->count) { + for (entry = c->bans->entries; entry; entry = nexte) { + nexte = entry->next; + argv[0] = "-b"; + argv[1] = entry->mask; + ircdproto->SendMode(findbot(s_OperServ), c->name, "-b %s", entry->mask); + chan_set_modes(s_OperServ, c, 2, argv, 0); + } + } - /* Clear excepts */ - if (ircd->except && c->excepts && c->excepts->count) { - for (entry = c->excepts->entries; entry; entry = nexte) { - nexte = entry->next; - argv[0] = "-e"; - argv[1] = entry->mask; - ircdproto->SendMode(findbot(s_OperServ), c->name, "-e %s", entry->mask); - chan_set_modes(s_OperServ, c, 2, argv, 0); - } - } + /* Clear excepts */ + if (ircd->except && c->excepts && c->excepts->count) { + for (entry = c->excepts->entries; entry; entry = nexte) { + nexte = entry->next; + argv[0] = "-e"; + argv[1] = entry->mask; + ircdproto->SendMode(findbot(s_OperServ), c->name, "-e %s", entry->mask); + chan_set_modes(s_OperServ, c, 2, argv, 0); + } + } - /* Clear invites */ - if (ircd->invitemode && c->invites && c->invites->count) { - for (entry = c->invites->entries; entry; entry = nexte) { - nexte = entry->next; - argv[0] = "-I"; - argv[1] = entry->mask; - ircdproto->SendMode(findbot(s_OperServ), c->name, "-I %s", entry->mask); - chan_set_modes(s_OperServ, c, 2, argv, 0); - } - } - } + /* Clear invites */ + if (ircd->invitemode && c->invites && c->invites->count) { + for (entry = c->invites->entries; entry; entry = nexte) { + nexte = entry->next; + argv[0] = "-I"; + argv[1] = entry->mask; + ircdproto->SendMode(findbot(s_OperServ), c->name, "-I %s", entry->mask); + chan_set_modes(s_OperServ, c, 2, argv, 0); + } + } + } - if (all) { - notice_lang(s_OperServ, u, OPER_CLEARMODES_ALL_DONE, chan); - } else { - notice_lang(s_OperServ, u, OPER_CLEARMODES_DONE, chan); - } - return MOD_CONT; + if (all) { + notice_lang(s_OperServ, u, OPER_CLEARMODES_ALL_DONE, chan); + } else { + notice_lang(s_OperServ, u, OPER_CLEARMODES_DONE, chan); + } + return MOD_CONT; } MODULE_INIT("os_clearmodes", OSClearModes) diff --git a/src/core/os_defcon.c b/src/core/os_defcon.c index 66aefc92a..69afa7bf2 100644 --- a/src/core/os_defcon.c +++ b/src/core/os_defcon.c @@ -49,9 +49,9 @@ class OSDEFCON : public Module **/ void myOperServHelp(User * u) { - if (is_services_admin(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_DEFCON); - } + if (is_services_admin(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_DEFCON); + } } /** @@ -66,52 +66,52 @@ void myOperServHelp(User * u) **/ int do_defcon(User * u) { - char *lvl = strtok(NULL, " "); - int newLevel = 0; - char *langglobal; - langglobal = getstring(NULL, DEFCON_GLOBAL); - - if (!DefConLevel) { /* If we dont have a .conf setting! */ - notice_lang(s_OperServ, u, OPER_DEFCON_NO_CONF); - return MOD_CONT; - } - - if (!lvl) { - notice_lang(s_OperServ, u, OPER_DEFCON_CHANGED, DefConLevel); - defcon_sendlvls(u); - return MOD_CONT; - } - newLevel = atoi(lvl); - if (newLevel < 1 || newLevel > 5) { - notice_lang(s_OperServ, u, OPER_DEFCON_SYNTAX); - return MOD_CONT; - } - DefConLevel = newLevel; - send_event(EVENT_DEFCON_LEVEL, 1, lvl); - DefContimer = time(NULL); - notice_lang(s_OperServ, u, OPER_DEFCON_CHANGED, DefConLevel); - defcon_sendlvls(u); - alog("Defcon level changed to %d by Oper %s", newLevel, u->nick); - ircdproto->SendGlobops(s_OperServ, getstring2(NULL, OPER_DEFCON_WALL), - u->nick, newLevel); - /* Global notice the user what is happening. Also any Message that - the Admin would like to add. Set in config file. */ - if (GlobalOnDefcon) { - if ((DefConLevel == 5) && (DefConOffMessage)) { - oper_global(NULL, "%s", DefConOffMessage); - } else { - oper_global(NULL, langglobal, DefConLevel); - } - } - if (GlobalOnDefconMore) { - if ((DefConOffMessage) && DefConLevel == 5) { - } else { - oper_global(NULL, "%s", DefconMessage); - } - } - /* Run any defcon functions, e.g. FORCE CHAN MODE */ - runDefCon(); - return MOD_CONT; + char *lvl = strtok(NULL, " "); + int newLevel = 0; + char *langglobal; + langglobal = getstring(NULL, DEFCON_GLOBAL); + + if (!DefConLevel) { /* If we dont have a .conf setting! */ + notice_lang(s_OperServ, u, OPER_DEFCON_NO_CONF); + return MOD_CONT; + } + + if (!lvl) { + notice_lang(s_OperServ, u, OPER_DEFCON_CHANGED, DefConLevel); + defcon_sendlvls(u); + return MOD_CONT; + } + newLevel = atoi(lvl); + if (newLevel < 1 || newLevel > 5) { + notice_lang(s_OperServ, u, OPER_DEFCON_SYNTAX); + return MOD_CONT; + } + DefConLevel = newLevel; + send_event(EVENT_DEFCON_LEVEL, 1, lvl); + DefContimer = time(NULL); + notice_lang(s_OperServ, u, OPER_DEFCON_CHANGED, DefConLevel); + defcon_sendlvls(u); + alog("Defcon level changed to %d by Oper %s", newLevel, u->nick); + ircdproto->SendGlobops(s_OperServ, getstring2(NULL, OPER_DEFCON_WALL), + u->nick, newLevel); + /* Global notice the user what is happening. Also any Message that + the Admin would like to add. Set in config file. */ + if (GlobalOnDefcon) { + if ((DefConLevel == 5) && (DefConOffMessage)) { + oper_global(NULL, "%s", DefConOffMessage); + } else { + oper_global(NULL, langglobal, DefConLevel); + } + } + if (GlobalOnDefconMore) { + if ((DefConOffMessage) && DefConLevel == 5) { + } else { + oper_global(NULL, "%s", DefconMessage); + } + } + /* Run any defcon functions, e.g. FORCE CHAN MODE */ + runDefCon(); + return MOD_CONT; } @@ -121,38 +121,38 @@ int do_defcon(User * u) **/ void defcon_sendlvls(User * u) { - if (checkDefCon(DEFCON_NO_NEW_CHANNELS)) { - notice_lang(s_OperServ, u, OPER_HELP_DEFCON_NO_NEW_CHANNELS); - } - if (checkDefCon(DEFCON_NO_NEW_NICKS)) { - notice_lang(s_OperServ, u, OPER_HELP_DEFCON_NO_NEW_NICKS); - } - if (checkDefCon(DEFCON_NO_MLOCK_CHANGE)) { - notice_lang(s_OperServ, u, OPER_HELP_DEFCON_NO_MLOCK_CHANGE); - } - if (checkDefCon(DEFCON_FORCE_CHAN_MODES) && (DefConChanModes)) { - notice_lang(s_OperServ, u, OPER_HELP_DEFCON_FORCE_CHAN_MODES, - DefConChanModes); - } - if (checkDefCon(DEFCON_REDUCE_SESSION)) { - notice_lang(s_OperServ, u, OPER_HELP_DEFCON_REDUCE_SESSION, - DefConSessionLimit); - } - if (checkDefCon(DEFCON_NO_NEW_CLIENTS)) { - notice_lang(s_OperServ, u, OPER_HELP_DEFCON_NO_NEW_CLIENTS); - } - if (checkDefCon(DEFCON_OPER_ONLY)) { - notice_lang(s_OperServ, u, OPER_HELP_DEFCON_OPER_ONLY); - } - if (checkDefCon(DEFCON_SILENT_OPER_ONLY)) { - notice_lang(s_OperServ, u, OPER_HELP_DEFCON_SILENT_OPER_ONLY); - } - if (checkDefCon(DEFCON_AKILL_NEW_CLIENTS)) { - notice_lang(s_OperServ, u, OPER_HELP_DEFCON_AKILL_NEW_CLIENTS); - } - if (checkDefCon(DEFCON_NO_NEW_MEMOS)) { - notice_lang(s_OperServ, u, OPER_HELP_DEFCON_NO_NEW_MEMOS); - } + if (checkDefCon(DEFCON_NO_NEW_CHANNELS)) { + notice_lang(s_OperServ, u, OPER_HELP_DEFCON_NO_NEW_CHANNELS); + } + if (checkDefCon(DEFCON_NO_NEW_NICKS)) { + notice_lang(s_OperServ, u, OPER_HELP_DEFCON_NO_NEW_NICKS); + } + if (checkDefCon(DEFCON_NO_MLOCK_CHANGE)) { + notice_lang(s_OperServ, u, OPER_HELP_DEFCON_NO_MLOCK_CHANGE); + } + if (checkDefCon(DEFCON_FORCE_CHAN_MODES) && (DefConChanModes)) { + notice_lang(s_OperServ, u, OPER_HELP_DEFCON_FORCE_CHAN_MODES, + DefConChanModes); + } + if (checkDefCon(DEFCON_REDUCE_SESSION)) { + notice_lang(s_OperServ, u, OPER_HELP_DEFCON_REDUCE_SESSION, + DefConSessionLimit); + } + if (checkDefCon(DEFCON_NO_NEW_CLIENTS)) { + notice_lang(s_OperServ, u, OPER_HELP_DEFCON_NO_NEW_CLIENTS); + } + if (checkDefCon(DEFCON_OPER_ONLY)) { + notice_lang(s_OperServ, u, OPER_HELP_DEFCON_OPER_ONLY); + } + if (checkDefCon(DEFCON_SILENT_OPER_ONLY)) { + notice_lang(s_OperServ, u, OPER_HELP_DEFCON_SILENT_OPER_ONLY); + } + if (checkDefCon(DEFCON_AKILL_NEW_CLIENTS)) { + notice_lang(s_OperServ, u, OPER_HELP_DEFCON_AKILL_NEW_CLIENTS); + } + if (checkDefCon(DEFCON_NO_NEW_MEMOS)) { + notice_lang(s_OperServ, u, OPER_HELP_DEFCON_NO_NEW_MEMOS); + } } MODULE_INIT("os_defcon", OSDEFCON) diff --git a/src/core/os_global.c b/src/core/os_global.c index d311c8f94..c538d26bd 100644 --- a/src/core/os_global.c +++ b/src/core/os_global.c @@ -44,9 +44,9 @@ class OSGlobal : public Module **/ void myOperServHelp(User * u) { - if (is_services_admin(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_GLOBAL); - } + if (is_services_admin(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_GLOBAL); + } } /** @@ -56,17 +56,17 @@ void myOperServHelp(User * u) **/ int do_global(User * u) { - char *msg = strtok(NULL, ""); + char *msg = strtok(NULL, ""); - if (!msg) { - syntax_error(s_OperServ, u, "GLOBAL", OPER_GLOBAL_SYNTAX); - return MOD_CONT; - } - if (WallOSGlobal) - ircdproto->SendGlobops(s_OperServ, "\2%s\2 just used GLOBAL command.", - u->nick); - oper_global(u->nick, "%s", msg); - return MOD_CONT; + if (!msg) { + syntax_error(s_OperServ, u, "GLOBAL", OPER_GLOBAL_SYNTAX); + return MOD_CONT; + } + if (WallOSGlobal) + ircdproto->SendGlobops(s_OperServ, "\2%s\2 just used GLOBAL command.", + u->nick); + oper_global(u->nick, "%s", msg); + return MOD_CONT; } MODULE_INIT("os_global", OSGlobal) diff --git a/src/core/os_help.c b/src/core/os_help.c index 7f1155eb1..fad752f54 100644 --- a/src/core/os_help.c +++ b/src/core/os_help.c @@ -41,16 +41,16 @@ class OSHelp : public Module **/ int do_help(User * u) { - const char *cmd = strtok(NULL, ""); - - if (!cmd) { - notice_help(s_OperServ, u, OPER_HELP); - moduleDisplayHelp(5, u); - notice_help(s_OperServ, u, OPER_HELP_LOGGED); - } else { - mod_help_cmd(s_OperServ, u, OPERSERV, cmd); - } - return MOD_CONT; + const char *cmd = strtok(NULL, ""); + + if (!cmd) { + notice_help(s_OperServ, u, OPER_HELP); + moduleDisplayHelp(5, u); + notice_help(s_OperServ, u, OPER_HELP_LOGGED); + } else { + mod_help_cmd(s_OperServ, u, OPERSERV, cmd); + } + return MOD_CONT; } MODULE_INIT("os_help", OSHelp) diff --git a/src/core/os_ignore.c b/src/core/os_ignore.c index 4ec37c730..088f51061 100644 --- a/src/core/os_ignore.c +++ b/src/core/os_ignore.c @@ -43,9 +43,9 @@ class OSIgnore : public Module **/ void myOperServHelp(User * u) { - if (is_services_admin(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_IGNORE); - } + if (is_services_admin(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_IGNORE); + } } /** @@ -55,79 +55,79 @@ void myOperServHelp(User * u) **/ int do_ignoreuser(User * u) { - char *cmd = strtok(NULL, " "); - int t; - - if (!cmd) { - notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX); - return MOD_CONT; - } - - if (!stricmp(cmd, "ADD")) { - char *time = strtok(NULL, " "); - char *nick = strtok(NULL, " "); - char *rest = strtok(NULL, ""); - - if (!nick) { - notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX); - return MOD_CONT; - } else if (!time) { - notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX); - return MOD_CONT; - } else { - t = dotime(time); - rest = NULL; - - if (t <= -1) { - notice_lang(s_OperServ, u, OPER_IGNORE_VALID_TIME); - return MOD_CONT; - } else if (t == 0) { - add_ignore(nick, t); - notice_lang(s_OperServ, u, OPER_IGNORE_PERM_DONE, nick); - } else { - add_ignore(nick, t); - notice_lang(s_OperServ, u, OPER_IGNORE_TIME_DONE, nick, time); - } - } - } else if (!stricmp(cmd, "LIST")) { - do_ignorelist(u); - - } else if (!stricmp(cmd, "DEL")) { - char *nick = strtok(NULL, " "); - if (!nick) { - notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX); - } else { - if (delete_ignore(nick)) { - notice_lang(s_OperServ, u, OPER_IGNORE_DEL_DONE, nick); - return MOD_CONT; - } - notice_lang(s_OperServ, u, OPER_IGNORE_LIST_NOMATCH, nick); - } - } else if (!stricmp(cmd, "CLEAR")) { - clear_ignores(); - notice_lang(s_OperServ, u, OPER_IGNORE_LIST_CLEARED); - return MOD_CONT; - } else - notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX); - - return MOD_CONT; + char *cmd = strtok(NULL, " "); + int t; + + if (!cmd) { + notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX); + return MOD_CONT; + } + + if (!stricmp(cmd, "ADD")) { + char *time = strtok(NULL, " "); + char *nick = strtok(NULL, " "); + char *rest = strtok(NULL, ""); + + if (!nick) { + notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX); + return MOD_CONT; + } else if (!time) { + notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX); + return MOD_CONT; + } else { + t = dotime(time); + rest = NULL; + + if (t <= -1) { + notice_lang(s_OperServ, u, OPER_IGNORE_VALID_TIME); + return MOD_CONT; + } else if (t == 0) { + add_ignore(nick, t); + notice_lang(s_OperServ, u, OPER_IGNORE_PERM_DONE, nick); + } else { + add_ignore(nick, t); + notice_lang(s_OperServ, u, OPER_IGNORE_TIME_DONE, nick, time); + } + } + } else if (!stricmp(cmd, "LIST")) { + do_ignorelist(u); + + } else if (!stricmp(cmd, "DEL")) { + char *nick = strtok(NULL, " "); + if (!nick) { + notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX); + } else { + if (delete_ignore(nick)) { + notice_lang(s_OperServ, u, OPER_IGNORE_DEL_DONE, nick); + return MOD_CONT; + } + notice_lang(s_OperServ, u, OPER_IGNORE_LIST_NOMATCH, nick); + } + } else if (!stricmp(cmd, "CLEAR")) { + clear_ignores(); + notice_lang(s_OperServ, u, OPER_IGNORE_LIST_CLEARED); + return MOD_CONT; + } else + notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX); + + return MOD_CONT; } /* shows the Services ignore list */ int do_ignorelist(User * u) { - IgnoreData *id; + IgnoreData *id; - if (!ignore) { - notice_lang(s_OperServ, u, OPER_IGNORE_LIST_EMPTY); - return MOD_CONT; - } + if (!ignore) { + notice_lang(s_OperServ, u, OPER_IGNORE_LIST_EMPTY); + return MOD_CONT; + } - notice_lang(s_OperServ, u, OPER_IGNORE_LIST); - for (id = ignore; id; id = id->next) - notice_user(s_OperServ, u, "%s", id->mask); + notice_lang(s_OperServ, u, OPER_IGNORE_LIST); + for (id = ignore; id; id = id->next) + notice_user(s_OperServ, u, "%s", id->mask); - return MOD_CONT; + return MOD_CONT; } MODULE_INIT("os_ignore", OSIgnore) diff --git a/src/core/os_jupe.c b/src/core/os_jupe.c index dcf550c4f..079ff4be1 100644 --- a/src/core/os_jupe.c +++ b/src/core/os_jupe.c @@ -43,9 +43,9 @@ class OSJupe : public Module **/ void myOperServHelp(User * u) { - if (is_services_admin(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_JUPE); - } + if (is_services_admin(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_JUPE); + } } /** @@ -55,27 +55,27 @@ void myOperServHelp(User * u) **/ int do_jupe(User * u) { - char *jserver = strtok(NULL, " "); - char *reason = strtok(NULL, ""); + char *jserver = strtok(NULL, " "); + char *reason = strtok(NULL, ""); - if (!jserver) { - syntax_error(s_OperServ, u, "JUPE", OPER_JUPE_SYNTAX); - } else { - if (!isValidHost(jserver, 3)) { - notice_lang(s_OperServ, u, OPER_JUPE_HOST_ERROR); - } else { + if (!jserver) { + syntax_error(s_OperServ, u, "JUPE", OPER_JUPE_SYNTAX); + } else { + if (!isValidHost(jserver, 3)) { + notice_lang(s_OperServ, u, OPER_JUPE_HOST_ERROR); + } else { char rbuf[256]; snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", u->nick, reason ? ": " : "", reason ? reason : ""); if (findserver(servlist, jserver)) ircdproto->SendSquit(jserver, rbuf); ircdproto->SendServer(jserver, 2, rbuf); new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL); - if (WallOSJupe) - ircdproto->SendGlobops(s_OperServ, "\2%s\2 used JUPE on \2%s\2", - u->nick, jserver); - } - } - return MOD_CONT; + if (WallOSJupe) + ircdproto->SendGlobops(s_OperServ, "\2%s\2 used JUPE on \2%s\2", + u->nick, jserver); + } + } + return MOD_CONT; } MODULE_INIT("os_jupe", OSJupe) diff --git a/src/core/os_kick.c b/src/core/os_kick.c index 7fc7f7aa2..fd47318fe 100644 --- a/src/core/os_kick.c +++ b/src/core/os_kick.c @@ -43,9 +43,9 @@ class OSKick : public Module **/ void myOperServHelp(User * u) { - if (is_services_oper(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_KICK); - } + if (is_services_oper(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_KICK); + } } /** @@ -55,35 +55,35 @@ void myOperServHelp(User * u) **/ int do_os_kick(User * u) { - const char *argv[3]; - char *chan, *nick, *s; - Channel *c; + const char *argv[3]; + char *chan, *nick, *s; + Channel *c; - chan = strtok(NULL, " "); - nick = strtok(NULL, " "); - s = strtok(NULL, ""); - if (!chan || !nick || !s) { - syntax_error(s_OperServ, u, "KICK", OPER_KICK_SYNTAX); - return MOD_CONT; - } - if (!(c = findchan(chan))) { - notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan); - } else if (c->bouncy_modes) { - notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE); - return MOD_CONT; - } - ircdproto->SendKick(findbot(s_OperServ), chan, nick, "%s (%s)", u->nick, s); - if (WallOSKick) - ircdproto->SendGlobops(s_OperServ, "%s used KICK on %s/%s", u->nick, - nick, chan); - argv[0] = sstrdup(chan); - argv[1] = sstrdup(nick); - argv[2] = sstrdup(s); - do_kick(s_OperServ, 3, argv); - free((void *)argv[2]); - free((void *)argv[1]); - free((void *)argv[0]); - return MOD_CONT; + chan = strtok(NULL, " "); + nick = strtok(NULL, " "); + s = strtok(NULL, ""); + if (!chan || !nick || !s) { + syntax_error(s_OperServ, u, "KICK", OPER_KICK_SYNTAX); + return MOD_CONT; + } + if (!(c = findchan(chan))) { + notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan); + } else if (c->bouncy_modes) { + notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE); + return MOD_CONT; + } + ircdproto->SendKick(findbot(s_OperServ), chan, nick, "%s (%s)", u->nick, s); + if (WallOSKick) + ircdproto->SendGlobops(s_OperServ, "%s used KICK on %s/%s", u->nick, + nick, chan); + argv[0] = sstrdup(chan); + argv[1] = sstrdup(nick); + argv[2] = sstrdup(s); + do_kick(s_OperServ, 3, argv); + free((void *)argv[2]); + free((void *)argv[1]); + free((void *)argv[0]); + return MOD_CONT; } MODULE_INIT("os_kick", OSKick) diff --git a/src/core/os_logonnews.c b/src/core/os_logonnews.c index 035c415db..0d26a543e 100644 --- a/src/core/os_logonnews.c +++ b/src/core/os_logonnews.c @@ -66,9 +66,9 @@ class OSLogonNews : public Module **/ void myOperServHelp(User * u) { - if (is_services_admin(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_LOGONNEWS); - } + if (is_services_admin(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_LOGONNEWS); + } } @@ -76,17 +76,17 @@ void myOperServHelp(User * u) * Upon /os reload refresh the count **/ int reload_config(int argc, char **argv) { - char buf[BUFSIZE]; + char buf[BUFSIZE]; - if (argc >= 1) { - if (!stricmp(argv[0], EVENT_START)) { + if (argc >= 1) { + if (!stricmp(argv[0], EVENT_START)) { free(c->help_param1); - snprintf(buf, BUFSIZE, "%d", NewsCount), - c->help_param1 = sstrdup(buf); - } - } + snprintf(buf, BUFSIZE, "%d", NewsCount), + c->help_param1 = sstrdup(buf); + } + } - return MOD_CONT; + return MOD_CONT; } /* EOF */ diff --git a/src/core/os_mode.c b/src/core/os_mode.c index 00be24c10..b004a826e 100644 --- a/src/core/os_mode.c +++ b/src/core/os_mode.c @@ -44,9 +44,9 @@ class OSMode : public Module **/ void myOperServHelp(User * u) { - if (is_services_oper(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_MODE); - } + if (is_services_oper(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_MODE); + } } /** @@ -56,37 +56,37 @@ void myOperServHelp(User * u) **/ int do_os_mode(User * u) { - int ac; - const char **av; - char *chan = strtok(NULL, " "), *modes = strtok(NULL, ""); - Channel *c; + int ac; + const char **av; + char *chan = strtok(NULL, " "), *modes = strtok(NULL, ""); + Channel *c; - if (!chan || !modes) { - syntax_error(s_OperServ, u, "MODE", OPER_MODE_SYNTAX); - return MOD_CONT; - } + if (!chan || !modes) { + syntax_error(s_OperServ, u, "MODE", OPER_MODE_SYNTAX); + return MOD_CONT; + } - if (!(c = findchan(chan))) { - notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan); - } else if (c->bouncy_modes) { - notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE); - return MOD_CONT; - } else if ((ircd->adminmode) && (!is_services_admin(u)) - && (c->mode & ircd->adminmode)) { - notice_lang(s_OperServ, u, PERMISSION_DENIED); - return MOD_CONT; - } else { - ircdproto->SendMode(findbot(s_OperServ), chan, "%s", modes); + if (!(c = findchan(chan))) { + notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan); + } else if (c->bouncy_modes) { + notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE); + return MOD_CONT; + } else if ((ircd->adminmode) && (!is_services_admin(u)) + && (c->mode & ircd->adminmode)) { + notice_lang(s_OperServ, u, PERMISSION_DENIED); + return MOD_CONT; + } else { + ircdproto->SendMode(findbot(s_OperServ), chan, "%s", modes); - ac = split_buf(modes, &av, 1); - chan_set_modes(s_OperServ, c, ac, av, -1); - free(av); + ac = split_buf(modes, &av, 1); + chan_set_modes(s_OperServ, c, ac, av, -1); + free(av); - if (WallOSMode) - ircdproto->SendGlobops(s_OperServ, "%s used MODE %s on %s", u->nick, - modes, chan); - } - return MOD_CONT; + if (WallOSMode) + ircdproto->SendGlobops(s_OperServ, "%s used MODE %s on %s", u->nick, + modes, chan); + } + return MOD_CONT; } MODULE_INIT("os_mode", OSMode) diff --git a/src/core/os_modinfo.c b/src/core/os_modinfo.c index c01ac26f7..485ba89bb 100644 --- a/src/core/os_modinfo.c +++ b/src/core/os_modinfo.c @@ -44,7 +44,7 @@ class OSModInfo : public Module **/ void myOperServHelp(User * u) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_MODINFO); + notice_lang(s_OperServ, u, OPER_HELP_CMD_MODINFO); } /** @@ -54,75 +54,75 @@ void myOperServHelp(User * u) **/ int do_modinfo(User * u) { - char *file; - struct tm tm; - char timebuf[64]; - Module *m; - int idx = 0; + char *file; + struct tm tm; + char timebuf[64]; + Module *m; + int idx = 0; - file = strtok(NULL, ""); - if (!file) { - syntax_error(s_OperServ, u, "MODINFO", OPER_MODULE_INFO_SYNTAX); - return MOD_CONT; - } - m = findModule(file); - if (m) { - tm = *localtime(&m->created); - strftime_lang(timebuf, sizeof(timebuf), u, - STRFTIME_DATE_TIME_FORMAT, &tm); - notice_lang(s_OperServ, u, OPER_MODULE_INFO_LIST, m->name.c_str(), - !m->version.empty() ? m->version.c_str() : "?", - !m->author.empty() ? m->author.c_str() : "?", timebuf); - for (idx = 0; idx < MAX_CMD_HASH; idx++) { - showModuleCmdLoaded(HOSTSERV[idx], m->name.c_str(), u); - showModuleCmdLoaded(OPERSERV[idx], m->name.c_str(), u); - showModuleCmdLoaded(NICKSERV[idx], m->name.c_str(), u); - showModuleCmdLoaded(CHANSERV[idx], m->name.c_str(), u); - showModuleCmdLoaded(BOTSERV[idx], m->name.c_str(), u); - showModuleCmdLoaded(MEMOSERV[idx], m->name.c_str(), u); - showModuleCmdLoaded(HELPSERV[idx], m->name.c_str(), u); - showModuleMsgLoaded(IRCD[idx], m->name.c_str(), u); + file = strtok(NULL, ""); + if (!file) { + syntax_error(s_OperServ, u, "MODINFO", OPER_MODULE_INFO_SYNTAX); + return MOD_CONT; + } + m = findModule(file); + if (m) { + tm = *localtime(&m->created); + strftime_lang(timebuf, sizeof(timebuf), u, + STRFTIME_DATE_TIME_FORMAT, &tm); + notice_lang(s_OperServ, u, OPER_MODULE_INFO_LIST, m->name.c_str(), + !m->version.empty() ? m->version.c_str() : "?", + !m->author.empty() ? m->author.c_str() : "?", timebuf); + for (idx = 0; idx < MAX_CMD_HASH; idx++) { + showModuleCmdLoaded(HOSTSERV[idx], m->name.c_str(), u); + showModuleCmdLoaded(OPERSERV[idx], m->name.c_str(), u); + showModuleCmdLoaded(NICKSERV[idx], m->name.c_str(), u); + showModuleCmdLoaded(CHANSERV[idx], m->name.c_str(), u); + showModuleCmdLoaded(BOTSERV[idx], m->name.c_str(), u); + showModuleCmdLoaded(MEMOSERV[idx], m->name.c_str(), u); + showModuleCmdLoaded(HELPSERV[idx], m->name.c_str(), u); + showModuleMsgLoaded(IRCD[idx], m->name.c_str(), u); - } - } else { - notice_lang(s_OperServ, u, OPER_MODULE_NO_INFO, file); - } - return MOD_CONT; + } + } else { + notice_lang(s_OperServ, u, OPER_MODULE_NO_INFO, file); + } + return MOD_CONT; } int showModuleCmdLoaded(CommandHash * cmdList, const char *mod_name, User * u) { - Command *c; - CommandHash *current; - int display = 0; + Command *c; + CommandHash *current; + int display = 0; - for (current = cmdList; current; current = current->next) { - for (c = current->c; c; c = c->next) { - if ((c->mod_name) && (stricmp(c->mod_name, mod_name) == 0)) { - notice_lang(s_OperServ, u, OPER_MODULE_CMD_LIST, - c->service, c->name); - display++; - } - } - } - return display; + for (current = cmdList; current; current = current->next) { + for (c = current->c; c; c = c->next) { + if ((c->mod_name) && (stricmp(c->mod_name, mod_name) == 0)) { + notice_lang(s_OperServ, u, OPER_MODULE_CMD_LIST, + c->service, c->name); + display++; + } + } + } + return display; } int showModuleMsgLoaded(MessageHash * msgList, const char *mod_name, User * u) { - Message *msg; - MessageHash *mcurrent; - int display = 0; - for (mcurrent = msgList; mcurrent; mcurrent = mcurrent->next) { - for (msg = mcurrent->m; msg; msg = msg->next) { - if ((msg->mod_name) && (stricmp(msg->mod_name, mod_name) == 0)) { - notice_lang(s_OperServ, u, OPER_MODULE_MSG_LIST, - msg->name); - display++; - } - } - } - return display; + Message *msg; + MessageHash *mcurrent; + int display = 0; + for (mcurrent = msgList; mcurrent; mcurrent = mcurrent->next) { + for (msg = mcurrent->m; msg; msg = msg->next) { + if ((msg->mod_name) && (stricmp(msg->mod_name, mod_name) == 0)) { + notice_lang(s_OperServ, u, OPER_MODULE_MSG_LIST, + msg->name); + display++; + } + } + } + return display; } MODULE_INIT("os_modinfo", OSModInfo) diff --git a/src/core/os_modlist.c b/src/core/os_modlist.c index deb2beada..85f1fe936 100644 --- a/src/core/os_modlist.c +++ b/src/core/os_modlist.c @@ -43,7 +43,7 @@ class OSModList : public Module **/ void myOperServHelp(User * u) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_MODLIST); + notice_lang(s_OperServ, u, OPER_HELP_CMD_MODLIST); } /** @@ -53,132 +53,132 @@ void myOperServHelp(User * u) **/ int do_modlist(User * u) { - int idx; - int count = 0; - int showCore = 0; - int showThird = 1; - int showProto = 1; - int showEnc = 1; - int showSupported = 1; - int showQA = 1; - - char *param; - ModuleHash *current = NULL; - - char core[] = "Core"; - char third[] = "3rd"; - char proto[] = "Protocol"; - char enc[] = "Encryption"; - char supported[] = "Supported"; - char qa[] = "QATested"; - - param = strtok(NULL, ""); - if (param) { - if (stricmp(param, core) == 0) { - showCore = 1; - showThird = 0; - showProto = 0; - showEnc = 0; - showSupported = 0; - showQA = 0; - } else if (stricmp(param, third) == 0) { - showCore = 0; - showThird = 1; - showSupported = 0; - showQA = 0; - showProto = 0; - showEnc = 0; - } else if (stricmp(param, proto) == 0) { - showCore = 0; - showThird = 0; - showProto = 1; - showEnc = 0; - showSupported = 0; - showQA = 0; - } else if (stricmp(param, supported) == 0) { - showCore = 0; - showThird = 0; - showProto = 0; - showSupported = 1; - showEnc = 0; - showQA = 0; - } else if (stricmp(param, qa) == 0) { - showCore = 0; - showThird = 0; - showProto = 0; - showSupported = 0; - showEnc = 0; - showQA = 1; - } else if (stricmp(param, enc) == 0) { - showCore = 0; - showThird = 0; - showProto = 0; - showSupported = 0; - showEnc = 1; - showQA = 0; - } - } - - notice_lang(s_OperServ, u, OPER_MODULE_LIST_HEADER); - - for (idx = 0; idx != MAX_CMD_HASH; idx++) { - for (current = MODULE_HASH[idx]; current; current = current->next) { - switch (current->m->type) { - case CORE: - if (showCore) { - notice_lang(s_OperServ, u, OPER_MODULE_LIST, - current->name, current->m->version.c_str(), core); - count++; - } - break; - case THIRD: - if (showThird) { - notice_lang(s_OperServ, u, OPER_MODULE_LIST, - current->name, current->m->version.c_str(), third); - count++; - } - break; - case PROTOCOL: - if (showProto) { - notice_lang(s_OperServ, u, OPER_MODULE_LIST, - current->name, current->m->version.c_str(), proto); - count++; - } - break; - case SUPPORTED: - if (showSupported) { - notice_lang(s_OperServ, u, OPER_MODULE_LIST, - current->name, current->m->version.c_str(), - supported); - count++; - } - break; - case QATESTED: - if (showQA) { - notice_lang(s_OperServ, u, OPER_MODULE_LIST, - current->name, current->m->version.c_str(), qa); - count++; - } - break; - case ENCRYPTION: - if (showEnc) { - notice_lang(s_OperServ, u, OPER_MODULE_LIST, - current->name, current->m->version.c_str(), enc); - count++; - } - break; - - } - - } - } - if (count == 0) { - notice_lang(s_OperServ, u, OPER_MODULE_NO_LIST); - } else { - notice_lang(s_OperServ, u, OPER_MODULE_LIST_FOOTER, count); - } - - return MOD_CONT; + int idx; + int count = 0; + int showCore = 0; + int showThird = 1; + int showProto = 1; + int showEnc = 1; + int showSupported = 1; + int showQA = 1; + + char *param; + ModuleHash *current = NULL; + + char core[] = "Core"; + char third[] = "3rd"; + char proto[] = "Protocol"; + char enc[] = "Encryption"; + char supported[] = "Supported"; + char qa[] = "QATested"; + + param = strtok(NULL, ""); + if (param) { + if (stricmp(param, core) == 0) { + showCore = 1; + showThird = 0; + showProto = 0; + showEnc = 0; + showSupported = 0; + showQA = 0; + } else if (stricmp(param, third) == 0) { + showCore = 0; + showThird = 1; + showSupported = 0; + showQA = 0; + showProto = 0; + showEnc = 0; + } else if (stricmp(param, proto) == 0) { + showCore = 0; + showThird = 0; + showProto = 1; + showEnc = 0; + showSupported = 0; + showQA = 0; + } else if (stricmp(param, supported) == 0) { + showCore = 0; + showThird = 0; + showProto = 0; + showSupported = 1; + showEnc = 0; + showQA = 0; + } else if (stricmp(param, qa) == 0) { + showCore = 0; + showThird = 0; + showProto = 0; + showSupported = 0; + showEnc = 0; + showQA = 1; + } else if (stricmp(param, enc) == 0) { + showCore = 0; + showThird = 0; + showProto = 0; + showSupported = 0; + showEnc = 1; + showQA = 0; + } + } + + notice_lang(s_OperServ, u, OPER_MODULE_LIST_HEADER); + + for (idx = 0; idx != MAX_CMD_HASH; idx++) { + for (current = MODULE_HASH[idx]; current; current = current->next) { + switch (current->m->type) { + case CORE: + if (showCore) { + notice_lang(s_OperServ, u, OPER_MODULE_LIST, + current->name, current->m->version.c_str(), core); + count++; + } + break; + case THIRD: + if (showThird) { + notice_lang(s_OperServ, u, OPER_MODULE_LIST, + current->name, current->m->version.c_str(), third); + count++; + } + break; + case PROTOCOL: + if (showProto) { + notice_lang(s_OperServ, u, OPER_MODULE_LIST, + current->name, current->m->version.c_str(), proto); + count++; + } + break; + case SUPPORTED: + if (showSupported) { + notice_lang(s_OperServ, u, OPER_MODULE_LIST, + current->name, current->m->version.c_str(), + supported); + count++; + } + break; + case QATESTED: + if (showQA) { + notice_lang(s_OperServ, u, OPER_MODULE_LIST, + current->name, current->m->version.c_str(), qa); + count++; + } + break; + case ENCRYPTION: + if (showEnc) { + notice_lang(s_OperServ, u, OPER_MODULE_LIST, + current->name, current->m->version.c_str(), enc); + count++; + } + break; + + } + + } + } + if (count == 0) { + notice_lang(s_OperServ, u, OPER_MODULE_NO_LIST); + } else { + notice_lang(s_OperServ, u, OPER_MODULE_LIST_FOOTER, count); + } + + return MOD_CONT; } MODULE_INIT("os_modlist", OSModList) diff --git a/src/core/os_modload.c b/src/core/os_modload.c index 3c7ce4a39..c48135901 100644 --- a/src/core/os_modload.c +++ b/src/core/os_modload.c @@ -43,9 +43,9 @@ class OSModLoad : public Module **/ void myOperServHelp(User * u) { - if (is_services_root(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_MODLOAD); - } + if (is_services_root(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_MODLOAD); + } } /** @@ -77,7 +77,7 @@ int do_modload(User * u) notice_lang(s_OperServ, u, OPER_MODULE_LOAD_FAIL, m->name.c_str()); } - return MOD_CONT; + return MOD_CONT; } MODULE_INIT("os_modload", OSModLoad) diff --git a/src/core/os_modunload.c b/src/core/os_modunload.c index 96790357f..994a056ad 100644 --- a/src/core/os_modunload.c +++ b/src/core/os_modunload.c @@ -45,9 +45,9 @@ class OSModUnLoad : public Module **/ void myOperServHelp(User * u) { - if (is_services_root(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_MODUNLOAD); - } + if (is_services_root(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_MODUNLOAD); + } } /** diff --git a/src/core/os_noop.c b/src/core/os_noop.c index e3ba6f190..a5f66a747 100644 --- a/src/core/os_noop.c +++ b/src/core/os_noop.c @@ -44,9 +44,9 @@ class OSNOOP : public Module **/ void myOperServHelp(User * u) { - if (is_services_admin(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_NOOP); - } + if (is_services_admin(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_NOOP); + } } /** @@ -56,41 +56,41 @@ void myOperServHelp(User * u) **/ int do_noop(User * u) { - char *cmd = strtok(NULL, " "); - char *server = strtok(NULL, " "); + char *cmd = strtok(NULL, " "); + char *server = strtok(NULL, " "); - if (!cmd || !server) { - syntax_error(s_OperServ, u, "NOOP", OPER_NOOP_SYNTAX); - } else if (!stricmp(cmd, "SET")) { - User *u2; - User *u3 = NULL; - char reason[NICKMAX + 32]; + if (!cmd || !server) { + syntax_error(s_OperServ, u, "NOOP", OPER_NOOP_SYNTAX); + } else if (!stricmp(cmd, "SET")) { + User *u2; + User *u3 = NULL; + char reason[NICKMAX + 32]; - /* Remove the O:lines */ - ircdproto->SendSVSNOOP(server, 1); + /* Remove the O:lines */ + ircdproto->SendSVSNOOP(server, 1); - snprintf(reason, sizeof(reason), "NOOP command used by %s", - u->nick); - if (WallOSNoOp) - ircdproto->SendGlobops(s_OperServ, "\2%s\2 used NOOP on \2%s\2", - u->nick, server); - notice_lang(s_OperServ, u, OPER_NOOP_SET, server); + snprintf(reason, sizeof(reason), "NOOP command used by %s", + u->nick); + if (WallOSNoOp) + ircdproto->SendGlobops(s_OperServ, "\2%s\2 used NOOP on \2%s\2", + u->nick, server); + notice_lang(s_OperServ, u, OPER_NOOP_SET, server); - /* Kill all the IRCops of the server */ - for (u2 = firstuser(); u2; u2 = u3) { - u3 = nextuser(); - if ((u2) && is_oper(u2) && (u2->server->name) - && match_wild(server, u2->server->name)) { - kill_user(s_OperServ, u2->nick, reason); - } - } - } else if (!stricmp(cmd, "REVOKE")) { - ircdproto->SendSVSNOOP(server, 0); - notice_lang(s_OperServ, u, OPER_NOOP_REVOKE, server); - } else { - syntax_error(s_OperServ, u, "NOOP", OPER_NOOP_SYNTAX); - } - return MOD_CONT; + /* Kill all the IRCops of the server */ + for (u2 = firstuser(); u2; u2 = u3) { + u3 = nextuser(); + if ((u2) && is_oper(u2) && (u2->server->name) + && match_wild(server, u2->server->name)) { + kill_user(s_OperServ, u2->nick, reason); + } + } + } else if (!stricmp(cmd, "REVOKE")) { + ircdproto->SendSVSNOOP(server, 0); + notice_lang(s_OperServ, u, OPER_NOOP_REVOKE, server); + } else { + syntax_error(s_OperServ, u, "NOOP", OPER_NOOP_SYNTAX); + } + return MOD_CONT; } MODULE_INIT("os_noop", OSNOOP) diff --git a/src/core/os_oline.c b/src/core/os_oline.c index 3cce00093..5f9f65fd1 100644 --- a/src/core/os_oline.c +++ b/src/core/os_oline.c @@ -47,9 +47,9 @@ class OSOLine : public Module **/ void myOperServHelp(User * u) { - if (is_services_admin(u) && u->isSuperAdmin) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_OLINE); - } + if (is_services_admin(u) && u->isSuperAdmin) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_OLINE); + } } /** @@ -59,40 +59,40 @@ void myOperServHelp(User * u) **/ int do_operoline(User * u) { - char *nick = strtok(NULL, " "); - char *flags = strtok(NULL, ""); - User *u2 = NULL; + char *nick = strtok(NULL, " "); + char *flags = strtok(NULL, ""); + User *u2 = NULL; - /* Only allow this if SuperAdmin is enabled */ - if (!u->isSuperAdmin) { - notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ONLY); - return MOD_CONT; - } + /* Only allow this if SuperAdmin is enabled */ + if (!u->isSuperAdmin) { + notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ONLY); + return MOD_CONT; + } - if (!nick || !flags) { - syntax_error(s_OperServ, u, "OLINE", OPER_OLINE_SYNTAX); - return MOD_CONT; - } else { - /* let's check whether the user is online */ - if (!(u2 = finduser(nick))) { - notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, nick); - } else if (u2 && flags[0] == '+') { - ircdproto->SendSVSO(s_OperServ, nick, flags); - ircdproto->SendMode(findbot(s_OperServ), nick, "+o"); - common_svsmode(u2, "+o", NULL); - notice_lang(s_OperServ, u2, OPER_OLINE_IRCOP); - notice_lang(s_OperServ, u, OPER_OLINE_SUCCESS, flags, nick); - ircdproto->SendGlobops(s_OperServ, "\2%s\2 used OLINE for %s", - u->nick, nick); - } else if (u2 && flags[0] == '-') { - ircdproto->SendSVSO(s_OperServ, nick, flags); - notice_lang(s_OperServ, u, OPER_OLINE_SUCCESS, flags, nick); - ircdproto->SendGlobops(s_OperServ, "\2%s\2 used OLINE for %s", - u->nick, nick); - } else - syntax_error(s_OperServ, u, "OLINE", OPER_OLINE_SYNTAX); - } - return MOD_CONT; + if (!nick || !flags) { + syntax_error(s_OperServ, u, "OLINE", OPER_OLINE_SYNTAX); + return MOD_CONT; + } else { + /* let's check whether the user is online */ + if (!(u2 = finduser(nick))) { + notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, nick); + } else if (u2 && flags[0] == '+') { + ircdproto->SendSVSO(s_OperServ, nick, flags); + ircdproto->SendMode(findbot(s_OperServ), nick, "+o"); + common_svsmode(u2, "+o", NULL); + notice_lang(s_OperServ, u2, OPER_OLINE_IRCOP); + notice_lang(s_OperServ, u, OPER_OLINE_SUCCESS, flags, nick); + ircdproto->SendGlobops(s_OperServ, "\2%s\2 used OLINE for %s", + u->nick, nick); + } else if (u2 && flags[0] == '-') { + ircdproto->SendSVSO(s_OperServ, nick, flags); + notice_lang(s_OperServ, u, OPER_OLINE_SUCCESS, flags, nick); + ircdproto->SendGlobops(s_OperServ, "\2%s\2 used OLINE for %s", + u->nick, nick); + } else + syntax_error(s_OperServ, u, "OLINE", OPER_OLINE_SYNTAX); + } + return MOD_CONT; } MODULE_INIT("os_oline", OSOLine) diff --git a/src/core/os_oper.c b/src/core/os_oper.c index 15a56832b..f93dab779 100644 --- a/src/core/os_oper.c +++ b/src/core/os_oper.c @@ -17,7 +17,7 @@ int do_oper(User * u); int oper_list_callback(SList * slist, int number, void *item, - va_list args); + va_list args); int oper_list(int number, NickCore * nc, User * u, int *sent_header); void myOperServHelp(User * u); @@ -46,7 +46,7 @@ class OSOper : public Module **/ void myOperServHelp(User * u) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_OPER); + notice_lang(s_OperServ, u, OPER_HELP_CMD_OPER); } /** @@ -56,181 +56,181 @@ void myOperServHelp(User * u) **/ int do_oper(User * u) { - char *cmd = strtok(NULL, " "); - char *nick = strtok(NULL, " "); - NickAlias *na; - int res = 0; - - if (!cmd || (!nick && stricmp(cmd, "LIST") && stricmp(cmd, "CLEAR"))) { - syntax_error(s_OperServ, u, "OPER", OPER_OPER_SYNTAX); - } else if (!stricmp(cmd, "ADD")) { - if (!is_services_root(u)) { - notice_lang(s_OperServ, u, PERMISSION_DENIED); - return MOD_CONT; - } - - if (!(na = findnick(nick))) { - notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick); - return MOD_CONT; - } - - if (na->status & NS_VERBOTEN) { - notice_lang(s_OperServ, u, NICK_X_FORBIDDEN, nick); - return MOD_CONT; - } - - if (na->nc->flags & NI_SERVICES_OPER - || slist_indexof(&servopers, na->nc) != -1) { - notice_lang(s_OperServ, u, OPER_OPER_EXISTS, nick); - return MOD_CONT; - } - - res = slist_add(&servopers, na->nc); - if (res == -2) { - notice_lang(s_OperServ, u, OPER_OPER_REACHED_LIMIT, nick); - return MOD_CONT; - } else { - if (na->nc->flags & NI_SERVICES_ADMIN - && (res = slist_indexof(&servadmins, na->nc)) != -1) { - if (!is_services_root(u)) { - notice_lang(s_OperServ, u, PERMISSION_DENIED); - return MOD_CONT; - } - slist_delete(&servadmins, res); - na->nc->flags |= NI_SERVICES_OPER; - notice_lang(s_OperServ, u, OPER_OPER_MOVED, nick); - } else { - na->nc->flags |= NI_SERVICES_OPER; - notice_lang(s_OperServ, u, OPER_OPER_ADDED, nick); - } - } - - if (readonly) - notice_lang(s_OperServ, u, READ_ONLY_MODE); - } else if (!stricmp(cmd, "DEL")) { - if (!is_services_root(u)) { - notice_lang(s_OperServ, u, PERMISSION_DENIED); - return MOD_CONT; - } - - if (isdigit(*nick) && strspn(nick, "1234567890,-") == strlen(nick)) { - /* Deleting a range */ - res = slist_delete_range(&servopers, nick, NULL); - if (res == 0) { - notice_lang(s_OperServ, u, OPER_OPER_NO_MATCH); - return MOD_CONT; - } else if (res == 1) { - notice_lang(s_OperServ, u, OPER_OPER_DELETED_ONE); - } else { - notice_lang(s_OperServ, u, OPER_OPER_DELETED_SEVERAL, res); - } - } else { - if (!(na = findnick(nick))) { - notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick); - return MOD_CONT; - } - - if (na->status & NS_VERBOTEN) { - notice_lang(s_OperServ, u, NICK_X_FORBIDDEN, nick); - return MOD_CONT; - } - - if (!(na->nc->flags & NI_SERVICES_OPER) - || (res = slist_indexof(&servopers, na->nc)) == -1) { - notice_lang(s_OperServ, u, OPER_OPER_NOT_FOUND, nick); - return MOD_CONT; - } - - slist_delete(&servopers, res); - notice_lang(s_OperServ, u, OPER_OPER_DELETED, nick); - } - - if (readonly) - notice_lang(s_OperServ, u, READ_ONLY_MODE); - } else if (!stricmp(cmd, "LIST")) { - int sent_header = 0; + char *cmd = strtok(NULL, " "); + char *nick = strtok(NULL, " "); + NickAlias *na; + int res = 0; + + if (!cmd || (!nick && stricmp(cmd, "LIST") && stricmp(cmd, "CLEAR"))) { + syntax_error(s_OperServ, u, "OPER", OPER_OPER_SYNTAX); + } else if (!stricmp(cmd, "ADD")) { + if (!is_services_root(u)) { + notice_lang(s_OperServ, u, PERMISSION_DENIED); + return MOD_CONT; + } + + if (!(na = findnick(nick))) { + notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick); + return MOD_CONT; + } + + if (na->status & NS_VERBOTEN) { + notice_lang(s_OperServ, u, NICK_X_FORBIDDEN, nick); + return MOD_CONT; + } + + if (na->nc->flags & NI_SERVICES_OPER + || slist_indexof(&servopers, na->nc) != -1) { + notice_lang(s_OperServ, u, OPER_OPER_EXISTS, nick); + return MOD_CONT; + } + + res = slist_add(&servopers, na->nc); + if (res == -2) { + notice_lang(s_OperServ, u, OPER_OPER_REACHED_LIMIT, nick); + return MOD_CONT; + } else { + if (na->nc->flags & NI_SERVICES_ADMIN + && (res = slist_indexof(&servadmins, na->nc)) != -1) { + if (!is_services_root(u)) { + notice_lang(s_OperServ, u, PERMISSION_DENIED); + return MOD_CONT; + } + slist_delete(&servadmins, res); + na->nc->flags |= NI_SERVICES_OPER; + notice_lang(s_OperServ, u, OPER_OPER_MOVED, nick); + } else { + na->nc->flags |= NI_SERVICES_OPER; + notice_lang(s_OperServ, u, OPER_OPER_ADDED, nick); + } + } + + if (readonly) + notice_lang(s_OperServ, u, READ_ONLY_MODE); + } else if (!stricmp(cmd, "DEL")) { + if (!is_services_root(u)) { + notice_lang(s_OperServ, u, PERMISSION_DENIED); + return MOD_CONT; + } + + if (isdigit(*nick) && strspn(nick, "1234567890,-") == strlen(nick)) { + /* Deleting a range */ + res = slist_delete_range(&servopers, nick, NULL); + if (res == 0) { + notice_lang(s_OperServ, u, OPER_OPER_NO_MATCH); + return MOD_CONT; + } else if (res == 1) { + notice_lang(s_OperServ, u, OPER_OPER_DELETED_ONE); + } else { + notice_lang(s_OperServ, u, OPER_OPER_DELETED_SEVERAL, res); + } + } else { + if (!(na = findnick(nick))) { + notice_lang(s_OperServ, u, NICK_X_NOT_REGISTERED, nick); + return MOD_CONT; + } + + if (na->status & NS_VERBOTEN) { + notice_lang(s_OperServ, u, NICK_X_FORBIDDEN, nick); + return MOD_CONT; + } + + if (!(na->nc->flags & NI_SERVICES_OPER) + || (res = slist_indexof(&servopers, na->nc)) == -1) { + notice_lang(s_OperServ, u, OPER_OPER_NOT_FOUND, nick); + return MOD_CONT; + } + + slist_delete(&servopers, res); + notice_lang(s_OperServ, u, OPER_OPER_DELETED, nick); + } + + if (readonly) + notice_lang(s_OperServ, u, READ_ONLY_MODE); + } else if (!stricmp(cmd, "LIST")) { + int sent_header = 0; if (!is_oper(u)) { notice_lang(s_OperServ, u, PERMISSION_DENIED); return MOD_CONT; } - if (servopers.count == 0) { - notice_lang(s_OperServ, u, OPER_OPER_LIST_EMPTY); - return MOD_CONT; - } - - if (!nick || (isdigit(*nick) - && strspn(nick, "1234567890,-") == strlen(nick))) { - res = - slist_enum(&servopers, nick, &oper_list_callback, u, - &sent_header); - if (res == 0) { - notice_lang(s_OperServ, u, OPER_OPER_NO_MATCH); - return MOD_CONT; - } else { - notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Oper"); - } - } else { - int i; - - for (i = 0; i < servopers.count; i++) - if (!stricmp - (nick, ((NickCore *) servopers.list[i])->display) - || match_wild_nocase(nick, - ((NickCore *) servopers.list[i])-> - display)) - oper_list(i + 1, (NickCore *)servopers.list[i], u, &sent_header); - - if (!sent_header) - notice_lang(s_OperServ, u, OPER_OPER_NO_MATCH); - else { - notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Oper"); - } - } - } else if (!stricmp(cmd, "CLEAR")) { - if (!is_services_root(u)) { - notice_lang(s_OperServ, u, PERMISSION_DENIED); - return MOD_CONT; - } - - if (servopers.count == 0) { - notice_lang(s_OperServ, u, OPER_OPER_LIST_EMPTY); - return MOD_CONT; - } - - slist_clear(&servopers, 1); - notice_lang(s_OperServ, u, OPER_OPER_CLEAR); - } else { - syntax_error(s_OperServ, u, "OPER", OPER_OPER_SYNTAX); - } - return MOD_CONT; + if (servopers.count == 0) { + notice_lang(s_OperServ, u, OPER_OPER_LIST_EMPTY); + return MOD_CONT; + } + + if (!nick || (isdigit(*nick) + && strspn(nick, "1234567890,-") == strlen(nick))) { + res = + slist_enum(&servopers, nick, &oper_list_callback, u, + &sent_header); + if (res == 0) { + notice_lang(s_OperServ, u, OPER_OPER_NO_MATCH); + return MOD_CONT; + } else { + notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Oper"); + } + } else { + int i; + + for (i = 0; i < servopers.count; i++) + if (!stricmp + (nick, ((NickCore *) servopers.list[i])->display) + || match_wild_nocase(nick, + ((NickCore *) servopers.list[i])-> + display)) + oper_list(i + 1, (NickCore *)servopers.list[i], u, &sent_header); + + if (!sent_header) + notice_lang(s_OperServ, u, OPER_OPER_NO_MATCH); + else { + notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Oper"); + } + } + } else if (!stricmp(cmd, "CLEAR")) { + if (!is_services_root(u)) { + notice_lang(s_OperServ, u, PERMISSION_DENIED); + return MOD_CONT; + } + + if (servopers.count == 0) { + notice_lang(s_OperServ, u, OPER_OPER_LIST_EMPTY); + return MOD_CONT; + } + + slist_clear(&servopers, 1); + notice_lang(s_OperServ, u, OPER_OPER_CLEAR); + } else { + syntax_error(s_OperServ, u, "OPER", OPER_OPER_SYNTAX); + } + return MOD_CONT; } /* Lists an oper entry, prefixing it with the header if needed */ int oper_list(int number, NickCore * nc, User * u, int *sent_header) { - if (!nc) - return 0; + if (!nc) + return 0; - if (!*sent_header) { - notice_lang(s_OperServ, u, OPER_OPER_LIST_HEADER); - *sent_header = 1; - } + if (!*sent_header) { + notice_lang(s_OperServ, u, OPER_OPER_LIST_HEADER); + *sent_header = 1; + } - notice_lang(s_OperServ, u, OPER_OPER_LIST_FORMAT, number, nc->display); - return 1; + notice_lang(s_OperServ, u, OPER_OPER_LIST_FORMAT, number, nc->display); + return 1; } /* Callback for enumeration purposes */ int oper_list_callback(SList * slist, int number, void *item, va_list args) { - User *u = va_arg(args, User *); - int *sent_header = va_arg(args, int *); + User *u = va_arg(args, User *); + int *sent_header = va_arg(args, int *); - return oper_list(number, (NickCore *)item, u, sent_header); + return oper_list(number, (NickCore *)item, u, sent_header); } MODULE_INIT("os_oper", OSOper) diff --git a/src/core/os_opernews.c b/src/core/os_opernews.c index 13b71da53..82fed8e76 100644 --- a/src/core/os_opernews.c +++ b/src/core/os_opernews.c @@ -50,7 +50,7 @@ class OSOperNews : public Module ~OSOperNews() { - free(c->help_param1); + free(c->help_param1); } }; @@ -61,26 +61,26 @@ class OSOperNews : public Module **/ void myOperServHelp(User * u) { - if (is_services_admin(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_OPERNEWS); - } + if (is_services_admin(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_OPERNEWS); + } } /** * Upon /os reload refresh the count **/ int reload_config(int argc, char **argv) { - char buf[BUFSIZE]; - - if (argc >= 1) { - if (!stricmp(argv[0], EVENT_START)) { - free(c->help_param1); - snprintf(buf, BUFSIZE, "%d", NewsCount), - c->help_param1 = sstrdup(buf); - } - } + char buf[BUFSIZE]; + + if (argc >= 1) { + if (!stricmp(argv[0], EVENT_START)) { + free(c->help_param1); + snprintf(buf, BUFSIZE, "%d", NewsCount), + c->help_param1 = sstrdup(buf); + } + } - return MOD_CONT; + return MOD_CONT; } diff --git a/src/core/os_quit.c b/src/core/os_quit.c index 42410c780..019cf9617 100644 --- a/src/core/os_quit.c +++ b/src/core/os_quit.c @@ -43,9 +43,9 @@ class OSQuit : public Module **/ void myOperServHelp(User * u) { - if (is_services_root(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_QUIT); - } + if (is_services_root(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_QUIT); + } } /** @@ -55,17 +55,17 @@ void myOperServHelp(User * u) **/ int do_os_quit(User * u) { - quitmsg = (char *)calloc(28 + strlen(u->nick), 1); - if (!quitmsg) - quitmsg = "QUIT command received, but out of memory!"; - else - sprintf((char *)quitmsg, "QUIT command received from %s", u->nick); // XXX we know this is safe, but.. + quitmsg = (char *)calloc(28 + strlen(u->nick), 1); + if (!quitmsg) + quitmsg = "QUIT command received, but out of memory!"; + else + sprintf((char *)quitmsg, "QUIT command received from %s", u->nick); // XXX we know this is safe, but.. - if (GlobalOnCycle) { - oper_global(NULL, "%s", GlobalOnCycleMessage); - } - quitting = 1; - return MOD_CONT; + if (GlobalOnCycle) { + oper_global(NULL, "%s", GlobalOnCycleMessage); + } + quitting = 1; + return MOD_CONT; } MODULE_INIT("os_quit", OSQuit) diff --git a/src/core/os_randomnews.c b/src/core/os_randomnews.c index 3c4db1985..d20b1b1fd 100644 --- a/src/core/os_randomnews.c +++ b/src/core/os_randomnews.c @@ -46,9 +46,9 @@ class OSRandomNews : public Module **/ void myOperServHelp(User * u) { - if (is_services_admin(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_RANDOMNEWS); - } + if (is_services_admin(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_RANDOMNEWS); + } } MODULE_INIT("os_randomnews", OSRandomNews) diff --git a/src/core/os_raw.c b/src/core/os_raw.c index be520e305..140b329e2 100644 --- a/src/core/os_raw.c +++ b/src/core/os_raw.c @@ -44,23 +44,23 @@ class OSRaw : public Module **/ int do_raw(User * u) { - char *text = strtok(NULL, ""); - if (!text) - syntax_error(s_OperServ, u, "RAW", OPER_RAW_SYNTAX); - else { - send_cmd(NULL, "%s", text); - if (WallOSRaw) { - char *kw = strtok(text, " "); - while (kw && *kw == ':') - kw = strtok(NULL, " "); - ircdproto->SendGlobops(s_OperServ, - "\2%s\2 used RAW command for \2%s\2", - u->nick, - (kw ? kw : "\2non RFC compliant message\2")); - } - alog("%s used RAW command for %s", u->nick, text); - } - return MOD_CONT; + char *text = strtok(NULL, ""); + if (!text) + syntax_error(s_OperServ, u, "RAW", OPER_RAW_SYNTAX); + else { + send_cmd(NULL, "%s", text); + if (WallOSRaw) { + char *kw = strtok(text, " "); + while (kw && *kw == ':') + kw = strtok(NULL, " "); + ircdproto->SendGlobops(s_OperServ, + "\2%s\2 used RAW command for \2%s\2", + u->nick, + (kw ? kw : "\2non RFC compliant message\2")); + } + alog("%s used RAW command for %s", u->nick, text); + } + return MOD_CONT; } MODULE_INIT("os_raw", OSRaw) diff --git a/src/core/os_reload.c b/src/core/os_reload.c index 693838700..514fa42e7 100644 --- a/src/core/os_reload.c +++ b/src/core/os_reload.c @@ -43,9 +43,9 @@ class OSReload : public Module **/ void myOperServHelp(User * u) { - if (is_services_root(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_RELOAD); - } + if (is_services_root(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_RELOAD); + } } /** @@ -55,19 +55,19 @@ void myOperServHelp(User * u) **/ int do_reload(User * u) { - if (!read_config(1)) { - quitmsg = (char *)calloc(28 + strlen(u->nick), 1); - if (!quitmsg) - quitmsg = - "Error during the reload of the configuration file, but out of memory!"; - else - sprintf((char *)quitmsg, /* XXX */ - "Error during the reload of the configuration file!"); - quitting = 1; - } - send_event(EVENT_RELOAD, 1, EVENT_START); - notice_lang(s_OperServ, u, OPER_RELOAD); - return MOD_CONT; + if (!read_config(1)) { + quitmsg = (char *)calloc(28 + strlen(u->nick), 1); + if (!quitmsg) + quitmsg = + "Error during the reload of the configuration file, but out of memory!"; + else + sprintf((char *)quitmsg, /* XXX */ + "Error during the reload of the configuration file!"); + quitting = 1; + } + send_event(EVENT_RELOAD, 1, EVENT_START); + notice_lang(s_OperServ, u, OPER_RELOAD); + return MOD_CONT; } MODULE_INIT("os_reload", OSReload) diff --git a/src/core/os_restart.c b/src/core/os_restart.c index 5380244a8..e690de97e 100644 --- a/src/core/os_restart.c +++ b/src/core/os_restart.c @@ -47,9 +47,9 @@ class OSRestart : public Module **/ void myOperServHelp(User * u) { - if (is_services_root(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_RESTART); - } + if (is_services_root(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_RESTART); + } } /** @@ -60,21 +60,21 @@ void myOperServHelp(User * u) int do_restart(User * u) { #ifdef SERVICES_BIN - quitmsg = (char *)calloc(31 + strlen(u->nick), 1); - if (!quitmsg) - quitmsg = "RESTART command received, but out of memory!"; - else - sprintf((char *)quitmsg, /* XXX */ "RESTART command received from %s", u->nick); + quitmsg = (char *)calloc(31 + strlen(u->nick), 1); + if (!quitmsg) + quitmsg = "RESTART command received, but out of memory!"; + else + sprintf((char *)quitmsg, /* XXX */ "RESTART command received from %s", u->nick); - if (GlobalOnCycle) { - oper_global(NULL, "%s", GlobalOnCycleMessage); - } - /* raise(SIGHUP); */ - do_restart_services(); + if (GlobalOnCycle) { + oper_global(NULL, "%s", GlobalOnCycleMessage); + } + /* raise(SIGHUP); */ + do_restart_services(); #else - notice_lang(s_OperServ, u, OPER_CANNOT_RESTART); + notice_lang(s_OperServ, u, OPER_CANNOT_RESTART); #endif - return MOD_CONT; + return MOD_CONT; } MODULE_INIT("os_restart", OSRestart) diff --git a/src/core/os_session.c b/src/core/os_session.c index ddc8fe9b2..9a8bad41c 100644 --- a/src/core/os_session.c +++ b/src/core/os_session.c @@ -47,10 +47,10 @@ class OSSession : public Module **/ void myOperServHelp(User * u) { - if (is_services_oper(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_SESSION); - notice_lang(s_OperServ, u, OPER_HELP_CMD_EXCEPTION); - } + if (is_services_oper(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_SESSION); + notice_lang(s_OperServ, u, OPER_HELP_CMD_EXCEPTION); + } } MODULE_INIT("os_session", OSSession) diff --git a/src/core/os_set.c b/src/core/os_set.c index 8472b56df..600a292d0 100644 --- a/src/core/os_set.c +++ b/src/core/os_set.c @@ -57,9 +57,9 @@ class OSSet : public Module **/ void myOperServHelp(User * u) { - if (is_services_root(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_SET); - } + if (is_services_root(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_SET); + } } /** @@ -69,173 +69,173 @@ void myOperServHelp(User * u) **/ int do_set(User * u) { - char *option = strtok(NULL, " "); - char *setting = strtok(NULL, " "); - int index; - Channel *c; + char *option = strtok(NULL, " "); + char *setting = strtok(NULL, " "); + int index; + Channel *c; - if (!option) { - syntax_error(s_OperServ, u, "SET", OPER_SET_SYNTAX); - } else if (stricmp(option, "LIST") == 0) { - index = - (allow_ignore ? OPER_SET_LIST_OPTION_ON : - OPER_SET_LIST_OPTION_OFF); - notice_lang(s_OperServ, u, index, "IGNORE"); - index = - (readonly ? OPER_SET_LIST_OPTION_ON : - OPER_SET_LIST_OPTION_OFF); - notice_lang(s_OperServ, u, index, "READONLY"); - index = - (logchan ? OPER_SET_LIST_OPTION_ON : OPER_SET_LIST_OPTION_OFF); - notice_lang(s_OperServ, u, index, "LOGCHAN"); - index = - (debug ? OPER_SET_LIST_OPTION_ON : OPER_SET_LIST_OPTION_OFF); - notice_lang(s_OperServ, u, index, "DEBUG"); - index = - (noexpire ? OPER_SET_LIST_OPTION_ON : - OPER_SET_LIST_OPTION_OFF); - notice_lang(s_OperServ, u, index, "NOEXPIRE"); + if (!option) { + syntax_error(s_OperServ, u, "SET", OPER_SET_SYNTAX); + } else if (stricmp(option, "LIST") == 0) { + index = + (allow_ignore ? OPER_SET_LIST_OPTION_ON : + OPER_SET_LIST_OPTION_OFF); + notice_lang(s_OperServ, u, index, "IGNORE"); + index = + (readonly ? OPER_SET_LIST_OPTION_ON : + OPER_SET_LIST_OPTION_OFF); + notice_lang(s_OperServ, u, index, "READONLY"); + index = + (logchan ? OPER_SET_LIST_OPTION_ON : OPER_SET_LIST_OPTION_OFF); + notice_lang(s_OperServ, u, index, "LOGCHAN"); + index = + (debug ? OPER_SET_LIST_OPTION_ON : OPER_SET_LIST_OPTION_OFF); + notice_lang(s_OperServ, u, index, "DEBUG"); + index = + (noexpire ? OPER_SET_LIST_OPTION_ON : + OPER_SET_LIST_OPTION_OFF); + notice_lang(s_OperServ, u, index, "NOEXPIRE"); #ifdef USE_MYSQL - index = - (do_mysql ? OPER_SET_LIST_OPTION_ON : - OPER_SET_LIST_OPTION_OFF); - notice_lang(s_OperServ, u, index, "SQL"); + index = + (do_mysql ? OPER_SET_LIST_OPTION_ON : + OPER_SET_LIST_OPTION_OFF); + notice_lang(s_OperServ, u, index, "SQL"); #endif - } else if (!setting) { - syntax_error(s_OperServ, u, "SET", OPER_SET_SYNTAX); - } else if (stricmp(option, "IGNORE") == 0) { - if (stricmp(setting, "on") == 0) { - allow_ignore = 1; - notice_lang(s_OperServ, u, OPER_SET_IGNORE_ON); - } else if (stricmp(setting, "off") == 0) { - allow_ignore = 0; - notice_lang(s_OperServ, u, OPER_SET_IGNORE_OFF); - } else { - notice_lang(s_OperServ, u, OPER_SET_IGNORE_ERROR); - } + } else if (!setting) { + syntax_error(s_OperServ, u, "SET", OPER_SET_SYNTAX); + } else if (stricmp(option, "IGNORE") == 0) { + if (stricmp(setting, "on") == 0) { + allow_ignore = 1; + notice_lang(s_OperServ, u, OPER_SET_IGNORE_ON); + } else if (stricmp(setting, "off") == 0) { + allow_ignore = 0; + notice_lang(s_OperServ, u, OPER_SET_IGNORE_OFF); + } else { + notice_lang(s_OperServ, u, OPER_SET_IGNORE_ERROR); + } #ifdef USE_MYSQL - } else if (stricmp(option, "SQL") == 0) { - if (stricmp(setting, "on") == 0) { - if (!MysqlHost) { - notice_lang(s_OperServ, u, OPER_SET_SQL_ERROR_DISABLED); - } else { - if (rdb_init()) { - notice_lang(s_OperServ, u, OPER_SET_SQL_ON); - } else { - notice_lang(s_OperServ, u, OPER_SET_SQL_ERROR_INIT); - } - } - } else if (stricmp(setting, "off") == 0) { - if (!MysqlHost) { - notice_lang(s_OperServ, u, OPER_SET_SQL_ERROR_DISABLED); - } else { - /* could call rdb_close() but that does nothing - TSL */ - do_mysql = 0; - notice_lang(s_OperServ, u, OPER_SET_SQL_OFF); - } - } else { - notice_lang(s_OperServ, u, OPER_SET_SQL_ERROR); - } + } else if (stricmp(option, "SQL") == 0) { + if (stricmp(setting, "on") == 0) { + if (!MysqlHost) { + notice_lang(s_OperServ, u, OPER_SET_SQL_ERROR_DISABLED); + } else { + if (rdb_init()) { + notice_lang(s_OperServ, u, OPER_SET_SQL_ON); + } else { + notice_lang(s_OperServ, u, OPER_SET_SQL_ERROR_INIT); + } + } + } else if (stricmp(setting, "off") == 0) { + if (!MysqlHost) { + notice_lang(s_OperServ, u, OPER_SET_SQL_ERROR_DISABLED); + } else { + /* could call rdb_close() but that does nothing - TSL */ + do_mysql = 0; + notice_lang(s_OperServ, u, OPER_SET_SQL_OFF); + } + } else { + notice_lang(s_OperServ, u, OPER_SET_SQL_ERROR); + } #endif - } else if (stricmp(option, "READONLY") == 0) { - if (stricmp(setting, "on") == 0) { - readonly = 1; - alog("Read-only mode activated"); - close_log(); - notice_lang(s_OperServ, u, OPER_SET_READONLY_ON); - } else if (stricmp(setting, "off") == 0) { - readonly = 0; - open_log(); - alog("Read-only mode deactivated"); - notice_lang(s_OperServ, u, OPER_SET_READONLY_OFF); - } else { - notice_lang(s_OperServ, u, OPER_SET_READONLY_ERROR); - } + } else if (stricmp(option, "READONLY") == 0) { + if (stricmp(setting, "on") == 0) { + readonly = 1; + alog("Read-only mode activated"); + close_log(); + notice_lang(s_OperServ, u, OPER_SET_READONLY_ON); + } else if (stricmp(setting, "off") == 0) { + readonly = 0; + open_log(); + alog("Read-only mode deactivated"); + notice_lang(s_OperServ, u, OPER_SET_READONLY_OFF); + } else { + notice_lang(s_OperServ, u, OPER_SET_READONLY_ERROR); + } - } else if (stricmp(option, "LOGCHAN") == 0) { - /* Unlike the other SET commands where only stricmp is necessary, - * we also have to ensure that LogChannel is defined or we can't - * send to it. - * - * -jester - */ - if (LogChannel && (stricmp(setting, "on") == 0)) { - if (ircd->join2msg) { - c = findchan(LogChannel); - ircdproto->SendJoin(findbot(s_GlobalNoticer), LogChannel, c ? c->creation_time : time(NULL)); - } - logchan = 1; - alog("Now sending log messages to %s", LogChannel); - notice_lang(s_OperServ, u, OPER_SET_LOGCHAN_ON, LogChannel); - } else if (LogChannel && (stricmp(setting, "off") == 0)) { - alog("No longer sending log messages to a channel"); - if (ircd->join2msg) { - ircdproto->SendPart(findbot(s_GlobalNoticer), LogChannel, NULL); - } - logchan = 0; - notice_lang(s_OperServ, u, OPER_SET_LOGCHAN_OFF); - } else { - notice_lang(s_OperServ, u, OPER_SET_LOGCHAN_ERROR); - } - /** - * Allow the user to turn super admin on/off + } else if (stricmp(option, "LOGCHAN") == 0) { + /* Unlike the other SET commands where only stricmp is necessary, + * we also have to ensure that LogChannel is defined or we can't + * send to it. + * + * -jester + */ + if (LogChannel && (stricmp(setting, "on") == 0)) { + if (ircd->join2msg) { + c = findchan(LogChannel); + ircdproto->SendJoin(findbot(s_GlobalNoticer), LogChannel, c ? c->creation_time : time(NULL)); + } + logchan = 1; + alog("Now sending log messages to %s", LogChannel); + notice_lang(s_OperServ, u, OPER_SET_LOGCHAN_ON, LogChannel); + } else if (LogChannel && (stricmp(setting, "off") == 0)) { + alog("No longer sending log messages to a channel"); + if (ircd->join2msg) { + ircdproto->SendPart(findbot(s_GlobalNoticer), LogChannel, NULL); + } + logchan = 0; + notice_lang(s_OperServ, u, OPER_SET_LOGCHAN_OFF); + } else { + notice_lang(s_OperServ, u, OPER_SET_LOGCHAN_ERROR); + } + /** + * Allow the user to turn super admin on/off * * Rob - **/ - } else if (stricmp(option, "SUPERADMIN") == 0) { - if (!SuperAdmin) { - notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_NOT_ENABLED); - } else if (stricmp(setting, "on") == 0) { - u->isSuperAdmin = 1; - notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ON); - alog("%s: %s is a SuperAdmin ", s_OperServ, u->nick); - ircdproto->SendGlobops(s_OperServ, - getstring2(NULL, OPER_SUPER_ADMIN_WALL_ON), - u->nick); - } else if (stricmp(setting, "off") == 0) { - u->isSuperAdmin = 0; - notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_OFF); - alog("%s: %s is no longer a SuperAdmin", s_OperServ, u->nick); - ircdproto->SendGlobops(s_OperServ, - getstring2(NULL, OPER_SUPER_ADMIN_WALL_OFF), - u->nick); - } else { - notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_SYNTAX); - } - } else if (stricmp(option, "DEBUG") == 0) { - if (stricmp(setting, "on") == 0) { - debug = 1; - alog("Debug mode activated"); - notice_lang(s_OperServ, u, OPER_SET_DEBUG_ON); - } else if (stricmp(setting, "off") == 0 || - (*setting == '0' && atoi(setting) == 0)) { - alog("Debug mode deactivated"); - debug = 0; - notice_lang(s_OperServ, u, OPER_SET_DEBUG_OFF); - } else if (isdigit(*setting) && atoi(setting) > 0) { - debug = atoi(setting); - alog("Debug mode activated (level %d)", debug); - notice_lang(s_OperServ, u, OPER_SET_DEBUG_LEVEL, debug); - } else { - notice_lang(s_OperServ, u, OPER_SET_DEBUG_ERROR); - } + **/ + } else if (stricmp(option, "SUPERADMIN") == 0) { + if (!SuperAdmin) { + notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_NOT_ENABLED); + } else if (stricmp(setting, "on") == 0) { + u->isSuperAdmin = 1; + notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ON); + alog("%s: %s is a SuperAdmin ", s_OperServ, u->nick); + ircdproto->SendGlobops(s_OperServ, + getstring2(NULL, OPER_SUPER_ADMIN_WALL_ON), + u->nick); + } else if (stricmp(setting, "off") == 0) { + u->isSuperAdmin = 0; + notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_OFF); + alog("%s: %s is no longer a SuperAdmin", s_OperServ, u->nick); + ircdproto->SendGlobops(s_OperServ, + getstring2(NULL, OPER_SUPER_ADMIN_WALL_OFF), + u->nick); + } else { + notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_SYNTAX); + } + } else if (stricmp(option, "DEBUG") == 0) { + if (stricmp(setting, "on") == 0) { + debug = 1; + alog("Debug mode activated"); + notice_lang(s_OperServ, u, OPER_SET_DEBUG_ON); + } else if (stricmp(setting, "off") == 0 || + (*setting == '0' && atoi(setting) == 0)) { + alog("Debug mode deactivated"); + debug = 0; + notice_lang(s_OperServ, u, OPER_SET_DEBUG_OFF); + } else if (isdigit(*setting) && atoi(setting) > 0) { + debug = atoi(setting); + alog("Debug mode activated (level %d)", debug); + notice_lang(s_OperServ, u, OPER_SET_DEBUG_LEVEL, debug); + } else { + notice_lang(s_OperServ, u, OPER_SET_DEBUG_ERROR); + } - } else if (stricmp(option, "NOEXPIRE") == 0) { - if (stricmp(setting, "ON") == 0) { - noexpire = 1; - alog("No expire mode activated"); - notice_lang(s_OperServ, u, OPER_SET_NOEXPIRE_ON); - } else if (stricmp(setting, "OFF") == 0) { - noexpire = 0; - alog("No expire mode deactivated"); - notice_lang(s_OperServ, u, OPER_SET_NOEXPIRE_OFF); - } else { - notice_lang(s_OperServ, u, OPER_SET_NOEXPIRE_ERROR); - } - } else { - notice_lang(s_OperServ, u, OPER_SET_UNKNOWN_OPTION, option); - } - return MOD_CONT; + } else if (stricmp(option, "NOEXPIRE") == 0) { + if (stricmp(setting, "ON") == 0) { + noexpire = 1; + alog("No expire mode activated"); + notice_lang(s_OperServ, u, OPER_SET_NOEXPIRE_ON); + } else if (stricmp(setting, "OFF") == 0) { + noexpire = 0; + alog("No expire mode deactivated"); + notice_lang(s_OperServ, u, OPER_SET_NOEXPIRE_OFF); + } else { + notice_lang(s_OperServ, u, OPER_SET_NOEXPIRE_ERROR); + } + } else { + notice_lang(s_OperServ, u, OPER_SET_UNKNOWN_OPTION, option); + } + return MOD_CONT; } MODULE_INIT("os_set", OSSet) diff --git a/src/core/os_sgline.c b/src/core/os_sgline.c index 0cd6c10e9..49aa459fe 100644 --- a/src/core/os_sgline.c +++ b/src/core/os_sgline.c @@ -16,10 +16,10 @@ #include "module.h" int sgline_view_callback(SList * slist, int number, void *item, - va_list args); + va_list args); int sgline_view(int number, SXLine * sx, User * u, int *sent_header); int sgline_list_callback(SList * slist, int number, void *item, - va_list args); + va_list args); int sgline_list(int number, SXLine * sx, User * u, int *sent_header); int do_sgline(User * u); @@ -54,9 +54,9 @@ class OSSGLine : public Module **/ void myOperServHelp(User * u) { - if (is_services_oper(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_SGLINE); - } + if (is_services_oper(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_SGLINE); + } } /** @@ -66,43 +66,43 @@ void myOperServHelp(User * u) **/ int do_sgline(User * u) { - char *cmd = strtok(NULL, " "); - - if (!cmd) - cmd = ""; - - if (!stricmp(cmd, "ADD")) { - int deleted = 0; - char *expiry, *mask, *reason; - time_t expires; - - mask = strtok(NULL, ":"); - if (mask && *mask == '+') { - expiry = mask; - mask = strchr(expiry, ' '); - if (mask) { - *mask = 0; - mask++; - } - } else { - expiry = NULL; - } - - expires = expiry ? dotime(expiry) : SGLineExpiry; - /* If the expiry given does not contain a final letter, it's in days, - * said the doc. Ah well. - */ - if (expiry && isdigit(expiry[strlen(expiry) - 1])) - expires *= 86400; - /* Do not allow less than a minute expiry time */ - if (expires != 0 && expires < 60) { - notice_lang(s_OperServ, u, BAD_EXPIRY_TIME); - return MOD_CONT; - } else if (expires > 0) { - expires += time(NULL); - } - - if (mask && (reason = strtok(NULL, ""))) { + char *cmd = strtok(NULL, " "); + + if (!cmd) + cmd = ""; + + if (!stricmp(cmd, "ADD")) { + int deleted = 0; + char *expiry, *mask, *reason; + time_t expires; + + mask = strtok(NULL, ":"); + if (mask && *mask == '+') { + expiry = mask; + mask = strchr(expiry, ' '); + if (mask) { + *mask = 0; + mask++; + } + } else { + expiry = NULL; + } + + expires = expiry ? dotime(expiry) : SGLineExpiry; + /* If the expiry given does not contain a final letter, it's in days, + * said the doc. Ah well. + */ + if (expiry && isdigit(expiry[strlen(expiry) - 1])) + expires *= 86400; + /* Do not allow less than a minute expiry time */ + if (expires != 0 && expires < 60) { + notice_lang(s_OperServ, u, BAD_EXPIRY_TIME); + return MOD_CONT; + } else if (expires > 0) { + expires += time(NULL); + } + + if (mask && (reason = strtok(NULL, ""))) { /* Clean up the last character of the mask if it is a space * See bug #761 */ @@ -110,243 +110,243 @@ int do_sgline(User * u) if (mask[masklen - 1] == ' ') mask[masklen - 1] = '\0'; - /* We first do some sanity check on the proposed mask. */ - - if (mask && strspn(mask, "*?") == strlen(mask)) { - notice_lang(s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask); - return MOD_CONT; - } - - deleted = add_sgline(u, mask, u->nick, expires, reason); - if (deleted < 0) - return MOD_CONT; - else if (deleted) - notice_lang(s_OperServ, u, OPER_SGLINE_DELETED_SEVERAL, - deleted); - notice_lang(s_OperServ, u, OPER_SGLINE_ADDED, mask); - - if (WallOSSGLine) { - char buf[128]; - - if (!expires) { - strcpy(buf, "does not expire"); - } else { - int wall_expiry = expires - time(NULL); - char *s = NULL; - - if (wall_expiry >= 86400) { - wall_expiry /= 86400; - s = "day"; - } else if (wall_expiry >= 3600) { - wall_expiry /= 3600; - s = "hour"; - } else if (wall_expiry >= 60) { - wall_expiry /= 60; - s = "minute"; - } - - snprintf(buf, sizeof(buf), "expires in %d %s%s", - wall_expiry, s, - (wall_expiry == 1) ? "" : "s"); - } - - ircdproto->SendGlobops(s_OperServ, - "%s added an SGLINE for %s (%s)", u->nick, - mask, buf); - } - - if (readonly) - notice_lang(s_OperServ, u, READ_ONLY_MODE); - - } else { - syntax_error(s_OperServ, u, "SGLINE", OPER_SGLINE_SYNTAX); - } - - } else if (!stricmp(cmd, "DEL")) { - - char *mask; - int res = 0; - - mask = strtok(NULL, ""); - - if (!mask) { - syntax_error(s_OperServ, u, "SGLINE", OPER_SGLINE_SYNTAX); - return MOD_CONT; - } - - if (sglines.count == 0) { - notice_lang(s_OperServ, u, OPER_SGLINE_LIST_EMPTY); - return MOD_CONT; - } - - if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) { - /* Deleting a range */ - res = slist_delete_range(&sglines, mask, NULL); - if (res == 0) { - notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH); - return MOD_CONT; - } else if (res == 1) { - notice_lang(s_OperServ, u, OPER_SGLINE_DELETED_ONE); - } else { - notice_lang(s_OperServ, u, OPER_SGLINE_DELETED_SEVERAL, - res); - } - } else { - if ((res = slist_indexof(&sglines, mask)) == -1) { - notice_lang(s_OperServ, u, OPER_SGLINE_NOT_FOUND, mask); - return MOD_CONT; - } - - slist_delete(&sglines, res); - notice_lang(s_OperServ, u, OPER_SGLINE_DELETED, mask); - } - - if (readonly) - notice_lang(s_OperServ, u, READ_ONLY_MODE); - - } else if (!stricmp(cmd, "LIST")) { - char *mask; - int res, sent_header = 0; - - if (sglines.count == 0) { - notice_lang(s_OperServ, u, OPER_SGLINE_LIST_EMPTY); - return MOD_CONT; - } - - mask = strtok(NULL, ""); - - if (!mask || (isdigit(*mask) - && strspn(mask, "1234567890,-") == strlen(mask))) { - res = - slist_enum(&sglines, mask, &sgline_list_callback, u, - &sent_header); - if (res == 0) { - notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH); - return MOD_CONT; - } - } else { - int i; - char *amask; - - for (i = 0; i < sglines.count; i++) { - amask = ((SXLine *) sglines.list[i])->mask; - if (!stricmp(mask, amask) - || match_wild_nocase(mask, amask)) - sgline_list(i + 1, (SXLine *)sglines.list[i], u, &sent_header); - } - - if (!sent_header) - notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH); - else { - notice_lang(s_OperServ, u, END_OF_ANY_LIST, "SGLine"); - } - } - } else if (!stricmp(cmd, "VIEW")) { - char *mask; - int res, sent_header = 0; - - if (sglines.count == 0) { - notice_lang(s_OperServ, u, OPER_SGLINE_LIST_EMPTY); - return MOD_CONT; - } - - mask = strtok(NULL, ""); - - if (!mask || (isdigit(*mask) - && strspn(mask, "1234567890,-") == strlen(mask))) { - res = - slist_enum(&sglines, mask, &sgline_view_callback, u, - &sent_header); - if (res == 0) { - notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH); - return MOD_CONT; - } - } else { - int i; - char *amask; - - for (i = 0; i < sglines.count; i++) { - amask = ((SXLine *) sglines.list[i])->mask; - if (!stricmp(mask, amask) - || match_wild_nocase(mask, amask)) - sgline_view(i + 1, (SXLine *)sglines.list[i], u, &sent_header); - } - - if (!sent_header) - notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH); - } - } else if (!stricmp(cmd, "CLEAR")) { - slist_clear(&sglines, 1); - notice_lang(s_OperServ, u, OPER_SGLINE_CLEAR); - } else { - syntax_error(s_OperServ, u, "SGLINE", OPER_SGLINE_SYNTAX); - } - return MOD_CONT; + /* We first do some sanity check on the proposed mask. */ + + if (mask && strspn(mask, "*?") == strlen(mask)) { + notice_lang(s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask); + return MOD_CONT; + } + + deleted = add_sgline(u, mask, u->nick, expires, reason); + if (deleted < 0) + return MOD_CONT; + else if (deleted) + notice_lang(s_OperServ, u, OPER_SGLINE_DELETED_SEVERAL, + deleted); + notice_lang(s_OperServ, u, OPER_SGLINE_ADDED, mask); + + if (WallOSSGLine) { + char buf[128]; + + if (!expires) { + strcpy(buf, "does not expire"); + } else { + int wall_expiry = expires - time(NULL); + char *s = NULL; + + if (wall_expiry >= 86400) { + wall_expiry /= 86400; + s = "day"; + } else if (wall_expiry >= 3600) { + wall_expiry /= 3600; + s = "hour"; + } else if (wall_expiry >= 60) { + wall_expiry /= 60; + s = "minute"; + } + + snprintf(buf, sizeof(buf), "expires in %d %s%s", + wall_expiry, s, + (wall_expiry == 1) ? "" : "s"); + } + + ircdproto->SendGlobops(s_OperServ, + "%s added an SGLINE for %s (%s)", u->nick, + mask, buf); + } + + if (readonly) + notice_lang(s_OperServ, u, READ_ONLY_MODE); + + } else { + syntax_error(s_OperServ, u, "SGLINE", OPER_SGLINE_SYNTAX); + } + + } else if (!stricmp(cmd, "DEL")) { + + char *mask; + int res = 0; + + mask = strtok(NULL, ""); + + if (!mask) { + syntax_error(s_OperServ, u, "SGLINE", OPER_SGLINE_SYNTAX); + return MOD_CONT; + } + + if (sglines.count == 0) { + notice_lang(s_OperServ, u, OPER_SGLINE_LIST_EMPTY); + return MOD_CONT; + } + + if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) { + /* Deleting a range */ + res = slist_delete_range(&sglines, mask, NULL); + if (res == 0) { + notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH); + return MOD_CONT; + } else if (res == 1) { + notice_lang(s_OperServ, u, OPER_SGLINE_DELETED_ONE); + } else { + notice_lang(s_OperServ, u, OPER_SGLINE_DELETED_SEVERAL, + res); + } + } else { + if ((res = slist_indexof(&sglines, mask)) == -1) { + notice_lang(s_OperServ, u, OPER_SGLINE_NOT_FOUND, mask); + return MOD_CONT; + } + + slist_delete(&sglines, res); + notice_lang(s_OperServ, u, OPER_SGLINE_DELETED, mask); + } + + if (readonly) + notice_lang(s_OperServ, u, READ_ONLY_MODE); + + } else if (!stricmp(cmd, "LIST")) { + char *mask; + int res, sent_header = 0; + + if (sglines.count == 0) { + notice_lang(s_OperServ, u, OPER_SGLINE_LIST_EMPTY); + return MOD_CONT; + } + + mask = strtok(NULL, ""); + + if (!mask || (isdigit(*mask) + && strspn(mask, "1234567890,-") == strlen(mask))) { + res = + slist_enum(&sglines, mask, &sgline_list_callback, u, + &sent_header); + if (res == 0) { + notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH); + return MOD_CONT; + } + } else { + int i; + char *amask; + + for (i = 0; i < sglines.count; i++) { + amask = ((SXLine *) sglines.list[i])->mask; + if (!stricmp(mask, amask) + || match_wild_nocase(mask, amask)) + sgline_list(i + 1, (SXLine *)sglines.list[i], u, &sent_header); + } + + if (!sent_header) + notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH); + else { + notice_lang(s_OperServ, u, END_OF_ANY_LIST, "SGLine"); + } + } + } else if (!stricmp(cmd, "VIEW")) { + char *mask; + int res, sent_header = 0; + + if (sglines.count == 0) { + notice_lang(s_OperServ, u, OPER_SGLINE_LIST_EMPTY); + return MOD_CONT; + } + + mask = strtok(NULL, ""); + + if (!mask || (isdigit(*mask) + && strspn(mask, "1234567890,-") == strlen(mask))) { + res = + slist_enum(&sglines, mask, &sgline_view_callback, u, + &sent_header); + if (res == 0) { + notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH); + return MOD_CONT; + } + } else { + int i; + char *amask; + + for (i = 0; i < sglines.count; i++) { + amask = ((SXLine *) sglines.list[i])->mask; + if (!stricmp(mask, amask) + || match_wild_nocase(mask, amask)) + sgline_view(i + 1, (SXLine *)sglines.list[i], u, &sent_header); + } + + if (!sent_header) + notice_lang(s_OperServ, u, OPER_SGLINE_NO_MATCH); + } + } else if (!stricmp(cmd, "CLEAR")) { + slist_clear(&sglines, 1); + notice_lang(s_OperServ, u, OPER_SGLINE_CLEAR); + } else { + syntax_error(s_OperServ, u, "SGLINE", OPER_SGLINE_SYNTAX); + } + return MOD_CONT; } /* Lists an SGLINE entry, prefixing it with the header if needed */ int sgline_view(int number, SXLine * sx, User * u, int *sent_header) { - char timebuf[32], expirebuf[256]; - struct tm tm; + char timebuf[32], expirebuf[256]; + struct tm tm; - if (!sx) - return 0; + if (!sx) + return 0; - if (!*sent_header) { - notice_lang(s_OperServ, u, OPER_SGLINE_VIEW_HEADER); - *sent_header = 1; - } + if (!*sent_header) { + notice_lang(s_OperServ, u, OPER_SGLINE_VIEW_HEADER); + *sent_header = 1; + } - tm = *localtime(&sx->seton); - strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_SHORT_DATE_FORMAT, - &tm); - expire_left(u->na, expirebuf, sizeof(expirebuf), sx->expires); - notice_lang(s_OperServ, u, OPER_SGLINE_VIEW_FORMAT, number, sx->mask, - sx->by, timebuf, expirebuf, sx->reason); + tm = *localtime(&sx->seton); + strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_SHORT_DATE_FORMAT, + &tm); + expire_left(u->na, expirebuf, sizeof(expirebuf), sx->expires); + notice_lang(s_OperServ, u, OPER_SGLINE_VIEW_FORMAT, number, sx->mask, + sx->by, timebuf, expirebuf, sx->reason); - return 1; + return 1; } /* Callback for enumeration purposes */ int sgline_view_callback(SList * slist, int number, void *item, - va_list args) + va_list args) { - User *u = va_arg(args, User *); - int *sent_header = va_arg(args, int *); + User *u = va_arg(args, User *); + int *sent_header = va_arg(args, int *); - return sgline_view(number, (SXLine *)item, u, sent_header); + return sgline_view(number, (SXLine *)item, u, sent_header); } /* Lists an SGLINE entry, prefixing it with the header if needed */ int sgline_list(int number, SXLine * sx, User * u, int *sent_header) { - if (!sx) - return 0; + if (!sx) + return 0; - if (!*sent_header) { - notice_lang(s_OperServ, u, OPER_SGLINE_LIST_HEADER); - *sent_header = 1; - } + if (!*sent_header) { + notice_lang(s_OperServ, u, OPER_SGLINE_LIST_HEADER); + *sent_header = 1; + } - notice_lang(s_OperServ, u, OPER_SGLINE_LIST_FORMAT, number, sx->mask, - sx->reason); + notice_lang(s_OperServ, u, OPER_SGLINE_LIST_FORMAT, number, sx->mask, + sx->reason); - return 1; + return 1; } /* Callback for enumeration purposes */ int sgline_list_callback(SList * slist, int number, void *item, - va_list args) + va_list args) { - User *u = va_arg(args, User *); - int *sent_header = va_arg(args, int *); + User *u = va_arg(args, User *); + int *sent_header = va_arg(args, int *); - return sgline_list(number, (SXLine *)item, u, sent_header); + return sgline_list(number, (SXLine *)item, u, sent_header); } MODULE_INIT("os_sgline", OSSGLine) diff --git a/src/core/os_shutdown.c b/src/core/os_shutdown.c index a981d1555..03099e410 100644 --- a/src/core/os_shutdown.c +++ b/src/core/os_shutdown.c @@ -43,9 +43,9 @@ class OSShutdown : public Module **/ void myOperServHelp(User * u) { - if (is_services_root(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_SHUTDOWN); - } + if (is_services_root(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_SHUTDOWN); + } } /** @@ -55,18 +55,18 @@ void myOperServHelp(User * u) **/ int do_shutdown(User * u) { - quitmsg = (char *)calloc(32 + strlen(u->nick), 1); - if (!quitmsg) - quitmsg = "SHUTDOWN command received, but out of memory!"; - else - sprintf((char *)quitmsg, /* XXX */ "SHUTDOWN command received from %s", u->nick); + quitmsg = (char *)calloc(32 + strlen(u->nick), 1); + if (!quitmsg) + quitmsg = "SHUTDOWN command received, but out of memory!"; + else + sprintf((char *)quitmsg, /* XXX */ "SHUTDOWN command received from %s", u->nick); - if (GlobalOnCycle) { - oper_global(NULL, "%s", GlobalOnCycleMessage); - } - save_data = 1; - delayed_quit = 1; - return MOD_CONT; + if (GlobalOnCycle) { + oper_global(NULL, "%s", GlobalOnCycleMessage); + } + save_data = 1; + delayed_quit = 1; + return MOD_CONT; } MODULE_INIT("os_shutdown", OSShutdown) diff --git a/src/core/os_sqline.c b/src/core/os_sqline.c index f6cad0d78..072c224f8 100644 --- a/src/core/os_sqline.c +++ b/src/core/os_sqline.c @@ -17,10 +17,10 @@ int do_sqline(User * u); int sqline_view_callback(SList * slist, int number, void *item, - va_list args); + va_list args); int sqline_view(int number, SXLine * sx, User * u, int *sent_header); int sqline_list_callback(SList * slist, int number, void *item, - va_list args); + va_list args); int sqline_list(int number, SXLine * sx, User * u, int *sent_header); void myOperServHelp(User * u); @@ -53,9 +53,9 @@ class OSSQLine : public Module **/ void myOperServHelp(User * u) { - if (is_services_oper(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_SQLINE); - } + if (is_services_oper(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_SQLINE); + } } /** @@ -65,281 +65,281 @@ void myOperServHelp(User * u) **/ int do_sqline(User * u) { - char *cmd = strtok(NULL, " "); - - if (!cmd) - cmd = ""; - - if (!stricmp(cmd, "ADD")) { - int deleted = 0; - char *expiry, *mask, *reason; - time_t expires; - - mask = strtok(NULL, " "); - if (mask && *mask == '+') { - expiry = mask; - mask = strtok(NULL, " "); - } else { - expiry = NULL; - } - - expires = expiry ? dotime(expiry) : SQLineExpiry; - /* If the expiry given does not contain a final letter, it's in days, - * said the doc. Ah well. - */ - if (expiry && isdigit(expiry[strlen(expiry) - 1])) - expires *= 86400; - /* Do not allow less than a minute expiry time */ - if (expires != 0 && expires < 60) { - notice_lang(s_OperServ, u, BAD_EXPIRY_TIME); - return MOD_CONT; - } else if (expires > 0) { - expires += time(NULL); - } - - if (mask && (reason = strtok(NULL, ""))) { - - /* We first do some sanity check on the proposed mask. */ - if (strspn(mask, "*") == strlen(mask)) { - notice_lang(s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask); - return MOD_CONT; - } - - /* Channel SQLINEs are only supported on Bahamut servers */ - if (*mask == '#' && !ircd->chansqline) { - notice_lang(s_OperServ, u, - OPER_SQLINE_CHANNELS_UNSUPPORTED); - return MOD_CONT; - } - - deleted = add_sqline(u, mask, u->nick, expires, reason); - if (deleted < 0) - return MOD_CONT; - else if (deleted) - notice_lang(s_OperServ, u, OPER_SQLINE_DELETED_SEVERAL, - deleted); - notice_lang(s_OperServ, u, OPER_SQLINE_ADDED, mask); - - if (WallOSSQLine) { - char buf[128]; - - if (!expires) { - strcpy(buf, "does not expire"); - } else { - int wall_expiry = expires - time(NULL); - char *s = NULL; - - if (wall_expiry >= 86400) { - wall_expiry /= 86400; - s = "day"; - } else if (wall_expiry >= 3600) { - wall_expiry /= 3600; - s = "hour"; - } else if (wall_expiry >= 60) { - wall_expiry /= 60; - s = "minute"; - } - - snprintf(buf, sizeof(buf), "expires in %d %s%s", - wall_expiry, s, - (wall_expiry == 1) ? "" : "s"); - } - - ircdproto->SendGlobops(s_OperServ, - "%s added an SQLINE for %s (%s)", u->nick, - mask, buf); - } - - if (readonly) - notice_lang(s_OperServ, u, READ_ONLY_MODE); - - } else { - syntax_error(s_OperServ, u, "SQLINE", OPER_SQLINE_SYNTAX); - } - - } else if (!stricmp(cmd, "DEL")) { - - char *mask; - int res = 0; - - mask = strtok(NULL, ""); - - if (!mask) { - syntax_error(s_OperServ, u, "SQLINE", OPER_SQLINE_SYNTAX); - return MOD_CONT; - } - - if (sqlines.count == 0) { - notice_lang(s_OperServ, u, OPER_SQLINE_LIST_EMPTY); - return MOD_CONT; - } - - if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) { - /* Deleting a range */ - res = slist_delete_range(&sqlines, mask, NULL); - if (res == 0) { - notice_lang(s_OperServ, u, OPER_SQLINE_NO_MATCH); - return MOD_CONT; - } else if (res == 1) { - notice_lang(s_OperServ, u, OPER_SQLINE_DELETED_ONE); - } else { - notice_lang(s_OperServ, u, OPER_SQLINE_DELETED_SEVERAL, - res); - } - } else { - if ((res = slist_indexof(&sqlines, mask)) == -1) { - notice_lang(s_OperServ, u, OPER_SQLINE_NOT_FOUND, mask); - return MOD_CONT; - } - - slist_delete(&sqlines, res); - notice_lang(s_OperServ, u, OPER_SQLINE_DELETED, mask); - } - - if (readonly) - notice_lang(s_OperServ, u, READ_ONLY_MODE); - - } else if (!stricmp(cmd, "LIST")) { - char *mask; - int res, sent_header = 0; - - if (sqlines.count == 0) { - notice_lang(s_OperServ, u, OPER_SQLINE_LIST_EMPTY); - return MOD_CONT; - } - - mask = strtok(NULL, ""); - - if (!mask || (isdigit(*mask) - && strspn(mask, "1234567890,-") == strlen(mask))) { - res = - slist_enum(&sqlines, mask, &sqline_list_callback, u, - &sent_header); - if (res == 0) { - notice_lang(s_OperServ, u, OPER_SQLINE_NO_MATCH); - return MOD_CONT; - } - } else { - int i; - char *amask; - - for (i = 0; i < sqlines.count; i++) { - amask = ((SXLine *) sqlines.list[i])->mask; - if (!stricmp(mask, amask) - || match_wild_nocase(mask, amask)) - sqline_list(i + 1, (SXLine *)sqlines.list[i], u, &sent_header); - } - - if (!sent_header) - notice_lang(s_OperServ, u, OPER_SQLINE_NO_MATCH); - else { - notice_lang(s_OperServ, u, END_OF_ANY_LIST, "SQLine"); - } - } - } else if (!stricmp(cmd, "VIEW")) { - char *mask; - int res, sent_header = 0; - - if (sqlines.count == 0) { - notice_lang(s_OperServ, u, OPER_SQLINE_LIST_EMPTY); - return MOD_CONT; - } - - mask = strtok(NULL, ""); - - if (!mask || (isdigit(*mask) - && strspn(mask, "1234567890,-") == strlen(mask))) { - res = - slist_enum(&sqlines, mask, &sqline_view_callback, u, - &sent_header); - if (res == 0) { - notice_lang(s_OperServ, u, OPER_SQLINE_NO_MATCH); - return MOD_CONT; - } - } else { - int i; - char *amask; - - for (i = 0; i < sqlines.count; i++) { - amask = ((SXLine *) sqlines.list[i])->mask; - if (!stricmp(mask, amask) - || match_wild_nocase(mask, amask)) - sqline_view(i + 1, (SXLine *)sqlines.list[i], u, &sent_header); - } - - if (!sent_header) - notice_lang(s_OperServ, u, OPER_SQLINE_NO_MATCH); - } - } else if (!stricmp(cmd, "CLEAR")) { - slist_clear(&sqlines, 1); - notice_lang(s_OperServ, u, OPER_SQLINE_CLEAR); - } else { - syntax_error(s_OperServ, u, "SQLINE", OPER_SQLINE_SYNTAX); - } - return MOD_CONT; + char *cmd = strtok(NULL, " "); + + if (!cmd) + cmd = ""; + + if (!stricmp(cmd, "ADD")) { + int deleted = 0; + char *expiry, *mask, *reason; + time_t expires; + + mask = strtok(NULL, " "); + if (mask && *mask == '+') { + expiry = mask; + mask = strtok(NULL, " "); + } else { + expiry = NULL; + } + + expires = expiry ? dotime(expiry) : SQLineExpiry; + /* If the expiry given does not contain a final letter, it's in days, + * said the doc. Ah well. + */ + if (expiry && isdigit(expiry[strlen(expiry) - 1])) + expires *= 86400; + /* Do not allow less than a minute expiry time */ + if (expires != 0 && expires < 60) { + notice_lang(s_OperServ, u, BAD_EXPIRY_TIME); + return MOD_CONT; + } else if (expires > 0) { + expires += time(NULL); + } + + if (mask && (reason = strtok(NULL, ""))) { + + /* We first do some sanity check on the proposed mask. */ + if (strspn(mask, "*") == strlen(mask)) { + notice_lang(s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask); + return MOD_CONT; + } + + /* Channel SQLINEs are only supported on Bahamut servers */ + if (*mask == '#' && !ircd->chansqline) { + notice_lang(s_OperServ, u, + OPER_SQLINE_CHANNELS_UNSUPPORTED); + return MOD_CONT; + } + + deleted = add_sqline(u, mask, u->nick, expires, reason); + if (deleted < 0) + return MOD_CONT; + else if (deleted) + notice_lang(s_OperServ, u, OPER_SQLINE_DELETED_SEVERAL, + deleted); + notice_lang(s_OperServ, u, OPER_SQLINE_ADDED, mask); + + if (WallOSSQLine) { + char buf[128]; + + if (!expires) { + strcpy(buf, "does not expire"); + } else { + int wall_expiry = expires - time(NULL); + char *s = NULL; + + if (wall_expiry >= 86400) { + wall_expiry /= 86400; + s = "day"; + } else if (wall_expiry >= 3600) { + wall_expiry /= 3600; + s = "hour"; + } else if (wall_expiry >= 60) { + wall_expiry /= 60; + s = "minute"; + } + + snprintf(buf, sizeof(buf), "expires in %d %s%s", + wall_expiry, s, + (wall_expiry == 1) ? "" : "s"); + } + + ircdproto->SendGlobops(s_OperServ, + "%s added an SQLINE for %s (%s)", u->nick, + mask, buf); + } + + if (readonly) + notice_lang(s_OperServ, u, READ_ONLY_MODE); + + } else { + syntax_error(s_OperServ, u, "SQLINE", OPER_SQLINE_SYNTAX); + } + + } else if (!stricmp(cmd, "DEL")) { + + char *mask; + int res = 0; + + mask = strtok(NULL, ""); + + if (!mask) { + syntax_error(s_OperServ, u, "SQLINE", OPER_SQLINE_SYNTAX); + return MOD_CONT; + } + + if (sqlines.count == 0) { + notice_lang(s_OperServ, u, OPER_SQLINE_LIST_EMPTY); + return MOD_CONT; + } + + if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) { + /* Deleting a range */ + res = slist_delete_range(&sqlines, mask, NULL); + if (res == 0) { + notice_lang(s_OperServ, u, OPER_SQLINE_NO_MATCH); + return MOD_CONT; + } else if (res == 1) { + notice_lang(s_OperServ, u, OPER_SQLINE_DELETED_ONE); + } else { + notice_lang(s_OperServ, u, OPER_SQLINE_DELETED_SEVERAL, + res); + } + } else { + if ((res = slist_indexof(&sqlines, mask)) == -1) { + notice_lang(s_OperServ, u, OPER_SQLINE_NOT_FOUND, mask); + return MOD_CONT; + } + + slist_delete(&sqlines, res); + notice_lang(s_OperServ, u, OPER_SQLINE_DELETED, mask); + } + + if (readonly) + notice_lang(s_OperServ, u, READ_ONLY_MODE); + + } else if (!stricmp(cmd, "LIST")) { + char *mask; + int res, sent_header = 0; + + if (sqlines.count == 0) { + notice_lang(s_OperServ, u, OPER_SQLINE_LIST_EMPTY); + return MOD_CONT; + } + + mask = strtok(NULL, ""); + + if (!mask || (isdigit(*mask) + && strspn(mask, "1234567890,-") == strlen(mask))) { + res = + slist_enum(&sqlines, mask, &sqline_list_callback, u, + &sent_header); + if (res == 0) { + notice_lang(s_OperServ, u, OPER_SQLINE_NO_MATCH); + return MOD_CONT; + } + } else { + int i; + char *amask; + + for (i = 0; i < sqlines.count; i++) { + amask = ((SXLine *) sqlines.list[i])->mask; + if (!stricmp(mask, amask) + || match_wild_nocase(mask, amask)) + sqline_list(i + 1, (SXLine *)sqlines.list[i], u, &sent_header); + } + + if (!sent_header) + notice_lang(s_OperServ, u, OPER_SQLINE_NO_MATCH); + else { + notice_lang(s_OperServ, u, END_OF_ANY_LIST, "SQLine"); + } + } + } else if (!stricmp(cmd, "VIEW")) { + char *mask; + int res, sent_header = 0; + + if (sqlines.count == 0) { + notice_lang(s_OperServ, u, OPER_SQLINE_LIST_EMPTY); + return MOD_CONT; + } + + mask = strtok(NULL, ""); + + if (!mask || (isdigit(*mask) + && strspn(mask, "1234567890,-") == strlen(mask))) { + res = + slist_enum(&sqlines, mask, &sqline_view_callback, u, + &sent_header); + if (res == 0) { + notice_lang(s_OperServ, u, OPER_SQLINE_NO_MATCH); + return MOD_CONT; + } + } else { + int i; + char *amask; + + for (i = 0; i < sqlines.count; i++) { + amask = ((SXLine *) sqlines.list[i])->mask; + if (!stricmp(mask, amask) + || match_wild_nocase(mask, amask)) + sqline_view(i + 1, (SXLine *)sqlines.list[i], u, &sent_header); + } + + if (!sent_header) + notice_lang(s_OperServ, u, OPER_SQLINE_NO_MATCH); + } + } else if (!stricmp(cmd, "CLEAR")) { + slist_clear(&sqlines, 1); + notice_lang(s_OperServ, u, OPER_SQLINE_CLEAR); + } else { + syntax_error(s_OperServ, u, "SQLINE", OPER_SQLINE_SYNTAX); + } + return MOD_CONT; } int sqline_view(int number, SXLine * sx, User * u, int *sent_header) { - char timebuf[32], expirebuf[256]; - struct tm tm; + char timebuf[32], expirebuf[256]; + struct tm tm; - if (!sx) - return 0; + if (!sx) + return 0; - if (!*sent_header) { - notice_lang(s_OperServ, u, OPER_SQLINE_VIEW_HEADER); - *sent_header = 1; - } + if (!*sent_header) { + notice_lang(s_OperServ, u, OPER_SQLINE_VIEW_HEADER); + *sent_header = 1; + } - tm = *localtime(&sx->seton); - strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_SHORT_DATE_FORMAT, - &tm); - expire_left(u->na, expirebuf, sizeof(expirebuf), sx->expires); - notice_lang(s_OperServ, u, OPER_SQLINE_VIEW_FORMAT, number, sx->mask, - sx->by, timebuf, expirebuf, sx->reason); + tm = *localtime(&sx->seton); + strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_SHORT_DATE_FORMAT, + &tm); + expire_left(u->na, expirebuf, sizeof(expirebuf), sx->expires); + notice_lang(s_OperServ, u, OPER_SQLINE_VIEW_FORMAT, number, sx->mask, + sx->by, timebuf, expirebuf, sx->reason); - return 1; + return 1; } /* Callback for enumeration purposes */ int sqline_view_callback(SList * slist, int number, void *item, - va_list args) + va_list args) { - User *u = va_arg(args, User *); - int *sent_header = va_arg(args, int *); + User *u = va_arg(args, User *); + int *sent_header = va_arg(args, int *); - return sqline_view(number, (SXLine *)item, u, sent_header); + return sqline_view(number, (SXLine *)item, u, sent_header); } /* Lists an SQLINE entry, prefixing it with the header if needed */ int sqline_list(int number, SXLine * sx, User * u, int *sent_header) { - if (!sx) - return 0; + if (!sx) + return 0; - if (!*sent_header) { - notice_lang(s_OperServ, u, OPER_SQLINE_LIST_HEADER); - *sent_header = 1; - } + if (!*sent_header) { + notice_lang(s_OperServ, u, OPER_SQLINE_LIST_HEADER); + *sent_header = 1; + } - notice_lang(s_OperServ, u, OPER_SQLINE_LIST_FORMAT, number, sx->mask, - sx->reason); + notice_lang(s_OperServ, u, OPER_SQLINE_LIST_FORMAT, number, sx->mask, + sx->reason); - return 1; + return 1; } /* Callback for enumeration purposes */ int sqline_list_callback(SList * slist, int number, void *item, - va_list args) + va_list args) { - User *u = va_arg(args, User *); - int *sent_header = va_arg(args, int *); + User *u = va_arg(args, User *); + int *sent_header = va_arg(args, int *); - return sqline_list(number, (SXLine *)item, u, sent_header); + return sqline_list(number, (SXLine *)item, u, sent_header); } MODULE_INIT("os_sqline", OSSQLine) diff --git a/src/core/os_staff.c b/src/core/os_staff.c index fa29b2b7d..9e5b820b4 100644 --- a/src/core/os_staff.c +++ b/src/core/os_staff.c @@ -18,7 +18,7 @@ int do_staff(User * u); void myOperServHelp(User * u); int opers_list_callback(SList * slist, int number, void *item, - va_list args); + va_list args); int opers_list(int number, NickCore * nc, User * u, char *level); class OSStaff : public Module @@ -46,7 +46,7 @@ class OSStaff : public Module **/ void myOperServHelp(User * u) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_STAFF); + notice_lang(s_OperServ, u, OPER_HELP_CMD_STAFF); } /** @@ -56,53 +56,53 @@ void myOperServHelp(User * u) **/ int do_staff(User * u) { - int idx = 0; - User *au = NULL; - NickCore *nc; - NickAlias *na; - int found; - int i; - - notice_lang(s_OperServ, u, OPER_STAFF_LIST_HEADER); - slist_enum(&servopers, NULL, &opers_list_callback, u, "OPER"); - slist_enum(&servadmins, NULL, &opers_list_callback, u, "ADMN"); - - for (idx = 0; idx < RootNumber; idx++) { - found = 0; - if ((au = finduser(ServicesRoots[idx]))) { /* see if user is online */ - found = 1; - notice_lang(s_OperServ, u, OPER_STAFF_FORMAT, '*', "ROOT", - ServicesRoots[idx]); - } else if ((nc = findcore(ServicesRoots[idx]))) { - for (i = 0; i < nc->aliases.count; i++) { /* check all aliases */ - na = (NickAlias *)nc->aliases.list[i]; - if ((au = finduser(na->nick))) { /* see if user is online */ - found = 1; - notice_lang(s_OperServ, u, OPER_STAFF_AFORMAT, - '*', "ROOT", ServicesRoots[idx], na->nick); - } - } - } - - if (!found) - notice_lang(s_OperServ, u, OPER_STAFF_FORMAT, ' ', "ROOT", - ServicesRoots[idx]); - - } - notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Staff"); - return MOD_CONT; + int idx = 0; + User *au = NULL; + NickCore *nc; + NickAlias *na; + int found; + int i; + + notice_lang(s_OperServ, u, OPER_STAFF_LIST_HEADER); + slist_enum(&servopers, NULL, &opers_list_callback, u, "OPER"); + slist_enum(&servadmins, NULL, &opers_list_callback, u, "ADMN"); + + for (idx = 0; idx < RootNumber; idx++) { + found = 0; + if ((au = finduser(ServicesRoots[idx]))) { /* see if user is online */ + found = 1; + notice_lang(s_OperServ, u, OPER_STAFF_FORMAT, '*', "ROOT", + ServicesRoots[idx]); + } else if ((nc = findcore(ServicesRoots[idx]))) { + for (i = 0; i < nc->aliases.count; i++) { /* check all aliases */ + na = (NickAlias *)nc->aliases.list[i]; + if ((au = finduser(na->nick))) { /* see if user is online */ + found = 1; + notice_lang(s_OperServ, u, OPER_STAFF_AFORMAT, + '*', "ROOT", ServicesRoots[idx], na->nick); + } + } + } + + if (!found) + notice_lang(s_OperServ, u, OPER_STAFF_FORMAT, ' ', "ROOT", + ServicesRoots[idx]); + + } + notice_lang(s_OperServ, u, END_OF_ANY_LIST, "Staff"); + return MOD_CONT; } /** * Function for the enumerator to call **/ int opers_list_callback(SList * slist, int number, void *item, - va_list args) + va_list args) { - User *u = va_arg(args, User *); - char *level = va_arg(args, char *); + User *u = va_arg(args, User *); + char *level = va_arg(args, char *); - return opers_list(number, (NickCore *)item, u, level); + return opers_list(number, (NickCore *)item, u, level); } @@ -111,35 +111,35 @@ int opers_list_callback(SList * slist, int number, void *item, **/ int opers_list(int number, NickCore * nc, User * u, char *level) { - User *au = NULL; - NickAlias *na; - int found; - int i; - - if (!nc) - return 0; - - found = 0; - if ((au = finduser(nc->display))) { /* see if user is online */ - found = 1; - notice_lang(s_OperServ, u, OPER_STAFF_FORMAT, '*', level, - nc->display); - } else { - for (i = 0; i < nc->aliases.count; i++) { /* check all aliases */ - na = (NickAlias *)nc->aliases.list[i]; - if ((au = finduser(na->nick))) { /* see if user is online */ - found = 1; - notice_lang(s_OperServ, u, OPER_STAFF_AFORMAT, '*', level, - nc->display, na->nick); - } - } - } - - if (!found) - notice_lang(s_OperServ, u, OPER_STAFF_FORMAT, ' ', level, - nc->display); - - return 1; + User *au = NULL; + NickAlias *na; + int found; + int i; + + if (!nc) + return 0; + + found = 0; + if ((au = finduser(nc->display))) { /* see if user is online */ + found = 1; + notice_lang(s_OperServ, u, OPER_STAFF_FORMAT, '*', level, + nc->display); + } else { + for (i = 0; i < nc->aliases.count; i++) { /* check all aliases */ + na = (NickAlias *)nc->aliases.list[i]; + if ((au = finduser(na->nick))) { /* see if user is online */ + found = 1; + notice_lang(s_OperServ, u, OPER_STAFF_AFORMAT, '*', level, + nc->display, na->nick); + } + } + } + + if (!found) + notice_lang(s_OperServ, u, OPER_STAFF_FORMAT, ' ', level, + nc->display); + + return 1; } MODULE_INIT("os_staff", OSStaff) diff --git a/src/core/os_stats.c b/src/core/os_stats.c index dea85b770..35a0f03f7 100644 --- a/src/core/os_stats.c +++ b/src/core/os_stats.c @@ -48,7 +48,7 @@ class OSStats : public Module **/ void myOperServHelp(User * u) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_STATS); + notice_lang(s_OperServ, u, OPER_HELP_CMD_STATS); } /** @@ -58,16 +58,16 @@ void myOperServHelp(User * u) **/ int stats_count_servers(Server * s) { - int count = 0; + int count = 0; - while (s) { - count++; - if (s->links) - count += stats_count_servers(s->links); - s = s->next; - } + while (s) { + count++; + if (s->links) + count += stats_count_servers(s->links); + s = s->next; + } - return count; + return count; } /** @@ -77,365 +77,365 @@ int stats_count_servers(Server * s) **/ int do_stats(User * u) { - time_t uptime = time(NULL) - start_time; - char *extra = strtok(NULL, ""); - int days = uptime / 86400, hours = (uptime / 3600) % 24, - mins = (uptime / 60) % 60, secs = uptime % 60; - struct tm *tm; - char timebuf[64]; - char buf[512]; - int buflen; - int i; + time_t uptime = time(NULL) - start_time; + char *extra = strtok(NULL, ""); + int days = uptime / 86400, hours = (uptime / 3600) % 24, + mins = (uptime / 60) % 60, secs = uptime % 60; + struct tm *tm; + char timebuf[64]; + char buf[512]; + int buflen; + int i; - if (extra && stricmp(extra, "ALL") != 0) { - if (stricmp(extra, "AKILL") == 0) { - int timeout; - /* AKILLs */ - notice_lang(s_OperServ, u, OPER_STATS_AKILL_COUNT, - akills.count); - timeout = AutokillExpiry + 59; - if (timeout >= 172800) - notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_DAYS, - timeout / 86400); - else if (timeout >= 86400) - notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_DAY); - else if (timeout >= 7200) - notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_HOURS, - timeout / 3600); - else if (timeout >= 3600) - notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_HOUR); - else if (timeout >= 120) - notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_MINS, - timeout / 60); - else if (timeout >= 60) - notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_MIN); - else - notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_NONE); - if (ircd->sgline) { - /* SGLINEs */ - notice_lang(s_OperServ, u, OPER_STATS_SGLINE_COUNT, - sglines.count); - timeout = SGLineExpiry + 59; - if (timeout >= 172800) - notice_lang(s_OperServ, u, - OPER_STATS_SGLINE_EXPIRE_DAYS, - timeout / 86400); - else if (timeout >= 86400) - notice_lang(s_OperServ, u, - OPER_STATS_SGLINE_EXPIRE_DAY); - else if (timeout >= 7200) - notice_lang(s_OperServ, u, - OPER_STATS_SGLINE_EXPIRE_HOURS, - timeout / 3600); - else if (timeout >= 3600) - notice_lang(s_OperServ, u, - OPER_STATS_SGLINE_EXPIRE_HOUR); - else if (timeout >= 120) - notice_lang(s_OperServ, u, - OPER_STATS_SGLINE_EXPIRE_MINS, - timeout / 60); - else if (timeout >= 60) - notice_lang(s_OperServ, u, - OPER_STATS_SGLINE_EXPIRE_MIN); - else - notice_lang(s_OperServ, u, - OPER_STATS_SGLINE_EXPIRE_NONE); - } - if (ircd->sqline) { - /* SQLINEs */ - notice_lang(s_OperServ, u, OPER_STATS_SQLINE_COUNT, - sqlines.count); - timeout = SQLineExpiry + 59; - if (timeout >= 172800) - notice_lang(s_OperServ, u, - OPER_STATS_SQLINE_EXPIRE_DAYS, - timeout / 86400); - else if (timeout >= 86400) - notice_lang(s_OperServ, u, - OPER_STATS_SQLINE_EXPIRE_DAY); - else if (timeout >= 7200) - notice_lang(s_OperServ, u, - OPER_STATS_SQLINE_EXPIRE_HOURS, - timeout / 3600); - else if (timeout >= 3600) - notice_lang(s_OperServ, u, - OPER_STATS_SQLINE_EXPIRE_HOUR); - else if (timeout >= 120) - notice_lang(s_OperServ, u, - OPER_STATS_SQLINE_EXPIRE_MINS, - timeout / 60); - else if (timeout >= 60) - notice_lang(s_OperServ, u, - OPER_STATS_SQLINE_EXPIRE_MIN); - else - notice_lang(s_OperServ, u, - OPER_STATS_SQLINE_EXPIRE_NONE); - } - if (ircd->szline) { - /* SZLINEs */ - notice_lang(s_OperServ, u, OPER_STATS_SZLINE_COUNT, - szlines.count); - timeout = SZLineExpiry + 59; - if (timeout >= 172800) - notice_lang(s_OperServ, u, - OPER_STATS_SZLINE_EXPIRE_DAYS, - timeout / 86400); - else if (timeout >= 86400) - notice_lang(s_OperServ, u, - OPER_STATS_SZLINE_EXPIRE_DAY); - else if (timeout >= 7200) - notice_lang(s_OperServ, u, - OPER_STATS_SZLINE_EXPIRE_HOURS, - timeout / 3600); - else if (timeout >= 3600) - notice_lang(s_OperServ, u, - OPER_STATS_SZLINE_EXPIRE_HOUR); - else if (timeout >= 120) - notice_lang(s_OperServ, u, - OPER_STATS_SZLINE_EXPIRE_MINS, - timeout / 60); - else if (timeout >= 60) - notice_lang(s_OperServ, u, - OPER_STATS_SZLINE_EXPIRE_MIN); - else - notice_lang(s_OperServ, u, - OPER_STATS_SZLINE_EXPIRE_NONE); - } - return MOD_CONT; - } else if (!stricmp(extra, "RESET")) { - if (is_services_admin(u)) { - maxusercnt = usercnt; - notice_lang(s_OperServ, u, OPER_STATS_RESET); - } else { - notice_lang(s_OperServ, u, PERMISSION_DENIED); - } - return MOD_CONT; - } else if (stricmp(extra, "MEMORY") && stricmp(extra, "UPLINK")) { - notice_lang(s_OperServ, u, OPER_STATS_UNKNOWN_OPTION, extra); - } - } + if (extra && stricmp(extra, "ALL") != 0) { + if (stricmp(extra, "AKILL") == 0) { + int timeout; + /* AKILLs */ + notice_lang(s_OperServ, u, OPER_STATS_AKILL_COUNT, + akills.count); + timeout = AutokillExpiry + 59; + if (timeout >= 172800) + notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_DAYS, + timeout / 86400); + else if (timeout >= 86400) + notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_DAY); + else if (timeout >= 7200) + notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_HOURS, + timeout / 3600); + else if (timeout >= 3600) + notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_HOUR); + else if (timeout >= 120) + notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_MINS, + timeout / 60); + else if (timeout >= 60) + notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_MIN); + else + notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_NONE); + if (ircd->sgline) { + /* SGLINEs */ + notice_lang(s_OperServ, u, OPER_STATS_SGLINE_COUNT, + sglines.count); + timeout = SGLineExpiry + 59; + if (timeout >= 172800) + notice_lang(s_OperServ, u, + OPER_STATS_SGLINE_EXPIRE_DAYS, + timeout / 86400); + else if (timeout >= 86400) + notice_lang(s_OperServ, u, + OPER_STATS_SGLINE_EXPIRE_DAY); + else if (timeout >= 7200) + notice_lang(s_OperServ, u, + OPER_STATS_SGLINE_EXPIRE_HOURS, + timeout / 3600); + else if (timeout >= 3600) + notice_lang(s_OperServ, u, + OPER_STATS_SGLINE_EXPIRE_HOUR); + else if (timeout >= 120) + notice_lang(s_OperServ, u, + OPER_STATS_SGLINE_EXPIRE_MINS, + timeout / 60); + else if (timeout >= 60) + notice_lang(s_OperServ, u, + OPER_STATS_SGLINE_EXPIRE_MIN); + else + notice_lang(s_OperServ, u, + OPER_STATS_SGLINE_EXPIRE_NONE); + } + if (ircd->sqline) { + /* SQLINEs */ + notice_lang(s_OperServ, u, OPER_STATS_SQLINE_COUNT, + sqlines.count); + timeout = SQLineExpiry + 59; + if (timeout >= 172800) + notice_lang(s_OperServ, u, + OPER_STATS_SQLINE_EXPIRE_DAYS, + timeout / 86400); + else if (timeout >= 86400) + notice_lang(s_OperServ, u, + OPER_STATS_SQLINE_EXPIRE_DAY); + else if (timeout >= 7200) + notice_lang(s_OperServ, u, + OPER_STATS_SQLINE_EXPIRE_HOURS, + timeout / 3600); + else if (timeout >= 3600) + notice_lang(s_OperServ, u, + OPER_STATS_SQLINE_EXPIRE_HOUR); + else if (timeout >= 120) + notice_lang(s_OperServ, u, + OPER_STATS_SQLINE_EXPIRE_MINS, + timeout / 60); + else if (timeout >= 60) + notice_lang(s_OperServ, u, + OPER_STATS_SQLINE_EXPIRE_MIN); + else + notice_lang(s_OperServ, u, + OPER_STATS_SQLINE_EXPIRE_NONE); + } + if (ircd->szline) { + /* SZLINEs */ + notice_lang(s_OperServ, u, OPER_STATS_SZLINE_COUNT, + szlines.count); + timeout = SZLineExpiry + 59; + if (timeout >= 172800) + notice_lang(s_OperServ, u, + OPER_STATS_SZLINE_EXPIRE_DAYS, + timeout / 86400); + else if (timeout >= 86400) + notice_lang(s_OperServ, u, + OPER_STATS_SZLINE_EXPIRE_DAY); + else if (timeout >= 7200) + notice_lang(s_OperServ, u, + OPER_STATS_SZLINE_EXPIRE_HOURS, + timeout / 3600); + else if (timeout >= 3600) + notice_lang(s_OperServ, u, + OPER_STATS_SZLINE_EXPIRE_HOUR); + else if (timeout >= 120) + notice_lang(s_OperServ, u, + OPER_STATS_SZLINE_EXPIRE_MINS, + timeout / 60); + else if (timeout >= 60) + notice_lang(s_OperServ, u, + OPER_STATS_SZLINE_EXPIRE_MIN); + else + notice_lang(s_OperServ, u, + OPER_STATS_SZLINE_EXPIRE_NONE); + } + return MOD_CONT; + } else if (!stricmp(extra, "RESET")) { + if (is_services_admin(u)) { + maxusercnt = usercnt; + notice_lang(s_OperServ, u, OPER_STATS_RESET); + } else { + notice_lang(s_OperServ, u, PERMISSION_DENIED); + } + return MOD_CONT; + } else if (stricmp(extra, "MEMORY") && stricmp(extra, "UPLINK")) { + notice_lang(s_OperServ, u, OPER_STATS_UNKNOWN_OPTION, extra); + } + } - if (!extra || ((stricmp(extra, "MEMORY") != 0) - && (stricmp(extra, "UPLINK") != 0))) { - notice_lang(s_OperServ, u, OPER_STATS_CURRENT_USERS, usercnt, - opcnt); - tm = localtime(&maxusertime); - strftime_lang(timebuf, sizeof(timebuf), u, - STRFTIME_DATE_TIME_FORMAT, tm); - notice_lang(s_OperServ, u, OPER_STATS_MAX_USERS, maxusercnt, - timebuf); - if (days > 1) { - notice_lang(s_OperServ, u, OPER_STATS_UPTIME_DHMS, - days, hours, mins, secs); - } else if (days == 1) { - notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1DHMS, - days, hours, mins, secs); - } else { - if (hours > 1) { - if (mins != 1) { - if (secs != 1) { - notice_lang(s_OperServ, u, OPER_STATS_UPTIME_HMS, - hours, mins, secs); - } else { - notice_lang(s_OperServ, u, OPER_STATS_UPTIME_HM1S, - hours, mins, secs); - } - } else { - if (secs != 1) { - notice_lang(s_OperServ, u, OPER_STATS_UPTIME_H1MS, - hours, mins, secs); - } else { - notice_lang(s_OperServ, u, OPER_STATS_UPTIME_H1M1S, - hours, mins, secs); - } - } - } else if (hours == 1) { - if (mins != 1) { - if (secs != 1) { - notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1HMS, - hours, mins, secs); - } else { - notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1HM1S, - hours, mins, secs); - } - } else { - if (secs != 1) { - notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1H1MS, - hours, mins, secs); - } else { - notice_lang(s_OperServ, u, - OPER_STATS_UPTIME_1H1M1S, hours, mins, - secs); - } - } - } else { - if (mins != 1) { - if (secs != 1) { - notice_lang(s_OperServ, u, OPER_STATS_UPTIME_MS, - mins, secs); - } else { - notice_lang(s_OperServ, u, OPER_STATS_UPTIME_M1S, - mins, secs); - } - } else { - if (secs != 1) { - notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1MS, - mins, secs); - } else { - notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1M1S, - mins, secs); - } - } - } - } - } + if (!extra || ((stricmp(extra, "MEMORY") != 0) + && (stricmp(extra, "UPLINK") != 0))) { + notice_lang(s_OperServ, u, OPER_STATS_CURRENT_USERS, usercnt, + opcnt); + tm = localtime(&maxusertime); + strftime_lang(timebuf, sizeof(timebuf), u, + STRFTIME_DATE_TIME_FORMAT, tm); + notice_lang(s_OperServ, u, OPER_STATS_MAX_USERS, maxusercnt, + timebuf); + if (days > 1) { + notice_lang(s_OperServ, u, OPER_STATS_UPTIME_DHMS, + days, hours, mins, secs); + } else if (days == 1) { + notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1DHMS, + days, hours, mins, secs); + } else { + if (hours > 1) { + if (mins != 1) { + if (secs != 1) { + notice_lang(s_OperServ, u, OPER_STATS_UPTIME_HMS, + hours, mins, secs); + } else { + notice_lang(s_OperServ, u, OPER_STATS_UPTIME_HM1S, + hours, mins, secs); + } + } else { + if (secs != 1) { + notice_lang(s_OperServ, u, OPER_STATS_UPTIME_H1MS, + hours, mins, secs); + } else { + notice_lang(s_OperServ, u, OPER_STATS_UPTIME_H1M1S, + hours, mins, secs); + } + } + } else if (hours == 1) { + if (mins != 1) { + if (secs != 1) { + notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1HMS, + hours, mins, secs); + } else { + notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1HM1S, + hours, mins, secs); + } + } else { + if (secs != 1) { + notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1H1MS, + hours, mins, secs); + } else { + notice_lang(s_OperServ, u, + OPER_STATS_UPTIME_1H1M1S, hours, mins, + secs); + } + } + } else { + if (mins != 1) { + if (secs != 1) { + notice_lang(s_OperServ, u, OPER_STATS_UPTIME_MS, + mins, secs); + } else { + notice_lang(s_OperServ, u, OPER_STATS_UPTIME_M1S, + mins, secs); + } + } else { + if (secs != 1) { + notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1MS, + mins, secs); + } else { + notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1M1S, + mins, secs); + } + } + } + } + } - if (extra && ((stricmp(extra, "ALL") == 0) - || (stricmp(extra, "UPLINK") == 0)) - && is_services_admin(u)) { - buf[0] = '\0'; - buflen = 511; /* How confusing, this is the amount of space left! */ - for (i = 0; capab_info[i].token; i++) { - if (uplink_capab & capab_info[i].flag) { - strncat(buf, " ", buflen); - buflen--; - strncat(buf, capab_info[i].token, buflen); - buflen -= strlen(capab_info[i].token); - /* Special cases */ - if (capab_info[i].flag == CAPAB_CHANMODE) { - strncat(buf, "=", buflen); - buflen--; - strncat(buf, ircd->chanmodes, buflen); - buflen -= strlen(ircd->chanmodes); - } - if (capab_info[i].flag == CAPAB_NICKCHARS) { - strncat(buf, "=", buflen); - buflen--; - if (ircd->nickchars) { - strncat(buf, ircd->nickchars, buflen); - buflen -= strlen(ircd->nickchars); - } /* leave blank if it was null */ - } - } - } - notice_lang(s_OperServ, u, OPER_STATS_UPLINK_SERVER, - serv_uplink->name); - notice_lang(s_OperServ, u, OPER_STATS_UPLINK_CAPAB, buf); - notice_lang(s_OperServ, u, OPER_STATS_UPLINK_SERVER_COUNT, - stats_count_servers(serv_uplink)); - } + if (extra && ((stricmp(extra, "ALL") == 0) + || (stricmp(extra, "UPLINK") == 0)) + && is_services_admin(u)) { + buf[0] = '\0'; + buflen = 511; /* How confusing, this is the amount of space left! */ + for (i = 0; capab_info[i].token; i++) { + if (uplink_capab & capab_info[i].flag) { + strncat(buf, " ", buflen); + buflen--; + strncat(buf, capab_info[i].token, buflen); + buflen -= strlen(capab_info[i].token); + /* Special cases */ + if (capab_info[i].flag == CAPAB_CHANMODE) { + strncat(buf, "=", buflen); + buflen--; + strncat(buf, ircd->chanmodes, buflen); + buflen -= strlen(ircd->chanmodes); + } + if (capab_info[i].flag == CAPAB_NICKCHARS) { + strncat(buf, "=", buflen); + buflen--; + if (ircd->nickchars) { + strncat(buf, ircd->nickchars, buflen); + buflen -= strlen(ircd->nickchars); + } /* leave blank if it was null */ + } + } + } + notice_lang(s_OperServ, u, OPER_STATS_UPLINK_SERVER, + serv_uplink->name); + notice_lang(s_OperServ, u, OPER_STATS_UPLINK_CAPAB, buf); + notice_lang(s_OperServ, u, OPER_STATS_UPLINK_SERVER_COUNT, + stats_count_servers(serv_uplink)); + } - if (extra && ((stricmp(extra, "ALL") == 0) - || (stricmp(extra, "MEMORY") == 0)) - && is_services_admin(u)) { - long count, mem; + if (extra && ((stricmp(extra, "ALL") == 0) + || (stricmp(extra, "MEMORY") == 0)) + && is_services_admin(u)) { + long count, mem; - notice_lang(s_OperServ, u, OPER_STATS_BYTES_READ, - total_read / 1024); - notice_lang(s_OperServ, u, OPER_STATS_BYTES_WRITTEN, - total_written / 1024); + notice_lang(s_OperServ, u, OPER_STATS_BYTES_READ, + total_read / 1024); + notice_lang(s_OperServ, u, OPER_STATS_BYTES_WRITTEN, + total_written / 1024); - get_user_stats(&count, &mem); - notice_lang(s_OperServ, u, OPER_STATS_USER_MEM, count, - (mem + 512) / 1024); - get_channel_stats(&count, &mem); - notice_lang(s_OperServ, u, OPER_STATS_CHANNEL_MEM, count, - (mem + 512) / 1024); - get_core_stats(&count, &mem); - notice_lang(s_OperServ, u, OPER_STATS_GROUPS_MEM, count, - (mem + 512) / 1024); - get_aliases_stats(&count, &mem); - notice_lang(s_OperServ, u, OPER_STATS_ALIASES_MEM, count, - (mem + 512) / 1024); - get_chanserv_stats(&count, &mem); - notice_lang(s_OperServ, u, OPER_STATS_CHANSERV_MEM, count, - (mem + 512) / 1024); - if (s_BotServ) { - get_botserv_stats(&count, &mem); - notice_lang(s_OperServ, u, OPER_STATS_BOTSERV_MEM, count, - (mem + 512) / 1024); - } - if (s_HostServ) { - get_hostserv_stats(&count, &mem); - notice_lang(s_OperServ, u, OPER_STATS_HOSTSERV_MEM, count, - (mem + 512) / 1024); - } - get_operserv_stats(&count, &mem); - notice_lang(s_OperServ, u, OPER_STATS_OPERSERV_MEM, count, - (mem + 512) / 1024); - get_session_stats(&count, &mem); - notice_lang(s_OperServ, u, OPER_STATS_SESSIONS_MEM, count, - (mem + 512) / 1024); - } - return MOD_CONT; + get_user_stats(&count, &mem); + notice_lang(s_OperServ, u, OPER_STATS_USER_MEM, count, + (mem + 512) / 1024); + get_channel_stats(&count, &mem); + notice_lang(s_OperServ, u, OPER_STATS_CHANNEL_MEM, count, + (mem + 512) / 1024); + get_core_stats(&count, &mem); + notice_lang(s_OperServ, u, OPER_STATS_GROUPS_MEM, count, + (mem + 512) / 1024); + get_aliases_stats(&count, &mem); + notice_lang(s_OperServ, u, OPER_STATS_ALIASES_MEM, count, + (mem + 512) / 1024); + get_chanserv_stats(&count, &mem); + notice_lang(s_OperServ, u, OPER_STATS_CHANSERV_MEM, count, + (mem + 512) / 1024); + if (s_BotServ) { + get_botserv_stats(&count, &mem); + notice_lang(s_OperServ, u, OPER_STATS_BOTSERV_MEM, count, + (mem + 512) / 1024); + } + if (s_HostServ) { + get_hostserv_stats(&count, &mem); + notice_lang(s_OperServ, u, OPER_STATS_HOSTSERV_MEM, count, + (mem + 512) / 1024); + } + get_operserv_stats(&count, &mem); + notice_lang(s_OperServ, u, OPER_STATS_OPERSERV_MEM, count, + (mem + 512) / 1024); + get_session_stats(&count, &mem); + notice_lang(s_OperServ, u, OPER_STATS_SESSIONS_MEM, count, + (mem + 512) / 1024); + } + return MOD_CONT; } void get_operserv_stats(long *nrec, long *memuse) { - int i; - long mem = 0, count = 0, mem2 = 0, count2 = 0; - Akill *ak; - SXLine *sx; + int i; + long mem = 0, count = 0, mem2 = 0, count2 = 0; + Akill *ak; + SXLine *sx; - count += akills.count; - mem += akills.capacity; - mem += akills.count * sizeof(Akill); + count += akills.count; + mem += akills.capacity; + mem += akills.count * sizeof(Akill); - for (i = 0; i < akills.count; i++) { - ak = (Akill *)akills.list[i]; - mem += strlen(ak->user) + 1; - mem += strlen(ak->host) + 1; - mem += strlen(ak->by) + 1; - mem += strlen(ak->reason) + 1; - } + for (i = 0; i < akills.count; i++) { + ak = (Akill *)akills.list[i]; + mem += strlen(ak->user) + 1; + mem += strlen(ak->host) + 1; + mem += strlen(ak->by) + 1; + mem += strlen(ak->reason) + 1; + } - if (ircd->sgline) { - count += sglines.count; - mem += sglines.capacity; - mem += sglines.count * sizeof(SXLine); + if (ircd->sgline) { + count += sglines.count; + mem += sglines.capacity; + mem += sglines.count * sizeof(SXLine); - for (i = 0; i < sglines.count; i++) { - sx = (SXLine *)sglines.list[i]; - mem += strlen(sx->mask) + 1; - mem += strlen(sx->by) + 1; - mem += strlen(sx->reason) + 1; - } - } - if (ircd->sqline) { - count += sqlines.count; - mem += sqlines.capacity; - mem += sqlines.count * sizeof(SXLine); + for (i = 0; i < sglines.count; i++) { + sx = (SXLine *)sglines.list[i]; + mem += strlen(sx->mask) + 1; + mem += strlen(sx->by) + 1; + mem += strlen(sx->reason) + 1; + } + } + if (ircd->sqline) { + count += sqlines.count; + mem += sqlines.capacity; + mem += sqlines.count * sizeof(SXLine); - for (i = 0; i < sqlines.count; i++) { - sx = (SXLine *)sqlines.list[i]; - mem += strlen(sx->mask) + 1; - mem += strlen(sx->by) + 1; - mem += strlen(sx->reason) + 1; - } - } - if (ircd->szline) { - count += szlines.count; - mem += szlines.capacity; - mem += szlines.count * sizeof(SXLine); + for (i = 0; i < sqlines.count; i++) { + sx = (SXLine *)sqlines.list[i]; + mem += strlen(sx->mask) + 1; + mem += strlen(sx->by) + 1; + mem += strlen(sx->reason) + 1; + } + } + if (ircd->szline) { + count += szlines.count; + mem += szlines.capacity; + mem += szlines.count * sizeof(SXLine); - for (i = 0; i < szlines.count; i++) { - sx = (SXLine *)szlines.list[i]; - mem += strlen(sx->mask) + 1; - mem += strlen(sx->by) + 1; - mem += strlen(sx->reason) + 1; - } - } + for (i = 0; i < szlines.count; i++) { + sx = (SXLine *)szlines.list[i]; + mem += strlen(sx->mask) + 1; + mem += strlen(sx->by) + 1; + mem += strlen(sx->reason) + 1; + } + } - get_news_stats(&count2, &mem2); - count += count2; - mem += mem2; - get_exception_stats(&count2, &mem2); - count += count2; - mem += mem2; + get_news_stats(&count2, &mem2); + count += count2; + mem += mem2; + get_exception_stats(&count2, &mem2); + count += count2; + mem += mem2; - *nrec = count; - *memuse = mem; + *nrec = count; + *memuse = mem; } MODULE_INIT("os_stats", OSStats) diff --git a/src/core/os_svsnick.c b/src/core/os_svsnick.c index fda5d3a58..244500b2a 100644 --- a/src/core/os_svsnick.c +++ b/src/core/os_svsnick.c @@ -46,9 +46,9 @@ class OSSVSNick : public Module **/ void myOperServHelp(User * u) { - if (is_services_admin(u) && u->isSuperAdmin) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_SVSNICK); - } + if (is_services_admin(u) && u->isSuperAdmin) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_SVSNICK); + } } /** @@ -60,56 +60,56 @@ void myOperServHelp(User * u) int do_svsnick(User * u) { - char *nick = strtok(NULL, " "); - char *newnick = strtok(NULL, " "); - - NickAlias *na; - char *c; - - /* Only allow this if SuperAdmin is enabled */ - if (!u->isSuperAdmin) { - notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ONLY); - return MOD_CONT; - } - - if (!nick || !newnick) { - syntax_error(s_OperServ, u, "SVSNICK", OPER_SVSNICK_SYNTAX); - return MOD_CONT; - } - - /* Truncate long nicknames to NICKMAX-2 characters */ - if (strlen(newnick) > (NICKMAX - 2)) { - notice_lang(s_OperServ, u, NICK_X_TRUNCATED, - newnick, NICKMAX - 2, newnick); - newnick[NICKMAX - 2] = '\0'; - } - - /* Check for valid characters */ - if (*newnick == '-' || isdigit(*newnick)) { - notice_lang(s_OperServ, u, NICK_X_ILLEGAL, newnick); - return MOD_CONT; - } - for (c = newnick; *c && (c - newnick) < NICKMAX; c++) { - if (!isvalidnick(*c)) { - notice_lang(s_OperServ, u, NICK_X_ILLEGAL, newnick); - return MOD_CONT; - } - } - - /* Check for a nick in use or a forbidden/suspended nick */ - if (!finduser(nick)) { - notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, nick); - } else if (finduser(newnick)) { - notice_lang(s_OperServ, u, NICK_X_IN_USE, newnick); - } else if ((na = findnick(newnick)) && (na->status & NS_VERBOTEN)) { - notice_lang(s_OperServ, u, NICK_X_FORBIDDEN, newnick); - } else { - notice_lang(s_OperServ, u, OPER_SVSNICK_NEWNICK, nick, newnick); - ircdproto->SendGlobops(s_OperServ, "%s used SVSNICK to change %s to %s", - u->nick, nick, newnick); - ircdproto->SendForceNickChange(nick, newnick, time(NULL)); - } - return MOD_CONT; + char *nick = strtok(NULL, " "); + char *newnick = strtok(NULL, " "); + + NickAlias *na; + char *c; + + /* Only allow this if SuperAdmin is enabled */ + if (!u->isSuperAdmin) { + notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ONLY); + return MOD_CONT; + } + + if (!nick || !newnick) { + syntax_error(s_OperServ, u, "SVSNICK", OPER_SVSNICK_SYNTAX); + return MOD_CONT; + } + + /* Truncate long nicknames to NICKMAX-2 characters */ + if (strlen(newnick) > (NICKMAX - 2)) { + notice_lang(s_OperServ, u, NICK_X_TRUNCATED, + newnick, NICKMAX - 2, newnick); + newnick[NICKMAX - 2] = '\0'; + } + + /* Check for valid characters */ + if (*newnick == '-' || isdigit(*newnick)) { + notice_lang(s_OperServ, u, NICK_X_ILLEGAL, newnick); + return MOD_CONT; + } + for (c = newnick; *c && (c - newnick) < NICKMAX; c++) { + if (!isvalidnick(*c)) { + notice_lang(s_OperServ, u, NICK_X_ILLEGAL, newnick); + return MOD_CONT; + } + } + + /* Check for a nick in use or a forbidden/suspended nick */ + if (!finduser(nick)) { + notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, nick); + } else if (finduser(newnick)) { + notice_lang(s_OperServ, u, NICK_X_IN_USE, newnick); + } else if ((na = findnick(newnick)) && (na->status & NS_VERBOTEN)) { + notice_lang(s_OperServ, u, NICK_X_FORBIDDEN, newnick); + } else { + notice_lang(s_OperServ, u, OPER_SVSNICK_NEWNICK, nick, newnick); + ircdproto->SendGlobops(s_OperServ, "%s used SVSNICK to change %s to %s", + u->nick, nick, newnick); + ircdproto->SendForceNickChange(nick, newnick, time(NULL)); + } + return MOD_CONT; } MODULE_INIT("os_svsnick", OSSVSNick) diff --git a/src/core/os_szline.c b/src/core/os_szline.c index 7e06be601..4e324b261 100644 --- a/src/core/os_szline.c +++ b/src/core/os_szline.c @@ -18,9 +18,9 @@ int do_szline(User * u); void myOperServHelp(User * u); int szline_view_callback(SList * slist, int number, void *item, - va_list args); + va_list args); int szline_list_callback(SList * slist, int number, void *item, - va_list args); + va_list args); int szline_view(int number, SXLine * sx, User * u, int *sent_header); int szline_list(int number, SXLine * sx, User * u, int *sent_header); @@ -52,9 +52,9 @@ class OSSZLine : public Module **/ void myOperServHelp(User * u) { - if (is_services_oper(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_SZLINE); - } + if (is_services_oper(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_SZLINE); + } } /** @@ -64,277 +64,277 @@ void myOperServHelp(User * u) **/ int do_szline(User * u) { - char *cmd = strtok(NULL, " "); - - if (!cmd) - cmd = ""; - - if (!stricmp(cmd, "ADD")) { - int deleted = 0; - char *expiry, *mask, *reason; - time_t expires; - - mask = strtok(NULL, " "); - if (mask && *mask == '+') { - expiry = mask; - mask = strtok(NULL, " "); - } else { - expiry = NULL; - } - - expires = expiry ? dotime(expiry) : SZLineExpiry; - /* If the expiry given does not contain a final letter, it's in days, - * said the doc. Ah well. - */ - if (expiry && isdigit(expiry[strlen(expiry) - 1])) - expires *= 86400; - /* Do not allow less than a minute expiry time */ - if (expires != 0 && expires < 60) { - notice_lang(s_OperServ, u, BAD_EXPIRY_TIME); - return MOD_CONT; - } else if (expires > 0) { - expires += time(NULL); - } - - if (mask && (reason = strtok(NULL, ""))) { - /* We first do some sanity check on the proposed mask. */ - - if (strchr(mask, '!') || strchr(mask, '@')) { - notice_lang(s_OperServ, u, OPER_SZLINE_ONLY_IPS); - return MOD_CONT; - } - - if (strspn(mask, "*?") == strlen(mask)) { - notice_lang(s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask); - return MOD_CONT; - } - - deleted = add_szline(u, mask, u->nick, expires, reason); - if (deleted < 0) - return MOD_CONT; - else if (deleted) - notice_lang(s_OperServ, u, OPER_SZLINE_DELETED_SEVERAL, - deleted); - notice_lang(s_OperServ, u, OPER_SZLINE_ADDED, mask); - - if (WallOSSZLine) { - char buf[128]; - - if (!expires) { - strcpy(buf, "does not expire"); - } else { - int wall_expiry = expires - time(NULL); - char *s = NULL; - - if (wall_expiry >= 86400) { - wall_expiry /= 86400; - s = "day"; - } else if (wall_expiry >= 3600) { - wall_expiry /= 3600; - s = "hour"; - } else if (wall_expiry >= 60) { - wall_expiry /= 60; - s = "minute"; - } - - snprintf(buf, sizeof(buf), "expires in %d %s%s", - wall_expiry, s, - (wall_expiry == 1) ? "" : "s"); - } - - ircdproto->SendGlobops(s_OperServ, - "%s added an SZLINE for %s (%s)", u->nick, - mask, buf); - } - - if (readonly) - notice_lang(s_OperServ, u, READ_ONLY_MODE); - - } else { - syntax_error(s_OperServ, u, "SZLINE", OPER_SZLINE_SYNTAX); - } - - } else if (!stricmp(cmd, "DEL")) { - - char *mask; - int res = 0; - - mask = strtok(NULL, " "); - - if (!mask) { - syntax_error(s_OperServ, u, "SZLINE", OPER_SZLINE_SYNTAX); - return MOD_CONT; - } - - if (szlines.count == 0) { - notice_lang(s_OperServ, u, OPER_SZLINE_LIST_EMPTY); - return MOD_CONT; - } - - if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) { - /* Deleting a range */ - res = slist_delete_range(&szlines, mask, NULL); - if (res == 0) { - notice_lang(s_OperServ, u, OPER_SZLINE_NO_MATCH); - return MOD_CONT; - } else if (res == 1) { - notice_lang(s_OperServ, u, OPER_SZLINE_DELETED_ONE); - } else { - notice_lang(s_OperServ, u, OPER_SZLINE_DELETED_SEVERAL, - res); - } - } else { - if ((res = slist_indexof(&szlines, mask)) == -1) { - notice_lang(s_OperServ, u, OPER_SZLINE_NOT_FOUND, mask); - return MOD_CONT; - } - - slist_delete(&szlines, res); - notice_lang(s_OperServ, u, OPER_SZLINE_DELETED, mask); - } - - if (readonly) - notice_lang(s_OperServ, u, READ_ONLY_MODE); - - } else if (!stricmp(cmd, "LIST")) { - char *mask; - int res, sent_header = 0; - - if (szlines.count == 0) { - notice_lang(s_OperServ, u, OPER_SZLINE_LIST_EMPTY); - return MOD_CONT; - } - - mask = strtok(NULL, " "); - - if (!mask || (isdigit(*mask) - && strspn(mask, "1234567890,-") == strlen(mask))) { - res = - slist_enum(&szlines, mask, &szline_list_callback, u, - &sent_header); - if (res == 0) { - notice_lang(s_OperServ, u, OPER_SZLINE_NO_MATCH); - return MOD_CONT; - } - } else { - int i; - char *amask; - - for (i = 0; i < szlines.count; i++) { - amask = ((SXLine *) szlines.list[i])->mask; - if (!stricmp(mask, amask) - || match_wild_nocase(mask, amask)) - szline_list(i + 1, (SXLine *)szlines.list[i], u, &sent_header); - } - - if (!sent_header) - notice_lang(s_OperServ, u, OPER_SZLINE_NO_MATCH); - } - } else if (!stricmp(cmd, "VIEW")) { - char *mask; - int res, sent_header = 0; - - if (szlines.count == 0) { - notice_lang(s_OperServ, u, OPER_SZLINE_LIST_EMPTY); - return MOD_CONT; - } - - mask = strtok(NULL, " "); - - if (!mask || (isdigit(*mask) - && strspn(mask, "1234567890,-") == strlen(mask))) { - res = - slist_enum(&szlines, mask, &szline_view_callback, u, - &sent_header); - if (res == 0) { - notice_lang(s_OperServ, u, OPER_SZLINE_NO_MATCH); - return MOD_CONT; - } - } else { - int i; - char *amask; - - for (i = 0; i < szlines.count; i++) { - amask = ((SXLine *) szlines.list[i])->mask; - if (!stricmp(mask, amask) - || match_wild_nocase(mask, amask)) - szline_view(i + 1, (SXLine *)szlines.list[i], u, &sent_header); - } - - if (!sent_header) - notice_lang(s_OperServ, u, OPER_SZLINE_NO_MATCH); - } - } else if (!stricmp(cmd, "CLEAR")) { - slist_clear(&szlines, 1); - notice_lang(s_OperServ, u, OPER_SZLINE_CLEAR); - } else { - syntax_error(s_OperServ, u, "SZLINE", OPER_SZLINE_SYNTAX); - } - return MOD_CONT; + char *cmd = strtok(NULL, " "); + + if (!cmd) + cmd = ""; + + if (!stricmp(cmd, "ADD")) { + int deleted = 0; + char *expiry, *mask, *reason; + time_t expires; + + mask = strtok(NULL, " "); + if (mask && *mask == '+') { + expiry = mask; + mask = strtok(NULL, " "); + } else { + expiry = NULL; + } + + expires = expiry ? dotime(expiry) : SZLineExpiry; + /* If the expiry given does not contain a final letter, it's in days, + * said the doc. Ah well. + */ + if (expiry && isdigit(expiry[strlen(expiry) - 1])) + expires *= 86400; + /* Do not allow less than a minute expiry time */ + if (expires != 0 && expires < 60) { + notice_lang(s_OperServ, u, BAD_EXPIRY_TIME); + return MOD_CONT; + } else if (expires > 0) { + expires += time(NULL); + } + + if (mask && (reason = strtok(NULL, ""))) { + /* We first do some sanity check on the proposed mask. */ + + if (strchr(mask, '!') || strchr(mask, '@')) { + notice_lang(s_OperServ, u, OPER_SZLINE_ONLY_IPS); + return MOD_CONT; + } + + if (strspn(mask, "*?") == strlen(mask)) { + notice_lang(s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask); + return MOD_CONT; + } + + deleted = add_szline(u, mask, u->nick, expires, reason); + if (deleted < 0) + return MOD_CONT; + else if (deleted) + notice_lang(s_OperServ, u, OPER_SZLINE_DELETED_SEVERAL, + deleted); + notice_lang(s_OperServ, u, OPER_SZLINE_ADDED, mask); + + if (WallOSSZLine) { + char buf[128]; + + if (!expires) { + strcpy(buf, "does not expire"); + } else { + int wall_expiry = expires - time(NULL); + char *s = NULL; + + if (wall_expiry >= 86400) { + wall_expiry /= 86400; + s = "day"; + } else if (wall_expiry >= 3600) { + wall_expiry /= 3600; + s = "hour"; + } else if (wall_expiry >= 60) { + wall_expiry /= 60; + s = "minute"; + } + + snprintf(buf, sizeof(buf), "expires in %d %s%s", + wall_expiry, s, + (wall_expiry == 1) ? "" : "s"); + } + + ircdproto->SendGlobops(s_OperServ, + "%s added an SZLINE for %s (%s)", u->nick, + mask, buf); + } + + if (readonly) + notice_lang(s_OperServ, u, READ_ONLY_MODE); + + } else { + syntax_error(s_OperServ, u, "SZLINE", OPER_SZLINE_SYNTAX); + } + + } else if (!stricmp(cmd, "DEL")) { + + char *mask; + int res = 0; + + mask = strtok(NULL, " "); + + if (!mask) { + syntax_error(s_OperServ, u, "SZLINE", OPER_SZLINE_SYNTAX); + return MOD_CONT; + } + + if (szlines.count == 0) { + notice_lang(s_OperServ, u, OPER_SZLINE_LIST_EMPTY); + return MOD_CONT; + } + + if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) { + /* Deleting a range */ + res = slist_delete_range(&szlines, mask, NULL); + if (res == 0) { + notice_lang(s_OperServ, u, OPER_SZLINE_NO_MATCH); + return MOD_CONT; + } else if (res == 1) { + notice_lang(s_OperServ, u, OPER_SZLINE_DELETED_ONE); + } else { + notice_lang(s_OperServ, u, OPER_SZLINE_DELETED_SEVERAL, + res); + } + } else { + if ((res = slist_indexof(&szlines, mask)) == -1) { + notice_lang(s_OperServ, u, OPER_SZLINE_NOT_FOUND, mask); + return MOD_CONT; + } + + slist_delete(&szlines, res); + notice_lang(s_OperServ, u, OPER_SZLINE_DELETED, mask); + } + + if (readonly) + notice_lang(s_OperServ, u, READ_ONLY_MODE); + + } else if (!stricmp(cmd, "LIST")) { + char *mask; + int res, sent_header = 0; + + if (szlines.count == 0) { + notice_lang(s_OperServ, u, OPER_SZLINE_LIST_EMPTY); + return MOD_CONT; + } + + mask = strtok(NULL, " "); + + if (!mask || (isdigit(*mask) + && strspn(mask, "1234567890,-") == strlen(mask))) { + res = + slist_enum(&szlines, mask, &szline_list_callback, u, + &sent_header); + if (res == 0) { + notice_lang(s_OperServ, u, OPER_SZLINE_NO_MATCH); + return MOD_CONT; + } + } else { + int i; + char *amask; + + for (i = 0; i < szlines.count; i++) { + amask = ((SXLine *) szlines.list[i])->mask; + if (!stricmp(mask, amask) + || match_wild_nocase(mask, amask)) + szline_list(i + 1, (SXLine *)szlines.list[i], u, &sent_header); + } + + if (!sent_header) + notice_lang(s_OperServ, u, OPER_SZLINE_NO_MATCH); + } + } else if (!stricmp(cmd, "VIEW")) { + char *mask; + int res, sent_header = 0; + + if (szlines.count == 0) { + notice_lang(s_OperServ, u, OPER_SZLINE_LIST_EMPTY); + return MOD_CONT; + } + + mask = strtok(NULL, " "); + + if (!mask || (isdigit(*mask) + && strspn(mask, "1234567890,-") == strlen(mask))) { + res = + slist_enum(&szlines, mask, &szline_view_callback, u, + &sent_header); + if (res == 0) { + notice_lang(s_OperServ, u, OPER_SZLINE_NO_MATCH); + return MOD_CONT; + } + } else { + int i; + char *amask; + + for (i = 0; i < szlines.count; i++) { + amask = ((SXLine *) szlines.list[i])->mask; + if (!stricmp(mask, amask) + || match_wild_nocase(mask, amask)) + szline_view(i + 1, (SXLine *)szlines.list[i], u, &sent_header); + } + + if (!sent_header) + notice_lang(s_OperServ, u, OPER_SZLINE_NO_MATCH); + } + } else if (!stricmp(cmd, "CLEAR")) { + slist_clear(&szlines, 1); + notice_lang(s_OperServ, u, OPER_SZLINE_CLEAR); + } else { + syntax_error(s_OperServ, u, "SZLINE", OPER_SZLINE_SYNTAX); + } + return MOD_CONT; } int szline_view(int number, SXLine * sx, User * u, int *sent_header) { - char timebuf[32], expirebuf[256]; - struct tm tm; + char timebuf[32], expirebuf[256]; + struct tm tm; - if (!sx) - return 0; + if (!sx) + return 0; - if (!*sent_header) { - notice_lang(s_OperServ, u, OPER_SZLINE_VIEW_HEADER); - *sent_header = 1; - } + if (!*sent_header) { + notice_lang(s_OperServ, u, OPER_SZLINE_VIEW_HEADER); + *sent_header = 1; + } - tm = *localtime(&sx->seton); - strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_SHORT_DATE_FORMAT, - &tm); - expire_left(u->na, expirebuf, sizeof(expirebuf), sx->expires); - notice_lang(s_OperServ, u, OPER_SZLINE_VIEW_FORMAT, number, sx->mask, - sx->by, timebuf, expirebuf, sx->reason); + tm = *localtime(&sx->seton); + strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_SHORT_DATE_FORMAT, + &tm); + expire_left(u->na, expirebuf, sizeof(expirebuf), sx->expires); + notice_lang(s_OperServ, u, OPER_SZLINE_VIEW_FORMAT, number, sx->mask, + sx->by, timebuf, expirebuf, sx->reason); - return 1; + return 1; } /* Callback for enumeration purposes */ int szline_view_callback(SList * slist, int number, void *item, - va_list args) + va_list args) { - User *u = va_arg(args, User *); - int *sent_header = va_arg(args, int *); + User *u = va_arg(args, User *); + int *sent_header = va_arg(args, int *); - return szline_view(number, (SXLine *)item, u, sent_header); + return szline_view(number, (SXLine *)item, u, sent_header); } /* Callback for enumeration purposes */ int szline_list_callback(SList * slist, int number, void *item, - va_list args) + va_list args) { - User *u = va_arg(args, User *); - int *sent_header = va_arg(args, int *); + User *u = va_arg(args, User *); + int *sent_header = va_arg(args, int *); - return szline_list(number, (SXLine *)item, u, sent_header); + return szline_list(number, (SXLine *)item, u, sent_header); } /* Lists an SZLINE entry, prefixing it with the header if needed */ int szline_list(int number, SXLine * sx, User * u, int *sent_header) { - if (!sx) - return 0; + if (!sx) + return 0; - if (!*sent_header) { - notice_lang(s_OperServ, u, OPER_SZLINE_LIST_HEADER); - *sent_header = 1; - } + if (!*sent_header) { + notice_lang(s_OperServ, u, OPER_SZLINE_LIST_HEADER); + *sent_header = 1; + } - notice_lang(s_OperServ, u, OPER_SZLINE_LIST_FORMAT, number, sx->mask, - sx->reason); + notice_lang(s_OperServ, u, OPER_SZLINE_LIST_FORMAT, number, sx->mask, + sx->reason); - return 1; + return 1; } MODULE_INIT("os_szline", OSSZLine) diff --git a/src/core/os_umode.c b/src/core/os_umode.c index d860890c0..a2420fbe4 100644 --- a/src/core/os_umode.c +++ b/src/core/os_umode.c @@ -54,9 +54,9 @@ void AnopeFini(void) **/ void myOperServHelp(User * u) { - if (is_services_admin(u) && u->isSuperAdmin) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_UMODE); - } + if (is_services_admin(u) && u->isSuperAdmin) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_UMODE); + } } /** @@ -69,45 +69,45 @@ void myOperServHelp(User * u) */ int do_operumodes(User * u) { - char *nick = strtok(NULL, " "); - char *modes = strtok(NULL, ""); - - User *u2; - - /* Only allow this if SuperAdmin is enabled */ - if (!u->isSuperAdmin) { - notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ONLY); - return MOD_CONT; - } - - if (!nick || !modes) { - syntax_error(s_OperServ, u, "UMODE", OPER_UMODE_SYNTAX); - return MOD_CONT; - } - - /** - * Only accept a +/- mode string - *-rob - **/ - if ((modes[0] != '+') && (modes[0] != '-')) { - syntax_error(s_OperServ, u, "UMODE", OPER_UMODE_SYNTAX); - return MOD_CONT; - } - if (!(u2 = finduser(nick))) { - notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, nick); - } else { - ircdproto->SendMode(findbot(s_OperServ), nick, "%s", modes); - - common_svsmode(u2, modes, NULL); - - notice_lang(s_OperServ, u, OPER_UMODE_SUCCESS, nick); - notice_lang(s_OperServ, u2, OPER_UMODE_CHANGED, u->nick); - - if (WallOSMode) - ircdproto->SendGlobops(s_OperServ, "\2%s\2 used UMODE on %s", - u->nick, nick); - } - return MOD_CONT; + char *nick = strtok(NULL, " "); + char *modes = strtok(NULL, ""); + + User *u2; + + /* Only allow this if SuperAdmin is enabled */ + if (!u->isSuperAdmin) { + notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ONLY); + return MOD_CONT; + } + + if (!nick || !modes) { + syntax_error(s_OperServ, u, "UMODE", OPER_UMODE_SYNTAX); + return MOD_CONT; + } + + /** + * Only accept a +/- mode string + *-rob + **/ + if ((modes[0] != '+') && (modes[0] != '-')) { + syntax_error(s_OperServ, u, "UMODE", OPER_UMODE_SYNTAX); + return MOD_CONT; + } + if (!(u2 = finduser(nick))) { + notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, nick); + } else { + ircdproto->SendMode(findbot(s_OperServ), nick, "%s", modes); + + common_svsmode(u2, modes, NULL); + + notice_lang(s_OperServ, u, OPER_UMODE_SUCCESS, nick); + notice_lang(s_OperServ, u2, OPER_UMODE_CHANGED, u->nick); + + if (WallOSMode) + ircdproto->SendGlobops(s_OperServ, "\2%s\2 used UMODE on %s", + u->nick, nick); + } + return MOD_CONT; } MODULE_INIT("os_umode", OSUMode) diff --git a/src/core/os_update.c b/src/core/os_update.c index 88573126f..bcd20ee24 100644 --- a/src/core/os_update.c +++ b/src/core/os_update.c @@ -43,9 +43,9 @@ class OSUpdate : public Module **/ void myOperServHelp(User * u) { - if (is_services_root(u)) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_UPDATE); - } + if (is_services_root(u)) { + notice_lang(s_OperServ, u, OPER_HELP_CMD_UPDATE); + } } /** @@ -55,9 +55,9 @@ void myOperServHelp(User * u) **/ int do_update(User * u) { - notice_lang(s_OperServ, u, OPER_UPDATING); - save_data = 1; - return MOD_CONT; + notice_lang(s_OperServ, u, OPER_UPDATING); + save_data = 1; + return MOD_CONT; } MODULE_INIT("os_update", OSUpdate) diff --git a/src/core/os_userlist.c b/src/core/os_userlist.c index b2ffbb3a8..318f95870 100644 --- a/src/core/os_userlist.c +++ b/src/core/os_userlist.c @@ -48,7 +48,7 @@ class OSUserList : public Module **/ void myOperServHelp(User * u) { - notice_lang(s_OperServ, u, OPER_HELP_CMD_USERLIST); + notice_lang(s_OperServ, u, OPER_HELP_CMD_USERLIST); } /** @@ -59,52 +59,52 @@ void myOperServHelp(User * u) int do_userlist(User * u) { - char *pattern = strtok(NULL, " "); - char *opt = strtok(NULL, " "); - - Channel *c; - int modes = 0; - - if (opt && !stricmp(opt, "INVISIBLE")) - modes |= anope_get_invis_mode(); - - if (pattern && (c = findchan(pattern))) { - struct c_userlist *cu; - - notice_lang(s_OperServ, u, OPER_USERLIST_HEADER_CHAN, pattern); - - for (cu = c->users; cu; cu = cu->next) { - if (modes && !(cu->user->mode & modes)) - continue; - notice_lang(s_OperServ, u, OPER_USERLIST_RECORD, - cu->user->nick, common_get_vident(cu->user), - common_get_vhost(cu->user)); - } - } else { - char mask[BUFSIZE]; - int i; - User *u2; - - notice_lang(s_OperServ, u, OPER_USERLIST_HEADER); - - for (i = 0; i < 1024; i++) { - for (u2 = userlist[i]; u2; u2 = u2->next) { - if (pattern) { - snprintf(mask, sizeof(mask), "%s!%s@%s", u2->nick, - common_get_vident(u2), common_get_vhost(u2)); - if (!match_wild_nocase(pattern, mask)) - continue; - if (modes && !(u2->mode & modes)) - continue; - } - notice_lang(s_OperServ, u, OPER_USERLIST_RECORD, u2->nick, - common_get_vident(u2), common_get_vhost(u2)); - } - } - } - - notice_lang(s_OperServ, u, OPER_USERLIST_END); - return MOD_CONT; + char *pattern = strtok(NULL, " "); + char *opt = strtok(NULL, " "); + + Channel *c; + int modes = 0; + + if (opt && !stricmp(opt, "INVISIBLE")) + modes |= anope_get_invis_mode(); + + if (pattern && (c = findchan(pattern))) { + struct c_userlist *cu; + + notice_lang(s_OperServ, u, OPER_USERLIST_HEADER_CHAN, pattern); + + for (cu = c->users; cu; cu = cu->next) { + if (modes && !(cu->user->mode & modes)) + continue; + notice_lang(s_OperServ, u, OPER_USERLIST_RECORD, + cu->user->nick, common_get_vident(cu->user), + common_get_vhost(cu->user)); + } + } else { + char mask[BUFSIZE]; + int i; + User *u2; + + notice_lang(s_OperServ, u, OPER_USERLIST_HEADER); + + for (i = 0; i < 1024; i++) { + for (u2 = userlist[i]; u2; u2 = u2->next) { + if (pattern) { + snprintf(mask, sizeof(mask), "%s!%s@%s", u2->nick, + common_get_vident(u2), common_get_vhost(u2)); + if (!match_wild_nocase(pattern, mask)) + continue; + if (modes && !(u2->mode & modes)) + continue; + } + notice_lang(s_OperServ, u, OPER_USERLIST_RECORD, u2->nick, + common_get_vident(u2), common_get_vhost(u2)); + } + } + } + + notice_lang(s_OperServ, u, OPER_USERLIST_END); + return MOD_CONT; } MODULE_INIT("os_userlist", OSUserList) diff --git a/src/datafiles.c b/src/datafiles.c index 4316da7b4..5fcacf33e 100644 --- a/src/datafiles.c +++ b/src/datafiles.c @@ -30,21 +30,21 @@ static time_t lastwarn = 0; */ int get_file_version(dbFILE * f) { - FILE *fp = f->fp; - int version = - fgetc(fp) << 24 | fgetc(fp) << 16 | fgetc(fp) << 8 | fgetc(fp); - if (ferror(fp)) { - log_perror("Error reading version number on %s", f->filename); - return 0; - } else if (feof(fp)) { - alog("Error reading version number on %s: End of file detected", - f->filename); - return 0; - } else if (version < 1) { - alog("Invalid version number (%d) on %s", version, f->filename); - return 0; - } - return version; + FILE *fp = f->fp; + int version = + fgetc(fp) << 24 | fgetc(fp) << 16 | fgetc(fp) << 8 | fgetc(fp); + if (ferror(fp)) { + log_perror("Error reading version number on %s", f->filename); + return 0; + } else if (feof(fp)) { + alog("Error reading version number on %s: End of file detected", + f->filename); + return 0; + } else if (version < 1) { + alog("Invalid version number (%d) on %s", version, f->filename); + return 0; + } + return version; } /*************************************************************************/ @@ -56,15 +56,15 @@ int get_file_version(dbFILE * f) */ int write_file_version(dbFILE * f, uint32 version) { - FILE *fp = f->fp; - if (fputc(version >> 24 & 0xFF, fp) < 0 || - fputc(version >> 16 & 0xFF, fp) < 0 || - fputc(version >> 8 & 0xFF, fp) < 0 || - fputc(version & 0xFF, fp) < 0) { - log_perror("Error writing version number on %s", f->filename); - return 0; - } - return 1; + FILE *fp = f->fp; + if (fputc(version >> 24 & 0xFF, fp) < 0 || + fputc(version >> 16 & 0xFF, fp) < 0 || + fputc(version >> 8 & 0xFF, fp) < 0 || + fputc(version & 0xFF, fp) < 0) { + log_perror("Error writing version number on %s", f->filename); + return 0; + } + return 1; } /*************************************************************************/ @@ -77,40 +77,40 @@ int write_file_version(dbFILE * f, uint32 version) */ static dbFILE *open_db_read(const char *service, const char *filename) { - dbFILE *f; - FILE *fp; - - f = (dbFILE *)scalloc(sizeof(*f), 1); - if (!f) { - log_perror("Can't read %s database %s", service, filename); - if (time(NULL) - lastwarn > WarningTimeout) { - ircdproto->SendGlobops(NULL, - "Write error on %s: Memory allocation failed", - filename); - lastwarn = time(NULL); - } - return NULL; - } - strscpy(f->filename, filename, sizeof(f->filename)); - f->mode = 'r'; - fp = fopen(f->filename, "rb"); - if (!fp) { - int errno_save = errno; - if (errno != ENOENT) - log_perror("Can not read %s database %s", service, - f->filename); - if (time(NULL) - lastwarn > WarningTimeout) { - ircdproto->SendGlobops(NULL, "Write error on %s: %s", f->filename, - strerror(errno)); - lastwarn = time(NULL); - } - free(f); - errno = errno_save; - return NULL; - } - f->fp = fp; - f->backupfp = NULL; - return f; + dbFILE *f; + FILE *fp; + + f = (dbFILE *)scalloc(sizeof(*f), 1); + if (!f) { + log_perror("Can't read %s database %s", service, filename); + if (time(NULL) - lastwarn > WarningTimeout) { + ircdproto->SendGlobops(NULL, + "Write error on %s: Memory allocation failed", + filename); + lastwarn = time(NULL); + } + return NULL; + } + strscpy(f->filename, filename, sizeof(f->filename)); + f->mode = 'r'; + fp = fopen(f->filename, "rb"); + if (!fp) { + int errno_save = errno; + if (errno != ENOENT) + log_perror("Can not read %s database %s", service, + f->filename); + if (time(NULL) - lastwarn > WarningTimeout) { + ircdproto->SendGlobops(NULL, "Write error on %s: %s", f->filename, + strerror(errno)); + lastwarn = time(NULL); + } + free(f); + errno = errno_save; + return NULL; + } + f->fp = fp; + f->backupfp = NULL; + return f; } /*************************************************************************/ @@ -123,132 +123,132 @@ static dbFILE *open_db_read(const char *service, const char *filename) * @return dbFile struct */ static dbFILE *open_db_write(const char *service, const char *filename, - uint32 version) + uint32 version) { - dbFILE *f; - int fd; + dbFILE *f; + int fd; #ifdef _WIN32 - char buffer[_MAX_PATH]; - char win32filename[MAXPATHLEN]; + char buffer[_MAX_PATH]; + char win32filename[MAXPATHLEN]; - /* Get the current working directory: */ - if (_getcwd(buffer, _MAX_PATH) == NULL) { - alog("Warning: Unable to set Current working directory"); - } + /* Get the current working directory: */ + if (_getcwd(buffer, _MAX_PATH) == NULL) { + alog("Warning: Unable to set Current working directory"); + } #endif - f = (dbFILE *)scalloc(sizeof(*f), 1); - if (!f) { - log_perror("Can not read %s database %s", service, filename); - return NULL; - } - strscpy(f->filename, filename, sizeof(f->filename)); + f = (dbFILE *)scalloc(sizeof(*f), 1); + if (!f) { + log_perror("Can not read %s database %s", service, filename); + return NULL; + } + strscpy(f->filename, filename, sizeof(f->filename)); #ifndef _WIN32 - filename = f->filename; + filename = f->filename; #else - snprintf(win32filename, sizeof(win32filename), "%s\\%s", buffer, - f->filename); - filename = win32filename; + snprintf(win32filename, sizeof(win32filename), "%s\\%s", buffer, + f->filename); + filename = win32filename; #endif - f->mode = 'w'; - - *f->backupname = 0; - snprintf(f->backupname, sizeof(f->backupname), "%s.save", filename); - if (!*f->backupname || strcmp(f->backupname, filename) == 0) { - int errno_save = errno; - alog("Opening %s database %s for write: Filename too long", - service, filename); - free(f); - errno = errno_save; - return NULL; - } + f->mode = 'w'; + + *f->backupname = 0; + snprintf(f->backupname, sizeof(f->backupname), "%s.save", filename); + if (!*f->backupname || strcmp(f->backupname, filename) == 0) { + int errno_save = errno; + alog("Opening %s database %s for write: Filename too long", + service, filename); + free(f); + errno = errno_save; + return NULL; + } #ifndef _WIN32 - unlink(filename); + unlink(filename); #else - DeleteFile(filename); + DeleteFile(filename); #endif - f->backupfp = fopen(filename, "rb"); + f->backupfp = fopen(filename, "rb"); #ifdef _WIN32 - if (!MoveFileExA(filename, f->backupname, MOVEFILE_COPY_ALLOWED) - && GetLastError() != ENOENT) { - int errno_save = GetLastError(); + if (!MoveFileExA(filename, f->backupname, MOVEFILE_COPY_ALLOWED) + && GetLastError() != ENOENT) { + int errno_save = GetLastError(); #else - if (rename(filename, f->backupname) < 0 && errno != ENOENT) { - int errno_save = errno; + if (rename(filename, f->backupname) < 0 && errno != ENOENT) { + int errno_save = errno; #endif - static int walloped = 0; - if (!walloped) { - walloped++; - ircdproto->SendGlobops(NULL, "Can not back up %s database %s", - service, filename); - } + static int walloped = 0; + if (!walloped) { + walloped++; + ircdproto->SendGlobops(NULL, "Can not back up %s database %s", + service, filename); + } #ifdef _WIN32 - if (debug) { - if (errno == ENOENT) { - alog("debug: Error %d (ENOENT) : the file or directory does not exist", errno, filename); - } else if (errno == EACCES) { - alog("debug: Error %d (EACCES) : error while attempting to access file", errno); - } else { - alog("debug: Error %d", errno); - } - } + if (debug) { + if (errno == ENOENT) { + alog("debug: Error %d (ENOENT) : the file or directory does not exist", errno, filename); + } else if (errno == EACCES) { + alog("debug: Error %d (EACCES) : error while attempting to access file", errno); + } else { + alog("debug: Error %d", errno); + } + } #else - if (debug) { - alog("debug: Error %d", errno); - } + if (debug) { + alog("debug: Error %d", errno); + } #endif - errno = errno_save; - log_perror("Can not back up %s database %s", service, filename); - if (!NoBackupOkay) { - if (f->backupfp) - fclose(f->backupfp); - free(f); - errno = errno_save; - return NULL; - } - *f->backupname = 0; - } + errno = errno_save; + log_perror("Can not back up %s database %s", service, filename); + if (!NoBackupOkay) { + if (f->backupfp) + fclose(f->backupfp); + free(f); + errno = errno_save; + return NULL; + } + *f->backupname = 0; + } #ifndef _WIN32 - unlink(filename); + unlink(filename); #else - DeleteFile(filename); + DeleteFile(filename); #endif - /* Use open() to avoid people sneaking a new file in under us */ + /* Use open() to avoid people sneaking a new file in under us */ #ifndef _WIN32 - fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666); + fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666); #else - fd = open(filename, O_WRONLY | O_CREAT | O_EXCL | _O_BINARY, 0666); + fd = open(filename, O_WRONLY | O_CREAT | O_EXCL | _O_BINARY, 0666); #endif - f->fp = fdopen(fd, "wb"); /* will fail and return NULL if fd < 0 */ - if (!f->fp || !write_file_version(f, version)) { - int errno_save = errno; - static int walloped = 0; - if (!walloped) { - walloped++; - ircdproto->SendGlobops(NULL, "Can't write to %s database %s", - service, filename); - } - errno = errno_save; - log_perror("Can't write to %s database %s", service, filename); - if (f->fp) { - fclose(f->fp); + f->fp = fdopen(fd, "wb"); /* will fail and return NULL if fd < 0 */ + if (!f->fp || !write_file_version(f, version)) { + int errno_save = errno; + static int walloped = 0; + if (!walloped) { + walloped++; + ircdproto->SendGlobops(NULL, "Can't write to %s database %s", + service, filename); + } + errno = errno_save; + log_perror("Can't write to %s database %s", service, filename); + if (f->fp) { + fclose(f->fp); #ifndef _WIN32 - unlink(filename); + unlink(filename); #else - DeleteFile(filename); + DeleteFile(filename); #endif - } - if (*f->backupname && rename(f->backupname, filename) < 0) - log_perror("Cannot restore backup copy of %s", filename); + } + if (*f->backupname && rename(f->backupname, filename) < 0) + log_perror("Cannot restore backup copy of %s", filename); /* Then the Lord said unto Moses, thou shalt free what thou hast malloced - * -- codemastr */ - free(f); - errno = errno_save; - return NULL; - } - return f; + * -- codemastr */ + free(f); + errno = errno_save; + return NULL; + } + return f; } /*************************************************************************/ @@ -268,16 +268,16 @@ static dbFILE *open_db_write(const char *service, const char *filename, * @return dbFile struct */ dbFILE *open_db(const char *service, const char *filename, - const char *mode, uint32 version) + const char *mode, uint32 version) { - if (*mode == 'r') { - return open_db_read(service, filename); - } else if (*mode == 'w') { - return open_db_write(service, filename, version); - } else { - errno = EINVAL; - return NULL; - } + if (*mode == 'r') { + return open_db_read(service, filename); + } else if (*mode == 'w') { + return open_db_write(service, filename, version); + } else { + errno = EINVAL; + return NULL; + } } /*************************************************************************/ @@ -292,47 +292,47 @@ dbFILE *open_db(const char *service, const char *filename, */ void restore_db(dbFILE * f) { - int errno_save = errno; - - if (f->mode == 'w') { - int ok = 0; /* Did we manage to restore the old file? */ - errno = errno_save = 0; - if (*f->backupname && strcmp(f->backupname, f->filename) != 0) { - if (rename(f->backupname, f->filename) == 0) - ok = 1; - } - if (!ok && f->backupfp) { - char buf[1024]; - unsigned int i; - ok = 1; - if (fseek(f->fp, 0, SEEK_SET) < 0) - ok = 0; - while (ok && (i = fread(buf, 1, sizeof(buf), f->backupfp)) > 0) { - if (fwrite(buf, 1, i, f->fp) != i) - ok = 0; - } - if (ok) { - fflush(f->fp); - ftruncate(fileno(f->fp), ftell(f->fp)); - } - } - if (!ok && errno > 0) - log_perror("Unable to restore backup of %s", f->filename); - errno_save = errno; - if (f->backupfp) - fclose(f->backupfp); - if (*f->backupname) + int errno_save = errno; + + if (f->mode == 'w') { + int ok = 0; /* Did we manage to restore the old file? */ + errno = errno_save = 0; + if (*f->backupname && strcmp(f->backupname, f->filename) != 0) { + if (rename(f->backupname, f->filename) == 0) + ok = 1; + } + if (!ok && f->backupfp) { + char buf[1024]; + unsigned int i; + ok = 1; + if (fseek(f->fp, 0, SEEK_SET) < 0) + ok = 0; + while (ok && (i = fread(buf, 1, sizeof(buf), f->backupfp)) > 0) { + if (fwrite(buf, 1, i, f->fp) != i) + ok = 0; + } + if (ok) { + fflush(f->fp); + ftruncate(fileno(f->fp), ftell(f->fp)); + } + } + if (!ok && errno > 0) + log_perror("Unable to restore backup of %s", f->filename); + errno_save = errno; + if (f->backupfp) + fclose(f->backupfp); + if (*f->backupname) #ifndef _WIN32 - unlink(f->backupname); + unlink(f->backupname); #else - DeleteFile(f->backupname); + DeleteFile(f->backupname); #endif - } - fclose(f->fp); - if (!errno_save) - errno_save = errno; - free(f); - errno = errno_save; + } + fclose(f->fp); + if (!errno_save) + errno_save = errno; + free(f); + errno = errno_save; } /*************************************************************************/ @@ -345,18 +345,18 @@ void restore_db(dbFILE * f) */ void close_db(dbFILE * f) { - if (f->mode == 'w' && *f->backupname - && strcmp(f->backupname, f->filename) != 0) { - if (f->backupfp) - fclose(f->backupfp); + if (f->mode == 'w' && *f->backupname + && strcmp(f->backupname, f->filename) != 0) { + if (f->backupfp) + fclose(f->backupfp); #ifndef _WIN32 - unlink(f->backupname); + unlink(f->backupname); #else - DeleteFile(f->backupname); + DeleteFile(f->backupname); #endif - } - fclose(f->fp); - free(f); + } + fclose(f->fp); + free(f); } /*************************************************************************/ @@ -377,14 +377,14 @@ void close_db(dbFILE * f) */ int read_int16(uint16 * ret, dbFILE * f) { - int c1, c2; - - c1 = fgetc(f->fp); - c2 = fgetc(f->fp); - if (c1 == EOF || c2 == EOF) - return -1; - *ret = c1 << 8 | c2; - return 0; + int c1, c2; + + c1 = fgetc(f->fp); + c2 = fgetc(f->fp); + if (c1 == EOF || c2 == EOF) + return -1; + *ret = c1 << 8 | c2; + return 0; } /*************************************************************************/ @@ -398,11 +398,11 @@ int read_int16(uint16 * ret, dbFILE * f) */ int write_int16(uint16 val, dbFILE * f) { - if (fputc((val >> 8) & 0xFF, f->fp) == EOF - || fputc(val & 0xFF, f->fp) == EOF) { - return -1; - } - return 0; + if (fputc((val >> 8) & 0xFF, f->fp) == EOF + || fputc(val & 0xFF, f->fp) == EOF) { + return -1; + } + return 0; } /*************************************************************************/ @@ -416,16 +416,16 @@ int write_int16(uint16 val, dbFILE * f) */ int read_int32(uint32 * ret, dbFILE * f) { - int c1, c2, c3, c4; - - c1 = fgetc(f->fp); - c2 = fgetc(f->fp); - c3 = fgetc(f->fp); - c4 = fgetc(f->fp); - if (c1 == EOF || c2 == EOF || c3 == EOF || c4 == EOF) - return -1; - *ret = c1 << 24 | c2 << 16 | c3 << 8 | c4; - return 0; + int c1, c2, c3, c4; + + c1 = fgetc(f->fp); + c2 = fgetc(f->fp); + c3 = fgetc(f->fp); + c4 = fgetc(f->fp); + if (c1 == EOF || c2 == EOF || c3 == EOF || c4 == EOF) + return -1; + *ret = c1 << 24 | c2 << 16 | c3 << 8 | c4; + return 0; } /*************************************************************************/ @@ -439,15 +439,15 @@ int read_int32(uint32 * ret, dbFILE * f) */ int write_int32(uint32 val, dbFILE * f) { - if (fputc((val >> 24) & 0xFF, f->fp) == EOF) - return -1; - if (fputc((val >> 16) & 0xFF, f->fp) == EOF) - return -1; - if (fputc((val >> 8) & 0xFF, f->fp) == EOF) - return -1; - if (fputc((val) & 0xFF, f->fp) == EOF) - return -1; - return 0; + if (fputc((val >> 24) & 0xFF, f->fp) == EOF) + return -1; + if (fputc((val >> 16) & 0xFF, f->fp) == EOF) + return -1; + if (fputc((val >> 8) & 0xFF, f->fp) == EOF) + return -1; + if (fputc((val) & 0xFF, f->fp) == EOF) + return -1; + return 0; } /*************************************************************************/ @@ -461,13 +461,13 @@ int write_int32(uint32 val, dbFILE * f) */ int read_ptr(void **ret, dbFILE * f) { - int c; + int c; - c = fgetc(f->fp); - if (c == EOF) - return -1; - *ret = (c ? (void *) 1 : (void *) 0); - return 0; + c = fgetc(f->fp); + if (c == EOF) + return -1; + *ret = (c ? (void *) 1 : (void *) 0); + return 0; } /*************************************************************************/ @@ -481,9 +481,9 @@ int read_ptr(void **ret, dbFILE * f) */ int write_ptr(const void *ptr, dbFILE * f) { - if (fputc(ptr ? 1 : 0, f->fp) == EOF) - return -1; - return 0; + if (fputc(ptr ? 1 : 0, f->fp) == EOF) + return -1; + return 0; } /*************************************************************************/ @@ -497,22 +497,22 @@ int write_ptr(const void *ptr, dbFILE * f) */ int read_string(char **ret, dbFILE * f) { - char *s; - uint16 len; - - if (read_int16(&len, f) < 0) - return -1; - if (len == 0) { - *ret = NULL; - return 0; - } - s = (char *)scalloc(len, 1); - if (len != fread(s, 1, len, f->fp)) { - free(s); - return -1; - } - *ret = s; - return 0; + char *s; + uint16 len; + + if (read_int16(&len, f) < 0) + return -1; + if (len == 0) { + *ret = NULL; + return 0; + } + s = (char *)scalloc(len, 1); + if (len != fread(s, 1, len, f->fp)) { + free(s); + return -1; + } + *ret = s; + return 0; } /*************************************************************************/ @@ -526,20 +526,20 @@ int read_string(char **ret, dbFILE * f) */ int write_string(const char *s, dbFILE * f) { - uint32 len; - - if (!s) - return write_int16(0, f); - len = strlen(s); - if (len > 65534) - len = 65534; - if (write_int16((uint16) (len + 1), f) < 0) - return -1; - if (len > 0 && fwrite(s, 1, len, f->fp) != len) - return -1; - if (fputc(0, f->fp) == EOF) - return -1; - return 0; + uint32 len; + + if (!s) + return write_int16(0, f); + len = strlen(s); + if (len > 65534) + len = 65534; + if (write_int16((uint16) (len + 1), f) < 0) + return -1; + if (len > 0 && fwrite(s, 1, len, f->fp) != len) + return -1; + if (fputc(0, f->fp) == EOF) + return -1; + return 0; } /*************************************************************************/ @@ -554,14 +554,14 @@ int write_string(const char *s, dbFILE * f) static void rename_database(const char *name, char *ext) { - char destpath[PATH_MAX]; + char destpath[PATH_MAX]; - snprintf(destpath, sizeof(destpath), "backups/%s.%s", name, ext); - if (rename(name, destpath) != 0) { - alog("Backup of %s failed.", name); - ircdproto->SendGlobops(s_OperServ, "WARNING! Backup of %s failed.", - name); - } + snprintf(destpath, sizeof(destpath), "backups/%s.%s", name, ext); + if (rename(name, destpath) != 0) { + alog("Backup of %s failed.", name); + ircdproto->SendGlobops(s_OperServ, "WARNING! Backup of %s failed.", + name); + } } /*************************************************************************/ @@ -574,72 +574,72 @@ static void rename_database(const char *name, char *ext) static void remove_backups(void) { - char ext[9]; - char path[PATH_MAX]; + char ext[9]; + char path[PATH_MAX]; - time_t t; - struct tm tm; + time_t t; + struct tm tm; - time(&t); - t -= (60 * 60 * 24 * KeepBackups); - tm = *localtime(&t); - strftime(ext, sizeof(ext), "%Y%m%d", &tm); + time(&t); + t -= (60 * 60 * 24 * KeepBackups); + tm = *localtime(&t); + strftime(ext, sizeof(ext), "%Y%m%d", &tm); - snprintf(path, sizeof(path), "backups/%s.%s", NickDBName, ext); + snprintf(path, sizeof(path), "backups/%s.%s", NickDBName, ext); #ifndef _WIN32 - unlink(path); + unlink(path); #else - DeleteFile(path); + DeleteFile(path); #endif - snprintf(path, sizeof(path), "backups/%s.%s", ChanDBName, ext); + snprintf(path, sizeof(path), "backups/%s.%s", ChanDBName, ext); #ifndef _WIN32 - unlink(path); + unlink(path); #else - DeleteFile(path); + DeleteFile(path); #endif - snprintf(path, sizeof(path), "backups/%s.%s", OperDBName, ext); + snprintf(path, sizeof(path), "backups/%s.%s", OperDBName, ext); #ifndef _WIN32 - unlink(path); + unlink(path); #else - DeleteFile(path); + DeleteFile(path); #endif - snprintf(path, sizeof(path), "backups/%s.%s", NewsDBName, ext); + snprintf(path, sizeof(path), "backups/%s.%s", NewsDBName, ext); #ifndef _WIN32 - unlink(path); + unlink(path); #else - DeleteFile(path); + DeleteFile(path); #endif - snprintf(path, sizeof(path), "backups/%s.%s", ExceptionDBName, ext); + snprintf(path, sizeof(path), "backups/%s.%s", ExceptionDBName, ext); #ifndef _WIN32 - unlink(path); + unlink(path); #else - DeleteFile(path); + DeleteFile(path); #endif - if (s_BotServ) { - snprintf(path, sizeof(path), "backups/%s.%s", BotDBName, ext); + if (s_BotServ) { + snprintf(path, sizeof(path), "backups/%s.%s", BotDBName, ext); #ifndef _WIN32 - unlink(path); + unlink(path); #else - DeleteFile(path); + DeleteFile(path); #endif - } - if (s_HostServ) { - snprintf(path, sizeof(path), "backups/%s.%s", HostDBName, ext); + } + if (s_HostServ) { + snprintf(path, sizeof(path), "backups/%s.%s", HostDBName, ext); #ifndef _WIN32 - unlink(path); + unlink(path); #else - DeleteFile(path); + DeleteFile(path); #endif - } - if (NSEmailReg) { - snprintf(path, sizeof(path), "backups/%s.%s", PreNickDBName, ext); + } + if (NSEmailReg) { + snprintf(path, sizeof(path), "backups/%s.%s", PreNickDBName, ext); #ifndef _WIN32 - unlink(path); + unlink(path); #else - DeleteFile(path); + DeleteFile(path); #endif - } + } } /*************************************************************************/ @@ -652,50 +652,50 @@ static void remove_backups(void) void backup_databases(void) { - time_t t; - struct tm tm; + time_t t; + struct tm tm; - if (!KeepBackups) { - return; - } + if (!KeepBackups) { + return; + } - time(&t); - tm = *localtime(&t); + time(&t); + tm = *localtime(&t); - if (!curday) { - curday = tm.tm_yday; - return; - } + if (!curday) { + curday = tm.tm_yday; + return; + } - if (curday != tm.tm_yday) { + if (curday != tm.tm_yday) { - char ext[9]; + char ext[9]; - send_event(EVENT_DB_BACKUP, 1, EVENT_START); - alog("Backing up databases"); + send_event(EVENT_DB_BACKUP, 1, EVENT_START); + alog("Backing up databases"); - remove_backups(); + remove_backups(); - curday = tm.tm_yday; - strftime(ext, sizeof(ext), "%Y%m%d", &tm); + curday = tm.tm_yday; + strftime(ext, sizeof(ext), "%Y%m%d", &tm); - rename_database(NickDBName, ext); - if (s_BotServ) { - rename_database(BotDBName, ext); - } - rename_database(ChanDBName, ext); - if (s_HostServ) { - rename_database(HostDBName, ext); - } - if (NSEmailReg) { - rename_database(PreNickDBName, ext); - } + rename_database(NickDBName, ext); + if (s_BotServ) { + rename_database(BotDBName, ext); + } + rename_database(ChanDBName, ext); + if (s_HostServ) { + rename_database(HostDBName, ext); + } + if (NSEmailReg) { + rename_database(PreNickDBName, ext); + } - rename_database(OperDBName, ext); - rename_database(NewsDBName, ext); - rename_database(ExceptionDBName, ext); - send_event(EVENT_DB_BACKUP, 1, EVENT_STOP); - } + rename_database(OperDBName, ext); + rename_database(NewsDBName, ext); + rename_database(ExceptionDBName, ext); + send_event(EVENT_DB_BACKUP, 1, EVENT_STOP); + } } /*************************************************************************/ @@ -703,55 +703,55 @@ void backup_databases(void) void ModuleDatabaseBackup(const char *dbname) { - time_t t; - struct tm tm; + time_t t; + struct tm tm; - if (!KeepBackups) { - return; - } + if (!KeepBackups) { + return; + } - time(&t); - tm = *localtime(&t); + time(&t); + tm = *localtime(&t); - if (!curday) { - curday = tm.tm_yday; - return; - } + if (!curday) { + curday = tm.tm_yday; + return; + } - if (curday != tm.tm_yday) { + if (curday != tm.tm_yday) { - char ext[9]; + char ext[9]; - if (debug) { - alog("Module Database Backing up %s", dbname); - } - ModuleRemoveBackups(dbname); - curday = tm.tm_yday; - strftime(ext, sizeof(ext), "%Y%m%d", &tm); - rename_database(dbname, ext); - } + if (debug) { + alog("Module Database Backing up %s", dbname); + } + ModuleRemoveBackups(dbname); + curday = tm.tm_yday; + strftime(ext, sizeof(ext), "%Y%m%d", &tm); + rename_database(dbname, ext); + } } /*************************************************************************/ void ModuleRemoveBackups(const char *dbname) { - char ext[9]; - char path[PATH_MAX]; + char ext[9]; + char path[PATH_MAX]; - time_t t; - struct tm tm; + time_t t; + struct tm tm; - time(&t); - t -= (60 * 60 * 24 * KeepBackups); - tm = *localtime(&t); - strftime(ext, sizeof(ext), "%Y%m%d", &tm); + time(&t); + t -= (60 * 60 * 24 * KeepBackups); + tm = *localtime(&t); + strftime(ext, sizeof(ext), "%Y%m%d", &tm); - snprintf(path, sizeof(path), "backups/%s.%s", dbname, ext); + snprintf(path, sizeof(path), "backups/%s.%s", dbname, ext); #ifndef _WIN32 - unlink(path); + unlink(path); #else - DeleteFile(path); + DeleteFile(path); #endif } diff --git a/src/encrypt.c b/src/encrypt.c index 9b68ca9d7..99e77d127 100644 --- a/src/encrypt.c +++ b/src/encrypt.c @@ -19,31 +19,31 @@ Encryption encryption; /******************************************************************************/ void encmodule_encrypt(int (*func) - (const char *src, int len, char *dest, int size)) + (const char *src, int len, char *dest, int size)) { - encryption.encrypt = func; + encryption.encrypt = func; } void encmodule_encrypt_in_place(int (*func) (char *buf, int size)) { - encryption.encrypt_in_place = func; + encryption.encrypt_in_place = func; } void encmodule_encrypt_check_len(int (*func) (int passlen, int bufsize)) { - encryption.encrypt_check_len = func; + encryption.encrypt_check_len = func; } void encmodule_decrypt(int (*func) (const char *src, char *dest, int size)) { - encryption.decrypt = func; + encryption.decrypt = func; } void encmodule_check_password(int (*func) - (const char *plaintext, - const char *password)) + (const char *plaintext, + const char *password)) { - encryption.check_password = func; + encryption.check_password = func; } /******************************************************************************/ @@ -55,10 +55,10 @@ void encmodule_check_password(int (*func) **/ int enc_encrypt(const char *src, int len, char *dest, int size) { - if (encryption.encrypt) { - return encryption.encrypt(src, len, dest, size); - } - return -1; + if (encryption.encrypt) { + return encryption.encrypt(src, len, dest, size); + } + return -1; } /** @@ -68,10 +68,10 @@ int enc_encrypt(const char *src, int len, char *dest, int size) **/ int enc_encrypt_in_place(char *buf, int size) { - if (encryption.encrypt_in_place) { - return encryption.encrypt_in_place(buf, size); - } - return -1; + if (encryption.encrypt_in_place) { + return encryption.encrypt_in_place(buf, size); + } + return -1; } /** @@ -84,10 +84,10 @@ int enc_encrypt_in_place(char *buf, int size) **/ int enc_encrypt_check_len(int passlen, int bufsize) { - if (encryption.encrypt_check_len) { - return encryption.encrypt_check_len(passlen, bufsize); - } - return -1; + if (encryption.encrypt_check_len) { + return encryption.encrypt_check_len(passlen, bufsize); + } + return -1; } /** @@ -98,10 +98,10 @@ int enc_encrypt_check_len(int passlen, int bufsize) **/ int enc_decrypt(const char *src, char *dest, int size) { - if (encryption.decrypt) { - return encryption.decrypt(src, dest, size); - } - return -1; + if (encryption.decrypt) { + return encryption.decrypt(src, dest, size); + } + return -1; } /** @@ -113,10 +113,10 @@ int enc_decrypt(const char *src, char *dest, int size) **/ int enc_check_password(const char *plaintext, const char *password) { - if (encryption.check_password) { - return encryption.check_password(plaintext, password); - } - return -1; + if (encryption.check_password) { + return encryption.check_password(plaintext, password); + } + return -1; } /* EOF */ diff --git a/src/events.c b/src/events.c index 9971da58c..fbb40b4d8 100644 --- a/src/events.c +++ b/src/events.c @@ -20,154 +20,154 @@ EvtHookHash *EVENTHOOKS[MAX_CMD_HASH]; EvtMessage *find_event(const char *name) { - EvtMessage *m; - m = findEventHandler(EVENT, name); - return m; + EvtMessage *m; + m = findEventHandler(EVENT, name); + return m; } EvtHook *find_eventhook(const char *name) { - EvtHook *m; - m = findEventHook(EVENTHOOKS, name); - return m; + EvtHook *m; + m = findEventHook(EVENTHOOKS, name); + return m; } void send_event(const char *name, int argc, ...) { - va_list va; - char *a; - int idx = 0; - char **argv; - - argv = (char **) malloc(sizeof(char *) * argc); - va_start(va, argc); - for (idx = 0; idx < argc; idx++) { - a = va_arg(va, char *); - argv[idx] = sstrdup(a); - } - va_end(va); - - if (debug) - alog("debug: Emitting event \"%s\" (%d args)", name, argc); - - event_process_hook(name, argc, argv); - - /** - * Now that the events have seen the message, free it up - **/ - for (idx = 0; idx < argc; idx++) { - free(argv[idx]); - } - free(argv); + va_list va; + char *a; + int idx = 0; + char **argv; + + argv = (char **) malloc(sizeof(char *) * argc); + va_start(va, argc); + for (idx = 0; idx < argc; idx++) { + a = va_arg(va, char *); + argv[idx] = sstrdup(a); + } + va_end(va); + + if (debug) + alog("debug: Emitting event \"%s\" (%d args)", name, argc); + + event_process_hook(name, argc, argv); + + /** + * Now that the events have seen the message, free it up + **/ + for (idx = 0; idx < argc; idx++) { + free(argv[idx]); + } + free(argv); } void eventprintf(char *fmt, ...) { - va_list args; - char buf[16384]; /* Really huge, to try and avoid truncation */ - char *event; - - va_start(args, fmt); - vsnprintf(buf, sizeof(buf), fmt, args); - event = sstrdup(buf); - event_message_process(event); - va_end(args); - if (event) { - free(event); - } - return; + va_list args; + char buf[16384]; /* Really huge, to try and avoid truncation */ + char *event; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + event = sstrdup(buf); + event_message_process(event); + va_end(args); + if (event) { + free(event); + } + return; } void event_message_process(char *eventbuf) { - int retVal = 0; - EvtMessage *current = NULL; - char source[64]; - char cmd[64]; - char buf[512]; /* Longest legal IRC command line */ - char *s; - int ac; /* Parameters for the command */ - const char **av; - EvtMessage *evm; - - /* zero out the buffers before we do much else */ - *buf = '\0'; - *source = '\0'; - *cmd = '\0'; - - strscpy(buf, eventbuf, sizeof(buf)); - - doCleanBuffer((char *) buf); - - /* Split the buffer into pieces. */ - if (*buf == ':') { - s = strpbrk(buf, " "); - if (!s) - return; - *s = 0; - while (isspace(*++s)); - strscpy(source, buf + 1, sizeof(source)); - memmove(buf, s, strlen(s) + 1); - } else { - *source = 0; - } - if (!*buf) - return; - s = strpbrk(buf, " "); - if (s) { - *s = 0; - while (isspace(*++s)); - } else - s = buf + strlen(buf); - strscpy(cmd, buf, sizeof(cmd)); - ac = split_buf(s, &av, 1); - - /* Do something with the message. */ - evm = find_event(cmd); - if (evm) { - if (evm->func) { - mod_current_module_name = evm->mod_name; - retVal = evm->func(source, ac, av); - mod_current_module_name = NULL; - if (retVal == MOD_CONT) { - current = evm->next; - while (current && current->func && retVal == MOD_CONT) { - mod_current_module_name = current->mod_name; - retVal = current->func(source, ac, av); - mod_current_module_name = NULL; - current = current->next; - } - } - } - } - /* Free argument list we created */ - free(av); + int retVal = 0; + EvtMessage *current = NULL; + char source[64]; + char cmd[64]; + char buf[512]; /* Longest legal IRC command line */ + char *s; + int ac; /* Parameters for the command */ + const char **av; + EvtMessage *evm; + + /* zero out the buffers before we do much else */ + *buf = '\0'; + *source = '\0'; + *cmd = '\0'; + + strscpy(buf, eventbuf, sizeof(buf)); + + doCleanBuffer((char *) buf); + + /* Split the buffer into pieces. */ + if (*buf == ':') { + s = strpbrk(buf, " "); + if (!s) + return; + *s = 0; + while (isspace(*++s)); + strscpy(source, buf + 1, sizeof(source)); + memmove(buf, s, strlen(s) + 1); + } else { + *source = 0; + } + if (!*buf) + return; + s = strpbrk(buf, " "); + if (s) { + *s = 0; + while (isspace(*++s)); + } else + s = buf + strlen(buf); + strscpy(cmd, buf, sizeof(cmd)); + ac = split_buf(s, &av, 1); + + /* Do something with the message. */ + evm = find_event(cmd); + if (evm) { + if (evm->func) { + mod_current_module_name = evm->mod_name; + retVal = evm->func(source, ac, av); + mod_current_module_name = NULL; + if (retVal == MOD_CONT) { + current = evm->next; + while (current && current->func && retVal == MOD_CONT) { + mod_current_module_name = current->mod_name; + retVal = current->func(source, ac, av); + mod_current_module_name = NULL; + current = current->next; + } + } + } + } + /* Free argument list we created */ + free(av); } void event_process_hook(const char *name, int argc, char **argv) { - int retVal = 0; - EvtHook *current = NULL; - EvtHook *evh; - - /* Do something with the message. */ - evh = find_eventhook(name); - if (evh) { - if (evh->func) { - mod_current_module_name = evh->mod_name; - retVal = evh->func(argc, argv); - mod_current_module_name = NULL; - if (retVal == MOD_CONT) { - current = evh->next; - while (current && current->func && retVal == MOD_CONT) { - mod_current_module_name = current->mod_name; - retVal = current->func(argc, argv); - mod_current_module_name = NULL; - current = current->next; - } - } - } - } + int retVal = 0; + EvtHook *current = NULL; + EvtHook *evh; + + /* Do something with the message. */ + evh = find_eventhook(name); + if (evh) { + if (evh->func) { + mod_current_module_name = evh->mod_name; + retVal = evh->func(argc, argv); + mod_current_module_name = NULL; + if (retVal == MOD_CONT) { + current = evh->next; + while (current && current->func && retVal == MOD_CONT) { + mod_current_module_name = current->mod_name; + retVal = current->func(argc, argv); + mod_current_module_name = NULL; + current = current->next; + } + } + } + } } /** @@ -178,14 +178,14 @@ void event_process_hook(const char *name, int argc, char **argv) */ int displayEventMessage(EvtMessage * evm) { - EvtMessage *msg = NULL; - int i = 0; - alog("Displaying message list for %s", evm->name); - for (msg = evm; msg; msg = msg->next) { - alog("%d: 0x%p", ++i, (void *) msg); - } - alog("end"); - return 0; + EvtMessage *msg = NULL; + int i = 0; + alog("Displaying message list for %s", evm->name); + for (msg = evm; msg; msg = msg->next) { + alog("%d: 0x%p", ++i, (void *) msg); + } + alog("end"); + return 0; } /** @@ -196,14 +196,14 @@ int displayEventMessage(EvtMessage * evm) */ int displayEventHook(EvtHook * evh) { - EvtHook *msg = NULL; - int i = 0; - alog("Displaying message list for %s", evh->name); - for (msg = evh; msg; msg = msg->next) { - alog("%d: 0x%p", ++i, (void *) msg); - } - alog("end"); - return 0; + EvtHook *msg = NULL; + int i = 0; + alog("Displaying message list for %s", evh->name); + for (msg = evh; msg; msg = msg->next) { + alog("%d: 0x%p", ++i, (void *) msg); + } + alog("end"); + return 0; } /** @@ -214,21 +214,21 @@ int displayEventHook(EvtHook * evh) */ int displayHookFromHash(char *name) { - EvtHookHash *current = NULL; - int index = 0; - index = CMD_HASH(name); - if (debug > 1) { - alog("debug: trying to display message %s", name); - } - for (current = EVENTHOOKS[index]; current; current = current->next) { - if (stricmp(name, current->name) == 0) { - displayEventHook(current->evh); - } - } - if (debug > 1) { - alog("debug: done displaying message %s", name); - } - return 0; + EvtHookHash *current = NULL; + int index = 0; + index = CMD_HASH(name); + if (debug > 1) { + alog("debug: trying to display message %s", name); + } + for (current = EVENTHOOKS[index]; current; current = current->next) { + if (stricmp(name, current->name) == 0) { + displayEventHook(current->evh); + } + } + if (debug > 1) { + alog("debug: done displaying message %s", name); + } + return 0; } /** @@ -239,21 +239,21 @@ int displayHookFromHash(char *name) */ int displayEvtMessageFromHash(char *name) { - EvtMessageHash *current = NULL; - int index = 0; - index = CMD_HASH(name); - if (debug > 1) { - alog("debug: trying to display message %s", name); - } - for (current = EVENT[index]; current; current = current->next) { - if (stricmp(name, current->name) == 0) { - displayEventMessage(current->evm); - } - } - if (debug > 1) { - alog("debug: done displaying message %s", name); - } - return 0; + EvtMessageHash *current = NULL; + int index = 0; + index = CMD_HASH(name); + if (debug > 1) { + alog("debug: trying to display message %s", name); + } + for (current = EVENT[index]; current; current = current->next) { + if (stricmp(name, current->name) == 0) { + displayEventMessage(current->evm); + } + } + if (debug > 1) { + alog("debug: done displaying message %s", name); + } + return 0; } /******************************************************************************* @@ -267,21 +267,21 @@ int displayEvtMessageFromHash(char *name) * @return a new Message object **/ EvtMessage *createEventHandler(char *name, - int (*func) (const char *source, int ac, - const char **av)) + int (*func) (const char *source, int ac, + const char **av)) { - EvtMessage *evm = NULL; - if (!func) { - return NULL; - } - if ((evm = (EvtMessage *)malloc(sizeof(EvtMessage))) == NULL) { - fatal("Out of memory!"); - } - evm->name = sstrdup(name); - evm->func = func; - evm->mod_name = NULL; - evm->next = NULL; - return evm; + EvtMessage *evm = NULL; + if (!func) { + return NULL; + } + if ((evm = (EvtMessage *)malloc(sizeof(EvtMessage))) == NULL) { + fatal("Out of memory!"); + } + evm->name = sstrdup(name); + evm->func = func; + evm->mod_name = NULL; + evm->next = NULL; + return evm; } /** @@ -292,18 +292,18 @@ EvtMessage *createEventHandler(char *name, **/ EvtHook *createEventHook(const char *name, int (*func) (int argc, char **argv)) { - EvtHook *evh = NULL; - if (!func) { - return NULL; - } - if ((evh = (EvtHook *)malloc(sizeof(EvtHook))) == NULL) { - fatal("Out of memory!"); - } - evh->name = sstrdup(name); - evh->func = func; - evh->mod_name = NULL; - evh->next = NULL; - return evh; + EvtHook *evh = NULL; + if (!func) { + return NULL; + } + if ((evh = (EvtHook *)malloc(sizeof(EvtHook))) == NULL) { + fatal("Out of memory!"); + } + evh->name = sstrdup(name); + evh->func = func; + evh->mod_name = NULL; + evh->next = NULL; + return evh; } /** @@ -314,21 +314,21 @@ EvtHook *createEventHook(const char *name, int (*func) (int argc, char **argv)) * @return NULL if we cant find it, or a pointer to the Message if we can **/ EvtMessage *findEventHandler(EvtMessageHash * msgEvtTable[], - const char *name) + const char *name) { - int idx; - EvtMessageHash *current = NULL; - if (!msgEvtTable || !name) { - return NULL; - } - idx = CMD_HASH(name); - - for (current = msgEvtTable[idx]; current; current = current->next) { - if (stricmp(name, current->name) == 0) { - return current->evm; - } - } - return NULL; + int idx; + EvtMessageHash *current = NULL; + if (!msgEvtTable || !name) { + return NULL; + } + idx = CMD_HASH(name); + + for (current = msgEvtTable[idx]; current; current = current->next) { + if (stricmp(name, current->name) == 0) { + return current->evm; + } + } + return NULL; } /** @@ -340,19 +340,19 @@ EvtMessage *findEventHandler(EvtMessageHash * msgEvtTable[], **/ EvtHook *findEventHook(EvtHookHash * hookEvtTable[], const char *name) { - int idx; - EvtHookHash *current = NULL; - if (!hookEvtTable || !name) { - return NULL; - } - idx = CMD_HASH(name); - - for (current = hookEvtTable[idx]; current; current = current->next) { - if (stricmp(name, current->name) == 0) { - return current->evh; - } - } - return NULL; + int idx; + EvtHookHash *current = NULL; + if (!hookEvtTable || !name) { + return NULL; + } + idx = CMD_HASH(name); + + for (current = hookEvtTable[idx]; current; current = current->next) { + if (stricmp(name, current->name) == 0) { + return current->evh; + } + } + return NULL; } /** @@ -363,11 +363,11 @@ EvtHook *findEventHook(EvtHookHash * hookEvtTable[], const char *name) **/ int addCoreEventHandler(EvtMessageHash * msgEvtTable[], EvtMessage * evm) { - if (!msgEvtTable || !evm) { - return MOD_ERR_PARAMS; - } - evm->core = 1; - return addEventHandler(msgEvtTable, evm); + if (!msgEvtTable || !evm) { + return MOD_ERR_PARAMS; + } + evm->core = 1; + return addEventHandler(msgEvtTable, evm); } /** @@ -378,42 +378,42 @@ int addCoreEventHandler(EvtMessageHash * msgEvtTable[], EvtMessage * evm) **/ int addEventHandler(EvtMessageHash * msgEvtTable[], EvtMessage * evm) { - /* We can assume both param's have been checked by this point.. */ - int index = 0; - EvtMessageHash *current = NULL; - EvtMessageHash *newHash = NULL; - EvtMessageHash *lastHash = NULL; - - if (!msgEvtTable || !evm) { - return MOD_ERR_PARAMS; - } - - index = CMD_HASH(evm->name); - - for (current = msgEvtTable[index]; current; current = current->next) { - if (stricmp(evm->name, current->name) == 0) { /* the msg exist's we are a addHead */ - evm->next = current->evm; - current->evm = evm; - if (debug) - alog("debug: existing msg: (0x%p), new msg (0x%p)", - (void *) evm->next, (void *) evm); - return MOD_ERR_OK; - } - lastHash = current; - } - - if ((newHash = (EvtMessageHash *)malloc(sizeof(EvtMessageHash))) == NULL) { - fatal("Out of memory"); - } - newHash->next = NULL; - newHash->name = sstrdup(evm->name); - newHash->evm = evm; - - if (lastHash == NULL) - msgEvtTable[index] = newHash; - else - lastHash->next = newHash; - return MOD_ERR_OK; + /* We can assume both param's have been checked by this point.. */ + int index = 0; + EvtMessageHash *current = NULL; + EvtMessageHash *newHash = NULL; + EvtMessageHash *lastHash = NULL; + + if (!msgEvtTable || !evm) { + return MOD_ERR_PARAMS; + } + + index = CMD_HASH(evm->name); + + for (current = msgEvtTable[index]; current; current = current->next) { + if (stricmp(evm->name, current->name) == 0) { /* the msg exist's we are a addHead */ + evm->next = current->evm; + current->evm = evm; + if (debug) + alog("debug: existing msg: (0x%p), new msg (0x%p)", + (void *) evm->next, (void *) evm); + return MOD_ERR_OK; + } + lastHash = current; + } + + if ((newHash = (EvtMessageHash *)malloc(sizeof(EvtMessageHash))) == NULL) { + fatal("Out of memory"); + } + newHash->next = NULL; + newHash->name = sstrdup(evm->name); + newHash->evm = evm; + + if (lastHash == NULL) + msgEvtTable[index] = newHash; + else + lastHash->next = newHash; + return MOD_ERR_OK; } /** @@ -424,42 +424,42 @@ int addEventHandler(EvtMessageHash * msgEvtTable[], EvtMessage * evm) **/ int addEventHook(EvtHookHash * hookEvtTable[], EvtHook * evh) { - /* We can assume both param's have been checked by this point.. */ - int index = 0; - EvtHookHash *current = NULL; - EvtHookHash *newHash = NULL; - EvtHookHash *lastHash = NULL; - - if (!hookEvtTable || !evh) { - return MOD_ERR_PARAMS; - } - - index = CMD_HASH(evh->name); - - for (current = hookEvtTable[index]; current; current = current->next) { - if (stricmp(evh->name, current->name) == 0) { /* the msg exist's we are a addHead */ - evh->next = current->evh; - current->evh = evh; - if (debug) - alog("debug: existing msg: (0x%p), new msg (0x%p)", - (void *) evh->next, (void *) evh); - return MOD_ERR_OK; - } - lastHash = current; - } - - if ((newHash = (EvtHookHash *)malloc(sizeof(EvtHookHash))) == NULL) { - fatal("Out of memory"); - } - newHash->next = NULL; - newHash->name = sstrdup(evh->name); - newHash->evh = evh; - - if (lastHash == NULL) - hookEvtTable[index] = newHash; - else - lastHash->next = newHash; - return MOD_ERR_OK; + /* We can assume both param's have been checked by this point.. */ + int index = 0; + EvtHookHash *current = NULL; + EvtHookHash *newHash = NULL; + EvtHookHash *lastHash = NULL; + + if (!hookEvtTable || !evh) { + return MOD_ERR_PARAMS; + } + + index = CMD_HASH(evh->name); + + for (current = hookEvtTable[index]; current; current = current->next) { + if (stricmp(evh->name, current->name) == 0) { /* the msg exist's we are a addHead */ + evh->next = current->evh; + current->evh = evh; + if (debug) + alog("debug: existing msg: (0x%p), new msg (0x%p)", + (void *) evh->next, (void *) evh); + return MOD_ERR_OK; + } + lastHash = current; + } + + if ((newHash = (EvtHookHash *)malloc(sizeof(EvtHookHash))) == NULL) { + fatal("Out of memory"); + } + newHash->next = NULL; + newHash->name = sstrdup(evh->name); + newHash->evh = evh; + + if (lastHash == NULL) + hookEvtTable[index] = newHash; + else + lastHash->next = newHash; + return MOD_ERR_OK; } /** @@ -470,11 +470,11 @@ int addEventHook(EvtHookHash * hookEvtTable[], EvtHook * evh) **/ int addCoreEventHook(EvtHookHash * hookEvtTable[], EvtHook * evh) { - if (!hookEvtTable || !evh) { - return MOD_ERR_PARAMS; - } - evh->core = 1; - return addEventHook(hookEvtTable, evh); + if (!hookEvtTable || !evh) { + return MOD_ERR_PARAMS; + } + evh->core = 1; + return addEventHook(hookEvtTable, evh); } int Module::AddEventHandler(EvtMessage *evm) @@ -514,36 +514,36 @@ int Module::AddEventHook(EvtHook *evh) int Module::DelEventHandler(const char *sname) { - EvtMessage *evm; - int status; - - evm = findEventHandler(EVENT, sname); - if (!evm) { - return MOD_ERR_NOEXIST; - } - - status = delEventHandler(EVENT, evm, this->name.c_str()); - if (debug) { - displayEvtMessageFromHash(evm->name); - } - return status; + EvtMessage *evm; + int status; + + evm = findEventHandler(EVENT, sname); + if (!evm) { + return MOD_ERR_NOEXIST; + } + + status = delEventHandler(EVENT, evm, this->name.c_str()); + if (debug) { + displayEvtMessageFromHash(evm->name); + } + return status; } int Module::DelEventHook(const char *sname) { - EvtHook *evh; - int status; - - evh = findEventHook(EVENTHOOKS, sname); - if (!evh) { - return MOD_ERR_NOEXIST; - } - - status = delEventHook(EVENTHOOKS, evh, this->name.c_str()); - if (debug) { - displayHookFromHash(evh->name); - } - return status; + EvtHook *evh; + int status; + + evh = findEventHook(EVENTHOOKS, sname); + if (!evh) { + return MOD_ERR_NOEXIST; + } + + status = delEventHook(EVENTHOOKS, evh, this->name.c_str()); + if (debug) { + displayHookFromHash(evh->name); + } + return status; } /** @@ -554,68 +554,68 @@ int Module::DelEventHook(const char *sname) * @return MOD_ERR_OK on success, althing else on fail. **/ int delEventHandler(EvtMessageHash * msgEvtTable[], EvtMessage * evm, - const char *mod_name) + const char *mod_name) { - int index = 0; - EvtMessageHash *current = NULL; - EvtMessageHash *lastHash = NULL; - EvtMessage *tail = NULL, *last = NULL; - - if (!evm || !msgEvtTable) { - return MOD_ERR_PARAMS; - } - - index = CMD_HASH(evm->name); - - for (current = msgEvtTable[index]; current; current = current->next) { - if (stricmp(evm->name, current->name) == 0) { - if (!lastHash) { - tail = current->evm; - if (tail->next) { - while (tail) { - if (mod_name && tail->mod_name - && (stricmp(mod_name, tail->mod_name) == 0)) { - if (last) { - last->next = tail->next; - } else { - current->evm = tail->next; - } - return MOD_ERR_OK; - } - last = tail; - tail = tail->next; - } - } else { - msgEvtTable[index] = current->next; - free(current->name); - return MOD_ERR_OK; - } - } else { - tail = current->evm; - if (tail->next) { - while (tail) { - if (mod_name && tail->mod_name - && (stricmp(mod_name, tail->mod_name) == 0)) { - if (last) { - last->next = tail->next; - } else { - current->evm = tail->next; - } - return MOD_ERR_OK; - } - last = tail; - tail = tail->next; - } - } else { - lastHash->next = current->next; - free(current->name); - return MOD_ERR_OK; - } - } - } - lastHash = current; - } - return MOD_ERR_NOEXIST; + int index = 0; + EvtMessageHash *current = NULL; + EvtMessageHash *lastHash = NULL; + EvtMessage *tail = NULL, *last = NULL; + + if (!evm || !msgEvtTable) { + return MOD_ERR_PARAMS; + } + + index = CMD_HASH(evm->name); + + for (current = msgEvtTable[index]; current; current = current->next) { + if (stricmp(evm->name, current->name) == 0) { + if (!lastHash) { + tail = current->evm; + if (tail->next) { + while (tail) { + if (mod_name && tail->mod_name + && (stricmp(mod_name, tail->mod_name) == 0)) { + if (last) { + last->next = tail->next; + } else { + current->evm = tail->next; + } + return MOD_ERR_OK; + } + last = tail; + tail = tail->next; + } + } else { + msgEvtTable[index] = current->next; + free(current->name); + return MOD_ERR_OK; + } + } else { + tail = current->evm; + if (tail->next) { + while (tail) { + if (mod_name && tail->mod_name + && (stricmp(mod_name, tail->mod_name) == 0)) { + if (last) { + last->next = tail->next; + } else { + current->evm = tail->next; + } + return MOD_ERR_OK; + } + last = tail; + tail = tail->next; + } + } else { + lastHash->next = current->next; + free(current->name); + return MOD_ERR_OK; + } + } + } + lastHash = current; + } + return MOD_ERR_NOEXIST; } @@ -627,68 +627,68 @@ int delEventHandler(EvtMessageHash * msgEvtTable[], EvtMessage * evm, * @return MOD_ERR_OK on success, althing else on fail. **/ int delEventHook(EvtHookHash * hookEvtTable[], EvtHook * evh, - const char *mod_name) + const char *mod_name) { - int index = 0; - EvtHookHash *current = NULL; - EvtHookHash *lastHash = NULL; - EvtHook *tail = NULL, *last = NULL; - - if (!evh || !hookEvtTable) { - return MOD_ERR_PARAMS; - } - - index = CMD_HASH(evh->name); - - for (current = hookEvtTable[index]; current; current = current->next) { - if (stricmp(evh->name, current->name) == 0) { - if (!lastHash) { - tail = current->evh; - if (tail->next) { - while (tail) { - if (mod_name && tail->mod_name - && (stricmp(mod_name, tail->mod_name) == 0)) { - if (last) { - last->next = tail->next; - } else { - current->evh = tail->next; - } - return MOD_ERR_OK; - } - last = tail; - tail = tail->next; - } - } else { - hookEvtTable[index] = current->next; - free(current->name); - return MOD_ERR_OK; - } - } else { - tail = current->evh; - if (tail->next) { - while (tail) { - if (mod_name && tail->mod_name - && (stricmp(mod_name, tail->mod_name) == 0)) { - if (last) { - last->next = tail->next; - } else { - current->evh = tail->next; - } - return MOD_ERR_OK; - } - last = tail; - tail = tail->next; - } - } else { - lastHash->next = current->next; - free(current->name); - return MOD_ERR_OK; - } - } - } - lastHash = current; - } - return MOD_ERR_NOEXIST; + int index = 0; + EvtHookHash *current = NULL; + EvtHookHash *lastHash = NULL; + EvtHook *tail = NULL, *last = NULL; + + if (!evh || !hookEvtTable) { + return MOD_ERR_PARAMS; + } + + index = CMD_HASH(evh->name); + + for (current = hookEvtTable[index]; current; current = current->next) { + if (stricmp(evh->name, current->name) == 0) { + if (!lastHash) { + tail = current->evh; + if (tail->next) { + while (tail) { + if (mod_name && tail->mod_name + && (stricmp(mod_name, tail->mod_name) == 0)) { + if (last) { + last->next = tail->next; + } else { + current->evh = tail->next; + } + return MOD_ERR_OK; + } + last = tail; + tail = tail->next; + } + } else { + hookEvtTable[index] = current->next; + free(current->name); + return MOD_ERR_OK; + } + } else { + tail = current->evh; + if (tail->next) { + while (tail) { + if (mod_name && tail->mod_name + && (stricmp(mod_name, tail->mod_name) == 0)) { + if (last) { + last->next = tail->next; + } else { + current->evh = tail->next; + } + return MOD_ERR_OK; + } + last = tail; + tail = tail->next; + } + } else { + lastHash->next = current->next; + free(current->name); + return MOD_ERR_OK; + } + } + } + lastHash = current; + } + return MOD_ERR_NOEXIST; } @@ -699,18 +699,18 @@ int delEventHook(EvtHookHash * hookEvtTable[], EvtHook * evh, **/ int destroyEventHandler(EvtMessage * evm) { - if (!evm) { - return MOD_ERR_PARAMS; - } - if (evm->name) { - free(evm->name); - } - evm->func = NULL; - if (evm->mod_name) { - free(evm->mod_name); - } - evm->next = NULL; - return MOD_ERR_OK; + if (!evm) { + return MOD_ERR_PARAMS; + } + if (evm->name) { + free(evm->name); + } + evm->func = NULL; + if (evm->mod_name) { + free(evm->mod_name); + } + evm->next = NULL; + return MOD_ERR_OK; } /** @@ -720,16 +720,16 @@ int destroyEventHandler(EvtMessage * evm) **/ int destroyEventHook(EvtHook * evh) { - if (!evh) { - return MOD_ERR_PARAMS; - } - if (evh->name) { - free(evh->name); - } - evh->func = NULL; - if (evh->mod_name) { - free(evh->mod_name); - } - evh->next = NULL; - return MOD_ERR_OK; + if (!evh) { + return MOD_ERR_PARAMS; + } + if (evh->name) { + free(evh->name); + } + evh->func = NULL; + if (evh->mod_name) { + free(evh->mod_name); + } + evh->next = NULL; + return MOD_ERR_OK; } diff --git a/src/helpserv.c b/src/helpserv.c index 72f2142c7..3ac81c88e 100644 --- a/src/helpserv.c +++ b/src/helpserv.c @@ -37,7 +37,7 @@ void moduleAddHelpServCmds(void) */ void helpserv_init(void) { - moduleAddHelpServCmds(); + moduleAddHelpServCmds(); } /*************************************************************************/ @@ -50,20 +50,20 @@ void helpserv_init(void) */ void helpserv(User * u, char *buf) { - const char *cmd, *s; + const char *cmd, *s; - cmd = strtok(buf, " "); + cmd = strtok(buf, " "); - if (!cmd) { - return; - } else if (stricmp(cmd, "\1PING") == 0) { - if (!(s = strtok(NULL, ""))) { - s = ""; - } - ircdproto->SendCTCP(findbot(s_HelpServ), u->nick, "PING %s", s); - } else { - mod_run_cmd(s_HelpServ, u, HELPSERV, cmd); - } + if (!cmd) { + return; + } else if (stricmp(cmd, "\1PING") == 0) { + if (!(s = strtok(NULL, ""))) { + s = ""; + } + ircdproto->SendCTCP(findbot(s_HelpServ), u->nick, "PING %s", s); + } else { + mod_run_cmd(s_HelpServ, u, HELPSERV, cmd); + } } /*************************************************************************/ diff --git a/src/hostserv.c b/src/hostserv.c index 36cd99fdc..d34a611a6 100644 --- a/src/hostserv.c +++ b/src/hostserv.c @@ -22,10 +22,10 @@ void load_hs_dbase_v1(dbFILE * f); void load_hs_dbase_v2(dbFILE * f); void load_hs_dbase_v3(dbFILE * f); -HostCore *head = NULL; /* head of the HostCore list */ +HostCore *head = NULL; /* head of the HostCore list */ E int do_hs_sync(NickCore * nc, char *vIdent, char *hostmask, - char *creator, time_t time); + char *creator, time_t time); E void moduleAddHostServCmds(void); @@ -45,24 +45,24 @@ void moduleAddHostServCmds(void) void get_hostserv_stats(long *nrec, long *memuse) { - long count = 0, mem = 0; - HostCore *hc; - - for (hc = head; hc; hc = hc->next) { - count++; - mem += sizeof(*hc); - if (hc->nick) - mem += strlen(hc->nick) + 1; - if (hc->vIdent) - mem += strlen(hc->vIdent) + 1; - if (hc->vHost) - mem += strlen(hc->vHost) + 1; - if (hc->creator) - mem += strlen(hc->creator) + 1; - } - - *nrec = count; - *memuse = mem; + long count = 0, mem = 0; + HostCore *hc; + + for (hc = head; hc; hc = hc->next) { + count++; + mem += sizeof(*hc); + if (hc->nick) + mem += strlen(hc->nick) + 1; + if (hc->vIdent) + mem += strlen(hc->vIdent) + 1; + if (hc->vHost) + mem += strlen(hc->vHost) + 1; + if (hc->creator) + mem += strlen(hc->creator) + 1; + } + + *nrec = count; + *memuse = mem; } /*************************************************************************/ @@ -73,9 +73,9 @@ void get_hostserv_stats(long *nrec, long *memuse) */ void hostserv_init(void) { - if (s_HostServ) { - moduleAddHostServCmds(); - } + if (s_HostServ) { + moduleAddHostServCmds(); + } } /*************************************************************************/ @@ -88,33 +88,33 @@ void hostserv_init(void) */ void hostserv(User * u, char *buf) { - const char *cmd, *s; - - cmd = strtok(buf, " "); - - if (!cmd) { - return; - } else if (stricmp(cmd, "\1PING") == 0) { - if (!(s = strtok(NULL, ""))) { - s = ""; - } - ircdproto->SendCTCP(findbot(s_HostServ), u->nick, "PING %s", s); - } else { - if (ircd->vhost) { - mod_run_cmd(s_HostServ, u, HOSTSERV, cmd); - } else { - notice_lang(s_HostServ, u, SERVICE_OFFLINE, s_HostServ); - } - } + const char *cmd, *s; + + cmd = strtok(buf, " "); + + if (!cmd) { + return; + } else if (stricmp(cmd, "\1PING") == 0) { + if (!(s = strtok(NULL, ""))) { + s = ""; + } + ircdproto->SendCTCP(findbot(s_HostServ), u->nick, "PING %s", s); + } else { + if (ircd->vhost) { + mod_run_cmd(s_HostServ, u, HOSTSERV, cmd); + } else { + notice_lang(s_HostServ, u, SERVICE_OFFLINE, s_HostServ); + } + } } /*************************************************************************/ -/* Start of Linked List routines */ +/* Start of Linked List routines */ /*************************************************************************/ HostCore *hostCoreListHead() { - return head; + return head; } /** @@ -128,43 +128,43 @@ HostCore *hostCoreListHead() * @return HostCore */ HostCore *createHostCorelist(HostCore * next, char *nick, char *vIdent, - char *vHost, const char *creator, int32 tmp_time) + char *vHost, const char *creator, int32 tmp_time) { - next = (HostCore *)malloc(sizeof(HostCore)); - if (next == NULL) { - ircdproto->SendGlobops(s_HostServ, - "Unable to allocate memory to create the vHost LL, problems i sense.."); - } else { - next->nick = (char *)malloc(sizeof(char) * strlen(nick) + 1); - next->vHost = (char *)malloc(sizeof(char) * strlen(vHost) + 1); - next->creator = (char *)malloc(sizeof(char) * strlen(creator) + 1); - if (vIdent) - next->vIdent = (char *)malloc(sizeof(char) * strlen(vIdent) + 1); - if ((next->nick == NULL) || (next->vHost == NULL) - || (next->creator == NULL)) { - ircdproto->SendGlobops(s_HostServ, - "Unable to allocate memory to create the vHost LL, problems i sense.."); - return NULL; - } - strcpy(next->nick, nick); - strcpy(next->vHost, vHost); - strcpy(next->creator, creator); - if (vIdent) { - if ((next->vIdent == NULL)) { - ircdproto->SendGlobops(s_HostServ, - "Unable to allocate memory to create the vHost LL, problems i sense.."); - return NULL; - } - strcpy(next->vIdent, vIdent); - } else { - next->vIdent = NULL; - } - next->time = tmp_time; - next->next = NULL; - return next; - } - return NULL; + next = (HostCore *)malloc(sizeof(HostCore)); + if (next == NULL) { + ircdproto->SendGlobops(s_HostServ, + "Unable to allocate memory to create the vHost LL, problems i sense.."); + } else { + next->nick = (char *)malloc(sizeof(char) * strlen(nick) + 1); + next->vHost = (char *)malloc(sizeof(char) * strlen(vHost) + 1); + next->creator = (char *)malloc(sizeof(char) * strlen(creator) + 1); + if (vIdent) + next->vIdent = (char *)malloc(sizeof(char) * strlen(vIdent) + 1); + if ((next->nick == NULL) || (next->vHost == NULL) + || (next->creator == NULL)) { + ircdproto->SendGlobops(s_HostServ, + "Unable to allocate memory to create the vHost LL, problems i sense.."); + return NULL; + } + strcpy(next->nick, nick); + strcpy(next->vHost, vHost); + strcpy(next->creator, creator); + if (vIdent) { + if ((next->vIdent == NULL)) { + ircdproto->SendGlobops(s_HostServ, + "Unable to allocate memory to create the vHost LL, problems i sense.."); + return NULL; + } + strcpy(next->vIdent, vIdent); + } else { + next->vIdent = NULL; + } + next->time = tmp_time; + next->next = NULL; + return next; + } + return NULL; } /*************************************************************************/ @@ -178,177 +178,177 @@ HostCore *createHostCorelist(HostCore * next, char *nick, char *vIdent, */ HostCore *findHostCore(HostCore * phead, char *nick, bool* found) { - HostCore *previous, *current; - - *found = false; - current = phead; - previous = current; - - if (!nick) { - return NULL; - } - - while (current != NULL) { - if (stricmp(nick, current->nick) == 0) { - *found = true; - break; - } else if (stricmp(nick, current->nick) < 0) { - /* we know were not gonna find it now.... */ - break; - } else { - previous = current; - current = current->next; - } - } - if (current == phead) { - return NULL; - } else { - return previous; - } + HostCore *previous, *current; + + *found = false; + current = phead; + previous = current; + + if (!nick) { + return NULL; + } + + while (current != NULL) { + if (stricmp(nick, current->nick) == 0) { + *found = true; + break; + } else if (stricmp(nick, current->nick) < 0) { + /* we know were not gonna find it now.... */ + break; + } else { + previous = current; + current = current->next; + } + } + if (current == phead) { + return NULL; + } else { + return previous; + } } /*************************************************************************/ HostCore *insertHostCore(HostCore * phead, HostCore * prev, char *nick, - char *vIdent, char *vHost, const char *creator, - int32 tmp_time) + char *vIdent, char *vHost, const char *creator, + int32 tmp_time) { - HostCore *newCore, *tmp; - - if (!nick || !vHost || !creator) { - return NULL; - } - - newCore = (HostCore *)malloc(sizeof(HostCore)); - if (newCore == NULL) { - ircdproto->SendGlobops(s_HostServ, - "Unable to allocate memory to insert into the vHost LL, problems i sense.."); - return NULL; - } else { - newCore->nick = (char *)malloc(sizeof(char) * strlen(nick) + 1); - newCore->vHost = (char *)malloc(sizeof(char) * strlen(vHost) + 1); - newCore->creator = (char *)malloc(sizeof(char) * strlen(creator) + 1); - if (vIdent) - newCore->vIdent = (char *)malloc(sizeof(char) * strlen(vIdent) + 1); - if ((newCore->nick == NULL) || (newCore->vHost == NULL) - || (newCore->creator == NULL)) { - ircdproto->SendGlobops(s_HostServ, - "Unable to allocate memory to create the vHost LL, problems i sense.."); - return NULL; - } - strcpy(newCore->nick, nick); - strcpy(newCore->vHost, vHost); - strcpy(newCore->creator, creator); - if (vIdent) { - if ((newCore->vIdent == NULL)) { - ircdproto->SendGlobops(s_HostServ, - "Unable to allocate memory to create the vHost LL, problems i sense.."); - return NULL; - } - strcpy(newCore->vIdent, vIdent); - } else { - newCore->vIdent = NULL; - } - newCore->time = tmp_time; - if (prev == NULL) { - tmp = phead; - phead = newCore; - newCore->next = tmp; - } else { - tmp = prev->next; - prev->next = newCore; - newCore->next = tmp; - } - } - return phead; + HostCore *newCore, *tmp; + + if (!nick || !vHost || !creator) { + return NULL; + } + + newCore = (HostCore *)malloc(sizeof(HostCore)); + if (newCore == NULL) { + ircdproto->SendGlobops(s_HostServ, + "Unable to allocate memory to insert into the vHost LL, problems i sense.."); + return NULL; + } else { + newCore->nick = (char *)malloc(sizeof(char) * strlen(nick) + 1); + newCore->vHost = (char *)malloc(sizeof(char) * strlen(vHost) + 1); + newCore->creator = (char *)malloc(sizeof(char) * strlen(creator) + 1); + if (vIdent) + newCore->vIdent = (char *)malloc(sizeof(char) * strlen(vIdent) + 1); + if ((newCore->nick == NULL) || (newCore->vHost == NULL) + || (newCore->creator == NULL)) { + ircdproto->SendGlobops(s_HostServ, + "Unable to allocate memory to create the vHost LL, problems i sense.."); + return NULL; + } + strcpy(newCore->nick, nick); + strcpy(newCore->vHost, vHost); + strcpy(newCore->creator, creator); + if (vIdent) { + if ((newCore->vIdent == NULL)) { + ircdproto->SendGlobops(s_HostServ, + "Unable to allocate memory to create the vHost LL, problems i sense.."); + return NULL; + } + strcpy(newCore->vIdent, vIdent); + } else { + newCore->vIdent = NULL; + } + newCore->time = tmp_time; + if (prev == NULL) { + tmp = phead; + phead = newCore; + newCore->next = tmp; + } else { + tmp = prev->next; + prev->next = newCore; + newCore->next = tmp; + } + } + return phead; } /*************************************************************************/ HostCore *deleteHostCore(HostCore * phead, HostCore * prev) { - HostCore *tmp; - - if (prev == NULL) { - tmp = phead; - phead = phead->next; - } else { - tmp = prev->next; - prev->next = tmp->next; - } - free(tmp->vHost); - free(tmp->nick); - free(tmp->creator); - if (tmp->vIdent) { - free(tmp->vIdent); - } - free(tmp); - return phead; + HostCore *tmp; + + if (prev == NULL) { + tmp = phead; + phead = phead->next; + } else { + tmp = prev->next; + prev->next = tmp->next; + } + free(tmp->vHost); + free(tmp->nick); + free(tmp->creator); + if (tmp->vIdent) { + free(tmp->vIdent); + } + free(tmp); + return phead; } /*************************************************************************/ void addHostCore(char *nick, char *vIdent, char *vhost, const char *creator, - int32 tmp_time) + int32 tmp_time) { - HostCore *tmp; - bool found = false; - - if (head == NULL) { - head = - createHostCorelist(head, nick, vIdent, vhost, creator, - tmp_time); - } else { - tmp = findHostCore(head, nick, &found); - if (!found) { - head = - insertHostCore(head, tmp, nick, vIdent, vhost, creator, - tmp_time); - } else { - head = deleteHostCore(head, tmp); /* delete the old entry */ - addHostCore(nick, vIdent, vhost, creator, tmp_time); /* recursive call to add new entry */ - } - } + HostCore *tmp; + bool found = false; + + if (head == NULL) { + head = + createHostCorelist(head, nick, vIdent, vhost, creator, + tmp_time); + } else { + tmp = findHostCore(head, nick, &found); + if (!found) { + head = + insertHostCore(head, tmp, nick, vIdent, vhost, creator, + tmp_time); + } else { + head = deleteHostCore(head, tmp); /* delete the old entry */ + addHostCore(nick, vIdent, vhost, creator, tmp_time); /* recursive call to add new entry */ + } + } } /*************************************************************************/ char *getvHost(char *nick) { - HostCore *tmp; - bool found = false; - tmp = findHostCore(head, nick, &found); - if (found) { - if (tmp == NULL) - return head->vHost; - else - return tmp->next->vHost; - } - return NULL; + HostCore *tmp; + bool found = false; + tmp = findHostCore(head, nick, &found); + if (found) { + if (tmp == NULL) + return head->vHost; + else + return tmp->next->vHost; + } + return NULL; } /*************************************************************************/ char *getvIdent(char *nick) { - HostCore *tmp; - bool found = false; - tmp = findHostCore(head, nick, &found); - if (found) { - if (tmp == NULL) - return head->vIdent; - else - return tmp->next->vIdent; - } - return NULL; + HostCore *tmp; + bool found = false; + tmp = findHostCore(head, nick, &found); + if (found) { + if (tmp == NULL) + return head->vIdent; + else + return tmp->next->vIdent; + } + return NULL; } /*************************************************************************/ void delHostCore(char *nick) { - HostCore *tmp; - bool found = false; - tmp = findHostCore(head, nick, &found); - if (found) { - head = deleteHostCore(head, tmp); - } + HostCore *tmp; + bool found = false; + tmp = findHostCore(head, nick, &found); + if (found) { + head = deleteHostCore(head, tmp); + } } @@ -359,151 +359,151 @@ void delHostCore(char *nick) /* Start of Load/Save routines */ /*************************************************************************/ #define SAFE(x) do { \ - if ((x) < 0) { \ + if ((x) < 0) { \ if (!forceload) \ - fatal("Read error on %s", HostDBName); \ + fatal("Read error on %s", HostDBName); \ failed = 1; \ break; \ - } \ + } \ } while (0) void load_hs_dbase(void) { - dbFILE *f; - int ver; - - if (!(f = open_db(s_HostServ, HostDBName, "r", HOST_VERSION))) { - return; - } - ver = get_file_version(f); - - if (ver == 1) { - load_hs_dbase_v1(f); - } else if (ver == 2) { - load_hs_dbase_v2(f); - } else if (ver == 3) { - load_hs_dbase_v3(f); - } - close_db(f); + dbFILE *f; + int ver; + + if (!(f = open_db(s_HostServ, HostDBName, "r", HOST_VERSION))) { + return; + } + ver = get_file_version(f); + + if (ver == 1) { + load_hs_dbase_v1(f); + } else if (ver == 2) { + load_hs_dbase_v2(f); + } else if (ver == 3) { + load_hs_dbase_v3(f); + } + close_db(f); } void load_hs_dbase_v1(dbFILE * f) { - int c; - int failed = 0; - int32 tmp; - - char *nick; - char *vHost; - - tmp = time(NULL); - - while (!failed && (c = getc_db(f)) == 1) { - - if (c == 1) { - SAFE(read_string(&nick, f)); - SAFE(read_string(&vHost, f)); - addHostCore(nick, NULL, vHost, "Unknown", tmp); /* could get a speed increase by not searching the list */ - free(nick); /* as we know the db is in alphabetical order... */ - free(vHost); - } else { - fatal("Invalid format in %s %d", HostDBName, c); - } - } + int c; + int failed = 0; + int32 tmp; + + char *nick; + char *vHost; + + tmp = time(NULL); + + while (!failed && (c = getc_db(f)) == 1) { + + if (c == 1) { + SAFE(read_string(&nick, f)); + SAFE(read_string(&vHost, f)); + addHostCore(nick, NULL, vHost, "Unknown", tmp); /* could get a speed increase by not searching the list */ + free(nick); /* as we know the db is in alphabetical order... */ + free(vHost); + } else { + fatal("Invalid format in %s %d", HostDBName, c); + } + } } void load_hs_dbase_v2(dbFILE * f) { - int c; - int failed = 0; - - char *nick; - char *vHost; - char *creator; - uint32 time; - - while (!failed && (c = getc_db(f)) == 1) { - - if (c == 1) { - SAFE(read_string(&nick, f)); - SAFE(read_string(&vHost, f)); - SAFE(read_string(&creator, f)); - SAFE(read_int32(&time, f)); - addHostCore(nick, NULL, vHost, creator, time); /* could get a speed increase by not searching the list */ - free(nick); /* as we know the db is in alphabetical order... */ - free(vHost); - free(creator); - } else { - fatal("Invalid format in %s %d", HostDBName, c); - } - } + int c; + int failed = 0; + + char *nick; + char *vHost; + char *creator; + uint32 time; + + while (!failed && (c = getc_db(f)) == 1) { + + if (c == 1) { + SAFE(read_string(&nick, f)); + SAFE(read_string(&vHost, f)); + SAFE(read_string(&creator, f)); + SAFE(read_int32(&time, f)); + addHostCore(nick, NULL, vHost, creator, time); /* could get a speed increase by not searching the list */ + free(nick); /* as we know the db is in alphabetical order... */ + free(vHost); + free(creator); + } else { + fatal("Invalid format in %s %d", HostDBName, c); + } + } } void load_hs_dbase_v3(dbFILE * f) { - int c; - int failed = 0; - - char *nick; - char *vHost; - char *creator; - char *vIdent; - uint32 time; - - while (!failed && (c = getc_db(f)) == 1) { - if (c == 1) { - SAFE(read_string(&nick, f)); - SAFE(read_string(&vIdent, f)); - SAFE(read_string(&vHost, f)); - SAFE(read_string(&creator, f)); - SAFE(read_int32(&time, f)); - addHostCore(nick, vIdent, vHost, creator, time); /* could get a speed increase by not searching the list */ - free(nick); /* as we know the db is in alphabetical order... */ - free(vHost); - free(creator); - free(vIdent); - } else { - fatal("Invalid format in %s %d", HostDBName, c); - } - } + int c; + int failed = 0; + + char *nick; + char *vHost; + char *creator; + char *vIdent; + uint32 time; + + while (!failed && (c = getc_db(f)) == 1) { + if (c == 1) { + SAFE(read_string(&nick, f)); + SAFE(read_string(&vIdent, f)); + SAFE(read_string(&vHost, f)); + SAFE(read_string(&creator, f)); + SAFE(read_int32(&time, f)); + addHostCore(nick, vIdent, vHost, creator, time); /* could get a speed increase by not searching the list */ + free(nick); /* as we know the db is in alphabetical order... */ + free(vHost); + free(creator); + free(vIdent); + } else { + fatal("Invalid format in %s %d", HostDBName, c); + } + } } #undef SAFE /*************************************************************************/ #define SAFE(x) do { \ - if ((x) < 0) { \ + if ((x) < 0) { \ restore_db(f); \ log_perror("Write error on %s", HostDBName); \ if (time(NULL) - lastwarn > WarningTimeout) { \ - ircdproto->SendGlobops(NULL, "Write error on %s: %s", HostDBName, \ + ircdproto->SendGlobops(NULL, "Write error on %s: %s", HostDBName, \ strerror(errno)); \ - lastwarn = time(NULL); \ + lastwarn = time(NULL); \ } \ return; \ - } \ + } \ } while (0) void save_hs_dbase(void) { - dbFILE *f; - static time_t lastwarn = 0; - HostCore *current; - - if (!(f = open_db(s_HostServ, HostDBName, "w", HOST_VERSION))) - return; - - current = head; - while (current != NULL) { - SAFE(write_int8(1, f)); - SAFE(write_string(current->nick, f)); - SAFE(write_string(current->vIdent, f)); - SAFE(write_string(current->vHost, f)); - SAFE(write_string(current->creator, f)); - SAFE(write_int32(current->time, f)); - current = current->next; - } - SAFE(write_int8(0, f)); - close_db(f); + dbFILE *f; + static time_t lastwarn = 0; + HostCore *current; + + if (!(f = open_db(s_HostServ, HostDBName, "w", HOST_VERSION))) + return; + + current = head; + while (current != NULL) { + SAFE(write_int8(1, f)); + SAFE(write_string(current->nick, f)); + SAFE(write_string(current->vIdent, f)); + SAFE(write_string(current->vHost, f)); + SAFE(write_string(current->creator, f)); + SAFE(write_int32(current->time, f)); + current = current->next; + } + SAFE(write_int8(0, f)); + close_db(f); } @@ -517,74 +517,74 @@ void save_hs_dbase(void) /*************************************************************************/ int do_hs_sync(NickCore * nc, char *vIdent, char *hostmask, char *creator, - time_t time) + time_t time) { - int i; - NickAlias *na; - - for (i = 0; i < nc->aliases.count; i++) { - na = (NickAlias *)nc->aliases.list[i]; - addHostCore(na->nick, vIdent, hostmask, creator, time); - } - return MOD_CONT; + int i; + NickAlias *na; + + for (i = 0; i < nc->aliases.count; i++) { + na = (NickAlias *)nc->aliases.list[i]; + addHostCore(na->nick, vIdent, hostmask, creator, time); + } + return MOD_CONT; } /*************************************************************************/ int do_on_id(User * u) -{ /* we've assumed that the user exists etc.. */ - char *vHost; /* as were only gonna call this from nsid routine */ - char *vIdent; - vHost = getvHost(u->nick); - vIdent = getvIdent(u->nick); - if (vHost != NULL) { - if (vIdent) { - notice_lang(s_HostServ, u, HOST_IDENT_ACTIVATED, vIdent, - vHost); - } else { - notice_lang(s_HostServ, u, HOST_ACTIVATED, vHost); - } - ircdproto->SendVhost(u->nick, vIdent, vHost); - if (ircd->vhost) { - u->vhost = sstrdup(vHost); - } - if (ircd->vident) { - if (vIdent) - u->vident = sstrdup(vIdent); - } - set_lastmask(u); - } - return MOD_CONT; +{ /* we've assumed that the user exists etc.. */ + char *vHost; /* as were only gonna call this from nsid routine */ + char *vIdent; + vHost = getvHost(u->nick); + vIdent = getvIdent(u->nick); + if (vHost != NULL) { + if (vIdent) { + notice_lang(s_HostServ, u, HOST_IDENT_ACTIVATED, vIdent, + vHost); + } else { + notice_lang(s_HostServ, u, HOST_ACTIVATED, vHost); + } + ircdproto->SendVhost(u->nick, vIdent, vHost); + if (ircd->vhost) { + u->vhost = sstrdup(vHost); + } + if (ircd->vident) { + if (vIdent) + u->vident = sstrdup(vIdent); + } + set_lastmask(u); + } + return MOD_CONT; } /*************************************************************************/ int is_host_setter(User * u) { - int i, j; - NickAlias *na; - - if (is_services_oper(u)) { - return 1; - } - if (!nick_identified(u)) { - return 0; - } - - /* Look through all user's aliases (0000412) */ - for (i = 0; i < u->na->nc->aliases.count; i++) { - na = (NickAlias *)u->na->nc->aliases.list[i]; - for (j = 0; j < HostNumber; j++) { - if (stricmp(HostSetters[j], na->nick) == 0) { - return 1; - } - } - } - - return 0; + int i, j; + NickAlias *na; + + if (is_services_oper(u)) { + return 1; + } + if (!nick_identified(u)) { + return 0; + } + + /* Look through all user's aliases (0000412) */ + for (i = 0; i < u->na->nc->aliases.count; i++) { + na = (NickAlias *)u->na->nc->aliases.list[i]; + for (j = 0; j < HostNumber; j++) { + if (stricmp(HostSetters[j], na->nick) == 0) { + return 1; + } + } + } + + return 0; } int is_host_remover(User * u) { - return is_host_setter(u); /* only here incase we want to split them up later */ + return is_host_setter(u); /* only here incase we want to split them up later */ } /* @@ -592,13 +592,13 @@ int is_host_remover(User * u) */ void set_lastmask(User * u) { - if (u->na->last_usermask) - free(u->na->last_usermask); - - u->na->last_usermask = - (char *)smalloc(strlen(common_get_vident(u)) + - strlen(common_get_vhost(u)) + 2); - sprintf(u->na->last_usermask, "%s@%s", common_get_vident(u), - common_get_vhost(u)); + if (u->na->last_usermask) + free(u->na->last_usermask); + + u->na->last_usermask = + (char *)smalloc(strlen(common_get_vident(u)) + + strlen(common_get_vhost(u)) + 2); + sprintf(u->na->last_usermask, "%s@%s", common_get_vident(u), + common_get_vhost(u)); } diff --git a/src/init.c b/src/init.c index ce3e7c4f3..3e4f2ed72 100644 --- a/src/init.c +++ b/src/init.c @@ -24,15 +24,15 @@ extern void moduleAddIRCDMsgs(void); void introduce_user(const char *user) { - /* Watch out for infinite loops... */ + /* Watch out for infinite loops... */ #define LTSIZE 20 - static int lasttimes[LTSIZE]; - if (lasttimes[0] >= time(NULL) - 3) - fatal("introduce_user() loop detected"); - memmove(lasttimes, lasttimes + 1, sizeof(lasttimes) - sizeof(int)); - lasttimes[LTSIZE - 1] = time(NULL); + static int lasttimes[LTSIZE]; + if (lasttimes[0] >= time(NULL) - 3) + fatal("introduce_user() loop detected"); + memmove(lasttimes, lasttimes + 1, sizeof(lasttimes) - sizeof(int)); + lasttimes[LTSIZE - 1] = time(NULL); #undef LTSIZE - /* We make the bots go online */ + /* We make the bots go online */ BotInfo *bi; int i; @@ -56,23 +56,23 @@ void introduce_user(const char *user) static int set_group(void) { #if defined(RUNGROUP) && defined(HAVE_SETGRENT) - struct group *gr; - - setgrent(); - while ((gr = getgrent()) != NULL) { - if (strcmp(gr->gr_name, RUNGROUP) == 0) - break; - } - endgrent(); - if (gr) { - setgid(gr->gr_gid); - return 0; - } else { - alog("Unknown group `%s'\n", RUNGROUP); - return -1; - } + struct group *gr; + + setgrent(); + while ((gr = getgrent()) != NULL) { + if (strcmp(gr->gr_name, RUNGROUP) == 0) + break; + } + endgrent(); + if (gr) { + setgid(gr->gr_gid); + return 0; + } else { + alog("Unknown group `%s'\n", RUNGROUP); + return -1; + } #else - return 0; + return 0; #endif } @@ -86,33 +86,33 @@ static int set_group(void) static int parse_dir_options(int ac, char **av) { - int i; - char *s; - - for (i = 1; i < ac; i++) { - s = av[i]; - if (*s == '-') { - s++; - if (strcmp(s, "dir") == 0) { - if (++i >= ac) { - fprintf(stderr, "-dir requires a parameter\n"); - return -1; - } - services_dir = av[i]; - } else if (strcmp(s, "log") == 0) { - if (++i >= ac) { - fprintf(stderr, "-log requires a parameter\n"); - return -1; - } - log_filename = av[i]; - } else if (strcmp(s, "version") == 0) { - fprintf(stdout, "Anope-%s %s -- %s\n", version_number, - version_flags, version_build); - exit(EXIT_SUCCESS); - } - } - } - return 0; + int i; + char *s; + + for (i = 1; i < ac; i++) { + s = av[i]; + if (*s == '-') { + s++; + if (strcmp(s, "dir") == 0) { + if (++i >= ac) { + fprintf(stderr, "-dir requires a parameter\n"); + return -1; + } + services_dir = av[i]; + } else if (strcmp(s, "log") == 0) { + if (++i >= ac) { + fprintf(stderr, "-log requires a parameter\n"); + return -1; + } + log_filename = av[i]; + } else if (strcmp(s, "version") == 0) { + fprintf(stdout, "Anope-%s %s -- %s\n", version_number, + version_flags, version_build); + exit(EXIT_SUCCESS); + } + } + } + return 0; } /*************************************************************************/ @@ -123,179 +123,179 @@ static int parse_dir_options(int ac, char **av) static int parse_options(int ac, char **av) { - int i; - char *s, *t; - - for (i = 1; i < ac; i++) { - s = av[i]; - if (*s == '-') { - s++; - if (strcmp(s, "remote") == 0) { - if (++i >= ac) { - fprintf(stderr, "-remote requires hostname[:port]\n"); - return -1; - } - s = av[i]; - t = strchr(s, ':'); - if (t) { - int portnum; - *t++ = 0; - portnum = atoi(t); - if ((portnum > 0) && (portnum < 65535)) - RemotePort = portnum; - else { - fprintf(stderr, - "-remote: Port numbers must be in the range 1..65535. Using default.\n"); - return -1; - } - } - RemoteServer = s; - } else if (strcmp(s, "local") == 0) { - if (++i >= ac) { - fprintf(stderr, - "-local requires hostname or [hostname]:[port]\n"); - return -1; - } - s = av[i]; - t = strchr(s, ':'); - if (t) { - int portnum; - *t++ = 0; - portnum = atoi(t); - if ((portnum >= 0) && (portnum < 65535)) - LocalPort = portnum; - else { - fprintf(stderr, - "-local: Port numbers must be in the range 1..65535 or 0. Using default.\n"); - return -1; - } - } - LocalHost = s; - } else if (strcmp(s, "name") == 0) { - if (++i >= ac) { - fprintf(stderr, "-name requires a parameter\n"); - return -1; - } - ServerName = av[i]; - } else if (strcmp(s, "desc") == 0) { - if (++i >= ac) { - fprintf(stderr, "-desc requires a parameter\n"); - return -1; - } - ServerDesc = av[i]; - } else if (strcmp(s, "user") == 0) { - if (++i >= ac) { - fprintf(stderr, "-user requires a parameter\n"); - return -1; - } - ServiceUser = av[i]; - } else if (strcmp(s, "host") == 0) { - if (++i >= ac) { - fprintf(stderr, "-host requires a parameter\n"); - return -1; - } - ServiceHost = av[i]; - } else if (strcmp(s, "dir") == 0) { - /* Handled by parse_dir_options() */ - i++; /* Skip parameter */ - } else if (strcmp(s, "log") == 0) { - /* Handled by parse_dir_options(), too */ - i++; /* Skip parameter */ - } else if (strcmp(s, "update") == 0) { - if (++i >= ac) { - fprintf(stderr, "-update requires a parameter\n"); - return -1; - } - s = av[i]; - if (atoi(s) <= 0) { - fprintf(stderr, - "-update: number of seconds must be positive"); - return -1; - } else - UpdateTimeout = atol(s); - } else if (strcmp(s, "expire") == 0) { - if (++i >= ac) { - fprintf(stderr, "-expire requires a parameter\n"); - return -1; - } - s = av[i]; - if (atoi(s) <= 0) { - fprintf(stderr, - "-expire: number of seconds must be positive\n"); - return -1; - } else - ExpireTimeout = atol(s); - } else if (strcmp(s, "debug") == 0) { - debug++; - } else if (strcmp(s, "readonly") == 0) { - readonly = 1; - } else if (strcmp(s, "nofork") == 0) { - nofork = 1; - } else if (strcmp(s, "logchan") == 0) { - if (!LogChannel) { - fprintf(stderr, - "-logchan: LogChannel must be defined in services.conf\n"); - } else { /* LogChannel */ - - logchan = 1; - } - } else if (strcmp(s, "forceload") == 0) { - forceload = 1; - } else if (strcmp(s, "nothird") == 0) { - nothird = 1; - } else if (strcmp(s, "protocoldebug") == 0) { - protocoldebug = 1; - } else if (strcmp(s, "support") == 0) { - nofork = 1; - debug++; - nothird = 1; - } else if (!strcmp(s, "noexpire")) { - noexpire = 1; - } else if (!strcmp(s, "help")) { - fprintf(stdout, "Anope-%s %s -- %s\n", version_number, - version_flags, version_build); - fprintf(stdout, - "Anope IRC Services (http://www.anope.org)\n"); - fprintf(stdout, "Usage ./services [options] ...\n"); - fprintf(stdout, - "-remote -remote hostname[:port]\n"); - fprintf(stdout, "-local -local hostname[:port]\n"); - fprintf(stdout, "-name -name servername\n"); - fprintf(stdout, "-desc -desc serverdesc\n"); - fprintf(stdout, "-user -user serviceuser\n"); - fprintf(stdout, "-host -host servicehost\n"); - fprintf(stdout, - "-update -update updatetime(secs)\n"); - fprintf(stdout, - "-expire -expire expiretime(secs)\n"); - fprintf(stdout, "-debug -debug\n"); - fprintf(stdout, "-nofork -nofork\n"); - fprintf(stdout, "-logchan -logchan channelname\n"); - fprintf(stdout, "-forceload -forceload\n"); - fprintf(stdout, "-nothird -nothird\n"); - fprintf(stdout, "-support -support\n"); - fprintf(stdout, "-readonly -readonly\n"); - fprintf(stdout, "-noexpire -noexpire\n"); - fprintf(stdout, "-version -version\n"); - fprintf(stdout, "-help -help\n"); - fprintf(stdout, "-log -log logfilename\n"); - fprintf(stdout, - "-dir -dir servicesdirectory\n\n"); - fprintf(stdout, - "Further support is available from http://www.anope.org\n"); - fprintf(stdout, - "Or visit US on IRC at irc.anope.org #anope\n"); - exit(EXIT_SUCCESS); - } else { - fprintf(stderr, "Unknown option -%s\n", s); - return -1; - } - } else { - fprintf(stderr, "Non-option arguments not allowed\n"); - return -1; - } - } - return 0; + int i; + char *s, *t; + + for (i = 1; i < ac; i++) { + s = av[i]; + if (*s == '-') { + s++; + if (strcmp(s, "remote") == 0) { + if (++i >= ac) { + fprintf(stderr, "-remote requires hostname[:port]\n"); + return -1; + } + s = av[i]; + t = strchr(s, ':'); + if (t) { + int portnum; + *t++ = 0; + portnum = atoi(t); + if ((portnum > 0) && (portnum < 65535)) + RemotePort = portnum; + else { + fprintf(stderr, + "-remote: Port numbers must be in the range 1..65535. Using default.\n"); + return -1; + } + } + RemoteServer = s; + } else if (strcmp(s, "local") == 0) { + if (++i >= ac) { + fprintf(stderr, + "-local requires hostname or [hostname]:[port]\n"); + return -1; + } + s = av[i]; + t = strchr(s, ':'); + if (t) { + int portnum; + *t++ = 0; + portnum = atoi(t); + if ((portnum >= 0) && (portnum < 65535)) + LocalPort = portnum; + else { + fprintf(stderr, + "-local: Port numbers must be in the range 1..65535 or 0. Using default.\n"); + return -1; + } + } + LocalHost = s; + } else if (strcmp(s, "name") == 0) { + if (++i >= ac) { + fprintf(stderr, "-name requires a parameter\n"); + return -1; + } + ServerName = av[i]; + } else if (strcmp(s, "desc") == 0) { + if (++i >= ac) { + fprintf(stderr, "-desc requires a parameter\n"); + return -1; + } + ServerDesc = av[i]; + } else if (strcmp(s, "user") == 0) { + if (++i >= ac) { + fprintf(stderr, "-user requires a parameter\n"); + return -1; + } + ServiceUser = av[i]; + } else if (strcmp(s, "host") == 0) { + if (++i >= ac) { + fprintf(stderr, "-host requires a parameter\n"); + return -1; + } + ServiceHost = av[i]; + } else if (strcmp(s, "dir") == 0) { + /* Handled by parse_dir_options() */ + i++; /* Skip parameter */ + } else if (strcmp(s, "log") == 0) { + /* Handled by parse_dir_options(), too */ + i++; /* Skip parameter */ + } else if (strcmp(s, "update") == 0) { + if (++i >= ac) { + fprintf(stderr, "-update requires a parameter\n"); + return -1; + } + s = av[i]; + if (atoi(s) <= 0) { + fprintf(stderr, + "-update: number of seconds must be positive"); + return -1; + } else + UpdateTimeout = atol(s); + } else if (strcmp(s, "expire") == 0) { + if (++i >= ac) { + fprintf(stderr, "-expire requires a parameter\n"); + return -1; + } + s = av[i]; + if (atoi(s) <= 0) { + fprintf(stderr, + "-expire: number of seconds must be positive\n"); + return -1; + } else + ExpireTimeout = atol(s); + } else if (strcmp(s, "debug") == 0) { + debug++; + } else if (strcmp(s, "readonly") == 0) { + readonly = 1; + } else if (strcmp(s, "nofork") == 0) { + nofork = 1; + } else if (strcmp(s, "logchan") == 0) { + if (!LogChannel) { + fprintf(stderr, + "-logchan: LogChannel must be defined in services.conf\n"); + } else { /* LogChannel */ + + logchan = 1; + } + } else if (strcmp(s, "forceload") == 0) { + forceload = 1; + } else if (strcmp(s, "nothird") == 0) { + nothird = 1; + } else if (strcmp(s, "protocoldebug") == 0) { + protocoldebug = 1; + } else if (strcmp(s, "support") == 0) { + nofork = 1; + debug++; + nothird = 1; + } else if (!strcmp(s, "noexpire")) { + noexpire = 1; + } else if (!strcmp(s, "help")) { + fprintf(stdout, "Anope-%s %s -- %s\n", version_number, + version_flags, version_build); + fprintf(stdout, + "Anope IRC Services (http://www.anope.org)\n"); + fprintf(stdout, "Usage ./services [options] ...\n"); + fprintf(stdout, + "-remote -remote hostname[:port]\n"); + fprintf(stdout, "-local -local hostname[:port]\n"); + fprintf(stdout, "-name -name servername\n"); + fprintf(stdout, "-desc -desc serverdesc\n"); + fprintf(stdout, "-user -user serviceuser\n"); + fprintf(stdout, "-host -host servicehost\n"); + fprintf(stdout, + "-update -update updatetime(secs)\n"); + fprintf(stdout, + "-expire -expire expiretime(secs)\n"); + fprintf(stdout, "-debug -debug\n"); + fprintf(stdout, "-nofork -nofork\n"); + fprintf(stdout, "-logchan -logchan channelname\n"); + fprintf(stdout, "-forceload -forceload\n"); + fprintf(stdout, "-nothird -nothird\n"); + fprintf(stdout, "-support -support\n"); + fprintf(stdout, "-readonly -readonly\n"); + fprintf(stdout, "-noexpire -noexpire\n"); + fprintf(stdout, "-version -version\n"); + fprintf(stdout, "-help -help\n"); + fprintf(stdout, "-log -log logfilename\n"); + fprintf(stdout, + "-dir -dir servicesdirectory\n\n"); + fprintf(stdout, + "Further support is available from http://www.anope.org\n"); + fprintf(stdout, + "Or visit US on IRC at irc.anope.org #anope\n"); + exit(EXIT_SUCCESS); + } else { + fprintf(stderr, "Unknown option -%s\n", s); + return -1; + } + } else { + fprintf(stderr, "Non-option arguments not allowed\n"); + return -1; + } + } + return 0; } /*************************************************************************/ @@ -304,7 +304,7 @@ static int parse_options(int ac, char **av) static void remove_pidfile(void) { - remove(PIDFilename); + remove(PIDFilename); } /*************************************************************************/ @@ -313,16 +313,16 @@ static void remove_pidfile(void) static void write_pidfile(void) { - FILE *pidfile; - - pidfile = fopen(PIDFilename, "w"); - if (pidfile) { - fprintf(pidfile, "%d\n", (int) getpid()); - fclose(pidfile); - atexit(remove_pidfile); - } else { - log_perror("Warning: cannot write to PID file %s", PIDFilename); - } + FILE *pidfile; + + pidfile = fopen(PIDFilename, "w"); + if (pidfile) { + fprintf(pidfile, "%d\n", (int) getpid()); + fclose(pidfile); + atexit(remove_pidfile); + } else { + log_perror("Warning: cannot write to PID file %s", PIDFilename); + } } /*************************************************************************/ @@ -333,251 +333,251 @@ int openlog_failed = 0, openlog_errno = 0; int init_primary(int ac, char **av) { - int started_from_term = isatty(0) && isatty(1) && isatty(2); + int started_from_term = isatty(0) && isatty(1) && isatty(2); - /* Set file creation mask and group ID. */ + /* Set file creation mask and group ID. */ #if defined(DEFUMASK) && HAVE_UMASK - umask(DEFUMASK); + umask(DEFUMASK); #endif - if (set_group() < 0) - return -1; - - /* Parse command line for -dir and -version options. */ - parse_dir_options(ac, av); - /* Parse all remaining command-line options. */ - parse_options(ac, av); - - /* Chdir to Services data directory. */ - if (chdir(services_dir) < 0) { - fprintf(stderr, "chdir(%s): %s\n", services_dir, strerror(errno)); - return -1; - } - - /* Open logfile, and complain if we didn't. */ - if (open_log() < 0) { - openlog_errno = errno; - if (started_from_term) { - fprintf(stderr, "Warning: unable to open log file %s: %s\n", - log_filename, strerror(errno)); - } else { - openlog_failed = 1; - } - } - - /* Read configuration file; exit if there are problems. */ - if (!read_config(0)) { - return -1; - } - - /* Add IRCD Protocol Module; exit if there are errors */ - if (protocol_module_init()) { - return -1; - } - - /* Add Encryption Module; exit if there are errors */ - if (encryption_module_init()) { - return -1; - } - return 0; + if (set_group() < 0) + return -1; + + /* Parse command line for -dir and -version options. */ + parse_dir_options(ac, av); + /* Parse all remaining command-line options. */ + parse_options(ac, av); + + /* Chdir to Services data directory. */ + if (chdir(services_dir) < 0) { + fprintf(stderr, "chdir(%s): %s\n", services_dir, strerror(errno)); + return -1; + } + + /* Open logfile, and complain if we didn't. */ + if (open_log() < 0) { + openlog_errno = errno; + if (started_from_term) { + fprintf(stderr, "Warning: unable to open log file %s: %s\n", + log_filename, strerror(errno)); + } else { + openlog_failed = 1; + } + } + + /* Read configuration file; exit if there are problems. */ + if (!read_config(0)) { + return -1; + } + + /* Add IRCD Protocol Module; exit if there are errors */ + if (protocol_module_init()) { + return -1; + } + + /* Add Encryption Module; exit if there are errors */ + if (encryption_module_init()) { + return -1; + } + return 0; } int init_secondary(int ac, char **av) { - int i; - int started_from_term = isatty(0) && isatty(1) && isatty(2); - - /* Add Core MSG handles */ - moduleAddMsgs(); - - /* Parse the defcon mode string if needed */ - if (DefConLevel) { - if (!defconParseModeString(DefConChanModes)) { - fprintf(stderr, - "services.conf: The given DefConChanModes mode string was incorrect (see log for exact errors)\n"); - return -1; - } - } + int i; + int started_from_term = isatty(0) && isatty(1) && isatty(2); + + /* Add Core MSG handles */ + moduleAddMsgs(); + + /* Parse the defcon mode string if needed */ + if (DefConLevel) { + if (!defconParseModeString(DefConChanModes)) { + fprintf(stderr, + "services.conf: The given DefConChanModes mode string was incorrect (see log for exact errors)\n"); + return -1; + } + } #ifndef _WIN32 - if (!nofork) { - if ((i = fork()) < 0) { - perror("fork()"); - return -1; - } else if (i != 0) { - exit(0); - } - if (started_from_term) { - close(0); - close(1); - close(2); - } - if (setpgid(0, 0) < 0) { - perror("setpgid()"); - return -1; - } - } + if (!nofork) { + if ((i = fork()) < 0) { + perror("fork()"); + return -1; + } else if (i != 0) { + exit(0); + } + if (started_from_term) { + close(0); + close(1); + close(2); + } + if (setpgid(0, 0) < 0) { + perror("setpgid()"); + return -1; + } + } #else - /* Initialize winsocks -- codemastr */ - { - WSADATA wsa; - if (WSAStartup(MAKEWORD(1, 1), &wsa)) { - alog("Failed to initialized WinSock library"); - return -1; - } - } - if (!SupportedWindowsVersion()) { + /* Initialize winsocks -- codemastr */ + { + WSADATA wsa; + if (WSAStartup(MAKEWORD(1, 1), &wsa)) { + alog("Failed to initialized WinSock library"); + return -1; + } + } + if (!SupportedWindowsVersion()) { - char *winver = GetWindowsVersion(); + char *winver = GetWindowsVersion(); - alog("%s is not a supported version of Windows", winver); + alog("%s is not a supported version of Windows", winver); - free(winver); + free(winver); - return -1; + return -1; - } - if (!nofork) { - alog("Launching Anope into the background"); - FreeConsole(); - } + } + if (!nofork) { + alog("Launching Anope into the background"); + FreeConsole(); + } #endif - /* Write our PID to the PID file. */ - write_pidfile(); - - /* Announce ourselves to the logfile. */ - if (debug || readonly) { - alog("Anope %s (ircd protocol: %s) starting up (options:%s%s)", - version_number, version_protocol, - debug ? " debug" : "", readonly ? " readonly" : ""); - } else { - alog("Anope %s (ircd protocol: %s) starting up", - version_number, version_protocol); - } - start_time = time(NULL); + /* Write our PID to the PID file. */ + write_pidfile(); + + /* Announce ourselves to the logfile. */ + if (debug || readonly) { + alog("Anope %s (ircd protocol: %s) starting up (options:%s%s)", + version_number, version_protocol, + debug ? " debug" : "", readonly ? " readonly" : ""); + } else { + alog("Anope %s (ircd protocol: %s) starting up", + version_number, version_protocol); + } + start_time = time(NULL); - /* If in read-only mode, close the logfile again. */ - if (readonly) - close_log(); + /* If in read-only mode, close the logfile again. */ + if (readonly) + close_log(); - /* Set signal handlers. Catch certain signals to let us do things or - * panic as necessary, and ignore all others. - */ + /* Set signal handlers. Catch certain signals to let us do things or + * panic as necessary, and ignore all others. + */ #ifndef _WIN32 #if defined(NSIG) - for (i = 1; i <= NSIG - 1; i++) { + for (i = 1; i <= NSIG - 1; i++) { #else - for (i = 1; i <= 31; i++) { + for (i = 1; i <= 31; i++) { #endif - signal(i, SIG_IGN); - } + signal(i, SIG_IGN); + } #else - /* work around to bug #527 */ - signal(SIGILL, SIG_IGN); - signal(SIGBREAK, SIG_IGN); - signal(SIGABRT, SIG_IGN); + /* work around to bug #527 */ + signal(SIGILL, SIG_IGN); + signal(SIGBREAK, SIG_IGN); + signal(SIGABRT, SIG_IGN); #endif - signal(SIGINT, sighandler); - signal(SIGTERM, sighandler); + signal(SIGINT, sighandler); + signal(SIGTERM, sighandler); #ifndef _WIN32 - signal(SIGQUIT, sighandler); + signal(SIGQUIT, sighandler); #endif - if (!DumpCore) { - signal(SIGSEGV, sighandler); + if (!DumpCore) { + signal(SIGSEGV, sighandler); #ifndef _WIN32 - signal(SIGBUS, sighandler); - signal(SIGTRAP, sighandler); + signal(SIGBUS, sighandler); + signal(SIGTRAP, sighandler); #endif - } else { - signal(SIGSEGV, SIG_DFL); + } else { + signal(SIGSEGV, SIG_DFL); #ifndef _WIN32 - signal(SIGBUS, sighandler); - signal(SIGTRAP, sighandler); + signal(SIGBUS, sighandler); + signal(SIGTRAP, sighandler); #endif - } + } #ifndef _WIN32 - signal(SIGQUIT, sighandler); - signal(SIGHUP, sighandler); - signal(SIGUSR2, sighandler); + signal(SIGQUIT, sighandler); + signal(SIGHUP, sighandler); + signal(SIGUSR2, sighandler); #endif #ifdef SIGIOT - signal(SIGIOT, sighandler); + signal(SIGIOT, sighandler); #endif - signal(SIGFPE, sighandler); + signal(SIGFPE, sighandler); #ifndef _WIN32 - signal(SIGUSR1, sighandler); /* This is our "out-of-memory" panic switch */ + signal(SIGUSR1, sighandler); /* This is our "out-of-memory" panic switch */ #endif - /* Initialize multi-language support */ - lang_init(); - if (debug) - alog("debug: Loaded languages"); + /* Initialize multi-language support */ + lang_init(); + if (debug) + alog("debug: Loaded languages"); - /* Initialize subservices */ - ns_init(); - cs_init(); - ms_init(); - bs_init(); - os_init(); - hostserv_init(); - helpserv_init(); + /* Initialize subservices */ + ns_init(); + cs_init(); + ms_init(); + bs_init(); + os_init(); + hostserv_init(); + helpserv_init(); - /* load any custom modules */ + /* load any custom modules */ ModuleManager::LoadModuleList(ModulesNumber, ModulesAutoload); - /* Initialize random number generator */ - rand_init(); - add_entropy_userkeys(); + /* Initialize random number generator */ + rand_init(); + add_entropy_userkeys(); - /* Load up databases */ + /* Load up databases */ load_ns_dbase(); if (debug) - alog("debug: Loaded %s database (1/%d)", s_NickServ, + alog("debug: Loaded %s database (1/%d)", s_NickServ, (PreNickDBName ? 8 : 7)); if (s_HostServ) { - load_hs_dbase(); - if (debug) + load_hs_dbase(); + if (debug) alog("debug: Loaded %s database (2/%d)", s_HostServ, - (PreNickDBName ? 8 : 7)); + (PreNickDBName ? 8 : 7)); } else if (debug) { - alog("debug: HostServ database (2/%d) not loaded because HostServ is disabled", (PreNickDBName ? 8 : 7)); + alog("debug: HostServ database (2/%d) not loaded because HostServ is disabled", (PreNickDBName ? 8 : 7)); } if (s_BotServ) { - load_bs_dbase(); - if (debug) + load_bs_dbase(); + if (debug) alog("debug: Loaded %s database (3/%d)", s_BotServ, - (PreNickDBName ? 8 : 7)); + (PreNickDBName ? 8 : 7)); } else if (debug) { - alog("debug: BotServ database (3/%d) not loaded because BotServ is disabled", (PreNickDBName ? 8 : 7)); + alog("debug: BotServ database (3/%d) not loaded because BotServ is disabled", (PreNickDBName ? 8 : 7)); } load_cs_dbase(); if (debug) - alog("debug: Loaded %s database (4/%d)", s_ChanServ, + alog("debug: Loaded %s database (4/%d)", s_ChanServ, (PreNickDBName ? 8 : 7)); load_os_dbase(); if (debug) - alog("debug: Loaded %s database (5/%d)", s_OperServ, + alog("debug: Loaded %s database (5/%d)", s_OperServ, (PreNickDBName ? 8 : 7)); load_news(); if (debug) - alog("debug: Loaded news database (6/%d)", + alog("debug: Loaded news database (6/%d)", (PreNickDBName ? 8 : 7)); load_exceptions(); if (debug) - alog("debug: Loaded exception database (7/%d)", + alog("debug: Loaded exception database (7/%d)", (PreNickDBName ? 8 : 7)); if (PreNickDBName) { - load_ns_req_db(); - if (debug) + load_ns_req_db(); + if (debug) alog("debug: Loaded PreNick database (8/8)"); } - alog("Databases loaded"); + alog("Databases loaded"); /* this is only used on the first run of Anope. */ @@ -602,73 +602,73 @@ int init_secondary(int ac, char **av) bi = new BotInfo(s_GlobalNoticer, ServiceUser, ServiceHost, desc_GlobalNoticer); } - /* Save the databases back to file/mysql to reflect any changes */ - alog("Info: Reflecting database records."); - save_databases(); - send_event(EVENT_CONNECT, 1, EVENT_START); - - /* Connect to the remote server */ - servsock = conn(RemoteServer, RemotePort, LocalHost, LocalPort); - if (servsock < 0 && RemoteServer2) { - servsock = conn(RemoteServer2, RemotePort2, LocalHost, LocalPort); - if (servsock < 0 && RemoteServer3) { - servsock = - conn(RemoteServer3, RemotePort3, LocalHost, LocalPort); - if (servsock < 0) { - fatal_perror("Can't connect to server"); - } else { - servernum = 3; - alog("Connected to Server %d (%s:%d)", servernum, - RemoteServer3, RemotePort3); - } - } else { - if (servsock < 0) { - fatal_perror("Can't connect to server"); - } - servernum = 2; - alog("Connected to Server %d (%s:%d)", servernum, - RemoteServer2, RemotePort2); - } - } else { - if (servsock < 0) { - fatal_perror("Can't connect to server"); - } - servernum = 1; - alog("Connected to Server %d (%s:%d)", servernum, RemoteServer, - RemotePort); - } - - ircdproto->SendConnect(); - send_event(EVENT_CONNECT, 1, EVENT_STOP); - - sgets2(inbuf, sizeof(inbuf), servsock); - if (strnicmp(inbuf, "ERROR", 5) == 0) { - /* Close server socket first to stop wallops, since the other - * server doesn't want to listen to us anyway */ - disconn(servsock); - servsock = -1; - fatal("Remote server returned: %s", inbuf); - } - - /* Announce a logfile error if there was one */ - if (openlog_failed) { - ircdproto->SendGlobops(NULL, "Warning: couldn't open logfile: %s", - strerror(openlog_errno)); - } - - /* Bring in our pseudo-clients */ - introduce_user(NULL); - - /* And hybrid needs Global joined in the logchan */ - if (logchan && ircd->join2msg) { - /* XXX might desync */ - ircdproto->SendJoin(findbot(s_GlobalNoticer), LogChannel, time(NULL)); - } - - ircdproto->SendEOB(); - - /* Success! */ - return 0; + /* Save the databases back to file/mysql to reflect any changes */ + alog("Info: Reflecting database records."); + save_databases(); + send_event(EVENT_CONNECT, 1, EVENT_START); + + /* Connect to the remote server */ + servsock = conn(RemoteServer, RemotePort, LocalHost, LocalPort); + if (servsock < 0 && RemoteServer2) { + servsock = conn(RemoteServer2, RemotePort2, LocalHost, LocalPort); + if (servsock < 0 && RemoteServer3) { + servsock = + conn(RemoteServer3, RemotePort3, LocalHost, LocalPort); + if (servsock < 0) { + fatal_perror("Can't connect to server"); + } else { + servernum = 3; + alog("Connected to Server %d (%s:%d)", servernum, + RemoteServer3, RemotePort3); + } + } else { + if (servsock < 0) { + fatal_perror("Can't connect to server"); + } + servernum = 2; + alog("Connected to Server %d (%s:%d)", servernum, + RemoteServer2, RemotePort2); + } + } else { + if (servsock < 0) { + fatal_perror("Can't connect to server"); + } + servernum = 1; + alog("Connected to Server %d (%s:%d)", servernum, RemoteServer, + RemotePort); + } + + ircdproto->SendConnect(); + send_event(EVENT_CONNECT, 1, EVENT_STOP); + + sgets2(inbuf, sizeof(inbuf), servsock); + if (strnicmp(inbuf, "ERROR", 5) == 0) { + /* Close server socket first to stop wallops, since the other + * server doesn't want to listen to us anyway */ + disconn(servsock); + servsock = -1; + fatal("Remote server returned: %s", inbuf); + } + + /* Announce a logfile error if there was one */ + if (openlog_failed) { + ircdproto->SendGlobops(NULL, "Warning: couldn't open logfile: %s", + strerror(openlog_errno)); + } + + /* Bring in our pseudo-clients */ + introduce_user(NULL); + + /* And hybrid needs Global joined in the logchan */ + if (logchan && ircd->join2msg) { + /* XXX might desync */ + ircdproto->SendJoin(findbot(s_GlobalNoticer), LogChannel, time(NULL)); + } + + ircdproto->SendEOB(); + + /* Success! */ + return 0; } /*************************************************************************/ diff --git a/src/ircd.c b/src/ircd.c index d9b729ef0..670947645 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -55,139 +55,139 @@ void anope_SendNumeric(const char *source, int numeric, const char *dest, const **/ void pmodule_ircd_var(IRCDVar * ircdvar) { - ircd = ircdvar; + ircd = ircdvar; } void pmodule_ircd_cap(IRCDCAPAB * cap) { - ircdcap = cap; + ircdcap = cap; } void pmodule_ircd_version(const char *version) { - version_protocol = sstrdup(version); + version_protocol = sstrdup(version); } void pmodule_ircd_cbmodeinfos(CBModeInfo * modeinfos) { - cbmodeinfos = modeinfos; + cbmodeinfos = modeinfos; } void pmodule_ircd_cumodes(CUMode modes[128]) { - int i = 0; - for (i = 0; i < 128; i++) { - cumodes[i] = modes[i]; - } + int i = 0; + for (i = 0; i < 128; i++) { + cumodes[i] = modes[i]; + } } void pmodule_ircd_flood_mode_char_set(const char *mode) { - flood_mode_char_set = sstrdup(mode); + flood_mode_char_set = sstrdup(mode); } void pmodule_ircd_flood_mode_char_remove(const char *mode) { - flood_mode_char_remove = sstrdup(mode); + flood_mode_char_remove = sstrdup(mode); } void pmodule_ircd_cbmodes(CBMode modes[128]) { - int i = 0; - for (i = 0; i < 128; i++) { - cbmodes[i] = modes[i]; - } + int i = 0; + for (i = 0; i < 128; i++) { + cbmodes[i] = modes[i]; + } } void pmodule_ircd_cmmodes(CMMode modes[128]) { - int i = 0; - for (i = 0; i < 128; i++) { - cmmodes[i] = modes[i]; - } + int i = 0; + for (i = 0; i < 128; i++) { + cmmodes[i] = modes[i]; + } } void pmodule_ircd_csmodes(char mode[128]) { - int i = 0; - for (i = 0; i < 128; i++) { - csmodes[i] = mode[i]; - } + int i = 0; + for (i = 0; i < 128; i++) { + csmodes[i] = mode[i]; + } } void pmodule_ircd_useTSMode(int use) { - UseTSMODE = use; + UseTSMODE = use; } /** mode stuff */ void pmodule_invis_umode(int mode) { - ircd_modes.user_invis = mode; + ircd_modes.user_invis = mode; } void pmodule_oper_umode(int mode) { - ircd_modes.user_oper = mode; + ircd_modes.user_oper = mode; } void pmodule_invite_cmode(int mode) { - ircd_modes.chan_invite = mode; + ircd_modes.chan_invite = mode; } void pmodule_secret_cmode(int mode) { - ircd_modes.chan_secret = mode; + ircd_modes.chan_secret = mode; } void pmodule_private_cmode(int mode) { - ircd_modes.chan_private = mode; + ircd_modes.chan_private = mode; } void pmodule_key_mode(int mode) { - ircd_modes.chan_key = mode; + ircd_modes.chan_key = mode; } void pmodule_limit_mode(int mode) { - ircd_modes.chan_limit = mode; + ircd_modes.chan_limit = mode; } int anope_get_invis_mode() { - return ircd_modes.user_invis; + return ircd_modes.user_invis; } int anope_get_oper_mode() { - return ircd_modes.user_oper; + return ircd_modes.user_oper; } int anope_get_invite_mode() { - return ircd_modes.chan_invite; + return ircd_modes.chan_invite; } int anope_get_secret_mode() { - return ircd_modes.chan_secret; + return ircd_modes.chan_secret; } int anope_get_private_mode() { - return ircd_modes.chan_private; + return ircd_modes.chan_private; } int anope_get_key_mode() { - return ircd_modes.chan_key; + return ircd_modes.chan_key; } int anope_get_limit_mode() { - return ircd_modes.chan_limit; + return ircd_modes.chan_limit; } diff --git a/src/language.c b/src/language.c index d521cf188..e99dc0862 100644 --- a/src/language.c +++ b/src/language.c @@ -28,22 +28,22 @@ int langlist[NUM_LANGS]; /* Order in which languages should be displayed: (alphabetical) */ static int langorder[NUM_LANGS] = { - LANG_EN_US, /* English (US) */ - LANG_FR, /* French */ - LANG_DE, /* German */ - LANG_IT, /* Italian */ - LANG_JA_JIS, /* Japanese (JIS encoding) */ - LANG_JA_EUC, /* Japanese (EUC encoding) */ - LANG_JA_SJIS, /* Japanese (SJIS encoding) */ - LANG_PT, /* Portugese */ - LANG_ES, /* Spanish */ - LANG_TR, /* Turkish */ - LANG_CAT, /* Catalan */ - LANG_GR, /* Greek */ - LANG_NL, /* Dutch */ - LANG_RU, /* Russian */ - LANG_HUN, /* Hungarian */ - LANG_PL, /* Polish */ + LANG_EN_US, /* English (US) */ + LANG_FR, /* French */ + LANG_DE, /* German */ + LANG_IT, /* Italian */ + LANG_JA_JIS, /* Japanese (JIS encoding) */ + LANG_JA_EUC, /* Japanese (EUC encoding) */ + LANG_JA_SJIS, /* Japanese (SJIS encoding) */ + LANG_PT, /* Portugese */ + LANG_ES, /* Spanish */ + LANG_TR, /* Turkish */ + LANG_CAT, /* Catalan */ + LANG_GR, /* Greek */ + LANG_NL, /* Dutch */ + LANG_RU, /* Russian */ + LANG_HUN, /* Hungarian */ + LANG_PL, /* Polish */ }; /*************************************************************************/ @@ -52,99 +52,99 @@ static int langorder[NUM_LANGS] = { static int read_int32(int32 * ptr, FILE * f) { - int a = fgetc(f); - int b = fgetc(f); - int c = fgetc(f); - int d = fgetc(f); - if (a == EOF || b == EOF || c == EOF || d == EOF) - return -1; - *ptr = a << 24 | b << 16 | c << 8 | d; - return 0; + int a = fgetc(f); + int b = fgetc(f); + int c = fgetc(f); + int d = fgetc(f); + if (a == EOF || b == EOF || c == EOF || d == EOF) + return -1; + *ptr = a << 24 | b << 16 | c << 8 | d; + return 0; } static void load_lang(int index, const char *filename) { - char buf[256]; - FILE *f; - int32 num, i; + char buf[256]; + FILE *f; + int32 num, i; - if (debug) { - alog("debug: Loading language %d from file `languages/%s'", - index, filename); - } - snprintf(buf, sizeof(buf), "languages/%s", filename); + if (debug) { + alog("debug: Loading language %d from file `languages/%s'", + index, filename); + } + snprintf(buf, sizeof(buf), "languages/%s", filename); #ifndef _WIN32 - if (!(f = fopen(buf, "r"))) { + if (!(f = fopen(buf, "r"))) { #else - if (!(f = fopen(buf, "rb"))) { + if (!(f = fopen(buf, "rb"))) { #endif - log_perror("Failed to load language %d (%s)", index, filename); - return; - } else if (read_int32(&num, f) < 0) { - alog("Failed to read number of strings for language %d (%s)", - index, filename); - return; - } else if (num != NUM_STRINGS) { - alog("Warning: Bad number of strings (%d, wanted %d) " - "for language %d (%s)", num, NUM_STRINGS, index, filename); - } - langtexts[index] = (char **)scalloc(sizeof(char *), NUM_STRINGS); - if (num > NUM_STRINGS) - num = NUM_STRINGS; - for (i = 0; i < num; i++) { - int32 pos, len; - fseek(f, i * 8 + 4, SEEK_SET); - if (read_int32(&pos, f) < 0 || read_int32(&len, f) < 0) { - alog("Failed to read entry %d in language %d (%s) TOC", - i, index, filename); - while (--i >= 0) { - if (langtexts[index][i]) - free(langtexts[index][i]); - } - free(langtexts[index]); - langtexts[index] = NULL; - return; - } - if (len == 0) { - langtexts[index][i] = NULL; - } else if (len >= 65536) { - alog("Entry %d in language %d (%s) is too long (over 64k)--" - "corrupt TOC?", i, index, filename); - while (--i >= 0) { - if (langtexts[index][i]) - free(langtexts[index][i]); - } - free(langtexts[index]); - langtexts[index] = NULL; - return; - } else if (len < 0) { - alog("Entry %d in language %d (%s) has negative length--" - "corrupt TOC?", i, index, filename); - while (--i >= 0) { - if (langtexts[index][i]) - free(langtexts[index][i]); - } - free(langtexts[index]); - langtexts[index] = NULL; - return; - } else { - langtexts[index][i] = (char *)scalloc(len + 1, 1); - fseek(f, pos, SEEK_SET); - if (fread(langtexts[index][i], 1, len, f) != len) { - alog("Failed to read string %d in language %d (%s)", - i, index, filename); - while (--i >= 0) { - if (langtexts[index][i]) - free(langtexts[index][i]); - } - free(langtexts[index]); - langtexts[index] = NULL; - return; - } - langtexts[index][i][len] = 0; - } - } - fclose(f); + log_perror("Failed to load language %d (%s)", index, filename); + return; + } else if (read_int32(&num, f) < 0) { + alog("Failed to read number of strings for language %d (%s)", + index, filename); + return; + } else if (num != NUM_STRINGS) { + alog("Warning: Bad number of strings (%d, wanted %d) " + "for language %d (%s)", num, NUM_STRINGS, index, filename); + } + langtexts[index] = (char **)scalloc(sizeof(char *), NUM_STRINGS); + if (num > NUM_STRINGS) + num = NUM_STRINGS; + for (i = 0; i < num; i++) { + int32 pos, len; + fseek(f, i * 8 + 4, SEEK_SET); + if (read_int32(&pos, f) < 0 || read_int32(&len, f) < 0) { + alog("Failed to read entry %d in language %d (%s) TOC", + i, index, filename); + while (--i >= 0) { + if (langtexts[index][i]) + free(langtexts[index][i]); + } + free(langtexts[index]); + langtexts[index] = NULL; + return; + } + if (len == 0) { + langtexts[index][i] = NULL; + } else if (len >= 65536) { + alog("Entry %d in language %d (%s) is too long (over 64k)--" + "corrupt TOC?", i, index, filename); + while (--i >= 0) { + if (langtexts[index][i]) + free(langtexts[index][i]); + } + free(langtexts[index]); + langtexts[index] = NULL; + return; + } else if (len < 0) { + alog("Entry %d in language %d (%s) has negative length--" + "corrupt TOC?", i, index, filename); + while (--i >= 0) { + if (langtexts[index][i]) + free(langtexts[index][i]); + } + free(langtexts[index]); + langtexts[index] = NULL; + return; + } else { + langtexts[index][i] = (char *)scalloc(len + 1, 1); + fseek(f, pos, SEEK_SET); + if (fread(langtexts[index][i], 1, len, f) != len) { + alog("Failed to read string %d in language %d (%s)", + i, index, filename); + while (--i >= 0) { + if (langtexts[index][i]) + free(langtexts[index][i]); + } + free(langtexts[index]); + langtexts[index] = NULL; + return; + } + langtexts[index][i][len] = 0; + } + } + fclose(f); } /*************************************************************************/ @@ -152,26 +152,26 @@ static void load_lang(int index, const char *filename) /* Replace all %M's with "/msg " or "/" */ void lang_sanitize() { - int i = 0, j = 0; - int len = 0; - char tmp[2000]; - char *newstr = NULL; - for (i = 0; i < NUM_LANGS; i++) { - for (j = 0; j < NUM_STRINGS; j++) { - if (strstr(langtexts[i][j], "%R")) { - len = strlen(langtexts[i][j]); - strscpy(tmp, langtexts[i][j], sizeof(tmp)); - if (UseStrictPrivMsg) { - strnrepl(tmp, sizeof(tmp), "%R", "/"); - } else { - strnrepl(tmp, sizeof(tmp), "%R", "/msg "); - } - newstr = sstrdup(tmp); - free(langtexts[i][j]); - langtexts[i][j] = newstr; - } - } - } + int i = 0, j = 0; + int len = 0; + char tmp[2000]; + char *newstr = NULL; + for (i = 0; i < NUM_LANGS; i++) { + for (j = 0; j < NUM_STRINGS; j++) { + if (strstr(langtexts[i][j], "%R")) { + len = strlen(langtexts[i][j]); + strscpy(tmp, langtexts[i][j], sizeof(tmp)); + if (UseStrictPrivMsg) { + strnrepl(tmp, sizeof(tmp), "%R", "/"); + } else { + strnrepl(tmp, sizeof(tmp), "%R", "/msg "); + } + newstr = sstrdup(tmp); + free(langtexts[i][j]); + langtexts[i][j] = newstr; + } + } + } } @@ -179,52 +179,52 @@ void lang_sanitize() void lang_init() { - int i, j, n = 0; + int i, j, n = 0; - load_lang(LANG_CAT, "cat"); - load_lang(LANG_DE, "de"); - load_lang(LANG_EN_US, "en_us"); - load_lang(LANG_ES, "es"); - load_lang(LANG_FR, "fr"); - load_lang(LANG_GR, "gr"); - load_lang(LANG_PT, "pt"); - load_lang(LANG_TR, "tr"); - load_lang(LANG_IT, "it"); - load_lang(LANG_NL, "nl"); - load_lang(LANG_RU, "ru"); - load_lang(LANG_HUN, "hun"); - load_lang(LANG_PL, "pl"); + load_lang(LANG_CAT, "cat"); + load_lang(LANG_DE, "de"); + load_lang(LANG_EN_US, "en_us"); + load_lang(LANG_ES, "es"); + load_lang(LANG_FR, "fr"); + load_lang(LANG_GR, "gr"); + load_lang(LANG_PT, "pt"); + load_lang(LANG_TR, "tr"); + load_lang(LANG_IT, "it"); + load_lang(LANG_NL, "nl"); + load_lang(LANG_RU, "ru"); + load_lang(LANG_HUN, "hun"); + load_lang(LANG_PL, "pl"); - for (i = 0; i < NUM_LANGS; i++) { - if (langtexts[langorder[i]] != NULL) { - langnames[langorder[i]] = langtexts[langorder[i]][LANG_NAME]; - langlist[n++] = langorder[i]; - for (j = 0; j < NUM_STRINGS; j++) { - if (!langtexts[langorder[i]][j]) { - langtexts[langorder[i]][j] = - langtexts[DEF_LANGUAGE][j]; - } - if (!langtexts[langorder[i]][j]) { - langtexts[langorder[i]][j] = langtexts[LANG_EN_US][j]; - } - } - } - } - while (n < NUM_LANGS) - langlist[n++] = -1; + for (i = 0; i < NUM_LANGS; i++) { + if (langtexts[langorder[i]] != NULL) { + langnames[langorder[i]] = langtexts[langorder[i]][LANG_NAME]; + langlist[n++] = langorder[i]; + for (j = 0; j < NUM_STRINGS; j++) { + if (!langtexts[langorder[i]][j]) { + langtexts[langorder[i]][j] = + langtexts[DEF_LANGUAGE][j]; + } + if (!langtexts[langorder[i]][j]) { + langtexts[langorder[i]][j] = langtexts[LANG_EN_US][j]; + } + } + } + } + while (n < NUM_LANGS) + langlist[n++] = -1; - /* Not what I intended to do, but these services are so archaïc - * that it's difficult to do more. */ - if ((NSDefLanguage = langlist[NSDefLanguage]) < 0) - NSDefLanguage = DEF_LANGUAGE; + /* Not what I intended to do, but these services are so archaïc + * that it's difficult to do more. */ + if ((NSDefLanguage = langlist[NSDefLanguage]) < 0) + NSDefLanguage = DEF_LANGUAGE; - if (!langtexts[DEF_LANGUAGE]) - fatal("Unable to load default language"); - for (i = 0; i < NUM_LANGS; i++) { - if (!langtexts[i]) - langtexts[i] = langtexts[DEF_LANGUAGE]; - } - lang_sanitize(); + if (!langtexts[DEF_LANGUAGE]) + fatal("Unable to load default language"); + for (i = 0; i < NUM_LANGS; i++) { + if (!langtexts[i]) + langtexts[i] = langtexts[DEF_LANGUAGE]; + } + lang_sanitize(); } /*************************************************************************/ @@ -240,52 +240,52 @@ void lang_init() int strftime_lang(char *buf, int size, User * u, int format, struct tm *tm) { - int language = u && u->na ? u->na->nc->language : NSDefLanguage; - char tmpbuf[BUFSIZE], buf2[BUFSIZE]; - char *s; - int i, ret; + int language = u && u->na ? u->na->nc->language : NSDefLanguage; + char tmpbuf[BUFSIZE], buf2[BUFSIZE]; + char *s; + int i, ret; - if (!tm) { - return 0; - } + if (!tm) { + return 0; + } - strscpy(tmpbuf, langtexts[language][format], sizeof(tmpbuf)); - if ((s = langtexts[language][STRFTIME_DAYS_SHORT]) != NULL) { - for (i = 0; i < tm->tm_wday; i++) - s += strcspn(s, "\n") + 1; - i = strcspn(s, "\n"); - strncpy(buf2, s, i); - buf2[i] = 0; - strnrepl(tmpbuf, sizeof(tmpbuf), "%a", buf2); - } - if ((s = langtexts[language][STRFTIME_DAYS_LONG]) != NULL) { - for (i = 0; i < tm->tm_wday; i++) - s += strcspn(s, "\n") + 1; - i = strcspn(s, "\n"); - strncpy(buf2, s, i); - buf2[i] = 0; - strnrepl(tmpbuf, sizeof(tmpbuf), "%A", buf2); - } - if ((s = langtexts[language][STRFTIME_MONTHS_SHORT]) != NULL) { - for (i = 0; i < tm->tm_mon; i++) - s += strcspn(s, "\n") + 1; - i = strcspn(s, "\n"); - strncpy(buf2, s, i); - buf2[i] = 0; - strnrepl(tmpbuf, sizeof(tmpbuf), "%b", buf2); - } - if ((s = langtexts[language][STRFTIME_MONTHS_LONG]) != NULL) { - for (i = 0; i < tm->tm_mon; i++) - s += strcspn(s, "\n") + 1; - i = strcspn(s, "\n"); - strncpy(buf2, s, i); - buf2[i] = 0; - strnrepl(tmpbuf, sizeof(tmpbuf), "%B", buf2); - } - ret = strftime(buf, size, tmpbuf, tm); - if (ret == size) - buf[size - 1] = 0; - return ret; + strscpy(tmpbuf, langtexts[language][format], sizeof(tmpbuf)); + if ((s = langtexts[language][STRFTIME_DAYS_SHORT]) != NULL) { + for (i = 0; i < tm->tm_wday; i++) + s += strcspn(s, "\n") + 1; + i = strcspn(s, "\n"); + strncpy(buf2, s, i); + buf2[i] = 0; + strnrepl(tmpbuf, sizeof(tmpbuf), "%a", buf2); + } + if ((s = langtexts[language][STRFTIME_DAYS_LONG]) != NULL) { + for (i = 0; i < tm->tm_wday; i++) + s += strcspn(s, "\n") + 1; + i = strcspn(s, "\n"); + strncpy(buf2, s, i); + buf2[i] = 0; + strnrepl(tmpbuf, sizeof(tmpbuf), "%A", buf2); + } + if ((s = langtexts[language][STRFTIME_MONTHS_SHORT]) != NULL) { + for (i = 0; i < tm->tm_mon; i++) + s += strcspn(s, "\n") + 1; + i = strcspn(s, "\n"); + strncpy(buf2, s, i); + buf2[i] = 0; + strnrepl(tmpbuf, sizeof(tmpbuf), "%b", buf2); + } + if ((s = langtexts[language][STRFTIME_MONTHS_LONG]) != NULL) { + for (i = 0; i < tm->tm_mon; i++) + s += strcspn(s, "\n") + 1; + i = strcspn(s, "\n"); + strncpy(buf2, s, i); + buf2[i] = 0; + strnrepl(tmpbuf, sizeof(tmpbuf), "%B", buf2); + } + ret = strftime(buf, size, tmpbuf, tm); + if (ret == size) + buf[size - 1] = 0; + return ret; } /*************************************************************************/ @@ -295,15 +295,15 @@ int strftime_lang(char *buf, int size, User * u, int format, struct tm *tm) void syntax_error(char *service, User * u, const char *command, int msgnum) { - const char *str; + const char *str; - if (!u) { - return; - } + if (!u) { + return; + } - str = getstring(u->na, msgnum); - notice_lang(service, u, SYNTAX_ERROR, str); - notice_lang(service, u, MORE_INFO, service, command); + str = getstring(u->na, msgnum); + notice_lang(service, u, SYNTAX_ERROR, str); + notice_lang(service, u, MORE_INFO, service, command); } /*************************************************************************/ @@ -23,45 +23,45 @@ static int curday = 0; static int get_logname(char *name, int count, struct tm *tm) { - char timestamp[32]; - time_t t; + char timestamp[32]; + time_t t; - if (!tm) { - time(&t); - tm = localtime(&t); - } + if (!tm) { + time(&t); + tm = localtime(&t); + } - /* fix bug 577 */ - strftime(timestamp, sizeof(timestamp), "%Y%m%d", tm); - snprintf(name, count, "logs/%s.%s", log_filename, timestamp); - curday = tm->tm_yday; + /* fix bug 577 */ + strftime(timestamp, sizeof(timestamp), "%Y%m%d", tm); + snprintf(name, count, "logs/%s.%s", log_filename, timestamp); + curday = tm->tm_yday; - return 1; + return 1; } /*************************************************************************/ static void remove_log(void) { - time_t t; - struct tm tm; + time_t t; + struct tm tm; - char name[PATH_MAX]; + char name[PATH_MAX]; - if (!KeepLogs) - return; + if (!KeepLogs) + return; - time(&t); - t -= (60 * 60 * 24 * KeepLogs); - tm = *localtime(&t); + time(&t); + t -= (60 * 60 * 24 * KeepLogs); + tm = *localtime(&t); - /* removed if from here cause get_logchan is always 1 */ - get_logname(name, sizeof(name), &tm); + /* removed if from here cause get_logchan is always 1 */ + get_logname(name, sizeof(name), &tm); #ifndef _WIN32 - unlink(name); + unlink(name); #else - DeleteFile(name); + DeleteFile(name); #endif } @@ -69,17 +69,17 @@ static void remove_log(void) static void checkday(void) { - time_t t; - struct tm tm; + time_t t; + struct tm tm; - time(&t); - tm = *localtime(&t); + time(&t); + tm = *localtime(&t); - if (curday != tm.tm_yday) { - close_log(); - remove_log(); - open_log(); - } + if (curday != tm.tm_yday) { + close_log(); + remove_log(); + open_log(); + } } /*************************************************************************/ @@ -89,18 +89,18 @@ static void checkday(void) int open_log(void) { - char name[PATH_MAX]; + char name[PATH_MAX]; - if (logfile) - return 0; + if (logfile) + return 0; - /* if removed again.. get_logname is always 1 */ - get_logname(name, sizeof(name), NULL); - logfile = fopen(name, "a"); + /* if removed again.. get_logname is always 1 */ + get_logname(name, sizeof(name), NULL); + logfile = fopen(name, "a"); - if (logfile) - setbuf(logfile, NULL); - return logfile != NULL ? 0 : -1; + if (logfile) + setbuf(logfile, NULL); + return logfile != NULL ? 0 : -1; } /*************************************************************************/ @@ -109,10 +109,10 @@ int open_log(void) void close_log(void) { - if (!logfile) - return; - fclose(logfile); - logfile = NULL; + if (!logfile) + return; + fclose(logfile); + logfile = NULL; } /*************************************************************************/ @@ -120,29 +120,29 @@ void close_log(void) /* added cause this is used over and over in the code */ char *log_gettimestamp(void) { - time_t t; - struct tm tm; - static char tbuf[256]; + time_t t; + struct tm tm; + static char tbuf[256]; - time(&t); - tm = *localtime(&t); + time(&t); + tm = *localtime(&t); #if HAVE_GETTIMEOFDAY - if (debug) { - char *s; - struct timeval tv; - gettimeofday(&tv, NULL); - strftime(tbuf, sizeof(tbuf) - 1, "[%b %d %H:%M:%S", &tm); - s = tbuf + strlen(tbuf); - s += snprintf(s, sizeof(tbuf) - (s - tbuf), ".%06d", - (int) tv.tv_usec); - strftime(s, sizeof(tbuf) - (s - tbuf) - 1, " %Y]", &tm); - } else { + if (debug) { + char *s; + struct timeval tv; + gettimeofday(&tv, NULL); + strftime(tbuf, sizeof(tbuf) - 1, "[%b %d %H:%M:%S", &tm); + s = tbuf + strlen(tbuf); + s += snprintf(s, sizeof(tbuf) - (s - tbuf), ".%06d", + (int) tv.tv_usec); + strftime(s, sizeof(tbuf) - (s - tbuf) - 1, " %Y]", &tm); + } else { #endif - strftime(tbuf, sizeof(tbuf) - 1, "[%b %d %H:%M:%S %Y]", &tm); + strftime(tbuf, sizeof(tbuf) - 1, "[%b %d %H:%M:%S %Y]", &tm); #if HAVE_GETTIMEOFDAY - } + } #endif - return tbuf; + return tbuf; } /*************************************************************************/ @@ -153,33 +153,33 @@ char *log_gettimestamp(void) void alog(const char *fmt, ...) { - va_list args; - char *buf; - int errno_save = errno; - char str[BUFSIZE]; - - checkday(); - - if (!fmt) { - return; - } - - va_start(args, fmt); - vsnprintf(str, sizeof(str), fmt, args); - va_end(args); - - buf = log_gettimestamp(); - - if (logfile) { - fprintf(logfile, "%s %s\n", buf, str); - } - if (nofork) { - fprintf(stderr, "%s %s\n", buf, str); - } - if (LogChannel && logchan && !debug && findchan(LogChannel)) { - ircdproto->SendPrivmsg(findbot(s_GlobalNoticer), LogChannel, "%s", str); - } - errno = errno_save; + va_list args; + char *buf; + int errno_save = errno; + char str[BUFSIZE]; + + checkday(); + + if (!fmt) { + return; + } + + va_start(args, fmt); + vsnprintf(str, sizeof(str), fmt, args); + va_end(args); + + buf = log_gettimestamp(); + + if (logfile) { + fprintf(logfile, "%s %s\n", buf, str); + } + if (nofork) { + fprintf(stderr, "%s %s\n", buf, str); + } + if (LogChannel && logchan && !debug && findchan(LogChannel)) { + ircdproto->SendPrivmsg(findbot(s_GlobalNoticer), LogChannel, "%s", str); + } + errno = errno_save; } /*************************************************************************/ @@ -190,30 +190,30 @@ void alog(const char *fmt, ...) void log_perror(const char *fmt, ...) { - va_list args; - char *buf; - int errno_save = errno; - char str[BUFSIZE]; - - checkday(); - - if (!fmt) { - return; - } - - va_start(args, fmt); - vsnprintf(str, sizeof(str), fmt, args); - va_end(args); - - buf = log_gettimestamp(); - - if (logfile) { - fprintf(logfile, "%s %s : %s\n", buf, str, strerror(errno_save)); - } - if (nofork) { - fprintf(stderr, "%s %s : %s\n", buf, str, strerror(errno_save)); - } - errno = errno_save; + va_list args; + char *buf; + int errno_save = errno; + char str[BUFSIZE]; + + checkday(); + + if (!fmt) { + return; + } + + va_start(args, fmt); + vsnprintf(str, sizeof(str), fmt, args); + va_end(args); + + buf = log_gettimestamp(); + + if (logfile) { + fprintf(logfile, "%s %s : %s\n", buf, str, strerror(errno_save)); + } + if (nofork) { + fprintf(stderr, "%s %s : %s\n", buf, str, strerror(errno_save)); + } + errno = errno_save; } /*************************************************************************/ @@ -224,33 +224,33 @@ void log_perror(const char *fmt, ...) void fatal(const char *fmt, ...) { - va_list args; - char *buf; - char buf2[4096]; + va_list args; + char *buf; + char buf2[4096]; - checkday(); + checkday(); - if (!fmt) { - return; - } + if (!fmt) { + return; + } - va_start(args, fmt); - vsnprintf(buf2, sizeof(buf2), fmt, args); - va_end(args); + va_start(args, fmt); + vsnprintf(buf2, sizeof(buf2), fmt, args); + va_end(args); - buf = log_gettimestamp(); + buf = log_gettimestamp(); - if (logfile) - fprintf(logfile, "%s FATAL: %s\n", buf, buf2); - if (nofork) - fprintf(stderr, "%s FATAL: %s\n", buf, buf2); - if (servsock >= 0) - ircdproto->SendGlobops(NULL, "FATAL ERROR! %s", buf2); + if (logfile) + fprintf(logfile, "%s FATAL: %s\n", buf, buf2); + if (nofork) + fprintf(stderr, "%s FATAL: %s\n", buf, buf2); + if (servsock >= 0) + ircdproto->SendGlobops(NULL, "FATAL ERROR! %s", buf2); - /* one of the many places this needs to be called from */ - ModuleRunTimeDirCleanUp(); + /* one of the many places this needs to be called from */ + ModuleRunTimeDirCleanUp(); - exit(1); + exit(1); } /*************************************************************************/ @@ -259,37 +259,37 @@ void fatal(const char *fmt, ...) void fatal_perror(const char *fmt, ...) { - va_list args; - char *buf; - char buf2[4096]; - int errno_save = errno; + va_list args; + char *buf; + char buf2[4096]; + int errno_save = errno; - checkday(); + checkday(); - if (!fmt) { - return; - } + if (!fmt) { + return; + } - va_start(args, fmt); - vsnprintf(buf2, sizeof(buf2), fmt, args); - va_end(args); + va_start(args, fmt); + vsnprintf(buf2, sizeof(buf2), fmt, args); + va_end(args); - buf = log_gettimestamp(); + buf = log_gettimestamp(); - if (logfile) - fprintf(logfile, "%s FATAL: %s: %s\n", buf, buf2, - strerror(errno_save)); - if (nofork) - fprintf(stderr, "%s FATAL: %s: %s\n", buf, buf2, - strerror(errno_save)); - if (servsock >= 0) - ircdproto->SendGlobops(NULL, "FATAL ERROR! %s: %s", buf2, - strerror(errno_save)); + if (logfile) + fprintf(logfile, "%s FATAL: %s: %s\n", buf, buf2, + strerror(errno_save)); + if (nofork) + fprintf(stderr, "%s FATAL: %s: %s\n", buf, buf2, + strerror(errno_save)); + if (servsock >= 0) + ircdproto->SendGlobops(NULL, "FATAL ERROR! %s: %s", buf2, + strerror(errno_save)); - /* one of the many places this needs to be called from */ - ModuleRunTimeDirCleanUp(); + /* one of the many places this needs to be called from */ + ModuleRunTimeDirCleanUp(); - exit(1); + exit(1); } /*************************************************************************/ @@ -301,36 +301,36 @@ void fatal_perror(const char *fmt, ...) void fatal_sockerror(const char *fmt, ...) { - va_list args; - char *buf; - char buf2[4096]; - int errno_save = ano_sockgeterr(); - - if (!fmt) { - return; - } - - checkday(); - - /* this will fix 581 */ - va_start(args, fmt); - vsnprintf(buf2, sizeof(buf2), fmt, args); - va_end(args); - - buf = log_gettimestamp(); - - if (logfile) - fprintf(logfile, "%s FATAL: %s: %s\n", buf, buf2, - ano_sockstrerror(errno_save)); - if (stderr) - fprintf(stderr, "%s FATAL: %s: %s\n", buf, buf2, - ano_sockstrerror(errno_save)); - if (servsock >= 0) - ircdproto->SendGlobops(NULL, "FATAL ERROR! %s: %s", buf2, - strerror(errno_save)); - - /* one of the many places this needs to be called from */ - ModuleRunTimeDirCleanUp(); - - exit(1); + va_list args; + char *buf; + char buf2[4096]; + int errno_save = ano_sockgeterr(); + + if (!fmt) { + return; + } + + checkday(); + + /* this will fix 581 */ + va_start(args, fmt); + vsnprintf(buf2, sizeof(buf2), fmt, args); + va_end(args); + + buf = log_gettimestamp(); + + if (logfile) + fprintf(logfile, "%s FATAL: %s: %s\n", buf, buf2, + ano_sockstrerror(errno_save)); + if (stderr) + fprintf(stderr, "%s FATAL: %s: %s\n", buf, buf2, + ano_sockstrerror(errno_save)); + if (servsock >= 0) + ircdproto->SendGlobops(NULL, "FATAL ERROR! %s: %s", buf2, + strerror(errno_save)); + + /* one of the many places this needs to be called from */ + ModuleRunTimeDirCleanUp(); + + exit(1); } diff --git a/src/mail.c b/src/mail.c index 0d66086c2..43d8e7845 100644 --- a/src/mail.c +++ b/src/mail.c @@ -28,44 +28,44 @@ * @return MailInfo struct */ MailInfo *MailRegBegin(User * u, NickRequest * nr, char *subject, - char *service) + char *service) { - if (!u || !nr || !subject || !service) { - return NULL; - } - - if (!UseMail) { - notice_lang(service, u, MAIL_DISABLED); - } else if ((time(NULL) - u->lastmail < MailDelay) - || (time(NULL) - nr->lastmail < MailDelay)) { - notice_lang(service, u, MAIL_DELAYED, MailDelay); - } else if (!nr->email) { - notice_lang(service, u, MAIL_INVALID, nr->nick); - } else { - MailInfo *mail; - - mail = (MailInfo *)scalloc(sizeof(MailInfo), 1); - mail->sender = u; - mail->recipient = NULL; - mail->recip = nr; - - if (!(mail->pipe = popen(SendMailPath, "w"))) { - free(mail); - notice_lang(service, u, MAIL_LATER); - return NULL; - } - - fprintf(mail->pipe, "From: %s\n", SendFrom); - if (DontQuoteAddresses) { - fprintf(mail->pipe, "To: %s <%s>\n", nr->nick, nr->email); - } else { - fprintf(mail->pipe, "To: \"%s\" <%s>\n", nr->nick, nr->email); - } - fprintf(mail->pipe, "Subject: %s\n", subject); - return mail; - } - - return NULL; + if (!u || !nr || !subject || !service) { + return NULL; + } + + if (!UseMail) { + notice_lang(service, u, MAIL_DISABLED); + } else if ((time(NULL) - u->lastmail < MailDelay) + || (time(NULL) - nr->lastmail < MailDelay)) { + notice_lang(service, u, MAIL_DELAYED, MailDelay); + } else if (!nr->email) { + notice_lang(service, u, MAIL_INVALID, nr->nick); + } else { + MailInfo *mail; + + mail = (MailInfo *)scalloc(sizeof(MailInfo), 1); + mail->sender = u; + mail->recipient = NULL; + mail->recip = nr; + + if (!(mail->pipe = popen(SendMailPath, "w"))) { + free(mail); + notice_lang(service, u, MAIL_LATER); + return NULL; + } + + fprintf(mail->pipe, "From: %s\n", SendFrom); + if (DontQuoteAddresses) { + fprintf(mail->pipe, "To: %s <%s>\n", nr->nick, nr->email); + } else { + fprintf(mail->pipe, "To: \"%s\" <%s>\n", nr->nick, nr->email); + } + fprintf(mail->pipe, "Subject: %s\n", subject); + return mail; + } + + return NULL; } /*************************************************************************/ @@ -82,45 +82,45 @@ MailInfo *MailRegBegin(User * u, NickRequest * nr, char *subject, */ MailInfo *MailBegin(User * u, NickCore * nc, char *subject, char *service) { - if (!u || !nc || !subject || !service) { - return NULL; - } - - if (!UseMail) { - notice_lang(service, u, MAIL_DISABLED); - } else if (((time(NULL) - u->lastmail < MailDelay) - || (time(NULL) - nc->lastmail < MailDelay)) - && !is_services_root(u)) { - notice_lang(service, u, MAIL_DELAYED, MailDelay); - } else if (!nc->email) { - notice_lang(service, u, MAIL_INVALID, nc->display); - } else { - MailInfo *mail; - - mail = (MailInfo *)scalloc(sizeof(MailInfo), 1); - mail->sender = u; - mail->recipient = nc; - mail->recip = NULL; - - if (!(mail->pipe = popen(SendMailPath, "w"))) { - free(mail); - notice_lang(service, u, MAIL_LATER); - return NULL; - } - - fprintf(mail->pipe, "From: %s\n", SendFrom); - if (DontQuoteAddresses) { - fprintf(mail->pipe, "To: %s <%s>\n", nc->display, nc->email); - } else { - fprintf(mail->pipe, "To: \"%s\" <%s>\n", nc->display, - nc->email); - } - fprintf(mail->pipe, "Subject: %s\n", subject); - - return mail; - } - - return NULL; + if (!u || !nc || !subject || !service) { + return NULL; + } + + if (!UseMail) { + notice_lang(service, u, MAIL_DISABLED); + } else if (((time(NULL) - u->lastmail < MailDelay) + || (time(NULL) - nc->lastmail < MailDelay)) + && !is_services_root(u)) { + notice_lang(service, u, MAIL_DELAYED, MailDelay); + } else if (!nc->email) { + notice_lang(service, u, MAIL_INVALID, nc->display); + } else { + MailInfo *mail; + + mail = (MailInfo *)scalloc(sizeof(MailInfo), 1); + mail->sender = u; + mail->recipient = nc; + mail->recip = NULL; + + if (!(mail->pipe = popen(SendMailPath, "w"))) { + free(mail); + notice_lang(service, u, MAIL_LATER); + return NULL; + } + + fprintf(mail->pipe, "From: %s\n", SendFrom); + if (DontQuoteAddresses) { + fprintf(mail->pipe, "To: %s <%s>\n", nc->display, nc->email); + } else { + fprintf(mail->pipe, "To: \"%s\" <%s>\n", nc->display, + nc->email); + } + fprintf(mail->pipe, "Subject: %s\n", subject); + + return mail; + } + + return NULL; } /*************************************************************************/ @@ -133,37 +133,37 @@ MailInfo *MailBegin(User * u, NickCore * nc, char *subject, char *service) MailInfo *MailMemoBegin(NickCore * nc) { - if (!nc) - return NULL; - - if (!UseMail || !nc->email) { - return NULL; - - } else { - MailInfo *mail; - - mail = (MailInfo *)scalloc(sizeof(MailInfo), 1); - mail->sender = NULL; - mail->recipient = nc; - mail->recip = NULL; - - if (!(mail->pipe = popen(SendMailPath, "w"))) { - free(mail); - return NULL; - } - - fprintf(mail->pipe, "From: %s\n", SendFrom); - if (DontQuoteAddresses) { - fprintf(mail->pipe, "To: %s <%s>\n", nc->display, nc->email); - } else { - fprintf(mail->pipe, "To: \"%s\" <%s>\n", nc->display, - nc->email); - } - fprintf(mail->pipe, "Subject: %s\n", - getstring2(NULL, MEMO_MAIL_SUBJECT)); - return mail; - } - return NULL; + if (!nc) + return NULL; + + if (!UseMail || !nc->email) { + return NULL; + + } else { + MailInfo *mail; + + mail = (MailInfo *)scalloc(sizeof(MailInfo), 1); + mail->sender = NULL; + mail->recipient = nc; + mail->recip = NULL; + + if (!(mail->pipe = popen(SendMailPath, "w"))) { + free(mail); + return NULL; + } + + fprintf(mail->pipe, "From: %s\n", SendFrom); + if (DontQuoteAddresses) { + fprintf(mail->pipe, "To: %s <%s>\n", nc->display, nc->email); + } else { + fprintf(mail->pipe, "To: \"%s\" <%s>\n", nc->display, + nc->email); + } + fprintf(mail->pipe, "Subject: %s\n", + getstring2(NULL, MEMO_MAIL_SUBJECT)); + return mail; + } + return NULL; } /*************************************************************************/ @@ -175,30 +175,30 @@ MailInfo *MailMemoBegin(NickCore * nc) */ void MailEnd(MailInfo * mail) { - /* - param checking modified because we don't - have an user sending this mail. - Certus, 02.04.2004 */ + /* - param checking modified because we don't + have an user sending this mail. + Certus, 02.04.2004 */ - if (!mail || !mail->pipe) { /* removed sender check */ - return; - } + if (!mail || !mail->pipe) { /* removed sender check */ + return; + } - if (!mail->recipient && !mail->recip) { - return; - } + if (!mail->recipient && !mail->recip) { + return; + } - pclose(mail->pipe); + pclose(mail->pipe); - if (mail->sender) /* added sender check */ - mail->sender->lastmail = time(NULL); + if (mail->sender) /* added sender check */ + mail->sender->lastmail = time(NULL); - if (mail->recipient) - mail->recipient->lastmail = time(NULL); - else - mail->recip->lastmail = time(NULL); + if (mail->recipient) + mail->recipient->lastmail = time(NULL); + else + mail->recip->lastmail = time(NULL); - free(mail); + free(mail); } /*************************************************************************/ @@ -211,10 +211,10 @@ void MailEnd(MailInfo * mail) */ void MailReset(User * u, NickCore * nc) { - if (u) - u->lastmail = 0; - if (nc) - nc->lastmail = 0; + if (u) + u->lastmail = 0; + if (nc) + nc->lastmail = 0; } /*************************************************************************/ @@ -231,54 +231,54 @@ void MailReset(User * u, NickCore * nc) */ int MailValidate(const char *email) { - int has_period = 0, len; - char copy[BUFSIZE], *domain; - - static char specials[] = - { '(', ')', '<', '>', '@', ',', ';', ':', '\\', '\"', '[', ']', - ' ' - }; - - if (!email) - return 0; - strcpy(copy, email); - - domain = strchr(copy, '@'); - if (!domain) - return 0; - *domain = '\0'; - domain++; - - /* Don't accept NULL copy or domain. */ - if (*copy == 0 || *domain == 0) - return 0; - - /* Check for forbidden characters in the name */ - for (unsigned int i = 0; i < strlen(copy); i++) { - - if (copy[i] <= 31 || copy[i] >= 127) - return 0; - for (unsigned int j = 0; j < 13; j++) - if (copy[i] == specials[j]) - return 0; - } - - /* Check for forbidden characters in the domain, and if it seems to be valid. */ - for (int i = 0; i < (len = strlen(domain)); i++) { - if (domain[i] <= 31 || domain[i] >= 127) - return 0; - for (unsigned int j = 0; j < 13; j++) - if (domain[i] == specials[j]) - return 0; - if (domain[i] == '.') { - if (i == 0 || i == len - 1) - return 0; - has_period = 1; - } - } - - if (!has_period) - return 0; - - return 1; + int has_period = 0, len; + char copy[BUFSIZE], *domain; + + static char specials[] = + { '(', ')', '<', '>', '@', ',', ';', ':', '\\', '\"', '[', ']', + ' ' + }; + + if (!email) + return 0; + strcpy(copy, email); + + domain = strchr(copy, '@'); + if (!domain) + return 0; + *domain = '\0'; + domain++; + + /* Don't accept NULL copy or domain. */ + if (*copy == 0 || *domain == 0) + return 0; + + /* Check for forbidden characters in the name */ + for (unsigned int i = 0; i < strlen(copy); i++) { + + if (copy[i] <= 31 || copy[i] >= 127) + return 0; + for (unsigned int j = 0; j < 13; j++) + if (copy[i] == specials[j]) + return 0; + } + + /* Check for forbidden characters in the domain, and if it seems to be valid. */ + for (int i = 0; i < (len = strlen(domain)); i++) { + if (domain[i] <= 31 || domain[i] >= 127) + return 0; + for (unsigned int j = 0; j < 13; j++) + if (domain[i] == specials[j]) + return 0; + if (domain[i] == '.') { + if (i == 0 || i == len - 1) + return 0; + has_period = 1; + } + } + + if (!has_period) + return 0; + + return 1; } diff --git a/src/main.c b/src/main.c index e29249311..dcbf8a303 100644 --- a/src/main.c +++ b/src/main.c @@ -34,19 +34,19 @@ /******** Global variables! ********/ /* Command-line options: (note that configuration variables are in config.c) */ -const char *services_dir = SERVICES_DIR; /* -dir dirname */ -const char *log_filename = LOG_FILENAME; /* -log filename */ -int debug = 0; /* -debug */ -int readonly = 0; /* -readonly */ -int logchan = 0; /* -logchan */ -int nofork = 0; /* -nofork */ -int forceload = 0; /* -forceload */ -int nothird = 0; /* -nothrid */ -int noexpire = 0; /* -noexpire */ -int protocoldebug = 0; /* -protocoldebug */ +const char *services_dir = SERVICES_DIR; /* -dir dirname */ +const char *log_filename = LOG_FILENAME; /* -log filename */ +int debug = 0; /* -debug */ +int readonly = 0; /* -readonly */ +int logchan = 0; /* -logchan */ +int nofork = 0; /* -nofork */ +int forceload = 0; /* -forceload */ +int nothird = 0; /* -nothrid */ +int noexpire = 0; /* -noexpire */ +int protocoldebug = 0; /* -protocoldebug */ #ifdef _WIN32 -char *binary_dir; /* Used to store base path for win32 restart */ +char *binary_dir; /* Used to store base path for win32 restart */ #endif /* Set to 1 if we are to quit */ @@ -77,7 +77,7 @@ char **my_av, **my_envp; const char version_number[] = VERSION_STRING; const char version_number_dotted[] = VERSION_STRING_DOTTED; const char version_build[] = - "build #" BUILD ", compiled " __DATE__ " " __TIME__; + "build #" BUILD ", compiled " __DATE__ " " __TIME__; /* the space is needed cause if you build with nothing it will complain */ const char version_flags[] = " " VER_OS VER_MYSQL VER_MODULE; @@ -97,72 +97,72 @@ static int started = 0; extern void expire_all(void) { - waiting = -30; - send_event(EVENT_DB_EXPIRE, 1, EVENT_START); - waiting = -3; - if (debug) - alog("debug: Running expire routines"); - waiting = -21; - expire_nicks(); - waiting = -22; - expire_chans(); - waiting = -23; - expire_requests(); - waiting = -25; - expire_akills(); - if (ircd->sgline) { - waiting = -26; - expire_sglines(); - } - if (ircd->sqline) { - waiting = -28; - expire_sqlines(); - } - if (ircd->szline) { - waiting = -27; - expire_szlines(); - } - waiting = -29; - expire_exceptions(); - waiting = -31; - send_event(EVENT_DB_EXPIRE, 1, EVENT_STOP); + waiting = -30; + send_event(EVENT_DB_EXPIRE, 1, EVENT_START); + waiting = -3; + if (debug) + alog("debug: Running expire routines"); + waiting = -21; + expire_nicks(); + waiting = -22; + expire_chans(); + waiting = -23; + expire_requests(); + waiting = -25; + expire_akills(); + if (ircd->sgline) { + waiting = -26; + expire_sglines(); + } + if (ircd->sqline) { + waiting = -28; + expire_sqlines(); + } + if (ircd->szline) { + waiting = -27; + expire_szlines(); + } + waiting = -29; + expire_exceptions(); + waiting = -31; + send_event(EVENT_DB_EXPIRE, 1, EVENT_STOP); } /*************************************************************************/ void save_databases(void) { - waiting = -19; - send_event(EVENT_DB_SAVING, 1, EVENT_START); - waiting = -2; - if (debug) - alog("debug: Saving FFF databases"); - waiting = -10; - backup_databases(); - waiting = -11; - save_ns_dbase(); - waiting = -12; - if (PreNickDBName) { - save_ns_req_dbase(); - waiting = -13; - } - save_cs_dbase(); - if (s_BotServ) { - waiting = -14; - save_bs_dbase(); - } - if (s_HostServ) { - waiting = -15; - save_hs_dbase(); - } - waiting = -16; - save_os_dbase(); - waiting = -17; - save_news(); - waiting = -18; - save_exceptions(); - waiting = -20; - send_event(EVENT_DB_SAVING, 1, EVENT_STOP); + waiting = -19; + send_event(EVENT_DB_SAVING, 1, EVENT_START); + waiting = -2; + if (debug) + alog("debug: Saving FFF databases"); + waiting = -10; + backup_databases(); + waiting = -11; + save_ns_dbase(); + waiting = -12; + if (PreNickDBName) { + save_ns_req_dbase(); + waiting = -13; + } + save_cs_dbase(); + if (s_BotServ) { + waiting = -14; + save_bs_dbase(); + } + if (s_HostServ) { + waiting = -15; + save_hs_dbase(); + } + waiting = -16; + save_os_dbase(); + waiting = -17; + save_news(); + waiting = -18; + save_exceptions(); + waiting = -20; + send_event(EVENT_DB_SAVING, 1, EVENT_STOP); } /*************************************************************************/ @@ -171,28 +171,28 @@ void save_databases(void) static void services_restart(void) { - alog("Restarting"); - send_event(EVENT_RESTART, 1, EVENT_START); - if (!quitmsg) - quitmsg = "Restarting"; - ircdproto->SendSquit(ServerName, quitmsg); - disconn(servsock); - close_log(); - /* First don't unload protocol module, then do so */ - modules_unload_all(true, false); - modules_unload_all(true, true); + alog("Restarting"); + send_event(EVENT_RESTART, 1, EVENT_START); + if (!quitmsg) + quitmsg = "Restarting"; + ircdproto->SendSquit(ServerName, quitmsg); + disconn(servsock); + close_log(); + /* First don't unload protocol module, then do so */ + modules_unload_all(true, false); + modules_unload_all(true, true); #ifdef _WIN32 - /* This fixes bug #589 - change to binary directory for restart */ - /* -- heinz */ - if (binary_dir) - chdir(binary_dir); + /* This fixes bug #589 - change to binary directory for restart */ + /* -- heinz */ + if (binary_dir) + chdir(binary_dir); #endif - execve(SERVICES_BIN, my_av, my_envp); - if (!readonly) { - open_log(); - log_perror("Restart failed"); - close_log(); - } + execve(SERVICES_BIN, my_av, my_envp); + if (!readonly) { + open_log(); + log_perror("Restart failed"); + close_log(); + } } /*************************************************************************/ @@ -202,12 +202,12 @@ static void services_restart(void) **/ void do_restart_services(void) { - if (!readonly) { - expire_all(); - save_databases(); - } - services_restart(); - exit(1); + if (!readonly) { + expire_all(); + save_databases(); + } + services_restart(); + exit(1); } /*************************************************************************/ @@ -216,34 +216,34 @@ void do_restart_services(void) static void services_shutdown(void) { - User *u, *next; - - send_event(EVENT_SHUTDOWN, 1, EVENT_START); - - if (!quitmsg) - quitmsg = "Terminating, reason unknown"; - alog("%s", quitmsg); - if (started) { - ircdproto->SendSquit(ServerName, quitmsg); - Anope_Free(uplink); - Anope_Free(mod_current_buffer); - if (ircd->chanmodes) { - Anope_Free(ircd->chanmodes); - } - u = firstuser(); - while (u) { - next = nextuser(); - delete u; - u = next; - } - } - send_event(EVENT_SHUTDOWN, 1, EVENT_STOP); - disconn(servsock); - /* First don't unload protocol module, then do so */ - modules_unload_all(true, false); - modules_unload_all(true, true); - /* just in case they weren't all removed at least run once */ - ModuleRunTimeDirCleanUp(); + User *u, *next; + + send_event(EVENT_SHUTDOWN, 1, EVENT_START); + + if (!quitmsg) + quitmsg = "Terminating, reason unknown"; + alog("%s", quitmsg); + if (started) { + ircdproto->SendSquit(ServerName, quitmsg); + Anope_Free(uplink); + Anope_Free(mod_current_buffer); + if (ircd->chanmodes) { + Anope_Free(ircd->chanmodes); + } + u = firstuser(); + while (u) { + next = nextuser(); + delete u; + u = next; + } + } + send_event(EVENT_SHUTDOWN, 1, EVENT_STOP); + disconn(servsock); + /* First don't unload protocol module, then do so */ + modules_unload_all(true, false); + modules_unload_all(true, true); + /* just in case they weren't all removed at least run once */ + ModuleRunTimeDirCleanUp(); } /*************************************************************************/ @@ -252,190 +252,190 @@ static void services_shutdown(void) void sighandler(int signum) { - /* We set the quit message to something default, just to be sure it is - * always set when we need it. It seems some signals slip through to the - * QUIT code without having a valid quitmsg. -GD - */ - quitmsg = sstrdup("Signal Received"); - if (started) { + /* We set the quit message to something default, just to be sure it is + * always set when we need it. It seems some signals slip through to the + * QUIT code without having a valid quitmsg. -GD + */ + quitmsg = sstrdup("Signal Received"); + if (started) { #ifndef _WIN32 - if (signum == SIGHUP) { /* SIGHUP = save databases and restart */ - signal(SIGHUP, SIG_IGN); - signal(SIGUSR2, SIG_IGN); - alog("Received SIGHUP, restarting."); + if (signum == SIGHUP) { /* SIGHUP = save databases and restart */ + signal(SIGHUP, SIG_IGN); + signal(SIGUSR2, SIG_IGN); + alog("Received SIGHUP, restarting."); - expire_all(); - save_databases(); + expire_all(); + save_databases(); - if (!quitmsg) - quitmsg = "Restarting on SIGHUP"; + if (!quitmsg) + quitmsg = "Restarting on SIGHUP"; #ifdef SERVICES_BIN - services_restart(); - exit(1); + services_restart(); + exit(1); #else - quitmsg = - "Restart attempt failed--SERVICES_BIN not defined (rerun configure)"; + quitmsg = + "Restart attempt failed--SERVICES_BIN not defined (rerun configure)"; #endif - } else if (signum == SIGQUIT) { - /* had to move it to here to make win32 happy */ - } else if (signum == SIGUSR2) { + } else if (signum == SIGQUIT) { + /* had to move it to here to make win32 happy */ + } else if (signum == SIGUSR2) { - alog("Received SIGUSR2: Saving Databases & Rehash Configuration"); + alog("Received SIGUSR2: Saving Databases & Rehash Configuration"); - expire_all(); - save_databases(); + expire_all(); + save_databases(); - if (!read_config(1)) { - quitmsg = "Error Reading Configuration File (Received SIGUSR2)"; - quitting = 1; - } - send_event(EVENT_RELOAD, 1, EVENT_START); - return; + if (!read_config(1)) { + quitmsg = "Error Reading Configuration File (Received SIGUSR2)"; + quitting = 1; + } + send_event(EVENT_RELOAD, 1, EVENT_START); + return; - } else + } else #endif - if (signum == SIGTERM) { - signal(SIGTERM, SIG_IGN); + if (signum == SIGTERM) { + signal(SIGTERM, SIG_IGN); #ifndef _WIN32 - signal(SIGHUP, SIG_IGN); + signal(SIGHUP, SIG_IGN); #endif - alog("Received SIGTERM, exiting."); - - expire_all(); - save_databases(); - quitmsg = "Shutting down on SIGTERM"; - services_shutdown(); - exit(0); - } else if (signum == SIGINT) { - if (nofork) { - signal(SIGINT, SIG_IGN); - alog("Received SIGINT, exiting."); - expire_all(); - save_databases(); - quitmsg = "Shutting down on SIGINT"; - services_shutdown(); - exit(0); - } - } else if (!waiting) { - alog("PANIC! buffer = %s", inbuf); - /* Cut off if this would make IRC command >510 characters. */ - if (strlen(inbuf) > 448) { - inbuf[446] = '>'; - inbuf[447] = '>'; - inbuf[448] = 0; - } - ircdproto->SendGlobops(NULL, "PANIC! buffer = %s\r\n", inbuf); - modules_unload_all(false, true); - } else if (waiting < 0) { - /* This is static on the off-chance we run low on stack */ - static char buf[BUFSIZE]; - switch (waiting) { - case -1: - snprintf(buf, sizeof(buf), "in timed_update"); - break; - case -10: - snprintf(buf, sizeof(buf), "backing up databases"); - break; - case -11: - snprintf(buf, sizeof(buf), "saving %s", NickDBName); - break; - case -12: - snprintf(buf, sizeof(buf), "saving %s", ChanDBName); - break; - case -13: - snprintf(buf, sizeof(buf), "saving %s", PreNickDBName); - break; - case -14: - snprintf(buf, sizeof(buf), "saving %s", BotDBName); - break; - case -15: - snprintf(buf, sizeof(buf), "saving %s", HostDBName); - break; - case -16: - snprintf(buf, sizeof(buf), "saving %s", OperDBName); - break; - case -17: - snprintf(buf, sizeof(buf), "saving %s", NewsDBName); - break; - case -18: - snprintf(buf, sizeof(buf), "saving %s", ExceptionDBName); - break; - case -19: - snprintf(buf, sizeof(buf), "Sending event %s %s", - EVENT_DB_SAVING, EVENT_START); - break; - case -20: - snprintf(buf, sizeof(buf), "Sending event %s %s", - EVENT_DB_SAVING, EVENT_STOP); - break; - case -21: - snprintf(buf, sizeof(buf), "expiring nicknames"); - break; - case -22: - snprintf(buf, sizeof(buf), "expiring channels"); - break; - case -25: - snprintf(buf, sizeof(buf), "expiring autokills"); - break; - case -26: - snprintf(buf, sizeof(buf), "expiring SGLINEs"); - break; - case -27: - snprintf(buf, sizeof(buf), "expiring SZLINEs"); - break; - case -28: - snprintf(buf, sizeof(buf), "expiring SQLINEs"); - break; - case -29: - snprintf(buf, sizeof(buf), "expiring Exceptions"); - break; - case -30: - snprintf(buf, sizeof(buf), "Sending event %s %s", - EVENT_DB_EXPIRE, EVENT_START); - break; - case -31: - snprintf(buf, sizeof(buf), "Sending event %s %s", - EVENT_DB_EXPIRE, EVENT_STOP); - break; - default: - snprintf(buf, sizeof(buf), "waiting=%d", waiting); - } - ircdproto->SendGlobops(NULL, "PANIC! %s (caught signal %d)", buf, signum); - alog("PANIC! %s (caught signal %d)", buf, signum); - modules_unload_all(false, true); - } - } - - if ( + alog("Received SIGTERM, exiting."); + + expire_all(); + save_databases(); + quitmsg = "Shutting down on SIGTERM"; + services_shutdown(); + exit(0); + } else if (signum == SIGINT) { + if (nofork) { + signal(SIGINT, SIG_IGN); + alog("Received SIGINT, exiting."); + expire_all(); + save_databases(); + quitmsg = "Shutting down on SIGINT"; + services_shutdown(); + exit(0); + } + } else if (!waiting) { + alog("PANIC! buffer = %s", inbuf); + /* Cut off if this would make IRC command >510 characters. */ + if (strlen(inbuf) > 448) { + inbuf[446] = '>'; + inbuf[447] = '>'; + inbuf[448] = 0; + } + ircdproto->SendGlobops(NULL, "PANIC! buffer = %s\r\n", inbuf); + modules_unload_all(false, true); + } else if (waiting < 0) { + /* This is static on the off-chance we run low on stack */ + static char buf[BUFSIZE]; + switch (waiting) { + case -1: + snprintf(buf, sizeof(buf), "in timed_update"); + break; + case -10: + snprintf(buf, sizeof(buf), "backing up databases"); + break; + case -11: + snprintf(buf, sizeof(buf), "saving %s", NickDBName); + break; + case -12: + snprintf(buf, sizeof(buf), "saving %s", ChanDBName); + break; + case -13: + snprintf(buf, sizeof(buf), "saving %s", PreNickDBName); + break; + case -14: + snprintf(buf, sizeof(buf), "saving %s", BotDBName); + break; + case -15: + snprintf(buf, sizeof(buf), "saving %s", HostDBName); + break; + case -16: + snprintf(buf, sizeof(buf), "saving %s", OperDBName); + break; + case -17: + snprintf(buf, sizeof(buf), "saving %s", NewsDBName); + break; + case -18: + snprintf(buf, sizeof(buf), "saving %s", ExceptionDBName); + break; + case -19: + snprintf(buf, sizeof(buf), "Sending event %s %s", + EVENT_DB_SAVING, EVENT_START); + break; + case -20: + snprintf(buf, sizeof(buf), "Sending event %s %s", + EVENT_DB_SAVING, EVENT_STOP); + break; + case -21: + snprintf(buf, sizeof(buf), "expiring nicknames"); + break; + case -22: + snprintf(buf, sizeof(buf), "expiring channels"); + break; + case -25: + snprintf(buf, sizeof(buf), "expiring autokills"); + break; + case -26: + snprintf(buf, sizeof(buf), "expiring SGLINEs"); + break; + case -27: + snprintf(buf, sizeof(buf), "expiring SZLINEs"); + break; + case -28: + snprintf(buf, sizeof(buf), "expiring SQLINEs"); + break; + case -29: + snprintf(buf, sizeof(buf), "expiring Exceptions"); + break; + case -30: + snprintf(buf, sizeof(buf), "Sending event %s %s", + EVENT_DB_EXPIRE, EVENT_START); + break; + case -31: + snprintf(buf, sizeof(buf), "Sending event %s %s", + EVENT_DB_EXPIRE, EVENT_STOP); + break; + default: + snprintf(buf, sizeof(buf), "waiting=%d", waiting); + } + ircdproto->SendGlobops(NULL, "PANIC! %s (caught signal %d)", buf, signum); + alog("PANIC! %s (caught signal %d)", buf, signum); + modules_unload_all(false, true); + } + } + + if ( #ifndef _WIN32 - signum == SIGUSR1 || + signum == SIGUSR1 || #endif - !(quitmsg = (const char *)calloc(BUFSIZE, 1))) { - quitmsg = "Out of memory!"; - } else { - snprintf((char *)quitmsg, BUFSIZE, "Services terminating on signal %d", signum); - } - - if (signum == SIGSEGV) { - do_backtrace(1); - modules_unload_all(false, true); /* probably cant do this, but might as well try, we have nothing left to loose */ - } - /* Should we send the signum here as well? -GD */ - send_event(EVENT_SIGNAL, 1, quitmsg); - - if (started) { - services_shutdown(); - exit(0); - } else { - if (isatty(2)) { - fprintf(stderr, "%s\n", quitmsg); - } else { - alog("%s", quitmsg); - } - exit(1); - } + !(quitmsg = (const char *)calloc(BUFSIZE, 1))) { + quitmsg = "Out of memory!"; + } else { + snprintf((char *)quitmsg, BUFSIZE, "Services terminating on signal %d", signum); + } + + if (signum == SIGSEGV) { + do_backtrace(1); + modules_unload_all(false, true); /* probably cant do this, but might as well try, we have nothing left to loose */ + } + /* Should we send the signum here as well? -GD */ + send_event(EVENT_SIGNAL, 1, quitmsg); + + if (started) { + services_shutdown(); + exit(0); + } else { + if (isatty(2)) { + fprintf(stderr, "%s\n", quitmsg); + } else { + alog("%s", quitmsg); + } + exit(1); + } } /*************************************************************************/ @@ -444,175 +444,175 @@ void sighandler(int signum) int main(int ac, char **av, char **envp) { - volatile time_t last_update; /* When did we last update the databases? */ - volatile time_t last_expire; /* When did we last expire nicks/channels? */ - volatile time_t last_check; /* When did we last check timeouts? */ - volatile time_t last_DefCon; /* When was DefCon last checked? */ + volatile time_t last_update; /* When did we last update the databases? */ + volatile time_t last_expire; /* When did we last expire nicks/channels? */ + volatile time_t last_check; /* When did we last check timeouts? */ + volatile time_t last_DefCon; /* When was DefCon last checked? */ - int i; - char *progname; + int i; + char *progname; - my_av = av; - my_envp = envp; + my_av = av; + my_envp = envp; #ifndef _WIN32 - /* If we're root, issue a warning now */ - if ((getuid() == 0) && (getgid() == 0)) { - fprintf(stderr, - "WARNING: You are currently running Anope as the root superuser. Anope does not\n"); - fprintf(stderr, - " require root privileges to run, and it is discouraged that you run Anope\n"); - fprintf(stderr, " as the root superuser.\n"); - } + /* If we're root, issue a warning now */ + if ((getuid() == 0) && (getgid() == 0)) { + fprintf(stderr, + "WARNING: You are currently running Anope as the root superuser. Anope does not\n"); + fprintf(stderr, + " require root privileges to run, and it is discouraged that you run Anope\n"); + fprintf(stderr, " as the root superuser.\n"); + } #else - /* - * We need to know which directory we're in for when restart is called. - * This only affects Windows as a full path is not specified in services_dir. - * This fixes bug #589. - * -- heinz - */ - binary_dir = smalloc(MAX_PATH); - if (!getcwd(binary_dir, MAX_PATH)) { - fprintf(stderr, "error: getcwd() error\n"); - return -1; - } + /* + * We need to know which directory we're in for when restart is called. + * This only affects Windows as a full path is not specified in services_dir. + * This fixes bug #589. + * -- heinz + */ + binary_dir = smalloc(MAX_PATH); + if (!getcwd(binary_dir, MAX_PATH)) { + fprintf(stderr, "error: getcwd() error\n"); + return -1; + } #endif - /* General initialization first */ - if ((i = init_primary(ac, av)) != 0) - return i; + /* General initialization first */ + if ((i = init_primary(ac, av)) != 0) + return i; - /* Find program name. */ - if ((progname = strrchr(av[0], '/')) != NULL) - progname++; - else - progname = av[0]; + /* Find program name. */ + if ((progname = strrchr(av[0], '/')) != NULL) + progname++; + else + progname = av[0]; - /* Initialization stuff. */ - if ((i = init_secondary(ac, av)) != 0) - return i; + /* Initialization stuff. */ + if ((i = init_secondary(ac, av)) != 0) + return i; - /* We have a line left over from earlier, so process it first. */ - process(); + /* We have a line left over from earlier, so process it first. */ + process(); - /* Set up timers. */ - last_update = time(NULL); - last_expire = time(NULL); - last_check = time(NULL); - last_DefCon = time(NULL); + /* Set up timers. */ + last_update = time(NULL); + last_expire = time(NULL); + last_check = time(NULL); + last_DefCon = time(NULL); - started = 1; + started = 1; - /*** Main loop. ***/ + /*** Main loop. ***/ - while (!quitting) { - time_t t = time(NULL); + while (!quitting) { + time_t t = time(NULL); - if (debug >= 2) - alog("debug: Top of main loop"); + if (debug >= 2) + alog("debug: Top of main loop"); - if (!noexpire && !readonly - && (save_data || t - last_expire >= ExpireTimeout)) { - expire_all(); - last_expire = t; - } + if (!noexpire && !readonly + && (save_data || t - last_expire >= ExpireTimeout)) { + expire_all(); + last_expire = t; + } - if (!readonly && (save_data || t - last_update >= UpdateTimeout)) { - if (delayed_quit) - ircdproto->SendGlobops(NULL, - "Updating databases on shutdown, please wait."); + if (!readonly && (save_data || t - last_update >= UpdateTimeout)) { + if (delayed_quit) + ircdproto->SendGlobops(NULL, + "Updating databases on shutdown, please wait."); - save_databases(); + save_databases(); - if (save_data < 0) - break; /* out of main loop */ + if (save_data < 0) + break; /* out of main loop */ - save_data = 0; - last_update = t; - } + save_data = 0; + last_update = t; + } - if ((DefConTimeOut) && (t - last_DefCon >= DefConTimeOut)) { - resetDefCon(5); - last_DefCon = t; - } + if ((DefConTimeOut) && (t - last_DefCon >= DefConTimeOut)) { + resetDefCon(5); + last_DefCon = t; + } - if (delayed_quit) - break; + if (delayed_quit) + break; - moduleCallBackRun(); + moduleCallBackRun(); - waiting = -1; - if (t - last_check >= TimeoutCheck) { - check_timeouts(); - last_check = t; - } + waiting = -1; + if (t - last_check >= TimeoutCheck) { + check_timeouts(); + last_check = t; + } - waiting = 1; - /* this is a nasty nasty typecast. we need to rewrite the - socket stuff -Certus */ - i = (int) (long) sgets2(inbuf, sizeof(inbuf), servsock); - waiting = 0; - if ((i > 0) || (i < (-1))) { - process(); - } else if (i == 0) { - int errno_save = errno; - quitmsg = (const char *)scalloc(BUFSIZE, 1); - if (quitmsg) { + waiting = 1; + /* this is a nasty nasty typecast. we need to rewrite the + socket stuff -Certus */ + i = (int) (long) sgets2(inbuf, sizeof(inbuf), servsock); + waiting = 0; + if ((i > 0) || (i < (-1))) { + process(); + } else if (i == 0) { + int errno_save = errno; + quitmsg = (const char *)scalloc(BUFSIZE, 1); + if (quitmsg) { // Naughty, but oh well. :) - snprintf((char *)quitmsg, BUFSIZE, - "Read error from server: %s (error num: %d)", - strerror(errno_save), errno_save); - } else { - quitmsg = "Read error from server"; - } - quitting = 1; - - /* Save the databases */ - if (!readonly) - save_databases(); - } - waiting = -4; - } - - - /* Check for restart instead of exit */ - if (save_data == -2) { + snprintf((char *)quitmsg, BUFSIZE, + "Read error from server: %s (error num: %d)", + strerror(errno_save), errno_save); + } else { + quitmsg = "Read error from server"; + } + quitting = 1; + + /* Save the databases */ + if (!readonly) + save_databases(); + } + waiting = -4; + } + + + /* Check for restart instead of exit */ + if (save_data == -2) { #ifdef SERVICES_BIN - alog("Restarting"); - if (!quitmsg) - quitmsg = "Restarting"; - ircdproto->SendSquit(ServerName, quitmsg); - disconn(servsock); - close_log(); + alog("Restarting"); + if (!quitmsg) + quitmsg = "Restarting"; + ircdproto->SendSquit(ServerName, quitmsg); + disconn(servsock); + close_log(); #ifdef _WIN32 - /* This fixes bug #589 - change to binary directory for restart */ - /* -- heinz */ - if (binary_dir) - chdir(binary_dir); + /* This fixes bug #589 - change to binary directory for restart */ + /* -- heinz */ + if (binary_dir) + chdir(binary_dir); #endif - execve(SERVICES_BIN, av, envp); - if (!readonly) { - open_log(); - log_perror("Restart failed"); - close_log(); - } - return 1; + execve(SERVICES_BIN, av, envp); + if (!readonly) { + open_log(); + log_perror("Restart failed"); + close_log(); + } + return 1; #else - quitmsg = - "Restart attempt failed--SERVICES_BIN not defined (rerun configure)"; + quitmsg = + "Restart attempt failed--SERVICES_BIN not defined (rerun configure)"; #endif - } + } - /* Disconnect and exit */ - services_shutdown(); + /* Disconnect and exit */ + services_shutdown(); #ifdef _WIN32 - if (binary_dir) - free(binary_dir); + if (binary_dir) + free(binary_dir); #endif - return 0; + return 0; } /*************************************************************************/ @@ -621,32 +621,32 @@ void do_backtrace(int show_segheader) { #ifndef _WIN32 #ifdef HAVE_BACKTRACE - void *array[50]; - size_t size; - char **strings; - int i; - - if (show_segheader) { - alog("Backtrace: Segmentation fault detected"); - alog("Backtrace: report the following lines"); - } - alog("Backtrace: Anope version %s %s %s", version_number, - version_build, version_flags); - size = backtrace(array, 10); - strings = backtrace_symbols(array, size); - for (i = 0; i < size; i++) { - alog("Backtrace(%d): %s", i, strings[i]); - } - free(strings); - alog("Backtrace: complete"); + void *array[50]; + size_t size; + char **strings; + int i; + + if (show_segheader) { + alog("Backtrace: Segmentation fault detected"); + alog("Backtrace: report the following lines"); + } + alog("Backtrace: Anope version %s %s %s", version_number, + version_build, version_flags); + size = backtrace(array, 10); + strings = backtrace_symbols(array, size); + for (i = 0; i < size; i++) { + alog("Backtrace(%d): %s", i, strings[i]); + } + free(strings); + alog("Backtrace: complete"); #else - alog("Backtrace: not available on this platform"); + alog("Backtrace: not available on this platform"); #endif #else - char *winver; - winver = GetWindowsVersion(); - alog("Backtrace: not available on Windows"); - alog("Running %S", winver); - free(winver); + char *winver; + winver = GetWindowsVersion(); + alog("Backtrace: not available on Windows"); + alog("Running %S", winver); + free(winver); #endif } diff --git a/src/memory.c b/src/memory.c index 056a29a76..30fe46627 100644 --- a/src/memory.c +++ b/src/memory.c @@ -30,19 +30,19 @@ */ void *smalloc(long size) { - void *buf; + void *buf; - if (!size) { - size = 1; - } - buf = malloc(size); - if (!buf) + if (!size) { + size = 1; + } + buf = malloc(size); + if (!buf) #ifndef _WIN32 - raise(SIGUSR1); + raise(SIGUSR1); #else - abort(); + abort(); #endif - return buf; + return buf; } /*************************************************************************/ @@ -55,19 +55,19 @@ void *smalloc(long size) */ void *scalloc(long elsize, long els) { - void *buf; + void *buf; - if (!elsize || !els) { - elsize = els = 1; - } - buf = calloc(elsize, els); - if (!buf) + if (!elsize || !els) { + elsize = els = 1; + } + buf = calloc(elsize, els); + if (!buf) #ifndef _WIN32 - raise(SIGUSR1); + raise(SIGUSR1); #else - abort(); + abort(); #endif - return buf; + return buf; } /*************************************************************************/ @@ -80,19 +80,19 @@ void *scalloc(long elsize, long els) */ void *srealloc(void *oldptr, long newsize) { - void *buf; + void *buf; - if (!newsize) { - newsize = 1; - } - buf = realloc(oldptr, newsize); - if (!buf) + if (!newsize) { + newsize = 1; + } + buf = realloc(oldptr, newsize); + if (!buf) #ifndef _WIN32 - raise(SIGUSR1); + raise(SIGUSR1); #else - abort(); + abort(); #endif - return buf; + return buf; } /*************************************************************************/ @@ -105,28 +105,28 @@ void *srealloc(void *oldptr, long newsize) */ char *sstrdup(const char *src) { - char *ret = NULL; - if (src) { + char *ret = NULL; + if (src) { #ifdef __STRICT_ANSI__ - if ((ret = (char *) malloc(strlen(src) + 1))) {; - strcpy(ret, src); - } + if ((ret = (char *) malloc(strlen(src) + 1))) {; + strcpy(ret, src); + } #else - ret = strdup(src); + ret = strdup(src); #endif - if (!ret) + if (!ret) #ifndef _WIN32 - raise(SIGUSR1); + raise(SIGUSR1); #else - abort(); + abort(); #endif - } else { - alog("sstrdup() called with NULL-arg"); - if (debug) - do_backtrace(0); - } + } else { + alog("sstrdup() called with NULL-arg"); + if (debug) + do_backtrace(0); + } - return ret; + return ret; } /*************************************************************************/ diff --git a/src/memoserv.c b/src/memoserv.c index 716bd41e0..0054f3f9c 100644 --- a/src/memoserv.c +++ b/src/memoserv.c @@ -38,94 +38,94 @@ void moduleAddMemoServCmds(void) { */ void ms_init(void) { - moduleAddMemoServCmds(); + moduleAddMemoServCmds(); } /*************************************************************************/ /** * memoserv: Main MemoServ routine. - * Note that the User structure passed to the do_* routines will - * always be valid (non-NULL) and will always have a valid - * NickInfo pointer in the `ni' field. + * Note that the User structure passed to the do_* routines will + * always be valid (non-NULL) and will always have a valid + * NickInfo pointer in the `ni' field. * @param u User Struct * @param buf Buffer containing the privmsg * @return void */ void memoserv(User * u, char *buf) { - const char *cmd, *s; - - cmd = strtok(buf, " "); - if (!cmd) { - return; - } else if (stricmp(cmd, "\1PING") == 0) { - if (!(s = strtok(NULL, ""))) { - s = ""; - } - ircdproto->SendCTCP(findbot(s_MemoServ), u->nick, "PING %s", s); - } else { - if (!u->na && stricmp(cmd, "HELP") != 0) - notice_lang(s_MemoServ, u, NICK_NOT_REGISTERED_HELP, - s_NickServ); - else - mod_run_cmd(s_MemoServ, u, MEMOSERV, cmd); - } + const char *cmd, *s; + + cmd = strtok(buf, " "); + if (!cmd) { + return; + } else if (stricmp(cmd, "\1PING") == 0) { + if (!(s = strtok(NULL, ""))) { + s = ""; + } + ircdproto->SendCTCP(findbot(s_MemoServ), u->nick, "PING %s", s); + } else { + if (!u->na && stricmp(cmd, "HELP") != 0) + notice_lang(s_MemoServ, u, NICK_NOT_REGISTERED_HELP, + s_NickServ); + else + mod_run_cmd(s_MemoServ, u, MEMOSERV, cmd); + } } /*************************************************************************/ /** * check_memos: See if the given user has any unread memos, and send a - * NOTICE to that user if so (and if the appropriate flag is - * set). + * NOTICE to that user if so (and if the appropriate flag is + * set). * @param u User Struct * @return void */ void check_memos(User * u) { - NickCore *nc; - int i, newcnt = 0; - - if (!u) { - if (debug) { - alog("debug: check_memos called with NULL values"); - } - return; - } - - if (!(nc = (u->na ? u->na->nc : NULL)) || !nick_recognized(u) || - !(nc->flags & NI_MEMO_SIGNON)) { - return; - } - - for (i = 0; i < nc->memos.memocount; i++) { - if (nc->memos.memos[i].flags & MF_UNREAD) - newcnt++; - } - if (newcnt > 0) { - notice_lang(s_MemoServ, u, - newcnt == 1 ? MEMO_HAVE_NEW_MEMO : MEMO_HAVE_NEW_MEMOS, - newcnt); - if (newcnt == 1 && (nc->memos.memos[i - 1].flags & MF_UNREAD)) { - notice_lang(s_MemoServ, u, MEMO_TYPE_READ_LAST, s_MemoServ); - } else if (newcnt == 1) { - for (i = 0; i < nc->memos.memocount; i++) { - if (nc->memos.memos[i].flags & MF_UNREAD) - break; - } - notice_lang(s_MemoServ, u, MEMO_TYPE_READ_NUM, s_MemoServ, - nc->memos.memos[i].number); - } else { - notice_lang(s_MemoServ, u, MEMO_TYPE_LIST_NEW, s_MemoServ); - } - } - if (nc->memos.memomax > 0 && nc->memos.memocount >= nc->memos.memomax) { - if (nc->memos.memocount > nc->memos.memomax) - notice_lang(s_MemoServ, u, MEMO_OVER_LIMIT, nc->memos.memomax); - else - notice_lang(s_MemoServ, u, MEMO_AT_LIMIT, nc->memos.memomax); - } + NickCore *nc; + int i, newcnt = 0; + + if (!u) { + if (debug) { + alog("debug: check_memos called with NULL values"); + } + return; + } + + if (!(nc = (u->na ? u->na->nc : NULL)) || !nick_recognized(u) || + !(nc->flags & NI_MEMO_SIGNON)) { + return; + } + + for (i = 0; i < nc->memos.memocount; i++) { + if (nc->memos.memos[i].flags & MF_UNREAD) + newcnt++; + } + if (newcnt > 0) { + notice_lang(s_MemoServ, u, + newcnt == 1 ? MEMO_HAVE_NEW_MEMO : MEMO_HAVE_NEW_MEMOS, + newcnt); + if (newcnt == 1 && (nc->memos.memos[i - 1].flags & MF_UNREAD)) { + notice_lang(s_MemoServ, u, MEMO_TYPE_READ_LAST, s_MemoServ); + } else if (newcnt == 1) { + for (i = 0; i < nc->memos.memocount; i++) { + if (nc->memos.memos[i].flags & MF_UNREAD) + break; + } + notice_lang(s_MemoServ, u, MEMO_TYPE_READ_NUM, s_MemoServ, + nc->memos.memos[i].number); + } else { + notice_lang(s_MemoServ, u, MEMO_TYPE_LIST_NEW, s_MemoServ); + } + } + if (nc->memos.memomax > 0 && nc->memos.memocount >= nc->memos.memomax) { + if (nc->memos.memocount > nc->memos.memomax) + notice_lang(s_MemoServ, u, MEMO_OVER_LIMIT, nc->memos.memomax); + else + notice_lang(s_MemoServ, u, MEMO_AT_LIMIT, nc->memos.memomax); + } } /*************************************************************************/ @@ -142,41 +142,41 @@ void check_memos(User * u) */ MemoInfo *getmemoinfo(const char *name, int *ischan, int *isforbid) { - if (*name == '#') { - ChannelInfo *ci; - if (ischan) - *ischan = 1; - ci = cs_findchan(name); - if (ci) { - if (!(ci->flags & CI_VERBOTEN)) { - *isforbid = 0; - return &ci->memos; - } else { - *isforbid = 1; - return NULL; - } - } else { - *isforbid = 0; - return NULL; - } - } else { - NickAlias *na; - if (ischan) - *ischan = 0; - na = findnick(name); - if (na) { - if (!(na->status & NS_VERBOTEN)) { - *isforbid = 0; - return &na->nc->memos; - } else { - *isforbid = 1; - return NULL; - } - } else { - *isforbid = 0; - return NULL; - } - } + if (*name == '#') { + ChannelInfo *ci; + if (ischan) + *ischan = 1; + ci = cs_findchan(name); + if (ci) { + if (!(ci->flags & CI_VERBOTEN)) { + *isforbid = 0; + return &ci->memos; + } else { + *isforbid = 1; + return NULL; + } + } else { + *isforbid = 0; + return NULL; + } + } else { + NickAlias *na; + if (ischan) + *ischan = 0; + na = findnick(name); + if (na) { + if (!(na->status & NS_VERBOTEN)) { + *isforbid = 0; + return &na->nc->memos; + } else { + *isforbid = 1; + return NULL; + } + } else { + *isforbid = 0; + return NULL; + } + } } /*************************************************************************/ @@ -195,139 +195,139 @@ MemoInfo *getmemoinfo(const char *name, int *ischan, int *isforbid) */ void memo_send(User * u, char *name, char *text, int z) { - int ischan; - int isforbid; - Memo *m; - MemoInfo *mi; - time_t now = time(NULL); - char *source = u->na->nc->display; - int is_servoper = is_services_oper(u); - - if (readonly) { - notice_lang(s_MemoServ, u, MEMO_SEND_DISABLED); - } else if (checkDefCon(DEFCON_NO_NEW_MEMOS)) { - notice_lang(s_MemoServ, u, OPER_DEFCON_DENIED); - return; - } else if (!text) { - if (z == 0) - syntax_error(s_MemoServ, u, "SEND", MEMO_SEND_SYNTAX); - - if (z == 3) - syntax_error(s_MemoServ, u, "RSEND", MEMO_RSEND_SYNTAX); - - } else if (!nick_recognized(u)) { - if (z == 0 || z == 3) - notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); - - } else if (!(mi = getmemoinfo(name, &ischan, &isforbid))) { - if (z == 0 || z == 3) { - if (isforbid) { - notice_lang(s_MemoServ, u, - ischan ? CHAN_X_FORBIDDEN : - NICK_X_FORBIDDEN, name); - } else { - notice_lang(s_MemoServ, u, - ischan ? CHAN_X_NOT_REGISTERED : - NICK_X_NOT_REGISTERED, name); - } - } - } else if (z != 2 && MSSendDelay > 0 && - u && u->lastmemosend + MSSendDelay > now && !is_servoper) { - u->lastmemosend = now; - if (z == 0) - notice_lang(s_MemoServ, u, MEMO_SEND_PLEASE_WAIT, MSSendDelay); - - if (z == 3) - notice_lang(s_MemoServ, u, MEMO_RSEND_PLEASE_WAIT, - MSSendDelay); - - } else if (mi->memomax == 0 && !is_servoper) { - if (z == 0 || z == 3) - notice_lang(s_MemoServ, u, MEMO_X_GETS_NO_MEMOS, name); - - } else if (mi->memomax > 0 && mi->memocount >= mi->memomax - && !is_servoper) { - if (z == 0 || z == 3) - notice_lang(s_MemoServ, u, MEMO_X_HAS_TOO_MANY_MEMOS, name); - - } else { - u->lastmemosend = now; - mi->memocount++; - mi->memos = (Memo *)srealloc(mi->memos, sizeof(Memo) * mi->memocount); - m = &mi->memos[mi->memocount - 1]; - strscpy(m->sender, source, NICKMAX); - m->moduleData = NULL; - if (mi->memocount > 1) { - m->number = m[-1].number + 1; - if (m->number < 1) { - int i; - for (i = 0; i < mi->memocount; i++) { - mi->memos[i].number = i + 1; - } - } - } else { - m->number = 1; - } - m->time = time(NULL); - m->text = sstrdup(text); - m->flags = MF_UNREAD; - /* Set notify sent flag - DrStein */ - if (z == 2) { - m->flags |= MF_NOTIFYS; - } - /* Set receipt request flag */ - if (z == 3) - m->flags |= MF_RECEIPT; - if (z == 0 || z == 3) - notice_lang(s_MemoServ, u, MEMO_SENT, name); - if (!ischan) { - NickAlias *na; - NickCore *nc = (findnick(name))->nc; - - if (MSNotifyAll) { - if ((nc->flags & NI_MEMO_RECEIVE) - && get_ignore(name) == NULL) { - int i; - - for (i = 0; i < nc->aliases.count; i++) { - na = (NickAlias *)nc->aliases.list[i]; - if (na->u && nick_identified(na->u)) - notice_lang(s_MemoServ, na->u, - MEMO_NEW_MEMO_ARRIVED, source, - s_MemoServ, m->number); - } - } else { - if ((u = finduser(name)) && nick_identified(u) - && (nc->flags & NI_MEMO_RECEIVE)) - notice_lang(s_MemoServ, u, MEMO_NEW_MEMO_ARRIVED, - source, s_MemoServ, m->number); - } /* if (flags & MEMO_RECEIVE) */ - } - /* if (MSNotifyAll) */ - /* let's get out the mail if set in the nickcore - certus */ - if (nc->flags & NI_MEMO_MAIL) - new_memo_mail(nc, m); - } else { - struct c_userlist *cu, *next; - Channel *c; - - if (MSNotifyAll && (c = findchan(name))) { - for (cu = c->users; cu; cu = next) { - next = cu->next; - if (check_access(cu->user, c->ci, CA_MEMO)) { - if (cu->user->na - && (cu->user->na->nc->flags & NI_MEMO_RECEIVE) - && get_ignore(cu->user->nick) == NULL) { - notice_lang(s_MemoServ, cu->user, - MEMO_NEW_X_MEMO_ARRIVED, - c->ci->name, s_MemoServ, - c->ci->name, m->number); - } - } - } - } /* MSNotifyAll */ - } /* if (!ischan) */ - } /* if command is valid */ + int ischan; + int isforbid; + Memo *m; + MemoInfo *mi; + time_t now = time(NULL); + char *source = u->na->nc->display; + int is_servoper = is_services_oper(u); + + if (readonly) { + notice_lang(s_MemoServ, u, MEMO_SEND_DISABLED); + } else if (checkDefCon(DEFCON_NO_NEW_MEMOS)) { + notice_lang(s_MemoServ, u, OPER_DEFCON_DENIED); + return; + } else if (!text) { + if (z == 0) + syntax_error(s_MemoServ, u, "SEND", MEMO_SEND_SYNTAX); + + if (z == 3) + syntax_error(s_MemoServ, u, "RSEND", MEMO_RSEND_SYNTAX); + + } else if (!nick_recognized(u)) { + if (z == 0 || z == 3) + notice_lang(s_MemoServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ); + + } else if (!(mi = getmemoinfo(name, &ischan, &isforbid))) { + if (z == 0 || z == 3) { + if (isforbid) { + notice_lang(s_MemoServ, u, + ischan ? CHAN_X_FORBIDDEN : + NICK_X_FORBIDDEN, name); + } else { + notice_lang(s_MemoServ, u, + ischan ? CHAN_X_NOT_REGISTERED : + NICK_X_NOT_REGISTERED, name); + } + } + } else if (z != 2 && MSSendDelay > 0 && + u && u->lastmemosend + MSSendDelay > now && !is_servoper) { + u->lastmemosend = now; + if (z == 0) + notice_lang(s_MemoServ, u, MEMO_SEND_PLEASE_WAIT, MSSendDelay); + + if (z == 3) + notice_lang(s_MemoServ, u, MEMO_RSEND_PLEASE_WAIT, + MSSendDelay); + + } else if (mi->memomax == 0 && !is_servoper) { + if (z == 0 || z == 3) + notice_lang(s_MemoServ, u, MEMO_X_GETS_NO_MEMOS, name); + + } else if (mi->memomax > 0 && mi->memocount >= mi->memomax + && !is_servoper) { + if (z == 0 || z == 3) + notice_lang(s_MemoServ, u, MEMO_X_HAS_TOO_MANY_MEMOS, name); + + } else { + u->lastmemosend = now; + mi->memocount++; + mi->memos = (Memo *)srealloc(mi->memos, sizeof(Memo) * mi->memocount); + m = &mi->memos[mi->memocount - 1]; + strscpy(m->sender, source, NICKMAX); + m->moduleData = NULL; + if (mi->memocount > 1) { + m->number = m[-1].number + 1; + if (m->number < 1) { + int i; + for (i = 0; i < mi->memocount; i++) { + mi->memos[i].number = i + 1; + } + } + } else { + m->number = 1; + } + m->time = time(NULL); + m->text = sstrdup(text); + m->flags = MF_UNREAD; + /* Set notify sent flag - DrStein */ + if (z == 2) { + m->flags |= MF_NOTIFYS; + } + /* Set receipt request flag */ + if (z == 3) + m->flags |= MF_RECEIPT; + if (z == 0 || z == 3) + notice_lang(s_MemoServ, u, MEMO_SENT, name); + if (!ischan) { + NickAlias *na; + NickCore *nc = (findnick(name))->nc; + + if (MSNotifyAll) { + if ((nc->flags & NI_MEMO_RECEIVE) + && get_ignore(name) == NULL) { + int i; + + for (i = 0; i < nc->aliases.count; i++) { + na = (NickAlias *)nc->aliases.list[i]; + if (na->u && nick_identified(na->u)) + notice_lang(s_MemoServ, na->u, + MEMO_NEW_MEMO_ARRIVED, source, + s_MemoServ, m->number); + } + } else { + if ((u = finduser(name)) && nick_identified(u) + && (nc->flags & NI_MEMO_RECEIVE)) + notice_lang(s_MemoServ, u, MEMO_NEW_MEMO_ARRIVED, + source, s_MemoServ, m->number); + } /* if (flags & MEMO_RECEIVE) */ + } + /* if (MSNotifyAll) */ + /* let's get out the mail if set in the nickcore - certus */ + if (nc->flags & NI_MEMO_MAIL) + new_memo_mail(nc, m); + } else { + struct c_userlist *cu, *next; + Channel *c; + + if (MSNotifyAll && (c = findchan(name))) { + for (cu = c->users; cu; cu = next) { + next = cu->next; + if (check_access(cu->user, c->ci, CA_MEMO)) { + if (cu->user->na + && (cu->user->na->nc->flags & NI_MEMO_RECEIVE) + && get_ignore(cu->user->nick) == NULL) { + notice_lang(s_MemoServ, cu->user, + MEMO_NEW_X_MEMO_ARRIVED, + c->ci->name, s_MemoServ, + c->ci->name, m->number); + } + } + } + } /* MSNotifyAll */ + } /* if (!ischan) */ + } /* if command is valid */ } /*************************************************************************/ @@ -339,53 +339,53 @@ void memo_send(User * u, char *name, char *text, int z) */ int delmemo(MemoInfo * mi, int num) { - int i; - - for (i = 0; i < mi->memocount; i++) { - if (mi->memos[i].number == num) - break; - } - if (i < mi->memocount) { - moduleCleanStruct(&mi->memos[i].moduleData); - free(mi->memos[i].text); /* Deallocate memo text memory */ - mi->memocount--; /* One less memo now */ - if (i < mi->memocount) /* Move remaining memos down a slot */ - memmove(mi->memos + i, mi->memos + i + 1, - sizeof(Memo) * (mi->memocount - i)); - if (mi->memocount == 0) { /* If no more memos, free array */ - free(mi->memos); - mi->memos = NULL; - } - return 1; - } else { - return 0; - } + int i; + + for (i = 0; i < mi->memocount; i++) { + if (mi->memos[i].number == num) + break; + } + if (i < mi->memocount) { + moduleCleanStruct(&mi->memos[i].moduleData); + free(mi->memos[i].text); /* Deallocate memo text memory */ + mi->memocount--; /* One less memo now */ + if (i < mi->memocount) /* Move remaining memos down a slot */ + memmove(mi->memos + i, mi->memos + i + 1, + sizeof(Memo) * (mi->memocount - i)); + if (mi->memocount == 0) { /* If no more memos, free array */ + free(mi->memos); + mi->memos = NULL; + } + return 1; + } else { + return 0; + } } /*************************************************************************/ static void new_memo_mail(NickCore * nc, Memo * m) { - MailInfo *mail = NULL; - - if (!nc || !m) - return; - - mail = MailMemoBegin(nc); - if (!mail) { - return; - } - fprintf(mail->pipe, getstring2(NULL, MEMO_MAIL_TEXT1), nc->display); - fprintf(mail->pipe, "\n"); - fprintf(mail->pipe, getstring2(NULL, MEMO_MAIL_TEXT2), m->sender, - m->number); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, "%s", getstring2(NULL, MEMO_MAIL_TEXT3)); - fprintf(mail->pipe, "\n\n"); - fprintf(mail->pipe, "%s", m->text); - fprintf(mail->pipe, "\n"); - MailEnd(mail); - return; + MailInfo *mail = NULL; + + if (!nc || !m) + return; + + mail = MailMemoBegin(nc); + if (!mail) { + return; + } + fprintf(mail->pipe, getstring2(NULL, MEMO_MAIL_TEXT1), nc->display); + fprintf(mail->pipe, "\n"); + fprintf(mail->pipe, getstring2(NULL, MEMO_MAIL_TEXT2), m->sender, + m->number); + fprintf(mail->pipe, "\n\n"); + fprintf(mail->pipe, "%s", getstring2(NULL, MEMO_MAIL_TEXT3)); + fprintf(mail->pipe, "\n\n"); + fprintf(mail->pipe, "%s", m->text); + fprintf(mail->pipe, "\n"); + MailEnd(mail); + return; } @@ -394,49 +394,49 @@ static void new_memo_mail(NickCore * nc, Memo * m) void rsend_notify(User * u, Memo * m, const char *chan) { - NickAlias *na; - NickCore *nc; - char text[256]; - const char *fmt; - - /* Only send receipt if memos are allowed */ - if ((!readonly) && (!checkDefCon(DEFCON_NO_NEW_MEMOS))) { - - /* Get nick alias for sender */ - na = findnick(m->sender); - - if (!na) { - return; - } - - /* Get nick core for sender */ - nc = na->nc; - - if (!nc) { - return; - } - - /* Text of the memo varies if the recepient was a - nick or channel */ - if (chan) { - fmt = getstring(na, MEMO_RSEND_CHAN_MEMO_TEXT); - sprintf(text, fmt, chan); - } else { - fmt = getstring(na, MEMO_RSEND_NICK_MEMO_TEXT); - sprintf(text, "%s", fmt); - } - - /* Send notification */ - memo_send(u, m->sender, text, 2); - - /* Notify recepient of the memo that a notification has - been sent to the sender */ - notice_lang(s_MemoServ, u, MEMO_RSEND_USER_NOTIFICATION, - nc->display); - } - - /* Remove receipt flag from the original memo */ - m->flags &= ~MF_RECEIPT; - - return; + NickAlias *na; + NickCore *nc; + char text[256]; + const char *fmt; + + /* Only send receipt if memos are allowed */ + if ((!readonly) && (!checkDefCon(DEFCON_NO_NEW_MEMOS))) { + + /* Get nick alias for sender */ + na = findnick(m->sender); + + if (!na) { + return; + } + + /* Get nick core for sender */ + nc = na->nc; + + if (!nc) { + return; + } + + /* Text of the memo varies if the recepient was a + nick or channel */ + if (chan) { + fmt = getstring(na, MEMO_RSEND_CHAN_MEMO_TEXT); + sprintf(text, fmt, chan); + } else { + fmt = getstring(na, MEMO_RSEND_NICK_MEMO_TEXT); + sprintf(text, "%s", fmt); + } + + /* Send notification */ + memo_send(u, m->sender, text, 2); + + /* Notify recepient of the memo that a notification has + been sent to the sender */ + notice_lang(s_MemoServ, u, MEMO_RSEND_USER_NOTIFICATION, + nc->display); + } + + /* Remove receipt flag from the original memo */ + m->flags &= ~MF_RECEIPT; + + return; } diff --git a/src/messages.c b/src/messages.c index 7351de915..1e4e8acf4 100644 --- a/src/messages.c +++ b/src/messages.c @@ -20,259 +20,259 @@ int m_nickcoll(const char *user) { - introduce_user(user); - return MOD_CONT; + introduce_user(user); + return MOD_CONT; } /*************************************************************************/ int m_away(const char *source, const char *msg) { - User *u; + User *u; - u = finduser(source); + u = finduser(source); - if (u && msg == 0) /* un-away */ - check_memos(u); - return MOD_CONT; + if (u && msg == 0) /* un-away */ + check_memos(u); + return MOD_CONT; } /*************************************************************************/ int m_kill(const char *nick, const char *msg) { - BotInfo *bi; - - /* Recover if someone kills us. */ - /* use nickIsServices() to reduce the number of lines of code - TSL */ - if (nickIsServices(nick, 0)) { - introduce_user(nick); - } else if (s_BotServ && (bi = findbot(nick))) { - introduce_user(nick); - bi->RejoinAll(); - } else { - do_kill(nick, msg); - } - return MOD_CONT; + BotInfo *bi; + + /* Recover if someone kills us. */ + /* use nickIsServices() to reduce the number of lines of code - TSL */ + if (nickIsServices(nick, 0)) { + introduce_user(nick); + } else if (s_BotServ && (bi = findbot(nick))) { + introduce_user(nick); + bi->RejoinAll(); + } else { + do_kill(nick, msg); + } + return MOD_CONT; } /*************************************************************************/ int m_time(const char *source, int ac, const char **av) { - time_t t; - struct tm *tm; - char buf[64]; + time_t t; + struct tm *tm; + char buf[64]; - if (!source) { - return MOD_CONT; - } + if (!source) { + return MOD_CONT; + } - time(&t); - tm = localtime(&t); - strftime(buf, sizeof(buf), "%a %b %d %H:%M:%S %Y %Z", tm); + time(&t); + tm = localtime(&t); + strftime(buf, sizeof(buf), "%a %b %d %H:%M:%S %Y %Z", tm); ircdproto->SendNumeric(ServerName, 391, source, "%s :%s", ServerName, buf); - return MOD_CONT; + return MOD_CONT; } /*************************************************************************/ int m_motd(const char *source) { - FILE *f; - char buf[BUFSIZE]; + FILE *f; + char buf[BUFSIZE]; - if (!source) { - return MOD_CONT; - } + if (!source) { + return MOD_CONT; + } - f = fopen(MOTDFilename, "r"); - if (f) { + f = fopen(MOTDFilename, "r"); + if (f) { ircdproto->SendNumeric(ServerName, 375, source, ":- %s Message of the Day", ServerName); - while (fgets(buf, sizeof(buf), f)) { - buf[strlen(buf) - 1] = 0; + while (fgets(buf, sizeof(buf), f)) { + buf[strlen(buf) - 1] = 0; ircdproto->SendNumeric(ServerName, 372, source, ":- %s", buf); - } - fclose(f); + } + fclose(f); ircdproto->SendNumeric(ServerName, 376, source, ":End of /MOTD command."); - } else { + } else { ircdproto->SendNumeric(ServerName, 422, source, ":- MOTD file not found! Please contact your IRC administrator."); - } - return MOD_CONT; + } + return MOD_CONT; } /*************************************************************************/ int m_privmsg(const char *source, const char *receiver, const char *msg) { - char *s; - time_t starttime, stoptime; /* When processing started and finished */ + char *s; + time_t starttime, stoptime; /* When processing started and finished */ - BotInfo *bi; - ChannelInfo *ci; - User *u; + BotInfo *bi; + ChannelInfo *ci; + User *u; - if (!source || !*source || !*receiver || !receiver || !msg) { - return MOD_CONT; - } + if (!source || !*source || !*receiver || !receiver || !msg) { + return MOD_CONT; + } - u = finduser(source); + u = finduser(source); - if (!u) { - alog("%s: user record for %s not found", msg, source); + if (!u) { + alog("%s: user record for %s not found", msg, source); /* Two lookups naughty, however, this won't happen often. -- w00t */ if (findbot(receiver)) { - ircdproto->SendMessage(findbot(receiver), source, - getstring(NULL, USER_RECORD_NOT_FOUND)); + ircdproto->SendMessage(findbot(receiver), source, + getstring(NULL, USER_RECORD_NOT_FOUND)); + } + return MOD_CONT; + } + + if (*receiver == '#') { + if (s_BotServ && (ci = cs_findchan(receiver))) { + /* Some paranoia checks */ + if (!(ci->flags & CI_VERBOTEN) && ci->c && ci->bi) { + botchanmsgs(u, ci, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX + } + } + } else { + /* Check if we should ignore. Operators always get through. */ + if (allow_ignore && !is_oper(u)) { + IgnoreData *ign = get_ignore(source); + if (ign) { + alog("Ignored message from %s: \"%s\"", source, inbuf); + return MOD_CONT; + } + } + + /* If a server is specified (nick@server format), make sure it matches + * us, and strip it off. */ + s = strchr(receiver, '@'); + if (s) { + *s++ = 0; + if (stricmp(s, ServerName) != 0) + return MOD_CONT; + } else if (UseStrictPrivMsg) { + if (debug) { + alog("Ignored PRIVMSG without @ from %s", source); + } + notice_lang(receiver, u, INVALID_TARGET, receiver, receiver, + ServerName, receiver); + return MOD_CONT; } - return MOD_CONT; - } - - if (*receiver == '#') { - if (s_BotServ && (ci = cs_findchan(receiver))) { - /* Some paranoia checks */ - if (!(ci->flags & CI_VERBOTEN) && ci->c && ci->bi) { - botchanmsgs(u, ci, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX - } - } - } else { - /* Check if we should ignore. Operators always get through. */ - if (allow_ignore && !is_oper(u)) { - IgnoreData *ign = get_ignore(source); - if (ign) { - alog("Ignored message from %s: \"%s\"", source, inbuf); - return MOD_CONT; - } - } - - /* If a server is specified (nick@server format), make sure it matches - * us, and strip it off. */ - s = strchr(receiver, '@'); - if (s) { - *s++ = 0; - if (stricmp(s, ServerName) != 0) - return MOD_CONT; - } else if (UseStrictPrivMsg) { - if (debug) { - alog("Ignored PRIVMSG without @ from %s", source); - } - notice_lang(receiver, u, INVALID_TARGET, receiver, receiver, - ServerName, receiver); - return MOD_CONT; - } - - starttime = time(NULL); - - if (!stricmp(receiver, s_OperServ)) { - if (!is_oper(u) && OSOpersOnly) { - notice_lang(s_OperServ, u, ACCESS_DENIED); - if (WallBadOS) - ircdproto->SendGlobops(s_OperServ, - "Denied access to %s from %s!%s@%s (non-oper)", - s_OperServ, u->nick, u->username, - u->host); - } else { - operserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX - } - } else if (!stricmp(receiver, s_NickServ)) { - nickserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX - } else if (!stricmp(receiver, s_ChanServ)) { - if (!is_oper(u) && CSOpersOnly) - notice_lang(s_ChanServ, u, ACCESS_DENIED); - else - chanserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX - } else if (!stricmp(receiver, s_MemoServ)) { - memoserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX - } else if (s_HostServ && !stricmp(receiver, s_HostServ)) { - hostserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX - } else if (s_HelpServ && !stricmp(receiver, s_HelpServ)) { - helpserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX - } else if (s_BotServ && !stricmp(receiver, s_BotServ)) { - botserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX - } else if (s_BotServ && (bi = findbot(receiver))) { - botmsgs(u, bi, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX - } - - /* Add to ignore list if the command took a significant amount of time. */ - if (allow_ignore) { - stoptime = time(NULL); - if (stoptime > starttime && *source && !strchr(source, '.')) - add_ignore(source, stoptime - starttime); - } - } - return MOD_CONT; + + starttime = time(NULL); + + if (!stricmp(receiver, s_OperServ)) { + if (!is_oper(u) && OSOpersOnly) { + notice_lang(s_OperServ, u, ACCESS_DENIED); + if (WallBadOS) + ircdproto->SendGlobops(s_OperServ, + "Denied access to %s from %s!%s@%s (non-oper)", + s_OperServ, u->nick, u->username, + u->host); + } else { + operserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX + } + } else if (!stricmp(receiver, s_NickServ)) { + nickserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX + } else if (!stricmp(receiver, s_ChanServ)) { + if (!is_oper(u) && CSOpersOnly) + notice_lang(s_ChanServ, u, ACCESS_DENIED); + else + chanserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX + } else if (!stricmp(receiver, s_MemoServ)) { + memoserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX + } else if (s_HostServ && !stricmp(receiver, s_HostServ)) { + hostserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX + } else if (s_HelpServ && !stricmp(receiver, s_HelpServ)) { + helpserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX + } else if (s_BotServ && !stricmp(receiver, s_BotServ)) { + botserv(u, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX + } else if (s_BotServ && (bi = findbot(receiver))) { + botmsgs(u, bi, (char *)msg); // XXX Unsafe cast, this needs reviewing -- CyberBotX + } + + /* Add to ignore list if the command took a significant amount of time. */ + if (allow_ignore) { + stoptime = time(NULL); + if (stoptime > starttime && *source && !strchr(source, '.')) + add_ignore(source, stoptime - starttime); + } + } + return MOD_CONT; } /*************************************************************************/ int m_stats(const char *source, int ac, const char **av) { - int i; - User *u; - NickCore *nc; + int i; + User *u; + NickCore *nc; - if (ac < 1) - return MOD_CONT; + if (ac < 1) + return MOD_CONT; - switch (*av[0]) { - case 'l': - u = finduser(source); + switch (*av[0]) { + case 'l': + u = finduser(source); - if (u && is_oper(u)) { + if (u && is_oper(u)) { - if (servernum == 1) { + if (servernum == 1) { ircdproto->SendNumeric(ServerName, 211, source, "Server SendBuf SentBytes SentMsgs RecvBuf RecvBytes RecvMsgs ConnTime"); ircdproto->SendNumeric(ServerName, 211, source, "%s %d %d %d %d %d %d %ld", RemoteServer, write_buffer_len(), total_written, -1, read_buffer_len(), total_read, -1, time(NULL) - start_time); - } else if (servernum == 2) { + } else if (servernum == 2) { ircdproto->SendNumeric(ServerName, 211, source, "Server SendBuf SentBytes SentMsgs RecvBuf RecvBytes RecvMsgs ConnTime"); ircdproto->SendNumeric(ServerName, 211, source, "%s %d %d %d %d %d %d %ld", RemoteServer2, write_buffer_len(), total_written, -1, read_buffer_len(), total_read, -1, time(NULL) - start_time); - } else if (servernum == 3) { + } else if (servernum == 3) { ircdproto->SendNumeric(ServerName, 211, source, "Server SendBuf SentBytes SentMsgs RecvBuf RecvBytes RecvMsgs ConnTime"); ircdproto->SendNumeric(ServerName, 211, source, "%s %d %d %d %d %d %d %ld", RemoteServer3, write_buffer_len(), total_written, -1, read_buffer_len(), total_read, -1, time(NULL) - start_time); - } - } + } + } ircdproto->SendNumeric(ServerName, 219, source, "%c :End of /STATS report.", *av[0] ? *av[0] : '*'); - break; - case 'o': - case 'O': + break; + case 'o': + case 'O': /* Check whether the user is an operator */ - u = finduser(source); - if (u && !is_oper(u) && HideStatsO) { + u = finduser(source); + if (u && !is_oper(u) && HideStatsO) { ircdproto->SendNumeric(ServerName, 219, source, "%c :End of /STATS report.", *av[0] ? *av[0] : '*'); - } else { - for (i = 0; i < RootNumber; i++) + } else { + for (i = 0; i < RootNumber; i++) ircdproto->SendNumeric(ServerName, 243, source, "O * * %s Root 0", ServicesRoots[i]); - for (i = 0; i < servadmins.count && (nc = (NickCore *)servadmins.list[i]); - i++) + for (i = 0; i < servadmins.count && (nc = (NickCore *)servadmins.list[i]); + i++) ircdproto->SendNumeric(ServerName, 243, source, "O * * %s Admin 0", nc->display); - for (i = 0; i < servopers.count && (nc = (NickCore *)servopers.list[i]); - i++) + for (i = 0; i < servopers.count && (nc = (NickCore *)servopers.list[i]); + i++) ircdproto->SendNumeric(ServerName, 243, source, "O * * %s Oper 0", nc->display); ircdproto->SendNumeric(ServerName, 219, source, "%c :End of /STATS report.", *av[0] ? *av[0] : '*'); - } + } - break; + break; - case 'u':{ - int uptime = time(NULL) - start_time; + case 'u':{ + int uptime = time(NULL) - start_time; ircdproto->SendNumeric(ServerName, 242, source, ":Services up %d day%s, %02d:%02d:%02d", uptime / 86400, uptime / 86400 == 1 ? "" : "s", (uptime / 3600) % 24, (uptime / 60) % 60, uptime % 60); ircdproto->SendNumeric(ServerName, 250, source, ":Current users: %d (%d ops); maximum %d", usercnt, opcnt, maxusercnt); ircdproto->SendNumeric(ServerName, 219, source, "%c :End of /STATS report.", *av[0] ? *av[0] : '*'); - break; - } /* case 'u' */ + break; + } /* case 'u' */ - default: + default: ircdproto->SendNumeric(ServerName, 219, source, "%c :End of /STATS report.", *av[0] ? *av[0] : '*'); - break; - } - return MOD_CONT; + break; + } + return MOD_CONT; } /*************************************************************************/ @@ -289,72 +289,72 @@ int m_version(const char *source, int ac, const char **av) int m_whois(const char *source, const char *who) { - BotInfo *bi; - NickAlias *na; - const char *clientdesc; - - if (source && who) { - if (stricmp(who, s_NickServ) == 0) - clientdesc = desc_NickServ; - else if (stricmp(who, s_ChanServ) == 0) - clientdesc = desc_ChanServ; - else if (stricmp(who, s_MemoServ) == 0) - clientdesc = desc_MemoServ; - else if (s_BotServ && stricmp(who, s_BotServ) == 0) - clientdesc = desc_BotServ; - else if (s_HostServ && stricmp(who, s_HostServ) == 0) - clientdesc = desc_HostServ; - else if (stricmp(who, s_HelpServ) == 0) - clientdesc = desc_HelpServ; - else if (stricmp(who, s_OperServ) == 0) - clientdesc = desc_OperServ; - else if (stricmp(who, s_GlobalNoticer) == 0) - clientdesc = desc_GlobalNoticer; - else if (s_BotServ && (bi = findbot(who))) { - /* Bots are handled separately */ + BotInfo *bi; + NickAlias *na; + const char *clientdesc; + + if (source && who) { + if (stricmp(who, s_NickServ) == 0) + clientdesc = desc_NickServ; + else if (stricmp(who, s_ChanServ) == 0) + clientdesc = desc_ChanServ; + else if (stricmp(who, s_MemoServ) == 0) + clientdesc = desc_MemoServ; + else if (s_BotServ && stricmp(who, s_BotServ) == 0) + clientdesc = desc_BotServ; + else if (s_HostServ && stricmp(who, s_HostServ) == 0) + clientdesc = desc_HostServ; + else if (stricmp(who, s_HelpServ) == 0) + clientdesc = desc_HelpServ; + else if (stricmp(who, s_OperServ) == 0) + clientdesc = desc_OperServ; + else if (stricmp(who, s_GlobalNoticer) == 0) + clientdesc = desc_GlobalNoticer; + else if (s_BotServ && (bi = findbot(who))) { + /* Bots are handled separately */ ircdproto->SendNumeric(ServerName, 311, source, "%s %s %s * :%s", bi->nick, bi->user, bi->host, bi->real); ircdproto->SendNumeric(ServerName, 307, source, "%s :is a registered nick", bi->nick); ircdproto->SendNumeric(ServerName, 312, source, "%s %s :%s", bi->nick, ServerName, ServerDesc); ircdproto->SendNumeric(ServerName, 317, source, "%s %ld %ld :seconds idle, signon time", bi->nick, time(NULL) - bi->lastmsg, start_time); ircdproto->SendNumeric(ServerName, 318, source, "%s :End of /WHOIS list.", who); - return MOD_CONT; - } else if (!(ircd->svshold && UseSVSHOLD) && (na = findnick(who)) - && (na->status & NS_KILL_HELD)) { - /* We have a nick enforcer client here that we need to respond to. - * We can't just say it doesn't exist here, even tho it does for - * other servers :) -GD - */ + return MOD_CONT; + } else if (!(ircd->svshold && UseSVSHOLD) && (na = findnick(who)) + && (na->status & NS_KILL_HELD)) { + /* We have a nick enforcer client here that we need to respond to. + * We can't just say it doesn't exist here, even tho it does for + * other servers :) -GD + */ ircdproto->SendNumeric(ServerName, 311, source, "%s %s %s * :Services Enforcer", na->nick, NSEnforcerUser, NSEnforcerHost); ircdproto->SendNumeric(ServerName, 312, source, "%s %s :%s", na->nick, ServerName, ServerDesc); ircdproto->SendNumeric(ServerName, 318, source, "%s :End of /WHOIS list.", who); - return MOD_CONT; - } else { + return MOD_CONT; + } else { ircdproto->SendNumeric(ServerName, 401, source, "%s :No such service.", who); - return MOD_CONT; - } + return MOD_CONT; + } ircdproto->SendNumeric(ServerName, 311, source, "%s %s %s * :%s", who, ServiceUser, ServiceHost, clientdesc); ircdproto->SendNumeric(ServerName, 312, source, "%s %s :%s", who, ServerName, ServerDesc); ircdproto->SendNumeric(ServerName, 317, source, "%s %ld %ld :seconds idle, signon time", who, time(NULL) - start_time, start_time); ircdproto->SendNumeric(ServerName, 318, source, "%s :End of /WHOIS list.", who); - } - return MOD_CONT; + } + return MOD_CONT; } /* *INDENT-OFF* */ void moduleAddMsgs(void) { - Message *m; - m = createMessage("STATS", m_stats); addCoreMessage(IRCD,m); - m = createMessage("TIME", m_time); addCoreMessage(IRCD,m); - m = createMessage("VERSION", m_version); addCoreMessage(IRCD,m); + Message *m; + m = createMessage("STATS", m_stats); addCoreMessage(IRCD,m); + m = createMessage("TIME", m_time); addCoreMessage(IRCD,m); + m = createMessage("VERSION", m_version); addCoreMessage(IRCD,m); } /*************************************************************************/ Message *find_message(const char *name) { - Message *m; - m = findMessage(IRCD, name); - return m; + Message *m; + m = findMessage(IRCD, name); + return m; } /*************************************************************************/ diff --git a/src/misc.c b/src/misc.c index 091d83c51..df0b628f6 100644 --- a/src/misc.c +++ b/src/misc.c @@ -20,43 +20,43 @@ #define issp(c) ((c) == 32) struct arc4_stream { - u_int8_t i; - u_int8_t j; - u_int8_t s[256]; + u_int8_t i; + u_int8_t j; + u_int8_t s[256]; } rs; /*************************************************************************/ /** * toupper: Like the ANSI functions, but make sure we return an - * int instead of a (signed) char. + * int instead of a (signed) char. * @param c Char * @return int */ int toupper(char c) { - if (islower(c)) { - return (unsigned char) c - ('a' - 'A'); - } else { - return (unsigned char) c; - } + if (islower(c)) { + return (unsigned char) c - ('a' - 'A'); + } else { + return (unsigned char) c; + } } /*************************************************************************/ /** * tolower: Like the ANSI functions, but make sure we return an - * int instead of a (signed) char. + * int instead of a (signed) char. * @param c Char * @return int */ int tolower(char c) { - if (isupper(c)) { - return (unsigned char) c + ('a' - 'A'); - } else { - return (unsigned char) c; - } + if (isupper(c)) { + return (unsigned char) c + ('a' - 'A'); + } else { + return (unsigned char) c; + } } /*************************************************************************/ @@ -67,15 +67,15 @@ int tolower(char c) */ void binary_to_hex(unsigned char *bin, char *hex, int length) { - static const char trans[] = "0123456789ABCDEF"; - int i; + static const char trans[] = "0123456789ABCDEF"; + int i; - for (i = 0; i < length; i++) { - hex[i << 1] = trans[bin[i] >> 4]; - hex[(i << 1) + 1] = trans[bin[i] & 0xf]; - } + for (i = 0; i < length; i++) { + hex[i << 1] = trans[bin[i] >> 4]; + hex[(i << 1) + 1] = trans[bin[i] & 0xf]; + } - hex[i << 1] = '\0'; + hex[i << 1] = '\0'; } @@ -83,7 +83,7 @@ void binary_to_hex(unsigned char *bin, char *hex, int length) /** * strscpy: Copy at most len-1 characters from a string to a buffer, and - * add a null terminator after the last character copied. + * 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 @@ -91,51 +91,51 @@ void binary_to_hex(unsigned char *bin, char *hex, int length) */ char *strscpy(char *d, const char *s, size_t len) { - char *d_orig = d; - - if (!len) { - return d; - } - while (--len && (*d++ = *s++)); - *d = '\0'; - return d_orig; + char *d_orig = d; + + if (!len) { + return d; + } + while (--len && (*d++ = *s++)); + *d = '\0'; + return d_orig; } /*************************************************************************/ /** * stristr: Search case-insensitively for string s2 within string s1, - * returning the first occurrence of s2 or NULL if s2 was not - * found. + * 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; - - while (*s1) { - if (tolower(*s1) == tolower(*d)) { - s1++; - d++; - if (*d == 0) - return s; - } else { - s = ++s1; - d = s2; - } - } - return NULL; + register char *s = s1, *d = s2; + + while (*s1) { + if (tolower(*s1) == tolower(*d)) { + s1++; + d++; + if (*d == 0) + return s; + } else { + s = ++s1; + d = s2; + } + } + return NULL; } /*************************************************************************/ /** * 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. + * 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 @@ -144,51 +144,51 @@ char *stristr(char *s1, char *s2) */ char *strnrepl(char *s, int32 size, const char *old, const char *newstr) { - char *ptr = s; - int32 left = strlen(s); - int32 avail = size - (left + 1); - int32 oldlen = strlen(old); - int32 newlen = strlen(newstr); - int32 diff = newlen - oldlen; - - while (left >= oldlen) { - if (strncmp(ptr, old, oldlen) != 0) { - left--; - ptr++; - continue; - } - if (diff > avail) - break; - if (diff != 0) - memmove(ptr + oldlen + diff, ptr + oldlen, left + 1 - oldlen); - strncpy(ptr, newstr, newlen); - ptr += newlen; - left -= oldlen; - } - return s; + char *ptr = s; + int32 left = strlen(s); + int32 avail = size - (left + 1); + int32 oldlen = strlen(old); + int32 newlen = strlen(newstr); + int32 diff = newlen - oldlen; + + while (left >= oldlen) { + if (strncmp(ptr, old, oldlen) != 0) { + left--; + ptr++; + continue; + } + if (diff > avail) + break; + if (diff != 0) + memmove(ptr + oldlen + diff, ptr + oldlen, left + 1 - oldlen); + strncpy(ptr, newstr, newlen); + ptr += newlen; + left -= oldlen; + } + return s; } /*************************************************************************/ /** * 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. + * 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 */ const char *merge_args(int argc, const char **argv) { - int i; - static char s[4096]; - char *t; - - t = s; - for (i = 0; i < argc; i++) - t += snprintf(t, sizeof(s) - (t - s), "%s%s", *argv++, - (i < argc - 1) ? " " : ""); - return s; + int i; + static char s[4096]; + char *t; + + t = s; + for (i = 0; i < argc; i++) + t += snprintf(t, sizeof(s) - (t - s), "%s%s", *argv++, + (i < argc - 1) ? " " : ""); + return s; } /* @@ -196,23 +196,23 @@ const char *merge_args(int argc, const char **argv) */ const char *merge_args(int argc, char **argv) { - int i; - static char s[4096]; - char *t; - - t = s; - for (i = 0; i < argc; i++) - t += snprintf(t, sizeof(s) - (t - s), "%s%s", *argv++, - (i < argc - 1) ? " " : ""); - return s; + int i; + static char s[4096]; + char *t; + + t = s; + for (i = 0; i < argc; i++) + t += snprintf(t, sizeof(s) - (t - s), "%s%s", *argv++, + (i < argc - 1) ? " " : ""); + return s; } /*************************************************************************/ /** * 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. + * '*' 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 @@ -220,45 +220,45 @@ const char *merge_args(int argc, char **argv) */ static int do_match_wild(const char *pattern, const char *str, int docase) { - char c; - const char *s; - - if (!str || !*str || !pattern || !*pattern) { - return 0; - } - - /* This WILL eventually terminate: either by *pattern == 0, or by a - * trailing '*'. */ - - for (;;) { - switch (c = *pattern++) { - case 0: - if (!*str) - return 1; - return 0; - case '?': - if (!*str) - return 0; - str++; - break; - case '*': - if (!*pattern) - return 1; /* trailing '*' matches everything else */ - s = str; - while (*s) { - if ((docase ? (*s == *pattern) - : (tolower(*s) == tolower(*pattern))) - && do_match_wild(pattern, s, docase)) - return 1; - s++; - } - break; - default: - if (docase ? (*str++ != c) : (tolower(*str++) != tolower(c))) - return 0; - break; - } /* switch */ - } + char c; + const char *s; + + if (!str || !*str || !pattern || !*pattern) { + return 0; + } + + /* This WILL eventually terminate: either by *pattern == 0, or by a + * trailing '*'. */ + + for (;;) { + switch (c = *pattern++) { + case 0: + if (!*str) + return 1; + return 0; + case '?': + if (!*str) + return 0; + str++; + break; + case '*': + if (!*pattern) + return 1; /* trailing '*' matches everything else */ + s = str; + while (*s) { + if ((docase ? (*s == *pattern) + : (tolower(*s) == tolower(*pattern))) + && do_match_wild(pattern, s, docase)) + return 1; + s++; + } + break; + default: + if (docase ? (*str++ != c) : (tolower(*str++) != tolower(c))) + return 0; + break; + } /* switch */ + } } /*************************************************************************/ @@ -271,7 +271,7 @@ static int do_match_wild(const char *pattern, const char *str, int docase) */ int match_wild(const char *pattern, const char *str) { - return do_match_wild(pattern, str, 1); + return do_match_wild(pattern, str, 1); } /*************************************************************************/ @@ -284,7 +284,7 @@ int match_wild(const char *pattern, const char *str) */ int match_wild_nocase(const char *pattern, const char *str) { - return do_match_wild(pattern, str, 0); + return do_match_wild(pattern, str, 0); } /*************************************************************************/ @@ -307,102 +307,102 @@ int match_wild_nocase(const char *pattern, const char *str) * @return int */ int process_numlist(const char *numstr, int *count_ret, - range_callback_t callback, User * u, ...) + range_callback_t callback, User * u, ...) { - int n1, n2, i; - int res = 0, retval = 0, count = 0; - va_list args, preserve; - - if (!numstr || !*numstr) { - return -1; - } - - va_start(args, u); - - /* - * This algorithm ignores invalid characters, ignores a dash - * when it precedes a comma, and ignores everything from the - * end of a valid number or range to the next comma or null. - */ - for (;;) { - n1 = n2 = strtol(numstr, (char **) &numstr, 10); - numstr += strcspn(numstr, "0123456789,-"); - if (*numstr == '-') { - numstr++; - numstr += strcspn(numstr, "0123456789,"); - if (isdigit(*numstr)) { - n2 = strtol(numstr, (char **) &numstr, 10); - numstr += strcspn(numstr, "0123456789,-"); - } - } - for (i = n1; i <= n2 && i >= 0; i++) { - VA_COPY(preserve, args); - res = callback(u, i, preserve); - va_end(preserve); - count++; - if (res < 0) - break; - retval += res; - if (count >= 32767) { - if (count_ret) - *count_ret = count; - return retval; - } - } - if (res < -1) - break; - numstr += strcspn(numstr, ","); - if (*numstr) - numstr++; - else - break; - } - if (count_ret) - *count_ret = count; - - va_end(args); - - return retval; + int n1, n2, i; + int res = 0, retval = 0, count = 0; + va_list args, preserve; + + if (!numstr || !*numstr) { + return -1; + } + + va_start(args, u); + + /* + * This algorithm ignores invalid characters, ignores a dash + * when it precedes a comma, and ignores everything from the + * end of a valid number or range to the next comma or null. + */ + for (;;) { + n1 = n2 = strtol(numstr, (char **) &numstr, 10); + numstr += strcspn(numstr, "0123456789,-"); + if (*numstr == '-') { + numstr++; + numstr += strcspn(numstr, "0123456789,"); + if (isdigit(*numstr)) { + n2 = strtol(numstr, (char **) &numstr, 10); + numstr += strcspn(numstr, "0123456789,-"); + } + } + for (i = n1; i <= n2 && i >= 0; i++) { + VA_COPY(preserve, args); + res = callback(u, i, preserve); + va_end(preserve); + count++; + if (res < 0) + break; + retval += res; + if (count >= 32767) { + if (count_ret) + *count_ret = count; + return retval; + } + } + if (res < -1) + break; + numstr += strcspn(numstr, ","); + if (*numstr) + numstr++; + else + break; + } + if (count_ret) + *count_ret = count; + + va_end(args); + + return retval; } /*************************************************************************/ /** * dotime: Return the number of seconds corresponding to the given time - * string. If the given string does not represent a valid time, - * return -1. + * 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). + * 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; - - if (!s || !*s) { - return -1; - } - - amount = strtol(s, (char **) &s, 10); - if (*s) { - switch (*s) { - case 's': - return amount; - case 'm': - return amount * 60; - case 'h': - return amount * 3600; - case 'd': - return amount * 86400; - default: - return -1; - } - } else { - return amount; - } + int amount; + + if (!s || !*s) { + return -1; + } + + amount = strtol(s, (char **) &s, 10); + if (*s) { + switch (*s) { + case 's': + return amount; + case 'm': + return amount * 60; + case 'h': + return amount * 3600; + case 'd': + return amount * 86400; + default: + return -1; + } + } else { + return amount; + } } /*************************************************************************/ @@ -418,60 +418,60 @@ int dotime(const char *s) */ char *duration(NickAlias * na, char *buf, int bufsize, time_t seconds) { - int days = 0, hours = 0, minutes = 0; - int need_comma = 0; - - char buf2[64], *end; - char *comma = getstring(na, COMMA_SPACE); - - /* We first calculate everything */ - days = seconds / 86400; - seconds -= (days * 86400); - hours = seconds / 3600; - seconds -= (hours * 3600); - minutes = seconds / 60; - - if (!days && !hours && !minutes) { - snprintf(buf, bufsize, - getstring(na, - (seconds <= - 1 ? DURATION_SECOND : DURATION_SECONDS)), - seconds); - } else { - end = buf; - if (days) { - snprintf(buf2, sizeof(buf2), - getstring(na, - (days == 1 ? DURATION_DAY : DURATION_DAYS)), - days); - end += snprintf(end, bufsize - (end - buf), "%s", buf2); - need_comma = 1; - } - if (hours) { - snprintf(buf2, sizeof(buf2), - getstring(na, - (hours == - 1 ? DURATION_HOUR : DURATION_HOURS)), - hours); - end += - snprintf(end, bufsize - (end - buf), "%s%s", - (need_comma ? comma : ""), buf2); - need_comma = 1; - } - if (minutes) { - snprintf(buf2, sizeof(buf2), - getstring(na, - (minutes == - 1 ? DURATION_MINUTE : DURATION_MINUTES)), - minutes); - end += - snprintf(end, bufsize - (end - buf), "%s%s", - (need_comma ? comma : ""), buf2); - need_comma = 1; - } - } - - return buf; + int days = 0, hours = 0, minutes = 0; + int need_comma = 0; + + char buf2[64], *end; + char *comma = getstring(na, COMMA_SPACE); + + /* We first calculate everything */ + days = seconds / 86400; + seconds -= (days * 86400); + hours = seconds / 3600; + seconds -= (hours * 3600); + minutes = seconds / 60; + + if (!days && !hours && !minutes) { + snprintf(buf, bufsize, + getstring(na, + (seconds <= + 1 ? DURATION_SECOND : DURATION_SECONDS)), + seconds); + } else { + end = buf; + if (days) { + snprintf(buf2, sizeof(buf2), + getstring(na, + (days == 1 ? DURATION_DAY : DURATION_DAYS)), + days); + end += snprintf(end, bufsize - (end - buf), "%s", buf2); + need_comma = 1; + } + if (hours) { + snprintf(buf2, sizeof(buf2), + getstring(na, + (hours == + 1 ? DURATION_HOUR : DURATION_HOURS)), + hours); + end += + snprintf(end, bufsize - (end - buf), "%s%s", + (need_comma ? comma : ""), buf2); + need_comma = 1; + } + if (minutes) { + snprintf(buf2, sizeof(buf2), + getstring(na, + (minutes == + 1 ? DURATION_MINUTE : DURATION_MINUTES)), + minutes); + end += + snprintf(end, bufsize - (end - buf), "%s%s", + (need_comma ? comma : ""), buf2); + need_comma = 1; + } + } + + return buf; } /*************************************************************************/ @@ -486,49 +486,49 @@ char *duration(NickAlias * na, char *buf, int bufsize, time_t seconds) */ char *expire_left(NickAlias * na, char *buf, int len, time_t expires) { - time_t now = time(NULL); - - if (!expires) { - strncpy(buf, getstring(na, NO_EXPIRE), len); - } else if (expires <= now) { - strncpy(buf, getstring(na, EXPIRES_SOON), len); - } else { - time_t diff = expires - now + 59; - - if (diff >= 86400) { - int days = diff / 86400; - snprintf(buf, len, - getstring(na, (days == 1) ? EXPIRES_1D : EXPIRES_D), - days); - } else { - if (diff <= 3600) { - int minutes = diff / 60; - snprintf(buf, len, - getstring(na, - (minutes == - 1) ? EXPIRES_1M : EXPIRES_M), minutes); - } else { - int hours = diff / 3600, minutes; - diff -= (hours * 3600); - minutes = diff / 60; - snprintf(buf, len, - getstring(na, - ((hours == 1 - && minutes == - 1) ? EXPIRES_1H1M : ((hours == 1 - && minutes != - 1) ? EXPIRES_1HM - : ((hours != 1 - && minutes == - 1) ? - EXPIRES_H1M : - EXPIRES_HM)))), - hours, minutes); - } - } - } - - return buf; + time_t now = time(NULL); + + if (!expires) { + strncpy(buf, getstring(na, NO_EXPIRE), len); + } else if (expires <= now) { + strncpy(buf, getstring(na, EXPIRES_SOON), len); + } else { + time_t diff = expires - now + 59; + + if (diff >= 86400) { + int days = diff / 86400; + snprintf(buf, len, + getstring(na, (days == 1) ? EXPIRES_1D : EXPIRES_D), + days); + } else { + if (diff <= 3600) { + int minutes = diff / 60; + snprintf(buf, len, + getstring(na, + (minutes == + 1) ? EXPIRES_1M : EXPIRES_M), minutes); + } else { + int hours = diff / 3600, minutes; + diff -= (hours * 3600); + minutes = diff / 60; + snprintf(buf, len, + getstring(na, + ((hours == 1 + && minutes == + 1) ? EXPIRES_1H1M : ((hours == 1 + && minutes != + 1) ? EXPIRES_1HM + : ((hours != 1 + && minutes == + 1) ? + EXPIRES_H1M : + EXPIRES_HM)))), + hours, minutes); + } + } + } + + return buf; } @@ -538,86 +538,86 @@ char *expire_left(NickAlias * na, char *buf, int len, time_t expires) * Validate the host * shortname = ( letter / digit ) *( letter / digit / "-" ) *( letter / digit ) * hostname = shortname *( "." shortname ) - * ip4addr = 1*3digit "." 1*3digit "." 1*3digit "." 1*3digit + * 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; - int len = 0; - int sec_len = 0; - int dots = 1; - if (type != 1 && type != 2) { - return 0; - } - if (!host) { - return 0; - } - - len = strlen(host); - - if (len > HOSTMAX) { - return 0; - } - - switch (type) { - case 1: - for (idx = 0; idx < len; idx++) { - if (isdigit(host[idx])) { - if (sec_len < 3) { - sec_len++; - } else { - return 0; - } - } else { - if (idx == 0) { - return 0; - } /* cant start with a non-digit */ - if (host[idx] != '.') { - return 0; - } /* only . is a valid non-digit */ - if (sec_len > 3) { - return 0; - } /* sections cant be more than 3 digits */ - sec_len = 0; - dots++; - } - } - if (dots != 4) { - return 0; - } - break; - case 2: - dots = 0; - for (idx = 0; idx < len; idx++) { - if (!isalnum(host[idx])) { - if (idx == 0) { - return 0; - } - if ((host[idx] != '.') && (host[idx] != '-')) { - return 0; - } - if (host[idx] == '.') { - dots++; - } - } - } - if (host[len - 1] == '.') { - return 0; - } - /** + int idx = 0; + int len = 0; + int sec_len = 0; + int dots = 1; + if (type != 1 && type != 2) { + return 0; + } + if (!host) { + return 0; + } + + len = strlen(host); + + if (len > HOSTMAX) { + return 0; + } + + switch (type) { + case 1: + for (idx = 0; idx < len; idx++) { + if (isdigit(host[idx])) { + if (sec_len < 3) { + sec_len++; + } else { + return 0; + } + } else { + if (idx == 0) { + return 0; + } /* cant start with a non-digit */ + if (host[idx] != '.') { + return 0; + } /* only . is a valid non-digit */ + if (sec_len > 3) { + return 0; + } /* sections cant be more than 3 digits */ + sec_len = 0; + dots++; + } + } + if (dots != 4) { + return 0; + } + break; + case 2: + dots = 0; + for (idx = 0; idx < len; idx++) { + if (!isalnum(host[idx])) { + if (idx == 0) { + return 0; + } + if ((host[idx] != '.') && (host[idx] != '-')) { + return 0; + } + if (host[idx] == '.') { + dots++; + } + } + } + if (host[len - 1] == '.') { + return 0; + } + /** * Ultimate3 dosnt like a non-dotted hosts at all, nor does unreal, * so just dont allow them. **/ - if (dots == 0) { - return 0; - } + if (dots == 0) { + return 0; + } - break; - } - return 1; + break; + } + return 1; } /*************************************************************************/ @@ -630,15 +630,15 @@ int doValidHost(const char *host, int type) */ int isValidHost(const char *host, int type) { - int status = 0; - if (type == 3) { - if (!(status = doValidHost(host, 1))) { - status = doValidHost(host, 2); - } - } else { - status = doValidHost(host, type); - } - return status; + int status = 0; + if (type == 3) { + if (!(status = doValidHost(host, 1))) { + status = doValidHost(host, 2); + } + } else { + status = doValidHost(host, type); + } + return status; } /*************************************************************************/ @@ -650,12 +650,12 @@ int isValidHost(const char *host, int type) */ int isvalidchar(const char c) { - if (((c >= 'A') && (c <= 'Z')) || - ((c >= 'a') && (c <= 'z')) || - ((c >= '0') && (c <= '9')) || (c == '.') || (c == '-')) - return 1; - else - return 0; + if (((c >= 'A') && (c <= 'Z')) || + ((c >= 'a') && (c <= 'z')) || + ((c >= '0') && (c <= '9')) || (c == '.') || (c == '-')) + return 1; + else + return 0; } @@ -670,24 +670,24 @@ int isvalidchar(const char c) */ char *myStrGetToken(const char *str, const char dilim, int token_number) { - int len, idx, counter = 0, start_pos = 0; - char *substring = NULL; - if (!str) { - return NULL; - } - len = strlen(str); - for (idx = 0; idx <= len; idx++) { - if ((str[idx] == dilim) || (idx == len)) { - if (counter == token_number) { - substring = myStrSubString(str, start_pos, idx); - counter++; - } else { - start_pos = idx + 1; - counter++; - } - } - } - return substring; + int len, idx, counter = 0, start_pos = 0; + char *substring = NULL; + if (!str) { + return NULL; + } + len = strlen(str); + for (idx = 0; idx <= len; idx++) { + if ((str[idx] == dilim) || (idx == len)) { + if (counter == token_number) { + substring = myStrSubString(str, start_pos, idx); + counter++; + } else { + start_pos = idx + 1; + counter++; + } + } + } + return substring; } /*************************************************************************/ @@ -700,29 +700,29 @@ char *myStrGetToken(const char *str, const char dilim, int token_number) * @return token */ char *myStrGetOnlyToken(const char *str, const char dilim, - int token_number) + int token_number) { - int len, idx, counter = 0, start_pos = 0; - char *substring = NULL; - if (!str) { - return NULL; - } - len = strlen(str); - for (idx = 0; idx <= len; idx++) { - if (str[idx] == dilim) { - if (counter == token_number) { - if (str[idx] == '\r') - substring = myStrSubString(str, start_pos, idx - 1); - else - substring = myStrSubString(str, start_pos, idx); - counter++; - } else { - start_pos = idx + 1; - counter++; - } - } - } - return substring; + int len, idx, counter = 0, start_pos = 0; + char *substring = NULL; + if (!str) { + return NULL; + } + len = strlen(str); + for (idx = 0; idx <= len; idx++) { + if (str[idx] == dilim) { + if (counter == token_number) { + if (str[idx] == '\r') + substring = myStrSubString(str, start_pos, idx - 1); + else + substring = myStrSubString(str, start_pos, idx); + counter++; + } else { + start_pos = idx + 1; + counter++; + } + } + } + return substring; } /*************************************************************************/ @@ -735,27 +735,27 @@ char *myStrGetOnlyToken(const char *str, const char dilim, * @return token */ char *myStrGetTokenRemainder(const char *str, const char dilim, - int token_number) + int token_number) { - int len, idx, counter = 0, start_pos = 0; - char *substring = NULL; - if (!str) { - return NULL; - } - len = strlen(str); - - for (idx = 0; idx <= len; idx++) { - if ((str[idx] == dilim) || (idx == len)) { - if (counter == token_number) { - substring = myStrSubString(str, start_pos, len); - counter++; - } else { - start_pos = idx + 1; - counter++; - } - } - } - return substring; + int len, idx, counter = 0, start_pos = 0; + char *substring = NULL; + if (!str) { + return NULL; + } + len = strlen(str); + + for (idx = 0; idx <= len; idx++) { + if ((str[idx] == dilim) || (idx == len)) { + if (counter == token_number) { + substring = myStrSubString(str, start_pos, len); + counter++; + } else { + start_pos = idx + 1; + counter++; + } + } + } + return substring; } /*************************************************************************/ @@ -769,20 +769,20 @@ char *myStrGetTokenRemainder(const char *str, const char dilim, */ char *myStrSubString(const char *src, int start, int end) { - char *substring = NULL; - int len, idx; - if (!src) { - return NULL; - } - len = strlen(src); - if (((start >= 0) && (end <= len)) && (end > start)) { - substring = (char *) malloc(sizeof(char) * ((end - start) + 1)); - for (idx = 0; idx <= end - start; idx++) { - substring[idx] = src[start + idx]; - } - substring[end - start] = '\0'; - } - return substring; + char *substring = NULL; + int len, idx; + if (!src) { + return NULL; + } + len = strlen(src); + if (((start >= 0) && (end <= len)) && (end > start)) { + substring = (char *) malloc(sizeof(char) * ((end - start) + 1)); + for (idx = 0; idx <= end - start; idx++) { + substring[idx] = src[start + idx]; + } + substring[end - start] = '\0'; + } + return substring; } /*************************************************************************/ @@ -794,31 +794,31 @@ char *myStrSubString(const char *src, int start, int end) */ void doCleanBuffer(char *str) { - char *in, *out; - char ch; - - if (!str) { - return; - } - - in = str; - out = str; - - while (issp(ch = *in++)); - if (ch != '\0') - for (;;) { - *out++ = ch; - ch = *in++; - if (ch == '\0') - break; - if (!issp(ch)) - continue; - while (issp(ch = *in++)); - if (ch == '\0') - break; - *out++ = ' '; - } - *out = ch; /* == '\0' */ + char *in, *out; + char ch; + + if (!str) { + return; + } + + in = str; + out = str; + + while (issp(ch = *in++)); + if (ch != '\0') + for (;;) { + *out++ = ch; + ch = *in++; + if (ch == '\0') + break; + if (!issp(ch)) + continue; + while (issp(ch = *in++)); + if (ch == '\0') + break; + *out++ = ' '; + } + *out = ch; /* == '\0' */ } /*************************************************************************/ @@ -831,14 +831,14 @@ void doCleanBuffer(char *str) */ void EnforceQlinedNick(const char *nick, const char *killer) { - User *u2; - - if ((u2 = finduser(nick))) { - alog("Killed Q-lined nick: %s!%s@%s", u2->nick, u2->username, - u2->host); - kill_user(killer, u2->nick, - "This nick is reserved for Services. Please use a non Q-Lined nick."); - } + User *u2; + + if ((u2 = finduser(nick))) { + alog("Killed Q-lined nick: %s!%s@%s", u2->nick, u2->username, + u2->host); + kill_user(killer, u2->nick, + "This nick is reserved for Services. Please use a non Q-Lined nick."); + } } /*************************************************************************/ @@ -851,57 +851,57 @@ void EnforceQlinedNick(const char *nick, const char *killer) */ int nickIsServices(const char *tempnick, int bot) { - int found = 0; - char *s, *nick; - - if (!tempnick) { - return found; - } - - nick = sstrdup(tempnick); - - s = strchr(nick, '@'); - if (s) { - *s++ = 0; - if (stricmp(s, ServerName) != 0) { - free(nick); - return found; - } - } - - if (s_NickServ && (stricmp(nick, s_NickServ) == 0)) - found++; - else if (s_ChanServ && (stricmp(nick, s_ChanServ) == 0)) - found++; - else if (s_HostServ && (stricmp(nick, s_HostServ) == 0)) - found++; - else if (s_MemoServ && (stricmp(nick, s_MemoServ) == 0)) - found++; - else if (s_BotServ && (stricmp(nick, s_BotServ) == 0)) - found++; - else if (s_HelpServ && (stricmp(nick, s_HelpServ) == 0)) - found++; - else if (s_OperServ && (stricmp(nick, s_OperServ) == 0)) - found++; - else if (s_GlobalNoticer && (stricmp(nick, s_GlobalNoticer) == 0)) - found++; - else if (s_BotServ && bot) { - BotInfo *bi; - int i; - for (i = 0; i < 256; i++) { - for (bi = botlists[i]; bi; bi = bi->next) { - if (stricmp(nick, bi->nick) == 0) { - found++; - continue; - } - } - } - } - - /* Somehow, something tells me we should free this :) -GD */ - free(nick); - - return found; + int found = 0; + char *s, *nick; + + if (!tempnick) { + return found; + } + + nick = sstrdup(tempnick); + + s = strchr(nick, '@'); + if (s) { + *s++ = 0; + if (stricmp(s, ServerName) != 0) { + free(nick); + return found; + } + } + + if (s_NickServ && (stricmp(nick, s_NickServ) == 0)) + found++; + else if (s_ChanServ && (stricmp(nick, s_ChanServ) == 0)) + found++; + else if (s_HostServ && (stricmp(nick, s_HostServ) == 0)) + found++; + else if (s_MemoServ && (stricmp(nick, s_MemoServ) == 0)) + found++; + else if (s_BotServ && (stricmp(nick, s_BotServ) == 0)) + found++; + else if (s_HelpServ && (stricmp(nick, s_HelpServ) == 0)) + found++; + else if (s_OperServ && (stricmp(nick, s_OperServ) == 0)) + found++; + else if (s_GlobalNoticer && (stricmp(nick, s_GlobalNoticer) == 0)) + found++; + else if (s_BotServ && bot) { + BotInfo *bi; + int i; + for (i = 0; i < 256; i++) { + for (bi = botlists[i]; bi; bi = bi->next) { + if (stricmp(nick, bi->nick) == 0) { + found++; + continue; + } + } + } + } + + /* Somehow, something tells me we should free this :) -GD */ + free(nick); + + return found; } /*************************************************************************/ @@ -912,11 +912,11 @@ int nickIsServices(const char *tempnick, int bot) */ static void arc4_init(void) { - int n; - for (n = 0; n < 256; n++) - rs.s[n] = n; - rs.i = 0; - rs.j = 0; + int n; + for (n = 0; n < 256; n++) + rs.s[n] = n; + rs.i = 0; + rs.j = 0; } /*************************************************************************/ @@ -929,17 +929,17 @@ static void arc4_init(void) */ static void arc4_addrandom(void *dat, int datlen) { - int n; - u_int8_t si; - - rs.i--; - for (n = 0; n < 256; n++) { - rs.i = (rs.i + 1); - si = rs.s[rs.i]; - rs.j = (rs.j + si + ((unsigned char *) dat)[n % datlen]); - rs.s[rs.i] = rs.s[rs.j]; - rs.s[rs.j] = si; - } + int n; + u_int8_t si; + + rs.i--; + for (n = 0; n < 256; n++) { + rs.i = (rs.i + 1); + si = rs.s[rs.i]; + rs.j = (rs.j + si + ((unsigned char *) dat)[n % datlen]); + rs.s[rs.i] = rs.s[rs.j]; + rs.s[rs.j] = si; + } } /*************************************************************************/ @@ -950,48 +950,48 @@ static void arc4_addrandom(void *dat, int datlen) */ void rand_init(void) { - int n; + int n; #ifndef _WIN32 - int fd; + int fd; #endif - struct { + struct { #ifdef USE_MYSQL - int sqlrand; + int sqlrand; #endif #ifndef _WIN32 - struct timeval nowt; /* time */ - char rnd[32]; /* /dev/urandom */ + struct timeval nowt; /* time */ + char rnd[32]; /* /dev/urandom */ #else - MEMORYSTATUS mstat; /* memory status */ - struct _timeb nowt; /* time */ + MEMORYSTATUS mstat; /* memory status */ + struct _timeb nowt; /* time */ #endif - } rdat; + } rdat; - arc4_init(); + arc4_init(); - /* Grab "random" MYSQL data */ + /* Grab "random" MYSQL data */ #ifdef USE_MYSQL - rdat.sqlrand = mysql_rand(); + rdat.sqlrand = mysql_rand(); #endif - /* Grab OS specific "random" data */ + /* Grab OS specific "random" data */ #ifndef _WIN32 - /* unix/bsd: time */ - gettimeofday(&rdat.nowt, NULL); - /* unix/bsd: /dev/urandom */ - fd = open("/dev/urandom", O_RDONLY); - if (fd) { - n = read(fd, &rdat.rnd, sizeof(rdat.rnd)); - close(fd); - } + /* unix/bsd: time */ + gettimeofday(&rdat.nowt, NULL); + /* unix/bsd: /dev/urandom */ + fd = open("/dev/urandom", O_RDONLY); + if (fd) { + n = read(fd, &rdat.rnd, sizeof(rdat.rnd)); + close(fd); + } #else - /* win32: time */ - _ftime(&rdat.nowt); - /* win32: memory status */ - GlobalMemoryStatus(&rdat.mstat); + /* win32: time */ + _ftime(&rdat.nowt); + /* win32: memory status */ + GlobalMemoryStatus(&rdat.mstat); #endif - arc4_addrandom(&rdat, sizeof(rdat)); + arc4_addrandom(&rdat, sizeof(rdat)); } /*************************************************************************/ @@ -1002,10 +1002,10 @@ void rand_init(void) */ void add_entropy_userkeys(void) { - arc4_addrandom(&UserKey1, sizeof(UserKey1)); - arc4_addrandom(&UserKey2, sizeof(UserKey2)); - arc4_addrandom(&UserKey3, sizeof(UserKey3)); - /* UserKey3 is also used in mysql_rand() */ + arc4_addrandom(&UserKey1, sizeof(UserKey1)); + arc4_addrandom(&UserKey2, sizeof(UserKey2)); + arc4_addrandom(&UserKey3, sizeof(UserKey3)); + /* UserKey3 is also used in mysql_rand() */ } /*************************************************************************/ @@ -1016,15 +1016,15 @@ void add_entropy_userkeys(void) */ unsigned char getrandom8(void) { - unsigned char si, sj; - - rs.i = (rs.i + 1); - si = rs.s[rs.i]; - rs.j = (rs.j + si); - sj = rs.s[rs.j]; - rs.s[rs.i] = sj; - rs.s[rs.j] = si; - return (rs.s[(si + sj) & 0xff]); + unsigned char si, sj; + + rs.i = (rs.i + 1); + si = rs.s[rs.i]; + rs.j = (rs.j + si); + sj = rs.s[rs.j]; + rs.s[rs.i] = sj; + rs.s[rs.j] = si; + return (rs.s[(si + sj) & 0xff]); } /*************************************************************************/ @@ -1035,11 +1035,11 @@ unsigned char getrandom8(void) */ u_int16_t getrandom16(void) { - u_int16_t val; + u_int16_t val; - val = getrandom8() << 8; - val |= getrandom8(); - return val; + val = getrandom8() << 8; + val |= getrandom8(); + return val; } /*************************************************************************/ @@ -1050,13 +1050,13 @@ u_int16_t getrandom16(void) */ u_int32_t getrandom32(void) { - u_int32_t val; + u_int32_t val; - val = getrandom8() << 24; - val |= getrandom8() << 16; - val |= getrandom8() << 8; - val |= getrandom8(); - return val; + val = getrandom8() << 24; + val |= getrandom8() << 16; + val |= getrandom8() << 8; + val |= getrandom8(); + return val; } /*************************************************************************/ @@ -1069,18 +1069,18 @@ u_int32_t getrandom32(void) */ int myNumToken(const char *str, const char dilim) { - int len, idx, counter = 0, start_pos = 0; - if (!str) { - return 0; - } - len = strlen(str); - for (idx = 0; idx <= len; idx++) { - if ((str[idx] == dilim) || (idx == len)) { - start_pos = idx + 1; - counter++; - } - } - return counter; + int len, idx, counter = 0, start_pos = 0; + if (!str) { + return 0; + } + len = strlen(str); + for (idx = 0; idx <= len; idx++) { + if ((str[idx] == dilim) || (idx == len)) { + start_pos = idx + 1; + counter++; + } + } + return counter; } /*************************************************************************/ @@ -1092,28 +1092,28 @@ int myNumToken(const char *str, const char dilim) */ char *host_resolve(char *host) { - struct hostent *hentp = NULL; - uint32 ip = INADDR_NONE; - char ipbuf[16]; - char *ipreturn; - struct in_addr addr; - - ipreturn = NULL; - - hentp = gethostbyname(host); - - if (hentp) { - memcpy(&ip, hentp->h_addr, sizeof(hentp->h_length)); - addr.s_addr = ip; - ntoa(addr, ipbuf, sizeof(ipbuf)); - ipreturn = sstrdup(ipbuf); - if (debug) { - alog("debug: resolved %s to %s", host, ipbuf); - } - return ipreturn; - } else { - return ipreturn; - } + struct hostent *hentp = NULL; + uint32 ip = INADDR_NONE; + char ipbuf[16]; + char *ipreturn; + struct in_addr addr; + + ipreturn = NULL; + + hentp = gethostbyname(host); + + if (hentp) { + memcpy(&ip, hentp->h_addr, sizeof(hentp->h_length)); + addr.s_addr = ip; + ntoa(addr, ipbuf, sizeof(ipbuf)); + ipreturn = sstrdup(ipbuf); + if (debug) { + alog("debug: resolved %s to %s", host, ipbuf); + } + return ipreturn; + } else { + return ipreturn; + } } /*************************************************************************/ @@ -1127,16 +1127,16 @@ char *host_resolve(char *host) char *str_signed(unsigned char *str) { - char *nstr; + char *nstr; - nstr = (char *) str; - while (*str) { - *nstr = (char) *str; - str++; - nstr++; - } + nstr = (char *) str; + while (*str) { + *nstr = (char) *str; + str++; + nstr++; + } - return nstr; + return nstr; } /** @@ -1146,19 +1146,19 @@ char *str_signed(unsigned char *str) char *stripModePrefix(const char *str) { - if (str && ((*str == '+') || (*str == '-'))) { - return sstrdup(str + 1); - } - return NULL; + if (str && ((*str == '+') || (*str == '-'))) { + return sstrdup(str + 1); + } + return NULL; } /* Equivalent to inet_ntoa */ void ntoa(struct in_addr addr, char *ipaddr, int len) { - unsigned char *bytes = (unsigned char *) &addr.s_addr; - snprintf(ipaddr, len, "%u.%u.%u.%u", bytes[0], bytes[1], bytes[2], - bytes[3]); + unsigned char *bytes = (unsigned char *) &addr.s_addr; + snprintf(ipaddr, len, "%u.%u.%u.%u", bytes[0], bytes[1], bytes[2], + bytes[3]); } /** @@ -1169,22 +1169,22 @@ void ntoa(struct in_addr addr, char *ipaddr, int len) **/ char **buildStringList(char *src, int *number) { - char *s; - int i = 0; - char **list = NULL; - - if (src) { - s = strtok(src, " "); - do { - if (s) { - i++; - list = (char **)realloc(list, sizeof(char *) * i); - list[i - 1] = sstrdup(s); - } - } while ((s = strtok(NULL, " "))); - } - *number = i; /* always zero it, even if we have no setters */ - return list; + char *s; + int i = 0; + char **list = NULL; + + if (src) { + s = strtok(src, " "); + do { + if (s) { + i++; + list = (char **)realloc(list, sizeof(char *) * i); + list[i - 1] = sstrdup(s); + } + } while ((s = strtok(NULL, " "))); + } + *number = i; /* always zero it, even if we have no setters */ + return list; } /* @@ -1199,12 +1199,12 @@ char **buildStringList(char *src, int *number) * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. +* notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products -* derived from this software without specific prior written permission. +* derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED `AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY @@ -1221,57 +1221,57 @@ char **buildStringList(char *src, int *number) #ifndef HAVE_STRLCAT size_t strlcat(char *dst, const char *src, size_t siz) { - char *d = dst; - const char *s = src; - size_t n = siz, dlen; + char *d = dst; + const char *s = src; + size_t n = siz, dlen; - while (n-- != 0 && *d != '\0') - d++; + while (n-- != 0 && *d != '\0') + d++; - dlen = d - dst; - n = siz - dlen; + dlen = d - dst; + n = siz - dlen; - if (n == 0) - return (dlen + strlen(s)); + if (n == 0) + return (dlen + strlen(s)); - while (*s != '\0') { - if (n != 1) { - *d++ = *s; - n--; - } + while (*s != '\0') { + if (n != 1) { + *d++ = *s; + n--; + } - s++; - } + s++; + } - *d = '\0'; - return dlen + (s - src); /* count does not include NUL */ + *d = '\0'; + return dlen + (s - src); /* count does not include NUL */ } #endif #ifndef HAVE_STRLCPY size_t strlcpy(char *dst, const char *src, size_t siz) { - char *d = dst; - const char *s = src; - size_t n = siz; - - /* Copy as many bytes as will fit */ - if (n != 0 && --n != 0) { - do { - if ((*d++ = *s++) == 0) - break; - } - while (--n != 0); - } - - /* Not enough room in dst, add NUL and traverse rest of src */ - if (n == 0) { - if (siz != 0) - *d = '\0'; /* NUL-terminate dst */ - while (*s++); - } - - return s - src - 1; /* count does not include NUL */ + char *d = dst; + const char *s = src; + size_t n = siz; + + /* Copy as many bytes as will fit */ + if (n != 0 && --n != 0) { + do { + if ((*d++ = *s++) == 0) + break; + } + while (--n != 0); + } + + /* Not enough room in dst, add NUL and traverse rest of src */ + if (n == 0) { + if (siz != 0) + *d = '\0'; /* NUL-terminate dst */ + while (*s++); + } + + return s - src - 1; /* count does not include NUL */ } #endif @@ -1281,169 +1281,169 @@ size_t strlcpy(char *dst, const char *src, size_t siz) #ifdef _WIN32 char *GetWindowsVersion(void) { - OSVERSIONINFOEX osvi; - BOOL bOsVersionInfoEx; - char buf[BUFSIZE]; - char *extra; - char *cputype; - SYSTEM_INFO si; - - ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); - ZeroMemory(&si, sizeof(SYSTEM_INFO)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - - if (!(bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *) & osvi))) { - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - if (!GetVersionEx((OSVERSIONINFO *) & osvi)) { - return sstrdup(""); - } - } - GetSystemInfo(&si); - - /* Determine CPU type 32 or 64 */ - if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 ) { - cputype = sstrdup(" 64-bit"); - } else if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_INTEL ) { - cputype = sstrdup(" 32-bit"); - } else if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64 ) { - cputype = sstrdup(" Itanium 64-bit"); - } else { + OSVERSIONINFOEX osvi; + BOOL bOsVersionInfoEx; + char buf[BUFSIZE]; + char *extra; + char *cputype; + SYSTEM_INFO si; + + ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); + ZeroMemory(&si, sizeof(SYSTEM_INFO)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + + if (!(bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *) & osvi))) { + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + if (!GetVersionEx((OSVERSIONINFO *) & osvi)) { + return sstrdup(""); + } + } + GetSystemInfo(&si); + + /* Determine CPU type 32 or 64 */ + if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 ) { + cputype = sstrdup(" 64-bit"); + } else if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_INTEL ) { + cputype = sstrdup(" 32-bit"); + } else if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64 ) { + cputype = sstrdup(" Itanium 64-bit"); + } else { cputype = sstrdup(" "); - } + } - switch (osvi.dwPlatformId) { - /* test for the Windows NT product family. */ - case VER_PLATFORM_WIN32_NT: + switch (osvi.dwPlatformId) { + /* test for the Windows NT product family. */ + case VER_PLATFORM_WIN32_NT: /* Windows Vista or Windows Server 2008 */ - if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0) { - if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) { - extra = sstrdup("Enterprise Edition"); - } else if (osvi.wSuiteMask & VER_SUITE_DATACENTER) { - extra = sstrdup("Datacenter Edition"); - } else if (osvi.wSuiteMask & VER_SUITE_PERSONAL) { - extra = sstrdup("Home Premium/Basic"); - } else { - extra = sstrdup(" "); - } - if (osvi.wProductType & VER_NT_WORKSTATION) { - snprintf(buf, sizeof(buf), "Microsoft Windows Vista %s%s", - cputype, extra); - } else { - snprintf(buf, sizeof(buf), "Microsoft Windows Server 2008 %s%s", - cputype, extra); - } - free(extra); - } + if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0) { + if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) { + extra = sstrdup("Enterprise Edition"); + } else if (osvi.wSuiteMask & VER_SUITE_DATACENTER) { + extra = sstrdup("Datacenter Edition"); + } else if (osvi.wSuiteMask & VER_SUITE_PERSONAL) { + extra = sstrdup("Home Premium/Basic"); + } else { + extra = sstrdup(" "); + } + if (osvi.wProductType & VER_NT_WORKSTATION) { + snprintf(buf, sizeof(buf), "Microsoft Windows Vista %s%s", + cputype, extra); + } else { + snprintf(buf, sizeof(buf), "Microsoft Windows Server 2008 %s%s", + cputype, extra); + } + free(extra); + } /* Windows 2003 or Windows XP Pro 64 */ - if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) { - if (osvi.wSuiteMask & VER_SUITE_DATACENTER) { - extra = sstrdup("Datacenter Edition"); - } else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) { - extra = sstrdup("Enterprise Edition"); - } else if (osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER) { - extra = sstrdup("Compute Cluster Edition"); - } else if (osvi.wSuiteMask == VER_SUITE_BLADE) { - extra = sstrdup("Web Edition"); - } else { - extra = sstrdup("Standard Edition"); - } - if ( osvi.wProductType & VER_NT_WORKSTATION && si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) { - snprintf(buf, sizeof(buf), "Windows XP Professional x64 Edition %s", - extra); - } else { - snprintf(buf, sizeof(buf), - "Microsoft Windows Server 2003 Family %s%s", cputype, extra); - } - free(extra); - } - if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) { - if (osvi.wSuiteMask & VER_SUITE_EMBEDDEDNT) { - extra = sstrdup("Embedded"); - } else if (osvi.wSuiteMask & VER_SUITE_PERSONAL) { - extra = sstrdup("Home Edition"); - } else { - extra = sstrdup(" "); - } - snprintf(buf, sizeof(buf), "Microsoft Windows XP %s", extra); - free(extra); - } - if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) { - if (osvi.wSuiteMask & VER_SUITE_DATACENTER) { - extra = sstrdup("Datacenter Server"); - } else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) { - extra = sstrdup("Advanced Server"); - } else { - extra = sstrdup("Server"); - } - snprintf(buf, sizeof(buf), "Microsoft Windows 2000 %s", extra); - free(extra); - } - if (osvi.dwMajorVersion <= 4) { - if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) { - extra = sstrdup("Server 4.0, Enterprise Edition"); - } else { - extra = sstrdup("Server 4.0"); - } - snprintf(buf, sizeof(buf), "Microsoft Windows NT %s", extra); - free(extra); - } - case VER_PLATFORM_WIN32_WINDOWS: - if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0) { - if (osvi.szCSDVersion[1] == 'C' || osvi.szCSDVersion[1] == 'B') { - extra = sstrdup("OSR2"); - } else { - extra = sstrdup(" "); - } - snprintf(buf, sizeof(buf), "Microsoft Windows 95 %s", extra); - free(extra); - } - if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10) { - if (osvi.szCSDVersion[1] == 'A') { - extra = sstrdup("SE"); - } else { - extra = sstrdup(" "); - } - snprintf(buf, sizeof(buf), "Microsoft Windows 98 %s", extra); - free(extra); - } - if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90) { - snprintf(buf, sizeof(buf), - "Microsoft Windows Millennium Edition"); - } - } - free(cputype); - return sstrdup(buf); + if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) { + if (osvi.wSuiteMask & VER_SUITE_DATACENTER) { + extra = sstrdup("Datacenter Edition"); + } else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) { + extra = sstrdup("Enterprise Edition"); + } else if (osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER) { + extra = sstrdup("Compute Cluster Edition"); + } else if (osvi.wSuiteMask == VER_SUITE_BLADE) { + extra = sstrdup("Web Edition"); + } else { + extra = sstrdup("Standard Edition"); + } + if ( osvi.wProductType & VER_NT_WORKSTATION && si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) { + snprintf(buf, sizeof(buf), "Windows XP Professional x64 Edition %s", + extra); + } else { + snprintf(buf, sizeof(buf), + "Microsoft Windows Server 2003 Family %s%s", cputype, extra); + } + free(extra); + } + if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) { + if (osvi.wSuiteMask & VER_SUITE_EMBEDDEDNT) { + extra = sstrdup("Embedded"); + } else if (osvi.wSuiteMask & VER_SUITE_PERSONAL) { + extra = sstrdup("Home Edition"); + } else { + extra = sstrdup(" "); + } + snprintf(buf, sizeof(buf), "Microsoft Windows XP %s", extra); + free(extra); + } + if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) { + if (osvi.wSuiteMask & VER_SUITE_DATACENTER) { + extra = sstrdup("Datacenter Server"); + } else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) { + extra = sstrdup("Advanced Server"); + } else { + extra = sstrdup("Server"); + } + snprintf(buf, sizeof(buf), "Microsoft Windows 2000 %s", extra); + free(extra); + } + if (osvi.dwMajorVersion <= 4) { + if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) { + extra = sstrdup("Server 4.0, Enterprise Edition"); + } else { + extra = sstrdup("Server 4.0"); + } + snprintf(buf, sizeof(buf), "Microsoft Windows NT %s", extra); + free(extra); + } + case VER_PLATFORM_WIN32_WINDOWS: + if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0) { + if (osvi.szCSDVersion[1] == 'C' || osvi.szCSDVersion[1] == 'B') { + extra = sstrdup("OSR2"); + } else { + extra = sstrdup(" "); + } + snprintf(buf, sizeof(buf), "Microsoft Windows 95 %s", extra); + free(extra); + } + if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10) { + if (osvi.szCSDVersion[1] == 'A') { + extra = sstrdup("SE"); + } else { + extra = sstrdup(" "); + } + snprintf(buf, sizeof(buf), "Microsoft Windows 98 %s", extra); + free(extra); + } + if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90) { + snprintf(buf, sizeof(buf), + "Microsoft Windows Millennium Edition"); + } + } + free(cputype); + return sstrdup(buf); } int SupportedWindowsVersion(void) { - OSVERSIONINFOEX osvi; - BOOL bOsVersionInfoEx; - - ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - - if (!(bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *) & osvi))) { - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - if (!GetVersionEx((OSVERSIONINFO *) & osvi)) { - return 0; - } - } - - switch (osvi.dwPlatformId) { - /* test for the Windows NT product family. */ - case VER_PLATFORM_WIN32_NT: - /* win nt4 */ - if (osvi.dwMajorVersion <= 4) { - return 0; - } - /* the rest */ - return 1; - /* win95 win98 winME */ - case VER_PLATFORM_WIN32_WINDOWS: - return 0; - } - return 0; + OSVERSIONINFOEX osvi; + BOOL bOsVersionInfoEx; + + ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + + if (!(bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *) & osvi))) { + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + if (!GetVersionEx((OSVERSIONINFO *) & osvi)) { + return 0; + } + } + + switch (osvi.dwPlatformId) { + /* test for the Windows NT product family. */ + case VER_PLATFORM_WIN32_NT: + /* win nt4 */ + if (osvi.dwMajorVersion <= 4) { + return 0; + } + /* the rest */ + return 1; + /* win95 win98 winME */ + case VER_PLATFORM_WIN32_WINDOWS: + return 0; + } + return 0; } #endif @@ -1459,10 +1459,10 @@ int SupportedWindowsVersion(void) */ uint32 cidr_to_netmask(uint16 cidr) { - if (cidr == 0) - return 0; + if (cidr == 0) + return 0; - return (0xFFFFFFFF - (1 << (32 - cidr)) + 1); + return (0xFFFFFFFF - (1 << (32 - cidr)) + 1); } /** @@ -1472,12 +1472,12 @@ uint32 cidr_to_netmask(uint16 cidr) */ uint16 netmask_to_cidr(uint32 mask) { - int tmp = 0; + int tmp = 0; - while (!(mask & (1 << tmp)) && (tmp < 32)) - tmp++; + while (!(mask & (1 << tmp)) && (tmp < 32)) + tmp++; - return (32 - tmp); + return (32 - tmp); } /*************************************************************************/ @@ -1489,13 +1489,13 @@ uint16 netmask_to_cidr(uint32 mask) */ int str_is_wildcard(const char *str) { - while (*str) { - if ((*str == '*') || (*str == '?')) - return 1; - str++; - } + while (*str) { + if ((*str == '*') || (*str == '?')) + return 1; + str++; + } - return 0; + return 0; } /** @@ -1505,13 +1505,13 @@ int str_is_wildcard(const char *str) */ int str_is_pure_wildcard(const char *str) { - while (*str) { - if (*str != '*') - return 0; - str++; - } + while (*str) { + if (*str != '*') + return 0; + str++; + } - return 1; + return 1; } /*************************************************************************/ @@ -1523,28 +1523,28 @@ int str_is_pure_wildcard(const char *str) */ uint32 str_is_ip(char *str) { - int i; - int octets[4] = { -1, -1, -1, -1 }; - char *s = str; - uint32 ip; - - for (i = 0; i < 4; i++) { - octets[i] = strtol(s, &s, 10); - /* Bail out if the octet is invalid or wrongly terminated */ - if ((octets[i] < 0) || (octets[i] > 255) - || ((i < 3) && (*s != '.'))) - return 0; - if (i < 3) - s++; - } - - /* Fill the IP - the dirty way */ - ip = octets[3]; - ip += octets[2] * 256; - ip += octets[1] * 65536; - ip += octets[0] * 16777216; - - return ip; + int i; + int octets[4] = { -1, -1, -1, -1 }; + char *s = str; + uint32 ip; + + for (i = 0; i < 4; i++) { + octets[i] = strtol(s, &s, 10); + /* Bail out if the octet is invalid or wrongly terminated */ + if ((octets[i] < 0) || (octets[i] > 255) + || ((i < 3) && (*s != '.'))) + return 0; + if (i < 3) + s++; + } + + /* Fill the IP - the dirty way */ + ip = octets[3]; + ip += octets[2] * 256; + ip += octets[1] * 65536; + ip += octets[0] * 16777216; + + return ip; } /*************************************************************************/ @@ -1560,60 +1560,60 @@ uint32 str_is_ip(char *str) */ int str_is_cidr(char *str, uint32 * ip, uint32 * mask, char **host) { - int i; - int octets[4] = { -1, -1, -1, -1 }; - char *s = str; - char buf[512]; - uint16 cidr; - - for (i = 0; i < 4; i++) { - octets[i] = strtol(s, &s, 10); - /* Bail out if the octet is invalid or wrongly terminated */ - if ((octets[i] < 0) || (octets[i] > 255) - || ((i < 3) && (*s != '.'))) - return 0; - if (i < 3) - s++; - } - - /* Fill the IP - the dirty way */ - *ip = octets[3]; - *ip += octets[2] * 256; - *ip += octets[1] * 65536; - *ip += octets[0] * 16777216; - - if (*s == '/') { - s++; - /* There's a CIDR mask here! */ - cidr = strtol(s, &s, 10); - /* Bail out if the CIDR is invalid or the string isn't done yet */ - if ((cidr > 32) || (*s)) - return 0; - } else { - /* No CIDR mask here - use 32 so the whole ip will be matched */ - cidr = 32; - } - - *mask = cidr_to_netmask(cidr); - /* Apply the mask to avoid 255.255.255.255/8 bans */ - *ip &= *mask; - - /* Refill the octets to fill the host */ - octets[0] = (*ip & 0xFF000000) / 16777216; - octets[1] = (*ip & 0x00FF0000) / 65536; - octets[2] = (*ip & 0x0000FF00) / 256; - octets[3] = (*ip & 0x000000FF); - - if (cidr == 32) - snprintf(buf, 512, "%d.%d.%d.%d", octets[0], octets[1], octets[2], - octets[3]); - else - snprintf(buf, 512, "%d.%d.%d.%d/%d", octets[0], octets[1], - octets[2], octets[3], cidr); - - *host = sstrdup(buf); - - return 1; + int i; + int octets[4] = { -1, -1, -1, -1 }; + char *s = str; + char buf[512]; + uint16 cidr; + + for (i = 0; i < 4; i++) { + octets[i] = strtol(s, &s, 10); + /* Bail out if the octet is invalid or wrongly terminated */ + if ((octets[i] < 0) || (octets[i] > 255) + || ((i < 3) && (*s != '.'))) + return 0; + if (i < 3) + s++; + } + + /* Fill the IP - the dirty way */ + *ip = octets[3]; + *ip += octets[2] * 256; + *ip += octets[1] * 65536; + *ip += octets[0] * 16777216; + + if (*s == '/') { + s++; + /* There's a CIDR mask here! */ + cidr = strtol(s, &s, 10); + /* Bail out if the CIDR is invalid or the string isn't done yet */ + if ((cidr > 32) || (*s)) + return 0; + } else { + /* No CIDR mask here - use 32 so the whole ip will be matched */ + cidr = 32; + } + + *mask = cidr_to_netmask(cidr); + /* Apply the mask to avoid 255.255.255.255/8 bans */ + *ip &= *mask; + + /* Refill the octets to fill the host */ + octets[0] = (*ip & 0xFF000000) / 16777216; + octets[1] = (*ip & 0x00FF0000) / 65536; + octets[2] = (*ip & 0x0000FF00) / 256; + octets[3] = (*ip & 0x000000FF); + + if (cidr == 32) + snprintf(buf, 512, "%d.%d.%d.%d", octets[0], octets[1], octets[2], + octets[3]); + else + snprintf(buf, 512, "%d.%d.%d.%d/%d", octets[0], octets[1], + octets[2], octets[3], cidr); + + *host = sstrdup(buf); + + return 1; } /* EOF */ diff --git a/src/module.cpp b/src/module.cpp index 7179d8bdf..9c86ec299 100644 --- a/src/module.cpp +++ b/src/module.cpp @@ -38,31 +38,31 @@ Module::Module(const std::string &mname, const std::string &creator) this->lang[i].argc = 0; } - int index = 0; - ModuleHash *current = NULL; - ModuleHash *newHash = NULL; - ModuleHash *lastHash = NULL; + int index = 0; + ModuleHash *current = NULL; + ModuleHash *newHash = NULL; + ModuleHash *lastHash = NULL; - index = CMD_HASH(this->name); + index = CMD_HASH(this->name); - for (current = MODULE_HASH[index]; current; current = current->next) { - if (this->name ==current->name) + for (current = MODULE_HASH[index]; current; current = current->next) { + if (this->name ==current->name) throw CoreException("Module already exists!"); - lastHash = current; - } - - if ((newHash = (ModuleHash *)malloc(sizeof(ModuleHash))) == NULL) { - fatal("Out of memory"); - } - this->created = time(NULL); - newHash->next = NULL; - newHash->name = sstrdup(this->name.c_str()); - newHash->m = this; - - if (lastHash == NULL) - MODULE_HASH[index] = newHash; - else - lastHash->next = newHash; + lastHash = current; + } + + if ((newHash = (ModuleHash *)malloc(sizeof(ModuleHash))) == NULL) { + fatal("Out of memory"); + } + this->created = time(NULL); + newHash->next = NULL; + newHash->name = sstrdup(this->name.c_str()); + newHash->m = this; + + if (lastHash == NULL) + MODULE_HASH[index] = newHash; + else + lastHash->next = newHash; } Module::~Module() @@ -81,130 +81,130 @@ Module::~Module() alog("%s", ano_moderr()); } - int idx; - CommandHash *current = NULL; - MessageHash *mcurrent = NULL; - EvtMessageHash *ecurrent = NULL; - EvtHookHash *ehcurrent = NULL; - - Command *c; - Message *msg; - EvtMessage *eMsg; - EvtHook *eHook; - int status = 0; - - /* Kill any active callbacks this module has */ - moduleCallBackPrepForUnload(this->name.c_str()); - - /* Remove any stored data this module has */ - moduleDelAllDataMod(this); - - /** - * ok, im going to walk every hash looking for commands we own, now, not exactly elegant or efficiant :) - **/ - for (idx = 0; idx < MAX_CMD_HASH; idx++) { - for (current = HS_cmdTable[idx]; current; current = current->next) { - for (c = current->c; c; c = c->next) { - if ((c->mod_name) && (strcmp(c->mod_name, this->name.c_str()) == 0)) { - this->DelCommand(HOSTSERV, c->name); - } - } - } - - for (current = BS_cmdTable[idx]; current; current = current->next) { - for (c = current->c; c; c = c->next) { - if ((c->mod_name) && (strcmp(c->mod_name, this->name.c_str()) == 0)) { - this->DelCommand(BOTSERV, c->name); - } - } - } - - for (current = MS_cmdTable[idx]; current; current = current->next) { - for (c = current->c; c; c = c->next) { - if ((c->mod_name) && (strcmp(c->mod_name, this->name.c_str()) == 0)) { - this->DelCommand(MEMOSERV, c->name); - } - } - } - - for (current = NS_cmdTable[idx]; current; current = current->next) { - for (c = current->c; c; c = c->next) { - if ((c->mod_name) && (strcmp(c->mod_name, this->name.c_str()) == 0)) { - this->DelCommand(NICKSERV, c->name); - } - } - } - - for (current = CS_cmdTable[idx]; current; current = current->next) { - for (c = current->c; c; c = c->next) { - if ((c->mod_name) && (strcmp(c->mod_name, this->name.c_str()) == 0)) { - this->DelCommand(CHANSERV, c->name); - } - } - } - - for (current = HE_cmdTable[idx]; current; current = current->next) { - for (c = current->c; c; c = c->next) { - if ((c->mod_name) && (strcmp(c->mod_name, this->name.c_str()) == 0)) { - this->DelCommand(HELPSERV, c->name); - } - } - } - - for (current = OS_cmdTable[idx]; current; current = current->next) { - for (c = current->c; c; c = c->next) { - if ((c->mod_name) && (stricmp(c->mod_name, this->name.c_str()) == 0)) { - this->DelCommand(OPERSERV, c->name); - } - } - } - - for (mcurrent = IRCD[idx]; mcurrent; mcurrent = mcurrent->next) { - for (msg = mcurrent->m; msg; msg = msg->next) { - if ((msg->mod_name) - && (stricmp(msg->mod_name, this->name.c_str()) == 0)) { - moduleDelMessage(msg->name); - } - } - } - - for (ecurrent = EVENT[idx]; ecurrent; ecurrent = ecurrent->next) { - for (eMsg = ecurrent->evm; eMsg; eMsg = eMsg->next) { - if ((eMsg->mod_name) - && (stricmp(eMsg->mod_name, this->name.c_str()) == 0)) { - status = delEventHandler(EVENT, eMsg, this->name.c_str()); - } - } - } - for (ehcurrent = EVENTHOOKS[idx]; ehcurrent; - ehcurrent = ehcurrent->next) { - for (eHook = ehcurrent->evh; eHook; eHook = eHook->next) { - if ((eHook->mod_name) - && (stricmp(eHook->mod_name, this->name.c_str()) == 0)) { - status = delEventHook(EVENTHOOKS, eHook, this->name.c_str()); - } - } - } - } - - int index = 0; - ModuleHash *lastHash = NULL; + int idx; + CommandHash *current = NULL; + MessageHash *mcurrent = NULL; + EvtMessageHash *ecurrent = NULL; + EvtHookHash *ehcurrent = NULL; + + Command *c; + Message *msg; + EvtMessage *eMsg; + EvtHook *eHook; + int status = 0; + + /* Kill any active callbacks this module has */ + moduleCallBackPrepForUnload(this->name.c_str()); + + /* Remove any stored data this module has */ + moduleDelAllDataMod(this); + + /** + * ok, im going to walk every hash looking for commands we own, now, not exactly elegant or efficiant :) + **/ + for (idx = 0; idx < MAX_CMD_HASH; idx++) { + for (current = HS_cmdTable[idx]; current; current = current->next) { + for (c = current->c; c; c = c->next) { + if ((c->mod_name) && (strcmp(c->mod_name, this->name.c_str()) == 0)) { + this->DelCommand(HOSTSERV, c->name); + } + } + } + + for (current = BS_cmdTable[idx]; current; current = current->next) { + for (c = current->c; c; c = c->next) { + if ((c->mod_name) && (strcmp(c->mod_name, this->name.c_str()) == 0)) { + this->DelCommand(BOTSERV, c->name); + } + } + } + + for (current = MS_cmdTable[idx]; current; current = current->next) { + for (c = current->c; c; c = c->next) { + if ((c->mod_name) && (strcmp(c->mod_name, this->name.c_str()) == 0)) { + this->DelCommand(MEMOSERV, c->name); + } + } + } + + for (current = NS_cmdTable[idx]; current; current = current->next) { + for (c = current->c; c; c = c->next) { + if ((c->mod_name) && (strcmp(c->mod_name, this->name.c_str()) == 0)) { + this->DelCommand(NICKSERV, c->name); + } + } + } + + for (current = CS_cmdTable[idx]; current; current = current->next) { + for (c = current->c; c; c = c->next) { + if ((c->mod_name) && (strcmp(c->mod_name, this->name.c_str()) == 0)) { + this->DelCommand(CHANSERV, c->name); + } + } + } + + for (current = HE_cmdTable[idx]; current; current = current->next) { + for (c = current->c; c; c = c->next) { + if ((c->mod_name) && (strcmp(c->mod_name, this->name.c_str()) == 0)) { + this->DelCommand(HELPSERV, c->name); + } + } + } + + for (current = OS_cmdTable[idx]; current; current = current->next) { + for (c = current->c; c; c = c->next) { + if ((c->mod_name) && (stricmp(c->mod_name, this->name.c_str()) == 0)) { + this->DelCommand(OPERSERV, c->name); + } + } + } + + for (mcurrent = IRCD[idx]; mcurrent; mcurrent = mcurrent->next) { + for (msg = mcurrent->m; msg; msg = msg->next) { + if ((msg->mod_name) + && (stricmp(msg->mod_name, this->name.c_str()) == 0)) { + moduleDelMessage(msg->name); + } + } + } + + for (ecurrent = EVENT[idx]; ecurrent; ecurrent = ecurrent->next) { + for (eMsg = ecurrent->evm; eMsg; eMsg = eMsg->next) { + if ((eMsg->mod_name) + && (stricmp(eMsg->mod_name, this->name.c_str()) == 0)) { + status = delEventHandler(EVENT, eMsg, this->name.c_str()); + } + } + } + for (ehcurrent = EVENTHOOKS[idx]; ehcurrent; + ehcurrent = ehcurrent->next) { + for (eHook = ehcurrent->evh; eHook; eHook = eHook->next) { + if ((eHook->mod_name) + && (stricmp(eHook->mod_name, this->name.c_str()) == 0)) { + status = delEventHook(EVENTHOOKS, eHook, this->name.c_str()); + } + } + } + } + + int index = 0; + ModuleHash *lastHash = NULL; ModuleHash *mhash = NULL; - index = CMD_HASH(this->name); - - for (mhash = MODULE_HASH[index]; mhash; mhash = mhash->next) { - if (this->name == mhash->name) { - if (!lastHash) { - MODULE_HASH[index] = mhash->next; - } else { - lastHash->next = mhash->next; - } - free(mhash->name); - free(mhash); - } - lastHash = mhash; - } + index = CMD_HASH(this->name); + + for (mhash = MODULE_HASH[index]; mhash; mhash = mhash->next) { + if (this->name == mhash->name) { + if (!lastHash) { + MODULE_HASH[index] = mhash->next; + } else { + lastHash->next = mhash->next; + } + free(mhash->name); + free(mhash); + } + lastHash = mhash; + } } void Module::SetType(MODType ntype) diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index 2a01351e1..8ce6ce953 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -20,17 +20,17 @@ void ModuleManager::LoadModuleList(int total_modules, char **module_list) { - int idx; - Module *m; - int status = 0; - for (idx = 0; idx < total_modules; idx++) { - m = findModule(module_list[idx]); - if (!m) { - status = ModuleManager::LoadModule(module_list[idx], NULL); - mod_current_module = NULL; - mod_current_user = NULL; - } - } + int idx; + Module *m; + int status = 0; + for (idx = 0; idx < total_modules; idx++) { + m = findModule(module_list[idx]); + if (!m) { + status = ModuleManager::LoadModule(module_list[idx], NULL); + mod_current_module = NULL; + mod_current_user = NULL; + } + } } /** @@ -44,17 +44,17 @@ void ModuleManager::LoadModuleList(int total_modules, char **module_list) */ static int moduleCopyFile(const char *name, const char *output) { - int ch; - FILE *source, *target; + int ch; + FILE *source, *target; int srcfp; - char input[4096]; - int len; + char input[4096]; + int len; - strncpy(input, MODULE_PATH, 4095); /* Get full path with module extension */ - len = strlen(input); - strncat(input, name, 4095 - len); - len = strlen(output); - strncat(input, MODULE_EXT, 4095 - len); + strncpy(input, MODULE_PATH, 4095); /* Get full path with module extension */ + len = strlen(input); + strncat(input, name, 4095 - len); + len = strlen(output); + strncat(input, MODULE_EXT, 4095 - len); #ifndef _WIN32 if ((srcfp = mkstemp((char *)output)) == -1) @@ -71,27 +71,27 @@ static int moduleCopyFile(const char *name, const char *output) * calls for it here? -GD */ #ifndef _WIN32 - if ((source = fopen(input, "r")) == NULL) { + if ((source = fopen(input, "r")) == NULL) { #else - if ((source = fopen(input, "rb")) == NULL) { + if ((source = fopen(input, "rb")) == NULL) { #endif - return MOD_ERR_NOEXIST; - } + return MOD_ERR_NOEXIST; + } #ifndef _WIN32 - if ((target = fdopen(srcfp, "w")) == NULL) { + if ((target = fdopen(srcfp, "w")) == NULL) { #else - if ((target = fopen(output, "wb")) == NULL) { + if ((target = fopen(output, "wb")) == NULL) { #endif - return MOD_ERR_FILE_IO; - } - while ((ch = fgetc(source)) != EOF) { - fputc(ch, target); - } - fclose(source); - if (fclose(target) != 0) { - return MOD_ERR_FILE_IO; - } - return MOD_ERR_OK; + return MOD_ERR_FILE_IO; + } + while ((ch = fgetc(source)) != EOF) { + fputc(ch, target); + } + fclose(source); + if (fclose(target) != 0) { + return MOD_ERR_FILE_IO; + } + return MOD_ERR_OK; } static bool IsOneOfModuleTypeLoaded(MODType mt) @@ -148,7 +148,7 @@ int ModuleManager::LoadModule(const std::string &modname, User * u) pbuf += "XXXXXX"; /* Don't skip return value checking! -GD */ - if ((ret = moduleCopyFile(modname.c_str(), pbuf.c_str())) != MOD_ERR_OK) + if ((ret = moduleCopyFile(modname.c_str(), pbuf.c_str())) != MOD_ERR_OK) { /* XXX: This used to assign filename here, but I don't think that was correct.. * even if it was, it makes life very fucking difficult, so. @@ -174,7 +174,7 @@ int ModuleManager::LoadModule(const std::string &modname, User * u) return MOD_ERR_NOLOAD; } - if (!func) + if (!func) { throw CoreException("Couldn't find constructor, yet moderror wasn't set?"); } diff --git a/src/modules.c b/src/modules.c index 36ffc2ed5..aa8f09b29 100644 --- a/src/modules.c +++ b/src/modules.c @@ -56,23 +56,23 @@ ModuleCallBack *moduleCallBackHead = NULL; char *ModuleGetErrStr(int status) { - const char *module_err_str[] = { - "Module, Okay - No Error", /* MOD_ERR_OK */ - "Module Error, Allocating memory", /* MOD_ERR_MEMORY */ - "Module Error, Not enough parameters", /* MOD_ERR_PARAMS */ - "Module Error, Already loaded", /* MOD_ERR_EXISTS */ - "Module Error, File does not exist", /* MOD_ERR_NOEXIST */ - "Module Error, No User", /* MOD_ERR_NOUSER */ - "Module Error, Error during load time or module returned MOD_STOP", /* MOD_ERR_NOLOAD */ - "Module Error, Unable to unload", /* MOD_ERR_NOUNLOAD */ - "Module Error, Incorrect syntax", /* MOD_ERR_SYNTAX */ - "Module Error, Unable to delete", /* MOD_ERR_NODELETE */ - "Module Error, Unknown Error occuried", /* MOD_ERR_UNKOWN */ - "Module Error, File I/O Error", /* MOD_ERR_FILE_IO */ - "Module Error, No Service found for request", /* MOD_ERR_NOSERVICE */ - "Module Error, No module name for request" /* MOD_ERR_NO_MOD_NAME */ - }; - return (char *) module_err_str[status]; + const char *module_err_str[] = { + "Module, Okay - No Error", /* MOD_ERR_OK */ + "Module Error, Allocating memory", /* MOD_ERR_MEMORY */ + "Module Error, Not enough parameters", /* MOD_ERR_PARAMS */ + "Module Error, Already loaded", /* MOD_ERR_EXISTS */ + "Module Error, File does not exist", /* MOD_ERR_NOEXIST */ + "Module Error, No User", /* MOD_ERR_NOUSER */ + "Module Error, Error during load time or module returned MOD_STOP", /* MOD_ERR_NOLOAD */ + "Module Error, Unable to unload", /* MOD_ERR_NOUNLOAD */ + "Module Error, Incorrect syntax", /* MOD_ERR_SYNTAX */ + "Module Error, Unable to delete", /* MOD_ERR_NODELETE */ + "Module Error, Unknown Error occuried", /* MOD_ERR_UNKOWN */ + "Module Error, File I/O Error", /* MOD_ERR_FILE_IO */ + "Module Error, No Service found for request", /* MOD_ERR_NOSERVICE */ + "Module Error, No module name for request" /* MOD_ERR_NO_MOD_NAME */ + }; + return (char *) module_err_str[status]; } @@ -89,14 +89,14 @@ char *ModuleGetErrStr(int status) */ static int displayCommand(Command * c) { - Command *cmd = NULL; - int i = 0; - alog("Displaying command list for %s", c->name); - for (cmd = c; cmd; cmd = cmd->next) { - alog("%d: 0x%p", ++i, (void *) cmd); - } - alog("end"); - return 0; + Command *cmd = NULL; + int i = 0; + alog("Displaying command list for %s", c->name); + for (cmd = c; cmd; cmd = cmd->next) { + alog("%d: 0x%p", ++i, (void *) cmd); + } + alog("end"); + return 0; } /** @@ -108,21 +108,21 @@ static int displayCommand(Command * c) */ static int displayCommandFromHash(CommandHash * cmdTable[], const char *name) { - CommandHash *current = NULL; - int index = 0; - index = CMD_HASH(name); - if (debug > 1) { - alog("debug: trying to display command %s", name); - } - for (current = cmdTable[index]; current; current = current->next) { - if (stricmp(name, current->name) == 0) { - displayCommand(current->c); - } - } - if (debug > 1) { - alog("debug: done displaying command %s", name); - } - return 0; + CommandHash *current = NULL; + int index = 0; + index = CMD_HASH(name); + if (debug > 1) { + alog("debug: trying to display command %s", name); + } + for (current = cmdTable[index]; current; current = current->next) { + if (stricmp(name, current->name) == 0) { + displayCommand(current->c); + } + } + if (debug > 1) { + alog("debug: done displaying command %s", name); + } + return 0; } /** @@ -133,14 +133,14 @@ static int displayCommandFromHash(CommandHash * cmdTable[], const char *name) */ static int displayMessage(Message * m) { - Message *msg = NULL; - int i = 0; - alog("Displaying message list for %s", m->name); - for (msg = m; msg; msg = msg->next) { - alog("%d: 0x%p", ++i, (void *) msg); - } - alog("end"); - return 0; + Message *msg = NULL; + int i = 0; + alog("Displaying message list for %s", m->name); + for (msg = m; msg; msg = msg->next) { + alog("%d: 0x%p", ++i, (void *) msg); + } + alog("end"); + return 0; } /** @@ -151,21 +151,21 @@ static int displayMessage(Message * m) */ static int displayMessageFromHash(const char *name) { - MessageHash *current = NULL; - int index = 0; - index = CMD_HASH(name); - if (debug > 1) { - alog("debug: trying to display message %s", name); - } - for (current = IRCD[index]; current; current = current->next) { - if (stricmp(name, current->name) == 0) { - displayMessage(current->m); - } - } - if (debug > 1) { - alog("debug: done displaying message %s", name); - } - return 0; + MessageHash *current = NULL; + int index = 0; + index = CMD_HASH(name); + if (debug > 1) { + alog("debug: trying to display message %s", name); + } + for (current = IRCD[index]; current; current = current->next) { + if (stricmp(name, current->name) == 0) { + displayMessage(current->m); + } + } + if (debug > 1) { + alog("debug: done displaying message %s", name); + } + return 0; } /************************************************/ @@ -174,14 +174,14 @@ static int displayMessageFromHash(const char *name) * **/ int encryption_module_init(void) { - int ret = 0; + int ret = 0; - alog("Loading Encryption Module: [%s]", EncModule); - ret = ModuleManager::LoadModule(EncModule, NULL); + alog("Loading Encryption Module: [%s]", EncModule); + ret = ModuleManager::LoadModule(EncModule, NULL); if (ret == MOD_ERR_OK) findModule(EncModule)->SetType(ENCRYPTION); - mod_current_module = NULL; - return ret; + mod_current_module = NULL; + return ret; } /** @@ -189,10 +189,10 @@ int encryption_module_init(void) { **/ int protocol_module_init(void) { - int ret = 0; + int ret = 0; - alog("Loading IRCD Protocol Module: [%s]", IRCDModule); - ret = ModuleManager::LoadModule(IRCDModule, NULL); + alog("Loading IRCD Protocol Module: [%s]", IRCDModule); + ret = ModuleManager::LoadModule(IRCDModule, NULL); if (ret == MOD_ERR_OK) { @@ -207,14 +207,14 @@ int protocol_module_init(void) } /* We can assume the ircd supports TS6 here */ - if (UseTS6 && !Numeric) { - alog("UseTS6 requires the setting of Numeric to be enabled."); - ret = -1; - } + if (UseTS6 && !Numeric) { + alog("UseTS6 requires the setting of Numeric to be enabled."); + ret = -1; + } } mod_current_module = NULL; - return ret; + return ret; } /** @@ -247,33 +247,33 @@ void modules_unload_all(bool fini, bool unload_proto) next = mh->next; if (unload_proto || (mh->m->type != PROTOCOL)) { mod_current_module = mh->m; - mod_current_module_name = mh->m->name.c_str(); - mod_current_module_name = NULL; + mod_current_module_name = mh->m->name.c_str(); + mod_current_module_name = NULL; - delete mh->m; - } - mh = next; + delete mh->m; + } + mh = next; } } } void Module::InsertLanguage(int langNumber, int ac, const char **av) { - int i; + int i; if (debug) alog("debug: %s Adding %d texts for language %d", this->name.c_str(), ac, langNumber); - if (this->lang[langNumber].argc > 0) { - moduleDeleteLanguage(langNumber); - } + if (this->lang[langNumber].argc > 0) { + moduleDeleteLanguage(langNumber); + } - this->lang[langNumber].argc = ac; - this->lang[langNumber].argv = - (char **)malloc(sizeof(char *) * ac); - for (i = 0; i < ac; i++) { - this->lang[langNumber].argv[i] = sstrdup(av[i]); - } + this->lang[langNumber].argc = ac; + this->lang[langNumber].argv = + (char **)malloc(sizeof(char *) * ac); + for (i = 0; i < ac; i++) { + this->lang[langNumber].argv[i] = sstrdup(av[i]); + } } /** @@ -283,19 +283,19 @@ void Module::InsertLanguage(int langNumber, int ac, const char **av) */ Module *findModule(const char *name) { - int idx; - ModuleHash *current = NULL; - if (!name) { - return NULL; - } - idx = CMD_HASH(name); - - for (current = MODULE_HASH[idx]; current; current = current->next) { - if (stricmp(name, current->name) == 0) { - return current->m; - } - } - return NULL; + int idx; + ModuleHash *current = NULL; + if (!name) { + return NULL; + } + idx = CMD_HASH(name); + + for (current = MODULE_HASH[idx]; current; current = current->next) { + if (stricmp(name, current->name) == 0) { + return current->m; + } + } + return NULL; } @@ -315,39 +315,39 @@ Module *findModule(const char *name) * @return a "ready to use" Command struct will be returned */ Command *createCommand(const char *name, int (*func) (User * u), - int (*has_priv) (User * u), int help_all, - int help_reg, int help_oper, int help_admin, - int help_root) + int (*has_priv) (User * u), int help_all, + int help_reg, int help_oper, int help_admin, + int help_root) { - Command *c; - if (!name || !*name) { - return NULL; - } - - if ((c = (Command *)malloc(sizeof(Command))) == NULL) { - fatal("Out of memory!"); - } - c->name = sstrdup(name); - c->routine = func; - c->has_priv = has_priv; - c->helpmsg_all = help_all; - c->helpmsg_reg = help_reg; - c->helpmsg_oper = help_oper; - c->helpmsg_admin = help_admin; - c->helpmsg_root = help_root; - c->help_param1 = NULL; - c->help_param2 = NULL; - c->help_param3 = NULL; - c->help_param4 = NULL; - c->next = NULL; - c->mod_name = NULL; - c->service = NULL; - c->all_help = NULL; - c->regular_help = NULL; - c->oper_help = NULL; - c->admin_help = NULL; - c->root_help = NULL; - return c; + Command *c; + if (!name || !*name) { + return NULL; + } + + if ((c = (Command *)malloc(sizeof(Command))) == NULL) { + fatal("Out of memory!"); + } + c->name = sstrdup(name); + c->routine = func; + c->has_priv = has_priv; + c->helpmsg_all = help_all; + c->helpmsg_reg = help_reg; + c->helpmsg_oper = help_oper; + c->helpmsg_admin = help_admin; + c->helpmsg_root = help_root; + c->help_param1 = NULL; + c->help_param2 = NULL; + c->help_param3 = NULL; + c->help_param4 = NULL; + c->next = NULL; + c->mod_name = NULL; + c->service = NULL; + c->all_help = NULL; + c->regular_help = NULL; + c->oper_help = NULL; + c->admin_help = NULL; + c->root_help = NULL; + return c; } /** @@ -357,43 +357,43 @@ Command *createCommand(const char *name, int (*func) (User * u), */ int destroyCommand(Command * c) { - if (!c) { - return MOD_ERR_PARAMS; - } - if (c->core == 1) { - return MOD_ERR_UNKNOWN; - } - if (c->name) { - free(c->name); - } - c->routine = NULL; - c->has_priv = NULL; - c->helpmsg_all = -1; - c->helpmsg_reg = -1; - c->helpmsg_oper = -1; - c->helpmsg_admin = -1; - c->helpmsg_root = -1; - if (c->help_param1) { - free(c->help_param1); - } - if (c->help_param2) { - free(c->help_param2); - } - if (c->help_param3) { - free(c->help_param3); - } - if (c->help_param4) { - free(c->help_param4); - } - if (c->mod_name) { - free(c->mod_name); - } - if (c->service) { - free(c->service); - } - c->next = NULL; - free(c); - return MOD_ERR_OK; + if (!c) { + return MOD_ERR_PARAMS; + } + if (c->core == 1) { + return MOD_ERR_UNKNOWN; + } + if (c->name) { + free(c->name); + } + c->routine = NULL; + c->has_priv = NULL; + c->helpmsg_all = -1; + c->helpmsg_reg = -1; + c->helpmsg_oper = -1; + c->helpmsg_admin = -1; + c->helpmsg_root = -1; + if (c->help_param1) { + free(c->help_param1); + } + if (c->help_param2) { + free(c->help_param2); + } + if (c->help_param3) { + free(c->help_param3); + } + if (c->help_param4) { + free(c->help_param4); + } + if (c->mod_name) { + free(c->mod_name); + } + if (c->service) { + free(c->service); + } + c->next = NULL; + free(c); + return MOD_ERR_OK; } /** Add a command to a command table. Only for internal use. @@ -407,135 +407,135 @@ int destroyCommand(Command * c) */ static int internal_addCommand(CommandHash * cmdTable[], Command * c, int pos) { - /* We can assume both param's have been checked by this point.. */ - int index = 0; - CommandHash *current = NULL; - CommandHash *newHash = NULL; - CommandHash *lastHash = NULL; - Command *tail = NULL; - - if (!cmdTable || !c || (pos < 0 || pos > 2)) { - return MOD_ERR_PARAMS; - } - - if (mod_current_module_name && !c->mod_name) - return MOD_ERR_NO_MOD_NAME; - - index = CMD_HASH(c->name); - - for (current = cmdTable[index]; current; current = current->next) { - if ((c->service) && (current->c) && (current->c->service) - && (!strcmp(c->service, current->c->service) == 0)) { - continue; - } - if ((stricmp(c->name, current->name) == 0)) { /* the cmd exist's we are a addHead */ - if (pos == 1) { - c->next = current->c; - current->c = c; - if (debug) - alog("debug: existing cmd: (0x%p), new cmd (0x%p)", - (void *) c->next, (void *) c); - return MOD_ERR_OK; - } else if (pos == 2) { - - tail = current->c; - while (tail->next) - tail = tail->next; - if (debug) - alog("debug: existing cmd: (0x%p), new cmd (0x%p)", - (void *) tail, (void *) c); - tail->next = c; - c->next = NULL; - - return MOD_ERR_OK; - } else - return MOD_ERR_EXISTS; - } - lastHash = current; - } - - if ((newHash = (CommandHash *)malloc(sizeof(CommandHash))) == NULL) { - fatal("Out of memory"); - } - newHash->next = NULL; - newHash->name = sstrdup(c->name); - newHash->c = c; - - if (lastHash == NULL) - cmdTable[index] = newHash; - else - lastHash->next = newHash; - - return MOD_ERR_OK; + /* We can assume both param's have been checked by this point.. */ + int index = 0; + CommandHash *current = NULL; + CommandHash *newHash = NULL; + CommandHash *lastHash = NULL; + Command *tail = NULL; + + if (!cmdTable || !c || (pos < 0 || pos > 2)) { + return MOD_ERR_PARAMS; + } + + if (mod_current_module_name && !c->mod_name) + return MOD_ERR_NO_MOD_NAME; + + index = CMD_HASH(c->name); + + for (current = cmdTable[index]; current; current = current->next) { + if ((c->service) && (current->c) && (current->c->service) + && (!strcmp(c->service, current->c->service) == 0)) { + continue; + } + if ((stricmp(c->name, current->name) == 0)) { /* the cmd exist's we are a addHead */ + if (pos == 1) { + c->next = current->c; + current->c = c; + if (debug) + alog("debug: existing cmd: (0x%p), new cmd (0x%p)", + (void *) c->next, (void *) c); + return MOD_ERR_OK; + } else if (pos == 2) { + + tail = current->c; + while (tail->next) + tail = tail->next; + if (debug) + alog("debug: existing cmd: (0x%p), new cmd (0x%p)", + (void *) tail, (void *) c); + tail->next = c; + c->next = NULL; + + return MOD_ERR_OK; + } else + return MOD_ERR_EXISTS; + } + lastHash = current; + } + + if ((newHash = (CommandHash *)malloc(sizeof(CommandHash))) == NULL) { + fatal("Out of memory"); + } + newHash->next = NULL; + newHash->name = sstrdup(c->name); + newHash->c = c; + + if (lastHash == NULL) + cmdTable[index] = newHash; + else + lastHash->next = newHash; + + return MOD_ERR_OK; } int Module::AddCommand(CommandHash * cmdTable[], Command * c, int pos) { - int status; - - if (!cmdTable || !c) { - return MOD_ERR_PARAMS; - } - c->core = 0; - if (!c->mod_name) { - c->mod_name = sstrdup(this->name.c_str()); - } - - - if (cmdTable == HOSTSERV) { - if (s_HostServ) { - c->service = sstrdup(s_HostServ); - } else { - return MOD_ERR_NOSERVICE; - } - } else if (cmdTable == BOTSERV) { - if (s_BotServ) { - c->service = sstrdup(s_BotServ); - } else { - return MOD_ERR_NOSERVICE; - } - } else if (cmdTable == MEMOSERV) { - if (s_MemoServ) { - c->service = sstrdup(s_MemoServ); - } else { - return MOD_ERR_NOSERVICE; - } - } else if (cmdTable == CHANSERV) { - if (s_ChanServ) { - c->service = sstrdup(s_ChanServ); - } else { - return MOD_ERR_NOSERVICE; - } - } else if (cmdTable == NICKSERV) { - if (s_NickServ) { - c->service = sstrdup(s_NickServ); - } else { - return MOD_ERR_NOSERVICE; - } - } else if (cmdTable == HELPSERV) { - if (s_HelpServ) { - c->service = sstrdup(s_HelpServ); - } else { - return MOD_ERR_NOSERVICE; - } - } else if (cmdTable == OPERSERV) { - if (s_OperServ) { - c->service = sstrdup(s_OperServ); - } else { - return MOD_ERR_NOSERVICE; - } - } else - c->service = sstrdup("Unknown"); - - if (debug >= 2) - displayCommandFromHash(cmdTable, c->name); - status = internal_addCommand(cmdTable, c, pos); - if (debug >= 2) - displayCommandFromHash(cmdTable, c->name); - if (status != MOD_ERR_OK) { - alog("ERROR! [%d]", status); - } - return status; + int status; + + if (!cmdTable || !c) { + return MOD_ERR_PARAMS; + } + c->core = 0; + if (!c->mod_name) { + c->mod_name = sstrdup(this->name.c_str()); + } + + + if (cmdTable == HOSTSERV) { + if (s_HostServ) { + c->service = sstrdup(s_HostServ); + } else { + return MOD_ERR_NOSERVICE; + } + } else if (cmdTable == BOTSERV) { + if (s_BotServ) { + c->service = sstrdup(s_BotServ); + } else { + return MOD_ERR_NOSERVICE; + } + } else if (cmdTable == MEMOSERV) { + if (s_MemoServ) { + c->service = sstrdup(s_MemoServ); + } else { + return MOD_ERR_NOSERVICE; + } + } else if (cmdTable == CHANSERV) { + if (s_ChanServ) { + c->service = sstrdup(s_ChanServ); + } else { + return MOD_ERR_NOSERVICE; + } + } else if (cmdTable == NICKSERV) { + if (s_NickServ) { + c->service = sstrdup(s_NickServ); + } else { + return MOD_ERR_NOSERVICE; + } + } else if (cmdTable == HELPSERV) { + if (s_HelpServ) { + c->service = sstrdup(s_HelpServ); + } else { + return MOD_ERR_NOSERVICE; + } + } else if (cmdTable == OPERSERV) { + if (s_OperServ) { + c->service = sstrdup(s_OperServ); + } else { + return MOD_ERR_NOSERVICE; + } + } else + c->service = sstrdup("Unknown"); + + if (debug >= 2) + displayCommandFromHash(cmdTable, c->name); + status = internal_addCommand(cmdTable, c, pos); + if (debug >= 2) + displayCommandFromHash(cmdTable, c->name); + if (status != MOD_ERR_OK) { + alog("ERROR! [%d]", status); + } + return status; } @@ -547,65 +547,65 @@ int Module::AddCommand(CommandHash * cmdTable[], Command * c, int pos) */ static int internal_delCommand(CommandHash * cmdTable[], Command * c, const char *mod_name) { - int index = 0; - CommandHash *current = NULL; - CommandHash *lastHash = NULL; - Command *tail = NULL, *last = NULL; - - if (!c || !cmdTable) { - return MOD_ERR_PARAMS; - } - - index = CMD_HASH(c->name); - for (current = cmdTable[index]; current; current = current->next) { - if (stricmp(c->name, current->name) == 0) { - if (!lastHash) { - tail = current->c; - if (tail->next) { - while (tail) { - if (mod_name && tail->mod_name - && (stricmp(mod_name, tail->mod_name) == 0)) { - if (last) { - last->next = tail->next; - } else { - current->c = tail->next; - } - return MOD_ERR_OK; - } - last = tail; - tail = tail->next; - } - } else { - cmdTable[index] = current->next; - free(current->name); - return MOD_ERR_OK; - } - } else { - tail = current->c; - if (tail->next) { - while (tail) { - if (mod_name && tail->mod_name - && (stricmp(mod_name, tail->mod_name) == 0)) { - if (last) { - last->next = tail->next; - } else { - current->c = tail->next; - } - return MOD_ERR_OK; - } - last = tail; - tail = tail->next; - } - } else { - lastHash->next = current->next; - free(current->name); - return MOD_ERR_OK; - } - } - } - lastHash = current; - } - return MOD_ERR_NOEXIST; + int index = 0; + CommandHash *current = NULL; + CommandHash *lastHash = NULL; + Command *tail = NULL, *last = NULL; + + if (!c || !cmdTable) { + return MOD_ERR_PARAMS; + } + + index = CMD_HASH(c->name); + for (current = cmdTable[index]; current; current = current->next) { + if (stricmp(c->name, current->name) == 0) { + if (!lastHash) { + tail = current->c; + if (tail->next) { + while (tail) { + if (mod_name && tail->mod_name + && (stricmp(mod_name, tail->mod_name) == 0)) { + if (last) { + last->next = tail->next; + } else { + current->c = tail->next; + } + return MOD_ERR_OK; + } + last = tail; + tail = tail->next; + } + } else { + cmdTable[index] = current->next; + free(current->name); + return MOD_ERR_OK; + } + } else { + tail = current->c; + if (tail->next) { + while (tail) { + if (mod_name && tail->mod_name + && (stricmp(mod_name, tail->mod_name) == 0)) { + if (last) { + last->next = tail->next; + } else { + current->c = tail->next; + } + return MOD_ERR_OK; + } + last = tail; + tail = tail->next; + } + } else { + lastHash->next = current->next; + free(current->name); + return MOD_ERR_OK; + } + } + } + lastHash = current; + } + return MOD_ERR_NOEXIST; } /** @@ -616,29 +616,29 @@ static int internal_delCommand(CommandHash * cmdTable[], Command * c, const char */ int Module::DelCommand(CommandHash * cmdTable[], const char *dname) { - Command *c = NULL; - Command *cmd = NULL; - int status = 0; - - c = findCommand(cmdTable, dname); - if (!c) { - return MOD_ERR_NOEXIST; - } - - - for (cmd = c; cmd; cmd = cmd->next) { - if (cmd->mod_name - && cmd->mod_name == this->name) { - if (debug >= 2) { - displayCommandFromHash(cmdTable, dname); - } - status = internal_delCommand(cmdTable, cmd, this->name.c_str()); - if (debug >= 2) { - displayCommandFromHash(cmdTable, dname); - } - } - } - return status; + Command *c = NULL; + Command *cmd = NULL; + int status = 0; + + c = findCommand(cmdTable, dname); + if (!c) { + return MOD_ERR_NOEXIST; + } + + + for (cmd = c; cmd; cmd = cmd->next) { + if (cmd->mod_name + && cmd->mod_name == this->name) { + if (debug >= 2) { + displayCommandFromHash(cmdTable, dname); + } + status = internal_delCommand(cmdTable, cmd, this->name.c_str()); + if (debug >= 2) { + displayCommandFromHash(cmdTable, dname); + } + } + } + return status; } /** @@ -649,20 +649,20 @@ int Module::DelCommand(CommandHash * cmdTable[], const char *dname) */ Command *findCommand(CommandHash * cmdTable[], const char *name) { - int idx; - CommandHash *current = NULL; - if (!cmdTable || !name) { - return NULL; - } - - idx = CMD_HASH(name); - - for (current = cmdTable[idx]; current; current = current->next) { - if (stricmp(name, current->name) == 0) { - return current->c; - } - } - return NULL; + int idx; + CommandHash *current = NULL; + if (!cmdTable || !name) { + return NULL; + } + + idx = CMD_HASH(name); + + for (current = cmdTable[idx]; current; current = current->next) { + if (stricmp(name, current->name) == 0) { + return current->c; + } + } + return NULL; } /******************************************************************************* @@ -676,20 +676,20 @@ Command *findCommand(CommandHash * cmdTable[], const char *name) * @return a new Message object **/ Message *createMessage(const char *name, - int (*func) (const char *source, int ac, const char **av)) + int (*func) (const char *source, int ac, const char **av)) { - Message *m = NULL; - if (!name || !func) { - return NULL; - } - if ((m = (Message *)malloc(sizeof(Message))) == NULL) { - fatal("Out of memory!"); - } - m->name = sstrdup(name); - m->func = func; - m->mod_name = NULL; - m->next = NULL; - return m; + Message *m = NULL; + if (!name || !func) { + return NULL; + } + if ((m = (Message *)malloc(sizeof(Message))) == NULL) { + fatal("Out of memory!"); + } + m->name = sstrdup(name); + m->func = func; + m->mod_name = NULL; + m->next = NULL; + return m; } /** @@ -701,19 +701,19 @@ Message *createMessage(const char *name, **/ Message *findMessage(MessageHash * msgTable[], const char *name) { - int idx; - MessageHash *current = NULL; - if (!msgTable || !name) { - return NULL; - } - idx = CMD_HASH(name); - - for (current = msgTable[idx]; current; current = current->next) { + int idx; + MessageHash *current = NULL; + if (!msgTable || !name) { + return NULL; + } + idx = CMD_HASH(name); + + for (current = msgTable[idx]; current; current = current->next) { if (stricmp(name, current->name) == 0) { return current->m; } - } - return NULL; + } + return NULL; } /** @@ -726,58 +726,58 @@ Message *findMessage(MessageHash * msgTable[], const char *name) int addMessage(MessageHash * msgTable[], Message * m, int pos) { - /* We can assume both param's have been checked by this point.. */ - int index = 0; - MessageHash *current = NULL; - MessageHash *newHash = NULL; - MessageHash *lastHash = NULL; - Message *tail = NULL; - int match = 0; - - if (!msgTable || !m || (pos < 0 || pos > 2)) { - return MOD_ERR_PARAMS; - } - - index = CMD_HASH(m->name); - - for (current = msgTable[index]; current; current = current->next) { - match = stricmp(m->name, current->name); - if (match == 0) { /* the msg exist's we are a addHead */ - if (pos == 1) { - m->next = current->m; - current->m = m; - if (debug) - alog("debug: existing msg: (0x%p), new msg (0x%p)", - (void *) m->next, (void *) m); - return MOD_ERR_OK; - } else if (pos == 2) { - tail = current->m; - while (tail->next) - tail = tail->next; - if (debug) - alog("debug: existing msg: (0x%p), new msg (0x%p)", - (void *) tail, (void *) m); - tail->next = m; - m->next = NULL; - return MOD_ERR_OK; - } else - return MOD_ERR_EXISTS; - } - lastHash = current; - } - - if ((newHash = (MessageHash *)malloc(sizeof(MessageHash))) == NULL) { - fatal("Out of memory"); - } - newHash->next = NULL; - newHash->name = sstrdup(m->name); - newHash->m = m; - - if (lastHash == NULL) - msgTable[index] = newHash; - else - lastHash->next = newHash; - return MOD_ERR_OK; + /* We can assume both param's have been checked by this point.. */ + int index = 0; + MessageHash *current = NULL; + MessageHash *newHash = NULL; + MessageHash *lastHash = NULL; + Message *tail = NULL; + int match = 0; + + if (!msgTable || !m || (pos < 0 || pos > 2)) { + return MOD_ERR_PARAMS; + } + + index = CMD_HASH(m->name); + + for (current = msgTable[index]; current; current = current->next) { + match = stricmp(m->name, current->name); + if (match == 0) { /* the msg exist's we are a addHead */ + if (pos == 1) { + m->next = current->m; + current->m = m; + if (debug) + alog("debug: existing msg: (0x%p), new msg (0x%p)", + (void *) m->next, (void *) m); + return MOD_ERR_OK; + } else if (pos == 2) { + tail = current->m; + while (tail->next) + tail = tail->next; + if (debug) + alog("debug: existing msg: (0x%p), new msg (0x%p)", + (void *) tail, (void *) m); + tail->next = m; + m->next = NULL; + return MOD_ERR_OK; + } else + return MOD_ERR_EXISTS; + } + lastHash = current; + } + + if ((newHash = (MessageHash *)malloc(sizeof(MessageHash))) == NULL) { + fatal("Out of memory"); + } + newHash->next = NULL; + newHash->name = sstrdup(m->name); + newHash->m = m; + + if (lastHash == NULL) + msgTable[index] = newHash; + else + lastHash->next = newHash; + return MOD_ERR_OK; } /** @@ -788,11 +788,11 @@ int addMessage(MessageHash * msgTable[], Message * m, int pos) **/ int addCoreMessage(MessageHash * msgTable[], Message * m) { - if (!msgTable || !m) { - return MOD_ERR_PARAMS; - } - m->core = 1; - return addMessage(msgTable, m, 0); + if (!msgTable || !m) { + return MOD_ERR_PARAMS; + } + m->core = 1; + return addMessage(msgTable, m, 0); } /** @@ -803,30 +803,30 @@ int addCoreMessage(MessageHash * msgTable[], Message * m) **/ int moduleAddMessage(Message * m, int pos) { - int status; - - if (!m) { - return MOD_ERR_PARAMS; - } - - /* ok, this appears to be a module adding a message from outside of AnopeInit, try to look up its module struct for it */ - if ((mod_current_module_name) && (!mod_current_module)) { - mod_current_module = findModule(mod_current_module_name); - } - - if (!mod_current_module) { - return MOD_ERR_UNKNOWN; - } /* shouldnt happen */ - m->core = 0; - if (!m->mod_name) { - m->mod_name = sstrdup(mod_current_module->name.c_str()); - } - - status = addMessage(IRCD, m, pos); - if (debug) { - displayMessageFromHash(m->name); - } - return status; + int status; + + if (!m) { + return MOD_ERR_PARAMS; + } + + /* ok, this appears to be a module adding a message from outside of AnopeInit, try to look up its module struct for it */ + if ((mod_current_module_name) && (!mod_current_module)) { + mod_current_module = findModule(mod_current_module_name); + } + + if (!mod_current_module) { + return MOD_ERR_UNKNOWN; + } /* shouldnt happen */ + m->core = 0; + if (!m->mod_name) { + m->mod_name = sstrdup(mod_current_module->name.c_str()); + } + + status = addMessage(IRCD, m, pos); + if (debug) { + displayMessageFromHash(m->name); + } + return status; } /** @@ -836,22 +836,22 @@ int moduleAddMessage(Message * m, int pos) **/ int moduleDelMessage(const char *name) { - Message *m; - int status; - - if (!mod_current_module) { - return MOD_ERR_UNKNOWN; - } - m = findMessage(IRCD, name); - if (!m) { - return MOD_ERR_NOEXIST; - } - - status = delMessage(IRCD, m, mod_current_module->name.c_str()); - if (debug) { - displayMessageFromHash(m->name); - } - return status; + Message *m; + int status; + + if (!mod_current_module) { + return MOD_ERR_UNKNOWN; + } + m = findMessage(IRCD, name); + if (!m) { + return MOD_ERR_NOEXIST; + } + + status = delMessage(IRCD, m, mod_current_module->name.c_str()); + if (debug) { + displayMessageFromHash(m->name); + } + return status; } /** @@ -863,66 +863,66 @@ int moduleDelMessage(const char *name) **/ int delMessage(MessageHash * msgTable[], Message * m, const char *mod_name) { - int index = 0; - MessageHash *current = NULL; - MessageHash *lastHash = NULL; - Message *tail = NULL, *last = NULL; - - if (!m || !msgTable) { - return MOD_ERR_PARAMS; - } - - index = CMD_HASH(m->name); - - for (current = msgTable[index]; current; current = current->next) { - if (stricmp(m->name, current->name) == 0) { - if (!lastHash) { - tail = current->m; - if (tail->next) { - while (tail) { - if (mod_name && tail->mod_name - && (stricmp(mod_name, tail->mod_name) == 0)) { - if (last) { - last->next = tail->next; - } else { - current->m = tail->next; - } - return MOD_ERR_OK; - } - last = tail; - tail = tail->next; - } - } else { - msgTable[index] = current->next; - free(current->name); - return MOD_ERR_OK; - } - } else { - tail = current->m; - if (tail->next) { - while (tail) { - if (mod_name && tail->mod_name - && (stricmp(mod_name, tail->mod_name) == 0)) { - if (last) { - last->next = tail->next; - } else { - current->m = tail->next; - } - return MOD_ERR_OK; - } - last = tail; - tail = tail->next; - } - } else { - lastHash->next = current->next; - free(current->name); - return MOD_ERR_OK; - } - } - } - lastHash = current; - } - return MOD_ERR_NOEXIST; + int index = 0; + MessageHash *current = NULL; + MessageHash *lastHash = NULL; + Message *tail = NULL, *last = NULL; + + if (!m || !msgTable) { + return MOD_ERR_PARAMS; + } + + index = CMD_HASH(m->name); + + for (current = msgTable[index]; current; current = current->next) { + if (stricmp(m->name, current->name) == 0) { + if (!lastHash) { + tail = current->m; + if (tail->next) { + while (tail) { + if (mod_name && tail->mod_name + && (stricmp(mod_name, tail->mod_name) == 0)) { + if (last) { + last->next = tail->next; + } else { + current->m = tail->next; + } + return MOD_ERR_OK; + } + last = tail; + tail = tail->next; + } + } else { + msgTable[index] = current->next; + free(current->name); + return MOD_ERR_OK; + } + } else { + tail = current->m; + if (tail->next) { + while (tail) { + if (mod_name && tail->mod_name + && (stricmp(mod_name, tail->mod_name) == 0)) { + if (last) { + last->next = tail->next; + } else { + current->m = tail->next; + } + return MOD_ERR_OK; + } + last = tail; + tail = tail->next; + } + } else { + lastHash->next = current->next; + free(current->name); + return MOD_ERR_OK; + } + } + } + lastHash = current; + } + return MOD_ERR_NOEXIST; } /** @@ -932,18 +932,18 @@ int delMessage(MessageHash * msgTable[], Message * m, const char *mod_name) **/ int destroyMessage(Message * m) { - if (!m) { - return MOD_ERR_PARAMS; - } - if (m->name) { - free(m->name); - } - m->func = NULL; - if (m->mod_name) { - free(m->mod_name); - } - m->next = NULL; - return MOD_ERR_OK; + if (!m) { + return MOD_ERR_PARAMS; + } + if (m->name) { + free(m->name); + } + m->func = NULL; + if (m->mod_name) { + free(m->mod_name); + } + m->next = NULL; + return MOD_ERR_OK; } /******************************************************************************* @@ -961,54 +961,54 @@ int destroyMessage(Message * m) * @see moduleDelCallBack **/ int moduleAddCallback(const char *name, time_t when, - int (*func) (int argc, char *argv[]), int argc, - char **argv) + int (*func) (int argc, char *argv[]), int argc, + char **argv) { - ModuleCallBack *newcb, *tmp, *prev; - int i; - newcb = (ModuleCallBack *)malloc(sizeof(ModuleCallBack)); - if (!newcb) - return MOD_ERR_MEMORY; - - if (name) - newcb->name = sstrdup(name); - else - newcb->name = NULL; - newcb->when = when; - if (mod_current_module_name) { - newcb->owner_name = sstrdup(mod_current_module_name); - } else { - newcb->owner_name = NULL; - } - newcb->func = func; - newcb->argc = argc; - newcb->argv = (char **)malloc(sizeof(char *) * argc); - for (i = 0; i < argc; i++) { - newcb->argv[i] = sstrdup(argv[i]); - } - newcb->next = NULL; - - if (moduleCallBackHead == NULL) { - moduleCallBackHead = newcb; - } else { /* find place in list */ - tmp = moduleCallBackHead; - prev = tmp; - if (newcb->when < tmp->when) { - newcb->next = tmp; - moduleCallBackHead = newcb; - } else { - while (tmp && newcb->when >= tmp->when) { - prev = tmp; - tmp = tmp->next; - } - prev->next = newcb; - newcb->next = tmp; - } - } - if (debug) - alog("debug: added module CallBack: [%s] due to execute at %ld", - newcb->name ? newcb->name : "?", (long int) newcb->when); - return MOD_ERR_OK; + ModuleCallBack *newcb, *tmp, *prev; + int i; + newcb = (ModuleCallBack *)malloc(sizeof(ModuleCallBack)); + if (!newcb) + return MOD_ERR_MEMORY; + + if (name) + newcb->name = sstrdup(name); + else + newcb->name = NULL; + newcb->when = when; + if (mod_current_module_name) { + newcb->owner_name = sstrdup(mod_current_module_name); + } else { + newcb->owner_name = NULL; + } + newcb->func = func; + newcb->argc = argc; + newcb->argv = (char **)malloc(sizeof(char *) * argc); + for (i = 0; i < argc; i++) { + newcb->argv[i] = sstrdup(argv[i]); + } + newcb->next = NULL; + + if (moduleCallBackHead == NULL) { + moduleCallBackHead = newcb; + } else { /* find place in list */ + tmp = moduleCallBackHead; + prev = tmp; + if (newcb->when < tmp->when) { + newcb->next = tmp; + moduleCallBackHead = newcb; + } else { + while (tmp && newcb->when >= tmp->when) { + prev = tmp; + tmp = tmp->next; + } + prev->next = newcb; + newcb->next = tmp; + } + } + if (debug) + alog("debug: added module CallBack: [%s] due to execute at %ld", + newcb->name ? newcb->name : "?", (long int) newcb->when); + return MOD_ERR_OK; } /** @@ -1016,7 +1016,7 @@ int moduleAddCallback(const char *name, time_t when, **/ void moduleCallBackRun(void) { - ModuleCallBack *tmp; + ModuleCallBack *tmp; while ((tmp = moduleCallBackHead) && (tmp->when <= time(NULL))) { if (debug) @@ -1036,26 +1036,26 @@ void moduleCallBackRun(void) **/ void moduleCallBackDeleteEntry(ModuleCallBack * prev) { - ModuleCallBack *tmp = NULL; - int i; - if (prev == NULL) { - tmp = moduleCallBackHead; - moduleCallBackHead = tmp->next; - } else { - tmp = prev->next; - prev->next = tmp->next; - } - if (tmp->name) - free(tmp->name); - if (tmp->owner_name) - free(tmp->owner_name); - tmp->func = NULL; - for (i = 0; i < tmp->argc; i++) { - free(tmp->argv[i]); - } - tmp->argc = 0; - tmp->next = NULL; - free(tmp); + ModuleCallBack *tmp = NULL; + int i; + if (prev == NULL) { + tmp = moduleCallBackHead; + moduleCallBackHead = tmp->next; + } else { + tmp = prev->next; + prev->next = tmp->next; + } + if (tmp->name) + free(tmp->name); + if (tmp->owner_name) + free(tmp->owner_name); + tmp->func = NULL; + for (i = 0; i < tmp->argc; i++) { + free(tmp->argv[i]); + } + tmp->argc = 0; + tmp->next = NULL; + free(tmp); } /** @@ -1066,24 +1066,24 @@ void moduleCallBackDeleteEntry(ModuleCallBack * prev) **/ static ModuleCallBack *moduleCallBackFindEntry(const char *mod_name, bool * found) { - ModuleCallBack *prev = NULL, *current = NULL; - *found = false; - current = moduleCallBackHead; - while (current != NULL) { - if (current->owner_name - && (strcmp(mod_name, current->owner_name) == 0)) { - *found = true; - break; - } else { - prev = current; - current = current->next; - } - } - if (current == moduleCallBackHead) { - return NULL; - } else { - return prev; - } + ModuleCallBack *prev = NULL, *current = NULL; + *found = false; + current = moduleCallBackHead; + while (current != NULL) { + if (current->owner_name + && (strcmp(mod_name, current->owner_name) == 0)) { + *found = true; + break; + } else { + prev = current; + current = current->next; + } + } + if (current == moduleCallBackHead) { + return NULL; + } else { + return prev; + } } /** @@ -1092,38 +1092,38 @@ static ModuleCallBack *moduleCallBackFindEntry(const char *mod_name, bool * foun **/ void moduleDelCallback(char *name) { - ModuleCallBack *current = NULL; - ModuleCallBack *prev = NULL, *tmp = NULL; - int del = 0; - if (!mod_current_module_name) { - return; - } - if (!name) { - return; - } - current = moduleCallBackHead; - while (current) { - if ((current->owner_name) && (current->name)) { - if ((strcmp(mod_current_module_name, current->owner_name) == 0) - && (strcmp(current->name, name) == 0)) { - if (debug) { - alog("debug: removing CallBack %s for module %s", name, - mod_current_module_name); - } - tmp = current->next; /* get a pointer to the next record, as once we delete this record, we'll lose it :) */ - moduleCallBackDeleteEntry(prev); /* delete this record */ - del = 1; /* set the record deleted flag */ - } - } - if (del == 1) { /* if a record was deleted */ - current = tmp; /* use the value we stored in temp */ - tmp = NULL; /* clear it for next time */ - del = 0; /* reset the flag */ - } else { - prev = current; /* just carry on as normal */ - current = current->next; - } - } + ModuleCallBack *current = NULL; + ModuleCallBack *prev = NULL, *tmp = NULL; + int del = 0; + if (!mod_current_module_name) { + return; + } + if (!name) { + return; + } + current = moduleCallBackHead; + while (current) { + if ((current->owner_name) && (current->name)) { + if ((strcmp(mod_current_module_name, current->owner_name) == 0) + && (strcmp(current->name, name) == 0)) { + if (debug) { + alog("debug: removing CallBack %s for module %s", name, + mod_current_module_name); + } + tmp = current->next; /* get a pointer to the next record, as once we delete this record, we'll lose it :) */ + moduleCallBackDeleteEntry(prev); /* delete this record */ + del = 1; /* set the record deleted flag */ + } + } + if (del == 1) { /* if a record was deleted */ + current = tmp; /* use the value we stored in temp */ + tmp = NULL; /* clear it for next time */ + del = 0; /* reset the flag */ + } else { + prev = current; /* just carry on as normal */ + current = current->next; + } + } } /** @@ -1133,17 +1133,17 @@ void moduleDelCallback(char *name) **/ void moduleCallBackPrepForUnload(const char *mod_name) { - bool found = false; - ModuleCallBack *tmp = NULL; - - tmp = moduleCallBackFindEntry(mod_name, &found); - while (found) { - if (debug) { - alog("debug: removing CallBack for module %s", mod_name); - } - moduleCallBackDeleteEntry(tmp); - tmp = moduleCallBackFindEntry(mod_name, &found); - } + bool found = false; + ModuleCallBack *tmp = NULL; + + tmp = moduleCallBackFindEntry(mod_name, &found); + while (found) { + if (debug) { + alog("debug: removing CallBack for module %s", mod_name); + } + moduleCallBackDeleteEntry(tmp); + tmp = moduleCallBackFindEntry(mod_name, &found); + } } /** @@ -1153,14 +1153,14 @@ void moduleCallBackPrepForUnload(const char *mod_name) **/ char *moduleGetLastBuffer(void) { - char *tmp = NULL; - if (mod_current_buffer) { - tmp = strchr(mod_current_buffer, ' '); - if (tmp) { - tmp++; - } - } - return tmp; + char *tmp = NULL; + if (mod_current_buffer) { + tmp = strchr(mod_current_buffer, ' '); + if (tmp) { + tmp++; + } + } + return tmp; } /******************************************************************************* @@ -1173,11 +1173,11 @@ char *moduleGetLastBuffer(void) **/ int moduleAddRootHelp(Command * c, int (*func) (User * u)) { - if (c) { - c->root_help = func; - return MOD_STOP; - } - return MOD_CONT; + if (c) { + c->root_help = func; + return MOD_STOP; + } + return MOD_CONT; } /** @@ -1187,11 +1187,11 @@ int moduleAddRootHelp(Command * c, int (*func) (User * u)) **/ int moduleAddAdminHelp(Command * c, int (*func) (User * u)) { - if (c) { - c->admin_help = func; - return MOD_STOP; - } - return MOD_CONT; + if (c) { + c->admin_help = func; + return MOD_STOP; + } + return MOD_CONT; } /** @@ -1201,11 +1201,11 @@ int moduleAddAdminHelp(Command * c, int (*func) (User * u)) **/ int moduleAddOperHelp(Command * c, int (*func) (User * u)) { - if (c) { - c->oper_help = func; - return MOD_STOP; - } - return MOD_CONT; + if (c) { + c->oper_help = func; + return MOD_STOP; + } + return MOD_CONT; } /** @@ -1215,11 +1215,11 @@ int moduleAddOperHelp(Command * c, int (*func) (User * u)) **/ int moduleAddRegHelp(Command * c, int (*func) (User * u)) { - if (c) { - c->regular_help = func; - return MOD_STOP; - } - return MOD_CONT; + if (c) { + c->regular_help = func; + return MOD_STOP; + } + return MOD_CONT; } /** @@ -1229,11 +1229,11 @@ int moduleAddRegHelp(Command * c, int (*func) (User * u)) **/ int moduleAddHelp(Command * c, int (*func) (User * u)) { - if (c) { - c->all_help = func; - return MOD_STOP; - } - return MOD_CONT; + if (c) { + c->all_help = func; + return MOD_STOP; + } + return MOD_CONT; } /** @@ -1243,9 +1243,9 @@ int moduleAddHelp(Command * c, int (*func) (User * u)) **/ void moduleSetNickHelp(void (*func) (User * u)) { - if (mod_current_module) { - mod_current_module->nickHelp = func; - } + if (mod_current_module) { + mod_current_module->nickHelp = func; + } } /** @@ -1255,9 +1255,9 @@ void moduleSetNickHelp(void (*func) (User * u)) **/ void moduleSetChanHelp(void (*func) (User * u)) { - if (mod_current_module) { - mod_current_module->chanHelp = func; - } + if (mod_current_module) { + mod_current_module->chanHelp = func; + } } /** @@ -1267,9 +1267,9 @@ void moduleSetChanHelp(void (*func) (User * u)) **/ void moduleSetMemoHelp(void (*func) (User * u)) { - if (mod_current_module) { - mod_current_module->memoHelp = func; - } + if (mod_current_module) { + mod_current_module->memoHelp = func; + } } /** @@ -1279,9 +1279,9 @@ void moduleSetMemoHelp(void (*func) (User * u)) **/ void moduleSetBotHelp(void (*func) (User * u)) { - if (mod_current_module) { - mod_current_module->botHelp = func; - } + if (mod_current_module) { + mod_current_module->botHelp = func; + } } /** @@ -1291,9 +1291,9 @@ void moduleSetBotHelp(void (*func) (User * u)) **/ void moduleSetOperHelp(void (*func) (User * u)) { - if (mod_current_module) { - mod_current_module->operHelp = func; - } + if (mod_current_module) { + mod_current_module->operHelp = func; + } } /** @@ -1303,9 +1303,9 @@ void moduleSetOperHelp(void (*func) (User * u)) **/ void moduleSetHostHelp(void (*func) (User * u)) { - if (mod_current_module) { - mod_current_module->hostHelp = func; - } + if (mod_current_module) { + mod_current_module->hostHelp = func; + } } /** @@ -1315,9 +1315,9 @@ void moduleSetHostHelp(void (*func) (User * u)) **/ void moduleSetHelpHelp(void (*func) (User * u)) { - if (mod_current_module) { - mod_current_module->helpHelp = func; - } + if (mod_current_module) { + mod_current_module->helpHelp = func; + } } /** @@ -1327,33 +1327,33 @@ void moduleSetHelpHelp(void (*func) (User * u)) **/ void moduleDisplayHelp(int service, User * u) { - int idx; - ModuleHash *current = NULL; + int idx; + ModuleHash *current = NULL; Module *calling_module = mod_current_module; const char *calling_module_name = mod_current_module_name; - for (idx = 0; idx != MAX_CMD_HASH; idx++) { - for (current = MODULE_HASH[idx]; current; current = current->next) { + for (idx = 0; idx != MAX_CMD_HASH; idx++) { + for (current = MODULE_HASH[idx]; current; current = current->next) { mod_current_module_name = current->name; mod_current_module = current->m; - if ((service == 1) && current->m->nickHelp) { - current->m->nickHelp(u); - } else if ((service == 2) && current->m->chanHelp) { - current->m->chanHelp(u); - } else if ((service == 3) && current->m->memoHelp) { - current->m->memoHelp(u); - } else if ((service == 4) && current->m->botHelp) { - current->m->botHelp(u); - } else if ((service == 5) && current->m->operHelp) { - current->m->operHelp(u); - } else if ((service == 6) && current->m->hostHelp) { - current->m->hostHelp(u); - } else if ((service == 7) && current->m->helpHelp) { - current->m->helpHelp(u); - } - } - } + if ((service == 1) && current->m->nickHelp) { + current->m->nickHelp(u); + } else if ((service == 2) && current->m->chanHelp) { + current->m->chanHelp(u); + } else if ((service == 3) && current->m->memoHelp) { + current->m->memoHelp(u); + } else if ((service == 4) && current->m->botHelp) { + current->m->botHelp(u); + } else if ((service == 5) && current->m->operHelp) { + current->m->operHelp(u); + } else if ((service == 6) && current->m->hostHelp) { + current->m->hostHelp(u); + } else if ((service == 7) && current->m->helpHelp) { + current->m->helpHelp(u); + } + } + } mod_current_module = calling_module; mod_current_module_name = calling_module_name; @@ -1369,33 +1369,33 @@ void moduleDisplayHelp(int service, User * u) **/ int moduleAddData(ModuleData ** md, const char *key, char *value) { - ModuleData *newData = NULL; + ModuleData *newData = NULL; - if (mod_current_module_name == NULL) { - alog("moduleAddData() called with mod_current_module_name being NULL"); - if (debug) - do_backtrace(0); - } + if (mod_current_module_name == NULL) { + alog("moduleAddData() called with mod_current_module_name being NULL"); + if (debug) + do_backtrace(0); + } - if (!key || !value) { - alog("A module (%s) tried to use ModuleAddData() with one or more NULL arguments... returning", mod_current_module_name); - return MOD_ERR_PARAMS; - } + if (!key || !value) { + alog("A module (%s) tried to use ModuleAddData() with one or more NULL arguments... returning", mod_current_module_name); + return MOD_ERR_PARAMS; + } - moduleDelData(md, key); /* Remove any existing module data for this module with the same key */ + moduleDelData(md, key); /* Remove any existing module data for this module with the same key */ - newData = (ModuleData *)malloc(sizeof(ModuleData)); - if (!newData) { - return MOD_ERR_MEMORY; - } + newData = (ModuleData *)malloc(sizeof(ModuleData)); + if (!newData) { + return MOD_ERR_MEMORY; + } - newData->moduleName = sstrdup(mod_current_module_name); - newData->key = sstrdup(key); - newData->value = sstrdup(value); - newData->next = *md; - *md = newData; + newData->moduleName = sstrdup(mod_current_module_name); + newData->key = sstrdup(key); + newData->value = sstrdup(value); + newData->next = *md; + *md = newData; - return MOD_ERR_OK; + return MOD_ERR_OK; } /** @@ -1407,31 +1407,31 @@ int moduleAddData(ModuleData ** md, const char *key, char *value) **/ char *moduleGetData(ModuleData ** md, const char *key) { - /* See comment in moduleAddData... -GD */ - char *mod_name = sstrdup(mod_current_module_name); - ModuleData *current = *md; - - if (mod_current_module_name == NULL) { - alog("moduleGetData() called with mod_current_module_name being NULL"); - if (debug) - do_backtrace(0); - } - - if (debug) { - alog("debug: moduleGetData %p : key %s", (void *) md, key); - alog("debug: Current Module %s", mod_name); - } - - while (current) { - if ((stricmp(current->moduleName, mod_name) == 0) - && (stricmp(current->key, key) == 0)) { - free(mod_name); - return sstrdup(current->value); - } - current = current->next; - } - free(mod_name); - return NULL; + /* See comment in moduleAddData... -GD */ + char *mod_name = sstrdup(mod_current_module_name); + ModuleData *current = *md; + + if (mod_current_module_name == NULL) { + alog("moduleGetData() called with mod_current_module_name being NULL"); + if (debug) + do_backtrace(0); + } + + if (debug) { + alog("debug: moduleGetData %p : key %s", (void *) md, key); + alog("debug: Current Module %s", mod_name); + } + + while (current) { + if ((stricmp(current->moduleName, mod_name) == 0) + && (stricmp(current->key, key) == 0)) { + free(mod_name); + return sstrdup(current->value); + } + current = current->next; + } + free(mod_name); + return NULL; } /** @@ -1442,40 +1442,40 @@ char *moduleGetData(ModuleData ** md, const char *key) **/ void moduleDelData(ModuleData ** md, const char *key) { - /* See comment in moduleAddData... -GD */ - char *mod_name = sstrdup(mod_current_module_name); - ModuleData *current = *md; - ModuleData *prev = NULL; - ModuleData *next = NULL; - - if (mod_current_module_name == NULL) { - alog("moduleDelData() called with mod_current_module_name being NULL"); - if (debug) - do_backtrace(0); - } - - if (key) { - while (current) { - next = current->next; - if ((stricmp(current->moduleName, mod_name) == 0) - && (stricmp(current->key, key) == 0)) { - if (prev) { - prev->next = current->next; - } else { - *md = current->next; - } - free(current->moduleName); - free(current->key); - free(current->value); - current->next = NULL; - free(current); - } else { - prev = current; - } - current = next; - } - } - free(mod_name); + /* See comment in moduleAddData... -GD */ + char *mod_name = sstrdup(mod_current_module_name); + ModuleData *current = *md; + ModuleData *prev = NULL; + ModuleData *next = NULL; + + if (mod_current_module_name == NULL) { + alog("moduleDelData() called with mod_current_module_name being NULL"); + if (debug) + do_backtrace(0); + } + + if (key) { + while (current) { + next = current->next; + if ((stricmp(current->moduleName, mod_name) == 0) + && (stricmp(current->key, key) == 0)) { + if (prev) { + prev->next = current->next; + } else { + *md = current->next; + } + free(current->moduleName); + free(current->key); + free(current->value); + current->next = NULL; + free(current); + } else { + prev = current; + } + current = next; + } + } + free(mod_name); } /** @@ -1486,37 +1486,37 @@ void moduleDelData(ModuleData ** md, const char *key) **/ void moduleDelAllData(ModuleData ** md) { - /* See comment in moduleAddData... -GD */ - char *mod_name = sstrdup(mod_current_module_name); - ModuleData *current = *md; - ModuleData *prev = NULL; - ModuleData *next = NULL; - - if (mod_current_module_name == NULL) { - alog("moduleDelAllData() called with mod_current_module_name being NULL"); - if (debug) - do_backtrace(0); - } - - while (current) { - next = current->next; - if ((stricmp(current->moduleName, mod_name) == 0)) { - if (prev) { - prev->next = current->next; - } else { - *md = current->next; - } - free(current->moduleName); - free(current->key); - free(current->value); - current->next = NULL; - free(current); - } else { - prev = current; - } - current = next; - } - free(mod_name); + /* See comment in moduleAddData... -GD */ + char *mod_name = sstrdup(mod_current_module_name); + ModuleData *current = *md; + ModuleData *prev = NULL; + ModuleData *next = NULL; + + if (mod_current_module_name == NULL) { + alog("moduleDelAllData() called with mod_current_module_name being NULL"); + if (debug) + do_backtrace(0); + } + + while (current) { + next = current->next; + if ((stricmp(current->moduleName, mod_name) == 0)) { + if (prev) { + prev->next = current->next; + } else { + *md = current->next; + } + free(current->moduleName); + free(current->key); + free(current->value); + current->next = NULL; + free(current); + } else { + prev = current; + } + current = next; + } + free(mod_name); } /** @@ -1525,52 +1525,52 @@ void moduleDelAllData(ModuleData ** md) **/ void moduleDelAllDataMod(Module * m) { - bool freeme = false; - int i, j; - User *user; - NickAlias *na; - NickCore *nc; - ChannelInfo *ci; - - if (!mod_current_module_name) { - mod_current_module_name = sstrdup(m->name.c_str()); - freeme = true; - } - - for (i = 0; i < 1024; i++) { - /* Remove the users */ - for (user = userlist[i]; user; user = user->next) { - moduleDelAllData(&user->moduleData); - } - /* Remove the nick Cores */ - for (nc = nclists[i]; nc; nc = nc->next) { - moduleDelAllData(&nc->moduleData); - /* Remove any memo data for this nick core */ - for (j = 0; j < nc->memos.memocount; j++) { - moduleCleanStruct(&nc->memos.memos[j].moduleData); - } - } - /* Remove the nick Aliases */ - for (na = nalists[i]; na; na = na->next) { - moduleDelAllData(&na->moduleData); - } - } - - for (i = 0; i < 256; i++) { - /* Remove any chan info data */ - for (ci = chanlists[i]; ci; ci = ci->next) { - moduleDelAllData(&ci->moduleData); - /* Remove any memo data for this nick core */ - for (j = 0; j < ci->memos.memocount; j++) { - moduleCleanStruct(&ci->memos.memos[j].moduleData); - } - } - } - - if (freeme) { - free((void *)mod_current_module_name); - mod_current_module_name = NULL; - } + bool freeme = false; + int i, j; + User *user; + NickAlias *na; + NickCore *nc; + ChannelInfo *ci; + + if (!mod_current_module_name) { + mod_current_module_name = sstrdup(m->name.c_str()); + freeme = true; + } + + for (i = 0; i < 1024; i++) { + /* Remove the users */ + for (user = userlist[i]; user; user = user->next) { + moduleDelAllData(&user->moduleData); + } + /* Remove the nick Cores */ + for (nc = nclists[i]; nc; nc = nc->next) { + moduleDelAllData(&nc->moduleData); + /* Remove any memo data for this nick core */ + for (j = 0; j < nc->memos.memocount; j++) { + moduleCleanStruct(&nc->memos.memos[j].moduleData); + } + } + /* Remove the nick Aliases */ + for (na = nalists[i]; na; na = na->next) { + moduleDelAllData(&na->moduleData); + } + } + + for (i = 0; i < 256; i++) { + /* Remove any chan info data */ + for (ci = chanlists[i]; ci; ci = ci->next) { + moduleDelAllData(&ci->moduleData); + /* Remove any memo data for this nick core */ + for (j = 0; j < ci->memos.memocount; j++) { + moduleCleanStruct(&ci->memos.memos[j].moduleData); + } + } + } + + if (freeme) { + free((void *)mod_current_module_name); + mod_current_module_name = NULL; + } } /** @@ -1580,19 +1580,19 @@ void moduleDelAllDataMod(Module * m) **/ void moduleCleanStruct(ModuleData ** moduleData) { - ModuleData *current = *moduleData; - ModuleData *next = NULL; - - while (current) { - next = current->next; - free(current->moduleName); - free(current->key); - free(current->value); - current->next = NULL; - free(current); - current = next; - } - *moduleData = NULL; + ModuleData *current = *moduleData; + ModuleData *next = NULL; + + while (current) { + next = current->next; + free(current->moduleName); + free(current->key); + free(current->value); + current->next = NULL; + free(current); + current = next; + } + *moduleData = NULL; } /** @@ -1606,48 +1606,48 @@ void moduleCleanStruct(ModuleData ** moduleData) **/ bool moduleMinVersion(int major, int minor, int patch, int build) { - bool ret = false; - if (VERSION_MAJOR > major) { /* Def. new */ - ret = true; - } else if (VERSION_MAJOR == major) { /* Might be newer */ - if (minor == -1) { - return true; - } /* They dont care about minor */ - if (VERSION_MINOR > minor) { /* Def. newer */ - ret = true; - } else if (VERSION_MINOR == minor) { /* Might be newer */ - if (patch == -1) { - return true; - } /* They dont care about patch */ - if (VERSION_PATCH > patch) { - ret = true; - } else if (VERSION_PATCH == patch) { + bool ret = false; + if (VERSION_MAJOR > major) { /* Def. new */ + ret = true; + } else if (VERSION_MAJOR == major) { /* Might be newer */ + if (minor == -1) { + return true; + } /* They dont care about minor */ + if (VERSION_MINOR > minor) { /* Def. newer */ + ret = true; + } else if (VERSION_MINOR == minor) { /* Might be newer */ + if (patch == -1) { + return true; + } /* They dont care about patch */ + if (VERSION_PATCH > patch) { + ret = true; + } else if (VERSION_PATCH == patch) { #if 0 // XXX - if (build == -1) { - return true; - } /* They dont care about build */ - if (VERSION_BUILD >= build) { - ret = true; - } + if (build == -1) { + return true; + } /* They dont care about build */ + if (VERSION_BUILD >= build) { + ret = true; + } #endif - } - } - } - return ret; + } + } + } + return ret; } #ifdef _WIN32 const char *ano_moderr(void) { - static char errbuf[513]; - DWORD err = GetLastError(); - if (err == 0) - return NULL; - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err, 0, errbuf, 512, - NULL); - return errbuf; + static char errbuf[513]; + DWORD err = GetLastError(); + if (err == 0) + return NULL; + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err, 0, errbuf, 512, + NULL); + return errbuf; } #endif @@ -1655,39 +1655,39 @@ const char *ano_moderr(void) * Allow ircd protocol files to update the protect level info tables. **/ void updateProtectDetails(const char *level_info_protect_word, - const char *level_info_protectme_word, - const char *fant_protect_add, const char *fant_protect_del, - const char *level_protect_word, const char *protect_set_mode, - const char *protect_unset_mode) + const char *level_info_protectme_word, + const char *fant_protect_add, const char *fant_protect_del, + const char *level_protect_word, const char *protect_set_mode, + const char *protect_unset_mode) { - int i = 0; - CSModeUtil ptr; - LevelInfo l_ptr; - - ptr = csmodeutils[i]; - while (ptr.name) { - if (strcmp(ptr.name, "PROTECT") == 0) { - csmodeutils[i].bsname = sstrdup(fant_protect_add); - csmodeutils[i].mode = sstrdup(protect_set_mode); - } else if (strcmp(ptr.name, "DEPROTECT") == 0) { - csmodeutils[i].bsname = sstrdup(fant_protect_del); - csmodeutils[i].mode = sstrdup(protect_unset_mode); - } - ptr = csmodeutils[++i]; - } - - i = 0; - l_ptr = levelinfo[i]; - while (l_ptr.what != -1) { - if (l_ptr.what == CA_PROTECT) { - levelinfo[i].name = sstrdup(level_info_protect_word); - } else if (l_ptr.what == CA_PROTECTME) { - levelinfo[i].name = sstrdup(level_info_protectme_word); - } else if (l_ptr.what == CA_AUTOPROTECT) { - levelinfo[i].name = sstrdup(level_protect_word); - } - l_ptr = levelinfo[++i]; - } + int i = 0; + CSModeUtil ptr; + LevelInfo l_ptr; + + ptr = csmodeutils[i]; + while (ptr.name) { + if (strcmp(ptr.name, "PROTECT") == 0) { + csmodeutils[i].bsname = sstrdup(fant_protect_add); + csmodeutils[i].mode = sstrdup(protect_set_mode); + } else if (strcmp(ptr.name, "DEPROTECT") == 0) { + csmodeutils[i].bsname = sstrdup(fant_protect_del); + csmodeutils[i].mode = sstrdup(protect_unset_mode); + } + ptr = csmodeutils[++i]; + } + + i = 0; + l_ptr = levelinfo[i]; + while (l_ptr.what != -1) { + if (l_ptr.what == CA_PROTECT) { + levelinfo[i].name = sstrdup(level_info_protect_word); + } else if (l_ptr.what == CA_PROTECTME) { + levelinfo[i].name = sstrdup(level_info_protectme_word); + } else if (l_ptr.what == CA_AUTOPROTECT) { + levelinfo[i].name = sstrdup(level_protect_word); + } + l_ptr = levelinfo[++i]; + } } /** @@ -1697,90 +1697,90 @@ void updateProtectDetails(const char *level_info_protect_word, **/ int moduleGetConfigDirective(Directive * d) { - FILE *config; - char *dir = NULL; - char buf[1024]; + FILE *config; + char *dir = NULL; + char buf[1024]; char *directive; - int linenum = 0; - int ac = 0; - char *av[MAXPARAMS]; + int linenum = 0; + int ac = 0; + char *av[MAXPARAMS]; char *str = NULL; - char *s = NULL; + char *s = NULL; char *t = NULL; - int retval = 1; - - config = fopen(SERVICES_CONF, "r"); - if (!config) { - alog("Can't open %s", SERVICES_CONF); - return 0; - } - while (fgets(buf, sizeof(buf), config)) { - linenum++; - if (*buf == '#' || *buf == '\r' || *buf == '\n') { - continue; + int retval = 1; + + config = fopen(SERVICES_CONF, "r"); + if (!config) { + alog("Can't open %s", SERVICES_CONF); + return 0; + } + while (fgets(buf, sizeof(buf), config)) { + linenum++; + if (*buf == '#' || *buf == '\r' || *buf == '\n') { + continue; + } + dir = myStrGetOnlyToken(buf, '\t', 0); + if (dir) { + str = myStrGetTokenRemainder(buf, '\t', 1); + } else { + dir = myStrGetOnlyToken(buf, ' ', 0); + if (dir || (dir = myStrGetOnlyToken(buf, '\n', 0))) { + str = myStrGetTokenRemainder(buf, ' ', 1); + } else { + continue; + } } - dir = myStrGetOnlyToken(buf, '\t', 0); - if (dir) { - str = myStrGetTokenRemainder(buf, '\t', 1); - } else { - dir = myStrGetOnlyToken(buf, ' ', 0); - if (dir || (dir = myStrGetOnlyToken(buf, '\n', 0))) { - str = myStrGetTokenRemainder(buf, ' ', 1); - } else { - continue; - } - } if (dir) { directive = normalizeBuffer(dir); } else { continue; } - if (stricmp(directive, d->name) == 0) { - if (str) { + if (stricmp(directive, d->name) == 0) { + if (str) { s = str; - while (isspace(*s)) - s++; - while (*s) { - if (ac >= MAXPARAMS) { - alog("module error: too many config. params"); - break; - } - t = s; - if (*s == '"') { - t++; - s++; - while (*s && *s != '"') { - if (*s == '\\' && s[1] != 0) - s++; - s++; - } - if (!*s) - alog("module error: Warning: unterminated double-quoted string"); - else - *s++ = 0; - } else { - s += strcspn(s, " \t\r\n"); - if (*s) - *s++ = 0; - } - av[ac++] = t; - while (isspace(*s)) - s++; - } - } - retval = parse_directive(d, directive, ac, av, linenum, 0, s); - } + while (isspace(*s)) + s++; + while (*s) { + if (ac >= MAXPARAMS) { + alog("module error: too many config. params"); + break; + } + t = s; + if (*s == '"') { + t++; + s++; + while (*s && *s != '"') { + if (*s == '\\' && s[1] != 0) + s++; + s++; + } + if (!*s) + alog("module error: Warning: unterminated double-quoted string"); + else + *s++ = 0; + } else { + s += strcspn(s, " \t\r\n"); + if (*s) + *s++ = 0; + } + av[ac++] = t; + while (isspace(*s)) + s++; + } + } + retval = parse_directive(d, directive, ac, av, linenum, 0, s); + } if (directive) { free(directive); } - } - if (dir) - free(dir); - if (str) - free(str); - fclose(config); - return retval; + } + if (dir) + free(dir); + if (str) + free(str); + fclose(config); + return retval; } /** @@ -1792,47 +1792,47 @@ int moduleGetConfigDirective(Directive * d) **/ void moduleNoticeLang(char *source, User * u, int number, ...) { - va_list va; - char buffer[4096], outbuf[4096]; - char *fmt = NULL; - int lang = NSDefLanguage; - char *s, *t, *buf; - - if ((mod_current_module_name) && (!mod_current_module || mod_current_module_name != mod_current_module->name)) { - mod_current_module = findModule(mod_current_module_name); - } - - /* Find the users lang, and use it if we can */ - if (u && u->na && u->na->nc) { - lang = u->na->nc->language; - } - - /* If the users lang isnt supported, drop back to English */ - if (mod_current_module->lang[lang].argc == 0) { - lang = LANG_EN_US; - } - - /* If the requested lang string exists for the language */ - if (mod_current_module->lang[lang].argc > number) { - fmt = mod_current_module->lang[lang].argv[number]; - - buf = sstrdup(fmt); - va_start(va, number); - vsnprintf(buffer, 4095, buf, va); - va_end(va); - s = buffer; - while (*s) { - t = s; - s += strcspn(s, "\n"); - if (*s) - *s++ = '\0'; - strscpy(outbuf, t, sizeof(outbuf)); - notice_user(source, u, "%s", outbuf); - } + va_list va; + char buffer[4096], outbuf[4096]; + char *fmt = NULL; + int lang = NSDefLanguage; + char *s, *t, *buf; + + if ((mod_current_module_name) && (!mod_current_module || mod_current_module_name != mod_current_module->name)) { + mod_current_module = findModule(mod_current_module_name); + } + + /* Find the users lang, and use it if we can */ + if (u && u->na && u->na->nc) { + lang = u->na->nc->language; + } + + /* If the users lang isnt supported, drop back to English */ + if (mod_current_module->lang[lang].argc == 0) { + lang = LANG_EN_US; + } + + /* If the requested lang string exists for the language */ + if (mod_current_module->lang[lang].argc > number) { + fmt = mod_current_module->lang[lang].argv[number]; + + buf = sstrdup(fmt); + va_start(va, number); + vsnprintf(buffer, 4095, buf, va); + va_end(va); + s = buffer; + while (*s) { + t = s; + s += strcspn(s, "\n"); + if (*s) + *s++ = '\0'; + strscpy(outbuf, t, sizeof(outbuf)); + notice_user(source, u, "%s", outbuf); + } free(buf); - } else { - alog("%s: INVALID language string call, language: [%d], String [%d]", mod_current_module->name.c_str(), lang, number); - } + } else { + alog("%s: INVALID language string call, language: [%d], String [%d]", mod_current_module->name.c_str(), lang, number); + } } /** @@ -1843,30 +1843,30 @@ void moduleNoticeLang(char *source, User * u, int number, ...) **/ const char *moduleGetLangString(User * u, int number) { - int lang = NSDefLanguage; + int lang = NSDefLanguage; - if ((mod_current_module_name) && (!mod_current_module || mod_current_module_name != mod_current_module->name)) - mod_current_module = findModule(mod_current_module_name); + if ((mod_current_module_name) && (!mod_current_module || mod_current_module_name != mod_current_module->name)) + mod_current_module = findModule(mod_current_module_name); - /* Find the users lang, and use it if we can */ - if (u && u->na && u->na->nc) - lang = u->na->nc->language; + /* Find the users lang, and use it if we can */ + if (u && u->na && u->na->nc) + lang = u->na->nc->language; - /* If the users lang isnt supported, drop back to English */ - if (mod_current_module->lang[lang].argc == 0) - lang = LANG_EN_US; + /* If the users lang isnt supported, drop back to English */ + if (mod_current_module->lang[lang].argc == 0) + lang = LANG_EN_US; - /* If the requested lang string exists for the language */ - if (mod_current_module->lang[lang].argc > number) { - return mod_current_module->lang[lang].argv[number]; + /* If the requested lang string exists for the language */ + if (mod_current_module->lang[lang].argc > number) { + return mod_current_module->lang[lang].argv[number]; /* Return an empty string otherwise, because we might be used without * the return value being checked. If we would return NULL, bad things * would happen! */ } else { - alog("%s: INVALID language string call, language: [%d], String [%d]", mod_current_module->name.c_str(), lang, number); + alog("%s: INVALID language string call, language: [%d], String [%d]", mod_current_module->name.c_str(), lang, number); return ""; - } + } } /** @@ -1875,37 +1875,37 @@ const char *moduleGetLangString(User * u, int number) **/ void moduleDeleteLanguage(int langNumber) { - int idx = 0; - if ((mod_current_module_name) && (!mod_current_module || mod_current_module_name != mod_current_module->name)) { - mod_current_module = findModule(mod_current_module_name); - } - for (idx = 0; idx > mod_current_module->lang[langNumber].argc; idx++) { - free(mod_current_module->lang[langNumber].argv[idx]); - } - mod_current_module->lang[langNumber].argc = 0; + int idx = 0; + if ((mod_current_module_name) && (!mod_current_module || mod_current_module_name != mod_current_module->name)) { + mod_current_module = findModule(mod_current_module_name); + } + for (idx = 0; idx > mod_current_module->lang[langNumber].argc; idx++) { + free(mod_current_module->lang[langNumber].argv[idx]); + } + mod_current_module->lang[langNumber].argc = 0; } void ModuleRunTimeDirCleanUp(void) { #ifndef _WIN32 - DIR *dirp; - struct dirent *dp; + DIR *dirp; + struct dirent *dp; #else - BOOL fFinished; - HANDLE hList; - TCHAR szDir[MAX_PATH + 1]; - TCHAR szSubDir[MAX_PATH + 1]; - WIN32_FIND_DATA FileData; - char buffer[_MAX_PATH]; + BOOL fFinished; + HANDLE hList; + TCHAR szDir[MAX_PATH + 1]; + TCHAR szSubDir[MAX_PATH + 1]; + WIN32_FIND_DATA FileData; + char buffer[_MAX_PATH]; #endif - char dirbuf[BUFSIZE]; - char filebuf[BUFSIZE]; + char dirbuf[BUFSIZE]; + char filebuf[BUFSIZE]; #ifndef _WIN32 - snprintf(dirbuf, BUFSIZE, "%s/modules/runtime", services_dir); + snprintf(dirbuf, BUFSIZE, "%s/modules/runtime", services_dir); #else - snprintf(dirbuf, BUFSIZE, "\\%s", "modules/runtime"); + snprintf(dirbuf, BUFSIZE, "\\%s", "modules/runtime"); #endif if (debug) { @@ -1913,52 +1913,52 @@ void ModuleRunTimeDirCleanUp(void) } #ifndef _WIN32 - if ((dirp = opendir(dirbuf)) == NULL) { + if ((dirp = opendir(dirbuf)) == NULL) { if (debug) { - alog("debug: cannot open directory (%s)", dirbuf); + alog("debug: cannot open directory (%s)", dirbuf); + } + return; + } + while ((dp = readdir(dirp)) != NULL) { + if (dp->d_ino == 0) { + continue; } - return; - } - while ((dp = readdir(dirp)) != NULL) { - if (dp->d_ino == 0) { - continue; - } - if (!stricmp(dp->d_name, ".") || !stricmp(dp->d_name, "..")) { - continue; - } - snprintf(filebuf, BUFSIZE, "%s/%s", dirbuf, dp->d_name); + if (!stricmp(dp->d_name, ".") || !stricmp(dp->d_name, "..")) { + continue; + } + snprintf(filebuf, BUFSIZE, "%s/%s", dirbuf, dp->d_name); unlink(filebuf); - } - closedir(dirp); + } + closedir(dirp); #else - /* Get the current working directory: */ - if (_getcwd(buffer, _MAX_PATH) == NULL) { + /* Get the current working directory: */ + if (_getcwd(buffer, _MAX_PATH) == NULL) { if (debug) { - alog("debug: Unable to set Current working directory"); + alog("debug: Unable to set Current working directory"); } - } - snprintf(szDir, sizeof(szDir), "%s\\%s\\*", buffer, dirbuf); - - hList = FindFirstFile(szDir, &FileData); - if (hList != INVALID_HANDLE_VALUE) { - fFinished = FALSE; - while (!fFinished) { - if (!(FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { - snprintf(filebuf, BUFSIZE, "%s/%s", dirbuf, FileData.cFileName); + } + snprintf(szDir, sizeof(szDir), "%s\\%s\\*", buffer, dirbuf); + + hList = FindFirstFile(szDir, &FileData); + if (hList != INVALID_HANDLE_VALUE) { + fFinished = FALSE; + while (!fFinished) { + if (!(FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { + snprintf(filebuf, BUFSIZE, "%s/%s", dirbuf, FileData.cFileName); DeleteFile(filebuf); - } - if (!FindNextFile(hList, &FileData)) { - if (GetLastError() == ERROR_NO_MORE_FILES) { - fFinished = TRUE; - } - } - } - } else { + } + if (!FindNextFile(hList, &FileData)) { + if (GetLastError() == ERROR_NO_MORE_FILES) { + fFinished = TRUE; + } + } + } + } else { if (debug) { - alog("debug: Invalid File Handle. GetLastError reports %d\n", GetLastError()); + alog("debug: Invalid File Handle. GetLastError reports %d\n", GetLastError()); } - } - FindClose(hList); + } + FindClose(hList); #endif if (debug) { alog("debug: Module run time directory has been cleaned out"); diff --git a/src/modules/bs_fantasy_unban.c b/src/modules/bs_fantasy_unban.c index b7ce00ebf..88920176a 100644 --- a/src/modules/bs_fantasy_unban.c +++ b/src/modules/bs_fantasy_unban.c @@ -41,31 +41,31 @@ class BSFantasyUnban : public Module **/ int do_fantasy(int argc, char **argv) { - User *u; - ChannelInfo *ci; - char *target = NULL; + User *u; + ChannelInfo *ci; + char *target = NULL; - if (argc < 3) - return MOD_CONT; + if (argc < 3) + return MOD_CONT; - if (stricmp(argv[0], "unban") == 0) { - u = finduser(argv[1]); - ci = cs_findchan(argv[2]); - if (!u || !ci || !check_access(u, ci, CA_UNBAN)) - return MOD_CONT; + if (stricmp(argv[0], "unban") == 0) { + u = finduser(argv[1]); + ci = cs_findchan(argv[2]); + if (!u || !ci || !check_access(u, ci, CA_UNBAN)) + return MOD_CONT; - if (argc >= 4) - target = myStrGetToken(argv[3], ' ', 0); - if (!target) - common_unban(ci, u->nick); - else - common_unban(ci, target); + if (argc >= 4) + target = myStrGetToken(argv[3], ' ', 0); + if (!target) + common_unban(ci, u->nick); + else + common_unban(ci, target); - /* free target if needed (#852) */ - Anope_Free(target); - } + /* free target if needed (#852) */ + Anope_Free(target); + } - return MOD_CONT; + return MOD_CONT; } MODULE_INIT("bs_fantasy_unban", BSFantasyUnban) diff --git a/src/modules/cs_enforce.c b/src/modules/cs_enforce.c index 31dd089d0..7d66bcb1a 100644 --- a/src/modules/cs_enforce.c +++ b/src/modules/cs_enforce.c @@ -1,5 +1,5 @@ /* cs_enforce - Add a /cs ENFORCE command to enforce various set - * options and channelmodes on a channel. + * options and channelmodes on a channel. * * (C) 2003-2008 Anope Team * Contact us at info@anope.org @@ -23,14 +23,14 @@ void my_cs_help(User * u); int my_cs_help_enforce(User * u); void my_add_languages(void); -#define LNG_NUM_STRINGS 6 +#define LNG_NUM_STRINGS 6 -#define LNG_CHAN_HELP 0 -#define LNG_ENFORCE_SYNTAX 1 -#define LNG_CHAN_HELP_ENFORCE 2 -#define LNG_CHAN_HELP_ENFORCE_R_ENABLED 3 -#define LNG_CHAN_HELP_ENFORCE_R_DISABLED 4 -#define LNG_CHAN_RESPONSE 5 +#define LNG_CHAN_HELP 0 +#define LNG_ENFORCE_SYNTAX 1 +#define LNG_CHAN_HELP_ENFORCE 2 +#define LNG_CHAN_HELP_ENFORCE_R_ENABLED 3 +#define LNG_CHAN_HELP_ENFORCE_R_DISABLED 4 +#define LNG_CHAN_RESPONSE 5 class CSEnforce : public Module { @@ -52,7 +52,7 @@ class CSEnforce : public Module /* English (US) */ const char* langtable_en_us[] = { /* LNG_CHAN_HELP */ - " ENFORCE Enforce various channel modes and set options", + " ENFORCE Enforce various channel modes and set options", /* LNG_ENFORCE_SYNTAX */ "Syntax: \002ENFORCE \037channel\037 [\037what\037]\002", /* LNG_CHAN_HELP_ENFORCE */ @@ -86,7 +86,7 @@ class CSEnforce : public Module /* Dutch (NL) */ const char* langtable_nl[] = { /* LNG_CHAN_HELP */ - " ENFORCE Forceer enkele kanaalmodes en set-opties", + " ENFORCE Forceer enkele kanaalmodes en set-opties", /* LNG_ENFORCE_SYNTAX */ "Syntax: \002ENFORCE \037kanaal\037 [\037wat\037]\002", /* LNG_CHAN_HELP_ENFORCE */ @@ -122,7 +122,7 @@ class CSEnforce : public Module /* German (DE) */ const char* langtable_de[] = { /* LNG_CHAN_HELP */ - " ENFORCE Erzwingt verschieden Modes und SET Optionen", + " ENFORCE Erzwingt verschieden Modes und SET Optionen", /* LNG_ENFORCE_SYNTAX */ "Syntax: \002ENFORCE \037Channel\037 [\037was\037]\002", /* LNG_CHAN_HELP_ENFORCE */ @@ -155,7 +155,7 @@ class CSEnforce : public Module /* Portuguese (PT) */ const char* langtable_pt[] = { /* LNG_CHAN_HELP */ - " ENFORCE Verifica o cumprimento de vários modos de canal e opções ajustadas", + " ENFORCE Verifica o cumprimento de vários modos de canal e opções ajustadas", /* LNG_ENFORCE_SYNTAX */ "Sintaxe: \002ENFORCE \037canal\037 [\037opção\037]\002", /* LNG_CHAN_HELP_ENFORCE */ @@ -188,7 +188,7 @@ class CSEnforce : public Module /* Russian (RU) */ const char* langtable_ru[] = { /* LNG_CHAN_HELP */ - " ENFORCE Ïåðåïðîâåðêà è óñòàíîâêà ðàçëè÷íûõ ðåæèìîâ è îïöèé êàíàëà", + " ENFORCE Ïåðåïðîâåðêà è óñòàíîâêà ðàçëè÷íûõ ðåæèìîâ è îïöèé êàíàëà", /* LNG_ENFORCE_SYNTAX */ "Ñèíòàêñèñ: \002ENFORCE \037#êàíàë\037 \037ïàðàìåòð\037\002", /* LNG_CHAN_HELP_ENFORCE */ @@ -220,7 +220,7 @@ class CSEnforce : public Module /* Italian (IT) */ const char* langtable_it[] = { /* LNG_CHAN_HELP */ - " ENFORCE Forza diversi modi di canale ed opzioni SET", + " ENFORCE Forza diversi modi di canale ed opzioni SET", /* LNG_ENFORCE_SYNTAX */ "Sintassi: \002ENFORCE \037canale\037 [\037cosa\037]\002", /* LNG_CHAN_HELP_ENFORCE */ @@ -264,206 +264,206 @@ class CSEnforce : public Module /* Enforcing functions */ void do_enforce_secureops(Channel * c) { - struct c_userlist *user; - struct c_userlist *next; - ChannelInfo *ci; - uint32 flags; - - if (!(ci = c->ci)) - return; - - if (debug) - alog("debug: cs_enforce: Enforcing SECUREOPS on %s", c->name); - - /* Dirty hack to allow chan_set_correct_modes to work ok. - * We pretend like SECUREOPS is on so it doesn't ignore that - * part of the code. This way we can enforce SECUREOPS even - * if it's off. - */ - flags = ci->flags; - ci->flags |= CI_SECUREOPS; - - user = c->users; - do { - next = user->next; - chan_set_correct_modes(user->user, c, 0); - user = next; - } while (user); - - ci->flags = flags; + struct c_userlist *user; + struct c_userlist *next; + ChannelInfo *ci; + uint32 flags; + + if (!(ci = c->ci)) + return; + + if (debug) + alog("debug: cs_enforce: Enforcing SECUREOPS on %s", c->name); + + /* Dirty hack to allow chan_set_correct_modes to work ok. + * We pretend like SECUREOPS is on so it doesn't ignore that + * part of the code. This way we can enforce SECUREOPS even + * if it's off. + */ + flags = ci->flags; + ci->flags |= CI_SECUREOPS; + + user = c->users; + do { + next = user->next; + chan_set_correct_modes(user->user, c, 0); + user = next; + } while (user); + + ci->flags = flags; } void do_enforce_restricted(Channel * c) { - struct c_userlist *user; - struct c_userlist *next; - ChannelInfo *ci; - int16 old_nojoin_level; - char mask[BUFSIZE]; - char *reason; - const char *av[3]; - User *u; - - if (!(ci = c->ci)) - return; - - if (debug) - alog("debug: cs_enforce: Enforcing RESTRICTED on %s", c->name); - - old_nojoin_level = ci->levels[CA_NOJOIN]; - if (ci->levels[CA_NOJOIN] < 0) - ci->levels[CA_NOJOIN] = 0; - - user = c->users; - do { - next = user->next; - u = user->user; - if (check_access(u, c->ci, CA_NOJOIN)) { - get_idealban(ci, u, mask, sizeof(mask)); - reason = getstring(u->na, CHAN_NOT_ALLOWED_TO_JOIN); - ircdproto->SendMode(whosends(ci), ci->name, "+b %s %lu", mask, - time(NULL)); - ircdproto->SendKick(whosends(ci), ci->name, u->nick, "%s", reason); - av[0] = ci->name; - av[1] = u->nick; - av[2] = reason; - do_kick(s_ChanServ, 3, av); - } - user = next; - } while (user); - - ci->levels[CA_NOJOIN] = old_nojoin_level; + struct c_userlist *user; + struct c_userlist *next; + ChannelInfo *ci; + int16 old_nojoin_level; + char mask[BUFSIZE]; + char *reason; + const char *av[3]; + User *u; + + if (!(ci = c->ci)) + return; + + if (debug) + alog("debug: cs_enforce: Enforcing RESTRICTED on %s", c->name); + + old_nojoin_level = ci->levels[CA_NOJOIN]; + if (ci->levels[CA_NOJOIN] < 0) + ci->levels[CA_NOJOIN] = 0; + + user = c->users; + do { + next = user->next; + u = user->user; + if (check_access(u, c->ci, CA_NOJOIN)) { + get_idealban(ci, u, mask, sizeof(mask)); + reason = getstring(u->na, CHAN_NOT_ALLOWED_TO_JOIN); + ircdproto->SendMode(whosends(ci), ci->name, "+b %s %lu", mask, + time(NULL)); + ircdproto->SendKick(whosends(ci), ci->name, u->nick, "%s", reason); + av[0] = ci->name; + av[1] = u->nick; + av[2] = reason; + do_kick(s_ChanServ, 3, av); + } + user = next; + } while (user); + + ci->levels[CA_NOJOIN] = old_nojoin_level; } void do_enforce_cmode_R(Channel * c) { - struct c_userlist *user; - struct c_userlist *next; - ChannelInfo *ci; - char mask[BUFSIZE]; - char *reason; - const char *av[3]; - User *u; - CBMode *cbm; - - if (!(ci = c->ci)) - return; - - if (debug) - alog("debug: cs_enforce: Enforcing mode +R on %s", c->name); - - user = c->users; - do { - next = user->next; - u = user->user; - if (!nick_identified(u)) { - get_idealban(ci, u, mask, sizeof(mask)); - reason = getstring(u->na, CHAN_NOT_ALLOWED_TO_JOIN); - if (((cbm = &cbmodes['R'])->flag == 0) - || !(c->mode & cbm->flag)) - ircdproto->SendMode(whosends(ci), ci->name, "+b %s %lu", mask, - time(NULL)); - ircdproto->SendKick(whosends(ci), ci->name, u->nick, "%s", reason); - av[0] = ci->name; - av[1] = u->nick; - av[2] = reason; - do_kick(s_ChanServ, 3, av); - } - user = next; - } while (user); + struct c_userlist *user; + struct c_userlist *next; + ChannelInfo *ci; + char mask[BUFSIZE]; + char *reason; + const char *av[3]; + User *u; + CBMode *cbm; + + if (!(ci = c->ci)) + return; + + if (debug) + alog("debug: cs_enforce: Enforcing mode +R on %s", c->name); + + user = c->users; + do { + next = user->next; + u = user->user; + if (!nick_identified(u)) { + get_idealban(ci, u, mask, sizeof(mask)); + reason = getstring(u->na, CHAN_NOT_ALLOWED_TO_JOIN); + if (((cbm = &cbmodes['R'])->flag == 0) + || !(c->mode & cbm->flag)) + ircdproto->SendMode(whosends(ci), ci->name, "+b %s %lu", mask, + time(NULL)); + ircdproto->SendKick(whosends(ci), ci->name, u->nick, "%s", reason); + av[0] = ci->name; + av[1] = u->nick; + av[2] = reason; + do_kick(s_ChanServ, 3, av); + } + user = next; + } while (user); } /* Enforcing Group Functions */ void do_enforce_set(Channel * c) { - ChannelInfo *ci; + ChannelInfo *ci; - if (!(ci = c->ci)) - return; + if (!(ci = c->ci)) + return; - if (ci->flags & CI_SECUREOPS) - do_enforce_secureops(c); - if (ci->flags & CI_RESTRICTED) - do_enforce_restricted(c); + if (ci->flags & CI_SECUREOPS) + do_enforce_secureops(c); + if (ci->flags & CI_RESTRICTED) + do_enforce_restricted(c); } void do_enforce_modes(Channel * c) { - CBMode *cbm; + CBMode *cbm; - if (((cbm = &cbmodes['R'])->flag != 0) && (c->mode & cbm->flag)) - do_enforce_cmode_R(c); + if (((cbm = &cbmodes['R'])->flag != 0) && (c->mode & cbm->flag)) + do_enforce_cmode_R(c); } /* End of enforcing functions */ int my_cs_enforce(User * u) { - char *cur_buffer; - char *chan=NULL; - char *what=NULL; - Channel *c; - ChannelInfo *ci; - - cur_buffer = moduleGetLastBuffer(); - chan = myStrGetToken(cur_buffer, ' ', 0); - - if (!chan) { - moduleNoticeLang(s_ChanServ, u, LNG_ENFORCE_SYNTAX); - } else if (!(c = findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); - } else if (!(ci = c->ci)) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name); - } else if (!is_services_admin(u) && !check_access(u, ci, CA_AKICK)) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - } else { - what = myStrGetToken(cur_buffer, ' ', 1); - if (!what || (stricmp(what, "SET") == 0)) { - do_enforce_set(c); - moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what); - } else if (stricmp(what, "MODES") == 0) { - do_enforce_modes(c); - moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what); - } else if (stricmp(what, "SECUREOPS") == 0) { - do_enforce_secureops(c); - moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what); - } else if (stricmp(what, "RESTRICTED") == 0) { - do_enforce_restricted(c); - moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what); - } else if (stricmp(what, "+R") == 0) { - do_enforce_cmode_R(c); - moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what); - } else { - moduleNoticeLang(s_ChanServ, u, LNG_ENFORCE_SYNTAX); - } - } - - if(chan) free(chan); - if(what) free(what); - - return MOD_CONT; + char *cur_buffer; + char *chan=NULL; + char *what=NULL; + Channel *c; + ChannelInfo *ci; + + cur_buffer = moduleGetLastBuffer(); + chan = myStrGetToken(cur_buffer, ' ', 0); + + if (!chan) { + moduleNoticeLang(s_ChanServ, u, LNG_ENFORCE_SYNTAX); + } else if (!(c = findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); + } else if (!(ci = c->ci)) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name); + } else if (!is_services_admin(u) && !check_access(u, ci, CA_AKICK)) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + } else { + what = myStrGetToken(cur_buffer, ' ', 1); + if (!what || (stricmp(what, "SET") == 0)) { + do_enforce_set(c); + moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what); + } else if (stricmp(what, "MODES") == 0) { + do_enforce_modes(c); + moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what); + } else if (stricmp(what, "SECUREOPS") == 0) { + do_enforce_secureops(c); + moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what); + } else if (stricmp(what, "RESTRICTED") == 0) { + do_enforce_restricted(c); + moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what); + } else if (stricmp(what, "+R") == 0) { + do_enforce_cmode_R(c); + moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what); + } else { + moduleNoticeLang(s_ChanServ, u, LNG_ENFORCE_SYNTAX); + } + } + + if(chan) free(chan); + if(what) free(what); + + return MOD_CONT; } /* Language and response stuff */ void my_cs_help(User * u) { - moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP); + moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP); } int my_cs_help_enforce(User * u) { - moduleNoticeLang(s_ChanServ, u, LNG_ENFORCE_SYNTAX); - ircdproto->SendMessage(findbot(s_ChanServ), u->nick, " "); - moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP_ENFORCE); - ircdproto->SendMessage(findbot(s_ChanServ), u->nick, " "); - if (cbmodes['R'].flag != 0) - moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP_ENFORCE_R_ENABLED); - else - moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP_ENFORCE_R_DISABLED); - - return MOD_STOP; + moduleNoticeLang(s_ChanServ, u, LNG_ENFORCE_SYNTAX); + ircdproto->SendMessage(findbot(s_ChanServ), u->nick, " "); + moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP_ENFORCE); + ircdproto->SendMessage(findbot(s_ChanServ), u->nick, " "); + if (cbmodes['R'].flag != 0) + moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP_ENFORCE_R_ENABLED); + else + moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP_ENFORCE_R_DISABLED); + + return MOD_STOP; } MODULE_INIT("cs_enforce", CSEnforce) diff --git a/src/modules/cs_tban.c b/src/modules/cs_tban.c index 327ec43e6..6045c7a98 100644 --- a/src/modules/cs_tban.c +++ b/src/modules/cs_tban.c @@ -33,11 +33,11 @@ int canBanUser(Channel * c, User * u, User * u2); void mAddLanguages(void); -#define LANG_NUM_STRINGS 4 -#define TBAN_HELP 0 -#define TBAN_SYNTAX 1 -#define TBAN_HELP_DETAIL 2 -#define TBAN_RESPONSE 3 +#define LANG_NUM_STRINGS 4 +#define TBAN_HELP 0 +#define TBAN_SYNTAX 1 +#define TBAN_HELP_DETAIL 2 +#define TBAN_RESPONSE 3 class CSTBan : public Module { @@ -56,7 +56,7 @@ class CSTBan : public Module this->SetType(SUPPORTED); const char* langtable_en_us[] = { - " TBAN Bans the user for a given length of time", + " TBAN Bans the user for a given length of time", "Syntax: TBAN channel nick time", "Bans the given user from a channel for a specified length of\n" "time. If the ban is removed before by hand, it will NOT be replaced.", @@ -64,7 +64,7 @@ class CSTBan : public Module }; const char* langtable_nl[] = { - " TBAN Verban een gebruiker voor een bepaalde tijd", + " TBAN Verban een gebruiker voor een bepaalde tijd", "Syntax: TBAN kanaal nick tijd", "Verbant de gegeven gebruiken van het gegeven kanaal voor de\n" "gegeven tijdsduur. Als de verbanning eerder wordt verwijderd,\n" @@ -73,7 +73,7 @@ class CSTBan : public Module }; const char* langtable_de[] = { - " TBAN Bant ein User für eine bestimmte Zeit aus ein Channel", + " TBAN Bant ein User für eine bestimmte Zeit aus ein Channel", "Syntax: TBAN Channel Nickname Zeit", "Bant ein User für eine bestimmte Zeit aus ein Channel\n" "Wenn der Ban manuell entfernt wird, wird es NICHT ersetzt.", @@ -81,7 +81,7 @@ class CSTBan : public Module }; const char* langtable_pt[] = { - " TBAN Bane o usuário por um determinado período de tempo", + " TBAN Bane o usuário por um determinado período de tempo", "Sintaxe: TBAN canal nick tempo", "Bane de um canal o usuário especificado por um determinado período de\n" "tempo. Se o ban for removido manualmente antes do tempo, ele não será recolocado.", @@ -89,7 +89,7 @@ class CSTBan : public Module }; const char* langtable_ru[] = { - " TBAN Áàíèò ïîëüçîâàòåëÿ íà óêàçàííûé ïðîìåæóòîê âðåìåíè", + " TBAN Áàíèò ïîëüçîâàòåëÿ íà óêàçàííûé ïðîìåæóòîê âðåìåíè", "Ñèíòàêñèñ: TBAN #êàíàë íèê âðåìÿ", "Áàíèò ïîëüçîâàòåëÿ íà óêàçàííûé ïðîìåæóòîê âðåìåíè â ñåêóíäàõ\n" "Ïðèìå÷àíèå: óäàëåííûé âðó÷íóþ (äî ñâîåãî èñòå÷åíèÿ) áàí ÍÅ ÁÓÄÅÒ\n" @@ -98,7 +98,7 @@ class CSTBan : public Module }; const char* langtable_it[] = { - " TBAN Banna l'utente per un periodo di tempo specificato", + " TBAN Banna l'utente per un periodo di tempo specificato", "Sintassi: TBAN canale nick tempo", "Banna l'utente specificato da un canale per un periodo di tempo\n" "specificato. Se il ban viene rimosso a mano prima della scadenza, NON verrà rimpiazzato.", @@ -118,120 +118,120 @@ class CSTBan : public Module void myHelp(User * u) { - moduleNoticeLang(s_ChanServ, u, TBAN_HELP); + moduleNoticeLang(s_ChanServ, u, TBAN_HELP); } void myFullHelpSyntax(User * u) { - moduleNoticeLang(s_ChanServ, u, TBAN_SYNTAX); + moduleNoticeLang(s_ChanServ, u, TBAN_SYNTAX); } int myFullHelp(User * u) { - myFullHelpSyntax(u); - ircdproto->SendMessage(findbot(s_ChanServ), u->nick, " "); - moduleNoticeLang(s_ChanServ, u, TBAN_HELP_DETAIL); - return MOD_CONT; + myFullHelpSyntax(u); + ircdproto->SendMessage(findbot(s_ChanServ), u->nick, " "); + moduleNoticeLang(s_ChanServ, u, TBAN_HELP_DETAIL); + return MOD_CONT; } void mySendResponse(User * u, char *channel, char *mask, char *time) { - moduleNoticeLang(s_ChanServ, u, TBAN_RESPONSE, mask, channel, time); + moduleNoticeLang(s_ChanServ, u, TBAN_RESPONSE, mask, channel, time); } int do_tban(User * u) { - char mask[BUFSIZE]; - Channel *c; - User *u2 = NULL; - - char *buffer = moduleGetLastBuffer(); - char *chan; - char *nick; - char *time; - - chan = myStrGetToken(buffer, ' ', 0); - nick = myStrGetToken(buffer, ' ', 1); - time = myStrGetToken(buffer, ' ', 2); - - if (time && chan && nick) { - - if (!(c = findchan(chan))) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); - } else if (!(u2 = finduser(nick))) { - notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, nick); - } else { - if (canBanUser(c, u, u2)) { - get_idealban(c->ci, u2, mask, sizeof(mask)); - addBan(c, dotime(time), mask); - mySendResponse(u, chan, mask, time); - } - } - } else { - myFullHelpSyntax(u); - } - if (time) - free(time); - if (nick) - free(nick); - if (chan) - free(chan); - - return MOD_CONT; + char mask[BUFSIZE]; + Channel *c; + User *u2 = NULL; + + char *buffer = moduleGetLastBuffer(); + char *chan; + char *nick; + char *time; + + chan = myStrGetToken(buffer, ' ', 0); + nick = myStrGetToken(buffer, ' ', 1); + time = myStrGetToken(buffer, ' ', 2); + + if (time && chan && nick) { + + if (!(c = findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); + } else if (!(u2 = finduser(nick))) { + notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, nick); + } else { + if (canBanUser(c, u, u2)) { + get_idealban(c->ci, u2, mask, sizeof(mask)); + addBan(c, dotime(time), mask); + mySendResponse(u, chan, mask, time); + } + } + } else { + myFullHelpSyntax(u); + } + if (time) + free(time); + if (nick) + free(nick); + if (chan) + free(chan); + + return MOD_CONT; } void addBan(Channel * c, time_t timeout, char *banmask) { - const char *av[3]; - char *cb[2]; + const char *av[3]; + char *cb[2]; - cb[0] = c->name; - cb[1] = banmask; + cb[0] = c->name; + cb[1] = banmask; - av[0] = "+b"; - av[1] = banmask; + av[0] = "+b"; + av[1] = banmask; - ircdproto->SendMode(whosends(c->ci), c->name, "+b %s", av[1]); - chan_set_modes(s_ChanServ, c, 2, av, 1); + ircdproto->SendMode(whosends(c->ci), c->name, "+b %s", av[1]); + chan_set_modes(s_ChanServ, c, 2, av, 1); - moduleAddCallback("tban", time(NULL) + timeout, delBan, 2, cb); + moduleAddCallback("tban", time(NULL) + timeout, delBan, 2, cb); } int delBan(int argc, char **argv) { - const char *av[3]; - Channel *c; + const char *av[3]; + Channel *c; - av[0] = "-b"; - av[1] = argv[1]; + av[0] = "-b"; + av[1] = argv[1]; - if ((c = findchan(argv[0])) && c->ci) { - ircdproto->SendMode(whosends(c->ci), c->name, "-b %s", av[1]); - chan_set_modes(s_ChanServ, c, 2, av, 1); - } + if ((c = findchan(argv[0])) && c->ci) { + ircdproto->SendMode(whosends(c->ci), c->name, "-b %s", av[1]); + chan_set_modes(s_ChanServ, c, 2, av, 1); + } - return MOD_CONT; + return MOD_CONT; } int canBanUser(Channel * c, User * u, User * u2) { - ChannelInfo *ci; - int ok = 0; - if (!(ci = c->ci)) { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name); - } else if (ci->flags & CI_VERBOTEN) { - notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, c->name); - } else if (!check_access(u, ci, CA_BAN)) { - notice_lang(s_ChanServ, u, ACCESS_DENIED); - } else if (ircd->except && is_excepted(ci, u2)) { - notice_lang(s_ChanServ, u, CHAN_EXCEPTED, u2->nick, ci->name); - } else if (ircd->protectedumode && is_protected(u2)) { - notice_lang(s_ChanServ, u, PERMISSION_DENIED); - } else { - ok = 1; - } - - return ok; + ChannelInfo *ci; + int ok = 0; + if (!(ci = c->ci)) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, c->name); + } else if (!check_access(u, ci, CA_BAN)) { + notice_lang(s_ChanServ, u, ACCESS_DENIED); + } else if (ircd->except && is_excepted(ci, u2)) { + notice_lang(s_ChanServ, u, CHAN_EXCEPTED, u2->nick, ci->name); + } else if (ircd->protectedumode && is_protected(u2)) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + } else { + ok = 1; + } + + return ok; } diff --git a/src/modules/demos/catserv/catserv_messages.c b/src/modules/demos/catserv/catserv_messages.c index 23c1b4ec1..667b336b5 100644 --- a/src/modules/demos/catserv/catserv_messages.c +++ b/src/modules/demos/catserv/catserv_messages.c @@ -5,10 +5,10 @@ void addMessageList(void) { - Command *c; - c = createCommand("meow", do_meow, NULL, -1, -1, -1, -1, -1); - this->AddCommand(Catserv_cmdTable, c, MOD_UNIQUE); - c = createCommand("purr", do_purr, NULL, -1, -1, -1, -1, -1); - this->AddCommand(Catserv_cmdTable, c, MOD_UNIQUE); + Command *c; + c = createCommand("meow", do_meow, NULL, -1, -1, -1, -1, -1); + this->AddCommand(Catserv_cmdTable, c, MOD_UNIQUE); + c = createCommand("purr", do_purr, NULL, -1, -1, -1, -1, -1); + this->AddCommand(Catserv_cmdTable, c, MOD_UNIQUE); } diff --git a/src/modules/demos/catserv/ircd_catserv.c b/src/modules/demos/catserv/ircd_catserv.c index 763ae9cec..0f98df58a 100644 --- a/src/modules/demos/catserv/ircd_catserv.c +++ b/src/modules/demos/catserv/ircd_catserv.c @@ -22,89 +22,89 @@ char *s_CatServ = "CatServ"; int AnopeInit(int argc, char **argv) { - Message *msg = NULL; - int status; + Message *msg = NULL; + int status; #ifdef IRC_UNREAL32 - if (UseTokens) { - msg = createMessage("!", my_privmsg); - } else { - msg = createMessage("PRIVMSG", my_privmsg); - } + if (UseTokens) { + msg = createMessage("!", my_privmsg); + } else { + msg = createMessage("PRIVMSG", my_privmsg); + } #else - msg = createMessage("PRIVMSG", my_privmsg); + msg = createMessage("PRIVMSG", my_privmsg); #endif - status = moduleAddMessage(msg, MOD_HEAD); - if (status == MOD_ERR_OK) { - addClient(s_CatServ, "meow!"); - addMessageList(); - } - this->SetAuthor(AUTHOR); - this->SetVersion(VERSION); - alog("ircd_catserv.so: loaded, message status [%d]", status); - return MOD_CONT; + status = moduleAddMessage(msg, MOD_HEAD); + if (status == MOD_ERR_OK) { + addClient(s_CatServ, "meow!"); + addMessageList(); + } + this->SetAuthor(AUTHOR); + this->SetVersion(VERSION); + alog("ircd_catserv.so: loaded, message status [%d]", status); + return MOD_CONT; } void AnopeFini(void) { - delClient(); + delClient(); } int my_privmsg(char *source, int ac, char **av) { - User *u; - char *s; + User *u; + char *s; - /* First, some basic checks */ - if (ac != 2) - return MOD_CONT; /* bleh */ - if (!(u = finduser(source))) { - return MOD_CONT; - } /* non-user source */ - if (*av[0] == '#') { - return MOD_CONT; - } - /* Channel message */ - /* we should prolly honour the ignore list here, but i cba for this... */ - s = strchr(av[0], '@'); - if (s) { - *s++ = 0; - if (stricmp(s, ServerName) != 0) - return MOD_CONT; - } - if ((stricmp(av[0], s_CatServ)) == 0) { /* its for US! */ - catserv(u, av[1]); - return MOD_STOP; - } else { /* ok it isnt us, let the old code have it */ - return MOD_CONT; - } + /* First, some basic checks */ + if (ac != 2) + return MOD_CONT; /* bleh */ + if (!(u = finduser(source))) { + return MOD_CONT; + } /* non-user source */ + if (*av[0] == '#') { + return MOD_CONT; + } + /* Channel message */ + /* we should prolly honour the ignore list here, but i cba for this... */ + s = strchr(av[0], '@'); + if (s) { + *s++ = 0; + if (stricmp(s, ServerName) != 0) + return MOD_CONT; + } + if ((stricmp(av[0], s_CatServ)) == 0) { /* its for US! */ + catserv(u, av[1]); + return MOD_STOP; + } else { /* ok it isnt us, let the old code have it */ + return MOD_CONT; + } } void addClient(char *nick, char *realname) { - anope_SendClientIntroduction(nick, "catserv", "meow.meow.land", realname, "+"); + anope_SendClientIntroduction(nick, "catserv", "meow.meow.land", realname, "+"); } void delClient(void) { - anope_SendQuit(s_CatServ, "QUIT :Module Unloaded!"); + anope_SendQuit(s_CatServ, "QUIT :Module Unloaded!"); } /*****************************************************************************/ /* Main CatServ routine. */ void catserv(User * u, char *buf) { - char *cmd, *s; + char *cmd, *s; - cmd = strtok(buf, " "); + cmd = strtok(buf, " "); - if (!cmd) { - return; - } else if (stricmp(cmd, "\1PING") == 0) { - if (!(s = strtok(NULL, ""))) - s = "\1"; - notice(s_CatServ, u->nick, "\1PING %s", s); - } else { - mod_run_cmd(s_CatServ, u, Catserv_cmdTable, cmd); - } + if (!cmd) { + return; + } else if (stricmp(cmd, "\1PING") == 0) { + if (!(s = strtok(NULL, ""))) + s = "\1"; + notice(s_CatServ, u->nick, "\1PING %s", s); + } else { + mod_run_cmd(s_CatServ, u, Catserv_cmdTable, cmd); + } } diff --git a/src/modules/demos/catserv/purr.c b/src/modules/demos/catserv/purr.c index 5a39dc26e..e7c1e9c8d 100644 --- a/src/modules/demos/catserv/purr.c +++ b/src/modules/demos/catserv/purr.c @@ -3,6 +3,6 @@ int do_purr(User * u) { - notice(s_CatServ, u->nick, "PURR!"); - return MOD_STOP; + notice(s_CatServ, u->nick, "PURR!"); + return MOD_STOP; } diff --git a/src/modules/demos/events.c b/src/modules/demos/events.c index 25dd79fb9..bea3ccd6d 100644 --- a/src/modules/demos/events.c +++ b/src/modules/demos/events.c @@ -17,22 +17,22 @@ int do_moo(int argc, char **argv); int AnopeInit(int argc, char **argv) { - EvtMessage *msg = NULL; - EvtHook *hook = NULL; - int status; - msg = createEventHandler("NICK", my_nick); - status = moduleAddEventHandler(msg); + EvtMessage *msg = NULL; + EvtHook *hook = NULL; + int status; + msg = createEventHandler("NICK", my_nick); + status = moduleAddEventHandler(msg); - hook = createEventHook(EVENT_DB_SAVING, my_save); - status = this->AddEventHook(hook); + hook = createEventHook(EVENT_DB_SAVING, my_save); + status = this->AddEventHook(hook); - hook = createEventHook(EVENT_BOT_FANTASY, do_moo); - status = this->AddEventHook(hook); - - this->SetAuthor(AUTHOR); - this->SetVersion(VERSION); - return MOD_CONT; + hook = createEventHook(EVENT_BOT_FANTASY, do_moo); + status = this->AddEventHook(hook); + + this->SetAuthor(AUTHOR); + this->SetVersion(VERSION); + return MOD_CONT; } void AnopeFini(void) @@ -50,9 +50,9 @@ int my_save(int argc, char **argv) { if(argc>=1) { if (!stricmp(argv[0], EVENT_START)) { - alog("Saving the databases! has started"); + alog("Saving the databases! has started"); } else { - alog("Saving the databases is complete"); + alog("Saving the databases is complete"); } } return MOD_CONT; @@ -68,15 +68,15 @@ int my_save(int argc, char **argv) * @return MOD_CONT or MOD_STOP **/ int do_moo(int argc, char **argv) { - ChannelInfo *ci; - if(argc>=3) { /* We need at least 3 arguments */ + ChannelInfo *ci; + if(argc>=3) { /* We need at least 3 arguments */ if(stricmp(argv[0],"moo")==0) { /* is it meant for us? */ - if((ci = cs_findchan(argv[2]))) { /* channel should always exist */ - anope_cmd_privmsg(ci->bi->nick, ci->name, "%cACTION moo's at %s %c",1,argv[1],1); - return MOD_STOP; /* We've dealt with it, dont let others */ - } + if((ci = cs_findchan(argv[2]))) { /* channel should always exist */ + anope_cmd_privmsg(ci->bi->nick, ci->name, "%cACTION moo's at %s %c",1,argv[1],1); + return MOD_STOP; /* We've dealt with it, dont let others */ + } } - } - return MOD_CONT; /* guess it wasnt for us, pass it on */ + } + return MOD_CONT; /* guess it wasnt for us, pass it on */ } diff --git a/src/modules/demos/hs_conf.c b/src/modules/demos/hs_conf.c index 233aa2ff1..755b1bae4 100644 --- a/src/modules/demos/hs_conf.c +++ b/src/modules/demos/hs_conf.c @@ -14,24 +14,24 @@ int mReadConfig(int argc, char **argv); char *setting; int AnopeInit(int argc, char **argv) { - Command *c; - EvtHook *hook; - int status = 0; + Command *c; + EvtHook *hook; + int status = 0; - setting = NULL; + setting = NULL; - mReadConfig(0,NULL); - - c = createCommand("SHOW",mShowSetting,NULL,-1,-1,-1,-1,-1); - status = this->AddCommand(HOSTSERV, c, MOD_HEAD); + mReadConfig(0,NULL); + + c = createCommand("SHOW",mShowSetting,NULL,-1,-1,-1,-1,-1); + status = this->AddCommand(HOSTSERV, c, MOD_HEAD); - hook = createEventHook(EVENT_RELOAD, mReadConfig); - status = this->AddEventHook(hook); - - if(status!=MOD_ERR_OK) { + hook = createEventHook(EVENT_RELOAD, mReadConfig); + status = this->AddEventHook(hook); + + if(status!=MOD_ERR_OK) { return MOD_STOP; - } - return MOD_CONT; + } + return MOD_CONT; } /** @@ -46,8 +46,8 @@ void AnopeFini(void) { * Simple function to show the user the current config setting **/ int mShowSetting(User *u) { - notice(s_HostServ,u->nick,"Setting in use is [%s]",setting); - return MOD_CONT; + notice(s_HostServ,u->nick,"Setting in use is [%s]",setting); + return MOD_CONT; } /** @@ -55,19 +55,19 @@ int mShowSetting(User *u) { * the EVENT_RELOAD event is recived. **/ int mReadConfig(int argc, char **argv) { - char *tmp=NULL; - Directive d[] = {{"HSConfigSetting", {{PARAM_STRING, PARAM_RELOAD, &tmp}}}}; - moduleGetConfigDirective(d); + char *tmp=NULL; + Directive d[] = {{"HSConfigSetting", {{PARAM_STRING, PARAM_RELOAD, &tmp}}}}; + moduleGetConfigDirective(d); - if(setting) { - free(setting); - } - if(tmp) { + if(setting) { + free(setting); + } + if(tmp) { setting = tmp; - } else { + } else { setting = sstrdup(DEFAULT_SETTING); - } - return MOD_CONT; + } + return MOD_CONT; } diff --git a/src/modules/demos/hs_moo.c b/src/modules/demos/hs_moo.c index 61210271b..ab677527c 100644 --- a/src/modules/demos/hs_moo.c +++ b/src/modules/demos/hs_moo.c @@ -22,22 +22,22 @@ int myHostServMooRootHelp(User *u); /* Function to display extra help t int AnopeInit(int argc, char **argv) /* This will be executed when the module is loaded */ { - Command *c; /* Pointer to a Command */ - int status = 0; /* the status of our new command */ - c = createCommand("moo", hs_moo_show, NULL, -1, -1, -1, -1, -1); /* Create a new command "moo" pointing to hs_moo */ + Command *c; /* Pointer to a Command */ + int status = 0; /* the status of our new command */ + c = createCommand("moo", hs_moo_show, NULL, -1, -1, -1, -1, -1); /* Create a new command "moo" pointing to hs_moo */ - moduleAddHelp(c,myHostServMooHelp); /* add help for all users to this command */ - moduleAddRegHelp(c,myHostServMooRegHelp); /* add extra regular-user only help to this command */ - moduleAddOperHelp(c,myHostServMooOperHelp); /* add extra oper only help to this command */ - moduleAddAdminHelp(c,myHostServMooAdminHelp); /* add extra admin only help to this command */ - moduleAddRootHelp(c,myHostServMooRootHelp); /* add extra root only help to this command */ + moduleAddHelp(c,myHostServMooHelp); /* add help for all users to this command */ + moduleAddRegHelp(c,myHostServMooRegHelp); /* add extra regular-user only help to this command */ + moduleAddOperHelp(c,myHostServMooOperHelp); /* add extra oper only help to this command */ + moduleAddAdminHelp(c,myHostServMooAdminHelp); /* add extra admin only help to this command */ + moduleAddRootHelp(c,myHostServMooRootHelp); /* add extra root only help to this command */ - moduleSetHostHelp(myHostServHelp); /* add us to the .hs help list */ + moduleSetHostHelp(myHostServHelp); /* add us to the .hs help list */ - status = this->AddCommand(HOSTSERV, c, MOD_HEAD); /* Add the command to the HOSTSERV cmd table */ + status = this->AddCommand(HOSTSERV, c, MOD_HEAD); /* Add the command to the HOSTSERV cmd table */ - /* Check if we have any argv's */ - if(argc>0) { + /* Check if we have any argv's */ + if(argc>0) { /* we do, the first will be the nick of the person modload'ing us */ /* or NULL if we were auto-loaded */ if(argv[0]) { @@ -45,24 +45,24 @@ int AnopeInit(int argc, char **argv) /* This will be executed when the mod } else { alog("hs_moo was automatically loaded by anope"); } - } - alog("hs_moo.so: Add Command 'moo' Status: %d",status); /* Log the command being added */ - - moduleAddCallback("test",time(NULL)+dotime("15s"),test,0,NULL); /* set a call-back function to exec in 3 mins time */ - moduleDelCallback("test"); - this->SetAuthor(AUTHOR); /* tell Anope about the author */ - this->SetVersion(VERSION); /* Tell Anope about the verison */ - - if(status!=MOD_ERR_OK) { + } + alog("hs_moo.so: Add Command 'moo' Status: %d",status); /* Log the command being added */ + + moduleAddCallback("test",time(NULL)+dotime("15s"),test,0,NULL); /* set a call-back function to exec in 3 mins time */ + moduleDelCallback("test"); + this->SetAuthor(AUTHOR); /* tell Anope about the author */ + this->SetVersion(VERSION); /* Tell Anope about the verison */ + + if(status!=MOD_ERR_OK) { return MOD_STOP; - } - return MOD_CONT; + } + return MOD_CONT; } int hs_moo_show(User * u) { - notice(s_HostServ, u->nick, "MOO! - This command was loaded via a module!"); /* Just notice the user */ - return MOD_STOP; /* MOD_STOP means we will NOT pass control back to other */ + notice(s_HostServ, u->nick, "MOO! - This command was loaded via a module!"); /* Just notice the user */ + return MOD_STOP; /* MOD_STOP means we will NOT pass control back to other */ } /* modules waiting to handle the /hs moo command! */ int test(int argc, char **argv) { @@ -76,11 +76,11 @@ void AnopeFini(void) } /***************************************************************************************************************************************/ -/* The code below here shows various ways of dealing with the module help system */ +/* The code below here shows various ways of dealing with the module help system */ /***************************************************************************************************************************************/ void myHostServHelp(User *u) { - notice(s_HostServ,u->nick, " MOO Moo's at the user!"); /* this will appear in the help list */ + notice(s_HostServ,u->nick, " MOO Moo's at the user!"); /* this will appear in the help list */ } int myHostServMooHelp(User *u) { diff --git a/src/modules/hs_request.c b/src/modules/hs_request.c index cd9939e96..e9ad605a8 100644 --- a/src/modules/hs_request.c +++ b/src/modules/hs_request.c @@ -1,5 +1,5 @@ /* hs_request.c - Add request and activate functionality to HostServ, - * along with adding +req as optional param to HostServ list. + * along with adding +req as optional param to HostServ list. * * (C) 2003-2008 Anope Team * Contact us at info@anope.org @@ -65,7 +65,7 @@ int hs_help_waiting(User * u); void hs_help(User * u); void my_add_host_request(char *nick, char *vIdent, char *vhost, - char *creator, int32 tmp_time); + char *creator, int32 tmp_time); int my_isvalidchar(const char c); void my_memo_lang(User * u, char *name, int z, int number, ...); void req_send_memos(User * u, char *vHost); @@ -155,11 +155,11 @@ class HSRequest : public Module /* LNG_NO_REQUEST */ "No request for nick %s found.", /* LNG_HELP */ - " REQUEST Request a vHost for your nick", + " REQUEST Request a vHost for your nick", /* LNG_HELP_SETTER */ - " ACTIVATE Approve the requested vHost of a user\n" - " REJECT Reject the requested vHost of a user\n" - " WAITING Convenience command for LIST +req", + " ACTIVATE Approve the requested vHost of a user\n" + " REJECT Reject the requested vHost of a user\n" + " WAITING Convenience command for LIST +req", /* LNG_HELP_REQUEST */ "Request the given vHost to be actived for your nick by the\n" "network administrators. Please be patient while your request\n" @@ -205,11 +205,11 @@ class HSRequest : public Module /* LNG_NO_REQUEST */ "Geen aanvraag voor nick %s gevonden.", /* LNG_HELP */ - " REQUEST Vraag een vHost aan voor je nick", + " REQUEST Vraag een vHost aan voor je nick", /* LNG_HELP_SETTER */ - " ACTIVATE Activeer de aangevraagde vHost voor een gebruiker\n" - " REJECT Keur de aangevraagde vHost voor een gebruiker af\n" - " WAITING Snelkoppeling naar LIST +req", + " ACTIVATE Activeer de aangevraagde vHost voor een gebruiker\n" + " REJECT Keur de aangevraagde vHost voor een gebruiker af\n" + " WAITING Snelkoppeling naar LIST +req", /* LNG_HELP_REQUEST */ "Verzoek de gegeven vHost te activeren voor jouw nick bij de\n" "netwerk beheerders. Het kan even duren voordat je aanvraag\n" @@ -255,11 +255,11 @@ class HSRequest : public Module /* LNG_NO_REQUEST */ "Nenhum pedido encontrado para o nick %s.", /* LNG_HELP */ - " REQUEST Request a vHost for your nick", + " REQUEST Request a vHost for your nick", /* LNG_HELP_SETTER */ - " ACTIVATE Aprova o pedido de vHost de um usuário\n" - " REJECT Recusa o pedido de vHost de um usuário\n" - " WAITING Comando para LISTAR +req", + " ACTIVATE Aprova o pedido de vHost de um usuário\n" + " REJECT Recusa o pedido de vHost de um usuário\n" + " WAITING Comando para LISTAR +req", /* LNG_HELP_REQUEST */ "Solicita a ativação do vHost fornecido em seu nick pelos\n" "administradores da rede. Por favor, tenha paciência\n" @@ -305,11 +305,11 @@ class HSRequest : public Module /* LNG_NO_REQUEST */ "Çàïðîñ íà vHost äëÿ íèêà %s íå íàéäåí.", /* LNG_HELP */ - " REQUEST Çàïðîñ íà vHost äëÿ âàøåãî òåêóùåãî íèêà", + " REQUEST Çàïðîñ íà vHost äëÿ âàøåãî òåêóùåãî íèêà", /* LNG_HELP_SETTER */ - " ACTIVATE Óòâåðäèòü çàïðàøèâàåìûé ïîëüçîâàòåëåì vHost\n" - " REJECT Îòêëîíèòü çàïðàøèâàåìûé ïîëüçîâàòåëåì vHost\n" - " WAITING Ñïèñîê çàïðîñîâ îæèäàþùèõ îáðàáîòêè (àíàëîã LIST +req)", + " ACTIVATE Óòâåðäèòü çàïðàøèâàåìûé ïîëüçîâàòåëåì vHost\n" + " REJECT Îòêëîíèòü çàïðàøèâàåìûé ïîëüçîâàòåëåì vHost\n" + " WAITING Ñïèñîê çàïðîñîâ îæèäàþùèõ îáðàáîòêè (àíàëîã LIST +req)", /* LNG_HELP_REQUEST */ "Îòïðàâëÿåò çàïðîñ íà àêòèâàöèþ vHost, êîòîðûé áóäåò ðàññìîòðåí îäíèì èç\n" "àäìèíèñòðàòîðîâ ñåòè. Ïðîñüáà ïðîÿâèòü òåðïåíèå, ïîêà çàïðîñ\n" @@ -355,11 +355,11 @@ class HSRequest : public Module /* LNG_NO_REQUEST */ "Nessuna richiesta trovata per il nick %s.", /* LNG_HELP */ - " REQUEST Richiede un vHost per il tuo nick", + " REQUEST Richiede un vHost per il tuo nick", /* LNG_HELP_SETTER */ - " ACTIVATE Approva il vHost richiesto di un utente\n" - " REJECT Rifiuta il vHost richiesto di un utente\n" - " WAITING Comando per LIST +req", + " ACTIVATE Approva il vHost richiesto di un utente\n" + " REJECT Rifiuta il vHost richiesto di un utente\n" + " WAITING Comando per LIST +req", /* LNG_HELP_REQUEST */ "Richiede l'attivazione del vHost specificato per il tuo nick da parte\n" "degli amministratori di rete. Sei pregato di pazientare finchè la tua\n" @@ -400,577 +400,577 @@ class HSRequest : public Module int hs_do_request(User * u) { - char *cur_buffer; - char *nick; - char *rawhostmask; - char hostmask[HOSTMAX]; - NickAlias *na; - int32 tmp_time; - char *s; - char *vIdent = NULL; - time_t now = time(NULL); - - cur_buffer = moduleGetLastBuffer(); - nick = u->nick; - rawhostmask = myStrGetToken(cur_buffer, ' ', 0); - - if (!nick || !rawhostmask) { - if (rawhostmask) - free(rawhostmask); - moduleNoticeLang(s_HostServ, u, LNG_REQUEST_SYNTAX); - return MOD_CONT; - } - - vIdent = myStrGetOnlyToken(rawhostmask, '@', 0); /* Get the first substring, @ as delimiter */ - if (vIdent) { - rawhostmask = myStrGetTokenRemainder(rawhostmask, '@', 1); /* get the remaining string */ - if (!rawhostmask) { - moduleNoticeLang(s_HostServ, u, LNG_REQUEST_SYNTAX); - free(vIdent); - return MOD_CONT; - } - if (strlen(vIdent) > USERMAX - 1) { - notice_lang(s_HostServ, u, HOST_SET_IDENTTOOLONG, USERMAX); - free(vIdent); - free(rawhostmask); - return MOD_CONT; - } else { - for (s = vIdent; *s; s++) { - if (!my_isvalidchar(*s)) { - notice_lang(s_HostServ, u, HOST_SET_IDENT_ERROR); - free(vIdent); - free(rawhostmask); - return MOD_CONT; - } - } - } - if (!ircd->vident) { - notice_lang(s_HostServ, u, HOST_NO_VIDENT); - free(vIdent); - free(rawhostmask); - return MOD_CONT; - } - } - if (strlen(rawhostmask) < HOSTMAX - 1) { - snprintf(hostmask, HOSTMAX, "%s", rawhostmask); - } else { - notice_lang(s_HostServ, u, HOST_SET_TOOLONG, HOSTMAX); - if (vIdent) - free(vIdent); - free(rawhostmask); - return MOD_CONT; - } - - if (!isValidHost(hostmask, 3)) { - notice_lang(s_HostServ, u, HOST_SET_ERROR); - if (vIdent) - free(vIdent); - free(rawhostmask); - return MOD_CONT; - } - - tmp_time = time(NULL); - if ((na = findnick(nick))) { - if (HSRequestMemoOper || HSRequestMemoSetters) { - if (MSSendDelay > 0 && u - && u->lastmemosend + MSSendDelay > now) { - moduleNoticeLang(s_HostServ, u, LNG_REQUEST_WAIT, - MSSendDelay); - u->lastmemosend = now; - if (vIdent) - free(vIdent); - free(rawhostmask); - return MOD_CONT; - } - } - my_add_host_request(nick, vIdent, hostmask, u->nick, tmp_time); - - moduleNoticeLang(s_HostServ, u, LNG_REQUESTED); - req_send_memos(u, hostmask); - alog("New vHost Requested by %s", nick); - } else { - notice_lang(s_HostServ, u, HOST_NOREG, nick); - } - - if (vIdent) - free(vIdent); - free(rawhostmask); - - return MOD_CONT; + char *cur_buffer; + char *nick; + char *rawhostmask; + char hostmask[HOSTMAX]; + NickAlias *na; + int32 tmp_time; + char *s; + char *vIdent = NULL; + time_t now = time(NULL); + + cur_buffer = moduleGetLastBuffer(); + nick = u->nick; + rawhostmask = myStrGetToken(cur_buffer, ' ', 0); + + if (!nick || !rawhostmask) { + if (rawhostmask) + free(rawhostmask); + moduleNoticeLang(s_HostServ, u, LNG_REQUEST_SYNTAX); + return MOD_CONT; + } + + vIdent = myStrGetOnlyToken(rawhostmask, '@', 0); /* Get the first substring, @ as delimiter */ + if (vIdent) { + rawhostmask = myStrGetTokenRemainder(rawhostmask, '@', 1); /* get the remaining string */ + if (!rawhostmask) { + moduleNoticeLang(s_HostServ, u, LNG_REQUEST_SYNTAX); + free(vIdent); + return MOD_CONT; + } + if (strlen(vIdent) > USERMAX - 1) { + notice_lang(s_HostServ, u, HOST_SET_IDENTTOOLONG, USERMAX); + free(vIdent); + free(rawhostmask); + return MOD_CONT; + } else { + for (s = vIdent; *s; s++) { + if (!my_isvalidchar(*s)) { + notice_lang(s_HostServ, u, HOST_SET_IDENT_ERROR); + free(vIdent); + free(rawhostmask); + return MOD_CONT; + } + } + } + if (!ircd->vident) { + notice_lang(s_HostServ, u, HOST_NO_VIDENT); + free(vIdent); + free(rawhostmask); + return MOD_CONT; + } + } + if (strlen(rawhostmask) < HOSTMAX - 1) { + snprintf(hostmask, HOSTMAX, "%s", rawhostmask); + } else { + notice_lang(s_HostServ, u, HOST_SET_TOOLONG, HOSTMAX); + if (vIdent) + free(vIdent); + free(rawhostmask); + return MOD_CONT; + } + + if (!isValidHost(hostmask, 3)) { + notice_lang(s_HostServ, u, HOST_SET_ERROR); + if (vIdent) + free(vIdent); + free(rawhostmask); + return MOD_CONT; + } + + tmp_time = time(NULL); + if ((na = findnick(nick))) { + if (HSRequestMemoOper || HSRequestMemoSetters) { + if (MSSendDelay > 0 && u + && u->lastmemosend + MSSendDelay > now) { + moduleNoticeLang(s_HostServ, u, LNG_REQUEST_WAIT, + MSSendDelay); + u->lastmemosend = now; + if (vIdent) + free(vIdent); + free(rawhostmask); + return MOD_CONT; + } + } + my_add_host_request(nick, vIdent, hostmask, u->nick, tmp_time); + + moduleNoticeLang(s_HostServ, u, LNG_REQUESTED); + req_send_memos(u, hostmask); + alog("New vHost Requested by %s", nick); + } else { + notice_lang(s_HostServ, u, HOST_NOREG, nick); + } + + if (vIdent) + free(vIdent); + free(rawhostmask); + + return MOD_CONT; } void my_memo_lang(User * u, char *name, int z, int number, ...) { - va_list va; - char buffer[4096], outbuf[4096]; - char *fmt = NULL; - int lang = LANG_EN_US; - char *s, *t, *buf; - User *u2; - - if ((mod_current_module_name) - && (!mod_current_module - || mod_current_module_name != mod_current_module->name)) - mod_current_module = findModule(mod_current_module_name); - - u2 = finduser(name); - /* Find the users lang, and use it if we cant */ - if (u2 && u2->na && u2->na->nc) - lang = u2->na->nc->language; - - /* If the users lang isnt supported, drop back to enlgish */ - if (mod_current_module->lang[lang].argc == 0) - lang = LANG_EN_US; - - /* If the requested lang string exists for the language */ - if (mod_current_module->lang[lang].argc > number) { - fmt = mod_current_module->lang[lang].argv[number]; - - buf = sstrdup(fmt); - s = buf; - while (*s) { - t = s; - s += strcspn(s, "\n"); - if (*s) - *s++ = '\0'; - strscpy(outbuf, t, sizeof(outbuf)); - - va_start(va, number); - vsnprintf(buffer, 4095, outbuf, va); - va_end(va); - memo_send(u, name, buffer, z); - } - free(buf); - } else { - alog("%s: INVALID language string call, language: [%d], String [%d]", mod_current_module->name.c_str(), lang, number); - } + va_list va; + char buffer[4096], outbuf[4096]; + char *fmt = NULL; + int lang = LANG_EN_US; + char *s, *t, *buf; + User *u2; + + if ((mod_current_module_name) + && (!mod_current_module + || mod_current_module_name != mod_current_module->name)) + mod_current_module = findModule(mod_current_module_name); + + u2 = finduser(name); + /* Find the users lang, and use it if we cant */ + if (u2 && u2->na && u2->na->nc) + lang = u2->na->nc->language; + + /* If the users lang isnt supported, drop back to enlgish */ + if (mod_current_module->lang[lang].argc == 0) + lang = LANG_EN_US; + + /* If the requested lang string exists for the language */ + if (mod_current_module->lang[lang].argc > number) { + fmt = mod_current_module->lang[lang].argv[number]; + + buf = sstrdup(fmt); + s = buf; + while (*s) { + t = s; + s += strcspn(s, "\n"); + if (*s) + *s++ = '\0'; + strscpy(outbuf, t, sizeof(outbuf)); + + va_start(va, number); + vsnprintf(buffer, 4095, outbuf, va); + va_end(va); + memo_send(u, name, buffer, z); + } + free(buf); + } else { + alog("%s: INVALID language string call, language: [%d], String [%d]", mod_current_module->name.c_str(), lang, number); + } } void req_send_memos(User * u, char *vHost) { - int i; - int z = 2; - - if (checkDefCon(DEFCON_NO_NEW_MEMOS)) - return; - - if (HSRequestMemoOper == 1) { - for (i = 0; i < servopers.count; i++) { - my_memo_lang(u, (((NickCore *) servopers.list[i])->display), z, - LNG_REQUEST_MEMO, vHost); - } - for (i = 0; i < servadmins.count; i++) { - my_memo_lang(u, (((NickCore *) servadmins.list[i])->display), - z, LNG_REQUEST_MEMO, vHost); - } - for (i = 0; i < RootNumber; i++) { - my_memo_lang(u, ServicesRoots[i], z, LNG_REQUEST_MEMO, vHost); - } - } - if (HSRequestMemoSetters == 1) { - for (i = 0; i < HostNumber; i++) { - my_memo_lang(u, HostSetters[i], z, LNG_REQUEST_MEMO, vHost); - } - } + int i; + int z = 2; + + if (checkDefCon(DEFCON_NO_NEW_MEMOS)) + return; + + if (HSRequestMemoOper == 1) { + for (i = 0; i < servopers.count; i++) { + my_memo_lang(u, (((NickCore *) servopers.list[i])->display), z, + LNG_REQUEST_MEMO, vHost); + } + for (i = 0; i < servadmins.count; i++) { + my_memo_lang(u, (((NickCore *) servadmins.list[i])->display), + z, LNG_REQUEST_MEMO, vHost); + } + for (i = 0; i < RootNumber; i++) { + my_memo_lang(u, ServicesRoots[i], z, LNG_REQUEST_MEMO, vHost); + } + } + if (HSRequestMemoSetters == 1) { + for (i = 0; i < HostNumber; i++) { + my_memo_lang(u, HostSetters[i], z, LNG_REQUEST_MEMO, vHost); + } + } } int ns_do_drop(User * u) { - HostCore *tmp; - bool found = false; - NickAlias *na; + HostCore *tmp; + bool found = false; + NickAlias *na; - na = findnick(u->nick); - tmp = findHostCore(hs_request_head, u->nick, &found); + na = findnick(u->nick); + tmp = findHostCore(hs_request_head, u->nick, &found); - if (found && na) - hs_request_head = deleteHostCore(hs_request_head, tmp); + if (found && na) + hs_request_head = deleteHostCore(hs_request_head, tmp); - return MOD_CONT; + return MOD_CONT; } int hs_do_reject(User * u) { - char *cur_buffer; - char *nick; - char *reason; - HostCore *tmp, *hc; - bool found = false; - - cur_buffer = moduleGetLastBuffer(); - nick = myStrGetToken(cur_buffer, ' ', 0); - reason = myStrGetTokenRemainder(cur_buffer, ' ', 1); - - if (!nick) { - moduleNoticeLang(s_HostServ, u, LNG_REJECT_SYNTAX); - if (reason) - free(reason); - return MOD_CONT; - } - - tmp = findHostCore(hs_request_head, nick, &found); - if (found) { - if (!tmp) - hc = hs_request_head; - else - hc = tmp->next; - - if (HSRequestMemoUser) { - if (reason) - my_memo_lang(u, hc->nick, 2, LNG_REJECT_MEMO_REASON, - reason); - else - my_memo_lang(u, hc->nick, 2, LNG_REJECT_MEMO); - } - - hs_request_head = deleteHostCore(hs_request_head, tmp); - moduleNoticeLang(s_HostServ, u, LNG_REJECTED, nick); - alog("Host Request for %s rejected by %s (%s)", nick, u->nick, - reason ? reason : ""); - } else { - moduleNoticeLang(s_HostServ, u, LNG_NO_REQUEST, nick); - } - - free(nick); - if (reason) - free(reason); - - return MOD_CONT; + char *cur_buffer; + char *nick; + char *reason; + HostCore *tmp, *hc; + bool found = false; + + cur_buffer = moduleGetLastBuffer(); + nick = myStrGetToken(cur_buffer, ' ', 0); + reason = myStrGetTokenRemainder(cur_buffer, ' ', 1); + + if (!nick) { + moduleNoticeLang(s_HostServ, u, LNG_REJECT_SYNTAX); + if (reason) + free(reason); + return MOD_CONT; + } + + tmp = findHostCore(hs_request_head, nick, &found); + if (found) { + if (!tmp) + hc = hs_request_head; + else + hc = tmp->next; + + if (HSRequestMemoUser) { + if (reason) + my_memo_lang(u, hc->nick, 2, LNG_REJECT_MEMO_REASON, + reason); + else + my_memo_lang(u, hc->nick, 2, LNG_REJECT_MEMO); + } + + hs_request_head = deleteHostCore(hs_request_head, tmp); + moduleNoticeLang(s_HostServ, u, LNG_REJECTED, nick); + alog("Host Request for %s rejected by %s (%s)", nick, u->nick, + reason ? reason : ""); + } else { + moduleNoticeLang(s_HostServ, u, LNG_NO_REQUEST, nick); + } + + free(nick); + if (reason) + free(reason); + + return MOD_CONT; } int hs_do_activate(User * u) { - char *cur_buffer; - char *nick; - NickAlias *na; - HostCore *tmp, *hc; - bool found = false; - - cur_buffer = moduleGetLastBuffer(); - nick = myStrGetToken(cur_buffer, ' ', 0); - - if (!nick) { - moduleNoticeLang(s_HostServ, u, LNG_ACTIVATE_SYNTAX); - return MOD_CONT; - } - - if ((na = findnick(nick))) { - tmp = findHostCore(hs_request_head, nick, &found); - if (found) { - if (!tmp) - hc = hs_request_head; - else - hc = tmp->next; - - addHostCore(hc->nick, hc->vIdent, hc->vHost, u->nick, - time(NULL)); - - if (HSRequestMemoUser) - my_memo_lang(u, hc->nick, 2, LNG_ACTIVATE_MEMO); - - hs_request_head = deleteHostCore(hs_request_head, tmp); - moduleNoticeLang(s_HostServ, u, LNG_ACTIVATED, nick); - alog("Host Request for %s activated by %s", nick, u->nick); - } else { - moduleNoticeLang(s_HostServ, u, LNG_NO_REQUEST, nick); - } - } else { - /* Should be "User Not Found" instead */ - moduleNoticeLang(s_HostServ, u, LNG_ACTIVATE_SYNTAX); - } - - free(nick); - return MOD_CONT; + char *cur_buffer; + char *nick; + NickAlias *na; + HostCore *tmp, *hc; + bool found = false; + + cur_buffer = moduleGetLastBuffer(); + nick = myStrGetToken(cur_buffer, ' ', 0); + + if (!nick) { + moduleNoticeLang(s_HostServ, u, LNG_ACTIVATE_SYNTAX); + return MOD_CONT; + } + + if ((na = findnick(nick))) { + tmp = findHostCore(hs_request_head, nick, &found); + if (found) { + if (!tmp) + hc = hs_request_head; + else + hc = tmp->next; + + addHostCore(hc->nick, hc->vIdent, hc->vHost, u->nick, + time(NULL)); + + if (HSRequestMemoUser) + my_memo_lang(u, hc->nick, 2, LNG_ACTIVATE_MEMO); + + hs_request_head = deleteHostCore(hs_request_head, tmp); + moduleNoticeLang(s_HostServ, u, LNG_ACTIVATED, nick); + alog("Host Request for %s activated by %s", nick, u->nick); + } else { + moduleNoticeLang(s_HostServ, u, LNG_NO_REQUEST, nick); + } + } else { + /* Should be "User Not Found" instead */ + moduleNoticeLang(s_HostServ, u, LNG_ACTIVATE_SYNTAX); + } + + free(nick); + return MOD_CONT; } void my_add_host_request(char *nick, char *vIdent, char *vhost, - char *creator, int32 tmp_time) + char *creator, int32 tmp_time) { - HostCore *tmp; - bool found = false; - - if (!hs_request_head) { - hs_request_head = - createHostCorelist(hs_request_head, nick, vIdent, vhost, - creator, tmp_time); - } else { - tmp = findHostCore(hs_request_head, nick, &found); - if (!found) { - hs_request_head = - insertHostCore(hs_request_head, tmp, nick, vIdent, vhost, - creator, tmp_time); - } else { - hs_request_head = deleteHostCore(hs_request_head, tmp); /* delete the old entry */ - my_add_host_request(nick, vIdent, vhost, creator, tmp_time); /* recursive call to add new entry */ - } - } + HostCore *tmp; + bool found = false; + + if (!hs_request_head) { + hs_request_head = + createHostCorelist(hs_request_head, nick, vIdent, vhost, + creator, tmp_time); + } else { + tmp = findHostCore(hs_request_head, nick, &found); + if (!found) { + hs_request_head = + insertHostCore(hs_request_head, tmp, nick, vIdent, vhost, + creator, tmp_time); + } else { + hs_request_head = deleteHostCore(hs_request_head, tmp); /* delete the old entry */ + my_add_host_request(nick, vIdent, vhost, creator, tmp_time); /* recursive call to add new entry */ + } + } } int my_isvalidchar(const char c) { - if (((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z')) - || ((c >= '0') && (c <= '9')) || (c == '.') || (c == '-')) - return 1; - else - return 0; + if (((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z')) + || ((c >= '0') && (c <= '9')) || (c == '.') || (c == '-')) + return 1; + else + return 0; } int hs_do_list_out(User * u) { - char *key; + char *key; - key = moduleGetLastBuffer(); - if (!key) - return MOD_CONT; + key = moduleGetLastBuffer(); + if (!key) + return MOD_CONT; - if (stricmp(key, "+req") != 0) - return MOD_CONT; + if (stricmp(key, "+req") != 0) + return MOD_CONT; - show_list(u); + show_list(u); - return MOD_CONT; + return MOD_CONT; } int hs_do_waiting(User * u) { - show_list(u); + show_list(u); - return MOD_CONT; + return MOD_CONT; } void show_list(User * u) { - struct tm *tm; - char buf[BUFSIZE]; - int counter = 1; - int from = 0, to = 0; - int display_counter = 0; - HostCore *current; - - current = hs_request_head; - while (current) { - if ((((counter >= from) && (counter <= to)) - || ((from == 0) && (to == 0))) - && (display_counter < NSListMax)) { - display_counter++; - tm = localtime(¤t->time); - strftime(buf, sizeof(buf), - getstring(NULL, STRFTIME_DATE_TIME_FORMAT), tm); - if (current->vIdent) - notice_lang(s_HostServ, u, HOST_IDENT_ENTRY, counter, - current->nick, current->vIdent, current->vHost, - current->creator, buf); - else - notice_lang(s_HostServ, u, HOST_ENTRY, counter, - current->nick, current->vHost, - current->creator, buf); - } - counter++; - current = current->next; - } - notice_lang(s_HostServ, u, HOST_LIST_FOOTER, display_counter); + struct tm *tm; + char buf[BUFSIZE]; + int counter = 1; + int from = 0, to = 0; + int display_counter = 0; + HostCore *current; + + current = hs_request_head; + while (current) { + if ((((counter >= from) && (counter <= to)) + || ((from == 0) && (to == 0))) + && (display_counter < NSListMax)) { + display_counter++; + tm = localtime(¤t->time); + strftime(buf, sizeof(buf), + getstring(NULL, STRFTIME_DATE_TIME_FORMAT), tm); + if (current->vIdent) + notice_lang(s_HostServ, u, HOST_IDENT_ENTRY, counter, + current->nick, current->vIdent, current->vHost, + current->creator, buf); + else + notice_lang(s_HostServ, u, HOST_ENTRY, counter, + current->nick, current->vHost, + current->creator, buf); + } + counter++; + current = current->next; + } + notice_lang(s_HostServ, u, HOST_LIST_FOOTER, display_counter); } int hs_help_request(User * u) { - moduleNoticeLang(s_HostServ, u, LNG_REQUEST_SYNTAX); - ircdproto->SendMessage(findbot(s_HostServ), u->nick, " "); - moduleNoticeLang(s_HostServ, u, LNG_HELP_REQUEST); + moduleNoticeLang(s_HostServ, u, LNG_REQUEST_SYNTAX); + ircdproto->SendMessage(findbot(s_HostServ), u->nick, " "); + moduleNoticeLang(s_HostServ, u, LNG_HELP_REQUEST); - return MOD_CONT; + return MOD_CONT; } int hs_help_activate(User * u) { - if (is_host_setter(u)) { - moduleNoticeLang(s_HostServ, u, LNG_ACTIVATE_SYNTAX); - ircdproto->SendMessage(findbot(s_HostServ), u->nick, " "); - moduleNoticeLang(s_HostServ, u, LNG_HELP_ACTIVATE); - if (HSRequestMemoUser) - moduleNoticeLang(s_HostServ, u, LNG_HELP_ACTIVATE_MEMO); - } else { - notice_lang(s_HostServ, u, NO_HELP_AVAILABLE, "ACTIVATE"); - } - - return MOD_CONT; + if (is_host_setter(u)) { + moduleNoticeLang(s_HostServ, u, LNG_ACTIVATE_SYNTAX); + ircdproto->SendMessage(findbot(s_HostServ), u->nick, " "); + moduleNoticeLang(s_HostServ, u, LNG_HELP_ACTIVATE); + if (HSRequestMemoUser) + moduleNoticeLang(s_HostServ, u, LNG_HELP_ACTIVATE_MEMO); + } else { + notice_lang(s_HostServ, u, NO_HELP_AVAILABLE, "ACTIVATE"); + } + + return MOD_CONT; } int hs_help_reject(User * u) { - if (is_host_setter(u)) { - moduleNoticeLang(s_HostServ, u, LNG_REJECT_SYNTAX); - ircdproto->SendMessage(findbot(s_HostServ), u->nick, " "); - moduleNoticeLang(s_HostServ, u, LNG_HELP_REJECT); - if (HSRequestMemoUser) - moduleNoticeLang(s_HostServ, u, LNG_HELP_REJECT_MEMO); - } else { - notice_lang(s_HostServ, u, NO_HELP_AVAILABLE, "REJECT"); - } - - return MOD_CONT; + if (is_host_setter(u)) { + moduleNoticeLang(s_HostServ, u, LNG_REJECT_SYNTAX); + ircdproto->SendMessage(findbot(s_HostServ), u->nick, " "); + moduleNoticeLang(s_HostServ, u, LNG_HELP_REJECT); + if (HSRequestMemoUser) + moduleNoticeLang(s_HostServ, u, LNG_HELP_REJECT_MEMO); + } else { + notice_lang(s_HostServ, u, NO_HELP_AVAILABLE, "REJECT"); + } + + return MOD_CONT; } int hs_help_waiting(User * u) { - if (is_host_setter(u)) { - moduleNoticeLang(s_HostServ, u, LNG_WAITING_SYNTAX); - ircdproto->SendMessage(findbot(s_HostServ), u->nick, " "); - moduleNoticeLang(s_HostServ, u, LNG_HELP_WAITING); - } else { - notice_lang(s_HostServ, u, NO_HELP_AVAILABLE, "WAITING"); - } - - return MOD_CONT; + if (is_host_setter(u)) { + moduleNoticeLang(s_HostServ, u, LNG_WAITING_SYNTAX); + ircdproto->SendMessage(findbot(s_HostServ), u->nick, " "); + moduleNoticeLang(s_HostServ, u, LNG_HELP_WAITING); + } else { + notice_lang(s_HostServ, u, NO_HELP_AVAILABLE, "WAITING"); + } + + return MOD_CONT; } void hs_help(User * u) { - moduleNoticeLang(s_HostServ, u, LNG_HELP); - if (is_host_setter(u)) - moduleNoticeLang(s_HostServ, u, LNG_HELP_SETTER); + moduleNoticeLang(s_HostServ, u, LNG_HELP); + if (is_host_setter(u)) + moduleNoticeLang(s_HostServ, u, LNG_HELP_SETTER); } void hsreq_load_db(void) { - FILE *fp; - const char *filename; - char readbuf[1024]; - char *nick, *vident, *vhost, *creator, *tmp; - int32 tmp_time; - char *buf; - - if (HSRequestDBName) - filename = HSRequestDBName; - else - filename = HSREQ_DEFAULT_DBNAME; - - fp = fopen(filename, "r"); - if (!fp) { - alog("[hs_request] Unable to open database ('%s') for reading", - filename); - return; - } - - while (fgets(readbuf, 1024, fp)) { - buf = normalizeBuffer(readbuf); - if (buf || *buf) { - nick = myStrGetToken(buf, ':', 0); - vident = myStrGetToken(buf, ':', 1); - vhost = myStrGetToken(buf, ':', 2); - tmp = myStrGetToken(buf, ':', 3); - if (tmp) { - tmp_time = strtol(tmp, (char **) NULL, 16); - free(tmp); - } else { - tmp_time = 0; - } - creator = myStrGetToken(buf, ':', 4); - if (!nick || !vident || !vhost || !creator) { - alog("[hs_request] Error while reading database, skipping record"); - continue; - } - if (stricmp(vident, "(null)") == 0) { - free(vident); - vident = NULL; - } - my_add_host_request(nick, vident, vhost, creator, tmp_time); - free(nick); - free(vhost); - free(creator); - if (vident) - free(vident); - } - free(buf); - } - - fclose(fp); - - if (debug) - alog("[hs_request] Succesfully loaded database"); + FILE *fp; + const char *filename; + char readbuf[1024]; + char *nick, *vident, *vhost, *creator, *tmp; + int32 tmp_time; + char *buf; + + if (HSRequestDBName) + filename = HSRequestDBName; + else + filename = HSREQ_DEFAULT_DBNAME; + + fp = fopen(filename, "r"); + if (!fp) { + alog("[hs_request] Unable to open database ('%s') for reading", + filename); + return; + } + + while (fgets(readbuf, 1024, fp)) { + buf = normalizeBuffer(readbuf); + if (buf || *buf) { + nick = myStrGetToken(buf, ':', 0); + vident = myStrGetToken(buf, ':', 1); + vhost = myStrGetToken(buf, ':', 2); + tmp = myStrGetToken(buf, ':', 3); + if (tmp) { + tmp_time = strtol(tmp, (char **) NULL, 16); + free(tmp); + } else { + tmp_time = 0; + } + creator = myStrGetToken(buf, ':', 4); + if (!nick || !vident || !vhost || !creator) { + alog("[hs_request] Error while reading database, skipping record"); + continue; + } + if (stricmp(vident, "(null)") == 0) { + free(vident); + vident = NULL; + } + my_add_host_request(nick, vident, vhost, creator, tmp_time); + free(nick); + free(vhost); + free(creator); + if (vident) + free(vident); + } + free(buf); + } + + fclose(fp); + + if (debug) + alog("[hs_request] Succesfully loaded database"); } void hsreq_save_db(void) { - FILE *fp; - const char *filename; - const char *vident; - HostCore *current; - - if (HSRequestDBName) - filename = HSRequestDBName; - else - filename = HSREQ_DEFAULT_DBNAME; - - fp = fopen(filename, "w"); - if (!fp) { - alog("[hs_request] Unable to open database ('%s') for writing", - filename); - return; - } - - current = hs_request_head; - while (current) { - vident = (current->vIdent ? current->vIdent : "(null)"); - fprintf(fp, "%s:%s:%s:%X:%s\n", current->nick, vident, - current->vHost, (uint32) current->time, current->creator); - current = current->next; - } - - fclose(fp); - - if (debug) - alog("[hs_request] Succesfully saved database"); + FILE *fp; + const char *filename; + const char *vident; + HostCore *current; + + if (HSRequestDBName) + filename = HSRequestDBName; + else + filename = HSREQ_DEFAULT_DBNAME; + + fp = fopen(filename, "w"); + if (!fp) { + alog("[hs_request] Unable to open database ('%s') for writing", + filename); + return; + } + + current = hs_request_head; + while (current) { + vident = (current->vIdent ? current->vIdent : "(null)"); + fprintf(fp, "%s:%s:%s:%X:%s\n", current->nick, vident, + current->vHost, (uint32) current->time, current->creator); + current = current->next; + } + + fclose(fp); + + if (debug) + alog("[hs_request] Succesfully saved database"); } int hsreqevt_db_saving(int argc, char **argv) { - if ((argc >= 1) && (stricmp(argv[0], EVENT_START) == 0)) - hsreq_save_db(); + if ((argc >= 1) && (stricmp(argv[0], EVENT_START) == 0)) + hsreq_save_db(); - return MOD_CONT; + return MOD_CONT; } int hsreqevt_db_backup(int argc, char **argv) { - if ((argc >= 1) && (stricmp(argv[0], EVENT_START) == 0)) { - if (HSRequestDBName) - ModuleDatabaseBackup(HSRequestDBName); - else - ModuleDatabaseBackup(HSREQ_DEFAULT_DBNAME); + if ((argc >= 1) && (stricmp(argv[0], EVENT_START) == 0)) { + if (HSRequestDBName) + ModuleDatabaseBackup(HSRequestDBName); + else + ModuleDatabaseBackup(HSREQ_DEFAULT_DBNAME); } - return MOD_CONT; + return MOD_CONT; } void my_load_config(void) { - int i; - char *tmp = NULL; - - Directive confvalues[][1] = { - {{"HSRequestMemoUser", - {{PARAM_SET, PARAM_RELOAD, &HSRequestMemoUser}}}}, - {{"HSRequestMemoOper", - {{PARAM_SET, PARAM_RELOAD, &HSRequestMemoOper}}}}, - {{"HSRequestMemoSetters", - {{PARAM_SET, PARAM_RELOAD, &HSRequestMemoSetters}}}}, - {{"HSRequestDBName", {{PARAM_STRING, PARAM_RELOAD, &tmp}}}} - }; - - for (i = 0; i < 4; i++) - moduleGetConfigDirective(confvalues[i]); - - if (tmp) { - if (HSRequestDBName) - free(HSRequestDBName); - HSRequestDBName = sstrdup(tmp); - } else { - HSRequestDBName = sstrdup(HSREQ_DEFAULT_DBNAME); - } - - if (debug) - alog("debug: [hs_request] Set config vars: MemoUser=%d MemoOper=%d MemoSetters=%d DBName='%s'", HSRequestMemoUser, HSRequestMemoOper, HSRequestMemoSetters, HSRequestDBName); + int i; + char *tmp = NULL; + + Directive confvalues[][1] = { + {{"HSRequestMemoUser", + {{PARAM_SET, PARAM_RELOAD, &HSRequestMemoUser}}}}, + {{"HSRequestMemoOper", + {{PARAM_SET, PARAM_RELOAD, &HSRequestMemoOper}}}}, + {{"HSRequestMemoSetters", + {{PARAM_SET, PARAM_RELOAD, &HSRequestMemoSetters}}}}, + {{"HSRequestDBName", {{PARAM_STRING, PARAM_RELOAD, &tmp}}}} + }; + + for (i = 0; i < 4; i++) + moduleGetConfigDirective(confvalues[i]); + + if (tmp) { + if (HSRequestDBName) + free(HSRequestDBName); + HSRequestDBName = sstrdup(tmp); + } else { + HSRequestDBName = sstrdup(HSREQ_DEFAULT_DBNAME); + } + + if (debug) + alog("debug: [hs_request] Set config vars: MemoUser=%d MemoOper=%d MemoSetters=%d DBName='%s'", HSRequestMemoUser, HSRequestMemoOper, HSRequestMemoSetters, HSRequestDBName); } MODULE_INIT("hs_request", HSRequest) diff --git a/src/modules/ns_maxemail.c b/src/modules/ns_maxemail.c index ef5b8b167..b2f82eb41 100644 --- a/src/modules/ns_maxemail.c +++ b/src/modules/ns_maxemail.c @@ -1,5 +1,5 @@ /* ns_maxemail.c - Limit the amount of times an email address - * can be used for a NickServ account. + * can be used for a NickServ account. * * (C) 2003-2008 Anope Team * Contact us at info@anope.org @@ -108,104 +108,104 @@ class NSMaxEmail : public Module int count_email_in_use(char *email, User * u) { - NickCore *nc; - int i; - int count = 0; + NickCore *nc; + int i; + int count = 0; - if (!email) - return 0; + if (!email) + return 0; - for (i = 0; i < 1024; i++) { - for (nc = nclists[i]; nc; nc = nc->next) { - if (!(u->na && u->na->nc && (u->na->nc == nc)) && nc->email && (stricmp(nc->email, email) == 0)) - count++; - } - } + for (i = 0; i < 1024; i++) { + for (nc = nclists[i]; nc; nc = nc->next) { + if (!(u->na && u->na->nc && (u->na->nc == nc)) && nc->email && (stricmp(nc->email, email) == 0)) + count++; + } + } - return count; + return count; } int check_email_limit_reached(char *email, User * u) { - if ((NSEmailMax < 1) || !email || is_services_admin(u)) - return MOD_CONT; + if ((NSEmailMax < 1) || !email || is_services_admin(u)) + return MOD_CONT; - if (count_email_in_use(email, u) < NSEmailMax) - return MOD_CONT; + if (count_email_in_use(email, u) < NSEmailMax) + return MOD_CONT; - if (NSEmailMax == 1) - moduleNoticeLang(s_NickServ, u, LNG_NSEMAILMAX_REACHED_ONE); - else - moduleNoticeLang(s_NickServ, u, LNG_NSEMAILMAX_REACHED, - NSEmailMax); + if (NSEmailMax == 1) + moduleNoticeLang(s_NickServ, u, LNG_NSEMAILMAX_REACHED_ONE); + else + moduleNoticeLang(s_NickServ, u, LNG_NSEMAILMAX_REACHED, + NSEmailMax); - return MOD_STOP; + return MOD_STOP; } int my_ns_register(User * u) { - char *cur_buffer; - char *email; - int ret; + char *cur_buffer; + char *email; + int ret; - cur_buffer = moduleGetLastBuffer(); - email = myStrGetToken(cur_buffer, ' ', 1); + cur_buffer = moduleGetLastBuffer(); + email = myStrGetToken(cur_buffer, ' ', 1); if (!email) return MOD_CONT; - ret = check_email_limit_reached(email, u); - free(email); + ret = check_email_limit_reached(email, u); + free(email); - return ret; + return ret; } int my_ns_set(User * u) { - char *cur_buffer; - char *set; - char *email; - int ret; + char *cur_buffer; + char *set; + char *email; + int ret; - cur_buffer = moduleGetLastBuffer(); - set = myStrGetToken(cur_buffer, ' ', 0); + cur_buffer = moduleGetLastBuffer(); + set = myStrGetToken(cur_buffer, ' ', 0); if (!set) return MOD_CONT; - if (stricmp(set, "email") != 0) { - free(set); - return MOD_CONT; - } + if (stricmp(set, "email") != 0) { + free(set); + return MOD_CONT; + } - free(set); - email = myStrGetToken(cur_buffer, ' ', 1); + free(set); + email = myStrGetToken(cur_buffer, ' ', 1); if (!email) return MOD_CONT; - ret = check_email_limit_reached(email, u); - free(email); + ret = check_email_limit_reached(email, u); + free(email); - return ret; + return ret; } int my_event_reload(int argc, char **argv) { - if ((argc > 0) && (stricmp(argv[0], EVENT_START) == 0)) - my_load_config(); + if ((argc > 0) && (stricmp(argv[0], EVENT_START) == 0)) + my_load_config(); - return MOD_CONT; + return MOD_CONT; } void my_load_config(void) { - Directive confvalues[] = { - {"NSEmailMax", {{PARAM_INT, PARAM_RELOAD, &NSEmailMax}}} - }; + Directive confvalues[] = { + {"NSEmailMax", {{PARAM_INT, PARAM_RELOAD, &NSEmailMax}}} + }; - moduleGetConfigDirective(confvalues); + moduleGetConfigDirective(confvalues); - if (debug) - alog("debug: [ns_maxemail] NSEmailMax set to %d", NSEmailMax); + if (debug) + alog("debug: [ns_maxemail] NSEmailMax set to %d", NSEmailMax); } diff --git a/src/modules/ns_noop_convert.c b/src/modules/ns_noop_convert.c index a4ccea7d0..6a2a29b09 100644 --- a/src/modules/ns_noop_convert.c +++ b/src/modules/ns_noop_convert.c @@ -27,14 +27,14 @@ /* Multi-language stuff */ #define LANG_NUM_STRINGS 8 -#define AUTOOP_SYNTAX 0 +#define AUTOOP_SYNTAX 0 #define AUTOOP_STATUS_ON 1 #define AUTOOP_STATUS_OFF 2 -#define AUTOOP_NO_NICK 3 -#define AUTOOP_ON 4 -#define AUTOOP_OFF 5 -#define AUTOOP_DESC 6 -#define AUTOOP_HELP 7 +#define AUTOOP_NO_NICK 3 +#define AUTOOP_ON 4 +#define AUTOOP_OFF 5 +#define AUTOOP_DESC 6 +#define AUTOOP_HELP 7 /*************************************************************************/ @@ -94,34 +94,34 @@ class NSNOOPConvert : public Module **/ int mLoadData(void) { - int ret = 0; - int len = 0; - - char *name = NULL; - - NickAlias *na = NULL; - FILE *in; - - /* will _never_ be this big thanks to the 512 limit of a message */ - char buffer[2000]; - if ((in = fopen(NSAutoOPDBName, "r")) == NULL) { - alog("ns_noop: WARNING: Can not open database file! (it might not exist, this is not fatal)"); - ret = 1; - } else { - while (fgets(buffer, 1500, in)) { - name = myStrGetToken(buffer, ' ', 0); - if (name) { - len = strlen(name); - /* Take the \n from the end of the line */ - name[len - 1] = '\0'; - if ((na = findnick(name))) { - na->nc->flags |= NI_AUTOOP; - } - free(name); - } - } - } - return ret; + int ret = 0; + int len = 0; + + char *name = NULL; + + NickAlias *na = NULL; + FILE *in; + + /* will _never_ be this big thanks to the 512 limit of a message */ + char buffer[2000]; + if ((in = fopen(NSAutoOPDBName, "r")) == NULL) { + alog("ns_noop: WARNING: Can not open database file! (it might not exist, this is not fatal)"); + ret = 1; + } else { + while (fgets(buffer, 1500, in)) { + name = myStrGetToken(buffer, ' ', 0); + if (name) { + len = strlen(name); + /* Take the \n from the end of the line */ + name[len - 1] = '\0'; + if ((na = findnick(name))) { + na->nc->flags |= NI_AUTOOP; + } + free(name); + } + } + } + return ret; } /*************************************************************************/ @@ -132,33 +132,33 @@ int mLoadData(void) **/ int mLoadConfig(int argc, char **argv) { - char *tmp = NULL; + char *tmp = NULL; - Directive d[] = { - {"NSAutoOPDBName", {{PARAM_STRING, PARAM_RELOAD, &tmp}}}, - }; + Directive d[] = { + {"NSAutoOPDBName", {{PARAM_STRING, PARAM_RELOAD, &tmp}}}, + }; - moduleGetConfigDirective(d); + moduleGetConfigDirective(d); - if (NSAutoOPDBName) - free(NSAutoOPDBName); + if (NSAutoOPDBName) + free(NSAutoOPDBName); - if (tmp) { - NSAutoOPDBName = tmp; - } else { - NSAutoOPDBName = sstrdup(DEFAULT_DB_NAME); - alog("ns_noop: NSAutoOPDBName is not defined in Services configuration file, using default %s", NSAutoOPDBName); - } + if (tmp) { + NSAutoOPDBName = tmp; + } else { + NSAutoOPDBName = sstrdup(DEFAULT_DB_NAME); + alog("ns_noop: NSAutoOPDBName is not defined in Services configuration file, using default %s", NSAutoOPDBName); + } - if (!NSAutoOPDBName) { - alog("ns_noop: FATAL: Can't read required configuration directives!"); - return MOD_STOP; - } else { - alog("ns_noop: Directive NSAutoOPDBName loaded (%s)...", - NSAutoOPDBName); - } + if (!NSAutoOPDBName) { + alog("ns_noop: FATAL: Can't read required configuration directives!"); + return MOD_STOP; + } else { + alog("ns_noop: Directive NSAutoOPDBName loaded (%s)...", + NSAutoOPDBName); + } - return MOD_CONT; + return MOD_CONT; } /*************************************************************************/ diff --git a/src/modules/os_ignore_db.c b/src/modules/os_ignore_db.c index 1d6d11ece..064dfa380 100644 --- a/src/modules/os_ignore_db.c +++ b/src/modules/os_ignore_db.c @@ -21,22 +21,22 @@ #define IGNOREDBVERSION 1
/* Database seperators */
-#define SEPARATOR '^' /* End of a key, seperates keys from values */
-#define BLOCKEND '\n' /* End of a block, e.g. a whole ignore */
-#define VALUEEND '\000' /* End of a value */
-#define SUBSTART '\010' /* Beginning of a new subblock, closed by a BLOCKEND */
+#define SEPARATOR '^' /* End of a key, seperates keys from values */
+#define BLOCKEND '\n' /* End of a block, e.g. a whole ignore */
+#define VALUEEND '\000' /* End of a value */
+#define SUBSTART '\010' /* Beginning of a new subblock, closed by a BLOCKEND */
/* Database reading return values */
#define DB_READ_SUCCESS 0
-#define DB_READ_ERROR 1
-#define DB_EOF_ERROR 2
+#define DB_READ_ERROR 1
+#define DB_EOF_ERROR 2
#define DB_VERSION_ERROR 3
#define DB_READ_BLOCKEND 4
#define DB_READ_SUBSTART 5
#define DB_WRITE_SUCCESS 0
-#define DB_WRITE_ERROR 1
-#define DB_WRITE_NOVAL 2
+#define DB_WRITE_ERROR 1
+#define DB_WRITE_NOVAL 2
/* Database Key, Value max length */
#define MAXKEYLEN 128
@@ -46,12 +46,12 @@ typedef struct db_file_ DBFile;
struct db_file_ {
- FILE *fptr; /* Pointer to the opened file */
- int db_version; /* The db version of the datafiles (only needed for reading) */
- int core_db_version; /* The current db version of this anope source */
- char service[256]; /* StatServ/etc. */
- char filename[256]; /* Filename of the database */
- char temp_name[262]; /* Temp filename of the database */
+ FILE *fptr; /* Pointer to the opened file */
+ int db_version; /* The db version of the datafiles (only needed for reading) */
+ int core_db_version; /* The current db version of this anope source */
+ char service[256]; /* StatServ/etc. */
+ char filename[256]; /* Filename of the database */
+ char temp_name[262]; /* Temp filename of the database */
};
@@ -179,7 +179,7 @@ int backup_ignoredb(int argc, char **argv) { /* ------------------------------------------------------------------------------- */
/**************************************************************************
- * DataBase Handling
+ * DataBase Handling
**************************************************************************/
void load_ignore_db(void) {
@@ -198,7 +198,7 @@ void load_ignore_db(void) { /* Open the db, fill the rest of dbptr and allocate memory for key and value */
if (new_open_db_read(dbptr, &key, &value)) {
free(dbptr);
- return; /* Bang, an error occurred */
+ return; /* Bang, an error occurred */
}
while (1) {
@@ -214,7 +214,7 @@ void load_ignore_db(void) { new_close_db(dbptr->fptr, &key, &value);
free(dbptr);
return;
- } else if (retval == DB_READ_BLOCKEND) { /* DB_READ_BLOCKEND */
+ } else if (retval == DB_READ_BLOCKEND) { /* DB_READ_BLOCKEND */
/* Check if we have everything to add the ignore..
* We shouldn't bother with already expired ignores either.. */
if (mask && (expiry_time > time(NULL) || expiry_time == 0)) {
@@ -248,7 +248,7 @@ void load_ignore_db(void) { if (mask) free(mask);
mask = NULL;
expiry_time = time(NULL);
- } else { /* DB_READ_SUCCESS */
+ } else { /* DB_READ_SUCCESS */
if (!*key || !*value)
continue;
@@ -290,7 +290,7 @@ void save_ignore_db(void) { if (new_open_db_write(dbptr)) {
rename(dbptr->temp_name, IgnoreDB);
free(dbptr);
- return; /* Bang, an error occurred */
+ return; /* Bang, an error occurred */
}
/* Store the version of the DB in the DB as well...
@@ -324,8 +324,8 @@ void save_ignore_db(void) { if (dbptr) {
new_close_db(dbptr->fptr, NULL, NULL); /* close file */
- remove(dbptr->temp_name); /* saved successfully, no need to keep the old one */
- free(dbptr); /* free the db struct */
+ remove(dbptr->temp_name); /* saved successfully, no need to keep the old one */
+ free(dbptr); /* free the db struct */
}
}
@@ -333,7 +333,7 @@ void save_ignore_db(void) { /* ------------------------------------------------------------------------------- */
/**************************************************************************
- * Generic DataBase Functions (Borrowed this from Trystan :-) )
+ * Generic DataBase Functions (Borrowed this from Trystan :-) )
**************************************************************************/
@@ -438,21 +438,21 @@ int new_read_db_entry(char **key, char **value, FILE *fptr) { if (ferror(fptr)) {
return DB_READ_ERROR; /* error! */
}
- return DB_EOF_ERROR; /* end of file */
- } else if (character == BLOCKEND) { /* END OF BLOCK */
+ return DB_EOF_ERROR; /* end of file */
+ } else if (character == BLOCKEND) { /* END OF BLOCK */
return DB_READ_BLOCKEND;
- } else if (character == VALUEEND) { /* END OF VALUE */
+ } else if (character == VALUEEND) { /* END OF VALUE */
string[i] = '\0'; /* end of value */
return DB_READ_SUCCESS;
- } else if (character == SEPARATOR) { /* END OF KEY */
+ } else if (character == SEPARATOR) { /* END OF KEY */
string[i] = '\0'; /* end of key */
- string = *value; /* beginning of value */
- i = 0; /* start with the first character of our value */
+ string = *value; /* beginning of value */
+ i = 0; /* start with the first character of our value */
} else {
if ((i == (MAXKEYLEN - 1)) && (string == *key)) { /* max key length reached, continuing with value */
- string[i] = '\0'; /* end of key */
- string = *value; /* beginning of value */
- i = 0; /* start with the first character of our value */
+ string[i] = '\0'; /* end of key */
+ string = *value; /* beginning of value */
+ i = 0; /* start with the first character of our value */
} else if ((i == (MAXVALLEN - 1)) && (string == *value)) { /* max value length reached, returning */
string[i] = '\0';
return DB_READ_SUCCESS;
diff --git a/src/modules/os_info.c b/src/modules/os_info.c index 2d69267ae..6a123ae2d 100644 --- a/src/modules/os_info.c +++ b/src/modules/os_info.c @@ -27,16 +27,16 @@ /* Multi-language stuff */ #define LANG_NUM_STRINGS 10 -#define OINFO_SYNTAX 0 +#define OINFO_SYNTAX 0 #define OINFO_ADD_SUCCESS 1 #define OINFO_DEL_SUCCESS 2 -#define OCINFO_SYNTAX 3 +#define OCINFO_SYNTAX 3 #define OCINFO_ADD_SUCCESS 4 #define OCINFO_DEL_SUCCESS 5 -#define OINFO_HELP 6 -#define OCINFO_HELP 7 -#define OINFO_HELP_CMD 8 -#define OCINFO_HELP_CMD 9 +#define OINFO_HELP 6 +#define OCINFO_HELP 7 +#define OINFO_HELP_CMD 8 +#define OCINFO_HELP_CMD 9 /*************************************************************************/ @@ -130,9 +130,9 @@ class OSInfo : public Module "This will show up when any oper /cs info's the channel.\n" "and can be used for 'tagging' channels etc....", /* OINFO_HELP_CMD */ - " OINFO Add / Del an OperInfo line to a nick", + " OINFO Add / Del an OperInfo line to a nick", /* OCINFO_HELP_CMD */ - " OINFO Add / Del an OperInfo line to a channel" + " OINFO Add / Del an OperInfo line to a channel" }; const char* langtable_es[] = { @@ -159,9 +159,9 @@ class OSInfo : public Module "Esto se mostrara cuando cualquier operador haga /cs info canal\n" "y puede ser usado para 'marcado' de canales, etc....", /* OINFO_HELP_CMD */ - " OINFO Agrega / Elimina una linea OperInfo al nick", + " OINFO Agrega / Elimina una linea OperInfo al nick", /* OCINFO_HELP_CMD */ - " OINFO Agrega / Elimina una linea OperInfo al canal" + " OINFO Agrega / Elimina una linea OperInfo al canal" }; const char* langtable_nl[] = { @@ -190,9 +190,9 @@ class OSInfo : public Module "een oper /cs info kanaal doet voor dit kanaal, en kan worden\n" "gebruikt om een kanaal te 'markeren' etc...", /* OINFO_HELP_CMD */ - " OINFO Voeg een OperInfo regel toe aan een nick of verwijder deze", + " OINFO Voeg een OperInfo regel toe aan een nick of verwijder deze", /* OCINFO_HELP_CMD */ - " OINFO Voeg een OperInfo regel toe aan een kanaal of verwijder deze" + " OINFO Voeg een OperInfo regel toe aan een kanaal of verwijder deze" }; const char* langtable_de[] = { @@ -219,9 +219,9 @@ class OSInfo : public Module "Channel.Sie wird angezeigt wenn ein Oper mit /cs info sich\n" "über den Channel informiert.", /* OINFO_HELP_CMD */ - " OINFO Addiert / Löscht eine OperInfo Linie zu / von einen Nicknamen", + " OINFO Addiert / Löscht eine OperInfo Linie zu / von einen Nicknamen", /* OCINFO_HELP_CMD */ - " OINFO Addiert / Löscht eine OperInfo Linie zu / von einen Channel" + " OINFO Addiert / Löscht eine OperInfo Linie zu / von einen Channel" }; const char* langtable_pt[] = { @@ -248,9 +248,9 @@ class OSInfo : public Module "Isto será mostrado quando qualquer Operador usar /cs info canal\n" "e pode ser usado para 'etiquetar' canais etc...", /* OINFO_HELP_CMD */ - " OINFO Adiciona ou Apaga a linha OperInfo para um nick", + " OINFO Adiciona ou Apaga a linha OperInfo para um nick", /* OCINFO_HELP_CMD */ - " OINFO Adiciona ou Apaga a linha OperInfo para um canal" + " OINFO Adiciona ou Apaga a linha OperInfo para um canal" }; const char* langtable_ru[] = { @@ -277,9 +277,9 @@ class OSInfo : public Module "êîòîðàÿ áóäåò ïîêàçàíà ëþáîìó îïåðàòîðó, çàïðàøèâàþùåìó INFO êàíàëà.\n" "Ìîæåò áûòü èñïîëüçîâàíà äëÿ 'ïîìåòêè' êàíàëîâ è ò. ä...", /* OINFO_HELP_CMD */ - " OINFO Äîáàâëÿåò/Óäàëÿåò îïåð-èíôî äëÿ íèêà", + " OINFO Äîáàâëÿåò/Óäàëÿåò îïåð-èíôî äëÿ íèêà", /* OCINFO_HELP_CMD */ - " OINFO Äîáàâëÿåò/Óäàëÿåò îïåð-èíôî äëÿ êàíàëà" + " OINFO Äîáàâëÿåò/Óäàëÿåò îïåð-èíôî äëÿ êàíàëà" }; const char* langtable_it[] = { @@ -306,9 +306,9 @@ class OSInfo : public Module "Queste vengono mostrate quando un oper esegue il comando /cs info <canale>\n" "e possono essere utilizzate per 'marchiare' i canali ecc...", /* OINFO_HELP_CMD */ - " OINFO Aggiunge/Rimuove una linea OperInfo ad/da un nick", + " OINFO Aggiunge/Rimuove una linea OperInfo ad/da un nick", /* OCINFO_HELP_CMD */ - " OINFO Aggiunge/Rimuove una linea OperInfo ad/da un canale" + " OINFO Aggiunge/Rimuove una linea OperInfo ad/da un canale" }; this->InsertLanguage(LANG_EN_US, LANG_NUM_STRINGS, langtable_en_us); @@ -350,62 +350,62 @@ class OSInfo : public Module **/ int myAddNickInfo(User * u) { - char *text = NULL; - char *cmd = NULL; - char *nick = NULL; - char *info = NULL; - NickAlias *na = NULL; - - /* Get the last buffer anope recived */ - text = moduleGetLastBuffer(); - if (text) { - cmd = myStrGetToken(text, ' ', 0); - nick = myStrGetToken(text, ' ', 1); - info = myStrGetTokenRemainder(text, ' ', 2); - if (cmd && nick) { - if (strcasecmp(cmd, "ADD") == 0) { - /* Syntax error, again! */ - if (info) { - /* ok we've found the user */ - if ((na = findnick(nick))) { - /* Add the module data to the user */ - moduleAddData(&na->nc->moduleData, "info", info); - moduleNoticeLang(s_NickServ, u, - OINFO_ADD_SUCCESS, nick); - /* NickCore not found! */ - } else { - notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, - nick); - } - free(info); - } - } else if (strcasecmp(cmd, "DEL") == 0) { - /* ok we've found the user */ - if ((na = findnick(nick))) { - moduleDelData(&na->nc->moduleData, "info"); - moduleNoticeLang(s_NickServ, u, - OINFO_DEL_SUCCESS, nick); - /* NickCore not found! */ - } else { - notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, - nick); - } - /* another syntax error! */ - } else { - moduleNoticeLang(s_NickServ, u, OINFO_SYNTAX); - } - free(cmd); - free(nick); - /* Syntax error */ - } else if (cmd) { - moduleNoticeLang(s_NickServ, u, OINFO_SYNTAX); - free(cmd); - /* Syntax error */ - } else { - moduleNoticeLang(s_NickServ, u, OINFO_SYNTAX); - } - } - return MOD_CONT; + char *text = NULL; + char *cmd = NULL; + char *nick = NULL; + char *info = NULL; + NickAlias *na = NULL; + + /* Get the last buffer anope recived */ + text = moduleGetLastBuffer(); + if (text) { + cmd = myStrGetToken(text, ' ', 0); + nick = myStrGetToken(text, ' ', 1); + info = myStrGetTokenRemainder(text, ' ', 2); + if (cmd && nick) { + if (strcasecmp(cmd, "ADD") == 0) { + /* Syntax error, again! */ + if (info) { + /* ok we've found the user */ + if ((na = findnick(nick))) { + /* Add the module data to the user */ + moduleAddData(&na->nc->moduleData, "info", info); + moduleNoticeLang(s_NickServ, u, + OINFO_ADD_SUCCESS, nick); + /* NickCore not found! */ + } else { + notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, + nick); + } + free(info); + } + } else if (strcasecmp(cmd, "DEL") == 0) { + /* ok we've found the user */ + if ((na = findnick(nick))) { + moduleDelData(&na->nc->moduleData, "info"); + moduleNoticeLang(s_NickServ, u, + OINFO_DEL_SUCCESS, nick); + /* NickCore not found! */ + } else { + notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED, + nick); + } + /* another syntax error! */ + } else { + moduleNoticeLang(s_NickServ, u, OINFO_SYNTAX); + } + free(cmd); + free(nick); + /* Syntax error */ + } else if (cmd) { + moduleNoticeLang(s_NickServ, u, OINFO_SYNTAX); + free(cmd); + /* Syntax error */ + } else { + moduleNoticeLang(s_NickServ, u, OINFO_SYNTAX); + } + } + return MOD_CONT; } /** @@ -420,60 +420,60 @@ int myAddNickInfo(User * u) **/ int myAddChanInfo(User * u) { - char *text = NULL; - char *cmd = NULL; - char *chan = NULL; - char *info = NULL; - ChannelInfo *ci = NULL; - - /* Get the last buffer anope recived */ - text = moduleGetLastBuffer(); - if (text) { - cmd = myStrGetToken(text, ' ', 0); - chan = myStrGetToken(text, ' ', 1); - info = myStrGetTokenRemainder(text, ' ', 2); - if (cmd && chan) { - if (strcasecmp(cmd, "ADD") == 0) { - if (info) { - if ((ci = cs_findchan(chan))) { - /* Add the module data to the channel */ - moduleAddData(&ci->moduleData, "info", info); - moduleNoticeLang(s_ChanServ, u, - OCINFO_ADD_SUCCESS, chan); - /* ChanInfo */ - } else { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, - chan); - } - free(info); - } - } else if (strcasecmp(cmd, "DEL") == 0) { - if ((ci = cs_findchan(chan))) { - /* Del the module data from the channel */ - moduleDelData(&ci->moduleData, "info"); - moduleNoticeLang(s_ChanServ, u, - OCINFO_DEL_SUCCESS, chan); - /* ChanInfo */ - } else { - notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, - chan); - } - /* another syntax error! */ - } else { - moduleNoticeLang(s_ChanServ, u, OCINFO_SYNTAX); - } - free(cmd); - free(chan); - /* Syntax error */ - } else if (cmd) { - moduleNoticeLang(s_ChanServ, u, OCINFO_SYNTAX); - free(cmd); - /* Syntax error */ - } else { - moduleNoticeLang(s_ChanServ, u, OCINFO_SYNTAX); - } - } - return MOD_CONT; + char *text = NULL; + char *cmd = NULL; + char *chan = NULL; + char *info = NULL; + ChannelInfo *ci = NULL; + + /* Get the last buffer anope recived */ + text = moduleGetLastBuffer(); + if (text) { + cmd = myStrGetToken(text, ' ', 0); + chan = myStrGetToken(text, ' ', 1); + info = myStrGetTokenRemainder(text, ' ', 2); + if (cmd && chan) { + if (strcasecmp(cmd, "ADD") == 0) { + if (info) { + if ((ci = cs_findchan(chan))) { + /* Add the module data to the channel */ + moduleAddData(&ci->moduleData, "info", info); + moduleNoticeLang(s_ChanServ, u, + OCINFO_ADD_SUCCESS, chan); + /* ChanInfo */ + } else { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, + chan); + } + free(info); + } + } else if (strcasecmp(cmd, "DEL") == 0) { + if ((ci = cs_findchan(chan))) { + /* Del the module data from the channel */ + moduleDelData(&ci->moduleData, "info"); + moduleNoticeLang(s_ChanServ, u, + OCINFO_DEL_SUCCESS, chan); + /* ChanInfo */ + } else { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, + chan); + } + /* another syntax error! */ + } else { + moduleNoticeLang(s_ChanServ, u, OCINFO_SYNTAX); + } + free(cmd); + free(chan); + /* Syntax error */ + } else if (cmd) { + moduleNoticeLang(s_ChanServ, u, OCINFO_SYNTAX); + free(cmd); + /* Syntax error */ + } else { + moduleNoticeLang(s_ChanServ, u, OCINFO_SYNTAX); + } + } + return MOD_CONT; } /*************************************************************************/ @@ -485,34 +485,34 @@ int myAddChanInfo(User * u) **/ int myNickInfo(User * u) { - char *text = NULL; - char *nick = NULL; + char *text = NULL; + char *nick = NULL; char *info = NULL; - NickAlias *na = NULL; - - /* Only show our goodies to opers */ - if (is_oper(u)) { - /* Get the last buffer anope recived */ - text = moduleGetLastBuffer(); - if (text) { - nick = myStrGetToken(text, ' ', 0); - if (nick) { - /* ok we've found the user */ - if ((na = findnick(nick))) { - /* If we have any info on this user */ - if ((info = moduleGetData(&na->nc->moduleData, "info"))) { - notice_user(s_NickServ, u, " OperInfo: %s", info); + NickAlias *na = NULL; + + /* Only show our goodies to opers */ + if (is_oper(u)) { + /* Get the last buffer anope recived */ + text = moduleGetLastBuffer(); + if (text) { + nick = myStrGetToken(text, ' ', 0); + if (nick) { + /* ok we've found the user */ + if ((na = findnick(nick))) { + /* If we have any info on this user */ + if ((info = moduleGetData(&na->nc->moduleData, "info"))) { + notice_user(s_NickServ, u, " OperInfo: %s", info); free(info); - } - /* NickCore not found! */ - } else { - /* we dont care! */ - } - free(nick); - } - } - } - return MOD_CONT; + } + /* NickCore not found! */ + } else { + /* we dont care! */ + } + free(nick); + } + } + } + return MOD_CONT; } /** @@ -522,30 +522,30 @@ int myNickInfo(User * u) **/ int myChanInfo(User * u) { - char *text = NULL; - char *chan = NULL; + char *text = NULL; + char *chan = NULL; char *info = NULL; - ChannelInfo *ci = NULL; - - /* Only show our goodies to opers */ - if (is_oper(u)) { - /* Get the last buffer anope recived */ - text = moduleGetLastBuffer(); - if (text) { - chan = myStrGetToken(text, ' ', 0); - if (chan) { - if ((ci = cs_findchan(chan))) { - /* If we have any info on this channel */ - if ((info = moduleGetData(&ci->moduleData, "info"))) { - notice_user(s_ChanServ, u, " OperInfo: %s", info); + ChannelInfo *ci = NULL; + + /* Only show our goodies to opers */ + if (is_oper(u)) { + /* Get the last buffer anope recived */ + text = moduleGetLastBuffer(); + if (text) { + chan = myStrGetToken(text, ' ', 0); + if (chan) { + if ((ci = cs_findchan(chan))) { + /* If we have any info on this channel */ + if ((info = moduleGetData(&ci->moduleData, "info"))) { + notice_user(s_ChanServ, u, " OperInfo: %s", info); free(info); - } - } - free(chan); - } - } - } - return MOD_CONT; + } + } + free(chan); + } + } + } + return MOD_CONT; } /*************************************************************************/ @@ -556,53 +556,53 @@ int myChanInfo(User * u) **/ int mLoadData(void) { - int ret = 0; - FILE *in; - - char *type = NULL; - char *name = NULL; - char *info = NULL; - int len = 0; - - ChannelInfo *ci = NULL; - NickAlias *na = NULL; - - /* will _never_ be this big thanks to the 512 limit of a message */ - char buffer[2000]; - if ((in = fopen(OSInfoDBName, "r")) == NULL) { - alog("os_info: WARNING: can not open the database file! (it might not exist, this is not fatal)"); - ret = 1; - } else { - while (fgets(buffer, 1500, in)) { - type = myStrGetToken(buffer, ' ', 0); - name = myStrGetToken(buffer, ' ', 1); - info = myStrGetTokenRemainder(buffer, ' ', 2); - if (type) { - if (name) { - if (info) { - len = strlen(info); - /* Take the \n from the end of the line */ - info[len - 1] = '\0'; - if (stricmp(type, "C") == 0) { - if ((ci = cs_findchan(name))) { - moduleAddData(&ci->moduleData, "info", - info); - } - } else if (stricmp(type, "N") == 0) { - if ((na = findnick(name))) { - moduleAddData(&na->nc->moduleData, "info", - info); - } - } - free(info); - } - free(name); - } - free(type); - } - } - } - return ret; + int ret = 0; + FILE *in; + + char *type = NULL; + char *name = NULL; + char *info = NULL; + int len = 0; + + ChannelInfo *ci = NULL; + NickAlias *na = NULL; + + /* will _never_ be this big thanks to the 512 limit of a message */ + char buffer[2000]; + if ((in = fopen(OSInfoDBName, "r")) == NULL) { + alog("os_info: WARNING: can not open the database file! (it might not exist, this is not fatal)"); + ret = 1; + } else { + while (fgets(buffer, 1500, in)) { + type = myStrGetToken(buffer, ' ', 0); + name = myStrGetToken(buffer, ' ', 1); + info = myStrGetTokenRemainder(buffer, ' ', 2); + if (type) { + if (name) { + if (info) { + len = strlen(info); + /* Take the \n from the end of the line */ + info[len - 1] = '\0'; + if (stricmp(type, "C") == 0) { + if ((ci = cs_findchan(name))) { + moduleAddData(&ci->moduleData, "info", + info); + } + } else if (stricmp(type, "N") == 0) { + if ((na = findnick(name))) { + moduleAddData(&na->nc->moduleData, "info", + info); + } + } + free(info); + } + free(name); + } + free(type); + } + } + } + return ret; } /** @@ -614,49 +614,49 @@ int mLoadData(void) **/ int mSaveData(int argc, char **argv) { - ChannelInfo *ci = NULL; - NickCore *nc = NULL; - int i = 0; - int ret = 0; - FILE *out; - char *info = NULL; - - if (argc >= 1) { - if (!stricmp(argv[0], EVENT_START)) { - if ((out = fopen(OSInfoDBName, "w")) == NULL) { - alog("os_info: ERROR: can not open the database file!"); - ircdproto->SendGlobops(s_OperServ, - "os_info: ERROR: can not open the database file!"); - ret = 1; - } else { - for (i = 0; i < 1024; i++) { - for (nc = nclists[i]; nc; nc = nc->next) { - /* If we have any info on this user */ - if ((info = moduleGetData(&nc->moduleData, "info"))) { - fprintf(out, "N %s %s\n", nc->display, info); + ChannelInfo *ci = NULL; + NickCore *nc = NULL; + int i = 0; + int ret = 0; + FILE *out; + char *info = NULL; + + if (argc >= 1) { + if (!stricmp(argv[0], EVENT_START)) { + if ((out = fopen(OSInfoDBName, "w")) == NULL) { + alog("os_info: ERROR: can not open the database file!"); + ircdproto->SendGlobops(s_OperServ, + "os_info: ERROR: can not open the database file!"); + ret = 1; + } else { + for (i = 0; i < 1024; i++) { + for (nc = nclists[i]; nc; nc = nc->next) { + /* If we have any info on this user */ + if ((info = moduleGetData(&nc->moduleData, "info"))) { + fprintf(out, "N %s %s\n", nc->display, info); free(info); - } - } - } + } + } + } - for (i = 0; i < 256; i++) { - for (ci = chanlists[i]; ci; ci = ci->next) { - /* If we have any info on this channel */ - if ((info = moduleGetData(&ci->moduleData, "info"))) { - fprintf(out, "C %s %s\n", ci->name, info); + for (i = 0; i < 256; i++) { + for (ci = chanlists[i]; ci; ci = ci->next) { + /* If we have any info on this channel */ + if ((info = moduleGetData(&ci->moduleData, "info"))) { + fprintf(out, "C %s %s\n", ci->name, info); free(info); - } - } - } - fclose(out); - } - } else { - ret = 0; - } - } - - return ret; + } + } + } + fclose(out); + } + } else { + ret = 0; + } + } + + return ret; } /** @@ -676,28 +676,28 @@ int mBackupData(int argc, char **argv) **/ int mLoadConfig(void) { - char *tmp = NULL; + char *tmp = NULL; - Directive directivas[] = { - {"OSInfoDBName", {{PARAM_STRING, PARAM_RELOAD, &tmp}}}, - }; + Directive directivas[] = { + {"OSInfoDBName", {{PARAM_STRING, PARAM_RELOAD, &tmp}}}, + }; - Directive *d = &directivas[0]; - moduleGetConfigDirective(d); + Directive *d = &directivas[0]; + moduleGetConfigDirective(d); - if (OSInfoDBName) - free(OSInfoDBName); + if (OSInfoDBName) + free(OSInfoDBName); - if (tmp) { - OSInfoDBName = tmp; - } else { - OSInfoDBName = sstrdup(DEFAULT_DB_NAME); - alog("os_info: OSInfoDBName is not defined in Services configuration file, using default %s", OSInfoDBName); - } + if (tmp) { + OSInfoDBName = tmp; + } else { + OSInfoDBName = sstrdup(DEFAULT_DB_NAME); + alog("os_info: OSInfoDBName is not defined in Services configuration file, using default %s", OSInfoDBName); + } - alog("os_info: Directive OSInfoDBName loaded (%s)...", OSInfoDBName); + alog("os_info: Directive OSInfoDBName loaded (%s)...", OSInfoDBName); - return 0; + return 0; } /** @@ -706,58 +706,58 @@ int mLoadConfig(void) **/ int mEventReload(int argc, char **argv) { - int ret = 0; - if (argc >= 1) { - if (!stricmp(argv[0], EVENT_START)) { - alog("os_info: Reloading configuration directives..."); - ret = mLoadConfig(); - } else { - /* Nothing for now */ - } - } - - if (ret) - alog("os_info.c: ERROR: An error has occured while reloading the configuration file"); - - return MOD_CONT; + int ret = 0; + if (argc >= 1) { + if (!stricmp(argv[0], EVENT_START)) { + alog("os_info: Reloading configuration directives..."); + ret = mLoadConfig(); + } else { + /* Nothing for now */ + } + } + + if (ret) + alog("os_info.c: ERROR: An error has occured while reloading the configuration file"); + + return MOD_CONT; } /*************************************************************************/ int mNickHelp(User * u) { - if (is_oper(u)) { - moduleNoticeLang(s_NickServ, u, OINFO_HELP); - } else { - notice_lang(s_NickServ, u, NO_HELP_AVAILABLE, "OINFO"); - } - return MOD_CONT; + if (is_oper(u)) { + moduleNoticeLang(s_NickServ, u, OINFO_HELP); + } else { + notice_lang(s_NickServ, u, NO_HELP_AVAILABLE, "OINFO"); + } + return MOD_CONT; } int mChanHelp(User * u) { - if (is_oper(u)) { - moduleNoticeLang(s_ChanServ, u, OCINFO_HELP); - } else { - notice_lang(s_ChanServ, u, NO_HELP_AVAILABLE, "OINFO"); - } - return MOD_CONT; + if (is_oper(u)) { + moduleNoticeLang(s_ChanServ, u, OCINFO_HELP); + } else { + notice_lang(s_ChanServ, u, NO_HELP_AVAILABLE, "OINFO"); + } + return MOD_CONT; } /* This help will be added to the main NickServ list */ void mMainNickHelp(User * u) { - if (is_oper(u)) { - moduleNoticeLang(s_NickServ, u, OINFO_HELP_CMD); - } + if (is_oper(u)) { + moduleNoticeLang(s_NickServ, u, OINFO_HELP_CMD); + } } /* This help will be added to the main NickServ list */ void mMainChanHelp(User * u) { - if (is_oper(u)) { - moduleNoticeLang(s_ChanServ, u, OCINFO_HELP_CMD); - } + if (is_oper(u)) { + moduleNoticeLang(s_ChanServ, u, OCINFO_HELP_CMD); + } } /*************************************************************************/ diff --git a/src/news.c b/src/news.c index a0c2010ba..24660dfac 100644 --- a/src/news.c +++ b/src/news.c @@ -41,67 +41,67 @@ NewsItem *news = NULL; #define MSG_MAX 11 struct newsmsgs { - int16 type; - const char *name; - int msgs[MSG_MAX + 1]; + int16 type; + const char *name; + int msgs[MSG_MAX + 1]; }; struct newsmsgs msgarray[] = { - {NEWS_LOGON, "LOGON", - {NEWS_LOGON_SYNTAX, - NEWS_LOGON_LIST_HEADER, - NEWS_LOGON_LIST_ENTRY, - NEWS_LOGON_LIST_NONE, - NEWS_LOGON_ADD_SYNTAX, - NEWS_LOGON_ADD_FULL, - NEWS_LOGON_ADDED, - NEWS_LOGON_DEL_SYNTAX, - NEWS_LOGON_DEL_NOT_FOUND, - NEWS_LOGON_DELETED, - NEWS_LOGON_DEL_NONE, - NEWS_LOGON_DELETED_ALL} - }, - {NEWS_OPER, "OPER", - {NEWS_OPER_SYNTAX, - NEWS_OPER_LIST_HEADER, - NEWS_OPER_LIST_ENTRY, - NEWS_OPER_LIST_NONE, - NEWS_OPER_ADD_SYNTAX, - NEWS_OPER_ADD_FULL, - NEWS_OPER_ADDED, - NEWS_OPER_DEL_SYNTAX, - NEWS_OPER_DEL_NOT_FOUND, - NEWS_OPER_DELETED, - NEWS_OPER_DEL_NONE, - NEWS_OPER_DELETED_ALL} - }, - {NEWS_RANDOM, "RANDOM", - {NEWS_RANDOM_SYNTAX, - NEWS_RANDOM_LIST_HEADER, - NEWS_RANDOM_LIST_ENTRY, - NEWS_RANDOM_LIST_NONE, - NEWS_RANDOM_ADD_SYNTAX, - NEWS_RANDOM_ADD_FULL, - NEWS_RANDOM_ADDED, - NEWS_RANDOM_DEL_SYNTAX, - NEWS_RANDOM_DEL_NOT_FOUND, - NEWS_RANDOM_DELETED, - NEWS_RANDOM_DEL_NONE, - NEWS_RANDOM_DELETED_ALL} - } + {NEWS_LOGON, "LOGON", + {NEWS_LOGON_SYNTAX, + NEWS_LOGON_LIST_HEADER, + NEWS_LOGON_LIST_ENTRY, + NEWS_LOGON_LIST_NONE, + NEWS_LOGON_ADD_SYNTAX, + NEWS_LOGON_ADD_FULL, + NEWS_LOGON_ADDED, + NEWS_LOGON_DEL_SYNTAX, + NEWS_LOGON_DEL_NOT_FOUND, + NEWS_LOGON_DELETED, + NEWS_LOGON_DEL_NONE, + NEWS_LOGON_DELETED_ALL} + }, + {NEWS_OPER, "OPER", + {NEWS_OPER_SYNTAX, + NEWS_OPER_LIST_HEADER, + NEWS_OPER_LIST_ENTRY, + NEWS_OPER_LIST_NONE, + NEWS_OPER_ADD_SYNTAX, + NEWS_OPER_ADD_FULL, + NEWS_OPER_ADDED, + NEWS_OPER_DEL_SYNTAX, + NEWS_OPER_DEL_NOT_FOUND, + NEWS_OPER_DELETED, + NEWS_OPER_DEL_NONE, + NEWS_OPER_DELETED_ALL} + }, + {NEWS_RANDOM, "RANDOM", + {NEWS_RANDOM_SYNTAX, + NEWS_RANDOM_LIST_HEADER, + NEWS_RANDOM_LIST_ENTRY, + NEWS_RANDOM_LIST_NONE, + NEWS_RANDOM_ADD_SYNTAX, + NEWS_RANDOM_ADD_FULL, + NEWS_RANDOM_ADDED, + NEWS_RANDOM_DEL_SYNTAX, + NEWS_RANDOM_DEL_NOT_FOUND, + NEWS_RANDOM_DELETED, + NEWS_RANDOM_DEL_NONE, + NEWS_RANDOM_DELETED_ALL} + } }; static int *findmsgs(int16 type, const char **type_name) { - int i; - for (i = 0; i < lenof(msgarray); i++) { - if (msgarray[i].type == type) { - if (type_name) - *type_name = msgarray[i].name; - return msgarray[i].msgs; - } - } - return NULL; + int i; + for (i = 0; i < lenof(msgarray); i++) { + if (msgarray[i].type == type) { + if (type_name) + *type_name = msgarray[i].name; + return msgarray[i].msgs; + } + } + return NULL; } /*************************************************************************/ @@ -114,12 +114,12 @@ static void do_news_list(User * u, int16 type, int *msgs); /* Add news items. */ static void do_news_add(User * u, int16 type, int *msgs, - const char *type_name); + const char *type_name); static int add_newsitem(User * u, const char *text, int16 type); /* Delete news items. */ static void do_news_del(User * u, int16 type, int *msgs, - const char *type_name); + const char *type_name); static int del_newsitem(int num, int16 type); /*************************************************************************/ @@ -128,14 +128,14 @@ static int del_newsitem(int num, int16 type); void get_news_stats(long *nrec, long *memuse) { - long mem; - int i; - - mem = sizeof(NewsItem) * news_size; - for (i = 0; i < nnews; i++) - mem += strlen(news[i].text) + 1; - *nrec = nnews; - *memuse = mem; + long mem; + int i; + + mem = sizeof(NewsItem) * news_size; + for (i = 0; i < nnews; i++) + mem += strlen(news[i].text) + 1; + *nrec = nnews; + *memuse = mem; } /*************************************************************************/ @@ -143,55 +143,55 @@ void get_news_stats(long *nrec, long *memuse) /*************************************************************************/ #define SAFE(x) do { \ - if ((x) < 0) { \ + if ((x) < 0) { \ if (!forceload) \ - fatal("Read error on %s", NewsDBName); \ + fatal("Read error on %s", NewsDBName); \ nnews = i; \ break; \ - } \ + } \ } while (0) void load_news() { - dbFILE *f; - int i; - uint16 n; - uint32 tmp32; - - if (!(f = open_db(s_OperServ, NewsDBName, "r", NEWS_VERSION))) - return; - switch (i = get_file_version(f)) { - case 9: - case 8: - case 7: - SAFE(read_int16(&n, f)); - nnews = n; - if (nnews < 8) - news_size = 16; - else if (nnews >= 16384) - news_size = 32767; - else - news_size = 2 * nnews; - news = (NewsItem *)scalloc(sizeof(*news) * news_size, 1); - if (!nnews) { - close_db(f); - return; - } - for (i = 0; i < nnews; i++) { - SAFE(read_int16(&news[i].type, f)); - SAFE(read_int32(&news[i].num, f)); - SAFE(read_string(&news[i].text, f)); - SAFE(read_buffer(news[i].who, f)); - SAFE(read_int32(&tmp32, f)); - news[i].time = tmp32; - } - break; - - default: - fatal("Unsupported version (%d) on %s", i, NewsDBName); - } /* switch (ver) */ - - close_db(f); + dbFILE *f; + int i; + uint16 n; + uint32 tmp32; + + if (!(f = open_db(s_OperServ, NewsDBName, "r", NEWS_VERSION))) + return; + switch (i = get_file_version(f)) { + case 9: + case 8: + case 7: + SAFE(read_int16(&n, f)); + nnews = n; + if (nnews < 8) + news_size = 16; + else if (nnews >= 16384) + news_size = 32767; + else + news_size = 2 * nnews; + news = (NewsItem *)scalloc(sizeof(*news) * news_size, 1); + if (!nnews) { + close_db(f); + return; + } + for (i = 0; i < nnews; i++) { + SAFE(read_int16(&news[i].type, f)); + SAFE(read_int32(&news[i].num, f)); + SAFE(read_string(&news[i].text, f)); + SAFE(read_buffer(news[i].who, f)); + SAFE(read_int32(&tmp32, f)); + news[i].time = tmp32; + } + break; + + default: + fatal("Unsupported version (%d) on %s", i, NewsDBName); + } /* switch (ver) */ + + close_db(f); } #undef SAFE @@ -199,35 +199,35 @@ void load_news() /*************************************************************************/ #define SAFE(x) do { \ - if ((x) < 0) { \ + if ((x) < 0) { \ restore_db(f); \ log_perror("Write error on %s", NewsDBName); \ if (time(NULL) - lastwarn > WarningTimeout) { \ - ircdproto->SendGlobops(NULL, "Write error on %s: %s", NewsDBName, \ + ircdproto->SendGlobops(NULL, "Write error on %s: %s", NewsDBName, \ strerror(errno)); \ - lastwarn = time(NULL); \ + lastwarn = time(NULL); \ } \ return; \ - } \ + } \ } while (0) void save_news() { - dbFILE *f; - int i; - static time_t lastwarn = 0; - - if (!(f = open_db(s_OperServ, NewsDBName, "w", NEWS_VERSION))) - return; - SAFE(write_int16(nnews, f)); - for (i = 0; i < nnews; i++) { - SAFE(write_int16(news[i].type, f)); - SAFE(write_int32(news[i].num, f)); - SAFE(write_string(news[i].text, f)); - SAFE(write_buffer(news[i].who, f)); - SAFE(write_int32(news[i].time, f)); - } - close_db(f); + dbFILE *f; + int i; + static time_t lastwarn = 0; + + if (!(f = open_db(s_OperServ, NewsDBName, "w", NEWS_VERSION))) + return; + SAFE(write_int16(nnews, f)); + for (i = 0; i < nnews; i++) { + SAFE(write_int16(news[i].type, f)); + SAFE(write_int32(news[i].num, f)); + SAFE(write_string(news[i].text, f)); + SAFE(write_buffer(news[i].who, f)); + SAFE(write_int32(news[i].time, f)); + } + close_db(f); } #undef SAFE @@ -238,65 +238,65 @@ void save_news() void display_news(User * u, int16 type) { - int msg; - - if (type == NEWS_LOGON) { - msg = NEWS_LOGON_TEXT; - } else if (type == NEWS_OPER) { - msg = NEWS_OPER_TEXT; - } else if (type == NEWS_RANDOM) { - msg = NEWS_RANDOM_TEXT; - } else { - alog("news: Invalid type (%d) to display_news()", type); - return; - } - - if (type == NEWS_RANDOM) { - static int current_news = -1; - int count = 0; - - if (!nnews) - return; - - while (count++ < nnews) { - if (++current_news >= nnews) - current_news = 0; - - if (news[current_news].type == type) { - struct tm *tm; - char timebuf[64]; - - tm = localtime(&news[current_news].time); - strftime_lang(timebuf, sizeof(timebuf), u, - STRFTIME_SHORT_DATE_FORMAT, tm); - notice_lang(s_GlobalNoticer, u, msg, timebuf, - news[current_news].text); - - return; - } - } - } else { - int i, count = 0; - - for (i = nnews - 1; i >= 0; i--) { - if (count >= NewsCount) - break; - if (news[i].type == type) - count++; - } - while (++i < nnews) { - if (news[i].type == type) { - struct tm *tm; - char timebuf[64]; - - tm = localtime(&news[i].time); - strftime_lang(timebuf, sizeof(timebuf), u, - STRFTIME_SHORT_DATE_FORMAT, tm); - notice_lang(s_GlobalNoticer, u, msg, timebuf, - news[i].text); - } - } - } + int msg; + + if (type == NEWS_LOGON) { + msg = NEWS_LOGON_TEXT; + } else if (type == NEWS_OPER) { + msg = NEWS_OPER_TEXT; + } else if (type == NEWS_RANDOM) { + msg = NEWS_RANDOM_TEXT; + } else { + alog("news: Invalid type (%d) to display_news()", type); + return; + } + + if (type == NEWS_RANDOM) { + static int current_news = -1; + int count = 0; + + if (!nnews) + return; + + while (count++ < nnews) { + if (++current_news >= nnews) + current_news = 0; + + if (news[current_news].type == type) { + struct tm *tm; + char timebuf[64]; + + tm = localtime(&news[current_news].time); + strftime_lang(timebuf, sizeof(timebuf), u, + STRFTIME_SHORT_DATE_FORMAT, tm); + notice_lang(s_GlobalNoticer, u, msg, timebuf, + news[current_news].text); + + return; + } + } + } else { + int i, count = 0; + + for (i = nnews - 1; i >= 0; i--) { + if (count >= NewsCount) + break; + if (news[i].type == type) + count++; + } + while (++i < nnews) { + if (news[i].type == type) { + struct tm *tm; + char timebuf[64]; + + tm = localtime(&news[i].time); + strftime_lang(timebuf, sizeof(timebuf), u, + STRFTIME_SHORT_DATE_FORMAT, tm); + notice_lang(s_GlobalNoticer, u, msg, timebuf, + news[i].text); + } + } + } } /*************************************************************************/ @@ -305,23 +305,23 @@ void display_news(User * u, int16 type) /* Declared in extern.h */ int do_logonnews(User * u) { - do_news(u, NEWS_LOGON); - return MOD_CONT; + do_news(u, NEWS_LOGON); + return MOD_CONT; } /* Declared in extern.h */ int do_opernews(User * u) { - do_news(u, NEWS_OPER); - return MOD_CONT; + do_news(u, NEWS_OPER); + return MOD_CONT; } /* Declared in extern.h */ int do_randomnews(User * u) { - do_news(u, NEWS_RANDOM); - return MOD_CONT; + do_news(u, NEWS_RANDOM); + return MOD_CONT; } /*************************************************************************/ @@ -329,39 +329,39 @@ int do_randomnews(User * u) /* Main news command handling routine. */ void do_news(User * u, short type) { - int is_servadmin = is_services_admin(u); - const char *cmd = strtok(NULL, " "); - const char *type_name; - int *msgs; - - msgs = findmsgs(type, &type_name); - if (!msgs) { - alog("news: Invalid type to do_news()"); - return; - } - - if (!cmd) - cmd = ""; - - if (stricmp(cmd, "LIST") == 0) { - do_news_list(u, type, msgs); - } else if (stricmp(cmd, "ADD") == 0) { - if (is_servadmin) - do_news_add(u, type, msgs, type_name); - else - notice_lang(s_OperServ, u, PERMISSION_DENIED); - - } else if (stricmp(cmd, "DEL") == 0) { - if (is_servadmin) - do_news_del(u, type, msgs, type_name); - else - notice_lang(s_OperServ, u, PERMISSION_DENIED); - - } else { - char buf[32]; - snprintf(buf, sizeof(buf), "%sNEWS", type_name); - syntax_error(s_OperServ, u, buf, msgs[MSG_SYNTAX]); - } + int is_servadmin = is_services_admin(u); + const char *cmd = strtok(NULL, " "); + const char *type_name; + int *msgs; + + msgs = findmsgs(type, &type_name); + if (!msgs) { + alog("news: Invalid type to do_news()"); + return; + } + + if (!cmd) + cmd = ""; + + if (stricmp(cmd, "LIST") == 0) { + do_news_list(u, type, msgs); + } else if (stricmp(cmd, "ADD") == 0) { + if (is_servadmin) + do_news_add(u, type, msgs, type_name); + else + notice_lang(s_OperServ, u, PERMISSION_DENIED); + + } else if (stricmp(cmd, "DEL") == 0) { + if (is_servadmin) + do_news_del(u, type, msgs, type_name); + else + notice_lang(s_OperServ, u, PERMISSION_DENIED); + + } else { + char buf[32]; + snprintf(buf, sizeof(buf), "%sNEWS", type_name); + syntax_error(s_OperServ, u, buf, msgs[MSG_SYNTAX]); + } } /*************************************************************************/ @@ -370,29 +370,29 @@ void do_news(User * u, short type) static void do_news_list(User * u, int16 type, int *msgs) { - int i, count = 0; - char timebuf[64]; - struct tm *tm; - - for (i = 0; i < nnews; i++) { - if (news[i].type == type) { - if (count == 0) - notice_lang(s_OperServ, u, msgs[MSG_LIST_HEADER]); - tm = localtime(&news[i].time); - strftime_lang(timebuf, sizeof(timebuf), - u, STRFTIME_DATE_TIME_FORMAT, tm); - notice_lang(s_OperServ, u, msgs[MSG_LIST_ENTRY], - news[i].num, timebuf, - *news[i].who ? news[i].who : "<unknown>", - news[i].text); - count++; - } - } - if (count == 0) - notice_lang(s_OperServ, u, msgs[MSG_LIST_NONE]); - else { - notice_lang(s_OperServ, u, END_OF_ANY_LIST, "News"); - } + int i, count = 0; + char timebuf[64]; + struct tm *tm; + + for (i = 0; i < nnews; i++) { + if (news[i].type == type) { + if (count == 0) + notice_lang(s_OperServ, u, msgs[MSG_LIST_HEADER]); + tm = localtime(&news[i].time); + strftime_lang(timebuf, sizeof(timebuf), + u, STRFTIME_DATE_TIME_FORMAT, tm); + notice_lang(s_OperServ, u, msgs[MSG_LIST_ENTRY], + news[i].num, timebuf, + *news[i].who ? news[i].who : "<unknown>", + news[i].text); + count++; + } + } + if (count == 0) + notice_lang(s_OperServ, u, msgs[MSG_LIST_NONE]); + else { + notice_lang(s_OperServ, u, END_OF_ANY_LIST, "News"); + } } /*************************************************************************/ @@ -400,26 +400,26 @@ static void do_news_list(User * u, int16 type, int *msgs) /* Handle a {LOGON,OPER}NEWS ADD command. */ static void do_news_add(User * u, int16 type, int *msgs, - const char *type_name) + const char *type_name) { - char *text = strtok(NULL, ""); + char *text = strtok(NULL, ""); int n; - if (!text) { - char buf[32]; - snprintf(buf, sizeof(buf), "%sNEWS", type_name); - syntax_error(s_OperServ, u, buf, msgs[MSG_ADD_SYNTAX]); - } else { - if (readonly) { - notice_lang(s_OperServ, u, READ_ONLY_MODE); + if (!text) { + char buf[32]; + snprintf(buf, sizeof(buf), "%sNEWS", type_name); + syntax_error(s_OperServ, u, buf, msgs[MSG_ADD_SYNTAX]); + } else { + if (readonly) { + notice_lang(s_OperServ, u, READ_ONLY_MODE); return; } - n = add_newsitem(u, text, type); - if (n < 0) - notice_lang(s_OperServ, u, msgs[MSG_ADD_FULL]); - else - notice_lang(s_OperServ, u, msgs[MSG_ADDED], n); - } + n = add_newsitem(u, text, type); + if (n < 0) + notice_lang(s_OperServ, u, msgs[MSG_ADD_FULL]); + else + notice_lang(s_OperServ, u, msgs[MSG_ADDED], n); + } } @@ -429,32 +429,32 @@ static void do_news_add(User * u, int16 type, int *msgs, static int add_newsitem(User * u, const char *text, short type) { - int i, num; - - if (nnews >= 32767) - return -1; - - if (nnews >= news_size) { - if (news_size < 8) - news_size = 8; - else - news_size *= 2; - news = (NewsItem *)srealloc(news, sizeof(*news) * news_size); - } - num = 0; - for (i = nnews - 1; i >= 0; i--) { - if (news[i].type == type) { - num = news[i].num; - break; - } - } - news[nnews].type = type; - news[nnews].num = num + 1; - news[nnews].text = sstrdup(text); - news[nnews].time = time(NULL); - strscpy(news[nnews].who, u->nick, NICKMAX); - nnews++; - return num + 1; + int i, num; + + if (nnews >= 32767) + return -1; + + if (nnews >= news_size) { + if (news_size < 8) + news_size = 8; + else + news_size *= 2; + news = (NewsItem *)srealloc(news, sizeof(*news) * news_size); + } + num = 0; + for (i = nnews - 1; i >= 0; i--) { + if (news[i].type == type) { + num = news[i].num; + break; + } + } + news[nnews].type = type; + news[nnews].num = num + 1; + news[nnews].text = sstrdup(text); + news[nnews].time = time(NULL); + strscpy(news[nnews].who, u->nick, NICKMAX); + nnews++; + return num + 1; } /*************************************************************************/ @@ -462,38 +462,38 @@ static int add_newsitem(User * u, const char *text, short type) /* Handle a {LOGON,OPER}NEWS DEL command. */ static void do_news_del(User * u, int16 type, int *msgs, - const char *type_name) + const char *type_name) { - char *text = strtok(NULL, " "); - int i, num; - - if (!text) { - char buf[32]; - snprintf(buf, sizeof(buf), "%sNEWS", type_name); - syntax_error(s_OperServ, u, buf, msgs[MSG_DEL_SYNTAX]); - } else { - if (readonly) { - notice_lang(s_OperServ, u, READ_ONLY_MODE); + char *text = strtok(NULL, " "); + int i, num; + + if (!text) { + char buf[32]; + snprintf(buf, sizeof(buf), "%sNEWS", type_name); + syntax_error(s_OperServ, u, buf, msgs[MSG_DEL_SYNTAX]); + } else { + if (readonly) { + notice_lang(s_OperServ, u, READ_ONLY_MODE); return; } - if (stricmp(text, "ALL") != 0) { - num = atoi(text); - if (num > 0 && del_newsitem(num, type)) { - notice_lang(s_OperServ, u, msgs[MSG_DELETED], num); - /* Reset the order - #0000397 */ - for (i = 0; i < nnews; i++) { - if ((news[i].type == type) && (news[i].num > num)) - news[i].num--; - } - } else - notice_lang(s_OperServ, u, msgs[MSG_DEL_NOT_FOUND], num); - } else { - if (del_newsitem(0, type)) - notice_lang(s_OperServ, u, msgs[MSG_DELETED_ALL]); - else - notice_lang(s_OperServ, u, msgs[MSG_DEL_NONE]); - } - } + if (stricmp(text, "ALL") != 0) { + num = atoi(text); + if (num > 0 && del_newsitem(num, type)) { + notice_lang(s_OperServ, u, msgs[MSG_DELETED], num); + /* Reset the order - #0000397 */ + for (i = 0; i < nnews; i++) { + if ((news[i].type == type) && (news[i].num > num)) + news[i].num--; + } + } else + notice_lang(s_OperServ, u, msgs[MSG_DEL_NOT_FOUND], num); + } else { + if (del_newsitem(0, type)) + notice_lang(s_OperServ, u, msgs[MSG_DELETED_ALL]); + else + notice_lang(s_OperServ, u, msgs[MSG_DEL_NONE]); + } + } } @@ -503,21 +503,21 @@ static void do_news_del(User * u, int16 type, int *msgs, static int del_newsitem(int num, short type) { - int i; - int count = 0; - - for (i = 0; i < nnews; i++) { - if (news[i].type == type && (num == 0 || news[i].num == num)) { - free(news[i].text); - count++; - nnews--; - if (i < nnews) - memcpy(news + i, news + i + 1, - sizeof(*news) * (nnews - i)); - i--; - } - } - return count; + int i; + int count = 0; + + for (i = 0; i < nnews; i++) { + if (news[i].type == type && (num == 0 || news[i].num == num)) { + free(news[i].text); + count++; + nnews--; + if (i < nnews) + memcpy(news + i, news + i + 1, + sizeof(*news) * (nnews - i)); + i--; + } + } + return count; } /*************************************************************************/ diff --git a/src/nickserv.c b/src/nickserv.c index 2940538b2..42a417cae 100644 --- a/src/nickserv.c +++ b/src/nickserv.c @@ -24,10 +24,10 @@ NickAlias *nalists[1024]; NickCore *nclists[1024]; NickRequest *nrlists[1024]; -unsigned int guestnum; /* Current guest number */ +unsigned int guestnum; /* Current guest number */ -#define TO_COLLIDE 0 /* Collide the user with this nick */ -#define TO_RELEASE 1 /* Release a collided nick */ +#define TO_COLLIDE 0 /* Collide the user with this nick */ +#define TO_RELEASE 1 /* Release a collided nick */ /*************************************************************************/ @@ -45,26 +45,26 @@ void moduleAddNickServCmds(void) { void get_aliases_stats(long *nrec, long *memuse) { - long count = 0, mem = 0; - int i; - NickAlias *na; - - for (i = 0; i < 1024; i++) { - for (na = nalists[i]; na; na = na->next) { - count++; - mem += sizeof(*na); - if (na->nick) - mem += strlen(na->nick) + 1; - if (na->last_usermask) - mem += strlen(na->last_usermask) + 1; - if (na->last_realname) - mem += strlen(na->last_realname) + 1; - if (na->last_quit) - mem += strlen(na->last_quit) + 1; - } - } - *nrec = count; - *memuse = mem; + long count = 0, mem = 0; + int i; + NickAlias *na; + + for (i = 0; i < 1024; i++) { + for (na = nalists[i]; na; na = na->next) { + count++; + mem += sizeof(*na); + if (na->nick) + mem += strlen(na->nick) + 1; + if (na->last_usermask) + mem += strlen(na->last_usermask) + 1; + if (na->last_realname) + mem += strlen(na->last_realname) + 1; + if (na->last_quit) + mem += strlen(na->last_quit) + 1; + } + } + *nrec = count; + *memuse = mem; } /*************************************************************************/ @@ -73,46 +73,46 @@ void get_aliases_stats(long *nrec, long *memuse) void get_core_stats(long *nrec, long *memuse) { - long count = 0, mem = 0; - int i, j; - NickCore *nc; - char **accptr; - - for (i = 0; i < 1024; i++) { - for (nc = nclists[i]; nc; nc = nc->next) { - count++; - mem += sizeof(*nc); - - if (nc->display) - mem += strlen(nc->display) + 1; - if (nc->pass) - mem += strlen(nc->pass) + 1; - - if (nc->url) - mem += strlen(nc->url) + 1; - if (nc->email) - mem += strlen(nc->email) + 1; - if (nc->greet) - mem += strlen(nc->greet) + 1; - - mem += sizeof(char *) * nc->accesscount; - for (accptr = nc->access, j = 0; j < nc->accesscount; - accptr++, j++) { - if (*accptr) - mem += strlen(*accptr) + 1; - } - - mem += nc->memos.memocount * sizeof(Memo); - for (j = 0; j < nc->memos.memocount; j++) { - if (nc->memos.memos[j].text) - mem += strlen(nc->memos.memos[j].text) + 1; - } - - mem += sizeof(void *) * nc->aliases.count; - } - } - *nrec = count; - *memuse = mem; + long count = 0, mem = 0; + int i, j; + NickCore *nc; + char **accptr; + + for (i = 0; i < 1024; i++) { + for (nc = nclists[i]; nc; nc = nc->next) { + count++; + mem += sizeof(*nc); + + if (nc->display) + mem += strlen(nc->display) + 1; + if (nc->pass) + mem += strlen(nc->pass) + 1; + + if (nc->url) + mem += strlen(nc->url) + 1; + if (nc->email) + mem += strlen(nc->email) + 1; + if (nc->greet) + mem += strlen(nc->greet) + 1; + + mem += sizeof(char *) * nc->accesscount; + for (accptr = nc->access, j = 0; j < nc->accesscount; + accptr++, j++) { + if (*accptr) + mem += strlen(*accptr) + 1; + } + + mem += nc->memos.memocount * sizeof(Memo); + for (j = 0; j < nc->memos.memocount; j++) { + if (nc->memos.memos[j].text) + mem += strlen(nc->memos.memos[j].text) + 1; + } + + mem += sizeof(void *) * nc->aliases.count; + } + } + *nrec = count; + *memuse = mem; } /*************************************************************************/ @@ -122,10 +122,10 @@ void get_core_stats(long *nrec, long *memuse) void ns_init(void) { - moduleAddNickServCmds(); - guestnum = time(NULL); - while (guestnum > 9999999) - guestnum -= 10000000; + moduleAddNickServCmds(); + guestnum = time(NULL); + while (guestnum > 9999999) + guestnum -= 10000000; } /*************************************************************************/ @@ -134,20 +134,20 @@ void ns_init(void) void nickserv(User * u, char *buf) { - const char *cmd, *s; + const char *cmd, *s; - cmd = strtok(buf, " "); + cmd = strtok(buf, " "); - if (!cmd) { - return; - } else if (stricmp(cmd, "\1PING") == 0) { - if (!(s = strtok(NULL, ""))) { - s = ""; - } - ircdproto->SendCTCP(findbot(s_NickServ), u->nick, "PING %s", s); - } else { - mod_run_cmd(s_NickServ, u, NICKSERV, cmd); - } + if (!cmd) { + return; + } else if (stricmp(cmd, "\1PING") == 0) { + if (!(s = strtok(NULL, ""))) { + s = ""; + } + ircdproto->SendCTCP(findbot(s_NickServ), u->nick, "PING %s", s); + } else { + mod_run_cmd(s_NickServ, u, NICKSERV, cmd); + } } @@ -157,474 +157,474 @@ void nickserv(User * u, char *buf) #define SAFE(x) do { \ - if ((x) < 0) { \ + if ((x) < 0) { \ if (!forceload) \ - fatal("Read error on %s", NickDBName); \ + fatal("Read error on %s", NickDBName); \ failed = 1; \ break; \ - } \ + } \ } while (0) /* Loads NickServ database versions 5 to 11 (<= 4 is not supported) */ void load_old_ns_dbase(void) { - dbFILE *f; - int ver, i, j, c; - NickAlias *na, *na2, *next; - NickCore *nc; - int failed = 0; - - uint16 tmp16; - uint32 tmp32; - - char bufn[NICKMAX], bufp[PASSMAX]; - char *email, *greet, *url, *forbidby, *forbidreason; - uint32 icq; - - if (!(f = open_db(s_NickServ, NickDBName, "r", NICK_VERSION))) - return; - - ver = get_file_version(f); - if (ver <= 4) { - fatal("Unsupported version number (%d) on %s", ver, NickDBName); - close_db(f); - return; - } - - for (i = 0; i < 256 && !failed; i++) { - while ((c = getc_db(f)) == 1) { - if (c != 1) - fatal("Invalid format in %s", NickDBName); - - na = (NickAlias *)scalloc(sizeof(NickAlias), 1); - - SAFE(read_buffer(bufn, f)); - na->nick = sstrdup(bufn); - SAFE(read_buffer(bufp, f)); /* Will be used later if needed */ - - SAFE(read_string(&url, f)); - SAFE(read_string(&email, f)); - if (ver >= 10) - SAFE(read_int32(&icq, f)); - else - icq = 0; - if (ver >= 9) - SAFE(read_string(&greet, f)); - else - greet = NULL; - - SAFE(read_string(&na->last_usermask, f)); - SAFE(read_string(&na->last_realname, f)); - SAFE(read_string(&na->last_quit, f)); - - SAFE(read_int32(&tmp32, f)); - na->time_registered = tmp32; - SAFE(read_int32(&tmp32, f)); - na->last_seen = tmp32; - - SAFE(read_int16(&na->status, f)); - na->status &= ~NS_TEMPORARY; - - if (ver >= 9) { - SAFE(read_string(&forbidby, f)); - SAFE(read_string(&forbidreason, f)); - /* Cleanup */ - if (forbidby && *forbidby == '@') { - free(forbidby); - forbidby = NULL; - } - if (forbidreason && *forbidreason == 0) { - free(forbidreason); - forbidreason = NULL; - } - } else { - forbidby = NULL; - forbidreason = NULL; - } - - if (na->status & NS_VERBOTEN) { - if (na->last_usermask) - free(na->last_usermask); - if (na->last_realname) - free(na->last_realname); - - na->last_usermask = forbidby; - na->last_realname = forbidreason; - } else { - if (!na->last_usermask) - na->last_usermask = sstrdup(""); - if (!na->last_realname) - na->last_realname = sstrdup(""); - } - - /* Store the reference for later resolving */ - SAFE(read_string((char **) &na->nc, f)); - SAFE(read_int16(&tmp16, f)); /* Was linkcount */ - - if (na->nc) { - SAFE(read_int16(&tmp16, f)); /* Was channelcount */ - } else { - /* This nick was a master nick, so it also has all the - * core info! =) - */ - nc = (NickCore *)scalloc(1, sizeof(NickCore)); - slist_init(&nc->aliases); - - /* The initial display is what used to be the master nick */ - nc->display = sstrdup(na->nick); - - /* We grabbed info before; fill the appropriate fields now */ - if (*bufp) - memcpy(nc->pass, bufp, PASSMAX); - else - memset(nc->pass, 0, PASSMAX); /* Which may be the case for forbidden nicks .. */ - - nc->email = email; - nc->greet = greet; - nc->icq = icq; - nc->url = url; - - /* We check whether the e-mail is valid because it was not tested - * in older versions. - */ - if (ver <= 10 && nc->email && !MailValidate(nc->email)) { - free(nc->email); - nc->email = NULL; - } - - SAFE(read_int32(&nc->flags, f)); - if (!NSAllowKillImmed) - nc->flags &= ~NI_KILL_IMMED; - - /* Status flags cleanup */ - if (na->status & NS_OLD_ENCRYPTEDPW) { - nc->flags |= NI_ENCRYPTEDPW; - na->status &= ~NS_OLD_ENCRYPTEDPW; - } - - /* Add services opers and admins to the appropriate list, but - only if the database version is equal to or more than 10. */ - if (ver >= 10) { - if (nc->flags & NI_SERVICES_ADMIN) - slist_add(&servadmins, nc); - if (nc->flags & NI_SERVICES_OPER) - slist_add(&servopers, nc); - } - - /* Add the Services root flag if needed. */ - if (nc) - for (j = 0; j < RootNumber; j++) - if (!stricmp(ServicesRoots[j], na->nick)) - nc->flags |= NI_SERVICES_ROOT; - - SAFE(read_int16(&nc->accesscount, f)); - if (nc->accesscount) { - char **access; - access = (char **)scalloc(sizeof(char *) * nc->accesscount, 1); - nc->access = access; - for (j = 0; j < nc->accesscount; j++, access++) - SAFE(read_string(access, f)); - } - - SAFE(read_int16(&tmp16, f)); - nc->memos.memocount = (int16) tmp16; - SAFE(read_int16(&tmp16, f)); - nc->memos.memomax = (int16) tmp16; - if (nc->memos.memocount) { - Memo *memos; - memos = (Memo *)scalloc(sizeof(Memo) * nc->memos.memocount, 1); - nc->memos.memos = memos; - - for (j = 0; j < nc->memos.memocount; j++, memos++) { - SAFE(read_int32(&memos->number, f)); - SAFE(read_int16(&memos->flags, f)); - SAFE(read_int32(&tmp32, f)); - memos->time = tmp32; - SAFE(read_buffer(memos->sender, f)); - SAFE(read_string(&memos->text, f)); - memos->moduleData = NULL; - } - } - - /* We read the channel count, but don't take care of it. - load_cs_dbase will regenerate it correctly. */ - SAFE(read_int16(&tmp16, f)); + dbFILE *f; + int ver, i, j, c; + NickAlias *na, *na2, *next; + NickCore *nc; + int failed = 0; + + uint16 tmp16; + uint32 tmp32; + + char bufn[NICKMAX], bufp[PASSMAX]; + char *email, *greet, *url, *forbidby, *forbidreason; + uint32 icq; + + if (!(f = open_db(s_NickServ, NickDBName, "r", NICK_VERSION))) + return; + + ver = get_file_version(f); + if (ver <= 4) { + fatal("Unsupported version number (%d) on %s", ver, NickDBName); + close_db(f); + return; + } + + for (i = 0; i < 256 && !failed; i++) { + while ((c = getc_db(f)) == 1) { + if (c != 1) + fatal("Invalid format in %s", NickDBName); + + na = (NickAlias *)scalloc(sizeof(NickAlias), 1); + + SAFE(read_buffer(bufn, f)); + na->nick = sstrdup(bufn); + SAFE(read_buffer(bufp, f)); /* Will be used later if needed */ + + SAFE(read_string(&url, f)); + SAFE(read_string(&email, f)); + if (ver >= 10) + SAFE(read_int32(&icq, f)); + else + icq = 0; + if (ver >= 9) + SAFE(read_string(&greet, f)); + else + greet = NULL; + + SAFE(read_string(&na->last_usermask, f)); + SAFE(read_string(&na->last_realname, f)); + SAFE(read_string(&na->last_quit, f)); + + SAFE(read_int32(&tmp32, f)); + na->time_registered = tmp32; + SAFE(read_int32(&tmp32, f)); + na->last_seen = tmp32; + + SAFE(read_int16(&na->status, f)); + na->status &= ~NS_TEMPORARY; + + if (ver >= 9) { + SAFE(read_string(&forbidby, f)); + SAFE(read_string(&forbidreason, f)); + /* Cleanup */ + if (forbidby && *forbidby == '@') { + free(forbidby); + forbidby = NULL; + } + if (forbidreason && *forbidreason == 0) { + free(forbidreason); + forbidreason = NULL; + } + } else { + forbidby = NULL; + forbidreason = NULL; + } + + if (na->status & NS_VERBOTEN) { + if (na->last_usermask) + free(na->last_usermask); + if (na->last_realname) + free(na->last_realname); + + na->last_usermask = forbidby; + na->last_realname = forbidreason; + } else { + if (!na->last_usermask) + na->last_usermask = sstrdup(""); + if (!na->last_realname) + na->last_realname = sstrdup(""); + } + + /* Store the reference for later resolving */ + SAFE(read_string((char **) &na->nc, f)); + SAFE(read_int16(&tmp16, f)); /* Was linkcount */ + + if (na->nc) { + SAFE(read_int16(&tmp16, f)); /* Was channelcount */ + } else { + /* This nick was a master nick, so it also has all the + * core info! =) + */ + nc = (NickCore *)scalloc(1, sizeof(NickCore)); + slist_init(&nc->aliases); + + /* The initial display is what used to be the master nick */ + nc->display = sstrdup(na->nick); + + /* We grabbed info before; fill the appropriate fields now */ + if (*bufp) + memcpy(nc->pass, bufp, PASSMAX); + else + memset(nc->pass, 0, PASSMAX); /* Which may be the case for forbidden nicks .. */ + + nc->email = email; + nc->greet = greet; + nc->icq = icq; + nc->url = url; + + /* We check whether the e-mail is valid because it was not tested + * in older versions. + */ + if (ver <= 10 && nc->email && !MailValidate(nc->email)) { + free(nc->email); + nc->email = NULL; + } + + SAFE(read_int32(&nc->flags, f)); + if (!NSAllowKillImmed) + nc->flags &= ~NI_KILL_IMMED; + + /* Status flags cleanup */ + if (na->status & NS_OLD_ENCRYPTEDPW) { + nc->flags |= NI_ENCRYPTEDPW; + na->status &= ~NS_OLD_ENCRYPTEDPW; + } + + /* Add services opers and admins to the appropriate list, but + only if the database version is equal to or more than 10. */ + if (ver >= 10) { + if (nc->flags & NI_SERVICES_ADMIN) + slist_add(&servadmins, nc); + if (nc->flags & NI_SERVICES_OPER) + slist_add(&servopers, nc); + } + + /* Add the Services root flag if needed. */ + if (nc) + for (j = 0; j < RootNumber; j++) + if (!stricmp(ServicesRoots[j], na->nick)) + nc->flags |= NI_SERVICES_ROOT; + + SAFE(read_int16(&nc->accesscount, f)); + if (nc->accesscount) { + char **access; + access = (char **)scalloc(sizeof(char *) * nc->accesscount, 1); + nc->access = access; + for (j = 0; j < nc->accesscount; j++, access++) + SAFE(read_string(access, f)); + } + + SAFE(read_int16(&tmp16, f)); + nc->memos.memocount = (int16) tmp16; + SAFE(read_int16(&tmp16, f)); + nc->memos.memomax = (int16) tmp16; + if (nc->memos.memocount) { + Memo *memos; + memos = (Memo *)scalloc(sizeof(Memo) * nc->memos.memocount, 1); + nc->memos.memos = memos; + + for (j = 0; j < nc->memos.memocount; j++, memos++) { + SAFE(read_int32(&memos->number, f)); + SAFE(read_int16(&memos->flags, f)); + SAFE(read_int32(&tmp32, f)); + memos->time = tmp32; + SAFE(read_buffer(memos->sender, f)); + SAFE(read_string(&memos->text, f)); + memos->moduleData = NULL; + } + } + + /* We read the channel count, but don't take care of it. + load_cs_dbase will regenerate it correctly. */ + SAFE(read_int16(&tmp16, f)); /* formerly nc->channelmax, RIP */ - SAFE(read_int16(&tmp16, f)); - SAFE(read_int16(&nc->language, f)); - - if (ver >= 11 && ver < 13) { - char *s; - - SAFE(read_int16(&tmp16, f)); - SAFE(read_int32(&tmp32, f)); - SAFE(read_int16(&tmp16, f)); - SAFE(read_string(&s, f)); - } - - /* Set us as being a master nick; fill the nc field also. - The NS_MASTER flag will not be cleared in this function. */ - na->status |= NS_MASTER; - na->nc = nc; - slist_add(&nc->aliases, na); - - /* Insert our new core in the core list */ - insert_core(nc); - } - - alpha_insert_alias(na); - - } /* while (getc_db(f) != 0) */ - } /* for (i) */ - - /* Now resolve what were called links */ - for (i = 0; i < 1024; i++) { - for (na = nalists[i]; na; na = next) { - next = na->next; - - /* Master nicks are already resolved */ - if (na->status & NS_MASTER) - continue; - - na2 = na; - /* While the reference resolves and it's not a master nick */ - while ((na2 = findnick((char *) na2->nc)) - && !(na2->status & NS_MASTER)); - - /* It didn't resolve. This is problematic since there is no core. :/ - We delete the nick. */ - if (!na2) { - alog("%s: while loading database: %s was linked to inexistant %s", s_NickServ, na->nick, (char *) na->nc); - delnick(na); - continue; - } - - /* OK we have information on the core. We mark the current alias - as a master nick because it now contains a valid core. */ - na->nc = na2->nc; - na->status |= NS_MASTER; - slist_add(&na->nc->aliases, na); - } - } - - close_db(f); + SAFE(read_int16(&tmp16, f)); + SAFE(read_int16(&nc->language, f)); + + if (ver >= 11 && ver < 13) { + char *s; + + SAFE(read_int16(&tmp16, f)); + SAFE(read_int32(&tmp32, f)); + SAFE(read_int16(&tmp16, f)); + SAFE(read_string(&s, f)); + } + + /* Set us as being a master nick; fill the nc field also. + The NS_MASTER flag will not be cleared in this function. */ + na->status |= NS_MASTER; + na->nc = nc; + slist_add(&nc->aliases, na); + + /* Insert our new core in the core list */ + insert_core(nc); + } + + alpha_insert_alias(na); + + } /* while (getc_db(f) != 0) */ + } /* for (i) */ + + /* Now resolve what were called links */ + for (i = 0; i < 1024; i++) { + for (na = nalists[i]; na; na = next) { + next = na->next; + + /* Master nicks are already resolved */ + if (na->status & NS_MASTER) + continue; + + na2 = na; + /* While the reference resolves and it's not a master nick */ + while ((na2 = findnick((char *) na2->nc)) + && !(na2->status & NS_MASTER)); + + /* It didn't resolve. This is problematic since there is no core. :/ + We delete the nick. */ + if (!na2) { + alog("%s: while loading database: %s was linked to inexistant %s", s_NickServ, na->nick, (char *) na->nc); + delnick(na); + continue; + } + + /* OK we have information on the core. We mark the current alias + as a master nick because it now contains a valid core. */ + na->nc = na2->nc; + na->status |= NS_MASTER; + slist_add(&na->nc->aliases, na); + } + } + + close_db(f); } void load_ns_req_db(void) { - dbFILE *f; - int i, c, ver; - NickRequest *nr; - uint32 tmp32; - int failed = 0, len; - char *pass; - - if (!(f = open_db(s_NickServ, PreNickDBName, "r", PRE_NICK_VERSION))) - return; - ver = get_file_version(f); - for (i = 0; i < 1024 && !failed; i++) { - while ((c = getc_db(f)) == 1) { - if (c != 1) - fatal("Invalid format in %s", PreNickDBName); - nr = (NickRequest *)scalloc(1, sizeof(NickRequest)); - SAFE(read_string(&nr->nick, f)); - SAFE(read_string(&nr->passcode, f)); - if (ver < 2) { - SAFE(read_string(&pass, f)); - len = strlen(pass); - enc_encrypt(pass, len, nr->password, PASSMAX); - memset(pass, 0, len); - free(pass); - } else - SAFE(read_buffer(nr->password, f)); - SAFE(read_string(&nr->email, f)); - SAFE(read_int32(&tmp32, f)); - nr->requested = tmp32; - insert_requestnick(nr); - } - } - close_db(f); + dbFILE *f; + int i, c, ver; + NickRequest *nr; + uint32 tmp32; + int failed = 0, len; + char *pass; + + if (!(f = open_db(s_NickServ, PreNickDBName, "r", PRE_NICK_VERSION))) + return; + ver = get_file_version(f); + for (i = 0; i < 1024 && !failed; i++) { + while ((c = getc_db(f)) == 1) { + if (c != 1) + fatal("Invalid format in %s", PreNickDBName); + nr = (NickRequest *)scalloc(1, sizeof(NickRequest)); + SAFE(read_string(&nr->nick, f)); + SAFE(read_string(&nr->passcode, f)); + if (ver < 2) { + SAFE(read_string(&pass, f)); + len = strlen(pass); + enc_encrypt(pass, len, nr->password, PASSMAX); + memset(pass, 0, len); + free(pass); + } else + SAFE(read_buffer(nr->password, f)); + SAFE(read_string(&nr->email, f)); + SAFE(read_int32(&tmp32, f)); + nr->requested = tmp32; + insert_requestnick(nr); + } + } + close_db(f); } void load_ns_dbase(void) { - dbFILE *f; - int ver, i, j, c; - NickAlias *na, **nalast, *naprev; - NickCore *nc, **nclast, *ncprev; - int failed = 0; - uint16 tmp16; - uint32 tmp32; - char *s, *pass; - - if (!(f = open_db(s_NickServ, NickDBName, "r", NICK_VERSION))) - return; - - ver = get_file_version(f); - - if (ver <= 11) { - close_db(f); - load_old_ns_dbase(); - return; - } - - /* First we load nick cores */ - for (i = 0; i < 1024 && !failed; i++) { - nclast = &nclists[i]; - ncprev = NULL; - - while ((c = getc_db(f)) == 1) { - if (c != 1) - fatal("Invalid format in %s", NickDBName); - - nc = (NickCore *)scalloc(1, sizeof(NickCore)); - *nclast = nc; - nclast = &nc->next; - nc->prev = ncprev; - ncprev = nc; - - slist_init(&nc->aliases); - - SAFE(read_string(&nc->display, f)); - if (ver < 14) { - SAFE(read_string(&pass, f)); - if (pass) { - memset(nc->pass, 0, PASSMAX); - memcpy(nc->pass, pass, strlen(pass)); - } else - memset(nc->pass, 0, PASSMAX); - } else - SAFE(read_buffer(nc->pass, f)); - - SAFE(read_string(&nc->email, f)); - SAFE(read_string(&nc->greet, f)); - SAFE(read_int32(&nc->icq, f)); - SAFE(read_string(&nc->url, f)); - - SAFE(read_int32(&nc->flags, f)); - if (!NSAllowKillImmed) - nc->flags &= ~NI_KILL_IMMED; - SAFE(read_int16(&nc->language, f)); - - /* Add services opers and admins to the appropriate list, but - only if the database version is more than 10. */ - if (nc->flags & NI_SERVICES_ADMIN) - slist_add(&servadmins, nc); - if (nc->flags & NI_SERVICES_OPER) - slist_add(&servopers, nc); - - SAFE(read_int16(&nc->accesscount, f)); - if (nc->accesscount) { - char **access; - access = (char **)scalloc(sizeof(char *) * nc->accesscount, 1); - nc->access = access; - for (j = 0; j < nc->accesscount; j++, access++) - SAFE(read_string(access, f)); - } - - SAFE(read_int16(&tmp16, f)); - nc->memos.memocount = (int16) tmp16; - SAFE(read_int16(&tmp16, f)); - nc->memos.memomax = (int16) tmp16; - if (nc->memos.memocount) { - Memo *memos; - memos = (Memo *)scalloc(sizeof(Memo) * nc->memos.memocount, 1); - nc->memos.memos = memos; - for (j = 0; j < nc->memos.memocount; j++, memos++) { - SAFE(read_int32(&memos->number, f)); - SAFE(read_int16(&memos->flags, f)); - SAFE(read_int32(&tmp32, f)); - memos->time = tmp32; - SAFE(read_buffer(memos->sender, f)); - SAFE(read_string(&memos->text, f)); - memos->moduleData = NULL; - } - } - - SAFE(read_int16(&nc->channelcount, f)); - SAFE(read_int16(&tmp16, f)); - - if (ver < 13) { - /* Used to be dead authentication system */ - SAFE(read_int16(&tmp16, f)); - SAFE(read_int32(&tmp32, f)); - SAFE(read_int16(&tmp16, f)); - SAFE(read_string(&s, f)); - } - - } /* while (getc_db(f) != 0) */ - *nclast = NULL; - } /* for (i) */ - - for (i = 0; i < 1024 && !failed; i++) { - nalast = &nalists[i]; - naprev = NULL; - while ((c = getc_db(f)) == 1) { - if (c != 1) - fatal("Invalid format in %s", NickDBName); - - na = (NickAlias *)scalloc(1, sizeof(NickAlias)); - - SAFE(read_string(&na->nick, f)); - - SAFE(read_string(&na->last_usermask, f)); - SAFE(read_string(&na->last_realname, f)); - SAFE(read_string(&na->last_quit, f)); - - SAFE(read_int32(&tmp32, f)); - na->time_registered = tmp32; - SAFE(read_int32(&tmp32, f)); - na->last_seen = tmp32; - SAFE(read_int16(&na->status, f)); - na->status &= ~NS_TEMPORARY; - - SAFE(read_string(&s, f)); - na->nc = findcore(s); - free(s); - - slist_add(&na->nc->aliases, na); - - if (!(na->status & NS_VERBOTEN)) { - if (!na->last_usermask) - na->last_usermask = sstrdup(""); - if (!na->last_realname) - na->last_realname = sstrdup(""); - } - - na->nc->flags &= ~NI_SERVICES_ROOT; - - *nalast = na; - nalast = &na->next; - na->prev = naprev; - naprev = na; - - } /* while (getc_db(f) != 0) */ - - *nalast = NULL; - } /* for (i) */ - - close_db(f); - - for (i = 0; i < 1024; i++) { - NickAlias *next; - - for (na = nalists[i]; na; na = next) { - next = na->next; - /* We check for coreless nicks (although it should never happen) */ - if (!na->nc) { - alog("%s: while loading database: %s has no core! We delete it.", s_NickServ, na->nick); - delnick(na); - continue; - } - - /* Add the Services root flag if needed. */ - for (j = 0; j < RootNumber; j++) - if (!stricmp(ServicesRoots[j], na->nick)) - na->nc->flags |= NI_SERVICES_ROOT; - } - } + dbFILE *f; + int ver, i, j, c; + NickAlias *na, **nalast, *naprev; + NickCore *nc, **nclast, *ncprev; + int failed = 0; + uint16 tmp16; + uint32 tmp32; + char *s, *pass; + + if (!(f = open_db(s_NickServ, NickDBName, "r", NICK_VERSION))) + return; + + ver = get_file_version(f); + + if (ver <= 11) { + close_db(f); + load_old_ns_dbase(); + return; + } + + /* First we load nick cores */ + for (i = 0; i < 1024 && !failed; i++) { + nclast = &nclists[i]; + ncprev = NULL; + + while ((c = getc_db(f)) == 1) { + if (c != 1) + fatal("Invalid format in %s", NickDBName); + + nc = (NickCore *)scalloc(1, sizeof(NickCore)); + *nclast = nc; + nclast = &nc->next; + nc->prev = ncprev; + ncprev = nc; + + slist_init(&nc->aliases); + + SAFE(read_string(&nc->display, f)); + if (ver < 14) { + SAFE(read_string(&pass, f)); + if (pass) { + memset(nc->pass, 0, PASSMAX); + memcpy(nc->pass, pass, strlen(pass)); + } else + memset(nc->pass, 0, PASSMAX); + } else + SAFE(read_buffer(nc->pass, f)); + + SAFE(read_string(&nc->email, f)); + SAFE(read_string(&nc->greet, f)); + SAFE(read_int32(&nc->icq, f)); + SAFE(read_string(&nc->url, f)); + + SAFE(read_int32(&nc->flags, f)); + if (!NSAllowKillImmed) + nc->flags &= ~NI_KILL_IMMED; + SAFE(read_int16(&nc->language, f)); + + /* Add services opers and admins to the appropriate list, but + only if the database version is more than 10. */ + if (nc->flags & NI_SERVICES_ADMIN) + slist_add(&servadmins, nc); + if (nc->flags & NI_SERVICES_OPER) + slist_add(&servopers, nc); + + SAFE(read_int16(&nc->accesscount, f)); + if (nc->accesscount) { + char **access; + access = (char **)scalloc(sizeof(char *) * nc->accesscount, 1); + nc->access = access; + for (j = 0; j < nc->accesscount; j++, access++) + SAFE(read_string(access, f)); + } + + SAFE(read_int16(&tmp16, f)); + nc->memos.memocount = (int16) tmp16; + SAFE(read_int16(&tmp16, f)); + nc->memos.memomax = (int16) tmp16; + if (nc->memos.memocount) { + Memo *memos; + memos = (Memo *)scalloc(sizeof(Memo) * nc->memos.memocount, 1); + nc->memos.memos = memos; + for (j = 0; j < nc->memos.memocount; j++, memos++) { + SAFE(read_int32(&memos->number, f)); + SAFE(read_int16(&memos->flags, f)); + SAFE(read_int32(&tmp32, f)); + memos->time = tmp32; + SAFE(read_buffer(memos->sender, f)); + SAFE(read_string(&memos->text, f)); + memos->moduleData = NULL; + } + } + + SAFE(read_int16(&nc->channelcount, f)); + SAFE(read_int16(&tmp16, f)); + + if (ver < 13) { + /* Used to be dead authentication system */ + SAFE(read_int16(&tmp16, f)); + SAFE(read_int32(&tmp32, f)); + SAFE(read_int16(&tmp16, f)); + SAFE(read_string(&s, f)); + } + + } /* while (getc_db(f) != 0) */ + *nclast = NULL; + } /* for (i) */ + + for (i = 0; i < 1024 && !failed; i++) { + nalast = &nalists[i]; + naprev = NULL; + while ((c = getc_db(f)) == 1) { + if (c != 1) + fatal("Invalid format in %s", NickDBName); + + na = (NickAlias *)scalloc(1, sizeof(NickAlias)); + + SAFE(read_string(&na->nick, f)); + + SAFE(read_string(&na->last_usermask, f)); + SAFE(read_string(&na->last_realname, f)); + SAFE(read_string(&na->last_quit, f)); + + SAFE(read_int32(&tmp32, f)); + na->time_registered = tmp32; + SAFE(read_int32(&tmp32, f)); + na->last_seen = tmp32; + SAFE(read_int16(&na->status, f)); + na->status &= ~NS_TEMPORARY; + + SAFE(read_string(&s, f)); + na->nc = findcore(s); + free(s); + + slist_add(&na->nc->aliases, na); + + if (!(na->status & NS_VERBOTEN)) { + if (!na->last_usermask) + na->last_usermask = sstrdup(""); + if (!na->last_realname) + na->last_realname = sstrdup(""); + } + + na->nc->flags &= ~NI_SERVICES_ROOT; + + *nalast = na; + nalast = &na->next; + na->prev = naprev; + naprev = na; + + } /* while (getc_db(f) != 0) */ + + *nalast = NULL; + } /* for (i) */ + + close_db(f); + + for (i = 0; i < 1024; i++) { + NickAlias *next; + + for (na = nalists[i]; na; na = next) { + next = na->next; + /* We check for coreless nicks (although it should never happen) */ + if (!na->nc) { + alog("%s: while loading database: %s has no core! We delete it.", s_NickServ, na->nick); + delnick(na); + continue; + } + + /* Add the Services root flag if needed. */ + for (j = 0; j < RootNumber; j++) + if (!stricmp(ServicesRoots[j], na->nick)) + na->nc->flags |= NI_SERVICES_ROOT; + } + } } #undef SAFE @@ -632,120 +632,120 @@ void load_ns_dbase(void) /*************************************************************************/ #define SAFE(x) do { \ - if ((x) < 0) { \ + if ((x) < 0) { \ restore_db(f); \ log_perror("Write error on %s", NickDBName); \ if (time(NULL) - lastwarn > WarningTimeout) { \ - ircdproto->SendGlobops(NULL, "Write error on %s: %s", NickDBName, \ + ircdproto->SendGlobops(NULL, "Write error on %s: %s", NickDBName, \ strerror(errno)); \ - lastwarn = time(NULL); \ + lastwarn = time(NULL); \ } \ return; \ - } \ + } \ } while (0) void save_ns_dbase(void) { - dbFILE *f; - int i, j; - NickAlias *na; - NickCore *nc; - char **access; - Memo *memos; - static time_t lastwarn = 0; + dbFILE *f; + int i, j; + NickAlias *na; + NickCore *nc; + char **access; + Memo *memos; + static time_t lastwarn = 0; - if (!(f = open_db(s_NickServ, NickDBName, "w", NICK_VERSION))) - return; + if (!(f = open_db(s_NickServ, NickDBName, "w", NICK_VERSION))) + return; - for (i = 0; i < 1024; i++) { - for (nc = nclists[i]; nc; nc = nc->next) { - SAFE(write_int8(1, f)); + for (i = 0; i < 1024; i++) { + for (nc = nclists[i]; nc; nc = nc->next) { + SAFE(write_int8(1, f)); - SAFE(write_string(nc->display, f)); - SAFE(write_buffer(nc->pass, f)); + SAFE(write_string(nc->display, f)); + SAFE(write_buffer(nc->pass, f)); - SAFE(write_string(nc->email, f)); - SAFE(write_string(nc->greet, f)); - SAFE(write_int32(nc->icq, f)); - SAFE(write_string(nc->url, f)); + SAFE(write_string(nc->email, f)); + SAFE(write_string(nc->greet, f)); + SAFE(write_int32(nc->icq, f)); + SAFE(write_string(nc->url, f)); - SAFE(write_int32(nc->flags, f)); - SAFE(write_int16(nc->language, f)); + SAFE(write_int32(nc->flags, f)); + SAFE(write_int16(nc->language, f)); - SAFE(write_int16(nc->accesscount, f)); - for (j = 0, access = nc->access; j < nc->accesscount; - j++, access++) - SAFE(write_string(*access, f)); + SAFE(write_int16(nc->accesscount, f)); + for (j = 0, access = nc->access; j < nc->accesscount; + j++, access++) + SAFE(write_string(*access, f)); - SAFE(write_int16(nc->memos.memocount, f)); - SAFE(write_int16(nc->memos.memomax, f)); - memos = nc->memos.memos; - for (j = 0; j < nc->memos.memocount; j++, memos++) { - SAFE(write_int32(memos->number, f)); - SAFE(write_int16(memos->flags, f)); - SAFE(write_int32(memos->time, f)); - SAFE(write_buffer(memos->sender, f)); - SAFE(write_string(memos->text, f)); - } + SAFE(write_int16(nc->memos.memocount, f)); + SAFE(write_int16(nc->memos.memomax, f)); + memos = nc->memos.memos; + for (j = 0; j < nc->memos.memocount; j++, memos++) { + SAFE(write_int32(memos->number, f)); + SAFE(write_int16(memos->flags, f)); + SAFE(write_int32(memos->time, f)); + SAFE(write_buffer(memos->sender, f)); + SAFE(write_string(memos->text, f)); + } - SAFE(write_int16(nc->channelcount, f)); - SAFE(write_int16(nc->channelcount, f)); // write this twice to avoid having to revbump the NickServ DB from anope 1.7, hack alert XXX + SAFE(write_int16(nc->channelcount, f)); + SAFE(write_int16(nc->channelcount, f)); // write this twice to avoid having to revbump the NickServ DB from anope 1.7, hack alert XXX - } /* for (nc) */ + } /* for (nc) */ - SAFE(write_int8(0, f)); + SAFE(write_int8(0, f)); - } /* for (i) */ + } /* for (i) */ - for (i = 0; i < 1024; i++) { - for (na = nalists[i]; na; na = na->next) { - SAFE(write_int8(1, f)); + for (i = 0; i < 1024; i++) { + for (na = nalists[i]; na; na = na->next) { + SAFE(write_int8(1, f)); - SAFE(write_string(na->nick, f)); + SAFE(write_string(na->nick, f)); - SAFE(write_string(na->last_usermask, f)); - SAFE(write_string(na->last_realname, f)); - SAFE(write_string(na->last_quit, f)); + SAFE(write_string(na->last_usermask, f)); + SAFE(write_string(na->last_realname, f)); + SAFE(write_string(na->last_quit, f)); - SAFE(write_int32(na->time_registered, f)); - SAFE(write_int32(na->last_seen, f)); + SAFE(write_int32(na->time_registered, f)); + SAFE(write_int32(na->last_seen, f)); - SAFE(write_int16(na->status, f)); + SAFE(write_int16(na->status, f)); - SAFE(write_string(na->nc->display, f)); + SAFE(write_string(na->nc->display, f)); - } /* for (na) */ - SAFE(write_int8(0, f)); - } /* for (i) */ + } /* for (na) */ + SAFE(write_int8(0, f)); + } /* for (i) */ - close_db(f); + close_db(f); } void save_ns_req_dbase(void) { - dbFILE *f; - int i; - NickRequest *nr; - static time_t lastwarn = 0; - - if (!(f = open_db(s_NickServ, PreNickDBName, "w", PRE_NICK_VERSION))) - return; - - for (i = 0; i < 1024; i++) { - for (nr = nrlists[i]; nr; nr = nr->next) { - SAFE(write_int8(1, f)); - SAFE(write_string(nr->nick, f)); - SAFE(write_string(nr->passcode, f)); - SAFE(write_buffer(nr->password, f)); - SAFE(write_string(nr->email, f)); - SAFE(write_int32(nr->requested, f)); - SAFE(write_int8(0, f)); - } - } - close_db(f); + dbFILE *f; + int i; + NickRequest *nr; + static time_t lastwarn = 0; + + if (!(f = open_db(s_NickServ, PreNickDBName, "w", PRE_NICK_VERSION))) + return; + + for (i = 0; i < 1024; i++) { + for (nr = nrlists[i]; nr; nr = nr->next) { + SAFE(write_int8(1, f)); + SAFE(write_string(nr->nick, f)); + SAFE(write_string(nr->passcode, f)); + SAFE(write_buffer(nr->password, f)); + SAFE(write_string(nr->email, f)); + SAFE(write_int32(nr->requested, f)); + SAFE(write_int8(0, f)); + } + } + close_db(f); } @@ -763,71 +763,71 @@ void save_ns_req_dbase(void) int validate_user(User * u) { - NickAlias *na; - NickRequest *nr; - - int on_access; - - if ((nr = findrequestnick(u->nick))) { - notice_lang(s_NickServ, u, NICK_IS_PREREG); - } - - if (!(na = u->na)) - return 0; - - if (na->status & NS_VERBOTEN) { - notice_lang(s_NickServ, u, NICK_MAY_NOT_BE_USED); - collide(na, 0); - return 0; - } - - if (na->nc->flags & NI_SUSPENDED) { - notice_lang(s_NickServ, u, NICK_X_SUSPENDED, u->nick); - collide(na, 0); - return 0; - } - - on_access = is_on_access(u, na->nc); - if (on_access) - na->status |= NS_ON_ACCESS; - - if (!(na->nc->flags & NI_SECURE) && on_access) { - na->status |= NS_RECOGNIZED; - na->last_seen = time(NULL); - if (na->last_usermask) - free(na->last_usermask); - na->last_usermask = - (char *)scalloc(strlen(common_get_vident(u)) + - strlen(common_get_vhost(u)) + 2, 1); - sprintf(na->last_usermask, "%s@%s", common_get_vident(u), - common_get_vhost(u)); - if (na->last_realname) - free(na->last_realname); - na->last_realname = sstrdup(u->realname); - return 1; - } - - if (on_access || !(na->nc->flags & NI_KILL_IMMED)) { - if (na->nc->flags & NI_SECURE) - notice_lang(s_NickServ, u, NICK_IS_SECURE, s_NickServ); - else - notice_lang(s_NickServ, u, NICK_IS_REGISTERED, s_NickServ); - } - - if ((na->nc->flags & NI_KILLPROTECT) && !on_access) { - if (na->nc->flags & NI_KILL_IMMED) { - notice_lang(s_NickServ, u, FORCENICKCHANGE_NOW); - collide(na, 0); - } else if (na->nc->flags & NI_KILL_QUICK) { - notice_lang(s_NickServ, u, FORCENICKCHANGE_IN_20_SECONDS); - add_ns_timeout(na, TO_COLLIDE, 20); - } else { - notice_lang(s_NickServ, u, FORCENICKCHANGE_IN_1_MINUTE); - add_ns_timeout(na, TO_COLLIDE, 60); - } - } - - return 0; + NickAlias *na; + NickRequest *nr; + + int on_access; + + if ((nr = findrequestnick(u->nick))) { + notice_lang(s_NickServ, u, NICK_IS_PREREG); + } + + if (!(na = u->na)) + return 0; + + if (na->status & NS_VERBOTEN) { + notice_lang(s_NickServ, u, NICK_MAY_NOT_BE_USED); + collide(na, 0); + return 0; + } + + if (na->nc->flags & NI_SUSPENDED) { + notice_lang(s_NickServ, u, NICK_X_SUSPENDED, u->nick); + collide(na, 0); + return 0; + } + + on_access = is_on_access(u, na->nc); + if (on_access) + na->status |= NS_ON_ACCESS; + + if (!(na->nc->flags & NI_SECURE) && on_access) { + na->status |= NS_RECOGNIZED; + na->last_seen = time(NULL); + if (na->last_usermask) + free(na->last_usermask); + na->last_usermask = + (char *)scalloc(strlen(common_get_vident(u)) + + strlen(common_get_vhost(u)) + 2, 1); + sprintf(na->last_usermask, "%s@%s", common_get_vident(u), + common_get_vhost(u)); + if (na->last_realname) + free(na->last_realname); + na->last_realname = sstrdup(u->realname); + return 1; + } + + if (on_access || !(na->nc->flags & NI_KILL_IMMED)) { + if (na->nc->flags & NI_SECURE) + notice_lang(s_NickServ, u, NICK_IS_SECURE, s_NickServ); + else + notice_lang(s_NickServ, u, NICK_IS_REGISTERED, s_NickServ); + } + + if ((na->nc->flags & NI_KILLPROTECT) && !on_access) { + if (na->nc->flags & NI_KILL_IMMED) { + notice_lang(s_NickServ, u, FORCENICKCHANGE_NOW); + collide(na, 0); + } else if (na->nc->flags & NI_KILL_QUICK) { + notice_lang(s_NickServ, u, FORCENICKCHANGE_IN_20_SECONDS); + add_ns_timeout(na, TO_COLLIDE, 20); + } else { + notice_lang(s_NickServ, u, FORCENICKCHANGE_IN_1_MINUTE); + add_ns_timeout(na, TO_COLLIDE, 60); + } + } + + return 0; } /*************************************************************************/ @@ -837,42 +837,42 @@ int validate_user(User * u) void cancel_user(User * u) { - NickAlias *na = u->na; - - if (na) { - if (na->status & NS_GUESTED) { - if (ircd->svshold) { - if (UseSVSHOLD) { - ircdproto->SendSVSHold(na->nick); - } else { - if (ircd->svsnick) { - ircdproto->SendClientIntroduction(u->nick, NSEnforcerUser, - NSEnforcerHost, - "Services Enforcer", "+", ts6_uid_retrieve()); - add_ns_timeout(na, TO_RELEASE, NSReleaseTimeout); - } else { - ircdproto->SendSVSKill(s_NickServ, u->nick, - "Killing to enforce nick"); - } - } - } else { - if (ircd->svsnick) { - ircdproto->SendClientIntroduction(u->nick, NSEnforcerUser, - NSEnforcerHost, - "Services Enforcer", "+", ts6_uid_retrieve()); - add_ns_timeout(na, TO_RELEASE, NSReleaseTimeout); - } else { - ircdproto->SendSVSKill(s_NickServ, u->nick, - "Killing to enforce nick"); - } - } - na->status &= ~NS_TEMPORARY; - na->status |= NS_KILL_HELD; - } else { - na->status &= ~NS_TEMPORARY; - } - del_ns_timeout(na, TO_COLLIDE); - } + NickAlias *na = u->na; + + if (na) { + if (na->status & NS_GUESTED) { + if (ircd->svshold) { + if (UseSVSHOLD) { + ircdproto->SendSVSHold(na->nick); + } else { + if (ircd->svsnick) { + ircdproto->SendClientIntroduction(u->nick, NSEnforcerUser, + NSEnforcerHost, + "Services Enforcer", "+", ts6_uid_retrieve()); + add_ns_timeout(na, TO_RELEASE, NSReleaseTimeout); + } else { + ircdproto->SendSVSKill(s_NickServ, u->nick, + "Killing to enforce nick"); + } + } + } else { + if (ircd->svsnick) { + ircdproto->SendClientIntroduction(u->nick, NSEnforcerUser, + NSEnforcerHost, + "Services Enforcer", "+", ts6_uid_retrieve()); + add_ns_timeout(na, TO_RELEASE, NSReleaseTimeout); + } else { + ircdproto->SendSVSKill(s_NickServ, u->nick, + "Killing to enforce nick"); + } + } + na->status &= ~NS_TEMPORARY; + na->status |= NS_KILL_HELD; + } else { + na->status &= ~NS_TEMPORARY; + } + del_ns_timeout(na, TO_COLLIDE); + } } /*************************************************************************/ @@ -881,18 +881,18 @@ void cancel_user(User * u) int nick_identified(User * u) { - if (u) { - if (u->na) { - if (u->na->status) { - return (u->na->status & NS_IDENTIFIED); - } else { - return 0; - } - } else { - return 0; - } - } - return 0; + if (u) { + if (u->na) { + if (u->na->status) { + return (u->na->status & NS_IDENTIFIED); + } else { + return 0; + } + } else { + return 0; + } + } + return 0; } /*************************************************************************/ @@ -901,18 +901,18 @@ int nick_identified(User * u) int nick_recognized(User * u) { - if (u) { - if (u->na) { - if (u->na->status) { - return (u->na->status & (NS_IDENTIFIED | NS_RECOGNIZED)); - } else { - return 0; - } - } else { - return 0; - } - } - return 0; + if (u) { + if (u->na) { + if (u->na->status) { + return (u->na->status & (NS_IDENTIFIED | NS_RECOGNIZED)); + } else { + return 0; + } + } else { + return 0; + } + } + return 0; } /*************************************************************************/ @@ -921,7 +921,7 @@ int nick_recognized(User * u) int group_identified(User * u, NickCore * nc) { - return nick_identified(u) && u->na->nc == nc; + return nick_identified(u) && u->na->nc == nc; } /*************************************************************************/ @@ -932,54 +932,54 @@ int group_identified(User * u, NickCore * nc) void expire_nicks() { - int i; - NickAlias *na, *next; - time_t now = time(NULL); - char *tmpnick; - - for (i = 0; i < 1024; i++) { - for (na = nalists[i]; na; na = next) { - next = na->next; - - if (na->u - && ((na->nc->flags & NI_SECURE) ? nick_identified(na->u) : - nick_recognized(na->u))) { - if (debug >= 2) - alog("debug: NickServ: updating last seen time for %s", - na->nick); - na->last_seen = now; - continue; - } - - if (NSExpire && now - na->last_seen >= NSExpire - && !(na->status & (NS_VERBOTEN | NS_NO_EXPIRE)) - && !(na->nc->flags & (NI_SUSPENDED))) { - alog("Expiring nickname %s (group: %s) (e-mail: %s)", - na->nick, na->nc->display, - (na->nc->email ? na->nc->email : "none")); - tmpnick = sstrdup(na->nick); - delnick(na); - send_event(EVENT_NICK_EXPIRE, 1, tmpnick); - free(tmpnick); - } - } - } + int i; + NickAlias *na, *next; + time_t now = time(NULL); + char *tmpnick; + + for (i = 0; i < 1024; i++) { + for (na = nalists[i]; na; na = next) { + next = na->next; + + if (na->u + && ((na->nc->flags & NI_SECURE) ? nick_identified(na->u) : + nick_recognized(na->u))) { + if (debug >= 2) + alog("debug: NickServ: updating last seen time for %s", + na->nick); + na->last_seen = now; + continue; + } + + if (NSExpire && now - na->last_seen >= NSExpire + && !(na->status & (NS_VERBOTEN | NS_NO_EXPIRE)) + && !(na->nc->flags & (NI_SUSPENDED))) { + alog("Expiring nickname %s (group: %s) (e-mail: %s)", + na->nick, na->nc->display, + (na->nc->email ? na->nc->email : "none")); + tmpnick = sstrdup(na->nick); + delnick(na); + send_event(EVENT_NICK_EXPIRE, 1, tmpnick); + free(tmpnick); + } + } + } } void expire_requests() { - int i; - NickRequest *nr, *next; - time_t now = time(NULL); - for (i = 0; i < 1024; i++) { - for (nr = nrlists[i]; nr; nr = next) { - next = nr->next; - if (NSRExpire && now - nr->requested >= NSRExpire) { - alog("Request for nick %s expiring", nr->nick); - delnickrequest(nr); - } - } - } + int i; + NickRequest *nr, *next; + time_t now = time(NULL); + for (i = 0; i < 1024; i++) { + for (nr = nrlists[i]; nr; nr = next) { + next = nr->next; + if (NSRExpire && now - nr->requested >= NSRExpire) { + alog("Request for nick %s expiring", nr->nick); + delnickrequest(nr); + } + } + } } /*************************************************************************/ @@ -988,20 +988,20 @@ void expire_requests() NickRequest *findrequestnick(const char *nick) { - NickRequest *nr; - - if (!*nick || !nick) { - if (debug) { - alog("debug: findrequestnick() called with NULL values"); - } - return NULL; - } - - for (nr = nrlists[HASH(nick)]; nr; nr = nr->next) { - if (stricmp(nr->nick, nick) == 0) - return nr; - } - return NULL; + NickRequest *nr; + + if (!*nick || !nick) { + if (debug) { + alog("debug: findrequestnick() called with NULL values"); + } + return NULL; + } + + for (nr = nrlists[HASH(nick)]; nr; nr = nr->next) { + if (stricmp(nr->nick, nick) == 0) + return nr; + } + return NULL; } /* Return the NickAlias structure for the given nick, or NULL if the nick @@ -1009,21 +1009,21 @@ NickRequest *findrequestnick(const char *nick) NickAlias *findnick(const char *nick) { - NickAlias *na; + NickAlias *na; - if (!nick || !*nick) { - if (debug) { - alog("debug: findnick() called with NULL values"); - } - return NULL; - } + if (!nick || !*nick) { + if (debug) { + alog("debug: findnick() called with NULL values"); + } + return NULL; + } - for (na = nalists[HASH(nick)]; na; na = na->next) { - if (stricmp(na->nick, nick) == 0) - return na; - } + for (na = nalists[HASH(nick)]; na; na = na->next) { + if (stricmp(na->nick, nick) == 0) + return na; + } - return NULL; + return NULL; } NickAlias *findnick(const std::string &nick) @@ -1038,21 +1038,21 @@ NickAlias *findnick(const std::string &nick) NickCore *findcore(const char *nick) { - NickCore *nc; + NickCore *nc; - if (!nick || !*nick) { - if (debug) { - alog("debug: findcore() called with NULL values"); - } - return NULL; - } + if (!nick || !*nick) { + if (debug) { + alog("debug: findcore() called with NULL values"); + } + return NULL; + } - for (nc = nclists[HASH(nick)]; nc; nc = nc->next) { - if (stricmp(nc->display, nick) == 0) - return nc; - } + for (nc = nclists[HASH(nick)]; nc; nc = nc->next) { + if (stricmp(nc->display, nick) == 0) + return nc; + } - return NULL; + return NULL; } /*************************************************************************/ @@ -1064,39 +1064,39 @@ NickCore *findcore(const char *nick) int is_on_access(User * u, NickCore * nc) { - int i; - char *buf; - char *buf2 = NULL; - - if (nc->accesscount == 0) - return 0; - - buf = (char *)scalloc(strlen(u->username) + strlen(u->host) + 2, 1); - sprintf(buf, "%s@%s", u->username, u->host); - if (ircd->vhost) { - if (u->vhost) { - buf2 = (char *)scalloc(strlen(u->username) + strlen(u->vhost) + 2, 1); - sprintf(buf2, "%s@%s", u->username, u->vhost); - } - } - - for (i = 0; i < nc->accesscount; i++) { - if (match_wild_nocase(nc->access[i], buf) - || (ircd->vhost ? match_wild_nocase(nc->access[i], buf2) : 0)) { - free(buf); - if (ircd->vhost) { - if (u->vhost) { - free(buf2); - } - } - return 1; - } - } - free(buf); - if (ircd->vhost) { - free(buf2); - } - return 0; + int i; + char *buf; + char *buf2 = NULL; + + if (nc->accesscount == 0) + return 0; + + buf = (char *)scalloc(strlen(u->username) + strlen(u->host) + 2, 1); + sprintf(buf, "%s@%s", u->username, u->host); + if (ircd->vhost) { + if (u->vhost) { + buf2 = (char *)scalloc(strlen(u->username) + strlen(u->vhost) + 2, 1); + sprintf(buf2, "%s@%s", u->username, u->vhost); + } + } + + for (i = 0; i < nc->accesscount; i++) { + if (match_wild_nocase(nc->access[i], buf) + || (ircd->vhost ? match_wild_nocase(nc->access[i], buf2) : 0)) { + free(buf); + if (ircd->vhost) { + if (u->vhost) { + free(buf2); + } + } + return 1; + } + } + free(buf); + if (ircd->vhost) { + free(buf2); + } + return 0; } /*************************************************************************/ @@ -1105,30 +1105,30 @@ int is_on_access(User * u, NickCore * nc) void alpha_insert_alias(NickAlias * na) { - NickAlias *ptr, *prev; - char *nick; - int index; - - if (!na) { - if (debug) { - alog("debug: alpha_insert_alias called with NULL values"); - } - return; - } - - nick = na->nick; - index = HASH(nick); - - for (prev = NULL, ptr = nalists[index]; - ptr && stricmp(ptr->nick, nick) < 0; prev = ptr, ptr = ptr->next); - na->prev = prev; - na->next = ptr; - if (!prev) - nalists[index] = na; - else - prev->next = na; - if (ptr) - ptr->prev = na; + NickAlias *ptr, *prev; + char *nick; + int index; + + if (!na) { + if (debug) { + alog("debug: alpha_insert_alias called with NULL values"); + } + return; + } + + nick = na->nick; + index = HASH(nick); + + for (prev = NULL, ptr = nalists[index]; + ptr && stricmp(ptr->nick, nick) < 0; prev = ptr, ptr = ptr->next); + na->prev = prev; + na->next = ptr; + if (!prev) + nalists[index] = na; + else + prev->next = na; + if (ptr) + ptr->prev = na; } /*************************************************************************/ @@ -1137,41 +1137,41 @@ void alpha_insert_alias(NickAlias * na) void insert_core(NickCore * nc) { - int index; - - if (!nc) { - if (debug) { - alog("debug: insert_core called with NULL values"); - } - return; - } - - index = HASH(nc->display); - - nc->prev = NULL; - nc->next = nclists[index]; - if (nc->next) - nc->next->prev = nc; - nclists[index] = nc; + int index; + + if (!nc) { + if (debug) { + alog("debug: insert_core called with NULL values"); + } + return; + } + + index = HASH(nc->display); + + nc->prev = NULL; + nc->next = nclists[index]; + if (nc->next) + nc->next->prev = nc; + nclists[index] = nc; } /*************************************************************************/ void insert_requestnick(NickRequest * nr) { - int index = HASH(nr->nick); - if (!nr) { - if (debug) { - alog("debug: insert_requestnick called with NULL values"); - } - return; - } - - - nr->prev = NULL; - nr->next = nrlists[index]; - if (nr->next) - nr->next->prev = nr; - nrlists[index] = nr; + int index = HASH(nr->nick); + if (!nr) { + if (debug) { + alog("debug: insert_requestnick called with NULL values"); + } + return; + } + + + nr->prev = NULL; + nr->next = nrlists[index]; + if (nr->next) + nr->next->prev = nr; + nrlists[index] = nr; } /*************************************************************************/ @@ -1182,31 +1182,31 @@ void insert_requestnick(NickRequest * nr) void change_core_display(NickCore * nc, char *newdisplay) { - if (!newdisplay) { - NickAlias *na; + if (!newdisplay) { + NickAlias *na; - if (nc->aliases.count <= 0) - return; + if (nc->aliases.count <= 0) + return; - na = (NickAlias *)nc->aliases.list[0]; - newdisplay = na->nick; - } + na = (NickAlias *)nc->aliases.list[0]; + newdisplay = na->nick; + } - /* Log ... */ - alog("%s: changing %s nickname group display to %s", s_NickServ, - nc->display, newdisplay); + /* Log ... */ + alog("%s: changing %s nickname group display to %s", s_NickServ, + nc->display, newdisplay); - /* Remove the core from the list */ - if (nc->next) - nc->next->prev = nc->prev; - if (nc->prev) - nc->prev->next = nc->next; - else - nclists[HASH(nc->display)] = nc->next; + /* Remove the core from the list */ + if (nc->next) + nc->next->prev = nc->prev; + if (nc->prev) + nc->prev->next = nc->next; + else + nclists[HASH(nc->display)] = nc->next; - free(nc->display); - nc->display = sstrdup(newdisplay); - insert_core(nc); + free(nc->display); + nc->display = sstrdup(newdisplay); + insert_core(nc); } @@ -1219,72 +1219,72 @@ void change_core_display(NickCore * nc, char *newdisplay) static int delcore(NickCore * nc) { - int i; - /* (Hopefully complete) cleanup */ - cs_remove_nick(nc); - os_remove_nick(nc); - - /* Remove the core from the list */ - if (nc->next) - nc->next->prev = nc->prev; - if (nc->prev) - nc->prev->next = nc->next; - else - nclists[HASH(nc->display)] = nc->next; - - /* Log .. */ - alog("%s: deleting nickname group %s", s_NickServ, nc->display); - - /* Now we can safely free it. */ - free(nc->display); - - if (nc->email) - free(nc->email); - if (nc->greet) - free(nc->greet); - if (nc->url) - free(nc->url); - - if (nc->access) { - for (i = 0; i < nc->accesscount; i++) { - if (nc->access[i]) - free(nc->access[i]); - } - free(nc->access); - } - - if (nc->memos.memos) { - for (i = 0; i < nc->memos.memocount; i++) { - if (nc->memos.memos[i].text) - free(nc->memos.memos[i].text); - moduleCleanStruct(&nc->memos.memos[i].moduleData); - } - free(nc->memos.memos); - } - - moduleCleanStruct(&nc->moduleData); - - free(nc); - - return 1; + int i; + /* (Hopefully complete) cleanup */ + cs_remove_nick(nc); + os_remove_nick(nc); + + /* Remove the core from the list */ + if (nc->next) + nc->next->prev = nc->prev; + if (nc->prev) + nc->prev->next = nc->next; + else + nclists[HASH(nc->display)] = nc->next; + + /* Log .. */ + alog("%s: deleting nickname group %s", s_NickServ, nc->display); + + /* Now we can safely free it. */ + free(nc->display); + + if (nc->email) + free(nc->email); + if (nc->greet) + free(nc->greet); + if (nc->url) + free(nc->url); + + if (nc->access) { + for (i = 0; i < nc->accesscount; i++) { + if (nc->access[i]) + free(nc->access[i]); + } + free(nc->access); + } + + if (nc->memos.memos) { + for (i = 0; i < nc->memos.memocount; i++) { + if (nc->memos.memos[i].text) + free(nc->memos.memos[i].text); + moduleCleanStruct(&nc->memos.memos[i].moduleData); + } + free(nc->memos.memos); + } + + moduleCleanStruct(&nc->moduleData); + + free(nc); + + return 1; } /*************************************************************************/ int delnickrequest(NickRequest * nr) { - if (nr) { - nrlists[HASH(nr->nick)] = nr->next; - if (nr->nick) - free(nr->nick); - if (nr->passcode) - free(nr->passcode); - if (nr->email) - free(nr->email); - free(nr); - } - - return 0; + if (nr) { + nrlists[HASH(nr->nick)] = nr->next; + if (nr->nick) + free(nr->nick); + if (nr->passcode) + free(nr->passcode); + if (nr->email) + free(nr->email); + free(nr); + } + + return 0; } /*************************************************************************/ @@ -1299,59 +1299,59 @@ int delnickrequest(NickRequest * nr) int delnick(NickAlias * na) { - /* First thing to do: remove any timeout belonging to the nick we're deleting */ - clean_ns_timeouts(na); - - /* Second thing to do: look for an user using the alias - * being deleted, and make appropriate changes */ - - if (na->u) { - na->u->na = NULL; - - if (ircd->modeonunreg) - common_svsmode(na->u, ircd->modeonunreg, "1"); - - } - - delHostCore(na->nick); /* delete any vHost's for this nick */ - - /* Accept nicks that have no core, because of database load functions */ - if (na->nc) { - /* Next: see if our core is still useful. */ - slist_remove(&na->nc->aliases, na); - if (na->nc->aliases.count == 0) { - if (!delcore(na->nc)) - return 0; - na->nc = NULL; - } else { - /* Display updating stuff */ - if (!stricmp(na->nick, na->nc->display)) - change_core_display(na->nc, NULL); - } - } - - /* Remove us from the aliases list */ - if (na->next) - na->next->prev = na->prev; - if (na->prev) - na->prev->next = na->next; - else - nalists[HASH(na->nick)] = na->next; - - free(na->nick); - if (na->last_usermask) - free(na->last_usermask); - if (na->last_realname) - free(na->last_realname); - if (na->last_quit) - free(na->last_quit); - - moduleCleanStruct(&na->moduleData); - - free(na); - - - return 1; + /* First thing to do: remove any timeout belonging to the nick we're deleting */ + clean_ns_timeouts(na); + + /* Second thing to do: look for an user using the alias + * being deleted, and make appropriate changes */ + + if (na->u) { + na->u->na = NULL; + + if (ircd->modeonunreg) + common_svsmode(na->u, ircd->modeonunreg, "1"); + + } + + delHostCore(na->nick); /* delete any vHost's for this nick */ + + /* Accept nicks that have no core, because of database load functions */ + if (na->nc) { + /* Next: see if our core is still useful. */ + slist_remove(&na->nc->aliases, na); + if (na->nc->aliases.count == 0) { + if (!delcore(na->nc)) + return 0; + na->nc = NULL; + } else { + /* Display updating stuff */ + if (!stricmp(na->nick, na->nc->display)) + change_core_display(na->nc, NULL); + } + } + + /* Remove us from the aliases list */ + if (na->next) + na->next->prev = na->prev; + if (na->prev) + na->prev->next = na->next; + else + nalists[HASH(na->nick)] = na->next; + + free(na->nick); + if (na->last_usermask) + free(na->last_usermask); + if (na->last_realname) + free(na->last_realname); + if (na->last_quit) + free(na->last_quit); + + moduleCleanStruct(&na->moduleData); + + free(na); + + + return 1; } /*************************************************************************/ @@ -1368,32 +1368,32 @@ int delnick(NickAlias * na) void collide(NickAlias * na, int from_timeout) { - char guestnick[NICKMAX]; - - if (!from_timeout) - del_ns_timeout(na, TO_COLLIDE); - - /* Old system was unsure since there can be more than one collide - * per second. So let use another safer method. - * --lara - */ - /* So you should check the length of NSGuestNickPrefix, eh Lara? - * --Certus - */ - - if (ircd->svsnick) { - /* We need to make sure the guestnick is free -- heinz */ - do { - snprintf(guestnick, sizeof(guestnick), "%s%d", - NSGuestNickPrefix, getrandom16()); - } while (finduser(guestnick)); - notice_lang(s_NickServ, na->u, FORCENICKCHANGE_CHANGING, - guestnick); - ircdproto->SendForceNickChange(na->nick, guestnick, time(NULL)); - na->status |= NS_GUESTED; - } else { - kill_user(s_NickServ, na->nick, "Services nickname-enforcer kill"); - } + char guestnick[NICKMAX]; + + if (!from_timeout) + del_ns_timeout(na, TO_COLLIDE); + + /* Old system was unsure since there can be more than one collide + * per second. So let use another safer method. + * --lara + */ + /* So you should check the length of NSGuestNickPrefix, eh Lara? + * --Certus + */ + + if (ircd->svsnick) { + /* We need to make sure the guestnick is free -- heinz */ + do { + snprintf(guestnick, sizeof(guestnick), "%s%d", + NSGuestNickPrefix, getrandom16()); + } while (finduser(guestnick)); + notice_lang(s_NickServ, na->u, FORCENICKCHANGE_CHANGING, + guestnick); + ircdproto->SendForceNickChange(na->nick, guestnick, time(NULL)); + na->status |= NS_GUESTED; + } else { + kill_user(s_NickServ, na->nick, "Services nickname-enforcer kill"); + } } /*************************************************************************/ @@ -1402,28 +1402,28 @@ void collide(NickAlias * na, int from_timeout) void release(NickAlias * na, int from_timeout) { - if (!from_timeout) - del_ns_timeout(na, TO_RELEASE); - if (ircd->svshold) { - if (UseSVSHOLD) { - ircdproto->SendSVSHoldDel(na->nick); - } else { - ircdproto->SendQuit(na->nick, NULL); - } - } else { - ircdproto->SendQuit(na->nick, NULL); - } - na->status &= ~NS_KILL_HELD; + if (!from_timeout) + del_ns_timeout(na, TO_RELEASE); + if (ircd->svshold) { + if (UseSVSHOLD) { + ircdproto->SendSVSHoldDel(na->nick); + } else { + ircdproto->SendQuit(na->nick, NULL); + } + } else { + ircdproto->SendQuit(na->nick, NULL); + } + na->status &= ~NS_KILL_HELD; } /*************************************************************************/ /*************************************************************************/ static struct my_timeout { - struct my_timeout *next, *prev; - NickAlias *na; - Timeout *to; - int type; + struct my_timeout *next, *prev; + NickAlias *na; + Timeout *to; + int type; } *my_timeouts; /*************************************************************************/ @@ -1432,24 +1432,24 @@ static struct my_timeout { static void rem_ns_timeout(NickAlias * na, int type) { - struct my_timeout *t, *t2; - - t = my_timeouts; - while (t) { - if (t->na == na && t->type == type) { - t2 = t->next; - if (t->next) - t->next->prev = t->prev; - if (t->prev) - t->prev->next = t->next; - else - my_timeouts = t->next; - free(t); - t = t2; - } else { - t = t->next; - } - } + struct my_timeout *t, *t2; + + t = my_timeouts; + while (t) { + if (t->na == na && t->type == type) { + t2 = t->next; + if (t->next) + t->next->prev = t->prev; + if (t->prev) + t->prev->next = t->next; + else + my_timeouts = t->next; + free(t); + t = t2; + } else { + t = t->next; + } + } } /*************************************************************************/ @@ -1458,17 +1458,17 @@ static void rem_ns_timeout(NickAlias * na, int type) static void timeout_collide(Timeout * t) { - NickAlias *na = (NickAlias *)t->data; - - rem_ns_timeout(na, TO_COLLIDE); - /* If they identified or don't exist anymore, don't kill them. */ - if ((na->status & NS_IDENTIFIED) || !na->u - || na->u->my_signon > t->settime) - return; - /* The RELEASE timeout will always add to the beginning of the - * list, so we won't see it. Which is fine because it can't be - * triggered yet anyway. */ - collide(na, 1); + NickAlias *na = (NickAlias *)t->data; + + rem_ns_timeout(na, TO_COLLIDE); + /* If they identified or don't exist anymore, don't kill them. */ + if ((na->status & NS_IDENTIFIED) || !na->u + || na->u->my_signon > t->settime) + return; + /* The RELEASE timeout will always add to the beginning of the + * list, so we won't see it. Which is fine because it can't be + * triggered yet anyway. */ + collide(na, 1); } /*************************************************************************/ @@ -1477,10 +1477,10 @@ static void timeout_collide(Timeout * t) static void timeout_release(Timeout * t) { - NickAlias *na = (NickAlias *)t->data; + NickAlias *na = (NickAlias *)t->data; - rem_ns_timeout(na, TO_RELEASE); - release(na, 1); + rem_ns_timeout(na, TO_RELEASE); + release(na, 1); } /*************************************************************************/ @@ -1489,37 +1489,37 @@ static void timeout_release(Timeout * t) static void add_ns_timeout(NickAlias * na, int type, time_t delay) { - Timeout *to; - struct my_timeout *t; - void (*timeout_routine) (Timeout *); - - if (type == TO_COLLIDE) - timeout_routine = timeout_collide; - else if (type == TO_RELEASE) - timeout_routine = timeout_release; - else { - alog("NickServ: unknown timeout type %d! na=0x%p (%s), delay=%ld", - type, (void *) na, na->nick, (long int) delay); - return; - } - - to = add_timeout(delay, timeout_routine, 0); - to->data = na; - - t = (struct my_timeout *)scalloc(sizeof(struct my_timeout), 1); - t->na = na; - t->to = to; - t->type = type; - - t->prev = NULL; - t->next = my_timeouts; - my_timeouts = t; - /* Andy Church should stop coding while being drunk. - * Here's the two lines he forgot that produced the timed_update evil bug - * and a *big* memory leak. - */ - if (t->next) - t->next->prev = t; + Timeout *to; + struct my_timeout *t; + void (*timeout_routine) (Timeout *); + + if (type == TO_COLLIDE) + timeout_routine = timeout_collide; + else if (type == TO_RELEASE) + timeout_routine = timeout_release; + else { + alog("NickServ: unknown timeout type %d! na=0x%p (%s), delay=%ld", + type, (void *) na, na->nick, (long int) delay); + return; + } + + to = add_timeout(delay, timeout_routine, 0); + to->data = na; + + t = (struct my_timeout *)scalloc(sizeof(struct my_timeout), 1); + t->na = na; + t->to = to; + t->type = type; + + t->prev = NULL; + t->next = my_timeouts; + my_timeouts = t; + /* Andy Church should stop coding while being drunk. + * Here's the two lines he forgot that produced the timed_update evil bug + * and a *big* memory leak. + */ + if (t->next) + t->next->prev = t; } /*************************************************************************/ @@ -1528,25 +1528,25 @@ static void add_ns_timeout(NickAlias * na, int type, time_t delay) void del_ns_timeout(NickAlias * na, int type) { - struct my_timeout *t, *t2; - - t = my_timeouts; - while (t) { - if (t->na == na && t->type == type) { - t2 = t->next; - if (t->next) - t->next->prev = t->prev; - if (t->prev) - t->prev->next = t->next; - else - my_timeouts = t->next; - del_timeout(t->to); - free(t); - t = t2; - } else { - t = t->next; - } - } + struct my_timeout *t, *t2; + + t = my_timeouts; + while (t) { + if (t->na == na && t->type == type) { + t2 = t->next; + if (t->next) + t->next->prev = t->prev; + if (t->prev) + t->prev->next = t->next; + else + my_timeouts = t->next; + del_timeout(t->to); + free(t); + t = t2; + } else { + t = t->next; + } + } } /*************************************************************************/ @@ -1557,27 +1557,27 @@ void del_ns_timeout(NickAlias * na, int type) void clean_ns_timeouts(NickAlias * na) { - struct my_timeout *t, *next; - - for (t = my_timeouts; t; t = next) { - next = t->next; - if (t->na == na) { - if (debug) - alog("debug: %s deleting timeout type %d from %s", - s_NickServ, t->type, t->na->nick); - /* If the timeout has the TO_RELEASE type, we should release the user */ - if (t->type == TO_RELEASE) - release(na, 1); - if (t->next) - t->next->prev = t->prev; - if (t->prev) - t->prev->next = t->next; - else - my_timeouts = t->next; - del_timeout(t->to); - free(t); - } - } + struct my_timeout *t, *next; + + for (t = my_timeouts; t; t = next) { + next = t->next; + if (t->na == na) { + if (debug) + alog("debug: %s deleting timeout type %d from %s", + s_NickServ, t->type, t->na->nick); + /* If the timeout has the TO_RELEASE type, we should release the user */ + if (t->type == TO_RELEASE) + release(na, 1); + if (t->next) + t->next->prev = t->prev; + if (t->prev) + t->prev->next = t->next; + else + my_timeouts = t->next; + del_timeout(t->to); + free(t); + } + } } /*************************************************************************/ @@ -1588,64 +1588,64 @@ void clean_ns_timeouts(NickAlias * na) /* We don't use this function but we keep it for module coders -certus */ int should_mode_change(int16 status, int16 mode) { - switch (mode) { - case CUS_OP: - if (status & CUS_OP) { - return 0; - } - break; - case CUS_VOICE: - if (status & CUS_OP) { - return 0; - } - if (status & CUS_HALFOP) { - return 0; - } - if (status & CUS_VOICE) { - return 0; - } - return 1; - break; - case CUS_HALFOP: - if (status & CUS_OP) { - return 0; - } - if (status & CUS_HALFOP) { - return 0; - } - return 1; - break; - case CUS_OWNER: - if (ircd->owner) { - if (status & CUS_OWNER) { - return 0; - } - } - break; - case CUS_PROTECT: - if (ircd->protect) { - if (status & CUS_PROTECT) { - return 0; - } - } - break; - } - return 1; + switch (mode) { + case CUS_OP: + if (status & CUS_OP) { + return 0; + } + break; + case CUS_VOICE: + if (status & CUS_OP) { + return 0; + } + if (status & CUS_HALFOP) { + return 0; + } + if (status & CUS_VOICE) { + return 0; + } + return 1; + break; + case CUS_HALFOP: + if (status & CUS_OP) { + return 0; + } + if (status & CUS_HALFOP) { + return 0; + } + return 1; + break; + case CUS_OWNER: + if (ircd->owner) { + if (status & CUS_OWNER) { + return 0; + } + } + break; + case CUS_PROTECT: + if (ircd->protect) { + if (status & CUS_PROTECT) { + return 0; + } + } + break; + } + return 1; } /*************************************************************************/ int do_setmodes(User * u) { - struct u_chanlist *uc; - Channel *c; - - /* Walk users current channels */ - for (uc = u->chans; uc; uc = uc->next) { - if ((c = uc->chan)) - chan_set_correct_modes(u, c, 1); - } - return MOD_CONT; + struct u_chanlist *uc; + Channel *c; + + /* Walk users current channels */ + for (uc = u->chans; uc; uc = uc->next) { + if ((c = uc->chan)) + chan_set_correct_modes(u, c, 1); + } + return MOD_CONT; } /*************************************************************************/ @@ -1659,20 +1659,20 @@ int do_setmodes(User * u) **/ void nsStartNickTracking(User * u) { - NickCore *nc; + NickCore *nc; - /* We only track identified users */ - if (nick_identified(u)) { - nc = u->na->nc; + /* We only track identified users */ + if (nick_identified(u)) { + nc = u->na->nc; - /* Release memory if needed */ - if (u->nickTrack) - free(u->nickTrack); + /* Release memory if needed */ + if (u->nickTrack) + free(u->nickTrack); - /* Copy the nick core displayed nick to - the user structure for further checks */ - u->nickTrack = sstrdup(nc->display); - } + /* Copy the nick core displayed nick to + the user structure for further checks */ + u->nickTrack = sstrdup(nc->display); + } } /** @@ -1681,11 +1681,11 @@ void nsStartNickTracking(User * u) **/ void nsStopNickTracking(User * u) { - /* Simple enough. If its there, release it */ - if (u->nickTrack) { - free(u->nickTrack); - u->nickTrack = NULL; - } + /* Simple enough. If its there, release it */ + if (u->nickTrack) { + free(u->nickTrack); + u->nickTrack = NULL; + } } /** @@ -1695,28 +1695,28 @@ void nsStopNickTracking(User * u) **/ int nsCheckNickTracking(User * u) { - NickCore *nc; - NickAlias *na; - char *nick; - - /* No nick alias or nick return false by default */ - if ((!(na = u->na)) || (!(nick = na->nick))) { - return 0; - } - - /* nick is forbidden best return 0 */ - if (na->status & NS_VERBOTEN) { - return 0; - } - - /* Get the core for the requested nick */ - nc = na->nc; - - /* If the core and the tracking displayed nick are there, - * and they match, return true - */ - if (nc && u->nickTrack && (strcmp(nc->display, u->nickTrack) == 0)) - return 1; - else - return 0; + NickCore *nc; + NickAlias *na; + char *nick; + + /* No nick alias or nick return false by default */ + if ((!(na = u->na)) || (!(nick = na->nick))) { + return 0; + } + + /* nick is forbidden best return 0 */ + if (na->status & NS_VERBOTEN) { + return 0; + } + + /* Get the core for the requested nick */ + nc = na->nc; + + /* If the core and the tracking displayed nick are there, + * and they match, return true + */ + if (nc && u->nickTrack && (strcmp(nc->display, u->nickTrack) == 0)) + return 1; + else + return 0; } diff --git a/src/operserv.c b/src/operserv.c index a32ca46e3..20e63a41b 100644 --- a/src/operserv.c +++ b/src/operserv.c @@ -27,9 +27,9 @@ SList akills, sglines, sqlines, szlines; /*************************************************************************/ static int compare_adminlist_entries(SList * slist, void *item1, - void *item2); + void *item2); static int compare_operlist_entries(SList * slist, void *item1, - void *item2); + void *item2); static void free_adminlist_entry(SList * slist, void *item); static void free_operlist_entry(SList * slist, void *item); @@ -46,13 +46,13 @@ time_t DefContimer; int DefConModesSet = 0; char *defconReverseModes(const char *modes); -uint32 DefConModesOn; /* Modes to be enabled during DefCon */ -uint32 DefConModesOff; /* Modes to be disabled during DefCon */ -ChannelInfo DefConModesCI; /* ChannelInfo containg params for locked modes - * during DefCon; I would've done this nicer if i - * could, but all damn mode functions require a - * ChannelInfo struct! --gdex - */ +uint32 DefConModesOn; /* Modes to be enabled during DefCon */ +uint32 DefConModesOff; /* Modes to be disabled during DefCon */ +ChannelInfo DefConModesCI; /* ChannelInfo containg params for locked modes + * during DefCon; I would've done this nicer if i + * could, but all damn mode functions require a + * ChannelInfo struct! --gdex + */ void moduleAddOperServCmds(void); @@ -61,14 +61,14 @@ void moduleAddOperServCmds(void); /* Options for the lists */ SListOpts akopts = { 0, NULL, &is_akill_entry_equal, &free_akill_entry }; SListOpts saopts = { SLISTF_SORT, &compare_adminlist_entries, NULL, - &free_adminlist_entry + &free_adminlist_entry }; SListOpts sgopts = { 0, NULL, &is_sgline_entry_equal, &free_sgline_entry }; SListOpts soopts = - { SLISTF_SORT, &compare_operlist_entries, NULL, &free_operlist_entry }; + { SLISTF_SORT, &compare_operlist_entries, NULL, &free_operlist_entry }; SListOpts sqopts = - { SLISTF_SORT, NULL, &is_sqline_entry_equal, &free_sqline_entry }; + { SLISTF_SORT, NULL, &is_sqline_entry_equal, &free_sqline_entry }; SListOpts szopts = { 0, NULL, &is_szline_entry_equal, &free_szline_entry }; /*************************************************************************/ @@ -85,29 +85,29 @@ void moduleAddOperServCmds(void) { void os_init(void) { - moduleAddOperServCmds(); - - /* Initialization of the lists */ - slist_init(&servadmins); - servadmins.opts = &saopts; - slist_init(&servopers); - servopers.opts = &soopts; - - slist_init(&akills); - akills.opts = &akopts; - - if (ircd->sgline) { - slist_init(&sglines); - sglines.opts = &sgopts; - } - if (ircd->sqline) { - slist_init(&sqlines); - sqlines.opts = &sqopts; - } - if (ircd->szline) { - slist_init(&szlines); - szlines.opts = &szopts; - } + moduleAddOperServCmds(); + + /* Initialization of the lists */ + slist_init(&servadmins); + servadmins.opts = &saopts; + slist_init(&servopers); + servopers.opts = &soopts; + + slist_init(&akills); + akills.opts = &akopts; + + if (ircd->sgline) { + slist_init(&sglines); + sglines.opts = &sgopts; + } + if (ircd->sqline) { + slist_init(&sqlines); + sqlines.opts = &sqopts; + } + if (ircd->szline) { + slist_init(&szlines); + szlines.opts = &szopts; + } } /*************************************************************************/ @@ -116,22 +116,22 @@ void os_init(void) void operserv(User * u, char *buf) { - const char *cmd; - const char *s; - - alog("%s: %s: %s", s_OperServ, u->nick, buf); - - cmd = strtok(buf, " "); - if (!cmd) { - return; - } else if (stricmp(cmd, "\1PING") == 0) { - if (!(s = strtok(NULL, ""))) { - s = ""; - } - ircdproto->SendCTCP(findbot(s_OperServ), u->nick, "PING %s", s); - } else { - mod_run_cmd(s_OperServ, u, OPERSERV, cmd); - } + const char *cmd; + const char *s; + + alog("%s: %s: %s", s_OperServ, u->nick, buf); + + cmd = strtok(buf, " "); + if (!cmd) { + return; + } else if (stricmp(cmd, "\1PING") == 0) { + if (!(s = strtok(NULL, ""))) { + s = ""; + } + ircdproto->SendCTCP(findbot(s_OperServ), u->nick, "PING %s", s); + } else { + mod_run_cmd(s_OperServ, u, OPERSERV, cmd); + } } /*************************************************************************/ @@ -141,111 +141,111 @@ void operserv(User * u, char *buf) /* Load old AKILL data. */ #define SAFE(x) do { \ - if ((x) < 0) { \ + if ((x) < 0) { \ if (!forceload) \ - fatal("Read error on %s", AutokillDBName); \ + fatal("Read error on %s", AutokillDBName); \ break; \ - } \ + } \ } while (0) static void load_old_akill(void) { - dbFILE *f; - int i, j; - uint16 tmp16; - uint32 tmp32; - char buf[NICKMAX], mask2[BUFSIZE], *mask, *s; - Akill *ak, *entry; - - if (! - (f = - open_db("AKILL", AutokillDBName ? AutokillDBName : "akill.db", - "r", 9))) - return; - - get_file_version(f); - - read_int16(&tmp16, f); - slist_setcapacity(&akills, tmp16); - - for (j = 0; j < akills.capacity; j++) { - ak = (Akill *)scalloc(sizeof(Akill), 1); - - SAFE(read_string(&mask, f)); - s = strchr(mask, '@'); - *s = 0; - s++; - ak->user = sstrdup(mask); - ak->host = sstrdup(s); - SAFE(read_string(&ak->reason, f)); - SAFE(read_buffer(buf, f)); - if (!*buf) - ak->by = sstrdup("<unknown>"); - else - ak->by = sstrdup(buf); - SAFE(read_int32(&tmp32, f)); - ak->seton = tmp32 ? tmp32 : time(NULL); - SAFE(read_int32(&tmp32, f)); - ak->expires = tmp32; - - /* Sanity checks *sigh* */ - - /* No nicknames allowed! */ - if (strchr(ak->user, '!')) { - ircdproto->SendAkillDel(ak->user, ak->host); - free(ak); - continue; - } - - snprintf(mask2, sizeof(mask2), "%s@%s", ak->user, ak->host); - - /* Is the mask already in the AKILL list? */ - if (slist_indexof(&akills, mask2) != -1) { - free(ak); - continue; - } - - /* Checks whether there is an AKILL that already covers - * the one we want to add, and whether there are AKILLs - * that would be covered by this one. Expiry time - * does *also* matter. - */ - - if (akills.count > 0) { - - for (i = akills.count - 1; i >= 0; i--) { - - char amask[BUFSIZE]; - - entry = (Akill *)akills.list[i]; - - if (!entry) - continue; - - snprintf(amask, sizeof(amask), "%s@%s", entry->user, - entry->host); - - if (match_wild_nocase(amask, mask2) - && (entry->expires >= ak->expires - || entry->expires == 0)) { - ircdproto->SendAkillDel(ak->user, ak->host); - free(ak); - ak = NULL; - break; - } - - if (match_wild_nocase(mask2, amask) - && (entry->expires <= ak->expires || ak->expires == 0)) - slist_delete(&akills, i); - } - - } - - if (ak) - slist_add(&akills, ak); - } - - close_db(f); + dbFILE *f; + int i, j; + uint16 tmp16; + uint32 tmp32; + char buf[NICKMAX], mask2[BUFSIZE], *mask, *s; + Akill *ak, *entry; + + if (! + (f = + open_db("AKILL", AutokillDBName ? AutokillDBName : "akill.db", + "r", 9))) + return; + + get_file_version(f); + + read_int16(&tmp16, f); + slist_setcapacity(&akills, tmp16); + + for (j = 0; j < akills.capacity; j++) { + ak = (Akill *)scalloc(sizeof(Akill), 1); + + SAFE(read_string(&mask, f)); + s = strchr(mask, '@'); + *s = 0; + s++; + ak->user = sstrdup(mask); + ak->host = sstrdup(s); + SAFE(read_string(&ak->reason, f)); + SAFE(read_buffer(buf, f)); + if (!*buf) + ak->by = sstrdup("<unknown>"); + else + ak->by = sstrdup(buf); + SAFE(read_int32(&tmp32, f)); + ak->seton = tmp32 ? tmp32 : time(NULL); + SAFE(read_int32(&tmp32, f)); + ak->expires = tmp32; + + /* Sanity checks *sigh* */ + + /* No nicknames allowed! */ + if (strchr(ak->user, '!')) { + ircdproto->SendAkillDel(ak->user, ak->host); + free(ak); + continue; + } + + snprintf(mask2, sizeof(mask2), "%s@%s", ak->user, ak->host); + + /* Is the mask already in the AKILL list? */ + if (slist_indexof(&akills, mask2) != -1) { + free(ak); + continue; + } + + /* Checks whether there is an AKILL that already covers + * the one we want to add, and whether there are AKILLs + * that would be covered by this one. Expiry time + * does *also* matter. + */ + + if (akills.count > 0) { + + for (i = akills.count - 1; i >= 0; i--) { + + char amask[BUFSIZE]; + + entry = (Akill *)akills.list[i]; + + if (!entry) + continue; + + snprintf(amask, sizeof(amask), "%s@%s", entry->user, + entry->host); + + if (match_wild_nocase(amask, mask2) + && (entry->expires >= ak->expires + || entry->expires == 0)) { + ircdproto->SendAkillDel(ak->user, ak->host); + free(ak); + ak = NULL; + break; + } + + if (match_wild_nocase(mask2, amask) + && (entry->expires <= ak->expires || ak->expires == 0)) + slist_delete(&akills, i); + } + + } + + if (ak) + slist_add(&akills, ak); + } + + close_db(f); } #undef SAFE @@ -253,148 +253,148 @@ static void load_old_akill(void) /* Load OperServ data. */ #define SAFE(x) do { \ - if ((x) < 0) { \ + if ((x) < 0) { \ if (!forceload) \ - fatal("Read error on %s", OperDBName); \ + fatal("Read error on %s", OperDBName); \ failed = 1; \ break; \ - } \ + } \ } while (0) void load_os_dbase(void) { - dbFILE *f; - int16 i, ver; - uint16 tmp16, n; - uint32 tmp32; - char *s; - int failed = 0; - - if (!(f = open_db(s_OperServ, OperDBName, "r", OPER_VERSION))) - return; - - ver = get_file_version(f); - - if (ver <= 9) { - NickAlias *na; - - SAFE(read_int16(&n, f)); - for (i = 0; i < n && !failed; i++) { - SAFE(read_string(&s, f)); - if (s) { - na = findnick(s); - if (na) { - na->nc->flags |= NI_SERVICES_ADMIN; - if (slist_indexof(&servadmins, na) == -1) - slist_add(&servadmins, na); - } - free(s); - } - } - if (!failed) - SAFE(read_int16(&n, f)); - for (i = 0; i < n && !failed; i++) { - SAFE(read_string(&s, f)); - if (s) { - na = findnick(s); - if (na) { - na->nc->flags |= NI_SERVICES_OPER; - if (slist_indexof(&servopers, na) == -1) - slist_add(&servopers, na); - } - free(s); - } - } - } - - if (ver >= 7) { - SAFE(read_int32(&maxusercnt, f)); - SAFE(read_int32(&tmp32, f)); - maxusertime = tmp32; - } - - if (ver <= 10) - load_old_akill(); - else { - Akill *ak; - - read_int16(&tmp16, f); - slist_setcapacity(&akills, tmp16); - - for (i = 0; i < akills.capacity; i++) { - ak = (Akill *)scalloc(sizeof(Akill), 1); - - SAFE(read_string(&ak->user, f)); - SAFE(read_string(&ak->host, f)); - SAFE(read_string(&ak->by, f)); - SAFE(read_string(&ak->reason, f)); - SAFE(read_int32(&tmp32, f)); - ak->seton = tmp32; - SAFE(read_int32(&tmp32, f)); - ak->expires = tmp32; - - slist_add(&akills, ak); - } - } - - if (ver >= 11) { - SXLine *sx; - - read_int16(&tmp16, f); - slist_setcapacity(&sglines, tmp16); - - for (i = 0; i < sglines.capacity; i++) { - sx = (SXLine *)scalloc(sizeof(SXLine), 1); - - SAFE(read_string(&sx->mask, f)); - SAFE(read_string(&sx->by, f)); - SAFE(read_string(&sx->reason, f)); - SAFE(read_int32(&tmp32, f)); - sx->seton = tmp32; - SAFE(read_int32(&tmp32, f)); - sx->expires = tmp32; - - slist_add(&sglines, sx); - } - - if (ver >= 13) { - read_int16(&tmp16, f); - slist_setcapacity(&sqlines, tmp16); - - for (i = 0; i < sqlines.capacity; i++) { - sx = (SXLine *)scalloc(sizeof(SXLine), 1); - - SAFE(read_string(&sx->mask, f)); - SAFE(read_string(&sx->by, f)); - SAFE(read_string(&sx->reason, f)); - SAFE(read_int32(&tmp32, f)); - sx->seton = tmp32; - SAFE(read_int32(&tmp32, f)); - sx->expires = tmp32; - - slist_add(&sqlines, sx); - } - } - - read_int16(&tmp16, f); - slist_setcapacity(&szlines, tmp16); - - for (i = 0; i < szlines.capacity; i++) { - sx = (SXLine *)scalloc(sizeof(SXLine), 1); - - SAFE(read_string(&sx->mask, f)); - SAFE(read_string(&sx->by, f)); - SAFE(read_string(&sx->reason, f)); - SAFE(read_int32(&tmp32, f)); - sx->seton = tmp32; - SAFE(read_int32(&tmp32, f)); - sx->expires = tmp32; - - slist_add(&szlines, sx); - } - } - - close_db(f); + dbFILE *f; + int16 i, ver; + uint16 tmp16, n; + uint32 tmp32; + char *s; + int failed = 0; + + if (!(f = open_db(s_OperServ, OperDBName, "r", OPER_VERSION))) + return; + + ver = get_file_version(f); + + if (ver <= 9) { + NickAlias *na; + + SAFE(read_int16(&n, f)); + for (i = 0; i < n && !failed; i++) { + SAFE(read_string(&s, f)); + if (s) { + na = findnick(s); + if (na) { + na->nc->flags |= NI_SERVICES_ADMIN; + if (slist_indexof(&servadmins, na) == -1) + slist_add(&servadmins, na); + } + free(s); + } + } + if (!failed) + SAFE(read_int16(&n, f)); + for (i = 0; i < n && !failed; i++) { + SAFE(read_string(&s, f)); + if (s) { + na = findnick(s); + if (na) { + na->nc->flags |= NI_SERVICES_OPER; + if (slist_indexof(&servopers, na) == -1) + slist_add(&servopers, na); + } + free(s); + } + } + } + + if (ver >= 7) { + SAFE(read_int32(&maxusercnt, f)); + SAFE(read_int32(&tmp32, f)); + maxusertime = tmp32; + } + + if (ver <= 10) + load_old_akill(); + else { + Akill *ak; + + read_int16(&tmp16, f); + slist_setcapacity(&akills, tmp16); + + for (i = 0; i < akills.capacity; i++) { + ak = (Akill *)scalloc(sizeof(Akill), 1); + + SAFE(read_string(&ak->user, f)); + SAFE(read_string(&ak->host, f)); + SAFE(read_string(&ak->by, f)); + SAFE(read_string(&ak->reason, f)); + SAFE(read_int32(&tmp32, f)); + ak->seton = tmp32; + SAFE(read_int32(&tmp32, f)); + ak->expires = tmp32; + + slist_add(&akills, ak); + } + } + + if (ver >= 11) { + SXLine *sx; + + read_int16(&tmp16, f); + slist_setcapacity(&sglines, tmp16); + + for (i = 0; i < sglines.capacity; i++) { + sx = (SXLine *)scalloc(sizeof(SXLine), 1); + + SAFE(read_string(&sx->mask, f)); + SAFE(read_string(&sx->by, f)); + SAFE(read_string(&sx->reason, f)); + SAFE(read_int32(&tmp32, f)); + sx->seton = tmp32; + SAFE(read_int32(&tmp32, f)); + sx->expires = tmp32; + + slist_add(&sglines, sx); + } + + if (ver >= 13) { + read_int16(&tmp16, f); + slist_setcapacity(&sqlines, tmp16); + + for (i = 0; i < sqlines.capacity; i++) { + sx = (SXLine *)scalloc(sizeof(SXLine), 1); + + SAFE(read_string(&sx->mask, f)); + SAFE(read_string(&sx->by, f)); + SAFE(read_string(&sx->reason, f)); + SAFE(read_int32(&tmp32, f)); + sx->seton = tmp32; + SAFE(read_int32(&tmp32, f)); + sx->expires = tmp32; + + slist_add(&sqlines, sx); + } + } + + read_int16(&tmp16, f); + slist_setcapacity(&szlines, tmp16); + + for (i = 0; i < szlines.capacity; i++) { + sx = (SXLine *)scalloc(sizeof(SXLine), 1); + + SAFE(read_string(&sx->mask, f)); + SAFE(read_string(&sx->by, f)); + SAFE(read_string(&sx->reason, f)); + SAFE(read_int32(&tmp32, f)); + sx->seton = tmp32; + SAFE(read_int32(&tmp32, f)); + sx->expires = tmp32; + + slist_add(&szlines, sx); + } + } + + close_db(f); } @@ -405,77 +405,77 @@ void load_os_dbase(void) /* Save OperServ data. */ #define SAFE(x) do { \ - if ((x) < 0) { \ + if ((x) < 0) { \ restore_db(f); \ log_perror("Write error on %s", OperDBName); \ if (time(NULL) - lastwarn > WarningTimeout) { \ - ircdproto->SendGlobops(NULL, "Write error on %s: %s", OperDBName, \ + ircdproto->SendGlobops(NULL, "Write error on %s: %s", OperDBName, \ strerror(errno)); \ - lastwarn = time(NULL); \ + lastwarn = time(NULL); \ } \ return; \ - } \ + } \ } while (0) void save_os_dbase(void) { - int i; - dbFILE *f; - static time_t lastwarn = 0; - Akill *ak; - SXLine *sx; - - if (!(f = open_db(s_OperServ, OperDBName, "w", OPER_VERSION))) - return; - SAFE(write_int32(maxusercnt, f)); - SAFE(write_int32(maxusertime, f)); - - SAFE(write_int16(akills.count, f)); - for (i = 0; i < akills.count; i++) { - ak = (Akill *)akills.list[i]; - - SAFE(write_string(ak->user, f)); - SAFE(write_string(ak->host, f)); - SAFE(write_string(ak->by, f)); - SAFE(write_string(ak->reason, f)); - SAFE(write_int32(ak->seton, f)); - SAFE(write_int32(ak->expires, f)); - } - - SAFE(write_int16(sglines.count, f)); - for (i = 0; i < sglines.count; i++) { - sx = (SXLine *)sglines.list[i]; - - SAFE(write_string(sx->mask, f)); - SAFE(write_string(sx->by, f)); - SAFE(write_string(sx->reason, f)); - SAFE(write_int32(sx->seton, f)); - SAFE(write_int32(sx->expires, f)); - } - - SAFE(write_int16(sqlines.count, f)); - for (i = 0; i < sqlines.count; i++) { - sx = (SXLine *)sqlines.list[i]; - - SAFE(write_string(sx->mask, f)); - SAFE(write_string(sx->by, f)); - SAFE(write_string(sx->reason, f)); - SAFE(write_int32(sx->seton, f)); - SAFE(write_int32(sx->expires, f)); - } - - SAFE(write_int16(szlines.count, f)); - for (i = 0; i < szlines.count; i++) { - sx = (SXLine *)szlines.list[i]; - - SAFE(write_string(sx->mask, f)); - SAFE(write_string(sx->by, f)); - SAFE(write_string(sx->reason, f)); - SAFE(write_int32(sx->seton, f)); - SAFE(write_int32(sx->expires, f)); - } - - close_db(f); + int i; + dbFILE *f; + static time_t lastwarn = 0; + Akill *ak; + SXLine *sx; + + if (!(f = open_db(s_OperServ, OperDBName, "w", OPER_VERSION))) + return; + SAFE(write_int32(maxusercnt, f)); + SAFE(write_int32(maxusertime, f)); + + SAFE(write_int16(akills.count, f)); + for (i = 0; i < akills.count; i++) { + ak = (Akill *)akills.list[i]; + + SAFE(write_string(ak->user, f)); + SAFE(write_string(ak->host, f)); + SAFE(write_string(ak->by, f)); + SAFE(write_string(ak->reason, f)); + SAFE(write_int32(ak->seton, f)); + SAFE(write_int32(ak->expires, f)); + } + + SAFE(write_int16(sglines.count, f)); + for (i = 0; i < sglines.count; i++) { + sx = (SXLine *)sglines.list[i]; + + SAFE(write_string(sx->mask, f)); + SAFE(write_string(sx->by, f)); + SAFE(write_string(sx->reason, f)); + SAFE(write_int32(sx->seton, f)); + SAFE(write_int32(sx->expires, f)); + } + + SAFE(write_int16(sqlines.count, f)); + for (i = 0; i < sqlines.count; i++) { + sx = (SXLine *)sqlines.list[i]; + + SAFE(write_string(sx->mask, f)); + SAFE(write_string(sx->by, f)); + SAFE(write_string(sx->reason, f)); + SAFE(write_int32(sx->seton, f)); + SAFE(write_int32(sx->expires, f)); + } + + SAFE(write_int16(szlines.count, f)); + for (i = 0; i < szlines.count; i++) { + sx = (SXLine *)szlines.list[i]; + + SAFE(write_string(sx->mask, f)); + SAFE(write_string(sx->by, f)); + SAFE(write_string(sx->reason, f)); + SAFE(write_int32(sx->seton, f)); + SAFE(write_int32(sx->expires, f)); + } + + close_db(f); } @@ -487,8 +487,8 @@ void save_os_dbase(void) void os_remove_nick(NickCore * nc) { - slist_remove(&servadmins, nc); - slist_remove(&servopers, nc); + slist_remove(&servadmins, nc); + slist_remove(&servopers, nc); } /*************************************************************************/ @@ -498,12 +498,12 @@ void os_remove_nick(NickCore * nc) int is_services_root(User * u) { - if ((NSStrictPrivileges && !is_oper(u)) - || (!nick_identified(u))) - return 0; - if ((u->na->nc->flags & NI_SERVICES_ROOT)) - return 1; - return 0; + if ((NSStrictPrivileges && !is_oper(u)) + || (!nick_identified(u))) + return 0; + if ((u->na->nc->flags & NI_SERVICES_ROOT)) + return 1; + return 0; } /*************************************************************************/ @@ -512,12 +512,12 @@ int is_services_root(User * u) int is_services_admin(User * u) { - if ((NSStrictPrivileges && !is_oper(u)) - || (!nick_identified(u))) - return 0; - if ((u->na->nc->flags & (NI_SERVICES_ADMIN | NI_SERVICES_ROOT))) - return 1; - return 0; + if ((NSStrictPrivileges && !is_oper(u)) + || (!nick_identified(u))) + return 0; + if ((u->na->nc->flags & (NI_SERVICES_ADMIN | NI_SERVICES_ROOT))) + return 1; + return 0; } /*************************************************************************/ @@ -526,14 +526,14 @@ int is_services_admin(User * u) int is_services_oper(User * u) { - if ((NSStrictPrivileges && !is_oper(u)) - || (!nick_identified(u))) - return 0; - if ((u->na->nc-> - flags & (NI_SERVICES_OPER | NI_SERVICES_ADMIN | - NI_SERVICES_ROOT))) - return 1; - return 0; + if ((NSStrictPrivileges && !is_oper(u)) + || (!nick_identified(u))) + return 0; + if ((u->na->nc-> + flags & (NI_SERVICES_OPER | NI_SERVICES_ADMIN | + NI_SERVICES_ROOT))) + return 1; + return 0; } /*************************************************************************/ @@ -542,11 +542,11 @@ int is_services_oper(User * u) int nick_is_services_root(NickCore * nc) { - if (nc) { - if (nc->flags & (NI_SERVICES_ROOT)) - return 1; - } - return 0; + if (nc) { + if (nc->flags & (NI_SERVICES_ROOT)) + return 1; + } + return 0; } /*************************************************************************/ @@ -555,11 +555,11 @@ int nick_is_services_root(NickCore * nc) int nick_is_services_admin(NickCore * nc) { - if (nc) { - if (nc->flags & (NI_SERVICES_ADMIN | NI_SERVICES_ROOT)) - return 1; - } - return 0; + if (nc) { + if (nc->flags & (NI_SERVICES_ADMIN | NI_SERVICES_ROOT)) + return 1; + } + return 0; } /*************************************************************************/ @@ -568,13 +568,13 @@ int nick_is_services_admin(NickCore * nc) int nick_is_services_oper(NickCore * nc) { - if (nc) { - if (nc-> - flags & (NI_SERVICES_OPER | NI_SERVICES_ADMIN | - NI_SERVICES_ROOT)) - return 1; - } - return 0; + if (nc) { + if (nc-> + flags & (NI_SERVICES_OPER | NI_SERVICES_ADMIN | + NI_SERVICES_ROOT)) + return 1; + } + return 0; } @@ -587,44 +587,44 @@ int nick_is_services_oper(NickCore * nc) Server *server_global(Server * s, char *msg) { - Server *sl; - - while (s) { - /* Do not send the notice to ourselves our juped servers */ - if (!(s->flags & (SERVER_ISME | SERVER_JUPED))) - notice_server(s_GlobalNoticer, s, "%s", msg); - - if (s->links) { - sl = server_global(s->links, msg); - if (sl) - s = sl; - else - s = s->next; - } else { - s = s->next; - } - } - return s; + Server *sl; + + while (s) { + /* Do not send the notice to ourselves our juped servers */ + if (!(s->flags & (SERVER_ISME | SERVER_JUPED))) + notice_server(s_GlobalNoticer, s, "%s", msg); + + if (s->links) { + sl = server_global(s->links, msg); + if (sl) + s = sl; + else + s = s->next; + } else { + s = s->next; + } + } + return s; } void oper_global(char *nick, const char *fmt, ...) { - va_list args; - char msg[2048]; /* largest valid message is 512, this should cover any global */ - char dmsg[2048]; /* largest valid message is 512, this should cover any global */ - - va_start(args, fmt); - vsnprintf(msg, sizeof(msg), fmt, args); - va_end(args); - - /* I don't like the way this is coded... */ - if ((nick) && (!AnonymousGlobal)) { - snprintf(dmsg, sizeof(dmsg), "[%s] %s", nick, msg); - server_global(servlist, dmsg); - } else { - server_global(servlist, msg); - } + va_list args; + char msg[2048]; /* largest valid message is 512, this should cover any global */ + char dmsg[2048]; /* largest valid message is 512, this should cover any global */ + + va_start(args, fmt); + vsnprintf(msg, sizeof(msg), fmt, args); + va_end(args); + + /* I don't like the way this is coded... */ + if ((nick) && (!AnonymousGlobal)) { + snprintf(dmsg, sizeof(dmsg), "[%s] %s", nick, msg); + server_global(servlist, dmsg); + } else { + server_global(servlist, msg); + } } @@ -640,209 +640,209 @@ void oper_global(char *nick, const char *fmt, ...) */ int add_akill(User * u, char *mask, const char *by, const time_t expires, - const char *reason) + const char *reason) { - int deleted = 0, i; - char *user, *mask2, *host; - Akill *entry; - - if (!mask) { - return -1; - } - - /* Checks whether there is an AKILL that already covers - * the one we want to add, and whether there are AKILLs - * that would be covered by this one. The masks AND the - * expiry times are used to determine this, because some - * AKILLs may become useful when another one expires. - * If so, warn the user in the first case and cleanup - * the useless AKILLs in the second. - */ - - if (akills.count > 0) { - - for (i = akills.count - 1; i >= 0; i--) { - char amask[BUFSIZE]; - - entry = (Akill *)akills.list[i]; - - if (!entry) - continue; - - snprintf(amask, sizeof(amask), "%s@%s", entry->user, - entry->host); - - if (!stricmp(amask, mask)) { - /* We change the AKILL expiry time if its current one is less than the new. - * This is preferable to be sure we don't change an important AKILL - * accidentely. - */ - if (entry->expires >= expires || entry->expires == 0) { - if (u) - notice_lang(s_OperServ, u, OPER_AKILL_EXISTS, - mask); - return -1; - } else { - entry->expires = expires; - if (u) - notice_lang(s_OperServ, u, OPER_AKILL_CHANGED, - amask); - return -2; - } - } - - if (match_wild_nocase(amask, mask) - && (entry->expires >= expires || entry->expires == 0)) { - if (u) - notice_lang(s_OperServ, u, OPER_AKILL_ALREADY_COVERED, - mask, amask); - return -1; - } - - if (match_wild_nocase(mask, amask) - && (entry->expires <= expires || expires == 0)) { - slist_delete(&akills, i); - deleted++; - } - } - - } - - /* We can now check whether the list is full or not. */ - if (slist_full(&akills)) { - if (u) - notice_lang(s_OperServ, u, OPER_AKILL_REACHED_LIMIT, - akills.limit); - return -1; - } - - /* We can now (really) add the AKILL. */ - mask2 = sstrdup(mask); - host = strchr(mask2, '@'); - - if (!host) { - free(mask2); - return -1; - } - - user = mask2; - *host = 0; - host++; - - entry = (Akill *)scalloc(sizeof(Akill), 1); - - if (!entry) { - free(mask2); - return -1; - } - - entry->user = sstrdup(user); - entry->host = sstrdup(host); - entry->by = sstrdup(by); - entry->reason = sstrdup(reason); - entry->seton = time(NULL); - entry->expires = expires; - - slist_add(&akills, entry); - - if (AkillOnAdd) - ircdproto->SendAkill(entry->user, entry->host, entry->by, entry->seton, - entry->expires, entry->reason); - - free(mask2); - - return deleted; + int deleted = 0, i; + char *user, *mask2, *host; + Akill *entry; + + if (!mask) { + return -1; + } + + /* Checks whether there is an AKILL that already covers + * the one we want to add, and whether there are AKILLs + * that would be covered by this one. The masks AND the + * expiry times are used to determine this, because some + * AKILLs may become useful when another one expires. + * If so, warn the user in the first case and cleanup + * the useless AKILLs in the second. + */ + + if (akills.count > 0) { + + for (i = akills.count - 1; i >= 0; i--) { + char amask[BUFSIZE]; + + entry = (Akill *)akills.list[i]; + + if (!entry) + continue; + + snprintf(amask, sizeof(amask), "%s@%s", entry->user, + entry->host); + + if (!stricmp(amask, mask)) { + /* We change the AKILL expiry time if its current one is less than the new. + * This is preferable to be sure we don't change an important AKILL + * accidentely. + */ + if (entry->expires >= expires || entry->expires == 0) { + if (u) + notice_lang(s_OperServ, u, OPER_AKILL_EXISTS, + mask); + return -1; + } else { + entry->expires = expires; + if (u) + notice_lang(s_OperServ, u, OPER_AKILL_CHANGED, + amask); + return -2; + } + } + + if (match_wild_nocase(amask, mask) + && (entry->expires >= expires || entry->expires == 0)) { + if (u) + notice_lang(s_OperServ, u, OPER_AKILL_ALREADY_COVERED, + mask, amask); + return -1; + } + + if (match_wild_nocase(mask, amask) + && (entry->expires <= expires || expires == 0)) { + slist_delete(&akills, i); + deleted++; + } + } + + } + + /* We can now check whether the list is full or not. */ + if (slist_full(&akills)) { + if (u) + notice_lang(s_OperServ, u, OPER_AKILL_REACHED_LIMIT, + akills.limit); + return -1; + } + + /* We can now (really) add the AKILL. */ + mask2 = sstrdup(mask); + host = strchr(mask2, '@'); + + if (!host) { + free(mask2); + return -1; + } + + user = mask2; + *host = 0; + host++; + + entry = (Akill *)scalloc(sizeof(Akill), 1); + + if (!entry) { + free(mask2); + return -1; + } + + entry->user = sstrdup(user); + entry->host = sstrdup(host); + entry->by = sstrdup(by); + entry->reason = sstrdup(reason); + entry->seton = time(NULL); + entry->expires = expires; + + slist_add(&akills, entry); + + if (AkillOnAdd) + ircdproto->SendAkill(entry->user, entry->host, entry->by, entry->seton, + entry->expires, entry->reason); + + free(mask2); + + return deleted; } /* Does the user match any AKILLs? */ int check_akill(const char *nick, const char *username, const char *host, - const char *vhost, const char *ip) + const char *vhost, const char *ip) { - int i; - Akill *ak; - - /** - * If DefCon is set to NO new users - kill the user ;). - **/ - if (checkDefCon(DEFCON_NO_NEW_CLIENTS)) { - kill_user(s_OperServ, nick, DefConAkillReason); - return 1; - } - - if (akills.count == 0) - return 0; - - for (i = 0; i < akills.count; i++) { - ak = (Akill *)akills.list[i]; - if (!ak) - continue; - if (match_wild_nocase(ak->user, username) - && match_wild_nocase(ak->host, host)) { - ircdproto->SendAkill(ak->user, ak->host, ak->by, ak->seton, - ak->expires, ak->reason); - return 1; - } - if (ircd->vhost) { - if (vhost) { - if (match_wild_nocase(ak->user, username) - && match_wild_nocase(ak->host, vhost)) { - ircdproto->SendAkill(ak->user, ak->host, ak->by, ak->seton, - ak->expires, ak->reason); - return 1; - } - } - } - if (ircd->nickip) { - if (ip) { - if (match_wild_nocase(ak->user, username) - && match_wild_nocase(ak->host, ip)) { - ircdproto->SendAkill(ak->user, ak->host, ak->by, ak->seton, - ak->expires, ak->reason); - return 1; - } - } - } - - } - - return 0; + int i; + Akill *ak; + + /** + * If DefCon is set to NO new users - kill the user ;). + **/ + if (checkDefCon(DEFCON_NO_NEW_CLIENTS)) { + kill_user(s_OperServ, nick, DefConAkillReason); + return 1; + } + + if (akills.count == 0) + return 0; + + for (i = 0; i < akills.count; i++) { + ak = (Akill *)akills.list[i]; + if (!ak) + continue; + if (match_wild_nocase(ak->user, username) + && match_wild_nocase(ak->host, host)) { + ircdproto->SendAkill(ak->user, ak->host, ak->by, ak->seton, + ak->expires, ak->reason); + return 1; + } + if (ircd->vhost) { + if (vhost) { + if (match_wild_nocase(ak->user, username) + && match_wild_nocase(ak->host, vhost)) { + ircdproto->SendAkill(ak->user, ak->host, ak->by, ak->seton, + ak->expires, ak->reason); + return 1; + } + } + } + if (ircd->nickip) { + if (ip) { + if (match_wild_nocase(ak->user, username) + && match_wild_nocase(ak->host, ip)) { + ircdproto->SendAkill(ak->user, ak->host, ak->by, ak->seton, + ak->expires, ak->reason); + return 1; + } + } + } + + } + + return 0; } /* Delete any expired autokills. */ void expire_akills(void) { - int i; - time_t now = time(NULL); - Akill *ak; + int i; + time_t now = time(NULL); + Akill *ak; - for (i = akills.count - 1; i >= 0; i--) { - ak = (Akill *)akills.list[i]; + for (i = akills.count - 1; i >= 0; i--) { + ak = (Akill *)akills.list[i]; - if (!ak->expires || ak->expires > now) - continue; + if (!ak->expires || ak->expires > now) + continue; - if (WallAkillExpire) - ircdproto->SendGlobops(s_OperServ, "AKILL on %s@%s has expired", - ak->user, ak->host); - slist_delete(&akills, i); - } + if (WallAkillExpire) + ircdproto->SendGlobops(s_OperServ, "AKILL on %s@%s has expired", + ak->user, ak->host); + slist_delete(&akills, i); + } } static void free_akill_entry(SList * slist, void *item) { - Akill *ak = (Akill *)item; + Akill *ak = (Akill *)item; - /* Remove the AKILLs from all the servers */ - ircdproto->SendAkillDel(ak->user, ak->host); + /* Remove the AKILLs from all the servers */ + ircdproto->SendAkillDel(ak->user, ak->host); - /* Free the structure */ - free(ak->user); - free(ak->host); - free(ak->by); - free(ak->reason); - free(ak); + /* Free the structure */ + free(ak->user); + free(ak->host); + free(ak->by); + free(ak->reason); + free(ak); } /* item1 is not an Akill pointer, but a char @@ -850,18 +850,18 @@ static void free_akill_entry(SList * slist, void *item) static int is_akill_entry_equal(SList * slist, void *item1, void *item2) { - char *ak1 = (char *)item1, buf[BUFSIZE]; - Akill *ak2 = (Akill *)item2; + char *ak1 = (char *)item1, buf[BUFSIZE]; + Akill *ak2 = (Akill *)item2; - if (!ak1 || !ak2) - return 0; + if (!ak1 || !ak2) + return 0; - snprintf(buf, sizeof(buf), "%s@%s", ak2->user, ak2->host); + snprintf(buf, sizeof(buf), "%s@%s", ak2->user, ak2->host); - if (!stricmp(ak1, buf)) - return 1; - else - return 0; + if (!stricmp(ak1, buf)) + return 1; + else + return 0; } @@ -873,179 +873,179 @@ static int is_akill_entry_equal(SList * slist, void *item1, void *item2) */ int add_sgline(User * u, char *mask, const char *by, const time_t expires, - const char *reason) + const char *reason) { - int deleted = 0, i; - SXLine *entry; - User *u2, *next; - char buf[BUFSIZE]; - *buf = '\0'; - - /* Checks whether there is an SGLINE that already covers - * the one we want to add, and whether there are SGLINEs - * that would be covered by this one. - * If so, warn the user in the first case and cleanup - * the useless SGLINEs in the second. - */ - - if (!mask) { - return -1; - } - - if (sglines.count > 0) { - - for (i = sglines.count - 1; i >= 0; i--) { - entry = (SXLine *)sglines.list[i]; - - if (!entry) - continue; - - if (!stricmp(entry->mask, mask)) { - if (entry->expires >= expires || entry->expires == 0) { - if (u) - notice_lang(s_OperServ, u, OPER_SGLINE_EXISTS, - mask); - return -1; - } else { - entry->expires = expires; - if (u) - notice_lang(s_OperServ, u, OPER_SGLINE_CHANGED, - entry->mask); - return -2; - } - } - - if (match_wild_nocase(entry->mask, mask) - && (entry->expires >= expires || entry->expires == 0)) { - if (u) - notice_lang(s_OperServ, u, OPER_SGLINE_ALREADY_COVERED, - mask, entry->mask); - return -1; - } - - if (match_wild_nocase(mask, entry->mask) - && (entry->expires <= expires || expires == 0)) { - slist_delete(&sglines, i); - deleted++; - } - } - - } - - /* We can now check whether the list is full or not. */ - if (slist_full(&sglines)) { - if (u) - notice_lang(s_OperServ, u, OPER_SGLINE_REACHED_LIMIT, - sglines.limit); - return -1; - } - - /* We can now (really) add the SGLINE. */ - entry = (SXLine *)scalloc(sizeof(SXLine), 1); - if (!entry) - return -1; - - entry->mask = sstrdup(mask); - entry->by = sstrdup(by); - entry->reason = sstrdup(reason); - entry->seton = time(NULL); - entry->expires = expires; - - slist_add(&sglines, entry); - - ircdproto->SendSGLine(entry->mask, entry->reason); - - if (KillonSGline && !ircd->sglineenforce) { - snprintf(buf, (BUFSIZE - 1), "G-Lined: %s", entry->reason); - u2 = firstuser(); - while (u2) { - next = nextuser(); - if (!is_oper(u2)) { - if (match_wild_nocase(entry->mask, u2->realname)) { - kill_user(ServerName, u2->nick, buf); - } - } - u2 = next; - } - } - return deleted; + int deleted = 0, i; + SXLine *entry; + User *u2, *next; + char buf[BUFSIZE]; + *buf = '\0'; + + /* Checks whether there is an SGLINE that already covers + * the one we want to add, and whether there are SGLINEs + * that would be covered by this one. + * If so, warn the user in the first case and cleanup + * the useless SGLINEs in the second. + */ + + if (!mask) { + return -1; + } + + if (sglines.count > 0) { + + for (i = sglines.count - 1; i >= 0; i--) { + entry = (SXLine *)sglines.list[i]; + + if (!entry) + continue; + + if (!stricmp(entry->mask, mask)) { + if (entry->expires >= expires || entry->expires == 0) { + if (u) + notice_lang(s_OperServ, u, OPER_SGLINE_EXISTS, + mask); + return -1; + } else { + entry->expires = expires; + if (u) + notice_lang(s_OperServ, u, OPER_SGLINE_CHANGED, + entry->mask); + return -2; + } + } + + if (match_wild_nocase(entry->mask, mask) + && (entry->expires >= expires || entry->expires == 0)) { + if (u) + notice_lang(s_OperServ, u, OPER_SGLINE_ALREADY_COVERED, + mask, entry->mask); + return -1; + } + + if (match_wild_nocase(mask, entry->mask) + && (entry->expires <= expires || expires == 0)) { + slist_delete(&sglines, i); + deleted++; + } + } + + } + + /* We can now check whether the list is full or not. */ + if (slist_full(&sglines)) { + if (u) + notice_lang(s_OperServ, u, OPER_SGLINE_REACHED_LIMIT, + sglines.limit); + return -1; + } + + /* We can now (really) add the SGLINE. */ + entry = (SXLine *)scalloc(sizeof(SXLine), 1); + if (!entry) + return -1; + + entry->mask = sstrdup(mask); + entry->by = sstrdup(by); + entry->reason = sstrdup(reason); + entry->seton = time(NULL); + entry->expires = expires; + + slist_add(&sglines, entry); + + ircdproto->SendSGLine(entry->mask, entry->reason); + + if (KillonSGline && !ircd->sglineenforce) { + snprintf(buf, (BUFSIZE - 1), "G-Lined: %s", entry->reason); + u2 = firstuser(); + while (u2) { + next = nextuser(); + if (!is_oper(u2)) { + if (match_wild_nocase(entry->mask, u2->realname)) { + kill_user(ServerName, u2->nick, buf); + } + } + u2 = next; + } + } + return deleted; } /* Does the user match any SGLINEs? */ int check_sgline(const char *nick, const char *realname) { - int i; - SXLine *sx; - - if (sglines.count == 0) - return 0; - - for (i = 0; i < sglines.count; i++) { - sx = (SXLine *)sglines.list[i]; - if (!sx) - continue; - - if (match_wild_nocase(sx->mask, realname)) { - ircdproto->SendSGLine(sx->mask, sx->reason); - /* We kill nick since s_sgline can't */ - ircdproto->SendSVSKill(ServerName, nick, "G-Lined: %s", sx->reason); - return 1; - } - } - - return 0; + int i; + SXLine *sx; + + if (sglines.count == 0) + return 0; + + for (i = 0; i < sglines.count; i++) { + sx = (SXLine *)sglines.list[i]; + if (!sx) + continue; + + if (match_wild_nocase(sx->mask, realname)) { + ircdproto->SendSGLine(sx->mask, sx->reason); + /* We kill nick since s_sgline can't */ + ircdproto->SendSVSKill(ServerName, nick, "G-Lined: %s", sx->reason); + return 1; + } + } + + return 0; } /* Delete any expired SGLINEs. */ void expire_sglines(void) { - int i; - time_t now = time(NULL); - SXLine *sx; + int i; + time_t now = time(NULL); + SXLine *sx; - for (i = sglines.count - 1; i >= 0; i--) { - sx = (SXLine *)sglines.list[i]; + for (i = sglines.count - 1; i >= 0; i--) { + sx = (SXLine *)sglines.list[i]; - if (!sx->expires || sx->expires > now) - continue; + if (!sx->expires || sx->expires > now) + continue; - if (WallSGLineExpire) - ircdproto->SendGlobops(s_OperServ, "SGLINE on \2%s\2 has expired", - sx->mask); - slist_delete(&sglines, i); - } + if (WallSGLineExpire) + ircdproto->SendGlobops(s_OperServ, "SGLINE on \2%s\2 has expired", + sx->mask); + slist_delete(&sglines, i); + } } static void free_sgline_entry(SList * slist, void *item) { - SXLine *sx = (SXLine *)item; + SXLine *sx = (SXLine *)item; - /* Remove the SGLINE from all the servers */ - ircdproto->SendSGLineDel(sx->mask); + /* Remove the SGLINE from all the servers */ + ircdproto->SendSGLineDel(sx->mask); - /* Free the structure */ - free(sx->mask); - free(sx->by); - free(sx->reason); - free(sx); + /* Free the structure */ + free(sx->mask); + free(sx->by); + free(sx->reason); + free(sx); } /* item1 is not an SXLine pointer, but a char */ static int is_sgline_entry_equal(SList * slist, void *item1, void *item2) { - char *sx1 = (char *)item1; - SXLine *sx2 = (SXLine *)item2; + char *sx1 = (char *)item1; + SXLine *sx2 = (SXLine *)item2; - if (!sx1 || !sx2) - return 0; + if (!sx1 || !sx2) + return 0; - if (!stricmp(sx1, sx2->mask)) - return 1; - else - return 0; + if (!stricmp(sx1, sx2->mask)) + return 1; + else + return 0; } /*************************************************************************/ @@ -1056,217 +1056,217 @@ static int is_sgline_entry_equal(SList * slist, void *item1, void *item2) */ int add_sqline(User * u, char *mask, const char *by, const time_t expires, - const char *reason) + const char *reason) { - int deleted = 0, i; - User *u2, *next; - SXLine *entry; - char buf[BUFSIZE]; - *buf = '\0'; - - /* Checks whether there is an SQLINE that already covers - * the one we want to add, and whether there are SQLINEs - * that would be covered by this one. - * If so, warn the user in the first case and cleanup - * the useless SQLINEs in the second. - */ - - if (!mask) { - return -1; - } - - if (sqlines.count > 0) { - - for (i = sqlines.count - 1; i >= 0; i--) { - entry = (SXLine *)sqlines.list[i]; - - if (!entry) - continue; - - if ((*mask == '#' && *entry->mask != '#') || - (*mask != '#' && *entry->mask == '#')) - continue; - - if (!stricmp(entry->mask, mask)) { - if (entry->expires >= expires || entry->expires == 0) { - if (u) - notice_lang(s_OperServ, u, OPER_SQLINE_EXISTS, - mask); - return -1; - } else { - entry->expires = expires; - if (u) - notice_lang(s_OperServ, u, OPER_SQLINE_CHANGED, - entry->mask); - return -2; - } - } - - if (match_wild_nocase(entry->mask, mask) - && (entry->expires >= expires || entry->expires == 0)) { - if (u) - notice_lang(s_OperServ, u, OPER_SQLINE_ALREADY_COVERED, - mask, entry->mask); - return -1; - } - - if (match_wild_nocase(mask, entry->mask) - && (entry->expires <= expires || expires == 0)) { - slist_delete(&sqlines, i); - deleted++; - } - } - - } - - /* We can now check whether the list is full or not. */ - if (slist_full(&sqlines)) { - if (u) - notice_lang(s_OperServ, u, OPER_SQLINE_REACHED_LIMIT, - sqlines.limit); - return -1; - } - - /* We can now (really) add the SQLINE. */ - entry = (SXLine *)scalloc(sizeof(SXLine), 1); - if (!entry) - return -1; - - entry->mask = sstrdup(mask); - entry->by = sstrdup(by); - entry->reason = sstrdup(reason); - entry->seton = time(NULL); - entry->expires = expires; - - slist_add(&sqlines, entry); - - sqline(entry->mask, entry->reason); - - if (KillonSQline) { - snprintf(buf, (BUFSIZE - 1), "Q-Lined: %s", entry->reason); - u2 = firstuser(); - while (u2) { - next = nextuser(); - if (!is_oper(u2)) { - if (match_wild_nocase(entry->mask, u2->nick)) { - kill_user(ServerName, u2->nick, buf); - } - } - u2 = next; - } - } - - return deleted; + int deleted = 0, i; + User *u2, *next; + SXLine *entry; + char buf[BUFSIZE]; + *buf = '\0'; + + /* Checks whether there is an SQLINE that already covers + * the one we want to add, and whether there are SQLINEs + * that would be covered by this one. + * If so, warn the user in the first case and cleanup + * the useless SQLINEs in the second. + */ + + if (!mask) { + return -1; + } + + if (sqlines.count > 0) { + + for (i = sqlines.count - 1; i >= 0; i--) { + entry = (SXLine *)sqlines.list[i]; + + if (!entry) + continue; + + if ((*mask == '#' && *entry->mask != '#') || + (*mask != '#' && *entry->mask == '#')) + continue; + + if (!stricmp(entry->mask, mask)) { + if (entry->expires >= expires || entry->expires == 0) { + if (u) + notice_lang(s_OperServ, u, OPER_SQLINE_EXISTS, + mask); + return -1; + } else { + entry->expires = expires; + if (u) + notice_lang(s_OperServ, u, OPER_SQLINE_CHANGED, + entry->mask); + return -2; + } + } + + if (match_wild_nocase(entry->mask, mask) + && (entry->expires >= expires || entry->expires == 0)) { + if (u) + notice_lang(s_OperServ, u, OPER_SQLINE_ALREADY_COVERED, + mask, entry->mask); + return -1; + } + + if (match_wild_nocase(mask, entry->mask) + && (entry->expires <= expires || expires == 0)) { + slist_delete(&sqlines, i); + deleted++; + } + } + + } + + /* We can now check whether the list is full or not. */ + if (slist_full(&sqlines)) { + if (u) + notice_lang(s_OperServ, u, OPER_SQLINE_REACHED_LIMIT, + sqlines.limit); + return -1; + } + + /* We can now (really) add the SQLINE. */ + entry = (SXLine *)scalloc(sizeof(SXLine), 1); + if (!entry) + return -1; + + entry->mask = sstrdup(mask); + entry->by = sstrdup(by); + entry->reason = sstrdup(reason); + entry->seton = time(NULL); + entry->expires = expires; + + slist_add(&sqlines, entry); + + sqline(entry->mask, entry->reason); + + if (KillonSQline) { + snprintf(buf, (BUFSIZE - 1), "Q-Lined: %s", entry->reason); + u2 = firstuser(); + while (u2) { + next = nextuser(); + if (!is_oper(u2)) { + if (match_wild_nocase(entry->mask, u2->nick)) { + kill_user(ServerName, u2->nick, buf); + } + } + u2 = next; + } + } + + return deleted; } /* Does the user match any SQLINEs? */ int check_sqline(const char *nick, int nick_change) { - int i; - SXLine *sx; - char reason[300]; - - if (sqlines.count == 0) - return 0; - - for (i = 0; i < sqlines.count; i++) { - sx = (SXLine *)sqlines.list[i]; - if (!sx) - continue; - - if (ircd->chansqline) { - if (*sx->mask == '#') - continue; - } - - if (match_wild_nocase(sx->mask, nick)) { - sqline(sx->mask, sx->reason); - /* We kill nick since s_sqline can't */ - snprintf(reason, sizeof(reason), "Q-Lined: %s", sx->reason); - kill_user(s_OperServ, nick, reason); - return 1; - } - } - - return 0; + int i; + SXLine *sx; + char reason[300]; + + if (sqlines.count == 0) + return 0; + + for (i = 0; i < sqlines.count; i++) { + sx = (SXLine *)sqlines.list[i]; + if (!sx) + continue; + + if (ircd->chansqline) { + if (*sx->mask == '#') + continue; + } + + if (match_wild_nocase(sx->mask, nick)) { + sqline(sx->mask, sx->reason); + /* We kill nick since s_sqline can't */ + snprintf(reason, sizeof(reason), "Q-Lined: %s", sx->reason); + kill_user(s_OperServ, nick, reason); + return 1; + } + } + + return 0; } int check_chan_sqline(const char *chan) { - int i; - SXLine *sx; + int i; + SXLine *sx; - if (sqlines.count == 0) - return 0; + if (sqlines.count == 0) + return 0; - for (i = 0; i < sqlines.count; i++) { - sx = (SXLine *)sqlines.list[i]; - if (!sx) - continue; + for (i = 0; i < sqlines.count; i++) { + sx = (SXLine *)sqlines.list[i]; + if (!sx) + continue; - if (*sx->mask != '#') - continue; + if (*sx->mask != '#') + continue; - if (match_wild_nocase(sx->mask, chan)) { - sqline(sx->mask, sx->reason); - return 1; - } - } + if (match_wild_nocase(sx->mask, chan)) { + sqline(sx->mask, sx->reason); + return 1; + } + } - return 0; + return 0; } /* Delete any expired SQLINEs. */ void expire_sqlines(void) { - int i; - time_t now = time(NULL); - SXLine *sx; + int i; + time_t now = time(NULL); + SXLine *sx; - for (i = sqlines.count - 1; i >= 0; i--) { - sx = (SXLine *)sqlines.list[i]; + for (i = sqlines.count - 1; i >= 0; i--) { + sx = (SXLine *)sqlines.list[i]; - if (!sx->expires || sx->expires > now) - continue; + if (!sx->expires || sx->expires > now) + continue; - if (WallSQLineExpire) - ircdproto->SendGlobops(s_OperServ, "SQLINE on \2%s\2 has expired", - sx->mask); + if (WallSQLineExpire) + ircdproto->SendGlobops(s_OperServ, "SQLINE on \2%s\2 has expired", + sx->mask); - slist_delete(&sqlines, i); - } + slist_delete(&sqlines, i); + } } static void free_sqline_entry(SList * slist, void *item) { - SXLine *sx = (SXLine *)item; + SXLine *sx = (SXLine *)item; - /* Remove the SQLINE from all the servers */ - ircdproto->SendSQLineDel(sx->mask); + /* Remove the SQLINE from all the servers */ + ircdproto->SendSQLineDel(sx->mask); - /* Free the structure */ - free(sx->mask); - free(sx->by); - free(sx->reason); - free(sx); + /* Free the structure */ + free(sx->mask); + free(sx->by); + free(sx->reason); + free(sx); } /* item1 is not an SXLine pointer, but a char */ static int is_sqline_entry_equal(SList * slist, void *item1, void *item2) { - char *sx1 = (char *)item1; - SXLine *sx2 = (SXLine *)item2; + char *sx1 = (char *)item1; + SXLine *sx2 = (SXLine *)item2; - if (!sx1 || !sx2) - return 0; + if (!sx1 || !sx2) + return 0; - if (!stricmp(sx1, sx2->mask)) - return 1; - else - return 0; + if (!stricmp(sx1, sx2->mask)) + return 1; + else + return 0; } /*************************************************************************/ @@ -1277,112 +1277,112 @@ static int is_sqline_entry_equal(SList * slist, void *item1, void *item2) */ int add_szline(User * u, char *mask, const char *by, const time_t expires, - const char *reason) + const char *reason) { - int deleted = 0, i; - SXLine *entry; - - if (!mask) { - return -1; - } - - /* Checks whether there is an SZLINE that already covers - * the one we want to add, and whether there are SZLINEs - * that would be covered by this one. - * If so, warn the user in the first case and cleanup - * the useless SZLINEs in the second. - */ - - if (szlines.count > 0) { - - for (i = szlines.count - 1; i >= 0; i--) { - entry = (SXLine *)szlines.list[i]; - - if (!entry) - continue; - - if (!stricmp(entry->mask, mask)) { - if (entry->expires >= expires || entry->expires == 0) { - if (u) - notice_lang(s_OperServ, u, OPER_SZLINE_EXISTS, - mask); - return -1; - } else { - entry->expires = expires; - if (u) - notice_lang(s_OperServ, u, OPER_SZLINE_EXISTS, - mask); - return -2; - } - } - - if (match_wild_nocase(entry->mask, mask)) { - if (u) - notice_lang(s_OperServ, u, OPER_SZLINE_ALREADY_COVERED, - mask, entry->mask); - return -1; - } - - if (match_wild_nocase(mask, entry->mask)) { - slist_delete(&szlines, i); - deleted++; - } - } - - } - - /* We can now check whether the list is full or not. */ - if (slist_full(&szlines)) { - if (u) - notice_lang(s_OperServ, u, OPER_SZLINE_REACHED_LIMIT, - szlines.limit); - return -1; - } - - /* We can now (really) add the SZLINE. */ - entry = (SXLine *)scalloc(sizeof(SXLine), 1); - if (!entry) - return -1; - - entry->mask = sstrdup(mask); - entry->by = sstrdup(by); - entry->reason = sstrdup(reason); - entry->seton = time(NULL); - entry->expires = expires; - - slist_add(&szlines, entry); - ircdproto->SendSZLine(entry->mask, entry->reason, entry->by); - - return deleted; + int deleted = 0, i; + SXLine *entry; + + if (!mask) { + return -1; + } + + /* Checks whether there is an SZLINE that already covers + * the one we want to add, and whether there are SZLINEs + * that would be covered by this one. + * If so, warn the user in the first case and cleanup + * the useless SZLINEs in the second. + */ + + if (szlines.count > 0) { + + for (i = szlines.count - 1; i >= 0; i--) { + entry = (SXLine *)szlines.list[i]; + + if (!entry) + continue; + + if (!stricmp(entry->mask, mask)) { + if (entry->expires >= expires || entry->expires == 0) { + if (u) + notice_lang(s_OperServ, u, OPER_SZLINE_EXISTS, + mask); + return -1; + } else { + entry->expires = expires; + if (u) + notice_lang(s_OperServ, u, OPER_SZLINE_EXISTS, + mask); + return -2; + } + } + + if (match_wild_nocase(entry->mask, mask)) { + if (u) + notice_lang(s_OperServ, u, OPER_SZLINE_ALREADY_COVERED, + mask, entry->mask); + return -1; + } + + if (match_wild_nocase(mask, entry->mask)) { + slist_delete(&szlines, i); + deleted++; + } + } + + } + + /* We can now check whether the list is full or not. */ + if (slist_full(&szlines)) { + if (u) + notice_lang(s_OperServ, u, OPER_SZLINE_REACHED_LIMIT, + szlines.limit); + return -1; + } + + /* We can now (really) add the SZLINE. */ + entry = (SXLine *)scalloc(sizeof(SXLine), 1); + if (!entry) + return -1; + + entry->mask = sstrdup(mask); + entry->by = sstrdup(by); + entry->reason = sstrdup(reason); + entry->seton = time(NULL); + entry->expires = expires; + + slist_add(&szlines, entry); + ircdproto->SendSZLine(entry->mask, entry->reason, entry->by); + + return deleted; } /* Check and enforce any Zlines that we have */ int check_szline(const char *nick, char *ip) { - int i; - SXLine *sx; - - if (szlines.count == 0) { - return 0; - } - - if (!ip) { - return 0; - } - - for (i = 0; i < szlines.count; i++) { - sx = (SXLine *)szlines.list[i]; - if (!sx) { - continue; - } - - if (match_wild_nocase(sx->mask, ip)) { - ircdproto->SendSZLine(sx->mask, sx->reason, sx->by); - return 1; - } - } - - return 0; + int i; + SXLine *sx; + + if (szlines.count == 0) { + return 0; + } + + if (!ip) { + return 0; + } + + for (i = 0; i < szlines.count; i++) { + sx = (SXLine *)szlines.list[i]; + if (!sx) { + continue; + } + + if (match_wild_nocase(sx->mask, ip)) { + ircdproto->SendSZLine(sx->mask, sx->reason, sx->by); + return 1; + } + } + + return 0; } @@ -1390,35 +1390,35 @@ int check_szline(const char *nick, char *ip) void expire_szlines(void) { - int i; - time_t now = time(NULL); - SXLine *sx; + int i; + time_t now = time(NULL); + SXLine *sx; - for (i = szlines.count - 1; i >= 0; i--) { - sx = (SXLine *)szlines.list[i]; + for (i = szlines.count - 1; i >= 0; i--) { + sx = (SXLine *)szlines.list[i]; - if (!sx->expires || sx->expires > now) - continue; + if (!sx->expires || sx->expires > now) + continue; - if (WallSZLineExpire) - ircdproto->SendGlobops(s_OperServ, "SZLINE on \2%s\2 has expired", - sx->mask); - slist_delete(&szlines, i); - } + if (WallSZLineExpire) + ircdproto->SendGlobops(s_OperServ, "SZLINE on \2%s\2 has expired", + sx->mask); + slist_delete(&szlines, i); + } } static void free_szline_entry(SList * slist, void *item) { - SXLine *sx = (SXLine *)item; + SXLine *sx = (SXLine *)item; - /* Remove the SZLINE from all the servers */ - ircdproto->SendSZLineDel(sx->mask); + /* Remove the SZLINE from all the servers */ + ircdproto->SendSZLineDel(sx->mask); - /* Free the structure */ - free(sx->mask); - free(sx->by); - free(sx->reason); - free(sx); + /* Free the structure */ + free(sx->mask); + free(sx->by); + free(sx->reason); + free(sx); } /* item1 is not an SXLine pointer, but a char @@ -1426,16 +1426,16 @@ static void free_szline_entry(SList * slist, void *item) static int is_szline_entry_equal(SList * slist, void *item1, void *item2) { - char *sx1 = (char *)item1; - SXLine *sx2 = (SXLine *)item2; + char *sx1 = (char *)item1; + SXLine *sx2 = (SXLine *)item2; - if (!sx1 || !sx2) - return 0; + if (!sx1 || !sx2) + return 0; - if (!stricmp(sx1, sx2->mask)) - return 1; - else - return 0; + if (!stricmp(sx1, sx2->mask)) + return 1; + else + return 0; } /*************************************************************************/ @@ -1443,20 +1443,20 @@ static int is_szline_entry_equal(SList * slist, void *item1, void *item2) /* Callback function used to sort the admin list */ static int compare_adminlist_entries(SList * slist, void *item1, - void *item2) + void *item2) { - NickCore *nc1 = (NickCore *)item1, *nc2 = (NickCore *)item2; - if (!nc1 || !nc2) - return -1; /* To tell to continue */ - return stricmp(nc1->display, nc2->display); + NickCore *nc1 = (NickCore *)item1, *nc2 = (NickCore *)item2; + if (!nc1 || !nc2) + return -1; /* To tell to continue */ + return stricmp(nc1->display, nc2->display); } /* Callback function used when an admin list entry is deleted */ static void free_adminlist_entry(SList * slist, void *item) { - NickCore *nc = (NickCore *)item; - nc->flags &= ~NI_SERVICES_ADMIN; + NickCore *nc = (NickCore *)item; + nc->flags &= ~NI_SERVICES_ADMIN; } /*************************************************************************/ @@ -1464,20 +1464,20 @@ static void free_adminlist_entry(SList * slist, void *item) /* Callback function used to sort the oper list */ static int compare_operlist_entries(SList * slist, void *item1, - void *item2) + void *item2) { - NickCore *nc1 = (NickCore *)item1, *nc2 = (NickCore *)item2; - if (!nc1 || !nc2) - return -1; /* To tell to continue */ - return stricmp(nc1->display, nc2->display); + NickCore *nc1 = (NickCore *)item1, *nc2 = (NickCore *)item2; + if (!nc1 || !nc2) + return -1; /* To tell to continue */ + return stricmp(nc1->display, nc2->display); } /* Callback function used when an oper list entry is deleted */ static void free_operlist_entry(SList * slist, void *item) { - NickCore *nc = (NickCore *)item; - nc->flags &= ~NI_SERVICES_OPER; + NickCore *nc = (NickCore *)item; + nc->flags &= ~NI_SERVICES_OPER; } /*************************************************************************/ @@ -1487,7 +1487,7 @@ static void free_operlist_entry(SList * slist, void *item) **/ int checkDefCon(int level) { - return DefCon[DefConLevel] & level; + return DefCon[DefConLevel] & level; } /** @@ -1495,31 +1495,31 @@ int checkDefCon(int level) **/ void resetDefCon(int level) { - char strLevel[5]; - snprintf(strLevel, 4, "%d", level); - if (DefConLevel != level) { - if ((DefContimer) - && (time(NULL) - DefContimer >= DefConTimeOut)) { - DefConLevel = level; - send_event(EVENT_DEFCON_LEVEL, 1, strLevel); - alog("Defcon level timeout, returning to lvl %d", level); - ircdproto->SendGlobops(s_OperServ, - getstring2(NULL, OPER_DEFCON_WALL), - s_OperServ, level); - if (GlobalOnDefcon) { - if (DefConOffMessage) { - oper_global(NULL, "%s", DefConOffMessage); - } else { - oper_global(NULL, getstring(NULL, DEFCON_GLOBAL), - DefConLevel); - } - } - if (GlobalOnDefconMore && !DefConOffMessage) { - oper_global(NULL, "%s", DefconMessage); - } - runDefCon(); - } - } + char strLevel[5]; + snprintf(strLevel, 4, "%d", level); + if (DefConLevel != level) { + if ((DefContimer) + && (time(NULL) - DefContimer >= DefConTimeOut)) { + DefConLevel = level; + send_event(EVENT_DEFCON_LEVEL, 1, strLevel); + alog("Defcon level timeout, returning to lvl %d", level); + ircdproto->SendGlobops(s_OperServ, + getstring2(NULL, OPER_DEFCON_WALL), + s_OperServ, level); + if (GlobalOnDefcon) { + if (DefConOffMessage) { + oper_global(NULL, "%s", DefConOffMessage); + } else { + oper_global(NULL, getstring(NULL, DEFCON_GLOBAL), + DefConLevel); + } + } + if (GlobalOnDefconMore && !DefConOffMessage) { + oper_global(NULL, "%s", DefconMessage); + } + runDefCon(); + } + } } /** @@ -1527,27 +1527,27 @@ void resetDefCon(int level) **/ void runDefCon(void) { - char *newmodes; - if (checkDefCon(DEFCON_FORCE_CHAN_MODES)) { - if (DefConChanModes && !DefConModesSet) { - if (DefConChanModes[0] == '+' || DefConChanModes[0] == '-') { - alog("DEFCON: setting %s on all chan's", DefConChanModes); - do_mass_mode(DefConChanModes); - DefConModesSet = 1; - } - } - } else { - if (DefConChanModes && (DefConModesSet != 0)) { - if (DefConChanModes[0] == '+' || DefConChanModes[0] == '-') { - DefConModesSet = 0; - if ((newmodes = defconReverseModes(DefConChanModes))) { - alog("DEFCON: setting %s on all chan's", newmodes); - do_mass_mode(newmodes); - free(newmodes); - } - } - } - } + char *newmodes; + if (checkDefCon(DEFCON_FORCE_CHAN_MODES)) { + if (DefConChanModes && !DefConModesSet) { + if (DefConChanModes[0] == '+' || DefConChanModes[0] == '-') { + alog("DEFCON: setting %s on all chan's", DefConChanModes); + do_mass_mode(DefConChanModes); + DefConModesSet = 1; + } + } + } else { + if (DefConChanModes && (DefConModesSet != 0)) { + if (DefConChanModes[0] == '+' || DefConChanModes[0] == '-') { + DefConModesSet = 0; + if ((newmodes = defconReverseModes(DefConChanModes))) { + alog("DEFCON: setting %s on all chan's", newmodes); + do_mass_mode(newmodes); + free(newmodes); + } + } + } + } } /** @@ -1555,24 +1555,24 @@ void runDefCon(void) **/ char *defconReverseModes(const char *modes) { - char *newmodes = NULL; - int i = 0; - if (!modes) { - return NULL; - } - if (!(newmodes = (char *)malloc(sizeof(char) * strlen(modes) + 1))) { - return NULL; - } - for (i = 0; i < strlen(modes); i++) { - if (modes[i] == '+') - newmodes[i] = '-'; - else if (modes[i] == '-') - newmodes[i] = '+'; - else - newmodes[i] = modes[i]; - } - newmodes[i] = '\0'; - return newmodes; + char *newmodes = NULL; + int i = 0; + if (!modes) { + return NULL; + } + if (!(newmodes = (char *)malloc(sizeof(char) * strlen(modes) + 1))) { + return NULL; + } + for (i = 0; i < strlen(modes); i++) { + if (modes[i] == '+') + newmodes[i] = '-'; + else if (modes[i] == '-') + newmodes[i] = '+'; + else + newmodes[i] = modes[i]; + } + newmodes[i] = '\0'; + return newmodes; } /* Parse the defcon mlock mode string and set the correct global vars. @@ -1582,96 +1582,96 @@ char *defconReverseModes(const char *modes) */ int defconParseModeString(const char *str) { - int add = -1; /* 1 if adding, 0 if deleting, -1 if neither */ - unsigned char mode; - CBMode *cbm; - char *str_copy = sstrdup(str); /* We need this copy as str is const -GD */ - char *param; /* Store parameters during mode parsing */ - - /* Reinitialize everything */ - DefConModesOn = 0; - DefConModesOff = 0; - DefConModesCI.mlock_limit = 0; - DefConModesCI.mlock_key = NULL; - DefConModesCI.mlock_flood = NULL; - DefConModesCI.mlock_redirect = NULL; - - /* Initialize strtok() internal buffer */ - strtok(str_copy, " "); - - /* Loop while there are modes to set */ - while ((mode = *str++) && (mode != ' ')) { - switch (mode) { - case '+': - add = 1; - continue; - case '-': - add = 0; - continue; - default: - if (add < 0) - continue; - } - - if ((int) mode < 128 && (cbm = &cbmodes[(int) mode])->flag != 0) { - if (cbm->flags & CBM_NO_MLOCK) { - alog("DefConChanModes mode character '%c' cannot be locked", mode); - free(str_copy); - return 0; - } else if (add) { - DefConModesOn |= cbm->flag; - DefConModesOff &= ~cbm->flag; - if (cbm->cssetvalue) { - if (!(param = strtok(NULL, " "))) { - alog("DefConChanModes mode character '%c' has no parameter while one is expected", mode); - free(str_copy); - return 0; - } - cbm->cssetvalue(&DefConModesCI, param); - } - } else { - DefConModesOff |= cbm->flag; - if (DefConModesOn & cbm->flag) { - DefConModesOn &= ~cbm->flag; - if (cbm->cssetvalue) { - cbm->cssetvalue(&DefConModesCI, NULL); - } - } - } - } else { - alog("DefConChanModes unknown mode character '%c'", mode); - free(str_copy); - return 0; - } - } /* while (*param) */ - - free(str_copy); - - if (ircd->Lmode) { - /* We can't mlock +L if +l is not mlocked as well. */ - if ((DefConModesOn & ircd->chan_lmode) - && !(DefConModesOn & anope_get_limit_mode())) { - DefConModesOn &= ~ircd->chan_lmode; - free(DefConModesCI.mlock_redirect); - DefConModesCI.mlock_redirect = NULL; - alog("DefConChanModes must lock mode +l as well to lock mode +L"); - return 0; - } - } - - /* Some ircd we can't set NOKNOCK without INVITE */ - /* So check if we need there is a NOKNOCK MODE and that we need INVITEONLY */ - if (ircd->noknock && ircd->knock_needs_i) { - if ((DefConModesOn & ircd->noknock) - && !(DefConModesOn & anope_get_invite_mode())) { - DefConModesOn &= ~ircd->noknock; - alog("DefConChanModes must lock mode +i as well to lock mode +K"); - return 0; - } - } - - /* Everything is set fine, return 1 */ - return 1; + int add = -1; /* 1 if adding, 0 if deleting, -1 if neither */ + unsigned char mode; + CBMode *cbm; + char *str_copy = sstrdup(str); /* We need this copy as str is const -GD */ + char *param; /* Store parameters during mode parsing */ + + /* Reinitialize everything */ + DefConModesOn = 0; + DefConModesOff = 0; + DefConModesCI.mlock_limit = 0; + DefConModesCI.mlock_key = NULL; + DefConModesCI.mlock_flood = NULL; + DefConModesCI.mlock_redirect = NULL; + + /* Initialize strtok() internal buffer */ + strtok(str_copy, " "); + + /* Loop while there are modes to set */ + while ((mode = *str++) && (mode != ' ')) { + switch (mode) { + case '+': + add = 1; + continue; + case '-': + add = 0; + continue; + default: + if (add < 0) + continue; + } + + if ((int) mode < 128 && (cbm = &cbmodes[(int) mode])->flag != 0) { + if (cbm->flags & CBM_NO_MLOCK) { + alog("DefConChanModes mode character '%c' cannot be locked", mode); + free(str_copy); + return 0; + } else if (add) { + DefConModesOn |= cbm->flag; + DefConModesOff &= ~cbm->flag; + if (cbm->cssetvalue) { + if (!(param = strtok(NULL, " "))) { + alog("DefConChanModes mode character '%c' has no parameter while one is expected", mode); + free(str_copy); + return 0; + } + cbm->cssetvalue(&DefConModesCI, param); + } + } else { + DefConModesOff |= cbm->flag; + if (DefConModesOn & cbm->flag) { + DefConModesOn &= ~cbm->flag; + if (cbm->cssetvalue) { + cbm->cssetvalue(&DefConModesCI, NULL); + } + } + } + } else { + alog("DefConChanModes unknown mode character '%c'", mode); + free(str_copy); + return 0; + } + } /* while (*param) */ + + free(str_copy); + + if (ircd->Lmode) { + /* We can't mlock +L if +l is not mlocked as well. */ + if ((DefConModesOn & ircd->chan_lmode) + && !(DefConModesOn & anope_get_limit_mode())) { + DefConModesOn &= ~ircd->chan_lmode; + free(DefConModesCI.mlock_redirect); + DefConModesCI.mlock_redirect = NULL; + alog("DefConChanModes must lock mode +l as well to lock mode +L"); + return 0; + } + } + + /* Some ircd we can't set NOKNOCK without INVITE */ + /* So check if we need there is a NOKNOCK MODE and that we need INVITEONLY */ + if (ircd->noknock && ircd->knock_needs_i) { + if ((DefConModesOn & ircd->noknock) + && !(DefConModesOn & anope_get_invite_mode())) { + DefConModesOn &= ~ircd->noknock; + alog("DefConChanModes must lock mode +i as well to lock mode +K"); + return 0; + } + } + + /* Everything is set fine, return 1 */ + return 1; } /*************************************************************************/ diff --git a/src/process.c b/src/process.c index 3f2348097..54a4dc1e8 100644 --- a/src/process.c +++ b/src/process.c @@ -33,67 +33,67 @@ IgnoreData *ignore; */ void add_ignore(const char *nick, time_t delta) { - IgnoreData *ign; - char tmp[BUFSIZE]; - char *mask, *user, *host; - User *u; - time_t now; - + IgnoreData *ign; + char tmp[BUFSIZE]; + char *mask, *user, *host; + User *u; + time_t now; + if (!nick) - return; - now = time(NULL); - - - /* If it s an existing user, we ignore the hostmask. */ - if ((u = finduser(nick))) { - snprintf(tmp, sizeof(tmp), "*!*@%s", u->host); - mask = sstrdup(tmp); - - /* Determine whether we get a nick or a mask. */ - } else if ((host = strchr(nick, '@'))) { - /* Check whether we have a nick too.. */ - if ((user = strchr(nick, '!'))) { - /* this should never happen */ - if (user > host) - return; - mask = sstrdup(nick); - } else { - /* We have user@host. Add nick wildcard. */ - snprintf(tmp, sizeof(tmp), "*!%s", nick); - mask = sstrdup(tmp); - } - - /* We only got a nick.. */ - } else { - + return; + now = time(NULL); + + + /* If it s an existing user, we ignore the hostmask. */ + if ((u = finduser(nick))) { + snprintf(tmp, sizeof(tmp), "*!*@%s", u->host); + mask = sstrdup(tmp); + + /* Determine whether we get a nick or a mask. */ + } else if ((host = strchr(nick, '@'))) { + /* Check whether we have a nick too.. */ + if ((user = strchr(nick, '!'))) { + /* this should never happen */ + if (user > host) + return; + mask = sstrdup(nick); + } else { + /* We have user@host. Add nick wildcard. */ + snprintf(tmp, sizeof(tmp), "*!%s", nick); + mask = sstrdup(tmp); + } + + /* We only got a nick.. */ + } else { + snprintf(tmp, sizeof(tmp), "%s!*@*", nick); - mask = sstrdup(tmp); - } - - /* Check if we already got an identical entry. */ - for (ign = ignore; ign; ign = ign->next) - if (stricmp(ign->mask, mask) == 0) - break; - - /* Found one.. */ - if (ign) { - if (delta == 0) - ign->time = 0; - else if (ign->time < now + delta) - ign->time = now + delta; - /* Create new entry.. */ - } else { - ign = (IgnoreData *)scalloc(sizeof(*ign), 1); - ign->mask = mask; - ign->time = (delta == 0 ? 0 : now + delta); - ign->prev = NULL; - ign->next = ignore; - if (ignore) - ignore->prev = ign; - ignore = ign; - if (debug) - alog("debug: Added new ignore entry for %s", mask); - } + mask = sstrdup(tmp); + } + + /* Check if we already got an identical entry. */ + for (ign = ignore; ign; ign = ign->next) + if (stricmp(ign->mask, mask) == 0) + break; + + /* Found one.. */ + if (ign) { + if (delta == 0) + ign->time = 0; + else if (ign->time < now + delta) + ign->time = now + delta; + /* Create new entry.. */ + } else { + ign = (IgnoreData *)scalloc(sizeof(*ign), 1); + ign->mask = mask; + ign->time = (delta == 0 ? 0 : now + delta); + ign->prev = NULL; + ign->next = ignore; + if (ignore) + ignore->prev = ign; + ignore = ign; + if (debug) + alog("debug: Added new ignore entry for %s", mask); + } } /*************************************************************************/ @@ -107,75 +107,75 @@ snprintf(tmp, sizeof(tmp), "%s!*@*", nick); */ IgnoreData *get_ignore(const char *nick) { - IgnoreData *ign; - char tmp[BUFSIZE]; - char *user, *host; - time_t now; - User *u; - + IgnoreData *ign; + char tmp[BUFSIZE]; + char *user, *host; + time_t now; + User *u; + if (!nick) - return NULL; - + return NULL; + - /* User has disabled the IGNORE system */ - if (!allow_ignore) - return NULL; - + /* User has disabled the IGNORE system */ + if (!allow_ignore) + return NULL; + now = time(NULL); - + u = finduser(nick); - - - /* If we find a real user, match his mask against the ignorelist. */ - if (u) { - /* Opers are not ignored, even if a matching entry may be present. */ - if (is_oper(u)) - return NULL; - for (ign = ignore; ign; ign = ign->next) - if (match_usermask(ign->mask, u)) - break; - + + + /* If we find a real user, match his mask against the ignorelist. */ + if (u) { + /* Opers are not ignored, even if a matching entry may be present. */ + if (is_oper(u)) + return NULL; + for (ign = ignore; ign; ign = ign->next) + if (match_usermask(ign->mask, u)) + break; + } else { - /* We didn't get a user.. generate a valid mask. */ - if ((host = strchr(nick, '@'))) { - if ((user = strchr(nick, '!'))) { - /* this should never happen */ - if (user > host) - return NULL; - snprintf(tmp, sizeof(tmp), "%s", nick); - } else { - /* We have user@host. Add nick wildcard. */ - snprintf(tmp, sizeof(tmp), "*!%s", nick); - } - - /* We only got a nick.. */ - } else - + /* We didn't get a user.. generate a valid mask. */ + if ((host = strchr(nick, '@'))) { + if ((user = strchr(nick, '!'))) { + /* this should never happen */ + if (user > host) + return NULL; + snprintf(tmp, sizeof(tmp), "%s", nick); + } else { + /* We have user@host. Add nick wildcard. */ + snprintf(tmp, sizeof(tmp), "*!%s", nick); + } + + /* We only got a nick.. */ + } else + snprintf(tmp, sizeof(tmp), "%s!*@*", nick); - + for (ign = ignore; ign; ign = ign->next) - if (match_wild_nocase(ign->mask, tmp)) - break; - } - - /* Check whether the entry has timed out */ - if (ign && ign->time != 0 && ign->time <= now) { - if (debug) - alog("debug: Expiring ignore entry %s", ign->mask); - if (ign->prev) - ign->prev->next = ign->next; - else if (ignore == ign) - ignore = ign->next; - if (ign->next) - ign->next->prev = ign->prev; - free(ign->mask); - free(ign); - ign = NULL; - } - + if (match_wild_nocase(ign->mask, tmp)) + break; + } + + /* Check whether the entry has timed out */ + if (ign && ign->time != 0 && ign->time <= now) { + if (debug) + alog("debug: Expiring ignore entry %s", ign->mask); + if (ign->prev) + ign->prev->next = ign->next; + else if (ignore == ign) + ignore = ign->next; + if (ign->next) + ign->next->prev = ign->prev; + free(ign->mask); + free(ign); + ign = NULL; + } + if (ign && debug) - alog("debug: Found ignore entry (%s) for %s", ign->mask, nick); - return ign; + alog("debug: Found ignore entry (%s) for %s", ign->mask, nick); + return ign; } @@ -188,60 +188,60 @@ if (ign && debug) */ int delete_ignore(const char *nick) { - IgnoreData *ign; - char tmp[BUFSIZE]; - char *user, *host; - User *u; - + IgnoreData *ign; + char tmp[BUFSIZE]; + char *user, *host; + User *u; + if (!nick) - return 0; - - /* If it s an existing user, we ignore the hostmask. */ - if ((u = finduser(nick))) { - snprintf(tmp, sizeof(tmp), "*!*@%s", u->host); - - /* Determine whether we get a nick or a mask. */ - } else if ((host = strchr(nick, '@'))) { - /* Check whether we have a nick too.. */ - if ((user = strchr(nick, '!'))) { - /* this should never happen */ - if (user > host) - return 0; - snprintf(tmp, sizeof(tmp), "%s", nick); - } else { - /* We have user@host. Add nick wildcard. */ - snprintf(tmp, sizeof(tmp), "*!%s", nick); - } - - /* We only got a nick.. */ - } else - + return 0; + + /* If it s an existing user, we ignore the hostmask. */ + if ((u = finduser(nick))) { + snprintf(tmp, sizeof(tmp), "*!*@%s", u->host); + + /* Determine whether we get a nick or a mask. */ + } else if ((host = strchr(nick, '@'))) { + /* Check whether we have a nick too.. */ + if ((user = strchr(nick, '!'))) { + /* this should never happen */ + if (user > host) + return 0; + snprintf(tmp, sizeof(tmp), "%s", nick); + } else { + /* We have user@host. Add nick wildcard. */ + snprintf(tmp, sizeof(tmp), "*!%s", nick); + } + + /* We only got a nick.. */ + } else + snprintf(tmp, sizeof(tmp), "%s!*@*", nick); - for (ign = ignore; ign; ign = ign->next) - if (stricmp(ign->mask, tmp) == 0) - break; - - /* No matching ignore found. */ - if (!ign) - return 0; - + for (ign = ignore; ign; ign = ign->next) + if (stricmp(ign->mask, tmp) == 0) + break; + + /* No matching ignore found. */ + if (!ign) + return 0; + if (debug) - alog("Deleting ignore entry %s", ign->mask); - - /* Delete the entry and all references to it. */ - if (ign->prev) - ign->prev->next = ign->next; - else if (ignore == ign) - ignore = ign->next; - if (ign->next) - ign->next->prev = ign->prev; - + alog("Deleting ignore entry %s", ign->mask); + + /* Delete the entry and all references to it. */ + if (ign->prev) + ign->prev->next = ign->next; + else if (ignore == ign) + ignore = ign->next; + if (ign->next) + ign->next->prev = ign->prev; + free(ign->mask); - free(ign); - ign = NULL; - + free(ign); + ign = NULL; + return 1; } @@ -249,129 +249,129 @@ return 1; /*************************************************************************/ - + /** * Clear the ignorelist. * @return The number of entries deleted. */ int clear_ignores() { - IgnoreData *ign, *next; - int i = 0; - + IgnoreData *ign, *next; + int i = 0; + if (!ignore) - return 0; - + return 0; + for (ign = ignore; ign; ign = next) { - next = ign->next; - if (debug) - alog("Deleting ignore entry %s", ign->mask); - free(ign->mask); - free(ign); - i++; - } - + next = ign->next; + if (debug) + alog("Deleting ignore entry %s", ign->mask); + free(ign->mask); + free(ign); + i++; + } + ignore = NULL; - return i; + return i; } /*************************************************************************/ /* split_buf: Split a buffer into arguments and store the arguments in an - * argument vector pointed to by argv (which will be malloc'd - * as necessary); return the argument count. If colon_special - * is non-zero, then treat a parameter with a leading ':' as - * the last parameter of the line, per the IRC RFC. Destroys - * the buffer by side effect. + * argument vector pointed to by argv (which will be malloc'd + * as necessary); return the argument count. If colon_special + * is non-zero, then treat a parameter with a leading ':' as + * the last parameter of the line, per the IRC RFC. Destroys + * the buffer by side effect. */ int split_buf(char *buf, const char ***argv, int colon_special) { - int argvsize = 8; - int argc; - char *s; - - *argv = (const char **)scalloc(sizeof(const char *) * argvsize, 1); - argc = 0; - while (*buf) { - if (argc == argvsize) { - argvsize += 8; - *argv = (const char **)srealloc(*argv, sizeof(const char *) * argvsize); - } - if (*buf == ':') { - (*argv)[argc++] = buf + 1; - buf = ""; - } else { - s = strpbrk(buf, " "); - if (s) { - *s++ = 0; - while (*s == ' ') - s++; - } else { - s = buf + strlen(buf); - } - (*argv)[argc++] = buf; - buf = s; - } - } - return argc; + int argvsize = 8; + int argc; + char *s; + + *argv = (const char **)scalloc(sizeof(const char *) * argvsize, 1); + argc = 0; + while (*buf) { + if (argc == argvsize) { + argvsize += 8; + *argv = (const char **)srealloc(*argv, sizeof(const char *) * argvsize); + } + if (*buf == ':') { + (*argv)[argc++] = buf + 1; + buf = ""; + } else { + s = strpbrk(buf, " "); + if (s) { + *s++ = 0; + while (*s == ' ') + s++; + } else { + s = buf + strlen(buf); + } + (*argv)[argc++] = buf; + buf = s; + } + } + return argc; } /*************************************************************************/ /* process: Main processing routine. Takes the string in inbuf (global - * variable) and does something appropriate with it. */ + * variable) and does something appropriate with it. */ void process() { - int retVal = 0; - Message *current = NULL; - char source[64]; - char cmd[64]; - char buf[512]; /* Longest legal IRC command line */ - char *s; - int ac; /* Parameters for the command */ - const 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) { - 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)); - - doCleanBuffer((char *) buf); - - /* Split the buffer into pieces. */ - if (*buf == ':') { - s = strpbrk(buf, " "); - if (!s) - return; - *s = 0; - while (isspace(*++s)); - strscpy(source, buf + 1, sizeof(source)); - memmove(buf, s, strlen(s) + 1); - } else { - *source = 0; - } - if (!*buf) - return; - s = strpbrk(buf, " "); - if (s) { - *s = 0; - while (isspace(*++s)); - } else - s = buf + strlen(buf); - strscpy(cmd, buf, sizeof(cmd)); - ac = split_buf(s, &av, 1); + int retVal = 0; + Message *current = NULL; + char source[64]; + char cmd[64]; + char buf[512]; /* Longest legal IRC command line */ + char *s; + int ac; /* Parameters for the command */ + const 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) { + 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)); + + doCleanBuffer((char *) buf); + + /* Split the buffer into pieces. */ + if (*buf == ':') { + s = strpbrk(buf, " "); + if (!s) + return; + *s = 0; + while (isspace(*++s)); + strscpy(source, buf + 1, sizeof(source)); + memmove(buf, s, strlen(s) + 1); + } else { + *source = 0; + } + if (!*buf) + return; + s = strpbrk(buf, " "); + if (s) { + *s = 0; + while (isspace(*++s)); + } else + s = buf + strlen(buf); + strscpy(cmd, buf, sizeof(cmd)); + ac = split_buf(s, &av, 1); if (protocoldebug) { @@ -389,46 +389,46 @@ void process() alog("debug: av[0] = NULL"); } - if (mod_current_buffer) { - free(mod_current_buffer); - } - - if (ac >= 1) { - if (nickIsServices(av[0], 1)) { - mod_current_buffer = - (ac > 1 ? sstrdup(av[1]) : sstrdup(av[0])); - } else { - mod_current_buffer = - (ac > 1 ? sstrdup(av[1]) : sstrdup(av[0])); - } - } else { - mod_current_buffer = NULL; - } - - /* Do something with the message. */ - m = find_message(cmd); - if (m) { - if (m->func) { - mod_current_module_name = m->mod_name; - retVal = m->func(source, ac, av); - mod_current_module_name = NULL; - if (retVal == MOD_CONT) { - current = m->next; - while (current && current->func && retVal == MOD_CONT) { - mod_current_module_name = current->mod_name; - retVal = current->func(source, ac, av); - mod_current_module_name = NULL; - current = current->next; - } - } - } - } else { - if (debug) - alog("debug: unknown message from server (%s)", inbuf); - } - - /* Free argument list we created */ - free(av); + if (mod_current_buffer) { + free(mod_current_buffer); + } + + if (ac >= 1) { + if (nickIsServices(av[0], 1)) { + mod_current_buffer = + (ac > 1 ? sstrdup(av[1]) : sstrdup(av[0])); + } else { + mod_current_buffer = + (ac > 1 ? sstrdup(av[1]) : sstrdup(av[0])); + } + } else { + mod_current_buffer = NULL; + } + + /* Do something with the message. */ + m = find_message(cmd); + if (m) { + if (m->func) { + mod_current_module_name = m->mod_name; + retVal = m->func(source, ac, av); + mod_current_module_name = NULL; + if (retVal == MOD_CONT) { + current = m->next; + while (current && current->func && retVal == MOD_CONT) { + mod_current_module_name = current->mod_name; + retVal = current->func(source, ac, av); + mod_current_module_name = NULL; + current = current->next; + } + } + } + } else { + if (debug) + alog("debug: unknown message from server (%s)", inbuf); + } + + /* Free argument list we created */ + free(av); } /*************************************************************************/ diff --git a/src/protocol/bahamut.c b/src/protocol/bahamut.c index d512f93c8..d26379aa9 100644 --- a/src/protocol/bahamut.c +++ b/src/protocol/bahamut.c @@ -55,415 +55,415 @@ #define CMODE_R 0x00000100 /* Only identified users can join */ #define CMODE_r 0x00000200 /* Set for all registered channels */ #define CMODE_c 0x00000400 /* Colors can't be used */ -#define CMODE_M 0x00000800 /* Non-regged nicks can't send messages */ -#define CMODE_j 0x00001000 /* join throttle */ +#define CMODE_M 0x00000800 /* Non-regged nicks can't send messages */ +#define CMODE_j 0x00001000 /* join throttle */ #define CMODE_O 0x00008000 /* Only opers can join */ #define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r IRCDVar myIrcd[] = { - {"Bahamut 1.8.x", /* ircd name */ - "+", /* Modes used by pseudoclients */ - 2, /* Chan Max Symbols */ - "-cilmnpstOR", /* Modes to Remove */ - "+o", /* Channel Umode used by Botserv bots */ - 1, /* SVSNICK */ - 0, /* Vhost */ - 0, /* Has Owner */ - NULL, /* Mode to set for an owner */ - NULL, /* Mode to unset for an owner */ - NULL, /* Mode to set for channel admin */ - NULL, /* Mode to unset for channel admin */ - "+rd", /* Mode On Reg */ - NULL, /* Mode on ID for Roots */ - NULL, /* Mode on ID for Admins */ - NULL, /* Mode on ID for Opers */ - "-r+d", /* Mode on UnReg */ - "+d", /* Mode on Nick Change */ - 1, /* Supports SGlines */ - 1, /* Supports SQlines */ - 1, /* Supports SZlines */ - 0, /* Supports Halfop +h */ - 3, /* Number of server args */ - 0, /* Join 2 Set */ - 0, /* Join 2 Message */ - 1, /* Has exceptions +e */ - 0, /* TS Topic Forward */ - 0, /* TS Topci Backward */ - 0, /* Protected Umode */ - 0, /* Has Admin */ - 1, /* Chan SQlines */ - 1, /* Quit on Kill */ - 1, /* SVSMODE unban */ - 0, /* Has Protect */ - 0, /* Reverse */ - 1, /* Chan Reg */ - CMODE_r, /* Channel Mode */ - 0, /* vidents */ - 1, /* svshold */ - 1, /* time stamp on mode */ - 1, /* NICKIP */ - 0, /* O:LINE */ - 1, /* UMODE */ - 0, /* VHOST ON NICK */ - 0, /* Change RealName */ - 0, /* No Knock */ - 0, /* Admin Only */ - DEFAULT_MLOCK, /* Default MLOCK */ - 0, /* Vhost Mode */ - 1, /* +f */ - 0, /* +L */ - CMODE_j, /* Mode */ - 0, /* Mode */ - 1, - 1, /* No Knock requires +i */ - NULL, /* CAPAB Chan Modes */ - 0, /* We support TOKENS */ - 0, /* TIME STAMPS are BASE64 */ - 1, /* +I support */ - 0, /* SJOIN ban char */ - 0, /* SJOIN except char */ - 0, /* SJOIN invite char */ - 0, /* Can remove User Channel Modes with SVSMODE */ - 0, /* Sglines are not enforced until user reconnects */ - NULL, /* vhost char */ - 0, /* ts6 */ - 1, /* support helper umode */ - 0, /* p10 */ - NULL, /* character set */ - 1, /* reports sync state */ - 0, /* CIDR channelbans */ - "$", /* TLD Prefix for Global */ - } - , - {NULL} + {"Bahamut 1.8.x", /* ircd name */ + "+", /* Modes used by pseudoclients */ + 2, /* Chan Max Symbols */ + "-cilmnpstOR", /* Modes to Remove */ + "+o", /* Channel Umode used by Botserv bots */ + 1, /* SVSNICK */ + 0, /* Vhost */ + 0, /* Has Owner */ + NULL, /* Mode to set for an owner */ + NULL, /* Mode to unset for an owner */ + NULL, /* Mode to set for channel admin */ + NULL, /* Mode to unset for channel admin */ + "+rd", /* Mode On Reg */ + NULL, /* Mode on ID for Roots */ + NULL, /* Mode on ID for Admins */ + NULL, /* Mode on ID for Opers */ + "-r+d", /* Mode on UnReg */ + "+d", /* Mode on Nick Change */ + 1, /* Supports SGlines */ + 1, /* Supports SQlines */ + 1, /* Supports SZlines */ + 0, /* Supports Halfop +h */ + 3, /* Number of server args */ + 0, /* Join 2 Set */ + 0, /* Join 2 Message */ + 1, /* Has exceptions +e */ + 0, /* TS Topic Forward */ + 0, /* TS Topci Backward */ + 0, /* Protected Umode */ + 0, /* Has Admin */ + 1, /* Chan SQlines */ + 1, /* Quit on Kill */ + 1, /* SVSMODE unban */ + 0, /* Has Protect */ + 0, /* Reverse */ + 1, /* Chan Reg */ + CMODE_r, /* Channel Mode */ + 0, /* vidents */ + 1, /* svshold */ + 1, /* time stamp on mode */ + 1, /* NICKIP */ + 0, /* O:LINE */ + 1, /* UMODE */ + 0, /* VHOST ON NICK */ + 0, /* Change RealName */ + 0, /* No Knock */ + 0, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + 0, /* Vhost Mode */ + 1, /* +f */ + 0, /* +L */ + CMODE_j, /* Mode */ + 0, /* Mode */ + 1, + 1, /* No Knock requires +i */ + NULL, /* CAPAB Chan Modes */ + 0, /* We support TOKENS */ + 0, /* TIME STAMPS are BASE64 */ + 1, /* +I support */ + 0, /* SJOIN ban char */ + 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ + 0, /* Can remove User Channel Modes with SVSMODE */ + 0, /* Sglines are not enforced until user reconnects */ + NULL, /* vhost char */ + 0, /* ts6 */ + 1, /* support helper umode */ + 0, /* p10 */ + NULL, /* character set */ + 1, /* reports sync state */ + 0, /* CIDR channelbans */ + "$", /* TLD Prefix for Global */ + } + , + {NULL} }; IRCDCAPAB myIrcdcap[] = { - { - CAPAB_NOQUIT, /* NOQUIT */ - CAPAB_TSMODE, /* TSMODE */ - CAPAB_UNCONNECT, /* UNCONNECT */ - 0, /* NICKIP */ - 0, /* SJOIN */ - 0, /* ZIP */ - CAPAB_BURST, /* BURST */ - 0, /* TS5 */ - 0, /* TS3 */ - CAPAB_DKEY, /* DKEY */ - 0, /* PT4 */ - 0, /* SCS */ - 0, /* QS */ - 0, /* UID */ - 0, /* KNOCK */ - 0, /* CLIENT */ - 0, /* IPV6 */ - 0, /* SSJ5 */ - 0, /* SN2 */ - 0, /* TOKEN */ - 0, /* VHOST */ - 0, /* SSJ3 */ - 0, /* NICK2 */ - 0, /* UMODE2 */ - 0, /* VL */ - 0, /* TLKEXT */ - 0, /* DODKEY */ - CAPAB_DOZIP, /* DOZIP */ - 0, 0, 0} + { + CAPAB_NOQUIT, /* NOQUIT */ + CAPAB_TSMODE, /* TSMODE */ + CAPAB_UNCONNECT, /* UNCONNECT */ + 0, /* NICKIP */ + 0, /* SJOIN */ + 0, /* ZIP */ + CAPAB_BURST, /* BURST */ + 0, /* TS5 */ + 0, /* TS3 */ + CAPAB_DKEY, /* DKEY */ + 0, /* PT4 */ + 0, /* SCS */ + 0, /* QS */ + 0, /* UID */ + 0, /* KNOCK */ + 0, /* CLIENT */ + 0, /* IPV6 */ + 0, /* SSJ5 */ + 0, /* SN2 */ + 0, /* TOKEN */ + 0, /* VHOST */ + 0, /* SSJ3 */ + 0, /* NICK2 */ + 0, /* UMODE2 */ + 0, /* VL */ + 0, /* TLKEXT */ + 0, /* DODKEY */ + CAPAB_DOZIP, /* DOZIP */ + 0, 0, 0} }; unsigned long umodes[128] = { - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused, Unused, Horzontal Tab */ - 0, 0, 0, /* Line Feed, Unused, Unused */ - 0, 0, 0, /* Carriage Return, Unused, Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused, Unused, Space */ - 0, 0, 0, /* ! " # */ - 0, 0, 0, /* $ % & */ - 0, 0, 0, /* ! ( ) */ - 0, 0, 0, /* * + , */ - 0, 0, 0, /* - . / */ - 0, 0, /* 0 1 */ - 0, 0, /* 2 3 */ - 0, 0, /* 4 5 */ - 0, 0, /* 6 7 */ - 0, 0, /* 8 9 */ - 0, 0, /* : ; */ - 0, 0, 0, /* < = > */ - 0, 0, /* ? @ */ - UMODE_A, 0, 0, /* A B C */ - UMODE_D, 0, UMODE_F, /* D E F */ - 0, 0, UMODE_I, /* G H I */ - 0, UMODE_K, 0, /* J K L */ - 0, 0, UMODE_O, /* M N O */ - 0, 0, UMODE_R, /* P Q R */ - 0, 0, 0, /* S T U */ - 0, 0, UMODE_X, /* V W X */ - 0, /* Y */ - 0, /* Z */ - 0, 0, 0, /* [ \ ] */ - 0, 0, 0, /* ^ _ ` */ - UMODE_a, UMODE_b, UMODE_c, /* a b c */ - UMODE_d, UMODE_e, UMODE_f, /* d e f */ - UMODE_g, UMODE_h, UMODE_i, /* g h i */ - UMODE_j, UMODE_k, 0, /* j k l */ - UMODE_m, UMODE_n, UMODE_o, /* m n o */ - 0, 0, UMODE_r, /* p q r */ - UMODE_s, 0, 0, /* s t u */ - 0, UMODE_w, UMODE_x, /* v w x */ - UMODE_y, /* y */ - 0, /* z */ - 0, 0, 0, /* { | } */ - 0, 0 /* ~ � */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused, Unused, Horzontal Tab */ + 0, 0, 0, /* Line Feed, Unused, Unused */ + 0, 0, 0, /* Carriage Return, Unused, Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused, Unused, Space */ + 0, 0, 0, /* ! " # */ + 0, 0, 0, /* $ % & */ + 0, 0, 0, /* ! ( ) */ + 0, 0, 0, /* * + , */ + 0, 0, 0, /* - . / */ + 0, 0, /* 0 1 */ + 0, 0, /* 2 3 */ + 0, 0, /* 4 5 */ + 0, 0, /* 6 7 */ + 0, 0, /* 8 9 */ + 0, 0, /* : ; */ + 0, 0, 0, /* < = > */ + 0, 0, /* ? @ */ + UMODE_A, 0, 0, /* A B C */ + UMODE_D, 0, UMODE_F, /* D E F */ + 0, 0, UMODE_I, /* G H I */ + 0, UMODE_K, 0, /* J K L */ + 0, 0, UMODE_O, /* M N O */ + 0, 0, UMODE_R, /* P Q R */ + 0, 0, 0, /* S T U */ + 0, 0, UMODE_X, /* V W X */ + 0, /* Y */ + 0, /* Z */ + 0, 0, 0, /* [ \ ] */ + 0, 0, 0, /* ^ _ ` */ + UMODE_a, UMODE_b, UMODE_c, /* a b c */ + UMODE_d, UMODE_e, UMODE_f, /* d e f */ + UMODE_g, UMODE_h, UMODE_i, /* g h i */ + UMODE_j, UMODE_k, 0, /* j k l */ + UMODE_m, UMODE_n, UMODE_o, /* m n o */ + 0, 0, UMODE_r, /* p q r */ + UMODE_s, 0, 0, /* s t u */ + 0, UMODE_w, UMODE_x, /* v w x */ + UMODE_y, /* y */ + 0, /* z */ + 0, 0, 0, /* { | } */ + 0, 0 /* ~ � */ }; char myCsmodes[128] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, 0, 0, - 0, - 0, 0, 0, 0, - 0, + 0, + 0, + 0, 0, 0, + 0, + 0, 0, 0, 0, + 0, - 'v', 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'v', 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; CMMode myCmmodes[128] = { - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, /* BCD */ - {NULL}, {NULL}, {NULL}, /* EFG */ - {NULL}, /* H */ - {add_invite, del_invite}, /* I */ - {NULL}, /* J */ - {NULL}, {NULL}, {NULL}, /* KLM */ - {NULL}, {NULL}, {NULL}, /* NOP */ - {NULL}, {NULL}, {NULL}, /* QRS */ - {NULL}, {NULL}, {NULL}, /* TUV */ - {NULL}, {NULL}, {NULL}, /* WXY */ - {NULL}, /* Z */ - {NULL}, {NULL}, /* (char 91 - 92) */ - {NULL}, {NULL}, {NULL}, /* (char 93 - 95) */ - {NULL}, /* ` (char 96) */ - {NULL}, /* a (char 97) */ - {add_ban, del_ban}, /* b */ - {NULL}, {NULL}, /* cd */ - {add_exception, del_exception}, - {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, /* BCD */ + {NULL}, {NULL}, {NULL}, /* EFG */ + {NULL}, /* H */ + {add_invite, del_invite}, /* I */ + {NULL}, /* J */ + {NULL}, {NULL}, {NULL}, /* KLM */ + {NULL}, {NULL}, {NULL}, /* NOP */ + {NULL}, {NULL}, {NULL}, /* QRS */ + {NULL}, {NULL}, {NULL}, /* TUV */ + {NULL}, {NULL}, {NULL}, /* WXY */ + {NULL}, /* Z */ + {NULL}, {NULL}, /* (char 91 - 92) */ + {NULL}, {NULL}, {NULL}, /* (char 93 - 95) */ + {NULL}, /* ` (char 96) */ + {NULL}, /* a (char 97) */ + {add_ban, del_ban}, /* b */ + {NULL}, {NULL}, /* cd */ + {add_exception, del_exception}, + {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} }; CBMode myCbmodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, - {0}, /* A */ - {0}, /* B */ - {0}, /* C */ - {0}, /* D */ - {0}, /* E */ - {0}, /* F */ - {0}, /* G */ - {0}, /* H */ - {0}, /* I */ - {0}, /* J */ - {0}, /* K */ - {0}, /* L */ - {CMODE_M, 0, NULL, NULL}, /* M */ - {0}, /* N */ - {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, - {0}, /* P */ - {0}, /* Q */ - {CMODE_R, 0, NULL, NULL}, /* R */ - {0}, /* S */ - {0}, /* T */ - {0}, /* U */ - {0}, /* V */ - {0}, /* W */ - {0}, /* X */ - {0}, /* Y */ - {0}, /* Z */ - {0}, {0}, {0}, {0}, {0}, {0}, - {0}, /* a */ - {0}, /* b */ - {CMODE_c, 0, NULL, NULL}, - {0}, /* d */ - {0}, /* e */ - {0}, /* f */ - {0}, /* g */ - {0}, /* h */ - {CMODE_i, 0, NULL, NULL}, - {CMODE_j, 0, set_flood, cs_set_flood}, /* j */ - {CMODE_k, 0, chan_set_key, cs_set_key}, - {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, - {CMODE_m, 0, NULL, NULL}, - {CMODE_n, 0, NULL, NULL}, - {0}, /* o */ - {CMODE_p, 0, NULL, NULL}, - {0}, /* q */ - {CMODE_r, CBM_NO_MLOCK, NULL, NULL}, - {CMODE_s, 0, NULL, NULL}, - {CMODE_t, 0, NULL, NULL}, - {0}, - {0}, /* v */ - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {0}, /* z */ - {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, + {0}, /* A */ + {0}, /* B */ + {0}, /* C */ + {0}, /* D */ + {0}, /* E */ + {0}, /* F */ + {0}, /* G */ + {0}, /* H */ + {0}, /* I */ + {0}, /* J */ + {0}, /* K */ + {0}, /* L */ + {CMODE_M, 0, NULL, NULL}, /* M */ + {0}, /* N */ + {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* P */ + {0}, /* Q */ + {CMODE_R, 0, NULL, NULL}, /* R */ + {0}, /* S */ + {0}, /* T */ + {0}, /* U */ + {0}, /* V */ + {0}, /* W */ + {0}, /* X */ + {0}, /* Y */ + {0}, /* Z */ + {0}, {0}, {0}, {0}, {0}, {0}, + {0}, /* a */ + {0}, /* b */ + {CMODE_c, 0, NULL, NULL}, + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {0}, /* h */ + {CMODE_i, 0, NULL, NULL}, + {CMODE_j, 0, set_flood, cs_set_flood}, /* j */ + {CMODE_k, 0, chan_set_key, cs_set_key}, + {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, + {CMODE_m, 0, NULL, NULL}, + {CMODE_n, 0, NULL, NULL}, + {0}, /* o */ + {CMODE_p, 0, NULL, NULL}, + {0}, /* q */ + {CMODE_r, CBM_NO_MLOCK, NULL, NULL}, + {CMODE_s, 0, NULL, NULL}, + {CMODE_t, 0, NULL, NULL}, + {0}, + {0}, /* v */ + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0} }; CBModeInfo myCbmodeinfos[] = { - {'c', CMODE_c, 0, NULL, NULL}, - {'i', CMODE_i, 0, NULL, NULL}, - {'j', CMODE_j, 0, get_flood, cs_get_flood}, - {'k', CMODE_k, 0, get_key, cs_get_key}, - {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, - {'m', CMODE_m, 0, NULL, NULL}, - {'n', CMODE_n, 0, NULL, NULL}, - {'p', CMODE_p, 0, NULL, NULL}, - {'r', CMODE_r, 0, NULL, NULL}, - {'s', CMODE_s, 0, NULL, NULL}, - {'t', CMODE_t, 0, NULL, NULL}, - {'M', CMODE_M, 0, NULL, NULL}, - {'O', CMODE_O, 0, NULL, NULL}, - {'R', CMODE_R, 0, NULL, NULL}, - {0} + {'c', CMODE_c, 0, NULL, NULL}, + {'i', CMODE_i, 0, NULL, NULL}, + {'j', CMODE_j, 0, get_flood, cs_get_flood}, + {'k', CMODE_k, 0, get_key, cs_get_key}, + {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, + {'m', CMODE_m, 0, NULL, NULL}, + {'n', CMODE_n, 0, NULL, NULL}, + {'p', CMODE_p, 0, NULL, NULL}, + {'r', CMODE_r, 0, NULL, NULL}, + {'s', CMODE_s, 0, NULL, NULL}, + {'t', CMODE_t, 0, NULL, NULL}, + {'M', CMODE_M, 0, NULL, NULL}, + {'O', CMODE_O, 0, NULL, NULL}, + {'R', CMODE_R, 0, NULL, NULL}, + {0} }; CUMode myCumodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, - {0}, /* a */ - {0}, /* b */ - {0}, /* c */ - {0}, /* d */ - {0}, /* e */ - {0}, /* f */ - {0}, /* g */ - {0}, /* h */ - {0}, /* i */ - {0}, /* j */ - {0}, /* k */ - {0}, /* l */ - {0}, /* m */ - {0}, /* n */ - {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, - {0}, /* p */ - {0}, /* q */ - {0}, /* r */ - {0}, /* s */ - {0}, /* t */ - {0}, /* u */ - {CUS_VOICE, 0, NULL}, - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {0}, /* z */ - {0}, {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, + {0}, /* a */ + {0}, /* b */ + {0}, /* c */ + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {0}, /* h */ + {0}, /* i */ + {0}, /* j */ + {0}, /* k */ + {0}, /* l */ + {0}, /* m */ + {0}, /* n */ + {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, + {0}, /* p */ + {0}, /* q */ + {0}, /* r */ + {0}, /* s */ + {0}, /* t */ + {0}, /* u */ + {CUS_VOICE, 0, NULL}, + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0}, {0} }; void bahamut_cmd_burst() { - send_cmd(NULL, "BURST"); + send_cmd(NULL, "BURST"); } /* * SVINFO - * parv[0] = sender prefix - * parv[1] = TS_CURRENT for the server - * parv[2] = TS_MIN for the server - * parv[3] = server is standalone or connected to non-TS only - * parv[4] = server's idea of UTC time + * parv[0] = sender prefix + * parv[1] = TS_CURRENT for the server + * parv[2] = TS_MIN for the server + * parv[3] = server is standalone or connected to non-TS only + * parv[4] = server's idea of UTC time */ void bahamut_cmd_svinfo() { - send_cmd(NULL, "SVINFO 3 1 0 :%ld", (long int) time(NULL)); + send_cmd(NULL, "SVINFO 3 1 0 :%ld", (long int) time(NULL)); } /* PASS */ void bahamut_cmd_pass(const char *pass) { - send_cmd(NULL, "PASS %s :TS", pass); + send_cmd(NULL, "PASS %s :TS", pass); } /* CAPAB */ void bahamut_cmd_capab() { - send_cmd(NULL, - "CAPAB SSJOIN NOQUIT BURST UNCONNECT NICKIP TSMODE TS3"); + send_cmd(NULL, + "CAPAB SSJOIN NOQUIT BURST UNCONNECT NICKIP TSMODE TS3"); } /* this avoids "undefined symbol" messages of those whom try to load mods that call on this function */ void bahamut_cmd_chghost(const char *nick, const char *vhost) { - if (debug) { - alog("debug: This IRCD does not support vhosting"); - } + if (debug) { + alog("debug: This IRCD does not support vhosting"); + } } @@ -742,301 +742,301 @@ class BahamutIRCdProto : public IRCDProto /* EVENT: SJOIN */ int anope_event_sjoin(const char *source, int ac, const char **av) { - do_sjoin(source, ac, av); - return MOD_CONT; + do_sjoin(source, ac, av); + return MOD_CONT; } /* ** NICK - new -** source = NULL +** source = NULL ** parv[0] = nickname -** parv[1] = hopcount -** parv[2] = timestamp -** parv[3] = modes -** parv[4] = username -** parv[5] = hostname -** parv[6] = server +** parv[1] = hopcount +** parv[2] = timestamp +** parv[3] = modes +** parv[4] = username +** parv[5] = hostname +** parv[6] = server ** parv[7] = servicestamp -** parv[8] = IP +** parv[8] = IP ** parv[9] = info ** NICK - change -** source = oldnick +** source = oldnick ** parv[0] = new nickname -** parv[1] = hopcount +** parv[1] = hopcount */ int anope_event_nick(const char *source, int ac, const char **av) { - User *user; - - if (ac != 2) { - user = do_nick(source, av[0], av[4], av[5], av[6], av[9], - strtoul(av[2], NULL, 10), strtoul(av[7], NULL, 0), - strtoul(av[8], NULL, 0), NULL, NULL); - if (user) { - ircdproto->ProcessUsermodes(user, 1, &av[3]); - } - } else { - do_nick(source, av[0], NULL, NULL, NULL, NULL, - strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); - } - return MOD_CONT; + User *user; + + if (ac != 2) { + user = do_nick(source, av[0], av[4], av[5], av[6], av[9], + strtoul(av[2], NULL, 10), strtoul(av[7], NULL, 0), + strtoul(av[8], NULL, 0), NULL, NULL); + if (user) { + ircdproto->ProcessUsermodes(user, 1, &av[3]); + } + } else { + do_nick(source, av[0], NULL, NULL, NULL, NULL, + strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); + } + return MOD_CONT; } /* EVENT : CAPAB */ int anope_event_capab(const char *source, int ac, const char **av) { - capab_parse(ac, av); - return MOD_CONT; + capab_parse(ac, av); + return MOD_CONT; } /* EVENT : OS */ int anope_event_os(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_OperServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_OperServ, av[0]); + return MOD_CONT; } /* EVENT : NS */ int anope_event_ns(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_NickServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_NickServ, av[0]); + return MOD_CONT; } /* EVENT : MS */ int anope_event_ms(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_MemoServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_MemoServ, av[0]); + return MOD_CONT; } /* EVENT : HS */ int anope_event_hs(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_HostServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_HostServ, av[0]); + return MOD_CONT; } /* EVENT : CS */ int anope_event_cs(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_ChanServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_ChanServ, av[0]); + return MOD_CONT; } int anope_event_436(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; + if (ac < 1) + return MOD_CONT; - m_nickcoll(av[0]); - return MOD_CONT; + m_nickcoll(av[0]); + return MOD_CONT; } /* EVENT : SERVER */ int anope_event_server(const char *source, int ac, const char **av) { - if (!stricmp(av[1], "1")) { - uplink = sstrdup(av[0]); - } + if (!stricmp(av[1], "1")) { + uplink = sstrdup(av[0]); + } - do_server(source, av[0], av[1], av[2], NULL); - return MOD_CONT; + do_server(source, av[0], av[1], av[2], NULL); + return MOD_CONT; } /* EVENT : PRIVMSG */ int anope_event_privmsg(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; - m_privmsg(source, av[0], av[1]); - return MOD_CONT; + if (ac != 2) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; } int anope_event_part(const char *source, int ac, const char **av) { - if (ac < 1 || ac > 2) - return MOD_CONT; - do_part(source, ac, av); - return MOD_CONT; + if (ac < 1 || ac > 2) + return MOD_CONT; + do_part(source, ac, av); + return MOD_CONT; } int anope_event_whois(const char *source, int ac, const char **av) { - if (source && ac >= 1) { - m_whois(source, av[0]); - } - return MOD_CONT; + if (source && ac >= 1) { + m_whois(source, av[0]); + } + return MOD_CONT; } int anope_event_topic(const char *source, int ac, const char **av) { - if (ac != 4) - return MOD_CONT; - do_topic(source, ac, av); - return MOD_CONT; + if (ac != 4) + return MOD_CONT; + do_topic(source, ac, av); + return MOD_CONT; } int anope_event_squit(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; - do_squit(source, ac, av); - return MOD_CONT; + if (ac != 2) + return MOD_CONT; + do_squit(source, ac, av); + return MOD_CONT; } int anope_event_quit(const char *source, int ac, const char **av) { - if (ac != 1) - return MOD_CONT; - do_quit(source, ac, av); - return MOD_CONT; + if (ac != 1) + return MOD_CONT; + do_quit(source, ac, av); + return MOD_CONT; } /* EVENT: MODE */ int anope_event_mode(const char *source, int ac, const char **av) { - if (ac < 2) - return MOD_CONT; - - if (*av[0] == '#' || *av[0] == '&') { - do_cmode(source, ac, av); - } else { - do_umode(source, ac, av); - } - return MOD_CONT; + if (ac < 2) + return MOD_CONT; + + if (*av[0] == '#' || *av[0] == '&') { + do_cmode(source, ac, av); + } else { + do_umode(source, ac, av); + } + return MOD_CONT; } /* EVENT: KILL */ int anope_event_kill(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - m_kill(av[0], av[1]); - return MOD_CONT; + m_kill(av[0], av[1]); + return MOD_CONT; } /* EVENT: KICK */ int anope_event_kick(const char *source, int ac, const char **av) { - if (ac != 3) - return MOD_CONT; - do_kick(source, ac, av); - return MOD_CONT; + if (ac != 3) + return MOD_CONT; + do_kick(source, ac, av); + return MOD_CONT; } /* EVENT: JOIN */ int anope_event_join(const char *source, int ac, const char **av) { - if (ac != 1) - return MOD_CONT; - do_join(source, ac, av); - return MOD_CONT; + if (ac != 1) + return MOD_CONT; + do_join(source, ac, av); + return MOD_CONT; } /* EVENT: MOTD */ int anope_event_motd(const char *source, int ac, const char **av) { - if (!source) { - return MOD_CONT; - } + if (!source) { + return MOD_CONT; + } - m_motd(source); - return MOD_CONT; + m_motd(source); + return MOD_CONT; } int anope_event_away(const char *source, int ac, const char **av) { - if (!source) { - return MOD_CONT; - } - m_away(source, (ac ? av[0] : NULL)); - return MOD_CONT; + if (!source) { + return MOD_CONT; + } + m_away(source, (ac ? av[0] : NULL)); + return MOD_CONT; } int anope_event_ping(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - ircdproto->SendPong(ac > 1 ? av[1] : ServerName, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + ircdproto->SendPong(ac > 1 ? av[1] : ServerName, av[0]); + return MOD_CONT; } int anope_event_error(const char *source, int ac, const char **av) { - if (ac >= 1) { - if (debug) { - alog("debug: %s", av[0]); - } - } - return MOD_CONT; + if (ac >= 1) { + if (debug) { + alog("debug: %s", av[0]); + } + } + return MOD_CONT; } int anope_event_burst(const char *source, int ac, const char **av) { - Server *s; - s = findserver(servlist, source); - if (!ac) { - /* for future use - start burst */ - } else { - /* If we found a server with the given source, that one just - * finished bursting. If there was no source, then our uplink - * server finished bursting. -GD - */ - if (!s && serv_uplink) - s = serv_uplink; - finish_sync(s, 1); - } - return MOD_CONT; + Server *s; + s = findserver(servlist, source); + if (!ac) { + /* for future use - start burst */ + } else { + /* If we found a server with the given source, that one just + * finished bursting. If there was no source, then our uplink + * server finished bursting. -GD + */ + if (!s && serv_uplink) + s = serv_uplink; + finish_sync(s, 1); + } + return MOD_CONT; } /* *INDENT-OFF* */ void moduleAddIRCDMsgs(void) { - Message *m; - - - /* first update the cs protect info about this ircd */ - updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+","-"); - - /* now add the commands */ - m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); - m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); - m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); - m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); - m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); - m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); - m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); - m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); - m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); - m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); - m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); - m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); - m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); - m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); - m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); - m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); - m = createMessage("SVSMODE", anope_event_mode); addCoreMessage(IRCD,m); - m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); - m = createMessage("CS", anope_event_cs); addCoreMessage(IRCD,m); - m = createMessage("HS", anope_event_hs); addCoreMessage(IRCD,m); - m = createMessage("MS", anope_event_ms); addCoreMessage(IRCD,m); - m = createMessage("NS", anope_event_ns); addCoreMessage(IRCD,m); - m = createMessage("OS", anope_event_os); addCoreMessage(IRCD,m); - m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); - m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m); - m = createMessage("BURST", anope_event_burst); addCoreMessage(IRCD,m); + Message *m; + + + /* first update the cs protect info about this ircd */ + updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+","-"); + + /* now add the commands */ + m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); + m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); + m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); + m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); + m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); + m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); + m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); + m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); + m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); + m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); + m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); + m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); + m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); + m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); + m = createMessage("SVSMODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); + m = createMessage("CS", anope_event_cs); addCoreMessage(IRCD,m); + m = createMessage("HS", anope_event_hs); addCoreMessage(IRCD,m); + m = createMessage("MS", anope_event_ms); addCoreMessage(IRCD,m); + m = createMessage("NS", anope_event_ns); addCoreMessage(IRCD,m); + m = createMessage("OS", anope_event_os); addCoreMessage(IRCD,m); + m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); + m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m); + m = createMessage("BURST", anope_event_burst); addCoreMessage(IRCD,m); } /* *INDENT-ON* */ diff --git a/src/protocol/charybdis.c b/src/protocol/charybdis.c index 7c34f3de3..cee42ce1c 100644 --- a/src/protocol/charybdis.c +++ b/src/protocol/charybdis.c @@ -49,373 +49,373 @@ #define DEFAULT_MLOCK CMODE_n | CMODE_t IRCDVar myIrcd[] = { - {"Charybdis 1.0+", /* ircd name */ - "+oiS", /* Modes used by pseudoclients */ - 2, /* Chan Max Symbols */ - "-cilmnpstrgzQF", /* Modes to Remove */ - "+o", /* Channel Umode used by Botserv bots */ - 1, /* SVSNICK */ - 1, /* Vhost */ - 0, /* Has Owner */ - NULL, /* Mode to set for an owner */ - NULL, /* Mode to unset for an owner */ - NULL, /* Mode to set for chan admin */ - NULL, /* Mode to unset for chan admin */ - NULL, /* Mode On Reg */ - NULL, /* Mode on ID for Roots */ - NULL, /* Mode on ID for Admins */ - NULL, /* Mode on ID for Opers */ - NULL, /* Mode on UnReg */ - NULL, /* Mode on Nick Change */ - 1, /* Supports SGlines */ - 1, /* Supports SQlines */ - 1, /* Supports SZlines */ - 0, /* Supports Halfop +h */ - 3, /* Number of server args */ - 1, /* Join 2 Set */ - 1, /* Join 2 Message */ - 1, /* Has exceptions +e */ - 0, /* TS Topic Forward */ - 0, /* TS Topci Backward */ - 0, /* Protected Umode */ - 0, /* Has Admin */ - 1, /* Chan SQlines */ - 0, /* Quit on Kill */ - 0, /* SVSMODE unban */ - 0, /* Has Protect */ - 0, /* Reverse */ - 0, /* Chan Reg */ - 0, /* Channel Mode */ - 0, /* vidents */ - 1, /* svshold */ - 0, /* time stamp on mode */ - 0, /* NICKIP */ - 0, /* UMODE */ - 0, /* O:LINE */ - 1, /* VHOST ON NICK */ - 0, /* Change RealName */ - CMODE_p, /* No Knock */ - 0, /* Admin Only */ - DEFAULT_MLOCK, /* Default MLOCK */ - 0, /* Vhost Mode */ - 1, /* +f */ - 1, /* +L */ - CMODE_j, /* +f Mode */ - CMODE_f, /* +L Mode (+f <target>) */ - 1, /* On nick change check if they could be identified */ - 0, /* No Knock requires +i */ - NULL, /* CAPAB Chan Modes */ - 0, /* We support TOKENS */ - 0, /* TIME STAMPS are BASE64 */ - 1, /* +I support */ - 0, /* SJOIN ban char */ - 0, /* SJOIN except char */ - 0, /* SJOIN invite char */ - 0, /* Can remove User Channel Modes with SVSMODE */ - 0, /* Sglines are not enforced until user reconnects */ - NULL, /* vhost char */ - 1, /* ts6 */ - 0, /* support helper umode */ - 0, /* p10 */ - NULL, /* character set */ - 0, /* reports sync state */ - 1, /* CIDR channelbans */ - "$$", /* TLD Prefix for Global */ - } - , - {NULL} + {"Charybdis 1.0+", /* ircd name */ + "+oiS", /* Modes used by pseudoclients */ + 2, /* Chan Max Symbols */ + "-cilmnpstrgzQF", /* Modes to Remove */ + "+o", /* Channel Umode used by Botserv bots */ + 1, /* SVSNICK */ + 1, /* Vhost */ + 0, /* Has Owner */ + NULL, /* Mode to set for an owner */ + NULL, /* Mode to unset for an owner */ + NULL, /* Mode to set for chan admin */ + NULL, /* Mode to unset for chan admin */ + NULL, /* Mode On Reg */ + NULL, /* Mode on ID for Roots */ + NULL, /* Mode on ID for Admins */ + NULL, /* Mode on ID for Opers */ + NULL, /* Mode on UnReg */ + NULL, /* Mode on Nick Change */ + 1, /* Supports SGlines */ + 1, /* Supports SQlines */ + 1, /* Supports SZlines */ + 0, /* Supports Halfop +h */ + 3, /* Number of server args */ + 1, /* Join 2 Set */ + 1, /* Join 2 Message */ + 1, /* Has exceptions +e */ + 0, /* TS Topic Forward */ + 0, /* TS Topci Backward */ + 0, /* Protected Umode */ + 0, /* Has Admin */ + 1, /* Chan SQlines */ + 0, /* Quit on Kill */ + 0, /* SVSMODE unban */ + 0, /* Has Protect */ + 0, /* Reverse */ + 0, /* Chan Reg */ + 0, /* Channel Mode */ + 0, /* vidents */ + 1, /* svshold */ + 0, /* time stamp on mode */ + 0, /* NICKIP */ + 0, /* UMODE */ + 0, /* O:LINE */ + 1, /* VHOST ON NICK */ + 0, /* Change RealName */ + CMODE_p, /* No Knock */ + 0, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + 0, /* Vhost Mode */ + 1, /* +f */ + 1, /* +L */ + CMODE_j, /* +f Mode */ + CMODE_f, /* +L Mode (+f <target>) */ + 1, /* On nick change check if they could be identified */ + 0, /* No Knock requires +i */ + NULL, /* CAPAB Chan Modes */ + 0, /* We support TOKENS */ + 0, /* TIME STAMPS are BASE64 */ + 1, /* +I support */ + 0, /* SJOIN ban char */ + 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ + 0, /* Can remove User Channel Modes with SVSMODE */ + 0, /* Sglines are not enforced until user reconnects */ + NULL, /* vhost char */ + 1, /* ts6 */ + 0, /* support helper umode */ + 0, /* p10 */ + NULL, /* character set */ + 0, /* reports sync state */ + 1, /* CIDR channelbans */ + "$$", /* TLD Prefix for Global */ + } + , + {NULL} }; IRCDCAPAB myIrcdcap[] = { - { - 0, /* NOQUIT */ - 0, /* TSMODE */ - 0, /* UNCONNECT */ - 0, /* NICKIP */ - 0, /* SJOIN */ - CAPAB_ZIP, /* ZIP */ - 0, /* BURST */ - CAPAB_TS5, /* TS5 */ - 0, /* TS3 */ - 0, /* DKEY */ - 0, /* PT4 */ - 0, /* SCS */ - CAPAB_QS, /* QS */ - CAPAB_UID, /* UID */ - CAPAB_KNOCK, /* KNOCK */ - 0, /* CLIENT */ - 0, /* IPV6 */ - 0, /* SSJ5 */ - 0, /* SN2 */ - 0, /* TOKEN */ - 0, /* VHOST */ - 0, /* SSJ3 */ - 0, /* NICK2 */ - 0, /* UMODE2 */ - 0, /* VL */ - 0, /* TLKEXT */ - 0, /* DODKEY */ - 0, /* DOZIP */ - 0, 0, 0} + { + 0, /* NOQUIT */ + 0, /* TSMODE */ + 0, /* UNCONNECT */ + 0, /* NICKIP */ + 0, /* SJOIN */ + CAPAB_ZIP, /* ZIP */ + 0, /* BURST */ + CAPAB_TS5, /* TS5 */ + 0, /* TS3 */ + 0, /* DKEY */ + 0, /* PT4 */ + 0, /* SCS */ + CAPAB_QS, /* QS */ + CAPAB_UID, /* UID */ + CAPAB_KNOCK, /* KNOCK */ + 0, /* CLIENT */ + 0, /* IPV6 */ + 0, /* SSJ5 */ + 0, /* SN2 */ + 0, /* TOKEN */ + 0, /* VHOST */ + 0, /* SSJ3 */ + 0, /* NICK2 */ + 0, /* UMODE2 */ + 0, /* VL */ + 0, /* TLKEXT */ + 0, /* DODKEY */ + 0, /* DOZIP */ + 0, 0, 0} }; unsigned long umodes[128] = { - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused, Unused, Horzontal Tab */ - 0, 0, 0, /* Line Feed, Unused, Unused */ - 0, 0, 0, /* Carriage Return, Unused, Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused, Unused, Space */ - 0, 0, 0, /* ! " # */ - 0, 0, 0, /* $ % & */ - 0, 0, 0, /* ! ( ) */ - 0, 0, 0, /* * + , */ - 0, 0, 0, /* - . / */ - 0, 0, /* 0 1 */ - 0, 0, /* 2 3 */ - 0, 0, /* 4 5 */ - 0, 0, /* 6 7 */ - 0, 0, /* 8 9 */ - 0, 0, /* : ; */ - 0, 0, 0, /* < = > */ - 0, 0, /* ? @ */ - 0, 0, 0, /* A B C */ - 0, 0, 0, /* D E F */ - 0, 0, 0, /* G H I */ - 0, 0, 0, /* J K L */ - 0, 0, 0, /* M N O */ - 0, UMODE_Q, UMODE_R, /* P Q R */ - UMODE_S, 0, 0, /* S T U */ - 0, 0, 0, /* V W X */ - 0, /* Y */ - 0, /* Z */ - 0, 0, 0, /* [ \ ] */ - 0, 0, 0, /* ^ _ ` */ - UMODE_a, 0, 0, /* a b c */ - 0, 0, 0, /* d e f */ - UMODE_g, 0, UMODE_i, /* g h i */ - 0, 0, UMODE_l, /* j k l */ - 0, 0, UMODE_o, /* m n o */ - 0, 0, 0, /* p q r */ - UMODE_s, 0, 0, /* s t u */ - 0, UMODE_w, 0, /* v w x */ - 0, /* y */ - UMODE_z, /* z */ - 0, 0, 0, /* { | } */ - 0, 0 /* ~ � */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused, Unused, Horzontal Tab */ + 0, 0, 0, /* Line Feed, Unused, Unused */ + 0, 0, 0, /* Carriage Return, Unused, Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused, Unused, Space */ + 0, 0, 0, /* ! " # */ + 0, 0, 0, /* $ % & */ + 0, 0, 0, /* ! ( ) */ + 0, 0, 0, /* * + , */ + 0, 0, 0, /* - . / */ + 0, 0, /* 0 1 */ + 0, 0, /* 2 3 */ + 0, 0, /* 4 5 */ + 0, 0, /* 6 7 */ + 0, 0, /* 8 9 */ + 0, 0, /* : ; */ + 0, 0, 0, /* < = > */ + 0, 0, /* ? @ */ + 0, 0, 0, /* A B C */ + 0, 0, 0, /* D E F */ + 0, 0, 0, /* G H I */ + 0, 0, 0, /* J K L */ + 0, 0, 0, /* M N O */ + 0, UMODE_Q, UMODE_R, /* P Q R */ + UMODE_S, 0, 0, /* S T U */ + 0, 0, 0, /* V W X */ + 0, /* Y */ + 0, /* Z */ + 0, 0, 0, /* [ \ ] */ + 0, 0, 0, /* ^ _ ` */ + UMODE_a, 0, 0, /* a b c */ + 0, 0, 0, /* d e f */ + UMODE_g, 0, UMODE_i, /* g h i */ + 0, 0, UMODE_l, /* j k l */ + 0, 0, UMODE_o, /* m n o */ + 0, 0, 0, /* p q r */ + UMODE_s, 0, 0, /* s t u */ + 0, UMODE_w, 0, /* v w x */ + 0, /* y */ + UMODE_z, /* z */ + 0, 0, 0, /* { | } */ + 0, 0 /* ~ � */ }; char myCsmodes[128] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, 0, 0, - 0, - 0, 0, 0, 0, - 0, + 0, + 0, + 0, 0, 0, + 0, + 0, 0, 0, 0, + 0, - 'v', 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'v', 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; CMMode myCmmodes[128] = { - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, /* BCD */ - {NULL}, {NULL}, {NULL}, /* EFG */ - {NULL}, /* H */ - {add_invite, del_invite}, - {NULL}, /* J */ - {NULL}, {NULL}, {NULL}, /* KLM */ - {NULL}, {NULL}, {NULL}, /* NOP */ - {NULL}, {NULL}, {NULL}, /* QRS */ - {NULL}, {NULL}, {NULL}, /* TUV */ - {NULL}, {NULL}, {NULL}, /* WXY */ - {NULL}, /* Z */ - {NULL}, {NULL}, /* (char 91 - 92) */ - {NULL}, {NULL}, {NULL}, /* (char 93 - 95) */ - {NULL}, /* ` (char 96) */ - {NULL}, /* a (char 97) */ - {add_ban, del_ban}, - {NULL}, - {NULL}, - {add_exception, del_exception}, - {NULL}, - {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, /* BCD */ + {NULL}, {NULL}, {NULL}, /* EFG */ + {NULL}, /* H */ + {add_invite, del_invite}, + {NULL}, /* J */ + {NULL}, {NULL}, {NULL}, /* KLM */ + {NULL}, {NULL}, {NULL}, /* NOP */ + {NULL}, {NULL}, {NULL}, /* QRS */ + {NULL}, {NULL}, {NULL}, /* TUV */ + {NULL}, {NULL}, {NULL}, /* WXY */ + {NULL}, /* Z */ + {NULL}, {NULL}, /* (char 91 - 92) */ + {NULL}, {NULL}, {NULL}, /* (char 93 - 95) */ + {NULL}, /* ` (char 96) */ + {NULL}, /* a (char 97) */ + {add_ban, del_ban}, + {NULL}, + {NULL}, + {add_exception, del_exception}, + {NULL}, + {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} }; CBMode myCbmodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, - {0}, /* A */ - {0}, /* B */ - {0}, /* C */ - {0}, /* D */ - {0}, /* E */ - {CMODE_F, 0, NULL, NULL}, /* F */ - {0}, /* G */ - {0}, /* H */ - {0}, /* I */ - {0}, /* J */ - {0}, /* K */ - {CMODE_L, CBM_NO_USER_MLOCK, NULL, NULL}, /* L */ - {0}, /* M */ - {0}, /* N */ - {0}, /* O */ - {CMODE_P, CBM_NO_USER_MLOCK, NULL, NULL}, /* P */ - {CMODE_Q, 0, NULL, NULL}, /* Q */ - {0}, /* R */ - {0}, /* S */ - {0}, /* T */ - {0}, /* U */ - {0}, /* V */ - {0}, /* W */ - {0}, /* X */ - {0}, /* Y */ - {0}, /* Z */ - {0}, {0}, {0}, {0}, {0}, {0}, - {0}, - {0}, /* b */ - {CMODE_c, 0, NULL, NULL}, /* c */ - {0}, /* d */ - {0}, /* e */ - {CMODE_f, 0, set_redirect, cs_set_redirect}, /* f */ - {CMODE_g, 0, NULL, NULL}, /* g */ - {0}, /* h */ - {CMODE_i, 0, NULL, NULL}, - {CMODE_j, 0, set_flood, cs_set_flood}, /* j */ - {CMODE_k, 0, chan_set_key, cs_set_key}, - {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, - {CMODE_m, 0, NULL, NULL}, - {CMODE_n, 0, NULL, NULL}, - {0}, /* o */ - {CMODE_p, 0, NULL, NULL}, - {0}, /* q */ - {CMODE_r, 0, NULL, NULL}, - {CMODE_s, 0, NULL, NULL}, - {CMODE_t, 0, NULL, NULL}, - {0}, - {0}, /* v */ - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {CMODE_z, 0, NULL, NULL}, /* z */ - {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, + {0}, /* A */ + {0}, /* B */ + {0}, /* C */ + {0}, /* D */ + {0}, /* E */ + {CMODE_F, 0, NULL, NULL}, /* F */ + {0}, /* G */ + {0}, /* H */ + {0}, /* I */ + {0}, /* J */ + {0}, /* K */ + {CMODE_L, CBM_NO_USER_MLOCK, NULL, NULL}, /* L */ + {0}, /* M */ + {0}, /* N */ + {0}, /* O */ + {CMODE_P, CBM_NO_USER_MLOCK, NULL, NULL}, /* P */ + {CMODE_Q, 0, NULL, NULL}, /* Q */ + {0}, /* R */ + {0}, /* S */ + {0}, /* T */ + {0}, /* U */ + {0}, /* V */ + {0}, /* W */ + {0}, /* X */ + {0}, /* Y */ + {0}, /* Z */ + {0}, {0}, {0}, {0}, {0}, {0}, + {0}, + {0}, /* b */ + {CMODE_c, 0, NULL, NULL}, /* c */ + {0}, /* d */ + {0}, /* e */ + {CMODE_f, 0, set_redirect, cs_set_redirect}, /* f */ + {CMODE_g, 0, NULL, NULL}, /* g */ + {0}, /* h */ + {CMODE_i, 0, NULL, NULL}, + {CMODE_j, 0, set_flood, cs_set_flood}, /* j */ + {CMODE_k, 0, chan_set_key, cs_set_key}, + {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, + {CMODE_m, 0, NULL, NULL}, + {CMODE_n, 0, NULL, NULL}, + {0}, /* o */ + {CMODE_p, 0, NULL, NULL}, + {0}, /* q */ + {CMODE_r, 0, NULL, NULL}, + {CMODE_s, 0, NULL, NULL}, + {CMODE_t, 0, NULL, NULL}, + {0}, + {0}, /* v */ + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {CMODE_z, 0, NULL, NULL}, /* z */ + {0}, {0}, {0}, {0} }; CBModeInfo myCbmodeinfos[] = { - {'c', CMODE_c, 0, NULL, NULL}, - {'f', CMODE_f, CBM_MINUS_NO_ARG, get_redirect, cs_get_redirect}, - {'g', CMODE_g, 0, NULL, NULL}, - {'i', CMODE_i, 0, NULL, NULL}, - {'j', CMODE_j, CBM_MINUS_NO_ARG, get_flood, cs_get_flood}, - {'k', CMODE_k, 0, get_key, cs_get_key}, - {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, - {'m', CMODE_m, 0, NULL, NULL}, - {'n', CMODE_n, 0, NULL, NULL}, - {'p', CMODE_p, 0, NULL, NULL}, - {'r', CMODE_r, 0, NULL, NULL}, - {'s', CMODE_s, 0, NULL, NULL}, - {'t', CMODE_t, 0, NULL, NULL}, - {'z', CMODE_z, 0, NULL, NULL}, - {'F', CMODE_F, 0, NULL, NULL}, - {'L', CMODE_L, 0, NULL, NULL}, - {'P', CMODE_P, 0, NULL, NULL}, - {'Q', CMODE_Q, 0, NULL, NULL}, - {0} + {'c', CMODE_c, 0, NULL, NULL}, + {'f', CMODE_f, CBM_MINUS_NO_ARG, get_redirect, cs_get_redirect}, + {'g', CMODE_g, 0, NULL, NULL}, + {'i', CMODE_i, 0, NULL, NULL}, + {'j', CMODE_j, CBM_MINUS_NO_ARG, get_flood, cs_get_flood}, + {'k', CMODE_k, 0, get_key, cs_get_key}, + {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, + {'m', CMODE_m, 0, NULL, NULL}, + {'n', CMODE_n, 0, NULL, NULL}, + {'p', CMODE_p, 0, NULL, NULL}, + {'r', CMODE_r, 0, NULL, NULL}, + {'s', CMODE_s, 0, NULL, NULL}, + {'t', CMODE_t, 0, NULL, NULL}, + {'z', CMODE_z, 0, NULL, NULL}, + {'F', CMODE_F, 0, NULL, NULL}, + {'L', CMODE_L, 0, NULL, NULL}, + {'P', CMODE_P, 0, NULL, NULL}, + {'Q', CMODE_Q, 0, NULL, NULL}, + {0} }; CUMode myCumodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, - - {0}, /* a */ - {0}, /* b */ - {0}, /* c */ - {0}, /* d */ - {0}, /* e */ - {0}, /* f */ - {0}, /* g */ - {0}, - {0}, /* i */ - {0}, /* j */ - {0}, /* k */ - {0}, /* l */ - {0}, /* m */ - {0}, /* n */ - {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, - {0}, /* p */ - {0}, /* q */ - {0}, /* r */ - {0}, /* s */ - {0}, /* t */ - {0}, /* u */ - {CUS_VOICE, 0, NULL}, - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {0}, /* z */ - {0}, {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, + + {0}, /* a */ + {0}, /* b */ + {0}, /* c */ + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {0}, + {0}, /* i */ + {0}, /* j */ + {0}, /* k */ + {0}, /* l */ + {0}, /* m */ + {0}, /* n */ + {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, + {0}, /* p */ + {0}, /* q */ + {0}, /* r */ + {0}, /* s */ + {0}, /* t */ + {0}, /* u */ + {CUS_VOICE, 0, NULL}, + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0}, {0} }; /*******************************************************************/ @@ -424,15 +424,15 @@ CUMode myCumodes[128] = { /* * SVINFO - * parv[0] = sender prefix - * parv[1] = TS_CURRENT for the server - * parv[2] = TS_MIN for the server - * parv[3] = server is standalone or connected to non-TS only - * parv[4] = server's idea of UTC time + * parv[0] = sender prefix + * parv[1] = TS_CURRENT for the server + * parv[2] = TS_MIN for the server + * parv[3] = server is standalone or connected to non-TS only + * parv[4] = server's idea of UTC time */ void charybdis_cmd_svinfo() { - send_cmd(NULL, "SVINFO 6 3 0 :%ld", (long int) time(NULL)); + send_cmd(NULL, "SVINFO 6 3 0 :%ld", (long int) time(NULL)); } void charybdis_cmd_svsinfo() @@ -442,57 +442,57 @@ void charybdis_cmd_svsinfo() /* CAPAB */ /* - QS - Can handle quit storm removal - EX - Can do channel +e exemptions - CHW - Can do channel wall @# - LL - Can do lazy links - IE - Can do invite exceptions - EOB - Can do EOB message - KLN - Can do KLINE message - GLN - Can do GLINE message - HUB - This server is a HUB - UID - Can do UIDs - ZIP - Can do ZIPlinks - ENC - Can do ENCrypted links - KNOCK - supports KNOCK + QS - Can handle quit storm removal + EX - Can do channel +e exemptions + CHW - Can do channel wall @# + LL - Can do lazy links + IE - Can do invite exceptions + EOB - Can do EOB message + KLN - Can do KLINE message + GLN - Can do GLINE message + HUB - This server is a HUB + UID - Can do UIDs + ZIP - Can do ZIPlinks + ENC - Can do ENCrypted links + KNOCK - supports KNOCK TBURST - supports TBURST PARA - supports invite broadcasting for +p ENCAP - supports message encapsulation SERVICES - supports services-oriented TS6 extensions - EUID - supports EUID and non-ENCAP CHGHOST + EUID - supports EUID and non-ENCAP CHGHOST */ void charybdis_cmd_capab() { - send_cmd(NULL, - "CAPAB :QS EX CHW IE KLN GLN KNOCK TB UNKLN CLUSTER ENCAP SERVICES EUID"); + send_cmd(NULL, + "CAPAB :QS EX CHW IE KLN GLN KNOCK TB UNKLN CLUSTER ENCAP SERVICES EUID"); } /* PASS */ void charybdis_cmd_pass(const char *pass) { - if (UseTS6) { - send_cmd(NULL, "PASS %s TS 6 :%s", pass, TS6SID); - } else { - send_cmd(NULL, "PASS %s :TS", pass); - } + if (UseTS6) { + send_cmd(NULL, "PASS %s TS 6 :%s", pass, TS6SID); + } else { + send_cmd(NULL, "PASS %s :TS", pass); + } } void charybdis_cmd_tmode(const char *source, const char *dest, const char *fmt, ...) { - va_list args; - char buf[BUFSIZE]; - *buf = '\0'; - - if (fmt) { - va_start(args, fmt); - vsnprintf(buf, BUFSIZE - 1, fmt, args); - va_end(args); - } - if (!*buf) { - return; - } - - send_cmd(NULL, "MODE %s %s", dest, buf); + va_list args; + char buf[BUFSIZE]; + *buf = '\0'; + + if (fmt) { + va_start(args, fmt); + vsnprintf(buf, BUFSIZE - 1, fmt, args); + va_end(args); + } + if (!*buf) { + return; + } + + send_cmd(NULL, "MODE %s %s", dest, buf); } class CharybdisProto : public IRCDProto @@ -759,8 +759,8 @@ class CharybdisProto : public IRCDProto int anope_event_sjoin(const char *source, int ac, const char **av) { - do_sjoin(source, ac, av); - return MOD_CONT; + do_sjoin(source, ac, av); + return MOD_CONT; } /* @@ -789,29 +789,29 @@ int anope_event_sjoin(const char *source, int ac, const char **av) */ int anope_event_nick(const char *source, int ac, const char **av) { - Server *s; - User *user; - - if (UseTS6 && ac == 9) { - s = findserver_uid(servlist, source); - /* Source is always the server */ - user = do_nick("", av[0], av[4], av[5], s->name, av[8], - strtoul(av[2], NULL, 10), 0, 0, NULL, av[7]); - if (user) { - ircdproto->ProcessUsermodes(user, 1, &av[3]); - } - } else { - if (ac != 2) { - user = do_nick(source, av[0], av[4], av[5], av[6], av[7], - strtoul(av[2], NULL, 10), 0, 0, NULL, NULL); - if (user) - ircdproto->ProcessUsermodes(user, 1, &av[3]); - } else { - do_nick(source, av[0], NULL, NULL, NULL, NULL, - strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); - } - } - return MOD_CONT; + Server *s; + User *user; + + if (UseTS6 && ac == 9) { + s = findserver_uid(servlist, source); + /* Source is always the server */ + user = do_nick("", av[0], av[4], av[5], s->name, av[8], + strtoul(av[2], NULL, 10), 0, 0, NULL, av[7]); + if (user) { + ircdproto->ProcessUsermodes(user, 1, &av[3]); + } + } else { + if (ac != 2) { + user = do_nick(source, av[0], av[4], av[5], av[6], av[7], + strtoul(av[2], NULL, 10), 0, 0, NULL, NULL); + if (user) + ircdproto->ProcessUsermodes(user, 1, &av[3]); + } else { + do_nick(source, av[0], NULL, NULL, NULL, NULL, + strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); + } + } + return MOD_CONT; } /* @@ -831,200 +831,200 @@ int anope_event_nick(const char *source, int ac, const char **av) */ int anope_event_euid(const char *source, int ac, const char **av) { - Server *s; - User *user; - time_t ts; + Server *s; + User *user; + time_t ts; - if (UseTS6 && ac == 11) { - s = findserver_uid(servlist, source); - /* Source is always the server */ + if (UseTS6 && ac == 11) { + s = findserver_uid(servlist, source); + /* Source is always the server */ ts = strtoul(av[2], NULL, 10); - user = do_nick("", av[0], av[4], !strcmp(av[8], "*") ? av[5] : av[8], s->name, av[10], - ts, !stricmp(av[0], av[9]) ? ts : 0, 0, av[5], av[7]); - if (user) { - ircdproto->ProcessUsermodes(user, 1, &av[3]); - } - } - return MOD_CONT; + user = do_nick("", av[0], av[4], !strcmp(av[8], "*") ? av[5] : av[8], s->name, av[10], + ts, !stricmp(av[0], av[9]) ? ts : 0, 0, av[5], av[7]); + if (user) { + ircdproto->ProcessUsermodes(user, 1, &av[3]); + } + } + return MOD_CONT; } int anope_event_topic(const char *source, int ac, const char **av) { - User *u; - - if (ac == 4) { - do_topic(source, ac, av); - } else { - Channel *c = findchan(av[0]); - time_t topic_time = time(NULL); - - if (!c) { - if (debug) { - alog("debug: TOPIC %s for nonexistent channel %s", - merge_args(ac - 1, av + 1), av[0]); - } - return MOD_CONT; - } - - if (check_topiclock(c, topic_time)) - return MOD_CONT; - - if (c->topic) { - free(c->topic); - c->topic = NULL; - } - if (ac > 1 && *av[1]) - c->topic = sstrdup(av[1]); - - if (UseTS6) { - u = find_byuid(source); - if (u) { - strscpy(c->topic_setter, u->nick, sizeof(c->topic_setter)); - } else { - strscpy(c->topic_setter, source, sizeof(c->topic_setter)); - } - } else { - strscpy(c->topic_setter, source, sizeof(c->topic_setter)); - } - c->topic_time = topic_time; - - record_topic(av[0]); + User *u; + + if (ac == 4) { + do_topic(source, ac, av); + } else { + Channel *c = findchan(av[0]); + time_t topic_time = time(NULL); + if (!c) { + if (debug) { + alog("debug: TOPIC %s for nonexistent channel %s", + merge_args(ac - 1, av + 1), av[0]); + } + return MOD_CONT; + } + + if (check_topiclock(c, topic_time)) + return MOD_CONT; + + if (c->topic) { + free(c->topic); + c->topic = NULL; + } if (ac > 1 && *av[1]) - send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[1]); + c->topic = sstrdup(av[1]); + + if (UseTS6) { + u = find_byuid(source); + if (u) { + strscpy(c->topic_setter, u->nick, sizeof(c->topic_setter)); + } else { + strscpy(c->topic_setter, source, sizeof(c->topic_setter)); + } + } else { + strscpy(c->topic_setter, source, sizeof(c->topic_setter)); + } + c->topic_time = topic_time; + + record_topic(av[0]); + + if (ac > 1 && *av[1]) + send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[1]); else - send_event(EVENT_TOPIC_UPDATED, 2, av[0], ""); - } - return MOD_CONT; + send_event(EVENT_TOPIC_UPDATED, 2, av[0], ""); + } + return MOD_CONT; } int anope_event_tburst(const char *source, int ac, const char **av) { - char *setter; - Channel *c; - time_t topic_time; - - if (ac != 4) { - return MOD_CONT; - } - - setter = myStrGetToken(av[2], '!', 0); - - c = findchan(av[0]); - topic_time = strtol(av[1], NULL, 10); - - if (!c) { - if (debug) { - alog("debug: TOPIC %s for nonexistent channel %s", - merge_args(ac - 1, av + 1), av[0]); - } - if (setter) - free(setter); - return MOD_CONT; - } - - if (check_topiclock(c, topic_time)) { - if (setter) - free(setter); - return MOD_CONT; - } - - if (c->topic) { - free(c->topic); - c->topic = NULL; - } - if (ac > 1 && *av[3]) - c->topic = sstrdup(av[3]); - - strscpy(c->topic_setter, setter, sizeof(c->topic_setter)); - c->topic_time = topic_time; - - record_topic(av[0]); + char *setter; + Channel *c; + time_t topic_time; + + if (ac != 4) { + return MOD_CONT; + } + + setter = myStrGetToken(av[2], '!', 0); + + c = findchan(av[0]); + topic_time = strtol(av[1], NULL, 10); + + if (!c) { + if (debug) { + alog("debug: TOPIC %s for nonexistent channel %s", + merge_args(ac - 1, av + 1), av[0]); + } + if (setter) + free(setter); + return MOD_CONT; + } + + if (check_topiclock(c, topic_time)) { + if (setter) + free(setter); + return MOD_CONT; + } + + if (c->topic) { + free(c->topic); + c->topic = NULL; + } + if (ac > 1 && *av[3]) + c->topic = sstrdup(av[3]); + + strscpy(c->topic_setter, setter, sizeof(c->topic_setter)); + c->topic_time = topic_time; + + record_topic(av[0]); if (ac > 1 && *av[3]) - send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[3]); + send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[3]); else - send_event(EVENT_TOPIC_UPDATED, 2, av[0], ""); + send_event(EVENT_TOPIC_UPDATED, 2, av[0], ""); - if (setter) - free(setter); + if (setter) + free(setter); - return MOD_CONT; + return MOD_CONT; } int anope_event_436(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; + if (ac < 1) + return MOD_CONT; - m_nickcoll(av[0]); - return MOD_CONT; + m_nickcoll(av[0]); + return MOD_CONT; } int anope_event_ping(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - ircdproto->SendPong(ac > 1 ? av[1] : ServerName, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + ircdproto->SendPong(ac > 1 ? av[1] : ServerName, av[0]); + return MOD_CONT; } int anope_event_away(const char *source, int ac, const char **av) { - User *u = NULL; + User *u = NULL; - if (UseTS6) { - u = find_byuid(source); - } + if (UseTS6) { + u = find_byuid(source); + } - m_away((UseTS6 ? (u ? u->nick : source) : source), - (ac ? av[0] : NULL)); - return MOD_CONT; + m_away((UseTS6 ? (u ? u->nick : source) : source), + (ac ? av[0] : NULL)); + return MOD_CONT; } int anope_event_kill(const char *source, int ac, const char **av) { - User *u = NULL; + User *u = NULL; - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - if (UseTS6) { - u = find_byuid(av[0]); - } + if (UseTS6) { + u = find_byuid(av[0]); + } - m_kill(u ? u->nick : av[0], av[1]); - return MOD_CONT; + m_kill(u ? u->nick : av[0], av[1]); + return MOD_CONT; } int anope_event_kick(const char *source, int ac, const char **av) { - if (ac != 3) - return MOD_CONT; - do_kick(source, ac, av); - return MOD_CONT; + if (ac != 3) + return MOD_CONT; + do_kick(source, ac, av); + return MOD_CONT; } int anope_event_join(const char *source, int ac, const char **av) { - if (ac != 1) { + if (ac != 1) { /* ignore cmodes in JOIN as per TS6 v8 */ - do_sjoin(source, ac > 2 ? 2 : ac, av); - return MOD_CONT; - } else { - do_join(source, ac, av); - } - return MOD_CONT; + do_sjoin(source, ac > 2 ? 2 : ac, av); + return MOD_CONT; + } else { + do_join(source, ac, av); + } + return MOD_CONT; } int anope_event_motd(const char *source, int ac, const char **av) { - if (!source) { - return MOD_CONT; - } + if (!source) { + return MOD_CONT; + } - m_motd(source); - return MOD_CONT; + m_motd(source); + return MOD_CONT; } int anope_event_privmsg(const char *source, int ac, const char **av) @@ -1045,16 +1045,16 @@ int anope_event_privmsg(const char *source, int ac, const char **av) int anope_event_part(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac < 1 || ac > 2) { - return MOD_CONT; - } + if (ac < 1 || ac > 2) { + return MOD_CONT; + } - u = find_byuid(source); - do_part((UseTS6 ? (u ? u->nick : source) : source), ac, av); + u = find_byuid(source); + do_part((UseTS6 ? (u ? u->nick : source) : source), ac, av); - return MOD_CONT; + return MOD_CONT; } int anope_event_whois(const char *source, int ac, const char **av) @@ -1072,224 +1072,224 @@ int anope_event_whois(const char *source, int ac, const char **av) /* EVENT: SERVER */ int anope_event_server(const char *source, int ac, const char **av) { - if (!stricmp(av[1], "1")) { - uplink = sstrdup(av[0]); - if (UseTS6 && TS6UPLINK) { - do_server(source, av[0], av[1], av[2], TS6UPLINK); - } else { - do_server(source, av[0], av[1], av[2], NULL); - } - } else { - do_server(source, av[0], av[1], av[2], NULL); - } - return MOD_CONT; + if (!stricmp(av[1], "1")) { + uplink = sstrdup(av[0]); + if (UseTS6 && TS6UPLINK) { + do_server(source, av[0], av[1], av[2], TS6UPLINK); + } else { + do_server(source, av[0], av[1], av[2], NULL); + } + } else { + do_server(source, av[0], av[1], av[2], NULL); + } + return MOD_CONT; } int anope_event_sid(const char *source, int ac, const char **av) { - Server *s; + Server *s; - /* :42X SID trystan.nomadirc.net 2 43X :ircd-charybdis test server */ + /* :42X SID trystan.nomadirc.net 2 43X :ircd-charybdis test server */ - s = findserver_uid(servlist, source); + s = findserver_uid(servlist, source); - do_server(s->name, av[0], av[1], av[3], av[2]); - return MOD_CONT; + do_server(s->name, av[0], av[1], av[3], av[2]); + return MOD_CONT; } int anope_event_squit(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; - do_squit(source, ac, av); - return MOD_CONT; + if (ac != 2) + return MOD_CONT; + do_squit(source, ac, av); + return MOD_CONT; } int anope_event_quit(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 1) { - return MOD_CONT; - } + if (ac != 1) { + return MOD_CONT; + } - u = find_byuid(source); + u = find_byuid(source); - do_quit((UseTS6 ? (u ? u->nick : source) : source), ac, av); - return MOD_CONT; + do_quit((UseTS6 ? (u ? u->nick : source) : source), ac, av); + return MOD_CONT; } int anope_event_mode(const char *source, int ac, const char **av) { - User *u, *u2; - - if (ac < 2) { - return MOD_CONT; - } - - if (*av[0] == '#' || *av[0] == '&') { - do_cmode(source, ac, av); - } else { - if (UseTS6) { - u = find_byuid(source); - u2 = find_byuid(av[0]); - av[0] = u2->nick; - do_umode(u->nick, ac, av); - } else { - do_umode(source, ac, av); - } - } - return MOD_CONT; + User *u, *u2; + + if (ac < 2) { + return MOD_CONT; + } + + if (*av[0] == '#' || *av[0] == '&') { + do_cmode(source, ac, av); + } else { + if (UseTS6) { + u = find_byuid(source); + u2 = find_byuid(av[0]); + av[0] = u2->nick; + do_umode(u->nick, ac, av); + } else { + do_umode(source, ac, av); + } + } + return MOD_CONT; } int anope_event_tmode(const char *source, int ac, const char **av) { - if (ac > 2 && (*av[1] == '#' || *av[1] == '&')) { - do_cmode(source, ac, av); - } - return MOD_CONT; + if (ac > 2 && (*av[1] == '#' || *av[1] == '&')) { + do_cmode(source, ac, av); + } + return MOD_CONT; } /* Event: PROTOCTL */ int anope_event_capab(const char *source, int ac, const char **av) { - int argvsize = 8; - int argc; - const char **argv; - char *str; - - if (ac < 1) - return MOD_CONT; - - /* We get the params as one arg, we should split it for capab_parse */ - argv = (const char **)scalloc(argvsize, sizeof(const char *)); - argc = 0; - while ((str = myStrGetToken(av[0], ' ', argc))) { - if (argc == argvsize) { - argvsize += 8; - argv = (const char **)srealloc(argv, argvsize * sizeof(const char *)); - } - argv[argc] = str; - argc++; - } - - capab_parse(argc, argv); - - /* Free our built ac/av */ - for (argvsize = 0; argvsize < argc; argvsize++) { - free((char *)argv[argvsize]); - } - free((char **)argv); - - return MOD_CONT; + int argvsize = 8; + int argc; + const char **argv; + char *str; + + if (ac < 1) + return MOD_CONT; + + /* We get the params as one arg, we should split it for capab_parse */ + argv = (const char **)scalloc(argvsize, sizeof(const char *)); + argc = 0; + while ((str = myStrGetToken(av[0], ' ', argc))) { + if (argc == argvsize) { + argvsize += 8; + argv = (const char **)srealloc(argv, argvsize * sizeof(const char *)); + } + argv[argc] = str; + argc++; + } + + capab_parse(argc, argv); + + /* Free our built ac/av */ + for (argvsize = 0; argvsize < argc; argvsize++) { + free((char *)argv[argvsize]); + } + free((char **)argv); + + return MOD_CONT; } int anope_event_pass(const char *source, int ac, const char **av) { - if (UseTS6) { - TS6UPLINK = sstrdup(av[3]); - } - return MOD_CONT; + if (UseTS6) { + TS6UPLINK = sstrdup(av[3]); + } + return MOD_CONT; } int anope_event_bmask(const char *source, int ac, const char **av) { - Channel *c; - char *bans; - char *b; - int count, i; - - /* :42X BMASK 1106409026 #ircops b :*!*@*.aol.com */ - /* 0 1 2 3 */ - c = findchan(av[1]); - - if (c) { - bans = sstrdup(av[3]); - count = myNumToken(bans, ' '); - for (i = 0; i <= count - 1; i++) { - b = myStrGetToken(bans, ' ', i); - if (!stricmp(av[2], "b")) { - add_ban(c, b); - } - if (!stricmp(av[2], "e")) { - add_exception(c, b); - } - if (!stricmp(av[2], "I")) { - add_invite(c, b); - } - if (b) - free(b); - } - free(bans); - } - return MOD_CONT; + Channel *c; + char *bans; + char *b; + int count, i; + + /* :42X BMASK 1106409026 #ircops b :*!*@*.aol.com */ + /* 0 1 2 3 */ + c = findchan(av[1]); + + if (c) { + bans = sstrdup(av[3]); + count = myNumToken(bans, ' '); + for (i = 0; i <= count - 1; i++) { + b = myStrGetToken(bans, ' ', i); + if (!stricmp(av[2], "b")) { + add_ban(c, b); + } + if (!stricmp(av[2], "e")) { + add_exception(c, b); + } + if (!stricmp(av[2], "I")) { + add_invite(c, b); + } + if (b) + free(b); + } + free(bans); + } + return MOD_CONT; } int anope_event_error(const char *source, int ac, const char **av) { - if (ac >= 1) { - if (debug) { - alog("debug: %s", av[0]); - } - } - return MOD_CONT; + if (ac >= 1) { + if (debug) { + alog("debug: %s", av[0]); + } + } + return MOD_CONT; } int charybdis_send_account(int argc, char **argv) { - send_cmd((UseTS6 ? TS6SID : ServerName), "ENCAP * SU %s :%s", + send_cmd((UseTS6 ? TS6SID : ServerName), "ENCAP * SU %s :%s", argv[0], argv[0]); - return MOD_CONT; + return MOD_CONT; } /* XXX: We need a hook on /ns logout before this is useful! --nenolod */ /* We have one now! -GD */ int charybdis_send_deaccount(int argc, char **argv) { - send_cmd((UseTS6 ? TS6SID : ServerName), "ENCAP * SU %s", + send_cmd((UseTS6 ? TS6SID : ServerName), "ENCAP * SU %s", argv[0]); - return MOD_CONT; + return MOD_CONT; } /* *INDENT-OFF* */ void moduleAddIRCDMsgs(void) { - Message *m; - - updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+","-"); - - if (UseTS6) { - TS6SID = sstrdup(Numeric); - } - - m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); - m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); - m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); - m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); - m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); - m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); - m = createMessage("TMODE", anope_event_tmode); addCoreMessage(IRCD,m); - m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); - m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); - m = createMessage("BMASK", anope_event_bmask); addCoreMessage(IRCD,m); - m = createMessage("UID", anope_event_nick); addCoreMessage(IRCD,m); - m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); - m = createMessage("PASS", anope_event_pass); addCoreMessage(IRCD,m); - m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); - m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); - m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); - m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); - m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); - m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); - m = createMessage("TB", anope_event_tburst); addCoreMessage(IRCD,m); - m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); - m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); - m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); - m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m); - m = createMessage("SID", anope_event_sid); addCoreMessage(IRCD,m); - m = createMessage("EUID", anope_event_euid); addCoreMessage(IRCD,m); + Message *m; + + updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+","-"); + + if (UseTS6) { + TS6SID = sstrdup(Numeric); + } + + m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); + m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); + m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); + m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); + m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); + m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("TMODE", anope_event_tmode); addCoreMessage(IRCD,m); + m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); + m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("BMASK", anope_event_bmask); addCoreMessage(IRCD,m); + m = createMessage("UID", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); + m = createMessage("PASS", anope_event_pass); addCoreMessage(IRCD,m); + m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); + m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); + m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); + m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); + m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); + m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); + m = createMessage("TB", anope_event_tburst); addCoreMessage(IRCD,m); + m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); + m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); + m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); + m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m); + m = createMessage("SID", anope_event_sid); addCoreMessage(IRCD,m); + m = createMessage("EUID", anope_event_euid); addCoreMessage(IRCD,m); } /* *INDENT-ON* */ diff --git a/src/protocol/inspircd11.c b/src/protocol/inspircd11.c index ed8c7f06f..d20801548 100644 --- a/src/protocol/inspircd11.c +++ b/src/protocol/inspircd11.c @@ -64,338 +64,338 @@ #include "winsock.h" int inet_aton(const char *name, struct in_addr *addr) { - uint32 a = inet_addr(name); - addr->s_addr = a; - return a != (uint32) - 1; + uint32 a = inet_addr(name); + addr->s_addr = a; + return a != (uint32) - 1; } #endif IRCDVar myIrcd[] = { - {"InspIRCd 1.1", /* ircd name */ - "+I", /* Modes used by pseudoclients */ - 5, /* Chan Max Symbols */ - "-cilmnpstuzACGHKNOQRSV", /* Modes to Remove */ - "+ao", /* Channel Umode used by Botserv bots */ - 1, /* SVSNICK */ - 1, /* Vhost */ - 1, /* Has Owner */ - "+q", /* Mode to set for an owner */ - "-q", /* Mode to unset for an owner */ - "+a", /* Mode to set for channel admin */ - "-a", /* Mode to unset for channel admin */ - "+r", /* Mode On Reg */ - NULL, /* Mode on ID for Roots */ - NULL, /* Mode on ID for Admins */ - NULL, /* Mode on ID for Opers */ - "-r", /* Mode on UnReg */ - "-r", /* Mode on Nick Change */ - 1, /* Supports SGlines */ - 1, /* Supports SQlines */ - 1, /* Supports SZlines */ - 1, /* Supports Halfop +h */ - 4, /* Number of server args */ - 0, /* Join 2 Set */ - 1, /* Join 2 Message */ - 0, /* Has exceptions +e */ - 1, /* TS Topic Forward */ - 0, /* TS Topci Backward */ - 0, /* Protected Umode */ - 0, /* Has Admin */ - 0, /* Chan SQlines */ - 0, /* Quit on Kill */ - 0, /* SVSMODE unban */ - 1, /* Has Protect */ - 1, /* Reverse */ - 1, /* Chan Reg */ - CMODE_r, /* Channel Mode */ - 1, /* vidents */ - 0, /* svshold */ - 0, /* time stamp on mode */ - 0, /* NICKIP */ - 1, /* O:LINE */ - 1, /* UMODE */ - 1, /* VHOST ON NICK */ - 0, /* Change RealName */ - CMODE_K, /* No Knock */ - 0, /* Admin Only */ - DEFAULT_MLOCK, /* Default MLOCK */ - UMODE_x, /* Vhost Mode */ - 0, /* +f */ - 1, /* +L */ - CMODE_f, - CMODE_L, - 0, - 1, /* No Knock requires +i */ - NULL, /* CAPAB Chan Modes */ - 0, /* We support inspircd TOKENS */ - 0, /* TIME STAMPS are BASE64 */ - 0, /* +I support */ - 0, /* SJOIN ban char */ - 0, /* SJOIN except char */ - 0, /* SJOIN invite char */ - 0, /* Can remove User Channel Modes with SVSMODE */ - 0, /* Sglines are not enforced until user reconnects */ - "x", /* vhost char */ - 0, /* ts6 */ - 1, /* support helper umode */ - 0, /* p10 */ - NULL, /* character set */ - 0, /* reports sync state */ - 1, /* CIDR channelbans */ - "$", /* TLD Prefix for Global */ - } - , - {NULL} + {"InspIRCd 1.1", /* ircd name */ + "+I", /* Modes used by pseudoclients */ + 5, /* Chan Max Symbols */ + "-cilmnpstuzACGHKNOQRSV", /* Modes to Remove */ + "+ao", /* Channel Umode used by Botserv bots */ + 1, /* SVSNICK */ + 1, /* Vhost */ + 1, /* Has Owner */ + "+q", /* Mode to set for an owner */ + "-q", /* Mode to unset for an owner */ + "+a", /* Mode to set for channel admin */ + "-a", /* Mode to unset for channel admin */ + "+r", /* Mode On Reg */ + NULL, /* Mode on ID for Roots */ + NULL, /* Mode on ID for Admins */ + NULL, /* Mode on ID for Opers */ + "-r", /* Mode on UnReg */ + "-r", /* Mode on Nick Change */ + 1, /* Supports SGlines */ + 1, /* Supports SQlines */ + 1, /* Supports SZlines */ + 1, /* Supports Halfop +h */ + 4, /* Number of server args */ + 0, /* Join 2 Set */ + 1, /* Join 2 Message */ + 0, /* Has exceptions +e */ + 1, /* TS Topic Forward */ + 0, /* TS Topci Backward */ + 0, /* Protected Umode */ + 0, /* Has Admin */ + 0, /* Chan SQlines */ + 0, /* Quit on Kill */ + 0, /* SVSMODE unban */ + 1, /* Has Protect */ + 1, /* Reverse */ + 1, /* Chan Reg */ + CMODE_r, /* Channel Mode */ + 1, /* vidents */ + 0, /* svshold */ + 0, /* time stamp on mode */ + 0, /* NICKIP */ + 1, /* O:LINE */ + 1, /* UMODE */ + 1, /* VHOST ON NICK */ + 0, /* Change RealName */ + CMODE_K, /* No Knock */ + 0, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + UMODE_x, /* Vhost Mode */ + 0, /* +f */ + 1, /* +L */ + CMODE_f, + CMODE_L, + 0, + 1, /* No Knock requires +i */ + NULL, /* CAPAB Chan Modes */ + 0, /* We support inspircd TOKENS */ + 0, /* TIME STAMPS are BASE64 */ + 0, /* +I support */ + 0, /* SJOIN ban char */ + 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ + 0, /* Can remove User Channel Modes with SVSMODE */ + 0, /* Sglines are not enforced until user reconnects */ + "x", /* vhost char */ + 0, /* ts6 */ + 1, /* support helper umode */ + 0, /* p10 */ + NULL, /* character set */ + 0, /* reports sync state */ + 1, /* CIDR channelbans */ + "$", /* TLD Prefix for Global */ + } + , + {NULL} }; IRCDCAPAB myIrcdcap[] = { - { - CAPAB_NOQUIT, /* NOQUIT */ - 0, /* TSMODE */ - 1, /* UNCONNECT */ - 0, /* NICKIP */ - 0, /* SJOIN */ - 0, /* ZIP */ - 0, /* BURST */ - 0, /* TS5 */ - 0, /* TS3 */ - 0, /* DKEY */ - 0, /* PT4 */ - 0, /* SCS */ - 0, /* QS */ - 0, /* UID */ - 0, /* KNOCK */ - 0, /* CLIENT */ - 0, /* IPV6 */ - 0, /* SSJ5 */ - 0, /* SN2 */ - 0, /* TOKEN */ - 0, /* VHOST */ - CAPAB_SSJ3, /* SSJ3 */ - CAPAB_NICK2, /* NICK2 */ - 0, /* UMODE2 */ - CAPAB_VL, /* VL */ - CAPAB_TLKEXT, /* TLKEXT */ - 0, /* DODKEY */ - 0, /* DOZIP */ - 0, - 0, 0} + { + CAPAB_NOQUIT, /* NOQUIT */ + 0, /* TSMODE */ + 1, /* UNCONNECT */ + 0, /* NICKIP */ + 0, /* SJOIN */ + 0, /* ZIP */ + 0, /* BURST */ + 0, /* TS5 */ + 0, /* TS3 */ + 0, /* DKEY */ + 0, /* PT4 */ + 0, /* SCS */ + 0, /* QS */ + 0, /* UID */ + 0, /* KNOCK */ + 0, /* CLIENT */ + 0, /* IPV6 */ + 0, /* SSJ5 */ + 0, /* SN2 */ + 0, /* TOKEN */ + 0, /* VHOST */ + CAPAB_SSJ3, /* SSJ3 */ + CAPAB_NICK2, /* NICK2 */ + 0, /* UMODE2 */ + CAPAB_VL, /* VL */ + CAPAB_TLKEXT, /* TLKEXT */ + 0, /* DODKEY */ + 0, /* DOZIP */ + 0, + 0, 0} }; unsigned long umodes[128] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, UMODE_A, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0, 0, 0, 0, 0, - 0, UMODE_a, 0, 0, 0, 0, 0, - UMODE_g, - UMODE_h, UMODE_i, 0, 0, 0, 0, 0, UMODE_o, - 0, - 0, UMODE_r, 0, 0, 0, 0, UMODE_w, - UMODE_x, - 0, - 0, - 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, UMODE_A, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, + 0, + 0, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0, 0, 0, 0, 0, + 0, UMODE_a, 0, 0, 0, 0, 0, + UMODE_g, + UMODE_h, UMODE_i, 0, 0, 0, 0, 0, UMODE_o, + 0, + 0, UMODE_r, 0, 0, 0, 0, UMODE_w, + UMODE_x, + 0, + 0, + 0, 0, 0, 0, 0 }; char myCsmodes[128] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, 0, 0, - 'h', /* (37) % Channel halfops */ - 'a', - 0, 0, 0, 0, + 0, + 0, + 0, 0, 0, + 'h', /* (37) % Channel halfops */ + 'a', + 0, 0, 0, 0, - 'v', 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'v', 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'q', 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'q', 0 }; CMMode myCmmodes[128] = { - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, - {NULL}, - {add_ban, del_ban}, - {NULL}, - {NULL}, - {NULL, NULL}, - {NULL}, - {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, + {NULL}, + {add_ban, del_ban}, + {NULL}, + {NULL}, + {NULL, NULL}, + {NULL}, + {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} }; CBMode myCbmodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, - {CMODE_A, CBM_NO_USER_MLOCK, NULL, NULL}, - {0}, /* B */ - {CMODE_C, 0, NULL, NULL}, /* C */ - {0}, /* D */ - {0}, /* E */ - {0}, /* F */ - {CMODE_G, 0, NULL, NULL}, /* G */ - {CMODE_H, CBM_NO_USER_MLOCK, NULL, NULL}, - {0}, /* I */ - {0}, /* J */ - {CMODE_K, 0, NULL, NULL}, /* K */ - {CMODE_L, 0, set_redirect, cs_set_redirect}, - {0}, /* M */ - {CMODE_N, 0, NULL, NULL}, /* N */ - {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, - {0}, /* P */ - {CMODE_Q, 0, NULL, NULL}, /* Q */ - {CMODE_R, 0, NULL, NULL}, /* R */ - {CMODE_S, 0, NULL, NULL}, /* S */ - {0}, /* T */ - {0}, /* U */ - {CMODE_V, 0, NULL, NULL}, /* V */ - {0}, /* W */ - {0}, /* X */ - {0}, /* Y */ - {0}, /* Z */ - {0}, {0}, {0}, {0}, {0}, {0}, - {0}, /* a */ - {0}, /* b */ - {CMODE_c, 0, NULL, NULL}, - {0}, /* d */ - {0}, /* e */ - {0}, /* f */ - {0}, /* g */ - {0}, /* h */ - {CMODE_i, 0, NULL, NULL}, - {0}, /* j */ - {CMODE_k, 0, chan_set_key, cs_set_key}, - {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, - {CMODE_m, 0, NULL, NULL}, - {CMODE_n, 0, NULL, NULL}, - {0}, /* o */ - {CMODE_p, 0, NULL, NULL}, - {0}, /* q */ - {CMODE_r, CBM_NO_MLOCK, NULL, NULL}, - {CMODE_s, 0, NULL, NULL}, - {CMODE_t, 0, NULL, NULL}, - {CMODE_u, 0, NULL, NULL}, - {0}, /* v */ - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {CMODE_z, 0, NULL, NULL}, - {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, + {CMODE_A, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* B */ + {CMODE_C, 0, NULL, NULL}, /* C */ + {0}, /* D */ + {0}, /* E */ + {0}, /* F */ + {CMODE_G, 0, NULL, NULL}, /* G */ + {CMODE_H, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* I */ + {0}, /* J */ + {CMODE_K, 0, NULL, NULL}, /* K */ + {CMODE_L, 0, set_redirect, cs_set_redirect}, + {0}, /* M */ + {CMODE_N, 0, NULL, NULL}, /* N */ + {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* P */ + {CMODE_Q, 0, NULL, NULL}, /* Q */ + {CMODE_R, 0, NULL, NULL}, /* R */ + {CMODE_S, 0, NULL, NULL}, /* S */ + {0}, /* T */ + {0}, /* U */ + {CMODE_V, 0, NULL, NULL}, /* V */ + {0}, /* W */ + {0}, /* X */ + {0}, /* Y */ + {0}, /* Z */ + {0}, {0}, {0}, {0}, {0}, {0}, + {0}, /* a */ + {0}, /* b */ + {CMODE_c, 0, NULL, NULL}, + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {0}, /* h */ + {CMODE_i, 0, NULL, NULL}, + {0}, /* j */ + {CMODE_k, 0, chan_set_key, cs_set_key}, + {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, + {CMODE_m, 0, NULL, NULL}, + {CMODE_n, 0, NULL, NULL}, + {0}, /* o */ + {CMODE_p, 0, NULL, NULL}, + {0}, /* q */ + {CMODE_r, CBM_NO_MLOCK, NULL, NULL}, + {CMODE_s, 0, NULL, NULL}, + {CMODE_t, 0, NULL, NULL}, + {CMODE_u, 0, NULL, NULL}, + {0}, /* v */ + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {CMODE_z, 0, NULL, NULL}, + {0}, {0}, {0}, {0} }; CBModeInfo myCbmodeinfos[] = { - {'f', CMODE_f, 0, NULL, NULL}, - {'c', CMODE_c, 0, NULL, NULL}, - {'i', CMODE_i, 0, NULL, NULL}, - {'k', CMODE_k, 0, get_key, cs_get_key}, - {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, - {'m', CMODE_m, 0, NULL, NULL}, - {'n', CMODE_n, 0, NULL, NULL}, - {'p', CMODE_p, 0, NULL, NULL}, - {'r', CMODE_r, 0, NULL, NULL}, - {'s', CMODE_s, 0, NULL, NULL}, - {'t', CMODE_t, 0, NULL, NULL}, - {'u', CMODE_u, 0, NULL, NULL}, - {'z', CMODE_z, 0, NULL, NULL}, - {'A', CMODE_A, 0, NULL, NULL}, - {'C', CMODE_C, 0, NULL, NULL}, - {'G', CMODE_G, 0, NULL, NULL}, - {'H', CMODE_H, 0, NULL, NULL}, - {'K', CMODE_K, 0, NULL, NULL}, - {'L', CMODE_L, 0, get_redirect, cs_get_redirect}, - {'N', CMODE_N, 0, NULL, NULL}, - {'O', CMODE_O, 0, NULL, NULL}, - {'Q', CMODE_Q, 0, NULL, NULL}, - {'R', CMODE_R, 0, NULL, NULL}, - {'S', CMODE_S, 0, NULL, NULL}, - {'V', CMODE_V, 0, NULL, NULL}, - {0} + {'f', CMODE_f, 0, NULL, NULL}, + {'c', CMODE_c, 0, NULL, NULL}, + {'i', CMODE_i, 0, NULL, NULL}, + {'k', CMODE_k, 0, get_key, cs_get_key}, + {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, + {'m', CMODE_m, 0, NULL, NULL}, + {'n', CMODE_n, 0, NULL, NULL}, + {'p', CMODE_p, 0, NULL, NULL}, + {'r', CMODE_r, 0, NULL, NULL}, + {'s', CMODE_s, 0, NULL, NULL}, + {'t', CMODE_t, 0, NULL, NULL}, + {'u', CMODE_u, 0, NULL, NULL}, + {'z', CMODE_z, 0, NULL, NULL}, + {'A', CMODE_A, 0, NULL, NULL}, + {'C', CMODE_C, 0, NULL, NULL}, + {'G', CMODE_G, 0, NULL, NULL}, + {'H', CMODE_H, 0, NULL, NULL}, + {'K', CMODE_K, 0, NULL, NULL}, + {'L', CMODE_L, 0, get_redirect, cs_get_redirect}, + {'N', CMODE_N, 0, NULL, NULL}, + {'O', CMODE_O, 0, NULL, NULL}, + {'Q', CMODE_Q, 0, NULL, NULL}, + {'R', CMODE_R, 0, NULL, NULL}, + {'S', CMODE_S, 0, NULL, NULL}, + {'V', CMODE_V, 0, NULL, NULL}, + {0} }; CUMode myCumodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, - - {CUS_PROTECT, CUF_PROTECT_BOTSERV, check_valid_op}, - {0}, /* b */ - {0}, /* c */ - {0}, /* d */ - {0}, /* e */ - {0}, /* f */ - {0}, /* g */ - {CUS_HALFOP, 0, check_valid_op}, - {0}, /* i */ - {0}, /* j */ - {0}, /* k */ - {0}, /* l */ - {0}, /* m */ - {0}, /* n */ - {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, - {0}, /* p */ - {CUS_OWNER, 0, check_valid_op}, - {0}, /* r */ - {0}, /* s */ - {0}, /* t */ - {0}, /* u */ - {CUS_VOICE, 0, NULL}, - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {0}, /* z */ - {0}, {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, + + {CUS_PROTECT, CUF_PROTECT_BOTSERV, check_valid_op}, + {0}, /* b */ + {0}, /* c */ + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {CUS_HALFOP, 0, check_valid_op}, + {0}, /* i */ + {0}, /* j */ + {0}, /* k */ + {0}, /* l */ + {0}, /* m */ + {0}, /* n */ + {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, + {0}, /* p */ + {CUS_OWNER, 0, check_valid_op}, + {0}, /* r */ + {0}, /* s */ + {0}, /* t */ + {0}, /* u */ + {CUS_VOICE, 0, NULL}, + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0}, {0} }; static int has_servicesmod = 0; @@ -415,22 +415,22 @@ static int has_inviteexceptionmod = 0; /* CHGHOST */ void inspircd_cmd_chghost(const char *nick, const char *vhost) { - if (has_chghostmod == 1) { - if (!nick || !vhost) { - return; - } - send_cmd(s_OperServ, "CHGHOST %s %s", nick, vhost); - } else { + if (has_chghostmod == 1) { + if (!nick || !vhost) { + return; + } + send_cmd(s_OperServ, "CHGHOST %s %s", nick, vhost); + } else { ircdproto->SendGlobops(s_OperServ, "CHGHOST not loaded!"); - } + } } int anope_event_idle(const char *source, int ac, const char **av) { - if (ac == 1) { - send_cmd(av[0], "IDLE %s %ld 0", source, (long int) time(NULL)); - } - return MOD_CONT; + if (ac == 1) { + send_cmd(av[0], "IDLE %s %ld 0", source, (long int) time(NULL)); + } + return MOD_CONT; } static char currentpass[1024]; @@ -438,7 +438,7 @@ static char currentpass[1024]; /* PASS */ void inspircd_cmd_pass(const char *pass) { - strncpy(currentpass, pass, 1024); + strncpy(currentpass, pass, 1024); } @@ -695,623 +695,623 @@ class InspIRCdProto : public IRCDProto int anope_event_ftopic(const char *source, int ac, const char **av) { - /* :source FTOPIC channel ts setby :topic */ - const char *temp; - if (ac < 4) - return MOD_CONT; - temp = av[1]; /* temp now holds ts */ - av[1] = av[2]; /* av[1] now holds set by */ - av[2] = temp; /* av[2] now holds ts */ - do_topic(source, ac, av); - return MOD_CONT; + /* :source FTOPIC channel ts setby :topic */ + const char *temp; + if (ac < 4) + return MOD_CONT; + temp = av[1]; /* temp now holds ts */ + av[1] = av[2]; /* av[1] now holds set by */ + av[2] = temp; /* av[2] now holds ts */ + do_topic(source, ac, av); + return MOD_CONT; } int anope_event_mode(const char *source, int ac, const char **av) { - if (ac < 2) - return MOD_CONT; - - if (*av[0] == '#' || *av[0] == '&') { - do_cmode(source, ac, av); - } else { - /* InspIRCd lets opers change another - users modes, we have to kludge this - as it slightly breaks RFC1459 - */ - if (!strcasecmp(source, av[0])) { - do_umode(source, ac, av); - } else { - do_umode(av[0], ac, av); - } - } - return MOD_CONT; + if (ac < 2) + return MOD_CONT; + + if (*av[0] == '#' || *av[0] == '&') { + do_cmode(source, ac, av); + } else { + /* InspIRCd lets opers change another + users modes, we have to kludge this + as it slightly breaks RFC1459 + */ + if (!strcasecmp(source, av[0])) { + do_umode(source, ac, av); + } else { + do_umode(av[0], ac, av); + } + } + return MOD_CONT; } int anope_event_opertype(const char *source, int ac, const char **av) { - /* opertype is equivalent to mode +o because servers - dont do this directly */ - User *u; - u = finduser(source); - if (u && !is_oper(u)) { - const char *newav[2]; - newav[0] = source; - newav[1] = "+o"; - return anope_event_mode(source, 2, newav); - } else - return MOD_CONT; + /* opertype is equivalent to mode +o because servers + dont do this directly */ + User *u; + u = finduser(source); + if (u && !is_oper(u)) { + const char *newav[2]; + newav[0] = source; + newav[1] = "+o"; + return anope_event_mode(source, 2, newav); + } else + return MOD_CONT; } int anope_event_fmode(const char *source, int ac, const char **av) { - const char *newav[25]; - int n, o; - Channel *c; - - /* :source FMODE #test 12345678 +nto foo */ - if (ac < 3) - return MOD_CONT; - - /* Checking the TS for validity to avoid desyncs */ - if ((c = findchan(av[0]))) { - if (c->creation_time > strtol(av[1], NULL, 10)) { - /* Our TS is bigger, we should lower it */ - c->creation_time = strtol(av[1], NULL, 10); - } else if (c->creation_time < strtol(av[1], NULL, 10)) { - /* The TS we got is bigger, we should ignore this message. */ - return MOD_CONT; - } - } else { - /* Got FMODE for a non-existing channel */ - return MOD_CONT; - } - - /* TS's are equal now, so we can proceed with parsing */ - n = o = 0; - while (n < ac) { - if (n != 1) { - newav[o] = av[n]; - o++; - if (debug) - alog("Param: %s", newav[o - 1]); - } - n++; - } - - return anope_event_mode(source, ac - 1, newav); + const char *newav[25]; + int n, o; + Channel *c; + + /* :source FMODE #test 12345678 +nto foo */ + if (ac < 3) + return MOD_CONT; + + /* Checking the TS for validity to avoid desyncs */ + if ((c = findchan(av[0]))) { + if (c->creation_time > strtol(av[1], NULL, 10)) { + /* Our TS is bigger, we should lower it */ + c->creation_time = strtol(av[1], NULL, 10); + } else if (c->creation_time < strtol(av[1], NULL, 10)) { + /* The TS we got is bigger, we should ignore this message. */ + return MOD_CONT; + } + } else { + /* Got FMODE for a non-existing channel */ + return MOD_CONT; + } + + /* TS's are equal now, so we can proceed with parsing */ + n = o = 0; + while (n < ac) { + if (n != 1) { + newav[o] = av[n]; + o++; + if (debug) + alog("Param: %s", newav[o - 1]); + } + n++; + } + + return anope_event_mode(source, ac - 1, newav); } int anope_event_fjoin(const char *source, int ac, const char **av) { - const char *newav[10]; - - /* value used for myStrGetToken */ - int curtoken = 0; - - /* storing the current nick */ - char *curnick; - - /* these are used to generate the final string that is passed to ircservices' core */ - int nlen = 0; - char nicklist[514]; - - /* temporary buffer */ - char prefixandnick[60]; - - *nicklist = '\0'; - *prefixandnick = '\0'; - - if (ac < 3) - return MOD_CONT; - - curnick = myStrGetToken(av[2], ' ', curtoken); - while (curnick != NULL) { - for (; *curnick; curnick++) { - /* I bet theres a better way to do this... */ - if ((*curnick == '&') || - (*curnick == '~') || (*curnick == '@') || (*curnick == '%') - || (*curnick == '+')) { - prefixandnick[nlen++] = *curnick; - continue; - } else { - if (*curnick == ',') { - curnick++; - strncpy(prefixandnick + nlen, curnick, - sizeof(prefixandnick) - nlen); - break; - } else { - alog("fjoin: unrecognised prefix: %c", *curnick); - } - } - } - strncat(nicklist, prefixandnick, 513); - strncat(nicklist, " ", 513); - curtoken++; - curnick = myStrGetToken(av[2], ' ', curtoken); - nlen = 0; - } - - newav[0] = av[1]; /* timestamp */ - newav[1] = av[0]; /* channel name */ - newav[2] = "+"; /* channel modes */ - newav[3] = nicklist; - do_sjoin(source, 4, newav); - - return MOD_CONT; + const char *newav[10]; + + /* value used for myStrGetToken */ + int curtoken = 0; + + /* storing the current nick */ + char *curnick; + + /* these are used to generate the final string that is passed to ircservices' core */ + int nlen = 0; + char nicklist[514]; + + /* temporary buffer */ + char prefixandnick[60]; + + *nicklist = '\0'; + *prefixandnick = '\0'; + + if (ac < 3) + return MOD_CONT; + + curnick = myStrGetToken(av[2], ' ', curtoken); + while (curnick != NULL) { + for (; *curnick; curnick++) { + /* I bet theres a better way to do this... */ + if ((*curnick == '&') || + (*curnick == '~') || (*curnick == '@') || (*curnick == '%') + || (*curnick == '+')) { + prefixandnick[nlen++] = *curnick; + continue; + } else { + if (*curnick == ',') { + curnick++; + strncpy(prefixandnick + nlen, curnick, + sizeof(prefixandnick) - nlen); + break; + } else { + alog("fjoin: unrecognised prefix: %c", *curnick); + } + } + } + strncat(nicklist, prefixandnick, 513); + strncat(nicklist, " ", 513); + curtoken++; + curnick = myStrGetToken(av[2], ' ', curtoken); + nlen = 0; + } + + newav[0] = av[1]; /* timestamp */ + newav[1] = av[0]; /* channel name */ + newav[2] = "+"; /* channel modes */ + newav[3] = nicklist; + do_sjoin(source, 4, newav); + + return MOD_CONT; } /* Events */ int anope_event_ping(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - ircdproto->SendPong(ServerName, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + ircdproto->SendPong(ServerName, av[0]); + return MOD_CONT; } int anope_event_436(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; + if (ac < 1) + return MOD_CONT; - m_nickcoll(av[0]); - return MOD_CONT; + m_nickcoll(av[0]); + return MOD_CONT; } int anope_event_away(const char *source, int ac, const char **av) { - if (!source) { - return MOD_CONT; - } - m_away(source, (ac ? av[0] : NULL)); - return MOD_CONT; + if (!source) { + return MOD_CONT; + } + m_away(source, (ac ? av[0] : NULL)); + return MOD_CONT; } /* Taken from hybrid.c, topic syntax is identical */ int anope_event_topic(const char *source, int ac, const char **av) { - Channel *c = findchan(av[0]); - time_t topic_time = time(NULL); - - if (!c) { - if (debug) { - alog("debug: TOPIC %s for nonexistent channel %s", - merge_args(ac - 1, av + 1), av[0]); - } - return MOD_CONT; - } - - if (check_topiclock(c, topic_time)) - return MOD_CONT; - - if (c->topic) { - free(c->topic); - c->topic = NULL; - } - if (ac > 1 && *av[1]) - c->topic = sstrdup(av[1]); - - strscpy(c->topic_setter, source, sizeof(c->topic_setter)); - c->topic_time = topic_time; - - record_topic(av[0]); - - if (ac > 1 && *av[1]) - send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[1]); - else - send_event(EVENT_TOPIC_UPDATED, 2, av[0], ""); - - return MOD_CONT; + Channel *c = findchan(av[0]); + time_t topic_time = time(NULL); + + if (!c) { + if (debug) { + alog("debug: TOPIC %s for nonexistent channel %s", + merge_args(ac - 1, av + 1), av[0]); + } + return MOD_CONT; + } + + if (check_topiclock(c, topic_time)) + return MOD_CONT; + + if (c->topic) { + free(c->topic); + c->topic = NULL; + } + if (ac > 1 && *av[1]) + c->topic = sstrdup(av[1]); + + strscpy(c->topic_setter, source, sizeof(c->topic_setter)); + c->topic_time = topic_time; + + record_topic(av[0]); + + if (ac > 1 && *av[1]) + send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[1]); + else + send_event(EVENT_TOPIC_UPDATED, 2, av[0], ""); + + return MOD_CONT; } int anope_event_squit(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; - do_squit(source, ac, av); - return MOD_CONT; + if (ac != 2) + return MOD_CONT; + do_squit(source, ac, av); + return MOD_CONT; } int anope_event_rsquit(const char *source, int ac, const char **av) { - if (ac < 1 || ac > 3) - return MOD_CONT; + if (ac < 1 || ac > 3) + return MOD_CONT; - /* Horrible workaround to an insp bug (#) in how RSQUITs are sent - mark */ - if (ac > 1 && strcmp(ServerName, av[0]) == 0) - do_squit(source, ac - 1, av + 1); - else - do_squit(source, ac, av); + /* Horrible workaround to an insp bug (#) in how RSQUITs are sent - mark */ + if (ac > 1 && strcmp(ServerName, av[0]) == 0) + do_squit(source, ac - 1, av + 1); + else + do_squit(source, ac, av); - return MOD_CONT; + return MOD_CONT; } int anope_event_quit(const char *source, int ac, const char **av) { - if (ac != 1) - return MOD_CONT; - do_quit(source, ac, av); - return MOD_CONT; + if (ac != 1) + return MOD_CONT; + do_quit(source, ac, av); + return MOD_CONT; } int anope_event_kill(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - m_kill(av[0], av[1]); - return MOD_CONT; + m_kill(av[0], av[1]); + return MOD_CONT; } int anope_event_kick(const char *source, int ac, const char **av) { - if (ac != 3) - return MOD_CONT; - do_kick(source, ac, av); - return MOD_CONT; + if (ac != 3) + return MOD_CONT; + do_kick(source, ac, av); + return MOD_CONT; } int anope_event_join(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; - do_join(source, ac, av); - return MOD_CONT; + if (ac != 2) + return MOD_CONT; + do_join(source, ac, av); + return MOD_CONT; } int anope_event_motd(const char *source, int ac, const char **av) { - if (!source) { - return MOD_CONT; - } + if (!source) { + return MOD_CONT; + } - m_motd(source); - return MOD_CONT; + m_motd(source); + return MOD_CONT; } int anope_event_setname(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 1) - return MOD_CONT; + if (ac != 1) + return MOD_CONT; - u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETNAME for nonexistent user %s", source); - } - return MOD_CONT; - } + u = finduser(source); + if (!u) { + if (debug) { + alog("debug: SETNAME for nonexistent user %s", source); + } + return MOD_CONT; + } - u->SetRealname(av[0]); - return MOD_CONT; + u->SetRealname(av[0]); + return MOD_CONT; } int anope_event_chgname(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - u = finduser(source); - if (!u) { - if (debug) { - alog("debug: FNAME for nonexistent user %s", source); - } - return MOD_CONT; - } + u = finduser(source); + if (!u) { + if (debug) { + alog("debug: FNAME for nonexistent user %s", source); + } + return MOD_CONT; + } - u->SetRealname(av[0]); - return MOD_CONT; + u->SetRealname(av[0]); + return MOD_CONT; } int anope_event_setident(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 1) - return MOD_CONT; + if (ac != 1) + return MOD_CONT; - u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETIDENT for nonexistent user %s", source); - } - return MOD_CONT; - } + u = finduser(source); + if (!u) { + if (debug) { + alog("debug: SETIDENT for nonexistent user %s", source); + } + return MOD_CONT; + } - u->SetIdent(av[0]); - return MOD_CONT; + u->SetIdent(av[0]); + return MOD_CONT; } int anope_event_chgident(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - u = finduser(av[0]); - if (!u) { - if (debug) { - alog("debug: CHGIDENT for nonexistent user %s", av[0]); - } - return MOD_CONT; - } + u = finduser(av[0]); + if (!u) { + if (debug) { + alog("debug: CHGIDENT for nonexistent user %s", av[0]); + } + return MOD_CONT; + } - u->SetIdent(av[1]); - return MOD_CONT; + u->SetIdent(av[1]); + return MOD_CONT; } int anope_event_sethost(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 1) - return MOD_CONT; + if (ac != 1) + return MOD_CONT; - u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETHOST for nonexistent user %s", source); - } - return MOD_CONT; - } + u = finduser(source); + if (!u) { + if (debug) { + alog("debug: SETHOST for nonexistent user %s", source); + } + return MOD_CONT; + } - u->SetDisplayedHost(av[0]); - return MOD_CONT; + u->SetDisplayedHost(av[0]); + return MOD_CONT; } int anope_event_nick(const char *source, int ac, const char **av) { - User *user; - struct in_addr addy; - uint32 *ad = (uint32 *) & addy; + User *user; + struct in_addr addy; + uint32 *ad = (uint32 *) & addy; - if (ac != 1) { - if (ac == 8) { + if (ac != 1) { + if (ac == 8) { int svid = 0; int ts = strtoul(av[0], NULL, 10); if (strchr(av[5], 'r') != NULL) svid = ts; - inet_aton(av[6], &addy); - user = do_nick("", av[1], /* nick */ - av[4], /* username */ - av[2], /* realhost */ - source, /* server */ - av[7], /* realname */ - ts, svid, htonl(*ad), av[3], NULL); - if (user) { - ircdproto->ProcessUsermodes(user, 1, &av[5]); + inet_aton(av[6], &addy); + user = do_nick("", av[1], /* nick */ + av[4], /* username */ + av[2], /* realhost */ + source, /* server */ + av[7], /* realname */ + ts, svid, htonl(*ad), av[3], NULL); + if (user) { + ircdproto->ProcessUsermodes(user, 1, &av[5]); user->chost = av[3]; } - } - } else { - do_nick(source, av[0], NULL, NULL, NULL, NULL, 0, 0, 0, NULL, - NULL); - } - return MOD_CONT; + } + } else { + do_nick(source, av[0], NULL, NULL, NULL, NULL, 0, 0, 0, NULL, + NULL); + } + return MOD_CONT; } int anope_event_chghost(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 1) - return MOD_CONT; + if (ac != 1) + return MOD_CONT; - u = finduser(source); - if (!u) { - if (debug) { - alog("debug: FHOST for nonexistent user %s", source); - } - return MOD_CONT; - } + u = finduser(source); + if (!u) { + if (debug) { + alog("debug: FHOST for nonexistent user %s", source); + } + return MOD_CONT; + } - u->SetDisplayedHost(av[0]); - return MOD_CONT; + u->SetDisplayedHost(av[0]); + return MOD_CONT; } /* EVENT: SERVER */ int anope_event_server(const char *source, int ac, const char **av) { - if (!stricmp(av[1], "1")) { - uplink = sstrdup(av[0]); - } - do_server(source, av[0], av[1], av[2], NULL); - return MOD_CONT; + if (!stricmp(av[1], "1")) { + uplink = sstrdup(av[0]); + } + do_server(source, av[0], av[1], av[2], NULL); + return MOD_CONT; } int anope_event_privmsg(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; - m_privmsg(source, av[0], av[1]); - return MOD_CONT; + if (ac != 2) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; } int anope_event_part(const char *source, int ac, const char **av) { - if (ac < 1 || ac > 2) - return MOD_CONT; - do_part(source, ac, av); - return MOD_CONT; + if (ac < 1 || ac > 2) + return MOD_CONT; + do_part(source, ac, av); + return MOD_CONT; } int anope_event_whois(const char *source, int ac, const char **av) { - if (source && ac >= 1) { - m_whois(source, av[0]); - } - return MOD_CONT; + if (source && ac >= 1) { + m_whois(source, av[0]); + } + return MOD_CONT; } int anope_event_capab(const char *source, int ac, const char **av) { - int argc; - CBModeInfo *cbmi; + int argc; + CBModeInfo *cbmi; - if (strcasecmp(av[0], "START") == 0) { - /* reset CAPAB */ - has_servicesmod = 0; - has_globopsmod = 0; + if (strcasecmp(av[0], "START") == 0) { + /* reset CAPAB */ + has_servicesmod = 0; + has_globopsmod = 0; has_svsholdmod = 0; has_chghostmod = 0; has_chgidentmod = 0; - } else if (strcasecmp(av[0], "MODULES") == 0) { - if (strstr(av[1], "m_globops.so")) { - has_globopsmod = 1; - } - if (strstr(av[1], "m_services.so")) { - has_servicesmod = 1; - } + } else if (strcasecmp(av[0], "MODULES") == 0) { + if (strstr(av[1], "m_globops.so")) { + has_globopsmod = 1; + } + if (strstr(av[1], "m_services.so")) { + has_servicesmod = 1; + } if (strstr(av[1], "m_svshold.so")) { - has_svsholdmod = 1; - } + has_svsholdmod = 1; + } if (strstr(av[1], "m_chghost.so")) { - has_chghostmod = 1; - } + has_chghostmod = 1; + } if (strstr(av[1], "m_chgident.so")) { - has_chgidentmod = 1; - } - if (strstr(av[1], "m_messageflood.so")) { - has_messagefloodmod = 1; - } - if (strstr(av[1], "m_banexception.so")) { - has_banexceptionmod = 1; - } - if (strstr(av[1], "m_inviteexception.so")) { - has_inviteexceptionmod = 1; - } - } else if (strcasecmp(av[0], "END") == 0) { - if (!has_globopsmod) { - send_cmd(NULL, - "ERROR :m_globops is not loaded. This is required by Anope"); - quitmsg = "Remote server does not have the m_globops module loaded, and this is required."; - quitting = 1; - return MOD_STOP; - } - if (!has_servicesmod) { - send_cmd(NULL, - "ERROR :m_services is not loaded. This is required by Anope"); - quitmsg = "Remote server does not have the m_services module loaded, and this is required."; - quitting = 1; - return MOD_STOP; - } - if (!has_svsholdmod) { - ircdproto->SendGlobops(s_OperServ, "SVSHOLD missing, Usage disabled until module is loaded."); - } - if (!has_chghostmod) { - ircdproto->SendGlobops(s_OperServ, "CHGHOST missing, Usage disabled until module is loaded."); - } - if (!has_chgidentmod) { - ircdproto->SendGlobops(s_OperServ, "CHGIDENT missing, Usage disabled until module is loaded."); - } - if (has_messagefloodmod) { - cbmi = myCbmodeinfos; - - /* Find 'f' in myCbmodeinfos and add the relevant bits to myCbmodes and myCbmodeinfos - * to enable +f support if found. This is needed because we're really not set up to - * handle modular ircds which can have modes enabled/disabled as they please :( - mark - */ - while ((cbmi->mode != 'f')) { - cbmi++; - } - if (cbmi) { - cbmi->getvalue = get_flood; - cbmi->csgetvalue = cs_get_flood; - - myCbmodes['f'].flag = CMODE_f; - myCbmodes['f'].flags = 0; - myCbmodes['f'].setvalue = set_flood; - myCbmodes['f'].cssetvalue = cs_set_flood; - - pmodule_ircd_cbmodeinfos(myCbmodeinfos); - pmodule_ircd_cbmodes(myCbmodes); - - ircd->fmode = 1; - } - else { - alog("Support for channelmode +f can not be enabled"); - if (debug) { - alog("debug: 'f' missing from myCbmodeinfos"); - } - } - } - if (has_banexceptionmod) { - myCmmodes['e'].addmask = add_exception; - myCmmodes['e'].delmask = del_exception; - ircd->except = 1; - } - if (has_inviteexceptionmod) { - myCmmodes['I'].addmask = add_invite; - myCmmodes['I'].delmask = del_invite; - ircd->invitemode = 1; - } - ircd->svshold = has_svsholdmod; - - if (has_banexceptionmod || has_inviteexceptionmod) { - pmodule_ircd_cmmodes(myCmmodes); - } - - /* Generate a fake capabs parsing call so things like NOQUIT work - * fine. It's ugly, but it works.... - */ - argc = 6; + has_chgidentmod = 1; + } + if (strstr(av[1], "m_messageflood.so")) { + has_messagefloodmod = 1; + } + if (strstr(av[1], "m_banexception.so")) { + has_banexceptionmod = 1; + } + if (strstr(av[1], "m_inviteexception.so")) { + has_inviteexceptionmod = 1; + } + } else if (strcasecmp(av[0], "END") == 0) { + if (!has_globopsmod) { + send_cmd(NULL, + "ERROR :m_globops is not loaded. This is required by Anope"); + quitmsg = "Remote server does not have the m_globops module loaded, and this is required."; + quitting = 1; + return MOD_STOP; + } + if (!has_servicesmod) { + send_cmd(NULL, + "ERROR :m_services is not loaded. This is required by Anope"); + quitmsg = "Remote server does not have the m_services module loaded, and this is required."; + quitting = 1; + return MOD_STOP; + } + if (!has_svsholdmod) { + ircdproto->SendGlobops(s_OperServ, "SVSHOLD missing, Usage disabled until module is loaded."); + } + if (!has_chghostmod) { + ircdproto->SendGlobops(s_OperServ, "CHGHOST missing, Usage disabled until module is loaded."); + } + if (!has_chgidentmod) { + ircdproto->SendGlobops(s_OperServ, "CHGIDENT missing, Usage disabled until module is loaded."); + } + if (has_messagefloodmod) { + cbmi = myCbmodeinfos; + + /* Find 'f' in myCbmodeinfos and add the relevant bits to myCbmodes and myCbmodeinfos + * to enable +f support if found. This is needed because we're really not set up to + * handle modular ircds which can have modes enabled/disabled as they please :( - mark + */ + while ((cbmi->mode != 'f')) { + cbmi++; + } + if (cbmi) { + cbmi->getvalue = get_flood; + cbmi->csgetvalue = cs_get_flood; + + myCbmodes['f'].flag = CMODE_f; + myCbmodes['f'].flags = 0; + myCbmodes['f'].setvalue = set_flood; + myCbmodes['f'].cssetvalue = cs_set_flood; + + pmodule_ircd_cbmodeinfos(myCbmodeinfos); + pmodule_ircd_cbmodes(myCbmodes); + + ircd->fmode = 1; + } + else { + alog("Support for channelmode +f can not be enabled"); + if (debug) { + alog("debug: 'f' missing from myCbmodeinfos"); + } + } + } + if (has_banexceptionmod) { + myCmmodes['e'].addmask = add_exception; + myCmmodes['e'].delmask = del_exception; + ircd->except = 1; + } + if (has_inviteexceptionmod) { + myCmmodes['I'].addmask = add_invite; + myCmmodes['I'].delmask = del_invite; + ircd->invitemode = 1; + } + ircd->svshold = has_svsholdmod; + + if (has_banexceptionmod || has_inviteexceptionmod) { + pmodule_ircd_cmmodes(myCmmodes); + } + + /* Generate a fake capabs parsing call so things like NOQUIT work + * fine. It's ugly, but it works.... + */ + argc = 6; const char *argv[] = {"NOQUIT", "SSJ3", "NICK2", "VL", "TLKEXT", "UNCONNECT"}; - capab_parse(argc, argv); - } - return MOD_CONT; + capab_parse(argc, argv); + } + return MOD_CONT; } void moduleAddIRCDMsgs(void) { - Message *m; - - updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+a","-a"); - - m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); - m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); - m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); - m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); - m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); - m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); - m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); - m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); - m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); - m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); - m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); - m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); - m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); - m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); - m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); - m = createMessage("RSQUIT", anope_event_rsquit); addCoreMessage(IRCD,m); - m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); - m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); - m = createMessage("SVSMODE", anope_event_mode) ;addCoreMessage(IRCD,m); - m = createMessage("FHOST", anope_event_chghost); addCoreMessage(IRCD,m); - m = createMessage("CHGIDENT", anope_event_chgident); addCoreMessage(IRCD,m); - m = createMessage("FNAME", anope_event_chgname); addCoreMessage(IRCD,m); - m = createMessage("SETHOST", anope_event_sethost); addCoreMessage(IRCD,m); - m = createMessage("SETIDENT", anope_event_setident); addCoreMessage(IRCD,m); - m = createMessage("SETNAME", anope_event_setname); addCoreMessage(IRCD,m); - m = createMessage("FJOIN", anope_event_fjoin); addCoreMessage(IRCD,m); - m = createMessage("FMODE", anope_event_fmode); addCoreMessage(IRCD,m); - m = createMessage("FTOPIC", anope_event_ftopic); addCoreMessage(IRCD,m); - m = createMessage("OPERTYPE", anope_event_opertype); addCoreMessage(IRCD,m); - m = createMessage("IDLE", anope_event_idle); addCoreMessage(IRCD,m); + Message *m; + + updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+a","-a"); + + m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); + m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); + m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); + m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); + m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); + m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); + m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); + m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); + m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); + m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); + m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); + m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); + m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); + m = createMessage("RSQUIT", anope_event_rsquit); addCoreMessage(IRCD,m); + m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); + m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); + m = createMessage("SVSMODE", anope_event_mode) ;addCoreMessage(IRCD,m); + m = createMessage("FHOST", anope_event_chghost); addCoreMessage(IRCD,m); + m = createMessage("CHGIDENT", anope_event_chgident); addCoreMessage(IRCD,m); + m = createMessage("FNAME", anope_event_chgname); addCoreMessage(IRCD,m); + m = createMessage("SETHOST", anope_event_sethost); addCoreMessage(IRCD,m); + m = createMessage("SETIDENT", anope_event_setident); addCoreMessage(IRCD,m); + m = createMessage("SETNAME", anope_event_setname); addCoreMessage(IRCD,m); + m = createMessage("FJOIN", anope_event_fjoin); addCoreMessage(IRCD,m); + m = createMessage("FMODE", anope_event_fmode); addCoreMessage(IRCD,m); + m = createMessage("FTOPIC", anope_event_ftopic); addCoreMessage(IRCD,m); + m = createMessage("OPERTYPE", anope_event_opertype); addCoreMessage(IRCD,m); + m = createMessage("IDLE", anope_event_idle); addCoreMessage(IRCD,m); } diff --git a/src/protocol/inspircd12.cpp b/src/protocol/inspircd12.cpp index d70c2019d..d10da6392 100644 --- a/src/protocol/inspircd12.cpp +++ b/src/protocol/inspircd12.cpp @@ -64,338 +64,338 @@ #include "winsock.h" int inet_aton(const char *name, struct in_addr *addr) { - uint32 a = inet_addr(name); - addr->s_addr = a; - return a != (uint32) - 1; + uint32 a = inet_addr(name); + addr->s_addr = a; + return a != (uint32) - 1; } #endif IRCDVar myIrcd[] = { - {"InspIRCd 1.2", /* ircd name */ - "+I", /* Modes used by pseudoclients */ - 5, /* Chan Max Symbols */ - "-cilmnpstuzACGHKNOQRSV", /* Modes to Remove */ - "+ao", /* Channel Umode used by Botserv bots */ - 1, /* SVSNICK */ - 1, /* Vhost */ - 1, /* Has Owner */ - "+q", /* Mode to set for an owner */ - "-q", /* Mode to unset for an owner */ - "+a", /* Mode to set for channel admin */ - "-a", /* Mode to unset for channel admin */ - "+r", /* Mode On Reg */ - NULL, /* Mode on ID for Roots */ - NULL, /* Mode on ID for Admins */ - NULL, /* Mode on ID for Opers */ - "-r", /* Mode on UnReg */ - "-r", /* Mode on Nick Change */ - 1, /* Supports SGlines */ - 1, /* Supports SQlines */ - 1, /* Supports SZlines */ - 1, /* Supports Halfop +h */ - 4, /* Number of server args */ - 0, /* Join 2 Set */ - 1, /* Join 2 Message */ - 0, /* Has exceptions +e */ - 1, /* TS Topic Forward */ - 0, /* TS Topci Backward */ - 0, /* Protected Umode */ - 0, /* Has Admin */ - 0, /* Chan SQlines */ - 0, /* Quit on Kill */ - 0, /* SVSMODE unban */ - 1, /* Has Protect */ - 1, /* Reverse */ - 1, /* Chan Reg */ - CMODE_r, /* Channel Mode */ - 1, /* vidents */ - 0, /* svshold */ - 0, /* time stamp on mode */ - 0, /* NICKIP */ - 1, /* O:LINE */ - 1, /* UMODE */ - 1, /* VHOST ON NICK */ - 0, /* Change RealName */ - CMODE_K, /* No Knock */ - 0, /* Admin Only */ - DEFAULT_MLOCK, /* Default MLOCK */ - UMODE_x, /* Vhost Mode */ - 0, /* +f */ - 1, /* +L */ - CMODE_f, - CMODE_L, - 0, - 1, /* No Knock requires +i */ - NULL, /* CAPAB Chan Modes */ - 0, /* We support inspircd TOKENS */ - 0, /* TIME STAMPS are BASE64 */ - 0, /* +I support */ - 0, /* SJOIN ban char */ - 0, /* SJOIN except char */ - 0, /* SJOIN invite char */ - 0, /* Can remove User Channel Modes with SVSMODE */ - 0, /* Sglines are not enforced until user reconnects */ - "x", /* vhost char */ - 1, /* ts6 */ - 1, /* support helper umode */ - 0, /* p10 */ - NULL, /* character set */ - 0, /* reports sync state */ - 1, /* CIDR channelbans */ - "$", /* TLD Prefix for Global */ - } - , - {NULL} + {"InspIRCd 1.2", /* ircd name */ + "+I", /* Modes used by pseudoclients */ + 5, /* Chan Max Symbols */ + "-cilmnpstuzACGHKNOQRSV", /* Modes to Remove */ + "+ao", /* Channel Umode used by Botserv bots */ + 1, /* SVSNICK */ + 1, /* Vhost */ + 1, /* Has Owner */ + "+q", /* Mode to set for an owner */ + "-q", /* Mode to unset for an owner */ + "+a", /* Mode to set for channel admin */ + "-a", /* Mode to unset for channel admin */ + "+r", /* Mode On Reg */ + NULL, /* Mode on ID for Roots */ + NULL, /* Mode on ID for Admins */ + NULL, /* Mode on ID for Opers */ + "-r", /* Mode on UnReg */ + "-r", /* Mode on Nick Change */ + 1, /* Supports SGlines */ + 1, /* Supports SQlines */ + 1, /* Supports SZlines */ + 1, /* Supports Halfop +h */ + 4, /* Number of server args */ + 0, /* Join 2 Set */ + 1, /* Join 2 Message */ + 0, /* Has exceptions +e */ + 1, /* TS Topic Forward */ + 0, /* TS Topci Backward */ + 0, /* Protected Umode */ + 0, /* Has Admin */ + 0, /* Chan SQlines */ + 0, /* Quit on Kill */ + 0, /* SVSMODE unban */ + 1, /* Has Protect */ + 1, /* Reverse */ + 1, /* Chan Reg */ + CMODE_r, /* Channel Mode */ + 1, /* vidents */ + 0, /* svshold */ + 0, /* time stamp on mode */ + 0, /* NICKIP */ + 1, /* O:LINE */ + 1, /* UMODE */ + 1, /* VHOST ON NICK */ + 0, /* Change RealName */ + CMODE_K, /* No Knock */ + 0, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + UMODE_x, /* Vhost Mode */ + 0, /* +f */ + 1, /* +L */ + CMODE_f, + CMODE_L, + 0, + 1, /* No Knock requires +i */ + NULL, /* CAPAB Chan Modes */ + 0, /* We support inspircd TOKENS */ + 0, /* TIME STAMPS are BASE64 */ + 0, /* +I support */ + 0, /* SJOIN ban char */ + 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ + 0, /* Can remove User Channel Modes with SVSMODE */ + 0, /* Sglines are not enforced until user reconnects */ + "x", /* vhost char */ + 1, /* ts6 */ + 1, /* support helper umode */ + 0, /* p10 */ + NULL, /* character set */ + 0, /* reports sync state */ + 1, /* CIDR channelbans */ + "$", /* TLD Prefix for Global */ + } + , + {NULL} }; IRCDCAPAB myIrcdcap[] = { - { - CAPAB_NOQUIT, /* NOQUIT */ - 0, /* TSMODE */ - 1, /* UNCONNECT */ - 0, /* NICKIP */ - 0, /* SJOIN */ - 0, /* ZIP */ - 0, /* BURST */ - 0, /* TS5 */ - 0, /* TS3 */ - 0, /* DKEY */ - 0, /* PT4 */ - 0, /* SCS */ - 0, /* QS */ - 0, /* UID */ - 0, /* KNOCK */ - 0, /* CLIENT */ - 0, /* IPV6 */ - 0, /* SSJ5 */ - 0, /* SN2 */ - 0, /* TOKEN */ - 0, /* VHOST */ - CAPAB_SSJ3, /* SSJ3 */ - CAPAB_NICK2, /* NICK2 */ - 0, /* UMODE2 */ - CAPAB_VL, /* VL */ - CAPAB_TLKEXT, /* TLKEXT */ - 0, /* DODKEY */ - 0, /* DOZIP */ - 0, - 0, 0} + { + CAPAB_NOQUIT, /* NOQUIT */ + 0, /* TSMODE */ + 1, /* UNCONNECT */ + 0, /* NICKIP */ + 0, /* SJOIN */ + 0, /* ZIP */ + 0, /* BURST */ + 0, /* TS5 */ + 0, /* TS3 */ + 0, /* DKEY */ + 0, /* PT4 */ + 0, /* SCS */ + 0, /* QS */ + 0, /* UID */ + 0, /* KNOCK */ + 0, /* CLIENT */ + 0, /* IPV6 */ + 0, /* SSJ5 */ + 0, /* SN2 */ + 0, /* TOKEN */ + 0, /* VHOST */ + CAPAB_SSJ3, /* SSJ3 */ + CAPAB_NICK2, /* NICK2 */ + 0, /* UMODE2 */ + CAPAB_VL, /* VL */ + CAPAB_TLKEXT, /* TLKEXT */ + 0, /* DODKEY */ + 0, /* DOZIP */ + 0, + 0, 0} }; unsigned long umodes[128] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, UMODE_A, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, - 0, 0, 0, 0, 0, 0, 0, - 0, - 0, 0, 0, 0, 0, - 0, UMODE_a, 0, 0, 0, 0, 0, - UMODE_g, - UMODE_h, UMODE_i, 0, 0, 0, 0, 0, UMODE_o, - 0, - 0, UMODE_r, 0, 0, 0, 0, UMODE_w, - UMODE_x, - 0, - 0, - 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, UMODE_A, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, + 0, + 0, + 0, 0, 0, 0, 0, 0, 0, + 0, + 0, 0, 0, 0, 0, + 0, UMODE_a, 0, 0, 0, 0, 0, + UMODE_g, + UMODE_h, UMODE_i, 0, 0, 0, 0, 0, UMODE_o, + 0, + 0, UMODE_r, 0, 0, 0, 0, UMODE_w, + UMODE_x, + 0, + 0, + 0, 0, 0, 0, 0 }; char myCsmodes[128] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, 0, 0, - 'h', /* (37) % Channel halfops */ - 'a', - 0, 0, 0, 0, + 0, + 0, + 0, 0, 0, + 'h', /* (37) % Channel halfops */ + 'a', + 0, 0, 0, 0, - 'v', 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'v', 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'q', 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'q', 0 }; CMMode myCmmodes[128] = { - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, - {NULL}, - {add_ban, del_ban}, - {NULL}, - {NULL}, - {NULL, NULL}, - {NULL}, - {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, + {NULL}, + {add_ban, del_ban}, + {NULL}, + {NULL}, + {NULL, NULL}, + {NULL}, + {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} }; CBMode myCbmodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, - {CMODE_A, CBM_NO_USER_MLOCK, NULL, NULL}, - {0}, /* B */ - {CMODE_C, 0, NULL, NULL}, /* C */ - {0}, /* D */ - {0}, /* E */ - {0}, /* F */ - {CMODE_G, 0, NULL, NULL}, /* G */ - {CMODE_H, CBM_NO_USER_MLOCK, NULL, NULL}, - {0}, /* I */ - {0}, /* J */ - {CMODE_K, 0, NULL, NULL}, /* K */ - {CMODE_L, 0, set_redirect, cs_set_redirect}, - {0}, /* M */ - {CMODE_N, 0, NULL, NULL}, /* N */ - {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, - {0}, /* P */ - {CMODE_Q, 0, NULL, NULL}, /* Q */ - {CMODE_R, 0, NULL, NULL}, /* R */ - {CMODE_S, 0, NULL, NULL}, /* S */ - {0}, /* T */ - {0}, /* U */ - {CMODE_V, 0, NULL, NULL}, /* V */ - {0}, /* W */ - {0}, /* X */ - {0}, /* Y */ - {0}, /* Z */ - {0}, {0}, {0}, {0}, {0}, {0}, - {0}, /* a */ - {0}, /* b */ - {CMODE_c, 0, NULL, NULL}, - {0}, /* d */ - {0}, /* e */ - {0}, /* f */ - {0}, /* g */ - {0}, /* h */ - {CMODE_i, 0, NULL, NULL}, - {0}, /* j */ - {CMODE_k, 0, chan_set_key, cs_set_key}, - {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, - {CMODE_m, 0, NULL, NULL}, - {CMODE_n, 0, NULL, NULL}, - {0}, /* o */ - {CMODE_p, 0, NULL, NULL}, - {0}, /* q */ - {CMODE_r, CBM_NO_MLOCK, NULL, NULL}, - {CMODE_s, 0, NULL, NULL}, - {CMODE_t, 0, NULL, NULL}, - {CMODE_u, 0, NULL, NULL}, - {0}, /* v */ - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {CMODE_z, 0, NULL, NULL}, - {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, + {CMODE_A, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* B */ + {CMODE_C, 0, NULL, NULL}, /* C */ + {0}, /* D */ + {0}, /* E */ + {0}, /* F */ + {CMODE_G, 0, NULL, NULL}, /* G */ + {CMODE_H, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* I */ + {0}, /* J */ + {CMODE_K, 0, NULL, NULL}, /* K */ + {CMODE_L, 0, set_redirect, cs_set_redirect}, + {0}, /* M */ + {CMODE_N, 0, NULL, NULL}, /* N */ + {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* P */ + {CMODE_Q, 0, NULL, NULL}, /* Q */ + {CMODE_R, 0, NULL, NULL}, /* R */ + {CMODE_S, 0, NULL, NULL}, /* S */ + {0}, /* T */ + {0}, /* U */ + {CMODE_V, 0, NULL, NULL}, /* V */ + {0}, /* W */ + {0}, /* X */ + {0}, /* Y */ + {0}, /* Z */ + {0}, {0}, {0}, {0}, {0}, {0}, + {0}, /* a */ + {0}, /* b */ + {CMODE_c, 0, NULL, NULL}, + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {0}, /* h */ + {CMODE_i, 0, NULL, NULL}, + {0}, /* j */ + {CMODE_k, 0, chan_set_key, cs_set_key}, + {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, + {CMODE_m, 0, NULL, NULL}, + {CMODE_n, 0, NULL, NULL}, + {0}, /* o */ + {CMODE_p, 0, NULL, NULL}, + {0}, /* q */ + {CMODE_r, CBM_NO_MLOCK, NULL, NULL}, + {CMODE_s, 0, NULL, NULL}, + {CMODE_t, 0, NULL, NULL}, + {CMODE_u, 0, NULL, NULL}, + {0}, /* v */ + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {CMODE_z, 0, NULL, NULL}, + {0}, {0}, {0}, {0} }; CBModeInfo myCbmodeinfos[] = { - {'f', CMODE_f, 0, NULL, NULL}, - {'c', CMODE_c, 0, NULL, NULL}, - {'i', CMODE_i, 0, NULL, NULL}, - {'k', CMODE_k, 0, get_key, cs_get_key}, - {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, - {'m', CMODE_m, 0, NULL, NULL}, - {'n', CMODE_n, 0, NULL, NULL}, - {'p', CMODE_p, 0, NULL, NULL}, - {'r', CMODE_r, 0, NULL, NULL}, - {'s', CMODE_s, 0, NULL, NULL}, - {'t', CMODE_t, 0, NULL, NULL}, - {'u', CMODE_u, 0, NULL, NULL}, - {'z', CMODE_z, 0, NULL, NULL}, - {'A', CMODE_A, 0, NULL, NULL}, - {'C', CMODE_C, 0, NULL, NULL}, - {'G', CMODE_G, 0, NULL, NULL}, - {'H', CMODE_H, 0, NULL, NULL}, - {'K', CMODE_K, 0, NULL, NULL}, - {'L', CMODE_L, 0, get_redirect, cs_get_redirect}, - {'N', CMODE_N, 0, NULL, NULL}, - {'O', CMODE_O, 0, NULL, NULL}, - {'Q', CMODE_Q, 0, NULL, NULL}, - {'R', CMODE_R, 0, NULL, NULL}, - {'S', CMODE_S, 0, NULL, NULL}, - {'V', CMODE_V, 0, NULL, NULL}, - {0} + {'f', CMODE_f, 0, NULL, NULL}, + {'c', CMODE_c, 0, NULL, NULL}, + {'i', CMODE_i, 0, NULL, NULL}, + {'k', CMODE_k, 0, get_key, cs_get_key}, + {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, + {'m', CMODE_m, 0, NULL, NULL}, + {'n', CMODE_n, 0, NULL, NULL}, + {'p', CMODE_p, 0, NULL, NULL}, + {'r', CMODE_r, 0, NULL, NULL}, + {'s', CMODE_s, 0, NULL, NULL}, + {'t', CMODE_t, 0, NULL, NULL}, + {'u', CMODE_u, 0, NULL, NULL}, + {'z', CMODE_z, 0, NULL, NULL}, + {'A', CMODE_A, 0, NULL, NULL}, + {'C', CMODE_C, 0, NULL, NULL}, + {'G', CMODE_G, 0, NULL, NULL}, + {'H', CMODE_H, 0, NULL, NULL}, + {'K', CMODE_K, 0, NULL, NULL}, + {'L', CMODE_L, 0, get_redirect, cs_get_redirect}, + {'N', CMODE_N, 0, NULL, NULL}, + {'O', CMODE_O, 0, NULL, NULL}, + {'Q', CMODE_Q, 0, NULL, NULL}, + {'R', CMODE_R, 0, NULL, NULL}, + {'S', CMODE_S, 0, NULL, NULL}, + {'V', CMODE_V, 0, NULL, NULL}, + {0} }; CUMode myCumodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, - - {CUS_PROTECT, CUF_PROTECT_BOTSERV, check_valid_op}, - {0}, /* b */ - {0}, /* c */ - {0}, /* d */ - {0}, /* e */ - {0}, /* f */ - {0}, /* g */ - {CUS_HALFOP, 0, check_valid_op}, - {0}, /* i */ - {0}, /* j */ - {0}, /* k */ - {0}, /* l */ - {0}, /* m */ - {0}, /* n */ - {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, - {0}, /* p */ - {CUS_OWNER, 0, check_valid_op}, - {0}, /* r */ - {0}, /* s */ - {0}, /* t */ - {0}, /* u */ - {CUS_VOICE, 0, NULL}, - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {0}, /* z */ - {0}, {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, + + {CUS_PROTECT, CUF_PROTECT_BOTSERV, check_valid_op}, + {0}, /* b */ + {0}, /* c */ + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {CUS_HALFOP, 0, check_valid_op}, + {0}, /* i */ + {0}, /* j */ + {0}, /* k */ + {0}, /* l */ + {0}, /* m */ + {0}, /* n */ + {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, + {0}, /* p */ + {CUS_OWNER, 0, check_valid_op}, + {0}, /* r */ + {0}, /* s */ + {0}, /* t */ + {0}, /* u */ + {CUS_VOICE, 0, NULL}, + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0}, {0} }; static int has_servicesmod = 0; @@ -440,7 +440,7 @@ static char currentpass[1024]; /* PASS */ void inspircd_cmd_pass(const char *pass) { - strncpy(currentpass, pass, 1024); + strncpy(currentpass, pass, 1024); } @@ -702,87 +702,87 @@ class InspIRCdProto : public IRCDProto int anope_event_ftopic(const char *source, int ac, const char **av) { - /* :source FTOPIC channel ts setby :topic */ - const char *temp; - if (ac < 4) - return MOD_CONT; - temp = av[1]; /* temp now holds ts */ - av[1] = av[2]; /* av[1] now holds set by */ - av[2] = temp; /* av[2] now holds ts */ - do_topic(source, ac, av); - return MOD_CONT; + /* :source FTOPIC channel ts setby :topic */ + const char *temp; + if (ac < 4) + return MOD_CONT; + temp = av[1]; /* temp now holds ts */ + av[1] = av[2]; /* av[1] now holds set by */ + av[2] = temp; /* av[2] now holds ts */ + do_topic(source, ac, av); + return MOD_CONT; } int anope_event_mode(const char *source, int ac, const char **av) { - if (*av[0] == '#' || *av[0] == '&') { - do_cmode(source, ac, av); - } else { - /* InspIRCd lets opers change another - users modes, we have to kludge this - as it slightly breaks RFC1459 - */ - if (!strcasecmp(source, av[0])) { - do_umode(source, ac, av); - } else { - do_umode(av[0], ac, av); - } - } - return MOD_CONT; + if (*av[0] == '#' || *av[0] == '&') { + do_cmode(source, ac, av); + } else { + /* InspIRCd lets opers change another + users modes, we have to kludge this + as it slightly breaks RFC1459 + */ + if (!strcasecmp(source, av[0])) { + do_umode(source, ac, av); + } else { + do_umode(av[0], ac, av); + } + } + return MOD_CONT; } int anope_event_opertype(const char *source, int ac, const char **av) { - /* opertype is equivalent to mode +o because servers - dont do this directly */ - User *u; - u = finduser(source); - if (u && !is_oper(u)) { - const char *newav[2]; - newav[0] = source; - newav[1] = "+o"; - return anope_event_mode(source, 2, newav); - } else - return MOD_CONT; + /* opertype is equivalent to mode +o because servers + dont do this directly */ + User *u; + u = finduser(source); + if (u && !is_oper(u)) { + const char *newav[2]; + newav[0] = source; + newav[1] = "+o"; + return anope_event_mode(source, 2, newav); + } else + return MOD_CONT; } int anope_event_fmode(const char *source, int ac, const char **av) { - const char *newav[25]; - int n, o; - Channel *c; - - /* :source FMODE #test 12345678 +nto foo */ - if (ac < 3) - return MOD_CONT; - - /* Checking the TS for validity to avoid desyncs */ - if ((c = findchan(av[0]))) { - if (c->creation_time > strtol(av[1], NULL, 10)) { - /* Our TS is bigger, we should lower it */ - c->creation_time = strtol(av[1], NULL, 10); - } else if (c->creation_time < strtol(av[1], NULL, 10)) { - /* The TS we got is bigger, we should ignore this message. */ - return MOD_CONT; - } - } else { - /* Got FMODE for a non-existing channel */ - return MOD_CONT; - } - - /* TS's are equal now, so we can proceed with parsing */ - n = o = 0; - while (n < ac) { - if (n != 1) { - newav[o] = av[n]; - o++; - if (debug) - alog("Param: %s", newav[o - 1]); - } - n++; - } - - return anope_event_mode(source, ac - 1, newav); + const char *newav[25]; + int n, o; + Channel *c; + + /* :source FMODE #test 12345678 +nto foo */ + if (ac < 3) + return MOD_CONT; + + /* Checking the TS for validity to avoid desyncs */ + if ((c = findchan(av[0]))) { + if (c->creation_time > strtol(av[1], NULL, 10)) { + /* Our TS is bigger, we should lower it */ + c->creation_time = strtol(av[1], NULL, 10); + } else if (c->creation_time < strtol(av[1], NULL, 10)) { + /* The TS we got is bigger, we should ignore this message. */ + return MOD_CONT; + } + } else { + /* Got FMODE for a non-existing channel */ + return MOD_CONT; + } + + /* TS's are equal now, so we can proceed with parsing */ + n = o = 0; + while (n < ac) { + if (n != 1) { + newav[o] = av[n]; + o++; + if (debug) + alog("Param: %s", newav[o - 1]); + } + n++; + } + + return anope_event_mode(source, ac - 1, newav); } /* @@ -856,9 +856,9 @@ endnick: nlen = 0; } - newav[0] = av[1]; /* timestamp */ - newav[1] = av[0]; /* channel name */ - newav[2] = av[2]; /* channel modes */ // XXX: this is incorrect, it doesn't take into account +L etc, modes which require params.. call FMODE instead? -- w00t + newav[0] = av[1]; /* timestamp */ + newav[1] = av[0]; /* channel name */ + newav[2] = av[2]; /* channel modes */ // XXX: this is incorrect, it doesn't take into account +L etc, modes which require params.. call FMODE instead? -- w00t newav[3] = nicklist; do_sjoin(source, 4, newav); @@ -874,57 +874,57 @@ int anope_event_ping(const char *source, int ac, const char **av) int anope_event_436(const char *source, int ac, const char **av) { - m_nickcoll(av[0]); - return MOD_CONT; + m_nickcoll(av[0]); + return MOD_CONT; } int anope_event_away(const char *source, int ac, const char **av) { - m_away(source, (ac ? av[0] : NULL)); - return MOD_CONT; + m_away(source, (ac ? av[0] : NULL)); + return MOD_CONT; } /* Taken from hybrid.c, topic syntax is identical */ int anope_event_topic(const char *source, int ac, const char **av) { - Channel *c = findchan(av[0]); - time_t topic_time = time(NULL); - - if (!c) { - if (debug) { - alog("debug: TOPIC %s for nonexistent channel %s", - merge_args(ac - 1, av + 1), av[0]); - } - return MOD_CONT; - } - - if (check_topiclock(c, topic_time)) - return MOD_CONT; - - if (c->topic) { - free(c->topic); - c->topic = NULL; - } - if (ac > 1 && *av[1]) - c->topic = sstrdup(av[1]); - - strscpy(c->topic_setter, source, sizeof(c->topic_setter)); - c->topic_time = topic_time; - - record_topic(av[0]); - - if (ac > 1 && *av[1]) - send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[1]); - else - send_event(EVENT_TOPIC_UPDATED, 2, av[0], ""); - - return MOD_CONT; + Channel *c = findchan(av[0]); + time_t topic_time = time(NULL); + + if (!c) { + if (debug) { + alog("debug: TOPIC %s for nonexistent channel %s", + merge_args(ac - 1, av + 1), av[0]); + } + return MOD_CONT; + } + + if (check_topiclock(c, topic_time)) + return MOD_CONT; + + if (c->topic) { + free(c->topic); + c->topic = NULL; + } + if (ac > 1 && *av[1]) + c->topic = sstrdup(av[1]); + + strscpy(c->topic_setter, source, sizeof(c->topic_setter)); + c->topic_time = topic_time; + + record_topic(av[0]); + + if (ac > 1 && *av[1]) + send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[1]); + else + send_event(EVENT_TOPIC_UPDATED, 2, av[0], ""); + + return MOD_CONT; } int anope_event_squit(const char *source, int ac, const char **av) { - do_squit(source, ac, av); - return MOD_CONT; + do_squit(source, ac, av); + return MOD_CONT; } int anope_event_rsquit(const char *source, int ac, const char **av) @@ -935,121 +935,121 @@ int anope_event_rsquit(const char *source, int ac, const char **av) int anope_event_quit(const char *source, int ac, const char **av) { - do_quit(source, ac, av); - return MOD_CONT; + do_quit(source, ac, av); + return MOD_CONT; } int anope_event_kill(const char *source, int ac, const char **av) { - m_kill(av[0], av[1]); - return MOD_CONT; + m_kill(av[0], av[1]); + return MOD_CONT; } int anope_event_kick(const char *source, int ac, const char **av) { - do_kick(source, ac, av); - return MOD_CONT; + do_kick(source, ac, av); + return MOD_CONT; } int anope_event_join(const char *source, int ac, const char **av) { - do_join(source, ac, av); - return MOD_CONT; + do_join(source, ac, av); + return MOD_CONT; } int anope_event_motd(const char *source, int ac, const char **av) { - m_motd(source); - return MOD_CONT; + m_motd(source); + return MOD_CONT; } int anope_event_setname(const char *source, int ac, const char **av) { - User *u; - - u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETNAME for nonexistent user %s", source); - } - return MOD_CONT; - } - - u->SetRealname(av[0]); - return MOD_CONT; + User *u; + + u = finduser(source); + if (!u) { + if (debug) { + alog("debug: SETNAME for nonexistent user %s", source); + } + return MOD_CONT; + } + + u->SetRealname(av[0]); + return MOD_CONT; } int anope_event_chgname(const char *source, int ac, const char **av) { - User *u; - - u = finduser(source); - if (!u) { - if (debug) { - alog("debug: FNAME for nonexistent user %s", source); - } - return MOD_CONT; - } - - u->SetRealname(av[0]); - return MOD_CONT; + User *u; + + u = finduser(source); + if (!u) { + if (debug) { + alog("debug: FNAME for nonexistent user %s", source); + } + return MOD_CONT; + } + + u->SetRealname(av[0]); + return MOD_CONT; } int anope_event_setident(const char *source, int ac, const char **av) { - User *u; - - u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETIDENT for nonexistent user %s", source); - } - return MOD_CONT; - } - - u->SetIdent(av[0]); - return MOD_CONT; + User *u; + + u = finduser(source); + if (!u) { + if (debug) { + alog("debug: SETIDENT for nonexistent user %s", source); + } + return MOD_CONT; + } + + u->SetIdent(av[0]); + return MOD_CONT; } int anope_event_chgident(const char *source, int ac, const char **av) { - User *u; - - u = finduser(av[0]); - if (!u) { - if (debug) { - alog("debug: CHGIDENT for nonexistent user %s", av[0]); - } - return MOD_CONT; - } - - u->SetIdent(av[1]); - return MOD_CONT; + User *u; + + u = finduser(av[0]); + if (!u) { + if (debug) { + alog("debug: CHGIDENT for nonexistent user %s", av[0]); + } + return MOD_CONT; + } + + u->SetIdent(av[1]); + return MOD_CONT; } int anope_event_sethost(const char *source, int ac, const char **av) { - User *u; - - u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETHOST for nonexistent user %s", source); - } - return MOD_CONT; - } - - u->SetDisplayedHost(av[0]); - return MOD_CONT; + User *u; + + u = finduser(source); + if (!u) { + if (debug) { + alog("debug: SETHOST for nonexistent user %s", source); + } + return MOD_CONT; + } + + u->SetDisplayedHost(av[0]); + return MOD_CONT; } int anope_event_nick(const char *source, int ac, const char **av) { - do_nick(source, av[0], NULL, NULL, NULL, NULL, 0, 0, 0, NULL, NULL); - return MOD_CONT; + do_nick(source, av[0], NULL, NULL, NULL, NULL, 0, 0, 0, NULL, NULL); + return MOD_CONT; } @@ -1097,18 +1097,18 @@ int anope_event_uid(const char *source, int ac, const char **av) int anope_event_chghost(const char *source, int ac, const char **av) { - User *u; - - u = finduser(source); - if (!u) { - if (debug) { - alog("debug: FHOST for nonexistent user %s", source); - } - return MOD_CONT; - } - - u->SetDisplayedHost(av[0]); - return MOD_CONT; + User *u; + + u = finduser(source); + if (!u) { + if (debug) { + alog("debug: FHOST for nonexistent user %s", source); + } + return MOD_CONT; + } + + u->SetDisplayedHost(av[0]); + return MOD_CONT; } /* @@ -1125,8 +1125,8 @@ int anope_event_server(const char *source, int ac, const char **av) { uplink = sstrdup(av[0]); } - do_server(source, av[0], av[2], av[4], av[3]); - return MOD_CONT; + do_server(source, av[0], av[2], av[4], av[3]); + return MOD_CONT; } @@ -1140,172 +1140,172 @@ int anope_event_privmsg(const char *source, int ac, const char **av) int anope_event_part(const char *source, int ac, const char **av) { - do_part(source, ac, av); - return MOD_CONT; + do_part(source, ac, av); + return MOD_CONT; } int anope_event_whois(const char *source, int ac, const char **av) { - m_whois(source, av[0]); - return MOD_CONT; + m_whois(source, av[0]); + return MOD_CONT; } int anope_event_capab(const char *source, int ac, const char **av) { - int argc; - CBModeInfo *cbmi; + int argc; + CBModeInfo *cbmi; - if (strcasecmp(av[0], "START") == 0) { - /* reset CAPAB */ - has_servicesmod = 0; - has_globopsmod = 0; + if (strcasecmp(av[0], "START") == 0) { + /* reset CAPAB */ + has_servicesmod = 0; + has_globopsmod = 0; has_svsholdmod = 0; has_chghostmod = 0; has_chgidentmod = 0; - } else if (strcasecmp(av[0], "MODULES") == 0) { - if (strstr(av[1], "m_globops.so")) { - has_globopsmod = 1; - } - if (strstr(av[1], "m_services_account.so")) { - has_servicesmod = 1; - } + } else if (strcasecmp(av[0], "MODULES") == 0) { + if (strstr(av[1], "m_globops.so")) { + has_globopsmod = 1; + } + if (strstr(av[1], "m_services_account.so")) { + has_servicesmod = 1; + } if (strstr(av[1], "m_svshold.so")) { - has_svsholdmod = 1; - } + has_svsholdmod = 1; + } if (strstr(av[1], "m_chghost.so")) { - has_chghostmod = 1; - } + has_chghostmod = 1; + } if (strstr(av[1], "m_chgident.so")) { - has_chgidentmod = 1; - } - if (strstr(av[1], "m_messageflood.so")) { - has_messagefloodmod = 1; - } - if (strstr(av[1], "m_banexception.so")) { - has_banexceptionmod = 1; - } - if (strstr(av[1], "m_inviteexception.so")) { - has_inviteexceptionmod = 1; - } - } else if (strcasecmp(av[0], "END") == 0) { - if (!has_globopsmod) { - send_cmd(NULL, - "ERROR :m_globops is not loaded. This is required by Anope"); - quitmsg = "Remote server does not have the m_globops module loaded, and this is required."; - quitting = 1; - return MOD_STOP; - } - if (!has_servicesmod) { - send_cmd(NULL, - "ERROR :m_services is not loaded. This is required by Anope"); - quitmsg = "Remote server does not have the m_services module loaded, and this is required."; - quitting = 1; - return MOD_STOP; - } - if (!has_svsholdmod) { - ircdproto->SendGlobops(s_OperServ, "SVSHOLD missing, Usage disabled until module is loaded."); - } - if (!has_chghostmod) { - ircdproto->SendGlobops(s_OperServ, "CHGHOST missing, Usage disabled until module is loaded."); - } - if (!has_chgidentmod) { - ircdproto->SendGlobops(s_OperServ, "CHGIDENT missing, Usage disabled until module is loaded."); - } - if (has_messagefloodmod) { - cbmi = myCbmodeinfos; - - /* Find 'f' in myCbmodeinfos and add the relevant bits to myCbmodes and myCbmodeinfos - * to enable +f support if found. This is needed because we're really not set up to - * handle modular ircds which can have modes enabled/disabled as they please :( - mark - */ - while ((cbmi->mode != 'f')) { - cbmi++; - } - if (cbmi) { - cbmi->getvalue = get_flood; - cbmi->csgetvalue = cs_get_flood; - - myCbmodes['f'].flag = CMODE_f; - myCbmodes['f'].flags = 0; - myCbmodes['f'].setvalue = set_flood; - myCbmodes['f'].cssetvalue = cs_set_flood; - - pmodule_ircd_cbmodeinfos(myCbmodeinfos); - pmodule_ircd_cbmodes(myCbmodes); - - ircd->fmode = 1; - } - else { - alog("Support for channelmode +f can not be enabled"); - if (debug) { - alog("debug: 'f' missing from myCbmodeinfos"); - } - } - } - if (has_banexceptionmod) { - myCmmodes['e'].addmask = add_exception; - myCmmodes['e'].delmask = del_exception; - ircd->except = 1; - } - if (has_inviteexceptionmod) { - myCmmodes['I'].addmask = add_invite; - myCmmodes['I'].delmask = del_invite; - ircd->invitemode = 1; - } - ircd->svshold = has_svsholdmod; - - if (has_banexceptionmod || has_inviteexceptionmod) { - pmodule_ircd_cmmodes(myCmmodes); - } - - /* Generate a fake capabs parsing call so things like NOQUIT work - * fine. It's ugly, but it works.... - */ - argc = 6; + has_chgidentmod = 1; + } + if (strstr(av[1], "m_messageflood.so")) { + has_messagefloodmod = 1; + } + if (strstr(av[1], "m_banexception.so")) { + has_banexceptionmod = 1; + } + if (strstr(av[1], "m_inviteexception.so")) { + has_inviteexceptionmod = 1; + } + } else if (strcasecmp(av[0], "END") == 0) { + if (!has_globopsmod) { + send_cmd(NULL, + "ERROR :m_globops is not loaded. This is required by Anope"); + quitmsg = "Remote server does not have the m_globops module loaded, and this is required."; + quitting = 1; + return MOD_STOP; + } + if (!has_servicesmod) { + send_cmd(NULL, + "ERROR :m_services is not loaded. This is required by Anope"); + quitmsg = "Remote server does not have the m_services module loaded, and this is required."; + quitting = 1; + return MOD_STOP; + } + if (!has_svsholdmod) { + ircdproto->SendGlobops(s_OperServ, "SVSHOLD missing, Usage disabled until module is loaded."); + } + if (!has_chghostmod) { + ircdproto->SendGlobops(s_OperServ, "CHGHOST missing, Usage disabled until module is loaded."); + } + if (!has_chgidentmod) { + ircdproto->SendGlobops(s_OperServ, "CHGIDENT missing, Usage disabled until module is loaded."); + } + if (has_messagefloodmod) { + cbmi = myCbmodeinfos; + + /* Find 'f' in myCbmodeinfos and add the relevant bits to myCbmodes and myCbmodeinfos + * to enable +f support if found. This is needed because we're really not set up to + * handle modular ircds which can have modes enabled/disabled as they please :( - mark + */ + while ((cbmi->mode != 'f')) { + cbmi++; + } + if (cbmi) { + cbmi->getvalue = get_flood; + cbmi->csgetvalue = cs_get_flood; + + myCbmodes['f'].flag = CMODE_f; + myCbmodes['f'].flags = 0; + myCbmodes['f'].setvalue = set_flood; + myCbmodes['f'].cssetvalue = cs_set_flood; + + pmodule_ircd_cbmodeinfos(myCbmodeinfos); + pmodule_ircd_cbmodes(myCbmodes); + + ircd->fmode = 1; + } + else { + alog("Support for channelmode +f can not be enabled"); + if (debug) { + alog("debug: 'f' missing from myCbmodeinfos"); + } + } + } + if (has_banexceptionmod) { + myCmmodes['e'].addmask = add_exception; + myCmmodes['e'].delmask = del_exception; + ircd->except = 1; + } + if (has_inviteexceptionmod) { + myCmmodes['I'].addmask = add_invite; + myCmmodes['I'].delmask = del_invite; + ircd->invitemode = 1; + } + ircd->svshold = has_svsholdmod; + + if (has_banexceptionmod || has_inviteexceptionmod) { + pmodule_ircd_cmmodes(myCmmodes); + } + + /* Generate a fake capabs parsing call so things like NOQUIT work + * fine. It's ugly, but it works.... + */ + argc = 6; const char *argv[] = {"NOQUIT", "SSJ3", "NICK2", "VL", "TLKEXT", "UNCONNECT"}; - capab_parse(argc, argv); - } - return MOD_CONT; + capab_parse(argc, argv); + } + return MOD_CONT; } void moduleAddIRCDMsgs(void) { - Message *m; - - updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+a","-a"); - - m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); - m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); - m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); - m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); - m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); - m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); - m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); - m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); - m = createMessage("UID", anope_event_uid); addCoreMessage(IRCD,m); - m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); - m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); - m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); - m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); - m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); - m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); - m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); - m = createMessage("RSQUIT", anope_event_rsquit); addCoreMessage(IRCD,m); - m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); - m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); - m = createMessage("SVSMODE", anope_event_mode) ;addCoreMessage(IRCD,m); - m = createMessage("FHOST", anope_event_chghost); addCoreMessage(IRCD,m); - m = createMessage("CHGIDENT", anope_event_chgident); addCoreMessage(IRCD,m); - m = createMessage("FNAME", anope_event_chgname); addCoreMessage(IRCD,m); - m = createMessage("SETHOST", anope_event_sethost); addCoreMessage(IRCD,m); - m = createMessage("SETIDENT", anope_event_setident); addCoreMessage(IRCD,m); - m = createMessage("SETNAME", anope_event_setname); addCoreMessage(IRCD,m); - m = createMessage("FJOIN", anope_event_fjoin); addCoreMessage(IRCD,m); - m = createMessage("FMODE", anope_event_fmode); addCoreMessage(IRCD,m); - m = createMessage("FTOPIC", anope_event_ftopic); addCoreMessage(IRCD,m); - m = createMessage("OPERTYPE", anope_event_opertype); addCoreMessage(IRCD,m); - m = createMessage("IDLE", anope_event_idle); addCoreMessage(IRCD,m); + Message *m; + + updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+a","-a"); + + m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); + m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); + m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); + m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); + m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); + m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); + m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("UID", anope_event_uid); addCoreMessage(IRCD,m); + m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); + m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); + m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); + m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); + m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); + m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); + m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); + m = createMessage("RSQUIT", anope_event_rsquit); addCoreMessage(IRCD,m); + m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); + m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); + m = createMessage("SVSMODE", anope_event_mode) ;addCoreMessage(IRCD,m); + m = createMessage("FHOST", anope_event_chghost); addCoreMessage(IRCD,m); + m = createMessage("CHGIDENT", anope_event_chgident); addCoreMessage(IRCD,m); + m = createMessage("FNAME", anope_event_chgname); addCoreMessage(IRCD,m); + m = createMessage("SETHOST", anope_event_sethost); addCoreMessage(IRCD,m); + m = createMessage("SETIDENT", anope_event_setident); addCoreMessage(IRCD,m); + m = createMessage("SETNAME", anope_event_setname); addCoreMessage(IRCD,m); + m = createMessage("FJOIN", anope_event_fjoin); addCoreMessage(IRCD,m); + m = createMessage("FMODE", anope_event_fmode); addCoreMessage(IRCD,m); + m = createMessage("FTOPIC", anope_event_ftopic); addCoreMessage(IRCD,m); + m = createMessage("OPERTYPE", anope_event_opertype); addCoreMessage(IRCD,m); + m = createMessage("IDLE", anope_event_idle); addCoreMessage(IRCD,m); } class ProtoInspIRCd : public Module diff --git a/src/protocol/obsolete/hybrid.c b/src/protocol/obsolete/hybrid.c index f9e9e7c0d..7cc5db5fc 100644 --- a/src/protocol/obsolete/hybrid.c +++ b/src/protocol/obsolete/hybrid.c @@ -16,638 +16,638 @@ #include "hybrid.h" IRCDVar myIrcd[] = { - {"HybridIRCd 7.*", /* ircd name */ - "+o", /* nickserv mode */ - "+o", /* chanserv mode */ - "+o", /* memoserv mode */ - NULL, /* hostserv mode */ - "+aio", /* operserv mode */ - "+o", /* botserv mode */ - "+h", /* helpserv mode */ - "+i", /* Dev/Null mode */ - "+io", /* Global mode */ - "+o", /* nickserv alias mode */ - "+o", /* chanserv alias mode */ - "+o", /* memoserv alias mode */ - NULL, /* hostserv alias mode */ - "+aio", /* operserv alias mode */ - "+o", /* botserv alias mode */ - "+h", /* helpserv alias mode */ - "+i", /* Dev/Null alias mode */ - "+io", /* Global alias mode */ - "+", /* Used by BotServ Bots */ - 3, /* Chan Max Symbols */ - "-ailmnpst", /* Modes to Remove */ - "+o", /* Channel Umode used by Botserv bots */ - 0, /* SVSNICK */ - 0, /* Vhost */ - 0, /* Has Owner */ - NULL, /* Mode to set for an owner */ - NULL, /* Mode to unset for an owner */ - NULL, /* Mode to set for admin */ - NULL, /* Mode to unset for admin */ - NULL, /* Mode On Reg */ - NULL, /* Mode on ID for Roots */ - NULL, /* Mode on ID for Admins */ - NULL, /* Mode on ID for Opers */ - NULL, /* Mode on UnReg */ - NULL, /* Mode on Nick Change */ - 1, /* Supports SGlines */ - 1, /* Supports SQlines */ - 0, /* Supports SZlines */ - 1, /* Supports Halfop +h */ - 3, /* Number of server args */ - 1, /* Join 2 Set */ - 1, /* Join 2 Message */ - 1, /* Has exceptions +e */ - 0, /* TS Topic Forward */ - 0, /* TS Topci Backward */ - 0, /* Protected Umode */ - 0, /* Has Admin */ - 0, /* Chan SQlines */ - 0, /* Quit on Kill */ - 0, /* SVSMODE unban */ - 0, /* Has Protect */ - 0, /* Reverse */ - 0, /* Chan Reg */ - 0, /* Channel Mode */ - 0, /* vidents */ - 0, /* svshold */ - 0, /* time stamp on mode */ - 0, /* NICKIP */ - 0, /* UMODE */ - 0, /* O:LINE */ - 0, /* VHOST ON NICK */ - 0, /* Change RealName */ - CMODE_p, /* No Knock */ - 0, /* Admin Only */ - DEFAULT_MLOCK, /* Default MLOCK */ - 0, /* Vhost Mode */ - 0, /* +f */ - 0, /* +L */ - 0, /* +f Mode */ - 0, /* +L Mode */ - 0, /* On nick change check if they could be identified */ - 0, /* No Knock requires +i */ - NULL, /* CAPAB Chan Modes */ - 0, /* We support TOKENS */ - 1, /* TOKENS are CASE inSensitive */ - 0, /* TIME STAMPS are BASE64 */ - 0, /* +I support */ - 0, /* SJOIN ban char */ - 0, /* SJOIN except char */ - 0, /* SJOIN invite char */ - 0, /* Can remove User Channel Modes with SVSMODE */ - 0, /* Sglines are not enforced until user reconnects */ - NULL, /* vhost char */ - 0, /* ts6 */ - 0, /* support helper umode */ - 0, /* p10 */ - NULL, /* character set */ - 0, /* reports sync state */ - 0, /* CIDR channelbans */ - } - , - {NULL} + {"HybridIRCd 7.*", /* ircd name */ + "+o", /* nickserv mode */ + "+o", /* chanserv mode */ + "+o", /* memoserv mode */ + NULL, /* hostserv mode */ + "+aio", /* operserv mode */ + "+o", /* botserv mode */ + "+h", /* helpserv mode */ + "+i", /* Dev/Null mode */ + "+io", /* Global mode */ + "+o", /* nickserv alias mode */ + "+o", /* chanserv alias mode */ + "+o", /* memoserv alias mode */ + NULL, /* hostserv alias mode */ + "+aio", /* operserv alias mode */ + "+o", /* botserv alias mode */ + "+h", /* helpserv alias mode */ + "+i", /* Dev/Null alias mode */ + "+io", /* Global alias mode */ + "+", /* Used by BotServ Bots */ + 3, /* Chan Max Symbols */ + "-ailmnpst", /* Modes to Remove */ + "+o", /* Channel Umode used by Botserv bots */ + 0, /* SVSNICK */ + 0, /* Vhost */ + 0, /* Has Owner */ + NULL, /* Mode to set for an owner */ + NULL, /* Mode to unset for an owner */ + NULL, /* Mode to set for admin */ + NULL, /* Mode to unset for admin */ + NULL, /* Mode On Reg */ + NULL, /* Mode on ID for Roots */ + NULL, /* Mode on ID for Admins */ + NULL, /* Mode on ID for Opers */ + NULL, /* Mode on UnReg */ + NULL, /* Mode on Nick Change */ + 1, /* Supports SGlines */ + 1, /* Supports SQlines */ + 0, /* Supports SZlines */ + 1, /* Supports Halfop +h */ + 3, /* Number of server args */ + 1, /* Join 2 Set */ + 1, /* Join 2 Message */ + 1, /* Has exceptions +e */ + 0, /* TS Topic Forward */ + 0, /* TS Topci Backward */ + 0, /* Protected Umode */ + 0, /* Has Admin */ + 0, /* Chan SQlines */ + 0, /* Quit on Kill */ + 0, /* SVSMODE unban */ + 0, /* Has Protect */ + 0, /* Reverse */ + 0, /* Chan Reg */ + 0, /* Channel Mode */ + 0, /* vidents */ + 0, /* svshold */ + 0, /* time stamp on mode */ + 0, /* NICKIP */ + 0, /* UMODE */ + 0, /* O:LINE */ + 0, /* VHOST ON NICK */ + 0, /* Change RealName */ + CMODE_p, /* No Knock */ + 0, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + 0, /* Vhost Mode */ + 0, /* +f */ + 0, /* +L */ + 0, /* +f Mode */ + 0, /* +L Mode */ + 0, /* On nick change check if they could be identified */ + 0, /* No Knock requires +i */ + NULL, /* CAPAB Chan Modes */ + 0, /* We support TOKENS */ + 1, /* TOKENS are CASE inSensitive */ + 0, /* TIME STAMPS are BASE64 */ + 0, /* +I support */ + 0, /* SJOIN ban char */ + 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ + 0, /* Can remove User Channel Modes with SVSMODE */ + 0, /* Sglines are not enforced until user reconnects */ + NULL, /* vhost char */ + 0, /* ts6 */ + 0, /* support helper umode */ + 0, /* p10 */ + NULL, /* character set */ + 0, /* reports sync state */ + 0, /* CIDR channelbans */ + } + , + {NULL} }; IRCDCAPAB myIrcdcap[] = { - { - CAPAB_NOQUIT, /* NOQUIT */ - 0, /* TSMODE */ - 0, /* UNCONNECT */ - 0, /* NICKIP */ - 0, /* SJOIN */ - CAPAB_ZIP, /* ZIP */ - 0, /* BURST */ - CAPAB_TS5, /* TS5 */ - 0, /* TS3 */ - 0, /* DKEY */ - 0, /* PT4 */ - 0, /* SCS */ - CAPAB_QS, /* QS */ - CAPAB_UID, /* UID */ - CAPAB_KNOCK, /* KNOCK */ - 0, /* CLIENT */ - 0, /* IPV6 */ - 0, /* SSJ5 */ - 0, /* SN2 */ - 0, /* TOKEN */ - 0, /* VHOST */ - 0, /* SSJ3 */ - 0, /* NICK2 */ - 0, /* UMODE2 */ - 0, /* VL */ - 0, /* TLKEXT */ - 0, /* DODKEY */ - 0, /* DOZIP */ - 0, 0, 0} + { + CAPAB_NOQUIT, /* NOQUIT */ + 0, /* TSMODE */ + 0, /* UNCONNECT */ + 0, /* NICKIP */ + 0, /* SJOIN */ + CAPAB_ZIP, /* ZIP */ + 0, /* BURST */ + CAPAB_TS5, /* TS5 */ + 0, /* TS3 */ + 0, /* DKEY */ + 0, /* PT4 */ + 0, /* SCS */ + CAPAB_QS, /* QS */ + CAPAB_UID, /* UID */ + CAPAB_KNOCK, /* KNOCK */ + 0, /* CLIENT */ + 0, /* IPV6 */ + 0, /* SSJ5 */ + 0, /* SN2 */ + 0, /* TOKEN */ + 0, /* VHOST */ + 0, /* SSJ3 */ + 0, /* NICK2 */ + 0, /* UMODE2 */ + 0, /* VL */ + 0, /* TLKEXT */ + 0, /* DODKEY */ + 0, /* DOZIP */ + 0, 0, 0} }; void hybrid_ProcessUsermodes(User * user, int ac, const char **av) { - int add = 1; /* 1 if adding modes, 0 if deleting */ - const char *modes = av[0]; - - ac--; - - if (debug) - alog("debug: Changing mode for %s to %s", user->nick, modes); - - while (*modes) { - - /* This looks better, much better than "add ? (do_add) : (do_remove)". - * At least this is readable without paying much attention :) -GD - */ - if (add) - user->mode |= umodes[(int) *modes]; - else - user->mode &= ~umodes[(int) *modes]; - - switch (*modes++) { - case '+': - add = 1; - break; - case '-': - add = 0; - break; - case 'd': - if (ac == 0) { - alog("user: umode +d with no parameter (?) for user %s", - user->nick); - break; - } - - ac--; - av++; - user->svid = strtoul(*av, NULL, 0); - break; - case 'o': - if (add) { - opcnt++; - - if (WallOper) - anope_SendGlobops(s_OperServ, - "\2%s\2 is now an IRC operator.", - user->nick); - display_news(user, NEWS_OPER); - - } else { - opcnt--; - } - break; - case 'r': - if (add && !nick_identified(user)) { - send_cmd(ServerName, "SVSMODE %s -r", user->nick); - user->mode &= ~UMODE_r; - } - break; - - } - } + int add = 1; /* 1 if adding modes, 0 if deleting */ + const char *modes = av[0]; + + ac--; + + if (debug) + alog("debug: Changing mode for %s to %s", user->nick, modes); + + while (*modes) { + + /* This looks better, much better than "add ? (do_add) : (do_remove)". + * At least this is readable without paying much attention :) -GD + */ + if (add) + user->mode |= umodes[(int) *modes]; + else + user->mode &= ~umodes[(int) *modes]; + + switch (*modes++) { + case '+': + add = 1; + break; + case '-': + add = 0; + break; + case 'd': + if (ac == 0) { + alog("user: umode +d with no parameter (?) for user %s", + user->nick); + break; + } + + ac--; + av++; + user->svid = strtoul(*av, NULL, 0); + break; + case 'o': + if (add) { + opcnt++; + + if (WallOper) + anope_SendGlobops(s_OperServ, + "\2%s\2 is now an IRC operator.", + user->nick); + display_news(user, NEWS_OPER); + + } else { + opcnt--; + } + break; + case 'r': + if (add && !nick_identified(user)) { + send_cmd(ServerName, "SVSMODE %s -r", user->nick); + user->mode &= ~UMODE_r; + } + break; + + } + } } unsigned long umodes[128] = { - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused, Unused, Horzontal Tab */ - 0, 0, 0, /* Line Feed, Unused, Unused */ - 0, 0, 0, /* Carriage Return, Unused, Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused, Unused, Space */ - 0, 0, 0, /* ! " # */ - 0, 0, 0, /* $ % & */ - 0, 0, 0, /* ! ( ) */ - 0, 0, 0, /* * + , */ - 0, 0, 0, /* - . / */ - 0, 0, /* 0 1 */ - 0, 0, /* 2 3 */ - 0, 0, /* 4 5 */ - 0, 0, /* 6 7 */ - 0, 0, /* 8 9 */ - 0, 0, /* : ; */ - 0, 0, 0, /* < = > */ - 0, 0, /* ? @ */ - 0, 0, 0, /* A B C */ - 0, 0, 0, /* D E F */ - 0, 0, 0, /* G H I */ - 0, 0, 0, /* J K L */ - 0, 0, 0, /* M N O */ - 0, 0, 0, /* P Q R */ - 0, 0, 0, /* S T U */ - 0, 0, 0, /* V W X */ - 0, /* Y */ - 0, /* Z */ - 0, 0, 0, /* [ \ ] */ - 0, 0, 0, /* ^ _ ` */ - UMODE_a, UMODE_b, UMODE_c, /* a b c */ - UMODE_d, 0, UMODE_f, /* d e f */ - UMODE_g, 0, UMODE_i, /* g h i */ - 0, UMODE_k, UMODE_l, /* j k l */ - 0, UMODE_n, UMODE_o, /* m n o */ - 0, 0, UMODE_r, /* p q r */ - UMODE_s, 0, UMODE_u, /* s t u */ - 0, UMODE_w, UMODE_x, /* v w x */ - UMODE_y, /* y */ - UMODE_z, /* z */ - 0, 0, 0, /* { | } */ - 0, 0 /* ~ � */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused, Unused, Horzontal Tab */ + 0, 0, 0, /* Line Feed, Unused, Unused */ + 0, 0, 0, /* Carriage Return, Unused, Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused, Unused, Space */ + 0, 0, 0, /* ! " # */ + 0, 0, 0, /* $ % & */ + 0, 0, 0, /* ! ( ) */ + 0, 0, 0, /* * + , */ + 0, 0, 0, /* - . / */ + 0, 0, /* 0 1 */ + 0, 0, /* 2 3 */ + 0, 0, /* 4 5 */ + 0, 0, /* 6 7 */ + 0, 0, /* 8 9 */ + 0, 0, /* : ; */ + 0, 0, 0, /* < = > */ + 0, 0, /* ? @ */ + 0, 0, 0, /* A B C */ + 0, 0, 0, /* D E F */ + 0, 0, 0, /* G H I */ + 0, 0, 0, /* J K L */ + 0, 0, 0, /* M N O */ + 0, 0, 0, /* P Q R */ + 0, 0, 0, /* S T U */ + 0, 0, 0, /* V W X */ + 0, /* Y */ + 0, /* Z */ + 0, 0, 0, /* [ \ ] */ + 0, 0, 0, /* ^ _ ` */ + UMODE_a, UMODE_b, UMODE_c, /* a b c */ + UMODE_d, 0, UMODE_f, /* d e f */ + UMODE_g, 0, UMODE_i, /* g h i */ + 0, UMODE_k, UMODE_l, /* j k l */ + 0, UMODE_n, UMODE_o, /* m n o */ + 0, 0, UMODE_r, /* p q r */ + UMODE_s, 0, UMODE_u, /* s t u */ + 0, UMODE_w, UMODE_x, /* v w x */ + UMODE_y, /* y */ + UMODE_z, /* z */ + 0, 0, 0, /* { | } */ + 0, 0 /* ~ � */ }; char myCsmodes[128] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, - 'a', /* (33) ! */ - 0, 0, 0, - 'h', - 0, 0, 0, 0, - 0, + 0, + 'a', /* (33) ! */ + 0, 0, 0, + 'h', + 0, 0, 0, 0, + 0, - 'v', 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'v', 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; CMMode myCmmodes[128] = { - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, /* BCD */ - {NULL}, {NULL}, {NULL}, /* EFG */ - {NULL}, /* H */ - {add_invite, del_invite}, - {NULL}, /* J */ - {NULL}, {NULL}, {NULL}, /* KLM */ - {NULL}, {NULL}, {NULL}, /* NOP */ - {NULL}, {NULL}, {NULL}, /* QRS */ - {NULL}, {NULL}, {NULL}, /* TUV */ - {NULL}, {NULL}, {NULL}, /* WXY */ - {NULL}, /* Z */ - {NULL}, {NULL}, /* (char 91 - 92) */ - {NULL}, {NULL}, {NULL}, /* (char 93 - 95) */ - {NULL}, /* ` (char 96) */ - {NULL}, /* a (char 97) */ - {add_ban, del_ban}, - {NULL}, - {NULL}, - {add_exception, del_exception}, - {NULL}, - {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, /* BCD */ + {NULL}, {NULL}, {NULL}, /* EFG */ + {NULL}, /* H */ + {add_invite, del_invite}, + {NULL}, /* J */ + {NULL}, {NULL}, {NULL}, /* KLM */ + {NULL}, {NULL}, {NULL}, /* NOP */ + {NULL}, {NULL}, {NULL}, /* QRS */ + {NULL}, {NULL}, {NULL}, /* TUV */ + {NULL}, {NULL}, {NULL}, /* WXY */ + {NULL}, /* Z */ + {NULL}, {NULL}, /* (char 91 - 92) */ + {NULL}, {NULL}, {NULL}, /* (char 93 - 95) */ + {NULL}, /* ` (char 96) */ + {NULL}, /* a (char 97) */ + {add_ban, del_ban}, + {NULL}, + {NULL}, + {add_exception, del_exception}, + {NULL}, + {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} }; CBMode myCbmodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, - {0}, /* A */ - {0}, /* B */ - {0}, /* C */ - {0}, /* D */ - {0}, /* E */ - {0}, /* F */ - {0}, /* G */ - {0}, /* H */ - {0}, /* I */ - {0}, /* J */ - {0}, /* K */ - {0}, /* L */ - {0}, /* M */ - {0}, /* N */ - {0}, /* O */ - {0}, /* P */ - {0}, /* Q */ - {0}, - {0}, /* S */ - {0}, /* T */ - {0}, /* U */ - {0}, /* V */ - {0}, /* W */ - {0}, /* X */ - {0}, /* Y */ - {0}, /* Z */ - {0}, {0}, {0}, {0}, {0}, {0}, - {CMODE_a, 0, NULL, NULL}, - {0}, /* b */ - {0}, /* c */ - {0}, /* d */ - {0}, /* e */ - {0}, /* f */ - {0}, /* g */ - {0}, /* h */ - {CMODE_i, 0, NULL, NULL}, - {0}, /* j */ - {CMODE_k, 0, chan_set_key, cs_set_key}, - {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, - {CMODE_m, 0, NULL, NULL}, - {CMODE_n, 0, NULL, NULL}, - {0}, /* o */ - {CMODE_p, 0, NULL, NULL}, - {0}, /* q */ - {0}, - {CMODE_s, 0, NULL, NULL}, - {CMODE_t, 0, NULL, NULL}, - {0}, - {0}, /* v */ - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {0}, /* z */ - {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, + {0}, /* A */ + {0}, /* B */ + {0}, /* C */ + {0}, /* D */ + {0}, /* E */ + {0}, /* F */ + {0}, /* G */ + {0}, /* H */ + {0}, /* I */ + {0}, /* J */ + {0}, /* K */ + {0}, /* L */ + {0}, /* M */ + {0}, /* N */ + {0}, /* O */ + {0}, /* P */ + {0}, /* Q */ + {0}, + {0}, /* S */ + {0}, /* T */ + {0}, /* U */ + {0}, /* V */ + {0}, /* W */ + {0}, /* X */ + {0}, /* Y */ + {0}, /* Z */ + {0}, {0}, {0}, {0}, {0}, {0}, + {CMODE_a, 0, NULL, NULL}, + {0}, /* b */ + {0}, /* c */ + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {0}, /* h */ + {CMODE_i, 0, NULL, NULL}, + {0}, /* j */ + {CMODE_k, 0, chan_set_key, cs_set_key}, + {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, + {CMODE_m, 0, NULL, NULL}, + {CMODE_n, 0, NULL, NULL}, + {0}, /* o */ + {CMODE_p, 0, NULL, NULL}, + {0}, /* q */ + {0}, + {CMODE_s, 0, NULL, NULL}, + {CMODE_t, 0, NULL, NULL}, + {0}, + {0}, /* v */ + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0} }; CBModeInfo myCbmodeinfos[] = { - {'a', CMODE_a, 0, NULL, NULL}, - {'i', CMODE_i, 0, NULL, NULL}, - {'k', CMODE_k, 0, get_key, cs_get_key}, - {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, - {'m', CMODE_m, 0, NULL, NULL}, - {'n', CMODE_n, 0, NULL, NULL}, - {'p', CMODE_p, 0, NULL, NULL}, - {'s', CMODE_s, 0, NULL, NULL}, - {'t', CMODE_t, 0, NULL, NULL}, - {0} + {'a', CMODE_a, 0, NULL, NULL}, + {'i', CMODE_i, 0, NULL, NULL}, + {'k', CMODE_k, 0, get_key, cs_get_key}, + {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, + {'m', CMODE_m, 0, NULL, NULL}, + {'n', CMODE_n, 0, NULL, NULL}, + {'p', CMODE_p, 0, NULL, NULL}, + {'s', CMODE_s, 0, NULL, NULL}, + {'t', CMODE_t, 0, NULL, NULL}, + {0} }; CUMode myCumodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, - - {0}, /* a */ - {0}, /* b */ - {0}, /* c */ - {0}, /* d */ - {0}, /* e */ - {0}, /* f */ - {0}, /* g */ - {CUS_HALFOP, 0, check_valid_op}, - {0}, /* i */ - {0}, /* j */ - {0}, /* k */ - {0}, /* l */ - {0}, /* m */ - {0}, /* n */ - {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, - {0}, /* p */ - {0}, /* q */ - {0}, /* r */ - {0}, /* s */ - {0}, /* t */ - {0}, /* u */ - {CUS_VOICE, 0, NULL}, - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {0}, /* z */ - {0}, {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, + + {0}, /* a */ + {0}, /* b */ + {0}, /* c */ + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {CUS_HALFOP, 0, check_valid_op}, + {0}, /* i */ + {0}, /* j */ + {0}, /* k */ + {0}, /* l */ + {0}, /* m */ + {0}, /* n */ + {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, + {0}, /* p */ + {0}, /* q */ + {0}, /* r */ + {0}, /* s */ + {0}, /* t */ + {0}, /* u */ + {CUS_VOICE, 0, NULL}, + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0}, {0} }; void hybrid_cmd_notice(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - if (NSDefFlags & NI_MSG) { - hybrid_cmd_privmsg2(source, dest, buf); - } else { - send_cmd(source, "NOTICE %s :%s", dest, buf); - } + if (NSDefFlags & NI_MSG) { + hybrid_cmd_privmsg2(source, dest, buf); + } else { + send_cmd(source, "NOTICE %s :%s", dest, buf); + } } void hybrid_cmd_notice2(const char *source, const char *dest, const char *msg) { - send_cmd(source, "NOTICE %s :%s", dest, msg); + send_cmd(source, "NOTICE %s :%s", dest, msg); } void hybrid_cmd_privmsg(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(source, "PRIVMSG %s :%s", dest, buf); + send_cmd(source, "PRIVMSG %s :%s", dest, buf); } void hybrid_cmd_privmsg2(const char *source, const char *dest, const char *msg) { - send_cmd(source, "PRIVMSG %s :%s", dest, msg); + send_cmd(source, "PRIVMSG %s :%s", dest, msg); } void hybrid_SendGlobalNotice(const char *source, const char *dest, const char *msg) { - send_cmd(source, "NOTICE $$%s :%s", dest, msg); + send_cmd(source, "NOTICE $$%s :%s", dest, msg); } void hybrid_SendGlobalPrivmsg(const char *source, const char *dest, const char *msg) { - send_cmd(source, "PRIVMSG $$%s :%s", dest, msg); + send_cmd(source, "PRIVMSG $$%s :%s", dest, msg); } void hybrid_SendGlobops(const char *source, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(source ? source : ServerName, "OPERWALL :%s", buf); + send_cmd(source ? source : ServerName, "OPERWALL :%s", buf); } /* GLOBOPS - to handle old WALLOPS */ void hybrid_SendGlobops_legacy(const char *source, const char *fmt) { - send_cmd(source ? source : ServerName, "OPERWALL :%s", fmt); + send_cmd(source ? source : ServerName, "OPERWALL :%s", fmt); } int anope_event_sjoin(const char *source, int ac, const char **av) { - do_sjoin(source, ac, av); - return MOD_CONT; + do_sjoin(source, ac, av); + return MOD_CONT; } int anope_event_nick(const char *source, int ac, const char **av) { - if (ac != 2) { - User *user = do_nick(source, av[0], av[4], av[5], av[6], av[7], - strtoul(av[2], NULL, 10), 0, 0, NULL, NULL); - if (user) - anope_ProcessUsermodes(user, 1, &av[3]); - } else { - do_nick(source, av[0], NULL, NULL, NULL, NULL, - strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); - } - return MOD_CONT; + if (ac != 2) { + User *user = do_nick(source, av[0], av[4], av[5], av[6], av[7], + strtoul(av[2], NULL, 10), 0, 0, NULL, NULL); + if (user) + anope_ProcessUsermodes(user, 1, &av[3]); + } else { + do_nick(source, av[0], NULL, NULL, NULL, NULL, + strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); + } + return MOD_CONT; } int anope_event_topic(const char *source, int ac, const char **av) { - if (ac == 4) { - do_topic(source, ac, av); - } else { - Channel *c = findchan(av[0]); - time_t topic_time = time(NULL); - - if (!c) { - if (debug) { - alog("debug: TOPIC %s for nonexistent channel %s", - merge_args(ac - 1, av + 1), av[0]); - } - return MOD_CONT; - } + if (ac == 4) { + do_topic(source, ac, av); + } else { + Channel *c = findchan(av[0]); + time_t topic_time = time(NULL); + + if (!c) { + if (debug) { + alog("debug: TOPIC %s for nonexistent channel %s", + merge_args(ac - 1, av + 1), av[0]); + } + return MOD_CONT; + } - if (check_topiclock(c, topic_time)) - return MOD_CONT; + if (check_topiclock(c, topic_time)) + return MOD_CONT; - if (c->topic) { - free(c->topic); - c->topic = NULL; - } - if (ac > 1 && *av[1]) - c->topic = sstrdup(av[1]); + if (c->topic) { + free(c->topic); + c->topic = NULL; + } + if (ac > 1 && *av[1]) + c->topic = sstrdup(av[1]); - strscpy(c->topic_setter, source, sizeof(c->topic_setter)); - c->topic_time = topic_time; + strscpy(c->topic_setter, source, sizeof(c->topic_setter)); + c->topic_time = topic_time; - record_topic(av[0]); + record_topic(av[0]); if (ac > 1 && *av[1]) - send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[1]); + send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[1]); else - send_event(EVENT_TOPIC_UPDATED, 2, av[0], ""); - } - return MOD_CONT; + send_event(EVENT_TOPIC_UPDATED, 2, av[0], ""); + } + return MOD_CONT; } int anope_event_tburst(const char *source, int ac, const char **av) { - if (ac != 5) - return MOD_CONT; + if (ac != 5) + return MOD_CONT; - av[0] = av[1]; - av[1] = av[3]; - av[3] = av[4]; - do_topic(source, 4, av); - return MOD_CONT; + av[0] = av[1]; + av[1] = av[3]; + av[3] = av[4]; + do_topic(source, 4, av); + return MOD_CONT; } int anope_event_436(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; + if (ac < 1) + return MOD_CONT; - m_nickcoll(av[0]); - return MOD_CONT; + m_nickcoll(av[0]); + return MOD_CONT; } /* *INDENT-OFF* */ void moduleAddIRCDMsgs(void) { - Message *m; - - updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+","-"); - - m = createMessage("401", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("402", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); - m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); - m = createMessage("INVITE", anope_event_invite); addCoreMessage(IRCD,m); - m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); - m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); - m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); - m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); - m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); - m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); - m = createMessage("NOTICE", anope_event_notice); addCoreMessage(IRCD,m); - m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); - m = createMessage("PASS", anope_event_pass); addCoreMessage(IRCD,m); - m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); - m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); - m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); - m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); - m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); - m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); - m = createMessage("TBURST", anope_event_tburst); addCoreMessage(IRCD,m); - m = createMessage("USER", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("WALLOPS", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); - m = createMessage("AKILL", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("GLOBOPS", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("GNOTICE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("GOPER", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("RAKILL", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SILENCE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SVSKILL", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SVSMODE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SVSNICK", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SVSNOOP", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SQLINE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("UNSQLINE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); - m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); - m = createMessage("SVINFO", anope_event_svinfo); addCoreMessage(IRCD,m); -/* m = createMessage("EOB", anope_event_eob); addCoreMessage(IRCD,m); */ - m = createMessage("ADMIN", anope_event_admin); addCoreMessage(IRCD,m); - m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m); + Message *m; + + updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+","-"); + + m = createMessage("401", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("402", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); + m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); + m = createMessage("INVITE", anope_event_invite); addCoreMessage(IRCD,m); + m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); + m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); + m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); + m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); + m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("NOTICE", anope_event_notice); addCoreMessage(IRCD,m); + m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); + m = createMessage("PASS", anope_event_pass); addCoreMessage(IRCD,m); + m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); + m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); + m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); + m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); + m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); + m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); + m = createMessage("TBURST", anope_event_tburst); addCoreMessage(IRCD,m); + m = createMessage("USER", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("WALLOPS", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); + m = createMessage("AKILL", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("GLOBOPS", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("GNOTICE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("GOPER", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("RAKILL", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SILENCE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SVSKILL", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SVSMODE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SVSNICK", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SVSNOOP", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SQLINE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("UNSQLINE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); + m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); + m = createMessage("SVINFO", anope_event_svinfo); addCoreMessage(IRCD,m); +/* m = createMessage("EOB", anope_event_eob); addCoreMessage(IRCD,m); */ + m = createMessage("ADMIN", anope_event_admin); addCoreMessage(IRCD,m); + m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m); } /* *INDENT-ON* */ @@ -655,28 +655,28 @@ void moduleAddIRCDMsgs(void) { void hybrid_SendSQLine(const char *mask, const char *reason) { - if (!mask || !reason) { - return; - } + if (!mask || !reason) { + return; + } - send_cmd(ServerName, "RESV * %s :%s", mask, reason); + send_cmd(ServerName, "RESV * %s :%s", mask, reason); } void hybrid_SendSGLineDel(const char *mask) { - if (!mask) { - return; - } + if (!mask) { + return; + } - send_cmd(ServerName, "UNXLINE * %s", mask); + send_cmd(ServerName, "UNXLINE * %s", mask); } void hybrid_SendSZLineDel(const char *mask) { - /* Does not support */ + /* Does not support */ } void hybrid_SendSZLine(const char *mask, const char *reason, const char *whom) { - /* Does not support */ + /* Does not support */ } void hybrid_cmd_svsadmin(const char *server, int set) @@ -685,11 +685,11 @@ void hybrid_cmd_svsadmin(const char *server, int set) void hybrid_SendSGLine(const char *mask, const char *reason) { - if (!mask || !reason) { - return; - } + if (!mask || !reason) { + return; + } - send_cmd(ServerName, "XLINE * %s 0 :%s", mask, reason); + send_cmd(ServerName, "XLINE * %s 0 :%s", mask, reason); } void HybridIRCdProto::SendAkillDel(const char *user, const char *host) @@ -699,34 +699,34 @@ void HybridIRCdProto::SendAkillDel(const char *user, const char *host) } void hybrid_cmd_topic(const char *whosets, const char *chan, const char *whosetit, - const char *topic, time_t when) + const char *topic, time_t when) { - send_cmd(whosets, "TOPIC %s :%s", chan, topic); + send_cmd(whosets, "TOPIC %s :%s", chan, topic); } void hybrid_SendVhostDel(User * u) { - /* does not support vhosting */ + /* does not support vhosting */ } void hybrid_SendVhost(const char *nick, const char *vIdent, const char *vhost) { - /* does not support vhosting */ + /* does not support vhosting */ } void hybrid_SendSQLineDel(const char *user) { - if (!user) { - return; - } + if (!user) { + return; + } - send_cmd(ServerName, "UNRESV * %s", user); + send_cmd(ServerName, "UNRESV * %s", user); } void hybrid_SendJoin(const char *user, const char *channel, time_t chantime) { - send_cmd(NULL, "SJOIN %ld %s + :%s", (long int) chantime, channel, - user); + send_cmd(NULL, "SJOIN %ld %s + :%s", (long int) chantime, channel, + user); } /* @@ -739,60 +739,60 @@ reason: the reason for the kline. */ void hybrid_SendAkill(const char *user, const char *host, const char *who, time_t when, - time_t expires, const char *reason) + time_t expires, const char *reason) { - send_cmd(s_OperServ, "KLINE * %ld %s %s :%s", - (long int) (expires - (long) time(NULL)), user, host, reason); + send_cmd(s_OperServ, "KLINE * %ld %s %s :%s", + (long int) (expires - (long) time(NULL)), user, host, reason); } void hybrid_SendSVSKill(const char *source, const char *user, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - if (!source || !user) { - return; - } + if (!source || !user) { + return; + } - send_cmd(source, "KILL %s :%s", user, buf); + send_cmd(source, "KILL %s :%s", user, buf); } void hybrid_SendSVSMode(User * u, int ac, const char **av) { - /* Hybrid does not support SVSMODE */ + /* Hybrid does not support SVSMODE */ } /* * SVINFO - * parv[0] = sender prefix - * parv[1] = TS_CURRENT for the server - * parv[2] = TS_MIN for the server - * parv[3] = server is standalone or connected to non-TS only - * parv[4] = server's idea of UTC time + * parv[0] = sender prefix + * parv[1] = TS_CURRENT for the server + * parv[2] = TS_MIN for the server + * parv[3] = server is standalone or connected to non-TS only + * parv[4] = server's idea of UTC time */ void hybrid_cmd_svinfo() { - send_cmd(NULL, "SVINFO 5 5 0 :%ld", (long int) time(NULL)); + send_cmd(NULL, "SVINFO 5 5 0 :%ld", (long int) time(NULL)); } /* CAPAB */ /* - QS - Can handle quit storm removal - EX - Can do channel +e exemptions - CHW - Can do channel wall @# - LL - Can do lazy links - IE - Can do invite exceptions - EOB - Can do EOB message - KLN - Can do KLINE message - GLN - Can do GLINE message + QS - Can handle quit storm removal + EX - Can do channel +e exemptions + CHW - Can do channel wall @# + LL - Can do lazy links + IE - Can do invite exceptions + EOB - Can do EOB message + KLN - Can do KLINE message + GLN - Can do GLINE message HOPS - can do half ops (+h) - HUB - This server is a HUB + HUB - This server is a HUB AOPS - Can do anon ops (+a) - UID - Can do UIDs - ZIP - Can do ZIPlinks - ENC - Can do ENCrypted links + UID - Can do UIDs + ZIP - Can do ZIPlinks + ENC - Can do ENCrypted links KNOCK - supports KNOCK TBURST - supports TBURST PARA - supports invite broadcasting for +p @@ -800,425 +800,425 @@ void hybrid_cmd_svinfo() */ void hybrid_cmd_capab() { - send_cmd(NULL, - "CAPAB :QS EX CHW IE KLN GLN HOPS HUB AOPS KNOCK TBURST PARA"); + send_cmd(NULL, + "CAPAB :QS EX CHW IE KLN GLN HOPS HUB AOPS KNOCK TBURST PARA"); } /* PASS */ void hybrid_cmd_pass(const char *pass) { - send_cmd(NULL, "PASS %s :TS", pass); + send_cmd(NULL, "PASS %s :TS", pass); } /* SERVER name hop descript */ void hybrid_SendServer(const char *servname, int hop, const char *descript) { - send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript); + send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript); } void hybrid_SendConnect(int servernum) { - me_server = - new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); - if (servernum == 1) - hybrid_cmd_pass(RemotePassword); - else if (servernum == 2) - hybrid_cmd_pass(RemotePassword2); - else if (servernum == 3) - hybrid_cmd_pass(RemotePassword3); + if (servernum == 1) + hybrid_cmd_pass(RemotePassword); + else if (servernum == 2) + hybrid_cmd_pass(RemotePassword2); + else if (servernum == 3) + hybrid_cmd_pass(RemotePassword3); - hybrid_cmd_capab(); - hybrid_SendServer(ServerName, 1, ServerDesc); - hybrid_cmd_svinfo(); + hybrid_cmd_capab(); + hybrid_SendServer(ServerName, 1, ServerDesc); + hybrid_cmd_svinfo(); } void hybrid_cmd_svsinfo() { - /* not used */ + /* not used */ } void hybrid_SendClientIntroduction(const char *nick, const char *user, const char *host, const char *real, - const char *modes) + const char *modes) { - EnforceQlinedNick(nick, s_BotServ); - send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s :%s", nick, - (long int) time(NULL), modes, user, host, ServerName, real); + EnforceQlinedNick(nick, s_BotServ); + send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s :%s", nick, + (long int) time(NULL), modes, user, host, ServerName, real); } void hybrid_SendPart(const char *nick, const char *chan, const char *buf) { - if (buf) { - send_cmd(nick, "PART %s :%s", chan, buf); - } else { - send_cmd(nick, "PART %s", chan); - } + if (buf) { + send_cmd(nick, "PART %s :%s", chan, buf); + } else { + send_cmd(nick, "PART %s", chan); + } } int anope_event_ping(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - hybrid_SendPong(ac > 1 ? av[1] : ServerName, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + hybrid_SendPong(ac > 1 ? av[1] : ServerName, av[0]); + return MOD_CONT; } int anope_event_away(const char *source, int ac, const char **av) { - if (!source) { - return MOD_CONT; - } - m_away(source, (ac ? av[0] : NULL)); - return MOD_CONT; + if (!source) { + return MOD_CONT; + } + m_away(source, (ac ? av[0] : NULL)); + return MOD_CONT; } int anope_event_kill(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - m_kill(av[0], av[1]); - return MOD_CONT; + m_kill(av[0], av[1]); + return MOD_CONT; } int anope_event_kick(const char *source, int ac, const char **av) { - if (ac != 3) - return MOD_CONT; - do_kick(source, ac, av); - return MOD_CONT; + if (ac != 3) + return MOD_CONT; + do_kick(source, ac, av); + return MOD_CONT; } int anope_event_eob(const char *source, int ac, const char **av) { - Server *s; - s = findserver(servlist, source); - /* If we found a server with the given source, that one just - * finished bursting. If there was no source, then our uplink - * server finished bursting. -GD - */ - if (!s && serv_uplink) - s = serv_uplink; - finish_sync(s, 1); + Server *s; + s = findserver(servlist, source); + /* If we found a server with the given source, that one just + * finished bursting. If there was no source, then our uplink + * server finished bursting. -GD + */ + if (!s && serv_uplink) + s = serv_uplink; + finish_sync(s, 1); - return MOD_CONT; + return MOD_CONT; } void hybrid_SendEOB() { -/* send_cmd(ServerName, "EOB"); */ +/* send_cmd(ServerName, "EOB"); */ } int anope_event_join(const char *source, int ac, const char **av) { - if (ac != 1) - return MOD_CONT; - do_join(source, ac, av); - return MOD_CONT; + if (ac != 1) + return MOD_CONT; + do_join(source, ac, av); + return MOD_CONT; } int anope_event_motd(const char *source, int ac, const char **av) { - if (!source) { - return MOD_CONT; - } + if (!source) { + return MOD_CONT; + } - m_motd(source); - return MOD_CONT; + m_motd(source); + return MOD_CONT; } int anope_event_privmsg(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; - m_privmsg(source, av[0], av[1]); - return MOD_CONT; + if (ac != 2) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; } int anope_event_part(const char *source, int ac, const char **av) { - if (ac < 1 || ac > 2) - return MOD_CONT; - do_part(source, ac, av); - return MOD_CONT; + if (ac < 1 || ac > 2) + return MOD_CONT; + do_part(source, ac, av); + return MOD_CONT; } int anope_event_whois(const char *source, int ac, const char **av) { - if (source && ac >= 1) { - m_whois(source, av[0]); - } - return MOD_CONT; + if (source && ac >= 1) { + m_whois(source, av[0]); + } + return MOD_CONT; } /* EVENT: SERVER */ int anope_event_server(const char *source, int ac, const char **av) { - if (!stricmp(av[1], "1")) { - uplink = sstrdup(av[0]); - } - do_server(source, av[0], av[1], av[2], NULL); - return MOD_CONT; + if (!stricmp(av[1], "1")) { + uplink = sstrdup(av[0]); + } + do_server(source, av[0], av[1], av[2], NULL); + return MOD_CONT; } int anope_event_squit(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; - do_squit(source, ac, av); - return MOD_CONT; + if (ac != 2) + return MOD_CONT; + do_squit(source, ac, av); + return MOD_CONT; } int anope_event_quit(const char *source, int ac, const char **av) { - if (ac != 1) - return MOD_CONT; - do_quit(source, ac, av); - return MOD_CONT; + if (ac != 1) + return MOD_CONT; + do_quit(source, ac, av); + return MOD_CONT; } void hybrid_cmd_372(const char *source, const char *msg) { - send_cmd(ServerName, "372 %s :- %s", source, msg); + send_cmd(ServerName, "372 %s :- %s", source, msg); } void hybrid_cmd_372_error(const char *source) { - send_cmd(ServerName, "422 %s :- MOTD file not found! Please " - "contact your IRC administrator.", source); + send_cmd(ServerName, "422 %s :- MOTD file not found! Please " + "contact your IRC administrator.", source); } void hybrid_cmd_375(const char *source) { - send_cmd(ServerName, "375 %s :- %s Message of the Day", - source, ServerName); + send_cmd(ServerName, "375 %s :- %s Message of the Day", + source, ServerName); } void hybrid_cmd_376(const char *source) { - send_cmd(ServerName, "376 %s :End of /MOTD command.", source); + send_cmd(ServerName, "376 %s :End of /MOTD command.", source); } /* 391 */ void hybrid_cmd_391(const char *source, const char *timestr) { - if (!timestr) { - return; - } - send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr); + if (!timestr) { + return; + } + send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr); } /* 250 */ void hybrid_cmd_250(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "250 %s", buf); + send_cmd(NULL, "250 %s", buf); } /* 307 */ void hybrid_cmd_307(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "307 %s", buf); + send_cmd(ServerName, "307 %s", buf); } /* 311 */ void hybrid_cmd_311(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "311 %s", buf); + send_cmd(ServerName, "311 %s", buf); } /* 312 */ void hybrid_cmd_312(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "312 %s", buf); + send_cmd(ServerName, "312 %s", buf); } /* 317 */ void hybrid_cmd_317(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "317 %s", buf); + send_cmd(ServerName, "317 %s", buf); } /* 219 */ void hybrid_cmd_219(const char *source, const char *letter) { - if (!source) { - return; - } + if (!source) { + return; + } - if (letter) { - send_cmd(NULL, "219 %s %c :End of /STATS report.", source, - *letter); - } else { - send_cmd(NULL, "219 %s l :End of /STATS report.", source); - } + if (letter) { + send_cmd(NULL, "219 %s %c :End of /STATS report.", source, + *letter); + } else { + send_cmd(NULL, "219 %s l :End of /STATS report.", source); + } } /* 401 */ void hybrid_cmd_401(const char *source, const char *who) { - if (!source || !who) { - return; - } - send_cmd(ServerName, "401 %s %s :No such service.", source, who); + if (!source || !who) { + return; + } + send_cmd(ServerName, "401 %s %s :No such service.", source, who); } /* 318 */ void hybrid_cmd_318(const char *source, const char *who) { - if (!source || !who) { - return; - } + if (!source || !who) { + return; + } - send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who); + send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who); } /* 242 */ void hybrid_cmd_242(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "242 %s", buf); + send_cmd(NULL, "242 %s", buf); } /* 243 */ void hybrid_cmd_243(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "243 %s", buf); + send_cmd(NULL, "243 %s", buf); } /* 211 */ void hybrid_cmd_211(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "211 %s", buf); + send_cmd(NULL, "211 %s", buf); } void hybrid_SendMode(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(source, "MODE %s %s", dest, buf); + send_cmd(source, "MODE %s %s", dest, buf); } void hybrid_cmd_nick(const char *nick, const char *name, const char *mode) { - EnforceQlinedNick(nick, NULL); - send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s :%s", nick, - (long int) time(NULL), mode, ServiceUser, ServiceHost, - ServerName, (name)); + EnforceQlinedNick(nick, NULL); + send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s :%s", nick, + (long int) time(NULL), mode, ServiceUser, ServiceHost, + ServerName, (name)); } void hybrid_SendKick(const char *source, const char *chan, const char *user, const char *buf) { - if (buf) { - send_cmd(source, "KICK %s %s :%s", chan, user, buf); - } else { - send_cmd(source, "KICK %s %s", chan, user); - } + if (buf) { + send_cmd(source, "KICK %s %s :%s", chan, user, buf); + } else { + send_cmd(source, "KICK %s %s", chan, user); + } } void hybrid_SendNoticeChanops(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "NOTICE @%s :%s", dest, buf); + send_cmd(NULL, "NOTICE @%s :%s", dest, buf); } void hybrid_SendBotOp(const char *nick, const char *chan) { - anope_SendMode(nick, chan, "%s %s", ircd->botchanumode, nick); + anope_SendMode(nick, chan, "%s %s", ircd->botchanumode, nick); } /* QUIT */ void hybrid_SendQuit(const char *source, const char *buf) { - if (buf) { - send_cmd(source, "QUIT :%s", buf); - } else { - send_cmd(source, "QUIT"); - } + if (buf) { + send_cmd(source, "QUIT :%s", buf); + } else { + send_cmd(source, "QUIT"); + } } /* PONG */ void hybrid_SendPong(const char *servname, const char *who) { - send_cmd(servname, "PONG %s", who); + send_cmd(servname, "PONG %s", who); } /* INVITE */ void hybrid_SendInvite(const char *source, const char *chan, const char *nick) { - if (!source || !chan || !nick) { - return; - } + if (!source || !chan || !nick) { + return; + } - send_cmd(source, "INVITE %s %s", nick, chan); + send_cmd(source, "INVITE %s %s", nick, chan); } /* SQUIT */ void hybrid_SendSquit(const char *servname, const char *message) { - if (!servname || !message) { - return; - } + if (!servname || !message) { + return; + } - send_cmd(NULL, "SQUIT %s :%s", servname, message); + send_cmd(NULL, "SQUIT %s :%s", servname, message); } int anope_event_mode(const char *source, int ac, const char **av) { - if (ac < 2) - return MOD_CONT; + if (ac < 2) + return MOD_CONT; - if (*av[0] == '#' || *av[0] == '&') { - do_cmode(source, ac, av); - } else { - do_umode(source, ac, av); - } - return MOD_CONT; + if (*av[0] == '#' || *av[0] == '&') { + do_cmode(source, ac, av); + } else { + do_umode(source, ac, av); + } + return MOD_CONT; } void hybrid_cmd_351(const char *source) { - send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s (%s) -- %s", - source, version_number, ServerName, ircd->name, version_flags, - EncModule, version_build); + send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s (%s) -- %s", + source, version_number, ServerName, ircd->name, version_flags, + EncModule, version_build); } /* Event: PROTOCTL */ @@ -1244,7 +1244,7 @@ int anope_event_capab(const char *source, int ac, const char **av) argc++; } - capab_parse(argc, argv); + capab_parse(argc, argv); /* Free our built ac/av */ for (argvsize = 0; argvsize < argc; argvsize++) { @@ -1252,163 +1252,163 @@ int anope_event_capab(const char *source, int ac, const char **av) } free((char **)argv); - return MOD_CONT; + return MOD_CONT; } /* SVSHOLD - set */ void hybrid_SendSVSHOLD(const char *nick) { - /* Not supported by this IRCD */ + /* Not supported by this IRCD */ } /* SVSHOLD - release */ void hybrid_SendSVSHOLDDel(const char *nick) { - /* Not Supported by this IRCD */ + /* Not Supported by this IRCD */ } /* SVSNICK */ void hybrid_SendForceNickChange(const char *nick, const char *newnick, time_t when) { - /* Not Supported by this IRCD */ + /* Not Supported by this IRCD */ } void hybrid_SendGuestNick(const char *nick, const char *user, const char *host, const char *real, - const char *modes) + const char *modes) { - send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s :%s", nick, - (long int) time(NULL), modes, user, host, ServerName, real); + send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s :%s", nick, + (long int) time(NULL), modes, user, host, ServerName, real); } void hybrid_SendSVSO(const char *source, const char *nick, const char *flag) { - /* Not Supported by this IRCD */ + /* Not Supported by this IRCD */ } void hybrid_SendBanDel(const char *name, const char *nick) { - /* Not Supported by this IRCD */ + /* Not Supported by this IRCD */ } /* SVSMODE channel modes */ void hybrid_SendSVSMode_chan(const char *name, const char *mode, const char *nick) { - /* Not Supported by this IRCD */ + /* Not Supported by this IRCD */ } /* SVSMODE +d */ /* sent if svid is something weird */ void hybrid_SendSVID(const char *nick, time_t ts) { - send_cmd(ServerName, "SVSMODE %s +d 1", nick); + send_cmd(ServerName, "SVSMODE %s +d 1", nick); } /* SVSMODE +d */ /* nc_change was = 1, and there is no na->status */ void hybrid_SendUnregisteredNick(User * u) { - /* not used */ + /* not used */ } /* SVSMODE +d */ void hybrid_SendSVID2(User * u, const char *ts) { - /* not used */ + /* not used */ } void hybrid_SendSVID3(User * u, const char *ts) { - /* not used */ + /* not used */ } /* NICK <newnick> */ void hybrid_SendChangeBotNick(const char *oldnick, const char *newnick) { - if (!oldnick || !newnick) { - return; - } + if (!oldnick || !newnick) { + return; + } - send_cmd(oldnick, "NICK %s", newnick); + send_cmd(oldnick, "NICK %s", newnick); } /* * SVINFO - * parv[0] = sender prefix - * parv[1] = TS_CURRENT for the server - * parv[2] = TS_MIN for the server - * parv[3] = server is standalone or connected to non-TS only - * parv[4] = server's idea of UTC time + * parv[0] = sender prefix + * parv[1] = TS_CURRENT for the server + * parv[2] = TS_MIN for the server + * parv[3] = server is standalone or connected to non-TS only + * parv[4] = server's idea of UTC time */ int anope_event_svinfo(const char *source, int ac, const char **av) { - /* currently not used but removes the message : unknown message from server */ - return MOD_CONT; + /* currently not used but removes the message : unknown message from server */ + return MOD_CONT; } int anope_event_pass(const char *source, int ac, const char **av) { - /* currently not used but removes the message : unknown message from server */ - return MOD_CONT; + /* currently not used but removes the message : unknown message from server */ + return MOD_CONT; } void hybrid_SendSVSJoin(const char *source, const char *nick, const char *chan, const char *param) { - /* Not Supported by this IRCD */ + /* Not Supported by this IRCD */ } void hybrid_SendSVSPart(const char *source, const char *nick, const char *chan) { - /* Not Supported by this IRCD */ + /* Not Supported by this IRCD */ } void hybrid_SendSWhois(const char *source, const char *who, const char *mask) { - /* not supported */ + /* not supported */ } int anope_event_notice(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_admin(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_invite(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int hybrid_IsFloodModeParamValid(const char *value) { - return 0; + return 0; } int anope_event_error(const char *source, int ac, const char **av) { - if (ac >= 1) { - if (debug) { - alog("debug: %s", av[0]); - } - } - return MOD_CONT; + if (ac >= 1) { + if (debug) { + alog("debug: %s", av[0]); + } + } + return MOD_CONT; } void hybrid_SendJupe(const char *jserver, const char *who, const char *reason) { - char rbuf[256]; + char rbuf[256]; - snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who, - reason ? ": " : "", reason ? reason : ""); + snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who, + reason ? ": " : "", reason ? reason : ""); - if (findserver(servlist, jserver)) - hybrid_SendSquit(jserver, rbuf); - hybrid_SendServer(jserver, 2, rbuf); - new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL); + if (findserver(servlist, jserver)) + hybrid_SendSquit(jserver, rbuf); + hybrid_SendServer(jserver, 2, rbuf); + new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL); } /* @@ -1417,8 +1417,8 @@ void hybrid_SendJupe(const char *jserver, const char *who, const char *reason) */ int hybrid_IsNickValid(const char *nick) { - /* no hard coded invalid nicks */ - return 1; + /* no hard coded invalid nicks */ + return 1; } /* @@ -1427,23 +1427,23 @@ int hybrid_IsNickValid(const char *nick) */ int hybrid_IsChannelValid(const char *chan) { - /* no hard coded invalid chans */ - return 1; + /* no hard coded invalid chans */ + return 1; } void hybrid_SendCTCP(const char *source, const char *dest, const char *buf) { - char *s; + char *s; - if (!buf) { - return; - } else { - s = normalizeBuffer(buf); - } + if (!buf) { + return; + } else { + s = normalizeBuffer(buf); + } - send_cmd(source, "NOTICE %s :\1%s \1", dest, s); - free(s); + send_cmd(source, "NOTICE %s :\1%s \1", dest, s); + free(s); } @@ -1453,78 +1453,78 @@ void hybrid_SendCTCP(const char *source, const char *dest, const char *buf) **/ void moduleAddAnopeCmds() { - pmodule_cmd_topic(hybrid_cmd_topic); - pmodule_SendVhostDel(hybrid_cmd_vhost_off); - pmodule_SendAkill(hybrid_cmd_akill); - pmodule_SendSVSKill(hybrid_SendSVSKill); - pmodule_SendSVSMode(hybrid_cmd_svsmode); - pmodule_cmd_372(hybrid_cmd_372); - pmodule_cmd_372_error(hybrid_cmd_372_error); - pmodule_cmd_375(hybrid_cmd_375); - pmodule_cmd_376(hybrid_cmd_376); - pmodule_cmd_nick(hybrid_cmd_nick); - pmodule_SendGuestNick(hybrid_cmd_guest_nick); - pmodule_SendMode(hybrid_cmd_mode); - pmodule_SendClientIntroduction(hybrid_cmd_bot_nick); - pmodule_SendKick(hybrid_cmd_kick); - pmodule_SendNoticeChanops(hybrid_cmd_notice_ops); - pmodule_cmd_notice(hybrid_cmd_notice); - pmodule_cmd_notice2(hybrid_cmd_notice2); - pmodule_cmd_privmsg(hybrid_cmd_privmsg); - pmodule_cmd_privmsg2(hybrid_cmd_privmsg2); - pmodule_SendGlobalNotice(hybrid_cmd_serv_notice); - pmodule_SendGlobalPrivmsg(hybrid_cmd_serv_privmsg); - pmodule_SendBotOp(hybrid_cmd_bot_chan_mode); - pmodule_cmd_351(hybrid_cmd_351); - pmodule_SendQuit(hybrid_cmd_quit); - pmodule_SendPong(hybrid_cmd_pong); - pmodule_SendJoin(hybrid_cmd_join); - pmodule_SendSQLineDel(hybrid_cmd_unsqline); - pmodule_SendInvite(hybrid_cmd_invite); - pmodule_SendPart(hybrid_cmd_part); - pmodule_cmd_391(hybrid_cmd_391); - pmodule_cmd_250(hybrid_cmd_250); - pmodule_cmd_307(hybrid_cmd_307); - pmodule_cmd_311(hybrid_cmd_311); - pmodule_cmd_312(hybrid_cmd_312); - pmodule_cmd_317(hybrid_cmd_317); - pmodule_cmd_219(hybrid_cmd_219); - pmodule_cmd_401(hybrid_cmd_401); - pmodule_cmd_318(hybrid_cmd_318); - pmodule_cmd_242(hybrid_cmd_242); - pmodule_cmd_243(hybrid_cmd_243); - pmodule_cmd_211(hybrid_cmd_211); - pmodule_SendGlobops(hybrid_cmd_global); - pmodule_SendGlobops_legacy(hybrid_cmd_global_legacy); - pmodule_SendSQLine(hybrid_cmd_sqline); - pmodule_SendSquit(hybrid_cmd_squit); - pmodule_SendSVSO(hybrid_cmd_svso); - pmodule_SendChangeBotNick(hybrid_cmd_chg_nick); - pmodule_SendForceNickChange(hybrid_cmd_svsnick); - pmodule_SendVhost(hybrid_cmd_vhost_on); - pmodule_SendConnect(hybrid_cmd_connect); - pmodule_SendSVSHOLD(hybrid_cmd_svshold); - pmodule_SendSVSHOLDDel(hybrid_cmd_release_svshold); - pmodule_SendSGLineDel(hybrid_cmd_unsgline); - pmodule_SendSZLineDel(hybrid_cmd_unszline); - pmodule_SendSZLine(hybrid_cmd_szline); - pmodule_SendSGLine(hybrid_cmd_sgline); - pmodule_SendBanDel(hybrid_cmd_unban); - pmodule_SendSVSMode_chan(hybrid_cmd_svsmode_chan); - pmodule_SendSVID(hybrid_cmd_svid_umode); - pmodule_SendUnregisteredNick(hybrid_cmd_nc_change); - pmodule_SendSVID2(hybrid_cmd_svid_umode2); - pmodule_SendSVID3(hybrid_cmd_svid_umode3); - pmodule_SendSVSJoin(hybrid_cmd_svsjoin); - pmodule_SendSVSPart(hybrid_cmd_svspart); - pmodule_SendSWhois(hybrid_cmd_swhois); - pmodule_SendEOB(hybrid_cmd_eob); - pmodule_IsFloodModeParamValid(hybrid_flood_mode_check); - pmodule_SendJupe(hybrid_cmd_jupe); - pmodule_IsNickValid(hybrid_valid_nick); - pmodule_IsChannelValid(hybrid_valid_chan); - pmodule_SendCTCP(hybrid_cmd_ctcp); - pmodule_ProcessUsermodes(hybrid_set_umode); + pmodule_cmd_topic(hybrid_cmd_topic); + pmodule_SendVhostDel(hybrid_cmd_vhost_off); + pmodule_SendAkill(hybrid_cmd_akill); + pmodule_SendSVSKill(hybrid_SendSVSKill); + pmodule_SendSVSMode(hybrid_cmd_svsmode); + pmodule_cmd_372(hybrid_cmd_372); + pmodule_cmd_372_error(hybrid_cmd_372_error); + pmodule_cmd_375(hybrid_cmd_375); + pmodule_cmd_376(hybrid_cmd_376); + pmodule_cmd_nick(hybrid_cmd_nick); + pmodule_SendGuestNick(hybrid_cmd_guest_nick); + pmodule_SendMode(hybrid_cmd_mode); + pmodule_SendClientIntroduction(hybrid_cmd_bot_nick); + pmodule_SendKick(hybrid_cmd_kick); + pmodule_SendNoticeChanops(hybrid_cmd_notice_ops); + pmodule_cmd_notice(hybrid_cmd_notice); + pmodule_cmd_notice2(hybrid_cmd_notice2); + pmodule_cmd_privmsg(hybrid_cmd_privmsg); + pmodule_cmd_privmsg2(hybrid_cmd_privmsg2); + pmodule_SendGlobalNotice(hybrid_cmd_serv_notice); + pmodule_SendGlobalPrivmsg(hybrid_cmd_serv_privmsg); + pmodule_SendBotOp(hybrid_cmd_bot_chan_mode); + pmodule_cmd_351(hybrid_cmd_351); + pmodule_SendQuit(hybrid_cmd_quit); + pmodule_SendPong(hybrid_cmd_pong); + pmodule_SendJoin(hybrid_cmd_join); + pmodule_SendSQLineDel(hybrid_cmd_unsqline); + pmodule_SendInvite(hybrid_cmd_invite); + pmodule_SendPart(hybrid_cmd_part); + pmodule_cmd_391(hybrid_cmd_391); + pmodule_cmd_250(hybrid_cmd_250); + pmodule_cmd_307(hybrid_cmd_307); + pmodule_cmd_311(hybrid_cmd_311); + pmodule_cmd_312(hybrid_cmd_312); + pmodule_cmd_317(hybrid_cmd_317); + pmodule_cmd_219(hybrid_cmd_219); + pmodule_cmd_401(hybrid_cmd_401); + pmodule_cmd_318(hybrid_cmd_318); + pmodule_cmd_242(hybrid_cmd_242); + pmodule_cmd_243(hybrid_cmd_243); + pmodule_cmd_211(hybrid_cmd_211); + pmodule_SendGlobops(hybrid_cmd_global); + pmodule_SendGlobops_legacy(hybrid_cmd_global_legacy); + pmodule_SendSQLine(hybrid_cmd_sqline); + pmodule_SendSquit(hybrid_cmd_squit); + pmodule_SendSVSO(hybrid_cmd_svso); + pmodule_SendChangeBotNick(hybrid_cmd_chg_nick); + pmodule_SendForceNickChange(hybrid_cmd_svsnick); + pmodule_SendVhost(hybrid_cmd_vhost_on); + pmodule_SendConnect(hybrid_cmd_connect); + pmodule_SendSVSHOLD(hybrid_cmd_svshold); + pmodule_SendSVSHOLDDel(hybrid_cmd_release_svshold); + pmodule_SendSGLineDel(hybrid_cmd_unsgline); + pmodule_SendSZLineDel(hybrid_cmd_unszline); + pmodule_SendSZLine(hybrid_cmd_szline); + pmodule_SendSGLine(hybrid_cmd_sgline); + pmodule_SendBanDel(hybrid_cmd_unban); + pmodule_SendSVSMode_chan(hybrid_cmd_svsmode_chan); + pmodule_SendSVID(hybrid_cmd_svid_umode); + pmodule_SendUnregisteredNick(hybrid_cmd_nc_change); + pmodule_SendSVID2(hybrid_cmd_svid_umode2); + pmodule_SendSVID3(hybrid_cmd_svid_umode3); + pmodule_SendSVSJoin(hybrid_cmd_svsjoin); + pmodule_SendSVSPart(hybrid_cmd_svspart); + pmodule_SendSWhois(hybrid_cmd_swhois); + pmodule_SendEOB(hybrid_cmd_eob); + pmodule_IsFloodModeParamValid(hybrid_flood_mode_check); + pmodule_SendJupe(hybrid_cmd_jupe); + pmodule_IsNickValid(hybrid_valid_nick); + pmodule_IsChannelValid(hybrid_valid_chan); + pmodule_SendCTCP(hybrid_cmd_ctcp); + pmodule_ProcessUsermodes(hybrid_set_umode); } /** @@ -1533,34 +1533,34 @@ void moduleAddAnopeCmds() int AnopeInit(int argc, char **argv) { - this->SetAuthor("Anope"); - this->SetVersion("$Id$"); - this->SetType(PROTOCOL); - - pmodule_ircd_version("Hybrid IRCd 7.0"); - pmodule_ircd_cap(myIrcdcap); - pmodule_ircd_var(myIrcd); - pmodule_ircd_cbmodeinfos(myCbmodeinfos); - pmodule_ircd_cumodes(myCumodes); - pmodule_ircd_flood_mode_char_set(""); - pmodule_ircd_flood_mode_char_remove(""); - pmodule_ircd_cbmodes(myCbmodes); - pmodule_ircd_cmmodes(myCmmodes); - pmodule_ircd_csmodes(myCsmodes); - pmodule_ircd_useTSMode(0); - - /** Deal with modes anope _needs_ to know **/ - pmodule_invis_umode(UMODE_i); - pmodule_oper_umode(UMODE_o); - pmodule_invite_cmode(CMODE_i); - pmodule_secret_cmode(CMODE_s); - pmodule_private_cmode(CMODE_p); - pmodule_key_mode(CMODE_k); - pmodule_limit_mode(CMODE_l); - - moduleAddAnopeCmds(); + this->SetAuthor("Anope"); + this->SetVersion("$Id$"); + this->SetType(PROTOCOL); + + pmodule_ircd_version("Hybrid IRCd 7.0"); + pmodule_ircd_cap(myIrcdcap); + pmodule_ircd_var(myIrcd); + pmodule_ircd_cbmodeinfos(myCbmodeinfos); + pmodule_ircd_cumodes(myCumodes); + pmodule_ircd_flood_mode_char_set(""); + pmodule_ircd_flood_mode_char_remove(""); + pmodule_ircd_cbmodes(myCbmodes); + pmodule_ircd_cmmodes(myCmmodes); + pmodule_ircd_csmodes(myCsmodes); + pmodule_ircd_useTSMode(0); + + /** Deal with modes anope _needs_ to know **/ + pmodule_invis_umode(UMODE_i); + pmodule_oper_umode(UMODE_o); + pmodule_invite_cmode(CMODE_i); + pmodule_secret_cmode(CMODE_s); + pmodule_private_cmode(CMODE_p); + pmodule_key_mode(CMODE_k); + pmodule_limit_mode(CMODE_l); + + moduleAddAnopeCmds(); pmodule_ircd_proto(&ircd_proto); - moduleAddIRCDMsgs(); + moduleAddIRCDMsgs(); - return MOD_CONT; + return MOD_CONT; } diff --git a/src/protocol/obsolete/hybrid.h b/src/protocol/obsolete/hybrid.h index 3d58695d4..a7e744ad5 100644 --- a/src/protocol/obsolete/hybrid.h +++ b/src/protocol/obsolete/hybrid.h @@ -30,15 +30,15 @@ #define UMODE_y 0x00040000 /* See LINKS, STATS (if configured), TRACE notices */ #define UMODE_z 0x00080000 /* See oper generated WALLOPS */ -#define CMODE_i 0x00000001 /* Invite only */ -#define CMODE_m 0x00000002 /* Users without +v/h/o cannot send text to the channel */ -#define CMODE_n 0x00000004 /* Users must be in the channel to send text to it */ -#define CMODE_p 0x00000008 /* Private is obsolete, this now restricts KNOCK */ -#define CMODE_s 0x00000010 /* The channel does not show up on NAMES or LIST */ -#define CMODE_t 0x00000020 /* Only chanops can change the topic */ -#define CMODE_k 0x00000040 /* Key/password for the channel. */ -#define CMODE_l 0x00000080 /* Limit the number of users in a channel */ -#define CMODE_a 0x00000400 /* Anonymous ops, chanops are hidden */ +#define CMODE_i 0x00000001 /* Invite only */ +#define CMODE_m 0x00000002 /* Users without +v/h/o cannot send text to the channel */ +#define CMODE_n 0x00000004 /* Users must be in the channel to send text to it */ +#define CMODE_p 0x00000008 /* Private is obsolete, this now restricts KNOCK */ +#define CMODE_s 0x00000010 /* The channel does not show up on NAMES or LIST */ +#define CMODE_t 0x00000020 /* Only chanops can change the topic */ +#define CMODE_k 0x00000040 /* Key/password for the channel. */ +#define CMODE_l 0x00000080 /* Limit the number of users in a channel */ +#define CMODE_a 0x00000400 /* Anonymous ops, chanops are hidden */ #define DEFAULT_MLOCK CMODE_n | CMODE_t diff --git a/src/protocol/obsolete/plexus3.c b/src/protocol/obsolete/plexus3.c index 99025bc5b..358522bce 100644 --- a/src/protocol/obsolete/plexus3.c +++ b/src/protocol/obsolete/plexus3.c @@ -34,7 +34,7 @@ IRCDVar myIrcd[] = { "+i", /* Dev/Null alias mode */ "+i", /* Global alias mode */ "+i", /* Used by BotServ Bots */ - 5, /* Chan Max Symbols */ + 5, /* Chan Max Symbols */ "-cilmnpstBMNORS", /* Modes to Remove */ "+ao", /* Channel Umode used by Botserv bots */ 1, /* SVSNICK */ @@ -44,50 +44,50 @@ IRCDVar myIrcd[] = { "-q", /* Mode to unset for an owner */ "+a", /* Mode to set for chan admin */ "-a", /* Mode to unset for chan admin */ - "+rd", /* Mode On Reg */ - "N", /* Mode on ID for Roots */ - NULL, /* Mode on ID for Admins */ - NULL, /* Mode on ID for Opers */ - "-r+d", /* Mode on UnReg */ + "+rd", /* Mode On Reg */ + "N", /* Mode on ID for Roots */ + NULL, /* Mode on ID for Admins */ + NULL, /* Mode on ID for Opers */ + "-r+d", /* Mode on UnReg */ "+d", /* Mode on Nick Change */ - 1, /* Supports SGlines */ - 1, /* Supports SQlines */ - 0, /* Supports SZlines */ + 1, /* Supports SGlines */ + 1, /* Supports SQlines */ + 0, /* Supports SZlines */ 1, /* Supports Halfop +h */ 3, /* Number of server args */ - 0, /* Join 2 Set */ - 0, /* Join 2 Message */ - 1, /* Has exceptions +e */ - 0, /* TS Topic Forward */ - 0, /* TS Topci Backward */ - UMODE_N, /* Protected Umode */ - 0, /* Has Admin */ - 1, /* Chan SQlines */ - 0, /* Quit on Kill */ - 0, /* SVSMODE unban */ - 1, /* Has Protect */ - 0, /* Reverse */ - 0, /* Chan Reg */ - 0, /* Channel Mode */ - 0, /* vidents */ - 1, /* svshold */ + 0, /* Join 2 Set */ + 0, /* Join 2 Message */ + 1, /* Has exceptions +e */ + 0, /* TS Topic Forward */ + 0, /* TS Topci Backward */ + UMODE_N, /* Protected Umode */ + 0, /* Has Admin */ + 1, /* Chan SQlines */ + 0, /* Quit on Kill */ + 0, /* SVSMODE unban */ + 1, /* Has Protect */ + 0, /* Reverse */ + 0, /* Chan Reg */ + 0, /* Channel Mode */ + 0, /* vidents */ + 1, /* svshold */ 1, /* time stamp on mode */ - 0, /* NICKIP */ - 0, /* O:LINE */ - 1, /* UMODE */ - 1, /* VHOST ON NICK */ - 0, /* Change RealName */ - CMODE_p, /* No Knock */ - 0, /* Admin Only */ - DEFAULT_MLOCK, /* Default MLOCK */ - UMODE_x, /* Vhost Mode */ - 0, /* +f */ - 0, /* +L */ - 0, /* +f Mode */ - 0, /* +L Mode */ + 0, /* NICKIP */ + 0, /* O:LINE */ + 1, /* UMODE */ + 1, /* VHOST ON NICK */ + 0, /* Change RealName */ + CMODE_p, /* No Knock */ + 0, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + UMODE_x, /* Vhost Mode */ + 0, /* +f */ + 0, /* +L */ + 0, /* +f Mode */ + 0, /* +L Mode */ 1, /* On nick change check if they could be identified */ 0, /* No Knock requires +i */ - NULL, /* CAPAB Chan Modes */ + NULL, /* CAPAB Chan Modes */ 0, /* We support TOKENS */ 1, /* TOKENS are CASE inSensitive */ 0, /* TIME STAMPS are BASE64 */ @@ -103,7 +103,7 @@ IRCDVar myIrcd[] = { 0, /* p10 */ NULL, /* character set */ 1, /* reports sync state */ - 0, /* CIDR channelbans */ + 0, /* CIDR channelbans */ } , {NULL} @@ -111,34 +111,34 @@ IRCDVar myIrcd[] = { IRCDCAPAB myIrcdcap[] = { { - 0, /* NOQUIT */ - 0, /* TSMODE */ - 0, /* UNCONNECT */ - 0, /* NICKIP */ - 0, /* SJOIN */ - CAPAB_ZIP, /* ZIP */ - 0, /* BURST */ - CAPAB_TS5, /* TS5 */ - 0, /* TS3 */ - 0, /* DKEY */ - 0, /* PT4 */ - 0, /* SCS */ - CAPAB_QS, /* QS */ - CAPAB_UID, /* UID */ - CAPAB_KNOCK, /* KNOCK */ - 0, /* CLIENT */ - 0, /* IPV6 */ - 0, /* SSJ5 */ - 0, /* SN2 */ - 0, /* TOKEN */ - 0, /* VHOST */ - 0, /* SSJ3 */ - 0, /* NICK2 */ - 0, /* UMODE2 */ - 0, /* VL */ - 0, /* TLKEXT */ - 0, /* DODKEY */ - 0, /* DOZIP */ + 0, /* NOQUIT */ + 0, /* TSMODE */ + 0, /* UNCONNECT */ + 0, /* NICKIP */ + 0, /* SJOIN */ + CAPAB_ZIP, /* ZIP */ + 0, /* BURST */ + CAPAB_TS5, /* TS5 */ + 0, /* TS3 */ + 0, /* DKEY */ + 0, /* PT4 */ + 0, /* SCS */ + CAPAB_QS, /* QS */ + CAPAB_UID, /* UID */ + CAPAB_KNOCK, /* KNOCK */ + 0, /* CLIENT */ + 0, /* IPV6 */ + 0, /* SSJ5 */ + 0, /* SN2 */ + 0, /* TOKEN */ + 0, /* VHOST */ + 0, /* SSJ3 */ + 0, /* NICK2 */ + 0, /* UMODE2 */ + 0, /* VL */ + 0, /* TLKEXT */ + 0, /* DODKEY */ + 0, /* DOZIP */ 0, 0, 0} }; @@ -153,20 +153,20 @@ plexus_ProcessUsermodes (User * user, int ac, const char **av) ac--; if (debug) - alog ("debug: Changing mode for %s to %s", user->nick, modes); + alog ("debug: Changing mode for %s to %s", user->nick, modes); while (*modes) - { + { - /* This looks better, much better than "add ? (do_add) : (do_remove)". - * At least this is readable without paying much attention :) -GD - */ - if (add) + /* This looks better, much better than "add ? (do_add) : (do_remove)". + * At least this is readable without paying much attention :) -GD + */ + if (add) user->mode |= umodes[(int) *modes]; - else + else user->mode &= ~umodes[(int) *modes]; - switch (*modes++) + switch (*modes++) { case '+': add = 1; @@ -176,11 +176,11 @@ plexus_ProcessUsermodes (User * user, int ac, const char **av) break; case 'd': if (ac == 0) - { - alog ("user: umode +d with no parameter (?) for user %s", - user->nick); - break; - } + { + alog ("user: umode +d with no parameter (?) for user %s", + user->nick); + break; + } ac--; av++; @@ -191,30 +191,30 @@ plexus_ProcessUsermodes (User * user, int ac, const char **av) break; case 'o': if (add) - { - opcnt++; + { + opcnt++; - if (WallOper) + if (WallOper) anope_SendGlobops (s_OperServ, "\2%s\2 is now an IRC operator.", user->nick); - display_news (user, NEWS_OPER); + display_news (user, NEWS_OPER); - } + } else - { - opcnt--; - } + { + opcnt--; + } break; case 'r': if (add && !nick_identified (user)) - { - common_svsmode (user, "-r", NULL); - user->mode &= ~UMODE_r; - } + { + common_svsmode (user, "-r", NULL); + user->mode &= ~UMODE_r; + } break; } - } + } } unsigned long umodes[128] = { @@ -276,7 +276,7 @@ char myCsmodes[128] = { 0, 0, 0, 0, 0, - 'h', /* (37) % Channel halfops */ + 'h', /* (37) % Channel halfops */ 'a', 0, 0, 0, 0, @@ -479,18 +479,18 @@ void plexus_cmd_notice (const char *source, const char *dest, const char *buf) { if (!buf) - { - return; - } + { + return; + } if (NSDefFlags & NI_MSG) - { - plexus_cmd_privmsg2 (source, dest, buf); - } + { + plexus_cmd_privmsg2 (source, dest, buf); + } else - { - send_cmd (source, "NOTICE %s :%s", dest, buf); - } + { + send_cmd (source, "NOTICE %s :%s", dest, buf); + } } void @@ -503,9 +503,9 @@ void plexus_cmd_privmsg (const char *source, const char *dest, const char *buf) { if (!buf) - { - return; - } + { + return; + } send_cmd (source, "PRIVMSG %s :%s", dest, buf); } @@ -533,9 +533,9 @@ void plexus_SendGlobops (const char *source, const char *buf) { if (!buf) - { - return; - } + { + return; + } send_cmd (source ? source : ServerName, "OPERWALL :%s", buf); } @@ -558,18 +558,18 @@ int anope_event_nick (const char *source, int ac, const char **av) { if (ac != 2) - { - User *user = do_nick (source, av[0], av[4], av[8], av[6], av[9], - strtoul (av[2], NULL, 10), - strtoul (av[7], NULL, 0), 0, av[5], NULL); - if (user) + { + User *user = do_nick (source, av[0], av[4], av[8], av[6], av[9], + strtoul (av[2], NULL, 10), + strtoul (av[7], NULL, 0), 0, av[5], NULL); + if (user) anope_ProcessUsermodes (user, 1, &av[3]); - } + } else - { - do_nick (source, av[0], NULL, NULL, NULL, NULL, - strtoul (av[1], NULL, 10), 0, 0, NULL, NULL); - } + { + do_nick (source, av[0], NULL, NULL, NULL, NULL, + strtoul (av[1], NULL, 10), 0, 0, NULL, NULL); + } return MOD_CONT; } @@ -577,46 +577,46 @@ int anope_event_topic (const char *source, int ac, const char **av) { if (ac == 4) - { - do_topic (source, ac, av); - } + { + do_topic (source, ac, av); + } else - { - Channel *c = findchan (av[0]); - time_t topic_time = time (NULL); + { + Channel *c = findchan (av[0]); + time_t topic_time = time (NULL); - if (!c) + if (!c) { if (debug) - { - alog ("debug: TOPIC %s for nonexistent channel %s", - merge_args (ac - 1, av + 1), av[0]); - } + { + alog ("debug: TOPIC %s for nonexistent channel %s", + merge_args (ac - 1, av + 1), av[0]); + } return MOD_CONT; } - if (check_topiclock (c, topic_time)) + if (check_topiclock (c, topic_time)) return MOD_CONT; - if (c->topic) + if (c->topic) { free (c->topic); c->topic = NULL; } - if (ac > 1 && *av[1]) + if (ac > 1 && *av[1]) c->topic = sstrdup (av[1]); - strscpy (c->topic_setter, source, sizeof (c->topic_setter)); - c->topic_time = topic_time; + strscpy (c->topic_setter, source, sizeof (c->topic_setter)); + c->topic_time = topic_time; - record_topic (av[0]); + record_topic (av[0]); if (ac > 1 && *av[1]) - send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[1]); + send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[1]); else - send_event(EVENT_TOPIC_UPDATED, 2, av[0], ""); + send_event(EVENT_TOPIC_UPDATED, 2, av[0], ""); - } + } return MOD_CONT; } @@ -624,7 +624,7 @@ int anope_event_tburst (const char *source, int ac, const char **av) { if (ac != 5) - return MOD_CONT; + return MOD_CONT; av[0] = av[1]; av[1] = av[3]; @@ -643,28 +643,28 @@ int anope_event_encap (const char *source, int ac, const char **av) { if (ac < 2) - return MOD_CONT; + return MOD_CONT; if (!stricmp (av[1], "CHGHOST")) - { - User *u; + { + User *u; - if (ac != 4) + if (ac != 4) return MOD_CONT; - u = finduser (av[2]); - if (!u) + u = finduser (av[2]); + if (!u) { if (debug) - { - alog ("debug: CHGHOST for nonexistent user %s", av[2]); - } + { + alog ("debug: CHGHOST for nonexistent user %s", av[2]); + } return MOD_CONT; } - u->SetDisplayedHost(av[3]); - return MOD_CONT; - } + u->SetDisplayedHost(av[3]); + return MOD_CONT; + } return MOD_CONT; } @@ -672,7 +672,7 @@ int anope_event_436 (const char *source, int ac, const char **av) { if (ac < 1) - return MOD_CONT; + return MOD_CONT; m_nickcoll (av[0]); return MOD_CONT; @@ -803,7 +803,7 @@ plexus_cmd_topic (const char *whosets, const char *chan, const char *whosetit, const char *topic, time_t when) { send_cmd (whosets, "ENCAP * TOPIC %s %s %lu :%s", chan, whosetit, - (unsigned long int) when, topic); + (unsigned long int) when, topic); } void @@ -818,18 +818,18 @@ plexus_SendVhost (const char *nick, const char *vIdent, const char *vhost) User *u; if (!nick) - { - return; - } + { + return; + } u = finduser (nick); if (u) - { - send_cmd (ServerName, "ENCAP * CHGHOST %s %s", u->nick, vhost); - common_svsmode (u, "+x", NULL); - u->mode |= UMODE_x; - } + { + send_cmd (ServerName, "ENCAP * CHGHOST %s %s", u->nick, vhost); + common_svsmode (u, "+x", NULL); + u->mode |= UMODE_x; + } } void @@ -842,7 +842,7 @@ void plexus_SendJoin (const char *user, const char *channel, time_t chantime) { send_cmd (ServerName, "SJOIN %ld %s + :%s", (long int) chantime, channel, - user); + user); } /* @@ -859,21 +859,21 @@ plexus_SendAkill (const char *user, const char *host, const char *who, time_t wh time_t expires, const char *reason) { send_cmd (s_OperServ, "KLINE * %ld %s %s :%s", - (long int) (expires - (long) time (NULL)), user, host, reason); + (long int) (expires - (long) time (NULL)), user, host, reason); } void plexus_SendSVSKill (const char *source, const char *user, const char *buf) { if (!buf) - { - return; - } + { + return; + } if (!source || !user) - { - return; - } + { + return; + } send_cmd (source, "KILL %s :%s", user, buf); } @@ -882,17 +882,17 @@ void plexus_SendSVSMode (User * u, int ac, const char **av) { send_cmd (ServerName, "ENCAP * SVSMODE %s %ld %s%s%s", u->nick, - (long int) u->timestamp, av[0], (ac == 2 ? " " : ""), - (ac == 2 ? av[1] : "")); + (long int) u->timestamp, av[0], (ac == 2 ? " " : ""), + (ac == 2 ? av[1] : "")); } /* * SVINFO - * parv[0] = sender prefix - * parv[1] = TS_CURRENT for the server - * parv[2] = TS_MIN for the server - * parv[3] = server is standalone or connected to non-TS only - * parv[4] = server's idea of UTC time + * parv[0] = sender prefix + * parv[1] = TS_CURRENT for the server + * parv[2] = TS_MIN for the server + * parv[3] = server is standalone or connected to non-TS only + * parv[4] = server's idea of UTC time */ void plexus_cmd_svinfo () @@ -902,31 +902,31 @@ plexus_cmd_svinfo () /* CAPAB */ /* - QS - Can handle quit storm removal - EX - Can do channel +e exemptions - CHW - Can do channel wall @# - LL - Can do lazy links - IE - Can do invite exceptions - EOB - Can do EOB message - KLN - Can do KLINE message - GLN - Can do GLINE message + QS - Can handle quit storm removal + EX - Can do channel +e exemptions + CHW - Can do channel wall @# + LL - Can do lazy links + IE - Can do invite exceptions + EOB - Can do EOB message + KLN - Can do KLINE message + GLN - Can do GLINE message HOPS - can do half ops (+h) - HUB - This server is a HUB + HUB - This server is a HUB AOPS - Can do anon ops (+a) - UID - Can do UIDs - ZIP - Can do ZIPlinks - ENC - Can do ENCrypted links + UID - Can do UIDs + ZIP - Can do ZIPlinks + ENC - Can do ENCrypted links KNOCK - supports KNOCK TBURST - supports TBURST PARA - supports invite broadcasting for +p ENCAP - supports encapsulization of protocol messages - SVS - supports services protocol extensions + SVS - supports services protocol extensions */ void plexus_cmd_capab () { send_cmd (NULL, - "CAPAB :QS EX CHW IE EOB KLN UNKLN GLN HUB KNOCK TBURST PARA ENCAP SVS"); + "CAPAB :QS EX CHW IE EOB KLN UNKLN GLN HUB KNOCK TBURST PARA ENCAP SVS"); } /* PASS */ @@ -949,11 +949,11 @@ plexus_SendConnect (int servernum) me_server = new_server (NULL, ServerName, ServerDesc, SERVER_ISME, NULL); if (servernum == 1) - plexus_cmd_pass (RemotePassword); + plexus_cmd_pass (RemotePassword); else if (servernum == 2) - plexus_cmd_pass (RemotePassword2); + plexus_cmd_pass (RemotePassword2); else if (servernum == 3) - plexus_cmd_pass (RemotePassword3); + plexus_cmd_pass (RemotePassword3); plexus_cmd_capab (); plexus_SendServer (ServerName, 1, ServerDesc); @@ -970,12 +970,12 @@ plexus_cmd_svsinfo () void plexus_SendClientIntroduction (const char *nick, const char *user, const char *host, const char *real, - const char *modes) + const char *modes) { EnforceQlinedNick (nick, NULL); send_cmd (ServerName, "NICK %s 1 %ld %s %s %s %s 0 %s :%s", nick, - (long int) time (NULL), modes, user, host, ServerName, host, - real); + (long int) time (NULL), modes, user, host, ServerName, host, + real); plexus_SendSQLine (nick, "Reserved for services"); } @@ -984,20 +984,20 @@ void plexus_SendPart (const char *nick, const char *chan, const char *buf) { if (buf) - { - send_cmd (nick, "PART %s :%s", chan, buf); - } + { + send_cmd (nick, "PART %s :%s", chan, buf); + } else - { - send_cmd (nick, "PART %s", chan); - } + { + send_cmd (nick, "PART %s", chan); + } } int anope_event_ping (const char *source, int ac, const char **av) { if (ac < 1) - return MOD_CONT; + return MOD_CONT; plexus_SendPong (ac > 1 ? av[1] : ServerName, av[0]); return MOD_CONT; } @@ -1006,9 +1006,9 @@ int anope_event_away (const char *source, int ac, const char **av) { if (!source) - { - return MOD_CONT; - } + { + return MOD_CONT; + } m_away (source, (ac ? av[0] : NULL)); return MOD_CONT; } @@ -1017,7 +1017,7 @@ int anope_event_kill (const char *source, int ac, const char **av) { if (ac != 2) - return MOD_CONT; + return MOD_CONT; m_kill (av[0], av[1]); return MOD_CONT; @@ -1027,7 +1027,7 @@ int anope_event_kick (const char *source, int ac, const char **av) { if (ac != 3) - return MOD_CONT; + return MOD_CONT; do_kick (source, ac, av); return MOD_CONT; } @@ -1042,7 +1042,7 @@ anope_event_eob (const char *source, int ac, const char **av) * server finished bursting. -GD */ if (!s && serv_uplink) - s = serv_uplink; + s = serv_uplink; finish_sync (s, 1); return MOD_CONT; @@ -1059,7 +1059,7 @@ int anope_event_join (const char *source, int ac, const char **av) { if (ac != 1) - return MOD_CONT; + return MOD_CONT; do_join (source, ac, av); return MOD_CONT; } @@ -1068,9 +1068,9 @@ int anope_event_motd (const char *source, int ac, const char **av) { if (!source) - { - return MOD_CONT; - } + { + return MOD_CONT; + } m_motd (source); return MOD_CONT; @@ -1080,7 +1080,7 @@ int anope_event_privmsg (const char *source, int ac, const char **av) { if (ac != 2) - return MOD_CONT; + return MOD_CONT; m_privmsg (source, av[0], av[1]); return MOD_CONT; } @@ -1089,7 +1089,7 @@ int anope_event_part (const char *source, int ac, const char **av) { if (ac < 1 || ac > 2) - return MOD_CONT; + return MOD_CONT; do_part (source, ac, av); return MOD_CONT; } @@ -1098,9 +1098,9 @@ int anope_event_whois (const char *source, int ac, const char **av) { if (source && ac >= 1) - { - m_whois (source, av[0]); - } + { + m_whois (source, av[0]); + } return MOD_CONT; } @@ -1109,9 +1109,9 @@ int anope_event_server (const char *source, int ac, const char **av) { if (!stricmp (av[1], "1")) - { - uplink = sstrdup (av[0]); - } + { + uplink = sstrdup (av[0]); + } do_server (source, av[0], av[1], av[2], NULL); return MOD_CONT; } @@ -1120,7 +1120,7 @@ int anope_event_squit (const char *source, int ac, const char **av) { if (ac != 2) - return MOD_CONT; + return MOD_CONT; do_squit (source, ac, av); return MOD_CONT; } @@ -1129,7 +1129,7 @@ int anope_event_quit (const char *source, int ac, const char **av) { if (ac != 1) - return MOD_CONT; + return MOD_CONT; do_quit (source, ac, av); return MOD_CONT; } @@ -1144,14 +1144,14 @@ void plexus_cmd_372_error (const char *source) { send_cmd (ServerName, "422 %s :- MOTD file not found! Please " - "contact your IRC administrator.", source); + "contact your IRC administrator.", source); } void plexus_cmd_375 (const char *source) { send_cmd (ServerName, "375 %s :- %s Message of the Day", - source, ServerName); + source, ServerName); } void @@ -1165,9 +1165,9 @@ void plexus_cmd_391 (const char *source, const char *timestr) { if (!timestr) - { - return; - } + { + return; + } send_cmd (ServerName, "391 :%s %s :%s", source, ServerName, timestr); } @@ -1176,9 +1176,9 @@ void plexus_cmd_250 (const char *buf) { if (!buf) - { - return; - } + { + return; + } send_cmd (ServerName, "250 %s", buf); } @@ -1188,9 +1188,9 @@ void plexus_cmd_307 (const char *buf) { if (!buf) - { - return; - } + { + return; + } send_cmd (ServerName, "307 %s", buf); } @@ -1200,9 +1200,9 @@ void plexus_cmd_311 (const char *buf) { if (!buf) - { - return; - } + { + return; + } send_cmd (ServerName, "311 %s", buf); } @@ -1212,9 +1212,9 @@ void plexus_cmd_312 (const char *buf) { if (!buf) - { - return; - } + { + return; + } send_cmd (ServerName, "312 %s", buf); } @@ -1224,9 +1224,9 @@ void plexus_cmd_317 (const char *buf) { if (!buf) - { - return; - } + { + return; + } send_cmd (ServerName, "317 %s", buf); } @@ -1236,19 +1236,19 @@ void plexus_cmd_219 (const char *source, const char *letter) { if (!source) - { - return; - } + { + return; + } if (letter) - { - send_cmd (ServerName, "219 %s %c :End of /STATS report.", source, + { + send_cmd (ServerName, "219 %s %c :End of /STATS report.", source, *letter); - } + } else - { - send_cmd (ServerName, "219 %s l :End of /STATS report.", source); - } + { + send_cmd (ServerName, "219 %s l :End of /STATS report.", source); + } } /* 401 */ @@ -1256,9 +1256,9 @@ void plexus_cmd_401 (const char *source, const char *who) { if (!source || !who) - { - return; - } + { + return; + } send_cmd (ServerName, "401 %s %s :No such service.", source, who); } @@ -1267,9 +1267,9 @@ void plexus_cmd_318 (const char *source, const char *who) { if (!source || !who) - { - return; - } + { + return; + } send_cmd (ServerName, "318 %s %s :End of /WHOIS list.", source, who); } @@ -1279,9 +1279,9 @@ void plexus_cmd_242 (const char *buf) { if (!buf) - { - return; - } + { + return; + } send_cmd (ServerName, "242 %s", buf); } @@ -1291,9 +1291,9 @@ void plexus_cmd_243 (const char *buf) { if (!buf) - { - return; - } + { + return; + } send_cmd (ServerName, "243 %s", buf); } @@ -1303,9 +1303,9 @@ void plexus_cmd_211 (const char *buf) { if (!buf) - { - return; - } + { + return; + } send_cmd (ServerName, "211 %s", buf); } @@ -1314,9 +1314,9 @@ void plexus_SendMode (const char *source, const char *dest, const char *buf) { if (!buf) - { - return; - } + { + return; + } send_cmd (source, "MODE %s %s", dest, buf); } @@ -1326,8 +1326,8 @@ plexus_cmd_nick (const char *nick, const char *name, const char *mode) { EnforceQlinedNick (nick, NULL); send_cmd (ServerName, "NICK %s 1 %ld %s %s %s %s 0 %s :%s", nick, - (long int) time (NULL), mode, ServiceUser, ServiceHost, - ServerName, ServiceHost, (name)); + (long int) time (NULL), mode, ServiceUser, ServiceHost, + ServerName, ServiceHost, (name)); send_cmd (nick, "RESV * %s :%s", nick, "Reserved for services"); } @@ -1335,22 +1335,22 @@ void plexus_SendKick (const char *source, const char *chan, const char *user, const char *buf) { if (buf) - { - send_cmd (source, "KICK %s %s :%s", chan, user, buf); - } + { + send_cmd (source, "KICK %s %s :%s", chan, user, buf); + } else - { - send_cmd (source, "KICK %s %s", chan, user); - } + { + send_cmd (source, "KICK %s %s", chan, user); + } } void plexus_SendNoticeChanops (const char *source, const char *dest, const char *buf) { if (!buf) - { - return; - } + { + return; + } send_cmd (ServerName, "NOTICE @%s :%s", dest, buf); } @@ -1366,13 +1366,13 @@ void plexus_SendQuit (const char *source, const char *buf) { if (buf) - { - send_cmd (source, "QUIT :%s", buf); - } + { + send_cmd (source, "QUIT :%s", buf); + } else - { - send_cmd (source, "QUIT"); - } + { + send_cmd (source, "QUIT"); + } } /* PONG */ @@ -1387,9 +1387,9 @@ void plexus_SendInvite (const char *source, const char *chan, const char *nick) { if (!source || !chan || !nick) - { - return; - } + { + return; + } send_cmd (source, "INVITE %s %s", nick, chan); } @@ -1399,9 +1399,9 @@ void plexus_SendSquit (const char *servname, const char *message) { if (!servname || !message) - { - return; - } + { + return; + } send_cmd (ServerName, "SQUIT %s :%s", servname, message); } @@ -1410,26 +1410,26 @@ int anope_event_mode (const char *source, int ac, const char **av) { if (ac < 2) - return MOD_CONT; + return MOD_CONT; if (*av[0] == '#' || *av[0] == '&') - { - do_cmode (source, ac, av); - } + { + do_cmode (source, ac, av); + } else - { - Server *s; - s = findserver (servlist, source); + { + Server *s; + s = findserver (servlist, source); - if (s && *av[0]) + if (s && *av[0]) { do_umode (av[0], ac, av); } - else + else { do_umode (source, ac, av); } - } + } return MOD_CONT; } @@ -1437,8 +1437,8 @@ void plexus_cmd_351 (const char *source) { send_cmd (ServerName, "351 %s Anope-%s %s :%s - %s (%s) -- %s", - source, version_number, ServerName, ircd->name, version_flags, - EncModule, version_build); + source, version_number, ServerName, ircd->name, version_flags, + EncModule, version_build); } /* Event: PROTOCTL */ @@ -1451,29 +1451,29 @@ anope_event_capab (const char *source, int ac, const char **av) char *str; if (ac < 1) - return MOD_CONT; + return MOD_CONT; /* We get the params as one arg, we should split it for capab_parse */ argv = (const char **)scalloc (argvsize, sizeof (const char *)); argc = 0; while ((str = myStrGetToken (av[0], ' ', argc))) - { - if (argc == argvsize) + { + if (argc == argvsize) { argvsize += 8; argv = (const char **)srealloc (argv, argvsize * sizeof (const char *)); } - argv[argc] = str; - argc++; - } + argv[argc] = str; + argc++; + } capab_parse (argc, argv); /* Free our built ac/av */ for (argvsize = 0; argvsize < argc; argvsize++) - { - free ((char *)argv[argvsize]); - } + { + free ((char *)argv[argvsize]); + } free ((char **)argv); return MOD_CONT; @@ -1484,8 +1484,8 @@ void plexus_SendSVSHOLD (const char *nick) { send_cmd (s_OperServ, "ENCAP * RESV %d %s 0 :%s", NSReleaseTimeout, nick, - "This nick is being held for a registered user. " - "For help with regaining nicknames please see /nickserv help release"); + "This nick is being held for a registered user. " + "For help with regaining nicknames please see /nickserv help release"); } /* SVSHOLD - release */ @@ -1502,21 +1502,21 @@ plexus_SendForceNickChange (const char *nick, const char *newnick, time_t when) User *u; if (!nick || !newnick) - return; + return; if( (u = finduser (nick))) { - send_cmd (ServerName, "ENCAP * SVSNICK %s %ld %s %ld", - u->nick, (long int) u->timestamp, newnick, (long int) when); + send_cmd (ServerName, "ENCAP * SVSNICK %s %ld %s %ld", + u->nick, (long int) u->timestamp, newnick, (long int) when); } } void plexus_SendGuestNick (const char *nick, const char *user, const char *host, const char *real, - const char *modes) + const char *modes) { send_cmd (ServerName, "NICK %s 1 %ld %s %s %s %s 0 %s :%s", nick, - (long int) time (NULL), modes, user, host, ServerName, host, - real); + (long int) time (NULL), modes, user, host, ServerName, host, + real); } void @@ -1545,7 +1545,7 @@ void plexus_SendSVID (const char *nick, time_t ts) { send_cmd (ServerName, "ENCAP * SVSMODE %s %lu +d 1", nick, - (unsigned long int) ts); + (unsigned long int) ts); } /* SVSMODE +d */ @@ -1571,17 +1571,17 @@ plexus_SendSVID3 (User * u, const char *ts) strlcpy(modes, "+r", sizeof(modes)); if(ircd->rootmodeonid && is_services_root(u)) { - strlcat(modes, ircd->rootmodeonid, sizeof(modes)); + strlcat(modes, ircd->rootmodeonid, sizeof(modes)); } else if(ircd->adminmodeonid && is_services_admin(u)) { - strlcat(modes, ircd->adminmodeonid, sizeof(modes)); + strlcat(modes, ircd->adminmodeonid, sizeof(modes)); } else if(ircd->opermodeonid && is_services_oper(u)) { - strlcat(modes, ircd->opermodeonid, sizeof(modes)); + strlcat(modes, ircd->opermodeonid, sizeof(modes)); } if (u->svid != u->timestamp) { - strlcat(modes, "d", sizeof(modes)); - common_svsmode (u, modes, ts); + strlcat(modes, "d", sizeof(modes)); + common_svsmode (u, modes, ts); } else { - common_svsmode (u, modes, NULL); + common_svsmode (u, modes, NULL); } } @@ -1590,20 +1590,20 @@ void plexus_SendChangeBotNick (const char *oldnick, const char *newnick) { if (!oldnick || !newnick) - { - return; - } + { + return; + } send_cmd (oldnick, "NICK %s", newnick); } /* * SVINFO - * parv[0] = sender prefix - * parv[1] = TS_CURRENT for the server - * parv[2] = TS_MIN for the server - * parv[3] = server is standalone or connected to non-TS only - * parv[4] = server's idea of UTC time + * parv[0] = sender prefix + * parv[1] = TS_CURRENT for the server + * parv[2] = TS_MIN for the server + * parv[3] = server is standalone or connected to non-TS only + * parv[4] = server's idea of UTC time */ int anope_event_svinfo (const char *source, int ac, const char **av) @@ -1665,12 +1665,12 @@ int anope_event_error (const char *source, int ac, const char **av) { if (ac >= 1) - { - if (debug) + { + if (debug) { alog ("debug: %s", av[0]); } - } + } return MOD_CONT; } @@ -1680,10 +1680,10 @@ plexus_SendJupe (const char *jserver, const char *who, const char *reason) char rbuf[256]; snprintf (rbuf, sizeof (rbuf), "(H) Juped by %s%s%s", who, - reason ? ": " : "", reason ? reason : ""); + reason ? ": " : "", reason ? reason : ""); if (findserver(servlist, jserver)) - plexus_SendSquit (jserver, rbuf); + plexus_SendSquit (jserver, rbuf); plexus_SendServer (jserver, 2, rbuf); new_server (me_server, jserver, rbuf, SERVER_JUPED, NULL); } @@ -1717,13 +1717,13 @@ plexus_SendCTCP (const char *source, const char *dest, const char *buf) char *s; if (!buf) - { - return; - } + { + return; + } else - { - s = normalizeBuffer (buf); - } + { + s = normalizeBuffer (buf); + } send_cmd (source, "NOTICE %s :\1%s \1", dest, s); free (s); diff --git a/src/protocol/obsolete/ptlink.c b/src/protocol/obsolete/ptlink.c index ffc7915e0..b0cba3bfa 100644 --- a/src/protocol/obsolete/ptlink.c +++ b/src/protocol/obsolete/ptlink.c @@ -16,379 +16,379 @@ #include "ptlink.h" IRCDVar myIrcd[] = { - {"PTlink 6.15.*+", /* ircd name */ - "+o", /* nickserv mode */ - "+o", /* chanserv mode */ - "+o", /* memoserv mode */ - "+o", /* hostserv mode */ - "+io", /* operserv mode */ - "+o", /* botserv mode */ - "+h", /* helpserv mode */ - "+i", /* Dev/Null mode */ - "+io", /* Global mode */ - "+o", /* nickserv alias mode */ - "+o", /* chanserv alias mode */ - "+o", /* memoserv alias mode */ - "+io", /* hostserv alias mode */ - "+io", /* operserv alias mode */ - "+o", /* botserv alias mode */ - "+h", /* helpserv alias mode */ - "+i", /* Dev/Null alias mode */ - "+io", /* Global alias mode */ - "+", /* Used by BotServ Bots */ - 2, /* Chan Max Symbols */ - "-inpsmtCRKOASdcqBNl", /* Modes to Remove */ - "+ao", /* Channel Umode used by Botserv bots */ - 1, /* SVSNICK */ - 1, /* Vhost */ - 0, /* Has Owner */ - NULL, /* Mode to set for an owner */ - NULL, /* Mode to unset for an owner */ - "+a", /* Mode to set for chan admin */ - "-a", /* Mode to unset for chan admin */ - "+r", /* Mode On Reg */ - NULL, /* Mode on ID for Roots */ - NULL, /* Mode on ID for Admins */ - NULL, /* Mode on ID for Opers */ - "-r", /* Mode on UnReg */ - NULL, /* Mode on Nick Change */ - 1, /* Supports SGlines */ - 1, /* Supports SQlines */ - 1, /* Supports SZlines */ - 0, /* Supports Halfop +h */ - 4, /* Number of server args */ - 0, /* Join 2 Set */ - 0, /* Join 2 Message */ - 1, /* Has exceptions +e */ - 0, /* TS Topic Forward */ - 0, /* TS Topci Backward */ - 0, /* Protected Umode */ - 0, /* Has Admin */ - 0, /* Chan SQlines */ - 0, /* Quit on Kill */ - 0, /* SVSMODE unban */ - 1, /* Has Protect */ - 0, /* Reverse */ - 1, /* Chan Reg */ - CMODE_r, /* Channel Mode */ - 1, /* vidents */ - 0, /* svshold */ - 0, /* time stamp on mode */ - 0, /* NICKIP */ - 0, /* O:LINE */ - 1, /* UMODE */ - 1, /* VHOST ON NICK */ - 0, /* Change RealName */ - CMODE_K, /* No Knock */ - CMODE_A, /* Admin Only */ - DEFAULT_MLOCK, /* Default MLOCK */ - UMODE_VH, /* Vhost Mode */ - 1, /* +f */ - 0, /* +L */ - CMODE_f, - 0, - 1, - 1, /* No Knock requires +i */ - NULL, /* CAPAB Chan Modes */ - 0, /* We support TOKENS */ - 1, /* TOKENS are CASE inSensitive */ - 0, /* TIME STAMPS are BASE64 */ - 0, /* +I support */ - 0, /* SJOIN ban char */ - 0, /* SJOIN except char */ - 0, /* SJOIN invite char */ - 0, /* Can remove User Channel Modes with SVSMODE */ - 0, /* Sglines are not enforced until user reconnects */ - NULL, /* vhost char */ - 0, /* ts6 */ - 1, /* support helper umode */ - 0, /* p10 */ - NULL, /* character set */ - 0, /* reports sync state */ - 0, /* CIDR channelbans */ - } - , - {NULL} + {"PTlink 6.15.*+", /* ircd name */ + "+o", /* nickserv mode */ + "+o", /* chanserv mode */ + "+o", /* memoserv mode */ + "+o", /* hostserv mode */ + "+io", /* operserv mode */ + "+o", /* botserv mode */ + "+h", /* helpserv mode */ + "+i", /* Dev/Null mode */ + "+io", /* Global mode */ + "+o", /* nickserv alias mode */ + "+o", /* chanserv alias mode */ + "+o", /* memoserv alias mode */ + "+io", /* hostserv alias mode */ + "+io", /* operserv alias mode */ + "+o", /* botserv alias mode */ + "+h", /* helpserv alias mode */ + "+i", /* Dev/Null alias mode */ + "+io", /* Global alias mode */ + "+", /* Used by BotServ Bots */ + 2, /* Chan Max Symbols */ + "-inpsmtCRKOASdcqBNl", /* Modes to Remove */ + "+ao", /* Channel Umode used by Botserv bots */ + 1, /* SVSNICK */ + 1, /* Vhost */ + 0, /* Has Owner */ + NULL, /* Mode to set for an owner */ + NULL, /* Mode to unset for an owner */ + "+a", /* Mode to set for chan admin */ + "-a", /* Mode to unset for chan admin */ + "+r", /* Mode On Reg */ + NULL, /* Mode on ID for Roots */ + NULL, /* Mode on ID for Admins */ + NULL, /* Mode on ID for Opers */ + "-r", /* Mode on UnReg */ + NULL, /* Mode on Nick Change */ + 1, /* Supports SGlines */ + 1, /* Supports SQlines */ + 1, /* Supports SZlines */ + 0, /* Supports Halfop +h */ + 4, /* Number of server args */ + 0, /* Join 2 Set */ + 0, /* Join 2 Message */ + 1, /* Has exceptions +e */ + 0, /* TS Topic Forward */ + 0, /* TS Topci Backward */ + 0, /* Protected Umode */ + 0, /* Has Admin */ + 0, /* Chan SQlines */ + 0, /* Quit on Kill */ + 0, /* SVSMODE unban */ + 1, /* Has Protect */ + 0, /* Reverse */ + 1, /* Chan Reg */ + CMODE_r, /* Channel Mode */ + 1, /* vidents */ + 0, /* svshold */ + 0, /* time stamp on mode */ + 0, /* NICKIP */ + 0, /* O:LINE */ + 1, /* UMODE */ + 1, /* VHOST ON NICK */ + 0, /* Change RealName */ + CMODE_K, /* No Knock */ + CMODE_A, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + UMODE_VH, /* Vhost Mode */ + 1, /* +f */ + 0, /* +L */ + CMODE_f, + 0, + 1, + 1, /* No Knock requires +i */ + NULL, /* CAPAB Chan Modes */ + 0, /* We support TOKENS */ + 1, /* TOKENS are CASE inSensitive */ + 0, /* TIME STAMPS are BASE64 */ + 0, /* +I support */ + 0, /* SJOIN ban char */ + 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ + 0, /* Can remove User Channel Modes with SVSMODE */ + 0, /* Sglines are not enforced until user reconnects */ + NULL, /* vhost char */ + 0, /* ts6 */ + 1, /* support helper umode */ + 0, /* p10 */ + NULL, /* character set */ + 0, /* reports sync state */ + 0, /* CIDR channelbans */ + } + , + {NULL} }; IRCDCAPAB myIrcdcap[] = { - { - 0, /* NOQUIT */ - 0, /* TSMODE */ - 0, /* UNCONNECT */ - 0, /* NICKIP */ - 0, /* SJOIN */ - CAPAB_ZIP, /* ZIP */ - 0, /* BURST */ - 0, /* TS5 */ - 0, /* TS3 */ - 0, /* DKEY */ - CAPAB_PT4, /* PT4 */ - CAPAB_SCS, /* SCS */ - CAPAB_QS, /* QS */ - 0, /* UID */ - 0, /* KNOCK */ - 0, /* CLIENT */ - 0, /* IPV6 */ - 0, /* SSJ5 */ - 0, /* SN2 */ - 0, /* TOKEN */ - 0, /* VHOST */ - 0, /* SSJ3 */ - 0, /* NICK2 */ - 0, /* UMODE2 */ - 0, /* VL */ - 0, /* TLKEXT */ - 0, /* DODKEY */ - 0, /* DOZIP */ - 0, 0, 0} + { + 0, /* NOQUIT */ + 0, /* TSMODE */ + 0, /* UNCONNECT */ + 0, /* NICKIP */ + 0, /* SJOIN */ + CAPAB_ZIP, /* ZIP */ + 0, /* BURST */ + 0, /* TS5 */ + 0, /* TS3 */ + 0, /* DKEY */ + CAPAB_PT4, /* PT4 */ + CAPAB_SCS, /* SCS */ + CAPAB_QS, /* QS */ + 0, /* UID */ + 0, /* KNOCK */ + 0, /* CLIENT */ + 0, /* IPV6 */ + 0, /* SSJ5 */ + 0, /* SN2 */ + 0, /* TOKEN */ + 0, /* VHOST */ + 0, /* SSJ3 */ + 0, /* NICK2 */ + 0, /* UMODE2 */ + 0, /* VL */ + 0, /* TLKEXT */ + 0, /* DODKEY */ + 0, /* DOZIP */ + 0, 0, 0} }; unsigned long umodes[128] = { - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused, Unused, Horzontal Tab */ - 0, 0, 0, /* Line Feed, Unused, Unused */ - 0, 0, 0, /* Carriage Return, Unused, Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused, Unused, Space */ - 0, 0, 0, /* ! " # */ - 0, 0, 0, /* $ % & */ - 0, 0, 0, /* ! ( ) */ - 0, 0, 0, /* * + , */ - 0, 0, 0, /* - . / */ - 0, 0, /* 0 1 */ - 0, 0, /* 2 3 */ - 0, 0, /* 4 5 */ - 0, 0, /* 6 7 */ - 0, 0, /* 8 9 */ - 0, 0, /* : ; */ - 0, 0, 0, /* < = > */ - 0, 0, /* ? @ */ - UMODE_A, UMODE_B, 0, /* A B C */ - 0, 0, 0, /* D E F */ - 0, UMODE_H, 0, /* G H I */ - 0, 0, 0, /* J K L */ - 0, UMODE_N, UMODE_O, /* M N O */ - 0, 0, UMODE_R, /* P Q R */ - UMODE_S, UMODE_T, 0, /* S T U */ - 0, 0, 0, /* V W X */ - 0, /* Y */ - 0, /* Z */ - 0, 0, 0, /* [ \ ] */ - 0, 0, 0, /* ^ _ ` */ - UMODE_a, 0, 0, /* a b c */ - 0, 0, 0, /* d e f */ - 0, UMODE_h, UMODE_i, /* g h i */ - 0, 0, 0, /* j k l */ - 0, 0, UMODE_o, /* m n o */ - UMODE_p, 0, UMODE_r, /* p q r */ - UMODE_s, 0, 0, /* s t u */ - UMODE_v, UMODE_w, 0, /* v w x */ - UMODE_y, /* y */ - UMODE_z, /* z */ - 0, 0, 0, /* { | } */ - 0, 0 /* ~ � */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused, Unused, Horzontal Tab */ + 0, 0, 0, /* Line Feed, Unused, Unused */ + 0, 0, 0, /* Carriage Return, Unused, Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused, Unused, Space */ + 0, 0, 0, /* ! " # */ + 0, 0, 0, /* $ % & */ + 0, 0, 0, /* ! ( ) */ + 0, 0, 0, /* * + , */ + 0, 0, 0, /* - . / */ + 0, 0, /* 0 1 */ + 0, 0, /* 2 3 */ + 0, 0, /* 4 5 */ + 0, 0, /* 6 7 */ + 0, 0, /* 8 9 */ + 0, 0, /* : ; */ + 0, 0, 0, /* < = > */ + 0, 0, /* ? @ */ + UMODE_A, UMODE_B, 0, /* A B C */ + 0, 0, 0, /* D E F */ + 0, UMODE_H, 0, /* G H I */ + 0, 0, 0, /* J K L */ + 0, UMODE_N, UMODE_O, /* M N O */ + 0, 0, UMODE_R, /* P Q R */ + UMODE_S, UMODE_T, 0, /* S T U */ + 0, 0, 0, /* V W X */ + 0, /* Y */ + 0, /* Z */ + 0, 0, 0, /* [ \ ] */ + 0, 0, 0, /* ^ _ ` */ + UMODE_a, 0, 0, /* a b c */ + 0, 0, 0, /* d e f */ + 0, UMODE_h, UMODE_i, /* g h i */ + 0, 0, 0, /* j k l */ + 0, 0, UMODE_o, /* m n o */ + UMODE_p, 0, UMODE_r, /* p q r */ + UMODE_s, 0, 0, /* s t u */ + UMODE_v, UMODE_w, 0, /* v w x */ + UMODE_y, /* y */ + UMODE_z, /* z */ + 0, 0, 0, /* { | } */ + 0, 0 /* ~ � */ }; char myCsmodes[128] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, 0, 0, - 0, - 0, 0, 0, 0, - 0, + 0, + 0, + 0, 0, 0, + 0, + 0, 0, 0, 0, + 0, - 'v', 0, 0, 'a', 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'v', 0, 0, 'a', 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; CMMode myCmmodes[128] = { - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, - {NULL}, - {add_ban, del_ban}, - {NULL}, - {NULL}, - {add_exception, del_exception}, - {NULL}, - {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, + {NULL}, + {add_ban, del_ban}, + {NULL}, + {NULL}, + {add_exception, del_exception}, + {NULL}, + {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} }; CBMode myCbmodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, - {CMODE_A, 0, NULL, NULL}, /* A */ - {CMODE_B, 0, NULL, NULL}, /* B */ - {CMODE_C, 0, NULL, NULL}, /* C */ - {0}, /* D */ - {0}, /* E */ - {0}, /* F */ - {0}, /* G */ - {0}, /* H */ - {0}, /* I */ - {0}, /* J */ - {CMODE_K, 0, NULL, NULL}, /* K */ - {0}, /* L */ - {0}, /* M */ - {CMODE_N, 0, NULL, NULL}, /* N */ - {CMODE_O, 0, NULL, NULL}, /* O */ - {0}, /* P */ - {0}, /* Q */ - {CMODE_R, 0, NULL, NULL}, /* R */ - {CMODE_S, 0, NULL, NULL}, /* S */ - {0}, /* T */ - {0}, /* U */ - {0}, /* V */ - {0}, /* W */ - {0}, /* X */ - {0}, /* Y */ - {0}, /* Z */ - {0}, {0}, {0}, {0}, {0}, {0}, - {0}, /* a */ - {0}, /* b */ - {CMODE_c, 0, NULL, NULL}, - {CMODE_d, 0, NULL, NULL}, - {0}, /* e */ - {CMODE_f, 0, set_flood, cs_set_flood}, - {0}, /* g */ - {0}, /* h */ - {CMODE_i, 0, NULL, NULL}, - {0}, /* j */ - {CMODE_k, 0, chan_set_key, cs_set_key}, - {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, - {CMODE_m, 0, NULL, NULL}, - {CMODE_n, 0, NULL, NULL}, - {0}, /* o */ - {CMODE_p, 0, NULL, NULL}, - {CMODE_q, 0, NULL, NULL}, - {CMODE_r, CBM_NO_MLOCK, NULL, NULL}, - {CMODE_s, 0, NULL, NULL}, - {CMODE_t, 0, NULL, NULL}, - {0}, - {0}, /* v */ - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {0}, /* z */ - {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, + {CMODE_A, 0, NULL, NULL}, /* A */ + {CMODE_B, 0, NULL, NULL}, /* B */ + {CMODE_C, 0, NULL, NULL}, /* C */ + {0}, /* D */ + {0}, /* E */ + {0}, /* F */ + {0}, /* G */ + {0}, /* H */ + {0}, /* I */ + {0}, /* J */ + {CMODE_K, 0, NULL, NULL}, /* K */ + {0}, /* L */ + {0}, /* M */ + {CMODE_N, 0, NULL, NULL}, /* N */ + {CMODE_O, 0, NULL, NULL}, /* O */ + {0}, /* P */ + {0}, /* Q */ + {CMODE_R, 0, NULL, NULL}, /* R */ + {CMODE_S, 0, NULL, NULL}, /* S */ + {0}, /* T */ + {0}, /* U */ + {0}, /* V */ + {0}, /* W */ + {0}, /* X */ + {0}, /* Y */ + {0}, /* Z */ + {0}, {0}, {0}, {0}, {0}, {0}, + {0}, /* a */ + {0}, /* b */ + {CMODE_c, 0, NULL, NULL}, + {CMODE_d, 0, NULL, NULL}, + {0}, /* e */ + {CMODE_f, 0, set_flood, cs_set_flood}, + {0}, /* g */ + {0}, /* h */ + {CMODE_i, 0, NULL, NULL}, + {0}, /* j */ + {CMODE_k, 0, chan_set_key, cs_set_key}, + {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, + {CMODE_m, 0, NULL, NULL}, + {CMODE_n, 0, NULL, NULL}, + {0}, /* o */ + {CMODE_p, 0, NULL, NULL}, + {CMODE_q, 0, NULL, NULL}, + {CMODE_r, CBM_NO_MLOCK, NULL, NULL}, + {CMODE_s, 0, NULL, NULL}, + {CMODE_t, 0, NULL, NULL}, + {0}, + {0}, /* v */ + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0} }; CBModeInfo myCbmodeinfos[] = { - {'c', CMODE_c, 0, NULL, NULL}, - {'d', CMODE_d, 0, NULL, NULL}, - {'f', CMODE_f, 0, get_flood, cs_get_flood}, - {'i', CMODE_i, 0, NULL, NULL}, - {'k', CMODE_k, 0, get_key, cs_get_key}, - {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, - {'m', CMODE_m, 0, NULL, NULL}, - {'n', CMODE_n, 0, NULL, NULL}, - {'p', CMODE_p, 0, NULL, NULL}, - {'q', CMODE_q, 0, NULL, NULL}, - {'r', CMODE_r, 0, NULL, NULL}, - {'s', CMODE_s, 0, NULL, NULL}, - {'t', CMODE_t, 0, NULL, NULL}, - {'A', CMODE_A, 0, NULL, NULL}, - {'B', CMODE_B, 0, NULL, NULL}, - {'C', CMODE_C, 0, NULL, NULL}, - {'K', CMODE_K, 0, NULL, NULL}, - {'N', CMODE_N, 0, NULL, NULL}, - {'O', CMODE_O, 0, NULL, NULL}, - {'R', CMODE_R, 0, NULL, NULL}, - {'S', CMODE_S, 0, NULL, NULL}, - {0} + {'c', CMODE_c, 0, NULL, NULL}, + {'d', CMODE_d, 0, NULL, NULL}, + {'f', CMODE_f, 0, get_flood, cs_get_flood}, + {'i', CMODE_i, 0, NULL, NULL}, + {'k', CMODE_k, 0, get_key, cs_get_key}, + {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, + {'m', CMODE_m, 0, NULL, NULL}, + {'n', CMODE_n, 0, NULL, NULL}, + {'p', CMODE_p, 0, NULL, NULL}, + {'q', CMODE_q, 0, NULL, NULL}, + {'r', CMODE_r, 0, NULL, NULL}, + {'s', CMODE_s, 0, NULL, NULL}, + {'t', CMODE_t, 0, NULL, NULL}, + {'A', CMODE_A, 0, NULL, NULL}, + {'B', CMODE_B, 0, NULL, NULL}, + {'C', CMODE_C, 0, NULL, NULL}, + {'K', CMODE_K, 0, NULL, NULL}, + {'N', CMODE_N, 0, NULL, NULL}, + {'O', CMODE_O, 0, NULL, NULL}, + {'R', CMODE_R, 0, NULL, NULL}, + {'S', CMODE_S, 0, NULL, NULL}, + {0} }; CUMode myCumodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, - - {0}, /* a */ - {0}, /* b */ - {0}, /* c */ - {0}, /* d */ - {0}, /* e */ - {0}, /* f */ - {0}, /* g */ - {0}, /* h */ - {0}, /* i */ - {0}, /* j */ - {0}, /* k */ - {0}, /* l */ - {0}, /* m */ - {0}, /* n */ - {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, - {0}, /* p */ - {0}, /* q */ - {0}, /* r */ - {0}, /* s */ - {0}, /* t */ - {0}, /* u */ - {CUS_VOICE, 0, NULL}, - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {0}, /* z */ - {0}, {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, + + {0}, /* a */ + {0}, /* b */ + {0}, /* c */ + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {0}, /* h */ + {0}, /* i */ + {0}, /* j */ + {0}, /* k */ + {0}, /* l */ + {0}, /* m */ + {0}, /* n */ + {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, + {0}, /* p */ + {0}, /* q */ + {0}, /* r */ + {0}, /* s */ + {0}, /* t */ + {0}, /* u */ + {CUS_VOICE, 0, NULL}, + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0}, {0} }; void ptlink_SendBotOp(const char *nick, const char *chan) { - anope_SendMode(s_ChanServ, chan, "%s %s %s", ircd->botchanumode, nick, - nick); + anope_SendMode(s_ChanServ, chan, "%s %s %s", ircd->botchanumode, nick, + nick); } /* @@ -403,8 +403,8 @@ void ptlink_SendBotOp(const char *nick, const char *chan) */ int anope_event_sjoin(const char *source, int ac, const char **av) { - do_sjoin(source, ac, av); - return MOD_CONT; + do_sjoin(source, ac, av); + return MOD_CONT; } /* @@ -420,55 +420,55 @@ int anope_event_sjoin(const char *source, int ac, const char **av) */ int anope_event_newmask(const char *source, int ac, const char **av) { - User *u; - const char *newhost = NULL, *newuser = NULL; - int tofree = 0; - - if (ac != 1) - return MOD_CONT; - u = finduser(source); - - if (!u) { - if (debug) { - alog("debug: NEWMASK for nonexistent user %s", av[0]); - } - return MOD_CONT; - } - - if ((u->mode & (UMODE_NM | UMODE_VH)) == (UMODE_NM | UMODE_VH)) { - /* This NEWMASK should be discarded because it's sent due to a +r by - * someone with a ptlink-masked host. PTlink has our correct host, so - * we can just ignore this :) Or we'll get ptlink's old host which is - * not what we want. -GD - */ - u->mode &= ~UMODE_NM; - if (debug) - alog("debug: Ignoring NEWMASK because it's send because of SVSMODE +r"); - return MOD_CONT; - } - - newuser = myStrGetOnlyToken(av[0], '@', 0); - if (newuser) { - newhost = myStrGetTokenRemainder(av[0], '@', 1); - tofree = 1; - u->SetIdent(newuser); - free((char *)newuser); - } else { - newhost = av[0]; - } - - if (newhost && *newhost == '@') - newhost++; - - u->mode |= UMODE_VH; - - if (newhost) - u->SetDisplayedHost(newhost); - - if (tofree) - free((char *)newhost); - - return MOD_CONT; + User *u; + const char *newhost = NULL, *newuser = NULL; + int tofree = 0; + + if (ac != 1) + return MOD_CONT; + u = finduser(source); + + if (!u) { + if (debug) { + alog("debug: NEWMASK for nonexistent user %s", av[0]); + } + return MOD_CONT; + } + + if ((u->mode & (UMODE_NM | UMODE_VH)) == (UMODE_NM | UMODE_VH)) { + /* This NEWMASK should be discarded because it's sent due to a +r by + * someone with a ptlink-masked host. PTlink has our correct host, so + * we can just ignore this :) Or we'll get ptlink's old host which is + * not what we want. -GD + */ + u->mode &= ~UMODE_NM; + if (debug) + alog("debug: Ignoring NEWMASK because it's send because of SVSMODE +r"); + return MOD_CONT; + } + + newuser = myStrGetOnlyToken(av[0], '@', 0); + if (newuser) { + newhost = myStrGetTokenRemainder(av[0], '@', 1); + tofree = 1; + u->SetIdent(newuser); + free((char *)newuser); + } else { + newhost = av[0]; + } + + if (newhost && *newhost == '@') + newhost++; + + u->mode |= UMODE_VH; + + if (newhost) + u->SetDisplayedHost(newhost); + + if (tofree) + free((char *)newhost); + + return MOD_CONT; } /* @@ -477,11 +477,11 @@ int anope_event_newmask(const char *source, int ac, const char **av) parv[1] = hopcount parv[2] = nick TS (nick introduction time) parv[3] = umodes - parv[4] = username - parv[5] = hostname - parv[6] = spoofed hostname - parv[7] = server - parv[8] = nick info + parv[4] = username + parv[5] = hostname + parv[6] = spoofed hostname + parv[7] = server + parv[8] = nick info */ /* Change NICK @@ -491,23 +491,23 @@ int anope_event_newmask(const char *source, int ac, const char **av) */ /* NICK xpto 2 561264 +rw irc num.myisp.pt mask.myisp.pt uc.ptlink.net :Just me - 0 1 2 3 4 5 6 7 8 + 0 1 2 3 4 5 6 7 8 */ int anope_event_nick(const char *source, int ac, const char **av) { - User *user; + User *user; - if (ac != 2) { - user = do_nick(source, av[0], av[4], av[5], av[7], av[8], - strtoul(av[2], NULL, 10), 0, 0, av[6], NULL); - if (user) - anope_ProcessUsermodes(user, 1, &av[3]); - } else { - do_nick(source, av[0], NULL, NULL, NULL, NULL, - strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); - } - return MOD_CONT; + if (ac != 2) { + user = do_nick(source, av[0], av[4], av[5], av[7], av[8], + strtoul(av[2], NULL, 10), 0, 0, av[6], NULL); + if (user) + anope_ProcessUsermodes(user, 1, &av[3]); + } else { + do_nick(source, av[0], NULL, NULL, NULL, NULL, + strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); + } + return MOD_CONT; } /* @@ -520,145 +520,145 @@ int anope_event_nick(const char *source, int ac, const char **av) */ int anope_event_server(const char *source, int ac, const char **av) { - if (!stricmp(av[1], "1")) { - uplink = sstrdup(av[0]); - } - do_server(source, av[0], av[1], av[3], NULL); - return MOD_CONT; + if (!stricmp(av[1], "1")) { + uplink = sstrdup(av[0]); + } + do_server(source, av[0], av[1], av[3], NULL); + return MOD_CONT; } int anope_event_436(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; + if (ac < 1) + return MOD_CONT; - m_nickcoll(av[0]); - return MOD_CONT; + m_nickcoll(av[0]); + return MOD_CONT; } void moduleAddIRCDMsgs(void) { - Message *m; - - updateProtectDetails("PROTECT", "PROTECTME", "protect", "deprotect", - "AUTOPROTECT", "+a", "-a"); - - m = createMessage("401", anope_event_null); - addCoreMessage(IRCD, m); - m = createMessage("402", anope_event_null); - addCoreMessage(IRCD, m); - m = createMessage("436", anope_event_436); - addCoreMessage(IRCD, m); - m = createMessage("461", anope_event_null); - addCoreMessage(IRCD, m); - m = createMessage("AWAY", anope_event_away); - addCoreMessage(IRCD, m); - m = createMessage("INVITE", anope_event_invite); - addCoreMessage(IRCD, m); - m = createMessage("JOIN", anope_event_join); - addCoreMessage(IRCD, m); - m = createMessage("KICK", anope_event_kick); - addCoreMessage(IRCD, m); - m = createMessage("KILL", anope_event_kill); - addCoreMessage(IRCD, m); - m = createMessage("MODE", anope_event_mode); - addCoreMessage(IRCD, m); - m = createMessage("MOTD", anope_event_motd); - addCoreMessage(IRCD, m); - m = createMessage("NICK", anope_event_nick); - addCoreMessage(IRCD, m); - m = createMessage("NOTICE", anope_event_notice); - addCoreMessage(IRCD, m); - m = createMessage("PART", anope_event_part); - addCoreMessage(IRCD, m); - m = createMessage("PASS", anope_event_pass); - addCoreMessage(IRCD, m); - m = createMessage("PING", anope_event_ping); - addCoreMessage(IRCD, m); - m = createMessage("PRIVMSG", anope_event_privmsg); - addCoreMessage(IRCD, m); - m = createMessage("QUIT", anope_event_quit); - addCoreMessage(IRCD, m); - m = createMessage("SERVER", anope_event_server); - addCoreMessage(IRCD, m); - m = createMessage("SQUIT", anope_event_squit); - addCoreMessage(IRCD, m); - m = createMessage("TOPIC", anope_event_topic); - addCoreMessage(IRCD, m); - m = createMessage("USER", anope_event_null); - addCoreMessage(IRCD, m); - m = createMessage("WALLOPS", anope_event_null); - addCoreMessage(IRCD, m); - m = createMessage("WHOIS", anope_event_whois); - addCoreMessage(IRCD, m); - m = createMessage("AKILL", anope_event_null); - addCoreMessage(IRCD, m); - m = createMessage("GLOBOPS", anope_event_null); - addCoreMessage(IRCD, m); - m = createMessage("GNOTICE", anope_event_null); - addCoreMessage(IRCD, m); - m = createMessage("GOPER", anope_event_null); - addCoreMessage(IRCD, m); - m = createMessage("RAKILL", anope_event_null); - addCoreMessage(IRCD, m); - m = createMessage("SILENCE", anope_event_null); - addCoreMessage(IRCD, m); - m = createMessage("SVSKILL", anope_event_null); - addCoreMessage(IRCD, m); - m = createMessage("SVSMODE", anope_event_null); - addCoreMessage(IRCD, m); - m = createMessage("SVSNICK", anope_event_null); - addCoreMessage(IRCD, m); - m = createMessage("SVSNOOP", anope_event_null); - addCoreMessage(IRCD, m); - m = createMessage("SQLINE", anope_event_null); - addCoreMessage(IRCD, m); - m = createMessage("UNSQLINE", anope_event_null); - addCoreMessage(IRCD, m); - m = createMessage("NEWMASK", anope_event_newmask); - addCoreMessage(IRCD, m); - m = createMessage("CAPAB", anope_event_capab); - addCoreMessage(IRCD, m); - m = createMessage("SVINFO", anope_event_svinfo); - addCoreMessage(IRCD, m); - m = createMessage("SVSINFO", anope_event_svsinfo); - addCoreMessage(IRCD, m); - m = createMessage("SJOIN", anope_event_sjoin); - addCoreMessage(IRCD, m); - m = createMessage("REHASH", anope_event_rehash); - addCoreMessage(IRCD, m); - m = createMessage("ADMIN", anope_event_admin); - addCoreMessage(IRCD, m); - m = createMessage("CREDITS", anope_event_credits); - addCoreMessage(IRCD, m); - m = createMessage("ERROR", anope_event_error); - addCoreMessage(IRCD, m); - m = createMessage("NJOIN", anope_event_sjoin); - addCoreMessage(IRCD, m); - m = createMessage("NNICK", anope_event_nick); - addCoreMessage(IRCD, m); - m = createMessage("ZLINE", anope_event_null); - addCoreMessage(IRCD, m); - m = createMessage("UNZLINE", anope_event_null); - addCoreMessage(IRCD, m); + Message *m; + + updateProtectDetails("PROTECT", "PROTECTME", "protect", "deprotect", + "AUTOPROTECT", "+a", "-a"); + + m = createMessage("401", anope_event_null); + addCoreMessage(IRCD, m); + m = createMessage("402", anope_event_null); + addCoreMessage(IRCD, m); + m = createMessage("436", anope_event_436); + addCoreMessage(IRCD, m); + m = createMessage("461", anope_event_null); + addCoreMessage(IRCD, m); + m = createMessage("AWAY", anope_event_away); + addCoreMessage(IRCD, m); + m = createMessage("INVITE", anope_event_invite); + addCoreMessage(IRCD, m); + m = createMessage("JOIN", anope_event_join); + addCoreMessage(IRCD, m); + m = createMessage("KICK", anope_event_kick); + addCoreMessage(IRCD, m); + m = createMessage("KILL", anope_event_kill); + addCoreMessage(IRCD, m); + m = createMessage("MODE", anope_event_mode); + addCoreMessage(IRCD, m); + m = createMessage("MOTD", anope_event_motd); + addCoreMessage(IRCD, m); + m = createMessage("NICK", anope_event_nick); + addCoreMessage(IRCD, m); + m = createMessage("NOTICE", anope_event_notice); + addCoreMessage(IRCD, m); + m = createMessage("PART", anope_event_part); + addCoreMessage(IRCD, m); + m = createMessage("PASS", anope_event_pass); + addCoreMessage(IRCD, m); + m = createMessage("PING", anope_event_ping); + addCoreMessage(IRCD, m); + m = createMessage("PRIVMSG", anope_event_privmsg); + addCoreMessage(IRCD, m); + m = createMessage("QUIT", anope_event_quit); + addCoreMessage(IRCD, m); + m = createMessage("SERVER", anope_event_server); + addCoreMessage(IRCD, m); + m = createMessage("SQUIT", anope_event_squit); + addCoreMessage(IRCD, m); + m = createMessage("TOPIC", anope_event_topic); + addCoreMessage(IRCD, m); + m = createMessage("USER", anope_event_null); + addCoreMessage(IRCD, m); + m = createMessage("WALLOPS", anope_event_null); + addCoreMessage(IRCD, m); + m = createMessage("WHOIS", anope_event_whois); + addCoreMessage(IRCD, m); + m = createMessage("AKILL", anope_event_null); + addCoreMessage(IRCD, m); + m = createMessage("GLOBOPS", anope_event_null); + addCoreMessage(IRCD, m); + m = createMessage("GNOTICE", anope_event_null); + addCoreMessage(IRCD, m); + m = createMessage("GOPER", anope_event_null); + addCoreMessage(IRCD, m); + m = createMessage("RAKILL", anope_event_null); + addCoreMessage(IRCD, m); + m = createMessage("SILENCE", anope_event_null); + addCoreMessage(IRCD, m); + m = createMessage("SVSKILL", anope_event_null); + addCoreMessage(IRCD, m); + m = createMessage("SVSMODE", anope_event_null); + addCoreMessage(IRCD, m); + m = createMessage("SVSNICK", anope_event_null); + addCoreMessage(IRCD, m); + m = createMessage("SVSNOOP", anope_event_null); + addCoreMessage(IRCD, m); + m = createMessage("SQLINE", anope_event_null); + addCoreMessage(IRCD, m); + m = createMessage("UNSQLINE", anope_event_null); + addCoreMessage(IRCD, m); + m = createMessage("NEWMASK", anope_event_newmask); + addCoreMessage(IRCD, m); + m = createMessage("CAPAB", anope_event_capab); + addCoreMessage(IRCD, m); + m = createMessage("SVINFO", anope_event_svinfo); + addCoreMessage(IRCD, m); + m = createMessage("SVSINFO", anope_event_svsinfo); + addCoreMessage(IRCD, m); + m = createMessage("SJOIN", anope_event_sjoin); + addCoreMessage(IRCD, m); + m = createMessage("REHASH", anope_event_rehash); + addCoreMessage(IRCD, m); + m = createMessage("ADMIN", anope_event_admin); + addCoreMessage(IRCD, m); + m = createMessage("CREDITS", anope_event_credits); + addCoreMessage(IRCD, m); + m = createMessage("ERROR", anope_event_error); + addCoreMessage(IRCD, m); + m = createMessage("NJOIN", anope_event_sjoin); + addCoreMessage(IRCD, m); + m = createMessage("NNICK", anope_event_nick); + addCoreMessage(IRCD, m); + m = createMessage("ZLINE", anope_event_null); + addCoreMessage(IRCD, m); + m = createMessage("UNZLINE", anope_event_null); + addCoreMessage(IRCD, m); } int anope_event_svsinfo(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_svinfo(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } /* Event: PROTOCTL */ int anope_event_capab(const char *source, int ac, const char **av) { - capab_parse(ac, av); - return MOD_CONT; + capab_parse(ac, av); + return MOD_CONT; } /* @@ -669,14 +669,14 @@ int anope_event_capab(const char *source, int ac, const char **av) */ void ptlink_SendSQLine(const char *mask, const char *reason) { - send_cmd(ServerName, "SQLINE %s :%s", mask, reason); + send_cmd(ServerName, "SQLINE %s :%s", mask, reason); } /* :%s SVSADMIN %s :%s parv[0] = sender (services client) parv[1] = target server - parv[2] = operation + parv[2] = operation operations: noopers - remove existing opers and disable o:lines */ @@ -703,13 +703,13 @@ void PTlinkProto::SendAkillDel(const char *user, const char *host) void anope_part(char *nick, char *chan) { - send_cmd(nick, "PART %s", chan); + send_cmd(nick, "PART %s", chan); } void anope_topic(char *whosets, char *chan, char *whosetit, char *topic, - time_t when) + time_t when) { - send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit, - (unsigned long int) when, topic); + send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit, + (unsigned long int) when, topic); } /* @@ -719,13 +719,13 @@ void anope_topic(char *whosets, char *chan, char *whosetit, char *topic, */ void ptlink_SendSQLineDel(const char *user) { - send_cmd(NULL, "UNSQLINE %s", user); + send_cmd(NULL, "UNSQLINE %s", user); } void ptlink_SendJoin(const char *user, const char *channel, time_t chantime) { - send_cmd(ServerName, "SJOIN %ld %s + :%s", (long int) chantime, - channel, user); + send_cmd(ServerName, "SJOIN %ld %s + :%s", (long int) chantime, + channel, user); } /* @@ -737,24 +737,24 @@ void ptlink_SendJoin(const char *user, const char *channel, time_t chantime) parv[4] = reason */ void ptlink_SendAkill(const char *user, const char *host, const char *who, time_t when, - time_t expires, const char *reason) + time_t expires, const char *reason) { - send_cmd(ServerName, "GLINE %s@%s %i %s :%s", user, host, 86400 * 2, - who, reason); + send_cmd(ServerName, "GLINE %s@%s %i %s :%s", user, host, 86400 * 2, + who, reason); } void ptlink_SendSVSKill(const char *source, const char *user, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - if (!source || !user) { - return; - } + if (!source || !user) { + return; + } - send_cmd(source, "KILL %s :%s", user, buf); + send_cmd(source, "KILL %s :%s", user, buf); } /* @@ -767,40 +767,40 @@ void ptlink_SendSVSKill(const char *source, const char *user, const char *buf) */ void ptlink_SendSVSMode(User * u, int ac, const char **av) { - send_cmd(ServerName, "SVSMODE %s %s%s%s", u->nick, av[0], - (ac == 2 ? " " : ""), (ac == 2 ? av[1] : "")); + send_cmd(ServerName, "SVSMODE %s %s%s%s", u->nick, av[0], + (ac == 2 ? " " : ""), (ac == 2 ? av[1] : "")); - /* If we set +r on someone +NRah (1 or more of those modes), PTlink will - * send us a NEWMASK with their ptlink-masked-host. If we want HostServ - * to work for them, we will need to send our NEWMASK after we receive - * theirs. Thus we make a hack and store in moduleData that we need to - * look out for that. - */ - if ((strchr(av[0], 'r') - && ((u->mode & UMODE_N) || (u->mode & UMODE_R) - || (u->mode & UMODE_a) || (u->mode & UMODE_h)))) - u->mode |= UMODE_NM; + /* If we set +r on someone +NRah (1 or more of those modes), PTlink will + * send us a NEWMASK with their ptlink-masked-host. If we want HostServ + * to work for them, we will need to send our NEWMASK after we receive + * theirs. Thus we make a hack and store in moduleData that we need to + * look out for that. + */ + if ((strchr(av[0], 'r') + && ((u->mode & UMODE_N) || (u->mode & UMODE_R) + || (u->mode & UMODE_a) || (u->mode & UMODE_h)))) + u->mode |= UMODE_NM; } int anope_event_error(const char *source, int ac, const char **av) { - if (ac >= 1) { - if (debug) { - alog("debug: %s", av[0]); - } - } - return MOD_CONT; + if (ac >= 1) { + if (debug) { + alog("debug: %s", av[0]); + } + } + return MOD_CONT; } void ptlink_SendSquit(const char *servname, const char *message) { - send_cmd(NULL, "SQUIT %s :%s", servname, message); + send_cmd(NULL, "SQUIT %s :%s", servname, message); } /* PONG */ void ptlink_SendPong(const char *servname, const char *who) { - send_cmd(servname, "PONG %s", who); + send_cmd(servname, "PONG %s", who); } /* @@ -815,11 +815,11 @@ void ptlink_SendPong(const char *servname, const char *who) void ptlink_cmd_svinfo() { #if defined(PTLINK_TS_CURRENT) && defined(PTLINK_TS_MIN) - send_cmd(NULL, "SVINFO %d %d %lu", PTLINK_TS_CURRENT, PTLINK_TS_MIN, - (unsigned long int) time(NULL)); + send_cmd(NULL, "SVINFO %d %d %lu", PTLINK_TS_CURRENT, PTLINK_TS_MIN, + (unsigned long int) time(NULL)); #else - /* hardwired if the defs some how go missing */ - send_cmd(NULL, "SVINFO 6 3 %lu", (unsigned long int) time(NULL)); + /* hardwired if the defs some how go missing */ + send_cmd(NULL, "SVINFO 6 3 %lu", (unsigned long int) time(NULL)); #endif } @@ -831,8 +831,8 @@ void ptlink_cmd_svinfo() */ void ptlink_cmd_svsinfo() { - send_cmd(NULL, "SVSINFO %lu %d", (unsigned long int) time(NULL), - maxusercnt); + send_cmd(NULL, "SVSINFO %lu %d", (unsigned long int) time(NULL), + maxusercnt); } /* @@ -843,7 +843,7 @@ void ptlink_cmd_svsinfo() */ void ptlink_cmd_pass(const char *pass) { - send_cmd(NULL, "PASS %s :TS", pass); + send_cmd(NULL, "PASS %s :TS", pass); } /* @@ -852,57 +852,57 @@ void ptlink_cmd_pass(const char *pass) */ void ptlink_cmd_capab() { - send_cmd(NULL, "CAPAB :QS PTS4"); + send_cmd(NULL, "CAPAB :QS PTS4"); } void ptlink_SendServer(const char *servname, int hop, const char *descript) { - send_cmd(NULL, "SERVER %s %d Anope.Services%s :%s", servname, hop, - version_number_dotted, descript); + send_cmd(NULL, "SERVER %s %d Anope.Services%s :%s", servname, hop, + version_number_dotted, descript); } void ptlink_SendConnect(int servernum) { - me_server = - new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); - if (servernum == 1) - ptlink_cmd_pass(RemotePassword); - else if (servernum == 2) - ptlink_cmd_pass(RemotePassword2); - else if (servernum == 3) - ptlink_cmd_pass(RemotePassword3); + if (servernum == 1) + ptlink_cmd_pass(RemotePassword); + else if (servernum == 2) + ptlink_cmd_pass(RemotePassword2); + else if (servernum == 3) + ptlink_cmd_pass(RemotePassword3); - ptlink_cmd_capab(); - ptlink_SendServer(ServerName, 1, ServerDesc); - ptlink_cmd_svinfo(); - ptlink_cmd_svsinfo(); + ptlink_cmd_capab(); + ptlink_SendServer(ServerName, 1, ServerDesc); + ptlink_cmd_svinfo(); + ptlink_cmd_svsinfo(); } int anope_event_privmsg(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; - m_privmsg(source, av[0], av[1]); - return MOD_CONT; + if (ac != 2) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; } int anope_event_part(const char *source, int ac, const char **av) { - if (ac < 1 || ac > 2) - return MOD_CONT; - do_part(source, ac, av); - return MOD_CONT; + if (ac < 1 || ac > 2) + return MOD_CONT; + do_part(source, ac, av); + return MOD_CONT; } int anope_event_whois(const char *source, int ac, const char **av) { - if (source && ac >= 1) { - m_whois(source, av[0]); - } - return MOD_CONT; + if (source && ac >= 1) { + m_whois(source, av[0]); + } + return MOD_CONT; } /* @@ -910,31 +910,31 @@ int anope_event_whois(const char *source, int ac, const char **av) parv[0] = sender prefix parv[1] = channel parv[2] = topic nick - parv[3] = topic time - parv[4] = topic text + parv[3] = topic time + parv[4] = topic text */ int anope_event_topic(const char *source, int ac, const char **av) { - if (ac != 4) - return MOD_CONT; - do_topic(source, ac, av); - return MOD_CONT; + if (ac != 4) + return MOD_CONT; + do_topic(source, ac, av); + return MOD_CONT; } int anope_event_squit(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; - do_squit(source, ac, av); - return MOD_CONT; + if (ac != 2) + return MOD_CONT; + do_squit(source, ac, av); + return MOD_CONT; } int anope_event_quit(const char *source, int ac, const char **av) { - if (ac != 1) - return MOD_CONT; - do_quit(source, ac, av); - return MOD_CONT; + if (ac != 1) + return MOD_CONT; + do_quit(source, ac, av); + return MOD_CONT; } /* @@ -945,246 +945,246 @@ int anope_event_quit(const char *source, int ac, const char **av) */ int anope_event_mode(const char *source, int ac, const char **av) { - if (ac < 2) - return MOD_CONT; + if (ac < 2) + return MOD_CONT; - if (*av[0] == '#' || *av[0] == '&') { - do_cmode(source, ac, av); - } else { - do_umode(source, ac, av); - } - return MOD_CONT; + if (*av[0] == '#' || *av[0] == '&') { + do_cmode(source, ac, av); + } else { + do_umode(source, ac, av); + } + return MOD_CONT; } int anope_event_kill(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - m_kill(av[0], av[1]); - return MOD_CONT; + m_kill(av[0], av[1]); + return MOD_CONT; } int anope_event_kick(const char *source, int ac, const char **av) { - if (ac != 3) - return MOD_CONT; - do_kick(source, ac, av); - return MOD_CONT; + if (ac != 3) + return MOD_CONT; + do_kick(source, ac, av); + return MOD_CONT; } int anope_event_join(const char *source, int ac, const char **av) { - if (ac != 1) - return MOD_CONT; - do_join(source, ac, av); - return MOD_CONT; + if (ac != 1) + return MOD_CONT; + do_join(source, ac, av); + return MOD_CONT; } int anope_event_motd(const char *source, int ac, const char **av) { - if (!source) { - return MOD_CONT; - } + if (!source) { + return MOD_CONT; + } - m_motd(source); - return MOD_CONT; + m_motd(source); + return MOD_CONT; } void ptlink_SendNoticeChanops(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "NOTICE @%s :%s", dest, buf); + send_cmd(NULL, "NOTICE @%s :%s", dest, buf); } void ptlink_cmd_notice(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - if (NSDefFlags & NI_MSG) { - ptlink_cmd_privmsg2(source, dest, buf); - } else { - send_cmd(source, "NOTICE %s :%s", dest, buf); - } + if (NSDefFlags & NI_MSG) { + ptlink_cmd_privmsg2(source, dest, buf); + } else { + send_cmd(source, "NOTICE %s :%s", dest, buf); + } } void ptlink_cmd_notice2(const char *source, const char *dest, const char *msg) { - send_cmd(source, "NOTICE %s :%s", dest, msg); + send_cmd(source, "NOTICE %s :%s", dest, msg); } void ptlink_cmd_privmsg(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(source, "PRIVMSG %s :%s", dest, buf); + send_cmd(source, "PRIVMSG %s :%s", dest, buf); } void ptlink_cmd_privmsg2(const char *source, const char *dest, const char *msg) { - send_cmd(source, "PRIVMSG %s :%s", dest, msg); + send_cmd(source, "PRIVMSG %s :%s", dest, msg); } void ptlink_SendGlobalNotice(const char *source, const char *dest, const char *msg) { - send_cmd(source, "NOTICE $%s :%s", dest, msg); + send_cmd(source, "NOTICE $%s :%s", dest, msg); } void ptlink_SendGlobalPrivmsg(const char *source, const char *dest, const char *msg) { - send_cmd(source, "PRIVMSG $%s :%s", dest, msg); + send_cmd(source, "PRIVMSG $%s :%s", dest, msg); } /* GLOBOPS */ void ptlink_SendGlobops(const char *source, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf); + send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf); } /* 391 */ void ptlink_cmd_391(const char *source, const char *timestr) { - if (!timestr) { - return; - } - send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr); + if (!timestr) { + return; + } + send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr); } /* 250 */ void ptlink_cmd_250(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "250 %s", buf); + send_cmd(NULL, "250 %s", buf); } /* 307 */ void ptlink_cmd_307(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "307 %s", buf); + send_cmd(ServerName, "307 %s", buf); } /* 311 */ void ptlink_cmd_311(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "311 %s", buf); + send_cmd(ServerName, "311 %s", buf); } /* 312 */ void ptlink_cmd_312(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "312 %s", buf); + send_cmd(ServerName, "312 %s", buf); } /* 317 */ void ptlink_cmd_317(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "317 %s", buf); + send_cmd(ServerName, "317 %s", buf); } /* 219 */ void ptlink_cmd_219(const char *source, const char *letter) { - if (!source) { - return; - } + if (!source) { + return; + } - if (letter) { - send_cmd(NULL, "219 %s %c :End of /STATS report.", source, - *letter); - } else { - send_cmd(NULL, "219 %s l :End of /STATS report.", source); - } + if (letter) { + send_cmd(NULL, "219 %s %c :End of /STATS report.", source, + *letter); + } else { + send_cmd(NULL, "219 %s l :End of /STATS report.", source); + } } /* 401 */ void ptlink_cmd_401(const char *source, const char *who) { - if (!source || !who) { - return; - } - send_cmd(ServerName, "401 %s %s :No such service.", source, who); + if (!source || !who) { + return; + } + send_cmd(ServerName, "401 %s %s :No such service.", source, who); } /* 318 */ void ptlink_cmd_318(const char *source, const char *who) { - if (!source || !who) { - return; - } + if (!source || !who) { + return; + } - send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who); + send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who); } /* 242 */ void ptlink_cmd_242(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "242 %s", buf); + send_cmd(NULL, "242 %s", buf); } /* 243 */ void ptlink_cmd_243(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "243 %s", buf); + send_cmd(NULL, "243 %s", buf); } /* 211 */ void ptlink_cmd_211(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "211 %s", buf); + send_cmd(NULL, "211 %s", buf); } void ptlink_SendMode(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(source, "MODE %s %s", dest, buf); + send_cmd(source, "MODE %s %s", dest, buf); } /* @@ -1193,51 +1193,51 @@ void ptlink_SendMode(const char *source, const char *dest, const char *buf) parv[2] = hopcount parv[3] = nick TS (nick introduction time) parv[4] = umodes - parv[5] = username - parv[6] = hostname - parv[7] = spoofed hostname - parv[8] = server - parv[9] = nick info + parv[5] = username + parv[6] = hostname + parv[7] = spoofed hostname + parv[8] = server + parv[9] = nick info */ void ptlink_cmd_nick(const char *nick, const char *name, const char *mode) { - EnforceQlinedNick(nick, NULL); - send_cmd(NULL, "NICK %s 1 %lu %s %s %s %s %s :%s", nick, - (unsigned long int) time(NULL), mode, ServiceUser, - ServiceHost, ServiceHost, ServerName, name); - ptlink_SendSQLine(nick, "Reserved for services"); + EnforceQlinedNick(nick, NULL); + send_cmd(NULL, "NICK %s 1 %lu %s %s %s %s %s :%s", nick, + (unsigned long int) time(NULL), mode, ServiceUser, + ServiceHost, ServiceHost, ServerName, name); + ptlink_SendSQLine(nick, "Reserved for services"); } void ptlink_SendKick(const char *source, const char *chan, const char *user, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - if (buf) { - send_cmd(source, "KICK %s %s :%s", chan, user, buf); - } else { - send_cmd(source, "KICK %s %s", chan, user); - } + if (buf) { + send_cmd(source, "KICK %s %s :%s", chan, user, buf); + } else { + send_cmd(source, "KICK %s %s", chan, user); + } } /* QUIT */ void ptlink_SendQuit(const char *source, const char *buf) { - if (buf) { - send_cmd(source, "QUIT :%s", buf); - } else { - send_cmd(source, "QUIT"); - } + if (buf) { + send_cmd(source, "QUIT :%s", buf); + } else { + send_cmd(source, "QUIT"); + } } void ptlink_SendPart(const char *nick, const char *chan, const char *buf) { - if (buf) { - send_cmd(nick, "PART %s :%s", chan, buf); - } else { - send_cmd(nick, "PART %s", chan); - } + if (buf) { + send_cmd(nick, "PART %s :%s", chan, buf); + } else { + send_cmd(nick, "PART %s", chan); + } } /* @@ -1245,156 +1245,156 @@ void ptlink_SendPart(const char *nick, const char *chan, const char *buf) parv[0] = sender prefix parv[1] = channel parv[2] = topic nick - parv[3] = topic time - parv[4] = topic text + parv[3] = topic time + parv[4] = topic text */ void ptlink_cmd_topic(const char *whosets, const char *chan, const char *whosetit, - const char *topic, time_t when) + const char *topic, time_t when) { - send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit, - (long int) time(NULL), topic); + send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit, + (long int) time(NULL), topic); } void ptlink_SendVhostDel(User * u) { - /* does not support vhosting */ + /* does not support vhosting */ } void ptlink_SendVhost(const char *nick, const char *vIdent, const char *vhost) { - User *u; + User *u; - if (vIdent) { - send_cmd(s_HostServ, "NEWMASK %s@%s %s", vIdent, vhost, nick); - } else { - send_cmd(s_HostServ, "NEWMASK %s %s", vhost, nick); - } + if (vIdent) { + send_cmd(s_HostServ, "NEWMASK %s@%s %s", vIdent, vhost, nick); + } else { + send_cmd(s_HostServ, "NEWMASK %s %s", vhost, nick); + } - if ((u = finduser(nick))) - u->mode |= UMODE_VH; + if ((u = finduser(nick))) + u->mode |= UMODE_VH; } /* INVITE */ void ptlink_SendInvite(const char *source, const char *chan, const char *nick) { - if (!source || !chan || !nick) { - return; - } + if (!source || !chan || !nick) { + return; + } - send_cmd(source, "INVITE %s %s", nick, chan); + send_cmd(source, "INVITE %s %s", nick, chan); } void ptlink_cmd_372(const char *source, const char *msg) { - send_cmd(ServerName, "372 %s :- %s", source, msg); + send_cmd(ServerName, "372 %s :- %s", source, msg); } void ptlink_cmd_372_error(const char *source) { - send_cmd(ServerName, "422 %s :- MOTD file not found! Please " - "contact your IRC administrator.", source); + send_cmd(ServerName, "422 %s :- MOTD file not found! Please " + "contact your IRC administrator.", source); } void ptlink_cmd_375(const char *source) { - send_cmd(ServerName, "375 %s :- %s Message of the Day", - source, ServerName); + send_cmd(ServerName, "375 %s :- %s Message of the Day", + source, ServerName); } void ptlink_cmd_376(const char *source) { - send_cmd(ServerName, "376 %s :End of /MOTD command.", source); + send_cmd(ServerName, "376 %s :End of /MOTD command.", source); } void ptlink_ProcessUsermodes(User * user, int ac, const char **av) { - int add = 1; /* 1 if adding modes, 0 if deleting */ - const char *modes = av[0]; - - ac--; - - if (debug) - alog("debug: Changing mode for %s to %s", user->nick, modes); - - while (*modes) { - - /* This looks better, much better than "add ? (do_add) : (do_remove)". - * At least this is readable without paying much attention :) -GD - */ - if (add) - user->mode |= umodes[(int) *modes]; - else - user->mode &= ~umodes[(int) *modes]; - - switch (*modes++) { - case '+': - add = 1; - break; - case '-': - add = 0; - break; - case 'o': - if (add) { - opcnt++; - - if (WallOper) - anope_SendGlobops(s_OperServ, - "\2%s\2 is now an IRC operator.", - user->nick); - display_news(user, NEWS_OPER); - if (is_services_admin(user)) { - common_svsmode(user, "+a", NULL); - user->mode |= UMODE_a; - } - - } else { - opcnt--; - } - break; - case 'r': - if (add && !nick_identified(user)) { - common_svsmode(user, "-r", NULL); - user->mode &= ~UMODE_r; - } - break; - } - } + int add = 1; /* 1 if adding modes, 0 if deleting */ + const char *modes = av[0]; + + ac--; + + if (debug) + alog("debug: Changing mode for %s to %s", user->nick, modes); + + while (*modes) { + + /* This looks better, much better than "add ? (do_add) : (do_remove)". + * At least this is readable without paying much attention :) -GD + */ + if (add) + user->mode |= umodes[(int) *modes]; + else + user->mode &= ~umodes[(int) *modes]; + + switch (*modes++) { + case '+': + add = 1; + break; + case '-': + add = 0; + break; + case 'o': + if (add) { + opcnt++; + + if (WallOper) + anope_SendGlobops(s_OperServ, + "\2%s\2 is now an IRC operator.", + user->nick); + display_news(user, NEWS_OPER); + if (is_services_admin(user)) { + common_svsmode(user, "+a", NULL); + user->mode |= UMODE_a; + } + + } else { + opcnt--; + } + break; + case 'r': + if (add && !nick_identified(user)) { + common_svsmode(user, "-r", NULL); + user->mode &= ~UMODE_r; + } + break; + } + } } int anope_event_ping(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - ptlink_SendPong(ac > 1 ? av[1] : ServerName, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + ptlink_SendPong(ac > 1 ? av[1] : ServerName, av[0]); + return MOD_CONT; } int anope_event_away(const char *source, int ac, const char **av) { - if (!source) { - return MOD_CONT; - } - m_away(source, (ac ? av[0] : NULL)); - return MOD_CONT; + if (!source) { + return MOD_CONT; + } + m_away(source, (ac ? av[0] : NULL)); + return MOD_CONT; } void ptlink_SendClientIntroduction(const char *nick, const char *user, const char *host, const char *real, - char *modes) + char *modes) { - EnforceQlinedNick(nick, s_BotServ); - send_cmd(NULL, "NICK %s 1 %lu %s %s %s %s %s :%s", nick, - (unsigned long int) time(NULL), modes, user, host, host, - ServerName, real); - ptlink_SendSQLine(nick, "Reserved for services"); + EnforceQlinedNick(nick, s_BotServ); + send_cmd(NULL, "NICK %s 1 %lu %s %s %s %s %s :%s", nick, + (unsigned long int) time(NULL), modes, user, host, host, + ServerName, real); + ptlink_SendSQLine(nick, "Reserved for services"); } void ptlink_cmd_351(const char *source) { - send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s (%s) -- %s", - source, version_number, ServerName, ircd->name, version_flags, - EncModule, version_build); + send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s (%s) -- %s", + source, version_number, ServerName, ircd->name, version_flags, + EncModule, version_build); } @@ -1402,13 +1402,13 @@ void ptlink_cmd_351(const char *source) /* SVSHOLD - set */ void ptlink_SendSVSHOLD(const char *nick) { - /* Not supported by this IRCD */ + /* Not supported by this IRCD */ } /* SVSHOLD - release */ void ptlink_SendSVSHOLDDel(const char *nick) { - /* Not Supported by this IRCD */ + /* Not Supported by this IRCD */ } /* @@ -1418,7 +1418,7 @@ void ptlink_SendSVSHOLDDel(const char *nick) */ void ptlink_SendSZLineDel(const char *mask) { - send_cmd(s_OperServ, "UNZLINE %s", mask); + send_cmd(s_OperServ, "UNZLINE %s", mask); } /* @@ -1430,8 +1430,8 @@ void ptlink_SendSZLineDel(const char *mask) */ void ptlink_SendSZLine(const char *mask, const char *reason, const char *whom) { - send_cmd(s_OperServ, "ZLINE %s %ld :%s", mask, - (long int) time(NULL) + 86400 * 2, reason); + send_cmd(s_OperServ, "ZLINE %s %ld :%s", mask, + (long int) time(NULL) + 86400 * 2, reason); } /* @@ -1441,7 +1441,7 @@ void ptlink_SendSZLine(const char *mask, const char *reason, const char *whom) */ void ptlink_SendSGLineDel(const char *mask) { - send_cmd(ServerName, "UNSXLINE :%s", mask); + send_cmd(ServerName, "UNSXLINE :%s", mask); } @@ -1454,8 +1454,8 @@ void ptlink_SendSGLineDel(const char *mask) */ void ptlink_SendSGLine(const char *mask, const char *reason) { - send_cmd(ServerName, "SXLINE %d :%s:%s", (int) strlen(mask), mask, - reason); + send_cmd(ServerName, "SXLINE %d :%s:%s", (int) strlen(mask), mask, + reason); } /* SVSNICK */ @@ -1468,36 +1468,36 @@ void ptlink_SendSGLine(const char *mask, const char *reason) */ void ptlink_SendForceNickChange(const char *source, const char *guest, time_t when) { - if (!source || !guest) { - return; - } - send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, (long int) when); + if (!source || !guest) { + return; + } + send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, (long int) when); } void ptlink_SendGuestNick(const char *nick, const char *user, const char *host, const char *real, - const char *modes) + const char *modes) { - send_cmd(NULL, "NICK %s 1 %lu %s %s %s %s %s :%s", nick, - (unsigned long int) time(NULL), modes, user, host, host, - ServerName, real); + send_cmd(NULL, "NICK %s 1 %lu %s %s %s %s %s :%s", nick, + (unsigned long int) time(NULL), modes, user, host, host, + ServerName, real); } void ptlink_SendBanDel(const char *name, const char *nick) { - /* Not Supported by this IRCD */ + /* Not Supported by this IRCD */ } /* SVSMODE channel modes */ void ptlink_SendSVSMode_chan(const char *name, const char *mode, const char *nick) { - /* Not Supported by this IRCD */ + /* Not Supported by this IRCD */ } void ptlink_SendSVSO(const char *source, const char *nick, const char *flag) { - /* Not Supported by this IRCD */ + /* Not Supported by this IRCD */ } @@ -1505,26 +1505,26 @@ void ptlink_SendSVSO(const char *source, const char *nick, const char *flag) /* sent if svid is something weird */ void ptlink_SendSVID(const char *nick, time_t ts) { - /* Not Supported by this ircd */ + /* Not Supported by this ircd */ } /* SVSMODE +d */ /* nc_change was = 1, and there is no na->status */ void ptlink_SendUnregisteredNick(User * u) { - /* Not Supported by this ircd */ + /* Not Supported by this ircd */ } /* SVSMODE +d */ /* sent if svid is something weird */ void ptlink_SendSVID2(User * u, const char *ts) { - common_svsmode(u, "+r", NULL); + common_svsmode(u, "+r", NULL); } void ptlink_SendSVID3(User * u, const char *ts) { - /* Bahamuts have this extra one, since they can check on even nick changes */ + /* Bahamuts have this extra one, since they can check on even nick changes */ } /* NICK <newnick> */ @@ -1536,11 +1536,11 @@ void ptlink_SendSVID3(User * u, const char *ts) */ void ptlink_SendChangeBotNick(const char *oldnick, const char *newnick) { - if (!oldnick || !newnick) { - return; - } + if (!oldnick || !newnick) { + return; + } - send_cmd(oldnick, "NICK %s %ld", newnick, (long int) time(NULL)); + send_cmd(oldnick, "NICK %s %ld", newnick, (long int) time(NULL)); } /* @@ -1552,7 +1552,7 @@ void ptlink_SendChangeBotNick(const char *oldnick, const char *newnick) */ void ptlink_SendSVSJoin(const char *source, const char *nick, const char *chan, const char *param) { - send_cmd(source, "SVSJOIN %s %s", nick, chan); + send_cmd(source, "SVSJOIN %s %s", nick, chan); } /* @@ -1564,80 +1564,80 @@ void ptlink_SendSVSJoin(const char *source, const char *nick, const char *chan, */ void ptlink_SendSVSPart(const char *source, const char *nick, const char *chan) { - send_cmd(source, "SVSPART %s :%s", nick, chan); + send_cmd(source, "SVSPART %s :%s", nick, chan); } void ptlink_SendSWhois(const char *source, const char *who, const char *mask) { - /* not supported */ + /* not supported */ } int anope_event_notice(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_pass(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_rehash(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_credits(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_admin(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_invite(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int ptlink_IsFloodModeParamValid(const char *value) { - char *dp, *end; + char *dp, *end; - if (value && *value != ':' - && (strtoul((*value == '*' ? value + 1 : value), &dp, 10) > 0) - && (*dp == ':') && (*(++dp) != 0) && (strtoul(dp, &end, 10) > 0) - && (*end == 0)) { - return 1; - } else { - return 0; - } + if (value && *value != ':' + && (strtoul((*value == '*' ? value + 1 : value), &dp, 10) > 0) + && (*dp == ':') && (*(++dp) != 0) && (strtoul(dp, &end, 10) > 0) + && (*end == 0)) { + return 1; + } else { + return 0; + } } void ptlink_SendEOB() { - /* not supported */ + /* not supported */ } void ptlink_SendJupe(const char *jserver, const char *who, const char *reason) { - char rbuf[256]; + char rbuf[256]; - snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who, - reason ? ": " : "", reason ? reason : ""); + snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who, + reason ? ": " : "", reason ? reason : ""); - if (findserver(servlist, jserver)) - ptlink_SendSquit(jserver, rbuf); - ptlink_SendServer(jserver, 1, rbuf); - new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL); + if (findserver(servlist, jserver)) + ptlink_SendSquit(jserver, rbuf); + ptlink_SendServer(jserver, 1, rbuf); + new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL); } /* GLOBOPS - to handle old WALLOPS */ void ptlink_SendGlobops_legacy(const char *source, const char *fmt) { - send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt); + send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt); } /* @@ -1646,8 +1646,8 @@ void ptlink_SendGlobops_legacy(const char *source, const char *fmt) */ int ptlink_IsNickValid(const char *nick) { - /* no hard coded invalid nicks */ - return 1; + /* no hard coded invalid nicks */ + return 1; } /* @@ -1656,23 +1656,23 @@ int ptlink_IsNickValid(const char *nick) */ int ptlink_IsChannelValid(const char *cahn) { - /* no hard coded invalid chan */ - return 1; + /* no hard coded invalid chan */ + return 1; } void ptlink_SendCTCP(const char *source, const char *dest, const char *buf) { - char *s; + char *s; - if (!buf) { - return; - } else { - s = normalizeBuffer(buf); - } + if (!buf) { + return; + } else { + s = normalizeBuffer(buf); + } - send_cmd(source, "NOTICE %s :\1%s \1", dest, s); - free(s); + send_cmd(source, "NOTICE %s :\1%s \1", dest, s); + free(s); } @@ -1682,78 +1682,78 @@ void ptlink_SendCTCP(const char *source, const char *dest, const char *buf) **/ void moduleAddAnopeCmds() { - pmodule_cmd_topic(ptlink_cmd_topic); - pmodule_SendVhostDel(ptlink_cmd_vhost_off); - pmodule_SendAkill(ptlink_cmd_akill); - pmodule_SendSVSKill(ptlink_SendSVSKill); - pmodule_SendSVSMode(ptlink_cmd_svsmode); - pmodule_cmd_372(ptlink_cmd_372); - pmodule_cmd_372_error(ptlink_cmd_372_error); - pmodule_cmd_375(ptlink_cmd_375); - pmodule_cmd_376(ptlink_cmd_376); - pmodule_cmd_nick(ptlink_cmd_nick); - pmodule_SendGuestNick(ptlink_cmd_guest_nick); - pmodule_SendMode(ptlink_cmd_mode); - pmodule_SendClientIntroduction(ptlink_cmd_bot_nick); - pmodule_SendKick(ptlink_cmd_kick); - pmodule_SendNoticeChanops(ptlink_cmd_notice_ops); - pmodule_cmd_notice(ptlink_cmd_notice); - pmodule_cmd_notice2(ptlink_cmd_notice2); - pmodule_cmd_privmsg(ptlink_cmd_privmsg); - pmodule_cmd_privmsg2(ptlink_cmd_privmsg2); - pmodule_SendGlobalNotice(ptlink_cmd_serv_notice); - pmodule_SendGlobalPrivmsg(ptlink_cmd_serv_privmsg); - pmodule_SendBotOp(ptlink_cmd_bot_chan_mode); - pmodule_cmd_351(ptlink_cmd_351); - pmodule_SendQuit(ptlink_cmd_quit); - pmodule_SendPong(ptlink_cmd_pong); - pmodule_SendJoin(ptlink_cmd_join); - pmodule_SendSQLineDel(ptlink_cmd_unsqline); - pmodule_SendInvite(ptlink_cmd_invite); - pmodule_SendPart(ptlink_cmd_part); - pmodule_cmd_391(ptlink_cmd_391); - pmodule_cmd_250(ptlink_cmd_250); - pmodule_cmd_307(ptlink_cmd_307); - pmodule_cmd_311(ptlink_cmd_311); - pmodule_cmd_312(ptlink_cmd_312); - pmodule_cmd_317(ptlink_cmd_317); - pmodule_cmd_219(ptlink_cmd_219); - pmodule_cmd_401(ptlink_cmd_401); - pmodule_cmd_318(ptlink_cmd_318); - pmodule_cmd_242(ptlink_cmd_242); - pmodule_cmd_243(ptlink_cmd_243); - pmodule_cmd_211(ptlink_cmd_211); - pmodule_SendGlobops(ptlink_cmd_global); - pmodule_SendGlobops_legacy(ptlink_cmd_global_legacy); - pmodule_SendSQLine(ptlink_cmd_sqline); - pmodule_SendSquit(ptlink_cmd_squit); - pmodule_SendSVSO(ptlink_cmd_svso); - pmodule_SendChangeBotNick(ptlink_cmd_chg_nick); - pmodule_SendForceNickChange(ptlink_cmd_svsnick); - pmodule_SendVhost(ptlink_cmd_vhost_on); - pmodule_SendConnect(ptlink_cmd_connect); - pmodule_SendSVSHOLD(ptlink_cmd_svshold); - pmodule_SendSVSHOLDDel(ptlink_cmd_release_svshold); - pmodule_SendSGLineDel(ptlink_cmd_unsgline); - pmodule_SendSZLineDel(ptlink_cmd_unszline); - pmodule_SendSZLine(ptlink_cmd_szline); - pmodule_SendSGLine(ptlink_cmd_sgline); - pmodule_SendBanDel(ptlink_cmd_unban); - pmodule_SendSVSMode_chan(ptlink_cmd_svsmode_chan); - pmodule_SendSVID(ptlink_cmd_svid_umode); - pmodule_SendUnregisteredNick(ptlink_cmd_nc_change); - pmodule_SendSVID2(ptlink_cmd_svid_umode2); - pmodule_SendSVID3(ptlink_cmd_svid_umode3); - pmodule_SendSVSJoin(ptlink_cmd_svsjoin); - pmodule_SendSVSPart(ptlink_cmd_svspart); - pmodule_SendSWhois(ptlink_cmd_swhois); - pmodule_SendEOB(ptlink_cmd_eob); - pmodule_IsFloodModeParamValid(ptlink_flood_mode_check); - pmodule_SendJupe(ptlink_cmd_jupe); - pmodule_IsNickValid(ptlink_valid_nick); - pmodule_IsChannelValid(ptlink_valid_chan); - pmodule_SendCTCP(ptlink_cmd_ctcp); - pmodule_ProcessUsermodes(ptlink_set_umode); + pmodule_cmd_topic(ptlink_cmd_topic); + pmodule_SendVhostDel(ptlink_cmd_vhost_off); + pmodule_SendAkill(ptlink_cmd_akill); + pmodule_SendSVSKill(ptlink_SendSVSKill); + pmodule_SendSVSMode(ptlink_cmd_svsmode); + pmodule_cmd_372(ptlink_cmd_372); + pmodule_cmd_372_error(ptlink_cmd_372_error); + pmodule_cmd_375(ptlink_cmd_375); + pmodule_cmd_376(ptlink_cmd_376); + pmodule_cmd_nick(ptlink_cmd_nick); + pmodule_SendGuestNick(ptlink_cmd_guest_nick); + pmodule_SendMode(ptlink_cmd_mode); + pmodule_SendClientIntroduction(ptlink_cmd_bot_nick); + pmodule_SendKick(ptlink_cmd_kick); + pmodule_SendNoticeChanops(ptlink_cmd_notice_ops); + pmodule_cmd_notice(ptlink_cmd_notice); + pmodule_cmd_notice2(ptlink_cmd_notice2); + pmodule_cmd_privmsg(ptlink_cmd_privmsg); + pmodule_cmd_privmsg2(ptlink_cmd_privmsg2); + pmodule_SendGlobalNotice(ptlink_cmd_serv_notice); + pmodule_SendGlobalPrivmsg(ptlink_cmd_serv_privmsg); + pmodule_SendBotOp(ptlink_cmd_bot_chan_mode); + pmodule_cmd_351(ptlink_cmd_351); + pmodule_SendQuit(ptlink_cmd_quit); + pmodule_SendPong(ptlink_cmd_pong); + pmodule_SendJoin(ptlink_cmd_join); + pmodule_SendSQLineDel(ptlink_cmd_unsqline); + pmodule_SendInvite(ptlink_cmd_invite); + pmodule_SendPart(ptlink_cmd_part); + pmodule_cmd_391(ptlink_cmd_391); + pmodule_cmd_250(ptlink_cmd_250); + pmodule_cmd_307(ptlink_cmd_307); + pmodule_cmd_311(ptlink_cmd_311); + pmodule_cmd_312(ptlink_cmd_312); + pmodule_cmd_317(ptlink_cmd_317); + pmodule_cmd_219(ptlink_cmd_219); + pmodule_cmd_401(ptlink_cmd_401); + pmodule_cmd_318(ptlink_cmd_318); + pmodule_cmd_242(ptlink_cmd_242); + pmodule_cmd_243(ptlink_cmd_243); + pmodule_cmd_211(ptlink_cmd_211); + pmodule_SendGlobops(ptlink_cmd_global); + pmodule_SendGlobops_legacy(ptlink_cmd_global_legacy); + pmodule_SendSQLine(ptlink_cmd_sqline); + pmodule_SendSquit(ptlink_cmd_squit); + pmodule_SendSVSO(ptlink_cmd_svso); + pmodule_SendChangeBotNick(ptlink_cmd_chg_nick); + pmodule_SendForceNickChange(ptlink_cmd_svsnick); + pmodule_SendVhost(ptlink_cmd_vhost_on); + pmodule_SendConnect(ptlink_cmd_connect); + pmodule_SendSVSHOLD(ptlink_cmd_svshold); + pmodule_SendSVSHOLDDel(ptlink_cmd_release_svshold); + pmodule_SendSGLineDel(ptlink_cmd_unsgline); + pmodule_SendSZLineDel(ptlink_cmd_unszline); + pmodule_SendSZLine(ptlink_cmd_szline); + pmodule_SendSGLine(ptlink_cmd_sgline); + pmodule_SendBanDel(ptlink_cmd_unban); + pmodule_SendSVSMode_chan(ptlink_cmd_svsmode_chan); + pmodule_SendSVID(ptlink_cmd_svid_umode); + pmodule_SendUnregisteredNick(ptlink_cmd_nc_change); + pmodule_SendSVID2(ptlink_cmd_svid_umode2); + pmodule_SendSVID3(ptlink_cmd_svid_umode3); + pmodule_SendSVSJoin(ptlink_cmd_svsjoin); + pmodule_SendSVSPart(ptlink_cmd_svspart); + pmodule_SendSWhois(ptlink_cmd_swhois); + pmodule_SendEOB(ptlink_cmd_eob); + pmodule_IsFloodModeParamValid(ptlink_flood_mode_check); + pmodule_SendJupe(ptlink_cmd_jupe); + pmodule_IsNickValid(ptlink_valid_nick); + pmodule_IsChannelValid(ptlink_valid_chan); + pmodule_SendCTCP(ptlink_cmd_ctcp); + pmodule_ProcessUsermodes(ptlink_set_umode); } /** @@ -1762,38 +1762,38 @@ void moduleAddAnopeCmds() int AnopeInit(int argc, char **argv) { - this->SetAuthor("Anope"); - this->SetVersion - ("$Id$"); - this->SetType(PROTOCOL); - - - pmodule_ircd_version("PTlink 6.15.*+"); - pmodule_ircd_cap(myIrcdcap); - pmodule_ircd_var(myIrcd); - pmodule_ircd_cbmodeinfos(myCbmodeinfos); - pmodule_ircd_cumodes(myCumodes); - pmodule_ircd_flood_mode_char_set("+f"); - pmodule_ircd_flood_mode_char_remove("-f"); - pmodule_ircd_cbmodes(myCbmodes); - pmodule_ircd_cmmodes(myCmmodes); - pmodule_ircd_csmodes(myCsmodes); - pmodule_ircd_useTSMode(0); - - /** Deal with modes anope _needs_ to know **/ - pmodule_invis_umode(UMODE_i); - pmodule_oper_umode(UMODE_o); - pmodule_invite_cmode(CMODE_i); - pmodule_secret_cmode(CMODE_s); - pmodule_private_cmode(CMODE_p); - pmodule_key_mode(CMODE_k); - pmodule_limit_mode(CMODE_l); - - moduleAddAnopeCmds(); + this->SetAuthor("Anope"); + this->SetVersion + ("$Id$"); + this->SetType(PROTOCOL); + + + pmodule_ircd_version("PTlink 6.15.*+"); + pmodule_ircd_cap(myIrcdcap); + pmodule_ircd_var(myIrcd); + pmodule_ircd_cbmodeinfos(myCbmodeinfos); + pmodule_ircd_cumodes(myCumodes); + pmodule_ircd_flood_mode_char_set("+f"); + pmodule_ircd_flood_mode_char_remove("-f"); + pmodule_ircd_cbmodes(myCbmodes); + pmodule_ircd_cmmodes(myCmmodes); + pmodule_ircd_csmodes(myCsmodes); + pmodule_ircd_useTSMode(0); + + /** Deal with modes anope _needs_ to know **/ + pmodule_invis_umode(UMODE_i); + pmodule_oper_umode(UMODE_o); + pmodule_invite_cmode(CMODE_i); + pmodule_secret_cmode(CMODE_s); + pmodule_private_cmode(CMODE_p); + pmodule_key_mode(CMODE_k); + pmodule_limit_mode(CMODE_l); + + moduleAddAnopeCmds(); pmodule_ircd_proto(&ircd_proto); - moduleAddIRCDMsgs(); + moduleAddIRCDMsgs(); - return MOD_CONT; + return MOD_CONT; } /* EOF */ diff --git a/src/protocol/obsolete/ptlink.h b/src/protocol/obsolete/ptlink.h index 8e7b893cf..83ac5ca34 100644 --- a/src/protocol/obsolete/ptlink.h +++ b/src/protocol/obsolete/ptlink.h @@ -65,7 +65,7 @@ that we support. PTLink 6.14 to 6.17 TS CURRENT is 6 and MIN is 3 - PTlink 6.18 TS CURRENT is 9 and MIN is 3 + PTlink 6.18 TS CURRENT is 9 and MIN is 3 PTLink 6.19 TS CURRENT is 10 and MIN is 9 If you are running 6.18 or 6.19 do not touch these values as they will diff --git a/src/protocol/obsolete/rageircd.c b/src/protocol/obsolete/rageircd.c index 1dd12910b..4e83bf03f 100644 --- a/src/protocol/obsolete/rageircd.c +++ b/src/protocol/obsolete/rageircd.c @@ -16,581 +16,581 @@ #include "rageircd.h" IRCDVar myIrcd[] = { - {"RageIRCd 2.0.*", /* ircd name */ - "+d", /* nickserv mode */ - "+d", /* chanserv mode */ - "+d", /* memoserv mode */ - "+d", /* hostserv mode */ - "+di", /* operserv mode */ - "+d", /* botserv mode */ - "+dh", /* helpserv mode */ - "+di", /* Dev/Null mode */ - "+di", /* Global mode */ - "+o", /* nickserv alias mode */ - "+o", /* chanserv alias mode */ - "+o", /* memoserv alias mode */ - "+io", /* hostserv alias mode */ - "+io", /* operserv alias mode */ - "+o", /* botserv alias mode */ - "+o", /* helpserv alias mode */ - "+i", /* Dev/Null alias mode */ - "+io", /* Global alias mode */ - "+", /* Used by BotServ Bots */ - 3, /* Chan Max Symbols */ - "-ilmnpRstcOACNM", /* Modes to Remove */ - "+o", /* Channel Umode used by Botserv bots */ - 1, /* SVSNICK */ - 1, /* Vhost */ - 0, /* Has Owner */ - NULL, /* Mode to set for an owner */ - NULL, /* Mode to unset for an owner */ - "+a", /* Mode to set for channel admin */ - "-a", /* Mode to unset for channel admin */ - "+rd", /* Mode On Reg */ - NULL, /* Mode on ID for Roots */ - NULL, /* Mode on ID for Admins */ - NULL, /* Mode on ID for Opers */ - "-rd", /* Mode on UnReg */ - "-r+d", /* Mode on Nick Change */ - 1, /* Supports SGlines */ - 1, /* Supports SQlines */ - 0, /* Supports SZlines */ - 1, /* Supports Halfop +h */ - 3, /* Number of server args */ - 0, /* Join 2 Set */ - 0, /* Join 2 Message */ - 1, /* Has exceptions +e */ - 0, /* TS Topic Forward */ - 0, /* TS Topic Backward */ - 0, /* Protected Umode */ - 1, /* Has Admin */ - 1, /* Chan SQlines */ - 1, /* Quit on Kill */ - 0, /* SVSMODE unban */ - 0, /* Has Protect */ - 0, /* Reverse */ - 1, /* Chan Reg */ - CMODE_r, /* Channel Mode */ - 0, /* vidents */ - 1, /* svshold */ - 1, /* time stamp on mode */ - 1, /* NICKIP */ - 0, /* O:LINE */ - 1, /* UMODE */ - 1, /* VHOST ON NICK */ - 0, /* Change RealName */ - CMODE_p, /* No Knock */ - CMODE_A, /* Admin Only */ - DEFAULT_MLOCK, /* Default MLOCK */ - UMODE_x, /* Vhost Mode */ - 0, /* +f */ - 0, /* +L */ - 0, - 0, - 1, - 0, /* No Knock requires +i */ - NULL, /* CAPAB Chan Modes */ - 0, /* We support TOKENS */ - 1, /* TOKENS are CASE inSensitive */ - 0, /* TIME STAMPS are BASE64 */ - 1, /* +I support */ - 0, /* SJOIN ban char */ - 0, /* SJOIN except char */ - 0, /* SJOIN invite char */ - 0, /* Can remove User Channel Modes with SVSMODE */ - 0, /* Sglines are not enforced until user reconnects */ - "x", /* vhost char */ - 0, /* ts6 */ - 1, /* support helper umode */ - 0, /* p10 */ - NULL, /* character set */ - 1, /* reports sync state */ - 0, /* CIDR channelbans */ - } - , - {NULL} + {"RageIRCd 2.0.*", /* ircd name */ + "+d", /* nickserv mode */ + "+d", /* chanserv mode */ + "+d", /* memoserv mode */ + "+d", /* hostserv mode */ + "+di", /* operserv mode */ + "+d", /* botserv mode */ + "+dh", /* helpserv mode */ + "+di", /* Dev/Null mode */ + "+di", /* Global mode */ + "+o", /* nickserv alias mode */ + "+o", /* chanserv alias mode */ + "+o", /* memoserv alias mode */ + "+io", /* hostserv alias mode */ + "+io", /* operserv alias mode */ + "+o", /* botserv alias mode */ + "+o", /* helpserv alias mode */ + "+i", /* Dev/Null alias mode */ + "+io", /* Global alias mode */ + "+", /* Used by BotServ Bots */ + 3, /* Chan Max Symbols */ + "-ilmnpRstcOACNM", /* Modes to Remove */ + "+o", /* Channel Umode used by Botserv bots */ + 1, /* SVSNICK */ + 1, /* Vhost */ + 0, /* Has Owner */ + NULL, /* Mode to set for an owner */ + NULL, /* Mode to unset for an owner */ + "+a", /* Mode to set for channel admin */ + "-a", /* Mode to unset for channel admin */ + "+rd", /* Mode On Reg */ + NULL, /* Mode on ID for Roots */ + NULL, /* Mode on ID for Admins */ + NULL, /* Mode on ID for Opers */ + "-rd", /* Mode on UnReg */ + "-r+d", /* Mode on Nick Change */ + 1, /* Supports SGlines */ + 1, /* Supports SQlines */ + 0, /* Supports SZlines */ + 1, /* Supports Halfop +h */ + 3, /* Number of server args */ + 0, /* Join 2 Set */ + 0, /* Join 2 Message */ + 1, /* Has exceptions +e */ + 0, /* TS Topic Forward */ + 0, /* TS Topic Backward */ + 0, /* Protected Umode */ + 1, /* Has Admin */ + 1, /* Chan SQlines */ + 1, /* Quit on Kill */ + 0, /* SVSMODE unban */ + 0, /* Has Protect */ + 0, /* Reverse */ + 1, /* Chan Reg */ + CMODE_r, /* Channel Mode */ + 0, /* vidents */ + 1, /* svshold */ + 1, /* time stamp on mode */ + 1, /* NICKIP */ + 0, /* O:LINE */ + 1, /* UMODE */ + 1, /* VHOST ON NICK */ + 0, /* Change RealName */ + CMODE_p, /* No Knock */ + CMODE_A, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + UMODE_x, /* Vhost Mode */ + 0, /* +f */ + 0, /* +L */ + 0, + 0, + 1, + 0, /* No Knock requires +i */ + NULL, /* CAPAB Chan Modes */ + 0, /* We support TOKENS */ + 1, /* TOKENS are CASE inSensitive */ + 0, /* TIME STAMPS are BASE64 */ + 1, /* +I support */ + 0, /* SJOIN ban char */ + 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ + 0, /* Can remove User Channel Modes with SVSMODE */ + 0, /* Sglines are not enforced until user reconnects */ + "x", /* vhost char */ + 0, /* ts6 */ + 1, /* support helper umode */ + 0, /* p10 */ + NULL, /* character set */ + 1, /* reports sync state */ + 0, /* CIDR channelbans */ + } + , + {NULL} }; IRCDCAPAB myIrcdcap[] = { - { - CAPAB_NOQUIT, /* NOQUIT */ - CAPAB_TSMODE, /* TSMODE */ - CAPAB_UNCONNECT, /* UNCONNECT */ - 0, /* NICKIP */ - 0, /* SJOIN */ - CAPAB_ZIP, /* ZIP */ - CAPAB_BURST, /* BURST */ - 0, /* TS5 */ - 0, /* TS3 */ - CAPAB_DKEY, /* DKEY */ - 0, /* PT4 */ - 0, /* SCS */ - 0, /* QS */ - CAPAB_UID, /* UID */ - 0, /* KNOCK */ - 0, /* CLIENT */ - 0, /* IPV6 */ - 0, /* SSJ5 */ - CAPAB_SN2, /* SN2 */ - CAPAB_TOKEN, /* TOKEN */ - CAPAB_VHOST, /* VHOST */ - CAPAB_SSJ3, /* SSJ3 */ - 0, /* NICK2 */ - 0, /* UMODE2 */ - 0, /* VL */ - 0, /* TLKEXT */ - 0, /* DODKEY */ - 0, /* DOZIP */ - 0, 0, 0} + { + CAPAB_NOQUIT, /* NOQUIT */ + CAPAB_TSMODE, /* TSMODE */ + CAPAB_UNCONNECT, /* UNCONNECT */ + 0, /* NICKIP */ + 0, /* SJOIN */ + CAPAB_ZIP, /* ZIP */ + CAPAB_BURST, /* BURST */ + 0, /* TS5 */ + 0, /* TS3 */ + CAPAB_DKEY, /* DKEY */ + 0, /* PT4 */ + 0, /* SCS */ + 0, /* QS */ + CAPAB_UID, /* UID */ + 0, /* KNOCK */ + 0, /* CLIENT */ + 0, /* IPV6 */ + 0, /* SSJ5 */ + CAPAB_SN2, /* SN2 */ + CAPAB_TOKEN, /* TOKEN */ + CAPAB_VHOST, /* VHOST */ + CAPAB_SSJ3, /* SSJ3 */ + 0, /* NICK2 */ + 0, /* UMODE2 */ + 0, /* VL */ + 0, /* TLKEXT */ + 0, /* DODKEY */ + 0, /* DOZIP */ + 0, 0, 0} }; unsigned long umodes[128] = { - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused, Unused, Horzontal Tab */ - 0, 0, 0, /* Line Feed, Unused, Unused */ - 0, 0, 0, /* Carriage Return, Unused, Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused, Unused, Space */ - 0, 0, 0, /* ! " # */ - 0, 0, 0, /* $ % & */ - 0, 0, 0, /* ! ( ) */ - 0, 0, 0, /* * + , */ - 0, 0, 0, /* - . / */ - 0, 0, /* 0 1 */ - 0, 0, /* 2 3 */ - 0, 0, /* 4 5 */ - 0, 0, /* 6 7 */ - 0, 0, /* 8 9 */ - 0, 0, /* : ; */ - 0, 0, 0, /* < = > */ - 0, 0, /* ? @ */ - UMODE_A, 0, 0, /* A B C */ - 0, 0, 0, /* D E F */ - 0, 0, 0, /* G H I */ - 0, 0, 0, /* J K L */ - 0, 0, 0, /* M N O */ - 0, 0, UMODE_R, /* P Q R */ - 0, 0, 0, /* S T U */ - 0, 0, 0, /* V W X */ - 0, /* Y */ - 0, /* Z */ - 0, 0, 0, /* [ \ ] */ - 0, 0, 0, /* ^ _ ` */ - UMODE_a, 0, 0, /* a b c */ - 0, 0, 0, /* d e f */ - 0, UMODE_h, UMODE_i, /* g h i */ - 0, 0, 0, /* j k l */ - 0, 0, UMODE_o, /* m n o */ - 0, 0, UMODE_r, /* p q r */ - 0, 0, 0, /* s t u */ - 0, UMODE_w, 0, /* v w x */ - 0, /* y */ - 0, /* z */ - 0, 0, 0, /* { | } */ - 0, 0 /* ~ � */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused, Unused, Horzontal Tab */ + 0, 0, 0, /* Line Feed, Unused, Unused */ + 0, 0, 0, /* Carriage Return, Unused, Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused, Unused, Space */ + 0, 0, 0, /* ! " # */ + 0, 0, 0, /* $ % & */ + 0, 0, 0, /* ! ( ) */ + 0, 0, 0, /* * + , */ + 0, 0, 0, /* - . / */ + 0, 0, /* 0 1 */ + 0, 0, /* 2 3 */ + 0, 0, /* 4 5 */ + 0, 0, /* 6 7 */ + 0, 0, /* 8 9 */ + 0, 0, /* : ; */ + 0, 0, 0, /* < = > */ + 0, 0, /* ? @ */ + UMODE_A, 0, 0, /* A B C */ + 0, 0, 0, /* D E F */ + 0, 0, 0, /* G H I */ + 0, 0, 0, /* J K L */ + 0, 0, 0, /* M N O */ + 0, 0, UMODE_R, /* P Q R */ + 0, 0, 0, /* S T U */ + 0, 0, 0, /* V W X */ + 0, /* Y */ + 0, /* Z */ + 0, 0, 0, /* [ \ ] */ + 0, 0, 0, /* ^ _ ` */ + UMODE_a, 0, 0, /* a b c */ + 0, 0, 0, /* d e f */ + 0, UMODE_h, UMODE_i, /* g h i */ + 0, 0, 0, /* j k l */ + 0, 0, UMODE_o, /* m n o */ + 0, 0, UMODE_r, /* p q r */ + 0, 0, 0, /* s t u */ + 0, UMODE_w, 0, /* v w x */ + 0, /* y */ + 0, /* z */ + 0, 0, 0, /* { | } */ + 0, 0 /* ~ � */ }; char myCsmodes[128] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, 0, 0, - 'h', /* (37) % Channel halfops */ - 0, 0, 0, 0, - 'a', /* * Channel Admins */ + 0, + 0, + 0, 0, 0, + 'h', /* (37) % Channel halfops */ + 0, 0, 0, 0, + 'a', /* * Channel Admins */ - 'v', 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'v', 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; CMMode myCmmodes[128] = { - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, /* BCD */ - {NULL}, {NULL}, {NULL}, /* EFG */ - {NULL}, /* H */ - {add_invite, del_invite}, - {NULL}, /* J */ - {NULL}, {NULL}, {NULL}, /* KLM */ - {NULL}, {NULL}, {NULL}, /* NOP */ - {NULL}, {NULL}, {NULL}, /* QRS */ - {NULL}, {NULL}, {NULL}, /* TUV */ - {NULL}, {NULL}, {NULL}, /* WXY */ - {NULL}, /* Z */ - {NULL}, {NULL}, /* (char 91 - 92) */ - {NULL}, {NULL}, {NULL}, /* (char 93 - 95) */ - {NULL}, /* ` (char 96) */ - {NULL}, /* a (char 97) */ - {add_ban, del_ban}, - {NULL}, - {NULL}, - {add_exception, del_exception}, - {NULL}, - {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, /* BCD */ + {NULL}, {NULL}, {NULL}, /* EFG */ + {NULL}, /* H */ + {add_invite, del_invite}, + {NULL}, /* J */ + {NULL}, {NULL}, {NULL}, /* KLM */ + {NULL}, {NULL}, {NULL}, /* NOP */ + {NULL}, {NULL}, {NULL}, /* QRS */ + {NULL}, {NULL}, {NULL}, /* TUV */ + {NULL}, {NULL}, {NULL}, /* WXY */ + {NULL}, /* Z */ + {NULL}, {NULL}, /* (char 91 - 92) */ + {NULL}, {NULL}, {NULL}, /* (char 93 - 95) */ + {NULL}, /* ` (char 96) */ + {NULL}, /* a (char 97) */ + {add_ban, del_ban}, + {NULL}, + {NULL}, + {add_exception, del_exception}, + {NULL}, + {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} }; CBMode myCbmodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, - {CMODE_A, CBM_NO_USER_MLOCK, NULL, NULL}, - {0}, /* B */ - {CMODE_C, 0, NULL, NULL}, - {0}, /* D */ - {0}, /* E */ - {0}, /* F */ - {0}, /* G */ - {0}, /* H */ - {0}, /* I */ - {0}, /* J */ - {0}, /* K */ - {0}, /* L */ - {CMODE_M, 0, NULL, NULL}, /* M */ - {CMODE_N, 0, NULL, NULL}, /* N */ - {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, - {0}, /* P */ - {0}, /* Q */ - {CMODE_R, 0, NULL, NULL}, /* R */ - {CMODE_S, 0, NULL, NULL}, /* S */ - {0}, /* T */ - {0}, /* U */ - {0}, /* V */ - {0}, /* W */ - {0}, /* X */ - {0}, /* Y */ - {0}, /* Z */ - {0}, {0}, {0}, {0}, {0}, {0}, - {0}, /* a */ - {0}, /* b */ - {CMODE_c, 0, NULL, NULL}, - {0}, /* d */ - {0}, /* e */ - {0}, /* f */ - {0}, /* g */ - {0}, /* h */ - {CMODE_i, 0, NULL, NULL}, - {0}, /* j */ - {CMODE_k, 0, chan_set_key, cs_set_key}, - {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, - {CMODE_m, 0, NULL, NULL}, - {CMODE_n, 0, NULL, NULL}, - {0}, /* o */ - {CMODE_p, 0, NULL, NULL}, - {0}, /* q */ - {CMODE_r, CBM_NO_MLOCK, NULL, NULL}, - {CMODE_s, 0, NULL, NULL}, - {CMODE_t, 0, NULL, NULL}, - {0}, - {0}, /* v */ - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {0}, /* z */ - {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, + {CMODE_A, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* B */ + {CMODE_C, 0, NULL, NULL}, + {0}, /* D */ + {0}, /* E */ + {0}, /* F */ + {0}, /* G */ + {0}, /* H */ + {0}, /* I */ + {0}, /* J */ + {0}, /* K */ + {0}, /* L */ + {CMODE_M, 0, NULL, NULL}, /* M */ + {CMODE_N, 0, NULL, NULL}, /* N */ + {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* P */ + {0}, /* Q */ + {CMODE_R, 0, NULL, NULL}, /* R */ + {CMODE_S, 0, NULL, NULL}, /* S */ + {0}, /* T */ + {0}, /* U */ + {0}, /* V */ + {0}, /* W */ + {0}, /* X */ + {0}, /* Y */ + {0}, /* Z */ + {0}, {0}, {0}, {0}, {0}, {0}, + {0}, /* a */ + {0}, /* b */ + {CMODE_c, 0, NULL, NULL}, + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {0}, /* h */ + {CMODE_i, 0, NULL, NULL}, + {0}, /* j */ + {CMODE_k, 0, chan_set_key, cs_set_key}, + {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, + {CMODE_m, 0, NULL, NULL}, + {CMODE_n, 0, NULL, NULL}, + {0}, /* o */ + {CMODE_p, 0, NULL, NULL}, + {0}, /* q */ + {CMODE_r, CBM_NO_MLOCK, NULL, NULL}, + {CMODE_s, 0, NULL, NULL}, + {CMODE_t, 0, NULL, NULL}, + {0}, + {0}, /* v */ + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0} }; CBModeInfo myCbmodeinfos[] = { - {'c', CMODE_c, 0, NULL, NULL}, - {'i', CMODE_i, 0, NULL, NULL}, - {'k', CMODE_k, 0, get_key, cs_get_key}, - {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, - {'m', CMODE_m, 0, NULL, NULL}, - {'n', CMODE_n, 0, NULL, NULL}, - {'p', CMODE_p, 0, NULL, NULL}, - {'r', CMODE_r, 0, NULL, NULL}, - {'s', CMODE_s, 0, NULL, NULL}, - {'t', CMODE_t, 0, NULL, NULL}, - {'A', CMODE_A, 0, NULL, NULL}, - {'C', CMODE_C, 0, NULL, NULL}, - {'M', CMODE_M, 0, NULL, NULL}, - {'N', CMODE_N, 0, NULL, NULL}, - {'O', CMODE_O, 0, NULL, NULL}, - {'R', CMODE_R, 0, NULL, NULL}, - {0} + {'c', CMODE_c, 0, NULL, NULL}, + {'i', CMODE_i, 0, NULL, NULL}, + {'k', CMODE_k, 0, get_key, cs_get_key}, + {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, + {'m', CMODE_m, 0, NULL, NULL}, + {'n', CMODE_n, 0, NULL, NULL}, + {'p', CMODE_p, 0, NULL, NULL}, + {'r', CMODE_r, 0, NULL, NULL}, + {'s', CMODE_s, 0, NULL, NULL}, + {'t', CMODE_t, 0, NULL, NULL}, + {'A', CMODE_A, 0, NULL, NULL}, + {'C', CMODE_C, 0, NULL, NULL}, + {'M', CMODE_M, 0, NULL, NULL}, + {'N', CMODE_N, 0, NULL, NULL}, + {'O', CMODE_O, 0, NULL, NULL}, + {'R', CMODE_R, 0, NULL, NULL}, + {0} }; CUMode myCumodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, - {CUS_PROTECT, CUF_PROTECT_BOTSERV, check_valid_admin}, - {0}, /* b */ - {0}, /* c */ - {0}, /* d */ - {0}, /* e */ - {0}, /* f */ - {0}, /* g */ - {CUS_HALFOP, 0, check_valid_op}, - {0}, /* i */ - {0}, /* j */ - {0}, /* k */ - {0}, /* l */ - {0}, /* m */ - {0}, /* n */ - {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, - {0}, /* p */ - {0}, /* q */ - {0}, /* r */ - {0}, /* s */ - {0}, /* t */ - {0}, /* u */ - {CUS_VOICE, 0, NULL}, - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {0}, /* z */ - {0}, {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, + {CUS_PROTECT, CUF_PROTECT_BOTSERV, check_valid_admin}, + {0}, /* b */ + {0}, /* c */ + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {CUS_HALFOP, 0, check_valid_op}, + {0}, /* i */ + {0}, /* j */ + {0}, /* k */ + {0}, /* l */ + {0}, /* m */ + {0}, /* n */ + {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, + {0}, /* p */ + {0}, /* q */ + {0}, /* r */ + {0}, /* s */ + {0}, /* t */ + {0}, /* u */ + {CUS_VOICE, 0, NULL}, + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0}, {0} }; void rageircd_cmd_bot_unban(ChannelInfo * ci, const char *nick) { - send_cmd(ServerName, "SVSMODE %s -b %s", ci->name, nick); + send_cmd(ServerName, "SVSMODE %s -b %s", ci->name, nick); } int anope_event_sjoin(const char *source, int ac, const char **av) { - do_sjoin(source, ac, av); - return MOD_CONT; + do_sjoin(source, ac, av); + return MOD_CONT; } int anope_event_nick(const char *source, int ac, const char **av) { - User *user; + User *user; - if (ac != 2) { - user = do_nick(source, av[0], av[4], av[5], av[6], av[9], - strtoul(av[2], NULL, 10), strtoul(av[7], NULL, 0), - strtoul(av[8], NULL, 0), "*", NULL); - if (user) - anope_ProcessUsermodes(user, 1, &av[3]); - } else { - do_nick(source, av[0], NULL, NULL, NULL, NULL, - strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); - } - return MOD_CONT; + if (ac != 2) { + user = do_nick(source, av[0], av[4], av[5], av[6], av[9], + strtoul(av[2], NULL, 10), strtoul(av[7], NULL, 0), + strtoul(av[8], NULL, 0), "*", NULL); + if (user) + anope_ProcessUsermodes(user, 1, &av[3]); + } else { + do_nick(source, av[0], NULL, NULL, NULL, NULL, + strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); + } + return MOD_CONT; } /* Event: PROTOCTL */ int anope_event_capab(const char *source, int ac, const char **av) { - capab_parse(ac, av); - return MOD_CONT; + capab_parse(ac, av); + return MOD_CONT; } int anope_event_vhost(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - u = finduser(av[0]); - if (!u) { - if (debug) { - alog("debug: VHOST for nonexistent user %s", av[0]); - } - return MOD_CONT; - } + u = finduser(av[0]); + if (!u) { + if (debug) { + alog("debug: VHOST for nonexistent user %s", av[0]); + } + return MOD_CONT; + } - u->SetDisplayedHost(av[1]); - return MOD_CONT; + u->SetDisplayedHost(av[1]); + return MOD_CONT; } /* ** SNICK -** source = NULL -** parv[0] = nickname Trystan -** parv[1] = timestamp 1090113640 -** parv[2] = hops 1 -** parv[3] = username Trystan -** parv[4] = host c-24-2-101-227.client.comcast.net -** parv[5] = IP 402810339 -** parv[6] = vhost mynet-27CCA80D.client.comcast.net -** parv[7] = server rage2.nomadirc.net +** source = NULL +** parv[0] = nickname Trystan +** parv[1] = timestamp 1090113640 +** parv[2] = hops 1 +** parv[3] = username Trystan +** parv[4] = host c-24-2-101-227.client.comcast.net +** parv[5] = IP 402810339 +** parv[6] = vhost mynet-27CCA80D.client.comcast.net +** parv[7] = server rage2.nomadirc.net ** parv[8] = servicestamp 0 -** parv[9] = modes +ix -** parv[10] = info Dreams are answers to questions not yet asked +** parv[9] = modes +ix +** parv[10] = info Dreams are answers to questions not yet asked */ int anope_event_snick(const char *source, int ac, const char **av) { - User *user; + User *user; - if (ac != 2) { - user = do_nick(source, av[0], av[3], av[4], av[7], av[10], - strtoul(av[1], NULL, 10), strtoul(av[8], NULL, 0), - strtoul(av[5], NULL, 0), av[6], NULL); - if (user) { - anope_ProcessUsermodes(user, 1, &av[9]); - } - } - return MOD_CONT; + if (ac != 2) { + user = do_nick(source, av[0], av[3], av[4], av[7], av[10], + strtoul(av[1], NULL, 10), strtoul(av[8], NULL, 0), + strtoul(av[5], NULL, 0), av[6], NULL); + if (user) { + anope_ProcessUsermodes(user, 1, &av[9]); + } + } + return MOD_CONT; } int anope_event_436(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; + if (ac < 1) + return MOD_CONT; - m_nickcoll(av[0]); - return MOD_CONT; + m_nickcoll(av[0]); + return MOD_CONT; } /* *INDENT-OFF* */ void moduleAddIRCDMsgs(void) { - Message *m; - - updateProtectDetails("ADMIN","ADMINME","admin","deadmin","AUTOADMIN","+a","-a"); - - m = createMessage("401", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("402", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); - m = createMessage("482", anope_event_482); addCoreMessage(IRCD,m); - m = createMessage("461", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); - m = createMessage("INVITE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); - m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); - m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); - m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); - m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); - m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); - m = createMessage("NOTICE", anope_event_notice); addCoreMessage(IRCD,m); - m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); - m = createMessage("PASS", anope_event_pass); addCoreMessage(IRCD,m); - m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); - m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); - m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); - m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); - m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); - m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); - m = createMessage("USER", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("WALLOPS", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); - m = createMessage("AKILL", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("GLOBOPS", anope_event_globops); addCoreMessage(IRCD,m); - m = createMessage("GOPER", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("RAKILL", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SILENCE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SVSKILL", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SVSMODE", anope_event_mode); addCoreMessage(IRCD,m); - m = createMessage("SVSNICK", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SVSNOOP", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SQLINE", anope_event_sqline); addCoreMessage(IRCD,m); - m = createMessage("UNSQLINE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); - m = createMessage("CS", anope_event_cs); addCoreMessage(IRCD,m); - m = createMessage("HS", anope_event_hs); addCoreMessage(IRCD,m); - m = createMessage("MS", anope_event_ms); addCoreMessage(IRCD,m); - m = createMessage("NS", anope_event_ns); addCoreMessage(IRCD,m); - m = createMessage("OS", anope_event_os); addCoreMessage(IRCD,m); - m = createMessage("RS", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SGLINE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); - m = createMessage("SS", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SVINFO", anope_event_svinfo); addCoreMessage(IRCD,m); - m = createMessage("SZLINE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("UNSGLINE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("UNSZLINE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SNICK", anope_event_snick); addCoreMessage(IRCD,m); - m = createMessage("VHOST", anope_event_vhost); addCoreMessage(IRCD,m); - m = createMessage("MYID", anope_event_myid); addCoreMessage(IRCD,m); - m = createMessage("GNOTICE", anope_event_notice); addCoreMessage(IRCD,m); - m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m); - m = createMessage("BURST", anope_event_burst); addCoreMessage(IRCD,m); - m = createMessage("REHASH", anope_event_rehash); addCoreMessage(IRCD,m); - m = createMessage("ADMIN", anope_event_admin); addCoreMessage(IRCD,m); - m = createMessage("CREDITS", anope_event_credits); addCoreMessage(IRCD,m); + Message *m; + + updateProtectDetails("ADMIN","ADMINME","admin","deadmin","AUTOADMIN","+a","-a"); + + m = createMessage("401", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("402", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); + m = createMessage("482", anope_event_482); addCoreMessage(IRCD,m); + m = createMessage("461", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); + m = createMessage("INVITE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); + m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); + m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); + m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); + m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("NOTICE", anope_event_notice); addCoreMessage(IRCD,m); + m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); + m = createMessage("PASS", anope_event_pass); addCoreMessage(IRCD,m); + m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); + m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); + m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); + m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); + m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); + m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); + m = createMessage("USER", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("WALLOPS", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); + m = createMessage("AKILL", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("GLOBOPS", anope_event_globops); addCoreMessage(IRCD,m); + m = createMessage("GOPER", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("RAKILL", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SILENCE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SVSKILL", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SVSMODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("SVSNICK", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SVSNOOP", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SQLINE", anope_event_sqline); addCoreMessage(IRCD,m); + m = createMessage("UNSQLINE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); + m = createMessage("CS", anope_event_cs); addCoreMessage(IRCD,m); + m = createMessage("HS", anope_event_hs); addCoreMessage(IRCD,m); + m = createMessage("MS", anope_event_ms); addCoreMessage(IRCD,m); + m = createMessage("NS", anope_event_ns); addCoreMessage(IRCD,m); + m = createMessage("OS", anope_event_os); addCoreMessage(IRCD,m); + m = createMessage("RS", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SGLINE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); + m = createMessage("SS", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SVINFO", anope_event_svinfo); addCoreMessage(IRCD,m); + m = createMessage("SZLINE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("UNSGLINE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("UNSZLINE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SNICK", anope_event_snick); addCoreMessage(IRCD,m); + m = createMessage("VHOST", anope_event_vhost); addCoreMessage(IRCD,m); + m = createMessage("MYID", anope_event_myid); addCoreMessage(IRCD,m); + m = createMessage("GNOTICE", anope_event_notice); addCoreMessage(IRCD,m); + m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m); + m = createMessage("BURST", anope_event_burst); addCoreMessage(IRCD,m); + m = createMessage("REHASH", anope_event_rehash); addCoreMessage(IRCD,m); + m = createMessage("ADMIN", anope_event_admin); addCoreMessage(IRCD,m); + m = createMessage("CREDITS", anope_event_credits); addCoreMessage(IRCD,m); } /* *INDENT-ON* */ int anope_event_error(const char *source, int ac, const char **av) { - if (ac >= 1) { - if (debug) { - alog("debug: %s", av[0]); - } - } - return MOD_CONT; + if (ac >= 1) { + if (debug) { + alog("debug: %s", av[0]); + } + } + return MOD_CONT; } int anope_event_burst(const char *source, int ac, const char **av) { - Server *s; - s = findserver(servlist, source); - if (ac > 1) { - /* for future use - start burst */ + Server *s; + s = findserver(servlist, source); + if (ac > 1) { + /* for future use - start burst */ } else { - /* If we found a server with the given source, that one just - * finished bursting. If there was no source, then our uplink - * server finished bursting. -GD - */ - if (!s && serv_uplink) - s = serv_uplink; - finish_sync(s, 1); + /* If we found a server with the given source, that one just + * finished bursting. If there was no source, then our uplink + * server finished bursting. -GD + */ + if (!s && serv_uplink) + s = serv_uplink; + finish_sync(s, 1); } return MOD_CONT; @@ -598,26 +598,26 @@ return MOD_CONT; void rageircd_SendSQLine(const char *mask, const char *reason) { - if (!mask || !reason) { - return; - } + if (!mask || !reason) { + return; + } - send_cmd(NULL, "SQLINE %s :%s", mask, reason); + send_cmd(NULL, "SQLINE %s :%s", mask, reason); } void rageircd_SendSGLineDel(const char *mask) { - send_cmd(NULL, "UNSGLINE 0 :%s", mask); + send_cmd(NULL, "UNSGLINE 0 :%s", mask); } void rageircd_SendSZLineDel(const char *mask) { - send_cmd(NULL, "UNSZLINE 0 %s", mask); + send_cmd(NULL, "UNSZLINE 0 %s", mask); } void rageircd_SendSZLine(const char *mask, const char *reason, const char *whom) { - send_cmd(NULL, "SZLINE %s :%s", mask, reason); + send_cmd(NULL, "SZLINE %s :%s", mask, reason); } void RageIRCdProto::SendSVSNOOP(const char *server, int set) @@ -632,7 +632,7 @@ void rageircd_cmd_svsadmin(const char *server, int set) void rageircd_SendSGLine(const char *mask, const char *reason) { - send_cmd(NULL, "SGLINE %d :%s:%s", (int)strlen(mask), mask, reason); + send_cmd(NULL, "SGLINE %d :%s:%s", (int)strlen(mask), mask, reason); } @@ -645,557 +645,557 @@ void RageIRCdProto::SendAkillDel(const char *user, const char *host) /* PART */ void rageircd_SendPart(const char *nick, const char *chan, const char *buf) { - if (!nick || !chan) { - return; - } + if (!nick || !chan) { + return; + } - if (buf) { - send_cmd(nick, "PART %s :%s", chan, buf); - } else { - send_cmd(nick, "PART %s", chan); - } + if (buf) { + send_cmd(nick, "PART %s :%s", chan, buf); + } else { + send_cmd(nick, "PART %s", chan); + } } void rageircd_cmd_topic(const char *whosets, const char *chan, const char *whosetit, - const char *topic, time_t when) + const char *topic, time_t when) { - send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit, - (unsigned long int) when, topic); + send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit, + (unsigned long int) when, topic); } void rageircd_SendVhostDel(User * u) { - send_cmd(s_HostServ, "SVSMODE %s -x", u->nick); - notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar); + send_cmd(s_HostServ, "SVSMODE %s -x", u->nick); + notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar); } void rageircd_cmd_chghost(const char *nick, const char *vhost) { - if (!nick || !vhost) { - return; - } - send_cmd(ServerName, "VHOST %s %s", nick, vhost); + if (!nick || !vhost) { + return; + } + send_cmd(ServerName, "VHOST %s %s", nick, vhost); } void rageircd_SendVhost(const char *nick, const char *vIdent, const char *vhost) { - send_cmd(s_HostServ, "SVSMODE %s +x", nick); - rageircd_cmd_chghost(nick, vhost); + send_cmd(s_HostServ, "SVSMODE %s +x", nick); + rageircd_cmd_chghost(nick, vhost); } void rageircd_SendSQLineDel(const char *user) { - send_cmd(NULL, "UNSQLINE %s", user); + send_cmd(NULL, "UNSQLINE %s", user); } void rageircd_SendJoin(const char *user, const char *channel, time_t chantime) { - send_cmd(user, "SJOIN %ld %s", (long int) chantime, channel); + send_cmd(user, "SJOIN %ld %s", (long int) chantime, channel); } void rageircd_SendAkill(const char *user, const char *host, const char *who, time_t when, - time_t expires, const char *reason) + time_t expires, const char *reason) { - send_cmd(NULL, "AKILL %s %s %d %s %ld :%s", host, user, 86400 * 2, who, - (long int) time(NULL), reason); + send_cmd(NULL, "AKILL %s %s %d %s %ld :%s", host, user, 86400 * 2, who, + (long int) time(NULL), reason); } void rageircd_SendSVSKill(const char *source, const char *user, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - if (!source || !user) { - return; - } + if (!source || !user) { + return; + } - send_cmd(source, "SVSKILL %s :%s", user, buf); + send_cmd(source, "SVSKILL %s :%s", user, buf); } void rageircd_SendSVSMode(User * u, int ac, const char **av) { - send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick, - (long int) u->timestamp, av[0], (ac == 2 ? " " : ""), - (ac == 2 ? av[1] : "")); + send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick, + (long int) u->timestamp, av[0], (ac == 2 ? " " : ""), + (ac == 2 ? av[1] : "")); } void rageircd_SendSquit(const char *servname, const char *message) { - send_cmd(NULL, "SQUIT %s :%s", servname, message); + send_cmd(NULL, "SQUIT %s :%s", servname, message); } /* PONG */ void rageircd_SendPong(const char *servname, const char *who) { - send_cmd(servname, "PONG %s", who); + send_cmd(servname, "PONG %s", who); } void rageircd_cmd_svinfo() { - send_cmd(NULL, "SVINFO 5 3 0 %ld bluemoon 0", (long int) time(NULL)); + send_cmd(NULL, "SVINFO 5 3 0 %ld bluemoon 0", (long int) time(NULL)); } void rageircd_cmd_capab() { - /* CAPAB BURST UNCONNECT ZIP SSJ3 SN2 VHOST SUID TOK1 TSMODE */ - send_cmd(NULL, "CAPAB BURST UNCONNECT SSJ3 SN2 VHOST TSMODE"); + /* CAPAB BURST UNCONNECT ZIP SSJ3 SN2 VHOST SUID TOK1 TSMODE */ + send_cmd(NULL, "CAPAB BURST UNCONNECT SSJ3 SN2 VHOST TSMODE"); } void rageircd_SendServer(const char *servname, int hop, const char *descript) { - send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript); + send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript); } /* PASS */ void rageircd_cmd_pass(const char *pass) { - send_cmd(NULL, "PASS %s :TS", pass); + send_cmd(NULL, "PASS %s :TS", pass); } void rageircd_cmd_burst() { - send_cmd(NULL, "BURST"); + send_cmd(NULL, "BURST"); } void rageircd_SendConnect(int servernum) { - if (Numeric) { - me_server = - new_server(NULL, ServerName, ServerDesc, SERVER_ISME, Numeric); - } else { - me_server = - new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); - } - - if (servernum == 1) - rageircd_cmd_pass(RemotePassword); - else if (servernum == 2) - rageircd_cmd_pass(RemotePassword2); - else if (servernum == 3) - rageircd_cmd_pass(RemotePassword3); - rageircd_cmd_capab(); - if (Numeric) { - send_cmd(NULL, "MYID !%s", Numeric); - } - rageircd_SendServer(ServerName, 1, ServerDesc); - rageircd_cmd_svinfo(); - rageircd_cmd_burst(); + if (Numeric) { + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, Numeric); + } else { + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); + } + + if (servernum == 1) + rageircd_cmd_pass(RemotePassword); + else if (servernum == 2) + rageircd_cmd_pass(RemotePassword2); + else if (servernum == 3) + rageircd_cmd_pass(RemotePassword3); + rageircd_cmd_capab(); + if (Numeric) { + send_cmd(NULL, "MYID !%s", Numeric); + } + rageircd_SendServer(ServerName, 1, ServerDesc); + rageircd_cmd_svinfo(); + rageircd_cmd_burst(); } void rageircd_ProcessUsermodes(User * user, int ac, const char **av) { - int add = 1; /* 1 if adding modes, 0 if deleting */ - const char *modes = av[0]; - - ac--; - - if (debug) - alog("debug: Changing mode for %s to %s", user->nick, modes); - - while (*modes) { - - /* This looks better, much better than "add ? (do_add) : (do_remove)". - * At least this is readable without paying much attention :) -GD - */ - if (add) - user->mode |= umodes[(int) *modes]; - else - user->mode &= ~umodes[(int) *modes]; - - switch (*modes++) { - case '+': - add = 1; - break; - case '-': - add = 0; - break; - case 'd': - if (ac == 0) { - alog("user: umode +d with no parameter (?) for user %s", - user->nick); - break; - } - - ac--; - av++; - user->svid = strtoul(*av, NULL, 0); - break; - case 'o': - if (add) { - opcnt++; - - if (WallOper) - anope_SendGlobops(s_OperServ, - "\2%s\2 is now an IRC operator.", - user->nick); - display_news(user, NEWS_OPER); - if (is_services_oper(user)) { - common_svsmode(user, "+a", NULL); - user->mode |= UMODE_a; - } - } else { - opcnt--; - } - break; - case 'r': - if (add && !nick_identified(user)) { - common_svsmode(user, "-r", NULL); - user->mode &= ~UMODE_r; - } - break; - case 'x': - update_host(user); - break; - } - } + int add = 1; /* 1 if adding modes, 0 if deleting */ + const char *modes = av[0]; + + ac--; + + if (debug) + alog("debug: Changing mode for %s to %s", user->nick, modes); + + while (*modes) { + + /* This looks better, much better than "add ? (do_add) : (do_remove)". + * At least this is readable without paying much attention :) -GD + */ + if (add) + user->mode |= umodes[(int) *modes]; + else + user->mode &= ~umodes[(int) *modes]; + + switch (*modes++) { + case '+': + add = 1; + break; + case '-': + add = 0; + break; + case 'd': + if (ac == 0) { + alog("user: umode +d with no parameter (?) for user %s", + user->nick); + break; + } + + ac--; + av++; + user->svid = strtoul(*av, NULL, 0); + break; + case 'o': + if (add) { + opcnt++; + + if (WallOper) + anope_SendGlobops(s_OperServ, + "\2%s\2 is now an IRC operator.", + user->nick); + display_news(user, NEWS_OPER); + if (is_services_oper(user)) { + common_svsmode(user, "+a", NULL); + user->mode |= UMODE_a; + } + } else { + opcnt--; + } + break; + case 'r': + if (add && !nick_identified(user)) { + common_svsmode(user, "-r", NULL); + user->mode &= ~UMODE_r; + } + break; + case 'x': + update_host(user); + break; + } + } } /* GLOBOPS */ void rageircd_SendGlobops(const char *source, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf); + send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf); } void rageircd_SendNoticeChanops(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "NOTICE @%s :%s", dest, buf); + send_cmd(NULL, "NOTICE @%s :%s", dest, buf); } void rageircd_cmd_notice(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - if (NSDefFlags & NI_MSG) { - rageircd_cmd_privmsg2(source, dest, buf); - } else { - send_cmd(source, "NOTICE %s :%s", dest, buf); - } + if (NSDefFlags & NI_MSG) { + rageircd_cmd_privmsg2(source, dest, buf); + } else { + send_cmd(source, "NOTICE %s :%s", dest, buf); + } } void rageircd_cmd_notice2(const char *source, const char *dest, const char *msg) { - send_cmd(source, "NOTICE %s :%s", dest, msg); + send_cmd(source, "NOTICE %s :%s", dest, msg); } void rageircd_cmd_privmsg(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(source, "PRIVMSG %s :%s", dest, buf); + send_cmd(source, "PRIVMSG %s :%s", dest, buf); } void rageircd_cmd_privmsg2(const char *source, const char *dest, const char *msg) { - send_cmd(source, "PRIVMSG %s :%s", dest, msg); + send_cmd(source, "PRIVMSG %s :%s", dest, msg); } void rageircd_SendGlobalNotice(const char *source, const char *dest, const char *msg) { - send_cmd(source, "NOTICE $%s :%s", dest, msg); + send_cmd(source, "NOTICE $%s :%s", dest, msg); } void rageircd_SendGlobalPrivmsg(const char *source, const char *dest, const char *msg) { - send_cmd(source, "PRIVMSG $%s :%s", dest, msg); + send_cmd(source, "PRIVMSG $%s :%s", dest, msg); } int anope_event_away(const char *source, int ac, const char **av) { - if (!source) { - return MOD_CONT; - } - m_away(source, (ac ? av[0] : NULL)); - return MOD_CONT; + if (!source) { + return MOD_CONT; + } + m_away(source, (ac ? av[0] : NULL)); + return MOD_CONT; } int anope_event_ping(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - rageircd_SendPong(ac > 1 ? av[1] : ServerName, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + rageircd_SendPong(ac > 1 ? av[1] : ServerName, av[0]); + return MOD_CONT; } void rageircd_cmd_351(const char *source) { - send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s (%s) -- %s", - source, version_number, ServerName, ircd->name, version_flags, - EncModule, version_build); + send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s (%s) -- %s", + source, version_number, ServerName, ircd->name, version_flags, + EncModule, version_build); } void rageircd_SendMode(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - if (ircdcap->tsmode) { - if (uplink_capab & ircdcap->tsmode || UseTSMODE) { - send_cmd(source, "MODE %s 0 %s", dest, buf); - } else { - send_cmd(source, "MODE %s %s", dest, buf); - } - } else { - send_cmd(source, "MODE %s %s", dest, buf); - } + if (ircdcap->tsmode) { + if (uplink_capab & ircdcap->tsmode || UseTSMODE) { + send_cmd(source, "MODE %s 0 %s", dest, buf); + } else { + send_cmd(source, "MODE %s %s", dest, buf); + } + } else { + send_cmd(source, "MODE %s %s", dest, buf); + } } void rageircd_SendKick(const char *source, const char *chan, const char *user, const char *buf) { - if (buf) { - send_cmd(source, "KICK %s %s :%s", chan, user, buf); - } else { - send_cmd(source, "KICK %s %s", chan, user); - } + if (buf) { + send_cmd(source, "KICK %s %s :%s", chan, user, buf); + } else { + send_cmd(source, "KICK %s %s", chan, user); + } } void rageircd_cmd_372(const char *source, const char *msg) { - send_cmd(ServerName, "372 %s :- %s", source, msg); + send_cmd(ServerName, "372 %s :- %s", source, msg); } void rageircd_cmd_372_error(const char *source) { - send_cmd(ServerName, "422 %s :- MOTD file not found! Please " - "contact your IRC administrator.", source); + send_cmd(ServerName, "422 %s :- MOTD file not found! Please " + "contact your IRC administrator.", source); } void rageircd_cmd_375(const char *source) { - send_cmd(ServerName, "375 %s :- %s Message of the Day", - source, ServerName); + send_cmd(ServerName, "375 %s :- %s Message of the Day", + source, ServerName); } void rageircd_cmd_376(const char *source) { - send_cmd(ServerName, "376 %s :End of /MOTD command.", source); + send_cmd(ServerName, "376 %s :End of /MOTD command.", source); } /* INVITE */ void rageircd_SendInvite(const char *source, const char *chan, const char *nick) { - if (!source || !chan || !nick) { - return; - } + if (!source || !chan || !nick) { + return; + } - send_cmd(source, "INVITE %s %s", nick, chan); + send_cmd(source, "INVITE %s %s", nick, chan); } /* 391 */ void rageircd_cmd_391(const char *source, const char *timestr) { - if (!timestr) { - return; - } - send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr); + if (!timestr) { + return; + } + send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr); } /* 250 */ void rageircd_cmd_250(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "250 %s", buf); + send_cmd(NULL, "250 %s", buf); } /* 307 */ void rageircd_cmd_307(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "307 %s", buf); + send_cmd(ServerName, "307 %s", buf); } /* 311 */ void rageircd_cmd_311(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "311 %s", buf); + send_cmd(ServerName, "311 %s", buf); } /* 312 */ void rageircd_cmd_312(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "312 %s", buf); + send_cmd(ServerName, "312 %s", buf); } /* 317 */ void rageircd_cmd_317(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "317 %s", buf); + send_cmd(ServerName, "317 %s", buf); } /* 219 */ void rageircd_cmd_219(const char *source, const char *letter) { - if (!source) { - return; - } + if (!source) { + return; + } - if (letter) { - send_cmd(NULL, "219 %s %c :End of /STATS report.", source, - *letter); - } else { - send_cmd(NULL, "219 %s l :End of /STATS report.", source); - } + if (letter) { + send_cmd(NULL, "219 %s %c :End of /STATS report.", source, + *letter); + } else { + send_cmd(NULL, "219 %s l :End of /STATS report.", source); + } } /* 401 */ void rageircd_cmd_401(const char *source, const char *who) { - if (!source || !who) { - return; - } - send_cmd(ServerName, "401 %s %s :No such service.", source, who); + if (!source || !who) { + return; + } + send_cmd(ServerName, "401 %s %s :No such service.", source, who); } /* 318 */ void rageircd_cmd_318(const char *source, const char *who) { - if (!source || !who) { - return; - } + if (!source || !who) { + return; + } - send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who); + send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who); } /* 242 */ void rageircd_cmd_242(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "242 %s", buf); + send_cmd(NULL, "242 %s", buf); } /* 243 */ void rageircd_cmd_243(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "243 %s", buf); + send_cmd(NULL, "243 %s", buf); } /* 211 */ void rageircd_cmd_211(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "211 %s", buf); + send_cmd(NULL, "211 %s", buf); } void rageircd_cmd_nick(const char *nick, const char *name, const char *modes) { - EnforceQlinedNick(nick, NULL); - send_cmd(NULL, "SNICK %s %ld 1 %s %s 0 * %s 0 %s :%s", nick, - (long int) time(NULL), ServiceUser, ServiceHost, ServerName, - modes, name); - rageircd_SendSQLine(nick, "Reserved for services"); + EnforceQlinedNick(nick, NULL); + send_cmd(NULL, "SNICK %s %ld 1 %s %s 0 * %s 0 %s :%s", nick, + (long int) time(NULL), ServiceUser, ServiceHost, ServerName, + modes, name); + rageircd_SendSQLine(nick, "Reserved for services"); } /* EVENT : OS */ int anope_event_os(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_OperServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_OperServ, av[0]); + return MOD_CONT; } /* EVENT : NS */ int anope_event_ns(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_NickServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_NickServ, av[0]); + return MOD_CONT; } /* EVENT : MS */ int anope_event_ms(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_MemoServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_MemoServ, av[0]); + return MOD_CONT; } /* EVENT : HS */ int anope_event_hs(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_HostServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_HostServ, av[0]); + return MOD_CONT; } /* EVENT : CS */ int anope_event_cs(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_ChanServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_ChanServ, av[0]); + return MOD_CONT; } /* QUIT */ void rageircd_SendQuit(const char *source, const char *buf) { - if (buf) { - send_cmd(source, "QUIT :%s", buf); - } else { - send_cmd(source, "QUIT"); - } + if (buf) { + send_cmd(source, "QUIT :%s", buf); + } else { + send_cmd(source, "QUIT"); + } } void rageircd_SendClientIntroduction(const char *nick, const char *user, const char *host, const char *real, - const char *modes) + const char *modes) { - EnforceQlinedNick(nick, s_BotServ); - send_cmd(NULL, "SNICK %s %ld 1 %s %s 0 * %s 0 %s :%s", nick, - (long int) time(NULL), user, host, ServerName, modes, real); - rageircd_SendSQLine(nick, "Reserved for services"); + EnforceQlinedNick(nick, s_BotServ); + send_cmd(NULL, "SNICK %s %ld 1 %s %s 0 * %s 0 %s :%s", nick, + (long int) time(NULL), user, host, ServerName, modes, real); + rageircd_SendSQLine(nick, "Reserved for services"); } /* SVSMODE -b */ void rageircd_SendBanDel(const char *name, const char *nick) { - rageircd_SendSVSMode_chan(name, "-b", nick); + rageircd_SendSVSMode_chan(name, "-b", nick); } @@ -1203,165 +1203,165 @@ void rageircd_SendBanDel(const char *name, const char *nick) void rageircd_SendSVSMode_chan(const char *name, const char *mode, const char *nick) { - if (nick) { - send_cmd(ServerName, "SVSMODE %s %s %s", name, mode, nick); - } else { - send_cmd(ServerName, "SVSMODE %s %s", name, mode); - } + if (nick) { + send_cmd(ServerName, "SVSMODE %s %s %s", name, mode, nick); + } else { + send_cmd(ServerName, "SVSMODE %s %s", name, mode); + } } void rageircd_SendBotOp(const char *nick, const char *chan) { - anope_SendMode(nick, chan, "%s %s", ircd->botchanumode, nick); + anope_SendMode(nick, chan, "%s %s", ircd->botchanumode, nick); } int anope_event_server(const char *source, int ac, const char **av) { - if (!stricmp(av[1], "1")) { - uplink = sstrdup(av[0]); - } - do_server(source, av[0], av[1], av[2], NULL); - return MOD_CONT; + if (!stricmp(av[1], "1")) { + uplink = sstrdup(av[0]); + } + do_server(source, av[0], av[1], av[2], NULL); + return MOD_CONT; } int anope_event_privmsg(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; - m_privmsg(source, av[0], av[1]); - return MOD_CONT; + if (ac != 2) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; } int anope_event_part(const char *source, int ac, const char **av) { - if (ac < 1 || ac > 2) - return MOD_CONT; - do_part(source, ac, av); - return MOD_CONT; + if (ac < 1 || ac > 2) + return MOD_CONT; + do_part(source, ac, av); + return MOD_CONT; } int anope_event_whois(const char *source, int ac, const char **av) { - if (source && ac >= 1) { - m_whois(source, av[0]); - } - return MOD_CONT; + if (source && ac >= 1) { + m_whois(source, av[0]); + } + return MOD_CONT; } int anope_event_482(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_topic(const char *source, int ac, const char **av) { - if (ac != 4) - return MOD_CONT; - do_topic(source, ac, av); - return MOD_CONT; + if (ac != 4) + return MOD_CONT; + do_topic(source, ac, av); + return MOD_CONT; } int anope_event_squit(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; - do_squit(source, ac, av); - return MOD_CONT; + if (ac != 2) + return MOD_CONT; + do_squit(source, ac, av); + return MOD_CONT; } int anope_event_quit(const char *source, int ac, const char **av) { - if (ac != 1) - return MOD_CONT; - do_quit(source, ac, av); - return MOD_CONT; + if (ac != 1) + return MOD_CONT; + do_quit(source, ac, av); + return MOD_CONT; } int anope_event_mode(const char *source, int ac, const char **av) { - if (ac < 2) - return MOD_CONT; + if (ac < 2) + return MOD_CONT; - if (*av[0] == '#' || *av[0] == '&') { - do_cmode(source, ac, av); - } else { - do_umode(source, ac, av); - } - return MOD_CONT; + if (*av[0] == '#' || *av[0] == '&') { + do_cmode(source, ac, av); + } else { + do_umode(source, ac, av); + } + return MOD_CONT; } int anope_event_kill(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - m_kill(av[0], av[1]); - return MOD_CONT; + m_kill(av[0], av[1]); + return MOD_CONT; } int anope_event_kick(const char *source, int ac, const char **av) { - if (ac != 3) - return MOD_CONT; - do_kick(source, ac, av); - return MOD_CONT; + if (ac != 3) + return MOD_CONT; + do_kick(source, ac, av); + return MOD_CONT; } int anope_event_join(const char *source, int ac, const char **av) { - if (ac != 1) - return MOD_CONT; - do_join(source, ac, av); - return MOD_CONT; + if (ac != 1) + return MOD_CONT; + do_join(source, ac, av); + return MOD_CONT; } int anope_event_motd(const char *source, int ac, const char **av) { - if (!source) { - return MOD_CONT; - } + if (!source) { + return MOD_CONT; + } - m_motd(source); - return MOD_CONT; + m_motd(source); + return MOD_CONT; } /* SVSHOLD - set */ void rageircd_SendSVSHOLD(const char *nick) { - send_cmd(ServerName, "SVSHOLD %s %d :%s", nick, NSReleaseTimeout, - "Being held for registered user"); + send_cmd(ServerName, "SVSHOLD %s %d :%s", nick, NSReleaseTimeout, + "Being held for registered user"); } /* SVSHOLD - release */ void rageircd_SendSVSHOLDDel(const char *nick) { - send_cmd(ServerName, "SVSHOLD %s 0", nick); + send_cmd(ServerName, "SVSHOLD %s 0", nick); } void rageircd_SendForceNickChange(const char *source, const char *guest, time_t when) { - if (!source || !guest) { - return; - } - send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, (long int) when); + if (!source || !guest) { + return; + } + send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, (long int) when); } void rageircd_SendGuestNick(const char *nick, const char *user, const char *host, - const char *real, const char *modes) + const char *real, const char *modes) { - send_cmd(NULL, "SNICK %s %ld 1 %s %s 0 * %s 0 %s :%s", nick, - (long int) time(NULL), user, host, ServerName, modes, real); + send_cmd(NULL, "SNICK %s %ld 1 %s %s 0 * %s 0 %s :%s", nick, + (long int) time(NULL), user, host, ServerName, modes, real); } void rageircd_SendSVSO(const char *source, const char *nick, const char *flag) { - /* Not Supported by this IRCD */ + /* Not Supported by this IRCD */ } @@ -1369,52 +1369,52 @@ void rageircd_SendSVSO(const char *source, const char *nick, const char *flag) /* sent if svid is something weird */ void rageircd_SendSVID(const char *nick, time_t ts) { - send_cmd(ServerName, "SVSMODE %s %lu +d 1", nick, - (unsigned long int) ts); + send_cmd(ServerName, "SVSMODE %s %lu +d 1", nick, + (unsigned long int) ts); } /* SVSMODE +d */ /* nc_change was = 1, and there is no na->status */ void rageircd_SendUnregisteredNick(User * u) { - common_svsmode(u, "+d", "1"); + common_svsmode(u, "+d", "1"); } /* SVSMODE +d */ void rageircd_SendSVID2(User * u, const char *ts) { - /* not used by bahamut ircds */ + /* not used by bahamut ircds */ } void rageircd_SendSVID3(User * u, const char *ts) { - if (u->svid != u->timestamp) { - common_svsmode(u, "+rd", ts); - } else { - common_svsmode(u, "+r", NULL); - } + if (u->svid != u->timestamp) { + common_svsmode(u, "+rd", ts); + } else { + common_svsmode(u, "+r", NULL); + } } /* NICK <newnick> */ void rageircd_SendChangeBotNick(const char *oldnick, const char *newnick) { - if (!oldnick || !newnick) { - return; - } + if (!oldnick || !newnick) { + return; + } - send_cmd(oldnick, "NICK %s", newnick); + send_cmd(oldnick, "NICK %s", newnick); } int anope_event_myid(const char *source, int ac, const char **av) { - /* currently not used but removes the message : unknown message from server */ - return MOD_CONT; + /* currently not used but removes the message : unknown message from server */ + return MOD_CONT; } int anope_event_pass(const char *source, int ac, const char **av) { - /* currently not used but removes the message : unknown message from server */ - return MOD_CONT; + /* currently not used but removes the message : unknown message from server */ + return MOD_CONT; } /* @@ -1434,90 +1434,90 @@ int anope_event_pass(const char *source, int ac, const char **av) */ int anope_event_svinfo(const char *source, int ac, const char **av) { - /* currently not used but removes the message : unknown message from server */ - return MOD_CONT; + /* currently not used but removes the message : unknown message from server */ + return MOD_CONT; } int anope_event_gnotice(const char *source, int ac, const char **av) { - /* currently not used but removes the message : unknown message from server */ - return MOD_CONT; + /* currently not used but removes the message : unknown message from server */ + return MOD_CONT; } int anope_event_notice(const char *source, int ac, const char **av) { - /* currently not used but removes the message : unknown message from server */ - return MOD_CONT; + /* currently not used but removes the message : unknown message from server */ + return MOD_CONT; } int anope_event_sqline(const char *source, int ac, const char **av) { - /* currently not used but removes the message : unknown message from server */ - return MOD_CONT; + /* currently not used but removes the message : unknown message from server */ + return MOD_CONT; } void rageircd_SendSVSJoin(const char *source, const char *nick, const char *chan, const char *param) { - /* Find no reference to it in the code and docs */ + /* Find no reference to it in the code and docs */ } void rageircd_SendSVSPart(const char *source, const char *nick, const char *chan) { - /* Find no reference to it in the code and docs */ + /* Find no reference to it in the code and docs */ } void rageircd_SendSWhois(const char *source, const char *who, const char *mask) { - /* not supported */ + /* not supported */ } int anope_event_rehash(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_credits(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_admin(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_globops(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int rageircd_IsFloodModeParamValid(const char *value) { - return 0; + return 0; } void rageircd_SendEOB() { - send_cmd(NULL, "BURST 0"); + send_cmd(NULL, "BURST 0"); } void rageircd_SendJupe(const char *jserver, const char *who, const char *reason) { - char rbuf[256]; + char rbuf[256]; - snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who, - reason ? ": " : "", reason ? reason : ""); + snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who, + reason ? ": " : "", reason ? reason : ""); - if (findserver(servlist, jserver)) - rageircd_SendSquit(jserver, rbuf); - rageircd_SendServer(jserver, 2, rbuf); - new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL); + if (findserver(servlist, jserver)) + rageircd_SendSquit(jserver, rbuf); + rageircd_SendServer(jserver, 2, rbuf); + new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL); } /* GLOBOPS - to handle old WALLOPS */ void rageircd_SendGlobops_legacy(const char *source, const char *fmt) { - send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt); + send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt); } /* @@ -1526,8 +1526,8 @@ void rageircd_SendGlobops_legacy(const char *source, const char *fmt) */ int rageircd_IsNickValid(const char *nick) { - /* no hard coded invalid nicks */ - return 1; + /* no hard coded invalid nicks */ + return 1; } /* @@ -1536,23 +1536,23 @@ int rageircd_IsNickValid(const char *nick) */ int rageircd_IsChannelValid(const char *chan) { - /* no hard coded invalid nicks */ - return 1; + /* no hard coded invalid nicks */ + return 1; } void rageircd_SendCTCP(const char *source, const char *dest, const char *buf) { - char *s; + char *s; - if (!buf) { - return; - } else { - s = normalizeBuffer(buf); - } + if (!buf) { + return; + } else { + s = normalizeBuffer(buf); + } - send_cmd(source, "NOTICE %s :\1%s \1", dest, s); - free(s); + send_cmd(source, "NOTICE %s :\1%s \1", dest, s); + free(s); } @@ -1562,78 +1562,78 @@ void rageircd_SendCTCP(const char *source, const char *dest, const char *buf) **/ void moduleAddAnopeCmds() { - pmodule_cmd_topic(rageircd_cmd_topic); - pmodule_SendVhostDel(rageircd_cmd_vhost_off); - pmodule_SendAkill(rageircd_cmd_akill); - pmodule_SendSVSKill(rageircd_SendSVSKill); - pmodule_SendSVSMode(rageircd_cmd_svsmode); - pmodule_cmd_372(rageircd_cmd_372); - pmodule_cmd_372_error(rageircd_cmd_372_error); - pmodule_cmd_375(rageircd_cmd_375); - pmodule_cmd_376(rageircd_cmd_376); - pmodule_cmd_nick(rageircd_cmd_nick); - pmodule_SendGuestNick(rageircd_cmd_guest_nick); - pmodule_SendMode(rageircd_cmd_mode); - pmodule_SendClientIntroduction(rageircd_cmd_bot_nick); - pmodule_SendKick(rageircd_cmd_kick); - pmodule_SendNoticeChanops(rageircd_cmd_notice_ops); - pmodule_cmd_notice(rageircd_cmd_notice); - pmodule_cmd_notice2(rageircd_cmd_notice2); - pmodule_cmd_privmsg(rageircd_cmd_privmsg); - pmodule_cmd_privmsg2(rageircd_cmd_privmsg2); - pmodule_SendGlobalNotice(rageircd_cmd_serv_notice); - pmodule_SendGlobalPrivmsg(rageircd_cmd_serv_privmsg); - pmodule_SendBotOp(rageircd_cmd_bot_chan_mode); - pmodule_cmd_351(rageircd_cmd_351); - pmodule_SendQuit(rageircd_cmd_quit); - pmodule_SendPong(rageircd_cmd_pong); - pmodule_SendJoin(rageircd_cmd_join); - pmodule_SendSQLineDel(rageircd_cmd_unsqline); - pmodule_SendInvite(rageircd_cmd_invite); - pmodule_SendPart(rageircd_cmd_part); - pmodule_cmd_391(rageircd_cmd_391); - pmodule_cmd_250(rageircd_cmd_250); - pmodule_cmd_307(rageircd_cmd_307); - pmodule_cmd_311(rageircd_cmd_311); - pmodule_cmd_312(rageircd_cmd_312); - pmodule_cmd_317(rageircd_cmd_317); - pmodule_cmd_219(rageircd_cmd_219); - pmodule_cmd_401(rageircd_cmd_401); - pmodule_cmd_318(rageircd_cmd_318); - pmodule_cmd_242(rageircd_cmd_242); - pmodule_cmd_243(rageircd_cmd_243); - pmodule_cmd_211(rageircd_cmd_211); - pmodule_SendGlobops(rageircd_cmd_global); - pmodule_SendGlobops_legacy(rageircd_cmd_global_legacy); - pmodule_SendSQLine(rageircd_cmd_sqline); - pmodule_SendSquit(rageircd_cmd_squit); - pmodule_SendSVSO(rageircd_cmd_svso); - pmodule_SendChangeBotNick(rageircd_cmd_chg_nick); - pmodule_SendForceNickChange(rageircd_cmd_svsnick); - pmodule_SendVhost(rageircd_cmd_vhost_on); - pmodule_SendConnect(rageircd_cmd_connect); - pmodule_SendSVSHOLD(rageircd_cmd_svshold); - pmodule_SendSVSHOLDDel(rageircd_cmd_release_svshold); - pmodule_SendSGLineDel(rageircd_cmd_unsgline); - pmodule_SendSZLineDel(rageircd_cmd_unszline); - pmodule_SendSZLine(rageircd_cmd_szline); - pmodule_SendSGLine(rageircd_cmd_sgline); - pmodule_SendBanDel(rageircd_cmd_unban); - pmodule_SendSVSMode_chan(rageircd_cmd_svsmode_chan); - pmodule_SendSVID(rageircd_cmd_svid_umode); - pmodule_SendUnregisteredNick(rageircd_cmd_nc_change); - pmodule_SendSVID2(rageircd_cmd_svid_umode2); - pmodule_SendSVID3(rageircd_cmd_svid_umode3); - pmodule_SendSVSJoin(rageircd_cmd_svsjoin); - pmodule_SendSVSPart(rageircd_cmd_svspart); - pmodule_SendSWhois(rageircd_cmd_swhois); - pmodule_SendEOB(rageircd_cmd_eob); - pmodule_IsFloodModeParamValid(rageircd_flood_mode_check); - pmodule_SendJupe(rageircd_cmd_jupe); - pmodule_IsNickValid(rageircd_valid_nick); - pmodule_IsChannelValid(rageircd_valid_chan); - pmodule_SendCTCP(rageircd_cmd_ctcp); - pmodule_ProcessUsermodes(rageircd_set_umode); + pmodule_cmd_topic(rageircd_cmd_topic); + pmodule_SendVhostDel(rageircd_cmd_vhost_off); + pmodule_SendAkill(rageircd_cmd_akill); + pmodule_SendSVSKill(rageircd_SendSVSKill); + pmodule_SendSVSMode(rageircd_cmd_svsmode); + pmodule_cmd_372(rageircd_cmd_372); + pmodule_cmd_372_error(rageircd_cmd_372_error); + pmodule_cmd_375(rageircd_cmd_375); + pmodule_cmd_376(rageircd_cmd_376); + pmodule_cmd_nick(rageircd_cmd_nick); + pmodule_SendGuestNick(rageircd_cmd_guest_nick); + pmodule_SendMode(rageircd_cmd_mode); + pmodule_SendClientIntroduction(rageircd_cmd_bot_nick); + pmodule_SendKick(rageircd_cmd_kick); + pmodule_SendNoticeChanops(rageircd_cmd_notice_ops); + pmodule_cmd_notice(rageircd_cmd_notice); + pmodule_cmd_notice2(rageircd_cmd_notice2); + pmodule_cmd_privmsg(rageircd_cmd_privmsg); + pmodule_cmd_privmsg2(rageircd_cmd_privmsg2); + pmodule_SendGlobalNotice(rageircd_cmd_serv_notice); + pmodule_SendGlobalPrivmsg(rageircd_cmd_serv_privmsg); + pmodule_SendBotOp(rageircd_cmd_bot_chan_mode); + pmodule_cmd_351(rageircd_cmd_351); + pmodule_SendQuit(rageircd_cmd_quit); + pmodule_SendPong(rageircd_cmd_pong); + pmodule_SendJoin(rageircd_cmd_join); + pmodule_SendSQLineDel(rageircd_cmd_unsqline); + pmodule_SendInvite(rageircd_cmd_invite); + pmodule_SendPart(rageircd_cmd_part); + pmodule_cmd_391(rageircd_cmd_391); + pmodule_cmd_250(rageircd_cmd_250); + pmodule_cmd_307(rageircd_cmd_307); + pmodule_cmd_311(rageircd_cmd_311); + pmodule_cmd_312(rageircd_cmd_312); + pmodule_cmd_317(rageircd_cmd_317); + pmodule_cmd_219(rageircd_cmd_219); + pmodule_cmd_401(rageircd_cmd_401); + pmodule_cmd_318(rageircd_cmd_318); + pmodule_cmd_242(rageircd_cmd_242); + pmodule_cmd_243(rageircd_cmd_243); + pmodule_cmd_211(rageircd_cmd_211); + pmodule_SendGlobops(rageircd_cmd_global); + pmodule_SendGlobops_legacy(rageircd_cmd_global_legacy); + pmodule_SendSQLine(rageircd_cmd_sqline); + pmodule_SendSquit(rageircd_cmd_squit); + pmodule_SendSVSO(rageircd_cmd_svso); + pmodule_SendChangeBotNick(rageircd_cmd_chg_nick); + pmodule_SendForceNickChange(rageircd_cmd_svsnick); + pmodule_SendVhost(rageircd_cmd_vhost_on); + pmodule_SendConnect(rageircd_cmd_connect); + pmodule_SendSVSHOLD(rageircd_cmd_svshold); + pmodule_SendSVSHOLDDel(rageircd_cmd_release_svshold); + pmodule_SendSGLineDel(rageircd_cmd_unsgline); + pmodule_SendSZLineDel(rageircd_cmd_unszline); + pmodule_SendSZLine(rageircd_cmd_szline); + pmodule_SendSGLine(rageircd_cmd_sgline); + pmodule_SendBanDel(rageircd_cmd_unban); + pmodule_SendSVSMode_chan(rageircd_cmd_svsmode_chan); + pmodule_SendSVID(rageircd_cmd_svid_umode); + pmodule_SendUnregisteredNick(rageircd_cmd_nc_change); + pmodule_SendSVID2(rageircd_cmd_svid_umode2); + pmodule_SendSVID3(rageircd_cmd_svid_umode3); + pmodule_SendSVSJoin(rageircd_cmd_svsjoin); + pmodule_SendSVSPart(rageircd_cmd_svspart); + pmodule_SendSWhois(rageircd_cmd_swhois); + pmodule_SendEOB(rageircd_cmd_eob); + pmodule_IsFloodModeParamValid(rageircd_flood_mode_check); + pmodule_SendJupe(rageircd_cmd_jupe); + pmodule_IsNickValid(rageircd_valid_nick); + pmodule_IsChannelValid(rageircd_valid_chan); + pmodule_SendCTCP(rageircd_cmd_ctcp); + pmodule_ProcessUsermodes(rageircd_set_umode); } /** @@ -1642,37 +1642,37 @@ void moduleAddAnopeCmds() int AnopeInit(int argc, char **argv) { - this->SetAuthor("Anope"); - this->SetVersion - ("$Id$"); - this->SetType(PROTOCOL); - - pmodule_ircd_version("RageIRCd 2.0.x"); - pmodule_ircd_cap(myIrcdcap); - pmodule_ircd_var(myIrcd); - pmodule_ircd_cbmodeinfos(myCbmodeinfos); - pmodule_ircd_cumodes(myCumodes); - pmodule_ircd_flood_mode_char_set(""); - pmodule_ircd_flood_mode_char_remove(""); - pmodule_ircd_cbmodes(myCbmodes); - pmodule_ircd_cmmodes(myCmmodes); - pmodule_ircd_csmodes(myCsmodes); - pmodule_ircd_useTSMode(1); - - /** Deal with modes anope _needs_ to know **/ - pmodule_invis_umode(UMODE_i); - pmodule_oper_umode(UMODE_o); - pmodule_invite_cmode(CMODE_i); - pmodule_secret_cmode(CMODE_s); - pmodule_private_cmode(CMODE_p); - pmodule_key_mode(CMODE_k); - pmodule_limit_mode(CMODE_l); - - moduleAddAnopeCmds(); + this->SetAuthor("Anope"); + this->SetVersion + ("$Id$"); + this->SetType(PROTOCOL); + + pmodule_ircd_version("RageIRCd 2.0.x"); + pmodule_ircd_cap(myIrcdcap); + pmodule_ircd_var(myIrcd); + pmodule_ircd_cbmodeinfos(myCbmodeinfos); + pmodule_ircd_cumodes(myCumodes); + pmodule_ircd_flood_mode_char_set(""); + pmodule_ircd_flood_mode_char_remove(""); + pmodule_ircd_cbmodes(myCbmodes); + pmodule_ircd_cmmodes(myCmmodes); + pmodule_ircd_csmodes(myCsmodes); + pmodule_ircd_useTSMode(1); + + /** Deal with modes anope _needs_ to know **/ + pmodule_invis_umode(UMODE_i); + pmodule_oper_umode(UMODE_o); + pmodule_invite_cmode(CMODE_i); + pmodule_secret_cmode(CMODE_s); + pmodule_private_cmode(CMODE_p); + pmodule_key_mode(CMODE_k); + pmodule_limit_mode(CMODE_l); + + moduleAddAnopeCmds(); pmodule_ircd_proto(&ircd_proto); - moduleAddIRCDMsgs(); + moduleAddIRCDMsgs(); - return MOD_CONT; + return MOD_CONT; } /* EOF */ diff --git a/src/protocol/obsolete/rageircd.h b/src/protocol/obsolete/rageircd.h index 12aab63dc..a20fedf30 100644 --- a/src/protocol/obsolete/rageircd.h +++ b/src/protocol/obsolete/rageircd.h @@ -32,7 +32,7 @@ #define CMODE_R 0x00000100 /* Only identified users can join */ #define CMODE_r 0x00000200 /* Set for all registered channels */ #define CMODE_c 0x00000400 /* Colors can't be used */ -#define CMODE_M 0x00000800 /* Non-regged nicks can't send messages */ +#define CMODE_M 0x00000800 /* Non-regged nicks can't send messages */ #define CMODE_N 0x00001000 #define CMODE_S 0x00002000 #define CMODE_C 0x00004000 diff --git a/src/protocol/obsolete/solidircd.c b/src/protocol/obsolete/solidircd.c index d5947a4b4..b6a70462b 100644 --- a/src/protocol/obsolete/solidircd.c +++ b/src/protocol/obsolete/solidircd.c @@ -18,502 +18,502 @@ #include "solidircd.h" IRCDVar myIrcd[] = { - {"Solid-IRCd 3.4.*", /* ircd name */ - "+o", /* nickserv mode */ - "+o", /* chanserv mode */ - "+o", /* memoserv mode */ - "+o", /* hostserv mode */ - "+io", /* operserv mode */ - "+o", /* botserv mode */ - "+h", /* helpserv mode */ - "+i", /* Dev/Null mode */ - "+io", /* Global mode */ - "+o", /* nickserv alias mode */ - "+o", /* chanserv alias mode */ - "+o", /* memoserv alias mode */ - "+io", /* hostserv alias mode */ - "+io", /* operserv alias mode */ - "+o", /* botserv alias mode */ - "+h", /* helpserv alias mode */ - "+i", /* Dev/Null alias mode */ - "+io", /* Global alias mode */ - "+", /* Used by BotServ Bots */ - 2, /* Chan Max Symbols */ - "-cilmnpstOR", /* Modes to Remove */ - "+o", /* Channel Umode used by Botserv bots */ - 1, /* SVSNICK */ - 1, /* Vhost */ - 0, /* Has Owner */ - NULL, /* Mode to set for an owner */ - NULL, /* Mode to unset for an owner */ - NULL, /* Mode to set for chan admin */ - NULL, /* Mode to unset for chan admin */ - "+rd", /* Mode On Reg */ - NULL, /* Mode on ID for Roots */ - NULL, /* Mode on ID for Admins */ - NULL, /* Mode on ID for Opers */ - "-r+d", /* Mode on UnReg */ - "+d", /* Mode on Nick Change */ - 1, /* Supports SGlines */ - 1, /* Supports SQlines */ - 1, /* Supports SZlines */ - 1, /* Supports Halfop +h */ - 3, /* Number of server args */ - 0, /* Join 2 Set */ - 0, /* Join 2 Message */ - 1, /* Has exceptions +e */ - 0, /* TS Topic Forward */ - 0, /* TS Topci Backward */ - 0, /* Protected Umode */ - 0, /* Has Admin */ - 1, /* Chan SQlines */ - 1, /* Quit on Kill */ - 1, /* SVSMODE unban */ - 0, /* Has Protect */ - 0, /* Reverse */ - 1, /* Chan Reg */ - CMODE_r, /* Channel Mode */ - 0, /* vidents */ - 1, /* svshold */ - 1, /* time stamp on mode */ - 1, /* NICKIP */ - 0, /* O:LINE */ - 1, /* UMODE */ - 0, /* VHOST ON NICK */ - 0, /* Change RealName */ - 0, /* No Knock */ - 0, /* Admin Only */ - DEFAULT_MLOCK, /* Default MLOCK */ - UMODE_v, /* Vhost Mode */ - 1, /* +f */ - 0, /* +L */ - CMODE_j, /* Mode */ - 0, /* Mode */ - 1, - 1, /* No Knock requires +i */ - NULL, /* CAPAB Chan Modes */ - 0, /* We support TOKENS */ - 1, /* TOKENS are CASE inSensitive */ - 0, /* TIME STAMPS are BASE64 */ - 1, /* +I support */ - 0, /* SJOIN ban char */ - 0, /* SJOIN except char */ - 0, /* SJOIN invite char */ - 0, /* Can remove User Channel Modes with SVSMODE */ - 0, /* Sglines are not enforced until user reconnects */ - "v", /* vhost char */ - 0, /* ts6 */ - 1, /* support helper umode */ - 0, /* p10 */ - NULL, /* character set */ - 1, /* reports sync state */ - 0, /* CIDR channelbans */ - } - , - {NULL} + {"Solid-IRCd 3.4.*", /* ircd name */ + "+o", /* nickserv mode */ + "+o", /* chanserv mode */ + "+o", /* memoserv mode */ + "+o", /* hostserv mode */ + "+io", /* operserv mode */ + "+o", /* botserv mode */ + "+h", /* helpserv mode */ + "+i", /* Dev/Null mode */ + "+io", /* Global mode */ + "+o", /* nickserv alias mode */ + "+o", /* chanserv alias mode */ + "+o", /* memoserv alias mode */ + "+io", /* hostserv alias mode */ + "+io", /* operserv alias mode */ + "+o", /* botserv alias mode */ + "+h", /* helpserv alias mode */ + "+i", /* Dev/Null alias mode */ + "+io", /* Global alias mode */ + "+", /* Used by BotServ Bots */ + 2, /* Chan Max Symbols */ + "-cilmnpstOR", /* Modes to Remove */ + "+o", /* Channel Umode used by Botserv bots */ + 1, /* SVSNICK */ + 1, /* Vhost */ + 0, /* Has Owner */ + NULL, /* Mode to set for an owner */ + NULL, /* Mode to unset for an owner */ + NULL, /* Mode to set for chan admin */ + NULL, /* Mode to unset for chan admin */ + "+rd", /* Mode On Reg */ + NULL, /* Mode on ID for Roots */ + NULL, /* Mode on ID for Admins */ + NULL, /* Mode on ID for Opers */ + "-r+d", /* Mode on UnReg */ + "+d", /* Mode on Nick Change */ + 1, /* Supports SGlines */ + 1, /* Supports SQlines */ + 1, /* Supports SZlines */ + 1, /* Supports Halfop +h */ + 3, /* Number of server args */ + 0, /* Join 2 Set */ + 0, /* Join 2 Message */ + 1, /* Has exceptions +e */ + 0, /* TS Topic Forward */ + 0, /* TS Topci Backward */ + 0, /* Protected Umode */ + 0, /* Has Admin */ + 1, /* Chan SQlines */ + 1, /* Quit on Kill */ + 1, /* SVSMODE unban */ + 0, /* Has Protect */ + 0, /* Reverse */ + 1, /* Chan Reg */ + CMODE_r, /* Channel Mode */ + 0, /* vidents */ + 1, /* svshold */ + 1, /* time stamp on mode */ + 1, /* NICKIP */ + 0, /* O:LINE */ + 1, /* UMODE */ + 0, /* VHOST ON NICK */ + 0, /* Change RealName */ + 0, /* No Knock */ + 0, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + UMODE_v, /* Vhost Mode */ + 1, /* +f */ + 0, /* +L */ + CMODE_j, /* Mode */ + 0, /* Mode */ + 1, + 1, /* No Knock requires +i */ + NULL, /* CAPAB Chan Modes */ + 0, /* We support TOKENS */ + 1, /* TOKENS are CASE inSensitive */ + 0, /* TIME STAMPS are BASE64 */ + 1, /* +I support */ + 0, /* SJOIN ban char */ + 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ + 0, /* Can remove User Channel Modes with SVSMODE */ + 0, /* Sglines are not enforced until user reconnects */ + "v", /* vhost char */ + 0, /* ts6 */ + 1, /* support helper umode */ + 0, /* p10 */ + NULL, /* character set */ + 1, /* reports sync state */ + 0, /* CIDR channelbans */ + } + , + {NULL} }; IRCDCAPAB myIrcdcap[] = { - { - CAPAB_NOQUIT, /* NOQUIT */ - CAPAB_TSMODE, /* TSMODE */ - CAPAB_UNCONNECT, /* UNCONNECT */ - 0, /* NICKIP */ - 0, /* SJOIN */ - 0, /* ZIP */ - CAPAB_BURST, /* BURST */ - 0, /* TS5 */ - 0, /* TS3 */ - CAPAB_DKEY, /* DKEY */ - 0, /* PT4 */ - 0, /* SCS */ - 0, /* QS */ - 0, /* UID */ - 0, /* KNOCK */ - 0, /* CLIENT */ - 0, /* IPV6 */ - 0, /* SSJ5 */ - 0, /* SN2 */ - 0, /* TOKEN */ - 0, /* VHOST */ - 0, /* SSJ3 */ - 0, /* NICK2 */ - 0, /* UMODE2 */ - 0, /* VL */ - 0, /* TLKEXT */ - 0, /* DODKEY */ - CAPAB_DOZIP, /* DOZIP */ - 0, 0, 0} + { + CAPAB_NOQUIT, /* NOQUIT */ + CAPAB_TSMODE, /* TSMODE */ + CAPAB_UNCONNECT, /* UNCONNECT */ + 0, /* NICKIP */ + 0, /* SJOIN */ + 0, /* ZIP */ + CAPAB_BURST, /* BURST */ + 0, /* TS5 */ + 0, /* TS3 */ + CAPAB_DKEY, /* DKEY */ + 0, /* PT4 */ + 0, /* SCS */ + 0, /* QS */ + 0, /* UID */ + 0, /* KNOCK */ + 0, /* CLIENT */ + 0, /* IPV6 */ + 0, /* SSJ5 */ + 0, /* SN2 */ + 0, /* TOKEN */ + 0, /* VHOST */ + 0, /* SSJ3 */ + 0, /* NICK2 */ + 0, /* UMODE2 */ + 0, /* VL */ + 0, /* TLKEXT */ + 0, /* DODKEY */ + CAPAB_DOZIP, /* DOZIP */ + 0, 0, 0} }; void solidircd_ProcessUsermodes(User * user, int ac, const char **av) { - int add = 1; /* 1 if adding modes, 0 if deleting */ - const char *modes = av[0]; - - ac--; - - if (debug) - alog("debug: Changing mode for %s to %s", user->nick, modes); - - while (*modes) { - - /* This looks better, much better than "add ? (do_add) : (do_remove)". - * At least this is readable without paying much attention :) -GD - */ - if (add) - user->mode |= umodes[(int) *modes]; - else - user->mode &= ~umodes[(int) *modes]; - - switch (*modes++) { - case '+': - add = 1; - break; - case '-': - add = 0; - break; - case 'a': - if (UnRestrictSAdmin) { - break; - } - if (add && !is_services_admin(user)) { - common_svsmode(user, "-a", NULL); - user->mode &= ~UMODE_a; - } - break; - case 'd': - if (ac == 0) { - alog("user: umode +d with no parameter (?) for user %s", - user->nick); - break; - } - - ac--; - av++; - user->svid = strtoul(*av, NULL, 0); - break; - case 'o': - if (add) { - opcnt++; - - if (WallOper) - anope_SendGlobops(s_OperServ, - "\2%s\2 is now an IRC operator.", - user->nick); - display_news(user, NEWS_OPER); - - } else { - opcnt--; - } - break; - case 'r': - if (add && !nick_identified(user)) { - common_svsmode(user, "-r", NULL); - user->mode &= ~UMODE_r; - } - break; - case 'v': - update_host(user); - break; - } - } + int add = 1; /* 1 if adding modes, 0 if deleting */ + const char *modes = av[0]; + + ac--; + + if (debug) + alog("debug: Changing mode for %s to %s", user->nick, modes); + + while (*modes) { + + /* This looks better, much better than "add ? (do_add) : (do_remove)". + * At least this is readable without paying much attention :) -GD + */ + if (add) + user->mode |= umodes[(int) *modes]; + else + user->mode &= ~umodes[(int) *modes]; + + switch (*modes++) { + case '+': + add = 1; + break; + case '-': + add = 0; + break; + case 'a': + if (UnRestrictSAdmin) { + break; + } + if (add && !is_services_admin(user)) { + common_svsmode(user, "-a", NULL); + user->mode &= ~UMODE_a; + } + break; + case 'd': + if (ac == 0) { + alog("user: umode +d with no parameter (?) for user %s", + user->nick); + break; + } + + ac--; + av++; + user->svid = strtoul(*av, NULL, 0); + break; + case 'o': + if (add) { + opcnt++; + + if (WallOper) + anope_SendGlobops(s_OperServ, + "\2%s\2 is now an IRC operator.", + user->nick); + display_news(user, NEWS_OPER); + + } else { + opcnt--; + } + break; + case 'r': + if (add && !nick_identified(user)) { + common_svsmode(user, "-r", NULL); + user->mode &= ~UMODE_r; + } + break; + case 'v': + update_host(user); + break; + } + } } unsigned long umodes[128] = { - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused, Unused, Horzontal Tab */ - 0, 0, 0, /* Line Feed, Unused, Unused */ - 0, 0, 0, /* Carriage Return, Unused, Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused, Unused, Space */ - 0, 0, 0, /* ! " # */ - 0, 0, 0, /* $ % & */ - 0, 0, 0, /* ! ( ) */ - 0, 0, 0, /* * + , */ - 0, 0, 0, /* - . / */ - 0, 0, /* 0 1 */ - 0, 0, /* 2 3 */ - 0, 0, /* 4 5 */ - 0, 0, /* 6 7 */ - 0, 0, /* 8 9 */ - 0, 0, /* : ; */ - 0, 0, 0, /* < = > */ - 0, 0, /* ? @ */ - UMODE_A, 0, UMODE_C, /* A B C */ - UMODE_D, 0, UMODE_F, /* D E F */ - 0, UMODE_H, UMODE_I, /* G H I */ - 0, UMODE_K, 0, /* J K L */ - 0, 0, UMODE_O, /* M N O */ - 0, 0, UMODE_R, /* P Q R */ - 0, 0, 0, /* S T U */ - 0, 0, UMODE_X, /* V W X */ - 0, /* Y */ - 0, /* Z */ - 0, 0, 0, /* [ \ ] */ - 0, 0, 0, /* ^ _ ` */ - UMODE_a, UMODE_b, UMODE_c, /* a b c */ - UMODE_d, UMODE_e, UMODE_f, /* d e f */ - UMODE_g, UMODE_h, UMODE_i, /* g h i */ - UMODE_j, UMODE_k, 0, /* j k l */ - UMODE_m, UMODE_n, UMODE_o, /* m n o */ - 0, 0, UMODE_r, /* p q r */ - UMODE_s, 0, 0, /* s t u */ - UMODE_v, UMODE_w, UMODE_x, /* v w x */ - UMODE_y, /* y */ - UMODE_z, /* z */ - 0, 0, 0, /* { | } */ - 0, 0 /* ~ � */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused, Unused, Horzontal Tab */ + 0, 0, 0, /* Line Feed, Unused, Unused */ + 0, 0, 0, /* Carriage Return, Unused, Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused, Unused, Space */ + 0, 0, 0, /* ! " # */ + 0, 0, 0, /* $ % & */ + 0, 0, 0, /* ! ( ) */ + 0, 0, 0, /* * + , */ + 0, 0, 0, /* - . / */ + 0, 0, /* 0 1 */ + 0, 0, /* 2 3 */ + 0, 0, /* 4 5 */ + 0, 0, /* 6 7 */ + 0, 0, /* 8 9 */ + 0, 0, /* : ; */ + 0, 0, 0, /* < = > */ + 0, 0, /* ? @ */ + UMODE_A, 0, UMODE_C, /* A B C */ + UMODE_D, 0, UMODE_F, /* D E F */ + 0, UMODE_H, UMODE_I, /* G H I */ + 0, UMODE_K, 0, /* J K L */ + 0, 0, UMODE_O, /* M N O */ + 0, 0, UMODE_R, /* P Q R */ + 0, 0, 0, /* S T U */ + 0, 0, UMODE_X, /* V W X */ + 0, /* Y */ + 0, /* Z */ + 0, 0, 0, /* [ \ ] */ + 0, 0, 0, /* ^ _ ` */ + UMODE_a, UMODE_b, UMODE_c, /* a b c */ + UMODE_d, UMODE_e, UMODE_f, /* d e f */ + UMODE_g, UMODE_h, UMODE_i, /* g h i */ + UMODE_j, UMODE_k, 0, /* j k l */ + UMODE_m, UMODE_n, UMODE_o, /* m n o */ + 0, 0, UMODE_r, /* p q r */ + UMODE_s, 0, 0, /* s t u */ + UMODE_v, UMODE_w, UMODE_x, /* v w x */ + UMODE_y, /* y */ + UMODE_z, /* z */ + 0, 0, 0, /* { | } */ + 0, 0 /* ~ � */ }; char myCsmodes[128] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, 0, 0, - 'h', - 0, 0, 0, 0, - 0, + 0, + 0, + 0, 0, 0, + 'h', + 0, 0, 0, 0, + 0, - 'v', 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'v', 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; CMMode myCmmodes[128] = { - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, /* BCD */ - {NULL}, {NULL}, {NULL}, /* EFG */ - {NULL}, /* H */ - {add_invite, del_invite}, - {NULL}, /* J */ - {NULL}, {NULL}, {NULL}, /* KLM */ - {NULL}, {NULL}, {NULL}, /* NOP */ - {NULL}, {NULL}, {NULL}, /* QRS */ - {NULL}, {NULL}, {NULL}, /* TUV */ - {NULL}, {NULL}, {NULL}, /* WXY */ - {NULL}, /* Z */ - {NULL}, {NULL}, /* (char 91 - 92) */ - {NULL}, {NULL}, {NULL}, /* (char 93 - 95) */ - {NULL}, /* ` (char 96) */ - {NULL}, /* a (char 97) */ - {add_ban, del_ban}, - {NULL}, - {NULL}, - {add_exception, del_exception}, - {NULL}, - {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, /* BCD */ + {NULL}, {NULL}, {NULL}, /* EFG */ + {NULL}, /* H */ + {add_invite, del_invite}, + {NULL}, /* J */ + {NULL}, {NULL}, {NULL}, /* KLM */ + {NULL}, {NULL}, {NULL}, /* NOP */ + {NULL}, {NULL}, {NULL}, /* QRS */ + {NULL}, {NULL}, {NULL}, /* TUV */ + {NULL}, {NULL}, {NULL}, /* WXY */ + {NULL}, /* Z */ + {NULL}, {NULL}, /* (char 91 - 92) */ + {NULL}, {NULL}, {NULL}, /* (char 93 - 95) */ + {NULL}, /* ` (char 96) */ + {NULL}, /* a (char 97) */ + {add_ban, del_ban}, + {NULL}, + {NULL}, + {add_exception, del_exception}, + {NULL}, + {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} }; CBMode myCbmodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, - {0}, /* A */ - {0}, /* B */ - {0}, /* C */ - {0}, /* D */ - {0}, /* E */ - {0}, /* F */ - {0}, /* G */ - {0}, /* H */ - {0}, /* I */ - {0}, /* J */ - {0}, /* K */ - {0}, /* L */ - {CMODE_M, 0, NULL, NULL}, /* M */ - {CMODE_N, 0, NULL, NULL}, /* N */ - {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, - {0}, /* P */ - {0}, /* Q */ - {CMODE_R, 0, NULL, NULL}, /* R */ - {CMODE_S, 0, NULL, NULL}, /* S */ - {0}, /* T */ - {0}, /* U */ - {0}, /* V */ - {0}, /* W */ - {0}, /* X */ - {0}, /* Y */ - {0}, /* Z */ - {0}, {0}, {0}, {0}, {0}, {0}, - {0}, /* a */ - {0}, /* b */ - {CMODE_c, 0, NULL, NULL}, - {0}, /* d */ - {0}, /* e */ - {0}, /* f */ - {0}, /* g */ - {0}, /* h */ - {CMODE_i, 0, NULL, NULL}, - {CMODE_j, 0, set_flood, cs_set_flood}, /* j */ - {CMODE_k, 0, chan_set_key, cs_set_key}, - {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, - {CMODE_m, 0, NULL, NULL}, - {CMODE_n, 0, NULL, NULL}, - {0}, /* o */ - {CMODE_p, 0, NULL, NULL}, - {0}, /* q */ - {CMODE_r, CBM_NO_MLOCK, NULL, NULL}, - {CMODE_s, 0, NULL, NULL}, - {CMODE_t, 0, NULL, NULL}, - {0}, - {0}, /* v */ - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {0}, /* z */ - {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, + {0}, /* A */ + {0}, /* B */ + {0}, /* C */ + {0}, /* D */ + {0}, /* E */ + {0}, /* F */ + {0}, /* G */ + {0}, /* H */ + {0}, /* I */ + {0}, /* J */ + {0}, /* K */ + {0}, /* L */ + {CMODE_M, 0, NULL, NULL}, /* M */ + {CMODE_N, 0, NULL, NULL}, /* N */ + {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* P */ + {0}, /* Q */ + {CMODE_R, 0, NULL, NULL}, /* R */ + {CMODE_S, 0, NULL, NULL}, /* S */ + {0}, /* T */ + {0}, /* U */ + {0}, /* V */ + {0}, /* W */ + {0}, /* X */ + {0}, /* Y */ + {0}, /* Z */ + {0}, {0}, {0}, {0}, {0}, {0}, + {0}, /* a */ + {0}, /* b */ + {CMODE_c, 0, NULL, NULL}, + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {0}, /* h */ + {CMODE_i, 0, NULL, NULL}, + {CMODE_j, 0, set_flood, cs_set_flood}, /* j */ + {CMODE_k, 0, chan_set_key, cs_set_key}, + {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, + {CMODE_m, 0, NULL, NULL}, + {CMODE_n, 0, NULL, NULL}, + {0}, /* o */ + {CMODE_p, 0, NULL, NULL}, + {0}, /* q */ + {CMODE_r, CBM_NO_MLOCK, NULL, NULL}, + {CMODE_s, 0, NULL, NULL}, + {CMODE_t, 0, NULL, NULL}, + {0}, + {0}, /* v */ + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0} }; CBModeInfo myCbmodeinfos[] = { - {'c', CMODE_c, 0, NULL, NULL}, - {'i', CMODE_i, 0, NULL, NULL}, - {'j', CMODE_j, 0, get_flood, cs_get_flood}, - {'k', CMODE_k, 0, get_key, cs_get_key}, - {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, - {'m', CMODE_m, 0, NULL, NULL}, - {'n', CMODE_n, 0, NULL, NULL}, - {'p', CMODE_p, 0, NULL, NULL}, - {'r', CMODE_r, 0, NULL, NULL}, - {'s', CMODE_s, 0, NULL, NULL}, - {'t', CMODE_t, 0, NULL, NULL}, - {'M', CMODE_M, 0, NULL, NULL}, - {'O', CMODE_O, 0, NULL, NULL}, - {'R', CMODE_R, 0, NULL, NULL}, - {'N', CMODE_N, 0, NULL, NULL}, - {'S', CMODE_S, 0, NULL, NULL}, - {0} + {'c', CMODE_c, 0, NULL, NULL}, + {'i', CMODE_i, 0, NULL, NULL}, + {'j', CMODE_j, 0, get_flood, cs_get_flood}, + {'k', CMODE_k, 0, get_key, cs_get_key}, + {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, + {'m', CMODE_m, 0, NULL, NULL}, + {'n', CMODE_n, 0, NULL, NULL}, + {'p', CMODE_p, 0, NULL, NULL}, + {'r', CMODE_r, 0, NULL, NULL}, + {'s', CMODE_s, 0, NULL, NULL}, + {'t', CMODE_t, 0, NULL, NULL}, + {'M', CMODE_M, 0, NULL, NULL}, + {'O', CMODE_O, 0, NULL, NULL}, + {'R', CMODE_R, 0, NULL, NULL}, + {'N', CMODE_N, 0, NULL, NULL}, + {'S', CMODE_S, 0, NULL, NULL}, + {0} }; CUMode myCumodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, - - {0}, /* a */ - {0}, /* b */ - {0}, /* c */ - {0}, /* d */ - {0}, /* e */ - {0}, /* f */ - {0}, /* g */ - {CUS_HALFOP, 0, check_valid_op}, - {0}, /* i */ - {0}, /* j */ - {0}, /* k */ - {0}, /* l */ - {0}, /* m */ - {0}, /* n */ - {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, - {0}, /* p */ - {0}, /* q */ - {0}, /* r */ - {0}, /* s */ - {0}, /* t */ - {0}, /* u */ - {CUS_VOICE, 0, NULL}, /* v */ - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {0}, /* z */ - {0}, {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, + + {0}, /* a */ + {0}, /* b */ + {0}, /* c */ + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {CUS_HALFOP, 0, check_valid_op}, + {0}, /* i */ + {0}, /* j */ + {0}, /* k */ + {0}, /* l */ + {0}, /* m */ + {0}, /* n */ + {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, + {0}, /* p */ + {0}, /* q */ + {0}, /* r */ + {0}, /* s */ + {0}, /* t */ + {0}, /* u */ + {CUS_VOICE, 0, NULL}, /* v */ + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0}, {0} }; void solidircd_SendMode(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - if (ircdcap->tsmode) { - if (uplink_capab & ircdcap->tsmode) { - send_cmd(source, "MODE %s 0 %s", dest, buf); - } else { - send_cmd(source, "MODE %s %s", dest, buf); - } - } else { - send_cmd(source, "MODE %s %s", dest, buf); - } + if (ircdcap->tsmode) { + if (uplink_capab & ircdcap->tsmode) { + send_cmd(source, "MODE %s 0 %s", dest, buf); + } else { + send_cmd(source, "MODE %s %s", dest, buf); + } + } else { + send_cmd(source, "MODE %s %s", dest, buf); + } } /* SVSHOLD - set */ void solidircd_SendSVSHOLD(const char *nick) { - send_cmd(ServerName, "SVSHOLD %s %d :%s", nick, NSReleaseTimeout, - "Being held for registered user"); + send_cmd(ServerName, "SVSHOLD %s %d :%s", nick, NSReleaseTimeout, + "Being held for registered user"); } /* SVSHOLD - release */ void solidircd_SendSVSHOLDDel(const char *nick) { - send_cmd(ServerName, "SVSHOLD %s 0", nick); + send_cmd(ServerName, "SVSHOLD %s 0", nick); } /* SVSMODE -b */ void solidircd_SendBanDel(const char *name, const char *nick) { - solidircd_SendSVSMode_chan(name, "-b", nick); + solidircd_SendSVSMode_chan(name, "-b", nick); } @@ -521,186 +521,186 @@ void solidircd_SendBanDel(const char *name, const char *nick) void solidircd_SendSVSMode_chan(const char *name, const char *mode, const char *nick) { - if (nick) { - send_cmd(ServerName, "SVSMODE %s %s %s", name, mode, nick); - } else { - send_cmd(ServerName, "SVSMODE %s %s", name, mode); - } + if (nick) { + send_cmd(ServerName, "SVSMODE %s %s %s", name, mode, nick); + } else { + send_cmd(ServerName, "SVSMODE %s %s", name, mode); + } } void solidircd_SendBotOp(const char *nick, const char *chan) { - anope_SendMode(nick, chan, "%s %s", ircd->botchanumode, nick); + anope_SendMode(nick, chan, "%s %s", ircd->botchanumode, nick); } /* EVENT: SJOIN */ int anope_event_sjoin(const char *source, int ac, const char **av) { - do_sjoin(source, ac, av); - return MOD_CONT; + do_sjoin(source, ac, av); + return MOD_CONT; } /* ** NICK - new -** source = NULL +** source = NULL ** parv[0] = nickname -** parv[1] = hopcount -** parv[2] = timestamp -** parv[3] = modes -** parv[4] = username -** parv[5] = hostname -** parv[6] = server +** parv[1] = hopcount +** parv[2] = timestamp +** parv[3] = modes +** parv[4] = username +** parv[5] = hostname +** parv[6] = server ** parv[7] = servicestamp -** parv[8] = IP +** parv[8] = IP ** parv[9] = info ** NICK - change -** source = oldnick +** source = oldnick ** parv[0] = new nickname -** parv[1] = hopcount +** parv[1] = hopcount */ int anope_event_nick(const char *source, int ac, const char **av) { - User *user; + User *user; - if (ac != 2) { - user = do_nick(source, av[0], av[4], av[5], av[6], av[9], - strtoul(av[2], NULL, 10), strtoul(av[7], NULL, 0), - strtoul(av[8], NULL, 0), NULL, NULL); - if (user) { - anope_ProcessUsermodes(user, 1, &av[3]); - } - } else { - do_nick(source, av[0], NULL, NULL, NULL, NULL, - strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); - } - return MOD_CONT; + if (ac != 2) { + user = do_nick(source, av[0], av[4], av[5], av[6], av[9], + strtoul(av[2], NULL, 10), strtoul(av[7], NULL, 0), + strtoul(av[8], NULL, 0), NULL, NULL); + if (user) { + anope_ProcessUsermodes(user, 1, &av[3]); + } + } else { + do_nick(source, av[0], NULL, NULL, NULL, NULL, + strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); + } + return MOD_CONT; } /* EVENT : CAPAB */ int anope_event_capab(const char *source, int ac, const char **av) { - capab_parse(ac, av); - return MOD_CONT; + capab_parse(ac, av); + return MOD_CONT; } /* EVENT : OS */ int anope_event_os(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_OperServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_OperServ, av[0]); + return MOD_CONT; } /* EVENT : NS */ int anope_event_ns(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_NickServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_NickServ, av[0]); + return MOD_CONT; } /* EVENT : MS */ int anope_event_ms(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_MemoServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_MemoServ, av[0]); + return MOD_CONT; } /* EVENT : HS */ int anope_event_hs(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_HostServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_HostServ, av[0]); + return MOD_CONT; } /* EVENT : CS */ int anope_event_cs(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_ChanServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_ChanServ, av[0]); + return MOD_CONT; } int anope_event_436(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; + if (ac < 1) + return MOD_CONT; - m_nickcoll(av[0]); - return MOD_CONT; + m_nickcoll(av[0]); + return MOD_CONT; } /* *INDENT-OFF* */ void moduleAddIRCDMsgs(void) { - Message *m; - - updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+","-"); - - m = createMessage("401", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("402", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); - m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); - m = createMessage("INVITE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); - m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); - m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); - m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); - m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); - m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); - m = createMessage("NOTICE", anope_event_notice); addCoreMessage(IRCD,m); - m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); - m = createMessage("PASS", anope_event_pass); addCoreMessage(IRCD,m); - m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); - m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); - m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); - m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); - m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); - m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); - m = createMessage("USER", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("WALLOPS", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); - m = createMessage("AKILL", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("GLOBOPS", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("GNOTICE", anope_event_gnotice); addCoreMessage(IRCD,m); - m = createMessage("GOPER", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("RAKILL", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SILENCE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SVSKILL", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SVSMODE", anope_event_mode); addCoreMessage(IRCD,m); - m = createMessage("SVSNICK", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SVSNOOP", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SQLINE", anope_event_sqline); addCoreMessage(IRCD,m); - m = createMessage("UNSQLINE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); - m = createMessage("CS", anope_event_cs); addCoreMessage(IRCD,m); - m = createMessage("HS", anope_event_hs); addCoreMessage(IRCD,m); - m = createMessage("MS", anope_event_ms); addCoreMessage(IRCD,m); - m = createMessage("NS", anope_event_ns); addCoreMessage(IRCD,m); - m = createMessage("OS", anope_event_os); addCoreMessage(IRCD,m); - m = createMessage("RS", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SGLINE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); - m = createMessage("SS", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SVINFO", anope_event_svinfo); addCoreMessage(IRCD,m); - m = createMessage("SZLINE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("UNSGLINE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("UNSZLINE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m); - m = createMessage("LUSERSLOCK",anope_event_luserslock); addCoreMessage(IRCD,m); - m = createMessage("BURST", anope_event_burst); addCoreMessage(IRCD,m); - m = createMessage("ADMIN", anope_event_admin); addCoreMessage(IRCD,m); - m = createMessage("SVHOST", anope_event_vs); addCoreMessage(IRCD,m); - m = createMessage("ELMER", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SILLY", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SHUN", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("NORMAL", anope_event_null); addCoreMessage(IRCD,m); + Message *m; + + updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+","-"); + + m = createMessage("401", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("402", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); + m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); + m = createMessage("INVITE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); + m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); + m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); + m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); + m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("NOTICE", anope_event_notice); addCoreMessage(IRCD,m); + m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); + m = createMessage("PASS", anope_event_pass); addCoreMessage(IRCD,m); + m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); + m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); + m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); + m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); + m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); + m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); + m = createMessage("USER", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("WALLOPS", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); + m = createMessage("AKILL", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("GLOBOPS", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("GNOTICE", anope_event_gnotice); addCoreMessage(IRCD,m); + m = createMessage("GOPER", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("RAKILL", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SILENCE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SVSKILL", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SVSMODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("SVSNICK", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SVSNOOP", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SQLINE", anope_event_sqline); addCoreMessage(IRCD,m); + m = createMessage("UNSQLINE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); + m = createMessage("CS", anope_event_cs); addCoreMessage(IRCD,m); + m = createMessage("HS", anope_event_hs); addCoreMessage(IRCD,m); + m = createMessage("MS", anope_event_ms); addCoreMessage(IRCD,m); + m = createMessage("NS", anope_event_ns); addCoreMessage(IRCD,m); + m = createMessage("OS", anope_event_os); addCoreMessage(IRCD,m); + m = createMessage("RS", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SGLINE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); + m = createMessage("SS", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SVINFO", anope_event_svinfo); addCoreMessage(IRCD,m); + m = createMessage("SZLINE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("UNSGLINE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("UNSZLINE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m); + m = createMessage("LUSERSLOCK",anope_event_luserslock); addCoreMessage(IRCD,m); + m = createMessage("BURST", anope_event_burst); addCoreMessage(IRCD,m); + m = createMessage("ADMIN", anope_event_admin); addCoreMessage(IRCD,m); + m = createMessage("SVHOST", anope_event_vs); addCoreMessage(IRCD,m); + m = createMessage("ELMER", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SILLY", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SHUN", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("NORMAL", anope_event_null); addCoreMessage(IRCD,m); } /* *INDENT-ON* */ @@ -708,50 +708,50 @@ void moduleAddIRCDMsgs(void) { int anope_event_vs(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - u = finduser(av[0]); - if (!u) { - if (debug) { - alog("debug: SVHOST for nonexistent user %s", av[0]); - } - return MOD_CONT; - } + u = finduser(av[0]); + if (!u) { + if (debug) { + alog("debug: SVHOST for nonexistent user %s", av[0]); + } + return MOD_CONT; + } - u->SetDisplayedHost(av[1]); - return MOD_CONT; + u->SetDisplayedHost(av[1]); + return MOD_CONT; } /* SQLINE */ void solidircd_SendSQLine(const char *mask, const char *reason) { - if (!mask || !reason) { - return; - } + if (!mask || !reason) { + return; + } - send_cmd(NULL, "SQLINE %s :%s", mask, reason); + send_cmd(NULL, "SQLINE %s :%s", mask, reason); } /* UNSGLINE */ void solidircd_SendSGLineDel(const char *mask) { - send_cmd(NULL, "UNSGLINE 0 :%s", mask); + send_cmd(NULL, "UNSGLINE 0 :%s", mask); } /* UNSZLINE */ void solidircd_SendSZLineDel(const char *mask) { - send_cmd(NULL, "UNSZLINE 0 %s", mask); + send_cmd(NULL, "UNSZLINE 0 %s", mask); } /* SZLINE */ void solidircd_SendSZLine(const char *mask, const char *reason, const char *whom) { - send_cmd(NULL, "SZLINE %s :%s", mask, reason); + send_cmd(NULL, "SZLINE %s :%s", mask, reason); } /* SVSNOOP */ @@ -768,7 +768,7 @@ void solidircd_cmd_svsadmin(const char *server, int set) /* SGLINE */ void solidircd_SendSGLine(const char *mask, const char *reason) { - send_cmd(NULL, "SGLINE %d :%s:%s", (int)strlen(mask), mask, reason); + send_cmd(NULL, "SGLINE %d :%s:%s", (int)strlen(mask), mask, reason); } /* RAKILL */ @@ -780,35 +780,35 @@ void SolidIRCdProto::SendAkillDel(const char *user, const char *host) /* PART */ void solidircd_SendPart(const char *nick, const char *chan, const char *buf) { - if (!nick || !chan) { - return; - } + if (!nick || !chan) { + return; + } - if (buf) { - send_cmd(nick, "PART %s :%s", chan, buf); - } else { - send_cmd(nick, "PART %s", chan); - } + if (buf) { + send_cmd(nick, "PART %s :%s", chan, buf); + } else { + send_cmd(nick, "PART %s", chan); + } } /* TOPIC */ void solidircd_cmd_topic(const char *whosets, const char *chan, const char *whosetit, - const char *topic, time_t when) + const char *topic, time_t when) { - send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit, - (unsigned long int) when, topic); + send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit, + (unsigned long int) when, topic); } /* UNSQLINE */ void solidircd_SendSQLineDel(const char *user) { - send_cmd(NULL, "UNSQLINE %s", user); + send_cmd(NULL, "UNSQLINE %s", user); } /* JOIN - SJOIN */ void solidircd_SendJoin(const char *user, const char *channel, time_t chantime) { - send_cmd(user, "SJOIN %ld %s", (long int) chantime, channel); + send_cmd(user, "SJOIN %ld %s", (long int) chantime, channel); } /* AKILL */ @@ -820,10 +820,10 @@ void solidircd_SendJoin(const char *user, const char *channel, time_t chantime) * parv[6]=reason */ void solidircd_SendAkill(const char *user, const char *host, const char *who, time_t when, - time_t expires, const char *reason) + time_t expires, const char *reason) { - send_cmd(NULL, "AKILL %s %s %d %s %ld :%s", host, user, 86400 * 2, who, - (long int) time(NULL), reason); + send_cmd(NULL, "AKILL %s %s %d %s %ld :%s", host, user, 86400 * 2, who, + (long int) time(NULL), reason); } /* SVSKILL */ @@ -838,11 +838,11 @@ void solidircd_SendAkill(const char *user, const char *host, const char *who, ti void solidircd_SendSVSKill(const char *source, const char *user, const char *buf) { - if (!source || !user || !buf) { - return; - } + if (!source || !user || !buf) { + return; + } - send_cmd(source, "SVSKILL %s :%s", user, buf); + send_cmd(source, "SVSKILL %s :%s", user, buf); } /* SVSMODE */ @@ -854,492 +854,492 @@ void solidircd_SendSVSKill(const char *source, const char *user, const char *buf */ void solidircd_SendSVSMode(User * u, int ac, const char **av) { - send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick, - (long int) u->timestamp, av[0], (ac == 2 ? " " : ""), - (ac == 2 ? av[1] : "")); + send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick, + (long int) u->timestamp, av[0], (ac == 2 ? " " : ""), + (ac == 2 ? av[1] : "")); } /* SQUIT */ /* - * parv[0] = sender prefix - * parv[1] = server name - * parv[2] = comment + * parv[0] = sender prefix + * parv[1] = server name + * parv[2] = comment */ void solidircd_SendSquit(const char *servname, const char *message) { - send_cmd(NULL, "SQUIT %s :%s", servname, message); + send_cmd(NULL, "SQUIT %s :%s", servname, message); } /* PONG */ void solidircd_SendPong(const char *servname, const char *who) { - send_cmd(servname, "PONG %s", who); + send_cmd(servname, "PONG %s", who); } void solidircd_cmd_burst() { - send_cmd(NULL, "BURST"); + send_cmd(NULL, "BURST"); } /* * SVINFO - * parv[0] = sender prefix - * parv[1] = TS_CURRENT for the server - * parv[2] = TS_MIN for the server - * parv[3] = server is standalone or connected to non-TS only - * parv[4] = server's idea of UTC time + * parv[0] = sender prefix + * parv[1] = TS_CURRENT for the server + * parv[2] = TS_MIN for the server + * parv[3] = server is standalone or connected to non-TS only + * parv[4] = server's idea of UTC time */ void solidircd_cmd_svinfo() { - send_cmd(NULL, "SVINFO 5 3 0 :%ld", (long int) time(NULL)); + send_cmd(NULL, "SVINFO 5 3 0 :%ld", (long int) time(NULL)); } /* PASS */ void solidircd_cmd_pass(const char *pass) { - send_cmd(NULL, "PASS %s :TS", pass); + send_cmd(NULL, "PASS %s :TS", pass); } /* SERVER */ void solidircd_SendServer(const char *servname, int hop, const char *descript) { - send_cmd(NULL, "SERVER %s %d :%s", servname, hop, ServerDesc); + send_cmd(NULL, "SERVER %s %d :%s", servname, hop, ServerDesc); } /* CAPAB */ void solidircd_cmd_capab() { - /* CAPAB SSJOIN NOQUIT BURST UNCONNECT ZIP NICKIP TSMODE */ - send_cmd(NULL, "CAPAB SSJOIN NOQUIT BURST UNCONNECT NICKIP TSMODE"); + /* CAPAB SSJOIN NOQUIT BURST UNCONNECT ZIP NICKIP TSMODE */ + send_cmd(NULL, "CAPAB SSJOIN NOQUIT BURST UNCONNECT NICKIP TSMODE"); } void solidircd_SendConnect(int servernum) { - me_server = - new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); - if (servernum == 1) { - solidircd_cmd_pass(RemotePassword); - } else if (servernum == 2) { - solidircd_cmd_pass(RemotePassword2); - } else if (servernum == 3) { - solidircd_cmd_pass(RemotePassword3); - } - solidircd_cmd_capab(); - solidircd_SendServer(ServerName, 1, ServerDesc); - solidircd_cmd_svinfo(); - solidircd_cmd_burst(); + if (servernum == 1) { + solidircd_cmd_pass(RemotePassword); + } else if (servernum == 2) { + solidircd_cmd_pass(RemotePassword2); + } else if (servernum == 3) { + solidircd_cmd_pass(RemotePassword3); + } + solidircd_cmd_capab(); + solidircd_SendServer(ServerName, 1, ServerDesc); + solidircd_cmd_svinfo(); + solidircd_cmd_burst(); } /* EVENT : SERVER */ int anope_event_server(const char *source, int ac, const char **av) { - char *uplink; + char *uplink; - if (!stricmp(av[1], "1")) { - uplink = sstrdup(av[0]); - } + if (!stricmp(av[1], "1")) { + uplink = sstrdup(av[0]); + } - do_server(source, av[0], av[1], av[2], NULL); - return MOD_CONT; + do_server(source, av[0], av[1], av[2], NULL); + return MOD_CONT; } /* EVENT : PRIVMSG */ int anope_event_privmsg(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; - m_privmsg(source, av[0], av[1]); - return MOD_CONT; + if (ac != 2) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; } /* EVENT : SVINFO */ /* - * parv[0] = sender prefix - * parv[1] = TS_CURRENT for the server - * parv[2] = TS_MIN for the server - * parv[3] = server is standalone or connected to non-TS only - * parv[4] = server's idea of UTC time + * parv[0] = sender prefix + * parv[1] = TS_CURRENT for the server + * parv[2] = TS_MIN for the server + * parv[3] = server is standalone or connected to non-TS only + * parv[4] = server's idea of UTC time */ int anope_event_svinfo(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_part(const char *source, int ac, const char **av) { - if (ac < 1 || ac > 2) - return MOD_CONT; - do_part(source, ac, av); - return MOD_CONT; + if (ac < 1 || ac > 2) + return MOD_CONT; + do_part(source, ac, av); + return MOD_CONT; } int anope_event_whois(const char *source, int ac, const char **av) { - if (source && ac >= 1) { - m_whois(source, av[0]); - } - return MOD_CONT; + if (source && ac >= 1) { + m_whois(source, av[0]); + } + return MOD_CONT; } int anope_event_topic(const char *source, int ac, const char **av) { - if (ac != 4) - return MOD_CONT; - do_topic(source, ac, av); - return MOD_CONT; + if (ac != 4) + return MOD_CONT; + do_topic(source, ac, av); + return MOD_CONT; } int anope_event_squit(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; - do_squit(source, ac, av); - return MOD_CONT; + if (ac != 2) + return MOD_CONT; + do_squit(source, ac, av); + return MOD_CONT; } int anope_event_quit(const char *source, int ac, const char **av) { - if (ac != 1) - return MOD_CONT; - do_quit(source, ac, av); - return MOD_CONT; + if (ac != 1) + return MOD_CONT; + do_quit(source, ac, av); + return MOD_CONT; } /* EVENT: MODE */ int anope_event_mode(const char *source, int ac, const char **av) { - if (ac < 2) - return MOD_CONT; + if (ac < 2) + return MOD_CONT; - if (*av[0] == '#' || *av[0] == '&') { - do_cmode(source, ac, av); - } else { - do_umode(source, ac, av); - } - return MOD_CONT; + if (*av[0] == '#' || *av[0] == '&') { + do_cmode(source, ac, av); + } else { + do_umode(source, ac, av); + } + return MOD_CONT; } /* EVENT: KILL */ int anope_event_kill(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - m_kill(av[0], av[1]); - return MOD_CONT; + m_kill(av[0], av[1]); + return MOD_CONT; } /* EVENT: KICK */ int anope_event_kick(const char *source, int ac, const char **av) { - if (ac != 3) - return MOD_CONT; - do_kick(source, ac, av); - return MOD_CONT; + if (ac != 3) + return MOD_CONT; + do_kick(source, ac, av); + return MOD_CONT; } /* EVENT: JOIN */ int anope_event_join(const char *source, int ac, const char **av) { - if (ac != 1) - return MOD_CONT; - do_join(source, ac, av); - return MOD_CONT; + if (ac != 1) + return MOD_CONT; + do_join(source, ac, av); + return MOD_CONT; } /* EVENT: MOTD */ int anope_event_motd(const char *source, int ac, const char **av) { - if (!source) { - return MOD_CONT; - } + if (!source) { + return MOD_CONT; + } - m_motd(source); - return MOD_CONT; + m_motd(source); + return MOD_CONT; } void solidircd_SendNoticeChanops(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } - send_cmd(NULL, "NOTICE @%s :%s", dest, buf); + if (!buf) { + return; + } + send_cmd(NULL, "NOTICE @%s :%s", dest, buf); } /* NOTICE */ void solidircd_cmd_notice(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - if (NSDefFlags & NI_MSG) { - solidircd_cmd_privmsg2(source, dest, buf); - } else { - send_cmd(source, "NOTICE %s :%s", dest, buf); - } + if (NSDefFlags & NI_MSG) { + solidircd_cmd_privmsg2(source, dest, buf); + } else { + send_cmd(source, "NOTICE %s :%s", dest, buf); + } } void solidircd_cmd_notice2(const char *source, const char *dest, const char *msg) { - send_cmd(source, "NOTICE %s :%s", dest, msg); + send_cmd(source, "NOTICE %s :%s", dest, msg); } void solidircd_cmd_privmsg(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(source, "PRIVMSG %s :%s", dest, buf); + send_cmd(source, "PRIVMSG %s :%s", dest, buf); } void solidircd_cmd_privmsg2(const char *source, const char *dest, const char *msg) { - send_cmd(source, "PRIVMSG %s :%s", dest, msg); + send_cmd(source, "PRIVMSG %s :%s", dest, msg); } void solidircd_SendGlobalNotice(const char *source, const char *dest, const char *msg) { - send_cmd(source, "NOTICE $%s :%s", dest, msg); + send_cmd(source, "NOTICE $%s :%s", dest, msg); } void solidircd_SendGlobalPrivmsg(const char *source, const char *dest, const char *msg) { - send_cmd(source, "PRIVMSG $%s :%s", dest, msg); + send_cmd(source, "PRIVMSG $%s :%s", dest, msg); } /* GLOBOPS */ void solidircd_SendGlobops(const char *source, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf); + send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf); } /* 391 */ void solidircd_cmd_391(const char *source, const char *timestr) { - if (!timestr) { - return; - } - send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr); + if (!timestr) { + return; + } + send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr); } /* 250 */ void solidircd_cmd_250(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "250 %s", buf); + send_cmd(NULL, "250 %s", buf); } /* 307 */ void solidircd_cmd_307(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "307 %s", buf); + send_cmd(ServerName, "307 %s", buf); } /* 311 */ void solidircd_cmd_311(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "311 %s", buf); + send_cmd(ServerName, "311 %s", buf); } /* 312 */ void solidircd_cmd_312(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "312 %s", buf); + send_cmd(ServerName, "312 %s", buf); } /* 317 */ void solidircd_cmd_317(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "317 %s", buf); + send_cmd(ServerName, "317 %s", buf); } /* 219 */ void solidircd_cmd_219(const char *source, const char *letter) { - if (!source) { - return; - } + if (!source) { + return; + } - if (letter) { - send_cmd(NULL, "219 %s %c :End of /STATS report.", source, - *letter); - } else { - send_cmd(NULL, "219 %s l :End of /STATS report.", source); - } + if (letter) { + send_cmd(NULL, "219 %s %c :End of /STATS report.", source, + *letter); + } else { + send_cmd(NULL, "219 %s l :End of /STATS report.", source); + } } /* 401 */ void solidircd_cmd_401(const char *source, const char *who) { - if (!source || !who) { - return; - } - send_cmd(ServerName, "401 %s %s :No such service.", source, who); + if (!source || !who) { + return; + } + send_cmd(ServerName, "401 %s %s :No such service.", source, who); } /* 318 */ void solidircd_cmd_318(const char *source, const char *who) { - if (!source || !who) { - return; - } + if (!source || !who) { + return; + } - send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who); + send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who); } /* 242 */ void solidircd_cmd_242(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "242 %s", buf); + send_cmd(NULL, "242 %s", buf); } /* 243 */ void solidircd_cmd_243(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "243 %s", buf); + send_cmd(NULL, "243 %s", buf); } /* 211 */ void solidircd_cmd_211(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "211 %s", buf); + send_cmd(NULL, "211 %s", buf); } void solidircd_cmd_nick(const char *nick, const char *name, const char *modes) { - EnforceQlinedNick(nick, NULL); - send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick, - (long int) time(NULL), modes, ServiceUser, ServiceHost, - ServerName, name); - solidircd_SendSQLine(nick, "Reserved for services"); + EnforceQlinedNick(nick, NULL); + send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick, + (long int) time(NULL), modes, ServiceUser, ServiceHost, + ServerName, name); + solidircd_SendSQLine(nick, "Reserved for services"); } void solidircd_SendKick(const char *source, const char *chan, const char *user, const char *buf) { - if (buf) { - send_cmd(source, "KICK %s %s :%s", chan, user, buf); - } else { - send_cmd(source, "KICK %s %s", chan, user); - } + if (buf) { + send_cmd(source, "KICK %s %s :%s", chan, user, buf); + } else { + send_cmd(source, "KICK %s %s", chan, user); + } } void solidircd_cmd_372(const char *source, const char *msg) { - send_cmd(ServerName, "372 %s :- %s", source, msg); + send_cmd(ServerName, "372 %s :- %s", source, msg); } void solidircd_cmd_372_error(const char *source) { - send_cmd(ServerName, "422 %s :- MOTD file not found! Please " - "contact your IRC administrator.", source); + send_cmd(ServerName, "422 %s :- MOTD file not found! Please " + "contact your IRC administrator.", source); } void solidircd_cmd_375(const char *source) { - send_cmd(ServerName, "375 %s :- %s Message of the Day", - source, ServerName); + send_cmd(ServerName, "375 %s :- %s Message of the Day", + source, ServerName); } void solidircd_cmd_376(const char *source) { - send_cmd(ServerName, "376 %s :End of /MOTD command.", source); + send_cmd(ServerName, "376 %s :End of /MOTD command.", source); } /* INVITE */ void solidircd_SendInvite(const char *source, const char *chan, const char *nick) { - if (!source || !chan || !nick) { - return; - } + if (!source || !chan || !nick) { + return; + } - send_cmd(source, "INVITE %s %s", nick, chan); + send_cmd(source, "INVITE %s %s", nick, chan); } /* QUIT */ void solidircd_SendQuit(const char *source, const char *buf) { - if (buf) { - send_cmd(source, "QUIT :%s", buf); - } else { - send_cmd(source, "QUIT"); - } + if (buf) { + send_cmd(source, "QUIT :%s", buf); + } else { + send_cmd(source, "QUIT"); + } } int anope_event_away(const char *source, int ac, const char **av) { - if (!source) { - return MOD_CONT; - } - m_away(source, (ac ? av[0] : NULL)); - return MOD_CONT; + if (!source) { + return MOD_CONT; + } + m_away(source, (ac ? av[0] : NULL)); + return MOD_CONT; } int anope_event_ping(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - solidircd_SendPong(ac > 1 ? av[1] : ServerName, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + solidircd_SendPong(ac > 1 ? av[1] : ServerName, av[0]); + return MOD_CONT; } void solidircd_cmd_351(const char *source) { - send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s (%s)-- %s", - source, version_number, ServerName, ircd->name, version_flags, - EncModule, version_build); + send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s (%s)-- %s", + source, version_number, ServerName, ircd->name, version_flags, + EncModule, version_build); } void solidircd_SendClientIntroduction(const char *nick, const char *user, const char *host, const char *real, - const char *modes) + const char *modes) { - EnforceQlinedNick(nick, s_BotServ); - send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick, - (long int) time(NULL), modes, user, host, ServerName, real); - solidircd_SendSQLine(nick, "Reserved for services"); + EnforceQlinedNick(nick, s_BotServ); + send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick, + (long int) time(NULL), modes, user, host, ServerName, real); + solidircd_SendSQLine(nick, "Reserved for services"); } /* SVSNICK */ @@ -1350,51 +1350,51 @@ void solidircd_SendClientIntroduction(const char *nick, const char *user, const */ void solidircd_SendForceNickChange(const char *source, const char *guest, time_t when) { - if (!source || !guest) { - return; - } - send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, (long int) when); + if (!source || !guest) { + return; + } + send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, (long int) when); } void solidircd_SendGuestNick(const char *nick, const char *user, const char *host, - const char *real, const char *modes) + const char *real, const char *modes) { - send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick, - (long int) time(NULL), modes, user, host, ServerName, real); + send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick, + (long int) time(NULL), modes, user, host, ServerName, real); } void solidircd_SendSVSO(const char *source, const char *nick, const char *flag) { - /* Not Supported by this IRCD */ + /* Not Supported by this IRCD */ } void solidircd_cmd_chghost(const char *nick, const char *vhost) { - if (!nick || !vhost) { - return; - } - send_cmd(ServerName, "SVHOST %s %s", nick, vhost); + if (!nick || !vhost) { + return; + } + send_cmd(ServerName, "SVHOST %s %s", nick, vhost); } void solidircd_SendVhost(const char *nick, const char *vIdent, const char *vhost) { - send_cmd(s_HostServ, "SVSMODE %s +v", nick); - solidircd_cmd_chghost(nick, vhost); + send_cmd(s_HostServ, "SVSMODE %s +v", nick); + solidircd_cmd_chghost(nick, vhost); } void solidircd_SendVhostDel(User * u) { - send_cmd(s_HostServ, "SVSMODE %s -v", u->nick); - notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar); + send_cmd(s_HostServ, "SVSMODE %s -v", u->nick); + notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar); } /* SVSMODE +d */ /* sent if svid is something weird */ void solidircd_SendSVID(const char *nick, time_t ts) { - send_cmd(ServerName, "SVSMODE %s %lu +d 1", nick, - (unsigned long int) ts); + send_cmd(ServerName, "SVSMODE %s %lu +d 1", nick, + (unsigned long int) ts); } @@ -1402,155 +1402,155 @@ void solidircd_SendSVID(const char *nick, time_t ts) /* nc_change was = 1, and there is no na->status */ void solidircd_SendUnregisteredNick(User * u) { - common_svsmode(u, "+d", "1"); + common_svsmode(u, "+d", "1"); } /* SVSMODE +d */ void solidircd_SendSVID2(User * u, const char *ts) { - /* not used by bahamut ircds */ + /* not used by bahamut ircds */ } void solidircd_SendSVID3(User * u, const char *ts) { - if (u->svid != u->timestamp) { - common_svsmode(u, "+rd", ts); - } else { - common_svsmode(u, "+r", NULL); - } + if (u->svid != u->timestamp) { + common_svsmode(u, "+rd", ts); + } else { + common_svsmode(u, "+r", NULL); + } } /* NICK <newnick> */ void solidircd_SendChangeBotNick(const char *oldnick, const char *newnick) { - if (!oldnick || !newnick) { - return; - } + if (!oldnick || !newnick) { + return; + } - send_cmd(oldnick, "NICK %s :%ld", newnick, (long int) time(NULL)); + send_cmd(oldnick, "NICK %s :%ld", newnick, (long int) time(NULL)); } int anope_event_error(const char *source, int ac, const char **av) { - if (ac >= 1) { - if (debug) { - alog("debug: %s", av[0]); - } - } - return MOD_CONT; + if (ac >= 1) { + if (debug) { + alog("debug: %s", av[0]); + } + } + return MOD_CONT; } int anope_event_notice(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_sqline(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_gnotice(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_pass(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } void solidircd_SendSVSJoin(const char *source, const char *nick, const char *chan, const char *param) { - /* Can not find any reference to these in Bahamut */ + /* Can not find any reference to these in Bahamut */ } void solidircd_SendSVSPart(const char *source, const char *nick, const char *chan) { - /* Can not find any reference to these in Bahamut */ + /* Can not find any reference to these in Bahamut */ } void solidircd_SendSWhois(const char *source, const char *who, const char *mask) { - /* not supported */ + /* not supported */ } void solidircd_SendEOB() { - send_cmd(NULL, "BURST 0"); + send_cmd(NULL, "BURST 0"); } int anope_event_burst(const char *source, int ac, const char **av) { - Server *s; - s = findserver(servlist, source); - if (!ac) { - /* for future use - start burst */ - } else { - /* If we found a server with the given source, that one just - * finished bursting. If there was no source, then our uplink - * server finished bursting. -GD - */ - if (!s && serv_uplink) - s = serv_uplink; - finish_sync(s, 1); - } - return MOD_CONT; + Server *s; + s = findserver(servlist, source); + if (!ac) { + /* for future use - start burst */ + } else { + /* If we found a server with the given source, that one just + * finished bursting. If there was no source, then our uplink + * server finished bursting. -GD + */ + if (!s && serv_uplink) + s = serv_uplink; + finish_sync(s, 1); + } + return MOD_CONT; } int anope_event_luserslock(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_rehash(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_credits(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_admin(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int solidircd_IsFloodModeParamValid(const char *value) { - char *dp, *end; + char *dp, *end; - if (value && *value != ':' - && (strtoul((*value == '*' ? value + 1 : value), &dp, 10) > 0) - && (*dp == ':') && (*(++dp) != 0) && (strtoul(dp, &end, 10) > 0) - && (*end == 0)) { - return 1; - } else { - return 0; - } + if (value && *value != ':' + && (strtoul((*value == '*' ? value + 1 : value), &dp, 10) > 0) + && (*dp == ':') && (*(++dp) != 0) && (strtoul(dp, &end, 10) > 0) + && (*end == 0)) { + return 1; + } else { + return 0; + } } void solidircd_SendJupe(const char *jserver, const char *who, const char *reason) { - char rbuf[256]; + char rbuf[256]; - snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who, - reason ? ": " : "", reason ? reason : ""); + snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who, + reason ? ": " : "", reason ? reason : ""); - if (findserver(servlist, jserver)) - solidircd_SendSquit(jserver, rbuf); - solidircd_SendServer(jserver, 2, rbuf); - new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL); + if (findserver(servlist, jserver)) + solidircd_SendSquit(jserver, rbuf); + solidircd_SendServer(jserver, 2, rbuf); + new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL); } /* GLOBOPS - to handle old WALLOPS */ void solidircd_SendGlobops_legacy(const char *source, const char *fmt) { - send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt); + send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt); } /* @@ -1559,8 +1559,8 @@ void solidircd_SendGlobops_legacy(const char *source, const char *fmt) */ int solidircd_IsNickValid(const char *nick) { - /* no hard coded invalid nicks */ - return 1; + /* no hard coded invalid nicks */ + return 1; } /* @@ -1569,23 +1569,23 @@ int solidircd_IsNickValid(const char *nick) */ int solidircd_IsChannelValid(const char *chan) { - /* no hard coded invalid chan*/ - return 1; + /* no hard coded invalid chan*/ + return 1; } void solidircd_SendCTCP(const char *source, const char *dest, const char *buf) { - char *s; + char *s; - if (!buf) { - return; - } else { - s = normalizeBuffer(buf); - } + if (!buf) { + return; + } else { + s = normalizeBuffer(buf); + } - send_cmd(source, "%s NOTICE :\1%s \1", dest, s); - free(s); + send_cmd(source, "%s NOTICE :\1%s \1", dest, s); + free(s); } @@ -1595,78 +1595,78 @@ void solidircd_SendCTCP(const char *source, const char *dest, const char *buf) **/ void moduleAddAnopeCmds() { - pmodule_cmd_topic(solidircd_cmd_topic); - pmodule_SendVhostDel(solidircd_cmd_vhost_off); - pmodule_SendAkill(solidircd_cmd_akill); - pmodule_SendSVSKill(solidircd_SendSVSKill); - pmodule_SendSVSMode(solidircd_cmd_svsmode); - pmodule_cmd_372(solidircd_cmd_372); - pmodule_cmd_372_error(solidircd_cmd_372_error); - pmodule_cmd_375(solidircd_cmd_375); - pmodule_cmd_376(solidircd_cmd_376); - pmodule_cmd_nick(solidircd_cmd_nick); - pmodule_SendGuestNick(solidircd_cmd_guest_nick); - pmodule_SendMode(solidircd_cmd_mode); - pmodule_SendClientIntroduction(solidircd_cmd_bot_nick); - pmodule_SendKick(solidircd_cmd_kick); - pmodule_SendNoticeChanops(solidircd_cmd_notice_ops); - pmodule_cmd_notice(solidircd_cmd_notice); - pmodule_cmd_notice2(solidircd_cmd_notice2); - pmodule_cmd_privmsg(solidircd_cmd_privmsg); - pmodule_cmd_privmsg2(solidircd_cmd_privmsg2); - pmodule_SendGlobalNotice(solidircd_cmd_serv_notice); - pmodule_SendGlobalPrivmsg(solidircd_cmd_serv_privmsg); - pmodule_SendBotOp(solidircd_cmd_bot_chan_mode); - pmodule_cmd_351(solidircd_cmd_351); - pmodule_SendQuit(solidircd_cmd_quit); - pmodule_SendPong(solidircd_cmd_pong); - pmodule_SendJoin(solidircd_cmd_join); - pmodule_SendSQLineDel(solidircd_cmd_unsqline); - pmodule_SendInvite(solidircd_cmd_invite); - pmodule_SendPart(solidircd_cmd_part); - pmodule_cmd_391(solidircd_cmd_391); - pmodule_cmd_250(solidircd_cmd_250); - pmodule_cmd_307(solidircd_cmd_307); - pmodule_cmd_311(solidircd_cmd_311); - pmodule_cmd_312(solidircd_cmd_312); - pmodule_cmd_317(solidircd_cmd_317); - pmodule_cmd_219(solidircd_cmd_219); - pmodule_cmd_401(solidircd_cmd_401); - pmodule_cmd_318(solidircd_cmd_318); - pmodule_cmd_242(solidircd_cmd_242); - pmodule_cmd_243(solidircd_cmd_243); - pmodule_cmd_211(solidircd_cmd_211); - pmodule_SendGlobops(solidircd_cmd_global); - pmodule_SendGlobops_legacy(solidircd_cmd_global_legacy); - pmodule_SendSQLine(solidircd_cmd_sqline); - pmodule_SendSquit(solidircd_cmd_squit); - pmodule_SendSVSO(solidircd_cmd_svso); - pmodule_SendChangeBotNick(solidircd_cmd_chg_nick); - pmodule_SendForceNickChange(solidircd_cmd_svsnick); - pmodule_SendVhost(solidircd_cmd_vhost_on); - pmodule_SendConnect(solidircd_cmd_connect); - pmodule_SendSVSHOLD(solidircd_cmd_svshold); - pmodule_SendSVSHOLDDel(solidircd_cmd_release_svshold); - pmodule_SendSGLineDel(solidircd_cmd_unsgline); - pmodule_SendSZLineDel(solidircd_cmd_unszline); - pmodule_SendSZLine(solidircd_cmd_szline); - pmodule_SendSGLine(solidircd_cmd_sgline); - pmodule_SendBanDel(solidircd_cmd_unban); - pmodule_SendSVSMode_chan(solidircd_cmd_svsmode_chan); - pmodule_SendSVID(solidircd_cmd_svid_umode); - pmodule_SendUnregisteredNick(solidircd_cmd_nc_change); - pmodule_SendSVID2(solidircd_cmd_svid_umode2); - pmodule_SendSVID3(solidircd_cmd_svid_umode3); - pmodule_SendSVSJoin(solidircd_cmd_svsjoin); - pmodule_SendSVSPart(solidircd_cmd_svspart); - pmodule_SendSWhois(solidircd_cmd_swhois); - pmodule_SendEOB(solidircd_cmd_eob); - pmodule_IsFloodModeParamValid(solidircd_flood_mode_check); - pmodule_SendJupe(solidircd_cmd_jupe); - pmodule_IsNickValid(solidircd_valid_nick); - pmodule_IsChannelValid(solidircd_valid_chan); - pmodule_SendCTCP(solidircd_cmd_ctcp); - pmodule_ProcessUsermodes(solidircd_set_umode); + pmodule_cmd_topic(solidircd_cmd_topic); + pmodule_SendVhostDel(solidircd_cmd_vhost_off); + pmodule_SendAkill(solidircd_cmd_akill); + pmodule_SendSVSKill(solidircd_SendSVSKill); + pmodule_SendSVSMode(solidircd_cmd_svsmode); + pmodule_cmd_372(solidircd_cmd_372); + pmodule_cmd_372_error(solidircd_cmd_372_error); + pmodule_cmd_375(solidircd_cmd_375); + pmodule_cmd_376(solidircd_cmd_376); + pmodule_cmd_nick(solidircd_cmd_nick); + pmodule_SendGuestNick(solidircd_cmd_guest_nick); + pmodule_SendMode(solidircd_cmd_mode); + pmodule_SendClientIntroduction(solidircd_cmd_bot_nick); + pmodule_SendKick(solidircd_cmd_kick); + pmodule_SendNoticeChanops(solidircd_cmd_notice_ops); + pmodule_cmd_notice(solidircd_cmd_notice); + pmodule_cmd_notice2(solidircd_cmd_notice2); + pmodule_cmd_privmsg(solidircd_cmd_privmsg); + pmodule_cmd_privmsg2(solidircd_cmd_privmsg2); + pmodule_SendGlobalNotice(solidircd_cmd_serv_notice); + pmodule_SendGlobalPrivmsg(solidircd_cmd_serv_privmsg); + pmodule_SendBotOp(solidircd_cmd_bot_chan_mode); + pmodule_cmd_351(solidircd_cmd_351); + pmodule_SendQuit(solidircd_cmd_quit); + pmodule_SendPong(solidircd_cmd_pong); + pmodule_SendJoin(solidircd_cmd_join); + pmodule_SendSQLineDel(solidircd_cmd_unsqline); + pmodule_SendInvite(solidircd_cmd_invite); + pmodule_SendPart(solidircd_cmd_part); + pmodule_cmd_391(solidircd_cmd_391); + pmodule_cmd_250(solidircd_cmd_250); + pmodule_cmd_307(solidircd_cmd_307); + pmodule_cmd_311(solidircd_cmd_311); + pmodule_cmd_312(solidircd_cmd_312); + pmodule_cmd_317(solidircd_cmd_317); + pmodule_cmd_219(solidircd_cmd_219); + pmodule_cmd_401(solidircd_cmd_401); + pmodule_cmd_318(solidircd_cmd_318); + pmodule_cmd_242(solidircd_cmd_242); + pmodule_cmd_243(solidircd_cmd_243); + pmodule_cmd_211(solidircd_cmd_211); + pmodule_SendGlobops(solidircd_cmd_global); + pmodule_SendGlobops_legacy(solidircd_cmd_global_legacy); + pmodule_SendSQLine(solidircd_cmd_sqline); + pmodule_SendSquit(solidircd_cmd_squit); + pmodule_SendSVSO(solidircd_cmd_svso); + pmodule_SendChangeBotNick(solidircd_cmd_chg_nick); + pmodule_SendForceNickChange(solidircd_cmd_svsnick); + pmodule_SendVhost(solidircd_cmd_vhost_on); + pmodule_SendConnect(solidircd_cmd_connect); + pmodule_SendSVSHOLD(solidircd_cmd_svshold); + pmodule_SendSVSHOLDDel(solidircd_cmd_release_svshold); + pmodule_SendSGLineDel(solidircd_cmd_unsgline); + pmodule_SendSZLineDel(solidircd_cmd_unszline); + pmodule_SendSZLine(solidircd_cmd_szline); + pmodule_SendSGLine(solidircd_cmd_sgline); + pmodule_SendBanDel(solidircd_cmd_unban); + pmodule_SendSVSMode_chan(solidircd_cmd_svsmode_chan); + pmodule_SendSVID(solidircd_cmd_svid_umode); + pmodule_SendUnregisteredNick(solidircd_cmd_nc_change); + pmodule_SendSVID2(solidircd_cmd_svid_umode2); + pmodule_SendSVID3(solidircd_cmd_svid_umode3); + pmodule_SendSVSJoin(solidircd_cmd_svsjoin); + pmodule_SendSVSPart(solidircd_cmd_svspart); + pmodule_SendSWhois(solidircd_cmd_swhois); + pmodule_SendEOB(solidircd_cmd_eob); + pmodule_IsFloodModeParamValid(solidircd_flood_mode_check); + pmodule_SendJupe(solidircd_cmd_jupe); + pmodule_IsNickValid(solidircd_valid_nick); + pmodule_IsChannelValid(solidircd_valid_chan); + pmodule_SendCTCP(solidircd_cmd_ctcp); + pmodule_ProcessUsermodes(solidircd_set_umode); } /** @@ -1675,35 +1675,35 @@ void moduleAddAnopeCmds() int AnopeInit(int argc, char **argv) { - this->SetAuthor("Anope"); - this->SetVersion - ("$Id$"); - this->SetType(PROTOCOL); - - pmodule_ircd_version("Solid-IRCd 3.4.*"); - pmodule_ircd_cap(myIrcdcap); - pmodule_ircd_var(myIrcd); - pmodule_ircd_cbmodeinfos(myCbmodeinfos); - pmodule_ircd_cumodes(myCumodes); - pmodule_ircd_flood_mode_char_set("+j"); - pmodule_ircd_flood_mode_char_remove("-j"); - pmodule_ircd_cbmodes(myCbmodes); - pmodule_ircd_cmmodes(myCmmodes); - pmodule_ircd_csmodes(myCsmodes); - pmodule_ircd_useTSMode(0); - - /** Deal with modes anope _needs_ to know **/ - pmodule_invis_umode(UMODE_i); - pmodule_oper_umode(UMODE_o); - pmodule_invite_cmode(CMODE_i); - pmodule_secret_cmode(CMODE_s); - pmodule_private_cmode(CMODE_p); - pmodule_key_mode(CMODE_k); - pmodule_limit_mode(CMODE_l); - - moduleAddAnopeCmds(); + this->SetAuthor("Anope"); + this->SetVersion + ("$Id$"); + this->SetType(PROTOCOL); + + pmodule_ircd_version("Solid-IRCd 3.4.*"); + pmodule_ircd_cap(myIrcdcap); + pmodule_ircd_var(myIrcd); + pmodule_ircd_cbmodeinfos(myCbmodeinfos); + pmodule_ircd_cumodes(myCumodes); + pmodule_ircd_flood_mode_char_set("+j"); + pmodule_ircd_flood_mode_char_remove("-j"); + pmodule_ircd_cbmodes(myCbmodes); + pmodule_ircd_cmmodes(myCmmodes); + pmodule_ircd_csmodes(myCsmodes); + pmodule_ircd_useTSMode(0); + + /** Deal with modes anope _needs_ to know **/ + pmodule_invis_umode(UMODE_i); + pmodule_oper_umode(UMODE_o); + pmodule_invite_cmode(CMODE_i); + pmodule_secret_cmode(CMODE_s); + pmodule_private_cmode(CMODE_p); + pmodule_key_mode(CMODE_k); + pmodule_limit_mode(CMODE_l); + + moduleAddAnopeCmds(); pmodule_ircd_proto(&ircd_proto); - moduleAddIRCDMsgs(); + moduleAddIRCDMsgs(); - return MOD_CONT; + return MOD_CONT; } diff --git a/src/protocol/obsolete/solidircd.h b/src/protocol/obsolete/solidircd.h index 23812ffc1..0644d17c2 100644 --- a/src/protocol/obsolete/solidircd.h +++ b/src/protocol/obsolete/solidircd.h @@ -56,10 +56,10 @@ #define CMODE_R 0x00000100 /* Only identified users can join */ #define CMODE_r 0x00000200 /* Set for all registered channels */ #define CMODE_c 0x00000400 /* Colors can't be used */ -#define CMODE_M 0x00000800 /* Non-regged nicks can't send messages */ -#define CMODE_j 0x00001000 /* join throttle */ -#define CMODE_S 0x00002000 /* SSL only */ -#define CMODE_N 0x00004000 /* No Nickname change */ +#define CMODE_M 0x00000800 /* Non-regged nicks can't send messages */ +#define CMODE_j 0x00001000 /* join throttle */ +#define CMODE_S 0x00002000 /* SSL only */ +#define CMODE_N 0x00004000 /* No Nickname change */ #define CMODE_O 0x00008000 /* Only opers can join */ diff --git a/src/protocol/obsolete/ultimate3.c b/src/protocol/obsolete/ultimate3.c index 7201096b7..92b83d7ab 100644 --- a/src/protocol/obsolete/ultimate3.c +++ b/src/protocol/obsolete/ultimate3.c @@ -16,468 +16,468 @@ #include "ultimate3.h" IRCDVar myIrcd[] = { - {"UltimateIRCd 3.0.*", /* ircd name */ - "+S", /* nickserv mode */ - "+S", /* chanserv mode */ - "+S", /* memoserv mode */ - "+o", /* hostserv mode */ - "+iS", /* operserv mode */ - "+S", /* botserv mode */ - "+Sh", /* helpserv mode */ - "+iS", /* Dev/Null mode */ - "+iS", /* Global mode */ - "+o", /* nickserv alias mode */ - "+o", /* chanserv alias mode */ - "+o", /* memoserv alias mode */ - "+io", /* hostserv alias mode */ - "+io", /* operserv alias mode */ - "+o", /* botserv alias mode */ - "+h", /* helpserv alias mode */ - "+i", /* Dev/Null alias mode */ - "+io", /* Global alias mode */ - "+S", /* Used by BotServ Bots */ - 5, /* Chan Max Symbols */ - "-ilmnpqstRKAO", /* Modes to Remove */ - "+o", /* Channel Umode used by Botserv bots */ - 1, /* SVSNICK */ - 1, /* Vhost */ - 0, /* Has Owner */ - NULL, /* Mode to set for an owner */ - NULL, /* Mode to unset for an owner */ - "+a", /* Mode to set for channel admin */ - "-a", /* Mode to unset for channel admin */ - "+rd", /* Mode On Reg */ - NULL, /* Mode on ID for Roots */ - NULL, /* Mode on ID for Admins */ - NULL, /* Mode on ID for Opers */ - "-r+d", /* Mode on UnReg */ - "+d", /* Mode on Nick Change */ - 1, /* Supports SGlines */ - 1, /* Supports SQlines */ - 1, /* Supports SZlines */ - 1, /* Supports Halfop +h */ - 3, /* Number of server args */ - 0, /* Join 2 Set */ - 0, /* Join 2 Message */ - 1, /* Has exceptions +e */ - 0, /* TS Topic Forward */ - 0, /* TS Topci Backward */ - UMODE_p, /* Protected Umode */ - 1, /* Has Admin */ - 1, /* Chan SQlines */ - 0, /* Quit on Kill */ - 1, /* SVSMODE unban */ - 0, /* Has Protect */ - 0, /* Reverse */ - 1, /* Chan Reg */ - CMODE_r, /* Channel Mode */ - 0, /* vidents */ - 0, /* svshold */ - 1, /* time stamp on mode */ - 1, /* NICKIP */ - 0, /* O:LINE */ - 1, /* UMODE */ - 1, /* VHOST ON NICK */ - 0, /* Change RealName */ - CMODE_K, /* No Knock */ - CMODE_A, /* Admin Only */ - DEFAULT_MLOCK, /* Default MLOCK */ - UMODE_x, /* Vhost Mode */ - 0, /* +f */ - 0, /* +L */ - 0, /* +f Mode */ - 0, /* +L Mode */ - 1, /* On nick change check if they could be identified */ - 1, /* No Knock requires +i */ - NULL, /* CAPAB Chan Modes */ - 0, /* We support TOKENS */ - 1, /* TOKENS are CASE inSensitive */ - 0, /* TIME STAMPS are BASE64 */ - 0, /* +I support */ - 0, /* SJOIN ban char */ - 0, /* SJOIN except char */ - 0, /* SJOIN invite char */ - 0, /* Can remove User Channel Modes with SVSMODE */ - 1, /* Sglines are enforced */ - "x", /* vhost char */ - 0, /* ts6 */ - 1, /* support helper umode */ - 0, /* p10 */ - NULL, /* character set */ - 1, /* reports sync state */ - 0, /* CIDR channelbans */ - } - , - {NULL} + {"UltimateIRCd 3.0.*", /* ircd name */ + "+S", /* nickserv mode */ + "+S", /* chanserv mode */ + "+S", /* memoserv mode */ + "+o", /* hostserv mode */ + "+iS", /* operserv mode */ + "+S", /* botserv mode */ + "+Sh", /* helpserv mode */ + "+iS", /* Dev/Null mode */ + "+iS", /* Global mode */ + "+o", /* nickserv alias mode */ + "+o", /* chanserv alias mode */ + "+o", /* memoserv alias mode */ + "+io", /* hostserv alias mode */ + "+io", /* operserv alias mode */ + "+o", /* botserv alias mode */ + "+h", /* helpserv alias mode */ + "+i", /* Dev/Null alias mode */ + "+io", /* Global alias mode */ + "+S", /* Used by BotServ Bots */ + 5, /* Chan Max Symbols */ + "-ilmnpqstRKAO", /* Modes to Remove */ + "+o", /* Channel Umode used by Botserv bots */ + 1, /* SVSNICK */ + 1, /* Vhost */ + 0, /* Has Owner */ + NULL, /* Mode to set for an owner */ + NULL, /* Mode to unset for an owner */ + "+a", /* Mode to set for channel admin */ + "-a", /* Mode to unset for channel admin */ + "+rd", /* Mode On Reg */ + NULL, /* Mode on ID for Roots */ + NULL, /* Mode on ID for Admins */ + NULL, /* Mode on ID for Opers */ + "-r+d", /* Mode on UnReg */ + "+d", /* Mode on Nick Change */ + 1, /* Supports SGlines */ + 1, /* Supports SQlines */ + 1, /* Supports SZlines */ + 1, /* Supports Halfop +h */ + 3, /* Number of server args */ + 0, /* Join 2 Set */ + 0, /* Join 2 Message */ + 1, /* Has exceptions +e */ + 0, /* TS Topic Forward */ + 0, /* TS Topci Backward */ + UMODE_p, /* Protected Umode */ + 1, /* Has Admin */ + 1, /* Chan SQlines */ + 0, /* Quit on Kill */ + 1, /* SVSMODE unban */ + 0, /* Has Protect */ + 0, /* Reverse */ + 1, /* Chan Reg */ + CMODE_r, /* Channel Mode */ + 0, /* vidents */ + 0, /* svshold */ + 1, /* time stamp on mode */ + 1, /* NICKIP */ + 0, /* O:LINE */ + 1, /* UMODE */ + 1, /* VHOST ON NICK */ + 0, /* Change RealName */ + CMODE_K, /* No Knock */ + CMODE_A, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + UMODE_x, /* Vhost Mode */ + 0, /* +f */ + 0, /* +L */ + 0, /* +f Mode */ + 0, /* +L Mode */ + 1, /* On nick change check if they could be identified */ + 1, /* No Knock requires +i */ + NULL, /* CAPAB Chan Modes */ + 0, /* We support TOKENS */ + 1, /* TOKENS are CASE inSensitive */ + 0, /* TIME STAMPS are BASE64 */ + 0, /* +I support */ + 0, /* SJOIN ban char */ + 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ + 0, /* Can remove User Channel Modes with SVSMODE */ + 1, /* Sglines are enforced */ + "x", /* vhost char */ + 0, /* ts6 */ + 1, /* support helper umode */ + 0, /* p10 */ + NULL, /* character set */ + 1, /* reports sync state */ + 0, /* CIDR channelbans */ + } + , + {NULL} }; IRCDCAPAB myIrcdcap[] = { - { - CAPAB_NOQUIT, /* NOQUIT */ - CAPAB_TSMODE, /* TSMODE */ - CAPAB_UNCONNECT, /* UNCONNECT */ - 0, /* NICKIP */ - CAPAB_NSJOIN, /* SJOIN */ - CAPAB_ZIP, /* ZIP */ - CAPAB_BURST, /* BURST */ - CAPAB_TS5, /* TS5 */ - 0, /* TS3 */ - CAPAB_DKEY, /* DKEY */ - 0, /* PT4 */ - 0, /* SCS */ - 0, /* QS */ - 0, /* UID */ - 0, /* KNOCK */ - CAPAB_CLIENT, /* CLIENT */ - CAPAB_IPV6, /* IPV6 */ - CAPAB_SSJ5, /* SSJ5 */ - 0, /* SN2 */ - 0, /* TOKEN */ - 0, /* VHOST */ - 0, /* SSJ3 */ - 0, /* NICK2 */ - 0, /* UMODE2 */ - 0, /* VL */ - 0, /* TLKEXT */ - CAPAB_DODKEY, /* DODKEY */ - CAPAB_DOZIP, /* DOZIP */ - 0, 0, 0} + { + CAPAB_NOQUIT, /* NOQUIT */ + CAPAB_TSMODE, /* TSMODE */ + CAPAB_UNCONNECT, /* UNCONNECT */ + 0, /* NICKIP */ + CAPAB_NSJOIN, /* SJOIN */ + CAPAB_ZIP, /* ZIP */ + CAPAB_BURST, /* BURST */ + CAPAB_TS5, /* TS5 */ + 0, /* TS3 */ + CAPAB_DKEY, /* DKEY */ + 0, /* PT4 */ + 0, /* SCS */ + 0, /* QS */ + 0, /* UID */ + 0, /* KNOCK */ + CAPAB_CLIENT, /* CLIENT */ + CAPAB_IPV6, /* IPV6 */ + CAPAB_SSJ5, /* SSJ5 */ + 0, /* SN2 */ + 0, /* TOKEN */ + 0, /* VHOST */ + 0, /* SSJ3 */ + 0, /* NICK2 */ + 0, /* UMODE2 */ + 0, /* VL */ + 0, /* TLKEXT */ + CAPAB_DODKEY, /* DODKEY */ + CAPAB_DOZIP, /* DOZIP */ + 0, 0, 0} }; void ultimate3_ProcessUsermodes(User * user, int ac, const char **av) { - int add = 1; /* 1 if adding modes, 0 if deleting */ - const char *modes = av[0]; - - ac--; - - if (debug) - alog("debug: Changing mode for %s to %s", user->nick, modes); - - while (*modes) { - - /* This looks better, much better than "add ? (do_add) : (do_remove)". - * At least this is readable without paying much attention :) -GD - */ - if (add) - user->mode |= umodes[(int) *modes]; - else - user->mode &= ~umodes[(int) *modes]; - - switch (*modes++) { - case '+': - add = 1; - break; - case '-': - add = 0; - break; - case 'a': - if (add && !is_services_oper(user)) { - common_svsmode(user, "-a", NULL); - user->mode &= ~UMODE_a; - } - break; - case 'P': - if (add && !is_services_admin(user)) { - common_svsmode(user, "-P", NULL); - user->mode &= ~UMODE_P; - } - break; - case 'Z': - if (add && !is_services_root(user)) { - common_svsmode(user, "-Z", NULL); - user->mode &= ~UMODE_Z; - } - break; - case 'd': - if (ac == 0) { - alog("user: umode +d with no parameter (?) for user %s", - user->nick); - break; - } - - ac--; - av++; - user->svid = strtoul(*av, NULL, 0); - break; - case 'o': - if (add) { - opcnt++; - if (WallOper) { - anope_SendGlobops(s_OperServ, - "\2%s\2 is now an IRC operator.", - user->nick); - } - display_news(user, NEWS_OPER); - if (is_services_oper(user)) { - common_svsmode(user, "+a", NULL); - user->mode |= UMODE_a; - } - if (is_services_admin(user)) { - common_svsmode(user, "+P", NULL); - user->mode |= UMODE_P; - } - if (is_services_root(user)) { - common_svsmode(user, "+Z", NULL); - user->mode |= UMODE_Z; - } - } else { - opcnt--; - } - break; - case 'r': - if (add && !nick_identified(user)) { - common_svsmode(user, "-r", NULL); - user->mode &= ~UMODE_r; - } - break; - case 'x': - update_host(user); - break; - } - } + int add = 1; /* 1 if adding modes, 0 if deleting */ + const char *modes = av[0]; + + ac--; + + if (debug) + alog("debug: Changing mode for %s to %s", user->nick, modes); + + while (*modes) { + + /* This looks better, much better than "add ? (do_add) : (do_remove)". + * At least this is readable without paying much attention :) -GD + */ + if (add) + user->mode |= umodes[(int) *modes]; + else + user->mode &= ~umodes[(int) *modes]; + + switch (*modes++) { + case '+': + add = 1; + break; + case '-': + add = 0; + break; + case 'a': + if (add && !is_services_oper(user)) { + common_svsmode(user, "-a", NULL); + user->mode &= ~UMODE_a; + } + break; + case 'P': + if (add && !is_services_admin(user)) { + common_svsmode(user, "-P", NULL); + user->mode &= ~UMODE_P; + } + break; + case 'Z': + if (add && !is_services_root(user)) { + common_svsmode(user, "-Z", NULL); + user->mode &= ~UMODE_Z; + } + break; + case 'd': + if (ac == 0) { + alog("user: umode +d with no parameter (?) for user %s", + user->nick); + break; + } + + ac--; + av++; + user->svid = strtoul(*av, NULL, 0); + break; + case 'o': + if (add) { + opcnt++; + if (WallOper) { + anope_SendGlobops(s_OperServ, + "\2%s\2 is now an IRC operator.", + user->nick); + } + display_news(user, NEWS_OPER); + if (is_services_oper(user)) { + common_svsmode(user, "+a", NULL); + user->mode |= UMODE_a; + } + if (is_services_admin(user)) { + common_svsmode(user, "+P", NULL); + user->mode |= UMODE_P; + } + if (is_services_root(user)) { + common_svsmode(user, "+Z", NULL); + user->mode |= UMODE_Z; + } + } else { + opcnt--; + } + break; + case 'r': + if (add && !nick_identified(user)) { + common_svsmode(user, "-r", NULL); + user->mode &= ~UMODE_r; + } + break; + case 'x': + update_host(user); + break; + } + } } unsigned long umodes[128] = { - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused, Unused, Horzontal Tab */ - 0, 0, 0, /* Line Feed, Unused, Unused */ - 0, 0, 0, /* Carriage Return, Unused, Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused, Unused, Space */ - 0, 0, 0, /* ! " # */ - 0, 0, 0, /* $ % & */ - 0, 0, 0, /* ! ( ) */ - 0, 0, 0, /* * + , */ - 0, 0, 0, /* - . / */ - 0, 0, /* 0 1 */ - 0, 0, /* 2 3 */ - 0, 0, /* 4 5 */ - 0, 0, /* 6 7 */ - 0, 0, /* 8 9 */ - 0, 0, /* : ; */ - 0, 0, 0, /* < = > */ - 0, 0, /* ? @ */ - UMODE_A, 0, 0, /* A B C */ - UMODE_D, 0, 0, /* D E F */ - 0, 0, 0, /* G H I */ - 0, 0, 0, /* J K L */ - 0, 0, UMODE_0, /* M N O */ - UMODE_P, 0, UMODE_R, /* P Q R */ - UMODE_S, 0, 0, /* S T U */ - 0, UMODE_W, 0, /* V W X */ - 0, /* Y */ - UMODE_Z, /* Z */ - 0, 0, 0, /* [ \ ] */ - 0, 0, 0, /* ^ _ ` */ - UMODE_a, 0, 0, /* a b c */ - UMODE_d, 0, 0, /* d e f */ - 0, UMODE_h, UMODE_i, /* g h i */ - 0, 0, 0, /* j k l */ - 0, 0, UMODE_o, /* m n o */ - UMODE_p, 0, UMODE_r, /* p q r */ - 0, 0, 0, /* s t u */ - 0, UMODE_w, UMODE_x, /* v w x */ - 0, /* y */ - 0, /* z */ - 0, 0, 0, /* { | } */ - 0, 0 /* ~ � */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused, Unused, Horzontal Tab */ + 0, 0, 0, /* Line Feed, Unused, Unused */ + 0, 0, 0, /* Carriage Return, Unused, Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused, Unused, Space */ + 0, 0, 0, /* ! " # */ + 0, 0, 0, /* $ % & */ + 0, 0, 0, /* ! ( ) */ + 0, 0, 0, /* * + , */ + 0, 0, 0, /* - . / */ + 0, 0, /* 0 1 */ + 0, 0, /* 2 3 */ + 0, 0, /* 4 5 */ + 0, 0, /* 6 7 */ + 0, 0, /* 8 9 */ + 0, 0, /* : ; */ + 0, 0, 0, /* < = > */ + 0, 0, /* ? @ */ + UMODE_A, 0, 0, /* A B C */ + UMODE_D, 0, 0, /* D E F */ + 0, 0, 0, /* G H I */ + 0, 0, 0, /* J K L */ + 0, 0, UMODE_0, /* M N O */ + UMODE_P, 0, UMODE_R, /* P Q R */ + UMODE_S, 0, 0, /* S T U */ + 0, UMODE_W, 0, /* V W X */ + 0, /* Y */ + UMODE_Z, /* Z */ + 0, 0, 0, /* [ \ ] */ + 0, 0, 0, /* ^ _ ` */ + UMODE_a, 0, 0, /* a b c */ + UMODE_d, 0, 0, /* d e f */ + 0, UMODE_h, UMODE_i, /* g h i */ + 0, 0, 0, /* j k l */ + 0, 0, UMODE_o, /* m n o */ + UMODE_p, 0, UMODE_r, /* p q r */ + 0, 0, 0, /* s t u */ + 0, UMODE_w, UMODE_x, /* v w x */ + 0, /* y */ + 0, /* z */ + 0, 0, 0, /* { | } */ + 0, 0 /* ~ � */ }; char myCsmodes[128] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, - 'a', /* (33) ! Channel Admins */ - 0, 0, 0, - 'h', /* (37) % Channel halfops */ - 0, 0, 0, 0, - 0, + 0, + 'a', /* (33) ! Channel Admins */ + 0, 0, 0, + 'h', /* (37) % Channel halfops */ + 0, 0, 0, 0, + 0, - 'v', 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'v', 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; CMMode myCmmodes[128] = { - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, - {NULL}, - {add_ban, del_ban}, - {NULL}, - {NULL}, - {add_exception, del_exception}, - {NULL}, - {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, + {NULL}, + {add_ban, del_ban}, + {NULL}, + {NULL}, + {add_exception, del_exception}, + {NULL}, + {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} }; CBMode myCbmodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, - {CMODE_A, CBM_NO_USER_MLOCK, NULL, NULL}, - {0}, /* B */ - {0}, /* C */ - {0}, /* D */ - {0}, /* E */ - {0}, /* F */ - {0}, /* G */ - {0}, /* H */ - {0}, /* I */ - {0}, /* J */ - {CMODE_K, 0, NULL, NULL}, /* K */ - {0}, /* L */ - {CMODE_M, 0, NULL, NULL}, /* M */ - {CMODE_N, 0, NULL, NULL}, /* N */ - {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, - {0}, /* P */ - {0}, /* Q */ - {CMODE_R, 0, NULL, NULL}, /* R */ - {CMODE_S, 0, NULL, NULL}, /* S */ - {0}, /* T */ - {0}, /* U */ - {0}, /* V */ - {0}, /* W */ - {0}, /* X */ - {0}, /* Y */ - {0}, /* Z */ - {0}, {0}, {0}, {0}, {0}, {0}, - {0}, /* a */ - {0}, /* b */ - {CMODE_c, 0, NULL, NULL}, /* c */ - {0}, /* d */ - {0}, /* e */ - {0}, /* f */ - {0}, /* g */ - {0}, /* h */ - {CMODE_i, 0, NULL, NULL}, /* i */ - {0}, /* j */ - {CMODE_k, 0, chan_set_key, cs_set_key}, - {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, - {CMODE_m, 0, NULL, NULL}, /* m */ - {CMODE_n, 0, NULL, NULL}, /* n */ - {0}, /* o */ - {CMODE_p, 0, NULL, NULL}, /* p */ - {CMODE_q, 0, NULL, NULL}, /* q */ - {CMODE_r, CBM_NO_MLOCK, NULL, NULL}, - {CMODE_s, 0, NULL, NULL}, /* s */ - {CMODE_t, 0, NULL, NULL}, /* t */ - {0}, /* u */ - {0}, /* v */ - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {0}, /* z */ - {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, + {CMODE_A, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* B */ + {0}, /* C */ + {0}, /* D */ + {0}, /* E */ + {0}, /* F */ + {0}, /* G */ + {0}, /* H */ + {0}, /* I */ + {0}, /* J */ + {CMODE_K, 0, NULL, NULL}, /* K */ + {0}, /* L */ + {CMODE_M, 0, NULL, NULL}, /* M */ + {CMODE_N, 0, NULL, NULL}, /* N */ + {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* P */ + {0}, /* Q */ + {CMODE_R, 0, NULL, NULL}, /* R */ + {CMODE_S, 0, NULL, NULL}, /* S */ + {0}, /* T */ + {0}, /* U */ + {0}, /* V */ + {0}, /* W */ + {0}, /* X */ + {0}, /* Y */ + {0}, /* Z */ + {0}, {0}, {0}, {0}, {0}, {0}, + {0}, /* a */ + {0}, /* b */ + {CMODE_c, 0, NULL, NULL}, /* c */ + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {0}, /* h */ + {CMODE_i, 0, NULL, NULL}, /* i */ + {0}, /* j */ + {CMODE_k, 0, chan_set_key, cs_set_key}, + {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, + {CMODE_m, 0, NULL, NULL}, /* m */ + {CMODE_n, 0, NULL, NULL}, /* n */ + {0}, /* o */ + {CMODE_p, 0, NULL, NULL}, /* p */ + {CMODE_q, 0, NULL, NULL}, /* q */ + {CMODE_r, CBM_NO_MLOCK, NULL, NULL}, + {CMODE_s, 0, NULL, NULL}, /* s */ + {CMODE_t, 0, NULL, NULL}, /* t */ + {0}, /* u */ + {0}, /* v */ + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0} }; CBModeInfo myCbmodeinfos[] = { - {'c', CMODE_c, 0, NULL, NULL}, - {'i', CMODE_i, 0, NULL, NULL}, - {'k', CMODE_k, 0, get_key, cs_get_key}, - {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, - {'m', CMODE_m, 0, NULL, NULL}, - {'n', CMODE_n, 0, NULL, NULL}, - {'p', CMODE_p, 0, NULL, NULL}, - {'q', CMODE_q, 0, NULL, NULL}, - {'r', CMODE_r, 0, NULL, NULL}, - {'s', CMODE_s, 0, NULL, NULL}, - {'t', CMODE_t, 0, NULL, NULL}, - {'A', CMODE_A, 0, NULL, NULL}, - {'K', CMODE_K, 0, NULL, NULL}, - {'M', CMODE_M, 0, NULL, NULL}, - {'N', CMODE_N, 0, NULL, NULL}, - {'O', CMODE_O, 0, NULL, NULL}, - {'R', CMODE_R, 0, NULL, NULL}, - {'S', CMODE_S, 0, NULL, NULL}, - {0} + {'c', CMODE_c, 0, NULL, NULL}, + {'i', CMODE_i, 0, NULL, NULL}, + {'k', CMODE_k, 0, get_key, cs_get_key}, + {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, + {'m', CMODE_m, 0, NULL, NULL}, + {'n', CMODE_n, 0, NULL, NULL}, + {'p', CMODE_p, 0, NULL, NULL}, + {'q', CMODE_q, 0, NULL, NULL}, + {'r', CMODE_r, 0, NULL, NULL}, + {'s', CMODE_s, 0, NULL, NULL}, + {'t', CMODE_t, 0, NULL, NULL}, + {'A', CMODE_A, 0, NULL, NULL}, + {'K', CMODE_K, 0, NULL, NULL}, + {'M', CMODE_M, 0, NULL, NULL}, + {'N', CMODE_N, 0, NULL, NULL}, + {'O', CMODE_O, 0, NULL, NULL}, + {'R', CMODE_R, 0, NULL, NULL}, + {'S', CMODE_S, 0, NULL, NULL}, + {0} }; CUMode myCumodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, - - {CUS_PROTECT, CUF_PROTECT_BOTSERV, check_valid_admin}, - {0}, /* b */ - {0}, /* c */ - {0}, /* d */ - {0}, /* e */ - {0}, /* f */ - {0}, /* g */ - {CUS_HALFOP, 0, check_valid_op}, - {0}, /* i */ - {0}, /* j */ - {0}, /* k */ - {0}, /* l */ - {0}, /* m */ - {0}, /* n */ - {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, - {0}, /* p */ - {0}, /* q */ - {0}, /* r */ - {0}, /* s */ - {0}, /* t */ - {0}, /* u */ - {CUS_VOICE, 0, NULL}, - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {0}, /* z */ - {0}, {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, + + {CUS_PROTECT, CUF_PROTECT_BOTSERV, check_valid_admin}, + {0}, /* b */ + {0}, /* c */ + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {CUS_HALFOP, 0, check_valid_op}, + {0}, /* i */ + {0}, /* j */ + {0}, /* k */ + {0}, /* l */ + {0}, /* m */ + {0}, /* n */ + {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, + {0}, /* p */ + {0}, /* q */ + {0}, /* r */ + {0}, /* s */ + {0}, /* t */ + {0}, /* u */ + {CUS_VOICE, 0, NULL}, + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0}, {0} }; /* SVSMODE -b */ void ultimate3_SendBanDel(const char *name, const char *nick) { - ultimate3_SendSVSMode_chan(name, "-b", nick); + ultimate3_SendSVSMode_chan(name, "-b", nick); } @@ -485,179 +485,179 @@ void ultimate3_SendBanDel(const char *name, const char *nick) void ultimate3_SendSVSMode_chan(const char *name, const char *mode, const char *nick) { - if (nick) { - send_cmd(ServerName, "SVSMODE %s %s %s", name, mode, nick); - } else { - send_cmd(ServerName, "SVSMODE %s %s", name, mode); - } + 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(const char *source, int ac, const char **av) { - do_sjoin(source, ac, av); - return MOD_CONT; + do_sjoin(source, ac, av); + return MOD_CONT; } /* ** NICK - new -** source = NULL +** source = NULL ** parv[0] = nickname -** parv[1] = hopcount -** parv[2] = timestamp -** parv[3] = modes -** parv[4] = username -** parv[5] = hostname -** parv[6] = server +** parv[1] = hopcount +** parv[2] = timestamp +** parv[3] = modes +** parv[4] = username +** parv[5] = hostname +** parv[6] = server ** parv[7] = servicestamp -** parv[8] = IP +** parv[8] = IP ** parv[9] = info ** NICK - change -** source = oldnick +** source = oldnick ** parv[0] = new nickname -** parv[1] = hopcount +** parv[1] = hopcount */ int anope_event_nick(const char *source, int ac, const char **av) { - if (ac != 2) { - User *user = do_nick(source, av[0], av[4], av[5], av[6], av[9], - strtoul(av[2], NULL, 10), strtoul(av[7], NULL, - 0), - strtoul(av[8], NULL, 0), "*", NULL); - if (user) - anope_ProcessUsermodes(user, 1, &av[3]); - } else { - do_nick(source, av[0], NULL, NULL, NULL, NULL, - strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); - } - return MOD_CONT; + if (ac != 2) { + User *user = do_nick(source, av[0], av[4], av[5], av[6], av[9], + strtoul(av[2], NULL, 10), strtoul(av[7], NULL, + 0), + strtoul(av[8], NULL, 0), "*", NULL); + if (user) + anope_ProcessUsermodes(user, 1, &av[3]); + } else { + do_nick(source, av[0], NULL, NULL, NULL, NULL, + strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); + } + return MOD_CONT; } int anope_event_sethost(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - u = finduser(av[0]); - if (!u) { - if (debug) { - alog("debug: SETHOST for nonexistent user %s", av[0]); - } - return MOD_CONT; - } + u = finduser(av[0]); + if (!u) { + if (debug) { + alog("debug: SETHOST for nonexistent user %s", av[0]); + } + return MOD_CONT; + } - u->SetDisplayedHost(av[1]); - return MOD_CONT; + u->SetDisplayedHost(av[1]); + return MOD_CONT; } int anope_event_capab(const char *source, int ac, const char **av) { - capab_parse(ac, av); - return MOD_CONT; + capab_parse(ac, av); + return MOD_CONT; } /* ** CLIENT -** source = NULL +** source = NULL ** parv[0] = nickname Trystan -** parv[1] = hopcount 1 -** parv[2] = timestamp 1090083810 -** parv[3] = modes +ix -** parv[4] = modes ? + -** parv[5] = username Trystan -** parv[6] = hostname c-24-2-101-227.client.comcast.net -** parv[7] = vhost 3223f75b.2b32ee69.client.comcast.net -** parv[8] = server WhiteRose.No.Eu.Shadow-Realm.org -** parv[9] = svid 0 -** parv[10] = ip 402810339 -** parv[11] = info Dreams are answers to questions not yet asked +** parv[1] = hopcount 1 +** parv[2] = timestamp 1090083810 +** parv[3] = modes +ix +** parv[4] = modes ? + +** parv[5] = username Trystan +** parv[6] = hostname c-24-2-101-227.client.comcast.net +** parv[7] = vhost 3223f75b.2b32ee69.client.comcast.net +** parv[8] = server WhiteRose.No.Eu.Shadow-Realm.org +** parv[9] = svid 0 +** parv[10] = ip 402810339 +** parv[11] = info Dreams are answers to questions not yet asked */ int anope_event_client(const char *source, int ac, const char **av) { - if (ac != 2) { - User *user = do_nick(source, av[0], av[5], av[6], av[8], av[11], - strtoul(av[2], NULL, 10), strtoul(av[9], NULL, - 0), - strtoul(av[10], NULL, 0), av[7], NULL); - if (user) { - anope_ProcessUsermodes(user, 1, &av[3]); - } - } - return MOD_CONT; + if (ac != 2) { + User *user = do_nick(source, av[0], av[5], av[6], av[8], av[11], + strtoul(av[2], NULL, 10), strtoul(av[9], NULL, + 0), + strtoul(av[10], NULL, 0), av[7], NULL); + if (user) { + anope_ProcessUsermodes(user, 1, &av[3]); + } + } + return MOD_CONT; } /* *INDENT-OFF* */ void moduleAddIRCDMsgs(void) { - Message *m; - - updateProtectDetails("ADMIN","ADMINME","admin","deadmin","AUTOADMIN","+a","-a"); - - m = createMessage("401", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("402", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); - m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); - m = createMessage("INVITE", anope_event_invite); addCoreMessage(IRCD,m); - m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); - m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); - m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); - m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); - m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); - m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); - m = createMessage("NOTICE", anope_event_notice); addCoreMessage(IRCD,m); - m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); - m = createMessage("PASS", anope_event_pass); addCoreMessage(IRCD,m); - m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); - m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); - m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); - m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); - m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); - m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); - m = createMessage("USER", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("WALLOPS", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); - m = createMessage("AKILL", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("GLOBOPS", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("GNOTICE", anope_event_gnotice); addCoreMessage(IRCD,m); - m = createMessage("GOPER", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("RAKILL", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SILENCE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SVSKILL", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SVSMODE", anope_event_mode); addCoreMessage(IRCD,m); - m = createMessage("SVSNICK", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SVSNOOP", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SQLINE", anope_event_sqline); addCoreMessage(IRCD,m); - m = createMessage("UNSQLINE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); - m = createMessage("CS", anope_event_cs); addCoreMessage(IRCD,m); - m = createMessage("HS", anope_event_hs); addCoreMessage(IRCD,m); - m = createMessage("MS", anope_event_ms); addCoreMessage(IRCD,m); - m = createMessage("NS", anope_event_ns); addCoreMessage(IRCD,m); - m = createMessage("OS", anope_event_os); addCoreMessage(IRCD,m); - m = createMessage("RS", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SGLINE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); - m = createMessage("SS", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SVINFO", anope_event_svinfo); addCoreMessage(IRCD,m); - m = createMessage("SZLINE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("UNSGLINE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("UNSZLINE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SETHOST", anope_event_sethost); addCoreMessage(IRCD,m); - m = createMessage("NETINFO", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("GCONNECT", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("NETGLOBAL", anope_event_netglobal); addCoreMessage(IRCD,m); - m = createMessage("CHATOPS", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("NETCTRL", anope_event_netctrl); addCoreMessage(IRCD,m); - m = createMessage("CLIENT", anope_event_client); addCoreMessage(IRCD,m); - m = createMessage("SMODE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m); - m = createMessage("BURST", anope_event_burst); addCoreMessage(IRCD,m); - m = createMessage("REHASH", anope_event_rehash); addCoreMessage(IRCD,m); - m = createMessage("ADMIN", anope_event_admin); addCoreMessage(IRCD,m); - m = createMessage("CREDITS", anope_event_credits); addCoreMessage(IRCD,m); - m = createMessage("SMODE", anope_event_mode); addCoreMessage(IRCD,m); - m = createMessage("EOBURST", anope_event_eob); addCoreMessage(IRCD,m); + Message *m; + + updateProtectDetails("ADMIN","ADMINME","admin","deadmin","AUTOADMIN","+a","-a"); + + m = createMessage("401", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("402", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); + m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); + m = createMessage("INVITE", anope_event_invite); addCoreMessage(IRCD,m); + m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); + m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); + m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); + m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); + m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("NOTICE", anope_event_notice); addCoreMessage(IRCD,m); + m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); + m = createMessage("PASS", anope_event_pass); addCoreMessage(IRCD,m); + m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); + m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); + m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); + m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); + m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); + m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); + m = createMessage("USER", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("WALLOPS", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); + m = createMessage("AKILL", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("GLOBOPS", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("GNOTICE", anope_event_gnotice); addCoreMessage(IRCD,m); + m = createMessage("GOPER", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("RAKILL", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SILENCE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SVSKILL", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SVSMODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("SVSNICK", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SVSNOOP", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SQLINE", anope_event_sqline); addCoreMessage(IRCD,m); + m = createMessage("UNSQLINE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); + m = createMessage("CS", anope_event_cs); addCoreMessage(IRCD,m); + m = createMessage("HS", anope_event_hs); addCoreMessage(IRCD,m); + m = createMessage("MS", anope_event_ms); addCoreMessage(IRCD,m); + m = createMessage("NS", anope_event_ns); addCoreMessage(IRCD,m); + m = createMessage("OS", anope_event_os); addCoreMessage(IRCD,m); + m = createMessage("RS", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SGLINE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); + m = createMessage("SS", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SVINFO", anope_event_svinfo); addCoreMessage(IRCD,m); + m = createMessage("SZLINE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("UNSGLINE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("UNSZLINE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SETHOST", anope_event_sethost); addCoreMessage(IRCD,m); + m = createMessage("NETINFO", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("GCONNECT", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("NETGLOBAL", anope_event_netglobal); addCoreMessage(IRCD,m); + m = createMessage("CHATOPS", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("NETCTRL", anope_event_netctrl); addCoreMessage(IRCD,m); + m = createMessage("CLIENT", anope_event_client); addCoreMessage(IRCD,m); + m = createMessage("SMODE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m); + m = createMessage("BURST", anope_event_burst); addCoreMessage(IRCD,m); + m = createMessage("REHASH", anope_event_rehash); addCoreMessage(IRCD,m); + m = createMessage("ADMIN", anope_event_admin); addCoreMessage(IRCD,m); + m = createMessage("CREDITS", anope_event_credits); addCoreMessage(IRCD,m); + m = createMessage("SMODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("EOBURST", anope_event_eob); addCoreMessage(IRCD,m); } /* *INDENT-ON* */ @@ -665,21 +665,21 @@ void moduleAddIRCDMsgs(void) { void ultimate3_SendSQLine(const char *mask, const char *reason) { - if (!mask || !reason) { - return; - } + if (!mask || !reason) { + return; + } - send_cmd(NULL, "SQLINE %s :%s", mask, reason); + send_cmd(NULL, "SQLINE %s :%s", mask, reason); } void ultimate3_SendSGLineDel(const char *mask) { - send_cmd(NULL, "UNSGLINE 0 :%s", mask); + send_cmd(NULL, "UNSGLINE 0 :%s", mask); } void ultimate3_SendSZLineDel(const char *mask) { - send_cmd(NULL, "UNSZLINE 0 %s", mask); + send_cmd(NULL, "UNSZLINE 0 %s", mask); } /* As of alpha27 (one after our offical support szline was removed */ @@ -689,10 +689,10 @@ void ultimate3_SendSZLineDel(const char *mask) */ void ultimate3_SendSZLine(const char *mask, const char *reason, const char *whom) { - send_cmd(NULL, "AKILL %s * %d %s %ld :%s", mask, 86400 * 2, whom, - (long int) time(NULL), reason); - /* leaving this in here in case some legacy user asks for it */ - /* send_cmd(NULL, "SZLINE %s :%s", mask, reason); */ + send_cmd(NULL, "AKILL %s * %d %s %ld :%s", mask, 86400 * 2, whom, + (long int) time(NULL), reason); + /* leaving this in here in case some legacy user asks for it */ + /* send_cmd(NULL, "SZLINE %s :%s", mask, reason); */ } void UltimateIRCdProto::SendSVSNOOP(const char *server, int set) @@ -707,7 +707,7 @@ void ultimate3_cmd_svsadmin(const char *server, int set) void ultimate3_SendSGLine(const char *mask, const char *reason) { - send_cmd(NULL, "SGLINE %d :%s:%s", (int)strlen(mask), mask, reason); + send_cmd(NULL, "SGLINE %d :%s:%s", (int)strlen(mask), mask, reason); } void UltimateIRCdProto::SendAkillDel(const char *user, const char *host) @@ -717,948 +717,948 @@ void UltimateIRCdProto::SendAkillDel(const char *user, const char *host) void ultimate3_SendVhostDel(User * u) { - send_cmd(s_HostServ, "SVSMODE %s -x", u->nick); - notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar); + send_cmd(s_HostServ, "SVSMODE %s -x", u->nick); + notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar); } void ultimate3_SendVhost(const char *nick, const char *vIdent, const char *vhost) { - send_cmd(s_HostServ, "SVSMODE %s +x", nick); - send_cmd(ServerName, "SETHOST %s %s", nick, vhost); + send_cmd(s_HostServ, "SVSMODE %s +x", nick); + send_cmd(ServerName, "SETHOST %s %s", nick, vhost); } void ultimate3_SendJoin(const char *user, const char *channel, time_t chantime) { - send_cmd(user, "SJOIN %ld %s", (long int) chantime, channel); + send_cmd(user, "SJOIN %ld %s", (long int) chantime, channel); } void ultimate3_SendAkill(const char *user, const char *host, const char *who, time_t when, - time_t expires, const char *reason) + time_t expires, const char *reason) { - send_cmd(NULL, "AKILL %s %s %d %s %ld :%s", host, user, 86400 * 2, who, - (long int) time(NULL), reason); + send_cmd(NULL, "AKILL %s %s %d %s %ld :%s", host, user, 86400 * 2, who, + (long int) time(NULL), reason); } void ultimate3_SendSVSKill(const char *source, const char *user, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "SVSKILL %s :%s", user, buf); + send_cmd(NULL, "SVSKILL %s :%s", user, buf); } void ultimate3_SendSVSMode(User * u, int ac, const char **av) { - send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick, - (long int) u->timestamp, av[0], (ac == 2 ? " " : ""), - (ac == 2 ? av[1] : "")); + send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick, + (long int) u->timestamp, av[0], (ac == 2 ? " " : ""), + (ac == 2 ? av[1] : "")); } void anope_squit(char *servname, char *message) { - send_cmd(servname, "SQUIT %s :%s", servname, message); + send_cmd(servname, "SQUIT %s :%s", servname, message); } void anope_pong(char *servname) { - send_cmd(servname, "PONG %s", servname); + send_cmd(servname, "PONG %s", servname); } /* Events */ int anope_event_ping(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - ultimate3_SendPong(ac > 1 ? av[1] : ServerName, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + ultimate3_SendPong(ac > 1 ? av[1] : ServerName, av[0]); + return MOD_CONT; } int anope_event_436(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; + if (ac < 1) + return MOD_CONT; - m_nickcoll(av[0]); - return MOD_CONT; + m_nickcoll(av[0]); + return MOD_CONT; } int anope_event_away(const char *source, int ac, const char **av) { - if (!source) { - return MOD_CONT; - } - m_away(source, (ac ? av[0] : NULL)); - return MOD_CONT; + if (!source) { + return MOD_CONT; + } + m_away(source, (ac ? av[0] : NULL)); + return MOD_CONT; } int anope_event_topic(const char *source, int ac, const char **av) { - if (ac != 4) - return MOD_CONT; - do_topic(source, ac, av); - return MOD_CONT; + if (ac != 4) + return MOD_CONT; + do_topic(source, ac, av); + return MOD_CONT; } int anope_event_squit(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; - do_squit(source, ac, av); - return MOD_CONT; + if (ac != 2) + return MOD_CONT; + do_squit(source, ac, av); + return MOD_CONT; } int anope_event_quit(const char *source, int ac, const char **av) { - if (ac != 1) - return MOD_CONT; - do_quit(source, ac, av); - return MOD_CONT; + if (ac != 1) + return MOD_CONT; + do_quit(source, ac, av); + return MOD_CONT; } int anope_event_mode(const char *source, int ac, const char **av) { - if (ac < 2) - return MOD_CONT; + if (ac < 2) + return MOD_CONT; - if (*av[0] == '#' || *av[0] == '&') { - do_cmode(source, ac, av); - } else { - do_umode(source, ac, av); - } - return MOD_CONT; + if (*av[0] == '#' || *av[0] == '&') { + do_cmode(source, ac, av); + } else { + do_umode(source, ac, av); + } + return MOD_CONT; } /* EVENT : OS */ int anope_event_os(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_OperServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_OperServ, av[0]); + return MOD_CONT; } /* EVENT : NS */ int anope_event_ns(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_NickServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_NickServ, av[0]); + return MOD_CONT; } /* EVENT : MS */ int anope_event_ms(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_MemoServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_MemoServ, av[0]); + return MOD_CONT; } /* EVENT : HS */ int anope_event_hs(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_HostServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_HostServ, av[0]); + return MOD_CONT; } /* EVENT : CS */ int anope_event_cs(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_ChanServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_ChanServ, av[0]); + return MOD_CONT; } int anope_event_kill(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - m_kill(av[0], av[1]); - return MOD_CONT; + m_kill(av[0], av[1]); + return MOD_CONT; } int anope_event_kick(const char *source, int ac, const char **av) { - if (ac != 3) - return MOD_CONT; - do_kick(source, ac, av); - return MOD_CONT; + if (ac != 3) + return MOD_CONT; + do_kick(source, ac, av); + return MOD_CONT; } int anope_event_join(const char *source, int ac, const char **av) { - if (ac != 1) - return MOD_CONT; - do_join(source, ac, av); - return MOD_CONT; + if (ac != 1) + return MOD_CONT; + do_join(source, ac, av); + return MOD_CONT; } int anope_event_motd(const char *source, int ac, const char **av) { - if (!source) { - return MOD_CONT; - } + if (!source) { + return MOD_CONT; + } - m_motd(source); - return MOD_CONT; + m_motd(source); + return MOD_CONT; } int anope_event_setname(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 1) - return MOD_CONT; + if (ac != 1) + return MOD_CONT; - u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETNAME for nonexistent user %s", source); - } - return MOD_CONT; - } + u = finduser(source); + if (!u) { + if (debug) { + alog("debug: SETNAME for nonexistent user %s", source); + } + return MOD_CONT; + } - u->SetRealname(av[0]); - return MOD_CONT; + u->SetRealname(av[0]); + return MOD_CONT; } int anope_event_chgname(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - u = finduser(av[0]); - if (!u) { - if (debug) { - alog("debug: CHGNAME for nonexistent user %s", av[0]); - } - return MOD_CONT; - } + u = finduser(av[0]); + if (!u) { + if (debug) { + alog("debug: CHGNAME for nonexistent user %s", av[0]); + } + return MOD_CONT; + } - u->SetRealname(av[1]); - return MOD_CONT; + u->SetRealname(av[1]); + return MOD_CONT; } int anope_event_setident(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 1) - return MOD_CONT; + if (ac != 1) + return MOD_CONT; - u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETIDENT for nonexistent user %s", source); - } - return MOD_CONT; - } + u = finduser(source); + if (!u) { + if (debug) { + alog("debug: SETIDENT for nonexistent user %s", source); + } + return MOD_CONT; + } - u->SetIdent(av[0]); - return MOD_CONT; + u->SetIdent(av[0]); + return MOD_CONT; } int anope_event_chgident(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - u = finduser(av[0]); - if (!u) { - if (debug) { - alog("debug: CHGIDENT for nonexistent user %s", av[0]); - } - return MOD_CONT; - } + u = finduser(av[0]); + if (!u) { + if (debug) { + alog("debug: CHGIDENT for nonexistent user %s", av[0]); + } + return MOD_CONT; + } - u->SetIdent(av[1]); - return MOD_CONT; + u->SetIdent(av[1]); + return MOD_CONT; } /* EVENT: SERVER */ int anope_event_server(const char *source, int ac, const char **av) { - if (!stricmp(av[1], "1")) { - uplink = sstrdup(av[0]); - } - do_server(source, av[0], av[1], av[2], NULL); - return MOD_CONT; + if (!stricmp(av[1], "1")) { + uplink = sstrdup(av[0]); + } + do_server(source, av[0], av[1], av[2], NULL); + return MOD_CONT; } int anope_event_privmsg(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; - m_privmsg(source, av[0], av[1]); - return MOD_CONT; + if (ac != 2) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; } int anope_event_part(const char *source, int ac, const char **av) { - if (ac < 1 || ac > 2) - return MOD_CONT; - do_part(source, ac, av); - return MOD_CONT; + if (ac < 1 || ac > 2) + return MOD_CONT; + do_part(source, ac, av); + return MOD_CONT; } int anope_event_whois(const char *source, int ac, const char **av) { - if (source && ac >= 1) { - m_whois(source, av[0]); - } - return MOD_CONT; + if (source && ac >= 1) { + m_whois(source, av[0]); + } + return MOD_CONT; } void ultimate3_cmd_topic(const char *whosets, const char *chan, const char *whosetit, - const char *topic, time_t when) + const char *topic, time_t when) { - send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit, - (unsigned long int) when, topic); + send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit, + (unsigned long int) when, topic); } void ultimate3_cmd_372(const char *source, const char *msg) { - send_cmd(ServerName, "372 %s :- %s", source, msg); + send_cmd(ServerName, "372 %s :- %s", source, msg); } void ultimate3_cmd_372_error(const char *source) { - send_cmd(ServerName, "422 %s :- MOTD file not found! Please " - "contact your IRC administrator.", source); + send_cmd(ServerName, "422 %s :- MOTD file not found! Please " + "contact your IRC administrator.", source); } void ultimate3_cmd_375(const char *source) { - send_cmd(ServerName, "375 %s :- %s Message of the Day", - source, ServerName); + send_cmd(ServerName, "375 %s :- %s Message of the Day", + source, ServerName); } void ultimate3_cmd_376(const char *source) { - send_cmd(ServerName, "376 %s :End of /MOTD command.", source); + send_cmd(ServerName, "376 %s :End of /MOTD command.", source); } void ultimate3_cmd_nick(const char *nick, const char *name, const char *modes) { - EnforceQlinedNick(nick, NULL); - send_cmd(NULL, "CLIENT %s 1 %ld %s + %s %s * %s 0 0 :%s", nick, - (long int) time(NULL), modes, ServiceUser, ServiceHost, - ServerName, name); - ultimate3_SendSQLine(nick, "Reserved for services"); + EnforceQlinedNick(nick, NULL); + send_cmd(NULL, "CLIENT %s 1 %ld %s + %s %s * %s 0 0 :%s", nick, + (long int) time(NULL), modes, ServiceUser, ServiceHost, + ServerName, name); + ultimate3_SendSQLine(nick, "Reserved for services"); } void ultimate3_SendGuestNick(const char *nick, const char *user, const char *host, - const char *real, const char *modes) + const char *real, const char *modes) { - send_cmd(NULL, "CLIENT %s 1 %ld %s + %s %s * %s 0 0 :%s", nick, - (long int) time(NULL), modes, user, host, ServerName, real); + send_cmd(NULL, "CLIENT %s 1 %ld %s + %s %s * %s 0 0 :%s", nick, + (long int) time(NULL), modes, user, host, ServerName, real); } void ultimate3_SendMode(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(source, "MODE %s %s", dest, buf); + send_cmd(source, "MODE %s %s", dest, buf); } void ultimate3_SendClientIntroduction(const char *nick, const char *user, const char *host, const char *real, - const char *modes) + const char *modes) { - EnforceQlinedNick(nick, s_BotServ); - send_cmd(NULL, "CLIENT %s 1 %ld %s + %s %s * %s 0 0 :%s", nick, - (long int) time(NULL), modes, user, host, ServerName, real); - ultimate3_SendSQLine(nick, "Reserved for services"); + EnforceQlinedNick(nick, s_BotServ); + send_cmd(NULL, "CLIENT %s 1 %ld %s + %s %s * %s 0 0 :%s", nick, + (long int) time(NULL), modes, user, host, ServerName, real); + ultimate3_SendSQLine(nick, "Reserved for services"); } void ultimate3_SendKick(const char *source, const char *chan, const char *user, const char *buf) { - if (buf) { - send_cmd(source, "KICK %s %s :%s", chan, user, buf); - } else { - send_cmd(source, "KICK %s %s", chan, user); - } + if (buf) { + send_cmd(source, "KICK %s %s :%s", chan, user, buf); + } else { + send_cmd(source, "KICK %s %s", chan, user); + } } void ultimate3_SendNoticeChanops(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "NOTICE @%s :%s", dest, buf); + send_cmd(NULL, "NOTICE @%s :%s", dest, buf); } void ultimate3_cmd_notice(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - if (NSDefFlags & NI_MSG) { - ultimate3_cmd_privmsg2(source, dest, buf); - } else { - send_cmd(source, "NOTICE %s :%s", dest, buf); - } + if (NSDefFlags & NI_MSG) { + ultimate3_cmd_privmsg2(source, dest, buf); + } else { + send_cmd(source, "NOTICE %s :%s", dest, buf); + } } void ultimate3_cmd_notice2(const char *source, const char *dest, const char *msg) { - send_cmd(source, "NOTICE %s :%s", dest, msg); + send_cmd(source, "NOTICE %s :%s", dest, msg); } void ultimate3_cmd_privmsg(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(source, "PRIVMSG %s :%s", dest, buf); + send_cmd(source, "PRIVMSG %s :%s", dest, buf); } void ultimate3_cmd_privmsg2(const char *source, const char *dest, const char *msg) { - send_cmd(source, "PRIVMSG %s :%s", dest, msg); + send_cmd(source, "PRIVMSG %s :%s", dest, msg); } void ultimate3_SendGlobalNotice(const char *source, const char *dest, const char *msg) { - send_cmd(source, "NOTICE $%s :%s", dest, msg); + send_cmd(source, "NOTICE $%s :%s", dest, msg); } void ultimate3_SendGlobalPrivmsg(const char *source, const char *dest, const char *msg) { - send_cmd(source, "PRIVMSG $%s :%s", dest, msg); + send_cmd(source, "PRIVMSG $%s :%s", dest, msg); } void ultimate3_SendBotOp(const char *nick, const char *chan) { - anope_SendMode(nick, chan, "%s %s %s", ircd->botchanumode, nick, nick); + anope_SendMode(nick, chan, "%s %s %s", ircd->botchanumode, nick, nick); } void ultimate3_cmd_351(const char *source) { - send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s (%s) -- %s", - source, version_number, ServerName, ircd->name, version_flags, - EncModule,version_build); + send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s (%s) -- %s", + source, version_number, ServerName, ircd->name, version_flags, + EncModule,version_build); } /* QUIT */ void ultimate3_SendQuit(const char *source, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - if (buf) { - send_cmd(source, "QUIT :%s", buf); - } else { - send_cmd(source, "QUIT"); - } + if (buf) { + send_cmd(source, "QUIT :%s", buf); + } else { + send_cmd(source, "QUIT"); + } } /* PROTOCTL */ void ultimate3_cmd_capab() { - send_cmd(NULL, - "CAPAB TS5 NOQUIT SSJ5 BURST UNCONNECT TSMODE NICKIP CLIENT"); + send_cmd(NULL, + "CAPAB TS5 NOQUIT SSJ5 BURST UNCONNECT TSMODE NICKIP CLIENT"); } /* PASS */ void ultimate3_cmd_pass(const char *pass) { - send_cmd(NULL, "PASS %s :TS", pass); + send_cmd(NULL, "PASS %s :TS", pass); } /* SERVER name hop descript */ /* Unreal 3.2 actually sends some info about itself in the descript area */ void ultimate3_SendServer(const char *servname, int hop, const char *descript) { - send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript); + send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript); } /* PONG */ void ultimate3_SendPong(const char *servname, const char *who) { - send_cmd(servname, "PONG %s", who); + send_cmd(servname, "PONG %s", who); } /* UNSQLINE */ void ultimate3_SendSQLineDel(const char *user) { - if (!user) { - return; - } - send_cmd(NULL, "UNSQLINE %s", user); + if (!user) { + return; + } + send_cmd(NULL, "UNSQLINE %s", user); } /* CHGHOST */ void ultimate3_cmd_chghost(const char *nick, const char *vhost) { - if (!nick || !vhost) { - return; - } - send_cmd(ServerName, "CHGHOST %s %s", nick, vhost); + if (!nick || !vhost) { + return; + } + send_cmd(ServerName, "CHGHOST %s %s", nick, vhost); } /* CHGIDENT */ void ultimate3_cmd_chgident(const char *nick, const char *vIdent) { - if (!nick || !vIdent) { - return; - } - send_cmd(ServerName, "CHGIDENT %s %s", nick, vIdent); + if (!nick || !vIdent) { + return; + } + send_cmd(ServerName, "CHGIDENT %s %s", nick, vIdent); } /* INVITE */ void ultimate3_SendInvite(const char *source, const char *chan, const char *nick) { - if (!source || !chan || !nick) { - return; - } + if (!source || !chan || !nick) { + return; + } - send_cmd(source, "INVITE %s %s", nick, chan); + send_cmd(source, "INVITE %s %s", nick, chan); } /* PART */ void ultimate3_SendPart(const char *nick, const char *chan, const char *buf) { - if (!nick || !chan) { - return; - } + if (!nick || !chan) { + return; + } - if (buf) { - send_cmd(nick, "PART %s :%s", chan, buf); - } else { - send_cmd(nick, "PART %s", chan); - } + if (buf) { + send_cmd(nick, "PART %s :%s", chan, buf); + } else { + send_cmd(nick, "PART %s", chan); + } } /* 391 */ void ultimate3_cmd_391(const char *source, const char *timestr) { - if (!timestr) { - return; - } - send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr); + if (!timestr) { + return; + } + send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr); } /* 250 */ void ultimate3_cmd_250(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "250 %s", buf); + send_cmd(NULL, "250 %s", buf); } /* 307 */ void ultimate3_cmd_307(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "307 %s", buf); + send_cmd(ServerName, "307 %s", buf); } /* 311 */ void ultimate3_cmd_311(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "311 %s", buf); + send_cmd(ServerName, "311 %s", buf); } /* 312 */ void ultimate3_cmd_312(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "312 %s", buf); + send_cmd(ServerName, "312 %s", buf); } /* 317 */ void ultimate3_cmd_317(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "317 %s", buf); + send_cmd(ServerName, "317 %s", buf); } /* 219 */ void ultimate3_cmd_219(const char *source, const char *letter) { - if (!source) { - return; - } + if (!source) { + return; + } - if (letter) { - send_cmd(NULL, "219 %s %c :End of /STATS report.", source, - *letter); - } else { - send_cmd(NULL, "219 %s l :End of /STATS report.", source); - } + if (letter) { + send_cmd(NULL, "219 %s %c :End of /STATS report.", source, + *letter); + } else { + send_cmd(NULL, "219 %s l :End of /STATS report.", source); + } } /* 401 */ void ultimate3_cmd_401(const char *source, const char *who) { - if (!source || !who) { - return; - } - send_cmd(ServerName, "401 %s %s :No such service.", source, who); + if (!source || !who) { + return; + } + send_cmd(ServerName, "401 %s %s :No such service.", source, who); } /* 318 */ void ultimate3_cmd_318(const char *source, const char *who) { - if (!source || !who) { - return; - } + if (!source || !who) { + return; + } - send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who); + send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who); } /* 242 */ void ultimate3_cmd_242(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "242 %s", buf); + send_cmd(NULL, "242 %s", buf); } /* 243 */ void ultimate3_cmd_243(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "243 %s", buf); + send_cmd(NULL, "243 %s", buf); } /* 211 */ void ultimate3_cmd_211(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "211 %s", buf); + send_cmd(NULL, "211 %s", buf); } /* GLOBOPS */ void ultimate3_SendGlobops(const char *source, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf); + send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf); } /* SQUIT */ void ultimate3_SendSquit(const char *servname, const char *message) { - if (!servname || !message) { - return; - } + if (!servname || !message) { + return; + } - send_cmd(NULL, "SQUIT %s :%s", servname, message); + send_cmd(NULL, "SQUIT %s :%s", servname, message); } /* SVSO */ void ultimate3_SendSVSO(const char *source, const char *nick, const char *flag) { - if (!source || !nick || !flag) { - return; - } + if (!source || !nick || !flag) { + return; + } - send_cmd(source, "SVSO %s %s", nick, flag); + send_cmd(source, "SVSO %s %s", nick, flag); } /* NICK <newnick> */ void ultimate3_SendChangeBotNick(const char *oldnick, const char *newnick) { - if (!oldnick || !newnick) { - return; - } + if (!oldnick || !newnick) { + return; + } - send_cmd(oldnick, "NICK %s", newnick); + send_cmd(oldnick, "NICK %s", newnick); } /* SVSNICK */ void ultimate3_SendForceNickChange(const char *source, const char *guest, time_t when) { - if (!source || !guest) { - return; - } - send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, (long int) when); + if (!source || !guest) { + return; + } + send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, (long int) when); } /* Functions that use serval cmd functions */ /* * SVINFO - * parv[0] = sender prefix - * parv[1] = TS_CURRENT for the server - * parv[2] = TS_MIN for the server - * parv[3] = server is standalone or connected to non-TS only - * parv[4] = server's idea of UTC time + * parv[0] = sender prefix + * parv[1] = TS_CURRENT for the server + * parv[2] = TS_MIN for the server + * parv[3] = server is standalone or connected to non-TS only + * parv[4] = server's idea of UTC time */ void ultimate3_cmd_svinfo() { - send_cmd(NULL, "SVINFO 5 3 0 :%ld", (long int) time(NULL)); + send_cmd(NULL, "SVINFO 5 3 0 :%ld", (long int) time(NULL)); } void ultimate3_cmd_burst() { - send_cmd(NULL, "BURST"); + send_cmd(NULL, "BURST"); } void ultimate3_SendConnect(int servernum) { - me_server = - new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); - if (servernum == 1) { - ultimate3_cmd_pass(RemotePassword); - } - if (servernum == 2) { - ultimate3_cmd_pass(RemotePassword2); - } - if (servernum == 3) { - ultimate3_cmd_pass(RemotePassword3); - } - ultimate3_cmd_capab(); - ultimate3_SendServer(ServerName, 1, ServerDesc); - ultimate3_cmd_svinfo(); - ultimate3_cmd_burst(); + if (servernum == 1) { + ultimate3_cmd_pass(RemotePassword); + } + if (servernum == 2) { + ultimate3_cmd_pass(RemotePassword2); + } + if (servernum == 3) { + ultimate3_cmd_pass(RemotePassword3); + } + ultimate3_cmd_capab(); + ultimate3_SendServer(ServerName, 1, ServerDesc); + ultimate3_cmd_svinfo(); + ultimate3_cmd_burst(); } /* SVSHOLD - set */ void ultimate3_SendSVSHOLD(const char *nick) { - /* Not supported by this IRCD */ + /* Not supported by this IRCD */ } /* SVSHOLD - release */ void ultimate3_SendSVSHOLDDel(const char *nick) { - /* Not Supported by this IRCD */ + /* Not Supported by this IRCD */ } /* SVSMODE +d */ /* sent if svid is something weird */ void ultimate3_SendSVID(const char *nick, time_t ts) { - send_cmd(ServerName, "SVSMODE %s %lu +d 1", nick, - (unsigned long int) ts); + send_cmd(ServerName, "SVSMODE %s %lu +d 1", nick, + (unsigned long int) ts); } /* SVSMODE +d */ /* nc_change was = 1, and there is no na->status */ void ultimate3_SendUnregisteredNick(User * u) { - common_svsmode(u, "+d", "1"); + common_svsmode(u, "+d", "1"); } /* SVSMODE +d */ void ultimate3_SendSVID2(User * u, const char *ts) { - /* not used by bahamut ircds */ + /* not used by bahamut ircds */ } void ultimate3_SendSVID3(User * u, const char *ts) { - if (u->svid != u->timestamp) { - common_svsmode(u, "+rd", ts); - } else { - common_svsmode(u, "+r", NULL); - } + if (u->svid != u->timestamp) { + common_svsmode(u, "+rd", ts); + } else { + common_svsmode(u, "+r", NULL); + } } int anope_event_svinfo(const char *source, int ac, const char **av) { - /* currently not used but removes the message : unknown message from server */ - return MOD_CONT; + /* currently not used but removes the message : unknown message from server */ + return MOD_CONT; } int anope_event_pass(const char *source, int ac, const char **av) { - /* currently not used but removes the message : unknown message from server */ - return MOD_CONT; + /* currently not used but removes the message : unknown message from server */ + return MOD_CONT; } int anope_event_gnotice(const char *source, int ac, const char **av) { - /* currently not used but removes the message : unknown message from server */ - return MOD_CONT; + /* currently not used but removes the message : unknown message from server */ + return MOD_CONT; } int anope_event_netctrl(const char *source, int ac, const char **av) { - /* currently not used but removes the message : unknown message from server */ - return MOD_CONT; + /* currently not used but removes the message : unknown message from server */ + return MOD_CONT; } int anope_event_notice(const char *source, int ac, const char **av) { - /* currently not used but removes the message : unknown message from server */ - return MOD_CONT; + /* currently not used but removes the message : unknown message from server */ + return MOD_CONT; } int anope_event_sqline(const char *source, int ac, const char **av) { - /* currently not used but removes the message : unknown message from server */ - return MOD_CONT; + /* currently not used but removes the message : unknown message from server */ + return MOD_CONT; } void ultimate3_SendSVSJoin(const char *source, const char *nick, const char *chan, const char *param) { - /* Not Supported by this IRCD */ + /* Not Supported by this IRCD */ } void ultimate3_SendSVSPart(const char *source, const char *nick, const char *chan) { - /* Not Supported by this IRCD */ + /* Not Supported by this IRCD */ } void ultimate3_SendSWhois(const char *source, const char *who, const char *mask) { - /* not supported */ + /* not supported */ } void ultimate3_SendEOB() { - send_cmd(NULL, "BURST 0"); + send_cmd(NULL, "BURST 0"); } int anope_event_error(const char *source, int ac, const char **av) { - if (ac >= 1) { - if (debug) { - alog("debug: %s", av[0]); - } - } - return MOD_CONT; + if (ac >= 1) { + if (debug) { + alog("debug: %s", av[0]); + } + } + return MOD_CONT; } int anope_event_eob(const char *source, int ac, const char **av) { - Server *s; + Server *s; - if (ac == 1) { - s = findserver(servlist, av[0]); - /* If we found a server with the given source, that one just - * finished bursting. If there was no source, then our uplink - * server finished bursting. -GD - */ - if (!s && serv_uplink) - s = serv_uplink; - finish_sync(s, 1); - } - return MOD_CONT; + if (ac == 1) { + s = findserver(servlist, av[0]); + /* If we found a server with the given source, that one just + * finished bursting. If there was no source, then our uplink + * server finished bursting. -GD + */ + if (!s && serv_uplink) + s = serv_uplink; + finish_sync(s, 1); + } + return MOD_CONT; } int anope_event_burst(const char *source, int ac, const char **av) { - Server *s; - s = findserver(servlist, source); - if (!ac) { - /* for future use - start burst */ - } else { - /* If we found a server with the given source, that one just - * finished bursting. If there was no source, then our uplink - * server finished bursting. -GD - */ - if (!s && serv_uplink) - s = serv_uplink; - finish_sync(s, 1); - } - return MOD_CONT; + Server *s; + s = findserver(servlist, source); + if (!ac) { + /* for future use - start burst */ + } else { + /* If we found a server with the given source, that one just + * finished bursting. If there was no source, then our uplink + * server finished bursting. -GD + */ + if (!s && serv_uplink) + s = serv_uplink; + finish_sync(s, 1); + } + return MOD_CONT; } int anope_event_rehash(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_credits(char *source, int ac, char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_admin(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_netglobal(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_invite(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int ultiamte3_IsFloodModeParamValid(const char *value) { - return 0; + return 0; } void ultimate3_SendJupe(const char *jserver, const char *who, const char *reason) { - char rbuf[256]; + char rbuf[256]; - snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who, - reason ? ": " : "", reason ? reason : ""); + snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who, + reason ? ": " : "", reason ? reason : ""); - if (findserver(servlist, jserver)) - ultimate3_SendSquit(jserver, rbuf); - ultimate3_SendServer(jserver, 2, rbuf); - new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL); + if (findserver(servlist, jserver)) + ultimate3_SendSquit(jserver, rbuf); + ultimate3_SendServer(jserver, 2, rbuf); + new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL); } /* GLOBOPS - to handle old WALLOPS */ void ultimate3_SendGlobops_legacy(const char *source, const char *fmt) { - send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt); + send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt); } /* @@ -1667,8 +1667,8 @@ void ultimate3_SendGlobops_legacy(const char *source, const char *fmt) */ int ultiamte3_IsNickValid(const char *nick) { - /* no hard coded invalid nicks */ - return 1; + /* no hard coded invalid nicks */ + return 1; } /* @@ -1677,23 +1677,23 @@ int ultiamte3_IsNickValid(const char *nick) */ int ultiamte3_IsChannelValid(const char *chan) { - /* no hard coded invalid chans */ - return 1; + /* no hard coded invalid chans */ + return 1; } void ultimate3_SendCTCP(const char *source, const char *dest, const char *buf) { - char *s; + char *s; - if (!buf) { - return; - } else { - s = normalizeBuffer(buf); - } + if (!buf) { + return; + } else { + s = normalizeBuffer(buf); + } - send_cmd(source, "NOTICE %s :\1%s \1", dest, s); - free(s); + send_cmd(source, "NOTICE %s :\1%s \1", dest, s); + free(s); } @@ -1703,78 +1703,78 @@ void ultimate3_SendCTCP(const char *source, const char *dest, const char *buf) **/ void moduleAddAnopeCmds() { - pmodule_cmd_topic(ultimate3_cmd_topic); - pmodule_SendVhostDel(ultimate3_cmd_vhost_off); - pmodule_SendAkill(ultimate3_cmd_akill); - pmodule_SendSVSKill(ultimate3_SendSVSKill); - pmodule_SendSVSMode(ultimate3_cmd_svsmode); - pmodule_cmd_372(ultimate3_cmd_372); - pmodule_cmd_372_error(ultimate3_cmd_372_error); - pmodule_cmd_375(ultimate3_cmd_375); - pmodule_cmd_376(ultimate3_cmd_376); - pmodule_cmd_nick(ultimate3_cmd_nick); - pmodule_SendGuestNick(ultimate3_cmd_guest_nick); - pmodule_SendMode(ultimate3_cmd_mode); - pmodule_SendClientIntroduction(ultimate3_cmd_bot_nick); - pmodule_SendKick(ultimate3_cmd_kick); - pmodule_SendNoticeChanops(ultimate3_cmd_notice_ops); - pmodule_cmd_notice(ultimate3_cmd_notice); - pmodule_cmd_notice2(ultimate3_cmd_notice2); - pmodule_cmd_privmsg(ultimate3_cmd_privmsg); - pmodule_cmd_privmsg2(ultimate3_cmd_privmsg2); - pmodule_SendGlobalNotice(ultimate3_cmd_serv_notice); - pmodule_SendGlobalPrivmsg(ultimate3_cmd_serv_privmsg); - pmodule_SendBotOp(ultimate3_cmd_bot_chan_mode); - pmodule_cmd_351(ultimate3_cmd_351); - pmodule_SendQuit(ultimate3_cmd_quit); - pmodule_SendPong(ultimate3_cmd_pong); - pmodule_SendJoin(ultimate3_cmd_join); - pmodule_SendSQLineDel(ultimate3_cmd_unsqline); - pmodule_SendInvite(ultimate3_cmd_invite); - pmodule_SendPart(ultimate3_cmd_part); - pmodule_cmd_391(ultimate3_cmd_391); - pmodule_cmd_250(ultimate3_cmd_250); - pmodule_cmd_307(ultimate3_cmd_307); - pmodule_cmd_311(ultimate3_cmd_311); - pmodule_cmd_312(ultimate3_cmd_312); - pmodule_cmd_317(ultimate3_cmd_317); - pmodule_cmd_219(ultimate3_cmd_219); - pmodule_cmd_401(ultimate3_cmd_401); - pmodule_cmd_318(ultimate3_cmd_318); - pmodule_cmd_242(ultimate3_cmd_242); - pmodule_cmd_243(ultimate3_cmd_243); - pmodule_cmd_211(ultimate3_cmd_211); - pmodule_SendGlobops(ultimate3_cmd_global); - pmodule_SendGlobops_legacy(ultimate3_cmd_global_legacy); - pmodule_SendSQLine(ultimate3_cmd_sqline); - pmodule_SendSquit(ultimate3_cmd_squit); - pmodule_SendSVSO(ultimate3_cmd_svso); - pmodule_SendChangeBotNick(ultimate3_cmd_chg_nick); - pmodule_SendForceNickChange(ultimate3_cmd_svsnick); - pmodule_SendVhost(ultimate3_cmd_vhost_on); - pmodule_SendConnect(ultimate3_cmd_connect); - pmodule_SendSVSHOLD(ultimate3_cmd_svshold); - pmodule_SendSVSHOLDDel(ultimate3_cmd_release_svshold); - pmodule_SendSGLineDel(ultimate3_cmd_unsgline); - pmodule_SendSZLineDel(ultimate3_cmd_unszline); - pmodule_SendSZLine(ultimate3_cmd_szline); - pmodule_SendSGLine(ultimate3_cmd_sgline); - pmodule_SendBanDel(ultimate3_cmd_unban); - pmodule_SendSVSMode_chan(ultimate3_cmd_svsmode_chan); - pmodule_SendSVID(ultimate3_cmd_svid_umode); - pmodule_SendUnregisteredNick(ultimate3_cmd_nc_change); - pmodule_SendSVID2(ultimate3_cmd_svid_umode2); - pmodule_SendSVID3(ultimate3_cmd_svid_umode3); - pmodule_SendSVSJoin(ultimate3_cmd_svsjoin); - pmodule_SendSVSPart(ultimate3_cmd_svspart); - pmodule_SendSWhois(ultimate3_cmd_swhois); - pmodule_SendEOB(ultimate3_cmd_eob); - pmodule_IsFloodModeParamValid(ultiamte3_flood_mode_check); - pmodule_SendJupe(ultimate3_cmd_jupe); - pmodule_IsNickValid(ultiamte3_valid_nick); - pmodule_IsChannelValid(ultiamte3_valid_chan); - pmodule_SendCTCP(ultimate3_cmd_ctcp); - pmodule_ProcessUsermodes(ultimate3_set_umode); + pmodule_cmd_topic(ultimate3_cmd_topic); + pmodule_SendVhostDel(ultimate3_cmd_vhost_off); + pmodule_SendAkill(ultimate3_cmd_akill); + pmodule_SendSVSKill(ultimate3_SendSVSKill); + pmodule_SendSVSMode(ultimate3_cmd_svsmode); + pmodule_cmd_372(ultimate3_cmd_372); + pmodule_cmd_372_error(ultimate3_cmd_372_error); + pmodule_cmd_375(ultimate3_cmd_375); + pmodule_cmd_376(ultimate3_cmd_376); + pmodule_cmd_nick(ultimate3_cmd_nick); + pmodule_SendGuestNick(ultimate3_cmd_guest_nick); + pmodule_SendMode(ultimate3_cmd_mode); + pmodule_SendClientIntroduction(ultimate3_cmd_bot_nick); + pmodule_SendKick(ultimate3_cmd_kick); + pmodule_SendNoticeChanops(ultimate3_cmd_notice_ops); + pmodule_cmd_notice(ultimate3_cmd_notice); + pmodule_cmd_notice2(ultimate3_cmd_notice2); + pmodule_cmd_privmsg(ultimate3_cmd_privmsg); + pmodule_cmd_privmsg2(ultimate3_cmd_privmsg2); + pmodule_SendGlobalNotice(ultimate3_cmd_serv_notice); + pmodule_SendGlobalPrivmsg(ultimate3_cmd_serv_privmsg); + pmodule_SendBotOp(ultimate3_cmd_bot_chan_mode); + pmodule_cmd_351(ultimate3_cmd_351); + pmodule_SendQuit(ultimate3_cmd_quit); + pmodule_SendPong(ultimate3_cmd_pong); + pmodule_SendJoin(ultimate3_cmd_join); + pmodule_SendSQLineDel(ultimate3_cmd_unsqline); + pmodule_SendInvite(ultimate3_cmd_invite); + pmodule_SendPart(ultimate3_cmd_part); + pmodule_cmd_391(ultimate3_cmd_391); + pmodule_cmd_250(ultimate3_cmd_250); + pmodule_cmd_307(ultimate3_cmd_307); + pmodule_cmd_311(ultimate3_cmd_311); + pmodule_cmd_312(ultimate3_cmd_312); + pmodule_cmd_317(ultimate3_cmd_317); + pmodule_cmd_219(ultimate3_cmd_219); + pmodule_cmd_401(ultimate3_cmd_401); + pmodule_cmd_318(ultimate3_cmd_318); + pmodule_cmd_242(ultimate3_cmd_242); + pmodule_cmd_243(ultimate3_cmd_243); + pmodule_cmd_211(ultimate3_cmd_211); + pmodule_SendGlobops(ultimate3_cmd_global); + pmodule_SendGlobops_legacy(ultimate3_cmd_global_legacy); + pmodule_SendSQLine(ultimate3_cmd_sqline); + pmodule_SendSquit(ultimate3_cmd_squit); + pmodule_SendSVSO(ultimate3_cmd_svso); + pmodule_SendChangeBotNick(ultimate3_cmd_chg_nick); + pmodule_SendForceNickChange(ultimate3_cmd_svsnick); + pmodule_SendVhost(ultimate3_cmd_vhost_on); + pmodule_SendConnect(ultimate3_cmd_connect); + pmodule_SendSVSHOLD(ultimate3_cmd_svshold); + pmodule_SendSVSHOLDDel(ultimate3_cmd_release_svshold); + pmodule_SendSGLineDel(ultimate3_cmd_unsgline); + pmodule_SendSZLineDel(ultimate3_cmd_unszline); + pmodule_SendSZLine(ultimate3_cmd_szline); + pmodule_SendSGLine(ultimate3_cmd_sgline); + pmodule_SendBanDel(ultimate3_cmd_unban); + pmodule_SendSVSMode_chan(ultimate3_cmd_svsmode_chan); + pmodule_SendSVID(ultimate3_cmd_svid_umode); + pmodule_SendUnregisteredNick(ultimate3_cmd_nc_change); + pmodule_SendSVID2(ultimate3_cmd_svid_umode2); + pmodule_SendSVID3(ultimate3_cmd_svid_umode3); + pmodule_SendSVSJoin(ultimate3_cmd_svsjoin); + pmodule_SendSVSPart(ultimate3_cmd_svspart); + pmodule_SendSWhois(ultimate3_cmd_swhois); + pmodule_SendEOB(ultimate3_cmd_eob); + pmodule_IsFloodModeParamValid(ultiamte3_flood_mode_check); + pmodule_SendJupe(ultimate3_cmd_jupe); + pmodule_IsNickValid(ultiamte3_valid_nick); + pmodule_IsChannelValid(ultiamte3_valid_chan); + pmodule_SendCTCP(ultimate3_cmd_ctcp); + pmodule_ProcessUsermodes(ultimate3_set_umode); } /** @@ -1783,35 +1783,35 @@ void moduleAddAnopeCmds() int AnopeInit(int argc, char **argv) { - this->SetAuthor("Anope"); - this->SetVersion - ("$Id$"); - this->SetType(PROTOCOL); - - pmodule_ircd_version("UltimateIRCd 3.0.0.a26+"); - pmodule_ircd_cap(myIrcdcap); - pmodule_ircd_var(myIrcd); - pmodule_ircd_cbmodeinfos(myCbmodeinfos); - pmodule_ircd_cumodes(myCumodes); - pmodule_ircd_flood_mode_char_set(""); - pmodule_ircd_flood_mode_char_remove(""); - pmodule_ircd_cbmodes(myCbmodes); - pmodule_ircd_cmmodes(myCmmodes); - pmodule_ircd_csmodes(myCsmodes); - pmodule_ircd_useTSMode(0); - - /** Deal with modes anope _needs_ to know **/ - pmodule_invis_umode(UMODE_i); - pmodule_oper_umode(UMODE_o); - pmodule_invite_cmode(CMODE_i); - pmodule_secret_cmode(CMODE_s); - pmodule_private_cmode(CMODE_p); - pmodule_key_mode(CMODE_k); - pmodule_limit_mode(CMODE_l); - - moduleAddAnopeCmds(); + this->SetAuthor("Anope"); + this->SetVersion + ("$Id$"); + this->SetType(PROTOCOL); + + pmodule_ircd_version("UltimateIRCd 3.0.0.a26+"); + pmodule_ircd_cap(myIrcdcap); + pmodule_ircd_var(myIrcd); + pmodule_ircd_cbmodeinfos(myCbmodeinfos); + pmodule_ircd_cumodes(myCumodes); + pmodule_ircd_flood_mode_char_set(""); + pmodule_ircd_flood_mode_char_remove(""); + pmodule_ircd_cbmodes(myCbmodes); + pmodule_ircd_cmmodes(myCmmodes); + pmodule_ircd_csmodes(myCsmodes); + pmodule_ircd_useTSMode(0); + + /** Deal with modes anope _needs_ to know **/ + pmodule_invis_umode(UMODE_i); + pmodule_oper_umode(UMODE_o); + pmodule_invite_cmode(CMODE_i); + pmodule_secret_cmode(CMODE_s); + pmodule_private_cmode(CMODE_p); + pmodule_key_mode(CMODE_k); + pmodule_limit_mode(CMODE_l); + + moduleAddAnopeCmds(); pmodule_ircd_proto(&ircd_proto); - moduleAddIRCDMsgs(); + moduleAddIRCDMsgs(); - return MOD_CONT; + return MOD_CONT; } diff --git a/src/protocol/obsolete/ultimate3.h b/src/protocol/obsolete/ultimate3.h index a67dc8e5f..de7683a21 100644 --- a/src/protocol/obsolete/ultimate3.h +++ b/src/protocol/obsolete/ultimate3.h @@ -46,8 +46,8 @@ #define CMODE_S 0x00002000 #define CMODE_K 0x00004000 #define CMODE_O 0x00008000 /* Only opers can join */ -#define CMODE_q 0x00010000 /* No Quit Reason */ -#define CMODE_M 0x00020000 /* Non-regged nicks can't send messages */ +#define CMODE_q 0x00010000 /* No Quit Reason */ +#define CMODE_M 0x00020000 /* Non-regged nicks can't send messages */ #define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r diff --git a/src/protocol/obsolete/viagra.c b/src/protocol/obsolete/viagra.c index eaacb2c21..dfe3454cd 100644 --- a/src/protocol/obsolete/viagra.c +++ b/src/protocol/obsolete/viagra.c @@ -17,133 +17,133 @@ #include "viagra.h" IRCDVar myIrcd[] = { - {"ViagraIRCd 1.3.*", /* ircd name */ - "+oS", /* nickserv mode */ - "+oS", /* chanserv mode */ - "+oS", /* memoserv mode */ - "+oS", /* hostserv mode */ - "+ioS", /* operserv mode */ - "+oS", /* botserv mode */ - "+oS", /* helpserv mode */ - "+i", /* Dev/Null mode */ - "+ioS", /* Global mode */ - "+oS", /* nickserv alias mode */ - "+oS", /* chanserv alias mode */ - "+oS", /* memoserv alias mode */ - "+ioS", /* hostserv alias mode */ - "+ioS", /* operserv alias mode */ - "+oS", /* botserv alias mode */ - "+oS", /* helpserv alias mode */ - "+iS", /* Dev/Null alias mode */ - "+ioS", /* Global alias mode */ - "+qS", /* Used by BotServ Bots */ - 5, /* Chan Max Symbols */ - "-ciklmnpstOR", /* Modes to Remove */ - "+ao", /* Channel Umode used by Botserv bots */ - 1, /* SVSNICK */ - 1, /* Vhost */ - 1, /* Has Owner */ - "+q", /* Mode to set for an owner */ - "-q", /* Mode to unset for an owner */ - "+a", /* Mode to set for channel admin */ - "-a", /* Mode to unset for channel admin */ - "+rd", /* Mode On Reg */ - NULL, /* Mode on ID for Roots */ - NULL, /* Mode on ID for Admins */ - NULL, /* Mode on ID for Opers */ - "-r+d", /* Mode on UnReg */ - "-r+d", /* Mode on Nick Change */ - 1, /* Supports SGlines */ - 1, /* Supports SQlines */ - 1, /* Supports SZlines */ - 1, /* Supports Halfop +h */ - 3, /* Number of server args */ - 0, /* Join 2 Set */ - 0, /* Join 2 Message */ - 1, /* Has exceptions +e */ - 0, /* TS Topic Forward */ - 0, /* TS Topci Backward */ - 0, /* Protected Umode */ - 1, /* Has Admin */ - 0, /* Chan SQlines */ - 1, /* Quit on Kill */ - 1, /* SVSMODE unban */ - 1, /* Has Protect */ - 0, /* Reverse */ - 1, /* Chan Reg */ - CMODE_r, /* Channel Mode */ - 1, /* vidents */ - 0, /* svshold */ - 1, /* time stamp on mode */ - 1, /* NICKIP */ - 0, /* O:LINE */ - 1, /* UMODE */ - 1, /* VHOST ON NICK */ - 1, /* Change RealName */ - 0, /* No Knock */ - 0, /* Admin Only */ - DEFAULT_MLOCK, /* Default MLOCK */ - UMODE_x, /* Vhost Mode */ - 0, /* +f */ - 0, /* +L */ - 0, - 0, - 1, - 1, /* No Knock requires +i */ - NULL, /* CAPAB Chan Modes */ - 0, /* We support TOKENS */ - 1, /* TOKENS are CASE inSensitive */ - 0, /* TIME STAMPS are BASE64 */ - 0, /* +I support */ - 0, /* SJOIN ban char */ - 0, /* SJOIN except char */ - 0, /* SJOIN invite char */ - 0, /* Can remove User Channel Modes with SVSMODE */ - 0, /* Sglines are not enforced until user reconnects */ - "x", /* vhost char */ - 0, /* ts6 */ - 1, /* support helper umode */ - 0, /* p10 */ - NULL, /* character set */ - 1, /* reports sync state */ - 0, /* CIDR channelbans */ - } - , - {NULL} + {"ViagraIRCd 1.3.*", /* ircd name */ + "+oS", /* nickserv mode */ + "+oS", /* chanserv mode */ + "+oS", /* memoserv mode */ + "+oS", /* hostserv mode */ + "+ioS", /* operserv mode */ + "+oS", /* botserv mode */ + "+oS", /* helpserv mode */ + "+i", /* Dev/Null mode */ + "+ioS", /* Global mode */ + "+oS", /* nickserv alias mode */ + "+oS", /* chanserv alias mode */ + "+oS", /* memoserv alias mode */ + "+ioS", /* hostserv alias mode */ + "+ioS", /* operserv alias mode */ + "+oS", /* botserv alias mode */ + "+oS", /* helpserv alias mode */ + "+iS", /* Dev/Null alias mode */ + "+ioS", /* Global alias mode */ + "+qS", /* Used by BotServ Bots */ + 5, /* Chan Max Symbols */ + "-ciklmnpstOR", /* Modes to Remove */ + "+ao", /* Channel Umode used by Botserv bots */ + 1, /* SVSNICK */ + 1, /* Vhost */ + 1, /* Has Owner */ + "+q", /* Mode to set for an owner */ + "-q", /* Mode to unset for an owner */ + "+a", /* Mode to set for channel admin */ + "-a", /* Mode to unset for channel admin */ + "+rd", /* Mode On Reg */ + NULL, /* Mode on ID for Roots */ + NULL, /* Mode on ID for Admins */ + NULL, /* Mode on ID for Opers */ + "-r+d", /* Mode on UnReg */ + "-r+d", /* Mode on Nick Change */ + 1, /* Supports SGlines */ + 1, /* Supports SQlines */ + 1, /* Supports SZlines */ + 1, /* Supports Halfop +h */ + 3, /* Number of server args */ + 0, /* Join 2 Set */ + 0, /* Join 2 Message */ + 1, /* Has exceptions +e */ + 0, /* TS Topic Forward */ + 0, /* TS Topci Backward */ + 0, /* Protected Umode */ + 1, /* Has Admin */ + 0, /* Chan SQlines */ + 1, /* Quit on Kill */ + 1, /* SVSMODE unban */ + 1, /* Has Protect */ + 0, /* Reverse */ + 1, /* Chan Reg */ + CMODE_r, /* Channel Mode */ + 1, /* vidents */ + 0, /* svshold */ + 1, /* time stamp on mode */ + 1, /* NICKIP */ + 0, /* O:LINE */ + 1, /* UMODE */ + 1, /* VHOST ON NICK */ + 1, /* Change RealName */ + 0, /* No Knock */ + 0, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + UMODE_x, /* Vhost Mode */ + 0, /* +f */ + 0, /* +L */ + 0, + 0, + 1, + 1, /* No Knock requires +i */ + NULL, /* CAPAB Chan Modes */ + 0, /* We support TOKENS */ + 1, /* TOKENS are CASE inSensitive */ + 0, /* TIME STAMPS are BASE64 */ + 0, /* +I support */ + 0, /* SJOIN ban char */ + 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ + 0, /* Can remove User Channel Modes with SVSMODE */ + 0, /* Sglines are not enforced until user reconnects */ + "x", /* vhost char */ + 0, /* ts6 */ + 1, /* support helper umode */ + 0, /* p10 */ + NULL, /* character set */ + 1, /* reports sync state */ + 0, /* CIDR channelbans */ + } + , + {NULL} }; IRCDCAPAB myIrcdcap[] = { - { - CAPAB_NOQUIT, /* NOQUIT */ - CAPAB_TSMODE, /* TSMODE */ - CAPAB_UNCONNECT, /* UNCONNECT */ - CAPAB_NICKIP, /* NICKIP */ - CAPAB_NSJOIN, /* SJOIN */ - CAPAB_ZIP, /* ZIP */ - CAPAB_BURST, /* BURST */ - CAPAB_TS5, /* TS5 */ - CAPAB_TS3, /* TS3 */ - CAPAB_DKEY, /* DKEY */ - 0, /* PT4 */ - 0, /* SCS */ - 0, /* QS */ - 0, /* UID */ - 0, /* KNOCK */ - 0, /* CLIENT */ - 0, /* IPV6 */ - 0, /* SSJ5 */ - 0, /* SN2 */ - 0, /* TOKEN */ - 0, /* VHOST */ - 0, /* SSJ3 */ - 0, /* NICK2 */ - 0, /* UMODE2 */ - 0, /* VL */ - 0, /* TLKEXT */ - CAPAB_DODKEY, /* DODKEY */ - CAPAB_DOZIP, /* DOZIP */ - 0, 0, 0} + { + CAPAB_NOQUIT, /* NOQUIT */ + CAPAB_TSMODE, /* TSMODE */ + CAPAB_UNCONNECT, /* UNCONNECT */ + CAPAB_NICKIP, /* NICKIP */ + CAPAB_NSJOIN, /* SJOIN */ + CAPAB_ZIP, /* ZIP */ + CAPAB_BURST, /* BURST */ + CAPAB_TS5, /* TS5 */ + CAPAB_TS3, /* TS3 */ + CAPAB_DKEY, /* DKEY */ + 0, /* PT4 */ + 0, /* SCS */ + 0, /* QS */ + 0, /* UID */ + 0, /* KNOCK */ + 0, /* CLIENT */ + 0, /* IPV6 */ + 0, /* SSJ5 */ + 0, /* SN2 */ + 0, /* TOKEN */ + 0, /* VHOST */ + 0, /* SSJ3 */ + 0, /* NICK2 */ + 0, /* UMODE2 */ + 0, /* VL */ + 0, /* TLKEXT */ + CAPAB_DODKEY, /* DODKEY */ + CAPAB_DOZIP, /* DOZIP */ + 0, 0, 0} }; @@ -151,364 +151,364 @@ IRCDCAPAB myIrcdcap[] = { void viagra_ProcessUsermodes(User * user, int ac, const char **av) { - int add = 1; /* 1 if adding modes, 0 if deleting */ - const char *modes = av[0]; - - ac--; - - if (debug) - alog("debug: Changing mode for %s to %s", user->nick, modes); - - while (*modes) { - - /* This looks better, much better than "add ? (do_add) : (do_remove)". - * At least this is readable without paying much attention :) -GD - */ - if (add) - user->mode |= umodes[(int) *modes]; - else - user->mode &= ~umodes[(int) *modes]; - - switch (*modes++) { - case '+': - add = 1; - break; - case '-': - add = 0; - break; - case 'd': - if (ac == 0) { - alog("user: umode +d with no parameter (?) for user %s", - user->nick); - break; - } - - ac--; - av++; - user->svid = strtoul(*av, NULL, 0); - break; - case 'o': - if (add) { - opcnt++; - if (WallOper) { - anope_SendGlobops(s_OperServ, - "\2%s\2 is now an IRC operator.", - user->nick); - } - display_news(user, NEWS_OPER); - } else { - opcnt--; - } - break; - case 'r': - if (add && !nick_identified(user)) { - common_svsmode(user, "-r", NULL); - user->mode &= ~UMODE_r; - } - break; - case 'x': - update_host(user); - break; - } - } + int add = 1; /* 1 if adding modes, 0 if deleting */ + const char *modes = av[0]; + + ac--; + + if (debug) + alog("debug: Changing mode for %s to %s", user->nick, modes); + + while (*modes) { + + /* This looks better, much better than "add ? (do_add) : (do_remove)". + * At least this is readable without paying much attention :) -GD + */ + if (add) + user->mode |= umodes[(int) *modes]; + else + user->mode &= ~umodes[(int) *modes]; + + switch (*modes++) { + case '+': + add = 1; + break; + case '-': + add = 0; + break; + case 'd': + if (ac == 0) { + alog("user: umode +d with no parameter (?) for user %s", + user->nick); + break; + } + + ac--; + av++; + user->svid = strtoul(*av, NULL, 0); + break; + case 'o': + if (add) { + opcnt++; + if (WallOper) { + anope_SendGlobops(s_OperServ, + "\2%s\2 is now an IRC operator.", + user->nick); + } + display_news(user, NEWS_OPER); + } else { + opcnt--; + } + break; + case 'r': + if (add && !nick_identified(user)) { + common_svsmode(user, "-r", NULL); + user->mode &= ~UMODE_r; + } + break; + case 'x': + update_host(user); + break; + } + } } unsigned long umodes[128] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, UMODE_A, 0, UMODE_C, 0, 0, 0, 0, 0, UMODE_I, 0, 0, 0, 0, UMODE_N, - UMODE_O, - 0, - UMODE_Q, - UMODE_R, - UMODE_S, UMODE_T, 0, 0, 0, 0, 0, - 0, - 0, 0, 0, 0, 0, - 0, UMODE_a, UMODE_b, UMODE_c, UMODE_d, UMODE_e, UMODE_f, - UMODE_g, - UMODE_h, UMODE_i, 0, 0, 0, 0, UMODE_n, UMODE_o, - 0, - 0, UMODE_r, UMODE_s, 0, 0, 0, UMODE_w, - UMODE_x, - 0, - 0, - 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, UMODE_A, 0, UMODE_C, 0, 0, 0, 0, 0, UMODE_I, 0, 0, 0, 0, UMODE_N, + UMODE_O, + 0, + UMODE_Q, + UMODE_R, + UMODE_S, UMODE_T, 0, 0, 0, 0, 0, + 0, + 0, 0, 0, 0, 0, + 0, UMODE_a, UMODE_b, UMODE_c, UMODE_d, UMODE_e, UMODE_f, + UMODE_g, + UMODE_h, UMODE_i, 0, 0, 0, 0, UMODE_n, UMODE_o, + 0, + 0, UMODE_r, UMODE_s, 0, 0, 0, UMODE_w, + UMODE_x, + 0, + 0, + 0, 0, 0, 0, 0 }; char myCsmodes[128] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, 0, 0, - 'h', /* (37) % Channel halfops */ - 0, /* (38) & bans */ - 0, 0, 0, - 'q', + 0, + 0, + 0, 0, 0, + 'h', /* (37) % Channel halfops */ + 0, /* (38) & bans */ + 0, 0, 0, + 'q', - 'v', 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'v', 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'a', 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'a', 0 }; CMMode myCmmodes[128] = { - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, - {NULL}, - {add_ban, del_ban}, - {NULL}, - {NULL}, - {add_exception, del_exception}, - {NULL}, - {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, + {NULL}, + {add_ban, del_ban}, + {NULL}, + {NULL}, + {add_exception, del_exception}, + {NULL}, + {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} }; CBMode myCbmodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, - {0}, /* A */ - {0}, /* B */ - {0}, /* C */ - {0}, /* D */ - {0}, /* E */ - {0}, /* F */ - {0}, /* G */ - {CMODE_H, 0, NULL, NULL}, /* H */ - {0}, /* I */ - {0}, /* J */ - {0}, /* K */ - {0}, /* L */ - {CMODE_M, 0, NULL, NULL}, /* M */ - {CMODE_N, 0, NULL, NULL}, /* N */ - {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, - {CMODE_P, 0, NULL, NULL}, /* P */ - {0}, /* Q */ - {CMODE_R, 0, NULL, NULL}, /* R */ - {CMODE_S, 0, NULL, NULL}, /* S */ - {0}, /* T */ - {0}, /* U */ - {0}, /* V */ - {0}, /* W */ - {0}, /* X */ - {0}, /* Y */ - {0}, /* Z */ - {0}, {0}, {0}, {0}, {0}, {0}, - {0}, /* a */ - {0}, /* b */ - {CMODE_c, 0, NULL, NULL}, - {0}, /* d */ - {0}, /* e */ - {0}, /* f */ - {0}, /* g */ - {0}, /* h */ - {CMODE_i, 0, NULL, NULL}, - {0}, /* j */ - {CMODE_k, 0, chan_set_key, cs_set_key}, - {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, - {CMODE_m, 0, NULL, NULL}, - {CMODE_n, 0, NULL, NULL}, - {0}, /* o */ - {CMODE_p, 0, NULL, NULL}, - {0}, /* q */ - {CMODE_r, CBM_NO_MLOCK, NULL, NULL}, - {CMODE_s, 0, NULL, NULL}, - {CMODE_t, 0, NULL, NULL}, - {0}, - {0}, /* v */ - {0}, /* w */ - {CMODE_x, 0, NULL, NULL}, /* x */ - {0}, /* y */ - {0}, /* z */ - {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, + {0}, /* A */ + {0}, /* B */ + {0}, /* C */ + {0}, /* D */ + {0}, /* E */ + {0}, /* F */ + {0}, /* G */ + {CMODE_H, 0, NULL, NULL}, /* H */ + {0}, /* I */ + {0}, /* J */ + {0}, /* K */ + {0}, /* L */ + {CMODE_M, 0, NULL, NULL}, /* M */ + {CMODE_N, 0, NULL, NULL}, /* N */ + {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, + {CMODE_P, 0, NULL, NULL}, /* P */ + {0}, /* Q */ + {CMODE_R, 0, NULL, NULL}, /* R */ + {CMODE_S, 0, NULL, NULL}, /* S */ + {0}, /* T */ + {0}, /* U */ + {0}, /* V */ + {0}, /* W */ + {0}, /* X */ + {0}, /* Y */ + {0}, /* Z */ + {0}, {0}, {0}, {0}, {0}, {0}, + {0}, /* a */ + {0}, /* b */ + {CMODE_c, 0, NULL, NULL}, + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {0}, /* h */ + {CMODE_i, 0, NULL, NULL}, + {0}, /* j */ + {CMODE_k, 0, chan_set_key, cs_set_key}, + {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, + {CMODE_m, 0, NULL, NULL}, + {CMODE_n, 0, NULL, NULL}, + {0}, /* o */ + {CMODE_p, 0, NULL, NULL}, + {0}, /* q */ + {CMODE_r, CBM_NO_MLOCK, NULL, NULL}, + {CMODE_s, 0, NULL, NULL}, + {CMODE_t, 0, NULL, NULL}, + {0}, + {0}, /* v */ + {0}, /* w */ + {CMODE_x, 0, NULL, NULL}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0} }; CBModeInfo myCbmodeinfos[] = { - {'c', CMODE_c, 0, NULL, NULL}, - {'i', CMODE_i, 0, NULL, NULL}, - {'k', CMODE_k, 0, get_key, cs_get_key}, - {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, - {'m', CMODE_m, 0, NULL, NULL}, - {'n', CMODE_n, 0, NULL, NULL}, - {'p', CMODE_p, 0, NULL, NULL}, - {'r', CMODE_r, 0, NULL, NULL}, - {'s', CMODE_s, 0, NULL, NULL}, - {'t', CMODE_t, 0, NULL, NULL}, - {'x', CMODE_x, 0, NULL, NULL}, - {'H', CMODE_H, 0, NULL, NULL}, - {'M', CMODE_M, 0, NULL, NULL}, - {'N', CMODE_N, 0, NULL, NULL}, - {'O', CMODE_O, 0, NULL, NULL}, - {'P', CMODE_P, 0, NULL, NULL}, - {'R', CMODE_R, 0, NULL, NULL}, - {'S', CMODE_S, 0, NULL, NULL}, - {0} + {'c', CMODE_c, 0, NULL, NULL}, + {'i', CMODE_i, 0, NULL, NULL}, + {'k', CMODE_k, 0, get_key, cs_get_key}, + {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, + {'m', CMODE_m, 0, NULL, NULL}, + {'n', CMODE_n, 0, NULL, NULL}, + {'p', CMODE_p, 0, NULL, NULL}, + {'r', CMODE_r, 0, NULL, NULL}, + {'s', CMODE_s, 0, NULL, NULL}, + {'t', CMODE_t, 0, NULL, NULL}, + {'x', CMODE_x, 0, NULL, NULL}, + {'H', CMODE_H, 0, NULL, NULL}, + {'M', CMODE_M, 0, NULL, NULL}, + {'N', CMODE_N, 0, NULL, NULL}, + {'O', CMODE_O, 0, NULL, NULL}, + {'P', CMODE_P, 0, NULL, NULL}, + {'R', CMODE_R, 0, NULL, NULL}, + {'S', CMODE_S, 0, NULL, NULL}, + {0} }; CUMode myCumodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, - - {CUS_PROTECT, CUF_PROTECT_BOTSERV, check_valid_op}, - {0}, /* b */ - {0}, /* c */ - {0}, /* d */ - {0}, /* e */ - {0}, /* f */ - {0}, /* g */ - {CUS_HALFOP, 0, check_valid_op}, - {0}, /* i */ - {0}, /* j */ - {0}, /* k */ - {0}, /* l */ - {0}, /* m */ - {0}, /* n */ - {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, - {0}, /* p */ - {CUS_OWNER, 0, check_valid_op}, - {0}, /* r */ - {0}, /* s */ - {0}, /* t */ - {0}, /* u */ - {CUS_VOICE, 0, NULL}, - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {0}, /* z */ - {0}, {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, + + {CUS_PROTECT, CUF_PROTECT_BOTSERV, check_valid_op}, + {0}, /* b */ + {0}, /* c */ + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {CUS_HALFOP, 0, check_valid_op}, + {0}, /* i */ + {0}, /* j */ + {0}, /* k */ + {0}, /* l */ + {0}, /* m */ + {0}, /* n */ + {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, + {0}, /* p */ + {CUS_OWNER, 0, check_valid_op}, + {0}, /* r */ + {0}, /* s */ + {0}, /* t */ + {0}, /* u */ + {CUS_VOICE, 0, NULL}, + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0}, {0} }; void viagra_cmd_bot_unban(ChannelInfo * ci, const char *nick) { - send_cmd(ServerName, "SVSMODE %s -b %s", ci->name, nick); + send_cmd(ServerName, "SVSMODE %s -b %s", ci->name, nick); } int anope_event_setname(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 1) - return MOD_CONT; + if (ac != 1) + return MOD_CONT; - u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETNAME for nonexistent user %s", source); - } - return MOD_CONT; - } + u = finduser(source); + if (!u) { + if (debug) { + alog("debug: SETNAME for nonexistent user %s", source); + } + return MOD_CONT; + } - u->SetRealname(av[0]); - return MOD_CONT; + u->SetRealname(av[0]); + return MOD_CONT; } int anope_event_sjoin(const char *source, int ac, const char **av) { - do_sjoin(source, ac, av); - return MOD_CONT; + do_sjoin(source, ac, av); + return MOD_CONT; } int anope_event_chgname(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - u = finduser(av[0]); - if (!u) { - if (debug) { - alog("debug: CHGNAME for nonexistent user %s", av[0]); - } - return MOD_CONT; - } + u = finduser(av[0]); + if (!u) { + if (debug) { + alog("debug: CHGNAME for nonexistent user %s", av[0]); + } + return MOD_CONT; + } - u->SetRealname(av[1]); - return MOD_CONT; + u->SetRealname(av[1]); + return MOD_CONT; } int anope_event_setident(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 1) - return MOD_CONT; + if (ac != 1) + return MOD_CONT; - u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETIDENT for nonexistent user %s", source); - } - return MOD_CONT; - } + u = finduser(source); + if (!u) { + if (debug) { + alog("debug: SETIDENT for nonexistent user %s", source); + } + return MOD_CONT; + } - u->SetIdent(av[0]); - return MOD_CONT; + u->SetIdent(av[0]); + return MOD_CONT; } int anope_event_chgident(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - u = finduser(av[0]); - if (!u) { - if (debug) { - alog("debug: CHGIDENT for nonexistent user %s", av[0]); - } - return MOD_CONT; - } + u = finduser(av[0]); + if (!u) { + if (debug) { + alog("debug: CHGIDENT for nonexistent user %s", av[0]); + } + return MOD_CONT; + } - u->SetIdent(av[1]); - return MOD_CONT; + u->SetIdent(av[1]); + return MOD_CONT; } /* @@ -518,102 +518,102 @@ int anope_event_chgident(const char *source, int ac, const char **av) */ int anope_event_sethost(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 1) - return MOD_CONT; + if (ac != 1) + return MOD_CONT; - u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETHOST for nonexistent user %s", source); - } - return MOD_CONT; - } + u = finduser(source); + if (!u) { + if (debug) { + alog("debug: SETHOST for nonexistent user %s", source); + } + return MOD_CONT; + } - u->SetDisplayedHost(av[0]); - return MOD_CONT; + u->SetDisplayedHost(av[0]); + return MOD_CONT; } int anope_event_nick(const char *source, int ac, const char **av) { - User *user; + User *user; - if (ac != 2) { - user = do_nick(source, av[0], av[4], av[5], av[6], av[9], - strtoul(av[2], NULL, 10), strtoul(av[7], NULL, 0), - strtoul(av[8], NULL, 0), "*", NULL); - if (user) { - anope_ProcessUsermodes(user, 1, &av[3]); - } - } else { - do_nick(source, av[0], NULL, NULL, NULL, NULL, - strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); - } - return MOD_CONT; + if (ac != 2) { + user = do_nick(source, av[0], av[4], av[5], av[6], av[9], + strtoul(av[2], NULL, 10), strtoul(av[7], NULL, 0), + strtoul(av[8], NULL, 0), "*", NULL); + if (user) { + anope_ProcessUsermodes(user, 1, &av[3]); + } + } else { + do_nick(source, av[0], NULL, NULL, NULL, NULL, + strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); + } + return MOD_CONT; } int anope_event_vs(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - u = finduser(av[0]); - if (!u) { - if (debug) { - alog("debug: VS for nonexistent user %s", av[0]); - } - return MOD_CONT; - } + u = finduser(av[0]); + if (!u) { + if (debug) { + alog("debug: VS for nonexistent user %s", av[0]); + } + return MOD_CONT; + } - u->SetDisplayedHost(av[1]); - return MOD_CONT; + u->SetDisplayedHost(av[1]); + return MOD_CONT; } int anope_event_chghost(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - u = finduser(av[0]); - if (!u) { - if (debug) { - alog("debug: CHGHOST for nonexistent user %s", av[0]); - } - return MOD_CONT; - } + u = finduser(av[0]); + if (!u) { + if (debug) { + alog("debug: CHGHOST for nonexistent user %s", av[0]); + } + return MOD_CONT; + } - u->SetDisplayedHost(av[1]); - return MOD_CONT; + u->SetDisplayedHost(av[1]); + return MOD_CONT; } int anope_event_436(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; + if (ac < 1) + return MOD_CONT; - m_nickcoll(av[0]); - return MOD_CONT; + m_nickcoll(av[0]); + return MOD_CONT; } int anope_event_notice(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_pass(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_svinfo(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } /* @@ -623,35 +623,35 @@ int anope_event_svinfo(const char *source, int ac, const char **av) */ int anope_event_gnotice(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_sqline(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_burst(const char *source, int ac, const char **av) { - Server *s; - s = findserver(servlist, source); - if (!ac) { - /* for future use - start burst */ - } else { - /* If we found a server with the given source, that one just - * finished bursting. If there was no source, then our uplink - * server finished bursting. -GD - */ - if (!s && serv_uplink) - s = serv_uplink; - finish_sync(s, 1); - } - return MOD_CONT; + Server *s; + s = findserver(servlist, source); + if (!ac) { + /* for future use - start burst */ + } else { + /* If we found a server with the given source, that one just + * finished bursting. If there was no source, then our uplink + * server finished bursting. -GD + */ + if (!s && serv_uplink) + s = serv_uplink; + finish_sync(s, 1); + } + return MOD_CONT; } int anope_event_tctrl(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } /* @@ -661,81 +661,81 @@ int anope_event_tctrl(const char *source, int ac, const char **av) */ int anope_event_error(const char *source, int ac, const char **av) { - if (ac >= 1) { - if (debug) { - alog("debug: %s", av[0]); - } - } - return MOD_CONT; + if (ac >= 1) { + if (debug) { + alog("debug: %s", av[0]); + } + } + return MOD_CONT; } /* *INDENT-OFF* */ void moduleAddIRCDMsgs(void) { - Message *m; - - updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+a","-a"); - - m = createMessage("401", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("402", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); - m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); - m = createMessage("INVITE", anope_event_invite); addCoreMessage(IRCD,m); - m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); - m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); - m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); - m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); - m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); - m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); - m = createMessage("NOTICE", anope_event_notice); addCoreMessage(IRCD,m); - m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); - m = createMessage("PASS", anope_event_pass); addCoreMessage(IRCD,m); - m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); - m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); - m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); - m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); - m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); - m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); - m = createMessage("WALLOPS", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); - m = createMessage("AKILL", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("GLOBOPS", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("GNOTICE", anope_event_gnotice); addCoreMessage(IRCD,m); - m = createMessage("GOPER", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("RAKILL", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SILENCE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SVSKILL", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SVSMODE", anope_event_mode); addCoreMessage(IRCD,m); - m = createMessage("SVSNICK", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SVSNOOP", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SQLINE", anope_event_sqline); addCoreMessage(IRCD,m); - m = createMessage("UNSQLINE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); - m = createMessage("CS", anope_event_cs); addCoreMessage(IRCD,m); - m = createMessage("HS", anope_event_hs); addCoreMessage(IRCD,m); - m = createMessage("MS", anope_event_ms); addCoreMessage(IRCD,m); - m = createMessage("NS", anope_event_ns); addCoreMessage(IRCD,m); - m = createMessage("OS", anope_event_os); addCoreMessage(IRCD,m); - m = createMessage("RS", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SGLINE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); - m = createMessage("SS", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("SVINFO", anope_event_svinfo); addCoreMessage(IRCD,m); - m = createMessage("SZLINE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("UNSGLINE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("UNSZLINE", anope_event_null); addCoreMessage(IRCD,m); - m = createMessage("CHGHOST", anope_event_chghost); addCoreMessage(IRCD,m); - m = createMessage("CHGIDENT", anope_event_chgident); addCoreMessage(IRCD,m); - m = createMessage("CHGNAME", anope_event_chgname); addCoreMessage(IRCD,m); - m = createMessage("SETHOST", anope_event_sethost); addCoreMessage(IRCD,m); - m = createMessage("SETIDENT", anope_event_setident); addCoreMessage(IRCD,m); - m = createMessage("SETNAME", anope_event_setname); addCoreMessage(IRCD,m); - m = createMessage("VS", anope_event_vs); addCoreMessage(IRCD,m); - m = createMessage("BURST", anope_event_burst); addCoreMessage(IRCD,m); - m = createMessage("TCTRL", anope_event_tctrl); addCoreMessage(IRCD,m); - m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m); - m = createMessage("REHASH", anope_event_rehash); addCoreMessage(IRCD,m); - m = createMessage("ADMIN", anope_event_admin); addCoreMessage(IRCD,m); - m = createMessage("SNOTICE", anope_event_snotice); addCoreMessage(IRCD,m); + Message *m; + + updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+a","-a"); + + m = createMessage("401", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("402", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); + m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); + m = createMessage("INVITE", anope_event_invite); addCoreMessage(IRCD,m); + m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); + m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); + m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); + m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); + m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("NOTICE", anope_event_notice); addCoreMessage(IRCD,m); + m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); + m = createMessage("PASS", anope_event_pass); addCoreMessage(IRCD,m); + m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); + m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); + m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); + m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); + m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); + m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); + m = createMessage("WALLOPS", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); + m = createMessage("AKILL", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("GLOBOPS", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("GNOTICE", anope_event_gnotice); addCoreMessage(IRCD,m); + m = createMessage("GOPER", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("RAKILL", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SILENCE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SVSKILL", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SVSMODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("SVSNICK", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SVSNOOP", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SQLINE", anope_event_sqline); addCoreMessage(IRCD,m); + m = createMessage("UNSQLINE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); + m = createMessage("CS", anope_event_cs); addCoreMessage(IRCD,m); + m = createMessage("HS", anope_event_hs); addCoreMessage(IRCD,m); + m = createMessage("MS", anope_event_ms); addCoreMessage(IRCD,m); + m = createMessage("NS", anope_event_ns); addCoreMessage(IRCD,m); + m = createMessage("OS", anope_event_os); addCoreMessage(IRCD,m); + m = createMessage("RS", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SGLINE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); + m = createMessage("SS", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("SVINFO", anope_event_svinfo); addCoreMessage(IRCD,m); + m = createMessage("SZLINE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("UNSGLINE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("UNSZLINE", anope_event_null); addCoreMessage(IRCD,m); + m = createMessage("CHGHOST", anope_event_chghost); addCoreMessage(IRCD,m); + m = createMessage("CHGIDENT", anope_event_chgident); addCoreMessage(IRCD,m); + m = createMessage("CHGNAME", anope_event_chgname); addCoreMessage(IRCD,m); + m = createMessage("SETHOST", anope_event_sethost); addCoreMessage(IRCD,m); + m = createMessage("SETIDENT", anope_event_setident); addCoreMessage(IRCD,m); + m = createMessage("SETNAME", anope_event_setname); addCoreMessage(IRCD,m); + m = createMessage("VS", anope_event_vs); addCoreMessage(IRCD,m); + m = createMessage("BURST", anope_event_burst); addCoreMessage(IRCD,m); + m = createMessage("TCTRL", anope_event_tctrl); addCoreMessage(IRCD,m); + m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m); + m = createMessage("REHASH", anope_event_rehash); addCoreMessage(IRCD,m); + m = createMessage("ADMIN", anope_event_admin); addCoreMessage(IRCD,m); + m = createMessage("SNOTICE", anope_event_snotice); addCoreMessage(IRCD,m); } /* *INDENT-ON* */ @@ -744,26 +744,26 @@ void moduleAddIRCDMsgs(void) { /* SQLINE */ void viagra_SendSQLine(const char *mask, const char *reason) { - if (!mask || !reason) { - return; - } + if (!mask || !reason) { + return; + } - send_cmd(NULL, "SQLINE %s :%s", mask, reason); + send_cmd(NULL, "SQLINE %s :%s", mask, reason); } void viagra_SendSGLineDel(const char *mask) { - send_cmd(NULL, "UNSGLINE 0 :%s", mask); + send_cmd(NULL, "UNSGLINE 0 :%s", mask); } void viagra_SendSZLineDel(const char *mask) { - send_cmd(NULL, "UNSZLINE 0 %s", mask); + send_cmd(NULL, "UNSZLINE 0 %s", mask); } void viagra_SendSZLine(const char *mask, const char *reason, const char *whom) { - send_cmd(NULL, "SZLINE %s :%s", mask, reason); + send_cmd(NULL, "SZLINE %s :%s", mask, reason); } void ViagraIRCdProto::SendSVSNOOP(const char *server, int set) @@ -778,7 +778,7 @@ void viagra_cmd_svsadmin(const char *server, int set) void viagra_SendSGLine(const char *mask, const char *reason) { - send_cmd(NULL, "SGLINE %d :%s:%s", (int)strlen(mask), mask, reason); + send_cmd(NULL, "SGLINE %d :%s:%s", (int)strlen(mask), mask, reason); } void ViagraIRCdProto::SendAkillDel(const char *user, const char *host) @@ -789,47 +789,47 @@ void ViagraIRCdProto::SendAkillDel(const char *user, const char *host) /* PART */ void viagra_SendPart(const char *nick, const char *chan, const char *buf) { - if (!nick || !chan) { - return; - } + if (!nick || !chan) { + return; + } - if (buf) { - send_cmd(nick, "PART %s :%s", chan, buf); - } else { - send_cmd(nick, "PART %s", chan); - } + if (buf) { + send_cmd(nick, "PART %s :%s", chan, buf); + } else { + send_cmd(nick, "PART %s", chan); + } } void viagra_cmd_topic(const char *whosets, const char *chan, const char *whosetit, - const char *topic, time_t when) + const char *topic, time_t when) { - send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit, - (unsigned long int) when, topic); + send_cmd(whosets, "TOPIC %s %s %lu :%s", chan, whosetit, + (unsigned long int) when, topic); } void viagra_SendVhostDel(User * u) { - send_cmd(NULL, "SVSMODE %s -x", u->nick); - notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar); + send_cmd(NULL, "SVSMODE %s -x", u->nick); + notice_lang(s_HostServ, u, HOST_OFF_UNREAL, u->nick, ircd->vhostchar); } void viagra_SendVhost(const char *nick, const char *vIdent, const char *vhost) { - if (vIdent) { - send_cmd(NULL, "CHGIDENT %s %s", nick, vIdent); - } - send_cmd(NULL, "SVSMODE %s +x", nick); - send_cmd(NULL, "SVSCHGHOST %s %s", nick, vhost); + if (vIdent) { + send_cmd(NULL, "CHGIDENT %s %s", nick, vIdent); + } + send_cmd(NULL, "SVSMODE %s +x", nick); + send_cmd(NULL, "SVSCHGHOST %s %s", nick, vhost); } void viagra_SendSQLineDel(const char *user) { - send_cmd(NULL, "UNSQLINE %s", user); + send_cmd(NULL, "UNSQLINE %s", user); } void viagra_SendJoin(const char *user, const char *channel, time_t chantime) { - send_cmd(user, "SJOIN %ld %s", (long int) chantime, channel); + send_cmd(user, "SJOIN %ld %s", (long int) chantime, channel); } @@ -843,10 +843,10 @@ void viagra_SendJoin(const char *user, const char *channel, time_t chantime) * parv[6]=reason */ void viagra_SendAkill(const char *user, const char *host, const char *who, time_t when, - time_t expires, const char *reason) + time_t expires, const char *reason) { - send_cmd(NULL, "AKILL %s %s %d %s %ld :%s", host, user, 86400 * 2, who, - (long int) time(NULL), reason); + send_cmd(NULL, "AKILL %s %s %d %s %ld :%s", host, user, 86400 * 2, who, + (long int) time(NULL), reason); } @@ -859,72 +859,72 @@ void viagra_SendAkill(const char *user, const char *host, const char *who, time_ */ void viagra_SendSVSKill(const char *source, const char *user, const char *buf) { - if (buf) { - send_cmd(source, "SVSKILL %s :%s", user, buf); - } - return; + if (buf) { + send_cmd(source, "SVSKILL %s :%s", user, buf); + } + return; } void viagra_SendMode(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - if (ircdcap->tsmode) { - if (uplink_capab & ircdcap->tsmode) { - send_cmd(source, "MODE %s 0 %s", dest, buf); - } else { - send_cmd(source, "MODE %s %s", dest, buf); - } - } else { - send_cmd(source, "MODE %s %s", dest, buf); - } + if (ircdcap->tsmode) { + if (uplink_capab & ircdcap->tsmode) { + send_cmd(source, "MODE %s 0 %s", dest, buf); + } else { + send_cmd(source, "MODE %s %s", dest, buf); + } + } else { + send_cmd(source, "MODE %s %s", dest, buf); + } } /* QUIT */ void viagra_SendQuit(const char *source, const char *buf) { - if (buf) { - send_cmd(source, "QUIT :%s", buf); - } else { - send_cmd(source, "QUIT"); - } + if (buf) { + send_cmd(source, "QUIT :%s", buf); + } else { + send_cmd(source, "QUIT"); + } } int anope_event_away(const char *source, int ac, const char **av) { - if (!source) { - return MOD_CONT; - } - m_away(source, (ac ? av[0] : NULL)); - return MOD_CONT; + if (!source) { + return MOD_CONT; + } + m_away(source, (ac ? av[0] : NULL)); + return MOD_CONT; } int anope_event_ping(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - viagra_SendPong(ac > 1 ? av[1] : ServerName, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + viagra_SendPong(ac > 1 ? av[1] : ServerName, av[0]); + return MOD_CONT; } void viagra_SendSVSMode(User * u, int ac, const char **av) { - send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick, - (long int) u->timestamp, av[0], (ac == 2 ? " " : ""), - (ac == 2 ? av[1] : "")); + send_cmd(ServerName, "SVSMODE %s %ld %s%s%s", u->nick, + (long int) u->timestamp, av[0], (ac == 2 ? " " : ""), + (ac == 2 ? av[1] : "")); } void viagra_SendSquit(const char *servname, const char *message) { - send_cmd(NULL, "SQUIT %s :%s", servname, message); + send_cmd(NULL, "SQUIT %s :%s", servname, message); } /* PONG */ void viagra_SendPong(const char *servname, const char *who) { - send_cmd(servname, "PONG %s", who); + send_cmd(servname, "PONG %s", who); } /* @@ -937,551 +937,551 @@ void viagra_SendPong(const char *servname, const char *who) */ void viagra_cmd_svinfo() { - send_cmd(NULL, "SVINFO 5 3 0 :%ld", (long int) time(NULL)); + send_cmd(NULL, "SVINFO 5 3 0 :%ld", (long int) time(NULL)); } /* CAPAB */ void viagra_cmd_capab() { - send_cmd(NULL, "CAPAB TS5 NOQUIT SSJOIN BURST UNCONNECT NICKIP"); + send_cmd(NULL, "CAPAB TS5 NOQUIT SSJOIN BURST UNCONNECT NICKIP"); } /* PASS */ void viagra_cmd_pass(const char *pass) { - send_cmd(NULL, "PASS %s :TS", pass); + send_cmd(NULL, "PASS %s :TS", pass); } /* SERVER */ void viagra_SendServer(const char *servname, int hop, const char *descript) { - send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript); + send_cmd(NULL, "SERVER %s %d :%s", servname, hop, descript); } void viagra_cmd_burst() { - send_cmd(NULL, "BURST"); + send_cmd(NULL, "BURST"); } void viagra_SendConnect(int servernum) { - me_server = - new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); + me_server = + new_server(NULL, ServerName, ServerDesc, SERVER_ISME, NULL); - if (servernum == 1) { - viagra_cmd_pass(RemotePassword); - } else if (servernum == 2) { - viagra_cmd_pass(RemotePassword2); - } else if (servernum == 3) { - viagra_cmd_pass(RemotePassword3); - } - viagra_cmd_capab(); - viagra_SendServer(ServerName, 1, ServerDesc); - viagra_cmd_svinfo(); - viagra_cmd_burst(); + if (servernum == 1) { + viagra_cmd_pass(RemotePassword); + } else if (servernum == 2) { + viagra_cmd_pass(RemotePassword2); + } else if (servernum == 3) { + viagra_cmd_pass(RemotePassword3); + } + viagra_cmd_capab(); + viagra_SendServer(ServerName, 1, ServerDesc); + viagra_cmd_svinfo(); + viagra_cmd_burst(); } /* EVENT : OS */ int anope_event_os(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_OperServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_OperServ, av[0]); + return MOD_CONT; } /* EVENT : NS */ int anope_event_ns(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_NickServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_NickServ, av[0]); + return MOD_CONT; } /* EVENT : MS */ int anope_event_ms(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_MemoServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_MemoServ, av[0]); + return MOD_CONT; } /* EVENT : HS */ int anope_event_hs(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_HostServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_HostServ, av[0]); + return MOD_CONT; } /* EVENT : CS */ int anope_event_cs(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - m_privmsg(source, s_ChanServ, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + m_privmsg(source, s_ChanServ, av[0]); + return MOD_CONT; } int anope_event_server(const char *source, int ac, const char **av) { - if (!stricmp(av[1], "1")) { - uplink = sstrdup(av[0]); - } - do_server(source, av[0], av[1], av[2], NULL); - return MOD_CONT; + if (!stricmp(av[1], "1")) { + uplink = sstrdup(av[0]); + } + do_server(source, av[0], av[1], av[2], NULL); + return MOD_CONT; } int anope_event_privmsg(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; - m_privmsg(source, av[0], av[1]); - return MOD_CONT; + if (ac != 2) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; } int anope_event_part(const char *source, int ac, const char **av) { - if (ac < 1 || ac > 2) - return MOD_CONT; - do_part(source, ac, av); - return MOD_CONT; + if (ac < 1 || ac > 2) + return MOD_CONT; + do_part(source, ac, av); + return MOD_CONT; } int anope_event_whois(const char *source, int ac, const char **av) { - if (source && ac >= 1) { - m_whois(source, av[0]); - } - return MOD_CONT; + if (source && ac >= 1) { + m_whois(source, av[0]); + } + return MOD_CONT; } int anope_event_topic(const char *source, int ac, const char **av) { - if (ac != 4) - return MOD_CONT; - do_topic(source, ac, av); - return MOD_CONT; + if (ac != 4) + return MOD_CONT; + do_topic(source, ac, av); + return MOD_CONT; } int anope_event_squit(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; - do_squit(source, ac, av); - return MOD_CONT; + if (ac != 2) + return MOD_CONT; + do_squit(source, ac, av); + return MOD_CONT; } int anope_event_quit(const char *source, int ac, const char **av) { - if (ac != 1) - return MOD_CONT; - do_quit(source, ac, av); - return MOD_CONT; + if (ac != 1) + return MOD_CONT; + do_quit(source, ac, av); + return MOD_CONT; } int anope_event_mode(const char *source, int ac, const char **av) { - if (ac < 2) - return MOD_CONT; + if (ac < 2) + return MOD_CONT; - if (*av[0] == '#' || *av[0] == '&') { - do_cmode(source, ac, av); - } else { - do_umode(source, ac, av); - } - return MOD_CONT; + if (*av[0] == '#' || *av[0] == '&') { + do_cmode(source, ac, av); + } else { + do_umode(source, ac, av); + } + return MOD_CONT; } int anope_event_kill(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - m_kill(av[0], av[1]); - return MOD_CONT; + m_kill(av[0], av[1]); + return MOD_CONT; } int anope_event_kick(const char *source, int ac, const char **av) { - if (ac != 3) - return MOD_CONT; - do_kick(source, ac, av); - return MOD_CONT; + if (ac != 3) + return MOD_CONT; + do_kick(source, ac, av); + return MOD_CONT; } int anope_event_join(const char *source, int ac, const char **av) { - if (ac != 1) - return MOD_CONT; - do_join(source, ac, av); - return MOD_CONT; + if (ac != 1) + return MOD_CONT; + do_join(source, ac, av); + return MOD_CONT; } int anope_event_motd(const char *source, int ac, const char **av) { - if (!source) { - return MOD_CONT; - } + if (!source) { + return MOD_CONT; + } - m_motd(source); - return MOD_CONT; + m_motd(source); + return MOD_CONT; } void viagra_SendNoticeChanops(const char *source, const char *dest, const char *buf) { - if (buf) { - send_cmd(NULL, "NOTICE @%s :%s", dest, buf); - } - return; + if (buf) { + send_cmd(NULL, "NOTICE @%s :%s", dest, buf); + } + return; } void viagra_cmd_notice(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - if (NSDefFlags & NI_MSG) { - viagra_cmd_privmsg2(source, dest, buf); - } else { - send_cmd(source, "NOTICE %s :%s", dest, buf); - } + if (NSDefFlags & NI_MSG) { + viagra_cmd_privmsg2(source, dest, buf); + } else { + send_cmd(source, "NOTICE %s :%s", dest, buf); + } } void viagra_cmd_notice2(const char *source, const char *dest, const char *msg) { - send_cmd(source, "NOTICE %s :%s", dest, msg); + send_cmd(source, "NOTICE %s :%s", dest, msg); } void viagra_cmd_privmsg(const char *source, const char *dest, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(source, "PRIVMSG %s :%s", dest, buf); + send_cmd(source, "PRIVMSG %s :%s", dest, buf); } void viagra_cmd_privmsg2(const char *source, const char *dest, const char *msg) { - send_cmd(source, "PRIVMSG %s :%s", dest, msg); + send_cmd(source, "PRIVMSG %s :%s", dest, msg); } void viagra_SendGlobalNotice(const char *source, const char *dest, const char *msg) { - send_cmd(source, "NOTICE $%s :%s", dest, msg); + send_cmd(source, "NOTICE $%s :%s", dest, msg); } void viagra_SendGlobalPrivmsg(const char *source, const char *dest, const char *msg) { - send_cmd(source, "PRIVMSG $%s :%s", dest, msg); + send_cmd(source, "PRIVMSG $%s :%s", dest, msg); } /* GLOBOPS */ void viagra_SendGlobops(const char *source, const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf); + send_cmd(source ? source : ServerName, "GLOBOPS :%s", buf); } /* 391 */ void viagra_cmd_391(const char *source, const char *timestr) { - if (!timestr) { - return; - } - send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr); + if (!timestr) { + return; + } + send_cmd(NULL, "391 :%s %s :%s", source, ServerName, timestr); } /* 250 */ void viagra_cmd_250(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "250 %s", buf); + send_cmd(NULL, "250 %s", buf); } /* 307 */ void viagra_cmd_307(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "307 %s", buf); + send_cmd(ServerName, "307 %s", buf); } /* 311 */ void viagra_cmd_311(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "311 %s", buf); + send_cmd(ServerName, "311 %s", buf); } /* 312 */ void viagra_cmd_312(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "312 %s", buf); + send_cmd(ServerName, "312 %s", buf); } /* 317 */ void viagra_cmd_317(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(ServerName, "317 %s", buf); + send_cmd(ServerName, "317 %s", buf); } /* 219 */ void viagra_cmd_219(const char *source, const char *letter) { - if (!source) { - return; - } + if (!source) { + return; + } - if (letter) { - send_cmd(NULL, "219 %s %c :End of /STATS report.", source, - *letter); - } else { - send_cmd(NULL, "219 %s l :End of /STATS report.", source); - } + if (letter) { + send_cmd(NULL, "219 %s %c :End of /STATS report.", source, + *letter); + } else { + send_cmd(NULL, "219 %s l :End of /STATS report.", source); + } } /* 401 */ void viagra_cmd_401(const char *source, const char *who) { - if (!source || !who) { - return; - } - send_cmd(ServerName, "401 %s %s :No such service.", source, who); + if (!source || !who) { + return; + } + send_cmd(ServerName, "401 %s %s :No such service.", source, who); } /* 318 */ void viagra_cmd_318(const char *source, const char *who) { - if (!source || !who) { - return; - } + if (!source || !who) { + return; + } - send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who); + send_cmd(ServerName, "318 %s %s :End of /WHOIS list.", source, who); } /* 242 */ void viagra_cmd_242(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "242 %s", buf); + send_cmd(NULL, "242 %s", buf); } /* 243 */ void viagra_cmd_243(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "243 %s", buf); + send_cmd(NULL, "243 %s", buf); } /* 211 */ void viagra_cmd_211(const char *buf) { - if (!buf) { - return; - } + if (!buf) { + return; + } - send_cmd(NULL, "211 %s", buf); + send_cmd(NULL, "211 %s", buf); } void viagra_cmd_351(const char *source) { - send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s (%s) -- %s", - source, version_number, ServerName, ircd->name, version_flags, - EncModule, version_build); + send_cmd(ServerName, "351 %s Anope-%s %s :%s - %s (%s) -- %s", + source, version_number, ServerName, ircd->name, version_flags, + EncModule, version_build); } void viagra_SendClientIntroduction(const char *nick, const char *user, const char *host, const char *real, - const char *modes) + const char *modes) { - EnforceQlinedNick(nick, s_BotServ); - send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick, - (long int) time(NULL), modes, user, host, ServerName, real); - viagra_SendSQLine(nick, "Reserved for services"); + EnforceQlinedNick(nick, s_BotServ); + send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick, + (long int) time(NULL), modes, user, host, ServerName, real); + viagra_SendSQLine(nick, "Reserved for services"); } void viagra_SendKick(const char *source, const char *chan, const char *user, const char *buf) { - if (buf) { - send_cmd(source, "KICK %s %s :%s", chan, user, buf); - } else { - send_cmd(source, "KICK %s %s", chan, user); - } + if (buf) { + send_cmd(source, "KICK %s %s :%s", chan, user, buf); + } else { + send_cmd(source, "KICK %s %s", chan, user); + } } void viagra_cmd_nick(const char *nick, const char *name, const char *modes) { - EnforceQlinedNick(nick, NULL); - send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick, - (long int) time(NULL), modes, ServiceUser, ServiceHost, - ServerName, name); - viagra_SendSQLine(nick, "Reserved for services"); + EnforceQlinedNick(nick, NULL); + send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick, + (long int) time(NULL), modes, ServiceUser, ServiceHost, + ServerName, name); + viagra_SendSQLine(nick, "Reserved for services"); } void viagra_cmd_372(const char *source, const char *msg) { - send_cmd(ServerName, "372 %s :- %s", source, msg); + send_cmd(ServerName, "372 %s :- %s", source, msg); } void viagra_cmd_372_error(const char *source) { - send_cmd(ServerName, "422 %s :- MOTD file not found! Please " - "contact your IRC administrator.", source); + send_cmd(ServerName, "422 %s :- MOTD file not found! Please " + "contact your IRC administrator.", source); } void viagra_cmd_375(const char *source) { - send_cmd(ServerName, "375 %s :- %s Message of the Day", - source, ServerName); + send_cmd(ServerName, "375 %s :- %s Message of the Day", + source, ServerName); } void viagra_cmd_376(const char *source) { - send_cmd(ServerName, "376 %s :End of /MOTD command.", source); + send_cmd(ServerName, "376 %s :End of /MOTD command.", source); } /* INVITE */ void viagra_SendInvite(const char *source, const char *chan, const char *nick) { - if (!source || !chan || !nick) { - return; - } + if (!source || !chan || !nick) { + return; + } - send_cmd(source, "INVITE %s %s", nick, chan); + send_cmd(source, "INVITE %s %s", nick, chan); } void viagra_SendBotOp(const char *nick, const char *chan) { - anope_SendMode(nick, chan, "%s %s", ircd->botchanumode, nick); + anope_SendMode(nick, chan, "%s %s", ircd->botchanumode, nick); } int anope_event_capab(const char *source, int ac, const char **av) { - capab_parse(ac, av); - return MOD_CONT; + capab_parse(ac, av); + return MOD_CONT; } /* SVSHOLD - set */ void viagra_SendSVSHOLD(const char *nick) { - /* Not supported by this IRCD */ + /* Not supported by this IRCD */ } /* SVSHOLD - release */ void viagra_SendSVSHOLDDel(const char *nick) { - /* Not Supported by this IRCD */ + /* Not Supported by this IRCD */ } /* SVSNICK */ void viagra_SendForceNickChange(const char *source, const char *guest, time_t when) { - if (!source || !guest) { - return; - } - send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, (long int) when); + if (!source || !guest) { + return; + } + send_cmd(NULL, "SVSNICK %s %s :%ld", source, guest, (long int) when); } void viagra_SendGuestNick(const char *nick, const char *user, const char *host, const char *real, - const char *modes) + const char *modes) { - send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick, - (long int) time(NULL), modes, user, host, ServerName, real); + send_cmd(NULL, "NICK %s 1 %ld %s %s %s %s 0 0 :%s", nick, + (long int) time(NULL), modes, user, host, ServerName, real); } void viagra_SendSVSO(const char *source, const char *nick, const char *flag) { - /* Not Supported by this IRCD */ + /* Not Supported by this IRCD */ } /* SVSMODE -b */ void viagra_SendBanDel(const char *name, const char *nick) { - viagra_SendSVSMode_chan(name, "-b", nick); + viagra_SendSVSMode_chan(name, "-b", nick); } /* SVSMODE channel modes */ void viagra_SendSVSMode_chan(const char *name, const char *mode, const char *nick) { - if (nick) { - send_cmd(ServerName, "SVSMODE %s %s %s", name, mode, nick); - } else { - send_cmd(ServerName, "SVSMODE %s %s", name, mode); - } + if (nick) { + send_cmd(ServerName, "SVSMODE %s %s %s", name, mode, nick); + } else { + send_cmd(ServerName, "SVSMODE %s %s", name, mode); + } } /* SVSMODE +d */ /* sent if svid is something weird */ void viagra_SendSVID(const char *nick, time_t ts) { - send_cmd(ServerName, "SVSMODE %s %lu +d 1", nick, - (unsigned long int) ts); + send_cmd(ServerName, "SVSMODE %s %lu +d 1", nick, + (unsigned long int) ts); } /* SVSMODE +d */ /* nc_change was = 1, and there is no na->status */ void viagra_SendUnregisteredNick(User * u) { - common_svsmode(u, "+d", "1"); + common_svsmode(u, "+d", "1"); } /* SVSMODE +d */ void viagra_SendSVID2(User * u, const char *ts) { - /* not used by bahamut ircds */ + /* not used by bahamut ircds */ } void viagra_SendSVID3(User * u, const char *ts) { - if (u->svid != u->timestamp) { - common_svsmode(u, "+rd", ts); - } else { - common_svsmode(u, "+r", NULL); - } + if (u->svid != u->timestamp) { + common_svsmode(u, "+rd", ts); + } else { + common_svsmode(u, "+r", NULL); + } } /* NICK <newnick> */ void viagra_SendChangeBotNick(const char *oldnick, const char *newnick) { - if (!oldnick || !newnick) { - return; - } + if (!oldnick || !newnick) { + return; + } - send_cmd(oldnick, "NICK %s", newnick); + send_cmd(oldnick, "NICK %s", newnick); } /* @@ -1492,7 +1492,7 @@ void viagra_SendChangeBotNick(const char *oldnick, const char *newnick) */ void viagra_SendSVSJoin(const char *source, const char *nick, const char *chan, const char *param) { - send_cmd(source, "SVSJOIN %s :%s", nick, chan); + send_cmd(source, "SVSJOIN %s :%s", nick, chan); } /* @@ -1503,61 +1503,61 @@ void viagra_SendSVSJoin(const char *source, const char *nick, const char *chan, */ void viagra_SendSVSPart(const char *source, const char *nick, const char *chan) { - send_cmd(source, "SVSPART %s :%s", nick, chan); + send_cmd(source, "SVSPART %s :%s", nick, chan); } void viagra_SendSWhois(const char *source, const char *who, const char *mask) { - /* not supported */ + /* not supported */ } int viagra_IsFloodModeParamValid(const char *value) { - return 0; + return 0; } int anope_event_rehash(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_admin(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_snotice(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } int anope_event_invite(const char *source, int ac, const char **av) { - return MOD_CONT; + return MOD_CONT; } void viagra_SendEOB() { - send_cmd(NULL, "BURST 0"); + send_cmd(NULL, "BURST 0"); } void viagra_SendJupe(const char *jserver, const char *who, const char *reason) { - char rbuf[256]; + char rbuf[256]; - snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who, - reason ? ": " : "", reason ? reason : ""); + snprintf(rbuf, sizeof(rbuf), "Juped by %s%s%s", who, + reason ? ": " : "", reason ? reason : ""); - if (findserver(servlist, jserver)) - viagra_SendSquit(jserver, rbuf); - viagra_SendServer(jserver, 2, rbuf); - new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL); + if (findserver(servlist, jserver)) + viagra_SendSquit(jserver, rbuf); + viagra_SendServer(jserver, 2, rbuf); + new_server(me_server, jserver, rbuf, SERVER_JUPED, NULL); } /* GLOBOPS - to handle old WALLOPS */ void viagra_SendGlobops_legacy(const char *source, const char *fmt) { - send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt); + send_cmd(source ? source : ServerName, "GLOBOPS :%s", fmt); } /* @@ -1566,8 +1566,8 @@ void viagra_SendGlobops_legacy(const char *source, const char *fmt) */ int viagra_IsNickValid(const char *nick) { - /* no hard coded invalid nicks */ - return 1; + /* no hard coded invalid nicks */ + return 1; } /* @@ -1576,23 +1576,23 @@ int viagra_IsNickValid(const char *nick) */ int viagra_IsChannelValid(const char *chan) { - /* no hard coded invalid chans */ - return 1; + /* no hard coded invalid chans */ + return 1; } void viagra_SendCTCP(const char *source, const char *dest, const char *buf) { - char *s; + char *s; - if (!buf) { - return; - } else { - s = normalizeBuffer(buf); - } + if (!buf) { + return; + } else { + s = normalizeBuffer(buf); + } - send_cmd(source, "NOTICE %s :\1%s \1", dest, s); - free(s); + send_cmd(source, "NOTICE %s :\1%s \1", dest, s); + free(s); } @@ -1602,78 +1602,78 @@ void viagra_SendCTCP(const char *source, const char *dest, const char *buf) **/ void moduleAddAnopeCmds() { - pmodule_cmd_topic(viagra_cmd_topic); - pmodule_SendVhostDel(viagra_cmd_vhost_off); - pmodule_SendAkill(viagra_cmd_akill); - pmodule_SendSVSKill(viagra_SendSVSKill); - pmodule_SendSVSMode(viagra_cmd_svsmode); - pmodule_cmd_372(viagra_cmd_372); - pmodule_cmd_372_error(viagra_cmd_372_error); - pmodule_cmd_375(viagra_cmd_375); - pmodule_cmd_376(viagra_cmd_376); - pmodule_cmd_nick(viagra_cmd_nick); - pmodule_SendGuestNick(viagra_cmd_guest_nick); - pmodule_SendMode(viagra_cmd_mode); - pmodule_SendClientIntroduction(viagra_cmd_bot_nick); - pmodule_SendKick(viagra_cmd_kick); - pmodule_SendNoticeChanops(viagra_cmd_notice_ops); - pmodule_cmd_notice(viagra_cmd_notice); - pmodule_cmd_notice2(viagra_cmd_notice2); - pmodule_cmd_privmsg(viagra_cmd_privmsg); - pmodule_cmd_privmsg2(viagra_cmd_privmsg2); - pmodule_SendGlobalNotice(viagra_cmd_serv_notice); - pmodule_SendGlobalPrivmsg(viagra_cmd_serv_privmsg); - pmodule_SendBotOp(viagra_cmd_bot_chan_mode); - pmodule_cmd_351(viagra_cmd_351); - pmodule_SendQuit(viagra_cmd_quit); - pmodule_SendPong(viagra_cmd_pong); - pmodule_SendJoin(viagra_cmd_join); - pmodule_SendSQLineDel(viagra_cmd_unsqline); - pmodule_SendInvite(viagra_cmd_invite); - pmodule_SendPart(viagra_cmd_part); - pmodule_cmd_391(viagra_cmd_391); - pmodule_cmd_250(viagra_cmd_250); - pmodule_cmd_307(viagra_cmd_307); - pmodule_cmd_311(viagra_cmd_311); - pmodule_cmd_312(viagra_cmd_312); - pmodule_cmd_317(viagra_cmd_317); - pmodule_cmd_219(viagra_cmd_219); - pmodule_cmd_401(viagra_cmd_401); - pmodule_cmd_318(viagra_cmd_318); - pmodule_cmd_242(viagra_cmd_242); - pmodule_cmd_243(viagra_cmd_243); - pmodule_cmd_211(viagra_cmd_211); - pmodule_SendGlobops(viagra_cmd_global); - pmodule_SendGlobops_legacy(viagra_cmd_global_legacy); - pmodule_SendSQLine(viagra_cmd_sqline); - pmodule_SendSquit(viagra_cmd_squit); - pmodule_SendSVSO(viagra_cmd_svso); - pmodule_SendChangeBotNick(viagra_cmd_chg_nick); - pmodule_SendForceNickChange(viagra_cmd_svsnick); - pmodule_SendVhost(viagra_cmd_vhost_on); - pmodule_SendConnect(viagra_cmd_connect); - pmodule_SendSVSHOLD(viagra_cmd_svshold); - pmodule_SendSVSHOLDDel(viagra_cmd_release_svshold); - pmodule_SendSGLineDel(viagra_cmd_unsgline); - pmodule_SendSZLineDel(viagra_cmd_unszline); - pmodule_SendSZLine(viagra_cmd_szline); - pmodule_SendSGLine(viagra_cmd_sgline); - pmodule_SendBanDel(viagra_cmd_unban); - pmodule_SendSVSMode_chan(viagra_cmd_svsmode_chan); - pmodule_SendSVID(viagra_cmd_svid_umode); - pmodule_SendUnregisteredNick(viagra_cmd_nc_change); - pmodule_SendSVID2(viagra_cmd_svid_umode2); - pmodule_SendSVID3(viagra_cmd_svid_umode3); - pmodule_SendSVSJoin(viagra_cmd_svsjoin); - pmodule_SendSVSPart(viagra_cmd_svspart); - pmodule_SendSWhois(viagra_cmd_swhois); - pmodule_SendEOB(viagra_cmd_eob); - pmodule_IsFloodModeParamValid(viagra_flood_mode_check); - pmodule_SendJupe(viagra_cmd_jupe); - pmodule_IsNickValid(viagra_valid_nick); - pmodule_IsChannelValid(viagra_valid_chan); - pmodule_SendCTCP(viagra_cmd_ctcp); - pmodule_ProcessUsermodes(viagra_set_umode); + pmodule_cmd_topic(viagra_cmd_topic); + pmodule_SendVhostDel(viagra_cmd_vhost_off); + pmodule_SendAkill(viagra_cmd_akill); + pmodule_SendSVSKill(viagra_SendSVSKill); + pmodule_SendSVSMode(viagra_cmd_svsmode); + pmodule_cmd_372(viagra_cmd_372); + pmodule_cmd_372_error(viagra_cmd_372_error); + pmodule_cmd_375(viagra_cmd_375); + pmodule_cmd_376(viagra_cmd_376); + pmodule_cmd_nick(viagra_cmd_nick); + pmodule_SendGuestNick(viagra_cmd_guest_nick); + pmodule_SendMode(viagra_cmd_mode); + pmodule_SendClientIntroduction(viagra_cmd_bot_nick); + pmodule_SendKick(viagra_cmd_kick); + pmodule_SendNoticeChanops(viagra_cmd_notice_ops); + pmodule_cmd_notice(viagra_cmd_notice); + pmodule_cmd_notice2(viagra_cmd_notice2); + pmodule_cmd_privmsg(viagra_cmd_privmsg); + pmodule_cmd_privmsg2(viagra_cmd_privmsg2); + pmodule_SendGlobalNotice(viagra_cmd_serv_notice); + pmodule_SendGlobalPrivmsg(viagra_cmd_serv_privmsg); + pmodule_SendBotOp(viagra_cmd_bot_chan_mode); + pmodule_cmd_351(viagra_cmd_351); + pmodule_SendQuit(viagra_cmd_quit); + pmodule_SendPong(viagra_cmd_pong); + pmodule_SendJoin(viagra_cmd_join); + pmodule_SendSQLineDel(viagra_cmd_unsqline); + pmodule_SendInvite(viagra_cmd_invite); + pmodule_SendPart(viagra_cmd_part); + pmodule_cmd_391(viagra_cmd_391); + pmodule_cmd_250(viagra_cmd_250); + pmodule_cmd_307(viagra_cmd_307); + pmodule_cmd_311(viagra_cmd_311); + pmodule_cmd_312(viagra_cmd_312); + pmodule_cmd_317(viagra_cmd_317); + pmodule_cmd_219(viagra_cmd_219); + pmodule_cmd_401(viagra_cmd_401); + pmodule_cmd_318(viagra_cmd_318); + pmodule_cmd_242(viagra_cmd_242); + pmodule_cmd_243(viagra_cmd_243); + pmodule_cmd_211(viagra_cmd_211); + pmodule_SendGlobops(viagra_cmd_global); + pmodule_SendGlobops_legacy(viagra_cmd_global_legacy); + pmodule_SendSQLine(viagra_cmd_sqline); + pmodule_SendSquit(viagra_cmd_squit); + pmodule_SendSVSO(viagra_cmd_svso); + pmodule_SendChangeBotNick(viagra_cmd_chg_nick); + pmodule_SendForceNickChange(viagra_cmd_svsnick); + pmodule_SendVhost(viagra_cmd_vhost_on); + pmodule_SendConnect(viagra_cmd_connect); + pmodule_SendSVSHOLD(viagra_cmd_svshold); + pmodule_SendSVSHOLDDel(viagra_cmd_release_svshold); + pmodule_SendSGLineDel(viagra_cmd_unsgline); + pmodule_SendSZLineDel(viagra_cmd_unszline); + pmodule_SendSZLine(viagra_cmd_szline); + pmodule_SendSGLine(viagra_cmd_sgline); + pmodule_SendBanDel(viagra_cmd_unban); + pmodule_SendSVSMode_chan(viagra_cmd_svsmode_chan); + pmodule_SendSVID(viagra_cmd_svid_umode); + pmodule_SendUnregisteredNick(viagra_cmd_nc_change); + pmodule_SendSVID2(viagra_cmd_svid_umode2); + pmodule_SendSVID3(viagra_cmd_svid_umode3); + pmodule_SendSVSJoin(viagra_cmd_svsjoin); + pmodule_SendSVSPart(viagra_cmd_svspart); + pmodule_SendSWhois(viagra_cmd_swhois); + pmodule_SendEOB(viagra_cmd_eob); + pmodule_IsFloodModeParamValid(viagra_flood_mode_check); + pmodule_SendJupe(viagra_cmd_jupe); + pmodule_IsNickValid(viagra_valid_nick); + pmodule_IsChannelValid(viagra_valid_chan); + pmodule_SendCTCP(viagra_cmd_ctcp); + pmodule_ProcessUsermodes(viagra_set_umode); } /** @@ -1682,34 +1682,34 @@ void moduleAddAnopeCmds() int AnopeInit(int argc, char **argv) { - this->SetAuthor("Anope"); - this->SetVersion("$Id$"); - this->SetType(PROTOCOL); - - pmodule_ircd_version("ViagraIRCd 1.3.x"); - pmodule_ircd_cap(myIrcdcap); - pmodule_ircd_var(myIrcd); - pmodule_ircd_cbmodeinfos(myCbmodeinfos); - pmodule_ircd_cumodes(myCumodes); - pmodule_ircd_flood_mode_char_set(""); - pmodule_ircd_flood_mode_char_remove(""); - pmodule_ircd_cbmodes(myCbmodes); - pmodule_ircd_cmmodes(myCmmodes); - pmodule_ircd_csmodes(myCsmodes); - pmodule_ircd_useTSMode(0); - - /** Deal with modes anope _needs_ to know **/ - pmodule_invis_umode(UMODE_i); - pmodule_oper_umode(UMODE_o); - pmodule_invite_cmode(CMODE_i); - pmodule_secret_cmode(CMODE_s); - pmodule_private_cmode(CMODE_p); - pmodule_key_mode(CMODE_k); - pmodule_limit_mode(CMODE_l); - - moduleAddAnopeCmds(); + this->SetAuthor("Anope"); + this->SetVersion("$Id$"); + this->SetType(PROTOCOL); + + pmodule_ircd_version("ViagraIRCd 1.3.x"); + pmodule_ircd_cap(myIrcdcap); + pmodule_ircd_var(myIrcd); + pmodule_ircd_cbmodeinfos(myCbmodeinfos); + pmodule_ircd_cumodes(myCumodes); + pmodule_ircd_flood_mode_char_set(""); + pmodule_ircd_flood_mode_char_remove(""); + pmodule_ircd_cbmodes(myCbmodes); + pmodule_ircd_cmmodes(myCmmodes); + pmodule_ircd_csmodes(myCsmodes); + pmodule_ircd_useTSMode(0); + + /** Deal with modes anope _needs_ to know **/ + pmodule_invis_umode(UMODE_i); + pmodule_oper_umode(UMODE_o); + pmodule_invite_cmode(CMODE_i); + pmodule_secret_cmode(CMODE_s); + pmodule_private_cmode(CMODE_p); + pmodule_key_mode(CMODE_k); + pmodule_limit_mode(CMODE_l); + + moduleAddAnopeCmds(); pmodule_ircd_proto(&ircd_proto); - moduleAddIRCDMsgs(); + moduleAddIRCDMsgs(); - return MOD_CONT; + return MOD_CONT; } diff --git a/src/protocol/ratbox.c b/src/protocol/ratbox.c index b46826e3a..7e29d09d5 100644 --- a/src/protocol/ratbox.c +++ b/src/protocol/ratbox.c @@ -48,363 +48,363 @@ #define DEFAULT_MLOCK CMODE_n | CMODE_t IRCDVar myIrcd[] = { - {"Ratbox 2.0+", /* ircd name */ - "+oi", /* Modes used by pseudoclients */ - 2, /* Chan Max Symbols */ - "-acilmnpst", /* Modes to Remove */ - "+o", /* Channel Umode used by Botserv bots */ - 0, /* SVSNICK */ - 0, /* Vhost */ - 0, /* Has Owner */ - NULL, /* Mode to set for an owner */ - NULL, /* Mode to unset for an owner */ - NULL, /* Mode to set for chan admin */ - NULL, /* Mode to unset for chan admin */ - NULL, /* Mode On Reg */ - NULL, /* Mode on ID for Roots */ - NULL, /* Mode on ID for Admins */ - NULL, /* Mode on ID for Opers */ - NULL, /* Mode on UnReg */ - NULL, /* Mode on Nick Change */ - 1, /* Supports SGlines */ - 1, /* Supports SQlines */ - 0, /* Supports SZlines */ - 0, /* Supports Halfop +h */ - 3, /* Number of server args */ - 1, /* Join 2 Set */ - 1, /* Join 2 Message */ - 1, /* Has exceptions +e */ - 0, /* TS Topic Forward */ - 0, /* TS Topci Backward */ - 0, /* Protected Umode */ - 0, /* Has Admin */ - 1, /* Chan SQlines */ - 0, /* Quit on Kill */ - 0, /* SVSMODE unban */ - 0, /* Has Protect */ - 0, /* Reverse */ - 0, /* Chan Reg */ - 0, /* Channel Mode */ - 0, /* vidents */ - 0, /* svshold */ - 0, /* time stamp on mode */ - 0, /* NICKIP */ - 0, /* UMODE */ - 0, /* O:LINE */ - 0, /* VHOST ON NICK */ - 0, /* Change RealName */ - CMODE_p, /* No Knock */ - 0, /* Admin Only */ - DEFAULT_MLOCK, /* Default MLOCK */ - 0, /* Vhost Mode */ - 0, /* +f */ - 0, /* +L */ - 0, /* +f Mode */ - 0, /* +L Mode */ - 0, /* On nick change check if they could be identified */ - 0, /* No Knock requires +i */ - NULL, /* CAPAB Chan Modes */ - 0, /* We support TOKENS */ - 0, /* TIME STAMPS are BASE64 */ - 1, /* +I support */ - 0, /* SJOIN ban char */ - 0, /* SJOIN except char */ - 0, /* SJOIN invite char */ - 0, /* Can remove User Channel Modes with SVSMODE */ - 0, /* Sglines are not enforced until user reconnects */ - NULL, /* vhost char */ - 1, /* ts6 */ - 0, /* support helper umode */ - 0, /* p10 */ - NULL, /* character set */ - 0, /* reports sync state */ - 0, /* CIDR channelbans */ - "$$", /* TLD Prefix for Global */ - } - , - {NULL} + {"Ratbox 2.0+", /* ircd name */ + "+oi", /* Modes used by pseudoclients */ + 2, /* Chan Max Symbols */ + "-acilmnpst", /* Modes to Remove */ + "+o", /* Channel Umode used by Botserv bots */ + 0, /* SVSNICK */ + 0, /* Vhost */ + 0, /* Has Owner */ + NULL, /* Mode to set for an owner */ + NULL, /* Mode to unset for an owner */ + NULL, /* Mode to set for chan admin */ + NULL, /* Mode to unset for chan admin */ + NULL, /* Mode On Reg */ + NULL, /* Mode on ID for Roots */ + NULL, /* Mode on ID for Admins */ + NULL, /* Mode on ID for Opers */ + NULL, /* Mode on UnReg */ + NULL, /* Mode on Nick Change */ + 1, /* Supports SGlines */ + 1, /* Supports SQlines */ + 0, /* Supports SZlines */ + 0, /* Supports Halfop +h */ + 3, /* Number of server args */ + 1, /* Join 2 Set */ + 1, /* Join 2 Message */ + 1, /* Has exceptions +e */ + 0, /* TS Topic Forward */ + 0, /* TS Topci Backward */ + 0, /* Protected Umode */ + 0, /* Has Admin */ + 1, /* Chan SQlines */ + 0, /* Quit on Kill */ + 0, /* SVSMODE unban */ + 0, /* Has Protect */ + 0, /* Reverse */ + 0, /* Chan Reg */ + 0, /* Channel Mode */ + 0, /* vidents */ + 0, /* svshold */ + 0, /* time stamp on mode */ + 0, /* NICKIP */ + 0, /* UMODE */ + 0, /* O:LINE */ + 0, /* VHOST ON NICK */ + 0, /* Change RealName */ + CMODE_p, /* No Knock */ + 0, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + 0, /* Vhost Mode */ + 0, /* +f */ + 0, /* +L */ + 0, /* +f Mode */ + 0, /* +L Mode */ + 0, /* On nick change check if they could be identified */ + 0, /* No Knock requires +i */ + NULL, /* CAPAB Chan Modes */ + 0, /* We support TOKENS */ + 0, /* TIME STAMPS are BASE64 */ + 1, /* +I support */ + 0, /* SJOIN ban char */ + 0, /* SJOIN except char */ + 0, /* SJOIN invite char */ + 0, /* Can remove User Channel Modes with SVSMODE */ + 0, /* Sglines are not enforced until user reconnects */ + NULL, /* vhost char */ + 1, /* ts6 */ + 0, /* support helper umode */ + 0, /* p10 */ + NULL, /* character set */ + 0, /* reports sync state */ + 0, /* CIDR channelbans */ + "$$", /* TLD Prefix for Global */ + } + , + {NULL} }; IRCDCAPAB myIrcdcap[] = { - { - 0, /* NOQUIT */ - 0, /* TSMODE */ - 0, /* UNCONNECT */ - 0, /* NICKIP */ - 0, /* SJOIN */ - CAPAB_ZIP, /* ZIP */ - 0, /* BURST */ - CAPAB_TS5, /* TS5 */ - 0, /* TS3 */ - 0, /* DKEY */ - 0, /* PT4 */ - 0, /* SCS */ - CAPAB_QS, /* QS */ - CAPAB_UID, /* UID */ - CAPAB_KNOCK, /* KNOCK */ - 0, /* CLIENT */ - 0, /* IPV6 */ - 0, /* SSJ5 */ - 0, /* SN2 */ - 0, /* TOKEN */ - 0, /* VHOST */ - 0, /* SSJ3 */ - 0, /* NICK2 */ - 0, /* UMODE2 */ - 0, /* VL */ - 0, /* TLKEXT */ - 0, /* DODKEY */ - 0, /* DOZIP */ - 0, 0, 0} + { + 0, /* NOQUIT */ + 0, /* TSMODE */ + 0, /* UNCONNECT */ + 0, /* NICKIP */ + 0, /* SJOIN */ + CAPAB_ZIP, /* ZIP */ + 0, /* BURST */ + CAPAB_TS5, /* TS5 */ + 0, /* TS3 */ + 0, /* DKEY */ + 0, /* PT4 */ + 0, /* SCS */ + CAPAB_QS, /* QS */ + CAPAB_UID, /* UID */ + CAPAB_KNOCK, /* KNOCK */ + 0, /* CLIENT */ + 0, /* IPV6 */ + 0, /* SSJ5 */ + 0, /* SN2 */ + 0, /* TOKEN */ + 0, /* VHOST */ + 0, /* SSJ3 */ + 0, /* NICK2 */ + 0, /* UMODE2 */ + 0, /* VL */ + 0, /* TLKEXT */ + 0, /* DODKEY */ + 0, /* DOZIP */ + 0, 0, 0} }; unsigned long umodes[128] = { - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused, Unused, Horzontal Tab */ - 0, 0, 0, /* Line Feed, Unused, Unused */ - 0, 0, 0, /* Carriage Return, Unused, Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused, Unused, Space */ - 0, 0, 0, /* ! " # */ - 0, 0, 0, /* $ % & */ - 0, 0, 0, /* ! ( ) */ - 0, 0, 0, /* * + , */ - 0, 0, 0, /* - . / */ - 0, 0, /* 0 1 */ - 0, 0, /* 2 3 */ - 0, 0, /* 4 5 */ - 0, 0, /* 6 7 */ - 0, 0, /* 8 9 */ - 0, 0, /* : ; */ - 0, 0, 0, /* < = > */ - 0, 0, /* ? @ */ - 0, 0, 0, /* A B C */ - 0, 0, 0, /* D E F */ - 0, 0, 0, /* G H I */ - 0, 0, 0, /* J K L */ - 0, 0, 0, /* M N O */ - 0, 0, 0, /* P Q R */ - 0, 0, 0, /* S T U */ - 0, 0, 0, /* V W X */ - 0, /* Y */ - 0, /* Z */ - 0, 0, 0, /* [ \ ] */ - 0, 0, 0, /* ^ _ ` */ - UMODE_a, UMODE_b, 0, /* a b c */ - UMODE_d, 0, 0, /* d e f */ - UMODE_g, 0, UMODE_i, /* g h i */ - 0, 0, UMODE_l, /* j k l */ - 0, UMODE_n, UMODE_o, /* m n o */ - 0, 0, 0, /* p q r */ - 0, 0, UMODE_u, /* s t u */ - 0, UMODE_w, UMODE_x, /* v w x */ - 0, /* y */ - 0, /* z */ - 0, 0, 0, /* { | } */ - 0, 0 /* ~ � */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused, Unused, Horzontal Tab */ + 0, 0, 0, /* Line Feed, Unused, Unused */ + 0, 0, 0, /* Carriage Return, Unused, Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused, Unused, Space */ + 0, 0, 0, /* ! " # */ + 0, 0, 0, /* $ % & */ + 0, 0, 0, /* ! ( ) */ + 0, 0, 0, /* * + , */ + 0, 0, 0, /* - . / */ + 0, 0, /* 0 1 */ + 0, 0, /* 2 3 */ + 0, 0, /* 4 5 */ + 0, 0, /* 6 7 */ + 0, 0, /* 8 9 */ + 0, 0, /* : ; */ + 0, 0, 0, /* < = > */ + 0, 0, /* ? @ */ + 0, 0, 0, /* A B C */ + 0, 0, 0, /* D E F */ + 0, 0, 0, /* G H I */ + 0, 0, 0, /* J K L */ + 0, 0, 0, /* M N O */ + 0, 0, 0, /* P Q R */ + 0, 0, 0, /* S T U */ + 0, 0, 0, /* V W X */ + 0, /* Y */ + 0, /* Z */ + 0, 0, 0, /* [ \ ] */ + 0, 0, 0, /* ^ _ ` */ + UMODE_a, UMODE_b, 0, /* a b c */ + UMODE_d, 0, 0, /* d e f */ + UMODE_g, 0, UMODE_i, /* g h i */ + 0, 0, UMODE_l, /* j k l */ + 0, UMODE_n, UMODE_o, /* m n o */ + 0, 0, 0, /* p q r */ + 0, 0, UMODE_u, /* s t u */ + 0, UMODE_w, UMODE_x, /* v w x */ + 0, /* y */ + 0, /* z */ + 0, 0, 0, /* { | } */ + 0, 0 /* ~ � */ }; char myCsmodes[128] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, 0, 0, - 0, - 0, 0, 0, 0, - 0, + 0, + 0, + 0, 0, 0, + 0, + 0, 0, 0, 0, + 0, - 'v', 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'v', 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; CMMode myCmmodes[128] = { - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, /* BCD */ - {NULL}, {NULL}, {NULL}, /* EFG */ - {NULL}, /* H */ - {add_invite, del_invite}, - {NULL}, /* J */ - {NULL}, {NULL}, {NULL}, /* KLM */ - {NULL}, {NULL}, {NULL}, /* NOP */ - {NULL}, {NULL}, {NULL}, /* QRS */ - {NULL}, {NULL}, {NULL}, /* TUV */ - {NULL}, {NULL}, {NULL}, /* WXY */ - {NULL}, /* Z */ - {NULL}, {NULL}, /* (char 91 - 92) */ - {NULL}, {NULL}, {NULL}, /* (char 93 - 95) */ - {NULL}, /* ` (char 96) */ - {NULL}, /* a (char 97) */ - {add_ban, del_ban}, - {NULL}, - {NULL}, - {add_exception, del_exception}, - {NULL}, - {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, /* BCD */ + {NULL}, {NULL}, {NULL}, /* EFG */ + {NULL}, /* H */ + {add_invite, del_invite}, + {NULL}, /* J */ + {NULL}, {NULL}, {NULL}, /* KLM */ + {NULL}, {NULL}, {NULL}, /* NOP */ + {NULL}, {NULL}, {NULL}, /* QRS */ + {NULL}, {NULL}, {NULL}, /* TUV */ + {NULL}, {NULL}, {NULL}, /* WXY */ + {NULL}, /* Z */ + {NULL}, {NULL}, /* (char 91 - 92) */ + {NULL}, {NULL}, {NULL}, /* (char 93 - 95) */ + {NULL}, /* ` (char 96) */ + {NULL}, /* a (char 97) */ + {add_ban, del_ban}, + {NULL}, + {NULL}, + {add_exception, del_exception}, + {NULL}, + {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} }; CBMode myCbmodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, - {0}, /* A */ - {0}, /* B */ - {0}, /* C */ - {0}, /* D */ - {0}, /* E */ - {0}, /* F */ - {0}, /* G */ - {0}, /* H */ - {0}, /* I */ - {0}, /* J */ - {0}, /* K */ - {0}, /* L */ - {0}, /* M */ - {0}, /* N */ - {0}, /* O */ - {0}, /* P */ - {0}, /* Q */ - {0}, /* R */ - {0}, /* S */ - {0}, /* T */ - {0}, /* U */ - {0}, /* V */ - {0}, /* W */ - {0}, /* X */ - {0}, /* Y */ - {0}, /* Z */ - {0}, {0}, {0}, {0}, {0}, {0}, - {0}, - {0}, /* b */ - {0}, /* c */ - {0}, /* d */ - {0}, /* e */ - {0}, /* f */ - {0}, /* g */ - {0}, /* h */ - {CMODE_i, 0, NULL, NULL}, - {0}, /* j */ - {CMODE_k, 0, chan_set_key, cs_set_key}, - {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, - {CMODE_m, 0, NULL, NULL}, - {CMODE_n, 0, NULL, NULL}, - {0}, /* o */ - {CMODE_p, 0, NULL, NULL}, - {0}, /* q */ - {0}, - {CMODE_s, 0, NULL, NULL}, - {CMODE_t, 0, NULL, NULL}, - {0}, - {0}, /* v */ - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {0}, /* z */ - {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, + {0}, /* A */ + {0}, /* B */ + {0}, /* C */ + {0}, /* D */ + {0}, /* E */ + {0}, /* F */ + {0}, /* G */ + {0}, /* H */ + {0}, /* I */ + {0}, /* J */ + {0}, /* K */ + {0}, /* L */ + {0}, /* M */ + {0}, /* N */ + {0}, /* O */ + {0}, /* P */ + {0}, /* Q */ + {0}, /* R */ + {0}, /* S */ + {0}, /* T */ + {0}, /* U */ + {0}, /* V */ + {0}, /* W */ + {0}, /* X */ + {0}, /* Y */ + {0}, /* Z */ + {0}, {0}, {0}, {0}, {0}, {0}, + {0}, + {0}, /* b */ + {0}, /* c */ + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {0}, /* h */ + {CMODE_i, 0, NULL, NULL}, + {0}, /* j */ + {CMODE_k, 0, chan_set_key, cs_set_key}, + {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, + {CMODE_m, 0, NULL, NULL}, + {CMODE_n, 0, NULL, NULL}, + {0}, /* o */ + {CMODE_p, 0, NULL, NULL}, + {0}, /* q */ + {0}, + {CMODE_s, 0, NULL, NULL}, + {CMODE_t, 0, NULL, NULL}, + {0}, + {0}, /* v */ + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0} }; CBModeInfo myCbmodeinfos[] = { - {'i', CMODE_i, 0, NULL, NULL}, - {'k', CMODE_k, 0, get_key, cs_get_key}, - {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, - {'m', CMODE_m, 0, NULL, NULL}, - {'n', CMODE_n, 0, NULL, NULL}, - {'p', CMODE_p, 0, NULL, NULL}, - {'s', CMODE_s, 0, NULL, NULL}, - {'t', CMODE_t, 0, NULL, NULL}, - {0} + {'i', CMODE_i, 0, NULL, NULL}, + {'k', CMODE_k, 0, get_key, cs_get_key}, + {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, + {'m', CMODE_m, 0, NULL, NULL}, + {'n', CMODE_n, 0, NULL, NULL}, + {'p', CMODE_p, 0, NULL, NULL}, + {'s', CMODE_s, 0, NULL, NULL}, + {'t', CMODE_t, 0, NULL, NULL}, + {0} }; CUMode myCumodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, - - {0}, /* a */ - {0}, /* b */ - {0}, /* c */ - {0}, /* d */ - {0}, /* e */ - {0}, /* f */ - {0}, /* g */ - {0}, - {0}, /* i */ - {0}, /* j */ - {0}, /* k */ - {0}, /* l */ - {0}, /* m */ - {0}, /* n */ - {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, - {0}, /* p */ - {0}, /* q */ - {0}, /* r */ - {0}, /* s */ - {0}, /* t */ - {0}, /* u */ - {CUS_VOICE, 0, NULL}, - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {0}, /* z */ - {0}, {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, + + {0}, /* a */ + {0}, /* b */ + {0}, /* c */ + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {0}, + {0}, /* i */ + {0}, /* j */ + {0}, /* k */ + {0}, /* l */ + {0}, /* m */ + {0}, /* n */ + {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, + {0}, /* p */ + {0}, /* q */ + {0}, /* r */ + {0}, /* s */ + {0}, /* t */ + {0}, /* u */ + {CUS_VOICE, 0, NULL}, + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0}, {0} }; @@ -412,15 +412,15 @@ CUMode myCumodes[128] = { /* * SVINFO - * parv[0] = sender prefix - * parv[1] = TS_CURRENT for the server - * parv[2] = TS_MIN for the server - * parv[3] = server is standalone or connected to non-TS only - * parv[4] = server's idea of UTC time + * parv[0] = sender prefix + * parv[1] = TS_CURRENT for the server + * parv[2] = TS_MIN for the server + * parv[3] = server is standalone or connected to non-TS only + * parv[4] = server's idea of UTC time */ void ratbox_cmd_svinfo() { - send_cmd(NULL, "SVINFO 6 3 0 :%ld", (long int) time(NULL)); + send_cmd(NULL, "SVINFO 6 3 0 :%ld", (long int) time(NULL)); } void ratbox_cmd_svsinfo() @@ -430,37 +430,37 @@ void ratbox_cmd_svsinfo() void ratbox_cmd_tmode(const char *source, const char *dest, const char *fmt, ...) { - va_list args; - char buf[BUFSIZE]; - *buf = '\0'; - - if (fmt) { - va_start(args, fmt); - vsnprintf(buf, BUFSIZE - 1, fmt, args); - va_end(args); - } - if (!*buf) { - return; - } - - send_cmd(NULL, "MODE %s %s", dest, buf); + va_list args; + char buf[BUFSIZE]; + *buf = '\0'; + + if (fmt) { + va_start(args, fmt); + vsnprintf(buf, BUFSIZE - 1, fmt, args); + va_end(args); + } + if (!*buf) { + return; + } + + send_cmd(NULL, "MODE %s %s", dest, buf); } /* CAPAB */ /* - QS - Can handle quit storm removal - EX - Can do channel +e exemptions - CHW - Can do channel wall @# - LL - Can do lazy links - IE - Can do invite exceptions - EOB - Can do EOB message - KLN - Can do KLINE message - GLN - Can do GLINE message - HUB - This server is a HUB - UID - Can do UIDs - ZIP - Can do ZIPlinks - ENC - Can do ENCrypted links + QS - Can handle quit storm removal + EX - Can do channel +e exemptions + CHW - Can do channel wall @# + LL - Can do lazy links + IE - Can do invite exceptions + EOB - Can do EOB message + KLN - Can do KLINE message + GLN - Can do GLINE message + HUB - This server is a HUB + UID - Can do UIDs + ZIP - Can do ZIPlinks + ENC - Can do ENCrypted links KNOCK - supports KNOCK TBURST - supports TBURST PARA - supports invite broadcasting for +p @@ -468,18 +468,18 @@ void ratbox_cmd_tmode(const char *source, const char *dest, const char *fmt, ... */ void ratbox_cmd_capab() { - send_cmd(NULL, - "CAPAB :QS EX CHW IE KLN GLN KNOCK TB UNKLN CLUSTER ENCAP"); + send_cmd(NULL, + "CAPAB :QS EX CHW IE KLN GLN KNOCK TB UNKLN CLUSTER ENCAP"); } /* PASS */ void ratbox_cmd_pass(const char *pass) { - if (UseTS6) { - send_cmd(NULL, "PASS %s TS 6 :%s", pass, TS6SID); - } else { - send_cmd(NULL, "PASS %s :TS", pass); - } + if (UseTS6) { + send_cmd(NULL, "PASS %s TS 6 :%s", pass, TS6SID); + } else { + send_cmd(NULL, "PASS %s :TS", pass); + } } class RatboxProto : public IRCDTS6Proto @@ -707,8 +707,8 @@ class RatboxProto : public IRCDTS6Proto int anope_event_sjoin(const char *source, int ac, const char **av) { - do_sjoin(source, ac, av); - return MOD_CONT; + do_sjoin(source, ac, av); + return MOD_CONT; } /* @@ -737,435 +737,435 @@ int anope_event_sjoin(const char *source, int ac, const char **av) */ int anope_event_nick(const char *source, int ac, const char **av) { - Server *s; - User *user; - - if (UseTS6 && ac == 9) { - s = findserver_uid(servlist, source); - /* Source is always the server */ - user = do_nick("", av[0], av[4], av[5], s->name, av[8], - strtoul(av[2], NULL, 10), 0, 0, "*", av[7]); - if (user) { - ircdproto->ProcessUsermodes(user, 1, &av[3]); - } - } else { - if (ac != 2) { - user = do_nick(source, av[0], av[4], av[5], av[6], av[7], - strtoul(av[2], NULL, 10), 0, 0, "*", NULL); - if (user) - ircdproto->ProcessUsermodes(user, 1, &av[3]); - } else { - do_nick(source, av[0], NULL, NULL, NULL, NULL, - strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); - } - } - return MOD_CONT; + Server *s; + User *user; + + if (UseTS6 && ac == 9) { + s = findserver_uid(servlist, source); + /* Source is always the server */ + user = do_nick("", av[0], av[4], av[5], s->name, av[8], + strtoul(av[2], NULL, 10), 0, 0, "*", av[7]); + if (user) { + ircdproto->ProcessUsermodes(user, 1, &av[3]); + } + } else { + if (ac != 2) { + user = do_nick(source, av[0], av[4], av[5], av[6], av[7], + strtoul(av[2], NULL, 10), 0, 0, "*", NULL); + if (user) + ircdproto->ProcessUsermodes(user, 1, &av[3]); + } else { + do_nick(source, av[0], NULL, NULL, NULL, NULL, + strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); + } + } + return MOD_CONT; } int anope_event_topic(const char *source, int ac, const char **av) { - User *u; - - if (ac == 4) { - do_topic(source, ac, av); - } else { - Channel *c = findchan(av[0]); - time_t topic_time = time(NULL); - - if (!c) { - if (debug) { - alog("debug: TOPIC %s for nonexistent channel %s", - merge_args(ac - 1, av + 1), av[0]); - } - return MOD_CONT; - } - - if (check_topiclock(c, topic_time)) - return MOD_CONT; - - if (c->topic) { - free(c->topic); - c->topic = NULL; - } - if (ac > 1 && *av[1]) - c->topic = sstrdup(av[1]); - - if (UseTS6) { - u = find_byuid(source); - if (u) { - strscpy(c->topic_setter, u->nick, sizeof(c->topic_setter)); - } else { - strscpy(c->topic_setter, source, sizeof(c->topic_setter)); - } - } else { - strscpy(c->topic_setter, source, sizeof(c->topic_setter)); - } - c->topic_time = topic_time; - - record_topic(av[0]); + User *u; + + if (ac == 4) { + do_topic(source, ac, av); + } else { + Channel *c = findchan(av[0]); + time_t topic_time = time(NULL); + + if (!c) { + if (debug) { + alog("debug: TOPIC %s for nonexistent channel %s", + merge_args(ac - 1, av + 1), av[0]); + } + return MOD_CONT; + } + + if (check_topiclock(c, topic_time)) + return MOD_CONT; + + if (c->topic) { + free(c->topic); + c->topic = NULL; + } + if (ac > 1 && *av[1]) + c->topic = sstrdup(av[1]); + + if (UseTS6) { + u = find_byuid(source); + if (u) { + strscpy(c->topic_setter, u->nick, sizeof(c->topic_setter)); + } else { + strscpy(c->topic_setter, source, sizeof(c->topic_setter)); + } + } else { + strscpy(c->topic_setter, source, sizeof(c->topic_setter)); + } + c->topic_time = topic_time; + + record_topic(av[0]); if (ac > 1 && *av[1]) - send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[1]); + send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[1]); else - send_event(EVENT_TOPIC_UPDATED, 2, av[0], ""); - } - return MOD_CONT; + send_event(EVENT_TOPIC_UPDATED, 2, av[0], ""); + } + return MOD_CONT; } int anope_event_tburst(const char *source, int ac, const char **av) { - char *setter; - Channel *c; - time_t topic_time; - - if (ac != 4) { - return MOD_CONT; - } - - setter = myStrGetToken(av[2], '!', 0); - - c = findchan(av[0]); - topic_time = strtol(av[1], NULL, 10); - - if (!c) { - if (debug) { - alog("debug: TOPIC %s for nonexistent channel %s", - merge_args(ac - 1, av + 1), av[0]); - } - if (setter) - free(setter); - return MOD_CONT; - } - - if (check_topiclock(c, topic_time)) { - if (setter) - free(setter); - return MOD_CONT; - } - - if (c->topic) { - free(c->topic); - c->topic = NULL; - } - if (ac > 1 && *av[3]) - c->topic = sstrdup(av[3]); - - strscpy(c->topic_setter, setter, sizeof(c->topic_setter)); - c->topic_time = topic_time; - - record_topic(av[0]); - if (setter) - free(setter); - return MOD_CONT; + char *setter; + Channel *c; + time_t topic_time; + + if (ac != 4) { + return MOD_CONT; + } + + setter = myStrGetToken(av[2], '!', 0); + + c = findchan(av[0]); + topic_time = strtol(av[1], NULL, 10); + + if (!c) { + if (debug) { + alog("debug: TOPIC %s for nonexistent channel %s", + merge_args(ac - 1, av + 1), av[0]); + } + if (setter) + free(setter); + return MOD_CONT; + } + + if (check_topiclock(c, topic_time)) { + if (setter) + free(setter); + return MOD_CONT; + } + + if (c->topic) { + free(c->topic); + c->topic = NULL; + } + if (ac > 1 && *av[3]) + c->topic = sstrdup(av[3]); + + strscpy(c->topic_setter, setter, sizeof(c->topic_setter)); + c->topic_time = topic_time; + + record_topic(av[0]); + if (setter) + free(setter); + return MOD_CONT; } int anope_event_436(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; + if (ac < 1) + return MOD_CONT; - m_nickcoll(av[0]); - return MOD_CONT; + m_nickcoll(av[0]); + return MOD_CONT; } int anope_event_ping(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - ircdproto->SendPong(ac > 1 ? av[1] : ServerName, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + ircdproto->SendPong(ac > 1 ? av[1] : ServerName, av[0]); + return MOD_CONT; } int anope_event_away(const char *source, int ac, const char **av) { - User *u = NULL; + User *u = NULL; - if (UseTS6) { - u = find_byuid(source); - } + if (UseTS6) { + u = find_byuid(source); + } - m_away((UseTS6 ? (u ? u->nick : source) : source), - (ac ? av[0] : NULL)); - return MOD_CONT; + m_away((UseTS6 ? (u ? u->nick : source) : source), + (ac ? av[0] : NULL)); + return MOD_CONT; } int anope_event_kill(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - m_kill(av[0], av[1]); - return MOD_CONT; + m_kill(av[0], av[1]); + return MOD_CONT; } int anope_event_kick(const char *source, int ac, const char **av) { - if (ac != 3) - return MOD_CONT; - do_kick(source, ac, av); - return MOD_CONT; + if (ac != 3) + return MOD_CONT; + do_kick(source, ac, av); + return MOD_CONT; } int anope_event_join(const char *source, int ac, const char **av) { - if (ac != 1) { - do_sjoin(source, ac, av); - return MOD_CONT; - } else { - do_join(source, ac, av); - } - return MOD_CONT; + if (ac != 1) { + do_sjoin(source, ac, av); + return MOD_CONT; + } else { + do_join(source, ac, av); + } + return MOD_CONT; } int anope_event_motd(const char *source, int ac, const char **av) { - if (!source) { - return MOD_CONT; - } + if (!source) { + return MOD_CONT; + } - m_motd(source); - return MOD_CONT; + m_motd(source); + return MOD_CONT; } int anope_event_privmsg(const char *source, int ac, const char **av) { - User *u; + User *u; BotInfo *bi; - if (ac != 2) { - return MOD_CONT; - } + if (ac != 2) { + return MOD_CONT; + } - u = find_byuid(source); - bi = findbot(av[0]); + u = find_byuid(source); + bi = findbot(av[0]); // XXX: this is really the same as charybdis - m_privmsg(source, av[0], av[1]); - return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; } int anope_event_part(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac < 1 || ac > 2) { - return MOD_CONT; - } + if (ac < 1 || ac > 2) { + return MOD_CONT; + } - u = find_byuid(source); - do_part((UseTS6 ? (u ? u->nick : source) : source), ac, av); + u = find_byuid(source); + do_part((UseTS6 ? (u ? u->nick : source) : source), ac, av); - return MOD_CONT; + return MOD_CONT; } int anope_event_whois(const char *source, int ac, const char **av) { - BotInfo *bi; + BotInfo *bi; - if (source && ac >= 1) { - bi = findbot(av[0]); - m_whois(source, (UseTS6 ? bi->uid.c_str() : bi->nick)); - } - return MOD_CONT; + if (source && ac >= 1) { + bi = findbot(av[0]); + m_whois(source, (UseTS6 ? bi->uid.c_str() : bi->nick)); + } + return MOD_CONT; } /* EVENT: SERVER */ int anope_event_server(const char *source, int ac, const char **av) { - if (!stricmp(av[1], "1")) { - uplink = sstrdup(av[0]); - if (UseTS6 && TS6UPLINK) { - do_server(source, av[0], av[1], av[2], TS6UPLINK); - } else { - do_server(source, av[0], av[1], av[2], NULL); - } - } else { - do_server(source, av[0], av[1], av[2], NULL); - } - return MOD_CONT; + if (!stricmp(av[1], "1")) { + uplink = sstrdup(av[0]); + if (UseTS6 && TS6UPLINK) { + do_server(source, av[0], av[1], av[2], TS6UPLINK); + } else { + do_server(source, av[0], av[1], av[2], NULL); + } + } else { + do_server(source, av[0], av[1], av[2], NULL); + } + return MOD_CONT; } int anope_event_sid(const char *source, int ac, const char **av) { - Server *s; + Server *s; - /* :42X SID trystan.nomadirc.net 2 43X :ircd-ratbox test server */ + /* :42X SID trystan.nomadirc.net 2 43X :ircd-ratbox test server */ - s = findserver_uid(servlist, source); + s = findserver_uid(servlist, source); - do_server(s->name, av[0], av[1], av[3], av[2]); - return MOD_CONT; + do_server(s->name, av[0], av[1], av[3], av[2]); + return MOD_CONT; } int anope_event_squit(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; - do_squit(source, ac, av); - return MOD_CONT; + if (ac != 2) + return MOD_CONT; + do_squit(source, ac, av); + return MOD_CONT; } int anope_event_quit(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 1) { - return MOD_CONT; - } + if (ac != 1) { + return MOD_CONT; + } - u = find_byuid(source); + u = find_byuid(source); - do_quit((UseTS6 ? (u ? u->nick : source) : source), ac, av); - return MOD_CONT; + do_quit((UseTS6 ? (u ? u->nick : source) : source), ac, av); + return MOD_CONT; } int anope_event_mode(const char *source, int ac, const char **av) { - User *u, *u2; - - if (ac < 2) { - return MOD_CONT; - } - - if (*av[0] == '#' || *av[0] == '&') { - do_cmode(source, ac, av); - } else { - if (UseTS6) { - u = find_byuid(source); - u2 = find_byuid(av[0]); - av[0] = u2->nick; - do_umode(u->nick, ac, av); - } else { - do_umode(source, ac, av); - } - } - return MOD_CONT; + User *u, *u2; + + if (ac < 2) { + return MOD_CONT; + } + + if (*av[0] == '#' || *av[0] == '&') { + do_cmode(source, ac, av); + } else { + if (UseTS6) { + u = find_byuid(source); + u2 = find_byuid(av[0]); + av[0] = u2->nick; + do_umode(u->nick, ac, av); + } else { + do_umode(source, ac, av); + } + } + return MOD_CONT; } int anope_event_tmode(const char *source, int ac, const char **av) { - if (*av[1] == '#' || *av[1] == '&') { - do_cmode(source, ac, av); - } - return MOD_CONT; + if (*av[1] == '#' || *av[1] == '&') { + do_cmode(source, ac, av); + } + return MOD_CONT; } /* Event: PROTOCTL */ int anope_event_capab(const char *source, int ac, const char **av) { - int argvsize = 8; - int argc; - const char **argv; - char *str; - - if (ac < 1) - return MOD_CONT; - - /* We get the params as one arg, we should split it for capab_parse */ - argv = (const char **)scalloc(argvsize, sizeof(const char *)); - argc = 0; - while ((str = myStrGetToken(av[0], ' ', argc))) { - if (argc == argvsize) { - argvsize += 8; - argv = (const char **)srealloc(argv, argvsize * sizeof(const char *)); - } - argv[argc] = str; - argc++; - } - - capab_parse(argc, argv); - - /* Free our built ac/av */ - for (argvsize = 0; argvsize < argc; argvsize++) { - free((char *)argv[argvsize]); - } - free((char **)argv); - - return MOD_CONT; + int argvsize = 8; + int argc; + const char **argv; + char *str; + + if (ac < 1) + return MOD_CONT; + + /* We get the params as one arg, we should split it for capab_parse */ + argv = (const char **)scalloc(argvsize, sizeof(const char *)); + argc = 0; + while ((str = myStrGetToken(av[0], ' ', argc))) { + if (argc == argvsize) { + argvsize += 8; + argv = (const char **)srealloc(argv, argvsize * sizeof(const char *)); + } + argv[argc] = str; + argc++; + } + + capab_parse(argc, argv); + + /* Free our built ac/av */ + for (argvsize = 0; argvsize < argc; argvsize++) { + free((char *)argv[argvsize]); + } + free((char **)argv); + + return MOD_CONT; } int anope_event_pass(const char *source, int ac, const char **av) { - if (UseTS6) { - TS6UPLINK = sstrdup(av[3]); - } - return MOD_CONT; + if (UseTS6) { + TS6UPLINK = sstrdup(av[3]); + } + return MOD_CONT; } int anope_event_bmask(const char *source, int ac, const char **av) { - Channel *c; - char *bans; - char *b; - int count, i; - - /* :42X BMASK 1106409026 #ircops b :*!*@*.aol.com */ - /* 0 1 2 3 */ - c = findchan(av[1]); - - if (c) { - bans = sstrdup(av[3]); - count = myNumToken(bans, ' '); - for (i = 0; i <= count - 1; i++) { - b = myStrGetToken(bans, ' ', i); - if (!stricmp(av[2], "b")) { - add_ban(c, b); - } - if (!stricmp(av[2], "e")) { - add_exception(c, b); - } - if (!stricmp(av[2], "I")) { - add_invite(c, b); - } - if (b) - free(b); - } - free(bans); - } - return MOD_CONT; + Channel *c; + char *bans; + char *b; + int count, i; + + /* :42X BMASK 1106409026 #ircops b :*!*@*.aol.com */ + /* 0 1 2 3 */ + c = findchan(av[1]); + + if (c) { + bans = sstrdup(av[3]); + count = myNumToken(bans, ' '); + for (i = 0; i <= count - 1; i++) { + b = myStrGetToken(bans, ' ', i); + if (!stricmp(av[2], "b")) { + add_ban(c, b); + } + if (!stricmp(av[2], "e")) { + add_exception(c, b); + } + if (!stricmp(av[2], "I")) { + add_invite(c, b); + } + if (b) + free(b); + } + free(bans); + } + return MOD_CONT; } int anope_event_error(const char *source, int ac, const char **av) { - if (ac >= 1) { - if (debug) { - alog("debug: %s", av[0]); - } - } - return MOD_CONT; + if (ac >= 1) { + if (debug) { + alog("debug: %s", av[0]); + } + } + return MOD_CONT; } void moduleAddIRCDMsgs(void) { - Message *m; - - updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+","-"); - - m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); - m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); - m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); - m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); - m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); - m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); - m = createMessage("TMODE", anope_event_tmode); addCoreMessage(IRCD,m); - m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); - m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); - m = createMessage("BMASK", anope_event_bmask); addCoreMessage(IRCD,m); - m = createMessage("UID", anope_event_nick); addCoreMessage(IRCD,m); - m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); - m = createMessage("PASS", anope_event_pass); addCoreMessage(IRCD,m); - m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); - m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); - m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); - m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); - m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); - m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); - m = createMessage("TB", anope_event_tburst); addCoreMessage(IRCD,m); - m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); - m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); - m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); - m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m); - m = createMessage("SID", anope_event_sid); addCoreMessage(IRCD,m); + Message *m; + + updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+","-"); + + m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); + m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); + m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); + m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); + m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); + m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("TMODE", anope_event_tmode); addCoreMessage(IRCD,m); + m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); + m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("BMASK", anope_event_bmask); addCoreMessage(IRCD,m); + m = createMessage("UID", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); + m = createMessage("PASS", anope_event_pass); addCoreMessage(IRCD,m); + m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); + m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); + m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); + m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); + m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); + m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); + m = createMessage("TB", anope_event_tburst); addCoreMessage(IRCD,m); + m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); + m = createMessage("CAPAB", anope_event_capab); addCoreMessage(IRCD,m); + m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); + m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m); + m = createMessage("SID", anope_event_sid); addCoreMessage(IRCD,m); } class ProtoRatbox : public Module diff --git a/src/protocol/unreal32.c b/src/protocol/unreal32.c index 8f1a31549..ab52ddf43 100644 --- a/src/protocol/unreal32.c +++ b/src/protocol/unreal32.c @@ -85,381 +85,381 @@ #define DEFAULT_MLOCK CMODE_n | CMODE_t | CMODE_r IRCDVar myIrcd[] = { - {"UnrealIRCd 3.2.x", /* ircd name */ - "+Soi", /* Modes used by pseudoclients */ - 5, /* Chan Max Symbols */ - "-cilmnpstuzACGHKMNOQRSTV", /* Modes to Remove */ - "+ao", /* Channel Umode used by Botserv bots */ - 1, /* SVSNICK */ - 1, /* Vhost */ - 1, /* Has Owner */ - "+q", /* Mode to set for an owner */ - "-q", /* Mode to unset for an owner */ - "+a", /* Mode to set for channel admin */ - "-a", /* Mode to unset for channel admin */ - "+rd", /* Mode On Reg */ - NULL, /* Mode on ID for Roots */ - NULL, /* Mode on ID for Admins */ - NULL, /* Mode on ID for Opers */ - "-r+d", /* Mode on UnReg */ - "-r+d", /* Mode on Nick Change */ - 1, /* Supports SGlines */ - 1, /* Supports SQlines */ - 1, /* Supports SZlines */ - 1, /* Supports Halfop +h */ - 3, /* Number of server args */ - 0, /* Join 2 Set */ - 0, /* Join 2 Message */ - 1, /* Has exceptions +e */ - 1, /* TS Topic Forward */ - 0, /* TS Topci Backward */ - UMODE_S, /* Protected Umode */ - 0, /* Has Admin */ - 0, /* Chan SQlines */ - 0, /* Quit on Kill */ - 1, /* SVSMODE unban */ - 1, /* Has Protect */ - 1, /* Reverse */ - 1, /* Chan Reg */ - CMODE_r, /* Channel Mode */ - 1, /* vidents */ - 1, /* svshold */ - 1, /* time stamp on mode */ - 1, /* NICKIP */ - 1, /* O:LINE */ - 1, /* UMODE */ - 1, /* VHOST ON NICK */ - 1, /* Change RealName */ - CMODE_K, /* No Knock */ - CMODE_A, /* Admin Only */ - DEFAULT_MLOCK, /* Default MLOCK */ - UMODE_x, /* Vhost Mode */ - 1, /* +f */ - 1, /* +L */ - CMODE_f, /* +f Mode */ - CMODE_L, /* +L Mode */ - 0, /* On nick change check if they could be identified */ - 1, /* No Knock requires +i */ - NULL, /* CAPAB Chan Modes */ - 1, /* We support Unreal TOKENS */ - 1, /* TIME STAMPS are BASE64 */ - 1, /* +I support */ - '&', /* SJOIN ban char */ - '\"', /* SJOIN except char */ - '\'', /* SJOIN invite char */ - 1, /* Can remove User Channel Modes with SVSMODE */ - 0, /* Sglines are not enforced until user reconnects */ - "x", /* vhost char */ - 0, /* ts6 */ - 1, /* support helper umode */ - 0, /* p10 */ - NULL, /* character set */ - 1, /* reports sync state */ - 0, /* CIDR channelbans */ - "$", /* TLD Prefix for Global */ - } - , - {NULL} + {"UnrealIRCd 3.2.x", /* ircd name */ + "+Soi", /* Modes used by pseudoclients */ + 5, /* Chan Max Symbols */ + "-cilmnpstuzACGHKMNOQRSTV", /* Modes to Remove */ + "+ao", /* Channel Umode used by Botserv bots */ + 1, /* SVSNICK */ + 1, /* Vhost */ + 1, /* Has Owner */ + "+q", /* Mode to set for an owner */ + "-q", /* Mode to unset for an owner */ + "+a", /* Mode to set for channel admin */ + "-a", /* Mode to unset for channel admin */ + "+rd", /* Mode On Reg */ + NULL, /* Mode on ID for Roots */ + NULL, /* Mode on ID for Admins */ + NULL, /* Mode on ID for Opers */ + "-r+d", /* Mode on UnReg */ + "-r+d", /* Mode on Nick Change */ + 1, /* Supports SGlines */ + 1, /* Supports SQlines */ + 1, /* Supports SZlines */ + 1, /* Supports Halfop +h */ + 3, /* Number of server args */ + 0, /* Join 2 Set */ + 0, /* Join 2 Message */ + 1, /* Has exceptions +e */ + 1, /* TS Topic Forward */ + 0, /* TS Topci Backward */ + UMODE_S, /* Protected Umode */ + 0, /* Has Admin */ + 0, /* Chan SQlines */ + 0, /* Quit on Kill */ + 1, /* SVSMODE unban */ + 1, /* Has Protect */ + 1, /* Reverse */ + 1, /* Chan Reg */ + CMODE_r, /* Channel Mode */ + 1, /* vidents */ + 1, /* svshold */ + 1, /* time stamp on mode */ + 1, /* NICKIP */ + 1, /* O:LINE */ + 1, /* UMODE */ + 1, /* VHOST ON NICK */ + 1, /* Change RealName */ + CMODE_K, /* No Knock */ + CMODE_A, /* Admin Only */ + DEFAULT_MLOCK, /* Default MLOCK */ + UMODE_x, /* Vhost Mode */ + 1, /* +f */ + 1, /* +L */ + CMODE_f, /* +f Mode */ + CMODE_L, /* +L Mode */ + 0, /* On nick change check if they could be identified */ + 1, /* No Knock requires +i */ + NULL, /* CAPAB Chan Modes */ + 1, /* We support Unreal TOKENS */ + 1, /* TIME STAMPS are BASE64 */ + 1, /* +I support */ + '&', /* SJOIN ban char */ + '\"', /* SJOIN except char */ + '\'', /* SJOIN invite char */ + 1, /* Can remove User Channel Modes with SVSMODE */ + 0, /* Sglines are not enforced until user reconnects */ + "x", /* vhost char */ + 0, /* ts6 */ + 1, /* support helper umode */ + 0, /* p10 */ + NULL, /* character set */ + 1, /* reports sync state */ + 0, /* CIDR channelbans */ + "$", /* TLD Prefix for Global */ + } + , + {NULL} }; IRCDCAPAB myIrcdcap[] = { - { - CAPAB_NOQUIT, /* NOQUIT */ - 0, /* TSMODE */ - 0, /* UNCONNECT */ - CAPAB_NICKIP, /* NICKIP */ - 0, /* SJOIN */ - CAPAB_ZIP, /* ZIP */ - 0, /* BURST */ - 0, /* TS5 */ - 0, /* TS3 */ - 0, /* DKEY */ - 0, /* PT4 */ - 0, /* SCS */ - 0, /* QS */ - 0, /* UID */ - 0, /* KNOCK */ - 0, /* CLIENT */ - 0, /* IPV6 */ - 0, /* SSJ5 */ - 0, /* SN2 */ - CAPAB_TOKEN, /* TOKEN */ - 0, /* VHOST */ - CAPAB_SSJ3, /* SSJ3 */ - CAPAB_NICK2, /* NICK2 */ - CAPAB_UMODE2, /* UMODE2 */ - CAPAB_VL, /* VL */ - CAPAB_TLKEXT, /* TLKEXT */ - 0, /* DODKEY */ - 0, /* DOZIP */ - CAPAB_CHANMODE, /* CHANMODE */ - CAPAB_SJB64, - CAPAB_NICKCHARS, - } + { + CAPAB_NOQUIT, /* NOQUIT */ + 0, /* TSMODE */ + 0, /* UNCONNECT */ + CAPAB_NICKIP, /* NICKIP */ + 0, /* SJOIN */ + CAPAB_ZIP, /* ZIP */ + 0, /* BURST */ + 0, /* TS5 */ + 0, /* TS3 */ + 0, /* DKEY */ + 0, /* PT4 */ + 0, /* SCS */ + 0, /* QS */ + 0, /* UID */ + 0, /* KNOCK */ + 0, /* CLIENT */ + 0, /* IPV6 */ + 0, /* SSJ5 */ + 0, /* SN2 */ + CAPAB_TOKEN, /* TOKEN */ + 0, /* VHOST */ + CAPAB_SSJ3, /* SSJ3 */ + CAPAB_NICK2, /* NICK2 */ + CAPAB_UMODE2, /* UMODE2 */ + CAPAB_VL, /* VL */ + CAPAB_TLKEXT, /* TLKEXT */ + 0, /* DODKEY */ + 0, /* DOZIP */ + CAPAB_CHANMODE, /* CHANMODE */ + CAPAB_SJB64, + CAPAB_NICKCHARS, + } }; unsigned long umodes[128] = { - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused, Unused, Horzontal Tab */ - 0, 0, 0, /* Line Feed, Unused, Unused */ - 0, 0, 0, /* Carriage Return, Unused, Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused */ - 0, 0, 0, /* Unused, Unused, Space */ - 0, 0, 0, /* ! " # */ - 0, 0, 0, /* $ % & */ - 0, 0, 0, /* ! ( ) */ - 0, 0, 0, /* * + , */ - 0, 0, 0, /* - . / */ - 0, 0, /* 0 1 */ - 0, 0, /* 2 3 */ - 0, 0, /* 4 5 */ - 0, 0, /* 6 7 */ - 0, 0, /* 8 9 */ - 0, 0, /* : ; */ - 0, 0, 0, /* < = > */ - 0, 0, /* ? @ */ - UMODE_A, UMODE_B, UMODE_C, /* A B C */ - 0, 0, 0, /* D E F */ - UMODE_G, UMODE_H, 0, /* G H I */ - 0, 0, 0, /* J K L */ - 0, UMODE_N, UMODE_O, /* M N O */ - 0, 0, UMODE_R, /* P Q R */ - UMODE_S, UMODE_T, 0, /* S T U */ - UMODE_V, UMODE_W, 0, /* V W X */ - 0, /* Y */ - 0, /* Z */ - 0, 0, 0, /* [ \ ] */ - 0, 0, 0, /* ^ _ ` */ - UMODE_a, 0, 0, /* a b c */ - UMODE_d, 0, 0, /* d e f */ - UMODE_g, UMODE_h, UMODE_i, /* g h i */ - 0, 0, 0, /* j k l */ - 0, 0, UMODE_o, /* m n o */ - UMODE_p, UMODE_q, UMODE_r, /* p q r */ - UMODE_s, UMODE_t, 0, /* s t u */ - UMODE_v, UMODE_w, UMODE_x, /* v w x */ - 0, /* y */ - UMODE_z, /* z */ - 0, 0, 0, /* { | } */ - 0, 0 /* ~ � */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused, Unused, Horzontal Tab */ + 0, 0, 0, /* Line Feed, Unused, Unused */ + 0, 0, 0, /* Carriage Return, Unused, Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused */ + 0, 0, 0, /* Unused, Unused, Space */ + 0, 0, 0, /* ! " # */ + 0, 0, 0, /* $ % & */ + 0, 0, 0, /* ! ( ) */ + 0, 0, 0, /* * + , */ + 0, 0, 0, /* - . / */ + 0, 0, /* 0 1 */ + 0, 0, /* 2 3 */ + 0, 0, /* 4 5 */ + 0, 0, /* 6 7 */ + 0, 0, /* 8 9 */ + 0, 0, /* : ; */ + 0, 0, 0, /* < = > */ + 0, 0, /* ? @ */ + UMODE_A, UMODE_B, UMODE_C, /* A B C */ + 0, 0, 0, /* D E F */ + UMODE_G, UMODE_H, 0, /* G H I */ + 0, 0, 0, /* J K L */ + 0, UMODE_N, UMODE_O, /* M N O */ + 0, 0, UMODE_R, /* P Q R */ + UMODE_S, UMODE_T, 0, /* S T U */ + UMODE_V, UMODE_W, 0, /* V W X */ + 0, /* Y */ + 0, /* Z */ + 0, 0, 0, /* [ \ ] */ + 0, 0, 0, /* ^ _ ` */ + UMODE_a, 0, 0, /* a b c */ + UMODE_d, 0, 0, /* d e f */ + UMODE_g, UMODE_h, UMODE_i, /* g h i */ + 0, 0, 0, /* j k l */ + 0, 0, UMODE_o, /* m n o */ + UMODE_p, UMODE_q, UMODE_r, /* p q r */ + UMODE_s, UMODE_t, 0, /* s t u */ + UMODE_v, UMODE_w, UMODE_x, /* v w x */ + 0, /* y */ + UMODE_z, /* z */ + 0, 0, 0, /* { | } */ + 0, 0 /* ~ � */ }; char myCsmodes[128] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, - 0, - 0, 0, 0, - 'h', /* (37) % Channel halfops */ - 'b', /* (38) & bans */ - 0, 0, 0, - 'q', + 0, + 0, + 0, 0, 0, + 'h', /* (37) % Channel halfops */ + 'b', /* (38) & bans */ + 0, 0, 0, + 'q', - 'v', 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'v', 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'a', 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'a', 0 }; CMMode myCmmodes[128] = { - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, /* BCD */ - {NULL}, {NULL}, {NULL}, /* EFG */ - {NULL}, /* H */ - {add_invite, del_invite}, /* I */ - {NULL}, /* J */ - {NULL}, {NULL}, {NULL}, /* KLM */ - {NULL}, {NULL}, {NULL}, /* NOP */ - {NULL}, {NULL}, {NULL}, /* QRS */ - {NULL}, {NULL}, {NULL}, /* TUV */ - {NULL}, {NULL}, {NULL}, /* WXY */ - {NULL}, /* Z */ - {NULL}, {NULL}, /* (char 91 - 92) */ - {NULL}, {NULL}, {NULL}, /* (char 93 - 95) */ - {NULL}, /* ` (char 96) */ - {NULL}, /* a (char 97) */ - {add_ban, del_ban}, /* b */ - {NULL}, {NULL}, /* cd */ - {add_exception, del_exception}, - {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, - {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, /* BCD */ + {NULL}, {NULL}, {NULL}, /* EFG */ + {NULL}, /* H */ + {add_invite, del_invite}, /* I */ + {NULL}, /* J */ + {NULL}, {NULL}, {NULL}, /* KLM */ + {NULL}, {NULL}, {NULL}, /* NOP */ + {NULL}, {NULL}, {NULL}, /* QRS */ + {NULL}, {NULL}, {NULL}, /* TUV */ + {NULL}, {NULL}, {NULL}, /* WXY */ + {NULL}, /* Z */ + {NULL}, {NULL}, /* (char 91 - 92) */ + {NULL}, {NULL}, {NULL}, /* (char 93 - 95) */ + {NULL}, /* ` (char 96) */ + {NULL}, /* a (char 97) */ + {add_ban, del_ban}, /* b */ + {NULL}, {NULL}, /* cd */ + {add_exception, del_exception}, + {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, + {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL} }; CBMode myCbmodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, - {CMODE_A, CBM_NO_USER_MLOCK, NULL, NULL}, - {0}, /* B */ - {CMODE_C, 0, NULL, NULL}, /* C */ - {0}, /* D */ - {0}, /* E */ - {0}, /* F */ - {CMODE_G, 0, NULL, NULL}, /* G */ - {0}, /* H */ - {0}, /* I */ - {0}, /* J */ - {CMODE_K, 0, NULL, NULL}, /* K */ - {CMODE_L, 0, set_redirect, cs_set_redirect}, - {CMODE_M, 0, NULL, NULL}, /* M */ - {CMODE_N, 0, NULL, NULL}, /* N */ - {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, - {0}, /* P */ - {CMODE_Q, 0, NULL, NULL}, /* Q */ - {CMODE_R, 0, NULL, NULL}, /* R */ - {CMODE_S, 0, NULL, NULL}, /* S */ - {CMODE_T, 0, NULL, NULL}, /* T */ - {0}, /* U */ - {CMODE_V, 0, NULL, NULL}, /* V */ - {0}, /* W */ - {0}, /* X */ - {0}, /* Y */ - {0}, /* Z */ - {0}, {0}, {0}, {0}, {0}, {0}, - {0}, /* a */ - {0}, /* b */ - {CMODE_c, 0, NULL, NULL}, - {0}, /* d */ - {0}, /* e */ - {CMODE_f, 0, set_flood, cs_set_flood}, - {0}, /* g */ - {0}, /* h */ - {CMODE_i, 0, NULL, NULL}, - {0}, /* j */ - {CMODE_k, 0, chan_set_key, cs_set_key}, - {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, - {CMODE_m, 0, NULL, NULL}, - {CMODE_n, 0, NULL, NULL}, - {0}, /* o */ - {CMODE_p, 0, NULL, NULL}, - {0}, /* q */ - {CMODE_r, CBM_NO_MLOCK, NULL, NULL}, - {CMODE_s, 0, NULL, NULL}, - {CMODE_t, 0, NULL, NULL}, - {CMODE_u, 0, NULL, NULL}, - {0}, /* v */ - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {CMODE_z, 0, NULL, NULL}, - {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, + {CMODE_A, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* B */ + {CMODE_C, 0, NULL, NULL}, /* C */ + {0}, /* D */ + {0}, /* E */ + {0}, /* F */ + {CMODE_G, 0, NULL, NULL}, /* G */ + {0}, /* H */ + {0}, /* I */ + {0}, /* J */ + {CMODE_K, 0, NULL, NULL}, /* K */ + {CMODE_L, 0, set_redirect, cs_set_redirect}, + {CMODE_M, 0, NULL, NULL}, /* M */ + {CMODE_N, 0, NULL, NULL}, /* N */ + {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL}, + {0}, /* P */ + {CMODE_Q, 0, NULL, NULL}, /* Q */ + {CMODE_R, 0, NULL, NULL}, /* R */ + {CMODE_S, 0, NULL, NULL}, /* S */ + {CMODE_T, 0, NULL, NULL}, /* T */ + {0}, /* U */ + {CMODE_V, 0, NULL, NULL}, /* V */ + {0}, /* W */ + {0}, /* X */ + {0}, /* Y */ + {0}, /* Z */ + {0}, {0}, {0}, {0}, {0}, {0}, + {0}, /* a */ + {0}, /* b */ + {CMODE_c, 0, NULL, NULL}, + {0}, /* d */ + {0}, /* e */ + {CMODE_f, 0, set_flood, cs_set_flood}, + {0}, /* g */ + {0}, /* h */ + {CMODE_i, 0, NULL, NULL}, + {0}, /* j */ + {CMODE_k, 0, chan_set_key, cs_set_key}, + {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit}, + {CMODE_m, 0, NULL, NULL}, + {CMODE_n, 0, NULL, NULL}, + {0}, /* o */ + {CMODE_p, 0, NULL, NULL}, + {0}, /* q */ + {CMODE_r, CBM_NO_MLOCK, NULL, NULL}, + {CMODE_s, 0, NULL, NULL}, + {CMODE_t, 0, NULL, NULL}, + {CMODE_u, 0, NULL, NULL}, + {0}, /* v */ + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {CMODE_z, 0, NULL, NULL}, + {0}, {0}, {0}, {0} }; CBModeInfo myCbmodeinfos[] = { - {'c', CMODE_c, 0, NULL, NULL}, - {'f', CMODE_f, 0, get_flood, cs_get_flood}, - {'i', CMODE_i, 0, NULL, NULL}, - {'k', CMODE_k, 0, get_key, cs_get_key}, - {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, - {'m', CMODE_m, 0, NULL, NULL}, - {'n', CMODE_n, 0, NULL, NULL}, - {'p', CMODE_p, 0, NULL, NULL}, - {'r', CMODE_r, 0, NULL, NULL}, - {'s', CMODE_s, 0, NULL, NULL}, - {'t', CMODE_t, 0, NULL, NULL}, - {'u', CMODE_u, 0, NULL, NULL}, - {'z', CMODE_z, 0, NULL, NULL}, - {'A', CMODE_A, 0, NULL, NULL}, - {'C', CMODE_C, 0, NULL, NULL}, - {'G', CMODE_G, 0, NULL, NULL}, - {'K', CMODE_K, 0, NULL, NULL}, - {'L', CMODE_L, 0, get_redirect, cs_get_redirect}, - {'M', CMODE_M, 0, NULL, NULL}, - {'N', CMODE_N, 0, NULL, NULL}, - {'O', CMODE_O, 0, NULL, NULL}, - {'Q', CMODE_Q, 0, NULL, NULL}, - {'R', CMODE_R, 0, NULL, NULL}, - {'S', CMODE_S, 0, NULL, NULL}, - {'T', CMODE_T, 0, NULL, NULL}, - {'V', CMODE_V, 0, NULL, NULL}, - {0} + {'c', CMODE_c, 0, NULL, NULL}, + {'f', CMODE_f, 0, get_flood, cs_get_flood}, + {'i', CMODE_i, 0, NULL, NULL}, + {'k', CMODE_k, 0, get_key, cs_get_key}, + {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit}, + {'m', CMODE_m, 0, NULL, NULL}, + {'n', CMODE_n, 0, NULL, NULL}, + {'p', CMODE_p, 0, NULL, NULL}, + {'r', CMODE_r, 0, NULL, NULL}, + {'s', CMODE_s, 0, NULL, NULL}, + {'t', CMODE_t, 0, NULL, NULL}, + {'u', CMODE_u, 0, NULL, NULL}, + {'z', CMODE_z, 0, NULL, NULL}, + {'A', CMODE_A, 0, NULL, NULL}, + {'C', CMODE_C, 0, NULL, NULL}, + {'G', CMODE_G, 0, NULL, NULL}, + {'K', CMODE_K, 0, NULL, NULL}, + {'L', CMODE_L, 0, get_redirect, cs_get_redirect}, + {'M', CMODE_M, 0, NULL, NULL}, + {'N', CMODE_N, 0, NULL, NULL}, + {'O', CMODE_O, 0, NULL, NULL}, + {'Q', CMODE_Q, 0, NULL, NULL}, + {'R', CMODE_R, 0, NULL, NULL}, + {'S', CMODE_S, 0, NULL, NULL}, + {'T', CMODE_T, 0, NULL, NULL}, + {'V', CMODE_V, 0, NULL, NULL}, + {0} }; CUMode myCumodes[128] = { - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, - - {0}, - - {CUS_PROTECT, CUF_PROTECT_BOTSERV, check_valid_op}, - {0}, /* b */ - {0}, /* c */ - {0}, /* d */ - {0}, /* e */ - {0}, /* f */ - {0}, /* g */ - {CUS_HALFOP, 0, check_valid_op}, - {0}, /* i */ - {0}, /* j */ - {0}, /* k */ - {0}, /* l */ - {0}, /* m */ - {0}, /* n */ - {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, - {0}, /* p */ - {CUS_OWNER, 0, check_valid_op}, - {0}, /* r */ - {0}, /* s */ - {0}, /* t */ - {0}, /* u */ - {CUS_VOICE, 0, NULL}, - {0}, /* w */ - {0}, /* x */ - {0}, /* y */ - {0}, /* z */ - {0}, {0}, {0}, {0}, {0} + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, + + {0}, + + {CUS_PROTECT, CUF_PROTECT_BOTSERV, check_valid_op}, + {0}, /* b */ + {0}, /* c */ + {0}, /* d */ + {0}, /* e */ + {0}, /* f */ + {0}, /* g */ + {CUS_HALFOP, 0, check_valid_op}, + {0}, /* i */ + {0}, /* j */ + {0}, /* k */ + {0}, /* l */ + {0}, /* m */ + {0}, /* n */ + {CUS_OP, CUF_PROTECT_BOTSERV, check_valid_op}, + {0}, /* p */ + {CUS_OWNER, 0, check_valid_op}, + {0}, /* r */ + {0}, /* s */ + {0}, /* t */ + {0}, /* u */ + {CUS_VOICE, 0, NULL}, + {0}, /* w */ + {0}, /* x */ + {0}, /* y */ + {0}, /* z */ + {0}, {0}, {0}, {0}, {0} }; @@ -470,26 +470,26 @@ CUMode myCumodes[128] = { */ void unreal_cmd_svswatch(const char *sender, const char *nick, const char *parm) { - send_cmd(sender, "Bw %s :%s", nick, parm); + send_cmd(sender, "Bw %s :%s", nick, parm); } void unreal_cmd_netinfo(int ac, const char **av) { - send_cmd(NULL, "AO %ld %ld %d %s 0 0 0 :%s", (long int) maxusercnt, (long int) time(NULL), atoi(av[2]), av[3], av[7]); + send_cmd(NULL, "AO %ld %ld %d %s 0 0 0 :%s", (long int) maxusercnt, (long int) time(NULL), atoi(av[2]), av[3], av[7]); } /* PROTOCTL */ /* NICKv2 = Nick Version 2 - VHP = Sends hidden host + VHP = Sends hidden host UMODE2 = sends UMODE2 on user modes NICKIP = Sends IP on NICK TOKEN = Use tokens to talk - SJ3 = Supports SJOIN + SJ3 = Supports SJOIN NOQUIT = No Quit TKLEXT = Extended TKL we don't use it but best to have it SJB64 = Base64 encoded time stamps - VL = Version Info - NS = Numeric Server + VL = Version Info + NS = Numeric Server */ void unreal_cmd_capab() @@ -507,25 +507,25 @@ void unreal_cmd_capab() /* PASS */ void unreal_cmd_pass(const char *pass) { - send_cmd(NULL, "PASS :%s", pass); + send_cmd(NULL, "PASS :%s", pass); } /* CHGHOST */ void unreal_cmd_chghost(const char *nick, const char *vhost) { - if (!nick || !vhost) { - return; - } - send_cmd(ServerName, "AL %s %s", nick, vhost); + if (!nick || !vhost) { + return; + } + send_cmd(ServerName, "AL %s %s", nick, vhost); } /* CHGIDENT */ void unreal_cmd_chgident(const char *nick, const char *vIdent) { - if (!nick || !vIdent) { - return; - } - send_cmd(ServerName, "AZ %s %s", nick, vIdent); + if (!nick || !vIdent) { + return; + } + send_cmd(ServerName, "AZ %s %s", nick, vIdent); } @@ -715,9 +715,9 @@ class UnrealIRCdProto : public IRCDProto /* ** svso - ** parv[0] = sender prefix - ** parv[1] = nick - ** parv[2] = options + ** parv[0] = sender prefix + ** parv[1] = nick + ** parv[2] = options */ void SendSVSO(const char *source, const char *nick, const char *flag) { @@ -927,17 +927,17 @@ class UnrealIRCdProto : public IRCDProto /* Event: PROTOCTL */ int anope_event_capab(const char *source, int ac, const char **av) { - capab_parse(ac, av); - return MOD_CONT; + capab_parse(ac, av); + return MOD_CONT; } /* Events */ int anope_event_ping(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; - ircdproto->SendPong(ac > 1 ? av[1] : ServerName, av[0]); - return MOD_CONT; + if (ac < 1) + return MOD_CONT; + ircdproto->SendPong(ac > 1 ? av[1] : ServerName, av[0]); + return MOD_CONT; } /* netinfo @@ -952,45 +952,45 @@ int anope_event_ping(const char *source, int ac, const char **av) */ int anope_event_netinfo(const char *source, int ac, const char **av) { - unreal_cmd_netinfo(ac, av); - return MOD_CONT; + unreal_cmd_netinfo(ac, av); + return MOD_CONT; } int anope_event_eos(const char *source, int ac, const char **av) { - Server *s; - s = findserver(servlist, source); - /* If we found a server with the given source, that one just - * finished bursting. If there was no source, then our uplink - * server finished bursting. -GD - */ - if (!s && serv_uplink) - s = serv_uplink; - finish_sync(s, 1); - return MOD_CONT; + Server *s; + s = findserver(servlist, source); + /* If we found a server with the given source, that one just + * finished bursting. If there was no source, then our uplink + * server finished bursting. -GD + */ + if (!s && serv_uplink) + s = serv_uplink; + finish_sync(s, 1); + return MOD_CONT; } int anope_event_436(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; + if (ac < 1) + return MOD_CONT; - m_nickcoll(av[0]); - return MOD_CONT; + m_nickcoll(av[0]); + return MOD_CONT; } /* ** away -** parv[0] = sender prefix -** parv[1] = away message +** parv[0] = sender prefix +** parv[1] = away message */ int anope_event_away(const char *source, int ac, const char **av) { - if (!source) { - return MOD_CONT; - } - m_away(source, (ac ? av[0] : NULL)); - return MOD_CONT; + if (!source) { + return MOD_CONT; + } + m_away(source, (ac ? av[0] : NULL)); + return MOD_CONT; } /* @@ -1007,426 +1007,426 @@ int anope_event_away(const char *source, int ac, const char **av) */ int anope_event_topic(const char *source, int ac, const char **av) { - if (ac != 4) - return MOD_CONT; - do_topic(source, ac, av); - return MOD_CONT; + if (ac != 4) + return MOD_CONT; + do_topic(source, ac, av); + return MOD_CONT; } int anope_event_squit(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; - do_squit(source, ac, av); - return MOD_CONT; + if (ac != 2) + return MOD_CONT; + do_squit(source, ac, av); + return MOD_CONT; } int anope_event_quit(const char *source, int ac, const char **av) { - if (ac != 1) - return MOD_CONT; - do_quit(source, ac, av); - return MOD_CONT; + if (ac != 1) + return MOD_CONT; + do_quit(source, ac, av); + return MOD_CONT; } int anope_event_mode(const char *source, int ac, const char **av) { - if (ac < 2) - return MOD_CONT; - - if (*av[0] == '#' || *av[0] == '&') { - do_cmode(source, ac, av); - } else { - do_umode(source, ac, av); - } - return MOD_CONT; + if (ac < 2) + return MOD_CONT; + + if (*av[0] == '#' || *av[0] == '&') { + do_cmode(source, ac, av); + } else { + do_umode(source, ac, av); + } + return MOD_CONT; } /* Unreal sends USER modes with this */ /* - umode2 - parv[0] - sender - parv[1] - modes to change + umode2 + parv[0] - sender + parv[1] - modes to change */ int anope_event_umode2(const char *source, int ac, const char **av) { - if (ac < 1) - return MOD_CONT; + if (ac < 1) + return MOD_CONT; - do_umode2(source, ac, av); - return MOD_CONT; + do_umode2(source, ac, av); + return MOD_CONT; } int anope_event_kill(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - m_kill(av[0], av[1]); - return MOD_CONT; + m_kill(av[0], av[1]); + return MOD_CONT; } int anope_event_kick(const char *source, int ac, const char **av) { - if (ac != 3) - return MOD_CONT; - do_kick(source, ac, av); - return MOD_CONT; + if (ac != 3) + return MOD_CONT; + do_kick(source, ac, av); + return MOD_CONT; } int anope_event_join(const char *source, int ac, const char **av) { - if (ac != 1) - return MOD_CONT; - do_join(source, ac, av); - return MOD_CONT; + if (ac != 1) + return MOD_CONT; + do_join(source, ac, av); + return MOD_CONT; } int anope_event_motd(const char *source, int ac, const char **av) { - if (!source) { - return MOD_CONT; - } + if (!source) { + return MOD_CONT; + } - m_motd(source); - return MOD_CONT; + m_motd(source); + return MOD_CONT; } int anope_event_setname(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 1) - return MOD_CONT; + if (ac != 1) + return MOD_CONT; - u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETNAME for nonexistent user %s", source); - } - return MOD_CONT; - } + u = finduser(source); + if (!u) { + if (debug) { + alog("debug: SETNAME for nonexistent user %s", source); + } + return MOD_CONT; + } - u->SetRealname(av[0]); - return MOD_CONT; + u->SetRealname(av[0]); + return MOD_CONT; } int anope_event_chgname(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - u = finduser(av[0]); - if (!u) { - if (debug) { - alog("debug: CHGNAME for nonexistent user %s", av[0]); - } - return MOD_CONT; - } + u = finduser(av[0]); + if (!u) { + if (debug) { + alog("debug: CHGNAME for nonexistent user %s", av[0]); + } + return MOD_CONT; + } - u->SetRealname(av[1]); - return MOD_CONT; + u->SetRealname(av[1]); + return MOD_CONT; } int anope_event_setident(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 1) - return MOD_CONT; + if (ac != 1) + return MOD_CONT; - u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETIDENT for nonexistent user %s", source); - } - return MOD_CONT; - } + u = finduser(source); + if (!u) { + if (debug) { + alog("debug: SETIDENT for nonexistent user %s", source); + } + return MOD_CONT; + } - u->SetIdent(av[0]); - return MOD_CONT; + u->SetIdent(av[0]); + return MOD_CONT; } int anope_event_chgident(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - u = finduser(av[0]); - if (!u) { - if (debug) { - alog("debug: CHGIDENT for nonexistent user %s", av[0]); - } - return MOD_CONT; - } + u = finduser(av[0]); + if (!u) { + if (debug) { + alog("debug: CHGIDENT for nonexistent user %s", av[0]); + } + return MOD_CONT; + } - u->SetIdent(av[1]); - return MOD_CONT; + u->SetIdent(av[1]); + return MOD_CONT; } int anope_event_sethost(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 1) - return MOD_CONT; + if (ac != 1) + return MOD_CONT; - u = finduser(source); - if (!u) { - if (debug) { - alog("debug: SETHOST for nonexistent user %s", source); - } - return MOD_CONT; - } + u = finduser(source); + if (!u) { + if (debug) { + alog("debug: SETHOST for nonexistent user %s", source); + } + return MOD_CONT; + } - u->SetDisplayedHost(av[0]); - return MOD_CONT; + u->SetDisplayedHost(av[0]); + return MOD_CONT; } /* ** NICK - new -** source = NULL +** source = NULL ** parv[0] = nickname -** parv[1] = hopcount -** parv[2] = timestamp -** parv[3] = username -** parv[4] = hostname -** parv[5] = servername +** parv[1] = hopcount +** parv[2] = timestamp +** parv[3] = username +** parv[4] = hostname +** parv[5] = servername ** if NICK version 1: -** parv[6] = servicestamp +** parv[6] = servicestamp ** parv[7] = info ** if NICK version 2: ** parv[6] = servicestamp -** parv[7] = umodes +** parv[7] = umodes ** parv[8] = virthost, * if none ** parv[9] = info ** if NICKIP: -** parv[9] = ip -** parv[10] = info +** parv[9] = ip +** parv[10] = info ** ** NICK - change -** source = oldnick +** source = oldnick ** parv[0] = new nickname -** parv[1] = hopcount +** parv[1] = hopcount */ /* do_nick(const char *source, char *nick, char *username, char *host, - char *server, char *realname, time_t ts, uint32 svid, - uint32 ip, char *vhost, char *uid) + char *server, char *realname, time_t ts, uint32 svid, + uint32 ip, char *vhost, char *uid) */ int anope_event_nick(const char *source, int ac, const char **av) { - User *user; - - if (ac != 2) { - if (ac == 7) { - /* - <codemastr> that was a bug that is now fixed in 3.2.1 - <codemastr> in some instances it would use the non-nickv2 format - <codemastr> it's sent when a nick collision occurs - - so we have to leave it around for now -TSL - */ - do_nick(source, av[0], av[3], av[4], av[5], av[6], - strtoul(av[2], NULL, 10), 0, 0, "*", NULL); - - } else if (ac == 11) { - user = do_nick(source, av[0], av[3], av[4], av[5], av[10], - strtoul(av[2], NULL, 10), strtoul(av[6], NULL, - 0), - ntohl(decode_ip(av[9])), av[8], NULL); - if (user) - ircdproto->ProcessUsermodes(user, 1, &av[7]); - - } else { - /* NON NICKIP */ - user = do_nick(source, av[0], av[3], av[4], av[5], av[9], - strtoul(av[2], NULL, 10), strtoul(av[6], NULL, - 0), 0, av[8], - NULL); - if (user) - ircdproto->ProcessUsermodes(user, 1, &av[7]); - } - } else { - do_nick(source, av[0], NULL, NULL, NULL, NULL, - strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); - } - return MOD_CONT; + User *user; + + if (ac != 2) { + if (ac == 7) { + /* + <codemastr> that was a bug that is now fixed in 3.2.1 + <codemastr> in some instances it would use the non-nickv2 format + <codemastr> it's sent when a nick collision occurs + - so we have to leave it around for now -TSL + */ + do_nick(source, av[0], av[3], av[4], av[5], av[6], + strtoul(av[2], NULL, 10), 0, 0, "*", NULL); + + } else if (ac == 11) { + user = do_nick(source, av[0], av[3], av[4], av[5], av[10], + strtoul(av[2], NULL, 10), strtoul(av[6], NULL, + 0), + ntohl(decode_ip(av[9])), av[8], NULL); + if (user) + ircdproto->ProcessUsermodes(user, 1, &av[7]); + + } else { + /* NON NICKIP */ + user = do_nick(source, av[0], av[3], av[4], av[5], av[9], + strtoul(av[2], NULL, 10), strtoul(av[6], NULL, + 0), 0, av[8], + NULL); + if (user) + ircdproto->ProcessUsermodes(user, 1, &av[7]); + } + } else { + do_nick(source, av[0], NULL, NULL, NULL, NULL, + strtoul(av[1], NULL, 10), 0, 0, NULL, NULL); + } + return MOD_CONT; } int anope_event_chghost(const char *source, int ac, const char **av) { - User *u; + User *u; - if (ac != 2) - return MOD_CONT; + if (ac != 2) + return MOD_CONT; - u = finduser(av[0]); - if (!u) { - if (debug) { - alog("debug: CHGHOST for nonexistent user %s", av[0]); - } - return MOD_CONT; - } + u = finduser(av[0]); + if (!u) { + if (debug) { + alog("debug: CHGHOST for nonexistent user %s", av[0]); + } + return MOD_CONT; + } - u->SetDisplayedHost(av[1]); - return MOD_CONT; + u->SetDisplayedHost(av[1]); + return MOD_CONT; } /* EVENT: SERVER */ int anope_event_server(const char *source, int ac, const char **av) { - char *desc; - char *vl; - char *upnumeric; - - if (!stricmp(av[1], "1")) { - uplink = sstrdup(av[0]); - vl = myStrGetToken(av[2], ' ', 0); - upnumeric = myStrGetToken(vl, '-', 2); - desc = myStrGetTokenRemainder(av[2], ' ', 1); - do_server(source, av[0], av[1], desc, upnumeric); - Anope_Free(vl); - Anope_Free(desc); - Anope_Free(upnumeric); - } else { - do_server(source, av[0], av[1], av[2], NULL); - } - - return MOD_CONT; + char *desc; + char *vl; + char *upnumeric; + + if (!stricmp(av[1], "1")) { + uplink = sstrdup(av[0]); + vl = myStrGetToken(av[2], ' ', 0); + upnumeric = myStrGetToken(vl, '-', 2); + desc = myStrGetTokenRemainder(av[2], ' ', 1); + do_server(source, av[0], av[1], desc, upnumeric); + Anope_Free(vl); + Anope_Free(desc); + Anope_Free(upnumeric); + } else { + do_server(source, av[0], av[1], av[2], NULL); + } + + return MOD_CONT; } int anope_event_privmsg(const char *source, int ac, const char **av) { - if (ac != 2) - return MOD_CONT; - m_privmsg(source, av[0], av[1]); - return MOD_CONT; + if (ac != 2) + return MOD_CONT; + m_privmsg(source, av[0], av[1]); + return MOD_CONT; } int anope_event_part(const char *source, int ac, const char **av) { - if (ac < 1 || ac > 2) - return MOD_CONT; - do_part(source, ac, av); - return MOD_CONT; + if (ac < 1 || ac > 2) + return MOD_CONT; + do_part(source, ac, av); + return MOD_CONT; } int anope_event_whois(const char *source, int ac, const char **av) { - if (source && ac >= 1) { - m_whois(source, av[0]); - } - return MOD_CONT; + if (source && ac >= 1) { + m_whois(source, av[0]); + } + return MOD_CONT; } int anope_event_error(const char *source, int ac, const char **av) { - if (av[0]) { - if (debug) { - alog("debug: %s", av[0]); - } + if (av[0]) { + if (debug) { + alog("debug: %s", av[0]); + } if(strstr(av[0],"No matching link configuration")!=0) { - alog("Error: Your IRCD's link block may not setup correctly, please check unrealircd.conf"); + alog("Error: Your IRCD's link block may not setup correctly, please check unrealircd.conf"); + } } - } - return MOD_CONT; + return MOD_CONT; } int anope_event_sdesc(const char *source, int ac, const char **av) { - Server *s; - s = findserver(servlist, source); + Server *s; + s = findserver(servlist, source); - if (s) { - s->desc = (char *)av[0]; // XXX Unsafe cast -- CyberBotX - } + if (s) { + s->desc = (char *)av[0]; // XXX Unsafe cast -- CyberBotX + } - return MOD_CONT; + return MOD_CONT; } int anope_event_sjoin(const char *source, int ac, const char **av) { - do_sjoin(source, ac, av); - return MOD_CONT; + do_sjoin(source, ac, av); + return MOD_CONT; } void moduleAddIRCDMsgs(void) { - Message *m; - - updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+a","-a"); - - m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); - m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); - m = createMessage("6", anope_event_away); addCoreMessage(IRCD,m); - m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); - m = createMessage("C", anope_event_join); addCoreMessage(IRCD,m); - m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); - m = createMessage("H", anope_event_kick); addCoreMessage(IRCD,m); - m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); - m = createMessage(".", anope_event_kill); addCoreMessage(IRCD,m); - m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); - m = createMessage("G", anope_event_mode); addCoreMessage(IRCD,m); - m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); - m = createMessage("F", anope_event_motd); addCoreMessage(IRCD,m); - m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); - m = createMessage("&", anope_event_nick); addCoreMessage(IRCD,m); - m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); - m = createMessage("D", anope_event_part); addCoreMessage(IRCD,m); - m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); - m = createMessage("8", anope_event_ping); addCoreMessage(IRCD,m); - m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); - m = createMessage("!", anope_event_privmsg); addCoreMessage(IRCD,m); - m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); - m = createMessage(",", anope_event_quit); addCoreMessage(IRCD,m); - m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); - m = createMessage("'", anope_event_server); addCoreMessage(IRCD,m); - m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); - m = createMessage("-", anope_event_squit); addCoreMessage(IRCD,m); - m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); - m = createMessage(")", anope_event_topic); addCoreMessage(IRCD,m); - m = createMessage("SVSMODE", anope_event_mode); addCoreMessage(IRCD,m); - m = createMessage("n", anope_event_mode); addCoreMessage(IRCD,m); - m = createMessage("SVS2MODE", anope_event_mode); addCoreMessage(IRCD,m); - m = createMessage("v", anope_event_mode); addCoreMessage(IRCD,m); - m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); - m = createMessage("#", anope_event_whois); addCoreMessage(IRCD,m); - m = createMessage("PROTOCTL", anope_event_capab); addCoreMessage(IRCD,m); - m = createMessage("_", anope_event_capab); addCoreMessage(IRCD,m); - m = createMessage("CHGHOST", anope_event_chghost); addCoreMessage(IRCD,m); - m = createMessage("AL", anope_event_chghost); addCoreMessage(IRCD,m); - m = createMessage("CHGIDENT", anope_event_chgident); addCoreMessage(IRCD,m); - m = createMessage("AZ", anope_event_chgident); addCoreMessage(IRCD,m); - m = createMessage("CHGNAME", anope_event_chgname); addCoreMessage(IRCD,m); - m = createMessage("BK", anope_event_chgname); addCoreMessage(IRCD,m); - m = createMessage("NETINFO", anope_event_netinfo); addCoreMessage(IRCD,m); - m = createMessage("AO", anope_event_netinfo); addCoreMessage(IRCD,m); - m = createMessage("SETHOST", anope_event_sethost); addCoreMessage(IRCD,m); - m = createMessage("AA", anope_event_sethost); addCoreMessage(IRCD,m); - m = createMessage("SETIDENT", anope_event_setident); addCoreMessage(IRCD,m); - m = createMessage("AD", anope_event_setident); addCoreMessage(IRCD,m); - m = createMessage("SETNAME", anope_event_setname); addCoreMessage(IRCD,m); - m = createMessage("AE", anope_event_setname); addCoreMessage(IRCD,m); - m = createMessage("EOS", anope_event_eos); addCoreMessage(IRCD,m); - m = createMessage("ES", anope_event_eos); addCoreMessage(IRCD,m); - m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m); - m = createMessage("5", anope_event_error); addCoreMessage(IRCD,m); - m = createMessage("UMODE2", anope_event_umode2); addCoreMessage(IRCD,m); - m = createMessage("|", anope_event_umode2); addCoreMessage(IRCD,m); - m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); - m = createMessage("~", anope_event_sjoin); addCoreMessage(IRCD,m); - m = createMessage("SDESC", anope_event_sdesc); addCoreMessage(IRCD,m); - m = createMessage("AG", anope_event_sdesc); addCoreMessage(IRCD,m); - - /* The non token version of these is in messages.c */ - m = createMessage("2", m_stats); addCoreMessage(IRCD,m); - m = createMessage(">", m_time); addCoreMessage(IRCD,m); - m = createMessage("+", m_version); addCoreMessage(IRCD,m); + Message *m; + + updateProtectDetails("PROTECT","PROTECTME","protect","deprotect","AUTOPROTECT","+a","-a"); + + m = createMessage("436", anope_event_436); addCoreMessage(IRCD,m); + m = createMessage("AWAY", anope_event_away); addCoreMessage(IRCD,m); + m = createMessage("6", anope_event_away); addCoreMessage(IRCD,m); + m = createMessage("JOIN", anope_event_join); addCoreMessage(IRCD,m); + m = createMessage("C", anope_event_join); addCoreMessage(IRCD,m); + m = createMessage("KICK", anope_event_kick); addCoreMessage(IRCD,m); + m = createMessage("H", anope_event_kick); addCoreMessage(IRCD,m); + m = createMessage("KILL", anope_event_kill); addCoreMessage(IRCD,m); + m = createMessage(".", anope_event_kill); addCoreMessage(IRCD,m); + m = createMessage("MODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("G", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("MOTD", anope_event_motd); addCoreMessage(IRCD,m); + m = createMessage("F", anope_event_motd); addCoreMessage(IRCD,m); + m = createMessage("NICK", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("&", anope_event_nick); addCoreMessage(IRCD,m); + m = createMessage("PART", anope_event_part); addCoreMessage(IRCD,m); + m = createMessage("D", anope_event_part); addCoreMessage(IRCD,m); + m = createMessage("PING", anope_event_ping); addCoreMessage(IRCD,m); + m = createMessage("8", anope_event_ping); addCoreMessage(IRCD,m); + m = createMessage("PRIVMSG", anope_event_privmsg); addCoreMessage(IRCD,m); + m = createMessage("!", anope_event_privmsg); addCoreMessage(IRCD,m); + m = createMessage("QUIT", anope_event_quit); addCoreMessage(IRCD,m); + m = createMessage(",", anope_event_quit); addCoreMessage(IRCD,m); + m = createMessage("SERVER", anope_event_server); addCoreMessage(IRCD,m); + m = createMessage("'", anope_event_server); addCoreMessage(IRCD,m); + m = createMessage("SQUIT", anope_event_squit); addCoreMessage(IRCD,m); + m = createMessage("-", anope_event_squit); addCoreMessage(IRCD,m); + m = createMessage("TOPIC", anope_event_topic); addCoreMessage(IRCD,m); + m = createMessage(")", anope_event_topic); addCoreMessage(IRCD,m); + m = createMessage("SVSMODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("n", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("SVS2MODE", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("v", anope_event_mode); addCoreMessage(IRCD,m); + m = createMessage("WHOIS", anope_event_whois); addCoreMessage(IRCD,m); + m = createMessage("#", anope_event_whois); addCoreMessage(IRCD,m); + m = createMessage("PROTOCTL", anope_event_capab); addCoreMessage(IRCD,m); + m = createMessage("_", anope_event_capab); addCoreMessage(IRCD,m); + m = createMessage("CHGHOST", anope_event_chghost); addCoreMessage(IRCD,m); + m = createMessage("AL", anope_event_chghost); addCoreMessage(IRCD,m); + m = createMessage("CHGIDENT", anope_event_chgident); addCoreMessage(IRCD,m); + m = createMessage("AZ", anope_event_chgident); addCoreMessage(IRCD,m); + m = createMessage("CHGNAME", anope_event_chgname); addCoreMessage(IRCD,m); + m = createMessage("BK", anope_event_chgname); addCoreMessage(IRCD,m); + m = createMessage("NETINFO", anope_event_netinfo); addCoreMessage(IRCD,m); + m = createMessage("AO", anope_event_netinfo); addCoreMessage(IRCD,m); + m = createMessage("SETHOST", anope_event_sethost); addCoreMessage(IRCD,m); + m = createMessage("AA", anope_event_sethost); addCoreMessage(IRCD,m); + m = createMessage("SETIDENT", anope_event_setident); addCoreMessage(IRCD,m); + m = createMessage("AD", anope_event_setident); addCoreMessage(IRCD,m); + m = createMessage("SETNAME", anope_event_setname); addCoreMessage(IRCD,m); + m = createMessage("AE", anope_event_setname); addCoreMessage(IRCD,m); + m = createMessage("EOS", anope_event_eos); addCoreMessage(IRCD,m); + m = createMessage("ES", anope_event_eos); addCoreMessage(IRCD,m); + m = createMessage("ERROR", anope_event_error); addCoreMessage(IRCD,m); + m = createMessage("5", anope_event_error); addCoreMessage(IRCD,m); + m = createMessage("UMODE2", anope_event_umode2); addCoreMessage(IRCD,m); + m = createMessage("|", anope_event_umode2); addCoreMessage(IRCD,m); + m = createMessage("SJOIN", anope_event_sjoin); addCoreMessage(IRCD,m); + m = createMessage("~", anope_event_sjoin); addCoreMessage(IRCD,m); + m = createMessage("SDESC", anope_event_sdesc); addCoreMessage(IRCD,m); + m = createMessage("AG", anope_event_sdesc); addCoreMessage(IRCD,m); + + /* The non token version of these is in messages.c */ + m = createMessage("2", m_stats); addCoreMessage(IRCD,m); + m = createMessage(">", m_time); addCoreMessage(IRCD,m); + m = createMessage("+", m_version); addCoreMessage(IRCD,m); } diff --git a/src/send.c b/src/send.c index 2d850fdc2..0055a8435 100644 --- a/src/send.c +++ b/src/send.c @@ -94,21 +94,21 @@ void send_cmd(const std::string &source, const char *fmt, ...) */ void notice_server(char *source, Server * s, const char *fmt, ...) { - va_list args; - char buf[BUFSIZE]; - *buf = '\0'; - - if (fmt) { - va_start(args, fmt); - vsnprintf(buf, BUFSIZE - 1, fmt, args); - - if (NSDefFlags & NI_MSG) { - ircdproto->SendGlobalPrivmsg(findbot(source), s->name, buf); - } else { - ircdproto->SendGlobalNotice(findbot(source), s->name, buf); - } - va_end(args); - } + va_list args; + char buf[BUFSIZE]; + *buf = '\0'; + + if (fmt) { + va_start(args, fmt); + vsnprintf(buf, BUFSIZE - 1, fmt, args); + + if (NSDefFlags & NI_MSG) { + ircdproto->SendGlobalPrivmsg(findbot(source), s->name, buf); + } else { + ircdproto->SendGlobalNotice(findbot(source), s->name, buf); + } + va_end(args); + } } /*************************************************************************/ @@ -123,18 +123,18 @@ void notice_server(char *source, Server * s, const char *fmt, ...) */ void notice_user(char *source, User * u, const char *fmt, ...) { - va_list args; - char buf[BUFSIZE]; - *buf = '\0'; + va_list args; + char buf[BUFSIZE]; + *buf = '\0'; - if (fmt) { - va_start(args, fmt); - vsnprintf(buf, BUFSIZE - 1, fmt, args); + if (fmt) { + va_start(args, fmt); + vsnprintf(buf, BUFSIZE - 1, fmt, args); u->SendMessage(source, buf); - va_end(args); - } + va_end(args); + } } /*************************************************************************/ @@ -149,18 +149,18 @@ void notice_user(char *source, User * u, const char *fmt, ...) void notice_list(char *source, char *dest, char **text) { User *u = finduser(dest); - while (*text) { - /* Have to kludge around an ircII bug here: if a notice includes - * no text, it is ignored, so we replace blank lines by lines - * with a single space. - */ - if (**text) { - u->SendMessage(source, *text); - } else { - u->SendMessage(source, " "); - } - text++; - } + while (*text) { + /* Have to kludge around an ircII bug here: if a notice includes + * no text, it is ignored, so we replace blank lines by lines + * with a single space. + */ + if (**text) { + u->SendMessage(source, *text); + } else { + u->SendMessage(source, " "); + } + text++; + } } /*************************************************************************/ @@ -175,31 +175,31 @@ void notice_list(char *source, char *dest, char **text) */ void notice_lang(const char *source, User * dest, int message, ...) { - va_list args; - char buf[4096]; /* because messages can be really big */ - char *s, *t; - const char *fmt; - - if (!dest || !message) { - return; - } - va_start(args, message); - fmt = getstring(dest->na, message); - - if (!fmt) - return; - memset(buf, 0, 4096); - vsnprintf(buf, sizeof(buf), fmt, args); - s = buf; - while (*s) { - t = s; - s += strcspn(s, "\n"); - if (*s) - *s++ = 0; + va_list args; + char buf[4096]; /* because messages can be really big */ + char *s, *t; + const char *fmt; + + if (!dest || !message) { + return; + } + va_start(args, message); + fmt = getstring(dest->na, message); + + if (!fmt) + return; + memset(buf, 0, 4096); + vsnprintf(buf, sizeof(buf), fmt, args); + s = buf; + while (*s) { + t = s; + s += strcspn(s, "\n"); + if (*s) + *s++ = 0; dest->SendMessage(source, *t ? t : " "); - } - va_end(args); + } + va_end(args); } /*************************************************************************/ @@ -216,34 +216,34 @@ void notice_lang(const char *source, User * dest, int message, ...) */ void notice_help(const char *source, User * dest, int message, ...) { - va_list args; - char buf[4096], buf2[4096], outbuf[BUFSIZE]; - char *s, *t; - const char *fmt; - - if (!dest || !message) { - return; - } - va_start(args, message); - fmt = getstring(dest->na, message); - if (!fmt) - return; - /* Some sprintf()'s eat %S or turn it into just S, so change all %S's - * into \1\1... we assume this doesn't occur anywhere else in the - * string. */ - strscpy(buf2, fmt, sizeof(buf2)); - strnrepl(buf2, sizeof(buf2), "%S", "\1\1"); - vsnprintf(buf, sizeof(buf), buf2, args); - s = buf; - while (*s) { - t = s; - s += strcspn(s, "\n"); - if (*s) - *s++ = 0; - strscpy(outbuf, t, sizeof(outbuf)); - strnrepl(outbuf, sizeof(outbuf), "\1\1", source); + va_list args; + char buf[4096], buf2[4096], outbuf[BUFSIZE]; + char *s, *t; + const char *fmt; + + if (!dest || !message) { + return; + } + va_start(args, message); + fmt = getstring(dest->na, message); + if (!fmt) + return; + /* Some sprintf()'s eat %S or turn it into just S, so change all %S's + * into \1\1... we assume this doesn't occur anywhere else in the + * string. */ + strscpy(buf2, fmt, sizeof(buf2)); + strnrepl(buf2, sizeof(buf2), "%S", "\1\1"); + vsnprintf(buf, sizeof(buf), buf2, args); + s = buf; + while (*s) { + t = s; + s += strcspn(s, "\n"); + if (*s) + *s++ = 0; + strscpy(outbuf, t, sizeof(outbuf)); + strnrepl(outbuf, sizeof(outbuf), "\1\1", source); dest->SendMessage(source, *outbuf ? outbuf : " "); - } - va_end(args); + } + va_end(args); } diff --git a/src/servers.c b/src/servers.c index 8da83b0a3..cf4cbf162 100644 --- a/src/servers.c +++ b/src/servers.c @@ -15,8 +15,8 @@ #include "services.h" Server *servlist = NULL; -Server *me_server = NULL; /* This are we */ -Server *serv_uplink = NULL; /* This is our uplink */ +Server *me_server = NULL; /* This are we */ +Server *serv_uplink = NULL; /* This is our uplink */ uint32 uplink_capab; char *uplink; char *TS6UPLINK; @@ -26,33 +26,33 @@ char *TS6SID; static Server *server_cur; CapabInfo capab_info[] = { - {"NOQUIT", CAPAB_NOQUIT}, - {"TSMODE", CAPAB_TSMODE}, - {"UNCONNECT", CAPAB_UNCONNECT}, - {"NICKIP", CAPAB_NICKIP}, - {"SSJOIN", CAPAB_NSJOIN}, - {"ZIP", CAPAB_ZIP}, - {"BURST", CAPAB_BURST}, - {"TS5", CAPAB_TS5}, - {"TS3", CAPAB_TS3}, - {"DKEY", CAPAB_DKEY}, - {"PT4", CAPAB_PT4}, - {"SCS", CAPAB_SCS}, - {"QS", CAPAB_QS}, - {"UID", CAPAB_UID}, - {"KNOCK", CAPAB_KNOCK}, - {"CLIENT", CAPAB_CLIENT}, - {"IPV6", CAPAB_IPV6}, - {"SSJ5", CAPAB_SSJ5}, - {"SN2", CAPAB_SN2}, - {"TOK1", CAPAB_TOKEN}, - {"TOKEN", CAPAB_TOKEN}, - {"VHOST", CAPAB_VHOST}, - {"SSJ3", CAPAB_SSJ3}, - {"SJB64", CAPAB_SJB64}, - {"CHANMODES", CAPAB_CHANMODE}, - {"NICKCHARS", CAPAB_NICKCHARS}, - {NULL, 0} + {"NOQUIT", CAPAB_NOQUIT}, + {"TSMODE", CAPAB_TSMODE}, + {"UNCONNECT", CAPAB_UNCONNECT}, + {"NICKIP", CAPAB_NICKIP}, + {"SSJOIN", CAPAB_NSJOIN}, + {"ZIP", CAPAB_ZIP}, + {"BURST", CAPAB_BURST}, + {"TS5", CAPAB_TS5}, + {"TS3", CAPAB_TS3}, + {"DKEY", CAPAB_DKEY}, + {"PT4", CAPAB_PT4}, + {"SCS", CAPAB_SCS}, + {"QS", CAPAB_QS}, + {"UID", CAPAB_UID}, + {"KNOCK", CAPAB_KNOCK}, + {"CLIENT", CAPAB_CLIENT}, + {"IPV6", CAPAB_IPV6}, + {"SSJ5", CAPAB_SSJ5}, + {"SN2", CAPAB_SN2}, + {"TOK1", CAPAB_TOKEN}, + {"TOKEN", CAPAB_TOKEN}, + {"VHOST", CAPAB_VHOST}, + {"SSJ3", CAPAB_SSJ3}, + {"SJB64", CAPAB_SJB64}, + {"CHANMODES", CAPAB_CHANMODE}, + {"NICKCHARS", CAPAB_NICKCHARS}, + {NULL, 0} }; /*************************************************************************/ @@ -64,12 +64,12 @@ CapabInfo capab_info[] = { */ Server *first_server(int flags) { - server_cur = servlist; - if (flags > -1) { - while (server_cur && (server_cur->flags != flags)) - server_cur = next_server(flags); - } - return server_cur; + server_cur = servlist; + if (flags > -1) { + while (server_cur && (server_cur->flags != flags)) + server_cur = next_server(flags); + } + return server_cur; } /*************************************************************************/ @@ -81,26 +81,26 @@ Server *first_server(int flags) */ Server *next_server(int flags) { - if (!server_cur) - return NULL; - - do { - if (server_cur->links) { - server_cur = server_cur->links; - } else if (server_cur->next) { - server_cur = server_cur->next; - } else { - do { - server_cur = server_cur->uplink; - if (server_cur && server_cur->next) { - server_cur = server_cur->next; - break; - } - } while (server_cur); - } - } while (server_cur && ((flags > -1) && (server_cur->flags != flags))); - - return server_cur; + if (!server_cur) + return NULL; + + do { + if (server_cur->links) { + server_cur = server_cur->links; + } else if (server_cur->next) { + server_cur = server_cur->next; + } else { + do { + server_cur = server_cur->uplink; + if (server_cur && server_cur->next) { + server_cur = server_cur->next; + break; + } + } while (server_cur); + } + } while (server_cur && ((flags > -1) && (server_cur->flags != flags))); + + return server_cur; } /*************************************************************************/ @@ -118,51 +118,51 @@ Server *next_server(int flags) * @return Server Struct */ Server *new_server(Server * server_uplink, const char *name, const char *desc, - uint16 flags, const char *suid) + uint16 flags, const char *suid) { - Server *serv; - - serv = (Server *)scalloc(sizeof(Server), 1); - if (!name) - name = ""; - serv->name = sstrdup(name); - serv->desc = sstrdup(desc); - serv->flags = flags; - serv->uplink = server_uplink; - if (suid) { - serv->suid = sstrdup(suid); - } else { - serv->suid = NULL; - } - if (ircd->sync) - serv->sync = SSYNC_IN_PROGRESS; - else - serv->sync = SSYNC_UNKNOWN; - serv->links = NULL; - serv->prev = NULL; - - if (!server_uplink) { - serv->hops = 0; - serv->next = servlist; - if (servlist) - servlist->prev = serv; - servlist = serv; - } else { - serv->hops = server_uplink->hops + 1; - serv->next = server_uplink->links; - if (server_uplink->links) - server_uplink->links->prev = serv; - server_uplink->links = serv; - } - /* Check if this is our uplink server */ - if ((server_uplink == me_server) && !(flags & SERVER_JUPED)) - serv_uplink = serv; - - /* Write the StartGlobal (to non-juped servers) */ - if (GlobalOnCycle && GlobalOnCycleUP && !(flags & SERVER_JUPED)) - notice_server(s_GlobalNoticer, serv, "%s", GlobalOnCycleUP); - - return serv; + Server *serv; + + serv = (Server *)scalloc(sizeof(Server), 1); + if (!name) + name = ""; + serv->name = sstrdup(name); + serv->desc = sstrdup(desc); + serv->flags = flags; + serv->uplink = server_uplink; + if (suid) { + serv->suid = sstrdup(suid); + } else { + serv->suid = NULL; + } + if (ircd->sync) + serv->sync = SSYNC_IN_PROGRESS; + else + serv->sync = SSYNC_UNKNOWN; + serv->links = NULL; + serv->prev = NULL; + + if (!server_uplink) { + serv->hops = 0; + serv->next = servlist; + if (servlist) + servlist->prev = serv; + servlist = serv; + } else { + serv->hops = server_uplink->hops + 1; + serv->next = server_uplink->links; + if (server_uplink->links) + server_uplink->links->prev = serv; + server_uplink->links = serv; + } + /* Check if this is our uplink server */ + if ((server_uplink == me_server) && !(flags & SERVER_JUPED)) + serv_uplink = serv; + + /* Write the StartGlobal (to non-juped servers) */ + if (GlobalOnCycle && GlobalOnCycleUP && !(flags & SERVER_JUPED)) + notice_server(s_GlobalNoticer, serv, "%s", GlobalOnCycleUP); + + return serv; } /*************************************************************************/ @@ -179,69 +179,69 @@ Server *new_server(Server * server_uplink, const char *name, const char *desc, */ static void delete_server(Server * serv, const char *quitreason) { - Server *s, *snext; - User *u, *unext; - NickAlias *na; - - if (!serv) { - if (debug) { - alog("debug: delete_server() called with NULL arg!"); - } - return; - } - - if (debug) - alog("debug: delete_server() called for %s", serv->name); - - if (ircdcap->noquit || ircdcap->qs) { - if ((uplink_capab & ircdcap->noquit) - || (uplink_capab & ircdcap->qs)) { - u = firstuser(); - while (u) { - unext = nextuser(); - if (u->server == serv) { - if ((na = u->na) && !(na->status & NS_VERBOTEN) - && (!(na->nc->flags & NI_SUSPENDED)) - && (na->status & (NS_IDENTIFIED | NS_RECOGNIZED))) { - na->last_seen = time(NULL); - if (na->last_quit) - free(na->last_quit); - na->last_quit = - (quitreason ? sstrdup(quitreason) : NULL); - } - if (LimitSessions) { - del_session(u->host); - } - delete u; - } - u = unext; - } - if (debug) - alog("debug: delete_server() cleared all users"); - } - } - - s = serv->links; - while (s) { - snext = s->next; - delete_server(s, quitreason); - s = snext; - } - - if (debug) - alog("debug: delete_server() cleared all servers"); - - free(serv->name); - free(serv->desc); - if (serv->prev) - serv->prev->next = serv->next; - if (serv->next) - serv->next->prev = serv->prev; - if (serv->uplink->links == serv) - serv->uplink->links = serv->next; - - if (debug) - alog("debug: delete_server() completed"); + Server *s, *snext; + User *u, *unext; + NickAlias *na; + + if (!serv) { + if (debug) { + alog("debug: delete_server() called with NULL arg!"); + } + return; + } + + if (debug) + alog("debug: delete_server() called for %s", serv->name); + + if (ircdcap->noquit || ircdcap->qs) { + if ((uplink_capab & ircdcap->noquit) + || (uplink_capab & ircdcap->qs)) { + u = firstuser(); + while (u) { + unext = nextuser(); + if (u->server == serv) { + if ((na = u->na) && !(na->status & NS_VERBOTEN) + && (!(na->nc->flags & NI_SUSPENDED)) + && (na->status & (NS_IDENTIFIED | NS_RECOGNIZED))) { + na->last_seen = time(NULL); + if (na->last_quit) + free(na->last_quit); + na->last_quit = + (quitreason ? sstrdup(quitreason) : NULL); + } + if (LimitSessions) { + del_session(u->host); + } + delete u; + } + u = unext; + } + if (debug) + alog("debug: delete_server() cleared all users"); + } + } + + s = serv->links; + while (s) { + snext = s->next; + delete_server(s, quitreason); + s = snext; + } + + if (debug) + alog("debug: delete_server() cleared all servers"); + + free(serv->name); + free(serv->desc); + if (serv->prev) + serv->prev->next = serv->next; + if (serv->next) + serv->next->prev = serv->prev; + if (serv->uplink->links == serv) + serv->uplink->links = serv->next; + + if (debug) + alog("debug: delete_server() completed"); } /*************************************************************************/ @@ -254,31 +254,31 @@ static void delete_server(Server * serv, const char *quitreason) */ Server *findserver(Server * s, const char *name) { - Server *sl; - - if (!name || !*name) { - return NULL; - } - - if (debug >= 3) { - alog("debug: findserver(%p)", name); - } - while (s && (stricmp(s->name, name) != 0)) { - if (s->links) { - sl = findserver(s->links, name); - if (sl) { - s = sl; - } else { - s = s->next; - } - } else { - s = s->next; - } - } - if (debug >= 3) { - alog("debug: findserver(%s) -> %p", name, (void *) s); - } - return s; + Server *sl; + + if (!name || !*name) { + return NULL; + } + + if (debug >= 3) { + alog("debug: findserver(%p)", name); + } + while (s && (stricmp(s->name, name) != 0)) { + if (s->links) { + sl = findserver(s->links, name); + if (sl) { + s = sl; + } else { + s = s->next; + } + } else { + s = s->next; + } + } + if (debug >= 3) { + alog("debug: findserver(%s) -> %p", name, (void *) s); + } + return s; } /*************************************************************************/ @@ -291,31 +291,31 @@ Server *findserver(Server * s, const char *name) */ Server *findserver_uid(Server * s, const char *name) { - Server *sl; - - if (!name || !*name) { - return NULL; - } - - if (debug >= 3) { - alog("debug: findserver_uid(%p)", name); - } - while (s && s->suid && (stricmp(s->suid, name) != 0)) { - if (s->links) { - sl = findserver_uid(s->links, name); - if (sl) { - s = sl; - } else { - s = s->next; - } - } else { - s = s->next; - } - } - if (debug >= 3) { - alog("debug: findserver_uid(%s) -> %p", name, (void *) s); - } - return s; + Server *sl; + + if (!name || !*name) { + return NULL; + } + + if (debug >= 3) { + alog("debug: findserver_uid(%p)", name); + } + while (s && s->suid && (stricmp(s->suid, name) != 0)) { + if (s->links) { + sl = findserver_uid(s->links, name); + if (sl) { + s = sl; + } else { + s = s->next; + } + } else { + s = s->next; + } + } + if (debug >= 3) { + alog("debug: findserver_uid(%s) -> %p", name, (void *) s); + } + return s; } /*************************************************************************/ @@ -328,16 +328,16 @@ Server *findserver_uid(Server * s, const char *name) */ int anope_check_sync(const char *name) { - Server *s; - s = findserver(servlist, name); + Server *s; + s = findserver(servlist, name); - if (!s) - return 0; + if (!s) + return 0; - if (is_sync(s)) - return 1; - else - return -1; + if (is_sync(s)) + return 1; + else + return -1; } /*************************************************************************/ @@ -352,26 +352,26 @@ int anope_check_sync(const char *name) * @return void */ void do_server(const char *source, const char *servername, const char *hops, - const char *descript, const char *numeric) + const char *descript, const char *numeric) { - Server *s; - - if (debug) { - if (!*source) { - alog("debug: Server introduced (%s)", servername); - } else { - alog("debug: Server introduced (%s) from %s", servername, - source); - } - } - - if (source[0] == '\0') - s = me_server; - else - s = findserver(servlist, source); - - new_server(s, servername, descript, 0, numeric); - send_event(EVENT_SERVER_CONNECT, 1, servername); + Server *s; + + if (debug) { + if (!*source) { + alog("debug: Server introduced (%s)", servername); + } else { + alog("debug: Server introduced (%s) from %s", servername, + source); + } + } + + if (source[0] == '\0') + s = me_server; + else + s = findserver(servlist, source); + + new_server(s, servername, descript, 0, numeric); + send_event(EVENT_SERVER_CONNECT, 1, servername); } /*************************************************************************/ @@ -385,47 +385,47 @@ void do_server(const char *source, const char *servername, const char *hops, */ void do_squit(const char *source, int ac, const char **av) { - char buf[BUFSIZE]; - Server *s; - - if (UseTS6 && ircd->ts6) { - s = findserver_uid(servlist, av[0]); - if (!s) { - s = findserver(servlist, av[0]); - } - } else { - s = findserver(servlist, av[0]); - } - if (!s) { - alog("SQUIT for nonexistent server (%s)!!", av[0]); - return; - } - send_event(EVENT_SERVER_SQUIT, 1, s->name); - - /* If this is a juped server, send a nice global to inform the online - * opers that we received it. - */ - if (s->flags & SERVER_JUPED) { - snprintf(buf, BUFSIZE, "Received SQUIT for juped server %s", - s->name); - ircdproto->SendGlobops(s_OperServ, buf); - } - - snprintf(buf, sizeof(buf), "%s %s", s->name, - (s->uplink ? s->uplink->name : "")); - - if (ircdcap->unconnect) { - if ((s->uplink == me_server) - && (uplink_capab & ircdcap->unconnect)) { - if (debug) { - alog("debug: Sending UNCONNECT SQUIT for %s", s->name); - } - /* need to fix */ - ircdproto->SendSquit(s->name, buf); - } - } - - delete_server(s, buf); + char buf[BUFSIZE]; + Server *s; + + if (UseTS6 && ircd->ts6) { + s = findserver_uid(servlist, av[0]); + if (!s) { + s = findserver(servlist, av[0]); + } + } else { + s = findserver(servlist, av[0]); + } + if (!s) { + alog("SQUIT for nonexistent server (%s)!!", av[0]); + return; + } + send_event(EVENT_SERVER_SQUIT, 1, s->name); + + /* If this is a juped server, send a nice global to inform the online + * opers that we received it. + */ + if (s->flags & SERVER_JUPED) { + snprintf(buf, BUFSIZE, "Received SQUIT for juped server %s", + s->name); + ircdproto->SendGlobops(s_OperServ, buf); + } + + snprintf(buf, sizeof(buf), "%s %s", s->name, + (s->uplink ? s->uplink->name : "")); + + if (ircdcap->unconnect) { + if ((s->uplink == me_server) + && (uplink_capab & ircdcap->unconnect)) { + if (debug) { + alog("debug: Sending UNCONNECT SQUIT for %s", s->name); + } + /* need to fix */ + ircdproto->SendSquit(s->name, buf); + } + } + + delete_server(s, buf); } /*************************************************************************/ @@ -438,38 +438,38 @@ void do_squit(const char *source, int ac, const char **av) */ void capab_parse(int ac, const char **av) { - int i; - int j; - char *s, *tmp; - - const char *temp; - - for (i = 0; i < ac; i++) { - temp = av[i]; - - s = myStrGetToken(temp, '=', 0); - tmp = myStrGetTokenRemainder(temp, '=', 1); - - if (!s) - continue; - - for (j = 0; capab_info[j].token; j++) { - if (stricmp(s, capab_info[j].token) == 0) - uplink_capab |= capab_info[j].flag; - /* Special cases */ - if ((stricmp(s, "NICKIP") == 0) && !ircd->nickip) - ircd->nickip = 1; - if ((stricmp(s, "CHANMODES") == 0) && tmp) - ircd->chanmodes = sstrdup(tmp); - if ((stricmp(s, "NICKCHARS") == 0) && tmp) - ircd->nickchars = sstrdup(tmp); - } - - if (s) - free(s); - if (tmp) - free(tmp); - } + int i; + int j; + char *s, *tmp; + + const char *temp; + + for (i = 0; i < ac; i++) { + temp = av[i]; + + s = myStrGetToken(temp, '=', 0); + tmp = myStrGetTokenRemainder(temp, '=', 1); + + if (!s) + continue; + + for (j = 0; capab_info[j].token; j++) { + if (stricmp(s, capab_info[j].token) == 0) + uplink_capab |= capab_info[j].flag; + /* Special cases */ + if ((stricmp(s, "NICKIP") == 0) && !ircd->nickip) + ircd->nickip = 1; + if ((stricmp(s, "CHANMODES") == 0) && tmp) + ircd->chanmodes = sstrdup(tmp); + if ((stricmp(s, "NICKCHARS") == 0) && tmp) + ircd->nickchars = sstrdup(tmp); + } + + if (s) + free(s); + if (tmp) + free(tmp); + } } /*************************************************************************/ @@ -482,15 +482,15 @@ void capab_parse(int ac, const char **av) */ int is_ulined(const char *server) { - int j; + int j; - for (j = 0; j < NumUlines; j++) { - if (stricmp(Ulines[j], server) == 0) { - return 1; - } - } + for (j = 0; j < NumUlines; j++) { + if (stricmp(Ulines[j], server) == 0) { + return 1; + } + } - return 0; + return 0; } /*************************************************************************/ @@ -503,9 +503,9 @@ int is_ulined(const char *server) */ int is_sync(Server * server) { - if ((server->sync == SSYNC_DONE) || (server->sync == SSYNC_UNKNOWN)) - return 1; - return 0; + if ((server->sync == SSYNC_DONE) || (server->sync == SSYNC_UNKNOWN)) + return 1; + return 0; } /*************************************************************************/ @@ -518,44 +518,44 @@ int is_sync(Server * server) */ void finish_sync(Server * serv, int sync_links) { - Server *s; - - if (!serv || is_sync(serv)) - return; - - /* Mark each server as in sync */ - s = serv; - do { - if (!is_sync(s)) { - if (debug) - alog("debug: Finishing sync for server %s", s->name); - - s->sync = SSYNC_DONE; - } - - if (!sync_links) - break; - - if (s->links) { - s = s->links; - } else if (s->next) { - s = s->next; - } else { - do { - s = s->uplink; - if (s == serv) - s = NULL; - if (s == me_server) - s = NULL; - } while (s && !(s->next)); - if (s) - s = s->next; - } - } while (s); - - /* Do some general stuff which should only be done once */ - restore_unsynced_topics(); - alog("Server %s is done syncing", serv->name); + Server *s; + + if (!serv || is_sync(serv)) + return; + + /* Mark each server as in sync */ + s = serv; + do { + if (!is_sync(s)) { + if (debug) + alog("debug: Finishing sync for server %s", s->name); + + s->sync = SSYNC_DONE; + } + + if (!sync_links) + break; + + if (s->links) { + s = s->links; + } else if (s->next) { + s = s->next; + } else { + do { + s = s->uplink; + if (s == serv) + s = NULL; + if (s == me_server) + s = NULL; + } while (s && !(s->next)); + if (s) + s = s->next; + } + } while (s); + + /* Do some general stuff which should only be done once */ + restore_unsynced_topics(); + alog("Server %s is done syncing", serv->name); } /*******************************************************************/ @@ -563,43 +563,43 @@ void finish_sync(Server * serv, int sync_links) /* TS6 UID generator common code. * * Derived from atheme-services, uid.c (hg 2954:116d46894b4c). - * -nenolod + * -nenolod */ static int ts6_uid_initted = 0; -static char ts6_new_uid[10]; /* allow for \0 */ +static char ts6_new_uid[10]; /* allow for \0 */ static unsigned int ts6_uid_index = 9; /* last slot in uid buf */ void ts6_uid_init(void) { - /* check just in case... you can never be too safe. */ - if (TS6SID != NULL) { - snprintf(ts6_new_uid, 10, "%sAAAAAA", TS6SID); - ts6_uid_initted = 1; - } else { - alog("warning: no TS6SID specified, disabling TS6 support."); - UseTS6 = 0; - - return; - } + /* check just in case... you can never be too safe. */ + if (TS6SID != NULL) { + snprintf(ts6_new_uid, 10, "%sAAAAAA", TS6SID); + ts6_uid_initted = 1; + } else { + alog("warning: no TS6SID specified, disabling TS6 support."); + UseTS6 = 0; + + return; + } } void ts6_uid_increment(unsigned int slot) { - if (slot != strlen(TS6SID)) { - if (ts6_new_uid[slot] == 'Z') - ts6_new_uid[slot] = '0'; - else if (ts6_new_uid[slot] == '9') { - ts6_new_uid[slot] = 'A'; - ts6_uid_increment(slot - 1); - } else - ts6_new_uid[slot]++; - } else { - if (ts6_new_uid[slot] == 'Z') - for (slot = 3; slot < 9; slot++) - ts6_new_uid[slot] = 'A'; - else - ts6_new_uid[slot]++; - } + if (slot != strlen(TS6SID)) { + if (ts6_new_uid[slot] == 'Z') + ts6_new_uid[slot] = '0'; + else if (ts6_new_uid[slot] == '9') { + ts6_new_uid[slot] = 'A'; + ts6_uid_increment(slot - 1); + } else + ts6_new_uid[slot]++; + } else { + if (ts6_new_uid[slot] == 'Z') + for (slot = 3; slot < 9; slot++) + ts6_new_uid[slot] = 'A'; + else + ts6_new_uid[slot]++; + } } const char *ts6_uid_retrieve(void) @@ -610,12 +610,12 @@ const char *ts6_uid_retrieve(void) return ""; } - if (ts6_uid_initted != 1) - ts6_uid_init(); + if (ts6_uid_initted != 1) + ts6_uid_init(); - ts6_uid_increment(ts6_uid_index - 1); + ts6_uid_increment(ts6_uid_index - 1); - return ts6_new_uid; + return ts6_new_uid; } /* EOF */ diff --git a/src/sessions.c b/src/sessions.c index 11a802d74..ede7dfbc9 100644 --- a/src/sessions.c +++ b/src/sessions.c @@ -55,7 +55,7 @@ * storing session information. This should be sufficient for the mean time. * -TheShadow */ -#define HASH(host) (((host)[0]&31)<<5 | ((host)[1]&31)) +#define HASH(host) (((host)[0]&31)<<5 | ((host)[1]&31)) Session *sessionlist[1024]; int32 nsessions = 0; @@ -69,33 +69,33 @@ int16 nexceptions = 0; void get_session_stats(long *nrec, long *memuse) { - Session *session; - long mem; - int i; - - mem = sizeof(Session) * nsessions; - for (i = 0; i < 1024; i++) { - for (session = sessionlist[i]; session; session = session->next) { - mem += strlen(session->host) + 1; - } - } - - *nrec = nsessions; - *memuse = mem; + Session *session; + long mem; + int i; + + mem = sizeof(Session) * nsessions; + for (i = 0; i < 1024; i++) { + for (session = sessionlist[i]; session; session = session->next) { + mem += strlen(session->host) + 1; + } + } + + *nrec = nsessions; + *memuse = mem; } void get_exception_stats(long *nrec, long *memuse) { - long mem; - int i; - - mem = sizeof(Exception) * nexceptions; - for (i = 0; i < nexceptions; i++) { - mem += strlen(exceptions[i].mask) + 1; - mem += strlen(exceptions[i].reason) + 1; - } - *nrec = nexceptions; - *memuse = mem; + long mem; + int i; + + mem = sizeof(Exception) * nexceptions; + for (i = 0; i < nexceptions; i++) { + mem += strlen(exceptions[i].mask) + 1; + mem += strlen(exceptions[i].reason) + 1; + } + *nrec = nexceptions; + *memuse = mem; } /*************************************************************************/ @@ -113,65 +113,65 @@ void get_exception_stats(long *nrec, long *memuse) int do_session(User * u) { - Session *session; - Exception *exception; - char *cmd = strtok(NULL, " "); - char *param1 = strtok(NULL, " "); - int mincount; - int i; - - if (!LimitSessions) { - notice_lang(s_OperServ, u, OPER_SESSION_DISABLED); - return MOD_CONT; - } - - if (!cmd) - cmd = ""; - - if (stricmp(cmd, "LIST") == 0) { - if (!param1) { - syntax_error(s_OperServ, u, "SESSION", - OPER_SESSION_LIST_SYNTAX); - - } else if ((mincount = atoi(param1)) <= 1) { - notice_lang(s_OperServ, u, OPER_SESSION_INVALID_THRESHOLD); - - } else { - notice_lang(s_OperServ, u, OPER_SESSION_LIST_HEADER, mincount); - notice_lang(s_OperServ, u, OPER_SESSION_LIST_COLHEAD); - for (i = 0; i < 1024; i++) { - for (session = sessionlist[i]; session; - session = session->next) { - if (session->count >= mincount) - notice_lang(s_OperServ, u, - OPER_SESSION_LIST_FORMAT, - session->count, session->host); - } - } - } - } else if (stricmp(cmd, "VIEW") == 0) { - if (!param1) { - syntax_error(s_OperServ, u, "SESSION", - OPER_SESSION_VIEW_SYNTAX); - - } else { - session = findsession(param1); - if (!session) { - notice_lang(s_OperServ, u, OPER_SESSION_NOT_FOUND, param1); - } else { - exception = find_host_exception(param1); - - notice_lang(s_OperServ, u, OPER_SESSION_VIEW_FORMAT, - param1, session->count, - exception ? exception-> - limit : DefSessionLimit); - } - } - - } else { - syntax_error(s_OperServ, u, "SESSION", OPER_SESSION_SYNTAX); - } - return MOD_CONT; + Session *session; + Exception *exception; + char *cmd = strtok(NULL, " "); + char *param1 = strtok(NULL, " "); + int mincount; + int i; + + if (!LimitSessions) { + notice_lang(s_OperServ, u, OPER_SESSION_DISABLED); + return MOD_CONT; + } + + if (!cmd) + cmd = ""; + + if (stricmp(cmd, "LIST") == 0) { + if (!param1) { + syntax_error(s_OperServ, u, "SESSION", + OPER_SESSION_LIST_SYNTAX); + + } else if ((mincount = atoi(param1)) <= 1) { + notice_lang(s_OperServ, u, OPER_SESSION_INVALID_THRESHOLD); + + } else { + notice_lang(s_OperServ, u, OPER_SESSION_LIST_HEADER, mincount); + notice_lang(s_OperServ, u, OPER_SESSION_LIST_COLHEAD); + for (i = 0; i < 1024; i++) { + for (session = sessionlist[i]; session; + session = session->next) { + if (session->count >= mincount) + notice_lang(s_OperServ, u, + OPER_SESSION_LIST_FORMAT, + session->count, session->host); + } + } + } + } else if (stricmp(cmd, "VIEW") == 0) { + if (!param1) { + syntax_error(s_OperServ, u, "SESSION", + OPER_SESSION_VIEW_SYNTAX); + + } else { + session = findsession(param1); + if (!session) { + notice_lang(s_OperServ, u, OPER_SESSION_NOT_FOUND, param1); + } else { + exception = find_host_exception(param1); + + notice_lang(s_OperServ, u, OPER_SESSION_VIEW_FORMAT, + param1, session->count, + exception ? exception-> + limit : DefSessionLimit); + } + } + + } else { + syntax_error(s_OperServ, u, "SESSION", OPER_SESSION_SYNTAX); + } + return MOD_CONT; } /*************************************************************************/ @@ -180,22 +180,22 @@ int do_session(User * u) Session *findsession(const char *host) { - Session *session; - int i; - - if (!host) { - return NULL; - } - - for (i = 0; i < 1024; i++) { - for (session = sessionlist[i]; session; session = session->next) { - if (stricmp(host, session->host) == 0) { - return session; - } - } - } - - return NULL; + Session *session; + int i; + + if (!host) { + return NULL; + } + + for (i = 0; i < 1024; i++) { + for (session = sessionlist[i]; session; session = session->next) { + if (stricmp(host, session->host) == 0) { + return session; + } + } + } + + return NULL; } /* Attempt to add a host to the session list. If the addition of the new host @@ -205,120 +205,120 @@ Session *findsession(const char *host) int add_session(const char *nick, const char *host, char *hostip) { - Session *session, **list; - Exception *exception; - int sessionlimit = 0; - - session = findsession(host); - - if (session) { - exception = find_hostip_exception(host, hostip); - - if (checkDefCon(DEFCON_REDUCE_SESSION)) { - sessionlimit = - exception ? exception->limit : DefConSessionLimit; - } else { - sessionlimit = exception ? exception->limit : DefSessionLimit; - } - - if (sessionlimit != 0 && session->count >= sessionlimit) { - if (SessionLimitExceeded) - ircdproto->SendMessage(findbot(s_OperServ), nick, SessionLimitExceeded, host); - if (SessionLimitDetailsLoc) - ircdproto->SendMessage(findbot(s_OperServ), nick, "%s", SessionLimitDetailsLoc); - - /* We don't use kill_user() because a user stucture has not yet - * been created. Simply kill the user. -TheShadow - */ - kill_user(s_OperServ, nick, "Session limit exceeded"); - - session->hits++; - if (MaxSessionKill && session->hits >= MaxSessionKill) { - char akillmask[BUFSIZE]; - snprintf(akillmask, sizeof(akillmask), "*@%s", host); - add_akill(NULL, akillmask, s_OperServ, - time(NULL) + SessionAutoKillExpiry, - "Session limit exceeded"); - ircdproto->SendGlobops(s_OperServ, - "Added a temporary AKILL for \2%s\2 due to excessive connections", - akillmask); - } - return 0; - } else { - session->count++; - return 1; - } - } - - nsessions++; - session = (Session *)scalloc(sizeof(Session), 1); - session->host = sstrdup(host); - list = &sessionlist[HASH(session->host)]; - session->next = *list; - if (*list) - (*list)->prev = session; - *list = session; - session->count = 1; - - return 1; + Session *session, **list; + Exception *exception; + int sessionlimit = 0; + + session = findsession(host); + + if (session) { + exception = find_hostip_exception(host, hostip); + + if (checkDefCon(DEFCON_REDUCE_SESSION)) { + sessionlimit = + exception ? exception->limit : DefConSessionLimit; + } else { + sessionlimit = exception ? exception->limit : DefSessionLimit; + } + + if (sessionlimit != 0 && session->count >= sessionlimit) { + if (SessionLimitExceeded) + ircdproto->SendMessage(findbot(s_OperServ), nick, SessionLimitExceeded, host); + if (SessionLimitDetailsLoc) + ircdproto->SendMessage(findbot(s_OperServ), nick, "%s", SessionLimitDetailsLoc); + + /* We don't use kill_user() because a user stucture has not yet + * been created. Simply kill the user. -TheShadow + */ + kill_user(s_OperServ, nick, "Session limit exceeded"); + + session->hits++; + if (MaxSessionKill && session->hits >= MaxSessionKill) { + char akillmask[BUFSIZE]; + snprintf(akillmask, sizeof(akillmask), "*@%s", host); + add_akill(NULL, akillmask, s_OperServ, + time(NULL) + SessionAutoKillExpiry, + "Session limit exceeded"); + ircdproto->SendGlobops(s_OperServ, + "Added a temporary AKILL for \2%s\2 due to excessive connections", + akillmask); + } + return 0; + } else { + session->count++; + return 1; + } + } + + nsessions++; + session = (Session *)scalloc(sizeof(Session), 1); + session->host = sstrdup(host); + list = &sessionlist[HASH(session->host)]; + session->next = *list; + if (*list) + (*list)->prev = session; + *list = session; + session->count = 1; + + return 1; } void del_session(const char *host) { - Session *session; - - if (!LimitSessions) { - if (debug) { - alog("debug: del_session called when LimitSessions is disabled"); - } - return; - } - - if (!host || !*host) { - if (debug) { - alog("debug: del_session called with NULL values"); - } - return; - } - - if (debug >= 2) - alog("debug: del_session() called"); - - session = findsession(host); - - if (!session) { - if (debug) { - ircdproto->SendGlobops(s_OperServ, - "WARNING: Tried to delete non-existant session: \2%s", - host); - alog("session: Tried to delete non-existant session: %s", - host); - } - return; - } - - if (session->count > 1) { - session->count--; - return; - } - - if (session->prev) - session->prev->next = session->next; - else - sessionlist[HASH(session->host)] = session->next; - if (session->next) - session->next->prev = session->prev; - - if (debug >= 2) - alog("debug: del_session(): free session structure"); - - free(session->host); - free(session); - - nsessions--; - - if (debug >= 2) - alog("debug: del_session() done"); + Session *session; + + if (!LimitSessions) { + if (debug) { + alog("debug: del_session called when LimitSessions is disabled"); + } + return; + } + + if (!host || !*host) { + if (debug) { + alog("debug: del_session called with NULL values"); + } + return; + } + + if (debug >= 2) + alog("debug: del_session() called"); + + session = findsession(host); + + if (!session) { + if (debug) { + ircdproto->SendGlobops(s_OperServ, + "WARNING: Tried to delete non-existant session: \2%s", + host); + alog("session: Tried to delete non-existant session: %s", + host); + } + return; + } + + if (session->count > 1) { + session->count--; + return; + } + + if (session->prev) + session->prev->next = session->next; + else + sessionlist[HASH(session->host)] = session->next; + if (session->next) + session->next->prev = session->prev; + + if (debug >= 2) + alog("debug: del_session(): free session structure"); + + free(session->host); + free(session); + + nsessions--; + + if (debug >= 2) + alog("debug: del_session() done"); } @@ -328,148 +328,148 @@ void del_session(const char *host) void expire_exceptions(void) { - int i; - time_t now = time(NULL); - - for (i = 0; i < nexceptions; i++) { - if (exceptions[i].expires == 0 || exceptions[i].expires > now) - continue; - if (WallExceptionExpire) - ircdproto->SendGlobops(s_OperServ, - "Session limit exception for %s has expired.", - exceptions[i].mask); - free(exceptions[i].mask); - free(exceptions[i].reason); - nexceptions--; - memmove(exceptions + i, exceptions + i + 1, - sizeof(Exception) * (nexceptions - i)); - exceptions = (Exception *)srealloc(exceptions, sizeof(Exception) * nexceptions); - i--; - } + int i; + time_t now = time(NULL); + + for (i = 0; i < nexceptions; i++) { + if (exceptions[i].expires == 0 || exceptions[i].expires > now) + continue; + if (WallExceptionExpire) + ircdproto->SendGlobops(s_OperServ, + "Session limit exception for %s has expired.", + exceptions[i].mask); + free(exceptions[i].mask); + free(exceptions[i].reason); + nexceptions--; + memmove(exceptions + i, exceptions + i + 1, + sizeof(Exception) * (nexceptions - i)); + exceptions = (Exception *)srealloc(exceptions, sizeof(Exception) * nexceptions); + i--; + } } /* Find the first exception this host matches and return it. */ Exception *find_host_exception(const char *host) { - int i; + int i; - for (i = 0; i < nexceptions; i++) { - if ((match_wild_nocase(exceptions[i].mask, host))) { - return &exceptions[i]; - } - } + for (i = 0; i < nexceptions; i++) { + if ((match_wild_nocase(exceptions[i].mask, host))) { + return &exceptions[i]; + } + } - return NULL; + return NULL; } /* Same as find_host_exception() except * this tries to find the exception by IP also. */ Exception *find_hostip_exception(const char *host, const char *hostip) { - int i; + int i; - for (i = 0; i < nexceptions; i++) { - if ((match_wild_nocase(exceptions[i].mask, host)) - || ((ircd->nickip && hostip) - && (match_wild_nocase(exceptions[i].mask, hostip)))) { - return &exceptions[i]; - } - } + for (i = 0; i < nexceptions; i++) { + if ((match_wild_nocase(exceptions[i].mask, host)) + || ((ircd->nickip && hostip) + && (match_wild_nocase(exceptions[i].mask, hostip)))) { + return &exceptions[i]; + } + } - return NULL; + return NULL; } /*************************************************************************/ /*********************** Exception Load/Save *****************************/ /*************************************************************************/ -#define SAFE(x) do { \ - if ((x) < 0) { \ - if (!forceload) \ - fatal("Read error on %s", ExceptionDBName); \ - nexceptions = i; \ - break; \ - } \ +#define SAFE(x) do { \ + if ((x) < 0) { \ + if (!forceload) \ + fatal("Read error on %s", ExceptionDBName); \ + nexceptions = i; \ + break; \ + } \ } while (0) void load_exceptions() { - dbFILE *f; - int i; - uint16 n; - uint16 tmp16; - uint32 tmp32; - - if (! - (f = open_db(s_OperServ, ExceptionDBName, "r", EXCEPTION_VERSION))) - return; - switch (i = get_file_version(f)) { - case 9: - case 8: - case 7: - SAFE(read_int16(&n, f)); - nexceptions = n; - exceptions = (Exception *)scalloc(sizeof(Exception) * nexceptions, 1); - if (!nexceptions) { - close_db(f); - return; - } - for (i = 0; i < nexceptions; i++) { - SAFE(read_string(&exceptions[i].mask, f)); - SAFE(read_int16(&tmp16, f)); - exceptions[i].limit = tmp16; - SAFE(read_buffer(exceptions[i].who, f)); - SAFE(read_string(&exceptions[i].reason, f)); - SAFE(read_int32(&tmp32, f)); - exceptions[i].time = tmp32; - SAFE(read_int32(&tmp32, f)); - exceptions[i].expires = tmp32; - } - break; - - default: - fatal("Unsupported version (%d) on %s", i, ExceptionDBName); - } /* switch (ver) */ - - close_db(f); + dbFILE *f; + int i; + uint16 n; + uint16 tmp16; + uint32 tmp32; + + if (! + (f = open_db(s_OperServ, ExceptionDBName, "r", EXCEPTION_VERSION))) + return; + switch (i = get_file_version(f)) { + case 9: + case 8: + case 7: + SAFE(read_int16(&n, f)); + nexceptions = n; + exceptions = (Exception *)scalloc(sizeof(Exception) * nexceptions, 1); + if (!nexceptions) { + close_db(f); + return; + } + for (i = 0; i < nexceptions; i++) { + SAFE(read_string(&exceptions[i].mask, f)); + SAFE(read_int16(&tmp16, f)); + exceptions[i].limit = tmp16; + SAFE(read_buffer(exceptions[i].who, f)); + SAFE(read_string(&exceptions[i].reason, f)); + SAFE(read_int32(&tmp32, f)); + exceptions[i].time = tmp32; + SAFE(read_int32(&tmp32, f)); + exceptions[i].expires = tmp32; + } + break; + + default: + fatal("Unsupported version (%d) on %s", i, ExceptionDBName); + } /* switch (ver) */ + + close_db(f); } #undef SAFE /*************************************************************************/ -#define SAFE(x) do { \ - if ((x) < 0) { \ - restore_db(f); \ - log_perror("Write error on %s", ExceptionDBName); \ - if (time(NULL) - lastwarn > WarningTimeout) { \ - ircdproto->SendGlobops(NULL, "Write error on %s: %s", ExceptionDBName, \ - strerror(errno)); \ - lastwarn = time(NULL); \ - } \ - return; \ - } \ +#define SAFE(x) do { \ + if ((x) < 0) { \ + restore_db(f); \ + log_perror("Write error on %s", ExceptionDBName); \ + if (time(NULL) - lastwarn > WarningTimeout) { \ + ircdproto->SendGlobops(NULL, "Write error on %s: %s", ExceptionDBName, \ + strerror(errno)); \ + lastwarn = time(NULL); \ + } \ + return; \ + } \ } while (0) void save_exceptions() { - dbFILE *f; - int i; - static time_t lastwarn = 0; - - if (! - (f = open_db(s_OperServ, ExceptionDBName, "w", EXCEPTION_VERSION))) - return; - SAFE(write_int16(nexceptions, f)); - for (i = 0; i < nexceptions; i++) { - SAFE(write_string(exceptions[i].mask, f)); - SAFE(write_int16(exceptions[i].limit, f)); - SAFE(write_buffer(exceptions[i].who, f)); - SAFE(write_string(exceptions[i].reason, f)); - SAFE(write_int32(exceptions[i].time, f)); - SAFE(write_int32(exceptions[i].expires, f)); - } - close_db(f); + dbFILE *f; + int i; + static time_t lastwarn = 0; + + if (! + (f = open_db(s_OperServ, ExceptionDBName, "w", EXCEPTION_VERSION))) + return; + SAFE(write_int16(nexceptions, f)); + for (i = 0; i < nexceptions; i++) { + SAFE(write_string(exceptions[i].mask, f)); + SAFE(write_int16(exceptions[i].limit, f)); + SAFE(write_buffer(exceptions[i].who, f)); + SAFE(write_string(exceptions[i].reason, f)); + SAFE(write_int32(exceptions[i].time, f)); + SAFE(write_int32(exceptions[i].expires, f)); + } + close_db(f); } #undef SAFE @@ -479,58 +479,58 @@ void save_exceptions() /*************************************************************************/ int exception_add(User * u, const char *mask, const int limit, - const char *reason, const char *who, - const time_t expires) + const char *reason, const char *who, + const time_t expires) { - int i; - - /* Check if an exception already exists for this mask */ - for (i = 0; i < nexceptions; i++) { - if (!stricmp(mask, exceptions[i].mask)) { - if (exceptions[i].limit != limit) { - exceptions[i].limit = limit; - if (u) - notice_lang(s_OperServ, u, OPER_EXCEPTION_CHANGED, - mask, exceptions[i].limit); - return -2; - } else { - if (u) - notice_lang(s_OperServ, u, OPER_EXCEPTION_EXISTS, - mask); - return -1; - } - } - } - - nexceptions++; - exceptions = (Exception *)srealloc(exceptions, sizeof(Exception) * nexceptions); - - exceptions[nexceptions - 1].mask = sstrdup(mask); - exceptions[nexceptions - 1].limit = limit; - exceptions[nexceptions - 1].reason = sstrdup(reason); - exceptions[nexceptions - 1].time = time(NULL); - strscpy(exceptions[nexceptions - 1].who, who, NICKMAX); - exceptions[nexceptions - 1].expires = expires; - exceptions[nexceptions - 1].num = nexceptions - 1; - - return 1; + int i; + + /* Check if an exception already exists for this mask */ + for (i = 0; i < nexceptions; i++) { + if (!stricmp(mask, exceptions[i].mask)) { + if (exceptions[i].limit != limit) { + exceptions[i].limit = limit; + if (u) + notice_lang(s_OperServ, u, OPER_EXCEPTION_CHANGED, + mask, exceptions[i].limit); + return -2; + } else { + if (u) + notice_lang(s_OperServ, u, OPER_EXCEPTION_EXISTS, + mask); + return -1; + } + } + } + + nexceptions++; + exceptions = (Exception *)srealloc(exceptions, sizeof(Exception) * nexceptions); + + exceptions[nexceptions - 1].mask = sstrdup(mask); + exceptions[nexceptions - 1].limit = limit; + exceptions[nexceptions - 1].reason = sstrdup(reason); + exceptions[nexceptions - 1].time = time(NULL); + strscpy(exceptions[nexceptions - 1].who, who, NICKMAX); + exceptions[nexceptions - 1].expires = expires; + exceptions[nexceptions - 1].num = nexceptions - 1; + + return 1; } /*************************************************************************/ static int exception_del(const int index) { - if (index < 0 || index >= nexceptions) - return 0; + if (index < 0 || index >= nexceptions) + return 0; - free(exceptions[index].mask); - free(exceptions[index].reason); - nexceptions--; - memmove(exceptions + index, exceptions + index + 1, - sizeof(Exception) * (nexceptions - index)); - exceptions = (Exception *)srealloc(exceptions, sizeof(Exception) * nexceptions); + free(exceptions[index].mask); + free(exceptions[index].reason); + nexceptions--; + memmove(exceptions + index, exceptions + index + 1, + sizeof(Exception) * (nexceptions - index)); + exceptions = (Exception *)srealloc(exceptions, sizeof(Exception) * nexceptions); - return 1; + return 1; } /* We use the "num" property to keep track of the position of each exception @@ -541,75 +541,75 @@ static int exception_del(const int index) static int exception_del_callback(User * u, int num, va_list args) { - int i; - int *last = va_arg(args, int *); - - *last = num; - for (i = 0; i < nexceptions; i++) { - if (num - 1 == exceptions[i].num) - break; - } - if (i < nexceptions) - return exception_del(i); - else - return 0; + int i; + int *last = va_arg(args, int *); + + *last = num; + for (i = 0; i < nexceptions; i++) { + if (num - 1 == exceptions[i].num) + break; + } + if (i < nexceptions) + return exception_del(i); + else + return 0; } static int exception_list(User * u, const int index, int *sent_header) { - if (index < 0 || index >= nexceptions) - return 0; - if (!*sent_header) { - notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_HEADER); - notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_COLHEAD); - *sent_header = 1; - } - notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_FORMAT, index + 1, - exceptions[index].limit, exceptions[index].mask); - return 1; + if (index < 0 || index >= nexceptions) + return 0; + if (!*sent_header) { + notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_HEADER); + notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_COLHEAD); + *sent_header = 1; + } + notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_FORMAT, index + 1, + exceptions[index].limit, exceptions[index].mask); + return 1; } static int exception_list_callback(User * u, int num, va_list args) { - int *sent_header = va_arg(args, int *); + int *sent_header = va_arg(args, int *); - return exception_list(u, num - 1, sent_header); + return exception_list(u, num - 1, sent_header); } static int exception_view(User * u, const int index, int *sent_header) { - char timebuf[32], expirebuf[256]; - struct tm tm; - time_t t = time(NULL); - - if (index < 0 || index >= nexceptions) - return 0; - if (!*sent_header) { - notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_HEADER); - *sent_header = 1; - } - - tm = *localtime(exceptions[index].time ? &exceptions[index].time : &t); - strftime_lang(timebuf, sizeof(timebuf), - u, STRFTIME_SHORT_DATE_FORMAT, &tm); - - expire_left(u->na, expirebuf, sizeof(expirebuf), - exceptions[index].expires); - - notice_lang(s_OperServ, u, OPER_EXCEPTION_VIEW_FORMAT, - index + 1, exceptions[index].mask, - *exceptions[index].who ? - exceptions[index].who : "<unknown>", - timebuf, expirebuf, exceptions[index].limit, - exceptions[index].reason); - return 1; + char timebuf[32], expirebuf[256]; + struct tm tm; + time_t t = time(NULL); + + if (index < 0 || index >= nexceptions) + return 0; + if (!*sent_header) { + notice_lang(s_OperServ, u, OPER_EXCEPTION_LIST_HEADER); + *sent_header = 1; + } + + tm = *localtime(exceptions[index].time ? &exceptions[index].time : &t); + strftime_lang(timebuf, sizeof(timebuf), + u, STRFTIME_SHORT_DATE_FORMAT, &tm); + + expire_left(u->na, expirebuf, sizeof(expirebuf), + exceptions[index].expires); + + notice_lang(s_OperServ, u, OPER_EXCEPTION_VIEW_FORMAT, + index + 1, exceptions[index].mask, + *exceptions[index].who ? + exceptions[index].who : "<unknown>", + timebuf, expirebuf, exceptions[index].limit, + exceptions[index].reason); + return 1; } static int exception_view_callback(User * u, int num, va_list args) { - int *sent_header = va_arg(args, int *); + int *sent_header = va_arg(args, int *); - return exception_view(u, num - 1, sent_header); + return exception_view(u, num - 1, sent_header); } /*************************************************************************/ @@ -634,211 +634,211 @@ static int exception_view_callback(User * u, int num, va_list args) int do_exception(User * u) { - char *cmd = strtok(NULL, " "); - char *mask, *reason, *expiry, *limitstr; - int limit, expires; - int i; - int x; - - if (!LimitSessions) { - notice_lang(s_OperServ, u, OPER_EXCEPTION_DISABLED); - return MOD_CONT; - } - - if (!cmd) - cmd = ""; - - if (stricmp(cmd, "ADD") == 0) { - if (nexceptions >= 32767) { - notice_lang(s_OperServ, u, OPER_EXCEPTION_TOO_MANY); - return MOD_CONT; - } - - mask = strtok(NULL, " "); - if (mask && *mask == '+') { - expiry = mask; - mask = strtok(NULL, " "); - } else { - expiry = NULL; - } - limitstr = strtok(NULL, " "); - reason = strtok(NULL, ""); - - if (!reason) { - syntax_error(s_OperServ, u, "EXCEPTION", - OPER_EXCEPTION_ADD_SYNTAX); - return MOD_CONT; - } - - expires = expiry ? dotime(expiry) : ExceptionExpiry; - if (expires < 0) { - notice_lang(s_OperServ, u, BAD_EXPIRY_TIME); - return MOD_CONT; - } else if (expires > 0) { - expires += time(NULL); - } - - limit = (limitstr && isdigit(*limitstr)) ? atoi(limitstr) : -1; - - if (limit < 0 || limit > MaxSessionLimit) { - notice_lang(s_OperServ, u, OPER_EXCEPTION_INVALID_LIMIT, - MaxSessionLimit); - return MOD_CONT; - - } else { - if (strchr(mask, '!') || strchr(mask, '@')) { - notice_lang(s_OperServ, u, - OPER_EXCEPTION_INVALID_HOSTMASK); - return MOD_CONT; - } - - x = exception_add(u, mask, limit, reason, u->nick, expires); - - if (x == 1) { - notice_lang(s_OperServ, u, OPER_EXCEPTION_ADDED, mask, - limit); - } - - if (readonly) - notice_lang(s_OperServ, u, READ_ONLY_MODE); - } - } else if (stricmp(cmd, "DEL") == 0) { - mask = strtok(NULL, " "); - - if (!mask) { - syntax_error(s_OperServ, u, "EXCEPTION", - OPER_EXCEPTION_DEL_SYNTAX); - return MOD_CONT; - } - - if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) { - int count, deleted, last = -1; - deleted = - process_numlist(mask, &count, exception_del_callback, u, - &last); - if (!deleted) { - if (count == 1) { - notice_lang(s_OperServ, u, - OPER_EXCEPTION_NO_SUCH_ENTRY, last); - } else { - notice_lang(s_OperServ, u, OPER_EXCEPTION_NO_MATCH); - } - } else if (deleted == 1) { - notice_lang(s_OperServ, u, OPER_EXCEPTION_DELETED_ONE); - } else { - notice_lang(s_OperServ, u, OPER_EXCEPTION_DELETED_SEVERAL, - deleted); - } - } else { - int deleted = 0; - - for (i = 0; i < nexceptions; i++) { - if (stricmp(mask, exceptions[i].mask) == 0) { - exception_del(i); - notice_lang(s_OperServ, u, OPER_EXCEPTION_DELETED, - mask); - deleted = 1; - break; - } - } - if (!deleted && i == nexceptions) - notice_lang(s_OperServ, u, OPER_EXCEPTION_NOT_FOUND, mask); - } - - /* Renumber the exception list. I don't believe in having holes in - * lists - it makes code more complex, harder to debug and we end up - * with huge index numbers. Imho, fixed numbering is only beneficial - * when one doesn't have range capable manipulation. -TheShadow */ - - for (i = 0; i < nexceptions; i++) - exceptions[i].num = i; - - if (readonly) - notice_lang(s_OperServ, u, READ_ONLY_MODE); - - } else if (stricmp(cmd, "MOVE") == 0) { - Exception *exception; - char *n1str = strtok(NULL, " "); /* From position */ - char *n2str = strtok(NULL, " "); /* To position */ - int n1, n2; - - if (!n2str) { - syntax_error(s_OperServ, u, "EXCEPTION", - OPER_EXCEPTION_MOVE_SYNTAX); - return MOD_CONT; - } - - n1 = atoi(n1str) - 1; - n2 = atoi(n2str) - 1; - - if ((n1 >= 0 && n1 < nexceptions) && (n2 >= 0 && n2 < nexceptions) - && (n1 != n2)) { - exception = (Exception *)scalloc(sizeof(Exception), 1); - memcpy(exception, &exceptions[n1], sizeof(Exception)); - - if (n1 < n2) { - /* Shift upwards */ - memmove(&exceptions[n1], &exceptions[n1 + 1], - sizeof(Exception) * (n2 - n1)); - memmove(&exceptions[n2], exception, sizeof(Exception)); - } else { - /* Shift downwards */ - memmove(&exceptions[n2 + 1], &exceptions[n2], - sizeof(Exception) * (n1 - n2)); - memmove(&exceptions[n2], exception, sizeof(Exception)); - } - - free(exception); - - notice_lang(s_OperServ, u, OPER_EXCEPTION_MOVED, - exceptions[n1].mask, n1 + 1, n2 + 1); - - /* Renumber the exception list. See the DEL block above for why. */ - for (i = 0; i < nexceptions; i++) - exceptions[i].num = i; - - if (readonly) - notice_lang(s_OperServ, u, READ_ONLY_MODE); - } else { - syntax_error(s_OperServ, u, "EXCEPTION", - OPER_EXCEPTION_MOVE_SYNTAX); - } - } else if (stricmp(cmd, "LIST") == 0) { - int sent_header = 0; - expire_exceptions(); - mask = strtok(NULL, " "); - if (mask && strspn(mask, "1234567890,-") == strlen(mask)) { - process_numlist(mask, NULL, exception_list_callback, u, - &sent_header); - } else { - for (i = 0; i < nexceptions; i++) { - if (!mask || match_wild_nocase(mask, exceptions[i].mask)) - exception_list(u, i, &sent_header); - } - } - if (!sent_header) - notice_lang(s_OperServ, u, OPER_EXCEPTION_NO_MATCH); - - } else if (stricmp(cmd, "VIEW") == 0) { - int sent_header = 0; - expire_exceptions(); - mask = strtok(NULL, " "); - if (mask && strspn(mask, "1234567890,-") == strlen(mask)) { - process_numlist(mask, NULL, exception_view_callback, u, - &sent_header); - } else { - for (i = 0; i < nexceptions; i++) { - if (!mask || match_wild_nocase(mask, exceptions[i].mask)) - exception_view(u, i, &sent_header); - } - } - if (!sent_header) - notice_lang(s_OperServ, u, OPER_EXCEPTION_NO_MATCH); - - } else { - syntax_error(s_OperServ, u, "EXCEPTION", OPER_EXCEPTION_SYNTAX); - } - return MOD_CONT; + char *cmd = strtok(NULL, " "); + char *mask, *reason, *expiry, *limitstr; + int limit, expires; + int i; + int x; + + if (!LimitSessions) { + notice_lang(s_OperServ, u, OPER_EXCEPTION_DISABLED); + return MOD_CONT; + } + + if (!cmd) + cmd = ""; + + if (stricmp(cmd, "ADD") == 0) { + if (nexceptions >= 32767) { + notice_lang(s_OperServ, u, OPER_EXCEPTION_TOO_MANY); + return MOD_CONT; + } + + mask = strtok(NULL, " "); + if (mask && *mask == '+') { + expiry = mask; + mask = strtok(NULL, " "); + } else { + expiry = NULL; + } + limitstr = strtok(NULL, " "); + reason = strtok(NULL, ""); + + if (!reason) { + syntax_error(s_OperServ, u, "EXCEPTION", + OPER_EXCEPTION_ADD_SYNTAX); + return MOD_CONT; + } + + expires = expiry ? dotime(expiry) : ExceptionExpiry; + if (expires < 0) { + notice_lang(s_OperServ, u, BAD_EXPIRY_TIME); + return MOD_CONT; + } else if (expires > 0) { + expires += time(NULL); + } + + limit = (limitstr && isdigit(*limitstr)) ? atoi(limitstr) : -1; + + if (limit < 0 || limit > MaxSessionLimit) { + notice_lang(s_OperServ, u, OPER_EXCEPTION_INVALID_LIMIT, + MaxSessionLimit); + return MOD_CONT; + + } else { + if (strchr(mask, '!') || strchr(mask, '@')) { + notice_lang(s_OperServ, u, + OPER_EXCEPTION_INVALID_HOSTMASK); + return MOD_CONT; + } + + x = exception_add(u, mask, limit, reason, u->nick, expires); + + if (x == 1) { + notice_lang(s_OperServ, u, OPER_EXCEPTION_ADDED, mask, + limit); + } + + if (readonly) + notice_lang(s_OperServ, u, READ_ONLY_MODE); + } + } else if (stricmp(cmd, "DEL") == 0) { + mask = strtok(NULL, " "); + + if (!mask) { + syntax_error(s_OperServ, u, "EXCEPTION", + OPER_EXCEPTION_DEL_SYNTAX); + return MOD_CONT; + } + + if (isdigit(*mask) && strspn(mask, "1234567890,-") == strlen(mask)) { + int count, deleted, last = -1; + deleted = + process_numlist(mask, &count, exception_del_callback, u, + &last); + if (!deleted) { + if (count == 1) { + notice_lang(s_OperServ, u, + OPER_EXCEPTION_NO_SUCH_ENTRY, last); + } else { + notice_lang(s_OperServ, u, OPER_EXCEPTION_NO_MATCH); + } + } else if (deleted == 1) { + notice_lang(s_OperServ, u, OPER_EXCEPTION_DELETED_ONE); + } else { + notice_lang(s_OperServ, u, OPER_EXCEPTION_DELETED_SEVERAL, + deleted); + } + } else { + int deleted = 0; + + for (i = 0; i < nexceptions; i++) { + if (stricmp(mask, exceptions[i].mask) == 0) { + exception_del(i); + notice_lang(s_OperServ, u, OPER_EXCEPTION_DELETED, + mask); + deleted = 1; + break; + } + } + if (!deleted && i == nexceptions) + notice_lang(s_OperServ, u, OPER_EXCEPTION_NOT_FOUND, mask); + } + + /* Renumber the exception list. I don't believe in having holes in + * lists - it makes code more complex, harder to debug and we end up + * with huge index numbers. Imho, fixed numbering is only beneficial + * when one doesn't have range capable manipulation. -TheShadow */ + + for (i = 0; i < nexceptions; i++) + exceptions[i].num = i; + + if (readonly) + notice_lang(s_OperServ, u, READ_ONLY_MODE); + + } else if (stricmp(cmd, "MOVE") == 0) { + Exception *exception; + char *n1str = strtok(NULL, " "); /* From position */ + char *n2str = strtok(NULL, " "); /* To position */ + int n1, n2; + + if (!n2str) { + syntax_error(s_OperServ, u, "EXCEPTION", + OPER_EXCEPTION_MOVE_SYNTAX); + return MOD_CONT; + } + + n1 = atoi(n1str) - 1; + n2 = atoi(n2str) - 1; + + if ((n1 >= 0 && n1 < nexceptions) && (n2 >= 0 && n2 < nexceptions) + && (n1 != n2)) { + exception = (Exception *)scalloc(sizeof(Exception), 1); + memcpy(exception, &exceptions[n1], sizeof(Exception)); + + if (n1 < n2) { + /* Shift upwards */ + memmove(&exceptions[n1], &exceptions[n1 + 1], + sizeof(Exception) * (n2 - n1)); + memmove(&exceptions[n2], exception, sizeof(Exception)); + } else { + /* Shift downwards */ + memmove(&exceptions[n2 + 1], &exceptions[n2], + sizeof(Exception) * (n1 - n2)); + memmove(&exceptions[n2], exception, sizeof(Exception)); + } + + free(exception); + + notice_lang(s_OperServ, u, OPER_EXCEPTION_MOVED, + exceptions[n1].mask, n1 + 1, n2 + 1); + + /* Renumber the exception list. See the DEL block above for why. */ + for (i = 0; i < nexceptions; i++) + exceptions[i].num = i; + + if (readonly) + notice_lang(s_OperServ, u, READ_ONLY_MODE); + } else { + syntax_error(s_OperServ, u, "EXCEPTION", + OPER_EXCEPTION_MOVE_SYNTAX); + } + } else if (stricmp(cmd, "LIST") == 0) { + int sent_header = 0; + expire_exceptions(); + mask = strtok(NULL, " "); + if (mask && strspn(mask, "1234567890,-") == strlen(mask)) { + process_numlist(mask, NULL, exception_list_callback, u, + &sent_header); + } else { + for (i = 0; i < nexceptions; i++) { + if (!mask || match_wild_nocase(mask, exceptions[i].mask)) + exception_list(u, i, &sent_header); + } + } + if (!sent_header) + notice_lang(s_OperServ, u, OPER_EXCEPTION_NO_MATCH); + + } else if (stricmp(cmd, "VIEW") == 0) { + int sent_header = 0; + expire_exceptions(); + mask = strtok(NULL, " "); + if (mask && strspn(mask, "1234567890,-") == strlen(mask)) { + process_numlist(mask, NULL, exception_view_callback, u, + &sent_header); + } else { + for (i = 0; i < nexceptions; i++) { + if (!mask || match_wild_nocase(mask, exceptions[i].mask)) + exception_view(u, i, &sent_header); + } + } + if (!sent_header) + notice_lang(s_OperServ, u, OPER_EXCEPTION_NO_MATCH); + + } else { + syntax_error(s_OperServ, u, "EXCEPTION", OPER_EXCEPTION_SYNTAX); + } + return MOD_CONT; } /*************************************************************************/ diff --git a/src/slist.c b/src/slist.c index 30de938e4..cf84f69a0 100644 --- a/src/slist.c +++ b/src/slist.c @@ -29,34 +29,34 @@ static SListOpts slist_defopts = { 0, NULL, NULL, NULL }; */ int slist_add(SList * slist, void *item) { - if (slist->limit != 0 && slist->count >= slist->limit) - return -2; - if (slist->opts && (slist->opts->flags & SLISTF_NODUP) - && slist_indexof(slist, item) != -1) - return -3; - if (slist->capacity == slist->count) - slist_setcapacity(slist, slist->capacity + 1); - - if (slist->opts && (slist->opts->flags & SLISTF_SORT) - && slist->opts->compareitem) { - int i; - - for (i = 0; i < slist->count; i++) { - if (slist->opts->compareitem(slist, item, slist->list[i]) <= 0) { - memmove(&slist->list[i + 1], &slist->list[i], - sizeof(void *) * (slist->count - i)); - slist->list[i] = item; - break; - } - } - - if (i == slist->count) - slist->list[slist->count] = item; - } else { - slist->list[slist->count] = item; - } - - return slist->count++; + if (slist->limit != 0 && slist->count >= slist->limit) + return -2; + if (slist->opts && (slist->opts->flags & SLISTF_NODUP) + && slist_indexof(slist, item) != -1) + return -3; + if (slist->capacity == slist->count) + slist_setcapacity(slist, slist->capacity + 1); + + if (slist->opts && (slist->opts->flags & SLISTF_SORT) + && slist->opts->compareitem) { + int i; + + for (i = 0; i < slist->count; i++) { + if (slist->opts->compareitem(slist, item, slist->list[i]) <= 0) { + memmove(&slist->list[i + 1], &slist->list[i], + sizeof(void *) * (slist->count - i)); + slist->list[i] = item; + break; + } + } + + if (i == slist->count) + slist->list[slist->count] = item; + } else { + slist->list[slist->count] = item; + } + + return slist->count++; } /*************************************************************************/ @@ -70,20 +70,20 @@ int slist_add(SList * slist, void *item) */ void slist_clear(SList * slist, int mustfree) { - if (mustfree && slist->opts && slist->opts->freeitem && slist->count) { - int i; - - for (i = 0; i < slist->count; i++) - if (slist->list[i]) - slist->opts->freeitem(slist, slist->list[i]); - } - - if (slist->list) { - free(slist->list); - slist->list = NULL; - } - slist->capacity = 0; - slist->count = 0; + if (mustfree && slist->opts && slist->opts->freeitem && slist->count) { + int i; + + for (i = 0; i < slist->count; i++) + if (slist->list[i]) + slist->opts->freeitem(slist, slist->list[i]); + } + + if (slist->list) { + free(slist->list); + slist->list = NULL; + } + slist->capacity = 0; + slist->count = 0; } /*************************************************************************/ @@ -97,23 +97,23 @@ void slist_clear(SList * slist, int mustfree) */ int slist_delete(SList * slist, int index) { - /* Range check */ - if (index >= slist->count) - return 0; + /* Range check */ + if (index >= slist->count) + return 0; - if (slist->list[index] && slist->opts && slist->opts->freeitem) - slist->opts->freeitem(slist, slist->list[index]); + if (slist->list[index] && slist->opts && slist->opts->freeitem) + slist->opts->freeitem(slist, slist->list[index]); - slist->list[index] = NULL; - slist->count--; + slist->list[index] = NULL; + slist->count--; - if (index < slist->count) - memmove(&slist->list[index], &slist->list[index + 1], - sizeof(void *) * (slist->count - index)); + if (index < slist->count) + memmove(&slist->list[index], &slist->list[index + 1], + sizeof(void *) * (slist->count - index)); - slist_setcapacity(slist, slist->capacity - 1); + slist_setcapacity(slist, slist->capacity - 1); - return 1; + return 1; } /*************************************************************************/ @@ -128,65 +128,65 @@ int slist_delete(SList * slist, int index) * @return int */ int slist_delete_range(SList * slist, char *range, slist_delcheckcb_t cb, - ...) + ...) { - int count = 0, i, n1, n2; - va_list args, preserve; - - va_start(args, cb); - - for (;;) { - n1 = n2 = strtol(range, (char **) &range, 10); - range += strcspn(range, "0123456789,-"); - - if (*range == '-') { - range++; - range += strcspn(range, "0123456789,"); - if (isdigit(*range)) { - n2 = strtol(range, (char **) &range, 10); - range += strcspn(range, "0123456789,-"); - } - } - - for (i = n1; i <= n2 && i > 0 && i <= slist->count; i++) { - - if (!slist->list[i - 1]) - continue; - - /* copy this off the stack for safety's sake --nenolod */ - VA_COPY(preserve, args); - - if (cb && !cb(slist, slist->list[i - 1], preserve)) { - va_end(preserve); - return -1; - } - - /* if it's to be freed, lets free it */ - if (slist->opts && slist->opts->freeitem) - slist->opts->freeitem(slist, slist->list[i - 1]); - slist->list[i - 1] = NULL; - - /* and release the copied list */ - va_end(preserve); - - count++; - } - - range += strcspn(range, ","); - if (*range) - range++; - else - break; - } - - /* We only really delete the items from the list after having processed - * everything because it would change the position of the items in the - * list otherwise. - */ - slist_pack(slist); - - va_end(args); - return count; + int count = 0, i, n1, n2; + va_list args, preserve; + + va_start(args, cb); + + for (;;) { + n1 = n2 = strtol(range, (char **) &range, 10); + range += strcspn(range, "0123456789,-"); + + if (*range == '-') { + range++; + range += strcspn(range, "0123456789,"); + if (isdigit(*range)) { + n2 = strtol(range, (char **) &range, 10); + range += strcspn(range, "0123456789,-"); + } + } + + for (i = n1; i <= n2 && i > 0 && i <= slist->count; i++) { + + if (!slist->list[i - 1]) + continue; + + /* copy this off the stack for safety's sake --nenolod */ + VA_COPY(preserve, args); + + if (cb && !cb(slist, slist->list[i - 1], preserve)) { + va_end(preserve); + return -1; + } + + /* if it's to be freed, lets free it */ + if (slist->opts && slist->opts->freeitem) + slist->opts->freeitem(slist, slist->list[i - 1]); + slist->list[i - 1] = NULL; + + /* and release the copied list */ + va_end(preserve); + + count++; + } + + range += strcspn(range, ","); + if (*range) + range++; + else + break; + } + + /* We only really delete the items from the list after having processed + * everything because it would change the position of the items in the + * list otherwise. + */ + slist_pack(slist); + + va_end(args); + return count; } /*************************************************************************/ @@ -203,79 +203,79 @@ int slist_delete_range(SList * slist, char *range, slist_delcheckcb_t cb, */ int slist_enum(SList * slist, char *range, slist_enumcb_t cb, ...) { - int count = 0, i, res; - va_list args, preserve; - - va_start(args, cb); - - if (!range) { - for (i = 0; i < slist->count; i++) { - if (!slist->list[i]) { - alog("SList: warning: NULL pointer in the list (?)"); - continue; - } - - /* copy off stack for safety */ - VA_COPY(preserve, args); - - res = cb(slist, i + 1, slist->list[i], preserve); - if (res < 0) { - va_end(preserve); - break; - } - - /* and release our copy */ - va_end(preserve); - - count += res; - } - } else { - int n1, n2; - - for (;;) { - res = 0; - n1 = n2 = strtol(range, (char **) &range, 10); - range += strcspn(range, "0123456789,-"); - if (*range == '-') { - range++; - range += strcspn(range, "0123456789,"); - if (isdigit(*range)) { - n2 = strtol(range, (char **) &range, 10); - range += strcspn(range, "0123456789,-"); - } - } - for (i = n1; i <= n2 && i > 0 && i <= slist->count; i++) { - if (!slist->list[i - 1]) { - alog("SList: warning: NULL pointer in the list (?)"); - continue; - } - - /* copy off stack for safety */ - VA_COPY(preserve, args); - - res = cb(slist, i, slist->list[i - 1], preserve); - if (res < 0) { - va_end(preserve); - break; - } - count += res; - - /* and release our copy */ - va_end(preserve); - } - if (res < -1) - break; - range += strcspn(range, ","); - if (*range) - range++; - else - break; - } - } - - va_end(args); - - return count; + int count = 0, i, res; + va_list args, preserve; + + va_start(args, cb); + + if (!range) { + for (i = 0; i < slist->count; i++) { + if (!slist->list[i]) { + alog("SList: warning: NULL pointer in the list (?)"); + continue; + } + + /* copy off stack for safety */ + VA_COPY(preserve, args); + + res = cb(slist, i + 1, slist->list[i], preserve); + if (res < 0) { + va_end(preserve); + break; + } + + /* and release our copy */ + va_end(preserve); + + count += res; + } + } else { + int n1, n2; + + for (;;) { + res = 0; + n1 = n2 = strtol(range, (char **) &range, 10); + range += strcspn(range, "0123456789,-"); + if (*range == '-') { + range++; + range += strcspn(range, "0123456789,"); + if (isdigit(*range)) { + n2 = strtol(range, (char **) &range, 10); + range += strcspn(range, "0123456789,-"); + } + } + for (i = n1; i <= n2 && i > 0 && i <= slist->count; i++) { + if (!slist->list[i - 1]) { + alog("SList: warning: NULL pointer in the list (?)"); + continue; + } + + /* copy off stack for safety */ + VA_COPY(preserve, args); + + res = cb(slist, i, slist->list[i - 1], preserve); + if (res < 0) { + va_end(preserve); + break; + } + count += res; + + /* and release our copy */ + va_end(preserve); + } + if (res < -1) + break; + range += strcspn(range, ","); + if (*range) + range++; + else + break; + } + } + + va_end(args); + + return count; } /*************************************************************************/ @@ -287,10 +287,10 @@ int slist_enum(SList * slist, char *range, slist_enumcb_t cb, ...) */ int slist_full(SList * slist) { - if (slist->limit != 0 && slist->count >= slist->limit) - return 1; - else - return 0; + if (slist->limit != 0 && slist->count >= slist->limit) + return 1; + else + return 0; } /*************************************************************************/ @@ -302,9 +302,9 @@ int slist_full(SList * slist) */ void slist_init(SList * slist) { - memset(slist, 0, sizeof(SList)); - slist->limit = SLIST_DEFAULT_LIMIT; - slist->opts = &slist_defopts; + memset(slist, 0, sizeof(SList)); + slist->limit = SLIST_DEFAULT_LIMIT; + slist->opts = &slist_defopts; } /*************************************************************************/ @@ -317,22 +317,22 @@ void slist_init(SList * slist) */ int slist_indexof(SList * slist, void *item) { - int16 i; - void *entry; - - if (slist->count == 0) - return -1; - - for (i = 0, entry = slist->list[0]; i < slist->count; - i++, entry = slist->list[i]) { - if ((slist->opts - && slist->opts->isequal) ? (slist->opts->isequal(slist, item, - entry)) - : (item == entry)) - return i; - } - - return -1; + int16 i; + void *entry; + + if (slist->count == 0) + return -1; + + for (i = 0, entry = slist->list[0]; i < slist->count; + i++, entry = slist->list[i]) { + if ((slist->opts + && slist->opts->isequal) ? (slist->opts->isequal(slist, item, + entry)) + : (item == entry)) + return i; + } + + return -1; } /*************************************************************************/ @@ -344,11 +344,11 @@ int slist_indexof(SList * slist, void *item) */ void slist_pack(SList * slist) { - int i; + int i; - for (i = slist->count - 1; i >= 0; i--) - if (!slist->list[i]) - slist_delete(slist, i); + for (i = slist->count - 1; i >= 0; i--) + if (!slist->list[i]) + slist_delete(slist, i); } /*************************************************************************/ @@ -362,11 +362,11 @@ void slist_pack(SList * slist) */ int slist_remove(SList * slist, void *item) { - int index = slist_indexof(slist, item); - if (index == -1) - return -1; - slist_delete(slist, index); - return index; + int index = slist_indexof(slist, item); + if (index == -1) + return -1; + slist_delete(slist, index); + return index; } /*************************************************************************/ @@ -379,17 +379,17 @@ int slist_remove(SList * slist, void *item) */ int slist_setcapacity(SList * slist, int16 capacity) { - if (slist->capacity == capacity) - return 1; - slist->capacity = capacity; - if (slist->capacity) - slist->list = - (void **)srealloc(slist->list, sizeof(void *) * slist->capacity); - else { - free(slist->list); - slist->list = NULL; - } - if (slist->capacity < slist->count) - slist->count = slist->capacity; - return 1; + if (slist->capacity == capacity) + return 1; + slist->capacity = capacity; + if (slist->capacity) + slist->list = + (void **)srealloc(slist->list, sizeof(void *) * slist->capacity); + else { + free(slist->list); + slist->list = NULL; + } + if (slist->capacity < slist->count) + slist->count = slist->capacity; + return 1; } diff --git a/src/sockutil.c b/src/sockutil.c index b63c42cc3..2bfb4e204 100644 --- a/src/sockutil.c +++ b/src/sockutil.c @@ -22,8 +22,8 @@ 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 *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; @@ -37,11 +37,11 @@ static int lastchar = EOF; */ int32 read_buffer_len() { - if (read_bufend >= read_curpos) { - return read_bufend - read_curpos; - } else { - return (read_bufend + NET_BUFSIZE) - read_curpos; - } + if (read_bufend >= read_curpos) { + return read_bufend - read_curpos; + } else { + return (read_bufend + NET_BUFSIZE) - read_curpos; + } } /*************************************************************************/ @@ -55,71 +55,71 @@ int32 read_buffer_len() */ static int buffered_read(ano_socket_t fd, char *buf, int len) { - int nread, left = len; - fd_set fds; - struct timeval tv = { 0, 0 }; - int errno_save = ano_sockgeterr(); - - if (fd < 0) { - ano_sockseterr(SOCKERR_EBADF); - return -1; - } - while (left > 0) { - struct timeval *tvptr = (read_bufend == read_curpos ? NULL : &tv); - FD_ZERO(&fds); - FD_SET(fd, &fds); - while (read_bufend != read_curpos - 1 - && !(read_curpos == read_netbuf - && read_bufend == read_buftop - 1) - && select(fd + 1, &fds, 0, 0, tvptr) == 1) { - int maxread; - tvptr = &tv; /* don't wait next time */ - if (read_bufend < read_curpos) /* wrapped around? */ - maxread = (read_curpos - 1) - read_bufend; - else if (read_curpos == read_netbuf) - maxread = read_buftop - read_bufend - 1; - else - maxread = read_buftop - read_bufend; - nread = ano_sockread(fd, read_bufend, maxread); - errno_save = ano_sockgeterr(); - if (debug >= 3) - alog("debug: buffered_read wanted %d, got %d", maxread, - nread); - if (nread <= 0) - break; - read_bufend += nread; - if (read_bufend == read_buftop) - read_bufend = read_netbuf; - } - if (read_curpos == read_bufend) /* No more data on socket */ - break; - /* See if we can gobble up the rest of the buffer. */ - if (read_curpos + left >= read_buftop && read_bufend < read_curpos) { - nread = read_buftop - read_curpos; - memcpy(buf, read_curpos, nread); - buf += nread; - left -= nread; - read_curpos = read_netbuf; - } - /* Now everything we need is in a single chunk at read_curpos. */ - if (read_bufend > read_curpos && read_bufend - read_curpos < left) - nread = read_bufend - read_curpos; - else - nread = left; - if (nread) { - memcpy(buf, read_curpos, nread); - buf += nread; - left -= nread; - read_curpos += nread; - } - } - total_read += len - left; - if (debug >= 4) { - alog("debug: buffered_read(%d,%p,%d) returning %d", - fd, buf, len, len - left); - } - ano_sockseterr(errno_save); - return len - left; + int nread, left = len; + fd_set fds; + struct timeval tv = { 0, 0 }; + int errno_save = ano_sockgeterr(); + + if (fd < 0) { + ano_sockseterr(SOCKERR_EBADF); + return -1; + } + while (left > 0) { + struct timeval *tvptr = (read_bufend == read_curpos ? NULL : &tv); + FD_ZERO(&fds); + FD_SET(fd, &fds); + while (read_bufend != read_curpos - 1 + && !(read_curpos == read_netbuf + && read_bufend == read_buftop - 1) + && select(fd + 1, &fds, 0, 0, tvptr) == 1) { + int maxread; + tvptr = &tv; /* don't wait next time */ + if (read_bufend < read_curpos) /* wrapped around? */ + maxread = (read_curpos - 1) - read_bufend; + else if (read_curpos == read_netbuf) + maxread = read_buftop - read_bufend - 1; + else + maxread = read_buftop - read_bufend; + nread = ano_sockread(fd, read_bufend, maxread); + errno_save = ano_sockgeterr(); + if (debug >= 3) + alog("debug: buffered_read wanted %d, got %d", maxread, + nread); + if (nread <= 0) + break; + read_bufend += nread; + if (read_bufend == read_buftop) + read_bufend = read_netbuf; + } + if (read_curpos == read_bufend) /* No more data on socket */ + break; + /* See if we can gobble up the rest of the buffer. */ + if (read_curpos + left >= read_buftop && read_bufend < read_curpos) { + nread = read_buftop - read_curpos; + memcpy(buf, read_curpos, nread); + buf += nread; + left -= nread; + read_curpos = read_netbuf; + } + /* Now everything we need is in a single chunk at read_curpos. */ + if (read_bufend > read_curpos && read_bufend - read_curpos < left) + nread = read_bufend - read_curpos; + else + nread = left; + if (nread) { + memcpy(buf, read_curpos, nread); + buf += nread; + left -= nread; + read_curpos += nread; + } + } + total_read += len - left; + if (debug >= 4) { + alog("debug: buffered_read(%d,%p,%d) returning %d", + fd, buf, len, len - left); + } + ano_sockseterr(errno_save); + return len - left; } /*************************************************************************/ @@ -132,55 +132,55 @@ static int buffered_read(ano_socket_t fd, char *buf, int len) */ static int buffered_read_one(ano_socket_t fd) { - int nread; - fd_set fds; - struct timeval tv = { 0, 0 }; - char c; - struct timeval *tvptr = (read_bufend == read_curpos ? NULL : &tv); - int errno_save = ano_sockgeterr(); - - if (fd < 0) { - ano_sockseterr(SOCKERR_EBADF); - return -1; - } - FD_ZERO(&fds); - FD_SET(fd, &fds); - while (read_bufend != read_curpos - 1 - && !(read_curpos == read_netbuf - && read_bufend == read_buftop - 1) - && select(fd + 1, &fds, 0, 0, tvptr) == 1) { - int maxread; - tvptr = &tv; /* don't wait next time */ - if (read_bufend < read_curpos) /* wrapped around? */ - maxread = (read_curpos - 1) - read_bufend; - else if (read_curpos == read_netbuf) - maxread = read_buftop - read_bufend - 1; - else - maxread = read_buftop - read_bufend; - nread = ano_sockread(fd, read_bufend, maxread); - errno_save = ano_sockgeterr(); - if (debug >= 3) - alog("debug: buffered_read_one wanted %d, got %d", maxread, - nread); - if (nread <= 0) - break; - read_bufend += nread; - if (read_bufend == read_buftop) - read_bufend = read_netbuf; - } - if (read_curpos == read_bufend) { /* No more data on socket */ - if (debug >= 4) - alog("debug: buffered_read_one(%d) returning %d", fd, EOF); - ano_sockseterr(errno_save); - return EOF; - } - c = *read_curpos++; - if (read_curpos == read_buftop) - read_curpos = read_netbuf; - total_read++; - if (debug >= 4) - alog("debug: buffered_read_one(%d) returning %d", fd, c); - return (int) c & 0xFF; + int nread; + fd_set fds; + struct timeval tv = { 0, 0 }; + char c; + struct timeval *tvptr = (read_bufend == read_curpos ? NULL : &tv); + int errno_save = ano_sockgeterr(); + + if (fd < 0) { + ano_sockseterr(SOCKERR_EBADF); + return -1; + } + FD_ZERO(&fds); + FD_SET(fd, &fds); + while (read_bufend != read_curpos - 1 + && !(read_curpos == read_netbuf + && read_bufend == read_buftop - 1) + && select(fd + 1, &fds, 0, 0, tvptr) == 1) { + int maxread; + tvptr = &tv; /* don't wait next time */ + if (read_bufend < read_curpos) /* wrapped around? */ + maxread = (read_curpos - 1) - read_bufend; + else if (read_curpos == read_netbuf) + maxread = read_buftop - read_bufend - 1; + else + maxread = read_buftop - read_bufend; + nread = ano_sockread(fd, read_bufend, maxread); + errno_save = ano_sockgeterr(); + if (debug >= 3) + alog("debug: buffered_read_one wanted %d, got %d", maxread, + nread); + if (nread <= 0) + break; + read_bufend += nread; + if (read_bufend == read_buftop) + read_bufend = read_netbuf; + } + if (read_curpos == read_bufend) { /* No more data on socket */ + if (debug >= 4) + alog("debug: buffered_read_one(%d) returning %d", fd, EOF); + ano_sockseterr(errno_save); + return EOF; + } + c = *read_curpos++; + if (read_curpos == read_buftop) + read_curpos = read_netbuf; + total_read++; + if (debug >= 4) + alog("debug: buffered_read_one(%d) returning %d", fd, c); + return (int) c & 0xFF; } /*************************************************************************/ @@ -191,11 +191,11 @@ static int buffered_read_one(ano_socket_t fd) */ int32 write_buffer_len() { - if (write_bufend >= write_curpos) { - return write_bufend - write_curpos; - } else { - return (write_bufend + NET_BUFSIZE) - write_curpos; - } + if (write_bufend >= write_curpos) { + return write_bufend - write_curpos; + } else { + return (write_bufend + NET_BUFSIZE) - write_curpos; + } } /*************************************************************************/ @@ -208,37 +208,37 @@ int32 write_buffer_len() */ static int flush_write_buffer(int wait) { - fd_set fds; - struct timeval tv = { 0, 0 }; - int errno_save = ano_sockgeterr(); - - if (write_bufend == write_curpos || write_fd == -1) - return 0; - FD_ZERO(&fds); - FD_SET(write_fd, &fds); - if (select(write_fd + 1, 0, &fds, 0, wait ? NULL : &tv) == 1) { - int maxwrite, nwritten; - if (write_curpos > write_bufend) /* wrapped around? */ - maxwrite = write_buftop - write_curpos; - else if (write_bufend == write_netbuf) - maxwrite = write_buftop - write_curpos - 1; - else - maxwrite = write_bufend - write_curpos; - nwritten = ano_sockwrite(write_fd, write_curpos, maxwrite); - errno_save = ano_sockgeterr(); - if (debug >= 3) - alog("debug: flush_write_buffer wanted %d, got %d", maxwrite, - nwritten); - if (nwritten > 0) { - write_curpos += nwritten; - if (write_curpos == write_buftop) - write_curpos = write_netbuf; - total_written += nwritten; - return nwritten; - } - } - ano_sockseterr(errno_save); - return 0; + fd_set fds; + struct timeval tv = { 0, 0 }; + int errno_save = ano_sockgeterr(); + + if (write_bufend == write_curpos || write_fd == -1) + return 0; + FD_ZERO(&fds); + FD_SET(write_fd, &fds); + if (select(write_fd + 1, 0, &fds, 0, wait ? NULL : &tv) == 1) { + int maxwrite, nwritten; + if (write_curpos > write_bufend) /* wrapped around? */ + maxwrite = write_buftop - write_curpos; + else if (write_bufend == write_netbuf) + maxwrite = write_buftop - write_curpos - 1; + else + maxwrite = write_bufend - write_curpos; + nwritten = ano_sockwrite(write_fd, write_curpos, maxwrite); + errno_save = ano_sockgeterr(); + if (debug >= 3) + alog("debug: flush_write_buffer wanted %d, got %d", maxwrite, + nwritten); + if (nwritten > 0) { + write_curpos += nwritten; + if (write_curpos == write_buftop) + write_curpos = write_netbuf; + total_written += nwritten; + return nwritten; + } + } + ano_sockseterr(errno_save); + return 0; } /*************************************************************************/ @@ -252,66 +252,66 @@ static int flush_write_buffer(int wait) */ static int buffered_write(ano_socket_t fd, char *buf, int len) { - int nwritten, left = len; - int errno_save = ano_sockgeterr(); - - if (fd < 0) { - errno = EBADF; - return -1; - } - write_fd = fd; - - while (left > 0) { - - /* Don't try putting anything in the buffer if it's full. */ - if (write_curpos != write_bufend + 1 && - (write_curpos != write_netbuf - || write_bufend != write_buftop - 1)) { - /* See if we need to write up to the end of the buffer. */ - if (write_bufend + left >= write_buftop - && write_curpos <= write_bufend) { - nwritten = write_buftop - write_bufend; - memcpy(write_bufend, buf, nwritten); - buf += nwritten; - left -= nwritten; - write_bufend = write_netbuf; - } - /* Now we can copy a single chunk to write_bufend. */ - if (write_curpos > write_bufend - && write_curpos - write_bufend - 1 < left) - nwritten = write_curpos - write_bufend - 1; - else - nwritten = left; - if (nwritten) { - memcpy(write_bufend, buf, nwritten); - buf += nwritten; - left -= nwritten; - write_bufend += nwritten; - } - } - - /* Now write to the socket as much as we can. */ - if (write_curpos == write_bufend + 1 || - (write_curpos == write_netbuf - && write_bufend == write_buftop - 1)) - flush_write_buffer(1); - else - flush_write_buffer(0); - errno_save = errno; - if (write_curpos == write_bufend + 1 || - (write_curpos == write_netbuf - && write_bufend == write_buftop - 1)) { - /* Write failed on full buffer */ - break; - } - } - - if (debug >= 4) { - alog("debug: buffered_write(%d,%p,%d) returning %d", - fd, buf, len, len - left); - } - ano_sockseterr(errno_save); - return len - left; + int nwritten, left = len; + int errno_save = ano_sockgeterr(); + + if (fd < 0) { + errno = EBADF; + return -1; + } + write_fd = fd; + + while (left > 0) { + + /* Don't try putting anything in the buffer if it's full. */ + if (write_curpos != write_bufend + 1 && + (write_curpos != write_netbuf + || write_bufend != write_buftop - 1)) { + /* See if we need to write up to the end of the buffer. */ + if (write_bufend + left >= write_buftop + && write_curpos <= write_bufend) { + nwritten = write_buftop - write_bufend; + memcpy(write_bufend, buf, nwritten); + buf += nwritten; + left -= nwritten; + write_bufend = write_netbuf; + } + /* Now we can copy a single chunk to write_bufend. */ + if (write_curpos > write_bufend + && write_curpos - write_bufend - 1 < left) + nwritten = write_curpos - write_bufend - 1; + else + nwritten = left; + if (nwritten) { + memcpy(write_bufend, buf, nwritten); + buf += nwritten; + left -= nwritten; + write_bufend += nwritten; + } + } + + /* Now write to the socket as much as we can. */ + if (write_curpos == write_bufend + 1 || + (write_curpos == write_netbuf + && write_bufend == write_buftop - 1)) + flush_write_buffer(1); + else + flush_write_buffer(0); + errno_save = errno; + if (write_curpos == write_bufend + 1 || + (write_curpos == write_netbuf + && write_bufend == write_buftop - 1)) { + /* Write failed on full buffer */ + break; + } + } + + if (debug >= 4) { + alog("debug: buffered_write(%d,%p,%d) returning %d", + fd, buf, len, len - left); + } + ano_sockseterr(errno_save); + return len - left; } @@ -328,43 +328,43 @@ static int buffered_write(ano_socket_t fd, char *buf, int len) #if 0 static int buffered_write_one(int c, ano_socket_t fd) { - struct timeval tv = { 0, 0 }; - - if (fd < 0) { - ano_sockseterr(SOCKERR_EBADF); - return -1; - } - write_fd = fd; - - /* Try to flush the buffer if it's full. */ - if (write_curpos == write_bufend + 1 || - (write_curpos == write_netbuf - && write_bufend == write_buftop - 1)) { - flush_write_buffer(1); - if (write_curpos == write_bufend + 1 || - (write_curpos == write_netbuf - && write_bufend == write_buftop - 1)) { - /* Write failed */ - if (debug >= 4) - alog("debug: buffered_write_one(%d) returning %d", fd, - EOF); - return EOF; - } - } - - /* Write the character. */ - *write_bufend++ = c; - if (write_bufend == write_buftop) - write_bufend = write_netbuf; - - /* Move it to the socket if we can. */ - flush_write_buffer(0); - - if (debug >= 4) - alog("debug: buffered_write_one(%d) returning %d", fd, c); - return (int) c & 0xFF; + struct timeval tv = { 0, 0 }; + + if (fd < 0) { + ano_sockseterr(SOCKERR_EBADF); + return -1; + } + write_fd = fd; + + /* Try to flush the buffer if it's full. */ + if (write_curpos == write_bufend + 1 || + (write_curpos == write_netbuf + && write_bufend == write_buftop - 1)) { + flush_write_buffer(1); + if (write_curpos == write_bufend + 1 || + (write_curpos == write_netbuf + && write_bufend == write_buftop - 1)) { + /* Write failed */ + if (debug >= 4) + alog("debug: buffered_write_one(%d) returning %d", fd, + EOF); + return EOF; + } + } + + /* Write the character. */ + *write_bufend++ = c; + if (write_bufend == write_buftop) + write_bufend = write_netbuf; + + /* Move it to the socket if we can. */ + flush_write_buffer(0); + + if (debug >= 4) + alog("debug: buffered_write_one(%d) returning %d", fd, c); + return (int) c & 0xFF; } -#endif /* 0 */ +#endif /* 0 */ /*************************************************************************/ @@ -375,14 +375,14 @@ static int buffered_write_one(int c, ano_socket_t fd) */ int sgetc(ano_socket_t s) { - int c; - - if (lastchar != EOF) { - c = lastchar; - lastchar = EOF; - return c; - } - return buffered_read_one(s); + int c; + + if (lastchar != EOF) { + c = lastchar; + lastchar = EOF; + return c; + } + return buffered_read_one(s); } /*************************************************************************/ @@ -395,7 +395,7 @@ int sgetc(ano_socket_t s) */ int sungetc(int c, int s) { - return lastchar = c; + return lastchar = c; } /*************************************************************************/ @@ -410,39 +410,39 @@ int sungetc(int c, int s) */ char *sgets(char *buf, int len, ano_socket_t s) { - int c = 0; - struct timeval tv; - fd_set fds; - char *ptr = buf; - - flush_write_buffer(0); - - if (len == 0) - return NULL; - FD_SET(s, &fds); - tv.tv_sec = ReadTimeout; - tv.tv_usec = 0; - while (read_buffer_len() == 0 && - (c = select(s + 1, &fds, NULL, NULL, &tv)) < 0) { - if (ano_sockgeterr() != EINTR) - break; - flush_write_buffer(0); - } - if (read_buffer_len() == 0 && c == 0) - return (char *) -1; - c = sgetc(s); - while (--len && (*ptr++ = c) != '\n' && (c = sgetc(s)) >= 0); - if (c < 0) - return NULL; - *ptr = 0; - return buf; + int c = 0; + struct timeval tv; + fd_set fds; + char *ptr = buf; + + flush_write_buffer(0); + + if (len == 0) + return NULL; + FD_SET(s, &fds); + tv.tv_sec = ReadTimeout; + tv.tv_usec = 0; + while (read_buffer_len() == 0 && + (c = select(s + 1, &fds, NULL, NULL, &tv)) < 0) { + if (ano_sockgeterr() != EINTR) + break; + flush_write_buffer(0); + } + if (read_buffer_len() == 0 && c == 0) + return (char *) -1; + c = sgetc(s); + while (--len && (*ptr++ = c) != '\n' && (c = sgetc(s)) >= 0); + if (c < 0) + return NULL; + *ptr = 0; + return buf; } /*************************************************************************/ /** * sgets2: Read a line of text from a socket, and strip newline and - * carriage return characters from the end of the line. + * carriage return characters from the end of the line. * @param buf Buffer to get * @param len Length * @param s Socket @@ -450,16 +450,16 @@ char *sgets(char *buf, int len, ano_socket_t s) */ char *sgets2(char *buf, int len, ano_socket_t s) { - char *str = sgets(buf, len, s); - - if (!str || str == (char *) -1) - return str; - str = buf + strlen(buf) - 1; - if (*str == '\n') - *str-- = 0; - if (*str == '\r') - *str = 0; - return buf; + char *str = sgets(buf, len, s); + + if (!str || str == (char *) -1) + return str; + str = buf + strlen(buf) - 1; + if (*str == '\n') + *str-- = 0; + if (*str == '\r') + *str = 0; + return buf; } /*************************************************************************/ @@ -474,7 +474,7 @@ char *sgets2(char *buf, int len, ano_socket_t s) */ int sread(ano_socket_t s, char *buf, int len) { - return buffered_read(s, buf, len); + return buffered_read(s, buf, len); } /*************************************************************************/ @@ -487,7 +487,7 @@ int sread(ano_socket_t s, char *buf, int len) */ int sputs(char *str, ano_socket_t s) { - return buffered_write(s, str, strlen(str)); + return buffered_write(s, str, strlen(str)); } /*************************************************************************/ @@ -501,14 +501,14 @@ int sputs(char *str, ano_socket_t s) */ int sockprintf(ano_socket_t s, const char *fmt, ...) { - va_list args; - char buf[16384]; /* Really huge, to try and avoid truncation */ - int value; - - va_start(args, fmt); - value = buffered_write(s, buf, vsnprintf(buf, sizeof(buf), fmt, args)); - va_end(args); - return value; + va_list args; + char buf[16384]; /* Really huge, to try and avoid truncation */ + int value; + + va_start(args, fmt); + value = buffered_write(s, buf, vsnprintf(buf, sizeof(buf), fmt, args)); + va_end(args); + return value; } /*************************************************************************/ @@ -523,18 +523,18 @@ int sockprintf(ano_socket_t s, const char *fmt, ...) */ static char *pack_ip(const char *ipaddr) { - static char ipbuf[4]; - int tmp[4], i; - - if (sscanf(ipaddr, "%d.%d.%d.%d", &tmp[0], &tmp[1], &tmp[2], &tmp[3]) - != 4) - return NULL; - for (i = 0; i < 4; i++) { - if (tmp[i] < 0 || tmp[i] > 255) - return NULL; - ipbuf[i] = tmp[i]; - } - return ipbuf; + static char ipbuf[4]; + int tmp[4], i; + + if (sscanf(ipaddr, "%d.%d.%d.%d", &tmp[0], &tmp[1], &tmp[2], &tmp[3]) + != 4) + return NULL; + for (i = 0; i < 4; i++) { + if (tmp[i] < 0 || tmp[i] > 255) + return NULL; + ipbuf[i] = tmp[i]; + } + return ipbuf; } #endif @@ -553,73 +553,73 @@ static char *pack_ip(const char *ipaddr) int conn(const char *host, int port, const char *lhost, int lport) { #if HAVE_GETHOSTBYNAME - struct hostent *hp; + struct hostent *hp; #else - char *addr; + char *addr; #endif - struct sockaddr_in sa, lsa; - ano_socket_t sock; - int sockopt = 1; + struct sockaddr_in sa, lsa; + ano_socket_t sock; + int sockopt = 1; - memset(&lsa, 0, sizeof(lsa)); - if (lhost) { + memset(&lsa, 0, sizeof(lsa)); + if (lhost) { #if HAVE_GETHOSTBYNAME - if ((hp = gethostbyname(lhost)) != NULL) { - memcpy((char *) &lsa.sin_addr, hp->h_addr, hp->h_length); - lsa.sin_family = hp->h_addrtype; + if ((hp = gethostbyname(lhost)) != NULL) { + memcpy((char *) &lsa.sin_addr, hp->h_addr, hp->h_length); + lsa.sin_family = hp->h_addrtype; #else - if (addr = pack_ip(lhost)) { - memcpy((char *) &lsa.sin_addr, addr, 4); - lsa.sin_family = AF_INET; + if (addr = pack_ip(lhost)) { + memcpy((char *) &lsa.sin_addr, addr, 4); + lsa.sin_family = AF_INET; #endif - } else { - lhost = NULL; - } - } - if (lport) - lsa.sin_port = htons((unsigned short) lport); - - memset(&sa, 0, sizeof(sa)); + } else { + lhost = NULL; + } + } + if (lport) + lsa.sin_port = htons((unsigned short) lport); + + memset(&sa, 0, sizeof(sa)); #if HAVE_GETHOSTBYNAME - if (!(hp = gethostbyname(host))) - return -1; - memcpy((char *) &sa.sin_addr, hp->h_addr, hp->h_length); - sa.sin_family = hp->h_addrtype; + if (!(hp = gethostbyname(host))) + return -1; + memcpy((char *) &sa.sin_addr, hp->h_addr, hp->h_length); + sa.sin_family = hp->h_addrtype; #else - if (!(addr = pack_ip(host))) { - alog("conn(): `%s' is not a valid IP address", host); - ano_sockseterr(SOCKERR_EINVAL); - return -1; - } - memcpy((char *) &sa.sin_addr, addr, 4); - sa.sin_family = AF_INET; + if (!(addr = pack_ip(host))) { + alog("conn(): `%s' is not a valid IP address", host); + ano_sockseterr(SOCKERR_EINVAL); + return -1; + } + memcpy((char *) &sa.sin_addr, addr, 4); + sa.sin_family = AF_INET; #endif - sa.sin_port = htons((unsigned short) port); - - if ((sock = socket(sa.sin_family, SOCK_STREAM, 0)) < 0) - return -1; - - if (setsockopt - (sock, SOL_SOCKET, SO_REUSEADDR, (char *) &sockopt, - sizeof(int)) < 0) - alog("debug: couldn't set SO_REUSEADDR on socket"); - - if ((lhost || lport) - && bind(sock, (struct sockaddr *) &lsa, sizeof(lsa)) < 0) { - int errno_save = ano_sockgeterr(); - ano_sockclose(sock); - ano_sockseterr(errno_save); - return -1; - } - - if (connect(sock, (struct sockaddr *) &sa, sizeof(sa)) < 0) { - int errno_save = ano_sockgeterr(); - ano_sockclose(sock); - ano_sockseterr(errno_save); - return -1; - } - - return sock; + sa.sin_port = htons((unsigned short) port); + + if ((sock = socket(sa.sin_family, SOCK_STREAM, 0)) < 0) + return -1; + + if (setsockopt + (sock, SOL_SOCKET, SO_REUSEADDR, (char *) &sockopt, + sizeof(int)) < 0) + alog("debug: couldn't set SO_REUSEADDR on socket"); + + if ((lhost || lport) + && bind(sock, (struct sockaddr *) &lsa, sizeof(lsa)) < 0) { + int errno_save = ano_sockgeterr(); + ano_sockclose(sock); + ano_sockseterr(errno_save); + return -1; + } + + if (connect(sock, (struct sockaddr *) &sa, sizeof(sa)) < 0) { + int errno_save = ano_sockgeterr(); + ano_sockclose(sock); + ano_sockseterr(errno_save); + return -1; + } + + return sock; } /*************************************************************************/ @@ -631,8 +631,8 @@ int conn(const char *host, int port, const char *lhost, int lport) */ void disconn(ano_socket_t s) { - shutdown(s, 2); - ano_sockclose(s); + shutdown(s, 2); + ano_sockclose(s); } /*************************************************************************/ @@ -641,97 +641,97 @@ void disconn(ano_socket_t s) #ifdef _WIN32 /* Microsoft makes things nice and fun for us! */ struct u_WSA_errors { - int error_code; - char *error_string; + int error_code; + char *error_string; }; /* Must be sorted ascending by error code */ struct u_WSA_errors WSAErrors[] = { - {WSAEINTR, "Interrupted system call"}, - {WSAEBADF, "Bad file number"}, - {WSAEACCES, "Permission denied"}, - {WSAEFAULT, "Bad address"}, - {WSAEINVAL, "Invalid argument"}, - {WSAEMFILE, "Too many open sockets"}, - {WSAEWOULDBLOCK, "Operation would block"}, - {WSAEINPROGRESS, "Operation now in progress"}, - {WSAEALREADY, "Operation already in progress"}, - {WSAENOTSOCK, "Socket operation on non-socket"}, - {WSAEDESTADDRREQ, "Destination address required"}, - {WSAEMSGSIZE, "Message too long"}, - {WSAEPROTOTYPE, "Protocol wrong type for socket"}, - {WSAENOPROTOOPT, "Bad protocol option"}, - {WSAEPROTONOSUPPORT, "Protocol not supported"}, - {WSAESOCKTNOSUPPORT, "Socket type not supported"}, - {WSAEOPNOTSUPP, "Operation not supported on socket"}, - {WSAEPFNOSUPPORT, "Protocol family not supported"}, - {WSAEAFNOSUPPORT, "Address family not supported"}, - {WSAEADDRINUSE, "Address already in use"}, - {WSAEADDRNOTAVAIL, "Can't assign requested address"}, - {WSAENETDOWN, "Network is down"}, - {WSAENETUNREACH, "Network is unreachable"}, - {WSAENETRESET, "Net connection reset"}, - {WSAECONNABORTED, "Software caused connection abort"}, - {WSAECONNRESET, "Connection reset by peer"}, - {WSAENOBUFS, "No buffer space available"}, - {WSAEISCONN, "Socket is already connected"}, - {WSAENOTCONN, "Socket is not connected"}, - {WSAESHUTDOWN, "Can't send after socket shutdown"}, - {WSAETOOMANYREFS, "Too many references, can't splice"}, - {WSAETIMEDOUT, "Connection timed out"}, - {WSAECONNREFUSED, "Connection refused"}, - {WSAELOOP, "Too many levels of symbolic links"}, - {WSAENAMETOOLONG, "File name too long"}, - {WSAEHOSTDOWN, "Host is down"}, - {WSAEHOSTUNREACH, "No route to host"}, - {WSAENOTEMPTY, "Directory not empty"}, - {WSAEPROCLIM, "Too many processes"}, - {WSAEUSERS, "Too many users"}, - {WSAEDQUOT, "Disc quota exceeded"}, - {WSAESTALE, "Stale NFS file handle"}, - {WSAEREMOTE, "Too many levels of remote in path"}, - {WSASYSNOTREADY, "Network subsystem is unavailable"}, - {WSAVERNOTSUPPORTED, "Winsock version not supported"}, - {WSANOTINITIALISED, "Winsock not yet initialized"}, - {WSAHOST_NOT_FOUND, "Host not found"}, - {WSATRY_AGAIN, "Non-authoritative host not found"}, - {WSANO_RECOVERY, "Non-recoverable errors"}, - {WSANO_DATA, "Valid name, no data record of requested type"}, - {WSAEDISCON, "Graceful disconnect in progress"}, + {WSAEINTR, "Interrupted system call"}, + {WSAEBADF, "Bad file number"}, + {WSAEACCES, "Permission denied"}, + {WSAEFAULT, "Bad address"}, + {WSAEINVAL, "Invalid argument"}, + {WSAEMFILE, "Too many open sockets"}, + {WSAEWOULDBLOCK, "Operation would block"}, + {WSAEINPROGRESS, "Operation now in progress"}, + {WSAEALREADY, "Operation already in progress"}, + {WSAENOTSOCK, "Socket operation on non-socket"}, + {WSAEDESTADDRREQ, "Destination address required"}, + {WSAEMSGSIZE, "Message too long"}, + {WSAEPROTOTYPE, "Protocol wrong type for socket"}, + {WSAENOPROTOOPT, "Bad protocol option"}, + {WSAEPROTONOSUPPORT, "Protocol not supported"}, + {WSAESOCKTNOSUPPORT, "Socket type not supported"}, + {WSAEOPNOTSUPP, "Operation not supported on socket"}, + {WSAEPFNOSUPPORT, "Protocol family not supported"}, + {WSAEAFNOSUPPORT, "Address family not supported"}, + {WSAEADDRINUSE, "Address already in use"}, + {WSAEADDRNOTAVAIL, "Can't assign requested address"}, + {WSAENETDOWN, "Network is down"}, + {WSAENETUNREACH, "Network is unreachable"}, + {WSAENETRESET, "Net connection reset"}, + {WSAECONNABORTED, "Software caused connection abort"}, + {WSAECONNRESET, "Connection reset by peer"}, + {WSAENOBUFS, "No buffer space available"}, + {WSAEISCONN, "Socket is already connected"}, + {WSAENOTCONN, "Socket is not connected"}, + {WSAESHUTDOWN, "Can't send after socket shutdown"}, + {WSAETOOMANYREFS, "Too many references, can't splice"}, + {WSAETIMEDOUT, "Connection timed out"}, + {WSAECONNREFUSED, "Connection refused"}, + {WSAELOOP, "Too many levels of symbolic links"}, + {WSAENAMETOOLONG, "File name too long"}, + {WSAEHOSTDOWN, "Host is down"}, + {WSAEHOSTUNREACH, "No route to host"}, + {WSAENOTEMPTY, "Directory not empty"}, + {WSAEPROCLIM, "Too many processes"}, + {WSAEUSERS, "Too many users"}, + {WSAEDQUOT, "Disc quota exceeded"}, + {WSAESTALE, "Stale NFS file handle"}, + {WSAEREMOTE, "Too many levels of remote in path"}, + {WSASYSNOTREADY, "Network subsystem is unavailable"}, + {WSAVERNOTSUPPORTED, "Winsock version not supported"}, + {WSANOTINITIALISED, "Winsock not yet initialized"}, + {WSAHOST_NOT_FOUND, "Host not found"}, + {WSATRY_AGAIN, "Non-authoritative host not found"}, + {WSANO_RECOVERY, "Non-recoverable errors"}, + {WSANO_DATA, "Valid name, no data record of requested type"}, + {WSAEDISCON, "Graceful disconnect in progress"}, #ifdef WSASYSCALLFAILURE - {WSASYSCALLFAILURE, "System call failure"}, + {WSASYSCALLFAILURE, "System call failure"}, #endif - {0, NULL} + {0, NULL} }; char *ano_sockstrerror(int error) { - static char unkerr[64]; - int start = 0; - int stop = sizeof(WSAErrors) / sizeof(WSAErrors[0]) - 1; - int mid; - - /* Microsoft decided not to use sequential numbers for the error codes, - * so we can't just use the array index for the code. But, at least - * use a binary search to make it as fast as possible. - */ - while (start <= stop) { - mid = (start + stop) / 2; - if (WSAErrors[mid].error_code > error) - stop = mid - 1; - - else if (WSAErrors[mid].error_code < error) - start = mid + 1; - else - return WSAErrors[mid].error_string; - } - sprintf(unkerr, "Unknown Error: %d", error); - return unkerr; + static char unkerr[64]; + int start = 0; + int stop = sizeof(WSAErrors) / sizeof(WSAErrors[0]) - 1; + int mid; + + /* Microsoft decided not to use sequential numbers for the error codes, + * so we can't just use the array index for the code. But, at least + * use a binary search to make it as fast as possible. + */ + while (start <= stop) { + mid = (start + stop) / 2; + if (WSAErrors[mid].error_code > error) + stop = mid - 1; + + else if (WSAErrors[mid].error_code < error) + start = mid + 1; + else + return WSAErrors[mid].error_string; + } + sprintf(unkerr, "Unknown Error: %d", error); + return unkerr; } int ano_socksetnonb(ano_socket_t fd) { - u_long i = 1; - return (!ioctlsocket(fd, FIONBIO, &i) ? -1 : 1); + u_long i = 1; + return (!ioctlsocket(fd, FIONBIO, &i) ? -1 : 1); } #endif diff --git a/src/timeout.c b/src/timeout.c index 94280c1d9..99e47164d 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -23,39 +23,39 @@ static Timeout *timeouts = NULL; void check_timeouts(void) { - Timeout *to, *to2; - time_t t = time(NULL); + Timeout *to, *to2; + time_t t = time(NULL); - if (debug >= 2) - alog("debug: Checking timeouts at %ld", (long int) t); + if (debug >= 2) + alog("debug: Checking timeouts at %ld", (long int) t); - to = timeouts; - while (to) { - if (t < to->timeout) { - to = to->next; - continue; - } - if (debug >= 4) { - alog("debug: Running timeout 0x%p (code=0x%p repeat=%d)", - (void *) to, (void *) to->code, to->repeat); - } - to->code(to); - if (to->repeat) { - to = to->next; - continue; - } - to2 = to->next; - if (to->next) - to->next->prev = to->prev; - if (to->prev) - to->prev->next = to->next; - else - timeouts = to->next; - free(to); - to = to2; - } - if (debug >= 2) - alog("debug: Finished timeout list"); + to = timeouts; + while (to) { + if (t < to->timeout) { + to = to->next; + continue; + } + if (debug >= 4) { + alog("debug: Running timeout 0x%p (code=0x%p repeat=%d)", + (void *) to, (void *) to->code, to->repeat); + } + to->code(to); + if (to->repeat) { + to = to->next; + continue; + } + to2 = to->next; + if (to->next) + to->next->prev = to->prev; + if (to->prev) + to->prev->next = to->next; + else + timeouts = to->next; + free(to); + to = to2; + } + if (debug >= 2) + alog("debug: Finished timeout list"); } /*************************************************************************/ @@ -68,17 +68,17 @@ void check_timeouts(void) Timeout *add_timeout(int delay, void (*code) (Timeout *), int repeat) { - Timeout *t = (Timeout *)scalloc(sizeof(Timeout), 1); - t->settime = time(NULL); - t->timeout = t->settime + delay; - t->code = code; - t->repeat = repeat; - t->next = timeouts; - t->prev = NULL; - if (timeouts) - timeouts->prev = t; - timeouts = t; - return t; + Timeout *t = (Timeout *)scalloc(sizeof(Timeout), 1); + t->settime = time(NULL); + t->timeout = t->settime + delay; + t->code = code; + t->repeat = repeat; + t->next = timeouts; + t->prev = NULL; + if (timeouts) + timeouts->prev = t; + timeouts = t; + return t; } /*************************************************************************/ @@ -87,21 +87,21 @@ Timeout *add_timeout(int delay, void (*code) (Timeout *), int repeat) void del_timeout(Timeout * t) { - Timeout *ptr; + Timeout *ptr; - for (ptr = timeouts; ptr; ptr = ptr->next) { - if (ptr == t) - break; - } - if (!ptr) - return; - if (t->prev) - t->prev->next = t->next; - else - timeouts = t->next; - if (t->next) - t->next->prev = t->prev; - free(t); + for (ptr = timeouts; ptr; ptr = ptr->next) { + if (ptr == t) + break; + } + if (!ptr) + return; + if (t->prev) + t->prev->next = t->next; + else + timeouts = t->next; + if (t->next) + t->next->prev = t->prev; + free(t); } /*************************************************************************/ diff --git a/src/tools/anopesmtp.c b/src/tools/anopesmtp.c index f5981a851..d00bcdc18 100644 --- a/src/tools/anopesmtp.c +++ b/src/tools/anopesmtp.c @@ -23,37 +23,37 @@ static int curday = 0; #ifdef _WIN32 int strcasecmp(const char *s1, const char *s2) { - register int c; - - while ((c = tolower(*s1)) == tolower(*s2)) { - if (c == 0) - return 0; - s1++; - s2++; - } - if (c < tolower(*s2)) - return -1; - return 1; + register int c; + + while ((c = tolower(*s1)) == tolower(*s2)) { + if (c == 0) + return 0; + s1++; + s2++; + } + if (c < tolower(*s2)) + return -1; + return 1; } #endif static int get_logname(char *name, int count, struct tm *tm) { - char timestamp[32]; + char timestamp[32]; - if (!tm) { - time_t t; + if (!tm) { + time_t t; - time(&t); - tm = localtime(&t); - } + time(&t); + tm = localtime(&t); + } - strftime(timestamp, count, "%Y%m%d", tm); - snprintf(name, count, "logs/%s.%s", "anopesmtp", timestamp); - curday = tm->tm_yday; + strftime(timestamp, count, "%Y%m%d", tm); + snprintf(name, count, "logs/%s.%s", "anopesmtp", timestamp); + curday = tm->tm_yday; - return 1; + return 1; } /*************************************************************************/ @@ -62,28 +62,28 @@ static int get_logname(char *name, int count, struct tm *tm) void close_log(void) { - if (!logfile) - return; - fclose(logfile); - logfile = NULL; + if (!logfile) + return; + fclose(logfile); + logfile = NULL; } /*************************************************************************/ static void remove_log(void) { - time_t t; - struct tm tm; + time_t t; + struct tm tm; - char name[PATH_MAX]; + char name[PATH_MAX]; - time(&t); - t -= (60 * 60 * 24 * 30); - tm = *localtime(&t); + time(&t); + t -= (60 * 60 * 24 * 30); + tm = *localtime(&t); - if (!get_logname(name, sizeof(name), &tm)) - return; - unlink(name); + if (!get_logname(name, sizeof(name), &tm)) + return; + unlink(name); } /*************************************************************************/ @@ -93,35 +93,35 @@ static void remove_log(void) int open_log(void) { - char name[PATH_MAX]; + char name[PATH_MAX]; - if (logfile) - return 0; + if (logfile) + return 0; - if (!get_logname(name, sizeof(name), NULL)) - return 0; - logfile = fopen(name, "a"); + if (!get_logname(name, sizeof(name), NULL)) + return 0; + logfile = fopen(name, "a"); - if (logfile) - setbuf(logfile, NULL); - return logfile != NULL ? 0 : -1; + if (logfile) + setbuf(logfile, NULL); + return logfile != NULL ? 0 : -1; } /*************************************************************************/ static void checkday(void) { - time_t t; - struct tm tm; + time_t t; + struct tm tm; - time(&t); - tm = *localtime(&t); + time(&t); + tm = *localtime(&t); - if (curday != tm.tm_yday) { - close_log(); - remove_log(); - open_log(); - } + if (curday != tm.tm_yday) { + close_log(); + remove_log(); + open_log(); + } } /*************************************************************************/ @@ -132,33 +132,33 @@ static void checkday(void) void alog(const char *fmt, ...) { - va_list args; - time_t t; - struct tm tm; - char buf[256]; - int errno_save = errno; - - if (!smtp_debug) { - return; - } - - checkday(); - - if (!fmt) { - return; - } - - va_start(args, fmt); - time(&t); - tm = *localtime(&t); - strftime(buf, sizeof(buf) - 1, "[%b %d %H:%M:%S %Y] ", &tm); - if (logfile && args) { - fputs(buf, logfile); - vfprintf(logfile, fmt, args); - fputc('\n', logfile); - } - va_end(args); - errno = errno_save; + va_list args; + time_t t; + struct tm tm; + char buf[256]; + int errno_save = errno; + + if (!smtp_debug) { + return; + } + + checkday(); + + if (!fmt) { + return; + } + + va_start(args, fmt); + time(&t); + tm = *localtime(&t); + strftime(buf, sizeof(buf) - 1, "[%b %d %H:%M:%S %Y] ", &tm); + if (logfile && args) { + fputs(buf, logfile); + vfprintf(logfile, fmt, args); + fputc('\n', logfile); + } + va_end(args); + errno = errno_save; } /*************************************************************************/ @@ -166,12 +166,12 @@ void alog(const char *fmt, ...) /* Remove a trailing \r\n */ char *strip(char *buf) { - char *c; - if ((c = strchr(buf, '\n'))) - *c = 0; - if ((c = strchr(buf, '\r'))) - *c = 0; - return buf; + char *c; + if ((c = strchr(buf, '\n'))) + *c = 0; + if ((c = strchr(buf, '\r'))) + *c = 0; + return buf; } /*************************************************************************/ @@ -181,11 +181,11 @@ char *strip(char *buf) */ char *lftocrlf(char *buf) { - char *result = (char *)malloc(strlen(buf) + 2); - strip(buf); - strcpy(result, buf); - strcat(result, "\r\n"); - return result; + char *result = (char *)malloc(strlen(buf) + 2); + strip(buf); + strcpy(result, buf); + strcat(result, "\r\n"); + return result; } /*************************************************************************/ @@ -193,18 +193,18 @@ char *lftocrlf(char *buf) /* Add a header to the list */ void smtp_add_header(char *header) { - struct smtp_header *head = (struct smtp_header *)malloc(sizeof(struct smtp_header)); - - head->header = lftocrlf(header); - head->next = NULL; - - if (!mail.smtp_headers) { - mail.smtp_headers = head; - } - if (mail.smtp_headers_tail) { - mail.smtp_headers_tail->next = head; - } - mail.smtp_headers_tail = head; + struct smtp_header *head = (struct smtp_header *)malloc(sizeof(struct smtp_header)); + + head->header = lftocrlf(header); + head->next = NULL; + + if (!mail.smtp_headers) { + mail.smtp_headers = head; + } + if (mail.smtp_headers_tail) { + mail.smtp_headers_tail->next = head; + } + mail.smtp_headers_tail = head; } /*************************************************************************/ @@ -212,14 +212,14 @@ void smtp_add_header(char *header) /* Is the buffer a header? */ int smtp_is_header(char *buf) { - char *tmp = strchr(buf, ' '); + char *tmp = strchr(buf, ' '); - if (!tmp) - return 0; + if (!tmp) + return 0; - if (*(tmp - 1) == ':') - return 1; - return 0; + if (*(tmp - 1) == ':') + return 1; + return 0; } /*************************************************************************/ @@ -227,12 +227,12 @@ int smtp_is_header(char *buf) /* Parse a header into a name and value */ void smtp_parse_header(char *buf, char **header, char **value) { - strip(buf); + strip(buf); - *header = strtok(buf, " "); - *value = strtok(NULL, ""); - if (*header) - (*header)[strlen(*header) - 1] = 0; + *header = strtok(buf, " "); + *value = strtok(NULL, ""); + if (*header) + (*header)[strlen(*header) - 1] = 0; } /*************************************************************************/ @@ -240,11 +240,11 @@ void smtp_parse_header(char *buf, char **header, char **value) /* Have we reached the end of input? */ int smtp_is_end(char *buf) { - if (*buf == '.') - if (*(buf + 1) == '\r' || *(buf + 1) == '\n') - return 1; + if (*buf == '.') + if (*(buf + 1) == '\r' || *(buf + 1) == '\n') + return 1; - return 0; + return 0; } /*************************************************************************/ @@ -252,7 +252,7 @@ int smtp_is_end(char *buf) /* Set who the email is from */ void smtp_set_from(char *from) { - mail.from = strdup(from); + mail.from = strdup(from); } /*************************************************************************/ @@ -260,13 +260,13 @@ void smtp_set_from(char *from) /* Set who the email is to */ void smtp_set_to(char *to) { - char *c; + char *c; - if ((c = strrchr(to, '<')) && *(c + 1)) { - to = c + 1; - to[strlen(to) - 1] = 0; - } - mail.to = strdup(to); + if ((c = strrchr(to, '<')) && *(c + 1)) { + to = c + 1; + to[strlen(to) - 1] = 0; + } + mail.to = strdup(to); } /*************************************************************************/ @@ -274,18 +274,18 @@ void smtp_set_to(char *to) /* Add a line of body text */ void smtp_add_body_line(char *line) { - struct smtp_body_line *body; + struct smtp_body_line *body; - body = (struct smtp_body_line *)malloc(sizeof(struct smtp_body_line)); + body = (struct smtp_body_line *)malloc(sizeof(struct smtp_body_line)); - body->line = lftocrlf(line); - body->next = NULL; + body->line = lftocrlf(line); + body->next = NULL; - if (!mail.smtp_body) - mail.smtp_body = body; - if (mail.smtp_body_tail) - mail.smtp_body_tail->next = body; - mail.smtp_body_tail = body; + if (!mail.smtp_body) + mail.smtp_body = body; + if (mail.smtp_body_tail) + mail.smtp_body_tail->next = body; + mail.smtp_body_tail = body; } @@ -294,25 +294,25 @@ void smtp_add_body_line(char *line) /* Establish a connection to the SMTP server */ int smtp_connect(char *host, unsigned short port) { - struct sockaddr_in addr; - - if ((mail.sock = socket(AF_INET, SOCK_STREAM, 0)) == SOCKET_ERROR) - return 0; - - if ((addr.sin_addr.s_addr = inet_addr(host)) == INADDR_NONE) { - struct hostent *hent; - if (!(hent = gethostbyname(host))) - return 0; - memcpy(&addr.sin_addr, hent->h_addr, hent->h_length); - } - addr.sin_family = AF_INET; - addr.sin_port = htons(port ? port : 25); - if (connect(mail.sock, (struct sockaddr *) &addr, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { - ano_sockclose(mail.sock); - return 0; - } - - return 1; + struct sockaddr_in addr; + + if ((mail.sock = socket(AF_INET, SOCK_STREAM, 0)) == SOCKET_ERROR) + return 0; + + if ((addr.sin_addr.s_addr = inet_addr(host)) == INADDR_NONE) { + struct hostent *hent; + if (!(hent = gethostbyname(host))) + return 0; + memcpy(&addr.sin_addr, hent->h_addr, hent->h_length); + } + addr.sin_family = AF_INET; + addr.sin_port = htons(port ? port : 25); + if (connect(mail.sock, (struct sockaddr *) &addr, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { + ano_sockclose(mail.sock); + return 0; + } + + return 1; } /*************************************************************************/ @@ -320,14 +320,14 @@ int smtp_connect(char *host, unsigned short port) /* Send a line of text */ int smtp_send(char *text) { - int result = ano_sockwrite(mail.sock, text, strlen(text)); + int result = ano_sockwrite(mail.sock, text, strlen(text)); - alog("SMTP: sent %s",text); + alog("SMTP: sent %s",text); - if (result == SOCKET_ERROR) - ano_sockclose(mail.sock); + if (result == SOCKET_ERROR) + ano_sockclose(mail.sock); - return result; + return result; } /*************************************************************************/ @@ -335,15 +335,15 @@ int smtp_send(char *text) /* Read a line of text */ int smtp_read(char *buf, int len) { - int result; + int result; - memset(buf, 0, len); - result = ano_sockread(mail.sock, buf, len); + memset(buf, 0, len); + result = ano_sockread(mail.sock, buf, len); - if (result == SOCKET_ERROR) - ano_sockclose(mail.sock); + if (result == SOCKET_ERROR) + ano_sockclose(mail.sock); - return result; + return result; } /*************************************************************************/ @@ -351,12 +351,12 @@ int smtp_read(char *buf, int len) /* Retrieve a response code */ int smtp_get_code(char *text) { - char *tmp = strtok(text, " "); + char *tmp = strtok(text, " "); - if (!tmp) - return 0; + if (!tmp) + return 0; - return atol(tmp); + return atol(tmp); } /*************************************************************************/ @@ -364,130 +364,130 @@ int smtp_get_code(char *text) /* Send the email */ int smtp_send_email() { - char buf[1024]; - struct smtp_header *head; - struct smtp_body_line *body; - int code; - int skip_done = 0; - - if (!smtp_read(buf, 1024)) { - alog("SMTP: error reading buffer"); - return 0; - } - - code = smtp_get_code(buf); - if (code != 220) { - alog("SMTP: error expected code 220 got %d",code); - return 0; - } - - if (!smtp_send("HELO anope\r\n")) { - alog("SMTP: error writting to socket"); - return 0; - } - - if (!smtp_read(buf, 1024)) { + char buf[1024]; + struct smtp_header *head; + struct smtp_body_line *body; + int code; + int skip_done = 0; + + if (!smtp_read(buf, 1024)) { + alog("SMTP: error reading buffer"); + return 0; + } + + code = smtp_get_code(buf); + if (code != 220) { + alog("SMTP: error expected code 220 got %d",code); + return 0; + } + + if (!smtp_send("HELO anope\r\n")) { + alog("SMTP: error writting to socket"); + return 0; + } + + if (!smtp_read(buf, 1024)) { alog("SMTP: error reading buffer"); - return 0; - } - - code = smtp_get_code(buf); - if (code != 250) { - alog("SMTP: error expected code 250 got %d",code); - return 0; - } - - strcpy(buf, "MAIL FROM: <"); - strcat(buf, mail.from); - strcat(buf, ">\r\n"); - - if (!smtp_send(buf)) { - alog("SMTP: error writting to socket"); - return 0; - } - - if (!smtp_read(buf, 1024)) { - alog("SMTP: error reading buffer"); - return 0; - } - - code = smtp_get_code(buf); - if (code != 250) - return 0; - - strcpy(buf, "RCPT TO: <"); - strcat(buf, mail.to); - strcat(buf, ">\r\n"); - - if (!smtp_send(buf)) { - alog("SMTP: error writting to socket"); - return 0; - } - - if (!smtp_read(buf, 1024)) { - alog("SMTP: error reading buffer"); - return 0; - } - - code = smtp_get_code(buf); - if (smtp_get_code(buf) != 250) { - alog("SMTP: error expected code 250 got %d",code); - return 0; - } - - if (!smtp_send("DATA\r\n")) { - alog("SMTP: error writting to socket"); - return 0; - } - - if (!smtp_read(buf, 1024)) { - alog("SMTP: error reading buffer"); - return 0; - } - - code = smtp_get_code(buf); - if (code != 354) { - alog("SMTP: error expected code 354 got %d",code); - return 0; - } - - for (head = mail.smtp_headers; head; head = head->next) { - if (!smtp_send(head->header)) { - alog("SMTP: error writting to socket"); - return 0; - } - } - - if (!smtp_send("\r\n")) { - alog("SMTP: error writting to socket"); - return 0; - } - - for (body = mail.smtp_body; body; body = body->next) { - if (skip_done) { - if (!smtp_send(body->line)) { - alog("SMTP: error writting to socket"); - return 0; - } - } else { - skip_done = 1; - } - } - - if (!smtp_send("\r\n.\r\n")) { - alog("SMTP: error writting to socket"); - return 0; - } - - return 1; + return 0; + } + + code = smtp_get_code(buf); + if (code != 250) { + alog("SMTP: error expected code 250 got %d",code); + return 0; + } + + strcpy(buf, "MAIL FROM: <"); + strcat(buf, mail.from); + strcat(buf, ">\r\n"); + + if (!smtp_send(buf)) { + alog("SMTP: error writting to socket"); + return 0; + } + + if (!smtp_read(buf, 1024)) { + alog("SMTP: error reading buffer"); + return 0; + } + + code = smtp_get_code(buf); + if (code != 250) + return 0; + + strcpy(buf, "RCPT TO: <"); + strcat(buf, mail.to); + strcat(buf, ">\r\n"); + + if (!smtp_send(buf)) { + alog("SMTP: error writting to socket"); + return 0; + } + + if (!smtp_read(buf, 1024)) { + alog("SMTP: error reading buffer"); + return 0; + } + + code = smtp_get_code(buf); + if (smtp_get_code(buf) != 250) { + alog("SMTP: error expected code 250 got %d",code); + return 0; + } + + if (!smtp_send("DATA\r\n")) { + alog("SMTP: error writting to socket"); + return 0; + } + + if (!smtp_read(buf, 1024)) { + alog("SMTP: error reading buffer"); + return 0; + } + + code = smtp_get_code(buf); + if (code != 354) { + alog("SMTP: error expected code 354 got %d",code); + return 0; + } + + for (head = mail.smtp_headers; head; head = head->next) { + if (!smtp_send(head->header)) { + alog("SMTP: error writting to socket"); + return 0; + } + } + + if (!smtp_send("\r\n")) { + alog("SMTP: error writting to socket"); + return 0; + } + + for (body = mail.smtp_body; body; body = body->next) { + if (skip_done) { + if (!smtp_send(body->line)) { + alog("SMTP: error writting to socket"); + return 0; + } + } else { + skip_done = 1; + } + } + + if (!smtp_send("\r\n.\r\n")) { + alog("SMTP: error writting to socket"); + return 0; + } + + return 1; } /*************************************************************************/ void smtp_disconnect() { - smtp_send("QUIT\r\n"); - ano_sockclose(mail.sock); + smtp_send("QUIT\r\n"); + ano_sockclose(mail.sock); } /*************************************************************************/ @@ -523,82 +523,82 @@ void mail_cleanup() int main(int argc, char *argv[]) { - char buf[8192]; + char buf[8192]; /* These are somehow unused - why are they here? -GD - struct smtp_body_line *b; - struct smtp_header *h; + struct smtp_body_line *b; + struct smtp_header *h; */ - int headers_done = 0; + int headers_done = 0; /* Win32 stuff */ #ifdef _WIN32 - WSADATA wsa; + WSADATA wsa; #endif - char *server, *aport; - short port; + char *server, *aport; + short port; - if (argc == 1) - return 0; + if (argc == 1) + return 0; - server = strtok(argv[1], ":"); - if ((aport = strtok(NULL, ""))) { - port = atoi(aport); - } else { - port = 25; - } + server = strtok(argv[1], ":"); + if ((aport = strtok(NULL, ""))) { + port = atoi(aport); + } else { + port = 25; + } if (!server) { - alog("No Server"); + alog("No Server"); /* Bad, bad, bad. This was a eturn from main with no value! -GD */ - return 0; - } else { - alog("SMTP: server %s port %d",server,port); - } + return 0; + } else { + alog("SMTP: server %s port %d",server,port); + } - memset(&mail, 0, sizeof(mail)); + memset(&mail, 0, sizeof(mail)); /* The WSAStartup function initiates use of WS2_32.DLL by a process. */ /* guessing we can skip it under *nix */ #ifdef _WIN32 - if (WSAStartup(MAKEWORD(1, 1), &wsa) != 0) - return 0; + if (WSAStartup(MAKEWORD(1, 1), &wsa) != 0) + return 0; #endif - /* Read the message and parse it */ - while (fgets(buf, 8192, stdin)) { - if (smtp_is_header(buf) && !headers_done) { - char *header, *value; - smtp_add_header(buf); - smtp_parse_header(buf, &header, &value); - if (!strcasecmp(header, "from")) { - alog("SMTP: from: %s",value); - smtp_set_from(value); - } else if (!strcasecmp(header, "to")) { - alog("SMTP: to: %s",value); - smtp_set_to(value); - } else if (smtp_is_end(buf)) { - break; - } else { - headers_done = 1; - smtp_add_body_line(buf); - } - } else { - smtp_add_body_line(buf); - } - } - - if (!smtp_connect(server, port)) { - alog("SMTP: failed to connect to %s:%d",server, port); + /* Read the message and parse it */ + while (fgets(buf, 8192, stdin)) { + if (smtp_is_header(buf) && !headers_done) { + char *header, *value; + smtp_add_header(buf); + smtp_parse_header(buf, &header, &value); + if (!strcasecmp(header, "from")) { + alog("SMTP: from: %s",value); + smtp_set_from(value); + } else if (!strcasecmp(header, "to")) { + alog("SMTP: to: %s",value); + smtp_set_to(value); + } else if (smtp_is_end(buf)) { + break; + } else { + headers_done = 1; + smtp_add_body_line(buf); + } + } else { + smtp_add_body_line(buf); + } + } + + if (!smtp_connect(server, port)) { + alog("SMTP: failed to connect to %s:%d",server, port); mail_cleanup(); - return 0; - } - if (!smtp_send_email()) { - alog("SMTP: error during sending of mail"); + return 0; + } + if (!smtp_send_email()) { + alog("SMTP: error during sending of mail"); mail_cleanup(); - return 0; - } - smtp_disconnect(); + return 0; + } + smtp_disconnect(); mail_cleanup(); - return 1; + return 1; } diff --git a/src/tools/db-merger.c b/src/tools/db-merger.c index a80508af5..dae44d74b 100644 --- a/src/tools/db-merger.c +++ b/src/tools/db-merger.c @@ -18,7 +18,7 @@ * that includes chanserv, nickserv, botserv and memoserv databases. * * - Certus - * February 11, 2005 + * February 11, 2005 * * * 0.2 beta: @@ -26,21 +26,21 @@ * to fix your broken nick dbs. * * - Certus - * August 04, 2005 + * August 04, 2005 * * * 0.3 beta: * Fixed win32 stuff. Merging should now work fine under windows. * * - Certus - * July 20, 2006 + * July 20, 2006 * * * 0.4 beta: * Fixed some compiler warnings about signed/unsigned ints. * * - Certus - * August 8, 2006 + * August 8, 2006 */ @@ -82,20 +82,20 @@ /* CONFIGURATION BLOCK */ -#define NICK_DB_1 "nick1.db" -#define NICK_DB_2 "nick2.db" +#define NICK_DB_1 "nick1.db" +#define NICK_DB_2 "nick2.db" #define NICK_DB_NEW "nick.db" -#define CHAN_DB_1 "chan1.db" -#define CHAN_DB_2 "chan2.db" +#define CHAN_DB_1 "chan1.db" +#define CHAN_DB_2 "chan2.db" #define CHAN_DB_NEW "chan.db" -#define BOT_DB_1 "bot1.db" -#define BOT_DB_2 "bot2.db" +#define BOT_DB_1 "bot1.db" +#define BOT_DB_2 "bot2.db" #define BOT_DB_NEW "bot.db" -#define HOST_DB_1 "hosts1.db" -#define HOST_DB_2 "hosts2.db" +#define HOST_DB_1 "hosts1.db" +#define HOST_DB_2 "hosts2.db" #define HOST_DB_NEW "hosts.db" /* END OF CONFIGURATION BLOCK */ @@ -118,15 +118,15 @@ #define read_int8(ret,f) ((*(ret)=fgetc((f)->fp))==EOF ? -1 : 0) #define write_int8(val,f) (fputc((val),(f)->fp)==EOF ? -1 : 0) #define SAFE(x) do { \ - if ((x) < 0) { \ + if ((x) < 0) { \ printf("Error, the database is broken, trying to continue... no guarantee.\n"); \ - } \ + } \ } while (0) #define READ(x) do { \ - if ((x) < 0) { \ - printf("Error, the database is broken, trying to continue... no guarantee.\n"); \ - exit(0); \ - } \ + if ((x) < 0) { \ + printf("Error, the database is broken, trying to continue... no guarantee.\n"); \ + exit(0); \ + } \ } while (0) typedef int16_t int16; @@ -143,126 +143,126 @@ typedef struct badword_ BadWord; typedef struct hostcore_ HostCore; struct memo_ { - uint32 number; /* Index number -- not necessarily array position! */ - uint16 flags; /* Flags */ - time_t time; /* When was it sent? */ - char sender[32]; /* Name of the sender */ - char *text; + uint32 number; /* Index number -- not necessarily array position! */ + uint16 flags; /* Flags */ + time_t time; /* When was it sent? */ + char sender[32]; /* Name of the sender */ + char *text; }; struct dbFILE_ { - int mode; /* 'r' for reading, 'w' for writing */ - FILE *fp; /* The normal file descriptor */ - char filename[1024]; /* Name of the database file */ + int mode; /* 'r' for reading, 'w' for writing */ + FILE *fp; /* The normal file descriptor */ + char filename[1024]; /* Name of the database file */ }; typedef struct { - int16 memocount; /* Current # of memos */ - int16 memomax; /* Max # of memos one can hold*/ - Memo *memos; /* Pointer to original memos */ + int16 memocount; /* Current # of memos */ + int16 memomax; /* Max # of memos one can hold*/ + Memo *memos; /* Pointer to original memos */ } MemoInfo; typedef struct { - uint16 in_use; /* 1 if this entry is in use, else 0 */ - int16 level; - NickCore *nc; /* Guaranteed to be non-NULL if in use, NULL if not */ - time_t last_seen; + uint16 in_use; /* 1 if this entry is in use, else 0 */ + int16 level; + NickCore *nc; /* Guaranteed to be non-NULL if in use, NULL if not */ + time_t last_seen; } ChanAccess; 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 in_use; /* Always 0 if not in use */ + int16 is_nick; /* 1 if a regged nickname, 0 if a nick!user@host mask */ uint16 flags; - union { - char *mask; /* Guaranteed to be non-NULL if in use, NULL if not */ + union { + char *mask; /* Guaranteed to be non-NULL if in use, NULL if not */ NickCore *nc; /* Same */ - } u; - char *reason; - char *creator; - time_t addtime; + } u; + char *reason; + char *creator; + time_t addtime; } AutoKick; struct nickalias_ { - NickAlias *next, *prev; - char *nick; /* Nickname */ - char *last_quit; /* Last quit message */ - char *last_realname; /* Last realname */ - char *last_usermask; /* Last usermask */ - time_t time_registered; /* When the nick was registered */ - time_t last_seen; /* When it was seen online for the last time */ - uint16 status; /* See NS_* below */ - NickCore *nc; /* I'm an alias of this */ + NickAlias *next, *prev; + char *nick; /* Nickname */ + char *last_quit; /* Last quit message */ + char *last_realname; /* Last realname */ + char *last_usermask; /* Last usermask */ + time_t time_registered; /* When the nick was registered */ + time_t last_seen; /* When it was seen online for the last time */ + uint16 status; /* See NS_* below */ + NickCore *nc; /* I'm an alias of this */ }; struct nickcore_ { NickCore *next, *prev; - char *display; /* How the nick is displayed */ - char pass[32]; /* Password of the nicks */ - char *email; /* E-mail associated to the nick */ - char *greet; /* Greet associated to the nick */ - uint32 icq; /* ICQ # associated to the nick */ - char *url; /* URL associated to the nick */ - uint32 flags; /* See NI_* below */ - uint16 language; /* Language selected by nickname owner (LANG_*) */ - uint16 accesscount; /* # of entries */ - char **access; /* Array of strings */ - MemoInfo memos; /* Memo information */ - uint16 channelcount; /* Number of channels currently registered */ - int unused; /* Used for nick collisions */ - int aliascount; /* How many aliases link to us? Remove the core if 0 */ + char *display; /* How the nick is displayed */ + char pass[32]; /* Password of the nicks */ + char *email; /* E-mail associated to the nick */ + char *greet; /* Greet associated to the nick */ + uint32 icq; /* ICQ # associated to the nick */ + char *url; /* URL associated to the nick */ + uint32 flags; /* See NI_* below */ + uint16 language; /* Language selected by nickname owner (LANG_*) */ + uint16 accesscount; /* # of entries */ + char **access; /* Array of strings */ + MemoInfo memos; /* Memo information */ + uint16 channelcount; /* Number of channels currently registered */ + int unused; /* Used for nick collisions */ + int aliascount; /* How many aliases link to us? Remove the core if 0 */ }; struct chaninfo_ { - ChannelInfo *next, *prev; - - char name[64]; /* Channel name */ - char *founder; /* Who registered the channel */ - char *successor; /* Who gets the channel if the founder nick is dropped or expires */ - char founderpass[32]; /* Channel password */ - char *desc; /* Description */ - char *url; /* URL */ - char *email; /* Email address */ - time_t time_registered; /* When was it registered */ - time_t last_used; /* When was it used hte last time */ - char *last_topic; /* Last topic on the channel */ - char last_topic_setter[32]; /* Who set the last topic */ - time_t last_topic_time; /* When the last topic was set */ - uint32 flags; /* Flags */ - char *forbidby; /* if forbidden: who did it */ - char *forbidreason; /* if forbidden: why */ - int16 bantype; /* Bantype */ - int16 *levels; /* Access levels for commands */ - uint16 accesscount; /* # of pple with access */ - ChanAccess *access; /* List of authorized users */ - uint16 akickcount; /* # of akicked pple */ - AutoKick *akick; /* List of users to kickban */ - uint32 mlock_on, mlock_off; /* See channel modes below */ - uint32 mlock_limit; /* 0 if no limit */ - char *mlock_key; /* NULL if no key */ - char *mlock_flood; /* NULL if no +f */ - char *mlock_redirect; /* NULL if no +L */ - char *entry_message; /* Notice sent on entering channel */ - MemoInfo memos; /* Memos */ - char *bi; /* Bot used on this channel */ - uint32 botflags; /* BS_* below */ - int16 *ttb; /* Times to ban for each kicker */ - uint16 bwcount; /* Badword count */ - BadWord *badwords; /* For BADWORDS kicker */ - int16 capsmin, capspercent; /* For CAPS kicker */ - int16 floodlines, floodsecs; /* For FLOOD kicker */ - int16 repeattimes; /* For REPEAT kicker */ + ChannelInfo *next, *prev; + + char name[64]; /* Channel name */ + char *founder; /* Who registered the channel */ + char *successor; /* Who gets the channel if the founder nick is dropped or expires */ + char founderpass[32]; /* Channel password */ + char *desc; /* Description */ + char *url; /* URL */ + char *email; /* Email address */ + time_t time_registered; /* When was it registered */ + time_t last_used; /* When was it used hte last time */ + char *last_topic; /* Last topic on the channel */ + char last_topic_setter[32]; /* Who set the last topic */ + time_t last_topic_time; /* When the last topic was set */ + uint32 flags; /* Flags */ + char *forbidby; /* if forbidden: who did it */ + char *forbidreason; /* if forbidden: why */ + int16 bantype; /* Bantype */ + int16 *levels; /* Access levels for commands */ + uint16 accesscount; /* # of pple with access */ + ChanAccess *access; /* List of authorized users */ + uint16 akickcount; /* # of akicked pple */ + AutoKick *akick; /* List of users to kickban */ + uint32 mlock_on, mlock_off; /* See channel modes below */ + uint32 mlock_limit; /* 0 if no limit */ + char *mlock_key; /* NULL if no key */ + char *mlock_flood; /* NULL if no +f */ + char *mlock_redirect; /* NULL if no +L */ + char *entry_message; /* Notice sent on entering channel */ + MemoInfo memos; /* Memos */ + char *bi; /* Bot used on this channel */ + uint32 botflags; /* BS_* below */ + int16 *ttb; /* Times to ban for each kicker */ + uint16 bwcount; /* Badword count */ + BadWord *badwords; /* For BADWORDS kicker */ + int16 capsmin, capspercent; /* For CAPS kicker */ + int16 floodlines, floodsecs; /* For FLOOD kicker */ + int16 repeattimes; /* For REPEAT kicker */ }; struct botinfo_ { BotInfo *next, *prev; - char *nick; /* Nickname of the bot */ - char *user; /* Its user name */ - char *host; /* Its hostname */ - char *real; /* Its real name */ - int16 flags; /* Bot flags */ - time_t created; /* Birth date */ - int16 chancount; /* Number of channels that use the bot. */ + char *nick; /* Nickname of the bot */ + char *user; /* Its user name */ + char *host; /* Its hostname */ + char *real; /* Its real name */ + int16 flags; /* Bot flags */ + time_t created; /* Birth date */ + int16 chancount; /* Number of channels that use the bot. */ }; struct badword_ { @@ -272,12 +272,12 @@ struct badword_ { }; struct hostcore_ { - HostCore *next, *last; - char *nick; /* Owner of the vHost */ - char *vIdent; /* vIdent for the user */ - char *vHost; /* Vhost for this user */ - char *creator; /* Oper Nick of the oper who set the vhost */ - time_t time; /* Date/Time vHost was set */ + HostCore *next, *last; + char *nick; /* Owner of the vHost */ + char *vIdent; /* vIdent for the user */ + char *vHost; /* Vhost for this user */ + char *creator; /* Oper Nick of the oper who set the vhost */ + time_t time; /* Date/Time vHost was set */ }; dbFILE *open_db_write(const char *service, const char *filename, int version); @@ -315,1729 +315,1729 @@ int nonick = 0, nochan = 0, nobot = 0, nohost = 0; int main(int argc, char *argv[]) { - dbFILE *f; - int i; - NickCore *nc, *ncnext; - HostCore *firsthc = NULL; - - printf("\n"C_LBLUE"DB Merger v0.4 beta for Anope IRC Services by Certus"C_NONE"\n\n"); - - if (argc >= 2) { - if (!mystricmp(argv[1], "--PREFEROLDEST")) { - printf("Preferring oldest database entries on collision.\n"); - preferoldest = 1; - } else if (!mystricmp(argv[1], "--PREFERFIRST")) { - printf("Preferring first database's entries on collision .\n"); - preferfirst = 1; - } else if (!mystricmp(argv[1], "--PREFERSECOND")) { - printf("Preferring second database's entries on collision.\n"); - prefersecond = 1; - } else if (!mystricmp(argv[1], "--PREFERNEWEST")) { - printf("Preferring newest database entries on collision.\n"); - prefernewest = 1; - } - } - - /* Section I: Nicks */ - /* Ia: First database */ - if ((f = open_db_read("NickServ", NICK_DB_1, 14))) { - - NickAlias *na, **nalast, *naprev; - NickCore *nc, **nclast, *ncprev; - int16 tmp16; - int32 tmp32; - int i, j, c; - - printf("Trying to merge nicks...\n"); - - /* Nick cores */ - for (i = 0; i < 1024; i++) { - nclast = &nclists[i]; - ncprev = NULL; - - while ((c = getc_db(f)) == 1) { - if (c != 1) { - printf("Invalid format in %s.\n", NICK_DB_1); - exit(0); - } - - nc = (NickCore *)calloc(1, sizeof(NickCore)); - nc->aliascount = 0; - nc->unused = 0; - - *nclast = nc; - nclast = &nc->next; - nc->prev = ncprev; - ncprev = nc; - - READ(read_string(&nc->display, f)); - READ(read_buffer(nc->pass, f)); - READ(read_string(&nc->email, f)); - READ(read_string(&nc->greet, f)); - READ(read_uint32(&nc->icq, f)); - READ(read_string(&nc->url, f)); - READ(read_uint32(&nc->flags, f)); - READ(read_uint16(&nc->language, f)); - READ(read_uint16(&nc->accesscount, f)); - if (nc->accesscount) { - char **access; - access = (char **)calloc(sizeof(char *) * nc->accesscount, 1); - nc->access = access; - for (j = 0; j < nc->accesscount; j++, access++) - READ(read_string(access, f)); - } - READ(read_int16(&nc->memos.memocount, f)); - READ(read_int16(&nc->memos.memomax, f)); - if (nc->memos.memocount) { - Memo *memos; - memos = (Memo *)calloc(sizeof(Memo) * nc->memos.memocount, 1); - nc->memos.memos = memos; - for (j = 0; j < nc->memos.memocount; j++, memos++) { - READ(read_uint32(&memos->number, f)); - READ(read_uint16(&memos->flags, f)); - READ(read_int32(&tmp32, f)); - memos->time = tmp32; - READ(read_buffer(memos->sender, f)); - READ(read_string(&memos->text, f)); - } - } - READ(read_uint16(&nc->channelcount, f)); - READ(read_int16(&tmp16, f)); - } /* getc_db() */ - *nclast = NULL; - } /* for() loop */ - - /* Nick aliases */ - for (i = 0; i < 1024; i++) { - char *s = NULL; - - nalast = &nalists[i]; - naprev = NULL; - - while ((c = getc_db(f)) == 1) { - if (c != 1) { - printf("Invalid format in %s.\n", NICK_DB_1); - exit(0); - } - - na = (NickAlias *)calloc(1, sizeof(NickAlias)); - - READ(read_string(&na->nick, f)); - READ(read_string(&na->last_usermask, f)); - READ(read_string(&na->last_realname, f)); - READ(read_string(&na->last_quit, f)); - - READ(read_int32(&tmp32, f)); - na->time_registered = tmp32; - READ(read_int32(&tmp32, f)); - na->last_seen = tmp32; - READ(read_uint16(&na->status, f)); - READ(read_string(&s, f)); - na->nc = findcore(s, 0); - na->nc->aliascount++; - free(s); - - *nalast = na; - nalast = &na->next; - na->prev = naprev; - naprev = na; - } /* getc_db() */ - *nalast = NULL; - } /* for() loop */ - close_db(f); /* End of section Ia */ - } else - nonick = 1; - - /* Ib: Second database */ - if (!nonick) { - if ((f = open_db_read("NickServ", NICK_DB_2, 14))) { - - NickAlias *na, *naptr; - NickCore *nc; - int16 tmp16; - int32 tmp32; - int i, j, index, c; - - /* Nick cores */ - for (i = 0; i < 1024; i++) { - - while ((c = getc_db(f)) == 1) { - if (c != 1) { - printf("Invalid format in %s.\n", NICK_DB_2); - exit(0); - } - - nc = (NickCore *)calloc(1, sizeof(NickCore)); - READ(read_string(&nc->display, f)); - READ(read_buffer(nc->pass, f)); - READ(read_string(&nc->email, f)); - - naptr = findnick(nc->display); - if (naptr) - nc->unused = 1; - else - nc->unused = 0; - - nc->aliascount = 0; - - index = HASH(nc->display); - nc->prev = NULL; - nc->next = nclists[index]; - if (nc->next) - nc->next->prev = nc; - nclists[index] = nc; - - READ(read_string(&nc->greet, f)); - READ(read_uint32(&nc->icq, f)); - READ(read_string(&nc->url, f)); - READ(read_uint32(&nc->flags, f)); - READ(read_uint16(&nc->language, f)); - READ(read_uint16(&nc->accesscount, f)); - if (nc->accesscount) { - char **access; - access = (char **)calloc(sizeof(char *) * nc->accesscount, 1); - nc->access = access; - for (j = 0; j < nc->accesscount; j++, access++) - READ(read_string(access, f)); - } - READ(read_int16(&nc->memos.memocount, f)); - READ(read_int16(&nc->memos.memomax, f)); - if (nc->memos.memocount) { - Memo *memos; - memos = (Memo *)calloc(sizeof(Memo) * nc->memos.memocount, 1); - nc->memos.memos = memos; - for (j = 0; j < nc->memos.memocount; j++, memos++) { - READ(read_uint32(&memos->number, f)); - READ(read_uint16(&memos->flags, f)); - READ(read_int32(&tmp32, f)); - memos->time = tmp32; - READ(read_buffer(memos->sender, f)); - READ(read_string(&memos->text, f)); - } - } - READ(read_uint16(&nc->channelcount, f)); - READ(read_int16(&tmp16, f)); - } /* getc_db() */ - } /* for() loop */ - - /* Nick aliases */ - for (i = 0; i < 1024; i++) { - char *s = NULL; - NickAlias *ptr, *prev, *naptr; - - while ((c = getc_db(f)) == 1) { - if (c != 1) { - printf("Invalid format in %s.\n", NICK_DB_1); - exit(0); - } - - na = (NickAlias *)calloc(1, sizeof(NickAlias)); - - READ(read_string(&na->nick, f)); - READ(read_string(&na->last_usermask, f)); - READ(read_string(&na->last_realname, f)); - READ(read_string(&na->last_quit, f)); - READ(read_int32(&tmp32, f)); - na->time_registered = tmp32; - READ(read_int32(&tmp32, f)); - na->last_seen = tmp32; - READ(read_uint16(&na->status, f)); - READ(read_string(&s, f)); - - naptr = findnick(na->nick); - if (naptr) { /* COLLISION! na = collision #1 (na->nc doesn't exist yet), naptr = collision #2 (naptr->nc exists) */ - char input[1024]; - NickCore *ncptr = findcore(na->nick, 1); /* Find core for #1, ncptr MUST exist since we've read all cores, if it doesn't eixst, we have a malformed db */; - - if (!ncptr) { /* malformed */ - printf("\n\n WARNING! Malformed database. No nickcore for nick %s, droping it.\n\n\n", na->nick); - delnick(na, 1); - } else { /* not malformed */ - if (!preferoldest && !preferfirst && !prefersecond && !prefernewest) { - printf("Nick collision for nick %s:\n\n", na->nick); - printf("Group 1: %s (%s)\n", ncptr->display, ncptr->email); - printf("Time registered: %s\n", ctime(&na->time_registered)); - printf("Group 2: %s (%s)\n", naptr->nc->display, naptr->nc->email); - printf("Time registered: %s\n", ctime(&naptr->time_registered)); - printf("What group do you want to keep? Enter the related group number \"1\" or \"2\".\n"); - } - - if (preferoldest) { - input[0] = (na->time_registered > naptr->time_registered) ? '1' : '2'; - } else if (prefernewest) { - input[0] = (na->time_registered > naptr->time_registered) ? '2' : '1'; - } else if (preferfirst) { - input[0] = '2'; - } else if (prefersecond) { - input[0] = '1'; - } else { - waiting_for_input: - scanf("%s", input); - } - if (input[0] == '1') { /* get alias #2 out of the list, then free() it, then add #1 to the list */ - printf("Deleting nick alias %s (#2).\n", naptr->nick); - naptr->nc->aliascount--; /* tell the core it has one alias less */ - delnick(naptr, 0); /* removes the alias from the list and free()s it */ - na->nc = ncptr; - na->nc->aliascount++; - index = HASH(na->nick); - for (prev = NULL, ptr = nalists[index]; ptr && mystricmp(ptr->nick, na->nick) < 0; prev = ptr, ptr = ptr->next); - na->prev = prev; - na->next = ptr; - if (!prev) - nalists[index] = na; - else - prev->next = na; - if (ptr) - ptr->prev = na; - } else if (input[0] == '2') { /* free() #1 alias */ - printf("Deleting nick alias %s (#1).\n", na->nick); - delnick(na, 1); /* free()s the alias without touching the list since na isn't in the list */ - } else { - printf("Invalid number, give us a valid one (1 or 2).\n"); - goto waiting_for_input; - } - } /* not malformed */ - } else { /* No collision, add the core pointer and put the alias in the list */ - na->nc = findcore(s, 0); - if (!na->nc) { - printf("\n\n WARNING! Malformed database. No nickcore for nick %s, droping it.\n\n\n", na->nick); - delnick(na, 1); - } else { - na->nc->aliascount++; - index = HASH(na->nick); - for (prev = NULL, ptr = nalists[index]; ptr && mystricmp(ptr->nick, na->nick) < 0; prev = ptr, ptr = ptr->next); - na->prev = prev; - na->next = ptr; - if (!prev) - nalists[index] = na; - else - prev->next = na; - if (ptr) - ptr->prev = na; - } - } - free(s); - } /* getc_db() */ - } /* for() loop */ - close_db(f); /* End of section Ib */ - } else - nonick = 1; - } - - /* CLEAN THE CORES */ - - for (i = 0; i < 1024; i++) { - for (nc = nclists[i]; nc; nc = ncnext) { - ncnext = nc->next; - if (nc->aliascount < 1) { - printf("Deleting core %s (%s).\n", nc->display, nc->email); - delcore(nc); - } - } - } - - /* Ic: Saving */ - if (!nonick) { - if ((f = open_db_write("NickServ", NICK_DB_NEW, 14))) { - - NickAlias *na; - NickCore *nc; - char **access; - Memo *memos; - int i, j; - - /* Nick cores */ - for (i = 0; i < 1024; i++) { - for (nc = nclists[i]; nc; nc = nc->next) { - SAFE(write_int8(1, f)); - SAFE(write_string(nc->display, f)); - SAFE(write_buffer(nc->pass, f)); - SAFE(write_string(nc->email, f)); - SAFE(write_string(nc->greet, f)); - SAFE(write_int32(nc->icq, f)); - SAFE(write_string(nc->url, f)); - SAFE(write_int32(nc->flags, f)); - SAFE(write_int16(nc->language, f)); - SAFE(write_int16(nc->accesscount, f)); - for (j = 0, access = nc->access; j < nc->accesscount; j++, access++) - SAFE(write_string(*access, f)); - - SAFE(write_int16(nc->memos.memocount, f)); - SAFE(write_int16(nc->memos.memomax, f)); - memos = nc->memos.memos; - for (j = 0; j < nc->memos.memocount; j++, memos++) { - SAFE(write_int32(memos->number, f)); - SAFE(write_int16(memos->flags, f)); - SAFE(write_int32(memos->time, f)); - SAFE(write_buffer(memos->sender, f)); - SAFE(write_string(memos->text, f)); - } - SAFE(write_int16(nc->channelcount, f)); - SAFE(write_int16(nc->channelcount, f)); // BK with anope1.7, hack alert XXX - } /* for (nc) */ - SAFE(write_int8(0, f)); - } /* for (i) */ - - /* Nick aliases */ - for (i = 0; i < 1024; i++) { - for (na = nalists[i]; na; na = na->next) { - SAFE(write_int8(1, f)); - SAFE(write_string(na->nick, f)); - SAFE(write_string(na->last_usermask, f)); - SAFE(write_string(na->last_realname, f)); - SAFE(write_string(na->last_quit, f)); - SAFE(write_int32(na->time_registered, f)); - SAFE(write_int32(na->last_seen, f)); - SAFE(write_int16(na->status, f)); - SAFE(write_string(na->nc->display, f)); - - } /* for (na) */ - SAFE(write_int8(0, f)); - } /* for (i) */ - close_db(f); /* End of section Ic */ - printf("Nick merging done. New database saved as %s.\n", NICK_DB_NEW); - } - } /* End of section I */ - - /* Section II: Chans */ - /* IIa: First database */ - if ((f = open_db_read("ChanServ", CHAN_DB_1, 16))) { - ChannelInfo *ci, **last, *prev; - int c; - - printf("Trying to merge channels...\n"); - - for (i = 0; i < 256; i++) { - int16 tmp16; - int32 tmp32; - int n_levels; - char *s; - int n_ttb; + dbFILE *f; + int i; + NickCore *nc, *ncnext; + HostCore *firsthc = NULL; + + printf("\n"C_LBLUE"DB Merger v0.4 beta for Anope IRC Services by Certus"C_NONE"\n\n"); + + if (argc >= 2) { + if (!mystricmp(argv[1], "--PREFEROLDEST")) { + printf("Preferring oldest database entries on collision.\n"); + preferoldest = 1; + } else if (!mystricmp(argv[1], "--PREFERFIRST")) { + printf("Preferring first database's entries on collision .\n"); + preferfirst = 1; + } else if (!mystricmp(argv[1], "--PREFERSECOND")) { + printf("Preferring second database's entries on collision.\n"); + prefersecond = 1; + } else if (!mystricmp(argv[1], "--PREFERNEWEST")) { + printf("Preferring newest database entries on collision.\n"); + prefernewest = 1; + } + } + + /* Section I: Nicks */ + /* Ia: First database */ + if ((f = open_db_read("NickServ", NICK_DB_1, 14))) { + + NickAlias *na, **nalast, *naprev; + NickCore *nc, **nclast, *ncprev; + int16 tmp16; + int32 tmp32; + int i, j, c; + + printf("Trying to merge nicks...\n"); + + /* Nick cores */ + for (i = 0; i < 1024; i++) { + nclast = &nclists[i]; + ncprev = NULL; + + while ((c = getc_db(f)) == 1) { + if (c != 1) { + printf("Invalid format in %s.\n", NICK_DB_1); + exit(0); + } + + nc = (NickCore *)calloc(1, sizeof(NickCore)); + nc->aliascount = 0; + nc->unused = 0; + + *nclast = nc; + nclast = &nc->next; + nc->prev = ncprev; + ncprev = nc; + + READ(read_string(&nc->display, f)); + READ(read_buffer(nc->pass, f)); + READ(read_string(&nc->email, f)); + READ(read_string(&nc->greet, f)); + READ(read_uint32(&nc->icq, f)); + READ(read_string(&nc->url, f)); + READ(read_uint32(&nc->flags, f)); + READ(read_uint16(&nc->language, f)); + READ(read_uint16(&nc->accesscount, f)); + if (nc->accesscount) { + char **access; + access = (char **)calloc(sizeof(char *) * nc->accesscount, 1); + nc->access = access; + for (j = 0; j < nc->accesscount; j++, access++) + READ(read_string(access, f)); + } + READ(read_int16(&nc->memos.memocount, f)); + READ(read_int16(&nc->memos.memomax, f)); + if (nc->memos.memocount) { + Memo *memos; + memos = (Memo *)calloc(sizeof(Memo) * nc->memos.memocount, 1); + nc->memos.memos = memos; + for (j = 0; j < nc->memos.memocount; j++, memos++) { + READ(read_uint32(&memos->number, f)); + READ(read_uint16(&memos->flags, f)); + READ(read_int32(&tmp32, f)); + memos->time = tmp32; + READ(read_buffer(memos->sender, f)); + READ(read_string(&memos->text, f)); + } + } + READ(read_uint16(&nc->channelcount, f)); + READ(read_int16(&tmp16, f)); + } /* getc_db() */ + *nclast = NULL; + } /* for() loop */ + + /* Nick aliases */ + for (i = 0; i < 1024; i++) { + char *s = NULL; + + nalast = &nalists[i]; + naprev = NULL; + + while ((c = getc_db(f)) == 1) { + if (c != 1) { + printf("Invalid format in %s.\n", NICK_DB_1); + exit(0); + } + + na = (NickAlias *)calloc(1, sizeof(NickAlias)); + + READ(read_string(&na->nick, f)); + READ(read_string(&na->last_usermask, f)); + READ(read_string(&na->last_realname, f)); + READ(read_string(&na->last_quit, f)); + + READ(read_int32(&tmp32, f)); + na->time_registered = tmp32; + READ(read_int32(&tmp32, f)); + na->last_seen = tmp32; + READ(read_uint16(&na->status, f)); + READ(read_string(&s, f)); + na->nc = findcore(s, 0); + na->nc->aliascount++; + free(s); + + *nalast = na; + nalast = &na->next; + na->prev = naprev; + naprev = na; + } /* getc_db() */ + *nalast = NULL; + } /* for() loop */ + close_db(f); /* End of section Ia */ + } else + nonick = 1; + + /* Ib: Second database */ + if (!nonick) { + if ((f = open_db_read("NickServ", NICK_DB_2, 14))) { + + NickAlias *na, *naptr; + NickCore *nc; + int16 tmp16; + int32 tmp32; + int i, j, index, c; + + /* Nick cores */ + for (i = 0; i < 1024; i++) { + + while ((c = getc_db(f)) == 1) { + if (c != 1) { + printf("Invalid format in %s.\n", NICK_DB_2); + exit(0); + } + + nc = (NickCore *)calloc(1, sizeof(NickCore)); + READ(read_string(&nc->display, f)); + READ(read_buffer(nc->pass, f)); + READ(read_string(&nc->email, f)); + + naptr = findnick(nc->display); + if (naptr) + nc->unused = 1; + else + nc->unused = 0; + + nc->aliascount = 0; + + index = HASH(nc->display); + nc->prev = NULL; + nc->next = nclists[index]; + if (nc->next) + nc->next->prev = nc; + nclists[index] = nc; + + READ(read_string(&nc->greet, f)); + READ(read_uint32(&nc->icq, f)); + READ(read_string(&nc->url, f)); + READ(read_uint32(&nc->flags, f)); + READ(read_uint16(&nc->language, f)); + READ(read_uint16(&nc->accesscount, f)); + if (nc->accesscount) { + char **access; + access = (char **)calloc(sizeof(char *) * nc->accesscount, 1); + nc->access = access; + for (j = 0; j < nc->accesscount; j++, access++) + READ(read_string(access, f)); + } + READ(read_int16(&nc->memos.memocount, f)); + READ(read_int16(&nc->memos.memomax, f)); + if (nc->memos.memocount) { + Memo *memos; + memos = (Memo *)calloc(sizeof(Memo) * nc->memos.memocount, 1); + nc->memos.memos = memos; + for (j = 0; j < nc->memos.memocount; j++, memos++) { + READ(read_uint32(&memos->number, f)); + READ(read_uint16(&memos->flags, f)); + READ(read_int32(&tmp32, f)); + memos->time = tmp32; + READ(read_buffer(memos->sender, f)); + READ(read_string(&memos->text, f)); + } + } + READ(read_uint16(&nc->channelcount, f)); + READ(read_int16(&tmp16, f)); + } /* getc_db() */ + } /* for() loop */ + + /* Nick aliases */ + for (i = 0; i < 1024; i++) { + char *s = NULL; + NickAlias *ptr, *prev, *naptr; + + while ((c = getc_db(f)) == 1) { + if (c != 1) { + printf("Invalid format in %s.\n", NICK_DB_1); + exit(0); + } + + na = (NickAlias *)calloc(1, sizeof(NickAlias)); + + READ(read_string(&na->nick, f)); + READ(read_string(&na->last_usermask, f)); + READ(read_string(&na->last_realname, f)); + READ(read_string(&na->last_quit, f)); + READ(read_int32(&tmp32, f)); + na->time_registered = tmp32; + READ(read_int32(&tmp32, f)); + na->last_seen = tmp32; + READ(read_uint16(&na->status, f)); + READ(read_string(&s, f)); + + naptr = findnick(na->nick); + if (naptr) { /* COLLISION! na = collision #1 (na->nc doesn't exist yet), naptr = collision #2 (naptr->nc exists) */ + char input[1024]; + NickCore *ncptr = findcore(na->nick, 1); /* Find core for #1, ncptr MUST exist since we've read all cores, if it doesn't eixst, we have a malformed db */; + + if (!ncptr) { /* malformed */ + printf("\n\n WARNING! Malformed database. No nickcore for nick %s, droping it.\n\n\n", na->nick); + delnick(na, 1); + } else { /* not malformed */ + if (!preferoldest && !preferfirst && !prefersecond && !prefernewest) { + printf("Nick collision for nick %s:\n\n", na->nick); + printf("Group 1: %s (%s)\n", ncptr->display, ncptr->email); + printf("Time registered: %s\n", ctime(&na->time_registered)); + printf("Group 2: %s (%s)\n", naptr->nc->display, naptr->nc->email); + printf("Time registered: %s\n", ctime(&naptr->time_registered)); + printf("What group do you want to keep? Enter the related group number \"1\" or \"2\".\n"); + } + + if (preferoldest) { + input[0] = (na->time_registered > naptr->time_registered) ? '1' : '2'; + } else if (prefernewest) { + input[0] = (na->time_registered > naptr->time_registered) ? '2' : '1'; + } else if (preferfirst) { + input[0] = '2'; + } else if (prefersecond) { + input[0] = '1'; + } else { + waiting_for_input: + scanf("%s", input); + } + if (input[0] == '1') { /* get alias #2 out of the list, then free() it, then add #1 to the list */ + printf("Deleting nick alias %s (#2).\n", naptr->nick); + naptr->nc->aliascount--; /* tell the core it has one alias less */ + delnick(naptr, 0); /* removes the alias from the list and free()s it */ + na->nc = ncptr; + na->nc->aliascount++; + index = HASH(na->nick); + for (prev = NULL, ptr = nalists[index]; ptr && mystricmp(ptr->nick, na->nick) < 0; prev = ptr, ptr = ptr->next); + na->prev = prev; + na->next = ptr; + if (!prev) + nalists[index] = na; + else + prev->next = na; + if (ptr) + ptr->prev = na; + } else if (input[0] == '2') { /* free() #1 alias */ + printf("Deleting nick alias %s (#1).\n", na->nick); + delnick(na, 1); /* free()s the alias without touching the list since na isn't in the list */ + } else { + printf("Invalid number, give us a valid one (1 or 2).\n"); + goto waiting_for_input; + } + } /* not malformed */ + } else { /* No collision, add the core pointer and put the alias in the list */ + na->nc = findcore(s, 0); + if (!na->nc) { + printf("\n\n WARNING! Malformed database. No nickcore for nick %s, droping it.\n\n\n", na->nick); + delnick(na, 1); + } else { + na->nc->aliascount++; + index = HASH(na->nick); + for (prev = NULL, ptr = nalists[index]; ptr && mystricmp(ptr->nick, na->nick) < 0; prev = ptr, ptr = ptr->next); + na->prev = prev; + na->next = ptr; + if (!prev) + nalists[index] = na; + else + prev->next = na; + if (ptr) + ptr->prev = na; + } + } + free(s); + } /* getc_db() */ + } /* for() loop */ + close_db(f); /* End of section Ib */ + } else + nonick = 1; + } + + /* CLEAN THE CORES */ + + for (i = 0; i < 1024; i++) { + for (nc = nclists[i]; nc; nc = ncnext) { + ncnext = nc->next; + if (nc->aliascount < 1) { + printf("Deleting core %s (%s).\n", nc->display, nc->email); + delcore(nc); + } + } + } + + /* Ic: Saving */ + if (!nonick) { + if ((f = open_db_write("NickServ", NICK_DB_NEW, 14))) { + + NickAlias *na; + NickCore *nc; + char **access; + Memo *memos; + int i, j; + + /* Nick cores */ + for (i = 0; i < 1024; i++) { + for (nc = nclists[i]; nc; nc = nc->next) { + SAFE(write_int8(1, f)); + SAFE(write_string(nc->display, f)); + SAFE(write_buffer(nc->pass, f)); + SAFE(write_string(nc->email, f)); + SAFE(write_string(nc->greet, f)); + SAFE(write_int32(nc->icq, f)); + SAFE(write_string(nc->url, f)); + SAFE(write_int32(nc->flags, f)); + SAFE(write_int16(nc->language, f)); + SAFE(write_int16(nc->accesscount, f)); + for (j = 0, access = nc->access; j < nc->accesscount; j++, access++) + SAFE(write_string(*access, f)); + + SAFE(write_int16(nc->memos.memocount, f)); + SAFE(write_int16(nc->memos.memomax, f)); + memos = nc->memos.memos; + for (j = 0; j < nc->memos.memocount; j++, memos++) { + SAFE(write_int32(memos->number, f)); + SAFE(write_int16(memos->flags, f)); + SAFE(write_int32(memos->time, f)); + SAFE(write_buffer(memos->sender, f)); + SAFE(write_string(memos->text, f)); + } + SAFE(write_int16(nc->channelcount, f)); + SAFE(write_int16(nc->channelcount, f)); // BK with anope1.7, hack alert XXX + } /* for (nc) */ + SAFE(write_int8(0, f)); + } /* for (i) */ + + /* Nick aliases */ + for (i = 0; i < 1024; i++) { + for (na = nalists[i]; na; na = na->next) { + SAFE(write_int8(1, f)); + SAFE(write_string(na->nick, f)); + SAFE(write_string(na->last_usermask, f)); + SAFE(write_string(na->last_realname, f)); + SAFE(write_string(na->last_quit, f)); + SAFE(write_int32(na->time_registered, f)); + SAFE(write_int32(na->last_seen, f)); + SAFE(write_int16(na->status, f)); + SAFE(write_string(na->nc->display, f)); + + } /* for (na) */ + SAFE(write_int8(0, f)); + } /* for (i) */ + close_db(f); /* End of section Ic */ + printf("Nick merging done. New database saved as %s.\n", NICK_DB_NEW); + } + } /* End of section I */ + + /* Section II: Chans */ + /* IIa: First database */ + if ((f = open_db_read("ChanServ", CHAN_DB_1, 16))) { + ChannelInfo *ci, **last, *prev; + int c; + + printf("Trying to merge channels...\n"); + + for (i = 0; i < 256; i++) { + int16 tmp16; + int32 tmp32; + int n_levels; + char *s; + int n_ttb; /* Unused variable - why? -GD - int J; + int J; */ - last = &chanlists[i]; - prev = NULL; - - while ((c = getc_db(f)) == 1) { - int j; - - if (c != 1) { - printf("Invalid format in %s.\n", CHAN_DB_1); - exit(0); - } - - ci = (ChannelInfo *)calloc(sizeof(ChannelInfo), 1); - *last = ci; - last = &ci->next; - ci->prev = prev; - prev = ci; - READ(read_buffer(ci->name, f)); - READ(read_string(&ci->founder, f)); - READ(read_string(&ci->successor, f)); - READ(read_buffer(ci->founderpass, f)); - READ(read_string(&ci->desc, f)); - if (!ci->desc) - ci->desc = strdup(""); - READ(read_string(&ci->url, f)); - READ(read_string(&ci->email, f)); - READ(read_int32(&tmp32, f)); - ci->time_registered = tmp32; - READ(read_int32(&tmp32, f)); - ci->last_used = tmp32; - READ(read_string(&ci->last_topic, f)); - READ(read_buffer(ci->last_topic_setter, f)); - READ(read_int32(&tmp32, f)); - ci->last_topic_time = tmp32; - READ(read_uint32(&ci->flags, f)); - /* Temporary flags cleanup */ - ci->flags &= ~0x80000000; - READ(read_string(&ci->forbidby, f)); - READ(read_string(&ci->forbidreason, f)); - READ(read_int16(&tmp16, f)); - ci->bantype = tmp16; - READ(read_int16(&tmp16, f)); - n_levels = tmp16; - ci->levels = (int16 *)calloc(36 * sizeof(*ci->levels), 1); - for (j = 0; j < n_levels; j++) { - if (j < 36) - READ(read_int16(&ci->levels[j], f)); - else - READ(read_int16(&tmp16, f)); - } - READ(read_uint16(&ci->accesscount, f)); - if (ci->accesscount) { - ci->access = (ChanAccess *)calloc(ci->accesscount, sizeof(ChanAccess)); - for (j = 0; j < ci->accesscount; j++) { - READ(read_uint16(&ci->access[j].in_use, f)); - if (ci->access[j].in_use) { - READ(read_int16(&ci->access[j].level, f)); - READ(read_string(&s, f)); - if (s) { - ci->access[j].nc = findcore(s, 0); - free(s); - } - if (ci->access[j].nc == NULL) - ci->access[j].in_use = 0; - READ(read_int32(&tmp32, f)); - ci->access[j].last_seen = tmp32; - } - } - } else { - ci->access = NULL; - } - READ(read_uint16(&ci->akickcount, f)); - if (ci->akickcount) { - ci->akick = (AutoKick *)calloc(ci->akickcount, sizeof(AutoKick)); - for (j = 0; j < ci->akickcount; j++) { - SAFE(read_uint16(&ci->akick[j].flags, f)); - if (ci->akick[j].flags & 0x0001) { - SAFE(read_string(&s, f)); - if (ci->akick[j].flags & 0x0002) { - ci->akick[j].u.nc = findcore(s, 0); - if (!ci->akick[j].u.nc) - ci->akick[j].flags &= ~0x0001; - free(s); - } else { - ci->akick[j].u.mask = s; - } - SAFE(read_string(&s, f)); - if (ci->akick[j].flags & 0x0001) - ci->akick[j].reason = s; - else if (s) - free(s); - SAFE(read_string(&s, f)); - if (ci->akick[j].flags & 0x0001) { - ci->akick[j].creator = s; - } else if (s) { - free(s); - } - SAFE(read_int32(&tmp32, f)); - if (ci->akick[j].flags & 0x0001) - ci->akick[j].addtime = tmp32; - } - } - } else { - ci->akick = NULL; - } - READ(read_uint32(&ci->mlock_on, f)); - READ(read_uint32(&ci->mlock_off, f)); - READ(read_uint32(&ci->mlock_limit, f)); - READ(read_string(&ci->mlock_key, f)); - READ(read_string(&ci->mlock_flood, f)); - READ(read_string(&ci->mlock_redirect, f)); - READ(read_int16(&ci->memos.memocount, f)); - READ(read_int16(&ci->memos.memomax, f)); - if (ci->memos.memocount) { - Memo *memos; - memos = (Memo *)calloc(sizeof(Memo) * ci->memos.memocount, 1); - ci->memos.memos = memos; - for (j = 0; j < ci->memos.memocount; j++, memos++) { - READ(read_uint32(&memos->number, f)); - READ(read_uint16(&memos->flags, f)); - READ(read_int32(&tmp32, f)); - memos->time = tmp32; - READ(read_buffer(memos->sender, f)); - READ(read_string(&memos->text, f)); - } - } - READ(read_string(&ci->entry_message, f)); - - /* BotServ options */ - READ(read_string(&ci->bi, f)); - READ(read_int32(&tmp32, f)); - ci->botflags = tmp32; - READ(read_int16(&tmp16, f)); - n_ttb = tmp16; - ci->ttb = (int16 *)calloc(2 * 8, 1); - for (j = 0; j < n_ttb; j++) { - if (j < 8) - READ(read_int16(&ci->ttb[j], f)); - else - READ(read_int16(&tmp16, f)); - } - for (j = n_ttb; j < 8; j++) - ci->ttb[j] = 0; - READ(read_int16(&tmp16, f)); - ci->capsmin = tmp16; - READ(read_int16(&tmp16, f)); - ci->capspercent = tmp16; - READ(read_int16(&tmp16, f)); - ci->floodlines = tmp16; - READ(read_int16(&tmp16, f)); - ci->floodsecs = tmp16; - READ(read_int16(&tmp16, f)); - ci->repeattimes = tmp16; - - READ(read_uint16(&ci->bwcount, f)); - if (ci->bwcount) { - ci->badwords = (BadWord *)calloc(ci->bwcount, sizeof(BadWord)); - for (j = 0; j < ci->bwcount; j++) { - SAFE(read_uint16(&ci->badwords[j].in_use, f)); - if (ci->badwords[j].in_use) { - SAFE(read_string(&ci->badwords[j].word, f)); - SAFE(read_uint16(&ci->badwords[j].type, f)); - } - } - } else { - ci->badwords = NULL; - } - } /* getc_db() */ - *last = NULL; - } /* for() loop */ - close_db(f); - } else - nochan = 1; - - /* IIb: Second database */ - if (!nochan) { - if ((f = open_db_read("ChanServ", CHAN_DB_2, 16))) { - int c; - - for (i = 0; i < 256; i++) { - int16 tmp16; - int32 tmp32; - int n_levels; - char *s; - int n_ttb; + last = &chanlists[i]; + prev = NULL; + + while ((c = getc_db(f)) == 1) { + int j; + + if (c != 1) { + printf("Invalid format in %s.\n", CHAN_DB_1); + exit(0); + } + + ci = (ChannelInfo *)calloc(sizeof(ChannelInfo), 1); + *last = ci; + last = &ci->next; + ci->prev = prev; + prev = ci; + READ(read_buffer(ci->name, f)); + READ(read_string(&ci->founder, f)); + READ(read_string(&ci->successor, f)); + READ(read_buffer(ci->founderpass, f)); + READ(read_string(&ci->desc, f)); + if (!ci->desc) + ci->desc = strdup(""); + READ(read_string(&ci->url, f)); + READ(read_string(&ci->email, f)); + READ(read_int32(&tmp32, f)); + ci->time_registered = tmp32; + READ(read_int32(&tmp32, f)); + ci->last_used = tmp32; + READ(read_string(&ci->last_topic, f)); + READ(read_buffer(ci->last_topic_setter, f)); + READ(read_int32(&tmp32, f)); + ci->last_topic_time = tmp32; + READ(read_uint32(&ci->flags, f)); + /* Temporary flags cleanup */ + ci->flags &= ~0x80000000; + READ(read_string(&ci->forbidby, f)); + READ(read_string(&ci->forbidreason, f)); + READ(read_int16(&tmp16, f)); + ci->bantype = tmp16; + READ(read_int16(&tmp16, f)); + n_levels = tmp16; + ci->levels = (int16 *)calloc(36 * sizeof(*ci->levels), 1); + for (j = 0; j < n_levels; j++) { + if (j < 36) + READ(read_int16(&ci->levels[j], f)); + else + READ(read_int16(&tmp16, f)); + } + READ(read_uint16(&ci->accesscount, f)); + if (ci->accesscount) { + ci->access = (ChanAccess *)calloc(ci->accesscount, sizeof(ChanAccess)); + for (j = 0; j < ci->accesscount; j++) { + READ(read_uint16(&ci->access[j].in_use, f)); + if (ci->access[j].in_use) { + READ(read_int16(&ci->access[j].level, f)); + READ(read_string(&s, f)); + if (s) { + ci->access[j].nc = findcore(s, 0); + free(s); + } + if (ci->access[j].nc == NULL) + ci->access[j].in_use = 0; + READ(read_int32(&tmp32, f)); + ci->access[j].last_seen = tmp32; + } + } + } else { + ci->access = NULL; + } + READ(read_uint16(&ci->akickcount, f)); + if (ci->akickcount) { + ci->akick = (AutoKick *)calloc(ci->akickcount, sizeof(AutoKick)); + for (j = 0; j < ci->akickcount; j++) { + SAFE(read_uint16(&ci->akick[j].flags, f)); + if (ci->akick[j].flags & 0x0001) { + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & 0x0002) { + ci->akick[j].u.nc = findcore(s, 0); + if (!ci->akick[j].u.nc) + ci->akick[j].flags &= ~0x0001; + free(s); + } else { + ci->akick[j].u.mask = s; + } + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & 0x0001) + ci->akick[j].reason = s; + else if (s) + free(s); + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & 0x0001) { + ci->akick[j].creator = s; + } else if (s) { + free(s); + } + SAFE(read_int32(&tmp32, f)); + if (ci->akick[j].flags & 0x0001) + ci->akick[j].addtime = tmp32; + } + } + } else { + ci->akick = NULL; + } + READ(read_uint32(&ci->mlock_on, f)); + READ(read_uint32(&ci->mlock_off, f)); + READ(read_uint32(&ci->mlock_limit, f)); + READ(read_string(&ci->mlock_key, f)); + READ(read_string(&ci->mlock_flood, f)); + READ(read_string(&ci->mlock_redirect, f)); + READ(read_int16(&ci->memos.memocount, f)); + READ(read_int16(&ci->memos.memomax, f)); + if (ci->memos.memocount) { + Memo *memos; + memos = (Memo *)calloc(sizeof(Memo) * ci->memos.memocount, 1); + ci->memos.memos = memos; + for (j = 0; j < ci->memos.memocount; j++, memos++) { + READ(read_uint32(&memos->number, f)); + READ(read_uint16(&memos->flags, f)); + READ(read_int32(&tmp32, f)); + memos->time = tmp32; + READ(read_buffer(memos->sender, f)); + READ(read_string(&memos->text, f)); + } + } + READ(read_string(&ci->entry_message, f)); + + /* BotServ options */ + READ(read_string(&ci->bi, f)); + READ(read_int32(&tmp32, f)); + ci->botflags = tmp32; + READ(read_int16(&tmp16, f)); + n_ttb = tmp16; + ci->ttb = (int16 *)calloc(2 * 8, 1); + for (j = 0; j < n_ttb; j++) { + if (j < 8) + READ(read_int16(&ci->ttb[j], f)); + else + READ(read_int16(&tmp16, f)); + } + for (j = n_ttb; j < 8; j++) + ci->ttb[j] = 0; + READ(read_int16(&tmp16, f)); + ci->capsmin = tmp16; + READ(read_int16(&tmp16, f)); + ci->capspercent = tmp16; + READ(read_int16(&tmp16, f)); + ci->floodlines = tmp16; + READ(read_int16(&tmp16, f)); + ci->floodsecs = tmp16; + READ(read_int16(&tmp16, f)); + ci->repeattimes = tmp16; + + READ(read_uint16(&ci->bwcount, f)); + if (ci->bwcount) { + ci->badwords = (BadWord *)calloc(ci->bwcount, sizeof(BadWord)); + for (j = 0; j < ci->bwcount; j++) { + SAFE(read_uint16(&ci->badwords[j].in_use, f)); + if (ci->badwords[j].in_use) { + SAFE(read_string(&ci->badwords[j].word, f)); + SAFE(read_uint16(&ci->badwords[j].type, f)); + } + } + } else { + ci->badwords = NULL; + } + } /* getc_db() */ + *last = NULL; + } /* for() loop */ + close_db(f); + } else + nochan = 1; + + /* IIb: Second database */ + if (!nochan) { + if ((f = open_db_read("ChanServ", CHAN_DB_2, 16))) { + int c; + + for (i = 0; i < 256; i++) { + int16 tmp16; + int32 tmp32; + int n_levels; + char *s; + int n_ttb; /* Unused variables - why? -GD - char input[1024]; - NickAlias *na; - int J; + char input[1024]; + NickAlias *na; + int J; */ - while ((c = getc_db(f)) == 1) { - ChannelInfo *ci = NULL, *ciptr = NULL; - int j; - - if (c != 1) { - printf("Invalid format in %s.\n", CHAN_DB_2); - exit(0); - } - - ci = (ChannelInfo *)calloc(sizeof(ChannelInfo), 1); - READ(read_buffer(ci->name, f)); - READ(read_string(&ci->founder, f)); - READ(read_string(&ci->successor, f)); - READ(read_buffer(ci->founderpass, f)); - READ(read_string(&ci->desc, f)); - if (!ci->desc) - ci->desc = strdup(""); - READ(read_string(&ci->url, f)); - READ(read_string(&ci->email, f)); - READ(read_int32(&tmp32, f)); - ci->time_registered = tmp32; - READ(read_int32(&tmp32, f)); - ci->last_used = tmp32; - READ(read_string(&ci->last_topic, f)); - READ(read_buffer(ci->last_topic_setter, f)); - READ(read_int32(&tmp32, f)); - ci->last_topic_time = tmp32; - READ(read_uint32(&ci->flags, f)); - /* Temporary flags cleanup */ - ci->flags &= ~0x80000000; - READ(read_string(&ci->forbidby, f)); - READ(read_string(&ci->forbidreason, f)); - READ(read_int16(&tmp16, f)); - ci->bantype = tmp16; - READ(read_int16(&tmp16, f)); - n_levels = tmp16; - ci->levels = (int16 *)calloc(36 * sizeof(*ci->levels), 1); - for (j = 0; j < n_levels; j++) { - if (j < 36) - READ(read_int16(&ci->levels[j], f)); - else - READ(read_int16(&tmp16, f)); - } - READ(read_uint16(&ci->accesscount, f)); - if (ci->accesscount) { - ci->access = (ChanAccess *)calloc(ci->accesscount, sizeof(ChanAccess)); - for (j = 0; j < ci->accesscount; j++) { - READ(read_uint16(&ci->access[j].in_use, f)); - if (ci->access[j].in_use) { - READ(read_int16(&ci->access[j].level, f)); - READ(read_string(&s, f)); - if (s) { - ci->access[j].nc = findcore(s, 0); - free(s); - } - if (ci->access[j].nc == NULL) - ci->access[j].in_use = 0; - READ(read_int32(&tmp32, f)); - ci->access[j].last_seen = tmp32; - } - } - } else { - ci->access = NULL; - } - READ(read_uint16(&ci->akickcount, f)); - if (ci->akickcount) { - ci->akick = (AutoKick *)calloc(ci->akickcount, sizeof(AutoKick)); - for (j = 0; j < ci->akickcount; j++) { - SAFE(read_uint16(&ci->akick[j].flags, f)); - if (ci->akick[j].flags & 0x0001) { - SAFE(read_string(&s, f)); - if (ci->akick[j].flags & 0x0002) { - ci->akick[j].u.nc = findcore(s, 0); - if (!ci->akick[j].u.nc) - ci->akick[j].flags &= ~0x0001; - free(s); - } else { - ci->akick[j].u.mask = s; - } - SAFE(read_string(&s, f)); - if (ci->akick[j].flags & 0x0001) - ci->akick[j].reason = s; - else if (s) - free(s); - SAFE(read_string(&s, f)); - if (ci->akick[j].flags & 0x0001) { - ci->akick[j].creator = s; - } else if (s) { - free(s); - } - SAFE(read_int32(&tmp32, f)); - if (ci->akick[j].flags & 0x0001) - ci->akick[j].addtime = tmp32; - } - } - } else { - ci->akick = NULL; - } - READ(read_uint32(&ci->mlock_on, f)); - READ(read_uint32(&ci->mlock_off, f)); - READ(read_uint32(&ci->mlock_limit, f)); - READ(read_string(&ci->mlock_key, f)); - READ(read_string(&ci->mlock_flood, f)); - READ(read_string(&ci->mlock_redirect, f)); - READ(read_int16(&ci->memos.memocount, f)); - READ(read_int16(&ci->memos.memomax, f)); - if (ci->memos.memocount) { - Memo *memos; - memos = (Memo *)calloc(sizeof(Memo) * ci->memos.memocount, 1); - ci->memos.memos = memos; - for (j = 0; j < ci->memos.memocount; j++, memos++) { - READ(read_uint32(&memos->number, f)); - READ(read_uint16(&memos->flags, f)); - READ(read_int32(&tmp32, f)); - memos->time = tmp32; - READ(read_buffer(memos->sender, f)); - READ(read_string(&memos->text, f)); - } - } - READ(read_string(&ci->entry_message, f)); - - /* BotServ options */ - READ(read_string(&ci->bi, f)); - READ(read_int32(&tmp32, f)); - ci->botflags = tmp32; - READ(read_int16(&tmp16, f)); - n_ttb = tmp16; - ci->ttb = (int16 *)calloc(32, 1); - for (j = 0; j < n_ttb; j++) { - if (j < 8) - READ(read_int16(&ci->ttb[j], f)); - else - READ(read_int16(&tmp16, f)); - } - for (j = n_ttb; j < 8; j++) - ci->ttb[j] = 0; - READ(read_int16(&tmp16, f)); - ci->capsmin = tmp16; - READ(read_int16(&tmp16, f)); - ci->capspercent = tmp16; - READ(read_int16(&tmp16, f)); - ci->floodlines = tmp16; - READ(read_int16(&tmp16, f)); - ci->floodsecs = tmp16; - READ(read_int16(&tmp16, f)); - ci->repeattimes = tmp16; - - READ(read_uint16(&ci->bwcount, f)); - if (ci->bwcount) { - ci->badwords = (BadWord *)calloc(ci->bwcount, sizeof(BadWord)); - for (j = 0; j < ci->bwcount; j++) { - SAFE(read_uint16(&ci->badwords[j].in_use, f)); - if (ci->badwords[j].in_use) { - SAFE(read_string(&ci->badwords[j].word, f)); - SAFE(read_uint16(&ci->badwords[j].type, f)); - } - } - } else { - ci->badwords = NULL; - } - /* READING DONE */ - ciptr = cs_findchan(ci->name); - if (ciptr) { /* COLLISION! ciptr = old = 1; ci = new = 2*/ - char input[1024]; - - if (!preferoldest && !preferfirst && !prefersecond && !prefernewest) { - printf("Chan collision for channel %s:\n\n", ci->name); - - printf("Owner of channel 1: %s (%s)\n", (ciptr->founder) ? ciptr->founder : "none", (ciptr->email) ? ciptr->email : "no valid email"); - printf("Accesscount: %u\n", ciptr->accesscount); - if (ciptr->flags & 0x00000080) { - printf("Status: Channel is forbidden"); - } else if (ciptr->flags & 0x00010000) { - printf("Status: Channel is suspended"); - } - printf("Time registered: %s\n", ctime(&ciptr->time_registered)); - - printf("Owner of channel 2: %s (%s)\n", (ci->founder) ? ci->founder : "none", (ci->email) ? ci->email : "no valid email"); - printf("Accesscount: %u\n", ci->accesscount); - if (ci->flags & 0x00000080) { - printf("Status: Channel is forbidden"); - } else if (ci->flags & 0x00010000) { - printf("Status: Channel is suspended"); - } - printf("Time registered: %s\n", ctime(&ci->time_registered)); - - printf("What channel do you want to keep? Enter the related number \"1\" or \"2\".\n"); - } - - if (preferoldest) { - input[0] = (ci->time_registered < ciptr->time_registered) ? '1' : '2'; - } else if (prefernewest) { - input[0] = (ci->time_registered < ciptr->time_registered) ? '2' : '1'; - } else if (preferfirst) { - input[0] = '1'; - } else if (prefersecond) { - input[0] = '2'; - } else { - waiting_for_input4: - scanf("%s", input); - } - if (input[0] == '1') { /* #2 isn't in the list yet, #1 is. -> free() #2 [ci] */ - NickCore *nc = NULL; - int i; - printf("Deleting chan %s (#2).\n", ci->name); - - if (ci->founder) { - nc = findcore(ci->founder, 0); - if (nc) - nc->channelcount--; - } - free(ci->desc); - free(ci->founder); - free(ci->successor); - if (ci->url) - free(ci->url); - if (ci->email) - free(ci->email); - if (ci->last_topic) - free(ci->last_topic); - if (ci->forbidby) - free(ci->forbidby); - if (ci->forbidreason) - free(ci->forbidreason); - if (ci->mlock_key) - free(ci->mlock_key); - if (ci->mlock_flood) - free(ci->mlock_flood); - if (ci->mlock_redirect) - free(ci->mlock_redirect); - if (ci->entry_message) - free(ci->entry_message); - if (ci->access) - free(ci->access); - for (i = 0; i < ci->akickcount; i++) { - if (!(ci->akick[i].flags & 0x0002) && ci->akick[i].u.mask) - free(ci->akick[i].u.mask); - if (ci->akick[i].reason) - free(ci->akick[i].reason); - if (ci->akick[i].creator) - free(ci->akick[i].creator); - } - if (ci->akick) - free(ci->akick); - if (ci->levels) - free(ci->levels); - if (ci->memos.memos) { - for (i = 0; i < ci->memos.memocount; i++) { - if (ci->memos.memos[i].text) - free(ci->memos.memos[i].text); - } - free(ci->memos.memos); - } - if (ci->ttb) - free(ci->ttb); - for (i = 0; i < ci->bwcount; i++) { - if (ci->badwords[i].word) - free(ci->badwords[i].word); - } - if (ci->badwords) - free(ci->badwords); - if (ci->bi) - free(ci->bi); - free(ci); - - } else if (input[0] == '2') { /* get #1 out of the list, free() it and add #2 to the list */ - NickCore *nc = NULL; - printf("Deleting chan %s (#1).\n", ciptr->name); - - if (ciptr->next) - ciptr->next->prev = ciptr->prev; - if (ciptr->prev) - ciptr->prev->next = ciptr->next; - else - chanlists[tolower(ciptr->name[1])] = ciptr->next; - - if (ciptr->founder) { - nc = findcore(ci->founder, 0); - if (nc) - nc->channelcount--; - } - free(ciptr->desc); - if (ciptr->url) - free(ciptr->url); - if (ciptr->email) - free(ciptr->email); - if (ciptr->last_topic) - free(ciptr->last_topic); - if (ciptr->forbidby) - free(ciptr->forbidby); - if (ciptr->forbidreason) - free(ciptr->forbidreason); - if (ciptr->mlock_key) - free(ciptr->mlock_key); - if (ciptr->mlock_flood) - free(ciptr->mlock_flood); - if (ciptr->mlock_redirect) - free(ciptr->mlock_redirect); - if (ciptr->entry_message) - free(ciptr->entry_message); - if (ciptr->access) - free(ciptr->access); - for (i = 0; i < ciptr->akickcount; i++) { - if (!(ciptr->akick[i].flags & 0x0002) && ciptr->akick[i].u.mask) - free(ciptr->akick[i].u.mask); - if (ciptr->akick[i].reason) - free(ciptr->akick[i].reason); - if (ciptr->akick[i].creator) - free(ciptr->akick[i].creator); - } - if (ciptr->akick) - free(ciptr->akick); - if (ciptr->levels) - free(ciptr->levels); - if (ciptr->memos.memos) { - for (i = 0; i < ciptr->memos.memocount; i++) { - if (ciptr->memos.memos[i].text) - free(ciptr->memos.memos[i].text); - } - free(ciptr->memos.memos); - } - if (ciptr->ttb) - free(ciptr->ttb); - for (i = 0; i < ciptr->bwcount; i++) { - if (ciptr->badwords[i].word) - free(ciptr->badwords[i].word); - } - if (ciptr->badwords) - free(ciptr->badwords); - free(ciptr); - - alpha_insert_chan(ci); - - } else { - printf("Invalid number, give us a valid one (1 or 2).\n"); - goto waiting_for_input4; - } - } else { /* no collision, put the chan into the list */ - alpha_insert_chan(ci); - } - } /* getc_db() */ - } /* for() loop */ - close_db(f); - } else - nochan = 1; - } - - /* IIc: Saving */ - if (!nochan) { - if ((f = open_db_write("ChanServ", CHAN_DB_NEW, 16))) { - ChannelInfo *ci; - Memo *memos; + while ((c = getc_db(f)) == 1) { + ChannelInfo *ci = NULL, *ciptr = NULL; + int j; + + if (c != 1) { + printf("Invalid format in %s.\n", CHAN_DB_2); + exit(0); + } + + ci = (ChannelInfo *)calloc(sizeof(ChannelInfo), 1); + READ(read_buffer(ci->name, f)); + READ(read_string(&ci->founder, f)); + READ(read_string(&ci->successor, f)); + READ(read_buffer(ci->founderpass, f)); + READ(read_string(&ci->desc, f)); + if (!ci->desc) + ci->desc = strdup(""); + READ(read_string(&ci->url, f)); + READ(read_string(&ci->email, f)); + READ(read_int32(&tmp32, f)); + ci->time_registered = tmp32; + READ(read_int32(&tmp32, f)); + ci->last_used = tmp32; + READ(read_string(&ci->last_topic, f)); + READ(read_buffer(ci->last_topic_setter, f)); + READ(read_int32(&tmp32, f)); + ci->last_topic_time = tmp32; + READ(read_uint32(&ci->flags, f)); + /* Temporary flags cleanup */ + ci->flags &= ~0x80000000; + READ(read_string(&ci->forbidby, f)); + READ(read_string(&ci->forbidreason, f)); + READ(read_int16(&tmp16, f)); + ci->bantype = tmp16; + READ(read_int16(&tmp16, f)); + n_levels = tmp16; + ci->levels = (int16 *)calloc(36 * sizeof(*ci->levels), 1); + for (j = 0; j < n_levels; j++) { + if (j < 36) + READ(read_int16(&ci->levels[j], f)); + else + READ(read_int16(&tmp16, f)); + } + READ(read_uint16(&ci->accesscount, f)); + if (ci->accesscount) { + ci->access = (ChanAccess *)calloc(ci->accesscount, sizeof(ChanAccess)); + for (j = 0; j < ci->accesscount; j++) { + READ(read_uint16(&ci->access[j].in_use, f)); + if (ci->access[j].in_use) { + READ(read_int16(&ci->access[j].level, f)); + READ(read_string(&s, f)); + if (s) { + ci->access[j].nc = findcore(s, 0); + free(s); + } + if (ci->access[j].nc == NULL) + ci->access[j].in_use = 0; + READ(read_int32(&tmp32, f)); + ci->access[j].last_seen = tmp32; + } + } + } else { + ci->access = NULL; + } + READ(read_uint16(&ci->akickcount, f)); + if (ci->akickcount) { + ci->akick = (AutoKick *)calloc(ci->akickcount, sizeof(AutoKick)); + for (j = 0; j < ci->akickcount; j++) { + SAFE(read_uint16(&ci->akick[j].flags, f)); + if (ci->akick[j].flags & 0x0001) { + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & 0x0002) { + ci->akick[j].u.nc = findcore(s, 0); + if (!ci->akick[j].u.nc) + ci->akick[j].flags &= ~0x0001; + free(s); + } else { + ci->akick[j].u.mask = s; + } + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & 0x0001) + ci->akick[j].reason = s; + else if (s) + free(s); + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & 0x0001) { + ci->akick[j].creator = s; + } else if (s) { + free(s); + } + SAFE(read_int32(&tmp32, f)); + if (ci->akick[j].flags & 0x0001) + ci->akick[j].addtime = tmp32; + } + } + } else { + ci->akick = NULL; + } + READ(read_uint32(&ci->mlock_on, f)); + READ(read_uint32(&ci->mlock_off, f)); + READ(read_uint32(&ci->mlock_limit, f)); + READ(read_string(&ci->mlock_key, f)); + READ(read_string(&ci->mlock_flood, f)); + READ(read_string(&ci->mlock_redirect, f)); + READ(read_int16(&ci->memos.memocount, f)); + READ(read_int16(&ci->memos.memomax, f)); + if (ci->memos.memocount) { + Memo *memos; + memos = (Memo *)calloc(sizeof(Memo) * ci->memos.memocount, 1); + ci->memos.memos = memos; + for (j = 0; j < ci->memos.memocount; j++, memos++) { + READ(read_uint32(&memos->number, f)); + READ(read_uint16(&memos->flags, f)); + READ(read_int32(&tmp32, f)); + memos->time = tmp32; + READ(read_buffer(memos->sender, f)); + READ(read_string(&memos->text, f)); + } + } + READ(read_string(&ci->entry_message, f)); + + /* BotServ options */ + READ(read_string(&ci->bi, f)); + READ(read_int32(&tmp32, f)); + ci->botflags = tmp32; + READ(read_int16(&tmp16, f)); + n_ttb = tmp16; + ci->ttb = (int16 *)calloc(32, 1); + for (j = 0; j < n_ttb; j++) { + if (j < 8) + READ(read_int16(&ci->ttb[j], f)); + else + READ(read_int16(&tmp16, f)); + } + for (j = n_ttb; j < 8; j++) + ci->ttb[j] = 0; + READ(read_int16(&tmp16, f)); + ci->capsmin = tmp16; + READ(read_int16(&tmp16, f)); + ci->capspercent = tmp16; + READ(read_int16(&tmp16, f)); + ci->floodlines = tmp16; + READ(read_int16(&tmp16, f)); + ci->floodsecs = tmp16; + READ(read_int16(&tmp16, f)); + ci->repeattimes = tmp16; + + READ(read_uint16(&ci->bwcount, f)); + if (ci->bwcount) { + ci->badwords = (BadWord *)calloc(ci->bwcount, sizeof(BadWord)); + for (j = 0; j < ci->bwcount; j++) { + SAFE(read_uint16(&ci->badwords[j].in_use, f)); + if (ci->badwords[j].in_use) { + SAFE(read_string(&ci->badwords[j].word, f)); + SAFE(read_uint16(&ci->badwords[j].type, f)); + } + } + } else { + ci->badwords = NULL; + } + /* READING DONE */ + ciptr = cs_findchan(ci->name); + if (ciptr) { /* COLLISION! ciptr = old = 1; ci = new = 2*/ + char input[1024]; + + if (!preferoldest && !preferfirst && !prefersecond && !prefernewest) { + printf("Chan collision for channel %s:\n\n", ci->name); + + printf("Owner of channel 1: %s (%s)\n", (ciptr->founder) ? ciptr->founder : "none", (ciptr->email) ? ciptr->email : "no valid email"); + printf("Accesscount: %u\n", ciptr->accesscount); + if (ciptr->flags & 0x00000080) { + printf("Status: Channel is forbidden"); + } else if (ciptr->flags & 0x00010000) { + printf("Status: Channel is suspended"); + } + printf("Time registered: %s\n", ctime(&ciptr->time_registered)); + + printf("Owner of channel 2: %s (%s)\n", (ci->founder) ? ci->founder : "none", (ci->email) ? ci->email : "no valid email"); + printf("Accesscount: %u\n", ci->accesscount); + if (ci->flags & 0x00000080) { + printf("Status: Channel is forbidden"); + } else if (ci->flags & 0x00010000) { + printf("Status: Channel is suspended"); + } + printf("Time registered: %s\n", ctime(&ci->time_registered)); + + printf("What channel do you want to keep? Enter the related number \"1\" or \"2\".\n"); + } + + if (preferoldest) { + input[0] = (ci->time_registered < ciptr->time_registered) ? '1' : '2'; + } else if (prefernewest) { + input[0] = (ci->time_registered < ciptr->time_registered) ? '2' : '1'; + } else if (preferfirst) { + input[0] = '1'; + } else if (prefersecond) { + input[0] = '2'; + } else { + waiting_for_input4: + scanf("%s", input); + } + if (input[0] == '1') { /* #2 isn't in the list yet, #1 is. -> free() #2 [ci] */ + NickCore *nc = NULL; + int i; + printf("Deleting chan %s (#2).\n", ci->name); + + if (ci->founder) { + nc = findcore(ci->founder, 0); + if (nc) + nc->channelcount--; + } + free(ci->desc); + free(ci->founder); + free(ci->successor); + if (ci->url) + free(ci->url); + if (ci->email) + free(ci->email); + if (ci->last_topic) + free(ci->last_topic); + if (ci->forbidby) + free(ci->forbidby); + if (ci->forbidreason) + free(ci->forbidreason); + if (ci->mlock_key) + free(ci->mlock_key); + if (ci->mlock_flood) + free(ci->mlock_flood); + if (ci->mlock_redirect) + free(ci->mlock_redirect); + if (ci->entry_message) + free(ci->entry_message); + if (ci->access) + free(ci->access); + for (i = 0; i < ci->akickcount; i++) { + if (!(ci->akick[i].flags & 0x0002) && ci->akick[i].u.mask) + free(ci->akick[i].u.mask); + if (ci->akick[i].reason) + free(ci->akick[i].reason); + if (ci->akick[i].creator) + free(ci->akick[i].creator); + } + if (ci->akick) + free(ci->akick); + if (ci->levels) + free(ci->levels); + if (ci->memos.memos) { + for (i = 0; i < ci->memos.memocount; i++) { + if (ci->memos.memos[i].text) + free(ci->memos.memos[i].text); + } + free(ci->memos.memos); + } + if (ci->ttb) + free(ci->ttb); + for (i = 0; i < ci->bwcount; i++) { + if (ci->badwords[i].word) + free(ci->badwords[i].word); + } + if (ci->badwords) + free(ci->badwords); + if (ci->bi) + free(ci->bi); + free(ci); + + } else if (input[0] == '2') { /* get #1 out of the list, free() it and add #2 to the list */ + NickCore *nc = NULL; + printf("Deleting chan %s (#1).\n", ciptr->name); + + if (ciptr->next) + ciptr->next->prev = ciptr->prev; + if (ciptr->prev) + ciptr->prev->next = ciptr->next; + else + chanlists[tolower(ciptr->name[1])] = ciptr->next; + + if (ciptr->founder) { + nc = findcore(ci->founder, 0); + if (nc) + nc->channelcount--; + } + free(ciptr->desc); + if (ciptr->url) + free(ciptr->url); + if (ciptr->email) + free(ciptr->email); + if (ciptr->last_topic) + free(ciptr->last_topic); + if (ciptr->forbidby) + free(ciptr->forbidby); + if (ciptr->forbidreason) + free(ciptr->forbidreason); + if (ciptr->mlock_key) + free(ciptr->mlock_key); + if (ciptr->mlock_flood) + free(ciptr->mlock_flood); + if (ciptr->mlock_redirect) + free(ciptr->mlock_redirect); + if (ciptr->entry_message) + free(ciptr->entry_message); + if (ciptr->access) + free(ciptr->access); + for (i = 0; i < ciptr->akickcount; i++) { + if (!(ciptr->akick[i].flags & 0x0002) && ciptr->akick[i].u.mask) + free(ciptr->akick[i].u.mask); + if (ciptr->akick[i].reason) + free(ciptr->akick[i].reason); + if (ciptr->akick[i].creator) + free(ciptr->akick[i].creator); + } + if (ciptr->akick) + free(ciptr->akick); + if (ciptr->levels) + free(ciptr->levels); + if (ciptr->memos.memos) { + for (i = 0; i < ciptr->memos.memocount; i++) { + if (ciptr->memos.memos[i].text) + free(ciptr->memos.memos[i].text); + } + free(ciptr->memos.memos); + } + if (ciptr->ttb) + free(ciptr->ttb); + for (i = 0; i < ciptr->bwcount; i++) { + if (ciptr->badwords[i].word) + free(ciptr->badwords[i].word); + } + if (ciptr->badwords) + free(ciptr->badwords); + free(ciptr); + + alpha_insert_chan(ci); + + } else { + printf("Invalid number, give us a valid one (1 or 2).\n"); + goto waiting_for_input4; + } + } else { /* no collision, put the chan into the list */ + alpha_insert_chan(ci); + } + } /* getc_db() */ + } /* for() loop */ + close_db(f); + } else + nochan = 1; + } + + /* IIc: Saving */ + if (!nochan) { + if ((f = open_db_write("ChanServ", CHAN_DB_NEW, 16))) { + ChannelInfo *ci; + Memo *memos; /* Unused variable - why? -GD - static time_t lastwarn = 0; + static time_t lastwarn = 0; */ - for (i = 0; i < 256; i++) { - int16 tmp16; - for (ci = chanlists[i]; ci; ci = ci->next) { - int j; - SAFE(write_int8(1, f)); - SAFE(write_buffer(ci->name, f)); - if (ci->founder) - SAFE(write_string(ci->founder, f)); - else - SAFE(write_string(NULL, f)); - if (ci->successor) - SAFE(write_string(ci->successor, f)); - else - SAFE(write_string(NULL, f)); - SAFE(write_buffer(ci->founderpass, f)); - SAFE(write_string(ci->desc, f)); - SAFE(write_string(ci->url, f)); - SAFE(write_string(ci->email, f)); - SAFE(write_int32(ci->time_registered, f)); - SAFE(write_int32(ci->last_used, f)); - SAFE(write_string(ci->last_topic, f)); - SAFE(write_buffer(ci->last_topic_setter, f)); - SAFE(write_int32(ci->last_topic_time, f)); - SAFE(write_int32(ci->flags, f)); - SAFE(write_string(ci->forbidby, f)); - SAFE(write_string(ci->forbidreason, f)); - SAFE(write_int16(ci->bantype, f)); - tmp16 = 36; - SAFE(write_int16(tmp16, f)); - for (j = 0; j < 36; j++) - SAFE(write_int16(ci->levels[j], f)); - - SAFE(write_int16(ci->accesscount, f)); - for (j = 0; j < ci->accesscount; j++) { - SAFE(write_int16(ci->access[j].in_use, f)); - if (ci->access[j].in_use) { - SAFE(write_int16(ci->access[j].level, f)); - SAFE(write_string(ci->access[j].nc->display, f)); - SAFE(write_int32(ci->access[j].last_seen, f)); - } - } - SAFE(write_int16(ci->akickcount, f)); - for (j = 0; j < ci->akickcount; j++) { - SAFE(write_int16(ci->akick[j].flags, f)); - if (ci->akick[j].flags & 0x0001) { - if (ci->akick[j].flags & 0x0002) - SAFE(write_string(ci->akick[j].u.nc->display, f)); - else - SAFE(write_string(ci->akick[j].u.mask, f)); - SAFE(write_string(ci->akick[j].reason, f)); - SAFE(write_string(ci->akick[j].creator, f)); - SAFE(write_int32(ci->akick[j].addtime, f)); - } - } - - SAFE(write_int32(ci->mlock_on, f)); - SAFE(write_int32(ci->mlock_off, f)); - SAFE(write_int32(ci->mlock_limit, f)); - SAFE(write_string(ci->mlock_key, f)); - SAFE(write_string(ci->mlock_flood, f)); - SAFE(write_string(ci->mlock_redirect, f)); - SAFE(write_int16(ci->memos.memocount, f)); - SAFE(write_int16(ci->memos.memomax, f)); - memos = ci->memos.memos; - for (j = 0; j < ci->memos.memocount; j++, memos++) { - SAFE(write_int32(memos->number, f)); - SAFE(write_int16(memos->flags, f)); - SAFE(write_int32(memos->time, f)); - SAFE(write_buffer(memos->sender, f)); - SAFE(write_string(memos->text, f)); - } - SAFE(write_string(ci->entry_message, f)); - if (ci->bi) - SAFE(write_string(ci->bi, f)); - else - SAFE(write_string(NULL, f)); - SAFE(write_int32(ci->botflags, f)); - tmp16 = 8; - SAFE(write_int16(tmp16, f)); - for (j = 0; j < 8; j++) - SAFE(write_int16(ci->ttb[j], f)); - SAFE(write_int16(ci->capsmin, f)); - SAFE(write_int16(ci->capspercent, f)); - SAFE(write_int16(ci->floodlines, f)); - SAFE(write_int16(ci->floodsecs, f)); - SAFE(write_int16(ci->repeattimes, f)); - - SAFE(write_int16(ci->bwcount, f)); - for (j = 0; j < ci->bwcount; j++) { - SAFE(write_int16(ci->badwords[j].in_use, f)); - if (ci->badwords[j].in_use) { - SAFE(write_string(ci->badwords[j].word, f)); - SAFE(write_int16(ci->badwords[j].type, f)); - } - } - } /* for (chanlists[i]) */ - SAFE(write_int8(0, f)); - } /* for (i) */ - close_db(f); - printf("Chan merging done. New database saved as %s.\n", CHAN_DB_NEW); - } - } - - /* Section III: Bots */ - /* IIIa: First database */ - if ((f = open_db_read("Botserv", BOT_DB_1, 10))) { - BotInfo *bi; - int c; - int32 tmp32; - int16 tmp16; - - printf("Trying to merge bots...\n"); - - while ((c = getc_db(f)) == 1) { - if (c != 1) { - printf("Invalid format in %s.\n", BOT_DB_1); - exit(0); - } - - bi = (BotInfo *)calloc(sizeof(BotInfo), 1); - READ(read_string(&bi->nick, f)); - READ(read_string(&bi->user, f)); - READ(read_string(&bi->host, f)); - READ(read_string(&bi->real, f)); - SAFE(read_int16(&tmp16, f)); - bi->flags = tmp16; - READ(read_int32(&tmp32, f)); - bi->created = tmp32; - READ(read_int16(&tmp16, f)); - bi->chancount = tmp16; - insert_bot(bi); - } - } else - nobot = 1; - - /* IIIb: Second database */ - if (!nobot) { - if ((f = open_db_read("Botserv", BOT_DB_2, 10))) { - BotInfo *bi, *biptr; - int c; - int32 tmp32; - int16 tmp16; - char input[1024]; - - while ((c = getc_db(f)) == 1) { - if (c != 1) { - printf("Invalid format in %s.\n", BOT_DB_2); - exit(0); - } - - bi = (BotInfo *)calloc(sizeof(BotInfo), 1); - READ(read_string(&bi->nick, f)); - READ(read_string(&bi->user, f)); - READ(read_string(&bi->host, f)); - READ(read_string(&bi->real, f)); - SAFE(read_int16(&tmp16, f)); - bi->flags = tmp16; - READ(read_int32(&tmp32, f)); - bi->created = tmp32; - READ(read_int16(&tmp16, f)); - bi->chancount = tmp16; - biptr = findbot(bi->nick); - if (biptr) { /* BOT COLLISION! #1 is biptr-> (db1), #2 is bi-> (db2) */ - if (!preferoldest && !preferfirst && !prefersecond && !prefernewest) { - printf("Bot collision for botnick %s:\n\n", biptr->nick); - printf("Bot 1: %s@%s (%s) is assigned to %d chans\n", biptr->user, biptr->host, biptr->real, biptr->chancount); - printf("Time registered: %s\n", ctime(&biptr->created)); - printf("Bot 2: %s@%s (%s) is assigned to %d chans\n", bi->user, bi->host, bi->real, bi->chancount); - printf("Time registered: %s\n", ctime(&bi->created)); - printf("What bot do you want to keep? Enter the related bot number \"1\" or \"2\".\n"); - } - - if (preferoldest) { - input[0] = (biptr->created > bi->created) ? '1' : '2'; - } else if (prefernewest) { - input[0] = (biptr->created > bi->created) ? '2' : '1'; - } else if (preferfirst) { - input[0] = '2'; - } else if (prefersecond) { - input[0] = '1'; - } else { - waiting_for_input3: - scanf("%s", input); - } - if (input[0] == '1') { /* free() bot #2 (bi) */ - printf("Deleting Bot %s!%s@%s (%s) (#2).\n", bi->nick, bi->user, bi->host, bi->real); - free(bi->nick); - free(bi->user); - free(bi->host); - free(bi->real); - free(bi); - } else if (input[0] == '2') { /* get bot #1 (biptr) out of the list, free() it and add #2 to the list */ - printf("Deleting Bot %s!%s@%s (%s) (#1).\n", biptr->nick, biptr->user, biptr->host, biptr->real); - if (biptr->next) - biptr->next->prev = biptr->prev; - if (biptr->prev) - biptr->prev->next = biptr->next; - else - botlists[tolower(*biptr->nick)] = biptr->next; - free(biptr->nick); - free(biptr->user); - free(biptr->host); - free(biptr->real); - free(biptr); - insert_bot(bi); - } else { - printf("Invalid number, give us a valid one (1 or 2).\n"); - goto waiting_for_input3; - } - } /* NO COLLISION (biptr) */ - insert_bot(bi); - } - } else - nobot = 1; - } - - /* IIIc: Saving */ - if (!nobot) { - if ((f = open_db_write("Botserv", BOT_DB_NEW, 10))) { - BotInfo *bi; - for (i = 0; i < 256; i++) { - for (bi = botlists[i]; bi; bi = bi->next) { - SAFE(write_int8(1, f)); - SAFE(write_string(bi->nick, f)); - SAFE(write_string(bi->user, f)); - SAFE(write_string(bi->host, f)); - SAFE(write_string(bi->real, f)); - SAFE(write_int16(bi->flags, f)); - SAFE(write_int32(bi->created, f)); - SAFE(write_int16(bi->chancount, f)); - } - } - SAFE(write_int8(0, f)); - close_db(f); - printf("Bot merging done. New database saved as %s.\n", BOT_DB_NEW); - } - } /* End of section III */ - - /* Section IV: Hosts */ - /* IVa: First database */ - if ((f = open_db_read("HostServ", HOST_DB_1, 3))) { - HostCore *hc; - int c; - int32 tmp32; - - printf("Trying to merge hosts...\n"); - - while ((c = getc_db(f)) == 1) { - if (c != 1) { - printf("Invalid format in %s.\n", HOST_DB_1); - exit(0); - } - hc = (HostCore *)calloc(1, sizeof(HostCore)); - READ(read_string(&hc->nick, f)); - READ(read_string(&hc->vIdent, f)); - READ(read_string(&hc->vHost, f)); - READ(read_string(&hc->creator, f)); - READ(read_int32(&tmp32, f)); - hc->time = tmp32; - hc->next = firsthc; - if (firsthc) - firsthc->last = hc; - hc->last = NULL; - firsthc = hc; - } - } else - nohost = 1; - - /* IVb: Second database */ - if (!nohost) { - if ((f = open_db_read("HostServ", HOST_DB_2, 3))) { - HostCore *hc, *hcptr; - char input[1024]; - int32 tmp32; - int c; - int collision = 0; - - while ((c = getc_db(f)) == 1) { - if (c != 1) { - printf("Invalid format in %s.\n", HOST_DB_2); - exit(0); - } - collision = 0; - hc = (HostCore *)calloc(1, sizeof(HostCore)); - READ(read_string(&hc->nick, f)); - READ(read_string(&hc->vIdent, f)); - READ(read_string(&hc->vHost, f)); - READ(read_string(&hc->creator, f)); - READ(read_int32(&tmp32, f)); - hc->time = tmp32; - - for (hcptr = firsthc; hcptr; hcptr = hcptr->next) { - if (!mystricmp(hcptr->nick, hc->nick)) { /* COLLISION: #1 is from db1 (hcptr), #2 is from db2 (hc) */ - collision++; - if (!preferoldest && !preferfirst && !prefersecond && !prefernewest) { - printf("vHost collision for nick %s:\n\n", hcptr->nick); - printf("vHost 1: %s (vIdent: %s)\n", hcptr->vHost, (hcptr->vIdent) ? hcptr->vIdent : "none"); - printf("Time set: %s\n", ctime(&hcptr->time)); - printf("vHost 2: %s (vIdent: %s)\n", hc->vHost, (hc->vIdent) ? hc->vIdent : "none"); - printf("Time set: %s\n", ctime(&hc->time)); - printf("What vhost do you want to keep? Enter the related number \"1\" or \"2\".\n"); - } - if (preferoldest) { - input[0] = (hcptr->time > hc->time) ? '1' : '2'; - } else if (prefernewest) { - input[0] = (hcptr->time > hc->time) ? '2' : '1'; - } else if (preferfirst) { - input[0] = '1'; - } else if (prefersecond) { - input[0] = '2'; - } else { - waiting_for_input2: - scanf("%s", input); - } - if (input[0] == '2') { /* free() hcptr and get it out of the list, put hc into the list */ - printf("Deleting vHost %s (vIdent: %s) for nick %s (#1).\n", hcptr->vHost, (hcptr->vIdent) ? hcptr->vIdent : "none", hcptr->nick); - if (hcptr->last) - hcptr->last->next = hcptr->next; - if (hcptr->next) - hcptr->next->last = hcptr->last; - free(hcptr->nick); - free(hcptr->vHost); - free(hcptr->vIdent); - free(hcptr->creator); - free(hcptr); - hc->next = firsthc; - if (firsthc) - firsthc->last = hc; - hc->last = NULL; - firsthc = hc; - } else if (input[0] == '1') { /* free() hc */ - printf("Deleting vHost %s (vIdent: %s) for nick %s (#2).\n", hc->vHost, (hc->vIdent) ? hc->vIdent : "none", hc->nick); - free(hc->nick); - free(hc->vHost); - free(hc->vIdent); - free(hc->creator); - free(hc); - } else { - printf("Invalid number, give us a valid one (1 or 2).\n"); - goto waiting_for_input2; - } /* input[0] */ - } /* mystricmp */ - } /* for (hcptr...) */ - if (!collision) { /* No collision */ - hc->next = firsthc; - if (firsthc) - firsthc->last = hc; - hc->last = NULL; - firsthc = hc; - } - } /* while */ - } else - nohost = 1; - } - - /* IVc: Saving */ - if (!nohost) { - if ((f = open_db_write("HostServ", HOST_DB_NEW, 3))) { - HostCore *hcptr; - for (hcptr = firsthc; hcptr; hcptr = hcptr->next) { - SAFE(write_int8(1, f)); - SAFE(write_string(hcptr->nick, f)); - SAFE(write_string(hcptr->vIdent, f)); - SAFE(write_string(hcptr->vHost, f)); - SAFE(write_string(hcptr->creator, f)); - SAFE(write_int32(hcptr->time, f)); - } - SAFE(write_int8(0, f)); - close_db(f); - printf("Host merging done. New database saved as %s.\n", HOST_DB_NEW); - } - } /* End of section IV */ - - /* MERGING DONE \o/ HURRAY! */ - - printf("\n\nMerging is now done. I give NO guarantee for your DBs.\n"); + for (i = 0; i < 256; i++) { + int16 tmp16; + for (ci = chanlists[i]; ci; ci = ci->next) { + int j; + SAFE(write_int8(1, f)); + SAFE(write_buffer(ci->name, f)); + if (ci->founder) + SAFE(write_string(ci->founder, f)); + else + SAFE(write_string(NULL, f)); + if (ci->successor) + SAFE(write_string(ci->successor, f)); + else + SAFE(write_string(NULL, f)); + SAFE(write_buffer(ci->founderpass, f)); + SAFE(write_string(ci->desc, f)); + SAFE(write_string(ci->url, f)); + SAFE(write_string(ci->email, f)); + SAFE(write_int32(ci->time_registered, f)); + SAFE(write_int32(ci->last_used, f)); + SAFE(write_string(ci->last_topic, f)); + SAFE(write_buffer(ci->last_topic_setter, f)); + SAFE(write_int32(ci->last_topic_time, f)); + SAFE(write_int32(ci->flags, f)); + SAFE(write_string(ci->forbidby, f)); + SAFE(write_string(ci->forbidreason, f)); + SAFE(write_int16(ci->bantype, f)); + tmp16 = 36; + SAFE(write_int16(tmp16, f)); + for (j = 0; j < 36; j++) + SAFE(write_int16(ci->levels[j], f)); + + SAFE(write_int16(ci->accesscount, f)); + for (j = 0; j < ci->accesscount; j++) { + SAFE(write_int16(ci->access[j].in_use, f)); + if (ci->access[j].in_use) { + SAFE(write_int16(ci->access[j].level, f)); + SAFE(write_string(ci->access[j].nc->display, f)); + SAFE(write_int32(ci->access[j].last_seen, f)); + } + } + SAFE(write_int16(ci->akickcount, f)); + for (j = 0; j < ci->akickcount; j++) { + SAFE(write_int16(ci->akick[j].flags, f)); + if (ci->akick[j].flags & 0x0001) { + if (ci->akick[j].flags & 0x0002) + SAFE(write_string(ci->akick[j].u.nc->display, f)); + else + SAFE(write_string(ci->akick[j].u.mask, f)); + SAFE(write_string(ci->akick[j].reason, f)); + SAFE(write_string(ci->akick[j].creator, f)); + SAFE(write_int32(ci->akick[j].addtime, f)); + } + } + + SAFE(write_int32(ci->mlock_on, f)); + SAFE(write_int32(ci->mlock_off, f)); + SAFE(write_int32(ci->mlock_limit, f)); + SAFE(write_string(ci->mlock_key, f)); + SAFE(write_string(ci->mlock_flood, f)); + SAFE(write_string(ci->mlock_redirect, f)); + SAFE(write_int16(ci->memos.memocount, f)); + SAFE(write_int16(ci->memos.memomax, f)); + memos = ci->memos.memos; + for (j = 0; j < ci->memos.memocount; j++, memos++) { + SAFE(write_int32(memos->number, f)); + SAFE(write_int16(memos->flags, f)); + SAFE(write_int32(memos->time, f)); + SAFE(write_buffer(memos->sender, f)); + SAFE(write_string(memos->text, f)); + } + SAFE(write_string(ci->entry_message, f)); + if (ci->bi) + SAFE(write_string(ci->bi, f)); + else + SAFE(write_string(NULL, f)); + SAFE(write_int32(ci->botflags, f)); + tmp16 = 8; + SAFE(write_int16(tmp16, f)); + for (j = 0; j < 8; j++) + SAFE(write_int16(ci->ttb[j], f)); + SAFE(write_int16(ci->capsmin, f)); + SAFE(write_int16(ci->capspercent, f)); + SAFE(write_int16(ci->floodlines, f)); + SAFE(write_int16(ci->floodsecs, f)); + SAFE(write_int16(ci->repeattimes, f)); + + SAFE(write_int16(ci->bwcount, f)); + for (j = 0; j < ci->bwcount; j++) { + SAFE(write_int16(ci->badwords[j].in_use, f)); + if (ci->badwords[j].in_use) { + SAFE(write_string(ci->badwords[j].word, f)); + SAFE(write_int16(ci->badwords[j].type, f)); + } + } + } /* for (chanlists[i]) */ + SAFE(write_int8(0, f)); + } /* for (i) */ + close_db(f); + printf("Chan merging done. New database saved as %s.\n", CHAN_DB_NEW); + } + } + + /* Section III: Bots */ + /* IIIa: First database */ + if ((f = open_db_read("Botserv", BOT_DB_1, 10))) { + BotInfo *bi; + int c; + int32 tmp32; + int16 tmp16; + + printf("Trying to merge bots...\n"); + + while ((c = getc_db(f)) == 1) { + if (c != 1) { + printf("Invalid format in %s.\n", BOT_DB_1); + exit(0); + } + + bi = (BotInfo *)calloc(sizeof(BotInfo), 1); + READ(read_string(&bi->nick, f)); + READ(read_string(&bi->user, f)); + READ(read_string(&bi->host, f)); + READ(read_string(&bi->real, f)); + SAFE(read_int16(&tmp16, f)); + bi->flags = tmp16; + READ(read_int32(&tmp32, f)); + bi->created = tmp32; + READ(read_int16(&tmp16, f)); + bi->chancount = tmp16; + insert_bot(bi); + } + } else + nobot = 1; + + /* IIIb: Second database */ + if (!nobot) { + if ((f = open_db_read("Botserv", BOT_DB_2, 10))) { + BotInfo *bi, *biptr; + int c; + int32 tmp32; + int16 tmp16; + char input[1024]; + + while ((c = getc_db(f)) == 1) { + if (c != 1) { + printf("Invalid format in %s.\n", BOT_DB_2); + exit(0); + } + + bi = (BotInfo *)calloc(sizeof(BotInfo), 1); + READ(read_string(&bi->nick, f)); + READ(read_string(&bi->user, f)); + READ(read_string(&bi->host, f)); + READ(read_string(&bi->real, f)); + SAFE(read_int16(&tmp16, f)); + bi->flags = tmp16; + READ(read_int32(&tmp32, f)); + bi->created = tmp32; + READ(read_int16(&tmp16, f)); + bi->chancount = tmp16; + biptr = findbot(bi->nick); + if (biptr) { /* BOT COLLISION! #1 is biptr-> (db1), #2 is bi-> (db2) */ + if (!preferoldest && !preferfirst && !prefersecond && !prefernewest) { + printf("Bot collision for botnick %s:\n\n", biptr->nick); + printf("Bot 1: %s@%s (%s) is assigned to %d chans\n", biptr->user, biptr->host, biptr->real, biptr->chancount); + printf("Time registered: %s\n", ctime(&biptr->created)); + printf("Bot 2: %s@%s (%s) is assigned to %d chans\n", bi->user, bi->host, bi->real, bi->chancount); + printf("Time registered: %s\n", ctime(&bi->created)); + printf("What bot do you want to keep? Enter the related bot number \"1\" or \"2\".\n"); + } + + if (preferoldest) { + input[0] = (biptr->created > bi->created) ? '1' : '2'; + } else if (prefernewest) { + input[0] = (biptr->created > bi->created) ? '2' : '1'; + } else if (preferfirst) { + input[0] = '2'; + } else if (prefersecond) { + input[0] = '1'; + } else { + waiting_for_input3: + scanf("%s", input); + } + if (input[0] == '1') { /* free() bot #2 (bi) */ + printf("Deleting Bot %s!%s@%s (%s) (#2).\n", bi->nick, bi->user, bi->host, bi->real); + free(bi->nick); + free(bi->user); + free(bi->host); + free(bi->real); + free(bi); + } else if (input[0] == '2') { /* get bot #1 (biptr) out of the list, free() it and add #2 to the list */ + printf("Deleting Bot %s!%s@%s (%s) (#1).\n", biptr->nick, biptr->user, biptr->host, biptr->real); + if (biptr->next) + biptr->next->prev = biptr->prev; + if (biptr->prev) + biptr->prev->next = biptr->next; + else + botlists[tolower(*biptr->nick)] = biptr->next; + free(biptr->nick); + free(biptr->user); + free(biptr->host); + free(biptr->real); + free(biptr); + insert_bot(bi); + } else { + printf("Invalid number, give us a valid one (1 or 2).\n"); + goto waiting_for_input3; + } + } /* NO COLLISION (biptr) */ + insert_bot(bi); + } + } else + nobot = 1; + } + + /* IIIc: Saving */ + if (!nobot) { + if ((f = open_db_write("Botserv", BOT_DB_NEW, 10))) { + BotInfo *bi; + for (i = 0; i < 256; i++) { + for (bi = botlists[i]; bi; bi = bi->next) { + SAFE(write_int8(1, f)); + SAFE(write_string(bi->nick, f)); + SAFE(write_string(bi->user, f)); + SAFE(write_string(bi->host, f)); + SAFE(write_string(bi->real, f)); + SAFE(write_int16(bi->flags, f)); + SAFE(write_int32(bi->created, f)); + SAFE(write_int16(bi->chancount, f)); + } + } + SAFE(write_int8(0, f)); + close_db(f); + printf("Bot merging done. New database saved as %s.\n", BOT_DB_NEW); + } + } /* End of section III */ + + /* Section IV: Hosts */ + /* IVa: First database */ + if ((f = open_db_read("HostServ", HOST_DB_1, 3))) { + HostCore *hc; + int c; + int32 tmp32; + + printf("Trying to merge hosts...\n"); + + while ((c = getc_db(f)) == 1) { + if (c != 1) { + printf("Invalid format in %s.\n", HOST_DB_1); + exit(0); + } + hc = (HostCore *)calloc(1, sizeof(HostCore)); + READ(read_string(&hc->nick, f)); + READ(read_string(&hc->vIdent, f)); + READ(read_string(&hc->vHost, f)); + READ(read_string(&hc->creator, f)); + READ(read_int32(&tmp32, f)); + hc->time = tmp32; + hc->next = firsthc; + if (firsthc) + firsthc->last = hc; + hc->last = NULL; + firsthc = hc; + } + } else + nohost = 1; + + /* IVb: Second database */ + if (!nohost) { + if ((f = open_db_read("HostServ", HOST_DB_2, 3))) { + HostCore *hc, *hcptr; + char input[1024]; + int32 tmp32; + int c; + int collision = 0; + + while ((c = getc_db(f)) == 1) { + if (c != 1) { + printf("Invalid format in %s.\n", HOST_DB_2); + exit(0); + } + collision = 0; + hc = (HostCore *)calloc(1, sizeof(HostCore)); + READ(read_string(&hc->nick, f)); + READ(read_string(&hc->vIdent, f)); + READ(read_string(&hc->vHost, f)); + READ(read_string(&hc->creator, f)); + READ(read_int32(&tmp32, f)); + hc->time = tmp32; + + for (hcptr = firsthc; hcptr; hcptr = hcptr->next) { + if (!mystricmp(hcptr->nick, hc->nick)) { /* COLLISION: #1 is from db1 (hcptr), #2 is from db2 (hc) */ + collision++; + if (!preferoldest && !preferfirst && !prefersecond && !prefernewest) { + printf("vHost collision for nick %s:\n\n", hcptr->nick); + printf("vHost 1: %s (vIdent: %s)\n", hcptr->vHost, (hcptr->vIdent) ? hcptr->vIdent : "none"); + printf("Time set: %s\n", ctime(&hcptr->time)); + printf("vHost 2: %s (vIdent: %s)\n", hc->vHost, (hc->vIdent) ? hc->vIdent : "none"); + printf("Time set: %s\n", ctime(&hc->time)); + printf("What vhost do you want to keep? Enter the related number \"1\" or \"2\".\n"); + } + if (preferoldest) { + input[0] = (hcptr->time > hc->time) ? '1' : '2'; + } else if (prefernewest) { + input[0] = (hcptr->time > hc->time) ? '2' : '1'; + } else if (preferfirst) { + input[0] = '1'; + } else if (prefersecond) { + input[0] = '2'; + } else { + waiting_for_input2: + scanf("%s", input); + } + if (input[0] == '2') { /* free() hcptr and get it out of the list, put hc into the list */ + printf("Deleting vHost %s (vIdent: %s) for nick %s (#1).\n", hcptr->vHost, (hcptr->vIdent) ? hcptr->vIdent : "none", hcptr->nick); + if (hcptr->last) + hcptr->last->next = hcptr->next; + if (hcptr->next) + hcptr->next->last = hcptr->last; + free(hcptr->nick); + free(hcptr->vHost); + free(hcptr->vIdent); + free(hcptr->creator); + free(hcptr); + hc->next = firsthc; + if (firsthc) + firsthc->last = hc; + hc->last = NULL; + firsthc = hc; + } else if (input[0] == '1') { /* free() hc */ + printf("Deleting vHost %s (vIdent: %s) for nick %s (#2).\n", hc->vHost, (hc->vIdent) ? hc->vIdent : "none", hc->nick); + free(hc->nick); + free(hc->vHost); + free(hc->vIdent); + free(hc->creator); + free(hc); + } else { + printf("Invalid number, give us a valid one (1 or 2).\n"); + goto waiting_for_input2; + } /* input[0] */ + } /* mystricmp */ + } /* for (hcptr...) */ + if (!collision) { /* No collision */ + hc->next = firsthc; + if (firsthc) + firsthc->last = hc; + hc->last = NULL; + firsthc = hc; + } + } /* while */ + } else + nohost = 1; + } + + /* IVc: Saving */ + if (!nohost) { + if ((f = open_db_write("HostServ", HOST_DB_NEW, 3))) { + HostCore *hcptr; + for (hcptr = firsthc; hcptr; hcptr = hcptr->next) { + SAFE(write_int8(1, f)); + SAFE(write_string(hcptr->nick, f)); + SAFE(write_string(hcptr->vIdent, f)); + SAFE(write_string(hcptr->vHost, f)); + SAFE(write_string(hcptr->creator, f)); + SAFE(write_int32(hcptr->time, f)); + } + SAFE(write_int8(0, f)); + close_db(f); + printf("Host merging done. New database saved as %s.\n", HOST_DB_NEW); + } + } /* End of section IV */ + + /* MERGING DONE \o/ HURRAY! */ + + printf("\n\nMerging is now done. I give NO guarantee for your DBs.\n"); return 0; } /* End of main() */ /* Open a database file for reading and check for the version */ dbFILE *open_db_read(const char *service, const char *filename, int version) { - dbFILE *f; - FILE *fp; - int myversion; - - f = (dbFILE *)calloc(sizeof(*f), 1); - if (!f) { - printf("Can't allocate memory for %s database %s.\n", service, filename); - exit(0); - } - strscpy(f->filename, filename, sizeof(f->filename)); - f->mode = 'r'; - fp = fopen(f->filename, "rb"); - if (!fp) { - printf("Can't read %s database %s.\n", service, f->filename); - free(f); - return NULL; - } - f->fp = fp; - myversion = fgetc(fp) << 24 | fgetc(fp) << 16 | fgetc(fp) << 8 | fgetc(fp); - if (feof(fp)) { - printf("Error reading version number on %s: End of file detected.\n", f->filename); - exit(0); - } else if (myversion < version) { - printf("Unsuported database version (%d) on %s.\n", myversion, f->filename); - exit(0); - } - return f; + dbFILE *f; + FILE *fp; + int myversion; + + f = (dbFILE *)calloc(sizeof(*f), 1); + if (!f) { + printf("Can't allocate memory for %s database %s.\n", service, filename); + exit(0); + } + strscpy(f->filename, filename, sizeof(f->filename)); + f->mode = 'r'; + fp = fopen(f->filename, "rb"); + if (!fp) { + printf("Can't read %s database %s.\n", service, f->filename); + free(f); + return NULL; + } + f->fp = fp; + myversion = fgetc(fp) << 24 | fgetc(fp) << 16 | fgetc(fp) << 8 | fgetc(fp); + if (feof(fp)) { + printf("Error reading version number on %s: End of file detected.\n", f->filename); + exit(0); + } else if (myversion < version) { + printf("Unsuported database version (%d) on %s.\n", myversion, f->filename); + exit(0); + } + return f; } /* Open a database file for reading and check for the version */ dbFILE *open_db_write(const char *service, const char *filename, int version) { - dbFILE *f; - int fd; - - f = (dbFILE *)calloc(sizeof(*f), 1); - if (!f) { - printf("Can't allocate memory for %s database %s.\n", service, filename); - exit(0); - } - strscpy(f->filename, filename, sizeof(f->filename)); - filename = f->filename; + dbFILE *f; + int fd; + + f = (dbFILE *)calloc(sizeof(*f), 1); + if (!f) { + printf("Can't allocate memory for %s database %s.\n", service, filename); + exit(0); + } + strscpy(f->filename, filename, sizeof(f->filename)); + filename = f->filename; #ifndef _WIN32 - unlink(filename); + unlink(filename); #else - DeleteFile(filename); + DeleteFile(filename); #endif - f->mode = 'w'; + f->mode = 'w'; #ifndef _WIN32 - fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666); + fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666); #else - fd = open(filename, O_WRONLY | O_CREAT | O_EXCL | _O_BINARY, 0666); + fd = open(filename, O_WRONLY | O_CREAT | O_EXCL | _O_BINARY, 0666); #endif - f->fp = fdopen(fd, "wb"); /* will fail and return NULL if fd < 0 */ - if (!f->fp || !write_file_version(f, version)) { - printf("Can't write to %s database %s.\n", service, filename); - if (f->fp) { - fclose(f->fp); + f->fp = fdopen(fd, "wb"); /* will fail and return NULL if fd < 0 */ + if (!f->fp || !write_file_version(f, version)) { + printf("Can't write to %s database %s.\n", service, filename); + if (f->fp) { + fclose(f->fp); #ifndef _WIN32 - unlink(filename); + unlink(filename); #else - DeleteFile(filename); + DeleteFile(filename); #endif - } - free(f); - return NULL; - } - return f; + } + free(f); + return NULL; + } + return f; } /* Close it */ void close_db(dbFILE * f) { - fclose(f->fp); - free(f); + fclose(f->fp); + free(f); } int read_int16(int16 * ret, dbFILE * f) { - int c1, c2; - - c1 = fgetc(f->fp); - c2 = fgetc(f->fp); - if (c1 == EOF || c2 == EOF) - return -1; - *ret = c1 << 8 | c2; - return 0; + int c1, c2; + + c1 = fgetc(f->fp); + c2 = fgetc(f->fp); + if (c1 == EOF || c2 == EOF) + return -1; + *ret = c1 << 8 | c2; + return 0; } int read_uint16(uint16 * ret, dbFILE * f) { - int c1, c2; - - c1 = fgetc(f->fp); - c2 = fgetc(f->fp); - if (c1 == EOF || c2 == EOF) - return -1; - *ret = c1 << 8 | c2; - return 0; + int c1, c2; + + c1 = fgetc(f->fp); + c2 = fgetc(f->fp); + if (c1 == EOF || c2 == EOF) + return -1; + *ret = c1 << 8 | c2; + return 0; } int write_int16(uint16 val, dbFILE * f) { - if (fputc((val >> 8) & 0xFF, f->fp) == EOF - || fputc(val & 0xFF, f->fp) == EOF) - return -1; - return 0; + if (fputc((val >> 8) & 0xFF, f->fp) == EOF + || fputc(val & 0xFF, f->fp) == EOF) + return -1; + return 0; } int read_int32(int32 * ret, dbFILE * f) { - int c1, c2, c3, c4; - - c1 = fgetc(f->fp); - c2 = fgetc(f->fp); - c3 = fgetc(f->fp); - c4 = fgetc(f->fp); - if (c1 == EOF || c2 == EOF || c3 == EOF || c4 == EOF) - return -1; - *ret = c1 << 24 | c2 << 16 | c3 << 8 | c4; - return 0; + int c1, c2, c3, c4; + + c1 = fgetc(f->fp); + c2 = fgetc(f->fp); + c3 = fgetc(f->fp); + c4 = fgetc(f->fp); + if (c1 == EOF || c2 == EOF || c3 == EOF || c4 == EOF) + return -1; + *ret = c1 << 24 | c2 << 16 | c3 << 8 | c4; + return 0; } int read_uint32(uint32 * ret, dbFILE * f) { - int c1, c2, c3, c4; - - c1 = fgetc(f->fp); - c2 = fgetc(f->fp); - c3 = fgetc(f->fp); - c4 = fgetc(f->fp); - if (c1 == EOF || c2 == EOF || c3 == EOF || c4 == EOF) - return -1; - *ret = c1 << 24 | c2 << 16 | c3 << 8 | c4; - return 0; + int c1, c2, c3, c4; + + c1 = fgetc(f->fp); + c2 = fgetc(f->fp); + c3 = fgetc(f->fp); + c4 = fgetc(f->fp); + if (c1 == EOF || c2 == EOF || c3 == EOF || c4 == EOF) + return -1; + *ret = c1 << 24 | c2 << 16 | c3 << 8 | c4; + return 0; } int write_int32(uint32 val, dbFILE * f) { - if (fputc((val >> 24) & 0xFF, f->fp) == EOF) - return -1; - if (fputc((val >> 16) & 0xFF, f->fp) == EOF) - return -1; - if (fputc((val >> 8) & 0xFF, f->fp) == EOF) - return -1; - if (fputc((val) & 0xFF, f->fp) == EOF) - return -1; - return 0; + if (fputc((val >> 24) & 0xFF, f->fp) == EOF) + return -1; + if (fputc((val >> 16) & 0xFF, f->fp) == EOF) + return -1; + if (fputc((val >> 8) & 0xFF, f->fp) == EOF) + return -1; + if (fputc((val) & 0xFF, f->fp) == EOF) + return -1; + return 0; } int read_ptr(void **ret, dbFILE * f) { - int c; + int c; - c = fgetc(f->fp); - if (c == EOF) - return -1; - *ret = (c ? (void *) 1 : (void *) 0); - return 0; + c = fgetc(f->fp); + if (c == EOF) + return -1; + *ret = (c ? (void *) 1 : (void *) 0); + return 0; } int write_ptr(const void *ptr, dbFILE * f) { - if (fputc(ptr ? 1 : 0, f->fp) == EOF) - return -1; - return 0; + if (fputc(ptr ? 1 : 0, f->fp) == EOF) + return -1; + return 0; } int read_string(char **ret, dbFILE * f) { - char *s; - uint16 len; - - if (read_uint16(&len, f) < 0) - return -1; - if (len == 0) { - *ret = NULL; - return 0; - } - s = (char *)calloc(len, 1); - if (len != fread(s, 1, len, f->fp)) { - free(s); - return -1; - } - *ret = s; - return 0; + char *s; + uint16 len; + + if (read_uint16(&len, f) < 0) + return -1; + if (len == 0) { + *ret = NULL; + return 0; + } + s = (char *)calloc(len, 1); + if (len != fread(s, 1, len, f->fp)) { + free(s); + return -1; + } + *ret = s; + return 0; } int write_string(const char *s, dbFILE * f) { - uint32 len; - - if (!s) - return write_int16(0, f); - len = strlen(s); - if (len > 65534) - len = 65534; - if (write_int16((uint16) (len + 1), f) < 0) - return -1; - if (len > 0 && fwrite(s, 1, len, f->fp) != len) - return -1; - if (fputc(0, f->fp) == EOF) - return -1; - return 0; + uint32 len; + + if (!s) + return write_int16(0, f); + len = strlen(s); + if (len > 65534) + len = 65534; + if (write_int16((uint16) (len + 1), f) < 0) + return -1; + if (len > 0 && fwrite(s, 1, len, f->fp) != len) + return -1; + if (fputc(0, f->fp) == EOF) + return -1; + return 0; } NickCore *findcore(const char *nick, int unused) { - NickCore *nc; + NickCore *nc; - for (nc = nclists[HASH(nick)]; nc; nc = nc->next) { - if (!mystricmp(nc->display, nick)) - if ((nc->unused && unused) || (!nc->unused && !unused)) - return nc; - } + for (nc = nclists[HASH(nick)]; nc; nc = nc->next) { + if (!mystricmp(nc->display, nick)) + if ((nc->unused && unused) || (!nc->unused && !unused)) + return nc; + } - return NULL; + return NULL; } NickAlias *findnick(const char *nick) { - NickAlias *na; + NickAlias *na; - for (na = nalists[HASH(nick)]; na; na = na->next) { - if (!mystricmp(na->nick, nick)) - return na; - } + for (na = nalists[HASH(nick)]; na; na = na->next) { + if (!mystricmp(na->nick, nick)) + return na; + } - return NULL; + return NULL; } int write_file_version(dbFILE * f, uint32 version) { - FILE *fp = f->fp; - if (fputc(version >> 24 & 0xFF, fp) < 0 || - fputc(version >> 16 & 0xFF, fp) < 0 || - fputc(version >> 8 & 0xFF, fp) < 0 || - fputc(version & 0xFF, fp) < 0) { - printf("Error writing version number on %s.\n", f->filename); - exit(0); - } - return 1; + FILE *fp = f->fp; + if (fputc(version >> 24 & 0xFF, fp) < 0 || + fputc(version >> 16 & 0xFF, fp) < 0 || + fputc(version >> 8 & 0xFF, fp) < 0 || + fputc(version & 0xFF, fp) < 0) { + printf("Error writing version number on %s.\n", f->filename); + exit(0); + } + return 1; } /* strscpy: Copy at most len-1 characters from a string to a buffer, and - * add a null terminator after the last character copied. + * add a null terminator after the last character copied. */ char *strscpy(char *d, const char *s, size_t len) { - char *d_orig = d; + char *d_orig = d; - if (!len) - return d; - while (--len && (*d++ = *s++)); - *d = '\0'; - return d_orig; + if (!len) + return d; + while (--len && (*d++ = *s++)); + *d = '\0'; + return d_orig; } int mystricmp(const char *s1, const char *s2) { - register int c; - - while ((c = tolower(*s1)) == tolower(*s2)) { - if (c == 0) - return 0; - s1++; - s2++; - } - if (c < tolower(*s2)) - return -1; - return 1; + register int c; + + while ((c = tolower(*s1)) == tolower(*s2)) { + if (c == 0) + return 0; + s1++; + s2++; + } + if (c < tolower(*s2)) + return -1; + return 1; } int delnick(NickAlias *na, int donttouchthelist) { - if (!donttouchthelist) { - /* Remove us from the aliases list */ - if (na->next) - na->next->prev = na->prev; - if (na->prev) - na->prev->next = na->next; - else - nalists[HASH(na->nick)] = na->next; - } - - /* free() us */ - free(na->nick); - if (na->last_usermask) - free(na->last_usermask); - if (na->last_realname) - free(na->last_realname); - if (na->last_quit) - free(na->last_quit); - free(na); - return 1; + if (!donttouchthelist) { + /* Remove us from the aliases list */ + if (na->next) + na->next->prev = na->prev; + if (na->prev) + na->prev->next = na->next; + else + nalists[HASH(na->nick)] = na->next; + } + + /* free() us */ + free(na->nick); + if (na->last_usermask) + free(na->last_usermask); + if (na->last_realname) + free(na->last_realname); + if (na->last_quit) + free(na->last_quit); + free(na); + return 1; } int delcore(NickCore *nc) { - int i; - /* Remove the core from the list */ - if (nc->next) - nc->next->prev = nc->prev; - if (nc->prev) - nc->prev->next = nc->next; - else - nclists[HASH(nc->display)] = nc->next; - - free(nc->display); - if (nc->pass) - free(nc->pass); - if (nc->email) - free(nc->email); - if (nc->greet) - free(nc->greet); - if (nc->url) - free(nc->url); - if (nc->access) { - for (i = 0; i < nc->accesscount; i++) { - if (nc->access[i]) - free(nc->access[i]); - } - free(nc->access); - } - if (nc->memos.memos) { - for (i = 0; i < nc->memos.memocount; i++) { - if (nc->memos.memos[i].text) - free(nc->memos.memos[i].text); - } - free(nc->memos.memos); - } - free(nc); - return 1; + int i; + /* Remove the core from the list */ + if (nc->next) + nc->next->prev = nc->prev; + if (nc->prev) + nc->prev->next = nc->next; + else + nclists[HASH(nc->display)] = nc->next; + + free(nc->display); + if (nc->pass) + free(nc->pass); + if (nc->email) + free(nc->email); + if (nc->greet) + free(nc->greet); + if (nc->url) + free(nc->url); + if (nc->access) { + for (i = 0; i < nc->accesscount; i++) { + if (nc->access[i]) + free(nc->access[i]); + } + free(nc->access); + } + if (nc->memos.memos) { + for (i = 0; i < nc->memos.memocount; i++) { + if (nc->memos.memos[i].text) + free(nc->memos.memos[i].text); + } + free(nc->memos.memos); + } + free(nc); + return 1; } void insert_bot(BotInfo * bi) { - BotInfo *ptr, *prev; - - for (prev = NULL, ptr = botlists[tolower(*bi->nick)]; - ptr != NULL && mystricmp(ptr->nick, bi->nick) < 0; - prev = ptr, ptr = ptr->next); - bi->prev = prev; - bi->next = ptr; - if (!prev) - botlists[tolower(*bi->nick)] = bi; - else - prev->next = bi; - if (ptr) - ptr->prev = bi; + BotInfo *ptr, *prev; + + for (prev = NULL, ptr = botlists[tolower(*bi->nick)]; + ptr != NULL && mystricmp(ptr->nick, bi->nick) < 0; + prev = ptr, ptr = ptr->next); + bi->prev = prev; + bi->next = ptr; + if (!prev) + botlists[tolower(*bi->nick)] = bi; + else + prev->next = bi; + if (ptr) + ptr->prev = bi; } BotInfo *findbot(char *nick) { - BotInfo *bi; + BotInfo *bi; - for (bi = botlists[tolower(*nick)]; bi; bi = bi->next) - if (!mystricmp(nick, bi->nick)) - return bi; + for (bi = botlists[tolower(*nick)]; bi; bi = bi->next) + if (!mystricmp(nick, bi->nick)) + return bi; - return NULL; + return NULL; } ChannelInfo *cs_findchan(const char *chan) { - ChannelInfo *ci; - for (ci = chanlists[tolower(chan[1])]; ci; ci = ci->next) { - if (!mystricmp(ci->name, chan)) - return ci; - } - return NULL; + ChannelInfo *ci; + for (ci = chanlists[tolower(chan[1])]; ci; ci = ci->next) { + if (!mystricmp(ci->name, chan)) + return ci; + } + return NULL; } void alpha_insert_chan(ChannelInfo * ci) { - ChannelInfo *ptr, *prev; - char *chan = ci->name; - - for (prev = NULL, ptr = chanlists[tolower(chan[1])]; - ptr != NULL && mystricmp(ptr->name, chan) < 0; - prev = ptr, ptr = ptr->next); - ci->prev = prev; - ci->next = ptr; - if (!prev) - chanlists[tolower(chan[1])] = ci; - else - prev->next = ci; - if (ptr) - ptr->prev = ci; + ChannelInfo *ptr, *prev; + char *chan = ci->name; + + for (prev = NULL, ptr = chanlists[tolower(chan[1])]; + ptr != NULL && mystricmp(ptr->name, chan) < 0; + prev = ptr, ptr = ptr->next); + ci->prev = prev; + ci->next = ptr; + if (!prev) + chanlists[tolower(chan[1])] = ci; + else + prev->next = ci; + if (ptr) + ptr->prev = ci; } diff --git a/src/tools/obsolete/epona2anope.c b/src/tools/obsolete/epona2anope.c index d89be6d12..946a0c731 100644 --- a/src/tools/obsolete/epona2anope.c +++ b/src/tools/obsolete/epona2anope.c @@ -18,11 +18,11 @@ * At the moment this only affects chanserv dbs. * * - Certus - * February 26, 2005 + * February 26, 2005 * * Added win32 fix. Who needs that anyways? :P * - Certus - * July 20, 2006 + * July 20, 2006 */ @@ -63,8 +63,8 @@ /* CONFIGURATION BLOCK */ -#define CHAN_DB_EPONA "chan1.db" -#define CHAN_DB_ANOPE "chan.db" +#define CHAN_DB_EPONA "chan1.db" +#define CHAN_DB_ANOPE "chan.db" /* END OF CONFIGURATION BLOCK */ @@ -86,15 +86,15 @@ #define read_int8(ret,f) ((*(ret)=fgetc((f)->fp))==EOF ? -1 : 0) #define write_int8(val,f) (fputc((val),(f)->fp)==EOF ? -1 : 0) #define SAFE(x) do { \ - if ((x) < 0) { \ + if ((x) < 0) { \ printf("Error, the database is broken, trying to continue... no guarantee.\n"); \ - } \ + } \ } while (0) #define READ(x) do { \ - if ((x) < 0) { \ - printf("Error, the database is broken, trying to continue... no guarantee.\n"); \ - exit(0); \ - } \ + if ((x) < 0) { \ + printf("Error, the database is broken, trying to continue... no guarantee.\n"); \ + exit(0); \ + } \ } while (0) typedef int16_t int16; @@ -111,103 +111,103 @@ typedef struct badword_ BadWord; typedef struct hostcore_ HostCore; struct memo_ { - uint32 number; /* Index number -- not necessarily array position! */ - int16 flags; /* Flags */ - time_t time; /* When was it sent? */ - char sender[32]; /* Name of the sender */ - char *text; + uint32 number; /* Index number -- not necessarily array position! */ + int16 flags; /* Flags */ + time_t time; /* When was it sent? */ + char sender[32]; /* Name of the sender */ + char *text; }; struct dbFILE_ { - int mode; /* 'r' for reading, 'w' for writing */ - FILE *fp; /* The normal file descriptor */ - char filename[1024]; /* Name of the database file */ + int mode; /* 'r' for reading, 'w' for writing */ + FILE *fp; /* The normal file descriptor */ + char filename[1024]; /* Name of the database file */ }; typedef struct { - int16 memocount; /* Current # of memos */ - int16 memomax; /* Max # of memos one can hold*/ - Memo *memos; /* Pointer to original memos */ + int16 memocount; /* Current # of memos */ + int16 memomax; /* Max # of memos one can hold*/ + Memo *memos; /* Pointer to original memos */ } MemoInfo; typedef struct { - int16 in_use; /* 1 if this entry is in use, else 0 */ - int16 level; - NickCore *nc; /* Guaranteed to be non-NULL if in use, NULL if not */ - time_t last_seen; + int16 in_use; /* 1 if this entry is in use, else 0 */ + int16 level; + NickCore *nc; /* Guaranteed to be non-NULL if in use, NULL if not */ + time_t last_seen; } ChanAccess; 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 in_use; /* Always 0 if not in use */ + int16 is_nick; /* 1 if a regged nickname, 0 if a nick!user@host mask */ int16 flags; - union { - char *mask; /* Guaranteed to be non-NULL if in use, NULL if not */ + union { + char *mask; /* Guaranteed to be non-NULL if in use, NULL if not */ NickCore *nc; /* Same */ - } u; - char *reason; - char *creator; - time_t addtime; + } u; + char *reason; + char *creator; + time_t addtime; } AutoKick; struct nickcore_ { NickCore *next, *prev; - char *display; /* How the nick is displayed */ - int unused; /* Used for nick collisions */ + char *display; /* How the nick is displayed */ + int unused; /* Used for nick collisions */ }; struct chaninfo_ { - ChannelInfo *next, *prev; - - char name[64]; /* Channel name */ - char *founder; /* Who registered the channel */ - char *successor; /* Who gets the channel if the founder nick is dropped or expires */ - char founderpass[32]; /* Channel password */ - char *desc; /* Description */ - char *url; /* URL */ - char *email; /* Email address */ - time_t time_registered; /* When was it registered */ - time_t last_used; /* When was it used hte last time */ - char *last_topic; /* Last topic on the channel */ - char last_topic_setter[32]; /* Who set the last topic */ - time_t last_topic_time; /* When the last topic was set */ - uint32 flags; /* Flags */ - char *forbidby; /* if forbidden: who did it */ - char *forbidreason; /* if forbidden: why */ - int16 bantype; /* Bantype */ - int16 *levels; /* Access levels for commands */ - int16 accesscount; /* # of pple with access */ - ChanAccess *access; /* List of authorized users */ - int16 akickcount; /* # of akicked pple */ - AutoKick *akick; /* List of users to kickban */ - uint32 mlock_on, mlock_off; /* See channel modes below */ - uint32 mlock_limit; /* 0 if no limit */ - char *mlock_key; /* NULL if no key */ - char *mlock_flood; /* NULL if no +f */ - char *mlock_joinrate; /* NULL if no +j */ - char *mlock_redirect; /* NULL if no +L */ - char *entry_message; /* Notice sent on entering channel */ - MemoInfo memos; /* Memos */ - char *bi; /* Bot used on this channel */ - uint32 botflags; /* BS_* below */ - int16 *ttb; /* Times to ban for each kicker */ - int16 bwcount; /* Badword count */ - BadWord *badwords; /* For BADWORDS kicker */ - int16 capsmin, capspercent; /* For CAPS kicker */ - int16 floodlines, floodsecs; /* For FLOOD kicker */ - int16 repeattimes; /* For REPEAT kicker */ + ChannelInfo *next, *prev; + + char name[64]; /* Channel name */ + char *founder; /* Who registered the channel */ + char *successor; /* Who gets the channel if the founder nick is dropped or expires */ + char founderpass[32]; /* Channel password */ + char *desc; /* Description */ + char *url; /* URL */ + char *email; /* Email address */ + time_t time_registered; /* When was it registered */ + time_t last_used; /* When was it used hte last time */ + char *last_topic; /* Last topic on the channel */ + char last_topic_setter[32]; /* Who set the last topic */ + time_t last_topic_time; /* When the last topic was set */ + uint32 flags; /* Flags */ + char *forbidby; /* if forbidden: who did it */ + char *forbidreason; /* if forbidden: why */ + int16 bantype; /* Bantype */ + int16 *levels; /* Access levels for commands */ + int16 accesscount; /* # of pple with access */ + ChanAccess *access; /* List of authorized users */ + int16 akickcount; /* # of akicked pple */ + AutoKick *akick; /* List of users to kickban */ + uint32 mlock_on, mlock_off; /* See channel modes below */ + uint32 mlock_limit; /* 0 if no limit */ + char *mlock_key; /* NULL if no key */ + char *mlock_flood; /* NULL if no +f */ + char *mlock_joinrate; /* NULL if no +j */ + char *mlock_redirect; /* NULL if no +L */ + char *entry_message; /* Notice sent on entering channel */ + MemoInfo memos; /* Memos */ + char *bi; /* Bot used on this channel */ + uint32 botflags; /* BS_* below */ + int16 *ttb; /* Times to ban for each kicker */ + int16 bwcount; /* Badword count */ + BadWord *badwords; /* For BADWORDS kicker */ + int16 capsmin, capspercent; /* For CAPS kicker */ + int16 floodlines, floodsecs; /* For FLOOD kicker */ + int16 repeattimes; /* For REPEAT kicker */ }; struct botinfo_ { BotInfo *next, *prev; - char *nick; /* Nickname of the bot */ - char *user; /* Its user name */ - char *host; /* Its hostname */ - char *real; /* Its real name */ - int16 flags; /* Bot flags */ - time_t created; /* Birth date */ - int16 chancount; /* Number of channels that use the bot. */ + char *nick; /* Nickname of the bot */ + char *user; /* Its user name */ + char *host; /* Its hostname */ + char *real; /* Its real name */ + int16 flags; /* Bot flags */ + time_t created; /* Birth date */ + int16 chancount; /* Number of channels that use the bot. */ }; struct badword_ { @@ -241,616 +241,616 @@ NickCore *nclists[1024]; int main(int argc, char *argv[]) { - dbFILE *f; - int i; - long countr = 0, countw = 0; + dbFILE *f; + int i; + long countr = 0, countw = 0; /* Unused variables - why? -GD - NickCore *nc, *ncnext; + NickCore *nc, *ncnext; */ - printf("\n"C_LBLUE"Epona to Anope DB converter by Certus"C_NONE"\n\n"); + printf("\n"C_LBLUE"Epona to Anope DB converter by Certus"C_NONE"\n\n"); - /* Section I: Reading */ - if ((f = open_db_read("ChanServ", CHAN_DB_EPONA, 17))) { - ChannelInfo *ci, **last, *prev; - int c; + /* Section I: Reading */ + if ((f = open_db_read("ChanServ", CHAN_DB_EPONA, 17))) { + ChannelInfo *ci, **last, *prev; + int c; - printf("Trying to convert channel database...\n"); + printf("Trying to convert channel database...\n"); - for (i = 0; i < 256; i++) { - int16 tmp16; - int32 tmp32; - int n_levels; - char *s; - int n_ttb; + for (i = 0; i < 256; i++) { + int16 tmp16; + int32 tmp32; + int n_levels; + char *s; + int n_ttb; /* Unused variable - why? -GD - int J; + int J; */ - last = &chanlists[i]; - prev = NULL; - - while ((c = getc_db(f)) == 1) { - int j; - - if (c != 1) { - printf("Invalid format in %s.\n", CHAN_DB_EPONA); - exit(0); - } - - ci = calloc(sizeof(ChannelInfo), 1); - *last = ci; - last = &ci->next; - ci->prev = prev; - prev = ci; - READ(read_buffer(ci->name, f)); - READ(read_string(&ci->founder, f)); - READ(read_string(&ci->successor, f)); - READ(read_buffer(ci->founderpass, f)); - READ(read_string(&ci->desc, f)); - if (!ci->desc) - ci->desc = strdup(""); - READ(read_string(&ci->url, f)); - READ(read_string(&ci->email, f)); - READ(read_int32(&tmp32, f)); - ci->time_registered = tmp32; - READ(read_int32(&tmp32, f)); - ci->last_used = tmp32; - READ(read_string(&ci->last_topic, f)); - READ(read_buffer(ci->last_topic_setter, f)); - READ(read_int32(&tmp32, f)); - ci->last_topic_time = tmp32; - READ(read_uint32(&ci->flags, f)); - /* Temporary flags cleanup */ - ci->flags &= ~0x80000000; - READ(read_string(&ci->forbidby, f)); - READ(read_string(&ci->forbidreason, f)); - READ(read_int16(&tmp16, f)); - ci->bantype = tmp16; - READ(read_int16(&tmp16, f)); - n_levels = tmp16; - ci->levels = calloc(36 * sizeof(*ci->levels), 1); - for (j = 0; j < n_levels; j++) { - if (j < 36) - READ(read_int16(&ci->levels[j], f)); - else - READ(read_int16(&tmp16, f)); - } - READ(read_int16(&ci->accesscount, f)); - if (ci->accesscount) { - ci->access = calloc(ci->accesscount, sizeof(ChanAccess)); - for (j = 0; j < ci->accesscount; j++) { - READ(read_int16(&ci->access[j].in_use, f)); - if (ci->access[j].in_use) { - READ(read_int16(&ci->access[j].level, f)); - READ(read_string(&s, f)); - if (s) { - ci->access[j].nc = findcore(s, 0); - free(s); - } - if (ci->access[j].nc == NULL) - ci->access[j].in_use = 0; - READ(read_int32(&tmp32, f)); - ci->access[j].last_seen = tmp32; - } - } - } else { - ci->access = NULL; - } - READ(read_int16(&ci->akickcount, f)); - if (ci->akickcount) { - ci->akick = calloc(ci->akickcount, sizeof(AutoKick)); - for (j = 0; j < ci->akickcount; j++) { - SAFE(read_int16(&ci->akick[j].flags, f)); - if (ci->akick[j].flags & 0x0001) { - SAFE(read_string(&s, f)); - if (ci->akick[j].flags & 0x0002) { - ci->akick[j].u.nc = findcore(s, 0); - if (!ci->akick[j].u.nc) - ci->akick[j].flags &= ~0x0001; - free(s); - } else { - ci->akick[j].u.mask = s; - } - SAFE(read_string(&s, f)); - if (ci->akick[j].flags & 0x0001) - ci->akick[j].reason = s; - else if (s) - free(s); - SAFE(read_string(&s, f)); - if (ci->akick[j].flags & 0x0001) { - ci->akick[j].creator = s; - } else if (s) { - free(s); - } - SAFE(read_int32(&tmp32, f)); - if (ci->akick[j].flags & 0x0001) - ci->akick[j].addtime = tmp32; - } - } - } else { - ci->akick = NULL; - } - READ(read_uint32(&ci->mlock_on, f)); - READ(read_uint32(&ci->mlock_off, f)); - READ(read_uint32(&ci->mlock_limit, f)); - READ(read_string(&ci->mlock_key, f)); - READ(read_string(&ci->mlock_flood, f)); - READ(read_string(&ci->mlock_joinrate, f)); - READ(read_string(&ci->mlock_redirect, f)); - READ(read_int16(&ci->memos.memocount, f)); - READ(read_int16(&ci->memos.memomax, f)); - if (ci->memos.memocount) { - Memo *memos; - memos = calloc(sizeof(Memo) * ci->memos.memocount, 1); - ci->memos.memos = memos; - for (j = 0; j < ci->memos.memocount; j++, memos++) { - READ(read_uint32(&memos->number, f)); - READ(read_int16(&memos->flags, f)); - READ(read_int32(&tmp32, f)); - memos->time = tmp32; - READ(read_buffer(memos->sender, f)); - READ(read_string(&memos->text, f)); - } - } - READ(read_string(&ci->entry_message, f)); - - /* BotServ options */ - READ(read_string(&ci->bi, f)); - READ(read_int32(&tmp32, f)); - ci->botflags = tmp32; - READ(read_int16(&tmp16, f)); - n_ttb = tmp16; - ci->ttb = calloc(2 * 8, 1); - for (j = 0; j < n_ttb; j++) { - if (j < 8) - READ(read_int16(&ci->ttb[j], f)); - else - READ(read_int16(&tmp16, f)); - } - for (j = n_ttb; j < 8; j++) - ci->ttb[j] = 0; - READ(read_int16(&tmp16, f)); - ci->capsmin = tmp16; - READ(read_int16(&tmp16, f)); - ci->capspercent = tmp16; - READ(read_int16(&tmp16, f)); - ci->floodlines = tmp16; - READ(read_int16(&tmp16, f)); - ci->floodsecs = tmp16; - READ(read_int16(&tmp16, f)); - ci->repeattimes = tmp16; - - READ(read_int16(&ci->bwcount, f)); - if (ci->bwcount) { - ci->badwords = calloc(ci->bwcount, sizeof(BadWord)); - for (j = 0; j < ci->bwcount; j++) { - SAFE(read_int16(&ci->badwords[j].in_use, f)); - if (ci->badwords[j].in_use) { - SAFE(read_string(&ci->badwords[j].word, f)); - SAFE(read_int16(&ci->badwords[j].type, f)); - } - } - } else { - ci->badwords = NULL; - } - countr++; - } /* getc_db() */ - *last = NULL; - } /* for() loop */ - close_db(f); - } - - /* II: Saving */ - { - if ((f = open_db_write("ChanServ", CHAN_DB_ANOPE, 16))) { - ChannelInfo *ci; - Memo *memos; + last = &chanlists[i]; + prev = NULL; + + while ((c = getc_db(f)) == 1) { + int j; + + if (c != 1) { + printf("Invalid format in %s.\n", CHAN_DB_EPONA); + exit(0); + } + + ci = calloc(sizeof(ChannelInfo), 1); + *last = ci; + last = &ci->next; + ci->prev = prev; + prev = ci; + READ(read_buffer(ci->name, f)); + READ(read_string(&ci->founder, f)); + READ(read_string(&ci->successor, f)); + READ(read_buffer(ci->founderpass, f)); + READ(read_string(&ci->desc, f)); + if (!ci->desc) + ci->desc = strdup(""); + READ(read_string(&ci->url, f)); + READ(read_string(&ci->email, f)); + READ(read_int32(&tmp32, f)); + ci->time_registered = tmp32; + READ(read_int32(&tmp32, f)); + ci->last_used = tmp32; + READ(read_string(&ci->last_topic, f)); + READ(read_buffer(ci->last_topic_setter, f)); + READ(read_int32(&tmp32, f)); + ci->last_topic_time = tmp32; + READ(read_uint32(&ci->flags, f)); + /* Temporary flags cleanup */ + ci->flags &= ~0x80000000; + READ(read_string(&ci->forbidby, f)); + READ(read_string(&ci->forbidreason, f)); + READ(read_int16(&tmp16, f)); + ci->bantype = tmp16; + READ(read_int16(&tmp16, f)); + n_levels = tmp16; + ci->levels = calloc(36 * sizeof(*ci->levels), 1); + for (j = 0; j < n_levels; j++) { + if (j < 36) + READ(read_int16(&ci->levels[j], f)); + else + READ(read_int16(&tmp16, f)); + } + READ(read_int16(&ci->accesscount, f)); + if (ci->accesscount) { + ci->access = calloc(ci->accesscount, sizeof(ChanAccess)); + for (j = 0; j < ci->accesscount; j++) { + READ(read_int16(&ci->access[j].in_use, f)); + if (ci->access[j].in_use) { + READ(read_int16(&ci->access[j].level, f)); + READ(read_string(&s, f)); + if (s) { + ci->access[j].nc = findcore(s, 0); + free(s); + } + if (ci->access[j].nc == NULL) + ci->access[j].in_use = 0; + READ(read_int32(&tmp32, f)); + ci->access[j].last_seen = tmp32; + } + } + } else { + ci->access = NULL; + } + READ(read_int16(&ci->akickcount, f)); + if (ci->akickcount) { + ci->akick = calloc(ci->akickcount, sizeof(AutoKick)); + for (j = 0; j < ci->akickcount; j++) { + SAFE(read_int16(&ci->akick[j].flags, f)); + if (ci->akick[j].flags & 0x0001) { + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & 0x0002) { + ci->akick[j].u.nc = findcore(s, 0); + if (!ci->akick[j].u.nc) + ci->akick[j].flags &= ~0x0001; + free(s); + } else { + ci->akick[j].u.mask = s; + } + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & 0x0001) + ci->akick[j].reason = s; + else if (s) + free(s); + SAFE(read_string(&s, f)); + if (ci->akick[j].flags & 0x0001) { + ci->akick[j].creator = s; + } else if (s) { + free(s); + } + SAFE(read_int32(&tmp32, f)); + if (ci->akick[j].flags & 0x0001) + ci->akick[j].addtime = tmp32; + } + } + } else { + ci->akick = NULL; + } + READ(read_uint32(&ci->mlock_on, f)); + READ(read_uint32(&ci->mlock_off, f)); + READ(read_uint32(&ci->mlock_limit, f)); + READ(read_string(&ci->mlock_key, f)); + READ(read_string(&ci->mlock_flood, f)); + READ(read_string(&ci->mlock_joinrate, f)); + READ(read_string(&ci->mlock_redirect, f)); + READ(read_int16(&ci->memos.memocount, f)); + READ(read_int16(&ci->memos.memomax, f)); + if (ci->memos.memocount) { + Memo *memos; + memos = calloc(sizeof(Memo) * ci->memos.memocount, 1); + ci->memos.memos = memos; + for (j = 0; j < ci->memos.memocount; j++, memos++) { + READ(read_uint32(&memos->number, f)); + READ(read_int16(&memos->flags, f)); + READ(read_int32(&tmp32, f)); + memos->time = tmp32; + READ(read_buffer(memos->sender, f)); + READ(read_string(&memos->text, f)); + } + } + READ(read_string(&ci->entry_message, f)); + + /* BotServ options */ + READ(read_string(&ci->bi, f)); + READ(read_int32(&tmp32, f)); + ci->botflags = tmp32; + READ(read_int16(&tmp16, f)); + n_ttb = tmp16; + ci->ttb = calloc(2 * 8, 1); + for (j = 0; j < n_ttb; j++) { + if (j < 8) + READ(read_int16(&ci->ttb[j], f)); + else + READ(read_int16(&tmp16, f)); + } + for (j = n_ttb; j < 8; j++) + ci->ttb[j] = 0; + READ(read_int16(&tmp16, f)); + ci->capsmin = tmp16; + READ(read_int16(&tmp16, f)); + ci->capspercent = tmp16; + READ(read_int16(&tmp16, f)); + ci->floodlines = tmp16; + READ(read_int16(&tmp16, f)); + ci->floodsecs = tmp16; + READ(read_int16(&tmp16, f)); + ci->repeattimes = tmp16; + + READ(read_int16(&ci->bwcount, f)); + if (ci->bwcount) { + ci->badwords = calloc(ci->bwcount, sizeof(BadWord)); + for (j = 0; j < ci->bwcount; j++) { + SAFE(read_int16(&ci->badwords[j].in_use, f)); + if (ci->badwords[j].in_use) { + SAFE(read_string(&ci->badwords[j].word, f)); + SAFE(read_int16(&ci->badwords[j].type, f)); + } + } + } else { + ci->badwords = NULL; + } + countr++; + } /* getc_db() */ + *last = NULL; + } /* for() loop */ + close_db(f); + } + + /* II: Saving */ + { + if ((f = open_db_write("ChanServ", CHAN_DB_ANOPE, 16))) { + ChannelInfo *ci; + Memo *memos; /* Unused variable - why? -GD - static time_t lastwarn = 0; + static time_t lastwarn = 0; */ - for (i = 0; i < 256; i++) { - int16 tmp16; - for (ci = chanlists[i]; ci; ci = ci->next) { - int j; - SAFE(write_int8(1, f)); - SAFE(write_buffer(ci->name, f)); - if (ci->founder) - SAFE(write_string(ci->founder, f)); - else - SAFE(write_string(NULL, f)); - if (ci->successor) - SAFE(write_string(ci->successor, f)); - else - SAFE(write_string(NULL, f)); - SAFE(write_buffer(ci->founderpass, f)); - SAFE(write_string(ci->desc, f)); - SAFE(write_string(ci->url, f)); - SAFE(write_string(ci->email, f)); - SAFE(write_int32(ci->time_registered, f)); - SAFE(write_int32(ci->last_used, f)); - SAFE(write_string(ci->last_topic, f)); - SAFE(write_buffer(ci->last_topic_setter, f)); - SAFE(write_int32(ci->last_topic_time, f)); - SAFE(write_int32(ci->flags, f)); - SAFE(write_string(ci->forbidby, f)); - SAFE(write_string(ci->forbidreason, f)); - SAFE(write_int16(ci->bantype, f)); - tmp16 = 36; - SAFE(write_int16(tmp16, f)); - for (j = 0; j < 36; j++) - SAFE(write_int16(ci->levels[j], f)); - - SAFE(write_int16(ci->accesscount, f)); - for (j = 0; j < ci->accesscount; j++) { - SAFE(write_int16(ci->access[j].in_use, f)); - if (ci->access[j].in_use) { - SAFE(write_int16(ci->access[j].level, f)); - SAFE(write_string(ci->access[j].nc->display, f)); - SAFE(write_int32(ci->access[j].last_seen, f)); - } - } - SAFE(write_int16(ci->akickcount, f)); - for (j = 0; j < ci->akickcount; j++) { - SAFE(write_int16(ci->akick[j].flags, f)); - if (ci->akick[j].flags & 0x0001) { - if (ci->akick[j].flags & 0x0002) - SAFE(write_string(ci->akick[j].u.nc->display, f)); - else - SAFE(write_string(ci->akick[j].u.mask, f)); - SAFE(write_string(ci->akick[j].reason, f)); - SAFE(write_string(ci->akick[j].creator, f)); - SAFE(write_int32(ci->akick[j].addtime, f)); - } - } - - SAFE(write_int32(ci->mlock_on, f)); - SAFE(write_int32(ci->mlock_off, f)); - SAFE(write_int32(ci->mlock_limit, f)); - SAFE(write_string(ci->mlock_key, f)); - SAFE(write_string(ci->mlock_flood, f)); - SAFE(write_string(ci->mlock_redirect, f)); - SAFE(write_int16(ci->memos.memocount, f)); - SAFE(write_int16(ci->memos.memomax, f)); - memos = ci->memos.memos; - for (j = 0; j < ci->memos.memocount; j++, memos++) { - SAFE(write_int32(memos->number, f)); - SAFE(write_int16(memos->flags, f)); - SAFE(write_int32(memos->time, f)); - SAFE(write_buffer(memos->sender, f)); - SAFE(write_string(memos->text, f)); - } - SAFE(write_string(ci->entry_message, f)); - if (ci->bi) - SAFE(write_string(ci->bi, f)); - else - SAFE(write_string(NULL, f)); - SAFE(write_int32(ci->botflags, f)); - tmp16 = 8; - SAFE(write_int16(tmp16, f)); - for (j = 0; j < 8; j++) - SAFE(write_int16(ci->ttb[j], f)); - SAFE(write_int16(ci->capsmin, f)); - SAFE(write_int16(ci->capspercent, f)); - SAFE(write_int16(ci->floodlines, f)); - SAFE(write_int16(ci->floodsecs, f)); - SAFE(write_int16(ci->repeattimes, f)); - - SAFE(write_int16(ci->bwcount, f)); - for (j = 0; j < ci->bwcount; j++) { - SAFE(write_int16(ci->badwords[j].in_use, f)); - if (ci->badwords[j].in_use) { - SAFE(write_string(ci->badwords[j].word, f)); - SAFE(write_int16(ci->badwords[j].type, f)); - } - } - countw++; - } /* for (chanlists[i]) */ - SAFE(write_int8(0, f)); - } /* for (i) */ - close_db(f); - printf("%ld channels read, %ld channels written. New database saved as %s.\n", countr, countw, CHAN_DB_ANOPE); - } - } - - printf("\n\nConverting is now done.\n"); + for (i = 0; i < 256; i++) { + int16 tmp16; + for (ci = chanlists[i]; ci; ci = ci->next) { + int j; + SAFE(write_int8(1, f)); + SAFE(write_buffer(ci->name, f)); + if (ci->founder) + SAFE(write_string(ci->founder, f)); + else + SAFE(write_string(NULL, f)); + if (ci->successor) + SAFE(write_string(ci->successor, f)); + else + SAFE(write_string(NULL, f)); + SAFE(write_buffer(ci->founderpass, f)); + SAFE(write_string(ci->desc, f)); + SAFE(write_string(ci->url, f)); + SAFE(write_string(ci->email, f)); + SAFE(write_int32(ci->time_registered, f)); + SAFE(write_int32(ci->last_used, f)); + SAFE(write_string(ci->last_topic, f)); + SAFE(write_buffer(ci->last_topic_setter, f)); + SAFE(write_int32(ci->last_topic_time, f)); + SAFE(write_int32(ci->flags, f)); + SAFE(write_string(ci->forbidby, f)); + SAFE(write_string(ci->forbidreason, f)); + SAFE(write_int16(ci->bantype, f)); + tmp16 = 36; + SAFE(write_int16(tmp16, f)); + for (j = 0; j < 36; j++) + SAFE(write_int16(ci->levels[j], f)); + + SAFE(write_int16(ci->accesscount, f)); + for (j = 0; j < ci->accesscount; j++) { + SAFE(write_int16(ci->access[j].in_use, f)); + if (ci->access[j].in_use) { + SAFE(write_int16(ci->access[j].level, f)); + SAFE(write_string(ci->access[j].nc->display, f)); + SAFE(write_int32(ci->access[j].last_seen, f)); + } + } + SAFE(write_int16(ci->akickcount, f)); + for (j = 0; j < ci->akickcount; j++) { + SAFE(write_int16(ci->akick[j].flags, f)); + if (ci->akick[j].flags & 0x0001) { + if (ci->akick[j].flags & 0x0002) + SAFE(write_string(ci->akick[j].u.nc->display, f)); + else + SAFE(write_string(ci->akick[j].u.mask, f)); + SAFE(write_string(ci->akick[j].reason, f)); + SAFE(write_string(ci->akick[j].creator, f)); + SAFE(write_int32(ci->akick[j].addtime, f)); + } + } + + SAFE(write_int32(ci->mlock_on, f)); + SAFE(write_int32(ci->mlock_off, f)); + SAFE(write_int32(ci->mlock_limit, f)); + SAFE(write_string(ci->mlock_key, f)); + SAFE(write_string(ci->mlock_flood, f)); + SAFE(write_string(ci->mlock_redirect, f)); + SAFE(write_int16(ci->memos.memocount, f)); + SAFE(write_int16(ci->memos.memomax, f)); + memos = ci->memos.memos; + for (j = 0; j < ci->memos.memocount; j++, memos++) { + SAFE(write_int32(memos->number, f)); + SAFE(write_int16(memos->flags, f)); + SAFE(write_int32(memos->time, f)); + SAFE(write_buffer(memos->sender, f)); + SAFE(write_string(memos->text, f)); + } + SAFE(write_string(ci->entry_message, f)); + if (ci->bi) + SAFE(write_string(ci->bi, f)); + else + SAFE(write_string(NULL, f)); + SAFE(write_int32(ci->botflags, f)); + tmp16 = 8; + SAFE(write_int16(tmp16, f)); + for (j = 0; j < 8; j++) + SAFE(write_int16(ci->ttb[j], f)); + SAFE(write_int16(ci->capsmin, f)); + SAFE(write_int16(ci->capspercent, f)); + SAFE(write_int16(ci->floodlines, f)); + SAFE(write_int16(ci->floodsecs, f)); + SAFE(write_int16(ci->repeattimes, f)); + + SAFE(write_int16(ci->bwcount, f)); + for (j = 0; j < ci->bwcount; j++) { + SAFE(write_int16(ci->badwords[j].in_use, f)); + if (ci->badwords[j].in_use) { + SAFE(write_string(ci->badwords[j].word, f)); + SAFE(write_int16(ci->badwords[j].type, f)); + } + } + countw++; + } /* for (chanlists[i]) */ + SAFE(write_int8(0, f)); + } /* for (i) */ + close_db(f); + printf("%ld channels read, %ld channels written. New database saved as %s.\n", countr, countw, CHAN_DB_ANOPE); + } + } + + printf("\n\nConverting is now done.\n"); return 0; } /* End of main() */ /* Open a database file for reading and check for the version */ dbFILE *open_db_read(const char *service, const char *filename, int version) { - dbFILE *f; - FILE *fp; - int myversion; - - f = calloc(sizeof(*f), 1); - if (!f) { - printf("Can't allocate memory for %s database %s.\n", service, filename); - exit(0); - } - strscpy(f->filename, filename, sizeof(f->filename)); - f->mode = 'r'; - fp = fopen(f->filename, "rb"); - if (!fp) { - printf("Can't read %s database %s.\n", service, f->filename); - free(f); - return NULL; - } - f->fp = fp; - myversion = fgetc(fp) << 24 | fgetc(fp) << 16 | fgetc(fp) << 8 | fgetc(fp); - if (feof(fp)) { - printf("Error reading version number on %s: End of file detected.\n", f->filename); - exit(0); - } else if (myversion < version) { - printf("Unsuported database version (%d) on %s.\n", myversion, f->filename); - exit(0); - } - return f; + dbFILE *f; + FILE *fp; + int myversion; + + f = calloc(sizeof(*f), 1); + if (!f) { + printf("Can't allocate memory for %s database %s.\n", service, filename); + exit(0); + } + strscpy(f->filename, filename, sizeof(f->filename)); + f->mode = 'r'; + fp = fopen(f->filename, "rb"); + if (!fp) { + printf("Can't read %s database %s.\n", service, f->filename); + free(f); + return NULL; + } + f->fp = fp; + myversion = fgetc(fp) << 24 | fgetc(fp) << 16 | fgetc(fp) << 8 | fgetc(fp); + if (feof(fp)) { + printf("Error reading version number on %s: End of file detected.\n", f->filename); + exit(0); + } else if (myversion < version) { + printf("Unsuported database version (%d) on %s.\n", myversion, f->filename); + exit(0); + } + return f; } /* Open a database file for reading and check for the version */ dbFILE *open_db_write(const char *service, const char *filename, int version) { - dbFILE *f; - int fd; - - f = calloc(sizeof(*f), 1); - if (!f) { - printf("Can't allocate memory for %s database %s.\n", service, filename); - exit(0); - } - strscpy(f->filename, filename, sizeof(f->filename)); - filename = f->filename; + dbFILE *f; + int fd; + + f = calloc(sizeof(*f), 1); + if (!f) { + printf("Can't allocate memory for %s database %s.\n", service, filename); + exit(0); + } + strscpy(f->filename, filename, sizeof(f->filename)); + filename = f->filename; #ifndef _WIN32 - unlink(filename); + unlink(filename); #else - DeleteFile(filename); + DeleteFile(filename); #endif - f->mode = 'w'; + f->mode = 'w'; #ifndef _WIN32 - fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666); + fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666); #else - fd = open(filename, O_WRONLY | O_CREAT | O_EXCL | _O_BINARY, 0666); + fd = open(filename, O_WRONLY | O_CREAT | O_EXCL | _O_BINARY, 0666); #endif - f->fp = fdopen(fd, "wb"); /* will fail and return NULL if fd < 0 */ - if (!f->fp || !write_file_version(f, version)) { - printf("Can't write to %s database %s.\n", service, filename); - if (f->fp) { - fclose(f->fp); + f->fp = fdopen(fd, "wb"); /* will fail and return NULL if fd < 0 */ + if (!f->fp || !write_file_version(f, version)) { + printf("Can't write to %s database %s.\n", service, filename); + if (f->fp) { + fclose(f->fp); #ifndef _WIN32 - unlink(filename); + unlink(filename); #else - DeleteFile(filename); + DeleteFile(filename); #endif - } - free(f); - return NULL; - } - return f; + } + free(f); + return NULL; + } + return f; } /* Close it */ void close_db(dbFILE * f) { - fclose(f->fp); - free(f); + fclose(f->fp); + free(f); } int read_int16(int16 * ret, dbFILE * f) { - int c1, c2; - - c1 = fgetc(f->fp); - c2 = fgetc(f->fp); - if (c1 == EOF || c2 == EOF) - return -1; - *ret = c1 << 8 | c2; - return 0; + int c1, c2; + + c1 = fgetc(f->fp); + c2 = fgetc(f->fp); + if (c1 == EOF || c2 == EOF) + return -1; + *ret = c1 << 8 | c2; + return 0; } int read_uint16(uint16 * ret, dbFILE * f) { - int c1, c2; - - c1 = fgetc(f->fp); - c2 = fgetc(f->fp); - if (c1 == EOF || c2 == EOF) - return -1; - *ret = c1 << 8 | c2; - return 0; + int c1, c2; + + c1 = fgetc(f->fp); + c2 = fgetc(f->fp); + if (c1 == EOF || c2 == EOF) + return -1; + *ret = c1 << 8 | c2; + return 0; } int write_int16(uint16 val, dbFILE * f) { - if (fputc((val >> 8) & 0xFF, f->fp) == EOF - || fputc(val & 0xFF, f->fp) == EOF) - return -1; - return 0; + if (fputc((val >> 8) & 0xFF, f->fp) == EOF + || fputc(val & 0xFF, f->fp) == EOF) + return -1; + return 0; } int read_int32(int32 * ret, dbFILE * f) { - int c1, c2, c3, c4; - - c1 = fgetc(f->fp); - c2 = fgetc(f->fp); - c3 = fgetc(f->fp); - c4 = fgetc(f->fp); - if (c1 == EOF || c2 == EOF || c3 == EOF || c4 == EOF) - return -1; - *ret = c1 << 24 | c2 << 16 | c3 << 8 | c4; - return 0; + int c1, c2, c3, c4; + + c1 = fgetc(f->fp); + c2 = fgetc(f->fp); + c3 = fgetc(f->fp); + c4 = fgetc(f->fp); + if (c1 == EOF || c2 == EOF || c3 == EOF || c4 == EOF) + return -1; + *ret = c1 << 24 | c2 << 16 | c3 << 8 | c4; + return 0; } int read_uint32(uint32 * ret, dbFILE * f) { - int c1, c2, c3, c4; - - c1 = fgetc(f->fp); - c2 = fgetc(f->fp); - c3 = fgetc(f->fp); - c4 = fgetc(f->fp); - if (c1 == EOF || c2 == EOF || c3 == EOF || c4 == EOF) - return -1; - *ret = c1 << 24 | c2 << 16 | c3 << 8 | c4; - return 0; + int c1, c2, c3, c4; + + c1 = fgetc(f->fp); + c2 = fgetc(f->fp); + c3 = fgetc(f->fp); + c4 = fgetc(f->fp); + if (c1 == EOF || c2 == EOF || c3 == EOF || c4 == EOF) + return -1; + *ret = c1 << 24 | c2 << 16 | c3 << 8 | c4; + return 0; } int write_int32(uint32 val, dbFILE * f) { - if (fputc((val >> 24) & 0xFF, f->fp) == EOF) - return -1; - if (fputc((val >> 16) & 0xFF, f->fp) == EOF) - return -1; - if (fputc((val >> 8) & 0xFF, f->fp) == EOF) - return -1; - if (fputc((val) & 0xFF, f->fp) == EOF) - return -1; - return 0; + if (fputc((val >> 24) & 0xFF, f->fp) == EOF) + return -1; + if (fputc((val >> 16) & 0xFF, f->fp) == EOF) + return -1; + if (fputc((val >> 8) & 0xFF, f->fp) == EOF) + return -1; + if (fputc((val) & 0xFF, f->fp) == EOF) + return -1; + return 0; } int read_ptr(void **ret, dbFILE * f) { - int c; + int c; - c = fgetc(f->fp); - if (c == EOF) - return -1; - *ret = (c ? (void *) 1 : (void *) 0); - return 0; + c = fgetc(f->fp); + if (c == EOF) + return -1; + *ret = (c ? (void *) 1 : (void *) 0); + return 0; } int write_ptr(const void *ptr, dbFILE * f) { - if (fputc(ptr ? 1 : 0, f->fp) == EOF) - return -1; - return 0; + if (fputc(ptr ? 1 : 0, f->fp) == EOF) + return -1; + return 0; } int read_string(char **ret, dbFILE * f) { - char *s; - uint16 len; - - if (read_uint16(&len, f) < 0) - return -1; - if (len == 0) { - *ret = NULL; - return 0; - } - s = calloc(len, 1); - if (len != fread(s, 1, len, f->fp)) { - free(s); - return -1; - } - *ret = s; - return 0; + char *s; + uint16 len; + + if (read_uint16(&len, f) < 0) + return -1; + if (len == 0) { + *ret = NULL; + return 0; + } + s = calloc(len, 1); + if (len != fread(s, 1, len, f->fp)) { + free(s); + return -1; + } + *ret = s; + return 0; } int write_string(const char *s, dbFILE * f) { - uint32 len; - - if (!s) - return write_int16(0, f); - len = strlen(s); - if (len > 65534) - len = 65534; - if (write_int16((uint16) (len + 1), f) < 0) - return -1; - if (len > 0 && fwrite(s, 1, len, f->fp) != len) - return -1; - if (fputc(0, f->fp) == EOF) - return -1; - return 0; + uint32 len; + + if (!s) + return write_int16(0, f); + len = strlen(s); + if (len > 65534) + len = 65534; + if (write_int16((uint16) (len + 1), f) < 0) + return -1; + if (len > 0 && fwrite(s, 1, len, f->fp) != len) + return -1; + if (fputc(0, f->fp) == EOF) + return -1; + return 0; } NickCore *findcore(const char *nick, int unused) { - NickCore *nc; + NickCore *nc; - for (nc = nclists[HASH(nick)]; nc; nc = nc->next) { - if (!mystricmp(nc->display, nick)) - if ((nc->unused && unused) || (!nc->unused && !unused)) - return nc; - } + for (nc = nclists[HASH(nick)]; nc; nc = nc->next) { + if (!mystricmp(nc->display, nick)) + if ((nc->unused && unused) || (!nc->unused && !unused)) + return nc; + } - return NULL; + return NULL; } int write_file_version(dbFILE * f, uint32 version) { - FILE *fp = f->fp; - if (fputc(version >> 24 & 0xFF, fp) < 0 || - fputc(version >> 16 & 0xFF, fp) < 0 || - fputc(version >> 8 & 0xFF, fp) < 0 || - fputc(version & 0xFF, fp) < 0) { - printf("Error writing version number on %s.\n", f->filename); - exit(0); - } - return 1; + FILE *fp = f->fp; + if (fputc(version >> 24 & 0xFF, fp) < 0 || + fputc(version >> 16 & 0xFF, fp) < 0 || + fputc(version >> 8 & 0xFF, fp) < 0 || + fputc(version & 0xFF, fp) < 0) { + printf("Error writing version number on %s.\n", f->filename); + exit(0); + } + return 1; } /* strscpy: Copy at most len-1 characters from a string to a buffer, and - * add a null terminator after the last character copied. + * add a null terminator after the last character copied. */ char *strscpy(char *d, const char *s, size_t len) { - char *d_orig = d; + char *d_orig = d; - if (!len) - return d; - while (--len && (*d++ = *s++)); - *d = '\0'; - return d_orig; + if (!len) + return d; + while (--len && (*d++ = *s++)); + *d = '\0'; + return d_orig; } int mystricmp(const char *s1, const char *s2) { - register int c; - - while ((c = tolower(*s1)) == tolower(*s2)) { - if (c == 0) - return 0; - s1++; - s2++; - } - if (c < tolower(*s2)) - return -1; - return 1; + register int c; + + while ((c = tolower(*s1)) == tolower(*s2)) { + if (c == 0) + return 0; + s1++; + s2++; + } + if (c < tolower(*s2)) + return -1; + return 1; } ChannelInfo *cs_findchan(const char *chan) { - ChannelInfo *ci; - for (ci = chanlists[tolower(chan[1])]; ci; ci = ci->next) { - if (!mystricmp(ci->name, chan)) - return ci; - } - return NULL; + ChannelInfo *ci; + for (ci = chanlists[tolower(chan[1])]; ci; ci = ci->next) { + if (!mystricmp(ci->name, chan)) + return ci; + } + return NULL; } void alpha_insert_chan(ChannelInfo * ci) { - ChannelInfo *ptr, *prev; - char *chan = ci->name; - - for (prev = NULL, ptr = chanlists[tolower(chan[1])]; - ptr != NULL && mystricmp(ptr->name, chan) < 0; - prev = ptr, ptr = ptr->next); - ci->prev = prev; - ci->next = ptr; - if (!prev) - chanlists[tolower(chan[1])] = ci; - else - prev->next = ci; - if (ptr) - ptr->prev = ci; + ChannelInfo *ptr, *prev; + char *chan = ci->name; + + for (prev = NULL, ptr = chanlists[tolower(chan[1])]; + ptr != NULL && mystricmp(ptr->name, chan) < 0; + prev = ptr, ptr = ptr->next); + ci->prev = prev; + ci->next = ptr; + if (!prev) + chanlists[tolower(chan[1])] = ci; + else + prev->next = ci; + if (ptr) + ptr->prev = ci; } diff --git a/src/tools/smtp.h b/src/tools/smtp.h index a16be487a..ef6a0d0aa 100644 --- a/src/tools/smtp.h +++ b/src/tools/smtp.h @@ -107,21 +107,21 @@ typedef int ano_socket_t; /* Data structures */ struct smtp_header { - char *header; - struct smtp_header *next; + char *header; + struct smtp_header *next; }; struct smtp_body_line { - char *line; - struct smtp_body_line *next; + char *line; + struct smtp_body_line *next; }; struct smtp_message { - struct smtp_header *smtp_headers, *smtp_headers_tail; - struct smtp_body_line *smtp_body, *smtp_body_tail; - char *from; - char *to; - ano_socket_t sock; + struct smtp_header *smtp_headers, *smtp_headers_tail; + struct smtp_body_line *smtp_body, *smtp_body_tail; + char *from; + char *to; + ano_socket_t sock; }; struct smtp_message mail; diff --git a/src/users.c b/src/users.c index f03b39837..fba9a6611 100644 --- a/src/users.c +++ b/src/users.c @@ -70,8 +70,8 @@ User::User(const std::string &snick) alog("user: New maximum user count: %d", maxusercnt); } - this->isSuperAdmin = 0; /* always set SuperAdmin to 0 for new users */ - this->nickTrack = NULL; /* ensure no default tracking nick */ + this->isSuperAdmin = 0; /* always set SuperAdmin to 0 for new users */ + this->nickTrack = NULL; /* ensure no default tracking nick */ } void User::SetNewNick(const std::string &newnick) @@ -114,8 +114,8 @@ void User::SetNewNick(const std::string &newnick) this->na->u = this; } - if (debug) - alog("debug: %s changed nick to %s", this->nick, newnick.c_str()); + if (debug) + alog("debug: %s changed nick to %s", this->nick, newnick.c_str()); } void User::SetDisplayedHost(const std::string &shost) @@ -123,14 +123,14 @@ void User::SetDisplayedHost(const std::string &shost) if (shost.empty()) throw "empty host? in MY services? it seems it's more likely than I thought."; - if (this->vhost) - free(this->vhost); - this->vhost = sstrdup(shost.c_str()); + if (this->vhost) + free(this->vhost); + this->vhost = sstrdup(shost.c_str()); - if (debug) - alog("debug: %s changed vhost to %s", this->nick, shost.c_str()); + if (debug) + alog("debug: %s changed vhost to %s", this->nick, shost.c_str()); - update_host(this); + update_host(this); } void User::SetIdent(const std::string &ident) @@ -315,18 +315,18 @@ void User::SendMessage(const char *source, const std::string &msg) */ void update_host(User * user) { - if (user->na && (nick_identified(user) - || (!(user->na->nc->flags & NI_SECURE) - && nick_recognized(user)))) { - if (user->na->last_usermask) - free(user->na->last_usermask); - - user->na->last_usermask = - (char *)smalloc(strlen(common_get_vident(user)) + - strlen(common_get_vhost(user)) + 2); - sprintf(user->na->last_usermask, "%s@%s", common_get_vident(user), - common_get_vhost(user)); - } + if (user->na && (nick_identified(user) + || (!(user->na->nc->flags & NI_SECURE) + && nick_recognized(user)))) { + if (user->na->last_usermask) + free(user->na->last_usermask); + + user->na->last_usermask = + (char *)smalloc(strlen(common_get_vident(user)) + + strlen(common_get_vhost(user)) + 2); + sprintf(user->na->last_usermask, "%s@%s", common_get_vident(user), + common_get_vhost(user)); + } } /*************************************************************************/ @@ -337,36 +337,36 @@ void update_host(User * user) void get_user_stats(long *nusers, long *memuse) { - long count = 0, mem = 0; - int i; - User *user; - struct u_chanlist *uc; - struct u_chaninfolist *uci; - - for (i = 0; i < 1024; i++) { - for (user = userlist[i]; user; user = user->next) { - count++; - mem += sizeof(*user); - if (user->username) - mem += strlen(user->username) + 1; - if (user->host) - mem += strlen(user->host) + 1; - if (ircd->vhost) { - if (user->vhost) - mem += strlen(user->vhost) + 1; - } - if (user->realname) - mem += strlen(user->realname) + 1; - if (user->server->name) - mem += strlen(user->server->name) + 1; - for (uc = user->chans; uc; uc = uc->next) - mem += sizeof(*uc); - for (uci = user->founder_chans; uci; uci = uci->next) - mem += sizeof(*uci); - } - } - *nusers = count; - *memuse = mem; + long count = 0, mem = 0; + int i; + User *user; + struct u_chanlist *uc; + struct u_chaninfolist *uci; + + for (i = 0; i < 1024; i++) { + for (user = userlist[i]; user; user = user->next) { + count++; + mem += sizeof(*user); + if (user->username) + mem += strlen(user->username) + 1; + if (user->host) + mem += strlen(user->host) + 1; + if (ircd->vhost) { + if (user->vhost) + mem += strlen(user->vhost) + 1; + } + if (user->realname) + mem += strlen(user->realname) + 1; + if (user->server->name) + mem += strlen(user->server->name) + 1; + for (uc = user->chans; uc; uc = uc->next) + mem += sizeof(*uc); + for (uci = user->founder_chans; uci; uci = uci->next) + mem += sizeof(*uci); + } + } + *nusers = count; + *memuse = mem; } /*************************************************************************/ @@ -375,23 +375,23 @@ void get_user_stats(long *nusers, long *memuse) User *finduser(const char *nick) { - User *user; - - if (!nick || !*nick) { - if (debug) { - alog("debug: finduser() called with NULL values"); - } - return NULL; - } - - if (debug >= 3) - alog("debug: finduser(%p)", nick); - user = userlist[HASH(nick)]; - while (user && stricmp(user->nick, nick) != 0) - user = user->next; - if (debug >= 3) - alog("debug: finduser(%s) -> 0x%p", nick, (void *) user); - return user; + User *user; + + if (!nick || !*nick) { + if (debug) { + alog("debug: finduser() called with NULL values"); + } + return NULL; + } + + if (debug >= 3) + alog("debug: finduser(%p)", nick); + user = userlist[HASH(nick)]; + while (user && stricmp(user->nick, nick) != 0) + user = user->next; + if (debug >= 3) + alog("debug: finduser(%s) -> 0x%p", nick, (void *) user); + return user; } @@ -404,51 +404,51 @@ static int next_index; User *firstuser(void) { - next_index = 0; - current = NULL; - while (next_index < 1024 && current == NULL) - current = userlist[next_index++]; - if (debug) - alog("debug: firstuser() returning %s", - current ? current->nick : "NULL (end of list)"); - return current; + next_index = 0; + current = NULL; + while (next_index < 1024 && current == NULL) + current = userlist[next_index++]; + if (debug) + alog("debug: firstuser() returning %s", + current ? current->nick : "NULL (end of list)"); + return current; } User *nextuser(void) { - if (current) - current = current->next; - if (!current && next_index < 1024) { - while (next_index < 1024 && current == NULL) - current = userlist[next_index++]; - } - if (debug) - alog("debug: nextuser() returning %s", - current ? current->nick : "NULL (end of list)"); - return current; + if (current) + current = current->next; + if (!current && next_index < 1024) { + while (next_index < 1024 && current == NULL) + current = userlist[next_index++]; + } + if (debug) + alog("debug: nextuser() returning %s", + current ? current->nick : "NULL (end of list)"); + return current; } User *find_byuid(const char *uid) { - User *u, *next; - - if (!uid) { - if (debug) - alog("debug: find_byuid() called with NULL-value"); - return NULL; - } - - u = first_uid(); - while (u) { - next = next_uid(); - if (u->uid) { - if (!stricmp(uid, u->uid)) { - return u; - } - } - u = next; - } - return NULL; + User *u, *next; + + if (!uid) { + if (debug) + alog("debug: find_byuid() called with NULL-value"); + return NULL; + } + + u = first_uid(); + while (u) { + next = next_uid(); + if (u->uid) { + if (!stricmp(uid, u->uid)) { + return u; + } + } + u = next; + } + return NULL; } static User *current_uid; @@ -456,33 +456,33 @@ static int next_index_uid; User *first_uid(void) { - next_index_uid = 0; - current_uid = NULL; - while (next_index_uid < 1024 && current_uid == NULL) { - current_uid = userlist[next_index_uid++]; - } - if (debug >= 2) { - alog("debug: first_uid() returning %s %s", - current_uid ? current_uid->nick : "NULL (end of list)", - current_uid ? current_uid->uid : ""); - } - return current_uid; + next_index_uid = 0; + current_uid = NULL; + while (next_index_uid < 1024 && current_uid == NULL) { + current_uid = userlist[next_index_uid++]; + } + if (debug >= 2) { + alog("debug: first_uid() returning %s %s", + current_uid ? current_uid->nick : "NULL (end of list)", + current_uid ? current_uid->uid : ""); + } + return current_uid; } User *next_uid(void) { - if (current_uid) - current_uid = current_uid->next; - if (!current_uid && next_index_uid < 1024) { - while (next_index_uid < 1024 && current_uid == NULL) - current_uid = userlist[next_index_uid++]; - } - if (debug >= 2) { - alog("debug: next_uid() returning %s %s", - current_uid ? current_uid->nick : "NULL (end of list)", - current_uid ? current_uid->uid : ""); - } - return current_uid; + if (current_uid) + current_uid = current_uid->next; + if (!current_uid && next_index_uid < 1024) { + while (next_index_uid < 1024 && current_uid == NULL) + current_uid = userlist[next_index_uid++]; + } + if (debug >= 2) { + alog("debug: next_uid() returning %s %s", + current_uid ? current_uid->nick : "NULL (end of list)", + current_uid ? current_uid->uid : ""); + } + return current_uid; } /*************************************************************************/ @@ -491,297 +491,297 @@ User *next_uid(void) /* Handle a server NICK command. */ User *do_nick(const char *source, const char *nick, const char *username, const char *host, - const char *server, const char *realname, time_t ts, uint32 svid, - uint32 ip, const char *vhost, const char *uid) + const char *server, const char *realname, time_t ts, uint32 svid, + uint32 ip, const char *vhost, const char *uid) { - User *user = NULL; - - char *tmp = NULL; - NickAlias *old_na; /* Old nick rec */ - int nc_changed = 1; /* Did nick core change? */ - int status = 0; /* Status to apply */ - char mask[USERMAX + HOSTMAX + 2]; - char *logrealname; - - if (!*source) { - char ipbuf[16]; - struct in_addr addr; - - if (ircd->nickvhost) { - if (vhost) { - if (!strcmp(vhost, "*")) { - vhost = NULL; - if (debug) - alog("debug: new user�with no vhost in NICK command: %s", nick); - } - } - } - - /* This is a new user; create a User structure for it. */ - if (debug) - alog("debug: new user: %s", nick); - - if (ircd->nickip) { - addr.s_addr = htonl(ip); - ntoa(addr, ipbuf, sizeof(ipbuf)); - } - - - if (LogUsers) { - /** + User *user = NULL; + + char *tmp = NULL; + NickAlias *old_na; /* Old nick rec */ + int nc_changed = 1; /* Did nick core change? */ + int status = 0; /* Status to apply */ + char mask[USERMAX + HOSTMAX + 2]; + char *logrealname; + + if (!*source) { + char ipbuf[16]; + struct in_addr addr; + + if (ircd->nickvhost) { + if (vhost) { + if (!strcmp(vhost, "*")) { + vhost = NULL; + if (debug) + alog("debug: new user�with no vhost in NICK command: %s", nick); + } + } + } + + /* This is a new user; create a User structure for it. */ + if (debug) + alog("debug: new user: %s", nick); + + if (ircd->nickip) { + addr.s_addr = htonl(ip); + ntoa(addr, ipbuf, sizeof(ipbuf)); + } + + + if (LogUsers) { + /** * Ugly swap routine for Flop's bug :) **/ - if (realname) { - tmp = strchr(realname, '%'); - while (tmp) { - *tmp = '-'; - tmp = strchr(realname, '%'); - } - } - logrealname = normalizeBuffer(realname); - - /** + if (realname) { + tmp = strchr(realname, '%'); + while (tmp) { + *tmp = '-'; + tmp = strchr(realname, '%'); + } + } + logrealname = normalizeBuffer(realname); + + /** * End of ugly swap **/ - if (ircd->nickvhost) { - if (ircd->nickip) { - alog("LOGUSERS: %s (%s@%s => %s) (%s) [%s] connected to the network (%s).", nick, username, host, (vhost ? vhost : "none"), logrealname, ipbuf, server); - } else { - alog("LOGUSERS: %s (%s@%s => %s) (%s) connected to the network (%s).", nick, username, host, (vhost ? vhost : "none"), logrealname, server); - } - } else { - if (ircd->nickip) { - alog("LOGUSERS: %s (%s@%s) (%s) [%s] connected to the network (%s).", nick, username, host, logrealname, ipbuf, server); - } else { - alog("LOGUSERS: %s (%s@%s) (%s) connected to the network (%s).", nick, username, host, logrealname, server); - } - } - Anope_Free(logrealname); - } - - /* We used to ignore the ~ which a lot of ircd's use to indicate no - * identd response. That caused channel bans to break, so now we - * just take what the server gives us. People are still encouraged - * to read the RFCs and stop doing anything to usernames depending - * on the result of an identd lookup. - */ - - /* First check for AKILLs. */ - /* DONT just return null if its an akill match anymore - yes its more efficent to, however, now that ircd's are - * starting to use things like E/F lines, we cant be 100% sure the client will be removed from the network :/ - * as such, create a user_struct, and if the client is removed, we'll delete it again when the QUIT notice - * comes in from the ircd. - **/ - if (check_akill(nick, username, host, vhost, ipbuf)) { -/* return NULL; */ - } + if (ircd->nickvhost) { + if (ircd->nickip) { + alog("LOGUSERS: %s (%s@%s => %s) (%s) [%s] connected to the network (%s).", nick, username, host, (vhost ? vhost : "none"), logrealname, ipbuf, server); + } else { + alog("LOGUSERS: %s (%s@%s => %s) (%s) connected to the network (%s).", nick, username, host, (vhost ? vhost : "none"), logrealname, server); + } + } else { + if (ircd->nickip) { + alog("LOGUSERS: %s (%s@%s) (%s) [%s] connected to the network (%s).", nick, username, host, logrealname, ipbuf, server); + } else { + alog("LOGUSERS: %s (%s@%s) (%s) connected to the network (%s).", nick, username, host, logrealname, server); + } + } + Anope_Free(logrealname); + } + + /* We used to ignore the ~ which a lot of ircd's use to indicate no + * identd response. That caused channel bans to break, so now we + * just take what the server gives us. People are still encouraged + * to read the RFCs and stop doing anything to usernames depending + * on the result of an identd lookup. + */ + + /* First check for AKILLs. */ + /* DONT just return null if its an akill match anymore - yes its more efficent to, however, now that ircd's are + * starting to use things like E/F lines, we cant be 100% sure the client will be removed from the network :/ + * as such, create a user_struct, and if the client is removed, we'll delete it again when the QUIT notice + * comes in from the ircd. + **/ + if (check_akill(nick, username, host, vhost, ipbuf)) { +/* return NULL; */ + } /** * DefCon AKILL system, if we want to akill all connecting user's here's where to do it * then force check_akill again on them... **/ - /* don't akill on netmerges -Certus */ - /* don't akill clients introduced by ulines. -Viper */ - if (is_sync(findserver(servlist, server)) - && checkDefCon(DEFCON_AKILL_NEW_CLIENTS) && !is_ulined(server)) { - strncpy(mask, "*@", 3); - strncat(mask, host, HOSTMAX); - alog("DEFCON: adding akill for %s", mask); - add_akill(NULL, mask, s_OperServ, - time(NULL) + DefConAKILL, - DefConAkillReason ? DefConAkillReason : - "DEFCON AKILL"); - if (check_akill(nick, username, host, vhost, ipbuf)) { -/* return NULL; */ - } - } - - /* SGLINE */ - if (ircd->sgline) { - if (check_sgline(nick, realname)) - return NULL; - } - - /* SQLINE */ - if (ircd->sqline) { - if (check_sqline(nick, 0)) - return NULL; - } - - /* SZLINE */ - if (ircd->szline && ircd->nickip) { - if (check_szline(nick, ipbuf)) - return NULL; - } - /* Now check for session limits */ - if (LimitSessions && !is_ulined(server) - && !add_session(nick, host, ipbuf)) - return NULL; - - /* Allocate User structure and fill it in. */ + /* don't akill on netmerges -Certus */ + /* don't akill clients introduced by ulines. -Viper */ + if (is_sync(findserver(servlist, server)) + && checkDefCon(DEFCON_AKILL_NEW_CLIENTS) && !is_ulined(server)) { + strncpy(mask, "*@", 3); + strncat(mask, host, HOSTMAX); + alog("DEFCON: adding akill for %s", mask); + add_akill(NULL, mask, s_OperServ, + time(NULL) + DefConAKILL, + DefConAkillReason ? DefConAkillReason : + "DEFCON AKILL"); + if (check_akill(nick, username, host, vhost, ipbuf)) { +/* return NULL; */ + } + } + + /* SGLINE */ + if (ircd->sgline) { + if (check_sgline(nick, realname)) + return NULL; + } + + /* SQLINE */ + if (ircd->sqline) { + if (check_sqline(nick, 0)) + return NULL; + } + + /* SZLINE */ + if (ircd->szline && ircd->nickip) { + if (check_szline(nick, ipbuf)) + return NULL; + } + /* Now check for session limits */ + if (LimitSessions && !is_ulined(server) + && !add_session(nick, host, ipbuf)) + return NULL; + + /* Allocate User structure and fill it in. */ user = new User(nick); - user->username = sstrdup(username); - user->host = sstrdup(host); - user->server = findserver(servlist, server); - user->realname = sstrdup(realname); - user->timestamp = ts; - user->my_signon = time(NULL); - user->vhost = vhost ? sstrdup(vhost) : sstrdup(host); - if (uid) { - user->uid = sstrdup(uid); /* p10/ts6 stuff */ - } else { - user->uid = NULL; - } - user->vident = sstrdup(username); - /* We now store the user's ip in the user_ struct, - * because we will use it in serveral places -- DrStein */ - if (ircd->nickip) { - user->hostip = sstrdup(ipbuf); - } else { - user->hostip = NULL; - } - - if (svid == 0) { - display_news(user, NEWS_LOGON); - display_news(user, NEWS_RANDOM); - } - - if (svid == ts && user->na) { - /* Timestamp and svid match, and nick is registered; automagically identify the nick */ - user->svid = svid; - user->na->status |= NS_IDENTIFIED; - check_memos(user); - nc_changed = 0; - - /* Start nick tracking if available */ - if (NSNickTracking) - nsStartNickTracking(user); - - } else if (svid != 1) { - /* Resets the svid because it doesn't match */ - user->svid = 1; - - ircdproto->SendSVID(user->nick, user->timestamp); - - } else { - user->svid = 1; - } - send_event(EVENT_NEWNICK, 1, nick); - - } else { - /* An old user changing nicks. */ - if (UseTS6) - user = find_byuid(source); - - if (!user) - user = finduser(source); - - if (!user) { - alog("user: NICK from nonexistent nick %s", source); - return NULL; - } - user->isSuperAdmin = 0; /* Dont let people nick change and stay SuperAdmins */ - if (debug) - alog("debug: %s changes nick to %s", source, nick); - - if (LogUsers) { - logrealname = normalizeBuffer(user->realname); - if (ircd->vhost) { - alog("LOGUSERS: %s (%s@%s => %s) (%s) changed nick to %s (%s).", user->nick, user->username, user->host, (user->vhost ? user->vhost : "(none)"), logrealname, nick, user->server->name); - } else { - alog("LOGUSERS: %s (%s@%s) (%s) changed nick to %s (%s).", - user->nick, user->username, user->host, logrealname, - nick, user->server->name); - } - if (logrealname) { - free(logrealname); - } - } - - user->timestamp = ts; - - if (stricmp(nick, user->nick) == 0) { - /* No need to redo things */ + user->username = sstrdup(username); + user->host = sstrdup(host); + user->server = findserver(servlist, server); + user->realname = sstrdup(realname); + user->timestamp = ts; + user->my_signon = time(NULL); + user->vhost = vhost ? sstrdup(vhost) : sstrdup(host); + if (uid) { + user->uid = sstrdup(uid); /* p10/ts6 stuff */ + } else { + user->uid = NULL; + } + user->vident = sstrdup(username); + /* We now store the user's ip in the user_ struct, + * because we will use it in serveral places -- DrStein */ + if (ircd->nickip) { + user->hostip = sstrdup(ipbuf); + } else { + user->hostip = NULL; + } + + if (svid == 0) { + display_news(user, NEWS_LOGON); + display_news(user, NEWS_RANDOM); + } + + if (svid == ts && user->na) { + /* Timestamp and svid match, and nick is registered; automagically identify the nick */ + user->svid = svid; + user->na->status |= NS_IDENTIFIED; + check_memos(user); + nc_changed = 0; + + /* Start nick tracking if available */ + if (NSNickTracking) + nsStartNickTracking(user); + + } else if (svid != 1) { + /* Resets the svid because it doesn't match */ + user->svid = 1; + + ircdproto->SendSVID(user->nick, user->timestamp); + + } else { + user->svid = 1; + } + send_event(EVENT_NEWNICK, 1, nick); + + } else { + /* An old user changing nicks. */ + if (UseTS6) + user = find_byuid(source); + + if (!user) + user = finduser(source); + + if (!user) { + alog("user: NICK from nonexistent nick %s", source); + return NULL; + } + user->isSuperAdmin = 0; /* Dont let people nick change and stay SuperAdmins */ + if (debug) + alog("debug: %s changes nick to %s", source, nick); + + if (LogUsers) { + logrealname = normalizeBuffer(user->realname); + if (ircd->vhost) { + alog("LOGUSERS: %s (%s@%s => %s) (%s) changed nick to %s (%s).", user->nick, user->username, user->host, (user->vhost ? user->vhost : "(none)"), logrealname, nick, user->server->name); + } else { + alog("LOGUSERS: %s (%s@%s) (%s) changed nick to %s (%s).", + user->nick, user->username, user->host, logrealname, + nick, user->server->name); + } + if (logrealname) { + free(logrealname); + } + } + + user->timestamp = ts; + + if (stricmp(nick, user->nick) == 0) { + /* No need to redo things */ user->SetNewNick(nick); - nc_changed = 0; - } else { - /* Update this only if nicks aren't the same */ - user->my_signon = time(NULL); - - old_na = user->na; - if (old_na) { - if (nick_recognized(user)) - user->na->last_seen = time(NULL); - status = old_na->status & NS_TRANSGROUP; - cancel_user(user); - } + nc_changed = 0; + } else { + /* Update this only if nicks aren't the same */ + user->my_signon = time(NULL); + + old_na = user->na; + if (old_na) { + if (nick_recognized(user)) + user->na->last_seen = time(NULL); + status = old_na->status & NS_TRANSGROUP; + cancel_user(user); + } user->SetNewNick(nick); - send_event(EVENT_CHANGE_NICK, 1, nick); - - if ((old_na ? old_na->nc : NULL) == - (user->na ? user->na->nc : NULL)) - nc_changed = 0; - - if (!nc_changed && (user->na)) - user->na->status |= status; - else { - ircdproto->SendUnregisteredNick(user); - } - } - - if (ircd->sqline) { - if (!is_oper(user) && check_sqline(user->nick, 1)) - return NULL; - } - - } /* if (!*source) */ - - /* Check for nick tracking to bypass identification */ - if (NSNickTracking && nsCheckNickTracking(user)) { - user->na->status |= NS_IDENTIFIED; - nc_changed = 0; - } - - if (nc_changed || !nick_recognized(user)) { - if (validate_user(user)) - check_memos(user); - - } else { - if (nick_identified(user)) { - char tsbuf[16]; - user->na->last_seen = time(NULL); - - if (user->na->last_usermask) - free(user->na->last_usermask); - user->na->last_usermask = - (char *)smalloc(strlen(common_get_vident(user)) + - strlen(common_get_vhost(user)) + 2); - sprintf(user->na->last_usermask, "%s@%s", - common_get_vident(user), common_get_vhost(user)); - - snprintf(tsbuf, sizeof(tsbuf), "%lu", - (unsigned long int) user->timestamp); - ircdproto->SendSVID2(user, tsbuf); - - alog("%s: %s!%s@%s automatically identified for nick %s", - s_NickServ, user->nick, user->username, - user->host, user->nick); - } - } - - /* Bahamut sets -r on every nick changes, so we must test it even if nc_changed == 0 */ - if (ircd->check_nick_id) { - if (nick_identified(user)) { - char tsbuf[16]; - snprintf(tsbuf, sizeof(tsbuf), "%lu", - (unsigned long int) user->timestamp); - ircdproto->SendSVID3(user, tsbuf); - } - } - - return user; + send_event(EVENT_CHANGE_NICK, 1, nick); + + if ((old_na ? old_na->nc : NULL) == + (user->na ? user->na->nc : NULL)) + nc_changed = 0; + + if (!nc_changed && (user->na)) + user->na->status |= status; + else { + ircdproto->SendUnregisteredNick(user); + } + } + + if (ircd->sqline) { + if (!is_oper(user) && check_sqline(user->nick, 1)) + return NULL; + } + + } /* if (!*source) */ + + /* Check for nick tracking to bypass identification */ + if (NSNickTracking && nsCheckNickTracking(user)) { + user->na->status |= NS_IDENTIFIED; + nc_changed = 0; + } + + if (nc_changed || !nick_recognized(user)) { + if (validate_user(user)) + check_memos(user); + + } else { + if (nick_identified(user)) { + char tsbuf[16]; + user->na->last_seen = time(NULL); + + if (user->na->last_usermask) + free(user->na->last_usermask); + user->na->last_usermask = + (char *)smalloc(strlen(common_get_vident(user)) + + strlen(common_get_vhost(user)) + 2); + sprintf(user->na->last_usermask, "%s@%s", + common_get_vident(user), common_get_vhost(user)); + + snprintf(tsbuf, sizeof(tsbuf), "%lu", + (unsigned long int) user->timestamp); + ircdproto->SendSVID2(user, tsbuf); + + alog("%s: %s!%s@%s automatically identified for nick %s", + s_NickServ, user->nick, user->username, + user->host, user->nick); + } + } + + /* Bahamut sets -r on every nick changes, so we must test it even if nc_changed == 0 */ + if (ircd->check_nick_id) { + if (nick_identified(user)) { + char tsbuf[16]; + snprintf(tsbuf, sizeof(tsbuf), "%lu", + (unsigned long int) user->timestamp); + ircdproto->SendSVID3(user, tsbuf); + } + } + + return user; } /*************************************************************************/ @@ -793,16 +793,16 @@ User *do_nick(const char *source, const char *nick, const char *username, const void do_umode(const char *source, int ac, const char **av) { - User *user; + User *user; - user = finduser(av[0]); - if (!user) { - alog("user: MODE %s for nonexistent nick %s: %s", av[1], av[0], - merge_args(ac, av)); - return; - } + user = finduser(av[0]); + if (!user) { + alog("user: MODE %s for nonexistent nick %s: %s", av[1], av[0], + merge_args(ac, av)); + return; + } - ircdproto->ProcessUsermodes(user, ac - 1, &av[1]); + ircdproto->ProcessUsermodes(user, ac - 1, &av[1]); } /* Handle a UMODE2 command for a user. @@ -811,16 +811,16 @@ void do_umode(const char *source, int ac, const char **av) void do_umode2(const char *source, int ac, const char **av) { - User *user; + User *user; - user = finduser(source); - if (!user) { - alog("user: MODE %s for nonexistent nick %s: %s", av[0], source, - merge_args(ac, av)); - return; - } + user = finduser(source); + if (!user) { + alog("user: MODE %s for nonexistent nick %s: %s", av[0], source, + merge_args(ac, av)); + return; + } - ircdproto->ProcessUsermodes(user, ac, &av[0]); + ircdproto->ProcessUsermodes(user, ac, &av[0]); } /*************************************************************************/ @@ -831,30 +831,30 @@ void do_umode2(const char *source, int ac, const char **av) void do_quit(const char *source, int ac, const char **av) { - User *user; - NickAlias *na; - - user = finduser(source); - if (!user) { - alog("user: QUIT from nonexistent user %s: %s", source, - merge_args(ac, av)); - return; - } - if (debug) { - alog("debug: %s quits", source); - } - if ((na = user->na) && (!(na->status & NS_VERBOTEN)) - && (!(na->nc->flags & NI_SUSPENDED)) - && (na->status & (NS_IDENTIFIED | NS_RECOGNIZED))) { - na->last_seen = time(NULL); - if (na->last_quit) - free(na->last_quit); - na->last_quit = *av[0] ? sstrdup(av[0]) : NULL; - } - if (LimitSessions && !is_ulined(user->server->name)) { - del_session(user->host); - } - delete user; + User *user; + NickAlias *na; + + user = finduser(source); + if (!user) { + alog("user: QUIT from nonexistent user %s: %s", source, + merge_args(ac, av)); + return; + } + if (debug) { + alog("debug: %s quits", source); + } + if ((na = user->na) && (!(na->status & NS_VERBOTEN)) + && (!(na->nc->flags & NI_SUSPENDED)) + && (na->status & (NS_IDENTIFIED | NS_RECOGNIZED))) { + na->last_seen = time(NULL); + if (na->last_quit) + free(na->last_quit); + na->last_quit = *av[0] ? sstrdup(av[0]) : NULL; + } + if (LimitSessions && !is_ulined(user->server->name)) { + del_session(user->host); + } + delete user; } /*************************************************************************/ @@ -866,32 +866,32 @@ void do_quit(const char *source, int ac, const char **av) void do_kill(const char *nick, const char *msg) { - User *user; - NickAlias *na; - - user = finduser(nick); - if (!user) { - if (debug) { - alog("debug: KILL of nonexistent nick: %s", nick); - } - return; - } - if (debug) { - alog("debug: %s killed", nick); - } - if ((na = user->na) && (!(na->status & NS_VERBOTEN)) - && (!(na->nc->flags & NI_SUSPENDED)) - && (na->status & (NS_IDENTIFIED | NS_RECOGNIZED))) { - na->last_seen = time(NULL); - if (na->last_quit) - free(na->last_quit); - na->last_quit = *msg ? sstrdup(msg) : NULL; - - } - if (LimitSessions && !is_ulined(user->server->name)) { - del_session(user->host); - } - delete user; + User *user; + NickAlias *na; + + user = finduser(nick); + if (!user) { + if (debug) { + alog("debug: KILL of nonexistent nick: %s", nick); + } + return; + } + if (debug) { + alog("debug: %s killed", nick); + } + if ((na = user->na) && (!(na->status & NS_VERBOTEN)) + && (!(na->nc->flags & NI_SUSPENDED)) + && (na->status & (NS_IDENTIFIED | NS_RECOGNIZED))) { + na->last_seen = time(NULL); + if (na->last_quit) + free(na->last_quit); + na->last_quit = *msg ? sstrdup(msg) : NULL; + + } + if (LimitSessions && !is_ulined(user->server->name)) { + del_session(user->host); + } + delete user; } /*************************************************************************/ @@ -901,11 +901,11 @@ void do_kill(const char *nick, const char *msg) int is_protected(User * user) { - if (ircd->protectedumode) { - return (user->mode & ircd->protectedumode); - } else { - return 0; - } + if (ircd->protectedumode) { + return (user->mode & ircd->protectedumode); + } else { + return 0; + } } /*************************************************************************/ @@ -914,11 +914,11 @@ int is_protected(User * user) int is_oper(User * user) { - if (user) { - return (user->mode & anope_get_oper_mode()); - } else { - return 0; - } + if (user) { + return (user->mode & anope_get_oper_mode()); + } else { + return 0; + } } /*************************************************************************/ @@ -927,13 +927,13 @@ int is_oper(User * user) /* Is the given user ban-excepted? */ int is_excepted(ChannelInfo * ci, User * user) { - if (!ci->c || !ircd->except) - return 0; + if (!ci->c || !ircd->except) + return 0; - if (elist_match_user(ci->c->excepts, user)) - return 1; + if (elist_match_user(ci->c->excepts, user)) + return 1; - return 0; + return 0; } /*************************************************************************/ @@ -941,13 +941,13 @@ int is_excepted(ChannelInfo * ci, User * user) /* Is the given MASK ban-excepted? */ int is_excepted_mask(ChannelInfo * ci, char *mask) { - if (!ci->c || !ircd->except) - return 0; + if (!ci->c || !ircd->except) + return 0; - if (elist_match_mask(ci->c->excepts, mask, 0)) - return 1; + if (elist_match_mask(ci->c->excepts, mask, 0)) + return 1; - return 0; + return 0; } @@ -959,42 +959,42 @@ int is_excepted_mask(ChannelInfo * ci, char *mask) int match_usermask(const char *mask, User * user) { - char *mask2; - char *nick, *username, *host; - int result; - - if (!mask || !*mask) { - return 0; - } - - mask2 = sstrdup(mask); - - if (strchr(mask2, '!')) { - nick = strtok(mask2, "!"); - username = strtok(NULL, "@"); - } else { - nick = NULL; - username = strtok(mask2, "@"); - } - host = strtok(NULL, ""); - if (!username || !host) { - free(mask2); - return 0; - } - - if (nick) { - result = match_wild_nocase(nick, user->nick) - && match_wild_nocase(username, user->username) - && (match_wild_nocase(host, user->host) - || match_wild_nocase(host, user->vhost)); - } else { - result = match_wild_nocase(username, user->username) - && (match_wild_nocase(host, user->host) - || match_wild_nocase(host, user->vhost)); - } - - free(mask2); - return result; + char *mask2; + char *nick, *username, *host; + int result; + + if (!mask || !*mask) { + return 0; + } + + mask2 = sstrdup(mask); + + if (strchr(mask2, '!')) { + nick = strtok(mask2, "!"); + username = strtok(NULL, "@"); + } else { + nick = NULL; + username = strtok(mask2, "@"); + } + host = strtok(NULL, ""); + if (!username || !host) { + free(mask2); + return 0; + } + + if (nick) { + result = match_wild_nocase(nick, user->nick) + && match_wild_nocase(username, user->username) + && (match_wild_nocase(host, user->host) + || match_wild_nocase(host, user->vhost)); + } else { + result = match_wild_nocase(username, user->username) + && (match_wild_nocase(host, user->host) + || match_wild_nocase(host, user->vhost)); + } + + free(mask2); + return result; } @@ -1004,42 +1004,42 @@ int match_usermask(const char *mask, User * user) int match_userip(const char *mask, User * user, char *iphost) { - char *mask2; - char *nick, *username, *host; - int result; - - if (!mask || !*mask) { - return 0; - } - - mask2 = sstrdup(mask); - - if (strchr(mask2, '!')) { - nick = strtok(mask2, "!"); - username = strtok(NULL, "@"); - } else { - nick = NULL; - username = strtok(mask2, "@"); - } - host = strtok(NULL, ""); - if (!username || !host) { - free(mask2); - return 0; - } - - if (nick) { - result = match_wild_nocase(nick, user->nick) - && match_wild_nocase(username, user->username) - && (match_wild_nocase(host, iphost) - || match_wild_nocase(host, user->vhost)); - } else { - result = match_wild_nocase(username, user->username) - && (match_wild_nocase(host, iphost) - || match_wild_nocase(host, user->vhost)); - } - - free(mask2); - return result; + char *mask2; + char *nick, *username, *host; + int result; + + if (!mask || !*mask) { + return 0; + } + + mask2 = sstrdup(mask); + + if (strchr(mask2, '!')) { + nick = strtok(mask2, "!"); + username = strtok(NULL, "@"); + } else { + nick = NULL; + username = strtok(mask2, "@"); + } + host = strtok(NULL, ""); + if (!username || !host) { + free(mask2); + return 0; + } + + if (nick) { + result = match_wild_nocase(nick, user->nick) + && match_wild_nocase(username, user->username) + && (match_wild_nocase(host, iphost) + || match_wild_nocase(host, user->vhost)); + } else { + result = match_wild_nocase(username, user->username) + && (match_wild_nocase(host, iphost) + || match_wild_nocase(host, user->vhost)); + } + + free(mask2); + return result; } /*************************************************************************/ @@ -1050,29 +1050,29 @@ int match_userip(const char *mask, User * user, char *iphost) */ void split_usermask(const char *mask, char **nick, char **user, - char **host) + char **host) { - char *mask2 = sstrdup(mask); - - *nick = strtok(mask2, "!"); - *user = strtok(NULL, "@"); - *host = strtok(NULL, ""); - /* Handle special case: mask == user@host */ - if (*nick && !*user && strchr(*nick, '@')) { - *nick = NULL; - *user = strtok(mask2, "@"); - *host = strtok(NULL, ""); - } - if (!*nick) - *nick = "*"; - if (!*user) - *user = "*"; - if (!*host) - *host = "*"; - *nick = sstrdup(*nick); - *user = sstrdup(*user); - *host = sstrdup(*host); - free(mask2); + char *mask2 = sstrdup(mask); + + *nick = strtok(mask2, "!"); + *user = strtok(NULL, "@"); + *host = strtok(NULL, ""); + /* Handle special case: mask == user@host */ + if (*nick && !*user && strchr(*nick, '@')) { + *nick = NULL; + *user = strtok(mask2, "@"); + *host = strtok(NULL, ""); + } + if (!*nick) + *nick = "*"; + if (!*user) + *user = "*"; + if (!*host) + *host = "*"; + *nick = sstrdup(*nick); + *user = sstrdup(*user); + *host = sstrdup(*host); + free(mask2); } /*************************************************************************/ @@ -1088,44 +1088,44 @@ void split_usermask(const char *mask, char **nick, char **user, char *create_mask(User * u) { - char *mask, *s, *end; - int ulen = strlen(common_get_vident(u)); - - /* Get us a buffer the size of the username plus hostname. The result - * will never be longer than this (and will often be shorter), thus we - * can use strcpy() and sprintf() safely. - */ - end = mask = (char *)smalloc(ulen + strlen(common_get_vhost(u)) + 3); - end += sprintf(end, "%s%s@", - (ulen < - (*(common_get_vident(u)) == - '~' ? USERMAX + 1 : USERMAX) ? "*" : ""), - (*(common_get_vident(u)) == - '~' ? common_get_vident(u) + - 1 : common_get_vident(u))); - - if (strspn(common_get_vhost(u), "0123456789.") == - strlen(common_get_vhost(u)) - && (s = strchr(common_get_vhost(u), '.')) - && (s = strchr(s + 1, '.')) - && (s = strchr(s + 1, '.')) - && (!strchr(s + 1, '.'))) { /* IP addr */ - s = sstrdup(common_get_vhost(u)); - *strrchr(s, '.') = 0; - - sprintf(end, "%s.*", s); - free(s); - } else { - if ((s = strchr(common_get_vhost(u), '.')) && strchr(s + 1, '.')) { - s = sstrdup(strchr(common_get_vhost(u), '.') - 1); - *s = '*'; - strcpy(end, s); - free(s); - } else { - strcpy(end, common_get_vhost(u)); - } - } - return mask; + char *mask, *s, *end; + int ulen = strlen(common_get_vident(u)); + + /* Get us a buffer the size of the username plus hostname. The result + * will never be longer than this (and will often be shorter), thus we + * can use strcpy() and sprintf() safely. + */ + end = mask = (char *)smalloc(ulen + strlen(common_get_vhost(u)) + 3); + end += sprintf(end, "%s%s@", + (ulen < + (*(common_get_vident(u)) == + '~' ? USERMAX + 1 : USERMAX) ? "*" : ""), + (*(common_get_vident(u)) == + '~' ? common_get_vident(u) + + 1 : common_get_vident(u))); + + if (strspn(common_get_vhost(u), "0123456789.") == + strlen(common_get_vhost(u)) + && (s = strchr(common_get_vhost(u), '.')) + && (s = strchr(s + 1, '.')) + && (s = strchr(s + 1, '.')) + && (!strchr(s + 1, '.'))) { /* IP addr */ + s = sstrdup(common_get_vhost(u)); + *strrchr(s, '.') = 0; + + sprintf(end, "%s.*", s); + free(s); + } else { + if ((s = strchr(common_get_vhost(u), '.')) && strchr(s + 1, '.')) { + s = sstrdup(strchr(common_get_vhost(u), '.') - 1); + *s = '*'; + strcpy(end, s); + free(s); + } else { + strcpy(end, common_get_vhost(u)); + } + } + return mask; } /*************************************************************************/ |