9fans archive / 1995 / 10 / 84 / prev next
From: beto@pla... beto@pla...
Subject: reading selected text in acme
Date: Mon, 9 Oct 1995 19:21:54 -0400
In <95Oct9.021146edt.78511@col...>
rob@pla... wrote:
> #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);
> }
>
>
>
Thanks