[El-Kabong Home]
Main Page   Compound List   File List   Compound Members   File Members  

ekhtml.h File Reference

Main El-Kabong header file. More...


Compounds

struct  ekhtml_attr_t
 Attribute object, passed into callbacks. More...

struct  ekhtml_string_t
 A string object, which is not NUL terminated. More...


Defines

#define EKHTML_BLOCKSIZE   (1024 * 4)
 EKHTML_BLOCKSIZE = # of blocks to allocate per chunk.


Typedefs

typedef ekhtml_string_t ekhtml_string_t
 A string object, which is not NUL terminated. More...

typedef ekhtml_attr_t ekhtml_attr_t
 Attribute object, passed into callbacks. More...

typedef ekhtml_parser_t ekhtml_parser_t
 The parser object. More...

typedef void(* ekhtml_data_cb_t )(void *cbdata, ekhtml_string_t *data)
 Callback for simple data. More...

typedef void(* ekhtml_starttag_cb_t )(void *cbdata, ekhtml_string_t *tag, ekhtml_attr_t *attrs)
 Callback for start tags. More...

typedef void(* ekhtml_endtag_cb_t )(void *cbdata, ekhtml_string_t *tag)
 Callback for end tags. More...


Functions

ekhtml_parser_tekhtml_parser_new (void *cbdata)
 Create a new parser object. More...

void ekhtml_parser_destroy (ekhtml_parser_t *parser)
 Destroys a parser object and all memory associated with it. More...

void ekhtml_parser_cbdata_set (ekhtml_parser_t *parser, void *cbdata)
 Set the callback data for the parser. More...

void ekhtml_parser_datacb_set (ekhtml_parser_t *parser, ekhtml_data_cb_t cb)
 Set the parser's data callback. More...

void ekhtml_parser_commentcb_set (ekhtml_parser_t *parser, ekhtml_data_cb_t cb)
 Set the parser's comment callback. More...

void ekhtml_parser_feed (ekhtml_parser_t *parser, ekhtml_string_t *data)
 Feed data for the parser to process. More...

int ekhtml_parser_flush (ekhtml_parser_t *parser, int flushall)
 Flush the parser innards. More...

void ekhtml_parser_startcb_add (ekhtml_parser_t *parser, const char *tag, ekhtml_starttag_cb_t cb)
 Add a callback for a start tag. More...

void ekhtml_parser_endcb_add (ekhtml_parser_t *parser, const char *tag, ekhtml_endtag_cb_t cb)
 Add a callback for an end tag. More...


Detailed Description

Main El-Kabong header file.

This header defines everything that a program should need to use the El-Kabong library.


Typedef Documentation

typedef struct ekhtml_attr_t ekhtml_attr_t
 

Attribute object, passed into callbacks.

When ekhtml parses tags containing key/value attributes, it will pass this structure representing those values into the callbacks. Note, for speed reasons, things such as the 'name' and 'value' fields are not terminated with '\0', and therefore have an associated length field (namelen, vallen).

typedef void(* ekhtml_data_cb_t)(void *cbdata, ekhtml_string_t *data)
 

Callback for simple data.

Callback functions of this form are used to process data which is not part of a start or end tag. This callback may also be used to process the body of comment tags.

I.e. <FOO>data_to_process</FOO> The data passed into the callback function will be "data_to_process"

Parameters:
cbdata  Callback data, as previously set by ekhtml_parser_cbdata_set
data  A pointer to the data in-between tags.
See also:
ekhtml_parser_cbdata_set() , ekhtml_parser_datacb_set()

typedef void(* ekhtml_endtag_cb_t)(void *cbdata, ekhtml_string_t *tag)
 

Callback for end tags.

Callback functions of this form are used to process end tags.

I.e. <FOO>data_to_process</FOO> The tag passed into the callback will be "FOO" with a length of 3.

Parameters:
cbdata  Callback data, as previously set by ekhtml_parser_cbdata_set
tag  A pointer to tag name. This is a traditional NUL terminated string.
See also:
ekhtml_parser_cbdata_set() , ekhtml_parser_endcb_add()

typedef struct ekhtml_parser_t ekhtml_parser_t
 

The parser object.

The parser object holds state information, such as which callbacks to invoke when reading tags, how much data is being processed, etc.

typedef void(* ekhtml_starttag_cb_t)(void *cbdata, ekhtml_string_t *tag, ekhtml_attr_t *attrs)
 

Callback for start tags.

Callback functions of this form are used to process start tags.

I.e. <FOO>data_to_process</FOO> The tag passed into the callback will be "FOO" with a length of 3.

Parameters:
cbdata  Callback data, as previously set by ekhtml_parser_cbdata_set
tag  A pointer to tag name. This is a traditional NUL terminated string.
attrs  Attributes of the tag.
See also:
ekhtml_parser_cbdata_set() , ekhtml_parser_startcb_add()

typedef struct ekhtml_string_t ekhtml_string_t
 

A string object, which is not NUL terminated.

For speed reasons, El-Kabong does not deal with zero-terminated strings.


Function Documentation

void ekhtml_parser_cbdata_set ekhtml_parser_t   parser,
void *    cbdata
 

Set the callback data for the parser.

This routine sets the callback data which is passed to set callbacks.

Parameters:
parser  Parser to set the callback data for
cbdata  Callback data the parser should use to pass to callbacks

void ekhtml_parser_commentcb_set ekhtml_parser_t   parser,
ekhtml_data_cb_t    cb
 

Set the parser's comment callback.

This routine sets the callback which should be invoked when the parser processes a comment.

Parameters:
parser  Parser to set the callback for
cb  Callback to invoke when processing a comment

void ekhtml_parser_datacb_set ekhtml_parser_t   parser,
ekhtml_data_cb_t    cb
 

Set the parser's data callback.

This routine sets the callback which should be invoked for non-tagged data.

Parameters:
parser  Parser to set the callback for
cb  Callback to invoke when processing non-tagged data

void ekhtml_parser_destroy ekhtml_parser_t   parser
 

Destroys a parser object and all memory associated with it.

After calling this routine, the parser should no longer be used, as any results would be undefined.

Parameters:
parser  The parser to destroy
See also:
ekhtml_parser_new()

void ekhtml_parser_endcb_add ekhtml_parser_t   parser,
const char *    tag,
ekhtml_endtag_cb_t    cb
 

Add a callback for an end tag.

This routine sets the callback which should be invoked when the parser processes an end tag. Both specific tags, and unknown tags can be used with this method.

Parameters:
parser  Parser to set the callback for
tag  Name of the tag to call `cb` for. If `tag` is NULL, then any tags which are unknown to the parser will be sent to the callback specified by `cb`.
cb  Callback to invoke

void ekhtml_parser_feed ekhtml_parser_t   parser,
ekhtml_string_t   data
 

Feed data for the parser to process.

Feed data into the HTML parser. This routine will fill up the internal buffer until it can go no more, then flush the data and refill. If there is more data that is required than the internal buffer can hold, it will be resized

Parameters:
parser  Parser to feed data to
data  Data to feed to the parser

int ekhtml_parser_flush ekhtml_parser_t   parser,
int    flushall
 

Flush the parser innards.

When this function is invoked, the parser will flush all data that is currently held, and any remaining state is saved. All data which is processed is removed from the parser, and the internal buffer is reshuffled.

Parameters:
parser  Parser to flush
flushall  If true, will flush all data, even if tags are not complete (i.e. "<FO")
Returns:
1 if action was taken (i.e. bytes were processed and the internal buffer was reshuffled) else 0

ekhtml_parser_t* ekhtml_parser_new void *    cbdata
 

Create a new parser object.

This routine creates a new parser object, with no set callback functions or state.

Parameters:
cbdata  Callback data to use when invoking callbacks
Returns:
A new ekhtml_parser_t object
See also:
ekhtml_parser_cbdata_set()

void ekhtml_parser_startcb_add ekhtml_parser_t   parser,
const char *    tag,
ekhtml_starttag_cb_t    cb
 

Add a callback for a start tag.

This routine sets the callback which should be invoked when the parser processes a start tag. Both specific tags, and unknown tags can be used with this method.

Parameters:
parser  Parser to set the callback for
tag  Name of the tag to call `cb` for. If `tag` is NULL, then any tags which are unknown to the parser will be sent to the callback specified by `cb`.
cb  Callback to invoke


Generated on Sun Nov 10 15:54:34 2002 for ekhtml by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002