home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * COMPAT.C
- *
- * $Header: Beta:src/uucp/src/dmail/RCS/compat.c,v 1.1 90/02/02 12:03:31 dillon Exp Locker: dillon $
- *
- * (C) Copyright 1985-1990 by Matthew Dillon, All Rights Reserved.
- *
- */
-
- #include <stdio.h>
- #include <pwd.h>
- #include <sys/stat.h>
- #include "config.h"
-
- #ifdef AMIGA
-
- extern char *gettmpenv();
- extern char *getenv();
-
- #include <stdlib.h>
- #include <exec/types.h>
- #include <libraries/dos.h>
- #include <libraries/dosextens.h>
-
- getpid()
- {
- return((long)FindTask(NULL));
- }
-
- getuid()
- {
- return(0);
- }
-
- static struct passwd pas;
-
- struct passwd *
- getpwuid()
- {
- char *name = gettmpenv("USER");
- if (name == NULL) {
- name = FindConfig(USERNAME);
- if (name == NULL) {
- puts("Warning, USER enviroment variable not set!");
- name = "root";
- }
- }
- pas.pw_name = malloc(strlen(name) + 1);
- pas.pw_dir = malloc(16);
- strcpy(pas.pw_name, name);
- strcpy(pas.pw_dir, "sys:");
- return(&pas);
- }
-
- struct passwd *
- getpwnam()
- {
- return(getpwuid(0));
- }
-
- void
- bzero(d, n)
- char *d;
- {
- setmem(d, n, 0);
- }
-
- void
- bcopy(s, d, n)
- char *s, *d;
- {
- movmem(s, d, n);
- }
-
- void
- sleep(n)
- {
- if (n)
- Delay(50 * n);
- }
-
- stat(file, st)
- char *file;
- struct stat *st;
- {
- struct FileLock *lock;
- struct FileInfoBlock *fib = (struct FileInfoBlock *)malloc(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);
- }
-
- flock(fd, locktype)
- {
- return(0);
- }
-
- char *
- gettmpenv(id)
- char *id;
- {
- static char *buf;
- static char *res = NULL;
- long fh;
- long len;
-
- buf = malloc(strlen(id) + 8);
- sprintf(buf, "ENV:%s", id);
- fh = Open(buf, 1005);
- free(buf);
- if (fh) {
- Seek(fh, 0L, 1);
- len = Seek(fh, 0L, -1);
- if (len < 0) {
- Close(fh);
- return(NULL);
- }
- if (res)
- free(res);
- res = malloc(len + 1);
- Read(fh, res, len);
- Close(fh);
- res[len] = 0;
- return(res);
- }
- return(NULL);
- }
-
-
- char *
- getenv(id)
- const char *id;
- {
- char *res = gettmpenv(id);
- char *perm = NULL;
-
- if (res) {
- perm = malloc(strlen(res) + 1);
- strcpy(perm, res);
- }
- return(perm);
- }
-
- #endif
-
-