From ba7e33a062fbd2d827833b0c57294aa5434befed Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Tue, 14 Feb 2012 18:25:39 +0000 Subject: [PATCH] * Add support for user-configurable log level settings. --- log.c | 7 ++++--- minidlna.c | 17 ++++++++++++++--- minidlna.conf | 4 ++++ minissdp.c | 11 ++--------- options.c | 1 + options.h | 1 + utils.c | 25 ++++++++++++++++++++++++- utils.h | 3 +++ 8 files changed, 53 insertions(+), 16 deletions(-) diff --git a/log.c b/log.c index ef21e8f..91aa564 100644 --- a/log.c +++ b/log.c @@ -62,11 +62,11 @@ log_init(const char *fname, const char *debug) if (debug) { - char *rhs, *lhs, *p; + const char *rhs, *lhs, *nlhs, *p; int n; int level, facility; memset(&log_level_set, 0, sizeof(log_level_set)); - rhs = lhs = (char*) debug; + rhs = nlhs = debug; while (rhs && (rhs = strchr(rhs, '='))) { rhs++; p = strchr(rhs, ','); @@ -75,7 +75,8 @@ log_init(const char *fname, const char *debug) if (!(strncasecmp(level_name[level], rhs, n))) break; } - rhs = p; + lhs = nlhs; + rhs = nlhs = p; if (!(level_name[level])) { // unknown level continue; diff --git a/minidlna.c b/minidlna.c index 9e3feb8..f35519d 100644 --- a/minidlna.c +++ b/minidlna.c @@ -350,6 +350,7 @@ init(int argc, char * * argv) char buf[PATH_MAX]; char ip_addr[INET_ADDRSTRLEN + 3] = {'\0'}; char log_str[72] = "general,artwork,database,inotify,scanner,metadata,http,ssdp,tivo=warn"; + char *log_level = NULL; /* first check if "-f" option is used */ for(i=2; i= plen) + { + if (*s == *p && strncasecmp(s+1, p+1, plen-1) == 0) + return (char*)s; + s++; + slen--; + } + + return NULL; +} + char * modifyString(char * string, const char * before, const char * after, short like) { diff --git a/utils.h b/utils.h index 67790b5..fbd0a91 100644 --- a/utils.h +++ b/utils.h @@ -39,6 +39,9 @@ trim(char *str); char * strstrc(const char *s, const char *p, const char t); +char * +strcasestrc(const char *s, const char *p, const char t); + char * modifyString(char * string, const char * before, const char * after, short like);