]>
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 * 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
);
33 const char *arg_string
,
36 return PE_parse_boot_argn(arg_string
, arg_ptr
, -1);
41 const char *arg_string
,
49 boolean_t arg_boolean
;
52 args
= PE_boot_args();
53 if (*args
== '\0') return FALSE
;
57 while(isargsep(*args
)) args
++;
67 while (!isargsep (*cp
) && *cp
!= '=')
69 if (*cp
!= '=' && !arg_boolean
)
75 if (strncmp(args
, arg_string
, i
) ||
76 (i
!=strlen(arg_string
)))
79 *(unsigned int *)arg_ptr
= TRUE
;
83 while (isargsep (*cp
))
85 if (*cp
== '=' && c
!= '=') {
89 if ('_' == *arg_string
) /* Force a string copy if the argument name begins with an underscore */
91 int hacklen
= 16 > max_len
? 16 : max_len
;
92 argstrcpy2 (++cp
, (char *)arg_ptr
, hacklen
); /* Hack - terminate after 16 characters */
96 switch (getval(cp
, &val
))
99 *(unsigned int *)arg_ptr
= val
;
103 if(max_len
> 0) //max_len of 0 performs no copy at all
104 argstrcpy2(++cp
, (char *)arg_ptr
, max_len
);
105 else if(max_len
== -1)
106 argstrcpy(++cp
, (char *)arg_ptr
);
113 /* Skip over current arg */
114 while(!isargsep(*args
)) args
++;
116 /* Skip leading white space (catch end of args) */
117 while(*args
&& isargsep(*args
)) args
++;
126 if (c
== ' ' || c
== '\0' || c
== '\t')
139 while (!isargsep(*from
)) {
155 while (!isargsep(*from
) && i
< maxlen
) {
168 register unsigned radix
, intval
;
169 register unsigned char c
;
191 case '0': case '1': case '2': case '3':
192 case '4': case '5': case '6': case '7':
203 if (((c
= *s
++) >= '0') && (c
<= '9'))
205 else if ((c
>= 'a') && (c
<= 'f'))
207 else if ((c
>= 'A') && (c
<= 'F'))
209 else if (c
== 'k' || c
== 'K')
210 { sign
*= 1024; break; }
211 else if (c
== 'm' || c
== 'M')
212 { sign
*= 1024 * 1024; break; }
213 else if (c
== 'g' || c
== 'G')
214 { sign
*= 1024 * 1024 * 1024; break; }
215 else if (isargsep(c
))
224 *val
= intval
* sign
;