X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=Usermode%2FApplications%2FCLIShell_src%2Fmain.c;h=4fe8a4a2331cb3f154c563d5099b310dafc7b88a;hb=1a96e0dd77d6922078edd703fc7c2e809b9499b8;hp=aa1d9abec48744cd0f5182998adb526848ee1439;hpb=f6b468cee21ebf1c9b98efec5315950aa043ead5;p=tpg%2Facess2.git diff --git a/Usermode/Applications/CLIShell_src/main.c b/Usermode/Applications/CLIShell_src/main.c index aa1d9abe..4fe8a4a2 100644 --- a/Usermode/Applications/CLIShell_src/main.c +++ b/Usermode/Applications/CLIShell_src/main.c @@ -13,6 +13,7 @@ // ==== PROTOTYPES ==== char *ReadCommandLine(int *Length); void Parse_Args(char *str, char **dest); +void CallCommand(char **Args); void Command_Colour(int argc, char **argv); void Command_Clear(int argc, char **argv); void Command_Cd(int argc, char **argv); @@ -27,12 +28,15 @@ struct { {"colour", Command_Colour}, {"clear", Command_Clear}, {"cd", Command_Cd}, {"dir", Command_Dir} }; +static char *cDEFAULT_PATH[] = {"/Acess"}; #define BUILTIN_COUNT (sizeof(cBUILTINS)/sizeof(cBUILTINS[0])) // ==== LOCAL VARIABLES ==== + int giNumPathDirs = 1; +char **gasPathDirs = cDEFAULT_PATH; +char **gasEnvironment; char gsCommandBuffer[1024]; char *gsCurrentDirectory = NULL; -char gsTmpBuffer[1024]; char **gasCommandHistory; int giLastCommand = 0; int giCommandSpace = 0; @@ -43,12 +47,13 @@ int main(int argc, char *argv[], char *envp[]) char *sCommandStr; char *saArgs[32]; int length = 0; - int pid = -1; + int i; int iArgCount = 0; int bCached = 1; - t_sysFInfo info; - //Command_Clear(0, NULL); + gasEnvironment = envp; + + Command_Clear(0, NULL); { char *tmp = getenv("CWD"); @@ -61,7 +66,6 @@ int main(int argc, char *argv[], char *envp[]) } } - write(_stdout, 1, "\n"); write(_stdout, 22, "Acess Shell Version 3\n"); write(_stdout, 2, "\n"); for(;;) @@ -70,13 +74,17 @@ int main(int argc, char *argv[], char *envp[]) if(saArgs[0]) free(saArgs); if(!bCached) free(sCommandStr); bCached = 0; - write(_stdout, 1, "\n"); write(_stdout, strlen(gsCurrentDirectory), gsCurrentDirectory); write(_stdout, 3, "$ "); // Read Command line sCommandStr = ReadCommandLine( &length ); + if(!sCommandStr) { + write(_stdout, 25, "PANIC: Out of heap space\n"); + return -1; + } + // Check if the command should be cached if(gasCommandHistory == NULL || strcmp(sCommandStr, gasCommandHistory[giLastCommand]) != 0) { @@ -100,46 +108,18 @@ int main(int argc, char *argv[], char *envp[]) if(saArgs[1][0] == '\0') continue; // Check Built-In Commands - // [HACK] Mem Usage - Use Length in place of `i' - for(length=0;length []\n"); Print("Valid Colours are "); for(fg=0;fg<8;fg++) { @@ -300,6 +374,10 @@ usage: return; } +/** + * \fn void Command_Clear(int argc, char **argv) + * \brief Clear the screen + */ void Command_Clear(int argc, char **argv) { write(_stdout, 4, "\x1B[2J"); //Clear Screen @@ -339,6 +417,9 @@ void Command_Cd(int argc, char **argv) free(gsCurrentDirectory); gsCurrentDirectory = malloc(strlen(tmpPath)+1); strcpy(gsCurrentDirectory, tmpPath); + + // Register change with kernel + chdir( gsCurrentDirectory ); } /**