+BOOL
+copyArgument(const char *argName, const char *val, int cnt, char **argP, int *cntRemainingP)
+{
+ int argLen = argName ? strlen(argName) : 0;
+ int len = argLen + cnt + 1; // +1 to account for space
+
+ if (len > *cntRemainingP) {
+ error("Warning: boot arguments too long, truncating\n");
+ return NO;
+ }
+
+ if (argName) {
+ strncpy( *argP, argName, argLen );
+ *argP += argLen;
+ *argP[0] = '=';
+ (*argP)++;
+ len++; // +1 to account for '='
+ }
+ strncpy( *argP, val, cnt );
+ *argP += cnt;
+ *argP[0] = ' ';
+ (*argP)++;
+
+ *cntRemainingP -= len;
+ return YES;
+}
+//
+// Returns TRUE if an argument was copied, FALSE otherwise
+
+BOOL
+processBootArgument(
+ const char *argName, // The argument to search for
+ const char *userString, // Typed-in boot arguments
+ const char *kernelFlags, // Kernel flags from config table
+ const char *configTable,
+ char **argP, // Output value
+ int *cntRemainingP, // Output count
+ char *foundVal // found value
+ )
+{
+ const char *val;
+ int cnt;
+ BOOL found = NO;
+
+ if (getValueForBootKey(userString, argName, &val, &cnt)) {
+ // Don't copy; these values will be copied at the end of argument processing.
+ found = YES;
+ } else if (getValueForBootKey(kernelFlags, argName, &val, &cnt)) {
+ // Don't copy; these values will be copied at the end of argument processing.
+ found = YES;
+ } else if (getValueForConfigTableKey(configTable, argName, &val, &cnt)) {
+ copyArgument(argName, val, cnt, argP, cntRemainingP);
+ found = YES;
+ }
+ if (found && foundVal) {
+ strlcpy(foundVal, val, cnt+1);
+ }
+ return found;
+}
+
+// Maximum config table value size
+#define VALUE_SIZE 1024
+
+int
+processBootOptions()