1: /* $Header: courier.h,v 2.0 85/11/21 07:22:05 jqj Exp $ */
2: /*
3: $Log: courier.h,v $
4: * Revision 2.0 85/11/21 07:22:05 jqj
5: * 4.3BSD standard release
6: *
7: * Revision 1.3 85/10/23 16:43:30 root
8: * Probably correct versions of basic conversion operators for the Gould.
9: *
10: * Revision 1.2 85/10/21 12:49:15 root
11: * Gould version: definitions for MoveLong, etc. (the MoveLong routine is in misc.c)
12: *
13: * Revision 1.2 85/10/17 16:46:55 jqj
14: * first Gould version: definitions for MoveLong etc.
15: *
16: * Revision 1.5 85/05/23 06:18:06 jqj
17: * Public Beta-test version, released 24 May 1985
18: *
19: * Revision 1.3 85/03/11 16:36:54 jqj
20: * Public alpha-test version, released 11 March 1985
21: *
22: * Revision 1.2 85/01/27 07:37:18 jqj
23: * finished but undebugged version
24: *
25: */
26:
27: #ifndef COURIERVERSION
28: /*
29: * the version of Courier we support
30: */
31: #define COURIERVERSION 3
32:
33: /*
34: * Predefined Courier types.
35: */
36: typedef char Boolean;
37: typedef unsigned short Cardinal;
38: typedef unsigned long LongCardinal;
39: typedef short Integer;
40: typedef long LongInteger;
41: typedef char *String;
42: typedef unsigned short Unspecified;
43: typedef unsigned long LongUnspecified;
44: typedef int NilRecord;
45:
46:
47: /*
48: * Low-level byte moving, with byte-swapping.
49: * Use these definitions for VAX and other low-enders.
50: */
51: #if vax
52: #define externalize_Boolean(p, buf) (*(short*)(buf) = *((char*)(p))<<8, 1)
53: #define internalize_Boolean(p, buf) (*(char*)(p) = *((char*)(buf)+1), 1)
54: #define MoveShort(a, b) (*(char*)(b) = *((char*)(a)+1),\
55: *((char*)(b)+1) = *(char*)(a),1)
56: #define MoveLong(a, b) (*(char*)(b) = *((char*)(a)+3),\
57: *((char*)(b)+1) = *((char*)(a)+2),\
58: *((char*)(b)+2) = *((char*)(a)+1),\
59: *((char*)(b)+3) = *(char*)(a), 2)
60: #endif
61:
62: /*
63: * Low-level byte moving, without byte-swapping.
64: * Use these definitions for SUN and other high-enders.
65: */
66: #if sun
67: #define externalize_Boolean(p, buf) (*(Unspecified*)(buf) = 1&*(char*)(p), 1)
68: #define internalize_Boolean(p, buf) (*(char*)(p) = 1&*(Unspecified*)(buf), 1)
69: #define MoveShort(a, b) (*(short *)(b) = *(short *)(a),1)
70: #define MoveLong(a, b) (*(long *)(b) = *(long *)(a),2)
71: #endif
72:
73: /*
74: * Low-level byte moving, without byte-swapping.
75: * Use these definitions for sel and other high-enders that require
76: * longword alignment.
77: */
78: #if sel
79: #define externalize_Boolean(p, buf) (*(Unspecified*)(buf) = 1&*(char*)(p), 1)
80: #define internalize_Boolean(p, buf) (*(p) = 1&*(Unspecified*)(buf), 1)
81: #define MoveShort(a, b) (*(short *)(b) = *(short *)(a),1)
82: int MoveLong();
83: #endif
84:
85: /*
86: * sizeof_Foo(p) is a function that returns the externalized size of
87: * the variable specified as argument (assumed to be of type Foo).
88: * clear_Foo(p) is a function that deallocates any components of Foo.
89: * externalize_Foo translates a variable from C form to external
90: * serialized form.
91: * internalize_Foo translates a variable from external serializedform
92: * to internal C form
93: */
94: #define sizeof_NilRecord(p) 0
95: #define clear_NilRecord(p)
96: #define externalize_NilRecord(p, buf) 0
97: #define internalize_NilRecord(p, buf) 0
98:
99: #define sizeof_Boolean(p) 1
100: #define clear_Boolean(p)
101:
102: #define sizeof_Cardinal(p) 1
103: #define clear_Cardinal(p)
104: #define externalize_Cardinal(p, buf) MoveShort(p, buf)
105: #define internalize_Cardinal(p, buf) MoveShort(buf, p)
106:
107: #define sizeof_LongCardinal(p) 2
108: #define clear_LongCardinal(p)
109: #define externalize_LongCardinal(p, buf) MoveLong(p, buf)
110: #define internalize_LongCardinal(p, buf) MoveLong(buf, p)
111:
112: #define sizeof_Integer(p) 1
113: #define clear_Integer(p)
114: #define externalize_Integer(p, buf) MoveShort(p, buf)
115: #define internalize_Integer(p, buf) MoveShort(buf, p)
116:
117: #define sizeof_LongInteger(p) 2
118: #define clear_LongInteger(p)
119: #define externalize_LongInteger(p, buf) MoveLong(p, buf)
120: #define internalize_LongInteger(p, buf) MoveLong(buf, p)
121:
122: #define sizeof_Unspecified(p) 1
123: #define clear_Unspecified(p)
124: #define externalize_Unspecified(p, buf) MoveShort(p, buf)
125: #define internalize_Unspecified(p, buf) MoveShort(buf, p)
126:
127: #define sizeof_LongUnspecified(p) 2
128: #define clear_LongUnspecified(p)
129: #define externalize_LongUnspecified(p, buf) MoveLong(p, buf)
130: #define internalize_LongUnspecified(p, buf) MoveLong(buf, p)
131:
132:
133: /*
134: * SPP stream types used by Courier
135: */
136: #define SPPSST_RPC 0
137: #define SPPSST_BDT 1
138: #define SPPSST_END 254
139: #define SPPSST_ENDREPLY 255
140:
141: /*
142: * the following should be in xn.h or spp.h
143: */
144: #define IDPPORT_COURIER 5
145: #ifndef MAXWORDS
146: #define MAXWORDS 267
147: #endif
148: #ifndef SPPMAXDATA
149: #define SPPMAXDATA (MAXWORDS*2)
150: #endif
151:
152: /*
153: * For streams
154: */
155: typedef enum {
156: nextSegment = 0,
157: lastSegment = 1
158: } StreamEnumerator;
159: #define sizeof_enumeration
160: #define clear_enumeration
161: #define externalize_enumeration
162: #define internalize_enumeration
163:
164:
165: /*
166: * miscellaneous structures and values used by Courier
167: * runtimes
168: */
169:
170: /*
171: * message types for Courier messages (should be mixed case?)
172: * (should only be of interest to the runtimes)
173: */
174: #define CALL 0
175: #define REJECT 1
176: #define RETURN 2
177: #define ABORT 3
178:
179: /*
180: * components of Courier error messages
181: */
182:
183: typedef struct {
184: Cardinal lowest;
185: Cardinal highest;
186: } ImplementedVersionNumbers;
187:
188: typedef struct {
189: enum {
190: unspecifiedError = 65535,
191: invalidArgument = 3,
192: noSuchProcedureValue = 2,
193: noSuchVersionNumber = 1,
194: noSuchProgramNumber = 0
195: } designator;
196: union {
197: NilRecord u_noSuchProgramNumber;
198: #define noSuchProgramNumber_case u.u_noSuchProgramNumber
199: ImplementedVersionNumbers u_noSuchVersionNumber;
200: #define noSuchVersionNumber_case u.u_noSuchVersionNumber
201: NilRecord u_noSuchProcedureValue;
202: #define noSuchProcedureValue_case u.u_noSuchProcedureValue
203: NilRecord u_invalidArgument;
204: #define invalidArgument_case u.u_invalidArgument
205: NilRecord u_unspecifiedError;
206: #define unspecifiedError_case u.u_unspecifiedError
207: } u;
208: } rejectionDetails;
209:
210: /*
211: * Macro for unpacking error arguments given a typedef and a field name
212: */
213: #define CourierErrArgs(type,field) \
214: (((type *)Exception.Message)->field)
215:
216: /*
217: * miscellaneous constants
218: */
219:
220: #ifndef TRUE
221: #define TRUE (1)
222: #endif
223:
224: #ifndef FALSE
225: #define FALSE (0)
226: #endif
227:
228: #ifndef NULL
229: #define NULL ((char*) 0)
230: #endif
231:
232:
233: /*
234: * exceptions defined in Courier
235: */
236:
237: #define REJECT_ERROR 65535
238: #define PROTOCOL_VIOLATION 65534
239:
240: /* plus all user-defined ERROR values, offset by ERROR_OFFSET */
241: #define ERROR_OFFSET 65536
242:
243: /*
244: * External declarations.
245: */
246:
247: extern Unspecified *Allocate();
248: extern Unspecified *ReceiveCallMessage(), *ReceiveReturnMessage();
249: extern Unspecified *ReadMessage();
250: extern int BDTwrite(),BDTclosewrite(),BDTread();
251: extern int sppclose(),sppclosereply();
252:
253: #endif COURIERVERSION