houdini.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 bufsize_t houdini_unescape_ent(cmark_strbuf *ob, const uint8_t *src,
  29. bufsize_t size);
  30. extern int houdini_escape_html(cmark_strbuf *ob, const uint8_t *src,
  31. bufsize_t size);
  32. extern int houdini_escape_html0(cmark_strbuf *ob, const uint8_t *src,
  33. bufsize_t size, int secure);
  34. extern int houdini_unescape_html(cmark_strbuf *ob, const uint8_t *src,
  35. bufsize_t size);
  36. extern void houdini_unescape_html_f(cmark_strbuf *ob, const uint8_t *src,
  37. bufsize_t size);
  38. extern int houdini_escape_href(cmark_strbuf *ob, const uint8_t *src,
  39. bufsize_t size);
  40. #ifdef __cplusplus
  41. }
  42. #endif
  43. #endif