From: Roy Marples Date: Wed, 14 May 2008 09:21:46 +0000 (+0000) Subject: Define our own log text so we can move it off bss. X-Git-Tag: v4.0.2~412 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6f0c6b6e6f91336e451b09cfa242d290e7f9bc4;p=thirdparty%2Fdhcpcd.git Define our own log text so we can move it off bss. --- diff --git a/logger.c b/logger.c index e542081f..f26c506b 100644 --- a/logger.c +++ b/logger.c @@ -25,10 +25,6 @@ * SUCH DAMAGE. */ -#ifndef SYSLOG_NAMES -# define SYSLOG_NAMES -#endif - #include #include #include @@ -42,26 +38,38 @@ static int loglevel = LOG_WARNING; static char logprefix[12] = {0}; +struct logname { + int level; + const char *name; +}; +static const struct logname const lognames[] = { + { LOG_DEBUG, "debug" }, + { LOG_INFO, "info" }, + { LOG_WARNING, "warning" }, + { LOG_ERR, "err" }, + { -1, NULL } +}; + int logtolevel(const char *priority) { - CODE *c; + const struct logname *lt; if (isdigit((unsigned char)*priority)) return atoi(priority); - for (c = prioritynames; c->c_name; c++) - if (!strcasecmp(priority, c->c_name)) - return c->c_val; + for (lt = lognames; lt->name; lt++) + if (!strcasecmp(priority, lt->name)) + return lt->level; return -1; } static const char * leveltolog(int level) { - CODE *c; + const struct logname *lt; - for (c = prioritynames; c->c_name; c++) - if (c->c_val == level) - return c->c_name; + for (lt = lognames; lt->name; lt++) + if (lt->level == level) + return lt->name; return NULL; } diff --git a/mk/prog.mk b/mk/prog.mk index 5c12b853..dc9bdf22 100644 --- a/mk/prog.mk +++ b/mk/prog.mk @@ -26,7 +26,7 @@ ${PROG}: ${OBJS} small: ${SRCS} echo "" > _${PROG}.c for src in ${SRCS}; do echo "#include \"$$src\"" >> _${PROG}.c; done - ${CC} ${CFLAGS} -DSYSLOG_NAMES -c _${PROG}.c -o _${PROG}.o + ${CC} ${CFLAGS} -c _${PROG}.c -o _${PROG}.o ${CC} ${LDFLAGS} -o ${PROG} _${PROG}.o ${LDADD} _proginstall: ${PROG}