From ccc0a2318314c027362375df8b18941f9ff35bf7 Mon Sep 17 00:00:00 2001 From: leitner Date: Sun, 3 Aug 2003 22:24:32 +0000 Subject: [PATCH] add int64 type to uint64.h add io.h as per http://cr.yp.to/lib/io.html --- io.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ uint64.h | 1 + 2 files changed, 62 insertions(+) create mode 100644 io.h diff --git a/io.h b/io.h new file mode 100644 index 0000000..71ae38b --- /dev/null +++ b/io.h @@ -0,0 +1,61 @@ +#ifndef IO_H +#define IO_H + +/* http://cr.yp.to/lib/io.html */ + +#include "uint64.h" +#include "tai.h" + +/* like open(s,O_RDONLY) */ +int io_readfile(int64* d,const char* s); +/* like open(s,O_WRONLY|O_TRUNC,0600) */ +int io_createfile(int64* d,const char* s); +/* like pipe(d) */ +int io_pipe(int64* d); + +/* non-blocking read(), -1 for EAGAIN and -3+errno for other errors */ +int64 io_tryread(int64 d,char* buf,int64 len); + +/* blocking read(), with -3 instead of -1 for errors */ +int64 io_waitread(int64 d,char* buf,int64 len); + +/* non-blocking write(), -1 for EAGAIN and -3+errno for other errors */ +int64 io_trywrite(int64 d,const char* buf,int64 len); + +/* blocking write(), with -3 instead of -1 for errors */ +int64 io_waitwrite(int64 d,const char* buf,int64 len); + +/* modify timeout attribute of file descriptor */ +void io_timeout(int64 d,struct taia t); + +/* like io_tryread but will return -2,errno=ETIMEDOUT if d has a timeout + * associated and it is passed without input being there */ +int64 io_tryreadtimeout(int64 d,char* buf,int64 len); + +/* like io_trywrite but will return -2,errno=ETIMEDOUT if d has a timeout + * associated and it is passed without being able to write */ +int64 io_trywritetimeout(int64 d,const char* buf,int64 len); + +void io_wantread(int64 d); +void io_wantwrite(int64 d); +void io_dontwantread(int64 d); +void io_dontwantwrite(int64 d); + +void io_wait(); +void io_waituntil(struct taia t); +void io_check(); + +/* return next descriptor from io_wait that can be read from */ +int64 io_canread(); +/* return next descriptor from io_wait that can be written to */ +int64 io_canwrite(); + +/* put d on internal data structure, return 1 on success, 0 on error */ +int io_fd(int64 d); + +/* put descriptor in non-blocking mode */ +void io_nonblock(int64 d); +/* put descriptor in close-on-exec mode */ +void io_closeonexec(int64 d); + +#endif diff --git a/uint64.h b/uint64.h index 734d2c2..f725c96 100644 --- a/uint64.h +++ b/uint64.h @@ -2,5 +2,6 @@ #define UINT64_H typedef unsigned long long uint64; +typedef signed long long int64; #endif