4 * Copyright 2007 Dmitry Chapyshev <dmitry@reactos.org>
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.
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.
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
20 #ifndef _STRSAFE_H_INCLUDED_
21 #define _STRSAFE_H_INCLUDED_
24 #define _STRSAFE_EXTERN_C extern "C"
27 #define _STRSAFE_EXTERN_C extern
35 #define STRSAFE_INLINE_API __inline HRESULT __stdcall
36 #define STRSAFEAPI _STRSAFE_EXTERN_C HRESULT __stdcall
38 #ifndef _NTSTRSAFE_H_INCLUDED_
40 #define STRSAFE_MAX_CCH 2147483647
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
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))
56 #endif /* _NTSTRSAFE_H_INCLUDED_ */
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)
62 #ifndef STRSAFE_NO_CCH_FUNCTIONS
64 StringCchCatA(LPTSTR pszDest
,
69 StringCchCatW(LPWSTR pszDest
,
74 StringCchCatExA(LPTSTR pszDest
,
78 size_t* pcchRemaining
,
79 unsigned long dwFlags
);
82 StringCchCatExW(LPWSTR pszDest
,
86 size_t* pcchRemaining
,
87 unsigned long dwFlags
);
90 StringCchCatNA(LPTSTR pszDest
,
96 StringCchCatNW(LPWSTR pszDest
,
102 StringCchCatNExA(LPTSTR pszDest
,
107 size_t* pcchRemaining
,
108 unsigned long dwFlags
);
111 StringCchCatNExW(LPWSTR pszDest
,
116 size_t* pcchRemaining
,
117 unsigned long dwFlags
);
120 StringCchCopyA(LPTSTR pszDest
,
125 StringCchCopyW(LPWSTR pszDest
,
130 StringCchCopyExA(LPTSTR pszDest
,
134 size_t* pcchRemaining
,
135 unsigned long dwFlags
);
138 StringCchCopyExW(LPWSTR pszDest
,
142 size_t* pcchRemaining
,
143 unsigned long dwFlags
);
146 StringCchCopyNA(LPTSTR pszDest
,
152 StringCchCopyNW(LPWSTR pszDest
,
158 StringCchCopyNExA(LPTSTR pszDest
,
163 size_t* pcchRemaining
,
164 unsigned long dwFlags
);
167 StringCchCopyNExW(LPWSTR pszDest
,
172 size_t* pcchRemaining
,
173 unsigned long dwFlags
);
176 StringCchGetsA(LPTSTR pszDest
,
180 StringCchGetsW(LPWSTR pszDest
,
184 StringCchGetsExA(LPTSTR pszDest
,
187 size_t* pcchRemaining
,
188 unsigned long dwFlags
);
191 StringCchGetsExW(LPWSTR pszDest
,
194 size_t* pcchRemaining
,
195 unsigned long dwFlags
);
198 StringCchVPrintfA(LPTSTR pszDest
,
204 StringCchVPrintfW(LPWSTR pszDest
,
210 StringCchVPrintfExA(LPTSTR pszDest
,
213 size_t* pcchRemaining
,
214 unsigned long dwFlags
,
219 StringCchVPrintfExW(LPWSTR pszDest
,
222 size_t* pcchRemaining
,
223 unsigned long dwFlags
,
228 StringCchLengthA(LPCTSTR psz
,
233 StringCchLengthW(LPCWSTR psz
,
236 #endif /* STRSAFE_NO_CCH_FUNCTIONS */
239 #ifndef STRSAFE_NO_CB_FUNCTIONS
241 StringCbCatA(LPTSTR pszDest
,
246 StringCbCatW(LPWSTR pszDest
,
251 StringCbCatExA(LPTSTR pszDest
,
255 size_t* pcbRemaining
,
256 unsigned long dwFlags
);
259 StringCbCatExW(LPWSTR pszDest
,
263 size_t* pcbRemaining
,
264 unsigned long dwFlags
);
267 StringCbCopyA(LPTSTR pszDest
,
272 StringCbCopyW(LPWSTR pszDest
,
277 StringCbCopyExA(LPTSTR pszDest
,
281 size_t* pcbRemaining
,
282 unsigned long dwFlags
);
285 StringCbCopyExW(LPWSTR pszDest
,
289 size_t* pcbRemaining
,
290 unsigned long dwFlags
);
293 StringCbCopyNA(LPTSTR pszDest
,
299 StringCbCopyNW(LPWSTR pszDest
,
305 StringCbCopyNExA(LPTSTR pszDest
,
310 size_t* pcbRemaining
,
311 unsigned long dwFlags
);
314 StringCbCopyNExW(LPWSTR pszDest
,
319 size_t* pcbRemaining
,
320 unsigned long dwFlags
);
323 StringCbGetsA(LPTSTR pszDest
,
327 StringCbGetsW(LPWSTR pszDest
,
331 StringCbGetsExA(LPTSTR pszDest
,
335 unsigned long dwFlags
);
338 StringCbGetsExW(LPWSTR pszDest
,
341 size_t* pcbRemaining
,
342 unsigned long dwFlags
);
345 StringCbPrintfA(LPTSTR pszDest
,
351 StringCbPrintfW(LPWSTR pszDest
,
357 StringCbPrintfExA(LPTSTR pszDest
,
360 size_t* pcbRemaining
,
361 unsigned long dwFlags
,
366 StringCbPrintfExW(LPWSTR pszDest
,
369 size_t* pcbRemaining
,
370 unsigned long dwFlags
,
373 #endif /* STRSAFE_NO_CB_FUNCTIONS */
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 */
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 */
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 */
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 */
452 #endif /* cplusplus */
454 #endif /* _STRSAFE_H_INCLUDED_ */