home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / include / ncompat.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  8.3 KB  |  251 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. /*-
  19.  * Copyright (c) 1991, 1993
  20.  *    The Regents of the University of California.  All rights reserved.
  21.  *
  22.  * Redistribution and use in source and binary forms, with or without
  23.  * modification, are permitted provided that the following conditions
  24.  * are met:
  25.  * 1. Redistributions of source code must retain the above copyright
  26.  *    notice, this list of conditions and the following disclaimer.
  27.  * 2. Redistributions in binary form must reproduce the above copyright
  28.  *    notice, this list of conditions and the following disclaimer in the
  29.  *    documentation and/or other materials provided with the distribution.
  30.  * 3. All advertising materials mentioning features or use of this software
  31.  *    must display the following acknowledgement:
  32.  *    This product includes software developed by the University of
  33.  *    California, Berkeley and its contributors.
  34.  * 4. Neither the name of the University nor the names of its contributors
  35.  *    may be used to endorse or promote products derived from this software
  36.  *    without specific prior written permission.
  37.  *
  38.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  39.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  40.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  41.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  42.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  43.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  44.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  45.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  46.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  47.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  48.  * SUCH DAMAGE.
  49.  *
  50.  *    @(#)compat.h    8.13 (Berkeley) 2/21/94
  51.  */
  52.  
  53. #ifndef    _COMPAT_H_
  54. #define    _COMPAT_H_
  55.  
  56. #include <sys/types.h>
  57.  
  58. /*
  59.  * If your system doesn't typedef u_long, u_short, or u_char, change
  60.  * the 0 to a 1.
  61.  */
  62. /*DSR041497 - these are defined in pmwsock.h, so only need for DOUGSOCK*/
  63. #ifdef XP_OS2_DOUGSOCK
  64. typedef unsigned char    u_char;        /* 4.[34]BSD names. */
  65. typedef unsigned int    u_int;
  66. typedef unsigned long    u_long;
  67. typedef unsigned short    u_short;
  68. #endif
  69.  
  70. /* If your system doesn't typedef size_t, change the 0 to a 1. */
  71. #if 0
  72. typedef unsigned int    size_t;        /* POSIX, 4.[34]BSD names. */
  73. #endif
  74.  
  75. /* If your system doesn't typedef ssize_t, change the 0 to a 1. */
  76. #if 0
  77. typedef    int        ssize_t;    /* POSIX names. */
  78. #endif
  79.  
  80. /*
  81.  * If your system doesn't have the POSIX type for a signal mask,
  82.  * change the 0 to a 1.
  83.  */
  84. #if 0                    /* POSIX 1003.1 signal mask type. */
  85. typedef unsigned int    sigset_t;
  86. #endif
  87.  
  88. /*
  89.  * If your system's vsprintf returns a char *, not an int,
  90.  * change the 0 to a 1.
  91.  */
  92. #if defined (__sun) && !defined(SVR4) /* SUNOS */
  93. #define    VSPRINTF_CHARSTAR
  94. #endif
  95. /*
  96.  * If you don't have POSIX 1003.1 signals, the signal code surrounding the 
  97.  * temporary file creation is intended to block all of the possible signals
  98.  * long enough to create the file and unlink it.  All of this stuff is
  99.  * intended to use old-style BSD calls to fake POSIX 1003.1 calls.
  100.  */
  101. #ifdef    NO_POSIX_SIGNALS
  102. #define    sigemptyset(set)    (*(set) = 0)
  103. #define    sigfillset(set)        (*(set) = ~(sigset_t)0, 0)
  104. #define    sigaddset(set,signo)    (*(set) |= sigmask(signo), 0)
  105. #define    sigdelset(set,signo)    (*(set) &= ~sigmask(signo), 0)
  106. #define    sigismember(set,signo)    ((*(set) & sigmask(signo)) != 0)
  107.  
  108. #define    SIG_BLOCK    1
  109. #define    SIG_UNBLOCK    2
  110. #define    SIG_SETMASK    3
  111.  
  112. static int __sigtemp;        /* For the use of sigprocmask */
  113.  
  114. /* Repeated test of oset != NULL is to avoid "*0". */
  115. #define    sigprocmask(how, set, oset)                    \
  116.     ((__sigtemp =                            \
  117.     (((how) == SIG_BLOCK) ?                        \
  118.         sigblock(0) | *(set) :                    \
  119.     (((how) == SIG_UNBLOCK) ?                    \
  120.         sigblock(0) & ~(*(set)) :                \
  121.     ((how) == SIG_SETMASK ?                        \
  122.         *(set) : sigblock(0))))),                \
  123.     ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) :    \
  124.         sigsetmask(__sigtemp)), 0)
  125. #endif
  126.  
  127. /*
  128.  * If your system doesn't have an include file with the appropriate
  129.  * byte order set, make sure you specify the correct one.
  130.  */
  131. #ifndef BYTE_ORDER
  132. #define    LITTLE_ENDIAN    1234        /* LSB first: i386, vax */
  133. #define    BIG_ENDIAN    4321        /* MSB first: 68000, ibm, net */
  134. #define    BYTE_ORDER    BIG_ENDIAN    /* Set for your system. */
  135. #endif
  136.  
  137. #if defined(SYSV) || defined(SYSTEM5) || defined(__sun)
  138. #define    index(a, b)        strchr(a, b)
  139. #define    rindex(a, b)        strrchr(a, b)
  140. #define    bzero(a, b)        memset(a, 0, b)
  141. #define    bcmp(a, b, n)        memcmp(a, b, n)
  142. #define    bcopy(a, b, n)        memmove(b, a, n)
  143. #endif
  144.  
  145. #if defined(BSD) || defined(BSD4_3)
  146. #define    strchr(a, b)        index(a, b)
  147. #define    strrchr(a, b)        rindex(a, b)
  148. #define    memcmp(a, b, n)        bcmp(a, b, n)
  149. #define    memmove(a, b, n)    bcopy(b, a, n)
  150. #endif
  151.  
  152. /*
  153.  * 32-bit machine.  The db routines are theoretically independent of
  154.  * the size of u_shorts and u_longs, but I don't know that anyone has
  155.  * ever actually tried it.  At a minimum, change the following #define's
  156.  * if you are trying to compile on a different type of system.
  157.  */
  158. #ifndef USHRT_MAX
  159. #define    USHRT_MAX        0xFFFF
  160. #define    ULONG_MAX        0xFFFFFFFF
  161. #endif
  162.  
  163. #ifndef O_ACCMODE            /* POSIX 1003.1 access mode mask. */
  164. #define    O_ACCMODE    (O_RDONLY|O_WRONLY|O_RDWR)
  165. #endif
  166.  
  167. #ifndef    _POSIX2_RE_DUP_MAX        /* POSIX 1003.2 RE limit. */
  168. #define    _POSIX2_RE_DUP_MAX    255
  169. #endif
  170.  
  171. /*
  172.  * If you can't provide lock values in the open(2) call.  Note, this
  173.  * allows races to happen.
  174.  */
  175. #ifndef O_EXLOCK            /* 4.4BSD extension. */
  176. #define    O_EXLOCK    0
  177. #endif
  178.  
  179. #ifndef O_SHLOCK            /* 4.4BSD extension. */
  180. #define    O_SHLOCK    0
  181. #endif
  182.  
  183. #ifndef EFTYPE
  184. #define    EFTYPE        EINVAL        /* POSIX 1003.1 format errno. */
  185. #endif
  186.  
  187. #ifndef    WCOREDUMP            /* 4.4BSD extension */
  188. #define    WCOREDUMP(a)    0
  189. #endif
  190.  
  191. #ifndef    STDERR_FILENO
  192. #define    STDIN_FILENO    0        /* ANSI C #defines */
  193. #define    STDOUT_FILENO    1
  194. #define    STDERR_FILENO    2
  195. #endif
  196.  
  197. #ifndef SEEK_END
  198. #define    SEEK_SET    0        /* POSIX 1003.1 seek values */
  199. #define    SEEK_CUR    1
  200. #define    SEEK_END    2
  201. #endif
  202.  
  203. #ifndef _POSIX_VDISABLE            /* POSIX 1003.1 disabling char. */
  204. #define    _POSIX_VDISABLE    0        /* Some systems used 0. */
  205. #endif
  206.  
  207. #ifndef    TCSASOFT            /* 4.4BSD extension. */
  208. #define    TCSASOFT    0
  209. #endif
  210.  
  211. #ifndef _POSIX2_RE_DUP_MAX        /* POSIX 1003.2 values. */
  212. #define    _POSIX2_RE_DUP_MAX    255
  213. #endif
  214.  
  215. #ifndef NULL                /* ANSI C #defines NULL everywhere. */
  216. #define    NULL        0
  217. #endif
  218.  
  219. #ifndef    MAX                /* Usually found in <sys/param.h>. */
  220. #define    MAX(_a,_b)    ((_a)<(_b)?(_b):(_a))
  221. #endif
  222. #ifndef    MIN                /* Usually found in <sys/param.h>. */
  223. #define    MIN(_a,_b)    ((_a)<(_b)?(_a):(_b))
  224. #endif
  225.  
  226. /* Default file permissions. */
  227. #ifndef DEFFILEMODE            /* 4.4BSD extension. */
  228. #define    DEFFILEMODE    (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
  229. #endif
  230.  
  231. #ifndef __sun
  232. #ifndef S_ISDIR                /* POSIX 1003.1 file type tests. */
  233. #define    S_ISDIR(m)    ((m & 0170000) == 0040000)    /* directory */
  234. #define    S_ISCHR(m)    ((m & 0170000) == 0020000)    /* char special */
  235. #define    S_ISBLK(m)    ((m & 0170000) == 0060000)    /* block special */
  236. #define    S_ISREG(m)    ((m & 0170000) == 0100000)    /* regular file */
  237. #define    S_ISFIFO(m)    ((m & 0170000) == 0010000)    /* fifo */
  238. #endif
  239. #ifndef S_ISLNK                /* BSD POSIX 1003.1 extensions */
  240. #define    S_ISLNK(m)    ((m & 0170000) == 0120000)    /* symbolic link */
  241. #define    S_ISSOCK(m)    ((m & 0170000) == 0140000)    /* socket */
  242. #endif
  243. #endif /* __sun */
  244.  
  245. /* The type of a va_list. */
  246. #ifndef _BSD_VA_LIST_            /* 4.4BSD #define. */
  247. #define    _BSD_VA_LIST_    char *
  248. #endif
  249.  
  250. #endif /* !_COMPAT_H_ */
  251.