#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef __CYGWIN__ #include #include #endif #include #include #include "xmlparse.h" #ifdef HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ /* ** Arrange to use either varargs or stdargs */ #define MAXSHORTSTR 203 /* max short string length */ #define QUAD_T unsigned long long #ifdef __STDC__ #include # define VA_LOCAL_DECL va_list ap; # define VA_START(f) va_start(ap, f) # define VA_END va_end(ap) #else /* __STDC__ */ # include # define VA_LOCAL_DECL va_list ap; # define VA_START(f) va_start(ap) # define VA_END va_end(ap) #endif /* __STDC__ */ #ifndef INCL_LIBXODE_H #define INCL_LIBXODE_H #ifdef __cplusplus extern "C" { #endif #ifndef HAVE_SNPRINTF extern int ap_snprintf(char *, size_t, const char *, ...); #define snprintf ap_snprintf #endif #ifndef HAVE_VSNPRINTF extern int ap_vsnprintf(char *, size_t, const char *, va_list ap); #define vsnprintf ap_vsnprintf #endif #define ZONE zonestr(__FILE__,__LINE__) char *zonestr(char *file, int line); /* --------------------------------------------------------- */ /* */ /* Pool-based memory management routines */ /* */ /* --------------------------------------------------------- */ #undef POOL_DEBUG /* flip these, this should be a prime number for top # of pools debugging #define POOL_DEBUG 40009 */ /* pheap - singular allocation of memory */ struct pheap { void *block; int size, used; }; /* pool_cleaner - callback type which is associated with a pool entry; invoked when the pool entry is free'd */ typedef void (*pool_cleaner)(void *arg); /* pfree - a linked list node which stores an allocation chunk, plus a callback */ struct pfree { pool_cleaner f; void *arg; struct pheap *heap; struct pfree *next; }; /* pool - base node for a pool. Maintains a linked list of pool entries (pfree) */ typedef struct pool_struct { int size; struct pfree *cleanup; struct pheap *heap; #ifdef POOL_DEBUG char name[8], zone[32]; int lsize; } _pool, *pool; #define pool_new() _pool_new(ZONE) #define pool_heap(i) _pool_new_heap(i,ZONE) #else } _pool, *pool; #define pool_heap(i) _pool_new_heap(i,NULL) #define pool_new() _pool_new(NULL) #endif pool _pool_new(char *zone); /* new pool :) */ pool _pool_new_heap(int size, char *zone); /* creates a new memory pool with an initial heap size */ void *pmalloc(pool p, int size); /* wrapper around malloc, takes from the pool, cleaned up automatically */ void *pmalloc_x(pool p, int size, char c); /* Wrapper around pmalloc which prefils buffer with c */ void *pmalloco(pool p, int size); /* YAPW for zeroing the block */ char *pstrdup(pool p, const char *src); /* wrapper around strdup, gains mem from pool */ void pool_stat(int full); /* print to stderr the changed pools and reset */ void pool_cleanup(pool p, pool_cleaner f, void *arg); /* calls f(arg) before the pool is freed during cleanup */ void pool_free(pool p); /* calls the cleanup functions, frees all the data on the pool, and deletes the pool itself */ /* --------------------------------------------------------- */ /* */ /* Socket helper stuff */ /* */ /* --------------------------------------------------------- */ #ifndef MAXHOSTNAMELEN #define MAXHOSTNAMELEN 64 #endif #define NETSOCKET_SERVER 0 #define NETSOCKET_CLIENT 1 #define NETSOCKET_UDP 2 #ifndef WIN32 int make_netsocket(u_short port, char *host, int type); struct in_addr *make_addr(char *host); int set_fd_close_on_exec(int fd, int flag); #endif /* --------------------------------------------------------- */ /* */ /* SHA calculations */ /* */ /* --------------------------------------------------------- */ #if (SIZEOF_INT == 4) typedef unsigned int uint32; #elif (SIZEOF_SHORT == 4) typedef unsigned short uint32; #else typedef unsigned int uint32; #endif /* HAVEUINT32 */ int sha_hash(int *data, int *hash); int sha_init(int *hash); char *shahash(char *str); /* NOT THREAD SAFE */ void shahash_r(const char* str, char hashbuf[40]); /* USE ME */ int strprintsha(char *dest, int *hashval); /* --------------------------------------------------------- */ /* */ /* Hashtable functions */ /* */ /* --------------------------------------------------------- */ typedef int (*KEYHASHFUNC)(const void *key); typedef int (*KEYCOMPAREFUNC)(const void *key1, const void *key2); typedef int (*TABLEWALKFUNC)(void *user_data, const void *key, void *data); typedef void *HASHTABLE; HASHTABLE ghash_create(int buckets, KEYHASHFUNC hash, KEYCOMPAREFUNC cmp); void ghash_destroy(HASHTABLE tbl); void *ghash_get(HASHTABLE tbl, const void *key); int ghash_put(HASHTABLE tbl, const void *key, void *value); int ghash_remove(HASHTABLE tbl, const void *key); int ghash_walk(HASHTABLE tbl, TABLEWALKFUNC func, void *user_data); int str_hash_code(
/*
The contents of this file are subject to the Mozilla Public License
Version 1.1 (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.mozilla.org/MPL/

Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific language governing rights and limitations
under the License.

The Original Code is expat.

The Initial Developer of the Original Code is James Clark.
Portions created by James Clark are Copyright (C) 1998, 1999
James Clark. All Rights Reserved.

Contributor(s):

Alternatively, the contents of this file may be used under the terms
of the GNU General Public License (the "GPL"), in which case the
provisions of the GPL are applicable instead of those above.  If you
wish to allow use of your version of this file only under the terms of
the GPL and not to allow others to use your version of this file under
the MPL, indicate your decision by deleting the provisions above and
replace them with the notice and other provisions required by the
GPL. If you do not delete the provisions abo