
#include <sys/types.h>
#include <time.h>

/********************** Function time ************************************/

#ifdef L_time
time_t time(where)
time_t *where;
{
   time_t rv;
   __time(&rv);
   if(where) *where = rv;
   return rv;
}
#endif

/********************** Function lseek ************************************/

#ifdef L_lseek
off_t lseek(fd, posn, where)
int fd;
off_t posn;
int where;
{
   off_t __lseek();
   return __lseek(fd, &posn, where);
}
#endif

/********************** Function getpid ************************************/

#ifdef L_getpid
int getpid()
{
   int ppid;
   return __getpid(&ppid);
}
#endif

/********************** Function getppid ************************************/

#ifdef L_getppid
int getppid()
{
   int ppid;
   __getpid(&ppid);
   return ppid;
}
#endif

/********************** Function getuid ************************************/

#ifdef L_getuid
int getuid()
{
   int euid;
   return __getuid(&euid);
}
#endif

/********************** Function geteuid ************************************/

#ifdef L_geteuid
int geteuid()
{
   int euid;
   __getuid(&euid);
   return euid;
}
#endif

/********************** Function getgid ************************************/

#ifdef L_getgid
int getgid()
{
   int egid;
   return __getgid(&egid);
}
#endif

/********************** Function getegid ************************************/

#ifdef L_getegid
int getegid()
{
   int egid;
   __getgid(&egid);
   return egid;
}
#endif

/********************** Function dup2 ************************************/

#ifdef L_dup2

#include <fcntl.h>

int dup2(ifd, ofd)
int ifd;
{
   return fcntl(ifd, F_DUPFD, ofd);
}
#endif

/********************** Function dup ************************************/

#ifdef L_dup
#include <fcntl.h>
#include <errno.h>

/* This is horribly complicated, there _must_ be a better way! */

#define DUP_MAX_FD 256	/* I know this exists ... can't find it tho :-\ */

int
dup(fd)
int fd;
{
   int nfd;
   extern int errno;
   int oerr = errno;

   errno = 0;
   for(nfd=0; nfd<DUP_MAX_FD; nfd++)
   {
      if( fcntl(nfd, F_GETFD) < 0 )
         break;
   }
   if( nfd == DUP_MAX_FD ) { errno = EMFILE ; return -1; }
   errno = oerr;
   if( fcntl(fd, F_DUPFD, nfd) < 0 )
   {
      if( errno == EINVAL ) errno = EMFILE;
      return -1;
   }
   return nfd;
}
#endif

/********************** Function abort ************************************/

#ifdef L_abort
int abort()
{
   kill(/* SIGABRT */ 6, getpid());	/* Correct one */
   sleep(2);				/* System may just schedule */
   kill(/* SIGKILL */ 9, getpid());	/* Can't trap this! */
   __exit(99);				/* WHAT!! */
}
#endif

/********************** THE END ********************************************/
