1 /* $Id: dl.c,v 2.5 1994/06/24 12:54:46 ceriel Exp $ */
3 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4 * See the copyright notice in the ACK home directory, in the file "Copyright".
27 char hex[] = "0123456789ABCDEF";
30 struct outsect sect[MAXSECT];
32 main(argc,argv) char **argv; {
39 fatal("usage: %s [object [tty]]\n",argv[0]);
44 fprintf(stderr,"%s: can't open %s\n",progname,s);
48 if (ohead.oh_flags & HF_LINK) {
49 fprintf(stderr,"%s: %s contains unresolved references\n",progname,s);
52 rd_sect(sect, ohead.oh_nsect);
55 for (i = 0; i < ohead.oh_nsect; i++) {
58 while (sect[i].os_size) {
59 unsigned int sz = 8096, fl;
60 extern char *calloc();
64 if (sz > sect[i].os_size) sz = sect[i].os_size;
65 sect[i].os_size -= sz;
66 pbuf = buf = calloc(sz, 1);
67 if (fl = sect[i].os_flen) {
69 sect[i].os_flen -= fl;
71 rd_emit(buf, (long) fl);
73 while (sz >= MAXBYTE) {
74 data(MAXBYTE, (int) pc, buf);
81 data(sz, (int) pc, buf);
98 newline(nd,pc,DATTYPE);
107 newline(0,records,EOFTYPE);
126 assert(bytecount == 0);
146 put(hex[(b>>4) & 017]);
163 i = read(ttyfd,&c,1);
170 fprintf(stderr,"%s: ",progname);
172 fprintf(stderr,"\n");
176 rd_fatal() { fatal("read error"); }