(core_option_manager.c) Some simplifications
This commit is contained in:
parent
a510fb5d20
commit
90e0d0bb70
|
@ -27,9 +27,6 @@
|
||||||
#include "core_option_manager.h"
|
#include "core_option_manager.h"
|
||||||
#include "msg_hash.h"
|
#include "msg_hash.h"
|
||||||
|
|
||||||
#define CORE_OPTION_MANAGER_MAP_TAG "#"
|
|
||||||
#define CORE_OPTION_MANAGER_MAP_DELIM ":"
|
|
||||||
|
|
||||||
/*********************/
|
/*********************/
|
||||||
/* Option Conversion */
|
/* Option Conversion */
|
||||||
/*********************/
|
/*********************/
|
||||||
|
@ -861,7 +858,8 @@ core_option_manager_t *core_option_manager_new_vars(
|
||||||
* the map */
|
* the map */
|
||||||
char address[256];
|
char address[256];
|
||||||
|
|
||||||
address[0] = '\0';
|
address[0] = '#';
|
||||||
|
address[1] = '\0';
|
||||||
|
|
||||||
/* Address string is normally:
|
/* Address string is normally:
|
||||||
* <category_key><delim><tag><option_key>
|
* <category_key><delim><tag><option_key>
|
||||||
|
@ -871,8 +869,7 @@ core_option_manager_t *core_option_manager_new_vars(
|
||||||
* so we could just set the address to
|
* so we could just set the address to
|
||||||
* <option_key> - but for consistency with
|
* <option_key> - but for consistency with
|
||||||
* 'modern' options, we apply the tag regardless */
|
* 'modern' options, we apply the tag regardless */
|
||||||
snprintf(address, sizeof(address),
|
strlcat(address, var->key, sizeof(address));
|
||||||
CORE_OPTION_MANAGER_MAP_TAG "%s", var->key);
|
|
||||||
|
|
||||||
if (!nested_list_add_item(opt->option_map,
|
if (!nested_list_add_item(opt->option_map,
|
||||||
address, NULL, (const void*)&opt->opts[size]))
|
address, NULL, (const void*)&opt->opts[size]))
|
||||||
|
@ -933,7 +930,7 @@ static bool core_option_manager_parse_option(
|
||||||
* character */
|
* character */
|
||||||
if (opt->cats &&
|
if (opt->cats &&
|
||||||
!string_is_empty(category_key) &&
|
!string_is_empty(category_key) &&
|
||||||
!strstr(category_key, CORE_OPTION_MANAGER_MAP_DELIM))
|
!strstr(category_key, ":"))
|
||||||
{
|
{
|
||||||
for (i = 0; i < opt->cats_size; i++)
|
for (i = 0; i < opt->cats_size; i++)
|
||||||
{
|
{
|
||||||
|
@ -964,7 +961,7 @@ static bool core_option_manager_parse_option(
|
||||||
/* If option has a category, option key
|
/* If option has a category, option key
|
||||||
* cannot contain a map delimiter character */
|
* cannot contain a map delimiter character */
|
||||||
if (!string_is_empty(option->category_key) &&
|
if (!string_is_empty(option->category_key) &&
|
||||||
strstr(key, CORE_OPTION_MANAGER_MAP_DELIM))
|
strstr(key, ":"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
option->key = strdup(key);
|
option->key = strdup(key);
|
||||||
|
@ -1193,7 +1190,6 @@ core_option_manager_t *core_option_manager_new(
|
||||||
const char *category_key = opt->opts[size].category_key;
|
const char *category_key = opt->opts[size].category_key;
|
||||||
char address[256];
|
char address[256];
|
||||||
|
|
||||||
address[0] = '\0';
|
|
||||||
|
|
||||||
/* Address string is nominally:
|
/* Address string is nominally:
|
||||||
* <category_key><delim><tag><option_key>
|
* <category_key><delim><tag><option_key>
|
||||||
|
@ -1201,15 +1197,21 @@ core_option_manager_t *core_option_manager_new(
|
||||||
* key in order to avoid category/option key
|
* key in order to avoid category/option key
|
||||||
* collisions */
|
* collisions */
|
||||||
if (string_is_empty(category_key))
|
if (string_is_empty(category_key))
|
||||||
snprintf(address, sizeof(address),
|
{
|
||||||
CORE_OPTION_MANAGER_MAP_TAG "%s", option_def->key);
|
address[0] = '#';
|
||||||
|
address[1] = '\0';
|
||||||
|
strlcat(address, option_def->key, sizeof(address));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
address[0] = '\0';
|
||||||
snprintf(address, sizeof(address),
|
snprintf(address, sizeof(address),
|
||||||
"%s" CORE_OPTION_MANAGER_MAP_DELIM CORE_OPTION_MANAGER_MAP_TAG "%s",
|
"%s#%s",
|
||||||
category_key, option_def->key);
|
category_key, option_def->key);
|
||||||
|
}
|
||||||
|
|
||||||
if (!nested_list_add_item(opt->option_map,
|
if (!nested_list_add_item(opt->option_map,
|
||||||
address, CORE_OPTION_MANAGER_MAP_DELIM,
|
address, ":",
|
||||||
(const void*)&opt->opts[size]))
|
(const void*)&opt->opts[size]))
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue