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