Blame gl/tests/test-sys_socket.c

Packit Service 4684c1
/* Test of <sys/socket.h> substitute.
Packit Service 4684c1
   Copyright (C) 2007, 2009-2020 Free Software Foundation, Inc.
Packit Service 4684c1
Packit Service 4684c1
   This program is free software: you can redistribute it and/or modify
Packit Service 4684c1
   it under the terms of the GNU General Public License as published by
Packit Service 4684c1
   the Free Software Foundation; either version 3 of the License, or
Packit Service 4684c1
   (at your option) any later version.
Packit Service 4684c1
Packit Service 4684c1
   This program is distributed in the hope that it will be useful,
Packit Service 4684c1
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 4684c1
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 4684c1
   GNU General Public License for more details.
Packit Service 4684c1
Packit Service 4684c1
   You should have received a copy of the GNU General Public License
Packit Service 4684c1
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
Packit Service 4684c1
Packit Service 4684c1
/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
Packit Service 4684c1
Packit Service 4684c1
#include <config.h>
Packit Service 4684c1
Packit Service 4684c1
#include <sys/socket.h>
Packit Service 4684c1
Packit Service 4684c1
#include <errno.h>
Packit Service 4684c1
Packit Service 4684c1
#if HAVE_SHUTDOWN
Packit Service 4684c1
/* Check some integer constant expressions.  */
Packit Service 4684c1
int a[] = { SHUT_RD, SHUT_WR, SHUT_RDWR };
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
/* Check that the 'socklen_t' type is defined.  */
Packit Service 4684c1
socklen_t t1;
Packit Service 4684c1
Packit Service 4684c1
/* Check that the 'size_t' and 'ssize_t' types are defined.  */
Packit Service 4684c1
size_t t2;
Packit Service 4684c1
ssize_t t3;
Packit Service 4684c1
Packit Service 4684c1
/* Check that 'struct iovec' is defined.  */
Packit Service 4684c1
struct iovec io;
Packit Service 4684c1
Packit Service 4684c1
/* Check that a minimal set of 'struct msghdr' is defined.  */
Packit Service 4684c1
struct msghdr msg;
Packit Service 4684c1
Packit Service 4684c1
int
Packit Service 4684c1
main (void)
Packit Service 4684c1
{
Packit Service 4684c1
  struct sockaddr_storage x;
Packit Service 4684c1
  sa_family_t i;
Packit Service 4684c1
Packit Service 4684c1
  /* Check some errno values.  */
Packit Service 4684c1
  switch (ENOTSOCK)
Packit Service 4684c1
    {
Packit Service 4684c1
    case ENOTSOCK:
Packit Service 4684c1
    case EADDRINUSE:
Packit Service 4684c1
    case ENETRESET:
Packit Service 4684c1
    case ECONNABORTED:
Packit Service 4684c1
    case ECONNRESET:
Packit Service 4684c1
    case ENOTCONN:
Packit Service 4684c1
    case ESHUTDOWN:
Packit Service 4684c1
      break;
Packit Service 4684c1
    }
Packit Service 4684c1
Packit Service 4684c1
  x.ss_family = 42;
Packit Service 4684c1
  i = 42;
Packit Service 4684c1
  msg.msg_iov = &io;
Packit Service 4684c1
Packit Service 4684c1
  return (x.ss_family - i + msg.msg_namelen + msg.msg_iov->iov_len
Packit Service 4684c1
          + msg.msg_iovlen);
Packit Service 4684c1
}