home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / fish / telecom / uucp_442 / src / dmail / compat.c < prev    next >
C/C++ Source or Header  |  1990-12-09  |  2KB  |  146 lines

  1.  
  2. /*
  3.  *  COMPAT.C
  4.  *
  5.  *  $Header: Beta:src/uucp/src/dmail/RCS/compat.c,v 1.1 90/02/02 12:03:31 dillon Exp Locker: dillon $
  6.  *
  7.  *  (C) Copyright 1985-1990 by Matthew Dillon,  All Rights Reserved.
  8.  *
  9.  */
  10.  
  11. #include <stdio.h>
  12. #include <pwd.h>
  13. #include <sys/stat.h>
  14. #include "config.h"
  15.  
  16. #ifdef AMIGA
  17.  
  18.  
  19. #include <stdlib.h>
  20. #include <exec/types.h>
  21. #include <libraries/dos.h>
  22. #include <libraries/dosextens.h>
  23.  
  24. getpid()
  25. {
  26.     return((long)FindTask(NULL));
  27. }
  28.  
  29. getuid()
  30. {
  31.     return(0);
  32. }
  33.  
  34. static struct passwd pas;
  35.  
  36. struct passwd *
  37. getpwuid()
  38. {
  39.     char *name = GetUserName();
  40.     if (name == NULL) {
  41.     puts("Warning, USER enviroment variable not set!");
  42.     name = "root";
  43.     }
  44.     pas.pw_name = malloc(strlen(name) + 1);
  45.     pas.pw_dir    = malloc(16);
  46.     strcpy(pas.pw_name, name);
  47.     strcpy(pas.pw_dir, "sys:");
  48.     return(&pas);
  49. }
  50.  
  51. void
  52. bzero(d, n)
  53. char *d;
  54. {
  55.     setmem(d, n, 0);
  56. }
  57.  
  58. void
  59. bcopy(s, d, n)
  60. char *s, *d;
  61. {
  62.     movmem(s, d, n);
  63. }
  64.  
  65. void
  66. sleep(n)
  67. {
  68.     if (n)
  69.     Delay(50 * n);
  70. }
  71.  
  72. stat(file, st)
  73. char *file;
  74. struct stat *st;
  75. {
  76.     struct FileLock *lock;
  77.     struct FileInfoBlock *fib = (struct FileInfoBlock *)malloc(sizeof(struct FileInfoBlock));
  78.  
  79.     lock = (struct FileLock *)Lock(file, SHARED_LOCK);
  80.     if (lock == NULL)
  81.     return(-1);
  82.     Examine((BPTR)lock, fib);
  83.     lock = (struct FileLock *)((long)lock << 2);
  84.     st->st_ino = lock->fl_Key;
  85.     st->st_ctime = st->st_mtime = fib->fib_Date.ds_Tick / 50 + fib->fib_Date.ds_Minute * 60 + fib->fib_Date.ds_Days * 86400;
  86.  
  87.     lock = (struct FileLock *)((long)lock >> 2);
  88.     UnLock((BPTR)lock);
  89.     free(fib);
  90.     return(0);
  91. }
  92.  
  93. flock(fd, locktype)
  94. {
  95.     return(0);
  96. }
  97.  
  98. char *
  99. gettmpenv(id)
  100. char *id;
  101. {
  102.     static char *buf;
  103.     static char *res = NULL;
  104.     long fh;
  105.     long len;
  106.  
  107.     buf = malloc(strlen(id) + 8);
  108.     sprintf(buf, "ENV:%s", id);
  109.     fh = Open(buf, 1005);
  110.     free(buf);
  111.     if (fh) {
  112.     Seek(fh, 0L, 1);
  113.     len = Seek(fh, 0L, -1);
  114.     if (len < 0) {
  115.         Close(fh);
  116.         return(NULL);
  117.     }
  118.     if (res)
  119.         free(res);
  120.     res = malloc(len + 1);
  121.     Read(fh, res, len);
  122.     Close(fh);
  123.     res[len] = 0;
  124.     return(res);
  125.     }
  126.     return(NULL);
  127. }
  128.  
  129.  
  130. char *
  131. getenv(id)
  132. const char *id;
  133. {
  134.     char *res = gettmpenv(id);
  135.     char *perm = NULL;
  136.  
  137.     if (res) {
  138.     perm = malloc(strlen(res) + 1);
  139.     strcpy(perm, res);
  140.     }
  141.     return(perm);
  142. }
  143.  
  144. #endif
  145.  
  146.