#define __SHELL_LIB__\r
\r
#include <Protocol/SimpleFileSystem.h>\r
-#include <Guid/FileInfo.h>\r
#include <Protocol/EfiShell.h>\r
\r
/**\r
This function will retrieve the information about the file for the handle \r
specified and store it in allocated pool memory.\r
\r
- This function allocates a buffer to store the file\92s information. It is the \r
- caller\92s responsibility to free the buffer\r
+ This function allocates a buffer to store the file's information. It is the \r
+ caller's responsibility to free the buffer\r
\r
@param FileHandle The file handle of the file for which information is \r
being requested.\r
\r
@param FileInfo The infotmation to set.\r
\r
- @retval EFI_SUCCESS The information was set.\r
+ @retval EFI_SUCCESS The information was set.\r
@retval EFI_UNSUPPORTED The InformationType is not known.\r
@retval EFI_NO_MEDIA The device has no medium.\r
@retval EFI_DEVICE_ERROR The device reported an error.\r
/**\r
This function will open a file or directory referenced by filename.\r
\r
- If return is EFI_SUCCESS, the Filehandle is the opened file\92s handle; \r
+ If return is EFI_SUCCESS, the Filehandle is the opened file's handle; \r
otherwise, the Filehandle is NULL. The Attributes is valid only for \r
EFI_FILE_MODE_CREATE.\r
\r
@param OpenMode the mode to open the file with.\r
@param Attributes the file's file attributes.\r
\r
- @retval EFI_SUCCESS The information was set.\r
+ @retval EFI_SUCCESS The information was set.\r
@retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
- @retval EFI_UNSUPPORTED Could not open the file path. \r
+ @retval EFI_UNSUPPORTED Could not open the file path. \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
+ @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_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_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 EFI_VOLUME_FULL The volume is full.\r
+ @retval EFI_VOLUME_FULL The volume is full.\r
**/\r
EFI_STATUS\r
EFIAPI\r
ShellOpenFileByName(\r
- IN CHAR16 *FilePath,\r
+ IN CONST CHAR16 *FilePath,\r
OUT EFI_FILE_HANDLE *FileHandle,\r
IN UINT64 OpenMode,\r
IN UINT64 Attributes\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
+ @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_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_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 EFI_VOLUME_FULL The volume is full.\r
+ @retval EFI_VOLUME_FULL The volume is full.\r
**/\r
EFI_STATUS\r
EFIAPI\r
ShellCreateDirectory(\r
- IN CHAR16 *DirectoryName,\r
+ IN CONST CHAR16 *DirectoryName,\r
OUT EFI_FILE_HANDLE *FileHandle\r
);\r
\r
This function reads information from an opened file.\r
\r
If FileHandle is not a directory, the function reads the requested number of \r
- bytes from the file at the file\92s current position and returns them in Buffer. \r
+ bytes from the file at the file's current position and returns them in Buffer. \r
If the read goes beyond the end of the file, the read length is truncated to the\r
- end of the file. The file\92s current position is increased by the number of bytes \r
+ end of the file. The file's current position is increased by the number of bytes \r
returned. If FileHandle is a directory, the function reads the directory entry \r
- at the file\92s current position and returns the entry in Buffer. If the Buffer \r
+ at the file's current position and returns the entry in Buffer. If the Buffer \r
is not large enough to hold the current directory entry, then \r
EFI_BUFFER_TOO_SMALL is returned and the current file position is not updated. \r
BufferSize is set to be the size of the buffer needed to read the entry. On \r
\r
@param Buffer the buffer to put read data into.\r
\r
- @retval EFI_SUCCESS Data was read.\r
- @retval EFI_NO_MEDIA The device has no media.\r
- @retval EFI_DEVICE_ERROR The device reported an error.\r
- @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
- @retval EFI_BUFFER_TO_SMALL Buffer is too small. ReadSize contains required \r
+ @retval EFI_SUCCESS Data was read.\r
+ @retval EFI_NO_MEDIA The device has no media.\r
+ @retval EFI_DEVICE_ERROR The device reported an error.\r
+ @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
+ @retval EFI_BUFFER_TO_SMALL Buffer is too small. ReadSize contains required \r
size.\r
\r
**/\r
This function writes the specified number of bytes to the file at the current \r
file position. The current file position is advanced the actual number of bytes \r
written, which is returned in BufferSize. Partial writes only occur when there \r
- has been a data error during the write attempt (such as \93volume space full\94). \r
+ has been a data error during the write attempt (such as "volume space full"). \r
The file is automatically grown to hold the data if required. Direct writes to \r
opened directories are not supported.\r
\r
@param Buffer the buffer containing data to write is stored.\r
\r
@retval EFI_SUCCESS Data was written.\r
- @retval EFI_UNSUPPORTED Writes to an open directory are not supported.\r
+ @retval EFI_UNSUPPORTED Writes to an open directory are not supported.\r
@retval EFI_NO_MEDIA The device has no media.\r
- @retval EFI_DEVICE_ERROR The device reported an error.\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 device is write-protected.\r
- @retval EFI_ACCESS_DENIED The file was open for read only.\r
- @retval EFI_VOLUME_FULL The volume is full.\r
+ @retval EFI_ACCESS_DENIED The file was open for read only.\r
+ @retval EFI_VOLUME_FULL The volume is full.\r
**/\r
EFI_STATUS\r
EFIAPI\r
ShellWriteFile(\r
IN EFI_FILE_HANDLE FileHandle,\r
IN OUT UINTN *BufferSize,\r
- IN CONST VOID *Buffer\r
+ IN VOID *Buffer\r
);\r
\r
/** \r
Close an open file handle.\r
\r
- This function closes a specified file handle. All \93dirty\94 cached file data is \r
+ This function closes a specified file handle. All "dirty" cached file data is \r
flushed to the device, and the file is closed. In all cases the handle is \r
closed.\r
\r
in the directory's info. Caller can use ShellFindNextFile() to get \r
subsequent files.\r
\r
+ Caller must use FreePool on *Buffer opon completion of all file searching.\r
+\r
@param DirHandle The file handle of the directory to search\r
- @param Buffer Pointer to buffer for file's information\r
+ @param Buffer Pointer to pointer to buffer for file's information\r
\r
@retval EFI_SUCCESS Found the first file.\r
@retval EFI_NOT_FOUND Cannot find the directory.\r
EFIAPI\r
ShellFindFirstFile (\r
IN EFI_FILE_HANDLE DirHandle,\r
- OUT EFI_FILE_INFO *Buffer\r
+ OUT EFI_FILE_INFO **Buffer\r
);\r
\r
/**\r
/**\r
Retrieve the size of a file.\r
\r
- This function extracts the file size info from the FileHandle\92s EFI_FILE_INFO \r
+ This function extracts the file size info from the FileHandle's EFI_FILE_INFO \r
data.\r
\r
@param FileHandle file handle from which size is retrieved\r
CONST CHAR16*\r
EFIAPI\r
ShellGetEnvironmentVariable (\r
- IN CHAR16 *EnvKey\r
+ IN CONST CHAR16 *EnvKey\r
);\r
\r
/**\r
/**\r
Retreives the current directory path\r
\r
- If the DeviceName is NULL, it returns the current device\92s current directory \r
+ If the DeviceName is NULL, it returns the current device's current directory \r
name. If the DeviceName is not NULL, it returns the current directory name \r
on specified drive.\r
\r
and will process '?' and '*' as such. the list must be freed with a call to \r
ShellCloseFileMetaArg().\r
\r
- This function will fail if called sequentially without freeing the list in the middle.\r
+ If you are NOT appending to an existing list *ListHead must be NULL. If \r
+ *ListHead is NULL then it must be callee freed.\r
\r
@param Arg pointer to path string\r
@param OpenMode mode to open files with\r
TypeFlag = 0,\r
TypeValue,\r
TypePosition,\r
+ TypeStart,\r
TypeMax,\r
} ParamType;\r
\r
ParamType Type;\r
} SHELL_PARAM_ITEM;\r
\r
+\r
+/// Helper structure for no parameters (besides -? and -b)\r
+extern SHELL_PARAM_ITEM EmptyParamList[];\r
+\r
/**\r
Checks the command line arguments passed against the list of valid ones. \r
Optionally removes NULL values first.\r
**/\r
EFI_STATUS\r
EFIAPI\r
-ShellCommandLineParse (\r
+ShellCommandLineParseEx (\r
IN CONST SHELL_PARAM_ITEM *CheckList,\r
OUT LIST_ENTRY **CheckPackage,\r
OUT CHAR16 **ProblemParam OPTIONAL,\r
- IN BOOLEAN AutoPageBreak\r
+ IN BOOLEAN AutoPageBreak,\r
+ IN BOOLEAN AlwaysAllowNumbers\r
);\r
\r
+// make it easy to upgrade from older versions of the shell library.\r
+#define ShellCommandLineParse(CheckList,CheckPackage,ProblemParam,AutoPageBreak) ShellCommandLineParseEx(CheckList,CheckPackage,ProblemParam,AutoPageBreak,FALSE)\r
+\r
/**\r
Frees shell variable list that was returned from ShellCommandLineParse.\r
\r
IN UINT32 Position\r
);\r
\r
-#endif // __SHELL_LIB__
\ No newline at end of file
+/**\r
+ returns the number of command line value parameters that were parsed. \r
+ \r
+ this will not include flags.\r
+\r
+ @retval (UINTN)-1 No parsing has ocurred\r
+ @return other The number of value parameters found\r
+**/\r
+UINTN\r
+EFIAPI\r
+ShellCommandLineGetCount(\r
+ VOID\r
+ );\r
+\r
+/**\r
+ This function causes the shell library to initialize itself. If the shell library\r
+ is already initialized it will de-initialize all the current protocol poitners and\r
+ re-populate them again.\r
+\r
+ When the library is used with PcdShellLibAutoInitialize set to true this function\r
+ will return EFI_SUCCESS and perform no actions.\r
+\r
+ This function is intended for internal access for shell commands only.\r
+\r
+ @retval EFI_SUCCESS the initialization was complete sucessfully\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellInitialize (\r
+ );\r
+\r
+/**\r
+ Print at a specific location on the screen.\r
+\r
+ This function will move the cursor to a given screen location, print the specified string, \r
+ and return the cursor to the original locaiton. \r
+ \r
+ If -1 is specified for either the Row or Col the current screen location for BOTH \r
+ will be used and the cursor's position will not be moved back to an original location.\r
+\r
+ if either Row or Col is out of range for the current console, then ASSERT\r
+ if Format is NULL, then ASSERT\r
+\r
+ In addition to the standard %-based flags as supported by UefiLib Print() this supports \r
+ the following additional flags:\r
+ %N - Set output attribute to normal\r
+ %H - Set output attribute to highlight\r
+ %E - Set output attribute to error\r
+ %B - Set output attribute to blue color\r
+ %V - Set output attribute to green color\r
+\r
+ Note: The background color is controlled by the shell command cls.\r
+\r
+ @param[in] Row the row to print at\r
+ @param[in] Col the column to print at\r
+ @param[in] Format the format string\r
+\r
+ @return the number of characters printed to the screen\r
+**/\r
+\r
+UINTN\r
+EFIAPI\r
+ShellPrintEx(\r
+ IN INT32 Col OPTIONAL,\r
+ IN INT32 Row OPTIONAL,\r
+ IN CONST CHAR16 *Format,\r
+ ...\r
+ );\r
+\r
+/**\r
+ Print at a specific location on the screen.\r
+\r
+ This function will move the cursor to a given screen location, print the specified string, \r
+ and return the cursor to the original locaiton. \r
+ \r
+ If -1 is specified for either the Row or Col the current screen location for BOTH \r
+ will be used and the cursor's position will not be moved back to an original location.\r
+\r
+ if either Row or Col is out of range for the current console, then ASSERT\r
+ if Format is NULL, then ASSERT\r
+\r
+ In addition to the standard %-based flags as supported by UefiLib Print() this supports \r
+ the following additional flags:\r
+ %N - Set output attribute to normal\r
+ %H - Set output attribute to highlight\r
+ %E - Set output attribute to error\r
+ %B - Set output attribute to blue color\r
+ %V - Set output attribute to green color\r
+\r
+ Note: The background color is controlled by the shell command cls.\r
+\r
+ @param[in] Row the row to print at\r
+ @param[in] Col the column to print at\r
+ @param[in] HiiFormatStringId the format string Id for getting from Hii\r
+ @param[in] HiiFormatHandle the format string Handle for getting from Hii\r
+\r
+ @return the number of characters printed to the screen\r
+**/\r
+UINTN\r
+EFIAPI\r
+ShellPrintHiiEx(\r
+ IN INT32 Col OPTIONAL,\r
+ IN INT32 Row OPTIONAL,\r
+ IN CONST EFI_STRING_ID HiiFormatStringId,\r
+ IN CONST EFI_HANDLE HiiFormatHandle,\r
+ ...\r
+ );\r
+\r
+/**\r
+ Function to determine if a given filename represents a file or a directory.\r
+\r
+ @param[in] DirName Path to directory to test.\r
+\r
+ @retval EFI_SUCCESS The Path represents a directory\r
+ @retval EFI_NOT_FOUND The Path does not represent a directory\r
+ @return other The path failed to open\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellIsDirectory(\r
+ IN CONST CHAR16 *DirName\r
+ );\r
+\r
+\r
+#endif // __SHELL_LIB__\r