forked from kexecboot/kexecboot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cfgparser.h
74 lines (60 loc) · 2.39 KB
/
cfgparser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* kexecboot - A kexec based bootloader
*
* Copyright (c) 2009-2011 Yuri Bushmelev <[email protected]>
* Copyright (c) 2009 Omegamoon <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef _HAVE_CONFIGPARSER_H
#define _HAVE_CONFIGPARSER_H
#include "config.h"
#include "util.h"
#define MOUNTPOINT "/mnt"
#define BOOTCFG_PATH MOUNTPOINT "/boot/boot.cfg"
enum ui_type_t { GUI, TEXTUI };
typedef struct {
char *label; /* Partition label (name) */
char *kernelpath; /* Found kernel (/boot/zImage) */
char *cmdline; /* Kernel cmdline (logo.nologo debug) */
char *initrd; /* Initial ramdisk file */
char *iconpath; /* Custom partition icon path */
void *icondata; /* Icon data */
int is_default; /* Use section as default? */
int priority; /* Priority of item in menu */
} kx_cfg_section;
/* Config file data structure */
struct cfgdata_t {
int timeout; /* Seconds before default item autobooting (0 - disabled) */
enum ui_type_t ui; /* UI (graphics/text) */
int debug; /* Use debugging */
unsigned int size; /* Size of sections array allocated */
unsigned int count; /* Sections count */
kx_cfg_section **list; /* List of sections */
kx_cfg_section *current; /* Latest allocated section */
/* cmdline parameters */
int angle; /* FB angle */
char *fbcon; /* fbcon tag */
char *mtdparts; /* MTD partitioning */
char *ttydev; /* Console tty device name */
};
/* Clean config file structure */
void init_cfgdata(struct cfgdata_t *cfgdata);
/* Free config file sections */
void destroy_cfgdata(struct cfgdata_t *cfgdata);
/* Set kernelpath only (may be used when no config file found) */
int cfgdata_add_kernel(struct cfgdata_t *cfgdata, char *kernelpath);
/* Parse config file into specified structure */
/* NOTE: It will not clean cfgdata before parsing, do it yourself */
int parse_cfgfile(char *cfgpath, struct cfgdata_t *cfgdata);
int parse_cmdline(struct cfgdata_t *cfgdata);
#endif /* _HAVE_CONFIGPARSER_H */