* functions are non-interactive only\r
\r
Copyright (c) 2014 Hewlett-Packard Development Company, L.P.\r
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
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
ShellCommandRegisterCommandName(L"vol", ShellCommandRunVol , ShellCommandGetManFileNameLevel2, 2, L"", TRUE, gShellLevel2HiiHandle, STRING_TOKEN(STR_GET_HELP_VOL) );\r
\r
//\r
- // support for permenant (built in) aliases\r
+ // support for permanent (built in) aliases\r
//\r
ShellCommandRegisterAlias(L"rm", L"del");\r
ShellCommandRegisterAlias(L"ls", L"dir");\r
@retval other An allocated pointer to a fuly qualified path.\r
**/\r
CHAR16*\r
-EFIAPI\r
GetFullyQualifiedPath(\r
IN CONST CHAR16* Path\r
)\r
if (StrStr(Path, L":") == NULL) {\r
CurDir = gEfiShellProtocol->GetCurDir(NULL);\r
StrnCatGrow(&PathToReturn, &Size, CurDir, 0);\r
+ StrnCatGrow(&PathToReturn, &Size, L"\\", 0);\r
if (*Path == L'\\') {\r
Path++;\r
}\r
@retval EFI_SUCCESS The operation was successful.\r
**/\r
EFI_STATUS\r
-EFIAPI\r
VerifyIntermediateDirectories (\r
IN CONST CHAR16 *Path\r
)\r
return (Status);\r
}\r
\r
-/**\r
- Be lazy and borrow from baselib.\r
-\r
- @param[in] Char The character to convert to upper case.\r
-\r
- @return Char as an upper case character.\r
-**/\r
-CHAR16\r
-EFIAPI\r
-InternalCharToUpper (\r
- IN CONST CHAR16 Char\r
- );\r
-\r
/**\r
String comparison without regard to case for a limited number of characters.\r
\r
@param[in] Target The second item to compare.\r
@param[in] Count How many characters to compare.\r
\r
- @retval NULL Source and Target are identical strings without regard to case.\r
- @return The location in Source where there is a difference.\r
+ @retval 0 Source and Target are identical strings without regard to case.\r
+ @retval !=0 Source is not identical to Target.\r
+ \r
**/\r
-CONST CHAR16*\r
-EFIAPI\r
+INTN\r
StrniCmp(\r
IN CONST CHAR16 *Source,\r
IN CONST CHAR16 *Target,\r
IN CONST UINTN Count\r
)\r
{\r
- UINTN LoopCount;\r
- CHAR16 Char1;\r
- CHAR16 Char2;\r
-\r
- ASSERT(Source != NULL);\r
- ASSERT(Target != NULL);\r
-\r
- for (LoopCount = 0 ; LoopCount < Count ; LoopCount++) {\r
- Char1 = InternalCharToUpper(Source[LoopCount]);\r
- Char2 = InternalCharToUpper(Target[LoopCount]);\r
- if (Char1 != Char2) {\r
- return (&Source[LoopCount]);\r
+ CHAR16 *SourceCopy;\r
+ CHAR16 *TargetCopy;\r
+ UINTN SourceLength;\r
+ UINTN TargetLength;\r
+ INTN Result;\r
+\r
+ if (Count == 0) {\r
+ return 0;\r
+ }\r
+\r
+ SourceLength = StrLen (Source);\r
+ TargetLength = StrLen (Target);\r
+ SourceLength = MIN (SourceLength, Count);\r
+ TargetLength = MIN (TargetLength, Count);\r
+ SourceCopy = AllocateCopyPool ((SourceLength + 1) * sizeof (CHAR16), Source);\r
+ if (SourceCopy == NULL) {\r
+ return -1;\r
+ }\r
+ TargetCopy = AllocateCopyPool ((TargetLength + 1) * sizeof (CHAR16), Target);\r
+ if (TargetCopy == NULL) {\r
+ FreePool (SourceCopy);\r
+ return -1;\r
+ }\r
+ \r
+ SourceCopy[SourceLength] = L'\0';\r
+ TargetCopy[TargetLength] = L'\0';\r
+ Result = gUnicodeCollation->StriColl (gUnicodeCollation, SourceCopy, TargetCopy);\r
+ FreePool (SourceCopy);\r
+ FreePool (TargetCopy);\r
+ return Result;\r
+}\r
+\r
+\r
+/**\r
+ Cleans off all the quotes in the string.\r
+\r
+ @param[in] OriginalString pointer to the string to be cleaned.\r
+ @param[out] CleanString The new string with all quotes removed. \r
+ Memory allocated in the function and free \r
+ by caller.\r
+\r
+ @retval EFI_SUCCESS The operation was successful.\r
+**/\r
+EFI_STATUS\r
+ShellLevel2StripQuotes (\r
+ IN CONST CHAR16 *OriginalString,\r
+ OUT CHAR16 **CleanString\r
+ )\r
+{\r
+ CHAR16 *Walker;\r
+ \r
+ if (OriginalString == NULL || CleanString == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ *CleanString = AllocateCopyPool (StrSize (OriginalString), OriginalString);\r
+ if (*CleanString == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ for (Walker = *CleanString; Walker != NULL && *Walker != CHAR_NULL ; Walker++) {\r
+ if (*Walker == L'\"') {\r
+ CopyMem(Walker, Walker+1, StrSize(Walker) - sizeof(Walker[0]));\r
}\r
}\r
- return (NULL);\r
+\r
+ return EFI_SUCCESS;\r
}\r
\r
+\r