[pan2: 173/268] * fixed mt of pthreads * added all #ifdefs for libssl and crypto



commit 63efd52b33ca595261dcf079be5ce0fa33382a81
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date:   Sun Oct 23 03:47:24 2011 +0200

    * fixed mt of pthreads
    * added all #ifdefs for libssl and crypto

 pan/tasks/socket-impl-main.cc    |   15 ++++++++-------
 pan/tasks/socket-impl-main.h     |    6 +++++-
 pan/tasks/socket-impl-openssl.cc |    4 ++++
 pan/tasks/socket-impl-openssl.h  |   16 ++++++++++------
 4 files changed, 27 insertions(+), 14 deletions(-)
---
diff --git a/pan/tasks/socket-impl-main.cc b/pan/tasks/socket-impl-main.cc
index a6da35d..ff6bc38 100644
--- a/pan/tasks/socket-impl-main.cc
+++ b/pan/tasks/socket-impl-main.cc
@@ -34,9 +34,6 @@
 #include <cerrno>
 #include <cstring>
 
-#include <openssl/crypto.h>
-#include <openssl/ssl.h>
-
 #include <pan/general/log.h>
 #include <pan/general/macros.h>
 #include <pan/general/worker-pool.h>
@@ -125,10 +122,12 @@ namespace pan
 
     void do_work ()
     {
-      if (use_ssl)
-        socket = new GIOChannelSocketSSL ();
-      else
-        socket = new GIOChannelSocket ();
+      #ifdef HAVE_OPENSSL
+        if (use_ssl)
+          socket = new GIOChannelSocketSSL ();
+        else
+      #endif
+          socket = new GIOChannelSocket ();
       ok = socket->open (host, port, err);
     }
 
@@ -143,6 +142,7 @@ namespace pan
 }
 
 
+#ifdef HAVE_OPENSSL
 namespace
 {
   static pthread_mutex_t *lock_cs=0;
@@ -172,6 +172,7 @@ namespace
     OPENSSL_free(lock_cs);
   }
 }
+#endif
 
 SocketCreator :: SocketCreator()
 {
diff --git a/pan/tasks/socket-impl-main.h b/pan/tasks/socket-impl-main.h
index c1b8787..881aba5 100644
--- a/pan/tasks/socket-impl-main.h
+++ b/pan/tasks/socket-impl-main.h
@@ -35,7 +35,11 @@
 #include <pan/general/string-view.h>
 #include <pan/general/worker-pool.h>
 #include "socket.h"
-#include "socket-impl-openssl.h"
+#ifdef HAVE_OPENSSL
+  #include <openssl/crypto.h>
+  #include <openssl/ssl.h>
+  #include "socket-impl-openssl.h"
+#endif
 #include "socket-impl-gio.h"
 
 namespace pan
diff --git a/pan/tasks/socket-impl-openssl.cc b/pan/tasks/socket-impl-openssl.cc
index 1f54b02..9ed76b4 100644
--- a/pan/tasks/socket-impl-openssl.cc
+++ b/pan/tasks/socket-impl-openssl.cc
@@ -99,6 +99,8 @@ using namespace pan;
 *****
 ****/
 
+#ifdef HAVE_OPENSSL // without libssl this class is just a stub....
+
 GIOChannelSocketSSL :: GIOChannelSocketSSL ():
    _channel (0),
    _tag_watch (0),
@@ -791,3 +793,5 @@ GIOChannelSocketSSL :: ssl_get_iochannel(GIOChannel *handle, gboolean verify)
   return 0;
 
 }
+#endif  //HAVE_OPENSSL
+
diff --git a/pan/tasks/socket-impl-openssl.h b/pan/tasks/socket-impl-openssl.h
index b5d9138..fcf8f23 100644
--- a/pan/tasks/socket-impl-openssl.h
+++ b/pan/tasks/socket-impl-openssl.h
@@ -25,12 +25,14 @@
 #include <glib/gstring.h>
 #include <pan/tasks/socket.h>
 
-#include <openssl/crypto.h>
-#include <openssl/x509.h>
-#include <openssl/x509v3.h>
-#include <openssl/pem.h>
-#include <openssl/ssl.h>
-#include <openssl/err.h>
+#ifdef HAVE_OPENSSL
+  #include <openssl/crypto.h>
+  #include <openssl/x509.h>
+  #include <openssl/x509v3.h>
+  #include <openssl/pem.h>
+  #include <openssl/ssl.h>
+  #include <openssl/err.h>
+#endif
 
 #include "socket-impl-gio.h"
 
@@ -46,6 +48,7 @@ namespace pan
     public:
       GIOChannelSocketSSL ();
       virtual ~GIOChannelSocketSSL ();
+#ifdef HAVE_OPENSSL
       virtual bool open (const StringView& address, int port, std::string& setme_err);
       virtual void write_command (const StringView& chars, Listener *);
       virtual void get_host (std::string& setme) const;
@@ -76,6 +79,7 @@ namespace pan
 
     private:
       GIOChannel* ssl_get_iochannel(GIOChannel *handle, gboolean verify=true);
+#endif
   };
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]