Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/config.c
Show First 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | set_config_value_node(nvlist_t *parent, const char *name, const char *value) | ||||
else if (nvlist_exists(parent, name)) | else if (nvlist_exists(parent, name)) | ||||
errx(4, | errx(4, | ||||
"Attemping to add value %s to existing node %s of list %p", | "Attemping to add value %s to existing node %s of list %p", | ||||
value, name, parent); | value, name, parent); | ||||
nvlist_add_string(parent, name, value); | nvlist_add_string(parent, name, value); | ||||
} | } | ||||
void | void | ||||
set_config_value_node_if_unset(nvlist_t *const parent, const char *const name, | |||||
const char *const value) | |||||
{ | |||||
if (get_config_value_node(parent, name) != NULL) { | |||||
return; | |||||
} | |||||
set_config_value_node(parent, name, value); | |||||
} | |||||
void | |||||
set_config_value(const char *path, const char *value) | set_config_value(const char *path, const char *value) | ||||
{ | { | ||||
const char *name; | const char *name; | ||||
char *node_name; | char *node_name; | ||||
nvlist_t *nvl; | nvlist_t *nvl; | ||||
/* Look for last separator. */ | /* Look for last separator. */ | ||||
name = strrchr(path, '.'); | name = strrchr(path, '.'); | ||||
Show All 13 Lines | if (name == NULL) { | ||||
/* Skip over '.'. */ | /* Skip over '.'. */ | ||||
name++; | name++; | ||||
} | } | ||||
if (nvlist_exists_nvlist(nvl, name)) | if (nvlist_exists_nvlist(nvl, name)) | ||||
errx(4, "Attempting to add value %s to existing node %s", | errx(4, "Attempting to add value %s to existing node %s", | ||||
value, path); | value, path); | ||||
set_config_value_node(nvl, name, value); | set_config_value_node(nvl, name, value); | ||||
} | |||||
void | |||||
set_config_value_if_unset(const char *const path, const char *const value) | |||||
{ | |||||
if (get_config_value(path) != NULL) { | |||||
return; | |||||
} | |||||
set_config_value(path, value); | |||||
} | } | ||||
static const char * | static const char * | ||||
get_raw_config_value(const char *path) | get_raw_config_value(const char *path) | ||||
{ | { | ||||
const char *name; | const char *name; | ||||
char *node_name; | char *node_name; | ||||
nvlist_t *nvl; | nvlist_t *nvl; | ||||
▲ Show 20 Lines • Show All 256 Lines • Show Last 20 Lines |