renamed properties functions

Mon, 15 Jul 2013 13:53:51 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 15 Jul 2013 13:53:51 +0200
changeset 110
1cf71e56f01e
parent 109
75cb6590358b
child 111
c8c59d7f4536

renamed properties functions

test/main.c file | annotate | diff | comparison | revisions
test/prop_tests.c file | annotate | diff | comparison | revisions
test/prop_tests.h file | annotate | diff | comparison | revisions
ucx/properties.c file | annotate | diff | comparison | revisions
ucx/properties.h file | annotate | diff | comparison | revisions
--- a/test/main.c	Sun Jul 14 17:11:34 2013 +0200
+++ b/test/main.c	Mon Jul 15 13:53:51 2013 +0200
@@ -171,12 +171,12 @@
         ucx_test_register(suite, test_ucx_map_rehash);
         
         /* UcxPropertiesParser Tests */
-        ucx_test_register(suite, test_ucx_prop_new);
-        ucx_test_register(suite, test_ucx_prop_parse);
-        ucx_test_register(suite, test_ucx_prop_parse_multi);
-        ucx_test_register(suite, test_ucx_prop_parse_part);
-        ucx_test_register(suite, test_ucx_prop_parse_long);
-        ucx_test_register(suite, test_ucx_prop_parse2map);
+        ucx_test_register(suite, test_ucx_properties_new);
+        ucx_test_register(suite, test_ucx_properties_next);
+        ucx_test_register(suite, test_ucx_properties_next_multi);
+        ucx_test_register(suite, test_ucx_properties_next_part);
+        ucx_test_register(suite, test_ucx_properties_next_long);
+        ucx_test_register(suite, test_ucx_properties2map);
         ucx_test_register(suite, test_ucx_properties_load);
         ucx_test_register(suite, test_ucx_properties_store);
         
--- a/test/prop_tests.c	Sun Jul 14 17:11:34 2013 +0200
+++ b/test/prop_tests.c	Mon Jul 15 13:53:51 2013 +0200
@@ -28,8 +28,8 @@
 
 #include "prop_tests.h"
 
-UCX_TEST_IMPLEMENT(test_ucx_prop_new) {
-    UcxPropParser *parser = ucx_prop_new();
+UCX_TEST_IMPLEMENT(test_ucx_properties_new) {
+    UcxProperties *parser = ucx_properties_new();
     
     UCX_TEST_BEGIN
             
@@ -39,10 +39,10 @@
     
     UCX_TEST_END
             
-    ucx_prop_free(parser);
+    ucx_properties_free(parser);
 }
 
-UCX_TEST_IMPLEMENT(test_ucx_prop_parse) {  
+UCX_TEST_IMPLEMENT(test_ucx_properties_next) {  
     const char *tests[] = {
         "name = value\n",
         "name=value\n",
@@ -88,32 +88,32 @@
     sstr_t value;
     
     for(int i=0;i<10;i++) {
-        UcxPropParser *parser = ucx_prop_new();
+        UcxProperties *parser = ucx_properties_new();
         
-        ucx_prop_fill(parser, (char*)tests[i], strlen(tests[i]));
+        ucx_properties_fill(parser, (char*)tests[i], strlen(tests[i]));
         UCX_TEST_ASSERT(parser->buffer == tests[i], "fill failed");
         UCX_TEST_ASSERT(parser->buflen == strlen(tests[i]), "wrong buflen");
         
-        int r = ucx_prop_parse(parser, &name, &value);
+        int r = ucx_properties_next(parser, &name, &value);
         sstr_t n = sstr((char*)names[i]);
         sstr_t v = sstr((char*)values[i]);
-        UCX_TEST_ASSERT(r == 1, "parse returned 0");
+        UCX_TEST_ASSERT(r == 1, "next returned 0");
         UCX_TEST_ASSERT((!sstrcmp(name, n)), "wrong property name");
         UCX_TEST_ASSERT((!sstrcmp(value, v)), "wrong property value");
         
-        r = ucx_prop_parse(parser, &name, &value);
-        UCX_TEST_ASSERT(r == 0, "parse returned 1");
+        r = ucx_properties_next(parser, &name, &value);
+        UCX_TEST_ASSERT(r == 0, "next returned 1");
         UCX_TEST_ASSERT(parser->tmp == NULL, "tmp not NULL");
         UCX_TEST_ASSERT(parser->tmpcap == 0, "tmpcap not NULL");
         UCX_TEST_ASSERT(parser->tmplen == 0, "tmplen not NULL");
         
-        ucx_prop_free(parser);
+        ucx_properties_free(parser);
     }
     
     UCX_TEST_END       
 }
 
-UCX_TEST_IMPLEMENT(test_ucx_prop_parse_multi) {
+UCX_TEST_IMPLEMENT(test_ucx_properties_next_multi) {
     const char *names[] = {
         "a",
         "b",
@@ -153,31 +153,31 @@
         "key2 = value2\n"
         "\n\n\n        \n           key3=value3\n";
     
-    UcxPropParser *parser = ucx_prop_new();
+    UcxProperties *parser = ucx_properties_new();
     
     UCX_TEST_BEGIN
     
-    ucx_prop_fill(parser, (char*)str, strlen(str));
+    ucx_properties_fill(parser, (char*)str, strlen(str));
     
     sstr_t name;
     sstr_t value;
     for(int i=0;i<8;i++) {
-        int r = ucx_prop_parse(parser, &name, &value);
-        UCX_TEST_ASSERT(r == 1, "parse returned 0");
+        int r = ucx_properties_next(parser, &name, &value);
+        UCX_TEST_ASSERT(r == 1, "next returned 0");
         UCX_TEST_ASSERT((!sstrcmp(name, sstr((char*)names[i]))), "wrong name");
         UCX_TEST_ASSERT((!sstrcmp(value, sstr((char*)values[i]))),
                 "wrong value");
     }
-    int r = ucx_prop_parse(parser, &name, &value);
-    UCX_TEST_ASSERT(r == 0, "parse returned 1");
+    int r = ucx_properties_next(parser, &name, &value);
+    UCX_TEST_ASSERT(r == 0, "next returned 1");
     
     UCX_TEST_END
     
-    ucx_prop_free(parser);
+    ucx_properties_free(parser);
 }
 
-UCX_TEST_IMPLEMENT(test_ucx_prop_parse_part) {
-    UcxPropParser *parser = ucx_prop_new();
+UCX_TEST_IMPLEMENT(test_ucx_properties_next_part) {
+    UcxProperties *parser = ucx_properties_new();
     const char *str;
     int r;
     sstr_t name;
@@ -186,108 +186,108 @@
     UCX_TEST_BEGIN
     
     str = "";
-    ucx_prop_fill(parser, (char*)str, strlen(str));
-    r = ucx_prop_parse(parser, &name, &value);
-    UCX_TEST_ASSERT(r == 0, "parse returned 1");
+    ucx_properties_fill(parser, (char*)str, strlen(str));
+    r = ucx_properties_next(parser, &name, &value);
+    UCX_TEST_ASSERT(r == 0, "next returned 1");
     
     str = "  \n";
-    ucx_prop_fill(parser, (char*)str, strlen(str));
-    r = ucx_prop_parse(parser, &name, &value); 
-    UCX_TEST_ASSERT(r == 0, "parse returned 1");
+    ucx_properties_fill(parser, (char*)str, strlen(str));
+    r = ucx_properties_next(parser, &name, &value); 
+    UCX_TEST_ASSERT(r == 0, "next returned 1");
     
     str = "name";
-    ucx_prop_fill(parser, (char*)str, strlen(str));
-    r = ucx_prop_parse(parser, &name, &value); 
-    UCX_TEST_ASSERT(r == 0, "parse returned 1");
+    ucx_properties_fill(parser, (char*)str, strlen(str));
+    r = ucx_properties_next(parser, &name, &value); 
+    UCX_TEST_ASSERT(r == 0, "next returned 1");
     
     str = "    ";
-    ucx_prop_fill(parser, (char*)str, strlen(str));
-    r = ucx_prop_parse(parser, &name, &value); 
-    UCX_TEST_ASSERT(r == 0, "parse returned 1");
+    ucx_properties_fill(parser, (char*)str, strlen(str));
+    r = ucx_properties_next(parser, &name, &value); 
+    UCX_TEST_ASSERT(r == 0, "next returned 1");
     
     str = "= ";
-    ucx_prop_fill(parser, (char*)str, strlen(str));
-    r = ucx_prop_parse(parser, &name, &value); 
-    UCX_TEST_ASSERT(r == 0, "parse returned 1");
+    ucx_properties_fill(parser, (char*)str, strlen(str));
+    r = ucx_properties_next(parser, &name, &value); 
+    UCX_TEST_ASSERT(r == 0, "next returned 1");
     
     str = "value";
-    ucx_prop_fill(parser, (char*)str, strlen(str));
-    r = ucx_prop_parse(parser, &name, &value); 
-    UCX_TEST_ASSERT(r == 0, "parse returned 1");
+    ucx_properties_fill(parser, (char*)str, strlen(str));
+    r = ucx_properties_next(parser, &name, &value); 
+    UCX_TEST_ASSERT(r == 0, "next returned 1");
     
     str = "\n";
-    ucx_prop_fill(parser, (char*)str, strlen(str));
-    r = ucx_prop_parse(parser, &name, &value); 
-    UCX_TEST_ASSERT(r == 1, "parse returned 0");
+    ucx_properties_fill(parser, (char*)str, strlen(str));
+    r = ucx_properties_next(parser, &name, &value); 
+    UCX_TEST_ASSERT(r == 1, "next returned 0");
     UCX_TEST_ASSERT((!sstrcmp(name, sstr((char*)"name"))), "wrong name");
     UCX_TEST_ASSERT((!sstrcmp(value, sstr((char*)"value"))), "wrong value");
     
     // second round
     str = "#comment\n";
-    ucx_prop_fill(parser, (char*)str, strlen(str));
-    r = ucx_prop_parse(parser, &name, &value); 
-    UCX_TEST_ASSERT(r == 0, "parse returned 1");
+    ucx_properties_fill(parser, (char*)str, strlen(str));
+    r = ucx_properties_next(parser, &name, &value); 
+    UCX_TEST_ASSERT(r == 0, "next returned 1");
     
     str = "#comment\nname = ";
-    ucx_prop_fill(parser, (char*)str, strlen(str));
-    r = ucx_prop_parse(parser, &name, &value); 
-    UCX_TEST_ASSERT(r == 0, "parse returned 1");
+    ucx_properties_fill(parser, (char*)str, strlen(str));
+    r = ucx_properties_next(parser, &name, &value); 
+    UCX_TEST_ASSERT(r == 0, "next returned 1");
     
     str = "value\na = b\n";
-    ucx_prop_fill(parser, (char*)str, strlen(str));
-    r = ucx_prop_parse(parser, &name, &value); 
-    UCX_TEST_ASSERT(r == 1, "parse returned 0");
+    ucx_properties_fill(parser, (char*)str, strlen(str));
+    r = ucx_properties_next(parser, &name, &value); 
+    UCX_TEST_ASSERT(r == 1, "next returned 0");
     UCX_TEST_ASSERT((!sstrcmp(name, sstr((char*)"name"))), "wrong name");
     UCX_TEST_ASSERT((!sstrcmp(value, sstr((char*)"value"))), "wrong value");
     
-    r = ucx_prop_parse(parser, &name, &value); 
-    UCX_TEST_ASSERT(r == 1, "parse returned 0");
+    r = ucx_properties_next(parser, &name, &value); 
+    UCX_TEST_ASSERT(r == 1, "next returned 0");
     UCX_TEST_ASSERT((!sstrcmp(name, sstr((char*)"a"))), "wrong name");
     UCX_TEST_ASSERT((!sstrcmp(value, sstr((char*)"b"))), "wrong value");
     
     str = "# comment\n#\n#\ntests = ";
-    ucx_prop_fill(parser, (char*)str, strlen(str));
-    r = ucx_prop_parse(parser, &name, &value); 
-    UCX_TEST_ASSERT(r == 0, "parse returned 1");
+    ucx_properties_fill(parser, (char*)str, strlen(str));
+    r = ucx_properties_next(parser, &name, &value); 
+    UCX_TEST_ASSERT(r == 0, "next returned 1");
     
     str = "test1 ";
-    ucx_prop_fill(parser, (char*)str, strlen(str));
-    r = ucx_prop_parse(parser, &name, &value); 
-    UCX_TEST_ASSERT(r == 0, "parse returned 1");
+    ucx_properties_fill(parser, (char*)str, strlen(str));
+    r = ucx_properties_next(parser, &name, &value); 
+    UCX_TEST_ASSERT(r == 0, "next returned 1");
     
     str = "test2 test3 test4\n";
     sstr_t testv = sstr((char*)"test1 test2 test3 test4");
-    ucx_prop_fill(parser, (char*)str, strlen(str));
-    r = ucx_prop_parse(parser, &name, &value); 
-    UCX_TEST_ASSERT(r == 1, "parse returned 0");
+    ucx_properties_fill(parser, (char*)str, strlen(str));
+    r = ucx_properties_next(parser, &name, &value); 
+    UCX_TEST_ASSERT(r == 1, "next returned 0");
     UCX_TEST_ASSERT((!sstrcmp(name, sstr((char*)"tests"))), "wrong name");
     UCX_TEST_ASSERT((!sstrcmp(value, testv)), "wrong value");
     
-    // test if parse finds a name/value after a tmp comment
+    // test if ucx_properties_next finds a name/value after a tmp comment
     str = "# just a comment";
-    ucx_prop_fill(parser, (char*)str, strlen(str));
-    r = ucx_prop_parse(parser, &name, &value); 
-    UCX_TEST_ASSERT(r == 0, "parse returned 1");
+    ucx_properties_fill(parser, (char*)str, strlen(str));
+    r = ucx_properties_next(parser, &name, &value); 
+    UCX_TEST_ASSERT(r == 0, "next returned 1");
     
     str = " in 3";
-    ucx_prop_fill(parser, (char*)str, strlen(str));
-    r = ucx_prop_parse(parser, &name, &value); 
-    UCX_TEST_ASSERT(r == 0, "parse returned 1");
+    ucx_properties_fill(parser, (char*)str, strlen(str));
+    r = ucx_properties_next(parser, &name, &value); 
+    UCX_TEST_ASSERT(r == 0, "next returned 1");
     
     str = " parts\na = 1\n";
-    ucx_prop_fill(parser, (char*)str, strlen(str));
-    r = ucx_prop_parse(parser, &name, &value); 
-    UCX_TEST_ASSERT(r == 1, "parse returned 0");
+    ucx_properties_fill(parser, (char*)str, strlen(str));
+    r = ucx_properties_next(parser, &name, &value); 
+    UCX_TEST_ASSERT(r == 1, "next returned 0");
     UCX_TEST_ASSERT((!sstrcmp(name, sstr((char*)"a"))), "wrong name");
     UCX_TEST_ASSERT((!sstrcmp(value, sstr((char*)"1"))), "wrong value");
     
     UCX_TEST_END
     
-    ucx_prop_free(parser);
+    ucx_properties_free(parser);
 }
 
-UCX_TEST_IMPLEMENT(test_ucx_prop_parse_long) {
-    UcxPropParser *parser = ucx_prop_new();
+UCX_TEST_IMPLEMENT(test_ucx_properties_next_long) {
+    UcxProperties *parser = ucx_properties_new();
     int r;
     size_t name_len = 512;
     char *long_name = (char*)malloc(name_len);
@@ -305,75 +305,75 @@
     sstr_t name;
     sstr_t value;
     
-    ucx_prop_fill(parser, long_name, 10);
-    r = ucx_prop_parse(parser, &name, &value);
-    UCX_TEST_ASSERT(r == 0, "parse returned 1");
+    ucx_properties_fill(parser, long_name, 10);
+    r = ucx_properties_next(parser, &name, &value);
+    UCX_TEST_ASSERT(r == 0, "next returned 1");
     
-    ucx_prop_fill(parser, long_name+10, 202);
-    r = ucx_prop_parse(parser, &name, &value);
-    UCX_TEST_ASSERT(r == 0, "parse returned 1");
+    ucx_properties_fill(parser, long_name+10, 202);
+    r = ucx_properties_next(parser, &name, &value);
+    UCX_TEST_ASSERT(r == 0, "next returned 1");
     
-    ucx_prop_fill(parser, long_name+212, 200);
-    r = ucx_prop_parse(parser, &name, &value);
-    UCX_TEST_ASSERT(r == 0, "parse returned 1");
+    ucx_properties_fill(parser, long_name+212, 200);
+    r = ucx_properties_next(parser, &name, &value);
+    UCX_TEST_ASSERT(r == 0, "next returned 1");
     
-    ucx_prop_fill(parser, long_name+412, 100);
-    r = ucx_prop_parse(parser, &name, &value);
-    UCX_TEST_ASSERT(r == 0, "parse returned 1");
+    ucx_properties_fill(parser, long_name+412, 100);
+    r = ucx_properties_next(parser, &name, &value);
+    UCX_TEST_ASSERT(r == 0, "next returned 1");
     
     const char *str = " = ";
-    ucx_prop_fill(parser, (char*)str, strlen(str));
-    r = ucx_prop_parse(parser, &name, &value);
-    UCX_TEST_ASSERT(r == 0, "parse returned 1");
+    ucx_properties_fill(parser, (char*)str, strlen(str));
+    r = ucx_properties_next(parser, &name, &value);
+    UCX_TEST_ASSERT(r == 0, "next returned 1");
     
-    ucx_prop_fill(parser, long_value, 512);
-    r = ucx_prop_parse(parser, &name, &value); 
-    UCX_TEST_ASSERT(r == 0, "parse returned 1");
+    ucx_properties_fill(parser, long_value, 512);
+    r = ucx_properties_next(parser, &name, &value); 
+    UCX_TEST_ASSERT(r == 0, "next returned 1");
     
-    ucx_prop_fill(parser, long_value+512, 1024);
-    r = ucx_prop_parse(parser, &name, &value);
-    UCX_TEST_ASSERT(r == 0, "parse returned 1");
+    ucx_properties_fill(parser, long_value+512, 1024);
+    r = ucx_properties_next(parser, &name, &value);
+    UCX_TEST_ASSERT(r == 0, "next returned 1");
     
-    ucx_prop_fill(parser, long_value+1536, 512);
-    r = ucx_prop_parse(parser, &name, &value);
-    UCX_TEST_ASSERT(r == 0, "parse returned 1");
+    ucx_properties_fill(parser, long_value+1536, 512);
+    r = ucx_properties_next(parser, &name, &value);
+    UCX_TEST_ASSERT(r == 0, "next returned 1");
     
     str = "\n#comment\nkey = value\n";
-    ucx_prop_fill(parser, (char*)str, strlen(str));    
-    r = ucx_prop_parse(parser, &name, &value);
+    ucx_properties_fill(parser, (char*)str, strlen(str));    
+    r = ucx_properties_next(parser, &name, &value);
     sstr_t n = sstrn(long_name, name_len);
     sstr_t v = sstrn(long_value, value_len);
-    UCX_TEST_ASSERT(r == 1, "parse returned 0");
+    UCX_TEST_ASSERT(r == 1, "next returned 0");
     UCX_TEST_ASSERT((!sstrcmp(name, n)), "wrong name");
     UCX_TEST_ASSERT((!sstrcmp(value, v)), "wrong value");
     
-    r = ucx_prop_parse(parser, &name, &value);
-    UCX_TEST_ASSERT(r == 1, "parse returned 0");
+    r = ucx_properties_next(parser, &name, &value);
+    UCX_TEST_ASSERT(r == 1, "next returned 0");
     UCX_TEST_ASSERT((!sstrcmp(name, sstr((char*)"key"))), "wrong name");
     UCX_TEST_ASSERT((!sstrcmp(value, sstr((char*)"value"))), "wrong value");
     
-    r = ucx_prop_parse(parser, &name, &value);
-    UCX_TEST_ASSERT(r == 0, "parse returned 1");
+    r = ucx_properties_next(parser, &name, &value);
+    UCX_TEST_ASSERT(r == 0, "next returned 1");
     
     UCX_TEST_END
     
     free(long_name);
     free(long_value);
-    ucx_prop_free(parser);
+    ucx_properties_free(parser);
 }
 
-UCX_TEST_IMPLEMENT(test_ucx_prop_parse2map) {
+UCX_TEST_IMPLEMENT(test_ucx_properties2map) {
     UcxMap *map = ucx_map_new(16);
-    UcxPropParser *parser = ucx_prop_new();
+    UcxProperties *parser = ucx_properties_new();
     
     UCX_TEST_BEGIN
     
     const char *str = "key1 = value1\nkey2 = value2\n\n#comment\n\nkey3 = value3\n";
-    ucx_prop_fill(parser, (char*)str, strlen(str));
+    ucx_properties_fill(parser, (char*)str, strlen(str));
     
-    int r = ucx_prop_parse2map(parser, map);
+    int r = ucx_properties2map(parser, map);
     
-    UCX_TEST_ASSERT(r == 0, "parse2map failed");
+    UCX_TEST_ASSERT(r == 0, "properties2map failed");
     UCX_TEST_ASSERT(map->count == 3, "wrong number of properties");
     
     char *v1 = (char*)ucx_map_cstr_get(map, "key1");
@@ -396,17 +396,17 @@
     map = ucx_map_new(16);
     
     str = "\n#comment\n";
-    ucx_prop_fill(parser, (char*)str, strlen(str));
+    ucx_properties_fill(parser, (char*)str, strlen(str));
     
-    r = ucx_prop_parse2map(parser, map);
-    UCX_TEST_ASSERT(r == 0, "parse2map failed");
+    r = ucx_properties2map(parser, map);
+    UCX_TEST_ASSERT(r == 0, "properties2map failed");
     UCX_TEST_ASSERT(map->count == 0, "wrong number of properties");
     
     str = "key1 = value1\nsyntax error line\n";
-    ucx_prop_fill(parser, (char*)str, strlen(str));
+    ucx_properties_fill(parser, (char*)str, strlen(str));
     
-    r = ucx_prop_parse2map(parser, map);
-    UCX_TEST_ASSERT(r == 1, "parse2map should return 1");
+    r = ucx_properties2map(parser, map);
+    UCX_TEST_ASSERT(r == 1, "properties2map should return 1");
     UCX_TEST_ASSERT(map->count == 1, "wrong number of properties");
     
     char *v = (char*)ucx_map_cstr_get(map, "key1");
@@ -414,7 +414,7 @@
     
     UCX_TEST_END
     
-    ucx_prop_free(parser);
+    ucx_properties_free(parser);
 }
 
 UCX_TEST_IMPLEMENT(test_ucx_properties_load) { 
--- a/test/prop_tests.h	Sun Jul 14 17:11:34 2013 +0200
+++ b/test/prop_tests.h	Mon Jul 15 13:53:51 2013 +0200
@@ -36,12 +36,12 @@
 extern "C" {
 #endif
 
-UCX_TEST_DECLARE(test_ucx_prop_new);
-UCX_TEST_DECLARE(test_ucx_prop_parse);
-UCX_TEST_DECLARE(test_ucx_prop_parse_multi);
-UCX_TEST_DECLARE(test_ucx_prop_parse_part);
-UCX_TEST_DECLARE(test_ucx_prop_parse_long);
-UCX_TEST_DECLARE(test_ucx_prop_parse2map);
+UCX_TEST_DECLARE(test_ucx_properties_new);
+UCX_TEST_DECLARE(test_ucx_properties_next);
+UCX_TEST_DECLARE(test_ucx_properties_next_multi);
+UCX_TEST_DECLARE(test_ucx_properties_next_part);
+UCX_TEST_DECLARE(test_ucx_properties_next_long);
+UCX_TEST_DECLARE(test_ucx_properties2map);
 UCX_TEST_DECLARE(test_ucx_properties_load);
 UCX_TEST_DECLARE(test_ucx_properties_store);
 
--- a/ucx/properties.c	Sun Jul 14 17:11:34 2013 +0200
+++ b/ucx/properties.c	Mon Jul 15 13:53:51 2013 +0200
@@ -32,9 +32,9 @@
 
 #include "properties.h"
 
-UcxPropParser *ucx_prop_new() {
-    UcxPropParser *parser = (UcxPropParser*)malloc(
-            sizeof(UcxPropParser));
+UcxProperties *ucx_properties_new() {
+    UcxProperties *parser = (UcxProperties*)malloc(
+            sizeof(UcxProperties));
     if(!parser) {
         return NULL;
     }
@@ -54,20 +54,20 @@
     return parser;
 }
 
-void ucx_prop_free(UcxPropParser *parser) {
+void ucx_properties_free(UcxProperties *parser) {
     if(parser->tmp) {
         free(parser->tmp);
     }
     free(parser);
 }
 
-void ucx_prop_fill(UcxPropParser *parser, char *buf, size_t len) {
+void ucx_properties_fill(UcxProperties *parser, char *buf, size_t len) {
     parser->buffer = buf;
     parser->buflen = len;
     parser->pos = 0;
 }
 
-static void parser_tmp_append(UcxPropParser *parser, char *buf, size_t len) {
+static void parser_tmp_append(UcxProperties *parser, char *buf, size_t len) {
     if(parser->tmpcap - parser->tmplen < len) {
         size_t newcap = parser->tmpcap + len + 64;
         parser->tmp = (char*)realloc(parser->tmp, newcap);
@@ -77,7 +77,7 @@
     parser->tmplen += len;
 }
 
-int ucx_prop_parse(UcxPropParser *parser, sstr_t *name, sstr_t *value)  {   
+int ucx_properties_next(UcxProperties *parser, sstr_t *name, sstr_t *value)  {   
     if(parser->tmplen > 0) {
         char *buf = parser->buffer + parser->pos;
         size_t len = parser->buflen - parser->pos;
@@ -98,7 +98,7 @@
             parser->tmpcap = 0;
             parser->tmplen = 0;
             // run parse with the tmp buffer as main buffer
-            int ret = ucx_prop_parse(parser, name, value);
+            int ret = ucx_properties_next(parser, name, value);
             
             // restore original buffer
             parser->tmp = parser->buffer;
@@ -111,7 +111,7 @@
              * we parse again with the original buffer to get a name/value
              * or a new tmp buffer
              */
-            return ret ? ret : ucx_prop_parse(parser, name, value);
+            return ret ? ret : ucx_properties_next(parser, name, value);
         } else {
             parser_tmp_append(parser, buf, len);
             return 0;
@@ -195,10 +195,10 @@
     return 0;
 }
 
-int ucx_prop_parse2map(UcxPropParser *parser, UcxMap *map) {
+int ucx_properties2map(UcxProperties *parser, UcxMap *map) {
     sstr_t name;
     sstr_t value;
-    while(ucx_prop_parse(parser, &name, &value)) {
+    while(ucx_properties_next(parser, &name, &value)) {
         name = sstrdup_alloc(map->allocator, name);
         if(!name.ptr) {
             return 1;
@@ -222,7 +222,7 @@
 }
 
 int ucx_properties_load(UcxMap *map, FILE *file) {
-    UcxPropParser *parser = ucx_prop_new();
+    UcxProperties *parser = ucx_properties_new();
     if(!parser || !map || !file) {
         return 1;
     }
@@ -231,14 +231,14 @@
     size_t r;
     char buf[1024];
     while((r = fread(buf, 1, 1024, file)) != 0) {
-        ucx_prop_fill(parser, buf, r);
-        if(ucx_prop_parse2map(parser, map)) {
+        ucx_properties_fill(parser, buf, r);
+        if(ucx_properties2map(parser, map)) {
             error = 1;
             break;
         }
     }
     
-    ucx_prop_free(parser);
+    ucx_properties_free(parser);
     return error;
 }
 
--- a/ucx/properties.h	Sun Jul 14 17:11:34 2013 +0200
+++ b/ucx/properties.h	Mon Jul 15 13:53:51 2013 +0200
@@ -48,14 +48,14 @@
     char   comment1;
     char   comment2;
     char   comment3;
-} UcxPropParser;
+} UcxProperties;
 
 
-UcxPropParser *ucx_prop_new();
-void ucx_prop_free(UcxPropParser *parser);
-void ucx_prop_fill(UcxPropParser *parser, char *buf, size_t len);
-int ucx_prop_parse(UcxPropParser *parser, sstr_t *name, sstr_t *value);
-int ucx_prop_parse2map(UcxPropParser *parser, UcxMap *map);
+UcxProperties *ucx_properties_new();
+void ucx_properties_free(UcxProperties *parser);
+void ucx_properties_fill(UcxProperties *parser, char *buf, size_t len);
+int ucx_properties_next(UcxProperties *parser, sstr_t *name, sstr_t *value);
+int ucx_properties2map(UcxProperties *parser, UcxMap *map);
 
 int ucx_properties_load(UcxMap *map, FILE *file);
 int ucx_properties_store(UcxMap *map, FILE *file);

mercurial