readifile.c (409B)
1 #include "stdinc.h" 2 #include "dat.h" 3 #include "fns.h" 4 5 void 6 usage(void) 7 { 8 fprint(2, "usage: readifile file\n"); 9 threadexitsall("usage"); 10 } 11 12 void 13 threadmain(int argc, char *argv[]) 14 { 15 IFile ifile; 16 17 ARGBEGIN{ 18 default: 19 usage(); 20 }ARGEND 21 22 if(argc != 1) 23 usage(); 24 25 if(readifile(&ifile, argv[0]) < 0) 26 sysfatal("readifile %s: %r", argv[0]); 27 write(1, ifile.b->data, ifile.b->len); 28 threadexitsall(nil); 29 }