File Handling Reference

As an example of how to extend the functionality of the Tamino API for C, we provide several convenience functions for file I/O. They are all part of the second layer and are also available in source code so that they can be adapted to individual needs.

The following functions are provided:


tac_define_from_file

int tac_define_from_file(TAC_HANDLE handle, const char *filename)

Defines a schema to the Tamino XML Server by reading it from a file.

Takes Parameters:

handle - a valid handle obtained from tac_init().
filename - a string containing the full name of the file that contains the schema.

Returns:

The predefined constant TAC_SUCCESS upon success, or an error code upon failure (see Return and Error Codes).

tac_load_from_file

int tac_load_from_file(TAC_HANDLE handle, const char *collection, const char *docname, const char *filename, const char *mime_type)

Inserts a single document from a file into the Tamino XML Server; mostly used for non-XML documents but also useable for XML data.

Takes Parameters:

handle - a valid handle obtained from tac_init().
collection - a string containing the name of the collection to be used.
docname - a string containing the doctype, a slash ('/'), and the name of the document, e.g. "images/property1.jpg".
filename - a string containing the full name of the file that contains the document.
mime_type - a string containing the MIME-type of the document, e.g. "image/jpeg".

Returns:

The predefined constant TAC_SUCCESS upon success, or an error code upon failure (see Return and Error Codes).

tac_process_from_file

int tac_process_from_file(TAC_HANDLE handle, const char *collection, const char *filename)

Loads XML document(s) from a file into the Tamino XML Server.

For multiple documents in one single file, one must use the file format as specified in the Tamino Data Loaders section of the Tamino XML Server documentation

Takes Parameters:

handle - a valid handle obtained from tac_init().
collection - a string containing the name of the collection to be used.
filename - a string containing the full name of the file that contains the document(s).

Returns:

The predefined constant TAC_SUCCESS upon success, or an error code upon failure (see Return and Error Codes).

tac_retrieve_to_file

int tac_retrieve_to_file(TAC_HANDLE handle, const char *collection, const char *docname, const char **mime_type, const char *filename)

Gets a single document from the Tamino XML Server and writes it to a file.

Takes Parameters:

handle - a valid handle obtained from tac_init().
collection - a string containing the name of the collection to be used.
docname - a string containing the doctype, a slash ('/'), and the name of the document, e.g. "images/property1.jpg".
mime_type - a pointer to a string that will contain the MIME-type of the returned document, e.g. "image/jpeg".
filename - a string containing the full name of the file that will contain the document.

Returns:

The predefined constant TAC_SUCCESS upon success, or an error code upon failure (see Return and Error Codes).