*
* ----------------------------------------------------------------------- */
+#include <fcntl.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <syslinux/adv.h>
#include <syslinux/config.h>
#include <dprintf.h>
+#include <core.h>
#include "menu.h"
#include "config.h"
static int parse_one_config(const char *filename)
{
+ const char *mode = "r";
FILE *f;
+ int fd;
- /*
- if (!strcmp(filename, "~"))
- filename = syslinux_config_file();
- */
-
- f = fopen(filename, "r");
- if (f)
- goto config_found;
-
- /* force to use hard coded config file name */
- f = fopen("extlinux.conf", "r");
- if (f)
- goto config_found;
-
- f = fopen("isolinux/isolinux.cfg", "r");
- if (f)
- goto config_found;
+ if (!filename)
+ fd = open_config();
+ else
+ fd = open(filename, O_RDONLY);
- f = fopen("syslinux.cfg", "r");
- if (f)
- goto config_found;
+ if (fd < 0)
+ return fd;
- return -1;
-config_found:
+ f = fdopen(fd, mode);
parse_config_file(f);
- fclose(f);
+
return 0;
}
current_menu = root_menu;
if (!argv || !*argv) {
- parse_one_config("~");
+ parse_one_config(NULL);
} else {
while ((filename = *argv++)) {
dprintf("Parsing config: %s", filename);