/*
 * $Header: /smsa/bsd:include/search.h:bsd  1.5  $
 * $Source: /smsa/bsd:include/search.h: $
 *
 * Copyright (c) 1988,1990 Acorn Computers Ltd., Cambridge, England
 */

#if !defined (__search_h)
#define __search_h

typedef struct entry {
    char *key;
    char *data;
} ENTRY;

typedef enum {
    FIND,
    ENTER
} ACTION;

typedef enum {
    preorder,
    postorder,
    endorder,
    leaf
} VISIT;

extern int hcreate (int /*nel*/);
extern void hdestroy (void);
extern ENTRY *hsearch (ENTRY /*item*/, ACTION /*action*/);

/*
 * In the first two function prototypes below, the type of the nelp
 * and width parameters is given as unsigned int rather than size_t if
 * size_t has not already been defined, because there is no permission
 * in XPG3 to define size_t here.  By contrast size_t can be and is
 * defined (conditionally) in e.g. <stdio.h>.
 */
#ifdef	__size_t
#define __size_t_	size_t
#else
#define __size_t_	unsigned int
#endif

extern void *lfind (void * /*key*/, void * /*base*/, __size_t_ * /*nelp*/,
		    __size_t_ /*width*/, 
		    int (* /*compar*/)(void * /*e1*/, void * /*e2*/));
extern void *lsearch (void * /*key*/, void * /*base*/, __size_t_ * /*nelp*/,
		      __size_t_ /*width*/, 
		      int (* /*compar*/)(void * /*e1*/, void * /*e2*/));

#undef	__size_t_


extern void *tsearch (void * /*key*/, void ** /*rootp*/,
		    int (* /*compar*/)(void * /*e1*/, void * /*e2*/));
extern void *tdelete (void * /*key*/, void ** /*rootp*/,
		    int (* /*compar*/)(void * /*e1*/, void * /*e2*/));
extern void *tfind (void * /*key*/, void ** /*rootp*/,
		    int (* /*compar*/)(void * /*e1*/, void * /*e2*/));
extern void twalk (void * /*root*/,
		   void (* /*action*/)(void * /*p*/, VISIT /*v*/, int /*level*/));

#endif/*__search_h*/

/* EOF search.h */
