Explorar el Código

* Moved CFG_ servers/servers6/realname/nick to cfg.c

svn: 1028
Bryan Drewery hace 22 años
padre
commit
9475a13119
Se han modificado 6 ficheros con 104 adiciones y 147 borrados
  1. 1 0
      doc/UPDATES
  2. 89 27
      src/cfg.c
  3. 7 4
      src/main.c
  4. 3 115
      src/mod/server.mod/server.c
  5. 3 0
      src/mod/server.mod/server.h
  6. 1 1
      src/net.c

+ 1 - 0
doc/UPDATES

@@ -18,6 +18,7 @@ This is a summary of ChangeLog basically.
 14.Now only perm owners may change cfg settings: authkey, cmdprefix, hijack, bad-cookie, manop
 15.Hubs weren't saving userflie on remote -chan.
 16.Bot specific channels (cmd_botjoin/cmd_botpart)
+17.Added CFG: servport.
 
 1.1.7
 

+ 89 - 27
src/cfg.c

@@ -21,6 +21,7 @@
 #include "tandem.h"
 #include "src/mod/channels.mod/channels.h"
 #ifdef LEAF
+#include "src/chanprog.h"
 #include "src/mod/server.mod/server.h"
 #endif /* LEAF */
 #ifdef S_DCCPASS
@@ -415,54 +416,118 @@ struct cfg_entry CFG_PROCESSLIST = {
 };
 #endif /* S_PROCESSCHECK */
 
+#ifdef LEAF
+void servers_changed(struct cfg_entry * entry, char * olddata, int * valid) {
+  char *slist = NULL, *p = NULL;
 
-/* this is cfg shit from servers/irc/ctcp because hub doesnt load
- * these mods */
-
-#ifdef HUB
-void servers_describe(struct cfg_entry * entry, int idx) {
-#ifdef HUB
-  dprintf(idx, STR("servers is a comma-separated list of servers the bot will use\n"));
-#endif /* HUB */
-}
-
-void servers6_describe(struct cfg_entry * entry, int idx) {
-#ifdef HUB
-  dprintf(idx, STR("servers6 is a comma-separated list of servers the bot will use (FOR IPv6)\n"));
-#endif /* HUB */
+  if (!strcmp(entry->name, "servers")) {
+    if (conf.bot->host6 || conf.bot->ip6) /* we want to use the servers6 entry. */
+      return;
+  } else if (!strcmp(entry->name, "servers6")) {
+    if (!conf.bot->host6 && !conf.bot->ip6) /* we probably want to use the normal server list.. */
+      return;
+  }
+  slist = (char *) (entry->ldata ? entry->ldata : (entry->gdata ? entry->gdata : ""));
+  if (serverlist) {
+    clearq(serverlist);
+    serverlist = NULL;
+  }
+#ifdef S_RANDSERVERS
+  shuffle(slist, ",");
+#endif /* S_RANDSERVERS */
+  p = strdup(slist);
+  add_server(p);
+  free(p);
 }
+#endif /* LEAF */
 
-void nick_describe(struct cfg_entry * entry, int idx) {
 #ifdef HUB
-  dprintf(idx, STR("nick is the bots preferred nick when connecting/using .resetnick\n"));
-#endif /* HUB */
+void servers_describe(struct cfg_entry * entry, int idx) {
+  if (!strcmp(entry->name, "servers")) 
+    dprintf(idx, STR("servers is a comma-separated list of servers the bot will use\n"));
+  else
+    dprintf(idx, STR("servers6 is a comma-separated list of servers the bot will use (FOR IPv6)\n"));
 }
-
-void realname_describe(struct cfg_entry * entry, int idx) {
-#ifdef HUB
-  dprintf(idx, STR("realname is the bots \"real name\" when connecting\n"));
 #endif /* HUB */
-}
 
 struct cfg_entry CFG_SERVERS = {
 	"servers", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
+#ifdef LEAF
+	servers_changed, servers_changed, NULL
+#else
 	NULL, NULL, servers_describe
+#endif /* LEAF */
 };
+
 struct cfg_entry CFG_SERVERS6 = {
 	"servers6", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
-	NULL, NULL, servers6_describe
+#ifdef LEAF
+	servers_changed, servers_changed, NULL
+#else
+	NULL, NULL, servers_describe
+#endif /* LEAF */
 };
 
+#ifdef LEAF
+void nick_changed(struct cfg_entry * entry, char * olddata, int * valid) {
+  char *p = NULL;
+
+  if (entry->ldata)
+    p = entry->ldata;
+  else if (entry->gdata)
+    p = entry->gdata;
+  else
+    p = NULL;
+  if (p && p[0])
+    strncpyz(origbotname, p, NICKLEN + 1);
+  else
+    strncpyz(origbotname, conf.bot->nick, NICKLEN + 1);
+  if (server_online)
+    dprintf(DP_SERVER, "NICK %s\n", origbotname);
+}
+#endif /* LEAF */
+
+#ifdef HUB
+void nick_describe(struct cfg_entry * entry, int idx) {
+  dprintf(idx, STR("nick is the bots preferred nick when connecting/using .resetnick\n"));
+}
+#endif /* HUB */
+
 struct cfg_entry CFG_NICK = {
 	"nick", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
+#ifdef LEAF
+	nick_changed, nick_changed, NULL
+#else
 	NULL, NULL, nick_describe
+#endif /* LEAF */
 };
 
+#ifdef HUB
+void realname_describe(struct cfg_entry * entry, int idx) {
+  dprintf(idx, STR("realname is the bots \"real name\" when connecting\n"));
+}
+#endif /* HUB */
+
+#ifdef LEAF
+void realname_changed(struct cfg_entry * entry, char * olddata, int * valid) {
+  if (entry->ldata) {
+    strncpyz(botrealname, (char *) entry->ldata, 121);
+  } else if (entry->gdata) {
+    strncpyz(botrealname, (char *) entry->gdata, 121);
+  }
+}
+#endif /* LEAF */
+
 struct cfg_entry CFG_REALNAME = {
 	"realname", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
+#ifdef LEAF
+	realname_changed, realname_changed, NULL
+#else
 	NULL, NULL, realname_describe
+#endif /* LEAF */
 };
 
+#ifdef HUB
 void getin_describe(struct cfg_entry *cfgent, int idx)
 {
 #ifdef HUB
@@ -744,14 +809,11 @@ void init_config()
   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);
-  cfg_noshare = 1;
-  set_cfg_str(NULL, "realname", "A deranged product of evil coders");
-  cfg_noshare = 0;
+#ifdef HUB
   add_cfg(&CFG_OPBOTS);
   add_cfg(&CFG_INBOTS);
   add_cfg(&CFG_LAGTHRESHOLD);

+ 7 - 4
src/main.c

@@ -775,11 +775,14 @@ int main(int argc, char **argv)
   ctcp_init();
   chanprog();
 #ifdef HUB
-  if (!CFG_CHANSET.gdata) {
-    cfg_noshare++;
+  cfg_noshare = 1;
+  if (!CFG_CHANSET.gdata)
     set_cfg_str(NULL, "chanset", glob_chanset);
-    cfg_noshare--;
-  }
+  if (!CFG_SERVPORT.gdata)
+    set_cfg_str(NULL, "servport", "6667");
+  if (!CFG_REALNAME.gdata)
+    set_cfg_str(NULL, "realname", "A deranged product of evil coders.");
+  cfg_noshare = 0;
 #endif /* HUB */
 
   strcpy(botuser, origbotname);

+ 3 - 115
src/mod/server.mod/server.c

@@ -59,7 +59,7 @@ char botrealname[121] = "";	/* realname of bot */
 static int server_timeout;	/* server timeout for connecting */
 static int never_give_up;	/* never give up when connecting to servers? */
 static int strict_servernames;	/* don't update server list */
-static struct server_list *serverlist = NULL;	/* old-style queue, still used by
+struct server_list *serverlist = NULL;	/* old-style queue, still used by
 					   server list */
 int cycle_time;			/* cycle time till next server connect */
 port_t default_port;		/* default IRC port */
@@ -922,7 +922,7 @@ void queue_server(int which, char *buf, int len)
 
 /* Add a new server to the server_list.
  */
-static void add_server(char *ss)
+void add_server(char *ss)
 {
   struct server_list *x = NULL, *z = NULL;
 #ifdef USE_IPV6
@@ -986,7 +986,7 @@ static void add_server(char *ss)
 
 /* Clear out the given server_list.
  */
-static void clearq(struct server_list *xx)
+void clearq(struct server_list *xx)
 {
   struct server_list *x = NULL;
 
@@ -1003,109 +1003,6 @@ static void clearq(struct server_list *xx)
   }
 }
 
-void servers_describe(struct cfg_entry * entry, int idx) {
-}
-void servers6_describe(struct cfg_entry * entry, int idx) {
-}
-
-void servers_changed(struct cfg_entry * entry, char * olddata, int * valid) {
-#ifdef LEAF
-  char *slist = NULL, *p = NULL;
-
-  if (conf.bot->host6 || conf.bot->ip6) /* we want to use the servers6 entry. */
-    return;
-
-  slist = (char *) (entry->ldata ? entry->ldata : (entry->gdata ? entry->gdata : ""));
-  if (serverlist) {
-    clearq(serverlist);
-    serverlist = NULL;
-  }
-#ifdef S_RANDSERVERS
-  shuffle(slist, ",");
-#endif /* S_RANDSERVERS */
-  p = strdup(slist);
-  add_server(p);
-  free(p);
-#endif /* LEAF */
-}
-
-void servers6_changed(struct cfg_entry * entry, char * olddata, int * valid) {
-#ifdef LEAF
-  char *slist = NULL, *p = NULL;
-
-  if (!conf.bot->host6 && !conf.bot->ip6) /* we probably want to use the normal server list.. */
-    return;
-
-  slist = (char *) (entry->ldata ? entry->ldata : (entry->gdata ? entry->gdata : ""));
-  if (serverlist) {
-    clearq(serverlist);
-    serverlist = NULL;
-  }
-#ifdef S_RANDSERVERS
-  shuffle(slist, ",");
-#endif /* S_RANDSERVERS */
-  p = strdup(slist);
-  add_server(p);
-  free(p);
-#endif /* LEAF */
-}
-
-void nick_describe(struct cfg_entry * entry, int idx) {
-}
-
-void nick_changed(struct cfg_entry * entry, char * olddata, int * valid) {
-#ifdef LEAF
-  char *p = NULL;
-
-  if (entry->ldata)
-    p = entry->ldata;
-  else if (entry->gdata)
-    p = entry->gdata;
-  else
-    p = NULL;
-  if (p && p[0])
-    strncpyz(origbotname, p, NICKLEN + 1);
-  else
-    strncpyz(origbotname, conf.bot->nick, NICKLEN + 1);
-  if (server_online)
-    dprintf(DP_SERVER, "NICK %s\n", origbotname);
-#endif /* LEAF */
-}
-
-void realname_describe(struct cfg_entry * entry, int idx) {
-}
-
-void realname_changed(struct cfg_entry * entry, char * olddata, int * valid) {
-#ifdef LEAF
-  if (entry->ldata) {
-    strncpyz(botrealname, (char *) entry->ldata, 121);
-  } else if (entry->gdata) {
-    strncpyz(botrealname, (char *) entry->gdata, 121);
-  }
-#endif /* LEAF */
-}
-
-struct cfg_entry CFG_SERVERS = {
-  "servers", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
-  servers_changed, servers_changed, servers_describe
-};
-
-struct cfg_entry CFG_SERVERS6 = {
-  "servers6", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
-  servers6_changed, servers6_changed, servers6_describe
-};
-
-struct cfg_entry CFG_NICK = {
-  "nick", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
-  nick_changed, nick_changed, nick_describe
-};
-
-struct cfg_entry CFG_REALNAME = {
-  "realname", CFGF_LOCAL | CFGF_GLOBAL, NULL, NULL,
-  realname_changed, realname_changed, realname_describe
-};
-
-
 /* Set botserver to the next available server.
  *
  * -> if (*ptr == -1) then jump to that particular server
@@ -1533,14 +1430,5 @@ void server_init()
   curserv = 999;
   checked_hostmask = 0;
   do_nettype();
-  add_cfg(&CFG_NICK);
-  add_cfg(&CFG_SERVERS);
-  add_cfg(&CFG_SERVERS6);
-  add_cfg(&CFG_REALNAME);
-    cfg_noshare = 1;
-  if (!CFG_REALNAME.gdata)
-    set_cfg_str(NULL, "realname", "A deranged product of evil coders.");
-  set_cfg_str(NULL, "servport", "6667");
-  cfg_noshare = 0;
 }
 #endif /* LEAF */

+ 3 - 0
src/mod/server.mod/server.h

@@ -55,6 +55,7 @@ extern port_t		default_port;
 extern time_t		server_online;
 extern char		cursrvname[], botrealname[], botuserhost[], ctcp_reply[],
 			newserver[], newserverpass[];
+extern struct server_list *serverlist;
 
 int check_bind_ctcpr(char *, char *, struct userrec *, char *, char *, char *, bind_table_t *);
 
@@ -66,5 +67,7 @@ void server_report(int, int);
 void server_init();
 void queue_server(int, char *, int);
 void server_die();
+void add_server(char *);
+void clearq(struct server_list *);
 
 #endif /*leaf*/

+ 1 - 1
src/net.c

@@ -681,7 +681,7 @@ int open_telnet_raw(int sock, char *server, port_t sport)
       error = 1;
     }
   }
-
+/* FIXME: (error) is unitialized */
   /* I guess we broke something */
   if (error) {
     killsock(sock);