2 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
5 /* $Id: astrip.c,v 1.10 1994/06/24 10:13:51 ceriel Exp $ */
13 astrip -- remove symbols and relocation bits
17 char temp_name[] = "/tmp/sXXXXXX";
23 int readerror, writeerror;
30 signal(SIGHUP, SIG_IGN);
31 signal(SIGINT, SIG_IGN);
32 signal(SIGQUIT, SIG_IGN);
33 tname = mktemp(temp_name);
35 if ((status = strip(argv[argc])) > 1)
50 if (! rd_open(name)) {
51 fprintf(stderr, "astrip: cannot open %s\n", name);
57 if(readerror || BADMAGIC(buf)) {
58 fprintf(stderr, "astrip: %s-- bad format\n", name);
62 size = OFF_RELO(buf) - SZ_HEAD;
63 buf.oh_flags &= ~HF_LINK;
69 if (! wr_open(tname)) {
70 fprintf(stderr, "astrip: cannot create temp file %s\n", tname);
77 fprintf(stderr, "astrip: write error on temp file %s\n", tname);
82 if (fw < 0 || lseek(fw, (long)SZ_HEAD, 0) < 0) {
83 fprintf(stderr, "astrip: cannot create temp file %s\n", tname);
88 if(copy(name, tname, size, rd_fd(), fw)) {
96 if (! rd_open(tname)) {
97 fprintf(stderr, "astrip: cannot read temp file %s\n", tname);
100 fw = creat(name, 0777);
102 fprintf(stderr, "astrip: cannot write %s\n", name);
106 if(copy(tname, name, size, rd_fd(), fw)) {
117 copy(fnam, tnam, size, fr, fw)
125 while(size != (long)0) {
129 rd_bytes(fr, lbuf, (long) s);
131 fprintf(stderr, "astrip: unexpected eof on %s\n", fnam);
134 wr_bytes(fw, lbuf, (long) s);
136 fprintf(stderr, "astrip: write error on %s\n", tnam);