--- libaitio/example/test_aio.c 2012/08/01 09:20:04 1.1.2.1 +++ libaitio/example/test_aio.c 2012/08/01 09:40:10 1.1.2.3 @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -7,13 +8,32 @@ int main(int argc, char **argv) { - int f; + int f, ret; + char buf[BUFSIZ]; f = open("test_aio.dat", O_CREAT | O_RDWR | O_TRUNC, 0644); if (f == -1) { perror("open"); return 1; } + + while (!feof(stdin)) { + memset(buf, 0, sizeof buf); + fgets(buf, sizeof buf, stdin); + printf("io_write=%d\n", (ret = io_write(f, buf, strlen(buf)))); + if (ret == -1) { + ioLIBERR(io); + return 2; + } + } + + memset(buf, 0, sizeof buf); + printf("io_read=%d\n", (ret = io_rread(f, buf, sizeof buf, 0, 0))); + if (ret == -1) { + ioLIBERR(io); + return 3; + } + printf("\n\n%s\n", buf); close(f); return 0;