From: Tom London Date: Sat, 20 Jan 1979 03:06:00 +0000 (-0500) Subject: Bell 32V development X-Git-Tag: Bell-32V~333 X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/2c344bd056cbe0e3f9631cf356486d2865a514ac Bell 32V development Work on file usr/src/libc/stdio/fopen.c Co-Authored-By: John Reiser Synthesized-from: 32v --- diff --git a/usr/src/libc/stdio/fopen.c b/usr/src/libc/stdio/fopen.c new file mode 100644 index 0000000000..26ca43e1e8 --- /dev/null +++ b/usr/src/libc/stdio/fopen.c @@ -0,0 +1,36 @@ +#include +#include + +FILE * +fopen(file, mode) +char *file; +register char *mode; +{ + extern int errno; + register f; + register FILE *iop; + extern FILE *_lastbuf; + + for (iop = _iob; iop->_flag&(_IOREAD|_IOWRT); iop++) + if (iop >= _lastbuf) + return(NULL); + if (*mode=='w') + f = creat(file, 0666); + else if (*mode=='a') { + if ((f = open(file, 1)) < 0) { + if (errno == ENOENT) + f = creat(file, 0666); + } + lseek(f, 0L, 2); + } else + f = open(file, 0); + if (f < 0) + return(NULL); + iop->_cnt = 0; + iop->_file = f; + if (*mode != 'r') + iop->_flag |= _IOWRT; + else + iop->_flag |= _IOREAD; + return(iop); +}