9fans archive / 1995 / 10 / 79 /    prev next

From: rob@pla... rob@pla...
Subject: reading selected text in acme
Date: Mon, 9 Oct 1995 02:02:35 -0400

#include <u.h>
#include <libc.h>

/* assumes chars==characters.  fixing this is an exercise for the reader */

void
main(void)
{
	int c, a, d, x1, x2;
	char buf[256];

	c = open("/mnt/acme/1/ctl", ORDWR);
	a = open("/mnt/acme/1/addr", OREAD);
	d = open("/mnt/acme/1/data", OREAD);
	write(c, "addr=dot", 8);
	read(a, buf, sizeof buf);
	x1 = atoi(buf);
	x2 = atoi(buf+12);
	seek(d, x1, 0);
	read(d, buf, x2-x1);
	write(1, buf, x2-x1);
	exits(0);
}