Add externs to avoid multiple definitions, and then add missing definitions.
[rrq/maintain_lilo.git] / src / cfg.h
1 /* cfg.h  -  Configuration file parser
2  * 
3  * Copyright 1992-1998 Werner Almesberger
4  * Copyright 1999-2007 John Coffman
5  * Copyright 2009-2011 Joachim Wiedorn
6  * All rights reserved.
7  * 
8  * Licensed under the terms contained in the file 'COPYING'
9  * in the source directory.
10  */
11
12 #ifndef CFG_H
13 #define CFG_H
14
15 typedef enum { cft_strg,cft_flag,cft_link,cft_end } CONFIG_TYPE;
16
17 typedef struct {
18     CONFIG_TYPE type;
19     char *name;
20     void *action;
21     void *data;
22     void *context;
23 } CONFIG;
24
25 #define RAID_EXTRA_BOOT "raid-extra-boot"
26
27 extern CONFIG cf_top[],cf_identify[],cf_options[],cf_all[],cf_kernel[],
28   cf_image[],cf_other[],cf_disk[],cf_partitions[],cf_partition[],
29   cf_map_drive[],cf_change_rules[],cf_change_rule[],cf_change[],
30   cf_change_dsc[],cf_bitmap[];
31
32 extern FILE *pw_file;
33
34
35 int cfg_open(char *name);
36
37 /* Opens the configuration file. Returns the file descriptor of the open
38    file. */
39
40 void cfg_error(char *msg,...) __attribute__ ((format (printf, 1, 2)));
41
42 /* Signals an error while parsing the configuration file and terminates the
43    program. */
44
45 void cfg_init(CONFIG *table);
46
47 /* Initializes the specified table. */
48
49 void cfg_set(CONFIG *table,char *item,char *value,void *context);
50
51 /* Sets the specified variable in table. If the variable has already been set
52    since the last call to cfg_init, a warning message is issued if the context
53    keys don't match or a fatal error is reported if they do. */
54
55 void cfg_unset(CONFIG *table,char *item);
56
57 /* Unsets the specified variable in table. It is a fatal error if the variable
58    was not set. */
59
60 int cfg_parse(CONFIG *table);
61
62 /* Parses the configuration file for variables contained in table. A non-zero
63    value is returned if a variable not found in table has been met. Zero is
64    returned if EOF has been reached. */
65
66 int cfg_get_flag(CONFIG *table,char *item);
67
68 /* Returns one if the specified variable is set, zero if it isn't. */
69
70 char *cfg_get_strg(CONFIG *table,char *item);
71
72 /* Returns the value of the specified variable if it is set, NULL otherwise. */
73
74
75 FILE *cfg_pw_open(void);
76 /* open the password file, creating a new file if  passw  is set. */
77
78 void cfg_bitmap_only(void);
79 /* allow only the "bitmap" keywords */
80
81 #if BETA_TEST
82 void cfg_alpha_check(void);
83 /* check for tables in alphabetical order */
84 #endif
85
86
87 #endif