bl_msg_only

This commit is contained in:
nohar 2006-10-21 12:06:31 +00:00
parent 7aa6305280
commit 98dcc2e4d4
6 changed files with 70 additions and 29 deletions

16
TODO
View File

@ -22,3 +22,19 @@ Thanks a lot for your help.
Best regards, Best regards,
Whoopie Whoopie
-- --
23:46 < nixternal> i have a question...when i log into my bip server with more
than 1 client at a time...i get a mass "ban message" from
the server..notice of all channel bans that i am in
23:52 < nohar> one of you client is downloading the ban list
23:52 < nohar> an both recieve the reply
23:52 < nixternal> ahhh
23:52 < nixternal> i am using konversation..so i need to figure how to shut
that off
23:53 < nixternal> the ban list for 50 channels sucks ;)
23:53 < nohar> yeah i don't know if you can disable this in konversation. maybe
we should code a hack for the ban reply to go only to the client
that asked for it
23:54 < nohar> there is such thing for /who already

View File

@ -55,6 +55,7 @@ int conf_backlog_lines = 10;
int conf_always_backlog; int conf_always_backlog;
int conf_log_sync_interval; int conf_log_sync_interval;
int conf_blreset_on_talk = 0; int conf_blreset_on_talk = 0;
int conf_bl_msg_only = 0;
list_t *parse_conf(FILE *file); list_t *parse_conf(FILE *file);
static void conf_die(char *fmt, ...); static void conf_die(char *fmt, ...);
@ -614,6 +615,9 @@ int fireup(FILE *conf)
case LEX_BACKLOG: case LEX_BACKLOG:
conf_backlog = t->ndata; conf_backlog = t->ndata;
break; break;
case LEX_BL_MSG_ONLY:
conf_bl_msg_only = t->ndata;
break;
case LEX_LOG: case LEX_LOG:
conf_log = t->ndata; conf_log = t->ndata;
break; break;

View File

@ -86,9 +86,10 @@
LEX_DEFAULT_NICK = 302, LEX_DEFAULT_NICK = 302,
LEX_DEFAULT_REALNAME = 303, LEX_DEFAULT_REALNAME = 303,
LEX_NO_CLIENT_AWAY_MSG = 304, LEX_NO_CLIENT_AWAY_MSG = 304,
LEX_BOOL = 305, LEX_BL_MSG_ONLY = 305,
LEX_INT = 306, LEX_BOOL = 306,
LEX_STRING = 307 LEX_INT = 307,
LEX_STRING = 308
}; };
#endif #endif
/* Tokens. */ /* Tokens. */
@ -139,9 +140,10 @@
#define LEX_DEFAULT_NICK 302 #define LEX_DEFAULT_NICK 302
#define LEX_DEFAULT_REALNAME 303 #define LEX_DEFAULT_REALNAME 303
#define LEX_NO_CLIENT_AWAY_MSG 304 #define LEX_NO_CLIENT_AWAY_MSG 304
#define LEX_BOOL 305 #define LEX_BL_MSG_ONLY 305
#define LEX_INT 306 #define LEX_BOOL 306
#define LEX_STRING 307 #define LEX_INT 307
#define LEX_STRING 308
@ -156,7 +158,7 @@ typedef union YYSTYPE
struct tuple *tuple; struct tuple *tuple;
} }
/* Line 1529 of yacc.c. */ /* Line 1529 of yacc.c. */
#line 160 "conf.h" #line 162 "conf.h"
YYSTYPE; YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1

View File

@ -80,7 +80,7 @@ struct tuple *tuple_l_new(int type, void *p)
%} %}
%token LEX_IP LEX_EQ LEX_PORT LEX_CSS LEX_SEMICOLON LEX_CONNECTION LEX_NETWORK LEX_LBRA LEX_RBRA LEX_USER LEX_NAME LEX_USERNAME LEX_NICK LEX_SERVER LEX_PASSWORD LEX_SRCIP LEX_HOST LEX_VHOST LEX_SOURCE_PORT LEX_NONE LEX_COMMENT LEX_BUNCH LEX_REALNAME LEX_SSL LEX_SSL_CHECK_MODE LEX_SSL_CHECK_STORE LEX_CHANNEL LEX_KEY LEX_LOG_ROOT LEX_LOG_FORMAT LEX_LOG_LEVEL LEX_BACKLOG_LINES LEX_BACKLOG LEX_LOG LEX_LOG_SYNC_INTERVAL LEX_FOLLOW_NICK LEX_ON_CONNECT_SEND LEX_AWAY_NICK LEX_PID_FILE LEX_IGN_FIRST_NICK LEX_ALWAYS_BACKLOG LEX_LOGIN LEX_BLRESET_ON_TALK LEX_DEFAULT_USER LEX_DEFAULT_NICK LEX_DEFAULT_REALNAME LEX_NO_CLIENT_AWAY_MSG %token LEX_IP LEX_EQ LEX_PORT LEX_CSS LEX_SEMICOLON LEX_CONNECTION LEX_NETWORK LEX_LBRA LEX_RBRA LEX_USER LEX_NAME LEX_USERNAME LEX_NICK LEX_SERVER LEX_PASSWORD LEX_SRCIP LEX_HOST LEX_VHOST LEX_SOURCE_PORT LEX_NONE LEX_COMMENT LEX_BUNCH LEX_REALNAME LEX_SSL LEX_SSL_CHECK_MODE LEX_SSL_CHECK_STORE LEX_CHANNEL LEX_KEY LEX_LOG_ROOT LEX_LOG_FORMAT LEX_LOG_LEVEL LEX_BACKLOG_LINES LEX_BACKLOG LEX_LOG LEX_LOG_SYNC_INTERVAL LEX_FOLLOW_NICK LEX_ON_CONNECT_SEND LEX_AWAY_NICK LEX_PID_FILE LEX_IGN_FIRST_NICK LEX_ALWAYS_BACKLOG LEX_LOGIN LEX_BLRESET_ON_TALK LEX_DEFAULT_USER LEX_DEFAULT_NICK LEX_DEFAULT_REALNAME LEX_NO_CLIENT_AWAY_MSG LEX_BL_MSG_ONLY
%union { %union {
int number; int number;
@ -113,6 +113,9 @@ command:
$3); } $3); }
| LEX_BACKLOG LEX_EQ LEX_BOOL { $$ = tuple_i_new(LEX_BACKLOG, | LEX_BACKLOG LEX_EQ LEX_BOOL { $$ = tuple_i_new(LEX_BACKLOG,
$3); } $3); }
| LEX_BL_MSG_ONLY LEX_EQ LEX_BOOL {
$$ = tuple_i_new(LEX_BL_MSG_ONLY, $3);
}
| LEX_LOG LEX_EQ LEX_BOOL { $$ = tuple_i_new(LEX_LOG, $3); } | LEX_LOG LEX_EQ LEX_BOOL { $$ = tuple_i_new(LEX_LOG, $3); }
| LEX_ALWAYS_BACKLOG LEX_EQ LEX_BOOL { $$ = tuple_i_new( | LEX_ALWAYS_BACKLOG LEX_EQ LEX_BOOL { $$ = tuple_i_new(
LEX_ALWAYS_BACKLOG, $3); } LEX_ALWAYS_BACKLOG, $3); }

View File

@ -84,6 +84,7 @@ list_t *parse_conf(FILE *file)
"log_format" { return LEX_LOG_FORMAT; } "log_format" { return LEX_LOG_FORMAT; }
"backlog_lines" { return LEX_BACKLOG_LINES; } "backlog_lines" { return LEX_BACKLOG_LINES; }
"backlog" { return LEX_BACKLOG; } "backlog" { return LEX_BACKLOG; }
"bl_msg_only" { return LEX_BL_MSG_ONLY; }
"log" { return LEX_LOG; } "log" { return LEX_LOG; }
"always_backlog" { return LEX_ALWAYS_BACKLOG; } "always_backlog" { return LEX_ALWAYS_BACKLOG; }
"log_sync_interval" { return LEX_LOG_SYNC_INTERVAL; } "log_sync_interval" { return LEX_LOG_SYNC_INTERVAL; }

View File

@ -28,6 +28,7 @@ int conf_memlog = 1;
extern int conf_backlog; extern int conf_backlog;
extern int conf_backlog_lines; extern int conf_backlog_lines;
extern int conf_always_backlog; extern int conf_always_backlog;
extern int conf_bl_msg_only;
int log_set_backlog_offset(log_t *logdata, char *dest); int log_set_backlog_offset(log_t *logdata, char *dest);
static int _log_write(log_t *logdata, logfilegroup_t *lf, char *d, char *str); static int _log_write(log_t *logdata, logfilegroup_t *lf, char *d, char *str);
@ -66,7 +67,7 @@ int check_dir_r(char *dirname)
int pos, count = 0; int pos, count = 0;
char *dir, *tmp; char *dir, *tmp;
int len = strlen(dirname); int len = strlen(dirname);
mylog(LOG_DEBUGVERB, "Recursive check of %s engaged", dirname); mylog(LOG_DEBUGVERB, "Recursive check of %s engaged", dirname);
tmp = dirname; tmp = dirname;
dir = (char *)malloc(sizeof(char) * (len + 1)); dir = (char *)malloc(sizeof(char) * (len + 1));
@ -131,12 +132,12 @@ char *log_build_filename(log_t *logdata, char *destination)
time_t s; time_t s;
char *dest = strdup(destination); char *dest = strdup(destination);
strtolower(dest); strtolower(dest);
log_format_len = strlen(conf_log_format); log_format_len = strlen(conf_log_format);
logfile = (char*)malloc((MAX_PATH_LEN + 1)*sizeof(char)); logfile = (char*)malloc((MAX_PATH_LEN + 1)*sizeof(char));
if (!logfile) if (!logfile)
fatal("out of memory"); fatal("out of memory");
time(&s); time(&s);
now = localtime(&s); now = localtime(&s);
snprintf(year, 5, "%04d", now->tm_year + 1900); snprintf(year, 5, "%04d", now->tm_year + 1900);
@ -150,16 +151,16 @@ char *log_build_filename(log_t *logdata, char *destination)
replace_var(logfile, "%Y", year, MAX_PATH_LEN); replace_var(logfile, "%Y", year, MAX_PATH_LEN);
replace_var(logfile, "%d", day, MAX_PATH_LEN); replace_var(logfile, "%d", day, MAX_PATH_LEN);
replace_var(logfile, "%m", month, MAX_PATH_LEN); replace_var(logfile, "%m", month, MAX_PATH_LEN);
logdir = strdup(logfile); logdir = strdup(logfile);
if (!logdir) if (!logdir)
fatal("out of memory"); fatal("out of memory");
/* strrchr works on bytes, not on char (if sizeof(char) != 1) */ /* strrchr works on bytes, not on char (if sizeof(char) != 1) */
tmp = strrchr(logdir, '/'); tmp = strrchr(logdir, '/');
if (tmp) if (tmp)
*tmp = '\0'; *tmp = '\0';
free(dest); free(dest);
if (check_dir_r(logdir)) { if (check_dir_r(logdir)) {
free(logfile); free(logfile);
@ -611,7 +612,7 @@ void log_client_none_connected(log_t *logdata)
if (conf_always_backlog) if (conf_always_backlog)
return; return;
for (hash_it_init(&logdata->logfgs, &hi); hash_it_item(&hi); for (hash_it_init(&logdata->logfgs, &hi); hash_it_item(&hi);
hash_it_next(&hi)) { hash_it_next(&hi)) {
lfg = hash_it_item(&hi); lfg = hash_it_item(&hi);
@ -699,7 +700,6 @@ int log_has_backlog(log_t *logdata, char *destination)
* 01-08-2005 10:46:11 < * jj!john@thebox.ofjj.net * 01-08-2005 10:46:11 < * jj!john@thebox.ofjj.net
*/ */
/* must *not* return NULL */
char *log_beautify(char *buf, char *dest) char *log_beautify(char *buf, char *dest)
{ {
int action = 0; int action = 0;
@ -727,8 +727,12 @@ char *log_beautify(char *buf, char *dest)
return _log_wrap(dest, buf); return _log_wrap(dest, buf);
lots = p - sots; lots = p - sots;
p++; p++;
if (strncmp(p, "-!-", 3) == 0) if (strncmp(p, "-!-", 3) == 0) {
return _log_wrap(dest, buf); if (conf_bl_msg_only)
return NULL;
else
return _log_wrap(dest, buf);
}
if (*p == '>') if (*p == '>')
out = 1; out = 1;
@ -736,6 +740,7 @@ char *log_beautify(char *buf, char *dest)
out = 0; out = 0;
else else
return _log_wrap(dest, buf); return _log_wrap(dest, buf);
p++; p++;
if (*p != ' ') if (*p != ' ')
return _log_wrap(dest, buf); return _log_wrap(dest, buf);
@ -746,7 +751,7 @@ char *log_beautify(char *buf, char *dest)
return _log_wrap(dest, buf); return _log_wrap(dest, buf);
p += 2; p += 2;
} }
son = p; son = p;
while (*p && *p != '!' && *p != ' ' && *p != ':') while (*p && *p != '!' && *p != ' ' && *p != ':')
p++; p++;
@ -757,10 +762,10 @@ char *log_beautify(char *buf, char *dest)
p = strchr(p, ' '); p = strchr(p, ' ');
if (!p || !p[0]) if (!p || !p[0])
return _log_wrap(dest, buf); return _log_wrap(dest, buf);
done = ((p[-1] == ':') || (action && (p[1] != '('))); done = ((p[-1] == ':') || (action && (p[1] != '(')));
p++; p++;
/* /*
* TODO add a : before the action text in the log files * TODO add a : before the action text in the log files
* otherwise "/me (bla) blabla" on a chan is logged exactly as * otherwise "/me (bla) blabla" on a chan is logged exactly as
@ -774,7 +779,7 @@ char *log_beautify(char *buf, char *dest)
while (*p && *p != ')' && *p != ' ' && *p != '!') while (*p && *p != ')' && *p != ' ' && *p != '!')
p++; p++;
lod = p - sod; lod = p - sod;
if (*p == '!') if (*p == '!')
while (*p && *p != ')' && *p != ' ') while (*p && *p != ')' && *p != ' ')
p++; p++;
@ -846,7 +851,7 @@ char *log_beautify(char *buf, char *dest)
if (action) if (action)
*p++ = 1; *p++ = 1;
*p++ = '\r'; *p++ = '\r';
*p++ = '\n'; *p++ = '\n';
*p = 0; *p = 0;
@ -951,6 +956,10 @@ next_file:
} }
buf[pos] = 0; buf[pos] = 0;
ret = log_beautify(buf, destination); ret = log_beautify(buf, destination);
if (ret == NULL) {
pos = 0;
continue;
}
free(buf); free(buf);
return ret; return ret;
} }
@ -1000,6 +1009,10 @@ next_file:
lf->backlog_offset--; lf->backlog_offset--;
buf[pos] = 0; buf[pos] = 0;
ret = log_beautify(buf, destination); ret = log_beautify(buf, destination);
if (ret == NULL) {
pos = 0;
continue;
}
free(buf); free(buf);
return ret; return ret;
} }
@ -1028,7 +1041,7 @@ static char *_log_wrap(char *dest, char *line)
} }
static int _log_write(log_t *logdata, logfilegroup_t *lfg, char *destination, static int _log_write(log_t *logdata, logfilegroup_t *lfg, char *destination,
char *str) char *str)
{ {
size_t nbwrite; size_t nbwrite;
size_t len; size_t len;
@ -1037,11 +1050,13 @@ static int _log_write(log_t *logdata, logfilegroup_t *lfg, char *destination,
if (lfg->memlog) { if (lfg->memlog) {
char *r = log_beautify(str, destination); char *r = log_beautify(str, destination);
list_add_last(lfg->memlog, r); if (r != NULL) {
if (lfg->memc == conf_backlog_lines) list_add_last(lfg->memlog, r);
free(list_remove_first(lfg->memlog)); if (lfg->memc == conf_backlog_lines)
else free(list_remove_first(lfg->memlog));
lfg->memc++; else
lfg->memc++;
}
} }
if (!conf_log) if (!conf_log)