LCOV - code coverage report
Current view: top level - src/utils - net.c (source / functions) Hit Total Coverage
Test: FreeTDS coverage Lines: 2 2 100.0 %
Date: 2025-01-18 12:13:41 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
       2             :  * Copyright (C) 2018  Ziglio Frediano
       3             :  *
       4             :  * This library is free software; you can redistribute it and/or
       5             :  * modify it under the terms of the GNU Library General Public
       6             :  * License as published by the Free Software Foundation; either
       7             :  * version 2 of the License, or (at your option) any later version.
       8             :  *
       9             :  * This library is distributed in the hope that it will be useful,
      10             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      12             :  * Library General Public License for more details.
      13             :  *
      14             :  * You should have received a copy of the GNU Library General Public
      15             :  * License along with this library; if not, write to the
      16             :  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      17             :  * Boston, MA 02111-1307, USA.
      18             :  */
      19             : 
      20             : #include <config.h>
      21             : 
      22             : #include <stdio.h>
      23             : 
      24             : #if HAVE_SYS_TYPES_H
      25             : #include <sys/types.h>
      26             : #endif /* HAVE_SYS_TYPES_H */
      27             : 
      28             : #if HAVE_ERRNO_H
      29             : #include <errno.h>
      30             : #endif /* HAVE_ERRNO_H */
      31             : 
      32             : #if HAVE_UNISTD_H
      33             : #include <unistd.h>
      34             : #endif /* HAVE_UNISTD_H */
      35             : 
      36             : #if HAVE_STDLIB_H
      37             : #include <stdlib.h>
      38             : #endif /* HAVE_STDLIB_H */
      39             : 
      40             : #if HAVE_SYS_SOCKET_H
      41             : #include <sys/socket.h>
      42             : #endif /* HAVE_SYS_SOCKET_H */
      43             : 
      44             : #if HAVE_NETINET_IN_H
      45             : #include <netinet/in.h>
      46             : #endif /* HAVE_NETINET_IN_H */
      47             : 
      48             : #ifdef _WIN32
      49             : #include <winsock2.h>
      50             : #endif
      51             : 
      52             : #include <freetds/utils.h>
      53             : 
      54             : /**
      55             :  * \addtogroup network
      56             :  * @{
      57             :  */
      58             : 
      59             : #ifndef __APPLE__
      60             : #undef SO_NOSIGPIPE
      61             : #endif
      62             : 
      63             : /**
      64             :  * Set socket to not throw SIGPIPE.
      65             :  * Not many systems support this feature (in this case ENOTSUP can be
      66             :  * returned).
      67             :  * @param sock socket to set
      68             :  * @param on   flag if enable or disable
      69             :  * @return 0 on success or error code
      70             :  */
      71             : int
      72          32 : tds_socket_set_nosigpipe(TDS_SYS_SOCKET sock, int on)
      73             : {
      74             : #if defined(SO_NOSIGPIPE)
      75             :         if (setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, (const void *) &on, sizeof(on)))
      76             :                 return sock_errno;
      77             :         return 0;
      78             : #elif defined(_WIN32)
      79             :         return 0;
      80             : #else
      81          32 :         return on ? ENOTSUP : 0;
      82             : #endif
      83             : }
      84             : 
      85             : /** @} */
      86             : 

Generated by: LCOV version 1.13