void
fail(const char *message) {
	perror(message);
	exit(1);
}


cothread_t reader;
cothread_t printer;
struct {
	char	*buf;	
	size_t	len;	
	size_t	cap;	
} line;
size_t count;		


void
reader_entry(void)
{
	FILE *input;
	size_t newcap;
	int c, eof, eol;
	char *newbuf;

	input = fopen(, );
	if (input == NULL)
		fail();

	line.buf = malloc(line.cap = 4096);  
	if (line.buf == NULL)
		fail();
	line.len = 0;  

	do {
		c = fgetc(input);  
		if (ferror(input))
			fail();

		eof = (c == EOF);
		if (eof) {
			
			eol = (line.len > 0);
		} else {
			
			if (line.len == line.cap) {
				
				newcap = line.cap * 2;
				newbuf = realloc(line.buf, newcap);
				if (newbuf == NULL)
					fail();
				line.buf = newbuf;
				line.cap = newcap;
			}
			line.buf[line.len++] = c;

			
			eol = (c == '\n');
		}

		if (eol) {
			
			co_switch(printer);
			line.len = 0;  
		}
	} while (!eof);

	free(line.buf);
	line.buf = NULL;  

	printf(, count);
	co_switch(printer);
}


int
main()
{
	reader = co_create(4096, reader_entry);
	printer = co_active();
	count = 0;

	for (;;) {
		co_switch(reader);
		if (line.buf == NULL)
			break;

		
		fwrite(line.buf, 1, line.len, stdout);
		count++;
	}

	co_delete(reader);
	return 0;
}