diff options
author | Karl Berry <karl@freefriends.org> | 2006-01-17 21:16:42 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2006-01-17 21:16:42 +0000 |
commit | a3d3111bfe26b8e5f5bc6049dfb2a4ca2edc7881 (patch) | |
tree | f4a8a34f904c1bb86adcc3ae0e14434badc6dbe4 /Build/source/utils/gzip/primos/primos.c | |
parent | 6c0eafbb1395d426a72a74538e0b2a95e8344ca6 (diff) |
utils 1
git-svn-id: svn://tug.org/texlive/trunk@1484 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/gzip/primos/primos.c')
-rw-r--r-- | Build/source/utils/gzip/primos/primos.c | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/Build/source/utils/gzip/primos/primos.c b/Build/source/utils/gzip/primos/primos.c new file mode 100644 index 00000000000..c751c9a2b6d --- /dev/null +++ b/Build/source/utils/gzip/primos/primos.c @@ -0,0 +1,122 @@ +/* +** primos.c +** +** This file contains emulation routines for some common Unix functions +** +** Author: Peter Eriksson <pen@lysator.liu.se> +*/ + +#ifdef __50SERIES + +#include <stdio.h> +#include <fcntl.h> +#include <sys/stat.h> + + +uid_t primos_uid = 42; +gid_t primos_gid = 42; +mode_t primos_mode = 600; + +/* Dummy do-nothing routine for chmod() */ +int chmod(path, mode) + char *path; + int mode; +{ + return 0; +} + +char *getenv(var) + char *var; +{ + char buf[256]; + extern char *gvget(); + + buf[0] = '.'; + strcpy(buf+1, var); + + return gvget(buf); +} + + +unlink(path) + char *path; +{ + return delete(path); +} + +int lstat(path, buf) + char *path; + struct stat *buf; +{ + return stat(path, buf); +} + +int stat(path, buf) + char *path; + struct stat *buf; +{ + buf->st_dev = 1; + buf->st_ino = 1; + buf->st_nlink = 1; + buf->st_uid = primos_uid; + buf->st_gid = primos_gid; + buf->st_rdev = 1; + buf->st_blksize = 2048; + + buf->st_rwlock = frwlock(path); + switch (buf->st_type = ftype(path)) + { + case 0: + case 1: + /* Regular file (SAM or DAM) */ + buf->st_size = fsize(path); + buf->st_mtime = fdtm(path); + + buf->st_mode = S_IFREG|primos_mode; + break; + + case 4: + buf->st_size = 0; + buf->st_mtime = fdtm(path); + + buf->st_mode = S_IFDIR|primos_mode; + break; + + case -1: + return -1; + + default: + buf->st_mode = primos_mode; + buf->st_size = fsize(path); + buf->st_mtime = fdtm(path); + } + + buf->st_blocks = (buf->st_size-1) / buf->st_blksize + 1; + + /* Should be fixed to really fetch these values, but that + * would require calling some PRIMOS subroutines and I don't have + * a copy of the Primos Subroutine reference manuals here.. + */ + buf->st_atime = buf->st_mtime; + buf->st_ctime = buf->st_mtime; + + return 0; +} + +int fstat(fd, buf) + int fd; + struct stat *buf; +{ + char path[1025]; + + return stat(getname(fd, path), buf); +} + +int ascii2pascii(c) + int c; +{ + return (c ? (c | 0x80) : '\0'); +} + + +#endif /* __50SERIES */ |