Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

118 lines
1.6 KiB

/*
* 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);
}