libcucul importers/exporters from/to various formats


Functions

cucul_buffer_tcucul_export_canvas (cucul_canvas_t *, char const *)
 Export a canvas into a foreign format.
char const *const * cucul_get_export_list (void)
 Get available export formats.
cucul_canvas_tcucul_import_canvas (cucul_buffer_t *, char const *)
 Import a buffer into a canvas.
char const *const * cucul_get_import_list (void)
 Get available import formats.

Detailed Description

These functions import various file formats into a new canvas, or export the current canvas to various text formats.

Function Documentation

cucul_buffer_t* cucul_export_canvas cucul_canvas_t cv,
char const *  format
 

This function exports a libcucul canvas into various foreign formats such as ANSI art, HTML, IRC colours, etc. One should use cucul_get_buffer_data() and cucul_get_buffer_size() to access the buffer contents. The allocated data is valid until cucul_free_buffer() is called.

Valid values for format are:

  • "caca": export native libcaca files.
  • "ansi": export ANSI art (CP437 charset with ANSI colour codes).
  • "html": export an HTML page with CSS information.
  • "html3": export an HTML table that should be compatible with most navigators, including textmode ones.
  • "irc": export UTF-8 text with mIRC colour codes.
  • "ps": export a PostScript document.
  • "svg": export an SVG vector image.
  • "tga": export a TGA image.

If an error occurs, NULL is returned and errno is set accordingly:

  • EINVAL Invalid format requested.
  • ENOMEM Not enough memory to allocate output buffer.

Parameters:
cv A libcucul canvas
format A string describing the requested output format.
Returns:
A libcucul buffer, or NULL in case of error.

char const* const* cucul_get_export_list void   ) 
 

Return a list of available export formats. The list is a NULL-terminated array of strings, interleaving a string containing the internal value for the export format, to be used with cucul_export_canvas(), and a string containing the natural language description for that export format.

This function never fails.

Returns:
An array of strings.

cucul_canvas_t* cucul_import_canvas cucul_buffer_t buffer,
char const *  format
 

This function imports a libcucul buffer as returned by cucul_load_memory() or cucul_load_file() into an internal libcucul canvas.

Valid values for format are:

  • "": attempt to autodetect the file format.
  • "ansi": import ANSI files.
  • "caca": import native libcaca files.

If an error occurs, NULL is returned and errno is set accordingly:

  • ENOMEM Not enough memory to allocate canvas.
  • EINVAL Invalid format requested.

Parameters:
buffer A libcucul buffer containing the data to be loaded into a canvas.
format A string describing the input format.
Returns:
A libcucul canvas, or NULL in case of error.

char const* const* cucul_get_import_list void   ) 
 

Return a list of available import formats. The list is a NULL-terminated array of strings, interleaving a string containing the internal value for the import format, to be used with cucul_import_canvas(), and a string containing the natural language description for that import format.

This function never fails.

Returns:
An array of strings.