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

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <aitio.h>


int
main(int argc, char **argv)
{
	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;
		}
	}

	close(f);
	return 0;
}

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