ICElib.h revision 266e564d
1/* $Xorg: ICElib.h,v 1.5 2001/02/09 02:03:26 xorgcvs Exp $ */
2/******************************************************************************
3
4
5Copyright 1993, 1998  The Open Group
6
7Permission to use, copy, modify, distribute, and sell this software and its
8documentation for any purpose is hereby granted without fee, provided that
9the above copyright notice appear in all copies and that both that
10copyright notice and this permission notice appear in supporting
11documentation.
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
19OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of The Open Group shall not be
24used in advertising or otherwise to promote the sale, use or other dealings
25in this Software without prior written authorization from The Open Group.
26
27Author: Ralph Mor, X Consortium
28******************************************************************************/
29/* $XFree86: xc/lib/ICE/ICElib.h,v 3.4 2001/12/14 19:53:35 dawes Exp $ */
30
31#ifndef _ICELIB_H_
32#define _ICELIB_H_
33
34#include <X11/ICE/ICE.h>
35#include <X11/Xfuncproto.h>
36
37#define Bool int
38#define Status int
39#define True 1
40#define False 0
41
42typedef void *IcePointer;
43
44typedef enum {
45    IcePoAuthHaveReply,
46    IcePoAuthRejected,
47    IcePoAuthFailed,
48    IcePoAuthDoneCleanup
49} IcePoAuthStatus;
50
51typedef enum {
52    IcePaAuthContinue,
53    IcePaAuthAccepted,
54    IcePaAuthRejected,
55    IcePaAuthFailed
56} IcePaAuthStatus;
57
58typedef enum {
59    IceConnectPending,
60    IceConnectAccepted,
61    IceConnectRejected,
62    IceConnectIOError
63} IceConnectStatus;
64
65typedef enum {
66    IceProtocolSetupSuccess,
67    IceProtocolSetupFailure,
68    IceProtocolSetupIOError,
69    IceProtocolAlreadyActive
70} IceProtocolSetupStatus;
71
72typedef enum {
73    IceAcceptSuccess,
74    IceAcceptFailure,
75    IceAcceptBadMalloc
76} IceAcceptStatus;
77
78typedef enum {
79    IceClosedNow,
80    IceClosedASAP,
81    IceConnectionInUse,
82    IceStartedShutdownNegotiation
83} IceCloseStatus;
84
85typedef enum {
86    IceProcessMessagesSuccess,
87    IceProcessMessagesIOError,
88    IceProcessMessagesConnectionClosed
89} IceProcessMessagesStatus;
90
91typedef struct {
92    unsigned long	sequence_of_request;
93    int			major_opcode_of_request;
94    int			minor_opcode_of_request;
95    IcePointer		reply;
96} IceReplyWaitInfo;
97
98typedef struct _IceConn *IceConn;
99typedef struct _IceListenObj *IceListenObj;
100
101typedef void (*IceWatchProc) (
102    IceConn		/* iceConn */,
103    IcePointer		/* clientData */,
104    Bool		/* opening */,
105    IcePointer *	/* watchData */
106);
107
108typedef void (*IcePoProcessMsgProc) (
109    IceConn 		/* iceConn */,
110    IcePointer		/* clientData */,
111    int			/* opcode */,
112    unsigned long	/* length */,
113    Bool		/* swap */,
114    IceReplyWaitInfo *  /* replyWait */,
115    Bool *		/* replyReadyRet */
116);
117
118typedef void (*IcePaProcessMsgProc) (
119    IceConn 		/* iceConn */,
120    IcePointer		/* clientData */,
121    int			/* opcode */,
122    unsigned long	/* length */,
123    Bool		/* swap */
124);
125
126typedef struct {
127    int			 major_version;
128    int			 minor_version;
129    IcePoProcessMsgProc  process_msg_proc;
130} IcePoVersionRec;
131
132typedef struct {
133    int			 major_version;
134    int			 minor_version;
135    IcePaProcessMsgProc  process_msg_proc;
136} IcePaVersionRec;
137
138typedef IcePoAuthStatus (*IcePoAuthProc) (
139    IceConn		/* iceConn */,
140    IcePointer *	/* authStatePtr */,
141    Bool		/* cleanUp */,
142    Bool		/* swap */,
143    int			/* authDataLen */,
144    IcePointer		/* authData */,
145    int *		/* replyDataLenRet */,
146    IcePointer *	/* replyDataRet */,
147    char **		/* errorStringRet */
148);
149
150typedef IcePaAuthStatus (*IcePaAuthProc) (
151    IceConn		/* iceConn */,
152    IcePointer *	/* authStatePtr */,
153    Bool		/* swap */,
154    int			/* authDataLen */,
155    IcePointer		/* authData */,
156    int *		/* replyDataLenRet */,
157    IcePointer *	/* replyDataRet */,
158    char **		/* errorStringRet */
159);
160
161typedef Bool (*IceHostBasedAuthProc) (
162    char *		/* hostName */
163);
164
165typedef Status (*IceProtocolSetupProc) (
166    IceConn 		/* iceConn */,
167    int			/* majorVersion */,
168    int			/* minorVersion */,
169    char *		/* vendor */,
170    char *		/* release */,
171    IcePointer *	/* clientDataRet */,
172    char **		/* failureReasonRet */
173);
174
175typedef void (*IceProtocolActivateProc) (
176    IceConn 		/* iceConn */,
177    IcePointer		/* clientData */
178);
179
180typedef void (*IceIOErrorProc) (
181    IceConn 		/* iceConn */
182);
183
184typedef void (*IcePingReplyProc) (
185    IceConn 		/* iceConn */,
186    IcePointer		/* clientData */
187);
188
189typedef void (*IceErrorHandler) (
190    IceConn 		/* iceConn */,
191    Bool		/* swap */,
192    int			/* offendingMinorOpcode */,
193    unsigned long 	/* offendingSequence */,
194    int 		/* errorClass */,
195    int			/* severity */,
196    IcePointer		/* values */
197);
198
199typedef void (*IceIOErrorHandler) (
200    IceConn 		/* iceConn */
201);
202
203
204/*
205 * Function prototypes
206 */
207
208_XFUNCPROTOBEGIN
209
210extern int IceRegisterForProtocolSetup (
211    char *			/* protocolName */,
212    char *			/* vendor */,
213    char *			/* release */,
214    int				/* versionCount */,
215    IcePoVersionRec *		/* versionRecs */,
216    int				/* authCount */,
217    char **			/* authNames */,
218    IcePoAuthProc *		/* authProcs */,
219    IceIOErrorProc		/* IOErrorProc */
220);
221
222extern int IceRegisterForProtocolReply (
223    char *			/* protocolName */,
224    char *			/* vendor */,
225    char *			/* release */,
226    int				/* versionCount */,
227    IcePaVersionRec *		/* versionRecs */,
228    int				/* authCount */,
229    char **			/* authNames */,
230    IcePaAuthProc *		/* authProcs */,
231    IceHostBasedAuthProc	/* hostBasedAuthProc */,
232    IceProtocolSetupProc	/* protocolSetupProc */,
233    IceProtocolActivateProc	/* protocolActivateProc */,
234    IceIOErrorProc		/* IOErrorProc */
235);
236
237extern IceConn IceOpenConnection (
238    char *		/* networkIdsList */,
239    IcePointer		/* context */,
240    Bool		/* mustAuthenticate */,
241    int			/* majorOpcodeCheck */,
242    int			/* errorLength */,
243    char *		/* errorStringRet */
244);
245
246extern IcePointer IceGetConnectionContext (
247    IceConn		/* iceConn */
248);
249
250extern Status IceListenForConnections (
251    int *		/* countRet */,
252    IceListenObj **	/* listenObjsRet */,
253    int			/* errorLength */,
254    char *		/* errorStringRet */
255);
256
257extern Status IceListenForWellKnownConnections (
258    char *		/* port */,
259    int *		/* countRet */,
260    IceListenObj **	/* listenObjsRet */,
261    int			/* errorLength */,
262    char *		/* errorStringRet */
263);
264
265extern int IceGetListenConnectionNumber (
266    IceListenObj	/* listenObj */
267);
268
269extern char *IceGetListenConnectionString (
270    IceListenObj	/* listenObj */
271);
272
273extern char *IceComposeNetworkIdList (
274    int			/* count */,
275    IceListenObj *	/* listenObjs */
276);
277
278extern void IceFreeListenObjs (
279    int			/* count */,
280    IceListenObj *	/* listenObjs */
281);
282
283extern void IceSetHostBasedAuthProc (
284    IceListenObj		/* listenObj */,
285    IceHostBasedAuthProc   	/* hostBasedAuthProc */
286);
287
288extern IceConn IceAcceptConnection (
289    IceListenObj	/* listenObj */,
290    IceAcceptStatus *	/* statusRet */
291);
292
293extern void IceSetShutdownNegotiation (
294    IceConn		/* iceConn */,
295    Bool		/* negotiate */
296);
297
298extern Bool IceCheckShutdownNegotiation (
299    IceConn		/* iceConn */
300);
301
302extern IceCloseStatus IceCloseConnection (
303    IceConn		/* iceConn */
304);
305
306extern Status IceAddConnectionWatch (
307    IceWatchProc		/* watchProc */,
308    IcePointer			/* clientData */
309);
310
311extern void IceRemoveConnectionWatch (
312    IceWatchProc		/* watchProc */,
313    IcePointer			/* clientData */
314);
315
316extern IceProtocolSetupStatus IceProtocolSetup (
317    IceConn		/* iceConn */,
318    int 		/* myOpcode */,
319    IcePointer		/* clientData */,
320    Bool		/* mustAuthenticate */,
321    int	*		/* majorVersionRet */,
322    int	*		/* minorVersionRet */,
323    char **		/* vendorRet */,
324    char **		/* releaseRet */,
325    int			/* errorLength */,
326    char *		/* errorStringRet */
327);
328
329extern Status IceProtocolShutdown (
330    IceConn		/* iceConn */,
331    int			/* majorOpcode */
332);
333
334extern IceProcessMessagesStatus IceProcessMessages (
335    IceConn		/* iceConn */,
336    IceReplyWaitInfo *	/* replyWait */,
337    Bool *		/* replyReadyRet */
338);
339
340extern Status IcePing (
341   IceConn		/* iceConn */,
342   IcePingReplyProc	/* pingReplyProc */,
343   IcePointer		/* clientData */
344);
345
346extern char *IceAllocScratch (
347   IceConn		/* iceConn */,
348   unsigned long	/* size */
349);
350
351extern int IceFlush (
352   IceConn		/* iceConn */
353);
354
355extern int IceGetOutBufSize (
356   IceConn		/* iceConn */
357);
358
359extern int IceGetInBufSize (
360   IceConn		/* iceConn */
361);
362
363extern IceConnectStatus IceConnectionStatus (
364    IceConn		/* iceConn */
365);
366
367extern char *IceVendor (
368    IceConn		/* iceConn */
369);
370
371extern char *IceRelease (
372    IceConn		/* iceConn */
373);
374
375extern int IceProtocolVersion (
376    IceConn		/* iceConn */
377);
378
379extern int IceProtocolRevision (
380    IceConn		/* iceConn */
381);
382
383extern int IceConnectionNumber (
384    IceConn		/* iceConn */
385);
386
387extern char *IceConnectionString (
388    IceConn		/* iceConn */
389);
390
391extern unsigned long IceLastSentSequenceNumber (
392    IceConn		/* iceConn */
393);
394
395extern unsigned long IceLastReceivedSequenceNumber (
396    IceConn		/* iceConn */
397);
398
399extern Bool IceSwapping (
400    IceConn		/* iceConn */
401);
402
403extern IceErrorHandler IceSetErrorHandler (
404    IceErrorHandler 	/* handler */
405);
406
407extern IceIOErrorHandler IceSetIOErrorHandler (
408    IceIOErrorHandler 	/* handler */
409);
410
411extern char *IceGetPeerName (
412    IceConn		/* iceConn */
413);
414
415/*
416 * Multithread Routines
417 */
418
419extern Status IceInitThreads (
420    void
421);
422
423extern void IceAppLockConn (
424    IceConn		/* iceConn */
425);
426
427extern void IceAppUnlockConn (
428    IceConn		/* iceConn */
429);
430
431_XFUNCPROTOEND
432
433#endif /* _ICELIB_H_ */
434