netutil.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* Network utilities for the Midnight Commander Virtual File System.
  2. Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2005, 2007
  3. Free Software Foundation, Inc.
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License
  6. as published by the Free Software Foundation; either version 2 of
  7. the License, or (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
  15. /**
  16. * \file
  17. * \brief Source: Virtual File System: Network utilities
  18. */
  19. #include <config.h>
  20. #include <stdlib.h>
  21. #include <signal.h>
  22. #include "lib/global.h"
  23. #include "netutil.h"
  24. /*** global variables ****************************************************************************/
  25. volatile sig_atomic_t got_sigpipe = 0;
  26. /*** file scope macro definitions ****************************************************************/
  27. /*** file scope type declarations ****************************************************************/
  28. /*** file scope variables ************************************************************************/
  29. /*** file scope functions ************************************************************************/
  30. /* --------------------------------------------------------------------------------------------- */
  31. static void
  32. sig_pipe (int unused)
  33. {
  34. (void) unused;
  35. got_sigpipe = 1;
  36. }
  37. /* --------------------------------------------------------------------------------------------- */
  38. /*** public functions ****************************************************************************/
  39. /* --------------------------------------------------------------------------------------------- */
  40. void
  41. tcp_init (void)
  42. {
  43. static gboolean initialized = FALSE;
  44. struct sigaction sa;
  45. if (initialized)
  46. return;
  47. got_sigpipe = 0;
  48. sa.sa_handler = sig_pipe;
  49. sa.sa_flags = 0;
  50. sigemptyset (&sa.sa_mask);
  51. sigaction (SIGPIPE, &sa, NULL);
  52. initialized = TRUE;
  53. }
  54. /* --------------------------------------------------------------------------------------------- */