Packages: All | Callback | DOM | Range | SAX | Schema | Traversal | XML | XPath | XPointer | XSLT | XSLTVM Functions | Datatypes

Package Callback

This package defines macros which declare functions (or function pointers) for XML callbacks. Callbacks are used for error-message handling, memory allocation & freeing, and stream operations.



Interface Callbacks

FunctionDescription
XML_ALLOC_F Low-level memory allocation
XML_ERRMSG_F Handle error message
XML_FREE_F Low-level memory freer
XML_STREAM_CLOSE_F User-defined stream close callback
XML_STREAM_OPEN_F User-defined stream open callback
XML_STREAM_WRITE_F User-defined stream write callback

XML_ALLOC_F

Name XML_ALLOC_F
Interface Callbacks
Purpose Low-level memory allocation
Prototype #define XML_ALLOC_F(func, mctx, size) \
void *func(void *mctx, size_t size)
Arguments
mctx  (IN)  low-level memory context
size  (IN)  number of bytes to allocate
Returns (void *) allocated memory
Description This macro defines a prototype for the low-level memory alloc function provided by the user. If no allocator is provided, malloc() is used. Memory should NOT be zeroed by this func! Matches XML_FREE_F.

See Also XML_FREE_F

XML_ERRMSG_F

Name XML_ERRMSG_F
Interface Callbacks
Purpose Handle error message
Prototype #define XML_ERRMSG_F(func, ectx, msg, err) \
void func(void *ectx, oratext *msg, xmlerr err)
Arguments
etcx  (IN)  error message context
msg  (IN)  text of error message
err  (IN)  numeric error code
Returns (void)
Description This macro defines a prototype for the error message handling function. If no error message callback is provided at XML initialization time, errors will be printed to stderr. If a handler is provided, it will be invoked instead of printing to stderr.

See Also XmlCreate

XML_FREE_F

Name XML_FREE_F
Interface Callbacks
Purpose Low-level memory freer
Prototype #define XML_FREE_F(func, mctx, ptr) \
void func(void *mctx, void *ptr)
Arguments
mctx  (IN)  low-level memory context
ptr  (IN)  memory to be freed
Returns (void)
Description This macro defines a prototype for the low-level memory free function provided by the user. If no allocator is provided, free() is used. Matches XML_ALLOC_F.

See Also XML_FREE_F

XML_STREAM_CLOSE_F

Name XML_STREAM_CLOSE_F
Interface Callbacks
Purpose User-defined stream close callback
Prototype #define XML_STREAM_CLOSE_F(func, xctx, sctx) \
void func(xmlctx *xctx, void *sctx) 
Arguments
xctx  (IN)  XML context
sctx  (IN)  user-defined stream context
Returns (void)
Description This macro defines a prototype for the close function callback, called to close an open source and free its resources.

See Also XML_STREAM_OPEN_F, XML_STREAM_WRITE_F

XML_STREAM_OPEN_F

Name XML_STREAM_OPEN_F
Interface Callbacks
Purpose User-defined stream open callback
Prototype #define XML_STREAM_OPEN_F(func, xctx, sctx, path, parts, length) \
xmlerr func(xmlctx *xctx, void *sctx, oratext *path, \
            void *parts, ubig_ora *length)
Arguments
xctx  (IN)  XML context
sctx  (IN)  user-defined stream context
path  (IN)  full path of the URI to be opened
parts  (IN)  URI broken down into components (opaque pointer)
length  (OUT)  total length of input data if known, 0 if not known
Returns (xmlerr) numeric error code, 0 on success
Description This macro defines a prototype for the open function callback, which is called once to open the input source. This function should return XMLERR_OK on success.

See Also XML_STREAM_CLOSE_F, XML_STREAM_WRITE_F

XML_STREAM_WRITE_F

Name XML_STREAM_WRITE_F
Interface Callbacks
Purpose User-defined stream write callback
Prototype #define XML_STREAM_WRITE_F(func, xctx, sctx, path, src, size) \
xmlerr func(xmlctx *xctx, void *sctx, oratext *path, \
            oratext *src, size_t size)
Arguments
xctx  (IN)  XML context
sctx  (IN)  user-defined stream context
path  (IN)  full URI of the open source (for error messages)
src  (IN)  source buffer to read data from
size  (IN)  size of source in bytes
Returns (xmlerr) numeric error code, 0 on success
Description This macro defines a prototype for the write function callback, called to write data to a user-defined stream.

See Also XML_STREAM_OPEN_F, XML_STREAM_CLOSE_F