aboutsummaryrefslogtreecommitdiff
path: root/src/houdini.h
blob: 9e1200ece2b86ea61f018d9a4e5cd7c222f1b9c0 (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(strbuf *ob, const uint8_t *src, size_t size);
  29. extern int houdini_escape_html(strbuf *ob, const uint8_t *src, size_t size);
  30. extern int houdini_escape_html0(strbuf *ob, const uint8_t *src, size_t size, int secure);
  31. extern int houdini_unescape_html(strbuf *ob, const uint8_t *src, size_t size);
  32. extern void houdini_unescape_html_f(strbuf *ob, const uint8_t *src, size_t size);
  33. extern int houdini_escape_xml(strbuf *ob, const uint8_t *src, size_t size);
  34. extern int houdini_escape_uri(strbuf *ob, const uint8_t *src, size_t size);
  35. extern int houdini_escape_url(strbuf *ob, const uint8_t *src, size_t size);
  36. extern int houdini_escape_href(strbuf *ob, const uint8_t *src, size_t size);
  37. extern int houdini_unescape_uri(strbuf *ob, const uint8_t *src, size_t size);
  38. extern int houdini_unescape_url(strbuf *ob, const uint8_t *src, size_t size);
  39. extern int houdini_escape_js(strbuf *ob, const uint8_t *src, size_t size);
  40. extern int houdini_unescape_js(strbuf *ob, const uint8_t *src, size_t size);
  41. #ifdef __cplusplus
  42. }
  43. #endif
  44. #endif