You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by su...@apache.org on 2008/06/26 13:12:18 UTC

svn commit: r671855 - in /webservices/axis2/trunk/c/tools/tcpmon: include/tcpmon_util.h src/entry.c src/tcpmon.c src/util.c

Author: supun
Date: Thu Jun 26 04:12:18 2008
New Revision: 671855

URL: http://svn.apache.org/viewvc?rev=671855&view=rev
Log:
TCP mon build break fix.

Modified:
    webservices/axis2/trunk/c/tools/tcpmon/include/tcpmon_util.h
    webservices/axis2/trunk/c/tools/tcpmon/src/entry.c
    webservices/axis2/trunk/c/tools/tcpmon/src/tcpmon.c
    webservices/axis2/trunk/c/tools/tcpmon/src/util.c

Modified: webservices/axis2/trunk/c/tools/tcpmon/include/tcpmon_util.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/tools/tcpmon/include/tcpmon_util.h?rev=671855&r1=671854&r2=671855&view=diff
==============================================================================
--- webservices/axis2/trunk/c/tools/tcpmon/include/tcpmon_util.h (original)
+++ webservices/axis2/trunk/c/tools/tcpmon/include/tcpmon_util.h Thu Jun 26 04:12:18 2008
@@ -48,6 +48,12 @@
         axis2_char_t * data,
         int format);
 
+	char *str_replace(
+		char *str,
+		const char *search,
+		const char *replace);
+
+
     /** @} */
 
 #ifdef __cplusplus

Modified: webservices/axis2/trunk/c/tools/tcpmon/src/entry.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/tools/tcpmon/src/entry.c?rev=671855&r1=671854&r2=671855&view=diff
==============================================================================
--- webservices/axis2/trunk/c/tools/tcpmon/src/entry.c (original)
+++ webservices/axis2/trunk/c/tools/tcpmon/src/entry.c Thu Jun 26 04:12:18 2008
@@ -26,6 +26,7 @@
 
 #include "tcpmon_entry_local.h"
 #include "tcpmon_session_local.h"
+#include "tcpmon_util.h"
 
 #define AXIS2_TCPMON
 

Modified: webservices/axis2/trunk/c/tools/tcpmon/src/tcpmon.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/tools/tcpmon/src/tcpmon.c?rev=671855&r1=671854&r2=671855&view=diff
==============================================================================
--- webservices/axis2/trunk/c/tools/tcpmon/src/tcpmon.c (original)
+++ webservices/axis2/trunk/c/tools/tcpmon/src/tcpmon.c Thu Jun 26 04:12:18 2008
@@ -31,6 +31,8 @@
 #include <axis2_http_transport.h>
 #include <axutil_version.h>
 
+#include <tcpmon_util.h>
+
 #define SIZE 1024
 axis2_char_t *tcpmon_traffic_log = "tcpmon_traffic.log";
 axutil_env_t *system_env = NULL;
@@ -51,10 +53,6 @@
     const axutil_env_t * env,
     char *error_message);
 
-char *str_replace(
-    char *str,
-    const char *search,
-    const char *replace);
 
 void sig_handler(
     int signal);
@@ -984,65 +982,6 @@
     return 0;
 }
 
-char *
-str_replace(
-    char *str,
-    const char *search,
-    const char *replace)
-{
-    int size = ((int)strlen(str)) * 2;
-    /* We are sure that the difference lies within the int range */
-    int addmem = size;
-    int diff = (int)(strlen(replace) - strlen(search));
-    /* We are sure that the difference lies within the int range */
-
-    char *str_return = (char *) malloc((size + 1) * sizeof(char));
-    char *str_tmp = (char *) malloc(size * sizeof(char));
-    char *str_relic;
-
-    if (str_return == NULL || str_tmp == NULL)
-    {
-        free(str_return);
-        free(str_tmp);
-        return "function str_replace : give me more memory";
-    }
-    if (!strcmp(search, replace))
-    {
-        free(str_return);
-        free(str_tmp);
-        return str;
-    }
-
-    strcpy(str_return, str);
-
-    while ((str_relic = strstr(str_return, search)) != NULL)
-    {
-        if ((int)strlen(str_return) + diff >= addmem)
-            /* We are sure that the difference lies within the int range */
-        {
-            str_return = (char *) realloc(str_return, addmem += size);
-            str_tmp = (char *) realloc(str_tmp, addmem);
-
-            if (str_return == NULL || str_tmp == NULL)
-            {
-                free(str_return);
-                free(str_tmp);
-                return "function str_replace : gimme more memory";
-            }
-        }
-
-        strcpy(str_tmp, replace);
-        strcat(str_tmp, (str_relic + strlen(search)));
-        *str_relic = '\0';
-
-        strcat(str_return, str_tmp);
-    }
-
-    free(str_tmp);
-    /* free(str); */ /* we are not allocating memory using str */
-    str_return[addmem] = '\0';
-    return (str_return);
-}
 
 /**
  * Signal handler

Modified: webservices/axis2/trunk/c/tools/tcpmon/src/util.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/tools/tcpmon/src/util.c?rev=671855&r1=671854&r2=671855&view=diff
==============================================================================
--- webservices/axis2/trunk/c/tools/tcpmon/src/util.c (original)
+++ webservices/axis2/trunk/c/tools/tcpmon/src/util.c Thu Jun 26 04:12:18 2008
@@ -18,6 +18,7 @@
 
 #include <tcpmon_util.h>
 #include <axiom.h>
+#include <stdlib.h>
 
 #define START_ELEMENT 1
 #define CHAR_VALUE 2
@@ -487,3 +488,64 @@
 
     return dest;
 }
+
+char *
+str_replace(
+    char *str,
+    const char *search,
+    const char *replace)
+{
+    int size = ((int)strlen(str)) * 2;
+    /* We are sure that the difference lies within the int range */
+    int addmem = size;
+    int diff = (int)(strlen(replace) - strlen(search));
+    /* We are sure that the difference lies within the int range */
+
+    char *str_return = (char *) malloc((size + 1) * sizeof(char));
+    char *str_tmp = (char *) malloc(size * sizeof(char));
+    char *str_relic;
+
+    if (str_return == NULL || str_tmp == NULL)
+    {
+        free(str_return);
+        free(str_tmp);
+        return "function str_replace : give me more memory";
+    }
+    if (!strcmp(search, replace))
+    {
+        free(str_return);
+        free(str_tmp);
+        return str;
+    }
+
+    strcpy(str_return, str);
+
+    while ((str_relic = strstr(str_return, search)) != NULL)
+    {
+        if ((int)strlen(str_return) + diff >= addmem)
+            /* We are sure that the difference lies within the int range */
+        {
+            str_return = (char *) realloc(str_return, addmem += size);
+            str_tmp = (char *) realloc(str_tmp, addmem);
+
+            if (str_return == NULL || str_tmp == NULL)
+            {
+                free(str_return);
+                free(str_tmp);
+                return "function str_replace : gimme more memory";
+            }
+        }
+
+        strcpy(str_tmp, replace);
+        strcat(str_tmp, (str_relic + strlen(search)));
+        *str_relic = '\0';
+
+        strcat(str_return, str_tmp);
+    }
+
+    free(str_tmp);
+    /* free(str); */ /* we are not allocating memory using str */
+    str_return[addmem] = '\0';
+    return (str_return);
+}
+