hs-bibutils-5.0: Haskell bindings to bibutils, the bibliography conversion utilities.

Portability | portable
Stability | provisional
Maintainer | andrea.rossato@unitn.it
Safe Haskell | None

Text.Bibutils

Contents

- Basic Functions
- Auxiliary Functions
  - Functions for Setting Parameters
- Input Formats
- Output Formats
- Options for Specific Output Formats
- Charsets
- Return Status

Description

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

Synopsis

- data Bibl
- data Param = Param {
  - redaformat :: CInt
  - writeformat :: CInt
  - charsetin :: CInt
  - charsetin_src :: CUChar
  - latexin :: CUChar
  - utf8in :: CUChar
  - xmlin :: CUChar
  - nosplittitle :: CUChar
  - charsetout :: CInt
  - charsetout_src :: CUChar
  - latexout :: CUChar
  - utf8out :: CUChar
  - utf8bom :: CUChar
  - xmlout :: CUChar
  - format_opts :: CInt
  - addcount :: CInt
  - output_raw :: CUChar
  - verbose :: CUChar
  - singlerefperfile :: CUChar
  }
- bibl_init :: IO (ForeignPtr Bibl)
- bibl_initparams :: BiblioIn -> BiblioOut -> String -> IO (ForeignPtr Param)
- bibl_read :: ForeignPtr Param -> ForeignPtr Bibl -> FilePath -> IO Status
- bibl_write :: ForeignPtr Param -> ForeignPtr Bibl -> FilePath -> IO Status
- bibl_readasis :: ForeignPtr Param -> FilePath -> IO ()
- bibl_addtoasis :: ForeignPtr Param -> String -> IO ()
- bibl_readcorps :: ForeignPtr Param -> FilePath -> IO ()
- bibl_addtocorps :: ForeignPtr Param -> String -> IO ()
- bibl_free :: ForeignPtr Bibl -> IO ()
- bibl_freeparams :: ForeignPtr Param -> IO ()
- bibl_reporterr :: Status -> IO ()
- numberOfRefs :: ForeignPtr Bibl -> IO Int
- status :: Status -> CInt
- setParam :: ForeignPtr Param -> (Param -> Param) -> IO ()
- setFormatOpts :: ForeignPtr Param -> [FormatOpt] -> IO ()
- setCharsetIn :: ForeignPtr Param -> Charset -> IO ()
- setCharsetOut :: ForeignPtr Param -> Charset -> IO ()
- setBOM :: ForeignPtr Param -> IO ()
- unsetBOM :: ForeignPtr Param -> IO ()
- setNoSplitTitle :: ForeignPtr Param -> IO ()
- unsetNoSplitTitle :: ForeignPtr Param -> IO ()
- setLatexOut :: ForeignPtr Param -> IO ()
- unsetLatexOut :: ForeignPtr Param -> IO ()
- setXmlOut :: ForeignPtr Param -> IO ()
- unsetXmlOut :: ForeignPtr Param -> IO ()
- setAddcount :: ForeignPtr Param -> IO ()
- unsetAddcount :: ForeignPtr Param -> IO ()
- setSinglerefperfile :: ForeignPtr Param -> IO ()
- unsetSinglerefperfile :: ForeignPtr Param -> IO ()
- setVerbose :: ForeignPtr Param -> IO ()
- unsetVerbose :: ForeignPtr Param -> IO ()
- data BiblioIn
- mods_in :: BiblioIn
- bibtex_in :: BiblioIn
- ris_in :: BiblioIn
- endnote_in :: BiblioIn
- copac_in :: BiblioIn
- isi_in :: BiblioIn
- medline_in :: BiblioIn
- biblatex_in :: BiblioIn
- endnotexml_in :: BiblioIn
- data BiblioOut
- mods_out :: BiblioOut
- bibtex_out :: BiblioOut
- ris_out :: BiblioOut
- endnote_out :: BiblioOut
- isi_out :: BiblioOut
- word2007_out :: BiblioOut
- adsab_out :: BiblioOut
- data FormatOpt
- bibout_finalcomma :: FormatOpt
- bibout_singledash :: FormatOpt
- bibout_whitespace :: FormatOpt
- bibout_brackets :: FormatOpt
- bibout_uppercase :: FormatOpt
- bibout_strictkey :: FormatOpt
- modsout_dropkey :: FormatOpt
- wordout_dropkey :: FormatOpt
- data Charset
- bibl_charset_unknown :: Charset
- bibl_charset_unicode :: Charset
- bibl_charset_gb18030 :: Charset
- bibl_charset_default :: Charset
- data Status
- bibl_ok :: Status
- bibl_err_badinput :: Status
- bibl_err_memerr :: Status
- bibl_err_cantopen :: Status

# Basic Functions

data Bibl

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.

Instances

Storable Bibl |

data Param

A type for storing the Param C struct. It should be accessed with the functions provided, such as `setCharsetIn`, etc.

Constructors

Param |
Fields redaformat :: CInt writeformat :: CInt charsetin :: CInt charsetin_src :: CUChar latexin :: CUChar utf8in :: CUChar xmlin :: CUChar nosplittitle :: CUChar charsetout :: CInt charsetout_src :: CUChar latexout :: CUChar utf8out :: CUChar utf8bom :: CUChar xmlout :: CUChar format_opts :: CInt addcount :: CInt output_raw :: CUChar verbose :: CUChar singlerefperfile :: CUChar

Instances

Show Param |
Storable Param |

bibl_init :: IO (ForeignPtr Bibl)

Initialize the `Bibl` C struct. Usually the first function being called.

bibl_initparams :: BiblioIn -> BiblioOut -> String -> IO (ForeignPtr Param)

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_read :: ForeignPtr Param -> ForeignPtr Bibl -> FilePath -> IO Status

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_write :: ForeignPtr Param -> ForeignPtr Bibl -> FilePath -> IO Status

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_readasis :: ForeignPtr Param -> FilePath -> IO ()

bibl_addtoasis :: ForeignPtr Param -> String -> IO ()

bibl_readcorps :: ForeignPtr Param -> FilePath -> IO ()

bibl_addtocorps :: ForeignPtr Param -> String -> IO ()

bibl_free :: ForeignPtr Bibl -> IO ()

Free the `Bibl` C struct.

bibl_freeparams :: ForeignPtr Param -> IO ()

Free the `Param` C struct.

bibl_reporterr :: Status -> IO ()

# Auxiliary Functions

numberOfRefs :: ForeignPtr Bibl -> IO Int

Retrieve the number of references from a `Bibl` C struct.

status :: Status -> CInt

## Functions for Setting Parameters

setParam :: ForeignPtr Param -> (Param -> Param) -> IO ()

Set fields of the `Param` C struct directly.

setFormatOpts :: ForeignPtr Param -> [FormatOpt] -> IO ()

Set output format specific options. See `FormatOpt`.

setCharsetIn :: ForeignPtr Param -> Charset -> IO ()

Set the input charset. Default is Latin-1 (ISO8859-1). See `Charset`.

setCharsetOut :: ForeignPtr Param -> Charset -> IO ()

Set the output charset.

setBOM :: ForeignPtr Param -> IO ()

Write utf8 byte-order-mark.

unsetBOM :: ForeignPtr Param -> IO ()

setNoSplitTitle :: ForeignPtr Param -> IO ()

Do not split titles.

unsetNoSplitTitle :: ForeignPtr Param -> IO ()

Split titles.

setLatexOut :: ForeignPtr Param -> IO ()

Write Latex codes.

unsetLatexOut :: ForeignPtr Param -> IO ()

setXmlOut :: ForeignPtr Param -> IO ()

Write characters in XML entities.

unsetXmlOut :: ForeignPtr Param -> IO ()

setAddcount :: ForeignPtr Param -> IO ()

Add reference count to reference id.

unsetAddcount :: ForeignPtr Param -> IO ()

setSinglerefperfile :: ForeignPtr Param -> IO ()

Output a single reference for each file.

unsetSinglerefperfile :: ForeignPtr Param -> IO ()

setVerbose :: ForeignPtr Param -> IO ()

Verbose output.

unsetVerbose :: ForeignPtr Param -> IO ()

Suppress verbose output.

# Input Formats

data BiblioIn

Instances

Eq BiblioIn |

mods_in :: BiblioIn

bibtex_in :: BiblioIn

ris_in :: BiblioIn

endnote_in :: BiblioIn

copac_in :: BiblioIn

isi_in :: BiblioIn

medline_in :: BiblioIn

biblatex_in :: BiblioIn

endnotexml_in :: BiblioIn

# Output Formats

data BiblioOut

Instances

Eq BiblioOut |

mods_out :: BiblioOut

bibtex_out :: BiblioOut

ris_out :: BiblioOut

endnote_out :: BiblioOut

isi_out :: BiblioOut

word2007_out :: BiblioOut

adsab_out :: BiblioOut

# Options for Specific Output Formats

data FormatOpt

bibout_finalcomma :: FormatOpt

bibout_singledash :: FormatOpt

bibout_whitespace :: FormatOpt

bibout_brackets :: FormatOpt

bibout_uppercase :: FormatOpt

bibout_strictkey :: FormatOpt

modsout_dropkey :: FormatOpt

wordout_dropkey :: FormatOpt

# Charsets

data Charset

Instances

Eq Charset |

bibl_charset_unknown :: Charset

bibl_charset_unicode :: Charset

bibl_charset_gb18030 :: Charset

bibl_charset_default :: Charset

# Return Status

data Status

Instances

Eq Status |
Show Status |

bibl_ok :: Status

bibl_err_badinput :: Status

bibl_err_memerr :: Status

bibl_err_cantopen :: Status