summaryrefslogtreecommitdiff
path: root/send/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'send/util.h')
-rw-r--r--send/util.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/send/util.h b/send/util.h
new file mode 100644
index 0000000..5f1a698
--- /dev/null
+++ b/send/util.h
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+
+static void
+warn(const char *msg) {
+ if (errno != 0)
+ perror(msg);
+ else
+ fprintf(stderr, "error: %s\n", msg);
+}
+
+static void
+error(const char *msg) {
+ warn(msg);
+ exit(1);
+}
+
+static int
+make_mhash(char *m) {
+ int hash = 0;
+ while (*m != 0) {
+ hash += *m;
+ m++;
+ }
+ return hash;
+}