]>
Commit | Line | Data |
---|---|---|
64bc6412 EA |
1 | /* Copyright (C) 1993 Ulrich Drepper |
2 | ||
3 | This file is intended to be included in the GNU C Library and the | |
4 | Linux C Library. So the copyright notice will be: | |
5 | ||
6 | ||
7 | Copyright (C) 1993 Free Software Foundation, Inc. | |
8 | This file is part of the GNU C Library. | |
9 | ||
10 | The GNU C Library is free software; you can redistribute it and/or | |
11 | modify it under the terms of the GNU Library General Public License as | |
12 | published by the Free Software Foundation; either version 2 of the | |
13 | License, or (at your option) any later version. | |
14 | ||
15 | The GNU C Library is distributed in the hope that it will be useful, | |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 | Library General Public License for more details. | |
19 | ||
20 | You should have received a copy of the GNU Library General Public | |
21 | License along with the GNU C Library; see the file COPYING.LIB. If | |
22 | not, write to the Free Software Foundation, Inc., 675 Mass Ave, | |
23 | Cambridge, MA 02139, USA. | |
24 | ||
25 | ||
26 | For now the file can be distributed under the LGPL. */ | |
27 | ||
28 | #ifndef _SEARCH_H | |
29 | #define _SEARCH_H | |
30 | ||
31 | #include <features.h> | |
32 | ||
33 | #define __need_size_t | |
34 | #define __need_NULL | |
35 | #include <stddef.h> | |
36 | ||
cc07f235 MNI |
37 | /* Get __compar_fn_t from stdlib.h */ |
38 | #include <stdlib.h> | |
39 | ||
64bc6412 EA |
40 | __BEGIN_DECLS |
41 | ||
cc07f235 | 42 | #if 0 |
64bc6412 EA |
43 | #ifndef __COMPAR_FN_T |
44 | #define __COMPAR_FN_T | |
45 | typedef int (*__compar_fn_t) __P ((__const __ptr_t, __const __ptr_t)); | |
46 | #endif | |
cc07f235 | 47 | #endif |
64bc6412 EA |
48 | |
49 | /* for use with hsearch(3) */ | |
50 | ||
51 | typedef struct entry { char *key; char *data; } ENTRY; | |
52 | typedef enum { FIND, ENTER } ACTION; | |
53 | ||
54 | extern ENTRY * hsearch __P((ENTRY __item, ACTION __action)); | |
55 | extern int hcreate __P((unsigned __nel)); | |
56 | extern void hdestroy __P((void)); | |
57 | ||
58 | ||
59 | /* The tsearch routines are very interesting. They make many | |
60 | * assumptions about the compiler. It assumpts that the first field | |
61 | * in node must be the "key" field, which points to the datum. | |
62 | * Everything depends on that. It is a very tricky stuff. H.J. | |
63 | */ | |
64 | /* For tsearch */ | |
65 | typedef enum { preorder, postorder, endorder, leaf } VISIT; | |
66 | ||
67 | extern void *tsearch __P((__const void * __key, void **__rootp, | |
68 | __compar_fn_t compar)); | |
69 | ||
c886fc91 | 70 | extern void *tfind __P((__const void * __key, void * __const * __rootp, |
64bc6412 EA |
71 | __compar_fn_t compar)); |
72 | ||
73 | extern void *tdelete __P((__const void * __key, void ** __rootp, | |
74 | __compar_fn_t compar)); | |
75 | ||
76 | #ifndef __ACTION_FN_T | |
77 | #define __ACTION_FN_T | |
78 | /* FYI, the first argument should be a pointer to "key". | |
79 | * Please read the man page for details. | |
80 | */ | |
81 | typedef void (*__action_fn_t) __P((__const void *__nodep, | |
82 | __const VISIT __value, | |
83 | __const int __level)); | |
84 | #endif | |
85 | ||
86 | extern void twalk __P((__const void * __root, __action_fn_t action)); | |
87 | ||
88 | ||
89 | extern void * lfind __P((__const void * __key, __const void * __base, | |
90 | size_t * __nmemb, size_t __size, | |
91 | __compar_fn_t __compar)); | |
92 | ||
93 | extern void * lsearch __P((__const void * __key, __const void * __base, | |
94 | size_t * __nmemb, size_t __size, | |
95 | __compar_fn_t __compar)); | |
96 | ||
97 | __END_DECLS | |
98 | ||
99 | #endif /* search.h */ |