コード例 #1
0
ファイル: Naga.cpp プロジェクト: Arc0re/lithtech
// ----------------------------------------------------------------------- //
// ROUTINE		: Naga::MC_Extra
// DESCRIPTION	: Create or remove (and fire) the spike
// RETURN TYPE	: void 
// ----------------------------------------------------------------------- //
void Naga::MC_Extra(const char *lpszParam)
{
	if (m_bAnimating && lpszParam) 
	{
		DDWORD dwFlags;

		if (_mbsicmp((const unsigned char*)lpszParam,(const unsigned char*)"take_spike") == 0)
		{
			// Make the spike visible
			dwFlags = m_pServerDE->GetObjectFlags(m_hSpike);
			dwFlags |= FLAG_VISIBLE;
			m_pServerDE->SetObjectFlags(m_hSpike, dwFlags);
		}

		if (_mbsicmp((const unsigned char*)lpszParam,(const unsigned char*)"fire_spike") == 0)
		{
			// Hide the hand-spike...
			dwFlags = m_pServerDE->GetObjectFlags(m_hSpike);
			dwFlags &= ~FLAG_VISIBLE;
			m_pServerDE->SetObjectFlags(m_hSpike, dwFlags);

			// ...and fire the spike weapon.
			Fire();
		}
	}
}
コード例 #2
0
ファイル: Rotating.cpp プロジェクト: Arc0re/lithtech
void Rotating::HandleTrigger(HOBJECT hSender, HSTRING hMsg)
{
	CServerDE* pServerDE = BaseClass::GetServerDE();
	if (!pServerDE) return;

	char* pMsg = pServerDE->GetStringData(hMsg);
	if (!pMsg || !pMsg[0]) return;

	if (m_eState == RWM_OFF && _mbsicmp((const unsigned char*)pMsg, (const unsigned char*)TRIGGER_MSG_ON) == 0)
	{
		SetSpinUp();
		pServerDE->SetNextUpdate(m_hObject, RWM_UPDATE_DELTA);
	}
	else if (m_eState != RWM_OFF && _mbsicmp((const unsigned char*)pMsg, (const unsigned char*)TRIGGER_MSG_OFF) == 0)
	{
		SetSpinDown();
		pServerDE->SetNextUpdate(m_hObject, RWM_UPDATE_DELTA);
	}
	else if (_mbsicmp((const unsigned char*)pMsg, (const unsigned char*)TRIGGER_MSG_TOGGLE) == 0)
	{
		if (m_eState == RWM_OFF)
			SetSpinUp();
		else
			SetSpinDown();
		pServerDE->SetNextUpdate(m_hObject, RWM_UPDATE_DELTA);
	}
}
コード例 #3
0
ファイル: dirent.c プロジェクト: somian/fileutil-ls
unsigned long _MapMode(struct cache_entry *ce)
{
	DWORD dwAttribs;
	unsigned long m;
	char *sz;

	dwAttribs = ce->dwFileAttributes;

	if (dwAttribs & (FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM)) {
		m = 0444;  // -r--r--r--
	} else {
		m = 0666;  // -rw-rw-rw-
	}

	if (dwAttribs & FILE_ATTRIBUTE_DIRECTORY) {
		m &= ~S_IFMT; m |= S_IFDIR;
		m |= 0111;
	} else if (dwAttribs & FILE_ATTRIBUTE_DEVICE) {
		m &= ~S_IFMT; m |= S_IFCHR;
	} else {
		m &= ~S_IFMT; m |= S_IFREG; // regular file
	}

	if (ce->ce_bIsSymlink) {
		m &= ~S_IFMT; m |= S_IFLNK; // symbolic link
	}

	if (dwAttribs & FILE_ATTRIBUTE_COMPRESSED) {
		m |= S_COMPR; // compressed
	}
	if (dwAttribs & FILE_ATTRIBUTE_STREAMS) { // pseudo-attrib
		//
		// The file has child streams (or is a stream)
		//
		m |= S_STREAM;
	}

	if ((sz = strrchr(ce->ce_filename, '.')) != NULL) {
		//
		// Heuristic: Assume executable if these types.
		//
		if (_mbsicmp(sz, ".exe") == 0 || _mbsicmp(sz, ".com") == 0 ||
			_mbsicmp(sz, ".bat") == 0 || _mbsicmp(sz, ".cmd") == 0) {
				m |= 0111;  // ---x--x--x-
		}
	}
	
	return m;
}
コード例 #4
0
void VolumeBrush::HandleTrigger(HOBJECT hSender, HSTRING hMsg)
{
    CServerDE* pServerDE = GetServerDE();
    if (!pServerDE) return;

    char* pMsg = pServerDE->GetStringData(hMsg);
    if (!pMsg || !pMsg[0]) return;

    DBOOL bToggle = DFALSE;

    if (_mbsicmp((const unsigned char*)pMsg, (const unsigned char*)TRIGGER_MSG_TOGGLE) == 0)
    {
        bToggle = DTRUE;
    }

    if ((bToggle && m_bHidden) || _mbsicmp((const unsigned char*)pMsg, (const unsigned char*)TRIGGER_MSG_ON) == 0)
    {
        DDWORD dwFlags;
        pServerDE->SetObjectFlags(m_hObject, m_dwSaveFlags);

        dwFlags = pServerDE->GetObjectUserFlags(m_hObject);
        pServerDE->SetObjectUserFlags(m_hObject, dwFlags | USRFLG_VISIBLE);

        if (m_hSurfaceObj)
        {
            dwFlags = pServerDE->GetObjectUserFlags(m_hSurfaceObj);
            pServerDE->SetObjectUserFlags(m_hSurfaceObj, dwFlags | USRFLG_VISIBLE);
        }

        m_bHidden = DFALSE;
    }
    else if ((bToggle && !m_bHidden) || _mbsicmp((const unsigned char*)pMsg, (const unsigned char*)TRIGGER_MSG_OFF) == 0)
    {
        DDWORD dwFlags;
        pServerDE->SetObjectFlags(m_hObject, m_dwSaveFlags & ~FLAG_VISIBLE);

        dwFlags = pServerDE->GetObjectUserFlags(m_hObject);
        pServerDE->SetObjectUserFlags(m_hObject, dwFlags & ~USRFLG_VISIBLE);

        if (m_hSurfaceObj)
        {
            dwFlags = pServerDE->GetObjectUserFlags(m_hSurfaceObj);
            pServerDE->SetObjectUserFlags(m_hSurfaceObj, dwFlags & ~USRFLG_VISIBLE);
        }

        m_bHidden = DTRUE;
    }
}
コード例 #5
0
ファイル: FlagObjects.cpp プロジェクト: Arc0re/lithtech
DDWORD FlagObject::ObjectMessageFn(HOBJECT hSender, DDWORD messageID, HMESSAGEREAD hRead)
{
	switch (messageID)
	{
		case MID_TRIGGER:
		{
			// Get the trigger name...

			HSTRING hMsg = g_pServerDE->ReadFromMessageHString(hRead);
			if (hMsg)
			{
				char* sMsg = g_pServerDE->GetStringData(hMsg);
				if (sMsg)
				{
					// Check if we should return to the flag stand...

					if (_mbsicmp((const unsigned char*)sMsg, (const unsigned char*)"return") == 0)
					{
						ReturnToFlagStand();
					}
				}

				g_pServerDE->FreeString(hMsg);
			}

			break;
		}

		default: break;
	}

	return B2BaseClass::ObjectMessageFn(hSender, messageID, hRead);
}
コード例 #6
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);
		}
	}
}
コード例 #7
0
//////////////////////////////////////////////////////////////////////
// Function name	: CInterfaceResMgr::Init
// Description	    :
// Return type      : LTBOOL
// Argument         : ILTClient* pClientDE
// Argument         : CGameClientShell* pClientShell
//////////////////////////////////////////////////////////////////////
LTBOOL CInterfaceResMgr::Init(ILTClient* pClientDE, CGameClientShell* pClientShell)
{
	if (!pClientDE)
	{
        return LTFALSE;
	}

    HSTRING hString;

	// Set the English flag
    hString = g_pLTClient->FormatString(IDS_GAME_LANGUAGE);
    if (hString && _mbsicmp((const unsigned char*)"english", (const unsigned char*)g_pLTClient->GetStringData(hString)) != 0)
    {
        m_bEnglish=LTFALSE;
	}
	else
    {
        m_bEnglish=LTTRUE;
	}
    g_pLTClient->FreeString(hString);
    hString=LTNULL;

	// Load the virtual key codes for yes responses
    hString=g_pLTClient->FormatString(IDS_MENU_VKEY_YES);
	if (hString)
	{
        m_nYesVKeyCode=atoi(g_pLTClient->GetStringData(hString));
        g_pLTClient->FreeString(hString);
        hString=LTNULL;
	}

	// Load the virtual key codes for no responses
    hString=g_pLTClient->FormatString(IDS_MENU_VKEY_NO);
	if (hString)
	{
        m_nNoVKeyCode=atoi(g_pLTClient->GetStringData(hString));
        g_pLTClient->FreeString(hString);
        hString=LTNULL;
	}

	// Init the InterfaceSurfMgr class
    m_InterfaceSurfMgr.Init(g_pLTClient);

	// set resolution dependant variables
	ScreenDimsChanged();


	// Initialize the fonts
    if (!InitFonts())
	{
        return LTFALSE;
	}

    return LTTRUE;
}
コード例 #8
0
ファイル: dirent.c プロジェクト: somian/fileutil-ls
static BOOL
_match_dir(struct cache_dir *cd, BOOL bFile, 
	LPCSTR szPath, LPCSTR szPat)
{
	if (_mbsicmp(cd->cd_dirname, szPath) == 0) {
		if (!bFile) {
			//
			// Matching against another pattern - must be exact match
			//
			if (_mbsicmp(szPat, cd->cd_pat) == 0) {
				return TRUE;
			}
		} else if (_DosPatternMatch(cd->cd_pat, szPat/*file*/)) {
			//
			// Matching against a file name - use pattern match
			//
			return TRUE;
		}
	}
	return FALSE;
}
コード例 #9
0
// Returns TRUE if two renderers are the same
LTBOOL CFolderDisplay::IsRendererEqual(RMode *pRenderer1, RMode *pRenderer2)
{
	_ASSERT(pRenderer1);
	_ASSERT(pRenderer2);

	if (_mbsicmp((const unsigned char*)pRenderer1->m_RenderDLL, (const unsigned char*)pRenderer2->m_RenderDLL) != 0)
	{
        return LTFALSE;
	}

	if (_mbsicmp((const unsigned char*)pRenderer1->m_InternalName, (const unsigned char*)pRenderer2->m_InternalName) != 0)
	{
        return LTFALSE;
	}

	if (_mbsicmp((const unsigned char*)pRenderer1->m_Description, (const unsigned char*)pRenderer2->m_Description) != 0)
	{
        return LTFALSE;
	}

	if (pRenderer1->m_Width != pRenderer2->m_Width)
	{
        return LTFALSE;
	}

	if (pRenderer1->m_Height != pRenderer2->m_Height)
	{
        return LTFALSE;
	}

	if (pRenderer1->m_BitDepth != pRenderer2->m_BitDepth)
	{
        return LTFALSE;
	}

    return LTTRUE;
}
コード例 #10
0
ファイル: MenuDisplay.cpp プロジェクト: bsmr-games/Blood2
// Returns TRUE if two renderers are the same
DBOOL CMenuDisplay::IsRendererEqual(RMode *pRenderer1, RMode *pRenderer2)
{
	assert(pRenderer1);
	assert(pRenderer2);

	if (_mbsicmp((const unsigned char*)pRenderer1->m_RenderDLL, (const unsigned char*)pRenderer2->m_RenderDLL) != 0)
	{
		return DFALSE;
	}
	
	if (_mbsicmp((const unsigned char*)pRenderer1->m_InternalName, (const unsigned char*)pRenderer2->m_InternalName) != 0)
	{
		return DFALSE;
	}
	
	if (_mbsicmp((const unsigned char*)pRenderer1->m_Description, (const unsigned char*)pRenderer2->m_Description) != 0)
	{
		return DFALSE;
	}
	
	if (pRenderer1->m_Width != pRenderer2->m_Width)
	{
		return DFALSE;
	}

	if (pRenderer1->m_Height != pRenderer2->m_Height)
	{
		return DFALSE;
	}

	if (pRenderer1->m_BitDepth != pRenderer2->m_BitDepth)
	{
		return DFALSE;
	}

	return DTRUE;
}
コード例 #11
0
ファイル: MenuDisplay.cpp プロジェクト: bsmr-games/Blood2
// Returns an index into m_rendererArray for this renderer.
// -1 is returned if it cannot be found
int CMenuDisplay::GetRendererIndex(RMode *pMode)
{
	assert(pMode);
	if (!pMode)
	{
		return -1;
	}

	// Find out if this renderer already exists in the array
	int nRenderIndex=-1;

	unsigned int i;
	for (i=0; i < m_rendererArray.GetSize(); i++)
	{
		if (_mbsicmp((const unsigned char*)m_rendererArray[i].m_description, (const unsigned char*)pMode->m_Description) == 0 &&
			_mbsicmp((const unsigned char*)m_rendererArray[i].m_renderDll, (const unsigned char*)pMode->m_RenderDLL) == 0)
		{
			nRenderIndex=i;
			break;
		}
	}

	return nRenderIndex;
}
コード例 #12
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);
}
コード例 #13
0
ファイル: MenuBase.cpp プロジェクト: bsmr-games/Blood2
// Sorts a file list.  This was taken from the old menu code.
FileEntry* CMenuBase::SortFileList(FileEntry *pfe)
{

	FileEntry	*pfindex;
	FileEntry	*pfList[MAX_FILE_LIST];
	int nCount=0;


	// Build an array of FileEntries.
	pfindex = pfe;
	while (pfindex && nCount < MAX_FILE_LIST)
	{
		pfList[nCount++] = pfindex;
		pfindex = pfindex->m_pNext;
	}
	if (pfindex) // Free any remaining items
	{
		m_pClientDE->FreeFileList(pfindex);
	}

	for (int i = nCount / 2; i > 0; i = (i == 2) ? 1 : (int) (i / 2.2))
	{
		for (int j = i; j < nCount; j++)
		{
			FileEntry *pfTemp = pfList[j];
			
			for (int k = j; k >= i && _mbsicmp((const unsigned char*)pfTemp->m_pBaseFilename, (const unsigned char*)pfList[k - i]->m_pBaseFilename) < 0; k -= i)
			{
				pfList[k] = pfList[k - i];
			}

			pfList[k] = pfTemp;
		}
	}

	pfindex = pfList[0];
	for (i=1; i < nCount-1; i++)
	{
		pfindex->m_pNext = pfList[i];
		pfindex = pfindex->m_pNext;
	}
	pfindex->m_pNext = DNULL;

	return pfList[0];
}
コード例 #14
0
ファイル: MBSICOLL.C プロジェクト: ngphloc/agmagic
int __cdecl _mbsicoll(
    const unsigned char *s1,
    const unsigned char *s2
    )
{
#if !defined (_WIN32)
        return _mbsicmp(s1, s2);
#else  /* !defined (_WIN32) */
        int ret;

        if (0 == (ret = __crtCompareStringA(__mblcid, NORM_IGNORECASE,
                s1, -1, s2, -1, __mbcodepage)))
            return _NLSCMPERROR;

        return ret - 2;

#endif  /* !defined (_WIN32) */
}
コード例 #15
0
ファイル: Destructable.cpp プロジェクト: bsmr-games/Blood2
void CDestructable::HandleTrigger(HOBJECT hSender, HMESSAGEREAD hRead)
{
	CServerDE* pServerDE = BaseClass::GetServerDE();
	if (!pServerDE) return;

	HSTRING hMsg = pServerDE->ReadFromMessageHString(hRead);

	char* pMsg = pServerDE->GetStringData(hMsg);
	if (!pMsg || !pMsg[0]) return;

	if (_mbsicmp((const unsigned char*)pMsg, (const unsigned char*)TRIGGER_MSG_KILL) == 0)
	{
		DVector vTmp;
		VEC_INIT(vTmp);
		BaseClass *ffObj = pServerDE->HandleToObject(hSender);
		DamageObject(hSender, ffObj, m_hObject, 1, vTmp, vTmp, DAMAGE_TYPE_DEATH);
	}
	pServerDE->FreeString(hMsg);
}
コード例 #16
0
ファイル: Registry.cpp プロジェクト: somian/fileutil-ls
static BOOL
_PrepReg(const char *szPath, struct find_reg *fr, DWORD dwType)
{
	char szBuf[FILENAME_MAX];
	LPSTR sz, szRoot, szKey=NULL;
	DWORD dwLen;

	if (szPath == NULL || szPath[0] != '\\') {
		SetLastError(ERROR_INVALID_PARAMETER);
		return FALSE;
	}

	//
	// "\*"
	// "\hklm\foo\*"
	// "\hklm\foo\baz", Use dwType to determine
	//
	if (_mbsicmp((PCUSTR)szPath, (PCUSTR)"\\*") == 0) { // "\*"
		fr->fr_bRootKeys = TRUE;
		return TRUE;
	}
	if (szPath[1] == '\0') { // "\"
		fr->fr_bRootKeys = TRUE;
		fr->fr_bEof = TRUE; // singleton
		return TRUE;
	}

	dwLen = strlen(szPath);
	if (dwLen >= FILENAME_MAX) {
		SetLastError(ERROR_BUFFER_OVERFLOW);
		return FALSE;
	}

	lstrcpyn(szBuf, szPath, FILENAME_MAX);

	if (szPath[dwLen-2] == '\\' && szPath[dwLen-1] == '*') { // "\foo\*"
		//
		// Truncate to "\foo"
		//
		szBuf[dwLen-2] = '\0';
		dwLen -= 2;
	} else if (szPath[dwLen-2] == '\\' && szPath[dwLen-1] == '.') { // "\foo\."
		//
		// Truncate to "\foo", singleton
		//
		szBuf[dwLen-2] = '\0';
		dwLen -= 2;
		fr->fr_bEof = TRUE; // singleton
	} else {
		fr->fr_bEof = TRUE; // singleton
	}

	szRoot = szBuf+1;
	if ((sz = (char*)_mbschr((PCUSTR)szRoot, '\\')) != NULL) {
		*sz = '\0';
		szKey = sz+1;
	}

	if (_mbsicmp((PCUSTR)szRoot, (PCUSTR)"HKLM") == 0) {
		fr->fr_hRoot = HKEY_LOCAL_MACHINE;
	} else if (_mbsicmp((PCUSTR)szRoot, (PCUSTR)"HKEY_LOCAL_MACHINE") == 0) {
		fr->fr_hRoot = HKEY_LOCAL_MACHINE;
	} else if (_mbsicmp((PCUSTR)szRoot, (PCUSTR)"HKCU") == 0) {
		fr->fr_hRoot = HKEY_CURRENT_USER;
	} else if (_mbsicmp((PCUSTR)szRoot, (PCUSTR)"HKEY_CURRENT_USER") == 0) {
		fr->fr_hRoot = HKEY_CURRENT_USER;
	} else if (_mbsicmp((PCUSTR)szRoot, (PCUSTR)"HKU") == 0) {
		fr->fr_hRoot = HKEY_USERS;
	} else if (_mbsicmp((PCUSTR)szRoot, (PCUSTR)"HKEY_USERS") == 0) {
		fr->fr_hRoot = HKEY_USERS;
	} else if (_mbsicmp((PCUSTR)szRoot, (PCUSTR)"HKCR") == 0) {
		fr->fr_hRoot = HKEY_CLASSES_ROOT;
	} else if (_mbsicmp((PCUSTR)szRoot, (PCUSTR)"HKEY_CLASSES_ROOT") == 0) {
		fr->fr_hRoot = HKEY_CLASSES_ROOT;
	} else {
		SetLastError(ERROR_PATH_NOT_FOUND);
		return FALSE;
	}
	strcpy(fr->fr_fd.name, szRoot);

	if (dwType == DT_REG) { // path is to a value, not a key
		fr->fr_bEof = TRUE; // singleton
		if ((sz = (LPSTR)strrchr((PCUSTR)szKey, '\\')) == NULL) {
			// Single value, no key
			fr->fr_szValue = xstrdup(szKey);
		} else {
			*sz = '\0'; 
			fr->fr_szKey = xstrdup(szKey);
			fr->fr_szValue = xstrdup(sz+1);
		}
		return TRUE;
	}
	if (szKey) {
		fr->fr_szKey = xstrdup(szKey);
	}
	return TRUE;
}
コード例 #17
0
ファイル: Streams.c プロジェクト: somian/fileutil-ls
//
// We do the actual digging into NTFS here
//
static BOOL
_LookupStream(BOOL bFirst,
	struct find_stream *fs, 
	char *szStreamMatch,
	struct _finddatai64_t *pfd)
{
	char szBuf[FILENAME_MAX*2];
	char *sz;
	HANDLE hFile;
#ifdef QUERY_EXTENDED_ATTRIBUTES
	PFILE_EA_INFORMATION pEaInfo = (PFILE_EA_INFORMATION) abEaInfo;
	//PFILE_FULL_EA_INFORMATION pFullEaInfo = (PFILE_FULL_EA_INFORMATION) abEaInfo;
#endif
	PFILE_STREAM_INFORMATION pStreamInfo = (PFILE_STREAM_INFORMATION) abStreamInfo;
	NTSTATUS Status;
	IO_STATUS_BLOCK IoStatus;
	struct stream_info *si, **psiPrev;

	if (fs->fs_next_stream_info != NULL) {
		goto next_si_entry;
	}

next_fs_entry:

	if (!bFirst) { // if _xfindnexti64()
		//
		// Get next file in list
		//
		if (_aefindnexti64(fs->fs_handle, pfd) < 0) {
			if (GetLastError() == ERROR_NO_MORE_FILES) {
				fs->fs_bEof = TRUE;
			}
			return FALSE; // splat
		}
	}

	//
	// pfd is loaded with real file data at this point
	//

	fs->fs_fd = *pfd; // get main file info - struct copy

	if ((pfd->attrib & (FILE_ATTRIBUTE_DEVICE|FILE_ATTRIBUTE_REPARSE_POINT)) != 0) {
		return TRUE; // no streams for devices or reparse-points
	}

	if (!DynaLoad("NTDLL.DLL", "NtQueryInformationFile", &pfnNtQueryInformationFile)) {
		goto done;
	}
	
#ifdef UNDEFINED
	if (!DynaLoad("NTDLL.DLL", "NtSetInformationFile", &pfnNtSetInformationFile)) {
		goto done;
	}
#endif

	//
	// Build path from fs->fs_szStrippedPath minus rightmost chunk
	// + '\\' + pfd->name
	//
	lstrcpyn(szBuf, fs->fs_szStrippedPath, FILENAME_MAX);
	if ((sz = strrchr(szBuf, '\\')) == NULL) {
		lstrcpyn(szBuf, pfd->name, FILENAME_MAX); // should never happen
	} else {
		lstrcpyn(sz+1, pfd->name, FILENAME_MAX);
	}

	//
	// Open the file with Backup semantics.
	//
	// UNDOCUMENTED: CreateFile does *not* require the
	// SeBackupPrivilege if the mode flags are 0!
	//
	// In all other cases FILE_FLAG_BACKUP_SEMANTICS requires
	// the SeBackupPrivilege.
	//
	if ((hFile = CreateFile(szBuf,
				0, // required - undocumented
				FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
				OPEN_EXISTING,
				FILE_FLAG_BACKUP_SEMANTICS, 0)) == INVALID_HANDLE_VALUE) {
		goto done;
	}

#ifdef QUERY_EXTENDED_ATTRIBUTES
	//
	// First query for Extended Attributes
	//
	Status = (*pfnNtQueryInformationFile)(hFile, &IoStatus, pEaInfo,
		EA_BUFSIZE, FileEaInformation/*7*/);

	if (NT_SUCCESS(Status) && pEaInfo->EaInformationLength != 0) {
		//
		// File has Extended Attributes
		//
		fd.Attribs |= FILE_ATTRIBUTE_EA;
	}
#endif

	//
	// Now query for streams
	//
	Status = (*pfnNtQueryInformationFile)(hFile, &IoStatus, pStreamInfo,
		STREAM_BUFSIZE, FileStreamInformation/*22*/);

	if (!NT_SUCCESS(Status)) {
		CloseHandle(hFile);
		MapNtStatusToWin32Error(Status);
		goto done;
	}

	if (IoStatus.Information == 0) { // pending??
		CloseHandle(hFile);
		SetLastError(ERROR_IO_PENDING); // should never happen
		goto done;
	}

	CloseHandle(hFile);

	//
	// BUG: We cannot enumerate streams for "." because it looks too
	// much like a drive letter (".:foo").  
	//
	// It triggers bugs in FILESYSTEM_PREFIX_LEN, glob.c, basename.c,
	// and many other places that check for szPath[1] == ':'.
	//
	if (strcmp(pfd->name, ".") == 0) {
		//
		// Indicate that dot has streams
		//
		pfd->attrib |= FILE_ATTRIBUTE_STREAMS;
		//
		// But do not enumerate them
		//
		goto done;
	}

	psiPrev = &fs->fs_list_stream_info;
	*psiPrev = NULL;

	for (;;) {
		char szPath[FILENAME_MAX];

		memset(szPath, 0, FILENAME_MAX); // required!

		//
		// Convert from wchar_t to multibyte string
		//
		if (!WideCharToMultiByte(get_codepage(), 0,
				pStreamInfo->StreamName,
				pStreamInfo->StreamNameLength / sizeof(WCHAR),
				szPath, FILENAME_MAX, NULL, NULL)) {
			break; // rare, ignore
		}

		if (stricmp(szPath, "::$DATA") != 0) { // skip default data stream
			//
			// Create a new stream_info obj
			//
			si = (struct stream_info *)xmalloc(sizeof(*si));
			memset(si, 0, sizeof(*si));
			si->si_szName = xstrdup(szPath);
			si->si_size = pStreamInfo->EndOfStream.QuadPart;
			si->si_phys_size = pStreamInfo->AllocationSize.QuadPart;

			// append to list
			*psiPrev = si; psiPrev = &si->si_next;
		}

		//
		// Bump to next FILE_STREAM_INFORMATION struct
		//
		if (pStreamInfo->NextEntryOffset == 0) { // end of chain
			*psiPrev = NULL;
			break;
		}
		pStreamInfo = (PFILE_STREAM_INFORMATION)
			(((char *)pStreamInfo) + pStreamInfo->NextEntryOffset);
	}

	// rewind to start
	fs->fs_next_stream_info = fs->fs_list_stream_info;

	if (fs->fs_list_stream_info != NULL) {
		//
		// Mark the file as having streams
		//
		pfd->attrib |= FILE_ATTRIBUTE_STREAMS;
		fs->fs_fd.attrib |= FILE_ATTRIBUTE_STREAMS; // mark children too
	}

	if (szStreamMatch == NULL) { // if want main file info
		return TRUE; // return of main file info
	}

	// fall through and return a matching stream

next_si_entry:
	
	if (fs->fs_next_stream_info == NULL) {
		goto next_fs_entry;
	}

	// pop next si entry
	si = fs->fs_next_stream_info;
	fs->fs_next_stream_info = si->si_next;

	*pfd = fs->fs_fd; // get main file info - struct copy

	//
	// Turn off the directory attribute - a stream is not a directory
	// (although a directory can have streams)
	//
	pfd->attrib &= ~FILE_ATTRIBUTE_DIRECTORY;

	//
	// See if stream does not match pattern
	//
	// Only match on direct match or '*'
	//
	if (szStreamMatch != NULL && 
		((szStreamMatch[0] != ':' || szStreamMatch[1] != '*' || szStreamMatch[2] != '\0') &&
			_mbsicmp(szStreamMatch, si->si_szName) != 0)) {
		// stream does not match pattern
		goto next_si_entry;
	}

	if (strlen(pfd->name) + strlen(si->si_szName) + 1 > sizeof(pfd->name)) {
		SetLastError(ERROR_BUFFER_OVERFLOW);
		goto done;
	}

	strcat(pfd->name, si->si_szName); // concat ":stream"

	if (phys_size) {
		pfd->size = si->si_phys_size;
	} else {
		pfd->size = si->si_size;
	}
	
done:
	return TRUE; // return of stream info (or main file info)
}
コード例 #18
0
ファイル: dirent.c プロジェクト: somian/fileutil-ls
//
// Opendir with wildcard pattern, for network speedup
//
// Called by glob.c
//
static DIR* 
__opendir_with_pat(const char* szPath, const char* szPat, BOOL bCache)
{
	char szBuf[FILENAME_MAX];
	char szFullDirPath[FILENAME_MAX];
	char szPatBuf[FILENAME_MAX+10];
	char* sz;
	struct cache_dir *cd;
	struct cache_entry *ce;
	DIR* pDir;
	long hFind;
	struct _finddatai64_t fd;
	BOOL bShowStreams = (show_streams == yes_arg);
	BOOL bFixedDisk = FALSE;
	BOOL bGetFullFileInfoOk = TRUE;

	//
	// Delete the previous non-cached dir, if any
	//
	if (_dir_nocache != NULL) {
		_delete_dir(_dir_nocache);
		_dir_nocache = NULL;
	}

	lstrcpyn(szBuf, szPath, sizeof(szBuf));
	//
	// Change forward slashes to backward slashes
	//
	for (sz = szBuf; *sz; ++sz) {
		if (*sz == '/') {
			*sz = '\\';
		}
	}
	//
	// Strip trailing backslashes
	//
	for (--sz; sz > szBuf; --sz) {
		if (*sz != '\\') {
			break;
		}
		if (sz == szBuf+2 && szBuf[1] == ':') {
			break; // stop if C:\  
		}
		*sz = '\0';
	}

	if (!gbReg) {
		//
		// See if the pattern contains any UNIX-style glob chars
		// other than *?
		//
		// Note that '!' is legal in an NTFS file name.
		//
		// Note that all glob chars are legal in registry names.
		//
		if (_mbspbrk(szPat, "[]+@") != NULL) {
			szPat = "*"; // punt
		}
	}

	//
	// Return cached dir if available
	//
	if ((cd = _find_cache_dir(szBuf, szPat)) != NULL) {
		pDir = xmalloc(sizeof(DIR));
		memset(pDir, 0, sizeof(pDir));
		pDir->dd_cd = cd;
		pDir->dd_next_entry = cd->cd_entry_first;
		return pDir;
	}

	//
	// Get the absolute path of the directory for FindFirst
	//
	if (_GetAbsolutePath(szBuf, szFullDirPath, FILENAME_MAX, &bFixedDisk) < 0) {
		return NULL;
	}

	//
	// Do not show streams if --fast on a non-fixed disk
	//
	if (run_fast && !bFixedDisk) {
		bShowStreams = FALSE;
	}

	//
	// See if the resulting path is too long
	//
	if (strlen(szBuf) + strlen(szPat) + 2 > sizeof(szBuf)) {
		errno = ENAMETOOLONG;
		return NULL;
	}

	//
	// Create a new directory node
	//
	cd = (struct cache_dir *)xmalloc(sizeof(struct cache_dir));
	memset(cd, 0, sizeof(*cd));
	cd->cd_dirname = xstrdup(szBuf); // *not* abs path - must match for caching
	cd->cd_pat = xstrdup(szPat);

	//
	// Append search pattern for FindFirstFile.
	// Use absolute path to make sure it works w/UNC
	//
	strcpy(szPatBuf, szFullDirPath);
	if (*right(szPatBuf, 1) != '\\') { // if not already
		strcat(szPatBuf, "\\");
	}
	strcat(szPatBuf, szPat);

#ifdef UNDEFINED
	//
	// BUG: FindFirst("\\server\share") fails!  Must append
	// a backslash, "\\server\share\"
	// 
	if (_IsServerRootPath(szPatBuf)) {
		sz = szPatBuf + strlen(szPatBuf) - 1;
		if (*sz != '\\') {
			*++sz = '\\';
			*++sz = '\0';
		}
	}
#endif

#ifdef _DEBUG
#define DEBUG_FINDFIRST
#endif
#ifdef DEBUG_FINDFIRST
more_printf("opendir: findfirst on \"%s\"\n", szPatBuf);
more_fflush(stdmore);
#endif

	//
	// Always guaranteed to return at least "." and "..", otherwise
	// not a directory or not found.
	//
	if ((hFind = _xfindfirsti64(szPatBuf, &fd, bShowStreams, DT_DIR))
			== (long)INVALID_HANDLE_VALUE) {
		MapWin32ErrorToPosixErrno();
		free(cd->cd_dirname);
		free(cd->cd_pat);
		free(cd);
		return NULL;
	}

	if (bCache) {
		//
		// Append new directory to the dir cache list
		//
		if (_dir_first == NULL) {
			_dir_first = _dir_last = cd;
		} else {
			_dir_last->cd_next = cd;
			_dir_last = cd;
		}
		_dir_nocache = NULL;
	} else {
		//
		// Save as non-cached
		//
		_dir_nocache = cd;
	}

	do {
		//
		// Append each file entry to the dir
		//
		ce = (struct cache_entry *)xmalloc(sizeof(*ce));
		memset(ce, 0, sizeof(*ce));
		if (cd->cd_entry_first == NULL) {
			cd->cd_entry_first = cd->cd_entry_last = ce;
		} else {
			cd->cd_entry_last->ce_next = ce;
			cd->cd_entry_last = ce;
		}
		ce->ce_filename = (char *)xstrdup(fd.name);
		ce->ce_size = fd.size;
		ce->ce_ino = 1; // requires GetFileInformationByHandle - uintmax_t
		ce->dwFileAttributes = fd.attrib; // FILE_ATTRIBUTE_NORMAL maps to 0
		ce->ce_atime = fd.time_access;
		ce->ce_mtime = fd.time_write;
		ce->ce_ctime = fd.time_create;
		ce->nNumberOfLinks = 1;

		if (bFixedDisk) {
			ce->dwFileAttributes |= FILE_ATTRIBUTE_FIXED_DISK;
		}

		// Flag reparse points and .LNK shortcuts as symbolic links
		if ((ce->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0 ||
				_mbsicmp(right(fd.name, 4), ".lnk") == 0) {
			ce->ce_bIsSymlink = TRUE;
		}

		//
		// If we are reparse point, or need full info,
		// or phys size, or short names, or ls -l
		//
		if ((ce->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0
				|| gbReg || !run_fast || bFixedDisk || print_inode
				|| phys_size || short_names) {
			char szBuf2[FILENAME_MAX], szBuf3[FILENAME_MAX];
			//
			// Build dir\file
			//
			if (strlen(szFullDirPath) + strlen(fd.name) + 2 < sizeof(szBuf2)) {
				strcpy(szBuf2, szFullDirPath); // directory path
				if (*right(szBuf2, 1) != '\\') { // if not already
					strcat(szBuf2, "\\");
				}
				strcat(szBuf2, fd.name);
				//
				// Get the absolute path
				//
				if (_GetAbsolutePath(szBuf2, szBuf3, FILENAME_MAX, NULL) >= 0) {
					//
					// Squirrel away our abs path for later lookup by security.cpp
					//
					ce->ce_abspath = xstrdup(szBuf3);

					if (gbReg && (ce->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
						// For registry keys we must test each regkey explicitly
						_follow_symlink(ce);
					}

					if ((!run_fast || bFixedDisk || print_inode) &&
							bGetFullFileInfoOk) {
						//
						// Get inode and hardlink info
						// (requires absolute path)
						//
						bGetFullFileInfoOk = (_get_full_file_info(szBuf3, ce) == 0);
					}
				}
				//
				// Get the physical size too if requested
				//
				if (phys_size) {
					ce->ce_size = _get_phys_size(szBuf2, ce->ce_size);
				}

				if (short_names) {
					//
					// Get the short path, then extract the rightmost 
					// component and stuff it into ce->ce_filename
					//
					_get_short_path(szBuf2);
					if ((sz = strrchr(szBuf2, '\\')) != NULL) {
						++sz;
						free(ce->ce_filename);
						ce->ce_filename = (char *)xstrdup(sz);
					}
				}

			}
		}
	} while (_xfindnexti64(hFind, &fd, bShowStreams) != -1);

	if (GetLastError() != ERROR_NO_MORE_FILES) { // network fail during walk
		DWORD dwError = GetLastError();
		_xfindclose(hFind, bShowStreams);
		SetLastError(dwError);
		MapWin32ErrorToPosixErrno();
		return NULL;
	}

	if (_xfindclose(hFind, bShowStreams) == -1) {
		MapWin32ErrorToPosixErrno();
		return NULL;
	}

	//
	// Build and return DIR
	//
	pDir = xmalloc(sizeof(DIR));
	memset(pDir, 0, sizeof(pDir));
	pDir->dd_cd = cd;
	pDir->dd_next_entry = cd->cd_entry_first;
	return pDir;
}
コード例 #19
0
// ---------------------------------------------------------------------
SInt32 WinMBCString::CompareNoCase(ConstAStr string) const
{
	return _mbsicmp(reinterpret_cast<const unsigned char*>(innerString.c_str()), reinterpret_cast<const unsigned char*>(string));
}
コード例 #20
0
ファイル: dirent.c プロジェクト: somian/fileutil-ls
//
// Return the symlink if followable, otherwise return the current
// node again
//
static struct cache_entry *
_follow_symlink(struct cache_entry *ce)
{
	char *sz, *szFullPath;
	char szPath[FILENAME_MAX+10];
	struct cache_entry *symce;
	long hFind;
	struct _finddatai64_t fd;
	BOOL bFixedDisk = FALSE;

	if (!gbReg && !ce->ce_bIsSymlink) {
		// not a symlink
		return ce;
	}

	if (ce->ce_symlink != NULL) {
		return ce->ce_symlink; // return whatever we got earlier
	}

	if (ce->ce_bBadSymlink) {
		//
		// Already tried and failed
		//
		return ce;
	}

	ce->ce_bBadSymlink = TRUE; // provisionally mark as bad

	if (ce->ce_abspath == NULL) { // if earlier _ExpandPath failed
		return ce; // bail
	}

	if (gbReg) {
		if ((sz = _GetRegistryLink(ce, szPath)) == NULL) {
			return ce; // bail
		}
	} else if ((ce->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
		//
		// Query the reparse point
		//
		if ((sz = _GetReparseTarget(ce, szPath)) == NULL) {
			return ce; // bail
		}
	} else {
		//
		// Query the .LNK shortcut
		//
		if ((sz = _GetShortcutTarget(ce, szPath)) == NULL) {
			return ce; // bail
		}
	}

	if (!gbReg && short_names) {
		_get_short_path(sz); // update in place
	}

	//
	// Build the symbolic link cache_entry
	//
	symce = (struct cache_entry *)xmalloc(sizeof(*symce));
	memset(symce, 0, sizeof(*symce));
	//
	// Store relative path for later readlink() (not just last component)
	//
	symce->ce_filename = (char *)xstrdup(sz);
	ce->ce_symlink = symce; // point to symlink
	ce->ce_bIsSymlink = TRUE;
	symce->ce_ino = 1; // requires GetFileInformationByHandle - uintmax_t
	symce->dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY; // we know this..
	symce->nNumberOfLinks = 1;

	//
	// Errors after this point are not very important.  At worst
	// we might lose st_mode, st_size and st_time info.
	//

	ce->ce_bBadSymlink = FALSE; // link is ok


	//
	// Get the absolute path
	//
	if (_GetAbsolutePath(symce->ce_filename, szPath, FILENAME_MAX, &bFixedDisk) < 0) {
		return symce; // bail
	}

	//
	// Squirrel away the absolute path for security.cpp
	//

	// BUG? should be symce->ce_abspath = xstrdup(szPath); ??
	ce->ce_abspath = xstrdup(szPath);

	if (gbReg) {
		return symce; // done 
	}

	szFullPath = szPath;

#ifdef DEBUG_FINDFIRST
more_printf("_follow_symlink: findfirst on \"%s\"\n", szFullPath);
more_fflush(stdmore);
#endif

	//
	// Do a singleton FindFirst to get WIN32_FILE_DATA
	//
	if ((hFind = _xfindfirsti64(szFullPath, &fd,
			FALSE/*bShowStreams*/, DT_UNKNOWN)) != (long)INVALID_HANDLE_VALUE) {
		// Suceeded
		if (_xfindclose(hFind, FALSE/*bShowStreams*/) == -1) {
			MapWin32ErrorToPosixErrno();
			return symce; // bail
		}
	} else {
		//
		// FindFirst failed.  This is a normal error (sic) for root folders
		// e.g., C:\ and sometimes \\server\share\
		//
		if ((szFullPath[1] == ':' && szFullPath[2] == '\\' && szFullPath[3] == '\0') ||
				_IsServerRootPath(szFullPath)) {
			//
			// Fake an entry for the root folder
			//
			time_t t;
			memset(&fd, 0, sizeof(fd));
			t = time(0);
			fd.attrib = FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_SYSTEM;
			strcpy(fd.name, "\\");
			fd.time_access = t;
			fd.time_write = t;
			fd.time_create = t;
		} else {
			MapWin32ErrorToPosixErrno();
			return symce;
		}
	}

	//
	// Fill in more data for the symlink target
	//
	symce->ce_size = fd.size;
	symce->dwFileAttributes = fd.attrib; // FILE_ATTRIBUTE_NORMAL maps to 0
	symce->ce_atime = fd.time_access;
	symce->ce_mtime = fd.time_write;
	symce->ce_ctime = fd.time_create;

	if (bFixedDisk) {
		symce->dwFileAttributes |= FILE_ATTRIBUTE_FIXED_DISK;
	}

	// Flag reparse points and .LNK shortcuts as symbolic links
	if ((symce->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0 ||
			_mbsicmp(right(fd.name, 4), ".lnk") == 0) {
		symce->ce_bIsSymlink = TRUE; // symlink pointing to a symlink (rare)
	}

	if (phys_size) {
		symce->ce_size = _get_phys_size(szFullPath, symce->ce_size);
	}

	//
	// Tah dah!
	//
	ce->ce_bBadSymlink = FALSE;

	return symce;
}
コード例 #21
0
ファイル: dirent.c プロジェクト: somian/fileutil-ls
//
// Work around a BUG in FindFirst.
//
// Expand "C:foo" to "C:/lbin/foo"
//
// Necessary because FindFirst("C:*") fails if the current dir
// is C:\.  Ditto FindFirst(".\*")
// 
// Also to discover UNC paths "." -> \\server\share
//
static int
_ExpandPath(char *szPath, char *szBuf, size_t dwBufLen)
{
	char *szFilePart=NULL; // unused
	size_t n;

	n = strlen(szPath) + 1;
	if (n > dwBufLen) {
		errno = ENAMETOOLONG;
		return -1;
	}

	if (gbReg) {
		//n = GetRegistryPathName(szPath, dwBufLen, szBuf);
		lstrcpyn(szBuf, szPath, dwBufLen); // use as-is
	} else {
		char *szStream = NULL;
		//
		// BUG: GetFullPathName(".:secret:$DATA") is wrongly expanded
		// to ".:\secret:$DATA".  Probably because GetFullPathName gets
		// confused and thinks that ".:" is a drive letter.
		//
		// WORKAROUND: Temporarily chop the stream suffix
		//
		if ((n = strlen(szPath)) >= 7 
				&& _mbsicmp(szPath+n-6, ":$DATA") == 0) {
			//
			// Find the second ':' going backwards
			//
			szPath[n-6] = '\0'; // temporarily hide the ":$DATA" suffix
			if ((szStream = strrchr(szPath, ':')) != NULL) {
				*szStream = '\0'; // temporarily hide the second ':'
			}
			szPath[n-6] = ':';
		}

		n = GetFullPathName(szPath, dwBufLen, szBuf, &szFilePart);

		if (szStream) {
			size_t nLenStream;

			*szStream = ':'; // restore the second ':'
			nLenStream = strlen(szStream);
			n += nLenStream;
			if (n+1 <= dwBufLen) {
				strcat(szBuf, szStream);
			}
		}
	}

	if (n+1 > dwBufLen) {
		errno = ENAMETOOLONG;
		return -1;
	}

	if (n == 0) {
		MapWin32ErrorToPosixErrno();
		return -1;
	}

#ifdef UNDEFINED
	//
	// Convert to forward slashes
	//
	for (sz = szBuf; *sz; ++sz) {
		if (*sz == '\\') {
			*sz = '/';
		}
	}
#endif

	return 0;
}
コード例 #22
0
ファイル: dirent.c プロジェクト: somian/fileutil-ls
static int
__xstat(const char *szPath, struct xstat *st, 
	unsigned long dwType, BOOL bCache, BOOL bFollowSymlink)
{
	char szFullPath[FILENAME_MAX], szBuf[FILENAME_MAX];
	char szDirBuf[FILENAME_MAX];
	char *sz, *szDir, *szFile;
	struct cache_dir *cd;
	struct cache_entry *ce;
	long hFind;
	struct _finddatai64_t fd;
	BOOL bShowStreams = (show_streams == yes_arg);
	BOOL bFixedDisk = FALSE; 

	lstrcpyn(szFullPath, szPath, FILENAME_MAX);
	//
	// Change forward slashes to backward slashes
	//
	for (sz = szFullPath; *sz; ++sz) {
		if (*sz == '/') {
			*sz = '\\';
		}
	}
	//
	// Strip trailing backslashes
	//
	for (--sz; sz > szFullPath; --sz) {
		if (*sz != '\\') {
			break;
		}
		if (sz == szFullPath+2 && szFullPath[1] == ':') {
			break; // stop if C:\  
		}
		*sz = '\0';
	}

	//
	// No FindFile wildcards allowed at this point
	//
	if (_mbspbrk(szFullPath, "?*") != NULL) {
		errno = ENOENT;
		return -1;
	}

	//
	// Break off dir and file components
	//
	strcpy(szBuf, szFullPath);

	if ((sz = strrchr(szBuf, '\\')) == NULL) {
		if (szBuf[1] == ':') {
			if (szBuf[2] == '\0') {
				// ls C:
				szDir = szBuf; // C:
				szFile = ".";
			} else {
				// ls C:foo
				szDirBuf[0] = szBuf[0];
				szDirBuf[1] = szBuf[1];
				szDirBuf[2] = '\0';
				szDir = szDirBuf; // C:
				szFile = szBuf+2; // foo
			}
		} else {
			// ls foo
			szDir = ".";
			szFile = szBuf;
		}
	} else {
		// ls dir\foo
		szFile = sz+1;
		//
		// Strip trailing backslashes from the dir component
		//
		strcpy(szDirBuf, szBuf); // copy to avoid stomping on szFile
		szDir = szDirBuf;
		sz = szDir + (sz-szBuf);
		*(sz+1) = '\0'; // ensure termination
		for (; *sz == '\\' && sz > szDirBuf; --sz) {
			if (sz == szDirBuf+2 && szDirBuf[1] == ':') {
				break; // stop if C:\  
			}
			*sz = '\0';
		}
	}

	if ((cd = _find_cache_dir(szDir, szFile)) != NULL) {
		//
		// Found hit from previous opendir()/readdir()
		//
		for (ce = cd->cd_entry_first; ce; ce = ce->ce_next) {
			if (ce->ce_filename[0] == szFile[0] &&
					_mbsicmp(ce->ce_filename, szFile) == 0) {
				//
				// Found file 
				//
				goto cache_hit;
			}
		}
		errno = ENOENT;  // not in cache dir
		return -1;
	}

	//
	// Get the canonical path for use in security.cpp
	//
	if (_GetAbsolutePath(szFullPath, szBuf, FILENAME_MAX, &bFixedDisk) < 0) {
		return -1;
	}

	strcpy(szFullPath, szBuf);

	//
	// Check the partial stat cache against the abs path
	//
	for (ce = _stat_first; ce; ce = ce->ce_next) {
		if (ce->ce_abspath && _mbsicmp(ce->ce_abspath, szFullPath) == 0) {
			goto cache_hit;
		}
	}

	//
	// Do not show streams if --fast on a non-fixed disk
	//
	if (run_fast && !bFixedDisk) {
		bShowStreams = FALSE;
	}

#ifdef DEBUG_FINDFIRST
more_printf("stat: findfirst on \"%s\"\n", szFullPath);
more_fflush(stdmore);
#endif

	//
	// Do a singleton FindFirst to get WIN32_FILE_DATA
	//
	if ((hFind = _xfindfirsti64(szFullPath, &fd, bShowStreams, dwType)) 
			!= (long)INVALID_HANDLE_VALUE) {
		// Succeeded
		if (_xfindclose(hFind, bShowStreams) == -1) {
			MapWin32ErrorToPosixErrno();
			return -1;
		}
	} else {
		//
		// FindFirst failed.  This is a normal (sic) error for root folders
		// e.g., C:\ and sometimes \\server\share\
		//
		if ((szFullPath[1] == ':' && szFullPath[2] == '\\' && szFullPath[3] == '\0') ||
				_IsServerRootPath(szFullPath)) {
			//
			// Fake an entry for the root folder
			//
			time_t t;
			memset(&fd, 0, sizeof(fd));
			t = time(0);
			fd.attrib = FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_SYSTEM;
			strcpy(fd.name, "\\");
			fd.time_access = t;
			fd.time_write = t;
			fd.time_create = t;
		} else {
			MapWin32ErrorToPosixErrno();
			return -1;
		}
	}

	ce = (struct cache_entry *)xmalloc(sizeof(*ce));
	memset(ce, 0, sizeof(*ce));

	if (bCache) {
		//
		// Put on the partial stat cache
		//
		if (_stat_first == NULL) {
			_stat_first = _stat_last = ce;
		} else {
			_stat_last->ce_next = ce;
			_stat_last = ce;
		}
	}

	if (short_names) {
		_get_short_path(szFullPath); // update in place
	}
	ce->ce_filename = (char *)xstrdup(fd.name); // last component only
	ce->ce_size = fd.size;
	ce->ce_ino = 1; // requires GetFileInformationByHandle - uintmax_t
	ce->dwFileAttributes = fd.attrib; // FILE_ATTRIBUTE_NORMAL maps to 0
	ce->ce_atime = fd.time_access;
	ce->ce_mtime = fd.time_write;
	ce->ce_ctime = fd.time_create;
	ce->nNumberOfLinks = 1;
	if (bFixedDisk) {
		ce->dwFileAttributes |= FILE_ATTRIBUTE_FIXED_DISK;
	}

	//
	// Squirrel away the canonical path
	//
	ce->ce_abspath = xstrdup(szFullPath);

	// Flag reparse points and .LNK shortcuts as symbolic links
	if ((ce->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0 ||
			_mbsicmp(right(fd.name, 4), ".lnk") == 0) {
		ce->ce_bIsSymlink = TRUE;
	}

	if (phys_size) {
		ce->ce_size = _get_phys_size(szFullPath, ce->ce_size);
	}
	if (!run_fast || bFixedDisk || print_inode) {
		//
		// Get inode and hardlink info
		//
		_get_full_file_info(szFullPath, ce);
	}

cache_hit:
	if (bFollowSymlink) {
		ce = _follow_symlink(ce);
	}
	memset(st, 0, sizeof(*st));
	st->st_ino = ce->ce_ino;
	st->st_size = ce->ce_size;
	st->st_atime = ce->ce_atime;
	st->st_mtime = ce->ce_mtime;
	st->st_ctime = ce->ce_ctime;
	st->st_nlink = (short)ce->nNumberOfLinks;
	st->st_mode = _MapMode(ce);
	st->st_ce = ce;

	return 0;
}
コード例 #23
0
// ---------------------------------------------------------------------
SInt32 WinMBCString::CompareNoCase(const WinMBCString& other) const
{
	return _mbsicmp(reinterpret_cast<const unsigned char*>(innerString.c_str()), reinterpret_cast<const unsigned char*>(other.innerString.c_str()));
}
コード例 #24
0
ファイル: MainMenus.cpp プロジェクト: bsmr-games/Blood2
// Initialize the fonts
void CMainMenus::InitFonts()
{
	m_pSmallFont = new CLTGUIFont;
	m_pLargeFont = new CLTGUIFont;
	
	// Initialize the bitmap fonts if we are in english
	if (IsEnglish())
	{
		char *lpszSmallFontPath="interface/fonts/MenuFont1.pcx";
		char *lpszSmallWidthPath="interface/fonts/MenuFont1.fnt";

		char *lpszLargeFontPath="interface/fonts/MenuFont1.pcx";
		char *lpszLargeWidthPath="interface/fonts/MenuFont1.fnt";
		
		if ( !m_pSmallFont->Init(m_pClientDE, lpszSmallFontPath, lpszSmallWidthPath) )
		{
			char szString[512];
			sprintf(szString, "Cannot load font: %s", lpszSmallFontPath);
			m_pClientDE->CPrint(szString);
		}
		
		if ( !m_pLargeFont->Init(m_pClientDE, lpszLargeFontPath, lpszLargeWidthPath) )
		{
			char szString[512];
			sprintf(szString, "Cannot load font: %s", lpszLargeFontPath);
			m_pClientDE->CPrint(szString);

			delete []m_pLargeFont;
			m_pLargeFont=DNULL;
		}
		
		// Load the large fading fonts
		m_pLargeFadeFonts = new CLTGUIFont[m_nNumLargeFadeFonts];

		int i;
		for (i=0; i < m_nNumLargeFadeFonts; i++)
		{
			char szPath[512];

			// Check to see if we should be loading a disabled font
			if (m_nNumLargeFadeFonts > 1 && i==m_nNumLargeFadeFonts-1)
			{
				sprintf(szPath, "interface/mainmenus/mm_font_dis.pcx", i+1);
			}
			else
			{
				sprintf(szPath, "interface/mainmenus/mm_font_0%d.pcx", i+1);
			}

			if ( !m_pLargeFadeFonts[i].Init(m_pClientDE, szPath, "interface/mainmenus/mm_font.fnt") )
			{
				char szString[512];
				sprintf(szString, "Cannot load font: %s", szPath);
				m_pClientDE->CPrint(szString);			
				
				delete []m_pLargeFadeFonts;

				// Set it to the large font
				m_pLargeFadeFonts=m_pLargeFont;
				m_nNumLargeFadeFonts=1;
			}		
		}
	}
	else
	{
		m_nNumLargeFadeFonts=0;

		// Initialize the engine fonts for non-english resource files
		InitEngineFont(m_pSmallFont, IDS_MENU_FONT_SMALL_NAME, IDS_MENU_FONT_SMALL_WIDTH, IDS_MENU_FONT_SMALL_HEIGHT);
		InitEngineFont(m_pLargeFont, IDS_MENU_FONT_LARGE_NAME, IDS_MENU_FONT_LARGE_WIDTH, IDS_MENU_FONT_LARGE_HEIGHT);

		// Initialize a title font if we aren't in english
		if (!IsEnglish())
		{
			m_pTitleFont = new CLTGUIFont;
			InitEngineFont(m_pTitleFont, IDS_MENU_FONT_TITLE_NAME, IDS_MENU_FONT_TITLE_WIDTH, IDS_MENU_FONT_TITLE_HEIGHT);
		}
	}

	// Set the wrapping method
	HSTRING hString=m_pClientDE->FormatString(IDS_FONT_WRAP_USE_SPACES);
	if (_mbsicmp((const unsigned char*)m_pClientDE->GetStringData(hString), (const unsigned char*)"1") == 0)
	{
		CLTGUIFont::SetWrapMethod(DTRUE);
	}
	else
	{
		CLTGUIFont::SetWrapMethod(DFALSE);
	}
}
コード例 #25
0
ファイル: MainMenus.cpp プロジェクト: bsmr-games/Blood2
// Initialization
DBOOL CMainMenus::Init(CClientDE* pClientDE)
{
	if (!pClientDE)
	{
		return DFALSE;
	}
	
	m_pClientDE = pClientDE;

	// Set the English flag
	HSTRING hString=m_pClientDE->FormatString(IDS_BLOOD2_LANGUAGE);
	if (hString && _mbsicmp((const unsigned char*)"english", (const unsigned char*)m_pClientDE->GetStringData(hString)) != 0)
	{
		m_bEnglish=DFALSE;
	}
	else
	{
		m_bEnglish=DTRUE;
	}
	m_pClientDE->FreeString(hString);
	hString=DNULL;

	// Load the virtual key codes for yes responses
	hString=m_pClientDE->FormatString(IDS_MENU_VKEY_YES);
	if (hString)
	{
		m_nYesVKeyCode=atoi(m_pClientDE->GetStringData(hString));
		m_pClientDE->FreeString(hString);
		hString=DNULL;
	}

	// Load the virtual key codes for no responses
	hString=m_pClientDE->FormatString(IDS_MENU_VKEY_NO);
	if (hString)
	{
		m_nNoVKeyCode=atoi(m_pClientDE->GetStringData(hString));
		m_pClientDE->FreeString(hString);
		hString=DNULL;
	}

	// Init the SharedResourceMgr class
	m_sharedResourceMgr.Init(m_pClientDE);

	// Determine if we need to set the low resolution flag
	RMode currentMode;
	if (m_pClientDE->GetRenderMode(&currentMode) == LT_OK)
	{
		if (currentMode.m_Width < 512 || currentMode.m_Height < 384)
		{
			m_bLowResolution=DTRUE;
			m_nMenuHeight=180;
		}
	}

	// Initialize the surfaces
	if ( !InitSurfaces() )
	{
		return DFALSE;
	}

	// Initialize the fonts
	InitFonts();

	// Initialize the message box
	m_messageBox.Create(m_pClientDE, "interface/mainmenus/dialog.pcx", GetSmallFont(), DNULL, DNULL);
	m_messageBox.SetTextColor(SETRGB(220,190,170));

	// Initialize the individual menus
	m_mainMenu.Init				(m_pClientDE, this, DNULL,				MENU_ID_MAINMENU,		m_nMenuHeight);
	m_singlePlayerMenu.Init		(m_pClientDE, this, &m_mainMenu,		MENU_ID_SINGLEPLAYER,	m_nMenuHeight);	
	m_bloodBathMenu.Init		(m_pClientDE, this, &m_mainMenu,		MENU_ID_BLOODBATH,		m_nMenuHeight);
	m_optionsMenu.Init			(m_pClientDE, this, &m_mainMenu,		MENU_ID_OPTIONS,		m_nMenuHeight);
	m_difficultyMenu.Init		(m_pClientDE, this, &m_singlePlayerMenu,MENU_ID_DIFFICULTY,		m_nMenuHeight);	
	m_customLevelMenu.Init		(m_pClientDE, this, &m_singlePlayerMenu,MENU_ID_CUSTOM_LEVEL,	m_nMenuHeight);
	m_loadGameMenu.Init			(m_pClientDE, this, &m_singlePlayerMenu,MENU_ID_LOAD_GAME,		m_nMenuHeight);	
	m_saveGameMenu.Init			(m_pClientDE, this, &m_singlePlayerMenu,MENU_ID_SAVE_GAME,		m_nMenuHeight);
	m_controlsMenu.Init			(m_pClientDE, this, &m_optionsMenu,		MENU_ID_CONTROLS,		m_nMenuHeight);
	m_soundMenu.Init			(m_pClientDE, this, &m_optionsMenu,		MENU_ID_SOUND,			m_nMenuHeight);
	m_displayMenu.Init			(m_pClientDE, this, &m_optionsMenu,		MENU_ID_DISPLAY,		m_nMenuHeight);
	m_characterMenu.Init		(m_pClientDE, this, &m_bloodBathMenu,	MENU_ID_CHARACTER,		m_nMenuHeight);	
	m_characterFilesMenu.Init	(m_pClientDE, this, &m_characterMenu,	MENU_ID_CHARACTERFILES,	100);
	m_characterSelectMenu.Init	(m_pClientDE, this, &m_singlePlayerMenu,MENU_ID_CHARACTERSELECT,m_nMenuHeight);
	m_mouseMenu.Init			(m_pClientDE, this, &m_optionsMenu	   ,MENU_ID_MOUSE		   ,m_nMenuHeight);
	m_keyboardMenu.Init			(m_pClientDE, this, &m_optionsMenu	   ,MENU_ID_KEYBOARD	   ,m_nMenuHeight);
	m_joystickMenu.Init			(m_pClientDE, this, &m_optionsMenu	   ,MENU_ID_JOYSTICK	   ,m_nMenuHeight);

	// Add each menu to the array
	m_menuArray.SetSize(0);
	m_menuArray.Add(&m_mainMenu);
	m_menuArray.Add(&m_singlePlayerMenu);
	m_menuArray.Add(&m_bloodBathMenu);
	m_menuArray.Add(&m_optionsMenu);
	m_menuArray.Add(&m_difficultyMenu);
	m_menuArray.Add(&m_customLevelMenu);
	m_menuArray.Add(&m_loadGameMenu);
	m_menuArray.Add(&m_saveGameMenu);
	m_menuArray.Add(&m_controlsMenu);
	m_menuArray.Add(&m_soundMenu);	
	m_menuArray.Add(&m_characterMenu);
	m_menuArray.Add(&m_characterFilesMenu);
	m_menuArray.Add(&m_characterSelectMenu);	
	m_menuArray.Add(&m_mouseMenu);
	m_menuArray.Add(&m_keyboardMenu);
	m_menuArray.Add(&m_joystickMenu);

	// Build each menu
	unsigned int i;
	for (i=0; i < m_menuArray.GetSize(); i++)
	{
		m_menuArray[i]->Build();
	}	

	// This is done after the build above because it shouldn't be built until the user
	// actually wants to go into the menu.	
	m_menuArray.Add(&m_displayMenu);

	SetCurrentMenu(MENU_ID_MAINMENU, MENU_ID_MAINMENU);	
	
	// Load the version string
	m_hstrVersion = m_pClientDE->FormatString(IDS_VERSION);

	return DTRUE;
}
コード例 #26
0
int test_implicit_compare_with_functions() {

  if (memcmp(A, "a", 1))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'memcmp' is called without explicitly comparing result
  // CHECK-FIXES: memcmp(A, "a", 1) != 0)

  if (wmemcmp(W, L"a", 1))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wmemcmp' is called without explicitly comparing result
  // CHECK-FIXES: wmemcmp(W, L"a", 1) != 0)

  if (memicmp(A, "a", 1))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'memicmp' is called without explicitly comparing result
  // CHECK-FIXES: memicmp(A, "a", 1) != 0)

  if (_memicmp(A, "a", 1))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_memicmp' is called without explicitly comparing result
  // CHECK-FIXES: _memicmp(A, "a", 1) != 0)

  if (_memicmp_l(A, "a", 1, locale))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_memicmp_l' is called without explicitly comparing result
  // CHECK-FIXES: _memicmp_l(A, "a", 1, locale) != 0)

  if (strcmp(A, "a"))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is called without explicitly comparing result
  // CHECK-FIXES: strcmp(A, "a") != 0)

  if (strncmp(A, "a", 1))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strncmp' is called without explicitly comparing result
  // CHECK-FIXES: strncmp(A, "a", 1) != 0)

  if (strcasecmp(A, "a"))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcasecmp' is called without explicitly comparing result
  // CHECK-FIXES: strcasecmp(A, "a") != 0)

  if (strncasecmp(A, "a", 1))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strncasecmp' is called without explicitly comparing result
  // CHECK-FIXES: strncasecmp(A, "a", 1) != 0)

  if (stricmp(A, "a"))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'stricmp' is called without explicitly comparing result
  // CHECK-FIXES: stricmp(A, "a") != 0)

  if (strcmpi(A, "a"))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmpi' is called without explicitly comparing result
  // CHECK-FIXES: strcmpi(A, "a") != 0)

  if (_stricmp(A, "a"))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_stricmp' is called without explicitly comparing result
  // CHECK-FIXES: _stricmp(A, "a") != 0)

  if (strnicmp(A, "a", 1))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strnicmp' is called without explicitly comparing result
  // CHECK-FIXES: strnicmp(A, "a", 1) != 0)

  if (_strnicmp(A, "a", 1))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_strnicmp' is called without explicitly comparing result
  // CHECK-FIXES: _strnicmp(A, "a", 1) != 0)

  if (_stricmp_l(A, "a", locale))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_stricmp_l' is called without explicitly comparing result
  // CHECK-FIXES: _stricmp_l(A, "a", locale) != 0)

  if (_strnicmp_l(A, "a", 1, locale))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_strnicmp_l' is called without explicitly comparing result
  // CHECK-FIXES: _strnicmp_l(A, "a", 1, locale) != 0)

  if (wcscmp(W, L"a"))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wcscmp' is called without explicitly comparing result
  // CHECK-FIXES: wcscmp(W, L"a") != 0)

  if (wcsncmp(W, L"a", 1))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wcsncmp' is called without explicitly comparing result
  // CHECK-FIXES: wcsncmp(W, L"a", 1) != 0)

  if (wcscasecmp(W, L"a"))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wcscasecmp' is called without explicitly comparing result
  // CHECK-FIXES: wcscasecmp(W, L"a") != 0)

  if (wcsicmp(W, L"a"))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wcsicmp' is called without explicitly comparing result
  // CHECK-FIXES: wcsicmp(W, L"a") != 0)

  if (_wcsicmp(W, L"a"))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_wcsicmp' is called without explicitly comparing result
  // CHECK-FIXES: _wcsicmp(W, L"a") != 0)

  if (_wcsicmp_l(W, L"a", locale))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_wcsicmp_l' is called without explicitly comparing result
  // CHECK-FIXES: _wcsicmp_l(W, L"a", locale) != 0)

  if (wcsnicmp(W, L"a", 1))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wcsnicmp' is called without explicitly comparing result
  // CHECK-FIXES: wcsnicmp(W, L"a", 1) != 0)

  if (_wcsnicmp(W, L"a", 1))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_wcsnicmp' is called without explicitly comparing result
  // CHECK-FIXES: _wcsnicmp(W, L"a", 1) != 0)

  if (_wcsnicmp_l(W, L"a", 1, locale))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_wcsnicmp_l' is called without explicitly comparing result
  // CHECK-FIXES: _wcsnicmp_l(W, L"a", 1, locale) != 0)

  if (_mbscmp(U, V))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbscmp' is called without explicitly comparing result
  // CHECK-FIXES: _mbscmp(U, V) != 0)

  if (_mbsncmp(U, V, 1))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsncmp' is called without explicitly comparing result
  // CHECK-FIXES: _mbsncmp(U, V, 1) != 0)

  if (_mbsnbcmp(U, V, 1))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnbcmp' is called without explicitly comparing result
  // CHECK-FIXES: _mbsnbcmp(U, V, 1) != 0)

  if (_mbsnbicmp(U, V, 1))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnbicmp' is called without explicitly comparing result
  // CHECK-FIXES: _mbsnbicmp(U, V, 1) != 0)

  if (_mbsicmp(U, V))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsicmp' is called without explicitly comparing result
  // CHECK-FIXES: _mbsicmp(U, V) != 0)

  if (_mbsnicmp(U, V, 1))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnicmp' is called without explicitly comparing result
  // CHECK-FIXES: _mbsnicmp(U, V, 1) != 0)

  if (_mbscmp_l(U, V, locale))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbscmp_l' is called without explicitly comparing result
  // CHECK-FIXES: _mbscmp_l(U, V, locale) != 0)

  if (_mbsncmp_l(U, V, 1, locale))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsncmp_l' is called without explicitly comparing result
  // CHECK-FIXES: _mbsncmp_l(U, V, 1, locale) != 0)

  if (_mbsicmp_l(U, V, locale))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsicmp_l' is called without explicitly comparing result
  // CHECK-FIXES: _mbsicmp_l(U, V, locale) != 0)

  if (_mbsnicmp_l(U, V, 1, locale))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnicmp_l' is called without explicitly comparing result
  // CHECK-FIXES: _mbsnicmp_l(U, V, 1, locale) != 0)

  if (_mbsnbcmp_l(U, V, 1, locale))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnbcmp_l' is called without explicitly comparing result
  // CHECK-FIXES: _mbsnbcmp_l(U, V, 1, locale) != 0)

  if (_mbsnbicmp_l(U, V, 1, locale))
    return 0;
  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnbicmp_l' is called without explicitly comparing result
  // CHECK-FIXES: _mbsnbicmp_l(U, V, 1, locale) != 0)

  return 1;
}