axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nand...@apache.org
Subject svn commit: r439300 [2/2] - in /webservices/axis2/trunk/c/tools/tcpmon: ./ include/ src/ test/ test/unit/
Date Fri, 01 Sep 2006 12:55:46 GMT
Added: webservices/axis2/trunk/c/tools/tcpmon/src/tcpmon_entry_local.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/tools/tcpmon/src/tcpmon_entry_local.h?rev=439300&view=auto
==============================================================================
--- webservices/axis2/trunk/c/tools/tcpmon/src/tcpmon_entry_local.h (added)
+++ webservices/axis2/trunk/c/tools/tcpmon/src/tcpmon_entry_local.h Fri Sep  1 05:55:44 2006
@@ -0,0 +1,13 @@
+#include <axis2_env.h>
+#include <tcpmon_entry.h>
+#include <tcpmon_session_local.h>
+
+typedef struct tcpmon_entry_request_data
+{
+    const axis2_env_t* env;
+    int socket;
+    tcpmon_session_t* session;
+} tcpmon_entry_request_data_t;
+
+void* tcpmon_entry_new_entry_funct(axis2_thread_t *thd, void* data);
+

Added: webservices/axis2/trunk/c/tools/tcpmon/src/tcpmon_session_local.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/tools/tcpmon/src/tcpmon_session_local.h?rev=439300&view=auto
==============================================================================
--- webservices/axis2/trunk/c/tools/tcpmon/src/tcpmon_session_local.h (added)
+++ webservices/axis2/trunk/c/tools/tcpmon/src/tcpmon_session_local.h Fri Sep  1 05:55:44
2006
@@ -0,0 +1,14 @@
+#include <tcpmon_session.h>
+#include <tcpmon_entry.h>
+
+axis2_status_t
+tcpmon_session_add_new_entry( tcpmon_session_t* session,
+                              const axis2_env_t* env, tcpmon_entry_t* entry);
+
+TCPMON_SESSION_TRANS_ERROR_FUNCT
+tcpmon_session_get_on_trans_fault (tcpmon_session_t *session,
+                        const axis2_env_t *env );
+
+TCPMON_SESSION_NEW_ENTRY_FUNCT
+tcpmon_session_get_on_new_entry (tcpmon_session_t *session,
+                        const axis2_env_t *env );

Added: 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=439300&view=auto
==============================================================================
--- webservices/axis2/trunk/c/tools/tcpmon/src/util.c (added)
+++ webservices/axis2/trunk/c/tools/tcpmon/src/util.c Fri Sep  1 05:55:44 2006
@@ -0,0 +1,210 @@
+#include <tcpmon_util.h>
+#include <axis2_string.h>
+
+typedef struct tcpmon_util_allocator
+{
+    int allocated;
+    int index;
+    axis2_char_t* buffer;
+} tcpmon_util_allocator_t;
+
+
+static void add_string( const axis2_env_t* env, 
+                      tcpmon_util_allocator_t* allocator, 
+                      axis2_char_t* string);
+
+static void add_axis2_char_t( const axis2_env_t* env, 
+                      tcpmon_util_allocator_t* allocator, 
+                      axis2_char_t c,
+                      int turns);
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+tcpmon_util_format_as_xml (const axis2_env_t* env, axis2_char_t* data)
+{
+    tcpmon_util_allocator_t* allocator = NULL;
+    axis2_char_t* p = NULL;
+    axis2_char_t* flag = NULL;
+    axis2_char_t tmp;
+    int tabs = 0;
+    int xml_part_found = 0;
+   
+    allocator = (tcpmon_util_allocator_t*) AXIS2_MALLOC(env->
+        allocator, sizeof(tcpmon_util_allocator_t));
+    allocator-> buffer = NULL;
+    allocator-> allocated = 0;
+    allocator-> index = 0;
+
+    for ( p = flag = data, tabs = 0 ; *p ; p ++)
+    {
+        /** dont do anything until this is seen */
+        for(  ;!xml_part_found && *p && !( *p == '<' && *(p+1)
== '?'); p ++)
+        {
+            /** just a new line */
+            if ( *p =='\n')
+            {
+                tmp = *(p+1);
+                *(p+1) = '\0';
+                add_string ( env, allocator, flag );
+                *(p+1) = tmp;
+                flag = p+1;
+            }
+        }
+        xml_part_found = 1; /* we come here after we found xml */
+        /** found a comment */
+        if ( *p == '<'  && *(p+1) =='!'  /**just continue since string conts */
+                        && *(p+2) =='-'
+                        && *(p+3) =='-')
+        {
+            for ( ; *p ; p ++ )
+            {
+
+                /** end the comment */
+                if ( *p == '-' && *(p+1) =='-' 
+                              && *(p+2) =='>' )
+                {
+                    break;
+                }
+                /** just a new line */
+                if ( *p =='\n')
+                {
+                    tmp = *(p+1);
+                    *(p+1) = '\0';
+                    add_string ( env, allocator, flag );
+                    *(p+1) = tmp;
+                    flag = p+1;
+                    add_axis2_char_t (env, allocator, '\n', 1);
+                    add_axis2_char_t ( env, allocator, '\t', tabs );
+                }
+            }
+            /** end the strig insdie the comment:| */
+            if ( !*p )
+            {
+                break;
+            }
+        }
+        /** found a quote*/
+        if ( *p == '"'  )
+        {
+            for( ; *p && *p != '"'; p ++ );
+            if ( !*p)
+            {
+                break;
+            }
+        }
+
+        /** open tag */ 
+        if ( *p =='<'  && !( *(p+1) =='/' || *(p+1) == '?' ) )
+        {
+            tabs ++;
+        }
+        /** close tag */
+        if ( *p =='<'  &&  *(p+1) =='/' )
+        {
+            tabs --;
+            tmp = *p;
+            *p = '\0';
+            add_string ( env, allocator, flag );
+            add_axis2_char_t (env, allocator, '\n', 1);
+            add_axis2_char_t (env, allocator, '\t', tabs);
+            *p = tmp;
+            flag = p;
+        }
+        /** found '>' go to a new line */
+        if ( *p =='>' )
+        {
+            /** ignore spaces */
+            for( ; *p && *p == ' '; p ++ );
+            if ( !*p)
+            {
+                break;
+            }
+
+            /** these are special case - new line would be set on next iterate */
+            if ( *(p+1) =='<' && *(p+2) =='/' )
+            {
+            }
+            else if ( p !=data && *(p-1) =='?' ) /* ignore this case */
+            {
+            }
+            else
+            {
+                tmp = *(p+1);
+                *(p+1) = '\0';
+                add_string ( env, allocator, flag );
+                *(p+1) = tmp;
+                flag = p+1;
+    
+                add_axis2_char_t (env, allocator, '\n', 1);
+                add_axis2_char_t (env, allocator, '\t', tabs);
+            }
+        }
+    }
+    *(allocator-> buffer + allocator-> index) = '\0';
+    return allocator-> buffer;
+}
+
+void add_string( const axis2_env_t* env,
+               tcpmon_util_allocator_t* allocator, 
+               axis2_char_t* string )
+{
+    int additional_len = 0;
+    void* dest = NULL;
+    void* src = NULL;
+    int count = 0;
+
+    additional_len = AXIS2_STRLEN ( string ) +1;
+    if ( allocator-> index + additional_len  >= allocator-> allocated )
+    {
+        if ( allocator-> allocated == 0 )
+        {
+            allocator-> buffer =
+                    AXIS2_MALLOC ( env-> allocator, additional_len );
+        }
+        else
+        {
+            allocator-> buffer =
+                    AXIS2_REALLOC ( env-> allocator, allocator-> buffer, 
+                                allocator-> allocated + additional_len);
+        }
+        allocator-> allocated += additional_len;
+    }
+    
+    /* copy memory */
+    dest = allocator-> buffer + allocator-> index;
+    src = string;
+    count = additional_len; /* this is with the terminating zero */
+    memcpy ( dest, src, count );
+   
+    allocator-> index += count -1;
+}
+
+void add_axis2_char_t( const axis2_env_t* env,
+               tcpmon_util_allocator_t* allocator, 
+               axis2_char_t c,
+               int turns)
+{
+    int additional_len = 0;
+
+    additional_len = turns + 1;
+    if ( allocator-> index + additional_len  >= allocator-> allocated )
+    {
+        if ( allocator-> allocated == 0 )
+        {
+            allocator-> buffer =
+                    AXIS2_MALLOC ( env-> allocator, additional_len );
+        }
+        else
+        {
+            allocator-> buffer =
+                    AXIS2_REALLOC ( env-> allocator, allocator-> buffer, 
+                                allocator-> allocated + additional_len);
+        }
+        allocator-> allocated += additional_len;
+    }
+    
+    /* copy memory */
+    memset ( allocator-> buffer + allocator-> index, c, turns );
+
+    allocator-> index += turns;
+    
+}

Added: webservices/axis2/trunk/c/tools/tcpmon/test/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/tools/tcpmon/test/Makefile.am?rev=439300&view=auto
==============================================================================
--- webservices/axis2/trunk/c/tools/tcpmon/test/Makefile.am (added)
+++ webservices/axis2/trunk/c/tools/tcpmon/test/Makefile.am Fri Sep  1 05:55:44 2006
@@ -0,0 +1 @@
+SUBDIRS = unit

Added: webservices/axis2/trunk/c/tools/tcpmon/test/unit/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/tools/tcpmon/test/unit/Makefile.am?rev=439300&view=auto
==============================================================================
--- webservices/axis2/trunk/c/tools/tcpmon/test/unit/Makefile.am (added)
+++ webservices/axis2/trunk/c/tools/tcpmon/test/unit/Makefile.am Fri Sep  1 05:55:44 2006
@@ -0,0 +1,19 @@
+TESTS =
+prgbindir=$(prefix)/bin/unit_test
+prgbin_PROGRAMS = tcpmon_unit_test_suite
+
+tcpmon_unit_test_suite_SOURCES = main.c tcpmon_test.c
+
+tcpmon_unit_test_suite_LDADD   =   \
+                     $(top_builddir)/src/libaxis2_tcpmon.la \
+                     -L$(CUTEST_HOME)/lib \
+                     -lcutest \
+                     -L$(AXIS2C_HOME)/lib \
+                     -laxis2_util \
+                     $(NULL)
+
+
+INCLUDES = -I${CUTEST_HOME}/include \
+           -I$(top_builddir)/include \
+           @UTILINC@ \
+           $(NULL)

Added: webservices/axis2/trunk/c/tools/tcpmon/test/unit/main.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/tools/tcpmon/test/unit/main.c?rev=439300&view=auto
==============================================================================
--- webservices/axis2/trunk/c/tools/tcpmon/test/unit/main.c (added)
+++ webservices/axis2/trunk/c/tools/tcpmon/test/unit/main.c Fri Sep  1 05:55:44 2006
@@ -0,0 +1,20 @@
+#include <CuTest.h>
+#include <stdio.h>
+#include "tcpmon_test.h"
+
+void RunAllTests(void) {
+    CuString *output = CuStringNew();
+    CuSuite* suite = CuSuiteNew();
+
+    CuSuiteAddSuite(suite, (CuSuite*)tcpmon_GetSuite());
+
+    CuSuiteRun(suite);
+    CuSuiteSummary(suite, output);
+    CuSuiteDetails(suite, output);
+    printf("%s\n", output->buffer);
+}
+
+int main(void) {
+    RunAllTests();
+    return 0;
+}

Added: webservices/axis2/trunk/c/tools/tcpmon/test/unit/result
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/tools/tcpmon/test/unit/result?rev=439300&view=auto
==============================================================================
--- webservices/axis2/trunk/c/tools/tcpmon/test/unit/result (added)
+++ webservices/axis2/trunk/c/tools/tcpmon/test/unit/result Fri Sep  1 05:55:44 2006
@@ -0,0 +1,14 @@
+F
+
+There was 1 failure:
+1) test_format_xml: tcpmon_test.c:28: expected <<input>
+  	check for one step
+  </input>
+  > but was <<input>
+	check for one step
+</input>
+í>
+
+!!!FAILURES!!!
+Runs: 1 Passes: 0 Fails: 1
+

Added: webservices/axis2/trunk/c/tools/tcpmon/test/unit/tcpmon_test.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/tools/tcpmon/test/unit/tcpmon_test.c?rev=439300&view=auto
==============================================================================
--- webservices/axis2/trunk/c/tools/tcpmon/test/unit/tcpmon_test.c (added)
+++ webservices/axis2/trunk/c/tools/tcpmon/test/unit/tcpmon_test.c Fri Sep  1 05:55:44 2006
@@ -0,0 +1,77 @@
+#include <CuTest.h>
+#include <axis2_utils.h>
+#include "tcpmon_test.h"
+#include <stdlib.h>
+#include <axis2_string.h>
+
+#include <tcpmon_util.h>
+
+void test_format_xml(CuTest *tc)
+{
+    axis2_env_t *env;
+    axis2_allocator_t *allocator;
+    axis2_char_t* input;
+    axis2_char_t* actual;
+    axis2_char_t* expected;
+
+    allocator = axis2_allocator_init(NULL);
+    env = axis2_env_create(allocator);
+
+    input = (char*)AXIS2_STRDUP(
+             "<input>check for one step</input>",
+                                              env);
+    actual = 
+      (char*)tcpmon_util_format_as_xml(env, input);
+    expected = "<input>\n"
+               "\tcheck for one step\n" 
+               "</input>\n";
+    CuAssertStrEquals(tc, expected, actual);
+    free (actual);
+    free (input);
+
+
+    input = (char*)AXIS2_STRDUP(
+             "<input><tag2><another_tag with='attriutes'>check for one
step</another_tag></tag2></input>",
+                                              env);
+    actual = 
+      (char*)tcpmon_util_format_as_xml(env, input);
+    expected = 
+               "<input>\n"
+               "\t<tag2>\n"
+               "\t\t<another_tag with='attriutes'>\n"
+               "\t\t\tcheck for one step\n"
+               "\t\t</another_tag>\n"
+               "\t</tag2>\n"
+               "</input>\n";
+
+    CuAssertStrEquals(tc, expected, actual);
+    free (actual);
+    free (input);
+
+    input = (char*)AXIS2_STRDUP(
+             "<?processing inc?><input><tag2><another_tag with='attriutes'>check
for one step</another_tag></tag2></input>",
+                                              env);
+    actual = 
+      (char*)tcpmon_util_format_as_xml(env, input);
+    expected = "<?processing inc?>\n"
+               "<input>\n"
+               "\t<tag2>\n"
+               "\t\t<another_tag with='attriutes'>\n"
+               "\t\t\tcheck for one step\n"
+               "\t\t</another_tag>\n"
+               "\t</tag2>\n"
+               "</input>\n";
+
+    CuAssertStrEquals(tc, expected, actual);
+    free (actual);
+    free (input);
+
+}
+
+CuSuite* tcpmon_GetSuite()
+{
+    CuSuite* suite = CuSuiteNew();
+    SUITE_ADD_TEST(suite, test_format_xml);
+    return suite;
+}
+

Added: webservices/axis2/trunk/c/tools/tcpmon/test/unit/tcpmon_test.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/tools/tcpmon/test/unit/tcpmon_test.h?rev=439300&view=auto
==============================================================================
--- webservices/axis2/trunk/c/tools/tcpmon/test/unit/tcpmon_test.h (added)
+++ webservices/axis2/trunk/c/tools/tcpmon/test/unit/tcpmon_test.h Fri Sep  1 05:55:44 2006
@@ -0,0 +1,9 @@
+#ifndef TCPMON_TEST_H
+#define TCPMON_TEST_H
+
+#include <CuTest.h>
+
+CuSuite* tcpmon_GetSuite();
+
+#endif /* TCPMON_TEST_H */
+



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message