]> jfr.im git - solanum.git/blobdiff - ircd/channel.c
ircd: send tags on every message
[solanum.git] / ircd / channel.c
index 6caf9fcb270ed4225a4015dd5da78632a3fa3d1a..50e96a3a899e35248fb3d49b6d3579e449393c59 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: channel.c 3580 2007-11-07 23:45:14Z jilles $
  */
 
 #include "stdinc.h"
 #include "channel.h"
 #include "chmode.h"
 #include "client.h"
-#include "common.h"
 #include "hash.h"
 #include "hook.h"
 #include "match.h"
@@ -41,9 +38,7 @@
 #include "s_conf.h"            /* ConfigFileEntry, ConfigChannel */
 #include "s_newconf.h"
 #include "logger.h"
-#include "ipv4_from_ipv6.h"
 #include "s_assert.h"
-#include "inline/stringops.h"
 
 struct config_channel_entry ConfigChannel;
 rb_dlink_list global_channel_list;
@@ -131,10 +126,10 @@ send_channel_join(struct Channel *chptr, struct Client *client_p)
        if (!IsClient(client_p))
                return;
 
-       sendto_channel_local_with_capability(ALL_MEMBERS, NOCAPS, CLICAP_EXTENDED_JOIN, chptr, ":%s!%s@%s JOIN %s",
+       sendto_channel_local_with_capability(client_p, ALL_MEMBERS, NOCAPS, CLICAP_EXTENDED_JOIN, chptr, ":%s!%s@%s JOIN %s",
                                             client_p->name, client_p->username, client_p->host, chptr->chname);
 
-       sendto_channel_local_with_capability(ALL_MEMBERS, CLICAP_EXTENDED_JOIN, NOCAPS, chptr, ":%s!%s@%s JOIN %s %s :%s",
+       sendto_channel_local_with_capability(client_p, ALL_MEMBERS, CLICAP_EXTENDED_JOIN, NOCAPS, chptr, ":%s!%s@%s JOIN %s %s :%s",
                                             client_p->name, client_p->username, client_p->host, chptr->chname,
                                             EmptyString(client_p->user->suser) ? "*" : client_p->user->suser,
                                             client_p->info);
@@ -340,23 +335,23 @@ invalidate_bancache_user(struct Client *client_p)
 /* check_channel_name()
  *
  * input       - channel name
- * output      - 1 if valid channel name, else 0
+ * output      - true if valid channel name, else false
  * side effects -
  */
-int
+bool
 check_channel_name(const char *name)
 {
        s_assert(name != NULL);
        if(name == NULL)
-               return 0;
+               return false;
 
        for (; *name; ++name)
        {
                if(!IsChanChar(*name))
-                       return 0;
+                       return false;
        }
 
-       return 1;
+       return true;
 }
 
 /* free_channel_list()
@@ -452,7 +447,7 @@ channel_member_names(struct Channel *chptr, struct Client *client_p, int show_eo
        {
                is_member = IsMember(client_p, chptr);
 
-               cur_len = mlen = rb_sprintf(lbuf, form_str(RPL_NAMREPLY),
+               cur_len = mlen = sprintf(lbuf, form_str(RPL_NAMREPLY),
                                            me.name, client_p->name,
                                            channel_pub_or_secret(chptr), chptr->chname);
 
@@ -477,7 +472,7 @@ channel_member_names(struct Channel *chptr, struct Client *client_p, int show_eo
                                        t = lbuf + mlen;
                                }
 
-                               tlen = rb_sprintf(t, "%s%s!%s@%s ", find_channel_status(msptr, stack),
+                               tlen = sprintf(t, "%s%s!%s@%s ", find_channel_status(msptr, stack),
                                                  target_p->name, target_p->username, target_p->host);
                        }
                        else
@@ -491,7 +486,7 @@ channel_member_names(struct Channel *chptr, struct Client *client_p, int show_eo
                                        t = lbuf + mlen;
                                }
 
-                               tlen = rb_sprintf(t, "%s%s ", find_channel_status(msptr, stack),
+                               tlen = sprintf(t, "%s%s ", find_channel_status(msptr, stack),
                                                  target_p->name);
                        }
 
@@ -561,8 +556,8 @@ is_banned_list(struct Channel *chptr, rb_dlink_list *list,
        /* if the buffers havent been built, do it here */
        if(s == NULL)
        {
-               rb_sprintf(src_host, "%s!%s@%s", who->name, who->username, who->host);
-               rb_sprintf(src_iphost, "%s!%s@%s", who->name, who->username, who->sockhost);
+               sprintf(src_host, "%s!%s@%s", who->name, who->username, who->host);
+               sprintf(src_iphost, "%s!%s@%s", who->name, who->username, who->sockhost);
 
                s = src_host;
                s2 = src_iphost;
@@ -572,22 +567,22 @@ is_banned_list(struct Channel *chptr, rb_dlink_list *list,
                /* if host mangling mode enabled, also check their real host */
                if(!strcmp(who->host, who->localClient->mangledhost))
                {
-                       rb_sprintf(src_althost, "%s!%s@%s", who->name, who->username, who->orighost);
+                       sprintf(src_althost, "%s!%s@%s", who->name, who->username, who->orighost);
                        s3 = src_althost;
                }
                /* if host mangling mode not enabled and no other spoof,
                 * also check the mangled form of their host */
                else if (!IsDynSpoof(who))
                {
-                       rb_sprintf(src_althost, "%s!%s@%s", who->name, who->username, who->localClient->mangledhost);
+                       sprintf(src_althost, "%s!%s@%s", who->name, who->username, who->localClient->mangledhost);
                        s3 = src_althost;
                }
        }
 #ifdef RB_IPV6
-       if(who->localClient->ip.ss_family == AF_INET6 &&
-                       ipv4_from_ipv6((const struct sockaddr_in6 *)&who->localClient->ip, &ip4))
+       if(GET_SS_FAMILY(&who->localClient->ip) == AF_INET6 &&
+                       rb_ipv4_from_ipv6((const struct sockaddr_in6 *)&who->localClient->ip, &ip4))
        {
-               rb_sprintf(src_ip4host, "%s!%s@", who->name, who->username);
+               sprintf(src_ip4host, "%s!%s@", who->name, who->username);
                s4 = src_ip4host + strlen(src_ip4host);
                rb_inet_ntop_sock((struct sockaddr *)&ip4,
                                s4, src_ip4host + sizeof src_ip4host - s4);
@@ -672,6 +667,7 @@ int
 is_banned(struct Channel *chptr, struct Client *who, struct membership *msptr,
          const char *s, const char *s2, const char **forward)
 {
+#if 0
        if (chptr->last_checked_client != NULL &&
                who == chptr->last_checked_client &&
                chptr->last_checked_type == CHFL_BAN &&
@@ -684,6 +680,9 @@ is_banned(struct Channel *chptr, struct Client *who, struct membership *msptr,
        chptr->last_checked_ts = rb_current_time();
 
        return chptr->last_checked_result;
+#else
+       return is_banned_list(chptr, &chptr->banlist, who, msptr, s, s2, forward);
+#endif
 }
 
 /* is_quieted()
@@ -697,6 +696,7 @@ int
 is_quieted(struct Channel *chptr, struct Client *who, struct membership *msptr,
           const char *s, const char *s2)
 {
+#if 0
        if (chptr->last_checked_client != NULL &&
                who == chptr->last_checked_client &&
                chptr->last_checked_type == CHFL_QUIET &&
@@ -709,6 +709,9 @@ is_quieted(struct Channel *chptr, struct Client *who, struct membership *msptr,
        chptr->last_checked_ts = rb_current_time();
 
        return chptr->last_checked_result;
+#else
+       return is_banned_list(chptr, &chptr->quietlist, who, msptr, s, s2, NULL);
+#endif
 }
 
 /* can_join()
@@ -737,21 +740,21 @@ can_join(struct Client *source_p, struct Channel *chptr, const char *key, const
        moduledata.chptr = chptr;
        moduledata.approved = 0;
 
-       rb_sprintf(src_host, "%s!%s@%s", source_p->name, source_p->username, source_p->host);
-       rb_sprintf(src_iphost, "%s!%s@%s", source_p->name, source_p->username, source_p->sockhost);
+       sprintf(src_host, "%s!%s@%s", source_p->name, source_p->username, source_p->host);
+       sprintf(src_iphost, "%s!%s@%s", source_p->name, source_p->username, source_p->sockhost);
        if(source_p->localClient->mangledhost != NULL)
        {
                /* if host mangling mode enabled, also check their real host */
                if(!strcmp(source_p->host, source_p->localClient->mangledhost))
                {
-                       rb_sprintf(src_althost, "%s!%s@%s", source_p->name, source_p->username, source_p->orighost);
+                       sprintf(src_althost, "%s!%s@%s", source_p->name, source_p->username, source_p->orighost);
                        use_althost = 1;
                }
                /* if host mangling mode not enabled and no other spoof,
                 * also check the mangled form of their host */
                else if (!IsDynSpoof(source_p))
                {
-                       rb_sprintf(src_althost, "%s!%s@%s", source_p->name, source_p->username, source_p->localClient->mangledhost);
+                       sprintf(src_althost, "%s!%s@%s", source_p->name, source_p->username, source_p->localClient->mangledhost);
                        use_althost = 1;
                }
        }
@@ -905,11 +908,11 @@ can_send(struct Channel *chptr, struct Client *source_p, struct membership *mspt
  * inputs       - flag 0 if PRIVMSG 1 if NOTICE. RFC
  *                says NOTICE must not auto reply
  *              - pointer to source Client
- *             - pointer to target channel
- * output      - 1 if target is under flood attack
+ *              - pointer to target channel
+ * output       - true if target is under flood attack
  * side effects        - check for flood attack on target chptr
  */
-int
+bool
 flood_attack_channel(int p_or_n, struct Client *source_p, struct Channel *chptr, char *chname)
 {
        int delta;
@@ -947,13 +950,13 @@ flood_attack_channel(int p_or_n, struct Client *source_p, struct Channel *chptr,
                                sendto_one(source_p,
                                           ":%s NOTICE %s :*** Message to %s throttled due to flooding",
                                           me.name, source_p->name, chptr->chname);
-                       return 1;
+                       return true;
                }
                else
                        chptr->received_number_of_privmsgs++;
        }
 
-       return 0;
+       return false;
 }
 
 /* find_bannickchange_channel()
@@ -972,8 +975,8 @@ find_bannickchange_channel(struct Client *client_p)
        if (!MyClient(client_p))
                return NULL;
 
-       rb_sprintf(src_host, "%s!%s@%s", client_p->name, client_p->username, client_p->host);
-       rb_sprintf(src_iphost, "%s!%s@%s", client_p->name, client_p->username, client_p->sockhost);
+       sprintf(src_host, "%s!%s@%s", client_p->name, client_p->username, client_p->host);
+       sprintf(src_iphost, "%s!%s@%s", client_p->name, client_p->username, client_p->sockhost);
 
        RB_DLINK_FOREACH(ptr, client_p->user->channel.head)
        {
@@ -1159,9 +1162,6 @@ set_channel_topic(struct Channel *chptr, const char *topic, const char *topic_in
                rb_strlcpy(chptr->topic, topic, TOPICLEN + 1);
                rb_strlcpy(chptr->topic_info, topic_info, USERHOST_REPLYLEN);
                chptr->topic_time = topicts;
-
-               if (ConfigChannel.strip_topic_colors)
-                       strip_colour(chptr->topic);
        }
        else
        {
@@ -1206,7 +1206,7 @@ channel_modes(struct Channel *chptr, struct Client *client_p)
                *mbuf++ = 'l';
 
                if(!IsClient(client_p) || IsMember(client_p, chptr))
-                       pbuf += rb_sprintf(pbuf, " %d", chptr->mode.limit);
+                       pbuf += sprintf(pbuf, " %d", chptr->mode.limit);
        }
 
        if(*chptr->mode.key)
@@ -1214,7 +1214,7 @@ channel_modes(struct Channel *chptr, struct Client *client_p)
                *mbuf++ = 'k';
 
                if(pbuf > buf2 || !IsClient(client_p) || IsMember(client_p, chptr))
-                       pbuf += rb_sprintf(pbuf, " %s", chptr->mode.key);
+                       pbuf += sprintf(pbuf, " %s", chptr->mode.key);
        }
 
        if(chptr->mode.join_num)
@@ -1222,7 +1222,7 @@ channel_modes(struct Channel *chptr, struct Client *client_p)
                *mbuf++ = 'j';
 
                if(pbuf > buf2 || !IsClient(client_p) || IsMember(client_p, chptr))
-                       pbuf += rb_sprintf(pbuf, " %d:%d", chptr->mode.join_num,
+                       pbuf += sprintf(pbuf, " %d:%d", chptr->mode.join_num,
                                           chptr->mode.join_time);
        }
 
@@ -1232,7 +1232,7 @@ channel_modes(struct Channel *chptr, struct Client *client_p)
                *mbuf++ = 'f';
 
                if(pbuf > buf2 || !IsClient(client_p) || IsMember(client_p, chptr))
-                       pbuf += rb_sprintf(pbuf, " %s", chptr->mode.forward);
+                       pbuf += sprintf(pbuf, " %s", chptr->mode.forward);
        }
 
        *mbuf = '\0';
@@ -1267,7 +1267,7 @@ send_cap_mode_changes(struct Client *client_p, struct Client *source_p,
        char *pbuf;
        const char *arg;
        int dir;
-       int arglen;
+       int arglen = 0;
 
        /* Now send to servers... */
        mc = 0;
@@ -1277,7 +1277,7 @@ send_cap_mode_changes(struct Client *client_p, struct Client *source_p,
        pbuf = parabuf;
        dir = MODE_QUERY;
 
-       mbl = preflen = rb_sprintf(modebuf, ":%s TMODE %ld %s ",
+       mbl = preflen = sprintf(modebuf, ":%s TMODE %ld %s ",
                                   use_id(source_p), (long) chptr->channelts,
                                   chptr->chname);
 
@@ -1340,7 +1340,7 @@ send_cap_mode_changes(struct Client *client_p, struct Client *source_p,
 
                if(arg != NULL)
                {
-                       len = rb_sprintf(pbuf, "%s ", arg);
+                       len = sprintf(pbuf, "%s ", arg);
                        pbuf += len;
                        pbl += len;
                        mc++;
@@ -1383,7 +1383,7 @@ resv_chan_forcepart(const char *name, const char *reason, int temp_time)
                        sendto_server(target_p, chptr, CAP_TS6, NOCAPS,
                                      ":%s PART %s", target_p->id, chptr->chname);
 
-                       sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s :%s",
+                       sendto_channel_local(target_p, ALL_MEMBERS, chptr, ":%s!%s@%s PART %s :%s",
                                             target_p->name, target_p->username,
                                             target_p->host, chptr->chname, target_p->name);