libmcs
0.6.0
Main Page
Classes
Files
File List
File Members
src
libmcs
mcs.h
Go to the documentation of this file.
1
/*
2
* This is mcs; a modular configuration system.
3
*
4
* Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
5
*
6
* Redistribution and use in source and binary forms, with or without
7
* modification, are permitted provided that the following conditions are
8
* met:
9
*
10
* 1. Redistributions of source code must retain the above copyright notice,
11
* this list of conditions and the following disclaimer.
12
*
13
* 2. Redistributions in binary form must reproduce the above copyright
14
* notice, this list of conditions and the following disclaimer in the
15
* documentation and/or other materials provided with the distribution.
16
*
17
* 3. The name of the author may not be used to endorse or promote products
18
* derived from this software without specific prior written permission.
19
*
20
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
* POSSIBILITY OF SUCH DAMAGE.
31
*/
32
33
#ifndef __LIBMCS_MCS_H__
34
#define __LIBMCS_MCS_H__
35
36
#include <unistd.h>
37
#include <stdlib.h>
38
#include <string.h>
39
#include <sys/stat.h>
40
#include <sys/types.h>
41
#include <dirent.h>
42
#include <stdio.h>
43
#include <limits.h>
44
#include <stdarg.h>
45
#include <errno.h>
46
47
#ifndef __WIN32__
48
#include <dlfcn.h>
49
#endif
50
51
#include <mowgli.h>
52
53
#ifdef _MCS_CORE
54
# include <
libmcs/mcs_config.h
>
55
#endif
56
58
typedef
enum
{
59
MCS_FAIL
,
60
MCS_OK
61
}
mcs_response_t
;
62
64
typedef
struct
mcs_handle_
mcs_handle_t
;
65
79
typedef
struct
{
80
void
*
handle
;
93
const
char
*
name
;
94
95
/* constructors and destructors */
96
110
mcs_handle_t
*(*mcs_new)(
char
*domain);
111
121
void (*
mcs_destroy
)(
mcs_handle_t
*handle);
122
123
/* retrieval */
124
133
mcs_response_t
(*
mcs_get_string
)(
mcs_handle_t
*handle,
134
const
char
*section,
135
const
char
*key,
136
char
**value);
137
146
mcs_response_t
(*
mcs_get_int
)(
mcs_handle_t
*handle,
147
const
char
*section,
148
const
char
*key,
149
int
*value);
150
159
mcs_response_t
(*
mcs_get_bool
)(
mcs_handle_t
*handle,
160
const
char
*section,
161
const
char
*key,
162
int
*value);
163
172
mcs_response_t
(*
mcs_get_float
)(
mcs_handle_t
*handle,
173
const
char
*section,
174
const
char
*key,
175
float
*value);
176
185
mcs_response_t
(*
mcs_get_double
)(
mcs_handle_t
*handle,
186
const
char
*section,
187
const
char
*key,
188
double
*value);
189
190
/* setting data */
191
200
mcs_response_t
(*
mcs_set_string
)(
mcs_handle_t
*handle,
201
const
char
*section,
202
const
char
*key,
203
const
char
*value);
204
213
mcs_response_t
(*
mcs_set_int
)(
mcs_handle_t
*handle,
214
const
char
*section,
215
const
char
*key,
216
int
value);
217
226
mcs_response_t
(*
mcs_set_bool
)(
mcs_handle_t
*handle,
227
const
char
*section,
228
const
char
*key,
229
int
value);
230
239
mcs_response_t
(*
mcs_set_float
)(
mcs_handle_t
*handle,
240
const
char
*section,
241
const
char
*key,
242
float
value);
243
252
mcs_response_t
(*
mcs_set_double
)(
mcs_handle_t
*handle,
253
const
char
*section,
254
const
char
*key,
255
double
value);
256
257
/* unset */
258
266
mcs_response_t
(*
mcs_unset_key
)(
mcs_handle_t
*handle,
267
const
char
*section,
268
const
char
*key);
269
270
/* key request */
271
278
mowgli_queue_t *(*mcs_get_keys)(
mcs_handle_t
*handle,
279
const
char
*section);
280
281
/* sections request */
282
288
mowgli_queue_t *(*mcs_get_sections)(
mcs_handle_t
*handle);
289
}
mcs_backend_t
;
290
294
struct
mcs_handle_
{
295
mowgli_object_t
object
;
296
mcs_backend_t
*
base
;
297
void
*
mcs_priv_handle
;
298
};
299
300
/*
301
* These functions have to do with initialization of the
302
* library.
303
*/
304
305
extern
void
mcs_init
(
void
);
306
extern
void
mcs_fini
(
void
);
307
extern
char
*
mcs_version
(
void
);
308
extern
void
mcs_handle_class_init
(
void
);
309
310
/*
311
* These functions have to do with registration of MCS backends.
312
*/
313
extern
mcs_response_t
mcs_backend_register
(
mcs_backend_t
*backend);
314
extern
mcs_response_t
mcs_backend_unregister
(
mcs_backend_t
*backend);
315
extern
mowgli_queue_t *
mcs_backend_get_list
(
void
);
316
extern
const
char
*
mcs_backend_select
(
void
);
317
318
/*
319
* These functions provide the public interface for creating and closing MCS
320
* handles.
321
*
322
* Please note that if a handle is not closed, the data may not be saved to
323
* disk.
324
*/
325
extern
mcs_handle_t
*
mcs_new
(
char
*domain);
326
extern
void
mcs_destroy
(
mcs_handle_t
*handle);
327
328
/*
329
* These functions provide the public interface for querying and setting data.
330
*/
331
/* retrieval */
332
extern
mcs_response_t
mcs_get_string
(
mcs_handle_t
*handle,
333
const
char
*section,
334
const
char
*key,
335
char
**value);
336
337
extern
mcs_response_t
mcs_get_int
(
mcs_handle_t
*handle,
338
const
char
*section,
339
const
char
*key,
340
int
*value);
341
342
extern
mcs_response_t
mcs_get_bool
(
mcs_handle_t
*handle,
343
const
char
*section,
344
const
char
*key,
345
int
*value);
346
347
extern
mcs_response_t
mcs_get_float
(
mcs_handle_t
*handle,
348
const
char
*section,
349
const
char
*key,
350
float
*value);
351
352
extern
mcs_response_t
mcs_get_double
(
mcs_handle_t
*handle,
353
const
char
*section,
354
const
char
*key,
355
double
*value);
356
357
/* setting data */
358
extern
mcs_response_t
mcs_set_string
(
mcs_handle_t
*handle,
359
const
char
*section,
360
const
char
*key,
361
const
char
*value);
362
363
extern
mcs_response_t
mcs_set_int
(
mcs_handle_t
*handle,
364
const
char
*section,
365
const
char
*key,
366
int
value);
367
368
extern
mcs_response_t
mcs_set_bool
(
mcs_handle_t
*handle,
369
const
char
*section,
370
const
char
*key,
371
int
value);
372
373
extern
mcs_response_t
mcs_set_float
(
mcs_handle_t
*handle,
374
const
char
*section,
375
const
char
*key,
376
float
value);
377
378
extern
mcs_response_t
mcs_set_double
(
mcs_handle_t
*handle,
379
const
char
*section,
380
const
char
*key,
381
double
value);
382
383
/* unset */
384
extern
mcs_response_t
mcs_unset_key
(
mcs_handle_t
*handle,
385
const
char
*section,
386
const
char
*key);
387
388
/* key request */
389
extern
mowgli_queue_t *
mcs_get_keys
(
mcs_handle_t
*handle,
390
const
char
*section);
391
392
extern
mowgli_queue_t *
mcs_get_sections
(
mcs_handle_t
*handle);
393
394
/*
395
* These functions have to do with the plugin loader.
396
*/
397
extern
void
mcs_load_plugins
(
void
);
398
extern
void
mcs_unload_plugins
(mowgli_queue_t *l);
399
400
/*
401
* These functions are utility functions.
402
*/
403
extern
size_t
mcs_strnlen
(
const
char
*str,
size_t
len);
404
extern
char
*
mcs_strndup
(
const
char
*str,
size_t
len);
405
extern
int
mcs_create_directory
(
const
char
*path, mode_t mode);
406
extern
size_t
mcs_strlcat
(
char
*dest,
const
char
*src,
size_t
count);
407
extern
size_t
mcs_strlcpy
(
char
*dest,
const
char
*src,
size_t
count);
408
409
#endif
Generated by
1.8.1.1