axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From din...@apache.org
Subject svn commit: r441454 - in /webservices/axis2/trunk/c/guththila: ./ include/ samples/ src/
Date Fri, 08 Sep 2006 09:33:43 GMT
Author: dinesh
Date: Fri Sep  8 02:33:42 2006
New Revision: 441454

URL: http://svn.apache.org/viewvc?view=rev&rev=441454
Log:
reader and writer modified to deal with memory buffer, memory reader and writer is added

Modified:
    webservices/axis2/trunk/c/guththila/Makefile.am
    webservices/axis2/trunk/c/guththila/configure.ac
    webservices/axis2/trunk/c/guththila/include/guththila_buffer.h
    webservices/axis2/trunk/c/guththila/include/guththila_error.h
    webservices/axis2/trunk/c/guththila/include/guththila_reader.h
    webservices/axis2/trunk/c/guththila/include/guththila_writer.h
    webservices/axis2/trunk/c/guththila/include/guththila_xml_pull_parser.h
    webservices/axis2/trunk/c/guththila/samples/guththila_main.c
    webservices/axis2/trunk/c/guththila/samples/guththila_writer_main.c
    webservices/axis2/trunk/c/guththila/src/Makefile.am
    webservices/axis2/trunk/c/guththila/src/guththila_buffer.c
    webservices/axis2/trunk/c/guththila/src/guththila_reader.c
    webservices/axis2/trunk/c/guththila/src/guththila_writer.c
    webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.c
    webservices/axis2/trunk/c/guththila/src/guththila_xml_writer.c

Modified: webservices/axis2/trunk/c/guththila/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/Makefile.am?view=diff&rev=441454&r1=441453&r2=441454
==============================================================================
--- webservices/axis2/trunk/c/guththila/Makefile.am (original)
+++ webservices/axis2/trunk/c/guththila/Makefile.am Fri Sep  8 02:33:42 2006
@@ -1,6 +1,6 @@
 #datadir=$(prefix)
 SUBDIRS = src 
-#include_HEADERS=$(top_builddir)/include/*.h
+include_HEADERS=$(top_builddir)/include/*.h
 data_DATA= INSTALL README AUTHORS NEWS LICENSE COPYING
 #EXTRA_DIST = build.sh autogen.sh CREDITS LICENSE
 dist-hook:

Modified: webservices/axis2/trunk/c/guththila/configure.ac
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/configure.ac?view=diff&rev=441454&r1=441453&r2=441454
==============================================================================
--- webservices/axis2/trunk/c/guththila/configure.ac (original)
+++ webservices/axis2/trunk/c/guththila/configure.ac Fri Sep  8 02:33:42 2006
@@ -22,7 +22,7 @@
 
 CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE"
 if test "$GCC" = "yes"; then
-    CFLAGS="$CFLAGS -ansi -Wall -Wno-implicit-function-declaration"
+    CFLAGS="$CFLAGS -ansi -ggdb3 -Wall -Wno-implicit-function-declaration -Werror"
 fi
 LDFLAGS="-lpthread"
 

Modified: webservices/axis2/trunk/c/guththila/include/guththila_buffer.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/include/guththila_buffer.h?view=diff&rev=441454&r1=441453&r2=441454
==============================================================================
--- webservices/axis2/trunk/c/guththila/include/guththila_buffer.h (original)
+++ webservices/axis2/trunk/c/guththila/include/guththila_buffer.h Fri Sep  8 02:33:42 2006
@@ -27,16 +27,20 @@
 
 typedef struct guththila_buffer_s
 {
-    int size;
-    int next;
-    int last;
-    int offset;
-    guththila_char_t *buff;
+  int size;
+  int next;
+  int last;
+  int offset;
+  int is_memory;
+  guththila_char_t *buff;
 } guththila_buffer_t;
 
 
 AXIS2_EXTERN guththila_buffer_t *
 guththila_buffer_create (axis2_env_t * environment, int size);
+
+AXIS2_EXTERN guththila_buffer_t *
+guththila_buffer_create_for_buffer (axis2_env_t * environment, char *buffer, int size);
 
 AXIS2_EXTERN void
 guththila_buffer_free (axis2_env_t * environment,

Modified: webservices/axis2/trunk/c/guththila/include/guththila_error.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/include/guththila_error.h?view=diff&rev=441454&r1=441453&r2=441454
==============================================================================
--- webservices/axis2/trunk/c/guththila/include/guththila_error.h (original)
+++ webservices/axis2/trunk/c/guththila/include/guththila_error.h Fri Sep  8 02:33:42 2006
@@ -91,7 +91,8 @@
       GUTHTHILA_WRITER_ERROR_XML_STRING_IN_NAME,
       GUTHTHILA_WRITER_ERROR_EXCESS_HYPENS_IN_COMMENT,
       GUTHTHILA_WRITER_ERROR_INVALID_CHAR_IN_ATTRIBUTE,
-      GUTHTHILA_WRITER_ERROR_NON_EXSISTING_URI
+      GUTHTHILA_WRITER_ERROR_NON_EXSISTING_URI,
+      GUTHTHILA_WRITER_ERROR_SAME_ATTRIBUTE_REPEAT
     } guththila_error_codes_t;
 
 

Modified: webservices/axis2/trunk/c/guththila/include/guththila_reader.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/include/guththila_reader.h?view=diff&rev=441454&r1=441453&r2=441454
==============================================================================
--- webservices/axis2/trunk/c/guththila/include/guththila_reader.h (original)
+++ webservices/axis2/trunk/c/guththila/include/guththila_reader.h Fri Sep  8 02:33:42 2006
@@ -22,8 +22,8 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include "guththila_buffer.h"
-/* #include "guththila_environment.h" */
 #include "guththila_defines.h"
 #include <axis2_env.h>
 #include "guththila_error.h"
@@ -31,7 +31,8 @@
 typedef enum guththila_reader_types
   {
     GUTHTHILA_FILE_READER = 1,
-    GUTHTHILA_IN_MEMORY_READER
+    GUTHTHILA_IO_READER,
+    GUTHTHILA_MEMORY_READER
   } guththila_reader_types_t;
 
 typedef struct guththila_reader_s
@@ -41,15 +42,32 @@
 } guththila_reader_t;
 
 
+
+typedef struct guththila_reader_impl_t
+{
+  guththila_reader_t reader;
+  int buffer_size;
+  FILE *fp;
+  char *buffer;
+  int (*input_read_callback)(char *buffer,int size, void *ctx);
+  void* context;
+}guththila_reader_impl_t;
+
+
 AXIS2_EXTERN guththila_reader_t *
 guththila_reader_create_for_file (axis2_env_t * environment,
                                   char* filename);
 
 AXIS2_EXTERN guththila_reader_t *
-guththila_reader_create_for_memory(axis2_env_t *environment,
+guththila_reader_create_for_io(axis2_env_t *environment,
                                    int (*input_read_callback)
                                        (char *buffer,int size,void* ctx),void *ctx);
-                                   
+
+AXIS2_EXTERN guththila_reader_t *
+guththila_reader_create_for_memory(axis2_env_t *environment,
+                                   void *buffer,
+                                    int size,
+				   void *ctx);                                   
 AXIS2_EXTERN int
 guththila_reader_read (axis2_env_t * environment,
                        guththila_char_t * buffer, int offset, int length,

Modified: webservices/axis2/trunk/c/guththila/include/guththila_writer.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/include/guththila_writer.h?view=diff&rev=441454&r1=441453&r2=441454
==============================================================================
--- webservices/axis2/trunk/c/guththila/include/guththila_writer.h (original)
+++ webservices/axis2/trunk/c/guththila/include/guththila_writer.h Fri Sep  8 02:33:42 2006
@@ -20,6 +20,7 @@
 #define GUTHTHILA_WRITER_H
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include "guththila_buffer.h"
 #include <axis2_env.h>
 #include "guththila_defines.h"
@@ -27,8 +28,8 @@
 
 typedef enum guththila_writer_types
   {
-    GUTHTHILA_WRITER_CREATE_FOR_FILE = 1,
-    GUTHTHILA_WRITER_CREATE_FOR_MEMORY
+    GUTHTHILA_WRITER_FILE = 1,
+    GUTHTHILA_WRITER_MEMORY
   }guththila_writer_types_t;
 
 typedef struct guththila_writer_s
@@ -40,24 +41,30 @@
 {
   guththila_writer_t writer;
   FILE *outputstream;
+  guththila_buffer_t *buffer;
 }guththila_writer_impl_t; 
 
 AXIS2_EXTERN guththila_writer_t* AXIS2_CALL
 guththila_writer_create_for_file(axis2_env_t *env, 
     char *fp);
 
+AXIS2_EXTERN guththila_writer_t* AXIS2_CALL
+guththila_writer_create_for_memory (axis2_env_t *env);
+
 
 AXIS2_EXTERN int AXIS2_CALL
 guththila_writer_write(axis2_env_t *env, 
-    char *buffer, 
-    int offset, 
-    int length, 
-    guththila_writer_t *wt);
+		       char *buffer, 
+		       int offset, 
+		       int length, 
+		       guththila_writer_t *wt);
 
 
 AXIS2_EXTERN void 
-guththila_writer_free 
-(axis2_env_t *env, 
- guththila_writer_t *wt);
+guththila_writer_free (axis2_env_t *env, 
+		       guththila_writer_t *wt);
 
+AXIS2_EXTERN char *
+guththila_writer_get_buffer (axis2_env_t *env, 
+		       guththila_writer_t *wt);
 #endif	/* GUTHTHILA_WRITE_H */

Modified: webservices/axis2/trunk/c/guththila/include/guththila_xml_pull_parser.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/include/guththila_xml_pull_parser.h?view=diff&rev=441454&r1=441453&r2=441454
==============================================================================
--- webservices/axis2/trunk/c/guththila/include/guththila_xml_pull_parser.h (original)
+++ webservices/axis2/trunk/c/guththila/include/guththila_xml_pull_parser.h Fri Sep  8 02:33:42 2006
@@ -89,6 +89,7 @@
   int offset;
   int last;
   int unicode_state;
+  int reader_type;
   enum guththila_status status;
   enum guththila_event_types guththila_event;
 } guththila_xml_pull_parser_t;
@@ -204,8 +205,8 @@
 						   int c);
                                               
                                               
-int AXIS2_CALL
-guththila_xml_pull_parser_is_space (axis2_env_t *environment, int c);
+/* int AXIS2_CALL */
+/* guththila_xml_pull_parser_is_space (axis2_env_t *environment, int c); */
 
 
 void AXIS2_CALL
@@ -365,6 +366,9 @@
 						    guththila_xml_pull_parser_t *p, 
 						    char *fp);
 
+AXIS2_EXTERN void  AXIS2_CALL
+guththila_xml_pull_parser_create_xml_stream_writer_for_memory (axis2_env_t *environment, 
+						    guththila_xml_pull_parser_t *p);
 
 AXIS2_EXTERN void AXIS2_CALL
 guththila_xml_pull_parser_write_to_buffer (axis2_env_t *env, 
@@ -609,6 +613,10 @@
 				      guththila_xml_pull_parser_t *p, 
 				      char *element_name, 
 				      char *characters);
+
+AXIS2_EXTERN char * AXIS2_CALL
+guththila_xml_pull_parser_get_memory_buffer (axis2_env_t *environemnt, 
+					     guththila_xml_pull_parser_t *p);
 
 AXIS2_EXTERN void AXIS2_CALL
 guththila_xml_pull_parser_xml_writer_free (axis2_env_t *environment,

Modified: webservices/axis2/trunk/c/guththila/samples/guththila_main.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/samples/guththila_main.c?view=diff&rev=441454&r1=441453&r2=441454
==============================================================================
--- webservices/axis2/trunk/c/guththila/samples/guththila_main.c (original)
+++ webservices/axis2/trunk/c/guththila/samples/guththila_main.c Fri Sep  8 02:33:42 2006
@@ -19,7 +19,7 @@
 
 #include "guththila_xml_pull_parser.h"
 #include "guththila_defines.h"
-/* #include "guththila_environment.h" */
+#include "buffer.h"
 
 int
 main (int argc, char *argv[])
@@ -32,7 +32,19 @@
     allocator = axis2_allocator_init (NULL);
     environment =
         axis2_env_create (allocator);
-    red = guththila_reader_create_for_file (environment, argv[1]);
+
+    if (argc > 1)
+      red = guththila_reader_create_for_file (environment, argv[1]);
+    else
+      {
+	if (xml_buffer)
+	  {
+	    int size = 0;
+	    size = strlen (xml_buffer);
+	    red = guththila_reader_create_for_memory (environment, (void *)xml_buffer, size, NULL);
+	  }
+      }
+    
     parser = guththila_xml_pull_parser_create (environment, red);
     guththila_xml_pull_parser_read (environment, parser);
 
@@ -62,7 +74,7 @@
                     printf ("%s\" ", p);
                     AXIS2_FREE (allocator, p);
                 }
-                printf ("?>");
+                printf ("?>\n");
             }
             break;
         case GUTHTHILA_START_ELEMENT:
@@ -74,7 +86,6 @@
 		guththila_depth_t *depth;
 
                 printf ("<");
-      /* printf ("\n %s \n", guththila_xml_pull_parser_get_encoding (environment, parser)); */
                 p = guththila_xml_pull_parser_get_prefix (environment,
                                                           parser);
                 if (p)
@@ -138,7 +149,6 @@
             {
                 char *p;
                 printf ("</");
-      /* printf ("\n %s \n", guththila_xml_pull_parser_get_encoding (environment, parser)); */
                 p = guththila_xml_pull_parser_get_prefix (environment,
                                                           parser);
                 if (p)
@@ -164,9 +174,6 @@
             break;
         };
     }
-    guththila_char_t *charq;
-    charq = guththila_xml_pull_parser_get_encoding (environment, parser);
-    printf ("encoding method is %s", charq);
     guththila_reader_free (environment, red);
     guththila_xml_pull_parser_free (environment, parser);
     axis2_allocator_free (allocator);

Modified: webservices/axis2/trunk/c/guththila/samples/guththila_writer_main.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/samples/guththila_writer_main.c?view=diff&rev=441454&r1=441453&r2=441454
==============================================================================
--- webservices/axis2/trunk/c/guththila/samples/guththila_writer_main.c (original)
+++ webservices/axis2/trunk/c/guththila/samples/guththila_writer_main.c Fri Sep  8 02:33:42 2006
@@ -1,13 +1,28 @@
 #include <stdio.h>
 #include <guththila_buffer.h>
 #include <guththila_reader.h>
+#include <guththila_writer.h>
 #include <guththila_xml_pull_parser.h>
 int main ()
 {
   axis2_allocator_t *allocator = axis2_allocator_init (NULL);
   axis2_env_t *env = axis2_env_create (allocator);
   guththila_xml_pull_parser_t *parser = guththila_xml_pull_parser_create (env, NULL);
-  guththila_xml_pull_parser_create_xml_stream_writer (env, parser, "w.xml");
+  guththila_writer_t *writer = guththila_writer_create_for_memory (env);
+/*   int c = 0; */
+/*   c = guththila_writer_write (env, "test", 0, 5, writer); */
+/* char *file = "<Template><Application1 xmlns:xplt=\"http://www.xxxx.com/\" xmlns:xpl=\"http://www.xxxx.com/\">first</Application1><Application2 xmlns:xplt=\"http://www.xxxx.com/\" xmlns:xpl=\"http://www.xxxx.com/\"> second</Application2> </Template>"; */
+
+/*   guththila_writer_write (env, file, 0, strlen (file), writer); */
+/*   guththila_writer_write (env, file, 0, strlen (file), writer); */
+/*   guththila_writer_write (env, file, 0, strlen (file), writer); */
+/*   guththila_writer_write (env, file, 0, strlen (file), writer); */
+/*   guththila_writer_write (env, file, 0, strlen (file), writer); */
+/*   guththila_writer_write (env, file, 0, strlen (file), writer); */
+/*   guththila_writer_write (env, file, 0, strlen (file), writer); */
+/*   char *t =  guththila_writer_get_buffer (env, writer); */
+/*   printf ("print \t %s \n", t); */
+  guththila_xml_pull_parser_create_xml_stream_writer_for_memory (env, parser);
   guththila_xml_pull_parser_write_start_document (env, parser);
   guththila_xml_pull_parser_write_start_element (env, parser, "person");
   guththila_xml_pull_parser_write_start_element (env, parser, "name");
@@ -25,6 +40,8 @@
   guththila_xml_pull_parser_write_start_element_with_prefix (env, parser, "a", "two");
   guththila_xml_pull_parser_write_characters (env, parser, "it works !");
   guththila_xml_pull_parser_write_end_document (env, parser);
+  char *t = guththila_writer_get_buffer (env, parser->xsw->writer);
+  printf ("%s \n", t);
   guththila_xml_pull_parser_xml_writer_free (env, parser);
   guththila_xml_pull_parser_free (env, parser);
   axis2_allocator_free (allocator);

Modified: webservices/axis2/trunk/c/guththila/src/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/Makefile.am?view=diff&rev=441454&r1=441453&r2=441454
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/Makefile.am (original)
+++ webservices/axis2/trunk/c/guththila/src/Makefile.am Fri Sep  8 02:33:42 2006
@@ -1,14 +1,14 @@
-lib_LTLIBRARIES = libaxis2_guththila.la
+lib_LTLIBRARIES = libguththila.la
 
-libaxis2_guththila_la_SOURCES = guththila_buffer.c \
-							guththila_token.c \
-							guththila_writer.c \
-							guththila_xml_pull_parser.c \
-							guththila_reader.c \
-							guththila_unicode.c \
-							guththila_xml_writer.c
+libguththila_la_SOURCES = guththila_buffer.c \
+	 		  guththila_token.c \
+			  guththila_reader.c \
+			  guththila_writer.c \
+			  guththila_xml_pull_parser.c \
+			  guththila_unicode.c \
+			  guththila_xml_writer.c
 
-libaxis2_guththila_la_LIBADD = -laxis2_util
+libguththila_la_LIBADD = -laxis2_util
 
 INCLUDES = -I$(top_builddir)/include \
 			@UTILINC@ 

Modified: webservices/axis2/trunk/c/guththila/src/guththila_buffer.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_buffer.c?view=diff&rev=441454&r1=441453&r2=441454
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_buffer.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_buffer.c Fri Sep  8 02:33:42 2006
@@ -18,25 +18,52 @@
 
 
 /* #include "guththila_environment.h" */
+#include <string.h>
 #include "guththila_buffer.h"
 #include <axis2_env.h>
 
 AXIS2_EXTERN guththila_buffer_t *
 guththila_buffer_create (axis2_env_t * environment, int size)
 {
-    guththila_buffer_t *name = AXIS2_MALLOC (environment->allocator,
+    guththila_buffer_t *name;
+    name = NULL;
+    name  = AXIS2_MALLOC (environment->allocator,
                                             sizeof (guththila_buffer_t));
-    name->size = size;
-    name->offset = 0;
-    name->last = 0;
-    name->next = 0;
-    name->buff = NULL;
-    if (size != 0)
-        name->buff = (guththila_char_t *) AXIS2_MALLOC (
-                                environment->allocator, size);
-    return name;
+    if (name)
+      {
+	name->size = size;
+	name->offset = 0;
+	name->last = 0;
+	name->next = 0;
+	name->is_memory = 0;
+	name->buff = NULL;
+	if (size != 0)
+	  name->buff = (guththila_char_t *) AXIS2_MALLOC (
+							  environment->allocator, size);
+      }
+	return name;
 }
 
+AXIS2_EXTERN guththila_buffer_t *
+guththila_buffer_create_for_buffer (axis2_env_t * environment, char *buffer, int size)
+{
+    guththila_buffer_t *name;
+    name = NULL;
+    name  = AXIS2_MALLOC (environment->allocator,
+                                            sizeof (guththila_buffer_t));
+    if (name)
+      {
+	name->size = size;
+	name->offset = 0;
+	name->is_memory = 1;
+	name->last = size;
+	name->next = 0;
+	name->buff = NULL;
+	if (buffer)
+	  name->buff = buffer;
+      }
+    return name;
+}
 
 AXIS2_EXTERN void
 guththila_buffer_free (axis2_env_t * environment,
@@ -44,7 +71,7 @@
 {
     if (name)
     {
-        if (name->buff)
+        if (name->buff && !name->is_memory)
         {
             AXIS2_FREE (environment->allocator, name->buff);
 	    name->buff = NULL;

Modified: webservices/axis2/trunk/c/guththila/src/guththila_reader.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_reader.c?view=diff&rev=441454&r1=441453&r2=441454
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_reader.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_reader.c Fri Sep  8 02:33:42 2006
@@ -21,15 +21,6 @@
 #include "guththila_defines.h"
 
 
-typedef struct guththila_reader_impl_t
-{
-    guththila_reader_t reader;
-    FILE *fp;
-    int (*input_read_callback)(char *buffer,int size, void *ctx);
-    void* context;
-}guththila_reader_impl_t;
-
-
 
 
 
@@ -61,10 +52,32 @@
 
 
 AXIS2_EXTERN guththila_reader_t *
-guththila_reader_create_for_memory(
+guththila_reader_create_for_io(
                 axis2_env_t *environment,
                 int (*input_read_callback)(char *buffer,int size,void* ctx),void* ctx)
 {
+    guththila_reader_impl_t *io_reader = 
+        (guththila_reader_impl_t *) AXIS2_MALLOC (environment->allocator,
+                                            sizeof (guththila_reader_impl_t));
+    if(!io_reader)
+    {
+        return NULL;
+    }
+    
+    io_reader->input_read_callback  = input_read_callback;
+    io_reader->context = ctx;
+    io_reader->reader.guththila_reader_type = GUTHTHILA_IO_READER;
+    
+    return &(io_reader->reader);
+}
+
+AXIS2_EXTERN guththila_reader_t *
+guththila_reader_create_for_memory(
+                axis2_env_t *environment,
+		void *buffer,
+                int size,
+		void* ctx)
+{
     guththila_reader_impl_t *memory_reader = 
         (guththila_reader_impl_t *) AXIS2_MALLOC (environment->allocator,
                                             sizeof (guththila_reader_impl_t));
@@ -73,14 +86,17 @@
         return NULL;
     }
     
-    memory_reader->input_read_callback  = input_read_callback;
+    if (buffer)
+      {
+	memory_reader->buffer  = (char *)buffer;
+	memory_reader->buffer_size = strlen ((const char *) buffer);
+      }
     memory_reader->context = ctx;
-    memory_reader->reader.guththila_reader_type = GUTHTHILA_IN_MEMORY_READER;
+    memory_reader->reader.guththila_reader_type = GUTHTHILA_MEMORY_READER;
     
     return &(memory_reader->reader);
 }
 
-
 AXIS2_EXTERN void
 guththila_reader_free (axis2_env_t * environment,
                        guththila_reader_t * r)
@@ -111,9 +127,13 @@
     {
        return (int)fread (buffer + offset, 1, length,((guththila_reader_impl_t*)r)->fp);
     }
-    else if(r->guththila_reader_type == GUTHTHILA_IN_MEMORY_READER)
+    else if(r->guththila_reader_type == GUTHTHILA_IO_READER)
         return ((guththila_reader_impl_t*)r)->input_read_callback((buffer + offset), length,
         ((guththila_reader_impl_t*)r)->context);
+    else if (r->guththila_reader_type == GUTHTHILA_MEMORY_READER)
+      {
+	return ((guththila_reader_impl_t *)r)->buffer_size;
+      }
  
     return GUTHTHILA_FAILURE;       
 }

Modified: webservices/axis2/trunk/c/guththila/src/guththila_writer.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_writer.c?view=diff&rev=441454&r1=441453&r2=441454
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_writer.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_writer.c Fri Sep  8 02:33:42 2006
@@ -29,16 +29,33 @@
       wt->outputstream = fopen (fp, "w");
       if (!wt->outputstream)
         return NULL;
-     wt->writer.guththila_writer_type = GUTHTHILA_WRITER_CREATE_FOR_FILE;
+     wt->writer.guththila_writer_type = GUTHTHILA_WRITER_FILE;
     return &(wt->writer);
 }
 
+AXIS2_EXTERN guththila_writer_t * AXIS2_CALL
+guththila_writer_create_for_memory (axis2_env_t *env)
+{
+      guththila_writer_impl_t *wt = NULL;
+
+      wt = (guththila_writer_impl_t *) AXIS2_MALLOC (env->allocator, sizeof (guththila_writer_impl_t));
+      wt->outputstream = NULL;
+
+      wt->buffer = guththila_buffer_create (env, 1024);
+      memset ((void *)wt->buffer->buff, 0, 1024);
+      if (!wt->buffer)
+	return NULL;
+      
+      wt->writer.guththila_writer_type = GUTHTHILA_WRITER_MEMORY;
+      return &(wt->writer);
+}
+
 AXIS2_EXTERN void
 guththila_writer_free (axis2_env_t *env, guththila_writer_t *wt)
 {
   if (wt)
     {
-      if (wt->guththila_writer_type == GUTHTHILA_WRITER_CREATE_FOR_FILE)
+      if (wt->guththila_writer_type == GUTHTHILA_WRITER_FILE)
 	{
 	  if (((guththila_writer_impl_t *)wt)->outputstream)
 	    fclose (((guththila_writer_impl_t *)wt)->outputstream);
@@ -54,12 +71,40 @@
     char *buffer, int offset, 
     int length, guththila_writer_t *wt)
 {
-    if (wt->guththila_writer_type == GUTHTHILA_WRITER_CREATE_FOR_FILE)
+  int c = 0;
+  guththila_writer_impl_t *writer_impl = NULL;
+    if (wt->guththila_writer_type == GUTHTHILA_WRITER_FILE)
     {
-        int c;
         c = fwrite (buffer+offset, 1, length, ((guththila_writer_impl_t *)wt)->outputstream);
-        return c;
     }
-    else 
-        return 0;
+    else if (wt->guththila_writer_type == GUTHTHILA_WRITER_MEMORY)
+      {
+	int size = 0;
+	writer_impl = (guththila_writer_impl_t *)wt;
+
+	if (writer_impl->buffer->buff)
+	  size = strlen ((const char *)writer_impl->buffer->buff);
+
+	if ((size + length) > writer_impl->buffer->size)
+	  {
+	    writer_impl->buffer = guththila_buffer_grow (env, writer_impl->buffer);
+	  }
+	strcat (writer_impl->buffer->buff, buffer);
+	c = length;
+      }
+    return c;
+}
+
+
+AXIS2_EXTERN char * AXIS2_CALL
+guththila_writer_get_buffer (axis2_env_t *env, 
+			     guththila_writer_t *wt)
+{
+  guththila_writer_impl_t *writer_impl = NULL;
+  writer_impl = (guththila_writer_impl_t *)wt;
+  
+  if (writer_impl->buffer->buff)
+    return (char *)writer_impl->buffer->buff;
+  else 
+    return (char *)NULL;
 }

Modified: webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.c?view=diff&rev=441454&r1=441453&r2=441454
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.c Fri Sep  8 02:33:42 2006
@@ -18,11 +18,11 @@
 
 #include <guththila_xml_pull_parser.h>
 
-static int AXIS2_CALL
-guththila_is_space (int c)
-{
-  return (0x20 == c || 0x9 == c || 0xD == c || 0xA == c);
-}
+/* static int AXIS2_CALL */
+/* guththila_is_space (int c) */
+/* { */
+/*   return (0x20 == c || 0x9 == c || 0xD == c || 0xA == c); */
+/* } */
 
 
 AXIS2_EXTERN guththila_xml_pull_parser_t * AXIS2_CALL
@@ -32,7 +32,22 @@
   guththila_xml_pull_parser_t *parser =
     (guththila_xml_pull_parser_t *) AXIS2_MALLOC (
 						  environment->allocator, sizeof (guththila_xml_pull_parser_t));
-  parser->buffer = guththila_buffer_create (environment, 1024);
+  guththila_reader_impl_t *reader_impl = NULL;
+  if (r)
+    {
+      reader_impl = (guththila_reader_impl_t *)r;
+      parser->reader_type = reader_impl->reader.guththila_reader_type;
+    }
+
+  if (reader_impl && reader_impl->reader.guththila_reader_type == GUTHTHILA_MEMORY_READER)
+    {
+      guththila_buffer_t *reader_buffer = NULL;
+      reader_buffer = guththila_buffer_create_for_buffer (environment, reader_impl->buffer, reader_impl->buffer_size);
+      parser->buffer = reader_buffer;
+    }
+  else
+    parser->buffer = guththila_buffer_create (environment, 1024);
+
   parser->stack = axis2_stack_create (environment);
   parser->attrib = axis2_stack_create (environment);
   parser->namesp = axis2_stack_create (environment);
@@ -56,8 +71,15 @@
 guththila_xml_pull_parser_free (axis2_env_t * environment,
                                 guththila_xml_pull_parser_t * parser)
 {
-  if (parser->buffer)
+  /*   if (parser->reader_type != GUTHTHILA_MEMORY_READER) */
+  /*     { */
+  /*        if (parser->buffer) */
+  /* 	guththila_buffer_free (environment, (void *) parser->buffer); */
+  /*     } */
+
+  if (parser->buffer) 
     guththila_buffer_free (environment, (void *) parser->buffer);
+
   if (parser->stack)
     AXIS2_STACK_FREE (parser->stack, environment);
   if (parser->attrib)
@@ -174,14 +196,21 @@
                                      guththila_xml_pull_parser_t * parser,
                                      int eof)
 {
-  if (((parser->_next) > (parser->last))
-      && guththila_xml_pull_parser_read (environment, parser))
+
+  if (parser->reader_type == GUTHTHILA_MEMORY_READER)
+    {
+      if (parser->_next > parser->last)
+	return -1;
+    }
+  else  if (((parser->_next) > (parser->last))
+	    && guththila_xml_pull_parser_read (environment, parser))
     {
       if (eof)
 	return -1;
       else
 	guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_ERROR_UNEXPECTED_EOF);
     }
+
   if (parser->_next == 0)
     {
       guththila_UTF8_char iu =
@@ -468,7 +497,11 @@
 	      guththila_xml_pull_parser_next_char (environment, parser, 0))
 	    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_ERROR_MISSING_GREATER_SIGN_IN_XML_DECLARATION);
 	  else
-	    parser->guththila_event = GUTHTHILA_START_DOCUMENT;
+	    {
+	      while (guththila_xml_pull_parser_is_space (environment, guththila_xml_pull_parser_next_char (environment, parser, 0))); 
+	      parser->_next--;
+	      parser->guththila_event = GUTHTHILA_START_DOCUMENT;
+	    }
         }
     }
   else
@@ -481,32 +514,32 @@
 guththila_xml_pull_parser_reset (axis2_env_t * environment,
                                  guththila_xml_pull_parser_t * parser)
 {
-    int ii; 
-    parser->offset = parser->_next;
-    parser->name = NULL;
-    parser->prefix = NULL;
-    parser->value = NULL;
+  int ii; 
+  parser->offset = parser->_next;
+  parser->name = NULL;
+  parser->prefix = NULL;
+  parser->value = NULL;
       
-    ii = AXIS2_STACK_SIZE (parser->attrib, environment);
-    for (; ii > 0; ii--)
+  ii = AXIS2_STACK_SIZE (parser->attrib, environment);
+  for (; ii > 0; ii--)
     {
-        void *d;
-        d = AXIS2_STACK_POP (parser->attrib, environment);
-        AXIS2_FREE (environment->allocator, d);
+      void *d;
+      d = AXIS2_STACK_POP (parser->attrib, environment);
+      AXIS2_FREE (environment->allocator, d);
     }
 
-    ii = AXIS2_STACK_SIZE (parser->stack, environment);
-    for (; ii > 0; ii--)
+  ii = AXIS2_STACK_SIZE (parser->stack, environment);
+  for (; ii > 0; ii--)
     {
-        void *d;
-        d = AXIS2_STACK_POP (parser->stack, environment);
-        AXIS2_FREE (environment->allocator, d);
+      void *d;
+      d = AXIS2_STACK_POP (parser->stack, environment);
+      AXIS2_FREE (environment->allocator, d);
     }
   /*   guththila_stack_clear (environment, parser->attrib); */
   /*   guththila_stack_clear (environment, parser->stack); */
   if(parser->guththila_event == GUTHTHILA_END_ELEMENT
-      || parser->guththila_event == GUTHTHILA_EMPTY_ELEMENT)
-        guththila_xml_pull_parser_close_element (environment, parser);
+     || parser->guththila_event == GUTHTHILA_EMPTY_ELEMENT)
+    guththila_xml_pull_parser_close_element (environment, parser);
 }
 
 
@@ -1207,7 +1240,7 @@
 {
   /*   int ix = parser->attrib->pointer; */
   int ix = AXIS2_STACK_SIZE (parser->attrib, environment);
-  guththila_attribute_t *attribute;
+  guththila_attribute_t *attribute = NULL;
   if (i > ix)
     guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_ERROR_REQUESTED_NUMBER_GREATER_THAN_STACK_SIZE);
   else
@@ -1225,7 +1258,7 @@
 {
   /* int ix = parser->attrib->pointer; */
   int ix = AXIS2_STACK_SIZE (parser->attrib, environment);
-  guththila_attribute_t *attribute;
+  guththila_attribute_t *attribute = NULL;
   if (i > ix)
     guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_ERROR_REQUESTED_NUMBER_GREATER_THAN_STACK_SIZE);
   else
@@ -1244,7 +1277,7 @@
 {
   /*   int ix = parser->attrib->pointer; */
   int ix = AXIS2_STACK_SIZE (parser->attrib, environment);
-  guththila_attribute_t *attribute;
+  guththila_attribute_t *attribute = NULL;
   if (i > ix)
     guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_ERROR_REQUESTED_NUMBER_GREATER_THAN_STACK_SIZE);
   else
@@ -1354,7 +1387,7 @@
 {
   /*   int ix = parser->namesp->pointer; */
   int ix = AXIS2_STACK_SIZE (parser->namesp, environment);
-  guththila_namespace_t *ns;
+  guththila_namespace_t *ns = NULL;
   if (i > ix)
     guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_ERROR_REQUESTED_NUMBER_GREATER_THAN_STACK_SIZE);
   else

Modified: webservices/axis2/trunk/c/guththila/src/guththila_xml_writer.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_xml_writer.c?view=diff&rev=441454&r1=441453&r2=441454
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_xml_writer.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_xml_writer.c Fri Sep  8 02:33:42 2006
@@ -22,7 +22,7 @@
 AXIS2_EXTERN void AXIS2_CALL
 guththila_xml_pull_parser_create_xml_stream_writer (axis2_env_t *env, guththila_xml_pull_parser_t *p, char *file)
 {
-  if (p && file)
+  if (p || file)
     {
       p->xsw = (guththila_xml_writer_t *) AXIS2_MALLOC (env->allocator, sizeof (guththila_xml_writer_t));
       p->xsw->writer = guththila_writer_create_for_file (env, file);
@@ -44,17 +44,48 @@
 
 
 AXIS2_EXTERN void AXIS2_CALL
+guththila_xml_pull_parser_create_xml_stream_writer_for_memory (axis2_env_t *env, guththila_xml_pull_parser_t *p)
+{
+  if (p)
+    {
+      p->xsw = (guththila_xml_writer_t *) AXIS2_MALLOC (env->allocator, sizeof (guththila_xml_writer_t));
+      p->xsw->writer = guththila_writer_create_for_memory (env);
+      p->xsw->writer_buffer = guththila_buffer_create (env, 1024);
+      p->xsw->writer_buffer->buff[0] = 0;
+      p->xsw->element = axis2_stack_create (env);
+      p->xsw->attribute = axis2_stack_create (env);
+      p->xsw->namespace = axis2_stack_create (env);
+      p->xsw->depth = axis2_stack_create (env);
+      p->xsw->next = 0;
+      p->xsw->offset = 0;
+      p->xsw->last = 1024;	/* size of the buffer */
+      p->xsw->start_element_open = -1;
+      p->xsw->empty_element_open = -1;
+    }
+  else
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS);
+}
+
+AXIS2_EXTERN void AXIS2_CALL
 guththila_xml_pull_parser_xml_writer_free(axis2_env_t *env, guththila_xml_pull_parser_t *p)
 {
+
   int size;
   size = 0;
-  guththila_xml_pull_parser_check_xml_stream_writer (env, p);
 
+  guththila_xml_pull_parser_check_xml_stream_writer (env, p);
+/*   guththila_xml_pull_parser_flush (env, p); */
+    guththila_xml_pull_parser_write_end_document (env, p);
+  if (p->xsw->writer_buffer)
+    {
+      guththila_buffer_free (env, p->xsw->writer_buffer);
+      p->xsw->writer_buffer = NULL;
+    }
 
   if (p->xsw->element)
     {
-        void *element;
-        size = 0;
+      void *element;
+      size = 0;
       
       size = AXIS2_STACK_SIZE (p->xsw->element, env);
       if (size)
@@ -103,8 +134,8 @@
 	      AXIS2_FREE (env->allocator, ns);
 	      ns = NULL;
 	    }
-      AXIS2_STACK_FREE (p->xsw->namespace, env);
-      p->xsw->namespace = NULL;
+	  AXIS2_STACK_FREE (p->xsw->namespace, env);
+	  p->xsw->namespace = NULL;
 	}
     }
 
@@ -122,8 +153,8 @@
 	      AXIS2_FREE (env->allocator, depth);
 	      depth = NULL;
 	    }
-      AXIS2_STACK_FREE (p->xsw->depth, env);
-      p->xsw->depth = NULL;
+	  AXIS2_STACK_FREE (p->xsw->depth, env);
+	  p->xsw->depth = NULL;
 	}
     }
 
@@ -133,11 +164,7 @@
       p->xsw->writer = NULL;
     }
 
-  if (p->xsw->writer_buffer)
-    {
-      guththila_buffer_free (env, p->xsw->writer_buffer);
-      p->xsw->writer_buffer = NULL;
-    }
+ 
   if (p->xsw)
     {
       AXIS2_FREE (env->allocator, p->xsw);
@@ -159,37 +186,37 @@
 
 AXIS2_EXTERN void AXIS2_CALL
 guththila_xml_pull_parser_write_start_document(axis2_env_t *env, 
-    guththila_xml_pull_parser_t *p)
+					       guththila_xml_pull_parser_t *p)
 {
-    char *sd =  NULL;    
-    guththila_xml_pull_parser_check_xml_stream_writer (env, p); 
-    sd  = "<?xml version = \"1.0\" encoding = \"utf-8\" ?>";
-    guththila_xml_pull_parser_write_to_buffer (env, p, sd);
+  char *sd =  NULL;    
+  guththila_xml_pull_parser_check_xml_stream_writer (env, p); 
+  sd  = "<?xml version = \"1.0\" encoding = \"utf-8\" ?>";
+  guththila_xml_pull_parser_write_to_buffer (env, p, sd);
 }
 
 
 AXIS2_EXTERN void AXIS2_CALL
 guththila_xml_pull_parser_write_end_element (axis2_env_t *env, guththila_xml_pull_parser_t *p)
 {
-     void *element = NULL;
-    guththila_xml_pull_parser_check_xml_stream_writer (env, p);
-    element = AXIS2_STACK_POP (p->xsw->element, env);
-    if(p->xsw->empty_element_open)
+  void *element = NULL;
+  guththila_xml_pull_parser_check_xml_stream_writer (env, p);
+  element = AXIS2_STACK_POP (p->xsw->element, env);
+  if(p->xsw->empty_element_open)
     {
-        guththila_xml_pull_parser_close_start_element (env, p);
+      guththila_xml_pull_parser_close_start_element (env, p);
     }
-    else
+  else
     {
-        guththila_xml_pull_parser_close_start_element (env, p);
-        if (element)
-	    {
-	        guththila_xml_pull_parser_write_to_buffer (env, p, "</");
-	        guththila_xml_pull_parser_write_to_buffer (env, p, element);
-	        guththila_xml_pull_parser_write_to_buffer (env, p, ">");
-	        guththila_xml_pull_parser_close_depth_element (env, p);
-	    }
-        else
-	        guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS);
+     guththila_xml_pull_parser_close_start_element (env, p);
+      if (element)
+	{
+	  guththila_xml_pull_parser_write_to_buffer (env, p, "</");
+	  guththila_xml_pull_parser_write_to_buffer (env, p, element);
+	  guththila_xml_pull_parser_write_to_buffer (env, p, ">");
+	  guththila_xml_pull_parser_close_depth_element (env, p);
+	}
+      else
+	guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS);
     }
 }
 
@@ -197,10 +224,10 @@
 AXIS2_EXTERN void AXIS2_CALL
 guththila_xml_pull_parser_flush (axis2_env_t *env, guththila_xml_pull_parser_t *p)
 {
-    int c;
-    int ii = 0;
-    guththila_xml_pull_parser_check_xml_stream_writer (env, p);
-    if(p->xsw->writer_buffer->buff)
+  int c;
+  int ii = 0;
+  guththila_xml_pull_parser_check_xml_stream_writer (env, p);
+  if(p->xsw->writer_buffer->buff)
     {
       ii = strlen (p->xsw->writer_buffer->buff);
       c = guththila_writer_write (env, p->xsw->writer_buffer->buff, 0, ii, p->xsw->writer);
@@ -223,13 +250,16 @@
     {
       guththila_xml_pull_parser_check_xml_stream_writer (env, p);
       guththila_xml_pull_parser_close_start_element (env, p);
+      guththila_xml_pull_parser_open_depth_element (env, p);
       size = AXIS2_STACK_SIZE (p->xsw->element, env);
-      if (size)
+ 
+     if (size)
 	{
 	  element = AXIS2_STACK_GET_AT (p->xsw->element, env, 0);
 	  if (!strcmp ((char *)element, start_element))
 	    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS);
 	}
+
       guththila_xml_pull_parser_check_name_validity (env, p,start_element);
       p->xsw->start_element_open = 1;
 
@@ -247,22 +277,21 @@
   if (buff)
     {
       guththila_xml_pull_parser_check_xml_stream_writer (env, p);
-      if (p->xsw->next >= p->xsw->last)
+      int length = 0;
+      length = strlen (buff);
+
+      if ((p->xsw->next + length) >= p->xsw->last)
 	{
 	  guththila_xml_pull_parser_flush (env, p);
 	  p->xsw->next = 0;
 	  p->xsw->offset = 0;
 	}
-      else
+	 
+      if (p->xsw->writer_buffer->buff && p->xsw->next > -1)
 	{
-	  int length;
-	  length = strlen (buff);
-	  if (p->xsw->writer_buffer->buff && p->xsw->next > -1)
-	    {
-	      strcat ((p->xsw->writer_buffer->buff) + (p->xsw->next), buff);
-	      p->xsw->offset = p->xsw->next;
-	      p->xsw->next += length;
-	    }
+	  strcat ((p->xsw->writer_buffer->buff) + (p->xsw->next), buff);
+	  p->xsw->offset = p->xsw->next;
+	  p->xsw->next += length;
 	}
     }
 }
@@ -286,6 +315,7 @@
 void AXIS2_CALL
 guththila_xml_pull_parser_close_start_element (axis2_env_t *env, guththila_xml_pull_parser_t *p)
 {
+  int stack_size = 0;
   if (p->xsw->start_element_open != -1 && p->xsw->empty_element_open != -1)
     {
       if (p->xsw->start_element_open && p->xsw->empty_element_open)
@@ -302,6 +332,19 @@
 	  guththila_xml_pull_parser_write_to_buffer (env, p,">");
 	  /*       Stack_clear (p->xsw->attribute); */
 	}
+      
+      stack_size = AXIS2_STACK_SIZE (p->xsw->attribute, env);
+      if (stack_size)
+	{
+	  guththila_attribute_t* att = NULL;
+	  for (;stack_size > 0; stack_size--)
+	    {
+	      att = (guththila_attribute_t *)AXIS2_STACK_POP (p->xsw->attribute, env);
+	      AXIS2_FREE (env->allocator, att);
+	      att = NULL;
+	    }
+	}
+
     }
   else
     {
@@ -309,7 +352,7 @@
       p->xsw->empty_element_open = 0;
     }
 
-  guththila_xml_pull_parser_open_depth_element (env, p);
+/*   guththila_xml_pull_parser_open_depth_element (env, p); */
 }
 
 
@@ -369,54 +412,54 @@
 AXIS2_EXTERN void AXIS2_CALL
 guththila_xml_pull_parser_write_comment (axis2_env_t *env, guththila_xml_pull_parser_t *p, const char *buff)
 {
-    char *s = NULL;
-    guththila_xml_pull_parser_check_xml_stream_writer (env, p);
-    guththila_xml_pull_parser_close_start_element (env, p);
-    s   = strchr (buff, '-');
-    if(s && s[1] == '-')
-        guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EXCESS_HYPENS_IN_COMMENT);
-    guththila_xml_pull_parser_write_to_buffer (env, p,"<!--");
-    guththila_xml_pull_parser_write_to_buffer (env, p,buff);
-    guththila_xml_pull_parser_write_to_buffer (env, p,"-->");
+  char *s = NULL;
+  guththila_xml_pull_parser_check_xml_stream_writer (env, p);
+  guththila_xml_pull_parser_close_start_element (env, p);
+  s   = strchr (buff, '-');
+  if(s && s[1] == '-')
+    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EXCESS_HYPENS_IN_COMMENT);
+  guththila_xml_pull_parser_write_to_buffer (env, p,"<!--");
+  guththila_xml_pull_parser_write_to_buffer (env, p,buff);
+  guththila_xml_pull_parser_write_to_buffer (env, p,"-->");
 }
 
 
 AXIS2_EXTERN void AXIS2_CALL
 guththila_xml_pull_parser_write_escape_character (axis2_env_t *env, guththila_xml_pull_parser_t *p, const char *buff)
 {
-    guththila_xml_pull_parser_close_start_element (env, p);
-    if(buff)
+  guththila_xml_pull_parser_close_start_element (env, p);
+  if(buff)
     {
-        switch (buff[0])
-	    {
-	        case '>':
-	        {
-	        guththila_xml_pull_parser_write_to_buffer (env, p,"&gt;");
-	        }
-	            break;
-    	    case '<':
-	        {
-    	        guththila_xml_pull_parser_write_to_buffer (env, p,"&lt;");
-	        }
-	            break;
-	        case '\'':
-	        {
-	            guththila_xml_pull_parser_write_to_buffer (env, p,"&apos;");
-	        }
-	            break;
-	        case '"':
-	        {
-	            guththila_xml_pull_parser_write_to_buffer (env, p,"&quot;");
-	        }
-	            break;
-	        case '&':
-	        {
-	            guththila_xml_pull_parser_write_to_buffer (env, p,"&amp;");
-	        }
-	            break;
-	    };
+      switch (buff[0])
+	{
+	case '>':
+	  {
+	    guththila_xml_pull_parser_write_to_buffer (env, p,"&gt;");
+	  }
+	  break;
+	case '<':
+	  {
+	    guththila_xml_pull_parser_write_to_buffer (env, p,"&lt;");
+	  }
+	  break;
+	case '\'':
+	  {
+	    guththila_xml_pull_parser_write_to_buffer (env, p,"&apos;");
+	  }
+	  break;
+	case '"':
+	  {
+	    guththila_xml_pull_parser_write_to_buffer (env, p,"&quot;");
+	  }
+	  break;
+	case '&':
+	  {
+	    guththila_xml_pull_parser_write_to_buffer (env, p,"&amp;");
+	  }
+	  break;
+	};
     }
-    else
+  else
     guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_INVALID_BUFFER);
 }
 
@@ -441,15 +484,15 @@
 	  if (element)
 	    {
 	      attr = (guththila_attribute_t *)element;
-	      if (!strcmp((char *)attr->name, local_name))
-		guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS);
-	      else
+	      if (strcmp((char *)attr->name, local_name))
 		{
 		  guththila_xml_pull_parser_do_write_attribute (env, p,local_name, value);
 		  break;
 		}
-	    }
-	}
+	      else
+		guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_SAME_ATTRIBUTE_REPEAT);
+	    }	}
+
 	    
     }
   else
@@ -461,9 +504,9 @@
 
 AXIS2_EXTERN void AXIS2_CALL
 guththila_xml_pull_parser_do_write_attribute (axis2_env_t *env, 
-    guththila_xml_pull_parser_t *p, 
-    const char *local_name, 
-    const char *value)
+					      guththila_xml_pull_parser_t *p, 
+					      const char *local_name, 
+					      const char *value)
 {
   guththila_attribute_t *attr = (guththila_attribute_t *) AXIS2_MALLOC (env->allocator, sizeof (guththila_attribute_t));
   
@@ -480,14 +523,14 @@
   
   if (strrchr (value, '&') 
       || strrchr (value, '<') 
-      || strrchr (value, '\''))
+      || strrchr (value, '\"'))
     guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_INVALID_CHAR_IN_ATTRIBUTE);
 
   guththila_xml_pull_parser_write_to_buffer (env, p," ");
   guththila_xml_pull_parser_write_to_buffer (env, p,local_name);
-  guththila_xml_pull_parser_write_to_buffer (env, p," = \'");
+  guththila_xml_pull_parser_write_to_buffer (env, p," = \"");
   guththila_xml_pull_parser_write_to_buffer (env, p,value);
-  guththila_xml_pull_parser_write_to_buffer (env, p,"\'");
+  guththila_xml_pull_parser_write_to_buffer (env, p,"\"");
 }
 
 
@@ -570,16 +613,17 @@
 AXIS2_EXTERN void AXIS2_CALL
 guththila_xml_pull_parser_write_namespace (axis2_env_t *env, guththila_xml_pull_parser_t *p, char *prefix, char *uri)
 {
-  if (!prefix || !strcmp(prefix, "xmlns"))
-    guththila_xml_pull_parser_do_write_default_namespace (env, p,uri);
-  
   if (!p->xsw->start_element_open)
     guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS);
+
+  if (!prefix || !strcmp(prefix, ""))
+    guththila_xml_pull_parser_do_write_default_namespace (env, p,uri);
   else
     {
       if (guththila_xml_pull_parser_check_prefix_validity (env, p,prefix, uri))
 	guththila_xml_pull_parser_do_write_namespace (env, p,prefix, uri);
     }
+  
 
 }
 
@@ -587,10 +631,10 @@
 AXIS2_EXTERN int AXIS2_CALL
 guththila_xml_pull_parser_check_prefix_validity (axis2_env_t *env, guththila_xml_pull_parser_t *p, char *prefix, char *uri)
 {
-  int size;
-  int ii;
-  void *element;
-  guththila_namespace_t *ns;
+  int size = 0;
+  int ii = 0;
+  void *element = NULL;
+  guththila_namespace_t *ns = NULL;
   size = AXIS2_STACK_SIZE (p->xsw->namespace, env);
   if (size)
     {
@@ -600,17 +644,18 @@
 	  if (element)
 	    {
 	      ns = (guththila_namespace_t *)element;
-	      if (ns->name)
+	      if (ns->name && prefix)
 		{
 		  if (!strcmp (ns->name, prefix))
-		    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS);
-		}
-	      if (uri)
-		{
-		  if (ns->uri)
 		    {
-		      if (!strcmp (ns->uri, uri))
-			guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS);
+		      if (ns->uri && uri)
+			{
+			  if (strcmp (ns->uri, uri))
+			    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS);
+			  else
+			    return 0;
+			}
+
 		    }
 		}
 	    }
@@ -625,26 +670,26 @@
 void AXIS2_CALL
 guththila_xml_pull_parser_do_write_namespace (axis2_env_t *env, guththila_xml_pull_parser_t *p, char *prefix, char *uri)
 {
-  guththila_namespace_t *ns = (guththila_namespace_t *) AXIS2_MALLOC (env->allocator, sizeof (guththila_namespace_t));
-  ns->name = prefix;
-  ns->length = strlen (prefix);
-  ns->uri = uri;
-  ns->lengthuri = strlen (uri);
-  AXIS2_STACK_PUSH (p->xsw->namespace, env, (  void *)ns);
+guththila_namespace_t *ns = (guththila_namespace_t *) AXIS2_MALLOC (env->allocator, sizeof (guththila_namespace_t));
+ns->name = prefix;
+ns->length = strlen (prefix);
+ns->uri = uri;
+ns->lengthuri = strlen (uri);
+AXIS2_STACK_PUSH (p->xsw->namespace, env, (  void *)ns);
   
-  guththila_xml_pull_parser_write_to_buffer (env, p," ");
-  guththila_xml_pull_parser_write_to_buffer (env, p,"xmlns:");
-  guththila_xml_pull_parser_write_to_buffer (env, p,prefix);
-  guththila_xml_pull_parser_write_to_buffer (env, p," = \'");
-  guththila_xml_pull_parser_write_to_buffer (env, p,uri);
-  guththila_xml_pull_parser_write_to_buffer (env, p,"\'");
+guththila_xml_pull_parser_write_to_buffer (env, p," ");
+guththila_xml_pull_parser_write_to_buffer (env, p,"xmlns:");
+guththila_xml_pull_parser_write_to_buffer (env, p,prefix);
+guththila_xml_pull_parser_write_to_buffer (env, p," = \'");
+guththila_xml_pull_parser_write_to_buffer (env, p,uri);
+guththila_xml_pull_parser_write_to_buffer (env, p,"\'");
 }
 
 
 AXIS2_EXTERN void AXIS2_CALL
 guththila_xml_pull_parser_write_attribute_with_prefix_and_namespace (axis2_env_t *env, guththila_xml_pull_parser_t *p,
-								     const char *prefix, const char *namespace,
-								     const char *local_name, const char *value)
+  const char *prefix, const char *namespace,
+  const char *local_name, const char *value)
 {
   int size = 0;
   void *element;
@@ -958,26 +1003,36 @@
 {
   int size;
   void *element;
-  char *start_element = (char *) calloc ((strlen (prefix) + strlen (local_name) +2), 1);
+  char *start_element = NULL;
+  if (prefix && local_name)
+    start_element = (char *) calloc ((strlen (prefix) + strlen (local_name) +2), 1);
+
   if (!p || !local_name)
     guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS);
   else
     {
       guththila_xml_pull_parser_check_xml_stream_writer (env, p);
       guththila_xml_pull_parser_close_start_element (env, p);
+      guththila_xml_pull_parser_open_depth_element (env, p);
      
       if (prefix)
 	{
 	  strcat (start_element, prefix);
 	  strcat (start_element, ":");
 	  strcat (start_element, local_name);
-	} 
+	}
+      else 
+	start_element = (char *)local_name; 
+
       size = AXIS2_STACK_SIZE (p->xsw->element, env);
       if (size)
 	{
 	  element = AXIS2_STACK_GET_AT (p->xsw->element, env, size);
-	  if (!strcmp ((char *)element, start_element))
-	    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS);
+	  if (start_element && element)
+	    {
+	      if (!strcmp ((char *)element, start_element))
+		guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS);
+	    }
 	}
 
       guththila_xml_pull_parser_check_name_validity (env, p,start_element);
@@ -1004,38 +1059,41 @@
 	guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_EMPTY_ARGUMENTS);
       else
 	{
-	    char *prefix = NULL;
-	    guththila_xml_pull_parser_check_xml_stream_writer (env, p);
-	    guththila_xml_pull_parser_close_start_element (env, p);
-	    prefix = guththila_xml_pull_parser_get_prefix_for_namespace (env, p,namespace_uri);
-	    if(prefix)
-	        start_element = (char *) calloc ((strlen (prefix) + strlen (local_name) +2), 1);
-	    else
-	        start_element = (char *) calloc ((strlen (local_name) +2), 1);
+	  char *prefix = NULL;
+	  guththila_xml_pull_parser_check_xml_stream_writer (env, p);
+	  guththila_xml_pull_parser_close_start_element (env, p);
+	  prefix = guththila_xml_pull_parser_get_prefix_for_namespace (env, p,namespace_uri);
+
+	  if(prefix)
+	    start_element = (char *) calloc ((strlen (prefix) + strlen (local_name) +2), 1);
+	  else
+	    start_element = (char *) calloc ((strlen (local_name) +2), 1);
      
-	    if(prefix)
+	  if(prefix)
 	    {
-	        strcat (start_element, prefix);
-	        strcat (start_element, ":");
-	        strcat (start_element, local_name);
+	      strcat (start_element, prefix);
+	      strcat (start_element, ":");
+	      strcat (start_element, local_name);
 	    } 
-	    else
-	        strcat (start_element, local_name);
-	    size = AXIS2_STACK_SIZE (p->xsw->element, env);
-	    if(size)
+	  else
+	    strcat (start_element, local_name);
+
+	  size = AXIS2_STACK_SIZE (p->xsw->element, env);
+
+	  if(size)
 	    {
-	        element = AXIS2_STACK_GET_AT (p->xsw->element, env, size);
-	        if (!strcmp ((char *)element, start_element))
-		    guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS);
+	      element = AXIS2_STACK_GET_AT (p->xsw->element, env, size);
+	      if (!strcmp ((char *)element, start_element))
+		guththila_xml_pull_parser_exception (p_FILE, LINE, GUTHTHILA_WRITER_ERROR_NON_MATCHING_ELEMENTS);
 	    }
 
-	    guththila_xml_pull_parser_check_name_validity (env, p,start_element);
-	    p->xsw->start_element_open = 1;
+	  guththila_xml_pull_parser_check_name_validity (env, p,start_element);
+	  p->xsw->start_element_open = 1;
       
-	    if (!p->xsw->empty_element_open)
-	        AXIS2_STACK_PUSH (p->xsw->element, env, start_element);
-	    guththila_xml_pull_parser_write_to_buffer (env, p,"<");
-	    guththila_xml_pull_parser_write_to_buffer  (env, p,start_element);
+	  if (!p->xsw->empty_element_open)
+	    AXIS2_STACK_PUSH (p->xsw->element, env, start_element);
+	  guththila_xml_pull_parser_write_to_buffer (env, p,"<");
+	  guththila_xml_pull_parser_write_to_buffer  (env, p,start_element);
 	}
     }
   else
@@ -1057,7 +1115,8 @@
 	{
 	  guththila_xml_pull_parser_check_xml_stream_writer (env, p);
 	  guththila_xml_pull_parser_close_start_element (env, p);
-	  
+	  guththila_xml_pull_parser_open_depth_element (env, p);
+
 	  if (prefix)
 	    {
 	      start_element = (char *) AXIS2_MALLOC (env->allocator, (strlen (prefix) + strlen (local_name) +2));
@@ -1132,23 +1191,23 @@
   int size = AXIS2_STACK_SIZE (p->xsw->depth, env);
   guththila_depth_t *d = (guththila_depth_t *) AXIS2_MALLOC (env->allocator, sizeof (guththila_depth_t)); 
 
-    if(size)
+  if(size)
     {
-        void *e = NULL;
-        guththila_depth_t *l = NULL;
-        e = AXIS2_STACK_GET (p->xsw->depth, env);
-        l = (guththila_depth_t *)e;
-        d->total = AXIS2_STACK_SIZE (p->xsw->namespace, env);
-        d->first = l->first + l->count;
-        d->count = d->total - l->total;
-        AXIS2_STACK_PUSH (p->xsw->depth, env, (void *)d);
-    }
-    else
-    {
-        d->first = 0;
-        d->total = AXIS2_STACK_SIZE (p->xsw->namespace, env);
-        d->count = d->total;
-        AXIS2_STACK_PUSH (p->xsw->depth, env, (void *)d);
+      void *e = NULL;
+      guththila_depth_t *l = NULL;
+      e = AXIS2_STACK_GET (p->xsw->depth, env);
+      l = (guththila_depth_t *)e;
+      d->total = AXIS2_STACK_SIZE (p->xsw->namespace, env);
+      d->first = l->first + l->count;
+      d->count = d->total - l->total;
+      AXIS2_STACK_PUSH (p->xsw->depth, env, (void *)d);
+    }
+  else
+    {
+      d->first = 0;
+      d->total = AXIS2_STACK_SIZE (p->xsw->namespace, env);
+      d->count = d->total;
+      AXIS2_STACK_PUSH (p->xsw->depth, env, (void *)d);
     }
 }
 
@@ -1174,22 +1233,22 @@
 AXIS2_EXTERN void AXIS2_CALL
 guththila_xml_pull_parser_write_end_document (axis2_env_t *env, guththila_xml_pull_parser_t *p)
 {
-    int ii = 0;
-    if (p->xsw->start_element_open || p->xsw->empty_element_open)
-        guththila_xml_pull_parser_close_start_element (env, p);
-    ii = AXIS2_STACK_SIZE (p->xsw->element, env);
-    for (; ii > 0; ii --)
-        guththila_xml_pull_parser_write_end_element (env, p);
-    guththila_xml_pull_parser_flush (env, p);
+  int ii = 0;
+  if (p->xsw->start_element_open || p->xsw->empty_element_open)
+    guththila_xml_pull_parser_close_start_element (env, p);
+  ii = AXIS2_STACK_SIZE (p->xsw->element, env);
+  for (; ii > 0; ii --)
+    guththila_xml_pull_parser_write_end_element (env, p);
+  guththila_xml_pull_parser_flush (env, p);
 }
 
 
 AXIS2_EXTERN void AXIS2_CALL 
 guththila_xml_pull_parser_close (axis2_env_t *env, 
-    guththila_xml_pull_parser_t *p)
+				 guththila_xml_pull_parser_t *p)
 {
-    guththila_xml_pull_parser_flush (env, p);
-    fclose (((guththila_writer_impl_t *)p->xsw->writer)->outputstream);
+  guththila_xml_pull_parser_flush (env, p);
+  fclose (((guththila_writer_impl_t *)p->xsw->writer)->outputstream);
 }
 
 
@@ -1200,4 +1259,15 @@
   guththila_xml_pull_parser_write_characters (env, p,characters);
   guththila_xml_pull_parser_write_end_element (env, p);
   guththila_xml_pull_parser_write_characters (env, p,"\n");
+}
+
+AXIS2_EXTERN char* AXIS2_CALL
+guththila_xml_pull_parser_get_memory_buffer (axis2_env_t *env, guththila_xml_pull_parser_t *p)
+{
+  char *buffer = NULL;
+  guththila_xml_pull_parser_flush (env, p);
+  if (p->xsw)
+    buffer = guththila_writer_get_buffer (env, p->xsw->writer);
+
+  return buffer;
 }



---------------------------------------------------------------------
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