+ @param[in] CmdName pointer to the command line to update.\r
+ \r
+ @retval Internal_Command The name is an internal command.\r
+ @retval File_Sys_Change the name is a file system change.\r
+ @retval Script_File_Name the name is a NSH script file.\r
+ @retval Unknown_Invalid the name is unknown.\r
+ @retval Efi_Application the name is an application (.EFI).\r
+**/\r
+SHELL_OPERATION_TYPES\r
+EFIAPI\r
+GetOperationType(\r
+ IN CONST CHAR16 *CmdName\r
+ )\r
+{\r
+ CHAR16* FileWithPath;\r
+ CONST CHAR16* TempLocation;\r
+ CONST CHAR16* TempLocation2;\r
+\r
+ FileWithPath = NULL;\r
+ //\r
+ // test for an internal command.\r
+ //\r
+ if (ShellCommandIsCommandOnList(CmdName)) {\r
+ return (Internal_Command);\r
+ }\r
+\r
+ //\r
+ // Test for file system change request. anything ending with : and cant have spaces.\r
+ //\r
+ if (CmdName[(StrLen(CmdName)-1)] == L':') {\r
+ if (StrStr(CmdName, L" ") != NULL) {\r
+ return (Unknown_Invalid);\r
+ }\r
+ return (File_Sys_Change);\r
+ }\r
+\r
+ //\r
+ // Test for a file\r
+ //\r
+ if ((FileWithPath = ShellFindFilePathEx(CmdName, mExecutableExtensions)) != NULL) {\r
+ //\r
+ // See if that file has a script file extension\r
+ //\r
+ if (StrLen(FileWithPath) > 4) {\r
+ TempLocation = FileWithPath+StrLen(FileWithPath)-4;\r
+ TempLocation2 = mScriptExtension;\r
+ if (StringNoCaseCompare((VOID*)(&TempLocation), (VOID*)(&TempLocation2)) == 0) {\r
+ SHELL_FREE_NON_NULL(FileWithPath);\r
+ return (Script_File_Name);\r
+ }\r
+ }\r
+\r
+ //\r
+ // Was a file, but not a script. we treat this as an application.\r
+ //\r
+ SHELL_FREE_NON_NULL(FileWithPath);\r
+ return (Efi_Application);\r
+ }\r
+ \r
+ SHELL_FREE_NON_NULL(FileWithPath);\r
+ //\r
+ // No clue what this is... return invalid flag...\r
+ //\r
+ return (Unknown_Invalid);\r
+}\r
+\r
+/**\r
+ Determine if the first item in a command line is valid.\r
+\r
+ @param[in] CmdLine The command line to parse.\r
+\r
+ @retval EFI_SUCCESS The item is valid.\r
+ @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
+ @retval EFI_NOT_FOUND The operation type is unknown or invalid.\r
+**/\r
+EFI_STATUS \r
+EFIAPI\r
+IsValidSplit(\r
+ IN CONST CHAR16 *CmdLine\r
+ )\r
+{\r
+ CHAR16 *Temp;\r
+ CHAR16 *FirstParameter;\r
+ CHAR16 *TempWalker;\r
+ EFI_STATUS Status;\r
+\r
+ Temp = NULL;\r
+\r
+ Temp = StrnCatGrow(&Temp, NULL, CmdLine, 0);\r
+ if (Temp == NULL) {\r
+ return (EFI_OUT_OF_RESOURCES);\r
+ }\r
+\r
+ FirstParameter = StrStr(Temp, L"|");\r
+ if (FirstParameter != NULL) {\r
+ *FirstParameter = CHAR_NULL;\r
+ }\r
+\r
+ FirstParameter = NULL;\r
+\r
+ //\r
+ // Process the command line\r
+ //\r
+ Status = ProcessCommandLineToFinal(&Temp);\r
+\r
+ if (!EFI_ERROR(Status)) {\r
+ FirstParameter = AllocateZeroPool(StrSize(CmdLine));\r
+ if (FirstParameter == NULL) {\r
+ SHELL_FREE_NON_NULL(Temp);\r
+ return (EFI_OUT_OF_RESOURCES);\r
+ }\r
+ TempWalker = (CHAR16*)Temp;\r
+ GetNextParameter(&TempWalker, &FirstParameter);\r
+\r
+ if (GetOperationType(FirstParameter) == Unknown_Invalid) {\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND), ShellInfoObject.HiiHandle, FirstParameter);\r
+ SetLastError(SHELL_NOT_FOUND);\r
+ Status = EFI_NOT_FOUND;\r
+ }\r
+ }\r
+\r
+ SHELL_FREE_NON_NULL(Temp);\r
+ SHELL_FREE_NON_NULL(FirstParameter);\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Determine if a command line contains with a split contains only valid commands.\r