1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
/*
* String hash table.
* Copyright (c) 1995, 1996, 1997 Markku Rossi.
*
* Author: Markku Rossi <mtr@iki.fi>
*/
/*
* Enscript is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Enscript is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Enscript. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef STRHASH_H
#define STRHASH_H
#ifndef ___P
#if PROTOTYPES
#define ___P(protos) protos
#else /* no PROTOTYPES */
#define ___P(protos) ()
#endif /* no PROTOTYPES */
#endif
typedef struct stringhash_st *StringHashPtr;
/*
* Init a hash and return a hash handle or NULL if there were errors.
*/
StringHashPtr strhash_init ___P ((void));
/*
* Free hash <hash>. Frees all resources that hash has allocated. <hash>
* shouldn't be used after this function is called.
*/
void strhash_free ___P ((StringHashPtr hash));
/*
* Put key <key> to hash <hash>. <data> will be bind to <key>. Returns
* true (1) if operation was successful or false (0) otherwise. If <key>
* is already bind to another data, then <old_data> will be set to old
* data. Otherwise it will be set to NULL.
*/
int strhash_put ___P ((StringHashPtr hash, char *key, int keylen, void *data,
void **old_data_return));
/*
* Get data associated to key <key>. Data is returned in <*data>.
* Returns true (1) is key was found or false (0) otherwise.
*/
int strhash_get ___P ((StringHashPtr hash, const char *key, int keylen,
void **data_return));
/*
* Deletes key <key> form <hash>. Data is returned in <*data>. Returns
* true (1) if <key> was found or false (0) if <key> was not found or
* errors were encountered.
*/
int strhash_delete ___P ((StringHashPtr hash, const char *key, int keylen,
void **data_return));
/*
* Get first item from hash <hash>. Returns 1 if there were items
* or 0 otherwise.
*/
int strhash_get_first ___P ((StringHashPtr hash, char **key_return,
int *keylen_return, void **data_return));
/*
* Get next item from hash <hash>. Returns 1 if there were items
* or 0 otherwise.
*/
int strhash_get_next ___P ((StringHashPtr hash, char **key_return,
int *keylen_return, void **data_return));
#endif /* not STRHASH_H */
|