diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 1995-08-07 14:02:12 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 1995-08-07 14:02:12 (GMT) |
commit | 426fa79a7d653599436cc5d144f34e33b80d9d28 (patch) | |
tree | 2480531d5bf23ec2edba0ae3c50fa2fcf1d37a62 | |
parent | 67b4e6d4e8c91d8d5e63072aaa6e57ce008aa60d (diff) | |
download | cpython-426fa79a7d653599436cc5d144f34e33b80d9d28.zip cpython-426fa79a7d653599436cc5d144f34e33b80d9d28.tar.gz cpython-426fa79a7d653599436cc5d144f34e33b80d9d28.tar.bz2 |
Mwerks version of fopenRF.
-rw-r--r-- | Mac/mwerks/mwfopenrf.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Mac/mwerks/mwfopenrf.c b/Mac/mwerks/mwfopenrf.c new file mode 100644 index 0000000..fa2a39b --- /dev/null +++ b/Mac/mwerks/mwfopenrf.c @@ -0,0 +1,47 @@ +/* +** mwfopenrf - Open resource fork as stdio file for CodeWarrior. +** +** Jack Jansen, CWI, August 1995. +*/ + +#ifdef __MWERKS__ +#include <stdio.h> +#include <unix.h> +#include <errno.h> +#include "errno_unix.h" + +FILE * +fopenRF(name, mode) + char *name; + char *mode; +{ + int fd; + FILE *fp; + int modebits = -1; + int extramodebits; + char *modep; + + for(modep=mode; *modep; modep++) { + switch(*modep) { + case 'r': modebits = O_RDONLY; break; + case 'w': modebits = O_WRONLY; extramodebits |= O_CREAT|O_TRUNC; break; + case 'a': modebits = O_RDONLY; + extramodebits |= O_CREAT|O_APPEND; + extramodebits &= ~O_TRUNC; + break; + case '+': modebits = O_RDWR; + extramodebits &= ~O_TRUNC; + break; + case 'b': extramodebits |= O_BINARY; + break; + default: + errno = EINVAL; + return NULL; + } + } + fd = open(name, modebits|extramodebits|O_RSRC); + if ( fd < 0 ) + return NULL; + return fdopen(fd, mode); +} +#endif /* __MWERKS__ */ |