Alo Reference

Functions

alo_open alo_close alo_out

Types

alo_doc_info

Constants

ALO_OPTION_NONE ALO_OPTION_APPEND_TO_FILE ALO_OPTION_OUTPUT_XML_DECLARATION ALO_OPTION_EXP_CONVERT_ISO_8859_1_TO_UTF_8

Description

This is the reference documentation for using Alo to output XML documents. It is a simple to use library that reduces the amount of code needed to output XML.

The header file alo.h declares the Alo API. For more information and examples on using Alo, see the Tutorial and explore the provided test code.

Functions

alo_openTOP

Open an Alo document for output.

Prototype

int16_t alo_open(alo_doc_info **doc, const char *file_name, uint32_t options,...)

Parameters

doc

the document to output to, allocated by alo_open

file_name

the filename to output to

options

options for outputting, like xml declarations and if to append to a file

Returns

0 if there is no error. errno can be checked to see if fopen had an error

Comments

Start output to the file named, outputting a declaration along with all the arguments if desired.

See Also

alo_out, alo_close

alo_closeTOP

Close an Alo document.

Prototype

void alo_close(alo_doc_info *doc)

Parameters

doc

Comments

Close any unfinished markup. Close the file written to. Free any memory used. Subsequent calls to this doc will not succeed.

See Also

alo_open, alo_out

alo_outTOP

Output some formatted XML data to the Alo document.

Prototype

int16_t alo_out(alo_doc_info *doc, int16_t level, const char *format,...)

Parameters

doc

the document to output to

level

which XML element in the document to output to

format

C string containing the text, XML instructions, and printf to output. This indicates how to interpret the following arguments.

Comments

Output data to the doc at the level according to the format specified. The format is a C string containing text, XML instructions to create XML structures, and printf like rules to output arguments as formatted text.

Text is output as is, except the characters &<>" are output as XML entities.

The syntax of an XML instruction is:

XML Instruction = \^[eaCDP]

Printf formats = %[flag][width][.precision][lh]?[scdiuxX]

If the level is not the current level, then the levels are closed until the correct level is reached. If the correct level is not reached, then DOLATER.

See Also

alo_open, alo_close

Types

alo_doc_infoTOP

Comments

The alo_doc_info structure contains information about the XML document being outputted. It is created by alo_open, passed to alo_out, and destroyed by alo_close. After destruction it is invalid to use it.

Prototype

typedef struct alo_doc_info alo_doc_info

Constants

ALO_OPTION_NONETOP

Only simple output is needed for new XML file.

ALO_OPTION_APPEND_TO_FILETOP

Append the XML to the file specified.

Comments

Otherwise alo_open will truncate the file if it already exists.

ALO_OPTION_OUTPUT_XML_DECLARATIONTOP

Output a XML declaration at the start of the document.

Comments

Use this when opening complete XML documents. It's useful to not use it when just writing XML fragments. If a version is not specified (as the first argument), then version="1.0" will be added as required to be a well-formed XML document.

ALO_OPTION_EXP_CONVERT_ISO_8859_1_TO_UTF_8TOP

Convert output from ISO-8859-1 to utf-8.

Comments

Useful to keep XML output in legacy environments as portable as possible.

Status of it's inclusion into the API is experimental until experience shows enough apps justify permanent inclusion.