diff options
author | Deepak S <deepak.s@linux.intel.com> | 2018-02-22 14:48:27 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2018-02-22 14:48:27 +0000 |
commit | 83199af0ffc12fcb0961debbbc8e83957d2d115b (patch) | |
tree | ad90b7f2f96ce900963bdbb980bb1834f0d907b8 | |
parent | 2c437c3c5c75d78a0adb4f2ebfa454943b8063ad (diff) | |
parent | e739edca4824d29614204d0f511afe5477dabbf7 (diff) |
Merge "Add support for comments in configuration variables"
-rw-r--r-- | VNFs/DPPD-PROX/cfgfile.c | 18 | ||||
-rw-r--r-- | VNFs/DPPD-PROX/parse_utils.c | 4 | ||||
-rw-r--r-- | VNFs/DPPD-PROX/parse_utils.h | 2 |
3 files changed, 15 insertions, 9 deletions
diff --git a/VNFs/DPPD-PROX/cfgfile.c b/VNFs/DPPD-PROX/cfgfile.c index 80a90937..0c5950e4 100644 --- a/VNFs/DPPD-PROX/cfgfile.c +++ b/VNFs/DPPD-PROX/cfgfile.c @@ -188,13 +188,17 @@ static struct cfg_section *cfg_check_section(char *buffer, struct cfg_section *p if (*pend == '\0') { return NULL; } - /* only numeric characters are valid for section index - (currently, variables not checked!) */ - if (pend[0] != '$') { - for (len = 0; pend[len] != '\0'; ++len) { - if (strchr(valid, pend[len]) == NULL) { - return NULL; - } + + /* only numeric characters are valid for section index */ + char val[MAX_CFG_STRING_LEN]; + if (pend[0] == '$') + parse_single_var(val, sizeof(val), pend); + else + strncpy(val, pend, sizeof(val)); + + for (len = 0; val[len] != '\0'; ++len) { + if (strchr(valid, val[len]) == NULL) { + return NULL; } } diff --git a/VNFs/DPPD-PROX/parse_utils.c b/VNFs/DPPD-PROX/parse_utils.c index d258c591..52337ffb 100644 --- a/VNFs/DPPD-PROX/parse_utils.c +++ b/VNFs/DPPD-PROX/parse_utils.c @@ -106,7 +106,7 @@ static struct var *var_lookup(const char *name) return NULL; } -static int parse_single_var(char *val, size_t len, const char *name) +int parse_single_var(char *val, size_t len, const char *name) { struct var *match; @@ -135,7 +135,7 @@ int parse_vars(char *val, size_t len, const char *name) { static char result[MAX_CFG_STRING_LEN]; static char cur_var[MAX_CFG_STRING_LEN]; - char parsed[2048]; + char parsed[MAX_CFG_STRING_LEN]; size_t name_len = strlen(name); enum parse_vars_state {NO_VAR, WHOLE_VAR, INLINE_VAR} state = NO_VAR; size_t result_len = 0; diff --git a/VNFs/DPPD-PROX/parse_utils.h b/VNFs/DPPD-PROX/parse_utils.h index 14aee9eb..27ebb0bd 100644 --- a/VNFs/DPPD-PROX/parse_utils.h +++ b/VNFs/DPPD-PROX/parse_utils.h @@ -118,4 +118,6 @@ const char* get_parse_err(void); /* Returns true if running from a virtual machine. */ int is_virtualized(void); +int parse_single_var(char *val, size_t len, const char *name); + #endif /* _PARSE_UTILS_H_ */ |