]> mj.ucw.cz Git - libucw.git/blob - ucw/conf-internal.h
Logger: Fixed use of unitialized flags
[libucw.git] / ucw / conf-internal.h
1 /*
2  *      UCW Library -- Configuration files: only for internal use of conf-*.c
3  *
4  *      (c) 2001--2006 Robert Spalek <robert@ucw.cz>
5  *      (c) 2003--2012 Martin Mares <mj@ucw.cz>
6  *
7  *      This software may be freely distributed and used according to the terms
8  *      of the GNU Lesser General Public License.
9  */
10
11 #ifndef _UCW_CONF_INTERNAL_H
12 #define _UCW_CONF_INTERNAL_H
13
14 #include <ucw/threads.h>
15
16 #ifdef CONFIG_UCW_CLEAN_ABI
17 #define cf_add_dirty ucw_cf_add_dirty
18 #define cf_commit_all ucw_cf_commit_all
19 #define cf_done_stack ucw_cf_done_stack
20 #define cf_find_subitem ucw_cf_find_subitem
21 #define cf_init_stack ucw_cf_init_stack
22 #define cf_interpret_line ucw_cf_interpret_line
23 #define cf_journal_delete ucw_cf_journal_delete
24 #define cf_journal_swap ucw_cf_journal_swap
25 #define cf_load_default ucw_cf_load_default
26 #define cf_obtain_context ucw_cf_obtain_context
27 #define cf_op_names ucw_cf_op_names
28 #define cf_sections ucw_cf_sections
29 #define cf_type_names ucw_cf_type_names
30 #define cf_type_size ucw_cf_type_size
31 #endif
32
33 /* Item stack used by conf-intr.c */
34
35 #define MAX_STACK_SIZE 16
36
37 struct item_stack {             // used by conf-intr.c
38   struct cf_section *sec;       // nested section
39   void *base_ptr;               // because original pointers are often relative
40   int op;                       // it is performed when a closing brace is encountered
41   void *list;                   // list the operations should be done on
42   u32 mask;                     // bit array of selectors searching in a list
43   struct cf_item *item;         // cf_item of the list
44 };
45
46 /* List of dirty sections used by conf-section.c */
47
48 struct dirty_section {
49   struct cf_section *sec;
50   void *ptr;
51 };
52
53 #define GBUF_TYPE       struct dirty_section
54 #define GBUF_PREFIX(x)  dirtsec_##x
55 #include <ucw/gbuf.h>
56
57 /* Configuration context */
58
59 struct cf_context {
60   struct mempool *pool;
61   int is_active;
62   int config_loaded;                    // at least one config file was loaded
63   struct cf_parser_state *parser;
64   uint everything_committed;            // did we already commit each section?
65   uint postpone_commit;                 // counter of calls to cf_open_group()
66   uint other_options;                   // used internally by cf_getopt()
67   clist conf_entries;                   // files/strings to reload
68   struct cf_journal_item *journal;      // journalling
69   int enable_journal;
70   struct old_pools *pools;
71   struct item_stack stack[MAX_STACK_SIZE];      // interpreter stack
72   uint stack_level;
73   struct cf_section sections;           // root section
74   uint sections_initialized;
75   dirtsec_t dirty;                      // dirty sections
76   uint dirties;
77 };
78
79 /* conf-ctxt.c */
80 static inline struct cf_context *cf_get_context(void)
81 {
82   struct cf_context *cc = ucwlib_thread_context()->cf_context;
83   ASSERT(cc->is_active);
84   return cc;
85 }
86
87 // In fact, this is equivalent to cf_get_context(), but it is not inlined,
88 // because we want to force the linker to include conf-context.c, which contains
89 // a constructor of the whole context mechanism.
90 struct cf_context *cf_obtain_context(void);
91
92 /* conf-intr.c */
93 #define OP_MASK 0xff            // only get the operation
94 #define OP_OPEN 0x100           // here we only get an opening brace instead of parameters
95 #define OP_1ST 0x200            // in the 1st phase selectors are recorded into the mask
96 #define OP_2ND 0x400            // in the 2nd phase real data are entered
97 enum cf_operation;
98 extern char *cf_op_names[];
99 extern char *cf_type_names[];
100
101 uint cf_type_size(enum cf_type type, struct cf_user_type *utype);
102 char *cf_interpret_line(struct cf_context *cc, char *name, enum cf_operation op, int number, char **pars);
103 void cf_init_stack(struct cf_context *cc);
104 int cf_done_stack(struct cf_context *cc);
105
106 /* conf-journal.c */
107 void cf_journal_swap(void);
108 void cf_journal_delete(void);
109
110 /* conf-section.c */
111 #define SEC_FLAG_DYNAMIC        0x80000000      // contains a dynamic attribute
112 #define SEC_FLAG_UNKNOWN        0x40000000      // ignore unknown entriies
113 #define SEC_FLAG_CANT_COPY      0x20000000      // contains lists or parsers
114 #define SEC_FLAG_NUMBER         0x0fffffff      // number of entries
115 enum cf_commit_mode { CF_NO_COMMIT, CF_COMMIT, CF_COMMIT_ALL };
116 extern struct cf_section cf_sections;
117
118 struct cf_item *cf_find_subitem(struct cf_section *sec, const char *name);
119 int cf_commit_all(enum cf_commit_mode cm);
120 void cf_add_dirty(struct cf_section *sec, void *ptr);
121
122 /* conf-getopt.c */
123 void cf_load_default(struct cf_context *cc);
124
125 #endif