home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / snews-20.zip / LOCK.C < prev    next >
C/C++ Source or Header  |  1992-07-13  |  689b  |  39 lines

  1. #ifndef msg
  2. #include <stdio.h>
  3. #include <share.h>
  4. #include "os2defs.h"
  5. #define msg(x)
  6. #endif
  7.  
  8. #include <errno.h>
  9.  
  10. FILE *flockopen(char *name, char *mode)
  11. {
  12.   int shflag = SH_DENYWR, try;
  13.   char *ptr;
  14.   FILE *file;
  15.   char buf[80];
  16.  
  17.   for ( ptr = mode; *ptr; ptr++ )
  18.     if ( *ptr == 'w' || *ptr == 'a' || *ptr == '+' )
  19.       shflag = SH_DENYRW;
  20.  
  21.   for ( try = 0; try < 10; try++ )
  22.     if ( (file = _fsopen(name, mode, shflag)) != NULL )
  23.       break;
  24.     else if ( errno == ENOENT )
  25.       break;
  26.     else
  27.     {
  28.       msg(name);
  29.       delay(1000);
  30.     }
  31.  
  32.   return file;
  33. }
  34.  
  35. void noinherit(HFILE hFile)
  36. {
  37.   DosSetFHandState(hFile, OPEN_FLAGS_NOINHERIT);
  38. }
  39.