#include <exec/types.h>
#include <libraries/dosextens.h>
#include <ctype.h>
#include <stdio.h>

#define BUFLEN 256

#ifdef AZTEC_C
#include <functions.h>
#else
#include <stdlib.h>
#include <string.h>
#include <dos.h>
#include <proto/dos.h>
#endif

BPTR fhi, fho; /***** Filehandles *****/

void gerror( s )
char *s;
{
 printf( "\n%s\n", s );
 if ( fhi ) Close( fhi );
 if ( fho ) Close( fho );
 exit( RETURN_WARN );
}

void main( argc, argv )
int argc; char *argv[];
{
 UBYTE buffer[ BUFLEN ];
 LONG cletti;
 if ( argc < 2 )
  gerror( "Uso: Print nomefile" );

 if ( ( fhi = Open(argv[ 1 ], MODE_OLDFILE ) ) == 0 )
  gerror( "Non si apre l'input" );

 if ( ( fho = Open( "PRT:", MODE_OLDFILE ) ) == 0 )
  gerror( "Non si apre la stampante" );

 do
  {
  cletti = Read( fhi, &buffer[ 0 ], BUFLEN );
  Write ( fho, &buffer[ 0 ], cletti ); 
  }
 while ( cletti == BUFLEN );

 Close ( fhi ); Close ( fho );
}
