]>
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 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 #include <pexpert/pexpert.h>
27 extern boolean_t
isargsep( char c
);
28 extern int argstrcpy(char *from
, char *to
);
29 extern int getval(char *s
, int *val
);
43 boolean_t arg_boolean
;
46 args
= PE_boot_args();
47 if (*args
== '\0') return FALSE
;
51 while(isargsep(*args
)) args
++;
61 while (!isargsep (*cp
) && *cp
!= '=')
63 if (*cp
!= '=' && !arg_boolean
)
69 if (strncmp(args
, arg_string
, i
) ||
70 (i
!=strlen(arg_string
)))
73 *(unsigned int *)arg_ptr
= TRUE
;
77 while (isargsep (*cp
))
79 if (*cp
== '=' && c
!= '=') {
83 if ('_' == *arg_string
) /* Force a string copy if the argument name begins with an underscore */
85 argstrcpy2 (++cp
, (char *)arg_ptr
, 16); /* Hack - terminate after 16 characters */
89 switch (getval(cp
, &val
))
92 *(unsigned int *)arg_ptr
= val
;
96 argstrcpy(++cp
, (char *)arg_ptr
);
103 /* Skip over current arg */
104 while(!isargsep(*args
)) args
++;
106 /* Skip leading white space (catch end of args) */
107 while(*args
&& isargsep(*args
)) args
++;
116 if (c
== ' ' || c
== '\0' || c
== '\t')
129 while (!isargsep(*from
)) {
145 while (!isargsep(*from
) && i
< maxlen
) {
158 register unsigned radix
, intval
;
159 register unsigned char c
;
181 case '0': case '1': case '2': case '3':
182 case '4': case '5': case '6': case '7':
193 if (((c
= *s
++) >= '0') && (c
<= '9'))
195 else if ((c
>= 'a') && (c
<= 'f'))
197 else if ((c
>= 'A') && (c
<= 'F'))
199 else if (c
== 'k' || c
== 'K')
200 { sign
*= 1024; break; }
201 else if (c
== 'm' || c
== 'M')
202 { sign
*= 1024 * 1024; break; }
203 else if (c
== 'g' || c
== 'G')
204 { sign
*= 1024 * 1024 * 1024; break; }
205 else if (isargsep(c
))
214 *val
= intval
* sign
;