59 lines
2.1 KiB
C
59 lines
2.1 KiB
C
/* lemon_board Copyright (C) 2022 Wael Karram.
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, version 3 of the License.
|
|
*
|
|
* This program 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 Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/* Include guard. */
|
|
#ifndef CONFIG_STRUCT
|
|
#define CONFIG_STRUCT
|
|
|
|
/* Include DB types. */
|
|
#include "../backend/databases/db_type.h"
|
|
/* Include frontend types. */
|
|
#include "../frontend/frontend_type.h"
|
|
|
|
/* Define constants. */
|
|
#define CONFIG_CHECK_PASS -1
|
|
/* Sidenote: -1 was chosen such that if the checker returns any other value, then it directly corresponds to the error line number in the config file. */
|
|
#define CONFIG_CHECK_FILE_ERROR -2
|
|
/* This error corresponds to a problem finding/opening the config file. */
|
|
|
|
/* Define data structures. */
|
|
/* This struct is used to store the program's configuration. */
|
|
typedef struct Config {
|
|
/* Flag for storing DB type. */
|
|
db_type_t db_type;
|
|
/* String used to store location of DB root. */
|
|
char *db_root_path;
|
|
/* String used to store the location of program root. */
|
|
char *program_root_path;
|
|
/* For storing the enabled frontend types. */
|
|
frontend_type_t *frontend_enabled;
|
|
/* For storing the number of enabled types. */
|
|
unsigned short enabled_frontend_types;
|
|
/* For storing additional frontend parameters. */
|
|
char **frontend_params;
|
|
/* For storing the update/regeneration interval (in seconds). */
|
|
unsigned long long update_interval;
|
|
} config_t;
|
|
|
|
/* Define functions. */
|
|
/* This function reads and checks a config file. */
|
|
int check_config(char *path);
|
|
/* This function reads and parses a config file. */
|
|
config_t *read_config(char *path);
|
|
/* This function writes into a config file. */
|
|
void write_config(char *path, config_t *config);
|
|
|
|
#endif /* CONFIG_STRUCT */
|