1 /*
2  * Copyright 1993 Network Computing Devices, Inc.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and
5  * its documentation for any purpose is hereby granted without fee, provided
6  * that the above copyright notice appear in all copies and that both that
7  * copyright notice and this permission notice appear in supporting
8  * documentation, and that the name Network Computing Devices, Inc. not be
9  * used in advertising or publicity pertaining to distribution of this
10  * software without specific, written prior permission.
11  *
12  * THIS SOFTWARE IS PROVIDED 'AS-IS'.  NETWORK COMPUTING DEVICES, INC.,
13  * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
14  * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
15  * PARTICULAR PURPOSE, OR NONINFRINGEMENT.  IN NO EVENT SHALL NETWORK
16  * COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
17  * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
18  * OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
19  * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
20  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21  *
22  * $NCDId: @(#)Alibint.h,v 1.20 1995/12/28 19:44:51 greg Exp $
23  */
24 
25 /* Portions derived from */
26 /* $XConsortium: Xlibint.h,v 11.96 92/01/30 10:22:57 rws Exp $ */
27 /* Copyright 1984, 1985, 1987, 1989  Massachusetts Institute of Technology */
28 
29 /*
30 Permission to use, copy, modify, distribute, and sell this software and its
31 documentation for any purpose is hereby granted without fee, provided that
32 the above copyright notice appear in all copies and that both that
33 copyright notice and this permission notice appear in supporting
34 documentation, and that the name of M.I.T. not be used in advertising or
35 publicity pertaining to distribution of the software without specific,
36 written prior permission.  M.I.T. makes no representations about the
37 suitability of this software for any purpose.  It is provided "as is"
38 without express or implied warranty.
39 */
40 
41 /*
42  *	Xlibint.h - Header definition and support file for the internal
43  *	support routines used by the C subroutine interface
44  *	library (Xlib) to the X Window System.
45  *
46  *	Warning, there be dragons here....
47  */
48 
49 #ifndef _NCD_ALIBINT_H_
50 #define _NCD_ALIBINT_H_
51 
52 #include <audio/audiolib.h>
53 
54 /* round up to a four byte boundary */
55 #define PAD4(x)				(((x) + 3) & ~3)
56 
57 /* useful macros for transfering attributes */
58 #define _xfer(s, d, x)	(d).x = (s).x
59 
60 #define _xferCommonPart(s, d)						       \
61 {									       \
62     _xfer(s, d, value_mask);						       \
63     _xfer(s, d, changable_mask);					       \
64     _xfer(s, d, id);							       \
65     _xfer(s, d, kind);							       \
66     _xfer(s, d, use);							       \
67     _xfer(s, d, format);						       \
68     _xfer(s, d, num_tracks);						       \
69     _xfer(s, d, access);						       \
70     _xfer((s).description, (d).description, type);			       \
71     _xfer((s).description, (d).description, len);			       \
72 }
73 
74 #define _xferDevicePart(s, d)						       \
75 {									       \
76     _xfer(s, d, min_sample_rate);					       \
77     _xfer(s, d, max_sample_rate);					       \
78     _xfer(s, d, location);						       \
79     _xfer(s, d, gain);							       \
80     _xfer(s, d, line_mode);						       \
81     _xfer(s, d, num_children);						       \
82 }
83 
84 #define _xferBucketPart(s, d)						       \
85 {									       \
86     _xfer(s, d, sample_rate);						       \
87     _xfer(s, d, num_samples);						       \
88 }
89 
90 #define _xferDeviceAttributes(s, d)					       \
91 {									       \
92     _xferCommonPart((s)->common, (d).common);				       \
93     _xferDevicePart((s)->device, (d).device);				       \
94 }
95 
96 #define _xferBucketAttributes(s, d)					       \
97 {									       \
98     _xferCommonPart((s)->common, (d).common);				       \
99     _xferBucketPart((s)->bucket, (d).bucket);				       \
100 }
101 
102 /*
103  * define the following if you want the _AuData macro to be a procedure instead
104  */
105 #ifdef CRAY
106 #define _AuDataRoutineIsProcedure
107 #endif /* CRAY */
108 
109 /*
110  * _QEvent datatype for use in input queueing.
111  */
112 typedef struct _AuSQEvent {
113     struct _AuSQEvent *next;
114     AuEvent event;
115 } _AuQEvent;
116 
117 #include <stdio.h>
118 #include <audio/Aproto.h>
119 #include <errno.h>
120 #define _AUBCOPYFUNC _Aubcopy
121 #include <audio/Afuncs.h>
122 #include <audio/Aosdefs.h>
123 
124 /* Utek leaves kernel macros around in include files (bleah) */
125 #ifdef dirty
126 #undef dirty
127 #endif
128 
129 #ifdef CRAY
130 #define WORD64
131 #endif
132 
133 #ifndef AU_NOT_STDC_ENV
134 # include <stdlib.h>
135 # include <string.h>
136 #else
137 # ifndef hpux
138    extern char *malloc(), *realloc(), *calloc();
139 # endif
140 void exit();
141 #ifdef SYSV
142 #include <string.h>
143 #else
144 #include <strings.h>
145 #endif
146 #endif
147 #if defined(macII) && !defined(__STDC__)  /* stdlib.h fails to define these */
148 extern char *malloc(), *realloc(), *calloc();
149 #endif /* macII */
150 
151 /*
152  * The following definitions can be used for locking requests in multi-threaded
153  * address spaces.
154  */
155 #include "mutex.h"
156 
157 #define Aufree(ptr) free((ptr))
158 
159 /*
160  * Note that some machines do not return a valid pointer for malloc(0), in
161  * which case we provide an alternate under the control of the
162  * define MALLOC_0_RETURNS_NULL.  This is necessary because some
163  * Aulib code expects malloc(0) to return a valid pointer to storage.
164  */
165 #ifdef MALLOC_0_RETURNS_NULL
166 
167 # define Aumalloc(size) malloc(((size) > 0 ? (size) : 1))
168 # define Aurealloc(ptr, size) realloc((ptr), ((size) > 0 ? (size) : 1))
169 # define Aucalloc(nelem, elsize) calloc(((nelem) > 0 ? (nelem) : 1), (elsize))
170 
171 #else
172 
173 # define Aumalloc(size) malloc((size))
174 # define Aurealloc(ptr, size) realloc((ptr), (size))
175 # define Aucalloc(nelem, elsize) calloc((nelem), (elsize))
176 
177 #endif /* MALLOC_0_RETURNS_NULL */
178 
179 #ifndef NULL
180 #define NULL 0
181 #endif
182 #define LOCKED 1
183 #define UNLOCKED 0
184 
185 #ifdef notdef
186 extern int errno;			/* Internal system error number. */
187 #endif
188 
189 #ifndef BUFSIZE
190 #define BUFSIZE 2048			/* Au output buffer size. */
191 #endif
192 
193 /*
194  * display flags
195  */
196 #define AuServerFlagsIOError	(1L << 0)
197 #define AuServerFlagsClosing	(1L << 1)
198 
199 /*
200  * Au Protocol packetizing macros.
201  */
202 
203 /*   Need to start requests on 64 bit word boundries
204  *   on a CRAY computer so add a NoOp (127) if needed.
205  *   A character pointer on a CRAY computer will be non-zero
206  *   after shifting right 61 bits of it is not pointing to
207  *   a word boundary.
208  */
209 #ifdef WORD64
210 #define WORD64ALIGN if ((AuInt32)aud->bufptr >> 61) {\
211            aud->last_req = aud->bufptr;\
212            *(aud->bufptr)   = Au_NoOperation;\
213            *(aud->bufptr+1) =  0;\
214            *(aud->bufptr+2) =  0;\
215            *(aud->bufptr+3) =  1;\
216              aud->request++;\
217              aud->bufptr += 4;\
218          }
219 #else /* else does not require alignment on 64-bit boundaries */
220 #define WORD64ALIGN
221 #endif /* WORD64 */
222 
223 
224 /*
225  * _AuGetReq - Get the next avilable Au request packet in the buffer and
226  * return it.
227  *
228  * "name" is the name of the request, e.g. CreatePixmap, OpenFont, etc.
229  * "req" is the name of the request pointer.
230  *
231  */
232 #ifdef UNIXCPP
233 #error "bummer"
234 #endif
235 #if defined(__STDC__) && !defined(UNIXCPP)
236 #define _AuGetReq(name, req, aud) \
237         WORD64ALIGN\
238 	if ((aud->bufptr + SIZEOF(au##name##Req)) > aud->bufmax)\
239 		_AuFlush(aud);\
240 	req = (au##name##Req *)(aud->last_req = aud->bufptr);\
241 	req->reqType = Au_##name;\
242 	req->length = (SIZEOF(au##name##Req))>>2;\
243 	aud->bufptr += SIZEOF(au##name##Req);\
244 	aud->request++
245 
246 #else  /* non-ANSI C uses empty comment instead of "##" for token concatenation */
247 #define _AuGetReq(name, req, aud) \
248         WORD64ALIGN\
249 	if ((aud->bufptr + SIZEOF(au/**/name/**/Req)) > aud->bufmax)\
250 		_AuFlush(aud);\
251 	req = (au/**/name/**/Req *)(aud->last_req = aud->bufptr);\
252 	req->reqType = Au_/**/name;\
253 	req->length = (SIZEOF(au/**/name/**/Req))>>2;\
254 	aud->bufptr += SIZEOF(au/**/name/**/Req);\
255 	aud->request++
256 #endif
257 
258 /* _AuGetReqExtra is the same as _AuGetReq, but allocates "n" additional
259    bytes after the request. "n" must be a multiple of 4!  */
260 
261 #if  defined(__STDC__) && !defined(UNIXCPP)
262 #define _AuGetReqExtra(name, n, req, aud) \
263         WORD64ALIGN\
264 	if ((aud->bufptr + SIZEOF(au##name##Req) + n) > aud->bufmax)\
265 		_AuFlush(aud);\
266 	req = (au##name##Req *)(aud->last_req = aud->bufptr);\
267 	req->reqType = Au_##name;\
268 	req->length = (SIZEOF(au##name##Req) + n)>>2;\
269 	aud->bufptr += SIZEOF(au##name##Req) + n;\
270 	aud->request++
271 #else
272 #define _AuGetReqExtra(name, n, req, aud) \
273         WORD64ALIGN\
274 	if ((aud->bufptr + SIZEOF(au/**/name/**/Req) + n) > aud->bufmax)\
275 		_AuFlush(aud);\
276 	req = (au/**/name/**/Req *)(aud->last_req = aud->bufptr);\
277 	req->reqType = Au_/**/name;\
278 	req->length = (SIZEOF(au/**/name/**/Req) + n)>>2;\
279 	aud->bufptr += SIZEOF(au/**/name/**/Req) + n;\
280 	aud->request++
281 #endif
282 
283 
284 /*
285  * _AuGetResReq is for those requests that have a resource ID
286  * (Window, Pixmap, GContext, etc.) as their single argument.
287  * "rid" is the name of the resource.
288  */
289 
290 #if  defined(__STDC__) && !defined(UNIXCPP)
291 #define _AuGetResReq(name, rid, req, aud) \
292         WORD64ALIGN\
293 	if ((aud->bufptr + SIZEOF(auResourceReq)) > aud->bufmax)\
294 	    _AuFlush(aud);\
295 	req = (auResourceReq *) (aud->last_req = aud->bufptr);\
296 	req->reqType = Au_##name;\
297 	req->length = 2;\
298 	req->id = (rid);\
299 	aud->bufptr += SIZEOF(auResourceReq);\
300 	aud->request++
301 #else
302 #define _AuGetResReq(name, rid, req, aud) \
303         WORD64ALIGN\
304 	if ((aud->bufptr + SIZEOF(auResourceReq)) > aud->bufmax)\
305 	    _AuFlush(aud);\
306 	req = (auResourceReq *) (aud->last_req = aud->bufptr);\
307 	req->reqType = Au_/**/name;\
308 	req->length = 2;\
309 	req->id = (rid);\
310 	aud->bufptr += SIZEOF(auResourceReq);\
311 	aud->request++
312 #endif
313 
314 /*
315  * _AuGetEmptyReq is for those requests that have no arguments
316  * at all.
317  */
318 #if  defined(__STDC__) && !defined(UNIXCPP)
319 #define _AuGetEmptyReq(name, req, aud) \
320         WORD64ALIGN\
321 	if ((aud->bufptr + SIZEOF(auReq)) > aud->bufmax)\
322 	    _AuFlush(aud);\
323 	req = (auReq *) (aud->last_req = aud->bufptr);\
324 	req->reqType = Au_##name;\
325 	req->length = 1;\
326 	aud->bufptr += SIZEOF(auReq);\
327 	aud->request++
328 #else
329 #define _AuGetEmptyReq(name, req, aud) \
330         WORD64ALIGN\
331 	if ((aud->bufptr + SIZEOF(auReq)) > aud->bufmax)\
332 	    _AuFlush(aud);\
333 	req = (auReq *) (aud->last_req = aud->bufptr);\
334 	req->reqType = Au_/**/name;\
335 	req->length = 1;\
336 	aud->bufptr += SIZEOF(auReq);\
337 	aud->request++
338 #endif
339 
340 
341 #define _AuSyncHandle(aud) \
342 	if (aud->synchandler) _AuDoSyncHandle(aud)
343 
344 /*
345  * _AuData - Place data in the buffer and pad the end to provide
346  * 32 bit word alignment.  Transmit if the buffer fills.
347  *
348  * "aud" is a pointer to a AuServer.
349  * "data" is a pinter to a data buffer.
350  * "len" is the length of the data buffer.
351  * we can presume buffer less than 2^16 bytes, so bcopy can be used safely.
352  */
353 #ifndef _AuDataRoutineIsProcedure
354 #define _AuData(aud, data, len) \
355 	if (aud->bufptr + (len) <= aud->bufmax) {\
356 		bcopy(data, aud->bufptr, (int)len);\
357 		aud->bufptr += ((len) + 3) & ~3;\
358 	} else\
359 		_AuSend(aud, data, len)
360 #endif /* _AuDataRoutineIsProcedure */
361 
362 
363 /* Allocate bytes from the buffer.  No padding is done, so if
364  * the length is not a multiple of 4, the caller must be
365  * careful to leave the buffer aligned after sending the
366  * current request.
367  *
368  * "type" is the type of the pointer being assigned to.
369  * "ptr" is the pointer being assigned to.
370  * "n" is the number of bytes to allocate.
371  *
372  * Example:
373  *    xTextElt *elt;
374  *    BufAlloc (xTextElt *, elt, nbytes)
375  */
376 
377 #define BufAlloc(type, ptr, n) \
378     if (aud->bufptr + (n) > aud->bufmax) \
379         _AuFlush (aud); \
380     ptr = (type) aud->bufptr; \
381     aud->bufptr += (n);
382 
383 /*
384  * provide emulation routines for smaller architectures
385  */
386 #ifndef WORD64
387 #define _AuData16(aud, data, len) _AuData((aud), (char *)(data), (len))
388 #define _AuData32(aud, data, len) _AuData((aud), (char *)(data), (len))
389 #define _AuRead16Pad(aud, data, len) _AuReadPad((aud), (char *)(data), (len))
390 #define _AuRead16(aud, data, len) _AuRead((aud), (char *)(data), (len))
391 #define _AuRead32(aud, data, len) _AuRead((aud), (char *)(data), (len))
392 #endif /* not WORD64 */
393 
394 #define _AuPackData16(aud,data,len) _AuData16 (aud, data, len)
395 #define _AuPackData32(aud,data,len) _AuData32 (aud, data, len)
396 
397 /* Xlib manual is bogus */
398 #define _AuPackData(aud,data,len) _AuPackData16 (aud, data, len)
399 
400 #define aumin(a,b) (((a) < (b)) ? (a) : (b))
401 #define aumax(a,b) (((a) > (b)) ? (a) : (b))
402 
403 #ifdef MUSTCOPY
404 
405 /* for when 32-bit alignment is not good enough */
406 #define _AuOneDataCard32(aud,dstaddr,srcvar) \
407   { aud->bufptr -= 4; _AuData32 (aud, (char *) &(srcvar), 4); }
408 
409 #else
410 
411 /* srcvar must be a variable for large architecture version */
412 #define _AuOneDataCard32(aud,dstaddr,srcvar) \
413   { *(AuUint32 *)(dstaddr) = (srcvar); }
414 
415 #endif /* MUSTCOPY */
416 
417 typedef struct _AuInternalAsync {
418     struct _AuInternalAsync *next;
419     AuBool (*handler)();
420     AuPointer data;
421 } _AuAsyncHandler;
422 
423 typedef struct _AuAsyncEState {
424     AuUint32 min_sequence_number;
425     AuUint32 max_sequence_number;
426     unsigned char error_code;
427     unsigned char major_opcode;
428     unsigned short minor_opcode;
429     unsigned char last_error_received;
430     int error_count;
431 } _AuAsyncErrorState;
432 
433 #define _AuEnqAsyncHandler(aud,hhh,ppp,ddd) { \
434     (hhh)->next = (aud)->async_handlers; \
435     (hhh)->handler = (ppp); \
436     (hhh)->data = (AuPointer) (ddd); \
437     (aud)->async_handlers = (hhh); \
438     }
439 
440 #define _AuDeqAsyncHandler(aud,handler) { \
441     if (aud->async_handlers == (handler)) \
442 	aud->async_handlers = (handler)->next; \
443     else \
444 	_AuDoDeqAsyncHandler(aud, handler); \
445     }
446 
447 
448 /*
449  * This structure is private to the library.
450  */
451 typedef struct _AuExten {	/* private to extension mechanism */
452 	struct _AuExten *next;	/* next in list */
453 	AuExtCodes codes;	/* public information, all extension told */
454 	int (*close_server)(	/* routine to call when connection closed */
455 	    AuServer *,		/* server */
456 	    AuExtCodes *	/* extensioncodes */
457 	);
458 	AuBool (*error)(	/* who to call when an error occurs */
459 	    AuServer *,		/* server */
460 	    auError *,		/* errorpacket */
461 	    AuExtCodes *,	/* extensioncodes */
462 	    AuBool *		/* returncode */
463 	);
464         char *(*error_string)(  /* routine to supply error string */
465 	    AuServer *,		/* server */
466 	    int,		/* errorcode */
467 	    AuExtCodes *,	/* extensioncodes */
468 	    char *,		/* buffer */
469 	    int			/* bufsiz */
470 	);
471 	char *name;		/* name of this extension */
472 	void (*error_values)( /* routine to supply error values */
473 	    AuServer *,		/* server */
474 	    AuErrorEvent *,	/* event */
475 	    FILE *		/* where to print */
476 	);
477 } _AuExtension;
478 
479 
480 #define _AuAddToLinkedList(head, item)					       \
481 {									       \
482     (item)->prev = NULL;						       \
483     (item)->next = head;						       \
484     if (head)								       \
485 	(head)->prev = item;						       \
486     head = item;							       \
487 }
488 
489 #define _AuRemoveFromLinkedList(head, item)				       \
490 {									       \
491     if ((item)->next)							       \
492 	(item)->next->prev = (item)->prev;				       \
493 									       \
494     if ((item)->prev)							       \
495 	(item)->prev->next = (item)->next;				       \
496     else								       \
497 	head = (item)->next;						       \
498 }
499 
500 /* extension hooks */
501 
502 _AUFUNCPROTOBEGIN
503 
504 /**********************/
505 /* Internal functions */
506 /**********************/
507 
508 extern int _AuDefaultError(
509     AuServer *,
510     AuErrorEvent *
511 );
512 
513 extern void
514 _AuDefaultIOError (
515     AuServer *
516 );
517 
518 extern AuBool _AuWireToEvent(
519     AuServer *,	/* server */
520     AuEvent *,	/* pointer to where event should be reformatted */
521     auEvent *	/* wire protocol event */
522 );
523 
524 extern AuBool _AuUnknownWireEvent(
525     AuServer *,	/* server */
526     AuEvent *,	/* pointer to where event should be reformatted */
527     auEvent *	/* wire protocol event */
528 );
529 
530 extern AuStatus _AuUnknownNativeEvent(
531     AuServer *,	/* server */
532     AuEvent *,	/* pointer to where event should be reformatted */
533     auEvent *	/* wire protocol event */
534 );
535 
536 extern AuID _AuAllocID (
537     AuServer *		/* server */
538 );
539 
540 #ifdef _AuDataRoutineIsProcedure
541 extern void _AuData(
542     AuServer *,		/* server */
543     char *,		/* data */
544     AuInt32		/* len */
545 );
546 #endif
547 
548 extern int _AuError (			/* prepare to upcall user handler */
549     AuServer *,		/* server */
550     auError *		/* reply */
551 );
552 extern int _AuIOError (			/* prepare to upcall user handler */
553     AuServer *		/* server */
554 );
555 
556 extern void _AuEatData (		/* swallow data from server */
557     AuServer *,		/* server */
558     AuUint32	/* nbytes */
559 );
560 
561 extern char *_AuAllocScratch (		/* fast memory allocator */
562     AuServer *,		/* server */
563     AuUint32	/* nbytes */
564 );
565 
566 extern AuUint32 _AuSetLastRequestRead(	/* update aud->last_request_read */
567     AuServer *,		/* server */
568     auGenericReply *	/* reply */
569 );
570 
571 extern int _AuGetHostname (		/* get name of this machine */
572     char *,		/* buf */
573     int			/* len */
574 );
575 
576 extern AuBool _AuAsyncErrorHandler (	/* internal error handler */
577     AuServer *,		/* server */
578     auReply *,		/* reply */
579     char *,		/* buf */
580     int,		/* len */
581     AuPointer		/* data */
582 );
583 
584 extern void _AuDoDeqAsyncHandler (
585     AuServer *,		/* server */
586     _AuAsyncHandler *	/* handler */
587 );
588 
589 extern char *_AuGetAsyncReply (		/* get async reply */
590     AuServer *,		/* server */
591     char *,		/* replbuf */
592     auReply *,		/* rep */
593     char *,		/* buf */
594     int,		/* len */
595     int,		/* extra */
596     AuBool		/* discard */
597 );
598 
599 extern AuBool _AuReply (
600     AuServer *,		/* server */
601     auReply *,		/* reply */
602     int,		/* extra */
603     AuBool,		/* discard */
604     AuStatus *		/* ret_status */
605 );
606 
607 extern AuBool _AuForceRoundTrip (
608     AuServer *,		/* server */
609     int,		/* error_code */
610     int,		/* major */
611     int,		/* minor */
612     AuStatus *		/* ret_status */
613 );
614 
615 #define _AuIfRoundTrip(aud,rsp) \
616     (rsp ? _AuForceRoundTrip (aud, 0, 0, 0, (rsp)) : AuTrue)
617 
618 extern int _AuPrintDefaultError (
619     AuServer *,		/* server */
620     AuErrorEvent *,	/* event */
621     FILE *		/* fp */
622 );
623 
624 extern void _AuFreeQ (
625     AuServer *		/* server */
626 );
627 
628 extern void _AuDoSyncHandle (
629     AuServer *		/* server */
630 );
631 
632 extern void
633 _AuAddToBucketCache(
634                     AuServer *,		/* server */
635                     AuBucketAttributes *	/* bucket attributes */
636 );
637 
638 extern AuBucketAttributes *
639 _AuLookupBucketInCache(
640 			 AuServer *,		/* server */
641 			 AuBucketID		/* bucket */
642 );
643 
644 extern void
645 _AuRemoveFromBucketCache(
646 			 AuServer *,		/* server */
647 			 AuBucketID		/* bucket */
648 );
649 
650 extern void
651 _AuFreeBucketCache(
652 			 AuServer *		/* server */
653 );
654 
655 extern void
656 _AuRead(
657         AuServer *,		/* server */
658 	char *,			/* data */
659 	AuInt32			/* size */
660 );
661 
662 void
663 _AuReadPad(
664         AuServer *,		/* server */
665 	char *,			/* data */
666 	AuInt32			/* size */
667 );
668 
669 extern void
670 _AuSend(
671         AuServer *,		/* server */
672 	char *,			/* data */
673 	AuInt32			/* size */
674 );
675 
676 extern void
677 _AuFreeExtData(
678     AuExtData *			/* extension */
679 );
680 
681 extern int
682 _AuDisconnectServer(
683     int				/* server */
684 );
685 
686 void
687 _AuFreeServerStructure(
688     AuServer  *			/* aud */
689 );
690 
691 void
692 _AuFlush(
693     AuServer  *			/* aud */
694 );
695 
696 int
697 _AuEventsQueued(
698     AuServer  *, 		/* aud */
699     int				/* mode */
700 );
701 
702 void
703 _AuReadEvents(
704     AuServer  * 		/* aud */
705 );
706 
707 int
708 _AuConnectServer(
709     const char *, 		/* server_name */
710     char **, 			/* fullnamep */
711     int *, 			/* svrnump */
712     char **, 			/* auth_namep */
713     int *, 			/* auth_namelenp */
714     char **, 			/* auth_datap */
715     int * 			/* auth_datalenp */
716 );
717 
718 /********************/
719 /* Public functions */
720 /********************/
721 
722 extern int (*AuESetCloseServer(
723     AuServer*		/* server */,
724     int			/* extension */,
725     int (*) (
726 	      AuServer*			/* server */,
727               AuExtCodes*		/* codes */
728             )		/* proc */
729 ))(
730     AuServer*, AuExtCodes*
731 );
732 
733 extern int (*AuESetError(
734     AuServer*		/* server */,
735     int			/* extension */,
736     int (*) (
737 	      AuServer*			/* server */,
738               auError*			/* err */,
739               AuExtCodes*		/* codes */,
740               int*			/* ret_code */
741             )		/* proc */
742 ))(
743     AuServer*, auError*, AuExtCodes*, int*
744 );
745 
746 extern char* (*AuESetErrorString(
747     AuServer*		/* server */,
748     int			/* extension */,
749     char* (*) (
750 	        AuServer*		/* server */,
751                 int			/* code */,
752                 AuExtCodes*		/* codes */,
753                 char*			/* buffer */,
754                 int			/* nbytes */
755               )		/* proc */
756 ))(
757     AuServer*, int, AuExtCodes*, char*, int
758 );
759 
760 extern void (*AuESetPrintErrorValues (
761     AuServer*		/* server */,
762     int			/* extension */,
763     void (*)(
764 	      AuServer*			/* server */,
765 	      AuErrorEvent*		/* ev */,
766 	      void*			/* fp */
767 	     )		/* proc */
768 ))(
769     AuServer*, AuErrorEvent*, void*
770 );
771 
772 extern int (*AuESetWireToEvent(
773     AuServer*		/* server */,
774     int			/* event_number */,
775     AuBool (*) (
776 	       AuServer*		/* server */,
777                AuEvent*			/* re */,
778                auEvent*			/* event */
779              )		/* proc */
780 ))(
781     AuServer*, AuEvent*, auEvent*
782 );
783 
784 extern AuStatus (*AuESetEventToWire(
785     AuServer*		/* server */,
786     int			/* event_number */,
787     int (*) (
788 	      AuServer*			/* server */,
789               AuEvent*			/* re */,
790               auEvent*			/* event */
791             )		/* proc */
792 ))(
793     AuServer*, AuEvent*, auEvent*
794 );
795 
796 extern AuStatus (*AuESetWireToError(
797     AuServer*		/* server */,
798     int			/* error_number */,
799     AuBool (*) (
800 	       AuServer*		/* server */,
801 	       AuErrorEvent*		/* he */,
802 	       auError*			/* we */
803             )		/* proc */
804 ))(
805     AuServer*, AuErrorEvent*, auError*
806 );
807 
808 extern AuSyncHandlerRec *
809 AuRegisterSyncHandler(
810 		      AuServer *,		/* server */
811 		      AuSyncHandlerCallback,	/* callback */
812 		      AuPointer			/* data */
813 );
814 
815 extern void
816 AuUnregisterSyncHandler(
817 			AuServer *,		/* server */
818 			AuSyncHandlerRec *	/* handler */
819 );
820 
821 extern AuEventEnqHandlerRec *
822 AuRegisterEventEnqHandler
823 (
824 		      AuServer *,		/* server */
825  		      int,			/* who */
826 		      AuEventEnqHandlerCallback,/* callback */
827 		      AuPointer			/* data */
828 );
829 
830 extern void
831 AuUnregisterEventEnqHandler(
832 			AuServer *,		/* server */
833 			AuEventEnqHandlerRec *	/* handler */
834 );
835 
836 _AUFUNCPROTOEND
837 
838 #endif /* _NCD_ALIBINT_H_ */
839