]> git.ipfire.org Git - thirdparty/ulogd2.git/commitdiff
conf: add flag to allow option setup tuning
authorEric Leblond <eric@regit.org>
Fri, 18 Jan 2013 18:41:19 +0000 (19:41 +0100)
committerEric Leblond <eric@regit.org>
Fri, 18 Jan 2013 18:41:19 +0000 (19:41 +0100)
This patch adds a flag to the config_entry structure to be able to
tune setup. First usage is to ask config parser not to update a key
if it has been already set.

include/ulogd/conffile.h
src/conffile.c

index 7431243a1178c3c282cb9372519495cab09396d3..aa35809d773c149bd431814674435d417afcbc3a 100644 (file)
@@ -41,11 +41,15 @@ enum {
 #define CONFIG_OPT_MANDATORY   0x0001
 #define CONFIG_OPT_MULTI       0x0002
 
+/* valid flag part */
+#define CONFIG_FLAG_VAL_PROTECTED      (1<<0)
+
 struct config_entry {
        char key[CONFIG_KEY_LEN];       /* name of config directive */
        u_int8_t type;                  /* type; see above */
        u_int8_t options;               /* options; see above  */
        u_int8_t hit;                   /* found? */
+       u_int8_t flag;                  /* tune setup of option */
        union {
                char string[CONFIG_VAL_STRING_LEN];
                int value;
index b27187ecc1f7d4d9e771d234bafd2b1c61e9ef86..8dbd72691eb92dd53f1f71b8fcb9edf6cf1b4a20 100644 (file)
@@ -167,7 +167,8 @@ int config_parse_file(const char *section, struct config_keyset *kset)
                for (i = 0; i < kset->num_ces; i++) {
                        struct config_entry *ce = &kset->ces[i];
                        pr_debug("parse main loop, key: %s\n", ce->key);
-                       if (strcmp(ce->key, (char *) &wordbuf)) {
+                       if ((strcmp(ce->key, (char *) &wordbuf)) ||
+                            ce->flag & CONFIG_FLAG_VAL_PROTECTED) {
                                continue;
                        }