home *** CD-ROM | disk | FTP | other *** search
- /*
- * COMPAT.C
- *
- * (C) Copyright 1985-1990 by Matthew Dillon, All Rights Reserved.
- */
-
- #include <stdio.h>
- #include <string.h>
- #include <pwd.h>
- #include <sys/stat.h>
-
- #include "dmail.h"
-
- #ifdef AMIGA
-
- #include <stdlib.h>
- #include <exec/types.h>
- #include <libraries/dos.h>
- #include <libraries/dosextens.h>
-
- Prototype long getpid (void);
- Prototype long getuid (void);
- Prototype struct passwd *getpwuid (int uid);
- Prototype int stat (const char *file, struct stat *st);
- Prototype int flock (int fd, int locktype);
- Prototype void *xmalloc (int size);
-
- long
- getpid (void)
- {
- return (long) FindTask (NULL);
- }
-
- long
- getuid (void)
- {
- return 0;
- }
-
- static struct passwd pas;
-
- struct passwd *
- getpwuid (int uid)
- {
- extern char
- *GetUserName (void);
- char
- *name = GetUserName ();
-
- /* uid is ignored. FIXME -- use getpwnam() from uucp.lib */
- if (name == NULL) {
- puts ("Warning, USER enviroment variable not set!");
- name = "root";
- }
- pas.pw_name = xmalloc (strlen (name) + 1);
- pas.pw_dir = xmalloc (16);
- strcpy (pas.pw_name, name);
- strcpy (pas.pw_dir, "sys:");
- return &pas;
- }
-
- int
- stat (const char *file, struct stat *st)
- {
- struct FileLock *lock;
- struct FileInfoBlock *fib = (struct FileInfoBlock *) xmalloc (sizeof (struct FileInfoBlock));
-
- lock = (struct FileLock *)Lock(file, SHARED_LOCK);
- if (lock == NULL)
- return(-1);
- Examine((BPTR)lock, fib);
- lock = (struct FileLock *)((long)lock << 2);
- st->st_ino = lock->fl_Key;
- st->st_ctime = st->st_mtime = fib->fib_Date.ds_Tick / 50 + fib->fib_Date.ds_Minute * 60 + fib->fib_Date.ds_Days * 86400;
-
- lock = (struct FileLock *)((long)lock >> 2);
- UnLock((BPTR)lock);
- free(fib);
- return(0);
- }
-
- int
- flock (int fd, int locktype)
- {
- return 0;
- }
-
- void *
- xmalloc (int size)
- {
- char
- *ptr = malloc (size);
-
- if (!ptr) {
- fprintf (stderr, "Can't get memory!\n");
- exit (30);
- }
-
- return ptr;
- }
- #endif
-