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 sa...@apache.org on 2005/10/24 10:17:17 UTC

svn commit: r327989 [1/4] - /webservices/axis2/trunk/c/modules/xml/guththila/src/

Author: samisa
Date: Mon Oct 24 01:15:14 2005
New Revision: 327989

URL: http://svn.apache.org/viewcvs?rev=327989&view=rev
Log:
droped the apr and added environment allocator etc. applied patch supplied by nandika

Added:
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_allocator.c   (with props)
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_allocator.h   (with props)
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_array.c   (with props)
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_array.h   (with props)
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_defines.h   (with props)
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_environment.c   (with props)
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_environment.h   (with props)
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_error.c   (with props)
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_error.h   (with props)
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_hash.c   (with props)
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_hash.h   (with props)
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_log.c   (with props)
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_log.h   (with props)
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_stream.c   (with props)
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_stream.h   (with props)
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_string.c   (with props)
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_string.h   (with props)
Modified:
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_buffer.c
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_buffer.h
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_main.c
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_namespace.h
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_reader.c
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_reader.h
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_stack.c
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_stack.h
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_token.c
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_token.h
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_unicode.c
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_unicode.h
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_xml_pull_parser.c
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_xml_pull_parser.h
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_xml_stream_writer.c
    webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_xml_stream_writer.h

Added: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_allocator.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_allocator.c?rev=327989&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_allocator.c (added)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_allocator.c Mon Oct 24 01:15:14 2005
@@ -0,0 +1,40 @@
+/*
+ * 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_allocator.h>
+#include <stdlib.h>
+#include <string.h>
+
+guththila_allocator_t *guththila_allocator_init(
+                guththila_allocator_t *allocator)
+{
+    if(allocator)
+        return allocator;
+        
+    else
+    {
+        allocator = (guththila_allocator_t*)malloc(sizeof(guththila_allocator_t));
+        if(allocator)
+        {
+            allocator->guththila_allocator_malloc = malloc;
+            allocator->guththila_allocator_realloc = realloc;
+            allocator->guththila_allocator_free = free;
+            allocator->guththila_allocator_calloc = calloc;
+            return allocator;
+        }
+     }
+    return NULL;
+}

Propchange: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_allocator.c
------------------------------------------------------------------------------
    svn:executable = *

Added: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_allocator.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_allocator.h?rev=327989&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_allocator.h (added)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_allocator.h Mon Oct 24 01:15:14 2005
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+#ifndef GUTHTHILA_ALLOCATOR_H
+#define GUTHTHILA_ALLOCATOR_H
+
+#include <guththila_defines.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef struct guththila_allocator
+{
+    void *(*guththila_allocator_malloc)(size_t size);
+    void *(*guththila_allocator_realloc)(void *ptr,size_t size);
+    void (*guththila_allocator_free)(void *ptr);
+    void *(*guththila_allocator_calloc)(size_t nelem, size_t elsize);
+}guththila_allocator_t;
+
+/**
+*   if the parsed allocator is null a default allocator is created
+*   otherwise the parsed allocator is returned. If there isn't enough 
+*   memory for allocation NULL is returned.
+*   @param allocator user defined allcator
+*/
+
+guththila_allocator_t *
+    guththila_allocator_init(guththila_allocator_t *allocator);
+    
+#define guththila_malloc(allocator, size) ((allocator)->guththila_allocator_malloc(size))
+#define guththila_realloc(allocator, ptr, size) ((allocator)->guththila_allocator_realloc(ptr, size))
+#define guththila_free(allocator, ptr) ((allocator)->guththila_allocator_free(ptr))
+#define guththila_calloc(allocator,size1,size2) ((allocator)->guththila_allocator_calloc((size1),(size2)));
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GUTHTHILA_ALLOCATOR_H */

Propchange: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_allocator.h
------------------------------------------------------------------------------
    svn:executable = *

Added: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_array.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_array.c?rev=327989&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_array.c (added)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_array.c Mon Oct 24 01:15:14 2005
@@ -0,0 +1,1119 @@
+/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include "guththila_array.h"
+
+/*****************************************************************
+ * This file contains guththila_array and guththila_table_t functions only.
+ */
+
+/*****************************************************************
+ *
+ * The 'array' functions...
+ */
+
+static void make_array_core(guththila_array_header_t *res, guththila_environment_t *environment,
+			    int nelts, int elt_size, int clear)
+{
+    /*
+     * Assure sanity if someone asks for
+     * array of zero elts.
+     */
+    if (nelts < 1) {
+        nelts = 1;
+    }
+
+    if (clear) {
+        res->elts = guththila_malloc(environment->allocator, nelts * elt_size);
+    }
+    else {
+        res->elts = guththila_malloc(environment->allocator, nelts * elt_size);
+    }
+
+    res->environment = environment;
+    res->elt_size = elt_size;
+    res->nelts = 0;		/* No active elements yet... */
+    res->nalloc = nelts;	/* ...but this many allocated */
+}
+
+int guththila_is_empty_array(const guththila_array_header_t *a)
+{
+    return ((a == NULL) || (a->nelts == 0));
+}
+
+guththila_array_header_t * guththila_array_make(guththila_environment_t *environment,
+						int nelts, int elt_size)
+{
+    guththila_array_header_t *res;
+
+    res = (guththila_array_header_t *) guththila_malloc(environment->allocator, sizeof(guththila_array_header_t));
+    make_array_core(res, environment, nelts, elt_size, 1);
+    return res;
+}
+
+void * guththila_array_pop(guththila_array_header_t *arr)
+{
+    if (guththila_is_empty_array(arr)) {
+        return NULL;
+    }
+   
+    return arr->elts + (arr->elt_size * (--arr->nelts));
+}
+
+void * guththila_array_push(guththila_array_header_t *arr)
+{
+    if (arr->nelts == arr->nalloc) {
+        int new_size = (arr->nalloc <= 0) ? 1 : arr->nalloc * 2;
+        guththila_char_t *new_data;
+
+        new_data = guththila_malloc(arr->environment->allocator, arr->elt_size * new_size);
+
+        memcpy(new_data, arr->elts, arr->nalloc * arr->elt_size);
+        memset(new_data + arr->nalloc * arr->elt_size, 0,
+               arr->elt_size * (new_size - arr->nalloc));
+        arr->elts = new_data;
+        arr->nalloc = new_size;
+    }
+
+    ++arr->nelts;
+    return arr->elts + (arr->elt_size * (arr->nelts - 1));
+}
+
+static void *guththila_array_push_noclear(guththila_array_header_t *arr)
+{
+    if (arr->nelts == arr->nalloc) {
+        int new_size = (arr->nalloc <= 0) ? 1 : arr->nalloc * 2;
+        guththila_char_t *new_data;
+
+        new_data = guththila_malloc(arr->environment->allocator, arr->elt_size * new_size);
+
+        memcpy(new_data, arr->elts, arr->nalloc * arr->elt_size);
+        arr->elts = new_data;
+        arr->nalloc = new_size;
+    }
+
+    ++arr->nelts;
+    return arr->elts + (arr->elt_size * (arr->nelts - 1));
+}
+
+void guththila_array_cat(guththila_array_header_t *dst,
+			       const guththila_array_header_t *src)
+{
+    int elt_size = dst->elt_size;
+
+    if (dst->nelts + src->nelts > dst->nalloc) {
+	int new_size = (dst->nalloc <= 0) ? 1 : dst->nalloc * 2;
+	guththila_char_t *new_data;
+
+	while (dst->nelts + src->nelts > new_size) {
+	    new_size *= 2;
+	}
+
+	new_data = guththila_malloc(dst->environment->allocator, elt_size * new_size);
+	memcpy(new_data, dst->elts, dst->nalloc * elt_size);
+
+	dst->elts = new_data;
+	dst->nalloc = new_size;
+    }
+
+    memcpy(dst->elts + dst->nelts * elt_size, src->elts,
+	   elt_size * src->nelts);
+    dst->nelts += src->nelts;
+}
+
+guththila_array_header_t * guththila_array_copy(guththila_environment_t *environment,
+						const guththila_array_header_t *arr)
+{
+    guththila_array_header_t *res =
+        (guththila_array_header_t *) guththila_malloc(environment->allocator, sizeof(guththila_array_header_t));
+    make_array_core(res,environment, arr->nalloc, arr->elt_size, 0);
+
+    memcpy(res->elts, arr->elts, arr->elt_size * arr->nelts);
+    res->nelts = arr->nelts;
+    memset(res->elts + res->elt_size * res->nelts, 0,
+           res->elt_size * (res->nalloc - res->nelts));
+    return res;
+}
+
+/* This cute function copies the array header *only*, but arranges
+ * for the data section to be copied on the first push or arraycat.
+ * It's useful when the elements of the array being copied are
+ * read only, but new stuff *might* get added on the end; we have the
+ * overhead of the full copy only where it is really needed.
+ */
+
+static  void copy_array_hdr_core(guththila_array_header_t *res,
+					   const guththila_array_header_t *arr)
+{
+    res->elts = arr->elts;
+    res->elt_size = arr->elt_size;
+    res->nelts = arr->nelts;
+    res->nalloc = arr->nelts;	/* Force overflow on push */
+}
+
+guththila_array_header_t *
+    guththila_array_copy_hdr(guththila_environment_t *environment,
+		       const guththila_array_header_t *arr)
+{
+    guththila_array_header_t *res;
+
+    res = (guththila_array_header_t *) guththila_malloc(environment->allocator, sizeof(guththila_array_header_t));
+    res->environment = environment;
+    copy_array_hdr_core(res, arr);
+    return res;
+}
+
+/* The above is used here to avoid consing multiple new array bodies... */
+
+guththila_array_header_t *
+    guththila_array_append(guththila_environment_t *environment,
+		      const guththila_array_header_t *first,
+		      const guththila_array_header_t *second)
+{
+    guththila_array_header_t *res = guththila_array_copy_hdr(environment, first);
+
+    guththila_array_cat(res, second);
+    return res;
+}
+
+/* guththila_array_pstrcat generates a new string containing
+ * the concatenated sequence of substrings referenced as elements within
+ * the array.  The string will be empty if all substrings are empty or null,
+ * or if there are no elements in the array.
+ * If sep is non-NUL, it will be inserted between elements as a separator.
+ */
+guththila_char_t * guththila_array_pstrcat(guththila_environment_t *environment,
+				     const guththila_array_header_t *arr,
+				     const guththila_char_t sep)
+{
+    guththila_char_t *cp, *res, **strpp;
+    guththila_ssize_t len;
+    int i;
+
+    if (arr->nelts <= 0 || arr->elts == NULL) {    /* Empty table? */
+        return (guththila_char_t *) guththila_malloc(environment->allocator, 1);
+    }
+
+    /* Pass one --- find length of required string */
+
+    len = 0;
+    for (i = 0, strpp = (guththila_char_t **) arr->elts; ; ++strpp) {
+        if (strpp && *strpp != NULL) {
+            len += guththila_strlen(environment->string,*strpp);
+        }
+        if (++i >= arr->nelts) {
+            break;
+	}
+        if (sep) {
+            ++len;
+	}
+    }
+
+    /* Allocate the required string */
+
+    res = (guththila_char_t *) guththila_malloc(environment->allocator, len + 1);
+    cp = res;
+
+    /* Pass two --- copy the argument strings into the result space */
+
+    for (i = 0, strpp = (guththila_char_t **) arr->elts; ; ++strpp) {
+        if (strpp && *strpp != NULL) {
+            len = guththila_strlen(environment->string,*strpp);
+            memcpy(cp, *strpp, len);
+            cp += len;
+        }
+        if (++i >= arr->nelts) {
+            break;
+	}
+        if (sep) {
+            *cp++ = sep;
+	}
+    }
+
+    *cp = '\0';
+
+    /* Return the result string */
+
+    return res;
+}
+
+
+/*****************************************************************
+ *
+ * The "table" functions.
+ */
+
+#if GUTHTHILA_CHARSET_EBCDIC
+#define CASE_MASK 0xbfbfbfbf
+#else
+#define CASE_MASK 0xdfdfdfdf
+#endif
+
+#define TABLE_HASH_SIZE 32
+#define TABLE_INDEX_MASK 0x1f
+#define TABLE_HASH(key)  (TABLE_INDEX_MASK & *(guththila_unsigned_char_t *)(key))
+#define TABLE_INDEX_IS_INITIALIZED(t, i) ((t)->index_initialized & (1 << (i)))
+#define TABLE_SET_INDEX_INITIALIZED(t, i) ((t)->index_initialized |= (1 << (i)))
+
+/* Compute the "checksum" for a key, consisting of the first
+ * 4 bytes, normalized for case-insensitivity and packed into
+ * an int...this checksum allows us to do a single integer
+ * comparison as a fast check to determine whether we can
+ * skip a strcasecmp
+ */
+#define COMPUTE_KEY_CHECKSUM(key, checksum)    \
+{                                              \
+    const guththila_char_t *k = (key);                     \
+    guththila_ssize_t c = (guththila_ssize_t)*k;         \
+    (checksum) = c;                            \
+    (checksum) <<= 8;                          \
+    if (c) {                                   \
+        c = (guththila_ssize_t)*++k;                \
+        checksum |= c;                         \
+    }                                          \
+    (checksum) <<= 8;                          \
+    if (c) {                                   \
+        c = (guththila_ssize_t)*++k;                \
+        checksum |= c;                         \
+    }                                          \
+    (checksum) <<= 8;                          \
+    if (c) {                                   \
+        c = (guththila_ssize_t)*++k;                \
+        checksum |= c;                         \
+    }                                          \
+    checksum &= CASE_MASK;                     \
+}
+
+/** The opaque string-content table type */
+struct guththila_table_t {
+    /* This has to be first to promote backwards compatibility with
+     * older modules which cast a guththila_table_t * to an guththila_array_header_t *...
+     * they should use the guththila_table_elts() function for most of the
+     * cases they do this for.
+     */
+    /** The underlying array for the table */
+    guththila_array_header_t a;
+#ifdef MAKE_TABLE_PROFILE
+    /** Who created the array. */
+    void *creator;
+#endif
+    /* An index to speed up table lookups.  The way this works is:
+     *   - Hash the key into the index:
+     *     - index_first[TABLE_HASH(key)] is the offset within
+     *       the table of the first entry with that key
+     *     - index_last[TABLE_HASH(key)] is the offset within
+     *       the table of the last entry with that key
+     *   - If (and only if) there is no entry in the table whose
+     *     key hashes to index element i, then the i'th bit
+     *     of index_initialized will be zero.  (Check this before
+     *     trying to use index_first[i] or index_last[i]!)
+     */
+    guththila_ssize_t index_initialized;
+    int index_first[TABLE_HASH_SIZE];
+    int index_last[TABLE_HASH_SIZE];
+};
+
+/*
+ * NOTICE: if you tweak this you should look at is_empty_table() 
+ * and table_elts() in alloc.h
+ */
+#ifdef MAKE_TABLE_PROFILE
+static guththila_table_entry_t *table_push(guththila_table_t *t)
+{
+    if (t->a.nelts == t->a.nalloc) {
+        return NULL;
+    }
+    return (guththila_table_entry_t *) guththila_array_push_noclear(&t->a);
+}
+#else /* MAKE_TABLE_PROFILE */
+#define table_push(t)	((guththila_table_entry_t *) guththila_array_push_noclear(&(t)->a))
+#endif /* MAKE_TABLE_PROFILE */
+
+const guththila_array_header_t * guththila_table_elts(const guththila_table_t *t)
+{
+    return (const guththila_array_header_t *)t;
+}
+
+int guththila_is_empty_table(const guththila_table_t *t)
+{
+    return ((t == NULL) || (t->a.nelts == 0));
+}
+
+guththila_table_t * guththila_table_make(guththila_environment_t *environment, int nelts)
+{
+    guththila_table_t *t = guththila_malloc(environment->allocator, sizeof(guththila_table_t));
+
+    make_array_core(&t->a,environment, nelts, sizeof(guththila_table_entry_t), 0);
+#ifdef MAKE_TABLE_PROFILE
+    t->creator = __builtin_return_address(0);
+#endif
+    t->index_initialized = 0;
+    return t;
+}
+
+guththila_table_t * guththila_table_copy(guththila_environment_t *environment, const guththila_table_t *t)
+{
+    guththila_table_t *new = guththila_malloc(environment->allocator, sizeof(guththila_table_t));
+
+
+    make_array_core(&new->a, environment, t->a.nalloc, sizeof(guththila_table_entry_t), 0);
+    memcpy(new->a.elts, t->a.elts, t->a.nelts * sizeof(guththila_table_entry_t));
+    new->a.nelts = t->a.nelts;
+    memcpy(new->index_first, t->index_first, sizeof(int) * TABLE_HASH_SIZE);
+    memcpy(new->index_last, t->index_last, sizeof(int) * TABLE_HASH_SIZE);
+    new->index_initialized = t->index_initialized;
+    return new;
+}
+
+static void table_reindex(guththila_table_t *t)
+{
+    int i;
+    int hash;
+    guththila_table_entry_t *next_elt = (guththila_table_entry_t *) t->a.elts;
+
+    t->index_initialized = 0;
+    for (i = 0; i < t->a.nelts; i++, next_elt++) {
+        hash = TABLE_HASH(next_elt->key);
+        t->index_last[hash] = i;
+        if (!TABLE_INDEX_IS_INITIALIZED(t, hash)) {
+            t->index_first[hash] = i;
+            TABLE_SET_INDEX_INITIALIZED(t, hash);
+        }
+    }
+}
+
+void guththila_table_clear(guththila_table_t *t)
+{
+    t->a.nelts = 0;
+    t->index_initialized = 0;
+}
+
+const guththila_char_t * guththila_table_get(const guththila_table_t *t, const guththila_char_t *key)
+{
+    guththila_table_entry_t *next_elt;
+    guththila_table_entry_t *end_elt;
+    guththila_ssize_t checksum;
+    int hash;
+
+    if (key == NULL) {
+	return NULL;
+    }
+
+    hash = TABLE_HASH(key);
+    if (!TABLE_INDEX_IS_INITIALIZED(t, hash)) {
+        return NULL;
+    }
+    COMPUTE_KEY_CHECKSUM(key, checksum);
+    next_elt = ((guththila_table_entry_t *) t->a.elts) + t->index_first[hash];;
+    end_elt = ((guththila_table_entry_t *) t->a.elts) + t->index_last[hash];
+
+    for (; next_elt <= end_elt; next_elt++) {
+	if ((checksum == next_elt->key_checksum) &&
+            !stricmp(next_elt->key, key)) {
+	    return next_elt->val;
+	}
+    }
+
+    return NULL;
+}
+
+void guththila_table_set(guththila_table_t *t, const guththila_char_t *key,
+                                const guththila_char_t *val)
+{
+    guththila_table_entry_t *next_elt;
+    guththila_table_entry_t *end_elt;
+    guththila_table_entry_t *table_end;
+    guththila_ssize_t checksum;
+    int hash;
+
+    COMPUTE_KEY_CHECKSUM(key, checksum);
+    hash = TABLE_HASH(key);
+    if (!TABLE_INDEX_IS_INITIALIZED(t, hash)) {
+        t->index_first[hash] = t->a.nelts;
+        TABLE_SET_INDEX_INITIALIZED(t, hash);
+        goto add_new_elt;
+    }
+    next_elt = ((guththila_table_entry_t *) t->a.elts) + t->index_first[hash];;
+    end_elt = ((guththila_table_entry_t *) t->a.elts) + t->index_last[hash];
+    table_end =((guththila_table_entry_t *) t->a.elts) + t->a.nelts;
+
+    for (; next_elt <= end_elt; next_elt++) {
+	if ((checksum == next_elt->key_checksum) &&
+            !stricmp(next_elt->key, key)) {
+
+            
+            /* Found an existing entry with the same key, so overwrite it */
+
+            int must_reindex = 0;
+            guththila_table_entry_t *dst_elt = NULL;
+
+            next_elt->val = guththila_strdup(t->a.environment->string, val);
+
+            /* Remove any other instances of this key */
+            for (next_elt++; next_elt <= end_elt; next_elt++) {
+                if ((checksum == next_elt->key_checksum) &&
+                    !stricmp(next_elt->key, key)) {
+                    t->a.nelts--;
+                    if (!dst_elt) {
+                        dst_elt = next_elt;
+                    }
+                }
+                else if (dst_elt) {
+                    *dst_elt++ = *next_elt;
+                    must_reindex = 1;
+                }
+            }
+
+            /* If we've removed anything, shift over the remainder
+             * of the table (note that the previous loop didn't
+             * run to the end of the table, just to the last match
+             * for the index)
+             */
+            if (dst_elt) {
+                for (; next_elt < table_end; next_elt++) {
+                    *dst_elt++ = *next_elt;
+                }
+                must_reindex = 1;
+            }
+            if (must_reindex) {
+                table_reindex(t);
+            }
+            return;
+        }
+    }
+
+add_new_elt:
+    t->index_last[hash] = t->a.nelts;
+    next_elt = (guththila_table_entry_t *) table_push(t);
+    next_elt->key = guththila_strdup(t->a.environment->string, key);
+    next_elt->val = guththila_strdup(t->a.environment->string, val);
+    next_elt->key_checksum = checksum;
+}
+
+void guththila_table_setn(guththila_table_t *t, const guththila_char_t *key,
+                                 const guththila_char_t *val)
+{
+    guththila_table_entry_t *next_elt;
+    guththila_table_entry_t *end_elt;
+    guththila_table_entry_t *table_end;
+    guththila_ssize_t checksum;
+    int hash;
+
+    COMPUTE_KEY_CHECKSUM(key, checksum);
+    hash = TABLE_HASH(key);
+    if (!TABLE_INDEX_IS_INITIALIZED(t, hash)) {
+        t->index_first[hash] = t->a.nelts;
+        TABLE_SET_INDEX_INITIALIZED(t, hash);
+        goto add_new_elt;
+    }
+    next_elt = ((guththila_table_entry_t *) t->a.elts) + t->index_first[hash];;
+    end_elt = ((guththila_table_entry_t *) t->a.elts) + t->index_last[hash];
+    table_end =((guththila_table_entry_t *) t->a.elts) + t->a.nelts;
+
+    for (; next_elt <= end_elt; next_elt++) {
+	if ((checksum == next_elt->key_checksum) &&
+            !stricmp(next_elt->key, key)) {
+
+            /* Found an existing entry with the same key, so overwrite it */
+
+            int must_reindex = 0;
+            guththila_table_entry_t *dst_elt = NULL;
+
+            next_elt->val = (guththila_char_t *)val;
+
+            /* Remove any other instances of this key */
+            for (next_elt++; next_elt <= end_elt; next_elt++) {
+                if ((checksum == next_elt->key_checksum) &&
+                    !stricmp(next_elt->key, key)) {
+                    t->a.nelts--;
+                    if (!dst_elt) {
+                        dst_elt = next_elt;
+                    }
+                }
+                else if (dst_elt) {
+                    *dst_elt++ = *next_elt;
+                    must_reindex = 1;
+                }
+            }
+
+            /* If we've removed anything, shift over the remainder
+             * of the table (note that the previous loop didn't
+             * run to the end of the table, just to the last match
+             * for the index)
+             */
+            if (dst_elt) {
+                for (; next_elt < table_end; next_elt++) {
+                    *dst_elt++ = *next_elt;
+                }
+                must_reindex = 1;
+            }
+            if (must_reindex) {
+                table_reindex(t);
+            }
+            return;
+        }
+    }
+
+add_new_elt:
+    t->index_last[hash] = t->a.nelts;
+    next_elt = (guththila_table_entry_t *) table_push(t);
+    next_elt->key = (guththila_char_t *)key;
+    next_elt->val = (guththila_char_t *)val;
+    next_elt->key_checksum = checksum;
+}
+
+void guththila_table_unset(guththila_table_t *t, const guththila_char_t *key)
+{
+    guththila_table_entry_t *next_elt;
+    guththila_table_entry_t *end_elt;
+    guththila_table_entry_t *dst_elt;
+    guththila_ssize_t checksum;
+    int hash;
+    int must_reindex;
+
+    hash = TABLE_HASH(key);
+    if (!TABLE_INDEX_IS_INITIALIZED(t, hash)) {
+        return;
+    }
+    COMPUTE_KEY_CHECKSUM(key, checksum);
+    next_elt = ((guththila_table_entry_t *) t->a.elts) + t->index_first[hash];
+    end_elt = ((guththila_table_entry_t *) t->a.elts) + t->index_last[hash];
+    must_reindex = 0;
+    for (; next_elt <= end_elt; next_elt++) {
+	if ((checksum == next_elt->key_checksum) &&
+            !stricmp(next_elt->key, key)) {
+
+            /* Found a match: remove this entry, plus any additional
+             * matches for the same key that might follow
+             */
+            guththila_table_entry_t *table_end = ((guththila_table_entry_t *) t->a.elts) +
+                t->a.nelts;
+            t->a.nelts--;
+            dst_elt = next_elt;
+            for (next_elt++; next_elt <= end_elt; next_elt++) {
+                if ((checksum == next_elt->key_checksum) &&
+                    !stricmp(next_elt->key, key)) {
+                    t->a.nelts--;
+                }
+                else {
+                    *dst_elt++ = *next_elt;
+                }
+            }
+
+            /* Shift over the remainder of the table (note that
+             * the previous loop didn't run to the end of the table,
+             * just to the last match for the index)
+             */
+            for (; next_elt < table_end; next_elt++) {
+                *dst_elt++ = *next_elt;
+            }
+            must_reindex = 1;
+            break;
+        }
+    }
+    if (must_reindex) {
+        table_reindex(t);
+    }
+}
+/*
+void guththila_table_merge(guththila_table_t *t, const guththila_char_t *key,
+				 const guththila_char_t *val)
+{
+    guththila_table_entry_t *next_elt;
+    guththila_table_entry_t *end_elt;
+    guththila_uint32_t checksum;
+    int hash;
+
+    COMPUTE_KEY_CHECKSUM(key, checksum);
+    hash = TABLE_HASH(key);
+    if (!TABLE_INDEX_IS_INITIALIZED(t, hash)) {
+        t->index_first[hash] = t->a.nelts;
+        TABLE_SET_INDEX_INITIALIZED(t, hash);
+        goto add_new_elt;
+    }
+    next_elt = ((guththila_table_entry_t *) t->a.elts) + t->index_first[hash];
+    end_elt = ((guththila_table_entry_t *) t->a.elts) + t->index_last[hash];
+
+    for (; next_elt <= end_elt; next_elt++) {
+	if ((checksum == next_elt->key_checksum) &&
+            !strcasecmp(next_elt->key, key)) {
+
+            /* Found an existing entry with the same key, so merge with it 
+	    next_elt->val = guththila_pstrcat(t->a.pool, next_elt->val, ", ",
+                                        val, NULL);
+            return;
+        }
+        
+    }
+
+add_new_elt:
+    t->index_last[hash] = t->a.nelts;
+    next_elt = (guththila_table_entry_t *) table_push(t);
+    next_elt->key = guththila_pstrdup(t->a.pool, key);
+    next_elt->val = guththila_pstrdup(t->a.pool, val);
+    next_elt->key_checksum = checksum;
+}
+
+void) guththila_table_mergen(guththila_table_t *t, const guththila_char_t *key,
+				  const guththila_char_t *val)
+{
+    guththila_table_entry_t *next_elt;
+    guththila_table_entry_t *end_elt;
+    guththila_uint32_t checksum;
+    int hash;
+
+#if GUTHTHILA_POOL_DEBUG
+    {
+	if (!guththila_pool_is_ancestor(guththila_pool_find(key), t->a.pool)) {
+	    fprintf(stderr, "guththila_table_mergen: key not in ancestor pool of t\n");
+	    abort();
+	}
+	if (!guththila_pool_is_ancestor(guththila_pool_find(val), t->a.pool)) {
+	    fprintf(stderr, "guththila_table_mergen: key not in ancestor pool of t\n");
+	    abort();
+	}
+    }
+#endif
+
+    COMPUTE_KEY_CHECKSUM(key, checksum);
+    hash = TABLE_HASH(key);
+    if (!TABLE_INDEX_IS_INITIALIZED(t, hash)) {
+        t->index_first[hash] = t->a.nelts;
+        TABLE_SET_INDEX_INITIALIZED(t, hash);
+        goto add_new_elt;
+    }
+    next_elt = ((guththila_table_entry_t *) t->a.elts) + t->index_first[hash];;
+    end_elt = ((guththila_table_entry_t *) t->a.elts) + t->index_last[hash];
+
+    for (; next_elt <= end_elt; next_elt++) {
+	if ((checksum == next_elt->key_checksum) &&
+            !strcasecmp(next_elt->key, key)) {
+
+            /* Found an existing entry with the same key, so merge with it 
+	    next_elt->val = guththila_pstrcat(t->a.pool, next_elt->val, ", ",
+                                        val, NULL);
+            return;
+        }
+    }
+
+add_new_elt:
+    t->index_last[hash] = t->a.nelts;
+    next_elt = (guththila_table_entry_t *) table_push(t);
+    next_elt->key = (guththila_char_t *)key;
+    next_elt->val = (guththila_char_t *)val;
+    next_elt->key_checksum = checksum;
+}
+*/
+void guththila_table_add(guththila_table_t *t, const guththila_char_t *key,
+			       const guththila_char_t *val)
+{
+    guththila_table_entry_t *elts;
+    guththila_ssize_t checksum;
+    int hash;
+
+    hash = TABLE_HASH(key);
+    t->index_last[hash] = t->a.nelts;
+    if (!TABLE_INDEX_IS_INITIALIZED(t, hash)) {
+        t->index_first[hash] = t->a.nelts;
+        TABLE_SET_INDEX_INITIALIZED(t, hash);
+    }
+    COMPUTE_KEY_CHECKSUM(key, checksum);
+    elts = (guththila_table_entry_t *) table_push(t);
+    elts->key = guththila_strdup(t->a.environment->string, key);
+    elts->val = guththila_strdup(t->a.environment->string, val);
+    elts->key_checksum = checksum;
+}
+
+void guththila_table_addn(guththila_table_t *t, const guththila_char_t *key,
+				const guththila_char_t *val)
+{
+    guththila_table_entry_t *elts;
+    guththila_ssize_t checksum;
+    int hash;
+
+
+
+    hash = TABLE_HASH(key);
+    t->index_last[hash] = t->a.nelts;
+    if (!TABLE_INDEX_IS_INITIALIZED(t, hash)) {
+        t->index_first[hash] = t->a.nelts;
+        TABLE_SET_INDEX_INITIALIZED(t, hash);
+    }
+    COMPUTE_KEY_CHECKSUM(key, checksum);
+    elts = (guththila_table_entry_t *) table_push(t);
+    elts->key = (guththila_char_t *)key;
+    elts->val = (guththila_char_t *)val;
+    elts->key_checksum = checksum;
+}
+
+guththila_table_t * guththila_table_overlay(guththila_environment_t *environment,
+					     const guththila_table_t *overlay,
+					     const guththila_table_t *base)
+{
+    guththila_table_t *res;
+
+
+    res = guththila_malloc(environment->allocator, sizeof(guththila_table_t));
+    /* behave like append_arrays */
+    res->a.environment = environment;
+    copy_array_hdr_core(&res->a, &overlay->a);
+    guththila_array_cat(&res->a, &base->a);
+    table_reindex(res);
+    return res;
+}
+
+/* And now for something completely abstract ...
+
+ * For each key value given as a vararg:
+ *   run the function pointed to as
+ *     int comp(void *r, char *key, char *value);
+ *   on each valid key-value pair in the guththila_table_t t that matches the vararg key,
+ *   or once for every valid key-value pair if the vararg list is empty,
+ *   until the function returns false (0) or we finish the table.
+ *
+ * Note that we restart the traversal for each vararg, which means that
+ * duplicate varargs will result in multiple executions of the function
+ * for each matching key.  Note also that if the vararg list is empty,
+ * only one traversal will be made and will cut short if comp returns 0.
+ *
+ * Note that the table_get and table_merge functions assume that each key in
+ * the guththila_table_t is unique (i.e., no multiple entries with the same key).  This
+ * function does not make that assumption, since it (unfortunately) isn't
+ * true for some of Apache's tables.
+ *
+ * Note that rec is simply passed-on to the comp function, so that the
+ * caller can pass additional info for the task.
+ *
+ * ADDENDUM for guththila_table_vdo():
+ * 
+ * The caching api will allow a user to walk the header values:
+ *
+ * guththila_status_t guththila_cache_el_header_walk(guththila_cache_el *el, 
+ *    int (*comp)(void *, const char *, const char *), void *rec, ...);
+ *
+ * So it can be ..., however from there I use a  callback that use a va_list:
+ *
+ * guththila_status_t (*cache_el_header_walk)(guththila_cache_el *el, 
+ *    int (*comp)(void *, const char *, const char *), void *rec, va_list);
+ *
+ * To pass those ...'s on down to the actual module that will handle walking
+ * their headers, in the file case this is actually just an guththila_table - and
+ * rather than reimplementing guththila_table_do (which IMHO would be bad) I just
+ * called it with the va_list. For mod_shmem_cache I don't need it since I
+ * can't use guththila_table's, but mod_file_cache should (though a good hash would
+ * be better, but that's a different issue :). 
+ *
+ * So to make mod_file_cache easier to maintain, it's a good thing
+ */
+int guththila_table_do(guththila_table_do_callback_fn_t *comp,
+                                     void *rec, const guththila_table_t *t, ...)
+{
+    int rv;
+
+    va_list vp;
+    va_start(vp, t);
+    rv = guththila_table_vdo(comp, rec, t, vp);
+    va_end(vp);
+
+    return rv;
+}
+
+int guththila_table_vdo(guththila_table_do_callback_fn_t *comp,
+                               void *rec, const guththila_table_t *t, va_list vp)
+{
+    guththila_char_t *argp;
+    guththila_table_entry_t *elts = (guththila_table_entry_t *) t->a.elts;
+    int vdorv = 1;
+
+    argp = va_arg(vp, guththila_char_t *);
+    do {
+        int rv = 1, i;
+        if (argp) {
+            /* Scan for entries that match the next key */
+            int hash = TABLE_HASH(argp);
+            if (TABLE_INDEX_IS_INITIALIZED(t, hash)) {
+                guththila_ssize_t checksum;
+                COMPUTE_KEY_CHECKSUM(argp, checksum);
+                for (i = t->index_first[hash];
+                     rv && (i <= t->index_last[hash]); ++i) {
+                    if (elts[i].key && (checksum == elts[i].key_checksum) &&
+                                        !stricmp(elts[i].key, argp)) {
+                        rv = (*comp) (rec, elts[i].key, elts[i].val);
+                    }
+                }
+            }
+        }
+        else {
+            /* Scan the entire table */
+            for (i = 0; rv && (i < t->a.nelts); ++i) {
+                if (elts[i].key) {
+                    rv = (*comp) (rec, elts[i].key, elts[i].val);
+                }
+            }
+        }
+        if (rv == 0) {
+            vdorv = 0;
+        }
+    } while (argp && ((argp = va_arg(vp, guththila_char_t *)) != NULL));
+
+    return vdorv;
+}
+
+static guththila_table_entry_t **table_mergesort(guththila_environment_t *environment,
+                                           guththila_table_entry_t **values, int n)
+{
+    /* Bottom-up mergesort, based on design in Sedgewick's "Algorithms
+     * in C," chapter 8
+     */
+    guththila_table_entry_t **values_tmp =
+        (guththila_table_entry_t **)guththila_malloc(environment->allocator, n * sizeof(guththila_table_entry_t*));
+    guththila_ssize_t i;
+    int blocksize;
+
+    /* First pass: sort pairs of elements (blocksize=1) */
+    for (i = 0; i + 1 < n; i += 2) {
+        if (stricmp(values[i]->key, values[i + 1]->key) > 0) {
+            guththila_table_entry_t *swap = values[i];
+            values[i] = values[i + 1];
+            values[i + 1] = swap;
+        }
+    }
+
+    /* Merge successively larger blocks */
+    blocksize = 2;
+    while (blocksize < n) {
+        guththila_table_entry_t **dst = values_tmp;
+        int next_start;
+        guththila_table_entry_t **swap;
+
+        /* Merge consecutive pairs blocks of the next blocksize.
+         * Within a block, elements are in sorted order due to
+         * the previous iteration.
+         */
+        for (next_start = 0; next_start + blocksize < n;
+             next_start += (blocksize + blocksize)) {
+
+            int block1_start = next_start;
+            int block2_start = block1_start + blocksize;
+            int block1_end = block2_start;
+            int block2_end = block2_start + blocksize;
+            if (block2_end > n) {
+                /* The last block may be smaller than blocksize */
+                block2_end = n;
+            }
+            for (;;) {
+
+                /* Merge the next two blocks:
+                 * Pick the smaller of the next element from
+                 * block 1 and the next element from block 2.
+                 * Once either of the blocks is emptied, copy
+                 * over all the remaining elements from the
+                 * other block
+                 */
+                if (block1_start == block1_end) {
+                    for (; block2_start < block2_end; block2_start++) {
+                        *dst++ = values[block2_start];
+                    }
+                    break;
+                }
+                else if (block2_start == block2_end) {
+                    for (; block1_start < block1_end; block1_start++) {
+                        *dst++ = values[block1_start];
+                    }
+                    break;
+                }
+                if (stricmp(values[block1_start]->key,
+                               values[block2_start]->key) > 0) {
+                    *dst++ = values[block2_start++];
+                }
+                else {
+                    *dst++ = values[block1_start++];
+                }
+            }
+        }
+
+        /* If n is not a multiple of 2*blocksize, some elements
+         * will be left over at the end of the array.
+         */
+        for (i = dst - values_tmp; i < n; i++) {
+            values_tmp[i] = values[i];
+        }
+
+        /* The output array of this pass becomes the input
+         * array of the next pass, and vice versa
+         */
+        swap = values_tmp;
+        values_tmp = values;
+        values = swap;
+
+        blocksize += blocksize;
+    }
+
+    return values;
+}
+
+void guththila_table_compress(guththila_table_t *t, unsigned flags)
+{
+    guththila_table_entry_t **sort_array;
+    guththila_table_entry_t **sort_next;
+    guththila_table_entry_t **sort_end;
+    guththila_table_entry_t *table_next;
+    guththila_table_entry_t **last;
+    int i;
+    int dups_found;
+
+    if (t->a.nelts <= 1) {
+        return;
+    }
+
+    /* Copy pointers to all the table elements into an
+     * array and sort to allow for easy detection of
+     * duplicate keys
+     */
+    sort_array = (guththila_table_entry_t **)
+        guththila_malloc(t->a.environment->allocator, t->a.nelts * sizeof(guththila_table_entry_t*));
+    sort_next = sort_array;
+    table_next = (guththila_table_entry_t *)t->a.elts;
+    i = t->a.nelts;
+    do {
+        *sort_next++ = table_next++;
+    } while (--i);
+
+    /* Note: the merge is done with mergesort instead of quicksort
+     * because mergesort is a stable sort and runs in n*log(n)
+     * time regardless of its inputs (quicksort is quadratic in
+     * the worst case)
+     */
+    sort_array = table_mergesort(t->a.environment, sort_array, t->a.nelts);
+
+    /* Process any duplicate keys */
+    dups_found = 0;
+    sort_next = sort_array;
+    sort_end = sort_array + t->a.nelts;
+    last = sort_next++;
+    while (sort_next < sort_end) {
+        if (((*sort_next)->key_checksum == (*last)->key_checksum) &&
+            !stricmp((*sort_next)->key, (*last)->key)) {
+            guththila_table_entry_t **dup_last = sort_next + 1;
+            dups_found = 1;
+            while ((dup_last < sort_end) &&
+                   ((*dup_last)->key_checksum == (*last)->key_checksum) &&
+                   !stricmp((*dup_last)->key, (*last)->key)) {
+                dup_last++;
+            }
+            dup_last--; /* Elements from last through dup_last, inclusive,
+                         * all have the same key
+                         */
+            if (flags == GUTHTHILA_OVERLAP_TABLES_MERGE) {
+                guththila_ssize_t len = 0;
+                guththila_table_entry_t **next = last;
+                guththila_char_t *new_val;
+                guththila_char_t *val_dst;
+                do {
+                    len += strlen((*next)->val);
+                    len += 2; /* for ", " or trailing null */
+                } while (++next <= dup_last);
+                new_val = (guththila_char_t *)guththila_malloc(t->a.environment->allocator, len);
+                val_dst = new_val;
+                next = last;
+                for (;;) {
+                    strcpy(val_dst, (*next)->val);
+                    val_dst += strlen((*next)->val);
+                    next++;
+                    if (next > dup_last) {
+                        *val_dst = 0;
+                        break;
+                    }
+                    else {
+                        *val_dst++ = ',';
+                        *val_dst++ = ' ';
+                    }
+                }
+                (*last)->val = new_val;
+            }
+            else { /* overwrite */
+                (*last)->val = (*dup_last)->val;
+            }
+            do {
+                (*sort_next)->key = NULL;
+            } while (++sort_next <= dup_last);
+        }
+        else {
+            last = sort_next++;
+        }
+    }
+
+    /* Shift elements to the left to fill holes left by removing duplicates */
+    if (dups_found) {
+        guththila_table_entry_t *src = (guththila_table_entry_t *)t->a.elts;
+        guththila_table_entry_t *dst = (guththila_table_entry_t *)t->a.elts;
+        guththila_table_entry_t *last_elt = src + t->a.nelts;
+        do {
+            if (src->key) {
+                *dst++ = *src;
+            }
+        } while (++src < last_elt);
+        t->a.nelts -= (int)(last_elt - dst);
+    }
+
+    table_reindex(t);
+}
+
+static void guththila_table_cat(guththila_table_t *t, const guththila_table_t *s)
+{
+    const int n = t->a.nelts;
+    register int idx;
+
+    guththila_array_cat(&t->a,&s->a);
+
+    if (n == 0) {
+        memcpy(t->index_first,s->index_first,sizeof(int) * TABLE_HASH_SIZE);
+        memcpy(t->index_last, s->index_last, sizeof(int) * TABLE_HASH_SIZE);
+        t->index_initialized = s->index_initialized;
+        return;
+    }
+
+    for (idx = 0; idx < TABLE_HASH_SIZE; ++idx) {
+        if (TABLE_INDEX_IS_INITIALIZED(s, idx)) {
+            t->index_last[idx] = s->index_last[idx] + n;
+            if (!TABLE_INDEX_IS_INITIALIZED(t, idx)) {
+                t->index_first[idx] = s->index_first[idx] + n;
+            }
+        }
+    }
+
+    t->index_initialized |= s->index_initialized;
+}
+
+void guththila_table_overlap(guththila_table_t *a, const guththila_table_t *b,
+				    unsigned flags)
+{
+    if (a->a.nelts + b->a.nelts == 0) {
+        return;
+    }
+
+
+
+    guththila_table_cat(a, b);
+
+    guththila_table_compress(a, flags);
+}

Propchange: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_array.c
------------------------------------------------------------------------------
    svn:executable = *

Added: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_array.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_array.h?rev=327989&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_array.h (added)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_array.h Mon Oct 24 01:15:14 2005
@@ -0,0 +1,422 @@
+/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * 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.
+ */
+
+#ifndef GUTHTHILA_TABLES_H
+#define GUTHTHILA_TABLES_H
+
+/**
+ * @file guththila_tables.h
+ * @brief GUTHTHILA  array and table 
+ */
+
+#include "guththila_defines.h"
+#include "guththila_environment.h"
+#include "guththila_defines.h"
+
+
+#include <stdarg.h>     /* for va_list */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @defgroup guththila_array (stack)  and table functions
+ * @ingroup GUTHTHILA 
+ * Tables are used to store entirely opaque structures 
+ * for applications, while Arrays are usually used to
+ * deal with string lists.
+ * @{
+ */
+
+/** the table abstract data type */
+typedef struct guththila_table_t guththila_table_t;
+
+/** @see guththila_array_header_t */
+typedef struct guththila_array_header_t guththila_array_header_t;
+
+/** An opaque array type */
+struct guththila_array_header_t {
+    /** The environment pointer of guththila */
+    guththila_environment_t *environment;
+    /** The amount of memory allocated for each element of the array */
+    int elt_size;
+    /** The number of active elements in the array */
+    int nelts;
+    /** The number of elements allocated in the array */
+    int nalloc;
+    /** The elements in the array */
+    guththila_char_t *elts;
+};
+
+/**
+ * The (opaque) structure for string-content tables.
+ */
+typedef struct guththila_table_entry_t guththila_table_entry_t;
+
+/** The type for each entry in a string-content table */
+struct guththila_table_entry_t {
+    /** The key for the current table entry */
+    guththila_char_t *key;          
+   
+   /** The value for the current table entry */
+    guththila_char_t *val;
+
+    /** A checksum for the key, for use by the guththila_table internals */
+    guththila_ssize_t key_checksum;
+};
+
+/**
+ * Get the elements from a table
+ * @param t The table
+ * @return An array containing the contents of the table
+ */
+const guththila_array_header_t * guththila_table_elts(const guththila_table_t *t);
+
+/**
+ * Determine if the table is empty
+ * @param t The table to check
+ * @return True if empty, False otherwise
+ */
+int guththila_is_empty_table(const guththila_table_t *t);
+
+/**
+ * Determine if the array is empty
+ * @param a The array to check
+ * @return True if empty, False otherwise
+ */
+int guththila_is_empty_array(const guththila_array_header_t *a);
+
+/**
+ * Create an array
+ * @param environment guththila_environment pointer
+ * @param nelts the number of elements in the initial array
+ * @param elt_size The size of each element in the array.
+ * @return The new array
+ */
+guththila_array_header_t * guththila_array_make(guththila_environment_t *environment,
+                                                 int nelts, int elt_size);
+
+/**
+ * Add a new element to an array (as a first-in, last-out stack)
+ * @param arr The array to add an element to.
+ * @return Location for the new element in the array.
+ * @remark If there are no free spots in the array, then this function will
+ *         allocate new space for the new element.
+ */
+void * guththila_array_push(guththila_array_header_t *arr);
+
+/**
+ * Remove an element from an array (as a first-in, last-out stack)
+ * @param arr The array to remove an element from.
+ * @return Location of the element in the array.
+ * @remark If there are no elements in the array, NULL is returned.
+ */
+void * guththila_array_pop(guththila_array_header_t *arr);
+
+/**
+ * Concatenate two arrays together
+ * @param dst The destination array, and the one to go first in the combined 
+ *            array
+ * @param src The source array to add to the destination array
+ */
+void guththila_array_cat(guththila_array_header_t *dst,
+			        const guththila_array_header_t *src);
+
+/**
+ * Copy the entire array
+ * @param environment guththila_environment
+ * @param arr The array to copy
+ * @return An exact copy of the array passed in
+ * @remark The alternate guththila_array_copy_hdr copies only the header, and arranges 
+ *         for the elements to be copied if (and only if) the code subsequently
+ *         does a push or arraycat.
+ */
+guththila_array_header_t * guththila_array_copy(guththila_environment_t *environment,
+                                      const guththila_array_header_t *arr);
+/**
+ * Copy the headers of the array, and arrange for the elements to be copied if
+ * and only if the code subsequently does a push or arraycat.
+ * @param environment guththila_environment
+ * @param arr The array to copy
+ * @return An exact copy of the array passed in
+ * @remark The alternate guththila_array_copy copies the *entire* array.
+ */
+guththila_array_header_t * guththila_array_copy_hdr(guththila_environment_t *environment,
+                                      const guththila_array_header_t *arr);
+
+/**
+ * Append one array to the end of another, creating a new array in the process.
+ * @param environment guththila_envioronment
+ * @param first The array to put first in the new array.
+ * @param second The array to put second in the new array.
+ * @return A new array containing the data from the two arrays passed in.
+*/
+guththila_array_header_t * guththila_array_append(guththila_environment_t *environment,
+                                      const guththila_array_header_t *first,
+                                      const guththila_array_header_t *second);
+
+/**
+ * Generates a new string containing the concatenated 
+ * sequence of substrings referenced as elements within the array.  The string 
+ * will be empty if all substrings are empty or null, or if there are no 
+ * elements in the array.  If sep is non-NUL, it will be inserted between 
+ * elements as a separator.
+ * @param environment guththila_environment
+ * @param arr The array to generate the string from
+ * @param sep The separator to use
+ * @return A string containing all of the data in the array.
+ */
+guththila_char_t * guththila_array_pstrcat(guththila_environment_t *p,
+				      const guththila_array_header_t *arr,
+				      const guththila_char_t sep);
+
+/**
+ * Make a new table
+ * @param environment guththila_environment
+ * @param nelts The number of elements in the initial table.
+ * @return The new table.
+ * @warning This table can only store text data
+ */
+guththila_table_t * guththila_table_make(guththila_environment_t *environment, int nelts);
+
+/**
+ * Create a new table and copy another table into it
+ * @param environment guththila_environment
+ * @param t The table to copy
+ * @return A copy of the table passed in
+ */
+guththila_table_t * guththila_table_copy(guththila_environment_t *environment,
+                                          const guththila_table_t *t);
+
+/**
+ * Delete all of the elements from a table
+ * @param t The table to clear
+ */
+void guththila_table_clear(guththila_table_t *t);
+
+/**
+ * Get the value associated with a given key from the table.  After this call,
+ * The data is still in the table
+ * @param t The table to search for the key
+ * @param key The key to search for
+ * @return The value associated with the key, or NULL if the key does not exist. 
+ */
+const guththila_char_t * guththila_table_get(const guththila_table_t *t, const guththila_char_t *key);
+
+/**
+ * Add a key/value pair to a table, if another element already exists with the
+ * same key, this will over-write the old data.
+ * @param t The table to add the data to.
+ * @param key The key fo use
+ * @param val The value to add
+ * @remark When adding data, this function makes a copy of both the key and the
+ *         value.
+ */
+void guththila_table_set(guththila_table_t *t, const guththila_char_t *key,
+                                const guththila_char_t *val);
+
+/**
+ * Add a key/value pair to a table, if another element already exists with the
+ * same key, this will over-write the old data.
+ * @param t The table to add the data to.
+ * @param key The key to use
+ * @param val The value to add
+ * @warning When adding data, this function does not make a copy of the key or 
+ *          the value, so care should be taken to ensure that the values will 
+ *          not change after they have been added..
+ */
+void guththila_table_setn(guththila_table_t *t, const guththila_char_t *key,
+                                 const guththila_char_t *val);
+
+/**
+ * Remove data from the table
+ * @param t The table to remove data from
+ * @param key The key of the data being removed
+ */
+void guththila_table_unset(guththila_table_t *t, const guththila_char_t *key);
+
+/**
+ * Add data to a table by merging the value with data that has already been 
+ * stored
+ * @param t The table to search for the data
+ * @param key The key to merge data for
+ * @param val The data to add
+ * @remark If the key is not found, then this function acts like guththila_table_add
+ */
+void guththila_table_merge(guththila_table_t *t, const guththila_char_t *key,
+                                  const guththila_char_t *val);
+
+/**
+ * Add data to a table by merging the value with data that has already been 
+ * stored
+ * @param t The table to search for the data
+ * @param key The key to merge data for
+ * @param val The data to add
+ * @remark If the key is not found, then this function acts like guththila_table_addn
+ */
+void guththila_table_mergen(guththila_table_t *t, const guththila_char_t *key,
+                                   const guththila_char_t *val);
+
+/**
+ * Add data to a table, regardless of whether there is another element with the
+ * same key.
+ * @param t The table to add to
+ * @param key The key to use
+ * @param val The value to add.
+ * @remark When adding data, this function makes a copy of both the key and the
+ *         value.
+ */
+void guththila_table_add(guththila_table_t *t, const guththila_char_t *key,
+                                const guththila_char_t *val);
+
+/**
+ * Add data to a table, regardless of whether there is another element with the
+ * same key.
+ * @param t The table to add to
+ * @param key The key to use
+ * @param val The value to add.
+ * @remark When adding data, this function does not make a copy of the key or the
+ *         value, so care should be taken to ensure that the values will not 
+ *         change after they have been added..
+ */
+void guththila_table_addn(guththila_table_t *t, const guththila_char_t *key,
+                                 const guththila_char_t *val);
+
+/**
+ * Merge two tables into one new table
+ * @param environment guththila_environment
+ * @param overlay The first table to put in the new table
+ * @param base The table to add at the end of the new table
+ * @return A new table containing all of the data from the two passed in
+ */
+guththila_table_t * guththila_table_overlay(guththila_environment_t *environment,
+                                             const guththila_table_t *overlay,
+                                             const guththila_table_t *base);
+
+/**
+ * Declaration prototype for the iterator callback function of guththila_table_do()
+ * and guththila_table_vdo().
+ * @param rec The data passed as the first argument to guththila_table_[v]do()
+ * @param key The key from this iteration of the table
+ * @param value The value from this iteration of the table
+ * @remark Iteration continues while this callback function returns non-zero.
+ * To export the callback function for guththila_table_[v]do() it must be declared 
+ * in the _NONSTD convention.
+ */
+typedef int (guththila_table_do_callback_fn_t)(void *rec, const guththila_char_t *key, 
+                                                    const guththila_char_t *value);
+
+/** 
+ * Iterate over a table running the provided function once for every
+ * element in the table.  If there is data passed in as a vararg, then the 
+ * function is only run on those elements whose key matches something in 
+ * the vararg.  If the vararg is NULL, then every element is run through the
+ * function.  Iteration continues while the function returns non-zero.
+ * @param comp The function to run
+ * @param rec The data to pass as the first argument to the function
+ * @param t The table to iterate over
+ * @param ... The vararg.  If this is NULL, then all elements in the table are
+ *            run through the function, otherwise only those whose key matches
+ *            are run.
+ * @return FALSE if one of the comp() iterations returned zero; TRUE if all
+ *            iterations returned non-zero
+ * @see guththila_table_do_callback_fn_t
+ */
+int guththila_table_do(guththila_table_do_callback_fn_t *comp,
+                                     void *rec, const guththila_table_t *t, ...);
+
+/** 
+ * Iterate over a table running the provided function once for every
+ * element in the table.  If there is data passed in as a vararg, then the 
+ * function is only run on those element's whose key matches something in 
+ * the vararg.  If the vararg is NULL, then every element is run through the
+ * function.  Iteration continues while the function returns non-zero.
+ * @param comp The function to run
+ * @param rec The data to pass as the first argument to the function
+ * @param t The table to iterate over
+ * @param vp The vararg table.  If this is NULL, then all elements in the 
+ *                table are run through the function, otherwise only those 
+ *                whose key matches are run.
+ * @return FALSE if one of the comp() iterations returned zero; TRUE if all
+ *            iterations returned non-zero
+ * @see guththila_table_do_callback_fn_t
+ */
+int guththila_table_vdo(guththila_table_do_callback_fn_t *comp,
+                               void *rec, const guththila_table_t *t, va_list vp);
+
+/** flag for overlap to use guththila_table_setn */
+#define GUTHTHILA_OVERLAP_TABLES_SET   (0)
+/** flag for overlap to use guththila_table_mergen */
+#define GUTHTHILA_OVERLAP_TABLES_MERGE (1)
+/**
+ * For each element in table b, either use setn or mergen to add the data
+ * to table a.  Which method is used is determined by the flags passed in.
+ * @param a The table to add the data to.
+ * @param b The table to iterate over, adding its data to table a
+ * @param flags How to add the table to table a.  One of:
+ *          GUTHTHILA_OVERLAP_TABLES_SET        Use guththila_table_setn
+ *          GUTHTHILA_OVERLAP_TABLES_MERGE      Use guththila_table_mergen
+ * @remark  This function is highly optimized, and uses less memory and CPU cycles
+ *          than a function that just loops through table b calling other functions.
+ */
+/**
+ *<PRE>
+ * Conceptually, guththila_table_overlap does this:
+ *
+ *  guththila_array_header_t *barr = guththila_table_elts(b);
+ *  guththila_table_entry_t *belt = (guththila_table_entry_t *)barr->elts;
+ *  int i;
+ *
+ *  for (i = 0; i < barr->nelts; ++i) {
+ *      if (flags & GUTHTHILA_OVERLAP_TABLES_MERGE) {
+ *          guththila_table_mergen(a, belt[i].key, belt[i].val);
+ *      }
+ *      else {
+ *          guththila_table_setn(a, belt[i].key, belt[i].val);
+ *      }
+ *  }
+ *
+ *  Except that it is more efficient (less space and cpu-time) especially
+ *  when b has many elements.
+ *
+ *  Notice the assumptions on the keys and values in b -- they must be
+ *  in an ancestor of a's pool.  In practice b and a are usually from
+ *  the same pool.
+ * </PRE>
+ */
+
+void guththila_table_overlap(guththila_table_t *a, const guththila_table_t *b,
+                                     unsigned flags);
+
+/**
+ * Eliminate redundant entries in a table by either overwriting
+ * or merging duplicates
+ *
+ * @param t Table.
+ * @param flags GUTHTHILA_OVERLAP_TABLES_MERGE to merge, or
+ *              GUTHTHILA_OVERLAP_TABLES_SET to overwrite
+ */
+void guththila_table_compress(guththila_table_t *t, unsigned flags);
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif	/* ! GUTHTHILA_TABLES_H */

Propchange: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_array.h
------------------------------------------------------------------------------
    svn:executable = *

Modified: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_buffer.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_buffer.c?rev=327989&r1=327988&r2=327989&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_buffer.c (original)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_buffer.c Mon Oct 24 01:15:14 2005
@@ -17,43 +17,44 @@
  * @author Dinesh Premalal (xydinesh@gmail.com, premalwd@cse.mrt.ac.lk)	
  */
 
-
+#include "guththila_environment.h"
 #include "guththila_buffer.h"
 
 guththila_buffer_t * 
-guththila_buffer_create (int size)
+guththila_buffer_create (guththila_environment_t *environment,int size)
 {
-  guththila_buffer_t *name = malloc (sizeof(guththila_buffer_t));
+  guththila_buffer_t *name = guththila_malloc (environment->allocator , sizeof(guththila_buffer_t));
   name->size = size;
   name->offset = 0;
   name->last = 0;
   name->next = 0;
-  if (name->buff)
-    free (name->buff);
+  name->buff = NULL;
   if (size != 0)
-    name->buff = (char *) malloc (size);
+    name->buff = (guththila_char_t *) guththila_malloc (environment->allocator,size);
   return name;
 }
 
 
 void 
-guththila_buffer_free (guththila_buffer_t *name)
+guththila_buffer_free (guththila_environment_t *environment, guththila_buffer_t *name)
 {
   if (name)
     {
       if (name->buff)
-	free (name->buff);
+	  {
+	        guththila_free (environment->allocator,name->buff);
+	  }
       free (name);
     }
 }
 
 
 guththila_buffer_t *
-guththila_buffer_grow (guththila_buffer_t *name)
+guththila_buffer_grow (guththila_environment_t *environment,guththila_buffer_t *name)
 {
   guththila_buffer_t *x;
   name->size <<= 1;
-  x = (guththila_buffer_t *) realloc (name, name->size);
+  x = (guththila_buffer_t *)guththila_realloc (environment->allocator,name, name->size);
   if (x)
     name = x; 
   else

Modified: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_buffer.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_buffer.h?rev=327989&r1=327988&r2=327989&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_buffer.h (original)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_buffer.h Mon Oct 24 01:15:14 2005
@@ -22,6 +22,8 @@
 #define GUTHTHILA_BUFFER_H
 
 #include <stdlib.h>
+#include "guththila_environment.h"
+
 
 typedef struct guththila_buffer_s
 {
@@ -29,11 +31,12 @@
   int next;
   int last;
   int offset;
-  char *buff;
+  guththila_char_t *buff;
 } guththila_buffer_t;
 
-guththila_buffer_t *guththila_buffer_create (int size);
-void guththila_buffer_free (guththila_buffer_t *name);
-guththila_buffer_t *guththila_buffer_grow (guththila_buffer_t *name);
+guththila_buffer_t *guththila_buffer_create (guththila_environment_t *environment,int size);
+void guththila_buffer_free (guththila_environment_t *environment, guththila_buffer_t *name);
+
+guththila_buffer_t *guththila_buffer_grow (guththila_environment_t *environment,guththila_buffer_t *name);
 
 #endif /* GUTHTHILA_BUFFER_H */

Added: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_defines.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_defines.h?rev=327989&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_defines.h (added)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_defines.h Mon Oct 24 01:15:14 2005
@@ -0,0 +1,27 @@
+#ifndef GUTHTHILA_DEFINES_H
+#define GUTHTHILA_DEFINES_H
+/**
+ * @file guththila_defines.h
+ * @brief Useful definitions, which may have platform concerns
+ */
+ 
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef char guththila_char_t;
+typedef unsigned char guththila_unsigned_char_t;
+typedef int guththila_bool_t;
+typedef int guththila_status_t;
+typedef unsigned int guththila_ssize_t;
+
+#define GUTHTHILA_TRUE 1
+#define GUTHTHILA_FALSE 0
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GUTHTHILA_DEFINES_H */

Propchange: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_defines.h
------------------------------------------------------------------------------
    svn:executable = *

Added: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_environment.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_environment.c?rev=327989&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_environment.c (added)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_environment.c Mon Oct 24 01:15:14 2005
@@ -0,0 +1,54 @@
+/*
+ * 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_environment.h>
+
+guththila_environment_t *guththila_environment_create(guththila_allocator_t *allocator, guththila_error_t *error, guththila_stream_t *stream, guththila_log_t *log, guththila_string_t *string)
+{
+    guththila_environment_t *environment;
+    if (!allocator)
+        return NULL;
+
+    environment = (guththila_environment_t*)guththila_malloc(allocator, sizeof(guththila_environment_t));
+
+    if (!environment)
+        return NULL;
+
+    environment->allocator = allocator;
+
+    if (!error)
+        environment->error = guththila_error_create(allocator);
+    else
+        environment->error = error;
+
+    if (!stream)
+        environment->stream = guththila_stream_create(allocator, NULL);
+    else
+        environment->stream = stream;
+
+    if (!log)
+        environment->log = guththila_log_create(allocator, NULL);
+    else
+        environment->log = log;
+
+    if (!string)
+        environment->string = guththila_string_create(allocator, NULL);
+    else
+        environment->string = string;
+
+    return environment;
+}
+

Propchange: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_environment.c
------------------------------------------------------------------------------
    svn:executable = *

Added: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_environment.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_environment.h?rev=327989&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_environment.h (added)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_environment.h Mon Oct 24 01:15:14 2005
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+#ifndef GUTHTHILA_ENVIRONMENT_H
+#define GUTHTHILA_ENVIRONMENT_H
+
+#include <guththila_allocator.h>
+#include <guththila_error.h>
+#include <guththila_stream.h>
+#include <guththila_log.h>
+#include "guththila_defines.h"
+#include <guththila_string.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct guththila_environment;
+struct guththila_environment_ops;
+
+typedef struct guththila_environment_ops {
+int test;
+} guththila_environment_ops_t;
+
+typedef struct guththila_environment {
+    struct guththila_environment_ops *ops;
+    guththila_allocator_t *allocator;   /* memory allocation routines */
+    guththila_error_t *error;           /* error handling */
+    guththila_stream_t *stream;         /* IO routines */
+    guththila_log_t *log;               /* logging routines */
+    guththila_string_t *string;         /* string routines */
+} guththila_environment_t;
+
+guththila_environment_t *guththila_environment_create(guththila_allocator_t *allocator, guththila_error_t *error, guththila_stream_t *stream, guththila_log_t *log, guththila_string_t *string);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GUTHTHILA_ENVIRONMENT_H */

Propchange: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_environment.h
------------------------------------------------------------------------------
    svn:executable = *

Added: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_error.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_error.c?rev=327989&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_error.c (added)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_error.c Mon Oct 24 01:15:14 2005
@@ -0,0 +1,48 @@
+/*
+ * 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_error.h>
+
+ guththila_char_t *guththila_error_ops_get_message();
+
+guththila_char_t *guththila_error_ops_get_message()
+{
+    return "This is the default error code";
+}
+
+guththila_error_t *guththila_error_create(guththila_allocator_t* allocator)
+{
+    guththila_error_t *error;
+    if (!allocator)
+        return NULL;
+    
+    error = (guththila_error_t*)guththila_malloc(allocator, sizeof(guththila_error_t ));
+
+    if (!error)
+        return NULL;
+    
+    error->ops = (guththila_error_ops_t*)guththila_malloc(allocator, sizeof(guththila_error_ops_t));
+
+    if (!error->ops)
+    {
+        guththila_free(allocator, error);
+        return NULL;
+    }
+    
+    error->ops->get_message = guththila_error_ops_get_message;
+    
+    return error;
+}

Propchange: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_error.c
------------------------------------------------------------------------------
    svn:executable = *

Added: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_error.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_error.h?rev=327989&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_error.h (added)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_error.h Mon Oct 24 01:15:14 2005
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+
+#ifndef GUTHTHILA_ERROR_H
+#define GUTHTHILA_ERROR_H
+
+#include <guththila_defines.h>
+#include <guththila_allocator.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct guththila_error;
+struct guththila_error_ops;
+
+typedef struct guththila_error_ops {
+    guththila_char_t* (*get_message)();
+} guththila_error_ops_t;
+
+typedef struct guththila_error {
+    struct guththila_error_ops *ops;
+    int errorno;
+} guththila_error_t;
+
+guththila_error_t *guththila_error_create(guththila_allocator_t* allocator);
+
+#define guththila_error_get_message(error) ((error)->ops->get_message())
+
+typedef enum guththila_status_codes {
+    GUTHTHILA_FAILURE = 0,
+    GUTHTHILA_SUCCESS
+} guththila_status_codes_t;
+
+typedef enum guththila_error_codes {
+    GUTHTHILA_ERROR_NONE = 0,
+    GUTHTHILA_ERROR_NO_MEMORY,
+    GUTHTHILA_ERROR_INVALID_NULL_PARAMETER,
+    GUTHTHILA_ERROR_INVALID_ITERATOR_STATE,
+    GUTHTHILA_ERROR_INVALID_NODE_TYPE,
+    GUTHTHILA_STREAM_WRITER_ERROR_NOT_IN_GUTHTHILA_START_ELEMENT,     
+    GUTHTHILA_STREAM_WRITER_ERROR_WRITING_TO_STREAM,        
+    GUTHTHILA_STREAM_WRITER_ERROR_STREAM_STRUCT_NULL,        
+    GUTHTHILA_STREAM_WRITER_ERROR_LOCAL_NAME_NULL,       
+    GUTHTHILA_STREAM_WRITER_ERROR_guththila_namespace_t_NULL,        
+    GUTHTHILA_STREAM_WRITER_ERROR_PREFIX_NULL,        
+    GUTHTHILA_STREAM_WRITER_ERROR_guththila_namespace_t_NOT_DECLARED,        
+    GUTHTHILA_STREAM_WRITER_ERROR_guththila_element_t_guththila_stack_t_EMPTY,   
+    GUTHTHILA_STREAM_WRITER_ERROR_ILLEGAL_STATE,      
+    GUTHTHILA_STREAM_WRITER_ERROR_GUTHTHILA_COMMENT_NULL,        
+    GUTHTHILA_STREAM_WRITER_ERROR_ILLEGAL_GUTHTHILA_COMMENT,       
+    GUTHTHILA_STREAM_WRITER_ERROR_PROCESSING_INSTRUCTION_TARGET_NULL,     
+    GUTHTHILA_STREAM_WRITER_ERROR_CDATA_NULL,     
+    GUTHTHILA_STREAM_WRITER_ERROR_ILLEGAL_CDATA,      
+    GUTHTHILA_STREAM_WRITER_ERROR_DTD_NULL,      
+    GUTHTHILA_STREAM_WRITER_ERROR_ENTITY_REF_NULL,      
+    GUTHTHILA_STREAM_WRITER_ERROR_ILLEGAL_XML_VERSION,  
+    GUTHTHILA_STREAM_WRITER_ERROR_TEXT_NULL,       
+    GUTHTHILA_STREAM_WRITER_ERROR_ILLEGAL_PREFIX,   
+    GUTHTHILA_STREAM_WRITER_ERROR_OUT_OF_MEMORY,
+    GUTHTHILA_STREAM_READER_ERROR_OUT_OF_MEMORY
+ 
+    
+ 
+     
+} guththila_error_codes_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* GUTHTHILA_ERROR_H */

Propchange: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_error.h
------------------------------------------------------------------------------
    svn:executable = *