Print this page
8485 Remove set but unused variables in usr/src/cmd
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/cmd-inet/usr.bin/talk/get_names.c
+++ new/usr/src/cmd/cmd-inet/usr.bin/talk/get_names.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22 /*
23 + * Copyright 2017 Gary Mills
23 24 * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
24 25 * Use is subject to license terms.
25 26 */
26 27
27 28 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28 29 /* All Rights Reserved */
29 30
30 31 /*
31 32 * University Copyright- Copyright (c) 1982, 1986, 1988
32 33 * The Regents of the University of California
33 34 * All Rights Reserved
34 35 *
35 36 * University Acknowledgment- Portions of this document are derived from
36 37 * software developed by the University of California, Berkeley, and its
37 38 * contributors.
38 39 */
39 40
40 -#pragma ident "%Z%%M% %I% %E% SMI"
41 -
42 41 #include "talk.h"
43 42 #include "ctl.h"
44 43 #include <locale.h>
45 44 #include <pwd.h>
46 45 #include <sys/systeminfo.h>
47 46
48 47 char *getlogin(), *ttyname(int);
49 48
50 49 extern CTL_MSG msg;
51 50
52 51 /*
53 52 * Determine the local and remote user, tty, and machines
54 53 */
55 54
56 55 struct hostent *gethostbyname();
57 56
↓ open down ↓ |
6 lines elided |
↑ open up ↑ |
58 57 void
59 58 get_names(argc, argv)
60 59 int argc;
61 60 char *argv[];
62 61 {
63 62 char hostname[HOST_NAME_LENGTH + 1];
64 63 char *rem_name;
65 64 char *my_name;
66 65 char *my_machine_name;
67 66 char *rem_machine_name;
68 - char *my_tty;
69 67 char *rem_tty;
70 68 char *ptr;
71 69 int name_length;
72 70
73 71 if (argc < 2) {
74 72 fprintf(stderr,
75 73 "Usage: talk %s\n", gettext("address [terminal]"));
76 74 exit(1);
77 75 }
78 76 if (!isatty(0)) {
79 77 fprintf(stderr,
80 78 gettext("Standard input must be a tty, not a pipe or a file\n"));
81 79 exit(1);
82 80 }
83 81
84 82 if (!isatty(1)) {
85 83 fprintf(stderr,
86 84 gettext("Standard output must be a tty, not a pipe or a file\n"));
87 85 exit(1);
88 86 }
89 87
90 88 if ((my_name = getlogin()) == NULL) {
91 89 struct passwd *pass = getpwuid(getuid());
92 90 if (pass != NULL)
93 91 my_name = pass->pw_name;
94 92 }
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
95 93 if (my_name == NULL) {
96 94 fprintf(stderr,
97 95 gettext("Who are you? You have no entry in /etc/utmp! Aborting..\n"));
98 96 exit(1);
99 97 }
100 98
101 99 name_length = HOST_NAME_LENGTH;
102 100 (void) sysinfo(SI_HOSTNAME, hostname, name_length);
103 101 my_machine_name = hostname;
104 102
105 - my_tty = strrchr(ttyname(0), '/') + 1;
106 -
107 103 /*
108 104 * check for, and strip out, the machine name of the target
109 105 */
110 106
111 107 for (ptr = argv[1]; *ptr != '\0' &&
112 108 *ptr != '@' &&
113 109 *ptr != ':' &&
114 110 *ptr != '!' &&
115 111 *ptr != '.'; ptr++) {
116 112 }
117 113
118 114 if (*ptr == '\0') {
119 115
120 116 /* this is a local to local talk */
121 117
122 118 rem_name = argv[1];
123 119 rem_machine_name = my_machine_name;
124 120
125 121 } else {
126 122
127 123 if (*ptr == '@') {
128 124 /* user@host */
129 125 rem_name = argv[1];
130 126 rem_machine_name = ptr + 1;
131 127 } else {
132 128 /* host.user or host!user or host:user */
133 129 rem_name = ptr + 1;
134 130 rem_machine_name = argv[1];
135 131 }
136 132 *ptr = '\0';
137 133 }
138 134
139 135
140 136 if (argc > 2) {
141 137 rem_tty = argv[2]; /* tty name is arg 2 */
142 138 } else {
143 139 rem_tty = "";
144 140 }
145 141
146 142 get_addrs(my_machine_name, rem_machine_name);
147 143
148 144 /* Load these useful values into the standard message header */
149 145
150 146 msg.id_num = 0;
151 147
152 148 strncpy(msg.l_name, my_name, NAME_SIZE);
153 149 msg.l_name[NAME_SIZE - 1] = '\0';
154 150
155 151 strncpy(msg.r_name, rem_name, NAME_SIZE);
156 152 msg.r_name[NAME_SIZE - 1] = '\0';
157 153
158 154 strncpy(msg.r_tty, rem_tty, TTY_SIZE);
159 155 msg.r_tty[TTY_SIZE - 1] = '\0';
160 156 }
↓ open down ↓ |
44 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX