]>
git.saurik.com Git - apple/xnu.git/blob - pexpert/gen/bootargs.c
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
22 #include <pexpert/pexpert.h>
24 extern boolean_t
isargsep( char c
);
25 extern int argstrcpy(char *from
, char *to
);
26 extern int getval(char *s
, int *val
);
40 boolean_t arg_boolean
;
43 args
= PE_boot_args();
44 if (*args
== '\0') return FALSE
;
48 while(isargsep(*args
)) args
++;
58 while (!isargsep (*cp
) && *cp
!= '=')
60 if (*cp
!= '=' && !arg_boolean
)
66 if (strncmp(args
, arg_string
, i
) ||
67 (i
!=strlen(arg_string
)))
70 *(unsigned int *)arg_ptr
= TRUE
;
74 while (isargsep (*cp
))
76 if (*cp
== '=' && c
!= '=') {
80 if ('_' == *arg_string
) /* Force a string copy if the argument name begins with an underscore */
82 argstrcpy2 (++cp
, (char *)arg_ptr
, 16); /* Hack - terminate after 16 characters */
86 switch (getval(cp
, &val
))
89 *(unsigned int *)arg_ptr
= val
;
93 argstrcpy(++cp
, (char *)arg_ptr
);
100 /* Skip over current arg */
101 while(!isargsep(*args
)) args
++;
103 /* Skip leading white space (catch end of args) */
104 while(*args
&& isargsep(*args
)) args
++;
113 if (c
== ' ' || c
== '\0' || c
== '\t')
126 while (!isargsep(*from
)) {
142 while (!isargsep(*from
) && i
< maxlen
) {
155 register unsigned radix
, intval
;
156 register unsigned char c
;
178 case '0': case '1': case '2': case '3':
179 case '4': case '5': case '6': case '7':
190 if (((c
= *s
++) >= '0') && (c
<= '9'))
192 else if ((c
>= 'a') && (c
<= 'f'))
194 else if ((c
>= 'A') && (c
<= 'F'))
196 else if (c
== 'k' || c
== 'K')
197 { sign
*= 1024; break; }
198 else if (c
== 'm' || c
== 'M')
199 { sign
*= 1024 * 1024; break; }
200 else if (c
== 'g' || c
== 'G')
201 { sign
*= 1024 * 1024 * 1024; break; }
202 else if (isargsep(c
))
211 *val
= intval
* sign
;