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