From: Entrope Date: Tue, 17 Feb 2004 22:02:03 +0000 (+0000) Subject: Indenting cleanups, +sp fix, PING fix X-Git-Tag: v1.4.0-rc1~275 X-Git-Url: http://git.pk910.de/?p=srvx.git;a=commitdiff_plain;h=d2048f43a8d603f4d758c685f88eceaaebb2b606 Indenting cleanups, +sp fix, PING fix Add explicit copyright notice to VERSION command When receiving a PING, respond using numnick instead of readable name Indenting fixes Remove out-of-date references to GamesNET git-archimport-id: srvx@srvx.net--2004-srvx/srvx--devo--1.3--patch-1 --- diff --git a/AUTHORS b/AUTHORS index 1bb68dd..6d224a1 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,7 +1,6 @@ srvx Development Team -Project Admins: -def +Project Admin: Entrope Coders: @@ -9,7 +8,7 @@ def Entrope Jedi SailorFrag -Zoot +Zoot Code Contributors: Phooeybane @@ -19,5 +18,5 @@ Documentation: Phooeybane Seldon -You can find the team on irc.gamesnet.net, in #srvx. Bug reports, +You can find the team on irc.gamesurge.net, in #srvx. Bug reports, feature requests, criticism or praise are welcome. We love feedback. diff --git a/docs/access-levels.txt b/docs/access-levels.txt index 97a4bb2..ccdc801 100644 --- a/docs/access-levels.txt +++ b/docs/access-levels.txt @@ -26,6 +26,6 @@ access, that is used instead). Authenticated opers and network helpers may use the !god mode in ChanServ to toggle security override on and off. Support helpers have security override on if (and only if) they are in a designated -"support channel." On GamesNET, this is #support. +"support channel." On GameSurge, this is #support. (More documentation goes here.) diff --git a/sockcheck.conf.example b/sockcheck.conf.example index a64dd7d..a421a90 100644 --- a/sockcheck.conf.example +++ b/sockcheck.conf.example @@ -26,7 +26,7 @@ // this crap at the front is the router trying to negotiate telnet options "fffb01fffb03fffd18fffd1f0d0a0d0a=U=s=e=r= =A=c=c=e=s=s= =V=e=r=i=f=i=c=a=t=i=o=n0d0a0d0a=P=a=s=s=w=o=r=d3a= :=c=i=s=c=o0d0a" { "0d0a=P=a=s=s=w=o=r=d3a= " "accept"; - "other" "reject:[1 hour] Cisco router with default password, visit http://www.gamesnet.net/proxyglines.php for more information."; + "other" "reject:[1 hour] Cisco router with default password"; }; "=W=i=n=G=a=t=e=>" "reject:Unsecured wingate"; "=T=o=o= =m=a=n=y" "reject:Unsecured wingate"; diff --git a/src/chanserv.help b/src/chanserv.help index 82bca01..ecd9c59 100644 --- a/src/chanserv.help +++ b/src/chanserv.help @@ -119,7 +119,7 @@ "BAN" ("/msg $C BAN <#channel> ", "This command will temporarily add a ban for the user specified as the parameter. Masks are to be supplied in the format !@ and usually contain wildcards. If a nick is specified, a mask is automatically generated (though not completely foolproof). This ban is removed either by removing it from the channel ban list using any irc client, or sending the UNBAN or UNBANALL commands. If you are banned with this method, the UNBANME command can be used.", "$uFor assistance, please join to #support$u", - "Example: *!*serv@*.gamesnet.net would ban anyone with ident 'serv' and a gamesnet.net hostname from joining the channel.", + "Example: *!*serv@*.gamesurge.net would ban anyone with ident 'serv' and a gamesurge.net hostname from joining the channel.", "$uSee Also:$u unban, unbanall, unbanme"); "BANS" ("/msg $C BANS <#channel>", "This command lists all permanent and timed bans in the channel.", @@ -506,7 +506,7 @@ "\"I don't see why not. It's got bloody well everything else.\"", "With that, the Chief Priest went to lunch. The novice suddenly achieved enlightenment, several years later."); "thanks" ("The srvx developers would like to thank the following people for their help in making srvx as polished as it is today:", - "$bGamesNET IRC Network$b - All the users and staff there bear with our shortcomings and bugs and let us know what needs to be fixed.", - "$bIC5 Networks$b (and JohnM in particular) - Never afraid to critique things, even if GamesNET is the 800 pound gorilla.", + "$bGameSurge IRC Network$b - All the users and staff there bear with our shortcomings and bugs and let us know what needs to be fixed.", + "$bIC5 Networks$b (and JohnM in particular) - Never afraid to critique things, even if we are the 800 pound gorilla.", "$bMeeko, eraser, hock(ey), KilledInAction, MadEwokHerd, Milon and Shoat$b - Hardcore beta testing and bug finding on the testnet.", "$bCrips$b - Reading through all the boring messages and finding ways to make them clearer."); diff --git a/src/ioset.c b/src/ioset.c index beb4504..4e8caf1 100644 --- a/src/ioset.c +++ b/src/ioset.c @@ -58,13 +58,12 @@ static unsigned int ioq_put_avail(const struct ioq *ioq) { /* Subtract 1 from ioq->get to be sure we don't fill the buffer * and make it look empty even when there's data in it. */ - if (ioq->put < ioq->get) { + if (ioq->put < ioq->get) return ioq->get - ioq->put - 1; - } else if (ioq->get == 0) { + else if (ioq->get == 0) return ioq->size - ioq->put - 1; - } else { + else return ioq->size - ioq->put; - } } static unsigned int @@ -191,32 +190,38 @@ ioset_try_write(struct io_fd *fd) { res = write(fd->fd, fd->send.buf+fd->send.get, req); if (res < 0) { switch (errno) { - case EAGAIN: break; + case EAGAIN: + break; default: log_module(MAIN_LOG, LOG_ERROR, "write() on fd %d error %d: %s", fd->fd, errno, strerror(errno)); } } else { fd->send.get += res; - if (fd->send.get == fd->send.size) fd->send.get = 0; + if (fd->send.get == fd->send.size) + fd->send.get = 0; } } void ioset_close(int fd, int os_close) { struct io_fd *fdp; - if (!(fdp = fds[fd])) return; + if (!(fdp = fds[fd])) + return; fds[fd] = NULL; - if (fdp->destroy_cb) fdp->destroy_cb(fdp); + if (fdp->destroy_cb) + fdp->destroy_cb(fdp); if (fdp->send.get != fdp->send.put) { int flags = fcntl(fd, F_GETFL); fcntl(fd, F_SETFL, flags&~O_NONBLOCK); ioset_try_write(fdp); /* it may need to send the beginning of the buffer now.. */ - if (fdp->send.get != fdp->send.put) ioset_try_write(fdp); + if (fdp->send.get != fdp->send.put) + ioset_try_write(fdp); } free(fdp->send.buf); free(fdp->recv.buf); - if (os_close) close(fd); + if (os_close) + close(fd); free(fdp); FD_CLR(fd, &read_fds); FD_CLR(fd, &write_fds); @@ -227,14 +232,13 @@ ioset_find_line_length(struct io_fd *fd) { unsigned int pos, max, len; len = 0; max = (fd->recv.put < fd->recv.get) ? fd->recv.size : fd->recv.put; - for (pos = fd->recv.get; pos < max; ++pos, ++len) { - if (IS_EOL(fd->recv.buf[pos])) return fd->line_len = len + 1; - } - if (fd->recv.put < fd->recv.get) { - for (pos = 0; pos < fd->recv.put; ++pos, ++len) { - if (IS_EOL(fd->recv.buf[pos])) return fd->line_len = len + 1; - } - } + for (pos = fd->recv.get; pos < max; ++pos, ++len) + if (IS_EOL(fd->recv.buf[pos])) + return fd->line_len = len + 1; + if (fd->recv.put < fd->recv.get) + for (pos = 0; pos < fd->recv.put; ++pos, ++len) + if (IS_EOL(fd->recv.buf[pos])) + return fd->line_len = len + 1; return fd->line_len = 0; } @@ -242,11 +246,13 @@ static void ioset_buffered_read(struct io_fd *fd) { int put_avail, nbr, fdnum; - if (!(put_avail = ioq_put_avail(&fd->recv))) put_avail = ioq_grow(&fd->recv); + if (!(put_avail = ioq_put_avail(&fd->recv))) + put_avail = ioq_grow(&fd->recv); nbr = read(fd->fd, fd->recv.buf + fd->recv.put, put_avail); if (nbr < 0) { switch (errno) { - case EAGAIN: break; + case EAGAIN: + break; default: log_module(MAIN_LOG, LOG_ERROR, "Unexpected read() error %d on fd %d: %s", errno, fd->fd, strerror(errno)); /* Just flag it as EOF and call readable_cb() to notify the fd's owner. */ @@ -263,21 +269,22 @@ ioset_buffered_read(struct io_fd *fd) { unsigned int pos; for (pos = fd->recv.put; pos < fd->recv.put + nbr; ++pos) { if (IS_EOL(fd->recv.buf[pos])) { - if (fd->recv.put < fd->recv.get) { + if (fd->recv.put < fd->recv.get) fd->line_len = fd->recv.size + pos + 1 - fd->recv.get; - } else { + else fd->line_len = pos + 1 - fd->recv.get; - } break; } } } fd->recv.put += nbr; - if (fd->recv.put == fd->recv.size) fd->recv.put = 0; + if (fd->recv.put == fd->recv.size) + fd->recv.put = 0; fdnum = fd->fd; while (fd->wants_reads && (fd->line_len > 0)) { fd->readable_cb(fd); - if (!fds[fdnum]) break; /* make sure they didn't close on us */ + if (!fds[fdnum]) + break; /* make sure they didn't close on us */ ioset_find_line_length(fd); } } @@ -286,9 +293,12 @@ ioset_buffered_read(struct io_fd *fd) { int ioset_line_read(struct io_fd *fd, char *dest, int max) { int avail, done; - if (fd->eof && (!ioq_get_avail(&fd->recv) || (fd->line_len < 0))) return 0; - if (fd->line_len < 0) return -1; - if (fd->line_len < max) max = fd->line_len; + if (fd->eof && (!ioq_get_avail(&fd->recv) || (fd->line_len < 0))) + return 0; + if (fd->line_len < 0) + return -1; + if (fd->line_len < max) + max = fd->line_len; avail = ioq_get_avail(&fd->recv); if (max > avail) { memcpy(dest, fd->recv.buf + fd->recv.get, avail); @@ -301,7 +311,8 @@ ioset_line_read(struct io_fd *fd, char *dest, int max) { } memcpy(dest + done, fd->recv.buf + fd->recv.get, max - done); fd->recv.get += max - done; - if (fd->recv.get == fd->recv.size) fd->recv.get = 0; + if (fd->recv.get == fd->recv.size) + fd->recv.get = 0; dest[max] = 0; ioset_find_line_length(fd); return max; @@ -321,7 +332,8 @@ debug_fdsets(const char *msg, int nfds, fd_set *read_fds, fd_set *write_fds, fd_ flags = (read_fds && FD_ISSET(ii, read_fds)) ? 1 : 0; flags |= (write_fds && FD_ISSET(ii, write_fds)) ? 2 : 0; flags |= (except_fds && FD_ISSET(ii, except_fds)) ? 4 : 0; - if (!flags) continue; + if (!flags) + continue; pos += sprintf(buf+pos, " %d%s", ii, flag_text[flags]); } gettimeofday(&now, NULL); @@ -343,15 +355,15 @@ ioset_run(void) { struct io_fd *fd; while (!quit_services) { - while (!socket_io_fd) uplink_connect(); + while (!socket_io_fd) + uplink_connect(); /* How long to sleep? (fill in select_timeout) */ wakey = timeq_next(); - if ((wakey - now) < 0) { + if ((wakey - now) < 0) select_timeout.tv_sec = 0; - } else { + else select_timeout.tv_sec = wakey - now; - } select_timeout.tv_usec = 0; /* Set up read_fds and write_fds fdsets. */ @@ -359,10 +371,13 @@ ioset_run(void) { FD_ZERO(&write_fds); max_fd = 0; for (nn=0; nnwants_reads) FD_SET(nn, &read_fds); - if ((fd->send.get != fd->send.put) || !fd->connected) FD_SET(nn, &write_fds); + if (fd->wants_reads) + FD_SET(nn, &read_fds); + if ((fd->send.get != fd->send.put) || !fd->connected) + FD_SET(nn, &write_fds); } /* Check for activity, update time. */ @@ -380,27 +395,28 @@ ioset_run(void) { /* Call back anybody that has connect or read activity and wants to know. */ for (nn=0; nnline_reads) { + if (fd->line_reads) ioset_buffered_read(fd); - } else { + else fd->readable_cb(fd); - } } if (FD_ISSET(nn, &write_fds) && !fd->connected) { int rc, arglen = sizeof(rc); - if (getsockopt(fd->fd, SOL_SOCKET, SO_ERROR, &rc, &arglen) < 0) rc = errno; + if (getsockopt(fd->fd, SOL_SOCKET, SO_ERROR, &rc, &arglen) < 0) + rc = errno; fd->connected = 1; - if (fd->connect_cb) fd->connect_cb(fd, rc); + if (fd->connect_cb) + fd->connect_cb(fd, rc); } /* Note: check whether write FD is still set, since the * connect_cb() might close the FD, making us dereference * a free()'d pointer for the fd. */ - if (FD_ISSET(nn, &write_fds) && (fd->send.get != fd->send.put)) { + if (FD_ISSET(nn, &write_fds) && (fd->send.get != fd->send.put)) ioset_try_write(fd); - } } /* Call any timeq events we need to call. */ @@ -420,9 +436,8 @@ ioset_run(void) { void ioset_write(struct io_fd *fd, const char *buf, unsigned int nbw) { unsigned int avail; - while (ioq_used(&fd->send) + nbw >= fd->send.size) { + while (ioq_used(&fd->send) + nbw >= fd->send.size) ioq_grow(&fd->send); - } avail = ioq_put_avail(&fd->send); if (nbw > avail) { memcpy(fd->send.buf + fd->send.put, buf, avail); @@ -432,7 +447,8 @@ ioset_write(struct io_fd *fd, const char *buf, unsigned int nbw) { } memcpy(fd->send.buf + fd->send.put, buf, nbw); fd->send.put += nbw; - if (fd->send.put == fd->send.size) fd->send.put = 0; + if (fd->send.put == fd->send.size) + fd->send.put = 0; } void diff --git a/src/modcmd.c b/src/modcmd.c index 301bdfb..834efab 100644 --- a/src/modcmd.c +++ b/src/modcmd.c @@ -1716,6 +1716,7 @@ static MODCMD_FUNC(cmd_dump_messages) { static MODCMD_FUNC(cmd_version) { reply("MCMSG_VERSION"); + send_message_type(4, user, cmd->parent->bot, "Copyright 2000-2004 srvx Development Team.\nThe srvx Development Team includes Paul Chang, Adrian Dewhurst, Miles Peterson, Michael Poole and others."); if ((argc > 1) && !irccasecmp(argv[1], "arch")) send_message_type(4, user, cmd->parent->bot, "%s", ARCH_VERSION); return 1; diff --git a/src/proto-bahamut.c b/src/proto-bahamut.c index f10f0f2..95dbe03 100644 --- a/src/proto-bahamut.c +++ b/src/proto-bahamut.c @@ -1265,6 +1265,13 @@ mod_chanmode_parse(struct chanNode *channel, char **modes, unsigned int argc, un } } change->argc = argc; /* in case any turned out to be ignored */ + if (change->modes_set & MODE_SECRET) { + change->modes_set &= ~(MODE_PRIVATE); + change->modes_clear |= MODE_PRIVATE; + } else if (change->modes_set & MODE_PRIVATE) { + change->modes_set &= ~(MODE_SECRET); + change->modes_clear |= MODE_SECRET; + } return change; error: mod_chanmode_free(change); diff --git a/src/proto-p10.c b/src/proto-p10.c index 2fc7fac..b711c10 100644 --- a/src/proto-p10.c +++ b/src/proto-p10.c @@ -832,14 +832,18 @@ static CMD_FUNC(cmd_eob_ack) static CMD_FUNC(cmd_ping) { + struct server *srv; + struct userNode *un; + if(argc > 3) - { irc_pong(argv[2], argv[1]); - } + else if ((srv = GetServerH(origin))) + irc_pong(self->name, srv->numeric); + else if ((un = GetUserH(origin))) + irc_pong(self->name, un->numeric); else - { irc_pong(self->name, origin); - } + timeq_del(0, timed_send_ping, 0, TIMEQ_IGNORE_WHEN|TIMEQ_IGNORE_DATA); timeq_del(0, timed_ping_timeout, 0, TIMEQ_IGNORE_WHEN|TIMEQ_IGNORE_DATA); timeq_add(now + ping_freq, timed_send_ping, 0); @@ -1975,7 +1979,7 @@ mod_chanmode_parse(struct chanNode *channel, char **modes, unsigned int argc, un case '-': add = 0; break; -#define do_chan_mode(FLAG) do { if (add) change->modes_set |= FLAG, change->modes_clear &= ~FLAG; else change->modes_clear |= FLAG, change->modes_set &= ~FLAG; } while(0) +#define do_chan_mode(FLAG) do { if (add) change->modes_set |= (FLAG), change->modes_clear &= ~(FLAG); else change->modes_clear |= (FLAG), change->modes_set &= ~(FLAG); } while(0) case 'C': do_chan_mode(MODE_NOCTCPS); break; case 'D': do_chan_mode(MODE_DELAYJOINS); break; case 'c': do_chan_mode(MODE_NOCOLORS); break; @@ -2044,6 +2048,13 @@ mod_chanmode_parse(struct chanNode *channel, char **modes, unsigned int argc, un } } change->argc = ch_arg; /* in case any turned out to be ignored */ + if (change->modes_set & MODE_SECRET) { + change->modes_set &= ~(MODE_PRIVATE); + change->modes_clear |= MODE_PRIVATE; + } else if (change->modes_set & MODE_PRIVATE) { + change->modes_set &= ~(MODE_SECRET); + change->modes_clear |= MODE_SECRET; + } return change; error: mod_chanmode_free(change); diff --git a/src/tools.c b/src/tools.c index 5026684..f8695b3 100644 --- a/src/tools.c +++ b/src/tools.c @@ -250,21 +250,30 @@ match_ircglob(const char *text, const char *glob) glob++; /* intentionally not tolower(...) so people can force * capitalization, or we can overload \ in the future */ - if (*text++ != *glob++) return 0; + if (*text++ != *glob++) + return 0; break; case '*': case '?': star_p = q_cnt = 0; do { - if (*glob == '*') star_p = 1; - else if (*glob == '?') q_cnt++; - else break; + if (*glob == '*') + star_p = 1; + else if (*glob == '?') + q_cnt++; + else + break; glob++; } while (1); - while (q_cnt) { if (!*text++) return 0; q_cnt--; } + while (q_cnt) { + if (!*text++) + return 0; + q_cnt--; + } if (star_p) { /* if this is the last glob character, it will match any text */ - if (!*glob) return 1; + if (!*glob) + return 1; /* Thanks to the loop above, we know that the next * character is a normal character. So just look for * the right character. @@ -279,11 +288,14 @@ match_ircglob(const char *text, const char *glob) } /* if !star_p, fall through to normal character case, * first checking to see if ?s carried us to the end */ - if (!*glob && !*text) return 1; + if (!*glob && !*text) + return 1; default: - if (!*text) return 0; + if (!*text) + return 0; while (*text && *glob && *glob != '*' && *glob != '?' && *glob != '\\') { - if (tolower(*text++) != tolower(*glob++)) return 0; + if (tolower(*text++) != tolower(*glob++)) + return 0; } } } @@ -337,22 +349,31 @@ user_matches_glob(struct userNode *user, const char *orig_glob, int include_nick int is_ircmask(const char *text) { - while (*text && (isalnum((char)*text) || strchr("-_[]|\\`^{}?*", *text))) text++; - if (*text++ != '!') return 0; - while (*text && *text != '@' && !isspace((char)*text)) text++; - if (*text++ != '@') return 0; - while (*text && !isspace((char)*text)) text++; + while (*text && (isalnum((char)*text) || strchr("-_[]|\\`^{}?*", *text))) + text++; + if (*text++ != '!') + return 0; + while (*text && *text != '@' && !isspace((char)*text)) + text++; + if (*text++ != '@') + return 0; + while (*text && !isspace((char)*text)) + text++; return !*text; } int is_gline(const char *text) { - if (*text == '@') return 0; + if (*text == '@') + return 0; text += strcspn(text, "@!% \t\r\n"); - if (*text++ != '@') return 0; - if (!*text) return 0; - while (*text && (isalnum((char)*text) || strchr(".-?*", *text))) text++; + if (*text++ != '@') + return 0; + if (!*text) + return 0; + while (*text && (isalnum((char)*text) || strchr(".-?*", *text))) + text++; return !*text; } @@ -362,20 +383,28 @@ split_ircmask(char *text, char **nick, char **ident, char **host) char *start; start = text; - while (isalnum((char)*text) || strchr("=[]\\`^{}?*", *text)) text++; - if (*text != '!' || ((text - start) > NICKLEN)) return 0; + while (isalnum((char)*text) || strchr("=[]\\`^{}?*", *text)) + text++; + if (*text != '!' || ((text - start) > NICKLEN)) + return 0; *text = 0; - if (nick) *nick = start; + if (nick) + *nick = start; start = ++text; - while (*text && *text != '@' && !isspace((char)*text)) text++; - if (*text != '@' || ((text - start) > USERLEN)) return 0; + while (*text && *text != '@' && !isspace((char)*text)) + text++; + if (*text != '@' || ((text - start) > USERLEN)) + return 0; *text = 0; - if (ident) *ident = start; + if (ident) + *ident = start; start = ++text; - while (*text && (isalnum((char)*text) || strchr(".-?*", *text))) text++; - if (host) *host = start; + while (*text && (isalnum((char)*text) || strchr(".-?*", *text))) + text++; + if (host) + *host = start; return !*text && ((text - start) <= HOSTLEN) && nick && ident && host; } @@ -532,15 +561,19 @@ parse_ipmask(const char *str, struct in_addr *addr, unsigned long *mask) unsigned long t_a, t_m; t_a = t_m = pos = 0; - if (addr) addr->s_addr = htonl(t_a); - if (mask) *mask = t_m; + if (addr) + addr->s_addr = htonl(t_a); + if (mask) + *mask = t_m; while (*str) { - if (!isdigit(*str)) return 0; + if (!isdigit(*str)) + return 0; accum = 0; do { accum = (accum * 10) + *str++ - '0'; } while (isdigit(*str)); - if (accum > 255) return 0; + if (accum > 255) + return 0; t_a = (t_a << 8) | accum; t_m = (t_m << 8) | 255; pos += 8; @@ -558,9 +591,8 @@ parse_ipmask(const char *str, struct in_addr *addr, unsigned long *mask) t_m <<= 32 - pos; pos = 32; goto out; - } else { + } else return 0; - } } } else if (*str == '/') { int start = pos; @@ -573,17 +605,20 @@ parse_ipmask(const char *str, struct in_addr *addr, unsigned long *mask) t_m = (t_m << 1) | 1; pos++; } - if (pos != start+accum) return 0; - } else if (*str == 0) { + if (pos != start+accum) + return 0; + } else if (*str == 0) break; - } else { + else return 0; - } } out: - if (pos != 32) return 0; - if (addr) addr->s_addr = htonl(t_a); - if (mask) *mask = t_m; + if (pos != 32) + return 0; + if (addr) + addr->s_addr = htonl(t_a); + if (mask) + *mask = t_m; return 1; } @@ -593,11 +628,11 @@ unsplit_string(char *set[], unsigned int max, char *dest) static char unsplit_buffer[MAXLEN*2]; unsigned int ii, jj, pos; - if (!dest) dest = unsplit_buffer; + if (!dest) + dest = unsplit_buffer; for (ii=pos=0; iih_addrtype != AF_INET) - return 0; - memcpy(ip, he->h_addr_list[0], sizeof(*ip)); - return 1; - } else { - return 0; - } + if (!he) + return 0; + if (he->h_addrtype != AF_INET) + return 0; + memcpy(ip, he->h_addr_list[0], sizeof(*ip)); + return 1; } DEFINE_LIST(string_buffer, char) @@ -738,13 +771,14 @@ void string_buffer_replace(struct string_buffer *buf, unsigned int from, unsigned int len, const char *repl) { unsigned int repl_len = strlen(repl); - if (from > buf->used) return; - if (len + from > buf->used) len = buf->used - from; + if (from > buf->used) + return; + if (len + from > buf->used) + len = buf->used - from; buf->used = buf->used + repl_len - len; if (buf->size <= buf->used) { - while (buf->used >= buf->size) { + while (buf->used >= buf->size) buf->size <<= 1; - } buf->list = realloc(buf->list, buf->size*sizeof(buf->list[0])); } memmove(buf->list+from+repl_len, buf->list+from+len, strlen(buf->list+from+len)); @@ -755,10 +789,12 @@ struct string_list str_tab; const char * strtab(unsigned int ii) { - if (ii > 65536) return NULL; + if (ii > 65536) + return NULL; if (ii > str_tab.size) { unsigned int old_size = str_tab.size; - while (ii >= str_tab.size) str_tab.size <<= 1; + while (ii >= str_tab.size) + str_tab.size <<= 1; str_tab.list = realloc(str_tab.list, str_tab.size*sizeof(str_tab.list[0])); memset(str_tab.list+old_size, 0, (str_tab.size-old_size)*sizeof(str_tab.list[0])); } @@ -773,12 +809,17 @@ void tools_init(void) { unsigned int upr, lwr; - for (lwr=0; lwr<256; ++lwr) tolower(lwr) = lwr; - for (upr='A', lwr='a'; lwr <= 'z'; ++upr, ++lwr) tolower(upr) = lwr; + for (lwr=0; lwr<256; ++lwr) + tolower(lwr) = lwr; + for (upr='A', lwr='a'; lwr <= 'z'; ++upr, ++lwr) + tolower(upr) = lwr; #ifdef WITH_PROTOCOL_P10 - for (upr='[', lwr='{'; lwr <= '~'; ++upr, ++lwr) tolower(upr) = lwr; - for (upr=0xc0, lwr=0xe0; lwr <= 0xf6; ++upr, ++lwr) tolower(upr) = lwr; - for (upr=0xd8, lwr=0xf8; lwr <= 0xfe; ++upr, ++lwr) tolower(upr) = lwr; + for (upr='[', lwr='{'; lwr <= '~'; ++upr, ++lwr) + tolower(upr) = lwr; + for (upr=0xc0, lwr=0xe0; lwr <= 0xf6; ++upr, ++lwr) + tolower(upr) = lwr; + for (upr=0xd8, lwr=0xf8; lwr <= 0xfe; ++upr, ++lwr) + tolower(upr) = lwr; #endif str_tab.size = 1001; str_tab.list = calloc(str_tab.size, sizeof(str_tab.list[0])); @@ -788,8 +829,7 @@ void tools_cleanup(void) { unsigned int ii; - for (ii=0; ii