menuutils.c revision 1.1
11.1Sdrochner/*	$NetBSD: menuutils.c,v 1.1 1997/09/17 17:13:02 drochner Exp $	*/
21.1Sdrochner
31.1Sdrochner/*
41.1Sdrochner * Copyright (c) 1996, 1997
51.1Sdrochner * 	Matthias Drochner.  All rights reserved.
61.1Sdrochner * Copyright (c) 1996, 1997
71.1Sdrochner * 	Perry E. Metzger.  All rights reserved.
81.1Sdrochner * Copyright (c) 1997
91.1Sdrochner *	Jason R. Thorpe.  All rights reserved
101.1Sdrochner *
111.1Sdrochner * Redistribution and use in source and binary forms, with or without
121.1Sdrochner * modification, are permitted provided that the following conditions
131.1Sdrochner * are met:
141.1Sdrochner * 1. Redistributions of source code must retain the above copyright
151.1Sdrochner *    notice, this list of conditions and the following disclaimer.
161.1Sdrochner * 2. Redistributions in binary form must reproduce the above copyright
171.1Sdrochner *    notice, this list of conditions and the following disclaimer in the
181.1Sdrochner *    documentation and/or other materials provided with the distribution.
191.1Sdrochner * 3. All advertising materials mentioning features or use of this software
201.1Sdrochner *    must display the following acknowledgements:
211.1Sdrochner *	This product includes software developed for the NetBSD Project
221.1Sdrochner *	by Matthias Drochner.
231.1Sdrochner *	This product includes software developed for the NetBSD Project
241.1Sdrochner *	by Perry E. Metzger.
251.1Sdrochner * 4. The names of the authors may not be used to endorse or promote products
261.1Sdrochner *    derived from this software without specific prior written permission.
271.1Sdrochner *
281.1Sdrochner * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
291.1Sdrochner * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
301.1Sdrochner * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
311.1Sdrochner * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
321.1Sdrochner * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
331.1Sdrochner * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
341.1Sdrochner * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
351.1Sdrochner * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
361.1Sdrochner * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
371.1Sdrochner * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
381.1Sdrochner */
391.1Sdrochner
401.1Sdrochner#include <lib/libkern/libkern.h>
411.1Sdrochner#include <lib/libsa/stand.h>
421.1Sdrochner
431.1Sdrochner#include "libi386.h"
441.1Sdrochner
451.1Sdrochnervoid
461.1Sdrochnerdocommand(arg)
471.1Sdrochner	char *arg;
481.1Sdrochner{
491.1Sdrochner	char *options;
501.1Sdrochner	int i;
511.1Sdrochner
521.1Sdrochner	options = gettrailer(arg);
531.1Sdrochner
541.1Sdrochner	for (i = 0; commands[i].c_name != NULL; i++) {
551.1Sdrochner		if (strcmp(arg, commands[i].c_name) == 0) {
561.1Sdrochner			(*commands[i].c_fn)(options);
571.1Sdrochner			return;
581.1Sdrochner		}
591.1Sdrochner	}
601.1Sdrochner
611.1Sdrochner	printf("unknown command\n");
621.1Sdrochner	command_help(NULL);
631.1Sdrochner}
641.1Sdrochner
651.1Sdrochnervoid
661.1Sdrochnerbootmenu()
671.1Sdrochner{
681.1Sdrochner	char input[80];
691.1Sdrochner
701.1Sdrochner	for (;;) {
711.1Sdrochner		char *c = input;
721.1Sdrochner
731.1Sdrochner		input[0] = '\0';
741.1Sdrochner		printf("> ");
751.1Sdrochner		gets(input);
761.1Sdrochner
771.1Sdrochner		/*
781.1Sdrochner		 * Skip leading whitespace.
791.1Sdrochner		 */
801.1Sdrochner		while(*c == ' ') c++;
811.1Sdrochner		if(*c)
821.1Sdrochner			docommand(c);
831.1Sdrochner	}
841.1Sdrochner}
85