dllpath.h
上传用户:dangjiwu
上传日期:2013-07-19
资源大小:42019k
文件大小:13k
源码类别:

Symbian

开发平台:

Visual C++

  1. /* ***** BEGIN LICENSE BLOCK *****
  2.  * Source last modified: $Id: dllpath.h,v 1.5.36.3 2004/07/09 01:43:51 hubbe Exp $
  3.  * 
  4.  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved.
  5.  * 
  6.  * The contents of this file, and the files included with this file,
  7.  * are subject to the current version of the RealNetworks Public
  8.  * Source License (the "RPSL") available at
  9.  * http://www.helixcommunity.org/content/rpsl unless you have licensed
  10.  * the file under the current version of the RealNetworks Community
  11.  * Source License (the "RCSL") available at
  12.  * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
  13.  * will apply. You may also obtain the license terms directly from
  14.  * RealNetworks.  You may not use this file except in compliance with
  15.  * the RPSL or, if you have a valid RCSL with RealNetworks applicable
  16.  * to this file, the RCSL.  Please see the applicable RPSL or RCSL for
  17.  * the rights, obligations and limitations governing use of the
  18.  * contents of the file.
  19.  * 
  20.  * Alternatively, the contents of this file may be used under the
  21.  * terms of the GNU General Public License Version 2 or later (the
  22.  * "GPL") in which case the provisions of the GPL are applicable
  23.  * instead of those above. If you wish to allow use of your version of
  24.  * this file only under the terms of the GPL, and not to allow others
  25.  * to use your version of this file under the terms of either the RPSL
  26.  * or RCSL, indicate your decision by deleting the provisions above
  27.  * and replace them with the notice and other provisions required by
  28.  * the GPL. If you do not delete the provisions above, a recipient may
  29.  * use your version of this file under the terms of any one of the
  30.  * RPSL, the RCSL or the GPL.
  31.  * 
  32.  * This file is part of the Helix DNA Technology. RealNetworks is the
  33.  * developer of the Original Code and owns the copyrights in the
  34.  * portions it created.
  35.  * 
  36.  * This file, and the files included with this file, is distributed
  37.  * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
  38.  * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
  39.  * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
  40.  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
  41.  * ENJOYMENT OR NON-INFRINGEMENT.
  42.  * 
  43.  * Technology Compatibility Kit Test Suite(s) Location:
  44.  *    http://www.helixcommunity.org/content/tck
  45.  * 
  46.  * Contributor(s):
  47.  * 
  48.  * ***** END LICENSE BLOCK ***** */
  49. #ifndef _DLL_PATH
  50. #define _DLL_PATH
  51. #include "hxcom.h"
  52. #include "hxmap.h"
  53. #include "hxstring.h"
  54. #ifdef _MACINTOSH                                                           
  55. #pragma export on                                                          
  56. STDAPI SetDLLAccessPath(const char* pPathDescriptor);
  57. #pragma export off 
  58. #endif
  59. #if defined(HELIX_CONFIG_NOSTATICS)
  60. #include "globals/hxglobals.h"
  61. #endif
  62. /*
  63.  *      Used to identify dll types.  
  64.  */
  65. typedef enum dll_types
  66. {
  67.         DLLTYPE_NOT_DEFINED = 0,              // Arbitrary DLLs (no predefined path used)
  68.         DLLTYPE_PLUGIN,                       // Plug-ins
  69.         DLLTYPE_CODEC,                        // Codecs
  70.         DLLTYPE_ENCSDK,                       // Encoder SDK DLLs 
  71.         DLLTYPE_COMMON,                       // Common libraries       
  72.         DLLTYPE_UPDATE,                       // Setup/Upgrade libraries
  73.         DLLTYPE_OBJBROKR,                     // Special entry for the object broker
  74.         DLLTYPE_RCAPLUGIN,                    // Gemini plugins
  75.         DLLTYPE_NUMBER                        // Not a type, used as number of predefined types.
  76. } DLLTYPES;           
  77. typedef HX_RESULT (HXEXPORT_PTR FPSETDLLACCESSPATH) (const char*);
  78. class DLLAccessPath
  79. {
  80. public:
  81.     DLLAccessPath();
  82.     virtual ~DLLAccessPath();
  83.     // This class is only ref-counted if it is used as such. 
  84.     // Most of the system uses this as a non-refcounted class.
  85.     STDMETHOD_(ULONG32,AddRef)  (THIS);
  86.     STDMETHOD_(ULONG32,Release) (THIS);
  87.     HX_RESULT SetAccessPaths(const char* pPathDescriptor);  
  88.     HX_RESULT SetPath(UINT16 nLibType, const char* szPath);
  89.     HX_RESULT SetPath(const char* szLibType, const char* szPath);
  90.     const char* GetPath(UINT16 nLibType);
  91.     const char* GetPath(const char* szLibType);
  92.     const char* GetLibTypeName(UINT16 nLibType);
  93.     HX_RESULT PassDLLAccessPath(FPSETDLLACCESSPATH pSetDLLAccessPath);
  94.     HX_RESULT AddPathToEnvironment(const char* szPath);
  95.     HX_RESULT RestoreEnvironment();
  96.     UINT32 GetNumPaths() {return m_mapPathes.GetCount();}
  97. protected:
  98.     static const char* const zm_pszDllTypeNames[DLLTYPE_NUMBER];
  99. private:
  100.     LONG32               m_lRefCount;
  101.     CHXMapStringToString m_mapPathes;
  102.     CHXString            m_strPathEnvVar;
  103. };
  104. extern DLLAccessPath* GetDLLAccessPath();  
  105. class DLLAccessDestructor
  106. {
  107. public:
  108.     DLLAccessDestructor() {};
  109.     ~DLLAccessDestructor() 
  110.     { 
  111. #ifndef _VXWORKS
  112.         if (GetDLLAccessPath())
  113.         {
  114.             GetDLLAccessPath()->Release(); 
  115.         }
  116. #endif
  117.     }
  118. };
  119. //
  120. // Macros for setting DLL loading paths
  121. //
  122. #ifndef _VXWORKS
  123. #if defined(_STATICALLY_LINKED) && !defined(HELIX_FEATURE_SERVER)
  124. // We need this since many DLLs have this listed
  125. // as an export, so we have to have it defined
  126. #define ENABLE_DLLACCESS_PATHS(GLOBAL)                           
  127. STDAPI ENTRYPOINT(SetDLLAccessPath)(const char* pPathDescriptor) 
  128. {                                                                
  129.     return HXR_OK;                                               
  130. }
  131. #define ENABLE_MULTILOAD_DLLACCESS_PATHS(GLOBAL)                 
  132. STDAPI ENTRYPOINT(SetDLLAccessPath)(const char* pPathDescriptor) 
  133. {                                                                
  134.         return HXR_OK;                                           
  135. }
  136. #elif defined(HELIX_CONFIG_NOSTATICS)
  137. #define ENABLE_DLLACCESS_PATHS(GLOBAL)                                      
  138.     static const DLLAccessPath* const _g_##GLOBAL = NULL;                   
  139.                                                                             
  140.     DLLAccessPath* ENTRYPOINT(GetDLLAccessPath)()                           
  141.     {                                                                       
  142.         return &HXGlobalDLLAccessPath::Get(&_g_##GLOBAL);                    
  143.     }                                                                       
  144.                                                                             
  145.     STDAPI ENTRYPOINT(SetDLLAccessPath)(const char* pPathDescriptor)        
  146.     {                                                                       
  147.         return (GetDLLAccessPath()->SetAccessPaths(pPathDescriptor));       
  148.     }                                                                       
  149. #else /* #if defined(_STATICALLY_LINKED) && !defined(HELIX_FEATURE_SERVER) */
  150. #define ENABLE_DLLACCESS_PATHS(GLOBAL)                                      
  151.     DLLAccessPath GLOBAL;                                                   
  152.                                                                             
  153.     DLLAccessPath* ENTRYPOINT(GetDLLAccessPath)()                           
  154.     {                                                                       
  155.         return &GLOBAL;                                                     
  156.     }                                                                       
  157.                                                                             
  158.     STDAPI ENTRYPOINT(SetDLLAccessPath)(const char* pPathDescriptor)        
  159.     {                                                                       
  160.         return (GetDLLAccessPath()->SetAccessPaths(pPathDescriptor));       
  161.     }                                                                       
  162. #ifdef _UNIX
  163. #define ENABLE_MULTILOAD_DLLACCESS_PATHS(GLOBAL)                            
  164.     DLLAccessPath* GLOBAL = NULL;                                           
  165.                                                                             
  166.     DLLAccessPath* GetDLLAccessPath()                                       
  167.     {                                                                       
  168.         if (!GLOBAL)                                                        
  169.         {                                                                   
  170.             GLOBAL = new DLLAccessPath();                                   
  171.             GLOBAL->AddRef();                                               
  172.         }                                                                   
  173.         return GLOBAL;                                                      
  174.     }                                                                       
  175.                                                                             
  176.     STDAPI ENTRYPOINT(SetDLLAccessPath)(const char* pPathDescriptor)                
  177.     {                                                                       
  178.         if (!GLOBAL)                                                        
  179.         {                                                                   
  180.             GLOBAL = new DLLAccessPath();                                   
  181.             GLOBAL->AddRef();                                               
  182.         }                                                                   
  183.                                                                             
  184.         return (GLOBAL->SetAccessPaths(pPathDescriptor));                   
  185.     }
  186.                                                                             
  187. #else /* #ifdef _UNIX */
  188. #define ENABLE_MULTILOAD_DLLACCESS_PATHS(GLOBAL)                            
  189.     DLLAccessPath* GLOBAL = NULL;                                           
  190.     DLLAccessDestructor GLOBALDestructor;                                   
  191.                                                                             
  192.     DLLAccessPath* GetDLLAccessPath()                                       
  193.     {                                                                       
  194.         if (!GLOBAL)                                                        
  195.         {                                                                   
  196.             GLOBAL = new DLLAccessPath();                                   
  197.             GLOBAL->AddRef();                                               
  198.         }                                                                   
  199.         return GLOBAL;                                                      
  200.     }                                                                       
  201.                                                                             
  202.     STDAPI ENTRYPOINT(SetDLLAccessPath)(const char* pPathDescriptor)                
  203.     {                                                                       
  204.         if (!GLOBAL)                                                        
  205.         {                                                                   
  206.             GLOBAL = new DLLAccessPath();                                   
  207.             GLOBAL->AddRef();                                               
  208.         }                                                                   
  209.                                                                             
  210.         return (GLOBAL->SetAccessPaths(pPathDescriptor));                   
  211.     }                                                                       
  212. #endif /* #ifdef _UNIX #else */
  213. #endif /* #if defined(_STATICALLY_LINKED) #else */
  214. #else /* #ifndef _VXWORKS */
  215. #define ENABLE_DLLACCESS_PATHS(GLOBAL)                                      
  216.     STDAPI ENTRYPOINT(SetDLLAccessPath)(const char* pPathDescriptor)        
  217.     {                                                                       
  218.         return 0;                                                           
  219.     }                                                                       
  220. #ifdef _SERVER
  221. #define ENABLE_MULTILOAD_DLLACCESS_PATHS(GLOBAL)                            
  222.     STDAPI ENTRYPOINT(SetDLLAccessPath)(const char* pPathDescriptor)        
  223.     {                                                                       
  224.         return 0;                                                           
  225.     }                                                                       
  226. #else
  227. #define ENABLE_MULTILOAD_DLLACCESS_PATHS(GLOBAL)                            
  228.     STDAPI ENTRYPOINT(SetDLLAccessPath)(const char* pPathDescriptor)        
  229.     {                                                                       
  230.         return 0;                                                           
  231.     }                                                                       
  232. #endif
  233. #endif /* #ifndef _VXWORKS #else */
  234. #endif /* #ifndef _DLL_PATH */