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,4 @@
_cleanup()
{
return(0);
}

View File

@@ -0,0 +1,6 @@
aclenf (s) /* counts length of string */
char *s;
{
int n;
for (n=0; *s++ != '\0'; n++);
return (n);}

View File

@@ -0,0 +1,11 @@
/*
* Creat.c -- Whitesmith's simulation of V6 "creat" function
*/
#include <std.h>
creat(name,mode)
char *name; /* -> Filename to create */
int mode; /* Read / Write, etc. */
{
return(create(name,1,1)); /* Write + 1 byte records*/
}

View File

@@ -0,0 +1,9 @@
/*
* El-Kludg-o Dup routine. Takes advantage of the fact that
* stdout is not closed by Bill Allen's stuff.
*/
dup(n)
register int n;
{
return(n);
}

View File

@@ -0,0 +1,7 @@
/*
* Bill Allen's kludge version of fflush ...
*/
myfflush()
{
return(0);
}

View File

@@ -0,0 +1,31 @@
/*****************************************************************************
*
* F P R I N T F F U N C T I O N
* -------------------------------
*
* The "fprintf" function is used to write data to a file using "putc".
*
* calling sequence:
*
* FILE *buff;
* .
* .
* .
* fprintf(buff,format,arg1,arg2, ... argn);
*
* Where:
*
* buff -> a UNIX structured buffer
* format is a text string as described in K & R
* Arg1-argn are optional arguments to be converted and
* placed in the output
*
*****************************************************************************/
fprintf (fd,fmt,a1) /* Declare args */
int fd; /* POS channel number */
char *fmt; /* -> Format string */
int a1; /* Whatever the right size */
{ /****************************/
extern char putc(); /* Putc routine from lib. */
_printf (fd,putc,fmt,&a1); /* Invoke secret routine */
} /****************************/

View File

@@ -0,0 +1,82 @@
ftoa (x, str, prec, format)
float x;
char *str;
{
/* converts a floating point number to an ascii string */
/* x is stored into str, which should be at least 30 chars long */
int ie, i, k, ndig, fstyle;
double y;
ndig = ( prec<=0) ? 7 : (prec > 22 ? 23 : prec+1);
if (format == 'f' || format == 'F')
fstyle = 1;
else
fstyle = 0;
/* print in e format unless last arg is 'f' */
ie = 0;
/* if x negative, write minus and reverse */
if ( x < 0)
{
*str++ = '-';
x = -x;
}
/* put x in range 1 <= x < 10 */
if (x > 0.0) while (x < 1.0)
{
x =* 10.0;
ie--;
}
while (x >= 10.0)
{
x = x/10.0;
ie++;
}
/* in f format, number of digits is related to size */
if (fstyle) ndig =+ ie;
/* round. x is between 1 and 10 and ndig will be printed to
right of decimal point so rounding is ... */
for (y = i = 1; i < ndig; i++)
y = y/10.;
x =+ y/2.;
if (x >= 10.0) {x = 1.0; ie++;} /* repair rounding disasters */
/* now loop. put out a digit (obtain by multiplying by
10, truncating, subtracting) until enough digits out */
/* if fstyle, and leading zeros, they go out special */
if (fstyle && ie<0)
{
*str++ = '0'; *str++ = '.';
if (ndig < 0) ie = ie-ndig; /* limit zeros if underflow */
for (i = -1; i > ie; i--)
*str++ = '0';
}
for (i=0; i < ndig; i++)
{
k = x;
*str++ = k + '0';
if (i == (fstyle ? ie : 0)) /* where is decimal point */
*str++ = '.';
x =- (y=k);
x =* 10.0;
}
/* now, in estyle, put out exponent if not zero */
if (!fstyle && ie != 0)
{
*str++ = 'E';
if (ie < 0)
{
ie = -ie;
*str++ = '-';
}
for (k=100; k > ie; k =/10);
for (; k > 0; k =/10)
{
*str++ = ie/k + '0';
ie = ie%k;
}
}
*str = '\0';
return;
}

View File

@@ -0,0 +1,55 @@
#define BLEN 512
struct iob {
int fd; /*file descriptor*/
int cc; /*char count*/
char *cp; /*ptr to next char*/
char cbuf[BLEN]; /*char buffer*/
};
fopen(fname,ibuf,x)
char *fname;
register struct iob *ibuf;
int x;
{
ibuf->cc = 0; /*no chars*/
x = (x == 0) ? 0 : 1;
return(ibuf->fd=open(fname,0,x));
}
char getc(ibuf)
register struct iob *ibuf;
{
char c;
if(ibuf->cc<=0) {
ibuf->cp = &(ibuf->cbuf[0]);
ibuf->cc = read(ibuf->fd,ibuf->cp,BLEN);
}
if(ibuf->cc <= 0) {
if(read(ibuf->fd,&c,1) != 1)
return(-1);
else
return(c);
}
ibuf->cc--;
return((int)(*(ibuf->cp)++)&0xff);
}
getw(ibuf)
register struct iob *ibuf;
{
register int j;
register int i;
if((j=getc(ibuf)) == -1)
return(-1);
i = j&0377;
if((j=getc(ibuf)) == -1)
return(-1);
i =| (j&0377)<<8;
if(i&0100000)
i =| 0xffff0000; /* make it negative */
return(i);
}

View File

@@ -0,0 +1,31 @@
#define BLEN 512
struct iob {
int fd; /*file descriptor*/
int cc; /*char count*/
char *cp; /*ptr to next char*/
char cbuf[BLEN]; /*char buffer*/
} fin;
getchar()
{
char c;
register int i;
if(fin.fd==0) {
if(read(0,&c,1)<=0 || c==4)
return(0);
i = c;
return(i&0xff);
}
if(fin.cc<=0) {
fin.cp = &(fin.cbuf[0]);
fin.cc = read(fin.fd,fin.cp,BLEN);
}
if(fin.cc <= 0) {
return(0);
}
fin.cc--;
i = *(fin.cp)++;
return(i&0xff);
}

View File

@@ -0,0 +1,7 @@
/*
* Getpid.c -- Whitesmith's version of UNIX getpid function
*/
getpid()
{
return(1);
}

View File

@@ -0,0 +1,63 @@
$ num
CLENF.C
CLENF.lis
$ num
CREAT.C
CREAT.lis
$ num
DUP.C
DUP.lis
$ num
FFLUSH.C
FFLUSH.lis
$ num
FPRINTF.C
FPRINTF.lis
$ num
FTOA.C
FTOA.lis
$ num
GETC.C
GETC.lis
$ num
GETC.C
GETC.lis
$ num
GETCHAR.C
GETCHAR.lis
$ num
GETPID.C
GETPID.lis
$ num
lseek.c
lseek.lis
$ num
PRINTF.C
PRINTF.lis
$ num
PUTC.C
PUTC.lis
$ num
PUTC.C
PUTC.lis
$ num
PUTCHAR.C
PUTCHAR.lis
$ num
PUTW.C
PUTW.lis
$ num
SBRK.C
SBRK.lis
$ num
SEEK.C
SEEK.lis
$ num
SPRINTF.C
SPRINTF.lis
$ num
UNLINK.C
UNLINK.lis
$ num
XPRINTF.C
XPRINTF.lis

View File

@@ -0,0 +1,26 @@
/* SEEK FOR VMS
* copyright (c) 1980 by Whitesmiths, Ltd.
*/
#include <std.h>
#include "vms.h"
FILE lseek(fd, loff, way)
FILE fd;
LONG loff;
COUNT way;
{
FAST RCB *p;
if (!(p = _ckfd(fd)) || !(p->flags & WFIX))
return (FAIL);
else
{
if (way == 0)
p->lseek = loff;
else if (way == 1)
p->lseek =+ loff;
else
p->lseek = p->lend + loff;
return (p->lseek);
}
}

View File

@@ -0,0 +1,23 @@
$ cx CREAT
$ cx cleanup
$ cx dup
$ cx getc
$ cx getchar
$ cx GETPID
$ cx PUTC
$ cx putchar
$ cx lseek
$ cx SEEK
$ cx UNLINK
$ cx CLENF
$ cx FTOA
$ cx PRINTF
$ cx FPRINTF
$ cx SPRINTF
$ cx XPRINTF
$ cx sbrk
$ cx strcat
$ cx xstrcmp
$library/create klutz *.obj
$ copy klutz.olb lib:
$ delete *.obj;*,*.olb;*

View File

@@ -0,0 +1,29 @@
/*****************************************************************************
*
* P R I N T F F U N C T I O N
* -------------------------------
*
* The "printf" function is used to write data to the standard output.
*
* calling sequence:
*
* printf(format,arg1,arg2, ... argn);
*
* Where:
*
* format is a text string as described in K & R
* Arg1-argn are optional arguments to be converted and
* placed in the output
*
*****************************************************************************/
__putc(fd,c) /* WSL is backwards!! */
{ /****************************/
putchar(c); /* Output character */
} /****************************/
printf (fmt,a1) /* Declare args */
char *fmt; /* -> Format string */
int a1; /* Whatever the right size */
{ /****************************/
_printf (0,__putc,fmt,&a1); /* Invoke secret routine */
} /****************************/

View File

@@ -0,0 +1,29 @@
/*****************************************************************************
*
* P R I N T F F U N C T I O N
* -------------------------------
*
* The "printf" function is used to write data to the standard output.
*
* calling sequence:
*
* printf(format,arg1,arg2, ... argn);
*
* Where:
*
* format is a text string as described in K & R
* Arg1-argn are optional arguments to be converted and
* placed in the output
*
*****************************************************************************/
__putc(fd,c) /* WSL is backwards!! */
{ /****************************/
write(1,&c,1); /* Output character */
} /****************************/
printf (fmt,a1) /* Declare args */
char *fmt; /* -> Format string */
int a1; /* Whatever the right size */
{ /****************************/
_printf (0,__putc,fmt,&a1); /* Invoke secret routine */
} /****************************/

View File

@@ -0,0 +1,63 @@
#define BLEN 512
struct iob {
int fd; /*file descriptor*/
int cc; /*char count*/
char *cp; /*ptr to next char*/
char cbuf[BLEN]; /*char buffer*/
};
fcreat(fname,ibuf,x)
char *fname;
int x;
register struct iob *ibuf;
{
ibuf->cc = BLEN; /*no chars*/
ibuf->cp = &(ibuf->cbuf[0]);
x = (x == 0) ? 0 : 1;
return(ibuf->fd=create(fname,2,x));
}
putc(c,ibuf)
char c;
register struct iob *ibuf;
{
if(ibuf->cc<=0) {
ibuf->cp = &(ibuf->cbuf[0]);
if(write(ibuf->fd,ibuf->cp,BLEN) != BLEN)
return(-1);
ibuf->cc = BLEN;
}
*(ibuf->cp)++ = c;
ibuf->cc--;
return(c);
}
putw(w,ibuf)
int w;
register struct iob *ibuf;
{
register j;
int i;
putc((char)w,ibuf);
putc((char)(w>>8),ibuf);
return(w);
}
myfflush(ibuf)
register struct iob *ibuf;
{
register i;
i = BLEN - ibuf->cc;
ibuf->cc = BLEN;
ibuf->cp = &(ibuf->cbuf[0]);
if(write(ibuf->fd,ibuf->cp,i) != i)
return(-1);
return(0);
}

View File

@@ -0,0 +1,42 @@
#define BLEN 512
struct iob {
int fd; /*file descriptor*/
int cc; /*char count*/
char *cp; /*ptr to next char*/
char cbuf[BLEN]; /*char buffer*/
} fout = {0,BLEN,&fout.cbuf[0]};
putchar(cc)
char cc;
{
if(fout.fd <= 1) {
if(write(1,&cc,1) != 1)
return(-1);
return(cc);
}
/* buffered output*/
if(fout.cc<=0) {
fout.cp = &(fout.cbuf[0]);
if(write(fout.fd,fout.cp,BLEN) != BLEN)
return(-1);
fout.cc = BLEN;
}
*(fout.cp)++ = cc;
fout.cc--;
return(cc);
}
myflush()
{
register i;
i = BLEN - fout.cc;
fout.cc = BLEN;
fout.cp = &(fout.cbuf[0]);
if(write(fout.fd,fout.cp,i) != i)
return(-1);
return(0);
}

View File

@@ -0,0 +1,13 @@
/*
* Putw.c -- Kludge version!
*/
putw(w,iobuf)
int w; /* 32-bits of which 16 are important */
int *iobuf; /* Not really, but ... */
{
short junk; /* Take care of hi word / low word etc */
junk = w & 0xffff; /* Convert to 16 bits */
write((*iobuf),&junk,2); /* Write out 2 bytes (Ugh!!) */
return(w);
}

View File

@@ -0,0 +1,69 @@
/* READ A FILE FOR VMS
* copyright (c) 1980 by Whitesmiths, Ltd.
*/
#include <std.h>
#include "vms.h"
COUNT read(fd, buf, size)
FILE fd;
FAST TEXT *buf;
COUNT size;
{
FAST RCB *p;
FAST BYTES n;
FAST BYTES bytesread;
BYTES boff;
COUNT stat;
if (!(p = _ckfd(fd)))
return (FAIL);
bytesread = 0;
for (n = 0; n < size; )
{
if (p->flags & WFIX)
{
boff = p->lseek & 0777;
if (p->lseek - boff == p->lact)
;
else if (!_wblk(p))
return (FAIL);
else if (!(stat = _read(p->rab, p->pbuf, BUFSIZE,
(p->lseek >> 9) + 1)))
break;
else if (stat != BUFSIZE)
{
p->lact = NOBLOCK;
if (bytesread == 0)
return (FAIL);
else
return (bytesread);
}
p->lact = p->lseek - boff;
p->bnext = p->pbuf + boff;
p->bleft = BUFSIZE - boff;
for (; n < size && 0 < p->bleft; --p->bleft, ++p->lseek)
*buf++ = *p->bnext++, ++n,++bytesread;
}
else if (p->bleft)
{
for (; n < size && 0 < p->bleft; --p->bleft, ++p->bnext)
if (*p->bnext != '\r' && *p->bnext != '\f' &&
*p->bnext != '\0')
*buf++ = *p->bnext, ++n;
}
else if ((stat = _read(p->rab, p->pbuf, BUFSIZE - 1, 0)) < -1)
return (FAIL);
else if (stat == -1)
break;
else
{
p->bleft = stat;
p->bnext = p->pbuf;
if (p->flags & (WCR|WTTY))
p->pbuf[p->bleft++] = '\n';
}
if (p->flags & WTTY && n)
break;
}
return (n);
}

View File

@@ -0,0 +1,27 @@
/* simulate sbrk system call until it works */
#define SBLEN 60000
long _sb_fmem[SBLEN]=0; /*free mem pool*/
char *_sb_fpt= _sb_fmem; /*free mem ptr */
char *sbrk(incr)
int incr;
{
register char *p;
p = _sb_fpt; /*save old ptr*/
if((_sb_fpt =+ incr) >= &_sb_fmem[SBLEN])
return(-1);
return(p);
}
int brk(addr)
char *addr;
{
if (addr <= &_sb_fmem[0] || addr > &_sb_fmem[SBLEN])
{
return(-1);
}
_sb_fpt = addr;
return(0);
}

View File

@@ -0,0 +1,16 @@
/*
* Seek.c -- Whitesmith's equivalent of V6 seek
*/
seek(fildes,offset,ptrname)
int fildes; /* UNIX / WS file descriptor */
int offset; /* File offset, bytes */
int ptrname; /* Sense variable */
{
offset &= 0xffff; /* Clear sign extension problems*/
if(ptrname > 2) /* Not byte sense seek */
{ /* */
offset = offset << 9; /* Multiply by 512 */
ptrname -= 3; /* reset to range 0 .. 2 */
} /********************************/
return(lseek(fildes,offset,ptrname));
}

View File

@@ -0,0 +1,31 @@
/*****************************************************************************
*
* S P R I N T F F U N C T I O N
* -------------------------------
*
* The "sprintf" function is used to format data into a string:
*
* calling sequence:
*
* char *buff;
* .
* .
* .
* sprintf(buff,format,arg1,arg2, ... argn);
*
* Where:
*
* buff -> a character string
* format is a text string as described in K & R
* Arg1-argn are optional arguments to be converted and
* placed in the output
*
*****************************************************************************/
sprintf (buff,fmt,a1) /* Declare args */
char *buff; /* -> Output string */
char *fmt; /* -> Format string */
int a1; /* Whatever the right size */
{ /****************************/
extern char _putstr(); /* Use this function */
_printf (buff,_putstr,fmt,&a1); /* Invoke secret routine */
} /****************************/

View File

@@ -0,0 +1,24 @@
/****************************************************************************
* STRCAT - concatenate strings
*
* BYTE *strcat(s1,s2) copies s2 to end of s1
* BYTE *s1, *s2;
*
* Assumes null terminated strings. No check is made for string area
* overflow.
****************************************************************************/
#include <portab.h>
BYTE *strcat(s1,s2)
REG BYTE *s1, *s2;
{
REG BYTE *cp;
for( cp=s1; *cp; cp++ ) /* save s1 for return. */
;
while( (*cp++ = *s2++) ) /* copy until eos(s2). */
;
return(s1);
}

View File

@@ -0,0 +1,17 @@
/**********************************************************************
* STRLEN - finds the number of non-null characters in s.
*
* WORD strlen(s)
* BYTE *s;
**********************************************************************/
#include <portab.h>
WORD strlen(s)
BYTE *s;
{ BYTE *p;
for( p = s; *p; p++ ) /* advance *p until NULL. */
;
return(p-s);
}

View File

@@ -0,0 +1,8 @@
/*
* Unlink.c -- Whitesmith's version of UNIX unlink function
*/
unlink(name)
char *name; /* -> file name */
{
return(remove(name));
}

View File

@@ -0,0 +1,29 @@
/* VMS INTERFACE DEFINES
* copyright (c) 1980 by Whitesmiths, Ltd.
*/
/* basic parameters
*/
#define FAIL -1
#define NFILES 16
#define NOBLOCK 010000000000
/* codes for flags and access
*/
#define WREAD 0001
#define WWRITE 0002
#define WOPEN 0004
#define WTTY 0010
#define WCR 0020
#define WFIX 0040
#define WDIRT 0100
#define WREMOVE 0200
/* the Whitesmiths VMS control block
*/
typedef struct {
BITS flags;
COUNT bleft;
TEXT *bnext, *pbuf, *rab;
LONG lseek, lact, lend;
} RCB;

View File

@@ -0,0 +1,164 @@
/*****************************************************************************
*
* P R I N T F I N T E R N A L R O U T I N E
* ---------------------------------------------
*
* Routine "_printf" is used to handle all "printf" functions, including
* "sprintf", and "fprintf".
*
* Calling Sequence:
*
* _printf(fd,func,fmt,arg1);
*
* Where:
*
* fd Is the file or string pointer.
* func Is the function to handle output.
* fmt Is the address of the format string.
* arg1 Is the address of the first arg.
*
* Bugs:
*
* It is assumed that args are contiguous starting at "arg1", and that
* all are the same size (int), except for floating point.
*
* "putc" arguments are reversed from UNIX.
*
*****************************************************************************/
char *_ptrbf = 0;
char *_ptrst = 0;
char *__fmt = 0;
_printf(fd,f,fmt,a1) /****************************/
int fd; /* Not really, but ... */
char (*f)(); /* Function pointer */
char *fmt; /* -> Format string */
int *a1; /* -> Arg list */
{ /****************************/
auto char c, *s, adj, *ptr,*p, buf[30];
auto int *adx, x, n, m, width, prec,i, padchar;
double zz, *dblptr;
extern _putstr();
_ptrbf = buf;
adx = a1;
_ptrst = fd;
__fmt = fmt;
while( c = *__fmt++ ){
if(c != '%') (*f)(fd,c);
else { x = *adx++;
if( *__fmt == '-' ){ adj = 'l'; __fmt++; }
else adj = 'r';
padchar = (*__fmt=='0') ? '0' : ' ';
width = __conv();
if( *__fmt == '.'){++__fmt; prec = __conv();}
else prec = 0;
s = 0;
if(*__fmt == 'l' || *__fmt == 'L') __fmt++;
switch ( c = *__fmt++ ) {
case 'D':
case 'd':
_prt1(x); break;
case 'o':
case 'O':
_prnt8(x); break;
case 'x':
case 'X':
_prntx(x); break;
case 'S':
case 's': s=x;
break;
case 'C':
case 'c': *_ptrbf++ = x&0777;
break;
case 'E':
case 'e':
case 'F':
case 'f':
dblptr = adx-1;
zz = *dblptr;
adx =+ 1;
ftoa (zz, buf, prec, c);
prec = 0;
s = buf;
break;
default: (*f)(fd,c);
adx--;
}
if (s == 0)
{*_ptrbf = '\0'; s = buf;}
n = aclenf (s);
n = (prec<n && prec != 0) ? prec : n;
m = width-n;
if (adj == 'r') while (m-- > 0) (*f)(fd,padchar);
while (n--) (*f)(fd,*s++);
while (m-- > 0) (*f)(fd,padchar);
_ptrbf = buf;
}
}
if((*f) == _putstr) (*f)(fd,'\0');
}
_prnt8 (n)
{ /* print in octal */
int p, k, sw;
if (n==0) {*_ptrbf++ = '0'; return;}
sw = 0;
for (p=31; p >= 0; p =- 3)
if ((k = (n>>p)&07) || sw)
{
if (p==31)
k = k & 02;
*_ptrbf++ = '0' + k;
sw = 1;
}
}
_prntx (n)
{
int d,a;
if (a = n>>4)
_prntx ( a & 0xfffffff);
d = n&017;
*_ptrbf++ = d > 9 ? 'A'+d-10 : '0' + d;
}
__conv()
{
auto c,n;
n = 0;
while( ((c = *__fmt++) >= '0') && (c<='9'))
n = n*10+c-'0';
__fmt--;
return(n);
}
_putstr(str,chr)
char chr;
char *str;
{
*_ptrst++ = chr;
return;
}
_prt1(n)
{
int digs[15], *dpt;
dpt = digs;
if (n >= 0)
n = -n;
else
*_ptrbf++ = '-';
for (; n != 0; n = n/10)
*dpt++ = n%10;
if (dpt == digs)
*dpt++ = 0;
while (dpt != digs)
{
--dpt;
*_ptrbf++ = '0' - *dpt;
}
}

View File

@@ -0,0 +1,37 @@
/*********************************************************************
* STRCMP - compares strings
*
* Special version which is case - insensitive.
*
* WORD strcmp(s1,s2)
* BYTE *s1, *s2;
*
* 'strcmp' compares null terminated strings s1 and s2.
* Returns:
* strcmp < 0 if s1<s2
* strcmp = 0 if s1=s2
* strcmp > 0 if s1>s2
*********************************************************************/
#include <portab.h>
WORD _strcmp(s1,s2)
REG BYTE *s1, *s2;
{
REG BYTE a,b;
while (*s1 && *s2)
{
a = _toupper(*s1++);
b = _toupper(*s2++);
if (a > b) return (1);
if (a < b) return (-1);
}
return(0);
}
MLOCAL BYTE _toupper(c)
REG BYTE c;
{
if(c >= 'a' && c <= 'z')
c -= 'a' - 'A';
return(c);
}