We will need this to bundle winpthreads.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- include/strsafe.h | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-)
diff --git a/include/strsafe.h b/include/strsafe.h index 842075f0fce..7fdb904ed8b 100644 --- a/include/strsafe.h +++ b/include/strsafe.h @@ -25,8 +25,39 @@ /* Windows version includes this header. */ /* #include <specstring.h> */
+#define STRSAFEAPI static inline HRESULT + +#define STRSAFE_MAX_CCH 2147483647 + #define STRSAFE_E_INSUFFICIENT_BUFFER ((HRESULT)0x8007007A) -#define STRSAFE_E_INVALID_PARAM ((HRESULT)0x80070075) +#define STRSAFE_E_INVALID_PARAMETER ((HRESULT)0x80070057) #define STRSAFE_E_END_OF_FILE ((HRESULT)0x80070026)
-#endif +typedef char *STRSAFE_LPSTR; +typedef const char *STRSAFE_LPCSTR; + +STRSAFEAPI StringCopyNWorkerA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc,size_t cchSrc) { + HRESULT hr = S_OK; + if(cchDest==0) hr = STRSAFE_E_INVALID_PARAMETER; + else { + while(cchDest && cchSrc && (*pszSrc!='\0')) { + *pszDest++ = *pszSrc++; + cchDest--; + cchSrc--; + } + if(cchDest==0) { + pszDest--; + hr = STRSAFE_E_INSUFFICIENT_BUFFER; + } + *pszDest= '\0'; + } + return hr; +} + +STRSAFEAPI StringCchCopyNA(STRSAFE_LPSTR pszDest,size_t cchDest,STRSAFE_LPCSTR pszSrc,size_t cchToCopy) { + if(cchDest > STRSAFE_MAX_CCH || cchToCopy > STRSAFE_MAX_CCH) + return STRSAFE_E_INVALID_PARAMETER; + return StringCopyNWorkerA(pszDest,cchDest,pszSrc,cchToCopy); +} + +#endif /* __WINE_STRSAFE_H */