Digital Research
This commit is contained in:
2020-11-06 18:50:37 +01:00
parent 621ed8ccaf
commit 31738079c4
8481 changed files with 1888323 additions and 0 deletions

View File

@@ -0,0 +1,758 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, Ca. 92121
*/
char *SCCSID = "@(#) ar68 - July 1, 1983";
#include <stdio.h>
#ifndef PDP11
# define SEEKTYPE long
# include <sys/types.h>
# include <stat.h>
# ifdef VAX11
# include <c68/ar68.h>
# else
# include <ar68.h>
# endif
#else
# include <stat11.h>
# define SEEKTYPE int
long mklong();
#endif
#ifdef VAX11
# define int short
#endif
#define USAGE "usage: %s [rdxtpvabi] [pos] archive file [file ...]\n"
#define DEFMODE 0666
char buff[BUFSIZ];
struct stat astat, tstat; /* 11 apr 83, struct stat */
#define READ 0
#define WRITE 1
/* flags for cp1file */
#define IEVEN 1
#define OEVEN 2
#define WHDR 4
#define ROWN 0400 /* file protection flags */
#define WOWN 0200
#define XOWN 0100
#define RGRP 040
#define WGRP 020
#define XGRP 010
#define ROTH 04
#define WOTH 02
#define XOTH 01
struct libhdr libhd;
struct libhdr *lp = { &libhd };
int libmagic = LIBMAGIC;
int rflg, dflg, xflg, tflg, vflg;
int uflg;
int pflg;
int areof;
FILE *arfp;
FILE *tempfd;
int aflg, bflg;
int psflg;
int matchflg;
char *psname;
char *arname,*tempname;
FILE *openar();
char *mktemp();
char *ctime();
char *fnonly();
int (*docom)();
int endit();
int replace();
int delete();
int extract();
int tell();
int print();
#ifdef VAX11
struct {
short loword;
short hiword;
};
#else
struct {
int hiword;
int loword;
};
#endif
char fname[15];
main(argc,argv)
char **argv;
{
register char *p1, *p2;
register char **ap;
register int i;
int j,docopy;
char *myname;
myname = *argv;
if( argc < 3 ) {
usage:
printf(USAGE,myname);
endit();
}
signal(1,endit);
signal(2,endit);
ap = &argv[1];
p1 = *ap++;
i = argc-3;
while(*p1) {
switch(*p1++) {
case 'r':
rflg++;
docom = replace;
break;
case 'a':
aflg++;
psname = *ap++;
i--;
break;
case 'b':
case 'i':
bflg++;
i--;
psname = *ap++;
break;
case 'd':
dflg++;
docom = delete;
break;
case 'x':
xflg++;
docom = extract;
break;
case 't':
tflg++;
docom = tell;
break;
case 'p':
pflg++;
docom = print;
break;
case 'v':
vflg++;
break;
case '-':
break;
default:
printf("invalid option flag: %c\n",*--p1);
endit();
}
}
uflg = rflg+dflg;
if( (uflg+xflg+tflg+pflg) != 1 ) {
printf("At least one and only one of 'rdxt' flags required\n");
endit();
}
psflg = aflg+bflg;
if( psflg > 1 ) {
printf("only one of 'abi' flags allowed\n");
endit();
}
if( psflg && (rflg != 1) ) {
printf("'abi' flags can only be used with 'r' flag\n");
endit();
}
arname = *ap++;
arfp = openar(arname,rflg);
if( i == 0 && tflg ) {
listall();
endit();
}
if( i == 0 && xflg ) {
exall();
endit();
}
if( i <= 0 )
goto usage;
tempname = mktemp("/tmp/_~ar?????");
if( (tempfd = fopen(tempname,"w")) == NULL ) {
printf("can't create %s\n",tempname);
endit();
}
if( lputw(&libmagic,tempfd) != 0 )
perror("ar: write error on magic number");
/* read archive, executing appropriate commands */
while( matchflg == 0 && nextar() ) {
docopy = 1;
if( !psflg ) {
for (j = 0; j < i; j++) {
if( streq( fnonly(ap[j]), &lp->lfname[0]) ) {
docopy = 0;
(*docom)(ap[j]);
i--;
while( j < i ) {
ap[j] = ap[j+1];
j++;
}
}
}
}
else if( streq(psname,&lp->lfname[0]) ) {
docopy = 0;
for (j = 0; j < i; j++)
(*docom)(ap[j]);
i = 0;
psflg = 0;
}
if( docopy )
skcopy(uflg);
}
/* deal with the leftovers */
if( i > 0 ) {
for (j = 0; j < i; j++) {
if( rflg )
(*docom)(ap[j]);
else
printf("%s not found\n",ap[j]);
}
}
(*docom)(0L);
/* make temp file the archive file */
if( stat(tempname,&tstat) < 0 ) {
printf("can't find %s\n",tempname);
endit();
}
if( arfp != NULL ) {
if( stat(arname,&astat) < 0 ) {
printf("can't find %s\n",arname);
endit();
}
if( (astat.st_nlink != 1) || (astat.st_dev != tstat.st_dev) ) {
fclose(arfp);
tmp2ar();
}
else if( (unlink(arname) == -1) ) {
printf("can't unlink old archive\nnew archive left in %s\n",
tempname);
tempname = 0; /* keeps endit from removing the archive */
}
else if( link(tempname,arname) < 0 ) {
if( copy(tempname,arname) < 0 ) {
printf("can't link to %s\nnew archive left in %s\n",
arname,tempname);
tempname = 0;
}
}
}
else {
if( (arfp = fopen(arname,"w")) == NULL ) {
printf("can't create %s\narchive left in %s\n",arname,tempname);
tempname = 0; /* keeps endit from removing the archive */
endit();
}
if( stat(arname,&astat) < 0 ) {
printf("can't find %s\n",arname);
endit();
}
fclose(arfp);
if( astat.st_dev != tstat.st_dev )
tmp2ar();
else if( (unlink(arname) < 0) || (link(tempname,arname) < 0) ) {
printf("can't link to %s\n",arname);
printf("new archive left in %s\n",tempname);
tempname = 0; /* keeps endit from removing the archive */
}
}
endit();
}
FILE *
openar(arp,crfl)
char *arp;
{
register FILE *i;
unsigned int ib;
if( (i = fopen(arp,"r")) == NULL ) { /* does not exist */
areof = 1;
return(NULL);
}
if( lgetw(&ib,i) != 0 || ib != LIBMAGIC ) {
notar:
printf("not archive format: %s %o\n",arp,ib);
endit();
}
return(i);
}
/* execute one command -- call with filename or 0 */
int
tell(ap)
char *ap;
{
register char *p;
register i;
register char *p1;
if( ckafile(ap) )
return;
if( vflg ) { /* long list */
pmode(lp->lfimode);
printf(" %d/%d ",lp->luserid,lp->lgid);
#ifdef PDP11
plong("%6ld",lp->lfsize);
#else
printf("%6ld",lp->lfsize);
#endif
p1 = ctime(&lp->lmodti);
p1[24] = '\0';
p1 += 4;
printf(" %s ",p1);
}
pfname();
skcopy(0);
}
pfname()
{
register char *p;
register i;
p = &lp->lfname[0];
i = LIBNSIZE;
while( *p && i ) {
putchar(*p++);
i--;
}
putchar('\n');
}
int
replace(name)
char *name;
{
register int i;
register FILE *ifd;
register struct stat *stp; /* 11 apr 83, struct stat */
struct stat stbuf;
#ifdef PDP11
long l;
#endif
stp = &stbuf;
if( name == 0 ) {
if( bflg && areof == 0 ) {
if( fseek(arfp,-(SEEKTYPE)LIBHDSIZE,1) == -1 )
printf("fseek error\n");
}
cprest();
return;
}
if( stat(name,stp) < 0 ) {
printf("can't find %s\n",name);
endit();
}
if( (ifd = fopen(name,"r")) == NULL ) {
printf("can't open %s\n",name);
endit();
}
if( areof && psflg ) {
printf("%s not in library\n",psname);
endit();
}
if( (bflg|aflg) && matchflg == 0 ) { /* copy archive before appending */
if( aflg )
skcopy(1);
matchflg++;
}
copystr(name,&lp->lfname[0],LIBNSIZE);
if( areof|aflg )
inform('a');
else if( bflg )
inform('i');
else {
inform('r');
skcopy(0); /* skip old copy */
}
lp->luserid = stp->st_uid;
lp->lgid = stp->st_gid;
lp->lfimode = stp->st_mode;
#ifdef PDP11
l = mklong(stp->st_mtime[0],stp->st_mtime[1]);
lp->lmodti = l;
l = mklong(stp->st_size0,stp->st_size1);
lp->lfsize = l;
#else
lp->lmodti = stp->st_mtime;
lp->lfsize = stp->st_size;
#endif
cp1file(ifd,tempfd,WHDR+OEVEN,name,tempname);
fclose(ifd);
}
int
delete(ap)
char *ap;
{
if( ap == 0 ) {
cprest();
return;
}
inform('d');
skcopy(0);
}
int
extract(ap)
char *ap;
{
register FILE *ofd;
register i;
if( ckafile(ap) )
return;
if( (i = creat(ap,lp->lfimode)) < 0 ) {
printf("can't create %s\n",ap);
endit();
}
ofd = fdopen(i,"w");
inform('x');
cp1file(arfp,ofd,IEVEN,arname,ap);
fclose(ofd);
}
int
print(ap)
char *ap;
{
if( ckafile(ap) )
return;
cp1file(arfp,1,IEVEN,arname,"std output");
}
int
endit()
{
if( tempname )
unlink(tempname);
exit(0);
}
/* list all file in the library */
listall()
{
while( nextar() )
tell((char *) -1);
}
/* read next ar file header into libhd */
nextar()
{
if( areof || getarhd(arfp,&libhd) == EOF || libhd.lfname[0] == 0 ) {
areof++;
return(0);
}
return(1);
}
/* call with cpflag = 0 for skip, cpflag = 1 for copy */
skcopy(cpflag)
int cpflag;
{
register SEEKTYPE l;
register int i;
if( areof )
return;
l = lp->lfsize;
if( l&1 )
l++;
if( cpflag ) {
inform('c');
cp1file(arfp,tempfd,WHDR+OEVEN+IEVEN,arname,tempname);
}
else {
if( fseek(arfp,l,1) == -1 ) {
printf("seek error on library\n");
endit();
}
}
}
char *mktemp(ap)
char *ap;
{
register char *p;
register i,j;
i = getpid(); /* process id */
p = ap;
while( *p )
p++;
for( j = 0; j < 5; j++ ) {
*--p = ((i&7) + '0');
i >>= 3;
}
return(ap);
}
streq(s1, s2)
char *s1, *s2;
{
register char *p1, *p2;
p1 = s1;
p2 = s2;
while( *p1++ == *p2 )
if( *p2++ == 0 )
return(1);
return(0);
}
int m1[] = { 1, ROWN, 'r', '-' };
int m2[] = { 1, WOWN, 'w', '-' };
int m3[] = { 1, XOWN, 'x', '-' };
int m4[] = { 1, RGRP, 'r', '-' };
int m5[] = { 1, WGRP, 'w', '-' };
int m6[] = { 1, XGRP, 'x', '-' };
int m7[] = { 1, ROTH, 'r', '-' };
int m8[] = { 1, WOTH, 'w', '-' };
int m9[] = { 1, XOTH, 'x', '-' };
int *m[] = { m1, m2, m3, m4, m5, m6, m7, m8, m9};
pmode(aflg1)
{
register int **mp;
for( mp = &m[0]; mp < &m[9]; )
select(*mp++,aflg1);
}
select(pairp,flg)
int *pairp;
int flg;
{
register int n, *ap, f;
ap = pairp;
f = flg;
n = *ap++;
while( --n >= 0 && (f&*ap++) == 0 )
ap++;
putchar(*ap);
}
inform(cc)
char cc;
{
if( vflg ) {
putchar(cc);
putchar(' ');
pfname();
}
}
copystr(ap1,ap2,alen)
char *ap1, *ap2;
{
register char *p1, *p2;
register len;
p2 = 0;
p1 = ap1;
while( *p1 )
if( *p1++ == '/' )
p2 = p1; /* point to char after last '/' in name */
if( p2 )
p1 = p2;
else
p1 = ap1;
p2 = ap2;
len = alen;
while( len ) {
if( ! (*p2++ = *p1++) )
break;
len--;
}
while( --len > 0 )
*p2++ = '\0';
}
#ifdef PDP11
long
mklong(ai1,ai2)
{
long l;
l.hiword = ai1;
l.loword = ai2;
return(l);
}
plong(num)
long num;
{
}
#endif
cprest()
{
while( nextar() )
skcopy(1); /* copy rest of library */
}
cp1file(ifd,ofd,aflags,iname,oname)
FILE *ifd, *ofd;
int aflags;
char *iname, *oname;
{
register i;
register long l;
register int flags, sz;
char str[50];
flags = aflags;
if( flags&WHDR ) {
if( putarhd(ofd,&libhd) != 0 ) {
iwrerr:
sprintf(str,"ar: write error on %s",oname);
perror(str);
endit();
}
}
l = lp->lfsize;
while( l ) {
if( l < BUFSIZ )
sz = l;
else
sz = BUFSIZ;
if( (i = fread(buff,sizeof (char),sz,ifd)) == NULL ) {
perror("ar: read error");
endit();
}
if( fwrite(buff,sizeof (char),i,ofd) == NULL )
goto iwrerr;
l -= i;
}
if( flags&OEVEN ) {
if( lp->lfsize&1 )
fwrite("",sizeof (char),1,ofd);
}
if( flags&IEVEN )
if( lp->lfsize&1 )
fread(buff,sizeof (char),1,ifd);
}
ckafile(ap)
char *ap;
{
if( ap == 0 )
endit();
if( areof ) {
printf("%s not in archive file\n",ap);
return(1);
}
return(0);
}
exall()
{
while( nextar() )
extract(lp->lfname);
}
tmp2ar()
{
register int n,ifd,ofd;
if( (ofd = creat(arname,DEFMODE)) < 0 ) {
printf("can't create %s\n",arname);
printf("archive left in %s\n",tempname);
tempname = 0; /* keeps endit from removing the archive */
return;
}
fclose(tempfd);
if( (ifd = open(tempname,0)) < 0 ) {
printf("failed to open %s\n",tempname);
return;
}
while( (n = read(ifd,buff,BUFSIZ)) > 0 )
write(ofd,buff,n);
tempfd = fdopen(ifd,"r");
}
char *
fnonly(s)
char *s;
{
register char *p, *r;
r = s;
strcpy(fname,r);
p = 0;
while( *r ) {
if(*r == '/' )
p = r;
r++;
}
if( p ) {
++p;
if( *p == 0 )
p = fname;
}
else
p = fname;
return(p);
}
/* this is a copy routine for the cross device archive creation */
copy(from,to)
char *from, *to;
{
register int ifd, ofd, len;
if( (ofd = open(to,WRITE)) == -1 ) {
if( (ofd = creat(to,DEFMODE)) == -1 )
return(-1);
}
if( (ifd = open(from,READ)) == -1 ) {
close(ofd);
unlink(to);
return(-1);
}
while( (len = read(ifd,buff,sizeof buff)) > 0 )
write(ofd,buff,len);
close(ifd);
close(ofd);
}

View File

@@ -0,0 +1,5 @@
>c68 -r -L sendc68.c ../binary/lib7.a -o sendc68.68
>c68 -r -L -DMC68000 ar68.c -l7 -o ar68.68
>c68 -r -L nm.c -l7 -o nm.68
>c68 -r -L setstack.c ../binary/lib7.a -o setstack.68
>c68 -r -L size.c ../binary/lib7.a -o size.68

View File

@@ -0,0 +1,5 @@
cc sendc68.c -o sendc68.pdp
cc -DPDP11 ar68.c -o ar68.pdp
cc nm.c -o nm.pdp
cc setstack.c -o setstack.pdp
cc size.c -o size.pdp

View File

@@ -0,0 +1,5 @@
cc -O -w sendc68.c -o sendc68.vax
cc -O -w -DVAX11 ar68.c -o ar68.vax
cc -O -w nm.c -o nm.vax
cc -O -w setstack.c -o setstack.vax
cc -O -w size.c -o size.vax

View File

@@ -0,0 +1,246 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, Ca. 92121
*/
char *version = "@(#)nm - Apr 29, 1983";
#include <stdio.h>
#ifdef VAX11
# include <c68/cout.h>
# include <c68/sendc68.h>
#else
# include <cout.h>
# include <sendc68.h>
#endif
#define SYNAMLEN 8
int loctr;
int pflg;
int symflg;
FILE *ifp;
struct hdr couthd;
char eflag, gflag, qflag, xflag, dflag, tflag, bflag, aflag;
main(argc,argv)
char **argv;
{
register char *p;
register long symsize;
register int i, c, tellem;
long l, value;
int flags, optioncount, argc_old;
char symbol[20];
eflag = gflag = qflag = xflag = dflag = tflag = bflag = aflag = 0;
argc_old = argc;
optioncount = 0;
while (argc > 1) /* set flags, ignore filenames */
if (*argv[argc-1] == '-')
{
optioncount++;
switch (*++argv[--argc])
{
case 'e':
eflag = 1;
break;
case 'g':
gflag = 1;
break;
case 'q':
qflag = 1;
break;
case 'x':
xflag = 1;
break;
case 'd':
dflag = 1;
break;
case 't':
tflag = 1;
break;
case 'b':
bflag = 1;
break;
case 'a':
aflag = 1;
break;
default :
printf("nm: nonexistent option %s\n", argv[argc]);
optioncount--;
break;
}
--argv[argc];
}
else argc--;
argc = argc_old;
if( ((argc - optioncount) < 1) || (argc > (3 + optioncount)) )
tellem = 1;
else
tellem = 0;
if( (argc - optioncount) <= 1 )
*argv = "c.out"; /* default */
else {
--argc;
++argv;
}
/* process each file - ignore options in parameter list */
while( argc-- ) {
if( **argv == '-' ) {
argv++; continue; }
if( openfile(*argv++) == 0 )
continue;
if( tellem )
printf("%s:\n",ifilname);
l = couthd.ch_tsize+couthd.ch_dsize+HDSIZE;
#ifdef PDP11
if( longseek(l,fileno(ifp),3) == 0 )
#else
if( fseek(ifp,l,0) == EOF )
#endif
{
fclose(ifp);
continue;
}
for( symsize = couthd.ch_ssize; symsize > 0; symsize -= OSTSIZE ) {
p = symbol;
for( i = SYNAMLEN; --i != -1; ) {
if( (c = getc(ifp)) > 0 )
*p++ = c;
else
*p = '\0';
}
lgetw(&flags,ifp);
lgetl(&value,ifp);
if (accept(flags, optioncount))
{
printf("%-11s",symbol);
printf("%8lx",value);
prtflags(flags);
}
}
}
exit(0);
}
accept(af, optioncount)
int af;
int optioncount;
{
register int f;
int pft;
pft = 0;
if (!(optioncount))
return(1);
f = af;
if (eflag&&(f&SYEQ))
pft = 1;
if (gflag&&(f&SYGL))
pft = 1;
if (qflag&&(f&SYER))
pft = 1;
if (xflag&&(f&SYXR))
pft = 1;
if (dflag&&(f&SYDA))
pft = 1;
if (tflag&&(f&SYTX))
pft = 1;
if (bflag&&(f&SYBS))
pft = 1;
if (aflag&&((!(f&SYDA))&&(!(f&SYTX))&&(!(f&SYBS))))
pft = 1;
return(pft);
}
prtflags(af)
{
register int f;
f = af;
if( f&SYEQ )
printf(" equ");
if( f&SYGL )
printf(" global");
if( f&SYER )
printf(" reg");
if( f&SYXR )
printf(" external");
if( f&SYDA )
printf(" data");
else if( f&SYTX )
printf(" text");
else if( f&SYBS )
printf(" bss");
else
printf(" abs");
putchar('\n');
}
openfile(ap)
char *ap;
{
register char *p;
p = ap;
if( (ifp = fopen(p,"r")) == NULL ) {
printf("unable to open %s\n",p);
return(0);
}
ifilname = p; /* point to current file name for error msgs */
return(readhdr()); /* read file header */
}
readhdr()
{
if( getchd(ifp,&couthd) != 0 ) {
printf("error reading %s\n",ifilname);
return(0);
}
if( couthd.ch_magic < MAGIC || couthd.ch_magic > MAGICST ) {
printf("file format error: %s %x\n",ifilname,couthd.ch_magic);
return(0);
}
return(1);
}
#ifdef PDP11
longseek(al,fildes,pn)
long al;
int fildes, pn;
{
long l;
register b,o;
l = al>>9;
b = l.loword; /* block # */
o = al.loword&0777; /* offset in block */
if( doseek(fildes,b,pn) == 0 ) /* seek to block */
return(0);
if( doseek(fildes,o,SEEKREL) == 0 ) /* do offset */
return(0);
return(1);
}
doseek(afd,aoff,apnam)
{
if( seek(afd,aoff,apnam) < 0 ) {
printf("seek error on file %s\n",ifilname);
return(0);
}
return(1);
}
#endif

View File

@@ -0,0 +1,254 @@
/*
Copyright 1983
Alcyon Corporation
8716 Production Ave.
San Diego, Ca. 92121
*/
char *version = "@(#) sendc68 - Jul 29, 1983";
#ifdef VAX11
# include <c68/cout.h>
# include <c68/sendc68.h>
#else
# include <cout.h>
# include <sendc68.h>
#endif
/**
* this program reads a c.out format binary file and converts
* it to the absolute ASCII load format acceptable by MACSBUG
* and then sends it down the standard output file
**/
#define RBLEN 32 /* number of bytes per S1 record */
#define DELAY 012000
#define SDEFAULT 0x400
#define EDEFAULT 0x1000
#define USAGE "[-r] [-d delay] [-s start] [-e end] [-] objectfile [outputfile]"
struct hdr2 couthd;
long loctr;
int fout;
int pflg;
char cksum;
int syno;
char *ofn;
int ofd;
int noclear;
int bcnt = RBLEN;
int regulus = 0;
int debug;
long delay, nlstart, nlend;
struct buf *file;
main(argc,argv)
int argc;
char *argv[];
{
long l, l1;
int i;
short word;
if( argc < 2 ) {
usage:
printf("Usage: sendc68 %s\n",USAGE);
exit();
}
file = &ibuf;
i = 1;
nlstart = SDEFAULT;
nlend = EDEFAULT;
while( *argv[i] == '-' ) {
switch(argv[i][1]) {
case '\0': /* '-' only */
noclear = 1;
break;
case 'r': /* don't put out cr-lf only lf */
regulus = 1;
break;
case 'd':
delay = atol(argv[++i]);
if( delay <= 0 )
delay = DELAY;
break;
case 's':
nlstart = atol(argv[++i]);
if( nlstart < 0 )
nlstart = SDEFAULT;
break;
case 'e':
nlend = atol(argv[++i]);
if( nlend < 0 )
nlend = EDEFAULT;
break;
case 'D':
debug = 1;
break;
default:
goto usage;
}
i++;
}
openfile(argv[i++]);
if( argc > i ) {
ofn = argv[i]; /* tty device name */
if( (ofd = creat(ofn,0666)) < 0 ) {
printf("unable to create %s\n",ofn);
exit();
}
}
else
ofd = dup(1); /* standard output file */
fout = ofd; /* use buffered output */
l1 = couthd.ch_tsize;
loctr = couthd.ch_entry;
/* Main Loop */
for( l = 0; l < l1; l += 2) {
lgetw(&word, file);
outword(word);
loctr += 2;
}
if( couthd.ch_magic == EX_ABMAGIC ) {
while(bcnt != RBLEN) /* fill out the last S1 buffer */
outword(0);
loctr = couthd.ch_dstart;
}
l1 = couthd.ch_dsize;
for( l = 0; l < l1; l += 2) {
lgetw(&word, file);
outword(word);
loctr += 2;
}
if( noclear == 0 ) {
if( couthd.ch_magic == EX_ABMAGIC ) {
while( bcnt != RBLEN ) /* fill out the last S1 buffer */
outword(0);
loctr = couthd.ch_bstart;
}
l1 = couthd.ch_bsize; /* size of bss */
while( l1 > 0 ) {
outword(0); /* clear the bss */
l1 -= 2;
loctr += 2;
}
}
while( bcnt != RBLEN ) /* fill out the last S1 buffer */
outword(0);
printf("S9030000FC\n");
if( !regulus )
putchar(015); /* carriage return */
flush();
}
openfile(ap)
char *ap;
{
register char *p;
p = ap;
if( (ibuf.fildes = open(p,0)) < 0 ) {
printf("unable to open %s\n",p);
exit();
}
ifilname = p; /* point to current file name for error msgs */
readhdr(); /* read file header */
}
#define BADMAGIC(magic) (magic<EX_MAGIC || magic>EX_4KSTXT)
readhdr()
{
if (getchd(file, &couthd) == -1) {
printf("read error on: %s\n",ifilname);
exit(-1);
}
if (debug) {
printf("magic = %x\n",couthd.ch_magic);
printf("tsize = %ld\n",couthd.ch_tsize);
printf("dsize = %ld\n",couthd.ch_dsize);
printf("bsize = %ld\n",couthd.ch_bsize);
printf("ssize = %ld\n",couthd.ch_ssize);
printf("stksize = %ld\n",couthd.ch_stksize);
printf("entry = %ld\n",couthd.ch_entry);
if (couthd.ch_magic == EX_ABMAGIC) {
printf("dstart = %ld\n",couthd.ch_dstart);
printf("bstart = %ld\n",couthd.ch_bstart);
}
}
if (BADMAGIC(couthd.ch_magic)) {
printf("file format error: %s %x\n",ifilname,couthd.ch_magic);
exit(-1);
}
}
outword(i)
register int i;
{
if( loctr >= nlstart && loctr < nlend ) /* MACSBUG RAM--dont load */
return;
if( bcnt == RBLEN ) { /* beginning of record */
cksum = 0;
if (loctr >= 0x10000L) {
printf("S2");
hexby((int)(RBLEN+4));
hexby((int)(loctr>>16));
}
else {
printf("S1");
hexby((int)(RBLEN+3)); /* byte count */
}
hexwd((int)loctr);
}
hexwd((int)i);
bcnt -= 2;
if( bcnt == 0 ) {
hexby((int)(-cksum-1));
putchar('\n');
if( !regulus )
putchar(015); /* carriage return */
bcnt = RBLEN;
flush();
dodelay(); /* give 68000 time to load */
}
}
hexwd(i)
register int i;
{
hexby(i>>8);
hexby(i);
}
hexby(c)
register int c;
{
c &= 0xff;
cksum += c;
outhex((c>>4)&017);
outhex(c&017);
}
outhex(x)
register int x;
{
if( x >= 0 && x <= 9 )
putchar(x+'0');
else if( x >= 10 && x <= 15 )
putchar(x-10+'A');
else
exit(-1);
}
dodelay()
{
register long i, j;
for( i = 0; i != delay; i++ )
j = 0;
}

View File

@@ -0,0 +1,85 @@
/*
Copyright 1982
Alcyon Corporation
8716 Production Ave.
San Diego, Ca. 92121
*/
#ifdef VAX11
# include <c68/cout.h>
#else
# include <cout.h>
#endif
struct hdr2 couthd;
/* set the stack size for a c.out format file */
char *version = "@(#)setstack - Mar 23, 1983";
main(argc,argv)
int argc;
char **argv;
{
register int fd;
register char *p;
#ifdef PDP11
register int stksize, brksize;
# define atol(x) atoi(x)
#else
register long stksize, brksize;
long atol();
#endif
if( argc == 4 ) {
if( (brksize = atol(argv[3])) < 0 ) {
printf("bad break size\n");
exit();
}
argc--;
}
if( argc != 3 ) {
printf("usage: %s filename stksize [brksize]\n",argv[0]);
exit(-1);
}
if( (stksize = atol(argv[2])) < 0 ) {
printf("bad stack size\n");
exit();
}
if( (fd = open(argv[1],2)) < 0 ) {
printf("can't open %s\n",argv[1]);
exit(-1);
}
if(fdgetchd(fd,&couthd) != 0) {
printf("can't read %s\n",argv[1]);
exit(-1);
}
brksize = (brksize+1023)&(~1023); /* round to 1K boundary */
stksize = (stksize+1023)&(~1023); /* round to 1K boundary */
switch( couthd.ch_magic ) {
case MAGIC:
case MAGIC+2:
case MAGIC+3:
case MAGIC+4:
break;
default:
printf("%s: not c.out format\n",*argv);
exit(-1);
}
if( stksize > 0 )
couthd.ch_stksize = stksize;
if( brksize > 0 )
couthd.ch_entry = -brksize;
#ifdef PDP11
seek(fd,0,0);
#else
lseek(fd,0L,0);
#endif
if(fdputchd(fd,&couthd) != 0) {
printf("can't write %s\n",argv[1]);
exit(-1);
}
exit(0);
}

View File

@@ -0,0 +1,173 @@
/*
Copyright 1982
Alcyon Corporation
8716 Production Ave.
San Diego, Ca. 92121
*/
char *version "@(#)size68 - Apr 28, 1983";
#ifdef VAX11
# include "cout.h"
#else
# include <cout.h>
#endif
struct hdr couthd;
#define BSIZE 512
struct iob {
int fd;
int cc;
char *cp;
char cbuf[BSIZE];
} iobuf;
int fflag, err;
main(argc,argv)
int argc;
char **argv;
{
register char *p;
for( argv++; argc > 1; argc--, argv++ ) {
p = *argv;
if( *p++ != '-' )
break;
for( ; *p != '\0'; p++ ) {
switch( *p ) {
case 'f':
fflag++;
break;
default:
printf("bad flag %c\n",*p);
exit(-1);
}
}
}
if( argc <= 1 )
dofile("a.out");
else {
while( --argc > 0 )
dofile(*argv++);
}
exit(err);
}
dofile(fn)
char *fn;
{
register int i, j;
register struct hdr *hd;
long l;
hd = &couthd;
if(fopen(fn,&iobuf) < 0) {
printf("unable to open %s\n",fn);
err++;
return;
}
if ( getchd(&iobuf,&couthd) == -1) {
printf("read error on %s\n",fn);
err++;
}
else {
printf("%s:",fn);
switch( hd->ch_magic ) {
case EX_MAGIC:
break;
case EX_ABMAGIC:
printf("(stand alone)");
break;
case EX_2KSTXT:
printf("(2k shared text)");
break;
case EX_IDMAGIC:
printf("(I/D split)");
break;
case EX_4KSTXT:
printf("(4k shared text)");
break;
default:
printf(" not c.out format\n");
close(iobuf.fd);
return;
}
l = hd->ch_tsize+hd->ch_dsize+hd->ch_bsize;
ldec(hd->ch_tsize);
putchar('+');
ldec(hd->ch_dsize);
putchar('+');
ldec(hd->ch_bsize);
putchar('=');
ldec(l);
printf(" (");
lhex(l);
printf(")");
if( hd->ch_stksize || fflag ) {
printf(" stack=");
ldec(hd->ch_stksize);
}
if( hd->ch_entry < 0 || fflag ) {
printf(" break=");
ldec(-hd->ch_entry);
}
if( fflag ) {
if( hd->ch_rlbflg == 0 )
printf(" (bits)");
else
printf(" (nobits)");
}
putchar('\n');
}
close(iobuf.fd);
}
char ostr[80];
lhex(al)
long al;
{
register int i;
register int j;
register char *p;
p = &ostr[80];
*--p = 0;
for(i = 0; i < 8; i++) {
j = al&017;
if(j < 10)
j =+ '0';
else
j =+ 'A'-10;
*--p = j;
al =>> 4;
if(al == 0)
break;
}
printf("%s",p);
}
ldec(al)
long al;
{
register char *p;
p = &ostr[80];
*--p = 0;
do {
*--p = (al%10L)+'0';
al =/ 10L;
} while (al != 0);
printf("%s",p);
}