mirror of
https://github.com/SEPPDROID/Digital-Research-Source-Code.git
synced 2025-10-24 08:54:17 +00:00
Upload
Digital Research
This commit is contained in:
758
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/util/ar68.c
Normal file
758
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/util/ar68.c
Normal 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);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
c68 -r -L sendc68.c -l7 -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 -l7 -o setstack.68
|
||||
c68 -r -L size.c -l7 -o size.68
|
||||
@@ -0,0 +1,5 @@
|
||||
cc -DPDP11 sendc68.c -o sendc68.pdp
|
||||
cc -DPDP11 ar68.c -o ar68.pdp
|
||||
cc -DPDP11 nm.c -o nm.pdp
|
||||
cc -DPDP11 setstack.c -o setstack.pdp
|
||||
cc -DPDP11 size.c -o size.pdp
|
||||
@@ -0,0 +1,6 @@
|
||||
# Buildfile for REGULUS cross utilites for used under VAX/UNIX
|
||||
cc -O -w -DVAX11 sendc68.c -lV6 -o sendc68.vax
|
||||
cc -O -w -DVAX11 ar68.c -lV7 -o ar68.vax
|
||||
cc -O -w -DVAX11 nm.c -lV7 -o nm.vax
|
||||
cc -O -w -DVAX11 setstack.c -lV6 -o setstack.vax
|
||||
cc -O -w -DVAX11 size.c -lV6 -o size.vax
|
||||
109
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/util/cout.h
Normal file
109
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/util/cout.h
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
Copyright 1983
|
||||
Alcyon Corporation
|
||||
8716 Production Ave.
|
||||
San Diego, CA 92121
|
||||
|
||||
@(#) sys/cout.h - Jul 26, 1983 REGULUS 4.1
|
||||
*/
|
||||
|
||||
|
||||
struct hdr {
|
||||
#ifndef VAX11
|
||||
int ch_magic; /* c.out magic number 060016 = $600E */
|
||||
#else
|
||||
unsigned short ch_magic;
|
||||
#endif
|
||||
long ch_tsize; /* text size */
|
||||
long ch_dsize; /* data size */
|
||||
long ch_bsize; /* bss size */
|
||||
long ch_ssize; /* symbol table size */
|
||||
long ch_stksize; /* stack size */
|
||||
long ch_entry; /* location of entry point */
|
||||
short ch_rlbflg; /* relocation bits present flag, must be signed */
|
||||
};
|
||||
|
||||
struct hdr_cout {
|
||||
#ifndef VAX11
|
||||
int ftype; /* c.out magic number 060016 = $600E */
|
||||
#else
|
||||
unsigned short ftype;
|
||||
#endif
|
||||
long ftext; /* text size */
|
||||
long fdata; /* data size */
|
||||
long fbss; /* bss size */
|
||||
long fsym; /* symbol table size */
|
||||
long fssize; /* stack size */
|
||||
long fentry; /* location of entry point */
|
||||
short fflag; /* relocation bits present flag, must be signed */
|
||||
};
|
||||
|
||||
struct hdr2 {
|
||||
#ifndef VAX11
|
||||
int ch_magic; /* c.out magic number = 601B hex */
|
||||
#else
|
||||
unsigned short ch_magic;
|
||||
#endif
|
||||
long ch_tsize; /* # bytes in program text segment */
|
||||
long ch_dsize; /* # bytes in program data segment */
|
||||
long ch_bsize; /* # bytes in program bss segment */
|
||||
long ch_ssize; /* # bytes in symbol table */
|
||||
long ch_stksize; /* initial stack size */
|
||||
long ch_entry; /* entry point--address of text segment */
|
||||
short ch_rlbflg; /* relocation bits suppressed flag, must be signed */
|
||||
long ch_dstart; /* address of data segment */
|
||||
long ch_bstart; /* address of bss segment */
|
||||
};
|
||||
|
||||
/* structure of the symbol table */
|
||||
|
||||
struct nlist {
|
||||
char n_name[8];
|
||||
#ifdef VAX11
|
||||
short n_type;
|
||||
#else
|
||||
int n_type;
|
||||
#endif
|
||||
long n_value;
|
||||
};
|
||||
|
||||
/* HDSIZE should be 28 bytes, HDSIZ2 should be 36 bytes */
|
||||
#ifndef VAX11
|
||||
# define HDSIZE (sizeof (struct hdr))
|
||||
# define HDSIZ2 (sizeof (struct hdr2))
|
||||
#else
|
||||
# define HDSIZE 28
|
||||
# define HDSIZ2 36
|
||||
#endif
|
||||
|
||||
#ifdef VAX11
|
||||
# define MAGIC (unsigned short) 0x601a /* bra .+26 instruction */
|
||||
# define MAGIC1 (unsigned short) 0x601b /* data & bss base defined */
|
||||
# define MAGICST2 (unsigned short) 0x601c /* shared text 2K boundary */
|
||||
# define MAGICID (unsigned short) 0x601d /* I & D split */
|
||||
# define MAGICST (unsigned short) 0x601e /* shared test 4k boundary (-n default) */
|
||||
|
||||
# define EX_MAGIC (unsigned short) 0x601a
|
||||
# define EX_ABMAGIC (unsigned short) 0x601b
|
||||
# define EX_2KSTXT (unsigned short) 0x601c
|
||||
# define EX_IDMAGIC (unsigned short) 0x601d
|
||||
# define EX_4KSTXT (unsigned short) 0x601e
|
||||
#else
|
||||
# define MAGIC 0x601a /* bra .+26 instruction */
|
||||
# define MAGIC1 0x601b /* data & bss base defined */
|
||||
# define MAGICST2 0x601c /* shared text 2K boundary */
|
||||
# define MAGICID 0x601d /* I & D split */
|
||||
# define MAGICST 0x601e /* shared test 4k boundary (-n default) */
|
||||
|
||||
# define EX_MAGIC 0x601a
|
||||
# define EX_ABMAGIC 0x601b
|
||||
# define EX_2KSTXT 0x601c
|
||||
# define EX_IDMAGIC 0x601d
|
||||
# define EX_4KSTXT 0x601e
|
||||
#endif
|
||||
|
||||
#define SHT2KBOUND 2048
|
||||
#define SHT2KFIX(x) (((x+SHT2KBOUND-1)/SHT2KBOUND)*SHT2KBOUND)
|
||||
#define SHT4KBOUND 4096
|
||||
#define SHT4KFIX(x) (((x+SHT4KBOUND-1)/SHT4KBOUND)*SHT4KBOUND)
|
||||
|
||||
278
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/util/nm.c
Normal file
278
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/util/nm.c
Normal file
@@ -0,0 +1,278 @@
|
||||
/*
|
||||
Copyright 1983
|
||||
Alcyon Corporation
|
||||
8716 Production Ave.
|
||||
San Diego, Ca. 92121
|
||||
*/
|
||||
|
||||
char *version = "@(#)nm - Sep 19, 1983";
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef MC68000
|
||||
# include <c68/cout.h>
|
||||
# include <c68/sendc68.h>
|
||||
# include <c68/ar68.h>
|
||||
#else
|
||||
# include <cout.h>
|
||||
# include <sendc68.h>
|
||||
# include <ar68.h>
|
||||
#endif
|
||||
|
||||
#define SYNAMLEN 8
|
||||
char outbuf1[BUFSIZ];
|
||||
int loctr;
|
||||
int pflg;
|
||||
int symflg;
|
||||
FILE *ifp;
|
||||
struct hdr2 couthd;
|
||||
struct libhdr libhd;
|
||||
long l, value;
|
||||
int flags;
|
||||
char symbol[20];
|
||||
long offset;
|
||||
int magic;
|
||||
char eflag, gflag, qflag, xflag, dflag, tflag, bflag, aflag;
|
||||
int optioncount;
|
||||
|
||||
main(argc,argv)
|
||||
char **argv;
|
||||
{
|
||||
int argc_old;
|
||||
|
||||
setbuf(stdout,outbuf1);
|
||||
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]);
|
||||
exit(-1);
|
||||
break;
|
||||
}
|
||||
--argv[argc];
|
||||
}
|
||||
else argc--;
|
||||
|
||||
argc = argc_old;
|
||||
if ((argc - optioncount) <= 1 )
|
||||
*argv = "a.out"; /* default */
|
||||
else {
|
||||
--argc;
|
||||
++argv;
|
||||
}
|
||||
|
||||
/* process each file - ignore options in parameter list */
|
||||
|
||||
while (argc--) {
|
||||
if (**argv == '-') {
|
||||
argv++;
|
||||
continue;
|
||||
}
|
||||
if (!openfile(*argv++))
|
||||
continue;
|
||||
offset = 0;
|
||||
lgetw(&magic, ifp); /* get magic number */
|
||||
if (magic == LIBMAGIC) { /* we've got a library (archive) */
|
||||
offset = sizeof(magic);
|
||||
while (getarhd(ifp, &libhd) != EOF && libhd.lfname[0] != 0) {
|
||||
offset += sizeof(libhd);
|
||||
ifilname = libhd.lfname;
|
||||
prtsym(); /* check for a.out format and print symbols */
|
||||
offset += libhd.lfsize;
|
||||
#ifdef PDP11
|
||||
longseek(offset, fileno(ifp), 0);
|
||||
#else
|
||||
fseek(ifp, offset, 0);
|
||||
#endif
|
||||
}
|
||||
fclose(ifp);
|
||||
continue;
|
||||
}
|
||||
#ifdef PDP11
|
||||
longseek(0L, fileno(ifp), 0);
|
||||
#else
|
||||
fseek(ifp, 0L, 0); /* put the magic number back */
|
||||
#endif
|
||||
prtsym(); /* check for a.out format and print symbols */
|
||||
fclose(ifp);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
prtsym() /* print all symbols for current object file */
|
||||
{
|
||||
register long symsize;
|
||||
register char *p;
|
||||
register int i, c;
|
||||
|
||||
printf("%s:\n",ifilname);
|
||||
if (!readhdr())
|
||||
return; /* not a.out format */
|
||||
if (couthd.ch_magic != EX_ABMAGIC)
|
||||
l = couthd.ch_tsize+couthd.ch_dsize+HDSIZE;
|
||||
else
|
||||
l = couthd.ch_tsize+couthd.ch_dsize+HDSIZ2;
|
||||
#ifdef PDP11
|
||||
if( longseek(l+offest,fileno(ifp),3) == 0 )
|
||||
#else
|
||||
if( fseek(ifp ,l+offset ,0) == EOF )
|
||||
#endif
|
||||
return;
|
||||
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 (!optioncount || accept(flags)) {
|
||||
printf("%-11s",symbol);
|
||||
printf("%8lx",value);
|
||||
prtflags(flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
accept(af)
|
||||
int af;
|
||||
{
|
||||
register int f;
|
||||
|
||||
f = af;
|
||||
if (eflag&&(f&SYEQ))
|
||||
return(1);
|
||||
if (gflag&&(f&SYGL))
|
||||
return(1);
|
||||
if (qflag&&(f&SYER))
|
||||
return(1);
|
||||
if (xflag&&(f&SYXR))
|
||||
return(1);
|
||||
if (dflag&&(f&SYDA))
|
||||
return(1);
|
||||
if (tflag&&(f&SYTX))
|
||||
return(1);
|
||||
if (bflag&&(f&SYBS))
|
||||
return(1);
|
||||
if (aflag&&((!(f&SYDA))&&(!(f&SYTX))&&(!(f&SYBS))))
|
||||
return(1);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
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&SYFN)
|
||||
printf(" filename");
|
||||
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(1);
|
||||
}
|
||||
|
||||
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
|
||||
253
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/util/sendc68.c
Normal file
253
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/util/sendc68.c
Normal file
@@ -0,0 +1,253 @@
|
||||
|
||||
/*
|
||||
Copyright 1983
|
||||
Alcyon Corporation
|
||||
8716 Production Ave.
|
||||
San Diego, Ca. 92121
|
||||
*/
|
||||
|
||||
char *version = "@(#) sendc68 - Sep 1, 1983";
|
||||
|
||||
#ifdef VAX11
|
||||
# include <c68/cout.h>
|
||||
# include <c68/sendc68.h>
|
||||
#endif
|
||||
#ifdef MC68000
|
||||
# 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;
|
||||
struct buf *file;
|
||||
|
||||
char cksum, *ofn;
|
||||
long loctr, delay;
|
||||
int fout, pflg, ofd, noclear, debug, syno;
|
||||
int bcnt = RBLEN;
|
||||
long nlstart = SDEFAULT;
|
||||
long nlend = EDEFAULT;
|
||||
int regulus = 0;
|
||||
|
||||
main(argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
register long l, l1;
|
||||
register int i;
|
||||
short word;
|
||||
char *calledby;
|
||||
|
||||
calledby = *argv++;
|
||||
if( argc-- < 2 ) {
|
||||
usage:
|
||||
printf("Usage: %s: %s\n",calledby,USAGE);
|
||||
exit();
|
||||
}
|
||||
file = &ibuf;
|
||||
while( **argv == '-' ) {
|
||||
switch(*++*argv) {
|
||||
case '\0': /* '-' only */
|
||||
noclear = 1;
|
||||
break;
|
||||
case 'r': /* don't put out cr-lf only lf */
|
||||
regulus = 1;
|
||||
break;
|
||||
case 'd':
|
||||
argv++; argc--;
|
||||
if ((delay = atol(*argv)) <= 0)
|
||||
delay = DELAY;
|
||||
break;
|
||||
case 's':
|
||||
argv++; argc--;
|
||||
if ((nlstart = atol(*argv)) < 0)
|
||||
nlstart = SDEFAULT;
|
||||
break;
|
||||
case 'e':
|
||||
argv++; argc--;
|
||||
if ((nlend = atol(*argv)) < 0)
|
||||
nlend = EDEFAULT;
|
||||
break;
|
||||
case 'D':
|
||||
debug = 1;
|
||||
break;
|
||||
default:
|
||||
goto usage;
|
||||
}
|
||||
argc--; argv++;
|
||||
}
|
||||
|
||||
if (!argc)
|
||||
goto usage;
|
||||
openfile(calledby,*argv++);
|
||||
if( --argc ) {
|
||||
ofn = *argv; /* tty device name */
|
||||
if( (ofd = creat(ofn,0666)) < 0 ) {
|
||||
printf("%s: unable to create [%s]\n",calledby,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(calledby,ap)
|
||||
char *calledby,*ap;
|
||||
{
|
||||
register char *p;
|
||||
|
||||
if (debug)
|
||||
printf("%s input file : [%s]\n",calledby,ap);
|
||||
p = ap;
|
||||
if( (ibuf.fildes = open(p,0)) < 0 ) {
|
||||
printf("%s: unable to open %s\n",calledby,p);
|
||||
exit(-1);
|
||||
}
|
||||
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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
176
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/util/size.c
Normal file
176
CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/util/size.c
Normal file
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
Copyright 1982, 1983
|
||||
Alcyon Corporation
|
||||
8716 Production Ave.
|
||||
San Diego, Ca. 92121
|
||||
*/
|
||||
|
||||
char *version = "@(#)size68 - Oct 5, 1983";
|
||||
|
||||
#ifndef MC68000
|
||||
# include <c68/cout.h>
|
||||
# define DEFAULT "c.out"
|
||||
#else
|
||||
# include <cout.h>
|
||||
# define DEFAULT "a.out"
|
||||
#endif
|
||||
|
||||
struct hdr2 couthd;
|
||||
|
||||
#define BSIZE 512
|
||||
struct iob {
|
||||
int fd;
|
||||
int cc;
|
||||
char *cp;
|
||||
char cbuf[BSIZE];
|
||||
} iobuf;
|
||||
|
||||
int fflag, err;
|
||||
char *calledby;
|
||||
|
||||
main(argc,argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
register char *p;
|
||||
|
||||
for( calledby = *argv++; argc > 1; argc--, argv++ ) {
|
||||
p = *argv;
|
||||
if( *p++ != '-' )
|
||||
break;
|
||||
for( ; *p != '\0'; p++ ) {
|
||||
switch( *p ) {
|
||||
|
||||
case 'f':
|
||||
fflag++;
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("%s: bad flag %c\n",calledby,*p);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if( argc <= 1 )
|
||||
dofile(DEFAULT);
|
||||
else {
|
||||
while( --argc > 0 )
|
||||
dofile(*argv++);
|
||||
}
|
||||
exit(err);
|
||||
}
|
||||
|
||||
dofile(fn)
|
||||
char *fn;
|
||||
{
|
||||
register int i, j;
|
||||
register struct hdr2 *hd;
|
||||
long l;
|
||||
|
||||
hd = &couthd;
|
||||
if(fopen(fn,&iobuf) < 0) {
|
||||
printf("%s: unable to open %s\n",calledby,fn);
|
||||
err++;
|
||||
return;
|
||||
}
|
||||
if ( getchd(&iobuf,&couthd) == -1) {
|
||||
printf("%s: read error on %s\n",calledby,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);
|
||||
}
|
||||
Reference in New Issue
Block a user