1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/nsprpub/pr/include/prinet.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,99 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* 1.10 + * File: prinet.h 1.11 + * Description: 1.12 + * Header file used to find the system header files for socket support[1]. 1.13 + * This file serves the following purposes: 1.14 + * - A cross-platform, "get-everything" socket header file. On 1.15 + * Unix, socket support is scattered in several header files, 1.16 + * while Windows has a "get-everything" socket header file[2]. 1.17 + * - NSPR needs the following macro definitions and function 1.18 + * prototype declarations from these header files: 1.19 + * AF_INET 1.20 + * INADDR_ANY, INADDR_LOOPBACK, INADDR_BROADCAST 1.21 + * ntohl(), ntohs(), htonl(), ntons(). 1.22 + * NSPR does not define its own versions of these macros and 1.23 + * functions. It simply uses the native versions, which have 1.24 + * the same names on all supported platforms. 1.25 + * This file is intended to be included by NSPR public header 1.26 + * files, such as prio.h. One should not include this file directly. 1.27 + * 1.28 + * Notes: 1.29 + * 1. This file should have been an internal header. Please do not 1.30 + * depend on it to pull in the system header files you need. 1.31 + * 2. WARNING: This file is no longer cross-platform as it is a no-op 1.32 + * for WIN32! See the comment in the WIN32 section for details. 1.33 + */ 1.34 + 1.35 +#ifndef prinet_h__ 1.36 +#define prinet_h__ 1.37 + 1.38 +#if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS) 1.39 +#include <sys/types.h> 1.40 +#include <sys/socket.h> /* AF_INET */ 1.41 +#include <netinet/in.h> /* INADDR_ANY, ..., ntohl(), ... */ 1.42 +#ifdef XP_OS2 1.43 +#include <sys/ioctl.h> 1.44 +#endif 1.45 +#ifdef XP_UNIX 1.46 +#ifdef AIX 1.47 +/* 1.48 + * On AIX 4.3, the header <arpa/inet.h> refers to struct 1.49 + * ether_addr and struct sockaddr_dl that are not declared. 1.50 + * The following struct declarations eliminate the compiler 1.51 + * warnings. 1.52 + */ 1.53 +struct ether_addr; 1.54 +struct sockaddr_dl; 1.55 +#endif /* AIX */ 1.56 +#include <arpa/inet.h> 1.57 +#endif /* XP_UNIX */ 1.58 +#include <netdb.h> 1.59 + 1.60 +#if defined(FREEBSD) || defined(BSDI) || defined(QNX) 1.61 +#include <rpc/types.h> /* the only place that defines INADDR_LOOPBACK */ 1.62 +#endif 1.63 + 1.64 +/* 1.65 + * OS/2 hack. For some reason INADDR_LOOPBACK is not defined in the 1.66 + * socket headers. 1.67 + */ 1.68 +#if defined(OS2) && !defined(INADDR_LOOPBACK) 1.69 +#define INADDR_LOOPBACK 0x7f000001 1.70 +#endif 1.71 + 1.72 +/* 1.73 + * Prototypes of ntohl() etc. are declared in <machine/endian.h> 1.74 + * on these platforms. 1.75 + */ 1.76 +#if defined(BSDI) || defined(OSF1) 1.77 +#include <machine/endian.h> 1.78 +#endif 1.79 + 1.80 +/* On Android, ntohl() etc. are declared in <sys/endian.h>. */ 1.81 +#ifdef __ANDROID__ 1.82 +#include <sys/endian.h> 1.83 +#endif 1.84 + 1.85 +#elif defined(WIN32) 1.86 + 1.87 +/* 1.88 + * Do not include any system header files. 1.89 + * 1.90 + * Originally we were including <windows.h>. It slowed down the 1.91 + * compilation of files that included NSPR headers, so we removed 1.92 + * the <windows.h> inclusion at customer's request, which created 1.93 + * an unfortunate inconsistency with other platforms. 1.94 + */ 1.95 + 1.96 +#else 1.97 + 1.98 +#error Unknown platform 1.99 + 1.100 +#endif 1.101 + 1.102 +#endif /* prinet_h__ */