/******************************************************************************

	SinglP()

	This function performs the action of a single P command.  It must

	1.  write the edit buffer to the output file.
	2.  clear the edit buffer
	3.  read a page into the edit buffer

*****************************************************************************/

#include "ZPort.h"		/* define portability identifiers */
#include "DefChars.h"		/* define identifiers for characters */
#include "DefTeco.h"		/* define general identifiers */

extern	DEFAULT	RdPage();	/* read a page */
extern	DEFAULT	WrPage();	/* write to output file */

EXTERN	DEFAULT	CurOut;		/* index of current output stream in OFiles */
EXTERN	char	*EBfBeg;	/* beginning of edit buffer */
EXTERN	char	*GapBeg;	/* beginning of edit buffer gap */
EXTERN	char	*EBfEnd;	/* end of edit buffer */
EXTERN	char	*GapEnd;	/* end of edit buffer gap */
EXTERN	LONG	FFPage;		/* form feed flag (returned by ^E command) */


DEFAULT SinglP()		/* do a single P command */
{
#if DEBUGGING
DbgInd+=2;if(DbgLvl>=2){DbgMsg();DbgDBf("SinglP: called.\015\012");DbgROf();}
#endif

	if (WrPage(CurOut, EBfBeg, EBfEnd, FFPage) == FAILURE)
#if DEBUGGING
{if(DbgLvl>=2)
{DbgMsg();DbgDBf("SinglP: returning FAILURE.\015\012");DbgROf();}DbgInd-=2;
#endif
		return(FAILURE);
#if DEBUGGING
}
#endif

	GapBeg = EBfBeg;		/* clear the... */
	GapEnd = EBfEnd;		/* ...edit buffer */

	if (RdPage() == FAILURE)
#if DEBUGGING
{if(DbgLvl>=2)
{DbgMsg();DbgDBf("SinglP: returning FAILURE.\015\012");DbgROf();}DbgInd-=2;
#endif
		return(FAILURE);
#if DEBUGGING
}
#endif

#if DEBUGGING
if(DbgLvl>=2)
{DbgMsg();DbgDBf("SinglP: returning SUCCESS.\015\012");DbgROf();}DbgInd-=2;
#endif
	return(SUCCESS);
}
