packages feed

bsd-sysctl 1.0.2 → 1.0.3

raw patch · 3 files changed

+28/−18 lines, 3 filessetup-changedPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- System.BSD.Sysctl: sysctlNameToOid :: String -> IO OID
- System.BSD.Sysctl: sysctlNameToOidArgs :: String -> [Int32] -> IO OID

Files

Setup.hs view
@@ -1,3 +1,21 @@ import Distribution.Simple+import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(withPrograms), buildDir)+import Distribution.Simple.Program (userSpecifyArgs) -main = defaultMain+import System.Directory+import System.FilePath++-- Define __HADDOCK__ when building documentation.+main = defaultMainWithHooks simpleUserHooks {+  haddockHook = \pkg lbi h f -> do+    let progs = userSpecifyArgs "hsc2hs" ["-D__HADDOCK__"] (withPrograms lbi)+    removePreProcessedFiles (buildDir lbi)+    haddockHook simpleUserHooks pkg lbi { withPrograms = progs } h f+}++-- Horrible hack to force re-processing of the .hsc file.  Otherwise+-- the __HADDOCK__ macro doesn't end up being defined.+removePreProcessedFiles :: FilePath -> IO ()+removePreProcessedFiles dir =+  removeFile (dir </> "System/BSD/Sysctl.hs")+    `catch` \_ -> return ()
System/BSD/Sysctl.hsc view
@@ -8,7 +8,7 @@ -- Module      :  System.BSD.Sysctl -- Copyright   :  (c) Maxime Henrion 2009 -- License     :  see LICENSE--- +-- -- Maintainer  :  mhenrion@gmail.com -- Stability   :  stable -- Portability :  portable@@ -21,18 +21,18 @@ -- at runtime with the 'sysctlPeekArray' function. -- -- On some platforms, there are sysctl nodes that accept parameters via--- additional components in the OID (see for instance the "kern.proc.pid" sysctl--- described in sysctl(3) on FreeBSD).  The 'sysctlNameToOidArgs' makes it easy--- to query such nodes as well.+-- additional components in the OID (see for instance the \"kern.proc.pid\"+-- sysctl described in sysctl(3) on FreeBSD).  The 'sysctlNameToOidArgs' makes+-- it easy to query such nodes as well. -- -- Nodes may be queried either by their OID as a list of integers, by their--- binary OID for maximum speed, or by their names on platforms that support it. +-- binary OID for maximum speed, or by their names on platforms that support it. -------------------------------------------------------------------------------  #include <sys/param.h> #include <sys/sysctl.h> -#if !defined(__linux__) && !defined(__OpenBSD__)+#if defined(__HADDOCK__) || (!defined(__linux__) && !defined(__OpenBSD__)) #define HAVE_SYSCTLNAMETOMIB #endif @@ -42,8 +42,10 @@   OID,    -- * OID creation and extraction+#ifdef HAVE_SYSCTLNAMETOMIB   sysctlNameToOid,	-- :: String -> IO OID   sysctlNameToOidArgs,	-- :: String -> [#{type int}] -> IO OID+#endif   sysctlPrepareOid,	-- :: [#{type int}] -> IO OID   sysctlExtractOid,	-- :: OID -> IO [#{type int}] @@ -115,21 +117,15 @@ -- on (at least) Linux and OpenBSD. foreign import ccall unsafe "sysctlnametomib"   c_sysctlnametomib :: CString -> Ptr CInt -> Ptr CSize -> IO CInt-#endif  -- | Get the 'OID' corresponding to a sysctl name. sysctlNameToOid :: String -> IO OID-#ifdef HAVE_SYSCTLNAMETOMIB sysctlNameToOid name = sysctlNameToOidArgs name []-#else-sysctlNameToOid name = error "not available on this platform"-#endif  -- | Like 'sysctlNameToOid', but allows to provide a list of -- additional integers to append to the OID, for specific sysctl -- nodes that support parameters this way. sysctlNameToOidArgs :: String -> [#{type int}] -> IO OID-#ifdef HAVE_SYSCTLNAMETOMIB sysctlNameToOidArgs name args =   withCString name $ \cname -> do     allocaArray (fromIntegral maxlen) $ \oid -> do@@ -147,11 +143,7 @@         return (OID fp (fromIntegral len))   where maxlen = #{const CTL_MAXNAME}         alen   = length args-#else-sysctlNameToOidArgs name args = error "not available on this platform"-#endif -#ifdef HAVE_SYSCTLNAMETOMIB instance SysctlKey String where   withKey name f = sysctlNameToOid name >>= flip withKey f #endif
bsd-sysctl.cabal view
@@ -1,5 +1,5 @@ Name:		bsd-sysctl-Version:	1.0.2+Version:	1.0.3 License-File:	LICENSE License:	BSD3 Author:		Maxime Henrion