#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <parserutils/errors.h>
#include <parserutils/functypes.h>
#include <parserutils/types.h>
#include <parserutils/charset/utf8.h>
#include <parserutils/utils/buffer.h>
Go to the source code of this file.
|
| 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) |
| |
◆ IS_ASCII
| #define IS_ASCII |
( |
|
x | ) |
(((x) & 0x80) == 0) |
◆ parserutils_charset_detect_func
Type of charset detection function
◆ parserutils_inputstream
◆ parserutils_inputstream_append()
Append data to an input stream
- Parameters
-
| 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 |
- Returns
- PARSERUTILS_OK on success, appropriate error otherwise
◆ parserutils_inputstream_change_charset()
Change the source charset of the input stream
- Parameters
-
| stream | Input stream to modify |
| enc | Charset name |
| source | Charset source identifier |
- Returns
- PARSERUTILS_OK on success, PARSERUTILS_BADPARM on invalid parameters, PARSERUTILS_INVALID if called after data has been read from stream, PARSERUTILS_BADENCODING if the encoding is unsupported, PARSERUTILS_NOMEM on memory exhaustion.
◆ parserutils_inputstream_create()
Create an input stream
- Parameters
-
| 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 |
- Returns
- PARSERUTILS_OK on success, PARSERUTILS_BADPARM on bad parameters, PARSERUTILS_NOMEM on memory exhaustion, PARSERUTILS_BADENCODING on unsupported encoding
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_inputstream_destroy()
Destroy an input stream
- Parameters
-
| stream | Input stream to destroy |
- Returns
- PARSERUTILS_OK on success, appropriate error otherwise
◆ parserutils_inputstream_insert()
Insert data into stream at current location
- Parameters
-
| stream | Input stream to insert into |
| data | Data to insert (UTF-8 encoded) |
| len | Length, in bytes, of data |
- Returns
- PARSERUTILS_OK on success, appropriate error otherwise
◆ parserutils_inputstream_peek_slow()
Look at the character in the stream that starts at offset bytes from the cursor (slow version)
- Parameters
-
| 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) |
- Returns
- PARSERUTILS_OK on success, _NEEDDATA on reaching the end of available input, _EOF on reaching the end of all input, _BADENCODING if the input cannot be decoded, _NOMEM on memory exhaustion, _BADPARM if bad parameters are passed.
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.
◆ parserutils_inputstream_read_charset()
Read the source charset of the input stream
- Parameters
-
| stream | Input stream to query |
| source | Pointer to location to receive charset source identifier |
- Returns
- Pointer to charset name (constant; do not free)