module Graphics.Text.Font.Choose.Config where

import Graphics.Text.Font.Choose.Strings
import Graphics.Text.Font.Choose.FontSet
import Graphics.Text.Font.Choose.CharSet
import Graphics.Text.Font.Choose.Pattern
import Graphics.Text.Font.Choose.ObjectSet

import Foreign.ForeignPtr
import Foreign.Ptr (Ptr, nullPtr, FunPtr)
import Foreign.Marshal.Alloc (alloca, allocaBytes, free)
import Foreign.Storable (Storable(..))
import Foreign.C.String (CString, peekCString, withCString)
import System.IO.Unsafe (unsafePerformIO)
import Data.Set (empty) -- For testing segfault source.

import Control.Exception (bracket)
import Graphics.Text.Font.Choose.Result (Word8, throwNull, throwFalse, throwPtr)

-- | System configuration regarding available fonts.
type Config = ForeignPtr Config'
data Config'
type Config_ = Ptr Config'

-- | Creates an empty configuration.
configCreate :: IO Config
configCreate :: IO Config
configCreate = forall a. FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
newForeignPtr FunPtr (Config_ -> IO ())
fcConfigDestroy forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall a. Ptr a -> Ptr a
throwNull forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IO Config_
fcConfigCreate
foreign import ccall "FcConfigCreate" fcConfigCreate :: IO Config_
ptr2config :: Config_ -> IO Config
ptr2config = forall a. FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
newForeignPtr FunPtr (Config_ -> IO ())
fcConfigDestroy
foreign import ccall "&FcConfigDestroy" fcConfigDestroy :: FunPtr (Config_ -> IO ())

-- | Sets the current default configuration to config.
-- Implicitly calls `configBuildFonts` if necessary.
configSetCurrent :: Config -> IO ()
configSetCurrent :: Config -> IO ()
configSetCurrent Config
config = Bool -> IO ()
throwFalse forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ Config_ -> IO Bool
fcConfigSetCurrent)
foreign import ccall "FcConfigSetCurrent" fcConfigSetCurrent :: Config_ -> IO Bool

-- | Returns the current default configuration.
configGetCurrent :: IO Config
configGetCurrent :: IO Config
configGetCurrent = (forall a. Ptr a -> Ptr a
throwNull forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Config_ -> IO Config_
fcConfigReference forall a. Ptr a
nullPtr) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
    forall a. FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
newForeignPtr FunPtr (Config_ -> IO ())
fcConfigDestroy
foreign import ccall "FcConfigReference" fcConfigReference :: Config_ -> IO Config_

-- | Checks all of the files related to config and returns whether any of them
-- has been modified since the configuration was created.
configUptoDate :: Config -> IO Bool
configUptoDate :: Config -> IO Bool
configUptoDate Config
config = forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ Config_ -> IO Bool
fcConfigUptoDate
foreign import ccall "FcConfigUptoDate" fcConfigUptoDate :: Config_ -> IO Bool

-- | Return the current user's home directory, if it is available,
-- and if using it is enabled, and NULL otherwise. (See also `configEnableHome`).
configHome :: IO (Maybe String)
configHome :: IO (Maybe String)
configHome = do
    CString
ret <- IO CString
fcConfigHome
    if CString
ret forall a. Eq a => a -> a -> Bool
== forall a. Ptr a
nullPtr then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing else forall a. a -> Maybe a
Just forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CString -> IO String
peekCString CString
ret
foreign import ccall "FcConfigHome" fcConfigHome :: IO CString

-- | If enable is `True`, then Fontconfig will use various files which are
-- specified relative to the user's home directory (using the ~ notation in
-- the configuration). When enable is `False`, then all use of the home
-- directory in these contexts will be disabled. The previous setting of
-- the value is returned.
foreign import ccall "FcConfigEnableHome" configEnableHome :: Bool -> IO Bool

-- | Returns the list of font directories specified in the configuration files
-- for config. Does not include any subdirectories.
configBuildFonts :: Config -> IO ()
configBuildFonts :: Config -> IO ()
configBuildFonts Config
config = Bool -> IO ()
throwFalse forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ Config_ -> IO Bool
fcConfigBuildFonts)
-- | Variant of `configBuildFonts` operating on the current configuration.
configBuildFonts' :: IO ()
configBuildFonts' :: IO ()
configBuildFonts' = Bool -> IO ()
throwFalse forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Config_ -> IO Bool
fcConfigBuildFonts forall a. Ptr a
nullPtr
foreign import ccall "FcConfigBuildFonts" fcConfigBuildFonts :: Config_ -> IO Bool

-- | Returns the list of font directories specified in the configuration files
-- for config. Does not include any subdirectories.
configGetConfigDirs :: Config -> IO StrList
configGetConfigDirs :: Config -> IO StrList
configGetConfigDirs = (Config_ -> IO StrList_) -> Config -> IO StrList
configStrsFunc Config_ -> IO StrList_
fcConfigGetConfigDirs
-- | Variant of `configGetConfigDirs` which operates on the current configuration.
configGetConfigDirs' :: IO StrList
configGetConfigDirs' :: IO StrList
configGetConfigDirs' = StrList_ -> IO StrList
thawStrList forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Config_ -> IO StrList_
fcConfigGetConfigDirs forall a. Ptr a
nullPtr
foreign import ccall "FcConfigGetConfigDirs" fcConfigGetConfigDirs :: Config_ -> IO StrList_

-- | Returns the list of font directories in config.
-- This includes the configured font directories along with any directories
-- below those in the filesystem.
configGetFontDirs :: Config -> IO StrList
configGetFontDirs :: Config -> IO StrList
configGetFontDirs = (Config_ -> IO StrList_) -> Config -> IO StrList
configStrsFunc Config_ -> IO StrList_
fcConfigGetFontDirs
-- | Variant of `configGetFontDirs` which operates on the current config.
configGetFontDirs' :: IO StrList
configGetFontDirs' :: IO StrList
configGetFontDirs' = IO StrList_ -> IO StrList
thawStrList_ forall a b. (a -> b) -> a -> b
$ Config_ -> IO StrList_
fcConfigGetFontDirs forall a. Ptr a
nullPtr
foreign import ccall "FcConfigGetFontDirs" fcConfigGetFontDirs :: Config_ -> IO StrList_

-- | Returns the list of known configuration files used to generate config.
configGetConfigFiles :: Config -> IO StrList
configGetConfigFiles :: Config -> IO StrList
configGetConfigFiles = (Config_ -> IO StrList_) -> Config -> IO StrList
configStrsFunc Config_ -> IO StrList_
fcConfigGetConfigFiles
-- | Variant of `configGetConfigFiles` which operates upon current configuration.
configGetConfigFiles' :: IO StrList
configGetConfigFiles' :: IO StrList
configGetConfigFiles' = IO StrList_ -> IO StrList
thawStrList_ forall a b. (a -> b) -> a -> b
$ Config_ -> IO StrList_
fcConfigGetConfigFiles forall a. Ptr a
nullPtr
foreign import ccall "FcConfigGetConfigFiles" fcConfigGetConfigFiles :: Config_ -> IO StrList_

-- | Returns a string list containing all of the directories that fontconfig
-- will search when attempting to load a cache file for a font directory.
configGetCacheDirs :: Config -> IO StrList
configGetCacheDirs :: Config -> IO StrList
configGetCacheDirs = (Config_ -> IO StrList_) -> Config -> IO StrList
configStrsFunc Config_ -> IO StrList_
fcConfigGetCacheDirs
-- | Variant of `configGetCacheDirs` which operates upon current configuration.
configGetCacheDirs' :: IO StrList
configGetCacheDirs' :: IO StrList
configGetCacheDirs' = IO StrList_ -> IO StrList
thawStrList_ forall a b. (a -> b) -> a -> b
$ Config_ -> IO StrList_
fcConfigGetCacheDirs forall a. Ptr a
nullPtr
foreign import ccall "FcConfigGetCacheDirs" fcConfigGetCacheDirs :: Config_ -> IO StrList_

-- | Whether to operate upon system or application fontlists.
data SetName = SetSystem | SetApplication deriving (Int -> SetName
SetName -> Int
SetName -> [SetName]
SetName -> SetName
SetName -> SetName -> [SetName]
SetName -> SetName -> SetName -> [SetName]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: SetName -> SetName -> SetName -> [SetName]
$cenumFromThenTo :: SetName -> SetName -> SetName -> [SetName]
enumFromTo :: SetName -> SetName -> [SetName]
$cenumFromTo :: SetName -> SetName -> [SetName]
enumFromThen :: SetName -> SetName -> [SetName]
$cenumFromThen :: SetName -> SetName -> [SetName]
enumFrom :: SetName -> [SetName]
$cenumFrom :: SetName -> [SetName]
fromEnum :: SetName -> Int
$cfromEnum :: SetName -> Int
toEnum :: Int -> SetName
$ctoEnum :: Int -> SetName
pred :: SetName -> SetName
$cpred :: SetName -> SetName
succ :: SetName -> SetName
$csucc :: SetName -> SetName
Enum, SetName -> SetName -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetName -> SetName -> Bool
$c/= :: SetName -> SetName -> Bool
== :: SetName -> SetName -> Bool
$c== :: SetName -> SetName -> Bool
Eq, Int -> SetName -> ShowS
[SetName] -> ShowS
SetName -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetName] -> ShowS
$cshowList :: [SetName] -> ShowS
show :: SetName -> String
$cshow :: SetName -> String
showsPrec :: Int -> SetName -> ShowS
$cshowsPrec :: Int -> SetName -> ShowS
Show, ReadPrec [SetName]
ReadPrec SetName
Int -> ReadS SetName
ReadS [SetName]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetName]
$creadListPrec :: ReadPrec [SetName]
readPrec :: ReadPrec SetName
$creadPrec :: ReadPrec SetName
readList :: ReadS [SetName]
$creadList :: ReadS [SetName]
readsPrec :: Int -> ReadS SetName
$creadsPrec :: Int -> ReadS SetName
Read)
-- | Returns one of the two sets of fonts from the configuration as specified
-- by set. This font set is owned by the library and must not be modified or
-- freed. If config is NULL, the current configuration is used.
-- This function isn't MT-safe.
configGetFonts :: Config -> SetName -> IO FontSet
configGetFonts :: Config -> SetName -> IO FontSet
configGetFonts Config
config SetName
set = do
    FontSet_
ret <- forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ forall a b c. (a -> b -> c) -> b -> a -> c
flip Config_ -> Int -> IO FontSet_
fcConfigGetFonts forall a b. (a -> b) -> a -> b
$ forall a. Enum a => a -> Int
fromEnum SetName
set
    FontSet_ -> IO FontSet
thawFontSet forall a b. (a -> b) -> a -> b
$ forall a. Ptr a -> Ptr a
throwNull FontSet_
ret
-- | Variant of `configGetFonts` which operates upon current configuration.
configGetFonts' :: SetName -> IO FontSet
configGetFonts' :: SetName -> IO FontSet
configGetFonts' SetName
set = do
    FontSet_
ret <- Config_ -> Int -> IO FontSet_
fcConfigGetFonts forall a. Ptr a
nullPtr forall a b. (a -> b) -> a -> b
$ forall a. Enum a => a -> Int
fromEnum SetName
set
    FontSet_ -> IO FontSet
thawFontSet forall a b. (a -> b) -> a -> b
$ forall a. Ptr a -> Ptr a
throwNull FontSet_
ret
foreign import ccall "FcConfigGetFonts" fcConfigGetFonts :: Config_ -> Int -> IO FontSet_

-- | Returns the interval between automatic checks of the configuration
-- (in seconds) specified in config. The configuration is checked during
-- a call to FcFontList when this interval has passed since the last check.
-- An interval setting of zero disables automatic checks.
configGetRescanInterval :: Config -> IO Int
configGetRescanInterval :: Config -> IO Int
configGetRescanInterval = forall a b c. (a -> b -> c) -> b -> a -> c
flip forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr forall a b. (a -> b) -> a -> b
$ Config_ -> IO Int
fcConfigGetRescanInterval
-- | Variant of `configGetRescanInterval` which operates upon current configuration.
configGetRescanInterval' :: IO Int
configGetRescanInterval' :: IO Int
configGetRescanInterval' = Config_ -> IO Int
fcConfigGetRescanInterval forall a. Ptr a
nullPtr
foreign import ccall "FcConfigGetRescanInterval" fcConfigGetRescanInterval ::
    Config_ -> IO Int

-- | Sets the rescan interval.
-- An interval setting of zero disables automatic checks.
configSetRescanInterval :: Config -> Int -> IO ()
configSetRescanInterval :: Config -> Int -> IO ()
configSetRescanInterval Config
config Int
val =
    Bool -> IO ()
throwFalse forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ forall a b c. (a -> b -> c) -> b -> a -> c
flip Config_ -> Int -> IO Bool
fcConfigSetRescanInterval Int
val)
-- | Variant of `configSetRescanInterval` which operates upon current configuration.
configSetRescanInterval' :: Int -> IO ()
configSetRescanInterval' :: Int -> IO ()
configSetRescanInterval' Int
v = Bool -> IO ()
throwFalse forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Config_ -> Int -> IO Bool
fcConfigSetRescanInterval forall a. Ptr a
nullPtr Int
v
foreign import ccall "FcConfigSetRescanInterval" fcConfigSetRescanInterval ::
    Config_ -> Int -> IO Bool

-- | Adds an application-specific font to the configuration.
configAppFontAddFile :: Config -> String -> IO ()
configAppFontAddFile :: Config -> String -> IO ()
configAppFontAddFile Config
config String
file = Bool -> IO ()
throwFalse forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<
    (forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' -> forall a. String -> (CString -> IO a) -> IO a
withCString String
file forall a b. (a -> b) -> a -> b
$ \CString
file' ->
        Config_ -> CString -> IO Bool
fcConfigAppFontAddFile Config_
config' CString
file')
-- | Variant of `configAppFontAddFile` which operates upon current configuration.
configAppFontAddFile' :: String -> IO ()
configAppFontAddFile' :: String -> IO ()
configAppFontAddFile' String
file =
    Bool -> IO ()
throwFalse forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (forall a. String -> (CString -> IO a) -> IO a
withCString String
file forall a b. (a -> b) -> a -> b
$ Config_ -> CString -> IO Bool
fcConfigAppFontAddFile forall a. Ptr a
nullPtr)
foreign import ccall "FcConfigAppFontAddFile" fcConfigAppFontAddFile ::
    Config_ -> CString -> IO Bool

-- | Scans the specified directory for fonts,
-- adding each one found to the application-specific set of fonts.
configAppFontAddDir :: Config -> String -> IO ()
configAppFontAddDir :: Config -> String -> IO ()
configAppFontAddDir Config
config String
file = Bool -> IO ()
throwFalse forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<
    (forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' -> forall a. String -> (CString -> IO a) -> IO a
withCString String
file forall a b. (a -> b) -> a -> b
$ Config_ -> CString -> IO Bool
fcConfigAppFontAddDir Config_
config')
-- | Variant of `configAppFontAddDir` which operates upon current configuration.
configAppFontAddDir' :: String -> IO ()
configAppFontAddDir' :: String -> IO ()
configAppFontAddDir' String
v = Bool -> IO ()
throwFalse forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (forall a. String -> (CString -> IO a) -> IO a
withCString String
v forall a b. (a -> b) -> a -> b
$ Config_ -> CString -> IO Bool
fcConfigAppFontAddDir forall a. Ptr a
nullPtr)
foreign import ccall "FcConfigAppFontAddDir" fcConfigAppFontAddDir ::
    Config_ -> CString -> IO Bool

-- | Clears the set of application-specific fonts.
configAppFontClear :: Config -> IO ()
configAppFontClear :: Config -> IO ()
configAppFontClear Config
config = Bool -> IO ()
throwFalse forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config Config_ -> IO Bool
fcConfigAppFontClear
-- | Variant of `configAppFontClear` which operates upon current configuration.
configAppFontClear' :: IO ()
configAppFontClear' :: IO ()
configAppFontClear' = Bool -> IO ()
throwFalse forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Config_ -> IO Bool
fcConfigAppFontClear forall a. Ptr a
nullPtr
foreign import ccall "FcConfigAppFontClear" fcConfigAppFontClear :: Config_ -> IO Bool

-- | What purpose does the given pattern serve?
data MatchKind = MatchPattern | MatchFont | MatchScan deriving Int -> MatchKind
MatchKind -> Int
MatchKind -> [MatchKind]
MatchKind -> MatchKind
MatchKind -> MatchKind -> [MatchKind]
MatchKind -> MatchKind -> MatchKind -> [MatchKind]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: MatchKind -> MatchKind -> MatchKind -> [MatchKind]
$cenumFromThenTo :: MatchKind -> MatchKind -> MatchKind -> [MatchKind]
enumFromTo :: MatchKind -> MatchKind -> [MatchKind]
$cenumFromTo :: MatchKind -> MatchKind -> [MatchKind]
enumFromThen :: MatchKind -> MatchKind -> [MatchKind]
$cenumFromThen :: MatchKind -> MatchKind -> [MatchKind]
enumFrom :: MatchKind -> [MatchKind]
$cenumFrom :: MatchKind -> [MatchKind]
fromEnum :: MatchKind -> Int
$cfromEnum :: MatchKind -> Int
toEnum :: Int -> MatchKind
$ctoEnum :: Int -> MatchKind
pred :: MatchKind -> MatchKind
$cpred :: MatchKind -> MatchKind
succ :: MatchKind -> MatchKind
$csucc :: MatchKind -> MatchKind
Enum
-- | Performs the sequence of pattern modification operations,
-- if kind is `MatchPattern`, then those tagged as pattern operations are applied,
-- else if kind is `MatchFont`, those tagged as font operations are applied and
-- p_pat is used for <test> elements with target=pattern.
configSubstituteWithPat :: Config -> Pattern -> Pattern -> MatchKind -> Pattern
configSubstituteWithPat :: Config -> Pattern -> Pattern -> MatchKind -> Pattern
configSubstituteWithPat Config
config Pattern
p Pattern
p_pat MatchKind
kind = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' -> forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p forall a b. (a -> b) -> a -> b
$ \Pattern_
p' ->
        forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p_pat forall a b. (a -> b) -> a -> b
$ \Pattern_
p_pat' -> do
            Bool
ok <- Config_ -> Pattern_ -> Pattern_ -> Int -> IO Bool
fcConfigSubstituteWithPat Config_
config' Pattern_
p' Pattern_
p_pat' forall a b. (a -> b) -> a -> b
$ forall a. Enum a => a -> Int
fromEnum MatchKind
kind
            Bool -> IO ()
throwFalse Bool
ok
            Pattern_ -> IO Pattern
thawPattern Pattern_
p'
-- | Variant of `configSubstituteWithPat` which operates upon current configuration.
configSubstituteWithPat' :: Pattern -> Pattern -> MatchKind -> Pattern
configSubstituteWithPat' :: Pattern -> Pattern -> MatchKind -> Pattern
configSubstituteWithPat' Pattern
p Pattern
p_pat MatchKind
kind = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$
    forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p forall a b. (a -> b) -> a -> b
$ \Pattern_
p' -> forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p_pat forall a b. (a -> b) -> a -> b
$ \Pattern_
p_pat' -> do
        Bool
ok <- Config_ -> Pattern_ -> Pattern_ -> Int -> IO Bool
fcConfigSubstituteWithPat forall a. Ptr a
nullPtr Pattern_
p' Pattern_
p_pat' forall a b. (a -> b) -> a -> b
$ forall a. Enum a => a -> Int
fromEnum MatchKind
kind
        Bool -> IO ()
throwFalse Bool
ok
        Pattern_ -> IO Pattern
thawPattern Pattern_
p'
foreign import ccall "FcConfigSubstituteWithPat" fcConfigSubstituteWithPat ::
    Config_ -> Pattern_ -> Pattern_ -> Int -> IO Bool

-- | Calls FcConfigSubstituteWithPat without setting p_pat.
configSubstitute :: Config -> Pattern -> MatchKind -> Pattern
configSubstitute :: Config -> Pattern -> MatchKind -> Pattern
configSubstitute Config
config Pattern
p MatchKind
kind = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$
    forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' -> forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p forall a b. (a -> b) -> a -> b
$ \Pattern_
p' -> do
        Bool
ok <- Config_ -> Pattern_ -> Int -> IO Bool
fcConfigSubstitute Config_
config' Pattern_
p' forall a b. (a -> b) -> a -> b
$ forall a. Enum a => a -> Int
fromEnum MatchKind
kind
        Bool -> IO ()
throwFalse Bool
ok
        Pattern_ -> IO Pattern
thawPattern Pattern_
p'
-- | Variant `configSubstitute` which operates upon current configuration.
configSubstitute' :: Pattern -> MatchKind -> Pattern
configSubstitute' :: Pattern -> MatchKind -> Pattern
configSubstitute' Pattern
p MatchKind
kind = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$ forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p forall a b. (a -> b) -> a -> b
$ \Pattern_
p' -> do
    Bool
ok <- Config_ -> Pattern_ -> Int -> IO Bool
fcConfigSubstitute forall a. Ptr a
nullPtr Pattern_
p' forall a b. (a -> b) -> a -> b
$ forall a. Enum a => a -> Int
fromEnum MatchKind
kind
    Bool -> IO ()
throwFalse Bool
ok
    Pattern_ -> IO Pattern
thawPattern Pattern_
p'
foreign import ccall "FcConfigSubstitute" fcConfigSubstitute ::
    Config_ -> Pattern_ -> Int -> IO Bool

-- | Finds the font in sets most closely matching pattern and returns
-- the result of `fontRenderPrepare` for that font and the provided pattern.
-- This function should be called only after `configSubstitute` and
-- `defaultSubstitute` have been called for p;
-- otherwise the results will not be correct.
fontMatch :: Config -> Pattern -> Maybe Pattern
fontMatch :: Config -> Pattern -> Maybe Pattern
fontMatch Config
config Pattern
pattern = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$ forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' ->
    forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
pattern forall a b. (a -> b) -> a -> b
$ \Pattern_
pattern' -> forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \Ptr Word8
res' -> do
        Pattern_
ret <- Config_ -> Pattern_ -> Ptr Word8 -> IO Pattern_
fcFontMatch Config_
config' Pattern_
pattern' Ptr Word8
res'
        forall a. Ptr Word8 -> IO a -> IO (Maybe a)
throwPtr Ptr Word8
res' forall a b. (a -> b) -> a -> b
$ IO Pattern_ -> IO Pattern
thawPattern_ forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a. Applicative f => a -> f a
pure Pattern_
ret
-- | Variant of `fontMatch` which operates upon current configuration.
fontMatch' :: Pattern -> Maybe Pattern
fontMatch' :: Pattern -> Maybe Pattern
fontMatch' Pattern
pattern = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$ forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
pattern forall a b. (a -> b) -> a -> b
$ \Pattern_
pattern' -> forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \Ptr Word8
res' -> do
    Pattern_
ret <- Config_ -> Pattern_ -> Ptr Word8 -> IO Pattern_
fcFontMatch forall a. Ptr a
nullPtr Pattern_
pattern' Ptr Word8
res'
    forall a. Ptr Word8 -> IO a -> IO (Maybe a)
throwPtr Ptr Word8
res' forall a b. (a -> b) -> a -> b
$ IO Pattern_ -> IO Pattern
thawPattern_ forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a. Applicative f => a -> f a
pure Pattern_
ret
foreign import ccall "FcFontMatch" fcFontMatch ::
    Config_ -> Pattern_ -> Ptr Word8 -> IO Pattern_

-- | Returns the list of fonts sorted by closeness to p. If trim is `True`,
-- elements in the list which don't include Unicode coverage not provided by
-- earlier elements in the list are elided. The union of Unicode coverage of
-- all of the fonts is returned in `snd`. This function should be called only
-- after `configSubstitute` and `defaultSubstitute` have been called for p;
-- otherwise the results will not be correct.
fontSort :: Config -> Pattern -> Bool -> Maybe (FontSet, CharSet)
fontSort :: Config -> Pattern -> Bool -> Maybe (FontSet, CharSet)
fontSort Config
config Pattern
pattern Bool
trim = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$ forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' ->
    forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
pattern forall a b. (a -> b) -> a -> b
$ \Pattern_
pattern' -> forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \Ptr CharSet_
csp' -> forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \Ptr Word8
res' -> do
            FontSet_
ret <- Config_
-> Pattern_ -> Bool -> Ptr CharSet_ -> Ptr Word8 -> IO FontSet_
fcFontSort Config_
config' Pattern_
pattern' Bool
trim Ptr CharSet_
csp' Ptr Word8
res'
            forall a. Ptr Word8 -> IO a -> IO (Maybe a)
throwPtr Ptr Word8
res' forall a b. (a -> b) -> a -> b
$ do
                FontSet
x <- IO FontSet_ -> IO FontSet
thawFontSet_ forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a. Applicative f => a -> f a
pure FontSet_
ret
                CharSet
y <- Ptr CharSet_ -> IO CharSet
thawCharSet' Ptr CharSet_
csp'
                forall (m :: * -> *) a. Monad m => a -> m a
return (FontSet
x, CharSet
y)
-- | Variant of `fontSort` which operates upon current configuration.
fontSort' :: Pattern -> Bool -> Maybe (FontSet, CharSet)
fontSort' :: Pattern -> Bool -> Maybe (FontSet, CharSet)
fontSort' Pattern
pattern Bool
trim = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$ forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
pattern forall a b. (a -> b) -> a -> b
$ \Pattern_
pattern' ->
    forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \Ptr CharSet_
csp' -> forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \Ptr Word8
res' -> do
        FontSet_
ret <- Config_
-> Pattern_ -> Bool -> Ptr CharSet_ -> Ptr Word8 -> IO FontSet_
fcFontSort forall a. Ptr a
nullPtr Pattern_
pattern' Bool
trim Ptr CharSet_
csp' Ptr Word8
res'
        forall a. Ptr Word8 -> IO a -> IO (Maybe a)
throwPtr Ptr Word8
res' forall a b. (a -> b) -> a -> b
$ do
            FontSet
x <- IO FontSet_ -> IO FontSet
thawFontSet_ forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a. Applicative f => a -> f a
pure FontSet_
ret
            CharSet
y <- Ptr CharSet_ -> IO CharSet
thawCharSet' Ptr CharSet_
csp'
            forall (m :: * -> *) a. Monad m => a -> m a
return (FontSet
x, CharSet
y)
foreign import ccall "FcFontSort" fcFontSort ::
    Config_ -> Pattern_ -> Bool -> Ptr CharSet_ -> Ptr Word8 -> IO FontSet_

-- | Creates a new pattern consisting of elements of font not appearing in pat,
-- elements of pat not appearing in font and the best matching value from pat
-- for elements appearing in both. The result is passed to
--`configSubstituteWithPat` with kind `matchFont` and then returned.
fontRenderPrepare :: Config -> Pattern -> Pattern -> Pattern
fontRenderPrepare :: Config -> Pattern -> Pattern -> Pattern
fontRenderPrepare Config
config Pattern
pat Pattern
font = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$ forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' ->
    forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
pat forall a b. (a -> b) -> a -> b
$ \Pattern_
pat' -> forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
font forall a b. (a -> b) -> a -> b
$ \Pattern_
font' -> do
        Pattern_
ret <- Config_ -> Pattern_ -> Pattern_ -> IO Pattern_
fcFontRenderPrepare Config_
config' Pattern_
pat' Pattern_
font'
        IO Pattern_ -> IO Pattern
thawPattern_ forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a. Ptr a -> Ptr a
throwNull Pattern_
ret
-- | Variant of `fontRenderPrepare` which operates upon current configuration.
fontRenderPrepare' :: Pattern -> Pattern -> Pattern
fontRenderPrepare' :: Pattern -> Pattern -> Pattern
fontRenderPrepare' Pattern
pat Pattern
font = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$ forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
pat forall a b. (a -> b) -> a -> b
$ \Pattern_
pat' ->
    forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
font forall a b. (a -> b) -> a -> b
$ \Pattern_
font' -> do
        Pattern_
ret <- Config_ -> Pattern_ -> Pattern_ -> IO Pattern_
fcFontRenderPrepare forall a. Ptr a
nullPtr Pattern_
pat' Pattern_
font'
        IO Pattern_ -> IO Pattern
thawPattern_ forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a. Applicative f => a -> f a
pure Pattern_
ret
foreign import ccall "FcFontRenderPrepare" fcFontRenderPrepare ::
    Config_ -> Pattern_ -> Pattern_ -> IO Pattern_

-- | Selects fonts matching p, creates patterns from those fonts containing only
-- the objects in os and returns the set of unique such patterns.
fontList :: Config -> Pattern -> ObjectSet -> FontSet
fontList :: Config -> Pattern -> StrList -> FontSet
fontList Config
config Pattern
p StrList
os = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$ forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' ->
    forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p forall a b. (a -> b) -> a -> b
$ \Pattern_
p' -> forall a. StrList -> (ObjectSet_ -> IO a) -> IO a
withObjectSet StrList
os forall a b. (a -> b) -> a -> b
$ \ObjectSet_
os' -> do
        FontSet_
ret <- Config_ -> Pattern_ -> ObjectSet_ -> IO FontSet_
fcFontList Config_
config' Pattern_
p' ObjectSet_
os'
        IO FontSet_ -> IO FontSet
thawFontSet_ forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a. Applicative f => a -> f a
pure FontSet_
ret
-- | Variant of `fontList` which operates upon current configuration.
fontList' :: Pattern -> ObjectSet -> FontSet
fontList' :: Pattern -> StrList -> FontSet
fontList' Pattern
p StrList
os = forall a. IO a -> a
unsafePerformIO forall a b. (a -> b) -> a -> b
$ forall a. Pattern -> (Pattern_ -> IO a) -> IO a
withPattern Pattern
p forall a b. (a -> b) -> a -> b
$ \Pattern_
p' -> forall a. StrList -> (ObjectSet_ -> IO a) -> IO a
withObjectSet StrList
os forall a b. (a -> b) -> a -> b
$ \ObjectSet_
os' -> do
    FontSet_
ret <- Config_ -> Pattern_ -> ObjectSet_ -> IO FontSet_
fcFontList forall a. Ptr a
nullPtr Pattern_
p' ObjectSet_
os'
    IO FontSet_ -> IO FontSet
thawFontSet_ forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a. Applicative f => a -> f a
pure FontSet_
ret
foreign import ccall "FcFontList" fcFontList ::
    Config_ -> Pattern_ -> ObjectSet_ -> IO FontSet_

{-configGetFilename :: Config -> String -> String
configGetFilename config name = unsafePerformIO $ withForeignPtr config $ \config' ->
    withCString name $ \name' -> do
        ret <- fcConfigGetFilename config' name'
        peekCString' ret
configGetFilename' :: String -> String
configGetFilename' name = unsafePerformIO $ withCString name $ \name' -> do
    ret <- fcConfigGetFilename nullPtr name'
    peekCString' ret
foreign import ccall "FcConfigGetFilename" fcConfigGetFilename :: Config_ -> CString -> IO CString
peekCString' txt = bracket (pure $ throwNull txt) free peekCString-}

-- | Walks the configuration in 'file' and constructs the internal representation
-- in 'config'. Any include files referenced from within 'file' will be loaded
-- and parsed. If 'complain' is `False`, no warning will be displayed if 'file'
-- does not exist. Error and warning messages will be output to stderr. 
configParseAndLoad :: Config -> String -> Bool -> IO Bool
configParseAndLoad :: Config -> String -> Bool -> IO Bool
configParseAndLoad Config
config String
name Bool
complain = forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' ->
    forall a. String -> (CString -> IO a) -> IO a
withCString String
name forall a b. (a -> b) -> a -> b
$ \CString
name' -> Config_ -> CString -> Bool -> IO Bool
fcConfigParseAndLoad Config_
config' CString
name' Bool
complain
-- Variant of `configParseAndLoad` which operates upon current configuration.
configParseAndLoad' :: String -> Bool -> IO Bool
configParseAndLoad' :: String -> Bool -> IO Bool
configParseAndLoad' String
name Bool
complain =
    forall a. String -> (CString -> IO a) -> IO a
withCString String
name forall a b. (a -> b) -> a -> b
$ \CString
name' -> Config_ -> CString -> Bool -> IO Bool
fcConfigParseAndLoad forall a. Ptr a
nullPtr CString
name' Bool
complain
foreign import ccall "FcConfigParseAndLoad" fcConfigParseAndLoad ::
    Config_ -> CString -> Bool -> IO Bool

-- | Walks the configuration in 'memory' and constructs the internal representation
-- in 'config'. Any includes files referenced from within 'memory' will be loaded
-- and dparsed. If 'complain' is `False`, no warning will be displayed if 'file'
-- does not exist. Error and warning messages will be output to stderr.
configParseAndLoadFromMemory :: Config -> String -> Bool -> IO Bool
configParseAndLoadFromMemory :: Config -> String -> Bool -> IO Bool
configParseAndLoadFromMemory Config
config String
buffer Bool
complain = forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' ->
    forall a. String -> (CString -> IO a) -> IO a
withCString String
buffer forall a b. (a -> b) -> a -> b
$ \CString
buffer' ->
        Config_ -> CString -> Bool -> IO Bool
fcConfigParseAndLoadFromMemory Config_
config' CString
buffer' Bool
complain
-- | Variant of `configParseAndLoadFromMemory` which operates upon current
-- configuration.
configParseAndLoadFromMemory' :: String -> Bool -> IO Bool
configParseAndLoadFromMemory' :: String -> Bool -> IO Bool
configParseAndLoadFromMemory' String
buffer Bool
complain = forall a. String -> (CString -> IO a) -> IO a
withCString String
buffer forall a b. (a -> b) -> a -> b
$ \CString
buffer' ->
    Config_ -> CString -> Bool -> IO Bool
fcConfigParseAndLoadFromMemory forall a. Ptr a
nullPtr CString
buffer' Bool
complain
foreign import ccall "FcConfigParseAndLoadFromMemory" fcConfigParseAndLoadFromMemory ::
    Config_ -> CString -> Bool -> IO Bool

-- | Obtains the system root directory in 'config' if available.
-- All files (including file properties in patterns) obtained from this 'config'
-- are relative to this system root directory.
-- This function isn't MT-safe. 
configGetSysRoot :: Config -> IO String
configGetSysRoot :: Config -> IO String
configGetSysRoot = forall a b c. (a -> b -> c) -> b -> a -> c
flip forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr forall a b. (a -> b) -> a -> b
$ \Config_
config' -> do
    CString
ret <- Config_ -> IO CString
fcConfigGetSysRoot Config_
config'
    CString -> IO String
peekCString forall a b. (a -> b) -> a -> b
$ forall a. Ptr a -> Ptr a
throwNull CString
ret
-- | Variant of `configGetSysRoot` which operates upon current configuration.
configGetSysRoot' :: IO String
configGetSysRoot' :: IO String
configGetSysRoot' = (CString -> IO String
peekCString forall b c a. (b -> c) -> (a -> b) -> a -> c
.forall a. Ptr a -> Ptr a
throwNull) forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Config_ -> IO CString
fcConfigGetSysRoot forall a. Ptr a
nullPtr
foreign import ccall "FcConfigGetSysRoot" fcConfigGetSysRoot :: Config_ -> IO CString

-- | Set 'sysroot' as the system root directory. All file paths used or created
-- with this 'config' (including file properties in patterns) will be considered
-- or made relative to this 'sysroot'. This allows a host to generate caches for
-- targets at build time. This also allows a cache to be re-targeted to a
-- different base directory if 'configGetSysRoot' is used to resolve file paths.
-- When setting this on the current config this causes changing current config.
configSetSysRoot :: Config -> String -> IO ()
configSetSysRoot :: Config -> String -> IO ()
configSetSysRoot Config
config String
val = forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' -> forall a. String -> (CString -> IO a) -> IO a
withCString String
val forall a b. (a -> b) -> a -> b
$
    Config_ -> CString -> IO ()
fcConfigSetSysRoot Config_
config'
-- | Variant of `configSetSysRoot` which operates upon current configuration.
configSetSysRoot' :: String -> IO ()
configSetSysRoot' :: String -> IO ()
configSetSysRoot' String
val = forall a. String -> (CString -> IO a) -> IO a
withCString String
val forall a b. (a -> b) -> a -> b
$ Config_ -> CString -> IO ()
fcConfigSetSysRoot forall a. Ptr a
nullPtr
foreign import ccall "FcConfigSetSysRoot" fcConfigSetSysRoot :: Config_ -> CString -> IO ()

-- | Retrieves a list of all filepaths & descriptions for all fonts in this
-- configuration alongside whether each is enabled.
-- Not thread-safe.
configGetFileInfo :: Config -> IO [(FilePath, String, Bool)]
configGetFileInfo :: Config -> IO [(String, String, Bool)]
configGetFileInfo Config
config =
  forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config forall a b. (a -> b) -> a -> b
$ \Config_
config' -> forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
configFileInfoIter'Size forall a b. (a -> b) -> a -> b
$ \Ptr ConfigFileInfoIter'
iter' -> do
    Config_ -> Ptr ConfigFileInfoIter' -> IO ()
fcConfigFileInfoIterInit Config_
config' Ptr ConfigFileInfoIter'
iter'
    let readEnt :: IO (Maybe (String, String, Bool))
readEnt = forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \Ptr CString
name' -> forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \Ptr CString
description' -> forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \Ptr Bool
enabled' -> do {
        Bool
ok <- Config_
-> Ptr ConfigFileInfoIter'
-> Ptr CString
-> Ptr CString
-> Ptr Bool
-> IO Bool
fcConfigFileInfoIterGet Config_
config' Ptr ConfigFileInfoIter'
iter' Ptr CString
name' Ptr CString
description' Ptr Bool
enabled';
        if Bool
ok then do
            String
name <- CString -> IO String
peekCString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall a. Storable a => Ptr a -> IO a
peek Ptr CString
name'
            String
description <- CString -> IO String
peekCString forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall a. Storable a => Ptr a -> IO a
peek Ptr CString
description'
            Bool
enabled <- forall a. Storable a => Ptr a -> IO a
peek Ptr Bool
enabled'
            forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just (String
name, String
description, Bool
enabled)
        else forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing}
    let go :: IO [(String, String, Bool)]
go = do {
        Maybe (String, String, Bool)
ent' <- IO (Maybe (String, String, Bool))
readEnt;
        case Maybe (String, String, Bool)
ent' of
            Just (String, String, Bool)
ent -> do
                Bool
ok <- Config_ -> Ptr ConfigFileInfoIter' -> IO Bool
fcConfigFileInfoIterNext Config_
config' Ptr ConfigFileInfoIter'
iter'
                [(String, String, Bool)]
ents <- if Bool
ok then IO [(String, String, Bool)]
go else forall (m :: * -> *) a. Monad m => a -> m a
return []
                forall (m :: * -> *) a. Monad m => a -> m a
return ((String, String, Bool)
ent forall a. a -> [a] -> [a]
: [(String, String, Bool)]
ents)
            Maybe (String, String, Bool)
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return []}
    IO [(String, String, Bool)]
go
-- | Variant `configGetFileInfo` which operates upon current configuration.
configGetFileInfo' :: IO [(FilePath, String, Bool)]
configGetFileInfo' :: IO [(String, String, Bool)]
configGetFileInfo' = IO Config
configGetCurrent forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Config -> IO [(String, String, Bool)]
configGetFileInfo
data ConfigFileInfoIter'
foreign import ccall "size_ConfigFileInfoIter" configFileInfoIter'Size :: Int
type ConfigFileInfoIter_ = Ptr ConfigFileInfoIter'
foreign import ccall "FcConfigFileInfoIterInit" fcConfigFileInfoIterInit ::
    Config_ -> ConfigFileInfoIter_ -> IO ()
foreign import ccall "FcConfigFileInfoIterNext" fcConfigFileInfoIterNext ::
    Config_ -> ConfigFileInfoIter_ -> IO Bool
foreign import ccall "FcConfigFileInfoIterGet" fcConfigFileInfoIterGet ::
    Config_ -> ConfigFileInfoIter_ -> Ptr CString -> Ptr CString -> Ptr Bool -> IO Bool

------

configStrsFunc :: (Config_ -> IO StrList_) -> Config -> IO StrList
configStrsFunc :: (Config_ -> IO StrList_) -> Config -> IO StrList
configStrsFunc Config_ -> IO StrList_
cb Config
config = IO StrList_ -> IO StrList
thawStrList_ forall a b. (a -> b) -> a -> b
$ forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr Config
config Config_ -> IO StrList_
cb