]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - modules/core/m_sjoin.c
ircsprintf -> rb_sprintf
[irc/rqf/shadowircd.git] / modules / core / m_sjoin.c
index 3682f2224c4ee12146a826feba1098e0050b92f4..7acac514ccc6b466ce763f8c698fe19f21995c51 100644 (file)
@@ -21,7 +21,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
  *
- *  $Id: m_sjoin.c 3131 2007-01-21 15:36:31Z jilles $
+ *  $Id: m_sjoin.c 3434 2007-04-28 23:47:25Z jilles $
  */
 
 #include "stdinc.h"
@@ -50,7 +50,7 @@ struct Message sjoin_msgtab = {
 
 mapi_clist_av1 sjoin_clist[] = { &sjoin_msgtab, NULL };
 
-DECLARE_MODULE_AV1(sjoin, NULL, NULL, sjoin_clist, NULL, NULL, "$Revision: 3131 $");
+DECLARE_MODULE_AV1(sjoin, NULL, NULL, sjoin_clist, NULL, NULL, "$Revision: 3434 $");
 
 /*
  * ms_sjoin
@@ -75,7 +75,7 @@ static int pargs;
 static void set_final_mode(struct Mode *mode, struct Mode *oldmode);
 static void remove_our_modes(struct Channel *chptr, struct Client *source_p);
 static void remove_ban_list(struct Channel *chptr, struct Client *source_p,
-                           dlink_list * list, char c, int cap, int mems);
+                           rb_dlink_list * list, char c, int cap, int mems);
 
 static int
 ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
@@ -105,7 +105,7 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
        char *p;
        int i, joinc = 0, timeslice = 0;
        static char empty[] = "";
-       dlink_node *ptr, *next_ptr;
+       rb_dlink_node *ptr, *next_ptr;
 
        if(!IsChannelName(parv[2]) || !check_channel_name(parv[2]))
                return 0;
@@ -263,13 +263,13 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
                {
                        struct membership *msptr;
                        struct Client *who;
-                       int l = dlink_list_length(&chptr->members);
-                       int b = dlink_list_length(&chptr->banlist) +
-                               dlink_list_length(&chptr->exceptlist) +
-                               dlink_list_length(&chptr->invexlist) +
-                               dlink_list_length(&chptr->quietlist);
+                       int l = rb_dlink_list_length(&chptr->members);
+                       int b = rb_dlink_list_length(&chptr->banlist) +
+                               rb_dlink_list_length(&chptr->exceptlist) +
+                               rb_dlink_list_length(&chptr->invexlist) +
+                               rb_dlink_list_length(&chptr->quietlist);
 
-                       DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head)
+                       RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->locmembers.head)
                        {
                                msptr = ptr->data;
                                who = msptr->client_p;
@@ -343,7 +343,7 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
        if(!keep_our_modes)
        {
                remove_our_modes(chptr, fakesource_p);
-               DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->invites.head)
+               RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->invites.head)
                {
                        del_invite(chptr, ptr->data);
                }
@@ -351,6 +351,9 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
                                     ":%s NOTICE %s :*** Notice -- TS for %s changed from %ld to %ld",
                                     me.name, chptr->chname, chptr->chname,
                                     (long) oldts, (long) newts);
+               /* Update capitalization in channel name, this makes the
+                * capitalization timestamped like modes are -- jilles */
+               strcpy(chptr->chname, parv[2]);
        }
 
        if(*modebuf != '\0')
@@ -364,14 +367,14 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
        else
                modes = empty_modes;
 
-       mlen_nick = ircsprintf(buf_nick, ":%s SJOIN %ld %s %s :",
+       mlen_nick = rb_sprintf(buf_nick, ":%s SJOIN %ld %s %s :",
                               source_p->name, (long) chptr->channelts, parv[2], modes);
        ptr_nick = buf_nick + mlen_nick;
 
        /* working on the presumption eventually itll be more efficient to
         * build a TS6 buffer without checking its needed..
         */
-       mlen_uid = ircsprintf(buf_uid, ":%s SJOIN %ld %s %s :",
+       mlen_uid = rb_sprintf(buf_uid, ":%s SJOIN %ld %s %s :",
                              use_id(source_p), (long) chptr->channelts, parv[2], modes);
        ptr_uid = buf_uid + mlen_uid;
 
@@ -452,20 +455,15 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
                }
 
                /* copy the nick to the two buffers */
-               len = ircsprintf(ptr_nick, "%s ", target_p->name);
+               len = rb_sprintf(ptr_nick, "%s ", target_p->name);
                ptr_nick += len;
                len_nick += len;
-               len = ircsprintf(ptr_uid, "%s ", use_id(target_p));
+               len = rb_sprintf(ptr_uid, "%s ", use_id(target_p));
                ptr_uid += len;
                len_uid += len;
 
                if(!keep_new_modes)
-               {
-                       if(fl & CHFL_CHANOP)
-                               fl = CHFL_DEOPPED;
-                       else
-                               fl = 0;
-               }
+                       fl = 0;
 
                if(!IsMember(target_p, chptr))
                {
@@ -556,10 +554,9 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
                                     CheckEmpty(para[2]), CheckEmpty(para[3]));
        }
 
-       if(!joins && !(chptr->mode.mode & MODE_PERMANENT))
+       if(!joins && !(chptr->mode.mode & MODE_PERMANENT) && isnew)
        {
-               if(isnew)
-                       destroy_channel(chptr);
+               destroy_channel(chptr);
 
                return 0;
        }
@@ -580,18 +577,18 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
         */
        if(!keep_our_modes && source_p->id[0] != '\0')
        {
-               if(dlink_list_length(&chptr->banlist) > 0)
+               if(rb_dlink_list_length(&chptr->banlist) > 0)
                        remove_ban_list(chptr, fakesource_p, &chptr->banlist, 'b', NOCAPS, ALL_MEMBERS);
 
-               if(dlink_list_length(&chptr->exceptlist) > 0)
+               if(rb_dlink_list_length(&chptr->exceptlist) > 0)
                        remove_ban_list(chptr, fakesource_p, &chptr->exceptlist,
                                        'e', CAP_EX, ONLY_CHANOPS);
 
-               if(dlink_list_length(&chptr->invexlist) > 0)
+               if(rb_dlink_list_length(&chptr->invexlist) > 0)
                        remove_ban_list(chptr, fakesource_p, &chptr->invexlist,
                                        'I', CAP_IE, ONLY_CHANOPS);
 
-               if(dlink_list_length(&chptr->quietlist) > 0)
+               if(rb_dlink_list_length(&chptr->quietlist) > 0)
                        remove_ban_list(chptr, fakesource_p, &chptr->quietlist,
                                        'q', NOCAPS, ALL_MEMBERS);
 
@@ -601,30 +598,6 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char
        return 0;
 }
 
-struct mode_letter
-{
-       int mode;
-       char letter;
-};
-
-static struct mode_letter flags[] = {
-       {MODE_NOPRIVMSGS, 'n'},
-       {MODE_TOPICLIMIT, 't'},
-       {MODE_SECRET, 's'},
-       {MODE_MODERATED, 'm'},
-       {MODE_INVITEONLY, 'i'},
-       {MODE_PRIVATE, 'p'},
-       {MODE_REGONLY, 'r'},
-       {MODE_EXLIMIT, 'L'},
-       {MODE_PERMANENT, 'P'},
-       {MODE_NOCOLOR, 'c'},
-       {MODE_FREEINVITE, 'g'},
-       {MODE_OPMODERATE, 'z'},
-       {MODE_FREETARGET, 'F'},
-       {MODE_DISFORWARD, 'Q'},
-       {0, 0}
-};
-
 static void
 set_final_mode(struct Mode *mode, struct Mode *oldmode)
 {
@@ -634,30 +607,30 @@ set_final_mode(struct Mode *mode, struct Mode *oldmode)
        int i;
 
        /* ok, first get a list of modes we need to add */
-       for (i = 0; flags[i].letter; i++)
+       for (i = 0; chmode_flags[i].letter; i++)
        {
-               if((mode->mode & flags[i].mode) && !(oldmode->mode & flags[i].mode))
+               if((mode->mode & chmode_flags[i].mode) && !(oldmode->mode & chmode_flags[i].mode))
                {
                        if(dir != MODE_ADD)
                        {
                                *mbuf++ = '+';
                                dir = MODE_ADD;
                        }
-                       *mbuf++ = flags[i].letter;
+                       *mbuf++ = chmode_flags[i].letter;
                }
        }
 
        /* now the ones we need to remove. */
-       for (i = 0; flags[i].letter; i++)
+       for (i = 0; chmode_flags[i].letter; i++)
        {
-               if((oldmode->mode & flags[i].mode) && !(mode->mode & flags[i].mode))
+               if((oldmode->mode & chmode_flags[i].mode) && !(mode->mode & chmode_flags[i].mode))
                {
                        if(dir != MODE_DEL)
                        {
                                *mbuf++ = '-';
                                dir = MODE_DEL;
                        }
-                       *mbuf++ = flags[i].letter;
+                       *mbuf++ = chmode_flags[i].letter;
                }
        }
 
@@ -678,7 +651,7 @@ set_final_mode(struct Mode *mode, struct Mode *oldmode)
                        dir = MODE_DEL;
                }
                *mbuf++ = 'k';
-               len = ircsprintf(pbuf, "%s ", oldmode->key);
+               len = rb_sprintf(pbuf, "%s ", oldmode->key);
                pbuf += len;
                pargs++;
        }
@@ -708,7 +681,7 @@ set_final_mode(struct Mode *mode, struct Mode *oldmode)
                        dir = MODE_ADD;
                }
                *mbuf++ = 'l';
-               len = ircsprintf(pbuf, "%d ", mode->limit);
+               len = rb_sprintf(pbuf, "%d ", mode->limit);
                pbuf += len;
                pargs++;
        }
@@ -720,7 +693,7 @@ set_final_mode(struct Mode *mode, struct Mode *oldmode)
                        dir = MODE_ADD;
                }
                *mbuf++ = 'k';
-               len = ircsprintf(pbuf, "%s ", mode->key);
+               len = rb_sprintf(pbuf, "%s ", mode->key);
                pbuf += len;
                pargs++;
        }
@@ -732,7 +705,7 @@ set_final_mode(struct Mode *mode, struct Mode *oldmode)
                        dir = MODE_ADD;
                }
                *mbuf++ = 'j';
-               len = ircsprintf(pbuf, "%d:%d ", mode->join_num, mode->join_time);
+               len = rb_sprintf(pbuf, "%d:%d ", mode->join_num, mode->join_time);
                pbuf += len;
                pargs++;
        }
@@ -744,7 +717,7 @@ set_final_mode(struct Mode *mode, struct Mode *oldmode)
                        dir = MODE_ADD;
                }
                *mbuf++ = 'f';
-               len = ircsprintf(pbuf, "%s ", mode->forward);
+               len = rb_sprintf(pbuf, "%s ", mode->forward);
                pbuf += len;
                pargs++;
        }
@@ -762,7 +735,7 @@ static void
 remove_our_modes(struct Channel *chptr, struct Client *source_p)
 {
        struct membership *msptr;
-       dlink_node *ptr;
+       rb_dlink_node *ptr;
        char lmodebuf[MODEBUFLEN];
        char *lpara[MAXMODEPARAMS];
        int count = 0;
@@ -774,7 +747,7 @@ remove_our_modes(struct Channel *chptr, struct Client *source_p)
        for (i = 0; i < MAXMODEPARAMS; i++)
                lpara[i] = NULL;
 
-       DLINK_FOREACH(ptr, chptr->members.head)
+       RB_DLINK_FOREACH(ptr, chptr->members.head)
        {
                msptr = ptr->data;
 
@@ -858,23 +831,23 @@ remove_our_modes(struct Channel *chptr, struct Client *source_p)
  */
 static void
 remove_ban_list(struct Channel *chptr, struct Client *source_p,
-               dlink_list * list, char c, int cap, int mems)
+               rb_dlink_list * list, char c, int cap, int mems)
 {
        static char lmodebuf[BUFSIZE];
        static char lparabuf[BUFSIZE];
        struct Ban *banptr;
-       dlink_node *ptr;
-       dlink_node *next_ptr;
+       rb_dlink_node *ptr;
+       rb_dlink_node *next_ptr;
        char *pbuf;
        int count = 0;
        int cur_len, mlen, plen;
 
        pbuf = lparabuf;
 
-       cur_len = mlen = ircsprintf(lmodebuf, ":%s MODE %s -", source_p->name, chptr->chname);
+       cur_len = mlen = rb_sprintf(lmodebuf, ":%s MODE %s -", source_p->name, chptr->chname);
        mbuf = lmodebuf + mlen;
 
-       DLINK_FOREACH_SAFE(ptr, next_ptr, list->head)
+       RB_DLINK_FOREACH_SAFE(ptr, next_ptr, list->head)
        {
                banptr = ptr->data;
 
@@ -902,7 +875,7 @@ remove_ban_list(struct Channel *chptr, struct Client *source_p,
 
                *mbuf++ = c;
                cur_len += plen;
-               pbuf += ircsprintf(pbuf, "%s ", banptr->banstr);
+               pbuf += rb_sprintf(pbuf, "%s ", banptr->banstr);
                count++;
 
                free_ban(banptr);