Annotation of sys/arch/mvme88k/stand/libsa/parse_args.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: parse_args.c,v 1.5 2006/05/16 22:52:09 miod Exp $ */
! 2:
! 3: /*-
! 4: * Copyright (c) 1995 Theo de Raadt
! 5: *
! 6: * Redistribution and use in source and binary forms, with or without
! 7: * modification, are permitted provided that the following conditions
! 8: * are met:
! 9: * 1. Redistributions of source code must retain the above copyright
! 10: * notice, this list of conditions and the following disclaimer.
! 11: * 2. Redistributions in binary form must reproduce the above copyright
! 12: * notice, this list of conditions and the following disclaimer in the
! 13: * documentation and/or other materials provided with the distribution.
! 14: *
! 15: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
! 16: * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
! 17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 18: * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
! 19: * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 20: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 21: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 22: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 23: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 24: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 25: * SUCH DAMAGE.
! 26: *
! 27: */
! 28:
! 29: #include <sys/param.h>
! 30: #include <sys/reboot.h>
! 31: #include <machine/prom.h>
! 32: #include <a.out.h>
! 33:
! 34: #include "stand.h"
! 35: #include "libsa.h"
! 36:
! 37: #define KERNEL_NAME "bsd"
! 38:
! 39: struct flags {
! 40: char c;
! 41: short bit;
! 42: } bf[] = {
! 43: { 'a', RB_ASKNAME }, /* ask root */
! 44: { 'b', RB_HALT },
! 45: { 'c', RB_CONFIG },
! 46: { 'd', RB_KDB },
! 47: { 'm', RB_MINIROOT },
! 48: { 'r', RB_DFLTROOT },
! 49: { 's', RB_SINGLE },
! 50: { 'y', RB_NOSYM },
! 51: };
! 52:
! 53: int
! 54: parse_args(filep, flagp)
! 55: char **filep;
! 56: int *flagp;
! 57: {
! 58: char *name = KERNEL_NAME, *ptr;
! 59: int i, howto = 0;
! 60: char c;
! 61:
! 62: if (bugargs.arg_start != bugargs.arg_end) {
! 63: ptr = bugargs.arg_start;
! 64: while ((c = *ptr) != '\0') {
! 65: while (c == ' ')
! 66: c = *++ptr;
! 67: if (c == '\0')
! 68: return (0);
! 69: if (c != '-') {
! 70: name = ptr;
! 71: while ((c = *++ptr) && c != ' ')
! 72: ;
! 73: if (c)
! 74: *ptr++ = 0;
! 75: continue;
! 76: }
! 77: while ((c = *++ptr) && c != ' ') {
! 78: if (c == 'q')
! 79: return (1);
! 80: for (i = 0; i < sizeof(bf)/sizeof(bf[0]); i++)
! 81: if (bf[i].c == c) {
! 82: howto |= bf[i].bit;
! 83: }
! 84: }
! 85: }
! 86: }
! 87: *flagp = howto;
! 88: *filep = name;
! 89: return (0);
! 90: }
CVSweb