changeset 781:4cc514343376

Rename th_cfg_find() to th_cfg_item_find().
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 04 Jul 2023 01:24:38 +0300
parents 847d1ebe5b81
children 94e8e6ad8c9e
files tests.c th_config.c th_config.h
diffstat 3 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/tests.c	Tue Jul 04 01:22:50 2023 +0300
+++ b/tests.c	Tue Jul 04 01:24:38 2023 +0300
@@ -377,22 +377,22 @@
     test_ctx ctx;
 
     test_start(&ctx, "Test configuration value search #%d", ++nsubtest);
-    test_result(&ctx, (item = th_cfg_find(cfg, "inside_sect", "intval", -1)) != NULL && *item->v.val_int == 112);
+    test_result(&ctx, (item = th_cfg_item_find(cfg, "inside_sect", "intval", -1)) != NULL && *item->v.val_int == 112);
     test_end(&ctx);
     test_start(&ctx, "Test configuration value search #%d", ++nsubtest);
-    test_result(&ctx, (item = th_cfg_find(cfg, "another_sect", "boolval", -1)) != NULL && *item->v.val_bool);
+    test_result(&ctx, (item = th_cfg_item_find(cfg, "another_sect", "boolval", -1)) != NULL && *item->v.val_bool);
     test_end(&ctx);
     test_start(&ctx, "Test configuration value search #%d", ++nsubtest);
-    test_result(&ctx, th_cfg_find(cfg, "no_match", NULL, -1) == NULL);
+    test_result(&ctx, th_cfg_item_find(cfg, "no_match", NULL, -1) == NULL);
     test_end(&ctx);
     test_start(&ctx, "Test configuration value search #%d", ++nsubtest);
-    test_result(&ctx, th_cfg_find(cfg, NULL, "no_match", -1) == NULL);
+    test_result(&ctx, th_cfg_item_find(cfg, NULL, "no_match", -1) == NULL);
     test_end(&ctx);
     test_start(&ctx, "Test configuration value search #%d", ++nsubtest);
-    test_result(&ctx, (item = th_cfg_find(cfg, NULL, "hexval", -1)) != NULL && *item->v.val_uint == 0x11223344);
+    test_result(&ctx, (item = th_cfg_item_find(cfg, NULL, "hexval", -1)) != NULL && *item->v.val_uint == 0x11223344);
     test_end(&ctx);
     test_start(&ctx, "Test configuration value search #%d", ++nsubtest);
-    test_result(&ctx, (item = th_cfg_find(cfg, NULL, "a_string_setting", -1)) != NULL && strcmp(*item->v.val_str, "v_str1") == 0);
+    test_result(&ctx, (item = th_cfg_item_find(cfg, NULL, "a_string_setting", -1)) != NULL && strcmp(*item->v.val_str, "v_str1") == 0);
     test_end(&ctx);
 }
 
@@ -465,7 +465,7 @@
     test_config_values(cfg);
 
     // Additional tests
-    item = th_cfg_find(cfg, NULL, "string_list", -1);
+    item = th_cfg_item_find(cfg, NULL, "string_list", -1);
     test_result(&ctx, item != NULL);
     if (item != NULL)
     {
@@ -544,7 +544,7 @@
     // Test ptr
     test_start(&ctx, "Test configuration string list ptr");
     test_result(&ctx,
-        (item = th_cfg_find(cfg, NULL, "string_list", -1)) != NULL &&
+        (item = th_cfg_item_find(cfg, NULL, "string_list", -1)) != NULL &&
         item->v.list == &v_str_list);
     test_end(&ctx);
 
--- a/th_config.c	Tue Jul 04 01:22:50 2023 +0300
+++ b/th_config.c	Tue Jul 04 01:24:38 2023 +0300
@@ -991,7 +991,8 @@
 }
 
 
-th_cfgitem_t *th_cfg_find(th_cfgitem_t *cfg, const char *section, const char *name, const int type)
+th_cfgitem_t *th_cfg_item_find(th_cfgitem_t *cfg, const char *section,
+    const char *name, const int type)
 {
     th_cfgitem_t *node;
 
--- a/th_config.h	Tue Jul 04 01:22:50 2023 +0300
+++ b/th_config.h	Tue Jul 04 01:24:38 2023 +0300
@@ -68,6 +68,7 @@
 
 int     th_cfg_add_comment(th_cfgitem_t **cfg, const char *comment);
 int     th_cfg_add_section(th_cfgitem_t **cfg, const char *name, th_cfgitem_t *sect);
+th_cfgitem_t * th_cfg_item_find(th_cfgitem_t *cfg, const char *section, const char *name, const int type);
 
 int     th_cfg_add_int(th_cfgitem_t **cfg, const char *name, int *data, int defValue);
 int     th_cfg_add_uint(th_cfgitem_t **cfg, const char *name, unsigned int *data, unsigned int defValue);
@@ -78,7 +79,6 @@
 int     th_cfg_add_hex_triplet(th_cfgitem_t **cfg, const char *name, unsigned int *data, unsigned int defValue);
 int     th_cfg_add_string_list(th_cfgitem_t **cfg, const char *name, th_llist_t **list);
 
-th_cfgitem_t *th_cfg_find(th_cfgitem_t *cfg, const char *section, const char *name, const int type);
 
 #ifdef __cplusplus
 }