## tests/wh/test_wh.c

/* [<][>][^][v][top][bottom][index][help] */

## DEFINITIONS

This source file includes following functions.

1. main

       1
       2 #include <stdio.h>
       3 #include <erroutines.h>
       4 #include <wh_queries.h>
       5 #include <socket.h>
       6
       7 /* defaults */
       8
       9 char *host="whois.ripe.net";
      10 int   port=43;
      11
      12 int
      13 main(int argc, char **argv)
         /* [<][>][^][v][top][bottom][index][help] */
      14 {
      15   char query[1024]="";
      16   char buffer[1024];
      17   int i,err, blurp;
      18   int sock;
      19
      20   for (i=1; i<argc; i++) {
      21     if( argv[i][0] == '-' ) {
      22       switch (argv[i][1]) {
      23       case 'h':
      24         host=argv[i+1];
      25
      26         argv[i+1] = argv[i]; /* set both to point to the same address */
      27         *argv[i] = 0;        /* and set to "" */
      28         i++;
      29                 continue;
      30       case 'p':
      31         port = atoi(argv[i+1]);
      32         *argv[i]=*argv[i+1]=0;
      33         i++;
      34         continue;
      35       }
      36     }
      37     strcat(query, argv[i]);
      38     strcat(query, " ");
      39   }
      40
      41   strcat(query, "\r\n");
      42
      43   /* printf( "calling WH_sock to host %s port %d \n", host, port); */
      44
      45   err = WH_connect(&sock, host, port);
      46
      47   if( !NOERR(err) ) {
      48     printf( "WH_connect returned %d\n", err);
      49     ER_perror(FAC_WH,err,"");
      50   }
      51   else {
      52
      53     write(sock, query, strlen(query));
      54
      55     while( (blurp = read(sock, buffer, sizeof(buffer) )) > 0 ) {
      56       write(1 /* stdout */, buffer, blurp);
      57     }
      58   }
      59
      60
      61   return 0;
      62 }

/* [<][>][^][v][top][bottom][index][help] */