Merge branch 'master' into bip08

Conflicts:

	src/log.c
This commit is contained in:
Arnaud Cornet 2009-01-09 09:57:17 +01:00
commit a6bb697f5d
3 changed files with 38 additions and 17 deletions

View File

@ -228,6 +228,7 @@ pid_is_there:
if (c != 1 || p == 0) {
mylog(LOG_INFO, "pid file found but invalid "
"data inside. Continuing...\n");
fclose(f);
if (unlink(conf_pid_file)) {
fatal("Cannot delete pid file '%s', "
"check permissions.\n",
@ -1379,7 +1380,7 @@ void adm_print_connection(struct link_client *ic, struct link *lnk,
noroom: /* that means the line is larger that RET_STR_LEN. We're not likely to
even read such a long line */
buf[RET_STR_LEN] = 0;
bip_notify(ic, buf);
bip_notify(ic, "%s", buf);
// TODO: on_connect_send
@ -1396,13 +1397,13 @@ noroom: /* that means the line is larger that RET_STR_LEN. We're not likely to
(ch->backlog ? "" : "`"));
if (t_written > LINE_SIZE_LIM) {
buf[RET_STR_LEN] = 0;
bip_notify(ic, buf);
bip_notify(ic, "%s", buf);
t_written = 0;
}
}
noroomchan:
buf[RET_STR_LEN] = 0;
bip_notify(ic, buf);
bip_notify(ic, "%s", buf);
t_written = snprintf(buf, RET_STR_LEN, " Status: ");
if (t_written >= RET_STR_LEN)
@ -1462,7 +1463,7 @@ noroomchan:
}
noroomstatus:
buf[RET_STR_LEN] = 0;
bip_notify(ic, buf);
bip_notify(ic, "%s", buf);
}
void adm_list_all_links(struct link_client *ic)
@ -1521,8 +1522,7 @@ void adm_info_user(struct link_client *ic, const char *name)
noroom:
buf[RET_STR_LEN] = 0;
bip_notify(ic, buf);
t_written = 0;
bip_notify(ic, "%s", buf);
#ifdef HAVE_LIBSSL
bip_notify(ic, "SSL check mode '%s', stored into '%s'",
@ -1590,13 +1590,13 @@ void adm_list_users(struct link_client *ic)
goto noroom;
if (t_written > LINE_SIZE_LIM) {
buf[RET_STR_LEN] = 0;
bip_notify(ic, buf);
bip_notify(ic, "%s", buf);
t_written = 0;
}
}
noroom:
buf[RET_STR_LEN] = 0;
bip_notify(ic, buf);
bip_notify(ic, "%s", buf);
}
bip_notify(ic, "-- End of User list");
}
@ -1640,13 +1640,13 @@ void adm_list_networks(struct link_client *ic)
goto noroom;
if (t_written > LINE_SIZE_LIM) {
buf[RET_STR_LEN] = 0;
bip_notify(ic, buf);
bip_notify(ic, "%s", buf);
t_written = 0;
}
}
noroom:
buf[RET_STR_LEN] = 0;
bip_notify(ic, buf);
bip_notify(ic, "%s", buf);
}
bip_notify(ic, "-- End of Network list");
}

View File

@ -2469,7 +2469,7 @@ void irc_main(bip_t *bip)
char *l;
while ((l = list_remove_first(&bip->errors)))
bip_notify(bip->reloading_client, l);
bip_notify(bip->reloading_client, "%s", l);
bip->reloading_client = NULL;
}

View File

@ -29,6 +29,7 @@ static int _log_write(log_t *logdata, logstore_t *lf, const char *d,
const char *str);
static char *_log_wrap(const char *dest, const char *line);
void logfile_free(logfile_t *lf);
static void log_drop(log_t *log, const char *storename);
#define BOLD_CHAR 0x02
#define LAMESTRING "!bip@bip.bip.bip PRIVMSG "
@ -131,13 +132,11 @@ void replace_var(char *str, char *var, char *value, unsigned int max)
char *log_build_filename(log_t *logdata, const char *destination)
{
char *logfile, year[5], day[3], month[3], *tmp, *logdir;
int log_format_len;
struct tm *now;
time_t s;
char *dest = bip_strdup(destination);
strtolower(dest);
log_format_len = strlen(conf_log_format);
logfile = (char *)bip_malloc(MAX_PATH_LEN + 1);
time(&s);
@ -459,8 +458,11 @@ void log_nick(log_t *logdata, const char *ircmask, const char *channel,
{
char *oldnick = nick_from_ircmask(ircmask);
if (hash_includes(&logdata->logfgs, oldnick))
if (hash_includes(&logdata->logfgs, oldnick)) {
if (hash_includes(&logdata->logfgs, newnick))
log_drop(logdata, newnick);
hash_rename_key(&logdata->logfgs, oldnick, newnick);
}
free(oldnick);
snprintf(logdata->buffer, LOGLINE_MAXLEN,
@ -654,6 +656,27 @@ void log_client_disconnected(log_t *logdata)
mylog(LOG_DEBUG, "A client disconnected");
}
void log_store_free(logstore_t *store)
{
logfile_t *lf;
log_reset(store);
if ((lf = list_remove_first(&store->file_group)))
logfile_free(lf);
free(store->name);
if (store->memlog)
list_free(store->memlog);
free(store);
}
static void log_drop(log_t *log, const char *storename)
{
logstore_t *store;
store = hash_remove(&log->logfgs, storename);
log_store_free(store);
}
void log_reinit_all(log_t *logdata)
{
logstore_t *store;
@ -1130,7 +1153,6 @@ void log_free(log_t *log)
{
hash_iterator_t it;
logstore_t *store;
logfile_t *lf;
list_remove(log_all_logs, log);
@ -1140,8 +1162,7 @@ void log_free(log_t *log)
for (hash_it_init(&log->logfgs, &it); (store = hash_it_item(&it));
hash_it_next(&it)) {
log_reset(store);
while ((lf = list_remove_first(&store->file_group)))
logfile_free(lf);
log_store_free(store);
}
hash_clean(&log->logfgs);
free(log);