Bladeren bron

* Added a FIXME and possible code for an ANSI Bug fix (dccutil.c)
* Fixed updatebin() so a hub doesn't lose control over it's port.


svn: 448

Bryan Drewery 22 jaren geleden
bovenliggende
commit
469b49f066
2 gewijzigde bestanden met toevoegingen van 34 en 36 verwijderingen
  1. 12 4
      src/dccutil.c
  2. 22 32
      src/misc.c

+ 12 - 4
src/dccutil.c

@@ -168,14 +168,22 @@ void dprintf EGG_VARARGS_DEF(int, arg1)
         a = 1;
       buf3[0] = '\0';
       for (i = 0 ; i < len ; i++) {
+/* FIXME: Trying to fix bug where you do .color on ANSI, then .bc <bot> help help OVER TELNET
+        if (buf[i] == '\033') {
+          unsigned char *e;
+          for (e = buf + 2; *e != 'm' && *e; e++)
+            i++;
+          if (i >= len) break;
+        }
+*/
         c = buf[i];
         buf2[0] = '\0';
 
         if (c == ':') {
-        if (a)
-          sprintf(buf2, "\e[%d;%dm%c\e[0m", 0, 37, c);
-        else
-          sprintf(buf2, "\003%d%c\003\002\002", 15, c);
+          if (a)
+            sprintf(buf2, "\e[%d;%dm%c\e[0m", 0, 37, c);
+          else
+            sprintf(buf2, "\003%d%c\003\002\002", 15, c);
         } else if (c == '@') {
           if (a)
             sprintf(buf2, "\e[1m%c\e[0m", c);

+ 22 - 32
src/misc.c

@@ -1419,43 +1419,33 @@ int updatebin (int idx, char *par, int autoi)
   usleep(5000);
 #endif /* HUB */
   putlog(LOG_DEBUG, "*", "Running for update: %s", buf);
-  i = system(buf);
-  if (i == -1 || WEXITSTATUS(i)) {
-    if (idx)
-      dprintf(idx, STR("Couldn't restart new binary (error %d)\n"), i);
-    putlog(LOG_MISC, "*", STR("Couldn't restart new binary (error %d)\n"), i);
-    return i;
-
-  } else {
 #ifdef LEAF
-    if (!autoi && localhub) {
-      /* let's drop the server connection ASAP */
-      if ((me = module_find("server", 0, 0))) {
-        Function *func = me->funcs;
-        (func[SERVER_NUKESERVER]) ("Updating...");
-      }
+  if (!autoi && localhub) {
+    /* let's drop the server connection ASAP */
+    if ((me = module_find("server", 0, 0))) {
+      Function *func = me->funcs;
+      (func[SERVER_NUKESERVER]) ("Updating...");
+    }
 #endif /* LEAF */
-      if (idx)
-        dprintf(idx, STR("Updating...bye\n"));
-      putlog(LOG_MISC, "*", STR("Updating...\n"));
-      botnet_send_chat(-1, botnetnick, "Updating...");
-      botnet_send_bye();
-      fatal("Updating...", 1);
-      usleep(2000 * 500);
-      bg_send_quit(BG_ABORT);
-
-      exit(0);
-      //No need to return :)
+    if (idx)
+      dprintf(idx, STR("Updating...bye\n"));
+    putlog(LOG_MISC, "*", STR("Updating...\n"));
+    botnet_send_chat(-1, botnetnick, "Updating...");
+    botnet_send_bye();
+    fatal("Updating...", 1);
+    usleep(2000 * 500);
+    bg_send_quit(BG_ABORT);
+    system(buf);		/* run the binary, it SHOULD work from earlier tests.. */
+    exit(0);
 #ifdef LEAF
-    } else {
-      if (localhub && autoi) {
-        add_hook(HOOK_SECONDLY, (Function) updatelocal);
-        return 0;
-      }
+  } else {
+    if (localhub && autoi) {
+      add_hook(HOOK_SECONDLY, (Function) updatelocal);
+      return 0;
     }
-#endif /* LEAF */
   }
-  /* this should never be reached */
+#endif /* LEAF */
+ /* this should never be reached */
   return 2;
 }