home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_10_02
/
1002014d
< prev
next >
Wrap
Text File
|
1991-12-17
|
583b
|
27 lines
Listing 4 -- the file xfopen.c
/* _Fopen function -- UNIX version */
#include "xstdio.h"
/* UNIX system call */
int _Open(const char *, int, int);
int _Fopen(const char *path, unsigned int smode,
const char *mods)
{ /* open from a file */
unsigned int acc;
acc = (smode & (_MOPENR|_MOPENW)) ==
(_MOPENR|_MOPENW) ? 2
: smode & _MOPENW ? 1 : 0;
if (smode & _MOPENA)
acc |= 010; /* O_APPEND */
if (smode & _MTRUNC)
acc |= 02000; /* O_TRUNC */
if (smode & _MCREAT)
acc |= 01000; /* O_CREAT */
return (_Open(path, acc, 0666));
}