System.Posix.ByteString

unix-2.7.2.2: POSIX functionality

Copyright | (c) The University of Glasgow 2002
License | BSD-style (see the file libraries/base/LICENSE)
Maintainer | libraries@haskell.org
Stability | provisional
Portability | non-portable (requires POSIX)
Safe Haskell | Safe
Language | Haskell2010

System.Posix.ByteString

Description

POSIX.1-2008 support with `ByteString` file paths and environment strings.

This module exports exactly the same API as System.Posix, except that all file paths and environment strings are represented by `ByteString` instead of `String`. The System.Posix API implicitly translates all file paths and environment strings using the locale encoding, whereas this version of the API does no encoding or decoding and works directly in terms of raw bytes.

Note that if you do need to interpret file paths or environment strings as text, then some Unicode encoding or decoding should be applied first.

Synopsis

- type RawFilePath = ByteString
- module System.Posix.Types
- module System.Posix.Signals
- module System.Posix.Directory.ByteString
- module System.Posix.Files.ByteString
- module System.Posix.Unistd
- module System.Posix.IO.ByteString
- module System.Posix.Env.ByteString
- module System.Posix.Process.ByteString
- module System.Posix.Temp.ByteString
- module System.Posix.Terminal.ByteString
- module System.Posix.Time
- module System.Posix.User
- module System.Posix.Resource
- module System.Posix.Semaphore
- module System.Posix.SharedMem
- data DL
  - = Null
  - | Next
  - | DLHandle (Ptr ())
- data RTLDFlags
  - = RTLD_LAZY
  - | RTLD_NOW
  - | RTLD_GLOBAL
  - | RTLD_LOCAL
- c_dlclose :: Ptr () -> IO CInt
- c_dlerror :: IO CString
- c_dlsym :: Ptr () -> CString -> IO (FunPtr a)
- c_dlopen :: CString -> CInt -> IO (Ptr ())
- haveRtldNext :: Bool
- haveRtldLocal :: Bool
- packRTLDFlags :: [RTLDFlags] -> CInt
- packDL :: DL -> Ptr ()
- dlclose :: DL -> IO ()
- dlerror :: IO String
- dlsym :: DL -> String -> IO (FunPtr a)
- undl :: DL -> Ptr ()
- dlopen :: RawFilePath -> [RTLDFlags] -> IO DL
- withDL :: RawFilePath -> [RTLDFlags] -> (DL -> IO a) -> IO a
- withDL_ :: RawFilePath -> [RTLDFlags] -> (DL -> IO a) -> IO ()

# Documentation

type RawFilePath = ByteString #

A literal POSIX file path

module System.Posix.Types

module System.Posix.Signals

module System.Posix.Directory.ByteString

module System.Posix.Files.ByteString

module System.Posix.Unistd

module System.Posix.IO.ByteString

module System.Posix.Env.ByteString

module System.Posix.Process.ByteString

module System.Posix.Temp.ByteString

module System.Posix.Terminal.ByteString

module System.Posix.Time

module System.Posix.User

module System.Posix.Resource

module System.Posix.Semaphore

module System.Posix.SharedMem

data DL #

Flags for `dlsym`. Notice that `Next` might not be available on your particular platform! Use `haveRtldNext`.

If `RTLD_DEFAULT` is not defined on your platform, `packDL` `Default` reduces to `nullPtr`.

Constructors

Null |
Next |
DLHandle (Ptr ()) |

Instances

Show DL # |
Instance details Defined in System.Posix.DynamicLinker.Prim Methods showsPrec :: Int -> DL -> ShowS Source # show :: DL -> String Source # showList :: [DL] -> ShowS Source #

data RTLDFlags #

Flags for `dlopen`.

Constructors

RTLD_LAZY |
RTLD_NOW |
RTLD_GLOBAL |
RTLD_LOCAL |

Instances

Read RTLDFlags # |
Instance details Defined in System.Posix.DynamicLinker.Prim Methods readsPrec :: Int -> ReadS RTLDFlags Source # readList :: ReadS [RTLDFlags] Source # readPrec :: ReadPrec RTLDFlags Source # readListPrec :: ReadPrec [RTLDFlags] Source #
Show RTLDFlags # |
Instance details Defined in System.Posix.DynamicLinker.Prim Methods showsPrec :: Int -> RTLDFlags -> ShowS Source # show :: RTLDFlags -> String Source # showList :: [RTLDFlags] -> ShowS Source #

c_dlclose :: Ptr () -> IO CInt #

c_dlerror :: IO CString #

c_dlsym :: Ptr () -> CString -> IO (FunPtr a) #

c_dlopen :: CString -> CInt -> IO (Ptr ()) #

haveRtldNext :: Bool #

On some hosts (e.g. SuSe and Ubuntu Linux) `RTLD_NEXT` (and `RTLD_DEFAULT`) are not visible without setting the macro `_GNU_SOURCE`. Since we don't want to define this macro, you can use the function `haveRtldNext` to check wether the flag `Next` is available. Ideally, this will be optimized by the compiler so that it should be as efficient as an `#ifdef`.

If you fail to test the flag and use it although it is undefined, `packDL` will throw an error.

haveRtldLocal :: Bool #

Deprecated: defaults to True

packRTLDFlags :: [RTLDFlags] -> CInt #

packDL :: DL -> Ptr () #

dlclose :: DL -> IO () #

dlerror :: IO String #

dlsym :: DL -> String -> IO (FunPtr a) #

`dlsym` returns the address binding of the symbol described in `symbol`, as it occurs in the shared object identified by `source`.

undl :: DL -> Ptr () #

`undl` obtains the raw handle. You mustn't do something like `withDL mod flags $ liftM undl >>= p -> use p`

dlopen :: RawFilePath -> [RTLDFlags] -> IO DL #

withDL :: RawFilePath -> [RTLDFlags] -> (DL -> IO a) -> IO a #

withDL_ :: RawFilePath -> [RTLDFlags] -> (DL -> IO a) -> IO () #