1 /* $NetBSD: parseutils.c,v 1.1 2001/09/27 10:03:28 minoura Exp $ */
4 * from /sys/arch/i386/lib/parseutils.c
5 * NetBSD: parseutils.c,v 1.3 2000/09/24 12:32:35 jdolecek Exp
9 * Copyright (c) 1996, 1997
10 * Matthias Drochner. All rights reserved.
11 * Copyright (c) 1996, 1997
12 * Perry E. Metzger. All rights reserved.
14 * Jason R. Thorpe. All rights reserved
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. All advertising materials mentioning features or use of this software
25 * must display the following acknowledgements:
26 * This product includes software developed for the NetBSD Project
27 * by Matthias Drochner.
28 * This product includes software developed for the NetBSD Project
29 * by Perry E. Metzger.
30 * 4. The names of the authors may not be used to endorse or promote products
31 * derived from this software without specific prior written permission.
33 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
34 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
35 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
36 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
37 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
38 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
39 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
40 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
41 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
42 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 #include <lib/libkern/libkern.h>
46 #include <lib/libsa/stand.h>
47 #include <sys/boot_flag.h>
53 * chops the head from the arguments and returns the arguments if any,
54 * or possibly an empty string.
61 if ((options
= strchr(arg
, ' ')) == NULL
)
66 /* trim leading blanks */
67 while (*options
&& *options
== ' ')
74 parseopts(const char *opts
, int *howto
)
79 while (*opts
&& *opts
!= ' ') {
83 printf("-%c: unknown flag\n", *opts
);
95 parseboot(char *arg
, char **filename
, int *howto
)
102 /* if there were no arguments */
107 /* [[xxNx:]filename] [-adqsv] */
109 /* check for just args */
113 /* there's a file name */
116 opts
= gettrailer(arg
);
119 } else if (*opts
!= '-') {
120 printf("invalid arguments\n");
125 /* at this point, we have dealt with filenames. */
127 /* now, deal with options */
129 if (parseopts(opts
, howto
) == 0)