コード例 #1
0
ファイル: LightFX.cpp プロジェクト: Arc0re/lithtech
// ----------------------------------------------------------------------- //
//
//	ROUTINE:	LightFX::
//
//	PURPOSE:
//
// ----------------------------------------------------------------------- //
void LightFX::PlayRampSound(int nDirection)
{
	CServerDE* pServerDE = GetServerDE();
	if (!pServerDE) return;
    
	char *sound = DNULL;
    
    // Set the char pointer    
	if (nDirection == 1 && m_hstrRampUpSound)
	{
		sound = pServerDE->GetStringData(m_hstrRampUpSound);
	}
	else if (m_hstrRampDownSound)
	{
		sound = pServerDE->GetStringData(m_hstrRampDownSound);
	}

    // Play the sound if valid pointer
	if (sound && _mbstrlen(sound) > 0)
	{
		DFLOAT Radius = 1000.0f;
		PlaySoundFromObject(m_hObject, sound, Radius, SOUNDPRIORITY_MISC_HIGH);
	}

}
コード例 #2
0
ファイル: KeyFixes.cpp プロジェクト: Arc0re/lithtech
void ConvertKeyToCurrentKeyboard(char* sNewKey, char* sOldKey, int nNewKeyMaxSize)
{
	if (_mbstrlen(sOldKey) == 1)
	{
		HKL nDefaultKeyboard = GetKeyboardLayout(0);

		SHORT nCharCode = sOldKey[0];

		if ((nCharCode > 0) && (nCharCode <= 255))
		{
			SHORT nScanCode = g_pEnglishCharToScanCodeTable[nCharCode];

			if (nScanCode != -1)
			{
				SHORT nKeyCode2 = MapVirtualKeyEx(nScanCode & 0xff, 1, nDefaultKeyboard);

				if (nKeyCode2 != -1)
				{
					UINT nNewChar = MapVirtualKeyEx( nKeyCode2 & 0xff, 2, nDefaultKeyboard);

					if (nNewChar != 0)
					{
						sNewKey[0] = (char)nNewChar;
						sNewKey[1] = '\0';
						return;
					}
				}
			}
		}
	}

	_mbsncpy((unsigned char*)sNewKey, (const unsigned char*)sOldKey, nNewKeyMaxSize);
	sNewKey[nNewKeyMaxSize-1] = '\0';
}
コード例 #3
0
ファイル: Credits.cpp プロジェクト: Arc0re/lithtech
DBOOL CCredit::AddString(char* sString)
{
	// Sanity checks...

	if (!m_pClientDE) return(DFALSE);
	if (!sString) return(DFALSE);
	if (m_cStrings >= MAX_CREDIT_STRINGS) return(DFALSE);


	// Check if this is a special command string...

	if (_mbsnbcmp((const unsigned char*)sString, (const unsigned char*)">TIME:", 6) == 0)
	{
		if (_mbstrlen(sString) > 6)
		{
			m_fHoldTime = (float)atof(&sString[6]);
			return(DTRUE);
		}
	}


	// Create a new string via the engine...

	HSTRING hString = m_pClientDE->CreateString(sString);
	if (!hString) return(DFALSE);

	m_aStrings[m_cStrings++] = hString;


	// All done...

	return(DTRUE);
}
コード例 #4
0
ファイル: tinystr.cpp プロジェクト: EmergencyX/e4mod-Client
// TiXmlString constructor, based on a C string
TiXmlString::TiXmlString (const char* instring)
{
    unsigned newlen;
    wchar_t * newstring;

    if (!instring)
    {
        allocated = 0;
        wcstring = NULL;
		clength = 0;
        return;
    }

	newlen = _mbstrlen(instring) + 1;

	if (newlen < 0)
	{
		allocated = 0;
		wcstring = NULL;
		clength = 0;
		return;
	}
    newstring = new wchar_t [newlen];
	mbstowcs(newstring, instring, newlen);
    allocated = newlen;
    wcstring = newstring;
	clength = newlen - 1;
}
コード例 #5
0
ファイル: Credits.cpp プロジェクト: rickyharis39/nolf2
LTBOOL CCredit::AddString(char* sString)
{
	// Sanity checks...

	if (!g_pLTClient) return(LTFALSE);
	if (!sString) return(LTFALSE);

	// Check if this is a special command string...

	if (strncmp(sString, ">TIME:", 6) == 0)
	{
		if (_mbstrlen(sString) > 6)
		{
			m_fHoldTime = (float)atof(&sString[6]);
			return(LTTRUE);
		}
	}
	if (strncmp(sString, ">POS:UL", 7) == 0)
	{
		m_hAlign = CUI_HALIGN_LEFT;
		m_Pos = s_PositionUL;
		m_ePosition = CP_UL;
		return(LTTRUE);
	}
	if (strncmp(sString, ">POS:UR", 7) == 0)
	{
		m_hAlign = CUI_HALIGN_RIGHT;
		m_Pos = s_PositionUR;
		m_ePosition = CP_UR;
		return(LTTRUE);
	}
	if (strncmp(sString, ">POS:LR", 7) == 0)
	{
		m_hAlign = CUI_HALIGN_RIGHT;
		m_Pos = s_PositionLR;
		m_ePosition = CP_LR;
		return(LTTRUE);
	}
	if (strncmp(sString, ">POS:LL", 7) == 0)
	{
		m_hAlign = CUI_HALIGN_LEFT;
		m_Pos = s_PositionLL;
		m_ePosition = CP_LL;
		return(LTTRUE);
	}
	if (strncmp(sString, ">BIG", 4) == 0)
	{
		m_bBig = LTTRUE;
		return(LTTRUE);
	}

	uint8 nFont = 0;
	CUIFont* pFont = g_pInterfaceResMgr->GetFont(nFont);
	CUIFormattedPolyString* pStr = g_pFontManager->CreateFormattedPolyString(pFont,sString,(float)m_Pos.x,(float)m_Pos.y);
	if (pStr)
		m_Strings.push_back(pStr);

	return(LTTRUE);
}
コード例 #6
0
ファイル: Credits.cpp プロジェクト: Arc0re/lithtech
DBOOL CCredit::Init(CClientDE* pClientDE, char* sBuf)
{
	// Sanity checks...

	if (!pClientDE) return(DFALSE);
	if (!sBuf) return(DFALSE);


	// Set simple members...

	m_pClientDE = pClientDE;
	m_nState    = CS_START;

	s_bPause    = DFALSE;


	// Parse the text buffer and add each line as a seperate string...

	char sString[256];
	int  i = 0;

	while (*sBuf)
	{
		if ((*sBuf == '\n') || (*sBuf == '\r') || (*sBuf == '\0'))
		{
			sString[i] = '\0';
			AddString(sString); 
			i = 0;

			while (((*sBuf == '\n') || (*sBuf == '\r'))) 
			{
				sBuf = (char*)_mbsinc((const unsigned char*)sBuf);
			};
		}
		else
		{
			int nCount = _mbsnbcnt((const unsigned char*)sBuf,1);
			memcpy(&sString[i], sBuf, nCount);
			i += nCount;
			sBuf = (char*)_mbsinc((const unsigned char*)sBuf);
		}
	}

	sString[i] = '\0';
	if (_mbstrlen(sString) > 0) AddString(sString);


	// All done...

	return(DTRUE);
}
コード例 #7
0
ファイル: MainMenus.cpp プロジェクト: bsmr-games/Blood2
// Changes the background of the menu
void CMainMenus::ChangeBackground(char *szBackground)
{
	// If the new background doesn't exist, just paint the old one black
	if(!szBackground)
	{
		HDECOLOR	black;
		black = m_pClientDE->SetupColor1(0.0f, 0.0f, 0.0f, DFALSE);
		m_pClientDE->FillRect(m_hSurfBackground, DNULL, black);

		if (m_lpszBackground)
		{
			delete []m_lpszBackground;
			m_lpszBackground=DNULL;
		}
		return;
	}

	// If the backgrounds are the same, then we don't need to reload them!
	if (m_lpszBackground)
	{
		if (_mbsicmp((const unsigned char*)szBackground, (const unsigned char*)m_lpszBackground) == 0)
		{
			return;
		}
		else
		{
			delete []m_lpszBackground;
			m_lpszBackground=DNULL;
		}
	}

	// Copy the background string
	int nBufferSize=_mbstrlen(szBackground)+1;
	m_lpszBackground = new char[nBufferSize];
	memset(m_lpszBackground, 0, nBufferSize);
	_mbscpy((unsigned char*)m_lpszBackground, (const unsigned char*)szBackground);

	// Delete the current background
	if(m_hSurfBackground)
	{
		m_pClientDE->DeleteSurface(m_hSurfBackground);
		m_hSurfBackground = DNULL;
	}

	// Replace it with the new background
	m_hSurfBackground = m_pClientDE->CreateSurfaceFromBitmap(szBackground);
}
コード例 #8
0
ファイル: CameraObj.cpp プロジェクト: Arc0re/lithtech
void CameraObj::HandleTrigger(HOBJECT hSender, HSTRING hMsg)
{
	if (!g_pServerDE) return;

	char* pMsg = g_pServerDE->GetStringData(hMsg);
	if (!pMsg) return;

	// Turn the camera on
	if (_mbsicmp((const unsigned char*)pMsg, (const unsigned char*)"ON") == 0)
	{
		SetActive(DTRUE);
	}
	
	// Turn the camera off
	else if (_mbsicmp((const unsigned char*)pMsg, (const unsigned char*)"OFF") == 0)
	{
		SetActive(DFALSE);
	}

	// Link to a named object
	else if (strnicmp(pMsg, "LINK", 4) == 0)
	{ 
		if (_mbstrlen(pMsg) >= 6)
		{
			// Skip ahead to the name of the object
			pMsg += 5;

			ObjectList*	pList = g_pServerDE->FindNamedObjects(pMsg);
    		if (pList)
			{
				ObjectLink* pLink = pList->m_pFirstLink;
				if (pLink)
    			{
					SetLinkObject(pLink->m_hObject);
	    		}

				g_pServerDE->RelinquishList(pList);
			}
		}
		else
		{
			SetLinkObject(DNULL);
		}
	}
}
コード例 #9
0
ファイル: theme.cpp プロジェクト: ifzz/BuyTicket
void	CTheme::DrawThemeText(	HDC dc,
					  int iPartId,
					  int iStateId,
					  LPCSTR pszText,
					  int iCharCount,
					  DWORD dwTextFlags,
					  DWORD dwTextFlags2,
					  const RECT *pRect
					  )
{
	if(m_hTheme && zDrawThemeText)
	{
		//Convert string to unicode
		int length = iCharCount;

		if(iCharCount == -1)
		{
			length = _mbstrlen(pszText);
		}

		//Use api convert routine
		wchar_t* wbuffer = new wchar_t[length+1];
		
		MultiByteToWideChar(	CP_THREAD_ACP,
								0,
								pszText,
								length,
								wbuffer,
								length+1);
		
		wbuffer[length] = '\0';
		
		DrawThemeText(	dc,
						iPartId,
						iStateId,
						wbuffer,
						iCharCount,
						dwTextFlags,
						dwTextFlags2,
						pRect );
		
		delete [] wbuffer;

	}
}
コード例 #10
0
ファイル: tinystr.cpp プロジェクト: EmergencyX/e4mod-Client
// TiXmlString = operator. Safe when assign own content
void TiXmlString ::operator = (const char * content)
{
    unsigned newlen;
    wchar_t * newstring;

    if (! content)
    {
        empty_it ();
        return;
    }
	newlen = _mbstrlen(content) + 1;
    newstring = new wchar_t [newlen];
    mbstowcs (newstring, content, newlen);
    empty_it ();
    allocated = newlen;
    wcstring = newstring;
	clength = newlen - 1;
}
コード例 #11
0
ファイル: VoiceMgr.cpp プロジェクト: Arc0re/lithtech
DBOOL CVoiceGroup::AddSoundString(char* sSound)
{
	// Sanity checks...

	if (!sSound) return(DFALSE);
	if (GetNumSounds() >= VM_MAX_SOUNDS) return(DFALSE);
	if (_mbstrlen(sSound) >= VM_MAX_STRING) return(DFALSE);


	// Add the string...

	_mbscpy((unsigned char*)m_sSounds[m_cSounds], (const unsigned char*)sSound);

	m_cSounds++;


	// All done...

	return(DTRUE);
}
コード例 #12
0
ファイル: VoiceMgr.cpp プロジェクト: Arc0re/lithtech
int CVoiceGroup::AddSoundStrings(char* sDir)
{
	// Sanity checks...

	if (!sDir) return(0);
	if (sDir[0] == '\0') return(0);


	// Add all of the sound strings in the given rez directory...

	int cSounds = 0;

	FileEntry* pFiles = m_pClientDE->GetFileList(sDir);
	if (!pFiles) return(0);

	FileEntry* pCurFile = pFiles;

	while (pCurFile)
	{
		if (pCurFile->m_Type == TYPE_FILE)
		{
			int nLen = _mbstrlen(pCurFile->m_pBaseFilename);

			if (nLen > 4 && strnicmp(&pCurFile->m_pBaseFilename[nLen - 4], ".wav", 4) == 0)
			{
				if (AddSoundString(pCurFile->m_pFullFilename))
				{
					cSounds++;
				}
			}
		}

		pCurFile= pCurFile->m_pNext;
	}


	// All done...
	m_pClientDE->FreeFileList(pFiles);
	return(cSounds);
}
コード例 #13
0
ファイル: mbstowcs.c プロジェクト: chunhualiu/OpenNT
size_t __cdecl _mbstowcs_lk
#else
size_t __cdecl mbstowcs
#endif
    (
        wchar_t  *pwcs,
        const char *s,
        size_t n
        )
{
        size_t count = 0;

        if (pwcs && n == 0)
            /* dest string exists, but 0 bytes converted */
            return (size_t) 0;

        _ASSERTE(s != NULL);

#ifdef _WIN32
#if !defined(_NTSUBSET_) && !defined(_POSIX_)

        /* if destination string exists, fill it in */
        if (pwcs)
        {
            if (__lc_handle[LC_CTYPE] == _CLOCALEHANDLE)
            {
                /* C locale: easy and fast */
                while (count < n)
                {
                    *pwcs = (wchar_t) ((unsigned char)s[count]);
                    if (!s[count])
                        return count;
                    count++;
                    pwcs++;
                }
                return count;

            } else {
                int bytecnt, charcnt;
                unsigned char *p;

                /* Assume that the buffer is large enough */
                if ((count=MultiByteToWideChar(__lc_codepage, MB_PRECOMPOSED|MB_ERR_INVALID_CHARS,
                    s, -1, pwcs, n)) != 0)
                    return count - 1; /* don't count NUL */

                if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
                {
                    errno = EILSEQ;
                    return (size_t)-1;
                }

                /* User-supplied buffer not large enough. */

                /* How many bytes are in n characters of the string? */
                charcnt = n;
                for (p = (unsigned char *)s; (charcnt-- && *p); p++)
                {
                    if (isleadbyte(*p))
                        p++;
                }
                bytecnt = ((int) ((char *)p - (char *)s));

                if ((count = MultiByteToWideChar (__lc_codepage, MB_PRECOMPOSED,
                    s, bytecnt, pwcs, n)) == 0)
                {
                    errno = EILSEQ;
                    return (size_t)-1;
                }

                return count; /* no NUL in string */
            }
        }
        else { /* pwcs == NULL, get size only, s must be NUL-terminated */
            if (__lc_handle[LC_CTYPE] == _CLOCALEHANDLE)
                return strlen(s);

            else {
                if ((count=MultiByteToWideChar(__lc_codepage, MB_PRECOMPOSED|MB_ERR_INVALID_CHARS,
                s, -1, NULL, 0)) == 0)
                {
                    errno = EILSEQ;
                    return (size_t)-1;
                }

                return count - 1;
            }
        }

#else /* _NTSUBSET_/_POSIX_ */

        if (pwcs) {

            NTSTATUS Status;
            int size;

            size = _mbstrlen(s);
            Status = RtlMultiByteToUnicodeN(pwcs,
                                            n * sizeof( *pwcs ),
                                            (PULONG)&size,
                                            (char *)s,
                                            size+1 );
            if (!NT_SUCCESS(Status)) {
                errno = EILSEQ;
                size = -1;
            } else {
                size = size / sizeof(*pwcs);
                if (pwcs[size-1] == L'\0') {
                    size -= 1;
                }
            }
            return size;

        } else { /* pwcs == NULL, get size only, s must be NUL-terminated */
            return strlen(s);
        }

#endif /* _NTSUBSET_/_POSIX_ */
#else /* _WIN32 */

        /* if destination string exists, fill it in */
        if (pwcs)
        {
            /* C locale: easy and fast */
            while (count < n)
            {
                *pwcs = (wchar_t) ((unsigned char)s[count]);
                if (!s[count])
                    return count;
                count++;
                pwcs++;
            }
            return count;

        } else { /* pwcs == NULL, get size only, s must be NUL-terminated */
            return strlen(s);
        }

#endif /* _WIN32 */

}
コード例 #14
0
ファイル: Debris.cpp プロジェクト: Arc0re/lithtech
DBOOL CDebris::ReadProp(ObjectCreateStruct *)
{
	CServerDE* pServerDE = BaseClass::GetServerDE();
	if (!pServerDE) return DFALSE;

	long nLongVal;
	if (pServerDE->GetPropLongInt("Amount", &nLongVal) == DE_OK)
		m_nAmount = (DBYTE)nLongVal;

	DBOOL bBoolVal;
	if (pServerDE->GetPropBool("Stone", &bBoolVal) == DE_OK)
		m_bStone = bBoolVal;

	if (pServerDE->GetPropBool("Metal", &bBoolVal) == DE_OK)
		m_bMetal = bBoolVal;

	if (pServerDE->GetPropBool("Wood", &bBoolVal) == DE_OK)
		m_bWood = bBoolVal;
	
	if (pServerDE->GetPropBool("Energy", &bBoolVal) == DE_OK)
		m_bEnergy = bBoolVal;
	
	if (pServerDE->GetPropBool("Glass", &bBoolVal) == DE_OK)
		m_bGlass = bBoolVal;
	
	if (pServerDE->GetPropBool("Terrain", &bBoolVal) == DE_OK)
		m_bTerrain = bBoolVal;

	if (pServerDE->GetPropBool("Plastic", &bBoolVal) == DE_OK)
		m_bPlastic = bBoolVal;

	if (pServerDE->GetPropBool("Metal", &bBoolVal) == DE_OK)
		m_bMetal = bBoolVal;

	if (pServerDE->GetPropBool("Liquid", &bBoolVal) == DE_OK)
		m_bLiquid = bBoolVal;

	if (pServerDE->GetPropBool("Custom", &bBoolVal) == DE_OK)
		m_bCustom = bBoolVal;

	if (pServerDE->GetPropBool("Flesh", &bBoolVal) == DE_OK)
		m_bFlesh = bBoolVal;

	if (pServerDE->GetPropBool("Exploding", &bBoolVal) == DE_OK)
		m_bExploding = bBoolVal;

	DFLOAT fRealVal;
	if (pServerDE->GetPropReal("Scale", &fRealVal) == DE_OK)
		m_fScale = fRealVal;

	char buf[MAX_CS_FILENAME_LEN];
	if (pServerDE->GetPropString("CustomSound", buf, MAX_CS_FILENAME_LEN) == DE_OK)
	{
		if (_mbstrlen(buf) > 0)
			m_hstrSound = pServerDE->CreateString(buf);
	}

	if (pServerDE->GetPropString("CustomModel", buf, MAX_CS_FILENAME_LEN) == DE_OK)
	{
		if (_mbstrlen(buf) > 0)
		{
			m_hstrModel1 = pServerDE->CreateString(buf);
//			m_hstrModel2 = pServerDE->CopyString(m_hstrModel1);
		}
	}

	if (pServerDE->GetPropString("CustomTexture", buf, MAX_CS_FILENAME_LEN) == DE_OK)
	{
		if (_mbstrlen(buf) > 0)
		{
			m_hstrTexture1 = pServerDE->CreateString(buf);
//			m_hstrTexture2 = pServerDE->CopyString(m_hstrTexture1);
		}
	}

	return DTRUE;
}
コード例 #15
0
ファイル: PathMgr.cpp プロジェクト: Arc0re/lithtech
DBOOL PathMgr::GetPath(char* pBasePathName, PathList* pReturnList)
{
	CServerDE* pServerDE = BaseClass::GetServerDE();
	if (!pServerDE) return DFALSE;

	if (!pBasePathName || !pReturnList || pBasePathName[0] == '\0') return DFALSE;

	// Make sure we've got some keys to look through...

	if (m_pathList.IsEmpty()) return DFALSE;


	// Make sure we start with a clean slate...

	if (!pReturnList->IsEmpty()) pReturnList->RemoveAll();


	int nNumItems = m_pathList.GetNumItems();
	int nNameLen  = _mbstrlen(pBasePathName);
	if (nNameLen < 1) return DFALSE;

	DList sortList;
	dl_InitList(&sortList);
	sortList.m_Head.m_pData = DNULL;

	for (int i=0; i < nNumItems; i++)
	{
		PathListData* pCurData = m_pathList[i];
		if (!pCurData || !pCurData->m_hstrName) return DFALSE;

		char* pName = pServerDE->GetStringData(pCurData->m_hstrName);
		if (!pName) return DFALSE;

		if (strnicmp(pName, pBasePathName, nNameLen) == 0)
		{
			int nTestLen = _mbstrlen(pName);
			
			// Make sure the name is of the form BaseXXX where XXX is
			// a number...

			if (nTestLen > nNameLen)
			{
				if (isdigit(pName[nNameLen]))
				{
					AddToSortedList(&sortList, pCurData);
				}
			}
		}
	}

	if (sortList.m_nElements < 1) return DFALSE;


	// Copy the sorted list to the return list...

	DLink* pLink = sortList.m_Head.m_pNext;

	while (sortList.m_nElements > 0)
	{
		PathListData* pData = (PathListData*)pLink->m_pData;
		if (pData)
		{
			pReturnList->Add(pData);
		}

		dl_RemoveAt(&sortList, pLink);
		delete pLink;

		pLink = sortList.m_Head.m_pNext;
	}


	return DTRUE;
}
コード例 #16
0
ファイル: string.c プロジェクト: bilboed/wine
static void test_mbcp(void)
{
    int mb_orig_max = *p__mb_cur_max;
    int curr_mbcp = _getmbcp();
    unsigned char *mbstring = (unsigned char *)"\xb0\xb1\xb2 \xb3\xb4 \xb5"; /* incorrect string */
    unsigned char *mbstring2 = (unsigned char *)"\xb0\xb1\xb2\xb3Q\xb4\xb5"; /* correct string */
    unsigned char *mbsonlylead = (unsigned char *)"\xb0\0\xb1\xb2 \xb3";
    unsigned char buf[16];
    int step;

    /* _mbtype tests */

    /* An SBCS codepage test. The ctype of characters on e.g. CP1252 or CP1250 differs slightly
     * between versions of Windows. Also Windows 9x seems to ignore the codepage and always uses
     * CP1252 (or the ACP?) so we test only a few ASCII characters */
    _setmbcp(1252);
    expect_eq(p_mbctype[10], 0, char, "%x");
    expect_eq(p_mbctype[50], 0, char, "%x");
    expect_eq(p_mbctype[66], _SBUP, char, "%x");
    expect_eq(p_mbctype[100], _SBLOW, char, "%x");
    expect_eq(p_mbctype[128], 0, char, "%x");
    _setmbcp(1250);
    expect_eq(p_mbctype[10], 0, char, "%x");
    expect_eq(p_mbctype[50], 0, char, "%x");
    expect_eq(p_mbctype[66], _SBUP, char, "%x");
    expect_eq(p_mbctype[100], _SBLOW, char, "%x");
    expect_eq(p_mbctype[128], 0, char, "%x");

    /* double byte code pages */
    test_codepage(932);
    test_codepage(936);
    test_codepage(949);
    test_codepage(950);

    _setmbcp(936);
    ok(*p__mb_cur_max == mb_orig_max, "__mb_cur_max shouldn't be updated (is %d != %d)\n", *p__mb_cur_max, mb_orig_max);
    ok(_ismbblead('\354'), "\354 should be a lead byte\n");
    ok(_ismbblead(' ') == FALSE, "' ' should not be a lead byte\n");
    ok(_ismbblead(0x1234b0), "0x1234b0 should not be a lead byte\n");
    ok(_ismbblead(0x123420) == FALSE, "0x123420 should not be a lead byte\n");
    ok(_ismbbtrail('\xb0'), "\xa0 should be a trail byte\n");
    ok(_ismbbtrail(' ') == FALSE, "' ' should not be a trail byte\n");

    /* _ismbslead */
    expect_eq(_ismbslead(mbstring, &mbstring[0]), -1, int, "%d");
    expect_eq(_ismbslead(mbstring, &mbstring[1]), FALSE, int, "%d");
    expect_eq(_ismbslead(mbstring, &mbstring[2]), -1, int, "%d");
    expect_eq(_ismbslead(mbstring, &mbstring[3]), FALSE, int, "%d");
    expect_eq(_ismbslead(mbstring, &mbstring[4]), -1, int, "%d");
    expect_eq(_ismbslead(mbstring, &mbstring[5]), FALSE, int, "%d");
    expect_eq(_ismbslead(mbstring, &mbstring[6]), FALSE, int, "%d");
    expect_eq(_ismbslead(mbstring, &mbstring[7]), -1, int, "%d");
    expect_eq(_ismbslead(mbstring, &mbstring[8]), FALSE, int, "%d");

    expect_eq(_ismbslead(mbsonlylead, &mbsonlylead[0]), -1, int, "%d");
    expect_eq(_ismbslead(mbsonlylead, &mbsonlylead[1]), FALSE, int, "%d");
    expect_eq(_ismbslead(mbsonlylead, &mbsonlylead[2]), FALSE, int, "%d");
    expect_eq(_ismbslead(mbsonlylead, &mbsonlylead[5]), FALSE, int, "%d");

    /* _ismbstrail */
    expect_eq(_ismbstrail(mbstring, &mbstring[0]), FALSE, int, "%d");
    expect_eq(_ismbstrail(mbstring, &mbstring[1]), -1, int, "%d");
    expect_eq(_ismbstrail(mbstring, &mbstring[2]), FALSE, int, "%d");
    expect_eq(_ismbstrail(mbstring, &mbstring[3]), -1, int, "%d");
    expect_eq(_ismbstrail(mbstring, &mbstring[4]), FALSE, int, "%d");
    expect_eq(_ismbstrail(mbstring, &mbstring[5]), -1, int, "%d");
    expect_eq(_ismbstrail(mbstring, &mbstring[6]), FALSE, int, "%d");
    expect_eq(_ismbstrail(mbstring, &mbstring[7]), FALSE, int, "%d");
    expect_eq(_ismbstrail(mbstring, &mbstring[8]), -1, int, "%d");

    expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[0]), FALSE, int, "%d");
    expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[1]), -1, int, "%d");
    expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[2]), FALSE, int, "%d");
    expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[3]), FALSE, int, "%d");
    expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[4]), FALSE, int, "%d");
    expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[5]), FALSE, int, "%d");

    /* _mbsbtype */
    expect_eq(_mbsbtype(mbstring, 0), _MBC_LEAD, int, "%d");
    expect_eq(_mbsbtype(mbstring, 1), _MBC_TRAIL, int, "%d");
    expect_eq(_mbsbtype(mbstring, 2), _MBC_LEAD, int, "%d");
    expect_eq(_mbsbtype(mbstring, 3), _MBC_ILLEGAL, int, "%d");
    expect_eq(_mbsbtype(mbstring, 4), _MBC_LEAD, int, "%d");
    expect_eq(_mbsbtype(mbstring, 5), _MBC_TRAIL, int, "%d");
    expect_eq(_mbsbtype(mbstring, 6), _MBC_SINGLE, int, "%d");
    expect_eq(_mbsbtype(mbstring, 7), _MBC_LEAD, int, "%d");
    expect_eq(_mbsbtype(mbstring, 8), _MBC_ILLEGAL, int, "%d");

    expect_eq(_mbsbtype(mbsonlylead, 0), _MBC_LEAD, int, "%d");
    expect_eq(_mbsbtype(mbsonlylead, 1), _MBC_ILLEGAL, int, "%d");
    expect_eq(_mbsbtype(mbsonlylead, 2), _MBC_ILLEGAL, int, "%d");
    expect_eq(_mbsbtype(mbsonlylead, 3), _MBC_ILLEGAL, int, "%d");
    expect_eq(_mbsbtype(mbsonlylead, 4), _MBC_ILLEGAL, int, "%d");
    expect_eq(_mbsbtype(mbsonlylead, 5), _MBC_ILLEGAL, int, "%d");

    /* _mbsnextc */
    expect_eq(_mbsnextc(mbstring), 0xb0b1, int, "%x");
    expect_eq(_mbsnextc(&mbstring[2]), 0xb220, int, "%x");  /* lead + invalid tail */
    expect_eq(_mbsnextc(&mbstring[3]), 0x20, int, "%x");    /* single char */

    /* _mbclen/_mbslen */
    expect_eq(_mbclen(mbstring), 2, int, "%d");
    expect_eq(_mbclen(&mbstring[2]), 2, int, "%d");
    expect_eq(_mbclen(&mbstring[3]), 1, int, "%d");
    expect_eq(_mbslen(mbstring2), 4, int, "%d");
    expect_eq(_mbslen(mbsonlylead), 0, int, "%d");          /* lead + NUL not counted as character */
    expect_eq(_mbslen(mbstring), 4, int, "%d");             /* lead + invalid trail counted */

    /* _mbccpy/_mbsncpy */
    memset(buf, 0xff, sizeof(buf));
    _mbccpy(buf, mbstring);
    expect_bin(buf, "\xb0\xb1\xff", 3);

    memset(buf, 0xff, sizeof(buf));
    _mbsncpy(buf, mbstring, 1);
    expect_bin(buf, "\xb0\xb1\xff", 3);
    memset(buf, 0xff, sizeof(buf));
    _mbsncpy(buf, mbstring, 2);
    expect_bin(buf, "\xb0\xb1\xb2 \xff", 5);
    memset(buf, 0xff, sizeof(buf));
    _mbsncpy(buf, mbstring, 3);
    expect_bin(buf, "\xb0\xb1\xb2 \xb3\xb4\xff", 7);
    memset(buf, 0xff, sizeof(buf));
    _mbsncpy(buf, mbstring, 4);
    expect_bin(buf, "\xb0\xb1\xb2 \xb3\xb4 \xff", 8);
    memset(buf, 0xff, sizeof(buf));
    _mbsncpy(buf, mbstring, 5);
    expect_bin(buf, "\xb0\xb1\xb2 \xb3\xb4 \0\0\xff", 10);
    memset(buf, 0xff, sizeof(buf));
    _mbsncpy(buf, mbsonlylead, 6);
    expect_bin(buf, "\0\0\0\0\0\0\0\xff", 8);

    memset(buf, 0xff, sizeof(buf));
    _mbsnbcpy(buf, mbstring2, 2);
    expect_bin(buf, "\xb0\xb1\xff", 3);
    _mbsnbcpy(buf, mbstring2, 3);
    expect_bin(buf, "\xb0\xb1\0\xff", 4);
    _mbsnbcpy(buf, mbstring2, 4);
    expect_bin(buf, "\xb0\xb1\xb2\xb3\xff", 5);
    memset(buf, 0xff, sizeof(buf));
    _mbsnbcpy(buf, mbsonlylead, 5);
    expect_bin(buf, "\0\0\0\0\0\xff", 6);

    /* _mbsinc/mbsdec */
    step = _mbsinc(mbstring) - mbstring;
    ok(step == 2, "_mbsinc adds %d (exp. 2)\n", step);
    step = _mbsinc(&mbstring[2]) - &mbstring[2];  /* lead + invalid tail */
    ok(step == 2, "_mbsinc adds %d (exp. 2)\n", step);

    step = _mbsninc(mbsonlylead, 1) - mbsonlylead;
    ok(step == 0, "_mbsninc adds %d (exp. 0)\n", step);
    step = _mbsninc(mbsonlylead, 2) - mbsonlylead;  /* lead + NUL byte + lead + char */
    ok(step == 0, "_mbsninc adds %d (exp. 0)\n", step);
    step = _mbsninc(mbstring2, 0) - mbstring2;
    ok(step == 0, "_mbsninc adds %d (exp. 2)\n", step);
    step = _mbsninc(mbstring2, 1) - mbstring2;
    ok(step == 2, "_mbsninc adds %d (exp. 2)\n", step);
    step = _mbsninc(mbstring2, 2) - mbstring2;
    ok(step == 4, "_mbsninc adds %d (exp. 4)\n", step);
    step = _mbsninc(mbstring2, 3) - mbstring2;
    ok(step == 5, "_mbsninc adds %d (exp. 5)\n", step);
    step = _mbsninc(mbstring2, 4) - mbstring2;
    ok(step == 7, "_mbsninc adds %d (exp. 7)\n", step);
    step = _mbsninc(mbstring2, 5) - mbstring2;
    ok(step == 7, "_mbsninc adds %d (exp. 7)\n", step);
    step = _mbsninc(mbstring2, 17) - mbstring2;
    ok(step == 7, "_mbsninc adds %d (exp. 7)\n", step);

    /* functions that depend on locale codepage, not mbcp.
     * we hope the current locale to be SBCS because setlocale(LC_ALL, ".1252") seems not to work yet
     * (as of Wine 0.9.43)
     */
    if (*p__mb_cur_max == 1)
    {
        expect_eq(mblen((char *)mbstring, 3), 1, int, "%x");
        expect_eq(_mbstrlen((char *)mbstring2), 7, int, "%d");
    }