config.h (1349B) download
1#pragma once
2
3#include <stdbool.h>
4#include <stdio.h>
5
6#define SECTION_MAX 20
7#define SECTION_MOUNT_MAX 100
8#define PATH_MAX 200
9
10typedef struct mount {
11 const char* type;
12 const char* source;
13 const char* target;
14 const char* options;
15 int flags;
16 bool try;
17} mount_t;
18
19typedef struct section {
20 const char* name;
21 const char* root;
22 const char* init;
23 mount_t mounts[SECTION_MOUNT_MAX];
24 int mount_size;
25} section_t;
26
27typedef enum parse_error {
28 P_ALLOC, // cannot allocate line
29 P_IDENTIFIER, // invalid command
30 P_USAGE, // invalid usage of command
31 P_SCOPE, // invalid scope
32 P_DATA, // parameter has invalid type
33 P_SECTION, // no section defined
34 P_REDEF, // init, master, default called more than once
35} parse_error_t;
36
37
38/**
39 * defined sections
40 */
41extern section_t sections[];
42
43/**
44 * size of defined sections
45 */
46extern int section_size;
47
48/**
49 * if colored output is wished
50 */
51extern bool color;
52
53/**
54 * if debug messages should be printed
55 */
56extern bool verbose;
57
58/**
59 * defined global mounts
60 */
61extern mount_t mounts[];
62
63/**
64 * size of defined global mounts
65 */
66extern int mount_size;
67
68/**
69 * menu timeout (TODO)
70 */
71extern int timeout;
72
73parse_error_t config_parsef(FILE* file, const char* filename);
74parse_error_t config_parse(int fd, const char* filename);
75void config_cleanup();
76void config_reset();