Home | History | Annotate | Line # | Download | only in util
      1 /*	$NetBSD: binhash.h,v 1.3 2022/10/08 16:12:50 christos Exp $	*/
      2 
      3 #ifndef _BINHASH_H_INCLUDED_
      4 #define _BINHASH_H_INCLUDED_
      5 
      6 /*++
      7 /* NAME
      8 /*	binhash 3h
      9 /* SUMMARY
     10 /*	hash table manager
     11 /* SYNOPSIS
     12 /*	#include <binhash.h>
     13 /* DESCRIPTION
     14 /* .nf
     15 
     16  /* Structure of one hash table entry. */
     17 
     18 typedef struct BINHASH_INFO {
     19     void   *key;			/* lookup key */
     20     ssize_t key_len;			/* key length */
     21     void   *value;			/* associated value */
     22     struct BINHASH_INFO *next;		/* colliding entry */
     23     struct BINHASH_INFO *prev;		/* colliding entry */
     24 } BINHASH_INFO;
     25 
     26  /* Structure of one hash table. */
     27 
     28 typedef struct BINHASH {
     29     ssize_t size;			/* length of entries array */
     30     ssize_t used;			/* number of entries in table */
     31     BINHASH_INFO **data;		/* entries array, auto-resized */
     32     BINHASH_INFO **seq_bucket;		/* current sequence hash bucket */
     33     BINHASH_INFO **seq_element;		/* current sequence element */
     34 } BINHASH;
     35 
     36 extern BINHASH *binhash_create(ssize_t);
     37 extern BINHASH_INFO *binhash_enter(BINHASH *, const void *, ssize_t, void *);
     38 extern BINHASH_INFO *binhash_locate(BINHASH *, const void *, ssize_t);
     39 extern void *binhash_find(BINHASH *, const void *, ssize_t);
     40 extern void binhash_delete(BINHASH *, const void *, ssize_t, void (*) (void *));
     41 extern void binhash_free(BINHASH *, void (*) (void *));
     42 extern void binhash_walk(BINHASH *, void (*) (BINHASH_INFO *, void *), void *);
     43 extern BINHASH_INFO **binhash_list(BINHASH *);
     44 extern BINHASH_INFO *binhash_sequence(BINHASH *, int);
     45 
     46 #define BINHASH_SEQ_FIRST	0
     47 #define BINHASH_SEQ_NEXT	1
     48 #define BINHASH_SEQ_STOP	(-1)
     49 
     50 /* LICENSE
     51 /* .ad
     52 /* .fi
     53 /*	The Secure Mailer license must be distributed with this software.
     54 /* AUTHOR(S)
     55 /*	Wietse Venema
     56 /*	IBM T.J. Watson Research
     57 /*	P.O. Box 704
     58 /*	Yorktown Heights, NY 10598, USA
     59 /* CREATION DATE
     60 /*	Thu Feb 20 16:54:29 EST 1997
     61 /* LAST MODIFICATION
     62 /*	%E% %U%
     63 /* VERSION/RELEASE
     64 /*	%I%
     65 /*--*/
     66 
     67 #endif
     68