aboutsummaryrefslogtreecommitdiffstats
path: root/src/util/io.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-04-08 23:02:48 +0200
committerMattias Andrée <maandree@kth.se>2017-04-08 23:02:48 +0200
commit0804a80954bf9b8c11392d77a4933ec0a4ff635b (patch)
treed19ab7658b07089af643deba41ec73f696925e54 /src/util/io.h
parentDocument memory requirements, minor style fixes, more use of BUFSIZ, fix warnings, and fix potential buffer overflow (diff)
downloadblind-0804a80954bf9b8c11392d77a4933ec0a4ff635b.tar.gz
blind-0804a80954bf9b8c11392d77a4933ec0a4ff635b.tar.bz2
blind-0804a80954bf9b8c11392d77a4933ec0a4ff635b.tar.xz
Add blind-translate and fix errors
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--src/util/io.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/util/io.h b/src/util/io.h
index 81b8f51..44e222d 100644
--- a/src/util/io.h
+++ b/src/util/io.h
@@ -1,8 +1,9 @@
/* See LICENSE file for copyright and license details. */
-#define ewriteall(...) enwriteall(1, __VA_ARGS__)
-#define ereadall(...) enreadall(1, __VA_ARGS__)
-#define epwriteall(...) enpwriteall(1, __VA_ARGS__)
+#define ewriteall(...) enwriteall(1, __VA_ARGS__)
+#define ereadall(...) enreadall(1, __VA_ARGS__)
+#define epwriteall(...) enpwriteall(1, __VA_ARGS__)
+#define ewritezeroes(...) enwritezeroes(1, __VA_ARGS__)
int writeall(int fd, void *buf, size_t n);
@@ -32,3 +33,12 @@ enpwriteall(int status, int fd, void *buf, size_t n, size_t ptr, const char *fna
if (pwriteall(fd, buf, n, ptr))
enprintf(status, "pwrite %s:", fname);
}
+
+int writezeroes(int fd, void *buf, size_t bufsize, size_t n);
+
+static inline void
+enwritezeroes(int status, int fd, void *buf, size_t bufsize, size_t n, const char *fname)
+{
+ if (writezeroes(fd, buf, bufsize, n))
+ enprintf(status, "write %s:", fname);
+}