1: /*
   2:  * Copyright (c) 1983 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifndef lint
   8: static char sccsid[] = "@(#)get_addrs.c	5.1 (Berkeley) 6/6/85";
   9: #endif not lint
  10: 
  11: #include "talk_ctl.h"
  12: 
  13: struct  hostent *gethostbyname();
  14: struct  servent *getservbyname();
  15: 
  16: get_addrs(my_machine_name, his_machine_name)
  17:     char *my_machine_name;
  18:     char *his_machine_name;
  19: {
  20:     struct hostent *hp;
  21:     struct servent *sp;
  22: 
  23:     msg.pid = getpid();
  24:     /* look up the address of the local host */
  25:     hp = gethostbyname(my_machine_name);
  26:     if (hp == (struct hostent *) 0) {
  27:         printf("This machine doesn't exist. Boy, am I confused!\n");
  28:         exit(-1);
  29:     }
  30:     bcopy(hp->h_addr, (char *)&my_machine_addr, hp->h_length);
  31:     /* if he is on the same machine, then simply copy */
  32:     if (bcmp((char *)&his_machine_name, (char *)&my_machine_name,
  33:         sizeof(his_machine_name)) == 0)
  34:         bcopy((char *)&my_machine_addr, (char *)&his_machine_addr,
  35:             sizeof(his_machine_name));
  36:     else {
  37:         /* look up the address of the recipient's machine */
  38:         hp = gethostbyname(his_machine_name);
  39:         if (hp == (struct hostent *) 0 ) {
  40:             printf("%s is an unknown host\n", his_machine_name);
  41:             exit(-1);
  42:         }
  43:         bcopy(hp->h_addr, (char *) &his_machine_addr, hp->h_length);
  44:     }
  45:     /* find the daemon portal */
  46:     sp = getservbyname("talk", "udp");
  47:     if (sp == 0) {
  48:         p_error("This machine doesn't support talk");
  49:         exit(-1);
  50:     }
  51:     daemon_port = sp->s_port;
  52: }

Defined functions

get_addrs defined in line 16; used 1 times

Defined variables

sccsid defined in line 8; never used
Last modified: 1986-03-16
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 944
Valid CSS Valid XHTML 1.0 Strict