xref: /reactos/sdk/include/ucrt/corecrt_search.h (revision e3e520d1)
1 //
2 // corecrt_search.h
3 //
4 //      Copyright (c) Microsoft Corporation. All rights reserved.
5 //
6 // Declarations of functions for sorting and searching.  These declarations are
7 // split out so that they may be included by both <stdlib.h> and <search.h>.
8 // <stdlib.h> does not include <search.h> to avoid introducing conflicts with
9 // other user headers named <search.h>.
10 //
11 #pragma once
12 
13 #include <corecrt.h>
14 #include <stddef.h>
15 
16 #pragma warning(push)
17 #pragma warning(disable: _UCRT_DISABLED_WARNINGS)
18 _UCRT_DISABLE_CLANG_WARNINGS
19 
20 _CRT_BEGIN_C_HEADER
21 
22 
23     typedef int (__cdecl* _CoreCrtSecureSearchSortCompareFunction)(void*, void const*, void const*);
24     typedef int (__cdecl* _CoreCrtNonSecureSearchSortCompareFunction)(void const*, void const*);
25 
26 
27 #if __STDC_WANT_SECURE_LIB__
28 
29     _Check_return_
30     _ACRTIMP void* __cdecl bsearch_s(
31         _In_                                               void const* _Key,
32         _In_reads_bytes_(_NumOfElements * _SizeOfElements) void const* _Base,
33         _In_                                               rsize_t     _NumOfElements,
34         _In_                                               rsize_t     _SizeOfElements,
35         _In_                   _CoreCrtSecureSearchSortCompareFunction _CompareFunction,
36         _In_opt_                                           void*       _Context
37         );
38 
39     _ACRTIMP void __cdecl qsort_s(
40         _Inout_updates_bytes_(_NumOfElements * _SizeOfElements) void*   _Base,
41         _In_                                                    rsize_t _NumOfElements,
42         _In_                                                    rsize_t _SizeOfElements,
43         _In_                    _CoreCrtSecureSearchSortCompareFunction _CompareFunction,
44         _In_opt_                                                void*   _Context
45         );
46 
47 #endif // __STDC_WANT_SECURE_LIB__
48 
49 
50 
51 _Check_return_
52 _ACRTIMP void* __cdecl bsearch(
53     _In_                                               void const* _Key,
54     _In_reads_bytes_(_NumOfElements * _SizeOfElements) void const* _Base,
55     _In_                                               size_t      _NumOfElements,
56     _In_                                               size_t      _SizeOfElements,
57     _In_                _CoreCrtNonSecureSearchSortCompareFunction _CompareFunction
58     );
59 
60 _ACRTIMP void __cdecl qsort(
61     _Inout_updates_bytes_(_NumOfElements * _SizeOfElements) void*  _Base,
62     _In_                                                    size_t _NumOfElements,
63     _In_                                                    size_t _SizeOfElements,
64     _In_                _CoreCrtNonSecureSearchSortCompareFunction _CompareFunction
65     );
66 
67 _Check_return_
68 _ACRTIMP void* __cdecl _lfind_s(
69     _In_                                                  void const*   _Key,
70     _In_reads_bytes_((*_NumOfElements) * _SizeOfElements) void const*   _Base,
71     _Inout_                                               unsigned int* _NumOfElements,
72     _In_                                                  size_t        _SizeOfElements,
73     _In_                        _CoreCrtSecureSearchSortCompareFunction _CompareFunction,
74     _In_                                                  void*         _Context
75     );
76 
77 _Check_return_
78 _ACRTIMP void* __cdecl _lfind(
79     _In_                                                  void const*   _Key,
80     _In_reads_bytes_((*_NumOfElements) * _SizeOfElements) void const*   _Base,
81     _Inout_                                               unsigned int* _NumOfElements,
82     _In_                                                  unsigned int  _SizeOfElements,
83     _In_                     _CoreCrtNonSecureSearchSortCompareFunction _CompareFunction
84     );
85 
86 _Check_return_
87 _ACRTIMP void* __cdecl _lsearch_s(
88     _In_                                                        void const*   _Key,
89     _Inout_updates_bytes_((*_NumOfElements ) * _SizeOfElements) void*         _Base,
90     _Inout_                                                     unsigned int* _NumOfElements,
91     _In_                                                        size_t        _SizeOfElements,
92     _In_                              _CoreCrtSecureSearchSortCompareFunction _CompareFunction,
93     _In_                                                        void*         _Context
94     );
95 
96 _Check_return_
97 _ACRTIMP void* __cdecl _lsearch(
98     _In_                                                        void const*   _Key,
99     _Inout_updates_bytes_((*_NumOfElements ) * _SizeOfElements) void*         _Base,
100     _Inout_                                                     unsigned int* _NumOfElements,
101     _In_                                                        unsigned int  _SizeOfElements,
102     _In_                           _CoreCrtNonSecureSearchSortCompareFunction _CompareFunction
103     );
104 
105 
106 
107 // Managed search routines
108 #if defined __cplusplus && defined _M_CEE
109 extern "C++"
110 {
111     typedef int (__clrcall* _CoreCrtMgdSecureSearchSortCompareFunction)(void*, void const*, void const*);
112     typedef int (__clrcall* _CoreCrtMgdNonSecureSearchSortCompareFunction)(void const*, void const*);
113 
114     #if __STDC_WANT_SECURE_LIB__
115 
116         _Check_return_
117         void* __clrcall bsearch_s(
118                 _In_                                               void const* _Key,
119                 _In_reads_bytes_(_NumOfElements * _SizeOfElements) void const* _Base,
120                 _In_                                               rsize_t     _NumOfElements,
121                 _In_                                               rsize_t     _SizeOfElements,
122                 _In_                _CoreCrtMgdSecureSearchSortCompareFunction _CompareFunction,
123                 _In_                                               void*       _Context);
124 
125         void __clrcall qsort_s(
126                 _Inout_updates_bytes_(_NumOfElements * _SizeOfElements) void*   _Base,
127                 _In_                                                    rsize_t _NumOfElements,
128                 _In_                                                    rsize_t _SizeOfElements,
129                 _In_                 _CoreCrtMgdSecureSearchSortCompareFunction _CompareFunction,
130                 _In_                                                    void*   _Context);
131 
132     #endif // __STDC_WANT_SECURE_LIB__
133 
134     _Check_return_
135     void* __clrcall bsearch(
136         _In_                                               void const* _Key,
137         _In_reads_bytes_(_NumOfElements * _SizeOfElements) void const* _Base,
138         _In_                                               size_t _NumOfElements,
139         _In_                                               size_t _SizeOfElements,
140         _In_        _CoreCrtMgdNonSecureSearchSortCompareFunction _CompareFunction
141         );
142 
143     _Check_return_
144     void* __clrcall _lfind_s(
145         _In_                                               void const*   _Key,
146         _In_reads_bytes_(_NumOfElements * _SizeOfElements) void const*   _Base,
147         _Inout_                                            unsigned int* _NumOfElements,
148         _In_                                               size_t        _SizeOfElements,
149         _In_                  _CoreCrtMgdSecureSearchSortCompareFunction _CompareFunction,
150         _In_                                               void*         _Context
151         );
152 
153     _Check_return_
154     void* __clrcall _lfind(
155         _In_                                                  void const*   _Key,
156         _In_reads_bytes_((*_NumOfElements) * _SizeOfElements) void const*   _Base,
157         _Inout_                                               unsigned int* _NumOfElements,
158         _In_                                                  unsigned int  _SizeOfElements,
159         _In_                  _CoreCrtMgdNonSecureSearchSortCompareFunction _CompareFunction
160         );
161 
162     _Check_return_
163     void* __clrcall _lsearch_s(
164         _In_                                                  void const*   _Key,
165         _In_reads_bytes_((*_NumOfElements) * _SizeOfElements) void*         _Base,
166         _In_                                                  unsigned int* _NumOfElements,
167         _In_                                                  size_t        _SizeOfElements,
168         _In_                     _CoreCrtMgdSecureSearchSortCompareFunction _CompareFunction,
169         _In_                                                  void*         _Context
170         );
171 
172     _Check_return_
173     void* __clrcall _lsearch(
174         _In_                                                       void const*   _Key,
175         _Inout_updates_bytes_((*_NumOfElements) * _SizeOfElements) void*         _Base,
176         _Inout_                                                    unsigned int* _NumOfElements,
177         _In_                                                       unsigned int  _SizeOfElements,
178         _In_                       _CoreCrtMgdNonSecureSearchSortCompareFunction _CompareFunction
179         );
180 
181     void __clrcall qsort(
182         _Inout_updates_bytes_(_NumOfElements * _SizeOfElements) void*  _Base,
183         _In_                                                    size_t _NumOfElements,
184         _In_                                                    size_t _SizeOfElements,
185         _In_             _CoreCrtMgdNonSecureSearchSortCompareFunction _CompareFunction
186         );
187 }
188 #endif // defined __cplusplus && defined _M_CEE
189 
190 
191 
192 #if defined(_CRT_INTERNAL_NONSTDC_NAMES) && _CRT_INTERNAL_NONSTDC_NAMES
193 
194     _Check_return_ _CRT_NONSTDC_DEPRECATE(_lfind)
195     _ACRTIMP void* __cdecl lfind(
196         _In_                                                  void const*   _Key,
197         _In_reads_bytes_((*_NumOfElements) * _SizeOfElements) void const*   _Base,
198         _Inout_                                               unsigned int* _NumOfElements,
199         _In_                                                  unsigned int  _SizeOfElements,
200         _In_                     _CoreCrtNonSecureSearchSortCompareFunction _CompareFunction
201         );
202 
203     _Check_return_ _CRT_NONSTDC_DEPRECATE(_lsearch)
204     _ACRTIMP void* __cdecl lsearch(
205         _In_                                                       void const*   _Key,
206         _Inout_updates_bytes_((*_NumOfElements) * _SizeOfElements) void*         _Base,
207         _Inout_                                                    unsigned int* _NumOfElements,
208         _In_                                                       unsigned int  _SizeOfElements,
209         _In_                          _CoreCrtNonSecureSearchSortCompareFunction _CompareFunction
210         );
211 
212 #endif // _CRT_INTERNAL_NONSTDC_NAMES
213 
214 
215 
216 _CRT_END_C_HEADER
217 _UCRT_RESTORE_CLANG_WARNINGS
218 #pragma warning(pop) // _UCRT_DISABLED_WARNINGS
219