add: config loading
This commit is contained in:
parent
3cd6668f9c
commit
25ba0ff723
22 changed files with 5799 additions and 75 deletions
22
main.c
22
main.c
|
@ -20,6 +20,9 @@
|
|||
#include <wiringPi.h>
|
||||
#include <piFace.h>
|
||||
#include <wiring_debug.h>
|
||||
#include <confini.h>
|
||||
|
||||
config_t global_config;
|
||||
|
||||
static MDB_env *mdb_env;
|
||||
static controller_t *this_controller;
|
||||
|
@ -39,6 +42,8 @@ terminate(int signum)
|
|||
|
||||
controller_free(this_controller);
|
||||
|
||||
free(global_config.relay_configs);
|
||||
|
||||
exit(signum);
|
||||
}
|
||||
|
||||
|
@ -60,6 +65,23 @@ main(int argc, char** argv)
|
|||
signal(SIGABRT, terminate);
|
||||
signal(SIGTERM, terminate);
|
||||
|
||||
/******************** LOAD CONFIG ********************/
|
||||
|
||||
char ini_file_name[] = "controller.ini";
|
||||
FILE * const ini_file = fopen(ini_file_name, "rb");
|
||||
if(ini_file == NULL)
|
||||
{
|
||||
LOG_ERROR("%s file was not found", ini_file_name);
|
||||
exit(1);
|
||||
}
|
||||
if(load_ini_file( ini_file, INI_DEFAULT_FORMAT, NULL, helper_load_config, &global_config))
|
||||
{
|
||||
LOG_ERROR("unable to parse ini file");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fclose(ini_file);
|
||||
|
||||
if(sizeof(time_t) < 8)
|
||||
{
|
||||
LOG_WARN("this system is not using 8-bit time");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue