1: /*
   2: ** proxy.c                         This file implements the proxy() call.
   3: **
   4: ** This program is in the public domain and may be used freely by anyone
   5: ** who wants to.
   6: **
   7: ** Last update: 12 Dec 1992
   8: **
   9: ** Please send bug fixes/bug reports to: Peter Eriksson <pen@lysator.liu.se>
  10: */
  11: 
  12: #include <stdio.h>
  13: #include <errno.h>
  14: 
  15: #include "identd.h"
  16: 
  17: 
  18: #ifdef INCLUDE_PROXY
  19: #include <sys/types.h>
  20: #include <sys/time.h>
  21: #include <netinet/in.h>
  22: 
  23: #include <ident.h>
  24: #endif
  25: 
  26: #ifndef __STDC__
  27: #define void int
  28: #endif
  29: 
  30: /*
  31: ** This function should establish a connection to a remote IDENT
  32: ** server and query it for the information associated with the
  33: ** specified connection and the return that to the caller.
  34: **
  35: ** Should there be three different timeouts (Connection Establishment,
  36: ** Query Transmit and Query Receive)?
  37: */
  38: int proxy(laddr, faddr, lport, fport, timeout)
  39: #ifdef INCLUDE_PROXY
  40:     struct in_addr *laddr;
  41:     struct in_addr *faddr;
  42: #else
  43:     void *laddr, *faddr;
  44: #endif
  45:     int lport;
  46:     int fport;
  47: #ifdef INCLUDE_PROXY
  48:     struct timeval *timeout;
  49: #else
  50:     void *timeout;
  51: #endif
  52: {
  53: #ifndef INCLUDE_PROXY
  54:     /* Just here to make the compiler shut up! */
  55:     laddr = faddr = NULL;
  56:     timeout = NULL;
  57: 
  58:     printf("%d , %d : ERROR : %s\r\n",
  59:        lport, fport,
  60:        unknown_flag ? "UNKNOWN-ERROR" : "X-NOT-YET-IMPLEMENTED");
  61: 
  62:     return -1;
  63: #else
  64:   id_t *idp;
  65:   char *answer;
  66:   char *opsys;
  67:   char *charset;
  68: 
  69:   idp = id_open(laddr, faddr, timeout);
  70:   if (!idp)
  71:   {
  72:     printf("%d , %d : ERROR : %s\r\n",
  73:        lport, fport,
  74:        unknown_flag ? "UNKNOWN-ERROR" : "X-CONNECTION-REFUSED");
  75:     return -1;
  76:   }
  77: 
  78:   if (id_query(idp, lport, fport, timeout) < 0)
  79:   {
  80:     printf("%d , %d : ERROR : %s\r\n",
  81:        lport, fport,
  82:        unknown_flag ? "UNKNOWN-ERROR" : "X-TRANSMIT-QUERY-ERROR");
  83:     id_close(idp);
  84:     return -1;
  85:   }
  86: 
  87:   switch (id_parse(idp, timeout, &lport, &fport, &answer, &opsys, &charset))
  88:   {
  89:     case 1:
  90:       printf("%d , %d : USERID : %s %s%s : %s\r\n",
  91:          lport, fport,
  92:          opsys,
  93:          charset ? "," : "",
  94:          charset ? charset : "",
  95:          answer);
  96:       break;
  97: 
  98:     case 2:
  99:       printf("%d , %d : ERROR : %s\r\n",
 100:          lport, fport, answer);
 101:       break;
 102: 
 103:     case 0:  /* More to parse - fix this later! */
 104:     case -1: /* Internal error */
 105:     default:
 106:       printf("%d , %d : ERROR : %s\r\n",
 107:          lport, fport,
 108:          unknown_flag ? "UNKNOWN-ERROR" : "X-PARSE-REPLY-ERROR");
 109:   }
 110: 
 111:   id_close(idp);
 112: #endif
 113: }

Defined functions

proxy defined in line 38; used 2 times

Defined macros

void defined in line 27; never used
Last modified: 1996-10-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1387
Valid CSS Valid XHTML 1.0 Strict