[BACK]Return to ypwhich.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ypwhich

Diff for /src/usr.bin/ypwhich/ypwhich.c between version 1.7 and 1.8

version 1.7, 1997/06/23 01:03:57 version 1.8, 1997/07/21 19:12:46
Line 1 
Line 1 
 /*      $OpenBSD$  /*      $OpenBSD$       */
 /*      $NetBSD: ypwhich.c,v 1.6 1996/05/13 02:43:48 thorpej Exp $      */  /*      $NetBSD: ypwhich.c,v 1.6 1996/05/13 02:43:48 thorpej Exp $      */
   
 /*  /*
Line 40 
Line 40 
 #include <sys/param.h>  #include <sys/param.h>
 #include <sys/types.h>  #include <sys/types.h>
 #include <sys/socket.h>  #include <sys/socket.h>
   
   #include <sys/socket.h>
   #include <netinet/in.h>
   #include <arpa/inet.h>
   
 #include <stdio.h>  #include <stdio.h>
   #include <string.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <ctype.h>  #include <ctype.h>
 #include <netdb.h>  #include <netdb.h>
   #include <err.h>
   
 #include <rpc/rpc.h>  #include <rpc/rpc.h>
 #include <rpc/xdr.h>  #include <rpc/xdr.h>
 #include <rpcsvc/yp.h>  #include <rpcsvc/yp.h>
Line 62 
Line 70 
         { "ethers", "ethers.byname" },          { "ethers", "ethers.byname" },
 };  };
   
   void
 usage()  usage()
 {  {
         fprintf(stderr, "Usage:\n");          fprintf(stderr, "Usage:\n");
Line 74 
Line 83 
 /*  /*
  * Like yp_bind except can query a specific host   * Like yp_bind except can query a specific host
  */   */
   int
 bind_host(dom, sin)  bind_host(dom, sin)
 char *dom;  char *dom;
 struct sockaddr_in *sin;  struct sockaddr_in *sin;
 {  {
         struct hostent *hent = NULL;          struct hostent *hent = NULL;
         struct ypbind_resp ypbr;          struct ypbind_resp ypbr;
         struct dom_binding *ysd;  
         struct timeval tv;          struct timeval tv;
         CLIENT *client;          CLIENT *client;
         int sock, r;          int sock, r;
         u_int32_t ss_addr;          struct in_addr ss_addr;
   
         sock = RPC_ANYSOCK;          sock = RPC_ANYSOCK;
         tv.tv_sec = 15;          tv.tv_sec = 15;
Line 116 
Line 125 
         }          }
         clnt_destroy(client);          clnt_destroy(client);
   
         bcopy(&ypbr.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr,          memmove(&ss_addr.s_addr, &ypbr.ypbind_resp_u.ypbind_bindinfo.ypbind_binding_addr,
             &ss_addr, sizeof (ss_addr));              sizeof (ss_addr));
   
         hent = gethostbyaddr((char *)&ss_addr, sizeof(ss_addr), AF_INET);          hent = gethostbyaddr((char *)&ss_addr.s_addr, sizeof(ss_addr.s_addr),
               AF_INET);
         if (hent != NULL)          if (hent != NULL)
                 printf("%s\n", hent->h_name);                  printf("%s\n", hent->h_name);
         else          else
Line 130 
Line 140 
   
 int  int
 main(argc, argv)  main(argc, argv)
 char **argv;          int argc;
           char **argv;
 {  {
         char *domain, *master, *map;          char *domain, *master, *map;
         struct ypmaplist *ypml, *y;          struct ypmaplist *ypml, *y;
Line 143 
Line 154 
         getmap = notrans = mode = 0;          getmap = notrans = mode = 0;
   
         yp_get_default_domain(&domain);          yp_get_default_domain(&domain);
           if (domain == NULL)
                   errx(1, "YP domain name not set");
   
         while ((c = getopt(argc, argv, "xd:mt")) != -1)          while ((c = getopt(argc, argv, "xd:mt")) != -1)
                 switch(c) {                  switch(c) {
                 case 'x':                  case 'x':
Line 168 
Line 182 
         if (mode == 0) {          if (mode == 0) {
                 switch(argc) {                  switch(argc) {
                 case 0:                  case 0:
                         bzero(&sin, sizeof sin);                          memset(&sin, 0, sizeof sin);
                         sin.sin_family = AF_INET;                          sin.sin_family = AF_INET;
                         sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);                          sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
   

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8