aboutsummaryrefslogtreecommitdiffstats
path: root/src/util/eopen.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-01-11 09:11:51 +0100
committerMattias Andrée <maandree@kth.se>2017-01-11 09:11:51 +0100
commitb7a82c980fe7e0c1f9029b55be97422428d65d5a (patch)
tree67bedc856eb1f72a2daa8ef8347b904269b06df5 /src/util/eopen.h
parentvu-crop: add -t (diff)
downloadblind-b7a82c980fe7e0c1f9029b55be97422428d65d5a.tar.gz
blind-b7a82c980fe7e0c1f9029b55be97422428d65d5a.tar.bz2
blind-b7a82c980fe7e0c1f9029b55be97422428d65d5a.tar.xz
Clean up code
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/util/eopen.h')
-rw-r--r--src/util/eopen.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/util/eopen.h b/src/util/eopen.h
new file mode 100644
index 0000000..42e8c5d
--- /dev/null
+++ b/src/util/eopen.h
@@ -0,0 +1,14 @@
+/* See LICENSE file for copyright and license details. */
+#include <fcntl.h>
+
+#define eopen(...) enopen(1, __VA_ARGS__)
+#define enopen(...) xenopen(__VA_ARGS__, 0)
+
+static inline int
+xenopen(int status, const char *path, int flags, int mode, ...)
+{
+ int fd = open(path, flags, mode);
+ if (fd < 0)
+ enprintf(status, "open %s:", path);
+ return fd;
+}