From 31c69b6ca1b91e7fd9fd8e14082fd2584c5f538c Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Sun, 24 May 2020 16:48:22 +0200 Subject: first public release Signed-off-by: Toni Uhlig --- source/tools/helper.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 source/tools/helper.h (limited to 'source/tools/helper.h') diff --git a/source/tools/helper.h b/source/tools/helper.h new file mode 100644 index 0000000..cc5e75b --- /dev/null +++ b/source/tools/helper.h @@ -0,0 +1,37 @@ +#ifndef HELPER_H_INCLUDED +#define HELPER_H_INCLUDED + +#include +#include + +#ifdef _USE_PYTHON +/* Python header files redefine some macros */ +#undef _POSIX_C_SOURCE +#undef _XOPEN_SOURCE +#include /* obligatory */ + +#undef calloc +#undef malloc +#undef realloc +#undef free +#define calloc MyPyMem_Calloc +#define malloc PyMem_Malloc +#define realloc PyMem_Realloc +#define free PyMem_Free +void* MyPyMem_Calloc(size_t n, size_t s); +#endif /* _USE_PYTHON */ + + +char* mapfile(const char* path, size_t* mapsizptr); + +ssize_t writebuf(const char* path, unsigned char* buf, size_t siz); + +char* bintostr(const char* buf, size_t siz, size_t delim, size_t *strlenptr); + +void printrimmed(char* str, size_t siz, size_t charsperline, bool printlinenmb); + +void printbytebuf(char* buf, size_t siz, size_t charsperline, bool printlinenmb); + +char *strnstr(const char *haystack, const char *needle, size_t len); + +#endif -- cgit v1.2.3