ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/vendor/ircservices-5.1.24/conffile.h
Revision: 3389
Committed: Fri Apr 25 14:12:15 2014 UTC (9 years, 10 months ago) by michael
Content type: text/x-chdr
File size: 4476 byte(s)
Log Message:
- Imported ircservices-5.1.24

File Contents

# Content
1 /* Structures, constants, and external declarations for configuration file
2 * handling.
3 *
4 * IRC Services is copyright (c) 1996-2009 Andrew Church.
5 * E-mail: <achurch@achurch.org>
6 * Parts written by Andrew Kempe and others.
7 * This program is free but copyrighted software; see the file GPL.txt for
8 * details.
9 */
10
11 #ifndef CONFFILE_H
12 #define CONFFILE_H
13
14 /*************************************************************************/
15
16 /* Configuration directives. Note that all numeric parameter types except
17 * CD_TIME and CD_SET take an int32 value pointer (including CD_TIMEMSEC).
18 */
19
20 /* Information about a configuration parameter's value: */
21 typedef union {
22 void *ptrval;
23 int32 intval;
24 time_t timeval;
25 } CDValue;
26
27 /* Information about a configuration directive: */
28 typedef struct {
29 const char *name;
30 struct {
31 int type; /* Parameter type (CD_* below) */
32 int flags; /* Parameter flags (CF_* below) */
33 void *ptr; /* Pointer to where to store the value */
34 /* The following data is internal-use-only: */
35 CDValue prev; /* Previous value (to restore when deconfigured) */
36 CDValue new; /* New value (to set if conf-file successfully read) */
37 } params[CONFIG_MAXPARAMS];
38 /* Also internal use only: */
39 int was_seen; /* Non-zero if directive was seen this time around */
40 } ConfigDirective;
41
42 #define CD_NONE 0
43 #define CD_INT 1
44 #define CD_POSINT 2 /* Positive integer only */
45 #define CD_PORT 3 /* 1..65535 only */
46 #define CD_STRING 4
47 #define CD_TIME 5 /* Type of `ptr' is `time_t *' */
48 #define CD_TIMEMSEC 6 /* Variable is in milliseconds, parameter
49 * in seconds (decimal allowed) */
50 #define CD_FUNC 7 /* `ptr' is a function to call; see
51 * init.c for examples */
52 #define CD_SET -1 /* Not a real parameter; just set the
53 * given `int' variable to 1 */
54 #define CD_DEPRECATED -2 /* Set for deprecated directives; causes
55 * a warning to be printed */
56
57 /* Flags: */
58 #define CF_OPTIONAL 0x01 /* Parameter is optional (defaults to 0) */
59 #define CF_DIRREQ 0x02 /* Directive is required (set on first param)*/
60 /* Internal-use-only flags: */
61 #define CF_SAVED 0x80 /* Original value saved in `prev' */
62 #define CF_WASSET 0x40 /* Parameter set this time around */
63 #define CF_ALLOCED 0x20 /* Current value is alloc'd by parser */
64 #define CF_ALLOCED_NEW 0x10 /* Value of `new' is alloc'd by parser */
65
66 /* Values for `action' parameter to configure() (can be or'ed together): */
67 #define CONFIGURE_READ 1 /* Read settings from configuration file */
68 #define CONFIGURE_SET 2 /* Set configuration variables to new values */
69
70 /* Values passed in `linenum' parameter to configuration directive handlers
71 * (CD_FUNC parameters) when `filename' is NULL: */
72 #define CDFUNC_INIT 0 /* Prepare for reading data */
73 #define CDFUNC_SET 1 /* Copy new data to real config variables */
74 #define CDFUNC_DECONFIG 2 /* Delete any data in config variables */
75
76 /*************************************************************************/
77
78 /* Global functions: */
79
80 /* Set configuration options for the given module (if `modulename' is NULL,
81 * set core configuration options). Returns nonzero on success, 0 on error
82 * (an error message is logged, and printed to the terminal if applicable,
83 * in this case). Returns successfully without doing anything if
84 * `directives' is NULL. */
85 extern int configure(const char *modulename, ConfigDirective *directives,
86 int action);
87
88 /* Deconfigure given directive array (free any allocated storage and
89 * restore original values). A no-op if `directives' is NULL. */
90 extern void deconfigure(ConfigDirective *directives);
91
92 /* Print a warning or error message to the log (and the console, if open). */
93 extern void config_error(const char *filename, int linenum,
94 const char *message,...);
95
96 /*************************************************************************/
97
98 #endif /* CONFFILE_H */
99
100 /*
101 * Local variables:
102 * c-file-style: "stroustrup"
103 * c-file-offsets: ((case-label . *) (statement-case-intro . *))
104 * indent-tabs-mode: nil
105 * End:
106 *
107 * vim: expandtab shiftwidth=4:
108 */