OSDN Git Service

Redo the filters based on assumptions discussed in mingw-dvlpr list.
[mingw/mingw-org-wsl.git] / include / search.h
1 /**
2  * @file search.h
3  * @copy 2012 MinGW.org project
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  * 
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  * 
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 #ifndef _SEARCH_H
25 #define _SEARCH_H
26 #pragma GCC system_header
27 #include <_mingw.h>
28
29 #ifndef RC_INVOKED
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #ifndef _SIZE_T_DEFINED
36 typedef unsigned int size_t;
37 #define _SIZE_T_DEFINED
38 #endif
39
40 /* bsearch and qsort are also declared in stdlib.h */
41 _CRTIMP void* __cdecl bsearch (const void*, const void*, size_t, size_t, 
42                                int (*)(const void*, const void*));
43 _CRTIMP void __cdecl qsort (void*, size_t, size_t,
44                             int (*)(const void*, const void*));
45
46 _CRTIMP void* __cdecl _lfind (const void*, const void*, unsigned int*,
47                               unsigned int, int (*)(const void*, const void*));
48 _CRTIMP void* __cdecl _lsearch (const void*, void*, unsigned int*, unsigned int,
49                                 int (*)(const void*, const void*));
50 /*
51 Documentation for these POSIX definitions and prototypes can be found in 
52 The Open Group Base Specifications Issue 6
53 IEEE Std 1003.1, 2004 Edition.
54 eg:  http://www.opengroup.org/onlinepubs/009695399/functions/twalk.html
55 */
56
57
58 typedef struct entry {
59         char *key;
60         void *data;
61 } ENTRY;
62
63 typedef enum {
64         FIND,
65         ENTER
66 } ACTION;
67
68 typedef enum {
69         preorder,
70         postorder,
71         endorder,
72         leaf
73 } VISIT;
74
75 #ifdef _SEARCH_PRIVATE
76 typedef struct node {
77         char         *key;
78         struct node  *llink, *rlink;
79 } node_t;
80 #endif
81
82 void * __cdecl tdelete (const void * __restrict__, void ** __restrict__,
83                         int (*)(const void *, const void *))
84                         __MINGW_ATTRIB_NONNULL (1)  __MINGW_ATTRIB_NONNULL (3);
85 void * __cdecl tfind (const void *, void * const *,
86                       int (*)(const void *, const void *))
87                       __MINGW_ATTRIB_NONNULL (1)  __MINGW_ATTRIB_NONNULL (3);
88 void * __cdecl tsearch (const void *, void **, 
89                         int (*)(const void *, const void *))
90                         __MINGW_ATTRIB_NONNULL (1)  __MINGW_ATTRIB_NONNULL (3);
91 void __cdecl twalk (const void *, void (*)(const void *, VISIT, int));
92
93 #ifndef _NO_OLDNAMES
94 _CRTIMP void* __cdecl lfind (const void*, const void*, unsigned int*,
95                              unsigned int, int (*)(const void*, const void*));
96 _CRTIMP void* __cdecl lsearch (const void*, void*, unsigned int*, unsigned int,
97                                int (*)(const void*, const void*));
98 #endif
99
100 #ifdef __cplusplus
101 }
102 #endif
103
104 #endif /* RC_INVOKED */
105 #endif /*  _SEARCH_H */