/* * Convert old to new archive format */ #include #include #define omag 0177555 struct ar_hdr nh; struct { char oname[8]; long odate; char ouid; char omode; unsigned siz; } oh; char *tmp; char *mktemp(); int f; int tf; union { char buf[512]; int magic; } b; main(argc, argv) char *argv[]; { register i; tmp = mktemp("/tmp/arcXXXXX"); for(i=1; i<4; i++) signal(i, SIG_IGN); for(i=1; i 0) { i = 512; if(n < i) i = n; read(f, b.buf, i); write(tf, b.buf, i); n -= i; } goto loop; out: lseek(f, 0L, 0); lseek(tf, 0L, 0); while((i=read(tf, b.buf, 512)) > 0) write(f, b.buf, i); close(f); close(tf); }