Adapted for ANSI C and our pseudo-Posix syscall interface.

This commit is contained in:
dtrg
2007-04-21 23:18:14 +00:00
parent 078faadbf9
commit f33fd63590
37 changed files with 222 additions and 279 deletions

View File

@@ -16,9 +16,12 @@
*
*/
#include <em_abs.h>
#include <pc_err.h>
#include <pc_file.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <em_abs.h>
#include <pc_err.h>
#include <pc_file.h>
/* to make it easier to patch ... */
extern struct file *_curfil;
@@ -85,8 +88,6 @@ extern char **_penvp;
extern char *_hol0();
extern _trp();
extern _exit();
extern int _write();
_catch(erno) unsigned erno; {
register struct errm *ep = &errors[0];
@@ -145,7 +146,7 @@ _catch(erno) unsigned erno; {
p = q;
while (*p)
p++;
if (_write(2,q,(int)(p-q)) < 0)
if (write(2,q,(int)(p-q)) < 0)
;
}
_exit(erno+1);

View File

@@ -18,14 +18,15 @@
/* Author: J.W. Stevenson */
#include <pc_file.h>
#include <pc_err.h>
#include <stdlib.h>
#include <unistd.h>
#include <pc_file.h>
#include <pc_err.h>
extern struct file *_curfil;
extern _trp();
extern _flush();
extern _outcpt();
extern int _close();
_xcls(f) struct file *f; {
@@ -61,7 +62,7 @@ _cls(f) struct file *f; {
return;
#endif
_xcls(f);
if (_close(f->ufd) != 0)
if (close(f->ufd) != 0)
_trp(ECLOSE);
f->flags = 0;
}

View File

@@ -18,8 +18,10 @@
/* Author: J.W. Stevenson */
#include <pc_file.h>
#include <pc_err.h>
#include <stdlib.h>
#include <errno.h>
#include <pc_file.h>
#include <pc_err.h>
extern struct file *_curfil;
extern _trp();

View File

@@ -18,14 +18,13 @@
/* Author: J.W. Stevenson */
#include <pc_file.h>
#include <pc_err.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <pc_file.h>
#include <pc_err.h>
#define EINTR 4
extern int errno;
extern _trp();
extern int _read();
_incpt(f) struct file *f; {
@@ -40,7 +39,7 @@ _incpt(f) struct file *f; {
if (f->count == 0) {
f->ptr = f->bufadr;
for(;;) {
f->count=_read(f->ufd,f->bufadr,f->buflen);
f->count=read(f->ufd,f->bufadr,f->buflen);
if ( f->count<0 ) {
if (errno != EINTR) _trp(EREAD) ;
continue ;

View File

@@ -23,9 +23,6 @@
extern (*_sig())();
extern _catch();
#ifndef CPM
extern int _gtty();
#endif
struct file **_extfl;
int _extflc; /* number of external files */
@@ -63,11 +60,7 @@ _ini(args,c,p,mainlb) char *args,*mainlb; int c; struct file **p; {
f->fname = "OUTPUT";
f->ufd = 1;
f->size = 1;
#ifdef CPM
f->count = 1;
#else
f->count = (_gtty(1,buf) >= 0 ? 1 : PC_BUFLEN);
#endif
f->buflen = f->count;
}
}

View File

@@ -18,8 +18,10 @@
/* Author: J.W. Stevenson */
#include <pc_file.h>
#include <pc_err.h>
#include <stdlib.h>
#include <unistd.h>
#include <pc_file.h>
#include <pc_err.h>
extern struct file **_extfl;
extern int _extflc;
@@ -31,33 +33,27 @@ extern char **_penvp;
extern _cls();
extern _xcls();
extern _trp();
extern int _getpid();
extern int _creat();
extern int _open();
extern int _close();
extern int _unlink();
extern long _lseek();
static int tmpfil() {
static char namebuf[] = "/tmp/plf.xxxxx";
int i; char *p,*q;
i = _getpid();
i = getpid();
p = namebuf;
q = p + 13;
do
*q++ = (i & 07) + '0';
while (i >>= 3);
*q = '\0';
if ((i = _creat(p,0644)) < 0)
if ((i = _creat(p += 4,0644)) < 0)
if ((i = _creat(p += 5,0644)) < 0)
if ((i = creat(p,0644)) < 0)
if ((i = creat(p += 4,0644)) < 0)
if ((i = creat(p += 5,0644)) < 0)
goto error;
if (_close(i) != 0)
if (close(i) != 0)
goto error;
if ((i = _open(p,2)) < 0)
if ((i = open(p,2)) < 0)
goto error;
if (_unlink(p) != 0)
if (remove(p) != 0)
error: _trp(EREWR);
return(i);
}
@@ -77,7 +73,7 @@ static int initfl(descr,sz,f) int descr; int sz; struct file *f; {
f->fname = "LOCAL";
if ((descr & WRBIT) == 0 && (f->flags & 0377) == MAGIC) {
_xcls(f);
if (_lseek(f->ufd,(long)0,0) == -1)
if (lseek(f->ufd,(long)0,0) == -1)
_trp(ERESET);
} else {
_cls(f);

View File

@@ -18,14 +18,13 @@
/* Author: J.W. Stevenson */
#include <pc_file.h>
#include <pc_err.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <pc_file.h>
#include <pc_err.h>
#define EINTR 4
extern int errno;
extern _trp();
extern int _write();
_flush(f) struct file *f; {
int i,n;
@@ -35,7 +34,7 @@ _flush(f) struct file *f; {
if (n <= 0)
return;
f->count = f->buflen;
if ((i = _write(f->ufd,f->bufadr,n)) < 0 && errno == EINTR)
if ((i = write(f->ufd,f->bufadr,n)) < 0 && errno == EINTR)
return;
if (i != n)
_trp(EWRITE);

View File

@@ -18,7 +18,7 @@
/* function perrno:integer; extern; */
extern int errno;
#include <errno.h>
int perrno() {
return(errno);

View File

@@ -18,8 +18,9 @@
/* function uread(fd:integer; var b:buf; n:integer):integer; */
extern int _read();
#include <stdlib.h>
#include <unistd.h>
int uread(fd,b,n) char *b; int fd,n; {
return(_read(fd,b,n));
return(read(fd,b,n));
}

View File

@@ -18,8 +18,9 @@
/* function uwrite(fd:integer; var b:buf; n:integer):integer; */
extern int _write();
#include <stdlib.h>
#include <unistd.h>
int uwrite(fd,b,n) char *b; int fd,n; {
return(_write(fd,b,n));
return(write(fd,b,n));
}