\r
\r
STATIC CONST UINT16 InvalidChars[] = {L'*', L'?', L'<', L'>', L'\\', L'/', L'\"', 0x0001, 0x0002};\r
-/**\r
- Function determines if the CommandName COULD be a valid command. It does not determine whether\r
- this is a valid command. It only checks for invalid characters.\r
-\r
- @param[in] CommandName The name to check\r
-\r
- @retval TRUE CommandName could be a command name\r
- @retval FALSE CommandName could not be a valid command name\r
-**/\r
-BOOLEAN\r
-IsValidCommandName(\r
- IN CONST CHAR16 *CommandName\r
- )\r
-{\r
- UINTN Count;\r
- if (CommandName == NULL) {\r
- ASSERT(FALSE);\r
- return (FALSE);\r
- }\r
- for ( Count = 0\r
- ; Count < sizeof(InvalidChars) / sizeof(InvalidChars[0])\r
- ; Count++\r
- ){\r
- if (ScanMem16(CommandName, StrSize(CommandName), InvalidChars[Count]) != NULL) {\r
- return (FALSE);\r
- }\r
- }\r
- return (TRUE);\r
-}\r
\r
/**\r
Function to process a NSH script file via SHELL_FILE_HANDLE.\r
OUT EFI_STATUS *CommandStatus\r
);\r
\r
-/**\r
- Function determines if the CommandName COULD be a valid command. It does not determine whether\r
- this is a valid command. It only checks for invalid characters.\r
-\r
- @param[in] CommandName The name to check\r
-\r
- @retval TRUE CommandName could be a command name\r
- @retval FALSE CommandName could not be a valid command name\r
-**/\r
-BOOLEAN\r
-IsValidCommandName(\r
- IN CONST CHAR16 *CommandName\r
- );\r
\r
/**\r
Function to process a NSH script file via SHELL_FILE_HANDLE.\r
return (FixFileName(Copy));\r
}\r
\r
-/**\r
- Remove the unicode file tag from the begining of the file buffer since that will not be\r
- used by StdIn.\r
-\r
- @param[in] Handle Pointer to the handle of the file to be processed.\r
-\r
- @retval EFI_SUCCESS The unicode file tag has been moved successfully.\r
-**/\r
-EFI_STATUS\r
-RemoveFileTag(\r
- IN SHELL_FILE_HANDLE *Handle\r
- )\r
-{\r
- UINTN CharSize;\r
- CHAR16 CharBuffer;\r
-\r
- CharSize = sizeof(CHAR16);\r
- CharBuffer = 0;\r
- gEfiShellProtocol->ReadFile(*Handle, &CharSize, &CharBuffer);\r
- if (CharBuffer != gUnicodeFileTag) {\r
- gEfiShellProtocol->SetFilePosition(*Handle, 0);\r
- }\r
- return (EFI_SUCCESS);\r
-}\r
\r
/**\r
Write the unicode file tag to the specified file.\r
return (FALSE);\r
}\r
\r
-/**\r
- Internal worker debug helper function to print out maps as they are added.\r
-\r
- @param[in] Mapping string mapping that has been added\r
- @param[in] DevicePath pointer to device path that has been mapped.\r
-\r
- @retval EFI_SUCCESS the operation was successful.\r
- @return other an error ocurred\r
-\r
- @sa LocateHandle\r
- @sa OpenProtocol\r
-**/\r
-EFI_STATUS\r
-InternalShellProtocolDebugPrintMessage (\r
- IN CONST CHAR16 *Mapping,\r
- IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
- )\r
-{\r
- EFI_STATUS Status;\r
- CHAR16 *Temp;\r
-\r
- Status = EFI_SUCCESS;\r
- DEBUG_CODE_BEGIN();\r
-\r
- if (Mapping != NULL) {\r
- DEBUG((EFI_D_INFO, "Added new map item:\"%S\"\r\n", Mapping));\r
- }\r
- Temp = ConvertDevicePathToText(DevicePath, TRUE, TRUE);\r
- DEBUG((EFI_D_INFO, "DevicePath: %S\r\n", Temp));\r
- FreePool(Temp);\r
-\r
- DEBUG_CODE_END();\r
- return (Status);\r
-}\r
\r
/**\r
This function creates a mapping for a device path.\r
// We are opening a regular file.\r
//\r
DevicePath = EfiShellGetDevicePathFromFilePath(FileName);\r
-// DEBUG_CODE(InternalShellProtocolDebugPrintMessage (NULL, DevicePath););\r
+\r
if (DevicePath == NULL) {\r
return (EFI_NOT_FOUND);\r
}\r
return (EFI_SUCCESS);\r
}\r
\r
-/**\r
- Updates a file name to be preceeded by the mapped drive name\r
-\r
- @param[in] BasePath the Mapped drive name to prepend\r
- @param[in, out] Path pointer to pointer to the file name to update.\r
-\r
- @retval EFI_SUCCESS\r
- @retval EFI_OUT_OF_RESOURCES\r
-**/\r
-EFI_STATUS\r
-UpdateFileName(\r
- IN CONST CHAR16 *BasePath,\r
- IN OUT CHAR16 **Path\r
- )\r
-{\r
- CHAR16 *Path2;\r
- UINTN Path2Size;\r
-\r
- Path2Size = 0;\r
- Path2 = NULL;\r
-\r
- ASSERT(Path != NULL);\r
- ASSERT(*Path != NULL);\r
- ASSERT(BasePath != NULL);\r
-\r
- //\r
- // convert a local path to an absolute path\r
- //\r
- if (StrStr(*Path, L":") == NULL) {\r
- ASSERT((Path2 == NULL && Path2Size == 0) || (Path2 != NULL));\r
- StrnCatGrow(&Path2, &Path2Size, BasePath, 0);\r
- if (Path2 == NULL) {\r
- return (EFI_OUT_OF_RESOURCES);\r
- }\r
- ASSERT((Path2 == NULL && Path2Size == 0) || (Path2 != NULL));\r
- StrnCatGrow(&Path2, &Path2Size, (*Path)[0] == L'\\'?(*Path) + 1 :*Path, 0);\r
- if (Path2 == NULL) {\r
- return (EFI_OUT_OF_RESOURCES);\r
- }\r
- }\r
-\r
- FreePool(*Path);\r
- (*Path) = Path2;\r
\r
- return (EFI_SUCCESS);\r
-}\r
\r
/**\r
If FileHandle is a directory then the function reads from FileHandle and reads in\r