summaryrefslogtreecommitdiff
path: root/cmark/src/houdini.h
blob: 69d4fec95cefb08899af2c218a5df8788a22741a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef CMARK_HOUDINI_H
#define CMARK_HOUDINI_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>

#include "buffer.h"

#ifdef HOUDINI_USE_LOCALE
#define _isxdigit(c) isxdigit(c)
#define _isdigit(c) isdigit(c)
#else
/*
 * Helper _isdigit methods -- do not trust the current locale
 * */
#define _isxdigit(c) (strchr("0123456789ABCDEFabcdef", (c)) != NULL)
#define _isdigit(c) ((c) >= '0' && (c) <= '9')
#endif

#define HOUDINI_ESCAPED_SIZE(x) (((x)*12) / 10)
#define HOUDINI_UNESCAPED_SIZE(x) (x)

bufsize_t houdini_unescape_ent(cmark_strbuf *ob, const uint8_t *src,
                               bufsize_t size);
int houdini_escape_html(cmark_strbuf *ob, const uint8_t *src,
                         bufsize_t size, int secure);
int houdini_unescape_html(cmark_strbuf *ob, const uint8_t *src,
                          bufsize_t size);
void houdini_unescape_html_f(cmark_strbuf *ob, const uint8_t *src,
                             bufsize_t size);
int houdini_escape_href(cmark_strbuf *ob, const uint8_t *src,
                        bufsize_t size);

#ifdef __cplusplus
}
#endif

#endif