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