|
|
@@ -14,6 +14,7 @@
|
|
|
#include "main.h"
|
|
|
#include "settings.h"
|
|
|
#include "misc.h"
|
|
|
+#include "users.h"
|
|
|
#include "misc_file.h"
|
|
|
#include "socket.h"
|
|
|
|
|
|
@@ -266,9 +267,10 @@ fatal:
|
|
|
void
|
|
|
init_conf()
|
|
|
{
|
|
|
- conf.bots = (conf_bot *) my_calloc(1, sizeof(conf_bot));
|
|
|
- conf.bots->nick = NULL;
|
|
|
- conf.bots->next = NULL;
|
|
|
+// conf.bots = (conf_bot *) my_calloc(1, sizeof(conf_bot));
|
|
|
+// conf.bots->nick = NULL;
|
|
|
+// conf.bots->next = NULL;
|
|
|
+ conf.bots = NULL;
|
|
|
conf.bot = NULL;
|
|
|
|
|
|
conf.watcher = 0;
|
|
|
@@ -346,12 +348,9 @@ checkpid(char *nick, conf_bot *bot)
|
|
|
void
|
|
|
conf_addbot(char *nick, char *ip, char *host, char *ip6)
|
|
|
{
|
|
|
- conf_bot *bot = NULL;
|
|
|
-
|
|
|
- for (bot = conf.bots; bot && bot->nick; bot = bot->next) ;
|
|
|
+ conf_bot *bot = (conf_bot *) my_calloc(1, sizeof(conf_bot));
|
|
|
|
|
|
- bot->next = (conf_bot *) my_calloc(1, sizeof(conf_bot));
|
|
|
- bot->next->next = NULL;
|
|
|
+ bot->next = NULL;
|
|
|
bot->pid_file = NULL;
|
|
|
bot->nick = strdup(nick);
|
|
|
bot->net.ip = NULL;
|
|
|
@@ -394,7 +393,7 @@ conf_addbot(char *nick, char *ip, char *host, char *ip6)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!bot->hub && bot == conf.bots) {
|
|
|
+ if (!bot->hub && !conf.bots) {
|
|
|
bot->localhub = 1; /* first bot */
|
|
|
conf.localhub = strdup(nick ? nick : origbotname);
|
|
|
/* perhaps they did -B localhub-bot ? */
|
|
|
@@ -402,34 +401,27 @@ conf_addbot(char *nick, char *ip, char *host, char *ip6)
|
|
|
localhub = 1;
|
|
|
}
|
|
|
|
|
|
+ list_append((struct list_type **) &(conf.bots), (struct list_type *) bot);
|
|
|
+// list_append((struct list_type **) &(cache->cchan), (struct list_type *) cchan);
|
|
|
}
|
|
|
|
|
|
void
|
|
|
-free_bot(char *botn)
|
|
|
+free_bot(conf_bot *bot)
|
|
|
{
|
|
|
- conf_bot *bot = NULL, *old = NULL;
|
|
|
-
|
|
|
- for (bot = conf.bots; bot && bot->nick; old = bot, bot = bot->next) {
|
|
|
- if (!strcmp(botn, bot->nick)) {
|
|
|
- free(bot->nick);
|
|
|
- free(bot->pid_file);
|
|
|
- if (bot->net.ip)
|
|
|
- free(bot->net.ip);
|
|
|
- if (bot->net.host)
|
|
|
- free(bot->net.host);
|
|
|
- if (bot->net.ip6)
|
|
|
- free(bot->net.ip6);
|
|
|
- if (bot->net.host6)
|
|
|
- free(bot->net.host6);
|
|
|
-
|
|
|
- if (old)
|
|
|
- old->next = bot->next;
|
|
|
- else
|
|
|
- conf.bots = bot->next;
|
|
|
- free(bot);
|
|
|
-
|
|
|
- break;
|
|
|
- }
|
|
|
+ if (bot) {
|
|
|
+ list_delete((struct list_type **) &(conf.bots), (struct list_type *) bot);
|
|
|
+
|
|
|
+ free(bot->nick);
|
|
|
+ free(bot->pid_file);
|
|
|
+ if (bot->net.ip)
|
|
|
+ free(bot->net.ip);
|
|
|
+ if (bot->net.host)
|
|
|
+ free(bot->net.host);
|
|
|
+ if (bot->net.ip6)
|
|
|
+ free(bot->net.ip6);
|
|
|
+ if (bot->net.host6)
|
|
|
+ free(bot->net.host6);
|
|
|
+ free(bot);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -442,7 +434,7 @@ conf_delbot(char *botn)
|
|
|
if (!strcmp(bot->nick, botn)) { /* found it! */
|
|
|
bot->pid = checkpid(bot->nick, bot);
|
|
|
killbot(bot->nick, SIGKILL);
|
|
|
- free_bot(bot->nick);
|
|
|
+ free_bot(bot);
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
@@ -456,15 +448,9 @@ free_conf_bots(void)
|
|
|
|
|
|
for (bot = conf.bots; bot; bot = bot_n) {
|
|
|
bot_n = bot->next;
|
|
|
-
|
|
|
- free_bot(bot->nick);
|
|
|
- }
|
|
|
- if (conf.bots) {
|
|
|
- if (!conf.bots->next)
|
|
|
- free(conf.bots);
|
|
|
- else
|
|
|
- sdprintf("FAILED TO CLEAR ALL OF .bots!, MEMORY LEAK!\n");
|
|
|
+ free_bot(bot);
|
|
|
}
|
|
|
+ conf.bots = NULL;
|
|
|
}
|
|
|
|
|
|
int
|