home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / auucp+-1.02 / fuucp_plus_src.lzh / dmail / compat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-11-21  |  2.4 KB  |  157 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. extern char *gettmpenv();
  19. extern char *getenv();
  20.  
  21. #include <stdlib.h>
  22. #include <exec/types.h>
  23. #include <libraries/dos.h>
  24. #include <libraries/dosextens.h>
  25.  
  26. getpid()
  27. {
  28.     return((long)FindTask(NULL));
  29. }
  30.  
  31. getuid()
  32. {
  33.     return(0);
  34. }
  35.  
  36. static struct passwd pas;
  37.  
  38. struct passwd *
  39. getpwuid()
  40. {
  41.     char *name = gettmpenv("USER");
  42.     if (name == NULL) {
  43.     name = FindConfig(USERNAME);
  44.     if (name == NULL) {
  45.         puts("Warning, USER enviroment variable not set!");
  46.         name = "root";
  47.     }
  48.     }
  49.     pas.pw_name = malloc(strlen(name) + 1);
  50.     pas.pw_dir    = malloc(16);
  51.     strcpy(pas.pw_name, name);
  52.     strcpy(pas.pw_dir, "sys:");
  53.     return(&pas);
  54. }
  55.  
  56. struct passwd *
  57. getpwnam()
  58. {
  59.     return(getpwuid(0));
  60. }
  61.  
  62. void
  63. bzero(d, n)
  64. char *d;
  65. {
  66.     setmem(d, n, 0);
  67. }
  68.  
  69. void
  70. bcopy(s, d, n)
  71. char *s, *d;
  72. {
  73.     movmem(s, d, n);
  74. }
  75.  
  76. void
  77. sleep(n)
  78. {
  79.     if (n)
  80.     Delay(50 * n);
  81. }
  82.  
  83. stat(file, st)
  84. char *file;
  85. struct stat *st;
  86. {
  87.     struct FileLock *lock;
  88.     struct FileInfoBlock *fib = (struct FileInfoBlock *)malloc(sizeof(struct FileInfoBlock));
  89.  
  90.     lock = (struct FileLock *)Lock(file, SHARED_LOCK);
  91.     if (lock == NULL)
  92.     return(-1);
  93.     Examine((BPTR)lock, fib);
  94.     lock = (struct FileLock *)((long)lock << 2);
  95.     st->st_ino = lock->fl_Key;
  96.     st->st_ctime = st->st_mtime = fib->fib_Date.ds_Tick / 50 + fib->fib_Date.ds_Minute * 60 + fib->fib_Date.ds_Days * 86400;
  97.  
  98.     lock = (struct FileLock *)((long)lock >> 2);
  99.     UnLock((BPTR)lock);
  100.     free(fib);
  101.     return(0);
  102. }
  103.  
  104. flock(fd, locktype)
  105. {
  106.     return(0);
  107. }
  108.  
  109. char *
  110. gettmpenv(id)
  111. char *id;
  112. {
  113.     static char *buf;
  114.     static char *res = NULL;
  115.     long fh;
  116.     long len;
  117.  
  118.     buf = malloc(strlen(id) + 8);
  119.     sprintf(buf, "ENV:%s", id);
  120.     fh = Open(buf, 1005);
  121.     free(buf);
  122.     if (fh) {
  123.     Seek(fh, 0L, 1);
  124.     len = Seek(fh, 0L, -1);
  125.     if (len < 0) {
  126.         Close(fh);
  127.         return(NULL);
  128.     }
  129.     if (res)
  130.         free(res);
  131.     res = malloc(len + 1);
  132.     Read(fh, res, len);
  133.     Close(fh);
  134.     res[len] = 0;
  135.     return(res);
  136.     }
  137.     return(NULL);
  138. }
  139.  
  140.  
  141. char *
  142. getenv(id)
  143. const char *id;
  144. {
  145.     char *res = gettmpenv(id);
  146.     char *perm = NULL;
  147.  
  148.     if (res) {
  149.     perm = malloc(strlen(res) + 1);
  150.     strcpy(perm, res);
  151.     }
  152.     return(perm);
  153. }
  154.  
  155. #endif
  156.  
  157.