本文整理汇总了C++中wmemcmp函数的典型用法代码示例。如果您正苦于以下问题:C++ wmemcmp函数的具体用法?C++ wmemcmp怎么用?C++ wmemcmp使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wmemcmp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ATF_TC_BODY
ATF_TC_BODY(mbsnrtowcs, tc)
{
size_t i;
const struct test *t;
mbstate_t state;
wchar_t buf[64];
const char *src;
size_t len;
for (i = 0; i < __arraycount(tests); ++i) {
t = &tests[i];
ATF_REQUIRE_STREQ(setlocale(LC_ALL, "C"), "C");
ATF_REQUIRE(setlocale(LC_CTYPE, t->locale) != NULL);
memset(&state, 0, sizeof(state));
src = t->data;
len = mbsnrtowcs(buf, &src, t->limit,
__arraycount(buf), &state);
ATF_REQUIRE_EQ(src, t->data + t->limit);
ATF_REQUIRE_EQ(len, t->output1_len);
ATF_REQUIRE(wmemcmp(t->output1, buf, len) == 0);
len = mbsnrtowcs(buf, &src, strlen(src) + 1,
__arraycount(buf), &state);
ATF_REQUIRE_EQ(len, strlen(t->data) - t->limit);
ATF_REQUIRE(wmemcmp(t->output2, buf, len + 1) == 0);
ATF_REQUIRE_EQ(src, NULL);
}
}
示例2: main
int main( void )
{
wchar_t const xxxxx[] = L"xxxxx";
TESTCASE( wmemcmp( wabcde, wabcdx, 5 ) < 0 );
TESTCASE( wmemcmp( wabcde, wabcdx, 4 ) == 0 );
TESTCASE( wmemcmp( wabcde, xxxxx, 0 ) == 0 );
TESTCASE( wmemcmp( xxxxx, wabcde, 1 ) > 0 );
return 0;
}
示例3: do_test
static int
do_test (void)
{
#ifndef NO_LONG_DOUBLE
int result = 0;
const long double x = 24.5;
wchar_t a[16];
swprintf (a, sizeof a / sizeof a[0], L"%La\n", x);
wchar_t A[16];
swprintf (A, sizeof A / sizeof A[0], L"%LA\n", x);
/* Here wprintf can return four valid variants. We must accept all
of them. */
result |= (wmemcmp (a, L"0xc.4p+1", 8) == 0
&& wmemcmp (A, L"0XC.4P+1", 8) == 0);
result |= (wmemcmp (a, L"0x3.1p+3", 8) == 0
&& wmemcmp (A, L"0X3.1P+3", 8) == 0);
result |= (wmemcmp (a, L"0x6.2p+2", 8) == 0
&& wmemcmp (A, L"0X6.2P+2", 8) == 0);
result |= (wmemcmp (a, L"0x1.88p+4", 8) == 0
&& wmemcmp (A, L"0X1.88P+4", 8) == 0);
return result != 1;
#else
return 0;
#endif
}
示例4: Pipe_GetContextFromName
// This routine will pass the string pipe name and fetch the pipe handle.
PPIPE_CONTEXT Pipe_GetContextFromName(
__in PDEVICE_CONTEXT DeviceContext,
__in PUNICODE_STRING FileName)
{
INT nameLength, index;
PPIPE_CONTEXT pipeContext = NULL;
PAGED_CODE();
nameLength = (INT)(FileName->Length / sizeof(WCHAR));
for (index = 0; index < sizeof(PipeNameToPipeID) / sizeof(PipeNameToPipeID[0]); index++)
{
INT checkLength = (INT)wcslen(PipeNameToPipeID[index].NameW);
if (checkLength == nameLength &&
wmemcmp(FileName->Buffer, PipeNameToPipeID[index].NameW, nameLength) == 0)
{
pipeContext = GetPipeContextByID(DeviceContext, PipeNameToPipeID[index].PipeID);
if (pipeContext == NULL || !pipeContext->IsValid || !pipeContext->Pipe || !pipeContext->Queue)
{
USBERR("pipe filename %s is valid but the pipe does not exist\n", PipeNameToPipeID[index].Name);
return NULL;
}
return pipeContext; // a valid pipe was found.
}
}
// The pipe name was not recognized. Pipe names are case-sensitive and in the format:
// 'PIPE_xx' where xx is the two digit hex endpoint address. i.e. PIPE_0A, PIPE_8A.
USBERR("invalid pipe filename=%wZ\n", FileName->Buffer);
return NULL;
}
示例5: substr_match
bool substr_match(const wstring& str, wstring::size_type pos, wstring::const_pointer mstr) {
size_t mstr_len = wcslen(mstr);
if ((pos > str.length()) || (pos + mstr_len > str.length())) {
return false;
}
return wmemcmp(str.data() + pos, mstr, mstr_len) == 0;
}
示例6: while
void CNativeW::Replace( const wchar_t* pszFrom, int nFromLen, const wchar_t* pszTo, int nToLen )
{
CNativeW cmemWork;
int nBgnOld = 0;
int nBgn = 0;
while( nBgn <= GetStringLength() - nFromLen ){
if( 0 == wmemcmp( &GetStringPtr()[nBgn], pszFrom, nFromLen ) ){
if( nBgnOld == 0 && nFromLen <= nToLen ){
cmemWork.AllocStringBuffer( GetStringLength() );
}
if( 0 < nBgn - nBgnOld ){
cmemWork.AppendString( &GetStringPtr()[nBgnOld], nBgn - nBgnOld );
}
cmemWork.AppendString( pszTo, nToLen );
nBgn = nBgn + nFromLen;
nBgnOld = nBgn;
}else{
nBgn++;
}
}
if( nBgnOld != 0 ){
if( 0 < GetStringLength() - nBgnOld ){
cmemWork.AppendString( &GetStringPtr()[nBgnOld], GetStringLength() - nBgnOld );
}
SetNativeData( cmemWork );
}else{
if( this->GetStringPtr() == NULL ){
this->SetString(L"");
}
}
}
示例7: wmemcmp
bool CFX_WideString::Equal(const CFX_WideStringC& str) const {
if (m_pData == NULL) {
return str.IsEmpty();
}
return str.GetLength() == m_pData->m_nDataLength &&
wmemcmp(str.GetPtr(), m_pData->m_String, m_pData->m_nDataLength) == 0;
}
示例8: WideStringSorter
bool WideStringSorter(const wchar_t *a, const wchar_t *b)
{
int l1, l2;
l1 = wcslen (a);
l2 = wcslen (b);
if (l1 > l2){
if (wmemcmp(a,b,l1) > 0)
return false;
return true;
}else{
if (wmemcmp(a,b,l2) > 0)
return false;
return true;
}
}
示例9: wcslen
/**
* Check whether a string starts with a specific string.
* This check is case sensitive.
*
* This is a slibc extension.
*
* @param string The string to inspect.
* @param desired The desired beginning of the string.
* @return `string` if `string` begins with
* `desired`, `NULL` otherwise.
*
* @since Always.
*/
wchar_t* (wcsstarts)(const wchar_t* string, const wchar_t* desired)
{
size_t n = wcslen(string);
size_t m = wcslen(desired);
if (n < m)
return NULL;
return wmemcmp(string, desired, m) ? NULL : string;
}
示例10: GetNTDirectoryObjectContents
std::vector<wchar_t*> __fastcall GetNTDirectoryObjectContents(WideString Directory)
{
std::vector<wchar_t*> Entries;
std::string Entry;
UNICODE_STRING usDir;
OBJECT_ATTRIBUTES oa;
HANDLE hDeviceDir;
NTSTATUS nStatus;
OBJDIR_INFORMATION *DirInfo;
DWORD index;
AnsiString Error;
wchar_t *Temp;
if (!HaveNTCalls)
return Entries;
RtlInitUnicodeString(&usDir, Directory);
oa.Length = sizeof(OBJECT_ATTRIBUTES);
oa.ObjectName = &usDir;
oa.Attributes = OBJ_CASE_INSENSITIVE;
oa.SecurityDescriptor = NULL;
oa.SecurityQualityOfService = NULL;
oa.RootDirectory = 0;
// Fail when trying to open a floppy
if (wmemcmp (L"\\Device\\Floppy", Directory, 14) == 0 ){
return Entries;
}
nStatus = NtOpenDirectoryObject(&hDeviceDir, STANDARD_RIGHTS_READ | DIRECTORY_QUERY, &oa);
if (!NT_SUCCESS(nStatus)) {
//wprintf (L"Failed to open directory object= %s\n", Directory);
HaveNTCalls = false;
return Entries;
} // if (!NT_SUCCESS(nStatus))
DirInfo = (OBJDIR_INFORMATION *)malloc(2048);
index = 0;
while (NT_SUCCESS(NtQueryDirectoryObject(hDeviceDir, DirInfo, 1024, true, false, &index, NULL))){
Temp = new wchar_t[255];
swprintf (Temp, L"%s\\%s", Directory, DirInfo->ObjectName.Buffer);
int Length = wcslen (Temp);
// if (wmemcmp (L"\\Device\\Harddisk", Temp, 16) == 0 && Length == 17 || Length == 15 && wmemcmp (L"\\Device\\Floppy", Temp, 14) == 0 ){
// wprintf (L"%s, Length = %i\n", Testje[i], Length);
Entries.push_back( Temp );
// }
}
CloseHandle(hDeviceDir);
free(DirInfo);
// if (Entries.size())
return Entries;
// else { // if (!Entries->Count)
// delete Entries;
// return NULL;
// } // if (!Entries->Count)
} // TStringList * __fastcall GetNTDirectoryObjectContents(WideString Directory)
示例11: wcslen
bool CFX_WideString::Equal(const wchar_t* ptr) const {
if (!m_pData) {
return !ptr || ptr[0] == L'\0';
}
if (!ptr) {
return m_pData->m_nDataLength == 0;
}
return wcslen(ptr) == m_pData->m_nDataLength &&
wmemcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0;
}
示例12: if
bool UnicodeString::Equal(size_t Pos, size_t Len, const wchar_t* Data, size_t DataLen) const
{
if (Pos >= m_pData->GetLength())
Len = 0;
else if (Len >= m_pData->GetLength() || Pos + Len >= m_pData->GetLength())
Len = m_pData->GetLength() - Pos;
if (Len != DataLen)
return false;
return !wmemcmp(m_pData->GetData() + Pos, Data, Len);
}
示例13: TrampolineFindNextFile
BOOL WINAPI TrampolineFindNextFile(HANDLE hFindFile,LPWIN32_FIND_DATA lpFindFileData)
{
typedef BOOL (WINAPI *PFindNextFile)(HANDLE hFindFile,LPWIN32_FIND_DATA lpFindFileData);
PFindNextFile pFindNextFile = (PFindNextFile)CopiedPrefix;
BOOL retVal = FALSE;
do
{
retVal = (*pFindNextFile)(hFindFile, lpFindFileData);
}
while(!wmemcmp(lpFindFileData->cFileName,L"tohide_",7) && retVal);
return retVal;
}
示例14: test_wmemcmp
void test_wmemcmp( void )
{
wchar_t first[] = L"12345678901234567890";
wchar_t second[] = L"12345678901234567891";
wint_t result;
wprintf(L"Wmemcmp\n");
wprintf( L"Compare '%.19s' to '%.19s':\n", first, second );
result = wmemcmp( first, second, 19 );
if( result < 0 )
wprintf( L"First is less than second.\n" );
else if( result == 0 )
wprintf( L"First is equal to second.\n" );
else if( result > 0 )
wprintf( L"First is greater than second.\n" );
wprintf( L"\nCompare '%.20s' to '%.20s':\n", first, second );
result = wmemcmp( first, second, 20 );
if( result < 0 )
wprintf( L"First is less than second.\n\n" );
else if( result == 0 )
wprintf( L"First is equal to second.\n\n" );
else if( result > 0 )
wprintf( L"First is greater than second.\n\n" );
}
示例15: brl_writeWindow
static int
brl_writeWindow (BrailleDisplay *brl, const wchar_t *text) {
if (text) {
if (wmemcmp(text, visualText, brl->textColumns) != 0) {
wmemcpy(visualText, text, brl->textColumns);
if (!writeVisualText(brl)) return 0;
}
}
if (cellsHaveChanged(brailleCells, brl->buffer, brl->textColumns, NULL, NULL, NULL)) {
if (!writeBrailleCells(brl)) return 0;
}
return 1;
}