X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fsystem.c;h=1726fef2f83cac9f766ba2598f3c1747bc66ffc2;hb=0302a53b419f8c56193c75bcbd068cc89ae4df0b;hp=a99603849c6b9187bd21447e391f60d97d1c8eeb;hpb=d865234182d56b941e939875f8da3e3c45f24fd5;p=tpg%2Facess2.git diff --git a/Kernel/system.c b/Kernel/system.c index a9960384..1726fef2 100644 --- a/Kernel/system.c +++ b/Kernel/system.c @@ -82,7 +82,7 @@ void System_Init(char *CommandLine) System_ExecuteCommandLine(); // - Execute the Config Script - Log_Log("Config", "Executing config script..."); + Log_Log("Config", "Executing config script '%s'", gsConfigScript); System_ExecuteScript(); // Set the debug to be echoed to the terminal @@ -318,6 +318,7 @@ void System_ExecuteScript(void) // Get length VFS_Seek(fp, 0, SEEK_END); fLen = VFS_Tell(fp); + Log_Debug("System", "VFS_Tell(%i) = %i", fp, fLen); VFS_Seek(fp, 0, SEEK_SET); // Read into memory buffer fData = malloc(fLen+1); @@ -338,7 +339,8 @@ void System_ExecuteScript(void) if(line->Parts[0][0] == ':') continue; // Ignore labels // Prescan and eliminate variables - for( j = 1; j < line->nParts; j++ ) { + for( j = 1; j < line->nParts; j++ ) + { Log_Debug("Config", "Arg #%i is '%s'", j, line->Parts[j]); bReplaced[j] = 0; if( line->Parts[j][0] != '$' ) continue; @@ -356,13 +358,16 @@ void System_ExecuteScript(void) bReplaced[j] = 1; } + // Find the command name for( j = 0; j < NUM_CONFIG_COMMANDS; j++ ) { Uint args[N_MAX_ARGS]; + if(strcmp(line->Parts[0], caConfigCommands[j].Name) != 0) continue; Log_Debug("Config", "Command '%s', %i args passed", line->Parts[0], line->nParts-1); + // Check against minimum argument count if( line->nParts - 1 < caConfigCommands[j].MinArgs ) { Log_Warning("Config", "Configuration command '%s' requires at least %i arguments, %i given", @@ -371,6 +376,7 @@ void System_ExecuteScript(void) break; } + // Check for extra arguments if( line->nParts - 1 > caConfigCommands[j].MaxArgs ) { Log_Warning("Config", "Configuration command '%s' takes at most %i arguments, %i given", @@ -379,10 +385,12 @@ void System_ExecuteScript(void) break; } + // Fill in defaults for( k = caConfigCommands[j].MaxArgs-1; k > line->nParts - 1; k-- ) { args[k] = caConfigCommands[j].OptDefaults[k]; } + // Convert arguments to integers for( k = line->nParts-1; k--; ) { if( caConfigCommands[j].IntArgs & (1 << k) ) {