#include	<std.h>
#include        <fc.h>          /* fcs header                   */
#include	<pccom.ih>
extern	stdout;			/* The standard output thing	*/
extern	io_wvb;			/* value for write virtual block */
#define IO_WVB (int)&io_wvb

#DEFINE EOF     -10             /* end of file status           */

#define RECSIZ  132             /* size of the largest record   */

int     fdbin1[ SFDBW ] = {0};  /* fdb for file .stb file       */

char    outbuf[RECSIZ] = {0};    /* input file buffer            */
int     riob[2] = {0};          /* record i/o status block      */


struct {
	long	rtyp;	/* Same as taskname	*/
	int	year;	/* Year since 1900	*/
	int	month;	/* month	(1-12)	*/
	int	day;	/* Day		(1-31)	*/
	int	hour;	/* hour		(0-23)	*/
	int	minute;	/* minute	(0-59)	*/
	int	second;	/* seconds	(0-59)	*/
	int	tick;	/* partof sec		*/
	int	clock;	/* ticks per second	*/
	int	extsts;	/* Task exit status	*/
	int	filler[2]; /* record filler	*/
	} recbuf = {0};


static	char fmtstr[ 132 ]= {0};	/* formatted output string */
char    *format =
"STS= %P; Vec %P; Ep %P; Seg %2R; Reg  %2R; DSW %D EFNs %4P%N";
char	*dattim =
"Loging started %Y %5Z%N";
char	*done   =
"Logging stopped at %Y %5Z. Task exit status = %P%N";

char *edmsg();

char	*dev = "LB:";
char	*uic = "[1,4]";
char	*file = "PAXMAI.AUT";

main(){

int	strln = 0;
int	status = 0;
int	frec = 1;	/* This is the first record.	*/
register int     i, j;	/* asorted loop and index counters	*/

	finit( &stdout, STDOUT, WRITE);

	if((status = fcopen ( fdbin1, dev, uic, file, 4, FCSEQIO+FCROACC, NOFOB )) != ISSUC){
		*edmsg( fmtstr,"%NFile open error %P", &status)='\0';
		putlin( fmtstr, lenstr(fmtstr));
		return(0);
	}

	while ((  status = getrb ( fdbin1, &recbuf, 132, NORECNUM,&riob)) == ISSUC  ){
		if( recbuf.rtyp == 0l)
			*edmsg( &fmtstr, (frec? dattim : done), &recbuf.year)= '\0';
		else
			*edmsg( &fmtstr, format, &recbuf.year)= '\0';
		frec = 0;
		putlin( fmtstr, lenstr( fmtstr ));
	}
	fcclos ( fdbin1 );
}
