diff --git a/src/bip.c b/src/bip.c index 2324a77..c803a36 100644 --- a/src/bip.c +++ b/src/bip.c @@ -624,7 +624,6 @@ int fireup(FILE *conf) { struct tuple *t; list_t *l; - list_iterator_t li; int r; conf_start(); @@ -695,7 +694,7 @@ int fireup(FILE *conf) if (t->type == TUPLE_STR) free(t->pdata); conf_die("Config error in base config (%d)", t->type); - return; + return 0; } free(t); } @@ -707,7 +706,7 @@ int fireup(FILE *conf) conf_die("You must set conf_backlog_lines if " "conf_log = false and " "conf_backlog = true"); - return; + return 0; } } @@ -715,7 +714,7 @@ int fireup(FILE *conf) if (conf_backlog_lines == 0) { conf_die("You must have not nul conf_backlog_lines if " "conf_always_backlog is enabled"); - return; + return 0; } } @@ -1080,6 +1079,14 @@ void adm_bip(struct link_client *ic, struct line *line) "jumpin' jumpin'"); connection_close(CONN(LINK(ic)->l_server)); } + } else if (strcasecmp(line->elemv[1], "BLRESET") == 0) { + hash_iterator_t it; + for (hash_it_init(&LINK(ic)->log->logfgs, &it); + hash_it_item(&it); + hash_it_next(&it)) { + logfilegroup_t *lfg = hash_it_item(&it); + log_reset(lfg); + } } else if (strcasecmp(line->elemv[1], "HELP") == 0) { WRITE_LINE2(CONN(ic), P_IRCMASK, "PRIVMSG", nick, "/BIP (RELOAD|LIST|JUMP|HELP)"); diff --git a/src/connection.c b/src/connection.c index 6044f85..6b5a550 100644 --- a/src/connection.c +++ b/src/connection.c @@ -944,7 +944,7 @@ static connection_t *connection_init(int anti_flood, int ssl, int timeout, { connection_t *conn; char *incoming; - list_t *outgoing, *incoming_lines; + list_t *outgoing; conn = (connection_t*)malloc(sizeof(connection_t)); incoming = (char*)malloc(sizeof(char) * CONN_BUFFER_SIZE); diff --git a/src/log.c b/src/log.c index 0ecb589..ecc21c9 100644 --- a/src/log.c +++ b/src/log.c @@ -178,16 +178,24 @@ void log_updatelast(logfile_t *lf) localtime_r(&t, &lf->last_log); } -void log_reinit(logfilegroup_t *lfg) +void log_reset(logfilegroup_t *lfg) { - mylog(LOG_ERROR, "%s is inconsistant, droping backlog info", - lfg->name); logfile_t *olf; + + if (lfg->memlog) { + while (!list_is_empty(lfg->memlog)) + free(list_remove_first(lfg->memlog)); + return; + } + while ((olf = list_get_first(&lfg->file_group)) != list_get_last(&lfg->file_group)) { logfile_free(olf); list_remove_first(&lfg->file_group); } + if (!olf) + return; + if (!olf->file) fatal("internal, (NULL logfile)"); fseek(olf->file, 0, SEEK_END); @@ -195,6 +203,13 @@ void log_reinit(logfilegroup_t *lfg) olf->backlog_offset = olf->len; } +void log_reinit(logfilegroup_t *lfg) +{ + mylog(LOG_ERROR, "%s is inconsistant, droping backlog info", + lfg->name); + log_reset(lfg); +} + static int log_add_file(log_t *logdata, char *destination, char *filename) { FILE *f; @@ -784,7 +799,7 @@ char *log_beautify(char *buf, char *dest) p = ret = (char *)malloc( 1 + lon + strlen(LAMESTRING) + lod + 2 + lots + - 1 + 3 + lom + 3 + action * (2 + strlen("ACTION "))); + 1 + 5 + lom + 3 + action * (2 + strlen("ACTION "))); if (!p) fatal("out of memory"); *p++ = ':'; @@ -807,7 +822,7 @@ char *log_beautify(char *buf, char *dest) p += strlen("ACTION "); } if (out) { - memcpy(p, "->", 2); + memcpy(p, " -> ", 4); p += 2; } memcpy(p, sots, lots); diff --git a/src/log.h b/src/log.h index 89a3a81..ee9ec2b 100644 --- a/src/log.h +++ b/src/log.h @@ -92,4 +92,5 @@ char *log_backread(log_t *logdata, char *destination); int log_has_backlog(log_t *logdata, char *destination); void log_flush_all(void); void log_client_none_connected(log_t *logdata); +void log_reset(logfilegroup_t *); #endif