]> jfr.im git - solanum.git/blobdiff - ircd/chmode.c
authd: misc fixes
[solanum.git] / ircd / chmode.c
index 4759d318834eeaed425137e3e67e8c444b8099c6..c3182d1fdd98e5e32b9db5892732807fcb4af30f 100644 (file)
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
- *
- *  $Id: chmode.c 3580 2007-11-07 23:45:14Z jilles $
  */
 
 #include "stdinc.h"
 #include "channel.h"
 #include "client.h"
-#include "common.h"
 #include "hash.h"
 #include "hook.h"
 #include "match.h"
@@ -205,10 +202,10 @@ get_channel_access(struct Client *source_p, struct Channel *chptr, struct member
  * Checks if mlock and chanops permit a mode change.
  *
  * inputs      - client, channel, access level, errors pointer, mode char
- * outputs     - 0 on failure, 1 on success
+ * outputs     - false on failure, true on success
  * side effects - error message sent on failure
  */
-static int
+static bool
 allow_mode_change(struct Client *source_p, struct Channel *chptr, int alevel,
                int *errors, char c)
 {
@@ -223,7 +220,7 @@ allow_mode_change(struct Client *source_p, struct Channel *chptr, int alevel,
                                        c,
                                        chptr->mode_lock);
                *errors |= SM_ERR_MLOCK;
-               return 0;
+               return false;
        }
        if(alevel < CHFL_CHANOP)
        {
@@ -231,18 +228,18 @@ allow_mode_change(struct Client *source_p, struct Channel *chptr, int alevel,
                        sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
                                   me.name, source_p->name, chptr->chname);
                *errors |= SM_ERR_NOOPS;
-               return 0;
+               return false;
        }
-       return 1;
+       return true;
 }
 
 /* add_id()
  *
  * inputs      - client, channel, id to add, type, forward
- * outputs     - 0 on failure, 1 on success
+ * outputs     - false on failure, true on success
  * side effects - given id is added to the appropriate list
  */
-int
+bool
 add_id(struct Client *source_p, struct Channel *chptr, const char *banid, const char *forward,
        rb_dlink_list * list, long mode_type)
 {
@@ -260,14 +257,14 @@ add_id(struct Client *source_p, struct Channel *chptr, const char *banid, const
                {
                        sendto_one(source_p, form_str(ERR_BANLISTFULL),
                                   me.name, source_p->name, chptr->chname, realban);
-                       return 0;
+                       return false;
                }
 
                RB_DLINK_FOREACH(ptr, list->head)
                {
                        actualBan = ptr->data;
                        if(mask_match(actualBan->banstr, realban))
-                               return 0;
+                               return false;
                }
        }
        /* dont let remotes set duplicates */
@@ -277,13 +274,13 @@ add_id(struct Client *source_p, struct Channel *chptr, const char *banid, const
                {
                        actualBan = ptr->data;
                        if(!irccmp(actualBan->banstr, realban))
-                               return 0;
+                               return false;
                }
        }
 
 
        if(IsPerson(source_p))
-               rb_sprintf(who, "%s!%s@%s", source_p->name, source_p->username, source_p->host);
+               sprintf(who, "%s!%s@%s", source_p->name, source_p->username, source_p->host);
        else
                rb_strlcpy(who, source_p->name, sizeof(who));
 
@@ -296,7 +293,7 @@ add_id(struct Client *source_p, struct Channel *chptr, const char *banid, const
        if(mode_type == CHFL_BAN || mode_type == CHFL_QUIET || mode_type == CHFL_EXCEPTION)
                chptr->bants++;
 
-       return 1;
+       return true;
 }
 
 /* del_id()
@@ -403,7 +400,7 @@ pretty_mask(const char *idmask)
                        *t = '~';
                if (*t == '~')
                        t++;
-               *t = ToLower(*t);
+               *t = irctolower(*t);
                return mask_buf + old_mask_pos;
        }
 
@@ -489,7 +486,7 @@ pretty_mask(const char *idmask)
  * output      - true if forwarding should be allowed
  * side effects - numeric sent if not allowed
  */
-static int
+static bool
 check_forward(struct Client *source_p, struct Channel *chptr,
                const char *forward)
 {
@@ -500,20 +497,20 @@ check_forward(struct Client *source_p, struct Channel *chptr,
                        (MyClient(source_p) && (strlen(forward) > LOC_CHANNELLEN || hash_find_resv(forward))))
        {
                sendto_one_numeric(source_p, ERR_BADCHANNAME, form_str(ERR_BADCHANNAME), forward);
-               return 0;
+               return false;
        }
        /* don't forward to inconsistent target -- jilles */
        if(chptr->chname[0] == '#' && forward[0] == '&')
        {
                sendto_one_numeric(source_p, ERR_BADCHANNAME,
                                   form_str(ERR_BADCHANNAME), forward);
-               return 0;
+               return false;
        }
        if(MyClient(source_p) && (targptr = find_channel(forward)) == NULL)
        {
                sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
                                   form_str(ERR_NOSUCHCHANNEL), forward);
-               return 0;
+               return false;
        }
        if(MyClient(source_p) && !(targptr->mode.mode & MODE_FREETARGET))
        {
@@ -522,10 +519,10 @@ check_forward(struct Client *source_p, struct Channel *chptr,
                {
                        sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
                                   me.name, source_p->name, targptr->chname);
-                       return 0;
+                       return false;
                }
        }
-       return 1;
+       return true;
 }
 
 /* fix_key()
@@ -538,9 +535,9 @@ check_forward(struct Client *source_p, struct Channel *chptr,
 static char *
 fix_key(char *arg)
 {
-       u_char *s, *t, c;
+       unsigned char *s, *t, c;
 
-       for(s = t = (u_char *) arg; (c = *s); s++)
+       for(s = t = (unsigned char *) arg; (c = *s); s++)
        {
                c &= 0x7f;
                if(c != ':' && c != ',' && c > ' ')
@@ -561,9 +558,9 @@ fix_key(char *arg)
 static char *
 fix_key_remote(char *arg)
 {
-       u_char *s, *t, c;
+       unsigned char *s, *t, c;
 
-       for(s = t = (u_char *) arg; (c = *s); s++)
+       for(s = t = (unsigned char *) arg; (c = *s); s++)
        {
                c &= 0x7f;
                if((c != 0x0a) && (c != ':') && (c != ',') && (c != 0x0d) && (c != ' '))
@@ -851,7 +848,7 @@ chm_ban(struct Client *source_p, struct Channel *chptr,
                        char buf[BANLEN];
                        banptr = ptr->data;
                        if(banptr->forward)
-                               rb_snprintf(buf, sizeof(buf), "%s$%s", banptr->banstr, banptr->forward);
+                               snprintf(buf, sizeof(buf), "%s$%s", banptr->banstr, banptr->forward);
                        else
                                rb_strlcpy(buf, banptr->banstr, sizeof(buf));
 
@@ -891,7 +888,7 @@ chm_ban(struct Client *source_p, struct Channel *chptr,
         * also make sure it will always fit on a line with channel
         * name etc.
         */
-       if(strlen(mask) > IRCD_MIN(BANLEN, MODEBUFLEN - 5))
+       if(strlen(mask) > MIN(BANLEN, MODEBUFLEN - 5))
        {
                sendto_one_numeric(source_p, ERR_INVALIDBAN,
                                form_str(ERR_INVALIDBAN),
@@ -981,7 +978,7 @@ chm_ban(struct Client *source_p, struct Channel *chptr,
                }
 
                if(removed && removed->forward)
-                       removed_mask_pos += rb_snprintf(buf + old_removed_mask_pos, sizeof(buf), "%s$%s", removed->banstr, removed->forward) + 1;
+                       removed_mask_pos += snprintf(buf + old_removed_mask_pos, sizeof(buf), "%s$%s", removed->banstr, removed->forward) + 1;
                else
                        removed_mask_pos += rb_strlcpy(buf + old_removed_mask_pos, mask, sizeof(buf)) + 1;
                if(removed)
@@ -1166,7 +1163,7 @@ chm_limit(struct Client *source_p, struct Channel *chptr,
                if(EmptyString(lstr) || (limit = atoi(lstr)) <= 0)
                        return;
 
-               rb_sprintf(limitstr, "%d", limit);
+               sprintf(limitstr, "%d", limit);
 
                mode_changes[mode_count].letter = c;
                mode_changes[mode_count].dir = MODE_ADD;
@@ -1741,9 +1738,9 @@ set_channel_mode(struct Client *client_p, struct Client *source_p,
                return;
 
        if(IsServer(source_p))
-               mlen = rb_sprintf(modebuf, ":%s MODE %s ", fakesource_p->name, chptr->chname);
+               mlen = sprintf(modebuf, ":%s MODE %s ", fakesource_p->name, chptr->chname);
        else
-               mlen = rb_sprintf(modebuf, ":%s!%s@%s MODE %s ",
+               mlen = sprintf(modebuf, ":%s!%s@%s MODE %s ",
                                  source_p->name, source_p->username,
                                  source_p->host, chptr->chname);
 
@@ -1808,7 +1805,7 @@ set_channel_mode(struct Client *client_p, struct Client *source_p,
                        if(mode_changes[i].arg != NULL)
                        {
                                paracount++;
-                               len = rb_sprintf(pbuf, "%s ", mode_changes[i].arg);
+                               len = sprintf(pbuf, "%s ", mode_changes[i].arg);
                                pbuf += len;
                                paralen += len;
                        }
@@ -1835,7 +1832,7 @@ set_channel_mode(struct Client *client_p, struct Client *source_p,
  */
 void
 set_channel_mlock(struct Client *client_p, struct Client *source_p,
-                 struct Channel *chptr, const char *newmlock, int propagate)
+                 struct Channel *chptr, const char *newmlock, bool propagate)
 {
        rb_free(chptr->mode_lock);
        chptr->mode_lock = newmlock ? rb_strdup(newmlock) : NULL;