/* * Printer interface functions * * * extern LONG OpenPrinter (); * Returns TRUE if succeeds, FALSE if fails. * * extern void ClosePrinter (); * The printer must have been opened. * * extern LONG PrintString ( char * string ); * Print the null terminated string on the printer. * Returns the status of DoIO() * * extern LONG DumpScreen ( struct Screen * screen ); * Dumps an intuition screen on the printer in black and white. * Returns the status of DoIO() * */ #include #include #include #include "printer.h" extern struct MsgPort * CreatePort (); extern struct IORequest * CreateExtIO (); extern LONG OpenDevice (); extern LONG DoIO (); union printerIO { struct IOStdReq ios; struct IODRPReq iodrp; struct IOPrtCmdReq iopc; }; static union printerIO * prt_request; static struct MsgPort * prt_port; LONG OpenPrinter () { prt_port = CreatePort ( (char *)NULL , (LONG)0 ); if ( prt_port != NULL ) { prt_request = (union printerIO *) CreateExtIO ( prt_port , (LONG)sizeof ( union printerIO ) ); if ( prt_request != NULL ) { if ( OpenDevice ( "printer.device" , (LONG)0 , prt_request , (LONG)0 ) == 0 ) { return ( TRUE ); } DeleteExtIO ( prt_request , (LONG)sizeof ( union printerIO ) ); } DeletePort ( prt_port ); } return ( FALSE ); } void ClosePrinter () { CloseDevice ( prt_request ); DeleteExtIO ( prt_request , (LONG) sizeof ( union printerIO ) ); DeletePort ( prt_port ); } LONG PrintString ( str ) char *str; { prt_request->ios.io_Command = CMD_WRITE; prt_request->ios.io_Length = -1; prt_request->ios.io_Data = (APTR) str; return ( DoIO ( prt_request ) ); } LONG DumpScreen ( screen ) struct Screen *screen; { prt_request->iodrp.io_Command = PRD_DUMPRPORT; prt_request->iodrp.io_RastPort = &screen->RastPort; prt_request->iodrp.io_ColorMap = screen->ViewPort.ColorMap; prt_request->iodrp.io_Modes = screen->ViewPort.Modes; prt_request->iodrp.io_SrcX = 0; prt_request->iodrp.io_SrcY = 0; prt_request->iodrp.io_SrcWidth = screen->Width; prt_request->iodrp.io_SrcHeight = screen->Height; prt_request->iodrp.io_DestCols = screen->Width; prt_request->iodrp.io_DestRows = screen->Height; prt_request->iodrp.io_Special = 0; return ( DoIO ( prt_request ) ); }