Adapted for ANSI C and our pseudo-Posix syscall interface.
This commit is contained in:
parent
b66d66b597
commit
1c83baa702
|
@ -6,6 +6,12 @@
|
||||||
#define LINO_AD 0
|
#define LINO_AD 0
|
||||||
#define FILN_AD 4
|
#define FILN_AD 4
|
||||||
|
|
||||||
|
/* ERANGE conflicts with a symbol in the ANSI C library. */
|
||||||
|
|
||||||
|
#ifdef ERANGE
|
||||||
|
#undef ERANGE
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LINO (*(int *)(_hol0()+LINO_AD))
|
#define LINO (*(int *)(_hol0()+LINO_AD))
|
||||||
#define FILN (*(char **)(_hol0()+FILN_AD))
|
#define FILN (*(char **)(_hol0()+FILN_AD))
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,13 @@
|
||||||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* EBADF conflicts with the ANSI C definition. */
|
||||||
|
|
||||||
|
#ifdef EBADF
|
||||||
|
#undef EBADF
|
||||||
|
#endif
|
||||||
|
|
||||||
#define EARGC 64
|
#define EARGC 64
|
||||||
#define EEXP 65
|
#define EEXP 65
|
||||||
#define ELOG 66
|
#define ELOG 66
|
||||||
|
|
|
@ -21,9 +21,6 @@
|
||||||
|
|
||||||
exa environ
|
exa environ
|
||||||
exa _end
|
exa _end
|
||||||
exa _penvp
|
|
||||||
_penvp
|
|
||||||
bss _EM_PSIZE,0,0
|
|
||||||
|
|
||||||
exp $_m_a_i_n
|
exp $_m_a_i_n
|
||||||
pro $_m_a_i_n,0
|
pro $_m_a_i_n,0
|
||||||
|
@ -31,31 +28,8 @@ _penvp
|
||||||
sim ; ignored
|
sim ; ignored
|
||||||
lal _EM_WSIZE+_EM_PSIZE
|
lal _EM_WSIZE+_EM_PSIZE
|
||||||
loi _EM_PSIZE
|
loi _EM_PSIZE
|
||||||
lae _penvp
|
|
||||||
sti _EM_PSIZE
|
|
||||||
/* Now test if environ is our own environ, or some user defined environ.
|
|
||||||
* First test if environ < _end. This is done for separate I&D systems.
|
|
||||||
*/
|
|
||||||
lae environ
|
|
||||||
lae _end
|
|
||||||
cmp
|
|
||||||
zge *1
|
|
||||||
/* Now environ < end, which means that we can derefence it without trouble
|
|
||||||
* on separate I&D systems.
|
|
||||||
*/
|
|
||||||
lae environ
|
|
||||||
loi 2
|
|
||||||
loc 2
|
|
||||||
loc _EM_WSIZE
|
|
||||||
cii
|
|
||||||
loc 21331 /* == 0x5353 */
|
|
||||||
bne *1
|
|
||||||
/* environ contains the magic value. Assume it's our own environ */
|
|
||||||
lae _penvp
|
|
||||||
loi _EM_PSIZE
|
|
||||||
lae environ
|
lae environ
|
||||||
sti _EM_PSIZE
|
sti _EM_PSIZE
|
||||||
1
|
|
||||||
#if __unix && ! (__em22 || __em24 || __em44)
|
#if __unix && ! (__em22 || __em24 || __em44)
|
||||||
lpi $_ctch_
|
lpi $_ctch_
|
||||||
sig
|
sig
|
||||||
|
@ -87,9 +61,9 @@ _penvp
|
||||||
bra *3
|
bra *3
|
||||||
1
|
1
|
||||||
loc 8
|
loc 8
|
||||||
cal $_getpid
|
cal $getpid
|
||||||
lfr _EM_WSIZE
|
lfr _EM_WSIZE
|
||||||
cal $_kill
|
cal $kill
|
||||||
asp 2*_EM_WSIZE
|
asp 2*_EM_WSIZE
|
||||||
3
|
3
|
||||||
lpi $_ctch_
|
lpi $_ctch_
|
||||||
|
|
|
@ -2,19 +2,9 @@
|
||||||
* environ.c - define the variable environ
|
* environ.c - define the variable environ
|
||||||
*/
|
*/
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
/*
|
|
||||||
* This file defines the variable environ and initializes it with a magic
|
|
||||||
* value. The C run-time start-off routine tests whether the variable
|
|
||||||
* environ is initialized with this value. If it is not, it is assumed
|
|
||||||
* that it is defined by the user. Only two bytes are tested, since we
|
|
||||||
* don't know the endian-ness and alignment restrictions of the machine.
|
|
||||||
* This means that the low-order two-bytes should be equal to the
|
|
||||||
* high-order two-bytes on machines with four-byte pointers. In fact, all
|
|
||||||
* the bytes in the pointer are the same, just in case.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if _EM_PSIZE==2
|
#include <unistd.h>
|
||||||
char **environ = (char **) 0x5353;
|
|
||||||
#else
|
/* Contains storage for the environ variable. */
|
||||||
char **environ = (char **) 0x53535353;
|
|
||||||
#endif
|
char** environ;
|
||||||
|
|
|
@ -3,11 +3,12 @@
|
||||||
*/
|
*/
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sgtty.h>
|
#include <sgtty.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
#define O_RDONLY 0
|
|
||||||
int _open(const char *path, int flags);
|
int _open(const char *path, int flags);
|
||||||
int _write(int d, const char *buf, int nbytes);
|
int _write(int d, const char *buf, int nbytes);
|
||||||
int _read(int d, char *buf, int nbytes);
|
int _read(int d, char *buf, int nbytes);
|
||||||
|
|
|
@ -3,11 +3,10 @@
|
||||||
*/
|
*/
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdlib.h>
|
||||||
#include <stdlib.h>
|
#include <stdio.h>
|
||||||
#include "loc_incl.h"
|
#include <unistd.h>
|
||||||
|
#include "loc_incl.h"
|
||||||
int _close(int d);
|
|
||||||
|
|
||||||
int
|
int
|
||||||
fclose(FILE *fp)
|
fclose(FILE *fp)
|
||||||
|
@ -22,7 +21,7 @@ fclose(FILE *fp)
|
||||||
if (i >= FOPEN_MAX)
|
if (i >= FOPEN_MAX)
|
||||||
return EOF;
|
return EOF;
|
||||||
if (fflush(fp)) retval = EOF;
|
if (fflush(fp)) retval = EOF;
|
||||||
if (_close(fileno(fp))) retval = EOF;
|
if (close(fileno(fp))) retval = EOF;
|
||||||
if ( io_testflag(fp,_IOMYBUF) && fp->_buf )
|
if ( io_testflag(fp,_IOMYBUF) && fp->_buf )
|
||||||
free((void *)fp->_buf);
|
free((void *)fp->_buf);
|
||||||
if (fp != stdin && fp != stdout && fp != stderr)
|
if (fp != stdin && fp != stdout && fp != stderr)
|
||||||
|
|
|
@ -3,12 +3,10 @@
|
||||||
*/
|
*/
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "loc_incl.h"
|
#include <unistd.h>
|
||||||
|
#include "loc_incl.h"
|
||||||
int _write(int d, const char *buf, int nbytes);
|
|
||||||
off_t _lseek(int fildes, off_t offset, int whence);
|
|
||||||
|
|
||||||
int
|
int
|
||||||
fflush(FILE *stream)
|
fflush(FILE *stream)
|
||||||
|
@ -32,7 +30,7 @@ fflush(FILE *stream)
|
||||||
if (stream->_buf && !io_testflag(stream,_IONBF))
|
if (stream->_buf && !io_testflag(stream,_IONBF))
|
||||||
adjust = stream->_count;
|
adjust = stream->_count;
|
||||||
stream->_count = 0;
|
stream->_count = 0;
|
||||||
_lseek(fileno(stream), (off_t) adjust, SEEK_CUR);
|
lseek(fileno(stream), (off_t) adjust, SEEK_CUR);
|
||||||
if (io_testflag(stream, _IOWRITE))
|
if (io_testflag(stream, _IOWRITE))
|
||||||
stream->_flags &= ~(_IOREADING | _IOWRITING);
|
stream->_flags &= ~(_IOREADING | _IOWRITING);
|
||||||
stream->_ptr = stream->_buf;
|
stream->_ptr = stream->_buf;
|
||||||
|
@ -49,12 +47,12 @@ fflush(FILE *stream)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (io_testflag(stream, _IOAPPEND)) {
|
if (io_testflag(stream, _IOAPPEND)) {
|
||||||
if (_lseek(fileno(stream), 0L, SEEK_END) == -1) {
|
if (lseek(fileno(stream), 0L, SEEK_END) == -1) {
|
||||||
stream->_flags |= _IOERR;
|
stream->_flags |= _IOERR;
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c1 = _write(stream->_fd, (char *)stream->_buf, count);
|
c1 = write(stream->_fd, (char *)stream->_buf, count);
|
||||||
|
|
||||||
stream->_count = 0;
|
stream->_count = 0;
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,10 @@
|
||||||
*/
|
*/
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdlib.h>
|
||||||
#include <stdlib.h>
|
#include <stdio.h>
|
||||||
#include "loc_incl.h"
|
#include <unistd.h>
|
||||||
|
#include "loc_incl.h"
|
||||||
int _read(int d, char *buf, int nbytes);
|
|
||||||
|
|
||||||
int
|
int
|
||||||
__fillbuf(register FILE *stream)
|
__fillbuf(register FILE *stream)
|
||||||
|
@ -53,7 +52,7 @@ __fillbuf(register FILE *stream)
|
||||||
stream->_bufsiz = 1;
|
stream->_bufsiz = 1;
|
||||||
}
|
}
|
||||||
stream->_ptr = stream->_buf;
|
stream->_ptr = stream->_buf;
|
||||||
stream->_count = _read(stream->_fd, (char *)stream->_buf, stream->_bufsiz);
|
stream->_count = read(stream->_fd, (char *)stream->_buf, stream->_bufsiz);
|
||||||
|
|
||||||
if (stream->_count <= 0){
|
if (stream->_count <= 0){
|
||||||
if (stream->_count == 0) {
|
if (stream->_count == 0) {
|
||||||
|
|
|
@ -3,15 +3,11 @@
|
||||||
*/
|
*/
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdlib.h>
|
||||||
#include <stdlib.h>
|
#include <stdio.h>
|
||||||
#include "loc_incl.h"
|
#include <unistd.h>
|
||||||
|
#include "loc_incl.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
off_t _lseek(int fildes, off_t offset, int whence);
|
|
||||||
int _write(int d, const char *buf, int nbytes);
|
|
||||||
int _isatty(int d);
|
|
||||||
extern void (*_clean)(void);
|
extern void (*_clean)(void);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -22,7 +18,7 @@ do_write(int d, char *buf, int nbytes)
|
||||||
/* POSIX actually allows write() to return a positive value less
|
/* POSIX actually allows write() to return a positive value less
|
||||||
than nbytes, so loop ...
|
than nbytes, so loop ...
|
||||||
*/
|
*/
|
||||||
while ((c = _write(d, buf, nbytes)) > 0 && c < nbytes) {
|
while ((c = write(d, buf, nbytes)) > 0 && c < nbytes) {
|
||||||
nbytes -= c;
|
nbytes -= c;
|
||||||
buf += c;
|
buf += c;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +37,7 @@ __flushbuf(int c, FILE * stream)
|
||||||
stream->_flags |= _IOWRITING;
|
stream->_flags |= _IOWRITING;
|
||||||
if (!io_testflag(stream, _IONBF)) {
|
if (!io_testflag(stream, _IONBF)) {
|
||||||
if (!stream->_buf) {
|
if (!stream->_buf) {
|
||||||
if (stream == stdout && _isatty(fileno(stdout))) {
|
if (stream == stdout && isatty(fileno(stdout))) {
|
||||||
if (!(stream->_buf =
|
if (!(stream->_buf =
|
||||||
(unsigned char *) malloc(BUFSIZ))) {
|
(unsigned char *) malloc(BUFSIZ))) {
|
||||||
stream->_flags |= _IONBF;
|
stream->_flags |= _IONBF;
|
||||||
|
@ -71,12 +67,12 @@ __flushbuf(int c, FILE * stream)
|
||||||
|
|
||||||
stream->_count = 0;
|
stream->_count = 0;
|
||||||
if (io_testflag(stream, _IOAPPEND)) {
|
if (io_testflag(stream, _IOAPPEND)) {
|
||||||
if (_lseek(fileno(stream), 0L, SEEK_END) == -1) {
|
if (lseek(fileno(stream), 0L, SEEK_END) == -1) {
|
||||||
stream->_flags |= _IOERR;
|
stream->_flags |= _IOERR;
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_write(fileno(stream), &c1, 1) != 1) {
|
if (write(fileno(stream), &c1, 1) != 1) {
|
||||||
stream->_flags |= _IOERR;
|
stream->_flags |= _IOERR;
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +87,7 @@ __flushbuf(int c, FILE * stream)
|
||||||
stream->_count = 0;
|
stream->_count = 0;
|
||||||
|
|
||||||
if (io_testflag(stream, _IOAPPEND)) {
|
if (io_testflag(stream, _IOAPPEND)) {
|
||||||
if (_lseek(fileno(stream), 0L, SEEK_END) == -1) {
|
if (lseek(fileno(stream), 0L, SEEK_END) == -1) {
|
||||||
stream->_flags |= _IOERR;
|
stream->_flags |= _IOERR;
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +106,7 @@ __flushbuf(int c, FILE * stream)
|
||||||
|
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
if (io_testflag(stream, _IOAPPEND)) {
|
if (io_testflag(stream, _IOAPPEND)) {
|
||||||
if (_lseek(fileno(stream), 0L, SEEK_END) == -1) {
|
if (lseek(fileno(stream), 0L, SEEK_END) == -1) {
|
||||||
stream->_flags |= _IOERR;
|
stream->_flags |= _IOERR;
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,18 +3,15 @@
|
||||||
*/
|
*/
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdlib.h>
|
||||||
#include <stdlib.h>
|
#include <stdio.h>
|
||||||
#include "loc_incl.h"
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "loc_incl.h"
|
||||||
|
|
||||||
#define PMODE 0666
|
#define PMODE 0666
|
||||||
|
|
||||||
/* The next 3 defines are true in all UNIX systems known to me.
|
|
||||||
*/
|
|
||||||
#define O_RDONLY 0
|
|
||||||
#define O_WRONLY 1
|
|
||||||
#define O_RDWR 2
|
|
||||||
|
|
||||||
/* Since the O_CREAT flag is not available on all systems, we can't get it
|
/* Since the O_CREAT flag is not available on all systems, we can't get it
|
||||||
* from the standard library. Furthermore, even if we know that <fcntl.h>
|
* from the standard library. Furthermore, even if we know that <fcntl.h>
|
||||||
* contains such a flag, it's not sure whether it can be used, since we
|
* contains such a flag, it's not sure whether it can be used, since we
|
||||||
|
@ -26,18 +23,13 @@
|
||||||
* Another problem is O_APPEND, for which the same holds. When "a"
|
* Another problem is O_APPEND, for which the same holds. When "a"
|
||||||
* open-mode is used, an lseek() to the end is done before every write()
|
* open-mode is used, an lseek() to the end is done before every write()
|
||||||
* system-call.
|
* system-call.
|
||||||
*
|
*
|
||||||
* The O_CREAT, O_TRUNC and O_APPEND given here, are only for convenience.
|
* FIXME dtrg: I'm not sure this is relevant any more. Implementing O_CREAT
|
||||||
* They are not passed to open(), so the values don't have to match a value
|
* and O_APPEND ought to be the job of the syscall library, no? Besides, the
|
||||||
* from the real world. It is enough when they are unique.
|
* code requires valid definitions.
|
||||||
|
*
|
||||||
|
* Remember to fix freopen.c if changing this.
|
||||||
*/
|
*/
|
||||||
#define O_CREAT 0x010
|
|
||||||
#define O_TRUNC 0x020
|
|
||||||
#define O_APPEND 0x040
|
|
||||||
|
|
||||||
int _open(const char *path, int flags);
|
|
||||||
int _creat(const char *path, int mode);
|
|
||||||
int _close(int d);
|
|
||||||
|
|
||||||
FILE *
|
FILE *
|
||||||
fopen(const char *name, const char *mode)
|
fopen(const char *name, const char *mode)
|
||||||
|
@ -89,11 +81,11 @@ fopen(const char *name, const char *mode)
|
||||||
* the file is opened for writing and the open() failed.
|
* the file is opened for writing and the open() failed.
|
||||||
*/
|
*/
|
||||||
if ((rwflags & O_TRUNC)
|
if ((rwflags & O_TRUNC)
|
||||||
|| (((fd = _open(name, rwmode)) < 0)
|
|| (((fd = open(name, rwmode)) < 0)
|
||||||
&& (rwflags & O_CREAT))) {
|
&& (rwflags & O_CREAT))) {
|
||||||
if (((fd = _creat(name, PMODE)) > 0) && flags | _IOREAD) {
|
if (((fd = creat(name, PMODE)) > 0) && flags | _IOREAD) {
|
||||||
(void) _close(fd);
|
(void) close(fd);
|
||||||
fd = _open(name, rwmode);
|
fd = open(name, rwmode);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -101,7 +93,7 @@ fopen(const char *name, const char *mode)
|
||||||
if (fd < 0) return (FILE *)NULL;
|
if (fd < 0) return (FILE *)NULL;
|
||||||
|
|
||||||
if (( stream = (FILE *) malloc(sizeof(FILE))) == NULL ) {
|
if (( stream = (FILE *) malloc(sizeof(FILE))) == NULL ) {
|
||||||
_close(fd);
|
close(fd);
|
||||||
return (FILE *)NULL;
|
return (FILE *)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,26 +3,17 @@
|
||||||
*/
|
*/
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdlib.h>
|
||||||
#include <stdlib.h>
|
#include <stdio.h>
|
||||||
#include "loc_incl.h"
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "loc_incl.h"
|
||||||
|
|
||||||
#define PMODE 0666
|
#define PMODE 0666
|
||||||
|
|
||||||
/* Do not "optimize" this file to use the open with O_CREAT if the file
|
/* Do not "optimize" this file to use the open with O_CREAT if the file
|
||||||
* does not exist. The reason is given in fopen.c.
|
* does not exist. The reason is given in fopen.c.
|
||||||
*/
|
*/
|
||||||
#define O_RDONLY 0
|
|
||||||
#define O_WRONLY 1
|
|
||||||
#define O_RDWR 2
|
|
||||||
|
|
||||||
#define O_CREAT 0x010
|
|
||||||
#define O_TRUNC 0x020
|
|
||||||
#define O_APPEND 0x040
|
|
||||||
|
|
||||||
int _open(const char *path, int flags);
|
|
||||||
int _creat(const char *path, int mode);
|
|
||||||
int _close(int d);
|
|
||||||
|
|
||||||
FILE *
|
FILE *
|
||||||
freopen(const char *name, const char *mode, FILE *stream)
|
freopen(const char *name, const char *mode, FILE *stream)
|
||||||
|
@ -32,7 +23,7 @@ freopen(const char *name, const char *mode, FILE *stream)
|
||||||
int fd, flags = stream->_flags & (_IONBF | _IOFBF | _IOLBF | _IOMYBUF);
|
int fd, flags = stream->_flags & (_IONBF | _IOFBF | _IOLBF | _IOMYBUF);
|
||||||
|
|
||||||
(void) fflush(stream); /* ignore errors */
|
(void) fflush(stream); /* ignore errors */
|
||||||
(void) _close(fileno(stream));
|
(void) close(fileno(stream));
|
||||||
|
|
||||||
switch(*mode++) {
|
switch(*mode++) {
|
||||||
case 'r':
|
case 'r':
|
||||||
|
@ -69,11 +60,11 @@ freopen(const char *name, const char *mode, FILE *stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((rwflags & O_TRUNC)
|
if ((rwflags & O_TRUNC)
|
||||||
|| (((fd = _open(name, rwmode)) < 0)
|
|| (((fd = open(name, rwmode)) < 0)
|
||||||
&& (rwflags & O_CREAT))) {
|
&& (rwflags & O_CREAT))) {
|
||||||
if (((fd = _creat(name, PMODE)) < 0) && flags | _IOREAD) {
|
if (((fd = creat(name, PMODE)) < 0) && flags | _IOREAD) {
|
||||||
(void) _close(fd);
|
(void) close(fd);
|
||||||
fd = _open(name, rwmode);
|
fd = open(name, rwmode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,17 +3,10 @@
|
||||||
*/
|
*/
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
#if (SEEK_CUR != 1) || (SEEK_END != 2) || (SEEK_SET != 0)
|
#include <unistd.h>
|
||||||
#error SEEK_* values are wrong
|
#include "loc_incl.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "loc_incl.h"
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
off_t _lseek(int fildes, off_t offset, int whence);
|
|
||||||
|
|
||||||
int
|
int
|
||||||
fseek(FILE *stream, long int offset, int whence)
|
fseek(FILE *stream, long int offset, int whence)
|
||||||
|
@ -35,7 +28,7 @@ fseek(FILE *stream, long int offset, int whence)
|
||||||
} else /* neither reading nor writing. The buffer must be empty */
|
} else /* neither reading nor writing. The buffer must be empty */
|
||||||
/* EMPTY */ ;
|
/* EMPTY */ ;
|
||||||
|
|
||||||
pos = _lseek(fileno(stream), offset - adjust, whence);
|
pos = lseek(fileno(stream), offset - adjust, whence);
|
||||||
if (io_testflag(stream, _IOREAD) && io_testflag(stream, _IOWRITE))
|
if (io_testflag(stream, _IOREAD) && io_testflag(stream, _IOWRITE))
|
||||||
stream->_flags &= ~(_IOREADING | _IOWRITING);
|
stream->_flags &= ~(_IOREADING | _IOWRITING);
|
||||||
|
|
||||||
|
|
|
@ -3,18 +3,11 @@
|
||||||
*/
|
*/
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
#if (SEEK_CUR != 1) || (SEEK_SET != 0) || (SEEK_END != 2)
|
#include <unistd.h>
|
||||||
#error SEEK_* values are wrong
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "loc_incl.h"
|
#include "loc_incl.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
off_t _lseek(int fildes, off_t offset, int whence);
|
|
||||||
|
|
||||||
long ftell(FILE *stream)
|
long ftell(FILE *stream)
|
||||||
{
|
{
|
||||||
long result;
|
long result;
|
||||||
|
@ -28,7 +21,7 @@ long ftell(FILE *stream)
|
||||||
adjust = stream->_ptr - stream->_buf;
|
adjust = stream->_ptr - stream->_buf;
|
||||||
else adjust = 0;
|
else adjust = 0;
|
||||||
|
|
||||||
result = _lseek(fileno(stream), 0, SEEK_CUR);
|
result = lseek(fileno(stream), 0, SEEK_CUR);
|
||||||
|
|
||||||
if ( result == -1 )
|
if ( result == -1 )
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
*/
|
*/
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
int _unlink(const char *path);
|
#include <unistd.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
remove(const char *filename) {
|
remove(const char *filename) {
|
||||||
return _unlink(filename);
|
return unlink(filename);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
*/
|
*/
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#if !defined(_POSIX_SOURCE)
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
int _link(const char *name1, const char *name2);
|
int _link(const char *name1, const char *name2);
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
*/
|
*/
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <stdio.h>
|
||||||
#include "loc_incl.h"
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
unsigned int _getpid(void);
|
#include "loc_incl.h"
|
||||||
|
|
||||||
FILE *
|
FILE *
|
||||||
tmpfile(void) {
|
tmpfile(void) {
|
||||||
|
@ -17,7 +17,7 @@ tmpfile(void) {
|
||||||
|
|
||||||
if (!name) {
|
if (!name) {
|
||||||
name = name_buffer + strlen(name_buffer);
|
name = name_buffer + strlen(name_buffer);
|
||||||
name = _i_compute(_getpid(), 10, name, 5);
|
name = _i_compute(getpid(), 10, name, 5);
|
||||||
*name = '\0';
|
*name = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
*/
|
*/
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <stdio.h>
|
||||||
#include "loc_incl.h"
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
unsigned int _getpid(void);
|
#include "loc_incl.h"
|
||||||
|
|
||||||
char *
|
char *
|
||||||
tmpnam(char *s) {
|
tmpnam(char *s) {
|
||||||
|
@ -17,7 +17,7 @@ tmpnam(char *s) {
|
||||||
|
|
||||||
if (!name) {
|
if (!name) {
|
||||||
name = name_buffer + strlen(name_buffer);
|
name = name_buffer + strlen(name_buffer);
|
||||||
name = _i_compute(_getpid(), 10, name, 5);
|
name = _i_compute(getpid(), 10, name, 5);
|
||||||
*name++ = '.';
|
*name++ = '.';
|
||||||
*name = '\0';
|
*name = '\0';
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
double
|
double
|
||||||
atof(const char *nptr)
|
(atof)(const char *nptr)
|
||||||
{
|
{
|
||||||
double d;
|
double d;
|
||||||
int e = errno;
|
int e = errno;
|
||||||
|
|
|
@ -4,16 +4,15 @@
|
||||||
*/
|
*/
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdlib.h>
|
||||||
#include <stdlib.h>
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#define NEXITS 32
|
#define NEXITS 32
|
||||||
|
|
||||||
void (*__functab[NEXITS])(void);
|
void (*__functab[NEXITS])(void);
|
||||||
int __funccnt = 0;
|
int __funccnt = 0;
|
||||||
|
|
||||||
extern void _exit(int);
|
|
||||||
|
|
||||||
/* only flush output buffers when necessary */
|
/* only flush output buffers when necessary */
|
||||||
int (*_clean)(void) = NULL;
|
int (*_clean)(void) = NULL;
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,13 @@
|
||||||
*/
|
*/
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
extern const char **_penvp;
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
getenv(const char *name)
|
getenv(const char *name)
|
||||||
{
|
{
|
||||||
register const char **v = _penvp;
|
register char **v = environ;
|
||||||
register const char *p, *q;
|
register const char *p, *q;
|
||||||
|
|
||||||
if (v == NULL || name == NULL)
|
if (v == NULL || name == NULL)
|
||||||
|
|
|
@ -23,11 +23,12 @@
|
||||||
#ifdef SYSTEM
|
#ifdef SYSTEM
|
||||||
#include <system.h>
|
#include <system.h>
|
||||||
#define SBRK sys_break
|
#define SBRK sys_break
|
||||||
|
extern void *SBRK(int incr);
|
||||||
#else
|
#else
|
||||||
#define SBRK _sbrk
|
#include <unistd.h>
|
||||||
|
#define SBRK sbrk
|
||||||
#define ILL_BREAK (void *)(-1) /* funny failure value */
|
#define ILL_BREAK (void *)(-1) /* funny failure value */
|
||||||
#endif
|
#endif
|
||||||
extern void *SBRK(int incr);
|
|
||||||
#ifdef STORE
|
#ifdef STORE
|
||||||
#define MAX_STORE 32
|
#define MAX_STORE 32
|
||||||
private do_free(mallink *ml), sell_out(void);
|
private do_free(mallink *ml), sell_out(void);
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#define CHAR_SHIFT 8
|
#define CHAR_SHIFT 8
|
||||||
|
|
||||||
int
|
int
|
||||||
mblen(const char *s, size_t n)
|
(mblen)(const char *s, size_t n)
|
||||||
{
|
{
|
||||||
if (s == (const char *)NULL) return 0; /* no state dependent codings */
|
if (s == (const char *)NULL) return 0; /* no state dependent codings */
|
||||||
if (n <= 0) return 0;
|
if (n <= 0) return 0;
|
||||||
|
|
|
@ -7,11 +7,6 @@
|
||||||
|
|
||||||
#if defined(__BSD4_2)
|
#if defined(__BSD4_2)
|
||||||
|
|
||||||
struct timeval {
|
|
||||||
long tv_sec; /* seconds */
|
|
||||||
long tv_usec; /* and microseconds */
|
|
||||||
};
|
|
||||||
|
|
||||||
#define RUSAGE_SELF 0
|
#define RUSAGE_SELF 0
|
||||||
#define RUSAGE_CHILDREN -1
|
#define RUSAGE_CHILDREN -1
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
char *
|
char *
|
||||||
ctime(const time_t *timer)
|
(ctime)(const time_t *timer)
|
||||||
{
|
{
|
||||||
return asctime(localtime(timer));
|
return asctime(localtime(timer));
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,17 +10,7 @@
|
||||||
|
|
||||||
#if defined(__BSD4_2)
|
#if defined(__BSD4_2)
|
||||||
|
|
||||||
struct timeval {
|
extern int _gettimeofday(struct timeval *tp, struct timezone *tzp);
|
||||||
long tv_sec; /* seconds */
|
|
||||||
long tv_usec; /* and microseconds */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct timezone {
|
|
||||||
int tz_minuteswest; /* minutes west of Greenwich */
|
|
||||||
int tz_dsttime; /* type of dst correction */
|
|
||||||
};
|
|
||||||
|
|
||||||
int _gettimeofday(struct timeval *tp, struct timezone *tzp);
|
|
||||||
|
|
||||||
#elif !defined(_POSIX_SOURCE) && !defined(__USG)
|
#elif !defined(_POSIX_SOURCE) && !defined(__USG)
|
||||||
#if !defined(_MINIX) /* MINIX has no ftime() */
|
#if !defined(_MINIX) /* MINIX has no ftime() */
|
||||||
|
|
|
@ -3,34 +3,22 @@
|
||||||
*/
|
*/
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
#if defined(__BSD4_2)
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <sys/time.h>
|
||||||
/*
|
#include <time.h>
|
||||||
* Structure returned by gettimeofday(2) system call,
|
#include <ack/config.h>
|
||||||
* and used in other calls.
|
|
||||||
*/
|
|
||||||
struct timeval {
|
|
||||||
long tv_sec; /* seconds */
|
|
||||||
long tv_usec; /* and microseconds */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct timezone {
|
#ifndef ACKCONF_TIME_IS_A_SYSCALL
|
||||||
int tz_minuteswest; /* minutes west of Greenwich */
|
|
||||||
int tz_dsttime; /* type of dst correction */
|
|
||||||
};
|
|
||||||
|
|
||||||
int _gettimeofday(struct timeval *tp, struct timezone *tzp);
|
|
||||||
|
|
||||||
time_t
|
time_t
|
||||||
time(time_t *timer)
|
time(time_t *timer)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
struct timezone tz;
|
struct timezone tz;
|
||||||
_gettimeofday(&tv, &tz);
|
gettimeofday(&tv, &tz);
|
||||||
|
|
||||||
if (timer) *timer = tv.tv_sec;
|
if (timer) *timer = tv.tv_sec;
|
||||||
return tv.tv_sec;
|
return tv.tv_sec;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
/* Assume time() is a system call */ /* ??? */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -13,23 +13,61 @@
|
||||||
#include <em_abs.h>
|
#include <em_abs.h>
|
||||||
#include <m2_traps.h>
|
#include <m2_traps.h>
|
||||||
|
|
||||||
|
static const char signals_list[] = {
|
||||||
|
#ifdef SIGHUP
|
||||||
|
SIGHUP,
|
||||||
|
#endif
|
||||||
|
#ifdef SIGINT
|
||||||
|
SIGINT,
|
||||||
|
#endif
|
||||||
|
#ifdef SIGQUIT
|
||||||
|
SIGQUIT,
|
||||||
|
#endif
|
||||||
|
#ifdef SIGTRAP
|
||||||
|
SIGTRAP,
|
||||||
|
#endif
|
||||||
|
#ifdef SIGIOT
|
||||||
|
SIGIOT,
|
||||||
|
#endif
|
||||||
|
#ifdef SIGEMT
|
||||||
|
SIGEMT,
|
||||||
|
#endif
|
||||||
|
#ifdef SIGFPE
|
||||||
|
SIGFPE,
|
||||||
|
#endif
|
||||||
|
#ifdef SIGBUS
|
||||||
|
SIGBUS,
|
||||||
|
#endif
|
||||||
|
#ifdef SIGSEGV
|
||||||
|
SIGSEGV,
|
||||||
|
#endif
|
||||||
|
#ifdef SIGPIPE
|
||||||
|
SIGPIPE,
|
||||||
|
#endif
|
||||||
|
#ifdef SIGALRM
|
||||||
|
SIGALRM,
|
||||||
|
#endif
|
||||||
|
#ifdef SIGTERM
|
||||||
|
SIGTERM,
|
||||||
|
#endif
|
||||||
|
-1
|
||||||
|
};
|
||||||
|
|
||||||
/* map unix signals onto EM traps */
|
/* map unix signals onto EM traps */
|
||||||
init()
|
void init(void)
|
||||||
{
|
{
|
||||||
sigtrp(M2_UNIXSIG, SIGHUP);
|
const char* p = signals_list;
|
||||||
sigtrp(M2_UNIXSIG, SIGINT);
|
do {
|
||||||
sigtrp(M2_UNIXSIG, SIGQUIT);
|
int i = *p++;
|
||||||
|
if (i == -1)
|
||||||
|
break;
|
||||||
|
sigtrp(M2_UNIXSIG, i);
|
||||||
|
} while (1);
|
||||||
|
|
||||||
sigtrp(EILLINS, SIGILL);
|
sigtrp(EILLINS, SIGILL);
|
||||||
sigtrp(M2_UNIXSIG, SIGTRAP);
|
#ifdef SIGSYS
|
||||||
sigtrp(M2_UNIXSIG, SIGIOT);
|
|
||||||
sigtrp(M2_UNIXSIG, SIGEMT);
|
|
||||||
sigtrp(M2_UNIXSIG, SIGFPE);
|
|
||||||
sigtrp(M2_UNIXSIG, SIGBUS);
|
|
||||||
sigtrp(M2_UNIXSIG, SIGSEGV);
|
|
||||||
sigtrp(EBADMON, SIGSYS);
|
sigtrp(EBADMON, SIGSYS);
|
||||||
sigtrp(M2_UNIXSIG, SIGPIPE);
|
#endif
|
||||||
sigtrp(M2_UNIXSIG, SIGALRM);
|
|
||||||
sigtrp(M2_UNIXSIG, SIGTERM);
|
|
||||||
}
|
}
|
||||||
#if defined(__em22) || defined(__em24) || defined(__em44)
|
#if defined(__em22) || defined(__em24) || defined(__em44)
|
||||||
killbss()
|
killbss()
|
||||||
|
|
|
@ -16,9 +16,12 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <em_abs.h>
|
#include <stdlib.h>
|
||||||
#include <pc_err.h>
|
#include <errno.h>
|
||||||
#include <pc_file.h>
|
#include <unistd.h>
|
||||||
|
#include <em_abs.h>
|
||||||
|
#include <pc_err.h>
|
||||||
|
#include <pc_file.h>
|
||||||
|
|
||||||
/* to make it easier to patch ... */
|
/* to make it easier to patch ... */
|
||||||
extern struct file *_curfil;
|
extern struct file *_curfil;
|
||||||
|
@ -85,8 +88,6 @@ extern char **_penvp;
|
||||||
|
|
||||||
extern char *_hol0();
|
extern char *_hol0();
|
||||||
extern _trp();
|
extern _trp();
|
||||||
extern _exit();
|
|
||||||
extern int _write();
|
|
||||||
|
|
||||||
_catch(erno) unsigned erno; {
|
_catch(erno) unsigned erno; {
|
||||||
register struct errm *ep = &errors[0];
|
register struct errm *ep = &errors[0];
|
||||||
|
@ -145,7 +146,7 @@ _catch(erno) unsigned erno; {
|
||||||
p = q;
|
p = q;
|
||||||
while (*p)
|
while (*p)
|
||||||
p++;
|
p++;
|
||||||
if (_write(2,q,(int)(p-q)) < 0)
|
if (write(2,q,(int)(p-q)) < 0)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
_exit(erno+1);
|
_exit(erno+1);
|
||||||
|
|
|
@ -18,14 +18,15 @@
|
||||||
|
|
||||||
/* Author: J.W. Stevenson */
|
/* Author: J.W. Stevenson */
|
||||||
|
|
||||||
#include <pc_file.h>
|
#include <stdlib.h>
|
||||||
#include <pc_err.h>
|
#include <unistd.h>
|
||||||
|
#include <pc_file.h>
|
||||||
|
#include <pc_err.h>
|
||||||
|
|
||||||
extern struct file *_curfil;
|
extern struct file *_curfil;
|
||||||
extern _trp();
|
extern _trp();
|
||||||
extern _flush();
|
extern _flush();
|
||||||
extern _outcpt();
|
extern _outcpt();
|
||||||
extern int _close();
|
|
||||||
|
|
||||||
_xcls(f) struct file *f; {
|
_xcls(f) struct file *f; {
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@ _cls(f) struct file *f; {
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
_xcls(f);
|
_xcls(f);
|
||||||
if (_close(f->ufd) != 0)
|
if (close(f->ufd) != 0)
|
||||||
_trp(ECLOSE);
|
_trp(ECLOSE);
|
||||||
f->flags = 0;
|
f->flags = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,10 @@
|
||||||
|
|
||||||
/* Author: J.W. Stevenson */
|
/* Author: J.W. Stevenson */
|
||||||
|
|
||||||
#include <pc_file.h>
|
#include <stdlib.h>
|
||||||
#include <pc_err.h>
|
#include <errno.h>
|
||||||
|
#include <pc_file.h>
|
||||||
|
#include <pc_err.h>
|
||||||
|
|
||||||
extern struct file *_curfil;
|
extern struct file *_curfil;
|
||||||
extern _trp();
|
extern _trp();
|
||||||
|
|
|
@ -18,14 +18,13 @@
|
||||||
|
|
||||||
/* Author: J.W. Stevenson */
|
/* Author: J.W. Stevenson */
|
||||||
|
|
||||||
#include <pc_file.h>
|
#include <stdlib.h>
|
||||||
#include <pc_err.h>
|
#include <errno.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <pc_file.h>
|
||||||
|
#include <pc_err.h>
|
||||||
|
|
||||||
#define EINTR 4
|
|
||||||
|
|
||||||
extern int errno;
|
|
||||||
extern _trp();
|
extern _trp();
|
||||||
extern int _read();
|
|
||||||
|
|
||||||
_incpt(f) struct file *f; {
|
_incpt(f) struct file *f; {
|
||||||
|
|
||||||
|
@ -40,7 +39,7 @@ _incpt(f) struct file *f; {
|
||||||
if (f->count == 0) {
|
if (f->count == 0) {
|
||||||
f->ptr = f->bufadr;
|
f->ptr = f->bufadr;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
f->count=_read(f->ufd,f->bufadr,f->buflen);
|
f->count=read(f->ufd,f->bufadr,f->buflen);
|
||||||
if ( f->count<0 ) {
|
if ( f->count<0 ) {
|
||||||
if (errno != EINTR) _trp(EREAD) ;
|
if (errno != EINTR) _trp(EREAD) ;
|
||||||
continue ;
|
continue ;
|
||||||
|
|
|
@ -23,9 +23,6 @@
|
||||||
|
|
||||||
extern (*_sig())();
|
extern (*_sig())();
|
||||||
extern _catch();
|
extern _catch();
|
||||||
#ifndef CPM
|
|
||||||
extern int _gtty();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct file **_extfl;
|
struct file **_extfl;
|
||||||
int _extflc; /* number of external files */
|
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->fname = "OUTPUT";
|
||||||
f->ufd = 1;
|
f->ufd = 1;
|
||||||
f->size = 1;
|
f->size = 1;
|
||||||
#ifdef CPM
|
|
||||||
f->count = 1;
|
f->count = 1;
|
||||||
#else
|
|
||||||
f->count = (_gtty(1,buf) >= 0 ? 1 : PC_BUFLEN);
|
|
||||||
#endif
|
|
||||||
f->buflen = f->count;
|
f->buflen = f->count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,10 @@
|
||||||
|
|
||||||
/* Author: J.W. Stevenson */
|
/* Author: J.W. Stevenson */
|
||||||
|
|
||||||
#include <pc_file.h>
|
#include <stdlib.h>
|
||||||
#include <pc_err.h>
|
#include <unistd.h>
|
||||||
|
#include <pc_file.h>
|
||||||
|
#include <pc_err.h>
|
||||||
|
|
||||||
extern struct file **_extfl;
|
extern struct file **_extfl;
|
||||||
extern int _extflc;
|
extern int _extflc;
|
||||||
|
@ -31,33 +33,27 @@ extern char **_penvp;
|
||||||
extern _cls();
|
extern _cls();
|
||||||
extern _xcls();
|
extern _xcls();
|
||||||
extern _trp();
|
extern _trp();
|
||||||
extern int _getpid();
|
|
||||||
extern int _creat();
|
|
||||||
extern int _open();
|
|
||||||
extern int _close();
|
|
||||||
extern int _unlink();
|
|
||||||
extern long _lseek();
|
|
||||||
|
|
||||||
static int tmpfil() {
|
static int tmpfil() {
|
||||||
static char namebuf[] = "/tmp/plf.xxxxx";
|
static char namebuf[] = "/tmp/plf.xxxxx";
|
||||||
int i; char *p,*q;
|
int i; char *p,*q;
|
||||||
|
|
||||||
i = _getpid();
|
i = getpid();
|
||||||
p = namebuf;
|
p = namebuf;
|
||||||
q = p + 13;
|
q = p + 13;
|
||||||
do
|
do
|
||||||
*q++ = (i & 07) + '0';
|
*q++ = (i & 07) + '0';
|
||||||
while (i >>= 3);
|
while (i >>= 3);
|
||||||
*q = '\0';
|
*q = '\0';
|
||||||
if ((i = _creat(p,0644)) < 0)
|
if ((i = creat(p,0644)) < 0)
|
||||||
if ((i = _creat(p += 4,0644)) < 0)
|
if ((i = creat(p += 4,0644)) < 0)
|
||||||
if ((i = _creat(p += 5,0644)) < 0)
|
if ((i = creat(p += 5,0644)) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
if (_close(i) != 0)
|
if (close(i) != 0)
|
||||||
goto error;
|
goto error;
|
||||||
if ((i = _open(p,2)) < 0)
|
if ((i = open(p,2)) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
if (_unlink(p) != 0)
|
if (remove(p) != 0)
|
||||||
error: _trp(EREWR);
|
error: _trp(EREWR);
|
||||||
return(i);
|
return(i);
|
||||||
}
|
}
|
||||||
|
@ -77,7 +73,7 @@ static int initfl(descr,sz,f) int descr; int sz; struct file *f; {
|
||||||
f->fname = "LOCAL";
|
f->fname = "LOCAL";
|
||||||
if ((descr & WRBIT) == 0 && (f->flags & 0377) == MAGIC) {
|
if ((descr & WRBIT) == 0 && (f->flags & 0377) == MAGIC) {
|
||||||
_xcls(f);
|
_xcls(f);
|
||||||
if (_lseek(f->ufd,(long)0,0) == -1)
|
if (lseek(f->ufd,(long)0,0) == -1)
|
||||||
_trp(ERESET);
|
_trp(ERESET);
|
||||||
} else {
|
} else {
|
||||||
_cls(f);
|
_cls(f);
|
||||||
|
|
|
@ -18,14 +18,13 @@
|
||||||
|
|
||||||
/* Author: J.W. Stevenson */
|
/* Author: J.W. Stevenson */
|
||||||
|
|
||||||
#include <pc_file.h>
|
#include <stdlib.h>
|
||||||
#include <pc_err.h>
|
#include <errno.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <pc_file.h>
|
||||||
|
#include <pc_err.h>
|
||||||
|
|
||||||
#define EINTR 4
|
|
||||||
|
|
||||||
extern int errno;
|
|
||||||
extern _trp();
|
extern _trp();
|
||||||
extern int _write();
|
|
||||||
|
|
||||||
_flush(f) struct file *f; {
|
_flush(f) struct file *f; {
|
||||||
int i,n;
|
int i,n;
|
||||||
|
@ -35,7 +34,7 @@ _flush(f) struct file *f; {
|
||||||
if (n <= 0)
|
if (n <= 0)
|
||||||
return;
|
return;
|
||||||
f->count = f->buflen;
|
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;
|
return;
|
||||||
if (i != n)
|
if (i != n)
|
||||||
_trp(EWRITE);
|
_trp(EWRITE);
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
/* function perrno:integer; extern; */
|
/* function perrno:integer; extern; */
|
||||||
|
|
||||||
extern int errno;
|
#include <errno.h>
|
||||||
|
|
||||||
int perrno() {
|
int perrno() {
|
||||||
return(errno);
|
return(errno);
|
||||||
|
|
|
@ -18,8 +18,9 @@
|
||||||
|
|
||||||
/* function uread(fd:integer; var b:buf; n:integer):integer; */
|
/* 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; {
|
int uread(fd,b,n) char *b; int fd,n; {
|
||||||
return(_read(fd,b,n));
|
return(read(fd,b,n));
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,9 @@
|
||||||
|
|
||||||
/* function uwrite(fd:integer; var b:buf; n:integer):integer; */
|
/* 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; {
|
int uwrite(fd,b,n) char *b; int fd,n; {
|
||||||
return(_write(fd,b,n));
|
return(write(fd,b,n));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue