1995-08-07 16:02:12 +02:00
|
|
|
/*
|
|
|
|
** mwfopenrf - Open resource fork as stdio file for CodeWarrior.
|
|
|
|
**
|
|
|
|
** Jack Jansen, CWI, August 1995.
|
|
|
|
*/
|
|
|
|
|
1996-02-14 17:00:27 +01:00
|
|
|
#if defined(__MWERKS__) && !defined(USE_GUSI)
|
1995-08-07 16:02:12 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <unix.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include "errno_unix.h"
|
|
|
|
|
|
|
|
FILE *
|
|
|
|
fopenRF(name, mode)
|
|
|
|
char *name;
|
|
|
|
char *mode;
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
int modebits = -1;
|
1995-08-14 14:21:50 +02:00
|
|
|
int extramodebits = 0;
|
1995-08-07 16:02:12 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
1995-08-14 14:21:50 +02:00
|
|
|
if ( modebits == -1 ) {
|
|
|
|
errno = EINVAL;
|
|
|
|
return NULL;
|
|
|
|
}
|
1995-08-07 16:02:12 +02:00
|
|
|
fd = open(name, modebits|extramodebits|O_RSRC);
|
|
|
|
if ( fd < 0 )
|
|
|
|
return NULL;
|
|
|
|
return fdopen(fd, mode);
|
|
|
|
}
|
|
|
|
#endif /* __MWERKS__ */
|