codekingpro/portable-devtools
115k
1/*2 * Summary: Chained hash tables3 * Description: This module implements the hash table support used in4 * various places in the library.5 *6 * Copy: See Copyright for the status of this software.7 *8 * Author: Bjorn Reese <bjorn.reese@systematic.dk>9 */10 11#ifndef __XML_HASH_H__12#define __XML_HASH_H__13 14#ifdef __cplusplus15extern "C" {16#endif17 18/*19 * The hash table.20 */21typedef struct _xmlHashTable xmlHashTable;22typedef xmlHashTable *xmlHashTablePtr;23 24#ifdef __cplusplus25}26#endif27 28#include <libxml/xmlversion.h>29#include <libxml/parser.h>30#include <libxml/dict.h>31 32#ifdef __cplusplus33extern "C" {34#endif35 36/*37 * Recent version of gcc produce a warning when a function pointer is assigned38 * to an object pointer, or vice versa. The following macro is a dirty hack39 * to allow suppression of the warning. If your architecture has function40 * pointers which are a different size than a void pointer, there may be some41 * serious trouble within the library.42 */43/**44 * XML_CAST_FPTR:45 * @fptr: pointer to a function46 *47 * Macro to do a casting from an object pointer to a48 * function pointer without encountering a warning from49 * gcc50 *51 * #define XML_CAST_FPTR(fptr) (*(void **)(&fptr))52 * This macro violated ISO C aliasing rules (gcc4 on s390 broke)53 * so it is disabled now54 */55 56#define XML_CAST_FPTR(fptr) fptr57 58 59/*60 * function types:61 */62/**63 * xmlHashDeallocator:64 * @payload: the data in the hash65 * @name: the name associated66 *67 * Callback to free data from a hash.68 */69typedef void (*xmlHashDeallocator)(void *payload, const xmlChar *name);70/**71 * xmlHashCopier:72 * @payload: the data in the hash73 * @name: the name associated74 *75 * Callback to copy data from a hash.76 *77 * Returns a copy of the data or NULL in case of error.78 */79typedef void *(*xmlHashCopier)(void *payload, const xmlChar *name);80/**81 * xmlHashScanner:82 * @payload: the data in the hash83 * @data: extra scanner data84 * @name: the name associated85 *86 * Callback when scanning data in a hash with the simple scanner.87 */88typedef void (*xmlHashScanner)(void *payload, void *data, const xmlChar *name);89/**90 * xmlHashScannerFull:91 * @payload: the data in the hash92 * @data: extra scanner data93 * @name: the name associated94 * @name2: the second name associated95 * @name3: the third name associated96 *97 * Callback when scanning data in a hash with the full scanner.98 */99typedef void (*xmlHashScannerFull)(void *payload, void *data,100 const xmlChar *name, const xmlChar *name2,101 const xmlChar *name3);102 103/*104 * Constructor and destructor.105 */106XMLPUBFUN xmlHashTablePtr107 xmlHashCreate (int size);108XMLPUBFUN xmlHashTablePtr109 xmlHashCreateDict(int size,110 xmlDictPtr dict);111XMLPUBFUN void112 xmlHashFree (xmlHashTablePtr table,113 xmlHashDeallocator f);114XMLPUBFUN void115 xmlHashDefaultDeallocator(void *entry,116 const xmlChar *name);117 118/*119 * Add a new entry to the hash table.120 */121XMLPUBFUN int122 xmlHashAddEntry (xmlHashTablePtr table,123 const xmlChar *name,124 void *userdata);125XMLPUBFUN int126 xmlHashUpdateEntry(xmlHashTablePtr table,127 const xmlChar *name,128 void *userdata,129 xmlHashDeallocator f);130XMLPUBFUN int131 xmlHashAddEntry2(xmlHashTablePtr table,132 const xmlChar *name,133 const xmlChar *name2,134 void *userdata);135XMLPUBFUN int136 xmlHashUpdateEntry2(xmlHashTablePtr table,137 const xmlChar *name,138 const xmlChar *name2,139 void *userdata,140 xmlHashDeallocator f);141XMLPUBFUN int142 xmlHashAddEntry3(xmlHashTablePtr table,143 const xmlChar *name,144 const xmlChar *name2,145 const xmlChar *name3,146 void *userdata);147XMLPUBFUN int148 xmlHashUpdateEntry3(xmlHashTablePtr table,149 const xmlChar *name,150 const xmlChar *name2,151 const xmlChar *name3,152 void *userdata,153 xmlHashDeallocator f);154 155/*156 * Remove an entry from the hash table.157 */158XMLPUBFUN int159 xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name,160 xmlHashDeallocator f);161XMLPUBFUN int162 xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name,163 const xmlChar *name2, xmlHashDeallocator f);164XMLPUBFUN int 165 xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name,166 const xmlChar *name2, const xmlChar *name3,167 xmlHashDeallocator f);168 169/*170 * Retrieve the userdata.171 */172XMLPUBFUN void *173 xmlHashLookup (xmlHashTablePtr table,174 const xmlChar *name);175XMLPUBFUN void *176 xmlHashLookup2 (xmlHashTablePtr table,177 const xmlChar *name,178 const xmlChar *name2);179XMLPUBFUN void *180 xmlHashLookup3 (xmlHashTablePtr table,181 const xmlChar *name,182 const xmlChar *name2,183 const xmlChar *name3);184XMLPUBFUN void *185 xmlHashQLookup (xmlHashTablePtr table,186 const xmlChar *name,187 const xmlChar *prefix);188XMLPUBFUN void *189 xmlHashQLookup2 (xmlHashTablePtr table,190 const xmlChar *name,191 const xmlChar *prefix,192 const xmlChar *name2,193 const xmlChar *prefix2);194XMLPUBFUN void *195 xmlHashQLookup3 (xmlHashTablePtr table,196 const xmlChar *name,197 const xmlChar *prefix,198 const xmlChar *name2,199 const xmlChar *prefix2,200 const xmlChar *name3,201 const xmlChar *prefix3);202 203/*204 * Helpers.205 */206XMLPUBFUN xmlHashTablePtr207 xmlHashCopy (xmlHashTablePtr table,208 xmlHashCopier f);209XMLPUBFUN int210 xmlHashSize (xmlHashTablePtr table);211XMLPUBFUN void212 xmlHashScan (xmlHashTablePtr table,213 xmlHashScanner f,214 void *data);215XMLPUBFUN void216 xmlHashScan3 (xmlHashTablePtr table,217 const xmlChar *name,218 const xmlChar *name2,219 const xmlChar *name3,220 xmlHashScanner f,221 void *data);222XMLPUBFUN void223 xmlHashScanFull (xmlHashTablePtr table,224 xmlHashScannerFull f,225 void *data);226XMLPUBFUN void227 xmlHashScanFull3(xmlHashTablePtr table,228 const xmlChar *name,229 const xmlChar *name2,230 const xmlChar *name3,231 xmlHashScannerFull f,232 void *data);233#ifdef __cplusplus234}235#endif236#endif /* ! __XML_HASH_H__ */237 