commands.c revision 1.2.6.2 1 1.2.6.2 tron /* $NetBSD: commands.c,v 1.2.6.2 2006/05/24 15:48:07 tron Exp $ */
2 1.2.6.2 tron
3 1.2.6.2 tron /*-
4 1.2.6.2 tron * Copyright (c) 1998 Michael Smith <msmith (at) freebsd.org>
5 1.2.6.2 tron * All rights reserved.
6 1.2.6.2 tron *
7 1.2.6.2 tron * Redistribution and use in source and binary forms, with or without
8 1.2.6.2 tron * modification, are permitted provided that the following conditions
9 1.2.6.2 tron * are met:
10 1.2.6.2 tron * 1. Redistributions of source code must retain the above copyright
11 1.2.6.2 tron * notice, this list of conditions and the following disclaimer.
12 1.2.6.2 tron * 2. Redistributions in binary form must reproduce the above copyright
13 1.2.6.2 tron * notice, this list of conditions and the following disclaimer in the
14 1.2.6.2 tron * documentation and/or other materials provided with the distribution.
15 1.2.6.2 tron *
16 1.2.6.2 tron * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 1.2.6.2 tron * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 1.2.6.2 tron * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 1.2.6.2 tron * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 1.2.6.2 tron * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 1.2.6.2 tron * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 1.2.6.2 tron * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 1.2.6.2 tron * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 1.2.6.2 tron * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.2.6.2 tron * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.2.6.2 tron * SUCH DAMAGE.
27 1.2.6.2 tron */
28 1.2.6.2 tron
29 1.2.6.2 tron #include <sys/cdefs.h>
30 1.2.6.2 tron /* __FBSDID("$FreeBSD: src/sys/boot/common/commands.c,v 1.19 2003/08/25 23:30:41 obrien Exp $"); */
31 1.2.6.2 tron
32 1.2.6.2 tron #include <lib/libsa/stand.h>
33 1.2.6.2 tron #include <lib/libkern/libkern.h>
34 1.2.6.2 tron
35 1.2.6.2 tron #include "bootstrap.h"
36 1.2.6.2 tron
37 1.2.6.2 tron char *command_errmsg;
38 1.2.6.2 tron char command_errbuf[256]; /* XXX should have procedural interface for setting, size limit? */
39 1.2.6.2 tron
40 1.2.6.2 tron static int page_file(char *filename);
41 1.2.6.2 tron
42 1.2.6.2 tron /*
43 1.2.6.2 tron * Help is read from a formatted text file.
44 1.2.6.2 tron *
45 1.2.6.2 tron * Entries in the file are formatted as
46 1.2.6.2 tron
47 1.2.6.2 tron # Ttopic [Ssubtopic] Ddescription
48 1.2.6.2 tron help
49 1.2.6.2 tron text
50 1.2.6.2 tron here
51 1.2.6.2 tron #
52 1.2.6.2 tron
53 1.2.6.2 tron *
54 1.2.6.2 tron * Note that for code simplicity's sake, the above format must be followed
55 1.2.6.2 tron * exactly.
56 1.2.6.2 tron *
57 1.2.6.2 tron * Subtopic entries must immediately follow the topic (this is used to
58 1.2.6.2 tron * produce the listing of subtopics).
59 1.2.6.2 tron *
60 1.2.6.2 tron * If no argument(s) are supplied by the user, the help for 'help' is displayed.
61 1.2.6.2 tron */
62 1.2.6.2 tron
63 1.2.6.2 tron static int
64 1.2.6.2 tron help_getnext(int fd, char **topic, char **subtopic, char **desc)
65 1.2.6.2 tron {
66 1.2.6.2 tron char line[81], *cp, *ep;
67 1.2.6.2 tron
68 1.2.6.2 tron for (;;) {
69 1.2.6.2 tron if (fgetstr(line, 80, fd) < 0)
70 1.2.6.2 tron return(0);
71 1.2.6.2 tron
72 1.2.6.2 tron if ((strlen(line) < 3) || (line[0] != '#') || (line[1] != ' '))
73 1.2.6.2 tron continue;
74 1.2.6.2 tron
75 1.2.6.2 tron *topic = *subtopic = *desc = NULL;
76 1.2.6.2 tron cp = line + 2;
77 1.2.6.2 tron while((cp != NULL) && (*cp != 0)) {
78 1.2.6.2 tron ep = strchr(cp, ' ');
79 1.2.6.2 tron if ((*cp == 'T') && (*topic == NULL)) {
80 1.2.6.2 tron if (ep != NULL)
81 1.2.6.2 tron *ep++ = 0;
82 1.2.6.2 tron *topic = strdup(cp + 1);
83 1.2.6.2 tron } else if ((*cp == 'S') && (*subtopic == NULL)) {
84 1.2.6.2 tron if (ep != NULL)
85 1.2.6.2 tron *ep++ = 0;
86 1.2.6.2 tron *subtopic = strdup(cp + 1);
87 1.2.6.2 tron } else if (*cp == 'D') {
88 1.2.6.2 tron *desc = strdup(cp + 1);
89 1.2.6.2 tron ep = NULL;
90 1.2.6.2 tron }
91 1.2.6.2 tron cp = ep;
92 1.2.6.2 tron }
93 1.2.6.2 tron if (*topic == NULL) {
94 1.2.6.2 tron if (*subtopic != NULL)
95 1.2.6.2 tron free(*subtopic);
96 1.2.6.2 tron if (*desc != NULL)
97 1.2.6.2 tron free(*desc);
98 1.2.6.2 tron continue;
99 1.2.6.2 tron }
100 1.2.6.2 tron return(1);
101 1.2.6.2 tron }
102 1.2.6.2 tron }
103 1.2.6.2 tron
104 1.2.6.2 tron static int
105 1.2.6.2 tron help_emitsummary(char *topic, char *subtopic, char *desc)
106 1.2.6.2 tron {
107 1.2.6.2 tron int i;
108 1.2.6.2 tron
109 1.2.6.2 tron pager_output(" ");
110 1.2.6.2 tron pager_output(topic);
111 1.2.6.2 tron i = strlen(topic);
112 1.2.6.2 tron if (subtopic != NULL) {
113 1.2.6.2 tron pager_output(" ");
114 1.2.6.2 tron pager_output(subtopic);
115 1.2.6.2 tron i += strlen(subtopic) + 1;
116 1.2.6.2 tron }
117 1.2.6.2 tron if (desc != NULL) {
118 1.2.6.2 tron do {
119 1.2.6.2 tron pager_output(" ");
120 1.2.6.2 tron } while (i++ < 30);
121 1.2.6.2 tron pager_output(desc);
122 1.2.6.2 tron }
123 1.2.6.2 tron return (pager_output("\n"));
124 1.2.6.2 tron }
125 1.2.6.2 tron
126 1.2.6.2 tron
127 1.2.6.2 tron int
128 1.2.6.2 tron command_help(int argc, char *argv[])
129 1.2.6.2 tron {
130 1.2.6.2 tron char buf[81]; /* XXX buffer size? */
131 1.2.6.2 tron int hfd, matched, doindex;
132 1.2.6.2 tron char *topic, *subtopic, *t, *s, *d;
133 1.2.6.2 tron
134 1.2.6.2 tron /* page the help text from our load path */
135 1.2.6.2 tron sprintf(buf, "%s/boot/loader.help", getenv("loaddev"));
136 1.2.6.2 tron if ((hfd = open(buf, O_RDONLY)) < 0) {
137 1.2.6.2 tron printf("Verbose help not available, use '?' to list commands\n");
138 1.2.6.2 tron return(CMD_OK);
139 1.2.6.2 tron }
140 1.2.6.2 tron
141 1.2.6.2 tron /* pick up request from arguments */
142 1.2.6.2 tron topic = subtopic = NULL;
143 1.2.6.2 tron switch(argc) {
144 1.2.6.2 tron case 3:
145 1.2.6.2 tron subtopic = strdup(argv[2]);
146 1.2.6.2 tron case 2:
147 1.2.6.2 tron topic = strdup(argv[1]);
148 1.2.6.2 tron break;
149 1.2.6.2 tron case 1:
150 1.2.6.2 tron topic = strdup("help");
151 1.2.6.2 tron break;
152 1.2.6.2 tron default:
153 1.2.6.2 tron command_errmsg = "usage is 'help <topic> [<subtopic>]";
154 1.2.6.2 tron return(CMD_ERROR);
155 1.2.6.2 tron }
156 1.2.6.2 tron
157 1.2.6.2 tron /* magic "index" keyword */
158 1.2.6.2 tron doindex = !strcmp(topic, "index");
159 1.2.6.2 tron matched = doindex;
160 1.2.6.2 tron
161 1.2.6.2 tron /* Scan the helpfile looking for help matching the request */
162 1.2.6.2 tron pager_open();
163 1.2.6.2 tron while(help_getnext(hfd, &t, &s, &d)) {
164 1.2.6.2 tron
165 1.2.6.2 tron if (doindex) { /* dink around formatting */
166 1.2.6.2 tron if (help_emitsummary(t, s, d))
167 1.2.6.2 tron break;
168 1.2.6.2 tron
169 1.2.6.2 tron } else if (strcmp(topic, t)) {
170 1.2.6.2 tron /* topic mismatch */
171 1.2.6.2 tron if(matched) /* nothing more on this topic, stop scanning */
172 1.2.6.2 tron break;
173 1.2.6.2 tron
174 1.2.6.2 tron } else {
175 1.2.6.2 tron /* topic matched */
176 1.2.6.2 tron matched = 1;
177 1.2.6.2 tron if (((subtopic == NULL) && (s == NULL)) ||
178 1.2.6.2 tron ((subtopic != NULL) && (s != NULL) && !strcmp(subtopic, s))) {
179 1.2.6.2 tron /* exact match, print text */
180 1.2.6.2 tron while((fgetstr(buf, 80, hfd) >= 0) && (buf[0] != '#')) {
181 1.2.6.2 tron if (pager_output(buf))
182 1.2.6.2 tron break;
183 1.2.6.2 tron if (pager_output("\n"))
184 1.2.6.2 tron break;
185 1.2.6.2 tron }
186 1.2.6.2 tron } else if ((subtopic == NULL) && (s != NULL)) {
187 1.2.6.2 tron /* topic match, list subtopics */
188 1.2.6.2 tron if (help_emitsummary(t, s, d))
189 1.2.6.2 tron break;
190 1.2.6.2 tron }
191 1.2.6.2 tron }
192 1.2.6.2 tron free(t);
193 1.2.6.2 tron free(s);
194 1.2.6.2 tron free(d);
195 1.2.6.2 tron }
196 1.2.6.2 tron pager_close();
197 1.2.6.2 tron close(hfd);
198 1.2.6.2 tron if (!matched) {
199 1.2.6.2 tron sprintf(command_errbuf, "no help available for '%s'", topic);
200 1.2.6.2 tron free(topic);
201 1.2.6.2 tron if (subtopic)
202 1.2.6.2 tron free(subtopic);
203 1.2.6.2 tron return(CMD_ERROR);
204 1.2.6.2 tron }
205 1.2.6.2 tron free(topic);
206 1.2.6.2 tron if (subtopic)
207 1.2.6.2 tron free(subtopic);
208 1.2.6.2 tron return(CMD_OK);
209 1.2.6.2 tron }
210 1.2.6.2 tron
211 1.2.6.2 tron
212 1.2.6.2 tron int
213 1.2.6.2 tron command_commandlist(int argc, char *argv[])
214 1.2.6.2 tron {
215 1.2.6.2 tron struct bootblk_command *cmdp;
216 1.2.6.2 tron int res;
217 1.2.6.2 tron char name[20];
218 1.2.6.2 tron int i;
219 1.2.6.2 tron
220 1.2.6.2 tron res = 0;
221 1.2.6.2 tron pager_open();
222 1.2.6.2 tron res = pager_output("Available commands:\n");
223 1.2.6.2 tron
224 1.2.6.2 tron for (i = 0, cmdp = commands; (cmdp->c_name != NULL) && (cmdp->c_desc != NULL ); i++, cmdp = commands + i) {
225 1.2.6.2 tron if (res)
226 1.2.6.2 tron break;
227 1.2.6.2 tron if ((cmdp->c_name != NULL) && (cmdp->c_desc != NULL)) {
228 1.2.6.2 tron sprintf(name, " %s ", cmdp->c_name);
229 1.2.6.2 tron pager_output(name);
230 1.2.6.2 tron pager_output(cmdp->c_desc);
231 1.2.6.2 tron res = pager_output("\n");
232 1.2.6.2 tron }
233 1.2.6.2 tron }
234 1.2.6.2 tron pager_close();
235 1.2.6.2 tron return(CMD_OK);
236 1.2.6.2 tron }
237 1.2.6.2 tron
238 1.2.6.2 tron /*
239 1.2.6.2 tron * XXX set/show should become set/echo if we have variable
240 1.2.6.2 tron * substitution happening.
241 1.2.6.2 tron */
242 1.2.6.2 tron
243 1.2.6.2 tron int
244 1.2.6.2 tron command_show(int argc, char *argv[])
245 1.2.6.2 tron {
246 1.2.6.2 tron struct env_var *ev;
247 1.2.6.2 tron char *cp;
248 1.2.6.2 tron
249 1.2.6.2 tron if (argc < 2) {
250 1.2.6.2 tron /*
251 1.2.6.2 tron * With no arguments, print everything.
252 1.2.6.2 tron */
253 1.2.6.2 tron pager_open();
254 1.2.6.2 tron for (ev = environ; ev != NULL; ev = ev->ev_next) {
255 1.2.6.2 tron pager_output(ev->ev_name);
256 1.2.6.2 tron cp = getenv(ev->ev_name);
257 1.2.6.2 tron if (cp != NULL) {
258 1.2.6.2 tron pager_output("=");
259 1.2.6.2 tron pager_output(cp);
260 1.2.6.2 tron }
261 1.2.6.2 tron if (pager_output("\n"))
262 1.2.6.2 tron break;
263 1.2.6.2 tron }
264 1.2.6.2 tron pager_close();
265 1.2.6.2 tron } else {
266 1.2.6.2 tron if ((cp = getenv(argv[1])) != NULL) {
267 1.2.6.2 tron printf("%s\n", cp);
268 1.2.6.2 tron } else {
269 1.2.6.2 tron sprintf(command_errbuf, "variable '%s' not found", argv[1]);
270 1.2.6.2 tron return(CMD_ERROR);
271 1.2.6.2 tron }
272 1.2.6.2 tron }
273 1.2.6.2 tron return(CMD_OK);
274 1.2.6.2 tron }
275 1.2.6.2 tron
276 1.2.6.2 tron
277 1.2.6.2 tron int
278 1.2.6.2 tron command_set(int argc, char *argv[])
279 1.2.6.2 tron {
280 1.2.6.2 tron int err;
281 1.2.6.2 tron
282 1.2.6.2 tron if (argc != 2) {
283 1.2.6.2 tron command_errmsg = "wrong number of arguments";
284 1.2.6.2 tron return(CMD_ERROR);
285 1.2.6.2 tron } else {
286 1.2.6.2 tron if ((err = putenv(argv[1])) != 0) {
287 1.2.6.2 tron command_errmsg = strerror(err);
288 1.2.6.2 tron return(CMD_ERROR);
289 1.2.6.2 tron }
290 1.2.6.2 tron }
291 1.2.6.2 tron return(CMD_OK);
292 1.2.6.2 tron }
293 1.2.6.2 tron
294 1.2.6.2 tron
295 1.2.6.2 tron int
296 1.2.6.2 tron command_unset(int argc, char *argv[])
297 1.2.6.2 tron {
298 1.2.6.2 tron int err;
299 1.2.6.2 tron
300 1.2.6.2 tron if (argc != 2) {
301 1.2.6.2 tron command_errmsg = "wrong number of arguments";
302 1.2.6.2 tron return(CMD_ERROR);
303 1.2.6.2 tron } else {
304 1.2.6.2 tron if ((err = unsetenv(argv[1])) != 0) {
305 1.2.6.2 tron command_errmsg = strerror(err);
306 1.2.6.2 tron return(CMD_ERROR);
307 1.2.6.2 tron }
308 1.2.6.2 tron }
309 1.2.6.2 tron return(CMD_OK);
310 1.2.6.2 tron }
311 1.2.6.2 tron
312 1.2.6.2 tron
313 1.2.6.2 tron int
314 1.2.6.2 tron command_echo(int argc, char *argv[])
315 1.2.6.2 tron {
316 1.2.6.2 tron char *s;
317 1.2.6.2 tron int nl, ch;
318 1.2.6.2 tron
319 1.2.6.2 tron nl = 0;
320 1.2.6.2 tron optind = 1;
321 1.2.6.2 tron optreset = 1;
322 1.2.6.2 tron while ((ch = getopt(argc, argv, "n")) != -1) {
323 1.2.6.2 tron switch(ch) {
324 1.2.6.2 tron case 'n':
325 1.2.6.2 tron nl = 1;
326 1.2.6.2 tron break;
327 1.2.6.2 tron case '?':
328 1.2.6.2 tron default:
329 1.2.6.2 tron /* getopt has already reported an error */
330 1.2.6.2 tron return(CMD_OK);
331 1.2.6.2 tron }
332 1.2.6.2 tron }
333 1.2.6.2 tron argv += (optind);
334 1.2.6.2 tron argc -= (optind);
335 1.2.6.2 tron
336 1.2.6.2 tron s = unargv(argc, argv);
337 1.2.6.2 tron if (s != NULL) {
338 1.2.6.2 tron printf("%s", s);
339 1.2.6.2 tron free(s);
340 1.2.6.2 tron }
341 1.2.6.2 tron if (!nl)
342 1.2.6.2 tron printf("\n");
343 1.2.6.2 tron return(CMD_OK);
344 1.2.6.2 tron }
345 1.2.6.2 tron
346 1.2.6.2 tron /*
347 1.2.6.2 tron * A passable emulation of the sh(1) command of the same name.
348 1.2.6.2 tron */
349 1.2.6.2 tron
350 1.2.6.2 tron
351 1.2.6.2 tron int
352 1.2.6.2 tron command_read(int argc, char *argv[])
353 1.2.6.2 tron {
354 1.2.6.2 tron char *prompt;
355 1.2.6.2 tron int timeout;
356 1.2.6.2 tron time_t when;
357 1.2.6.2 tron char *cp;
358 1.2.6.2 tron char *name;
359 1.2.6.2 tron char buf[256]; /* XXX size? */
360 1.2.6.2 tron int c;
361 1.2.6.2 tron
362 1.2.6.2 tron timeout = -1;
363 1.2.6.2 tron prompt = NULL;
364 1.2.6.2 tron optind = 1;
365 1.2.6.2 tron optreset = 1;
366 1.2.6.2 tron while ((c = getopt(argc, argv, "p:t:")) != -1) {
367 1.2.6.2 tron switch(c) {
368 1.2.6.2 tron
369 1.2.6.2 tron case 'p':
370 1.2.6.2 tron prompt = optarg;
371 1.2.6.2 tron break;
372 1.2.6.2 tron case 't':
373 1.2.6.2 tron timeout = strtol(optarg, &cp, 0);
374 1.2.6.2 tron if (cp == optarg) {
375 1.2.6.2 tron sprintf(command_errbuf, "bad timeout '%s'", optarg);
376 1.2.6.2 tron return(CMD_ERROR);
377 1.2.6.2 tron }
378 1.2.6.2 tron break;
379 1.2.6.2 tron default:
380 1.2.6.2 tron return(CMD_OK);
381 1.2.6.2 tron }
382 1.2.6.2 tron }
383 1.2.6.2 tron
384 1.2.6.2 tron argv += (optind);
385 1.2.6.2 tron argc -= (optind);
386 1.2.6.2 tron name = (argc > 0) ? argv[0]: NULL;
387 1.2.6.2 tron
388 1.2.6.2 tron if (prompt != NULL)
389 1.2.6.2 tron printf("%s", prompt);
390 1.2.6.2 tron if (timeout >= 0) {
391 1.2.6.2 tron when = time(NULL) + timeout;
392 1.2.6.2 tron while (!ischar())
393 1.2.6.2 tron if (time(NULL) >= when)
394 1.2.6.2 tron return(CMD_OK); /* is timeout an error? */
395 1.2.6.2 tron }
396 1.2.6.2 tron
397 1.2.6.2 tron ngets(buf, sizeof(buf));
398 1.2.6.2 tron
399 1.2.6.2 tron if (name != NULL)
400 1.2.6.2 tron setenv(name, buf, 1);
401 1.2.6.2 tron return(CMD_OK);
402 1.2.6.2 tron }
403 1.2.6.2 tron
404 1.2.6.2 tron /*
405 1.2.6.2 tron * File pager
406 1.2.6.2 tron */
407 1.2.6.2 tron
408 1.2.6.2 tron int
409 1.2.6.2 tron command_more(int argc, char *argv[])
410 1.2.6.2 tron {
411 1.2.6.2 tron int i;
412 1.2.6.2 tron int res;
413 1.2.6.2 tron char line[80];
414 1.2.6.2 tron
415 1.2.6.2 tron res=0;
416 1.2.6.2 tron pager_open();
417 1.2.6.2 tron for (i = 1; (i < argc) && (res == 0); i++) {
418 1.2.6.2 tron sprintf(line, "*** FILE %s BEGIN ***\n", argv[i]);
419 1.2.6.2 tron if (pager_output(line))
420 1.2.6.2 tron break;
421 1.2.6.2 tron res = page_file(argv[i]);
422 1.2.6.2 tron if (!res) {
423 1.2.6.2 tron sprintf(line, "*** FILE %s END ***\n", argv[i]);
424 1.2.6.2 tron res = pager_output(line);
425 1.2.6.2 tron }
426 1.2.6.2 tron }
427 1.2.6.2 tron pager_close();
428 1.2.6.2 tron
429 1.2.6.2 tron if (res == 0)
430 1.2.6.2 tron return CMD_OK;
431 1.2.6.2 tron else
432 1.2.6.2 tron return CMD_ERROR;
433 1.2.6.2 tron }
434 1.2.6.2 tron
435 1.2.6.2 tron static int
436 1.2.6.2 tron page_file(char *filename)
437 1.2.6.2 tron {
438 1.2.6.2 tron int result;
439 1.2.6.2 tron
440 1.2.6.2 tron result = pager_file(filename);
441 1.2.6.2 tron
442 1.2.6.2 tron if (result == -1)
443 1.2.6.2 tron sprintf(command_errbuf, "error showing %s", filename);
444 1.2.6.2 tron
445 1.2.6.2 tron return result;
446 1.2.6.2 tron }
447 1.2.6.2 tron
448 1.2.6.2 tron /*
449 1.2.6.2 tron * List all disk-like devices
450 1.2.6.2 tron */
451 1.2.6.2 tron
452 1.2.6.2 tron int
453 1.2.6.2 tron command_lsdev(int argc, char *argv[])
454 1.2.6.2 tron {
455 1.2.6.2 tron int verbose, ch, i;
456 1.2.6.2 tron char line[80];
457 1.2.6.2 tron
458 1.2.6.2 tron verbose = 0;
459 1.2.6.2 tron optind = 1;
460 1.2.6.2 tron optreset = 1;
461 1.2.6.2 tron while ((ch = getopt(argc, argv, "v")) != -1) {
462 1.2.6.2 tron switch(ch) {
463 1.2.6.2 tron case 'v':
464 1.2.6.2 tron verbose = 1;
465 1.2.6.2 tron break;
466 1.2.6.2 tron case '?':
467 1.2.6.2 tron default:
468 1.2.6.2 tron /* getopt has already reported an error */
469 1.2.6.2 tron return(CMD_OK);
470 1.2.6.2 tron }
471 1.2.6.2 tron }
472 1.2.6.2 tron argv += (optind);
473 1.2.6.2 tron argc -= (optind);
474 1.2.6.2 tron
475 1.2.6.2 tron pager_open();
476 1.2.6.2 tron
477 1.2.6.2 tron sprintf(line, "Device Enumeration:\n");
478 1.2.6.2 tron pager_output(line);
479 1.2.6.2 tron
480 1.2.6.2 tron for (i = 0; i < ndevs; i++) {
481 1.2.6.2 tron sprintf(line, "%s\n", devsw[i].dv_name);
482 1.2.6.2 tron if (pager_output(line))
483 1.2.6.2 tron break;
484 1.2.6.2 tron }
485 1.2.6.2 tron
486 1.2.6.2 tron pager_close();
487 1.2.6.2 tron return(CMD_OK);
488 1.2.6.2 tron }
489 1.2.6.2 tron
490