1: /*
   2: ** id_query.c                             Transmit a query to an IDENT server
   3: **
   4: ** Author: Peter Eriksson <pen@lysator.liu.se>
   5: */
   6: 
   7: #ifdef NeXT3
   8: #  include <libc.h>
   9: #endif
  10: 
  11: #include <stdio.h>
  12: #include <errno.h>
  13: #include <signal.h>
  14: 
  15: #ifdef HAVE_ANSIHEADERS
  16: #  include <stdlib.h>
  17: #  include <string.h>
  18: #  include <unistd.h>
  19: #endif
  20: 
  21: #include <sys/types.h>
  22: #include <sys/wait.h>
  23: #include <sys/time.h>
  24: 
  25: #ifdef _AIX
  26: #  include <sys/select.h>
  27: #endif
  28: 
  29: #ifdef _AIX
  30: #  include <sys/select.h>
  31: #endif
  32: #ifdef VMS
  33: #  include <sys/socket.h>     /* for fd_set */
  34: #endif
  35: #define IN_LIBIDENT_SRC
  36: #include "ident.h"
  37: 
  38: 
  39: int id_query __P4(ident_t *, id,
  40:           int, lport,
  41:           int, fport,
  42:           struct timeval *, timeout)
  43: {
  44: #ifdef SIGRETURNTYPE
  45:     SIGRETURNTYPE (*old_sig)();
  46: #else
  47:     void (*old_sig) __P((int));
  48: #endif
  49:     int res;
  50:     char buf[80];
  51:     fd_set ws;
  52: 
  53:     sprintf(buf, "%d , %d\r\n", lport, fport);
  54: 
  55:     if (timeout)
  56:     {
  57:     FD_ZERO(&ws);
  58:     FD_SET(id->fd, &ws);
  59: 
  60: #ifdef __hpux
  61:     if ((res = select(FD_SETSIZE, (int *)0, (int *)&ws, (int *)0, timeout)) < 0)
  62: #else
  63:     if ((res = select(FD_SETSIZE, (fd_set *)0, &ws, (fd_set *)0, timeout)) < 0)
  64: #endif
  65:         return -1;
  66: 
  67:     if (res == 0)
  68:     {
  69:         errno = ETIMEDOUT;
  70:         return -1;
  71:     }
  72:     }
  73: 
  74:     old_sig = signal(SIGPIPE, SIG_IGN);
  75: 
  76:     res = write(id->fd, buf, strlen(buf));
  77: 
  78:     signal(SIGPIPE, old_sig);
  79: 
  80:     return res;
  81: }

Defined functions

__P4 defined in line 39; never used

Defined variables

Defined macros

IN_LIBIDENT_SRC defined in line 35; never used
Last modified: 1995-11-23
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1301
Valid CSS Valid XHTML 1.0 Strict