Преглед изворни кода

* Removed 'link' 'disc' binds
* Cleaned up some linking functions
* Fucked up tell_bots() :D


svn: 1019

Bryan Drewery пре 22 година
родитељ
комит
e2771967be
7 измењених фајлова са 29 додато и 42 уклоњено
  1. 0 1
      src/botcmd.c
  2. 25 22
      src/botnet.c
  3. 1 1
      src/botnet.h
  4. 1 13
      src/core_binds.c
  5. 0 2
      src/core_binds.h
  6. 1 2
      src/dcc.c
  7. 1 1
      src/dcc.h

+ 0 - 1
src/botcmd.c

@@ -752,7 +752,6 @@ static void bot_nlinked(int idx, char *par)
     x = '-';
     x = '-';
   }
   }
   addbot(newbot, dcc[idx].nick, next, x, vlocalhub, vbuildts, vversion ? vversion : "");
   addbot(newbot, dcc[idx].nick, next, x, vlocalhub, vbuildts, vversion ? vversion : "");
-  check_bind_link(newbot, next);
 }
 }
 
 
 static void bot_unlinked(int idx, char *par)
 static void bot_unlinked(int idx, char *par)

+ 25 - 22
src/botnet.c

@@ -288,7 +288,7 @@ void partyaway(char *bot, int sock, char *msg)
 
 
 /* Remove a tandem bot from the chain list
 /* Remove a tandem bot from the chain list
  */
  */
-void rembot(char *who)
+void rembot(const char *who)
 {
 {
   tand_t **ptr = &tandbot, *ptr2 = NULL;
   tand_t **ptr = &tandbot, *ptr2 = NULL;
   struct userrec *u = NULL;
   struct userrec *u = NULL;
@@ -301,9 +301,8 @@ void rembot(char *who)
   if (!*ptr)
   if (!*ptr)
     /* May have just .unlink *'d */
     /* May have just .unlink *'d */
     return;
     return;
-  check_bind_disc(who);
 
 
-  u = get_user_by_handle(userlist, who);
+  u = get_user_by_handle(userlist, (char *) who);
   if (u != NULL)
   if (u != NULL)
     touch_laston(u, "unlinked", now);
     touch_laston(u, "unlinked", now);
 
 
@@ -358,7 +357,7 @@ void rempartybot(char *bot)
 
 
 /* Remove every bot linked 'via' bot <x>
 /* Remove every bot linked 'via' bot <x>
  */
  */
-void unvia(int idx, tand_t * who)
+void unvia(int idx, tand_t *who)
 {
 {
   tand_t *bot = NULL, *bot2 = NULL;
   tand_t *bot = NULL, *bot2 = NULL;
 
 
@@ -555,37 +554,40 @@ void answer_local_whom(int idx, int chan)
  */
  */
 void tell_bots(int idx)
 void tell_bots(int idx)
 {
 {
-  char *up = NULL, *down = NULL;
+  char format[81] = "";
   int upi = 1, downi = 0;
   int upi = 1, downi = 0;
-  size_t ulen = 0, dlen = 0;
+  size_t len;
   struct userrec *u = NULL;
   struct userrec *u = NULL;
 
 
-  ulen = strlen(conf.bot->nick);
-  up = calloc(1, ulen + 1);
-  strcpy(up, conf.bot->nick);
-  down = calloc(1, 1);
+  len = strlen(conf.bot->nick);
+  //up = calloc(1, ulen + 1);
+  //strcpy(up, conf.bot->nick);
+  //down = calloc(1, 1);
 
 
+  egg_snprintf(format, sizeof format, "%%s%%-11s%%s %%-5s %%-10s %%-11s %%s\n");
+  dprintf(idx, format, "", "Bot", "", "OS", "Username", "Shell");
+  dprintf(idx, format, "", "-----------", "", "----------", "-----------", "-----------------------");
+  
+/* FIXME: NEED ME! */
   for (u = userlist; u; u = u->next) {
   for (u = userlist; u; u = u->next) {
     if ((u->flags & USER_BOT) && (egg_strcasecmp(u->handle, conf.bot->nick))) {
     if ((u->flags & USER_BOT) && (egg_strcasecmp(u->handle, conf.bot->nick))) {
       size_t hlen = strlen(u->handle);
       size_t hlen = strlen(u->handle);
+      int up = 0;
 
 
       if (findbot(u->handle)) {
       if (findbot(u->handle)) {
         upi++;
         upi++;
-        up = realloc(up, ulen + hlen + /*', '*/ + 2 + 1);
-        strcat(up, ", ");
-        strcat(up, u->handle);
-        ulen += hlen + 3;
-      } else {
-        down = realloc(down, dlen + hlen + /*', '*/ + 2 + 1);
-        if (downi)
-          strcat(down, ", ");
+        up = 1;
+      } else
         downi++;
         downi++;
-        strcat(down, u->handle);
-        dlen += hlen + 3;
-      }
+
+      dprintf(idx, format, up ? GREEN(idx) : RED(idx), u->handle, COLOR_END(idx), 
+              get_user(&USERENTRY_OS, u), get_user(&USERENTRY_USERNAME, u), 
+              get_user(&USERENTRY_NODENAME, u));
+
+//      if (up) {
     }
     }
   }
   }
-
+/*
   if (!downi)
   if (!downi)
     dprintf(idx, "Bots up (%d) [%sall%s]: %s\n", upi, BOLD(idx), BOLD_END(idx), up);
     dprintf(idx, "Bots up (%d) [%sall%s]: %s\n", upi, BOLD(idx), BOLD_END(idx), up);
   else
   else
@@ -598,6 +600,7 @@ void tell_bots(int idx)
                COLOR_END(idx), RED(idx), (100 * downi / (upi + downi)), COLOR_END(idx));
                COLOR_END(idx), RED(idx), (100 * downi / (upi + downi)), COLOR_END(idx));
   free(up);
   free(up);
   free(down);
   free(down);
+*/
 }
 }
 
 
 /* Show a simpleton bot tree
 /* Show a simpleton bot tree

+ 1 - 1
src/botnet.h

@@ -26,7 +26,7 @@ int botlink(char *, int, char *);
 int botunlink(int, char *, char *);
 int botunlink(int, char *, char *);
 void addbot(char *, char *, char *, char, int, time_t, char *);
 void addbot(char *, char *, char *, char, int, time_t, char *);
 void updatebot(int, char *, char, int, time_t, char *);
 void updatebot(int, char *, char, int, time_t, char *);
-void rembot(char *);
+void rembot(const char *);
 struct tand_t_struct *findbot(char *);
 struct tand_t_struct *findbot(char *);
 void unvia(int, struct tand_t_struct *);
 void unvia(int, struct tand_t_struct *);
 void check_botnet_pings();
 void check_botnet_pings();

+ 1 - 13
src/core_binds.c

@@ -19,7 +19,7 @@
 
 
 extern cmd_t 		C_dcc[];
 extern cmd_t 		C_dcc[];
 
 
-static bind_table_t *BT_link = NULL, *BT_disc = NULL, *BT_away = NULL, *BT_dcc = NULL;
+static bind_table_t *BT_away = NULL, *BT_dcc = NULL;
 static bind_table_t *BT_chat = NULL, *BT_act = NULL, *BT_bcst = NULL, *BT_note = NULL;
 static bind_table_t *BT_chat = NULL, *BT_act = NULL, *BT_bcst = NULL, *BT_note = NULL;
 static bind_table_t *BT_bot = NULL, *BT_nkch = NULL, *BT_chon = NULL, *BT_chof = NULL;
 static bind_table_t *BT_bot = NULL, *BT_nkch = NULL, *BT_chon = NULL, *BT_chof = NULL;
 static bind_table_t *BT_chpt = NULL, *BT_chjn = NULL, *BT_time = NULL;
 static bind_table_t *BT_chpt = NULL, *BT_chjn = NULL, *BT_time = NULL;
@@ -37,8 +37,6 @@ void core_binds_init()
         BT_chpt = bind_table_add("chpt", 4, "ssii", MATCH_MASK, BIND_STACKABLE);
         BT_chpt = bind_table_add("chpt", 4, "ssii", MATCH_MASK, BIND_STACKABLE);
         BT_dcc = bind_table_add("dcc", 3, "Uis", MATCH_PARTIAL | MATCH_FLAGS, 0);
         BT_dcc = bind_table_add("dcc", 3, "Uis", MATCH_PARTIAL | MATCH_FLAGS, 0);
         add_builtins("dcc", C_dcc);
         add_builtins("dcc", C_dcc);
-        BT_disc = bind_table_add("disc", 1, "s", MATCH_MASK, BIND_STACKABLE);
-        BT_link = bind_table_add("link", 2, "ss", MATCH_MASK, BIND_STACKABLE);
         BT_nkch = bind_table_add("nkch", 2, "ss", MATCH_MASK, BIND_STACKABLE);
         BT_nkch = bind_table_add("nkch", 2, "ss", MATCH_MASK, BIND_STACKABLE);
         BT_note = bind_table_add("note", 3 , "sss", MATCH_EXACT, 0);
         BT_note = bind_table_add("note", 3 , "sss", MATCH_EXACT, 0);
 	BT_time = bind_table_add("time", 5, "iiiii", MATCH_MASK, BIND_STACKABLE);
 	BT_time = bind_table_add("time", 5, "iiiii", MATCH_MASK, BIND_STACKABLE);
@@ -156,16 +154,6 @@ void check_bind_nkch(const char *ohand, const char *nhand)
   check_bind(BT_nkch, ohand, NULL, ohand, nhand);
   check_bind(BT_nkch, ohand, NULL, ohand, nhand);
 }
 }
 
 
-void check_bind_link(const char *bot, const char *via)
-{
-  check_bind(BT_link, bot, NULL, bot, via);
-}
-
-void check_bind_disc(const char *bot)
-{
-  check_bind(BT_disc, bot, NULL, bot);
-}
-
 int check_bind_note(const char *from, const char *to, const char *text)
 int check_bind_note(const char *from, const char *to, const char *text)
 {
 {
   return check_bind(BT_note, to, NULL, from, to, text);
   return check_bind(BT_note, to, NULL, from, to, text);

+ 0 - 2
src/core_binds.h

@@ -7,8 +7,6 @@ void check_bind_dcc(const char *, int, const char *);
 void check_bind_chjn(const char *, const char *, int, char, int, const char *);
 void check_bind_chjn(const char *, const char *, int, char, int, const char *);
 void check_bind_chpt(const char *, const char *, int, int);
 void check_bind_chpt(const char *, const char *, int, int);
 void check_bind_bot(const char *, const char *, const char *);
 void check_bind_bot(const char *, const char *, const char *);
-void check_bind_link(const char *, const char *);
-void check_bind_disc(const char *);
 int check_bind_note(const char *, const char *, const char *);
 int check_bind_note(const char *, const char *, const char *);
 void check_bind_nkch(const char *, const char *);
 void check_bind_nkch(const char *, const char *);
 void check_bind_away(const char *, int, const char *);
 void check_bind_away(const char *, int, const char *);

+ 1 - 2
src/dcc.c

@@ -315,7 +315,6 @@ static void bot_version(int idx, char *par)
   touch_laston(dcc[idx].user, "linked", now);
   touch_laston(dcc[idx].user, "linked", now);
   dcc[idx].type = &DCC_BOT;
   dcc[idx].type = &DCC_BOT;
   addbot(dcc[idx].nick, dcc[idx].nick, conf.bot->nick, '-', vlocalhub, vbuildts, vversion);
   addbot(dcc[idx].nick, dcc[idx].nick, conf.bot->nick, '-', vlocalhub, vbuildts, vversion);
-  check_bind_link(dcc[idx].nick, conf.bot->nick);
   egg_snprintf(x, sizeof x, "v 1001500");
   egg_snprintf(x, sizeof x, "v 1001500");
   bot_shareupdate(idx, x);
   bot_shareupdate(idx, x);
   bot_share(idx, x);
   bot_share(idx, x);
@@ -1481,7 +1480,7 @@ struct dcc_table DCC_DUPWAIT =
  * wether we have a pending duplicate connection for that bot and continues
  * wether we have a pending duplicate connection for that bot and continues
  * with the login in that case.
  * with the login in that case.
  */
  */
-void dupwait_notify(char *who)
+void dupwait_notify(const char *who)
 {
 {
   register int idx;
   register int idx;
 
 

+ 1 - 1
src/dcc.h

@@ -221,7 +221,7 @@ extern struct dcc_table DCC_CHAT, DCC_BOT, DCC_LOST, DCC_BOT_NEW,
 
 
 void send_timesync(int);
 void send_timesync(int);
 void failed_link(int);
 void failed_link(int);
-void dupwait_notify(char *);
+void dupwait_notify(const char *);
 char *rand_dccresp();
 char *rand_dccresp();
 
 
 #endif /* !_DCC_H */
 #endif /* !_DCC_H */