diff options
Diffstat (limited to 'src/charset/codecs/codec_impl.h')
-rw-r--r-- | src/charset/codecs/codec_impl.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/charset/codecs/codec_impl.h b/src/charset/codecs/codec_impl.h new file mode 100644 index 0000000..9183594 --- /dev/null +++ b/src/charset/codecs/codec_impl.h @@ -0,0 +1,48 @@ +/* + * This file is part of LibParserUtils. + * Licensed under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + * Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org> + */ + +#ifndef parserutils_charset_codecs_codecimpl_h_ +#define parserutils_charset_codecs_codecimpl_h_ + +#include <stdbool.h> +#include <inttypes.h> + +#include <parserutils/charset/codec.h> + +/** + * Core charset codec definition; implementations extend this + */ +struct parserutils_charset_codec { + uint16_t mibenum; /**< MIB enum for charset */ + + parserutils_charset_codec_errormode errormode; /**< error mode */ + + parserutils_alloc alloc; /**< allocation function */ + void *alloc_pw; /**< private word */ + + struct { + void (*destroy)(parserutils_charset_codec *codec); + parserutils_error (*encode)(parserutils_charset_codec *codec, + const uint8_t **source, size_t *sourcelen, + uint8_t **dest, size_t *destlen); + parserutils_error (*decode)(parserutils_charset_codec *codec, + const uint8_t **source, size_t *sourcelen, + uint8_t **dest, size_t *destlen); + parserutils_error (*reset)(parserutils_charset_codec *codec); + } handler; /**< Vtable for handler code */ +}; + +/** + * Codec factory component definition + */ +typedef struct parserutils_charset_handler { + bool (*handles_charset)(const char *charset); + parserutils_charset_codec *(*create)(const char *charset, + parserutils_alloc alloc, void *pw); +} parserutils_charset_handler; + +#endif |