Add define for Kirk Smith's USR Courier driver. Change default baud
[unix-history] / usr / src / usr.bin / talk / get_addrs.c
... / ...
CommitLineData
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
8static char sccsid[] = "@(#)get_addrs.c 5.2 (Berkeley) %G%";
9#endif not lint
10
11#include "talk_ctl.h"
12#include <netdb.h>
13
14get_addrs(my_machine_name, his_machine_name)
15 char *my_machine_name, *his_machine_name;
16{
17 struct hostent *hp;
18 struct servent *sp;
19
20 msg.pid = htonl(getpid());
21 /* look up the address of the local host */
22 hp = gethostbyname(my_machine_name);
23 if (hp == (struct hostent *) 0) {
24 fprintf(stderr,
25 "talk: %s: Can't figure out network address.\n",
26 my_machine_name);
27 exit(-1);
28 }
29 bcopy(hp->h_addr, (char *)&my_machine_addr, hp->h_length);
30 /*
31 * If the callee is on-machine, just copy the
32 * network address, otherwise do a lookup...
33 */
34 if (strcmp(his_machine_name, my_machine_name)) {
35 hp = gethostbyname(his_machine_name);
36 if (hp == (struct hostent *) 0 ) {
37 fprintf(stderr,
38 "talk: %s: Can't figure out network address.\n",
39 his_machine_name);
40 exit(-1);
41 }
42 bcopy(hp->h_addr, (char *) &his_machine_addr, hp->h_length);
43 } else
44 his_machine_addr = my_machine_addr;
45 /* find the server's port */
46 sp = getservbyname("ntalk", "udp");
47 if (sp == 0) {
48 fprintf(stderr, "talk: %s/%s: service is not registered.\n",
49 "ntalk", "udp");
50 exit(-1);
51 }
52 daemon_port = sp->s_port;
53}