]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
conf: add function to get child with default
authorEric Leblond <eric@regit.org>
Sat, 6 Jan 2018 09:01:55 +0000 (10:01 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 12 Jan 2018 15:47:22 +0000 (16:47 +0100)
src/conf.c
src/conf.h

index 5ea30fc603ccb075b720638b18f3ce10d819c849..4d7ad84be5d125ce157bf362af71aff13ec9e3fb 100644 (file)
@@ -399,6 +399,19 @@ int ConfGetChildValue(const ConfNode *base, const char *name, const char **vptr)
     }
 }
 
+ConfNode *ConfGetChildWithDefault(const ConfNode *base, const ConfNode *dflt,
+    const char *name)
+{
+    ConfNode *node = ConfNodeLookupChild(base, name);
+    if (node != NULL)
+        return node;
+
+    /* Get 'default' value */
+    if (dflt) {
+        return ConfNodeLookupChild(dflt, name);
+    }
+    return NULL;
+}
 
 int ConfGetChildValueWithDefault(const ConfNode *base, const ConfNode *dflt,
     const char *name, const char **vptr)
index 171cc83db5a5aba0c7209e9ee1595df7f61a1834..e44a45d5ce2e09edc662c7dd77ed7c174f5c441b 100644 (file)
@@ -82,6 +82,7 @@ int ConfValIsFalse(const char *val);
 void ConfNodePrune(ConfNode *node);
 int ConfRemove(const char *name);
 
+ConfNode *ConfGetChildWithDefault(const ConfNode *base, const ConfNode *dflt, const char *name);
 ConfNode *ConfNodeLookupKeyValue(const ConfNode *base, const char *key, const char *value);
 int ConfGetChildValue(const ConfNode *base, const char *name, const char **vptr);
 int ConfGetChildValueInt(const ConfNode *base, const char *name, intmax_t *val);