]> jfr.im git - solanum.git/blobdiff - src/channel.c
ssld: use uint64_t explicitly when we want 64-bit counters
[solanum.git] / src / channel.c
index 20c0dc2c53f29ace90b286fbc28464c708b0658a..5f3f56cc71ed7802d7c230ddb6d0e7b773cac8bb 100644 (file)
@@ -2,9 +2,9 @@
  *  ircd-ratbox: A slightly useful ircd.
  *  channel.c: Controls channels.
  *
- * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center 
- * Copyright (C) 1996-2002 Hybrid Development Team 
- * Copyright (C) 2002-2005 ircd-ratbox development team 
+ * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
+ * Copyright (C) 1996-2002 Hybrid Development Team
+ * Copyright (C) 2002-2005 ircd-ratbox development team
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -42,6 +42,7 @@
 #include "s_newconf.h"
 #include "logger.h"
 #include "ipv4_from_ipv6.h"
+#include "s_assert.h"
 
 struct config_channel_entry ConfigChannel;
 rb_dlink_list global_channel_list;
@@ -136,6 +137,12 @@ send_channel_join(struct Channel *chptr, struct Client *client_p)
                                             client_p->name, client_p->username, client_p->host, chptr->chname,
                                             EmptyString(client_p->user->suser) ? "*" : client_p->user->suser,
                                             client_p->info);
+
+       /* Send away message to away-notify enabled clients. */
+       if (client_p->user->away)
+               sendto_channel_local_with_capability_butone(client_p, ALL_MEMBERS, CLICAP_AWAY_NOTIFY, NOCAPS, chptr,
+                                                           ":%s!%s@%s AWAY :%s", client_p->name, client_p->username,
+                                                           client_p->host, client_p->user->away);
 }
 
 /* find_channel_membership()
@@ -211,7 +218,7 @@ find_channel_status(struct membership *msptr, int combine)
 /* add_user_to_channel()
  *
  * input       - channel to add client to, client to add, channel flags
- * output      - 
+ * output      -
  * side effects - user is added to channel
  */
 void
@@ -458,17 +465,34 @@ channel_member_names(struct Channel *chptr, struct Client *client_p, int show_eo
                        if(IsInvisible(target_p) && !is_member)
                                continue;
 
-                       /* space, possible "@+" prefix */
-                       if(cur_len + strlen(target_p->name) + 3 >= BUFSIZE - 3)
+                       if (IsCapable(client_p, CLICAP_USERHOST_IN_NAMES))
                        {
-                               *(t - 1) = '\0';
-                               sendto_one(client_p, "%s", lbuf);
-                               cur_len = mlen;
-                               t = lbuf + mlen;
+                               /* space, possible "@+" prefix */
+                               if (cur_len + strlen(target_p->name) + strlen(target_p->username) + strlen(target_p->host) + 5 >= BUFSIZE - 5)
+                               {
+                                       *(t - 1) = '\0';
+                                       sendto_one(client_p, "%s", lbuf);
+                                       cur_len = mlen;
+                                       t = lbuf + mlen;
+                               }
+
+                               tlen = rb_sprintf(t, "%s%s!%s@%s ", find_channel_status(msptr, stack),
+                                                 target_p->name, target_p->username, target_p->host);
                        }
+                       else
+                       {
+                               /* space, possible "@+" prefix */
+                               if(cur_len + strlen(target_p->name) + 3 >= BUFSIZE - 3)
+                               {
+                                       *(t - 1) = '\0';
+                                       sendto_one(client_p, "%s", lbuf);
+                                       cur_len = mlen;
+                                       t = lbuf + mlen;
+                               }
 
-                       tlen = rb_sprintf(t, "%s%s ", find_channel_status(msptr, stack),
-                                         target_p->name);
+                               tlen = rb_sprintf(t, "%s%s ", find_channel_status(msptr, stack),
+                                                 target_p->name);
+                       }
 
                        cur_len += tlen;
                        t += tlen;
@@ -761,7 +785,7 @@ can_join(struct Client *source_p, struct Channel *chptr, const char *key, const
        /* join throttling stuff --nenolod */
        else if(chptr->mode.join_num > 0 && chptr->mode.join_time > 0)
        {
-               if ((rb_current_time() - chptr->join_delta <= 
+               if ((rb_current_time() - chptr->join_delta <=
                        chptr->mode.join_time) && (chptr->join_count >=
                        chptr->mode.join_num))
                        i = ERR_THROTTLE;
@@ -797,6 +821,7 @@ can_send(struct Channel *chptr, struct Client *source_p, struct membership *mspt
        hook_data_channel_approval moduledata;
 
        moduledata.approved = CAN_SEND_NONOP;
+       moduledata.dir = MODE_QUERY;
 
        if(IsServer(source_p) || IsService(source_p))
                return CAN_SEND_OPV;
@@ -847,6 +872,7 @@ can_send(struct Channel *chptr, struct Client *source_p, struct membership *mspt
        moduledata.chptr = msptr->chptr;
        moduledata.msptr = msptr;
        moduledata.target = NULL;
+       moduledata.dir = (moduledata.approved == CAN_SEND_NO) ? MODE_ADD : MODE_QUERY;
 
        call_hook(h_can_send, &moduledata);
 
@@ -857,7 +883,7 @@ can_send(struct Channel *chptr, struct Client *source_p, struct membership *mspt
  * flood_attack_channel
  * inputs       - flag 0 if PRIVMSG 1 if NOTICE. RFC
  *                says NOTICE must not auto reply
- *              - pointer to source Client 
+ *              - pointer to source Client
  *             - pointer to target channel
  * output      - 1 if target is under flood attack
  * side effects        - check for flood attack on target chptr
@@ -1065,7 +1091,7 @@ allocate_topic(struct Channel *chptr)
 
        /* Basically we allocate one large block for the topic and
         * the topic info.  We then split it up into two and shove it
-        * in the chptr 
+        * in the chptr
         */
        chptr->topic = ptr;
        chptr->topic_info = (char *) ptr + TOPICLEN + 1;
@@ -1212,8 +1238,6 @@ send_cap_mode_changes(struct Client *client_p, struct Client *source_p,
        int i, mbl, pbl, nc, mc, preflen, len;
        char *pbuf;
        const char *arg;
-       int cap;
-       int nocap;
        int dir;
        int arglen;
 
@@ -1239,9 +1263,6 @@ send_cap_mode_changes(struct Client *client_p, struct Client *source_p,
                if (mode_changes[i].letter == 0)
                        continue;
 
-               cap = mode_changes[i].caps;
-               nocap = mode_changes[i].nocaps;
-
                if (!EmptyString(mode_changes[i].id))
                        arg = mode_changes[i].id;
                else
@@ -1267,7 +1288,7 @@ send_cap_mode_changes(struct Client *client_p, struct Client *source_p,
                           ((mbl + pbl + arglen + 4) > (BUFSIZE - 3))))
                {
                        if(nc != 0)
-                               sendto_server(client_p, chptr, cap, nocap,
+                               sendto_server(client_p, chptr, NOCAPS, NOCAPS,
                                              "%s %s", modebuf, parabuf);
                        nc = 0;
                        mc = 0;
@@ -1302,7 +1323,7 @@ send_cap_mode_changes(struct Client *client_p, struct Client *source_p,
                parabuf[pbl - 1] = 0;
 
        if(nc != 0)
-               sendto_server(client_p, chptr, cap, nocap, "%s %s", modebuf, parabuf);
+               sendto_server(client_p, chptr, NOCAPS, NOCAPS, "%s %s", modebuf, parabuf);
 }
 
 void
@@ -1343,7 +1364,7 @@ resv_chan_forcepart(const char *name, const char *reason, int temp_time)
                        /* notify opers & user they were removed from the channel */
                        sendto_realops_snomask(SNO_GENERAL, L_ALL,
                                             "Forced PART for %s!%s@%s from %s (%s)",
-                                            target_p->name, target_p->username, 
+                                            target_p->name, target_p->username,
                                             target_p->host, name, reason);
 
                        if(temp_time > 0)