Explorar o código

* dcc[].simul is an idx, so it needs to be -1 to be disabled.
* lostdcc() no longer bzero()s the memory, this is only done in new_dcc() now.
* new_dcc() also sets dcc[].simul/sock to -1


svn: 2037

Bryan Drewery %!s(int64=21) %!d(string=hai) anos
pai
achega
fde17b5022
Modificáronse 6 ficheiros con 13 adicións e 9 borrados
  1. 1 1
      src/auth.c
  2. 1 1
      src/botnet.c
  3. 3 3
      src/cmds.c
  4. 6 2
      src/dccutil.c
  5. 1 1
      src/log.c
  6. 1 1
      src/main.c

+ 1 - 1
src/auth.c

@@ -223,7 +223,7 @@ bool Auth::GetIdx(const char *chname)
     dcc[idx].timeval = now;
     dcc[idx].irc = 1;
     dcc[idx].simultime = now;
-    dcc[idx].simul = 1;
+    dcc[idx].simul = 0;		/* not -1, so it's cleaned up later */
     dcc[idx].status = STAT_COLOR;
     dcc[idx].u.chat->con_flags = 0;
     strlcpy(dcc[idx].simulbot, chname ? chname : nick, NICKLEN);

+ 1 - 1
src/botnet.c

@@ -776,7 +776,7 @@ void dump_links(int z)
 
   /* Dump party line members */
   for (i = 0; i < dcc_total; i++) {
-    if (dcc[i].type && dcc[i].type == &DCC_CHAT && !dcc[i].simul) {
+    if (dcc[i].type && dcc[i].type == &DCC_CHAT && dcc[i].simul == -1) {
       if ((dcc[i].u.chat->channel >= 0) && (dcc[i].u.chat->channel < GLOBAL_CHANS)) {
         l = simple_sprintf2(x, "j !%s %s %D %c%D %s\n", conf.bot->nick, dcc[i].nick, 
                                dcc[i].u.chat->channel, geticon(i), dcc[i].sock, dcc[i].host);

+ 3 - 3
src/cmds.c

@@ -2083,7 +2083,7 @@ static void cmd_unlink(int idx, char *par)
 
 static void cmd_relay(int idx, char *par)
 {
-  if (dcc[idx].simul) {
+  if (dcc[idx].simul >= 0) {
     dprintf(idx, "Sorry, this cmd is not available with remote cmds.\n");
     return;
   }
@@ -2167,7 +2167,7 @@ int check_dcc_attrs(struct userrec *u, flag_t oatr)
   int stat;
 
   for (int i = 0; i < dcc_total; i++) {
-   if (dcc[i].type && !dcc[i].simul) {
+   if (dcc[i].type && dcc[i].simul == -1) {
     if (dcc[i].type == &DCC_CHAT && !conf.bot->hub && !ischanhub() && u == conf.bot->u) {
       dprintf(i, "I am no longer a chathub..\n");
       do_boot(i, conf.bot->nick, "I am no longer a chathub.");
@@ -2984,7 +2984,7 @@ static void cmd_strip(int idx, char *par)
 
 static void cmd_su(int idx, char *par)
 {
-  if (dcc[idx].simul) {
+  if (dcc[idx].simul >= 0) {
     dprintf(idx, "Sorry, this cmd is not available with remote cmds.\n");
     return;
   }

+ 6 - 2
src/dccutil.c

@@ -282,7 +282,7 @@ dprintf(int idx, const char *format, ...)
       strcat(buf, "\n");
       len = 1001;
     }
-    if (dcc[idx].simul > 0 && !dcc[idx].irc) {
+    if (dcc[idx].simul >= 0 && !dcc[idx].irc) {
       bounce_simul(idx, buf);
     } else if (dcc[idx].irc) {
 //      size_t size = strlen(dcc[idx].simulbot) + strlen(buf) + 20;
@@ -446,7 +446,9 @@ lostdcc(int n)
   else if (dcc[n].u.other)
     free(dcc[n].u.other);
 
-  egg_bzero(&dcc[n], sizeof(struct dcc_t));
+//  This is also done when we new_dcc(), so don't bother for now, we set sock/type to NULL, so it won't even be 
+//  parsed by anything.
+//  egg_bzero(&dcc[n], sizeof(struct dcc_t));
 
   dcc[n].sock = -1;
   dcc[n].type = NULL;
@@ -609,6 +611,8 @@ new_dcc(struct dcc_table *type, int xtra_size)
   dcc[i].type = type;
   if (xtra_size)
     dcc[i].u.other = (char *) my_calloc(1, xtra_size);
+  dcc[i].simul = -1;
+  dcc[i].sock = -1;
 
   sdprintf("new_dcc (%s): %d (dccn/dcc_total: %d/%d)", type->name, i, dccn, dcc_total);
   return i;

+ 1 - 1
src/log.c

@@ -177,7 +177,7 @@ void putlog(int type, const char *chname, const char *format, ...)
     botnet_send_log(-1, conf.bot->nick, type, out);
 
   for (idx = 0; idx < dcc_total; idx++) {
-    if (dcc[idx].type && (dcc[idx].type == &DCC_CHAT && !dcc[idx].simul) && (dcc[idx].u.chat->con_flags & type)) {
+    if (dcc[idx].type && (dcc[idx].type == &DCC_CHAT && dcc[idx].simul == -1) && (dcc[idx].u.chat->con_flags & type)) {
       if ((chname[0] == '@') || (chname[0] == '*') || (dcc[idx].u.chat->con_chan[0] == '*') ||
           (!rfc_casecmp(chname, dcc[idx].u.chat->con_chan)))
         dprintf(idx, "%s\n", out);

+ 1 - 1
src/main.c

@@ -193,7 +193,7 @@ static void check_expired_dcc()
 /* this also expires irc dcc_cmd auths */
 static void expire_simuls() {
   for (int idx = 0; idx < dcc_total; idx++) {
-    if (dcc[idx].type && dcc[idx].simul > -1) {
+    if (dcc[idx].type && dcc[idx].simul >= 0) {
       if ((now - dcc[idx].simultime) >= 100) { /* expire simuls after 100 seconds (re-uses idx, so it wont fill up) */
         dcc[idx].simul = -1;
 // FIXME: THIS NEEDS TO BE UPDATED FOR CLASS