home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / fonts / server / os / osdep.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-21  |  6.0 KB  |  181 lines

  1. /* $XConsortium: osdep.h,v 1.4 92/01/31 17:45:07 eswu Exp $ */
  2. /*
  3.  * Copyright 1990, 1991 Network Computing Devices;
  4.  * Portions Copyright 1987 by Digital Equipment Corporation and the
  5.  * Massachusetts Institute of Technology
  6.  *
  7.  * Permission to use, copy, modify, and distribute this protoype software
  8.  * and its documentation to Members and Affiliates of the MIT X Consortium
  9.  * any purpose and without fee is hereby granted, provided
  10.  * that the above copyright notice appear in all copies and that both that
  11.  * copyright notice and this permission notice appear in supporting
  12.  * documentation, and that the names of Network Computing Devices, Digital or
  13.  * MIT not be used in advertising or publicity pertaining to distribution of
  14.  * the software without specific, written prior permission.
  15.  *
  16.  * NETWORK COMPUTING DEVICES, DIGITAL AND MIT DISCLAIM ALL WARRANTIES WITH
  17.  * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  18.  * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES, DIGITAL OR MIT BE
  19.  * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  20.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  21.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  22.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  23.  *
  24.  * @(#)osdep.h    4.1    5/2/91
  25.  *
  26.  */
  27.  
  28. #ifndef _OSDEP_H_
  29. #define    _OSDEP_H_
  30.  
  31. #define    BOTIMEOUT    200    /* in milliseconds */
  32. #define    BUFSIZE        4096
  33. #define    BUFWATERMARK    8192
  34. #define    MAXBUFSIZE    (1 << 18)
  35.  
  36. #if NOFILE <= 128        /* 128 is value of MAXCLIENTS */
  37. #define    MAXSOCKS    (NOFILE - 1)
  38. #else
  39. #define    MAXSOCKS    128
  40. #endif
  41.  
  42. #define    mskcnt    ((MAXSOCKS + 31) / 32)    /* size of bit array */
  43.  
  44. #ifndef NULL
  45. #define NULL 0
  46. #endif
  47.  
  48. #if (mskcnt==1)
  49. #define BITMASK(i) (1 << (i))
  50. #define MASKIDX(i) 0
  51. #endif
  52.  
  53. #if (mskcnt>1)
  54. #define BITMASK(i) (1 << ((i) & 31))
  55. #define MASKIDX(i) ((i) >> 5)
  56. #endif
  57.  
  58. #define MASKWORD(buf, i) buf[MASKIDX(i)]
  59. #define BITSET(buf, i) MASKWORD(buf, i) |= BITMASK(i)
  60. #define BITCLEAR(buf, i) MASKWORD(buf, i) &= ~BITMASK(i)
  61. #define GETBIT(buf, i) (MASKWORD(buf, i) & BITMASK(i))
  62.  
  63. #if (mskcnt==1)
  64. #define COPYBITS(src, dst) dst[0] = src[0]
  65. #define CLEARBITS(buf) buf[0] = 0
  66. #define MASKANDSETBITS(dst, b1, b2) dst[0] = (b1[0] & b2[0])
  67. #define ORBITS(dst, b1, b2) dst[0] = (b1[0] | b2[0])
  68. #define UNSETBITS(dst, b1) (dst[0] &= ~b1[0])
  69. #define ANYSET(src) (src[0])
  70. #endif
  71.  
  72. #if (mskcnt==2)
  73. #define COPYBITS(src, dst) dst[0] = src[0]; dst[1] = src[1]
  74. #define CLEARBITS(buf) buf[0] = 0; buf[1] = 0
  75. #define MASKANDSETBITS(dst, b1, b2)  \
  76.               dst[0] = (b1[0] & b2[0]);\
  77.               dst[1] = (b1[1] & b2[1])
  78. #define ORBITS(dst, b1, b2)  \
  79.               dst[0] = (b1[0] | b2[0]);\
  80.               dst[1] = (b1[1] | b2[1])
  81. #define UNSETBITS(dst, b1) \
  82.                       dst[0] &= ~b1[0]; \
  83.                       dst[1] &= ~b1[1]
  84. #define ANYSET(src) (src[0] || src[1])
  85. #endif
  86.  
  87. #if (mskcnt==3)
  88. #define COPYBITS(src, dst) dst[0] = src[0]; dst[1] = src[1]; dst[2] = src[2];
  89. #define CLEARBITS(buf) buf[0] = 0; buf[1] = 0; buf[2] = 0
  90. #define MASKANDSETBITS(dst, b1, b2)  \
  91.               dst[0] = (b1[0] & b2[0]);\
  92.               dst[1] = (b1[1] & b2[1]);\
  93.               dst[2] = (b1[2] & b2[2])
  94. #define ORBITS(dst, b1, b2)  \
  95.               dst[0] = (b1[0] | b2[0]);\
  96.               dst[1] = (b1[1] | b2[1]);\
  97.               dst[2] = (b1[2] | b2[2])
  98. #define UNSETBITS(dst, b1) \
  99.                       dst[0] &= ~b1[0]; \
  100.                       dst[1] &= ~b1[1]; \
  101.                       dst[2] &= ~b1[2]
  102. #define ANYSET(src) (src[0] || src[1] || src[2])
  103. #endif
  104.  
  105. #if (mskcnt==4)
  106. #define COPYBITS(src, dst) dst[0] = src[0]; dst[1] = src[1]; dst[2] = src[2];\
  107.               dst[3] = src[3]
  108. #define CLEARBITS(buf) buf[0] = 0; buf[1] = 0; buf[2] = 0; buf[3] = 0
  109. #define MASKANDSETBITS(dst, b1, b2)  \
  110.                       dst[0] = (b1[0] & b2[0]);\
  111.                       dst[1] = (b1[1] & b2[1]);\
  112.                       dst[2] = (b1[2] & b2[2]);\
  113.                       dst[3] = (b1[3] & b2[3])
  114. #define ORBITS(dst, b1, b2)  \
  115.                       dst[0] = (b1[0] | b2[0]);\
  116.                       dst[1] = (b1[1] | b2[1]);\
  117.                       dst[2] = (b1[2] | b2[2]);\
  118.                       dst[3] = (b1[3] | b2[3])
  119. #define UNSETBITS(dst, b1) \
  120.                       dst[0] &= ~b1[0]; \
  121.                       dst[1] &= ~b1[1]; \
  122.                       dst[2] &= ~b1[2]; \
  123.                       dst[3] &= ~b1[3]
  124. #define ANYSET(src) (src[0] || src[1] || src[2] || src[3])
  125. #endif
  126.  
  127. #if (mskcnt>4)
  128. #define COPYBITS(src, dst) bcopy((caddr_t) src, (caddr_t) dst,\
  129.                  mskcnt*sizeof(long))
  130. #define CLEARBITS(buf) bzero((caddr_t) buf, mskcnt*sizeof(long))
  131. #define MASKANDSETBITS(dst, b1, b2)  \
  132.               { int cri;            \
  133.             for (cri=0; cri<mskcnt; cri++)    \
  134.                   dst[cri] = (b1[cri] & b2[cri]); }
  135. #define ORBITS(dst, b1, b2)  \
  136.               { int cri;            \
  137.               for (cri=0; cri<mskcnt; cri++)    \
  138.                   dst[cri] = (b1[cri] | b2[cri]); }
  139. #define UNSETBITS(dst, b1) \
  140.               { int cri;            \
  141.               for (cri=0; cri<mskcnt; cri++)    \
  142.                   dst[cri] &= ~b1[cri];  }
  143. #if (mskcnt==8)
  144. #define ANYSET(src) (src[0] || src[1] || src[2] || src[3] || \
  145.              src[4] || src[5] || src[6] || src[7])
  146. #endif
  147. /*
  148.  * If mskcnt>4 and not 8, then ANYSET is a routine defined in WaitFor.c.
  149.  *
  150.  * #define ANYSET(src) (src[0] || src[1] || src[2] || src[3] || src[4] ...)
  151.  */
  152. #endif
  153.  
  154. typedef struct _connectionInput {
  155.     struct _connectionInput *next;
  156.     char       *buffer;        /* contains current client input */
  157.     char       *bufptr;        /* pointer to current start of data */
  158.     int         bufcnt;        /* count of bytes in buffer */
  159.     int         lenLastReq;
  160.     int         size;
  161. }           ConnectionInput, *ConnectionInputPtr;
  162.  
  163. typedef struct _connectionOutput {
  164.     struct _connectionOutput *next;
  165.     int         size;
  166.     unsigned char *buf;
  167.     int         count;
  168. }           ConnectionOutput, *ConnectionOutputPtr;
  169.  
  170. typedef struct _osComm {
  171.     int         fd;
  172.     ConnectionInputPtr input;
  173.     ConnectionOutputPtr output;
  174.     long        conn_time;    /* timestamp if not established, else 0  */
  175. }           OsCommRec, *OsCommPtr;
  176.  
  177. extern Bool CloneSelf;
  178. extern Bool UseSyslog;
  179.  
  180. #endif                /* _OSDEP_H_ */
  181.