config: Only make keys global if before first entry

This commit is contained in:
mintsuki 2022-08-14 14:45:20 +02:00
parent 73f958e92e
commit 11b56c39f0
2 changed files with 13 additions and 5 deletions

View File

@ -8,7 +8,8 @@
#include <lib/print.h> #include <lib/print.h>
#include <pxe/tftp.h> #include <pxe/tftp.h>
#include <sys/cpu.h> static bool config_get_entry_name(char *ret, size_t index, size_t limit);
static char *config_get_entry(size_t *size, size_t index);
#define SEPARATOR '\n' #define SEPARATOR '\n'
@ -285,10 +286,19 @@ overflow:
menu_tree = create_menu_tree(NULL, 1, 0); menu_tree = create_menu_tree(NULL, 1, 0);
size_t s;
char *c = config_get_entry(&s, 0);
while (*c != ':') {
c--;
}
if (c > config_addr) {
c[-1] = 0;
}
return 0; return 0;
} }
bool config_get_entry_name(char *ret, size_t index, size_t limit) { static bool config_get_entry_name(char *ret, size_t index, size_t limit) {
if (!config_ready) if (!config_ready)
return false; return false;
@ -318,7 +328,7 @@ bool config_get_entry_name(char *ret, size_t index, size_t limit) {
return true; return true;
} }
char *config_get_entry(size_t *size, size_t index) { static char *config_get_entry(size_t *size, size_t index) {
if (!config_ready) if (!config_ready)
return NULL; return NULL;

View File

@ -29,8 +29,6 @@ int init_config_disk(struct volume *part);
int init_config_pxe(void); int init_config_pxe(void);
int init_config(size_t config_size); int init_config(size_t config_size);
bool config_get_entry_name(char *ret, size_t index, size_t limit);
char *config_get_entry(size_t *size, size_t index);
char *config_get_value(const char *config, size_t index, const char *key); char *config_get_value(const char *config, size_t index, const char *key);
struct conf_tuple config_get_tuple(const char *config, size_t index, struct conf_tuple config_get_tuple(const char *config, size_t index,
const char *key1, const char *key2); const char *key1, const char *key2);