/*	XWPFILES.C
**
**	File Utilities for XWP
*/

#include "a:stdio.h"
#include "b:oxege.h"

char FLprint;			/* Flag for print active    */
char GLpline;			/* Print line 		    */
char filename[15];		/* Filename to print out    */
int prnfp;			/* Printout file identifier */
extern char scratch[];

initprn()
	{
	spoke( 2, 15,  " FILE TO PRINT:  ", ATTDIM );
	spoke( 3, 15, "                 ", ATTBRT | INVATT);
	adr( 3, 16 );
	fflush( stdin );
	defcursor( 3 );
	gets( filename );
	defcursor( 0 );
	stoupper( filename );
	if ( ( prnfp = fopen( filename, "r" ) ) == NULL )
		{
		fill( 2, 15, 3, 32, FILL1, ATTDIM | ATTALT );
		return 0;
		}
	strcpy( scratch, "PRINTING " );
	strcat( scratch, filename );
	strcat( scratch, "..." );
	message( 2, 0, scratch );
	FLprint = 1;
	GLpline = 1;
	fill( 2, 15, 3, 32, FILL1, ATTDIM | ATTALT );
	}

print()
	{
	char c;
	if ( FLprint == NULL ) return;
	if ( (c = getc( prnfp )) == EOF)
		{
		endprn();
		}
	else	
		{ 
		lo( c );
		if ( c == LF )
			{
			++GLpline;
			}
		if ( GLpline == 55 )
			{
			GLpline = 1;
			lo( FF );
			}
		}
	}

endprn()
	{
	lo( FF);
	fclose( prnfp );
	message( 2, 0, greeting() ); 
	FLprint = 0;
	}

stoupper( string )
	char *string;
	{
	char *character;
	character = string;
	while ( *character )
		{
		*character = toupper( *character );
		character++;
		}
	return string;
	}
racter = string;
	while ( *character )
		{
		*character = toupper( *character );
		character++;
		}
	return 