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