[comp.sys.amiga.tech] this got blown out of alt.sources.amiga- so here it is

rminnich@udel.EDU (Ron Minnich) (08/04/88)

Newsgroups: alt.sources.amiga
Subject: version zero of a unix compat library.

Rather than hack perl up to fit the amiga, i hacked this this simple 
library up to support perl. It is not complete, and i expect
to hack a much nicer one for perl v2. when i get a chance. But is
a start, right?
   This is going to alt.sources.amiga due to the fact that 
there is a 6-month delay in comp.sources.amiga.
Note that you must pull some /usr/include files from unix to your machine.
It has been 6 months since i did this but i think you need 
/usr/include/stat.h and /usr/include/time.h. See what you think.
Also some things remain to be done. But the semantics of what is 
in here fits ados to unix correctly (in my opinion).
I really recommend you look at perl. And i will try to get the 
object file size down for perl2.
######no i did not shar it. sorry. #######

/*
 * Revision 1.0  87/12/18  13:04:33  root
 * Initial revision
 * Lattice C 4.01
 * 
 */

#include "EXTERN.h"
#include "perl.h"

#include <signal.h>

stat(name,sbuf)
char *name;
struct stat *sbuf;
{
  static struct FileInfoBlock *info;
  int error;
  unsigned short mode;
  info = calloc(1, sizeof *info);
  if (info == NULL)
    {
      printf("calloc in stat fialed!\n");
      return(-1);
    }
  error = dfind(info,name,0);
#ifdef notdefined
  printf("dfind for :%s:  error %d\n", name, error);
#endif
  if (error < 0)
    goto done;
  /* now the fun begins */
#ifdef notdefined
printf("DET %d\n", info->fib_DirEntryType);
#endif
  sbuf->st_ino = 0;
  mode = info->fib_Protection >> 1;
  mode |= mode | (mode << 3) | (mode << 6);
  mode |= info->fib_DirEntryType > 0 ? S_IFREG : S_IFDIR;
  sbuf->st_mode = mode;
  sbuf->st_nlink = 1;
  sbuf->st_uid = 0;
  sbuf->st_gid = 0;
  sbuf->st_size = info->fib_Size;

  sbuf->st_mtime = info->fib_Date.ds_Days << 22 + info->fib_Date.ds_Minute << 9 
                   + info->fib_Date.ds_Tick;
  sbuf->st_atime = sbuf->st_ctime = sbuf->st_mtime;
/* I thinnk st_blksize is wrong. */
  sbuf->st_blksize = 512;
  sbuf->st_blocks = info->fib_NumBlocks;
done:
  free(info);
  return(error);
}
sleep(x)
int x;
{
  if (x)
    Delay(x*50);
}

/* Unix functions that have no real meaning under ADOS */
getuid(){ return 0; }
geteuid(){ return 0; }
getgid(){ return 0; }
getegid(){ return 0; }
umask(){ return 0; }
chown(){ return 0; }

/* Stuff i haven't done yet */
execl(){ return -1;}
FILE *popen(){ return NULL;}
pclose(){ return -1;}
kill(){ return -1;}
mktemp(){ return -1;}
fork(){ return -1; }
vfork(){ return -1; }
execvp(){ return -1; }
link(){ return -1;}
getpid(){ return 0;}
  
-- 
ron (rminnich@udel.edu)