
#include "V.h"
#include "sys_stat.h"
/*
* Do some checking on the Vout file.  The main thing is checking its
* size against the Vsizlim, and if it is too big, moving the file to
* backup and starting a new one.  Also, if the V file doesn't exist,
* it will be created.  The return value currently is always zero.
*/
Vchklog()
{	int  r=0;
	STat st;
	Fenter("Vchklog");
	V7 "Called." D;
	if (!Vfile) {
		V5 "No Vfile." D;
		Done;
	}
	if (!Vout) {
		V5 "No Vout stream." D;
		Done;
	}
	V6 "Vsizlim=%d Vout=%08X Vfile=%s",
		Vsizlim,Vout,Dsps(Vfile,-1) D;
	if (Vout == stderr) {
		V5 "Vout == stderr" D;
		Done;
	}
	if (Stat(Vfile,&st)) {
		V2 "Can't get status of Vout file %s [Err %d=%s=%s]",
			Dsps(Vfile,-1),Errinfo D;
		Vnewlog();	/* Try to recover by re-opening it */
	} else {
		if (Vsizlim) {
			V6 "Got status of Vout file %s [Err %d=%s=%s]",
				Dsps(Vfile,-1),Errinfo D;
			if (st.st_size > Vsizlim) {
				V6 "Debug file \"%s\" is %lu bytes ...",Vfile,st.st_size D;
				Vnewlog();
			}


		}
	}
done:
	FExit;
	return r;
}
