Skip to content
Browse files

Workaround for broken versions of Cabal, including one that comes wit…

…h ghc-7.0.4. FIXES #8
  • Loading branch information...
1 parent 7e6efe8 commit 24f927ef7cbe1b2be382846e03f150ee605aa789 @phonohawk phonohawk committed Apr 6, 2012
Showing with 47 additions and 30 deletions.
  1. +16 −0 NEWS
  2. +9 −9 OpenSSL/BN.hsc
  3. +2 −1 OpenSSL/{DH.hsc → DH.hs}
  4. +0 −3 OpenSSL/DSA.hsc
  5. +2 −3 OpenSSL/EVP/Internal.hsc
  6. +0 −3 OpenSSL/RSA.hsc
  7. +7 −11 OpenSSL/Utils.hs
  8. +1 −0 OpenSSL/{X509.hsc → X509.hs}
  9. +10 −0 cbits/HsOpenSSL.h
View
16 NEWS
@@ -1,5 +1,21 @@
-*- coding: utf-8 -*-
+Changes from 0.10.1.4 to 0.10.2
+-------------------------------
+* Merged #9 "Add raw pointer read/write operations" by Iavor
+ S. Diatchki:
+
+ - OpenSSL.Session.readPtr
+ - OpenSSL.Session.tryReadPtr
+ - OpenSSL.Session.writePtr
+ - OpenSSL.Session.tryWritePtr
+
+* Fixed #8 "HsOpenSSL 0.10.1.4 won't build" reported by vcxp:
+
+ - Workaround for broken versions of Cabal, including one that comes
+ with ghc-7.0.4.
+
+
Changes from 0.10.1.3 to 0.10.1.4
---------------------------------
* Fixed #7 "Haskell Platform 2011.4 Support", reported by stepcut:
View
18 OpenSSL/BN.hsc
@@ -50,20 +50,20 @@ import Foreign.Storable
import OpenSSL.Utils
import System.IO.Unsafe
-#ifndef __GLASGOW_HASKELL__
-import Control.Monad
-import Foreign.C
-#else
+#ifdef __GLASGOW_HASKELL__
import Foreign.C.Types
import GHC.Base
-#if __GLASGOW_HASKELL__ < 612
+# if MIN_VERSION_integer_gmp(0,2,0)
+import GHC.Integer.GMP.Internals
+# else
import GHC.Num
import GHC.Prim
import GHC.Integer.Internals
import GHC.IOBase (IO(..))
+# endif
#else
-import GHC.Integer.GMP.Internals
-#endif
+import Control.Monad
+import Foreign.C
#endif
-- |'BigNum' is an opaque object representing a big number.
@@ -282,11 +282,11 @@ mpiToBN mpi = do
BS.useAsCStringLen mpi (\(ptr, len) -> do
_mpi2bn ptr (fromIntegral len) nullPtr) >>= return . wrapBN
--- | Convert an Integer to an MPI. SEe bnToMPI for the format
+-- | Convert an Integer to an MPI. See bnToMPI for the format
integerToMPI :: Integer -> IO BS.ByteString
integerToMPI v = bracket (integerToBN v) (_free . unwrapBN) bnToMPI
--- | Convert an MPI to an Integer. SEe bnToMPI for the format
+-- | Convert an MPI to an Integer. See bnToMPI for the format
mpiToInteger :: BS.ByteString -> IO Integer
mpiToInteger mpi = do
bn <- mpiToBN mpi
View
3 OpenSSL/DH.hsc → OpenSSL/DH.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
-- | Diffie-Hellman key exchange
module OpenSSL.DH
( DHP
@@ -17,7 +18,7 @@ import Data.ByteString (ByteString)
import qualified Data.ByteString.Internal as BS
import Control.Applicative ((<$>))
import Foreign.Ptr (Ptr, nullPtr)
-#if __GLASGOW_HASKELL__ >= 703
+#if MIN_VERSION_base(4,5,0)
import Foreign.C.Types (CInt(..))
#else
import Foreign.C.Types (CInt)
View
3 OpenSSL/DSA.hsc
@@ -40,9 +40,6 @@ import Foreign.C (CString)
import Foreign.C.Types
import OpenSSL.BN
import OpenSSL.Utils
-#if !(defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 612)
-import System.IO.Unsafe
-#endif
-- | The type of a DSA public key, includes parameters p, q, g and public.
newtype DSAPubKey = DSAPubKey (ForeignPtr DSA)
View
5 OpenSSL/EVP/Internal.hsc
@@ -1,4 +1,4 @@
-module OpenSSL.EVP.Internal (
+module OpenSSL.EVP.Internal (
Cipher(..),
EVP_CIPHER,
withCipherPtr,
@@ -51,7 +51,7 @@ import qualified Data.ByteString.Lazy.Internal as L8
import Control.Applicative ((<$>))
import Control.Exception (mask, mask_, bracket_, onException)
import Foreign.C.Types (CChar)
-#if __GLASGOW_HASKELL__ >= 703
+#if MIN_VERSION_base(4,5,0)
import Foreign.C.Types (CInt(..), CUInt(..), CSize(..))
#else
import Foreign.C.Types (CInt, CUInt, CSize)
@@ -306,4 +306,3 @@ unsafePKeyToPtr (VaguePKey pkey) = Unsafe.unsafeForeignPtrToPtr pkey
touchPKey :: VaguePKey -> IO ()
touchPKey (VaguePKey pkey) = touchForeignPtr pkey
-
View
3 OpenSSL/RSA.hsc
@@ -37,9 +37,6 @@ import System.IO.Unsafe (unsafePerformIO)
import Foreign.C
import OpenSSL.BN
import OpenSSL.Utils
-#if !(defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__)
-import System.IO.Unsafe
-#endif
-- |@'RSAPubKey'@ is an opaque object that represents RSA public key.
newtype RSAPubKey = RSAPubKey (ForeignPtr RSA)
View
18 OpenSSL/Utils.hs
@@ -1,4 +1,3 @@
-{-# LANGUAGE CPP #-}
module OpenSSL.Utils
( failIfNull
, failIfNull_
@@ -10,14 +9,12 @@ module OpenSSL.Utils
, peekCStringCLen
)
where
-
-import Foreign
-import Foreign.C
-import OpenSSL.ERR
-import Data.List (unfoldr)
-#if !(defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__)
-import Data.Bits ((.&.), (.|.), shiftR, shiftL)
-#endif
+import Foreign.C.String
+import Foreign.C.Types
+import Foreign.Ptr
+import OpenSSL.ERR
+import Data.Bits
+import Data.List
failIfNull :: Ptr a -> IO (Ptr a)
failIfNull ptr
@@ -97,7 +94,6 @@ fromHex = foldl step 0 where
byteHex 'F' = 15
byteHex _ = undefined
-
peekCStringCLen :: (Ptr CChar, CInt) -> IO String
peekCStringCLen (p, n)
- = peekCStringLen (p, fromIntegral n)
+ = peekCStringLen (p, fromIntegral n)
View
1 OpenSSL/X509.hsc → OpenSSL/X509.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
{-# OPTIONS_HADDOCK prune #-}
-- |An interface to X.509 certificate.
View
10 cbits/HsOpenSSL.h
@@ -20,6 +20,16 @@
#include <openssl/x509v3.h>
#include <openssl/dsa.h>
+/* A dirty hack to work around for broken versions of Cabal:
+ * https://github.com/phonohawk/HsOpenSSL/issues/8
+ *
+ * The trick is to abuse the fact that -Icbits is always passed to
+ * hsc2hs so we can reach the cabal_macros.h from cbits.
+ */
+#if !defined(MIN_VERSION_base)
+# include "../dist/build/autogen/cabal_macros.h"
+#endif
+
/* OpenSSL ********************************************************************/
void HsOpenSSL_OpenSSL_add_all_algorithms();
void HsOpenSSL_OPENSSL_free(void* ptr);

0 comments on commit 24f927e

Please sign in to comment.
Something went wrong with that request. Please try again.