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
|
/*
* prof-int.h
*/
#include <time.h>
#include "prof_err.h"
#if defined(__STDC__) || defined(_WINDOWS)
#define PROTOTYPE(x) x
#else
#define PROTOTYPE(x) ()
#endif
typedef long errcode_t;
/*
* This is the structure which stores the profile information for a
* particular configuration file.
*/
struct _prf_file_t {
errcode_t magic;
char *filename;
struct profile_node *root;
time_t timestamp;
int flags;
struct _prf_file_t *next;
};
typedef struct _prf_file_t *prf_file_t;
/*
* This structure defines the high-level, user visible profile_t
* object, which is used as a handle by users who need to query some
* configuration file(s)
*/
struct _profile_t {
errcode_t magic;
prf_file_t first_file;
};
typedef struct _profile_t *profile_t;
/*
* This structure defines the profile_section_t object, which is
* returned to the user when a section is searched.
*/
struct _profile_section_t {
errcode_t magic;
int top_lvl:1, top_lvl_search:1;
char *name;
void *state;
struct profile_node *parent, *sect;
profile_t profile;
prf_file_t file_ptr;
};
typedef struct _profile_section_t *profile_section_t;
extern errcode_t profile_get
PROTOTYPE((const char *filename, prf_file_t *ret_prof));
extern errcode_t profile_update
PROTOTYPE((prf_file_t profile));
extern errcode_t profile_parse_file
PROTOTYPE((FILE *f, struct profile_node **root));
/* prof_tree.c */
extern void profile_free_node
PROTOTYPE((struct profile_node *relation));
extern errcode_t profile_create_node
PROTOTYPE((const char *name, const char *value,
struct profile_node **ret_node));
extern errcode_t profile_add_node
PROTOTYPE ((struct profile_node *section,
const char *name, const char *value,
struct profile_node **ret_node));
extern errcode_t profile_find_node_relation
PROTOTYPE ((struct profile_node *section,
const char *name, void **state,
char **ret_name, char **value));
extern errcode_t profile_find_node_subsection
PROTOTYPE ((struct profile_node *section,
const char *name, void **state,
char **ret_name, struct profile_node **subsection));
extern errcode_t profile_get_node_parent
PROTOTYPE ((struct profile_node *section,
struct profile_node **parent));
extern errcode_t profile_delete_node_relation
PROTOTYPE ((struct profile_node *section, const char *name));
/* prof_file.c */
extern errcode_t profile_open_file
PROTOTYPE ((const char *filename, prf_file_t *ret_prof));
extern errcode_t profile_update_file
PROTOTYPE ((prf_file_t profile));
extern errcode_t profile_close_file
PROTOTYPE ((prf_file_t profile));
/* prof_init.c */
errcode_t profile_init
PROTOTYPE ((const char **filenames, profile_t *ret_profile));
extern void profile_release
PROTOTYPE ((profile_t profile));
|