Просмотр исходного кода

* CFG_CMDPREFIX now works
* cmdprefix is now a 'char'


svn: 1020

Bryan Drewery 22 лет назад
Родитель
Сommit
efae66f8d2
7 измененных файлов с 25 добавлено и 28 удалено
  1. 1 0
      doc/UPDATES
  2. 7 11
      src/cfg.c
  3. 1 1
      src/cfg.h
  4. 2 2
      src/mod/irc.mod/chan.c
  5. 1 1
      src/mod/irc.mod/irc.c
  6. 9 9
      src/mod/irc.mod/msgcmds.c
  7. 4 4
      src/mod/server.mod/servmsg.c

+ 1 - 0
doc/UPDATES

@@ -13,6 +13,7 @@ This is a summary of ChangeLog basically.
 9.Bots now record: USERNAME, NODENAME (shell host), OS in .whois.
 10.+private checking was segfaulting some cmds under certain conditions.
 11.Leaf bots weren't sharing partyline members on link.
+12.cfg: cmdprefix is now working as intended.
 
 1.1.7
 

+ 7 - 11
src/cfg.c

@@ -29,7 +29,7 @@
 
 int 				cfg_count = 0, cfg_noshare = 0;
 struct cfg_entry 		**cfg = NULL;
-char 				cmdprefix[1] = "+";	/* This is the prefix for msg/channel cmds */
+char 				cmdprefix = '+';	/* This is the prefix for msg/channel cmds */
 #ifdef S_DCCPASS
 struct cmd_pass 		*cmdpass = NULL;
 #endif /* S_DCCPASS */
@@ -113,19 +113,15 @@ struct cfg_entry CFG_MSGIDENT = {
 
 void cmdprefix_describe(struct cfg_entry *entry, int idx) {
 #ifdef HUB
-  dprintf(idx, STR("cmdprefix is the prefix used for msg cmds, ie: !op or .op\n"));
+  dprintf(idx, STR("cmdprefix is the prefix character used for msg cmds, ie: !op or .op\n"));
 #endif /* HUB */
 }
 
 void cmdprefix_changed(struct cfg_entry * entry, char * olddata, int * valid) {
-  if (entry->ldata) {
-    cmdprefix[0] = entry->ldata[0];
-    /* strncpyz(cmdprefix, (char *) entry->ldata, 2); */
-  } else if (entry->gdata) {
-    cmdprefix[0] = entry->gdata[0];
-    /* strncpyz(cmdprefix, (char *) entry->gdata, 2); */
-  }
-  cmdprefix[1] = 0;
+  if (entry->ldata)
+    cmdprefix = entry->ldata[0];
+  else if (entry->gdata)
+    cmdprefix = entry->gdata[0];
 }
 
 struct cfg_entry CFG_CMDPREFIX = {
@@ -721,12 +717,12 @@ void init_config()
   add_cfg(&CFG_MSGINVITE);
   add_cfg(&CFG_MSGIDENT);
 #endif /* S_MSGCMDS */
+  add_cfg(&CFG_CMDPREFIX);
 #ifdef HUB
   add_cfg(&CFG_NICK);
   add_cfg(&CFG_SERVERS);
   add_cfg(&CFG_SERVERS6);
   add_cfg(&CFG_REALNAME);
-  add_cfg(&CFG_CMDPREFIX);
   cfg_noshare = 1;
   set_cfg_str(NULL, "realname", "A deranged product of evil coders");
   cfg_noshare = 0;

+ 1 - 1
src/cfg.h

@@ -65,7 +65,7 @@ void set_cmd_pass(char *, int);
 extern struct cmd_pass            *cmdpass;
 #endif /* S_DCCPASS */
 
-extern char			cmdprefix[];
+extern char			cmdprefix;
 extern int			cfg_count, cfg_noshare;
 extern struct cfg_entry		**cfg;
 

+ 2 - 2
src/mod/irc.mod/chan.c

@@ -2742,10 +2742,10 @@ static int gotmsg(char *from, char *msg)
     if (botmatch && strcmp(fword, "*"))	
       fword = newsplit(&my_msg);	/* now this will be the command */
     /* is it a cmd? */
-    if (fword && fword[0] && fword[1] && ((botmatch && fword[0] != cmdprefix[0]) || (fword[0] == cmdprefix[0]))) {
+    if (fword && fword[0] && fword[1] && ((botmatch && fword[0] != cmdprefix) || (fword[0] == cmdprefix))) {
       i = findauth(uhost);
       if (i > -1 && auth[i].authed) {
-        if (fword[0] == cmdprefix[0])
+        if (fword[0] == cmdprefix)
           fword++;
         my_u = auth[i].user;
         if (check_bind_pubc(fword, nick, uhost, my_u, my_msg, chan->dname)) {

+ 1 - 1
src/mod/irc.mod/irc.c

@@ -1273,7 +1273,7 @@ static int check_bind_pubc(char *cmd, char *nick, char *from, struct userrec *u,
   int x = check_bind(BT_msgc, cmd, &fr, nick, from, u, args, chan);
 
   if (x & BIND_RET_LOG)
-    putlog(LOG_CMDS, "*", "(%s!%s) !%s! %s %s%s %s", nick, from, u ? u->handle : "*", chan, cmdprefix, cmd, args);
+    putlog(LOG_CMDS, "*", "(%s!%s) !%s! %s %c%s %s", nick, from, u ? u->handle : "*", chan, cmdprefix, cmd, args);
   if (x & BIND_RET_BREAK) return(1);
   return(0);
 }

+ 9 - 9
src/mod/irc.mod/msgcmds.c

@@ -314,7 +314,7 @@ static int msg_pls_auth(char *nick, char *host, struct userrec *u, char *par)
     auth[i].authing = 0;
     auth[i].authtime = now;
     auth[i].atime = now;
-    dprintf(DP_HELP, "NOTICE %s :You are now authorized for cmds, see %shelp\n", nick, cmdprefix);
+    dprintf(DP_HELP, "NOTICE %s :You are now authorized for cmds, see %chelp\n", nick, cmdprefix);
   } else { /* bad hash! */
     putlog(LOG_CMDS, "*", "(%s!%s) !%s! failed +AUTH", nick, host, u->handle);
 #ifdef S_AUTHHASH
@@ -476,7 +476,7 @@ static int msgc_op(char *nick, char *host, struct userrec *u, char *par, char *c
       m = ismember(chan, nick);
   }
 
-  putlog(LOG_CMDS, "*", "(%s!%s) !%s! %s %sOP %s", nick, host, u->handle, chname ? chname : "", cmdprefix, par ? par : "");
+  putlog(LOG_CMDS, "*", "(%s!%s) !%s! %s %cOP %s", nick, host, u->handle, chname ? chname : "", cmdprefix, par ? par : "");
 
   if (par[0] == '-') { /* we have an option! */
     char *tmp = NULL;
@@ -526,7 +526,7 @@ static int msgc_voice(char *nick, char *host, struct userrec *u, char *par, char
       m = ismember(chan, nick);
   }
 
-  putlog(LOG_CMDS, "*", "(%s!%s) !%s! %s %sVOICE %s", nick, host, u->handle, chname ? chname : "", cmdprefix, par ? par : "");
+  putlog(LOG_CMDS, "*", "(%s!%s) !%s! %s %cVOICE %s", nick, host, u->handle, chname ? chname : "", cmdprefix, par ? par : "");
 
   if (par[0] == '-') { /* we have an option! */
     char *tmp = NULL;
@@ -567,7 +567,7 @@ static int msgc_channels(char *nick, char *host, struct userrec *u, char *par, c
   struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0};
   char list[1024] = "";
 
-  putlog(LOG_CMDS, "*", "(%s!%s) !%s! %s %sCHANNELS %s", nick, host, u->handle, chname ? chname : "", cmdprefix, par ? par : "");
+  putlog(LOG_CMDS, "*", "(%s!%s) !%s! %s %cCHANNELS %s", nick, host, u->handle, chname ? chname : "", cmdprefix, par ? par : "");
   for (chan = chanset; chan; chan = chan->next) {
     get_user_flagrec(u, &fr, chan->dname);
     if (chk_op(fr, chan)) {
@@ -597,7 +597,7 @@ static int msgc_getkey(char *nick, char *host, struct userrec *u, char *par, cha
   if (!par[0])
     return 0;
 
-  putlog(LOG_CMDS, "*", "(%s!%s) !%s! %sGETKEY %s", nick, host, u->handle, cmdprefix, par);
+  putlog(LOG_CMDS, "*", "(%s!%s) !%s! %cGETKEY %s", nick, host, u->handle, cmdprefix, par);
 
   chan = findchan_by_dname(par);
   if (chan && channel_active(chan) && !channel_pending(chan)) {
@@ -619,7 +619,7 @@ static int msgc_help(char *nick, char *host, struct userrec *u, char *par, char
   bind_table_t *table = NULL;
   struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0};
 
-  putlog(LOG_CMDS, "*", "(%s!%s) !%s! %sHELP %s", nick, host, u->handle, cmdprefix, par ? par : "");
+  putlog(LOG_CMDS, "*", "(%s!%s) !%s! %cHELP %s", nick, host, u->handle, cmdprefix, par ? par : "");
 
 
   get_user_flagrec(u, &fr, chname);
@@ -638,7 +638,7 @@ static int msgc_md5(char *nick, char *host, struct userrec *u, char *par, char *
 {
   struct chanset_t *chan = NULL;
 
-  putlog(LOG_CMDS, "*", "(%s!%s) !%s! %s %sMD5 %s", nick, host, u->handle, chname ? chname : "", cmdprefix, par ? par : "");
+  putlog(LOG_CMDS, "*", "(%s!%s) !%s! %s %cMD5 %s", nick, host, u->handle, chname ? chname : "", cmdprefix, par ? par : "");
   
   if (chname && chname[0])
     chan = findchan_by_dname(chname);  
@@ -651,7 +651,7 @@ static int msgc_sha1(char *nick, char *host, struct userrec *u, char *par, char
 {
   struct chanset_t *chan = NULL;
 
-  putlog(LOG_CMDS, "*", "(%s!%s) !%s! %s %sSHA1 %s", nick, host, u->handle, chname ? chname : "", cmdprefix, par ? par : "");
+  putlog(LOG_CMDS, "*", "(%s!%s) !%s! %s %cSHA1 %s", nick, host, u->handle, chname ? chname : "", cmdprefix, par ? par : "");
   
   if (chname && chname[0])
     chan = findchan_by_dname(chname);  
@@ -669,7 +669,7 @@ static int msgc_invite(char *nick, char *host, struct userrec *u, char *par, cha
   if (chname && chname[0])
     return 0;
  
-  putlog(LOG_CMDS, "*", "(%s!%s) !%s! %sINVITE %s", nick, host, u->handle, cmdprefix, par ? par : "");
+  putlog(LOG_CMDS, "*", "(%s!%s) !%s! %cINVITE %s", nick, host, u->handle, cmdprefix, par ? par : "");
 
   if (par[0] == '-') {
     char *tmp = NULL;

+ 4 - 4
src/mod/server.mod/servmsg.c

@@ -125,7 +125,7 @@ static int check_bind_msgc(char *cmd, char *nick, char *from, struct userrec *u,
   x = check_bind(BT_msgc, cmd, &fr, nick, from, u, args, NULL);
 
   if (x & BIND_RET_LOG)
-    putlog(LOG_CMDS, "*", "(%s!%s) !%s! %s%s %s", nick, from, u ? u->handle : "*", cmdprefix, cmd, args);
+    putlog(LOG_CMDS, "*", "(%s!%s) !%s! %c%s %s", nick, from, u ? u->handle : "*", cmdprefix, cmd, args);
 
   if (x & BIND_RET_BREAK) return(1);
   return(0);
@@ -496,15 +496,15 @@ static int gotmsg(char *from, char *msg)
       i = findauth(uhost);
       /* is it a cmd? */
 
-      if (i > -1 && auth[i].authed && my_code[0] == cmdprefix[0] && my_code[1]) {
+      if (my_code && my_code[0] && my_code[1] && i > -1 && auth[i].authed && my_code[0] == cmdprefix) {
         my_code++;
         my_u = auth[i].user;
 
         if (check_bind_msgc(my_code, nick, uhost, my_u, msg))
           auth[i].atime = now;
         else
-          putlog(LOG_MSGS, "*", "[%s] %c%s %s", from, cmdprefix[0], my_code, msg);
-      } else if ((my_code[0] != cmdprefix[0] || !my_code[1] || i == -1 || !(auth[i].authed))) {
+          putlog(LOG_MSGS, "*", "[%s] %c%s %s", from, cmdprefix, my_code, msg);
+      } else if ((my_code[0] != cmdprefix || !my_code[1] || i == -1 || !(auth[i].authed))) {
 #endif /* S_AUTHCMDS */
         if (!ignoring) {
           int doit = 1;