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

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

1.1       nbrk        1: /*     $OpenBSD: parse_args.c,v 1.1 2006/05/16 22:48:18 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: int
                     40: parse_args(char *line, char **filep)
                     41: {
                     42:        char *name = NULL, *p;
                     43:
                     44:        /* recognize the special ``halt'' keyword */
                     45:        if (strcmp(line, "halt") == 0)
                     46:                return (1);
                     47:
                     48:        /*
                     49:         * The command line should be under the form
                     50:         *   devtype(...)filename args
                     51:         * such as
                     52:         *   inen()bsd -s
                     53:         * and we only care about the kernel name here.
                     54:         *
                     55:         * However, if the kernel could not be loaded, and we asked the
                     56:         * user, he may not give the devtype() part - especially since
                     57:         * at the moment we only support inen() anyway.
                     58:         */
                     59:
                     60:        /* search for a set of braces */
                     61:        for (p = line; *p != '\0' && *p != '('; p++) ;
                     62:        if (*p != '\0') {
                     63:                for (p = line; *p != '\0' && *p != ')'; p++) ;
                     64:                if (*p != '\0')
                     65:                        name = ++p;
                     66:        }
                     67:
                     68:        if (name == NULL)
                     69:                name = line;
                     70:
                     71:        /* now insert a NUL before any option */
                     72:        for (p = name; *p != '\0' && *p != ' '; p++) ;
                     73:        *p = '\0';
                     74:
                     75:        /* no name, use the default */
                     76:        if (*name == '\0')
                     77:                name = KERNEL_NAME;
                     78:
                     79:        *filep = name;
                     80:        return (0);
                     81: }

CVSweb