This function is called when the application sends a line of text to the POD for printing. The global variable prn_device contains the number of the currently selected COD. The argument passed to prn_print() is the index of the entry in the pdesc[] array which points to the text to be printed.
The code of prn_print() should print or display or otherwise deal with the text. It should return the value 1 when it has finished.
In our example, only two of our COD types implement output. The printer COD takes text to be printed, either to the slip or journal. The output_text() function is operating-systems dependent and not shown. The text output to the drawer COD indicates whether the drawer should be opened or closed.
int prn_print(int index)
{
switch (prn_device)
{
case 'P':
/* Print text on appropriate printer */
if (!output_text(till_printer, pdesc[index].text))
prn_error = till_printer == JOURNAL ?
ERR_JOURNAL_PRINT : ERR_SLIP_PRINT;
return 1;
case 'D':
/* Output text indicates whether to open or close drawer */
drawer_opened = (*pdesc[index].text == 'O');
return 1;
default:
/* other devices not implemented for printing */
return 1;
}
}
|
If asynchronous printing is implemented, prn_print() may return the value 0 to indicate that printing has not been completed. See Asynchronous Printing for details of how this should be implemented.
The string to be printed by prn_print() will end with either line-feed or carriage-return/line-feed depending on the printer characteristics set up with DFSETUP.