maint: retire the last VC'd ChangeLog file
[gzip.git] / primos / primos.c
blobc751c9a2b6d952738b80f618186f42e9f69af614
1 /*
2 ** primos.c
3 **
4 ** This file contains emulation routines for some common Unix functions
5 **
6 ** Author: Peter Eriksson <pen@lysator.liu.se>
7 */
9 #ifdef __50SERIES
11 #include <stdio.h>
12 #include <fcntl.h>
13 #include <sys/stat.h>
16 uid_t primos_uid = 42;
17 gid_t primos_gid = 42;
18 mode_t primos_mode = 600;
20 /* Dummy do-nothing routine for chmod() */
21 int chmod(path, mode)
22 char *path;
23 int mode;
25 return 0;
28 char *getenv(var)
29 char *var;
31 char buf[256];
32 extern char *gvget();
34 buf[0] = '.';
35 strcpy(buf+1, var);
37 return gvget(buf);
41 unlink(path)
42 char *path;
44 return delete(path);
47 int lstat(path, buf)
48 char *path;
49 struct stat *buf;
51 return stat(path, buf);
54 int stat(path, buf)
55 char *path;
56 struct stat *buf;
58 buf->st_dev = 1;
59 buf->st_ino = 1;
60 buf->st_nlink = 1;
61 buf->st_uid = primos_uid;
62 buf->st_gid = primos_gid;
63 buf->st_rdev = 1;
64 buf->st_blksize = 2048;
66 buf->st_rwlock = frwlock(path);
67 switch (buf->st_type = ftype(path))
69 case 0:
70 case 1:
71 /* Regular file (SAM or DAM) */
72 buf->st_size = fsize(path);
73 buf->st_mtime = fdtm(path);
75 buf->st_mode = S_IFREG|primos_mode;
76 break;
78 case 4:
79 buf->st_size = 0;
80 buf->st_mtime = fdtm(path);
82 buf->st_mode = S_IFDIR|primos_mode;
83 break;
85 case -1:
86 return -1;
88 default:
89 buf->st_mode = primos_mode;
90 buf->st_size = fsize(path);
91 buf->st_mtime = fdtm(path);
94 buf->st_blocks = (buf->st_size-1) / buf->st_blksize + 1;
96 /* Should be fixed to really fetch these values, but that
97 * would require calling some PRIMOS subroutines and I don't have
98 * a copy of the Primos Subroutine reference manuals here..
100 buf->st_atime = buf->st_mtime;
101 buf->st_ctime = buf->st_mtime;
103 return 0;
106 int fstat(fd, buf)
107 int fd;
108 struct stat *buf;
110 char path[1025];
112 return stat(getname(fd, path), buf);
115 int ascii2pascii(c)
116 int c;
118 return (c ? (c | 0x80) : '\0');
122 #endif /* __50SERIES */