Implement new Makefile as well as clean up source code
This commit is contained in:
103
src/config.c
103
src/config.c
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
* config.c - Configuration parsing functions
|
||||
*
|
||||
* This file is part of libglacier.
|
||||
*
|
||||
* Liblacier is free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation, either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libglacier is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with Libglacier. If
|
||||
* not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* ALL FUNCTIONS IN THIS FILE DEFINED IN: config.h */
|
||||
|
||||
/*
|
||||
* init_config
|
||||
*
|
||||
* DESCRIPTION: Initialize libconfig.
|
||||
* PARAMETERS: None.
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
init_config(void)
|
||||
{
|
||||
config_init(&cfg);
|
||||
|
||||
if (! config_read_file(&cfg, runtime_files[0])) {
|
||||
fprintf(stderr, "%s:%d - %s\n", config_error_file(&cfg),
|
||||
config_error_line(&cfg), config_error_text(&cfg));
|
||||
config_destroy(&cfg);
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (LG_VERBOSE == 1) {
|
||||
infolog("Initialized libconfig");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* die_config
|
||||
*
|
||||
* DESCRIPTION: Kill libconfig.
|
||||
* PARAMETERS: None.
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
die_config(void)
|
||||
{
|
||||
config_destroy(&cfg);
|
||||
|
||||
if (LG_VERBOSE == 1) {
|
||||
infolog("Destroyed libconfig");
|
||||
}
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* load_all_from_config
|
||||
*
|
||||
* DESCRIPTION: Loads all settings from the Glacier config file.
|
||||
* PARAMETERS: None.
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
load_all_from_config(void)
|
||||
{
|
||||
/* this is probably really ugly but it works */
|
||||
if (! config_lookup_bool(&cfg, "GLACIER_DO_INT_CHECK", &GLACIER_DO_INT_CHECK)) { return 1; }
|
||||
if (! config_lookup_bool(&cfg, "GLACIER_VERBOSE", &GLACIER_VERBOSE)) { return 1; }
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* load_all_from_profile
|
||||
*
|
||||
* DESCRIPTION: Loads all settings from the Glacier system profile.
|
||||
* PARAMETERS: None.
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
load_all_from_profile(void)
|
||||
{
|
||||
if (! config_lookup_string(&cfg, "GLACIER_REPO", &GLACIER_REPO)) { return 1; }
|
||||
if (! config_lookup_string(&cfg, "GLACIER_ARCH", &GLACIER_ARCH)) { return 1; }
|
||||
if (! config_lookup_string(&cfg, "GLACIER_TARGET", &GLACIER_TARGET)) { return 1; }
|
||||
if (! config_lookup_string(&cfg, "GLACIER_SYSTEM_PROFILE", &GLACIER_SYSTEM_PROFILE)) { return 1; }
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
27
src/config.h
Normal file
27
src/config.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* config.h - Various compile-time settings for libglacier
|
||||
*
|
||||
* This file is part of Glacier.
|
||||
*
|
||||
* Glacier is free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation, either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Glacier is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with Glacier. If
|
||||
* not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_H_
|
||||
#define CONFIG_H_
|
||||
|
||||
/* LG_VERBOSE - whether to use verbose logging for library events or not
|
||||
*
|
||||
* 0 is false, 1 is true
|
||||
*/
|
||||
#define LG_VERBOSE 0
|
||||
|
||||
#endif
|
||||
20
src/data.h
20
src/data.h
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* data.c - Data structure functions
|
||||
*
|
||||
* This file is part of libglacier.
|
||||
*
|
||||
* Liblacier is free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation, either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libglacier is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with Libglacier. If
|
||||
* not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* ALL FUNCTIONS IN THIS FILE DEFINED IN: config.h */
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <wchar.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "include/globals.h"
|
||||
|
||||
#define BUFFER_SIZE 1024
|
||||
#define MAX_CHILDREN 64
|
||||
|
||||
Reference in New Issue
Block a user