source: Daodan/MSYS2/mingw32/i686-w64-mingw32/include/strsafe.h

Last change on this file was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 75.8 KB
Line 
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6#ifndef _STRSAFE_H_INCLUDED_
7#define _STRSAFE_H_INCLUDED_
8
9#include <_mingw_unicode.h>
10#include <stdio.h>
11#include <string.h>
12#include <stdarg.h>
13#include <specstrings.h>
14
15#if defined(__CRT__NO_INLINE) && !defined(__CRT_STRSAFE_IMPL)
16#define __STRSAFE__NO_INLINE
17#endif
18
19#ifndef _SIZE_T_DEFINED
20#define _SIZE_T_DEFINED
21#undef size_t
22#ifdef _WIN64
23__MINGW_EXTENSION typedef unsigned __int64 size_t;
24#else
25typedef unsigned int size_t;
26#endif
27#endif
28
29#ifndef _SSIZE_T_DEFINED
30#define _SSIZE_T_DEFINED
31#undef ssize_t
32#ifdef _WIN64
33__MINGW_EXTENSION typedef __int64 ssize_t;
34#else
35typedef int ssize_t;
36#endif
37#endif
38
39#ifndef _WCHAR_T_DEFINED
40#define _WCHAR_T_DEFINED
41typedef unsigned short wchar_t;
42#endif
43
44#ifndef _HRESULT_DEFINED
45#define _HRESULT_DEFINED
46typedef __LONG32 HRESULT;
47#endif
48
49#ifndef SUCCEEDED
50#define SUCCEEDED(hr) ((HRESULT)(hr) >= 0)
51#endif
52
53#ifndef FAILED
54#define FAILED(hr) ((HRESULT)(hr) < 0)
55#endif
56
57#ifndef S_OK
58#define S_OK ((HRESULT)0x00000000)
59#endif
60
61#ifndef C_ASSERT
62#ifdef _MSC_VER
63# define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
64#else
65# define C_ASSERT(e) extern void __C_ASSERT__(int [(e)?1:-1])
66#endif
67#endif /* C_ASSERT */
68
69/* extern removed for C mode to avoid double extern qualifier from __CRT_INLINE */
70#ifdef __cplusplus
71#define _STRSAFE_EXTERN_C extern "C"
72#else
73#define _STRSAFE_EXTERN_C
74#endif
75
76#ifndef WINAPI
77#if defined(_ARM_)
78#define WINAPI
79#else
80#define WINAPI __stdcall
81#endif
82#endif
83
84#if !defined(__CRT__NO_INLINE) && !defined(__CRT_STRSAFE_IMPL)
85#define STRSAFEAPI _STRSAFE_EXTERN_C __inline HRESULT WINAPI
86/* Variadic functions can't be __stdcall. */
87#define STRSAFEAPIV _STRSAFE_EXTERN_C __inline HRESULT
88#else
89#define STRSAFEAPI _STRSAFE_EXTERN_C HRESULT WINAPI
90/* Variadic functions can't be __stdcall. */
91#define STRSAFEAPIV _STRSAFE_EXTERN_C HRESULT
92#endif
93
94#if !defined(__CRT__NO_INLINE) && !defined(__CRT_STRSAFE_IMPL)
95#define STRSAFE_INLINE_API _STRSAFE_EXTERN_C __CRT_INLINE HRESULT WINAPI
96#else
97#define STRSAFE_INLINE_API HRESULT WINAPI
98#endif
99
100#define STRSAFE_MAX_CCH 2147483647
101
102#ifndef _NTSTRSAFE_H_INCLUDED_
103#define STRSAFE_IGNORE_NULLS 0x00000100
104#define STRSAFE_FILL_BEHIND_NULL 0x00000200
105#define STRSAFE_FILL_ON_FAILURE 0x00000400
106#define STRSAFE_NULL_ON_FAILURE 0x00000800
107#define STRSAFE_NO_TRUNCATION 0x00001000
108#define STRSAFE_IGNORE_NULL_UNICODE_STRINGS 0x00010000
109#define STRSAFE_UNICODE_STRING_DEST_NULL_TERMINATED 0x00020000
110
111#define STRSAFE_VALID_FLAGS (0x000000FF | STRSAFE_IGNORE_NULLS | STRSAFE_FILL_BEHIND_NULL | STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)
112#define STRSAFE_UNICODE_STRING_VALID_FLAGS (STRSAFE_VALID_FLAGS | STRSAFE_IGNORE_NULL_UNICODE_STRINGS | STRSAFE_UNICODE_STRING_DEST_NULL_TERMINATED)
113
114#define STRSAFE_FILL_BYTE(x) ((unsigned __LONG32)((x & 0x000000FF) | STRSAFE_FILL_BEHIND_NULL))
115#define STRSAFE_FAILURE_BYTE(x) ((unsigned __LONG32)((x & 0x000000FF) | STRSAFE_FILL_ON_FAILURE))
116
117#define STRSAFE_GET_FILL_PATTERN(dwFlags) ((int)(dwFlags & 0x000000FF))
118#endif
119
120#define STRSAFE_E_INSUFFICIENT_BUFFER ((HRESULT)0x8007007A)
121#define STRSAFE_E_INVALID_PARAMETER ((HRESULT)0x80070057)
122#define STRSAFE_E_END_OF_FILE ((HRESULT)0x80070026)
123
124typedef char *STRSAFE_LPSTR;
125typedef const char *STRSAFE_LPCSTR;
126typedef wchar_t *STRSAFE_LPWSTR;
127typedef const wchar_t *STRSAFE_LPCWSTR;
128
129STRSAFEAPI StringCopyWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc);
130STRSAFEAPI StringCopyWorkerW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc);
131STRSAFEAPI StringCopyExWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPCSTR pszSrc,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags);
132STRSAFEAPI StringCopyExWorkerW(STRSAFE_LPWSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags);
133STRSAFEAPI StringCopyNWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc,size_t cchToCopy);
134STRSAFEAPI StringCopyNWorkerW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc,size_t cchToCopy);
135STRSAFEAPI StringCopyNExWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPCSTR pszSrc,size_t cchToCopy,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags);
136STRSAFEAPI StringCopyNExWorkerW(STRSAFE_LPWSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc,size_t cchToCopy,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags);
137STRSAFEAPI StringCatWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc);
138STRSAFEAPI StringCatWorkerW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc);
139STRSAFEAPI StringCatExWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPCSTR pszSrc,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags);
140STRSAFEAPI StringCatExWorkerW(STRSAFE_LPWSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags);
141STRSAFEAPI StringCatNWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc,size_t cchToAppend);
142STRSAFEAPI StringCatNWorkerW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc,size_t cchToAppend);
143STRSAFEAPI StringCatNExWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPCSTR pszSrc,size_t cchToAppend,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags);
144STRSAFEAPI StringCatNExWorkerW(STRSAFE_LPWSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc,size_t cchToAppend,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags);
145STRSAFEAPI StringVPrintfWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszFormat,va_list argList);
146STRSAFEAPI StringVPrintfWorkerW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszFormat,va_list argList);
147STRSAFEAPI StringVPrintfExWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags,STRSAFE_LPCSTR pszFormat,va_list argList);
148STRSAFEAPI StringVPrintfExWorkerW(STRSAFE_LPWSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags,STRSAFE_LPCWSTR pszFormat,va_list argList);
149STRSAFEAPI StringLengthWorkerA(STRSAFE_LPCSTR psz,size_t cchMax,size_t *pcchLength);
150STRSAFEAPI StringLengthWorkerW(STRSAFE_LPCWSTR psz,size_t cchMax,size_t *pcchLength);
151STRSAFE_INLINE_API StringGetsExWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags);
152STRSAFE_INLINE_API StringGetsExWorkerW(STRSAFE_LPWSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags);
153
154#define StringCchCopy __MINGW_NAME_AW(StringCchCopy)
155
156STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc);
157STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc);
158
159#ifndef __STRSAFE__NO_INLINE
160STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc) {
161 return (cchDest > STRSAFE_MAX_CCH ? STRSAFE_E_INVALID_PARAMETER : StringCopyWorkerA(pszDest,cchDest,pszSrc));
162}
163
164STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc) {
165 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
166 return StringCopyWorkerW(pszDest,cchDest,pszSrc);
167}
168#endif /* !__STRSAFE__NO_INLINE */
169
170#define StringCbCopy __MINGW_NAME_AW(StringCbCopy)
171
172STRSAFEAPI StringCbCopyA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPCSTR pszSrc);
173STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc);
174
175#ifndef __STRSAFE__NO_INLINE
176STRSAFEAPI StringCbCopyA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPCSTR pszSrc) {
177 if(cbDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
178 return StringCopyWorkerA(pszDest,cbDest,pszSrc);
179}
180
181STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc) {
182 size_t cchDest = cbDest / sizeof(wchar_t);
183 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
184 return StringCopyWorkerW(pszDest,cchDest,pszSrc);
185}
186#endif /* !__STRSAFE__NO_INLINE */
187
188#define StringCchCopyEx __MINGW_NAME_AW(StringCchCopyEx)
189
190STRSAFEAPI StringCchCopyExA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags);
191STRSAFEAPI StringCchCopyExW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags);
192
193#ifndef __STRSAFE__NO_INLINE
194STRSAFEAPI StringCchCopyExA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags) {
195 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
196 return StringCopyExWorkerA(pszDest,cchDest,cchDest,pszSrc,ppszDestEnd,pcchRemaining,dwFlags);
197}
198
199STRSAFEAPI StringCchCopyExW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags) {
200 size_t cbDest;
201 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
202 cbDest = cchDest * sizeof(wchar_t);
203 return StringCopyExWorkerW(pszDest,cchDest,cbDest,pszSrc,ppszDestEnd,pcchRemaining,dwFlags);
204}
205#endif /* !__STRSAFE__NO_INLINE */
206
207#define StringCbCopyEx __MINGW_NAME_AW(StringCbCopyEx)
208
209STRSAFEAPI StringCbCopyExA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPCSTR pszSrc,STRSAFE_LPSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags);
210STRSAFEAPI StringCbCopyExW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags);
211
212#ifndef __STRSAFE__NO_INLINE
213STRSAFEAPI StringCbCopyExA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPCSTR pszSrc,STRSAFE_LPSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags) {
214 HRESULT hr;
215 size_t cchRemaining = 0;
216 if(cbDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
217 hr = StringCopyExWorkerA(pszDest,cbDest,cbDest,pszSrc,ppszDestEnd,&cchRemaining,dwFlags);
218 if(SUCCEEDED(hr) || hr == STRSAFE_E_INSUFFICIENT_BUFFER) {
219 if(pcbRemaining)
220 *pcbRemaining = (cchRemaining*sizeof(char)) + (cbDest % sizeof(char));
221 }
222 return hr;
223}
224
225STRSAFEAPI StringCbCopyExW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags) {
226 HRESULT hr;
227 size_t cchDest = cbDest / sizeof(wchar_t);
228 size_t cchRemaining = 0;
229
230 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
231 hr = StringCopyExWorkerW(pszDest,cchDest,cbDest,pszSrc,ppszDestEnd,&cchRemaining,dwFlags);
232 if(SUCCEEDED(hr) || (hr==STRSAFE_E_INSUFFICIENT_BUFFER)) {
233 if(pcbRemaining)
234 *pcbRemaining = (cchRemaining*sizeof(wchar_t)) + (cbDest % sizeof(wchar_t));
235 }
236 return hr;
237}
238#endif /* !__STRSAFE__NO_INLINE */
239
240STRSAFEAPI StringCchCopyNA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc,size_t cchToCopy);
241STRSAFEAPI StringCchCopyNW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc,size_t cchToCopy);
242#define StringCchCopyN __MINGW_NAME_AW(StringCchCopyN)
243
244#ifndef __STRSAFE__NO_INLINE
245STRSAFEAPI StringCchCopyNA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc,size_t cchToCopy) {
246 if(cchDest > STRSAFE_MAX_CCH || cchToCopy > STRSAFE_MAX_CCH)
247 return STRSAFE_E_INVALID_PARAMETER;
248 return StringCopyNWorkerA(pszDest,cchDest,pszSrc,cchToCopy);
249}
250
251STRSAFEAPI StringCchCopyNW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc,size_t cchToCopy) {
252 if(cchDest > STRSAFE_MAX_CCH || cchToCopy > STRSAFE_MAX_CCH)
253 return STRSAFE_E_INVALID_PARAMETER;
254 return StringCopyNWorkerW(pszDest,cchDest,pszSrc,cchToCopy);
255}
256#endif /* !__STRSAFE__NO_INLINE */
257
258STRSAFEAPI StringCbCopyNA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPCSTR pszSrc,size_t cbToCopy);
259STRSAFEAPI StringCbCopyNW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc,size_t cbToCopy);
260
261#define StringCbCopyN __MINGW_NAME_AW(StringCbCopyN)
262
263#ifndef __STRSAFE__NO_INLINE
264STRSAFEAPI StringCbCopyNA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPCSTR pszSrc,size_t cbToCopy) {
265 if(cbDest > STRSAFE_MAX_CCH || cbToCopy > STRSAFE_MAX_CCH)
266 return STRSAFE_E_INVALID_PARAMETER;
267 return StringCopyNWorkerA(pszDest,cbDest,pszSrc,cbToCopy);
268}
269
270STRSAFEAPI StringCbCopyNW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc,size_t cbToCopy) {
271 size_t cchDest = cbDest / sizeof(wchar_t);
272 size_t cchToCopy = cbToCopy / sizeof(wchar_t);
273 if(cchDest > STRSAFE_MAX_CCH || cchToCopy > STRSAFE_MAX_CCH)
274 return STRSAFE_E_INVALID_PARAMETER;
275 return StringCopyNWorkerW(pszDest,cchDest,pszSrc,cchToCopy);
276}
277#endif /* !__STRSAFE__NO_INLINE */
278
279STRSAFEAPI StringCchCopyNExA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc,size_t cchToCopy,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags);
280STRSAFEAPI StringCchCopyNExW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc,size_t cchToCopy,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags);
281
282#define StringCchCopyNEx __MINGW_NAME_AW(StringCchCopyNEx)
283
284#ifndef __STRSAFE__NO_INLINE
285STRSAFEAPI StringCchCopyNExA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc,size_t cchToCopy,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags) {
286 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
287 return StringCopyNExWorkerA(pszDest,cchDest,cchDest,pszSrc,cchToCopy,ppszDestEnd,pcchRemaining,dwFlags);
288}
289
290STRSAFEAPI StringCchCopyNExW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc,size_t cchToCopy,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags) {
291 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
292 return StringCopyNExWorkerW(pszDest,cchDest,cchDest * sizeof(wchar_t),pszSrc,cchToCopy,ppszDestEnd,pcchRemaining,dwFlags);
293}
294#endif /* !__STRSAFE__NO_INLINE */
295
296STRSAFEAPI StringCbCopyNExA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPCSTR pszSrc,size_t cbToCopy,STRSAFE_LPSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags);
297STRSAFEAPI StringCbCopyNExW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc,size_t cbToCopy,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags);
298
299#define StringCbCopyNEx __MINGW_NAME_AW(StringCbCopyNEx)
300
301#ifndef __STRSAFE__NO_INLINE
302STRSAFEAPI StringCbCopyNExA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPCSTR pszSrc,size_t cbToCopy,STRSAFE_LPSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags) {
303 HRESULT hr;
304 size_t cchRemaining = 0;
305 if(cbDest > STRSAFE_MAX_CCH)
306 hr = STRSAFE_E_INVALID_PARAMETER;
307 else
308 hr = StringCopyNExWorkerA(pszDest,cbDest,cbDest,pszSrc,cbToCopy,ppszDestEnd,&cchRemaining,dwFlags);
309 if((SUCCEEDED(hr) || hr == STRSAFE_E_INSUFFICIENT_BUFFER) && pcbRemaining)
310 *pcbRemaining = cchRemaining;
311 return hr;
312}
313
314STRSAFEAPI StringCbCopyNExW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc,size_t cbToCopy,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags) {
315 HRESULT hr;
316 size_t cchDest;
317 size_t cchToCopy;
318 size_t cchRemaining = 0;
319 cchDest = cbDest / sizeof(wchar_t);
320 cchToCopy = cbToCopy / sizeof(wchar_t);
321 if(cchDest > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
322 else hr = StringCopyNExWorkerW(pszDest,cchDest,cbDest,pszSrc,cchToCopy,ppszDestEnd,&cchRemaining,dwFlags);
323 if((SUCCEEDED(hr) || hr == STRSAFE_E_INSUFFICIENT_BUFFER) && pcbRemaining)
324 *pcbRemaining = (cchRemaining*sizeof(wchar_t)) + (cbDest % sizeof(wchar_t));
325 return hr;
326}
327#endif /* !__STRSAFE__NO_INLINE */
328
329STRSAFEAPI StringCchCatA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc);
330STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc);
331
332#define StringCchCat __MINGW_NAME_AW(StringCchCat)
333
334#ifndef __STRSAFE__NO_INLINE
335STRSAFEAPI StringCchCatA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc) {
336 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
337 return StringCatWorkerA(pszDest,cchDest,pszSrc);
338}
339
340STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc) {
341 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
342 return StringCatWorkerW(pszDest,cchDest,pszSrc);
343}
344#endif /* !__STRSAFE__NO_INLINE */
345
346STRSAFEAPI StringCbCatA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPCSTR pszSrc);
347STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc);
348
349#define StringCbCat __MINGW_NAME_AW(StringCbCat)
350
351#ifndef __STRSAFE__NO_INLINE
352STRSAFEAPI StringCbCatA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPCSTR pszSrc) {
353 if(cbDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
354 return StringCatWorkerA(pszDest,cbDest,pszSrc);
355}
356
357STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc) {
358 size_t cchDest = cbDest / sizeof(wchar_t);
359 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
360 return StringCatWorkerW(pszDest,cchDest,pszSrc);
361}
362#endif /* !__STRSAFE__NO_INLINE */
363
364STRSAFEAPI StringCchCatExA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags);
365STRSAFEAPI StringCchCatExW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags);
366
367#define StringCchCatEx __MINGW_NAME_AW(StringCchCatEx)
368
369#ifndef __STRSAFE__NO_INLINE
370STRSAFEAPI StringCchCatExA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags) {
371 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
372 return StringCatExWorkerA(pszDest,cchDest,cchDest,pszSrc,ppszDestEnd,pcchRemaining,dwFlags);
373}
374
375STRSAFEAPI StringCchCatExW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags) {
376 size_t cbDest = cchDest*sizeof(wchar_t);
377 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
378 return StringCatExWorkerW(pszDest,cchDest,cbDest,pszSrc,ppszDestEnd,pcchRemaining,dwFlags);
379}
380#endif /* !__STRSAFE__NO_INLINE */
381
382STRSAFEAPI StringCbCatExA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPCSTR pszSrc,STRSAFE_LPSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags);
383STRSAFEAPI StringCbCatExW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags);
384
385#define StringCbCatEx __MINGW_NAME_AW(StringCbCatEx)
386
387#ifndef __STRSAFE__NO_INLINE
388STRSAFEAPI StringCbCatExA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPCSTR pszSrc,STRSAFE_LPSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags) {
389 HRESULT hr;
390 size_t cchRemaining = 0;
391 if(cbDest > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
392 else hr = StringCatExWorkerA(pszDest,cbDest,cbDest,pszSrc,ppszDestEnd,&cchRemaining,dwFlags);
393 if((SUCCEEDED(hr) || hr == STRSAFE_E_INSUFFICIENT_BUFFER) && pcbRemaining)
394 *pcbRemaining = (cchRemaining*sizeof(char)) + (cbDest % sizeof(char));
395 return hr;
396}
397
398STRSAFEAPI StringCbCatExW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags) {
399 HRESULT hr;
400 size_t cchDest = cbDest / sizeof(wchar_t);
401 size_t cchRemaining = 0;
402
403 if(cchDest > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
404 else hr = StringCatExWorkerW(pszDest,cchDest,cbDest,pszSrc,ppszDestEnd,&cchRemaining,dwFlags);
405 if((SUCCEEDED(hr) || hr == STRSAFE_E_INSUFFICIENT_BUFFER) && pcbRemaining)
406 *pcbRemaining = (cchRemaining*sizeof(wchar_t)) + (cbDest % sizeof(wchar_t));
407 return hr;
408}
409#endif /* !__STRSAFE__NO_INLINE */
410
411STRSAFEAPI StringCchCatNA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc,size_t cchToAppend);
412STRSAFEAPI StringCchCatNW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc,size_t cchToAppend);
413
414#define StringCchCatN __MINGW_NAME_AW(StringCchCatN)
415
416#ifndef __STRSAFE__NO_INLINE
417STRSAFEAPI StringCchCatNA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc,size_t cchToAppend) {
418 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
419 return StringCatNWorkerA(pszDest,cchDest,pszSrc,cchToAppend);
420}
421
422STRSAFEAPI StringCchCatNW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc,size_t cchToAppend) {
423 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
424 return StringCatNWorkerW(pszDest,cchDest,pszSrc,cchToAppend);
425}
426#endif /* !__STRSAFE__NO_INLINE */
427
428STRSAFEAPI StringCbCatNA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPCSTR pszSrc,size_t cbToAppend);
429STRSAFEAPI StringCbCatNW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc,size_t cbToAppend);
430
431#define StringCbCatN __MINGW_NAME_AW(StringCbCatN)
432
433#ifndef __STRSAFE__NO_INLINE
434STRSAFEAPI StringCbCatNA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPCSTR pszSrc,size_t cbToAppend) {
435 if(cbDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
436 return StringCatNWorkerA(pszDest,cbDest,pszSrc,cbToAppend);
437}
438
439STRSAFEAPI StringCbCatNW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc,size_t cbToAppend) {
440 size_t cchDest = cbDest / sizeof(wchar_t);
441 size_t cchToAppend = cbToAppend / sizeof(wchar_t);
442
443 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
444 return StringCatNWorkerW(pszDest,cchDest,pszSrc,cchToAppend);
445}
446#endif /* !__STRSAFE__NO_INLINE */
447
448STRSAFEAPI StringCchCatNExA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc,size_t cchToAppend,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags);
449STRSAFEAPI StringCchCatNExW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc,size_t cchToAppend,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags);
450
451#define StringCchCatNEx __MINGW_NAME_AW(StringCchCatNEx)
452
453#ifndef __STRSAFE__NO_INLINE
454STRSAFEAPI StringCchCatNExA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc,size_t cchToAppend,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags) {
455 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
456 return StringCatNExWorkerA(pszDest,cchDest,cchDest,pszSrc,cchToAppend,ppszDestEnd,pcchRemaining,dwFlags);
457}
458
459STRSAFEAPI StringCchCatNExW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc,size_t cchToAppend,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags) {
460 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
461 return StringCatNExWorkerW(pszDest,cchDest,(cchDest*sizeof(wchar_t)),pszSrc,cchToAppend,ppszDestEnd,pcchRemaining,dwFlags);
462}
463#endif
464
465STRSAFEAPI StringCbCatNExA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPCSTR pszSrc,size_t cbToAppend,STRSAFE_LPSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags);
466STRSAFEAPI StringCbCatNExW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc,size_t cbToAppend,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags);
467
468#define StringCbCatNEx __MINGW_NAME_AW(StringCbCatNEx)
469
470#ifndef __STRSAFE__NO_INLINE
471STRSAFEAPI StringCbCatNExA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPCSTR pszSrc,size_t cbToAppend,STRSAFE_LPSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags) {
472 HRESULT hr;
473 size_t cchRemaining = 0;
474 if(cbDest > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
475 else hr = StringCatNExWorkerA(pszDest,cbDest,cbDest,pszSrc,cbToAppend,ppszDestEnd,&cchRemaining,dwFlags);
476 if((SUCCEEDED(hr) || hr == STRSAFE_E_INSUFFICIENT_BUFFER) && pcbRemaining)
477 *pcbRemaining = (cchRemaining*sizeof(char)) + (cbDest % sizeof(char));
478 return hr;
479}
480
481STRSAFEAPI StringCbCatNExW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc,size_t cbToAppend,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags) {
482 HRESULT hr;
483 size_t cchDest = cbDest / sizeof(wchar_t);
484 size_t cchToAppend = cbToAppend / sizeof(wchar_t);
485 size_t cchRemaining = 0;
486 if(cchDest > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
487 else hr = StringCatNExWorkerW(pszDest,cchDest,cbDest,pszSrc,cchToAppend,ppszDestEnd,&cchRemaining,dwFlags);
488 if((SUCCEEDED(hr) || hr == STRSAFE_E_INSUFFICIENT_BUFFER) && pcbRemaining)
489 *pcbRemaining = (cchRemaining*sizeof(wchar_t)) + (cbDest % sizeof(wchar_t));
490 return hr;
491}
492#endif /* !__STRSAFE__NO_INLINE */
493
494STRSAFEAPI StringCchVPrintfA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszFormat,va_list argList);
495STRSAFEAPI StringCchVPrintfW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszFormat,va_list argList);
496
497#define StringCchVPrintf __MINGW_NAME_AW(StringCchVPrintf)
498
499#ifndef __STRSAFE__NO_INLINE
500STRSAFEAPI StringCchVPrintfA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszFormat,va_list argList) {
501 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
502 return StringVPrintfWorkerA(pszDest,cchDest,pszFormat,argList);
503}
504
505STRSAFEAPI StringCchVPrintfW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszFormat,va_list argList) {
506 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
507 return StringVPrintfWorkerW(pszDest,cchDest,pszFormat,argList);
508}
509#endif /* !__STRSAFE__NO_INLINE */
510
511STRSAFEAPI StringCbVPrintfA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPCSTR pszFormat,va_list argList);
512STRSAFEAPI StringCbVPrintfW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPCWSTR pszFormat,va_list argList);
513
514#define StringCbVPrintf __MINGW_NAME_AW(StringCbVPrintf)
515
516#ifndef __STRSAFE__NO_INLINE
517STRSAFEAPI StringCbVPrintfA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPCSTR pszFormat,va_list argList) {
518 if(cbDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
519 return StringVPrintfWorkerA(pszDest,cbDest,pszFormat,argList);
520}
521
522STRSAFEAPI StringCbVPrintfW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPCWSTR pszFormat,va_list argList) {
523 size_t cchDest = cbDest / sizeof(wchar_t);
524 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
525 return StringVPrintfWorkerW(pszDest,cchDest,pszFormat,argList);
526}
527#endif /* !__STRSAFE__NO_INLINE */
528
529STRSAFEAPIV StringCchPrintfA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszFormat,...);
530STRSAFEAPIV StringCchPrintfW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszFormat,...);
531
532#define StringCchPrintf __MINGW_NAME_AW(StringCchPrintf)
533
534#ifndef __STRSAFE__NO_INLINE
535STRSAFEAPIV StringCchPrintfA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszFormat,...) {
536 HRESULT hr;
537 va_list argList;
538 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
539 va_start(argList,pszFormat);
540 hr = StringVPrintfWorkerA(pszDest,cchDest,pszFormat,argList);
541 va_end(argList);
542 return hr;
543}
544
545STRSAFEAPIV StringCchPrintfW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszFormat,...) {
546 HRESULT hr;
547 va_list argList;
548 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
549 va_start(argList,pszFormat);
550 hr = StringVPrintfWorkerW(pszDest,cchDest,pszFormat,argList);
551 va_end(argList);
552 return hr;
553}
554#endif /* !__STRSAFE__NO_INLINE */
555
556STRSAFEAPIV StringCbPrintfA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPCSTR pszFormat,...);
557STRSAFEAPIV StringCbPrintfW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPCWSTR pszFormat,...);
558
559#define StringCbPrintf __MINGW_NAME_AW(StringCbPrintf)
560
561#ifndef __STRSAFE__NO_INLINE
562STRSAFEAPIV StringCbPrintfA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPCSTR pszFormat,...) {
563 HRESULT hr;
564 va_list argList;
565 if(cbDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
566 va_start(argList,pszFormat);
567 hr = StringVPrintfWorkerA(pszDest,cbDest,pszFormat,argList);
568 va_end(argList);
569 return hr;
570}
571
572STRSAFEAPIV StringCbPrintfW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPCWSTR pszFormat,...) {
573 HRESULT hr;
574 va_list argList;
575 size_t cchDest = cbDest / sizeof(wchar_t);
576 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
577 va_start(argList,pszFormat);
578 hr = StringVPrintfWorkerW(pszDest,cchDest,pszFormat,argList);
579 va_end(argList);
580 return hr;
581}
582#endif /* !__STRSAFE__NO_INLINE */
583
584STRSAFEAPIV StringCchPrintfExA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags,STRSAFE_LPCSTR pszFormat,...);
585STRSAFEAPIV StringCchPrintfExW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags,STRSAFE_LPCWSTR pszFormat,...);
586
587#define StringCchPrintfEx __MINGW_NAME_AW(StringCchPrintfEx)
588
589#ifndef __STRSAFE__NO_INLINE
590STRSAFEAPIV StringCchPrintfExA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags,STRSAFE_LPCSTR pszFormat,...) {
591 HRESULT hr;
592 va_list argList;
593 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
594 va_start(argList,pszFormat);
595 hr = StringVPrintfExWorkerA(pszDest,cchDest,cchDest,ppszDestEnd,pcchRemaining,dwFlags,pszFormat,argList);
596 va_end(argList);
597 return hr;
598}
599
600STRSAFEAPIV StringCchPrintfExW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags,STRSAFE_LPCWSTR pszFormat,...) {
601 HRESULT hr;
602 size_t cbDest = cchDest * sizeof(wchar_t);
603 va_list argList;
604 if(cchDest > STRSAFE_MAX_CCH) return STRSAFE_E_INVALID_PARAMETER;
605 va_start(argList,pszFormat);
606 hr = StringVPrintfExWorkerW(pszDest,cchDest,cbDest,ppszDestEnd,pcchRemaining,dwFlags,pszFormat,argList);
607 va_end(argList);
608 return hr;
609}
610#endif /* !__STRSAFE__NO_INLINE */
611
612STRSAFEAPIV StringCbPrintfExA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags,STRSAFE_LPCSTR pszFormat,...);
613STRSAFEAPIV StringCbPrintfExW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags,STRSAFE_LPCWSTR pszFormat,...);
614
615#define StringCbPrintfEx __MINGW_NAME_AW(StringCbPrintfEx)
616
617#ifndef __STRSAFE__NO_INLINE
618STRSAFEAPIV StringCbPrintfExA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags,STRSAFE_LPCSTR pszFormat,...) {
619 HRESULT hr;
620 size_t cchDest;
621 size_t cchRemaining = 0;
622 cchDest = cbDest / sizeof(char);
623 if(cchDest > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
624 else {
625 va_list argList;
626 va_start(argList,pszFormat);
627 hr = StringVPrintfExWorkerA(pszDest,cchDest,cbDest,ppszDestEnd,&cchRemaining,dwFlags,pszFormat,argList);
628 va_end(argList);
629 }
630 if(SUCCEEDED(hr) || (hr==STRSAFE_E_INSUFFICIENT_BUFFER)) {
631 if(pcbRemaining) {
632 *pcbRemaining = (cchRemaining*sizeof(char)) + (cbDest % sizeof(char));
633 }
634 }
635 return hr;
636}
637
638STRSAFEAPIV StringCbPrintfExW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags,STRSAFE_LPCWSTR pszFormat,...) {
639 HRESULT hr;
640 size_t cchDest;
641 size_t cchRemaining = 0;
642 cchDest = cbDest / sizeof(wchar_t);
643 if(cchDest > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
644 else {
645 va_list argList;
646 va_start(argList,pszFormat);
647 hr = StringVPrintfExWorkerW(pszDest,cchDest,cbDest,ppszDestEnd,&cchRemaining,dwFlags,pszFormat,argList);
648 va_end(argList);
649 }
650 if(SUCCEEDED(hr) || (hr==STRSAFE_E_INSUFFICIENT_BUFFER)) {
651 if(pcbRemaining) {
652 *pcbRemaining = (cchRemaining*sizeof(wchar_t)) + (cbDest % sizeof(wchar_t));
653 }
654 }
655 return hr;
656}
657#endif /* !__STRSAFE__NO_INLINE */
658
659STRSAFEAPI StringCchVPrintfExA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags,STRSAFE_LPCSTR pszFormat,va_list argList);
660STRSAFEAPI StringCchVPrintfExW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags,STRSAFE_LPCWSTR pszFormat,va_list argList);
661
662#define StringCchVPrintfEx __MINGW_NAME_AW(StringCchVPrintfEx)
663
664#ifndef __STRSAFE__NO_INLINE
665STRSAFEAPI StringCchVPrintfExA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags,STRSAFE_LPCSTR pszFormat,va_list argList) {
666 HRESULT hr;
667 if(cchDest > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
668 else {
669 size_t cbDest;
670 cbDest = cchDest*sizeof(char);
671 hr = StringVPrintfExWorkerA(pszDest,cchDest,cbDest,ppszDestEnd,pcchRemaining,dwFlags,pszFormat,argList);
672 }
673 return hr;
674}
675
676STRSAFEAPI StringCchVPrintfExW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags,STRSAFE_LPCWSTR pszFormat,va_list argList) {
677 HRESULT hr;
678 if(cchDest > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
679 else {
680 size_t cbDest;
681 cbDest = cchDest*sizeof(wchar_t);
682 hr = StringVPrintfExWorkerW(pszDest,cchDest,cbDest,ppszDestEnd,pcchRemaining,dwFlags,pszFormat,argList);
683 }
684 return hr;
685}
686#endif /* !__STRSAFE__NO_INLINE */
687
688STRSAFEAPI StringCbVPrintfExA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags,STRSAFE_LPCSTR pszFormat,va_list argList);
689STRSAFEAPI StringCbVPrintfExW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags,STRSAFE_LPCWSTR pszFormat,va_list argList);
690
691#define StringCbVPrintfEx __MINGW_NAME_AW(StringCbVPrintfEx)
692
693#ifndef __STRSAFE__NO_INLINE
694STRSAFEAPI StringCbVPrintfExA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags,STRSAFE_LPCSTR pszFormat,va_list argList) {
695 HRESULT hr;
696 size_t cchDest;
697 size_t cchRemaining = 0;
698 cchDest = cbDest / sizeof(char);
699 if(cchDest > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
700 else hr = StringVPrintfExWorkerA(pszDest,cchDest,cbDest,ppszDestEnd,&cchRemaining,dwFlags,pszFormat,argList);
701 if(SUCCEEDED(hr) || (hr==STRSAFE_E_INSUFFICIENT_BUFFER)) {
702 if(pcbRemaining) {
703 *pcbRemaining = (cchRemaining*sizeof(char)) + (cbDest % sizeof(char));
704 }
705 }
706 return hr;
707}
708
709STRSAFEAPI StringCbVPrintfExW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags,STRSAFE_LPCWSTR pszFormat,va_list argList) {
710 HRESULT hr;
711 size_t cchDest;
712 size_t cchRemaining = 0;
713 cchDest = cbDest / sizeof(wchar_t);
714 if(cchDest > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
715 else hr = StringVPrintfExWorkerW(pszDest,cchDest,cbDest,ppszDestEnd,&cchRemaining,dwFlags,pszFormat,argList);
716 if(SUCCEEDED(hr) || (hr==STRSAFE_E_INSUFFICIENT_BUFFER)) {
717 if(pcbRemaining) {
718 *pcbRemaining = (cchRemaining*sizeof(wchar_t)) + (cbDest % sizeof(wchar_t));
719 }
720 }
721 return hr;
722}
723#endif /* !__STRSAFE__NO_INLINE */
724
725STRSAFE_INLINE_API StringCchGetsA(STRSAFE_LPSTR pszDest,size_t cchDest);
726STRSAFE_INLINE_API StringCchGetsW(STRSAFE_LPWSTR pszDest,size_t cchDest);
727
728#define StringCchGets __MINGW_NAME_AW(StringCchGets)
729
730#ifndef __STRSAFE__NO_INLINE
731STRSAFE_INLINE_API StringCchGetsA(STRSAFE_LPSTR pszDest,size_t cchDest) {
732 HRESULT hr;
733 if(cchDest > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
734 else {
735 size_t cbDest;
736 cbDest = cchDest*sizeof(char);
737 hr = StringGetsExWorkerA(pszDest,cchDest,cbDest,NULL,NULL,0);
738 }
739 return hr;
740}
741
742STRSAFE_INLINE_API StringCchGetsW(STRSAFE_LPWSTR pszDest,size_t cchDest) {
743 HRESULT hr;
744 if(cchDest > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
745 else {
746 size_t cbDest;
747 cbDest = cchDest*sizeof(wchar_t);
748 hr = StringGetsExWorkerW(pszDest,cchDest,cbDest,NULL,NULL,0);
749 }
750 return hr;
751}
752#endif /* !__STRSAFE__NO_INLINE */
753
754STRSAFE_INLINE_API StringCbGetsA(STRSAFE_LPSTR pszDest,size_t cbDest);
755STRSAFE_INLINE_API StringCbGetsW(STRSAFE_LPWSTR pszDest,size_t cbDest);
756
757#define StringCbGets __MINGW_NAME_AW(StringCbGets)
758
759#ifndef __STRSAFE__NO_INLINE
760STRSAFE_INLINE_API StringCbGetsA(STRSAFE_LPSTR pszDest,size_t cbDest) {
761 HRESULT hr;
762 size_t cchDest;
763 cchDest = cbDest / sizeof(char);
764 if(cchDest > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
765 else hr = StringGetsExWorkerA(pszDest,cchDest,cbDest,NULL,NULL,0);
766 return hr;
767}
768
769STRSAFE_INLINE_API StringCbGetsW(STRSAFE_LPWSTR pszDest,size_t cbDest) {
770 HRESULT hr;
771 size_t cchDest;
772 cchDest = cbDest / sizeof(wchar_t);
773 if(cchDest > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
774 else hr = StringGetsExWorkerW(pszDest,cchDest,cbDest,NULL,NULL,0);
775 return hr;
776}
777#endif /* !__STRSAFE__NO_INLINE */
778
779STRSAFE_INLINE_API StringCchGetsExA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags);
780STRSAFE_INLINE_API StringCchGetsExW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags);
781
782#define StringCchGetsEx __MINGW_NAME_AW(StringCchGetsEx)
783
784#ifndef __STRSAFE__NO_INLINE
785STRSAFE_INLINE_API StringCchGetsExA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags) {
786 HRESULT hr;
787 if(cchDest > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
788 else {
789 size_t cbDest;
790 cbDest = cchDest*sizeof(char);
791 hr = StringGetsExWorkerA(pszDest,cchDest,cbDest,ppszDestEnd,pcchRemaining,dwFlags);
792 }
793 return hr;
794}
795
796STRSAFE_INLINE_API StringCchGetsExW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags) {
797 HRESULT hr;
798 if(cchDest > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
799 else {
800 size_t cbDest;
801 cbDest = cchDest*sizeof(wchar_t);
802 hr = StringGetsExWorkerW(pszDest,cchDest,cbDest,ppszDestEnd,pcchRemaining,dwFlags);
803 }
804 return hr;
805}
806#endif /* !__STRSAFE__NO_INLINE */
807
808STRSAFE_INLINE_API StringCbGetsExA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags);
809STRSAFE_INLINE_API StringCbGetsExW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags);
810
811#define StringCbGetsEx __MINGW_NAME_AW(StringCbGetsEx)
812
813#ifndef __STRSAFE__NO_INLINE
814STRSAFE_INLINE_API StringCbGetsExA(STRSAFE_LPSTR pszDest,size_t cbDest,STRSAFE_LPSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags) {
815 HRESULT hr;
816 size_t cchDest;
817 size_t cchRemaining = 0;
818 cchDest = cbDest / sizeof(char);
819 if(cchDest > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
820 else hr = StringGetsExWorkerA(pszDest,cchDest,cbDest,ppszDestEnd,&cchRemaining,dwFlags);
821 if(SUCCEEDED(hr) || (hr==STRSAFE_E_INSUFFICIENT_BUFFER) || (hr==STRSAFE_E_END_OF_FILE)) {
822 if(pcbRemaining) *pcbRemaining = (cchRemaining*sizeof(char)) + (cbDest % sizeof(char));
823 }
824 return hr;
825}
826
827STRSAFE_INLINE_API StringCbGetsExW(STRSAFE_LPWSTR pszDest,size_t cbDest,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcbRemaining,unsigned __LONG32 dwFlags) {
828 HRESULT hr;
829 size_t cchDest;
830 size_t cchRemaining = 0;
831 cchDest = cbDest / sizeof(wchar_t);
832 if(cchDest > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
833 else hr = StringGetsExWorkerW(pszDest,cchDest,cbDest,ppszDestEnd,&cchRemaining,dwFlags);
834 if(SUCCEEDED(hr) || (hr==STRSAFE_E_INSUFFICIENT_BUFFER) || (hr==STRSAFE_E_END_OF_FILE)) {
835 if(pcbRemaining) *pcbRemaining = (cchRemaining*sizeof(wchar_t)) + (cbDest % sizeof(wchar_t));
836 }
837 return hr;
838}
839#endif /* !__STRSAFE__NO_INLINE */
840
841STRSAFEAPI StringCchLengthA(STRSAFE_LPCSTR psz,size_t cchMax,size_t *pcchLength);
842STRSAFEAPI StringCchLengthW(STRSAFE_LPCWSTR psz,size_t cchMax,size_t *pcchLength);
843
844#define StringCchLength __MINGW_NAME_AW(StringCchLength)
845
846#ifndef __STRSAFE__NO_INLINE
847STRSAFEAPI StringCchLengthA(STRSAFE_LPCSTR psz,size_t cchMax,size_t *pcchLength) {
848 HRESULT hr;
849 if(!psz || (cchMax > STRSAFE_MAX_CCH)) hr = STRSAFE_E_INVALID_PARAMETER;
850 else hr = StringLengthWorkerA(psz,cchMax,pcchLength);
851 if(FAILED(hr) && pcchLength) {
852 *pcchLength = 0;
853 }
854 return hr;
855}
856
857STRSAFEAPI StringCchLengthW(STRSAFE_LPCWSTR psz,size_t cchMax,size_t *pcchLength) {
858 HRESULT hr;
859 if(!psz || (cchMax > STRSAFE_MAX_CCH)) hr = STRSAFE_E_INVALID_PARAMETER;
860 else hr = StringLengthWorkerW(psz,cchMax,pcchLength);
861 if(FAILED(hr) && pcchLength) {
862 *pcchLength = 0;
863 }
864 return hr;
865}
866#endif /* !__STRSAFE__NO_INLINE */
867
868STRSAFEAPI StringCbLengthA(STRSAFE_LPCSTR psz,size_t cbMax,size_t *pcbLength);
869STRSAFEAPI StringCbLengthW(STRSAFE_LPCWSTR psz,size_t cbMax,size_t *pcbLength);
870
871#define StringCbLength __MINGW_NAME_AW(StringCbLength)
872
873#ifndef __STRSAFE__NO_INLINE
874STRSAFEAPI StringCbLengthA(STRSAFE_LPCSTR psz,size_t cbMax,size_t *pcbLength) {
875 HRESULT hr;
876 size_t cchMax;
877 size_t cchLength = 0;
878 cchMax = cbMax / sizeof(char);
879 if(!psz || (cchMax > STRSAFE_MAX_CCH)) hr = STRSAFE_E_INVALID_PARAMETER;
880 else hr = StringLengthWorkerA(psz,cchMax,&cchLength);
881 if(pcbLength) {
882 if(SUCCEEDED(hr)) {
883 *pcbLength = cchLength*sizeof(char);
884 } else {
885 *pcbLength = 0;
886 }
887 }
888 return hr;
889}
890
891STRSAFEAPI StringCbLengthW(STRSAFE_LPCWSTR psz,size_t cbMax,size_t *pcbLength) {
892 HRESULT hr;
893 size_t cchMax;
894 size_t cchLength = 0;
895 cchMax = cbMax / sizeof(wchar_t);
896 if(!psz || (cchMax > STRSAFE_MAX_CCH)) hr = STRSAFE_E_INVALID_PARAMETER;
897 else hr = StringLengthWorkerW(psz,cchMax,&cchLength);
898 if(pcbLength) {
899 if(SUCCEEDED(hr)) {
900 *pcbLength = cchLength*sizeof(wchar_t);
901 } else {
902 *pcbLength = 0;
903 }
904 }
905 return hr;
906}
907
908STRSAFEAPI StringCopyWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc) {
909 HRESULT hr = S_OK;
910 if(cchDest==0) hr = STRSAFE_E_INVALID_PARAMETER;
911 else {
912 while(cchDest && (*pszSrc!='\0')) {
913 *pszDest++ = *pszSrc++;
914 cchDest--;
915 }
916 if(cchDest==0) {
917 pszDest--;
918 hr = STRSAFE_E_INSUFFICIENT_BUFFER;
919 }
920 *pszDest= '\0';
921 }
922 return hr;
923}
924
925STRSAFEAPI StringCopyWorkerW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc) {
926 HRESULT hr = S_OK;
927 if(cchDest==0) hr = STRSAFE_E_INVALID_PARAMETER;
928 else {
929 while(cchDest && (*pszSrc!=L'\0')) {
930 *pszDest++ = *pszSrc++;
931 cchDest--;
932 }
933 if(cchDest==0) {
934 pszDest--;
935 hr = STRSAFE_E_INSUFFICIENT_BUFFER;
936 }
937 *pszDest= L'\0';
938 }
939 return hr;
940}
941
942STRSAFEAPI StringCopyExWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPCSTR pszSrc,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags) {
943 HRESULT hr = S_OK;
944 STRSAFE_LPSTR pszDestEnd = pszDest;
945 size_t cchRemaining = 0;
946 if(dwFlags & (~STRSAFE_VALID_FLAGS)) hr = STRSAFE_E_INVALID_PARAMETER;
947 else {
948 if(dwFlags & STRSAFE_IGNORE_NULLS) {
949 if(!pszDest) {
950 if((cchDest!=0) || (cbDest!=0)) hr = STRSAFE_E_INVALID_PARAMETER;
951 }
952 if(!pszSrc) pszSrc = "";
953 }
954 if(SUCCEEDED(hr)) {
955 if(cchDest==0) {
956 pszDestEnd = pszDest;
957 cchRemaining = 0;
958 if(*pszSrc!='\0') {
959 if(!pszDest) hr = STRSAFE_E_INVALID_PARAMETER;
960 else hr = STRSAFE_E_INSUFFICIENT_BUFFER;
961 }
962 } else {
963 pszDestEnd = pszDest;
964 cchRemaining = cchDest;
965 while(cchRemaining && (*pszSrc!='\0')) {
966 *pszDestEnd++ = *pszSrc++;
967 cchRemaining--;
968 }
969 if(cchRemaining > 0) {
970 if(dwFlags & STRSAFE_FILL_BEHIND_NULL) {
971 memset(pszDestEnd + 1,STRSAFE_GET_FILL_PATTERN(dwFlags),((cchRemaining - 1)*sizeof(char)) + (cbDest % sizeof(char)));
972 }
973 } else {
974 pszDestEnd--;
975 cchRemaining++;
976 hr = STRSAFE_E_INSUFFICIENT_BUFFER;
977 }
978 *pszDestEnd = '\0';
979 }
980 }
981 }
982 if(FAILED(hr)) {
983 if(pszDest) {
984 if(dwFlags & STRSAFE_FILL_ON_FAILURE) {
985 memset(pszDest,STRSAFE_GET_FILL_PATTERN(dwFlags),cbDest);
986 if(STRSAFE_GET_FILL_PATTERN(dwFlags)==0) {
987 pszDestEnd = pszDest;
988 cchRemaining = cchDest;
989 } else if(cchDest > 0) {
990 pszDestEnd = pszDest + cchDest - 1;
991 cchRemaining = 1;
992 *pszDestEnd = '\0';
993 }
994 }
995 if(dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) {
996 if(cchDest > 0) {
997 pszDestEnd = pszDest;
998 cchRemaining = cchDest;
999 *pszDestEnd = '\0';
1000 }
1001 }
1002 }
1003 }
1004 if(SUCCEEDED(hr) || (hr==STRSAFE_E_INSUFFICIENT_BUFFER)) {
1005 if(ppszDestEnd) *ppszDestEnd = pszDestEnd;
1006 if(pcchRemaining) *pcchRemaining = cchRemaining;
1007 }
1008 return hr;
1009}
1010
1011STRSAFEAPI StringCopyExWorkerW(STRSAFE_LPWSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags) {
1012 HRESULT hr = S_OK;
1013 STRSAFE_LPWSTR pszDestEnd = pszDest;
1014 size_t cchRemaining = 0;
1015 if(dwFlags & (~STRSAFE_VALID_FLAGS)) hr = STRSAFE_E_INVALID_PARAMETER;
1016 else {
1017 if(dwFlags & STRSAFE_IGNORE_NULLS) {
1018 if(!pszDest) {
1019 if((cchDest!=0) || (cbDest!=0)) hr = STRSAFE_E_INVALID_PARAMETER;
1020 }
1021 if(!pszSrc) pszSrc = L"";
1022 }
1023 if(SUCCEEDED(hr)) {
1024 if(cchDest==0) {
1025 pszDestEnd = pszDest;
1026 cchRemaining = 0;
1027 if(*pszSrc!=L'\0') {
1028 if(!pszDest) hr = STRSAFE_E_INVALID_PARAMETER;
1029 else hr = STRSAFE_E_INSUFFICIENT_BUFFER;
1030 }
1031 } else {
1032 pszDestEnd = pszDest;
1033 cchRemaining = cchDest;
1034 while(cchRemaining && (*pszSrc!=L'\0')) {
1035 *pszDestEnd++ = *pszSrc++;
1036 cchRemaining--;
1037 }
1038 if(cchRemaining > 0) {
1039 if(dwFlags & STRSAFE_FILL_BEHIND_NULL) {
1040 memset(pszDestEnd + 1,STRSAFE_GET_FILL_PATTERN(dwFlags),((cchRemaining - 1)*sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)));
1041 }
1042 } else {
1043 pszDestEnd--;
1044 cchRemaining++;
1045 hr = STRSAFE_E_INSUFFICIENT_BUFFER;
1046 }
1047 *pszDestEnd = L'\0';
1048 }
1049 }
1050 }
1051 if(FAILED(hr)) {
1052 if(pszDest) {
1053 if(dwFlags & STRSAFE_FILL_ON_FAILURE) {
1054 memset(pszDest,STRSAFE_GET_FILL_PATTERN(dwFlags),cbDest);
1055 if(STRSAFE_GET_FILL_PATTERN(dwFlags)==0) {
1056 pszDestEnd = pszDest;
1057 cchRemaining = cchDest;
1058 } else if(cchDest > 0) {
1059 pszDestEnd = pszDest + cchDest - 1;
1060 cchRemaining = 1;
1061 *pszDestEnd = L'\0';
1062 }
1063 }
1064 if(dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) {
1065 if(cchDest > 0) {
1066 pszDestEnd = pszDest;
1067 cchRemaining = cchDest;
1068 *pszDestEnd = L'\0';
1069 }
1070 }
1071 }
1072 }
1073 if(SUCCEEDED(hr) || (hr==STRSAFE_E_INSUFFICIENT_BUFFER)) {
1074 if(ppszDestEnd) *ppszDestEnd = pszDestEnd;
1075 if(pcchRemaining) *pcchRemaining = cchRemaining;
1076 }
1077 return hr;
1078}
1079
1080STRSAFEAPI StringCopyNWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc,size_t cchSrc) {
1081 HRESULT hr = S_OK;
1082 if(cchDest==0) hr = STRSAFE_E_INVALID_PARAMETER;
1083 else {
1084 while(cchDest && cchSrc && (*pszSrc!='\0')) {
1085 *pszDest++ = *pszSrc++;
1086 cchDest--;
1087 cchSrc--;
1088 }
1089 if(cchDest==0) {
1090 pszDest--;
1091 hr = STRSAFE_E_INSUFFICIENT_BUFFER;
1092 }
1093 *pszDest= '\0';
1094 }
1095 return hr;
1096}
1097
1098STRSAFEAPI StringCopyNWorkerW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc,size_t cchToCopy) {
1099 HRESULT hr = S_OK;
1100 if(cchDest==0) hr = STRSAFE_E_INVALID_PARAMETER;
1101 else {
1102 while(cchDest && cchToCopy && (*pszSrc!=L'\0')) {
1103 *pszDest++ = *pszSrc++;
1104 cchDest--;
1105 cchToCopy--;
1106 }
1107 if(cchDest==0) {
1108 pszDest--;
1109 hr = STRSAFE_E_INSUFFICIENT_BUFFER;
1110 }
1111 *pszDest= L'\0';
1112 }
1113 return hr;
1114}
1115
1116STRSAFEAPI StringCopyNExWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPCSTR pszSrc,size_t cchToCopy,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags) {
1117 HRESULT hr = S_OK;
1118 STRSAFE_LPSTR pszDestEnd = pszDest;
1119 size_t cchRemaining = 0;
1120 if(dwFlags & (~STRSAFE_VALID_FLAGS)) hr = STRSAFE_E_INVALID_PARAMETER;
1121 else if(cchToCopy > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
1122 else {
1123 if(dwFlags & STRSAFE_IGNORE_NULLS) {
1124 if(!pszDest) {
1125 if((cchDest!=0) || (cbDest!=0)) hr = STRSAFE_E_INVALID_PARAMETER;
1126 }
1127 if(!pszSrc) pszSrc = "";
1128 }
1129 if(SUCCEEDED(hr)) {
1130 if(cchDest==0) {
1131 pszDestEnd = pszDest;
1132 cchRemaining = 0;
1133 if((cchToCopy!=0) && (*pszSrc!='\0')) {
1134 if(!pszDest) hr = STRSAFE_E_INVALID_PARAMETER;
1135 else hr = STRSAFE_E_INSUFFICIENT_BUFFER;
1136 }
1137 } else {
1138 pszDestEnd = pszDest;
1139 cchRemaining = cchDest;
1140 while(cchRemaining && cchToCopy && (*pszSrc!='\0')) {
1141 *pszDestEnd++ = *pszSrc++;
1142 cchRemaining--;
1143 cchToCopy--;
1144 }
1145 if(cchRemaining > 0) {
1146 if(dwFlags & STRSAFE_FILL_BEHIND_NULL) {
1147 memset(pszDestEnd + 1,STRSAFE_GET_FILL_PATTERN(dwFlags),((cchRemaining - 1)*sizeof(char)) + (cbDest % sizeof(char)));
1148 }
1149 } else {
1150 pszDestEnd--;
1151 cchRemaining++;
1152 hr = STRSAFE_E_INSUFFICIENT_BUFFER;
1153 }
1154 *pszDestEnd = '\0';
1155 }
1156 }
1157 }
1158 if(FAILED(hr)) {
1159 if(pszDest) {
1160 if(dwFlags & STRSAFE_FILL_ON_FAILURE) {
1161 memset(pszDest,STRSAFE_GET_FILL_PATTERN(dwFlags),cbDest);
1162 if(STRSAFE_GET_FILL_PATTERN(dwFlags)==0) {
1163 pszDestEnd = pszDest;
1164 cchRemaining = cchDest;
1165 } else if(cchDest > 0) {
1166 pszDestEnd = pszDest + cchDest - 1;
1167 cchRemaining = 1;
1168 *pszDestEnd = '\0';
1169 }
1170 }
1171 if(dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) {
1172 if(cchDest > 0) {
1173 pszDestEnd = pszDest;
1174 cchRemaining = cchDest;
1175 *pszDestEnd = '\0';
1176 }
1177 }
1178 }
1179 }
1180 if(SUCCEEDED(hr) || (hr==STRSAFE_E_INSUFFICIENT_BUFFER)) {
1181 if(ppszDestEnd) *ppszDestEnd = pszDestEnd;
1182 if(pcchRemaining) *pcchRemaining = cchRemaining;
1183 }
1184 return hr;
1185}
1186
1187STRSAFEAPI StringCopyNExWorkerW(STRSAFE_LPWSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc,size_t cchToCopy,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags) {
1188 HRESULT hr = S_OK;
1189 STRSAFE_LPWSTR pszDestEnd = pszDest;
1190 size_t cchRemaining = 0;
1191 if(dwFlags & (~STRSAFE_VALID_FLAGS)) hr = STRSAFE_E_INVALID_PARAMETER;
1192 else if(cchToCopy > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
1193 else {
1194 if(dwFlags & STRSAFE_IGNORE_NULLS) {
1195 if(!pszDest) {
1196 if((cchDest!=0) || (cbDest!=0)) hr = STRSAFE_E_INVALID_PARAMETER;
1197 }
1198 if(!pszSrc) pszSrc = L"";
1199 }
1200 if(SUCCEEDED(hr)) {
1201 if(cchDest==0) {
1202 pszDestEnd = pszDest;
1203 cchRemaining = 0;
1204 if((cchToCopy!=0) && (*pszSrc!=L'\0')) {
1205 if(!pszDest) hr = STRSAFE_E_INVALID_PARAMETER;
1206 else hr = STRSAFE_E_INSUFFICIENT_BUFFER;
1207 }
1208 } else {
1209 pszDestEnd = pszDest;
1210 cchRemaining = cchDest;
1211 while(cchRemaining && cchToCopy && (*pszSrc!=L'\0')) {
1212 *pszDestEnd++ = *pszSrc++;
1213 cchRemaining--;
1214 cchToCopy--;
1215 }
1216 if(cchRemaining > 0) {
1217 if(dwFlags & STRSAFE_FILL_BEHIND_NULL) {
1218 memset(pszDestEnd + 1,STRSAFE_GET_FILL_PATTERN(dwFlags),((cchRemaining - 1)*sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)));
1219 }
1220 } else {
1221 pszDestEnd--;
1222 cchRemaining++;
1223 hr = STRSAFE_E_INSUFFICIENT_BUFFER;
1224 }
1225 *pszDestEnd = L'\0';
1226 }
1227 }
1228 }
1229 if(FAILED(hr)) {
1230 if(pszDest) {
1231 if(dwFlags & STRSAFE_FILL_ON_FAILURE) {
1232 memset(pszDest,STRSAFE_GET_FILL_PATTERN(dwFlags),cbDest);
1233 if(STRSAFE_GET_FILL_PATTERN(dwFlags)==0) {
1234 pszDestEnd = pszDest;
1235 cchRemaining = cchDest;
1236 } else if(cchDest > 0) {
1237 pszDestEnd = pszDest + cchDest - 1;
1238 cchRemaining = 1;
1239 *pszDestEnd = L'\0';
1240 }
1241 }
1242 if(dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) {
1243 if(cchDest > 0) {
1244 pszDestEnd = pszDest;
1245 cchRemaining = cchDest;
1246 *pszDestEnd = L'\0';
1247 }
1248 }
1249 }
1250 }
1251 if(SUCCEEDED(hr) || (hr==STRSAFE_E_INSUFFICIENT_BUFFER)) {
1252 if(ppszDestEnd) *ppszDestEnd = pszDestEnd;
1253 if(pcchRemaining) *pcchRemaining = cchRemaining;
1254 }
1255 return hr;
1256}
1257
1258STRSAFEAPI StringCatWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc) {
1259 HRESULT hr;
1260 size_t cchDestLength;
1261 hr = StringLengthWorkerA(pszDest,cchDest,&cchDestLength);
1262 if(SUCCEEDED(hr)) hr = StringCopyWorkerA(pszDest + cchDestLength,cchDest - cchDestLength,pszSrc);
1263 return hr;
1264}
1265
1266STRSAFEAPI StringCatWorkerW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc) {
1267 HRESULT hr;
1268 size_t cchDestLength;
1269 hr = StringLengthWorkerW(pszDest,cchDest,&cchDestLength);
1270 if(SUCCEEDED(hr)) hr = StringCopyWorkerW(pszDest + cchDestLength,cchDest - cchDestLength,pszSrc);
1271 return hr;
1272}
1273
1274STRSAFEAPI StringCatExWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPCSTR pszSrc,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags) {
1275 HRESULT hr = S_OK;
1276 STRSAFE_LPSTR pszDestEnd = pszDest;
1277 size_t cchRemaining = 0;
1278 if(dwFlags & (~STRSAFE_VALID_FLAGS)) hr = STRSAFE_E_INVALID_PARAMETER;
1279 else {
1280 size_t cchDestLength;
1281 if(dwFlags & STRSAFE_IGNORE_NULLS) {
1282 if(!pszDest) {
1283 if((cchDest==0) && (cbDest==0)) cchDestLength = 0;
1284 else hr = STRSAFE_E_INVALID_PARAMETER;
1285 } else {
1286 hr = StringLengthWorkerA(pszDest,cchDest,&cchDestLength);
1287 if(SUCCEEDED(hr)) {
1288 pszDestEnd = pszDest + cchDestLength;
1289 cchRemaining = cchDest - cchDestLength;
1290 }
1291 }
1292 if(!pszSrc) pszSrc = "";
1293 } else {
1294 hr = StringLengthWorkerA(pszDest,cchDest,&cchDestLength);
1295 if(SUCCEEDED(hr)) {
1296 pszDestEnd = pszDest + cchDestLength;
1297 cchRemaining = cchDest - cchDestLength;
1298 }
1299 }
1300 if(SUCCEEDED(hr)) {
1301 if(cchDest==0) {
1302 if(*pszSrc!='\0') {
1303 if(!pszDest) hr = STRSAFE_E_INVALID_PARAMETER;
1304 else hr = STRSAFE_E_INSUFFICIENT_BUFFER;
1305 }
1306 } else hr = StringCopyExWorkerA(pszDestEnd,cchRemaining,(cchRemaining*sizeof(char)) + (cbDest % sizeof(char)),pszSrc,&pszDestEnd,&cchRemaining,dwFlags & (~(STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE)));
1307 }
1308 }
1309 if(FAILED(hr)) {
1310 if(pszDest) {
1311 if(dwFlags & STRSAFE_FILL_ON_FAILURE) {
1312 memset(pszDest,STRSAFE_GET_FILL_PATTERN(dwFlags),cbDest);
1313 if(STRSAFE_GET_FILL_PATTERN(dwFlags)==0) {
1314 pszDestEnd = pszDest;
1315 cchRemaining = cchDest;
1316 } else if(cchDest > 0) {
1317 pszDestEnd = pszDest + cchDest - 1;
1318 cchRemaining = 1;
1319 *pszDestEnd = '\0';
1320 }
1321 }
1322 if(dwFlags & STRSAFE_NULL_ON_FAILURE) {
1323 if(cchDest > 0) {
1324 pszDestEnd = pszDest;
1325 cchRemaining = cchDest;
1326 *pszDestEnd = '\0';
1327 }
1328 }
1329 }
1330 }
1331 if(SUCCEEDED(hr) || (hr==STRSAFE_E_INSUFFICIENT_BUFFER)) {
1332 if(ppszDestEnd) *ppszDestEnd = pszDestEnd;
1333 if(pcchRemaining) *pcchRemaining = cchRemaining;
1334 }
1335 return hr;
1336}
1337
1338STRSAFEAPI StringCatExWorkerW(STRSAFE_LPWSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags) {
1339 HRESULT hr = S_OK;
1340 STRSAFE_LPWSTR pszDestEnd = pszDest;
1341 size_t cchRemaining = 0;
1342 if(dwFlags & (~STRSAFE_VALID_FLAGS)) hr = STRSAFE_E_INVALID_PARAMETER;
1343 else {
1344 size_t cchDestLength;
1345 if(dwFlags & STRSAFE_IGNORE_NULLS) {
1346 if(!pszDest) {
1347 if((cchDest==0) && (cbDest==0)) cchDestLength = 0;
1348 else hr = STRSAFE_E_INVALID_PARAMETER;
1349 } else {
1350 hr = StringLengthWorkerW(pszDest,cchDest,&cchDestLength);
1351 if(SUCCEEDED(hr)) {
1352 pszDestEnd = pszDest + cchDestLength;
1353 cchRemaining = cchDest - cchDestLength;
1354 }
1355 }
1356 if(!pszSrc) pszSrc = L"";
1357 } else {
1358 hr = StringLengthWorkerW(pszDest,cchDest,&cchDestLength);
1359 if(SUCCEEDED(hr)) {
1360 pszDestEnd = pszDest + cchDestLength;
1361 cchRemaining = cchDest - cchDestLength;
1362 }
1363 }
1364 if(SUCCEEDED(hr)) {
1365 if(cchDest==0) {
1366 if(*pszSrc!=L'\0') {
1367 if(!pszDest) hr = STRSAFE_E_INVALID_PARAMETER;
1368 else hr = STRSAFE_E_INSUFFICIENT_BUFFER;
1369 }
1370 } else hr = StringCopyExWorkerW(pszDestEnd,cchRemaining,(cchRemaining*sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)),pszSrc,&pszDestEnd,&cchRemaining,dwFlags & (~(STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE)));
1371 }
1372 }
1373 if(FAILED(hr)) {
1374 if(pszDest) {
1375 if(dwFlags & STRSAFE_FILL_ON_FAILURE) {
1376 memset(pszDest,STRSAFE_GET_FILL_PATTERN(dwFlags),cbDest);
1377 if(STRSAFE_GET_FILL_PATTERN(dwFlags)==0) {
1378 pszDestEnd = pszDest;
1379 cchRemaining = cchDest;
1380 } else if(cchDest > 0) {
1381 pszDestEnd = pszDest + cchDest - 1;
1382 cchRemaining = 1;
1383 *pszDestEnd = L'\0';
1384 }
1385 }
1386 if(dwFlags & STRSAFE_NULL_ON_FAILURE) {
1387 if(cchDest > 0) {
1388 pszDestEnd = pszDest;
1389 cchRemaining = cchDest;
1390 *pszDestEnd = L'\0';
1391 }
1392 }
1393 }
1394 }
1395 if(SUCCEEDED(hr) || (hr==STRSAFE_E_INSUFFICIENT_BUFFER)) {
1396 if(ppszDestEnd) *ppszDestEnd = pszDestEnd;
1397 if(pcchRemaining) *pcchRemaining = cchRemaining;
1398 }
1399 return hr;
1400}
1401
1402STRSAFEAPI StringCatNWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc,size_t cchToAppend) {
1403 HRESULT hr;
1404 size_t cchDestLength;
1405 hr = StringLengthWorkerA(pszDest,cchDest,&cchDestLength);
1406 if(SUCCEEDED(hr)) hr = StringCopyNWorkerA(pszDest + cchDestLength,cchDest - cchDestLength,pszSrc,cchToAppend);
1407 return hr;
1408}
1409
1410STRSAFEAPI StringCatNWorkerW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszSrc,size_t cchToAppend) {
1411 HRESULT hr;
1412 size_t cchDestLength;
1413 hr = StringLengthWorkerW(pszDest,cchDest,&cchDestLength);
1414 if(SUCCEEDED(hr)) hr = StringCopyNWorkerW(pszDest + cchDestLength,cchDest - cchDestLength,pszSrc,cchToAppend);
1415 return hr;
1416}
1417
1418STRSAFEAPI StringCatNExWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPCSTR pszSrc,size_t cchToAppend,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags) {
1419 HRESULT hr = S_OK;
1420 STRSAFE_LPSTR pszDestEnd = pszDest;
1421 size_t cchRemaining = 0;
1422 size_t cchDestLength = 0;
1423 if(dwFlags & (~STRSAFE_VALID_FLAGS)) hr = STRSAFE_E_INVALID_PARAMETER;
1424 else if(cchToAppend > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
1425 else {
1426 if(dwFlags & STRSAFE_IGNORE_NULLS) {
1427 if(!pszDest) {
1428 if((cchDest==0) && (cbDest==0)) cchDestLength = 0;
1429 else hr = STRSAFE_E_INVALID_PARAMETER;
1430 } else {
1431 hr = StringLengthWorkerA(pszDest,cchDest,&cchDestLength);
1432 if(SUCCEEDED(hr)) {
1433 pszDestEnd = pszDest + cchDestLength;
1434 cchRemaining = cchDest - cchDestLength;
1435 }
1436 }
1437 if(!pszSrc) pszSrc = "";
1438 } else {
1439 hr = StringLengthWorkerA(pszDest,cchDest,&cchDestLength);
1440 if(SUCCEEDED(hr)) {
1441 pszDestEnd = pszDest + cchDestLength;
1442 cchRemaining = cchDest - cchDestLength;
1443 }
1444 }
1445 if(SUCCEEDED(hr)) {
1446 if(cchDest==0) {
1447 if((cchToAppend!=0) && (*pszSrc!='\0')) {
1448 if(!pszDest) hr = STRSAFE_E_INVALID_PARAMETER;
1449 else hr = STRSAFE_E_INSUFFICIENT_BUFFER;
1450 }
1451 } else hr = StringCopyNExWorkerA(pszDestEnd,cchRemaining,(cchRemaining*sizeof(char)) + (cbDest % sizeof(char)),pszSrc,cchToAppend,&pszDestEnd,&cchRemaining,dwFlags & (~(STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE)));
1452 }
1453 }
1454 if(FAILED(hr)) {
1455 if(pszDest) {
1456 if(dwFlags & STRSAFE_FILL_ON_FAILURE) {
1457 memset(pszDest,STRSAFE_GET_FILL_PATTERN(dwFlags),cbDest);
1458 if(STRSAFE_GET_FILL_PATTERN(dwFlags)==0) {
1459 pszDestEnd = pszDest;
1460 cchRemaining = cchDest;
1461 } else if(cchDest > 0) {
1462 pszDestEnd = pszDest + cchDest - 1;
1463 cchRemaining = 1;
1464 *pszDestEnd = '\0';
1465 }
1466 }
1467 if(dwFlags & (STRSAFE_NULL_ON_FAILURE)) {
1468 if(cchDest > 0) {
1469 pszDestEnd = pszDest;
1470 cchRemaining = cchDest;
1471 *pszDestEnd = '\0';
1472 }
1473 }
1474 }
1475 }
1476 if(SUCCEEDED(hr) || (hr==STRSAFE_E_INSUFFICIENT_BUFFER)) {
1477 if(ppszDestEnd) *ppszDestEnd = pszDestEnd;
1478 if(pcchRemaining) *pcchRemaining = cchRemaining;
1479 }
1480 return hr;
1481}
1482
1483STRSAFEAPI StringCatNExWorkerW(STRSAFE_LPWSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPCWSTR pszSrc,size_t cchToAppend,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags) {
1484 HRESULT hr = S_OK;
1485 STRSAFE_LPWSTR pszDestEnd = pszDest;
1486 size_t cchRemaining = 0;
1487 size_t cchDestLength = 0;
1488 if(dwFlags & (~STRSAFE_VALID_FLAGS)) hr = STRSAFE_E_INVALID_PARAMETER;
1489 else if(cchToAppend > STRSAFE_MAX_CCH) hr = STRSAFE_E_INVALID_PARAMETER;
1490 else {
1491 if(dwFlags & STRSAFE_IGNORE_NULLS) {
1492 if(!pszDest) {
1493 if((cchDest==0) && (cbDest==0)) cchDestLength = 0;
1494 else hr = STRSAFE_E_INVALID_PARAMETER;
1495 } else {
1496 hr = StringLengthWorkerW(pszDest,cchDest,&cchDestLength);
1497 if(SUCCEEDED(hr)) {
1498 pszDestEnd = pszDest + cchDestLength;
1499 cchRemaining = cchDest - cchDestLength;
1500 }
1501 }
1502 if(!pszSrc) pszSrc = L"";
1503 } else {
1504 hr = StringLengthWorkerW(pszDest,cchDest,&cchDestLength);
1505 if(SUCCEEDED(hr)) {
1506 pszDestEnd = pszDest + cchDestLength;
1507 cchRemaining = cchDest - cchDestLength;
1508 }
1509 }
1510 if(SUCCEEDED(hr)) {
1511 if(cchDest==0) {
1512 if((cchToAppend!=0) && (*pszSrc!=L'\0')) {
1513 if(!pszDest) hr = STRSAFE_E_INVALID_PARAMETER;
1514 else hr = STRSAFE_E_INSUFFICIENT_BUFFER;
1515 }
1516 } else hr = StringCopyNExWorkerW(pszDestEnd,cchRemaining,(cchRemaining*sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)),pszSrc,cchToAppend,&pszDestEnd,&cchRemaining,dwFlags & (~(STRSAFE_FILL_ON_FAILURE | STRSAFE_NULL_ON_FAILURE)));
1517 }
1518 }
1519 if(FAILED(hr)) {
1520 if(pszDest) {
1521 if(dwFlags & STRSAFE_FILL_ON_FAILURE) {
1522 memset(pszDest,STRSAFE_GET_FILL_PATTERN(dwFlags),cbDest);
1523 if(STRSAFE_GET_FILL_PATTERN(dwFlags)==0) {
1524 pszDestEnd = pszDest;
1525 cchRemaining = cchDest;
1526 } else if(cchDest > 0) {
1527 pszDestEnd = pszDest + cchDest - 1;
1528 cchRemaining = 1;
1529 *pszDestEnd = L'\0';
1530 }
1531 }
1532 if(dwFlags & (STRSAFE_NULL_ON_FAILURE)) {
1533 if(cchDest > 0) {
1534 pszDestEnd = pszDest;
1535 cchRemaining = cchDest;
1536 *pszDestEnd = L'\0';
1537 }
1538 }
1539 }
1540 }
1541 if(SUCCEEDED(hr) || (hr==STRSAFE_E_INSUFFICIENT_BUFFER)) {
1542 if(ppszDestEnd) *ppszDestEnd = pszDestEnd;
1543 if(pcchRemaining) *pcchRemaining = cchRemaining;
1544 }
1545 return hr;
1546}
1547
1548STRSAFEAPI StringVPrintfWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszFormat,va_list argList) {
1549 HRESULT hr = S_OK;
1550 if(cchDest==0) hr = STRSAFE_E_INVALID_PARAMETER;
1551 else {
1552 int iRet;
1553 size_t cchMax;
1554 cchMax = cchDest - 1;
1555 iRet = _vsnprintf(pszDest,cchMax,pszFormat,argList);
1556 if((iRet < 0) || (((size_t)iRet) > cchMax)) {
1557 pszDest += cchMax;
1558 *pszDest = '\0';
1559 hr = STRSAFE_E_INSUFFICIENT_BUFFER;
1560 } else if(((size_t)iRet)==cchMax) {
1561 pszDest += cchMax;
1562 *pszDest = '\0';
1563 }
1564 }
1565 return hr;
1566}
1567
1568STRSAFEAPI StringVPrintfWorkerW(STRSAFE_LPWSTR pszDest,size_t cchDest,STRSAFE_LPCWSTR pszFormat,va_list argList) {
1569 HRESULT hr = S_OK;
1570 if(cchDest==0) hr = STRSAFE_E_INVALID_PARAMETER;
1571 else {
1572 int iRet;
1573 size_t cchMax;
1574 cchMax = cchDest - 1;
1575 iRet = _vsnwprintf(pszDest,cchMax,pszFormat,argList);
1576 if((iRet < 0) || (((size_t)iRet) > cchMax)) {
1577 pszDest += cchMax;
1578 *pszDest = L'\0';
1579 hr = STRSAFE_E_INSUFFICIENT_BUFFER;
1580 } else if(((size_t)iRet)==cchMax) {
1581 pszDest += cchMax;
1582 *pszDest = L'\0';
1583 }
1584 }
1585 return hr;
1586}
1587
1588STRSAFEAPI StringVPrintfExWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags,STRSAFE_LPCSTR pszFormat,va_list argList) {
1589 HRESULT hr = S_OK;
1590 STRSAFE_LPSTR pszDestEnd = pszDest;
1591 size_t cchRemaining = 0;
1592 if(dwFlags & (~STRSAFE_VALID_FLAGS)) hr = STRSAFE_E_INVALID_PARAMETER;
1593 else {
1594 if(dwFlags & STRSAFE_IGNORE_NULLS) {
1595 if(!pszDest) {
1596 if((cchDest!=0) || (cbDest!=0)) hr = STRSAFE_E_INVALID_PARAMETER;
1597 }
1598 if(!pszFormat) pszFormat = "";
1599 }
1600 if(SUCCEEDED(hr)) {
1601 if(cchDest==0) {
1602 pszDestEnd = pszDest;
1603 cchRemaining = 0;
1604 if(*pszFormat!='\0') {
1605 if(!pszDest) hr = STRSAFE_E_INVALID_PARAMETER;
1606 else hr = STRSAFE_E_INSUFFICIENT_BUFFER;
1607 }
1608 } else {
1609 int iRet;
1610 size_t cchMax;
1611 cchMax = cchDest - 1;
1612 iRet = _vsnprintf(pszDest,cchMax,pszFormat,argList);
1613 if((iRet < 0) || (((size_t)iRet) > cchMax)) {
1614 pszDestEnd = pszDest + cchMax;
1615 cchRemaining = 1;
1616 *pszDestEnd = '\0';
1617 hr = STRSAFE_E_INSUFFICIENT_BUFFER;
1618 } else if(((size_t)iRet)==cchMax) {
1619 pszDestEnd = pszDest + cchMax;
1620 cchRemaining = 1;
1621 *pszDestEnd = '\0';
1622 } else if(((size_t)iRet) < cchMax) {
1623 pszDestEnd = pszDest + iRet;
1624 cchRemaining = cchDest - iRet;
1625 if(dwFlags & STRSAFE_FILL_BEHIND_NULL) {
1626 memset(pszDestEnd + 1,STRSAFE_GET_FILL_PATTERN(dwFlags),((cchRemaining - 1)*sizeof(char)) + (cbDest % sizeof(char)));
1627 }
1628 }
1629 }
1630 }
1631 }
1632 if(FAILED(hr)) {
1633 if(pszDest) {
1634 if(dwFlags & STRSAFE_FILL_ON_FAILURE) {
1635 memset(pszDest,STRSAFE_GET_FILL_PATTERN(dwFlags),cbDest);
1636 if(STRSAFE_GET_FILL_PATTERN(dwFlags)==0) {
1637 pszDestEnd = pszDest;
1638 cchRemaining = cchDest;
1639 } else if(cchDest > 0) {
1640 pszDestEnd = pszDest + cchDest - 1;
1641 cchRemaining = 1;
1642 *pszDestEnd = '\0';
1643 }
1644 }
1645 if(dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) {
1646 if(cchDest > 0) {
1647 pszDestEnd = pszDest;
1648 cchRemaining = cchDest;
1649 *pszDestEnd = '\0';
1650 }
1651 }
1652 }
1653 }
1654 if(SUCCEEDED(hr) || (hr==STRSAFE_E_INSUFFICIENT_BUFFER)) {
1655 if(ppszDestEnd) *ppszDestEnd = pszDestEnd;
1656 if(pcchRemaining) *pcchRemaining = cchRemaining;
1657 }
1658 return hr;
1659}
1660
1661STRSAFEAPI StringVPrintfExWorkerW(STRSAFE_LPWSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags,STRSAFE_LPCWSTR pszFormat,va_list argList) {
1662 HRESULT hr = S_OK;
1663 STRSAFE_LPWSTR pszDestEnd = pszDest;
1664 size_t cchRemaining = 0;
1665 if(dwFlags & (~STRSAFE_VALID_FLAGS)) hr = STRSAFE_E_INVALID_PARAMETER;
1666 else {
1667 if(dwFlags & STRSAFE_IGNORE_NULLS) {
1668 if(!pszDest) {
1669 if((cchDest!=0) || (cbDest!=0)) hr = STRSAFE_E_INVALID_PARAMETER;
1670 }
1671 if(!pszFormat) pszFormat = L"";
1672 }
1673 if(SUCCEEDED(hr)) {
1674 if(cchDest==0) {
1675 pszDestEnd = pszDest;
1676 cchRemaining = 0;
1677 if(*pszFormat!=L'\0') {
1678 if(!pszDest) hr = STRSAFE_E_INVALID_PARAMETER;
1679 else hr = STRSAFE_E_INSUFFICIENT_BUFFER;
1680 }
1681 } else {
1682 int iRet;
1683 size_t cchMax;
1684 cchMax = cchDest - 1;
1685 iRet = _vsnwprintf(pszDest,cchMax,pszFormat,argList);
1686 if((iRet < 0) || (((size_t)iRet) > cchMax)) {
1687 pszDestEnd = pszDest + cchMax;
1688 cchRemaining = 1;
1689 *pszDestEnd = L'\0';
1690 hr = STRSAFE_E_INSUFFICIENT_BUFFER;
1691 } else if(((size_t)iRet)==cchMax) {
1692 pszDestEnd = pszDest + cchMax;
1693 cchRemaining = 1;
1694 *pszDestEnd = L'\0';
1695 } else if(((size_t)iRet) < cchMax) {
1696 pszDestEnd = pszDest + iRet;
1697 cchRemaining = cchDest - iRet;
1698 if(dwFlags & STRSAFE_FILL_BEHIND_NULL) {
1699 memset(pszDestEnd + 1,STRSAFE_GET_FILL_PATTERN(dwFlags),((cchRemaining - 1)*sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)));
1700 }
1701 }
1702 }
1703 }
1704 }
1705 if(FAILED(hr)) {
1706 if(pszDest) {
1707 if(dwFlags & STRSAFE_FILL_ON_FAILURE) {
1708 memset(pszDest,STRSAFE_GET_FILL_PATTERN(dwFlags),cbDest);
1709 if(STRSAFE_GET_FILL_PATTERN(dwFlags)==0) {
1710 pszDestEnd = pszDest;
1711 cchRemaining = cchDest;
1712 } else if(cchDest > 0) {
1713 pszDestEnd = pszDest + cchDest - 1;
1714 cchRemaining = 1;
1715 *pszDestEnd = L'\0';
1716 }
1717 }
1718 if(dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) {
1719 if(cchDest > 0) {
1720 pszDestEnd = pszDest;
1721 cchRemaining = cchDest;
1722 *pszDestEnd = L'\0';
1723 }
1724 }
1725 }
1726 }
1727 if(SUCCEEDED(hr) || (hr==STRSAFE_E_INSUFFICIENT_BUFFER)) {
1728 if(ppszDestEnd) *ppszDestEnd = pszDestEnd;
1729 if(pcchRemaining) *pcchRemaining = cchRemaining;
1730 }
1731 return hr;
1732}
1733
1734STRSAFEAPI StringLengthWorkerA(STRSAFE_LPCSTR psz,size_t cchMax,size_t *pcchLength) {
1735 HRESULT hr = S_OK;
1736 size_t cchMaxPrev = cchMax;
1737 while(cchMax && (*psz!='\0')) {
1738 psz++;
1739 cchMax--;
1740 }
1741 if(cchMax==0) hr = STRSAFE_E_INVALID_PARAMETER;
1742 if(pcchLength) {
1743 if(SUCCEEDED(hr)) *pcchLength = cchMaxPrev - cchMax;
1744 else *pcchLength = 0;
1745 }
1746 return hr;
1747}
1748
1749STRSAFEAPI StringLengthWorkerW(STRSAFE_LPCWSTR psz,size_t cchMax,size_t *pcchLength) {
1750 HRESULT hr = S_OK;
1751 size_t cchMaxPrev = cchMax;
1752 while(cchMax && (*psz!=L'\0')) {
1753 psz++;
1754 cchMax--;
1755 }
1756 if(cchMax==0) hr = STRSAFE_E_INVALID_PARAMETER;
1757 if(pcchLength) {
1758 if(SUCCEEDED(hr)) *pcchLength = cchMaxPrev - cchMax;
1759 else *pcchLength = 0;
1760 }
1761 return hr;
1762}
1763
1764STRSAFE_INLINE_API StringGetsExWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags) {
1765 HRESULT hr = S_OK;
1766 STRSAFE_LPSTR pszDestEnd = pszDest;
1767 size_t cchRemaining = 0;
1768
1769 if(dwFlags & (~STRSAFE_VALID_FLAGS)) hr = STRSAFE_E_INVALID_PARAMETER;
1770 else {
1771 if(dwFlags & STRSAFE_IGNORE_NULLS) {
1772 if(!pszDest) {
1773 if((cchDest!=0) || (cbDest!=0)) hr = STRSAFE_E_INVALID_PARAMETER;
1774 }
1775 }
1776 if(SUCCEEDED(hr)) {
1777 if(cchDest <= 1) {
1778 pszDestEnd = pszDest;
1779 cchRemaining = cchDest;
1780 if(cchDest==1) *pszDestEnd = '\0';
1781 hr = STRSAFE_E_INSUFFICIENT_BUFFER;
1782 } else {
1783 pszDestEnd = pszDest;
1784 cchRemaining = cchDest;
1785 while(cchRemaining > 1) {
1786 char ch;
1787 int i = getc(stdin);
1788 if(i==EOF) {
1789 if(pszDestEnd==pszDest) hr = STRSAFE_E_END_OF_FILE;
1790 break;
1791 }
1792 ch = (char)i;
1793 if(ch=='\n') break;
1794 *pszDestEnd = ch;
1795 pszDestEnd++;
1796 cchRemaining--;
1797 }
1798 if(cchRemaining > 0) {
1799 if(dwFlags & STRSAFE_FILL_BEHIND_NULL) {
1800 memset(pszDestEnd + 1,STRSAFE_GET_FILL_PATTERN(dwFlags),((cchRemaining - 1)*sizeof(char)) + (cbDest % sizeof(char)));
1801 }
1802 }
1803 *pszDestEnd = '\0';
1804 }
1805 }
1806 }
1807 if(FAILED(hr)) {
1808 if(pszDest) {
1809 if(dwFlags & STRSAFE_FILL_ON_FAILURE) {
1810 memset(pszDest,STRSAFE_GET_FILL_PATTERN(dwFlags),cbDest);
1811 if(STRSAFE_GET_FILL_PATTERN(dwFlags)==0) {
1812 pszDestEnd = pszDest;
1813 cchRemaining = cchDest;
1814 } else if(cchDest > 0) {
1815 pszDestEnd = pszDest + cchDest - 1;
1816 cchRemaining = 1;
1817 *pszDestEnd = '\0';
1818 }
1819 }
1820 if(dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) {
1821 if(cchDest > 0) {
1822 pszDestEnd = pszDest;
1823 cchRemaining = cchDest;
1824 *pszDestEnd = '\0';
1825 }
1826 }
1827 }
1828 }
1829 if(SUCCEEDED(hr) || (hr==STRSAFE_E_INSUFFICIENT_BUFFER) || (hr==STRSAFE_E_END_OF_FILE)) {
1830 if(ppszDestEnd) *ppszDestEnd = pszDestEnd;
1831 if(pcchRemaining) *pcchRemaining = cchRemaining;
1832 }
1833 return hr;
1834}
1835
1836STRSAFE_INLINE_API StringGetsExWorkerW(STRSAFE_LPWSTR pszDest,size_t cchDest,size_t cbDest,STRSAFE_LPWSTR *ppszDestEnd,size_t *pcchRemaining,unsigned __LONG32 dwFlags) {
1837 HRESULT hr = S_OK;
1838 STRSAFE_LPWSTR pszDestEnd = pszDest;
1839 size_t cchRemaining = 0;
1840 if(dwFlags & (~STRSAFE_VALID_FLAGS)) {
1841 hr = STRSAFE_E_INVALID_PARAMETER;
1842 } else {
1843 if(dwFlags & STRSAFE_IGNORE_NULLS) {
1844 if(!pszDest) {
1845 if((cchDest!=0) || (cbDest!=0)) hr = STRSAFE_E_INVALID_PARAMETER;
1846 }
1847 }
1848 if(SUCCEEDED(hr)) {
1849 if(cchDest <= 1) {
1850 pszDestEnd = pszDest;
1851 cchRemaining = cchDest;
1852 if(cchDest==1) *pszDestEnd = L'\0';
1853 hr = STRSAFE_E_INSUFFICIENT_BUFFER;
1854 } else {
1855 pszDestEnd = pszDest;
1856 cchRemaining = cchDest;
1857 while(cchRemaining > 1) {
1858 wchar_t ch = getwc(stdin);
1859 if(ch==WEOF) {
1860 if(pszDestEnd==pszDest) hr = STRSAFE_E_END_OF_FILE;
1861 break;
1862 }
1863 if(ch==L'\n') break;
1864 *pszDestEnd = ch;
1865 pszDestEnd++;
1866 cchRemaining--;
1867 }
1868 if(cchRemaining > 0) {
1869 if(dwFlags & STRSAFE_FILL_BEHIND_NULL) {
1870 memset(pszDestEnd + 1,STRSAFE_GET_FILL_PATTERN(dwFlags),((cchRemaining - 1)*sizeof(wchar_t)) + (cbDest % sizeof(wchar_t)));
1871 }
1872 }
1873 *pszDestEnd = L'\0';
1874 }
1875 }
1876 }
1877 if(FAILED(hr)) {
1878 if(pszDest) {
1879 if(dwFlags & STRSAFE_FILL_ON_FAILURE) {
1880 memset(pszDest,STRSAFE_GET_FILL_PATTERN(dwFlags),cbDest);
1881 if(STRSAFE_GET_FILL_PATTERN(dwFlags)==0) {
1882 pszDestEnd = pszDest;
1883 cchRemaining = cchDest;
1884 } else if(cchDest > 0) {
1885 pszDestEnd = pszDest + cchDest - 1;
1886 cchRemaining = 1;
1887 *pszDestEnd = L'\0';
1888 }
1889 }
1890 if(dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION)) {
1891 if(cchDest > 0) {
1892 pszDestEnd = pszDest;
1893 cchRemaining = cchDest;
1894 *pszDestEnd = L'\0';
1895 }
1896 }
1897 }
1898 }
1899 if(SUCCEEDED(hr) || (hr==STRSAFE_E_INSUFFICIENT_BUFFER) || (hr==STRSAFE_E_END_OF_FILE)) {
1900 if(ppszDestEnd) *ppszDestEnd = pszDestEnd;
1901 if(pcchRemaining) *pcchRemaining = cchRemaining;
1902 }
1903 return hr;
1904}
1905#endif /* !__STRSAFE__NO_INLINE */
1906
1907#define StringCopyWorkerA StringCopyWorkerA_instead_use_StringCchCopyA_or_StringCchCopyExA;
1908#define StringCopyWorkerW StringCopyWorkerW_instead_use_StringCchCopyW_or_StringCchCopyExW;
1909#define StringCopyExWorkerA StringCopyExWorkerA_instead_use_StringCchCopyA_or_StringCchCopyExA;
1910#define StringCopyExWorkerW StringCopyExWorkerW_instead_use_StringCchCopyW_or_StringCchCopyExW;
1911#define StringCatWorkerA StringCatWorkerA_instead_use_StringCchCatA_or_StringCchCatExA;
1912#define StringCatWorkerW StringCatWorkerW_instead_use_StringCchCatW_or_StringCchCatExW;
1913#define StringCatExWorkerA StringCatExWorkerA_instead_use_StringCchCatA_or_StringCchCatExA;
1914#define StringCatExWorkerW StringCatExWorkerW_instead_use_StringCchCatW_or_StringCchCatExW;
1915#define StringCatNWorkerA StringCatNWorkerA_instead_use_StringCchCatNA_or_StrincCbCatNA;
1916#define StringCatNWorkerW StringCatNWorkerW_instead_use_StringCchCatNW_or_StringCbCatNW;
1917#define StringCatNExWorkerA StringCatNExWorkerA_instead_use_StringCchCatNExA_or_StringCbCatNExA;
1918#define StringCatNExWorkerW StringCatNExWorkerW_instead_use_StringCchCatNExW_or_StringCbCatNExW;
1919#define StringVPrintfWorkerA StringVPrintfWorkerA_instead_use_StringCchVPrintfA_or_StringCchVPrintfExA;
1920#define StringVPrintfWorkerW StringVPrintfWorkerW_instead_use_StringCchVPrintfW_or_StringCchVPrintfExW;
1921#define StringVPrintfExWorkerA StringVPrintfExWorkerA_instead_use_StringCchVPrintfA_or_StringCchVPrintfExA;
1922#define StringVPrintfExWorkerW StringVPrintfExWorkerW_instead_use_StringCchVPrintfW_or_StringCchVPrintfExW;
1923#define StringLengthWorkerA StringLengthWorkerA_instead_use_StringCchLengthA_or_StringCbLengthA;
1924#define StringLengthWorkerW StringLengthWorkerW_instead_use_StringCchLengthW_or_StringCbLengthW;
1925#define StringGetsExWorkerA StringGetsExWorkerA_instead_use_StringCchGetsA_or_StringCbGetsA
1926#define StringGetsExWorkerW StringGetsExWorkerW_instead_use_StringCchGetsW_or_StringCbGetsW
1927
1928#ifndef STRSAFE_NO_DEPRECATE
1929
1930#undef strcpy
1931#define strcpy strcpy_instead_use_StringCbCopyA_or_StringCchCopyA;
1932
1933#undef wcscpy
1934#define wcscpy wcscpy_instead_use_StringCbCopyW_or_StringCchCopyW;
1935
1936#undef strcat
1937#define strcat strcat_instead_use_StringCbCatA_or_StringCchCatA;
1938
1939#undef wcscat
1940#define wcscat wcscat_instead_use_StringCbCatW_or_StringCchCatW;
1941
1942#undef sprintf
1943#define sprintf sprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA;
1944
1945#undef swprintf
1946#define swprintf swprintf_instead_use_StringCbPrintfW_or_StringCchPrintfW;
1947
1948#undef vsprintf
1949#define vsprintf vsprintf_instead_use_StringCbVPrintfA_or_StringCchVPrintfA;
1950
1951#undef vswprintf
1952#define vswprintf vswprintf_instead_use_StringCbVPrintfW_or_StringCchVPrintfW;
1953
1954#undef _snprintf
1955#define _snprintf _snprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA;
1956
1957#undef _snwprintf
1958#define _snwprintf _snwprintf_instead_use_StringCbPrintfW_or_StringCchPrintfW;
1959
1960#undef _vsnprintf
1961#define _vsnprintf _vsnprintf_instead_use_StringCbVPrintfA_or_StringCchVPrintfA;
1962
1963#undef _vsnwprintf
1964#define _vsnwprintf _vsnwprintf_instead_use_StringCbVPrintfW_or_StringCchVPrintfW;
1965
1966#undef strcpyA
1967#define strcpyA strcpyA_instead_use_StringCbCopyA_or_StringCchCopyA;
1968
1969#undef strcpyW
1970#define strcpyW strcpyW_instead_use_StringCbCopyW_or_StringCchCopyW;
1971
1972#undef lstrcpy
1973#define lstrcpy lstrcpy_instead_use_StringCbCopy_or_StringCchCopy;
1974
1975#undef lstrcpyA
1976#define lstrcpyA lstrcpyA_instead_use_StringCbCopyA_or_StringCchCopyA;
1977
1978#undef lstrcpyW
1979#define lstrcpyW lstrcpyW_instead_use_StringCbCopyW_or_StringCchCopyW;
1980
1981#undef StrCpy
1982#define StrCpy StrCpy_instead_use_StringCbCopy_or_StringCchCopy;
1983
1984#undef StrCpyA
1985#define StrCpyA StrCpyA_instead_use_StringCbCopyA_or_StringCchCopyA;
1986
1987#undef StrCpyW
1988#define StrCpyW StrCpyW_instead_use_StringCbCopyW_or_StringCchCopyW;
1989
1990#undef _tcscpy
1991#define _tcscpy _tcscpy_instead_use_StringCbCopy_or_StringCchCopy;
1992
1993#undef _ftcscpy
1994#define _ftcscpy _ftcscpy_instead_use_StringCbCopy_or_StringCchCopy;
1995
1996#undef lstrcat
1997#define lstrcat lstrcat_instead_use_StringCbCat_or_StringCchCat;
1998
1999#undef lstrcatA
2000#define lstrcatA lstrcatA_instead_use_StringCbCatA_or_StringCchCatA;
2001
2002#undef lstrcatW
2003#define lstrcatW lstrcatW_instead_use_StringCbCatW_or_StringCchCatW;
2004
2005#undef StrCat
2006#define StrCat StrCat_instead_use_StringCbCat_or_StringCchCat;
2007
2008#undef StrCatA
2009#define StrCatA StrCatA_instead_use_StringCbCatA_or_StringCchCatA;
2010
2011#undef StrCatW
2012#define StrCatW StrCatW_instead_use_StringCbCatW_or_StringCchCatW;
2013
2014#undef StrNCat
2015#define StrNCat StrNCat_instead_use_StringCbCatN_or_StringCchCatN;
2016
2017#undef StrNCatA
2018#define StrNCatA StrNCatA_instead_use_StringCbCatNA_or_StringCchCatNA;
2019
2020#undef StrNCatW
2021#define StrNCatW StrNCatW_instead_use_StringCbCatNW_or_StringCchCatNW;
2022
2023#undef StrCatN
2024#define StrCatN StrCatN_instead_use_StringCbCatN_or_StringCchCatN;
2025
2026#undef StrCatNA
2027#define StrCatNA StrCatNA_instead_use_StringCbCatNA_or_StringCchCatNA;
2028
2029#undef StrCatNW
2030#define StrCatNW StrCatNW_instead_use_StringCbCatNW_or_StringCchCatNW;
2031
2032#undef _tcscat
2033#define _tcscat _tcscat_instead_use_StringCbCat_or_StringCchCat;
2034
2035#undef _ftcscat
2036#define _ftcscat _ftcscat_instead_use_StringCbCat_or_StringCchCat;
2037
2038#undef wsprintf
2039#define wsprintf wsprintf_instead_use_StringCbPrintf_or_StringCchPrintf;
2040
2041#undef wsprintfA
2042#define wsprintfA wsprintfA_instead_use_StringCbPrintfA_or_StringCchPrintfA;
2043
2044#undef wsprintfW
2045#define wsprintfW wsprintfW_instead_use_StringCbPrintfW_or_StringCchPrintfW;
2046
2047#undef wvsprintf
2048#define wvsprintf wvsprintf_instead_use_StringCbVPrintf_or_StringCchVPrintf;
2049
2050#undef wvsprintfA
2051#define wvsprintfA wvsprintfA_instead_use_StringCbVPrintfA_or_StringCchVPrintfA;
2052
2053#undef wvsprintfW
2054#define wvsprintfW wvsprintfW_instead_use_StringCbVPrintfW_or_StringCchVPrintfW;
2055
2056#undef _vstprintf
2057#define _vstprintf _vstprintf_instead_use_StringCbVPrintf_or_StringCchVPrintf;
2058
2059#undef _vsntprintf
2060#define _vsntprintf _vsntprintf_instead_use_StringCbVPrintf_or_StringCchVPrintf;
2061
2062#undef _stprintf
2063#define _stprintf _stprintf_instead_use_StringCbPrintf_or_StringCchPrintf;
2064
2065#undef _sntprintf
2066#define _sntprintf _sntprintf_instead_use_StringCbPrintf_or_StringCchPrintf;
2067
2068#undef _getts
2069#define _getts _getts_instead_use_StringCbGets_or_StringCchGets;
2070
2071#undef gets
2072#define gets _gets_instead_use_StringCbGetsA_or_StringCchGetsA;
2073
2074#undef _getws
2075#define _getws _getws_instead_use_StringCbGetsW_or_StringCchGetsW;
2076#endif
2077#endif
Note: See TracBrowser for help on using the repository browser.