build break fix and new function

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9461 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jcarsey
2009-11-20 21:13:41 +00:00
parent a31bd33cf8
commit 36a9d67261
4 changed files with 134 additions and 29 deletions

View File

@@ -718,8 +718,8 @@ ShellCommandLineGetFlag (
If CheckPackage is NULL, then return NULL. If CheckPackage is NULL, then return NULL.
@param CheckPackage The package of parsed command line arguments. @param[in] CheckPackage The package of parsed command line arguments.
@param KeyString The Key of the command line argument to check for. @param[in] KeyString The Key of the command line argument to check for.
@retval NULL The flag is not on the command line. @retval NULL The flag is not on the command line.
@retval !=NULL Pointer to unicode string of the value. @retval !=NULL Pointer to unicode string of the value.
@@ -736,10 +736,10 @@ ShellCommandLineGetValue (
Raw value parameters are in the form of "value" in a specific position in the list. Raw value parameters are in the form of "value" in a specific position in the list.
If CheckPackage is NULL, then return NULL; If CheckPackage is NULL, then return NULL.
@param CheckPackage The package of parsed command line arguments. @param[in] CheckPackage The package of parsed command line arguments.
@param Position The position of the value. @param[in] Position The position of the value.
@retval NULL The flag is not on the command line. @retval NULL The flag is not on the command line.
@retval !=NULL Pointer to unicode string of the value. @retval !=NULL Pointer to unicode string of the value.
@@ -765,6 +765,27 @@ ShellCommandLineGetCount(
VOID VOID
); );
/**
Determins if a parameter is duplicated.
If Param is not NULL then it will point to a callee allocated string buffer
with the parameter value if a duplicate is found.
If CheckPackage is NULL, then ASSERT.
@param[in] CheckPackage The package of parsed command line arguments.
@param[out] Param Upon finding one, a pointer to the duplicated parameter.
@retval EFI_SUCCESS No parameters were duplicated.
@retval EFI_DEVICE_ERROR A duplicate was found.
**/
EFI_STATUS
EFIAPI
ShellCommandLineCheckDuplicate (
IN CONST LIST_ENTRY *CheckPackage,
OUT CHAR16 **Param
);
/** /**
This function causes the shell library to initialize itself. If the shell library This function causes the shell library to initialize itself. If the shell library
is already initialized it will de-initialize all the current protocol poitners and is already initialized it will de-initialize all the current protocol poitners and

View File

@@ -791,7 +791,7 @@ EFI_STATUS
If Alias is NULL, ReturnedData points to a <20>;<3B> If Alias is NULL, ReturnedData points to a <20>;<3B>
delimited list of alias (e.g. delimited list of alias (e.g.
ReturnedData = <20>dir;del;copy;mfp<66>) that is null-terminated. ReturnedData = <20>dir;del;copy;mfp<66>) that is null-terminated.
@retval NULL an error ocurred. @retval NULL An error ocurred.
@retval NULL Alias was not a valid Alias. @retval NULL Alias was not a valid Alias.
**/ **/
typedef typedef

View File

@@ -21,35 +21,35 @@
} }
typedef struct _EFI_SHELL_PARAMETERS_PROTOCOL { typedef struct _EFI_SHELL_PARAMETERS_PROTOCOL {
/// ///
/// Points to an Argc-element array of points to null-terminated strings containing /// Points to an Argc-element array of points to null-terminated strings containing
/// the command-line parameters. The first entry in the array is always the full file /// the command-line parameters. The first entry in the array is always the full file
/// path of the executable. Any quotation marks that were used to preserve /// path of the executable. Any quotation marks that were used to preserve
/// whitespace have been removed. /// whitespace have been removed.
/// ///
CHAR16 **Argv; CHAR16 **Argv;
/// ///
/// The number of elements in the Argv array. /// The number of elements in the Argv array.
/// ///
UINTN Argc; UINTN Argc;
/// ///
/// The file handle for the standard input for this executable. This may be different /// The file handle for the standard input for this executable. This may be different
/// from the ConInHandle in the EFI_SYSTEM_TABLE. /// from the ConInHandle in the EFI_SYSTEM_TABLE.
/// ///
EFI_FILE_HANDLE StdIn; EFI_FILE_HANDLE StdIn;
/// ///
/// The file handle for the standard output for this executable. This may be different /// The file handle for the standard output for this executable. This may be different
/// from the ConOutHandle in the EFI_SYSTEM_TABLE. /// from the ConOutHandle in the EFI_SYSTEM_TABLE.
/// ///
EFI_FILE_HANDLE StdOut; EFI_FILE_HANDLE StdOut;
/// ///
/// The file handle for the standard error output for this executable. This may be /// The file handle for the standard error output for this executable. This may be
/// different from the StdErrHandle in the EFI_SYSTEM_TABLE. /// different from the StdErrHandle in the EFI_SYSTEM_TABLE.
/// ///
EFI_FILE_HANDLE StdErr; EFI_FILE_HANDLE StdErr;
} EFI_SHELL_PARAMETERS_PROTOCOL; } EFI_SHELL_PARAMETERS_PROTOCOL;

View File

@@ -1489,12 +1489,15 @@ ShellFindFilePath (
CHAR16 *RetVal; CHAR16 *RetVal;
CHAR16 *TestPath; CHAR16 *TestPath;
CONST CHAR16 *Walker; CONST CHAR16 *Walker;
UINTN Size;
RetVal = NULL; RetVal = NULL;
Path = ShellGetEnvironmentVariable(L"cwd"); Path = ShellGetEnvironmentVariable(L"cwd");
if (Path != NULL) { if (Path != NULL) {
TestPath = AllocateZeroPool((StrSize(Path) + StrSize(FileName))); Size = StrSize(Path);
Size += StrSize(FileName);
TestPath = AllocateZeroPool(Size);
StrCpy(TestPath, Path); StrCpy(TestPath, Path);
StrCat(TestPath, FileName); StrCat(TestPath, FileName);
Status = ShellOpenFileByName(TestPath, &Handle, EFI_FILE_MODE_READ, 0); Status = ShellOpenFileByName(TestPath, &Handle, EFI_FILE_MODE_READ, 0);
@@ -1508,7 +1511,9 @@ ShellFindFilePath (
} }
Path = ShellGetEnvironmentVariable(L"path"); Path = ShellGetEnvironmentVariable(L"path");
if (Path != NULL) { if (Path != NULL) {
TestPath = AllocateZeroPool((StrSize(Path)+StrSize(FileName))); Size = StrSize(Path);
Size += StrSize(FileName);
TestPath = AllocateZeroPool(Size);
Walker = (CHAR16*)Path; Walker = (CHAR16*)Path;
do { do {
CopyMem(TestPath, Walker, StrSize(Walker)); CopyMem(TestPath, Walker, StrSize(Walker));
@@ -2129,6 +2134,52 @@ ShellCommandLineGetCount(
return (mTotalParameterCount); return (mTotalParameterCount);
} }
/**
Determins if a parameter is duplicated.
If Param is not NULL then it will point to a callee allocated string buffer
with the parameter value if a duplicate is found.
If CheckPackage is NULL, then ASSERT.
@param[in] CheckPackage The package of parsed command line arguments.
@param[out] Param Upon finding one, a pointer to the duplicated parameter.
@retval EFI_SUCCESS No parameters were duplicated.
@retval EFI_DEVICE_ERROR A duplicate was found.
**/
EFI_STATUS
EFIAPI
ShellCommandLineCheckDuplicate (
IN CONST LIST_ENTRY *CheckPackage,
OUT CHAR16 **Param
)
{
LIST_ENTRY *Node1;
LIST_ENTRY *Node2;
ASSERT(CheckPackage != NULL);
for ( Node1 = GetFirstNode(CheckPackage)
; !IsNull (CheckPackage, Node1)
; Node1 = GetNextNode(CheckPackage, Node1)
){
for ( Node2 = GetNextNode(CheckPackage, Node1)
; !IsNull (CheckPackage, Node2)
; Node2 = GetNextNode(CheckPackage, Node2)
){
if (StrCmp(((SHELL_PARAM_PACKAGE*)Node1)->Name, ((SHELL_PARAM_PACKAGE*)Node2)->Name) == 0) {
if (Param != NULL) {
*Param = NULL;
*Param = StrnCatGrow(Param, NULL, ((SHELL_PARAM_PACKAGE*)Node1)->Name, 0);
}
return (EFI_DEVICE_ERROR);
}
}
}
return (EFI_SUCCESS);
}
/** /**
This is a find and replace function. it will return the NewString as a copy of This is a find and replace function. it will return the NewString as a copy of
SourceString with each instance of FindTarget replaced with ReplaceWith. SourceString with each instance of FindTarget replaced with ReplaceWith.
@@ -2459,6 +2510,39 @@ ShellIsDirectory(
return (EFI_NOT_FOUND); return (EFI_NOT_FOUND);
} }
/**
Function to determine if a given filename represents a file.
@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
ShellIsFile(
IN CONST CHAR16 *Name
)
{
EFI_STATUS Status;
EFI_FILE_HANDLE Handle;
Handle = NULL;
Status = ShellOpenFileByName(Name, &Handle, EFI_FILE_MODE_READ, 0);
if (EFI_ERROR(Status)) {
return (Status);
}
if (FileHandleIsDirectory(Handle) != EFI_SUCCESS) {
ShellCloseFile(&Handle);
return (EFI_SUCCESS);
}
ShellCloseFile(&Handle);
return (EFI_NOT_FOUND);
}
/** /**
Function to determine whether a string is decimal or hex representation of a number Function to determine whether a string is decimal or hex representation of a number
and return the number converted from the string. and return the number converted from the string.