3 * Copyright (c) 1995, 1996, 1997 Markku Rossi.
5 * Author: Markku Rossi <mtr@iki.fi>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2, or (at your option)
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; see the file COPYING. If not, write to
21 * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
30 #define ___P(protos) protos
31 #else /* no PROTOTYPES */
32 #define ___P(protos) ()
33 #endif /* no PROTOTYPES */
36 typedef struct stringhash_st *StringHashPtr;
39 * Init a hash and return a hash handle or NULL if there were errors.
41 StringHashPtr strhash_init ___P ((void));
44 * Free hash <hash>. Frees all resources that hash has allocated. <hash>
45 * shouldn't be used after this function is called.
47 void strhash_free ___P ((StringHashPtr hash));
50 * Put key <key> to hash <hash>. <data> will be bind to <key>. Returns
51 * true (1) if operation was successful or false (0) otherwise. If <key>
52 * is already bind to another data, then <old_data> will be set to old
53 * data. Otherwise it will be set to NULL.
55 int strhash_put ___P ((StringHashPtr hash, char *key, int keylen, void *data,
56 void **old_data_return));
59 * Get data associated to key <key>. Data is returned in <*data>.
60 * Returns true (1) is key was found or false (0) otherwise.
62 int strhash_get ___P ((StringHashPtr hash, const char *key, int keylen,
66 * Deletes key <key> form <hash>. Data is returned in <*data>. Returns
67 * true (1) if <key> was found or false (0) if <key> was not found or
68 * errors were encountered.
70 int strhash_delete ___P ((StringHashPtr hash, const char *key, int keylen,
74 * Get first item from hash <hash>. Returns 1 if there were items
77 int strhash_get_first ___P ((StringHashPtr hash, char **key_return,
78 int *keylen_return, void **data_return));
81 * Get next item from hash <hash>. Returns 1 if there were items
84 int strhash_get_next ___P ((StringHashPtr hash, char **key_return,
85 int *keylen_return, void **data_return));
87 #endif /* not STRHASH_H */