client.h revision bbe1b32b
1/* $Xorg: client.h,v 1.4 2001/02/09 02:05:43 xorgcvs Exp $ */ 2/* 3 4Copyright 1990, 1991, 1998 The Open Group 5 6Permission to use, copy, modify, distribute, and sell this software and its 7documentation for any purpose is hereby granted without fee, provided that 8the above copyright notice appear in all copies and that both that 9copyright notice and this permission notice appear in supporting 10documentation. 11 12The above copyright notice and this permission notice shall be included in 13all copies or substantial portions of the Software. 14 15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 22Except as contained in this notice, the name of The Open Group shall not be 23used in advertising or otherwise to promote the sale, use or other dealings 24in this Software without prior written authorization from The Open Group. 25 26 * Copyright 1990, 1991 Network Computing Devices; 27 * Portions Copyright 1987 by Digital Equipment Corporation 28 * 29 * Permission to use, copy, modify, distribute, and sell this software and 30 * its documentation for any purpose is hereby granted without fee, provided 31 * that the above copyright notice appear in all copies and that both that 32 * copyright notice and this permission notice appear in supporting 33 * documentation, and that the names of Network Computing Devices, or Digital 34 * not be used in advertising or publicity pertaining to distribution 35 * of the software without specific, written prior permission. 36 * 37 * NETWORK COMPUTING DEVICES, AND DIGITAL DISCLAIM ALL WARRANTIES WITH 38 * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF 39 * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES, 40 * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 41 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 42 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 43 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 44 * THIS SOFTWARE. 45 */ 46/* $XFree86: xc/programs/xfs/include/client.h,v 1.6 2001/01/17 23:45:31 dawes Exp $ */ 47 48#ifndef _CLIENT_H_ 49#define _CLIENT_H_ 50 51#ifndef _XTYPEDEF_CLIENTPTR 52typedef struct _Client *ClientPtr; 53#define _XTYPEDEF_CLIENTPTR 54#endif 55 56#include <misc.h> 57 58extern ClientPtr *clients; 59extern ClientPtr serverClient; 60 61#define NullClient ((ClientPtr) NULL) 62 63#define SERVER_CLIENT 0 64#define MINCLIENT 1 65 66#define CLIENT_ALIVE 0 67#define CLIENT_GONE 1 68#define CLIENT_AGED 2 69#define CLIENT_TIMED_OUT 4 70 71#define REQUEST(type) \ 72 type *stuff = (type *)client->requestBuffer 73 74#define REQUEST_FIXED_SIZE(fs_req, n) \ 75 if (((SIZEOF(fs_req) >> 2) > stuff->length) || \ 76 (((SIZEOF(fs_req) + (n) + 3) >> 2) != stuff->length)) { \ 77 int lengthword = stuff->length; \ 78 SendErrToClient(client, FSBadLength, (pointer)&lengthword); \ 79 return (FSBadLength); \ 80 } 81 82#define REQUEST_SIZE_MATCH(fs_req) \ 83 if ((SIZEOF(fs_req) >> 2) != stuff->length) { \ 84 int lengthword = stuff->length; \ 85 SendErrToClient(client, FSBadLength, (pointer)&lengthword); \ 86 return (FSBadLength); \ 87 } 88 89#define REQUEST_AT_LEAST_SIZE(fs_req) \ 90 if ((SIZEOF(fs_req) >> 2) > stuff->length) { \ 91 int lengthword = stuff->length; \ 92 SendErrToClient(client, FSBadLength, (pointer)&lengthword); \ 93 return (FSBadLength); \ 94 } 95 96#define WriteReplyToClient(client, size, reply) \ 97 if ((client)->swapped) \ 98 (*ReplySwapVector[((fsReq *)(client)->requestBuffer)->reqType]) \ 99 (client, (int)(size), reply); \ 100 else (void)WriteToClient(client, (int)(size), (char *)(reply)); 101 102#define WriteSwappedDataToClient(client, size, pbuf) \ 103 if ((client)->swapped) \ 104 (*(client)->pSwapReplyFunc)(client, (int)(size), pbuf); \ 105 else (void) WriteToClient(client, (int)(size), (char *)(pbuf)); 106 107 108typedef struct _WorkQueue *WorkQueuePtr; 109 110#include <difsutils.h> /* for ProcessWorkQueue(void) */ 111 112extern int (*ProcVector[]) (ClientPtr); 113extern int (*SwappedProcVector[]) (ClientPtr); 114 115#endif /* _CLIENT_H_ */ 116