1 // 2 // VMime library (http://www.vmime.org) 3 // Copyright (C) 2002-2013 Vincent Richard <vincent@vmime.org> 4 // 5 // This program is free software; you can redistribute it and/or 6 // modify it under the terms of the GNU General Public License as 7 // published by the Free Software Foundation; either version 3 of 8 // the License, or (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 // General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License along 16 // with this program; if not, write to the Free Software Foundation, Inc., 17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 // 19 // Linking this library statically or dynamically with other modules is making 20 // a combined work based on this library. Thus, the terms and conditions of 21 // the GNU General Public License cover the whole combination. 22 // 23 24 #ifndef VMIME_NET_TLS_OPENSSL_OPENSSLINITIALIZER_HPP_INCLUDED 25 #define VMIME_NET_TLS_OPENSSL_OPENSSLINITIALIZER_HPP_INCLUDED 26 27 28 #ifndef VMIME_BUILDING_DOC 29 30 31 #include "vmime/config.hpp" 32 33 #include <vector> 34 35 36 #if VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_TLS_SUPPORT && VMIME_TLS_SUPPORT_LIB_IS_OPENSSL 37 38 39 #include "vmime/utility/sync/criticalSection.hpp" 40 41 42 namespace vmime { 43 namespace net { 44 namespace tls { 45 46 47 /** Class responsible for setting up OpenSSL 48 */ 49 class OpenSSLInitializer 50 { 51 public: 52 53 /** Automatically initialize OpenSSL 54 */ 55 class autoInitializer 56 { 57 public: 58 59 autoInitializer(); 60 ~autoInitializer(); 61 }; 62 63 protected: 64 65 class oneTimeInitializer 66 { 67 public: 68 69 oneTimeInitializer(); 70 ~oneTimeInitializer(); 71 }; 72 73 74 /** Initializes the OpenSSL lib 75 */ 76 static void initialize(); 77 78 /** Shutdown the OpenSSL lib 79 */ 80 static void uninitialize(); 81 82 83 static shared_ptr <vmime::utility::sync::criticalSection> getMutex(); 84 85 enum 86 { 87 SEEDSIZE = 256 88 }; 89 90 91 // OpenSSL multithreading support 92 static void lock(int mode, int n, const char* file, int line); 93 static unsigned long id(); 94 95 private: 96 97 static shared_ptr <vmime::utility::sync::criticalSection >* sm_mutexes; 98 }; 99 100 101 } // tls 102 } // net 103 } // vmime 104 105 106 #endif // VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_TLS_SUPPORT && VMIME_TLS_SUPPORT_LIB_IS_OPENSSL 107 108 #endif // VMIME_BUILDING_DOC 109 110 #endif // VMIME_NET_TLS_OPENSSL_OPENSSLINITIALIZER_HPP_INCLUDED 111 112