Mercurial > dnsbl
diff src/tokenizer.cpp @ 98:91c27c00048f
tokenizer errors now go thru syslog to be visible during config file reloads in normal operation
author | carl |
---|---|
date | Thu, 22 Sep 2005 21:57:08 -0700 |
parents | 1142e46be550 |
children | d9c64bafbf60 |
line wrap: on
line diff
--- a/src/tokenizer.cpp Wed Sep 21 13:29:28 2005 -0700 +++ b/src/tokenizer.cpp Thu Sep 22 21:57:08 2005 -0700 @@ -6,10 +6,12 @@ */ -#include "dnsbl.h" +#include "includes.h" static char* tokenizer_version="$Id$"; +const int maxlen = 1000; // used for snprintf buffers + enum state {s_init, s_token, s_string, @@ -342,13 +344,13 @@ bool TOKEN::include(char *fn) { string_set::iterator i = filenamess.find(fn); if (i != filenamess.end()) { - my_syslog("redundant or recursive include file detected"); + token_error("redundant or recursive include file detected"); return false; } ifstream *is = new ifstream; is->open(fn); if (is->fail()) { - char buf[1000]; + char buf[maxlen]; snprintf(buf, sizeof(buf), "include file %s not found", fn); token_error(buf); return false; @@ -486,18 +488,24 @@ void TOKEN::token_error(const char *err) { token_error(); - printf("%s \n", err); + char buf[maxlen]; + snprintf(buf, sizeof(buf), "%s \n", err); + my_syslog(buf); } void TOKEN::token_error(const char *fmt, int d, const char *s) { - printf(fmt, d, s); + char buf[maxlen]; + snprintf(buf, sizeof(buf), fmt, d, s); + my_syslog(buf); } void TOKEN::token_error(const char *fmt, const char *t, const char *h) { if (!h) h = "null"; - printf(fmt, t, h); + char buf[maxlen]; + snprintf(buf, sizeof(buf), fmt, t, h); + my_syslog(buf); }