{-# LINE 1 "src/Text/Bibutils.hsc" #-}
{-# CFILES cbits/stub.c #-}
-----------------------------------------------------------------------------
-- |
-- Module      :  Text..Bibutils
-- Copyright   :  (C) 2008 Andrea Rossato
-- License     :  BSD3
--
-- Maintainer  :  vhaisman@gmail.com
-- Stability   :  provisional
-- Portability :  portable
--
-- Here is a simple program using hs-bibutils to conver a MODS
-- collection into a bibtex file, sending the output to stdout:
--
-- > import Text.Bibutils
-- >
-- > main :: IO ()
-- > main = do
-- >   bibl  <- bibl_init
-- >   param <- bibl_initparams mods_in bibtex_out "mods2bibtex"
-- >   setFormatOpts param [bibout_brackets, bibout_uppercase]
-- >   setBOM        param
-- >   setVerbose    param
-- >   bibl_read     param bibl "/path/to/bibtex.bib"
-- >   bibl_write    param bibl "-"
-- >   bibl_free       bibl
-- >   bibl_freeparams param
--
-----------------------------------------------------------------------------

module Text.Bibutils
    ( -- * Basic Functions
      Bibl
    , Param (..)
    , bibl_init
    , bibl_initparams
    , bibl_read
    , bibl_write
    , bibl_readasis
    , bibl_addtoasis
    , bibl_readcorps
    , bibl_addtocorps
    , bibl_free
    , bibl_freeparams
    , bibl_reporterr

    -- * Auxiliary Functions
    , numberOfRefs
    , status
    -- ** Functions for Setting Parameters
    , setParam
    , setFormatOpts
    , setCharsetIn
    , setCharsetOut
    , setBOM
    , unsetBOM
    , setNoSplitTitle
    , unsetNoSplitTitle
    , setLatexOut
    , unsetLatexOut
    , setXmlOut
    , unsetXmlOut
    , setAddcount
    , unsetAddcount
    , setSinglerefperfile
    , unsetSinglerefperfile
    , setOutputRawOpts
    , setVerbose
    , setVerboseLevel
    , unsetVerbose

    -- * Input Formats
    , BiblioIn
    , mods_in
    , bibtex_in
    , ris_in
    , endnote_in
    , copac_in
    , isi_in
    , medline_in
    , biblatex_in
    , endnotexml_in
    , ebi_in
    , word_in
    , nbib_in

    -- * Output Formats
    , BiblioOut
    , mods_out
    , bibtex_out
    , ris_out
    , endnote_out
    , isi_out
    , word2007_out
    , adsab_out
    , nbib_out

    -- * Options for Specific Output Formats
    , FormatOpt
    , bibout_finalcomma
    , bibout_singledash
    , bibout_whitespace
    , bibout_brackets
    , bibout_uppercase
    , bibout_strictkey
    , bibout_shorttitle
    , bibout_dropkey
    , modsout_dropkey

    -- * Charsets
    , Charset
    , bibl_charset_unknown
    , bibl_charset_unicode
    , bibl_charset_gb18030
    , bibl_charset_default
    , bibl_charset_utf8_default
    , bibl_charset_bom_default

    -- * Return Status
    , Status
    , bibl_ok
    , bibl_err_badinput
    , bibl_err_memerr
    , bibl_err_cantopen

    -- * Raw
    , Raw
    , bibl_raw_with_charset_convert
    , bibl_raw_with_make_ref_id

    ) where

import Control.Monad
import Foreign.C
import Foreign

-- | A type for storing the C struct with the bibliography data.
-- Mostly opaque to the Haskell side. See 'numberOfRefs' to retrieve
-- the number of references stored in the struct.
newtype Bibl = Bibl { Bibl -> CLong
n :: CLong }

instance Storable Bibl where
    sizeOf :: Bibl -> Int
sizeOf    Bibl
_     = (Int
24)
{-# LINE 144 "src/Text/Bibutils.hsc" #-}
    alignment _     = 8
{-# LINE 145 "src/Text/Bibutils.hsc" #-}
    peek p          = (\hsc_ptr -> peekByteOff hsc_ptr 0) p >>= return . Bibl
{-# LINE 146 "src/Text/Bibutils.hsc" #-}
    poke p (Bibl x) = (\hsc_ptr -> pokeByteOff hsc_ptr 0) p x
{-# LINE 147 "src/Text/Bibutils.hsc" #-}

-- | Initialize the 'Bibl' C struct. Usually the first function being
-- called.
bibl_init :: IO (ForeignPtr Bibl)
bibl_init :: IO (ForeignPtr Bibl)
bibl_init
    = (Ptr Bibl -> IO (ForeignPtr Bibl)) -> IO (ForeignPtr Bibl)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Bibl -> IO (ForeignPtr Bibl)) -> IO (ForeignPtr Bibl))
-> (Ptr Bibl -> IO (ForeignPtr Bibl)) -> IO (ForeignPtr Bibl)
forall a b. (a -> b) -> a -> b
$ \Ptr Bibl
p -> do
        Ptr Bibl -> IO ()
c_bibl_init    Ptr Bibl
p
        Ptr Bibl -> IO (ForeignPtr Bibl)
forall a. Ptr a -> IO (ForeignPtr a)
newForeignPtr_ Ptr Bibl
p

-- | Free the 'Bibl' C struct.
bibl_free :: ForeignPtr Bibl -> IO ()
bibl_free :: ForeignPtr Bibl -> IO ()
bibl_free ForeignPtr Bibl
bibl = ForeignPtr Bibl -> (Ptr Bibl -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Bibl
bibl Ptr Bibl -> IO ()
c_bibl_free

-- | Retrieve the number of references from a 'Bibl' C struct.
numberOfRefs :: ForeignPtr Bibl -> IO Int
numberOfRefs :: ForeignPtr Bibl -> IO Int
numberOfRefs ForeignPtr Bibl
b
    = ForeignPtr Bibl -> (Ptr Bibl -> IO Int) -> IO Int
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Bibl
b ((Ptr Bibl -> IO Int) -> IO Int) -> (Ptr Bibl -> IO Int) -> IO Int
forall a b. (a -> b) -> a -> b
$ \Ptr Bibl
cb -> Ptr Bibl -> IO Bibl
forall a. Storable a => Ptr a -> IO a
peek Ptr Bibl
cb IO Bibl -> (Bibl -> IO Int) -> IO Int
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Int -> IO Int
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Int -> IO Int) -> (Bibl -> Int) -> Bibl -> IO Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CLong -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (CLong -> Int) -> (Bibl -> CLong) -> Bibl -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bibl -> CLong
n

-- | A type for storing the Param C struct. It should be accessed with
-- the functions provided, such as 'setCharsetIn', etc.
data Param
    = Param
      { Param -> CInt
redaformat       :: CInt
      , Param -> CInt
writeformat      :: CInt
      , Param -> CInt
charsetin        :: CInt
      , Param -> CUChar
charsetin_src    :: CUChar
      , Param -> CUChar
latexin          :: CUChar
      , Param -> CUChar
utf8in           :: CUChar
      , Param -> CUChar
xmlin            :: CUChar
      , Param -> CUChar
nosplittitle     :: CUChar
      , Param -> CInt
charsetout       :: CInt
      , Param -> CUChar
charsetout_src   :: CUChar
      , Param -> CUChar
latexout         :: CUChar
      , Param -> CUChar
utf8out          :: CUChar
      , Param -> CUChar
utf8bom          :: CUChar
      , Param -> CUChar
xmlout           :: CUChar
      , Param -> CInt
format_opts      :: CInt
      , Param -> CInt
addcount         :: CInt
      , Param -> CUChar
output_raw       :: CUChar
      , Param -> CUChar
verbose          :: CUChar
      , Param -> CUChar
singlerefperfile :: CUChar
      } deriving ( Int -> Param -> ShowS
[Param] -> ShowS
Param -> FilePath
(Int -> Param -> ShowS)
-> (Param -> FilePath) -> ([Param] -> ShowS) -> Show Param
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Param -> ShowS
showsPrec :: Int -> Param -> ShowS
$cshow :: Param -> FilePath
show :: Param -> FilePath
$cshowList :: [Param] -> ShowS
showList :: [Param] -> ShowS
Show )

instance Storable Param where
    sizeOf :: Param -> Int
sizeOf    Param
_ = (Int
192)
{-# LINE 192 "src/Text/Bibutils.hsc" #-}
    alignment _ = 8
{-# LINE 193 "src/Text/Bibutils.hsc" #-}
    peek p      =  Param
                  `fmap` (\hsc_ptr -> peekByteOff hsc_ptr 0) p
{-# LINE 195 "src/Text/Bibutils.hsc" #-}
                  `ap`   (\hsc_ptr -> peekByteOff hsc_ptr 4) p
{-# LINE 196 "src/Text/Bibutils.hsc" #-}
                  `ap`   (\hsc_ptr -> peekByteOff hsc_ptr 8) p
{-# LINE 197 "src/Text/Bibutils.hsc" #-}
                  `ap`   (\hsc_ptr -> peekByteOff hsc_ptr 12) p
{-# LINE 198 "src/Text/Bibutils.hsc" #-}
                  `ap`   (\hsc_ptr -> peekByteOff hsc_ptr 13) p
{-# LINE 199 "src/Text/Bibutils.hsc" #-}
                  `ap`   (\hsc_ptr -> peekByteOff hsc_ptr 14) p
{-# LINE 200 "src/Text/Bibutils.hsc" #-}
                  `ap`   (\hsc_ptr -> peekByteOff hsc_ptr 15) p
{-# LINE 201 "src/Text/Bibutils.hsc" #-}
                  `ap`   (\hsc_ptr -> peekByteOff hsc_ptr 16) p
{-# LINE 202 "src/Text/Bibutils.hsc" #-}
                  `ap`   (\hsc_ptr -> peekByteOff hsc_ptr 20) p
{-# LINE 203 "src/Text/Bibutils.hsc" #-}
                  `ap`   (\hsc_ptr -> peekByteOff hsc_ptr 24) p
{-# LINE 204 "src/Text/Bibutils.hsc" #-}
                  `ap`   (\hsc_ptr -> peekByteOff hsc_ptr 25) p
{-# LINE 205 "src/Text/Bibutils.hsc" #-}
                  `ap`   (\hsc_ptr -> peekByteOff hsc_ptr 26) p
{-# LINE 206 "src/Text/Bibutils.hsc" #-}
                  `ap`   (\hsc_ptr -> peekByteOff hsc_ptr 27) p
{-# LINE 207 "src/Text/Bibutils.hsc" #-}
                  `ap`   (\hsc_ptr -> peekByteOff hsc_ptr 28) p
{-# LINE 208 "src/Text/Bibutils.hsc" #-}
                  `ap`   (\hsc_ptr -> peekByteOff hsc_ptr 32) p
{-# LINE 209 "src/Text/Bibutils.hsc" #-}
                  `ap`   (\hsc_ptr -> peekByteOff hsc_ptr 36) p
{-# LINE 210 "src/Text/Bibutils.hsc" #-}
                  `ap`   (\hsc_ptr -> peekByteOff hsc_ptr 40) p
{-# LINE 211 "src/Text/Bibutils.hsc" #-}
                  `ap`   (\hsc_ptr -> peekByteOff hsc_ptr 41) p
{-# LINE 212 "src/Text/Bibutils.hsc" #-}
                  `ap`   (\hsc_ptr -> peekByteOff hsc_ptr 42) p
{-# LINE 213 "src/Text/Bibutils.hsc" #-}
    poke p (Param rf wf ci csi li ui xi nt co cso lo uo ub xo fo a raw v s) = do
                         (\hsc_ptr -> pokeByteOff hsc_ptr 0) p rf
{-# LINE 215 "src/Text/Bibutils.hsc" #-}
                         (\hsc_ptr -> pokeByteOff hsc_ptr 4) p wf
{-# LINE 216 "src/Text/Bibutils.hsc" #-}
                         (\hsc_ptr -> pokeByteOff hsc_ptr 8) p ci
{-# LINE 217 "src/Text/Bibutils.hsc" #-}
                         (\hsc_ptr -> pokeByteOff hsc_ptr 12) p csi
{-# LINE 218 "src/Text/Bibutils.hsc" #-}
                         (\hsc_ptr -> pokeByteOff hsc_ptr 13) p li
{-# LINE 219 "src/Text/Bibutils.hsc" #-}
                         (\hsc_ptr -> pokeByteOff hsc_ptr 14) p ui
{-# LINE 220 "src/Text/Bibutils.hsc" #-}
                         (\hsc_ptr -> pokeByteOff hsc_ptr 15) p xi
{-# LINE 221 "src/Text/Bibutils.hsc" #-}
                         (\hsc_ptr -> pokeByteOff hsc_ptr 16) p nt
{-# LINE 222 "src/Text/Bibutils.hsc" #-}
                         (\hsc_ptr -> pokeByteOff hsc_ptr 20) p co
{-# LINE 223 "src/Text/Bibutils.hsc" #-}
                         (\hsc_ptr -> pokeByteOff hsc_ptr 24) p cso
{-# LINE 224 "src/Text/Bibutils.hsc" #-}
                         (\hsc_ptr -> pokeByteOff hsc_ptr 25) p lo
{-# LINE 225 "src/Text/Bibutils.hsc" #-}
                         (\hsc_ptr -> pokeByteOff hsc_ptr 26) p uo
{-# LINE 226 "src/Text/Bibutils.hsc" #-}
                         (\hsc_ptr -> pokeByteOff hsc_ptr 27) p ub
{-# LINE 227 "src/Text/Bibutils.hsc" #-}
                         (\hsc_ptr -> pokeByteOff hsc_ptr 28) p xo
{-# LINE 228 "src/Text/Bibutils.hsc" #-}
                         (\hsc_ptr -> pokeByteOff hsc_ptr 32) p fo
{-# LINE 229 "src/Text/Bibutils.hsc" #-}
                         (\hsc_ptr -> pokeByteOff hsc_ptr 36) p a
{-# LINE 230 "src/Text/Bibutils.hsc" #-}
                         (\hsc_ptr -> pokeByteOff hsc_ptr 40) p raw
{-# LINE 231 "src/Text/Bibutils.hsc" #-}
                         (\hsc_ptr -> pokeByteOff hsc_ptr 41) p v
{-# LINE 232 "src/Text/Bibutils.hsc" #-}
                         (\hsc_ptr -> pokeByteOff hsc_ptr 42) p s
{-# LINE 233 "src/Text/Bibutils.hsc" #-}

-- | Initialize the 'Param' C struct, given the input bibliographic
-- format, the output bibliographic format, and the program name to
-- be used for displaying debugging information.
bibl_initparams :: BiblioIn -> BiblioOut -> String -> IO (ForeignPtr Param)
bibl_initparams :: BiblioIn -> BiblioOut -> FilePath -> IO (ForeignPtr Param)
bibl_initparams BiblioIn
i BiblioOut
o FilePath
s
    = (Ptr Param -> IO (ForeignPtr Param)) -> IO (ForeignPtr Param)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca ((Ptr Param -> IO (ForeignPtr Param)) -> IO (ForeignPtr Param))
-> (Ptr Param -> IO (ForeignPtr Param)) -> IO (ForeignPtr Param)
forall a b. (a -> b) -> a -> b
$ \Ptr Param
p -> FilePath
-> (CString -> IO (ForeignPtr Param)) -> IO (ForeignPtr Param)
forall a. FilePath -> (CString -> IO a) -> IO a
withCString FilePath
s ((CString -> IO (ForeignPtr Param)) -> IO (ForeignPtr Param))
-> (CString -> IO (ForeignPtr Param)) -> IO (ForeignPtr Param)
forall a b. (a -> b) -> a -> b
$ \CString
cs  -> do
        Ptr Param -> CInt -> CInt -> CString -> IO ()
c_bibl_initparams Ptr Param
p (BiblioIn -> CInt
unBiblioIn BiblioIn
i) (BiblioOut -> CInt
unBiblioOut BiblioOut
o) CString
cs
        Ptr Param -> IO (ForeignPtr Param)
forall a. Ptr a -> IO (ForeignPtr a)
newForeignPtr_ Ptr Param
p

-- | Free the 'Param' C struct.
bibl_freeparams :: ForeignPtr Param -> IO ()
bibl_freeparams :: ForeignPtr Param -> IO ()
bibl_freeparams ForeignPtr Param
param = ForeignPtr Param -> (Ptr Param -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Param
param Ptr Param -> IO ()
c_bibl_freeparams

-- | Set fields of the 'Param' C struct directly.
setParam :: ForeignPtr Param -> (Param -> Param) -> IO ()
setParam :: ForeignPtr Param -> (Param -> Param) -> IO ()
setParam ForeignPtr Param
p Param -> Param
f = ForeignPtr Param -> (Ptr Param -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Param
p ((Ptr Param -> IO ()) -> IO ()) -> (Ptr Param -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Param
cp -> Ptr Param -> IO Param
forall a. Storable a => Ptr a -> IO a
peek Ptr Param
cp IO Param -> (Param -> IO ()) -> IO ()
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Ptr Param -> Param -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr Param
cp (Param -> IO ()) -> (Param -> Param) -> Param -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Param -> Param
f

-- | Set the input charset. Default is Latin-1 (ISO8859-1). See
-- 'Charset'.
setCharsetIn ::  ForeignPtr Param -> Charset -> IO ()
setCharsetIn :: ForeignPtr Param -> Charset -> IO ()
setCharsetIn ForeignPtr Param
p Charset
c
    = ForeignPtr Param -> (Param -> Param) -> IO ()
setParam ForeignPtr Param
p ((Param -> Param) -> IO ()) -> (Param -> Param) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Param
param -> Param
param { charsetin :: CInt
charsetin = Charset -> CInt
charset Charset
c }

-- | Set the output charset.
setCharsetOut ::  ForeignPtr Param -> Charset -> IO ()
setCharsetOut :: ForeignPtr Param -> Charset -> IO ()
setCharsetOut ForeignPtr Param
p Charset
c
    = ForeignPtr Param -> (Param -> Param) -> IO ()
setParam ForeignPtr Param
p ((Param -> Param) -> IO ()) -> (Param -> Param) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Param
param -> Param
param { charsetout :: CInt
charsetout = Charset -> CInt
charset Charset
c }

-- | Set output format specific options. See 'FormatOpt'.
setFormatOpts ::  ForeignPtr Param -> [FormatOpt] -> IO ()
setFormatOpts :: ForeignPtr Param -> [FormatOpt] -> IO ()
setFormatOpts ForeignPtr Param
p [FormatOpt]
os
    = ForeignPtr Param -> (Param -> Param) -> IO ()
setParam ForeignPtr Param
p ((Param -> Param) -> IO ()) -> (Param -> Param) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Param
param -> Param
param { format_opts :: CInt
format_opts = FormatOpt -> CInt
unFormatOpt (FormatOpt -> CInt) -> FormatOpt -> CInt
forall a b. (a -> b) -> a -> b
$ [FormatOpt] -> FormatOpt
combineFormatOpts [FormatOpt]
os }

-- | Write utf8 byte-order-mark.
setBOM ::  ForeignPtr Param -> IO ()
setBOM :: ForeignPtr Param -> IO ()
setBOM ForeignPtr Param
p
    = ForeignPtr Param -> (Param -> Param) -> IO ()
setParam ForeignPtr Param
p ((Param -> Param) -> IO ()) -> (Param -> Param) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Param
param -> Param
param { utf8bom :: CUChar
utf8bom = CUChar
1 }

unsetBOM ::  ForeignPtr Param -> IO ()
unsetBOM :: ForeignPtr Param -> IO ()
unsetBOM ForeignPtr Param
p
    = ForeignPtr Param -> (Param -> Param) -> IO ()
setParam ForeignPtr Param
p ((Param -> Param) -> IO ()) -> (Param -> Param) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Param
param -> Param
param { utf8bom :: CUChar
utf8bom = CUChar
0 }

-- | Do not split titles.
setNoSplitTitle ::  ForeignPtr Param -> IO ()
setNoSplitTitle :: ForeignPtr Param -> IO ()
setNoSplitTitle ForeignPtr Param
p
    = ForeignPtr Param -> (Param -> Param) -> IO ()
setParam ForeignPtr Param
p ((Param -> Param) -> IO ()) -> (Param -> Param) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Param
param -> Param
param { nosplittitle :: CUChar
nosplittitle = CUChar
1 }

-- | Split titles.
unsetNoSplitTitle ::  ForeignPtr Param -> IO ()
unsetNoSplitTitle :: ForeignPtr Param -> IO ()
unsetNoSplitTitle ForeignPtr Param
p
    = ForeignPtr Param -> (Param -> Param) -> IO ()
setParam ForeignPtr Param
p ((Param -> Param) -> IO ()) -> (Param -> Param) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Param
param -> Param
param { nosplittitle :: CUChar
nosplittitle = CUChar
0 }

-- | Write Latex codes.
setLatexOut ::  ForeignPtr Param -> IO ()
setLatexOut :: ForeignPtr Param -> IO ()
setLatexOut ForeignPtr Param
p
    = ForeignPtr Param -> (Param -> Param) -> IO ()
setParam ForeignPtr Param
p ((Param -> Param) -> IO ()) -> (Param -> Param) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Param
param -> Param
param { latexout :: CUChar
latexout = CUChar
1 }

unsetLatexOut ::  ForeignPtr Param -> IO ()
unsetLatexOut :: ForeignPtr Param -> IO ()
unsetLatexOut ForeignPtr Param
p
    = ForeignPtr Param -> (Param -> Param) -> IO ()
setParam ForeignPtr Param
p ((Param -> Param) -> IO ()) -> (Param -> Param) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Param
param -> Param
param { latexout :: CUChar
latexout = CUChar
0 }

-- | Write characters in XML entities.
setXmlOut ::  ForeignPtr Param -> IO ()
setXmlOut :: ForeignPtr Param -> IO ()
setXmlOut ForeignPtr Param
p
    = ForeignPtr Param -> (Param -> Param) -> IO ()
setParam ForeignPtr Param
p ((Param -> Param) -> IO ()) -> (Param -> Param) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Param
param -> Param
param { xmlout :: CUChar
xmlout = CUChar
1 }

unsetXmlOut ::  ForeignPtr Param -> IO ()
unsetXmlOut :: ForeignPtr Param -> IO ()
unsetXmlOut ForeignPtr Param
p
    = ForeignPtr Param -> (Param -> Param) -> IO ()
setParam ForeignPtr Param
p ((Param -> Param) -> IO ()) -> (Param -> Param) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Param
param -> Param
param { xmlout :: CUChar
xmlout = CUChar
0 }

-- | Add reference count to reference id.
setAddcount ::  ForeignPtr Param -> IO ()
setAddcount :: ForeignPtr Param -> IO ()
setAddcount ForeignPtr Param
p
    = ForeignPtr Param -> (Param -> Param) -> IO ()
setParam ForeignPtr Param
p ((Param -> Param) -> IO ()) -> (Param -> Param) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Param
param -> Param
param { addcount :: CInt
addcount = CInt
1 }

unsetAddcount ::  ForeignPtr Param -> IO ()
unsetAddcount :: ForeignPtr Param -> IO ()
unsetAddcount ForeignPtr Param
p
    = ForeignPtr Param -> (Param -> Param) -> IO ()
setParam ForeignPtr Param
p ((Param -> Param) -> IO ()) -> (Param -> Param) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Param
param -> Param
param { addcount :: CInt
addcount = CInt
0 }

-- | Output a single reference for each file.
setSinglerefperfile ::  ForeignPtr Param -> IO ()
setSinglerefperfile :: ForeignPtr Param -> IO ()
setSinglerefperfile ForeignPtr Param
p
    = ForeignPtr Param -> (Param -> Param) -> IO ()
setParam ForeignPtr Param
p ((Param -> Param) -> IO ()) -> (Param -> Param) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Param
param -> Param
param { singlerefperfile :: CUChar
singlerefperfile = CUChar
1 }

unsetSinglerefperfile ::  ForeignPtr Param -> IO ()
unsetSinglerefperfile :: ForeignPtr Param -> IO ()
unsetSinglerefperfile ForeignPtr Param
p
    = ForeignPtr Param -> (Param -> Param) -> IO ()
setParam ForeignPtr Param
p ((Param -> Param) -> IO ()) -> (Param -> Param) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Param
param -> Param
param { singlerefperfile :: CUChar
singlerefperfile = CUChar
0 }

-- | Set the output charset.
setOutputRawOpts ::  ForeignPtr Param -> [Raw] -> IO ()
setOutputRawOpts :: ForeignPtr Param -> [Raw] -> IO ()
setOutputRawOpts ForeignPtr Param
p [Raw]
os
    = ForeignPtr Param -> (Param -> Param) -> IO ()
setParam ForeignPtr Param
p ((Param -> Param) -> IO ()) -> (Param -> Param) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Param
param -> Param
param { output_raw :: CUChar
output_raw = Raw -> CUChar
unRaw (Raw -> CUChar) -> Raw -> CUChar
forall a b. (a -> b) -> a -> b
$ [Raw] -> Raw
combineRawOpts [Raw]
os }

-- | Verbose output.
setVerbose ::  ForeignPtr Param -> IO ()
setVerbose :: ForeignPtr Param -> IO ()
setVerbose ForeignPtr Param
p
    = ForeignPtr Param -> (Param -> Param) -> IO ()
setParam ForeignPtr Param
p ((Param -> Param) -> IO ()) -> (Param -> Param) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Param
param -> Param
param { verbose :: CUChar
verbose = CUChar
1 }

-- | Verbose output.
setVerboseLevel ::  ForeignPtr Param -> Int -> IO ()
setVerboseLevel :: ForeignPtr Param -> Int -> IO ()
setVerboseLevel ForeignPtr Param
p Int
v
    = ForeignPtr Param -> (Param -> Param) -> IO ()
setParam ForeignPtr Param
p ((Param -> Param) -> IO ()) -> (Param -> Param) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Param
param -> Param
param { verbose :: CUChar
verbose = Int -> CUChar
forall a. Enum a => Int -> a
toEnum Int
v }

-- | Suppress verbose output.
unsetVerbose ::  ForeignPtr Param -> IO ()
unsetVerbose :: ForeignPtr Param -> IO ()
unsetVerbose ForeignPtr Param
p
    = ForeignPtr Param -> (Param -> Param) -> IO ()
setParam ForeignPtr Param
p ((Param -> Param) -> IO ()) -> (Param -> Param) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Param
param -> Param
param { verbose :: CUChar
verbose = CUChar
0 }

-- | Given a 'Param' C structure, a 'Bibl' C structure, the path to
-- the input file (@\"-\"@ for the standard input), read the file,
-- storing the data in the 'Bibl' struct, and report a 'Status'.
bibl_read :: ForeignPtr Param -> ForeignPtr Bibl -> FilePath -> IO Status
bibl_read :: ForeignPtr Param -> ForeignPtr Bibl -> FilePath -> IO Status
bibl_read ForeignPtr Param
param ForeignPtr Bibl
bibl FilePath
path
    = ForeignPtr Param -> (Ptr Param -> IO Status) -> IO Status
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Param
param ((Ptr Param -> IO Status) -> IO Status)
-> (Ptr Param -> IO Status) -> IO Status
forall a b. (a -> b) -> a -> b
$ \Ptr Param
cparam ->
      ForeignPtr Bibl -> (Ptr Bibl -> IO Status) -> IO Status
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Bibl
bibl  ((Ptr Bibl -> IO Status) -> IO Status)
-> (Ptr Bibl -> IO Status) -> IO Status
forall a b. (a -> b) -> a -> b
$ \Ptr Bibl
cbibl  ->
      FilePath -> (CString -> IO Status) -> IO Status
forall a. FilePath -> (CString -> IO a) -> IO a
withCString    FilePath
path  ((CString -> IO Status) -> IO Status)
-> (CString -> IO Status) -> IO Status
forall a b. (a -> b) -> a -> b
$ \CString
cpath  ->
      FilePath -> (CString -> IO Status) -> IO Status
forall a. FilePath -> (CString -> IO a) -> IO a
withCString    FilePath
"r"   ((CString -> IO Status) -> IO Status)
-> (CString -> IO Status) -> IO Status
forall a b. (a -> b) -> a -> b
$ \CString
cmode  -> do
        Ptr CFile
cfile <- if FilePath
path FilePath -> FilePath -> Bool
forall a. Eq a => a -> a -> Bool
== FilePath
"-"
                 then Ptr CFile -> IO (Ptr CFile)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CFile
c_stdin
                 else FilePath -> IO (Ptr CFile) -> IO (Ptr CFile)
forall a. FilePath -> IO (Ptr a) -> IO (Ptr a)
throwErrnoIfNull FilePath
"fopen: " (CString -> CString -> IO (Ptr CFile)
fopen CString
cpath CString
cmode)
        CInt
cint  <- Ptr Bibl -> Ptr CFile -> CString -> Ptr Param -> IO CInt
c_bibl_read Ptr Bibl
cbibl Ptr CFile
cfile CString
cpath Ptr Param
cparam
        Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (FilePath
path FilePath -> FilePath -> Bool
forall a. Eq a => a -> a -> Bool
/= FilePath
"-") (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ Ptr CFile -> IO CInt
fclose Ptr CFile
cfile IO CInt -> IO () -> IO ()
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
        Status -> IO Status
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Status -> IO Status) -> Status -> IO Status
forall a b. (a -> b) -> a -> b
$ CInt -> Status
Status CInt
cint

-- | Given a 'Param' C structure, a 'Bibl' C structure, the path to an
-- output file (@\"-\"@ for the standard output), write the file
-- returning a 'Status'.
bibl_write :: ForeignPtr Param -> ForeignPtr Bibl -> FilePath -> IO Status
bibl_write :: ForeignPtr Param -> ForeignPtr Bibl -> FilePath -> IO Status
bibl_write ForeignPtr Param
param ForeignPtr Bibl
bibl FilePath
path
    = ForeignPtr Param -> (Ptr Param -> IO Status) -> IO Status
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Param
param ((Ptr Param -> IO Status) -> IO Status)
-> (Ptr Param -> IO Status) -> IO Status
forall a b. (a -> b) -> a -> b
$ \Ptr Param
cparam ->
      ForeignPtr Bibl -> (Ptr Bibl -> IO Status) -> IO Status
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Bibl
bibl  ((Ptr Bibl -> IO Status) -> IO Status)
-> (Ptr Bibl -> IO Status) -> IO Status
forall a b. (a -> b) -> a -> b
$ \Ptr Bibl
cbibl  ->
      FilePath -> (CString -> IO Status) -> IO Status
forall a. FilePath -> (CString -> IO a) -> IO a
withCString    FilePath
"w"   ((CString -> IO Status) -> IO Status)
-> (CString -> IO Status) -> IO Status
forall a b. (a -> b) -> a -> b
$ \CString
cmode  -> do
        Ptr CFile
cfile <- if FilePath
path FilePath -> FilePath -> Bool
forall a. Eq a => a -> a -> Bool
== FilePath
"-"
                 then Ptr CFile -> IO (Ptr CFile)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CFile
c_stdout
                 else FilePath -> (CString -> IO (Ptr CFile)) -> IO (Ptr CFile)
forall a. FilePath -> (CString -> IO a) -> IO a
withCString FilePath
path ((CString -> IO (Ptr CFile)) -> IO (Ptr CFile))
-> (CString -> IO (Ptr CFile)) -> IO (Ptr CFile)
forall a b. (a -> b) -> a -> b
$ FilePath -> IO (Ptr CFile) -> IO (Ptr CFile)
forall a. FilePath -> IO (Ptr a) -> IO (Ptr a)
throwErrnoIfNull FilePath
"fopen: " (IO (Ptr CFile) -> IO (Ptr CFile))
-> (CString -> IO (Ptr CFile)) -> CString -> IO (Ptr CFile)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CString -> CString -> IO (Ptr CFile))
-> CString -> CString -> IO (Ptr CFile)
forall a b c. (a -> b -> c) -> b -> a -> c
flip CString -> CString -> IO (Ptr CFile)
fopen CString
cmode
        CInt
cint <- Ptr Bibl -> Ptr CFile -> Ptr Param -> IO CInt
c_bibl_write Ptr Bibl
cbibl Ptr CFile
cfile Ptr Param
cparam
        Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (FilePath
path FilePath -> FilePath -> Bool
forall a. Eq a => a -> a -> Bool
/= FilePath
"-") (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ Ptr CFile -> IO CInt
fclose Ptr CFile
cfile IO CInt -> IO () -> IO ()
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
        Status -> IO Status
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Status -> IO Status) -> Status -> IO Status
forall a b. (a -> b) -> a -> b
$ CInt -> Status
Status CInt
cint

bibl_readasis :: ForeignPtr Param -> FilePath -> IO ()
bibl_readasis :: ForeignPtr Param -> FilePath -> IO ()
bibl_readasis ForeignPtr Param
param FilePath
path
    = ForeignPtr Param -> (Ptr Param -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Param
param  ((Ptr Param -> IO ()) -> IO ()) -> (Ptr Param -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Param
cparam ->
      FilePath -> (CString -> IO ()) -> IO ()
forall a. FilePath -> (CString -> IO a) -> IO a
withCString    FilePath
path  ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \CString
cpath   -> do
        Ptr Param -> CString -> IO ()
c_bibl_readasis Ptr Param
cparam CString
cpath

bibl_addtoasis :: ForeignPtr Param -> String -> IO ()
bibl_addtoasis :: ForeignPtr Param -> FilePath -> IO ()
bibl_addtoasis ForeignPtr Param
param FilePath
entry
    = ForeignPtr Param -> (Ptr Param -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Param
param ((Ptr Param -> IO ()) -> IO ()) -> (Ptr Param -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Param
cparam ->
      FilePath -> (CString -> IO ()) -> IO ()
forall a. FilePath -> (CString -> IO a) -> IO a
withCString    FilePath
entry ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \CString
centry -> do
        Ptr Param -> CString -> IO ()
c_bibl_addtoasis Ptr Param
cparam CString
centry

bibl_readcorps :: ForeignPtr Param -> FilePath -> IO ()
bibl_readcorps :: ForeignPtr Param -> FilePath -> IO ()
bibl_readcorps ForeignPtr Param
param FilePath
path
    = ForeignPtr Param -> (Ptr Param -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Param
param  ((Ptr Param -> IO ()) -> IO ()) -> (Ptr Param -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Param
cparam ->
      FilePath -> (CString -> IO ()) -> IO ()
forall a. FilePath -> (CString -> IO a) -> IO a
withCString    FilePath
path  ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \CString
cpath   -> do
        Ptr Param -> CString -> IO ()
c_bibl_readcorps Ptr Param
cparam CString
cpath

bibl_addtocorps :: ForeignPtr Param -> String -> IO ()
bibl_addtocorps :: ForeignPtr Param -> FilePath -> IO ()
bibl_addtocorps ForeignPtr Param
param FilePath
entry
    = ForeignPtr Param -> (Ptr Param -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Param
param ((Ptr Param -> IO ()) -> IO ()) -> (Ptr Param -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Param
cparam ->
      FilePath -> (CString -> IO ()) -> IO ()
forall a. FilePath -> (CString -> IO a) -> IO a
withCString    FilePath
entry ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \CString
centry -> do
        Ptr Param -> CString -> IO ()
c_bibl_addtocorps Ptr Param
cparam CString
centry

bibl_reporterr :: Status -> IO ()
bibl_reporterr :: Status -> IO ()
bibl_reporterr (Status CInt
st) = CInt -> IO ()
c_bibl_reporterr CInt
st

newtype BiblioIn  = BiblioIn  { BiblioIn -> CInt
unBiblioIn  :: CInt }
    deriving ( BiblioIn -> BiblioIn -> Bool
(BiblioIn -> BiblioIn -> Bool)
-> (BiblioIn -> BiblioIn -> Bool) -> Eq BiblioIn
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BiblioIn -> BiblioIn -> Bool
== :: BiblioIn -> BiblioIn -> Bool
$c/= :: BiblioIn -> BiblioIn -> Bool
/= :: BiblioIn -> BiblioIn -> Bool
Eq )

mods_in        :: BiblioIn
mods_in :: BiblioIn
mods_in        = CInt -> BiblioIn
BiblioIn CInt
100
bibtex_in      :: BiblioIn
bibtex_in :: BiblioIn
bibtex_in      = CInt -> BiblioIn
BiblioIn CInt
101
ris_in         :: BiblioIn
ris_in :: BiblioIn
ris_in         = CInt -> BiblioIn
BiblioIn CInt
102
endnote_in     :: BiblioIn
endnote_in :: BiblioIn
endnote_in     = CInt -> BiblioIn
BiblioIn CInt
103
copac_in       :: BiblioIn
copac_in :: BiblioIn
copac_in       = CInt -> BiblioIn
BiblioIn CInt
104
isi_in         :: BiblioIn
isi_in :: BiblioIn
isi_in         = CInt -> BiblioIn
BiblioIn CInt
105
medline_in     :: BiblioIn
medline_in :: BiblioIn
medline_in     = CInt -> BiblioIn
BiblioIn CInt
106
endnotexml_in  :: BiblioIn
endnotexml_in :: BiblioIn
endnotexml_in  = CInt -> BiblioIn
BiblioIn CInt
107
biblatex_in    :: BiblioIn
biblatex_in :: BiblioIn
biblatex_in    = CInt -> BiblioIn
BiblioIn CInt
108
ebi_in         :: BiblioIn
ebi_in :: BiblioIn
ebi_in         = BiblioIn 109
word_in        :: BiblioIn
word_in :: BiblioIn
word_in        = BiblioIn 110
nbib_in        :: BiblioIn
nbib_in :: BiblioIn
ris_out :: BiblioOut
nbib_in        = BiblioIn 111

{-# LINE 417 "src/Text/Bibutils.hsc" #-}

newtype BiblioOut = BiblioOut { unBiblioOut :: CInt }
    deriving ( Eq )

mods_out      :: BiblioOut
mods_out      = BiblioOut 200
bibtex_out    :: BiblioOut
bibtex_out    = BiblioOut 201
ris_out       :: BiblioOut
ris_out       = BiblioOut 202
endnote_out   :: BiblioOut
endnote_out   = BiblioOut 203
isi_out       :: BiblioOut
isi_out :: BiblioOut
isi_out       = CInt -> BiblioOut
BiblioOut CInt
204
word2007_out  :: BiblioOut
word2007_out :: BiblioOut
word2007_out  = CInt -> BiblioOut
BiblioOut CInt
205
adsab_out     :: BiblioOut
adsab_out :: BiblioOut
adsab_out     = CInt -> BiblioOut
BiblioOut CInt
206
nbib_out      :: BiblioOut
nbib_out :: BiblioOut
nbib_out      = BiblioOut 207

{-# LINE 431 "src/Text/Bibutils.hsc" #-}

newtype FormatOpt = FormatOpt { unFormatOpt :: CInt }



bibout_finalcomma  :: FormatOpt
bibout_finalcomma  = FormatOpt 2
bibout_singledash  :: FormatOpt
bibout_singledash :: FormatOpt
bibout_singledash  = CInt -> FormatOpt
FormatOpt CInt
4
bibout_whitespace  :: FormatOpt
bibout_whitespace :: FormatOpt
bibout_whitespace  = CInt -> FormatOpt
FormatOpt CInt
8
bibout_brackets    :: FormatOpt
bibout_brackets :: FormatOpt
bibout_brackets    = CInt -> FormatOpt
FormatOpt CInt
16
bibout_uppercase   :: FormatOpt
bibout_uppercase :: FormatOpt
bibout_uppercase   = CInt -> FormatOpt
FormatOpt CInt
32
bibout_strictkey   :: FormatOpt
bibout_strictkey :: FormatOpt
bibout_strictkey   = CInt -> FormatOpt
FormatOpt CInt
64
bibout_shorttitle  :: FormatOpt
bibout_shorttitle  = FormatOpt 128
bibout_dropkey     :: FormatOpt
bibout_dropkey :: FormatOpt
bibout_dropkey     = CInt -> FormatOpt
FormatOpt CInt
256
modsout_dropkey    :: FormatOpt
modsout_dropkey :: FormatOpt
modsout_dropkey    = CInt -> FormatOpt
FormatOpt CInt
512

{-# LINE 447 "src/Text/Bibutils.hsc" #-}

newtype Status = Status { status :: CInt }
    deriving ( Eq, Show )

bibl_ok            :: Status
bibl_ok            = Status 0
bibl_err_badinput  :: Status
bibl_err_badinput  = Status (-1)
bibl_err_memerr    :: Status
bibl_err_memerr :: Status
bibl_err_memerr    = CInt -> Status
Status (-CInt
2)
bibl_err_cantopen  :: Status
bibl_err_cantopen :: Status
bibl_err_cantopen  = CInt -> Status
Status (-CInt
3)

{-# LINE 457 "src/Text/Bibutils.hsc" #-}

newtype Raw = Raw { unRaw :: CUChar }
    deriving ( Eq, Show )

bibl_raw_with_charset_convert  :: Raw
bibl_raw_with_charset_convert :: Raw
bibl_raw_with_charset_convert  = CUChar -> Raw
Raw CUChar
4
bibl_raw_with_make_ref_id      :: Raw
bibl_raw_with_make_ref_id :: Raw
bibl_raw_with_make_ref_id      = CUChar -> Raw
Raw CUChar
8

{-# LINE 465 "src/Text/Bibutils.hsc" #-}

newtype Charset = Charset { charset :: CInt } deriving ( Eq )

bibl_charset_unknown       :: Charset
bibl_charset_unknown :: Charset
bibl_charset_unknown       = CInt -> Charset
Charset (-CInt
1)
bibl_charset_unicode       :: Charset
bibl_charset_unicode :: Charset
bibl_charset_unicode       = CInt -> Charset
Charset (-CInt
2)
bibl_charset_gb18030       :: Charset
bibl_charset_gb18030 :: Charset
bibl_charset_gb18030       = CInt -> Charset
Charset (-CInt
3)
bibl_charset_default       :: Charset
bibl_charset_default :: Charset
bibl_charset_default       = CInt -> Charset
Charset (-CInt
2)
bibl_charset_utf8_default  :: Charset
bibl_charset_utf8_default :: Charset
bibl_charset_utf8_default  = CInt -> Charset
Charset CInt
1
bibl_charset_bom_default   :: Charset
bibl_charset_bom_default :: Charset
bibl_charset_bom_default   = CInt -> Charset
Charset CInt
1

{-# LINE 476 "src/Text/Bibutils.hsc" #-}

-- Combine a list of output options into a single option, using bitwise (.|.)
combineRawOpts :: [Raw] -> Raw
combineRawOpts = Raw . foldr ((.|.) . unRaw) 0

-- Combine a list of options into a single option, using bitwise (.|.)
combineFormatOpts :: [FormatOpt] -> FormatOpt
combineFormatOpts :: [FormatOpt] -> FormatOpt
combineFormatOpts = CInt -> FormatOpt
FormatOpt (CInt -> FormatOpt)
-> ([FormatOpt] -> CInt) -> [FormatOpt] -> FormatOpt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FormatOpt -> CInt -> CInt) -> CInt -> [FormatOpt] -> CInt
forall a b. (a -> b -> b) -> b -> [a] -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (CInt -> CInt -> CInt
forall a. Bits a => a -> a -> a
(.|.) (CInt -> CInt -> CInt)
-> (FormatOpt -> CInt) -> FormatOpt -> CInt -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FormatOpt -> CInt
unFormatOpt) CInt
0





foreign import ccall unsafe "bibl_init"
    c_bibl_init :: Ptr Bibl -> IO ()

foreign import ccall unsafe "bibl_free"
    c_bibl_free :: Ptr Bibl -> IO ()

foreign import ccall unsafe "bibl_initparams"
    c_bibl_initparams :: Ptr Param -> CInt -> CInt -> CString -> IO ()

foreign import ccall unsafe "bibl_freeparams"
    c_bibl_freeparams :: Ptr Param -> IO ()

foreign import ccall unsafe "bibl_read"
    c_bibl_read :: Ptr Bibl -> Ptr CFile -> CString -> Ptr Param -> IO CInt

foreign import ccall unsafe "bibl_write"
    c_bibl_write :: Ptr Bibl -> Ptr CFile -> Ptr Param -> IO CInt

foreign import ccall unsafe "bibl_readasis"
    c_bibl_readasis :: Ptr Param -> CString -> IO ()

foreign import ccall unsafe "bibl_addtoasis"
    c_bibl_addtoasis :: Ptr Param -> CString -> IO ()

foreign import ccall unsafe "bibl_readcorps"
    c_bibl_readcorps :: Ptr Param -> CString -> IO ()

foreign import ccall unsafe "bibl_addtocorps"
    c_bibl_addtocorps :: Ptr Param -> CString -> IO ()

foreign import ccall unsafe "bibl_reporterr"
    c_bibl_reporterr :: CInt -> IO ()

foreign import ccall unsafe "fopen"
    fopen :: CString -> CString -> IO (Ptr CFile)

foreign import ccall unsafe "fclose"
    fclose :: Ptr CFile -> IO CInt

foreign import ccall unsafe "c_stdin"  c_stdin  :: Ptr CFile
foreign import ccall unsafe "c_stdout" c_stdout :: Ptr CFile