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 >
Text File  |  1991-12-17  |  583b  |  27 lines

  1.  
  2. Listing 4 -- the file xfopen.c
  3.  
  4. /* _Fopen function -- UNIX version */
  5. #include "xstdio.h"
  6.  
  7.         /* UNIX system call */
  8. int _Open(const char *, int, int);
  9.  
  10. int _Fopen(const char *path, unsigned int smode,
  11.     const char *mods)
  12.     {   /* open from a file */
  13.     unsigned int acc;
  14.  
  15.     acc = (smode & (_MOPENR|_MOPENW)) ==
  16.         (_MOPENR|_MOPENW) ? 2
  17.         : smode & _MOPENW ? 1 : 0;
  18.     if (smode & _MOPENA)
  19.         acc |= 010; /* O_APPEND */
  20.     if (smode & _MTRUNC)
  21.         acc |= 02000;   /* O_TRUNC */
  22.     if (smode & _MCREAT)
  23.         acc |= 01000;   /* O_CREAT */
  24.     return (_Open(path, acc, 0666));
  25.     }
  26.  
  27.