summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2014-07-29 11:05:06 +0000
committerMichael Adam <obnox@samba.org>2014-07-31 18:49:46 +0200
commit02a06ae6170666b78bfcba011d65918997e6f290 (patch)
treeb10a42083863b86f7fd605aacc0cea5d83c8f85a /lib
parent9aee4ba4786e49e7cb27b9f8428bb97622ccfb95 (diff)
downloadsamba-02a06ae6170666b78bfcba011d65918997e6f290.tar.gz
debug: Factor out debug_parse_param()
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/util/debug.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/lib/util/debug.c b/lib/util/debug.c
index 42b71c136d2..a2cb4ab45d8 100644
--- a/lib/util/debug.c
+++ b/lib/util/debug.c
@@ -336,6 +336,33 @@ static void debug_dump_status(int level)
}
}
+static bool debug_parse_param(char *param)
+{
+ char *class_name;
+ char *class_level;
+ char *saveptr;
+ int ndx;
+
+ class_name = strtok_r(param, ":", &saveptr);
+ if (class_name == NULL) {
+ return false;
+ }
+
+ class_level = strtok_r(NULL, "\0", &saveptr);
+ if (class_level == NULL) {
+ return false;
+ }
+
+ ndx = debug_lookup_classname(class_name);
+ if (ndx == -1) {
+ return false;
+ }
+
+ DEBUGLEVEL_CLASS[ndx] = atoi(class_level);
+
+ return true;
+}
+
/****************************************************************************
parse the debug levels from smbcontrol. Example debug level parameter:
printdrivers:7
@@ -366,14 +393,10 @@ static bool debug_parse_params(char **params)
/* Fill in new debug class levels */
for (; i < debug_num_classes && params[i]; i++) {
- char *class_name;
- char *class_level;
- char *saveptr;
- if ((class_name = strtok_r(params[i],":", &saveptr)) &&
- (class_level = strtok_r(NULL, "\0", &saveptr)) &&
- ((ndx = debug_lookup_classname(class_name)) != -1)) {
- DEBUGLEVEL_CLASS[ndx] = atoi(class_level);
- } else {
+ bool ok;
+
+ ok = debug_parse_param(params[i]);
+ if (!ok) {
DEBUG(0,("debug_parse_params: unrecognized debug "
"class name or format [%s]\n", params[i]));
return false;