util.h (768B)
1 #ifndef UTIL_H_ 2 #define UTIL_H_ 3 4 #ifdef __OpenBSD__ 5 #include <unistd.h> 6 #else 7 #define pledge(p1, p2) 0 8 #define unveil(p1, p2) 0 9 #endif 10 11 #define DELIM '\t' 12 #define DELIMSTR "\t" 13 14 #undef strlcpy 15 size_t strlcpy(char *dst, const char *src, size_t dsize); 16 17 #undef strnlen 18 size_t strnlen(const char *str, size_t maxlen); 19 20 #undef strtonum 21 long long strtonum(const char *numstr, long long minval, long long maxval, 22 const char **errstrp); 23 24 void * xreallocarray(void *m, size_t n, size_t s); 25 26 size_t allocarr(double **arr, const char *str, size_t maxlen); 27 int scannextval(char **str, double *val); 28 void printarr(double *arr, size_t len); 29 void printfarr(char *delimstr, int prec, double *arr, size_t len); 30 size_t fscanmatrix(FILE *stream, double ***arr, size_t *nf); 31 32 #endif