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 di...@apache.org on 2006/09/19 11:20:01 UTC

svn commit: r447788 [1/2] - in /webservices/axis2/trunk/c/guththila/src: guththila_buffer.c guththila_reader.c guththila_token.c guththila_unicode.c guththila_writer.c guththila_writer_main.c guththila_xml_pull_parser.c guththila_xml_writer.c

Author: dinesh
Date: Tue Sep 19 02:20:00 2006
New Revision: 447788

URL: http://svn.apache.org/viewvc?view=rev&rev=447788
Log:
modified to work with both linux and windows

Modified:
    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_token.c
    webservices/axis2/trunk/c/guththila/src/guththila_unicode.c
    webservices/axis2/trunk/c/guththila/src/guththila_writer.c
    webservices/axis2/trunk/c/guththila/src/guththila_writer_main.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/src/guththila_buffer.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_buffer.c?view=diff&rev=447788&r1=447787&r2=447788
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_buffer.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_buffer.c Tue Sep 19 02:20:00 2006
@@ -13,7 +13,7 @@
  *   See the License for the specific language governing permissions and
  *   limitations under the License.
  *
- *
+ *   
  */
 
 
@@ -22,75 +22,75 @@
 #include "guththila_buffer.h"
 #include <axis2_env.h>
 
-AXIS2_EXTERN guththila_buffer_t *
-guththila_buffer_create(axis2_env_t * environment, int size)
+AXIS2_EXTERN guththila_buffer_t * AXIS2_CALL
+guththila_buffer_create (axis2_env_t * environment, int size)
 {
     guththila_buffer_t *name;
     name = NULL;
-    name  = AXIS2_MALLOC(environment->allocator,
-            sizeof(guththila_buffer_t));
+    name  = AXIS2_MALLOC (environment->allocator,
+                                            sizeof (guththila_buffer_t));
     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;
+      {
+	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_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));
+    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;
-    }
+      {
+	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,
-        guththila_buffer_t * name)
+guththila_buffer_free (axis2_env_t * environment,
+                       guththila_buffer_t * name)
 {
     if (name)
     {
         if (name->buff && !name->is_memory)
         {
-            AXIS2_FREE(environment->allocator, name->buff);
-            name->buff = NULL;
+            AXIS2_FREE (environment->allocator, name->buff);
+	    name->buff = NULL;
         }
-        AXIS2_FREE(environment->allocator, name);
-        name = NULL;
+        AXIS2_FREE (environment->allocator, name);
+	name = NULL;
     }
 }
 
 
 AXIS2_EXTERN guththila_buffer_t *
-guththila_buffer_grow(axis2_env_t * environment,
-        guththila_buffer_t * name)
+guththila_buffer_grow (axis2_env_t * environment,
+                       guththila_buffer_t * name)
 {
 
     guththila_char_t *x = NULL;
     name->size <<= 1;
-    x = (guththila_char_t *) AXIS2_REALLOC(environment->allocator,
-            name->buff, name->size);
+    x = (guththila_char_t *) AXIS2_REALLOC (environment->allocator,
+                                                  name->buff,name->size);
     if (x)
         name->buff = x;
     else

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=447788&r1=447787&r2=447788
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_reader.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_reader.c Tue Sep 19 02:20:00 2006
@@ -1,139 +1,139 @@
-/*
- *   Copyright 2004,2005 The Apache Software Foundation.
- *
- *   Licensed under the Apache License, Version 2.0 (the "License");
- *   you may not use this file except in compliance with the License.
- *   You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *   Unless required by applicable law or agreed to in writing, software
- *   distributed under the License is distributed on an "AS IS" BASIS,
- *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *   See the License for the specific language governing permissions and
- *   limitations under the License.
- *
- *
- */
-
-
-#include "guththila_reader.h"
-#include "guththila_defines.h"
-
-
-
-
-
-AXIS2_EXTERN guththila_reader_t *
-guththila_reader_create_for_file(axis2_env_t * environment,
-        char *filename)
-{
-    guththila_reader_impl_t *file_reader = NULL;
-    if (!filename)
-        return NULL;
-
-    file_reader = (guththila_reader_impl_t *) AXIS2_MALLOC(environment->allocator,
-            sizeof(guththila_reader_impl_t));
-    if (!file_reader)
-        return NULL;
-
-    file_reader->fp  = fopen(filename, "r");
-
-    if (!(file_reader->fp))
-    {
-        AXIS2_FREE(environment->allocator, file_reader);
-        return NULL;
-    }
-
-    file_reader->reader.guththila_reader_type = GUTHTHILA_FILE_READER;
-
-    return &(file_reader->reader);
-}
-
-
-AXIS2_EXTERN guththila_reader_t *
-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));
-    if (!memory_reader)
-    {
-        return NULL;
-    }
-
-    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_MEMORY_READER;
-
-    return &(memory_reader->reader);
-}
-
-AXIS2_EXTERN void
-guththila_reader_free(axis2_env_t * environment,
-        guththila_reader_t * r)
-{
-
-    if (!r)
-        return;
-
-    if (r->guththila_reader_type == GUTHTHILA_FILE_READER)
-    {
-        if (((guththila_reader_impl_t*)r)->fp)
-            fclose(((guththila_reader_impl_t*)r)->fp);
-    }
-    AXIS2_FREE(environment->allocator, (guththila_reader_impl_t*)r);
-    return;
-}
-
-
-AXIS2_EXTERN int
-guththila_reader_read(axis2_env_t * environment,
-        guththila_char_t * buffer,
-        int offset,
-        int length,
-        guththila_reader_t * r)
-{
-
-    if (r->guththila_reader_type == GUTHTHILA_FILE_READER)
-    {
-        return (int)fread(buffer + offset, 1, length, ((guththila_reader_impl_t*)r)->fp);
-    }
-    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;
-}
+/*
+ *   Copyright 2004,2005 The Apache Software Foundation.
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ *   
+ */
+
+
+#include "guththila_reader.h"
+#include "guththila_defines.h"
+
+
+
+
+
+AXIS2_EXTERN guththila_reader_t * AXIS2_CALL
+guththila_reader_create_for_file (axis2_env_t * environment,
+                                  char *filename)
+{
+    guththila_reader_impl_t *file_reader = NULL;
+    if(!filename)
+        return NULL;
+    
+       file_reader = (guththila_reader_impl_t *) AXIS2_MALLOC ( environment->allocator,
+                                                 sizeof (guththila_reader_impl_t));
+    if(!file_reader)
+        return NULL;
+    
+    file_reader->fp  = fopen(filename,"r");
+    
+    if(!(file_reader->fp ))
+    {
+        AXIS2_FREE(environment->allocator,file_reader);
+        return NULL;
+    }                                                            
+    
+    file_reader->reader.guththila_reader_type = GUTHTHILA_FILE_READER;
+    
+    return &(file_reader->reader);
+}
+
+
+AXIS2_EXTERN guththila_reader_t * AXIS2_CALL
+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 * AXIS2_CALL
+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));
+    if(!memory_reader)
+    {
+        return NULL;
+    }
+    
+    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_MEMORY_READER;
+    
+    return &(memory_reader->reader);
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+guththila_reader_free (axis2_env_t * environment,
+                       guththila_reader_t * r)
+{
+
+    if (!r)
+        return;
+    
+    if(r->guththila_reader_type == GUTHTHILA_FILE_READER)
+    {   
+        if(((guththila_reader_impl_t*)r)->fp)
+            fclose(((guththila_reader_impl_t*)r)->fp);
+    }
+    AXIS2_FREE(environment->allocator, (guththila_reader_impl_t*)r); 
+   return;    
+}
+
+        
+AXIS2_EXTERN int AXIS2_CALL
+guththila_reader_read (axis2_env_t * environment,
+                       guththila_char_t * buffer,
+                       int offset,
+                       int length,
+                       guththila_reader_t * r)
+{
+    
+    if(r->guththila_reader_type == GUTHTHILA_FILE_READER)
+    {
+       return (int)fread (buffer + offset, 1, length,((guththila_reader_impl_t*)r)->fp);
+    }
+    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_token.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_token.c?view=diff&rev=447788&r1=447787&r2=447788
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_token.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_token.c Tue Sep 19 02:20:00 2006
@@ -13,7 +13,7 @@
  *   See the License for the specific language governing permissions and
  *   limitations under the License.
  *
- *
+ *   
  */
 
 
@@ -24,30 +24,30 @@
 
 
 AXIS2_EXTERN guththila_token_t *
-guththila_token_create_token_buffer(axis2_env_t *environment,
-        int size)
+guththila_token_create_token_buffer (axis2_env_t *environment,
+                                     int size)
 {
     guththila_token_t *tok =
-        (guththila_token_t *) AXIS2_MALLOC(environment->allocator,
-                sizeof(guththila_token_t) * size);
+        (guththila_token_t *) AXIS2_MALLOC (environment->allocator,
+                                          sizeof (guththila_token_t) * size);
     tok->size = size;
     return tok;
 }
 
 
 AXIS2_EXTERN void
-guththila_token_free_token_buffer(axis2_env_t * environment,
-        guththila_token_t * tok)
+guththila_token_free_token_buffer (axis2_env_t * environment,
+                                   guththila_token_t * tok)
 {
     if (tok)
-        AXIS2_FREE(environment->allocator, tok);
+        AXIS2_FREE (environment->allocator, tok);
 }
 
 
 AXIS2_EXTERN void
-guththila_token_exception()
+guththila_token_exception ()
 {
-    printf("Throws new token Exception");
+    printf ("Throws new token Exception");
     /* Samisa : we should define the error code and error desctioption and return error code to user
        no use of using printf within a library
        please delete this comment once this is fixed.
@@ -56,111 +56,111 @@
 
 
 AXIS2_EXTERN int
-guththila_token_length(axis2_env_t * environment,
-        guththila_token_t * tok)
+guththila_token_length (axis2_env_t * environment,
+                        guththila_token_t * tok)
 {
     if (tok->end)
         return (tok->end) - (tok->start) + 1;
     else
-        guththila_token_exception();
+        guththila_token_exception ();
     return 0;
 }
 
 
 AXIS2_EXTERN guththila_token_t *
-guththila_token_grow(axis2_env_t * environment,
-        guththila_token_t * tok)
+guththila_token_grow (axis2_env_t * environment,
+                      guththila_token_t * tok)
 {
     tok->size <<= 1;
-    tok = (guththila_token_t *) AXIS2_REALLOC(environment->allocator,
-            tok, sizeof(guththila_token_t) * tok->size);
+    tok = (guththila_token_t *) AXIS2_REALLOC (environment->allocator,
+                                 tok, sizeof (guththila_token_t) * tok->size);
 
     return tok;
 }
 
 
 AXIS2_EXTERN guththila_token_t *
-guththila_token_append(axis2_env_t * environment,
-        guththila_token_t * tok)
+guththila_token_append (axis2_env_t * environment,
+                        guththila_token_t * tok)
 {
     if (++(tok->last) > (tok->size))
-        guththila_token_grow(environment, tok);
+        guththila_token_grow (environment, tok);
     return &tok[tok->last];
 }
 
 
 AXIS2_EXTERN guththila_token_t *
-guththila_token_last(axis2_env_t * environment,
-        guththila_token_t * tok)
+guththila_token_last (axis2_env_t * environment,
+                      guththila_token_t * tok)
 {
     if (tok->last < 0)
-        guththila_token_exception();
+        guththila_token_exception ();
     return &tok[tok->last];
 }
 
 
 AXIS2_EXTERN int
-guththila_token_count(axis2_env_t * environment,
-        guththila_token_t * tok)
+guththila_token_count (axis2_env_t * environment,
+                       guththila_token_t * tok)
 {
     return tok->last;
 }
 
 AXIS2_EXTERN guththila_char_t *
-guththila_token_char_ref(axis2_env_t * environment,
-        guththila_char_t * buffer)
+guththila_token_char_ref (axis2_env_t * environment,
+                          guththila_char_t * buffer)
 {
     int len;
     int ii;
     int ix;
     guththila_char_t *ref_buffer = NULL;
-
-    len = AXIS2_STRLEN(buffer);
-    ref_buffer = (guththila_char_t *) AXIS2_MALLOC(
-                environment->allocator, len + 1);
-
-
+    
+    len = AXIS2_STRLEN ( buffer);
+    ref_buffer =  (guththila_char_t *) AXIS2_MALLOC (
+                            environment->allocator, len + 1);
+                            
+                            
     for (ii = 0, ix = 0; ii < len; ii++, ix++)
     {
         if (buffer[ii] == '&')
         {
             if (buffer[ii + 1] == 'a'
-                    && buffer[ii + 2] == 'm'
-                    && buffer[ii + 3] == 'p' && buffer[ii + 4] == ';')
+                && buffer[ii + 2] == 'm'
+                && buffer[ii + 3] == 'p' && buffer[ii + 4] == ';')
             {
                 ref_buffer[ix] = '&';
                 ii += 4;
             }
             else if (buffer[ii + 1] == 'g'
-                    && buffer[ii + 2] == 't' && buffer[ii + 3] == ';')
+                     && buffer[ii + 2] == 't' && buffer[ii + 3] == ';')
             {
                 ref_buffer[ix] = '>';
                 ii += 3;
             }
             else if (buffer[ii + 1] == 'l'
-                    && buffer[ii + 2] == 't' && buffer[ii + 3] == ';')
+                     && buffer[ii + 2] == 't' && buffer[ii + 3] == ';')
             {
                 ref_buffer[ix] = '<';
                 ii += 3;
             }
             else if (buffer[ii + 1] == 'q'
-                    && buffer[ii + 2] == 'u'
-                    && buffer[ii + 3] == 'o'
-                    && buffer[ii + 4] == 't' && buffer[ii + 5] == ';')
+                     && buffer[ii + 2] == 'u'
+                     && buffer[ii + 3] == 'o'
+                     && buffer[ii + 4] == 't' && buffer[ii + 5] == ';')
             {
                 ref_buffer[ix] = '"';
                 ii += 5;
             }
             else if (buffer[ii + 1] == 'a'
-                    && buffer[ii + 2] == 'p'
-                    && buffer[ii + 3] == 'o'
-                    && buffer[ii + 4] == 's' && buffer[ii + 5] == ';')
+                     && buffer[ii + 2] == 'p'
+                     && buffer[ii + 3] == 'o'
+                     && buffer[ii + 4] == 's' && buffer[ii + 5] == ';')
             {
                 ref_buffer[ix] = '\'';
                 ii += 5;
             }
             else
-                guththila_token_exception();
+                guththila_token_exception ();
         }
         else
             ref_buffer[ix] = buffer[ii];
@@ -170,8 +170,8 @@
 
 
 AXIS2_EXTERN guththila_char_t *
-guththila_token_to_string(axis2_env_t * environment,
-        guththila_token_t * tok, int unicode)
+guththila_token_to_string (axis2_env_t * environment,
+                           guththila_token_t * tok, int unicode)
 {
     if (tok)
     {
@@ -179,13 +179,13 @@
         {
             int length;
             guththila_char_t *buffer = NULL;
-            length = guththila_token_length(environment, tok);
-            buffer = (guththila_char_t *) AXIS2_MALLOC(environment->allocator,
-                    length + 1);
-            memcpy(buffer, tok->start, length);
+            length = guththila_token_length (environment, tok);
+            buffer = (guththila_char_t *) AXIS2_MALLOC (environment->allocator,
+                                                      length + 1);
+            memcpy (buffer, tok->start, length);
             buffer[length] = 0;
             if (tok->ref)
-                return guththila_token_char_ref(environment, buffer);
+                return guththila_token_char_ref (environment, buffer);
             else
                 return buffer;
         }
@@ -193,25 +193,25 @@
         {
             int length;
             guththila_char_t *buffer = NULL;
-            length = guththila_token_length(environment, tok);
-
-            buffer = (guththila_char_t *) AXIS2_MALLOC(
-                        environment->allocator, length + 1);
-
-            memcpy(buffer, tok->start, length);
+            length = guththila_token_length (environment, tok);
+            
+            buffer = (guththila_char_t *) AXIS2_MALLOC (
+                                environment->allocator, length + 1);
+                                
+            memcpy (buffer, tok->start, length);
             buffer[length] = 0;
-            return guththila_token_convert_utf16_to_utf8(environment, buffer,
-                    length);
+            return guththila_token_convert_utf16_to_utf8 (environment, buffer,
+                                                          length);
         }
     }
     else
-        return NULL;
+      return NULL;
 }
 
 
 AXIS2_EXTERN void
-guththila_token_relocate(axis2_env_t * environment,
-        guththila_token_t * tok, int offset)
+guththila_token_relocate (axis2_env_t * environment,
+                          guththila_token_t * tok, int offset)
 {
     tok->start -= offset;
     tok->end -= offset;
@@ -219,24 +219,24 @@
 
 
 AXIS2_EXTERN int
-guththila_token_compare(axis2_env_t * environment,
-        guththila_token_t * tok, const guththila_char_t * s,
-        int n, int unicode_state)
+guththila_token_compare (axis2_env_t * environment,
+                         guththila_token_t * tok, const guththila_char_t * s,
+                         int n, int unicode_state)
 {
     if (unicode_state == None)
-        return strncmp(tok->start, s, n);
+        return strncmp (tok->start, s, n);
     else
     {
         guththila_char_t *buffer = NULL;
-        buffer = guththila_token_to_string(environment, tok, unicode_state);
-        return strncmp(buffer, s, n);
+        buffer = guththila_token_to_string (environment, tok, unicode_state);
+        return strncmp (buffer, s, n);
     }
 }
 
 
 AXIS2_EXTERN int
-guththila_token_length_utf16(axis2_env_t * environment,
-        unsigned int utf16_ch)
+guththila_token_length_utf16 (axis2_env_t * environment,
+                              unsigned int utf16_ch)
 {
     int length;
 
@@ -258,15 +258,15 @@
 
 
 AXIS2_EXTERN guththila_char_t *
-guththila_token_build_utf8(axis2_env_t * environment,
-        unsigned int utf16_ch, int length)
+guththila_token_build_utf8 (axis2_env_t * environment,
+                            unsigned int utf16_ch, int length)
 {
     guththila_UTF8_char mask = 0;
     int ii = 0;
     guththila_char_t *buffer =
-        (guththila_char_t *) AXIS2_MALLOC(environment->allocator,
-                length + 1);
-    memset(buffer, 0, length + 1);
+        (guththila_char_t *) AXIS2_MALLOC (environment->allocator,
+                                               length + 1);
+    memset (buffer, 0, length+1);
 
     if (length == 1)
         buffer[0] = utf16_ch;
@@ -274,23 +274,23 @@
     {
         switch (length)
         {
-            case 1:
-                break;
-            case 2:
-                mask = 0xc0;
-                break;
-            case 3:
-                mask = 0xe0;
-                break;
-            case 4:
-                mask = 0xf0;
-                break;
-            case 5:
-                mask = 0xf8;
-                break;
-            case 6:
-                mask = 0xfc;
-                break;
+        case 1:
+            break;
+        case 2:
+            mask = 0xc0;
+            break;
+        case 3:
+            mask = 0xe0;
+            break;
+        case 4:
+            mask = 0xf0;
+            break;
+        case 5:
+            mask = 0xf8;
+            break;
+        case 6:
+            mask = 0xfc;
+            break;
         };
 
         for (ii = length - 1; ii > 0; ii--)
@@ -307,8 +307,8 @@
 
 
 AXIS2_EXTERN guththila_char_t *
-guththila_token_convert_utf16_to_utf8(axis2_env_t * environment,
-        guththila_char_t * buffer, int length)
+guththila_token_convert_utf16_to_utf8 (axis2_env_t * environment,
+                                       guththila_char_t * buffer, int length)
 {
     unsigned int utf16_char = 0;
     int length_utf16 = 0;
@@ -317,18 +317,18 @@
     guththila_char_t *output_char = 0;
     int ii = 0;
     guththila_char_t *output_buffer =
-        (guththila_char_t *) AXIS2_MALLOC(environment->allocator, 1);
-    memset(output_buffer, 0, 1);
+        (guththila_char_t *) AXIS2_MALLOC (environment->allocator, 1);
+    memset (output_buffer, 0, 1);
     for (ii = 0; length > ii;)
     {
         utf16_char = *((guththila_UTF16_char *) & input_buffer[ii]);
         ii += 2;
-        length_utf16 = guththila_token_length_utf16(environment, utf16_char);
+        length_utf16 = guththila_token_length_utf16 (environment, utf16_char);
         output_char =
-            guththila_token_build_utf8(environment, utf16_char,
-                    length_utf16);
+            guththila_token_build_utf8 (environment, utf16_char,
+                                        length_utf16);
         total_length += length_utf16;
-        output_buffer = strcat(output_buffer, output_char);
+        output_buffer = strcat (output_buffer, output_char);
     }
     return output_buffer;
 }

Modified: webservices/axis2/trunk/c/guththila/src/guththila_unicode.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_unicode.c?view=diff&rev=447788&r1=447787&r2=447788
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_unicode.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_unicode.c Tue Sep 19 02:20:00 2006
@@ -13,7 +13,7 @@
  *   See the License for the specific language governing permissions and
  *   limitations under the License.
  *
- *
+ *   
  */
 
 
@@ -22,11 +22,11 @@
 #include <string.h>
 #ifdef UNICODE_OUT              /* This variable for Obtain UTF-16 Output */
 
-/*! In order to determine length of UTF-16 Buffer
+/*! In order to determine length of UTF-16 Buffer 
  * Basicall guththila_char_t *p should be a Utf-16 Buffer  */
 
 guththila_UTF8_char
-guththila_strlen_unicode(guththila_char_t * p)
+guththila_strlen_unicode (guththila_char_t * p)
 {
     guththila_UTF8_char len = 0;
     guththila_UTF8_char d;
@@ -54,11 +54,11 @@
 
 /*!To Duplicate UTF-16 String  */
 guththila_char_t *
-guththila_strdup_unicode(guththila_char_t * p, int length)
+guththila_strdup_unicode (guththila_char_t * p, int length)
 {
     guththila_char_t *s;
-    s = (guththila_char_t *) calloc(length + 1, 1);
+    s = (guththila_char_t *) calloc (length + 1, 1);
     s[length] = 0;
-    return (guththila_char_t *) memcpy(s, p, length);
+    return (guththila_char_t *) memcpy (s, p, length);
 }
 #endif /*end of UNICODE_OUT definition  */

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=447788&r1=447787&r2=447788
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_writer.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_writer.c Tue Sep 19 02:20:00 2006
@@ -13,98 +13,98 @@
  *   See the License for the specific language governing permissions and
  *   limitations under the License.
  *
- *
+ *	
  */
 
 #include "guththila_writer.h"
 
 
 AXIS2_EXTERN guththila_writer_t * AXIS2_CALL
-guththila_writer_create_for_file(axis2_env_t *env, char *fp)
+guththila_writer_create_for_file (axis2_env_t *env, char *fp)
 {
-    guththila_writer_impl_t *wt = NULL;
-    if (!fp)
+      guththila_writer_impl_t *wt = NULL;
+      if(!fp)
         return NULL;
-    wt = (guththila_writer_impl_t *) AXIS2_MALLOC(env->allocator, sizeof(guththila_writer_impl_t));
-    wt->outputstream = fopen(fp, "w");
-    if (!wt->outputstream)
+      wt = (guththila_writer_impl_t *) AXIS2_MALLOC (env->allocator, sizeof (guththila_writer_impl_t));
+      wt->outputstream = fopen (fp, "w");
+      if (!wt->outputstream)
         return NULL;
-    wt->writer.guththila_writer_type = GUTHTHILA_WRITER_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_create_for_memory (axis2_env_t *env)
 {
-    guththila_writer_impl_t *wt = NULL;
+      guththila_writer_impl_t *wt = NULL;
 
-    wt = (guththila_writer_impl_t *) AXIS2_MALLOC(env->allocator, sizeof(guththila_writer_impl_t));
-    wt->outputstream = 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);
+      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)
+AXIS2_EXTERN void AXIS2_CALL
+guththila_writer_free (axis2_env_t *env, guththila_writer_t *wt)
 {
-    if (wt)
+  if (wt)
     {
-        if (wt->guththila_writer_type == GUTHTHILA_WRITER_FILE)
-        {
-            if (((guththila_writer_impl_t *)wt)->outputstream)
-                fclose(((guththila_writer_impl_t *)wt)->outputstream);
-            ((guththila_writer_impl_t *)wt)->outputstream = NULL;
-        }
-        AXIS2_FREE(env->allocator, (guththila_writer_t *)wt);
-        wt = NULL;
+      if (wt->guththila_writer_type == GUTHTHILA_WRITER_FILE)
+	{
+	  if (((guththila_writer_impl_t *)wt)->outputstream)
+	    fclose (((guththila_writer_impl_t *)wt)->outputstream);
+	  ((guththila_writer_impl_t *)wt)->outputstream = NULL;
+	}
+      AXIS2_FREE (env->allocator, (guththila_writer_t *)wt);
+      wt = NULL;
     }
 }
 
 AXIS2_EXTERN int AXIS2_CALL
-guththila_writer_write(axis2_env_t *env,
-        char *buffer, int offset,
-        int length, guththila_writer_t *wt)
+guththila_writer_write (axis2_env_t *env, 
+    char *buffer, int offset, 
+    int length, guththila_writer_t *wt)
 {
-    int c = 0;
-    guththila_writer_impl_t *writer_impl = NULL;
+  int c = 0;
+  guththila_writer_impl_t *writer_impl = NULL;
     if (wt->guththila_writer_type == GUTHTHILA_WRITER_FILE)
     {
-        c = fwrite(buffer + offset, 1, length, ((guththila_writer_impl_t *)wt)->outputstream);
+        c = fwrite (buffer+offset, 1, length, ((guththila_writer_impl_t *)wt)->outputstream);
     }
     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;
-    }
+      {
+	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_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;
+  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_writer_main.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/guththila/src/guththila_writer_main.c?view=diff&rev=447788&r1=447787&r2=447788
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_writer_main.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_writer_main.c Tue Sep 19 02:20:00 2006
@@ -1,32 +1,32 @@
-#include <stdio.h>
-#include <guththila_buffer.h>
-#include <guththila_reader.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_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");
-    guththila_xml_pull_parser_write_characters(env, parser, "guththila");
-    guththila_xml_pull_parser_write_start_element(env, parser, "escape");
-    guththila_xml_pull_parser_write_escape_character(env, parser, "&");
-    guththila_xml_pull_parser_write_escape_character(env, parser, ">");
-    guththila_xml_pull_parser_write_end_element(env, parser);
-    guththila_xml_pull_parser_write_start_element(env, parser, "escape");
-    guththila_xml_pull_parser_write_default_namespace(env, parser, "http://www.cse.mrt.ac.lk");
-    guththila_xml_pull_parser_write_namespace(env, parser, "a", "http://ws.apache.org");
-    guththila_xml_pull_parser_write_attribute_with_prefix(env, parser, "a", "web", "false");
-    guththila_xml_pull_parser_write_start_element(env, parser, "one");
-    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);
-    guththila_xml_pull_parser_xml_writer_free(env, parser);
-    guththila_xml_pull_parser_free(env, parser);
-    axis2_allocator_free(allocator);
-    axis2_env_free(env);
-    return 0;
-}
+#include <stdio.h>
+#include <guththila_buffer.h>
+#include <guththila_reader.h>
+#include <guththila.h>
+int main ()
+{
+  axis2_allocator_t *allocator = axis2_allocator_init (NULL);
+  axis2_env_t *env = axis2_env_create (allocator);
+  guththila_t *parser = guththila_create (env, NULL);
+  guththila_create_xml_stream_writer (env, parser, "w.xml");
+  guththila_write_start_document (env, parser);
+  guththila_write_start_element (env, parser, "person");
+  guththila_write_start_element (env, parser, "name");
+  guththila_write_characters (env, parser, "guththila");
+  guththila_write_start_element (env, parser, "escape");
+  guththila_write_escape_character (env, parser, "&");
+  guththila_write_escape_character (env, parser, ">");
+  guththila_write_end_element (env, parser);
+  guththila_write_start_element (env, parser, "escape");
+  guththila_write_default_namespace (env, parser, "http://www.cse.mrt.ac.lk");
+  guththila_write_namespace (env, parser, "a", "http://ws.apache.org");
+  guththila_write_attribute_with_prefix(env, parser, "a", "web", "false");
+  guththila_write_start_element (env, parser, "one");
+  guththila_write_start_element_with_prefix (env, parser, "a", "two");
+  guththila_write_characters (env, parser, "it works !");
+  guththila_write_end_document (env, parser);
+  guththila_xml_writer_free (env, parser);
+  guththila_free (env, parser);
+  axis2_allocator_free (allocator);
+  axis2_env_free (env);
+  return 0;
+}

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=447788&r1=447787&r2=447788
==============================================================================
--- webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.c (original)
+++ webservices/axis2/trunk/c/guththila/src/guththila_xml_pull_parser.c Tue Sep 19 02:20:00 2006
@@ -1,3 +1,1468 @@
+<<<<<<< .mine
+/*
+ *   Copyright 2004,2005 The Apache Software Foundation.
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ *   
+ */
+
+#include <guththila.h>
+
+AXIS2_EXTERN guththila_t * AXIS2_CALL
+guththila_create (axis2_env_t * environment,
+		  guththila_reader_t * r)
+{
+  guththila_t *parser =
+    (guththila_t *) AXIS2_MALLOC (
+				  environment->allocator, sizeof (guththila_t));
+  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);
+  parser->dep = axis2_stack_create (environment);
+  parser->name = NULL;
+  parser->prefix = NULL;
+  parser->value = NULL;
+  parser->reader = r;
+  parser->_next = 0;
+  parser->offset = 0;
+  parser->last = -1;
+  parser->status = S_1;
+  parser->unicode_state = None;
+  parser->xsw = NULL;
+  parser->is_whitespace = 0;
+  parser->is_char = 0;
+  return parser;
+}
+
+
+AXIS2_EXTERN  void AXIS2_CALL
+guththila_free (axis2_env_t * environment,
+		guththila_t * parser)
+{
+  if (parser->buffer) 
+    guththila_buffer_free (environment, (void *) parser->buffer);
+
+  if (parser->stack)
+    AXIS2_STACK_FREE (parser->stack, environment);
+  if (parser->attrib)
+    AXIS2_STACK_FREE (parser->attrib, environment);
+  if (parser->namesp)
+    AXIS2_STACK_FREE (parser->namesp, environment);
+  if (parser->dep)
+    AXIS2_STACK_FREE (parser->dep, environment);
+  
+  AXIS2_FREE (environment->allocator, (void *) parser);
+}
+
+
+AXIS2_EXTERN  int AXIS2_CALL
+guththila_exception (guththila_char_t * file, int line, int error_code)
+{
+  printf ("Throws guththila_exception \t %s \t %d \n", file,
+	  line);
+  /* Samisa: we should define a set of error codes and a corresponding error message set
+     rather than printing the above line to the console, we should be appending the
+     above string to the error message corresponding to the current error code
+     please delete this comment once this is fixed
+  */
+
+  /* Dinesh: Modified exception function to print line number , file
+     and return error code for particular error. If we feel that
+     file and line number is not necessary lets remove them later.*/
+  return error_code;
+}
+
+
+void AXIS2_CALL
+guththila_relocate_tokens (axis2_env_t *environment,
+			   guththila_t *parser,
+			   int offset)
+{
+  guththila_token_t *el = NULL;
+  int isize = 0;
+  isize = AXIS2_STACK_SIZE (parser->stack, environment);
+  /*   el = (guththila_token_t *) AXIS2_STACK_GET_AT (parser->stack, environment, isize-1); */
+  for (; isize > 0; isize--)
+    {
+      el = (guththila_token_t *) AXIS2_STACK_GET_AT (parser->stack, environment, isize-1);
+      guththila_token_relocate (environment, el, offset);
+    }
+}
+
+
+void AXIS2_CALL
+guththila_shift (axis2_env_t * environment,
+		 guththila_t * parser)
+{
+  memmove (parser->buffer->buff, parser->buffer->buff + (parser->offset),
+	   (parser->_next) - (parser->offset));
+  parser->_next -= parser->offset;
+  parser->last -= parser->offset;
+  parser->offset = 0;
+}
+
+
+AXIS2_EXTERN int AXIS2_CALL
+guththila_read (axis2_env_t * environment,
+		guththila_t * parser)
+{
+  int c = 0;
+  if (parser->_next == parser->buffer->size)
+    {
+      if (parser->offset > 0)
+        {
+	  guththila_relocate_tokens (environment, parser,
+				     parser->offset);
+	  guththila_shift (environment, parser);
+        }
+      else
+        {
+	  int b = parser->buffer->size;
+	  parser->buffer =
+	    guththila_buffer_grow (environment, parser->buffer);
+	  guththila_relocate_tokens (
+				     environment, parser, (parser->buffer->size - b));
+        }
+    }
+  c = guththila_reader_read (environment, (parser->buffer->buff),
+			     (parser->_next),
+			     (parser->buffer->size) - (parser->_next),
+			     parser->reader);
+  parser->last += c;
+  return !c;
+}
+
+
+int AXIS2_CALL
+guththila_from_utf16 (axis2_env_t * environment,
+		      guththila_t * parser,
+		      int eof)
+{
+  int c = parser->buffer->buff[parser->_next++];
+  if (((parser->_next) > (parser->last))
+      && guththila_read (environment, parser))
+    {
+      if (eof)
+	return -1;
+      else
+	guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_UNEXPECTED_UTF16_EOF);
+    }
+  while (!c)
+    c = parser->buffer->buff[parser->_next++];
+  return c;
+}
+
+
+int AXIS2_CALL
+guththila_next_char (axis2_env_t * environment,
+		     guththila_t * parser,
+		     int eof)
+{
+
+  if (parser->reader_type == GUTHTHILA_MEMORY_READER)
+    {
+      if (parser->_next > parser->last)
+	return -1;
+    }
+  else  if (((parser->_next) > (parser->last))
+	    && guththila_read (environment, parser))
+    {
+      if (eof)
+	return -1;
+      else
+	guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_UNEXPECTED_EOF);
+    }
+
+  if (parser->_next == 0)
+    {
+      guththila_UTF8_char iu =
+	(guththila_UTF8_char) parser->buffer->buff[parser->_next++];
+
+      if (0xff == iu
+	  && 0xfe ==
+	  (guththila_UTF8_char) parser->buffer->buff[parser->_next++])
+        {
+	  parser->unicode_state = LE;
+        }
+      else if (0xfe == iu
+	       && 0xff ==
+	       (guththila_UTF8_char) parser->buffer->buff[parser->_next++])
+        {
+	  parser->unicode_state = BE;
+        }
+      else if (0xef == iu
+	       && 0xbb ==
+	       (guththila_UTF8_char) parser->buffer->buff[parser->_next++]
+	       && 0xbf ==
+	       (guththila_UTF8_char) parser->buffer->buff[parser->_next++])
+        {
+	  parser->unicode_state = None;
+        }
+      else
+        {
+	  parser->unicode_state = None;
+	  parser->_next = 0;
+        }
+    }
+
+  if (parser->unicode_state == None)
+    return parser->buffer->buff[parser->_next++];
+  else
+    return guththila_from_utf16 (environment, parser,
+				 eof);
+}
+
+
+guththila_char_t * AXIS2_CALL
+guththila_last_char (axis2_env_t * environment,
+		     guththila_t * parser)
+{
+  return parser->buffer->buff + (parser->_next - 1);
+}
+
+
+void AXIS2_CALL
+guththila_open_token (axis2_env_t * environment,
+		      guththila_t * parser)
+{
+  guththila_token_t *t =
+    (guththila_token_t *) AXIS2_MALLOC (environment->allocator,
+					sizeof (guththila_token_t));
+  t->type = Unknown;
+  t->start = guththila_last_char (environment, parser);
+  AXIS2_STACK_PUSH (parser->stack, environment, t);
+}
+
+
+void AXIS2_CALL
+guththila_close_token (axis2_env_t * environment,
+		       guththila_t * parser,
+		       int t, int refer)
+{
+  guththila_token_t *token =
+    (guththila_token_t *) AXIS2_STACK_GET (parser->stack, environment);
+  token->type = t;
+  token->ref = refer;
+  token->end =
+    guththila_last_char (environment, parser) - 1;
+}
+
+
+int AXIS2_CALL
+guththila_skip_spaces (axis2_env_t * environment,
+		       guththila_t * parser,
+		       int c)
+{
+  while (0x20 == c || 0x9 == c || 0xD == c || 0xA == c)
+    c = guththila_next_char (environment, parser, 0);
+  return c;
+}
+
+
+int AXIS2_CALL
+guththila_process_eq (axis2_env_t * environment,
+		      guththila_t * parser,
+		      int c)
+{
+  int ic;
+  if (0x3D ==
+      guththila_skip_spaces (environment, parser, c))
+    {
+      ic = guththila_next_char (environment, parser, 0);
+      return guththila_skip_spaces (environment, parser,
+				    ic);
+    }
+  else
+    guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_PROCESS_EQUAL);
+  return 0;
+}
+
+
+int AXIS2_CALL
+guththila_process_version_info (axis2_env_t *
+				environment,
+				guththila_t *
+				parser)
+{
+  int ic;
+  int quote;
+  int nc;
+  ic = guththila_next_char (environment, parser, 0);
+  ic = guththila_skip_spaces (environment, parser, ic);
+  if (ic == 'v')
+    {
+      guththila_open_token (environment, parser);
+      if ('e' ==
+	  guththila_next_char (environment, parser, 0)
+	  && 'r' == guththila_next_char (environment,
+					 parser, 0)
+	  && 's' == guththila_next_char (environment,
+					 parser, 0)
+	  && 'i' == guththila_next_char (environment,
+					 parser, 0)
+	  && 'o' == guththila_next_char (environment,
+					 parser, 0)
+	  && 'n' == guththila_next_char (environment,
+					 parser, 0))
+        {
+	  ic = guththila_next_char (environment, parser, 0);
+	  guththila_close_token (environment, parser,
+				 _attribute, 0);
+	  quote =
+	    guththila_process_eq (environment, parser,
+				  ic);
+	  nc = guththila_next_char (environment, parser, 0);
+	  /* 0, since we don't expect EOF line here */
+	  guththila_open_token (environment, parser);
+	  while (quote != nc)
+	    nc = guththila_next_char (environment, parser,
+				      0);
+	  guththila_close_token (environment, parser,
+				 _attribute_value, 0);
+	  nc = guththila_next_char (environment, parser, 0);
+	  return guththila_skip_spaces (environment, parser,
+					nc);
+        }
+      else
+	guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_INCORRECT_VERSION_INFO);
+    }
+  else
+    guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_VERSION_INFO_NOT_FOUND);
+  return 0;
+}
+
+
+int AXIS2_CALL
+guththila_process_encoding_decl (axis2_env_t *
+				 environment,
+				 guththila_t *
+				 parser)
+{
+  int quote;
+  int nc;
+  int ic;
+  guththila_open_token (environment, parser);
+  if ('n' == guththila_next_char (environment, parser, 0)
+      && 'c' == guththila_next_char (environment, parser, 0)
+      && 'o' == guththila_next_char (environment, parser, 0)
+      && 'd' == guththila_next_char (environment, parser, 0)
+      && 'i' == guththila_next_char (environment, parser, 0)
+      && 'n' == guththila_next_char (environment, parser, 0)
+      && 'g' == guththila_next_char (environment, parser,
+				     0))
+    {
+      ic = guththila_next_char (environment, parser, 0);
+      guththila_close_token (environment, parser,
+			     _attribute, 0);
+      quote =
+	guththila_process_eq (environment, parser, ic);
+      nc = guththila_next_char (environment, parser, 0);
+      guththila_open_token (environment, parser);
+      while (quote != nc)
+	nc = guththila_next_char (environment, parser, 0);
+      guththila_close_token (environment, parser,
+			     _attribute_value, 0);
+      nc = guththila_next_char (environment, parser, 0);
+      return guththila_skip_spaces (environment, parser,
+				    nc);
+    }
+  else
+    guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_ENCODING_DECLARATION_ERROR);
+  return 0;
+}
+
+
+int AXIS2_CALL
+guththila_process_sd_decl (axis2_env_t *
+			   environment,
+			   guththila_t *
+			   parser)
+{
+  int quote = 0;
+  int nc = 0;
+  int ic = 0;
+  guththila_open_token (environment, parser);
+  if ('t' == guththila_next_char (environment, parser, 0)
+      && 'a' == guththila_next_char (environment, parser, 0)
+      && 'n' == guththila_next_char (environment, parser, 0)
+      && 'd' == guththila_next_char (environment, parser, 0)
+      && 'a' == guththila_next_char (environment, parser, 0)
+      && 'l' == guththila_next_char (environment, parser, 0)
+      && 'o' == guththila_next_char (environment, parser, 0)
+      && 'n' == guththila_next_char (environment, parser, 0)
+      && 'e' == guththila_next_char (environment, parser,
+				     0))
+    ic = guththila_next_char (environment, parser, 0);
+  guththila_close_token (environment, parser, _attribute,
+			 0);
+  quote = guththila_process_eq (environment, parser, ic);
+  nc = guththila_next_char (environment, parser, 0);
+  guththila_open_token (environment, parser);
+  while (quote != nc)
+    {
+      if ('y' == nc)
+        {
+	  if ('e' !=
+	      guththila_next_char (environment, parser, 0)
+	      || 's' != guththila_next_char (environment,
+					     parser, 0))
+	    guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_STANDALONE_ERROR_IN_YES);
+	  else
+	    nc = guththila_next_char (environment, parser,
+				      0);
+        }
+      else if ('n' == nc)
+        {
+	  if ('o' !=
+	      guththila_next_char (environment, parser, 0))
+	    guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_STANDALONE_ERROR_IN_NO);
+	  else
+	    nc = guththila_next_char (environment, parser,
+				      0);
+        }
+      else
+	guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_STANDALONE_ERROR_YES_OR_NO_NOT_AVAILABLE);
+    }
+  guththila_close_token (environment, parser,
+			 _attribute_value, 0);
+  nc = guththila_next_char (environment, parser, 0);
+  return guththila_skip_spaces (environment, parser, nc);
+}
+
+
+int AXIS2_CALL
+guththila_process_xml_decl (axis2_env_t *
+			    environment,
+			    guththila_t *
+			    parser)
+{
+  int ix;
+  if ('x' == guththila_next_char (environment, parser, 0)
+      && 'm' == guththila_next_char (environment, parser, 0)
+      && 'l' == guththila_next_char (environment, parser,
+				     0))
+    {
+      ix = guththila_process_version_info (environment,
+					   parser);
+
+      if ('e' == ix)
+	ix = guththila_process_encoding_decl (environment,
+					      parser);
+
+      if ('s' == ix)
+	ix = guththila_process_sd_decl (environment,
+					parser);
+
+      if ('?' == ix)
+        {
+	  if ('>' !=
+	      guththila_next_char (environment, parser, 0))
+	    guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_MISSING_GREATER_SIGN_IN_XML_DECLARATION);
+	  else
+	    {
+	      while (guththila_is_space (environment, guththila_next_char (environment, parser, 0))); 
+	      parser->_next--;
+	      parser->guththila_event = GUTHTHILA_START_DOCUMENT;
+	    }
+        }
+    }
+  else
+    guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_INCORRECT_XML_DECLARATION);
+  return 0;
+}
+
+
+void AXIS2_CALL
+guththila_reset (axis2_env_t * environment,
+		 guththila_t * parser)
+{
+  int ii; 
+  parser->offset = parser->_next;
+  parser->name = NULL;
+  parser->prefix = NULL;
+  parser->value = NULL;
+  parser->is_whitespace = 0;
+  parser->is_char = 0;
+      
+  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);
+    }
+
+  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);
+    }
+
+  if(parser->guththila_event == GUTHTHILA_END_ELEMENT
+     || parser->guththila_event == GUTHTHILA_EMPTY_ELEMENT)
+    guththila_close_element (environment, parser);
+}
+
+
+int AXIS2_CALL
+guththila_is_space (axis2_env_t * environment,
+		    int c)
+{
+  if (0x20 == c || 0xD == c || 0xA == c || 0x9 == c)
+    return 1;
+  else
+    return 0;
+}
+
+
+int AXIS2_CALL
+guththila_is_valid_starting_char (axis2_env_t *
+				  environment,
+				  guththila_t
+				  * parser, int c)
+{
+  if (isalpha (c) || '_' == c || ':' == c)
+    return 1;
+  else
+    return 0;
+}
+
+
+int AXIS2_CALL
+guththila_process_name (axis2_env_t * environment,
+			guththila_t * parser)
+{
+  int c;
+  guththila_char_t *x;
+  x = guththila_last_char (environment, parser);
+  if (!guththila_is_valid_starting_char
+      (environment, parser, x[0]))
+    guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_INVALID_NAME_STARTING_CHARACTER);
+
+  guththila_open_token (environment, parser);
+  c = guththila_next_char (environment, parser, 0);
+  while (!
+	 (guththila_is_space (environment, c) || '/' == c
+	  || '=' == c || '?' == c || '>' == c))
+    {
+      if (':' == c)
+        {
+	  guththila_close_token (environment, parser,
+				 _prefix, 0);
+	  c = guththila_next_char (environment, parser, 0);
+	  guththila_open_token (environment, parser);
+        }
+      else
+	c = guththila_next_char (environment, parser, 0);
+    }
+  guththila_close_token (environment, parser, _name, 0);
+
+  return c;
+}
+
+
+int AXIS2_CALL
+guththila_process_attribute_value (axis2_env_t *
+				   environment,
+				   guththila_t
+				   * parser, int quote)
+{
+  int c = 0;
+  if ('\'' == quote || '\"' == quote)
+    {
+      c = guththila_next_char (environment, parser, 0);
+      guththila_open_token (environment, parser);
+      do
+        {
+	  c = guththila_next_char (environment, parser, 0);
+	  if (quote == c)
+            {
+	      guththila_close_token (environment, parser,
+				     _attribute_value, 0);
+	      return guththila_next_char (environment,
+					  parser, 0);
+            }
+        }
+      while ('<' != c || '&' != c);
+    }
+  else
+    guththila_exception (p_FILE, LINE,  GUTHTHILA_ERROR_QUOTES_NOT_FOUND_BEFORE_ATTRIBUTE_VALUE );
+  return c;
+}
+
+
+int AXIS2_CALL
+guththila_process_attribute (axis2_env_t *
+			     environment,
+			     guththila_t *
+			     parser, int c)
+{
+  int q;
+  q = guththila_skip_spaces (environment, parser, c);
+  q = guththila_process_name (environment, parser);
+  q = guththila_process_eq (environment, parser, q);
+  q = guththila_process_attribute_value (environment,
+					 parser, q);
+  return q;
+}
+
+
+int AXIS2_CALL
+guththila_processSTagOrEmptyElem (axis2_env_t *
+				  environment,
+				  guththila_t
+				  * parser)
+{
+  int c;
+  c = guththila_process_name (environment, parser);
+  c = guththila_skip_spaces (environment, parser, c);
+  parser->guththila_event = GUTHTHILA_START_ELEMENT;
+  for (;;)
+    {
+      if ('/' == c)
+        {
+	  parser->guththila_event = GUTHTHILA_EMPTY_ELEMENT;
+	  if ('>' ==
+	      guththila_next_char (environment, parser, 0))
+	    return c;
+	  else
+	    guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_EMPTY_ELEMENT_NOT_CLOSED);
+        }
+      else if ('>' == c)
+	return c;
+      else
+        {
+	  c = guththila_process_attribute (environment,
+					   parser, c);
+	  c = guththila_skip_spaces (environment, parser,
+				     c);
+        }
+    }
+}
+
+
+int AXIS2_CALL
+guththila_process_char_data (axis2_env_t *
+			     environment,
+			     guththila_t *
+			     parser)
+{
+  int c = 0;
+  int ref = 0;
+  parser->is_whitespace = 0;
+  parser->is_char = 0;
+
+  parser->guththila_event = GUTHTHILA_CHARACTER;
+  guththila_open_token (environment, parser);
+
+  c = parser->buffer->buff [parser->_next - 1];
+
+  if (isspace (c))
+    {
+      parser->is_whitespace = 1;
+    }
+
+  do
+    {
+
+      c = guththila_next_char (environment, parser, -1);      
+
+      if (isspace (c))
+	{
+	  if (!parser->is_char)
+	    parser->is_whitespace = 1;
+	  else
+	    parser->is_whitespace = 0;
+	}
+      else if (c == '&')
+	ref = 1;
+      else if (c == -1)		/* first should check for eof then
+				   only check of r != < */
+        {
+	  guththila_close_token (environment, parser,
+				 _char_data, ref);
+	  return 0;
+        }
+      else if (c != '<') 
+	{
+	  parser->is_whitespace = 0;
+	  parser->is_char = 1;
+	}
+
+    }
+  while (c != '<');
+
+  guththila_close_token (environment, parser, _char_data,
+			 ref);
+  return c;
+}
+
+
+int AXIS2_CALL
+guththila_process_end_tag (axis2_env_t *
+			   environment,
+			   guththila_t *
+			   parser)
+{
+  int c;
+  c = guththila_next_char (environment, parser, 0);
+  c = guththila_process_name (environment, parser);
+  c = guththila_skip_spaces (environment, parser, c);
+  if ('>' == c)
+    parser->guththila_event = GUTHTHILA_END_ELEMENT;
+  else
+    guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_END_TAG_NOT_CLOSED);
+  return c;
+}
+
+
+int AXIS2_CALL
+guththila_process_pi (axis2_env_t * environment,
+		      guththila_t * parser)
+{
+  int c;
+  parser->guththila_event = GUTHTHILA_COMMENT;
+  c = guththila_next_char (environment, parser, 0);
+  while ('<' != c)
+    c = guththila_next_char (environment, parser, 0);
+  return c;
+}
+
+
+int AXIS2_CALL
+guththila_process_comment (axis2_env_t *
+			   environment,
+			   guththila_t *
+			   parser)
+{
+  int c;
+  if ('-' == guththila_next_char (environment, parser, 0)
+      && '-' == guththila_next_char (environment, parser,
+				     0))
+    {
+      c = guththila_next_char (environment, parser, 0);
+      while (1)
+        {
+	  c = guththila_next_char (environment, parser, 0);
+	  if ('-' == c)
+            {
+	      c = guththila_next_char (environment, parser,
+				       0);
+	      if ('-' == c)
+                {
+		  if ('>' ==
+		      guththila_next_char (environment,
+					   parser, 0))
+                    {
+		      parser->guththila_event = GUTHTHILA_COMMENT;
+		      while ('<' != c)
+                        {
+			  c = guththila_next_char
+			    (environment, parser, -1);
+			  if (c == -1)
+			    return c;
+                        }
+		      return c;
+                    }
+		  else
+		    guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_MORE_HYPENS_OCCURED_IN_COMMENT);
+                }
+            }
+        }
+    }
+  else
+    {
+      c = guththila_next_char (environment, parser, 0);
+      while ('<' != c)
+	c = guththila_next_char (environment, parser, -1);
+    }
+  return 0;
+}
+
+
+int AXIS2_CALL
+guththila_tokenize (axis2_env_t * environment,
+		    guththila_t * parser)
+{
+  do
+    {
+      int c;
+      c = guththila_next_char (environment, parser, -1);
+      if (c == -1)
+	return -1;
+
+      switch (parser->status)
+        {
+        case S_1:
+	  while (isspace(c))
+            {
+ c = guththila_next_char (environment, parser, -1);
+   if (c == -1)
+		 return -1;
+		 }
+
+			      if ('<' == c)
+				parser->status = S_2;
+			      else
+				parser->status = S_0;
+			      break;
+        case S_2:
+	  {
+	    if ('?' == c)
+	      {
+		guththila_process_xml_decl (environment,
+					    parser);
+		parser->status = S_3;
+	      }
+	    else if ('!' == c)
+	      {
+		guththila_process_comment (environment,
+					   parser);
+		parser->status = S_4;
+	      }
+	    else
+	      {
+		guththila_processSTagOrEmptyElem
+		  (environment, parser);
+		parser->status = S_3;
+	      }
+	  }
+	  break;
+        case S_3:
+	  if ('<' == c)
+	    parser->status = S_4;
+	  else
+            {
+	      c = guththila_process_char_data (environment,
+					       parser);
+	      if ('<' == c)
+                {
+		  parser->status = S_4;
+		  return parser->guththila_event;
+                }
+	      else if ('\0' == c)
+		parser->status = S_3;
+	      else
+		parser->status = S_0;
+            }
+	  break;
+        case S_4:
+	  if ('/' == c)
+            {
+	      guththila_process_end_tag (environment,
+					 parser);
+	      parser->status = S_3;
+            }
+	  else if ('?' == c)
+	    guththila_process_pi (environment, parser);
+	  else if ('!' == c)
+	    guththila_process_comment (environment,
+				       parser);
+	  else
+            {
+	      guththila_processSTagOrEmptyElem (environment,
+						parser);
+	      parser->status = S_3;
+            }
+	  break;
+        case S_0:
+	  guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_TOKENIZE_ERROR);
+        }
+    }
+  while (parser->status != S_3);
+  return parser->guththila_event;
+}
+
+
+AXIS2_EXTERN  int AXIS2_CALL
+guththila_next (axis2_env_t * environment,
+		guththila_t * parser)
+{
+  int ix;
+  guththila_reset (environment, parser);
+  ix = guththila_tokenize (environment, parser);
+  switch (ix)
+    {
+    case -1:
+      return -1;
+
+    case GUTHTHILA_START_DOCUMENT:
+      {
+	int ix;
+	guththila_token_t *token;
+	guththila_token_t *att_name;
+	guththila_token_t *att_value;
+	ix = AXIS2_STACK_SIZE (parser->stack, environment);
+	for (; ix > 0; ix--)
+	  {
+	    token = (guththila_token_t *)AXIS2_STACK_POP (parser->stack, environment);
+	    if (token->type == _attribute_value)
+	      {
+		att_value = token;
+		token = (guththila_token_t *)AXIS2_STACK_POP (parser->stack, environment);
+		ix--;
+		att_name = token;
+		guththila_add_attribute (environment,
+					 parser, att_name,
+					 att_value);
+	      }
+	  }
+      }
+      break;
+    case GUTHTHILA_START_ELEMENT:
+    case GUTHTHILA_EMPTY_ELEMENT:
+      {
+	int is = 0;
+	guththila_token_t *token;
+	guththila_token_t *name = NULL;
+	guththila_token_t *value = NULL;
+	is = AXIS2_STACK_SIZE (parser->stack, environment);
+	for (;
+	     is > 0 && 	AXIS2_STACK_SIZE (parser->stack, environment);
+	     is--)
+	  {
+	    token = (guththila_token_t *) AXIS2_STACK_POP (parser->stack, environment);
+	    /* be careful about memory leaks, when we pull it we get
+	       seperate _element need to free it properly */
+	    if (token->type == _attribute_value)
+	      {
+		value = token;
+		token = (guththila_token_t *) AXIS2_STACK_POP (parser->stack, environment);
+		is--;
+		name = token;
+		if (!guththila_token_compare
+		    (environment, token, "xmlns", 5,
+		     parser->unicode_state))
+		  guththila_add_namespace (environment,
+					   parser, name,
+					   value);
+		else
+		  guththila_add_attribute (environment,
+					   parser, name,
+					   value);
+	      }
+	    else if (token->type == _name)
+	      {
+		name = token;
+		parser->name = name;
+		parser->prefix = NULL;
+
+	      }
+	    else if (token->type == _prefix)
+	      {
+		guththila_attribute_t *attribute;
+		if (!guththila_token_compare
+		    (environment, token, "xmlns", 5,
+		     parser->unicode_state))
+		  {
+		    attribute = (guththila_attribute_t *) AXIS2_STACK_POP ( parser->attrib, environment);
+		    guththila_add_namespace (environment,
+					     parser,
+					     attribute->
+					     name,
+					     attribute->
+					     value);
+		  }
+		else
+		  {
+		    if (parser->name)
+		      parser->prefix = token;
+		    else
+		      {
+			attribute = (guththila_attribute_t *) AXIS2_STACK_POP ( parser->attrib, environment);
+			guththila_add_attribute_with_prefix
+			  (environment, parser, token,
+			   attribute->name, attribute->value);
+		      }
+		  }
+	      }
+	    else
+	      guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_INVALID_TOKEN_TYPE);
+	  }
+	guththila_open_element (environment, parser);
+      }
+      break;
+    case GUTHTHILA_END_ELEMENT:
+      {
+	guththila_token_t *token;
+	token = (guththila_token_t *) AXIS2_STACK_POP (parser->stack, environment);
+	if (token->type == _name)
+	  parser->name = token;
+
+	if (AXIS2_STACK_SIZE (parser->stack, environment))
+	  {
+	    token = (guththila_token_t *) AXIS2_STACK_POP (parser->stack, environment);
+	    if (token->type == _prefix)
+	      parser->prefix = token;
+	  }
+      }
+      break;
+    case GUTHTHILA_CHARACTER:
+      {
+	guththila_token_t *token;
+	token = (guththila_token_t *) AXIS2_STACK_POP (parser->stack, environment);
+	parser->value = token;
+      }
+      break;
+    case GUTHTHILA_ENTITY_REFERANCE:
+      break;
+    case GUTHTHILA_COMMENT:
+      break;
+
+    };
+  return parser->guththila_event;
+}
+
+
+void AXIS2_CALL
+guththila_open_element (axis2_env_t * environment,
+			guththila_t * parser)
+{
+  int ii;
+  guththila_depth_t *m =
+    (guththila_depth_t *) AXIS2_MALLOC (environment->allocator,
+					sizeof (guththila_depth_t));
+  guththila_depth_t *l = NULL;
+  guththila_depth_t *depth;
+  ii = AXIS2_STACK_SIZE (parser->dep, environment);
+  if (!ii)
+    {
+      m->first = 0;
+      m->total = AXIS2_STACK_SIZE (parser->namesp, environment);
+      m->count = m->total;
+      /*       guththila_stack_push_depth (environment, parser->dep, m); */
+      AXIS2_STACK_PUSH (parser->dep, environment, m);
+    }
+  else
+    {
+      depth = (guththila_depth_t *) AXIS2_STACK_GET (parser->dep, environment);
+      l = depth;
+      m->first = l->first + l->count;
+      m->total = AXIS2_STACK_SIZE (parser->namesp, environment);
+      m->count = m->total - l->total;
+      AXIS2_STACK_PUSH (parser->dep, environment, m);
+    }
+}
+
+
+void AXIS2_CALL
+guththila_close_element (axis2_env_t *
+			 environment,
+			 guththila_t * parser)
+{
+  guththila_depth_t *depth;
+  guththila_namespace_t *namespace;
+  int ii;
+  depth = (guththila_depth_t *) AXIS2_STACK_POP (parser->dep, environment);
+  ii = depth->count;
+  for (; ii > 0; ii--)
+    {
+      namespace = (guththila_namespace_t *) AXIS2_STACK_POP (parser->namesp, environment);
+      if (namespace->name)
+        {
+	  AXIS2_FREE (environment->allocator, namespace->name);
+	  namespace->name = NULL;
+        }
+      if (namespace->uri)
+        {
+	  AXIS2_FREE (environment->allocator, namespace->uri);
+	  namespace->uri = NULL;
+        }
+      
+    }
+
+}
+
+
+void AXIS2_CALL
+guththila_add_attribute (axis2_env_t *
+			 environment,
+			 guththila_t * parser,
+			 guththila_token_t * name,
+			 guththila_token_t * value)
+{
+  guththila_attribute_t *att;
+  att =
+    (guththila_attribute_t *) AXIS2_MALLOC (environment->allocator,
+					    sizeof
+					    (guththila_attribute_t));
+  att->name = name;
+  att->value = value;
+  att->prefix = NULL;
+  /*   guththila_stack_push (environment, parser->attrib, NULL, att); */
+  AXIS2_STACK_PUSH (parser->attrib, environment, att);
+}
+
+
+void AXIS2_CALL
+guththila_add_attribute_with_prefix (axis2_env_t *
+				     environment,
+				     guththila_t
+				     * parser,
+				     guththila_token_t *
+				     prefix,
+				     guththila_token_t * name,
+				     guththila_token_t *
+				     value)
+{
+  guththila_attribute_t *att;
+  att =
+    (guththila_attribute_t *) AXIS2_MALLOC (environment->allocator,
+					    sizeof
+					    (guththila_attribute_t));
+  att->name = name;
+  att->value = value;
+  att->prefix = prefix;
+  AXIS2_STACK_PUSH (parser->attrib, environment, att);
+
+  /* _element can keep , tokens and attributes here token set to null */
+}
+
+
+void AXIS2_CALL
+guththila_add_namespace (axis2_env_t *
+			 environment,
+			 guththila_t * parser,
+			 guththila_token_t * name,
+			 guththila_token_t * uri)
+{
+  guththila_namespace_t *ns;
+  ns = (guththila_namespace_t *) AXIS2_MALLOC (environment->allocator,
+					       sizeof
+					       (guththila_namespace_t));
+  ns->name =
+    guththila_token_to_string (environment, name, parser->unicode_state);
+  ns->length = AXIS2_STRLEN ( ns->name);
+  ns->uri =
+    guththila_token_to_string (environment, uri, parser->unicode_state);
+  ns->lengthuri = AXIS2_STRLEN ( ns->uri);
+  AXIS2_STACK_PUSH (parser->namesp, environment, ns);
+}
+
+
+AXIS2_EXTERN  int AXIS2_CALL
+guththila_get_attribute_count (axis2_env_t *
+			       environment,
+			       guththila_t *
+			       parser)
+{
+  return AXIS2_STACK_SIZE (parser->attrib, environment);
+}
+
+
+AXIS2_EXTERN  guththila_attribute_t * AXIS2_CALL
+guththila_get_attribute (axis2_env_t *
+			 environment,
+			 guththila_t * parser)
+{
+  guththila_attribute_t *attribute;
+  attribute = (guththila_attribute_t *) AXIS2_STACK_POP (parser->attrib, environment);
+  if (attribute)
+    return attribute;
+  else
+    return NULL;
+}
+
+
+AXIS2_EXTERN  guththila_char_t * AXIS2_CALL
+guththila_get_attribute_name (axis2_env_t *
+			      environment,
+			      guththila_t *
+			      parser,
+			      guththila_attribute_t * att)
+{
+  if (!att)
+    guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_NULL_ATTRIBUTE_NAME);
+  if (att->name->end)
+    return guththila_token_to_string (environment, att->name,
+				      parser->unicode_state);
+  return NULL;
+}
+
+
+AXIS2_EXTERN  guththila_char_t * AXIS2_CALL
+guththila_get_attribute_value (axis2_env_t *
+			       environment,
+			       guththila_t *
+			       parser,
+			       guththila_attribute_t * att)
+{
+  if (!att)
+    guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_NULL_ATTRIBUTE_VALUE);
+  if (att->value->end)
+    return guththila_token_to_string (environment, att->value,
+				      parser->unicode_state);
+  return NULL;
+}
+
+
+AXIS2_EXTERN  guththila_char_t * AXIS2_CALL
+guththila_get_attribute_prefix (axis2_env_t *
+				environment,
+				guththila_t *
+				parser,
+				guththila_attribute_t * att)
+{
+  if (!att)
+    guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_NULL_ATTRIBUTE_PREFIX);
+  if (att->prefix->end)
+    return guththila_token_to_string (environment, att->prefix,
+				      parser->unicode_state);
+  return NULL;
+}
+
+
+AXIS2_EXTERN  guththila_char_t * AXIS2_CALL
+guththila_get_attribute_prefix_by_number (axis2_env_t * environment, guththila_t * parser, int i)
+{
+  int ix = AXIS2_STACK_SIZE (parser->attrib, environment);
+  guththila_attribute_t *attribute = NULL;
+  if (i > ix)
+    guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_REQUESTED_NUMBER_GREATER_THAN_STACK_SIZE);
+  else
+    {
+      attribute = (guththila_attribute_t *) AXIS2_STACK_GET_AT (parser->attrib, environment, ix-i);
+    }
+  return guththila_token_to_string (environment, attribute->prefix,
+				    parser->unicode_state);
+}
+
+
+AXIS2_EXTERN  guththila_char_t * AXIS2_CALL
+guththila_get_attribute_name_by_number (axis2_env_t * environment, guththila_t * parser, int i)
+{
+  int ix = AXIS2_STACK_SIZE (parser->attrib, environment);
+  guththila_attribute_t *attribute = NULL;
+  if (i > ix)
+    guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_REQUESTED_NUMBER_GREATER_THAN_STACK_SIZE);
+  else
+    {
+      attribute = (guththila_attribute_t *) AXIS2_STACK_GET_AT (parser->attrib, environment, ix-i);
+    }
+  return guththila_token_to_string (environment, attribute->name,
+				    parser->unicode_state);
+}
+
+
+AXIS2_EXTERN  guththila_char_t * AXIS2_CALL
+guththila_get_attribute_value_by_number (axis2_env_t * environment, 
+					 guththila_t * parser, int i)
+{
+  int ix = AXIS2_STACK_SIZE (parser->attrib, environment);
+  guththila_attribute_t *attribute = NULL;
+  if (i > ix)
+    guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_REQUESTED_NUMBER_GREATER_THAN_STACK_SIZE);
+  else
+    {
+      attribute = (guththila_attribute_t *) AXIS2_STACK_GET_AT (parser->attrib, environment, ix-i);
+    }
+  return guththila_token_to_string (environment, attribute->value,
+				    parser->unicode_state);
+}
+
+
+AXIS2_EXTERN  guththila_char_t * AXIS2_CALL
+guththila_get_name (axis2_env_t * environment,
+		    guththila_t * parser)
+{
+  if (parser->name->end)
+    return guththila_token_to_string (environment, parser->name,
+				      parser->unicode_state);
+  return NULL;
+}
+
+
+AXIS2_EXTERN  guththila_char_t * AXIS2_CALL
+guththila_get_value (axis2_env_t * environment,
+		     guththila_t * parser)
+{
+  if (parser->value->end)
+    return guththila_token_to_string (environment, parser->value,
+				      parser->unicode_state);
+  else
+    return NULL;
+}
+
+
+AXIS2_EXTERN  guththila_char_t * AXIS2_CALL
+guththila_get_prefix (axis2_env_t * environment,
+		      guththila_t * parser)
+{
+  if (parser->prefix)
+    return guththila_token_to_string (environment, parser->prefix,
+				      parser->unicode_state);
+  return NULL;
+}
+
+
+AXIS2_EXTERN  int AXIS2_CALL
+guththila_get_namespace_count (axis2_env_t *
+			       environment,
+			       guththila_t *
+			       parser)
+{
+  if (parser->namesp)
+    return AXIS2_STACK_SIZE (parser->namesp, environment);
+  else
+    return 0;
+}
+
+
+AXIS2_EXTERN  guththila_namespace_t * AXIS2_CALL
+guththila_get_namespace (axis2_env_t *
+			 environment,
+			 guththila_t * parser)
+{
+  guththila_namespace_t *namespace;
+  namespace = (guththila_namespace_t *) AXIS2_STACK_GET (parser->namesp, environment);
+  if (namespace)
+    return namespace;
+  else
+    return NULL;
+}
+
+
+AXIS2_EXTERN  guththila_char_t * AXIS2_CALL
+guththila_get_namespace_prefix (axis2_env_t *
+				environment,
+				guththila_t *
+				parser,
+				guththila_namespace_t * ns)
+{
+  if (ns)
+    return AXIS2_STRDUP (ns->name, environment);
+  else
+    return NULL;
+}
+
+
+AXIS2_EXTERN  guththila_char_t * AXIS2_CALL
+guththila_get_namespace_uri (axis2_env_t *
+			     environment,
+			     guththila_t *
+			     parser,
+			     guththila_namespace_t * ns)
+{
+  if (ns)
+    return AXIS2_STRDUP (ns->uri, environment);
+  else
+    return NULL;
+}
+
+
+AXIS2_EXTERN  guththila_char_t * AXIS2_CALL
+guththila_get_namespace_prefix_by_number (axis2_env_t * environment, 
+					  guththila_t * parser, 
+					  int i)
+{
+  int ix = AXIS2_STACK_SIZE (parser->namesp, environment);
+  guththila_namespace_t *ns = NULL;
+  if (i > ix)
+    guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_REQUESTED_NUMBER_GREATER_THAN_STACK_SIZE);
+  else
+    {
+      ns = (guththila_namespace_t *) AXIS2_STACK_GET_AT (parser->namesp, environment, ix-i);
+    }
+  return AXIS2_STRDUP (ns->name, environment);
+}
+
+
+AXIS2_EXTERN  guththila_char_t * AXIS2_CALL
+guththila_get_namespace_uri_by_number (axis2_env_t
+				       * environment,
+				       guththila_t
+				       * parser, int i)
+{
+  int ix = AXIS2_STACK_SIZE (parser->namesp, environment);
+  guththila_namespace_t *ns = NULL;
+  if (i > ix)
+    guththila_exception (p_FILE, LINE, GUTHTHILA_ERROR_REQUESTED_NUMBER_GREATER_THAN_STACK_SIZE);
+  else
+    {
+      ns = (guththila_namespace_t *) AXIS2_STACK_GET_AT (parser->namesp, environment, ix-i);
+    }
+  return AXIS2_STRDUP (ns->uri, environment);
+}
+
+
+AXIS2_EXTERN  guththila_char_t * AXIS2_CALL
+guththila_get_attribute_namespace_by_number (axis2_env_t * environment, 
+					     guththila_t * parser, 
+					     int i)
+{
+  guththila_char_t *att_prefix;
+  int ii;
+  int ix = AXIS2_STACK_SIZE (parser->namesp, environment);
+  guththila_namespace_t *ns = NULL;
+  att_prefix =
+    guththila_get_attribute_prefix_by_number (environment,
+					      parser, i);
+
+  for (ii = 0; ii <= ix; ii++)
+    {
+      ns = (guththila_namespace_t *) AXIS2_STACK_GET_AT (parser->namesp, environment, ix-ii);
+      if (ns)
+        {
+	  if (ns && att_prefix)
+            {
+	      if (!
+		  (AXIS2_STRCMP
+		   ( ns->name, att_prefix)))
+		return AXIS2_STRDUP (ns->uri, environment);
+            }
+        }
+    }
+  return 0;
+}
+
+AXIS2_EXTERN  guththila_char_t * AXIS2_CALL
+guththila_get_encoding(axis2_env_t *environment,
+		       guththila_t *parser)
+{
+  /* parser will find character encoding base on Byte Order Mark
+     (BOM). */
+  switch (parser->unicode_state)
+    {
+    case None:
+      return "UTF-8";
+    case BE:
+      return "UTF-16";
+    case LE:
+      return "UTF-16";
+    default:
+      return (guththila_char_t *) GUTHTHILA_ERROR_INVALID_ENCODING_DECLARATION;
+    };
+}
+=======
 /*
  *   Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -1461,3 +2926,4 @@
             return (guththila_char_t *) GUTHTHILA_ERROR_INVALID_ENCODING_DECLARATION;
     };
 }
+>>>>>>> .r447787



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