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

📄 httpfsys.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: httpfsys.cpp,v 1.28.2.5 2004/07/13 21:00:44 bobclark Exp $ *  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. *  * The contents of this file, and the files included with this file, * are subject to the current version of the RealNetworks Public * Source License (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (the "RCSL") available at * http://www.helixcommunity.org/content/rcsl, in which case the RCSL * will apply. You may also obtain the license terms directly from * RealNetworks.  You may not use this file except in compliance with * the RPSL or, if you have a valid RCSL with RealNetworks applicable * to this file, the RCSL.  Please see the applicable RPSL or RCSL for * the rights, obligations and limitations governing use of the * contents of the file. *  * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. *  * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the * portions it created. *  * This file, and the files included with this file, is distributed * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET * ENJOYMENT OR NON-INFRINGEMENT. *  * Technology Compatibility Kit Test Suite(s) Location: *    http://www.helixcommunity.org/content/tck *  * Contributor(s): *  * ***** END LICENSE BLOCK ***** */#include "hlxclib/stdio.h"#include "hlxclib/string.h"#include "hlxclib/stdlib.h"#include "hlxclib/sys/types.h"#include "hlxclib/sys/stat.h"#include "httpfsys.ver"#include "hxtypes.h"#include "hxcom.h"#include "hxstrutl.h"#include "hxerror.h"#include "hxcomm.h"#include "ihxpckts.h"#include "hxfiles.h"#include "hxplugn.h"#include "hxplgns.h"#include "hxengin.h"#include "hxprefs.h"#include "ihxpckts.h"#include "hxmon.h"#include "hxrendr.h"#include "hxpends.h"#include "hxauthn.h"#include "hxtbuf.h"#include "hxtset.h"#include "ihxident.h"#include "perplex.h"#include "chxpckts.h"#include "dbcs.h"#include "chunkres.h"#include "hxslist.h"#include "httppars.h"#include "httpmsg.h"#include "mimehead.h"#include "portaddr.h"#include "hxver.h"#include "hxtick.h"#include "hxurl.h"#include "ihxcookies.h"#include "timerep.h"#include "cache.h"#include "unkimp.h"#include "hxdir.h"#include "rtsputil.h"#if defined(HELIX_FEATURE_HTTP_GZIP)#include "zlib.h"#include "decoder.h"#endif#include "pacutil.h"#include "httpfsys.h"#include "ihxcookies2.h"#ifdef _MACINTOSH//#include "../dcondev/dcon.h"#endif#if defined(_CARBON) || defined(_MAC_MACHO)#define USE_TEMP_CACHE_LOCATION 1#include "filespecutils.h"#endif#include "hxheap.h"#ifdef _DEBUG#undef HX_THIS_FILEstatic const char HX_THIS_FILE[] = __FILE__;#endif#ifdef _AIX#include "dllpath.h"ENABLE_MULTILOAD_DLLACCESS_PATHS(Httpfsys);#endif#define DEF_HTTP_PORT       80#define DEF_HTTP_PORT_STR   ":80/"#define ALLOCATION_SIZE     1024#ifdef _WIN16#define MAX_RECURSION_LEVEL     10#elif _LINUX#define MAX_RECURSION_LEVEL     30#elif defined(_MACINTOSH)#define MAX_RECURSION_LEVEL     20#else// XXXNH: reduced from 200 to 50 to fix stack overflow in ActiveX#define MAX_RECURSION_LEVEL     50#endif#undef  LOG_DATA#define MAX_CACHE_SIZE          (64 * 1024 * 1024)#define CACHE_DEFAULT_TTL_SECS  (1 * 60 * 60)#define  LOG_FILE               "C:/Temp/cached-httpfsys.log"#include "http_debug.h"#include "db.h"#include <string.h>UINT32 g_ulDefTtl;#ifndef USE_TEMP_CACHE_LOCATION#define DEF_CACHE_DB            "cache_db"#define MAX_CACHE_FILENAME      1024#else#define DEF_CACHE_DB            "helix_http_cache_db"#endif // USE_TEMP_CACHE_LOCATIONCCacheEntry*   g_pCacheEntry = NULL;IHXBuffer*    CreateBufferFromValues (IHXValues *pHeaderValues);// default if no timeouts in preferences.#define DEF_HTTP_SERVER_TIMEOUT     (20 * MILLISECS_PER_SECOND)#define DEF_HTTP_CONNECT_TIMEOUT    (30 * MILLISECS_PER_SECOND)// default user agent header#define DEF_USER_AGENT		"RMA/1.0 (compatible; RealMedia)"// threshhold to see if it's better to do a seek or// just wait for old-fashioned reading to catch up#define BYTE_RANGE_SEEK_THRESHHOLD (4 * 1024)const char* CHTTPFileSystem::zm_pDescription    = "RealNetworks HTTP File System with CHTTP Support";const char* CHTTPFileSystem::zm_pCopyright      = HXVER_COPYRIGHT;const char* CHTTPFileSystem::zm_pMoreInfoURL    = HXVER_MOREINFO;const char* CHTTPFileSystem::zm_pShortName      = "pn-http";/// This name is used to indicate the http server is /// actually RealServer. If the server team changes /// the http response header field, Server: then/// this value needs to be changed accordingly.#define REALSERVER_RESPONSE_NAME    "RealServer"//#define SUPPORT_SECURE_SOCKETS//#define CREATE_LOG_DUMP//#define LOG_DUMP_FILE	"c:/temp/avi.txt"#ifdef SUPPORT_SECURE_SOCKETSconst char* CHTTPFileSystem::zm_pProtocol       = "http|chttp|https";#elseconst char* CHTTPFileSystem::zm_pProtocol       = "http|chttp";#endifBOOL CHTTPFileSystem::m_bSaveNextStream = FALSE;//CHXString CHTTPFileSystem::m_SaveFileName( "" );CHXString CHTTPFileSystem::m_SaveFileName;static INT32 g_nRefCount_http  = 0;#define WWW_AUTHENTICATION_RECENT_KEY "authentication.http.realm.recent"#define PROXY_AUTHENTICATION_RECENT_KEY "proxy-authentication.http.realm.recent"#ifdef USE_TEMP_CACHE_LOCATIONstatic void SetBufferToCacheFilePath(IHXBuffer* pBuffer){    // For Mac Carbon, we put it in the Cleanup at Startup folder since the user may not    // have permission to write into the app's directory    CHXDirSpecifier tempDir = CHXFileSpecUtils::GetSystemTempDirectory();    HX_ASSERT(CHXFileSpecUtils::DirectoryExists(tempDir));    CHXFileSpecifier cacheFileSpec = tempDir.SpecifyChildFile(DEF_CACHE_DB);    CHXString strCachePath = cacheFileSpec.GetPathName();	    pBuffer->Set((UINT8*) (const char *) strCachePath, 1 + strCachePath.GetLength());}#endif/**************************************************************************** * *  Function: * *      CHTTPFileSystem::HXCreateInstance() * *  Purpose: * *      Function implemented by all plugin DLL's to create an instance of *      any of the objects supported by the DLL. This method is similar to *      Window's CoCreateInstance() in its purpose, except that it only *      creates objects from this plugin DLL. * *      NOTE: Aggregation is never used. Therefore an outer unknown is *      not passed to this function, and you do not need to code for this *      situation. * */HX_RESULT STDAPICALLTYPE CHTTPFileSystem::HXCreateInstance(    IUnknown**  /*OUT*/ ppIUnknown){    // Do NOT check for expiration.  Needed for Auto Upgrade.    *ppIUnknown = (IUnknown*)(IHXPlugin*)new CHTTPFileSystem();    if (*ppIUnknown)    {        (*ppIUnknown)->AddRef();        return HXR_OK;    }    return HXR_OUTOFMEMORY;}/**************************************************************************** * *  Function: * *      CHTTPFileSystem::HXShutdown() * *  Purpose: * *      Function implemented by all plugin DLL's to free any *global* *      resources. This method is called just before the DLL is unloaded. * */HX_RESULT STDAPICALLTYPE CHTTPFileSystem::HXShutdown(void){    // Joshe 7/19/2001:    // because HXShutdown sometimes gets called but httpfsys can be loaded     // from CHXIndependentHttp, we need this hack check to work around     // the crashes caused when HXShutdown is called when it shouldn't    // it's easier to fix here than to change plugin handler to query     // CanUnload first, though that is probably the right thing to do eventually    if(FAILED(CanUnload()))    {	return HXR_OK;    }    if (g_pCacheEntry)     {        g_pCacheEntry->close();        delete g_pCacheEntry;        g_pCacheEntry = NULL;    }    return HXR_OK;}/**************************************************************************** *  *  Function: *  *      CanUnload() *  *  Purpose: *  *      Function implemented by all plugin DLL's if it returns HXR_OK  *      then the pluginhandler can unload the DLL * */HX_RESULT CHTTPFileSystem::CanUnload(void){    return (g_nRefCount_http ? HXR_FAIL : HXR_OK);}BEGIN_INTERFACE_LIST(CHTTPFileSystem)    INTERFACE_LIST_ENTRY(IID_IHXPlugin, IHXPlugin)    INTERFACE_LIST_ENTRY(IID_IHXFileSystemObject, IHXFileSystemObject)    INTERFACE_LIST_ENTRY(IID_IHXFileSystemCache, IHXFileSystemCache)    INTERFACE_LIST_ENTRY(IID_IHXHTTPAutoStream, IHXHTTPAutoStream)END_INTERFACE_LISTCHTTPFileSystem::CHTTPFileSystem() :     m_pContext(NULL)    , m_pOptions(NULL){    g_nRefCount_http++;}CHTTPFileSystem::~CHTTPFileSystem(){    g_nRefCount_http--;    HX_RELEASE(m_pContext);    HX_RELEASE(m_pOptions);}/************************************************************************ *  Method: *    IHXPlugin::InitPlugin *  Purpose: *    Initializes the plugin for use. This interface must always be *    called before any other method is called. This is primarily needed *    so that the plugin can have access to the context for creation of *    IHXBuffers and IMalloc. */STDMETHODIMP CHTTPFileSystem::InitPlugin(IUnknown* /*IN*/ pContext){    /* This plugin does not need any context */    HX_RELEASE(m_pContext);    m_pContext = pContext;    if (m_pContext)    {        m_pContext->AddRef();    }    return HXR_OK;}/************************************************************************ *  Method: *    IHXPlugin::GetPluginInfo *  Purpose: *    Returns the basic information about this plugin. Including: * *    unInterfaceCount  the number of standard RMA interfaces *                      supported by this plugin DLL. *    pIIDList          array of IID's for standard RMA interfaces *                      supported by this plugin DLL. *    bLoadMultiple     whether or not this plugin DLL can be loaded *                      multiple times. All File Formats must set *                      this value to TRUE. *    pDescription      which is used in about UIs (can be NULL) *    pCopyright        which is used in about UIs (can be NULL) *    pMoreInfoURL      which is used in about UIs (can be NULL) */STDMETHODIMP CHTTPFileSystem::GetPluginInfo(    REF(BOOL)        /*OUT*/ bLoadMultiple,    REF(const char*) /*OUT*/ pDescription,    REF(const char*) /*OUT*/ pCopyright,    REF(const char*) /*OUT*/ pMoreInfoURL,    REF(ULONG32)     /*OUT*/ ulVersionNumber){    bLoadMultiple = TRUE;   // Must be true for file formats.    pDescription    = zm_pDescription;    pCopyright      = zm_pCopyright;    pMoreInfoURL    = zm_pMoreInfoURL;    ulVersionNumber = TARVER_ULONG32_VERSION;    return HXR_OK;}STDMETHODIMP CHTTPFileSystem::GetFileSystemInfo(    REF(const char*) /*OUT*/ pShortName,    REF(const char*) /*OUT*/ pProtocol){    pShortName  = zm_pShortName;    pProtocol   = zm_pProtocol;    return HXR_OK;}STDMETHODIMPCHTTPFileSystem::InitFileSystem(IHXValues* options){    LOGX ((szDbgTemp, "InitFileSystem()"));    if (options)    {	m_pOptions = options;	m_pOptions->AddRef();    }    return HXR_OK;}///////////////////////////////////////////////////////////////////////////  Method://      IHXFileSystemObject::CreateFile//  Purpose://      TBD//STDMETHODIMP CHTTPFileSystem::CreateFile(    IUnknown**  /*OUT*/ ppFileObject){    LOGX ((szDbgTemp, "CreateFile()"));    CHTTPFileObject* pFileObj = CHTTPFileObject::CreateObject();    if (pFileObj)    {        pFileObj->InitObject(NULL, this, m_pContext, m_pOptions);	if( m_bSaveNextStream )	{	    pFileObj->SetDestinationFile( m_SaveFileName );            m_bSaveNextStream = FALSE;	}        if(HXR_OK == pFileObj->QueryInterface(IID_IUnknown,                                            (void**)ppFileObject))        {            return HXR_OK;        }        return HXR_FAIL;    }    return HXR_OUTOFMEMORY;}///////////////////////////////////////////////////////////////////////////  Method://     CHTTPFileSystem::CreateDir//  Purpose://     TBD//STDMETHODIMP CHTTPFileSystem::CreateDir(    IUnknown**    /*OUT*/ ppDirObject){    return HXR_NOTIMPL;}

⌨️ 快捷键说明

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