diff options
Diffstat (limited to 'ShellPkg/Library')
-rw-r--r-- | ShellPkg/Library/BaseFileHandleLib/BaseFileHandleLib.c | 190 | ||||
-rw-r--r-- | ShellPkg/Library/BaseFileHandleLib/BaseFileHandleLib.inf | 2 | ||||
-rw-r--r-- | ShellPkg/Library/BaseSortLib/BaseSortLib.c | 8 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c | 1 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellLib/UefiShellLib.c | 160 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellLib/UefiShellLib.h | 38 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellLib/UefiShellLib.inf | 2 | ||||
-rw-r--r-- | ShellPkg/Library/UefiSortLib/UefiSortLib.c | 8 |
8 files changed, 336 insertions, 73 deletions
diff --git a/ShellPkg/Library/BaseFileHandleLib/BaseFileHandleLib.c b/ShellPkg/Library/BaseFileHandleLib/BaseFileHandleLib.c index ed068243d6..4b2ffb9d95 100644 --- a/ShellPkg/Library/BaseFileHandleLib/BaseFileHandleLib.c +++ b/ShellPkg/Library/BaseFileHandleLib/BaseFileHandleLib.c @@ -22,6 +22,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <Library/MemoryAllocationLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
+#include <Library/FileHandleLib.h>
+#include <Library/PcdLib.h>
+#include <Library/PrintLib.h>
#define MAX_FILE_NAME_LEN 522 // (20 * (6+5+2))+1) unicode characters from EFI FAT spec (doubled for bytes)
#define FIND_XXXXX_FILE_BUFFER_SIZE (SIZE_OF_EFI_FILE_INFO + MAX_FILE_NAME_LEN)
@@ -801,19 +804,63 @@ FileHandleGetFileName ( }
/**
+ Function to read a single line from a file. The \n is not included in the returned
+ buffer. The returned buffer must be callee freed.
+
+ If the position upon start is 0, then the Ascii Boolean will be set. This should be
+ maintained and not changed for all operations with the same file.
+
+ @param[in] Handle FileHandle to read from.
+ @param[in,out] Ascii Boolean value for indicating whether the file is Ascii (TRUE) or UCS2 (FALSE);
+
+ @return The line of text from the file.
+
+ @sa FileHandleReadLine
+**/
+CHAR16*
+EFIAPI
+FileHandleReturnLine(
+ IN EFI_FILE_HANDLE Handle,
+ IN OUT BOOLEAN *Ascii
+ )
+{
+ CHAR16 *RetVal;
+ UINTN Size;
+ EFI_STATUS Status;
+
+ Size = 0;
+ RetVal = NULL;
+
+ Status = FileHandleReadLine(Handle, RetVal, &Size, FALSE, Ascii);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ RetVal = AllocatePool(Size);
+ Status = FileHandleReadLine(Handle, RetVal, &Size, FALSE, Ascii);
+ }
+ ASSERT_EFI_ERROR(Status);
+ if (EFI_ERROR(Status) && (RetVal != NULL)) {
+ FreePool(RetVal);
+ RetVal = NULL;
+ }
+ return (RetVal);
+}
+
+/**
Function to read a single line (up to but not including the \n) from a file.
+ If the position upon start is 0, then the Ascii Boolean will be set. This should be
+ maintained and not changed for all operations with the same file.
+
@param[in] Handle FileHandle to read from
@param[in,out] Buffer pointer to buffer to read into
@param[in,out] Size pointer to number of bytes in buffer
- @param[in[ Truncate if TRUE then allows for truncation of the line to fit.
+ @param[in] Truncate if TRUE then allows for truncation of the line to fit.
if FALSE will reset the position to the begining of the
line if the buffer is not large enough.
+ @param[in,out] Ascii Boolean value for indicating whether the file is Ascii (TRUE) or UCS2 (FALSE);
@retval EFI_SUCCESS the operation was sucessful. the line is stored in
Buffer.
@retval EFI_INVALID_PARAMETER Handle was NULL.
- @retval EFI_INVALID_PARAMETER Buffer was NULL.
@retval EFI_INVALID_PARAMETER Size was NULL.
@retval EFI_BUFFER_TOO_SMALL Size was not enough space to store the line.
Size was updated to minimum space required.
@@ -823,31 +870,54 @@ EFI_STATUS EFIAPI
FileHandleReadLine(
IN EFI_FILE_HANDLE Handle,
- IN OUT VOID *Buffer,
+ IN OUT CHAR16 *Buffer,
IN OUT UINTN *Size,
- IN BOOLEAN Truncate
+ IN BOOLEAN Truncate,
+ IN OUT BOOLEAN *Ascii
){
EFI_STATUS Status;
CHAR16 CharBuffer;
UINTN CharSize;
UINTN CountSoFar;
- UINT64 Position;
+ UINT64 OriginalFilePosition;
if (Handle == NULL
- ||Buffer == NULL
||Size == NULL
){
return (EFI_INVALID_PARAMETER);
}
- FileHandleGetPosition(Handle, &Position);
+ FileHandleGetPosition(Handle, &OriginalFilePosition);
+ if (OriginalFilePosition == 0) {
+ CharSize = sizeof(CHAR16);
+ Status = FileHandleRead(Handle, &CharSize, &CharBuffer);
+ ASSERT_EFI_ERROR(Status);
+ if (CharBuffer == UnicodeFileTag) {
+ *Ascii = FALSE;
+ } else {
+ *Ascii = TRUE;
+ FileHandleSetPosition(Handle, OriginalFilePosition);
+ }
+ }
for (CountSoFar = 0;;CountSoFar++){
- CharSize = sizeof(CharBuffer);
+ CharBuffer = 0;
+ if (*Ascii) {
+ CharSize = sizeof(CHAR8);
+ } else {
+ CharSize = sizeof(CHAR16);
+ }
Status = FileHandleRead(Handle, &CharSize, &CharBuffer);
+ if (OriginalFilePosition == 0 && *Ascii == FALSE && CountSoFar == 0) {
+ //
+ // we need to skip the unicode tag
+ //
+ continue;
+ }
if ( EFI_ERROR(Status)
|| CharSize == 0
- || CharBuffer == '\n'
+ || (CharBuffer == L'\n' && *Ascii == FALSE)
+ || (CharBuffer == '\n' && *Ascii != FALSE )
){
break;
}
@@ -855,6 +925,7 @@ FileHandleReadLine( // if we have space save it...
//
if ((CountSoFar+1)*sizeof(CHAR16) < *Size){
+ ASSERT(Buffer != NULL);
((CHAR16*)Buffer)[CountSoFar] = CharBuffer;
((CHAR16*)Buffer)[CountSoFar+1] = CHAR_NULL;
}
@@ -866,13 +937,16 @@ FileHandleReadLine( if ((CountSoFar+1)*sizeof(CHAR16) > *Size){
*Size = (CountSoFar+1)*sizeof(CHAR16);
if (Truncate == FALSE) {
- FileHandleSetPosition(Handle, Position);
+ FileHandleSetPosition(Handle, OriginalFilePosition);
} else {
- DEBUG((DEBUG_WARN, "The line was truncated in ReadLine"));
+ DEBUG((DEBUG_WARN, "The line was truncated in FileHandleReadLine"));
}
return (EFI_BUFFER_TOO_SMALL);
}
- *Size = (CountSoFar+1)*sizeof(CHAR16);
+ while(Buffer[StrLen(Buffer)-1] == L'\r') {
+ Buffer[StrLen(Buffer)-1] = CHAR_NULL;
+ }
+
return (Status);
}
@@ -913,3 +987,95 @@ FileHandleWriteLine( Size = StrLen(L"\r\n");
return FileHandleWrite(Handle, &Size, L"\r\n");
}
+
+/**
+ function to take a formatted argument and print it to a file.
+
+ @param[in] Handle the file handle for the file to write to
+ @param[in] Format the format argument (see printlib for format specifier)
+ @param[in] ... the variable arguments for the format
+
+ @retval EFI_SUCCESS the operation was sucessful
+ @return other a return value from FileHandleWriteLine
+
+ @sa FileHandleWriteLine
+**/
+EFI_STATUS
+EFIAPI
+FileHandlePrintLine(
+ IN EFI_FILE_HANDLE Handle,
+ IN CONST CHAR16 *Format,
+ ...
+ )
+{
+ VA_LIST Marker;
+ CHAR16 *Buffer;
+ EFI_STATUS Status;
+
+ VA_START (Marker, Format);
+
+ //
+ // Get a buffer to print into
+ //
+ Buffer = AllocateZeroPool (PcdGet16 (PcdShellPrintBufferSize));
+ ASSERT (Buffer != NULL);
+
+ //
+ // Print into our buffer
+ //
+ UnicodeVSPrint (Buffer, PcdGet16 (PcdShellPrintBufferSize), Format, Marker);
+
+ //
+ // Print buffer into file
+ //
+ Status = FileHandleWriteLine(Handle, Buffer);
+
+ //
+ // Cleanup and return
+ //
+ FreePool(Buffer);
+ return (Status);
+}
+
+/**
+ Function to determine if a FILE_HANDLE is at the end of the file.
+
+ This will NOT work on directories.
+
+ If Handle is NULL, then ASSERT.
+
+ @param[in] Handle the file handle
+
+ @retval TRUE the position is at the end of the file
+ @retval FALSE the position is not at the end of the file
+**/
+BOOLEAN
+EFIAPI
+FileHandleEof(
+ IN EFI_FILE_HANDLE Handle
+ )
+{
+ EFI_FILE_INFO *Info;
+ UINT64 Pos;
+ BOOLEAN RetVal;
+
+ //
+ // ASSERT if Handle is NULL
+ //
+ ASSERT(Handle != NULL);
+
+ FileHandleGetPosition(Handle, &Pos);
+ Info = FileHandleGetInfo (Handle);
+ ASSERT(Info != NULL);
+ FileHandleSetPosition(Handle, Pos);
+
+ if (Info == NULL) {
+ return (FALSE);
+ }
+
+ RetVal = (Pos == Info->FileSize)?TRUE:FALSE;
+
+ FreePool (Info);
+
+ return (RetVal);
+}
\ No newline at end of file diff --git a/ShellPkg/Library/BaseFileHandleLib/BaseFileHandleLib.inf b/ShellPkg/Library/BaseFileHandleLib/BaseFileHandleLib.inf index 3d2583d1c0..141b55d39c 100644 --- a/ShellPkg/Library/BaseFileHandleLib/BaseFileHandleLib.inf +++ b/ShellPkg/Library/BaseFileHandleLib/BaseFileHandleLib.inf @@ -47,4 +47,4 @@ gEfiFileInfoGuid # ALWAYS_CONSUMED
[Pcd.common]
- gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize # ALWAYS_CONSUMED
\ No newline at end of file + gEfiShellPkgTokenSpaceGuid.PcdShellPrintBufferSize # ALWAYS_CONSUMED
diff --git a/ShellPkg/Library/BaseSortLib/BaseSortLib.c b/ShellPkg/Library/BaseSortLib/BaseSortLib.c index 91b2a17e7a..a7b37a0f55 100644 --- a/ShellPkg/Library/BaseSortLib/BaseSortLib.c +++ b/ShellPkg/Library/BaseSortLib/BaseSortLib.c @@ -178,8 +178,8 @@ PerformQuickSort ( **/
INTN
DevicePathCompare (
- IN VOID *Buffer1,
- IN VOID *Buffer2
+ IN CONST VOID *Buffer1,
+ IN CONST VOID *Buffer2
)
{
ASSERT(FALSE);
@@ -199,8 +199,8 @@ DevicePathCompare ( INTN
EFIAPI
StringNoCaseCompare (
- IN VOID *Buffer1,
- IN VOID *Buffer2
+ IN CONST VOID *Buffer1,
+ IN CONST VOID *Buffer2
)
{
ASSERT(FALSE);
diff --git a/ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c b/ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c index eda4f3b55b..978edcf42c 100644 --- a/ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c +++ b/ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c @@ -15,6 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <Base.h>
#include <Protocol/SimpleFileSystem.h>
+#include <Protocol/LoadedImage.h>
#include <Protocol/EfiShellInterface.h>
#include <Protocol/EfiShellParameters.h>
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c index fb763bde61..e1aaa9db80 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -1,37 +1,17 @@ /** @file
Provides interface to shell functionality for shell commands and applications.
-Copyright (c) 2006 - 2009, Intel Corporation<BR>
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
+ Copyright (c) 2006 - 2010, Intel Corporation<BR>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
-#include <Uefi.h>
-#include <Library/ShellLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/PcdLib.h>
-#include <Library/FileHandleLib.h>
-#include <Library/PrintLib.h>
-#include <Library/UefiLib.h>
-#include <Library/HiiLib.h>
-
-#include <Protocol/EfiShellEnvironment2.h>
-#include <Protocol/EfiShellInterface.h>
-#include <Protocol/EfiShell.h>
-#include <Protocol/EfiShellParameters.h>
-#include <Protocol/SimpleFileSystem.h>
-
#include "UefiShellLib.h"
#define MAX_FILE_NAME_LEN 522 // (20 * (6+5+2))+1) unicode characters from EFI FAT spec (doubled for bytes)
@@ -56,6 +36,7 @@ STATIC FILE_HANDLE_FUNCTION_MAP FileFunctionMap; STATIC UINTN mTotalParameterCount;
STATIC CHAR16 *mPostReplaceFormat;
STATIC CHAR16 *mPostReplaceFormat2;
+
/**
Check if a Unicode character is a hexadecimal character.
@@ -72,7 +53,7 @@ STATIC CHAR16 *mPostReplaceFormat2; **/
BOOLEAN
EFIAPI
-ShellInternalIsHexaDecimalDigitCharacter (
+ShellLibIsHexaDecimalDigitCharacter (
IN CHAR16 Char
) {
return (BOOLEAN) ((Char >= L'0' && Char <= L'9') || (Char >= L'A' && Char <= L'F') || (Char >= L'a' && Char <= L'f'));
@@ -161,10 +142,10 @@ ShellLibConstructorWorker ( ) {
EFI_STATUS Status;
- ASSERT(PcdGet16 (PcdShellLibMaxPrintBufferSize) < PcdGet32 (PcdMaximumUnicodeStringLength));
- mPostReplaceFormat = AllocateZeroPool (PcdGet16 (PcdShellLibMaxPrintBufferSize));
+ ASSERT(PcdGet16 (PcdShellPrintBufferSize) < PcdGet32 (PcdMaximumUnicodeStringLength));
+ mPostReplaceFormat = AllocateZeroPool (PcdGet16 (PcdShellPrintBufferSize));
ASSERT (mPostReplaceFormat != NULL);
- mPostReplaceFormat2 = AllocateZeroPool (PcdGet16 (PcdShellLibMaxPrintBufferSize));
+ mPostReplaceFormat2 = AllocateZeroPool (PcdGet16 (PcdShellPrintBufferSize));
ASSERT (mPostReplaceFormat2 != NULL);
//
@@ -1487,9 +1468,9 @@ ShellCloseFileMetaArg ( /**
Find a file by searching the CWD and then the path.
- if FileName is NULL then ASSERT.
+ If FileName is NULL then ASSERT.
- if the return value is not NULL then the memory must be caller freed.
+ If the return value is not NULL then the memory must be caller freed.
@param FileName Filename string.
@@ -1557,6 +1538,62 @@ ShellFindFilePath ( return (RetVal);
}
+/**
+ Find a file by searching the CWD and then the path with a variable set of file
+ extensions. If the file is not found it will append each extension in the list
+ in the order provided and return the first one that is successful.
+
+ If FileName is NULL, then ASSERT.
+ If FileExtension is NULL, then behavior is identical to ShellFindFilePath.
+
+ If the return value is not NULL then the memory must be caller freed.
+
+ @param[in] FileName Filename string.
+ @param[in] FileExtension Semi-colon delimeted list of possible extensions.
+
+ @retval NULL The file was not found.
+ @retval !NULL The path to the file.
+**/
+CHAR16 *
+EFIAPI
+ShellFindFilePathEx (
+ IN CONST CHAR16 *FileName,
+ IN CONST CHAR16 *FileExtension
+ )
+{
+ CHAR16 *TestPath;
+ CHAR16 *RetVal;
+ CONST CHAR16 *ExtensionWalker;
+ ASSERT(FileName != NULL);
+ if (FileExtension == NULL) {
+ return (ShellFindFilePath(FileName));
+ }
+ RetVal = ShellFindFilePath(FileName);
+ if (RetVal != NULL) {
+ return (RetVal);
+ }
+ TestPath = AllocateZeroPool(StrSize(FileName) + StrSize(FileExtension));
+ for (ExtensionWalker = FileExtension ; ; ExtensionWalker = StrStr(ExtensionWalker, L";") + 1 ){
+ StrCpy(TestPath, FileName);
+ StrCat(TestPath, ExtensionWalker);
+ if (StrStr(TestPath, L";") != NULL) {
+ *(StrStr(TestPath, L";")) = CHAR_NULL;
+ }
+ RetVal = ShellFindFilePath(TestPath);
+ if (RetVal != NULL) {
+ break;
+ }
+ //
+ // Must be after first loop...
+ //
+ if (StrStr(ExtensionWalker, L";") == NULL) {
+ break;
+ }
+ }
+ FreePool(TestPath);
+ return (RetVal);
+}
+
typedef struct {
LIST_ENTRY Link;
CHAR16 *Name;
@@ -1647,7 +1684,7 @@ InternalIsFlag ( //
// If we accept numbers then dont return TRUE. (they will be values)
//
- if (((Name[0] == L'-' || Name[0] == L'+') && ShellInternalIsHexaDecimalDigitCharacter(Name[1])) && AlwaysAllowNumbers == TRUE) {
+ if (((Name[0] == L'-' || Name[0] == L'+') && ShellLibIsHexaDecimalDigitCharacter(Name[1])) && AlwaysAllowNumbers != FALSE) {
return (FALSE);
}
@@ -1738,7 +1775,7 @@ InternalCommandLineParse ( //
// do nothing for NULL argv
//
- } else if (InternalIsOnCheckList(Argv[LoopCounter], CheckList, &CurrentItemType) == TRUE) {
+ } else if (InternalIsOnCheckList(Argv[LoopCounter], CheckList, &CurrentItemType) != FALSE) {
//
// We might have leftover if last parameter didnt have optional value
//
@@ -2200,9 +2237,11 @@ ShellCommandLineCheckDuplicate ( }
/**
- This is a find and replace function. it will return the NewString as a copy of
+ This is a find and replace function. Upon successful return the NewString is a copy of
SourceString with each instance of FindTarget replaced with ReplaceWith.
+ If SourceString and NewString overlap the behavior is undefined.
+
If the string would grow bigger than NewSize it will halt and return error.
@param[in] SourceString String with source buffer
@@ -2224,7 +2263,7 @@ ShellCommandLineCheckDuplicate ( EFI_STATUS
EFIAPI
-CopyReplace(
+ShellLibCopySearchAndReplace(
IN CHAR16 CONST *SourceString,
IN CHAR16 *NewString,
IN UINTN NewSize,
@@ -2342,21 +2381,21 @@ InternalShellPrintWorker( //
// Back and forth each time fixing up 1 of our flags...
//
- Status = CopyReplace(Format, mPostReplaceFormat, PcdGet16 (PcdShellLibMaxPrintBufferSize), L"%N", L"%%N");
+ Status = ShellLibCopySearchAndReplace(Format, mPostReplaceFormat, PcdGet16 (PcdShellPrintBufferSize), L"%N", L"%%N");
ASSERT_EFI_ERROR(Status);
- Status = CopyReplace(mPostReplaceFormat, mPostReplaceFormat2, PcdGet16 (PcdShellLibMaxPrintBufferSize), L"%E", L"%%E");
+ Status = ShellLibCopySearchAndReplace(mPostReplaceFormat, mPostReplaceFormat2, PcdGet16 (PcdShellPrintBufferSize), L"%E", L"%%E");
ASSERT_EFI_ERROR(Status);
- Status = CopyReplace(mPostReplaceFormat2, mPostReplaceFormat, PcdGet16 (PcdShellLibMaxPrintBufferSize), L"%H", L"%%H");
+ Status = ShellLibCopySearchAndReplace(mPostReplaceFormat2, mPostReplaceFormat, PcdGet16 (PcdShellPrintBufferSize), L"%H", L"%%H");
ASSERT_EFI_ERROR(Status);
- Status = CopyReplace(mPostReplaceFormat, mPostReplaceFormat2, PcdGet16 (PcdShellLibMaxPrintBufferSize), L"%B", L"%%B");
+ Status = ShellLibCopySearchAndReplace(mPostReplaceFormat, mPostReplaceFormat2, PcdGet16 (PcdShellPrintBufferSize), L"%B", L"%%B");
ASSERT_EFI_ERROR(Status);
- Status = CopyReplace(mPostReplaceFormat2, mPostReplaceFormat, PcdGet16 (PcdShellLibMaxPrintBufferSize), L"%V", L"%%V");
+ Status = ShellLibCopySearchAndReplace(mPostReplaceFormat2, mPostReplaceFormat, PcdGet16 (PcdShellPrintBufferSize), L"%V", L"%%V");
ASSERT_EFI_ERROR(Status);
//
// Use the last buffer from replacing to print from...
//
- Return = UnicodeVSPrint (mPostReplaceFormat2, PcdGet16 (PcdShellLibMaxPrintBufferSize), mPostReplaceFormat, Marker);
+ Return = UnicodeVSPrint (mPostReplaceFormat2, PcdGet16 (PcdShellPrintBufferSize), mPostReplaceFormat, Marker);
if (Col != -1 && Row != -1) {
Status = gST->ConOut->SetCursorPosition(gST->ConOut, Col, Row);
@@ -2594,6 +2633,39 @@ ShellIsFile( }
/**
+ Function to determine if a given filename represents a file.
+
+ This will search the CWD and then the Path.
+
+ If Name is NULL, then ASSERT.
+
+ @param[in] Name Path to file to test.
+
+ @retval EFI_SUCCESS The Path represents a file.
+ @retval EFI_NOT_FOUND The Path does not represent a file.
+ @retval other The path failed to open.
+**/
+EFI_STATUS
+EFIAPI
+ShellIsFileInPath(
+ IN CONST CHAR16 *Name
+ ) {
+ CHAR16 *NewName;
+ EFI_STATUS Status;
+
+ if (!EFI_ERROR(ShellIsFile(Name))) {
+ return (TRUE);
+ }
+
+ NewName = ShellFindFilePath(Name);
+ if (NewName == NULL) {
+ return (EFI_NOT_FOUND);
+ }
+ Status = ShellIsFile(NewName);
+ FreePool(NewName);
+ return (Status);
+}
+/**
Function to determine whether a string is decimal or hex representation of a number
and return the number converted from the string.
@@ -2608,7 +2680,7 @@ ShellStrToUintn( )
{
CONST CHAR16 *Walker;
- for (Walker = String; Walker != NULL && *Walker != CHAR_NULL && *Walker == L' '; Walker = Walker + 1);
+ for (Walker = String; Walker != NULL && *Walker != CHAR_NULL && *Walker == L' '; Walker++);
if (StrnCmp(Walker, L"0x", 2) == 0 || StrnCmp(Walker, L"0X", 2) == 0){
return (StrHexToUintn(Walker));
}
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.h b/ShellPkg/Library/UefiShellLib/UefiShellLib.h index 6be4a0397b..fe886ae79e 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.h +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.h @@ -1,17 +1,41 @@ /** @file
Provides interface to shell functionality for shell commands and applications.
-Copyright (c) 2006 - 2009, Intel Corporation<BR>
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
+ Copyright (c) 2006 - 2010, Intel Corporation<BR>
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
+#include <Uefi.h>
+
+#include <Guid/FileInfo.h>
+
+#include <Protocol/SimpleFileSystem.h>
+#include <Protocol/LoadedImage.h>
+#include <Protocol/EfiShellInterface.h>
+#include <Protocol/EfiShellEnvironment2.h>
+#include <Protocol/EfiShell.h>
+#include <Protocol/EfiShellParameters.h>
+
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/PcdLib.h>
+#include <Library/FileHandleLib.h>
+#include <Library/PrintLib.h>
+#include <Library/UefiLib.h>
+#include <Library/HiiLib.h>
+#include <Library/ShellLib.h>
+
typedef struct {
EFI_SHELL_GET_FILE_INFO GetFileInfo;
EFI_SHELL_SET_FILE_INFO SetFileInfo;
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.inf b/ShellPkg/Library/UefiShellLib/UefiShellLib.inf index 28fe893033..b089ec61fc 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.inf +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.inf @@ -65,5 +65,5 @@ [Pcd.common]
gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize # ALWAYS_CONSUMED
- gEfiShellPkgTokenSpaceGuid.PcdShellLibMaxPrintBufferSize # ALWAYS_CONSUMED
+ gEfiShellPkgTokenSpaceGuid.PcdShellPrintBufferSize # ALWAYS_CONSUMED
gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength # ALWAYS_CONSUMED
\ No newline at end of file diff --git a/ShellPkg/Library/UefiSortLib/UefiSortLib.c b/ShellPkg/Library/UefiSortLib/UefiSortLib.c index 1df45fb5ae..2a65f36507 100644 --- a/ShellPkg/Library/UefiSortLib/UefiSortLib.c +++ b/ShellPkg/Library/UefiSortLib/UefiSortLib.c @@ -192,8 +192,8 @@ PerformQuickSort ( **/
INTN
DevicePathCompare (
- IN VOID *Buffer1,
- IN VOID *Buffer2
+ IN CONST VOID *Buffer1,
+ IN CONST VOID *Buffer2
)
{
EFI_DEVICE_PATH_PROTOCOL *DevicePath1;
@@ -270,8 +270,8 @@ DevicePathCompare ( INTN
EFIAPI
StringNoCaseCompare (
- IN VOID *Buffer1,
- IN VOID *Buffer2
+ IN CONST VOID *Buffer1,
+ IN CONST VOID *Buffer2
)
{
EFI_STATUS Status;
|