Plan 9 from Bell Labs’s /usr/web/sources/contrib/tristan/oed/dump.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


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

#define min(a, b) (a) < (b) ? a : b

int
main(int argc, char **argv) {
	ulong off, len;
	uchar buf[32*1024];

	int s, t;

	if(argc < 3)
		exits("missing arguments");

	off = atol(argv[1]);
	len = atol(argv[2]) - off;
	
	seek(0, off, 0);
	while(len > 0){
		s = read(0, buf, min(sizeof(buf), len));
		if(s < 0)
			exits("read error");
		len -= s;
		t = write(1, buf, s);
		if(t != s)
			exits("write error");
	}
	exits(nil);
	return 0;
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.