]> git.sesse.net Git - rdpsrv/blob - Xserver/lib/font/fc/fslibos.h
Support RDP5 logon packets.
[rdpsrv] / Xserver / lib / font / fc / fslibos.h
1 /* $XConsortium: fslibos.h /main/16 1996/11/13 14:45:15 lehors $ */
2 /* $XFree86: xc/lib/font/fc/fslibos.h,v 3.3 1996/12/23 06:02:08 dawes Exp $ */
3 /*
4  * Copyright 1990 Network Computing Devices;
5  * Portions Copyright 1987 by Digital Equipment Corporation
6  */
7
8 /*
9
10 Copyright (c) 1987, 1994  X Consortium
11
12 Permission is hereby granted, free of charge, to any person obtaining
13 a copy of this software and associated documentation files (the
14 "Software"), to deal in the Software without restriction, including
15 without limitation the rights to use, copy, modify, merge, publish,
16 distribute, sublicense, and/or sell copies of the Software, and to
17 permit persons to whom the Software is furnished to do so, subject to
18 the following conditions:
19
20 The above copyright notice and this permission notice shall be included
21 in all copies or substantial portions of the Software.
22
23 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26 IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
27 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
28 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
29 OTHER DEALINGS IN THE SOFTWARE.
30
31 Except as contained in this notice, the name of the X Consortium shall
32 not be used in advertising or otherwise to promote the sale, use or
33 other dealings in this Software without prior written authorization
34 from the X Consortium.
35
36 */
37
38 /*
39  * FSlib networking & os include file
40  */
41
42 #include <X11/Xtrans.h>
43
44 #ifndef WIN32
45
46 /*
47  * makedepend screws up on #undef OPEN_MAX, so we define a new symbol
48  */
49
50 #ifndef FONT_OPEN_MAX
51
52 #ifndef X_NOT_POSIX
53 #ifdef _POSIX_SOURCE
54 #include <limits.h>
55 #else
56 #define _POSIX_SOURCE
57 #include <limits.h>
58 #undef _POSIX_SOURCE
59 #endif
60 #endif
61 #ifndef OPEN_MAX
62 #if defined(SVR4) || defined(__EMX__)
63 #ifdef SCO325
64 #define OPEN_MAX sysconf(_SC_OPEN_MAX)
65 #else
66 #define OPEN_MAX 256
67 #endif
68 #else
69 #include <sys/param.h>
70 #ifndef OPEN_MAX
71 #ifdef __OSF1__
72 #define OPEN_MAX 256
73 #else
74 #ifdef NOFILE
75 #define OPEN_MAX NOFILE
76 #else
77 #define OPEN_MAX NOFILES_MAX
78 #endif
79 #endif
80 #endif
81 #endif
82 #endif
83
84 #if OPEN_MAX > 256
85 #define FONT_OPEN_MAX 256
86 #else
87 #define FONT_OPEN_MAX OPEN_MAX
88 #endif
89
90 #endif /* FONT_OPEN_MAX */
91
92 #ifdef WORD64
93 #define NMSKBITS 64
94 #else
95 #define NMSKBITS 32
96 #endif
97
98 #define MSKCNT ((FONT_OPEN_MAX + NMSKBITS - 1) / NMSKBITS)
99
100 typedef unsigned long FdSet[MSKCNT];
101 typedef FdSet FdSetPtr;
102
103 #if (MSKCNT==1)
104 #define BITMASK(i) (1 << (i))
105 #define MASKIDX(i) 0
106 #endif
107
108 #if (MSKCNT>1)
109 #define BITMASK(i) (1 << ((i) & (NMSKBITS - 1)))
110 #define MASKIDX(i) ((i) / NMSKBITS)
111 #endif
112
113 #define MASKWORD(buf, i) buf[MASKIDX(i)]
114 #define BITSET(buf, i) MASKWORD(buf, i) |= BITMASK(i)
115 #define BITCLEAR(buf, i) MASKWORD(buf, i) &= ~BITMASK(i)
116 #define GETBIT(buf, i) (MASKWORD(buf, i) & BITMASK(i))
117
118 #if (MSKCNT==1)
119 #define COPYBITS(src, dst) dst[0] = src[0]
120 #define CLEARBITS(buf) buf[0] = 0
121 #define MASKANDSETBITS(dst, b1, b2) dst[0] = (b1[0] & b2[0])
122 #define ORBITS(dst, b1, b2) dst[0] = (b1[0] | b2[0])
123 #define UNSETBITS(dst, b1) (dst[0] &= ~b1[0])
124 #define ANYSET(src) (src[0])
125 #endif
126
127 #if (MSKCNT==2)
128 #define COPYBITS(src, dst) { dst[0] = src[0]; dst[1] = src[1]; }
129 #define CLEARBITS(buf) { buf[0] = 0; buf[1] = 0; }
130 #define MASKANDSETBITS(dst, b1, b2)  {\
131                       dst[0] = (b1[0] & b2[0]);\
132                       dst[1] = (b1[1] & b2[1]); }
133 #define ORBITS(dst, b1, b2)  {\
134                       dst[0] = (b1[0] | b2[0]);\
135                       dst[1] = (b1[1] | b2[1]); }
136 #define UNSETBITS(dst, b1) {\
137                       dst[0] &= ~b1[0]; \
138                       dst[1] &= ~b1[1]; }
139 #define ANYSET(src) (src[0] || src[1])
140 #endif
141
142 #if (MSKCNT==3)
143 #define COPYBITS(src, dst) { dst[0] = src[0]; dst[1] = src[1]; \
144                              dst[2] = src[2]; }
145 #define CLEARBITS(buf) { buf[0] = 0; buf[1] = 0; buf[2] = 0; }
146 #define MASKANDSETBITS(dst, b1, b2)  {\
147                       dst[0] = (b1[0] & b2[0]);\
148                       dst[1] = (b1[1] & b2[1]);\
149                       dst[2] = (b1[2] & b2[2]); }
150 #define ORBITS(dst, b1, b2)  {\
151                       dst[0] = (b1[0] | b2[0]);\
152                       dst[1] = (b1[1] | b2[1]);\
153                       dst[2] = (b1[2] | b2[2]); }
154 #define UNSETBITS(dst, b1) {\
155                       dst[0] &= ~b1[0]; \
156                       dst[1] &= ~b1[1]; \
157                       dst[2] &= ~b1[2]; }
158 #define ANYSET(src) (src[0] || src[1] || src[2])
159 #endif
160
161 #if (MSKCNT==4)
162 #define COPYBITS(src, dst) dst[0] = src[0]; dst[1] = src[1]; \
163                            dst[2] = src[2]; dst[3] = src[3]
164 #define CLEARBITS(buf) buf[0] = 0; buf[1] = 0; buf[2] = 0; buf[3] = 0
165 #define MASKANDSETBITS(dst, b1, b2)  \
166                       dst[0] = (b1[0] & b2[0]);\
167                       dst[1] = (b1[1] & b2[1]);\
168                       dst[2] = (b1[2] & b2[2]);\
169                       dst[3] = (b1[3] & b2[3])
170 #define ORBITS(dst, b1, b2)  \
171                       dst[0] = (b1[0] | b2[0]);\
172                       dst[1] = (b1[1] | b2[1]);\
173                       dst[2] = (b1[2] | b2[2]);\
174                       dst[3] = (b1[3] | b2[3])
175 #define UNSETBITS(dst, b1) \
176                       dst[0] &= ~b1[0]; \
177                       dst[1] &= ~b1[1]; \
178                       dst[2] &= ~b1[2]; \
179                       dst[3] &= ~b1[3]
180 #define ANYSET(src) (src[0] || src[1] || src[2] || src[3])
181 #endif
182
183 #if (MSKCNT>4)
184 #define COPYBITS(src, dst) memmove((caddr_t) dst, (caddr_t) src,\
185                                    MSKCNT*sizeof(long))
186 #define CLEARBITS(buf) bzero((caddr_t) buf, MSKCNT*sizeof(long))
187 #define MASKANDSETBITS(dst, b1, b2)  \
188                       { int cri;                        \
189                         for (cri=MSKCNT; --cri>=0; )    \
190                           dst[cri] = (b1[cri] & b2[cri]); }
191 #define ORBITS(dst, b1, b2)  \
192                       { int cri;                        \
193                       for (cri=MSKCNT; --cri>=0; )      \
194                           dst[cri] = (b1[cri] | b2[cri]); }
195 #define UNSETBITS(dst, b1) \
196                       { int cri;                        \
197                       for (cri=MSKCNT; --cri>=0; )      \
198                           dst[cri] &= ~b1[cri];  }
199 #if (MSKCNT==8)
200 #define ANYSET(src) (src[0] || src[1] || src[2] || src[3] || \
201                      src[4] || src[5] || src[6] || src[7])
202 #endif
203 #endif
204
205 #else /* not WIN32 */
206
207 #include <X11/Xwinsock.h>
208 #include <X11/Xw32defs.h>
209
210 typedef fd_set FdSet;
211 typedef FdSet *FdSetPtr;
212
213 #define CLEARBITS(set) FD_ZERO(&set)
214 #define BITSET(set,s) FD_SET(s,&set)
215 #define BITCLEAR(set,s) FD_CLR(s,&set)
216 #define GETBIT(set,s) FD_ISSET(s,&set)
217 #define ANYSET(set) set->fd_count
218
219 #endif