From 426f727b11f70cd3541d16757cf0ab414b87ea98 Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Thu, 14 Mar 2013 10:28:14 -0700 Subject: Cleaned up references to win32 pre-generated headers Moved pre-generated and static headers used for autotool-less win32 builds out of include/ and into win32/. Centralized the HAVE_CONFIG logic into two common headers, one for src/, and one for test/. All source code should know include headers from the same location, its the responsibility of the build prep system (autotools or msvcbuild.bat) to make sure the correct headers are in place. --- .gitignore | 6 +- libnet/.gitignore | 3 - libnet/Makefile.am | 4 +- libnet/README.win32 | 5 +- libnet/configure.ac | 2 +- libnet/doc/PACKET_BUILDING | 9 +- libnet/include/Makefile.am | 2 +- libnet/include/win32/Makefile.am | 2 - libnet/include/win32/config.h | 111 ------------------ libnet/include/win32/getopt.h | 84 ------------- libnet/include/win32/libnet.h | 120 ------------------- libnet/include/win32/stdint.h | 247 --------------------------------------- libnet/msvcbuild.bat | 6 +- libnet/sample/arp-new.c | 4 - libnet/sample/arp.c | 4 - libnet/sample/cdp.c | 4 - libnet/sample/dhcp_discover.c | 6 - libnet/sample/dns.c | 6 - libnet/sample/get_addr.c | 6 - libnet/sample/hsrp.c | 7 -- libnet/sample/icmp_echo_cq.c | 6 - libnet/sample/libnet_test.h | 11 +- libnet/sample/sebek.c | 7 -- libnet/sample/tcp1.c | 12 -- libnet/sample/udp1.c | 6 - libnet/src/Makefile.am | 2 +- libnet/src/common.h | 9 +- libnet/src/libnet_dll.c | 2 +- libnet/win32/Makefile.am | 2 + libnet/win32/config.h | 103 ++++++++++++++++ libnet/win32/getopt.h | 84 +++++++++++++ libnet/win32/libnet.h | 120 +++++++++++++++++++ libnet/win32/stdint.h | 247 +++++++++++++++++++++++++++++++++++++++ 33 files changed, 584 insertions(+), 665 deletions(-) delete mode 100644 libnet/.gitignore delete mode 100644 libnet/include/win32/Makefile.am delete mode 100644 libnet/include/win32/config.h delete mode 100644 libnet/include/win32/getopt.h delete mode 100644 libnet/include/win32/libnet.h delete mode 100644 libnet/include/win32/stdint.h create mode 100644 libnet/win32/Makefile.am create mode 100644 libnet/win32/config.h create mode 100644 libnet/win32/getopt.h create mode 100644 libnet/win32/libnet.h create mode 100644 libnet/win32/stdint.h diff --git a/.gitignore b/.gitignore index 7ebddb7..f5bea2f 100644 --- a/.gitignore +++ b/.gitignore @@ -12,17 +12,19 @@ *~ .*.swp .libs +Makefile Makefile.in aclocal.m4 autom4te.cache config.guess -config.h config.h.in config.log config.status config.sub configure +dynsections.js install-sh +jquery.js libnet*.changes libnet*.deb libnet-1.1.? @@ -35,6 +37,8 @@ libnet/doc/html/*.gif libnet/doc/html/*.html libnet/doc/html/*.png libnet/doc/man/man3/*.3 +libnet/include/config.h +libnet/include/getopt.h libnet/include/libnet.h libnet/include/libnet/stdint.h libnet/m4 diff --git a/libnet/.gitignore b/libnet/.gitignore deleted file mode 100644 index fccfc26..0000000 --- a/libnet/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -Makefile -doc/html/dynsections.js -doc/html/jquery.js diff --git a/libnet/Makefile.am b/libnet/Makefile.am index 2e628a1..e03c886 100644 --- a/libnet/Makefile.am +++ b/libnet/Makefile.am @@ -8,8 +8,8 @@ include $(top_srcdir)/Makefile.am.common -SUBDIRS = include src sample doc +SUBDIRS = include src sample doc win32 -EXTRA_DIST = Makefile.am.common +EXTRA_DIST = Makefile.am.common msvcbuild.bat bin_SCRIPTS = libnet-config diff --git a/libnet/README.win32 b/libnet/README.win32 index 4f22f0e..52be775 100644 --- a/libnet/README.win32 +++ b/libnet/README.win32 @@ -4,7 +4,10 @@ The batch file depends on the MSVC build environment being set (PATH, etc.), this can be done with Visual Studio's vsvars32.bat, or by starting a Visual Studio shell. -Also, the batch file hard-codes the location of the WinPcap developer's tools, +The batch file copies pre-prepared headers out of win32/, avoiding the +requirement for a gnu (cygwin or mingw) build environment. + +The batch file hard-codes the location of the WinPcap developer's tools, you may have to modify it for your environment, or install the developer's pack in the expected location. diff --git a/libnet/configure.ac b/libnet/configure.ac index cdc9a69..ccc28c2 100644 --- a/libnet/configure.ac +++ b/libnet/configure.ac @@ -298,7 +298,7 @@ AM_CONDITIONAL([INSTALL_SAMPLES], [test x"$enable_samples" = xyes]) AC_CONFIG_FILES([Makefile src/Makefile \ include/Makefile \ - include/libnet/Makefile include/win32/Makefile \ + include/libnet/Makefile win32/Makefile \ sample/Makefile doc/Makefile \ doc/man/Makefile doc/man/man3/Makefile doc/html/Makefile \ include/libnet.h libnet-config]) diff --git a/libnet/doc/PACKET_BUILDING b/libnet/doc/PACKET_BUILDING index 8f7dfff..f464a6f 100644 --- a/libnet/doc/PACKET_BUILDING +++ b/libnet/doc/PACKET_BUILDING @@ -65,14 +65,7 @@ struct libnet_sebek_hdr 4a) -#if (HAVE_CONFIG_H) -#include "../include/config.h" -#endif -#if (!(_WIN32) || (__CYGWIN__)) -#include "../include/libnet.h" -#else -#include "../include/win32/libnet.h" -#endif +#include "common.h" libnet_ptag_t libnet_build_sebek(u_int32_t magic, u_int16_t version, u_int16_t type, diff --git a/libnet/include/Makefile.am b/libnet/include/Makefile.am index b3e7768..b396dd5 100644 --- a/libnet/include/Makefile.am +++ b/libnet/include/Makefile.am @@ -6,4 +6,4 @@ nodist_include_HEADERS = libnet.h EXTRA_DIST = bpf.h gnuc.h ifaddrlist.h -SUBDIRS = libnet win32 +SUBDIRS = libnet diff --git a/libnet/include/win32/Makefile.am b/libnet/include/win32/Makefile.am deleted file mode 100644 index 343a0f2..0000000 --- a/libnet/include/win32/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -EXTRA_DIST = getopt.h libnet.h - diff --git a/libnet/include/win32/config.h b/libnet/include/win32/config.h deleted file mode 100644 index 2fab597..0000000 --- a/libnet/include/win32/config.h +++ /dev/null @@ -1,111 +0,0 @@ -/* include/config.h.in. Generated from configure.in by autoheader. */ -/* -dnl $Id: config.h,v 1.4 2004/01/03 20:31:00 mike Exp $ -dnl -dnl Libnet autoconfiguration acconfig.h file -dnl Copyright (c) 1998 - 2004 Mike D. Schiffman -dnl All rights reserved. -dnl -dnl Process this file with autoheader to produce a config.h file. -dnl -*/ - -#undef LIBNET_BSDISH_OS -#undef LIBNET_BSD_BYTE_SWAP -#undef DLPI_DEV_PREFIX -#undef HAVE_DEV_DLPI -#undef HAVE_SOLARIS -#undef HAVE_SOLARIS_IPV6 -#undef HAVE_HPUX11 -#undef HAVE_SOCKADDR_SA_LEN -#undef HAVE_DLPI -#undef HAVE_PACKET_SOCKET -#undef HAVE_STRUCT_IP_CSUM -#undef HAVE_LIB_PCAP -#undef STUPID_SOLARIS_CHECKSUM_BUG -#undef _BSD_SOURCE -#undef __BSD_SOURCE -#undef __FAVOR_BSD -#undef LIBNET_BIG_ENDIAN -#define LIBNET_LIL_ENDIAN 1 -#undef NO_SNPRINTF - - -/* -dnl EOF -*/ - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the `nsl' library (-lnsl). */ -#undef HAVE_LIBNSL - -/* Define to 1 if you have the `packet' library (-lpacket). */ -#undef HAVE_LIBPACKET - -/* Define to 1 if you have the `socket' library (-lsocket). */ -#undef HAVE_LIBSOCKET - -/* Define to 1 if you have the `wpcap' library (-lwpcap). */ -#undef HAVE_LIBWPCAP - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the header file. */ -#define HAVE_NET_ETHERNET_H 1 - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the `strerror' function. */ -#define HAVE_STRERROR 1 - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_BUFMOD_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_DLPI_EXT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_SOCKIO_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS diff --git a/libnet/include/win32/getopt.h b/libnet/include/win32/getopt.h deleted file mode 100644 index 6b6f643..0000000 --- a/libnet/include/win32/getopt.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 1987, 1993, 1994, 1996 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef __GETOPT_H__ -#define __GETOPT_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -extern int opterr; /* if error message should be printed */ -extern int optind; /* index into parent argv vector */ -extern int optopt; /* character checked for validity */ -extern int optreset; /* reset getopt */ -extern char *optarg; /* argument associated with option */ - -int getopt (int, char * const *, const char *); - -#ifdef __cplusplus -} -#endif - -#endif /* __GETOPT_H__ */ - -#ifndef __UNISTD_GETOPT__ -#ifndef __GETOPT_LONG_H__ -#define __GETOPT_LONG_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -struct option { - const char *name; - int has_arg; - int *flag; - int val; -}; - -int getopt_long (int, char *const *, const char *, const struct option *, int *); -#ifndef HAVE_DECL_GETOPT -#define HAVE_DECL_GETOPT 1 -#endif - -#define no_argument 0 -#define required_argument 1 -#define optional_argument 2 - -#ifdef __cplusplus -} -#endif - -#endif /* __GETOPT_LONG_H__ */ -#endif /* __UNISTD_GETOPT__ */ diff --git a/libnet/include/win32/libnet.h b/libnet/include/win32/libnet.h deleted file mode 100644 index 18a5d6c..0000000 --- a/libnet/include/win32/libnet.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * $Id: libnet.h,v 1.7 2004/01/03 20:31:00 mike Exp $ - * - * libnet.h - Network routine library header file for Win32 VC++ - * - * Copyright (c) 1998 - 2004 Mike D. Schiffman - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ - -#ifdef _WIN32 - -#ifndef __LIBNET_H -#define __LIBNET_H - -#include -#include -#include -#include "pcap.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -/* __WIN32__ is NOT a predefined MACRO, use _WIN32 - * __CYGWIN__ is defined within the cygwin environment. - */ -#ifndef __WIN32__ -#define __WIN32__ _WIN32 -#endif - -#define LIBNET_LIL_ENDIAN 1 -#define HAVE_CONFIG_H 1 - -/* TODO Definitions and includes below should be in a private header, libnet src needs them, libnet - library users don't (and they have negative side effects). - */ -/* Some UNIX to Win32 conversions */ -#define snprintf _snprintf -#define strdup _strdup -#define write _write -#define open _open -#define random rand -#define close closesocket -#define __func__ __FUNCTION__ -#ifndef _CRT_SECURE_NO_WARNINGS -#define _CRT_SECURE_NO_WARNINGS -#endif - -/* __FUNCTION__ available in VC ++ 7.0 (.NET) and greater */ -#if _MSC_VER < 1300 -#define __FUNCTION__ __FILE__ -#endif - -/* the following is only supported by MSVC and not by MinGW/MSys environements */ -#ifdef _MSC_VER -#pragma comment (lib,"ws2_32") /* Winsock 2 */ -#pragma comment (lib,"iphlpapi") /* IP Helper */ -#pragma comment (lib,"wpcap") /* Winpcap */ -#pragma comment (lib,"packet") -#endif - -/* FIXME this needs manual update during release packaging. */ -#define LIBNET_VERSION "1.1.6" - -/* To use Win32 native versions */ -#define WPCAP 1 -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define LIBNET_API __declspec(dllexport) - -#include "libnet/stdint.h" -#include "libnet/libnet-macros.h" -#include "libnet/libnet-headers.h" -#include "libnet/libnet-structures.h" -#include "libnet/libnet-asn1.h" -#include "libnet/libnet-functions.h" - -#ifdef __cplusplus -} -#endif - -#endif /* __LIBNET_H */ - -#endif -/* EOF */ diff --git a/libnet/include/win32/stdint.h b/libnet/include/win32/stdint.h deleted file mode 100644 index d02608a..0000000 --- a/libnet/include/win32/stdint.h +++ /dev/null @@ -1,247 +0,0 @@ -// ISO C9x compliant stdint.h for Microsoft Visual Studio -// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 -// -// Copyright (c) 2006-2008 Alexander Chemeris -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. The name of the author may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _MSC_VER // [ -#error "Use this header only with Microsoft Visual C++ compilers!" -#endif // _MSC_VER ] - -#ifndef _MSC_STDINT_H_ // [ -#define _MSC_STDINT_H_ - -#if _MSC_VER > 1000 -#pragma once -#endif - -#include - -// For Visual Studio 6 in C++ mode and for many Visual Studio versions when -// compiling for ARM we should wrap include with 'extern "C++" {}' -// or compiler give many errors like this: -// error C2733: second C linkage of overloaded function 'wmemchr' not allowed -#ifdef __cplusplus -extern "C" { -#endif -# include -#ifdef __cplusplus -} -#endif - -// Define _W64 macros to mark types changing their size, like intptr_t. -#ifndef _W64 -# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 -# define _W64 __w64 -# else -# define _W64 -# endif -#endif - - -// 7.18.1 Integer types - -// 7.18.1.1 Exact-width integer types - -// Visual Studio 6 and Embedded Visual C++ 4 doesn't -// realize that, e.g. char has the same size as __int8 -// so we give up on __intX for them. -#if (_MSC_VER < 1300) - typedef signed char int8_t; - typedef signed short int16_t; - typedef signed int int32_t; - typedef unsigned char uint8_t; - typedef unsigned short uint16_t; - typedef unsigned int uint32_t; -#else - typedef signed __int8 int8_t; - typedef signed __int16 int16_t; - typedef signed __int32 int32_t; - typedef unsigned __int8 uint8_t; - typedef unsigned __int16 uint16_t; - typedef unsigned __int32 uint32_t; -#endif -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; - - -// 7.18.1.2 Minimum-width integer types -typedef int8_t int_least8_t; -typedef int16_t int_least16_t; -typedef int32_t int_least32_t; -typedef int64_t int_least64_t; -typedef uint8_t uint_least8_t; -typedef uint16_t uint_least16_t; -typedef uint32_t uint_least32_t; -typedef uint64_t uint_least64_t; - -// 7.18.1.3 Fastest minimum-width integer types -typedef int8_t int_fast8_t; -typedef int16_t int_fast16_t; -typedef int32_t int_fast32_t; -typedef int64_t int_fast64_t; -typedef uint8_t uint_fast8_t; -typedef uint16_t uint_fast16_t; -typedef uint32_t uint_fast32_t; -typedef uint64_t uint_fast64_t; - -// 7.18.1.4 Integer types capable of holding object pointers -#ifdef _WIN64 // [ - typedef signed __int64 intptr_t; - typedef unsigned __int64 uintptr_t; -#else // _WIN64 ][ - typedef _W64 signed int intptr_t; - typedef _W64 unsigned int uintptr_t; -#endif // _WIN64 ] - -// 7.18.1.5 Greatest-width integer types -typedef int64_t intmax_t; -typedef uint64_t uintmax_t; - - -// 7.18.2 Limits of specified-width integer types - -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 - -// 7.18.2.1 Limits of exact-width integer types -#define INT8_MIN ((int8_t)_I8_MIN) -#define INT8_MAX _I8_MAX -#define INT16_MIN ((int16_t)_I16_MIN) -#define INT16_MAX _I16_MAX -#define INT32_MIN ((int32_t)_I32_MIN) -#define INT32_MAX _I32_MAX -#define INT64_MIN ((int64_t)_I64_MIN) -#define INT64_MAX _I64_MAX -#define UINT8_MAX _UI8_MAX -#define UINT16_MAX _UI16_MAX -#define UINT32_MAX _UI32_MAX -#define UINT64_MAX _UI64_MAX - -// 7.18.2.2 Limits of minimum-width integer types -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST8_MAX INT8_MAX -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST16_MAX INT16_MAX -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST32_MAX INT32_MAX -#define INT_LEAST64_MIN INT64_MIN -#define INT_LEAST64_MAX INT64_MAX -#define UINT_LEAST8_MAX UINT8_MAX -#define UINT_LEAST16_MAX UINT16_MAX -#define UINT_LEAST32_MAX UINT32_MAX -#define UINT_LEAST64_MAX UINT64_MAX - -// 7.18.2.3 Limits of fastest minimum-width integer types -#define INT_FAST8_MIN INT8_MIN -#define INT_FAST8_MAX INT8_MAX -#define INT_FAST16_MIN INT16_MIN -#define INT_FAST16_MAX INT16_MAX -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST32_MAX INT32_MAX -#define INT_FAST64_MIN INT64_MIN -#define INT_FAST64_MAX INT64_MAX -#define UINT_FAST8_MAX UINT8_MAX -#define UINT_FAST16_MAX UINT16_MAX -#define UINT_FAST32_MAX UINT32_MAX -#define UINT_FAST64_MAX UINT64_MAX - -// 7.18.2.4 Limits of integer types capable of holding object pointers -#ifdef _WIN64 // [ -# define INTPTR_MIN INT64_MIN -# define INTPTR_MAX INT64_MAX -# define UINTPTR_MAX UINT64_MAX -#else // _WIN64 ][ -# define INTPTR_MIN INT32_MIN -# define INTPTR_MAX INT32_MAX -# define UINTPTR_MAX UINT32_MAX -#endif // _WIN64 ] - -// 7.18.2.5 Limits of greatest-width integer types -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX - -// 7.18.3 Limits of other integer types - -#ifdef _WIN64 // [ -# define PTRDIFF_MIN _I64_MIN -# define PTRDIFF_MAX _I64_MAX -#else // _WIN64 ][ -# define PTRDIFF_MIN _I32_MIN -# define PTRDIFF_MAX _I32_MAX -#endif // _WIN64 ] - -#define SIG_ATOMIC_MIN INT_MIN -#define SIG_ATOMIC_MAX INT_MAX - -#ifndef SIZE_MAX // [ -# ifdef _WIN64 // [ -# define SIZE_MAX _UI64_MAX -# else // _WIN64 ][ -# define SIZE_MAX _UI32_MAX -# endif // _WIN64 ] -#endif // SIZE_MAX ] - -// WCHAR_MIN and WCHAR_MAX are also defined in -#ifndef WCHAR_MIN // [ -# define WCHAR_MIN 0 -#endif // WCHAR_MIN ] -#ifndef WCHAR_MAX // [ -# define WCHAR_MAX _UI16_MAX -#endif // WCHAR_MAX ] - -#define WINT_MIN 0 -#define WINT_MAX _UI16_MAX - -#endif // __STDC_LIMIT_MACROS ] - - -// 7.18.4 Limits of other integer types - -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 - -// 7.18.4.1 Macros for minimum-width integer constants - -#define INT8_C(val) val##i8 -#define INT16_C(val) val##i16 -#define INT32_C(val) val##i32 -#define INT64_C(val) val##i64 - -#define UINT8_C(val) val##ui8 -#define UINT16_C(val) val##ui16 -#define UINT32_C(val) val##ui32 -#define UINT64_C(val) val##ui64 - -// 7.18.4.2 Macros for greatest-width integer constants -#define INTMAX_C INT64_C -#define UINTMAX_C UINT64_C - -#endif // __STDC_CONSTANT_MACROS ] - - -#endif // _MSC_STDINT_H_ ] diff --git a/libnet/msvcbuild.bat b/libnet/msvcbuild.bat index 2cfc3dc..5284e64 100644 --- a/libnet/msvcbuild.bat +++ b/libnet/msvcbuild.bat @@ -10,8 +10,10 @@ @rem relative to C code in src/ @set WINPCAP=..\..\..\WpdPack -copy include\win32\libnet.h include\ -copy include\win32\stdint.h include\libnet\ +copy win32\libnet.h include\ +copy win32\stdint.h include\libnet\ +copy win32\config.h include\ +copy win32\getopt.h include\ cd src %MYCOMPILE% /I..\include /I%WINPCAP%\Include libnet_a*.c libnet_build_*.c libnet_c*.c libnet_dll.c libnet_error.c libnet_i*.c libnet_link_win32.c libnet_p*.c libnet_raw.c libnet_resolve.c libnet_version.c libnet_write.c diff --git a/libnet/sample/arp-new.c b/libnet/sample/arp-new.c index 6bea59e..9534996 100644 --- a/libnet/sample/arp-new.c +++ b/libnet/sample/arp-new.c @@ -31,12 +31,8 @@ */ #if (HAVE_CONFIG_H) -#if ((_WIN32) && !(__CYGWIN__)) -#include "../include/win32/config.h" -#else #include "../include/config.h" #endif -#endif #include "./libnet_test.h" int diff --git a/libnet/sample/arp.c b/libnet/sample/arp.c index 32c5532..391862f 100644 --- a/libnet/sample/arp.c +++ b/libnet/sample/arp.c @@ -31,12 +31,8 @@ */ #if (HAVE_CONFIG_H) -#if ((_WIN32) && !(__CYGWIN__)) -#include "../include/win32/config.h" -#else #include "../include/config.h" #endif -#endif #include "./libnet_test.h" int diff --git a/libnet/sample/cdp.c b/libnet/sample/cdp.c index 6b5a9b7..32ed77d 100644 --- a/libnet/sample/cdp.c +++ b/libnet/sample/cdp.c @@ -35,12 +35,8 @@ */ #if (HAVE_CONFIG_H) -#if ((_WIN32) && !(__CYGWIN__)) -#include "../include/win32/config.h" -#else #include "../include/config.h" #endif -#endif #include "./libnet_test.h" diff --git a/libnet/sample/dhcp_discover.c b/libnet/sample/dhcp_discover.c index dd4c5b7..054443a 100644 --- a/libnet/sample/dhcp_discover.c +++ b/libnet/sample/dhcp_discover.c @@ -31,13 +31,7 @@ * */ -#if (HAVE_CONFIG_H) -#include "../include/config.h" -#endif #include "./libnet_test.h" -#ifdef __WIN32__ -#include "../include/win32/getopt.h" -#endif void usage(char *prog) diff --git a/libnet/sample/dns.c b/libnet/sample/dns.c index dec4bee..d4a9727 100644 --- a/libnet/sample/dns.c +++ b/libnet/sample/dns.c @@ -30,13 +30,7 @@ * */ -#if (HAVE_CONFIG_H) -#include "../include/config.h" -#endif #include "./libnet_test.h" -#ifdef __WIN32__ -#include "../include/win32/getopt.h" -#endif void usage(char *prog) diff --git a/libnet/sample/get_addr.c b/libnet/sample/get_addr.c index 9832566..7374866 100644 --- a/libnet/sample/get_addr.c +++ b/libnet/sample/get_addr.c @@ -30,13 +30,7 @@ * */ -#if (HAVE_CONFIG_H) -#include "../include/config.h" -#endif #include "./libnet_test.h" -#ifdef __WIN32__ -#include "../include/win32/getopt.h" -#endif int main(int argc, char *argv[]) diff --git a/libnet/sample/hsrp.c b/libnet/sample/hsrp.c index 4818927..44dae24 100644 --- a/libnet/sample/hsrp.c +++ b/libnet/sample/hsrp.c @@ -29,13 +29,6 @@ * */ -#if (HAVE_CONFIG_H) -#if ((_WIN32) && !(__CYGWIN__)) -#include "../include/win32/config.h" -#else -#include "../include/config.h" -#endif -#endif #include "./libnet_test.h" diff --git a/libnet/sample/icmp_echo_cq.c b/libnet/sample/icmp_echo_cq.c index 0eaa61d..c5b2401 100644 --- a/libnet/sample/icmp_echo_cq.c +++ b/libnet/sample/icmp_echo_cq.c @@ -30,13 +30,7 @@ * */ -#if (HAVE_CONFIG_H) -#include "../include/config.h" -#endif #include "./libnet_test.h" -#ifdef __WIN32__ -#include "../include/win32/getopt.h" -#endif void usage(char *); diff --git a/libnet/sample/libnet_test.h b/libnet/sample/libnet_test.h index 7590e7a..8441e70 100644 --- a/libnet/sample/libnet_test.h +++ b/libnet/sample/libnet_test.h @@ -9,13 +9,12 @@ #ifndef __LIBNET_TEST_H #define __LIBNET_TEST_H -#ifndef _WIN32 -#include "../include/libnet.h" -#else -#include "../include/win32/libnet.h" -#include "../include/win32/getopt.h" +#if (HAVE_CONFIG_H) +#include "../include/config.h" #endif +#include "../include/libnet.h" + #define libnet_timersub(tvp, uvp, vvp) \ do { \ (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ @@ -40,7 +39,7 @@ u_char org_code[3] = {0x00, 0x00, 0x00}; void usage(char *); #if defined(__WIN32__) -#include +#include #include #include #ifndef _WIN32 diff --git a/libnet/sample/sebek.c b/libnet/sample/sebek.c index de1674b..e2493fa 100644 --- a/libnet/sample/sebek.c +++ b/libnet/sample/sebek.c @@ -29,13 +29,6 @@ * */ -#if (HAVE_CONFIG_H) -#if ((_WIN32) && !(__CYGWIN__)) -#include "../include/win32/config.h" -#else -#include "../include/config.h" -#endif -#endif #include "./libnet_test.h" void usage(char *name) diff --git a/libnet/sample/tcp1.c b/libnet/sample/tcp1.c index 52e59e8..3fe025c 100644 --- a/libnet/sample/tcp1.c +++ b/libnet/sample/tcp1.c @@ -30,13 +30,7 @@ * */ -#if (HAVE_CONFIG_H) -#include "../include/config.h" -#endif #include "libnet_test.h" -#ifdef __WIN32__ -#include "../include/win32/getopt.h" -#endif int main(int argc, char *argv[]) @@ -219,9 +213,3 @@ usage(char *name) name); } -#if defined(__WIN32__) -#include <../include/win32/getopt.h> -#include -#include -#endif /* __WIN32__ */ -/* EOF */ diff --git a/libnet/sample/udp1.c b/libnet/sample/udp1.c index 50add7d..dad4824 100644 --- a/libnet/sample/udp1.c +++ b/libnet/sample/udp1.c @@ -30,13 +30,7 @@ * */ -#if (HAVE_CONFIG_H) -#include "../include/config.h" -#endif #include "./libnet_test.h" -#ifdef __WIN32__ -#include "../include/win32/getopt.h" -#endif int main(int argc, char *argv[]) diff --git a/libnet/src/Makefile.am b/libnet/src/Makefile.am index 977f528..c993a93 100644 --- a/libnet/src/Makefile.am +++ b/libnet/src/Makefile.am @@ -8,7 +8,7 @@ include $(top_srcdir)/Makefile.am.common -EXTRA_DIST = libnet_dll.c +EXTRA_DIST = libnet_dll.c common.h lib_LTLIBRARIES = libnet.la diff --git a/libnet/src/common.h b/libnet/src/common.h index 704f68e..c0747e8 100644 --- a/libnet/src/common.h +++ b/libnet/src/common.h @@ -32,14 +32,8 @@ /* MSVC warns about snprintf */ #define _CRT_SECURE_NO_WARNINGS -#include "../include/win32/config.h" -#include "../include/win32/libnet.h" - #else -#include "../include/config.h" -#include "../include/libnet.h" - #include #include @@ -56,3 +50,6 @@ #endif +#include "../include/config.h" +#include "../include/libnet.h" + diff --git a/libnet/src/libnet_dll.c b/libnet/src/libnet_dll.c index cbeb3d1..84d2df9 100644 --- a/libnet/src/libnet_dll.c +++ b/libnet/src/libnet_dll.c @@ -29,7 +29,7 @@ * */ -#include "../include/win32/libnet.h" +#include "common" #include "packet32.h" BOOL WINAPI DllMain(HINSTANCE hinst, ULONG fdwReason, LPVOID lpReserved) diff --git a/libnet/win32/Makefile.am b/libnet/win32/Makefile.am new file mode 100644 index 0000000..af3b0a8 --- /dev/null +++ b/libnet/win32/Makefile.am @@ -0,0 +1,2 @@ +EXTRA_DIST = getopt.h libnet.h config.h stdint.h + diff --git a/libnet/win32/config.h b/libnet/win32/config.h new file mode 100644 index 0000000..926f12f --- /dev/null +++ b/libnet/win32/config.h @@ -0,0 +1,103 @@ +/* win32/config.h Originally generated from configure.in by autoheader. */ +/* Static win32 config.h, copied into include/ by msvcbuild.bat when + building without autotools. */ + +#undef LIBNET_BSDISH_OS +#undef LIBNET_BSD_BYTE_SWAP +#undef DLPI_DEV_PREFIX +#undef HAVE_DEV_DLPI +#undef HAVE_SOLARIS +#undef HAVE_SOLARIS_IPV6 +#undef HAVE_HPUX11 +#undef HAVE_SOCKADDR_SA_LEN +#undef HAVE_DLPI +#undef HAVE_PACKET_SOCKET +#undef HAVE_STRUCT_IP_CSUM +#undef HAVE_LIB_PCAP +#undef STUPID_SOLARIS_CHECKSUM_BUG +#undef _BSD_SOURCE +#undef __BSD_SOURCE +#undef __FAVOR_BSD +#undef LIBNET_BIG_ENDIAN +#define LIBNET_LIL_ENDIAN 1 +#undef NO_SNPRINTF + + +/* +dnl EOF +*/ + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `nsl' library (-lnsl). */ +#undef HAVE_LIBNSL + +/* Define to 1 if you have the `packet' library (-lpacket). */ +#undef HAVE_LIBPACKET + +/* Define to 1 if you have the `socket' library (-lsocket). */ +#undef HAVE_LIBSOCKET + +/* Define to 1 if you have the `wpcap' library (-lwpcap). */ +#undef HAVE_LIBWPCAP + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#define HAVE_NET_ETHERNET_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_BUFMOD_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_DLPI_EXT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SOCKIO_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS diff --git a/libnet/win32/getopt.h b/libnet/win32/getopt.h new file mode 100644 index 0000000..6b6f643 --- /dev/null +++ b/libnet/win32/getopt.h @@ -0,0 +1,84 @@ +/* + * Copyright (c) 1987, 1993, 1994, 1996 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef __GETOPT_H__ +#define __GETOPT_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int opterr; /* if error message should be printed */ +extern int optind; /* index into parent argv vector */ +extern int optopt; /* character checked for validity */ +extern int optreset; /* reset getopt */ +extern char *optarg; /* argument associated with option */ + +int getopt (int, char * const *, const char *); + +#ifdef __cplusplus +} +#endif + +#endif /* __GETOPT_H__ */ + +#ifndef __UNISTD_GETOPT__ +#ifndef __GETOPT_LONG_H__ +#define __GETOPT_LONG_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +struct option { + const char *name; + int has_arg; + int *flag; + int val; +}; + +int getopt_long (int, char *const *, const char *, const struct option *, int *); +#ifndef HAVE_DECL_GETOPT +#define HAVE_DECL_GETOPT 1 +#endif + +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 + +#ifdef __cplusplus +} +#endif + +#endif /* __GETOPT_LONG_H__ */ +#endif /* __UNISTD_GETOPT__ */ diff --git a/libnet/win32/libnet.h b/libnet/win32/libnet.h new file mode 100644 index 0000000..18a5d6c --- /dev/null +++ b/libnet/win32/libnet.h @@ -0,0 +1,120 @@ +/* + * $Id: libnet.h,v 1.7 2004/01/03 20:31:00 mike Exp $ + * + * libnet.h - Network routine library header file for Win32 VC++ + * + * Copyright (c) 1998 - 2004 Mike D. Schiffman + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#ifdef _WIN32 + +#ifndef __LIBNET_H +#define __LIBNET_H + +#include +#include +#include +#include "pcap.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/* __WIN32__ is NOT a predefined MACRO, use _WIN32 + * __CYGWIN__ is defined within the cygwin environment. + */ +#ifndef __WIN32__ +#define __WIN32__ _WIN32 +#endif + +#define LIBNET_LIL_ENDIAN 1 +#define HAVE_CONFIG_H 1 + +/* TODO Definitions and includes below should be in a private header, libnet src needs them, libnet + library users don't (and they have negative side effects). + */ +/* Some UNIX to Win32 conversions */ +#define snprintf _snprintf +#define strdup _strdup +#define write _write +#define open _open +#define random rand +#define close closesocket +#define __func__ __FUNCTION__ +#ifndef _CRT_SECURE_NO_WARNINGS +#define _CRT_SECURE_NO_WARNINGS +#endif + +/* __FUNCTION__ available in VC ++ 7.0 (.NET) and greater */ +#if _MSC_VER < 1300 +#define __FUNCTION__ __FILE__ +#endif + +/* the following is only supported by MSVC and not by MinGW/MSys environements */ +#ifdef _MSC_VER +#pragma comment (lib,"ws2_32") /* Winsock 2 */ +#pragma comment (lib,"iphlpapi") /* IP Helper */ +#pragma comment (lib,"wpcap") /* Winpcap */ +#pragma comment (lib,"packet") +#endif + +/* FIXME this needs manual update during release packaging. */ +#define LIBNET_VERSION "1.1.6" + +/* To use Win32 native versions */ +#define WPCAP 1 +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define LIBNET_API __declspec(dllexport) + +#include "libnet/stdint.h" +#include "libnet/libnet-macros.h" +#include "libnet/libnet-headers.h" +#include "libnet/libnet-structures.h" +#include "libnet/libnet-asn1.h" +#include "libnet/libnet-functions.h" + +#ifdef __cplusplus +} +#endif + +#endif /* __LIBNET_H */ + +#endif +/* EOF */ diff --git a/libnet/win32/stdint.h b/libnet/win32/stdint.h new file mode 100644 index 0000000..d02608a --- /dev/null +++ b/libnet/win32/stdint.h @@ -0,0 +1,247 @@ +// ISO C9x compliant stdint.h for Microsoft Visual Studio +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// +// Copyright (c) 2006-2008 Alexander Chemeris +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. The name of the author may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_STDINT_H_ // [ +#define _MSC_STDINT_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +// For Visual Studio 6 in C++ mode and for many Visual Studio versions when +// compiling for ARM we should wrap include with 'extern "C++" {}' +// or compiler give many errors like this: +// error C2733: second C linkage of overloaded function 'wmemchr' not allowed +#ifdef __cplusplus +extern "C" { +#endif +# include +#ifdef __cplusplus +} +#endif + +// Define _W64 macros to mark types changing their size, like intptr_t. +#ifndef _W64 +# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 +# define _W64 __w64 +# else +# define _W64 +# endif +#endif + + +// 7.18.1 Integer types + +// 7.18.1.1 Exact-width integer types + +// Visual Studio 6 and Embedded Visual C++ 4 doesn't +// realize that, e.g. char has the same size as __int8 +// so we give up on __intX for them. +#if (_MSC_VER < 1300) + typedef signed char int8_t; + typedef signed short int16_t; + typedef signed int int32_t; + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned int uint32_t; +#else + typedef signed __int8 int8_t; + typedef signed __int16 int16_t; + typedef signed __int32 int32_t; + typedef unsigned __int8 uint8_t; + typedef unsigned __int16 uint16_t; + typedef unsigned __int32 uint32_t; +#endif +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; + + +// 7.18.1.2 Minimum-width integer types +typedef int8_t int_least8_t; +typedef int16_t int_least16_t; +typedef int32_t int_least32_t; +typedef int64_t int_least64_t; +typedef uint8_t uint_least8_t; +typedef uint16_t uint_least16_t; +typedef uint32_t uint_least32_t; +typedef uint64_t uint_least64_t; + +// 7.18.1.3 Fastest minimum-width integer types +typedef int8_t int_fast8_t; +typedef int16_t int_fast16_t; +typedef int32_t int_fast32_t; +typedef int64_t int_fast64_t; +typedef uint8_t uint_fast8_t; +typedef uint16_t uint_fast16_t; +typedef uint32_t uint_fast32_t; +typedef uint64_t uint_fast64_t; + +// 7.18.1.4 Integer types capable of holding object pointers +#ifdef _WIN64 // [ + typedef signed __int64 intptr_t; + typedef unsigned __int64 uintptr_t; +#else // _WIN64 ][ + typedef _W64 signed int intptr_t; + typedef _W64 unsigned int uintptr_t; +#endif // _WIN64 ] + +// 7.18.1.5 Greatest-width integer types +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; + + +// 7.18.2 Limits of specified-width integer types + +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 + +// 7.18.2.1 Limits of exact-width integer types +#define INT8_MIN ((int8_t)_I8_MIN) +#define INT8_MAX _I8_MAX +#define INT16_MIN ((int16_t)_I16_MIN) +#define INT16_MAX _I16_MAX +#define INT32_MIN ((int32_t)_I32_MIN) +#define INT32_MAX _I32_MAX +#define INT64_MIN ((int64_t)_I64_MIN) +#define INT64_MAX _I64_MAX +#define UINT8_MAX _UI8_MAX +#define UINT16_MAX _UI16_MAX +#define UINT32_MAX _UI32_MAX +#define UINT64_MAX _UI64_MAX + +// 7.18.2.2 Limits of minimum-width integer types +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MIN INT64_MIN +#define INT_LEAST64_MAX INT64_MAX +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX + +// 7.18.2.3 Limits of fastest minimum-width integer types +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST16_MIN INT16_MIN +#define INT_FAST16_MAX INT16_MAX +#define INT_FAST32_MIN INT32_MIN +#define INT_FAST32_MAX INT32_MAX +#define INT_FAST64_MIN INT64_MIN +#define INT_FAST64_MAX INT64_MAX +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST16_MAX UINT16_MAX +#define UINT_FAST32_MAX UINT32_MAX +#define UINT_FAST64_MAX UINT64_MAX + +// 7.18.2.4 Limits of integer types capable of holding object pointers +#ifdef _WIN64 // [ +# define INTPTR_MIN INT64_MIN +# define INTPTR_MAX INT64_MAX +# define UINTPTR_MAX UINT64_MAX +#else // _WIN64 ][ +# define INTPTR_MIN INT32_MIN +# define INTPTR_MAX INT32_MAX +# define UINTPTR_MAX UINT32_MAX +#endif // _WIN64 ] + +// 7.18.2.5 Limits of greatest-width integer types +#define INTMAX_MIN INT64_MIN +#define INTMAX_MAX INT64_MAX +#define UINTMAX_MAX UINT64_MAX + +// 7.18.3 Limits of other integer types + +#ifdef _WIN64 // [ +# define PTRDIFF_MIN _I64_MIN +# define PTRDIFF_MAX _I64_MAX +#else // _WIN64 ][ +# define PTRDIFF_MIN _I32_MIN +# define PTRDIFF_MAX _I32_MAX +#endif // _WIN64 ] + +#define SIG_ATOMIC_MIN INT_MIN +#define SIG_ATOMIC_MAX INT_MAX + +#ifndef SIZE_MAX // [ +# ifdef _WIN64 // [ +# define SIZE_MAX _UI64_MAX +# else // _WIN64 ][ +# define SIZE_MAX _UI32_MAX +# endif // _WIN64 ] +#endif // SIZE_MAX ] + +// WCHAR_MIN and WCHAR_MAX are also defined in +#ifndef WCHAR_MIN // [ +# define WCHAR_MIN 0 +#endif // WCHAR_MIN ] +#ifndef WCHAR_MAX // [ +# define WCHAR_MAX _UI16_MAX +#endif // WCHAR_MAX ] + +#define WINT_MIN 0 +#define WINT_MAX _UI16_MAX + +#endif // __STDC_LIMIT_MACROS ] + + +// 7.18.4 Limits of other integer types + +#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 + +// 7.18.4.1 Macros for minimum-width integer constants + +#define INT8_C(val) val##i8 +#define INT16_C(val) val##i16 +#define INT32_C(val) val##i32 +#define INT64_C(val) val##i64 + +#define UINT8_C(val) val##ui8 +#define UINT16_C(val) val##ui16 +#define UINT32_C(val) val##ui32 +#define UINT64_C(val) val##ui64 + +// 7.18.4.2 Macros for greatest-width integer constants +#define INTMAX_C INT64_C +#define UINTMAX_C UINT64_C + +#endif // __STDC_CONSTANT_MACROS ] + + +#endif // _MSC_STDINT_H_ ] -- cgit v1.2.1