]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/proto-common.c
Lots of style changes to user replies. added numeric access back
[irc/evilnet/x3.git] / src / proto-common.c
index bc5a4164045d92fb182eeb07dcb20d404be57258..0cff85ad2b3e728da3b2f45cb902161aa8792b20 100644 (file)
@@ -1,7 +1,7 @@
 /* proto-common.c - common IRC protocol parsing/sending support
  * Copyright 2000-2004 srvx Development Team
  *
- * This file is part of srvx.
+ * This file is part of x3.
  *
  * srvx is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -373,7 +373,7 @@ static CMD_FUNC(cmd_version)
         log_module(MAIN_LOG, LOG_ERROR, "Could not find VERSION origin user %s", origin);
         return 0;
     }
-    irc_numeric(user, 351, "%s.%s %s :%s", PACKAGE_TARNAME, PACKAGE_VERSION, self->name, CODENAME);
+    irc_numeric(user, 351, "%s %s %s", PACKAGE_TARNAME, PACKAGE_VERSION, self->name);
     return 1;
 }
 
@@ -440,8 +440,9 @@ privmsg_chan_helper(struct chanNode *cn, void *data)
         mn->idle_since = now;
 
     /* Never send a NOTICE to a channel to one of the services */
-    if (!pd->is_notice && cf->func && GetUserMode(cn, cf->service))
-        cf->func(pd->user, cn, pd->text+1, cf->service);
+    if (!pd->is_notice && cf->func
+        && ((cn->modes & MODE_REGISTERED) || GetUserMode(cn, cf->service)))
+         cf->func(pd->user, cn, pd->text+1, cf->service);
 
     /* This catches *all* text sent to the channel that the services server sees */
     for (x = 0; x < ALLCHANMSG_FUNCS_MAX; x++) {
@@ -449,7 +450,7 @@ privmsg_chan_helper(struct chanNode *cn, void *data)
        if (!cf->func)
          break; /* end of list */
        else
-       cf->func(pd->user, cn, pd->text, cf->service);
+         cf->func(pd->user, cn, pd->text, cf->service);
     }
 }
 
@@ -569,14 +570,15 @@ mod_chanmode_apply(struct userNode *who, struct chanNode *channel, struct mod_ch
              * to be more specific than an existing ban.
              */
             for (jj=0; jj<channel->banlist.used; ++jj) {
-                if (match_ircglobs(change->args[ii].hostmask, channel->banlist.list[jj]->ban)) {
-                    banList_remove(&channel->banlist, channel->banlist.list[jj]);
-                    free(channel->banlist.list[jj]);
+                bn = channel->banlist.list[jj];
+                if (match_ircglobs(change->args[ii].u.hostmask, bn->ban)) {
+                    banList_remove(&channel->banlist, bn);
+                    free(bn);
                     jj--;
                 }
             }
             bn = calloc(1, sizeof(*bn));
-            safestrncpy(bn->ban, change->args[ii].hostmask, sizeof(bn->ban));
+            safestrncpy(bn->ban, change->args[ii].u.hostmask, sizeof(bn->ban));
             if (who)
                 safestrncpy(bn->who, who->nick, sizeof(bn->who));
             else
@@ -586,10 +588,11 @@ mod_chanmode_apply(struct userNode *who, struct chanNode *channel, struct mod_ch
             break;
         case MODE_REMOVE|MODE_BAN:
             for (jj=0; jj<channel->banlist.used; ++jj) {
-                if (strcmp(channel->banlist.list[jj]->ban, change->args[ii].hostmask))
+                bn = channel->banlist.list[jj];
+                if (strcmp(bn->ban, change->args[ii].u.hostmask))
                     continue;
-                free(channel->banlist.list[jj]);
-                banList_remove(&channel->banlist, channel->banlist.list[jj]);
+                free(bn);
+                banList_remove(&channel->banlist, bn);
                 break;
             }
             break;
@@ -599,14 +602,14 @@ mod_chanmode_apply(struct userNode *who, struct chanNode *channel, struct mod_ch
              * to be more specific than an existing exempt.
              */
             for (jj=0; jj<channel->exemptlist.used; ++jj) {
-                if (match_ircglobs(change->args[ii].hostmask, channel->exemptlist.list[jj]->exempt)) {
+                if (match_ircglobs(change->args[ii].u.hostmask, channel->exemptlist.list[jj]->exempt)) {
                     exemptList_remove(&channel->exemptlist, channel->exemptlist.list[jj]);
                     free(channel->exemptlist.list[jj]);
                     jj--;
                 }
             }
             en = calloc(1, sizeof(*en));
-            safestrncpy(en->exempt, change->args[ii].hostmask, sizeof(en->exempt));
+            safestrncpy(en->exempt, change->args[ii].u.hostmask, sizeof(en->exempt));
             if (who)
                 safestrncpy(en->who, who->nick, sizeof(en->who));
             else
@@ -616,7 +619,7 @@ mod_chanmode_apply(struct userNode *who, struct chanNode *channel, struct mod_ch
             break;
         case MODE_REMOVE|MODE_EXEMPT:
             for (jj=0; jj<channel->exemptlist.used; ++jj) {
-                if (strcmp(channel->exemptlist.list[jj]->exempt, change->args[ii].hostmask))
+                if (strcmp(channel->exemptlist.list[jj]->exempt, change->args[ii].u.hostmask))
                     continue;
                 free(channel->exemptlist.list[jj]);
                 exemptList_remove(&channel->exemptlist, channel->exemptlist.list[jj]);
@@ -632,9 +635,9 @@ mod_chanmode_apply(struct userNode *who, struct chanNode *channel, struct mod_ch
         case MODE_REMOVE|MODE_VOICE:
         case MODE_REMOVE|MODE_VOICE|MODE_CHANOP|MODE_HALFOP:
             if (change->args[ii].mode & MODE_REMOVE)
-                change->args[ii].member->modes &= ~change->args[ii].mode;
+                change->args[ii].u.member->modes &= ~change->args[ii].mode;
             else
-                change->args[ii].member->modes |= change->args[ii].mode;
+                change->args[ii].u.member->modes |= change->args[ii].mode;
             break;
         default:
             assert(0 && "Invalid mode argument");
@@ -671,7 +674,8 @@ mod_chanmode(struct userNode *who, struct chanNode *channel, char **modes, unsig
 }
 
 int
-irc_make_chanmode(struct chanNode *chan, char *out) {
+irc_make_chanmode(struct chanNode *chan, char *out)
+{
     struct mod_chanmode change;
     mod_chanmode_init(&change);
     change.modes_set = chan->modes;
@@ -733,7 +737,7 @@ generate_hostmask(struct userNode *user, int options)
         mask = ~0 << masklen;
         masked_ip = ntohl(user->ip.s_addr) & mask;
         hostname = alloca(32);
-        if (options & GENMASK_SRVXMASK) {
+        if (options & GENMASK_X3MASK) {
             sprintf(hostname, "%d.%d.%d.%d/%d", (masked_ip>>24)&0xFF, (masked_ip>>16)&0xFF, (masked_ip>>8)&0xFF, masked_ip&0xFF, masklen);
         } else {
             int ofs = 0;