You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sa...@apache.org on 2005/12/28 07:23:53 UTC

svn commit: r359418 - in /webservices/axis2/trunk/c/modules/util/src: axis2_string.h string.c

Author: samisa
Date: Tue Dec 27 22:23:48 2005
New Revision: 359418

URL: http://svn.apache.org/viewcvs?rev=359418&view=rev
Log:
Added missing strcasecmp and strncasecmp functions

Modified:
    webservices/axis2/trunk/c/modules/util/src/axis2_string.h
    webservices/axis2/trunk/c/modules/util/src/string.c

Modified: webservices/axis2/trunk/c/modules/util/src/axis2_string.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/src/axis2_string.h?rev=359418&r1=359417&r2=359418&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/src/axis2_string.h (original)
+++ webservices/axis2/trunk/c/modules/util/src/axis2_string.h Tue Dec 27 22:23:48 2005
@@ -38,8 +38,8 @@
     AXIS2_DECLARE(int)
     axis2_strcmp (const axis2_char_t * s1, const axis2_char_t * s2);
 
-    AXIS2_DECLARE(int)
-    axis2_strlen(const axis2_char_t *s);
+    AXIS2_DECLARE(axis2_ssize_t)
+    axis2_strlen(const axis2_char_t * s);
 
     AXIS2_DECLARE(int)
     axis2_strcasecmp(const axis2_char_t *s1, axis2_char_t *s2);
@@ -53,7 +53,8 @@
      * memory for the return value
      */
     AXIS2_DECLARE(axis2_char_t*)
-    axis2_stracat(const axis2_char_t *s1, const axis2_char_t *s2, axis2_env_t **env); 
+    axis2_stracat(const axis2_char_t *s1, const axis2_char_t *s2, axis2_env_t **env);
+
 
 #define AXIS2_STRDUP(pts, env) axis2_strdup(pts, env)
 #define AXIS2_STRCMP(s1, s2) axis2_strcmp(s1, s2)
@@ -61,6 +62,7 @@
 #define AXIS2_STRCASECMP(s1,s2) axis2_strcasecmp(s1,s2)
 #define AXIS2_STRNCASECMP(s1,s2,n) axis2_strncasecmp(s1,s2,n)
 #define AXIS2_STRACAT(s1, s2, env) axis2_stracat(s1, s2, env)
+
 /** @} */
     
 #ifdef __cplusplus

Modified: webservices/axis2/trunk/c/modules/util/src/string.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/util/src/string.c?rev=359418&r1=359417&r2=359418&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/src/string.c (original)
+++ webservices/axis2/trunk/c/modules/util/src/string.c Tue Dec 27 22:23:48 2005
@@ -19,6 +19,7 @@
 #include <string.h>
 #include <axis2.h>
 #include <axis2_defines.h>
+#include <ctype.h>
 
 AXIS2_DECLARE(void*)
 axis2_strdup (const void *ptr, axis2_env_t **env)
@@ -58,7 +59,7 @@
     }
     if(NULL == s2)
     {
-        return (axis2_char_t *)AXIS2_STRDUP(s1, env);
+        return (axis2_char_t)AXIS2_STRDUP(s1, env);
     }
     alloc_len = axis2_strlen(s1) + axis2_strlen(s2) + 1;
     ret = (axis2_char_t*)AXIS2_MALLOC((*env)->allocator,
@@ -79,11 +80,29 @@
         return -1;
 }
 
+
+AXIS2_DECLARE(axis2_ssize_t)
+axis2_strlen (const axis2_char_t * s)
+{
+	return strlen(s);
+}
+
+
 AXIS2_DECLARE(int)
-axis2_strlen(const axis2_char_t *s)
+axis2_strcasecmp(const axis2_char_t *s1, axis2_char_t *s2)
 {
-    if(s)
-        return strlen(s);
-    else
-        return -1;
+    while (toupper(*s1) == toupper(*s2++))
+	if (*s1++ == '\0')
+	    return(0);
+    return(toupper(*s1) - toupper(*--s2));
+}
+
+
+AXIS2_DECLARE(int)
+axis2_strncasecmp(const axis2_char_t *s1, axis2_char_t *s2, int n)
+{
+    while (--n >= 0 && toupper(*s1) == toupper(*s2++))
+	if (toupper(*s1++) == '\0')
+	    return(0);
+    return(n < 0 ? 0 : toupper(*s1) - toupper(*--s2));
 }