Annotation of libaitio/example/test_aio.c, revision 1.1.2.3
1.1.2.1 misho 1: #include <stdio.h>
1.1.2.2 misho 2: #include <string.h>
1.1.2.1 misho 3: #include <unistd.h>
4: #include <fcntl.h>
5: #include <aitio.h>
6:
7:
8: int
9: main(int argc, char **argv)
10: {
1.1.2.2 misho 11: int f, ret;
12: char buf[BUFSIZ];
1.1.2.1 misho 13:
14: f = open("test_aio.dat", O_CREAT | O_RDWR | O_TRUNC, 0644);
15: if (f == -1) {
16: perror("open");
17: return 1;
18: }
19:
1.1.2.2 misho 20: while (!feof(stdin)) {
21: memset(buf, 0, sizeof buf);
22: fgets(buf, sizeof buf, stdin);
23: printf("io_write=%d\n", (ret = io_write(f, buf, strlen(buf))));
24: if (ret == -1) {
25: ioLIBERR(io);
26: return 2;
27: }
28: }
29:
1.1.2.3 ! misho 30: memset(buf, 0, sizeof buf);
! 31: printf("io_read=%d\n", (ret = io_rread(f, buf, sizeof buf, 0, 0)));
! 32: if (ret == -1) {
! 33: ioLIBERR(io);
! 34: return 3;
! 35: }
! 36: printf("\n\n%s\n", buf);
! 37:
1.1.2.1 misho 38: close(f);
39: return 0;
40: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>