1 #include "private-libwebsockets.h"
4 LWS_EXTERN struct lws_rewrite *
5 lws_rewrite_create(struct lws *wsi, hubbub_callback_t cb, const char *from, const char *to)
7 struct lws_rewrite *r = lws_malloc(sizeof(*r));
9 if (hubbub_parser_create("UTF-8", false, &r->parser) != HUBBUB_OK) {
15 r->from_len = strlen(from);
17 r->to_len = strlen(to);
18 r->params.token_handler.handler = cb;
20 r->params.token_handler.pw = (void *)r;
21 if (hubbub_parser_setopt(r->parser, HUBBUB_PARSER_TOKEN_HANDLER,
22 &r->params) != HUBBUB_OK) {
32 lws_rewrite_parse(struct lws_rewrite *r,
33 const unsigned char *in, int in_len)
35 if (hubbub_parser_parse_chunk(r->parser, in, in_len) != HUBBUB_OK)
42 lws_rewrite_destroy(struct lws_rewrite *r)
44 hubbub_parser_destroy(r->parser);