Open System Services Programmer's Guide

char *iobuf;
short err;
spt_error_t spte;
long error;
_cc_status cc;
long tag;
long long filesize = 0;
if ((iobuf = malloc(IOSIZE)) == NULL)
{
printf("*** ERROR in Grd_READ_thread: unable to allocate
I/O buffer ***\n");
exit(0);
}
memset(iobuf, 0, IOSIZE);
/**********************************************************/
/* open the OSS file using FILE_OPEN_() so we can do */
/* Guardian nowait I/O */
/**********************************************************/
err = FILE_OPEN_(Grd_READ_file,
(short) sizeof(Grd_READ_file),
&fnum,
0 /* rd_wr */,
0 /* shared */,
1 /* nowait-depth */ ,
0 /* sync depth */,
0x0020 /* options - bit <10> set to allow open of an OSS pathname */);
if (err > 0)
{
printf("*** ERROR in Grd_READ_thread: FILE_OPEN_() of %s failed
w/error %d ***\n", Grd_READ_file, (int) err);
exit(0);
}
/*********************/
/* register the fnum */
/*********************/
spte = spt_regFile(fnum);
if (spte != SPT_SUCCESS)
{
printf("*** ERROR in Grd_READ_thread: spt_regFile()
failed w/error %d ***\n",(int) spte);
exit(0);
}
/***************************************************/
/* Do Guardian nowait I/O in a thread aware manner */
/***************************************************/
while (1)
{
tag = spt_generateTag();
cc = READX(fnum, iobuf, (short) IOSIZE, /* count read */, tag);
if (_status_ne(cc))
{
(void) FILE_GETINFO_(fnum, &err);
printf("*** ERROR in Grd_READ_thread: READX() failed
w/error %d ***\n",(int) err);
exit(0);
}
else /* CCE - read successfully initiated */
{
Thread-Aware and Nonblocking OSS Functions 355