master
c 21 lines 637 Bytes
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 #include "inicfg_internals.h"
4
5 size_t inicfg_foreach_value_in_section(struct config *root, const char *section, inicfg_foreach_value_cb_t cb, void *data) {
6 size_t used = 0;
7 struct config_section *co = inicfg_section_find(root, section);
8 if(co) {
9 SECTION_LOCK(co);
10 struct config_option *cv;
11 for(cv = co->values; cv ; cv = cv->next) {
12 if(cb(data, string2str(cv->name), string2str(cv->value))) {
13 cv->flags |= CONFIG_VALUE_USED;
14 used++;
15 }
16 }
17 SECTION_UNLOCK(co);
18 }
19
20 return used;
21 }