]>
git.saurik.com Git - apple/xnu.git/blob - pexpert/gen/bootargs.c
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 #include <pexpert/pexpert.h>
25 extern boolean_t
isargsep( char c
);
26 extern int argstrcpy(char *from
, char *to
);
27 extern int getval(char *s
, int *val
);
34 const char *arg_string
,
37 return PE_parse_boot_argn(arg_string
, arg_ptr
, -1);
42 const char *arg_string
,
50 boolean_t arg_boolean
;
53 args
= PE_boot_args();
54 if (*args
== '\0') return FALSE
;
58 while(isargsep(*args
)) args
++;
68 while (!isargsep (*cp
) && *cp
!= '=')
70 if (*cp
!= '=' && !arg_boolean
)
76 if (strncmp(args
, arg_string
, i
) ||
77 (i
!=strlen(arg_string
)))
80 *(unsigned int *)arg_ptr
= TRUE
;
84 while (isargsep (*cp
))
86 if (*cp
== '=' && c
!= '=') {
90 if ('_' == *arg_string
) /* Force a string copy if the argument name begins with an underscore */
92 int hacklen
= 16 > max_len
? 16 : max_len
;
93 argstrcpy2 (++cp
, (char *)arg_ptr
, hacklen
); /* Hack - terminate after 16 characters */
97 switch (getval(cp
, &val
))
100 *(unsigned int *)arg_ptr
= val
;
104 if(max_len
> 0) //max_len of 0 performs no copy at all
105 argstrcpy2(++cp
, (char *)arg_ptr
, max_len
);
106 else if(max_len
== -1)
107 argstrcpy(++cp
, (char *)arg_ptr
);
114 /* Skip over current arg */
115 while(!isargsep(*args
)) args
++;
117 /* Skip leading white space (catch end of args) */
118 while(*args
&& isargsep(*args
)) args
++;
127 if (c
== ' ' || c
== '\0' || c
== '\t')
140 while (!isargsep(*from
)) {
156 while (!isargsep(*from
) && i
< maxlen
) {
169 register unsigned radix
, intval
;
170 register unsigned char c
;
192 case '0': case '1': case '2': case '3':
193 case '4': case '5': case '6': case '7':
204 if (((c
= *s
++) >= '0') && (c
<= '9'))
206 else if ((c
>= 'a') && (c
<= 'f'))
208 else if ((c
>= 'A') && (c
<= 'F'))
210 else if (c
== 'k' || c
== 'K')
211 { sign
*= 1024; break; }
212 else if (c
== 'm' || c
== 'M')
213 { sign
*= 1024 * 1024; break; }
214 else if (c
== 'g' || c
== 'G')
215 { sign
*= 1024 * 1024 * 1024; break; }
216 else if (isargsep(c
))
225 *val
= intval
* sign
;