home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / duucp-1.17 / AU-117b4-src.lha / src / dmail / compat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-18  |  1.9 KB  |  102 lines

  1. /*
  2.  *  COMPAT.C
  3.  *
  4.  *  (C) Copyright 1985-1990 by Matthew Dillon,    All Rights Reserved.
  5.  */
  6.  
  7. #include <stdio.h>
  8. #include <string.h>
  9. #include <pwd.h>
  10. #include <sys/stat.h>
  11.  
  12. #include "dmail.h"
  13.  
  14. #ifdef AMIGA
  15.  
  16. #include <stdlib.h>
  17. #include <exec/types.h>
  18. #include <libraries/dos.h>
  19. #include <libraries/dosextens.h>
  20.  
  21. Prototype long getpid (void);
  22. Prototype long getuid (void);
  23. Prototype struct passwd *getpwuid (int uid);
  24. Prototype int stat (const char *file, struct stat *st);
  25. Prototype int flock (int fd, int locktype);
  26. Prototype void *xmalloc (int size);
  27.  
  28. long
  29. getpid (void)
  30. {
  31.     return (long) FindTask (NULL);
  32. }
  33.  
  34. long
  35. getuid (void)
  36. {
  37.     return 0;
  38. }
  39.  
  40. static struct passwd pas;
  41.  
  42. struct passwd *
  43. getpwuid (int uid)
  44. {
  45.     extern char
  46.         *GetUserName (void);
  47.     char
  48.         *name = GetUserName ();
  49.  
  50.     /* uid is ignored. FIXME -- use getpwnam() from uucp.lib */
  51.     if (name == NULL) {
  52.         puts ("Warning, USER enviroment variable not set!");
  53.         name = "root";
  54.     }
  55.     pas.pw_name = xmalloc (strlen (name) + 1);
  56.     pas.pw_dir  = xmalloc (16);
  57.     strcpy (pas.pw_name, name);
  58.     strcpy (pas.pw_dir, "sys:");
  59.     return &pas;
  60. }
  61.  
  62. int
  63. stat (const char *file, struct stat *st)
  64. {
  65.     struct FileLock *lock;
  66.     struct FileInfoBlock *fib = (struct FileInfoBlock *) xmalloc (sizeof (struct FileInfoBlock));
  67.  
  68.     lock = (struct FileLock *)Lock(file, SHARED_LOCK);
  69.     if (lock == NULL)
  70.     return(-1);
  71.     Examine((BPTR)lock, fib);
  72.     lock = (struct FileLock *)((long)lock << 2);
  73.     st->st_ino = lock->fl_Key;
  74.     st->st_ctime = st->st_mtime = fib->fib_Date.ds_Tick / 50 + fib->fib_Date.ds_Minute * 60 + fib->fib_Date.ds_Days * 86400;
  75.  
  76.     lock = (struct FileLock *)((long)lock >> 2);
  77.     UnLock((BPTR)lock);
  78.     free(fib);
  79.     return(0);
  80. }
  81.  
  82. int
  83. flock (int fd, int locktype)
  84. {
  85.     return 0;
  86. }
  87.  
  88. void *
  89. xmalloc (int size)
  90. {
  91.     char
  92.         *ptr = malloc (size);
  93.  
  94.     if (!ptr) {
  95.         fprintf (stderr, "Can't get memory!\n");
  96.         exit (30);
  97.     }
  98.  
  99.     return ptr;
  100. }
  101. #endif
  102.