summaryrefslogtreecommitdiff
path: root/src/pal/inc/strsafe.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/pal/inc/strsafe.h')
-rw-r--r--src/pal/inc/strsafe.h593
1 files changed, 0 insertions, 593 deletions
diff --git a/src/pal/inc/strsafe.h b/src/pal/inc/strsafe.h
index 58749f27ee..f32f5e6549 100644
--- a/src/pal/inc/strsafe.h
+++ b/src/pal/inc/strsafe.h
@@ -24,14 +24,6 @@
#pragma once
#endif
-#if defined(PLATFORM_UNIX) && !defined (FEATURE_PAL)
-#define _NATIVE_WCHAR_T_DEFINED
-#endif // defined(PLATFORM_UNIX) && !defined (FEATURE_PAL)
-
-#if defined(PLATFORM_UNIX) && !defined (FEATURE_PAL)
-#define _vsnprintf vsnprintf
-#endif // defined(PLATFORM_UNIX) && !defined (FEATURE_PAL)
-
#include <stdio.h> // for _vsnprintf, getc, getwc
#include <string.h> // for memset
#include <stdarg.h> // for va_start, etc.
@@ -51,13 +43,6 @@ typedef char16_t WCHAR;
#define _WCHAR_T_DEFINED
#endif
-#ifndef FEATURE_PAL
-#ifndef _HRESULT_DEFINED
-#define _HRESULT_DEFINED
-typedef LONG HRESULT;
-#endif // !_HRESULT_DEFINED
-#endif // !FEATURE_PAL
-
#ifndef SUCCEEDED
#define SUCCEEDED(hr) ((HRESULT)(hr) >= 0)
#endif
@@ -150,14 +135,6 @@ STRSAFEAPI StringLengthWorkerA(const char* psz, size_t cchMax, size_t* pcch);
STRSAFEAPI StringLengthWorkerW(const WCHAR* psz, size_t cchMax, size_t* pcch);
#endif // STRSAFE_INLINE
-#ifndef STRSAFE_LIB_IMPL
-#ifndef FEATURE_PAL
-// these functions are always inline
-STRSAFE_INLINE_API StringGetsExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags);
-STRSAFE_INLINE_API StringGetsExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags);
-#endif // !FEATURE_PAL
-#endif
-
#ifndef STRSAFE_NO_CCH_FUNCTIONS
/*++
@@ -247,7 +224,6 @@ STRSAFEAPI StringCchCopyA(char* pszDest, size_t cchDest, const char* pszSrc)
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCchCopyW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc)
{
HRESULT hr;
@@ -263,7 +239,6 @@ STRSAFEAPI StringCchCopyW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc)
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CCH_FUNCTIONS
@@ -361,7 +336,6 @@ STRSAFEAPI StringCbCopyA(char* pszDest, size_t cbDest, const char* pszSrc)
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCbCopyW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc)
{
HRESULT hr;
@@ -381,7 +355,6 @@ STRSAFEAPI StringCbCopyW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc)
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CB_FUNCTIONS
@@ -506,7 +479,6 @@ STRSAFEAPI StringCchCopyExA(char* pszDest, size_t cchDest, const char* pszSrc, c
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCchCopyExW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr;
@@ -527,7 +499,6 @@ STRSAFEAPI StringCchCopyExW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc,
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CCH_FUNCTIONS
@@ -660,7 +631,6 @@ STRSAFEAPI StringCbCopyExA(char* pszDest, size_t cbDest, const char* pszSrc, cha
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCbCopyExW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, WCHAR** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags)
{
HRESULT hr;
@@ -689,7 +659,6 @@ STRSAFEAPI StringCbCopyExW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, W
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CB_FUNCTIONS
@@ -784,7 +753,6 @@ STRSAFEAPI StringCchCopyNA(char* pszDest, size_t cchDest, const char* pszSrc, si
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCchCopyNW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc, size_t cchSrc)
{
HRESULT hr;
@@ -801,7 +769,6 @@ STRSAFEAPI StringCchCopyNW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc,
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CCH_FUNCTIONS
@@ -902,7 +869,6 @@ STRSAFEAPI StringCbCopyNA(char* pszDest, size_t cbDest, const char* pszSrc, size
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCbCopyNW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, size_t cbSrc)
{
HRESULT hr;
@@ -925,7 +891,6 @@ STRSAFEAPI StringCbCopyNW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, si
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CB_FUNCTIONS
@@ -1060,7 +1025,6 @@ STRSAFEAPI StringCchCopyNExA(char* pszDest, size_t cchDest, const char* pszSrc,
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCchCopyNExW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc, size_t cchSrc, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr;
@@ -1082,7 +1046,6 @@ STRSAFEAPI StringCchCopyNExW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CCH_FUNCTIONS
@@ -1226,7 +1189,6 @@ STRSAFEAPI StringCbCopyNExA(char* pszDest, size_t cbDest, const char* pszSrc, si
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCbCopyNExW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, size_t cbSrc, WCHAR** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags)
{
HRESULT hr;
@@ -1258,7 +1220,6 @@ STRSAFEAPI StringCbCopyNExW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc,
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CB_FUNCTIONS
@@ -1345,7 +1306,6 @@ STRSAFEAPI StringCchCatA(char* pszDest, size_t cchDest, const char* pszSrc)
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCchCatW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc)
{
HRESULT hr;
@@ -1361,7 +1321,6 @@ STRSAFEAPI StringCchCatW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc)
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CCH_FUNCTIONS
@@ -1451,7 +1410,6 @@ STRSAFEAPI StringCbCatA(char* pszDest, size_t cbDest, const char* pszSrc)
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCbCatW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc)
{
HRESULT hr;
@@ -1470,7 +1428,6 @@ STRSAFEAPI StringCbCatW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc)
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CB_FUNCTIONS
@@ -1598,7 +1555,6 @@ STRSAFEAPI StringCchCatExA(char* pszDest, size_t cchDest, const char* pszSrc, ch
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCchCatExW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr;
@@ -1619,7 +1575,6 @@ STRSAFEAPI StringCchCatExW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc,
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CCH_FUNCTIONS
@@ -1755,7 +1710,6 @@ STRSAFEAPI StringCbCatExA(char* pszDest, size_t cbDest, const char* pszSrc, char
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCbCatExW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, WCHAR** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags)
{
HRESULT hr;
@@ -1784,7 +1738,6 @@ STRSAFEAPI StringCbCatExW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, WC
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CB_FUNCTIONS
@@ -1877,7 +1830,6 @@ STRSAFEAPI StringCchCatNA(char* pszDest, size_t cchDest, const char* pszSrc, siz
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCchCatNW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc, size_t cchMaxAppend)
{
HRESULT hr;
@@ -1893,7 +1845,6 @@ STRSAFEAPI StringCchCatNW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc, s
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CCH_FUNCTIONS
@@ -1993,7 +1944,6 @@ STRSAFEAPI StringCbCatNA(char* pszDest, size_t cbDest, const char* pszSrc, size_
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCbCatNW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, size_t cbMaxAppend)
{
HRESULT hr;
@@ -2016,7 +1966,6 @@ STRSAFEAPI StringCbCatNW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, siz
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CB_FUNCTIONS
@@ -2147,7 +2096,6 @@ STRSAFEAPI StringCchCatNExA(char* pszDest, size_t cchDest, const char* pszSrc, s
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCchCatNExW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc, size_t cchMaxAppend, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr;
@@ -2168,7 +2116,6 @@ STRSAFEAPI StringCchCatNExW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc,
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CCH_FUNCTIONS
@@ -2311,7 +2258,6 @@ STRSAFEAPI StringCbCatNExA(char* pszDest, size_t cbDest, const char* pszSrc, siz
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCbCatNExW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, size_t cbMaxAppend, WCHAR** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags)
{
HRESULT hr;
@@ -2344,7 +2290,6 @@ STRSAFEAPI StringCbCatNExW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, s
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CB_FUNCTIONS
@@ -2403,62 +2348,7 @@ Return Value:
--*/
-#ifndef FEATURE_PAL
-#ifndef STRSAFE_LIB_IMPL
-STRSAFE_INLINE_API StringCchGetsA(char* pszDest, size_t cchDest);
-STRSAFE_INLINE_API StringCchGetsW(WCHAR* pszDest, size_t cchDest);
-#ifdef UNICODE
-#define StringCchGets StringCchGetsW
-#else
-#define StringCchGets StringCchGetsA
-#endif // !UNICODE
-
-STRSAFE_INLINE_API StringCchGetsA(char* pszDest, size_t cchDest)
-{
- HRESULT hr;
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- size_t cbDest;
-
- // safe to multiply cchDest * sizeof(char) since cchDest < STRSAFE_MAX_CCH and sizeof(char) is 1
- cbDest = cchDest * sizeof(char);
-
- hr = StringGetsExWorkerA(pszDest, cchDest, cbDest, NULL, NULL, 0);
- }
-
- return hr;
-}
-
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFE_INLINE_API StringCchGetsW(WCHAR* pszDest, size_t cchDest)
-{
- HRESULT hr;
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- size_t cbDest;
-
- // safe to multiply cchDest * sizeof(WCHAR) since cchDest < STRSAFE_MAX_CCH and sizeof(WCHAR) is 2
- cbDest = cchDest * sizeof(WCHAR);
-
- hr = StringGetsExWorkerW(pszDest, cchDest, cbDest, NULL, NULL, 0);
- }
-
- return hr;
-}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // !STRSAFE_NO_CCH_FUNCTIONS
-#endif // !STRSAFE_LIB_IMPL
-#endif // !FEATURE_PAL
#ifndef STRSAFE_NO_CB_FUNCTIONS
/*++
@@ -2514,60 +2404,7 @@ Return Value:
--*/
-#ifndef FEATURE_PAL
-#ifndef STRSAFE_LIB_IMPL
-STRSAFE_INLINE_API StringCbGetsA(char* pszDest, size_t cbDest);
-STRSAFE_INLINE_API StringCbGetsW(WCHAR* pszDest, size_t cbDest);
-#ifdef UNICODE
-#define StringCbGets StringCbGetsW
-#else
-#define StringCbGets StringCbGetsA
-#endif // !UNICODE
-
-STRSAFE_INLINE_API StringCbGetsA(char* pszDest, size_t cbDest)
-{
- HRESULT hr;
- size_t cchDest;
-
- // convert to count of characters
- cchDest = cbDest / sizeof(char);
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringGetsExWorkerA(pszDest, cchDest, cbDest, NULL, NULL, 0);
- }
-
- return hr;
-}
-
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFE_INLINE_API StringCbGetsW(WCHAR* pszDest, size_t cbDest)
-{
- HRESULT hr;
- size_t cchDest;
-
- // convert to count of characters
- cchDest = cbDest / sizeof(WCHAR);
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringGetsExWorkerW(pszDest, cchDest, cbDest, NULL, NULL, 0);
- }
-
- return hr;
-}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // !STRSAFE_NO_CB_FUNCTIONS
-#endif // !STRSAFE_LIB_IMPL
-#endif // !FEATURE_PAL
#ifndef STRSAFE_NO_CCH_FUNCTIONS
/*++
@@ -2650,62 +2487,7 @@ Return Value:
--*/
-#ifndef FEATURE_PAL
-#ifndef STRSAFE_LIB_IMPL
-STRSAFE_INLINE_API StringCchGetsExA(char* pszDest, size_t cchDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags);
-STRSAFE_INLINE_API StringCchGetsExW(WCHAR* pszDest, size_t cchDest, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags);
-#ifdef UNICODE
-#define StringCchGetsEx StringCchGetsExW
-#else
-#define StringCchGetsEx StringCchGetsExA
-#endif // !UNICODE
-
-STRSAFE_INLINE_API StringCchGetsExA(char* pszDest, size_t cchDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
-{
- HRESULT hr;
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- size_t cbDest;
-
- // safe to multiply cchDest * sizeof(char) since cchDest < STRSAFE_MAX_CCH and sizeof(char) is 1
- cbDest = cchDest * sizeof(char);
-
- hr = StringGetsExWorkerA(pszDest, cchDest, cbDest, ppszDestEnd, pcchRemaining, dwFlags);
- }
-
- return hr;
-}
-
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFE_INLINE_API StringCchGetsExW(WCHAR* pszDest, size_t cchDest, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
-{
- HRESULT hr;
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- size_t cbDest;
-
- // safe to multiply cchDest * sizeof(WCHAR) since cchDest < STRSAFE_MAX_CCH and sizeof(WCHAR) is 2
- cbDest = cchDest * sizeof(WCHAR);
-
- hr = StringGetsExWorkerW(pszDest, cchDest, cbDest, ppszDestEnd, pcchRemaining, dwFlags);
- }
-
- return hr;
-}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // !STRSAFE_NO_CCH_FUNCTIONS
-#endif // !STRSAFE_LIB_IMPL
-#endif // !FEATURE_PAL
#ifndef STRSAFE_NO_CB_FUNCTIONS
/*++
@@ -2788,82 +2570,7 @@ Return Value:
--*/
-#ifndef FEATURE_PAL
-#ifndef STRSAFE_LIB_IMPL
-STRSAFE_INLINE_API StringCbGetsExA(char* pszDest, size_t cbDest, char** ppszDestEnd, size_t* pbRemaining, unsigned long dwFlags);
-STRSAFE_INLINE_API StringCbGetsExW(WCHAR* pszDest, size_t cbDest, WCHAR** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags);
-#ifdef UNICODE
-#define StringCbGetsEx StringCbGetsExW
-#else
-#define StringCbGetsEx StringCbGetsExA
-#endif // !UNICODE
-
-STRSAFE_INLINE_API StringCbGetsExA(char* pszDest, size_t cbDest, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags)
-{
- HRESULT hr;
- size_t cchDest;
- size_t cchRemaining = 0;
-
- cchDest = cbDest / sizeof(char);
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringGetsExWorkerA(pszDest, cchDest, cbDest, ppszDestEnd, &cchRemaining, dwFlags);
- }
-
- if (SUCCEEDED(hr) ||
- (hr == STRSAFE_E_INSUFFICIENT_BUFFER) ||
- (hr == STRSAFE_E_END_OF_FILE))
- {
- if (pcbRemaining)
- {
- // safe to multiply cchRemaining * sizeof(char) since cchRemaining < STRSAFE_MAX_CCH and sizeof(char) is 1
- *pcbRemaining = (cchRemaining * sizeof(char)) + (cbDest % sizeof(char));
- }
- }
-
- return hr;
-}
-
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFE_INLINE_API StringCbGetsExW(WCHAR* pszDest, size_t cbDest, WCHAR** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags)
-{
- HRESULT hr;
- size_t cchDest;
- size_t cchRemaining = 0;
-
- cchDest = cbDest / sizeof(WCHAR);
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringGetsExWorkerW(pszDest, cchDest, cbDest, ppszDestEnd, &cchRemaining, dwFlags);
- }
-
- if (SUCCEEDED(hr) ||
- (hr == STRSAFE_E_INSUFFICIENT_BUFFER) ||
- (hr == STRSAFE_E_END_OF_FILE))
- {
- if (pcbRemaining)
- {
- // safe to multiply cchRemaining * sizeof(WCHAR) since cchRemaining < STRSAFE_MAX_CCH and sizeof(WCHAR) is 2
- *pcbRemaining = (cchRemaining * sizeof(WCHAR)) + (cbDest % sizeof(WCHAR));
- }
- }
-
- return hr;
-}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // !STRSAFE_NO_CB_FUNCTIONS
-#endif // !STRSAFE_LIB_IMPL
-#endif // !FEATURE_PAL
#ifndef STRSAFE_NO_CCH_FUNCTIONS
/*++
@@ -2937,7 +2644,6 @@ STRSAFEAPI StringCchLengthA(const char* psz, size_t cchMax, size_t* pcch)
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCchLengthW(const WCHAR* psz, size_t cchMax, size_t* pcch)
{
HRESULT hr;
@@ -2953,7 +2659,6 @@ STRSAFEAPI StringCchLengthW(const WCHAR* psz, size_t cchMax, size_t* pcch)
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CCH_FUNCTIONS
@@ -3040,7 +2745,6 @@ STRSAFEAPI StringCbLengthA(const char* psz, size_t cbMax, size_t* pcb)
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCbLengthW(const WCHAR* psz, size_t cbMax, size_t* pcb)
{
HRESULT hr;
@@ -3066,7 +2770,6 @@ STRSAFEAPI StringCbLengthW(const WCHAR* psz, size_t cbMax, size_t* pcb)
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CB_FUNCTIONS
@@ -3103,7 +2806,6 @@ STRSAFEAPI StringCopyWorkerA(char* pszDest, size_t cchDest, const char* pszSrc)
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCopyWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc)
{
HRESULT hr = S_OK;
@@ -3133,7 +2835,6 @@ STRSAFEAPI StringCopyWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
STRSAFEAPI StringCopyExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
@@ -3273,7 +2974,6 @@ STRSAFEAPI StringCopyExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, con
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCopyExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, const WCHAR* pszSrc, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr = S_OK;
@@ -3411,7 +3111,6 @@ STRSAFEAPI StringCopyExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, co
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
STRSAFEAPI StringCopyNWorkerA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchSrc)
{
@@ -3444,7 +3143,6 @@ STRSAFEAPI StringCopyNWorkerA(char* pszDest, size_t cchDest, const char* pszSrc,
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCopyNWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc, size_t cchSrc)
{
HRESULT hr = S_OK;
@@ -3475,7 +3173,6 @@ STRSAFEAPI StringCopyNWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSr
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
STRSAFEAPI StringCopyNExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, size_t cchSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
@@ -3616,7 +3313,6 @@ STRSAFEAPI StringCopyNExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, co
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCopyNExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, const WCHAR* pszSrc, size_t cchSrc, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr = S_OK;
@@ -3755,7 +3451,6 @@ STRSAFEAPI StringCopyNExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, c
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
STRSAFEAPI StringCatWorkerA(char* pszDest, size_t cchDest, const char* pszSrc)
{
@@ -3774,7 +3469,6 @@ STRSAFEAPI StringCatWorkerA(char* pszDest, size_t cchDest, const char* pszSrc)
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCatWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc)
{
HRESULT hr;
@@ -3791,7 +3485,6 @@ STRSAFEAPI StringCatWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc)
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
STRSAFEAPI StringCatExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
@@ -3940,7 +3633,6 @@ STRSAFEAPI StringCatExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, cons
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCatExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, const WCHAR* pszSrc, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr = S_OK;
@@ -4086,7 +3778,6 @@ STRSAFEAPI StringCatExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, con
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
STRSAFEAPI StringCatNWorkerA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchMaxAppend)
{
@@ -4106,7 +3797,6 @@ STRSAFEAPI StringCatNWorkerA(char* pszDest, size_t cchDest, const char* pszSrc,
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCatNWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc, size_t cchMaxAppend)
{
HRESULT hr;
@@ -4124,7 +3814,6 @@ STRSAFEAPI StringCatNWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
STRSAFEAPI StringCatNExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, size_t cchMaxAppend, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
@@ -4272,7 +3961,6 @@ STRSAFEAPI StringCatNExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, con
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCatNExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, const WCHAR* pszSrc, size_t cchMaxAppend, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr = S_OK;
@@ -4419,7 +4107,6 @@ STRSAFEAPI StringCatNExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, co
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
STRSAFEAPI StringLengthWorkerA(const char* psz, size_t cchMax, size_t* pcch)
{
@@ -4446,7 +4133,6 @@ STRSAFEAPI StringLengthWorkerA(const char* psz, size_t cchMax, size_t* pcch)
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringLengthWorkerW(const WCHAR* psz, size_t cchMax, size_t* pcch)
{
HRESULT hr = S_OK;
@@ -4471,285 +4157,6 @@ STRSAFEAPI StringLengthWorkerW(const WCHAR* psz, size_t cchMax, size_t* pcch)
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
-#ifndef STRSAFE_LIB_IMPL
-#ifndef FEATURE_PAL
-STRSAFE_INLINE_API StringGetsExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
-{
- HRESULT hr = S_OK;
- char* pszDestEnd = pszDest;
- size_t cchRemaining = 0;
-
- // ASSERT(cbDest == (cchDest * sizeof(char)) ||
- // cbDest == (cchDest * sizeof(char)) + (cbDest % sizeof(char)));
-
- // only accept valid flags
- if (dwFlags & (~STRSAFE_VALID_FLAGS))
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- if (dwFlags & STRSAFE_IGNORE_NULLS)
- {
- if (pszDest == NULL)
- {
- if ((cchDest != 0) || (cbDest != 0))
- {
- // NULL pszDest and non-zero cchDest/cbDest is invalid
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- }
- }
-
- if (SUCCEEDED(hr))
- {
- if (cchDest <= 1)
- {
- pszDestEnd = pszDest;
- cchRemaining = cchDest;
-
- if (cchDest == 1)
- {
- *pszDestEnd = '\0';
- }
-
- hr = STRSAFE_E_INSUFFICIENT_BUFFER;
- }
- else
- {
- char ch;
-
- pszDestEnd = pszDest;
- cchRemaining = cchDest;
-
- while ((cchRemaining > 1) && (ch = (char)getc(stdin)) != '\n')
- {
- if (ch == EOF)
- {
- if (pszDestEnd == pszDest)
- {
- // we failed to read anything from stdin
- hr = STRSAFE_E_END_OF_FILE;
- }
- break;
- }
-
- *pszDestEnd = ch;
-
- pszDestEnd++;
- cchRemaining--;
- }
-
- if (cchRemaining > 0)
- {
- // there is extra room
- if (dwFlags & STRSAFE_FILL_BEHIND_NULL)
- {
- memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(char)) + (cbDest % sizeof(char)));
- }
- }
-
- *pszDestEnd = '\0';
- }
- }
- }
-
- if (FAILED(hr))
- {
- if (pszDest)
- {
- if (dwFlags & STRSAFE_FILL_ON_FAILURE)
- {
- memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest);
-
- if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0)
- {
- pszDestEnd = pszDest;
- cchRemaining = cchDest;
- }
- else if (cchDest > 0)
- {
- pszDestEnd = pszDest + cchDest - 1;
- cchRemaining = 1;
-
- // null terminate the end of the string
- *pszDestEnd = '\0';
- }
- }
-
- if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION))
- {
- if (cchDest > 0)
- {
- pszDestEnd = pszDest;
- cchRemaining = cchDest;
-
- // null terminate the beginning of the string
- *pszDestEnd = '\0';
- }
- }
- }
- }
-
- if (SUCCEEDED(hr) ||
- (hr == STRSAFE_E_INSUFFICIENT_BUFFER) ||
- (hr == STRSAFE_E_END_OF_FILE))
- {
- if (ppszDestEnd)
- {
- *ppszDestEnd = pszDestEnd;
- }
-
- if (pcchRemaining)
- {
- *pcchRemaining = cchRemaining;
- }
- }
-
- return hr;
-}
-
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFE_INLINE_API StringGetsExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
-{
- HRESULT hr = S_OK;
- WCHAR* pszDestEnd = pszDest;
- size_t cchRemaining = 0;
-
- // ASSERT(cbDest == (cchDest * sizeof(char)) ||
- // cbDest == (cchDest * sizeof(char)) + (cbDest % sizeof(char)));
-
- // only accept valid flags
- if (dwFlags & (~STRSAFE_VALID_FLAGS))
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- if (dwFlags & STRSAFE_IGNORE_NULLS)
- {
- if (pszDest == NULL)
- {
- if ((cchDest != 0) || (cbDest != 0))
- {
- // NULL pszDest and non-zero cchDest/cbDest is invalid
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- }
- }
-
- if (SUCCEEDED(hr))
- {
- if (cchDest <= 1)
- {
- pszDestEnd = pszDest;
- cchRemaining = cchDest;
-
- if (cchDest == 1)
- {
- *pszDestEnd = L'\0';
- }
-
- hr = STRSAFE_E_INSUFFICIENT_BUFFER;
- }
- else
- {
- WCHAR ch;
-
- pszDestEnd = pszDest;
- cchRemaining = cchDest;
-
- while ((cchRemaining > 1) && (ch = (WCHAR)getwc(stdin)) != L'\n')
- {
- if (ch == EOF)
- {
- if (pszDestEnd == pszDest)
- {
- // we failed to read anything from stdin
- hr = STRSAFE_E_END_OF_FILE;
- }
- break;
- }
-
- *pszDestEnd = ch;
-
- pszDestEnd++;
- cchRemaining--;
- }
-
- if (cchRemaining > 0)
- {
- // there is extra room
- if (dwFlags & STRSAFE_FILL_BEHIND_NULL)
- {
- memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(WCHAR)) + (cbDest % sizeof(WCHAR)));
- }
- }
-
- *pszDestEnd = L'\0';
- }
- }
- }
-
- if (FAILED(hr))
- {
- if (pszDest)
- {
- if (dwFlags & STRSAFE_FILL_ON_FAILURE)
- {
- memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest);
-
- if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0)
- {
- pszDestEnd = pszDest;
- cchRemaining = cchDest;
- }
- else if (cchDest > 0)
- {
- pszDestEnd = pszDest + cchDest - 1;
- cchRemaining = 1;
-
- // null terminate the end of the string
- *pszDestEnd = L'\0';
- }
- }
-
- if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION))
- {
- if (cchDest > 0)
- {
- pszDestEnd = pszDest;
- cchRemaining = cchDest;
-
- // null terminate the beginning of the string
- *pszDestEnd = L'\0';
- }
- }
- }
- }
-
- if (SUCCEEDED(hr) ||
- (hr == STRSAFE_E_INSUFFICIENT_BUFFER) ||
- (hr == STRSAFE_E_END_OF_FILE))
- {
- if (ppszDestEnd)
- {
- *ppszDestEnd = pszDestEnd;
- }
-
- if (pcchRemaining)
- {
- *pcchRemaining = cchRemaining;
- }
- }
-
- return hr;
-}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
-#endif // !FEATURE_PAL
-#endif // !STRSAFE_LIB_IMPL
-
#endif // _STRSAFE_H_INCLUDED_