updated ucx and used new sstrlower in util_header_callback

Thu, 15 Oct 2015 16:55:10 +0200

author
Mike Becker <universe@uap-core.de>
date
Thu, 15 Oct 2015 16:55:10 +0200
changeset 174
e7e56c56d126
parent 173
947843245525
child 175
9e14d920a7d0

updated ucx and used new sstrlower in util_header_callback

libidav/utils.c file | annotate | diff | comparison | revisions
ucx/string.c file | annotate | diff | comparison | revisions
ucx/string.h file | annotate | diff | comparison | revisions
--- a/libidav/utils.c	Thu Oct 15 16:36:07 2015 +0200
+++ b/libidav/utils.c	Thu Oct 15 16:55:10 2015 +0200
@@ -312,13 +312,9 @@
     key.length = value.ptr - key.ptr;
     value.ptr++; value.length--;
     
-    key = sstrdup(sstrtrim(key));
+    key = sstrlower(sstrtrim(key));
     value = sstrdup(sstrtrim(value));
-    
-    for(size_t i = 0;i<key.length;i++) {
-        key.ptr[i] = tolower(key.ptr[i]);
-    }
-    
+        
     ucx_map_sstr_put(map, key, value.ptr);
     
     free(key.ptr);
--- a/ucx/string.c	Thu Oct 15 16:36:07 2015 +0200
+++ b/ucx/string.c	Thu Oct 15 16:55:10 2015 +0200
@@ -339,3 +339,35 @@
             suffix.ptr, suffix.length) == 0;
     }
 }
+
+sstr_t sstrlower(sstr_t string) {
+    sstr_t ret = sstrdup(string);
+    for (size_t i = 0; i < ret.length ; i++) {
+        ret.ptr[i] = tolower(ret.ptr[i]);
+    }
+    return ret;
+}
+
+sstr_t sstrlower_a(UcxAllocator *allocator, sstr_t string) {
+    sstr_t ret = sstrdup_a(allocator, string);
+    for (size_t i = 0; i < ret.length ; i++) {
+        ret.ptr[i] = tolower(ret.ptr[i]);
+    }
+    return ret;
+}
+
+sstr_t sstrupper(sstr_t string) {
+    sstr_t ret = sstrdup(string);
+    for (size_t i = 0; i < ret.length ; i++) {
+        ret.ptr[i] = toupper(ret.ptr[i]);
+    }
+    return ret;
+}
+
+sstr_t sstrupper_a(UcxAllocator *allocator, sstr_t string) {
+    sstr_t ret = sstrdup_a(allocator, string);
+    for (size_t i = 0; i < ret.length ; i++) {
+        ret.ptr[i] = toupper(ret.ptr[i]);
+    }
+    return ret;
+}
--- a/ucx/string.h	Thu Oct 15 16:36:07 2015 +0200
+++ b/ucx/string.h	Thu Oct 15 16:55:10 2015 +0200
@@ -383,6 +383,56 @@
  */
 int sstrsuffix(sstr_t string, sstr_t suffix);
 
+/**
+ * Returns a lower case version of a string.
+ * 
+ * This function creates a duplicate of the input string, first. See the
+ * documentation of sstrdup() for the implications.
+ * 
+ * @param string the input string
+ * @return the resulting lower case string
+ * @see sstrdup()
+ */
+sstr_t sstrlower(sstr_t string);
+
+/**
+ * Returns a lower case version of a string.
+ * 
+ * This function creates a duplicate of the input string, first. See the
+ * documentation of sstrdup_a() for the implications.
+ * 
+ * @param allocator the allocator used for duplicating the string
+ * @param string the input string
+ * @return the resulting lower case string
+ * @see sstrdup_a()
+ */
+sstr_t sstrlower_a(UcxAllocator *allocator, sstr_t string);
+
+/**
+ * Returns a upper case version of a string.
+ * 
+ * This function creates a duplicate of the input string, first. See the
+ * documentation of sstrdup() for the implications.
+ * 
+ * @param string the input string
+ * @return the resulting upper case string
+ * @see sstrdup()
+ */
+sstr_t sstrupper(sstr_t string);
+
+/**
+ * Returns a upper case version of a string.
+ * 
+ * This function creates a duplicate of the input string, first. See the
+ * documentation of sstrdup_a() for the implications.
+ * 
+ * @param allocator the allocator used for duplicating the string
+ * @param string the input string
+ * @return the resulting upper case string
+ * @see sstrdup_a()
+ */
+sstr_t sstrupper_a(UcxAllocator *allocator, sstr_t string);
+
 #ifdef	__cplusplus
 }
 #endif

mercurial