Windows-Server-2003/termsrv/tsutil/string.c

119 lines
1.6 KiB
C
Raw Permalink Normal View History

2024-08-04 01:28:15 +02:00
/*
* String.c
*
* Author: BreenH
*
* String utilities.
*/
/*
* Includes
*/
#include "precomp.h"
#include "tsutil.h"
#include "tsutilnt.h"
/*
* Function Implementations
*/
PSTR WINAPI
AllocateAndCopyStringA(
PCSTR pString
)
{
NTSTATUS Status;
PSTR pCopy;
ASSERT(pString != NULL);
pCopy = NULL;
Status = NtAllocateAndCopyStringA(&pCopy, pString);
if (NT_SUCCESS(Status))
{
return(pCopy);
}
else
{
SetLastError(RtlNtStatusToDosError(Status));
return(NULL);
}
}
PWSTR WINAPI
AllocateAndCopyStringW(
PCWSTR pString
)
{
NTSTATUS Status;
PWSTR pCopy;
ASSERT(pString != NULL);
pCopy = NULL;
Status = NtAllocateAndCopyStringW(&pCopy, pString);
if (NT_SUCCESS(Status))
{
return(pCopy);
}
else
{
SetLastError(RtlNtStatusToDosError(Status));
return(NULL);
}
}
BOOL WINAPI
ConvertAnsiToUnicode(
PWSTR *ppUnicodeString,
PCSTR pAnsiString
)
{
BOOL fRet;
NTSTATUS Status;
Status = NtConvertAnsiToUnicode(ppUnicodeString, pAnsiString);
if (NT_SUCCESS(Status))
{
fRet = TRUE;
}
else
{
fRet = FALSE;
SetLastError(RtlNtStatusToDosError(Status));
}
return(fRet);
}
BOOL WINAPI
ConvertUnicodeToAnsi(
PSTR *ppAnsiString,
PCWSTR pUnicodeString
)
{
BOOL fRet;
NTSTATUS Status;
Status = NtConvertUnicodeToAnsi(ppAnsiString, pUnicodeString);
if (NT_SUCCESS(Status))
{
fRet = TRUE;
}
else
{
fRet = FALSE;
SetLastError(RtlNtStatusToDosError(Status));
}
return(fRet);
}