Debian Codegraph @

storage/mroonga/vendor/groonga/lib/config.c

raw symbols SCIP
1 /* -*- c-basic-offset: 2 -*- */cxx . . $ `<file>/storage/mroonga/vendor/groonga/lib/config.c`/
2 /*
3 Copyright(C) 2015-2016 Brazil
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License version 2.1 as published by the Free Software Foundation.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
17 */
18
19 #include "grn_ctx_impl.h"cxx . . $ `<file>/storage/mroonga/vendor/groonga/lib/grn_ctx_impl.h`/
20 #include "grn_config.h"cxx . . $ `<file>/storage/mroonga/vendor/groonga/lib/grn_config.h`/
21
22 #include <string.h>
23
24 grn_rccxx . . $ grn_rc#
25 grn_config_setcxx . . $ grn_config_set(2afa6b044548fd83).(grn_ctxcxx . . $ grn_ctx# *ctx,
26 const char *key, int32_tcxx . . $ int32_t# key_size,
27 const char *value, int32_tcxx . . $ int32_t# value_size)
28 {
29 grn_objcxx . . $ grn_obj# *db;
30 grn_hashcxx . . $ grn_hash# *config;
31 void *packed_value;
32 grn_idcxx . . $ grn_id# id;
33
34 GRN_API_ENTERcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:45:9`!;
35
36 if (!ctx || !ctx->implcxx . . $ _grn_ctx#impl. || !(db = ctx->implcxx . . $ _grn_ctx#impl.->dbcxx . . $ _grn_ctx_impl#db.)) {
37 ERRcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:143:9`!(GRN_INVALID_ARGUMENT, "[config][set] DB isn't initialized");
38 GRN_API_RETURNcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:59:9`!(ctx->rc);
39 }
40
41 if (key_size == -1) {
42 key_size = strlencxx . . $ strlen(751346f8406fd082).(key);
43 }
44 if (key_size > GRN_CONFIG_MAX_KEY_SIZEcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/config.h:25:9`!) {
45 ERRcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:143:9`!(GRN_INVALID_ARGUMENT,
46 "[config][set] too large key: max=<%d>: <%d>",
47 GRN_CONFIG_MAX_KEY_SIZEcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/config.h:25:9`!, key_size);
48 GRN_API_RETURNcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:59:9`!(ctx->rc);
49 }
50
51 if (value_size == -1) {
52 value_size = strlencxx . . $ strlen(751346f8406fd082).(value);
53 }
54 if (value_size > (int32_tcxx . . $ int32_t#) GRN_CONFIG_MAX_VALUE_SIZEcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/config.h:26:9`!) {
55 ERRcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:143:9`!(GRN_INVALID_ARGUMENT,
56 "[config][set] too large value: max=<%" GRN_FMT_SIZEcxx . . $ `storage/mroonga/vendor/groonga/lib/grn.h:473:10`! ">: <%d>",
57 GRN_CONFIG_MAX_VALUE_SIZEcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/config.h:26:9`!, value_size);
58 GRN_API_RETURNcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:59:9`!(ctx->rc);
59 }
60
61 config = ((grn_dbcxx . . $ grn_db# *)db)->configcxx . . $ _grn_db#config.;
62 {
63 grn_rccxx . . $ grn_rc# rc;
64 rc = grn_io_lockcxx . . $ grn_io_lock(2c16bfdb6acf067b).(ctx, config->iocxx . . $ _grn_hash#io., grn_lock_timeoutcxx . . $ grn_lock_timeout.);
65 if (rc != GRN_SUCCESScxx . . $ GRN_SUCCESS.) {
66 if (ctx->rccxx . . $ _grn_ctx#rc. == GRN_SUCCESScxx . . $ GRN_SUCCESS.) {
67 ERRcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:143:9`!(rc, "[config][set] failed to lock");
68 }
69 GRN_API_RETURNcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:59:9`!(rc);
70 }
71 id = grn_hash_addcxx . . $ grn_hash_add(251a256fc515235e).(ctx, config, key, key_size, &packed_value, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
72 grn_io_unlockcxx . . $ grn_io_unlock(69bc83933b8864bc).(config->iocxx . . $ _grn_hash#io.);
73 }
74 if (id == GRN_ID_NILcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:41:9`! && ctx->rccxx . . $ _grn_ctx#rc. == GRN_SUCCESScxx . . $ GRN_SUCCESS.) {
75 ERRcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:143:9`!(GRN_INVALID_ARGUMENT,
76 "[config][set] failed to set: name=<%.*s>: <%d>",
77 key_size, key, value_size);
78 }
79
80 *((uint32_tcxx . . $ uint32_t# *)packed_value) = (uint32_tcxx . . $ uint32_t#)value_size;
81 grn_memcpycxx . . $ `storage/mroonga/vendor/groonga/include/groonga/portability.h:31:11`!((char *)packed_value + sizeof(uint32_t),
82 value, value_size);
83 ((char *)packed_value)[sizeof(uint32_tcxx . . $ uint32_t#) + value_size] = '\0';
84
85 GRN_API_RETURNcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:59:9`!(ctx->rc);
86 }
87
88 grn_rccxx . . $ grn_rc#
89 grn_config_getcxx . . $ grn_config_get(55f0c7275dd3feda).(grn_ctxcxx . . $ grn_ctx# *ctx,
90 const char *key, int32_tcxx . . $ int32_t# key_size,
91 const char **value, uint32_tcxx . . $ uint32_t# *value_size)
92 {
93 grn_objcxx . . $ grn_obj# *db;
94 grn_hashcxx . . $ grn_hash# *config;
95 grn_idcxx . . $ grn_id# id;
96 void *packed_value;
97
98 GRN_API_ENTERcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:45:9`!;
99
100 if (!ctx || !ctx->implcxx . . $ _grn_ctx#impl. || !(db = ctx->implcxx . . $ _grn_ctx#impl.->dbcxx . . $ _grn_ctx_impl#db.)) {
101 ERRcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:143:9`!(GRN_INVALID_ARGUMENT, "[config][get] DB isn't initialized");
102 GRN_API_RETURNcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:59:9`!(ctx->rc);
103 }
104
105 if (key_size == -1) {
106 key_size = strlencxx . . $ strlen(751346f8406fd082).(key);
107 }
108 if (key_size > GRN_CONFIG_MAX_KEY_SIZEcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/config.h:25:9`!) {
109 ERRcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:143:9`!(GRN_INVALID_ARGUMENT,
110 "[config][get] too large key: max=<%d>: <%d>",
111 GRN_CONFIG_MAX_KEY_SIZEcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/config.h:25:9`!, key_size);
112 GRN_API_RETURNcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:59:9`!(ctx->rc);
113 }
114
115 config = ((grn_dbcxx . . $ grn_db# *)db)->configcxx . . $ _grn_db#config.;
116 id = grn_hash_getcxx . . $ grn_hash_get(4e868e5367e71b67).(ctx, config, key, key_size, &packed_value);
117 if (id == GRN_ID_NILcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:41:9`!) {
118 *value = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
119 *value_size = 0;
120 GRN_API_RETURNcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:59:9`!(GRN_SUCCESS);
121 }
122
123 *value = (char *)packed_value + sizeof(uint32_tcxx . . $ uint32_t#);
124 *value_size = *((uint32_tcxx . . $ uint32_t# *)packed_value);
125 GRN_API_RETURNcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:59:9`!(GRN_SUCCESS);
126 }
127
128 grn_rccxx . . $ grn_rc#
129 grn_config_deletecxx . . $ grn_config_delete(7bd03b5ef0400a0e).(grn_ctxcxx . . $ grn_ctx# *ctx,
130 const char *key, int key_size)
131 {
132 grn_objcxx . . $ grn_obj# *db;
133 grn_hashcxx . . $ grn_hash# *config;
134
135 GRN_API_ENTERcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:45:9`!;
136
137 if (!ctx || !ctx->implcxx . . $ _grn_ctx#impl. || !(db = ctx->implcxx . . $ _grn_ctx#impl.->dbcxx . . $ _grn_ctx_impl#db.)) {
138 ERRcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:143:9`!(GRN_INVALID_ARGUMENT, "[config][delete] DB isn't initialized");
139 GRN_API_RETURNcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:59:9`!(ctx->rc);
140 }
141
142 if (key_size == -1) {
143 key_size = strlencxx . . $ strlen(751346f8406fd082).(key);
144 }
145 if (key_size > GRN_CONFIG_MAX_KEY_SIZEcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/config.h:25:9`!) {
146 ERRcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:143:9`!(GRN_INVALID_ARGUMENT,
147 "[config][delete] too large key: max=<%d>: <%d>",
148 GRN_CONFIG_MAX_KEY_SIZEcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/config.h:25:9`!, key_size);
149 GRN_API_RETURNcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:59:9`!(ctx->rc);
150 }
151
152 config = ((grn_dbcxx . . $ grn_db# *)db)->configcxx . . $ _grn_db#config.;
153 {
154 grn_rccxx . . $ grn_rc# rc;
155 rc = grn_io_lockcxx . . $ grn_io_lock(2c16bfdb6acf067b).(ctx, config->iocxx . . $ _grn_hash#io., grn_lock_timeoutcxx . . $ grn_lock_timeout.);
156 if (rc != GRN_SUCCESScxx . . $ GRN_SUCCESS.) {
157 if (ctx->rccxx . . $ _grn_ctx#rc. == GRN_SUCCESScxx . . $ GRN_SUCCESS.) {
158 ERRcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:143:9`!(rc, "[config][delete] failed to lock");
159 }
160 GRN_API_RETURNcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:59:9`!(rc);
161 }
162 rc = grn_hash_deletecxx . . $ grn_hash_delete(c1719313595c9549).(ctx, config, key, key_size, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
163 grn_io_unlockcxx . . $ grn_io_unlock(69bc83933b8864bc).(config->iocxx . . $ _grn_hash#io.);
164 if (rc != GRN_SUCCESScxx . . $ GRN_SUCCESS.) {
165 if (ctx->rccxx . . $ _grn_ctx#rc. == GRN_SUCCESScxx . . $ GRN_SUCCESS.) {
166 ERRcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:143:9`!(rc, "[config][delete] failed to delete");
167 }
168 }
169 }
170
171 GRN_API_RETURNcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:59:9`!(ctx->rc);
172 }
173
174 grn_objcxx . . $ grn_obj# *
175 grn_config_cursor_opencxx . . $ grn_config_cursor_open(ddec8e3b1327ceae).(grn_ctxcxx . . $ grn_ctx# *ctx)
176 {
177 grn_objcxx . . $ grn_obj# *db;
178 grn_hashcxx . . $ grn_hash# *config;
179 grn_config_cursorcxx . . $ grn_config_cursor# *cursor;
180 grn_idcxx . . $ grn_id# id;
181
182 GRN_API_ENTERcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:45:9`!;
183
184 if (!ctx || !ctx->implcxx . . $ _grn_ctx#impl. || !(db = ctx->implcxx . . $ _grn_ctx#impl.->dbcxx . . $ _grn_ctx_impl#db.)) {
185 ERRcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:143:9`!(GRN_INVALID_ARGUMENT, "[config][cursor][open] DB isn't initialized");
186 GRN_API_RETURNcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:59:9`!(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
187 }
188 config = ((grn_dbcxx . . $ grn_db# *)db)->configcxx . . $ _grn_db#config.;
189
190 cursor = GRN_MALLOCNcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_alloc.h:47:9`!(grn_config_cursor, 1);
191 if (!cursor) {
192 ERRcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:143:9`!(GRN_NO_MEMORY_AVAILABLE,
193 "[config][cursor][open] failed to allocate memory for config cursor");
194 GRN_API_RETURNcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:59:9`!(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
195 }
196
197 GRN_DB_OBJ_SET_TYPEcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:476:9`!(cursor, GRN_CURSOR_CONFIGcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:376:9`!);
198 cursor->hash_cursorcxx . . $ $anonymous_type_ee4dc404ce37f75b_0#hash_cursor. = grn_hash_cursor_opencxx . . $ grn_hash_cursor_open(d9a98562cd457d90).(ctx, config,
199 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, -1,
200 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, -1,
201 0, -1, 0);
202 if (!cursor->hash_cursorcxx . . $ $anonymous_type_ee4dc404ce37f75b_0#hash_cursor.) {
203 GRN_FREEcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_alloc.h:46:9`!(cursor);
204 ERRcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:143:9`!(GRN_NO_MEMORY_AVAILABLE,
205 "[config][cursor][open] failed to allocate memory for hash cursor");
206 GRN_API_RETURNcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:59:9`!(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
207 }
208
209 id = grn_obj_registercxx . . $ grn_obj_register(5739ee2245199e94).(ctx, ctx->implcxx . . $ _grn_ctx#impl.->dbcxx . . $ _grn_ctx_impl#db., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0);
210 DB_OBJcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_db.h:325:9`!(cursor)->headercxx . . $ $anonymous_type_9afa47707a1d1b6d_0#header..domaincxx . . $ _grn_obj_header#domain. = GRN_ID_NILcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:41:9`!;
211 DB_OBJcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_db.h:325:9`!(cursor)->rangecxx . . $ $anonymous_type_9afa47707a1d1b6d_0#range. = GRN_ID_NILcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:41:9`!;
212 grn_db_obj_initcxx . . $ grn_db_obj_init(e57fea19a9dd2af9).(ctx, ctx->implcxx . . $ _grn_ctx#impl.->dbcxx . . $ _grn_ctx_impl#db., id, DB_OBJcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_db.h:325:9`!(cursor));
213
214 GRN_API_RETURNcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:59:9`!((grn_obj *)cursor);
215 }
216
217 grn_rccxx . . $ grn_rc#
218 grn_config_cursor_closecxx . . $ grn_config_cursor_close(dcf8b8063f66b4ff).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_config_cursorcxx . . $ grn_config_cursor# *cursor)
219 {
220 grn_hash_cursor_closecxx . . $ grn_hash_cursor_close(7eec73c6b4523bff).(ctx, cursor->hash_cursorcxx . . $ $anonymous_type_ee4dc404ce37f75b_0#hash_cursor.);
221 GRN_FREEcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_alloc.h:46:9`!(cursor);
222
223 return GRN_SUCCESScxx . . $ GRN_SUCCESS.;
224 }
225
226 grn_boolcxx . . $ grn_bool#
227 grn_config_cursor_nextcxx . . $ grn_config_cursor_next(aa1157f04aaa08f5).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_objcxx . . $ grn_obj# *cursor)
228 {
229 grn_boolcxx . . $ grn_bool# have_next;
230 grn_config_cursorcxx . . $ grn_config_cursor# *config_cursor = (grn_config_cursorcxx . . $ grn_config_cursor# *)cursor;
231
232 GRN_API_ENTERcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:45:9`!;
233
234 have_next = grn_hash_cursor_nextcxx . . $ grn_hash_cursor_next(6f2ad840d1580522).(ctx, config_cursor->hash_cursorcxx . . $ $anonymous_type_ee4dc404ce37f75b_0#hash_cursor.) != GRN_ID_NILcxx . . $ `storage/mroonga/vendor/groonga/include/groonga/groonga.h:41:9`!;
235
236 GRN_API_RETURNcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:59:9`!(have_next);
237 }
238
239 uint32_tcxx . . $ uint32_t#
240 grn_config_cursor_get_keycxx . . $ grn_config_cursor_get_key(4d6594c229367d9b).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_objcxx . . $ grn_obj# *cursor, const char **key)
241 {
242 void *key_raw;
243 uint32_tcxx . . $ uint32_t# key_size;
244 grn_config_cursorcxx . . $ grn_config_cursor# *config_cursor = (grn_config_cursorcxx . . $ grn_config_cursor# *)cursor;
245
246 GRN_API_ENTERcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:45:9`!;
247
248 key_size = grn_hash_cursor_get_keycxx . . $ grn_hash_cursor_get_key(248c0d78df691c42).(ctx, config_cursor->hash_cursorcxx . . $ $anonymous_type_ee4dc404ce37f75b_0#hash_cursor., &key_raw);
249 *key = key_raw;
250
251 GRN_API_RETURNcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:59:9`!(key_size);
252 }
253
254 uint32_tcxx . . $ uint32_t#
255 grn_config_cursor_get_valuecxx . . $ grn_config_cursor_get_value(4d6594c229367d9b).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_objcxx . . $ grn_obj# *cursor, const char **value)
256 {
257 void *value_raw;
258 uint32_tcxx . . $ uint32_t# value_size;
259 uint32_tcxx . . $ uint32_t# value_size_raw;
260 grn_config_cursorcxx . . $ grn_config_cursor# *config_cursor = (grn_config_cursorcxx . . $ grn_config_cursor# *)cursor;
261
262 GRN_API_ENTERcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:45:9`!;
263
264 value_size_raw = grn_hash_cursor_get_valuecxx . . $ grn_hash_cursor_get_value(248c0d78df691c42).(ctx,
265 config_cursor->hash_cursorcxx . . $ $anonymous_type_ee4dc404ce37f75b_0#hash_cursor.,
266 &value_raw);
267 *value = (char *)value_raw + sizeof(uint32_tcxx . . $ uint32_t#);
268 value_size = *((uint32_tcxx . . $ uint32_t# *)value_raw);
269
270 GRN_API_RETURNcxx . . $ `storage/mroonga/vendor/groonga/lib/grn_ctx.h:59:9`!(value_size);
271 }
272
273 /* Deprecated since 5.1.2. Use grn_config_* instead. */
274 grn_rccxx . . $ grn_rc#
275 grn_conf_setcxx . . $ grn_conf_set(2afa6b044548fd83).(grn_ctxcxx . . $ grn_ctx# *ctx,
276 const char *key, int32_tcxx . . $ int32_t# key_size,
277 const char *value, int32_tcxx . . $ int32_t# value_size)
278 {
279 return grn_config_setcxx . . $ grn_config_set(2afa6b044548fd83).(ctx, key, key_size, value, value_size);
280 }
281
282 grn_rccxx . . $ grn_rc#
283 grn_conf_getcxx . . $ grn_conf_get(55f0c7275dd3feda).(grn_ctxcxx . . $ grn_ctx# *ctx,
284 const char *key, int32_tcxx . . $ int32_t# key_size,
285 const char **value, uint32_tcxx . . $ uint32_t# *value_size)
286 {
287 return grn_config_getcxx . . $ grn_config_get(55f0c7275dd3feda).(ctx, key, key_size, value, value_size);
288 }
289