/* gconf - General purpose configuration parser. Copyright (C) 2007, 2008, 2009 Sergey Poznyakoff This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #include #include #include #include #include typedef struct { char *file; int line; } gconf_locus_t; extern gconf_locus_t gconf_locus; enum gconf_data_type { gconf_type_void, gconf_type_string, gconf_type_short, gconf_type_ushort, gconf_type_int, gconf_type_uint, gconf_type_long, gconf_type_ulong, gconf_type_size, /* gconf_type_off,*/ gconf_type_uintmax, gconf_type_intmax, gconf_type_time, gconf_type_bool, gconf_type_ipv4, gconf_type_cidr, gconf_type_host, gconf_type_sockaddr, gconf_type_section }; #define GCONF_LIST 0x8000 #define GCONF_TYPE_MASK 0x00ff #define GCONF_TYPE(c) ((c) & GCONF_TYPE_MASK) #define GCONF_IS_LIST(c) ((c) & GCONF_LIST) enum gconf_callback_command { gconf_callback_section_begin, gconf_callback_section_end, gconf_callback_set_value }; #define GCONF_TYPE_STRING 0 #define GCONF_TYPE_LIST 1 #define GCONF_TYPE_ARRAY 2 typedef struct gconf_value { int type; union { gl_list_t list; const char *string; struct { size_t c; struct gconf_value *v; } arg; } v; } gconf_value_t; typedef int (*gconf_callback_fn) ( enum gconf_callback_command cmd, gconf_locus_t * /* locus */, void * /* varptr */, gconf_value_t * /* value */, void * /* cb_data */ ); struct gconf_keyword { const char *ident; const char *argname; const char *docstring; enum gconf_data_type type; void *varptr; size_t offset; gconf_callback_fn callback; void *callback_data; struct gconf_keyword *kwd; }; struct gconf_sockaddr { int len; struct sockaddr *sa; }; gconf_value_t *gconf_value_dup(gconf_value_t *input); extern void gconf_print_diag(gconf_locus_t *, int, int, const char*); void gconf_warning(gconf_locus_t *locus, int errcode, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4))); void gconf_error(gconf_locus_t *locus, int errcode, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4))); void gconf_set_keywords(struct gconf_keyword *kwd); void gconf_gram_trace(int n); void gconf_lex_trace (int n); int gconf_lex_begin(const char*); void gconf_lex_end(void); int gconf_parse (const char *name); void gconf_line_begin (void); void gconf_line_add (const char *text, size_t len); char *gconf_line_finish (void); extern int gconf_string_convert (void *target, enum gconf_data_type type, const char *string); extern gconf_locus_t gconf_current_locus; extern int gconf_error_count; extern int gconf_default_port; extern const char *gconf_preprocessor; extern bool gconf_log_to_stderr; extern void (*gconf_log_setup_hook) (); size_t gconf_preproc_fill_buffer (char *buf, size_t size); void gconf_preproc_add_include_dir (char *dir); int gconf_preproc_init (const char *name); void gconf_preproc_done (void); int gconf_preproc_run (const char *config_file, const char *extpp); FILE *gconf_preproc_extrn_start (const char *file, pid_t *ppid); void gconf_preproc_extrn_shutdown (pid_t pid); char *gconf_install_text (const char *str); void gconf_destroy_text (void); void gconf_include_path_setup (const char *dir, ...); void gconf_include_path_setup_v (char **dirs); const char *gconf_data_type_string (enum gconf_data_type type); void gconf_format_docstring (FILE *stream, const char *docstring, unsigned level); void gconf_format_simple_statement (FILE *stream, struct gconf_keyword *kwp, unsigned level); void gconf_format_block_statement (FILE *stream, struct gconf_keyword *kwp, unsigned level); void gconf_format_statement_array (FILE *stream, struct gconf_keyword *kwp, unsigned n, unsigned level);