/*
peek at a byte in a file. Value read is return value of command.
Copyright 2000 Rick Hohensee
This file is released for redistribution only as part of an
intact entire cLIeNUX Core.
uses libc.
*/
void usage ()
{ write(2,"\nUSAGE: peek filename offset_int \n\n", 41);
}
main(int argc, char * argv[])
{
int fd, offset, value;
char buf[4];
if ( argc - 3 )
{ usage();
exit(1);
}
fd = open(argv[1],2);
if ( fd < 0 )
{ write (2,"\nopen error\n",14);
exit(fd); /* error */
}
offset = atoi(argv[2]);
lseek(fd,offset, 0);
read(fd,buf,1);
return buf[0];
}
/*
gcc -o peek peek.c
strip -R .comment -R .note peek
wc peek
cp peek /.bi # install
cp peek.c /help/see/peek.1.html
*/