2 * UCW Library -- Configuration files: Contexts
4 * (c) 2012 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
12 #include <ucw/conf-internal.h>
13 #include <ucw/threads.h>
15 #ifndef CONFIG_UCW_DEFAULT_CONFIG
16 #define CONFIG_UCW_DEFAULT_CONFIG NULL
19 #ifndef CONFIG_UCW_ENV_VAR_CONFIG
20 #define CONFIG_UCW_ENV_VAR_CONFIG NULL
26 struct cf_context *cc = xmalloc_zero(sizeof(*cc));
28 clist_init(&cc->conf_entries);
33 cf_free_context(struct cf_context *cc)
35 ASSERT(!cc->is_active);
41 cf_switch_context(struct cf_context *cc)
43 struct ucwlib_context *uc = ucwlib_thread_context();
44 struct cf_context *prev = uc->cf_context;
49 ASSERT(!cc->is_active);
57 cf_obtain_context(void)
59 struct ucwlib_context *uc = ucwlib_thread_context();
60 if (unlikely(!uc->cf_context))
62 struct cf_context *cc = cf_new_context();
64 cc->def_file = CONFIG_UCW_DEFAULT_CONFIG;
65 cc->env_file = CONFIG_UCW_ENV_VAR_CONFIG;
68 return uc->cf_context;
72 cf_set_default_file(char *name)
74 struct cf_context *cc = cf_obtain_context();
79 cf_set_env_override(char *name)
81 struct cf_context *cc = cf_obtain_context();