Fix config handling
This commit is contained in:
		
							parent
							
								
									fad3d80f39
								
							
						
					
					
						commit
						fca35ade9e
					
				
					 18 changed files with 125 additions and 139 deletions
				
			
		
							
								
								
									
										13
									
								
								include/cli.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								include/cli.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
#ifndef CORE_CLI_H
 | 
			
		||||
#define CORE_CLI_H
 | 
			
		||||
 | 
			
		||||
typedef struct cli
 | 
			
		||||
{
 | 
			
		||||
    char *config_path;
 | 
			
		||||
} cli_t;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
cli_parse(int argc, const char **argv, config_t *config);
 | 
			
		||||
 | 
			
		||||
#endif /* CORE_CLI_H */
 | 
			
		||||
| 
						 | 
				
			
			@ -6,12 +6,6 @@
 | 
			
		|||
#include <mongoose.h>
 | 
			
		||||
#include <confini.h>
 | 
			
		||||
 | 
			
		||||
typedef enum
 | 
			
		||||
{
 | 
			
		||||
    RUN_TYPE_START,
 | 
			
		||||
    RUN_TYPE_INVALID,
 | 
			
		||||
} run_type_t;
 | 
			
		||||
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
    char *file;
 | 
			
		||||
| 
						 | 
				
			
			@ -21,7 +15,6 @@ typedef struct
 | 
			
		|||
    char *group;
 | 
			
		||||
    int log_level;
 | 
			
		||||
    FILE *log_file;
 | 
			
		||||
    run_type_t run_type;
 | 
			
		||||
    uint16_t server_port;
 | 
			
		||||
    uint16_t discovery_port;
 | 
			
		||||
    uint16_t mqtt_port;
 | 
			
		||||
| 
						 | 
				
			
			@ -33,7 +26,7 @@ typedef struct
 | 
			
		|||
    struct mg_serve_http_opts http_server_opts;
 | 
			
		||||
} config_t;
 | 
			
		||||
 | 
			
		||||
extern config_t global_config;
 | 
			
		||||
extern config_t *global_config;
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
config_init();
 | 
			
		||||
| 
						 | 
				
			
			@ -42,7 +35,7 @@ void
 | 
			
		|||
config_free();
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
config_try_ini_files(config_t *config);
 | 
			
		||||
config_load_string(char **holder, const char *value);
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
config_load(IniDispatch *disp, void *config_void);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,13 +14,6 @@
 | 
			
		|||
 */
 | 
			
		||||
#define MAX_NAME_LENGTH 128
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Maximum number of dbs for the databases for the MDB_env
 | 
			
		||||
 *
 | 
			
		||||
 * Used when calling mdb_env_set_maxdbs() in database_setup()
 | 
			
		||||
 */
 | 
			
		||||
#define MDB_MAXDBS 8
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief How many milli seconds to wait until poll timeout in main loop
 | 
			
		||||
 */
 | 
			
		||||
| 
						 | 
				
			
			@ -28,4 +21,6 @@
 | 
			
		|||
 | 
			
		||||
#define PIFACE_GPIO_BASE 200
 | 
			
		||||
 | 
			
		||||
#define DEFAULT_CONFIG_PATH "emgauwa-core.ini"
 | 
			
		||||
 | 
			
		||||
#endif /* CORE_CONTANTS_H */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,14 +3,10 @@
 | 
			
		|||
 | 
			
		||||
#include <time.h>
 | 
			
		||||
#include <config.h>
 | 
			
		||||
#include <confini.h>
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
helper_connect_tcp_server(char* host, uint16_t port);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
helper_parse_cli(int argc, const char **argv, config_t *config);
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
helper_get_weekday(const struct tm *time_struct);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue