]> jfr.im git - irc/thales.git/blame - src/conf.h
keep track of max number of servers
[irc/thales.git] / src / conf.h
CommitLineData
18038256 1/* GNU Thales - IRC to Relational Database Gateway
2ace9480 2 * Copyright (C) 2002 Lucas Nussbaum <lucas@lucas-nussbaum.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18/* Configuration file handling. */
19#ifndef _CONF_H_
20#define _CONF_H_
21
22#include "thales.h"
23#include "log.h"
24
25/* Configuration directives. */
26#define THALES_CONF "thales.conf"
27#define MAXPARAMS 4
28
29typedef struct
30{
31 char *name;
32 struct
33 {
34 int type; /* PARAM_* below */
35 int flags; /* Same */
36 void *ptr; /* Pointer to where to store the value */
37 }
38 params[MAXPARAMS];
39}
40Directive;
41
42#define PARAM_NONE 0
43#define PARAM_INT 1
44#define PARAM_POSINT 2 /* Positive integer only */
45#define PARAM_PORT 3 /* 1..65535 only */
46#define PARAM_STRING 4
47#define PARAM_TIME 5
48#define PARAM_STRING_ARRAY 6 /* Array of string */
49#define PARAM_SET -1 /* Not a real parameter; just set the
50 * * given integer variable to 1 */
51#define PARAM_DEPRECATED -2 /* Set for deprecated directives; `ptr'
52 * * is a function pointer to call */
53
54/* Flags: */
55#define PARAM_OPTIONAL 0x01
56#define PARAM_FULLONLY 0x02 /* Directive only allowed if !STREAMLINED */
57#define PARAM_RELOAD 0x04 /* Directive is reloadable */
58
59/* Print an error message to the log (and the console, if open). */
60void error(int linenum, char *message, ...);
61
62/* Parse a configuration line. Return 1 on success; otherwise, print an
63 * appropriate error message and return 0. Destroys the buffer by side
64 * effect.
65 */
66
67int parse(char *buf, int linenum, int reload);
68
69/* Read the entire configuration file. If an error occurs while reading
70 * the file or a required directive is not found, print and log an
71 * appropriate error message and return 0; otherwise, return 1.
72 *
73 * If reload is 1, will reload the configuration file.
74 * --lara
75 *
76 */
77
78int read_config(void);
79
80#endif /* _CONF_H_ */