summaryrefslogtreecommitdiff
path: root/src/utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils.h')
-rw-r--r--src/utils.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h
new file mode 100644
index 0000000..71d3e9c
--- /dev/null
+++ b/src/utils.h
@@ -0,0 +1,27 @@
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <errno.h>
+#include <arpa/inet.h>
+
+#ifndef __UTILS_H
+#define __UTILS_H
+
+#define match(a, b) (!strcmp(a, b))
+#define matchn(a, b, n) (!strncmp(a, b, n))
+
+int host_to_inet(const char *host, struct in_addr *in);
+int systemf(const char *fmt, ...);
+ssize_t safe_read(int fd, void *buf, size_t count);
+ssize_t safe_readn(int fd, void *buf, size_t len);
+ssize_t safe_write(int fd, const void *buf, size_t count);
+ssize_t full_write(int fd, const void *buf, size_t len);
+int set_nonblocking(int fd);
+int inet_conn_str(char *host, int port, int type);
+int inet_conn_ia(struct in_addr *host, int port, int type);
+
+#endif /* ~__UTILS_H */