home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Professional
/
OS2PRO194.ISO
/
os2
/
com
/
utils
/
smplnews
/
lock.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-07-13
|
689b
|
39 lines
#ifndef msg
#include <stdio.h>
#include <share.h>
#include "os2defs.h"
#define msg(x)
#endif
#include <errno.h>
FILE *flockopen(char *name, char *mode)
{
int shflag = SH_DENYWR, try;
char *ptr;
FILE *file;
char buf[80];
for ( ptr = mode; *ptr; ptr++ )
if ( *ptr == 'w' || *ptr == 'a' || *ptr == '+' )
shflag = SH_DENYRW;
for ( try = 0; try < 10; try++ )
if ( (file = _fsopen(name, mode, shflag)) != NULL )
break;
else if ( errno == ENOENT )
break;
else
{
msg(name);
delay(1000);
}
return file;
}
void noinherit(HFILE hFile)
{
DosSetFHandState(hFile, OPEN_FLAGS_NOINHERIT);
}