/** @file\r
Provides interface to shell functionality for shell commands and applications.\r
\r
-Copyright (c) 2006 - 2009, Intel Corporation<BR>\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
+ Copyright (c) 2006 - 2010, Intel Corporation<BR>\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
**/\r
\r
#if !defined(__SHELL_LIB__)\r
#define __SHELL_LIB__\r
\r
+#include <Uefi.h>\r
+#include <Guid/FileInfo.h>\r
#include <Protocol/SimpleFileSystem.h>\r
+#include <Protocol/LoadedImage.h>\r
+#include <Protocol/EfiShellInterface.h>\r
+#include <Protocol/EfiShellEnvironment2.h>\r
#include <Protocol/EfiShell.h>\r
+#include <Protocol/EfiShellParameters.h>\r
\r
/**\r
This function will retrieve the information about the file for the handle \r
This function opens a file with the open mode according to the file path. The \r
Attributes is valid only for EFI_FILE_MODE_CREATE.\r
\r
- @param[in] FilePath On input the device path to the file. On output \r
- the remaining device path.\r
- @param[out] DeviceHandle Pointer to the system device handle.\r
- @param[out] FileHandle Pointer to the file handle.\r
- @param[in] OpenMode The mode to open the file with.\r
- @param[in] Attributes The file's file attributes.\r
+ @param[in] FilePath On input the device path to the file. On output \r
+ the remaining device path.\r
+ @param[out] DeviceHandle Pointer to the system device handle.\r
+ @param[out] FileHandle Pointer to the file handle.\r
+ @param[in] OpenMode The mode to open the file with.\r
+ @param[in] Attributes The file's file attributes.\r
\r
@retval EFI_SUCCESS The information was set.\r
@retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
IN CONST CHAR16 *FileName\r
);\r
\r
+/**\r
+ Find a file by searching the CWD and then the path with a variable set of file \r
+ extensions. If the file is not found it will append each extension in the list \r
+ in the order provided and return the first one that is successful.\r
+\r
+ If FileName is NULL, then ASSERT.\r
+ If FileExtension is NULL, then behavior is identical to ShellFindFilePath.\r
+\r
+ If the return value is not NULL then the memory must be caller freed.\r
+\r
+ @param[in] FileName Filename string.\r
+ @param[in] FileExtension Semi-colon delimeted list of possible extensions.\r
+\r
+ @retval NULL The file was not found.\r
+ @retval !NULL The path to the file.\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+ShellFindFilePathEx (\r
+ IN CONST CHAR16 *FileName,\r
+ IN CONST CHAR16 *FileExtension\r
+ );\r
+\r
typedef enum {\r
TypeFlag = 0, ///< A flag that is present or not present only (IE "-a").\r
TypeValue, ///< A flag that has some data following it with a space (IE "-a 1").\r
/**\r
Function to determine if a given filename represents a file.\r
\r
+ This will search the CWD only.\r
+\r
If Name is NULL, then ASSERT.\r
\r
@param[in] Name Path to file to test.\r
IN CONST CHAR16 *Name\r
);\r
\r
+/**\r
+ Function to determine if a given filename represents a file.\r
+\r
+ This will search the CWD and then the Path.\r
+\r
+ If Name is NULL, then ASSERT.\r
+\r
+ @param[in] Name Path to file to test.\r
+\r
+ @retval EFI_SUCCESS The Path represents a file.\r
+ @retval EFI_NOT_FOUND The Path does not represent a file.\r
+ @retval other The path failed to open.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellIsFileInPath(\r
+ IN CONST CHAR16 *Name\r
+ );\r
+\r
/**\r
Function to determine whether a string is decimal or hex representation of a number \r
and return the number converted from the string.\r
IN UINTN Count\r
);\r
\r
+/**\r
+ This is a find and replace function. Upon successful return the NewString is a copy of \r
+ SourceString with each instance of FindTarget replaced with ReplaceWith.\r
+\r
+ If SourceString and NewString overlap the behavior is undefined.\r
+\r
+ If the string would grow bigger than NewSize it will halt and return error.\r
+\r
+ @param[in] SourceString String with source buffer.\r
+ @param[in,out] NewString String with resultant buffer.\r
+ @param[in] NewSize Size in bytes of NewString.\r
+ @param[in] FindTarget String to look for.\r
+ @param[in] ReplaceWith String to replace FindTarget with.\r
+\r
+ @retval EFI_INVALID_PARAMETER SourceString was NULL.\r
+ @retval EFI_INVALID_PARAMETER NewString was NULL.\r
+ @retval EFI_INVALID_PARAMETER FindTarget was NULL.\r
+ @retval EFI_INVALID_PARAMETER ReplaceWith was NULL.\r
+ @retval EFI_INVALID_PARAMETER FindTarget had length < 1.\r
+ @retval EFI_INVALID_PARAMETER SourceString had length < 1.\r
+ @retval EFI_BUFFER_TOO_SMALL NewSize was less than the minimum size to hold \r
+ the new string (truncation occurred).\r
+ @retval EFI_SUCCESS the string was sucessfully copied with replacement.\r
+**/\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ShellLibCopySearchAndReplace(\r
+ IN CHAR16 CONST *SourceString,\r
+ IN CHAR16 *NewString,\r
+ IN UINTN NewSize,\r
+ IN CONST CHAR16 *FindTarget,\r
+ IN CONST CHAR16 *ReplaceWith\r
+ );\r
+\r
+/**\r
+ Check if a Unicode character is a hexadecimal character.\r
+\r
+ This internal function checks if a Unicode character is a \r
+ decimal character. The valid hexadecimal character is \r
+ L'0' to L'9', L'a' to L'f', or L'A' to L'F'.\r
+\r
+ @param[in] Char The character to check.\r
+\r
+ @retval TRUE The Char is a hexadecmial character.\r
+ @retval FALSE The Char is not a hexadecmial character.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+ShellLibIsHexaDecimalDigitCharacter (\r
+ IN CHAR16 Char\r
+ );\r
+\r
#endif // __SHELL_LIB__\r