reSIProcate/rutil  9694
OpenSSLInit.hxx
Go to the documentation of this file.
00001 #if !defined(RESIP_OPENSSLINIT_HXX)
00002 #define RESIP_OPENSSLINIT_HXX 
00003 
00004 #if defined(HAVE_CONFIG_H)
00005   #include "config.h"
00006 #endif
00007 
00008 #include "rutil/Mutex.hxx"
00009 #include "rutil/RWMutex.hxx"
00010 #include "rutil/Data.hxx"
00011 #include <cassert>
00012 #include <vector>
00013 
00014 // This will not be built or installed if USE_SSL is not defined; if you are 
00015 // building against a source tree, and including this, and getting linker 
00016 // errors, the source tree was probably built with this flag off. Either stop
00017 // including this file, or re-build the source tree with SSL enabled.
00018 //#ifdef USE_SSL
00019 
00020 struct CRYPTO_dynlock_value
00021 {
00022       resip::Mutex* mutex;
00023 };
00024 
00025 extern "C"
00026 {
00027   void resip_OpenSSLInit_lockingFunction(int mode, int n, const char* file, int line);
00028   unsigned long resip_OpenSSLInit_threadIdFunction();
00029   CRYPTO_dynlock_value* resip_OpenSSLInit_dynCreateFunction(char* file, int line);
00030   void resip_OpenSSLInit_dynDestroyFunction(CRYPTO_dynlock_value*, const char* file, int line);
00031   void resip_OpenSSLInit_dynLockFunction(int mode, struct CRYPTO_dynlock_value*, const char* file, int line);
00032 }
00033 
00034 namespace resip
00035 {
00036 
00037 class OpenSSLInit
00038 {
00039    public:
00040       static bool init();
00041    private:
00042            OpenSSLInit();
00043            ~OpenSSLInit();
00044       friend void ::resip_OpenSSLInit_lockingFunction(int mode, int n, const char* file, int line);
00045       friend unsigned long ::resip_OpenSSLInit_threadIdFunction();
00046       friend CRYPTO_dynlock_value* ::resip_OpenSSLInit_dynCreateFunction(char* file, int line);
00047       friend void ::resip_OpenSSLInit_dynDestroyFunction(CRYPTO_dynlock_value*, const char* file, int line);
00048       friend void ::resip_OpenSSLInit_dynLockFunction(int mode, struct CRYPTO_dynlock_value*, const char* file, int line);
00049 
00050       static Mutex* mMutexes;    
00051       static volatile bool mInitialized;
00052 };
00053 static bool invokeOpenSSLInit = OpenSSLInit::init();
00054 
00055 }
00056 
00057 //#endif
00058 
00059 #endif