#define NULL 0
#endif
-int close(int d);
+int _close(int d);
int
closedir(register DIR *dirp) /* stream from opendir */
fd = dirp->dd_fd; /* bug fix thanks to R. Salz */
free( (pointer)dirp->dd_buf );
free( (pointer)dirp );
- return close( fd );
+ return _close( fd );
}
#include <stdlib.h>
#include "../stdio/loc_incl.h"
-int lseek(int d, int offset, int whence);
-
FILE *
fdopen(int fd, const char *mode)
{
extern int _getdents(); /* actual system call */
#endif
-extern int fstat(int fd, struct stat *buf);
-extern off_t lseek(int d, int offset, int whence);
+extern int _fstat(int fd, struct stat *buf);
+extern off_t _lseek(int d, int offset, int whence);
#ifndef DIRBLKSIZ
#define DIRBLKSIZ 4096 /* directory file read buffer size */
return -1;
}
- if ( fstat( fildes, &statb ) != 0 )
+ if ( _fstat( fildes, &statb ) != 0 )
return -1; /* errno set by fstat() */
if ( !S_ISDIR( statb.st_mode ) )
return -1;
}
- if ( (offset = lseek( fildes, (off_t)0, SEEK_CUR )) < 0 )
+ if ( (offset = _lseek( fildes, (off_t)0, SEEK_CUR )) < 0 )
return -1; /* errno set by lseek() */
#ifdef BFS /* no telling what remote hosts do */
typedef long off_t;
#endif
-off_t lseek(int d, off_t offset, int whence);
-int read(int d, char *buf, int nbytes);
-int close(int d);
+off_t _lseek(int d, off_t offset, int whence);
+int _read(int d, char *buf, int nbytes);
+int _close(int d);
#define RBUFSIZE 1024
static char _gr_file[] = "/etc/group";
setgrent(void)
{
if (_gfd >= 0)
- lseek(_gfd, 0L, 0);
+ _lseek(_gfd, 0L, 0);
else
_gfd = open(_gr_file, O_RDONLY);
endgrent(void)
{
if (_gfd >= 0)
- close(_gfd);
+ _close(_gfd);
_gfd = -1;
_bufcnt = 0;
_buf = _grbuf;
do {
if (--_bufcnt <= 0){
- if ((_bufcnt = read(_gfd, _buffer, RBUFSIZE)) <= 0)
+ if ((_bufcnt = _read(_gfd, _buffer, RBUFSIZE)) <= 0)
return 0;
else
_pnt = _buffer;
#include <sgtty.h>
#define O_RDONLY 0
-int open(const char *path, int flags);
-int write(int d, const char *buf, int nbytes);
-int read(int d, char *buf, int nbytes);
-int close(int d);
+int _open(const char *path, int flags);
+int _write(int d, const char *buf, int nbytes);
+int _read(int d, char *buf, int nbytes);
+int _close(int d);
-int stty(int, struct sgttyb *);
-int gtty(int, struct sgttyb *);
+int _stty(int, struct sgttyb *);
+int _gtty(int, struct sgttyb *);
char *
getpass(const char *prompt)
int fd;
void (*savesig)(int);
- if ((fd = open("/dev/tty", O_RDONLY)) < 0) fd = 0;
+ if ((fd = _open("/dev/tty", O_RDONLY)) < 0) fd = 0;
savesig = signal(SIGINT, SIG_IGN);
- write(2, prompt, strlen(prompt));
- gtty(fd, &tty);
+ _write(2, prompt, strlen(prompt));
+ _gtty(fd, &tty);
ttysave = tty;
tty.sg_flags &= ~ECHO;
- stty(fd, &tty);
- i = read(fd, pwdbuf, 9);
+ _stty(fd, &tty);
+ i = _read(fd, pwdbuf, 9);
while (pwdbuf[i - 1] != '\n')
- read(fd, &pwdbuf[i - 1], 1);
+ _read(fd, &pwdbuf[i - 1], 1);
pwdbuf[i - 1] = '\0';
- stty(fd, &ttysave);
- write(2, "\n", 1);
- if (fd != 0) close(fd);
+ _stty(fd, &ttysave);
+ _write(2, "\n", 1);
+ if (fd != 0) _close(fd);
signal(SIGINT, savesig);
return(pwdbuf);
}
#include <sys/stat.h>
#include <dirent.h>
-#ifdef BSD_SYSV
-#define open _open /* avoid emulation overhead */
-#endif
-
typedef void *pointer; /* (void *) if you have it */
-extern int open(const char *path, int flags, int mode);
-extern int close(int d);
-extern int fstat(int fd, struct stat *buf);
+extern int _open(const char *path, int flags, int mode);
+extern int _close(int d);
+extern int _fstat(int fd, struct stat *buf);
#ifndef NULL
#define NULL 0
register int fd; /* file descriptor for read */
struct stat sbuf; /* result of fstat() */
- if ( (fd = open( dirname, O_RDONLY, 0 )) < 0 )
+ if ( (fd = _open( dirname, O_RDONLY, 0 )) < 0 )
return NULL; /* errno set by open() */
- if ( fstat( fd, &sbuf ) != 0 || !S_ISDIR( sbuf.st_mode ) )
+ if ( _fstat( fd, &sbuf ) != 0 || !S_ISDIR( sbuf.st_mode ) )
{
- (void)close( fd );
+ (void)_close( fd );
errno = ENOTDIR;
return NULL; /* not a directory */
}
if ( dirp != NULL )
free( (pointer)dirp );
- (void)close( fd );
+ (void)_close( fd );
errno = serrno;
return NULL; /* not enough memory */
}
#endif /* __BSD4_2 */
#include "../stdio/loc_incl.h"
-int close(int d);
-int dup2(int oldd, int newd); /* not present in System 5 */
-int execl(const char *name, ... );
-int fork(void);
-int pipe(int fildes[2]);
-int wait(wait_arg *status);
+int _close(int d);
+int _dup2(int oldd, int newd); /* not present in System 5 */
+int _execl(const char *name, ... );
+int _fork(void);
+int _pipe(int fildes[2]);
+int _wait(wait_arg *status);
void _exit(int status);
static int pids[20];
int pid;
if (Xtype == 2 ||
- pipe(piped) < 0 ||
- (pid = fork()) < 0) return 0;
+ _pipe(piped) < 0 ||
+ (pid = _fork()) < 0) return 0;
if (pid == 0) {
/* child */
register int *p;
for (p = pids; p < &pids[ FOPEN_MAX]; p++) {
- if (*p) close(p - pids);
+ if (*p) _close(p - pids);
}
- close(piped[Xtype]);
- dup2(piped[!Xtype], !Xtype);
- close(piped[!Xtype]);
- execl("/bin/sh", "sh", "-c", command, (char *) 0);
+ _close(piped[Xtype]);
+ _dup2(piped[!Xtype], !Xtype);
+ _close(piped[!Xtype]);
+ _execl("/bin/sh", "sh", "-c", command, (char *) 0);
_exit(127); /* like system() ??? */
}
pids[piped[Xtype]] = pid;
- close(piped[!Xtype]);
+ _close(piped[!Xtype]);
return fdopen(piped[Xtype], type);
}
void (*quitsave)(int) = signal(SIGQUIT, SIG_IGN);
fclose(stream);
- while ((wret = wait(&status)) != -1) {
+ while ((wret = _wait(&status)) != -1) {
if (wret == pids[fd]) break;
}
if (wret == -1) ret_val = -1;
}
#if defined(__USG)
-int
-dup2(int oldd, int newd)
+int _dup(int fildes);
+
+static int
+_dup2(int oldd, int newd)
{
int i = 0, fd, tmp;
int fdbuf[_NFILES];
/* ignore the error on the close() */
- tmp = errno; (void) close(newd); errno = tmp;
- while ((fd = dup(oldd)) != newd) {
+ tmp = errno; (void) _close(newd); errno = tmp;
+ while ((fd = _dup(oldd)) != newd) {
if (fd == -1) break;
fdbuf[i++] = fd;
}
tmp = errno;
while (--i >= 0) {
- close(fdbuf[i]);
+ _close(fdbuf[i]);
}
errno = tmp;
return -(fd == -1);
#include <sys/types.h>
#include <dirent.h>
-extern off_t lseek(int d, int offset, int whence);
+extern off_t _lseek(int d, int offset, int whence);
#ifndef NULL
#define NULL 0
}
dirp->dd_loc = dirp->dd_size = 0; /* invalidate buffer */
- (void)lseek( dirp->dd_fd, (off_t)0, SEEK_SET ); /* may set errno */
+ (void)_lseek( dirp->dd_fd, (off_t)0, SEEK_SET ); /* may set errno */
}
#include <sys/types.h>
#include <dirent.h>
-extern off_t lseek(int d, int offset, int whence);
+extern off_t _lseek(int d, int offset, int whence);
#ifndef NULL
#define NULL 0
dirp->dd_loc = dirp->dd_size = 0;
- if ( lseek( dirp->dd_fd, (off_t)0, SEEK_SET )
+ if ( _lseek( dirp->dd_fd, (off_t)0, SEEK_SET )
!= 0
)
return; /* errno already set (EBADF) */
#include <signal.h>
#include <setjmp.h>
-int alarm(int n);
-void pause(void);
+int _alarm(int n);
+void _pause(void);
static jmp_buf setjmpbuf;
if (n <= 0) return;
if (setjmp(setjmpbuf)) {
signal(SIGALRM, oldsig);
- alarm(oldalarm);
+ _alarm(oldalarm);
return;
}
- oldalarm = alarm(5000); /* Who cares how long, as long
+ oldalarm = _alarm(5000); /* Who cares how long, as long
* as it is long enough
*/
if (oldalarm > n) oldalarm -= n;
oldalarm = 1;
}
oldsig = signal(SIGALRM, alfun);
- alarm(n);
+ _alarm(n);
for (;;) {
/* allow for other handlers ... */
- pause();
+ _pause();
}
}
#include <sys/types.h>
#include <dirent.h>
-extern off_t lseek(int d, int offset, int whence);
+extern off_t _lseek(int d, int offset, int whence);
#ifndef SEEK_CUR
#define SEEK_CUR 1
if ( dirp->dd_loc < dirp->dd_size ) /* valid index */
return ((struct dirent *)&dirp->dd_buf[dirp->dd_loc])->d_off;
else /* beginning of next directory block */
- return lseek( dirp->dd_fd, (off_t)0, SEEK_CUR );
+ return _lseek( dirp->dd_fd, (off_t)0, SEEK_CUR );
}