1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/*
* This file is part of blabouncer (https://www.blatech.co.uk/l_bratch/blabouncer).
* Copyright (C) 2019 Luke Bratch <luke@bratch.co.uk>.
*
* Blabouncer 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, version 3.
*
* Blabouncer 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 blabouncer. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONFIG_H_INCLUDED
#define CONFIG_H_INCLUDED
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libgen.h>
#include <sys/stat.h>
#include <limits.h>
#include "functions.h"
#define DEBUG_CRIT 0
#define DEBUG_SOME 1
#define DEBUG_FULL 2
#define ECONFINT 1 // errno value if getconfint() failed
#define MAXCHAR 1000
// Sets 'dest' to the value of the configuration option with name
// 'confname' from configuration file 'filename'.
// Returns 1 for success or 0 for error/failure as per what
// getconfstr() returns.
int getconfstr(char *confname, char *filename, char* dest);
// Populates 'dest' with the values of the configuration array option
// with name 'confname' from configuration file 'filename'.
// Returns 1 on success, 0 on reading no values, or -1 on an error.
// On error, dest[0] is set to the error string for later retrieval.
int getconfarr(char *confname, char *filename, char dest[MAXCONFARR][MAXDATASIZE]);
// Returns the value of the configuration option with name
// 'confname' from configuration file 'filename'.
// Sets errno to 0 on success, or ECONFINT if it fails, in which case the return value is undefined.
int getconfint(char *confname, char *filename);
// Create the default configuration file.
// Return 1 on success, 0 on failure.
int createconfigfile(char *filename);
#endif
|