dllpath.h
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:12k
源码类别:

Symbian

开发平台:

C/C++

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