From d40975fe0a785bfa2e9d5889e100168ab4c88c81 Mon Sep 17 00:00:00 2001 From: MorphyKutay Date: Fri, 17 May 2024 02:04:00 +0300 Subject: [PATCH] Update main.c Yes, correct. The updated xbc_show_value function uses a recursive approach to print all the data in a boot configuration file. This function checks if a xbc_node is a value node. If it is, it prints the value to the screen. If not, it retrieves the child nodes of the current node and recursively calls the xbc_show_value function for each one. This allows all child nodes to be included in the output. This recursive approach effectively handles complex structures and nested data in a boot configuration file. --- tools/bootconfig/main.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tools/bootconfig/main.c b/tools/bootconfig/main.c index 156b62a163c5a6..8c8c98fd79ebf4 100644 --- a/tools/bootconfig/main.c +++ b/tools/bootconfig/main.c @@ -23,13 +23,22 @@ static int xbc_show_value(struct xbc_node *node, bool semicolon) int i = 0; eol = semicolon ? ";\n" : "\n"; - xbc_array_for_each_value(node, val) { - if (strchr(val, '"')) - q = '\''; - else - q = '"'; - printf("%c%s%c%s", q, val, q, xbc_node_is_array(node) ? ", " : eol); - i++; + if(xbc_node_is_value(node)){ + xbc_array_for_each_value(node, val) { + if (strchr(val, '"')) + q = '\''; + else + q = '"'; + printf("%c%s%c%s", q, val, q, xbc_node_is_array(node) ? ", " : eol); + i++; + } + }else{ + struct xbc_node *child = xbc_node_get_child(node); + while(child){ + i += xbc_show_value(child, semicolon); + child = xbc_node_get_next(child); + } + } return i; }