fts-parser.h revision 3ad57148af55e45cc45401162d3460ed0b237a10
772120713c176bde8c932b3fb4c413d223741fcdTimo Sirainen#ifndef FTS_PARSER_H
772120713c176bde8c932b3fb4c413d223741fcdTimo Sirainen#define FTS_PARSER_H
772120713c176bde8c932b3fb4c413d223741fcdTimo Sirainen
772120713c176bde8c932b3fb4c413d223741fcdTimo Sirainenstruct message_block;
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainenstruct mail_user;
772120713c176bde8c932b3fb4c413d223741fcdTimo Sirainen
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainenstruct fts_parser_vfuncs {
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen struct fts_parser *(*try_init)(struct mail_user *user,
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen const char *content_type,
772120713c176bde8c932b3fb4c413d223741fcdTimo Sirainen const char *content_disposition);
772120713c176bde8c932b3fb4c413d223741fcdTimo Sirainen void (*more)(struct fts_parser *parser, struct message_block *block);
772120713c176bde8c932b3fb4c413d223741fcdTimo Sirainen void (*deinit)(struct fts_parser *parser);
3ad57148af55e45cc45401162d3460ed0b237a10Timo Sirainen void (*unload)(void);
772120713c176bde8c932b3fb4c413d223741fcdTimo Sirainen};
772120713c176bde8c932b3fb4c413d223741fcdTimo Sirainen
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainenstruct fts_parser {
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen struct fts_parser_vfuncs v;
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen buffer_t *utf8_output;
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen};
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainenextern struct fts_parser_vfuncs fts_parser_html;
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainenextern struct fts_parser_vfuncs fts_parser_script;
772120713c176bde8c932b3fb4c413d223741fcdTimo Sirainen
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainenbool fts_parser_init(struct mail_user *user,
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen const char *content_type, const char *content_disposition,
772120713c176bde8c932b3fb4c413d223741fcdTimo Sirainen struct fts_parser **parser_r);
4d27f95c76bd008bb38f9c442567046da2b6ce14Timo Sirainenstruct fts_parser *fts_parser_text_init(void);
4d27f95c76bd008bb38f9c442567046da2b6ce14Timo Sirainen
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen/* The parser is initially called with message body blocks. Once message is
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen finished, it's still called with incoming size=0 while the parser increases
ecc5a1a440799a0966c26da956f5d6e2d8073e03Timo Sirainen it to non-zero. */
772120713c176bde8c932b3fb4c413d223741fcdTimo Sirainenvoid fts_parser_more(struct fts_parser *parser, struct message_block *block);
772120713c176bde8c932b3fb4c413d223741fcdTimo Sirainenvoid fts_parser_deinit(struct fts_parser **parser);
772120713c176bde8c932b3fb4c413d223741fcdTimo Sirainen
3ad57148af55e45cc45401162d3460ed0b237a10Timo Sirainenvoid fts_parsers_unload(void);
3ad57148af55e45cc45401162d3460ed0b237a10Timo Sirainen
772120713c176bde8c932b3fb4c413d223741fcdTimo Sirainen#endif