From 3681d02253d29229e265720984ce81a35206de4c Mon Sep 17 00:00:00 2001 From: kinichiro Date: Sun, 25 Feb 2018 01:59:39 +0900 Subject: Add compat bits for libtls on Windows --- tls/compat/pread.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tls/compat/pread.c (limited to 'tls/compat/pread.c') diff --git a/tls/compat/pread.c b/tls/compat/pread.c new file mode 100644 index 0000000..f0c9a2f --- /dev/null +++ b/tls/compat/pread.c @@ -0,0 +1,23 @@ +/* + * Public domain + * + * Kinichiro Inoguchi + */ + +#include + +ssize_t +pread(int d, void *buf, size_t nbytes, off_t offset) +{ + off_t cpos, opos, rpos; + ssize_t bytes; + if((cpos = lseek(d, 0, SEEK_CUR)) == -1) + return -1; + if((opos = lseek(d, offset, SEEK_SET)) == -1) + return -1; + if((bytes = read(d, buf, nbytes)) == -1) + return -1; + if((rpos = lseek(d, cpos, SEEK_SET)) == -1) + return -1; + return bytes; +} -- cgit v1.2.3-55-g6feb