ccl  0.1.1
ccl.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2004 - 2005, 2012 Stephen F. Booth <me@sbooth.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */
18 
19 #ifndef CCL_H
20 #define CCL_H
21 
22 #if HAVE_CONFIG_H
23 # include <config.h>
24 #endif
25 
26 #include "ccl/bst.h"
27 
28 #ifdef __cplusplus
29  extern "C" {
30 #endif
31 
37 struct ccl_pair_t
38 {
40  char *key;
42  char *value;
43 };
44 
54 struct ccl_t
55 {
59  char sep_char;
61  char str_char;
62 
63 
64  /* ========== Implementation details below, subject to change */
65 
66  /* The parsed file data, stored as a binary tree*/
67  struct bst_table *table;
68 
69  /* The table traverser */
70  struct bst_traverser traverser;
71 
72  /* Currently traversing? */
73  int iterating;
74 };
75 typedef struct ccl_t ccl_t;
76 
88 int
89 ccl_parse(struct ccl_t *data,
90  const char *path);
91 
98 void
99 ccl_release(struct ccl_t *data);
100 
113 const char*
114 ccl_get(const struct ccl_t *data,
115  const char *key);
116 
128 const struct ccl_pair_t*
129 ccl_iterate(struct ccl_t *data);
130 
138 void
139 ccl_reset(struct ccl_t *data);
140 
152 struct ccl_pair_t*
153 ccl_set(const struct ccl_t *data,
154  const char *key,
155  const char *value);
156 
157 #ifdef __cplusplus
158  }
159 #endif
160 
161 #endif /* ! CCL_H */
162 
163 
char comment_char
Character that indicates the start of a comment.
Definition: ccl.h:57
void ccl_release(struct ccl_t *data)
Release memory associated with a configuration file.
const char * ccl_get(const struct ccl_t *data, const char *key)
Extract a value from a configuration file.
const struct ccl_pair_t * ccl_iterate(struct ccl_t *data)
Iterate through all key/value pairs in a configuration file.
char * key
The key.
Definition: ccl.h:40
char sep_char
Character that separates keys from values.
Definition: ccl.h:59
char * value
The value.
Definition: ccl.h:42
struct ccl_pair_t * ccl_set(const struct ccl_t *data, const char *key, const char *value)
Set a value in a configuration file.
Data structure encapsulating a parsed configuration file.
Definition: ccl.h:54
void ccl_reset(struct ccl_t *data)
Reset a configuration file iterator.
int ccl_parse(struct ccl_t *data, const char *path)
Parse a configuration file.
A key/value pair found in a configuration file.
Definition: ccl.h:37
char str_char
Character that delineates string literals.
Definition: ccl.h:61