Hello community, here is the log from the commit of package ghc-nfc for openSUSE:Factory checked in at 2017-08-31 20:57:32 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-nfc (Old) and /work/SRC/openSUSE:Factory/.ghc-nfc.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-nfc" Thu Aug 31 20:57:32 2017 rev:2 rq:513440 version:0.1.0 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-nfc/ghc-nfc.changes 2017-04-12 18:08:04.491029521 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-nfc.new/ghc-nfc.changes 2017-08-31 20:57:33.454193276 +0200 @@ -1,0 +2,5 @@ +Thu Jul 27 14:06:43 UTC 2017 - [email protected] + +- Update to version 0.1.0. + +------------------------------------------------------------------- Old: ---- nfc-0.0.1.tar.gz New: ---- nfc-0.1.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-nfc.spec ++++++ --- /var/tmp/diff_new_pack.bZ2TXO/_old 2017-08-31 20:57:34.298074709 +0200 +++ /var/tmp/diff_new_pack.bZ2TXO/_new 2017-08-31 20:57:34.310073022 +0200 @@ -18,7 +18,7 @@ %global pkg_name nfc Name: ghc-%{pkg_name} -Version: 0.0.1 +Version: 0.1.0 Release: 0 Summary: Libnfc bindings License: SUSE-Public-Domain ++++++ nfc-0.0.1.tar.gz -> nfc-0.1.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nfc-0.0.1/CHANGELOG.md new/nfc-0.1.0/CHANGELOG.md --- old/nfc-0.0.1/CHANGELOG.md 2016-12-09 08:24:58.000000000 +0100 +++ new/nfc-0.1.0/CHANGELOG.md 2016-12-20 19:00:25.000000000 +0100 @@ -1,3 +1,3 @@ -# 0.0.0 +# 0.0.1 * Initial release diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nfc-0.0.1/cbits/NFC.c new/nfc-0.1.0/cbits/NFC.c --- old/nfc-0.0.1/cbits/NFC.c 1970-01-01 01:00:00.000000000 +0100 +++ new/nfc-0.1.0/cbits/NFC.c 2017-02-22 18:33:33.000000000 +0100 @@ -0,0 +1,33 @@ +#include "nfc/nfc.h" +#include "nfc/nfc-types.h" + +/* These functions are needed because the libnfc author used #pragma pack(1). + * c2hs does not recognize this compiler directive. + */ +nfc_modulation *hs_nfc_get_nm(nfc_target *t) { return &t->nm; } + +size_t hs_nfc_target_size() { return sizeof(nfc_target); } + +uint8_t *hs_nfc_get_nai_abtAtqa(nfc_target *t) { return t->nti.nai.abtAtqa; } +uint8_t hs_nfc_get_nai_btSak(nfc_target *t) { return t->nti.nai.btSak; } +size_t hs_nfc_get_nai_szUidLen(nfc_target *t) { return t->nti.nai.szUidLen; } +uint8_t *hs_nfc_get_nai_abtUid(nfc_target *t) { return t->nti.nai.abtUid; } +size_t hs_nfc_get_nai_szAtsLen(nfc_target *t) { return t->nti.nai.szAtsLen; } +uint8_t *hs_nfc_get_nai_abtAts(nfc_target *t) { return t->nti.nai.abtAts; } + +/* Normally I would have c2hs make this for me, but I need to return Nothing or + * Just NFCTarget based on the return value, which c2hs does not support at this + * time. + */ +int __wrapped__nfc_initiator_select_passive_target (nfc_device *pnd, + const nfc_modulation *nm, + const uint8_t *pbtInitData, + const size_t szInitData, + nfc_target *pnt) +{ + return nfc_initiator_select_passive_target (pnd, + *nm, + pbtInitData, + szInitData, + pnt); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nfc-0.0.1/examples/print-mifare-uid-forever.hs new/nfc-0.1.0/examples/print-mifare-uid-forever.hs --- old/nfc-0.0.1/examples/print-mifare-uid-forever.hs 2016-12-14 19:34:18.000000000 +0100 +++ new/nfc-0.1.0/examples/print-mifare-uid-forever.hs 2017-02-22 18:32:27.000000000 +0100 @@ -16,6 +16,9 @@ Just d -> do void $ initiatorInit d forever $ do - let nfcMod = NFCModulation NmtIso14443a Nbr106 - (_, NFCTargetISO14443a info) <- initiatorSelectPassiveTarget d nfcMod Nothing - C8.putStrLn $ encode $ iso14443aAbtUid info + let nfcMod = NFCModulation NmtIso14443a Nbr106 + maybeTarget <- initiatorSelectPassiveTarget d nfcMod Nothing + -- OR: maybeTarget <- initiatorPollTarget d [nfcMod] 7 5 + case maybeTarget of + Just (NFCTargetISO14443a info) -> C8.putStrLn . encode $ iso14443aAbtUid info + _ -> return () diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nfc-0.0.1/nfc.cabal new/nfc-0.1.0/nfc.cabal --- old/nfc-0.0.1/nfc.cabal 2016-12-20 18:58:27.000000000 +0100 +++ new/nfc-0.1.0/nfc.cabal 2017-02-22 19:23:23.000000000 +0100 @@ -1,9 +1,9 @@ --- This file has been generated from package.yaml by hpack version 0.15.0. +-- This file has been generated from package.yaml by hpack version 0.17.0. -- -- see: https://github.com/sol/hpack name: nfc -version: 0.0.1 +version: 0.1.0 synopsis: libnfc bindings description: nfc is a set of bindings to libnfc category: Bindings @@ -33,6 +33,8 @@ hs-source-dirs: src ghc-options: -Wall + c-sources: + cbits/NFC.c extra-libraries: nfc build-depends: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nfc-0.0.1/package.yaml new/nfc-0.1.0/package.yaml --- old/nfc-0.0.1/package.yaml 2016-12-20 18:58:25.000000000 +0100 +++ new/nfc-0.1.0/package.yaml 2017-02-22 19:23:05.000000000 +0100 @@ -1,6 +1,6 @@ name: nfc synopsis: libnfc bindings -version: '0.0.1' +version: '0.1.0' license: PublicDomain maintainer: John Galt <[email protected]> category: Bindings @@ -29,6 +29,7 @@ - Bindings.NFC extra-libraries: - nfc + c-sources: cbits/* executables: print-mifare-uid-forever: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nfc-0.0.1/src/Bindings/NFC.chs new/nfc-0.1.0/src/Bindings/NFC.chs --- old/nfc-0.0.1/src/Bindings/NFC.chs 2016-12-20 18:53:22.000000000 +0100 +++ new/nfc-0.1.0/src/Bindings/NFC.chs 2017-02-22 18:32:08.000000000 +0100 @@ -13,12 +13,12 @@ , initiatorPollTarget ) where -import Control.Monad ((>=>)) +import Control.Monad ((<=<)) import Data.ByteString (ByteString, packCStringLen) import Data.Word (Word8, Word16) import Foreign.C.String (withCStringLen) import Foreign.C.Types (CUChar(..)) -import Foreign.ForeignPtr (newForeignPtr) +import Foreign.ForeignPtr (newForeignPtr, withForeignPtr) import Foreign.Ptr (Ptr, castPtr, nullPtr) import Foreign.Marshal.Alloc (alloca) import Foreign.Marshal.Array (allocaArray, pokeArray) @@ -41,7 +41,7 @@ data NFCTarget = NFCTargetISO14443a NFCISO14443aInfo outNfcCtx :: Ptr (Ptr ()) -> IO NFCContextPtr -outNfcCtx = peek >=> newForeignPtr nfc_exit +outNfcCtx = newForeignPtr nfc_exit <=< peek outNfcDev :: Ptr () -> IO (Maybe NFCDevicePtr) outNfcDev = maybePeek $ newForeignPtr nfc_close @@ -50,8 +50,8 @@ inMaybeStrLen Nothing f = f (nullPtr, 0) inMaybeStrLen (Just str) f = withCStringLen str $ \(ptr, len) -> f (castPtr ptr, fromIntegral len) -inNFCMod :: Num a => [NFCModulation] -> ((Ptr NFCModulation, a) -> IO b) -> IO b -inNFCMod nfcMod f = do +inNfcMod :: Num a => [NFCModulation] -> ((Ptr NFCModulation, a) -> IO b) -> IO b +inNfcMod nfcMod f = do let len = length nfcMod allocaArray len $ \ptr -> do @@ -61,6 +61,24 @@ #include "nfc/nfc.h" #include "nfc/nfc-types.h" +#c + +nfc_modulation *hs_nfc_get_nm(nfc_target *t); +size_t hs_nfc_target_size(); +uint8_t *hs_nfc_get_nai_abtAtqa(nfc_target *t); +uint8_t hs_nfc_get_nai_btSak(nfc_target *t); +size_t hs_nfc_get_nai_szUidLen(nfc_target *t); +uint8_t *hs_nfc_get_nai_abtUid(nfc_target *t); +size_t hs_nfc_get_nai_szAtsLen(nfc_target *t); +uint8_t *hs_nfc_get_nai_abtAts(nfc_target *t); +int __wrapped__nfc_initiator_select_passive_target (nfc_device *, + const nfc_modulation *, + const uint8_t *, + const size_t, + nfc_target *); + +#endc + {#enum nfc_modulation_type as NFCModulationType {underscoreToCase} deriving (Eq,Show)#} {#enum nfc_baud_rate as NFCBaudRate {underscoreToCase} deriving (Eq, Show)#} @@ -79,29 +97,39 @@ {#fun nfc_initiator_init as initiatorInit {`NFCDevicePtr'} -> `Int'#} -{#fun nfc_initiator_select_passive_target as initiatorSelectPassiveTarget -{`NFCDevicePtr', with* %`NFCModulation', inMaybeStrLen* `Maybe String'&, alloca- `NFCTarget' peek*} -> `Int'#} - -{#fun nfc_initiator_poll_target as initiatorPollTarget -{`NFCDevicePtr', inNFCMod* `[NFCModulation]'&, `Word8', `Word8', alloca- `NFCTarget' peek*} -> `Int'#} - -#c - -/* These functions are needed because the libnfc author used #pragma pack(1). - * c2hs does not recognize this compiler directive. - */ -nfc_modulation *hs_nfc_get_nm(nfc_target *t) { return &t->nm; } - -size_t hs_nfc_target_size() { return sizeof(nfc_target); } - -uint8_t *hs_nfc_get_nai_abtAtqa(nfc_target *t) { return t->nti.nai.abtAtqa; } -uint8_t hs_nfc_get_nai_btSak(nfc_target *t) { return t->nti.nai.btSak; } -size_t hs_nfc_get_nai_szUidLen(nfc_target *t) { return t->nti.nai.szUidLen; } -uint8_t *hs_nfc_get_nai_abtUid(nfc_target *t) { return t->nti.nai.abtUid; } -size_t hs_nfc_get_nai_szAtsLen(nfc_target *t) { return t->nti.nai.szAtsLen; } -uint8_t *hs_nfc_get_nai_abtAts(nfc_target *t) { return t->nti.nai.abtAts; } - -#endc +initiatorSelectPassiveTarget :: NFCDevicePtr -> NFCModulation -> Maybe String -> IO (Maybe NFCTarget) +initiatorSelectPassiveTarget dev nfcMod initData = + withForeignPtr dev $ \devPtr -> + with nfcMod $ \nfcModPtr -> + inMaybeStrLen initData $ \(strPtr, strLen) -> + alloca $ \target -> do + returnValue <- {#call __wrapped__nfc_initiator_select_passive_target#} + devPtr + nfcModPtr + strPtr + strLen + target + + if returnValue /= 1 + then return Nothing + else (return . Just <=< peek) target + +initiatorPollTarget :: NFCDevicePtr -> [NFCModulation] -> Word8 -> Word8 -> IO (Maybe NFCTarget) +initiatorPollTarget dev nfcMod numPolling period = do + withForeignPtr dev $ \devPtr -> + inNfcMod nfcMod $ \(nfcModArray, nfcModLen) -> + alloca $ \target -> do + returnValue <- {#call nfc_initiator_poll_target#} + devPtr + nfcModArray + nfcModLen + (fromIntegral numPolling) + (fromIntegral period) + target + + if returnValue /= 1 + then return Nothing + else (return . Just <=< peek) target decodeIso14443a :: Ptr NFCTarget -> IO NFCTarget decodeIso14443a p = do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nfc-0.0.1/stack.yaml new/nfc-0.1.0/stack.yaml --- old/nfc-0.0.1/stack.yaml 2016-12-20 18:55:14.000000000 +0100 +++ new/nfc-0.1.0/stack.yaml 2017-02-21 09:26:42.000000000 +0100 @@ -1,4 +1,4 @@ -resolver: lts-7.14 +resolver: lts-8.2 packages: - '.' extra-deps: []
