corosync 3.1.9
icmap.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Red Hat, Inc.
3 *
4 * All rights reserved.
5 *
6 * Author: Jan Friesse (jfriesse@redhat.com)
7 *
8 * This software licensed under BSD license, the text of which follows:
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 *
13 * - Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * - Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * - Neither the name of the Red Hat, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived from this
20 * software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 * THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35#include <config.h>
36
37#include <string.h>
38#include <stdio.h>
39
40#include <corosync/corotypes.h>
41
42#include <qb/qbdefs.h>
43#include <qb/qblist.h>
44#include <corosync/icmap.h>
45
46#define ICMAP_MAX_VALUE_LEN (16*1024)
47
54
55struct icmap_map {
56 qb_map_t *qb_map;
57};
58
59static icmap_map_t icmap_global_map;
60
62 char *key_name;
63 int32_t track_type;
65 void *user_data;
66 struct qb_list_head list;
67};
68
70 char *key_name;
71 int prefix;
72 struct qb_list_head list;
73};
74
75QB_LIST_DECLARE (icmap_ro_access_item_list_head);
76QB_LIST_DECLARE (icmap_track_list_head);
77
78/*
79 * Static functions declarations
80 */
81
82/*
83 * Check if key_name is valid icmap key name. Returns 0 on success, and -1 on fail
84 */
85static int icmap_check_key_name(const char *key_name);
86
87/*
88 * Check that value with given type has correct length value_len. Returns 0 on success,
89 * and -1 on fail
90 */
91static int icmap_check_value_len(const void *value, size_t value_len, icmap_value_types_t type);
92
93/*
94 * Checks if item has same value as value with value_len and given type. Returns 0 if not, otherwise !0.
95 */
96static int icmap_item_eq(const struct icmap_item *item, const void *value, size_t value_len, icmap_value_types_t type);
97
98/*
99 * Checks if given character is valid in key name. Returns 0 if not, otherwise !0.
100 */
101static int icmap_is_valid_name_char(char c);
102
103/*
104 * Helper for getting integer and float value with given type for key key_name and store it in value.
105 */
106static cs_error_t icmap_get_int_r(
107 const icmap_map_t map,
108 const char *key_name,
109 void *value,
111
112/*
113 * Return raw item value data. Internal function used by icmap_get_r which does most
114 * of arguments validity checks but doesn't copy data (it returns raw item data
115 * pointer). It's not very safe tho it's static.
116 */
117static cs_error_t icmap_get_ref_r(
118 const icmap_map_t map,
119 const char *key_name,
120 void **value,
121 size_t *value_len,
123
124/*
125 * Function implementation
126 */
127int32_t icmap_tt_to_qbtt(int32_t track_type)
128{
129 int32_t res = 0;
130
131 if (track_type & ICMAP_TRACK_DELETE) {
132 res |= QB_MAP_NOTIFY_DELETED;
133 }
134
135 if (track_type & ICMAP_TRACK_MODIFY) {
136 res |= QB_MAP_NOTIFY_REPLACED;
137 }
138
139 if (track_type & ICMAP_TRACK_ADD) {
140 res |= QB_MAP_NOTIFY_INSERTED;
141 }
142
143 if (track_type & ICMAP_TRACK_PREFIX) {
144 res |= QB_MAP_NOTIFY_RECURSIVE;
145 }
146
147 return (res);
148}
149
150int32_t icmap_qbtt_to_tt(int32_t track_type)
151{
152 int32_t res = 0;
153
154 if (track_type & QB_MAP_NOTIFY_DELETED) {
155 res |= ICMAP_TRACK_DELETE;
156 }
157
158 if (track_type & QB_MAP_NOTIFY_REPLACED) {
159 res |= ICMAP_TRACK_MODIFY;
160 }
161
162 if (track_type & QB_MAP_NOTIFY_INSERTED) {
163 res |= ICMAP_TRACK_ADD;
164 }
165
166 if (track_type & QB_MAP_NOTIFY_RECURSIVE) {
167 res |= ICMAP_TRACK_PREFIX;
168 }
169
170 return (res);
171}
172
173static void icmap_map_free_cb(uint32_t event,
174 char* key, void* old_value,
175 void* value, void* user_data)
176{
177 struct icmap_item *item = (struct icmap_item *)old_value;
178
179 /*
180 * value == old_value -> fast_adjust_int was used, don't free data
181 */
182 if (item != NULL && value != old_value) {
183 free(item->key_name);
184 free(item);
185 }
186}
187
189{
190 int32_t err;
191
192 *result = malloc(sizeof(struct icmap_map));
193 if (*result == NULL) {
194 return (CS_ERR_NO_MEMORY);
195 }
196
197 (*result)->qb_map = qb_trie_create();
198 if ((*result)->qb_map == NULL) {
199 free(*result);
200 return (CS_ERR_INIT);
201 }
202
203 err = qb_map_notify_add((*result)->qb_map, NULL, icmap_map_free_cb, QB_MAP_NOTIFY_FREE, NULL);
204 if (err != 0) {
205 qb_map_destroy((*result)->qb_map);
206 free(*result);
207 }
208
209 return (qb_to_cs_error(err));
210}
211
213{
214 return (icmap_init_r(&icmap_global_map));
215}
216
217static void icmap_set_ro_access_free(void)
218{
219 struct qb_list_head *iter, *tmp_iter;
220 struct icmap_ro_access_item *icmap_ro_ai;
221
222 qb_list_for_each_safe(iter, tmp_iter, &icmap_ro_access_item_list_head) {
223 icmap_ro_ai = qb_list_entry(iter, struct icmap_ro_access_item, list);
224 qb_list_del(&icmap_ro_ai->list);
225 free(icmap_ro_ai->key_name);
226 free(icmap_ro_ai);
227 }
228}
229
230static void icmap_del_all_track(void)
231{
232 struct qb_list_head *iter, *tmp_iter;
233 struct icmap_track *icmap_track;
234
235 qb_list_for_each_safe(iter, tmp_iter, &icmap_track_list_head) {
236 icmap_track = qb_list_entry(iter, struct icmap_track, list);
237
239 }
240}
241
243{
244
245 qb_map_destroy(map->qb_map);
246 free(map);
247
248 return;
249}
250
251void icmap_fini(void)
252{
253
254 icmap_del_all_track();
255 /*
256 * catch 22 warning:
257 * We need to drop this notify but we can't because it calls icmap_map_free_cb
258 * while destroying the tree to free icmap_item(s).
259 * -> qb_map_notify_del_2(icmap_map, NULL, icmap_map_free_cb, QB_MAP_NOTIFY_FREE, NULL);
260 * and we cannot call it after map_destroy. joy! :)
261 */
262 icmap_fini_r(icmap_global_map);
263 icmap_set_ro_access_free();
264
265 return ;
266}
267
269{
270
271 return (icmap_global_map);
272}
273
274static int icmap_is_valid_name_char(char c)
275{
276 return ((c >= 'a' && c <= 'z') ||
277 (c >= 'A' && c <= 'Z') ||
278 (c >= '0' && c <= '9') ||
279 c == '.' || c == '_' || c == '-' || c == '/' || c == ':');
280}
281
283{
284 int i;
285
286 for (i = 0; i < strlen(key_name); i++) {
287 if (!icmap_is_valid_name_char(key_name[i])) {
288 key_name[i] = '_';
289 }
290 }
291}
292
293static int icmap_check_key_name(const char *key_name)
294{
295 int i;
296
297 if ((strlen(key_name) < ICMAP_KEYNAME_MINLEN) || strlen(key_name) > ICMAP_KEYNAME_MAXLEN) {
298 return (-1);
299 }
300
301 for (i = 0; i < strlen(key_name); i++) {
302 if (!icmap_is_valid_name_char(key_name[i])) {
303 return (-1);
304 }
305 }
306
307 return (0);
308}
309
311{
312 size_t res = 0;
313
314 switch (type) {
315 case ICMAP_VALUETYPE_INT8: res = sizeof(int8_t); break;
316 case ICMAP_VALUETYPE_UINT8: res = sizeof(uint8_t); break;
317 case ICMAP_VALUETYPE_INT16: res = sizeof(int16_t); break;
318 case ICMAP_VALUETYPE_UINT16: res = sizeof(uint16_t); break;
319 case ICMAP_VALUETYPE_INT32: res = sizeof(int32_t); break;
320 case ICMAP_VALUETYPE_UINT32: res = sizeof(uint32_t); break;
321 case ICMAP_VALUETYPE_INT64: res = sizeof(int64_t); break;
322 case ICMAP_VALUETYPE_UINT64: res = sizeof(uint64_t); break;
323 case ICMAP_VALUETYPE_FLOAT: res = sizeof(float); break;
324 case ICMAP_VALUETYPE_DOUBLE: res = sizeof(double); break;
327 res = 0;
328 break;
329 }
330
331 return (res);
332}
333
334static int icmap_check_value_len(const void *value, size_t value_len, icmap_value_types_t type)
335{
336
337 if (value_len > ICMAP_MAX_VALUE_LEN) {
338 return (-1);
339 }
340
342 if (icmap_get_valuetype_len(type) == value_len) {
343 return (0);
344 } else {
345 return (-1);
346 }
347 }
348
350 /*
351 * value_len can be shorter then real string length, but never
352 * longer (+ 1 is because of 0 at the end of string)
353 */
354 if (value_len > strlen((const char *)value) + 1) {
355 return (-1);
356 } else {
357 return (0);
358 }
359 }
360
361 return (0);
362}
363
364static int icmap_item_eq(const struct icmap_item *item, const void *value, size_t value_len, icmap_value_types_t type)
365{
366 size_t ptr_len;
367
368 if (item->type != type) {
369 return (0);
370 }
371
372 if (item->type == ICMAP_VALUETYPE_STRING) {
373 ptr_len = strlen((const char *)value);
374 if (ptr_len > value_len) {
375 ptr_len = value_len;
376 }
377 ptr_len++;
378 } else {
379 ptr_len = value_len;
380 }
381
382 if (item->value_len == ptr_len) {
383 return (memcmp(item->value, value, value_len) == 0);
384 };
385
386 return (0);
387}
388
390 const icmap_map_t map1,
391 const char *key_name1,
392 const icmap_map_t map2,
393 const char *key_name2)
394{
395 struct icmap_item *item1, *item2;
396
397 if (map1 == NULL || key_name1 == NULL || map2 == NULL || key_name2 == NULL) {
398 return (0);
399 }
400
401 item1 = qb_map_get(map1->qb_map, key_name1);
402 item2 = qb_map_get(map2->qb_map, key_name2);
403
404 if (item1 == NULL || item2 == NULL) {
405 return (0);
406 }
407
408 return (icmap_item_eq(item1, item2->value, item2->value_len, item2->type));
409}
410
412 const icmap_map_t map,
413 const char *key_name,
414 const void *value,
415 size_t value_len,
417{
418 struct icmap_item *item;
419 struct icmap_item *new_item;
420 size_t new_value_len;
421 size_t new_item_size;
422
423 if (value == NULL || key_name == NULL) {
424 return (CS_ERR_INVALID_PARAM);
425 }
426
427 if (icmap_check_value_len(value, value_len, type) != 0) {
428 return (CS_ERR_INVALID_PARAM);
429 }
430
431 item = qb_map_get(map->qb_map, key_name);
432 if (item != NULL) {
433 /*
434 * Check that key is really changed
435 */
436 if (icmap_item_eq(item, value, value_len, type)) {
437 return (CS_OK);
438 }
439 } else {
440 if (icmap_check_key_name(key_name) != 0) {
441 return (CS_ERR_NAME_TOO_LONG);
442 }
443 }
444
447 new_value_len = strlen((const char *)value);
448 if (new_value_len > value_len) {
449 new_value_len = value_len;
450 }
451 new_value_len++;
452 } else {
453 new_value_len = value_len;
454 }
455 } else {
456 new_value_len = icmap_get_valuetype_len(type);
457 }
458
459 new_item_size = sizeof(struct icmap_item) + new_value_len;
460 new_item = malloc(new_item_size);
461 if (new_item == NULL) {
462 return (CS_ERR_NO_MEMORY);
463 }
464 memset(new_item, 0, new_item_size);
465
466 if (item == NULL) {
467 new_item->key_name = strdup(key_name);
468 if (new_item->key_name == NULL) {
469 free(new_item);
470 return (CS_ERR_NO_MEMORY);
471 }
472 } else {
473 new_item->key_name = item->key_name;
474 item->key_name = NULL;
475 }
476
477 new_item->type = type;
478 new_item->value_len = new_value_len;
479
480 memcpy(new_item->value, value, new_value_len);
481
482 if (new_item->type == ICMAP_VALUETYPE_STRING) {
483 ((char *)new_item->value)[new_value_len - 1] = 0;
484 }
485
486 qb_map_put(map->qb_map, new_item->key_name, new_item);
487
488 return (CS_OK);
489}
490
492 const char *key_name,
493 const void *value,
494 size_t value_len,
496{
497
498 return (icmap_set_r(icmap_global_map, key_name, value, value_len, type));
499}
500
501cs_error_t icmap_set_int8_r(const icmap_map_t map, const char *key_name, int8_t value)
502{
503
504 return (icmap_set_r(map, key_name, &value, sizeof(value), ICMAP_VALUETYPE_INT8));
505}
506
507cs_error_t icmap_set_uint8_r(const icmap_map_t map, const char *key_name, uint8_t value)
508{
509
510 return (icmap_set_r(map, key_name, &value, sizeof(value), ICMAP_VALUETYPE_UINT8));
511}
512
513cs_error_t icmap_set_int16_r(const icmap_map_t map, const char *key_name, int16_t value)
514{
515
516 return (icmap_set_r(map,key_name, &value, sizeof(value), ICMAP_VALUETYPE_INT16));
517}
518
519cs_error_t icmap_set_uint16_r(const icmap_map_t map, const char *key_name, uint16_t value)
520{
521
522 return (icmap_set_r(map, key_name, &value, sizeof(value), ICMAP_VALUETYPE_UINT16));
523}
524
525cs_error_t icmap_set_int32_r(const icmap_map_t map, const char *key_name, int32_t value)
526{
527
528 return (icmap_set_r(map, key_name, &value, sizeof(value), ICMAP_VALUETYPE_INT32));
529}
530
531cs_error_t icmap_set_uint32_r(const icmap_map_t map, const char *key_name, uint32_t value)
532{
533
534 return (icmap_set_r(map, key_name, &value, sizeof(value), ICMAP_VALUETYPE_UINT32));
535}
536
537cs_error_t icmap_set_int64_r(const icmap_map_t map, const char *key_name, int64_t value)
538{
539
540 return (icmap_set_r(map, key_name, &value, sizeof(value), ICMAP_VALUETYPE_INT64));
541}
542
543cs_error_t icmap_set_uint64_r(const icmap_map_t map, const char *key_name, uint64_t value)
544{
545
546 return (icmap_set_r(map, key_name, &value, sizeof(value), ICMAP_VALUETYPE_UINT64));
547}
548
550{
551
552 return (icmap_set_r(map, key_name, &value, sizeof(value), ICMAP_VALUETYPE_FLOAT));
553}
554
556{
557
558 return (icmap_set_r(map, key_name, &value, sizeof(value), ICMAP_VALUETYPE_DOUBLE));
559}
560
561cs_error_t icmap_set_string_r(const icmap_map_t map, const char *key_name, const char *value)
562{
563
564 if (value == NULL) {
565 return (CS_ERR_INVALID_PARAM);
566 }
567
568 return (icmap_set_r(map, key_name, value, strlen(value), ICMAP_VALUETYPE_STRING));
569}
570
572{
573
574 return (icmap_set_int8_r(icmap_global_map, key_name, value));
575}
576
578{
579
580 return (icmap_set_uint8_r(icmap_global_map, key_name, value));
581}
582
584{
585
586 return (icmap_set_int16_r(icmap_global_map, key_name, value));
587}
588
590{
591
592 return (icmap_set_uint16_r(icmap_global_map, key_name, value));
593}
594
596{
597
598 return (icmap_set_int32_r(icmap_global_map, key_name, value));
599}
600
602{
603
604 return (icmap_set_uint32_r(icmap_global_map, key_name, value));
605}
606
608{
609
610 return (icmap_set_int64_r(icmap_global_map, key_name, value));
611}
612
614{
615
616 return (icmap_set_uint64_r(icmap_global_map, key_name, value));
617}
618
620{
621
622 return (icmap_set_float_r(icmap_global_map, key_name, value));
623}
624
626{
627
628 return (icmap_set_double_r(icmap_global_map, key_name, value));
629}
630
631cs_error_t icmap_set_string(const char *key_name, const char *value)
632{
633
634 return (icmap_set_string_r(icmap_global_map, key_name, value));
635}
636
638{
639 struct icmap_item *item;
640
641 if (key_name == NULL) {
642 return (CS_ERR_INVALID_PARAM);
643 }
644
645 item = qb_map_get(map->qb_map, key_name);
646 if (item == NULL) {
647 return (CS_ERR_NOT_EXIST);
648 }
649
650 if (qb_map_rm(map->qb_map, item->key_name) != QB_TRUE) {
651 return (CS_ERR_NOT_EXIST);
652 }
653
654 return (CS_OK);
655}
656
658{
659
660 return (icmap_delete_r(icmap_global_map, key_name));
661}
662
663static cs_error_t icmap_get_ref_r(
664 const icmap_map_t map,
665 const char *key_name,
666 void **value,
667 size_t *value_len,
669{
670 struct icmap_item *item;
671
672 if (key_name == NULL) {
673 return (CS_ERR_INVALID_PARAM);
674 }
675
676 item = qb_map_get(map->qb_map, key_name);
677 if (item == NULL) {
678 return (CS_ERR_NOT_EXIST);
679 }
680
681 if (type != NULL) {
682 *type = item->type;
683 }
684
685 if (value_len != NULL) {
686 *value_len = item->value_len;
687 }
688
689 if (value != NULL) {
690 *value = item->value;
691 }
692
693 return (CS_OK);
694}
695
697 const icmap_map_t map,
698 const char *key_name,
699 void *value,
700 size_t *value_len,
702{
703 cs_error_t res;
704 void *tmp_value;
705 size_t tmp_value_len;
706
707 res = icmap_get_ref_r(map, key_name, &tmp_value, &tmp_value_len, type);
708 if (res != CS_OK) {
709 return (res);
710 }
711
712 if (value == NULL) {
713 if (value_len != NULL) {
714 *value_len = tmp_value_len;
715 }
716 } else {
717 if (value_len == NULL || *value_len < tmp_value_len) {
718 return (CS_ERR_INVALID_PARAM);
719 }
720
721 *value_len = tmp_value_len;
722
723 memcpy(value, tmp_value, tmp_value_len);
724 }
725
726 return (CS_OK);
727}
728
730 const char *key_name,
731 void *value,
732 size_t *value_len,
734{
735
736 return (icmap_get_r(icmap_global_map, key_name, value, value_len, type));
737}
738
740{
741 cs_error_t res;
742 size_t str_len;
744
745 res = icmap_get_r(map, key_name, NULL, &str_len, &type);
746 if (res != CS_OK || type != ICMAP_VALUETYPE_STRING) {
747 if (res == CS_OK) {
749 }
750
751 goto return_error;
752 }
753
754 *str = malloc(str_len);
755 if (*str == NULL) {
756 res = CS_ERR_NO_MEMORY;
757
758 goto return_error;
759 }
760
761 res = icmap_get_r(map, key_name, *str, &str_len, &type);
762 if (res != CS_OK) {
763 free(*str);
764 goto return_error;
765 }
766
767 return (CS_OK);
768
769return_error:
770 return (res);
771}
772
773static cs_error_t icmap_get_int_r(
774 const icmap_map_t map,
775 const char *key_name,
776 void *value,
778{
779 char key_value[16];
780 size_t key_size;
781 cs_error_t err;
782 icmap_value_types_t key_type;
783
784 key_size = sizeof(key_value);
785 memset(key_value, 0, key_size);
786
787 err = icmap_get_r(map, key_name, key_value, &key_size, &key_type);
788 if (err != CS_OK)
789 return (err);
790
791 if (key_type != type) {
792 return (CS_ERR_INVALID_PARAM);
793 }
794
795 memcpy(value, key_value, icmap_get_valuetype_len(key_type));
796
797 return (CS_OK);
798}
799
800cs_error_t icmap_get_int8_r(const icmap_map_t map, const char *key_name, int8_t *i8)
801{
802
803 return (icmap_get_int_r(map, key_name, i8, ICMAP_VALUETYPE_INT8));
804}
805
806cs_error_t icmap_get_uint8_r(const icmap_map_t map, const char *key_name, uint8_t *u8)
807{
808
809 return (icmap_get_int_r(map, key_name, u8, ICMAP_VALUETYPE_UINT8));
810}
811
812cs_error_t icmap_get_int16_r(const icmap_map_t map, const char *key_name, int16_t *i16)
813{
814
815 return (icmap_get_int_r(map, key_name, i16, ICMAP_VALUETYPE_INT16));
816}
817
818cs_error_t icmap_get_uint16_r(const icmap_map_t map, const char *key_name, uint16_t *u16)
819{
820
821 return (icmap_get_int_r(map, key_name, u16, ICMAP_VALUETYPE_UINT16));
822}
823
824cs_error_t icmap_get_int32_r(const icmap_map_t map, const char *key_name, int32_t *i32)
825{
826
827 return (icmap_get_int_r(map, key_name, i32, ICMAP_VALUETYPE_INT32));
828}
829
830cs_error_t icmap_get_uint32_r(const icmap_map_t map, const char *key_name, uint32_t *u32)
831{
832
833 return (icmap_get_int_r(map, key_name, u32, ICMAP_VALUETYPE_UINT32));
834}
835
836cs_error_t icmap_get_int64_r(const icmap_map_t map, const char *key_name, int64_t *i64)
837{
838
839 return(icmap_get_int_r(map, key_name, i64, ICMAP_VALUETYPE_INT64));
840}
841
842cs_error_t icmap_get_uint64_r(const icmap_map_t map, const char *key_name, uint64_t *u64)
843{
844
845 return (icmap_get_int_r(map, key_name, u64, ICMAP_VALUETYPE_UINT64));
846}
847
848cs_error_t icmap_get_float_r(const icmap_map_t map, const char *key_name, float *flt)
849{
850
851 return (icmap_get_int_r(map, key_name, flt, ICMAP_VALUETYPE_FLOAT));
852}
853
854cs_error_t icmap_get_double_r(const icmap_map_t map, const char *key_name, double *dbl)
855{
856
857 return (icmap_get_int_r(map, key_name, dbl, ICMAP_VALUETYPE_DOUBLE));
858}
859
860cs_error_t icmap_get_string(const char *key_name, char **str)
861{
862
863 return (icmap_get_string_r(icmap_global_map, key_name, str));
864}
865
866cs_error_t icmap_get_int8(const char *key_name, int8_t *i8)
867{
868
869 return (icmap_get_int8_r(icmap_global_map, key_name, i8));
870}
871
872cs_error_t icmap_get_uint8(const char *key_name, uint8_t *u8)
873{
874
875 return (icmap_get_uint8_r(icmap_global_map, key_name, u8));
876}
877
878cs_error_t icmap_get_int16(const char *key_name, int16_t *i16)
879{
880
881 return (icmap_get_int16_r(icmap_global_map, key_name, i16));
882}
883
884cs_error_t icmap_get_uint16(const char *key_name, uint16_t *u16)
885{
886
887 return (icmap_get_uint16_r(icmap_global_map, key_name, u16));
888}
889
890cs_error_t icmap_get_int32(const char *key_name, int32_t *i32)
891{
892
893 return (icmap_get_int32_r(icmap_global_map, key_name, i32));
894}
895
896cs_error_t icmap_get_uint32(const char *key_name, uint32_t *u32)
897{
898
899 return (icmap_get_uint32_r(icmap_global_map, key_name, u32));
900}
901
902cs_error_t icmap_get_int64(const char *key_name, int64_t *i64)
903{
904
905 return(icmap_get_int64_r(icmap_global_map, key_name, i64));
906}
907
908cs_error_t icmap_get_uint64(const char *key_name, uint64_t *u64)
909{
910
911 return (icmap_get_uint64_r(icmap_global_map, key_name, u64));
912}
913
914cs_error_t icmap_get_float(const char *key_name, float *flt)
915{
916
917 return (icmap_get_float_r(icmap_global_map, key_name, flt));
918}
919
920cs_error_t icmap_get_double(const char *key_name, double *dbl)
921{
922
923 return (icmap_get_double_r(icmap_global_map, key_name, dbl));
924}
925
927 const icmap_map_t map,
928 const char *key_name,
929 int32_t step)
930{
931 struct icmap_item *item;
932 uint8_t u8;
933 uint16_t u16;
934 uint32_t u32;
935 uint64_t u64;
936 cs_error_t err = CS_OK;
937
938 if (key_name == NULL) {
939 return (CS_ERR_INVALID_PARAM);
940 }
941
942 item = qb_map_get(map->qb_map, key_name);
943 if (item == NULL) {
944 return (CS_ERR_NOT_EXIST);
945 }
946
947 switch (item->type) {
950 memcpy(&u8, item->value, sizeof(u8));
951 u8 += step;
952 err = icmap_set(key_name, &u8, sizeof(u8), item->type);
953 break;
956 memcpy(&u16, item->value, sizeof(u16));
957 u16 += step;
958 err = icmap_set(key_name, &u16, sizeof(u16), item->type);
959 break;
962 memcpy(&u32, item->value, sizeof(u32));
963 u32 += step;
964 err = icmap_set(key_name, &u32, sizeof(u32), item->type);
965 break;
968 memcpy(&u64, item->value, sizeof(u64));
969 u64 += step;
970 err = icmap_set(key_name, &u64, sizeof(u64), item->type);
971 break;
977 break;
978 }
979
980 return (err);
981}
982
984 const char *key_name,
985 int32_t step)
986{
987
988 return (icmap_adjust_int_r(icmap_global_map, key_name, step));
989}
990
992 const icmap_map_t map,
993 const char *key_name,
994 int32_t step)
995{
996 struct icmap_item *item;
997 cs_error_t err = CS_OK;
998
999 if (key_name == NULL) {
1000 return (CS_ERR_INVALID_PARAM);
1001 }
1002
1003 item = qb_map_get(map->qb_map, key_name);
1004 if (item == NULL) {
1005 return (CS_ERR_NOT_EXIST);
1006 }
1007
1008 switch (item->type) {
1011 *(uint8_t *)item->value += step;
1012 break;
1015 *(uint16_t *)item->value += step;
1016 break;
1019 *(uint32_t *)item->value += step;
1020 break;
1023 *(uint64_t *)item->value += step;
1024 break;
1030 break;
1031 }
1032
1033 if (err == CS_OK) {
1034 qb_map_put(map->qb_map, item->key_name, item);
1035 }
1036
1037 return (err);
1038}
1039
1041 const char *key_name,
1042 int32_t step)
1043{
1044
1045 return (icmap_fast_adjust_int_r(icmap_global_map, key_name, step));
1046}
1047
1049{
1050 return (icmap_adjust_int_r(map, key_name, 1));
1051}
1052
1054{
1055 return (icmap_inc_r(icmap_global_map, key_name));
1056}
1057
1059{
1060 return (icmap_adjust_int_r(map, key_name, -1));
1061}
1062
1064{
1065 return (icmap_dec_r(icmap_global_map, key_name));
1066}
1067
1069{
1070 return (icmap_fast_adjust_int_r(map, key_name, 1));
1071}
1072
1074{
1075 return (icmap_fast_inc_r(icmap_global_map, key_name));
1076}
1077
1079{
1080 return (icmap_fast_adjust_int_r(map, key_name, -1));
1081}
1082
1084{
1085 return (icmap_fast_dec_r(icmap_global_map, key_name));
1086}
1087
1088icmap_iter_t icmap_iter_init_r(const icmap_map_t map, const char *prefix)
1089{
1090 return (qb_map_pref_iter_create(map->qb_map, prefix));
1091}
1092
1094{
1095 return (icmap_iter_init_r(icmap_global_map, prefix));
1096}
1097
1098
1100{
1101 struct icmap_item *item;
1102 const char *res;
1103
1104 res = qb_map_iter_next(iter, (void **)&item);
1105 if (res == NULL) {
1106 return (res);
1107 }
1108
1109 if (value_len != NULL) {
1110 *value_len = item->value_len;
1111 }
1112
1113 if (type != NULL) {
1114 *type = item->type;
1115 }
1116
1117 return (res);
1118}
1119
1121{
1122 qb_map_iter_free(iter);
1123}
1124
1125static void icmap_notify_fn(uint32_t event, char *key, void *old_value, void *value, void *user_data)
1126{
1128 struct icmap_item *new_item = (struct icmap_item *)value;
1129 struct icmap_item *old_item = (struct icmap_item *)old_value;
1130 struct icmap_notify_value new_val;
1131 struct icmap_notify_value old_val;
1132
1133 if (value == NULL && old_value == NULL) {
1134 return ;
1135 }
1136
1137 if (new_item != NULL) {
1138 new_val.type = new_item->type;
1139 new_val.len = new_item->value_len;
1140 new_val.data = new_item->value;
1141 } else {
1142 memset(&new_val, 0, sizeof(new_val));
1143 }
1144
1145 /*
1146 * old_item == new_item if fast functions are used -> don't fill old value
1147 */
1148 if (old_item != NULL && old_item != new_item) {
1149 old_val.type = old_item->type;
1150 old_val.len = old_item->value_len;
1151 old_val.data = old_item->value;
1152 } else {
1153 memset(&old_val, 0, sizeof(old_val));
1154 }
1155
1157 key,
1158 new_val,
1159 old_val,
1161}
1162
1164 const char *key_name,
1165 int32_t track_type,
1166 icmap_notify_fn_t notify_fn,
1167 void *user_data,
1169{
1170 int32_t err;
1171
1172 if (notify_fn == NULL || icmap_track == NULL) {
1173 return (CS_ERR_INVALID_PARAM);
1174 }
1175
1177 return (CS_ERR_INVALID_PARAM);
1178 }
1179
1180 *icmap_track = malloc(sizeof(**icmap_track));
1181 if (*icmap_track == NULL) {
1182 return (CS_ERR_NO_MEMORY);
1183 }
1184 memset(*icmap_track, 0, sizeof(**icmap_track));
1185
1186 if (key_name != NULL) {
1187 (*icmap_track)->key_name = strdup(key_name);
1188 };
1189
1190 (*icmap_track)->track_type = track_type;
1191 (*icmap_track)->notify_fn = notify_fn;
1192 (*icmap_track)->user_data = user_data;
1193
1194 if ((err = qb_map_notify_add(icmap_global_map->qb_map, (*icmap_track)->key_name, icmap_notify_fn,
1195 icmap_tt_to_qbtt(track_type), *icmap_track)) != 0) {
1196 free((*icmap_track)->key_name);
1197 free(*icmap_track);
1198
1199 return (qb_to_cs_error(err));
1200 }
1201
1202 qb_list_init(&(*icmap_track)->list);
1203 qb_list_add (&(*icmap_track)->list, &icmap_track_list_head);
1204
1205 return (CS_OK);
1206}
1207
1209{
1210 int32_t err;
1211
1212 if ((err = qb_map_notify_del_2(icmap_global_map->qb_map, icmap_track->key_name,
1213 icmap_notify_fn, icmap_tt_to_qbtt(icmap_track->track_type), icmap_track)) != 0) {
1214 return (qb_to_cs_error(err));
1215 }
1216
1217 qb_list_del(&icmap_track->list);
1218 free(icmap_track->key_name);
1219 free(icmap_track);
1220
1221 return (CS_OK);
1222}
1223
1228
1229cs_error_t icmap_set_ro_access(const char *key_name, int prefix, int ro_access)
1230{
1231 struct qb_list_head *iter, *tmp_iter;
1232 struct icmap_ro_access_item *icmap_ro_ai;
1233
1234 qb_list_for_each_safe(iter, tmp_iter, &icmap_ro_access_item_list_head) {
1235 icmap_ro_ai = qb_list_entry(iter, struct icmap_ro_access_item, list);
1236
1237 if (icmap_ro_ai->prefix == prefix && strcmp(key_name, icmap_ro_ai->key_name) == 0) {
1238 /*
1239 * We found item
1240 */
1241 if (ro_access) {
1242 return (CS_ERR_EXIST);
1243 } else {
1244 qb_list_del(&icmap_ro_ai->list);
1245 free(icmap_ro_ai->key_name);
1246 free(icmap_ro_ai);
1247
1248 return (CS_OK);
1249 }
1250 }
1251 }
1252
1253 if (!ro_access) {
1254 return (CS_ERR_NOT_EXIST);
1255 }
1256
1257 icmap_ro_ai = malloc(sizeof(*icmap_ro_ai));
1258 if (icmap_ro_ai == NULL) {
1259 return (CS_ERR_NO_MEMORY);
1260 }
1261
1262 memset(icmap_ro_ai, 0, sizeof(*icmap_ro_ai));
1263 icmap_ro_ai->key_name = strdup(key_name);
1264 if (icmap_ro_ai->key_name == NULL) {
1265 free(icmap_ro_ai);
1266 return (CS_ERR_NO_MEMORY);
1267 }
1268
1269 icmap_ro_ai->prefix = prefix;
1270 qb_list_init(&icmap_ro_ai->list);
1271 qb_list_add (&icmap_ro_ai->list, &icmap_ro_access_item_list_head);
1272
1273 return (CS_OK);
1274}
1275
1277{
1278 struct qb_list_head *iter;
1279 struct icmap_ro_access_item *icmap_ro_ai;
1280
1281 qb_list_for_each(iter, &icmap_ro_access_item_list_head) {
1282 icmap_ro_ai = qb_list_entry(iter, struct icmap_ro_access_item, list);
1283
1284 if (icmap_ro_ai->prefix) {
1285 if (strlen(icmap_ro_ai->key_name) > strlen(key_name))
1286 continue;
1287
1288 if (strncmp(icmap_ro_ai->key_name, key_name, strlen(icmap_ro_ai->key_name)) == 0) {
1289 return (CS_TRUE);
1290 }
1291 } else {
1292 if (strcmp(icmap_ro_ai->key_name, key_name) == 0) {
1293 return (CS_TRUE);
1294 }
1295 }
1296 }
1297
1298 return (CS_FALSE);
1299
1300}
1301
1303{
1304 icmap_iter_t iter;
1305 size_t value_len;
1306 icmap_value_types_t value_type;
1307 const char *key_name;
1308 cs_error_t err;
1309 void *value;
1310
1311 iter = icmap_iter_init_r(src_map, NULL);
1312 if (iter == NULL) {
1313 return (CS_ERR_NO_MEMORY);
1314 }
1315
1316 err = CS_OK;
1317
1318 while ((key_name = icmap_iter_next(iter, &value_len, &value_type)) != NULL) {
1319 err = icmap_get_ref_r(src_map, key_name, &value, &value_len, &value_type);
1320 if (err != CS_OK) {
1321 goto exit_iter_finalize;
1322 }
1323
1324 err = icmap_set_r(dst_map, key_name, value, value_len, value_type);
1325 if (err != CS_OK) {
1326 goto exit_iter_finalize;
1327 }
1328 }
1329
1330exit_iter_finalize:
1331 icmap_iter_finalize(iter);
1332
1333 return (err);
1334}
#define CS_FALSE
Definition corotypes.h:53
cs_error_t qb_to_cs_error(int result)
qb_to_cs_error
#define CS_TRUE
Definition corotypes.h:54
cs_error_t
The cs_error_t enum.
Definition corotypes.h:98
@ CS_ERR_NAME_TOO_LONG
Definition corotypes.h:111
@ CS_ERR_NO_MEMORY
Definition corotypes.h:106
@ CS_OK
Definition corotypes.h:99
@ CS_ERR_INVALID_PARAM
Definition corotypes.h:105
@ CS_ERR_NOT_EXIST
Definition corotypes.h:110
@ CS_ERR_INIT
Definition corotypes.h:102
@ CS_ERR_EXIST
Definition corotypes.h:112
uint32_t value
int32_t icmap_tt_to_qbtt(int32_t track_type)
Definition icmap.c:127
cs_error_t icmap_set_int8_r(const icmap_map_t map, const char *key_name, int8_t value)
Definition icmap.c:501
icmap_iter_t icmap_iter_init_r(const icmap_map_t map, const char *prefix)
icmap_iter_init_r
Definition icmap.c:1088
cs_error_t icmap_get_uint8(const char *key_name, uint8_t *u8)
Definition icmap.c:872
cs_error_t icmap_get_string_r(icmap_map_t map, const char *key_name, char **str)
Definition icmap.c:739
cs_error_t icmap_fast_adjust_int_r(const icmap_map_t map, const char *key_name, int32_t step)
icmap_fast_adjust_int_r
Definition icmap.c:991
cs_error_t icmap_get_uint16(const char *key_name, uint16_t *u16)
Definition icmap.c:884
cs_error_t icmap_get_float_r(const icmap_map_t map, const char *key_name, float *flt)
Definition icmap.c:848
cs_error_t icmap_get_uint32(const char *key_name, uint32_t *u32)
Definition icmap.c:896
cs_error_t icmap_set_int16_r(const icmap_map_t map, const char *key_name, int16_t value)
Definition icmap.c:513
cs_error_t icmap_set_uint8(const char *key_name, uint8_t value)
Definition icmap.c:577
cs_error_t icmap_set_uint16_r(const icmap_map_t map, const char *key_name, uint16_t value)
Definition icmap.c:519
cs_error_t icmap_set(const char *key_name, const void *value, size_t value_len, icmap_value_types_t type)
Store value with value_len length and type as key_name name in global icmap.
Definition icmap.c:491
cs_error_t icmap_adjust_int(const char *key_name, int32_t step)
icmap_adjust_int
Definition icmap.c:983
cs_error_t icmap_get_int64(const char *key_name, int64_t *i64)
Definition icmap.c:902
cs_error_t icmap_set_ro_access(const char *key_name, int prefix, int ro_access)
Set read-only access for given key (key_name) or prefix, If prefix is set.
Definition icmap.c:1229
cs_error_t icmap_set_uint32_r(const icmap_map_t map, const char *key_name, uint32_t value)
Definition icmap.c:531
cs_error_t icmap_delete(const char *key_name)
Delete key from map.
Definition icmap.c:657
cs_error_t icmap_fast_dec_r(const icmap_map_t map, const char *key_name)
icmap_fast_dec_r
Definition icmap.c:1078
cs_error_t icmap_set_float_r(const icmap_map_t map, const char *key_name, float value)
Definition icmap.c:549
#define ICMAP_MAX_VALUE_LEN
Definition icmap.c:46
cs_error_t icmap_set_int32(const char *key_name, int32_t value)
Definition icmap.c:595
cs_error_t icmap_delete_r(const icmap_map_t map, const char *key_name)
icmap_delete_r
Definition icmap.c:637
cs_error_t icmap_get_uint8_r(const icmap_map_t map, const char *key_name, uint8_t *u8)
Definition icmap.c:806
cs_error_t icmap_set_uint8_r(const icmap_map_t map, const char *key_name, uint8_t value)
Definition icmap.c:507
cs_error_t icmap_set_uint16(const char *key_name, uint16_t value)
Definition icmap.c:589
cs_error_t icmap_dec_r(const icmap_map_t map, const char *key_name)
icmap_dec_r
Definition icmap.c:1058
cs_error_t icmap_set_int64(const char *key_name, int64_t value)
Definition icmap.c:607
cs_error_t icmap_track_add(const char *key_name, int32_t track_type, icmap_notify_fn_t notify_fn, void *user_data, icmap_track_t *icmap_track)
Add tracking function for given key_name.
Definition icmap.c:1163
cs_error_t icmap_set_string(const char *key_name, const char *value)
Definition icmap.c:631
cs_error_t icmap_set_r(const icmap_map_t map, const char *key_name, const void *value, size_t value_len, icmap_value_types_t type)
Reentrant version of icmap_set.
Definition icmap.c:411
int32_t icmap_qbtt_to_tt(int32_t track_type)
Definition icmap.c:150
cs_error_t icmap_inc(const char *key_name)
Increase stored value by one.
Definition icmap.c:1053
cs_error_t icmap_set_int64_r(const icmap_map_t map, const char *key_name, int64_t value)
Definition icmap.c:537
cs_error_t icmap_set_double(const char *key_name, double value)
Definition icmap.c:625
cs_error_t icmap_set_int8(const char *key_name, int8_t value)
Definition icmap.c:571
size_t icmap_get_valuetype_len(icmap_value_types_t type)
Definition icmap.c:310
int icmap_key_value_eq(const icmap_map_t map1, const char *key_name1, const icmap_map_t map2, const char *key_name2)
Compare value of key with name key_name1 in map1 with key with name key_name2 in map2.
Definition icmap.c:389
cs_error_t icmap_get_float(const char *key_name, float *flt)
Definition icmap.c:914
cs_error_t icmap_get_double(const char *key_name, double *dbl)
Definition icmap.c:920
cs_error_t icmap_get_int8_r(const icmap_map_t map, const char *key_name, int8_t *i8)
Definition icmap.c:800
cs_error_t icmap_set_uint64_r(const icmap_map_t map, const char *key_name, uint64_t value)
Definition icmap.c:543
cs_error_t icmap_fast_dec(const char *key_name)
Decrease stored value by one.
Definition icmap.c:1083
icmap_iter_t icmap_iter_init(const char *prefix)
Initialize iterator with given prefix.
Definition icmap.c:1093
cs_error_t icmap_set_double_r(const icmap_map_t map, const char *key_name, double value)
Definition icmap.c:555
cs_error_t icmap_get_uint16_r(const icmap_map_t map, const char *key_name, uint16_t *u16)
Definition icmap.c:818
cs_error_t icmap_copy_map(icmap_map_t dst_map, const icmap_map_t src_map)
Copy content of src_map icmap to dst_map icmap.
Definition icmap.c:1302
cs_error_t icmap_init_r(icmap_map_t *result)
Initialize additional (local, reentrant) icmap_map.
Definition icmap.c:188
cs_error_t icmap_set_int32_r(const icmap_map_t map, const char *key_name, int32_t value)
Definition icmap.c:525
cs_error_t icmap_get_int64_r(const icmap_map_t map, const char *key_name, int64_t *i64)
Definition icmap.c:836
void icmap_convert_name_to_valid_name(char *key_name)
Converts given key_name to valid key name (replacing all prohibited characters by _)
Definition icmap.c:282
cs_error_t icmap_fast_adjust_int(const char *key_name, int32_t step)
icmap_fast_adjust_int
Definition icmap.c:1040
const char * icmap_iter_next(icmap_iter_t iter, size_t *value_len, icmap_value_types_t *type)
Return next item in iterator iter.
Definition icmap.c:1099
cs_error_t icmap_fast_inc(const char *key_name)
Increase stored value by one.
Definition icmap.c:1073
cs_error_t icmap_inc_r(const icmap_map_t map, const char *key_name)
icmap_inc_r
Definition icmap.c:1048
icmap_map_t icmap_get_global_map(void)
Return global icmap.
Definition icmap.c:268
cs_error_t icmap_get(const char *key_name, void *value, size_t *value_len, icmap_value_types_t *type)
Retrieve value of key key_name and store it in user preallocated value pointer.
Definition icmap.c:729
cs_error_t icmap_get_double_r(const icmap_map_t map, const char *key_name, double *dbl)
Definition icmap.c:854
cs_error_t icmap_set_string_r(const icmap_map_t map, const char *key_name, const char *value)
Definition icmap.c:561
void icmap_iter_finalize(icmap_iter_t iter)
Finalize iterator.
Definition icmap.c:1120
void icmap_fini_r(const icmap_map_t map)
Finalize local, reentrant icmap.
Definition icmap.c:242
cs_error_t icmap_get_int32_r(const icmap_map_t map, const char *key_name, int32_t *i32)
Definition icmap.c:824
cs_error_t icmap_get_r(const icmap_map_t map, const char *key_name, void *value, size_t *value_len, icmap_value_types_t *type)
Same as icmap_get but it's reentrant and operates on given icmap_map.
Definition icmap.c:696
cs_error_t icmap_get_int32(const char *key_name, int32_t *i32)
Definition icmap.c:890
cs_error_t icmap_init(void)
Initialize global icmap.
Definition icmap.c:212
cs_error_t icmap_track_delete(icmap_track_t icmap_track)
Remove previously added track.
Definition icmap.c:1208
cs_error_t icmap_set_uint64(const char *key_name, uint64_t value)
Definition icmap.c:613
cs_error_t icmap_dec(const char *key_name)
Decrease stored value by one.
Definition icmap.c:1063
void icmap_fini(void)
Finalize global icmap.
Definition icmap.c:251
cs_error_t icmap_get_uint32_r(const icmap_map_t map, const char *key_name, uint32_t *u32)
Definition icmap.c:830
cs_error_t icmap_get_uint64_r(const icmap_map_t map, const char *key_name, uint64_t *u64)
Definition icmap.c:842
QB_LIST_DECLARE(icmap_ro_access_item_list_head)
cs_error_t icmap_get_int16_r(const icmap_map_t map, const char *key_name, int16_t *i16)
Definition icmap.c:812
cs_error_t icmap_set_uint32(const char *key_name, uint32_t value)
Definition icmap.c:601
void * icmap_track_get_user_data(icmap_track_t icmap_track)
Return user data associated with given track.
Definition icmap.c:1224
cs_error_t icmap_set_int16(const char *key_name, int16_t value)
Definition icmap.c:583
cs_error_t icmap_get_uint64(const char *key_name, uint64_t *u64)
Definition icmap.c:908
cs_error_t icmap_get_string(const char *key_name, char **str)
Shortcut for icmap_get for string type.
Definition icmap.c:860
cs_error_t icmap_get_int16(const char *key_name, int16_t *i16)
Definition icmap.c:878
cs_error_t icmap_adjust_int_r(const icmap_map_t map, const char *key_name, int32_t step)
icmap_adjust_int_r
Definition icmap.c:926
int icmap_is_key_ro(const char *key_name)
Check in given key is read only.
Definition icmap.c:1276
cs_error_t icmap_set_float(const char *key_name, float value)
Definition icmap.c:619
cs_error_t icmap_get_int8(const char *key_name, int8_t *i8)
Definition icmap.c:866
cs_error_t icmap_fast_inc_r(const icmap_map_t map, const char *key_name)
icmap_fast_inc_r
Definition icmap.c:1068
#define ICMAP_TRACK_MODIFY
Definition icmap.h:78
#define ICMAP_KEYNAME_MINLEN
Minimum lenght of key in icmap.
Definition icmap.h:53
icmap_value_types_t
Possible types of value.
Definition icmap.h:58
@ ICMAP_VALUETYPE_UINT64
Definition icmap.h:66
@ ICMAP_VALUETYPE_BINARY
Definition icmap.h:70
@ ICMAP_VALUETYPE_UINT8
Definition icmap.h:60
@ ICMAP_VALUETYPE_INT8
Definition icmap.h:59
@ ICMAP_VALUETYPE_INT16
Definition icmap.h:61
@ ICMAP_VALUETYPE_UINT32
Definition icmap.h:64
@ ICMAP_VALUETYPE_STRING
Definition icmap.h:69
@ ICMAP_VALUETYPE_FLOAT
Definition icmap.h:67
@ ICMAP_VALUETYPE_INT64
Definition icmap.h:65
@ ICMAP_VALUETYPE_DOUBLE
Definition icmap.h:68
@ ICMAP_VALUETYPE_UINT16
Definition icmap.h:62
@ ICMAP_VALUETYPE_INT32
Definition icmap.h:63
#define ICMAP_TRACK_DELETE
Definition icmap.h:77
#define ICMAP_TRACK_PREFIX
Whole prefix is tracked, instead of key only (so "totem." tracking means that "totem....
Definition icmap.h:85
void(* icmap_notify_fn_t)(int32_t event, const char *key_name, struct icmap_notify_value new_value, struct icmap_notify_value old_value, void *user_data)
Prototype for notify callback function.
Definition icmap.h:103
qb_map_iter_t * icmap_iter_t
Itterator type.
Definition icmap.h:123
struct icmap_track * icmap_track_t
Track type.
Definition icmap.h:128
#define ICMAP_KEYNAME_MAXLEN
Maximum length of key in icmap.
Definition icmap.h:48
#define ICMAP_TRACK_ADD
Definition icmap.h:76
void * user_data
Definition sam.c:127
char value[]
Definition icmap.c:52
icmap_value_types_t type
Definition icmap.c:50
size_t value_len
Definition icmap.c:51
char * key_name
Definition icmap.c:49
qb_map_t * qb_map
Definition icmap.c:56
Structure passed as new_value and old_value in change callback.
Definition icmap.h:91
icmap_value_types_t type
Definition icmap.h:92
struct qb_list_head list
Definition icmap.c:72
struct qb_list_head list
Definition icmap.c:66
void * user_data
Definition icmap.c:65
icmap_notify_fn_t notify_fn
Definition icmap.c:64
char * key_name
Definition icmap.c:62
int32_t track_type
Definition icmap.c:63
char type
Definition totem.h:2