- Moved WM_ACTIVATEAPP calles before WM_NC/ACTIVATE calls.
[reactos.git] / reactos / include / psdk / strsafe.h
1 /*
2 * STRSAFE
3 *
4 * Copyright 2007 Dmitry Chapyshev <dmitry@reactos.org>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20 #ifndef _STRSAFE_H_INCLUDED_
21 #define _STRSAFE_H_INCLUDED_
22
23 #ifdef __cplusplus
24 #define _STRSAFE_EXTERN_C extern "C"
25 extern "C" {
26 #else
27 #define _STRSAFE_EXTERN_C extern
28 #endif
29
30 #include <string.h>
31 #include <stdarg.h>
32 #include <stdio.h>
33 #include <windows.h>
34
35 #define STRSAFE_INLINE_API __inline HRESULT __stdcall
36 #define STRSAFEAPI _STRSAFE_EXTERN_C HRESULT __stdcall
37
38 #ifndef _NTSTRSAFE_H_INCLUDED_
39
40 #define STRSAFE_MAX_CCH 2147483647
41
42 #define STRSAFE_FILL_BEHIND_NULL 0x00000200
43 #define STRSAFE_IGNORE_NULLS 0x00000100
44 #define STRSAFE_FILL_ON_FAILURE 0x00000400
45 #define STRSAFE_NULL_ON_FAILURE 0x00000800
46 #define STRSAFE_NO_TRUNCATION 0x00001000
47 #define STRSAFE_IGNORE_NULL_UNICODE_STRINGS 0x00010000
48 #define STRSAFE_UNICODE_STRING_DEST_NULL_TERMINATED 0x00020000
49
50 #define STRSAFE_VALID_FLAGS (0x000000FF | STRSAFE_IGNORE_NULLS | STRSAFE_FILL_BEHIND_NULL | STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)
51 #define STRSAFE_UNICODE_STRING_VALID_FLAGS (STRSAFE_VALID_FLAGS | STRSAFE_IGNORE_NULL_UNICODE_STRINGS | STRSAFE_UNICODE_STRING_DEST_NULL_TERMINATED)
52 #define STRSAFE_FILL_BYTE(x) ((unsigned long)((x & 0x000000FF) | STRSAFE_FILL_BEHIND_NULL))
53 #define STRSAFE_FAILURE_BYTE(x) ((unsigned long)((x & 0x000000FF) | STRSAFE_FILL_ON_FAILURE))
54 #define STRSAFE_GET_FILL_PATTERN(dwFlags) ((int)(dwFlags & 0x000000FF))
55
56 #endif /* _NTSTRSAFE_H_INCLUDED_ */
57
58 #define STRSAFE_E_INSUFFICIENT_BUFFER ((HRESULT)0x8007007AL)
59 #define STRSAFE_E_INVALID_PARAMETER ((HRESULT)0x80070057L)
60 #define STRSAFE_E_END_OF_FILE ((HRESULT)0x80070026L)
61
62 #ifndef STRSAFE_NO_CCH_FUNCTIONS
63 STRSAFEAPI
64 StringCchCatA(LPTSTR pszDest,
65 size_t cchDest,
66 LPCTSTR pszSrc);
67
68 STRSAFEAPI
69 StringCchCatW(LPWSTR pszDest,
70 size_t cchDest,
71 LPCWSTR pszSrc);
72
73 STRSAFEAPI
74 StringCchCatExA(LPTSTR pszDest,
75 size_t cchDest,
76 LPCTSTR pszSrc,
77 LPTSTR *ppszDestEnd,
78 size_t* pcchRemaining,
79 unsigned long dwFlags);
80
81 STRSAFEAPI
82 StringCchCatExW(LPWSTR pszDest,
83 size_t cchDest,
84 LPCWSTR pszSrc,
85 LPWSTR *ppszDestEnd,
86 size_t* pcchRemaining,
87 unsigned long dwFlags);
88
89 STRSAFEAPI
90 StringCchCatNA(LPTSTR pszDest,
91 size_t cchDest,
92 LPCTSTR pszSrc,
93 size_t cchMaxAppend);
94
95 STRSAFEAPI
96 StringCchCatNW(LPWSTR pszDest,
97 size_t cchDest,
98 LPCWSTR pszSrc,
99 size_t cchMaxAppend);
100
101 STRSAFEAPI
102 StringCchCatNExA(LPTSTR pszDest,
103 size_t cchDest,
104 LPCTSTR pszSrc,
105 size_t cchMaxAppend,
106 LPTSTR *ppszDestEnd,
107 size_t* pcchRemaining,
108 unsigned long dwFlags);
109
110 STRSAFEAPI
111 StringCchCatNExW(LPWSTR pszDest,
112 size_t cchDest,
113 LPCWSTR pszSrc,
114 size_t cchMaxAppend,
115 LPWSTR *ppszDestEnd,
116 size_t* pcchRemaining,
117 unsigned long dwFlags);
118
119 STRSAFEAPI
120 StringCchCopyA(LPTSTR pszDest,
121 size_t cchDest,
122 LPCTSTR pszSrc);
123
124 STRSAFEAPI
125 StringCchCopyW(LPWSTR pszDest,
126 size_t cchDest,
127 LPCWSTR pszSrc);
128
129 STRSAFEAPI
130 StringCchCopyExA(LPTSTR pszDest,
131 size_t cchDest,
132 LPCTSTR pszSrc,
133 LPTSTR *ppszDestEnd,
134 size_t* pcchRemaining,
135 unsigned long dwFlags);
136
137 STRSAFEAPI
138 StringCchCopyExW(LPWSTR pszDest,
139 size_t cchDest,
140 LPCWSTR pszSrc,
141 LPWSTR *ppszDestEnd,
142 size_t* pcchRemaining,
143 unsigned long dwFlags);
144
145 STRSAFEAPI
146 StringCchCopyNA(LPTSTR pszDest,
147 size_t cchDest,
148 LPCTSTR pszSrc,
149 size_t cchSrc);
150
151 STRSAFEAPI
152 StringCchCopyNW(LPWSTR pszDest,
153 size_t cchDest,
154 LPCWSTR pszSrc,
155 size_t cchSrc);
156
157 STRSAFEAPI
158 StringCchCopyNExA(LPTSTR pszDest,
159 size_t cchDest,
160 LPCTSTR pszSrc,
161 size_t cchSrc,
162 LPTSTR *ppszDestEnd,
163 size_t* pcchRemaining,
164 unsigned long dwFlags);
165
166 STRSAFEAPI
167 StringCchCopyNExW(LPWSTR pszDest,
168 size_t cchDest,
169 LPCWSTR pszSrc,
170 size_t cchSrc,
171 LPWSTR *ppszDestEnd,
172 size_t* pcchRemaining,
173 unsigned long dwFlags);
174
175 STRSAFE_INLINE_API
176 StringCchGetsA(LPTSTR pszDest,
177 size_t cchDest);
178
179 STRSAFE_INLINE_API
180 StringCchGetsW(LPWSTR pszDest,
181 size_t cchDest);
182
183 STRSAFE_INLINE_API
184 StringCchGetsExA(LPTSTR pszDest,
185 size_t cchDest,
186 LPTSTR *ppszDestEnd,
187 size_t* pcchRemaining,
188 unsigned long dwFlags);
189
190 STRSAFE_INLINE_API
191 StringCchGetsExW(LPWSTR pszDest,
192 size_t cchDest,
193 LPWSTR *ppszDestEnd,
194 size_t* pcchRemaining,
195 unsigned long dwFlags);
196
197 STRSAFEAPI
198 StringCchVPrintfA(LPTSTR pszDest,
199 size_t cchDest,
200 LPCTSTR pszFormat,
201 va_list argList);
202
203 STRSAFEAPI
204 StringCchVPrintfW(LPWSTR pszDest,
205 size_t cchDest,
206 LPCWSTR pszFormat,
207 va_list argList);
208
209 STRSAFEAPI
210 StringCchVPrintfExA(LPTSTR pszDest,
211 size_t cchDest,
212 LPTSTR *ppszDestEnd,
213 size_t* pcchRemaining,
214 unsigned long dwFlags,
215 LPCTSTR pszFormat,
216 va_list argList);
217
218 STRSAFEAPI
219 StringCchVPrintfExW(LPWSTR pszDest,
220 size_t cchDest,
221 LPWSTR *ppszDestEnd,
222 size_t* pcchRemaining,
223 unsigned long dwFlags,
224 LPCWSTR pszFormat,
225 va_list argList);
226
227 STRSAFEAPI
228 StringCchLengthA(LPCTSTR psz,
229 size_t cchMax,
230 size_t* pcch);
231
232 STRSAFEAPI
233 StringCchLengthW(LPCWSTR psz,
234 size_t cchMax,
235 size_t* pcch);
236 #endif /* STRSAFE_NO_CCH_FUNCTIONS */
237
238 /* CB */
239 #ifndef STRSAFE_NO_CB_FUNCTIONS
240 STRSAFEAPI
241 StringCbCatA(LPTSTR pszDest,
242 size_t cbDest,
243 LPCTSTR pszSrc);
244
245 STRSAFEAPI
246 StringCbCatW(LPWSTR pszDest,
247 size_t cbDest,
248 LPCWSTR pszSrc);
249
250 STRSAFEAPI
251 StringCbCatExA(LPTSTR pszDest,
252 size_t cbDest,
253 LPCTSTR pszSrc,
254 LPTSTR *ppszDestEnd,
255 size_t* pcbRemaining,
256 unsigned long dwFlags);
257
258 STRSAFEAPI
259 StringCbCatExW(LPWSTR pszDest,
260 size_t cbDest,
261 LPCWSTR pszSrc,
262 LPWSTR *ppszDestEnd,
263 size_t* pcbRemaining,
264 unsigned long dwFlags);
265
266 STRSAFEAPI
267 StringCbCopyA(LPTSTR pszDest,
268 size_t cbDest,
269 LPCTSTR pszSrc);
270
271 STRSAFEAPI
272 StringCbCopyW(LPWSTR pszDest,
273 size_t cbDest,
274 LPCWSTR pszSrc);
275
276 STRSAFEAPI
277 StringCbCopyExA(LPTSTR pszDest,
278 size_t cbDest,
279 LPCTSTR pszSrc,
280 LPTSTR *ppszDestEnd,
281 size_t* pcbRemaining,
282 unsigned long dwFlags);
283
284 STRSAFEAPI
285 StringCbCopyExW(LPWSTR pszDest,
286 size_t cbDest,
287 LPCWSTR pszSrc,
288 LPWSTR *ppszDestEnd,
289 size_t* pcbRemaining,
290 unsigned long dwFlags);
291
292 STRSAFEAPI
293 StringCbCopyNA(LPTSTR pszDest,
294 size_t cbDest,
295 LPCTSTR pszSrc,
296 size_t cbSrc);
297
298 STRSAFEAPI
299 StringCbCopyNW(LPWSTR pszDest,
300 size_t cbDest,
301 LPCWSTR pszSrc,
302 size_t cbSrc);
303
304 STRSAFEAPI
305 StringCbCopyNExA(LPTSTR pszDest,
306 size_t cbDest,
307 LPCTSTR pszSrc,
308 size_t cbSrc,
309 LPTSTR *ppszDestEnd,
310 size_t* pcbRemaining,
311 unsigned long dwFlags);
312
313 STRSAFEAPI
314 StringCbCopyNExW(LPWSTR pszDest,
315 size_t cbDest,
316 LPCWSTR pszSrc,
317 size_t cbSrc,
318 LPWSTR *ppszDestEnd,
319 size_t* pcbRemaining,
320 unsigned long dwFlags);
321
322 STRSAFE_INLINE_API
323 StringCbGetsA(LPTSTR pszDest,
324 size_t cbDest);
325
326 STRSAFE_INLINE_API
327 StringCbGetsW(LPWSTR pszDest,
328 size_t cbDest);
329
330 STRSAFE_INLINE_API
331 StringCbGetsExA(LPTSTR pszDest,
332 size_t cbDest,
333 LPTSTR *ppszDestEnd,
334 size_t* pbRemaining,
335 unsigned long dwFlags);
336
337 STRSAFE_INLINE_API
338 StringCbGetsExW(LPWSTR pszDest,
339 size_t cbDest,
340 LPWSTR *ppszDestEnd,
341 size_t* pcbRemaining,
342 unsigned long dwFlags);
343
344 STRSAFEAPI
345 StringCbPrintfA(LPTSTR pszDest,
346 size_t cbDest,
347 LPCTSTR pszFormat,
348 ...);
349
350 STRSAFEAPI
351 StringCbPrintfW(LPWSTR pszDest,
352 size_t cbDest,
353 LPCWSTR pszFormat,
354 ...);
355
356 STRSAFEAPI
357 StringCbPrintfExA(LPTSTR pszDest,
358 size_t cbDest,
359 LPTSTR *ppszDestEnd,
360 size_t* pcbRemaining,
361 unsigned long dwFlags,
362 LPCTSTR pszFormat,
363 ...);
364
365 STRSAFEAPI
366 StringCbPrintfExW(LPWSTR pszDest,
367 size_t cbDest,
368 LPWSTR *ppszDestEnd,
369 size_t* pcbRemaining,
370 unsigned long dwFlags,
371 LPCWSTR pszFormat,
372 ...);
373 #endif /* STRSAFE_NO_CB_FUNCTIONS */
374
375 #ifdef UNICODE
376 #ifndef STRSAFE_NO_CCH_FUNCTIONS
377 #define StringCchCat StringCchCatW
378 #define StringCchCatEx StringCchCatExW
379 #define StringCchCatN StringCchCatNW
380 #define StringCchCatNEx StringCchCatNExW
381 #define StringCchCopy StringCchCopyW
382 #define StringCchCopyEx StringCchCopyExW
383 #define StringCchCopyN StringCchCopyNW
384 #define StringCchCopyNEx StringCchCopyNExW
385 #define StringCchGets StringCchGetsW
386 #define StringCchGetsEx StringCchGetsExW
387 #define StringCchPrintf StringCchPrintfW
388 #define StringCchPrintfEx StringCchPrintfExW
389 #define StringCchVPrintf StringCchVPrintfW
390 #define StringCchVPrintfEx StringCchVPrintfExW
391 #define StringCchLength StringCchLengthW
392 #endif /* STRSAFE_NO_CCH_FUNCTIONS */
393
394 #ifndef STRSAFE_NO_CB_FUNCTIONS
395 #define StringCbCat StringCbCatW
396 #define StringCbCatEx StringCbCatExW
397 #define StringCbCatN StringCbCatNW
398 #define StringCbCatNEx StringCbCatNExW
399 #define StringCbCopy StringCbCopyW
400 #define StringCbCopyEx StringCbCopyExW
401 #define StringCbCopyN StringCbCopyNW
402 #define StringCbCopyNEx StringCbCopyNExW
403 #define StringCbGets StringCbGetsW
404 #define StringCbGetsEx StringCbGetsExW
405 #define StringCbPrintf StringCbPrintfW
406 #define StringCbPrintfEx StringCbPrintfExW
407 #define StringCbVPrintf StringCbVPrintfW
408 #define StringCbVPrintfEx StringCbVPrintfExW
409 #define StringCbLenght StringCbLenghtW
410 #endif /* STRSAFE_NO_CB_FUNCTIONS */
411
412 #else
413 #ifndef STRSAFE_NO_CCH_FUNCTIONS
414 #define StringCchCat StringCchCatA
415 #define StringCchCatEx StringCchCatExA
416 #define StringCchCatN StringCchCatNA
417 #define StringCchCatNEx StringCchCatNExA
418 #define StringCchCopy StringCchCopyA
419 #define StringCchCopyEx StringCchCopyExA
420 #define StringCchCopyN StringCchCopyNA
421 #define StringCchCopyNEx StringCchCopyNExA
422 #define StringCchGets StringCchGetsA
423 #define StringCchGetsEx StringCchGetsExA
424 #define StringCchPrintf StringCchPrintfA
425 #define StringCchPrintfEx StringCchPrintfExA
426 #define StringCchVPrintf StringCchVPrintfA
427 #define StringCchVPrintfEx StringCchVPrintfExA
428 #define StringCchLength StringCchLengthA
429 #endif /* STRSAFE_NO_CCH_FUNCTIONS */
430
431 #ifndef STRSAFE_NO_CB_FUNCTIONS
432 #define StringCbCat StringCbCatA
433 #define StringCbCatEx StringCbCatExA
434 #define StringCbCatN StringCbCatNA
435 #define StringCbCatNEx StringCbCatNExA
436 #define StringCbCopy StringCbCopyA
437 #define StringCbCopyEx StringCbCopyExA
438 #define StringCbCopyN StringCbCopyNA
439 #define StringCbCopyNEx StringCbCopyNExA
440 #define StringCbGets StringCbGetsA
441 #define StringCbGetsEx StringCbGetsExA
442 #define StringCbPrintf StringCbPrintfA
443 #define StringCbPrintfEx StringCbPrintfExA
444 #define StringCbVPrintf StringCbVPrintfA
445 #define StringCbVPrintfEx StringCbVPrintfExA
446 #define StringCbLenght StringCbLenghtA
447 #endif /* STRSAFE_NO_CB_FUNCTIONS */
448 #endif /* UNICODE */
449
450 #ifdef __cplusplus
451 }
452 #endif /* cplusplus */
453
454 #endif /* _STRSAFE_H_INCLUDED_ */