aboutsummaryrefslogtreecommitdiff
path: root/src/houdini.h
blob: 9f00f6d4f81bd6332330c064a0d641b8c39ea403 (plain)
  1. #ifndef CMARK_HOUDINI_H
  2. #define CMARK_HOUDINI_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <stdint.h>
  7. #include "config.h"
  8. #include "buffer.h"
  9. #ifdef HAVE___BUILTIN_EXPECT
  10. # define likely(x) __builtin_expect((x),1)
  11. # define unlikely(x) __builtin_expect((x),0)
  12. #else
  13. # define likely(x) (x)
  14. # define unlikely(x) (x)
  15. #endif
  16. #ifdef HOUDINI_USE_LOCALE
  17. # define _isxdigit(c) isxdigit(c)
  18. # define _isdigit(c) isdigit(c)
  19. #else
  20. /*
  21. * Helper _isdigit methods -- do not trust the current locale
  22. * */
  23. # define _isxdigit(c) (strchr("0123456789ABCDEFabcdef", (c)) != NULL)
  24. # define _isdigit(c) ((c) >= '0' && (c) <= '9')
  25. #endif
  26. #define HOUDINI_ESCAPED_SIZE(x) (((x) * 12) / 10)
  27. #define HOUDINI_UNESCAPED_SIZE(x) (x)
  28. extern size_t houdini_unescape_ent(cmark_strbuf *ob, const uint8_t *src, size_t size);
  29. extern int houdini_escape_html(cmark_strbuf *ob, const uint8_t *src, size_t size);
  30. extern int houdini_escape_html0(cmark_strbuf *ob, const uint8_t *src, size_t size, int secure);
  31. extern int houdini_unescape_html(cmark_strbuf *ob, const uint8_t *src, size_t size);
  32. extern void houdini_unescape_html_f(cmark_strbuf *ob, const uint8_t *src, size_t size);
  33. extern int houdini_escape_xml(cmark_strbuf *ob, const uint8_t *src, size_t size);
  34. extern int houdini_escape_uri(cmark_strbuf *ob, const uint8_t *src, size_t size);
  35. extern int houdini_escape_url(cmark_strbuf *ob, const uint8_t *src, size_t size);
  36. extern int houdini_escape_href(cmark_strbuf *ob, const uint8_t *src, size_t size);
  37. extern int houdini_unescape_uri(cmark_strbuf *ob, const uint8_t *src, size_t size);
  38. extern int houdini_unescape_url(cmark_strbuf *ob, const uint8_t *src, size_t size);
  39. extern int houdini_escape_js(cmark_strbuf *ob, const uint8_t *src, size_t size);
  40. extern int houdini_unescape_js(cmark_strbuf *ob, const uint8_t *src, size_t size);
  41. #ifdef __cplusplus
  42. }
  43. #endif
  44. #endif