Mercurial > hg
diff mcabber/src/histolog.c @ 899:a833f3d6119a
Add option 'max_history_age'
New option to specify how many days mcabber will load from the history files.
(Suggested by "ze" in mcabber chatroom a few weeks ago)
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sat, 10 Jun 2006 12:16:09 +0200 |
parents | b16acadd7d53 |
children | c0d44a9a99bc |
line wrap: on
line diff
--- a/mcabber/src/histolog.c Thu Jun 08 21:42:52 2006 +0200 +++ b/mcabber/src/histolog.c Sat Jun 10 12:16:09 2006 +0200 @@ -132,6 +132,7 @@ struct stat bufstat; guint err = 0; guint ln = 0; // line number + time_t starttime; if (!FileLoadLogs) return; @@ -158,6 +159,16 @@ scr_LogPrint(LPRINT_LOGNORM, "Reading <%s> history file...", jid); } + starttime = 0; + if (settings_opt_get_int("max_history_age") > 0) { + int maxdays = settings_opt_get_int("max_history_age"); + time(&starttime); + if (maxdays >= starttime/86400) + starttime = 0; + else + starttime -= maxdays * 86400; + } + /* See write_histo_line() for line format... */ while (!feof(fp)) { guint dataoffset = 25; @@ -216,6 +227,14 @@ if ((tail > data+dataoffset+1) && (*(tail-1) == '\n')) *(tail-1) = 0; + // Check if the data is older than max_history_age + if (starttime) { + if (timestamp > starttime) + starttime = 0; // From now on, load everything + else + continue; + } + if (type == 'M') { char *converted; if (info == 'S')