1 |
199 |
simons |
/* 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 |
|
|
|
37 |
|
|
__BEGIN_DECLS
|
38 |
|
|
|
39 |
|
|
#ifndef __COMPAR_FN_T
|
40 |
|
|
#define __COMPAR_FN_T
|
41 |
|
|
typedef int (*__compar_fn_t) __P ((__const __ptr_t, __const __ptr_t));
|
42 |
|
|
#endif
|
43 |
|
|
|
44 |
|
|
/* for use with hsearch(3) */
|
45 |
|
|
|
46 |
|
|
typedef struct entry { char *key; char *data; } ENTRY;
|
47 |
|
|
typedef enum { FIND, ENTER } ACTION;
|
48 |
|
|
|
49 |
|
|
extern ENTRY * hsearch __P((ENTRY __item, ACTION __action));
|
50 |
|
|
extern int hcreate __P((unsigned __nel));
|
51 |
|
|
extern void hdestroy __P((void));
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
/* The tsearch routines are very interesting. They make many
|
55 |
|
|
* assumptions about the compiler. It assumpts that the first field
|
56 |
|
|
* in node must be the "key" field, which points to the datum.
|
57 |
|
|
* Everything depends on that. It is a very tricky stuff. H.J.
|
58 |
|
|
*/
|
59 |
|
|
/* For tsearch */
|
60 |
|
|
typedef enum { preorder, postorder, endorder, leaf } VISIT;
|
61 |
|
|
|
62 |
|
|
extern void *tsearch __P((__const void * __key, void **__rootp,
|
63 |
|
|
__compar_fn_t compar));
|
64 |
|
|
|
65 |
|
|
extern void *tfind __P((__const void * __key, __const void ** __rootp,
|
66 |
|
|
__compar_fn_t compar));
|
67 |
|
|
|
68 |
|
|
extern void *tdelete __P((__const void * __key, void ** __rootp,
|
69 |
|
|
__compar_fn_t compar));
|
70 |
|
|
|
71 |
|
|
#ifndef __ACTION_FN_T
|
72 |
|
|
#define __ACTION_FN_T
|
73 |
|
|
/* FYI, the first argument should be a pointer to "key".
|
74 |
|
|
* Please read the man page for details.
|
75 |
|
|
*/
|
76 |
|
|
typedef void (*__action_fn_t) __P((__const void *__nodep,
|
77 |
|
|
__const VISIT __value,
|
78 |
|
|
__const int __level));
|
79 |
|
|
#endif
|
80 |
|
|
|
81 |
|
|
extern void twalk __P((__const void * __root, __action_fn_t action));
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
extern void * lfind __P((__const void * __key, __const void * __base,
|
85 |
|
|
size_t * __nmemb, size_t __size,
|
86 |
|
|
__compar_fn_t __compar));
|
87 |
|
|
|
88 |
|
|
extern void * lsearch __P((__const void * __key, __const void * __base,
|
89 |
|
|
size_t * __nmemb, size_t __size,
|
90 |
|
|
__compar_fn_t __compar));
|
91 |
|
|
|
92 |
|
|
__END_DECLS
|
93 |
|
|
|
94 |
|
|
#endif /* search.h */
|