Back to index

nagios-plugins  1.4.16
sockets.h
Go to the documentation of this file.
00001 /* sockets.h - wrappers for Windows socket functions
00002 
00003    Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
00004 
00005    This program is free software: you can redistribute it and/or modify
00006    it under the terms of the GNU General Public License as published by
00007    the Free Software Foundation; either version 3 of the License, or
00008    (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00017 
00018 /* Written by Simon Josefsson */
00019 
00020 #ifndef SOCKETS_H
00021 # define SOCKETS_H 1
00022 
00023 #define SOCKETS_1_0 0x100  /* don't use - does not work on Windows XP */
00024 #define SOCKETS_1_1 0x101
00025 #define SOCKETS_2_0 0x200  /* don't use - does not work on Windows XP */
00026 #define SOCKETS_2_1 0x201
00027 #define SOCKETS_2_2 0x202
00028 
00029 int gl_sockets_startup (int version);
00030 int gl_sockets_cleanup (void);
00031 
00032 /* This function is useful it you create a socket using gnulib's
00033    Winsock wrappers but needs to pass on the socket handle to some
00034    other library that only accepts sockets. */
00035 #if WINDOWS_SOCKETS
00036 
00037 #include <sys/socket.h>
00038 
00039 static inline SOCKET
00040 gl_fd_to_handle (int fd)
00041 {
00042   return _get_osfhandle (fd);
00043 }
00044 
00045 #else
00046 
00047 #define gl_fd_to_handle(x) (x)
00048 
00049 #endif /* WINDOWS_SOCKETS */
00050 
00051 #endif /* SOCKETS_H */