1 /* $NetBSD: parse_args.c,v 1.1 2002/02/27 21:02:27 scw 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 * 3. All advertising materials mentioning features or use of this software 15 * must display the following acknowledgement: 16 * This product includes software developed under OpenBSD by 17 * Theo de Raadt for Willowglen Singapore. 18 * 4. The name of the author may not be used to endorse or promote products 19 * derived from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 22 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 */ 34 35 #include <sys/param.h> 36 #include <sys/reboot.h> 37 #include <sys/disklabel.h> 38 #include <sys/boot_flag.h> 39 40 #include "stand.h" 41 #include "libsa.h" 42 43 #define KERNEL_NAME "netbsd" 44 45 void 46 parse_args(astart, aend, filep, flagp, partp) 47 char *astart; 48 const char *aend; 49 const char **filep; 50 int *flagp; 51 int *partp; 52 { 53 const char *name = KERNEL_NAME; 54 char *ptr; 55 int howto = 0, part = 0; 56 char c; 57 58 if (astart != aend) { 59 ptr = astart; 60 while ((c = *ptr)) { 61 while (c == ' ') 62 c = *++ptr; 63 if (c == '\0') 64 return; 65 if (c != '-') { 66 if (ptr[1] == ':') { 67 part = (int) (*ptr - 'A'); 68 if (part >= MAXPARTITIONS) 69 part -= 0x20; 70 if (part < 0 || part >= MAXPARTITIONS) 71 part = 0; 72 if (ptr[2] == ' ' || ptr[2] == '\0') { 73 ptr += 2; 74 continue; 75 } 76 name = &(ptr[2]); 77 } else 78 name = ptr; 79 while ((c = *++ptr) && c != ' ') 80 ; 81 if (c) 82 *ptr++ = 0; 83 continue; 84 } 85 while ((c = *++ptr) && c != ' ') 86 BOOT_FLAG(c, howto); 87 } 88 } 89 *flagp = howto; 90 *filep = name; 91 *partp = part; 92 } 93