Indenting cleanups, +sp fix, PING fix
authorEntrope <entrope@clan-dk.org>
Tue, 17 Feb 2004 22:02:03 +0000 (22:02 +0000)
committerEntrope <entrope@clan-dk.org>
Tue, 17 Feb 2004 22:02:03 +0000 (22:02 +0000)
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

AUTHORS
docs/access-levels.txt
sockcheck.conf.example
src/chanserv.help
src/ioset.c
src/modcmd.c
src/proto-bahamut.c
src/proto-p10.c
src/tools.c

diff --git a/AUTHORS b/AUTHORS
index 1bb68dd69c4332a5dff7427069ad6f1fa4c0bd2e..6d224a1441091e4f8b9f7cdc15a9bc519b42ed77 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,7 +1,6 @@
                             srvx Development Team
 
-Project Admins:
-def        <def@vt.edu>
+Project Admin:
 Entrope    <entrope@users.sourceforge.net>
 
 Coders:
@@ -9,7 +8,7 @@ def        <def@vt.edu>
 Entrope    <entrope@users.sourceforge.net>
 Jedi       <jedi@turboflux.net>
 SailorFrag <sailorfrag@users.sourceforge.net>
-Zoot       <zoot@gamesnet.net>
+Zoot       <zoot@gamesurge.net>
 
 Code Contributors:
 Phooeybane <phooeybane@glined.org>
@@ -19,5 +18,5 @@ Documentation:
 Phooeybane <phooeybane@glined.org>
 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.
index 97a4bb2b7b483950c6fe95209af2028f2a42d678..ccdc801a7992419144d966480b09f59050266004 100644 (file)
@@ -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.)
index a64dd7dbf5b230a249ffb6dce6fd7313ac94f946..a421a909a3cd5df607ca9116ca14d6968ecb9ee3 100644 (file)
@@ -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";
index 82bca0145901b5dbfa95a3219b0a7a03e860f39b..ecd9c59d6c697e617d3f0076dafe8f53109fe6c4 100644 (file)
 "BAN" ("/msg $C BAN <#channel> <mask|nick>",
         "This command will temporarily add a ban for the user specified as the parameter. Masks are to be supplied in the format <Nick>!<Ident>@<Host> 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.",
         "\"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.");
index beb4504322c5d230e2ac74f022e1b2075b9b4bae..4e8caf137d280e53311d1df31ec5cae223c75cf0 100644 (file)
@@ -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; nn<fds_size; nn++) {
-            if (!(fd = fds[nn])) continue;
+            if (!(fd = fds[nn]))
+                continue;
             max_fd = nn;
-            if (fd->wants_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; nn<fds_size; nn++) {
-            if (!(fd = fds[nn])) continue;
+            if (!(fd = fds[nn]))
+                continue;
             if (FD_ISSET(nn, &read_fds)) {
-                if (fd->line_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
index 301bdfb625d75c664275b4d55b2f7c69891211fc..834efabe31c51a94f201f1efc3bd6c32e526b3aa 100644 (file)
@@ -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;
index f10f0f2cf282a210579ef66db54e9c9bc06e2d16..95dbe03c8b13cec11f87853e15837c6fd6e3ae4e 100644 (file)
@@ -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);
index 2fc7fac7d964928ff56abdf8c30dfb885b3efca8..b711c101f709b5e63ef5537296dcd57c04f522b6 100644 (file)
@@ -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);
index 502668435a1969d5b316c02c0af6c0af9fb7f400..f8695b3862036ac1c23925784f1510bf68d2b640 100644 (file)
@@ -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; ii<max; ii++) {
-        for (jj=0; set[ii][jj]; jj++) {
+        for (jj=0; set[ii][jj]; jj++)
             dest[pos++] = set[ii][jj];
-        }
         dest[pos++] = ' ';
     }
     dest[--pos] = 0;
@@ -653,14 +688,12 @@ int
 getipbyname(const char *name, unsigned long *ip)
 {
     struct hostent *he = gethostbyname(name);
-    if (he) {
-       if (he->h_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<str_tab.size; ++ii) {
-        if (str_tab.list[ii]) free(str_tab.list[ii]);
-    }
+    for (ii=0; ii<str_tab.size; ++ii)
+        free(str_tab.list[ii]);
     free(str_tab.list);
 }