1*979b72c6Sdholland /* $NetBSD: menuutils.c,v 1.6 2016/06/11 06:20:11 dholland Exp $ */
227d7edd9Sdrochner
327d7edd9Sdrochner /*
427d7edd9Sdrochner * Copyright (c) 1996, 1997
527d7edd9Sdrochner * Matthias Drochner. All rights reserved.
627d7edd9Sdrochner * Copyright (c) 1996, 1997
727d7edd9Sdrochner * Perry E. Metzger. All rights reserved.
827d7edd9Sdrochner * Copyright (c) 1997
927d7edd9Sdrochner * Jason R. Thorpe. All rights reserved
1027d7edd9Sdrochner *
1127d7edd9Sdrochner * Redistribution and use in source and binary forms, with or without
1227d7edd9Sdrochner * modification, are permitted provided that the following conditions
1327d7edd9Sdrochner * are met:
1427d7edd9Sdrochner * 1. Redistributions of source code must retain the above copyright
1527d7edd9Sdrochner * notice, this list of conditions and the following disclaimer.
1627d7edd9Sdrochner * 2. Redistributions in binary form must reproduce the above copyright
1727d7edd9Sdrochner * notice, this list of conditions and the following disclaimer in the
1827d7edd9Sdrochner * documentation and/or other materials provided with the distribution.
1927d7edd9Sdrochner * 3. All advertising materials mentioning features or use of this software
2027d7edd9Sdrochner * must display the following acknowledgements:
2127d7edd9Sdrochner * This product includes software developed for the NetBSD Project
2227d7edd9Sdrochner * by Matthias Drochner.
2327d7edd9Sdrochner * This product includes software developed for the NetBSD Project
2427d7edd9Sdrochner * by Perry E. Metzger.
2527d7edd9Sdrochner * 4. The names of the authors may not be used to endorse or promote products
2627d7edd9Sdrochner * derived from this software without specific prior written permission.
2727d7edd9Sdrochner *
2827d7edd9Sdrochner * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2927d7edd9Sdrochner * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
3027d7edd9Sdrochner * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
3127d7edd9Sdrochner * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
3227d7edd9Sdrochner * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
3327d7edd9Sdrochner * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3427d7edd9Sdrochner * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3527d7edd9Sdrochner * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3627d7edd9Sdrochner * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3727d7edd9Sdrochner * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3827d7edd9Sdrochner */
3927d7edd9Sdrochner
4027d7edd9Sdrochner #include <lib/libkern/libkern.h>
4127d7edd9Sdrochner #include <lib/libsa/stand.h>
4227d7edd9Sdrochner
4327d7edd9Sdrochner #include "libi386.h"
4427d7edd9Sdrochner
4527d7edd9Sdrochner void
docommand(char * arg)46334f5e8fSchristos docommand(char *arg)
4727d7edd9Sdrochner {
4827d7edd9Sdrochner char *options;
4927d7edd9Sdrochner int i;
5027d7edd9Sdrochner
5127d7edd9Sdrochner options = gettrailer(arg);
5227d7edd9Sdrochner
5327d7edd9Sdrochner for (i = 0; commands[i].c_name != NULL; i++) {
5427d7edd9Sdrochner if (strcmp(arg, commands[i].c_name) == 0) {
5527d7edd9Sdrochner (*commands[i].c_fn)(options);
5627d7edd9Sdrochner return;
5727d7edd9Sdrochner }
5827d7edd9Sdrochner }
5927d7edd9Sdrochner
6027d7edd9Sdrochner printf("unknown command\n");
6127d7edd9Sdrochner command_help(NULL);
6227d7edd9Sdrochner }
6327d7edd9Sdrochner
64ee69c9e8Sjakllsch __dead void
bootmenu(void)65334f5e8fSchristos bootmenu(void)
6627d7edd9Sdrochner {
6727d7edd9Sdrochner char input[80];
6827d7edd9Sdrochner
6927d7edd9Sdrochner for (;;) {
7027d7edd9Sdrochner char *c = input;
7127d7edd9Sdrochner
7227d7edd9Sdrochner input[0] = '\0';
7327d7edd9Sdrochner printf("> ");
74*979b72c6Sdholland kgets(input, sizeof(input));
7527d7edd9Sdrochner
7627d7edd9Sdrochner /*
7727d7edd9Sdrochner * Skip leading whitespace.
7827d7edd9Sdrochner */
7949e9ba9aSchristos while (*c == ' ')
8049e9ba9aSchristos c++;
8127d7edd9Sdrochner if (*c)
8227d7edd9Sdrochner docommand(c);
8327d7edd9Sdrochner }
8427d7edd9Sdrochner }
85