+\r
+/**\r
+ Function to print help file / man page content in the spec from the UEFI Shell protocol GetHelpText function.\r
+\r
+ @param[in] CommandToGetHelpOn Pointer to a string containing the command name of help file to be printed.\r
+ @param[in] SectionToGetHelpOn Pointer to the section specifier(s).\r
+ @param[in] PrintCommandText If TRUE, prints the command followed by the help content, otherwise prints \r
+ the help content only.\r
+ @retval EFI_DEVICE_ERROR The help data format was incorrect.\r
+ @retval EFI_NOT_FOUND The help data could not be found.\r
+ @retval EFI_SUCCESS The operation was successful.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellPrintHelp (\r
+ IN CONST CHAR16 *CommandToGetHelpOn,\r
+ IN CONST CHAR16 *SectionToGetHelpOn,\r
+ IN BOOLEAN PrintCommandText\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ CHAR16 *OutText;\r
+ \r
+ OutText = NULL;\r
+ \r
+ //\r
+ // Get the string to print based\r
+ //\r
+ Status = gEfiShellProtocol->GetHelpText (CommandToGetHelpOn, SectionToGetHelpOn, &OutText);\r
+ \r
+ //\r
+ // make sure we got a valid string\r
+ //\r
+ if (EFI_ERROR(Status)){\r
+ return Status;\r
+ } \r
+ if (OutText == NULL || StrLen(OutText) == 0) {\r
+ return EFI_NOT_FOUND; \r
+ }\r
+ \r
+ //\r
+ // Chop off trailing stuff we dont need\r
+ //\r
+ while (OutText[StrLen(OutText)-1] == L'\r' || OutText[StrLen(OutText)-1] == L'\n' || OutText[StrLen(OutText)-1] == L' ') {\r
+ OutText[StrLen(OutText)-1] = CHAR_NULL;\r
+ }\r
+ \r
+ //\r
+ // Print this out to the console\r
+ //\r
+ if (PrintCommandText) {\r
+ ShellPrintEx(-1, -1, L"%H%-14s%N- %s\r\n", CommandToGetHelpOn, OutText);\r
+ } else {\r
+ ShellPrintEx(-1, -1, L"%N%s\r\n", OutText);\r
+ }\r
+ \r
+ SHELL_FREE_NON_NULL(OutText);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Function to delete a file by name\r
+ \r
+ @param[in] FileName Pointer to file name to delete.\r
+ \r
+ @retval EFI_SUCCESS the file was deleted sucessfully\r
+ @retval EFI_WARN_DELETE_FAILURE the handle was closed, but the file was not\r
+ deleted\r
+ @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
+ @retval EFI_NOT_FOUND The specified file could not be found on the\r
+ device or the file system could not be found\r
+ on the device.\r
+ @retval EFI_NO_MEDIA The device has no medium.\r
+ @retval EFI_MEDIA_CHANGED The device has a different medium in it or the\r
+ medium is no longer supported.\r
+ @retval EFI_DEVICE_ERROR The device reported an error.\r
+ @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
+ @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r
+ @retval EFI_ACCESS_DENIED The file was opened read only.\r
+ @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the\r
+ file.\r
+ @retval other The file failed to open\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellDeleteFileByName(\r
+ IN CONST CHAR16 *FileName\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ SHELL_FILE_HANDLE FileHandle;\r
+ \r
+ Status = ShellFileExists(FileName);\r
+ \r
+ if (Status == EFI_SUCCESS){\r
+ Status = ShellOpenFileByName(FileName, &FileHandle, EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0x0);\r
+ if (Status == EFI_SUCCESS){\r
+ Status = ShellDeleteFile(&FileHandle);\r
+ }\r
+ } \r
+\r
+ return(Status);\r
+ \r
+}\r
+\r
+/**\r
+ Cleans off all the quotes in the string.\r
+\r
+ @param[in] OriginalString pointer to the string to be cleaned.\r
+ @param[out] CleanString The new string with all quotes removed. \r
+ Memory allocated in the function and free \r
+ by caller.\r
+\r
+ @retval EFI_SUCCESS The operation was successful.\r
+**/\r
+EFI_STATUS\r
+InternalShellStripQuotes (\r
+ IN CONST CHAR16 *OriginalString,\r
+ OUT CHAR16 **CleanString\r
+ )\r
+{\r
+ CHAR16 *Walker;\r
+ \r
+ if (OriginalString == NULL || CleanString == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ *CleanString = AllocateCopyPool (StrSize (OriginalString), OriginalString);\r
+ if (*CleanString == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ for (Walker = *CleanString; Walker != NULL && *Walker != CHAR_NULL ; Walker++) {\r
+ if (*Walker == L'\"') {\r
+ CopyMem(Walker, Walker+1, StrSize(Walker) - sizeof(Walker[0]));\r
+ }\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r