bsd-sysctl-1.0.5: Access to the BSD sysctl(3) interfaceSource codeContentsIndex
System.BSD.Sysctl
Portabilityportable
Stabilitystable
Maintainermhenrion@gmail.com
Contents
The data types
OID creation and extraction
Basic reading functions
Advanced reading functions
Basic writing functions
Advanced writing functions
Description

This module allows access to the BSD sysctl(3) interface via the Haskell FFI.

Convenience functions to read and write the usual sysctl types are provided, as well as more advanced functions to handle binary values given a suitable Storable instance. It is also possible to retrieve data whose size changes 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 function 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.

Synopsis
class SysctlKey k
data OID
sysctlNameToOid :: String -> IO OID
sysctlNameToOidArgs :: String -> [Int32] -> IO OID
sysctlPrepareOid :: [Int32] -> IO OID
sysctlExtractOid :: OID -> IO [Int32]
sysctlReadInt :: SysctlKey k => k -> IO Int32
sysctlReadUInt :: SysctlKey k => k -> IO Word32
sysctlReadLong :: SysctlKey k => k -> IO Int32
sysctlReadULong :: SysctlKey k => k -> IO Word32
sysctlReadQuad :: SysctlKey k => k -> IO Int64
sysctlReadUQuad :: SysctlKey k => k -> IO Word64
sysctlReadString :: SysctlKey k => k -> IO String
sysctlPeek :: forall k a. (SysctlKey k, Storable a) => k -> IO a
sysctlPeekArray :: forall k a. (SysctlKey k, Storable a) => k -> IO [a]
sysctlWriteInt :: SysctlKey k => k -> Int32 -> IO ()
sysctlWriteUInt :: SysctlKey k => k -> Word32 -> IO ()
sysctlWriteLong :: SysctlKey k => k -> Int32 -> IO ()
sysctlWriteULong :: SysctlKey k => k -> Word32 -> IO ()
sysctlWriteQuad :: SysctlKey k => k -> Int64 -> IO ()
sysctlWriteUQuad :: SysctlKey k => k -> Word64 -> IO ()
sysctlWriteString :: SysctlKey k => k -> String -> IO ()
sysctlPoke :: (SysctlKey k, Storable a) => k -> a -> IO ()
The data types
class SysctlKey k Source
The class of types that can be used to identify a sysctl node.
show/hide Instances
data OID Source
An efficient representation of a sysctl OID for maximum performance.
show/hide Instances
OID creation and extraction
sysctlNameToOid :: String -> IO OIDSource
Get the OID corresponding to a sysctl name.
sysctlNameToOidArgs :: String -> [Int32] -> IO OIDSource
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.
sysctlPrepareOid :: [Int32] -> IO OIDSource
Prepare an OID for later use.
sysctlExtractOid :: OID -> IO [Int32]Source
Extract the list of integers contained in an OID.
Basic reading functions
sysctlReadInt :: SysctlKey k => k -> IO Int32Source
Read a signed integer from a sysctl (the C int type).
sysctlReadUInt :: SysctlKey k => k -> IO Word32Source
Read an unsigned integer from a sysctl (the C unsigned int type).
sysctlReadLong :: SysctlKey k => k -> IO Int32Source
Read a signed long integer from a sysctl (the C long type).
sysctlReadULong :: SysctlKey k => k -> IO Word32Source
Read an unsigned long integer from a sysctl (the C unsigned long type).
sysctlReadQuad :: SysctlKey k => k -> IO Int64Source
Read a signed 64-bit integer from a sysctl.
sysctlReadUQuad :: SysctlKey k => k -> IO Word64Source
Read an unsigned 64-bit integer from a sysctl.
sysctlReadString :: SysctlKey k => k -> IO StringSource
Read a string from a sysctl. If the string can possibly change with time, use sysctlPeekArray for characters instead.
Advanced reading functions
sysctlPeek :: forall k a. (SysctlKey k, Storable a) => k -> IO aSource
Read a storable value from a sysctl node. This is useful to read binary values such as C structures, otherwise the ad-hoc reading functions should be used instead.
sysctlPeekArray :: forall k a. (SysctlKey k, Storable a) => k -> IO [a]Source
Like sysctlPeek, but allows to retrieve a list of elements whose length can possibly change at runtime.
Basic writing functions
sysctlWriteInt :: SysctlKey k => k -> Int32 -> IO ()Source
Write a signed integer to a sysctl (the C int type).
sysctlWriteUInt :: SysctlKey k => k -> Word32 -> IO ()Source
Write an unsigned integer to a sysctl (the C unsigned int type).
sysctlWriteLong :: SysctlKey k => k -> Int32 -> IO ()Source
Write a signed long integer to a sysctl (the C long type).
sysctlWriteULong :: SysctlKey k => k -> Word32 -> IO ()Source
Write an unsigned long integer to a sysctl (the C unsigned long type).
sysctlWriteQuad :: SysctlKey k => k -> Int64 -> IO ()Source
Write a signed 64-bit integer to a sysctl.
sysctlWriteUQuad :: SysctlKey k => k -> Word64 -> IO ()Source
Write an unsigned 64-bit integer to a sysctl.
sysctlWriteString :: SysctlKey k => k -> String -> IO ()Source
Write a string to a sysctl.
Advanced writing functions
sysctlPoke :: (SysctlKey k, Storable a) => k -> a -> IO ()Source
Write a storable value to a sysctl node. This is useful to write binary values such as C structures, otherwise the ad-hoc writing functions should be used instead.
Produced by Haddock version 2.6.0