1
2/**
3 * \file windows-config.h
4 *
5 *  This file contains all of the routines that must be linked into
6 *  an executable to use the generated option processing.  The optional
7 *  routines are in separately compiled modules so that they will not
8 *  necessarily be linked in.
9 *
10 *  This file is part of AutoOpts, a companion to AutoGen.
11 *  AutoOpts is free software.
12 *  AutoOpts is Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
13 *
14 *  AutoOpts is available under any one of two licenses.  The license
15 *  in use must be one of these two and the choice is under the control
16 *  of the user of the license.
17 *
18 *   The GNU Lesser General Public License, version 3 or later
19 *      See the files "COPYING.lgplv3" and "COPYING.gplv3"
20 *
21 *   The Modified Berkeley Software Distribution License
22 *      See the file "COPYING.mbsd"
23 *
24 *  These files have the following sha256 sums:
25 *
26 *  8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95  COPYING.gplv3
27 *  4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b  COPYING.lgplv3
28 *  13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239  COPYING.mbsd
29 */
30
31#ifndef WINDOWS_CONFIG_HACKERY
32#define WINDOWS_CONFIG_HACKERY 1
33
34/*
35 * The definitions below have been stolen from NTP's config.h for Windows.
36 * However, they may be kept here in order to keep libopts independent from
37 * the NTP project.
38 */
39#ifndef __windows__
40#  define __windows__ 4
41#endif
42
43/*
44 * Miscellaneous functions that Microsoft maps to other names
45 */
46#define snprintf _snprintf
47
48#define SIZEOF_INT   4
49#define SIZEOF_CHARP 4
50#define SIZEOF_LONG  4
51#define SIZEOF_SHORT 2
52
53#define HAVE_LIMITS_H   1
54#define HAVE_STRDUP     1
55#define HAVE_STRCHR     1
56#define HAVE_FCNTL_H    1
57
58/*
59 * VS.NET's version of wspiapi.h has a bug in it where it assigns a value
60 * to a variable inside an if statement. It should be comparing them.
61 * We prevent inclusion since we are not using this code so we don't have
62 * to see the warning messages
63 */
64#ifndef _WSPIAPI_H_
65#define _WSPIAPI_H_
66#endif
67
68/* Prevent inclusion of winsock.h in windows.h */
69#ifndef _WINSOCKAPI_
70#define _WINSOCKAPI_
71#endif
72
73#ifndef __RPCASYNC_H__
74#define __RPCASYNC_H__
75#endif
76
77/* Include Windows headers */
78#include <windows.h>
79#include <winsock2.h>
80#include <limits.h>
81
82/*
83 * Compatibility declarations for Windows, assuming SYS_WINNT
84 * has been defined.
85 */
86#define strdup  _strdup
87#define stat    _stat       /* struct stat from <sys/stat.h> */
88#define unlink  _unlink
89#define fchmod( _x, _y )
90#define ssize_t SSIZE_T
91
92#include <io.h>
93#define open    _open
94#define close   _close
95#define read    _read
96#define write   _write
97#define lseek   _lseek
98#define pipe    _pipe
99#define dup2    _dup2
100
101#define O_RDWR     _O_RDWR
102#define O_RDONLY   _O_RDONLY
103#define O_EXCL     _O_EXCL
104
105#ifndef S_ISREG
106#  define S_IFREG _S_IFREG
107#  define       S_ISREG(mode)   (((mode) & S_IFREG) == S_IFREG)
108#endif
109
110#ifndef S_ISDIR
111#  define S_IFDIR _S_IFDIR
112#  define       S_ISDIR(mode)   (((mode) & S_IFDIR) == S_IFDIR)
113#endif
114
115/* C99 exact size integer support. */
116#if defined(HAVE_INTTYPES_H)
117# include <inttypes.h>
118
119#elif defined(HAVE_STDINT_H)
120# include <stdint.h>
121# define MISSING_INTTYPES_H 1
122
123#elif ! defined(ADDED_EXACT_SIZE_INTEGERS)
124# define ADDED_EXACT_SIZE_INTEGERS 1
125# define MISSING_INTTYPES_H 1
126
127  typedef __int8 int8_t;
128  typedef unsigned __int8 uint8_t;
129
130  typedef __int16 int16_t;
131  typedef unsigned __int16 uint16_t;
132
133  typedef __int32 int32_t;
134  typedef unsigned __int32 uint32_t;
135
136  typedef __int64 int64_t;
137  typedef unsigned __int64 uint64_t;
138
139  typedef unsigned long uintptr_t;
140  typedef long intptr_t;
141#endif
142
143#endif /* WINDOWS_CONFIG_HACKERY */
144/* windows-config.h ends here */
145