Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:19:29

0001 /*
0002  * Summary: Chained hash tables
0003  * Description: This module implements the hash table support used in
0004  *      various places in the library.
0005  *
0006  * Copy: See Copyright for the status of this software.
0007  *
0008  * Author: Bjorn Reese <bjorn.reese@systematic.dk>
0009  */
0010 
0011 #ifndef __XML_HASH_H__
0012 #define __XML_HASH_H__
0013 
0014 #include <libxml/xmlversion.h>
0015 #include <libxml/dict.h>
0016 #include <libxml/xmlstring.h>
0017 
0018 #ifdef __cplusplus
0019 extern "C" {
0020 #endif
0021 
0022 /*
0023  * The hash table.
0024  */
0025 typedef struct _xmlHashTable xmlHashTable;
0026 typedef xmlHashTable *xmlHashTablePtr;
0027 
0028 /*
0029  * Recent version of gcc produce a warning when a function pointer is assigned
0030  * to an object pointer, or vice versa.  The following macro is a dirty hack
0031  * to allow suppression of the warning.  If your architecture has function
0032  * pointers which are a different size than a void pointer, there may be some
0033  * serious trouble within the library.
0034  */
0035 /**
0036  * XML_CAST_FPTR:
0037  * @fptr:  pointer to a function
0038  *
0039  * Macro to do a casting from an object pointer to a
0040  * function pointer without encountering a warning from
0041  * gcc
0042  *
0043  * #define XML_CAST_FPTR(fptr) (*(void **)(&fptr))
0044  * This macro violated ISO C aliasing rules (gcc4 on s390 broke)
0045  * so it is disabled now
0046  */
0047 
0048 #define XML_CAST_FPTR(fptr) fptr
0049 
0050 /*
0051  * function types:
0052  */
0053 /**
0054  * xmlHashDeallocator:
0055  * @payload:  the data in the hash
0056  * @name:  the name associated
0057  *
0058  * Callback to free data from a hash.
0059  */
0060 typedef void (*xmlHashDeallocator)(void *payload, const xmlChar *name);
0061 /**
0062  * xmlHashCopier:
0063  * @payload:  the data in the hash
0064  * @name:  the name associated
0065  *
0066  * Callback to copy data from a hash.
0067  *
0068  * Returns a copy of the data or NULL in case of error.
0069  */
0070 typedef void *(*xmlHashCopier)(void *payload, const xmlChar *name);
0071 /**
0072  * xmlHashScanner:
0073  * @payload:  the data in the hash
0074  * @data:  extra scanner data
0075  * @name:  the name associated
0076  *
0077  * Callback when scanning data in a hash with the simple scanner.
0078  */
0079 typedef void (*xmlHashScanner)(void *payload, void *data, const xmlChar *name);
0080 /**
0081  * xmlHashScannerFull:
0082  * @payload:  the data in the hash
0083  * @data:  extra scanner data
0084  * @name:  the name associated
0085  * @name2:  the second name associated
0086  * @name3:  the third name associated
0087  *
0088  * Callback when scanning data in a hash with the full scanner.
0089  */
0090 typedef void (*xmlHashScannerFull)(void *payload, void *data,
0091                    const xmlChar *name, const xmlChar *name2,
0092                    const xmlChar *name3);
0093 
0094 /*
0095  * Constructor and destructor.
0096  */
0097 XMLPUBFUN xmlHashTablePtr
0098         xmlHashCreate       (int size);
0099 XMLPUBFUN xmlHashTablePtr
0100         xmlHashCreateDict   (int size,
0101                      xmlDictPtr dict);
0102 XMLPUBFUN void
0103         xmlHashFree     (xmlHashTablePtr hash,
0104                      xmlHashDeallocator dealloc);
0105 XMLPUBFUN void
0106         xmlHashDefaultDeallocator(void *entry,
0107                      const xmlChar *name);
0108 
0109 /*
0110  * Add a new entry to the hash table.
0111  */
0112 XMLPUBFUN int
0113         xmlHashAdd      (xmlHashTablePtr hash,
0114                                  const xmlChar *name,
0115                                  void *userdata);
0116 XMLPUBFUN int
0117         xmlHashAddEntry     (xmlHashTablePtr hash,
0118                                  const xmlChar *name,
0119                                  void *userdata);
0120 XMLPUBFUN int
0121         xmlHashUpdateEntry  (xmlHashTablePtr hash,
0122                                  const xmlChar *name,
0123                                  void *userdata,
0124                      xmlHashDeallocator dealloc);
0125 XMLPUBFUN int
0126         xmlHashAdd2     (xmlHashTablePtr hash,
0127                                  const xmlChar *name,
0128                                  const xmlChar *name2,
0129                                  void *userdata);
0130 XMLPUBFUN int
0131         xmlHashAddEntry2    (xmlHashTablePtr hash,
0132                                  const xmlChar *name,
0133                                  const xmlChar *name2,
0134                                  void *userdata);
0135 XMLPUBFUN int
0136         xmlHashUpdateEntry2 (xmlHashTablePtr hash,
0137                                  const xmlChar *name,
0138                                  const xmlChar *name2,
0139                                  void *userdata,
0140                      xmlHashDeallocator dealloc);
0141 XMLPUBFUN int
0142         xmlHashAdd3     (xmlHashTablePtr hash,
0143                                  const xmlChar *name,
0144                                  const xmlChar *name2,
0145                                  const xmlChar *name3,
0146                                  void *userdata);
0147 XMLPUBFUN int
0148         xmlHashAddEntry3    (xmlHashTablePtr hash,
0149                                  const xmlChar *name,
0150                                  const xmlChar *name2,
0151                                  const xmlChar *name3,
0152                                  void *userdata);
0153 XMLPUBFUN int
0154         xmlHashUpdateEntry3 (xmlHashTablePtr hash,
0155                                  const xmlChar *name,
0156                                  const xmlChar *name2,
0157                                  const xmlChar *name3,
0158                                  void *userdata,
0159                      xmlHashDeallocator dealloc);
0160 
0161 /*
0162  * Remove an entry from the hash table.
0163  */
0164 XMLPUBFUN int
0165         xmlHashRemoveEntry  (xmlHashTablePtr hash,
0166                      const xmlChar *name,
0167                      xmlHashDeallocator dealloc);
0168 XMLPUBFUN int
0169         xmlHashRemoveEntry2 (xmlHashTablePtr hash,
0170                      const xmlChar *name,
0171                      const xmlChar *name2,
0172                      xmlHashDeallocator dealloc);
0173 XMLPUBFUN int 
0174         xmlHashRemoveEntry3 (xmlHashTablePtr hash,
0175                      const xmlChar *name,
0176                      const xmlChar *name2,
0177                      const xmlChar *name3,
0178                      xmlHashDeallocator dealloc);
0179 
0180 /*
0181  * Retrieve the payload.
0182  */
0183 XMLPUBFUN void *
0184         xmlHashLookup       (xmlHashTablePtr hash,
0185                      const xmlChar *name);
0186 XMLPUBFUN void *
0187         xmlHashLookup2      (xmlHashTablePtr hash,
0188                      const xmlChar *name,
0189                      const xmlChar *name2);
0190 XMLPUBFUN void *
0191         xmlHashLookup3      (xmlHashTablePtr hash,
0192                      const xmlChar *name,
0193                      const xmlChar *name2,
0194                      const xmlChar *name3);
0195 XMLPUBFUN void *
0196         xmlHashQLookup      (xmlHashTablePtr hash,
0197                      const xmlChar *prefix,
0198                      const xmlChar *name);
0199 XMLPUBFUN void *
0200         xmlHashQLookup2     (xmlHashTablePtr hash,
0201                      const xmlChar *prefix,
0202                      const xmlChar *name,
0203                      const xmlChar *prefix2,
0204                      const xmlChar *name2);
0205 XMLPUBFUN void *
0206         xmlHashQLookup3     (xmlHashTablePtr hash,
0207                      const xmlChar *prefix,
0208                      const xmlChar *name,
0209                      const xmlChar *prefix2,
0210                      const xmlChar *name2,
0211                      const xmlChar *prefix3,
0212                      const xmlChar *name3);
0213 
0214 /*
0215  * Helpers.
0216  */
0217 XMLPUBFUN xmlHashTablePtr
0218         xmlHashCopySafe     (xmlHashTablePtr hash,
0219                      xmlHashCopier copy,
0220                      xmlHashDeallocator dealloc);
0221 XMLPUBFUN xmlHashTablePtr
0222         xmlHashCopy     (xmlHashTablePtr hash,
0223                      xmlHashCopier copy);
0224 XMLPUBFUN int
0225         xmlHashSize     (xmlHashTablePtr hash);
0226 XMLPUBFUN void
0227         xmlHashScan     (xmlHashTablePtr hash,
0228                      xmlHashScanner scan,
0229                      void *data);
0230 XMLPUBFUN void
0231         xmlHashScan3        (xmlHashTablePtr hash,
0232                      const xmlChar *name,
0233                      const xmlChar *name2,
0234                      const xmlChar *name3,
0235                      xmlHashScanner scan,
0236                      void *data);
0237 XMLPUBFUN void
0238         xmlHashScanFull     (xmlHashTablePtr hash,
0239                      xmlHashScannerFull scan,
0240                      void *data);
0241 XMLPUBFUN void
0242         xmlHashScanFull3    (xmlHashTablePtr hash,
0243                      const xmlChar *name,
0244                      const xmlChar *name2,
0245                      const xmlChar *name3,
0246                      xmlHashScannerFull scan,
0247                      void *data);
0248 #ifdef __cplusplus
0249 }
0250 #endif
0251 #endif /* ! __XML_HASH_H__ */