Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * This file is part of LibParserUtils.
  3.  * Licensed under the MIT License,
  4.  *                http://www.opensource.org/licenses/mit-license.php
  5.  * Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
  6.  */
  7.  
  8. #ifndef parserutils_charset_codecs_codecimpl_h_
  9. #define parserutils_charset_codecs_codecimpl_h_
  10.  
  11. #include <stdbool.h>
  12. #include <inttypes.h>
  13.  
  14. #include <parserutils/charset/codec.h>
  15.  
  16. /**
  17.  * Core charset codec definition; implementations extend this
  18.  */
  19. struct parserutils_charset_codec {
  20.         uint16_t mibenum;                       /**< MIB enum for charset */
  21.  
  22.         parserutils_charset_codec_errormode errormode;  /**< error mode */
  23.  
  24.         parserutils_alloc alloc;                /**< allocation function */
  25.         void *alloc_pw;                         /**< private word */
  26.  
  27.         struct {
  28.                 parserutils_error (*destroy)(parserutils_charset_codec *codec);
  29.                 parserutils_error (*encode)(parserutils_charset_codec *codec,
  30.                                 const uint8_t **source, size_t *sourcelen,
  31.                                 uint8_t **dest, size_t *destlen);
  32.                 parserutils_error (*decode)(parserutils_charset_codec *codec,
  33.                                 const uint8_t **source, size_t *sourcelen,
  34.                                 uint8_t **dest, size_t *destlen);
  35.                 parserutils_error (*reset)(parserutils_charset_codec *codec);
  36.         } handler; /**< Vtable for handler code */
  37. };
  38.  
  39. /**
  40.  * Codec factory component definition
  41.  */
  42. typedef struct parserutils_charset_handler {
  43.         bool (*handles_charset)(const char *charset);
  44.         parserutils_error (*create)(const char *charset,
  45.                         parserutils_alloc alloc, void *pw,
  46.                         parserutils_charset_codec **codec);
  47. } parserutils_charset_handler;
  48.  
  49. #endif
  50.