ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/include/confparse.h
Revision: 1.5
Committed: Sun Sep 9 20:05:51 2007 UTC (19 years ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.4: +12 -6 lines
Log Message:
- changed configurations to the c++ stdlib
- more #defines to enum
- removed getopt.h and link.h from the system as they were unused
- reworked logstreams
- added an itoa with old syntax
- made klines objects
- moved some global variables into appropriate classes
- fixed boost.foreach's compiler workaround #if's
- allow other files to add exceptions with ADD_EXCEPTION
- changed mynick_t to c++ object
- moved servers.h out of atheme.h
- corrected PING from inspircd 1.2

File Contents

# User Rev Content
1 pippijn 1.1 /*
2 pippijn 1.3 * Copyright © 2005 William Pitcock, et al.
3 pippijn 1.2 * Rights to this code are as documented in doc/pod/license.pod.
4 pippijn 1.1 *
5     * Data structures for flags to bitmask processing routines.
6     *
7 pippijn 1.5 * $Id: confparse.h,v 1.4 2007-08-28 22:18:30 pippijn Exp $
8 pippijn 1.1 */
9    
10     #ifndef CONFPARSE_H
11     #define CONFPARSE_H
12    
13 pippijn 1.5 #include <common/util.h>
14 pippijn 1.3 #include <ermyth/callback.h>
15 pippijn 1.4 #include <ermyth/type_traits.h>
16 pippijn 1.3
17     struct config_file_t : zero_initialised
18 pippijn 1.1 {
19     char *cf_filename;
20     config_entry_t *cf_entries;
21     config_file_t *cf_next;
22     };
23    
24 pippijn 1.3 struct config_entry_t : zero_initialised
25 pippijn 1.1 {
26     config_file_t *ce_fileptr;
27    
28     int ce_varlinenum;
29     char *ce_varname;
30     char *ce_vardata;
31     int ce_vardatanum;
32     int ce_fileposstart;
33     int ce_fileposend;
34    
35     int ce_sectlinenum;
36     config_entry_t *ce_entries;
37    
38     config_entry_t *ce_prevlevel;
39    
40     config_entry_t *ce_next;
41 pippijn 1.4
42     bool valid ()
43     {
44     return ce_vardata != NULL;
45     }
46    
47     template<typename T>
48     T vardata ()
49     {
50     return vardata (types::get<T> ());
51     }
52    
53     private:
54     char *vardata (types::charptr_type)
55     {
56     return ce_vardata;
57     }
58    
59     int vardata (types::int_type)
60     {
61     return ce_vardatanum;
62     }
63 pippijn 1.1 };
64    
65     struct Token
66     {
67 pippijn 1.3 char const * const text;
68     int const value;
69 pippijn 1.1 };
70    
71 pippijn 1.4 class ConfTable
72 pippijn 1.1 {
73 pippijn 1.3 struct callbacks
74     {
75     functor::callback0<> ready;
76     };
77    
78 pippijn 1.5 public: // typedefs
79     unsigned index;
80     typedef indexing_vector<ConfTable> list_type;
81    
82     public: // variables
83 pippijn 1.3 char const * const name;
84     int const rehashable;
85 pippijn 1.1 int (*handler) (config_entry_t *);
86     char *str_val;
87     int *int_val;
88 pippijn 1.3
89     static callbacks callback;
90    
91     ConfTable (char const * const blockname, int const can_rehash, int (*handlerfunc) (config_entry_t *))
92 pippijn 1.4 : name (blockname), rehashable (can_rehash), handler (handlerfunc), str_val (0), int_val (0)
93 pippijn 1.3 {
94     }
95 pippijn 1.1 };
96    
97 pippijn 1.4 E void init_newconf (void);
98 pippijn 1.5 E void deinit_conf (void);
99 pippijn 1.4 E struct ConfTable *find_top_conf (char const * const name);
100 pippijn 1.5 E struct ConfTable *find_conf_item (char const * const name, ConfTable::list_type &conflist);
101 pippijn 1.4 E void add_top_conf (char const * const name, int (*handler) (config_entry_t *ce));
102 pippijn 1.5 E void add_conf_item (char const * const name, ConfTable::list_type &conflist, int (*handler) (config_entry_t *ce));
103 pippijn 1.4 E void del_top_conf (char const * const name);
104 pippijn 1.5 E void del_conf_item (char const * const name, ConfTable::list_type &conflist);
105     E int subblock_handler (config_entry_t *ce, ConfTable::list_type &entries);
106 pippijn 1.1
107     #endif