[BACK]Return to parse_args.c CVS log [TXT][DIR] Up to [local] / sys / arch / mvmeppc / stand / libsa

Annotation of sys/arch/mvmeppc/stand/libsa/parse_args.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: parse_args.c,v 1.3 2004/01/24 21:12:22 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:
                     56: char **filep;
                     57: int *flagp;
                     58:
                     59: {
                     60:        char *name = KERNEL_NAME, *ptr;
                     61:        int i, howto = 0;
                     62:        char c;
                     63:
                     64:        if (bugargs.arg_start != bugargs.arg_end) {
                     65:                ptr = bugargs.arg_start;
                     66:                while (c = *ptr) {
                     67:                        while (c == ' ')
                     68:                                c = *++ptr;
                     69:                        if (c == '\0')
                     70:                                return (0);
                     71:                        if (c != '-') {
                     72:                                name = ptr;
                     73:                                while ((c = *++ptr) && c != ' ')
                     74:                                        ;
                     75:                                if (c)
                     76:                                        *ptr++ = 0;
                     77:                                continue;
                     78:                        }
                     79:                        while ((c = *++ptr) && c != ' ') {
                     80:                                if (c == 'q')
                     81:                                        return (1);
                     82:                                for (i = 0; i < sizeof(bf)/sizeof(bf[0]); i++)
                     83:                                        if (bf[i].c == c) {
                     84:                                                howto |= bf[i].bit;
                     85:                                        }
                     86:                        }
                     87:                }
                     88:        }
                     89:        *flagp = howto;
                     90:        *filep = name;
                     91:        return (0);
                     92: }

CVSweb