summaryrefslogtreecommitdiffabout
path: root/gconf/gconf.h
blob: f3d1bf88304861712149124daa327fcd77a757f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/* 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 <http://www.gnu.org/licenses/>. */

#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <gl_linked_list.h>

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);



Return to:

Send suggestions and report system problems to the System administrator.