91int main(
int argc,
char *argv[])
95 static const int buffSZ = 1024*1024;
96 const char *fPath, *fmt =
"%08x";
97 int bytes, fd,
opts = O_RDONLY;
99 bool addPath =
true, addNL =
true;
105 if (argc > 1 &&
'-' == *argv[1])
106 while ((c = getopt(argc,argv,
"dhnsx")) && ((
unsigned char)c != 0xff))
113 case 'n': addNL =
false;
115 case 's': addPath =
false;
117 case 'x': fmt =
"%x";
119 default: std::cerr <<pgm <<
'-' <<char(
optopt) <<
" option is invalid" <<std::endl;
138 int rc = posix_memalign(&buffP, sysconf(_SC_PAGESIZE), buffSZ);
139 if (rc) {errno = rc;
Fatal(
"allocate buffer to read", fPath);}
143 while((bytes =
read(fd, buffP, buffSZ)) > 0)
148 if (bytes < 0)
Fatal(
"read", fPath);
152 sprintf(csBuff, fmt, csVal);
153 std::cout <<(
char *)csBuff;
154 if (addPath) std::cout <<
' ' <<fPath;
155 if (addNL) std::cout << std::endl;