dualinit

A meta-init system for linux
Log | Files | Refs | LICENSE

config.h (1349B)


      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 
     10 typedef 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 
     19 typedef 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 
     27 typedef 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  */
     41 extern section_t sections[];
     42 
     43 /**
     44  * size of defined sections
     45  */
     46 extern int section_size;
     47 
     48 /**
     49  * if colored output is wished
     50  */
     51 extern bool color;
     52 
     53 /**
     54  * if debug messages should be printed
     55  */
     56 extern bool verbose;
     57 
     58 /**
     59  * defined global mounts
     60  */
     61 extern mount_t mounts[];
     62 
     63 /**
     64  * size of defined global mounts
     65  */
     66 extern int mount_size;
     67 
     68 /**
     69  * menu timeout (TODO)
     70  */
     71 extern int timeout;
     72 
     73 parse_error_t config_parsef(FILE* file, const char* filename);
     74 parse_error_t config_parse(int fd, const char* filename);
     75 void		  config_cleanup();
     76 void		  config_reset();