Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/config.c
| Show First 20 Lines • Show All 428 Lines • ▼ Show 20 Lines | ||||||||||
| void | void | |||||||||
| set_config_bool_node(nvlist_t *parent, const char *name, bool value) | set_config_bool_node(nvlist_t *parent, const char *name, bool value) | |||||||||
| { | { | |||||||||
| set_config_value_node(parent, name, value ? "true" : "false"); | set_config_value_node(parent, name, value ? "true" : "false"); | |||||||||
| } | } | |||||||||
| static void | void | |||||||||
| dump_tree(const char *prefix, const nvlist_t *nvl) | walk_config_nodes(const char *prefix, const nvlist_t *parent, void *arg, | |||||||||
| void (*cb)(const char *p, const char *n, const char *v, void *a)) | ||||||||||
corvink: Same here, I prefer adding names to the parameter but feel free to ignore my comment. | ||||||||||
| { | { | |||||||||
| void *cookie = NULL; | ||||||||||
| const char *name; | const char *name; | |||||||||
| void *cookie; | ||||||||||
| int type; | int type; | |||||||||
| cookie = NULL; | while ((name = nvlist_next(parent, &type, &cookie)) != NULL) { | |||||||||
| while ((name = nvlist_next(nvl, &type, &cookie)) != NULL) { | ||||||||||
| if (type == NV_TYPE_NVLIST) { | if (type == NV_TYPE_NVLIST) { | |||||||||
| char *new_prefix; | char *new_prefix; | |||||||||
| asprintf(&new_prefix, "%s%s.", prefix, name); | asprintf(&new_prefix, "%s%s.", prefix, name); | |||||||||
| dump_tree(new_prefix, nvlist_get_nvlist(nvl, name)); | walk_config_nodes(new_prefix, | |||||||||
| nvlist_get_nvlist(parent, name), arg, cb); | ||||||||||
| free(new_prefix); | free(new_prefix); | |||||||||
| } else { | } else { | |||||||||
| assert(type == NV_TYPE_STRING); | assert(type == NV_TYPE_STRING); | |||||||||
| printf("%s%s=%s\n", prefix, name, | cb(prefix, name, nvlist_get_string(parent, name), arg); | |||||||||
| nvlist_get_string(nvl, name)); | ||||||||||
| } | } | |||||||||
| } | } | |||||||||
| } | } | |||||||||
| static void | ||||||||||
| dump_node_cb(const char *prefix, const char *name, const char *value, | ||||||||||
| void *arg __unused) | ||||||||||
| { | ||||||||||
| printf("%s%s=%s\n", prefix, name, value); | ||||||||||
| } | ||||||||||
| void | void | |||||||||
| dump_config(void) | dump_config(void) | |||||||||
| { | { | |||||||||
| dump_tree("", config_root); | walk_config_nodes("", config_root, NULL, dump_node_cb); | |||||||||
Done Inline Actions
markj: | ||||||||||
| } | } | |||||||||
Same here, I prefer adding names to the parameter but feel free to ignore my comment.