- if(strcmp(Arg, "SCRIPT") == 0) {
- Log("Config Script: '%s'", value);
- gsConfigScript = value;
- } else {
- Warning("Kernel config setting '%s' is not recognised", Arg);
- }
-
- }
-}
-
-/**
- * \fn void System_ExecuteScript()
- */
-void System_ExecuteScript()
-{
- int fp;
- int fLen = 0;
- int i = 0, lineStart;
- char *sArg1, *sArg2, *sArg3;
- char *fData;
-
- // Open Script
- fp = VFS_Open(gsConfigScript, VFS_OPENFLAG_READ);
- if(fp == -1) {
- Warning("[CFG] Passed script '%s' does not exist", gsConfigScript);
- return;
- }
-
- // Read into memory buffer
- VFS_Seek(fp, 0, SEEK_END);
- fLen = VFS_Tell(fp);
- VFS_Seek(fp, 0, SEEK_SET);
- fData = malloc(fLen+1);
- VFS_Read(fp, fLen, fData);
- fData[fLen] = '\0';
- VFS_Close(fp);
-
- // Read Script
- while(i < fLen)
- {
- sArg1 = sArg2 = sArg3 = NULL;
-
- lineStart = i;
- // Clear leading whitespace and find empty lines
- while(i < fLen && (fData[i] == ' ' || fData[i]=='\t')) i ++;
- if(i == fLen) break;
- if(fData[i] == '\n') {
- i++;
- continue;
- }
-
- // Comment
- if(fData[i] == ';' || fData[i] == '#') {
- while(i < fLen && fData[i] != '\n') i ++;
- i ++;
- continue;
- }
-
- // Commands
- // - Mount
- if(strncmp("mount ", fData+i, 6) == 0) {
- i += 6;
- i += System_Int_GetString(fData+i, &sArg1);
- if(!sArg1) goto read2eol;
- i += System_Int_GetString(fData+i, &sArg2);
- if(!sArg2) goto read2eol;
- i += System_Int_GetString(fData+i, &sArg3);
- if(!sArg3) goto read2eol;
- //Log("[CFG ] Mount '%s' to '%s' (%s)\n", sArg1, sArg2, sArg3);
- VFS_Mount(sArg1, sArg2, sArg3, "");
- }
- // - Load Module
- else if(strncmp("module ", fData+i, 6) == 0) {
- i += 7;
- i += System_Int_GetString(fData+i, &sArg1);
- if(!sArg1) goto read2eol;
- //Log("[CFG ] Load Module '%s'\n", sArg1);
- Module_LoadFile(sArg1, ""); //!\todo Use the rest of the line as the argument string
- }
- // - Load Module
- else if(strncmp("edimod ", fData+i, 6) == 0) {
- i += 7;
- i += System_Int_GetString(fData+i, &sArg1);
- if(!sArg1) goto read2eol;
- Log("[CFG ] Load EDI Module '%s'\n", sArg1);
- Module_LoadFile(sArg1, "");
- }
- // - Symlink
- else if(strncmp("symlink ", fData+i, 7) == 0) {
- i += 8;
- i += System_Int_GetString(fData+i, &sArg1);
- if(!sArg1) goto read2eol;
- i += System_Int_GetString(fData+i, &sArg2);
- if(!sArg2) goto read2eol;
- Log("[CFG ] Symlink '%s' pointing to '%s'\n", sArg1, sArg2);
- VFS_Symlink(sArg1, sArg2);
- }
- // - New Directory
- else if(strncmp("mkdir ", fData+i, 5) == 0) {
- i += 6;
- i += System_Int_GetString(fData+i, &sArg1);
- if(!sArg1) goto read2eol;
- Log("[CFG ] New Directory '%s'\n", sArg1);
- VFS_MkDir(sArg1);
- }
- // - Spawn a task
- else if(strncmp("spawn ", fData+i, 5) == 0) {
- i += 6;
- i += System_Int_GetString(fData+i, &sArg1);
- if(!sArg1) goto read2eol;
- Log("[CFG ] Starting '%s' as a new task\n", sArg1);
- Proc_Spawn(sArg1);