54 /** |
54 /** |
55 * Input buffer (don't set manually). |
55 * Input buffer (don't set manually). |
56 * Automatically set by calls to ucx_properties_fill(). |
56 * Automatically set by calls to ucx_properties_fill(). |
57 */ |
57 */ |
58 char *buffer; |
58 char *buffer; |
|
59 |
59 /** |
60 /** |
60 * Length of the input buffer (don't set manually). |
61 * Length of the input buffer (don't set manually). |
61 * Automatically set by calls to ucx_properties_fill(). |
62 * Automatically set by calls to ucx_properties_fill(). |
62 */ |
63 */ |
63 size_t buflen; |
64 size_t buflen; |
|
65 |
64 /** |
66 /** |
65 * Current buffer position (don't set manually). |
67 * Current buffer position (don't set manually). |
66 * Used by ucx_properties_next(). |
68 * Used by ucx_properties_next(). |
67 */ |
69 */ |
68 size_t pos; |
70 size_t pos; |
|
71 |
69 /** |
72 /** |
70 * Internal temporary buffer (don't set manually). |
73 * Internal temporary buffer (don't set manually). |
71 * Used by ucx_properties_next(). |
74 * Used by ucx_properties_next(). |
72 */ |
75 */ |
73 char *tmp; |
76 char *tmp; |
|
77 |
74 /** |
78 /** |
75 * Internal temporary buffer length (don't set manually). |
79 * Internal temporary buffer length (don't set manually). |
76 * Used by ucx_properties_next(). |
80 * Used by ucx_properties_next(). |
77 */ |
81 */ |
78 size_t tmplen; |
82 size_t tmplen; |
|
83 |
79 /** |
84 /** |
80 * Internal temporary buffer capacity (don't set manually). |
85 * Internal temporary buffer capacity (don't set manually). |
81 * Used by ucx_properties_next(). |
86 * Used by ucx_properties_next(). |
82 */ |
87 */ |
83 size_t tmpcap; |
88 size_t tmpcap; |
|
89 |
84 /** |
90 /** |
85 * Parser error code. |
91 * Parser error code. |
86 * This is always 0 on success and a nonzero value on syntax errors. |
92 * This is always 0 on success and a nonzero value on syntax errors. |
87 * The value is set by ucx_properties_next(). |
93 * The value is set by ucx_properties_next(). |
88 */ |
94 */ |
89 int error; |
95 int error; |
|
96 |
90 /** |
97 /** |
91 * The delimiter that shall be used. |
98 * The delimiter that shall be used. |
92 * This is '=' by default. |
99 * This is '=' by default. |
93 */ |
100 */ |
94 char delimiter; |
101 char delimiter; |
|
102 |
95 /** |
103 /** |
96 * The first comment character. |
104 * The first comment character. |
97 * This is '#' by default. |
105 * This is '#' by default. |
98 */ |
106 */ |
99 char comment1; |
107 char comment1; |
|
108 |
100 /** |
109 /** |
101 * The second comment character. |
110 * The second comment character. |
102 * This is not set by default. |
111 * This is not set by default. |
103 */ |
112 */ |
104 char comment2; |
113 char comment2; |
|
114 |
105 /** |
115 /** |
106 * The third comment character. |
116 * The third comment character. |
107 * This is not set by default. |
117 * This is not set by default. |
108 */ |
118 */ |
109 char comment3; |
119 char comment3; |
113 /** |
123 /** |
114 * Constructs a new UcxProperties object. |
124 * Constructs a new UcxProperties object. |
115 * @return a pointer to the new UcxProperties object |
125 * @return a pointer to the new UcxProperties object |
116 */ |
126 */ |
117 UcxProperties *ucx_properties_new(); |
127 UcxProperties *ucx_properties_new(); |
|
128 |
118 /** |
129 /** |
119 * Destroys an UcxProperties object. |
130 * Destroys an UcxProperties object. |
120 * @param prop the UcxProperties object to destroy |
131 * @param prop the UcxProperties object to destroy |
121 */ |
132 */ |
122 void ucx_properties_free(UcxProperties *prop); |
133 void ucx_properties_free(UcxProperties *prop); |
|
134 |
123 /** |
135 /** |
124 * Sets the input buffer for the properties parser. |
136 * Sets the input buffer for the properties parser. |
125 * |
137 * |
126 * After calling this function, you may parse the data by calling |
138 * After calling this function, you may parse the data by calling |
127 * ucx_properties_next() until it returns 0. The function ucx_properties2map() |
139 * ucx_properties_next() until it returns 0. The function ucx_properties2map() |
134 * @param len the payload length of the buffer |
146 * @param len the payload length of the buffer |
135 * @see ucx_properties_next() |
147 * @see ucx_properties_next() |
136 * @see ucx_properties2map() |
148 * @see ucx_properties2map() |
137 */ |
149 */ |
138 void ucx_properties_fill(UcxProperties *prop, char *buf, size_t len); |
150 void ucx_properties_fill(UcxProperties *prop, char *buf, size_t len); |
|
151 |
139 /** |
152 /** |
140 * Retrieves the next key/value-pair. |
153 * Retrieves the next key/value-pair. |
141 * |
154 * |
142 * This function returns a nonzero value as long as there are key/value-pairs |
155 * This function returns a nonzero value as long as there are key/value-pairs |
143 * found. If no more key/value-pairs are found, you may refill the input buffer |
156 * found. If no more key/value-pairs are found, you may refill the input buffer |
153 * @param value a pointer to the sstr_t that shall contain the property value |
166 * @param value a pointer to the sstr_t that shall contain the property value |
154 * @return Nonzero, if a key/value-pair was successfully retrieved |
167 * @return Nonzero, if a key/value-pair was successfully retrieved |
155 * @see ucx_properties_fill() |
168 * @see ucx_properties_fill() |
156 */ |
169 */ |
157 int ucx_properties_next(UcxProperties *prop, sstr_t *name, sstr_t *value); |
170 int ucx_properties_next(UcxProperties *prop, sstr_t *name, sstr_t *value); |
|
171 |
158 /** |
172 /** |
159 * Retrieves all available key/value-pairs and puts them into an UcxMap. |
173 * Retrieves all available key/value-pairs and puts them into an UcxMap. |
160 * |
174 * |
161 * This is done by successive calls to ucx_properties_next() until no more |
175 * This is done by successive calls to ucx_properties_next() until no more |
162 * key/value-pairs can be retrieved. |
176 * key/value-pairs can be retrieved. |
182 * |
196 * |
183 * @see ucx_properties_fill() |
197 * @see ucx_properties_fill() |
184 * @see ucx_properties2map() |
198 * @see ucx_properties2map() |
185 */ |
199 */ |
186 int ucx_properties_load(UcxMap *map, FILE *file); |
200 int ucx_properties_load(UcxMap *map, FILE *file); |
|
201 |
187 /** |
202 /** |
188 * Stores an UcxMap to a file. |
203 * Stores an UcxMap to a file. |
189 * |
204 * |
190 * The key/value-pairs are written by using the following format: |
205 * The key/value-pairs are written by using the following format: |
191 * |
206 * |