src/ucx/properties.h

Sat, 05 Oct 2019 17:07:16 +0200

author
Mike Becker <universe@uap-core.de>
date
Sat, 05 Oct 2019 17:07:16 +0200
changeset 361
8ee9e23adbd2
parent 278
7b9170c22786
permissions
-rw-r--r--

adds missing include for strncasecmp() to avoid an implicit declaration

108
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
259
2f5dea574a75 modules documentation
Mike Becker <universe@uap-core.de>
parents: 251
diff changeset
4 * Copyright 2017 Mike Becker, Olaf Wintermann All rights reserved.
108
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
d2b1e67b2b48 new properties parser
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
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
130
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
28 /**
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
29 * @file properties.h
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
30 *
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
31 * Load / store utilities for properties files.
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
32 *
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
33 * @author Mike Becker
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
34 * @author Olaf Wintermann
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
35 */
108
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36
120
8170f658f017 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 110
diff changeset
37 #ifndef UCX_PROPERTIES_H
8170f658f017 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 110
diff changeset
38 #define UCX_PROPERTIES_H
108
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39
259
2f5dea574a75 modules documentation
Mike Becker <universe@uap-core.de>
parents: 251
diff changeset
40 #include "ucx.h"
2f5dea574a75 modules documentation
Mike Becker <universe@uap-core.de>
parents: 251
diff changeset
41 #include "map.h"
108
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 #ifdef __cplusplus
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 extern "C" {
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 #endif
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
47 /**
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
48 * UcxProperties object for parsing properties data.
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
49 * Most of the fields are for internal use only. You may configure the
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
50 * properties parser, e.g. by changing the used delimiter or specifying
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
51 * up to three different characters that shall introduce comments.
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
52 */
108
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 typedef struct {
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
54 /**
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
55 * Input buffer (don't set manually).
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
56 * Automatically set by calls to ucx_properties_fill().
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
57 */
108
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 char *buffer;
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
59
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
60 /**
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
61 * Length of the input buffer (don't set manually).
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
62 * Automatically set by calls to ucx_properties_fill().
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
63 */
108
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64 size_t buflen;
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
65
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
66 /**
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
67 * Current buffer position (don't set manually).
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
68 * Used by ucx_properties_next().
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
69 */
108
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 size_t pos;
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
71
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
72 /**
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
73 * Internal temporary buffer (don't set manually).
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
74 * Used by ucx_properties_next().
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
75 */
108
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 char *tmp;
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
77
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
78 /**
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
79 * Internal temporary buffer length (don't set manually).
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
80 * Used by ucx_properties_next().
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
81 */
108
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82 size_t tmplen;
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
83
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
84 /**
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
85 * Internal temporary buffer capacity (don't set manually).
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
86 * Used by ucx_properties_next().
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
87 */
108
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 size_t tmpcap;
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
89
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
90 /**
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
91 * Parser error code.
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
92 * This is always 0 on success and a nonzero value on syntax errors.
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
93 * The value is set by ucx_properties_next().
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
94 */
109
75cb6590358b added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
95 int error;
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
96
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
97 /**
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
98 * The delimiter that shall be used.
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
99 * This is '=' by default.
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
100 */
108
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101 char delimiter;
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
102
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
103 /**
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
104 * The first comment character.
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
105 * This is '#' by default.
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
106 */
108
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
107 char comment1;
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
108
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
109 /**
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
110 * The second comment character.
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
111 * This is not set by default.
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
112 */
108
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
113 char comment2;
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
114
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
115 /**
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
116 * The third comment character.
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
117 * This is not set by default.
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
118 */
108
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119 char comment3;
110
1cf71e56f01e renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
120 } UcxProperties;
108
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122
130
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
123 /**
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
124 * Constructs a new UcxProperties object.
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
125 * @return a pointer to the new UcxProperties object
130
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
126 */
110
1cf71e56f01e renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 109
diff changeset
127 UcxProperties *ucx_properties_new();
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
128
130
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
129 /**
225
a1a068c2c4ef updates documenting comments
Mike Becker <universe@uap-core.de>
parents: 215
diff changeset
130 * Destroys a UcxProperties object.
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
131 * @param prop the UcxProperties object to destroy
130
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
132 */
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
133 void ucx_properties_free(UcxProperties *prop);
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
134
130
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
135 /**
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
136 * Sets the input buffer for the properties parser.
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
137 *
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
138 * After calling this function, you may parse the data by calling
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
139 * ucx_properties_next() until it returns 0. The function ucx_properties2map()
215
e0853e077770 removed some implementation details from documentation + fixed ucx_buffer_write doc
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
140 * is a convenience function that reads as much data as possible by using this
e0853e077770 removed some implementation details from documentation + fixed ucx_buffer_write doc
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
141 * function.
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
142 *
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
143 *
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
144 * @param prop the UcxProperties object
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
145 * @param buf a pointer to the new buffer
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
146 * @param len the payload length of the buffer
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
147 * @see ucx_properties_next()
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
148 * @see ucx_properties2map()
130
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
149 */
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
150 void ucx_properties_fill(UcxProperties *prop, char *buf, size_t len);
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
151
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
152 /**
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
153 * Retrieves the next key/value-pair.
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
154 *
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
155 * This function returns a nonzero value as long as there are key/value-pairs
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
156 * found. If no more key/value-pairs are found, you may refill the input buffer
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
157 * with ucx_properties_fill().
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
158 *
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
159 * <b>Attention:</b> the sstr_t.ptr pointers of the output parameters point to
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
160 * memory within the input buffer of the parser and will get invalid some time.
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
161 * If you want long term copies of the key/value-pairs, use sstrdup() after
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
162 * calling this function.
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
163 *
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
164 * @param prop the UcxProperties object
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
165 * @param name a pointer to the sstr_t that shall contain the property name
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
166 * @param value a pointer to the sstr_t that shall contain the property value
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
167 * @return Nonzero, if a key/value-pair was successfully retrieved
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
168 * @see ucx_properties_fill()
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
169 */
130
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
170 int ucx_properties_next(UcxProperties *prop, sstr_t *name, sstr_t *value);
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
171
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
172 /**
225
a1a068c2c4ef updates documenting comments
Mike Becker <universe@uap-core.de>
parents: 215
diff changeset
173 * Retrieves all available key/value-pairs and puts them into a UcxMap.
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
174 *
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
175 * This is done by successive calls to ucx_properties_next() until no more
278
7b9170c22786 tell the user how allocation of property values works
Mike Becker <universe@uap-core.de>
parents: 259
diff changeset
176 * key/value-pairs can be retrieved.
7b9170c22786 tell the user how allocation of property values works
Mike Becker <universe@uap-core.de>
parents: 259
diff changeset
177 *
7b9170c22786 tell the user how allocation of property values works
Mike Becker <universe@uap-core.de>
parents: 259
diff changeset
178 * The memory for the map values is allocated by the map's own allocator.
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
179 *
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
180 * @param prop the UcxProperties object
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
181 * @param map the target map
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
182 * @return The UcxProperties.error code (i.e. 0 on success).
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
183 * @see ucx_properties_fill()
278
7b9170c22786 tell the user how allocation of property values works
Mike Becker <universe@uap-core.de>
parents: 259
diff changeset
184 * @see UcxMap.allocator
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
185 */
130
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
186 int ucx_properties2map(UcxProperties *prop, UcxMap *map);
109
75cb6590358b added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
187
130
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
188 /**
225
a1a068c2c4ef updates documenting comments
Mike Becker <universe@uap-core.de>
parents: 215
diff changeset
189 * Loads a properties file to a UcxMap.
130
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
190 *
215
e0853e077770 removed some implementation details from documentation + fixed ucx_buffer_write doc
Mike Becker <universe@uap-core.de>
parents: 192
diff changeset
191 * This is a convenience function that reads data from an input
130
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
192 * stream until the end of the stream is reached.
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
193 *
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
194 * @param map the map object to write the key/value-pairs to
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
195 * @param file the <code>FILE*</code> stream to read from
130
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
196 * @return 0 on success, or a non-zero value on error
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
197 *
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
198 * @see ucx_properties_fill()
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
199 * @see ucx_properties2map()
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
200 */
109
75cb6590358b added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
201 int ucx_properties_load(UcxMap *map, FILE *file);
146
aa376dba1ba8 fixed documentation for netbeans parser + added sstrprefix() and sstrsuffix()
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
202
130
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
203 /**
225
a1a068c2c4ef updates documenting comments
Mike Becker <universe@uap-core.de>
parents: 215
diff changeset
204 * Stores a UcxMap to a file.
130
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
205 *
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
206 * The key/value-pairs are written by using the following format:
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
207 *
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
208 * <code>[key] = [value]\\n</code>
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
209 *
133
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
210 * @param map the map to store
0a70e0d36949 finished documentation of UcxProperties
Mike Becker <universe@uap-core.de>
parents: 130
diff changeset
211 * @param file the <code>FILE*</code> stream to write to
130
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
212 * @return 0 on success, or a non-zero value on error
633f15ce2ee4 started documentation of UcxProperties + some fixes
Mike Becker <universe@uap-core.de>
parents: 120
diff changeset
213 */
109
75cb6590358b added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 108
diff changeset
214 int ucx_properties_store(UcxMap *map, FILE *file);
108
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
215
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
216 #ifdef __cplusplus
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
217 }
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
218 #endif
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
219
120
8170f658f017 some fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 110
diff changeset
220 #endif /* UCX_PROPERTIES_H */
108
d2b1e67b2b48 new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
221

mercurial