aboutsummaryrefslogtreecommitdiffstats
path: root/src/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h
new file mode 100644
index 0000000..c0e9064
--- /dev/null
+++ b/src/util.h
@@ -0,0 +1,38 @@
+#ifndef UTIL_H
+#define UTIL_H
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+
+#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 NULLFREE(p) do { free(p); p = 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 */