File:  [ELWIX - Embedded LightWeight unIX -] / libaitio / example / test_aio.c
Revision 1.1.2.3: download - view: text, annotated - select for diffs - revision graph
Wed Aug 1 09:40:10 2012 UTC (11 years, 11 months ago) by misho
Branches: io3_5
fini

    1: #include <stdio.h>
    2: #include <string.h>
    3: #include <unistd.h>
    4: #include <fcntl.h>
    5: #include <aitio.h>
    6: 
    7: 
    8: int
    9: main(int argc, char **argv)
   10: {
   11: 	int f, ret;
   12: 	char buf[BUFSIZ];
   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: 
   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: 
   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: 
   38: 	close(f);
   39: 	return 0;
   40: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>