Blame src/gl/sockets.h

Packit aea12f
/* sockets.h - wrappers for Windows socket functions
Packit aea12f
Packit Service 991b93
   Copyright (C) 2008-2020 Free Software Foundation, Inc.
Packit aea12f
Packit aea12f
   This program is free software: you can redistribute it and/or modify
Packit aea12f
   it under the terms of the GNU General Public License as published by
Packit aea12f
   the Free Software Foundation; either version 3 of the License, or
Packit aea12f
   (at your option) any later version.
Packit aea12f
Packit aea12f
   This program is distributed in the hope that it will be useful,
Packit aea12f
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit aea12f
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit aea12f
   GNU General Public License for more details.
Packit aea12f
Packit aea12f
   You should have received a copy of the GNU General Public License
Packit aea12f
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
Packit aea12f
Packit aea12f
/* Written by Simon Josefsson */
Packit aea12f
Packit aea12f
#ifndef SOCKETS_H
Packit aea12f
#define SOCKETS_H 1
Packit aea12f
Packit aea12f
#define SOCKETS_1_0 0x0001
Packit aea12f
#define SOCKETS_1_1 0x0101
Packit aea12f
#define SOCKETS_2_0 0x0002
Packit aea12f
#define SOCKETS_2_1 0x0102
Packit aea12f
#define SOCKETS_2_2 0x0202
Packit aea12f
Packit aea12f
int gl_sockets_startup (int version)
Packit aea12f
#ifndef WINDOWS_SOCKETS
Packit aea12f
  _GL_ATTRIBUTE_CONST
Packit aea12f
#endif
Packit aea12f
  ;
Packit aea12f
Packit aea12f
int gl_sockets_cleanup (void)
Packit aea12f
#ifndef WINDOWS_SOCKETS
Packit aea12f
  _GL_ATTRIBUTE_CONST
Packit aea12f
#endif
Packit aea12f
  ;
Packit aea12f
Packit aea12f
/* This function is useful it you create a socket using gnulib's
Packit aea12f
   Winsock wrappers but needs to pass on the socket handle to some
Packit aea12f
   other library that only accepts sockets. */
Packit aea12f
#ifdef WINDOWS_SOCKETS
Packit aea12f
Packit aea12f
# include <sys/socket.h>
Packit aea12f
Packit aea12f
# if GNULIB_MSVC_NOTHROW
Packit aea12f
#  include "msvc-nothrow.h"
Packit aea12f
# else
Packit aea12f
#  include <io.h>
Packit aea12f
# endif
Packit aea12f
Packit aea12f
static inline SOCKET
Packit aea12f
gl_fd_to_handle (int fd)
Packit aea12f
{
Packit aea12f
  return _get_osfhandle (fd);
Packit aea12f
}
Packit aea12f
Packit aea12f
#else
Packit aea12f
Packit aea12f
# define gl_fd_to_handle(x) (x)
Packit aea12f
Packit aea12f
#endif /* WINDOWS_SOCKETS */
Packit aea12f
Packit aea12f
#endif /* SOCKETS_H */