X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/c86edd1d9e5994aea33cfad3164e4827e591e7e6..78546f2b0f59b5c8fede1ce5535972716eb17041:/qabot/qabot_dbase.c diff --git a/qabot/qabot_dbase.c b/qabot/qabot_dbase.c index aeca5d82..4bd50c58 100644 --- a/qabot/qabot_dbase.c +++ b/qabot/qabot_dbase.c @@ -1,5 +1,4 @@ #include -#include #include #include "../nick/nick.h" @@ -21,14 +20,8 @@ void qabot_loaddb() { char* args[100]; time_t created; flag_t flags; - int spam_interval; - int ask_wait; - int queued_question_interval; - qab_bot* bot; - qab_block* b; - char blocktype; - if (!(f = fopen("qab_users", "r"))) + if (!(f = fopen("data/qab_users", "r"))) return; while (!feof(f)) { @@ -48,7 +41,7 @@ void qabot_loaddb() { fclose(f); - if (!(f = fopen("qab_bots", "r"))) + if (!(f = fopen("data/qab_bots", "r"))) return; while (!feof(f)) { @@ -65,69 +58,14 @@ void qabot_loaddb() { } fclose(f); - - if (!(f = fopen("qab_blocks", "r"))) - return; - - while (!feof(f)) { - if (fgets(buf, 2048, f)) { - buf[2048] = '\0'; - if (splitline(buf, args, 50, 0) != 5) { - fclose(f); - return; - } - - /* args[0] = botname - args[1] = type - args[2] = creator - args[3] = created - args[4] = blockstr */ - if (!strcmp(args[0], "q")) { - /* account block */ - if (strchr(args[4], '*') || args[4](target, '?')) - continue; /* wildcard account blocks are not supported */ - - blocktype = QABBLOCK_ACCOUNT; - } - else if (!strcmp(args[0], "t")) { - /* text block */ - blocktype = QABBLOCK_TEXT; - } - else if (!strcmp(args[0], "h")) { - /* hostmask block */ - blocktype = QABBLOCK_HOST; - } - else - continue; /* unknown block, lets skip and hope everything works out */ - - if (!(bot = qabot_findbot(args[0]))) - continue; /* no such bot added */ - - b = (qab_block*)malloc(sizeof(qab_block)); - b->type = blocktype; - b->created = (long)strol(args[3]); - strncpy(b->creator, args[2], ACCOUNTLEN); - b->creator[ACCOUNTLEN] = '\0'; - b->blockstr = strdup(args[4]); - b->prev = 0; - b->next = bot->blocks; - if (bot->blocks) - bot->blocks->prev = b; - bot->blocks = b; - bot->block_count++; - } - } - - fclose(f); } void qabot_savedb() { FILE* f; qab_user* u; qab_bot* b; - qab_block* block; - if (!(f = fopen("qab_users", "w"))) + if (!(f = fopen("data/qab_users", "w"))) return; for (u = qabot_users; u; u = u->next) @@ -135,7 +73,7 @@ void qabot_savedb() { fclose(f); - if (!(f = fopen("qab_bots", "w"))) + if (!(f = fopen("data/qab_bots", "w"))) return; for (b = qab_bots; b; b = b->next) @@ -144,16 +82,6 @@ void qabot_savedb() { b->ask_wait, b->queued_question_interval); fclose(f); - - if (!(f = fopen("qab_blocks", "w"))) - return; - - for (b = qab_bots; b; b = b->next) - for (block = b->blocks; block; block = block->next) - fprintf(f, "%s %c %s %ld %s\n", b->nick, block->type == QABBLOCK_ACCOUNT ? 'q' : block->type == QABBLOCK_HOST ? 'h' : 't', - block->creator, block->created, block->blockstr); - - fclose(f); } void qabot_savetimer(void* arg) { @@ -208,13 +136,3 @@ qab_user* qabot_getuser(const char* authname) { return 0; } - -qab_bot* qabot_findbot(const char* nickname) { - qab_bot* bot; - - for (bot = qab_bots; bot; bot = bot->next) - if (!ircd_strcmp(bot->nick, nickname)) - return bot; - - return 0; -}