From febbd12d00883a716a9edca25011f8aa306b859b Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sat, 25 Jun 2011 18:18:57 -0400 Subject: XSI search.h API implementation by Szabolcs Nagy --- include/search.h | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/search.h b/include/search.h index 9254ed0c..f1246ade 100644 --- a/include/search.h +++ b/include/search.h @@ -1,6 +1,40 @@ #ifndef _SEARCH_H #define _SEARCH_H -// FIXME!!! +#ifdef __cplusplus +extern "C" { +#endif + +#define __NEED_size_t +#include + +typedef enum { FIND, ENTER } ACTION; +typedef enum { preorder, postorder, endorder, leaf } VISIT; + +typedef struct { + char *key; + void *data; +} ENTRY; + +int hcreate(size_t); +void hdestroy(void); +ENTRY *hsearch(ENTRY, ACTION); + +void insque(void *, void *); +void remque(void *); + +void *lsearch(const void *, void *, size_t *, size_t, + int (*)(const void *, const void *)); +void *lfind(const void *, const void *, size_t *, size_t, + int (*)(const void *, const void *)); + +void *tdelete(const void *, void **, int(*)(const void *, const void *)); +void *tfind(const void *, void *const *, int(*)(const void *, const void *)); +void *tsearch(const void *, void **, int (*)(const void *, const void *)); +void twalk(const void *, void (*)(const void *, VISIT, int)); + +#ifdef __cplusplus +} +#endif #endif -- cgit v1.2.1