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 [2/4] -
/webservices/axis2/trunk/c/modules/xml/guththila/src/
Added: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_hash.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_hash.c?rev=327989&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_hash.c (added)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_hash.c Mon Oct 24 01:15:14 2005
@@ -0,0 +1,457 @@
+/*
+ * 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_hash.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+/*
+ * The internal form of a hash table.
+ *
+ * The table is an array indexed by the hash of the key; collisions
+ * are resolved by hanging a linked list of hash entries off each
+ * element of the array. Although this is a really simple design it
+ * isn't too bad given that environments have a low allocation overhead.
+ */
+
+typedef struct guththila_hash_entry_t guththila_hash_entry_t;
+
+struct guththila_hash_entry_t {
+ guththila_hash_entry_t *next;
+ unsigned int hash;
+ const void *key;
+ guththila_ssize_t klen;
+ const void *val;
+};
+
+/*
+ * Data structure for iterating through a hash table.
+ *
+ * We keep a pointer to the next hash entry here to allow the current
+ * hash entry to be freed or otherwise mangled between calls to
+ * guththila_hash_next().
+ */
+struct guththila_hash_index_t {
+ guththila_hash_t *ht;
+ guththila_hash_entry_t *this, *next;
+ unsigned int index;
+};
+
+/*
+ * The size of the array is always a power of two. We use the maximum
+ * index rather than the size so that we can use bitwise-AND for
+ * modular arithmetic.
+ * The count of hash entries may be greater depending on the chosen
+ * collision rate.
+ */
+struct guththila_hash_t {
+ guththila_environment_t *environment;
+ guththila_hash_entry_t **array;
+ guththila_hash_index_t iterator; /* For guththila_hash_first(NULL, ...) */
+ unsigned int count, max;
+ guththila_hashfunc_t hash_func;
+ guththila_hash_entry_t *free; /* List of recycled entries */
+};
+
+#define INITIAL_MAX 15 /* tunable == 2^n - 1 */
+
+
+/*
+ * Hash creation functions.
+ */
+
+static guththila_hash_entry_t **alloc_array(guththila_hash_t *ht, unsigned int max)
+{
+ return memset (guththila_malloc(ht->environment->allocator,
+ sizeof(*ht->array) * (max + 1)), 0, sizeof(*ht->array) * (max + 1) );
+}
+
+guththila_hash_t *guththila_hash_make(guththila_environment_t *environment)
+{
+ guththila_hash_t *ht;
+ ht = guththila_malloc(environment->allocator, sizeof(guththila_hash_t));
+ ht->environment = environment;
+ ht->free = NULL;
+ ht->count = 0;
+ ht->max = INITIAL_MAX;
+ ht->array = alloc_array(ht, ht->max);
+ ht->hash_func = guththila_hashfunc_default;
+ return ht;
+}
+
+guththila_hash_t *guththila_hash_make_custom(guththila_environment_t *environment,
+ guththila_hashfunc_t hash_func)
+{
+ guththila_hash_t *ht = guththila_hash_make(environment);
+ ht->hash_func = hash_func;
+ return ht;
+}
+
+
+/*
+ * Hash iteration functions.
+ */
+
+guththila_hash_index_t *guththila_hash_next(guththila_hash_index_t *hi)
+{
+ hi->this = hi->next;
+ while (!hi->this) {
+ if (hi->index > hi->ht->max)
+ return NULL;
+
+ hi->this = hi->ht->array[hi->index++];
+ }
+ hi->next = hi->this->next;
+ return hi;
+}
+
+guththila_hash_index_t *guththila_hash_first(guththila_environment_t *environment, guththila_hash_t *ht)
+{
+ guththila_hash_index_t *hi;
+ if (environment)
+ hi = guththila_malloc(environment->allocator, sizeof(*hi));
+ else
+ hi = &ht->iterator;
+
+ hi->ht = ht;
+ hi->index = 0;
+ hi->this = NULL;
+ hi->next = NULL;
+ return guththila_hash_next(hi);
+}
+
+void guththila_hash_this(guththila_hash_index_t *hi,
+ const void **key,
+ guththila_ssize_t *klen,
+ void **val)
+{
+ if (key) *key = hi->this->key;
+ if (klen) *klen = hi->this->klen;
+ if (val) *val = (void *)hi->this->val;
+}
+
+
+/*
+ * Expanding a hash table
+ */
+
+static void expand_array(guththila_hash_t *ht)
+{
+ guththila_hash_index_t *hi;
+ guththila_hash_entry_t **new_array;
+ unsigned int new_max;
+
+ new_max = ht->max * 2 + 1;
+ new_array = alloc_array(ht, new_max);
+ for (hi = guththila_hash_first(NULL, ht); hi; hi = guththila_hash_next(hi)) {
+ unsigned int i = hi->this->hash & new_max;
+ hi->this->next = new_array[i];
+ new_array[i] = hi->this;
+ }
+ ht->array = new_array;
+ ht->max = new_max;
+}
+
+unsigned int guththila_hashfunc_default(const guththila_char_t *char_key, guththila_ssize_t *klen)
+{
+ unsigned int hash = 0;
+ const guththila_unsigned_char_t *key = (const guththila_unsigned_char_t *)char_key;
+ const guththila_unsigned_char_t *p;
+ guththila_ssize_t i;
+
+ /*
+ * This is the popular `times 33' hash algorithm which is used by
+ * perl and also appears in Berkeley DB. This is one of the best
+ * known hash functions for strings because it is both computed
+ * very fast and distributes very well.
+ *
+ * The originator may be Dan Bernstein but the code in Berkeley DB
+ * cites Chris Torek as the source. The best citation I have found
+ * is "Chris Torek, Hash function for text in C, Usenet message
+ * <27...@mimsy.umd.edu> in comp.lang.c , October, 1990." in Rich
+ * Salz's USENIX 1992 paper about INN which can be found at
+ * <http://citeseer.nj.nec.com/salz92internetnews.html>.
+ *
+ * The magic of number 33, i.e. why it works better than many other
+ * constants, prime or not, has never been adequately explained by
+ * anyone. So I try an explanation: if one experimentally tests all
+ * multipliers between 1 and 256 (as I did while writing a low-level
+ * data structure library some time ago) one detects that even
+ * numbers are not useable at all. The remaining 128 odd numbers
+ * (except for the number 1) work more or less all equally well.
+ * They all distribute in an acceptable way and this way fill a hash
+ * table with an average percent of approx. 86%.
+ *
+ * If one compares the chi^2 values of the variants (see
+ * Bob Jenkins ``Hashing Frequently Asked Questions'' at
+ * http://burtleburtle.net/bob/hash/hashfaq.html for a description
+ * of chi^2), the number 33 not even has the best value. But the
+ * number 33 and a few other equally good numbers like 17, 31, 63,
+ * 127 and 129 have nevertheless a great advantage to the remaining
+ * numbers in the large set of possible multipliers: their multiply
+ * operation can be replaced by a faster operation based on just one
+ * shift plus either a single addition or subtraction operation. And
+ * because a hash function has to both distribute good _and_ has to
+ * be very fast to compute, those few numbers should be preferred.
+ *
+ * -- Ralf S. Engelschall <rs...@engelschall.com>
+ */
+
+ if (*klen == GUTHTHILA_HASH_KEY_STRING) {
+ for (p = key; *p; p++) {
+ hash = hash * 33 + *p;
+ }
+ *klen = p - key;
+ }
+ else {
+ for (p = key, i = *klen; i; i--, p++) {
+ hash = hash * 33 + *p;
+ }
+ }
+
+ return hash;
+}
+
+
+/*
+ * This is where we keep the details of the hash function and control
+ * the maximum collision rate.
+ *
+ * If val is non-NULL it creates and initializes a new hash entry if
+ * there isn't already one there; it returns an updatable pointer so
+ * that hash entries can be removed.
+ */
+
+static guththila_hash_entry_t **find_entry(guththila_hash_t *ht,
+ const void *key,
+ guththila_ssize_t klen,
+ const void *val)
+{
+ guththila_hash_entry_t **hep, *he;
+ unsigned int hash;
+
+ hash = ht->hash_func(key, &klen);
+
+ /* scan linked list */
+ for (hep = &ht->array[hash & ht->max], he = *hep;
+ he; hep = &he->next, he = *hep) {
+ if (he->hash == hash
+ && he->klen == klen
+ && memcmp(he->key, key, klen) == 0)
+ break;
+ }
+ if (he || !val)
+ return hep;
+
+ /* add a new entry for non-NULL values */
+ if ((he = ht->free) != NULL)
+ ht->free = he->next;
+ else
+ he = guththila_malloc(ht->environment->allocator, sizeof(*he));
+ he->next = NULL;
+ he->hash = hash;
+ he->key = key;
+ he->klen = klen;
+ he->val = val;
+ *hep = he;
+ ht->count++;
+ return hep;
+}
+
+guththila_hash_t *guththila_hash_copy(guththila_environment_t *environment,
+ const guththila_hash_t *orig)
+{
+ guththila_hash_t *ht;
+ guththila_hash_entry_t *new_vals;
+ unsigned int i, j;
+
+ ht = guththila_malloc(environment->allocator, sizeof(guththila_hash_t) +
+ sizeof(*ht->array) * (orig->max + 1) +
+ sizeof(guththila_hash_entry_t) * orig->count);
+ ht->environment = environment;
+ ht->free = NULL;
+ ht->count = orig->count;
+ ht->max = orig->max;
+ ht->hash_func = orig->hash_func;
+ ht->array = (guththila_hash_entry_t **)((guththila_char_t *)ht + sizeof(guththila_hash_t));
+
+ new_vals = (guththila_hash_entry_t *)((guththila_char_t *)(ht) + sizeof(guththila_hash_t) +
+ sizeof(*ht->array) * (orig->max + 1));
+ j = 0;
+ for (i = 0; i <= ht->max; i++) {
+ guththila_hash_entry_t **new_entry = &(ht->array[i]);
+ guththila_hash_entry_t *orig_entry = orig->array[i];
+ while (orig_entry) {
+ *new_entry = &new_vals[j++];
+ (*new_entry)->hash = orig_entry->hash;
+ (*new_entry)->key = orig_entry->key;
+ (*new_entry)->klen = orig_entry->klen;
+ (*new_entry)->val = orig_entry->val;
+ new_entry = &((*new_entry)->next);
+ orig_entry = orig_entry->next;
+ }
+ *new_entry = NULL;
+ }
+ return ht;
+}
+
+void *guththila_hash_get(guththila_hash_t *ht,
+ const void *key,
+ guththila_ssize_t klen)
+{
+ guththila_hash_entry_t *he;
+ he = *find_entry(ht, key, klen, NULL);
+ if (he)
+ return (void *)he->val;
+ else
+ return NULL;
+}
+
+void guththila_hash_set(guththila_hash_t *ht,
+ const void *key,
+ guththila_ssize_t klen,
+ const void *val)
+{
+ guththila_hash_entry_t **hep;
+ hep = find_entry(ht, key, klen, val);
+ if (*hep) {
+ if (!val) {
+ /* delete entry */
+ guththila_hash_entry_t *old = *hep;
+ *hep = (*hep)->next;
+ old->next = ht->free;
+ ht->free = old;
+ --ht->count;
+ }
+ else {
+ /* replace entry */
+ (*hep)->val = val;
+ /* check that the collision rate isn't too high */
+ if (ht->count > ht->max) {
+ expand_array(ht);
+ }
+ }
+ }
+ /* else key not present and val==NULL */
+}
+
+unsigned int guththila_hash_count(guththila_hash_t *ht)
+{
+ return ht->count;
+}
+
+guththila_hash_t *guththila_hash_overlay(guththila_environment_t *environment,
+ const guththila_hash_t *overlay,
+ const guththila_hash_t *base)
+{
+ return guththila_hash_merge(environment, overlay, base, NULL, NULL);
+}
+
+guththila_hash_t *guththila_hash_merge(guththila_environment_t *environment,
+ const guththila_hash_t *overlay,
+ const guththila_hash_t *base,
+ void * (*merger)(guththila_environment_t *environment,
+ const void *key,
+ guththila_ssize_t klen,
+ const void *h1_val,
+ const void *h2_val,
+ const void *data),
+ const void *data)
+{
+ guththila_hash_t *res;
+ guththila_hash_entry_t *new_vals = NULL;
+ guththila_hash_entry_t *iter;
+ guththila_hash_entry_t *ent;
+ unsigned int i,j,k;
+
+#if GUTHTHILA_POOL_DEBUG
+ /* we don't copy keys and values, so it's necessary that
+ * overlay->a.environment and base->a.environment have a life span at least
+ * as long as p
+ */
+ if (!guththila_environment_is_ancestor(overlay->environment, p)) {
+ fprintf(stderr,
+ "guththila_hash_merge: overlay's environment is not an ancestor of p\n");
+ abort();
+ }
+ if (!guththila_environment_is_ancestor(base->environment, p)) {
+ fprintf(stderr,
+ "guththila_hash_merge: base's environment is not an ancestor of p\n");
+ abort();
+ }
+#endif
+
+ res = guththila_malloc(environment->allocator, sizeof(guththila_hash_t));
+ res->environment = environment;
+ res->free = NULL;
+ res->hash_func = base->hash_func;
+ res->count = base->count;
+ res->max = (overlay->max > base->max) ? overlay->max : base->max;
+ if (base->count + overlay->count > res->max) {
+ res->max = res->max * 2 + 1;
+ }
+ res->array = alloc_array(res, res->max);
+ if (base->count + overlay->count) {
+ new_vals = guththila_malloc(environment->allocator, sizeof(guththila_hash_entry_t) *
+ (base->count + overlay->count));
+ }
+ j = 0;
+ for (k = 0; k <= base->max; k++) {
+ for (iter = base->array[k]; iter; iter = iter->next) {
+ i = iter->hash & res->max;
+ new_vals[j].klen = iter->klen;
+ new_vals[j].key = iter->key;
+ new_vals[j].val = iter->val;
+ new_vals[j].hash = iter->hash;
+ new_vals[j].next = res->array[i];
+ res->array[i] = &new_vals[j];
+ j++;
+ }
+ }
+
+ for (k = 0; k <= overlay->max; k++) {
+ for (iter = overlay->array[k]; iter; iter = iter->next) {
+ i = iter->hash & res->max;
+ for (ent = res->array[i]; ent; ent = ent->next) {
+ if ((ent->klen == iter->klen) &&
+ (memcmp(ent->key, iter->key, iter->klen) == 0)) {
+ if (merger) {
+ ent->val = (*merger)(environment, iter->key, iter->klen,
+ iter->val, ent->val, data);
+ }
+ else {
+ ent->val = iter->val;
+ }
+ break;
+ }
+ }
+ if (!ent) {
+ new_vals[j].klen = iter->klen;
+ new_vals[j].key = iter->key;
+ new_vals[j].val = iter->val;
+ new_vals[j].hash = iter->hash;
+ new_vals[j].next = res->array[i];
+ res->array[i] = &new_vals[j];
+ res->count++;
+ j++;
+ }
+ }
+ }
+ return res;
+}
+
Propchange: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_hash.c
------------------------------------------------------------------------------
svn:executable = *
Added: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_hash.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_hash.h?rev=327989&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_hash.h (added)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_hash.h Mon Oct 24 01:15:14 2005
@@ -0,0 +1,226 @@
+/*
+ * 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_HASH_H
+#define GUTHTHILA_HASH_H
+
+/**
+ * @file guththila_hash.h
+ * @brief Axis2 Hash Tables
+ */
+
+#include <guththila_defines.h>
+#include <guththila_environment.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup guththila_hash Hash Tables
+ * @ingroup guththila
+ * @{
+ */
+
+/**
+ * When passing a key to guththila_hash_set or guththila_hash_get, this value can be
+ * passed to indicate a string-valued key, and have guththila_hash compute the
+ * length automatically.
+ *
+ * @remark guththila_hash will use strlen(key) for the length. The NUL terminator
+ * is not included in the hash value (why throw a constant in?).
+ * Since the hash table merely references the provided key (rather
+ * than copying it), guththila_hash_this() will return the NUL-term'd key.
+ */
+#define GUTHTHILA_HASH_KEY_STRING (-1)
+
+/**
+ * Abstract type for hash tables.
+ */
+typedef struct guththila_hash_t guththila_hash_t;
+
+/**
+ * Abstract type for scanning hash tables.
+ */
+typedef struct guththila_hash_index_t guththila_hash_index_t;
+
+/**
+ * Callback functions for calculating hash values.
+ * @param key The key.
+ * @param klen The length of the key, or GUTHTHILA_HASH_KEY_STRING to use the string
+ * length. If GUTHTHILA_HASH_KEY_STRING then returns the actual key length.
+ */
+typedef unsigned int (*guththila_hashfunc_t)(const guththila_char_t *key, guththila_ssize_t *klen);
+
+/**
+ * The default hash function.
+ */
+unsigned int guththila_hashfunc_default(const guththila_char_t *key, guththila_ssize_t *klen);
+
+/**
+ * Create a hash table.
+ * @param environment The environment to allocate the hash table out of
+ * @return The hash table just created
+ */
+guththila_hash_t *guththila_hash_make(guththila_environment_t *environment);
+
+/**
+ * Create a hash table with a custom hash function
+ * @param environment The environment to allocate the hash table out of
+ * @param hash_func A custom hash function.
+ * @return The hash table just created
+ */
+guththila_hash_t *guththila_hash_make_custom(guththila_environment_t *environment,
+ guththila_hashfunc_t hash_func);
+
+/**
+ * Make a copy of a hash table
+ * @param environment The environment from which to allocate the new hash table
+ * @param h The hash table to clone
+ * @return The hash table just created
+ * @remark Makes a shallow copy
+ */
+guththila_hash_t *guththila_hash_copy(guththila_environment_t *environment,
+ const guththila_hash_t *h);
+
+/**
+ * Associate a value with a key in a hash table.
+ * @param ht The hash table
+ * @param key Pointer to the key
+ * @param klen Length of the key. Can be GUTHTHILA_HASH_KEY_STRING to use the string length.
+ * @param val Value to associate with the key
+ * @remark If the value is NULL the hash entry is deleted.
+ */
+void guththila_hash_set(guththila_hash_t *ht, const void *key,
+ guththila_ssize_t klen, const void *val);
+
+/**
+ * Look up the value associated with a key in a hash table.
+ * @param ht The hash table
+ * @param key Pointer to the key
+ * @param klen Length of the key. Can be GUTHTHILA_HASH_KEY_STRING to use the string length.
+ * @return Returns NULL if the key is not present.
+ */
+void *guththila_hash_get(guththila_hash_t *ht, const void *key,
+ guththila_ssize_t klen);
+
+/**
+ * Start iterating over the entries in a hash table.
+ * @param p The environment to allocate the guththila_hash_index_t iterator. If this
+ * environment is NULL, then an internal, non-thread-safe iterator is used.
+ * @param ht The hash table
+ * @remark There is no restriction on adding or deleting hash entries during
+ * an iteration (although the results may be unpredictable unless all you do
+ * is delete the current entry) and multiple iterations can be in
+ * progress at the same time.
+
+ * @example
+ */
+/**
+ * <PRE>
+ *
+ * int sum_values(guththila_environment_t *environment, guththila_hash_t *ht)
+ * {
+ * guththila_hash_index_t *hi;
+ * void *val;
+ * int sum = 0;
+ * for (hi = guththila_hash_first(p, ht); hi; hi = guththila_hash_next(hi)) {
+ * guththila_hash_this(hi, NULL, NULL, &val);
+ * sum += *(int *)val;
+ * }
+ * return sum;
+ * }
+ * </PRE>
+ */
+guththila_hash_index_t *guththila_hash_first(guththila_environment_t *environment, guththila_hash_t *ht);
+
+/**
+ * Continue iterating over the entries in a hash table.
+ * @param hi The iteration state
+ * @return a pointer to the updated iteration state. NULL if there are no more
+ * entries.
+ */
+guththila_hash_index_t *guththila_hash_next(guththila_hash_index_t *hi);
+
+/**
+ * Get the current entry's details from the iteration state.
+ * @param hi The iteration state
+ * @param key Return pointer for the pointer to the key.
+ * @param klen Return pointer for the key length.
+ * @param val Return pointer for the associated value.
+ * @remark The return pointers should point to a variable that will be set to the
+ * corresponding data, or they may be NULL if the data isn't interesting.
+ */
+void guththila_hash_this(guththila_hash_index_t *hi, const void **key,
+ guththila_ssize_t *klen, void **val);
+
+/**
+ * Get the number of key/value pairs in the hash table.
+ * @param ht The hash table
+ * @return The number of key/value pairs in the hash table.
+ */
+unsigned int guththila_hash_count(guththila_hash_t *ht);
+
+/**
+ * Merge two hash tables into one new hash table. The values of the overlay
+ * hash override the values of the base if both have the same key. Both
+ * hash tables must use the same hash function.
+ * @param p The environment to use for the new hash table
+ * @param overlay The table to add to the initial table
+ * @param base The table that represents the initial values of the new table
+ * @return A new hash table containing all of the data from the two passed in
+ */
+guththila_hash_t *guththila_hash_overlay(guththila_environment_t *environment,
+ const guththila_hash_t *overlay,
+ const guththila_hash_t *base);
+
+/**
+ * Merge two hash tables into one new hash table. If the same key
+ * is present in both tables, call the supplied merge function to
+ * produce a merged value for the key in the new table. Both
+ * hash tables must use the same hash function.
+ * @param p The environment to use for the new hash table
+ * @param h1 The first of the tables to merge
+ * @param h2 The second of the tables to merge
+ * @param merger A callback function to merge values, or NULL to
+ * make values from h1 override values from h2 (same semantics as
+ * guththila_hash_overlay())
+ * @param data Client data to pass to the merger function
+ * @return A new hash table containing all of the data from the two passed in
+ */
+guththila_hash_t *guththila_hash_merge(guththila_environment_t *environment,
+ const guththila_hash_t *h1,
+ const guththila_hash_t *h2,
+ void * (*merger)(guththila_environment_t *environment,
+ const void *key,
+ guththila_ssize_t klen,
+ const void *h1_val,
+ const void *h2_val,
+ const void *data),
+ const void *data);
+
+/**
+ * Get a pointer to the environment which the hash table was created in
+ */
+/*GUTHTHILA_POOL_DECLARE_ACCESSOR(hash);*/
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !GUTHTHILA_HASH_H */
Propchange: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_hash.h
------------------------------------------------------------------------------
svn:executable = *
Added: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_log.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_log.c?rev=327989&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_log.c (added)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_log.c Mon Oct 24 01:15:14 2005
@@ -0,0 +1,63 @@
+/*
+ * 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_log.h>
+#include <stdio.h>
+
+int guththila_log_impl_write(const void *buffer, size_t count);
+
+guththila_log_t *guththila_log_create(guththila_allocator_t* allocator, guththila_log_ops_t* operations)
+{
+ guththila_log_t *log;
+ if (!allocator)
+ return NULL;
+
+ log = (guththila_log_t*)guththila_malloc(allocator, sizeof(guththila_log_t));
+
+ if (!log)
+ return NULL;
+
+ if (operations)
+ log->ops = operations;
+ else
+ {
+ log->ops = (guththila_log_ops_t*)guththila_malloc(allocator, sizeof(guththila_log_ops_t));
+
+ if (!log->ops)
+ {
+ guththila_free(allocator, log);
+ return NULL;
+ }
+
+ log->ops->guththila_log_ops_write = guththila_log_impl_write;
+ }
+
+ return log;
+}
+
+int guththila_log_impl_write(const void *buffer, size_t count)
+{
+ int i;
+ if (!buffer)
+ return -1;
+
+ i =0;
+ for(i = 0; i < count; i++)
+ fprintf(stderr, "%c", ((guththila_char_t*)buffer)[i]);
+ printf("\n");
+ return 0;
+}
+
Propchange: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_log.c
------------------------------------------------------------------------------
svn:executable = *
Added: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_log.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_log.h?rev=327989&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_log.h (added)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_log.h Mon Oct 24 01:15:14 2005
@@ -0,0 +1,59 @@
+/*
+ * 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_LOG_H
+#define GUTHTHILA_LOG_H
+
+#include <guththila_allocator.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum guththila_log_levels
+{
+ GUTHTHILA_LOG_DEBUG = 0,
+ GUTHTHILA_LOG_INFO,
+ GUTHTHILA_LOG_WARNING,
+ GUTHTHILA_LOG_ERROR,
+ GUTHTHILA_LOG_CRITICAL
+} guththila_log_levels_t;
+
+struct guththila_log;
+struct guththila_log_ops;
+
+typedef struct guththila_log_ops
+{
+ int (*guththila_log_ops_write) (const void *buffer, size_t count);
+} guththila_log_ops_t;
+
+typedef struct guththila_log
+{
+ struct guththila_log_ops *ops;
+ guththila_log_levels_t level;
+ int enabled; /*boolean */
+} guththila_log_t;
+
+guththila_log_t *guththila_log_create (guththila_allocator_t * allocator,
+ guththila_log_ops_t * operations);
+
+#define guththila_log_write(log, buffer, count) ((log)->ops->guththila_log_ops_write(buffer, count))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GUTHTHILA_LOG_H */
Propchange: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_log.h
------------------------------------------------------------------------------
svn:executable = *
Modified: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_main.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_main.c?rev=327989&r1=327988&r2=327989&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_main.c (original)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_main.c Mon Oct 24 01:15:14 2005
@@ -18,16 +18,22 @@
*/
#include "guththila_xml_pull_parser.h"
+#include "guththila_defines.h"
+#include "guththila_environment.h"
int main (int argc, char *argv[])
{
guththila_reader_t *red;
FILE *fp = fopen ("response.xml", "r");
- red = guththila_reader_create (fp);
- guththila_xml_pull_parser_t *parser = guththila_xml_pull_parser_create (red);
- guththila_xml_pull_parser_read (parser);
+ guththila_environment_t *environment;
+ guththila_allocator_t *allocator;
+ allocator = guththila_allocator_init(NULL);
+ environment = guththila_environment_create(allocator,NULL,NULL,NULL,NULL);
+ red = guththila_reader_create (environment,fp);
+ guththila_xml_pull_parser_t *parser = guththila_xml_pull_parser_create (environment,red);
+ guththila_xml_pull_parser_read (environment,parser);
int c;
- while ((c = guththila_xml_pull_parser_next (parser)) != -1)
+ while ((c = guththila_xml_pull_parser_next (environment,parser)) != -1)
{
switch (c)
{
@@ -35,16 +41,16 @@
{
printf ("<?xml ");
int ix;
- ix = guththila_xml_pull_parser_get_attribute_count (parser);
+ ix = guththila_xml_pull_parser_get_attribute_count (environment,parser);
for (; ix > 0; ix--)
{
guththila_attribute_t *a;
char *p;
- a = guththila_xml_pull_parser_get_attribute (parser);
- p = guththila_xml_pull_parser_get_attribute_name (parser, a);
+ a = guththila_xml_pull_parser_get_attribute (environment,parser);
+ p = guththila_xml_pull_parser_get_attribute_name (environment,parser, a);
printf ("%s=\"", p);
free (p);
- p = guththila_xml_pull_parser_get_attribute_value (parser, a);
+ p = guththila_xml_pull_parser_get_attribute_value (environment,parser, a);
printf ("%s\" ", p);
free (p);
}
@@ -58,54 +64,54 @@
int ia;
int d;
char *p;
- p = guththila_xml_pull_parser_get_prefix (parser);
+ p = guththila_xml_pull_parser_get_prefix (environment,parser);
if (p)
{
printf ("%s:", p);
free (p);
}
- p = guththila_xml_pull_parser_get_name (parser);
+ p = guththila_xml_pull_parser_get_name (environment,parser);
printf ("%s", p);
free (p);
guththila_element_t *e;
- ia = guththila_xml_pull_parser_get_attribute_count (parser);
+ ia = guththila_xml_pull_parser_get_attribute_count (environment,parser);
for ( ; ia > 0; ia--)
{
/* p = guththila_xml_pull_parser_get_attribute_prefix_by_number
(parser, ia); */
- p = guththila_xml_pull_parser_get_attribute_namespace_by_number (parser, ia);
+ p = guththila_xml_pull_parser_get_attribute_namespace_by_number (environment,parser, ia);
if (p)
{
printf (" %s:", p);
free (p);
- p = guththila_xml_pull_parser_get_attribute_name_by_number (parser, ia);
+ p = guththila_xml_pull_parser_get_attribute_name_by_number (environment,parser, ia);
printf ("%s=\"", p);
free (p);
- p = guththila_xml_pull_parser_get_attribute_value_by_number (parser, ia);
+ p = guththila_xml_pull_parser_get_attribute_value_by_number (environment,parser, ia);
printf ("%s\"", p);
free (p);
}
else
{
- p = guththila_xml_pull_parser_get_attribute_name_by_number (parser, ia);
+ p = guththila_xml_pull_parser_get_attribute_name_by_number (environment,parser, ia);
printf (" %s=\"", p);
free (p);
- p = guththila_xml_pull_parser_get_attribute_value_by_number (parser, ia);
+ p = guththila_xml_pull_parser_get_attribute_value_by_number (environment,parser, ia);
printf ("%s\"", p);
free (p);
}
}
- e = guththila_stack_last (parser->dep);
+ e = guththila_stack_last (environment,parser->dep);
d = e->depth->count;
for (; d > 0; d--)
{
- p = guththila_xml_pull_parser_get_namespace_prefix_by_number (parser, d);
+ p = guththila_xml_pull_parser_get_namespace_prefix_by_number (environment,parser, d);
if (strncmp (p, "xmlns", 5))
printf (" xmlns:");
printf ("%s=\"", p);
free (p);
- p = guththila_xml_pull_parser_get_namespace_uri_by_number (parser, d);
+ p = guththila_xml_pull_parser_get_namespace_uri_by_number (environment,parser, d);
printf ("%s\" ", p);
free (p);
}
@@ -119,13 +125,13 @@
{
printf ("</");
char *p;
- p = guththila_xml_pull_parser_get_prefix (parser);
+ p = guththila_xml_pull_parser_get_prefix (environment,parser);
if (p)
{
printf ("%s:", p);
free (p);
}
- p = guththila_xml_pull_parser_get_name (parser);
+ p = guththila_xml_pull_parser_get_name (environment,parser);
printf ("%s", p);
free (p);
printf (">");
@@ -134,7 +140,7 @@
case GUTHTHILA_CHARACTER:
{
char *p;
- p = guththila_xml_pull_parser_get_value (parser);
+ p = guththila_xml_pull_parser_get_value (environment,parser);
printf (p);
free (p);
}
@@ -143,6 +149,6 @@
break;
};
}
- guththila_xml_pull_parser_free (parser);
+ guththila_xml_pull_parser_free (environment,parser);
return 0;
}
Modified: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_namespace.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_namespace.h?rev=327989&r1=327988&r2=327989&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_namespace.h (original)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_namespace.h Mon Oct 24 01:15:14 2005
@@ -24,9 +24,9 @@
typedef struct guththila_namespace_s
{
- char *name;
+ guththila_char_t *name;
int length;
- char *uri;
+ guththila_char_t *uri;
int lengthuri;
} guththila_namespace_t;
Modified: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_reader.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_reader.c?rev=327989&r1=327988&r2=327989&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_reader.c (original)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_reader.c Mon Oct 24 01:15:14 2005
@@ -19,12 +19,12 @@
#include "guththila_reader.h"
-
+#include "guththila_defines.h"
guththila_reader_t *
-guththila_reader_create (FILE *fp)
+guththila_reader_create (guththila_environment_t *environment,FILE *fp)
{
- guththila_reader_t *reader = (guththila_reader_t *) malloc (sizeof(guththila_reader_t));
+ guththila_reader_t *reader = (guththila_reader_t *)guththila_malloc (environment->allocator,sizeof(guththila_reader_t));
if (fp)
reader->fp = fp;
return reader;
@@ -32,22 +32,22 @@
void
-guththila_reader_free (guththila_reader_t *r)
+guththila_reader_free (guththila_environment_t *environment,guththila_reader_t *r)
{
+
if (r)
- free (r);
+ guththila_free (environment->allocator,r);
}
-
int
-guththila_reader_read (char *buffer, int offset, int length, guththila_reader_t *r)
+guththila_reader_read (guththila_environment_t *environment,guththila_char_t *buffer, int offset, int length, guththila_reader_t *r)
{
return (int)fread (buffer+offset, 1, length, r->fp);
}
int
-guththila_reader_set_input_stream (guththila_reader_t *r, FILE *fp)
+guththila_reader_set_input_stream (guththila_environment_t *environment,guththila_reader_t *r, FILE *fp)
{
if (fp)
{
Modified: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_reader.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_reader.h?rev=327989&r1=327988&r2=327989&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_reader.h (original)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_reader.h Mon Oct 24 01:15:14 2005
@@ -24,15 +24,17 @@
#include <stdio.h>
#include <stdlib.h>
#include "guththila_buffer.h"
+#include "guththila_environment.h"
+#include "guththila_defines.h"
typedef struct guththila_reader_s
{
FILE *fp;
} guththila_reader_t;
-guththila_reader_t *guththila_reader_create (FILE *fp);
-int guththila_reader_read (char *buffer, int offset, int length, guththila_reader_t *r);
-int guththila_reader_set_input_stream (guththila_reader_t *r, FILE *fp);
-void guththila_reader_free (guththila_reader_t *r);
+guththila_reader_t *guththila_reader_create (guththila_environment_t *environment,FILE *fp);
+int guththila_reader_read (guththila_environment_t *environment,guththila_char_t *buffer, int offset, int length, guththila_reader_t *r);
+int guththila_reader_set_input_stream (guththila_environment_t *environment,guththila_reader_t *r, FILE *fp);
+void guththila_reader_free (guththila_environment_t *environment,guththila_reader_t *r);
#endif /* GUTHTHILA_READER_H */
Modified: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_stack.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_stack.c?rev=327989&r1=327988&r2=327989&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_stack.c (original)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_stack.c Mon Oct 24 01:15:14 2005
@@ -17,13 +17,13 @@
* @author Dinesh Premalal (xydinesh@gmail.com, premalwd@cse.mrt.ac.lk)
*/
-
+#include "guththila_environment.h"
#include "guththila_stack.h"
guththila_stack_t *
-guththila_stack_create ()
+guththila_stack_create (guththila_environment_t *environment)
{
- guththila_stack_t *st = (guththila_stack_t *) malloc (sizeof (guththila_stack_t));
+ guththila_stack_t *st = (guththila_stack_t *) guththila_malloc (environment->allocator,sizeof (guththila_stack_t));
if (st)
{
st->pointer = 0;
@@ -38,11 +38,11 @@
int
-guththila_stack_push (guththila_stack_t *stack, guththila_token_t *tok, guththila_attribute_t *attr)
+guththila_stack_push (guththila_environment_t *environment,guththila_stack_t *stack, guththila_token_t *tok, guththila_attribute_t *attr)
{
if (stack)
{
- guththila_element_t *e = (guththila_element_t *) malloc (sizeof (guththila_element_t));
+ guththila_element_t *e = (guththila_element_t *) guththila_malloc (environment->allocator,sizeof (guththila_element_t));
e->token = tok;
e->attribute = attr;
if (stack->pointer == 0)
@@ -69,7 +69,7 @@
int
-guththila_stack_size (guththila_stack_t *stack)
+guththila_stack_size (guththila_environment_t *environment,guththila_stack_t *stack)
{
if (stack->pointer)
return stack->pointer;
@@ -79,36 +79,36 @@
void
-guththila_stack_free (guththila_stack_t *stack)
+guththila_stack_free (guththila_environment_t *environment,guththila_stack_t *stack)
{
if (stack && (stack->pointer > 0))
{
guththila_element_t *ele = stack->tail;
- guththila_stack_free_rec (stack, ele);
- free (ele);
- free (stack);
+ guththila_stack_free_rec (environment,stack, ele);
+ guththila_free (environment->allocator,ele);
+ guththila_free (environment->allocator,stack);
}
}
void
-guththila_stack_free_rec (guththila_stack_t *stack, guththila_element_t *elem)
+guththila_stack_free_rec (guththila_environment_t *environment,guththila_stack_t *stack, guththila_element_t *elem)
{
if (elem->prev == NULL)
{
- free (elem);
+ guththila_free (environment->allocator,elem);
}
else
{
elem = elem->prev;
- guththila_stack_free_rec (stack, elem);
- free (elem);
+ guththila_stack_free_rec (environment,stack, elem);
+ guththila_free (environment->allocator,elem);
}
}
guththila_element_t *
-guththila_stack_last (guththila_stack_t *stack)
+guththila_stack_last (guththila_environment_t *environment,guththila_stack_t *stack)
{
if (stack)
return stack->tail;
@@ -118,7 +118,7 @@
guththila_element_t *
-guththila_stack_pull (guththila_stack_t *stack)
+guththila_stack_pull (guththila_environment_t *environment,guththila_stack_t *stack)
{
guththila_element_t *e;
if (stack)
@@ -150,11 +150,11 @@
int
-guththila_stack_push_namespace (guththila_stack_t *stack, guththila_namespace_t *ns)
+guththila_stack_push_namespace (guththila_environment_t *environment,guththila_stack_t *stack, guththila_namespace_t *ns)
{
if (stack)
{
- guththila_element_t *e = (guththila_element_t *) malloc (sizeof (guththila_element_t));
+ guththila_element_t *e = (guththila_element_t *) guththila_malloc (environment->allocator,sizeof (guththila_element_t));
e->namespace = ns;
e->attribute = NULL;
e->token = NULL;
@@ -182,7 +182,7 @@
guththila_element_t *
-guththila_stack_pull_current (guththila_stack_t *stack)
+guththila_stack_pull_current (guththila_environment_t *environment,guththila_stack_t *stack)
{
guththila_element_t *e;
e = stack->current;
@@ -204,11 +204,11 @@
int
-guththila_stack_push_depth (guththila_stack_t *stack, guththila_depth_t *d)
+guththila_stack_push_depth (guththila_environment_t *environment,guththila_stack_t *stack, guththila_depth_t *d)
{
if (stack)
{
- guththila_element_t *e = (guththila_element_t *) malloc (sizeof (guththila_element_t));
+ guththila_element_t *e = (guththila_element_t *) guththila_malloc (environment->allocator,sizeof (guththila_element_t));
e->namespace = NULL;
e->attribute = NULL;
e->token = NULL;
@@ -237,13 +237,13 @@
void
-guththila_stack_clear (guththila_stack_t *stack)
+guththila_stack_clear (guththila_environment_t *environment,guththila_stack_t *stack)
{
guththila_element_t *e;
e = stack->tail;
if (e)
{
- guththila_stack_pull (stack);
+ guththila_stack_pull (environment,stack);
e = stack->tail;
}
stack->pointer = 0 ;
@@ -251,7 +251,7 @@
guththila_element_t *
-guththila_stack_get (guththila_stack_t *stack , int i)
+guththila_stack_get (guththila_environment_t *environment,guththila_stack_t *stack , int i)
{
if (i)
{
Modified: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_stack.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_stack.h?rev=327989&r1=327988&r2=327989&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_stack.h (original)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_stack.h Mon Oct 24 01:15:14 2005
@@ -20,7 +20,7 @@
#ifndef GUTHTHILA_STACK_H
#define GUTHTHILA_STACK_H
-
+#include "guththila_environment.h"
#include "guththila_token.h"
#include "guththila_attribute.h"
#include "guththila_namespace.h"
@@ -54,18 +54,18 @@
} guththila_stack_t;
/* stack implementation */
-guththila_stack_t *guththila_stack_create ();
-int guththila_stack_push (guththila_stack_t *st, guththila_token_t *tok, guththila_attribute_t *attr);
-int guththila_stack_size (guththila_stack_t *st);
-void guththila_stack_free (guththila_stack_t *st);
-void guththila_stack_free_rec (guththila_stack_t *st, guththila_element_t *el);
-guththila_element_t *guththila_stack_last (guththila_stack_t *st);
-guththila_element_t *guththila_stack_pull (guththila_stack_t *st);
-int guththila_stack_push_namespace (guththila_stack_t *st, guththila_namespace_t *ns);
-guththila_element_t *guththila_stack_pull_current (guththila_stack_t *st);
-int guththila_stack_push_depth (guththila_stack_t *st, guththila_depth_t *d);
-void guththila_stack_clear (guththila_stack_t *st);
-guththila_element_t *guththila_stack_get (guththila_stack_t *st, int i);
+guththila_stack_t *guththila_stack_create (guththila_environment_t *environment);
+int guththila_stack_push (guththila_environment_t *environment,guththila_stack_t *st, guththila_token_t *tok, guththila_attribute_t *attr);
+int guththila_stack_size (guththila_environment_t *environment,guththila_stack_t *st);
+void guththila_stack_free (guththila_environment_t *environment,guththila_stack_t *st);
+void guththila_stack_free_rec (guththila_environment_t *environment,guththila_stack_t *st, guththila_element_t *el);
+guththila_element_t *guththila_stack_last (guththila_environment_t *environment,guththila_stack_t *st);
+guththila_element_t *guththila_stack_pull (guththila_environment_t *environment,guththila_stack_t *st);
+int guththila_stack_push_namespace (guththila_environment_t *environment,guththila_stack_t *st, guththila_namespace_t *ns);
+guththila_element_t *guththila_stack_pull_current (guththila_environment_t *environment,guththila_stack_t *st);
+int guththila_stack_push_depth (guththila_environment_t *environment,guththila_stack_t *st, guththila_depth_t *d);
+void guththila_stack_clear (guththila_environment_t *environment,guththila_stack_t *st);
+guththila_element_t *guththila_stack_get (guththila_environment_t *environment,guththila_stack_t *st, int i);
#endif /* GUTHTHILA_STACK_H */
Added: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_stream.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_stream.c?rev=327989&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_stream.c (added)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_stream.c Mon Oct 24 01:15:14 2005
@@ -0,0 +1,77 @@
+/*
+ * 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_stream.h>
+#include <stdio.h>
+
+int guththila_stream_ops_read (void *buffer, size_t count);
+int guththila_stream_ops_write(const void *buffer, size_t count);
+
+guththila_stream_t *guththila_stream_create(guththila_allocator_t* allocator, guththila_stream_ops_t* operations)
+{
+ guththila_stream_t *stream;
+ if (!allocator)
+ return NULL;
+ stream = (guththila_stream_t*)guththila_malloc(allocator, sizeof(guththila_stream_t));
+
+ if (!stream)
+ return NULL;
+
+ if (operations)
+ stream->ops = operations;
+ else
+ {
+ stream->ops = (guththila_stream_ops_t*)guththila_malloc(allocator, sizeof(guththila_stream_ops_t));
+
+ if (!stream->ops)
+ {
+ guththila_free(allocator, stream);
+ return NULL;
+ }
+
+ stream->ops->guththila_stream_read = guththila_stream_ops_read;
+ stream->ops->guththila_stream_write = guththila_stream_ops_write;
+ }
+
+ return stream;
+}
+
+int guththila_stream_ops_read (void *buffer, size_t count)
+{
+ int i;
+ if (!buffer)
+ return -1;
+
+ i = 0;
+ for(i = 0; i < count -1; i++ )
+ {
+ ((guththila_char_t*)buffer)[i] = 'a';
+ }
+ ((guththila_char_t*)buffer)[i] = '\0';
+ return 0;
+}
+
+int guththila_stream_ops_write(const void *buffer, size_t count)
+{
+ int i ;
+ if (!buffer)
+ return -1;
+
+ i =0;
+ for(i = 0; i < count; i++)
+ printf("%c", ((guththila_char_t*)buffer)[i]);
+ return 0;
+}
Propchange: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_stream.c
------------------------------------------------------------------------------
svn:executable = *
Added: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_stream.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_stream.h?rev=327989&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_stream.h (added)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_stream.h Mon Oct 24 01:15:14 2005
@@ -0,0 +1,47 @@
+/*
+ * 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 count 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_STREAM_H
+#define GUTHTHILA_STREAM_H
+
+#include <guththila_allocator.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct guththila_stream;
+struct guththila_stream_ops;
+
+typedef struct guththila_stream_ops {
+ int (*guththila_stream_read)(void *buffer, size_t count);
+ int (*guththila_stream_write)(const void *buffer, size_t count);
+} guththila_stream_ops_t;
+
+typedef struct guththila_stream {
+ struct guththila_stream_ops *ops;
+} guththila_stream_t;
+
+guththila_stream_t *guththila_stream_create(guththila_allocator_t* allocator, guththila_stream_ops_t* operations);
+
+#define guththila_stream_read(stream, buffer, count) ((stream)->ops->guththila_stream_read(buffer, count))
+#define guththila_stream_write(stream, buffer, count) ((stream)->ops->guththila_stream_write(buffer, count))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GUTHTHILA_STREAM_H */
Propchange: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_stream.h
------------------------------------------------------------------------------
svn:executable = *
Added: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_string.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_string.c?rev=327989&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_string.c (added)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_string.c Mon Oct 24 01:15:14 2005
@@ -0,0 +1,109 @@
+/*
+ * 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_string.h>
+#include <stdlib.h>
+#include <string.h>
+#include "guththila_unicode.h"
+#include "guththila_defines.h"
+
+void* guththila_string_ops_strdup(const void* ptr)
+{
+ if (ptr)
+ return (void*)strdup(ptr);
+ else
+ return NULL;
+}
+
+int guththila_string_ops_strcmp(const guththila_char_t *s1, const guththila_char_t *s2)
+{
+ if (s1 && s2)
+ return strcmp(s1, s2);
+ else
+ return -1;
+}
+
+
+
+int guththila_string_ops_strlen(const guththila_char_t *s)
+{
+ if(s)
+ {
+
+#ifdef __UNICODE__FUNCTIONS__
+
+ return guththila_strlen_unicode(x);
+#else
+ return strlen(s);
+#endif
+
+ }
+ else
+ return -1;
+}
+guththila_char_t* guththila_string_ops_strndup(const guththila_char_t *s1,size_t len)
+{
+ if(s1)
+ {
+#ifdef __UNICODE__FUNCTIONS__
+
+ return guththila_strdup_unicode(x, y);
+
+#else
+ register size_t n;
+ register guththila_char_t *dst;
+
+ n = guththila_string_ops_strlen(s1);
+ if (len < n)
+ n = len;
+ dst = (guththila_char_t *) malloc(n+1);
+ if (dst)
+ {
+ memcpy(dst, s1, n);
+ dst[n] = '\0';
+ }
+ return dst;
+#endif
+ }
+ else
+ return NULL;
+}
+
+
+
+guththila_string_t *guththila_string_create(guththila_allocator_t *allocator,
+ guththila_string_t *string)
+{
+ if(string)
+ return string;
+
+ if (!allocator)
+ return NULL;
+
+ else
+ {
+ string = (guththila_string_t*)guththila_malloc(allocator, sizeof(guththila_string_t));
+ if(string)
+ {
+ string->guththila_string_strdup = guththila_string_ops_strdup;
+ string->guththila_string_strcmp = guththila_string_ops_strcmp;
+ string->guththila_string_strndup = guththila_string_ops_strndup;
+ string->guththila_string_strlen = guththila_string_ops_strlen;
+ return string;
+ }
+ }
+ return NULL;
+}
Propchange: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_string.c
------------------------------------------------------------------------------
svn:executable = *
Added: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_string.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_string.h?rev=327989&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_string.h (added)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_string.h Mon Oct 24 01:15:14 2005
@@ -0,0 +1,58 @@
+/*
+ * 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_STRING_H
+#define GUTHTHILA_STRING_H
+
+#include <guththila_defines.h>
+#include <guththila_allocator.h>
+//#include "guththila_unicode.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct guththila_string
+{
+ void* (*guththila_string_strdup)(const void *ptr);
+ int (*guththila_string_strcmp)(const guththila_char_t *s1, const guththila_char_t *s2);
+ guththila_char_t *(*guththila_string_strndup)(const guththila_char_t *s1,size_t n);
+ int (*guththila_string_strlen)(const guththila_char_t *s);
+ //guththila_char_t *(*guththila_string_strdup_unicode)(const guththila_char_t *s1,size_t n);
+ // guththila_UTF8_char (*guththila_string_strlen_unicode)(const guththila_char_t *);
+}guththila_string_t;
+
+/**
+* if the parsed string is null a default string is created
+* otherwise the parsed string is returned. If there isn't enough
+* memory for allocation NULL is returned.
+* @param string user defined allcator
+*/
+
+guththila_string_t *
+ guththila_string_create(guththila_allocator_t *allocator, guththila_string_t *string);
+
+#define guththila_strdup(string, ptr) ((string)->guththila_string_strdup(ptr))
+#define guththila_strcmp(string, s1, s2) ((string)->guththila_string_strcmp(s1, s2))
+#define guththila_strndup(string,s1,n) ((string)->guththila_string_strndup(s1,n))
+#define guththila_strlen(string,s1) ((string)->guththila_string_strlen(s1))
+//#define guththila_strdup_unicode(string,s1,n) ((string)->guththila_string_strdup(s1,n))
+//#define guththila_strlen_unicode(string,s1) ((string)->guththila_string_strlen_unicode(s1))
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GUTHTHILA_STRING_H */
Propchange: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_string.h
------------------------------------------------------------------------------
svn:executable = *
Modified: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_token.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_token.c?rev=327989&r1=327988&r2=327989&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_token.c (original)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_token.c Mon Oct 24 01:15:14 2005
@@ -22,19 +22,19 @@
#include "guththila_unicode.h"
guththila_token_t *
-guththila_token_create_token_buffer (int size)
+guththila_token_create_token_buffer (guththila_environment_t *environment,int size)
{
- guththila_token_t *tok = (guththila_token_t *) malloc (sizeof(guththila_token_t)*size);
+ guththila_token_t *tok = (guththila_token_t *)guththila_malloc (environment->allocator,sizeof(guththila_token_t)*size);
tok->size = size;
return tok;
}
void
-guththila_token_free_token_buffer (guththila_token_t *tok)
+guththila_token_free_token_buffer (guththila_environment_t *environment,guththila_token_t *tok)
{
if (tok)
- free (tok);
+ guththila_free (environment->allocator,tok);
}
@@ -50,7 +50,7 @@
int
-guththila_token_length (guththila_token_t *tok)
+guththila_token_length (guththila_environment_t *environment,guththila_token_t *tok)
{
if (tok->end)
return (tok->end) - (tok->start) + 1;
@@ -61,25 +61,25 @@
guththila_token_t *
-guththila_token_grow (guththila_token_t *tok)
+guththila_token_grow (guththila_environment_t *environment,guththila_token_t *tok)
{
tok->size <<= 1;
- tok = (guththila_token_t *) realloc (tok, sizeof(guththila_token_t)*tok->size);
+ tok = (guththila_token_t *) guththila_realloc (environment->allocator,tok, sizeof(guththila_token_t)*tok->size);
return tok;
}
guththila_token_t *
-guththila_token_append (guththila_token_t *tok)
+guththila_token_append (guththila_environment_t *environment,guththila_token_t *tok)
{
if (++ (tok->last) > (tok->size))
- guththila_token_grow (tok);
+ guththila_token_grow (environment,tok);
return &tok[tok->last];
}
guththila_token_t *
-guththila_token_last (guththila_token_t *tok)
+guththila_token_last (guththila_environment_t *environment,guththila_token_t *tok)
{
if (tok->last < 0)
guththila_token_exception ();
@@ -88,20 +88,20 @@
int
-guththila_token_count (guththila_token_t *tok)
+guththila_token_count (guththila_environment_t *environment,guththila_token_t *tok)
{
return tok->last;
}
-char*
-guththila_token_char_ref (char *buffer)
+guththila_char_t*
+guththila_token_char_ref (guththila_environment_t *environment,guththila_char_t *buffer)
{
int len;
int ii;
int ix;
- char *ref_buffer;
- len = strlen (buffer);
- ref_buffer = (char *) malloc (len+1);
+ guththila_char_t *ref_buffer;
+ len = guththila_strlen (environment->string,buffer);
+ ref_buffer = (guththila_char_t *) guththila_malloc (environment->allocator,len+1);
for (ii = 0, ix = 0; ii < len; ii++, ix++)
{
if (buffer[ii] == '&')
@@ -156,33 +156,33 @@
}
-char *
-guththila_token_to_string (guththila_token_t *tok, int unicode)
+guththila_char_t *
+guththila_token_to_string (guththila_environment_t *environment,guththila_token_t *tok, int unicode)
{
if (tok)
{
if (unicode == None)
{
int length;
- char *buffer;
- length = guththila_token_length (tok);
- buffer = (char *) malloc (length + 1);
+ guththila_char_t *buffer;
+ length = guththila_token_length (environment,tok);
+ buffer = (guththila_char_t *) guththila_malloc (environment->allocator,length + 1);
memcpy (buffer, tok->start, length);
buffer[length] = 0;
if (tok->ref)
- guththila_token_char_ref (buffer);
+ guththila_token_char_ref (environment,buffer);
else
return buffer;
}
else
{
int length;
- char *buffer;
- length = guththila_token_length (tok);
- buffer = (char *) malloc (length + 1);
+ guththila_char_t *buffer;
+ length = guththila_token_length (environment,tok);
+ buffer = (guththila_char_t *) guththila_malloc (environment->allocator,length + 1);
memcpy (buffer, tok->start, length);
buffer[length] = 0;
- return guththila_token_convert_utf16_to_utf8 (buffer, length);
+ return guththila_token_convert_utf16_to_utf8 (environment,buffer, length);
}
}
@@ -191,7 +191,7 @@
void
-guththila_token_relocate (guththila_token_t *tok, int offset)
+guththila_token_relocate (guththila_environment_t *environment,guththila_token_t *tok, int offset)
{
tok->start -= offset;
tok->end -= offset;
@@ -199,21 +199,21 @@
int
-guththila_token_compare (guththila_token_t *tok, const char *s, int n, int unicode_state)
+guththila_token_compare (guththila_environment_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);
else
{
- char *buffer;
- buffer = guththila_token_to_string (tok, unicode_state);
+ guththila_char_t *buffer;
+ buffer = guththila_token_to_string (environment,tok,unicode_state);
return strncmp (buffer, s, n);
}
}
int
-guththila_token_length_utf16 (unsigned int utf16_ch)
+guththila_token_length_utf16 (guththila_environment_t *environment,unsigned int utf16_ch)
{
int length;
@@ -234,12 +234,12 @@
}
-char*
-guththila_token_build_utf8 (unsigned int utf16_ch, int length)
+guththila_char_t*
+guththila_token_build_utf8 (guththila_environment_t *environment,unsigned int utf16_ch, int length)
{
guththila_UTF8_char mask = 0;
int ii = 0;
- char *buffer = (char *) calloc (length + 1, 1);
+ guththila_char_t *buffer = (guththila_char_t *) guththila_calloc (environment->allocator,length + 1, 1);
if (length == 1)
buffer[0] = utf16_ch;
else
@@ -278,22 +278,22 @@
}
-char *
-guththila_token_convert_utf16_to_utf8 (char *buffer, int length)
+guththila_char_t *
+guththila_token_convert_utf16_to_utf8 (guththila_environment_t *environment,guththila_char_t *buffer, int length)
{
unsigned int utf16_char = 0;
int length_utf16 = 0;
int total_length = 0;
- char *input_buffer = buffer;
- char *output_buffer = (char *) calloc (1, 1);
- char *output_char = 0;
+ guththila_char_t *input_buffer = buffer;
+ guththila_char_t *output_char = 0;
int ii = 0;
+ guththila_char_t *output_buffer = (guththila_char_t *) guththila_calloc (environment->allocator ,1, 1);
for (ii = 0; length > ii ; )
{
utf16_char = *((guththila_UTF16_char *)&input_buffer[ii]);
ii += 2;
- length_utf16 = guththila_token_length_utf16 (utf16_char);
- output_char = guththila_token_build_utf8 (utf16_char, length_utf16);
+ length_utf16 = guththila_token_length_utf16 (environment,utf16_char);
+ output_char = guththila_token_build_utf8 (environment,utf16_char, length_utf16);
total_length += length_utf16;
output_buffer = strcat (output_buffer, output_char);
}
Modified: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_token.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_token.h?rev=327989&r1=327988&r2=327989&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_token.h (original)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_token.h Mon Oct 24 01:15:14 2005
@@ -20,6 +20,8 @@
#ifndef GUTHTHILA_TOKEN_H
#define GUTHTHILA_TOKEN_H
+
+#include "guththila_environment.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -27,8 +29,8 @@
typedef struct guththila_token_s
{
int type;
- char *start;
- char *end;
+ guththila_char_t *start;
+ guththila_char_t *end;
int last;
int size;
int ref;
@@ -47,20 +49,20 @@
};
-guththila_token_t* guththila_token_create_token_buffer(int size);
-void guththila_token_free_token_buffer (guththila_token_t *tok);
-int guththila_token_length (guththila_token_t *tok);
+guththila_token_t* guththila_token_create_token_buffer(guththila_environment_t *environment,int size);
+void guththila_token_free_token_buffer (guththila_environment_t *environment,guththila_token_t *tok);
+int guththila_token_length (guththila_environment_t *environment,guththila_token_t *tok);
void guththila_token_exception ();
-guththila_token_t* guththila_token_append (guththila_token_t *tok);
-guththila_token_t* guththila_token_grow (guththila_token_t *tok);
-guththila_token_t* guththila_token_last (guththila_token_t *tok);
-int guththila_token_count (guththila_token_t *tok);
-char* guththila_token_to_string (guththila_token_t *tok, int unicode);
-void guththila_token_relocate (guththila_token_t *tok, int offset);
-int guththila_token_compare (guththila_token_t *tok, const char *st, int n, int unicode_state);
-char *guththila_token_convert_utf16_to_utf8 (char *buffer, int length);
-int guththila_token_length_utf16 (unsigned int utf16_ch);
-char *guththila_token_build_utf8 (unsigned int utf16_ch, int length);
-char *guththila_token_char_ref (char *buffer);
+guththila_token_t* guththila_token_append (guththila_environment_t *environment,guththila_token_t *tok);
+guththila_token_t* guththila_token_grow (guththila_environment_t *environment,guththila_token_t *tok);
+guththila_token_t* guththila_token_last (guththila_environment_t *environment,guththila_token_t *tok);
+int guththila_token_count (guththila_environment_t *environment,guththila_token_t *tok);
+guththila_char_t* guththila_token_to_string (guththila_environment_t *environment,guththila_token_t *tok, int unicode);
+void guththila_token_relocate (guththila_environment_t *environment,guththila_token_t *tok, int offset);
+int guththila_token_compare (guththila_environment_t *environment,guththila_token_t *tok, const guththila_char_t *st, int n, int unicode_state);
+guththila_char_t *guththila_token_convert_utf16_to_utf8 (guththila_environment_t *environment,guththila_char_t *buffer, int length);
+int guththila_token_length_utf16 (guththila_environment_t *environment,unsigned int utf16_ch);
+guththila_char_t *guththila_token_build_utf8 (guththila_environment_t *environment,unsigned int utf16_ch, int length);
+guththila_char_t *guththila_token_char_ref (guththila_environment_t *environment,guththila_char_t *buffer);
#endif /* GUTHTHILA_TOKEN_H */
Modified: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_unicode.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_unicode.c?rev=327989&r1=327988&r2=327989&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_unicode.c (original)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_unicode.c Mon Oct 24 01:15:14 2005
@@ -24,15 +24,15 @@
#ifdef UNICODE_OUT /* This variable for Obtain UTF-16 Output */
/*! In order to determine length of UTF-16 Buffer
- * Basicall char *p should be a Utf-16 Buffer */
+ * Basicall guththila_char_t *p should be a Utf-16 Buffer */
guththila_UTF8_char
-guththila_strlen_unicode (char *p)
+guththila_strlen_unicode (guththila_char_t *p)
{
guththila_UTF8_char len = 0;
guththila_UTF8_char d;
guththila_UTF16_char c ;
- char* s = p;
+ guththila_char_t* s = p;
c = *((guththila_UTF16_char *)&s[len]);
if (c)
{
@@ -54,12 +54,12 @@
}
/*!To Duplicate UTF-16 String */
-char *
-guththila_strdup_unicode (char* p, int length)
+guththila_char_t *
+guththila_strdup_unicode (guththila_char_t* p, int length)
{
- char *s;
- s = (char *)calloc (length+1, 1);
+ guththila_char_t *s;
+ s = (guththila_char_t *)calloc (length+1, 1);
s[length] = 0;
- return (char *)memcpy (s, p, length);
+ return (guththila_char_t *)memcpy (s, p, length);
}
#endif /*end of UNICODE_OUT definition */
Modified: webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_unicode.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_unicode.h?rev=327989&r1=327988&r2=327989&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_unicode.h (original)
+++ webservices/axis2/trunk/c/modules/xml/guththila/src/guththila_unicode.h Mon Oct 24 01:15:14 2005
@@ -34,12 +34,12 @@
enum guththila_UTF16_endianess {None=1, LE, BE};
#ifdef __UNICODE__FUNCTIONS__
-#define strlen(x) guththila_strlen_unicode(x)
+/* #define strlen(x) guththila_strlen_unicode(x)
#define strndup(x, y) guththila_strdup_unicode(x, y)
+*/
+guththila_UTF8_char guththila_strlen_unicode (guththila_char_t *);
-guththila_UTF8_char guththila_strlen_unicode (char *);
-
-char * guththila_strdup_unicode (char *, int);
+guththila_char_t * guththila_strdup_unicode (guththila_char_t *, int);
#endif /* __UNICODE__FUNCTIONS__ */