Explorar o código

* Converted some functions over

svn: 1803
Bryan Drewery %!s(int64=21) %!d(string=hai) anos
pai
achega
efc010fa11
Modificáronse 6 ficheiros con 51 adicións e 64 borrados
  1. 6 8
      src/botcmd.c
  2. 41 44
      src/botnet.c
  3. 0 2
      src/botnet.h
  4. 2 5
      src/dcc.c
  5. 0 2
      src/dcc.h
  6. 2 3
      src/main.c

+ 6 - 8
src/botcmd.c

@@ -657,11 +657,10 @@ static void bot_nlinked(int idx, char *par)
   botnet_send_nlinked(idx, newbot, next, x, vlocalhub, vbuildts, vversion);
   botnet_send_nlinked(idx, newbot, next, x, vlocalhub, vbuildts, vversion);
   
   
   if (x == '!') {
   if (x == '!') {
-#ifdef HUB
-    chatout("*** (%s) %s %s.\n", next, NET_LINKEDTO, newbot);
-#else
-    chatout("*** %s linked to botnet.\n", newbot);
-#endif
+    if (conf.bot->hub)
+      chatout("*** (%s) %s %s.\n", next, NET_LINKEDTO, newbot);
+    else
+      chatout("*** %s linked to botnet.\n", newbot);
     x = '-';
     x = '-';
   }
   }
   addbot(newbot, dcc[idx].nick, next, x, vlocalhub, vbuildts, vversion ? vversion : (char *) "");
   addbot(newbot, dcc[idx].nick, next, x, vlocalhub, vbuildts, vversion ? vversion : (char *) "");
@@ -769,9 +768,8 @@ static void bot_timesync(int idx, char *par)
 //  putlog(LOG_DEBUG, "@", "Got timesync from %s: %s (%li - %li)", dcc[idx].nick, par, atol(par), now);
 //  putlog(LOG_DEBUG, "@", "Got timesync from %s: %s (%li - %li)", dcc[idx].nick, par, atol(par), now);
   timesync = atol(par) - now;
   timesync = atol(par) - now;
 
 
-#ifdef HUB
-  send_timesync(-1);
-#endif /* HUB */
+  if (conf.bot->hub)
+    send_timesync(-1);
 }
 }
 
 
 /* reject <from> <bot>
 /* reject <from> <bot>

+ 41 - 44
src/botnet.c

@@ -432,19 +432,17 @@ void answer_local_whom(int idx, int chan)
   if(nicklen < 9) nicklen = 9;
   if(nicklen < 9) nicklen = 9;
   if(botnicklen < 9) botnicklen = 9;
   if(botnicklen < 9) botnicklen = 9;
 
 
-#ifdef HUB
-  egg_snprintf(format, sizeof format, "%%-%us   %%-%us  %%s\n", 
-                                  nicklen, botnicklen);
-  dprintf(idx, format, " Nick", 	" Bot",      " Host");
-  dprintf(idx, format, "----------",	"---------", "--------------------");
-  egg_snprintf(format, sizeof format, "%%c%%-%us %%c %%-%us  %%s%%s\n", 
-                                  nicklen, botnicklen);
-#else /* !HUB */
-  egg_snprintf(format, sizeof format, "%%-%us\n", nicklen);
-  dprintf(idx, format, " Nick");
-  dprintf(idx, format, "----------");
-  egg_snprintf(format, sizeof format, "%%c%%-%us %%c %%s\n", nicklen);
-#endif /* HUB */
+  if (conf.bot->hub) {
+    egg_snprintf(format, sizeof format, "%%-%us   %%-%us  %%s\n", nicklen, botnicklen);
+    dprintf(idx, format, " Nick", 	" Bot",      " Host");
+    dprintf(idx, format, "----------",	"---------", "--------------------");
+    egg_snprintf(format, sizeof format, "%%c%%-%us %%c %%-%us  %%s%%s\n", nicklen, botnicklen);
+  } else {
+    egg_snprintf(format, sizeof format, "%%-%us\n", nicklen);
+    dprintf(idx, format, " Nick");
+    dprintf(idx, format, "----------");
+    egg_snprintf(format, sizeof format, "%%c%%-%us %%c %%s\n", nicklen);
+  }
   for (i = 0; i < dcc_total; i++) {
   for (i = 0; i < dcc_total; i++) {
     if (dcc[i].type && dcc[i].type == &DCC_CHAT) {
     if (dcc[i].type && dcc[i].type == &DCC_CHAT) {
       if ((chan == (-1)) || ((chan >= 0) && (dcc[i].u.chat->channel == chan))) {
       if ((chan == (-1)) || ((chan >= 0) && (dcc[i].u.chat->channel == chan))) {
@@ -467,14 +465,17 @@ void answer_local_whom(int idx, int chan)
 	  idle[0] = 0;
 	  idle[0] = 0;
 
 
         total++;
         total++;
-	dprintf(idx, format, c, dcc[i].nick, 
-		(dcc[i].u.chat->channel == 0) && (chan == (-1)) ? '+' :
-		(dcc[i].u.chat->channel > GLOBAL_CHANS) &&
-#ifdef HUB
-		(chan == (-1)) ? '*' : ' ', conf.bot->nick, dcc[i].host, idle);
-#else /* !HUB */
-		(chan == (-1)) ? '*' : ' ', idle);
-#endif /* HUB */
+        if (conf.bot->hub)
+  	  dprintf(idx, format, c, dcc[i].nick, 
+		 (dcc[i].u.chat->channel == 0) && (chan == (-1)) ? '+' :
+		 (dcc[i].u.chat->channel > GLOBAL_CHANS) &&
+		 (chan == (-1)) ? '*' : ' ', conf.bot->nick, dcc[i].host, idle);
+        else
+          dprintf(idx, format, c, dcc[i].nick, 
+	         (dcc[i].u.chat->channel == 0) && (chan == (-1)) ? '+' :
+		 (dcc[i].u.chat->channel > GLOBAL_CHANS) &&
+		 (chan == (-1)) ? '*' : ' ', idle);
+
 	if (dcc[i].u.chat->away != NULL)
 	if (dcc[i].u.chat->away != NULL)
 	  dprintf(idx, "   AWAY: %s\n", dcc[i].u.chat->away);
 	  dprintf(idx, "   AWAY: %s\n", dcc[i].u.chat->away);
       }
       }
@@ -503,13 +504,11 @@ void answer_local_whom(int idx, int chan)
 	idle[0] = 0;
 	idle[0] = 0;
       total++;
       total++;
 
 
-      dprintf(idx, format, c, party[i].nick, 
-	      (party[i].chan == 0) && (chan == (-1)) ? '+' : ' ',
-#ifdef HUB
-	      party[i].bot, party[i].from, idle);
-#else /* !HUB */
-	      idle);
-#endif /* HUB */
+      if (conf.bot->hub) 
+        dprintf(idx, format, c, party[i].nick, (party[i].chan == 0) && (chan == (-1)) ? '+' : ' ', 
+                                party[i].bot, party[i].from, idle);
+      else
+        dprintf(idx, format, c, party[i].nick, (party[i].chan == 0) && (chan == (-1)) ? '+' : ' ', idle);
 
 
       if (party[i].status & PLSTAT_AWAY)
       if (party[i].status & PLSTAT_AWAY)
 	dprintf(idx, "   %s: %s\n", MISC_AWAY,
 	dprintf(idx, "   %s: %s\n", MISC_AWAY,
@@ -519,7 +518,6 @@ void answer_local_whom(int idx, int chan)
   dprintf(idx, "Total users: %d\n", total);
   dprintf(idx, "Total users: %d\n", total);
 }
 }
 
 
-#ifdef HUB
 /* Show z a list of all bots connected
 /* Show z a list of all bots connected
  */
  */
 void
 void
@@ -754,7 +752,6 @@ void tell_bottree(int idx)
   /* Hop information: (9d) */
   /* Hop information: (9d) */
   dprintf(idx, "Average hops: %3.1f, total bots: %d\n", ((float) tothops) / ((float) tands), tands + 1);
   dprintf(idx, "Average hops: %3.1f, total bots: %d\n", ((float) tothops) / ((float) tands), tands + 1);
 }
 }
-#endif /* HUB */
 
 
 /* Dump list of links to a new bot
 /* Dump list of links to a new bot
  */
  */
@@ -763,21 +760,22 @@ void dump_links(int z)
   register int i;
   register int i;
   register size_t l;
   register size_t l;
   char x[1024] = "";
   char x[1024] = "";
-#ifdef HUB
-  tand_t *bot = NULL;
-  char *p = NULL;
 
 
-  for (bot = tandbot; bot; bot = bot->next) {
-    if (bot->uplink == (tand_t *) 1)
-      p = conf.bot->nick;
-    else
-      p = bot->uplink->bot;
+  if (conf.bot->hub) {
+    tand_t *bot = NULL;
+    char *p = NULL;
 
 
-    l = simple_sprintf(x, "n %s %s %cD0gc %d %d %s\n", bot->bot, p, bot->share, bot->localhub, 
+    for (bot = tandbot; bot; bot = bot->next) {
+      if (bot->uplink == (tand_t *) 1)
+        p = conf.bot->nick;
+      else
+        p = bot->uplink->bot;
+
+      l = simple_sprintf(x, "n %s %s %cD0gc %d %d %s\n", bot->bot, p, bot->share, bot->localhub, 
                                                         bot->buildts, bot->version ? bot->version : "");
                                                         bot->buildts, bot->version ? bot->version : "");
-    tputs(dcc[z].sock, x, l);
+      tputs(dcc[z].sock, x, l);
+    }
   }
   }
-#endif /* HUB */
 
 
   /* Dump party line members */
   /* Dump party line members */
   for (i = 0; i < dcc_total; i++) {
   for (i = 0; i < dcc_total; i++) {
@@ -1159,9 +1157,8 @@ void tandem_relay(int idx, char *nick, register int i)
   strcpy(dcc[i].nick, nick);
   strcpy(dcc[i].nick, nick);
   dcc[i].user = u;
   dcc[i].user = u;
   strcpy(dcc[i].host, bi->address);
   strcpy(dcc[i].host, bi->address);
-#ifdef HUB
-  dprintf(idx, "%s %s @ %s:%d ...\n", BOT_CONNECTINGTO, nick, bi->address, bi->relay_port);
-#endif /* HUB */
+  if (conf.bot->hub) 
+    dprintf(idx, "%s %s @ %s:%d ...\n", BOT_CONNECTINGTO, nick, bi->address, bi->relay_port);
   dprintf(idx, "%s\n", BOT_BYEINFO1);
   dprintf(idx, "%s\n", BOT_BYEINFO1);
   dcc[idx].type = &DCC_PRE_RELAY;
   dcc[idx].type = &DCC_PRE_RELAY;
 
 

+ 0 - 2
src/botnet.h

@@ -16,10 +16,8 @@ void answer_local_whom(int, int);
 char *lastbot(char *);
 char *lastbot(char *);
 int nextbot(char *);
 int nextbot(char *);
 int in_chain(char *);
 int in_chain(char *);
-#ifdef HUB
 void tell_bots(int, int, const char *);
 void tell_bots(int, int, const char *);
 void tell_bottree(int);
 void tell_bottree(int);
-#endif /* HUB */
 void dump_links(int);
 void dump_links(int);
 int botlink(char *, int, char *);
 int botlink(char *, int, char *);
 int botunlink(int, char *, char *);
 int botunlink(int, char *, char *);

+ 2 - 5
src/dcc.c

@@ -117,7 +117,6 @@ strip_telnet(int sock, char *buf, int *len)
   *o = *p;
   *o = *p;
 }
 }
 
 
-#ifdef HUB
 void
 void
 send_timesync(int idx)
 send_timesync(int idx)
 {
 {
@@ -135,7 +134,6 @@ send_timesync(int idx)
     }
     }
   }
   }
 }
 }
-#endif /* HUB */
 
 
 static void
 static void
 greet_new_bot(int idx)
 greet_new_bot(int idx)
@@ -900,9 +898,8 @@ dcc_chat_pass(int idx, char *buf, int atr)
       dcc[idx].status = STAT_CALLED;
       dcc[idx].status = STAT_CALLED;
       dprintf(idx, "goodbye!\n");
       dprintf(idx, "goodbye!\n");
       greet_new_bot(idx);
       greet_new_bot(idx);
-#ifdef HUB
-      send_timesync(idx);
-#endif /* HUB */
+      if (conf.bot->hub)
+        send_timesync(idx);
     } else if (!egg_strcasecmp(pass, "neg")) {
     } else if (!egg_strcasecmp(pass, "neg")) {
       int snum = findanysnum(dcc[idx].sock);
       int snum = findanysnum(dcc[idx].sock);
 
 

+ 0 - 2
src/dcc.h

@@ -224,9 +224,7 @@ extern struct dcc_table DCC_CHAT, DCC_BOT, DCC_BOT_NEW,
  DCC_FORK_BOT, DCC_SOCKET, DCC_TELNET_ID, DCC_TELNET_NEW, DCC_TELNET_PW,
  DCC_FORK_BOT, DCC_SOCKET, DCC_TELNET_ID, DCC_TELNET_NEW, DCC_TELNET_PW,
  DCC_TELNET, DCC_IDENT, DCC_IDENTWAIT, DCC_IDENTD, DCC_IDENTD_CONNECT, DCC_DNSWAIT;
  DCC_TELNET, DCC_IDENT, DCC_IDENTWAIT, DCC_IDENTD, DCC_IDENTD_CONNECT, DCC_DNSWAIT;
 
 
-#ifdef HUB
 void send_timesync(int);
 void send_timesync(int);
-#endif /* HUB */
 void failed_link(int);
 void failed_link(int);
 void dupwait_notify(const char *);
 void dupwait_notify(const char *);
 
 

+ 2 - 3
src/main.c

@@ -526,9 +526,8 @@ static void check_autoaway()
 
 
 static void core_minutely()
 static void core_minutely()
 {
 {
-#ifdef HUB
-  send_timesync(-1);
-#endif /* HUB */
+  if (conf.bot->hub) 
+    send_timesync(-1);
 #ifdef LEAF
 #ifdef LEAF
   check_maxfiles();
   check_maxfiles();
   check_mypid();
   check_mypid();