⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 validatr.cpp

📁 著名的 helix realplayer 基于手机 symbian 系统的 播放器全套源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		       pContent[i] != 0 && i < iLen)
		{
		    i++;
		}

		memset(pUrl, 0, MAX_URL_STRING);
		j = 0;
		i++;

		continue;
	    }
*/
	    ramFile[j] = pContent[i]; 
	    
	    // Look for line terminators.
	    if ( ramFile[j] == '\n' || ramFile[j] == '\r' || ramFile[j] == 0 || i == iLen)
	    {
		ramFile[j] = 0;

		pString = new CHXString(ramFile);

		pString->TrimLeft();
		pString->TrimRight();

		iSize = pString->GetLength();
		if (iSize)
		{
		    memset(ramFile, 0, iLen+1);
		    SafeStrCpy(ramFile,  pString->GetBuffer(iSize), iLen+1);
		    
		    // A URL must have at least 4 chars. for protocol. This will
		    // take care of lines with junk or just CR on them.
		    
		    // detect RAM3.0 syntax
		    if (strncasecmp(ramFile, HX_RAM30_START_TAG, HX_RAM30_START_TAGSIZE) == 0)
		    {
			ulMajorVersion = 3;
		    }
		    else if (strncasecmp(ramFile, HX_RAM30_END_TAG, HX_RAM30_END_TAGSIZE) == 0)
		    {
			HX_DELETE(pString);
			break;
		    }
		    // detect RAM2.0 syntax
		    else if (strncasecmp(ramFile, HX_RAM20_START_TAG, HX_RAM20_START_TAGSIZE) == 0)
		    {
			ulMajorVersion = 2;
		    }
		    else if (strncasecmp(ramFile, HX_RAM20_END_TAG, HX_RAM20_END_TAGSIZE) == 0)
		    {
			HX_DELETE(pString);
			break;
		    }
		    // handle "--stop--" tag in 6.0
		    else if (strncasecmp(ramFile, "--stop--", 8) == 0)
		    {
			HX_DELETE(pString);
			break;
		    }
		    else 
		    {
			if (ulMajorVersion == 2 || ulMajorVersion == 3)
			{
			    if (strncasecmp(ramFile, HX_RAM_ENTRY_TAG, HX_RAM_ENTRY_TAGSIZE) == 0 && 
				(iSize >= (HX_RAM_ENTRY_TAGSIZE + 4)))
			    {
				CHXString* pStringAfterTag = new CHXString(ramFile+2);

				pStringAfterTag->TrimLeft();
				pStringAfterTag->TrimRight();
    
				iSize = pStringAfterTag->GetLength();
				if (iSize)
				{				
				    memset(ramFile, 0, iLen);
				    SafeStrCpy(ramFile,  pStringAfterTag->GetBuffer(iSize), iLen+1);
				}
				HX_DELETE(pStringAfterTag);
			    }
			    else
			    {
				memset(ramFile, 0, iLen);
			    }			    
			}
			    
			pCursor = strstr(ramFile, ":");
			if (pCursor)			
			{
			    ulProtocol = pCursor - ramFile;

			    if (ulProtocol > 0)
			    {
				pProtocol = new char[ulProtocol+1];
				memset(pProtocol, 0, ulProtocol+1);
				strncpy(pProtocol, ramFile, ulProtocol); /* Flawfinder: ignore */

				if (ValidateProtocol(pProtocol))
				{
				    bTrackFound = TRUE;
				}

				HX_VECTOR_DELETE(pProtocol);
			    }
			}
		    }
		}

		j = 0;
		HX_DELETE(pString);
	    }
	    else
	    {	
		j++; 
	    }

	    i++;
	}
	HX_VECTOR_DELETE(ramFile);

	if (bTrackFound)
	{	    
	    hr = HXR_OK;
	    goto cleanup;
	}
	else
	{
	    hr = HXR_INVALID_METAFILE;
	    goto cleanup;
	}
    }
    // determine if it is a RAM
    else
    {
	// Trim off any leading spaces/EOLs/tabs before adding on the pnm protocol...
	pLine = strtok(pContent, tokenset);

	while (pLine != NULL)
	{	
	    size_t pos = strspn(pLine,charset);
	    pLine += pos;

	    // handle RAM3.0 syntax
	    if (strncasecmp(pLine, HX_RAM30_START_TAG, HX_RAM30_START_TAGSIZE) == 0)
	    {
		ulMajorVersion = 3;
		pLine = strtok(NULL, tokenset);
		continue;
	    }
	    // handle RAM2.0 syntax
	    else if (strncasecmp(pLine, HX_RAM20_START_TAG, HX_RAM20_START_TAGSIZE) == 0)
	    {
		ulMajorVersion = 2;
		pLine = strtok(NULL, tokenset);
		continue;
	    }

	    if (ulMajorVersion == 2 && ulMajorVersion == 3)
	    {
		if (strncasecmp(pLine, HX_RAM_ENTRY_TAG, HX_RAM_ENTRY_TAGSIZE) == 0 &&
		    (pCursor = strstr(pLine, ":")))
		{
		    pLine += 2;		    
		    // trim off the leading spaces
		    while (pLine[0] == ' ')
		    {
			pLine++;
		    }
		}
		else
		{
		    pLine = strtok(NULL, tokenset);
		    continue;
		}			    
	    }
	    else
	    {
		pString = new CHXString(pLine);

		pString->TrimLeft();
		pString->TrimRight();

		if ((pString->GetLength() == 0)	    ||
		    (strncasecmp(pLine, "//", 2) == 0)  ||
		    (strncasecmp(pLine, "#", 1) == 0))
		{
		    // comments, skip to next line
		    pLine = strtok(NULL, tokenset);
		    HX_DELETE(pString);
		    continue;
		}
		HX_DELETE(pString);

		pCursor = strstr(pLine, ":");
		if (!pCursor)
		{
		    bIsRAM = FALSE;
		    break;
		}
	    }

	    ulProtocol = pCursor - pLine;
	    if (ulProtocol > 0)
	    {
		pProtocol = new char[ulProtocol+1];
		memset(pProtocol, 0, ulProtocol+1);
		strncpy(pProtocol, pLine, ulProtocol); /* Flawfinder: ignore */

		bIsRAM = ValidateProtocol(pProtocol);

		HX_VECTOR_DELETE(pProtocol);
		break;
	    }
	    else
	    {
		bIsRAM = FALSE;
		break;
	    }
	}

	if (bIsRAM)
	{
	    hr = HXR_OK;
	    goto cleanup;
	}
	else
	{
	    hr = HXR_FAILED;
	    goto cleanup;
	}
    }
    
cleanup:

    // set the RAMVersion to response header, it will be retrieved by the 
    // RAM file format
    if (pRequest && bIsRAM)
    {
	if (!pResponseHeaders)
	{
	    pResponseHeaders = (IHXValues*) new CHXHeader;
	    pResponseHeaders->AddRef();
	    bHeaderToBeSet = TRUE;
	}

	UINT32 ulPersistentVersion = HX_ENCODE_PROD_VERSION(ulMajorVersion, 0, 0, 0);
	pResponseHeaders->SetPropertyULONG32("PersistentVersion", ulPersistentVersion);

	if (bHeaderToBeSet)
	{
	    pRequest->SetResponseHeaders(pResponseHeaders); 
	}
    }

    HX_VECTOR_DELETE(pURL);
    HX_VECTOR_DELETE(pContent);

    HX_RELEASE(pResponseHeaders);
    HX_RELEASE(pValue);
    HX_RELEASE(pRequest);
    HX_RELEASE(pData);

    return hr;
}

HX_RESULT
HXValidator::BuildProtocolList(void)
{
    HX_RESULT	hr = HXR_OK;
    UINT32	j = 0;
    UINT32	ulPlugins = 0;
    IHXValues*	pValues = NULL;
    IHXBuffer*	pBuffer = NULL;
    IHXCommonClassFactory* pCommonClassFactory = NULL;
    IHXPluginQuery* pPluginQuery = NULL;
    IHXPluginGroupEnumerator* pPluginEnum = NULL;
    CHXString*	pProtocol = NULL;
    CHXSimpleList::Iterator i;

    if (HXR_OK != m_pContext->QueryInterface(IID_IHXCommonClassFactory, (void**)&pCommonClassFactory))
    {
	hr = HXR_FAILED;
	goto cleanup;
    }

    // reset the list
    i = m_ProtocolList.Begin();
    for (; i != m_ProtocolList.End(); ++i)
    {
	pProtocol = (CHXString*) (*i);
	HX_DELETE(pProtocol);
    }
    m_ProtocolList.RemoveAll();

    // we always add "pnm" and "rtsp"
    pProtocol = new CHXString("pnm");
    m_ProtocolList.AddTail(pProtocol);

    pProtocol = new CHXString("rtsp");
    m_ProtocolList.AddTail(pProtocol);

    // collect protocol info. from the pluginhandler
    if (HXR_OK != pCommonClassFactory->CreateInstance(IID_IHXPluginGroupEnumerator, 
							(void**)&pPluginEnum))
    {
	goto cleanup;
    }

    if (HXR_OK != pPluginEnum->QueryInterface(IID_IHXPluginQuery, (void**)&pPluginQuery))
    {
	goto cleanup;
    }

    if (HXR_OK != pPluginQuery->GetNumPluginsGivenGroup(IID_IHXFileSystemObject, ulPlugins))
    {
	goto cleanup;
    }

    for (j = 0; j < ulPlugins; j++)
    {
	HX_RELEASE(pBuffer);
	HX_RELEASE(pValues);

	if (HXR_OK != pPluginQuery->GetPluginInfo(IID_IHXFileSystemObject, j, pValues) ||
	    !pValues)
	{
	    continue;
	}

	if (HXR_OK != pValues->GetPropertyCString("FileProtocol", pBuffer) ||
	    !pBuffer)
	{
	    continue;
	}

	pProtocol = new CHXString((const char*) pBuffer->GetBuffer());
	int nPos = pProtocol->Find('|');
	while (nPos > 0)
	{
	    CHXString* pTemp = new CHXString(pProtocol->Left(nPos));
	    *pProtocol = pProtocol->Mid(nPos + 1);
	    m_ProtocolList.AddTail(pTemp);
	    nPos = pProtocol->Find('|');
	}
	m_ProtocolList.AddTail(pProtocol);
	if (pProtocol->CompareNoCase("lice") == 0)
	{
	    CHXString *pAnother = new CHXString("rnba");
	    m_ProtocolList.AddTail(pAnother);
	}
    }

cleanup:

    HX_RELEASE(pBuffer);
    HX_RELEASE(pValues);
    HX_RELEASE(pPluginQuery);
    HX_RELEASE(pPluginEnum);
    HX_RELEASE(pCommonClassFactory);

    return hr;
}

void
HXValidator::RefreshProtocols(void)
{
    m_bRefresh = TRUE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -