bsd-sysctl-1.0.8.0: Access to the BSD sysctl(3) interface

Copyright(c) Maxime Henrion 2009-2010
Licensesee LICENSE
Maintainermhenrion@gmail.com
Stabilitystable
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

System.BSD.Sysctl

Contents

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

The data types

class SysctlKey k Source #

The class of types that can be used to identify a sysctl node.

Minimal complete definition

withKey

Instances

SysctlKey OID Source # 

Methods

withKey :: OID -> (Ptr CInt -> CUInt -> IO a) -> IO a

SysctlKey [Int32] Source # 

Methods

withKey :: [Int32] -> (Ptr CInt -> CUInt -> IO a) -> IO a

data OID Source #

An efficient representation of a sysctl OID for maximum performance.

Instances

SysctlKey OID Source # 

Methods

withKey :: OID -> (Ptr CInt -> CUInt -> IO a) -> IO a

OID creation and extraction

sysctlPrepareOid :: [Int32] -> IO OID Source #

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 Int32 Source #

Read a signed integer from a sysctl (the C int type).

sysctlReadUInt :: SysctlKey k => k -> IO Word32 Source #

Read an unsigned integer from a sysctl (the C unsigned int type).

sysctlReadLong :: SysctlKey k => k -> IO Int64 Source #

Read a signed long integer from a sysctl (the C long type).

sysctlReadULong :: SysctlKey k => k -> IO Word64 Source #

Read an unsigned long integer from a sysctl (the C unsigned long type).

sysctlReadQuad :: SysctlKey k => k -> IO Int64 Source #

Read a signed 64-bit integer from a sysctl.

sysctlReadUQuad :: SysctlKey k => k -> IO Word64 Source #

Read an unsigned 64-bit integer from a sysctl.

sysctlReadString :: SysctlKey k => k -> IO String Source #

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 a Source #

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 -> Int64 -> IO () Source #

Write a signed long integer to a sysctl (the C long type).

sysctlWriteULong :: SysctlKey k => k -> Word64 -> 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.