/* * PAP.h * C Interface to PAP (Printer Access Protocol) routines * * Written by: Ken McLeod, 2026-01-07 * Last update: 2026-03-27 * * This software is provided as-is, with no warranties expressed or implied, * under the terms of the BSD 2-Clause License. See separate "LICENSE" file. */ #ifndef __PRINTER_ACCESS_PROTOCOL__ #define __PRINTER_ACCESS_PROTOCOL__ #include #include typedef struct { long int unused; char statusStr[256]; } PAPStatusRec, *PAPStatusPtr; /* PAP function IDs */ #define kPAPOpenConn 1 #define kPAPOpenConnReply 2 #define kPAPSendData 3 #define kPAPData 4 #define kPAPTickle 5 #define kPAPCloseConn 6 #define kPAPCloseConnReply 7 #define kPAPSendStatus 8 #define kPAPStatus 9 /* other constants */ #define kPAPMinQuantum 1 #define kPAPMaxQuantum 8 #ifdef __cplusplus extern "C" { #endif /* call this in main event loop to process incoming requests */ void CheckATP(void); /* call this prior to SLInit to specify emulated printer options */ void SetPrinterOptions(Boolean colorRibbon, Boolean sheetFeeder, Boolean iw1Mode, Boolean noReverse); /* accessor for options */ void GetPrinterOptions(Boolean *colorRibbon, Boolean *sheetFeeder, Boolean *iw1Mode, Boolean *noReverse); /* number of active connections (i.e. not idle) */ int GetActiveClientConnections(void); /* number of print jobs we have successfully received and spooled */ long JobsSpooled(void); /* server routines */ pascal int SLInit (EntityPtr printerName, /* AppleTalk entity name to serve */ int flowQuantum, /* # of 512-byte buffers for read */ PAPStatusPtr statusBuf, /* initial status is returned here */ int *refNum); /* server refNum for this instance */ pascal int PAPRegName (int refNum, /* server refNum for this name */ EntityPtr printerName); /* AppleTalk entity name to register */ pascal int PAPRemName (int refNum, /* server refNum for this name */ EntityPtr printerName); /* AppleTalk entity name to remove */ pascal int HeresStatus (int refNum, /* server refNum for updated status */ PAPStatusPtr statusBuf);/* new status string for this server */ pascal int SLClose (int refNum); /* server refNum from SLInit */ /* client routines */ pascal int PAPOpen (int *refNum, /* returned: connection ID ref */ EntityPtr printerName, /* AppleTalk entity name */ int flowQuantum, /* # of 512-byte buffers for read */ PAPStatusPtr statusBuf, /* returned: status string */ int *compState); /* returned: status, 0=success */ pascal int PAPStatus (EntityPtr printerName, /* AppleTalk entity name */ PAPStatusPtr statusBuf, /* returned: status string */ long int *nodeAddr); /* returned: node address */ pascal int PAPRead (int refNum, /* connection ID from PAPOpen */ char *rxBuf, /* buffer in which to read the data */ int *rxBufLen, /* size of the data read on output */ int *eofByte, /* set to positive value when EOF */ int *compState); /* returned: status, 0=success */ pascal int PAPWrite (int refNum, /* connection ID from PAPOpen */ char *txBuf, /* buffer with data to be written */ int txBufLen, /* size of the data to be written */ int eofByte, /* set to positive on last buffer */ int *compState); /* returned: status, 0=success */ pascal int PAPClose (int refNum); /* connection ID from PAPOpen */ pascal int PAPUnload (void); /* close connections, free storage */ #ifdef __cplusplus } #endif #endif /* __PRINTER_ACCESS_PROTOCOL__ */