helper.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) 2018 Markus Hennecke <markus-hennecke@markus-hennecke.de>
  3. *
  4. * Permission to use, copy, modify, and distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef __HELPER_H__
  17. #define __HELPER_H__
  18. #include <regex.h>
  19. #include <stdbool.h>
  20. struct memmap {
  21. void *data;
  22. size_t size;
  23. };
  24. struct md_mmap {
  25. struct memmap *mmap;
  26. bool md;
  27. char *html;
  28. size_t htmlsz;
  29. };
  30. const char *rx_get_errormsg(int, regex_t *);
  31. void decode_string(char *);
  32. struct memmap *memmap_new(const char *);
  33. struct memmap *memmap_new_at(int, const char *);
  34. void memmap_free(struct memmap *);
  35. size_t memmap_chomp(struct memmap *);
  36. struct md_mmap *md_mmap_new(const char *);
  37. struct md_mmap *md_mmap_new_at(int, const char *);
  38. struct md_mmap *md_mmap_new_from_memmap(struct memmap *);
  39. void md_mmap_free(struct md_mmap *);
  40. void md_mmap_parse(struct md_mmap *);
  41. void md_mmap_content(struct md_mmap *, void **, size_t *);
  42. #endif // __HELPER_H__