home *** CD-ROM | disk | FTP | other *** search
/ ftp.ncftp.com / ftp.ncftp.com.zip / ftp.ncftp.com / libncftp / older_versions / libncftp-3.1.5-src.tar.gz / libncftp-3.1.5-src.tar / libncftp-3.1.5 / sio / main.c < prev    next >
C/C++ Source or Header  |  2001-11-19  |  973b  |  57 lines

  1. #include "syshdrs.h"
  2. #ifdef PRAGMA_HDRSTOP
  3. #    pragma hdrstop
  4. #endif
  5.  
  6. int gLibSio_Uses_Me_To_Quiet_Variable_Unused_Warnings = 0;
  7.  
  8. #ifndef NO_SIGNALS
  9.  
  10. #if defined(HPUX) || defined(__hpux__)
  11. volatile Sjmp_buf gNetTimeoutJmp;
  12. volatile Sjmp_buf gPipeJmp;
  13. #else
  14. Sjmp_buf gNetTimeoutJmp;
  15. Sjmp_buf gPipeJmp;
  16. #endif
  17.  
  18. void
  19. SIOHandler(int sigNum)
  20. {
  21.     if (sigNum == SIGPIPE)
  22.         SLongjmp(gPipeJmp, 1);
  23.     SLongjmp(gNetTimeoutJmp, 1);
  24. }    /* SIOHandler */
  25.  
  26.  
  27.  
  28.  
  29. void (*SSignal(int signum, void (*handler)(int)))(int)
  30. {
  31. #ifdef HAVE_SIGACTION
  32.     struct sigaction sa, osa;
  33.  
  34.     (void) sigemptyset(&sa.sa_mask);
  35.     sa.sa_flags = 0;
  36.     sa.sa_handler = handler;
  37.     if (signum == SIGALRM) {
  38. #ifdef SA_INTERRUPT
  39.         sa.sa_flags |= SA_INTERRUPT;
  40. #endif
  41.     } else {
  42. #ifdef SA_RESTART
  43.         sa.sa_flags |= SA_RESTART;
  44. #endif
  45.     }
  46.     if (sigaction(signum, &sa, &osa) < 0)
  47.         return (SIG_ERR);
  48.     return (osa.sa_handler);
  49. #else
  50.     return SSignal(signum, handler);
  51. #endif    /* HAVE_SIGACTION */
  52. }
  53.  
  54. #endif    /* NO_SIGNALS */
  55.  
  56. /* eof main.c */
  57.