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