1: /*
   2:  * This is a short demo program that queries the Clearinghouse for the
   3:  * NS Address of a specified host.
   4:  * It should be rewritten to format the network address more reasonably.
   5:  */
   6: #include <stdio.h>
   7: #include <sys/types.h>
   8: #include <netns/ns.h>
   9: #include "Clearinghouse2_defs.h"
  10: #include <xnscourier/courier.h>
  11: 
  12: main(argc, argv)
  13:     int argc;
  14:     char *argv[];
  15: {
  16:     ObjectName name, defaults;
  17:     struct ns_addr *result;
  18:     extern struct ns_addr *CH_LookupAddr();
  19:     extern ObjectName CH_StringToName();
  20:     char *XNSaddrToString();
  21: 
  22:     if (argc != 2) {
  23:         fprintf(stderr,"Usage: %s name\n",argv[0]);
  24:         exit(1);
  25:     }
  26:     CH_NameDefault(&defaults);
  27:     name = CH_StringToName(argv[1],&defaults);
  28:     result = CH_LookupAddr(name,4);
  29:     if (result==0) {
  30:         printf("%s not found\n",name.object);
  31:         exit(1);
  32:     }
  33:     printf("name: %s:%s:%s\n",name.object,name.domain,name.organization);
  34:     printf("address: %s\n", XNSaddrToString(result));
  35: }
  36: 
  37: char *
  38: XNSaddrToString(addr)
  39:     struct ns_addr *addr;
  40: {
  41:     u_char *s;
  42:     static char buf[21];
  43: 
  44:     s = addr->x_host.c_host;
  45:     sprintf(buf,"%lx#%x.%x.%x.%x.%x.%x#%x",
  46:         ntohl(ns_netof(*addr)),
  47:         s[0], s[1], s[2], s[3], s[4], s[5],
  48:         ntohs(addr->x_port));
  49:     return(buf);
  50: }

Defined functions

XNSaddrToString defined in line 37; used 2 times
main defined in line 12; never used
Last modified: 1986-03-13
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 836
Valid CSS Valid XHTML 1.0 Strict