axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sam...@apache.org
Subject svn commit: r357141 - in /webservices/axis2/trunk/c/modules/util/src: axis2_string.h string.c
Date Fri, 16 Dec 2005 08:01:39 GMT
Author: samisa
Date: Fri Dec 16 00:01:31 2005
New Revision: 357141

URL: http://svn.apache.org/viewcvs?rev=357141&view=rev
Log:
Added stracat function

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=357141&r1=357140&r2=357141&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/src/axis2_string.h (original)
+++ webservices/axis2/trunk/c/modules/util/src/axis2_string.h Fri Dec 16 00:01:31 2005
@@ -41,10 +41,26 @@
     AXIS2_DECLARE(int)
     axis2_strlen(const axis2_char_t *s);
 
+    AXIS2_DECLARE(int)
+    axis2_strcasecmp(const axis2_char_t *s1, axis2_char_t *s2);
+
+    AXIS2_DECLARE(int)
+    axis2_strncasecmp(const axis2_char_t *s1, axis2_char_t *s2, int n);
+    
+    /* much similar to the strcat behaviour. But the difference is
+     * this allocates new memory to put the conatenated string rather than
+     * modifying the first argument. The user should free the allocated
+     * 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); 
+
 #define AXIS2_STRDUP(pts, env) axis2_strdup(pts, env)
 #define AXIS2_STRCMP(s1, s2) axis2_strcmp(s1, s2)
 #define AXIS2_STRLEN(s) axis2_strlen(s)
-
+#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=357141&r1=357140&r2=357141&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/util/src/string.c (original)
+++ webservices/axis2/trunk/c/modules/util/src/string.c Fri Dec 16 00:01:31 2005
@@ -42,6 +42,34 @@
     }
 }
 
+AXIS2_DECLARE(axis2_char_t*)
+axis2_stracat(const axis2_char_t *s1, const axis2_char_t *s2, axis2_env_t **env)
+{
+    axis2_char_t *ret = NULL;
+    int alloc_len = -1;
+
+    if(NULL == s1 && NULL == s2)
+    {
+        return NULL;
+    }
+    if(NULL == s1)
+    {
+        return (axis2_char_t*)AXIS2_STRDUP(s2, env);
+    }
+    if(NULL == s2)
+    {
+        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,
+                    alloc_len*sizeof(axis2_char_t));
+    memcpy(ret, s1, axis2_strlen(s1)*sizeof(axis2_char_t));
+    memcpy((ret + axis2_strlen(s1)*sizeof(axis2_char_t)), s2,
+                    axis2_strlen(s2)*sizeof(axis2_char_t));
+    ret[alloc_len*sizeof(axis2_char_t)] = '\0';
+    return ret;
+}
+
 AXIS2_DECLARE(int)
 axis2_strcmp (const axis2_char_t * s1, const axis2_char_t * s2)
 {



Mime
View raw message