AmendHub

Download

thecloud

/

SimpleSpooler

/

PAP.h

 

(View History)

thecloud   refactor StartSpooler code to allow auto-running server Latest amendment: 3 on 2026-07-29

1 /*
2 * PAP.h
3 * C Interface to PAP (Printer Access Protocol) routines
4 *
5 * Written by: Ken McLeod, 2026-01-07
6 * Last update: 2026-03-27
7 *
8 * This software is provided as-is, with no warranties expressed or implied,
9 * under the terms of the BSD 2-Clause License. See separate "LICENSE" file.
10 */
11
12 #ifndef __PRINTER_ACCESS_PROTOCOL__
13 #define __PRINTER_ACCESS_PROTOCOL__
14
15 #include <Types.h>
16 #include <AppleTalk.h>
17
18 typedef struct {
19 long int unused;
20 char statusStr[256];
21 } PAPStatusRec, *PAPStatusPtr;
22
23 /* PAP function IDs */
24 #define kPAPOpenConn 1
25 #define kPAPOpenConnReply 2
26 #define kPAPSendData 3
27 #define kPAPData 4
28 #define kPAPTickle 5
29 #define kPAPCloseConn 6
30 #define kPAPCloseConnReply 7
31 #define kPAPSendStatus 8
32 #define kPAPStatus 9
33
34 /* other constants */
35 #define kPAPMinQuantum 1
36 #define kPAPMaxQuantum 8
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
42 /* call this in main event loop to process incoming requests */
43 void CheckATP(void);
44
45 /* call this prior to SLInit to specify emulated printer options */
46 void SetPrinterOptions(Boolean colorRibbon, Boolean sheetFeeder,
47 Boolean iw1Mode, Boolean noReverse);
48
49 /* accessor for options */
50 void GetPrinterOptions(Boolean *colorRibbon, Boolean *sheetFeeder,
51 Boolean *iw1Mode, Boolean *noReverse);
52
53 /* number of active connections (i.e. not idle) */
54 int GetActiveClientConnections(void);
55
56 /* number of print jobs we have successfully received and spooled */
57 long JobsSpooled(void);
58
59
60 /* server routines */
61
62 pascal int SLInit (EntityPtr printerName, /* AppleTalk entity name to serve */
63 int flowQuantum, /* # of 512-byte buffers for read */
64 PAPStatusPtr statusBuf, /* initial status is returned here */
65 int *refNum); /* server refNum for this instance */
66
67 pascal int PAPRegName (int refNum, /* server refNum for this name */
68 EntityPtr printerName); /* AppleTalk entity name to register */
69
70 pascal int PAPRemName (int refNum, /* server refNum for this name */
71 EntityPtr printerName); /* AppleTalk entity name to remove */
72
73 pascal int HeresStatus (int refNum, /* server refNum for updated status */
74 PAPStatusPtr statusBuf);/* new status string for this server */
75
76 pascal int SLClose (int refNum); /* server refNum from SLInit */
77
78
79 /* client routines */
80
81 pascal int PAPOpen (int *refNum, /* returned: connection ID ref */
82 EntityPtr printerName, /* AppleTalk entity name */
83 int flowQuantum, /* # of 512-byte buffers for read */
84 PAPStatusPtr statusBuf, /* returned: status string */
85 int *compState); /* returned: status, 0=success */
86
87 pascal int PAPStatus (EntityPtr printerName, /* AppleTalk entity name */
88 PAPStatusPtr statusBuf, /* returned: status string */
89 long int *nodeAddr); /* returned: node address */
90
91 pascal int PAPRead (int refNum, /* connection ID from PAPOpen */
92 char *rxBuf, /* buffer in which to read the data */
93 int *rxBufLen, /* size of the data read on output */
94 int *eofByte, /* set to positive value when EOF */
95 int *compState); /* returned: status, 0=success */
96
97 pascal int PAPWrite (int refNum, /* connection ID from PAPOpen */
98 char *txBuf, /* buffer with data to be written */
99 int txBufLen, /* size of the data to be written */
100 int eofByte, /* set to positive on last buffer */
101 int *compState); /* returned: status, 0=success */
102
103 pascal int PAPClose (int refNum); /* connection ID from PAPOpen */
104
105 pascal int PAPUnload (void); /* close connections, free storage */
106
107
108 #ifdef __cplusplus
109 }
110 #endif
111
112 #endif /* __PRINTER_ACCESS_PROTOCOL__ */