1/* Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
2 * Copyright (c) 1999-2011 Douglas Gilbert. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms,
5 * with or without modification, are permitted provided
6 * that the following conditions are met:
7 *
8 *   Redistributions of source code must retain the above
9 *   copyright notice, this list of conditions and the
10 *   following disclaimer.
11 *
12 *   Redistributions in binary form must reproduce the above
13 *   copyright notice, this list of conditions and the following
14 *   disclaimer in the documentation and/or other materials
15 *   provided with the distribution.
16 *
17 *   Neither the name of the copyright holder nor the names
18 *   of any other contributors may be used to endorse or
19 *   promote products derived from this software without
20 *   specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
23 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
24 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
34 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
35 * OF SUCH DAMAGE.
36 */
37
38/* Headers */
39#cmakedefine HAVE_UNISTD_H
40#cmakedefine HAVE_INTTYPES_H
41#cmakedefine HAVE_STDLIB_H
42#cmakedefine HAVE_SYS_SELECT_H
43#cmakedefine HAVE_SYS_UIO_H
44#cmakedefine HAVE_SYS_SOCKET_H
45#cmakedefine HAVE_SYS_IOCTL_H
46#cmakedefine HAVE_SYS_TIME_H
47#cmakedefine HAVE_SYS_UN_H
48#cmakedefine HAVE_WINDOWS_H
49#cmakedefine HAVE_WS2TCPIP_H
50#cmakedefine HAVE_WINSOCK2_H
51#cmakedefine HAVE_NTDEF_H
52#cmakedefine HAVE_NTSTATUS_H
53
54/* Libraries */
55#cmakedefine HAVE_LIBCRYPT32
56
57/* Types */
58#cmakedefine HAVE_LONGLONG
59
60/* Functions */
61#cmakedefine HAVE_GETTIMEOFDAY
62#cmakedefine HAVE_INET_ADDR
63#cmakedefine HAVE_POLL
64#cmakedefine HAVE_SELECT
65#cmakedefine HAVE_SOCKET
66#cmakedefine HAVE_STRTOLL
67#cmakedefine HAVE_STRTOI64
68#cmakedefine HAVE_SNPRINTF
69
70/* OpenSSL functions */
71#cmakedefine HAVE_EVP_AES_128_CTR
72
73/* Socket non-blocking support */
74#cmakedefine HAVE_O_NONBLOCK
75#cmakedefine HAVE_FIONBIO
76#cmakedefine HAVE_IOCTLSOCKET
77#cmakedefine HAVE_IOCTLSOCKET_CASE
78#cmakedefine HAVE_SO_NONBLOCK
79#cmakedefine HAVE_DISABLED_NONBLOCKING
80
81/* snprintf not in Visual Studio CRT and _snprintf dangerously incompatible.
82   We provide a safe wrapper if snprintf not found */
83#ifndef HAVE_SNPRINTF
84#include <stdio.h>
85#include <stdarg.h>
86/* Want safe, 'n += snprintf(b + n ...)' like function. If cp_max_len is 1
87* then assume cp is pointing to a null char and do nothing. Returns number
88* number of chars placed in cp excluding the trailing null char. So for
89* cp_max_len > 0 the return value is always < cp_max_len; for cp_max_len
90* <= 0 the return value is 0 (and no chars are written to cp). */
91static int snprintf(char * cp, int cp_max_len, const char * fmt, ...)
92{
93    va_list args;
94    int n;
95
96    if (cp_max_len < 2)
97        return 0;
98    va_start(args, fmt);
99    n = vsnprintf(cp, cp_max_len, fmt, args);
100    va_end(args);
101    return (n < cp_max_len) ? n : (cp_max_len - 1);
102}
103
104#define HAVE_SNPRINTF
105#endif
106