1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#ifndef HELPER_H_INCLUDED
#define HELPER_H_INCLUDED
#include <stdbool.h>
#include <stdlib.h>
#ifdef _USE_PYTHON
/* Python header files redefine some macros */
#undef _POSIX_C_SOURCE
#undef _XOPEN_SOURCE
#include <Python.h> /* 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
|