src/ucx/cx/properties.h

4 weeks ago

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 02 Mar 2025 18:10:52 +0100 (4 weeks ago)
changeset 579
e10457d74fe1
permissions
-rw-r--r--

update ucx

579
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2024 Mike Becker, Olaf Wintermann All rights reserved.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 * @file properties.h
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 * @brief Interface for parsing data from properties files.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31 * @author Mike Becker
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 * @author Olaf Wintermann
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 * @copyright 2-Clause BSD License
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #ifndef UCX_PROPERTIES_H
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 #define UCX_PROPERTIES_H
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 #include "common.h"
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 #include "string.h"
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 #include "map.h"
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 #include "buffer.h"
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 #include <stdio.h>
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 #include <string.h>
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 #ifdef __cplusplus
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 extern "C" {
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 #endif
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 * Configures the expected characters for the properties parser.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 struct cx_properties_config_s {
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 * The key/value delimiter that shall be used.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 * This is '=' by default.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 char delimiter;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62 * The first comment character.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 * This is '#' by default.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 char comment1;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 * The second comment character.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 * This is not set by default.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 char comment2;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74 * The third comment character.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 * This is not set by default.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 char comment3;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 /*
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80 * The character, when appearing at the end of a line, continues that line.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 * This is '\' by default.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 * Reserved for future use.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 char continuation;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87 };
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 * Typedef for the properties config.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
91 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92 typedef struct cx_properties_config_s CxPropertiesConfig;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 * Default properties configuration.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97 cx_attr_export
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
98 extern const CxPropertiesConfig cx_properties_config_default;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
100 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101 * Status codes for the properties interface.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103 enum cx_properties_status {
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
104 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
105 * Everything is fine.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
106 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
107 CX_PROPERTIES_NO_ERROR,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
108 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109 * The input buffer does not contain more data.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
110 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111 CX_PROPERTIES_NO_DATA,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
112 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
113 * The input ends unexpectedly.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115 * This either happens when the last line does not terminate with a line
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116 * break, or when the input ends with a parsed key but no value.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118 CX_PROPERTIES_INCOMPLETE_DATA,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120 * Not used as a status and never returned by any function.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 * You can use this enumerator to check for all "good" status results
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 * by checking if the status is less than @c CX_PROPERTIES_OK.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125 * A "good" status means, that you can refill data and continue parsing.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
127 CX_PROPERTIES_OK,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129 * Input buffer is @c NULL.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
130 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131 CX_PROPERTIES_NULL_INPUT,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133 * The line contains a delimiter, but no key.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
135 CX_PROPERTIES_INVALID_EMPTY_KEY,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
136 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
137 * The line contains data, but no delimiter.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
139 CX_PROPERTIES_INVALID_MISSING_DELIMITER,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
140 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
141 * More internal buffer was needed, but could not be allocated.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
142 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
143 CX_PROPERTIES_BUFFER_ALLOC_FAILED,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
144 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
145 * Initializing the properties source failed.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
146 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
147 * @see cx_properties_read_init_func
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
148 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
149 CX_PROPERTIES_READ_INIT_FAILED,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
150 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
151 * Reading from a properties source failed.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
152 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
153 * @see cx_properties_read_func
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
154 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
155 CX_PROPERTIES_READ_FAILED,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
156 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
157 * Sinking a k/v-pair failed.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
158 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
159 * @see cx_properties_sink_func
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
160 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
161 CX_PROPERTIES_SINK_FAILED,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
162 };
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
163
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
164 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
165 * Typedef for the properties status enum.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
166 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
167 typedef enum cx_properties_status CxPropertiesStatus;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
168
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
169 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
170 * Interface for working with properties data.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
171 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
172 struct cx_properties_s {
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
173 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
174 * The configuration.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
175 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
176 CxPropertiesConfig config;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
177
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
178 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
179 * The text input buffer.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
180 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
181 CxBuffer input;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
182
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
183 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
184 * Internal buffer.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
185 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
186 CxBuffer buffer;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
187 };
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
188
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
189 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
190 * Typedef for the properties interface.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
191 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
192 typedef struct cx_properties_s CxProperties;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
193
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
194
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
195 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
196 * Typedef for a properties sink.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
197 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
198 typedef struct cx_properties_sink_s CxPropertiesSink;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
199
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
200 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
201 * A function that consumes a k/v-pair in a sink.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
202 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
203 * The sink could be e.g. a map and the sink function would be calling
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
204 * a map function to store the k/v-pair.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
205 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
206 * @param prop the properties interface that wants to sink a k/v-pair
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
207 * @param sink the sink
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
208 * @param key the key
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
209 * @param value the value
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
210 * @retval zero success
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
211 * @retval non-zero sinking the k/v-pair failed
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
212 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
213 cx_attr_nonnull
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
214 typedef int(*cx_properties_sink_func)(
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
215 CxProperties *prop,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
216 CxPropertiesSink *sink,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
217 cxstring key,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
218 cxstring value
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
219 );
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
220
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
221 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
222 * Defines a sink for k/v-pairs.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
223 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
224 struct cx_properties_sink_s {
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
225 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
226 * The sink object.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
227 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
228 void *sink;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
229 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
230 * Optional custom data.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
231 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
232 void *data;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
233 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
234 * A function for consuming k/v-pairs into the sink.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
235 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
236 cx_properties_sink_func sink_func;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
237 };
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
238
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
239
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
240 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
241 * Typedef for a properties source.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
242 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
243 typedef struct cx_properties_source_s CxPropertiesSource;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
244
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
245 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
246 * A function that reads data from a source.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
247 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
248 * When the source is depleted, implementations SHALL provide an empty
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
249 * string in the @p target and return zero.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
250 * A non-zero return value is only permitted in case of an error.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
251 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
252 * The meaning of the optional parameters is implementation-dependent.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
253 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
254 * @param prop the properties interface that wants to read from the source
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
255 * @param src the source
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
256 * @param target a string buffer where the read data shall be stored
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
257 * @retval zero success
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
258 * @retval non-zero reading the data failed
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
259 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
260 cx_attr_nonnull
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
261 typedef int(*cx_properties_read_func)(
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
262 CxProperties *prop,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
263 CxPropertiesSource *src,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
264 cxstring *target
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
265 );
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
266
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
267 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
268 * A function that may initialize additional memory for the source.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
269 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
270 * @param prop the properties interface that wants to read from the source
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
271 * @param src the source
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
272 * @retval zero initialization was successful
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
273 * @retval non-zero otherwise
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
274 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
275 cx_attr_nonnull
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
276 typedef int(*cx_properties_read_init_func)(
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
277 CxProperties *prop,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
278 CxPropertiesSource *src
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
279 );
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
280
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
281 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
282 * A function that cleans memory initialized by the read_init_func.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
283 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
284 * @param prop the properties interface that wants to read from the source
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
285 * @param src the source
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
286 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
287 cx_attr_nonnull
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
288 typedef void(*cx_properties_read_clean_func)(
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
289 CxProperties *prop,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
290 CxPropertiesSource *src
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
291 );
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
292
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
293 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
294 * Defines a properties source.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
295 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
296 struct cx_properties_source_s {
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
297 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
298 * The source object.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
299 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
300 * For example a file stream or a string.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
301 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
302 void *src;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
303 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
304 * Optional additional data pointer.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
305 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
306 void *data_ptr;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
307 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
308 * Optional size information.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
309 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
310 size_t data_size;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
311 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
312 * A function that reads data from the source.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
313 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
314 cx_properties_read_func read_func;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
315 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
316 * Optional function that may prepare the source for reading data.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
317 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
318 cx_properties_read_init_func read_init_func;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
319 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
320 * Optional function that cleans additional memory allocated by the
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
321 * read_init_func.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
322 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
323 cx_properties_read_clean_func read_clean_func;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
324 };
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
325
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
326 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
327 * Initialize a properties interface.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
328 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
329 * @param prop the properties interface
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
330 * @param config the properties configuration
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
331 * @see cxPropertiesInitDefault()
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
332 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
333 cx_attr_nonnull
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
334 cx_attr_export
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
335 void cxPropertiesInit(CxProperties *prop, CxPropertiesConfig config);
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
336
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
337 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
338 * Destroys the properties interface.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
339 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
340 * @note Even when you are certain that you did not use the interface in a
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
341 * way that caused a memory allocation, you should call this function anyway.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
342 * Future versions of the library might add features that need additional memory
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
343 * and you really don't want to search the entire code where you might need
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
344 * add call to this function.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
345 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
346 * @param prop the properties interface
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
347 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
348 cx_attr_nonnull
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
349 cx_attr_export
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
350 void cxPropertiesDestroy(CxProperties *prop);
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
351
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
352 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
353 * Destroys and re-initializes the properties interface.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
354 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
355 * You might want to use this, to reset the parser after
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
356 * encountering a syntax error.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
357 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
358 * @param prop the properties interface
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
359 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
360 cx_attr_nonnull
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
361 static inline void cxPropertiesReset(CxProperties *prop) {
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
362 CxPropertiesConfig config = prop->config;
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
363 cxPropertiesDestroy(prop);
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
364 cxPropertiesInit(prop, config);
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
365 }
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
366
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
367 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
368 * Initialize a properties parser with the default configuration.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
369 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
370 * @param prop (@c CxProperties*) the properties interface
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
371 * @see cxPropertiesInit()
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
372 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
373 #define cxPropertiesInitDefault(prop) \
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
374 cxPropertiesInit(prop, cx_properties_config_default)
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
375
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
376 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
377 * Fills the input buffer with data.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
378 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
379 * After calling this function, you can parse the data by calling
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
380 * cxPropertiesNext().
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
381 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
382 * @remark The properties interface tries to avoid allocations.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
383 * When you use this function and cxPropertiesNext() interleaving,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
384 * no allocations are performed. However, you must not free the
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
385 * pointer to the data in that case. When you invoke the fill
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
386 * function more than once before calling cxPropertiesNext(),
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
387 * the additional data is appended - inevitably leading to
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
388 * an allocation of a new buffer and copying the previous contents.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
389 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
390 * @param prop the properties interface
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
391 * @param buf a pointer to the data
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
392 * @param len the length of the data
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
393 * @retval zero success
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
394 * @retval non-zero a memory allocation was necessary but failed
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
395 * @see cxPropertiesFill()
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
396 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
397 cx_attr_nonnull
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
398 cx_attr_access_r(2, 3)
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
399 cx_attr_export
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
400 int cxPropertiesFilln(
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
401 CxProperties *prop,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
402 const char *buf,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
403 size_t len
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
404 );
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
405
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
406 #ifdef __cplusplus
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
407 } // extern "C"
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
408 cx_attr_nonnull
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
409 static inline int cxPropertiesFill(
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
410 CxProperties *prop,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
411 cxstring str
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
412 ) {
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
413 return cxPropertiesFilln(prop, str.ptr, str.length);
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
414 }
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
415
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
416 cx_attr_nonnull
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
417 static inline int cxPropertiesFill(
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
418 CxProperties *prop,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
419 cxmutstr str
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
420 ) {
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
421 return cxPropertiesFilln(prop, str.ptr, str.length);
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
422 }
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
423
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
424 cx_attr_nonnull
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
425 cx_attr_cstr_arg(2)
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
426 static inline int cxPropertiesFill(
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
427 CxProperties *prop,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
428 const char *str
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
429 ) {
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
430 return cxPropertiesFilln(prop, str, strlen(str));
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
431 }
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
432
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
433 extern "C" {
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
434 #else // __cplusplus
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
435 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
436 * Fills the input buffer with data.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
437 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
438 * After calling this function, you can parse the data by calling
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
439 * cxPropertiesNext().
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
440 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
441 * @attention The properties interface tries to avoid allocations.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
442 * When you use this function and cxPropertiesNext() interleaving,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
443 * no allocations are performed. However, you must not free the
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
444 * pointer to the data in that case. When you invoke the fill
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
445 * function more than once before calling cxPropertiesNext(),
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
446 * the additional data is appended - inevitably leading to
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
447 * an allocation of a new buffer and copying the previous contents.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
448 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
449 * @param prop the properties interface
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
450 * @param str the text to fill in
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
451 * @retval zero success
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
452 * @retval non-zero a memory allocation was necessary but failed
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
453 * @see cxPropertiesFilln()
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
454 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
455 #define cxPropertiesFill(prop, str) _Generic((str), \
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
456 cxstring: cx_properties_fill_cxstr, \
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
457 cxmutstr: cx_properties_fill_mutstr, \
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
458 char*: cx_properties_fill_str, \
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
459 const char*: cx_properties_fill_str) \
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
460 (prop, str)
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
461
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
462 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
463 * @copydoc cxPropertiesFill()
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
464 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
465 cx_attr_nonnull
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
466 static inline int cx_properties_fill_cxstr(
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
467 CxProperties *prop,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
468 cxstring str
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
469 ) {
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
470 return cxPropertiesFilln(prop, str.ptr, str.length);
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
471 }
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
472
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
473 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
474 * @copydoc cxPropertiesFill()
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
475 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
476 cx_attr_nonnull
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
477 static inline int cx_properties_fill_mutstr(
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
478 CxProperties *prop,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
479 cxmutstr str
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
480 ) {
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
481 return cxPropertiesFilln(prop, str.ptr, str.length);
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
482 }
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
483
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
484 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
485 * @copydoc cxPropertiesFill()
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
486 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
487 cx_attr_nonnull
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
488 cx_attr_cstr_arg(2)
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
489 static inline int cx_properties_fill_str(
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
490 CxProperties *prop,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
491 const char *str
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
492 ) {
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
493 return cxPropertiesFilln(prop, str, strlen(str));
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
494 }
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
495 #endif
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
496
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
497 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
498 * Specifies stack memory that shall be used as internal buffer.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
499 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
500 * @param prop the properties interface
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
501 * @param buf a pointer to stack memory
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
502 * @param capacity the capacity of the stack memory
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
503 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
504 cx_attr_nonnull
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
505 cx_attr_export
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
506 void cxPropertiesUseStack(
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
507 CxProperties *prop,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
508 char *buf,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
509 size_t capacity
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
510 );
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
511
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
512 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
513 * Retrieves the next key/value-pair.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
514 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
515 * This function returns zero as long as there are key/value-pairs found.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
516 * If no more key/value-pairs are found, #CX_PROPERTIES_NO_DATA is returned.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
517 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
518 * When an incomplete line is encountered, #CX_PROPERTIES_INCOMPLETE_DATA is
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
519 * returned, and you can add more data with #cxPropertiesFill().
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
520 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
521 * @remark The incomplete line will be stored in an internal buffer, which is
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
522 * allocated on the heap, by default. If you want to avoid allocations,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
523 * you can specify sufficient space with cxPropertiesUseStack() after
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
524 * initialization with cxPropertiesInit().
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
525 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
526 * @attention The returned strings will point into a buffer that might not be
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
527 * available later. It is strongly recommended to copy the strings for further
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
528 * use.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
529 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
530 * @param prop the properties interface
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
531 * @param key a pointer to the cxstring that shall contain the property name
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
532 * @param value a pointer to the cxstring that shall contain the property value
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
533 * @retval CX_PROPERTIES_NO_ERROR (zero) a key/value pair was found
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
534 * @retval CX_PROPERTIES_NO_DATA there is no (more) data in the input buffer
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
535 * @retval CX_PROPERTIES_INCOMPLETE_DATA the data in the input buffer is incomplete
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
536 * (fill more data and try again)
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
537 * @retval CX_PROPERTIES_NULL_INPUT the input buffer was never filled
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
538 * @retval CX_PROPERTIES_INVALID_EMPTY_KEY the properties data contains an illegal empty key
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
539 * @retval CX_PROPERTIES_INVALID_MISSING_DELIMITER the properties data contains a line without delimiter
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
540 * @retval CX_PROPERTIES_BUFFER_ALLOC_FAILED an internal allocation was necessary but failed
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
541 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
542 cx_attr_nonnull
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
543 cx_attr_nodiscard
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
544 cx_attr_export
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
545 CxPropertiesStatus cxPropertiesNext(
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
546 CxProperties *prop,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
547 cxstring *key,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
548 cxstring *value
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
549 );
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
550
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
551 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
552 * Creates a properties sink for an UCX map.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
553 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
554 * The values stored in the map will be pointers to freshly allocated,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
555 * zero-terminated C strings (@c char*), which means the @p map should have been
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
556 * created with #CX_STORE_POINTERS.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
557 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
558 * The default stdlib allocator will be used, unless you specify a custom
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
559 * allocator in the optional @c data field of the returned sink.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
560 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
561 * @param map the map that shall consume the k/v-pairs.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
562 * @return the sink
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
563 * @see cxPropertiesLoad()
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
564 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
565 cx_attr_nonnull
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
566 cx_attr_nodiscard
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
567 cx_attr_export
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
568 CxPropertiesSink cxPropertiesMapSink(CxMap *map);
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
569
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
570 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
571 * Creates a properties source based on an UCX string.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
572 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
573 * @param str the string
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
574 * @return the properties source
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
575 * @see cxPropertiesLoad()
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
576 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
577 cx_attr_nodiscard
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
578 cx_attr_export
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
579 CxPropertiesSource cxPropertiesStringSource(cxstring str);
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
580
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
581 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
582 * Creates a properties source based on C string with the specified length.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
583 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
584 * @param str the string
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
585 * @param len the length
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
586 * @return the properties source
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
587 * @see cxPropertiesLoad()
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
588 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
589 cx_attr_nonnull
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
590 cx_attr_nodiscard
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
591 cx_attr_access_r(1, 2)
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
592 cx_attr_export
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
593 CxPropertiesSource cxPropertiesCstrnSource(const char *str, size_t len);
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
594
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
595 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
596 * Creates a properties source based on a C string.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
597 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
598 * The length will be determined with strlen(), so the string MUST be
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
599 * zero-terminated.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
600 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
601 * @param str the string
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
602 * @return the properties source
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
603 * @see cxPropertiesLoad()
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
604 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
605 cx_attr_nonnull
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
606 cx_attr_nodiscard
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
607 cx_attr_cstr_arg(1)
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
608 cx_attr_export
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
609 CxPropertiesSource cxPropertiesCstrSource(const char *str);
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
610
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
611 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
612 * Creates a properties source based on an FILE.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
613 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
614 * @param file the file
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
615 * @param chunk_size how many bytes may be read in one operation
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
616 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
617 * @return the properties source
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
618 * @see cxPropertiesLoad()
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
619 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
620 cx_attr_nonnull
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
621 cx_attr_nodiscard
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
622 cx_attr_access_r(1)
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
623 cx_attr_export
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
624 CxPropertiesSource cxPropertiesFileSource(FILE *file, size_t chunk_size);
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
625
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
626
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
627 /**
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
628 * Loads properties data from a source and transfers it to a sink.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
629 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
630 * This function tries to read as much data from the source as possible.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
631 * When the source was completely consumed and at least on k/v-pair was found,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
632 * the return value will be #CX_PROPERTIES_NO_ERROR.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
633 * When the source was consumed but no k/v-pairs were found, the return value
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
634 * will be #CX_PROPERTIES_NO_DATA.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
635 * In case the source data ends unexpectedly, the #CX_PROPERTIES_INCOMPLETE_DATA
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
636 * is returned. In that case you should call this function again with the same
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
637 * sink and either an updated source or the same source if the source is able to
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
638 * yield the missing data.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
639 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
640 * The other result codes apply, according to their description.
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
641 *
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
642 * @param prop the properties interface
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
643 * @param sink the sink
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
644 * @param source the source
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
645 * @retval CX_PROPERTIES_NO_ERROR (zero) a key/value pair was found
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
646 * @retval CX_PROPERTIES_READ_INIT_FAILED initializing the source failed
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
647 * @retval CX_PROPERTIES_READ_FAILED reading from the source failed
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
648 * @retval CX_PROPERTIES_SINK_FAILED sinking the properties into the sink failed
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
649 * @retval CX_PROPERTIES_NO_DATA the source did not provide any key/value pairs
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
650 * @retval CX_PROPERTIES_INCOMPLETE_DATA the source did not provide enough data
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
651 * @retval CX_PROPERTIES_INVALID_EMPTY_KEY the properties data contains an illegal empty key
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
652 * @retval CX_PROPERTIES_INVALID_MISSING_DELIMITER the properties data contains a line without delimiter
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
653 * @retval CX_PROPERTIES_BUFFER_ALLOC_FAILED an internal allocation was necessary but failed
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
654 */
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
655 cx_attr_nonnull
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
656 cx_attr_export
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
657 CxPropertiesStatus cxPropertiesLoad(
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
658 CxProperties *prop,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
659 CxPropertiesSink sink,
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
660 CxPropertiesSource source
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
661 );
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
662
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
663 #ifdef __cplusplus
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
664 } // extern "C"
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
665 #endif
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
666
e10457d74fe1 update ucx
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
667 #endif // UCX_PROPERTIES_H

mercurial