Jack Jansen | 42218ce | 1997-01-31 16:15:11 +0000 | [diff] [blame] | 1 | /*********************************************************** |
| 2 | Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, |
| 3 | The Netherlands. |
| 4 | |
| 5 | All Rights Reserved |
| 6 | |
| 7 | Permission to use, copy, modify, and distribute this software and its |
| 8 | documentation for any purpose and without fee is hereby granted, |
| 9 | provided that the above copyright notice appear in all copies and that |
| 10 | both that copyright notice and this permission notice appear in |
| 11 | supporting documentation, and that the names of Stichting Mathematisch |
| 12 | Centrum or CWI or Corporation for National Research Initiatives or |
| 13 | CNRI not be used in advertising or publicity pertaining to |
| 14 | distribution of the software without specific, written prior |
| 15 | permission. |
| 16 | |
| 17 | While CWI is the initial source for this software, a modified version |
| 18 | is made available by the Corporation for National Research Initiatives |
| 19 | (CNRI) at the Internet address ftp://ftp.python.org. |
| 20 | |
| 21 | STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH |
| 22 | REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF |
| 23 | MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH |
| 24 | CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
| 25 | DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 26 | PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 27 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 28 | PERFORMANCE OF THIS SOFTWARE. |
| 29 | |
| 30 | ******************************************************************/ |
| 31 | |
Jack Jansen | 426fa79 | 1995-08-07 14:02:12 +0000 | [diff] [blame] | 32 | /* |
| 33 | ** mwfopenrf - Open resource fork as stdio file for CodeWarrior. |
Jack Jansen | 426fa79 | 1995-08-07 14:02:12 +0000 | [diff] [blame] | 34 | */ |
| 35 | |
Jack Jansen | b852b74 | 1996-02-14 16:00:27 +0000 | [diff] [blame] | 36 | #if defined(__MWERKS__) && !defined(USE_GUSI) |
Jack Jansen | 426fa79 | 1995-08-07 14:02:12 +0000 | [diff] [blame] | 37 | #include <stdio.h> |
| 38 | #include <unix.h> |
| 39 | #include <errno.h> |
| 40 | #include "errno_unix.h" |
| 41 | |
| 42 | FILE * |
| 43 | fopenRF(name, mode) |
| 44 | char *name; |
| 45 | char *mode; |
| 46 | { |
| 47 | int fd; |
Jack Jansen | 426fa79 | 1995-08-07 14:02:12 +0000 | [diff] [blame] | 48 | int modebits = -1; |
Jack Jansen | 9c45a65 | 1995-08-14 12:21:50 +0000 | [diff] [blame] | 49 | int extramodebits = 0; |
Jack Jansen | 426fa79 | 1995-08-07 14:02:12 +0000 | [diff] [blame] | 50 | char *modep; |
| 51 | |
| 52 | for(modep=mode; *modep; modep++) { |
| 53 | switch(*modep) { |
| 54 | case 'r': modebits = O_RDONLY; break; |
| 55 | case 'w': modebits = O_WRONLY; extramodebits |= O_CREAT|O_TRUNC; break; |
| 56 | case 'a': modebits = O_RDONLY; |
| 57 | extramodebits |= O_CREAT|O_APPEND; |
| 58 | extramodebits &= ~O_TRUNC; |
| 59 | break; |
| 60 | case '+': modebits = O_RDWR; |
| 61 | extramodebits &= ~O_TRUNC; |
| 62 | break; |
| 63 | case 'b': extramodebits |= O_BINARY; |
| 64 | break; |
| 65 | default: |
| 66 | errno = EINVAL; |
| 67 | return NULL; |
| 68 | } |
| 69 | } |
Jack Jansen | 9c45a65 | 1995-08-14 12:21:50 +0000 | [diff] [blame] | 70 | if ( modebits == -1 ) { |
| 71 | errno = EINVAL; |
| 72 | return NULL; |
| 73 | } |
Jack Jansen | 426fa79 | 1995-08-07 14:02:12 +0000 | [diff] [blame] | 74 | fd = open(name, modebits|extramodebits|O_RSRC); |
| 75 | if ( fd < 0 ) |
| 76 | return NULL; |
| 77 | return fdopen(fd, mode); |
| 78 | } |
| 79 | #endif /* __MWERKS__ */ |