-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2023 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
Mangle(parent->val);
}
}
- ConfNode *existing = ConfNodeLookupChild(parent, value);
- if (existing != NULL) {
- if (!existing->final) {
- SCLogInfo("Configuration node '%s' redefined.",
- existing->name);
- ConfNodePrune(existing);
- }
- node = existing;
- }
- else {
- node = ConfNodeNew();
- node->name = SCStrdup(value);
- if (node->name && strchr(node->name, '_')) {
- if (!(parent->name &&
- ((strcmp(parent->name, "address-groups") == 0) ||
- (strcmp(parent->name, "port-groups") == 0)))) {
- Mangle(node->name);
- if (mangle_errors < MANGLE_ERRORS_MAX) {
- SCLogWarning("%s is deprecated. Please use %s on line %" PRIuMAX
- ".",
- value, node->name, (uintmax_t)parser->mark.line + 1);
- mangle_errors++;
- if (mangle_errors >= MANGLE_ERRORS_MAX)
- SCLogWarning("not showing more "
- "parameter name warnings.");
+
+ if (strchr(value, '.') != NULL) {
+ node = ConfNodeGetNodeOrCreate(parent, value, 0);
+ } else {
+ ConfNode *existing = ConfNodeLookupChild(parent, value);
+ if (existing != NULL) {
+ if (!existing->final) {
+ SCLogInfo("Configuration node '%s' redefined.", existing->name);
+ ConfNodePrune(existing);
+ }
+ node = existing;
+ } else {
+ node = ConfNodeNew();
+ node->name = SCStrdup(value);
+ if (node->name && strchr(node->name, '_')) {
+ if (!(parent->name &&
+ ((strcmp(parent->name, "address-groups") == 0) ||
+ (strcmp(parent->name, "port-groups") == 0)))) {
+ Mangle(node->name);
+ if (mangle_errors < MANGLE_ERRORS_MAX) {
+ SCLogWarning(
+ "%s is deprecated. Please use %s on line %" PRIuMAX
+ ".",
+ value, node->name,
+ (uintmax_t)parser->mark.line + 1);
+ mangle_errors++;
+ if (mangle_errors >= MANGLE_ERRORS_MAX)
+ SCLogWarning("not showing more "
+ "parameter name warnings.");
+ }
}
}
+ TAILQ_INSERT_TAIL(&parent->head, node, next);
}
- TAILQ_INSERT_TAIL(&parent->head, node, next);
}
state = CONF_VAL;
}
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2023 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
* This function exits on memory failure as creating configuration
* nodes is usually part of application initialization.
*
+ * \param parent The node to use as the parent
* \param name The name of the configuration node to get.
* \param final Flag to set created nodes as final or not.
*
* \retval The existing configuration node if it exists, or a newly
* created node for the provided name. On error, NULL will be returned.
*/
-static ConfNode *ConfGetNodeOrCreate(const char *name, int final)
+ConfNode *ConfNodeGetNodeOrCreate(ConfNode *parent, const char *name, int final)
{
- ConfNode *parent = root;
ConfNode *node = NULL;
char node_name[NODE_NAME_MAX];
char *key;
return node;
}
+/**
+ * \brief Wrapper function for ConfNodeGetNodeOrCreate that operates
+ * on the current root node.
+ */
+static ConfNode *ConfGetNodeOrCreate(const char *name, int final)
+{
+ return ConfNodeGetNodeOrCreate(root, name, final);
+}
+
/**
* \brief Initialize the configuration system.
*/
-/* Copyright (C) 2007-2010 Open Information Security Foundation
+/* Copyright (C) 2007-2023 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
ConfNode *ConfSetIfaceNode(const char *ifaces_node_name, const char *iface);
int ConfSetRootAndDefaultNodes(
const char *ifaces_node_name, const char *iface, ConfNode **if_root, ConfNode **if_default);
-
+ConfNode *ConfNodeGetNodeOrCreate(ConfNode *parent, const char *name, int final);
#endif /* ! __CONF_H__ */