/****************************************************************
* program readit.c *
* *
* modified by reason *
* -------- -- ------ *
* 24-Jun-92 cbl orignal, reads from open file*
* returns label. *
* *
****************************************************************/
#define nread 80 /* number of bytes to read. */
void
readit(int fd)
{
int iread; /* number of bytes actually read. */
int istat; /* status of read. */
char buf[nread]; /* buffer for input data. */
int i;
printf(" Inside routine readit.\n");
iread=read(fd,buf,nread);
/* dump buffer */
printf("\n Read successful.\n");
/* character printout. */
printf("\n Attempt to printout string value.\n");
buf[nread]='\0'; /* null terminate string. */
printf("\n %s",buf);
}
/****************************************************************
* program mtdo.c *
* *
* modified by reason *
* -------- -- ------ *
* 13-Jan-92 cbl orignal, rewind tape *
* *
****************************************************************/
#include <stdio.h>
#include <sys/types.h>
#include <sys/mtio.h>
#include <sys/tpsc.h>
#include <errno.h>
#include <string.h>
#define SLEEPTIME 20 /* time to wait in seconds. */
#define RETRY 10 /* number of times to retry */
int
wait_for_tape (int fd)
{
static struct mtget mt_info; /* structure of magtape info. */
int istat; /* status of calls. */
int icount=0; /* count on number of waits. */
int iret; /* return value from call. */
/******************** Start of executable Code.****************/
iret=0; /* assume success. */
while (icount< RETRY) { /* only try waiting 10 times then fail. */
sleep(SLEEPTIME); /* wait for awhile, even before checking*/
istat=ioctl(fd,MTIOCGET,&mt_info); /* get tape info */
if(mt_info.mt_dsreg &&CT_LOADED== 0) /* device not ready */
icount++; /* only try 10 times. */
else
break; /* drive must be ready now. */
}
if(icount == RETRY) iret=-1;
}