hs-bibutils-4.12: 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 Source

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 Source

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)Source

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

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

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 Source

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 Source

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 ()Source

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

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

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

bibl_free :: ForeignPtr Bibl -> IO ()Source

Free the `Bibl` C struct.

bibl_freeparams :: ForeignPtr Param -> IO ()Source

Free the `Param` C struct.

bibl_reporterr :: Status -> IO ()Source

# Auxiliary Functions

numberOfRefs :: ForeignPtr Bibl -> IO Int Source

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

status :: Status -> CInt Source

## Functions for Setting Parameters

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

Set fields of the `Param` C struct directly.

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

Set output format specific options. See `FormatOpt`.

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

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

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

Set the output charset.

setBOM :: ForeignPtr Param -> IO ()Source

Write utf8 byte-order-mark.

unsetBOM :: ForeignPtr Param -> IO ()Source

setNoSplitTitle :: ForeignPtr Param -> IO ()Source

Do not split titles.

unsetNoSplitTitle :: ForeignPtr Param -> IO ()Source

Split titles.

setLatexOut :: ForeignPtr Param -> IO ()Source

Write Latex codes.

unsetLatexOut :: ForeignPtr Param -> IO ()Source

setXmlOut :: ForeignPtr Param -> IO ()Source

Write characters in XML entities.

unsetXmlOut :: ForeignPtr Param -> IO ()Source

setAddcount :: ForeignPtr Param -> IO ()Source

Add reference count to reference id.

unsetAddcount :: ForeignPtr Param -> IO ()Source

setSinglerefperfile :: ForeignPtr Param -> IO ()Source

Output a single reference for each file.

unsetSinglerefperfile :: ForeignPtr Param -> IO ()Source

setVerbose :: ForeignPtr Param -> IO ()Source

Verbose output.

unsetVerbose :: ForeignPtr Param -> IO ()Source

Suppress verbose output.

# Input Formats

data BiblioIn Source

Instances

Eq BiblioIn |

mods_in :: BiblioIn Source

bibtex_in :: BiblioIn Source

ris_in :: BiblioIn Source

endnote_in :: BiblioIn Source

copac_in :: BiblioIn Source

isi_in :: BiblioIn Source

medline_in :: BiblioIn Source

biblatex_in :: BiblioIn Source

endnotexml_in :: BiblioIn Source

# Output Formats

data BiblioOut Source

Instances

Eq BiblioOut |

mods_out :: BiblioOut Source

bibtex_out :: BiblioOut Source

ris_out :: BiblioOut Source

endnote_out :: BiblioOut Source

isi_out :: BiblioOut Source

word2007_out :: BiblioOut Source

adsab_out :: BiblioOut Source

# Options for Specific Output Formats

data FormatOpt Source

bibout_finalcomma :: FormatOpt Source

bibout_singledash :: FormatOpt Source

bibout_whitespace :: FormatOpt Source

bibout_brackets :: FormatOpt Source

bibout_uppercase :: FormatOpt Source

bibout_strictkey :: FormatOpt Source

modsout_dropkey :: FormatOpt Source

wordout_dropkey :: FormatOpt Source

# Charsets

data Charset Source

Instances

Eq Charset |

bibl_charset_unknown :: Charset Source

bibl_charset_unicode :: Charset Source

bibl_charset_gb18030 :: Charset Source

bibl_charset_default :: Charset Source

# Return Status

data Status Source

Instances

Eq Status |
Show Status |

bibl_ok :: Status Source

bibl_err_badinput :: Status Source

bibl_err_memerr :: Status Source

bibl_err_cantopen :: Status Source