X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fconf-internal.h;h=67a96cf5baece5563bf866c68a57d265fcd33467;hb=d4123b266f32fe1c84c03cc66ed7cc6c943a355b;hp=377a9cb235a1ab63e8815a787610a43892fa1f9c;hpb=031256ad2e123eec58521f8e3eb9496c197641d2;p=libucw.git diff --git a/ucw/conf-internal.h b/ucw/conf-internal.h index 377a9cb2..67a96cf5 100644 --- a/ucw/conf-internal.h +++ b/ucw/conf-internal.h @@ -2,7 +2,7 @@ * UCW Library -- Configuration files: only for internal use of conf-*.c * * (c) 2001--2006 Robert Spalek - * (c) 2003--2006 Martin Mares + * (c) 2003--2012 Martin Mares * * This software may be freely distributed and used according to the terms * of the GNU Lesser General Public License. @@ -11,6 +11,68 @@ #ifndef _UCW_CONF_INTERNAL_H #define _UCW_CONF_INTERNAL_H +#include + +/* Item stack used by conf-intr.c */ + +#define MAX_STACK_SIZE 16 + +struct item_stack { // used by conf-intr.c + struct cf_section *sec; // nested section + void *base_ptr; // because original pointers are often relative + int op; // it is performed when a closing brace is encountered + void *list; // list the operations should be done on + u32 mask; // bit array of selectors searching in a list + struct cf_item *item; // cf_item of the list +}; + +/* List of dirty sections used by conf-section.c */ + +struct dirty_section { + struct cf_section *sec; + void *ptr; +}; + +#define GBUF_TYPE struct dirty_section +#define GBUF_PREFIX(x) dirtsec_##x +#include + +/* Configuration context */ + +struct cf_context { + struct mempool *pool; + int is_active; + int config_loaded; // at least one config file was loaded + struct cf_parser_state *parser; + uns everything_committed; // did we already commit each section? + uns postpone_commit; // counter of calls to cf_open_group() + uns other_options; // used internally by cf_getopt() + clist conf_entries; // files/strings to reload + struct cf_journal_item *journal; // journalling + int enable_journal; + struct old_pools *pools; + struct item_stack stack[MAX_STACK_SIZE]; // interpreter stack + uns stack_level; + struct cf_section sections; // root section + uns sections_initialized; + dirtsec_t dirty; // dirty sections + uns dirties; +}; + +/* conf-ctxt.c */ +static inline struct cf_context * +cf_get_context(void) +{ + struct cf_context *cc = ucwlib_thread_context()->cf_context; + ASSERT(cc->is_active); + return cc; +} + +// In fact, this is equivalent to cf_get_context(), but it is not inlined, +// because we want to force the linker to include conf-context.c, which contains +// a constructor of the whole context mechanism. +struct cf_context *cf_obtain_context(void); + /* conf-intr.c */ #define OP_MASK 0xff // only get the operation #define OP_OPEN 0x100 // here we only get an opening brace instead of parameters @@ -21,9 +83,9 @@ extern char *cf_op_names[]; extern char *cf_type_names[]; uns cf_type_size(enum cf_type type, struct cf_user_type *utype); -char *cf_interpret_line(char *name, enum cf_operation op, int number, char **pars); -void cf_init_stack(void); -int cf_check_stack(void); +char *cf_interpret_line(struct cf_context *cc, char *name, enum cf_operation op, int number, char **pars); +void cf_init_stack(struct cf_context *cc); +int cf_done_stack(struct cf_context *cc); /* conf-journal.c */ void cf_journal_swap(void);