Debian Codegraph @

src/microhttpd/sysfdsetsize.c

raw
1 /*
2 This file is part of libmicrohttpd
3 Copyright (C) 2015-2023 Karlson2k (Evgeny Grin)
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 /**
21 * @file microhttpd/sysfdsetsize.c
22 * @brief Helper for obtaining FD_SETSIZE system default value
23 * @author Karlson2k (Evgeny Grin)
24 */
25
26
27 #include "mhd_options.h"
28
29 #ifndef MHD_SYS_FD_SETSIZE_
30
31 #include "sysfdsetsize.h"
32
33 #ifdef FD_SETSIZE
34 /* FD_SETSIZE was defined before system headers. */
35 /* To get system value of FD_SETSIZE, undefine FD_SETSIZE
36 here. */
37 #undef FD_SETSIZE
38 #endif /* FD_SETSIZE */
39
40 #ifdef HAVE_STDLIB_H
41 #include <stdlib.h>
42 #endif /* HAVE_STDLIB_H */
43 #if defined(__VXWORKS__) || defined(__vxworks) || defined(OS_VXWORKS)
44 #include <sockLib.h>
45 #endif /* OS_VXWORKS */
46 #ifdef HAVE_SYS_SELECT_H
47 #include <sys/select.h>
48 #endif /* HAVE_SYS_SELECT_H */
49 #ifdef HAVE_SYS_TYPES_H
50 #include <sys/types.h>
51 #endif /* HAVE_SYS_TYPES_H */
52 #ifdef HAVE_SYS_TIME_H
53 #include <sys/time.h>
54 #endif /* HAVE_SYS_TIME_H */
55 #ifdef HAVE_TIME_H
56 #include <time.h>
57 #endif /* HAVE_TIME_H */
58 #ifdef HAVE_UNISTD_H
59 #include <unistd.h>
60 #endif /* HAVE_UNISTD_H */
61 #ifdef HAVE_SYS_SOCKET_H
62 #include <sys/socket.h>
63 #endif /* HAVE_SYS_SOCKET_H */
64
65 #if defined(_WIN32) && ! defined(__CYGWIN__)
66 #ifndef WIN32_LEAN_AND_MEAN
67 #define WIN32_LEAN_AND_MEAN 1
68 #endif /* !WIN32_LEAN_AND_MEAN */
69 #include <winsock2.h>
70 #endif /* _WIN32 && !__CYGWIN__ */
71
72 #ifndef FD_SETSIZE
73 #error FD_SETSIZE must be defined in system headers
74 #endif /* !FD_SETSIZE */
75
76
77 /**
78 * Get system default value of FD_SETSIZE
79 * @return system default value of FD_SETSIZE
80 */
81 unsigned int
82 get_system_fdsetsize_value (void)
83 {
84 return (unsigned int) FD_SETSIZE;
85 }
86
87
88 #endif /* ! MHD_SYS_FD_SETSIZE_ */