• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/gettext-0.17/gettext-tools/gnulib-lib/
1/* Copyright (C) 1995, 2000-2003, 2005-2006 Free Software Foundation, Inc.
2
3   The GNU C Library is free software; you can redistribute it and/or
4   modify it under the terms of the GNU General Public License as
5   published by the Free Software Foundation; either version 2 of the
6   License, or (at your option) any later version.
7
8   The GNU C Library is distributed in the hope that it will be useful,
9   but WITHOUT ANY WARRANTY; without even the implied warranty of
10   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11   Library General Public License for more details.
12
13   You should have received a copy of the GNU General Public
14   License along with the GNU C Library; see the file COPYING.LIB.  If
15   not, write to the Free Software Foundation, Inc., 51 Franklin Street,
16   Fifth Floor, Boston, MA 02110-1301, USA.  */
17
18#ifndef _HASH_H
19#define _HASH_H
20
21#include "obstack.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27struct hash_entry;
28
29typedef struct hash_table
30{
31  unsigned long int size;   /* Number of allocated entries.  */
32  unsigned long int filled; /* Number of used entries.  */
33  struct hash_entry *first; /* Pointer to head of list of entries.  */
34  struct hash_entry *table; /* Pointer to array of entries.  */
35  struct obstack mem_pool;  /* Memory pool holding the keys.  */
36}
37hash_table;
38
39/* Initialize a hash table.  INIT_SIZE > 1 is the initial number of available
40   entries.
41   Return 0 upon successful completion, -1 upon memory allocation error.  */
42extern int hash_init (hash_table *htab, unsigned long int init_size);
43
44/* Delete a hash table's contents.
45   Return 0 always.  */
46extern int hash_destroy (hash_table *htab);
47
48/* Look up the value of a key in the given table.
49   If found, return 0 and set *RESULT to it.  Otherwise return -1.  */
50extern int hash_find_entry (hash_table *htab,
51			    const void *key, size_t keylen,
52			    void **result);
53
54/* Try to insert the pair (KEY[0..KEYLEN-1], DATA) in the hash table.
55   Return non-NULL (more precisely, the address of the KEY inside the table's
56   memory pool) if successful, or NULL if there is already an entry with the
57   given key.  */
58extern const void * hash_insert_entry (hash_table *htab,
59				       const void *key, size_t keylen,
60				       void *data);
61
62/* Insert the pair (KEY[0..KEYLEN-1], DATA) in the hash table.
63   Return 0.  */
64extern int hash_set_value (hash_table *htab,
65			   const void *key, size_t keylen,
66			   void *data);
67
68/* Steps *PTR forward to the next used entry in the given hash table.  *PTR
69   should be initially set to NULL.  Store information about the next entry
70   in *KEY, *KEYLEN, *DATA.
71   Return 0 normally, -1 when the whole hash table has been traversed.  */
72extern int hash_iterate (hash_table *htab, void **ptr,
73			 const void **key, size_t *keylen,
74			 void **data);
75
76/* Steps *PTR forward to the next used entry in the given hash table.  *PTR
77   should be initially set to NULL.  Store information about the next entry
78   in *KEY, *KEYLEN, *DATAP.  *DATAP is set to point to the storage of the
79   value; modifying **DATAP will modify the value of the entry.
80   Return 0 normally, -1 when the whole hash table has been traversed.  */
81extern int hash_iterate_modify (hash_table *htab, void **ptr,
82				const void **key, size_t *keylen,
83				void ***datap);
84
85/* Given SEED > 1, return the smallest odd prime number >= SEED.  */
86extern unsigned long int next_prime (unsigned long int seed);
87
88#ifdef __cplusplus
89}
90#endif
91
92#endif /* not _HASH_H */
93