diff options
author | Volker Lendecke <vl@samba.org> | 2014-07-29 20:01:31 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2014-07-31 18:49:47 +0200 |
commit | e249e794ecff42acfea264ecdd01af5bb661b503 (patch) | |
tree | 93696b86fce4d79e4d55e825c8ba7c213cfb2469 /lib/util/debug.c | |
parent | 0e448f8d358b067319143ab64103bd5870adce42 (diff) | |
download | samba-e249e794ecff42acfea264ecdd01af5bb661b503.tar.gz |
debug: Avoid dependency on str_list_make
strtok_r just also does the job and is available in libc
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'lib/util/debug.c')
-rw-r--r-- | lib/util/debug.c | 70 |
1 files changed, 29 insertions, 41 deletions
diff --git a/lib/util/debug.c b/lib/util/debug.c index 9c1b76a5297..33cbed2e773 100644 --- a/lib/util/debug.c +++ b/lib/util/debug.c @@ -362,71 +362,59 @@ static bool debug_parse_param(char *param) } /**************************************************************************** - parse the debug levels from smbcontrol. Example debug level parameter: - printdrivers:7 + Parse the debug levels from smb.conf. Example debug level string: + 3 tdb:5 printdrivers:7 + Note: the 1st param has no "name:" preceeding it. ****************************************************************************/ -static bool debug_parse_params(char **params) +bool debug_parse_levels(const char *params_str) { - int i, ndx; + size_t str_len = strlen(params_str); + char str[str_len+1]; + char *tok, *saveptr; + int i; - if (!params) - return false; + /* Just in case */ + debug_init(); + + memcpy(str, params_str, str_len+1); + + tok = strtok_r(str, LIST_SEP, &saveptr); + if (tok == NULL) { + return true; + } /* Allow DBGC_ALL to be specified w/o requiring its class name e.g."10" * v.s. "all:10", this is the traditional way to set DEBUGLEVEL */ - if (isdigit((int)params[0][0])) { - DEBUGLEVEL_CLASS[DBGC_ALL] = atoi(params[0]); - i = 1; /* start processing at the next params */ + if (isdigit(tok[0])) { + DEBUGLEVEL_CLASS[DBGC_ALL] = atoi(tok); + tok = strtok_r(NULL, LIST_SEP, &saveptr); } else { DEBUGLEVEL_CLASS[DBGC_ALL] = 0; - i = 0; /* DBGC_ALL not specified OR class name was included */ } /* Array is debug_num_classes long */ - for (ndx = DBGC_ALL; ndx < debug_num_classes; ndx++) { - DEBUGLEVEL_CLASS[ndx] = DEBUGLEVEL_CLASS[DBGC_ALL]; + for (i = DBGC_ALL+1; i < debug_num_classes; i++) { + DEBUGLEVEL_CLASS[i] = DEBUGLEVEL_CLASS[DBGC_ALL]; } - /* Fill in new debug class levels */ - for (; params[i]; i++) { + while (tok != NULL) { bool ok; - ok = debug_parse_param(params[i]); + ok = debug_parse_param(tok); if (!ok) { DEBUG(0,("debug_parse_params: unrecognized debug " - "class name or format [%s]\n", params[i])); + "class name or format [%s]\n", tok)); return false; } - } - - return true; -} -/**************************************************************************** - Parse the debug levels from smb.conf. Example debug level string: - 3 tdb:5 printdrivers:7 - Note: the 1st param has no "name:" preceeding it. -****************************************************************************/ - -bool debug_parse_levels(const char *params_str) -{ - char **params; - bool ok; - - /* Just in case */ - debug_init(); - - params = str_list_make(NULL, params_str, NULL); - - ok = debug_parse_params(params); - if (ok) { - debug_dump_status(5); + tok = strtok_r(NULL, LIST_SEP, &saveptr); } - TALLOC_FREE(params); - return ok; + debug_dump_status(5); + + return true; } /* setup for logging of talloc warnings */ |