home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / util / att-nameserver / osdep.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-06-14  |  6.6 KB  |  189 lines

  1. #ifndef    NOIDENT
  2. #ident    "@(#)nameserver:osdep.h    1.1"
  3. #endif
  4. /*
  5.  osdep.h (C header file)
  6.     Acc: 575775482 Wed Mar 30 20:38:02 1988
  7.     Mod: 575322770 Fri Mar 25 14:52:50 1988
  8.     Sta: 575778043 Wed Mar 30 21:20:43 1988
  9.     Owner: 5815
  10.     Group: 1985
  11.     Permissions: 664
  12. */
  13. /*
  14.     START USER STAMP AREA
  15. */
  16. /*
  17.     END USER STAMP AREA
  18. */
  19. /***********************************************************
  20. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  21. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  22.  
  23.                         All Rights Reserved
  24.  
  25. Permission to use, copy, modify, and distribute this software and its 
  26. documentation for any purpose and without fee is hereby granted, 
  27. provided that the above copyright notice appear in all copies and that
  28. both that copyright notice and this permission notice appear in 
  29. supporting documentation, and that the names of Digital or MIT not be
  30. used in advertising or publicity pertaining to distribution of the
  31. software without specific, written prior permission.  
  32.  
  33. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  34. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  35. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  36. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  37. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  38. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  39. SOFTWARE.
  40.  
  41. ******************************************************************/
  42.  
  43. /*
  44.  * Copyright 1988, 1989 AT&T, Inc.
  45.  *
  46.  * Permission to use, copy, modify, and distribute this software and its
  47.  * documentation for any purpose and without fee is hereby granted, provided
  48.  * that the above copyright notice appear in all copies and that both that
  49.  * copyright notice and this permission notice appear in supporting
  50.  * documentation, and that the name of AT&T not be used in advertising
  51.  * or publicity pertaining to distribution of the software without specific,
  52.  * written prior permission.  AT&T makes no representations about the
  53.  * suitability of this software for any purpose.  It is provided "as is"
  54.  * without express or implied warranty.
  55.  *
  56.  * AT&T DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  57.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL AT&T
  58.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  59.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  60.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  61.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  62.  *
  63. */
  64.  
  65. /* $Header: osdep.h,v 1.1 89/06/14 15:49:18 jim Exp $ */
  66.  
  67. #ifndef NULL
  68. #define NULL 0
  69. #endif
  70.  
  71. #define BUFSIZE 4096
  72. #define MAXBUFSIZE (1<<17)
  73. #if (NOFILES_MAX <= 128) /* 128 is value of MAXCLIENTS in dix layer */
  74. #define MAXSOCKS (NOFILES_MAX - 1)
  75. #else
  76. #define MAXSOCKS 128
  77. #endif
  78. #define mskcnt ((MAXSOCKS + 31) / 32)    /* size of bit array */
  79.  
  80. #if (mskcnt==1)
  81. #define BITMASK(i) (1 << (i))
  82. #define MASKIDX(i) 0
  83. #endif
  84. #if (mskcnt>1)
  85. #define BITMASK(i) (1 << ((i) & 31))
  86. #define MASKIDX(i) ((i) >> 5)
  87. #endif
  88.  
  89. #define MASKWORD(buf, i) buf[MASKIDX(i)]
  90. #define BITSET(buf, i) MASKWORD(buf, i) |= BITMASK(i)
  91. #define BITCLEAR(buf, i) MASKWORD(buf, i) &= ~BITMASK(i)
  92. #define GETBIT(buf, i) (MASKWORD(buf, i) & BITMASK(i))
  93.  
  94. int cri;
  95.  
  96. #if (mskcnt==1)
  97. #define COPYBITS(src, dst) dst[0] = src[0]
  98. #define CLEARBITS(buf) buf[0] = 0
  99. #define MASKANDSETBITS(dst, b1, b2) dst[0] = (b1[0] & b2[0])
  100. #define ORBITS(dst, b1, b2) dst[0] = (b1[0] | b2[0])
  101. #define UNSETBITS(dst, b1) (dst[0] &= ~b1[0])
  102. #define ANYSET(src) (src[0])
  103. #endif
  104. #if (mskcnt==2)
  105. #define COPYBITS(src, dst) dst[0] = src[0]; dst[1] = src[1]
  106. #define CLEARBITS(buf) buf[0] = 0; buf[1] = 0
  107. #define MASKANDSETBITS(dst, b1, b2)  \
  108.               dst[0] = (b1[0] & b2[0]);\
  109.               dst[1] = (b1[1] & b2[1])
  110. #define ORBITS(dst, b1, b2)  \
  111.               dst[0] = (b1[0] | b2[0]);\
  112.               dst[1] = (b1[1] | b2[1])
  113. #define UNSETBITS(dst, b1) \
  114.                       dst[0] &= ~b1[0]; \
  115.                       dst[1] &= ~b1[1]
  116. #define ANYSET(src) (src[0] || src[1])
  117. #endif
  118. #if (mskcnt==3)
  119. #define COPYBITS(src, dst) dst[0] = src[0]; dst[1] = src[1]; dst[2] = src[2];
  120. #define CLEARBITS(buf) buf[0] = 0; buf[1] = 0; buf[2] = 0
  121. #define MASKANDSETBITS(dst, b1, b2)  \
  122.               dst[0] = (b1[0] & b2[0]);\
  123.               dst[1] = (b1[1] & b2[1]);\
  124.               dst[2] = (b1[2] & b2[2])
  125. #define ORBITS(dst, b1, b2)  \
  126.               dst[0] = (b1[0] | b2[0]);\
  127.               dst[1] = (b1[1] | b2[1]);\
  128.               dst[2] = (b1[2] | b2[2])
  129. #define UNSETBITS(dst, b1) \
  130.                       dst[0] &= ~b1[0]; \
  131.                       dst[1] &= ~b1[1]; \
  132.                       dst[2] &= ~b1[2]
  133. #define ANYSET(src) (src[0] || src[1] || src[2])
  134. #endif
  135. #if (mskcnt==4)
  136. #define COPYBITS(src, dst) dst[0] = src[0]; dst[1] = src[1]; dst[2] = src[2];\
  137.               dst[3] = src[3]
  138. #define CLEARBITS(buf) buf[0] = 0; buf[1] = 0; buf[2] = 0; buf[3] = 0
  139. #define MASKANDSETBITS(dst, b1, b2)  \
  140.                       dst[0] = (b1[0] & b2[0]);\
  141.                       dst[1] = (b1[1] & b2[1]);\
  142.                       dst[2] = (b1[2] & b2[2]);\
  143.                       dst[3] = (b1[3] & b2[3])
  144. #define ORBITS(dst, b1, b2)  \
  145.                       dst[0] = (b1[0] | b2[0]);\
  146.                       dst[1] = (b1[1] | b2[1]);\
  147.                       dst[2] = (b1[2] | b2[2]);\
  148.                       dst[3] = (b1[3] | b2[3])
  149. #define UNSETBITS(dst, b1) \
  150.                       dst[0] &= ~b1[0]; \
  151.                       dst[1] &= ~b1[1]; \
  152.                       dst[2] &= ~b1[2]; \
  153.                       dst[3] &= ~b1[3]
  154. #define ANYSET(src) (src[0] || src[1] || src[2] || src[3])
  155. #endif
  156.  
  157. #if (mskcnt>4)
  158. #define COPYBITS(src, dst) bcopy((caddr_t) src, (caddr_t) dst,\
  159.                  mskcnt*sizeof(long))
  160. #define CLEARBITS(buf) bzero((caddr_t) buf, mskcnt*sizeof(long))
  161. #define MASKANDSETBITS(dst, b1, b2)  \
  162.               for (cri=0; cri<mskcnt; cri++) \
  163.                   dst[cri] = (b1[cri] & b2[cri])
  164. #define ORBITS(dst, b1, b2)  \
  165.               for (cri=0; cri<mskcnt; cri++) \
  166.                   dst[cri] = (b1[cri] | b2[cri])
  167. #define UNSETBITS(dst, b1) \
  168.               for (cri=0; cri<mskcnt; cri++) \
  169.                   dst[cri] &= ~b1[cri]; 
  170. #define ANYSET(src) (src[0] || src[1] || src[2] || src[3])
  171. #endif
  172.  
  173. typedef struct _connectionInput {
  174.     int used;                  /* is this client connected */
  175.     char *buffer;               /* contains current client input */
  176.     char *bufptr;               /* pointer to current start of data */
  177.     int  bufcnt;                /* count of bytes in buffer */
  178.     int lenLastReq;
  179.     int size;
  180. } ConnectionInput;
  181.  
  182. typedef struct _osPriv {
  183.     int fd;
  184. } osPrivRec, *osPrivPtr;
  185.  
  186. #define    MARKED_AS_DEAD(fd)    (-fd -5)
  187. #define    GET_DEAD_FD(fd)    (-fd - 5)
  188.  
  189.