root/libutil/strhash.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * Copyright (c) 2005 Tama Communications Corporation
   3  *
   4  * This file is part of GNU GLOBAL.
   5  *
   6  * This program is free software: you can redistribute it and/or modify
   7  * it under the terms of the GNU General Public License as published by
   8  * the Free Software Foundation, either version 3 of the License, or
   9  * (at your option) any later version.
  10  * 
  11  * This program is distributed in the hope that it will be useful,
  12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14  * GNU General Public License for more details.
  15  * 
  16  * You should have received a copy of the GNU General Public License
  17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18  */
  19 #ifndef _STRHASH_H
  20 #define _STRHASH_H
  21 
  22 #include "pool.h"
  23 #include "queue.h"
  24 
  25 struct sh_entry {
  26         SLIST_ENTRY(sh_entry) ptr;
  27         char *name;                     /**< name:  hash key            */
  28         void *value;                    /**< value: user structure      */
  29 };
  30 
  31 SLIST_HEAD(sh_head, sh_entry);
  32 
  33 typedef struct {
  34         int buckets;                    /**< number of buckets          */
  35         struct sh_head *htab;           /**< hash buckets                       */
  36         POOL *pool;                     /**< memory pool                        */
  37         unsigned long entries;          /**< number of entries          */
  38         /**
  39          * iterator
  40          */
  41         struct sh_entry *cur_entry;
  42         int cur_bucket;
  43 } STRHASH;
  44 
  45 STRHASH *strhash_open(int);
  46 struct sh_entry *strhash_assign(STRHASH *, const char *, int);
  47 char * strhash_strdup(STRHASH *, const char *, int);
  48 struct sh_entry *strhash_first(STRHASH *);
  49 struct sh_entry *strhash_next(STRHASH *);
  50 void strhash_reset(STRHASH *);
  51 void strhash_close(STRHASH *);
  52 
  53 #endif /* ! _STRHASH_H */

/* [previous][next][first][last][top][bottom][index][help] */