|
XenevaOS
|
#include <assert.h>#include <stdlib.h>#include <string.h>#include <parserutils/charset/mibenum.h>#include <parserutils/charset/utf8.h>#include <parserutils/input/inputstream.h>#include "input/filter.h"#include "utils/utils.h"
Classes | |
| struct | parserutils_inputstream_private |
Macros | |
| #define | IS_ASCII(x) (((x) & 0x80) == 0) |
| #define | UTF32_BOM_LEN (4) |
| #define | UTF16_BOM_LEN (2) |
| #define | UTF8_BOM_LEN (3) |
Typedefs | |
| typedef struct parserutils_inputstream_private | parserutils_inputstream_private |
Functions | |
| parserutils_error | parserutils_inputstream_create (const char *enc, uint32_t encsrc, parserutils_charset_detect_func csdetect, parserutils_inputstream **stream) |
| parserutils_error | parserutils_inputstream_destroy (parserutils_inputstream *stream) |
| parserutils_error | parserutils_inputstream_append (parserutils_inputstream *stream, const uint8_t *data, size_t len) |
| parserutils_error | parserutils_inputstream_insert (parserutils_inputstream *stream, const uint8_t *data, size_t len) |
| parserutils_error | parserutils_inputstream_peek_slow (parserutils_inputstream *stream, size_t offset, const uint8_t **ptr, size_t *length) |
| const char * | parserutils_inputstream_read_charset (parserutils_inputstream *stream, uint32_t *source) |
| parserutils_error | parserutils_inputstream_change_charset (parserutils_inputstream *stream, const char *enc, uint32_t source) |
| #define IS_ASCII | ( | x | ) | (((x) & 0x80) == 0) |
| #define UTF16_BOM_LEN (2) |
| #define UTF32_BOM_LEN (4) |
| #define UTF8_BOM_LEN (3) |
| typedef struct parserutils_inputstream_private parserutils_inputstream_private |
Private input stream definition
| parserutils_error parserutils_inputstream_append | ( | parserutils_inputstream * | stream, |
| const uint8_t * | data, | ||
| size_t | len | ||
| ) |
Append data to an input stream
| stream | Input stream to append data to |
| data | Data to append (in document charset), or NULL to flag EOF |
| len | Length, in bytes, of data |
| parserutils_error parserutils_inputstream_change_charset | ( | parserutils_inputstream * | stream, |
| const char * | enc, | ||
| uint32_t | source | ||
| ) |
Change the source charset of the input stream
| stream | Input stream to modify |
| enc | Charset name |
| source | Charset source identifier |
| parserutils_error parserutils_inputstream_create | ( | const char * | enc, |
| uint32_t | encsrc, | ||
| parserutils_charset_detect_func | csdetect, | ||
| parserutils_inputstream ** | stream | ||
| ) |
Create an input stream
| enc | Document charset, or NULL to autodetect |
| encsrc | Value for encoding source, if specified, or 0 |
| csdetect | Charset detection function, or NULL |
| stream | Pointer to location to receive stream instance |
The value 0 is defined as being the lowest priority encoding source (i.e. the default fallback encoding). Beyond this, no further interpretation is made upon the encoding source.
| parserutils_error parserutils_inputstream_destroy | ( | parserutils_inputstream * | stream | ) |
Destroy an input stream
| stream | Input stream to destroy |
| parserutils_error parserutils_inputstream_insert | ( | parserutils_inputstream * | stream, |
| const uint8_t * | data, | ||
| size_t | len | ||
| ) |
Insert data into stream at current location
| stream | Input stream to insert into |
| data | Data to insert (UTF-8 encoded) |
| len | Length, in bytes, of data |
| parserutils_error parserutils_inputstream_peek_slow | ( | parserutils_inputstream * | stream, |
| size_t | offset, | ||
| const uint8_t ** | ptr, | ||
| size_t * | length | ||
| ) |
Look at the character in the stream that starts at offset bytes from the cursor (slow version)
| stream | Stream to look in |
| offset | Byte offset of start of character |
| ptr | Pointer to location to receive pointer to character data |
| length | Pointer to location to receive character length (in bytes) |
Once the character pointed to by the result of this call has been advanced past (i.e. parserutils_inputstream_advance has caused the stream cursor to pass over the character), then no guarantee is made as to the validity of the data pointed to. Thus, any attempt to dereference the pointer after advancing past the data it points to is a bug.
| const char * parserutils_inputstream_read_charset | ( | parserutils_inputstream * | stream, |
| uint32_t * | source | ||
| ) |
Read the source charset of the input stream
| stream | Input stream to query |
| source | Pointer to location to receive charset source identifier |