libowfat/test/iob.c

29 lines
529 B
C
Raw Normal View History

2003-09-08 20:32:43 +00:00
#include <assert.h>
#include "iob.h"
2003-09-08 20:52:00 +00:00
#include "buffer.h"
#include <unistd.h>
static int64 write_cb(int64 fd,const void* buf,uint64 len) {
if (len>2) len=2;
return write(fd,buf,len);
}
2003-09-08 20:32:43 +00:00
2004-11-25 21:52:35 +00:00
int main() {
2003-09-08 20:32:43 +00:00
int64 fd;
io_batch* b;
int64 r;
2003-09-08 20:32:43 +00:00
assert(io_readfile(&fd,"GNUmakefile"));
assert(b=iob_new(10));
assert(iob_addbuf(b,"Huhu",4));
assert(iob_addbuf(b," fnord\n",7));
assert(iob_addfile(b,fd,10,10));
iob_send(1,b);
#if 0
do {
r=iob_write(1,b,write_cb);
} while (r>0);
#endif
2007-10-17 13:31:27 +00:00
iob_free(b);
2004-11-25 21:52:35 +00:00
return 0;
2003-09-08 20:32:43 +00:00
}