aboutsummaryrefslogtreecommitdiff
path: root/src/html/houdini.h
blob: 1e54d20d148bf594cad22e2238ff8c7ce9330b2a (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 int houdini_escape_html(strbuf *ob, const uint8_t *src, size_t size);
  23. extern int houdini_escape_html0(strbuf *ob, const uint8_t *src, size_t size, int secure);
  24. extern int houdini_unescape_html(strbuf *ob, const uint8_t *src, size_t size);
  25. extern int houdini_escape_xml(strbuf *ob, const uint8_t *src, size_t size);
  26. extern int houdini_escape_uri(strbuf *ob, const uint8_t *src, size_t size);
  27. extern int houdini_escape_url(strbuf *ob, const uint8_t *src, size_t size);
  28. extern int houdini_escape_href(strbuf *ob, const uint8_t *src, size_t size);
  29. extern int houdini_unescape_uri(strbuf *ob, const uint8_t *src, size_t size);
  30. extern int houdini_unescape_url(strbuf *ob, const uint8_t *src, size_t size);
  31. extern int houdini_escape_js(strbuf *ob, const uint8_t *src, size_t size);
  32. extern int houdini_unescape_js(strbuf *ob, const uint8_t *src, size_t size);
  33. #ifdef __cplusplus
  34. }
  35. #endif
  36. #endif