#ifndef UTIL_H #define UTIL_H #include #include #include #include #include #define ARRSIZE(x) (sizeof(x)/sizeof((x)[0])) #define MIN(x,y) ((x) > (y) ? (y) : (x)) #define MAX(x,y) ((x) < (y) ? (y) : (x)) #define PRINTABLE(c) ((c) >= 32 ? (c) : ' ') #define ERR(...) fprintf(stderr, "ERR: " __VA_ARGS__) #define FREE(p) do { free(p); p = NULL; } while (0) #define FCLOSE(f) do { if (f) fclose(f); f = NULL; } while (0) #define MHASHLEN 40 enum { FAIL = 0, OK = 1 }; void* checkp(void *p); void* die(const char *fmtstr, ...); char* aprintf(const char *fmtstr, ...); const char* mhash(const char *filename, int len); int checkalph(const char *str, const char *alph); void freadstr(FILE *f, char **dst); void fputstr(FILE *f, char *s); const char* ask(const char *fmtstr, ...); void dump(const char *filepath); int strpfcmp(const char *prefix, const char *str); float fle32toh(float v); extern int echo; #endif /* UTIL_H */