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