ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/hybrid-ircservices-1/conffile.h
Revision: 1209
Committed: Thu Aug 25 19:05:49 2011 UTC (12 years, 7 months ago) by michael
Content type: text/x-chdr
File size: 4511 byte(s)
Log Message:
- run everything thru indent
  "-bli0 -di1 -npcs -nut -cdw -bls -nbbo -bap"

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