#ifndef _SC_CONF_H
#define _SC_CONF_H
#ifdef __cplusplus
extern "C" {
#endif
#define SCCONF_BOOLEAN 11
#define SCCONF_INTEGER 12
#define SCCONF_STRING 13
typedef struct _scconf_block scconf_block;
typedef struct _scconf_list {
struct _scconf_list *next;
char *data;
} scconf_list;
#define SCCONF_ITEM_TYPE_COMMENT 0
#define SCCONF_ITEM_TYPE_BLOCK 1
#define SCCONF_ITEM_TYPE_VALUE 2
typedef struct _scconf_item {
struct _scconf_item *next;
int type;
char *key;
union {
char *comment;
scconf_block *block;
scconf_list *list;
} value;
} scconf_item;
struct _scconf_block {
scconf_block *parent;
scconf_list *name;
scconf_item *items;
};
typedef struct {
char *filename;
int debug;
scconf_block *root;
char *errmsg;
} scconf_context;
extern scconf_context *scconf_new(const char *filename);
extern void scconf_free(scconf_context * config);
extern int scconf_parse(scconf_context * config);
extern int scconf_parse_string(scconf_context * config, const char *string);
extern int scconf_write(scconf_context * config, const char *filename);
extern const scconf_block *scconf_find_block(const scconf_context * config, const scconf_block * block, const char *item_name);
extern scconf_block **scconf_find_blocks(const scconf_context * config, const scconf_block * block, const char *item_name, const char *key);
extern const scconf_list *scconf_find_list(const scconf_block * block, const char *option);
extern const char *scconf_get_str(const scconf_block * block, const char *option, const char *def);
extern int scconf_get_int(const scconf_block * block, const char *option, int def);
extern int scconf_get_bool(const scconf_block * block, const char *option, int def);
extern const char *scconf_put_str(scconf_block * block, const char *option, const char *value);
extern int scconf_put_int(scconf_block * block, const char *option, int value);
extern int scconf_put_bool(scconf_block * block, const char *option, int value);
extern scconf_block *scconf_block_add(scconf_context * config, scconf_block * block, const char *key, const scconf_list *name);
extern scconf_block *scconf_block_copy(const scconf_block * src, scconf_block ** dst);
extern void scconf_block_destroy(scconf_block * block);
extern scconf_item *scconf_item_add(scconf_context * config, scconf_block * block, scconf_item * item, int type, const char *key, const void *data);
extern scconf_item *scconf_item_copy(const scconf_item * src, scconf_item ** dst);
extern void scconf_item_destroy(scconf_item * item);
extern scconf_list *scconf_list_add(scconf_list ** list, const char *value);
extern scconf_list *scconf_list_copy(const scconf_list * src, scconf_list ** dst);
extern void scconf_list_destroy(scconf_list * list);
extern int scconf_list_array_length(const scconf_list * list);
extern int scconf_list_strings_length(const scconf_list * list);
extern char *scconf_list_strdup(const scconf_list * list, const char *filler);
extern const char **scconf_list_toarray(const scconf_list * list);
#ifdef __cplusplus
}
#endif
#endif