mEfiShellInterface = NULL;\r
}\r
}\r
+\r
//\r
// only success getting 2 of either the old or new, but no 1/2 and 1/2\r
//\r
IN EFI_SYSTEM_TABLE *SystemTable\r
) {\r
\r
-\r
mEfiShellEnvironment2 = NULL;\r
mEfiShellProtocol = NULL;\r
mEfiShellParametersProtocol = NULL;\r
// allocate a new EFI_SHELL_FILE_INFO object\r
//\r
NewInfo = AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO));\r
+ ASSERT(NewInfo != NULL);\r
+ if (NewInfo == NULL) {\r
+ break;\r
+ }\r
\r
//\r
// copy the simple items\r
Size = StrSize(Path);\r
Size += StrSize(FileName);\r
TestPath = AllocateZeroPool(Size);\r
+ ASSERT(TestPath != NULL);\r
+ if (TestPath == NULL) {\r
+ return (NULL);\r
+ }\r
StrCpy(TestPath, Path);\r
StrCat(TestPath, FileName);\r
Status = ShellOpenFileByName(TestPath, &Handle, EFI_FILE_MODE_READ, 0);\r
CONST CHAR16 *ExtensionWalker;\r
UINTN Size;\r
CHAR16 *TempChar;\r
+ CHAR16 *TempChar2;\r
\r
ASSERT(FileName != NULL);\r
if (FileExtension == NULL) {\r
Size = StrSize(FileName);\r
Size += StrSize(FileExtension);\r
TestPath = AllocateZeroPool(Size);\r
- for (ExtensionWalker = FileExtension ; ; ExtensionWalker = StrStr(ExtensionWalker, L";") + 1 ){\r
+ ASSERT(TestPath != NULL);\r
+ if (TestPath == NULL) {\r
+ return (NULL);\r
+ }\r
+ for (ExtensionWalker = FileExtension, TempChar2 = (CHAR16*)FileExtension; TempChar2 != NULL ; ExtensionWalker = TempChar2 + 1 ){\r
StrCpy(TestPath, FileName);\r
if (ExtensionWalker != NULL) {\r
StrCat(TestPath, ExtensionWalker);\r
if (RetVal != NULL) {\r
break;\r
}\r
- //\r
- // Must be after first loop...\r
- //\r
- if (StrStr(ExtensionWalker, L";") == NULL) {\r
- break;\r
- }\r
+ TempChar2 = StrStr(ExtensionWalker, L";");\r
}\r
FreePool(TestPath);\r
return (RetVal);\r
NewSize += 2 * Count * sizeof(CHAR16);\r
}\r
*Destination = ReallocatePool(*CurrentSize, NewSize, *Destination);\r
+ ASSERT(*Destination != NULL);\r
*CurrentSize = NewSize;\r
} else {\r
*Destination = AllocateZeroPool((Count+1)*sizeof(CHAR16));\r
+ ASSERT(*Destination != NULL);\r
}\r
\r
//\r
// Now use standard StrnCat on a big enough buffer\r
//\r
+ if (*Destination == NULL) {\r
+ return (NULL);\r
+ }\r
return StrnCat(*Destination, Source, Count);\r
}\r
+\r
+/**\r
+ Prompt the user and return the resultant answer to the requestor.\r
+\r
+ This function will display the requested question on the shell prompt and then\r
+ wait for an apropriate answer to be input from the console.\r
+\r
+ if the SHELL_PROMPT_REQUEST_TYPE is SHELL_PROMPT_REQUEST_TYPE_YESNO, SHELL_PROMPT_REQUEST_TYPE_QUIT_CONTINUE\r
+ or SHELL_PROMPT_REQUEST_TYPE_YESNOCANCEL then *Response is of type SHELL_PROMPT_RESPONSE.\r
+\r
+ if the SHELL_PROMPT_REQUEST_TYPE is SHELL_PROMPT_REQUEST_TYPE_FREEFORM then *Response is of type\r
+ CHAR16*.\r
+\r
+ In either case *Response must be callee freed if Response was not NULL;\r
+\r
+ @param Type What type of question is asked. This is used to filter the input\r
+ to prevent invalid answers to question.\r
+ @param Prompt Pointer to string prompt to use to request input.\r
+ @param Response Pointer to Response which will be populated upon return.\r
+\r
+ @retval EFI_SUCCESS The operation was sucessful.\r
+ @retval EFI_UNSUPPORTED The operation is not supported as requested.\r
+ @retval EFI_INVALID_PARAMETER A parameter was invalid.\r
+ @return other The operation failed.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellPromptForResponse (\r
+ IN SHELL_PROMPT_REQUEST_TYPE Type,\r
+ IN CHAR16 *Prompt OPTIONAL,\r
+ IN OUT VOID **Response OPTIONAL\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_INPUT_KEY Key;\r
+ UINTN EventIndex;\r
+ SHELL_PROMPT_RESPONSE *Resp;\r
+\r
+ Status = EFI_SUCCESS;\r
+ Resp = (SHELL_PROMPT_RESPONSE*)AllocatePool(sizeof(SHELL_PROMPT_RESPONSE));\r
+\r
+ switch(Type) {\r
+ case SHELL_PROMPT_REQUEST_TYPE_QUIT_CONTINUE:\r
+ if (Prompt != NULL) {\r
+ ShellPrintEx(-1, -1, L"%s", Prompt);\r
+ }\r
+ //\r
+ // wait for valid response\r
+ //\r
+ gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);\r
+ Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
+ ASSERT_EFI_ERROR(Status);\r
+ ShellPrintEx(-1, -1, L"%c", Key.UnicodeChar);\r
+ if (Key.UnicodeChar == L'Q' || Key.UnicodeChar ==L'q') {\r
+ *Resp = SHELL_PROMPT_RESPONSE_QUIT;\r
+ } else {\r
+ *Resp = SHELL_PROMPT_RESPONSE_CONTINUE;\r
+ }\r
+ break;\r
+ case SHELL_PROMPT_REQUEST_TYPE_YES_NO_ALL_CANCEL:\r
+ if (Prompt != NULL) {\r
+ ShellPrintEx(-1, -1, L"%s", Prompt);\r
+ }\r
+ //\r
+ // wait for valid response\r
+ //\r
+ *Resp = SHELL_PROMPT_RESPONSE_MAX;\r
+ while (*Resp == SHELL_PROMPT_RESPONSE_MAX) {\r
+ gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);\r
+ Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
+ ASSERT_EFI_ERROR(Status);\r
+ ShellPrintEx(-1, -1, L"%c", Key.UnicodeChar);\r
+ switch (Key.UnicodeChar) {\r
+ case L'Y':\r
+ case L'y':\r
+ *Resp = SHELL_PROMPT_RESPONSE_YES;\r
+ break;\r
+ case L'N':\r
+ case L'n':\r
+ *Resp = SHELL_PROMPT_RESPONSE_NO;\r
+ break;\r
+ case L'A':\r
+ case L'a':\r
+ *Resp = SHELL_PROMPT_RESPONSE_ALL;\r
+ break;\r
+ case L'C':\r
+ case L'c':\r
+ *Resp = SHELL_PROMPT_RESPONSE_CANCEL;\r
+ break;\r
+ }\r
+ }\r
+ break;\r
+ case SHELL_PROMPT_REQUEST_TYPE_ENTER_TO_COMTINUE:\r
+ case SHELL_PROMPT_REQUEST_TYPE_ANYKEY_TO_COMTINUE:\r
+ if (Prompt != NULL) {\r
+ ShellPrintEx(-1, -1, L"%s", Prompt);\r
+ }\r
+ //\r
+ // wait for valid response\r
+ //\r
+ *Resp = SHELL_PROMPT_RESPONSE_MAX;\r
+ while (*Resp == SHELL_PROMPT_RESPONSE_MAX) {\r
+ gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);\r
+ if (Type == SHELL_PROMPT_REQUEST_TYPE_ENTER_TO_COMTINUE) {\r
+ Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
+ ASSERT_EFI_ERROR(Status);\r
+ ShellPrintEx(-1, -1, L"%c", Key.UnicodeChar);\r
+ if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {\r
+ *Resp = SHELL_PROMPT_RESPONSE_CONTINUE;\r
+ break;\r
+ }\r
+ }\r
+ if (Type == SHELL_PROMPT_REQUEST_TYPE_ANYKEY_TO_COMTINUE) {\r
+ *Resp = SHELL_PROMPT_RESPONSE_CONTINUE;\r
+ break;\r
+ }\r
+ }\r
+ break;\r
+ ///@todo add more request types here!\r
+ default:\r
+ Status = EFI_UNSUPPORTED;\r
+ }\r
+\r
+ if (Response != NULL) {\r
+ *Response = Resp;\r
+ } else {\r
+ FreePool(Resp);\r
+ }\r
+\r
+ return (Status);\r
+}\r
+\r
+/**\r
+ Prompt the user and return the resultant answer to the requestor.\r
+\r
+ This function is the same as ShellPromptForResponse, except that the prompt is\r
+ automatically pulled from HII.\r
+\r
+ @param Type What type of question is asked. This is used to filter the input\r
+ to prevent invalid answers to question.\r
+ @param Prompt Pointer to string prompt to use to request input.\r
+ @param Response Pointer to Response which will be populated upon return.\r
+\r
+ @retval EFI_SUCCESS the operation was sucessful.\r
+ @return other the operation failed.\r
+\r
+ @sa ShellPromptForResponse\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellPromptForResponseHii (\r
+ IN SHELL_PROMPT_REQUEST_TYPE Type,\r
+ IN CONST EFI_STRING_ID HiiFormatStringId,\r
+ IN CONST EFI_HANDLE HiiFormatHandle,\r
+ IN OUT VOID **Response\r
+ )\r
+{\r
+ CHAR16 *Prompt;\r
+ EFI_STATUS Status;\r
+\r
+ Prompt = HiiGetString(HiiFormatHandle, HiiFormatStringId, NULL);\r
+ Status = ShellPromptForResponse(Type, Prompt, Response);\r
+ FreePool(Prompt);\r
+ return (Status);\r
+}\r
+\r
+\r