]> jfr.im git - solanum.git/blobdiff - ircd/supported.c
Correct order of chunking and encoding steps.
[solanum.git] / ircd / supported.c
index 69a95d6279691055933ab7405292b7b4f8b9c31c..4aa653ecdfe1bb295cc11952dabe63082eba7c71 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  charybdis: A slightly useful ircd.
+ *  Solanum: a slightly advanced ircd
  *  supported.c: isupport (005) numeric
  *
  * Copyright (C) 2006 Jilles Tjoelker
@@ -27,8 +27,6 @@
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
- *
- *  $Id: supported.c 3568 2007-09-09 18:59:08Z jilles $
  */
 
 /* From the old supported.h which is
@@ -74,7 +72,6 @@
 
 #include "stdinc.h"
 #include "client.h"
-#include "common.h"
 #include "numeric.h"
 #include "ircd.h"
 #include "s_conf.h"
@@ -83,6 +80,7 @@
 #include "chmode.h"
 #include "send.h"
 
+static char allowed_chantypes[BUFSIZE];
 rb_dlink_list isupportlist;
 
 struct isupportitem
@@ -201,7 +199,7 @@ const char *
 isupport_intptr(const void *ptr)
 {
        static char buf[15];
-       rb_snprintf(buf, sizeof buf, "%d", *(const int *)ptr);
+       snprintf(buf, sizeof buf, "%d", *(const int *)ptr);
        return buf;
 }
 
@@ -225,7 +223,7 @@ isupport_stringptr(const void *ptr)
        return *(char * const *)ptr;
 }
 
-static const char *
+const char *
 isupport_umode(const void *ptr)
 {
        const char *str;
@@ -238,9 +236,9 @@ isupport_umode(const void *ptr)
 static const char *
 isupport_chanmodes(const void *ptr)
 {
-       static char result[80];
+       static char result[300];
 
-       rb_snprintf(result, sizeof result, "%s%sbq,k,%slj,%s",
+       snprintf(result, sizeof result, "%s%sbq,k,%slj,%s",
                        ConfigChannel.use_except ? "e" : "",
                        ConfigChannel.use_invex ? "I" : "",
                        ConfigChannel.use_forward ? "f" : "",
@@ -248,19 +246,12 @@ isupport_chanmodes(const void *ptr)
        return result;
 }
 
-static const char *
-isupport_chantypes(const void *ptr)
-{
-       return ConfigChannel.disable_local_channels ? "#" : "&#";
-}
-
 static const char *
 isupport_chanlimit(const void *ptr)
 {
-       static char result[30];
+       static char result[BUFSIZE + 30];
 
-       rb_snprintf(result, sizeof result, "%s:%i",
-               ConfigChannel.disable_local_channels ? "#" : "&#", ConfigChannel.max_chans_per_user);
+       snprintf(result, sizeof result, "%s:%i", allowed_chantypes, ConfigChannel.max_chans_per_user);
        return result;
 }
 
@@ -269,7 +260,7 @@ isupport_maxlist(const void *ptr)
 {
        static char result[30];
 
-       rb_snprintf(result, sizeof result, "bq%s%s:%i",
+       snprintf(result, sizeof result, "bq%s%s:%i",
                        ConfigChannel.use_except ? "e" : "",
                        ConfigChannel.use_invex ? "I" : "",
                        ConfigChannel.max_bans);
@@ -281,7 +272,7 @@ isupport_targmax(const void *ptr)
 {
        static char result[200];
 
-       rb_snprintf(result, sizeof result, "NAMES:1,LIST:1,KICK:1,WHOIS:1,PRIVMSG:%d,NOTICE:%d,ACCEPT:,MONITOR:",
+       snprintf(result, sizeof result, "NAMES:1,LIST:1,KICK:1,WHOIS:1,PRIVMSG:%d,NOTICE:%d,ACCEPT:,MONITOR:",
                        ConfigFileEntry.max_targets,
                        ConfigFileEntry.max_targets);
        return result;
@@ -296,7 +287,7 @@ isupport_extban(const void *ptr)
        p = get_extban_string();
        if (EmptyString(p))
                return NULL;
-       rb_snprintf(result, sizeof result, "$,%s", p);
+       snprintf(result, sizeof result, "$,%s", p);
        return result;
 }
 
@@ -305,7 +296,7 @@ isupport_nicklen(const void *ptr)
 {
        static char result[200];
 
-       rb_snprintf(result, sizeof result, "%u", ConfigFileEntry.nicklen - 1);
+       snprintf(result, sizeof result, "%u", ConfigFileEntry.nicklen - 1);
        return result;
 }
 
@@ -317,7 +308,7 @@ init_isupport(void)
        static int topiclen = TOPICLEN;
        static int maxnicklen = NICKLEN - 1;
 
-       add_isupport("CHANTYPES", isupport_chantypes, NULL);
+       add_isupport("CHANTYPES", isupport_string, allowed_chantypes);
        add_isupport("EXCEPTS", isupport_boolean, &ConfigChannel.use_except);
        add_isupport("INVEX", isupport_boolean, &ConfigChannel.use_invex);
        add_isupport("CHANMODES", isupport_chanmodes, NULL);
@@ -327,7 +318,6 @@ init_isupport(void)
        add_isupport("MODES", isupport_intptr, &maxmodes);
        add_isupport("NETWORK", isupport_stringptr, &ServerInfo.network_name);
        add_isupport("STATUSMSG", isupport_string, "@+");
-       add_isupport("CALLERID", isupport_umode, "g");
        add_isupport("CASEMAPPING", isupport_string, "rfc1459");
        add_isupport("NICKLEN", isupport_nicklen, NULL);
        add_isupport("MAXNICKLEN", isupport_intptr, &maxnicklen);
@@ -336,5 +326,19 @@ init_isupport(void)
        add_isupport("DEAF", isupport_umode, "D");
        add_isupport("TARGMAX", isupport_targmax, NULL);
        add_isupport("EXTBAN", isupport_extban, NULL);
-       add_isupport("CLIENTVER", isupport_string, "3.0");
+}
+
+void
+chantypes_update(void)
+{
+       unsigned char *p;
+       memset(allowed_chantypes, '\0', sizeof allowed_chantypes);
+
+       p = (unsigned char *) allowed_chantypes;
+
+       for (unsigned int i = 0; i < 256; i++)
+       {
+               if (IsChanPrefix(i))
+                       *p++ = (unsigned char) i;
+       }
 }