diff options
Diffstat (limited to 'ShellPkg/Application/Shell')
-rw-r--r-- | ShellPkg/Application/Shell/ConsoleLogger.c | 843 | ||||
-rw-r--r-- | ShellPkg/Application/Shell/ConsoleLogger.h | 99 | ||||
-rw-r--r-- | ShellPkg/Application/Shell/ConsoleWrappers.c | 234 | ||||
-rw-r--r-- | ShellPkg/Application/Shell/ConsoleWrappers.h | 19 | ||||
-rw-r--r-- | ShellPkg/Application/Shell/FileHandleInternal.h | 21 | ||||
-rw-r--r-- | ShellPkg/Application/Shell/FileHandleWrappers.c | 1276 | ||||
-rw-r--r-- | ShellPkg/Application/Shell/FileHandleWrappers.h | 33 | ||||
-rw-r--r-- | ShellPkg/Application/Shell/Shell.c | 2211 | ||||
-rw-r--r-- | ShellPkg/Application/Shell/Shell.h | 174 | ||||
-rw-r--r-- | ShellPkg/Application/Shell/ShellEnvVar.c | 357 | ||||
-rw-r--r-- | ShellPkg/Application/Shell/ShellEnvVar.h | 58 | ||||
-rw-r--r-- | ShellPkg/Application/Shell/ShellManParser.c | 487 | ||||
-rw-r--r-- | ShellPkg/Application/Shell/ShellManParser.h | 15 | ||||
-rw-r--r-- | ShellPkg/Application/Shell/ShellParametersProtocol.c | 1100 | ||||
-rw-r--r-- | ShellPkg/Application/Shell/ShellParametersProtocol.h | 31 | ||||
-rw-r--r-- | ShellPkg/Application/Shell/ShellProtocol.c | 2569 | ||||
-rw-r--r-- | ShellPkg/Application/Shell/ShellProtocol.h | 226 |
17 files changed, 5170 insertions, 4583 deletions
diff --git a/ShellPkg/Application/Shell/ConsoleLogger.c b/ShellPkg/Application/Shell/ConsoleLogger.c index 36ba3ac..abef0a6 100644 --- a/ShellPkg/Application/Shell/ConsoleLogger.c +++ b/ShellPkg/Application/Shell/ConsoleLogger.c @@ -23,15 +23,16 @@ @sa InstallProtocolInterface
**/
EFI_STATUS
-ConsoleLoggerInstall(
- IN CONST UINTN ScreensToSave,
- OUT CONSOLE_LOGGER_PRIVATE_DATA **ConsoleInfo
+ConsoleLoggerInstall (
+ IN CONST UINTN ScreensToSave,
+ OUT CONSOLE_LOGGER_PRIVATE_DATA **ConsoleInfo
)
{
- EFI_STATUS Status;
- ASSERT(ConsoleInfo != NULL);
+ EFI_STATUS Status;
- (*ConsoleInfo) = AllocateZeroPool(sizeof(CONSOLE_LOGGER_PRIVATE_DATA));
+ ASSERT (ConsoleInfo != NULL);
+
+ (*ConsoleInfo) = AllocateZeroPool (sizeof (CONSOLE_LOGGER_PRIVATE_DATA));
if ((*ConsoleInfo) == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
@@ -66,18 +67,18 @@ ConsoleLoggerInstall( (*ConsoleInfo)->OurConOut.Mode = gST->ConOut->Mode;
(*ConsoleInfo)->Enabled = TRUE;
- Status = ConsoleLoggerResetBuffers(*ConsoleInfo);
- if (EFI_ERROR(Status)) {
- SHELL_FREE_NON_NULL((*ConsoleInfo));
+ Status = ConsoleLoggerResetBuffers (*ConsoleInfo);
+ if (EFI_ERROR (Status)) {
+ SHELL_FREE_NON_NULL ((*ConsoleInfo));
*ConsoleInfo = NULL;
return (Status);
}
- Status = gBS->InstallProtocolInterface(&gImageHandle, &gEfiSimpleTextOutProtocolGuid, EFI_NATIVE_INTERFACE, (VOID*)&((*ConsoleInfo)->OurConOut));
- if (EFI_ERROR(Status)) {
- SHELL_FREE_NON_NULL((*ConsoleInfo)->Buffer);
- SHELL_FREE_NON_NULL((*ConsoleInfo)->Attributes);
- SHELL_FREE_NON_NULL((*ConsoleInfo));
+ Status = gBS->InstallProtocolInterface (&gImageHandle, &gEfiSimpleTextOutProtocolGuid, EFI_NATIVE_INTERFACE, (VOID *)&((*ConsoleInfo)->OurConOut));
+ if (EFI_ERROR (Status)) {
+ SHELL_FREE_NON_NULL ((*ConsoleInfo)->Buffer);
+ SHELL_FREE_NON_NULL ((*ConsoleInfo)->Attributes);
+ SHELL_FREE_NON_NULL ((*ConsoleInfo));
*ConsoleInfo = NULL;
return (Status);
}
@@ -90,10 +91,10 @@ ConsoleLoggerInstall( //
gST->Hdr.CRC32 = 0;
gBS->CalculateCrc32 (
- (UINT8 *)&gST->Hdr,
- gST->Hdr.HeaderSize,
- &gST->Hdr.CRC32
- );
+ (UINT8 *)&gST->Hdr,
+ gST->Hdr.HeaderSize,
+ &gST->Hdr.CRC32
+ );
return (Status);
}
@@ -107,38 +108,47 @@ ConsoleLoggerInstall( @return other The operation failed. This was from UninstallProtocolInterface.
**/
EFI_STATUS
-ConsoleLoggerUninstall(
- IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
+ConsoleLoggerUninstall (
+ IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
)
{
- ASSERT(ConsoleInfo != NULL);
- ASSERT(ConsoleInfo->OldConOut != NULL);
+ ASSERT (ConsoleInfo != NULL);
+ ASSERT (ConsoleInfo->OldConOut != NULL);
if (ConsoleInfo->Buffer != NULL) {
- FreePool(ConsoleInfo->Buffer);
- DEBUG_CODE(ConsoleInfo->Buffer = NULL;);
- DEBUG_CODE(ConsoleInfo->BufferSize = 0;);
+ FreePool (ConsoleInfo->Buffer);
+ DEBUG_CODE (
+ ConsoleInfo->Buffer = NULL;
+ );
+ DEBUG_CODE (
+ ConsoleInfo->BufferSize = 0;
+ );
}
+
if (ConsoleInfo->Attributes != NULL) {
- FreePool(ConsoleInfo->Attributes);
- DEBUG_CODE(ConsoleInfo->Attributes = NULL;);
- DEBUG_CODE(ConsoleInfo->AttribSize = 0;);
+ FreePool (ConsoleInfo->Attributes);
+ DEBUG_CODE (
+ ConsoleInfo->Attributes = NULL;
+ );
+ DEBUG_CODE (
+ ConsoleInfo->AttribSize = 0;
+ );
}
gST->ConsoleOutHandle = ConsoleInfo->OldConHandle;
- gST->ConOut = ConsoleInfo->OldConOut;
+ gST->ConOut = ConsoleInfo->OldConOut;
//
// Update the CRC32 in the EFI System Table header
//
gST->Hdr.CRC32 = 0;
gBS->CalculateCrc32 (
- (UINT8 *)&gST->Hdr,
- gST->Hdr.HeaderSize,
- &gST->Hdr.CRC32
- );
+ (UINT8 *)&gST->Hdr,
+ gST->Hdr.HeaderSize,
+ &gST->Hdr.CRC32
+ );
- return (gBS->UninstallProtocolInterface(gImageHandle, &gEfiSimpleTextOutProtocolGuid, (VOID*)&ConsoleInfo->OurConOut));
+ return (gBS->UninstallProtocolInterface (gImageHandle, &gEfiSimpleTextOutProtocolGuid, (VOID *)&ConsoleInfo->OurConOut));
}
/**
@@ -154,29 +164,29 @@ ConsoleLoggerUninstall( @param[in] ConsoleInfo The pointer to the instance of the console logger information.
**/
EFI_STATUS
-ConsoleLoggerDisplayHistory(
- IN CONST BOOLEAN Forward,
- IN CONST UINTN Rows,
- IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
+ConsoleLoggerDisplayHistory (
+ IN CONST BOOLEAN Forward,
+ IN CONST UINTN Rows,
+ IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
)
{
- UINTN RowChange;
+ UINTN RowChange;
- ASSERT(ConsoleInfo != NULL);
+ ASSERT (ConsoleInfo != NULL);
//
// Calculate the row number change
//
switch (Rows) {
- case ((UINTN)(-1)):
- RowChange = ConsoleInfo->RowsPerScreen;
- break;
- case (0):
- RowChange = ConsoleInfo->RowsPerScreen / 2;
- break;
- default:
- RowChange = Rows;
- break;
+ case ((UINTN)(-1)):
+ RowChange = ConsoleInfo->RowsPerScreen;
+ break;
+ case (0):
+ RowChange = ConsoleInfo->RowsPerScreen / 2;
+ break;
+ default:
+ RowChange = Rows;
+ break;
}
//
@@ -202,7 +212,7 @@ ConsoleLoggerDisplayHistory( //
// Clear the screen
//
- ConsoleInfo->OldConOut->ClearScreen(ConsoleInfo->OldConOut);
+ ConsoleInfo->OldConOut->ClearScreen (ConsoleInfo->OldConOut);
//
// Set the new start row
@@ -216,7 +226,7 @@ ConsoleLoggerDisplayHistory( //
// Change the screen
//
- return (UpdateDisplayFromHistory(ConsoleInfo));
+ return (UpdateDisplayFromHistory (ConsoleInfo));
}
/**
@@ -229,11 +239,11 @@ ConsoleLoggerDisplayHistory( @sa UpdateDisplayFromHistory
**/
EFI_STATUS
-ConsoleLoggerStopHistory(
- IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
+ConsoleLoggerStopHistory (
+ IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
)
{
- ASSERT(ConsoleInfo != NULL);
+ ASSERT (ConsoleInfo != NULL);
if (ConsoleInfo->CurrentStartRow == ConsoleInfo->OriginalStartRow) {
return (EFI_SUCCESS);
}
@@ -241,10 +251,10 @@ ConsoleLoggerStopHistory( //
// Clear the screen
//
- ConsoleInfo->OldConOut->ClearScreen(ConsoleInfo->OldConOut);
+ ConsoleInfo->OldConOut->ClearScreen (ConsoleInfo->OldConOut);
ConsoleInfo->CurrentStartRow = ConsoleInfo->OriginalStartRow;
- return (UpdateDisplayFromHistory(ConsoleInfo));
+ return (UpdateDisplayFromHistory (ConsoleInfo));
}
/**
@@ -255,55 +265,57 @@ ConsoleLoggerStopHistory( @return other The operation failed.
**/
EFI_STATUS
-UpdateDisplayFromHistory(
- IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
+UpdateDisplayFromHistory (
+ IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
)
{
- EFI_STATUS Status;
- EFI_STATUS RetVal;
- CHAR16 *Screen;
- INT32 *Attributes;
- UINTN CurrentRow;
- CHAR16 TempCharHolder;
- UINTN Column;
- INT32 CurrentAttrib;
- UINTN CurrentColumn;
- CHAR16 *StringSegment;
- CHAR16 *StringSegmentEnd;
- CHAR16 StringSegmentEndChar;
- INT32 OrigAttribute;
-
- ASSERT(ConsoleInfo != NULL);
+ EFI_STATUS Status;
+ EFI_STATUS RetVal;
+ CHAR16 *Screen;
+ INT32 *Attributes;
+ UINTN CurrentRow;
+ CHAR16 TempCharHolder;
+ UINTN Column;
+ INT32 CurrentAttrib;
+ UINTN CurrentColumn;
+ CHAR16 *StringSegment;
+ CHAR16 *StringSegmentEnd;
+ CHAR16 StringSegmentEndChar;
+ INT32 OrigAttribute;
+
+ ASSERT (ConsoleInfo != NULL);
TempCharHolder = CHAR_NULL;
- RetVal = EFI_SUCCESS;
- OrigAttribute = ConsoleInfo->OldConOut->Mode->Attribute;
+ RetVal = EFI_SUCCESS;
+ OrigAttribute = ConsoleInfo->OldConOut->Mode->Attribute;
//
// Disable cursor visibility and move it to the top left corner
//
- ConsoleInfo->OldConOut->EnableCursor (ConsoleInfo->OldConOut, FALSE);
- ConsoleInfo->OldConOut->SetCursorPosition (ConsoleInfo->OldConOut, 0, 0);
+ ConsoleInfo->OldConOut->EnableCursor (ConsoleInfo->OldConOut, FALSE);
+ ConsoleInfo->OldConOut->SetCursorPosition (ConsoleInfo->OldConOut, 0, 0);
- Screen = &ConsoleInfo->Buffer[(ConsoleInfo->ColsPerScreen + 2) * ConsoleInfo->CurrentStartRow];
+ Screen = &ConsoleInfo->Buffer[(ConsoleInfo->ColsPerScreen + 2) * ConsoleInfo->CurrentStartRow];
Attributes = &ConsoleInfo->Attributes[ConsoleInfo->ColsPerScreen * ConsoleInfo->CurrentStartRow];
for ( CurrentRow = 0
- ; CurrentRow < ConsoleInfo->RowsPerScreen
- ; CurrentRow++
- , Screen += (ConsoleInfo->ColsPerScreen + 2)
- , Attributes += ConsoleInfo->ColsPerScreen
- ){
+ ; CurrentRow < ConsoleInfo->RowsPerScreen
+ ; CurrentRow++,
+ Screen += (ConsoleInfo->ColsPerScreen + 2),
+ Attributes += ConsoleInfo->ColsPerScreen
+ )
+ {
//
// dont use the last char - prevents screen scroll
//
- if (CurrentRow == (ConsoleInfo->RowsPerScreen-1)){
- TempCharHolder = Screen[ConsoleInfo->ColsPerScreen - 1];
+ if (CurrentRow == (ConsoleInfo->RowsPerScreen-1)) {
+ TempCharHolder = Screen[ConsoleInfo->ColsPerScreen - 1];
Screen[ConsoleInfo->ColsPerScreen - 1] = CHAR_NULL;
}
for ( Column = 0
- ; Column < ConsoleInfo->ColsPerScreen
- ; Column++
- ){
+ ; Column < ConsoleInfo->ColsPerScreen
+ ; Column++
+ )
+ {
if (Screen[Column] != CHAR_NULL) {
CurrentAttrib = Attributes[Column];
CurrentColumn = Column;
@@ -316,10 +328,11 @@ UpdateDisplayFromHistory( //
StringSegmentEndChar = CHAR_NULL;
for ( StringSegmentEnd = StringSegment
- ; *StringSegmentEnd != CHAR_NULL
- ; StringSegmentEnd++
- , Column++
- ){
+ ; *StringSegmentEnd != CHAR_NULL
+ ; StringSegmentEnd++,
+ Column++
+ )
+ {
if (Attributes[Column] != CurrentAttrib) {
StringSegmentEndChar = *StringSegmentEnd;
*StringSegmentEnd = CHAR_NULL;
@@ -331,12 +344,12 @@ UpdateDisplayFromHistory( // Now write out as much as had the same Attributes
//
- ConsoleInfo->OldConOut->SetAttribute(ConsoleInfo->OldConOut, CurrentAttrib);
- ConsoleInfo->OldConOut->SetCursorPosition(ConsoleInfo->OldConOut, CurrentColumn, CurrentRow);
- Status = ConsoleInfo->OldConOut->OutputString(ConsoleInfo->OldConOut, StringSegment);
+ ConsoleInfo->OldConOut->SetAttribute (ConsoleInfo->OldConOut, CurrentAttrib);
+ ConsoleInfo->OldConOut->SetCursorPosition (ConsoleInfo->OldConOut, CurrentColumn, CurrentRow);
+ Status = ConsoleInfo->OldConOut->OutputString (ConsoleInfo->OldConOut, StringSegment);
- if (EFI_ERROR(Status)) {
- ASSERT(FALSE);
+ if (EFI_ERROR (Status)) {
+ ASSERT (FALSE);
RetVal = Status;
}
@@ -346,7 +359,7 @@ UpdateDisplayFromHistory( // a segment with that new attribute
//
if (StringSegmentEndChar != CHAR_NULL) {
- *StringSegmentEnd = StringSegmentEndChar;
+ *StringSegmentEnd = StringSegmentEndChar;
StringSegmentEndChar = CHAR_NULL;
Column--;
}
@@ -358,7 +371,7 @@ UpdateDisplayFromHistory( //
if (TempCharHolder != CHAR_NULL) {
Screen[ConsoleInfo->ColsPerScreen - 1] = TempCharHolder;
- TempCharHolder = CHAR_NULL;
+ TempCharHolder = CHAR_NULL;
}
} // row for loop
@@ -368,27 +381,27 @@ UpdateDisplayFromHistory( //
if (ConsoleInfo->CurrentStartRow == ConsoleInfo->OriginalStartRow) {
ConsoleInfo->OldConOut->SetAttribute (
- ConsoleInfo->OldConOut,
- ConsoleInfo->HistoryMode.Attribute
- );
+ ConsoleInfo->OldConOut,
+ ConsoleInfo->HistoryMode.Attribute
+ );
ConsoleInfo->OldConOut->SetCursorPosition (
- ConsoleInfo->OldConOut,
- ConsoleInfo->HistoryMode.CursorColumn,
- ConsoleInfo->HistoryMode.CursorRow - ConsoleInfo->OriginalStartRow
- );
+ ConsoleInfo->OldConOut,
+ ConsoleInfo->HistoryMode.CursorColumn,
+ ConsoleInfo->HistoryMode.CursorRow - ConsoleInfo->OriginalStartRow
+ );
Status = ConsoleInfo->OldConOut->EnableCursor (
- ConsoleInfo->OldConOut,
- ConsoleInfo->HistoryMode.CursorVisible
- );
+ ConsoleInfo->OldConOut,
+ ConsoleInfo->HistoryMode.CursorVisible
+ );
if (EFI_ERROR (Status)) {
RetVal = Status;
}
} else {
ConsoleInfo->OldConOut->SetAttribute (
- ConsoleInfo->OldConOut,
- OrigAttribute
- );
+ ConsoleInfo->OldConOut,
+ OrigAttribute
+ );
}
return (RetVal);
@@ -407,13 +420,14 @@ UpdateDisplayFromHistory( EFI_STATUS
EFIAPI
ConsoleLoggerReset (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
- EFI_STATUS Status;
- CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
- ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This);
+ EFI_STATUS Status;
+ CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
+
+ ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
//
// Forward the request to the original ConOut
@@ -424,10 +438,10 @@ ConsoleLoggerReset ( // Check that the buffers are still correct for logging
//
if (!EFI_ERROR (Status)) {
- ConsoleLoggerResetBuffers(ConsoleInfo);
+ ConsoleLoggerResetBuffers (ConsoleInfo);
if (ExtendedVerification) {
ConsoleInfo->OriginalStartRow = 0;
- ConsoleInfo->CurrentStartRow = 0;
+ ConsoleInfo->CurrentStartRow = 0;
}
}
@@ -443,9 +457,9 @@ ConsoleLoggerReset ( @param[in] ConsoleInfo The pointer to the instance of the console logger information.
**/
EFI_STATUS
-AppendStringToHistory(
- IN CONST CHAR16 *String,
- IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
+AppendStringToHistory (
+ IN CONST CHAR16 *String,
+ IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
)
{
CONST CHAR16 *Walker;
@@ -453,127 +467,135 @@ AppendStringToHistory( UINTN PrintIndex;
UINTN Index;
- ASSERT(ConsoleInfo != NULL);
+ ASSERT (ConsoleInfo != NULL);
for ( Walker = String
- ; Walker != NULL && *Walker != CHAR_NULL
- ; Walker++
- ){
+ ; Walker != NULL && *Walker != CHAR_NULL
+ ; Walker++
+ )
+ {
switch (*Walker) {
- case (CHAR_BACKSPACE):
- if (ConsoleInfo->HistoryMode.CursorColumn > 0) {
- ConsoleInfo->HistoryMode.CursorColumn--;
- }
- break;
- case (CHAR_LINEFEED):
- if (ConsoleInfo->HistoryMode.CursorRow >= (INT32)((ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount)-1)) {
- //
- // Should never be bigger
- //
- ASSERT(ConsoleInfo->HistoryMode.CursorRow == (INT32)((ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount)-1));
-
- //
- // scroll history attributes 'up' 1 row and set the last row to default attribute
- //
- CopySize = ConsoleInfo->ColsPerScreen
- * ((ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount) - 1)
- * sizeof(ConsoleInfo->Attributes[0]);
- ASSERT(CopySize < ConsoleInfo->AttribSize);
- CopyMem(
- ConsoleInfo->Attributes,
- ConsoleInfo->Attributes + ConsoleInfo->ColsPerScreen,
- CopySize
- );
-
- for ( Index = 0
- ; Index < ConsoleInfo->ColsPerScreen
- ; Index++
- ){
- *(ConsoleInfo->Attributes + (CopySize/sizeof(ConsoleInfo->Attributes[0])) + Index) = ConsoleInfo->HistoryMode.Attribute;
+ case (CHAR_BACKSPACE):
+ if (ConsoleInfo->HistoryMode.CursorColumn > 0) {
+ ConsoleInfo->HistoryMode.CursorColumn--;
}
- //
- // scroll history buffer 'up' 1 row and set the last row to spaces (L' ')
- //
- CopySize = (ConsoleInfo->ColsPerScreen + 2)
- * ((ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount) - 1)
- * sizeof(ConsoleInfo->Buffer[0]);
- ASSERT(CopySize < ConsoleInfo->BufferSize);
- CopyMem(
- ConsoleInfo->Buffer,
- ConsoleInfo->Buffer + (ConsoleInfo->ColsPerScreen + 2),
- CopySize
- );
+ break;
+ case (CHAR_LINEFEED):
+ if (ConsoleInfo->HistoryMode.CursorRow >= (INT32)((ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount)-1)) {
+ //
+ // Should never be bigger
+ //
+ ASSERT (ConsoleInfo->HistoryMode.CursorRow == (INT32)((ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount)-1));
+
+ //
+ // scroll history attributes 'up' 1 row and set the last row to default attribute
+ //
+ CopySize = ConsoleInfo->ColsPerScreen
+ * ((ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount) - 1)
+ * sizeof (ConsoleInfo->Attributes[0]);
+ ASSERT (CopySize < ConsoleInfo->AttribSize);
+ CopyMem (
+ ConsoleInfo->Attributes,
+ ConsoleInfo->Attributes + ConsoleInfo->ColsPerScreen,
+ CopySize
+ );
+
+ for ( Index = 0
+ ; Index < ConsoleInfo->ColsPerScreen
+ ; Index++
+ )
+ {
+ *(ConsoleInfo->Attributes + (CopySize/sizeof (ConsoleInfo->Attributes[0])) + Index) = ConsoleInfo->HistoryMode.Attribute;
+ }
- //
- // Set that last row of chars to spaces
- //
- SetMem16(((UINT8*)ConsoleInfo->Buffer)+CopySize, ConsoleInfo->ColsPerScreen*sizeof(CHAR16), L' ');
- } else {
- //
- // we are not on the last row
- //
+ //
+ // scroll history buffer 'up' 1 row and set the last row to spaces (L' ')
+ //
+ CopySize = (ConsoleInfo->ColsPerScreen + 2)
+ * ((ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount) - 1)
+ * sizeof (ConsoleInfo->Buffer[0]);
+ ASSERT (CopySize < ConsoleInfo->BufferSize);
+ CopyMem (
+ ConsoleInfo->Buffer,
+ ConsoleInfo->Buffer + (ConsoleInfo->ColsPerScreen + 2),
+ CopySize
+ );
+
+ //
+ // Set that last row of chars to spaces
+ //
+ SetMem16 (((UINT8 *)ConsoleInfo->Buffer)+CopySize, ConsoleInfo->ColsPerScreen*sizeof (CHAR16), L' ');
+ } else {
+ //
+ // we are not on the last row
+ //
+
+ //
+ // We should not be scrolling history
+ //
+ ASSERT (ConsoleInfo->OriginalStartRow == ConsoleInfo->CurrentStartRow);
+ //
+ // are we at the end of a row?
+ //
+ if (ConsoleInfo->HistoryMode.CursorRow == (INT32)(ConsoleInfo->OriginalStartRow + ConsoleInfo->RowsPerScreen - 1)) {
+ ConsoleInfo->OriginalStartRow++;
+ ConsoleInfo->CurrentStartRow++;
+ }
+
+ ConsoleInfo->HistoryMode.CursorRow++;
+ }
+ break;
+ case (CHAR_CARRIAGE_RETURN):
//
- // We should not be scrolling history
+ // Move the cursor to the beginning of the current row.
//
- ASSERT (ConsoleInfo->OriginalStartRow == ConsoleInfo->CurrentStartRow);
+ ConsoleInfo->HistoryMode.CursorColumn = 0;
+ break;
+ default:
//
- // are we at the end of a row?
+ // Acrtually print characters into the history buffer
//
- if (ConsoleInfo->HistoryMode.CursorRow == (INT32) (ConsoleInfo->OriginalStartRow + ConsoleInfo->RowsPerScreen - 1)) {
- ConsoleInfo->OriginalStartRow++;
- ConsoleInfo->CurrentStartRow++;
- }
- ConsoleInfo->HistoryMode.CursorRow++;
- }
- break;
- case (CHAR_CARRIAGE_RETURN):
- //
- // Move the cursor to the beginning of the current row.
- //
- ConsoleInfo->HistoryMode.CursorColumn = 0;
- break;
- default:
- //
- // Acrtually print characters into the history buffer
- //
- PrintIndex = ConsoleInfo->HistoryMode.CursorRow * ConsoleInfo->ColsPerScreen + ConsoleInfo->HistoryMode.CursorColumn;
-
- for ( // no initializer needed
- ; ConsoleInfo->HistoryMode.CursorColumn < (INT32) ConsoleInfo->ColsPerScreen
- ; ConsoleInfo->HistoryMode.CursorColumn++
- , PrintIndex++
- , Walker++
- ){
- if (*Walker == CHAR_NULL
- ||*Walker == CHAR_BACKSPACE
- ||*Walker == CHAR_LINEFEED
- ||*Walker == CHAR_CARRIAGE_RETURN
- ){
+ PrintIndex = ConsoleInfo->HistoryMode.CursorRow * ConsoleInfo->ColsPerScreen + ConsoleInfo->HistoryMode.CursorColumn;
+
+ for ( // no initializer needed
+ ; ConsoleInfo->HistoryMode.CursorColumn < (INT32)ConsoleInfo->ColsPerScreen
+ ; ConsoleInfo->HistoryMode.CursorColumn++,
+ PrintIndex++,
+ Walker++
+ )
+ {
+ if ( (*Walker == CHAR_NULL)
+ || (*Walker == CHAR_BACKSPACE)
+ || (*Walker == CHAR_LINEFEED)
+ || (*Walker == CHAR_CARRIAGE_RETURN)
+ )
+ {
Walker--;
break;
- }
- //
- // The buffer is 2*CursorRow more since it has that many \r\n characters at the end of each row.
- //
+ }
- ASSERT(PrintIndex + ConsoleInfo->HistoryMode.CursorRow < ConsoleInfo->BufferSize);
- ConsoleInfo->Buffer[PrintIndex + (2*ConsoleInfo->HistoryMode.CursorRow)] = *Walker;
- ASSERT(PrintIndex < ConsoleInfo->AttribSize);
- ConsoleInfo->Attributes[PrintIndex] = ConsoleInfo->HistoryMode.Attribute;
- } // for loop
+ //
+ // The buffer is 2*CursorRow more since it has that many \r\n characters at the end of each row.
+ //
- //
- // Add the carriage return and line feed at the end of the lines
- //
- if (ConsoleInfo->HistoryMode.CursorColumn >= (INT32)ConsoleInfo->ColsPerScreen) {
- AppendStringToHistory(L"\r\n", ConsoleInfo);
- Walker--;
- }
+ ASSERT (PrintIndex + ConsoleInfo->HistoryMode.CursorRow < ConsoleInfo->BufferSize);
+ ConsoleInfo->Buffer[PrintIndex + (2*ConsoleInfo->HistoryMode.CursorRow)] = *Walker;
+ ASSERT (PrintIndex < ConsoleInfo->AttribSize);
+ ConsoleInfo->Attributes[PrintIndex] = ConsoleInfo->HistoryMode.Attribute;
+ } // for loop
- break;
+ //
+ // Add the carriage return and line feed at the end of the lines
+ //
+ if (ConsoleInfo->HistoryMode.CursorColumn >= (INT32)ConsoleInfo->ColsPerScreen) {
+ AppendStringToHistory (L"\r\n", ConsoleInfo);
+ Walker--;
+ }
+
+ break;
} // switch for character
} // for loop
@@ -597,23 +619,23 @@ AppendStringToHistory( rendered and were skipped.
**/
EFI_STATUS
-ConsoleLoggerOutputStringSplit(
- IN CONST CHAR16 *String,
- IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
+ConsoleLoggerOutputStringSplit (
+ IN CONST CHAR16 *String,
+ IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Forward the request to the original ConOut
//
- Status = ConsoleInfo->OldConOut->OutputString (ConsoleInfo->OldConOut, (CHAR16*)String);
+ Status = ConsoleInfo->OldConOut->OutputString (ConsoleInfo->OldConOut, (CHAR16 *)String);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return (Status);
}
- return (AppendStringToHistory(String, ConsoleInfo));
+ return (AppendStringToHistory (String, ConsoleInfo));
}
/**
@@ -625,37 +647,40 @@ ConsoleLoggerOutputStringSplit( @return other Break was choosen
**/
EFI_STATUS
-ConsoleLoggerDoPageBreak(
+ConsoleLoggerDoPageBreak (
VOID
)
{
- SHELL_PROMPT_RESPONSE *Resp;
- EFI_STATUS Status;
+ SHELL_PROMPT_RESPONSE *Resp;
+ EFI_STATUS Status;
Resp = NULL;
- ASSERT(ShellInfoObject.PageBreakEnabled);
+ ASSERT (ShellInfoObject.PageBreakEnabled);
ShellInfoObject.PageBreakEnabled = FALSE;
- Status = ShellPromptForResponseHii(ShellPromptResponseTypeQuitContinue, STRING_TOKEN(STR_SHELL_QUIT_CONT), ShellInfoObject.HiiHandle, (VOID**)&Resp);
+ Status = ShellPromptForResponseHii (ShellPromptResponseTypeQuitContinue, STRING_TOKEN (STR_SHELL_QUIT_CONT), ShellInfoObject.HiiHandle, (VOID **)&Resp);
ShellInfoObject.PageBreakEnabled = TRUE;
- ASSERT(Resp != NULL);
+ ASSERT (Resp != NULL);
if (Resp == NULL) {
return (EFI_NOT_FOUND);
}
- if (EFI_ERROR(Status)) {
+
+ if (EFI_ERROR (Status)) {
if (Resp != NULL) {
- FreePool(Resp);
+ FreePool (Resp);
}
+
return (Status);
}
+
if (*Resp == ShellPromptResponseContinue) {
- FreePool(Resp);
- ShellInfoObject.ConsoleInfo->RowCounter = 0;
-// ShellInfoObject.ConsoleInfo->OurConOut.Mode->CursorRow = 0;
-// ShellInfoObject.ConsoleInfo->OurConOut.Mode->CursorColumn = 0;
+ FreePool (Resp);
+ ShellInfoObject.ConsoleInfo->RowCounter = 0;
+ // ShellInfoObject.ConsoleInfo->OurConOut.Mode->CursorRow = 0;
+ // ShellInfoObject.ConsoleInfo->OurConOut.Mode->CursorColumn = 0;
return (EFI_SUCCESS);
} else if (*Resp == ShellPromptResponseQuit) {
- FreePool(Resp);
+ FreePool (Resp);
ShellInfoObject.ConsoleInfo->Enabled = FALSE;
//
// When user wants to quit, the shell should stop running the command.
@@ -663,10 +688,12 @@ ConsoleLoggerDoPageBreak( gBS->SignalEvent (ShellInfoObject.NewEfiShellProtocol->ExecutionBreak);
return (EFI_DEVICE_ERROR);
} else {
- ASSERT(FALSE);
+ ASSERT (FALSE);
}
+
return (EFI_SUCCESS);
}
+
/**
Worker function to handle printing the output with page breaks.
@@ -683,9 +710,9 @@ ConsoleLoggerDoPageBreak( rendered and were skipped.
**/
EFI_STATUS
-ConsoleLoggerPrintWithPageBreak(
- IN CONST CHAR16 *String,
- IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
+ConsoleLoggerPrintWithPageBreak (
+ IN CONST CHAR16 *String,
+ IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
)
{
CONST CHAR16 *Walker;
@@ -694,75 +721,30 @@ ConsoleLoggerPrintWithPageBreak( CHAR16 TempChar;
StringCopy = NULL;
- StringCopy = StrnCatGrow(&StringCopy, NULL, String, 0);
+ StringCopy = StrnCatGrow (&StringCopy, NULL, String, 0);
if (StringCopy == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
- for ( Walker = StringCopy
- , LineStart = StringCopy
- ; Walker != NULL && *Walker != CHAR_NULL
- ; Walker++
- ){
+ for ( Walker = StringCopy,
+ LineStart = StringCopy
+ ; Walker != NULL && *Walker != CHAR_NULL
+ ; Walker++
+ )
+ {
switch (*Walker) {
- case (CHAR_BACKSPACE):
- if (ConsoleInfo->OurConOut.Mode->CursorColumn > 0) {
- ConsoleInfo->OurConOut.Mode->CursorColumn--;
- }
- break;
- case (CHAR_LINEFEED):
- //
- // add a temp NULL terminator
- //
- TempChar = *(Walker + 1);
- *((CHAR16*)(Walker+1)) = CHAR_NULL;
-
- //
- // output the string
- //
- ConsoleLoggerOutputStringSplit (LineStart, ConsoleInfo);
-
- //
- // restore the temp NULL terminator to its original character
- //
- *((CHAR16*)(Walker+1)) = TempChar;
-
- //
- // Update LineStart Variable
- //
- LineStart = Walker + 1;
-
- //
- // increment row count
- //
- ShellInfoObject.ConsoleInfo->RowCounter++;
- ConsoleInfo->OurConOut.Mode->CursorRow++;
-
- break;
- case (CHAR_CARRIAGE_RETURN):
- //
- // Move the cursor to the beginning of the current row.
- //
- ConsoleInfo->OurConOut.Mode->CursorColumn = 0;
- break;
- default:
- //
- // increment column count
- //
- ConsoleInfo->OurConOut.Mode->CursorColumn++;
- //
- // check if that is the last column
- //
- if ((INTN)ConsoleInfo->ColsPerScreen == ConsoleInfo->OurConOut.Mode->CursorColumn + 1) {
- //
- // output a line similar to the linefeed character.
- //
+ case (CHAR_BACKSPACE):
+ if (ConsoleInfo->OurConOut.Mode->CursorColumn > 0) {
+ ConsoleInfo->OurConOut.Mode->CursorColumn--;
+ }
+ break;
+ case (CHAR_LINEFEED):
//
// add a temp NULL terminator
//
- TempChar = *(Walker + 1);
- *((CHAR16*)(Walker+1)) = CHAR_NULL;
+ TempChar = *(Walker + 1);
+ *((CHAR16 *)(Walker+1)) = CHAR_NULL;
//
// output the string
@@ -772,7 +754,7 @@ ConsoleLoggerPrintWithPageBreak( //
// restore the temp NULL terminator to its original character
//
- *((CHAR16*)(Walker+1)) = TempChar;
+ *((CHAR16 *)(Walker+1)) = TempChar;
//
// Update LineStart Variable
@@ -780,34 +762,82 @@ ConsoleLoggerPrintWithPageBreak( LineStart = Walker + 1;
//
- // increment row count and zero the column
+ // increment row count
//
ShellInfoObject.ConsoleInfo->RowCounter++;
ConsoleInfo->OurConOut.Mode->CursorRow++;
+
+ break;
+ case (CHAR_CARRIAGE_RETURN):
+ //
+ // Move the cursor to the beginning of the current row.
+ //
ConsoleInfo->OurConOut.Mode->CursorColumn = 0;
- } // last column on line
- break;
+ break;
+ default:
+ //
+ // increment column count
+ //
+ ConsoleInfo->OurConOut.Mode->CursorColumn++;
+ //
+ // check if that is the last column
+ //
+ if ((INTN)ConsoleInfo->ColsPerScreen == ConsoleInfo->OurConOut.Mode->CursorColumn + 1) {
+ //
+ // output a line similar to the linefeed character.
+ //
+
+ //
+ // add a temp NULL terminator
+ //
+ TempChar = *(Walker + 1);
+ *((CHAR16 *)(Walker+1)) = CHAR_NULL;
+
+ //
+ // output the string
+ //
+ ConsoleLoggerOutputStringSplit (LineStart, ConsoleInfo);
+
+ //
+ // restore the temp NULL terminator to its original character
+ //
+ *((CHAR16 *)(Walker+1)) = TempChar;
+
+ //
+ // Update LineStart Variable
+ //
+ LineStart = Walker + 1;
+
+ //
+ // increment row count and zero the column
+ //
+ ShellInfoObject.ConsoleInfo->RowCounter++;
+ ConsoleInfo->OurConOut.Mode->CursorRow++;
+ ConsoleInfo->OurConOut.Mode->CursorColumn = 0;
+ } // last column on line
+
+ break;
} // switch for character
//
// check if that was the last printable row. If yes handle PageBreak mode
//
if ((ConsoleInfo->RowsPerScreen) -1 == ShellInfoObject.ConsoleInfo->RowCounter) {
- if (EFI_ERROR(ConsoleLoggerDoPageBreak())) {
+ if (EFI_ERROR (ConsoleLoggerDoPageBreak ())) {
//
// We got an error which means 'break' and halt the printing
//
- SHELL_FREE_NON_NULL(StringCopy);
+ SHELL_FREE_NON_NULL (StringCopy);
return (EFI_DEVICE_ERROR);
}
}
} // for loop
- if (LineStart != NULL && *LineStart != CHAR_NULL) {
+ if ((LineStart != NULL) && (*LineStart != CHAR_NULL)) {
ConsoleLoggerOutputStringSplit (LineStart, ConsoleInfo);
}
- SHELL_FREE_NON_NULL(StringCopy);
+ SHELL_FREE_NON_NULL (StringCopy);
return (EFI_SUCCESS);
}
@@ -830,26 +860,26 @@ ConsoleLoggerPrintWithPageBreak( EFI_STATUS
EFIAPI
ConsoleLoggerOutputString (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN CHAR16 *WString
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ IN CHAR16 *WString
)
{
- EFI_STATUS Status;
- EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TxtInEx;
- EFI_KEY_DATA KeyData;
- UINTN EventIndex;
- CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
+ EFI_STATUS Status;
+ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TxtInEx;
+ EFI_KEY_DATA KeyData;
+ UINTN EventIndex;
+ CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
- ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This);
+ ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleOut) {
return (EFI_UNSUPPORTED);
}
- ASSERT(ShellInfoObject.ConsoleInfo == ConsoleInfo);
- Status = gBS->HandleProtocol (gST->ConsoleInHandle, &gEfiSimpleTextInputExProtocolGuid, (VOID **) &TxtInEx);
+ ASSERT (ShellInfoObject.ConsoleInfo == ConsoleInfo);
+
+ Status = gBS->HandleProtocol (gST->ConsoleInHandle, &gEfiSimpleTextInputExProtocolGuid, (VOID **)&TxtInEx);
if (!EFI_ERROR (Status)) {
while (ShellInfoObject.HaltOutput) {
-
ShellInfoObject.HaltOutput = FALSE;
//
// just get some key
@@ -857,7 +887,7 @@ ConsoleLoggerOutputString ( Status = gBS->WaitForEvent (1, &TxtInEx->WaitForKeyEx, &EventIndex);
ASSERT_EFI_ERROR (Status);
Status = TxtInEx->ReadKeyStrokeEx (TxtInEx, &KeyData);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
break;
}
@@ -865,7 +895,8 @@ ConsoleLoggerOutputString ( ((KeyData.KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID | EFI_LEFT_CONTROL_PRESSED)) ||
(KeyData.KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID | EFI_RIGHT_CONTROL_PRESSED))
)
- ) {
+ )
+ {
ShellInfoObject.HaltOutput = TRUE;
}
}
@@ -874,9 +905,9 @@ ConsoleLoggerOutputString ( if (!ShellInfoObject.ConsoleInfo->Enabled) {
return (EFI_DEVICE_ERROR);
} else if (ShellInfoObject.PageBreakEnabled) {
- return (ConsoleLoggerPrintWithPageBreak(WString, ConsoleInfo));
+ return (ConsoleLoggerPrintWithPageBreak (WString, ConsoleInfo));
} else {
- return (ConsoleLoggerOutputStringSplit(WString, ConsoleInfo));
+ return (ConsoleLoggerOutputStringSplit (WString, ConsoleInfo));
}
}
@@ -898,11 +929,12 @@ EFI_STATUS EFIAPI
ConsoleLoggerTestString (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN CHAR16 *WString
+ IN CHAR16 *WString
)
{
- CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
- ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This);
+ CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
+
+ ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
//
// Forward the request to the original ConOut
//
@@ -927,22 +959,23 @@ EFI_STATUS EFIAPI
ConsoleLoggerQueryMode (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN ModeNumber,
- OUT UINTN *Columns,
- OUT UINTN *Rows
+ IN UINTN ModeNumber,
+ OUT UINTN *Columns,
+ OUT UINTN *Rows
)
{
- CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
- ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This);
+ CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
+
+ ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
//
// Forward the request to the original ConOut
//
return (ConsoleInfo->OldConOut->QueryMode (
- ConsoleInfo->OldConOut,
- ModeNumber,
- Columns,
- Rows
- ));
+ ConsoleInfo->OldConOut,
+ ModeNumber,
+ Columns,
+ Rows
+ ));
}
/**
@@ -960,14 +993,15 @@ ConsoleLoggerQueryMode ( EFI_STATUS
EFIAPI
ConsoleLoggerSetMode (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN ModeNumber
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ IN UINTN ModeNumber
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
- CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
- ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This);
+ CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
+
+ ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
//
// Forward the request to the original ConOut
@@ -979,9 +1013,9 @@ ConsoleLoggerSetMode ( //
if (!EFI_ERROR (Status)) {
ConsoleInfo->OurConOut.Mode = ConsoleInfo->OldConOut->Mode;
- ConsoleLoggerResetBuffers(ConsoleInfo);
+ ConsoleLoggerResetBuffers (ConsoleInfo);
ConsoleInfo->OriginalStartRow = 0;
- ConsoleInfo->CurrentStartRow = 0;
+ ConsoleInfo->CurrentStartRow = 0;
ConsoleInfo->OurConOut.ClearScreen (&ConsoleInfo->OurConOut);
}
@@ -1006,14 +1040,15 @@ ConsoleLoggerSetMode ( EFI_STATUS
EFIAPI
ConsoleLoggerSetAttribute (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN Attribute
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ IN UINTN Attribute
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
- CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
- ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This);
+ CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
+
+ ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
//
// Forward the request to the original ConOut
@@ -1024,7 +1059,7 @@ ConsoleLoggerSetAttribute ( // Record console output history
//
if (!EFI_ERROR (Status)) {
- ConsoleInfo->HistoryMode.Attribute = (INT32) Attribute;
+ ConsoleInfo->HistoryMode.Attribute = (INT32)Attribute;
}
return Status;
@@ -1047,18 +1082,18 @@ ConsoleLoggerClearScreen ( IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
)
{
- EFI_STATUS Status;
- CHAR16 *Screen;
- INT32 *Attributes;
- UINTN Row;
- UINTN Column;
- CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
+ EFI_STATUS Status;
+ CHAR16 *Screen;
+ INT32 *Attributes;
+ UINTN Row;
+ UINTN Column;
+ CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleOut) {
return (EFI_UNSUPPORTED);
}
- ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This);
+ ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
//
// Forward the request to the original ConOut
@@ -1069,26 +1104,30 @@ ConsoleLoggerClearScreen ( // Record console output history
//
if (!EFI_ERROR (Status)) {
- Screen = &ConsoleInfo->Buffer[(ConsoleInfo->ColsPerScreen + 2) * ConsoleInfo->CurrentStartRow];
+ Screen = &ConsoleInfo->Buffer[(ConsoleInfo->ColsPerScreen + 2) * ConsoleInfo->CurrentStartRow];
Attributes = &ConsoleInfo->Attributes[ConsoleInfo->ColsPerScreen * ConsoleInfo->CurrentStartRow];
for ( Row = ConsoleInfo->OriginalStartRow
- ; Row < (ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount)
- ; Row++
- ){
+ ; Row < (ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount)
+ ; Row++
+ )
+ {
for ( Column = 0
- ; Column < ConsoleInfo->ColsPerScreen
- ; Column++
- , Screen++
- , Attributes++
- ){
- *Screen = L' ';
+ ; Column < ConsoleInfo->ColsPerScreen
+ ; Column++,
+ Screen++,
+ Attributes++
+ )
+ {
+ *Screen = L' ';
*Attributes = ConsoleInfo->OldConOut->Mode->Attribute;
}
+
//
// Skip the NULL on each column end in text buffer only
//
Screen += 2;
}
+
ConsoleInfo->HistoryMode.CursorColumn = 0;
ConsoleInfo->HistoryMode.CursorRow = 0;
}
@@ -1113,26 +1152,26 @@ EFI_STATUS EFIAPI
ConsoleLoggerSetCursorPosition (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN Column,
- IN UINTN Row
+ IN UINTN Column,
+ IN UINTN Row
)
{
- EFI_STATUS Status;
- CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
+ EFI_STATUS Status;
+ CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleOut) {
return (EFI_UNSUPPORTED);
}
- ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This);
+ ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
//
// Forward the request to the original ConOut
//
Status = ConsoleInfo->OldConOut->SetCursorPosition (
- ConsoleInfo->OldConOut,
- Column,
- Row
- );
+ ConsoleInfo->OldConOut,
+ Column,
+ Row
+ );
//
// Record console output history
@@ -1162,13 +1201,14 @@ EFI_STATUS EFIAPI
ConsoleLoggerEnableCursor (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN BOOLEAN Visible
+ IN BOOLEAN Visible
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
- CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
- ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(This);
+ CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo;
+
+ ConsoleInfo = CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS (This);
//
// Forward the request to the original ConOut
//
@@ -1193,41 +1233,42 @@ ConsoleLoggerEnableCursor ( history buffers.
**/
EFI_STATUS
-ConsoleLoggerResetBuffers(
- IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
+ConsoleLoggerResetBuffers (
+ IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (ConsoleInfo->Buffer != NULL) {
- FreePool(ConsoleInfo->Buffer);
+ FreePool (ConsoleInfo->Buffer);
ConsoleInfo->Buffer = NULL;
ConsoleInfo->BufferSize = 0;
}
+
if (ConsoleInfo->Attributes != NULL) {
- FreePool(ConsoleInfo->Attributes);
+ FreePool (ConsoleInfo->Attributes);
ConsoleInfo->Attributes = NULL;
ConsoleInfo->AttribSize = 0;
}
Status = gST->ConOut->QueryMode (gST->ConOut, gST->ConOut->Mode->Mode, &ConsoleInfo->ColsPerScreen, &ConsoleInfo->RowsPerScreen);
- if (EFI_ERROR(Status)){
+ if (EFI_ERROR (Status)) {
return (Status);
}
- ConsoleInfo->BufferSize = (ConsoleInfo->ColsPerScreen + 2) * ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount * sizeof(ConsoleInfo->Buffer[0]);
- ConsoleInfo->AttribSize = ConsoleInfo->ColsPerScreen * ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount * sizeof(ConsoleInfo->Attributes[0]);
+ ConsoleInfo->BufferSize = (ConsoleInfo->ColsPerScreen + 2) * ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount * sizeof (ConsoleInfo->Buffer[0]);
+ ConsoleInfo->AttribSize = ConsoleInfo->ColsPerScreen * ConsoleInfo->RowsPerScreen * ConsoleInfo->ScreenCount * sizeof (ConsoleInfo->Attributes[0]);
- ConsoleInfo->Buffer = (CHAR16*)AllocateZeroPool(ConsoleInfo->BufferSize);
+ ConsoleInfo->Buffer = (CHAR16 *)AllocateZeroPool (ConsoleInfo->BufferSize);
if (ConsoleInfo->Buffer == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
- ConsoleInfo->Attributes = (INT32*)AllocateZeroPool(ConsoleInfo->AttribSize);
+ ConsoleInfo->Attributes = (INT32 *)AllocateZeroPool (ConsoleInfo->AttribSize);
if (ConsoleInfo->Attributes == NULL) {
- FreePool(ConsoleInfo->Buffer);
- ConsoleInfo->Buffer = NULL;
+ FreePool (ConsoleInfo->Buffer);
+ ConsoleInfo->Buffer = NULL;
return (EFI_OUT_OF_RESOURCES);
}
diff --git a/ShellPkg/Application/Shell/ConsoleLogger.h b/ShellPkg/Application/Shell/ConsoleLogger.h index 0a01bc2..a9e017f 100644 --- a/ShellPkg/Application/Shell/ConsoleLogger.h +++ b/ShellPkg/Application/Shell/ConsoleLogger.h @@ -12,31 +12,31 @@ #define CONSOLE_LOGGER_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('c', 'o', 'P', 'D')
-typedef struct _CONSOLE_LOGGER_PRIVATE_DATA{
- UINTN Signature;
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL OurConOut; ///< the protocol we installed onto the system table
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OldConOut; ///< old protocol to reinstall upon exiting
- EFI_HANDLE OldConHandle; ///< old protocol handle
- UINTN ScreenCount; ///< How many screens worth of data to save
- CHAR16 *Buffer; ///< Buffer to save data
- UINTN BufferSize; ///< size of buffer in bytes
-
- // start row is the top of the screen
- UINTN OriginalStartRow; ///< What the originally visible start row was
- UINTN CurrentStartRow; ///< what the currently visible start row is
-
- UINTN RowsPerScreen; ///< how many rows the screen can display
- UINTN ColsPerScreen; ///< how many columns the screen can display
-
- INT32 *Attributes; ///< Buffer for Attribute to be saved for each character
- UINTN AttribSize; ///< Size of Attributes in bytes
-
- EFI_SIMPLE_TEXT_OUTPUT_MODE HistoryMode; ///< mode of the history log
- BOOLEAN Enabled; ///< Set to FALSE when a break is requested.
- UINTN RowCounter; ///< Initial row of each print job.
+typedef struct _CONSOLE_LOGGER_PRIVATE_DATA {
+ UINTN Signature;
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL OurConOut; ///< the protocol we installed onto the system table
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OldConOut; ///< old protocol to reinstall upon exiting
+ EFI_HANDLE OldConHandle; ///< old protocol handle
+ UINTN ScreenCount; ///< How many screens worth of data to save
+ CHAR16 *Buffer; ///< Buffer to save data
+ UINTN BufferSize; ///< size of buffer in bytes
+
+ // start row is the top of the screen
+ UINTN OriginalStartRow; ///< What the originally visible start row was
+ UINTN CurrentStartRow; ///< what the currently visible start row is
+
+ UINTN RowsPerScreen; ///< how many rows the screen can display
+ UINTN ColsPerScreen; ///< how many columns the screen can display
+
+ INT32 *Attributes; ///< Buffer for Attribute to be saved for each character
+ UINTN AttribSize; ///< Size of Attributes in bytes
+
+ EFI_SIMPLE_TEXT_OUTPUT_MODE HistoryMode; ///< mode of the history log
+ BOOLEAN Enabled; ///< Set to FALSE when a break is requested.
+ UINTN RowCounter; ///< Initial row of each print job.
} CONSOLE_LOGGER_PRIVATE_DATA;
-#define CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(a) CR (a, CONSOLE_LOGGER_PRIVATE_DATA, OurConOut, CONSOLE_LOGGER_PRIVATE_DATA_SIGNATURE)
+#define CONSOLE_LOGGER_PRIVATE_DATA_FROM_THIS(a) CR (a, CONSOLE_LOGGER_PRIVATE_DATA, OurConOut, CONSOLE_LOGGER_PRIVATE_DATA_SIGNATURE)
/**
Install our intermediate ConOut into the system table to
@@ -52,9 +52,9 @@ typedef struct _CONSOLE_LOGGER_PRIVATE_DATA{ @sa InstallProtocolInterface
**/
EFI_STATUS
-ConsoleLoggerInstall(
- IN CONST UINTN ScreensToSave,
- OUT CONSOLE_LOGGER_PRIVATE_DATA **ConsoleInfo
+ConsoleLoggerInstall (
+ IN CONST UINTN ScreensToSave,
+ OUT CONSOLE_LOGGER_PRIVATE_DATA **ConsoleInfo
);
/**
@@ -67,8 +67,8 @@ ConsoleLoggerInstall( @return other The operation failed. This was from UninstallProtocolInterface.
**/
EFI_STATUS
-ConsoleLoggerUninstall(
- IN OUT CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
+ConsoleLoggerUninstall (
+ IN OUT CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
);
/**
@@ -84,10 +84,10 @@ ConsoleLoggerUninstall( @param[in] ConsoleInfo The pointer to the instance of the console logger information.
**/
EFI_STATUS
-ConsoleLoggerDisplayHistory(
- IN CONST BOOLEAN Forward,
- IN CONST UINTN Rows,
- IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
+ConsoleLoggerDisplayHistory (
+ IN CONST BOOLEAN Forward,
+ IN CONST UINTN Rows,
+ IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
);
/**
@@ -100,8 +100,8 @@ ConsoleLoggerDisplayHistory( @sa UpdateDisplayFromHistory
**/
EFI_STATUS
-ConsoleLoggerStopHistory(
- IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
+ConsoleLoggerStopHistory (
+ IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
);
/**
@@ -112,8 +112,8 @@ ConsoleLoggerStopHistory( @return other The operation failed.
**/
EFI_STATUS
-UpdateDisplayFromHistory(
- IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
+UpdateDisplayFromHistory (
+ IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
);
/**
@@ -129,8 +129,8 @@ UpdateDisplayFromHistory( EFI_STATUS
EFIAPI
ConsoleLoggerReset (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
);
/**
@@ -151,9 +151,9 @@ ConsoleLoggerReset ( **/
EFI_STATUS
EFIAPI
-ConsoleLoggerOutputString(
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN CHAR16 *WString
+ConsoleLoggerOutputString (
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ IN CHAR16 *WString
);
/**
@@ -173,8 +173,8 @@ ConsoleLoggerOutputString( EFI_STATUS
EFIAPI
ConsoleLoggerTestString (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN CHAR16 *WString
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ IN CHAR16 *WString
);
/**
@@ -237,8 +237,8 @@ ConsoleLoggerSetMode ( EFI_STATUS
EFIAPI
ConsoleLoggerSetAttribute (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN Attribute
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ IN UINTN Attribute
);
/**
@@ -275,8 +275,8 @@ EFI_STATUS EFIAPI
ConsoleLoggerSetCursorPosition (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN Column,
- IN UINTN Row
+ IN UINTN Column,
+ IN UINTN Row
);
/**
@@ -309,9 +309,8 @@ ConsoleLoggerEnableCursor ( history buffers.
**/
EFI_STATUS
-ConsoleLoggerResetBuffers(
- IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
+ConsoleLoggerResetBuffers (
+ IN CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo
);
#endif //_CONSOLE_LOGGER_HEADER_
-
diff --git a/ShellPkg/Application/Shell/ConsoleWrappers.c b/ShellPkg/Application/Shell/ConsoleWrappers.c index ec340de..eae1137 100644 --- a/ShellPkg/Application/Shell/ConsoleWrappers.c +++ b/ShellPkg/Application/Shell/ConsoleWrappers.c @@ -9,20 +9,20 @@ #include "Shell.h"
-extern BOOLEAN AsciiRedirection;
+extern BOOLEAN AsciiRedirection;
typedef struct {
- EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn;
- SHELL_FILE_HANDLE FileHandle;
- EFI_HANDLE TheHandle;
- UINT64 RemainingBytesOfInputFile;
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn;
+ SHELL_FILE_HANDLE FileHandle;
+ EFI_HANDLE TheHandle;
+ UINT64 RemainingBytesOfInputFile;
} SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL;
typedef struct {
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOut;
- SHELL_FILE_HANDLE FileHandle;
- EFI_HANDLE TheHandle;
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalSimpleTextOut;
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOut;
+ SHELL_FILE_HANDLE FileHandle;
+ EFI_HANDLE TheHandle;
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalSimpleTextOut;
} SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;
/**
@@ -36,8 +36,8 @@ typedef struct { VOID
EFIAPI
ConInWaitForKey (
- IN EFI_EVENT Event,
- IN VOID *Context
+ IN EFI_EVENT Event,
+ IN VOID *Context
)
{
gBS->SignalEvent (Event);
@@ -53,9 +53,9 @@ ConInWaitForKey ( **/
EFI_STATUS
EFIAPI
-FileBasedSimpleTextInReset(
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+FileBasedSimpleTextInReset (
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
return (EFI_SUCCESS);
@@ -71,18 +71,18 @@ FileBasedSimpleTextInReset( **/
EFI_STATUS
EFIAPI
-FileBasedSimpleTextInReadKeyStroke(
- IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
- IN OUT EFI_INPUT_KEY *Key
+FileBasedSimpleTextInReadKeyStroke (
+ IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
+ IN OUT EFI_INPUT_KEY *Key
)
{
- UINTN Size;
- UINTN CharSize;
+ UINTN Size;
+ UINTN CharSize;
//
// Verify the parameters
//
- if (Key == NULL || This == NULL) {
+ if ((Key == NULL) || (This == NULL)) {
return (EFI_INVALID_PARAMETER);
}
@@ -93,13 +93,14 @@ FileBasedSimpleTextInReadKeyStroke( return (EFI_NOT_READY);
}
- Size = sizeof(CHAR16);
+ Size = sizeof (CHAR16);
- if(!AsciiRedirection) {
- CharSize = sizeof(CHAR16);
+ if (!AsciiRedirection) {
+ CharSize = sizeof (CHAR16);
} else {
- CharSize = sizeof(CHAR8);
+ CharSize = sizeof (CHAR8);
}
+
//
// Decrement the amount of free space by Size or set to zero (for odd length files)
//
@@ -110,10 +111,11 @@ FileBasedSimpleTextInReadKeyStroke( }
Key->ScanCode = 0;
- return (ShellInfoObject.NewEfiShellProtocol->ReadFile(
- ((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)This)->FileHandle,
- &Size,
- &Key->UnicodeChar));
+ return (ShellInfoObject.NewEfiShellProtocol->ReadFile (
+ ((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)This)->FileHandle,
+ &Size,
+ &Key->UnicodeChar
+ ));
}
/**
@@ -126,8 +128,8 @@ FileBasedSimpleTextInReadKeyStroke( @retval NULL There was insufficient memory available.
@return A pointer to the allocated protocol structure;
**/
-EFI_SIMPLE_TEXT_INPUT_PROTOCOL*
-CreateSimpleTextInOnFile(
+EFI_SIMPLE_TEXT_INPUT_PROTOCOL *
+CreateSimpleTextInOnFile (
IN SHELL_FILE_HANDLE FileHandleToUse,
IN EFI_HANDLE *HandleLocation
)
@@ -137,17 +139,17 @@ CreateSimpleTextInOnFile( UINT64 CurrentPosition;
UINT64 FileSize;
- if (HandleLocation == NULL || FileHandleToUse == NULL) {
+ if ((HandleLocation == NULL) || (FileHandleToUse == NULL)) {
return (NULL);
}
- ProtocolToReturn = AllocateZeroPool(sizeof(SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL));
+ ProtocolToReturn = AllocateZeroPool (sizeof (SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL));
if (ProtocolToReturn == NULL) {
return (NULL);
}
- ShellGetFileSize (FileHandleToUse, &FileSize);
- ShellGetFilePosition(FileHandleToUse, &CurrentPosition);
+ ShellGetFileSize (FileHandleToUse, &FileSize);
+ ShellGetFilePosition (FileHandleToUse, &CurrentPosition);
//
// Initialize the protocol members
@@ -165,21 +167,23 @@ CreateSimpleTextInOnFile( &ProtocolToReturn->SimpleTextIn.WaitForKey
);
- if (EFI_ERROR(Status)) {
- FreePool(ProtocolToReturn);
+ if (EFI_ERROR (Status)) {
+ FreePool (ProtocolToReturn);
return (NULL);
}
- ///@todo possibly also install SimpleTextInputEx on the handle at this point.
- Status = gBS->InstallProtocolInterface(
- &(ProtocolToReturn->TheHandle),
- &gEfiSimpleTextInProtocolGuid,
- EFI_NATIVE_INTERFACE,
- &(ProtocolToReturn->SimpleTextIn));
- if (!EFI_ERROR(Status)) {
+
+ /// @todo possibly also install SimpleTextInputEx on the handle at this point.
+ Status = gBS->InstallProtocolInterface (
+ &(ProtocolToReturn->TheHandle),
+ &gEfiSimpleTextInProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &(ProtocolToReturn->SimpleTextIn)
+ );
+ if (!EFI_ERROR (Status)) {
*HandleLocation = ProtocolToReturn->TheHandle;
- return ((EFI_SIMPLE_TEXT_INPUT_PROTOCOL*)ProtocolToReturn);
+ return ((EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)ProtocolToReturn);
} else {
- FreePool(ProtocolToReturn);
+ FreePool (ProtocolToReturn);
return (NULL);
}
}
@@ -193,26 +197,27 @@ CreateSimpleTextInOnFile( @retval EFI_SUCCESS The object was closed.
**/
EFI_STATUS
-CloseSimpleTextInOnFile(
+CloseSimpleTextInOnFile (
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *SimpleTextIn
)
{
- EFI_STATUS Status;
- EFI_STATUS Status1;
+ EFI_STATUS Status;
+ EFI_STATUS Status1;
if (SimpleTextIn == NULL) {
return (EFI_INVALID_PARAMETER);
}
- Status = gBS->CloseEvent(((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)SimpleTextIn)->SimpleTextIn.WaitForKey);
+ Status = gBS->CloseEvent (((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)SimpleTextIn)->SimpleTextIn.WaitForKey);
- Status1 = gBS->UninstallProtocolInterface(
- ((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL*)SimpleTextIn)->TheHandle,
- &gEfiSimpleTextInProtocolGuid,
- &(((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL*)SimpleTextIn)->SimpleTextIn));
+ Status1 = gBS->UninstallProtocolInterface (
+ ((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)SimpleTextIn)->TheHandle,
+ &gEfiSimpleTextInProtocolGuid,
+ &(((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)SimpleTextIn)->SimpleTextIn)
+ );
- FreePool(SimpleTextIn);
- if (!EFI_ERROR(Status)) {
+ FreePool (SimpleTextIn);
+ if (!EFI_ERROR (Status)) {
return (Status1);
} else {
return (Status);
@@ -230,8 +235,8 @@ CloseSimpleTextInOnFile( EFI_STATUS
EFIAPI
FileBasedSimpleTextOutReset (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
)
{
return (EFI_SUCCESS);
@@ -249,8 +254,8 @@ FileBasedSimpleTextOutReset ( EFI_STATUS
EFIAPI
FileBasedSimpleTextOutTestString (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN CHAR16 *WString
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ IN CHAR16 *WString
)
{
return (EFI_SUCCESS);
@@ -270,22 +275,23 @@ FileBasedSimpleTextOutTestString ( EFI_STATUS
EFIAPI
FileBasedSimpleTextOutQueryMode (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN ModeNumber,
- OUT UINTN *Columns,
- OUT UINTN *Rows
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ IN UINTN ModeNumber,
+ OUT UINTN *Columns,
+ OUT UINTN *Rows
)
{
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *PassThruProtocol;
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *PassThruProtocol;
PassThruProtocol = ((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)This)->OriginalSimpleTextOut;
// Pass the QueryMode call thru to the original SimpleTextOutProtocol
- return (PassThruProtocol->QueryMode(
- PassThruProtocol,
- ModeNumber,
- Columns,
- Rows));
+ return (PassThruProtocol->QueryMode (
+ PassThruProtocol,
+ ModeNumber,
+ Columns,
+ Rows
+ ));
}
/**
@@ -300,7 +306,7 @@ EFI_STATUS EFIAPI
FileBasedSimpleTextOutSetMode (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN ModeNumber
+ IN UINTN ModeNumber
)
{
return (EFI_UNSUPPORTED);
@@ -320,8 +326,8 @@ FileBasedSimpleTextOutSetMode ( EFI_STATUS
EFIAPI
FileBasedSimpleTextOutSetAttribute (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN Attribute
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ IN UINTN Attribute
)
{
return (EFI_SUCCESS);
@@ -357,8 +363,8 @@ EFI_STATUS EFIAPI
FileBasedSimpleTextOutSetCursorPosition (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN Column,
- IN UINTN Row
+ IN UINTN Column,
+ IN UINTN Row
)
{
return (EFI_SUCCESS);
@@ -377,7 +383,7 @@ EFI_STATUS EFIAPI
FileBasedSimpleTextOutEnableCursor (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN BOOLEAN Visible
+ IN BOOLEAN Visible
)
{
return (EFI_SUCCESS);
@@ -402,16 +408,18 @@ FileBasedSimpleTextOutEnableCursor ( EFI_STATUS
EFIAPI
FileBasedSimpleTextOutOutputString (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN CHAR16 *WString
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
+ IN CHAR16 *WString
)
{
- UINTN Size;
- Size = StrLen(WString) * sizeof(CHAR16);
- return (ShellInfoObject.NewEfiShellProtocol->WriteFile(
- ((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)This)->FileHandle,
- &Size,
- WString));
+ UINTN Size;
+
+ Size = StrLen (WString) * sizeof (CHAR16);
+ return (ShellInfoObject.NewEfiShellProtocol->WriteFile (
+ ((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)This)->FileHandle,
+ &Size,
+ WString
+ ));
}
/**
@@ -425,24 +433,25 @@ FileBasedSimpleTextOutOutputString ( @retval NULL There was insufficient memory available.
@return A pointer to the allocated protocol structure;
**/
-EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*
-CreateSimpleTextOutOnFile(
- IN SHELL_FILE_HANDLE FileHandleToUse,
- IN EFI_HANDLE *HandleLocation,
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalProtocol
+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *
+CreateSimpleTextOutOnFile (
+ IN SHELL_FILE_HANDLE FileHandleToUse,
+ IN EFI_HANDLE *HandleLocation,
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalProtocol
)
{
- SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ProtocolToReturn;
- EFI_STATUS Status;
+ SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ProtocolToReturn;
+ EFI_STATUS Status;
- if (HandleLocation == NULL || FileHandleToUse == NULL) {
+ if ((HandleLocation == NULL) || (FileHandleToUse == NULL)) {
return (NULL);
}
- ProtocolToReturn = AllocateZeroPool(sizeof(SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL));
+ ProtocolToReturn = AllocateZeroPool (sizeof (SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL));
if (ProtocolToReturn == NULL) {
return (NULL);
}
+
ProtocolToReturn->FileHandle = FileHandleToUse;
ProtocolToReturn->OriginalSimpleTextOut = OriginalProtocol;
ProtocolToReturn->SimpleTextOut.Reset = FileBasedSimpleTextOutReset;
@@ -454,11 +463,12 @@ CreateSimpleTextOutOnFile( ProtocolToReturn->SimpleTextOut.SetCursorPosition = FileBasedSimpleTextOutSetCursorPosition;
ProtocolToReturn->SimpleTextOut.EnableCursor = FileBasedSimpleTextOutEnableCursor;
ProtocolToReturn->SimpleTextOut.OutputString = FileBasedSimpleTextOutOutputString;
- ProtocolToReturn->SimpleTextOut.Mode = AllocateZeroPool(sizeof(EFI_SIMPLE_TEXT_OUTPUT_MODE));
+ ProtocolToReturn->SimpleTextOut.Mode = AllocateZeroPool (sizeof (EFI_SIMPLE_TEXT_OUTPUT_MODE));
if (ProtocolToReturn->SimpleTextOut.Mode == NULL) {
- FreePool(ProtocolToReturn);
+ FreePool (ProtocolToReturn);
return (NULL);
}
+
ProtocolToReturn->SimpleTextOut.Mode->MaxMode = OriginalProtocol->Mode->MaxMode;
ProtocolToReturn->SimpleTextOut.Mode->Mode = OriginalProtocol->Mode->Mode;
ProtocolToReturn->SimpleTextOut.Mode->Attribute = OriginalProtocol->Mode->Attribute;
@@ -466,17 +476,18 @@ CreateSimpleTextOutOnFile( ProtocolToReturn->SimpleTextOut.Mode->CursorRow = OriginalProtocol->Mode->CursorRow;
ProtocolToReturn->SimpleTextOut.Mode->CursorVisible = OriginalProtocol->Mode->CursorVisible;
- Status = gBS->InstallProtocolInterface(
- &(ProtocolToReturn->TheHandle),
- &gEfiSimpleTextOutProtocolGuid,
- EFI_NATIVE_INTERFACE,
- &(ProtocolToReturn->SimpleTextOut));
- if (!EFI_ERROR(Status)) {
+ Status = gBS->InstallProtocolInterface (
+ &(ProtocolToReturn->TheHandle),
+ &gEfiSimpleTextOutProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &(ProtocolToReturn->SimpleTextOut)
+ );
+ if (!EFI_ERROR (Status)) {
*HandleLocation = ProtocolToReturn->TheHandle;
- return ((EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)ProtocolToReturn);
+ return ((EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)ProtocolToReturn);
} else {
- SHELL_FREE_NON_NULL(ProtocolToReturn->SimpleTextOut.Mode);
- SHELL_FREE_NON_NULL(ProtocolToReturn);
+ SHELL_FREE_NON_NULL (ProtocolToReturn->SimpleTextOut.Mode);
+ SHELL_FREE_NON_NULL (ProtocolToReturn);
return (NULL);
}
}
@@ -490,19 +501,22 @@ CreateSimpleTextOutOnFile( @retval EFI_SUCCESS The object was closed.
**/
EFI_STATUS
-CloseSimpleTextOutOnFile(
+CloseSimpleTextOutOnFile (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut
)
{
EFI_STATUS Status;
+
if (SimpleTextOut == NULL) {
return (EFI_INVALID_PARAMETER);
}
- Status = gBS->UninstallProtocolInterface(
- ((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)SimpleTextOut)->TheHandle,
- &gEfiSimpleTextOutProtocolGuid,
- &(((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)SimpleTextOut)->SimpleTextOut));
- FreePool(SimpleTextOut->Mode);
- FreePool(SimpleTextOut);
+
+ Status = gBS->UninstallProtocolInterface (
+ ((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)SimpleTextOut)->TheHandle,
+ &gEfiSimpleTextOutProtocolGuid,
+ &(((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)SimpleTextOut)->SimpleTextOut)
+ );
+ FreePool (SimpleTextOut->Mode);
+ FreePool (SimpleTextOut);
return (Status);
}
diff --git a/ShellPkg/Application/Shell/ConsoleWrappers.h b/ShellPkg/Application/Shell/ConsoleWrappers.h index 965813d..0edbad8 100644 --- a/ShellPkg/Application/Shell/ConsoleWrappers.h +++ b/ShellPkg/Application/Shell/ConsoleWrappers.h @@ -20,8 +20,8 @@ @retval NULL There was insufficient memory available.
@return A pointer to the allocated protocol structure;
**/
-EFI_SIMPLE_TEXT_INPUT_PROTOCOL*
-CreateSimpleTextInOnFile(
+EFI_SIMPLE_TEXT_INPUT_PROTOCOL *
+CreateSimpleTextInOnFile (
IN SHELL_FILE_HANDLE FileHandleToUse,
IN EFI_HANDLE *HandleLocation
);
@@ -35,7 +35,7 @@ CreateSimpleTextInOnFile( @retval EFI_SUCCESS The object was closed.
**/
EFI_STATUS
-CloseSimpleTextInOnFile(
+CloseSimpleTextInOnFile (
IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *SimpleTextIn
);
@@ -50,11 +50,11 @@ CloseSimpleTextInOnFile( @retval NULL There was insufficient memory available.
@return A pointer to the allocated protocol structure;
**/
-EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*
-CreateSimpleTextOutOnFile(
- IN SHELL_FILE_HANDLE FileHandleToUse,
- IN EFI_HANDLE *HandleLocation,
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalProtocol
+EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *
+CreateSimpleTextOutOnFile (
+ IN SHELL_FILE_HANDLE FileHandleToUse,
+ IN EFI_HANDLE *HandleLocation,
+ IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalProtocol
);
/**
@@ -66,9 +66,8 @@ CreateSimpleTextOutOnFile( @retval EFI_SUCCESS The object was closed.
**/
EFI_STATUS
-CloseSimpleTextOutOnFile(
+CloseSimpleTextOutOnFile (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut
);
#endif //_SHELL_CONSOLE_WRAPPERS_HEADER_
-
diff --git a/ShellPkg/Application/Shell/FileHandleInternal.h b/ShellPkg/Application/Shell/FileHandleInternal.h index 09c5a8c..2ad2bd0 100644 --- a/ShellPkg/Application/Shell/FileHandleInternal.h +++ b/ShellPkg/Application/Shell/FileHandleInternal.h @@ -18,9 +18,9 @@ **/
VOID
MoveCursorBackward (
- IN UINTN LineLength,
- IN OUT UINTN *Column,
- IN OUT UINTN *Row
+ IN UINTN LineLength,
+ IN OUT UINTN *Column,
+ IN OUT UINTN *Row
);
/**
@@ -33,10 +33,10 @@ MoveCursorBackward ( **/
VOID
MoveCursorForward (
- IN UINTN LineLength,
- IN UINTN TotalRow,
- IN OUT UINTN *Column,
- IN OUT UINTN *Row
+ IN UINTN LineLength,
+ IN UINTN TotalRow,
+ IN OUT UINTN *Column,
+ IN OUT UINTN *Row
);
/**
@@ -50,10 +50,9 @@ MoveCursorForward ( **/
VOID
PrintCommandHistory (
- IN CONST UINTN TotalCols,
- IN CONST UINTN TotalRows,
- IN CONST UINTN StartColumn
+ IN CONST UINTN TotalCols,
+ IN CONST UINTN TotalRows,
+ IN CONST UINTN StartColumn
);
#endif //_FILE_HANDLE_INTERNAL_HEADER_
-
diff --git a/ShellPkg/Application/Shell/FileHandleWrappers.c b/ShellPkg/Application/Shell/FileHandleWrappers.c index a622a76..2ba9b34 100644 --- a/ShellPkg/Application/Shell/FileHandleWrappers.c +++ b/ShellPkg/Application/Shell/FileHandleWrappers.c @@ -12,7 +12,7 @@ #include "Shell.h"
#include "FileHandleInternal.h"
-#define MEM_WRITE_REALLOC_OVERHEAD 1024
+#define MEM_WRITE_REALLOC_OVERHEAD 1024
/**
File style interface for console (Open).
@@ -27,12 +27,12 @@ **/
EFI_STATUS
EFIAPI
-FileInterfaceOpenNotFound(
- IN EFI_FILE_PROTOCOL *This,
- OUT EFI_FILE_PROTOCOL **NewHandle,
- IN CHAR16 *FileName,
- IN UINT64 OpenMode,
- IN UINT64 Attributes
+FileInterfaceOpenNotFound (
+ IN EFI_FILE_PROTOCOL *This,
+ OUT EFI_FILE_PROTOCOL **NewHandle,
+ IN CHAR16 *FileName,
+ IN UINT64 OpenMode,
+ IN UINT64 Attributes
)
{
return (EFI_NOT_FOUND);
@@ -47,8 +47,8 @@ FileInterfaceOpenNotFound( **/
EFI_STATUS
EFIAPI
-FileInterfaceNopGeneric(
- IN EFI_FILE_PROTOCOL *This
+FileInterfaceNopGeneric (
+ IN EFI_FILE_PROTOCOL *This
)
{
return (EFI_SUCCESS);
@@ -64,9 +64,9 @@ FileInterfaceNopGeneric( **/
EFI_STATUS
EFIAPI
-FileInterfaceNopGetPosition(
- IN EFI_FILE_PROTOCOL *This,
- OUT UINT64 *Position
+FileInterfaceNopGetPosition (
+ IN EFI_FILE_PROTOCOL *This,
+ OUT UINT64 *Position
)
{
return (EFI_UNSUPPORTED);
@@ -82,9 +82,9 @@ FileInterfaceNopGetPosition( **/
EFI_STATUS
EFIAPI
-FileInterfaceNopSetPosition(
- IN EFI_FILE_PROTOCOL *This,
- IN UINT64 Position
+FileInterfaceNopSetPosition (
+ IN EFI_FILE_PROTOCOL *This,
+ IN UINT64 Position
)
{
return (EFI_UNSUPPORTED);
@@ -102,11 +102,11 @@ FileInterfaceNopSetPosition( **/
EFI_STATUS
EFIAPI
-FileInterfaceNopGetInfo(
- IN EFI_FILE_PROTOCOL *This,
- IN EFI_GUID *InformationType,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+FileInterfaceNopGetInfo (
+ IN EFI_FILE_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
return (EFI_UNSUPPORTED);
@@ -124,11 +124,11 @@ FileInterfaceNopGetInfo( **/
EFI_STATUS
EFIAPI
-FileInterfaceNopSetInfo(
- IN EFI_FILE_PROTOCOL *This,
- IN EFI_GUID *InformationType,
- IN UINTN BufferSize,
- IN VOID *Buffer
+FileInterfaceNopSetInfo (
+ IN EFI_FILE_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
)
{
return (EFI_UNSUPPORTED);
@@ -148,19 +148,21 @@ FileInterfaceNopSetInfo( **/
EFI_STATUS
EFIAPI
-FileInterfaceStdOutWrite(
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer
+FileInterfaceStdOutWrite (
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer
)
{
if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleOut) {
return (EFI_UNSUPPORTED);
}
+
if (*((CHAR16 *)Buffer) == gUnicodeFileTag) {
- return (gST->ConOut->OutputString(gST->ConOut, (CHAR16 *)Buffer + 1));
+ return (gST->ConOut->OutputString (gST->ConOut, (CHAR16 *)Buffer + 1));
}
- return (gST->ConOut->OutputString(gST->ConOut, Buffer));
+
+ return (gST->ConOut->OutputString (gST->ConOut, Buffer));
}
/**
@@ -174,10 +176,10 @@ FileInterfaceStdOutWrite( **/
EFI_STATUS
EFIAPI
-FileInterfaceStdInWrite(
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer
+FileInterfaceStdInWrite (
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer
)
{
return (EFI_UNSUPPORTED);
@@ -196,13 +198,13 @@ FileInterfaceStdInWrite( **/
EFI_STATUS
EFIAPI
-FileInterfaceStdErrWrite(
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer
+FileInterfaceStdErrWrite (
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer
)
{
- return (gST->StdErr->OutputString(gST->StdErr, Buffer));
+ return (gST->StdErr->OutputString (gST->StdErr, Buffer));
}
/**
@@ -216,10 +218,10 @@ FileInterfaceStdErrWrite( **/
EFI_STATUS
EFIAPI
-FileInterfaceStdOutRead(
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+FileInterfaceStdOutRead (
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
return (EFI_UNSUPPORTED);
@@ -236,10 +238,10 @@ FileInterfaceStdOutRead( **/
EFI_STATUS
EFIAPI
-FileInterfaceStdErrRead(
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+FileInterfaceStdErrRead (
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
return (EFI_UNSUPPORTED);
@@ -256,10 +258,10 @@ FileInterfaceStdErrRead( **/
EFI_STATUS
EFIAPI
-FileInterfaceNulRead(
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+FileInterfaceNulRead (
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
*BufferSize = 0;
@@ -277,10 +279,10 @@ FileInterfaceNulRead( **/
EFI_STATUS
EFIAPI
-FileInterfaceNulWrite(
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer
+FileInterfaceNulWrite (
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer
)
{
return (EFI_SUCCESS);
@@ -302,17 +304,17 @@ CreateTabCompletionList ( IN CONST UINTN BufferSize,
IN OUT EFI_SHELL_FILE_INFO **TabCompletionList,
IN OUT UINTN *TabUpdatePos
-)
+ )
{
- BOOLEAN InQuotation;
- UINTN TabPos;
- UINTN Index;
- CONST CHAR16 *Cwd;
- EFI_STATUS Status;
- CHAR16 *TabStr;
- EFI_SHELL_FILE_INFO *FileList;
- EFI_SHELL_FILE_INFO *FileInfo;
- EFI_SHELL_FILE_INFO *TempFileInfo;
+ BOOLEAN InQuotation;
+ UINTN TabPos;
+ UINTN Index;
+ CONST CHAR16 *Cwd;
+ EFI_STATUS Status;
+ CHAR16 *TabStr;
+ EFI_SHELL_FILE_INFO *FileList;
+ EFI_SHELL_FILE_INFO *FileInfo;
+ EFI_SHELL_FILE_INFO *TempFileInfo;
//
// Allocate buffers
@@ -334,28 +336,29 @@ CreateTabCompletionList ( InQuotation = FALSE;
for (Index = 0; Index < StringLen; Index++) {
switch (InputString[Index]) {
- case L'\"':
- InQuotation = (BOOLEAN) (!InQuotation);
- break;
+ case L'\"':
+ InQuotation = (BOOLEAN)(!InQuotation);
+ break;
- case L' ':
- if (!InQuotation) {
- TabPos = Index + 1;
- *TabUpdatePos = TabPos;
- }
- break;
+ case L' ':
+ if (!InQuotation) {
+ TabPos = Index + 1;
+ *TabUpdatePos = TabPos;
+ }
+
+ break;
- case L':':
+ case L':':
//
// handle the case "fs0:<TAB>"
// Update the TabUpdatePos as well.
//
- case L'\\':
- *TabUpdatePos = Index + 1;
- break;
+ case L'\\':
+ *TabUpdatePos = Index + 1;
+ break;
- default:
- break;
+ default:
+ break;
}
}
@@ -382,15 +385,16 @@ CreateTabCompletionList ( }
}
}
+
StrnCatS (TabStr, (BufferSize) / sizeof (CHAR16), InputString + TabPos, StringLen - TabPos);
StrnCatS (TabStr, (BufferSize) / sizeof (CHAR16), L"*", (BufferSize) / sizeof (CHAR16) - 1 - StrLen (TabStr));
- Status = ShellInfoObject.NewEfiShellProtocol->FindFiles(TabStr, &FileList);
+ Status = ShellInfoObject.NewEfiShellProtocol->FindFiles (TabStr, &FileList);
//
// Filter out the non-directory for "CD" command
// Filter "." and ".." for all
//
- if (!EFI_ERROR (Status) && FileList != NULL) {
+ if (!EFI_ERROR (Status) && (FileList != NULL)) {
//
// Skip the spaces in the beginning
//
@@ -398,20 +402,21 @@ CreateTabCompletionList ( InputString++;
}
- for (FileInfo = (EFI_SHELL_FILE_INFO *) GetFirstNode (&FileList->Link); !IsNull (&FileList->Link, &FileInfo->Link); ) {
+ for (FileInfo = (EFI_SHELL_FILE_INFO *)GetFirstNode (&FileList->Link); !IsNull (&FileList->Link, &FileInfo->Link); ) {
if (((StrCmp (FileInfo->FileName, L".") == 0) || (StrCmp (FileInfo->FileName, L"..") == 0)) ||
- (((InputString[0] == L'c' || InputString[0] == L'C') && (InputString[1] == L'd' || InputString[1] == L'D')) &&
- (ShellIsDirectory (FileInfo->FullName) != EFI_SUCCESS))) {
+ ((((InputString[0] == L'c') || (InputString[0] == L'C')) && ((InputString[1] == L'd') || (InputString[1] == L'D'))) &&
+ (ShellIsDirectory (FileInfo->FullName) != EFI_SUCCESS)))
+ {
TempFileInfo = FileInfo;
- FileInfo = (EFI_SHELL_FILE_INFO *) RemoveEntryList (&FileInfo->Link);
+ FileInfo = (EFI_SHELL_FILE_INFO *)RemoveEntryList (&FileInfo->Link);
InternalFreeShellFileInfoNode (TempFileInfo);
} else {
- FileInfo = (EFI_SHELL_FILE_INFO *) GetNextNode (&FileList->Link, &FileInfo->Link);
+ FileInfo = (EFI_SHELL_FILE_INFO *)GetNextNode (&FileList->Link, &FileInfo->Link);
}
}
}
- if (FileList != NULL && !IsListEmpty (&FileList->Link)) {
+ if ((FileList != NULL) && !IsListEmpty (&FileList->Link)) {
Status = EFI_SUCCESS;
} else {
ShellInfoObject.NewEfiShellProtocol->FreeFileList (&FileList);
@@ -450,40 +455,40 @@ CreateTabCompletionList ( **/
EFI_STATUS
EFIAPI
-FileInterfaceStdInRead(
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+FileInterfaceStdInRead (
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
- CHAR16 *CurrentString;
- BOOLEAN Done;
- UINTN TabUpdatePos; // Start index of the string updated by TAB stroke
- UINTN Column; // Column of current cursor
- UINTN Row; // Row of current cursor
- UINTN StartColumn; // Column at the beginning of the line
- UINTN Update; // Line index for update
- UINTN Delete; // Num of chars to delete from console after update
- UINTN StringLen; // Total length of the line
- UINTN StringCurPos; // Line index corresponding to the cursor
- UINTN MaxStr; // Maximum possible line length
- UINTN TotalColumn; // Num of columns in the console
- UINTN TotalRow; // Num of rows in the console
- UINTN SkipLength;
- UINTN OutputLength; // Length of the update string
- UINTN TailRow; // Row of end of line
- UINTN TailColumn; // Column of end of line
- EFI_INPUT_KEY Key;
-
- BUFFER_LIST *LinePos;
- BUFFER_LIST *NewPos;
- BOOLEAN InScrolling;
- EFI_STATUS Status;
- BOOLEAN InTabScrolling; // Whether in TAB-completion state
- EFI_SHELL_FILE_INFO *TabCompleteList;
- EFI_SHELL_FILE_INFO *TabCurrent;
- UINTN EventIndex;
- CHAR16 *TabOutputStr;
+ CHAR16 *CurrentString;
+ BOOLEAN Done;
+ UINTN TabUpdatePos; // Start index of the string updated by TAB stroke
+ UINTN Column; // Column of current cursor
+ UINTN Row; // Row of current cursor
+ UINTN StartColumn; // Column at the beginning of the line
+ UINTN Update; // Line index for update
+ UINTN Delete; // Num of chars to delete from console after update
+ UINTN StringLen; // Total length of the line
+ UINTN StringCurPos; // Line index corresponding to the cursor
+ UINTN MaxStr; // Maximum possible line length
+ UINTN TotalColumn; // Num of columns in the console
+ UINTN TotalRow; // Num of rows in the console
+ UINTN SkipLength;
+ UINTN OutputLength; // Length of the update string
+ UINTN TailRow; // Row of end of line
+ UINTN TailColumn; // Column of end of line
+ EFI_INPUT_KEY Key;
+
+ BUFFER_LIST *LinePos;
+ BUFFER_LIST *NewPos;
+ BOOLEAN InScrolling;
+ EFI_STATUS Status;
+ BOOLEAN InTabScrolling; // Whether in TAB-completion state
+ EFI_SHELL_FILE_INFO *TabCompleteList;
+ EFI_SHELL_FILE_INFO *TabCurrent;
+ UINTN EventIndex;
+ CHAR16 *TabOutputStr;
//
// If buffer is not large enough to hold a CHAR16, return minimum buffer size
@@ -493,27 +498,27 @@ FileInterfaceStdInRead( return (EFI_BUFFER_TOO_SMALL);
}
- Done = FALSE;
- CurrentString = Buffer;
- StringLen = 0;
- StringCurPos = 0;
- OutputLength = 0;
- Update = 0;
- Delete = 0;
- LinePos = NewPos = (BUFFER_LIST*)(&ShellInfoObject.ViewingSettings.CommandHistory);
- InScrolling = FALSE;
- InTabScrolling = FALSE;
- Status = EFI_SUCCESS;
- TabOutputStr = NULL;
- TabUpdatePos = 0;
- TabCompleteList = NULL;
- TabCurrent = NULL;
+ Done = FALSE;
+ CurrentString = Buffer;
+ StringLen = 0;
+ StringCurPos = 0;
+ OutputLength = 0;
+ Update = 0;
+ Delete = 0;
+ LinePos = NewPos = (BUFFER_LIST *)(&ShellInfoObject.ViewingSettings.CommandHistory);
+ InScrolling = FALSE;
+ InTabScrolling = FALSE;
+ Status = EFI_SUCCESS;
+ TabOutputStr = NULL;
+ TabUpdatePos = 0;
+ TabCompleteList = NULL;
+ TabCurrent = NULL;
//
// Get the screen setting and the current cursor location
//
- Column = StartColumn = gST->ConOut->Mode->CursorColumn;
- Row = gST->ConOut->Mode->CursorRow;
+ Column = StartColumn = gST->ConOut->Mode->CursorColumn;
+ Row = gST->ConOut->Mode->CursorRow;
gST->ConOut->QueryMode (gST->ConOut, gST->ConOut->Mode->Mode, &TotalColumn, &TotalRow);
//
@@ -524,6 +529,7 @@ FileInterfaceStdInRead( if (MaxStr > *BufferSize / sizeof (CHAR16)) {
MaxStr = *BufferSize / sizeof (CHAR16);
}
+
ZeroMem (CurrentString, MaxStr * sizeof (CHAR16));
do {
//
@@ -532,11 +538,11 @@ FileInterfaceStdInRead( gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
if (EFI_ERROR (Status)) {
-
- if (Status == EFI_NOT_READY)
+ if (Status == EFI_NOT_READY) {
continue;
+ }
- ZeroMem (CurrentString, MaxStr * sizeof(CHAR16));
+ ZeroMem (CurrentString, MaxStr * sizeof (CHAR16));
StringLen = 0;
break;
}
@@ -545,17 +551,17 @@ FileInterfaceStdInRead( // Press PageUp or PageDown to scroll the history screen up or down.
// Press any other key to quit scrolling.
//
- if (Key.UnicodeChar == 0 && (Key.ScanCode == SCAN_PAGE_UP || Key.ScanCode == SCAN_PAGE_DOWN)) {
+ if ((Key.UnicodeChar == 0) && ((Key.ScanCode == SCAN_PAGE_UP) || (Key.ScanCode == SCAN_PAGE_DOWN))) {
if (Key.ScanCode == SCAN_PAGE_UP) {
- ConsoleLoggerDisplayHistory(FALSE, 0, ShellInfoObject.ConsoleInfo);
+ ConsoleLoggerDisplayHistory (FALSE, 0, ShellInfoObject.ConsoleInfo);
} else if (Key.ScanCode == SCAN_PAGE_DOWN) {
- ConsoleLoggerDisplayHistory(TRUE, 0, ShellInfoObject.ConsoleInfo);
+ ConsoleLoggerDisplayHistory (TRUE, 0, ShellInfoObject.ConsoleInfo);
}
InScrolling = TRUE;
} else {
if (InScrolling) {
- ConsoleLoggerStopHistory(ShellInfoObject.ConsoleInfo);
+ ConsoleLoggerStopHistory (ShellInfoObject.ConsoleInfo);
InScrolling = FALSE;
}
}
@@ -563,206 +569,218 @@ FileInterfaceStdInRead( //
// If we are quitting TAB scrolling...
//
- if (InTabScrolling && Key.UnicodeChar != CHAR_TAB) {
+ if (InTabScrolling && (Key.UnicodeChar != CHAR_TAB)) {
if (TabCompleteList != NULL) {
ShellInfoObject.NewEfiShellProtocol->FreeFileList (&TabCompleteList);
- DEBUG_CODE(TabCompleteList = NULL;);
+ DEBUG_CODE (
+ TabCompleteList = NULL;
+ );
}
+
InTabScrolling = FALSE;
}
switch (Key.UnicodeChar) {
- case CHAR_CARRIAGE_RETURN:
- //
- // All done, print a newline at the end of the string
- //
- TailRow = Row + (StringLen - StringCurPos + Column) / TotalColumn;
- TailColumn = (StringLen - StringCurPos + Column) % TotalColumn;
- ShellPrintEx ((INT32)TailColumn, (INT32)TailRow, L"%N\n");
- Done = TRUE;
- break;
-
- case CHAR_BACKSPACE:
- if (StringCurPos != 0) {
- //
- // If not move back beyond string beginning, move all characters behind
- // the current position one character forward
- //
- StringCurPos--;
- Update = StringCurPos;
- Delete = 1;
- CopyMem (CurrentString + StringCurPos, CurrentString + StringCurPos + 1, sizeof (CHAR16) * (StringLen - StringCurPos));
-
- //
- // Adjust the current column and row
- //
- MoveCursorBackward (TotalColumn, &Column, &Row);
- }
- break;
-
- case CHAR_TAB:
- if (!InTabScrolling) {
- TabCurrent = NULL;
- //
- // Initialize a tab complete operation.
- //
- Status = CreateTabCompletionList (CurrentString, StringLen, *BufferSize, &TabCompleteList, &TabUpdatePos);
- if (!EFI_ERROR(Status)) {
- InTabScrolling = TRUE;
- }
-
- //
- // We do not set up the replacement.
- // The next section will do that.
- //
- }
-
- if (InTabScrolling) {
+ case CHAR_CARRIAGE_RETURN:
//
- // We are in a tab complete operation.
- // set up the next replacement.
+ // All done, print a newline at the end of the string
//
- ASSERT(TabCompleteList != NULL);
- if (TabCurrent == NULL) {
- TabCurrent = (EFI_SHELL_FILE_INFO*) GetFirstNode (&TabCompleteList->Link);
- } else {
- TabCurrent = (EFI_SHELL_FILE_INFO*) GetNextNode (&TabCompleteList->Link, &TabCurrent->Link);
- }
+ TailRow = Row + (StringLen - StringCurPos + Column) / TotalColumn;
+ TailColumn = (StringLen - StringCurPos + Column) % TotalColumn;
+ ShellPrintEx ((INT32)TailColumn, (INT32)TailRow, L"%N\n");
+ Done = TRUE;
+ break;
- //
- // Skip over the empty list beginning node
- //
- if (IsNull(&TabCompleteList->Link, &TabCurrent->Link)) {
- TabCurrent = (EFI_SHELL_FILE_INFO*) GetNextNode (&TabCompleteList->Link, &TabCurrent->Link);
- }
- }
- break;
+ case CHAR_BACKSPACE:
+ if (StringCurPos != 0) {
+ //
+ // If not move back beyond string beginning, move all characters behind
+ // the current position one character forward
+ //
+ StringCurPos--;
+ Update = StringCurPos;
+ Delete = 1;
+ CopyMem (CurrentString + StringCurPos, CurrentString + StringCurPos + 1, sizeof (CHAR16) * (StringLen - StringCurPos));
- default:
- if (Key.UnicodeChar >= ' ') {
- //
- // If we are at the buffer's end, drop the key
- //
- if (StringLen == MaxStr - 1 && (ShellInfoObject.ViewingSettings.InsertMode || StringCurPos == StringLen)) {
- break;
- }
- //
- // If in insert mode, make space by moving each other character 1
- // space higher in the array
- //
- if (ShellInfoObject.ViewingSettings.InsertMode) {
- CopyMem(CurrentString + StringCurPos + 1, CurrentString + StringCurPos, (StringLen - StringCurPos)*sizeof(CurrentString[0]));
+ //
+ // Adjust the current column and row
+ //
+ MoveCursorBackward (TotalColumn, &Column, &Row);
}
- CurrentString[StringCurPos] = Key.UnicodeChar;
- Update = StringCurPos;
+ break;
- StringCurPos += 1;
- OutputLength = 1;
- }
- break;
+ case CHAR_TAB:
+ if (!InTabScrolling) {
+ TabCurrent = NULL;
+ //
+ // Initialize a tab complete operation.
+ //
+ Status = CreateTabCompletionList (CurrentString, StringLen, *BufferSize, &TabCompleteList, &TabUpdatePos);
+ if (!EFI_ERROR (Status)) {
+ InTabScrolling = TRUE;
+ }
- case 0:
- switch (Key.ScanCode) {
- case SCAN_DELETE:
- //
- // Move characters behind current position one character forward
- //
- if (StringLen != 0) {
- Update = StringCurPos;
- Delete = 1;
- CopyMem (CurrentString + StringCurPos, CurrentString + StringCurPos + 1, sizeof (CHAR16) * (StringLen - StringCurPos));
+ //
+ // We do not set up the replacement.
+ // The next section will do that.
+ //
}
- break;
- case SCAN_UP:
- //
- // Prepare to print the previous command
- //
- NewPos = (BUFFER_LIST*)GetPreviousNode(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &LinePos->Link);
- if (IsNull(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &LinePos->Link)) {
- NewPos = (BUFFER_LIST*)GetPreviousNode(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &LinePos->Link);
- }
- break;
+ if (InTabScrolling) {
+ //
+ // We are in a tab complete operation.
+ // set up the next replacement.
+ //
+ ASSERT (TabCompleteList != NULL);
+ if (TabCurrent == NULL) {
+ TabCurrent = (EFI_SHELL_FILE_INFO *)GetFirstNode (&TabCompleteList->Link);
+ } else {
+ TabCurrent = (EFI_SHELL_FILE_INFO *)GetNextNode (&TabCompleteList->Link, &TabCurrent->Link);
+ }
- case SCAN_DOWN:
- //
- // Prepare to print the next command
- //
- NewPos = (BUFFER_LIST*)GetNextNode(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &LinePos->Link);
- if (NewPos == (BUFFER_LIST*)(&ShellInfoObject.ViewingSettings.CommandHistory)) {
- NewPos = (BUFFER_LIST*)GetNextNode(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &LinePos->Link);
+ //
+ // Skip over the empty list beginning node
+ //
+ if (IsNull (&TabCompleteList->Link, &TabCurrent->Link)) {
+ TabCurrent = (EFI_SHELL_FILE_INFO *)GetNextNode (&TabCompleteList->Link, &TabCurrent->Link);
+ }
}
- break;
- case SCAN_LEFT:
- //
- // Adjust current cursor position
- //
- if (StringCurPos != 0) {
- --StringCurPos;
- MoveCursorBackward (TotalColumn, &Column, &Row);
- }
break;
- case SCAN_RIGHT:
- //
- // Adjust current cursor position
- //
- if (StringCurPos < StringLen) {
- ++StringCurPos;
- MoveCursorForward (TotalColumn, TotalRow, &Column, &Row);
- }
- break;
+ default:
+ if (Key.UnicodeChar >= ' ') {
+ //
+ // If we are at the buffer's end, drop the key
+ //
+ if ((StringLen == MaxStr - 1) && (ShellInfoObject.ViewingSettings.InsertMode || (StringCurPos == StringLen))) {
+ break;
+ }
- case SCAN_HOME:
- //
- // Move current cursor position to the beginning of the command line
- //
- Row -= (StringCurPos + StartColumn) / TotalColumn;
- Column = StartColumn;
- StringCurPos = 0;
- break;
+ //
+ // If in insert mode, make space by moving each other character 1
+ // space higher in the array
+ //
+ if (ShellInfoObject.ViewingSettings.InsertMode) {
+ CopyMem (CurrentString + StringCurPos + 1, CurrentString + StringCurPos, (StringLen - StringCurPos)*sizeof (CurrentString[0]));
+ }
- case SCAN_END:
- //
- // Move current cursor position to the end of the command line
- //
- TailRow = Row + (StringLen - StringCurPos + Column) / TotalColumn;
- TailColumn = (StringLen - StringCurPos + Column) % TotalColumn;
- Row = TailRow;
- Column = TailColumn;
- StringCurPos = StringLen;
- break;
+ CurrentString[StringCurPos] = Key.UnicodeChar;
+ Update = StringCurPos;
- case SCAN_ESC:
- //
- // Prepare to clear the current command line
- //
- CurrentString[0] = 0;
- Update = 0;
- Delete = StringLen;
- Row -= (StringCurPos + StartColumn) / TotalColumn;
- Column = StartColumn;
- OutputLength = 0;
- break;
+ StringCurPos += 1;
+ OutputLength = 1;
+ }
- case SCAN_INSERT:
- //
- // Toggle the SEnvInsertMode flag
- //
- ShellInfoObject.ViewingSettings.InsertMode = (BOOLEAN)!ShellInfoObject.ViewingSettings.InsertMode;
break;
- case SCAN_F7:
- //
- // Print command history
- //
- PrintCommandHistory (TotalColumn, TotalRow, 4);
- *CurrentString = CHAR_NULL;
- Done = TRUE;
- break;
- }
+ case 0:
+ switch (Key.ScanCode) {
+ case SCAN_DELETE:
+ //
+ // Move characters behind current position one character forward
+ //
+ if (StringLen != 0) {
+ Update = StringCurPos;
+ Delete = 1;
+ CopyMem (CurrentString + StringCurPos, CurrentString + StringCurPos + 1, sizeof (CHAR16) * (StringLen - StringCurPos));
+ }
+
+ break;
+
+ case SCAN_UP:
+ //
+ // Prepare to print the previous command
+ //
+ NewPos = (BUFFER_LIST *)GetPreviousNode (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &LinePos->Link);
+ if (IsNull (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &LinePos->Link)) {
+ NewPos = (BUFFER_LIST *)GetPreviousNode (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &LinePos->Link);
+ }
+
+ break;
+
+ case SCAN_DOWN:
+ //
+ // Prepare to print the next command
+ //
+ NewPos = (BUFFER_LIST *)GetNextNode (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &LinePos->Link);
+ if (NewPos == (BUFFER_LIST *)(&ShellInfoObject.ViewingSettings.CommandHistory)) {
+ NewPos = (BUFFER_LIST *)GetNextNode (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &LinePos->Link);
+ }
+
+ break;
+
+ case SCAN_LEFT:
+ //
+ // Adjust current cursor position
+ //
+ if (StringCurPos != 0) {
+ --StringCurPos;
+ MoveCursorBackward (TotalColumn, &Column, &Row);
+ }
+
+ break;
+
+ case SCAN_RIGHT:
+ //
+ // Adjust current cursor position
+ //
+ if (StringCurPos < StringLen) {
+ ++StringCurPos;
+ MoveCursorForward (TotalColumn, TotalRow, &Column, &Row);
+ }
+
+ break;
+
+ case SCAN_HOME:
+ //
+ // Move current cursor position to the beginning of the command line
+ //
+ Row -= (StringCurPos + StartColumn) / TotalColumn;
+ Column = StartColumn;
+ StringCurPos = 0;
+ break;
+
+ case SCAN_END:
+ //
+ // Move current cursor position to the end of the command line
+ //
+ TailRow = Row + (StringLen - StringCurPos + Column) / TotalColumn;
+ TailColumn = (StringLen - StringCurPos + Column) % TotalColumn;
+ Row = TailRow;
+ Column = TailColumn;
+ StringCurPos = StringLen;
+ break;
+
+ case SCAN_ESC:
+ //
+ // Prepare to clear the current command line
+ //
+ CurrentString[0] = 0;
+ Update = 0;
+ Delete = StringLen;
+ Row -= (StringCurPos + StartColumn) / TotalColumn;
+ Column = StartColumn;
+ OutputLength = 0;
+ break;
+
+ case SCAN_INSERT:
+ //
+ // Toggle the SEnvInsertMode flag
+ //
+ ShellInfoObject.ViewingSettings.InsertMode = (BOOLEAN) !ShellInfoObject.ViewingSettings.InsertMode;
+ break;
+
+ case SCAN_F7:
+ //
+ // Print command history
+ //
+ PrintCommandHistory (TotalColumn, TotalRow, 4);
+ *CurrentString = CHAR_NULL;
+ Done = TRUE;
+ break;
+ }
}
if (Done) {
@@ -780,19 +798,18 @@ FileInterfaceStdInRead( }
}
- if (InTabScrolling && TabOutputStr != NULL) {
-
+ if (InTabScrolling && (TabOutputStr != NULL)) {
//
// Adjust the column and row to the start of TAB-completion string.
//
- Column = (StartColumn + TabUpdatePos) % TotalColumn;
- Row -= (StartColumn + StringCurPos) / TotalColumn - (StartColumn + TabUpdatePos) / TotalColumn;
+ Column = (StartColumn + TabUpdatePos) % TotalColumn;
+ Row -= (StartColumn + StringCurPos) / TotalColumn - (StartColumn + TabUpdatePos) / TotalColumn;
OutputLength = StrLen (TabCurrent->FileName);
//
// if the output string contains blank space, quotation marks L'\"'
// should be added to the output.
//
- if (StrStr(TabCurrent->FileName, L" ") != NULL){
+ if (StrStr (TabCurrent->FileName, L" ") != NULL) {
TabOutputStr[0] = L'\"';
CopyMem (TabOutputStr + 1, TabCurrent->FileName, OutputLength * sizeof (CHAR16));
TabOutputStr[OutputLength + 1] = L'\"';
@@ -801,34 +818,35 @@ FileInterfaceStdInRead( CopyMem (TabOutputStr, TabCurrent->FileName, OutputLength * sizeof (CHAR16));
TabOutputStr[OutputLength] = CHAR_NULL;
}
+
OutputLength = StrLen (TabOutputStr) < MaxStr - 1 ? StrLen (TabOutputStr) : MaxStr - 1;
CopyMem (CurrentString + TabUpdatePos, TabOutputStr, OutputLength * sizeof (CHAR16));
CurrentString[TabUpdatePos + OutputLength] = CHAR_NULL;
- StringCurPos = TabUpdatePos + OutputLength;
- Update = TabUpdatePos;
+ StringCurPos = TabUpdatePos + OutputLength;
+ Update = TabUpdatePos;
if (StringLen > TabUpdatePos + OutputLength) {
Delete = StringLen - TabUpdatePos - OutputLength;
}
- FreePool(TabOutputStr);
+ FreePool (TabOutputStr);
}
//
// If we have a new position, we are preparing to print a previous or
// next command.
//
- if (NewPos != (BUFFER_LIST*)(&ShellInfoObject.ViewingSettings.CommandHistory)) {
+ if (NewPos != (BUFFER_LIST *)(&ShellInfoObject.ViewingSettings.CommandHistory)) {
Column = StartColumn;
- Row -= (StringCurPos + StartColumn) / TotalColumn;
+ Row -= (StringCurPos + StartColumn) / TotalColumn;
- LinePos = NewPos;
- NewPos = (BUFFER_LIST*)(&ShellInfoObject.ViewingSettings.CommandHistory);
+ LinePos = NewPos;
+ NewPos = (BUFFER_LIST *)(&ShellInfoObject.ViewingSettings.CommandHistory);
- OutputLength = StrLen (LinePos->Buffer) < MaxStr - 1 ? StrLen (LinePos->Buffer) : MaxStr - 1;
+ OutputLength = StrLen (LinePos->Buffer) < MaxStr - 1 ? StrLen (LinePos->Buffer) : MaxStr - 1;
CopyMem (CurrentString, LinePos->Buffer, OutputLength * sizeof (CHAR16));
CurrentString[OutputLength] = CHAR_NULL;
- StringCurPos = OutputLength;
+ StringCurPos = OutputLength;
//
// Draw new input string
@@ -841,10 +859,11 @@ FileInterfaceStdInRead( Delete = StringLen - OutputLength;
}
}
+
//
// If we need to update the output do so now
//
- if (Update != (UINTN) -1) {
+ if (Update != (UINTN)-1) {
ShellPrintEx ((INT32)Column, (INT32)Row, L"%s%.*s", CurrentString + Update, Delete, L"");
StringLen = StrLen (CurrentString);
@@ -856,19 +875,19 @@ FileInterfaceStdInRead( StringCurPos = StringLen;
}
- Update = (UINTN) -1;
+ Update = (UINTN)-1;
//
// After using print to reflect newly updates, if we're not using
// BACKSPACE and DELETE, we need to move the cursor position forward,
// so adjust row and column here.
//
- if (Key.UnicodeChar != CHAR_BACKSPACE && !(Key.UnicodeChar == 0 && Key.ScanCode == SCAN_DELETE)) {
+ if ((Key.UnicodeChar != CHAR_BACKSPACE) && !((Key.UnicodeChar == 0) && (Key.ScanCode == SCAN_DELETE))) {
//
// Calculate row and column of the tail of current string
//
- TailRow = Row + (StringLen - StringCurPos + Column + OutputLength) / TotalColumn;
- TailColumn = (StringLen - StringCurPos + Column + OutputLength) % TotalColumn;
+ TailRow = Row + (StringLen - StringCurPos + Column + OutputLength) / TotalColumn;
+ TailColumn = (StringLen - StringCurPos + Column + OutputLength) % TotalColumn;
//
// If the tail of string reaches screen end, screen rolls up, so if
@@ -877,9 +896,10 @@ FileInterfaceStdInRead( // (if we are recalling commands using UPPER and DOWN key, and if the
// old command is too long to fit the screen, TailColumn must be 79.
//
- if (TailColumn == 0 && TailRow >= TotalRow && Row != TailRow) {
+ if ((TailColumn == 0) && (TailRow >= TotalRow) && (Row != TailRow)) {
Row--;
}
+
//
// Calculate the cursor position after current operation. If cursor
// reaches line end, update both row and column, otherwise, only
@@ -901,17 +921,18 @@ FileInterfaceStdInRead( Delete = 0;
}
+
//
// Set the cursor position for this key
//
gST->ConOut->SetCursorPosition (gST->ConOut, Column, Row);
} while (!Done);
- if (CurrentString != NULL && StrLen(CurrentString) > 0) {
+ if ((CurrentString != NULL) && (StrLen (CurrentString) > 0)) {
//
// add the line to the history buffer
//
- AddLineToCommandHistory(CurrentString);
+ AddLineToCommandHistory (CurrentString);
}
//
@@ -926,7 +947,8 @@ FileInterfaceStdInRead( if (TabCompleteList != NULL) {
ShellInfoObject.NewEfiShellProtocol->FreeFileList (&TabCompleteList);
}
- ASSERT(TabCompleteList == NULL);
+
+ ASSERT (TabCompleteList == NULL);
return Status;
}
@@ -934,7 +956,7 @@ FileInterfaceStdInRead( //
// FILE style interfaces for StdIn/StdOut/StdErr
//
-EFI_FILE_PROTOCOL FileInterfaceStdIn = {
+EFI_FILE_PROTOCOL FileInterfaceStdIn = {
EFI_FILE_REVISION,
FileInterfaceOpenNotFound,
FileInterfaceNopGeneric,
@@ -948,7 +970,7 @@ EFI_FILE_PROTOCOL FileInterfaceStdIn = { FileInterfaceNopGeneric
};
-EFI_FILE_PROTOCOL FileInterfaceStdOut = {
+EFI_FILE_PROTOCOL FileInterfaceStdOut = {
EFI_FILE_REVISION,
FileInterfaceOpenNotFound,
FileInterfaceNopGeneric,
@@ -962,7 +984,7 @@ EFI_FILE_PROTOCOL FileInterfaceStdOut = { FileInterfaceNopGeneric
};
-EFI_FILE_PROTOCOL FileInterfaceStdErr = {
+EFI_FILE_PROTOCOL FileInterfaceStdErr = {
EFI_FILE_REVISION,
FileInterfaceOpenNotFound,
FileInterfaceNopGeneric,
@@ -976,7 +998,7 @@ EFI_FILE_PROTOCOL FileInterfaceStdErr = { FileInterfaceNopGeneric
};
-EFI_FILE_PROTOCOL FileInterfaceNulFile = {
+EFI_FILE_PROTOCOL FileInterfaceNulFile = {
EFI_FILE_REVISION,
FileInterfaceOpenNotFound,
FileInterfaceNopGeneric,
@@ -990,30 +1012,27 @@ EFI_FILE_PROTOCOL FileInterfaceNulFile = { FileInterfaceNopGeneric
};
-
-
-
//
// This is identical to EFI_FILE_PROTOCOL except for the additional member
// for the name.
//
typedef struct {
- UINT64 Revision;
- EFI_FILE_OPEN Open;
- EFI_FILE_CLOSE Close;
- EFI_FILE_DELETE Delete;
- EFI_FILE_READ Read;
- EFI_FILE_WRITE Write;
- EFI_FILE_GET_POSITION GetPosition;
- EFI_FILE_SET_POSITION SetPosition;
- EFI_FILE_GET_INFO GetInfo;
- EFI_FILE_SET_INFO SetInfo;
- EFI_FILE_FLUSH Flush;
- CHAR16 Name[1];
+ UINT64 Revision;
+ EFI_FILE_OPEN Open;
+ EFI_FILE_CLOSE Close;
+ EFI_FILE_DELETE Delete;
+ EFI_FILE_READ Read;
+ EFI_FILE_WRITE Write;
+ EFI_FILE_GET_POSITION GetPosition;
+ EFI_FILE_SET_POSITION SetPosition;
+ EFI_FILE_GET_INFO GetInfo;
+ EFI_FILE_SET_INFO SetInfo;
+ EFI_FILE_FLUSH Flush;
+ CHAR16 Name[1];
} EFI_FILE_PROTOCOL_ENVIRONMENT;
-//ANSI compliance helper to get size of the struct.
-#define SIZE_OF_EFI_FILE_PROTOCOL_ENVIRONMENT EFI_FIELD_OFFSET (EFI_FILE_PROTOCOL_ENVIRONMENT, Name)
+// ANSI compliance helper to get size of the struct.
+#define SIZE_OF_EFI_FILE_PROTOCOL_ENVIRONMENT EFI_FIELD_OFFSET (EFI_FILE_PROTOCOL_ENVIRONMENT, Name)
/**
File style interface for Environment Variable (Close).
@@ -1026,11 +1045,11 @@ typedef struct { **/
EFI_STATUS
EFIAPI
-FileInterfaceEnvClose(
- IN EFI_FILE_PROTOCOL *This
+FileInterfaceEnvClose (
+ IN EFI_FILE_PROTOCOL *This
)
{
- VOID* NewBuffer;
+ VOID *NewBuffer;
UINTN NewSize;
EFI_STATUS Status;
BOOLEAN Volatile;
@@ -1042,48 +1061,49 @@ FileInterfaceEnvClose( // keep this. So, before closing, strip the trailing '\r\n' from the variable
// if it exists.
//
- NewBuffer = NULL;
- NewSize = 0;
- TotalSize = 0;
+ NewBuffer = NULL;
+ NewSize = 0;
+ TotalSize = 0;
- Status = IsVolatileEnv (((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, &Volatile);
+ Status = IsVolatileEnv (((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name, &Volatile);
if (EFI_ERROR (Status)) {
return Status;
}
- Status = SHELL_GET_ENVIRONMENT_VARIABLE(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, &NewSize, NewBuffer);
+ Status = SHELL_GET_ENVIRONMENT_VARIABLE (((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name, &NewSize, NewBuffer);
if (Status == EFI_BUFFER_TOO_SMALL) {
TotalSize = NewSize + sizeof (CHAR16);
NewBuffer = AllocateZeroPool (TotalSize);
if (NewBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- Status = SHELL_GET_ENVIRONMENT_VARIABLE(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, &NewSize, NewBuffer);
- }
- if (!EFI_ERROR(Status) && NewBuffer != NULL) {
+ Status = SHELL_GET_ENVIRONMENT_VARIABLE (((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name, &NewSize, NewBuffer);
+ }
+ if (!EFI_ERROR (Status) && (NewBuffer != NULL)) {
if (TotalSize / sizeof (CHAR16) >= 3) {
- if ( (((CHAR16*)NewBuffer)[TotalSize / sizeof (CHAR16) - 2] == CHAR_LINEFEED) &&
- (((CHAR16*)NewBuffer)[TotalSize / sizeof (CHAR16) - 3] == CHAR_CARRIAGE_RETURN)
- ) {
- ((CHAR16*)NewBuffer)[TotalSize / sizeof (CHAR16) - 3] = CHAR_NULL;
+ if ((((CHAR16 *)NewBuffer)[TotalSize / sizeof (CHAR16) - 2] == CHAR_LINEFEED) &&
+ (((CHAR16 *)NewBuffer)[TotalSize / sizeof (CHAR16) - 3] == CHAR_CARRIAGE_RETURN)
+ )
+ {
+ ((CHAR16 *)NewBuffer)[TotalSize / sizeof (CHAR16) - 3] = CHAR_NULL;
//
// If the NewBuffer end with \r\n\0, We will replace '\r' by '\0' and then update TotalSize.
//
- TotalSize -= sizeof(CHAR16) * 2;
+ TotalSize -= sizeof (CHAR16) * 2;
}
if (Volatile) {
Status = SHELL_SET_ENVIRONMENT_VARIABLE_V (
- ((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name,
+ ((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name,
TotalSize - sizeof (CHAR16),
NewBuffer
);
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
Status = ShellAddEnvVarToList (
- ((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name,
+ ((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name,
NewBuffer,
TotalSize,
EFI_VARIABLE_BOOTSERVICE_ACCESS
@@ -1091,14 +1111,14 @@ FileInterfaceEnvClose( }
} else {
Status = SHELL_SET_ENVIRONMENT_VARIABLE_NV (
- ((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name,
+ ((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name,
TotalSize - sizeof (CHAR16),
NewBuffer
);
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
Status = ShellAddEnvVarToList (
- ((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name,
+ ((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name,
NewBuffer,
TotalSize,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS
@@ -1108,8 +1128,8 @@ FileInterfaceEnvClose( }
}
- SHELL_FREE_NON_NULL(NewBuffer);
- FreePool((EFI_FILE_PROTOCOL_ENVIRONMENT*)This);
+ SHELL_FREE_NON_NULL (NewBuffer);
+ FreePool ((EFI_FILE_PROTOCOL_ENVIRONMENT *)This);
return (Status);
}
@@ -1122,12 +1142,12 @@ FileInterfaceEnvClose( **/
EFI_STATUS
EFIAPI
-FileInterfaceEnvDelete(
- IN EFI_FILE_PROTOCOL *This
+FileInterfaceEnvDelete (
+ IN EFI_FILE_PROTOCOL *This
)
{
- SHELL_DELETE_ENVIRONMENT_VARIABLE(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name);
- return (FileInterfaceEnvClose(This));
+ SHELL_DELETE_ENVIRONMENT_VARIABLE (((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name);
+ return (FileInterfaceEnvClose (This));
}
/**
@@ -1141,13 +1161,13 @@ FileInterfaceEnvDelete( **/
EFI_STATUS
EFIAPI
-FileInterfaceEnvRead(
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+FileInterfaceEnvRead (
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
*BufferSize = *BufferSize / sizeof (CHAR16) * sizeof (CHAR16);
if (*BufferSize != 0) {
@@ -1160,7 +1180,7 @@ FileInterfaceEnvRead( }
Status = SHELL_GET_ENVIRONMENT_VARIABLE (
- ((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name,
+ ((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name,
BufferSize,
Buffer
);
@@ -1170,6 +1190,7 @@ FileInterfaceEnvRead( //
*BufferSize += sizeof (gUnicodeFileTag);
}
+
return Status;
}
@@ -1186,26 +1207,26 @@ FileInterfaceEnvRead( **/
EFI_STATUS
EFIAPI
-FileInterfaceEnvVolWrite(
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer
+FileInterfaceEnvVolWrite (
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer
)
{
- VOID* NewBuffer;
+ VOID *NewBuffer;
UINTN NewSize;
EFI_STATUS Status;
UINTN TotalSize;
- NewBuffer = NULL;
- NewSize = 0;
- TotalSize = 0;
+ NewBuffer = NULL;
+ NewSize = 0;
+ TotalSize = 0;
- Status = SHELL_GET_ENVIRONMENT_VARIABLE(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, &NewSize, NewBuffer);
+ Status = SHELL_GET_ENVIRONMENT_VARIABLE (((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name, &NewSize, NewBuffer);
if (Status == EFI_BUFFER_TOO_SMALL) {
TotalSize = NewSize + *BufferSize + sizeof (CHAR16);
} else if (Status == EFI_NOT_FOUND) {
- TotalSize = *BufferSize + sizeof(CHAR16);
+ TotalSize = *BufferSize + sizeof (CHAR16);
} else {
return Status;
}
@@ -1216,40 +1237,39 @@ FileInterfaceEnvVolWrite( }
if (Status == EFI_BUFFER_TOO_SMALL) {
- Status = SHELL_GET_ENVIRONMENT_VARIABLE(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, &NewSize, NewBuffer);
+ Status = SHELL_GET_ENVIRONMENT_VARIABLE (((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name, &NewSize, NewBuffer);
}
- if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) {
+ if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
FreePool (NewBuffer);
return Status;
}
- CopyMem ((UINT8*)NewBuffer + NewSize, Buffer, *BufferSize);
+ CopyMem ((UINT8 *)NewBuffer + NewSize, Buffer, *BufferSize);
Status = ShellAddEnvVarToList (
- ((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name,
+ ((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name,
NewBuffer,
TotalSize,
EFI_VARIABLE_BOOTSERVICE_ACCESS
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
FreePool (NewBuffer);
return Status;
}
Status = SHELL_SET_ENVIRONMENT_VARIABLE_V (
- ((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name,
+ ((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name,
TotalSize - sizeof (CHAR16),
NewBuffer
);
- if (EFI_ERROR(Status)) {
- ShellRemvoeEnvVarFromList (((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name);
+ if (EFI_ERROR (Status)) {
+ ShellRemvoeEnvVarFromList (((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name);
}
FreePool (NewBuffer);
return Status;
}
-
/**
File style interface for Non Volatile Environment Variable (Write).
This function also caches the environment variable into gShellEnvVarList.
@@ -1263,22 +1283,22 @@ FileInterfaceEnvVolWrite( **/
EFI_STATUS
EFIAPI
-FileInterfaceEnvNonVolWrite(
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer
+FileInterfaceEnvNonVolWrite (
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer
)
{
- VOID* NewBuffer;
+ VOID *NewBuffer;
UINTN NewSize;
EFI_STATUS Status;
UINTN TotalSize;
- NewBuffer = NULL;
- NewSize = 0;
- TotalSize = 0;
+ NewBuffer = NULL;
+ NewSize = 0;
+ TotalSize = 0;
- Status = SHELL_GET_ENVIRONMENT_VARIABLE(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, &NewSize, NewBuffer);
+ Status = SHELL_GET_ENVIRONMENT_VARIABLE (((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name, &NewSize, NewBuffer);
if (Status == EFI_BUFFER_TOO_SMALL) {
TotalSize = NewSize + *BufferSize + sizeof (CHAR16);
} else if (Status == EFI_NOT_FOUND) {
@@ -1293,17 +1313,17 @@ FileInterfaceEnvNonVolWrite( }
if (Status == EFI_BUFFER_TOO_SMALL) {
- Status = SHELL_GET_ENVIRONMENT_VARIABLE(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, &NewSize, NewBuffer);
+ Status = SHELL_GET_ENVIRONMENT_VARIABLE (((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name, &NewSize, NewBuffer);
}
- if (EFI_ERROR(Status) && Status != EFI_NOT_FOUND) {
+ if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
FreePool (NewBuffer);
return Status;
}
- CopyMem ((UINT8*) NewBuffer + NewSize, Buffer, *BufferSize);
+ CopyMem ((UINT8 *)NewBuffer + NewSize, Buffer, *BufferSize);
Status = ShellAddEnvVarToList (
- ((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name,
+ ((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name,
NewBuffer,
TotalSize,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS
@@ -1314,12 +1334,12 @@ FileInterfaceEnvNonVolWrite( }
Status = SHELL_SET_ENVIRONMENT_VARIABLE_NV (
- ((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name,
+ ((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name,
TotalSize - sizeof (CHAR16),
NewBuffer
);
if (EFI_ERROR (Status)) {
- ShellRemvoeEnvVarFromList (((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name);
+ ShellRemvoeEnvVarFromList (((EFI_FILE_PROTOCOL_ENVIRONMENT *)This)->Name);
}
FreePool (NewBuffer);
@@ -1335,9 +1355,9 @@ FileInterfaceEnvNonVolWrite( @retval NULL Memory could not be allocated.
@return other a pointer to an EFI_FILE_PROTOCOL structure
**/
-EFI_FILE_PROTOCOL*
-CreateFileInterfaceEnv(
- IN CONST CHAR16 *EnvName
+EFI_FILE_PROTOCOL *
+CreateFileInterfaceEnv (
+ IN CONST CHAR16 *EnvName
)
{
EFI_STATUS Status;
@@ -1357,9 +1377,9 @@ CreateFileInterfaceEnv( //
// Get some memory
//
- EnvNameSize = StrSize(EnvName);
- EnvFileInterface = AllocateZeroPool(sizeof(EFI_FILE_PROTOCOL_ENVIRONMENT)+EnvNameSize);
- if (EnvFileInterface == NULL){
+ EnvNameSize = StrSize (EnvName);
+ EnvFileInterface = AllocateZeroPool (sizeof (EFI_FILE_PROTOCOL_ENVIRONMENT)+EnvNameSize);
+ if (EnvFileInterface == NULL) {
return (NULL);
}
@@ -1377,16 +1397,17 @@ CreateFileInterfaceEnv( EnvFileInterface->Delete = FileInterfaceEnvDelete;
EnvFileInterface->Read = FileInterfaceEnvRead;
- CopyMem(EnvFileInterface->Name, EnvName, EnvNameSize);
+ CopyMem (EnvFileInterface->Name, EnvName, EnvNameSize);
//
// Assign the different members for Volatile and Non-Volatile variables
//
if (Volatile) {
- EnvFileInterface->Write = FileInterfaceEnvVolWrite;
+ EnvFileInterface->Write = FileInterfaceEnvVolWrite;
} else {
- EnvFileInterface->Write = FileInterfaceEnvNonVolWrite;
+ EnvFileInterface->Write = FileInterfaceEnvNonVolWrite;
}
+
return ((EFI_FILE_PROTOCOL *)EnvFileInterface);
}
@@ -1399,9 +1420,9 @@ CreateFileInterfaceEnv( **/
VOID
MoveCursorBackward (
- IN UINTN LineLength,
- IN OUT UINTN *Column,
- IN OUT UINTN *Row
+ IN UINTN LineLength,
+ IN OUT UINTN *Column,
+ IN OUT UINTN *Row
)
{
//
@@ -1413,8 +1434,10 @@ MoveCursorBackward ( if (*Row > 0) {
(*Row)--;
}
+
return;
}
+
(*Column)--;
}
@@ -1428,10 +1451,10 @@ MoveCursorBackward ( **/
VOID
MoveCursorForward (
- IN UINTN LineLength,
- IN UINTN TotalRow,
- IN OUT UINTN *Column,
- IN OUT UINTN *Row
+ IN UINTN LineLength,
+ IN UINTN TotalRow,
+ IN OUT UINTN *Column,
+ IN OUT UINTN *Row
)
{
//
@@ -1459,70 +1482,67 @@ MoveCursorForward ( **/
VOID
PrintCommandHistory (
- IN CONST UINTN TotalCols,
- IN CONST UINTN TotalRows,
- IN CONST UINTN StartColumn
+ IN CONST UINTN TotalCols,
+ IN CONST UINTN TotalRows,
+ IN CONST UINTN StartColumn
)
{
- BUFFER_LIST *Node;
- UINTN Index;
- UINTN LineNumber;
- UINTN LineCount;
+ BUFFER_LIST *Node;
+ UINTN Index;
+ UINTN LineNumber;
+ UINTN LineCount;
ShellPrintEx (-1, -1, L"\n");
- Index = 0;
- LineNumber = 0;
+ Index = 0;
+ LineNumber = 0;
//
// go through history list...
//
- for ( Node = (BUFFER_LIST*)GetFirstNode(&ShellInfoObject.ViewingSettings.CommandHistory.Link)
- ; !IsNull(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Node->Link)
- ; Node = (BUFFER_LIST*)GetNextNode(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Node->Link)
- ){
+ for ( Node = (BUFFER_LIST *)GetFirstNode (&ShellInfoObject.ViewingSettings.CommandHistory.Link)
+ ; !IsNull (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Node->Link)
+ ; Node = (BUFFER_LIST *)GetNextNode (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Node->Link)
+ )
+ {
Index++;
LineCount = ((StrLen (Node->Buffer) + StartColumn + 1) / TotalCols) + 1;
if (LineNumber + LineCount >= TotalRows) {
- ShellPromptForResponseHii(
+ ShellPromptForResponseHii (
ShellPromptResponseTypeEnterContinue,
STRING_TOKEN (STR_SHELL_ENTER_TO_CONT),
ShellInfoObject.HiiHandle,
NULL
- );
+ );
LineNumber = 0;
}
+
ShellPrintEx (-1, -1, L"%2d. %s\n", Index, Node->Buffer);
LineNumber += LineCount;
}
}
-
-
-
-
-
//
// This is identical to EFI_FILE_PROTOCOL except for the additional members
// for the buffer, size, and position.
//
typedef struct {
- UINT64 Revision;
- EFI_FILE_OPEN Open;
- EFI_FILE_CLOSE Close;
- EFI_FILE_DELETE Delete;
- EFI_FILE_READ Read;
- EFI_FILE_WRITE Write;
- EFI_FILE_GET_POSITION GetPosition;
- EFI_FILE_SET_POSITION SetPosition;
- EFI_FILE_GET_INFO GetInfo;
- EFI_FILE_SET_INFO SetInfo;
- EFI_FILE_FLUSH Flush;
- VOID *Buffer;
- UINT64 Position;
- UINT64 BufferSize;
- BOOLEAN Unicode;
- UINT64 FileSize;
+ UINT64 Revision;
+ EFI_FILE_OPEN Open;
+ EFI_FILE_CLOSE Close;
+ EFI_FILE_DELETE Delete;
+ EFI_FILE_READ Read;
+ EFI_FILE_WRITE Write;
+ EFI_FILE_GET_POSITION GetPosition;
+ EFI_FILE_SET_POSITION SetPosition;
+ EFI_FILE_GET_INFO GetInfo;
+ EFI_FILE_SET_INFO SetInfo;
+ EFI_FILE_FLUSH Flush;
+ VOID *Buffer;
+ UINT64 Position;
+ UINT64 BufferSize;
+ BOOLEAN Unicode;
+ UINT64 FileSize;
} EFI_FILE_PROTOCOL_MEM;
/**
@@ -1536,13 +1556,13 @@ typedef struct { **/
EFI_STATUS
EFIAPI
-FileInterfaceMemSetPosition(
- IN EFI_FILE_PROTOCOL *This,
- OUT UINT64 Position
+FileInterfaceMemSetPosition (
+ IN EFI_FILE_PROTOCOL *This,
+ OUT UINT64 Position
)
{
- if (Position <= ((EFI_FILE_PROTOCOL_MEM*)This)->FileSize) {
- ((EFI_FILE_PROTOCOL_MEM*)This)->Position = Position;
+ if (Position <= ((EFI_FILE_PROTOCOL_MEM *)This)->FileSize) {
+ ((EFI_FILE_PROTOCOL_MEM *)This)->Position = Position;
return (EFI_SUCCESS);
} else {
return (EFI_INVALID_PARAMETER);
@@ -1559,12 +1579,12 @@ FileInterfaceMemSetPosition( **/
EFI_STATUS
EFIAPI
-FileInterfaceMemGetPosition(
- IN EFI_FILE_PROTOCOL *This,
- OUT UINT64 *Position
+FileInterfaceMemGetPosition (
+ IN EFI_FILE_PROTOCOL *This,
+ OUT UINT64 *Position
)
{
- *Position = ((EFI_FILE_PROTOCOL_MEM*)This)->Position;
+ *Position = ((EFI_FILE_PROTOCOL_MEM *)This)->Position;
return (EFI_SUCCESS);
}
@@ -1588,27 +1608,29 @@ FileInterfaceMemGetPosition( **/
EFI_STATUS
EFIAPI
-FileInterfaceMemGetInfo(
- IN EFI_FILE_PROTOCOL *This,
- IN EFI_GUID *InformationType,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+FileInterfaceMemGetInfo (
+ IN EFI_FILE_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
- EFI_FILE_INFO *FileInfo;
+ EFI_FILE_INFO *FileInfo;
if (CompareGuid (InformationType, &gEfiFileInfoGuid)) {
if (*BufferSize < sizeof (EFI_FILE_INFO)) {
*BufferSize = sizeof (EFI_FILE_INFO);
return EFI_BUFFER_TOO_SMALL;
}
+
if (Buffer == NULL) {
return EFI_INVALID_PARAMETER;
}
- FileInfo = (EFI_FILE_INFO *)Buffer;
+
+ FileInfo = (EFI_FILE_INFO *)Buffer;
FileInfo->Size = sizeof (*FileInfo);
ZeroMem (FileInfo, sizeof (*FileInfo));
- FileInfo->FileSize = ((EFI_FILE_PROTOCOL_MEM*)This)->FileSize;
+ FileInfo->FileSize = ((EFI_FILE_PROTOCOL_MEM *)This)->FileSize;
FileInfo->PhysicalSize = FileInfo->FileSize;
return EFI_SUCCESS;
}
@@ -1628,52 +1650,57 @@ FileInterfaceMemGetInfo( **/
EFI_STATUS
EFIAPI
-FileInterfaceMemWrite(
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer
+FileInterfaceMemWrite (
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer
)
{
CHAR8 *AsciiBuffer;
EFI_FILE_PROTOCOL_MEM *MemFile;
- MemFile = (EFI_FILE_PROTOCOL_MEM *) This;
+ MemFile = (EFI_FILE_PROTOCOL_MEM *)This;
if (MemFile->Unicode) {
//
// Unicode
//
if ((UINTN)(MemFile->Position + (*BufferSize)) > (UINTN)(MemFile->BufferSize)) {
- MemFile->Buffer = ReallocatePool((UINTN)(MemFile->BufferSize), (UINTN)(MemFile->BufferSize) + (*BufferSize) + MEM_WRITE_REALLOC_OVERHEAD, MemFile->Buffer);
- if (MemFile->Buffer == NULL){
+ MemFile->Buffer = ReallocatePool ((UINTN)(MemFile->BufferSize), (UINTN)(MemFile->BufferSize) + (*BufferSize) + MEM_WRITE_REALLOC_OVERHEAD, MemFile->Buffer);
+ if (MemFile->Buffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
MemFile->BufferSize += (*BufferSize) + MEM_WRITE_REALLOC_OVERHEAD;
}
- CopyMem(((UINT8*)MemFile->Buffer) + MemFile->Position, Buffer, *BufferSize);
+
+ CopyMem (((UINT8 *)MemFile->Buffer) + MemFile->Position, Buffer, *BufferSize);
MemFile->Position += (*BufferSize);
- MemFile->FileSize = MemFile->Position;
+ MemFile->FileSize = MemFile->Position;
return (EFI_SUCCESS);
} else {
//
// Ascii
//
- AsciiBuffer = AllocateZeroPool(*BufferSize);
+ AsciiBuffer = AllocateZeroPool (*BufferSize);
if (AsciiBuffer == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
- AsciiSPrint(AsciiBuffer, *BufferSize, "%S", Buffer);
- if ((UINTN)(MemFile->Position + AsciiStrSize(AsciiBuffer)) > (UINTN)(MemFile->BufferSize)) {
- MemFile->Buffer = ReallocatePool((UINTN)(MemFile->BufferSize), (UINTN)(MemFile->BufferSize) + AsciiStrSize(AsciiBuffer) + MEM_WRITE_REALLOC_OVERHEAD, MemFile->Buffer);
- if (MemFile->Buffer == NULL){
- FreePool(AsciiBuffer);
+
+ AsciiSPrint (AsciiBuffer, *BufferSize, "%S", Buffer);
+ if ((UINTN)(MemFile->Position + AsciiStrSize (AsciiBuffer)) > (UINTN)(MemFile->BufferSize)) {
+ MemFile->Buffer = ReallocatePool ((UINTN)(MemFile->BufferSize), (UINTN)(MemFile->BufferSize) + AsciiStrSize (AsciiBuffer) + MEM_WRITE_REALLOC_OVERHEAD, MemFile->Buffer);
+ if (MemFile->Buffer == NULL) {
+ FreePool (AsciiBuffer);
return EFI_OUT_OF_RESOURCES;
}
- MemFile->BufferSize += AsciiStrSize(AsciiBuffer) + MEM_WRITE_REALLOC_OVERHEAD;
+
+ MemFile->BufferSize += AsciiStrSize (AsciiBuffer) + MEM_WRITE_REALLOC_OVERHEAD;
}
- CopyMem(((UINT8*)MemFile->Buffer) + MemFile->Position, AsciiBuffer, AsciiStrSize(AsciiBuffer));
- MemFile->Position += (*BufferSize / sizeof(CHAR16));
- MemFile->FileSize = MemFile->Position;
- FreePool(AsciiBuffer);
+
+ CopyMem (((UINT8 *)MemFile->Buffer) + MemFile->Position, AsciiBuffer, AsciiStrSize (AsciiBuffer));
+ MemFile->Position += (*BufferSize / sizeof (CHAR16));
+ MemFile->FileSize = MemFile->Position;
+ FreePool (AsciiBuffer);
return (EFI_SUCCESS);
}
}
@@ -1689,19 +1716,20 @@ FileInterfaceMemWrite( **/
EFI_STATUS
EFIAPI
-FileInterfaceMemRead(
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer
+FileInterfaceMemRead (
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer
)
{
EFI_FILE_PROTOCOL_MEM *MemFile;
- MemFile = (EFI_FILE_PROTOCOL_MEM *) This;
+ MemFile = (EFI_FILE_PROTOCOL_MEM *)This;
if (*BufferSize > (UINTN)((MemFile->FileSize) - (UINTN)(MemFile->Position))) {
(*BufferSize) = (UINTN)((MemFile->FileSize) - (UINTN)(MemFile->Position));
}
- CopyMem(Buffer, ((UINT8*)MemFile->Buffer) + MemFile->Position, (*BufferSize));
+
+ CopyMem (Buffer, ((UINT8 *)MemFile->Buffer) + MemFile->Position, (*BufferSize));
MemFile->Position = MemFile->Position + (*BufferSize);
return (EFI_SUCCESS);
}
@@ -1717,12 +1745,12 @@ FileInterfaceMemRead( **/
EFI_STATUS
EFIAPI
-FileInterfaceMemClose(
- IN EFI_FILE_PROTOCOL *This
+FileInterfaceMemClose (
+ IN EFI_FILE_PROTOCOL *This
)
{
- SHELL_FREE_NON_NULL(((EFI_FILE_PROTOCOL_MEM*)This)->Buffer);
- SHELL_FREE_NON_NULL(This);
+ SHELL_FREE_NON_NULL (((EFI_FILE_PROTOCOL_MEM *)This)->Buffer);
+ SHELL_FREE_NON_NULL (This);
return (EFI_SUCCESS);
}
@@ -1735,9 +1763,9 @@ FileInterfaceMemClose( @retval NULL Memory could not be allocated.
@return other A pointer to an EFI_FILE_PROTOCOL structure.
**/
-EFI_FILE_PROTOCOL*
-CreateFileInterfaceMem(
- IN CONST BOOLEAN Unicode
+EFI_FILE_PROTOCOL *
+CreateFileInterfaceMem (
+ IN CONST BOOLEAN Unicode
)
{
EFI_FILE_PROTOCOL_MEM *FileInterface;
@@ -1745,8 +1773,8 @@ CreateFileInterfaceMem( //
// Get some memory
//
- FileInterface = AllocateZeroPool(sizeof(EFI_FILE_PROTOCOL_MEM));
- if (FileInterface == NULL){
+ FileInterface = AllocateZeroPool (sizeof (EFI_FILE_PROTOCOL_MEM));
+ if (FileInterface == NULL) {
return (NULL);
}
@@ -1766,38 +1794,39 @@ CreateFileInterfaceMem( FileInterface->Write = FileInterfaceMemWrite;
FileInterface->Unicode = Unicode;
- ASSERT(FileInterface->Buffer == NULL);
- ASSERT(FileInterface->BufferSize == 0);
- ASSERT(FileInterface->Position == 0);
+ ASSERT (FileInterface->Buffer == NULL);
+ ASSERT (FileInterface->BufferSize == 0);
+ ASSERT (FileInterface->Position == 0);
if (Unicode) {
- FileInterface->Buffer = AllocateZeroPool(sizeof(gUnicodeFileTag));
+ FileInterface->Buffer = AllocateZeroPool (sizeof (gUnicodeFileTag));
if (FileInterface->Buffer == NULL) {
FreePool (FileInterface);
return NULL;
}
- *((CHAR16 *) (FileInterface->Buffer)) = EFI_UNICODE_BYTE_ORDER_MARK;
- FileInterface->BufferSize = 2;
- FileInterface->Position = 2;
+
+ *((CHAR16 *)(FileInterface->Buffer)) = EFI_UNICODE_BYTE_ORDER_MARK;
+ FileInterface->BufferSize = 2;
+ FileInterface->Position = 2;
}
return ((EFI_FILE_PROTOCOL *)FileInterface);
}
typedef struct {
- UINT64 Revision;
- EFI_FILE_OPEN Open;
- EFI_FILE_CLOSE Close;
- EFI_FILE_DELETE Delete;
- EFI_FILE_READ Read;
- EFI_FILE_WRITE Write;
- EFI_FILE_GET_POSITION GetPosition;
- EFI_FILE_SET_POSITION SetPosition;
- EFI_FILE_GET_INFO GetInfo;
- EFI_FILE_SET_INFO SetInfo;
- EFI_FILE_FLUSH Flush;
- BOOLEAN Unicode;
- EFI_FILE_PROTOCOL *Orig;
+ UINT64 Revision;
+ EFI_FILE_OPEN Open;
+ EFI_FILE_CLOSE Close;
+ EFI_FILE_DELETE Delete;
+ EFI_FILE_READ Read;
+ EFI_FILE_WRITE Write;
+ EFI_FILE_GET_POSITION GetPosition;
+ EFI_FILE_SET_POSITION SetPosition;
+ EFI_FILE_GET_INFO GetInfo;
+ EFI_FILE_SET_INFO SetInfo;
+ EFI_FILE_FLUSH Flush;
+ BOOLEAN Unicode;
+ EFI_FILE_PROTOCOL *Orig;
} EFI_FILE_PROTOCOL_FILE;
/**
@@ -1812,12 +1841,12 @@ typedef struct { **/
EFI_STATUS
EFIAPI
-FileInterfaceFileSetPosition(
- IN EFI_FILE_PROTOCOL *This,
- IN UINT64 Position
+FileInterfaceFileSetPosition (
+ IN EFI_FILE_PROTOCOL *This,
+ IN UINT64 Position
)
{
- return ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->SetPosition(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, Position);
+ return ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->SetPosition (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, Position);
}
/**
@@ -1832,12 +1861,12 @@ FileInterfaceFileSetPosition( **/
EFI_STATUS
EFIAPI
-FileInterfaceFileGetPosition(
- IN EFI_FILE_PROTOCOL *This,
- OUT UINT64 *Position
+FileInterfaceFileGetPosition (
+ IN EFI_FILE_PROTOCOL *This,
+ OUT UINT64 *Position
)
{
- return ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->GetPosition(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, Position);
+ return ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->GetPosition (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, Position);
}
/**
@@ -1860,14 +1889,14 @@ FileInterfaceFileGetPosition( **/
EFI_STATUS
EFIAPI
-FileInterfaceFileGetInfo(
- IN EFI_FILE_PROTOCOL *This,
- IN EFI_GUID *InformationType,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+FileInterfaceFileGetInfo (
+ IN EFI_FILE_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
- return ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->GetInfo(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, InformationType, BufferSize, Buffer);
+ return ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->GetInfo (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, InformationType, BufferSize, Buffer);
}
/**
@@ -1889,14 +1918,14 @@ FileInterfaceFileGetInfo( **/
EFI_STATUS
EFIAPI
-FileInterfaceFileSetInfo(
- IN EFI_FILE_PROTOCOL *This,
- IN EFI_GUID *InformationType,
- IN UINTN BufferSize,
- IN VOID *Buffer
+FileInterfaceFileSetInfo (
+ IN EFI_FILE_PROTOCOL *This,
+ IN EFI_GUID *InformationType,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
)
{
- return ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->SetInfo(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, InformationType, BufferSize, Buffer);
+ return ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->SetInfo (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, InformationType, BufferSize, Buffer);
}
/**
@@ -1916,11 +1945,11 @@ FileInterfaceFileSetInfo( **/
EFI_STATUS
EFIAPI
-FileInterfaceFileFlush(
+FileInterfaceFileFlush (
IN EFI_FILE_PROTOCOL *This
)
{
- return ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Flush(((EFI_FILE_PROTOCOL_FILE*)This)->Orig);
+ return ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->Flush (((EFI_FILE_PROTOCOL_FILE *)This)->Orig);
}
/**
@@ -1939,10 +1968,10 @@ FileInterfaceFileFlush( **/
EFI_STATUS
EFIAPI
-FileInterfaceFileRead(
- IN EFI_FILE_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
+FileInterfaceFileRead (
+ IN EFI_FILE_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
)
{
EFI_STATUS Status;
@@ -1950,13 +1979,14 @@ FileInterfaceFileRead( CHAR8 *AsciiStrBuffer;
CHAR16 *UscStrBuffer;
UINTN Size;
- if (((EFI_FILE_PROTOCOL_FILE*)This)->Unicode) {
+
+ if (((EFI_FILE_PROTOCOL_FILE *)This)->Unicode) {
//
// Unicode
// There might be different file tag for the Unicode file. We cannot unconditionally insert the \xFEFF.
// So we choose to leave the file content as is.
//
- return (((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Read(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, BufferSize, Buffer));
+ return (((EFI_FILE_PROTOCOL_FILE *)This)->Orig->Read (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, BufferSize, Buffer));
} else {
//
// Ascii
@@ -1965,35 +1995,41 @@ FileInterfaceFileRead( if (*BufferSize == 0) {
return EFI_SUCCESS;
}
- Status = ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->GetPosition (((EFI_FILE_PROTOCOL_FILE*)This)->Orig, &Position);
+
+ Status = ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->GetPosition (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, &Position);
if (EFI_ERROR (Status)) {
return Status;
}
+
if (Position == 0) {
//
// First two bytes in Buffer is for the Unicode file tag.
//
*(CHAR16 *)Buffer = gUnicodeFileTag;
- Buffer = (CHAR16 *)Buffer + 1;
- Size = *BufferSize / sizeof (CHAR16) - 1;
+ Buffer = (CHAR16 *)Buffer + 1;
+ Size = *BufferSize / sizeof (CHAR16) - 1;
} else {
- Size = *BufferSize / sizeof (CHAR16);
+ Size = *BufferSize / sizeof (CHAR16);
}
+
AsciiStrBuffer = AllocateZeroPool (Size + 1);
if (AsciiStrBuffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- UscStrBuffer = AllocateZeroPool ((Size + 1) * sizeof(CHAR16));
- if (UscStrBuffer== NULL) {
- SHELL_FREE_NON_NULL(AsciiStrBuffer);
+
+ UscStrBuffer = AllocateZeroPool ((Size + 1) * sizeof (CHAR16));
+ if (UscStrBuffer == NULL) {
+ SHELL_FREE_NON_NULL (AsciiStrBuffer);
return EFI_OUT_OF_RESOURCES;
}
- Status = ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Read (((EFI_FILE_PROTOCOL_FILE*)This)->Orig, &Size, AsciiStrBuffer);
- if (!EFI_ERROR(Status)) {
+
+ Status = ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->Read (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, &Size, AsciiStrBuffer);
+ if (!EFI_ERROR (Status)) {
AsciiStrToUnicodeStrS (AsciiStrBuffer, UscStrBuffer, Size + 1);
*BufferSize = Size * sizeof (CHAR16);
CopyMem (Buffer, UscStrBuffer, *BufferSize);
}
+
SHELL_FREE_NON_NULL (AsciiStrBuffer);
SHELL_FREE_NON_NULL (UscStrBuffer);
return Status;
@@ -2022,14 +2058,14 @@ FileInterfaceFileRead( EFI_STATUS
EFIAPI
FileInterfaceFileOpen (
- IN EFI_FILE_PROTOCOL *This,
- OUT EFI_FILE_PROTOCOL **NewHandle,
- IN CHAR16 *FileName,
- IN UINT64 OpenMode,
- IN UINT64 Attributes
+ IN EFI_FILE_PROTOCOL *This,
+ OUT EFI_FILE_PROTOCOL **NewHandle,
+ IN CHAR16 *FileName,
+ IN UINT64 OpenMode,
+ IN UINT64 Attributes
)
{
- return ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Open(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, NewHandle, FileName, OpenMode, Attributes);
+ return ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->Open (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, NewHandle, FileName, OpenMode, Attributes);
}
/**
@@ -2043,13 +2079,14 @@ FileInterfaceFileOpen ( **/
EFI_STATUS
EFIAPI
-FileInterfaceFileDelete(
+FileInterfaceFileDelete (
IN EFI_FILE_PROTOCOL *This
)
{
- EFI_STATUS Status;
- Status = ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Delete(((EFI_FILE_PROTOCOL_FILE*)This)->Orig);
- FreePool(This);
+ EFI_STATUS Status;
+
+ Status = ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->Delete (((EFI_FILE_PROTOCOL_FILE *)This)->Orig);
+ FreePool (This);
return (Status);
}
@@ -2062,13 +2099,14 @@ FileInterfaceFileDelete( **/
EFI_STATUS
EFIAPI
-FileInterfaceFileClose(
- IN EFI_FILE_PROTOCOL *This
+FileInterfaceFileClose (
+ IN EFI_FILE_PROTOCOL *This
)
{
- EFI_STATUS Status;
- Status = ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Close(((EFI_FILE_PROTOCOL_FILE*)This)->Orig);
- FreePool(This);
+ EFI_STATUS Status;
+
+ Status = ((EFI_FILE_PROTOCOL_FILE *)This)->Orig->Close (((EFI_FILE_PROTOCOL_FILE *)This)->Orig);
+ FreePool (This);
return (Status);
}
@@ -2086,7 +2124,7 @@ FileInterfaceFileClose( **/
EFI_STATUS
EFIAPI
-FileInterfaceFileWrite(
+FileInterfaceFileWrite (
IN EFI_FILE_PROTOCOL *This,
IN OUT UINTN *BufferSize,
IN VOID *Buffer
@@ -2095,20 +2133,21 @@ FileInterfaceFileWrite( CHAR8 *AsciiBuffer;
UINTN Size;
EFI_STATUS Status;
- if (((EFI_FILE_PROTOCOL_FILE*)This)->Unicode) {
+
+ if (((EFI_FILE_PROTOCOL_FILE *)This)->Unicode) {
//
// Unicode
//
- return (((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Write(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, BufferSize, Buffer));
+ return (((EFI_FILE_PROTOCOL_FILE *)This)->Orig->Write (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, BufferSize, Buffer));
} else {
//
// Ascii
//
- AsciiBuffer = AllocateZeroPool(*BufferSize);
- AsciiSPrint(AsciiBuffer, *BufferSize, "%S", Buffer);
- Size = AsciiStrSize(AsciiBuffer) - 1; // (we dont need the null terminator)
- Status = (((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Write(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, &Size, AsciiBuffer));
- FreePool(AsciiBuffer);
+ AsciiBuffer = AllocateZeroPool (*BufferSize);
+ AsciiSPrint (AsciiBuffer, *BufferSize, "%S", Buffer);
+ Size = AsciiStrSize (AsciiBuffer) - 1; // (we dont need the null terminator)
+ Status = (((EFI_FILE_PROTOCOL_FILE *)This)->Orig->Write (((EFI_FILE_PROTOCOL_FILE *)This)->Orig, &Size, AsciiBuffer));
+ FreePool (AsciiBuffer);
return (Status);
}
}
@@ -2124,19 +2163,20 @@ FileInterfaceFileWrite( @return a new EFI_FILE_PROTOCOL object to be used instead of the template.
**/
-EFI_FILE_PROTOCOL*
-CreateFileInterfaceFile(
+EFI_FILE_PROTOCOL *
+CreateFileInterfaceFile (
IN CONST EFI_FILE_PROTOCOL *Template,
IN CONST BOOLEAN Unicode
)
{
- EFI_FILE_PROTOCOL_FILE *NewOne;
+ EFI_FILE_PROTOCOL_FILE *NewOne;
- NewOne = AllocateZeroPool(sizeof(EFI_FILE_PROTOCOL_FILE));
+ NewOne = AllocateZeroPool (sizeof (EFI_FILE_PROTOCOL_FILE));
if (NewOne == NULL) {
return (NULL);
}
- CopyMem(NewOne, Template, sizeof(EFI_FILE_PROTOCOL_FILE));
+
+ CopyMem (NewOne, Template, sizeof (EFI_FILE_PROTOCOL_FILE));
NewOne->Orig = (EFI_FILE_PROTOCOL *)Template;
NewOne->Unicode = Unicode;
NewOne->Open = FileInterfaceFileOpen;
diff --git a/ShellPkg/Application/Shell/FileHandleWrappers.h b/ShellPkg/Application/Shell/FileHandleWrappers.h index 5d58bfb..178b24bd 100644 --- a/ShellPkg/Application/Shell/FileHandleWrappers.h +++ b/ShellPkg/Application/Shell/FileHandleWrappers.h @@ -10,34 +10,34 @@ #define _SHELL_FILE_HANDLE_WRAPPERS_HEADER_
typedef struct {
- LIST_ENTRY Link;
- CHAR16* Buffer;
+ LIST_ENTRY Link;
+ CHAR16 *Buffer;
} SHELL_LINE_LIST;
typedef struct {
- UINTN LogCount;
- SHELL_LINE_LIST *Log;
+ UINTN LogCount;
+ SHELL_LINE_LIST *Log;
} SHELL_LINE_LOG;
///
/// FILE styte interfaces for StdIn.
///
-extern EFI_FILE_PROTOCOL FileInterfaceStdIn;
+extern EFI_FILE_PROTOCOL FileInterfaceStdIn;
///
/// FILE styte interfaces for StdOut.
///
-extern EFI_FILE_PROTOCOL FileInterfaceStdOut;
+extern EFI_FILE_PROTOCOL FileInterfaceStdOut;
///
/// FILE styte interfaces for StdErr.
///
-extern EFI_FILE_PROTOCOL FileInterfaceStdErr;
+extern EFI_FILE_PROTOCOL FileInterfaceStdErr;
///
/// FILE style interface for NUL file.
///
-extern EFI_FILE_PROTOCOL FileInterfaceNulFile;
+extern EFI_FILE_PROTOCOL FileInterfaceNulFile;
/**
Creates a EFI_FILE_PROTOCOL (almost) object for using to access
@@ -48,9 +48,9 @@ extern EFI_FILE_PROTOCOL FileInterfaceNulFile; @retval NULL Memory could not be allocated.
@return other a pointer to an EFI_FILE_PROTOCOL structure
**/
-EFI_FILE_PROTOCOL*
-CreateFileInterfaceEnv(
- CONST CHAR16 *EnvName
+EFI_FILE_PROTOCOL *
+CreateFileInterfaceEnv (
+ CONST CHAR16 *EnvName
);
/**
@@ -62,9 +62,9 @@ CreateFileInterfaceEnv( @retval NULL Memory could not be allocated.
@return other a pointer to an EFI_FILE_PROTOCOL structure
**/
-EFI_FILE_PROTOCOL*
-CreateFileInterfaceMem(
- IN CONST BOOLEAN Unicode
+EFI_FILE_PROTOCOL *
+CreateFileInterfaceMem (
+ IN CONST BOOLEAN Unicode
);
/**
@@ -77,11 +77,10 @@ CreateFileInterfaceMem( @retval NULL Memory could not be allocated.
@return other a pointer to an EFI_FILE_PROTOCOL structure
**/
-EFI_FILE_PROTOCOL*
-CreateFileInterfaceFile(
+EFI_FILE_PROTOCOL *
+CreateFileInterfaceFile (
IN CONST EFI_FILE_PROTOCOL *Template,
IN CONST BOOLEAN Unicode
);
#endif //_SHELL_FILE_HANDLE_WRAPPERS_HEADER_
-
diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shell/Shell.c index a556307..df00adf 100644 --- a/ShellPkg/Application/Shell/Shell.c +++ b/ShellPkg/Application/Shell/Shell.c @@ -13,31 +13,37 @@ //
// Initialize the global structure
//
-SHELL_INFO ShellInfoObject = {
+SHELL_INFO ShellInfoObject = {
NULL,
NULL,
FALSE,
FALSE,
{
- {{
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0
- }},
+ {
+ {
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0
+ }
+ },
0,
NULL,
NULL
},
- {{NULL, NULL}, NULL},
{
- {{NULL, NULL}, NULL},
+ { NULL,NULL }, NULL
+ },
+ {
+ {
+ { NULL,NULL }, NULL
+ },
0,
0,
TRUE
@@ -49,8 +55,12 @@ SHELL_INFO ShellInfoObject = { NULL,
NULL,
NULL,
- {{NULL, NULL}, NULL, NULL},
- {{NULL, NULL}, NULL, NULL},
+ {
+ { NULL,NULL }, NULL, NULL
+ },
+ {
+ { NULL,NULL }, NULL, NULL
+ },
NULL,
NULL,
NULL,
@@ -62,12 +72,12 @@ SHELL_INFO ShellInfoObject = { FALSE
};
-STATIC CONST CHAR16 mScriptExtension[] = L".NSH";
-STATIC CONST CHAR16 mExecutableExtensions[] = L".NSH;.EFI";
-STATIC CONST CHAR16 mStartupScript[] = L"startup.nsh";
-CONST CHAR16 mNoNestingEnvVarName[] = L"nonesting";
-CONST CHAR16 mNoNestingTrue[] = L"True";
-CONST CHAR16 mNoNestingFalse[] = L"False";
+STATIC CONST CHAR16 mScriptExtension[] = L".NSH";
+STATIC CONST CHAR16 mExecutableExtensions[] = L".NSH;.EFI";
+STATIC CONST CHAR16 mStartupScript[] = L"startup.nsh";
+CONST CHAR16 mNoNestingEnvVarName[] = L"nonesting";
+CONST CHAR16 mNoNestingTrue[] = L"True";
+CONST CHAR16 mNoNestingFalse[] = L"False";
/**
Cleans off leading and trailing spaces and tabs.
@@ -75,24 +85,24 @@ CONST CHAR16 mNoNestingFalse[] = L"False"; @param[in] String pointer to the string to trim them off.
**/
EFI_STATUS
-TrimSpaces(
- IN CHAR16 **String
+TrimSpaces (
+ IN CHAR16 **String
)
{
- ASSERT(String != NULL);
- ASSERT(*String!= NULL);
+ ASSERT (String != NULL);
+ ASSERT (*String != NULL);
//
// Remove any spaces and tabs at the beginning of the (*String).
//
while (((*String)[0] == L' ') || ((*String)[0] == L'\t')) {
- CopyMem((*String), (*String)+1, StrSize((*String)) - sizeof((*String)[0]));
+ CopyMem ((*String), (*String)+1, StrSize ((*String)) - sizeof ((*String)[0]));
}
//
// Remove any spaces and tabs at the end of the (*String).
//
- while ((StrLen (*String) > 0) && (((*String)[StrLen((*String))-1] == L' ') || ((*String)[StrLen((*String))-1] == L'\t'))) {
- (*String)[StrLen((*String))-1] = CHAR_NULL;
+ while ((StrLen (*String) > 0) && (((*String)[StrLen ((*String))-1] == L' ') || ((*String)[StrLen ((*String))-1] == L'\t'))) {
+ (*String)[StrLen ((*String))-1] = CHAR_NULL;
}
return (EFI_SUCCESS);
@@ -106,31 +116,33 @@ TrimSpaces( @param[in] FindString The string to look for
@param[in] CheckForEscapeCharacter TRUE to skip escaped instances of FinfString, otherwise will return even escaped instances
**/
-CHAR16*
-FindNextInstance(
+CHAR16 *
+FindNextInstance (
IN CONST CHAR16 *SourceString,
IN CONST CHAR16 *FindString,
IN CONST BOOLEAN CheckForEscapeCharacter
)
{
- CHAR16 *Temp;
+ CHAR16 *Temp;
+
if (SourceString == NULL) {
return (NULL);
}
- Temp = StrStr(SourceString, FindString);
+
+ Temp = StrStr (SourceString, FindString);
//
// If nothing found, or we don't care about escape characters
//
- if (Temp == NULL || !CheckForEscapeCharacter) {
+ if ((Temp == NULL) || !CheckForEscapeCharacter) {
return (Temp);
}
//
// If we found an escaped character, try again on the remainder of the string
//
- if ((Temp > (SourceString)) && *(Temp-1) == L'^') {
- return FindNextInstance(Temp+1, FindString, CheckForEscapeCharacter);
+ if ((Temp > (SourceString)) && (*(Temp-1) == L'^')) {
+ return FindNextInstance (Temp+1, FindString, CheckForEscapeCharacter);
}
//
@@ -149,12 +161,12 @@ FindNextInstance( @retval FALSE is NOT a valid environment variable name.
**/
BOOLEAN
-IsValidEnvironmentVariableName(
- IN CONST CHAR16 *BeginPercent,
- IN CONST CHAR16 *EndPercent
+IsValidEnvironmentVariableName (
+ IN CONST CHAR16 *BeginPercent,
+ IN CONST CHAR16 *EndPercent
)
{
- CONST CHAR16 *Walker;
+ CONST CHAR16 *Walker;
Walker = NULL;
@@ -168,12 +180,13 @@ IsValidEnvironmentVariableName( for (Walker = BeginPercent + 1; Walker < EndPercent; Walker++) {
if (
- (*Walker >= L'0' && *Walker <= L'9') ||
- (*Walker >= L'A' && *Walker <= L'Z') ||
- (*Walker >= L'a' && *Walker <= L'z') ||
+ ((*Walker >= L'0') && (*Walker <= L'9')) ||
+ ((*Walker >= L'A') && (*Walker <= L'Z')) ||
+ ((*Walker >= L'a') && (*Walker <= L'z')) ||
(*Walker == L'_')
- ) {
- if (Walker == BeginPercent + 1 && (*Walker >= L'0' && *Walker <= L'9')) {
+ )
+ {
+ if ((Walker == BeginPercent + 1) && ((*Walker >= L'0') && (*Walker <= L'9'))) {
return FALSE;
} else {
continue;
@@ -195,45 +208,48 @@ IsValidEnvironmentVariableName( @retval FALSE CmdLine does not have a valid split.
**/
BOOLEAN
-ContainsSplit(
- IN CONST CHAR16 *CmdLine
+ContainsSplit (
+ IN CONST CHAR16 *CmdLine
)
{
- CONST CHAR16 *TempSpot;
- CONST CHAR16 *FirstQuote;
- CONST CHAR16 *SecondQuote;
-
- FirstQuote = FindNextInstance (CmdLine, L"\"", TRUE);
- SecondQuote = NULL;
- TempSpot = FindFirstCharacter(CmdLine, L"|", L'^');
-
- if (FirstQuote == NULL ||
- TempSpot == NULL ||
- TempSpot == CHAR_NULL ||
- FirstQuote > TempSpot
- ) {
- return (BOOLEAN) ((TempSpot != NULL) && (*TempSpot != CHAR_NULL));
+ CONST CHAR16 *TempSpot;
+ CONST CHAR16 *FirstQuote;
+ CONST CHAR16 *SecondQuote;
+
+ FirstQuote = FindNextInstance (CmdLine, L"\"", TRUE);
+ SecondQuote = NULL;
+ TempSpot = FindFirstCharacter (CmdLine, L"|", L'^');
+
+ if ((FirstQuote == NULL) ||
+ (TempSpot == NULL) ||
+ (TempSpot == CHAR_NULL) ||
+ (FirstQuote > TempSpot)
+ )
+ {
+ return (BOOLEAN)((TempSpot != NULL) && (*TempSpot != CHAR_NULL));
}
while ((TempSpot != NULL) && (*TempSpot != CHAR_NULL)) {
- if (FirstQuote == NULL || FirstQuote > TempSpot) {
+ if ((FirstQuote == NULL) || (FirstQuote > TempSpot)) {
break;
}
+
SecondQuote = FindNextInstance (FirstQuote + 1, L"\"", TRUE);
if (SecondQuote == NULL) {
break;
}
+
if (SecondQuote < TempSpot) {
FirstQuote = FindNextInstance (SecondQuote + 1, L"\"", TRUE);
continue;
} else {
FirstQuote = FindNextInstance (SecondQuote + 1, L"\"", TRUE);
- TempSpot = FindFirstCharacter(TempSpot + 1, L"|", L'^');
+ TempSpot = FindFirstCharacter (TempSpot + 1, L"|", L'^');
continue;
}
}
- return (BOOLEAN) ((TempSpot != NULL) && (*TempSpot != CHAR_NULL));
+ return (BOOLEAN)((TempSpot != NULL) && (*TempSpot != CHAR_NULL));
}
/**
@@ -244,28 +260,30 @@ ContainsSplit( @retval EFI_OUT_OF_RESOURCES There is not enough memory available.
**/
EFI_STATUS
-InternalEfiShellStartCtrlSMonitor(
+InternalEfiShellStartCtrlSMonitor (
VOID
)
{
- EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *SimpleEx;
- EFI_KEY_DATA KeyData;
- EFI_STATUS Status;
-
- Status = gBS->OpenProtocol(
- gST->ConsoleInHandle,
- &gEfiSimpleTextInputExProtocolGuid,
- (VOID**)&SimpleEx,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(
+ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *SimpleEx;
+ EFI_KEY_DATA KeyData;
+ EFI_STATUS Status;
+
+ Status = gBS->OpenProtocol (
+ gST->ConsoleInHandle,
+ &gEfiSimpleTextInputExProtocolGuid,
+ (VOID **)&SimpleEx,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (
-1,
-1,
NULL,
STRING_TOKEN (STR_SHELL_NO_IN_EX),
- ShellInfoObject.HiiHandle);
+ ShellInfoObject.HiiHandle
+ );
return (EFI_SUCCESS);
}
@@ -274,42 +292,47 @@ InternalEfiShellStartCtrlSMonitor( KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED;
KeyData.Key.UnicodeChar = L's';
- Status = SimpleEx->RegisterKeyNotify(
- SimpleEx,
- &KeyData,
- NotificationFunction,
- &ShellInfoObject.CtrlSNotifyHandle1);
+ Status = SimpleEx->RegisterKeyNotify (
+ SimpleEx,
+ &KeyData,
+ NotificationFunction,
+ &ShellInfoObject.CtrlSNotifyHandle1
+ );
- KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED;
- if (!EFI_ERROR(Status)) {
- Status = SimpleEx->RegisterKeyNotify(
- SimpleEx,
- &KeyData,
- NotificationFunction,
- &ShellInfoObject.CtrlSNotifyHandle2);
+ KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED;
+ if (!EFI_ERROR (Status)) {
+ Status = SimpleEx->RegisterKeyNotify (
+ SimpleEx,
+ &KeyData,
+ NotificationFunction,
+ &ShellInfoObject.CtrlSNotifyHandle2
+ );
}
- KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED;
- KeyData.Key.UnicodeChar = 19;
-
- if (!EFI_ERROR(Status)) {
- Status = SimpleEx->RegisterKeyNotify(
- SimpleEx,
- &KeyData,
- NotificationFunction,
- &ShellInfoObject.CtrlSNotifyHandle3);
- }
- KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED;
- if (!EFI_ERROR(Status)) {
- Status = SimpleEx->RegisterKeyNotify(
- SimpleEx,
- &KeyData,
- NotificationFunction,
- &ShellInfoObject.CtrlSNotifyHandle4);
+
+ KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED;
+ KeyData.Key.UnicodeChar = 19;
+
+ if (!EFI_ERROR (Status)) {
+ Status = SimpleEx->RegisterKeyNotify (
+ SimpleEx,
+ &KeyData,
+ NotificationFunction,
+ &ShellInfoObject.CtrlSNotifyHandle3
+ );
}
- return (Status);
-}
+ KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED;
+ if (!EFI_ERROR (Status)) {
+ Status = SimpleEx->RegisterKeyNotify (
+ SimpleEx,
+ &KeyData,
+ NotificationFunction,
+ &ShellInfoObject.CtrlSNotifyHandle4
+ );
+ }
+ return (Status);
+}
/**
The entry point for the application.
@@ -335,46 +358,47 @@ UefiMain ( EFI_SIMPLE_TEXT_INPUT_PROTOCOL *OldConIn;
SPLIT_LIST *Split;
- if (PcdGet8(PcdShellSupportLevel) > 3) {
+ if (PcdGet8 (PcdShellSupportLevel) > 3) {
return (EFI_UNSUPPORTED);
}
//
// Clear the screen
//
- Status = gST->ConOut->ClearScreen(gST->ConOut);
- if (EFI_ERROR(Status)) {
+ Status = gST->ConOut->ClearScreen (gST->ConOut);
+ if (EFI_ERROR (Status)) {
return (Status);
}
//
// Populate the global structure from PCDs
//
- ShellInfoObject.ImageDevPath = NULL;
- ShellInfoObject.FileDevPath = NULL;
- ShellInfoObject.PageBreakEnabled = PcdGetBool(PcdShellPageBreakDefault);
- ShellInfoObject.ViewingSettings.InsertMode = PcdGetBool(PcdShellInsertModeDefault);
- ShellInfoObject.LogScreenCount = PcdGet8 (PcdShellScreenLogCount );
+ ShellInfoObject.ImageDevPath = NULL;
+ ShellInfoObject.FileDevPath = NULL;
+ ShellInfoObject.PageBreakEnabled = PcdGetBool (PcdShellPageBreakDefault);
+ ShellInfoObject.ViewingSettings.InsertMode = PcdGetBool (PcdShellInsertModeDefault);
+ ShellInfoObject.LogScreenCount = PcdGet8 (PcdShellScreenLogCount);
//
// verify we dont allow for spec violation
//
- ASSERT(ShellInfoObject.LogScreenCount >= 3);
+ ASSERT (ShellInfoObject.LogScreenCount >= 3);
//
// Initialize the LIST ENTRY objects...
//
- InitializeListHead(&ShellInfoObject.BufferToFreeList.Link);
- InitializeListHead(&ShellInfoObject.ViewingSettings.CommandHistory.Link);
- InitializeListHead(&ShellInfoObject.SplitList.Link);
+ InitializeListHead (&ShellInfoObject.BufferToFreeList.Link);
+ InitializeListHead (&ShellInfoObject.ViewingSettings.CommandHistory.Link);
+ InitializeListHead (&ShellInfoObject.SplitList.Link);
//
// Check PCDs for optional features that are not implemented yet.
//
- if ( PcdGetBool(PcdShellSupportOldProtocols)
- || !FeaturePcdGet(PcdShellRequireHiiPlatform)
- || FeaturePcdGet(PcdShellSupportFrameworkHii)
- ) {
+ if ( PcdGetBool (PcdShellSupportOldProtocols)
+ || !FeaturePcdGet (PcdShellRequireHiiPlatform)
+ || FeaturePcdGet (PcdShellSupportFrameworkHii)
+ )
+ {
return (EFI_UNSUPPORTED);
}
@@ -386,8 +410,8 @@ UefiMain ( //
// install our console logger. This will keep a log of the output for back-browsing
//
- Status = ConsoleLoggerInstall(ShellInfoObject.LogScreenCount, &ShellInfoObject.ConsoleInfo);
- if (!EFI_ERROR(Status)) {
+ Status = ConsoleLoggerInstall (ShellInfoObject.LogScreenCount, &ShellInfoObject.ConsoleInfo);
+ if (!EFI_ERROR (Status)) {
//
// Enable the cursor to be visible
//
@@ -398,16 +422,17 @@ UefiMain ( // only do this if PcdShellRequireHiiPlatform == FALSE
//
// remove EFI_UNSUPPORTED check above when complete.
- ///@todo add support for Framework HII
+ /// @todo add support for Framework HII
//
// install our (solitary) HII package
//
ShellInfoObject.HiiHandle = HiiAddPackages (&gEfiCallerIdGuid, gImageHandle, ShellStrings, NULL);
if (ShellInfoObject.HiiHandle == NULL) {
- if (PcdGetBool(PcdShellSupportFrameworkHii)) {
- ///@todo Add our package into Framework HII
+ if (PcdGetBool (PcdShellSupportFrameworkHii)) {
+ /// @todo Add our package into Framework HII
}
+
if (ShellInfoObject.HiiHandle == NULL) {
Status = EFI_NOT_STARTED;
goto FreeResources;
@@ -417,25 +442,25 @@ UefiMain ( //
// create and install the EfiShellParametersProtocol
//
- Status = CreatePopulateInstallShellParametersProtocol(&ShellInfoObject.NewShellParametersProtocol, &ShellInfoObject.RootShellInstance);
- ASSERT_EFI_ERROR(Status);
- ASSERT(ShellInfoObject.NewShellParametersProtocol != NULL);
+ Status = CreatePopulateInstallShellParametersProtocol (&ShellInfoObject.NewShellParametersProtocol, &ShellInfoObject.RootShellInstance);
+ ASSERT_EFI_ERROR (Status);
+ ASSERT (ShellInfoObject.NewShellParametersProtocol != NULL);
//
// create and install the EfiShellProtocol
//
- Status = CreatePopulateInstallShellProtocol(&ShellInfoObject.NewEfiShellProtocol);
- ASSERT_EFI_ERROR(Status);
- ASSERT(ShellInfoObject.NewEfiShellProtocol != NULL);
+ Status = CreatePopulateInstallShellProtocol (&ShellInfoObject.NewEfiShellProtocol);
+ ASSERT_EFI_ERROR (Status);
+ ASSERT (ShellInfoObject.NewEfiShellProtocol != NULL);
//
// Now initialize the shell library (it requires Shell Parameters protocol)
//
- Status = ShellInitialize();
- ASSERT_EFI_ERROR(Status);
+ Status = ShellInitialize ();
+ ASSERT_EFI_ERROR (Status);
- Status = CommandInit();
- ASSERT_EFI_ERROR(Status);
+ Status = CommandInit ();
+ ASSERT_EFI_ERROR (Status);
Status = ShellInitEnvVarList ();
@@ -450,39 +475,44 @@ UefiMain ( //
// If shell support level is >= 1 create the mappings and paths
//
- if (PcdGet8(PcdShellSupportLevel) >= 1) {
- Status = ShellCommandCreateInitialMappingsAndPaths();
+ if (PcdGet8 (PcdShellSupportLevel) >= 1) {
+ Status = ShellCommandCreateInitialMappingsAndPaths ();
}
//
// Set the environment variable for nesting support
//
- Size = 0;
+ Size = 0;
TempString = NULL;
if (!ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoNest) {
//
// No change. require nesting in Shell Protocol Execute()
//
- StrnCatGrow(&TempString,
- &Size,
- L"False",
- 0);
+ StrnCatGrow (
+ &TempString,
+ &Size,
+ L"False",
+ 0
+ );
} else {
- StrnCatGrow(&TempString,
- &Size,
- mNoNestingTrue,
- 0);
+ StrnCatGrow (
+ &TempString,
+ &Size,
+ mNoNestingTrue,
+ 0
+ );
}
- Status = InternalEfiShellSetEnv(mNoNestingEnvVarName, TempString, TRUE);
- SHELL_FREE_NON_NULL(TempString);
+
+ Status = InternalEfiShellSetEnv (mNoNestingEnvVarName, TempString, TRUE);
+ SHELL_FREE_NON_NULL (TempString);
Size = 0;
//
// save the device path for the loaded image and the device path for the filepath (under loaded image)
// These are where to look for the startup.nsh file
//
- Status = GetDevicePathsForImageAndFile(&ShellInfoObject.ImageDevPath, &ShellInfoObject.FileDevPath);
- ASSERT_EFI_ERROR(Status);
+ Status = GetDevicePathsForImageAndFile (&ShellInfoObject.ImageDevPath, &ShellInfoObject.FileDevPath);
+ ASSERT_EFI_ERROR (Status);
//
// Display the version
@@ -494,10 +524,10 @@ UefiMain ( NULL,
STRING_TOKEN (STR_VER_OUTPUT_MAIN_SHELL),
ShellInfoObject.HiiHandle,
- SupportLevel[PcdGet8(PcdShellSupportLevel)],
+ SupportLevel[PcdGet8 (PcdShellSupportLevel)],
gEfiShellProtocol->MajorVersion,
gEfiShellProtocol->MinorVersion
- );
+ );
ShellPrintHiiEx (
-1,
@@ -505,8 +535,8 @@ UefiMain ( NULL,
STRING_TOKEN (STR_VER_OUTPUT_MAIN_SUPPLIER),
ShellInfoObject.HiiHandle,
- (CHAR16 *) PcdGetPtr (PcdShellSupplier)
- );
+ (CHAR16 *)PcdGetPtr (PcdShellSupplier)
+ );
ShellPrintHiiEx (
-1,
@@ -518,83 +548,83 @@ UefiMain ( (gST->Hdr.Revision&0x0000ffff),
gST->FirmwareVendor,
gST->FirmwareRevision
- );
+ );
}
//
// Display the mapping
//
- if (PcdGet8(PcdShellSupportLevel) >= 2 && !ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoMap) {
- Status = RunCommand(L"map");
- ASSERT_EFI_ERROR(Status);
+ if ((PcdGet8 (PcdShellSupportLevel) >= 2) && !ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoMap) {
+ Status = RunCommand (L"map");
+ ASSERT_EFI_ERROR (Status);
}
//
// init all the built in alias'
//
- Status = SetBuiltInAlias();
- ASSERT_EFI_ERROR(Status);
+ Status = SetBuiltInAlias ();
+ ASSERT_EFI_ERROR (Status);
//
// Initialize environment variables
//
- if (ShellCommandGetProfileList() != NULL) {
- Status = InternalEfiShellSetEnv(L"profiles", ShellCommandGetProfileList(), TRUE);
- ASSERT_EFI_ERROR(Status);
+ if (ShellCommandGetProfileList () != NULL) {
+ Status = InternalEfiShellSetEnv (L"profiles", ShellCommandGetProfileList (), TRUE);
+ ASSERT_EFI_ERROR (Status);
}
- Size = 100;
- TempString = AllocateZeroPool(Size);
+ Size = 100;
+ TempString = AllocateZeroPool (Size);
- UnicodeSPrint(TempString, Size, L"%d", PcdGet8(PcdShellSupportLevel));
- Status = InternalEfiShellSetEnv(L"uefishellsupport", TempString, TRUE);
- ASSERT_EFI_ERROR(Status);
+ UnicodeSPrint (TempString, Size, L"%d", PcdGet8 (PcdShellSupportLevel));
+ Status = InternalEfiShellSetEnv (L"uefishellsupport", TempString, TRUE);
+ ASSERT_EFI_ERROR (Status);
- UnicodeSPrint(TempString, Size, L"%d.%d", ShellInfoObject.NewEfiShellProtocol->MajorVersion, ShellInfoObject.NewEfiShellProtocol->MinorVersion);
- Status = InternalEfiShellSetEnv(L"uefishellversion", TempString, TRUE);
- ASSERT_EFI_ERROR(Status);
+ UnicodeSPrint (TempString, Size, L"%d.%d", ShellInfoObject.NewEfiShellProtocol->MajorVersion, ShellInfoObject.NewEfiShellProtocol->MinorVersion);
+ Status = InternalEfiShellSetEnv (L"uefishellversion", TempString, TRUE);
+ ASSERT_EFI_ERROR (Status);
- UnicodeSPrint(TempString, Size, L"%d.%d", (gST->Hdr.Revision & 0xFFFF0000) >> 16, gST->Hdr.Revision & 0x0000FFFF);
- Status = InternalEfiShellSetEnv(L"uefiversion", TempString, TRUE);
- ASSERT_EFI_ERROR(Status);
+ UnicodeSPrint (TempString, Size, L"%d.%d", (gST->Hdr.Revision & 0xFFFF0000) >> 16, gST->Hdr.Revision & 0x0000FFFF);
+ Status = InternalEfiShellSetEnv (L"uefiversion", TempString, TRUE);
+ ASSERT_EFI_ERROR (Status);
- FreePool(TempString);
+ FreePool (TempString);
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
if (!ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoInterrupt) {
//
// Set up the event for CTRL-C monitoring...
//
- Status = InernalEfiShellStartMonitor();
+ Status = InernalEfiShellStartMonitor ();
}
- if (!EFI_ERROR(Status) && !ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleIn) {
+ if (!EFI_ERROR (Status) && !ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleIn) {
//
// Set up the event for CTRL-S monitoring...
//
- Status = InternalEfiShellStartCtrlSMonitor();
+ Status = InternalEfiShellStartCtrlSMonitor ();
}
- if (!EFI_ERROR(Status) && ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleIn) {
+ if (!EFI_ERROR (Status) && ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleIn) {
//
// close off the gST->ConIn
//
- OldConIn = gST->ConIn;
- ConInHandle = gST->ConsoleInHandle;
- gST->ConIn = CreateSimpleTextInOnFile((SHELL_FILE_HANDLE)&FileInterfaceNulFile, &gST->ConsoleInHandle);
+ OldConIn = gST->ConIn;
+ ConInHandle = gST->ConsoleInHandle;
+ gST->ConIn = CreateSimpleTextInOnFile ((SHELL_FILE_HANDLE)&FileInterfaceNulFile, &gST->ConsoleInHandle);
} else {
- OldConIn = NULL;
- ConInHandle = NULL;
+ OldConIn = NULL;
+ ConInHandle = NULL;
}
- if (!EFI_ERROR(Status) && PcdGet8(PcdShellSupportLevel) >= 1) {
+ if (!EFI_ERROR (Status) && (PcdGet8 (PcdShellSupportLevel) >= 1)) {
//
// process the startup script or launch the called app.
//
- Status = DoStartupScript(ShellInfoObject.ImageDevPath, ShellInfoObject.FileDevPath);
+ Status = DoStartupScript (ShellInfoObject.ImageDevPath, ShellInfoObject.FileDevPath);
}
- if (!ShellInfoObject.ShellInitSettings.BitUnion.Bits.Exit && !ShellCommandGetExit() && (PcdGet8(PcdShellSupportLevel) >= 3 || PcdGetBool(PcdShellForceConsole)) && !EFI_ERROR(Status) && !ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleIn) {
+ if (!ShellInfoObject.ShellInitSettings.BitUnion.Bits.Exit && !ShellCommandGetExit () && ((PcdGet8 (PcdShellSupportLevel) >= 3) || PcdGetBool (PcdShellForceConsole)) && !EFI_ERROR (Status) && !ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleIn) {
//
// begin the UI waiting loop
//
@@ -603,14 +633,14 @@ UefiMain ( // clean out all the memory allocated for CONST <something> * return values
// between each shell prompt presentation
//
- if (!IsListEmpty(&ShellInfoObject.BufferToFreeList.Link)){
- FreeBufferList(&ShellInfoObject.BufferToFreeList);
+ if (!IsListEmpty (&ShellInfoObject.BufferToFreeList.Link)) {
+ FreeBufferList (&ShellInfoObject.BufferToFreeList);
}
//
// Reset page break back to default.
//
- ShellInfoObject.PageBreakEnabled = PcdGetBool(PcdShellPageBreakDefault);
+ ShellInfoObject.PageBreakEnabled = PcdGetBool (PcdShellPageBreakDefault);
ASSERT (ShellInfoObject.ConsoleInfo != NULL);
ShellInfoObject.ConsoleInfo->Enabled = TRUE;
ShellInfoObject.ConsoleInfo->RowCounter = 0;
@@ -618,13 +648,14 @@ UefiMain ( //
// Display Prompt
//
- Status = DoShellPrompt();
- } while (!ShellCommandGetExit());
+ Status = DoShellPrompt ();
+ } while (!ShellCommandGetExit ());
}
- if (OldConIn != NULL && ConInHandle != NULL) {
+
+ if ((OldConIn != NULL) && (ConInHandle != NULL)) {
CloseSimpleTextInOnFile (gST->ConIn);
- gST->ConIn = OldConIn;
- gST->ConsoleInHandle = ConInHandle;
+ gST->ConIn = OldConIn;
+ gST->ConsoleInHandle = ConInHandle;
}
}
}
@@ -634,78 +665,105 @@ FreeResources: // uninstall protocols / free memory / etc...
//
if (ShellInfoObject.UserBreakTimer != NULL) {
- gBS->CloseEvent(ShellInfoObject.UserBreakTimer);
- DEBUG_CODE(ShellInfoObject.UserBreakTimer = NULL;);
+ gBS->CloseEvent (ShellInfoObject.UserBreakTimer);
+ DEBUG_CODE (
+ ShellInfoObject.UserBreakTimer = NULL;
+ );
}
+
if (ShellInfoObject.ImageDevPath != NULL) {
- FreePool(ShellInfoObject.ImageDevPath);
- DEBUG_CODE(ShellInfoObject.ImageDevPath = NULL;);
+ FreePool (ShellInfoObject.ImageDevPath);
+ DEBUG_CODE (
+ ShellInfoObject.ImageDevPath = NULL;
+ );
}
+
if (ShellInfoObject.FileDevPath != NULL) {
- FreePool(ShellInfoObject.FileDevPath);
- DEBUG_CODE(ShellInfoObject.FileDevPath = NULL;);
+ FreePool (ShellInfoObject.FileDevPath);
+ DEBUG_CODE (
+ ShellInfoObject.FileDevPath = NULL;
+ );
}
+
if (ShellInfoObject.NewShellParametersProtocol != NULL) {
- CleanUpShellParametersProtocol(ShellInfoObject.NewShellParametersProtocol);
- DEBUG_CODE(ShellInfoObject.NewShellParametersProtocol = NULL;);
+ CleanUpShellParametersProtocol (ShellInfoObject.NewShellParametersProtocol);
+ DEBUG_CODE (
+ ShellInfoObject.NewShellParametersProtocol = NULL;
+ );
}
- if (ShellInfoObject.NewEfiShellProtocol != NULL){
- if (ShellInfoObject.NewEfiShellProtocol->IsRootShell()){
- InternalEfiShellSetEnv(L"cwd", NULL, TRUE);
+
+ if (ShellInfoObject.NewEfiShellProtocol != NULL) {
+ if (ShellInfoObject.NewEfiShellProtocol->IsRootShell ()) {
+ InternalEfiShellSetEnv (L"cwd", NULL, TRUE);
}
+
CleanUpShellEnvironment (ShellInfoObject.NewEfiShellProtocol);
- DEBUG_CODE(ShellInfoObject.NewEfiShellProtocol = NULL;);
+ DEBUG_CODE (
+ ShellInfoObject.NewEfiShellProtocol = NULL;
+ );
}
- if (!IsListEmpty(&ShellInfoObject.BufferToFreeList.Link)){
- FreeBufferList(&ShellInfoObject.BufferToFreeList);
+ if (!IsListEmpty (&ShellInfoObject.BufferToFreeList.Link)) {
+ FreeBufferList (&ShellInfoObject.BufferToFreeList);
}
- if (!IsListEmpty(&ShellInfoObject.SplitList.Link)){
- ASSERT(FALSE); ///@todo finish this de-allocation (free SplitStdIn/Out when needed).
+ if (!IsListEmpty (&ShellInfoObject.SplitList.Link)) {
+ ASSERT (FALSE); /// @todo finish this de-allocation (free SplitStdIn/Out when needed).
- for ( Split = (SPLIT_LIST*)GetFirstNode (&ShellInfoObject.SplitList.Link)
- ; !IsNull (&ShellInfoObject.SplitList.Link, &Split->Link)
- ; Split = (SPLIT_LIST *)GetNextNode (&ShellInfoObject.SplitList.Link, &Split->Link)
- ) {
+ for ( Split = (SPLIT_LIST *)GetFirstNode (&ShellInfoObject.SplitList.Link)
+ ; !IsNull (&ShellInfoObject.SplitList.Link, &Split->Link)
+ ; Split = (SPLIT_LIST *)GetNextNode (&ShellInfoObject.SplitList.Link, &Split->Link)
+ )
+ {
RemoveEntryList (&Split->Link);
FreePool (Split);
}
- DEBUG_CODE (InitializeListHead (&ShellInfoObject.SplitList.Link););
+ DEBUG_CODE (
+ InitializeListHead (&ShellInfoObject.SplitList.Link);
+ );
}
if (ShellInfoObject.ShellInitSettings.FileName != NULL) {
- FreePool(ShellInfoObject.ShellInitSettings.FileName);
- DEBUG_CODE(ShellInfoObject.ShellInitSettings.FileName = NULL;);
+ FreePool (ShellInfoObject.ShellInitSettings.FileName);
+ DEBUG_CODE (
+ ShellInfoObject.ShellInitSettings.FileName = NULL;
+ );
}
if (ShellInfoObject.ShellInitSettings.FileOptions != NULL) {
- FreePool(ShellInfoObject.ShellInitSettings.FileOptions);
- DEBUG_CODE(ShellInfoObject.ShellInitSettings.FileOptions = NULL;);
+ FreePool (ShellInfoObject.ShellInitSettings.FileOptions);
+ DEBUG_CODE (
+ ShellInfoObject.ShellInitSettings.FileOptions = NULL;
+ );
}
if (ShellInfoObject.HiiHandle != NULL) {
- HiiRemovePackages(ShellInfoObject.HiiHandle);
- DEBUG_CODE(ShellInfoObject.HiiHandle = NULL;);
+ HiiRemovePackages (ShellInfoObject.HiiHandle);
+ DEBUG_CODE (
+ ShellInfoObject.HiiHandle = NULL;
+ );
}
- if (!IsListEmpty(&ShellInfoObject.ViewingSettings.CommandHistory.Link)){
- FreeBufferList(&ShellInfoObject.ViewingSettings.CommandHistory);
+ if (!IsListEmpty (&ShellInfoObject.ViewingSettings.CommandHistory.Link)) {
+ FreeBufferList (&ShellInfoObject.ViewingSettings.CommandHistory);
}
- ASSERT(ShellInfoObject.ConsoleInfo != NULL);
+ ASSERT (ShellInfoObject.ConsoleInfo != NULL);
if (ShellInfoObject.ConsoleInfo != NULL) {
- ConsoleLoggerUninstall(ShellInfoObject.ConsoleInfo);
- FreePool(ShellInfoObject.ConsoleInfo);
- DEBUG_CODE(ShellInfoObject.ConsoleInfo = NULL;);
+ ConsoleLoggerUninstall (ShellInfoObject.ConsoleInfo);
+ FreePool (ShellInfoObject.ConsoleInfo);
+ DEBUG_CODE (
+ ShellInfoObject.ConsoleInfo = NULL;
+ );
}
ShellFreeEnvVarList ();
- if (ShellCommandGetExit()) {
- return ((EFI_STATUS)ShellCommandGetExitCode());
+ if (ShellCommandGetExit ()) {
+ return ((EFI_STATUS)ShellCommandGetExitCode ());
}
+
return (Status);
}
@@ -715,32 +773,34 @@ FreeResources: @retval EFI_SUCCESS all init commands were run successfully.
**/
EFI_STATUS
-SetBuiltInAlias(
+SetBuiltInAlias (
VOID
)
{
- EFI_STATUS Status;
- CONST ALIAS_LIST *List;
- ALIAS_LIST *Node;
+ EFI_STATUS Status;
+ CONST ALIAS_LIST *List;
+ ALIAS_LIST *Node;
//
// Get all the commands we want to run
//
- List = ShellCommandGetInitAliasList();
+ List = ShellCommandGetInitAliasList ();
//
// for each command in the List
//
- for ( Node = (ALIAS_LIST*)GetFirstNode(&List->Link)
- ; !IsNull (&List->Link, &Node->Link)
- ; Node = (ALIAS_LIST *)GetNextNode(&List->Link, &Node->Link)
- ){
+ for ( Node = (ALIAS_LIST *)GetFirstNode (&List->Link)
+ ; !IsNull (&List->Link, &Node->Link)
+ ; Node = (ALIAS_LIST *)GetNextNode (&List->Link, &Node->Link)
+ )
+ {
//
// install the alias'
//
- Status = InternalSetAlias(Node->CommandString, Node->Alias, TRUE);
- ASSERT_EFI_ERROR(Status);
+ Status = InternalSetAlias (Node->CommandString, Node->Alias, TRUE);
+ ASSERT_EFI_ERROR (Status);
}
+
return (EFI_SUCCESS);
}
@@ -754,14 +814,15 @@ SetBuiltInAlias( @retval FALSE The 2 command names are not the same.
**/
BOOLEAN
-IsCommand(
- IN CONST CHAR16 *Command1,
- IN CONST CHAR16 *Command2
+IsCommand (
+ IN CONST CHAR16 *Command1,
+ IN CONST CHAR16 *Command2
)
{
- if (StringNoCaseCompare(&Command1, &Command2) == 0) {
+ if (StringNoCaseCompare (&Command1, &Command2) == 0) {
return (TRUE);
}
+
return (FALSE);
}
@@ -774,18 +835,20 @@ IsCommand( @retval FALSE The command is not a script only command.
**/
BOOLEAN
-IsScriptOnlyCommand(
- IN CONST CHAR16 *CommandName
+IsScriptOnlyCommand (
+ IN CONST CHAR16 *CommandName
)
{
- if (IsCommand(CommandName, L"for")
- ||IsCommand(CommandName, L"endfor")
- ||IsCommand(CommandName, L"if")
- ||IsCommand(CommandName, L"else")
- ||IsCommand(CommandName, L"endif")
- ||IsCommand(CommandName, L"goto")) {
+ if ( IsCommand (CommandName, L"for")
+ || IsCommand (CommandName, L"endfor")
+ || IsCommand (CommandName, L"if")
+ || IsCommand (CommandName, L"else")
+ || IsCommand (CommandName, L"endif")
+ || IsCommand (CommandName, L"goto"))
+ {
return (TRUE);
}
+
return (FALSE);
}
@@ -805,49 +868,53 @@ IsScriptOnlyCommand( **/
EFI_STATUS
GetDevicePathsForImageAndFile (
- IN OUT EFI_DEVICE_PATH_PROTOCOL **DevPath,
- IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevPath,
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath
)
{
- EFI_STATUS Status;
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
- EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
+ EFI_STATUS Status;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+ EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
- ASSERT(DevPath != NULL);
- ASSERT(FilePath != NULL);
+ ASSERT (DevPath != NULL);
+ ASSERT (FilePath != NULL);
Status = gBS->OpenProtocol (
- gImageHandle,
- &gEfiLoadedImageProtocolGuid,
- (VOID**)&LoadedImage,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (!EFI_ERROR (Status)) {
- Status = gBS->OpenProtocol (
- LoadedImage->DeviceHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID**)&ImageDevicePath,
+ gImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **)&LoadedImage,
gImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
+ );
+ if (!EFI_ERROR (Status)) {
+ Status = gBS->OpenProtocol (
+ LoadedImage->DeviceHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **)&ImageDevicePath,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
if (!EFI_ERROR (Status)) {
*DevPath = DuplicateDevicePath (ImageDevicePath);
*FilePath = DuplicateDevicePath (LoadedImage->FilePath);
- gBS->CloseProtocol(
- LoadedImage->DeviceHandle,
- &gEfiDevicePathProtocolGuid,
- gImageHandle,
- NULL);
- }
- gBS->CloseProtocol(
- gImageHandle,
- &gEfiLoadedImageProtocolGuid,
- gImageHandle,
- NULL);
+ gBS->CloseProtocol (
+ LoadedImage->DeviceHandle,
+ &gEfiDevicePathProtocolGuid,
+ gImageHandle,
+ NULL
+ );
+ }
+
+ gBS->CloseProtocol (
+ gImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ gImageHandle,
+ NULL
+ );
}
+
return (Status);
}
@@ -879,7 +946,7 @@ GetDevicePathsForImageAndFile ( @retval EFI_SUCCESS The variable is initialized.
**/
EFI_STATUS
-ProcessCommandLine(
+ProcessCommandLine (
VOID
)
{
@@ -899,13 +966,13 @@ ProcessCommandLine( Status = gBS->LocateProtocol (
&gEfiUnicodeCollation2ProtocolGuid,
NULL,
- (VOID **) &UnicodeCollation
+ (VOID **)&UnicodeCollation
);
if (EFI_ERROR (Status)) {
Status = gBS->LocateProtocol (
&gEfiUnicodeCollationProtocolGuid,
NULL,
- (VOID **) &UnicodeCollation
+ (VOID **)&UnicodeCollation
);
if (EFI_ERROR (Status)) {
return Status;
@@ -923,7 +990,7 @@ ProcessCommandLine( ShellInfoObject.ShellInitSettings.BitUnion.Bits.Delay = FALSE;
ShellInfoObject.ShellInitSettings.BitUnion.Bits.Exit = FALSE;
ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoNest = FALSE;
- ShellInfoObject.ShellInitSettings.Delay = 5;
+ ShellInfoObject.ShellInitSettings.Delay = 5;
//
// Start LoopVar at 0 to parse only optional arguments at Argv[0]
@@ -931,86 +998,92 @@ ProcessCommandLine( // UEFI Shell boot option is created, and OptionalData is provided
// that starts with shell command-line options.
//
- for (LoopVar = 0 ; LoopVar < gEfiShellParametersProtocol->Argc ; LoopVar++) {
+ for (LoopVar = 0; LoopVar < gEfiShellParametersProtocol->Argc; LoopVar++) {
CurrentArg = gEfiShellParametersProtocol->Argv[LoopVar];
if (UnicodeCollation->StriColl (
UnicodeCollation,
L"-startup",
CurrentArg
- ) == 0) {
- ShellInfoObject.ShellInitSettings.BitUnion.Bits.Startup = TRUE;
- }
- else if (UnicodeCollation->StriColl (
- UnicodeCollation,
- L"-nostartup",
- CurrentArg
- ) == 0) {
- ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoStartup = TRUE;
- }
- else if (UnicodeCollation->StriColl (
- UnicodeCollation,
- L"-noconsoleout",
- CurrentArg
- ) == 0) {
+ ) == 0)
+ {
+ ShellInfoObject.ShellInitSettings.BitUnion.Bits.Startup = TRUE;
+ } else if (UnicodeCollation->StriColl (
+ UnicodeCollation,
+ L"-nostartup",
+ CurrentArg
+ ) == 0)
+ {
+ ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoStartup = TRUE;
+ } else if (UnicodeCollation->StriColl (
+ UnicodeCollation,
+ L"-noconsoleout",
+ CurrentArg
+ ) == 0)
+ {
ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleOut = TRUE;
- }
- else if (UnicodeCollation->StriColl (
- UnicodeCollation,
- L"-noconsolein",
- CurrentArg
- ) == 0) {
- ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleIn = TRUE;
- }
- else if (UnicodeCollation->StriColl (
- UnicodeCollation,
- L"-nointerrupt",
- CurrentArg
- ) == 0) {
- ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoInterrupt = TRUE;
- }
- else if (UnicodeCollation->StriColl (
- UnicodeCollation,
- L"-nomap",
- CurrentArg
- ) == 0) {
- ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoMap = TRUE;
- }
- else if (UnicodeCollation->StriColl (
- UnicodeCollation,
- L"-noversion",
- CurrentArg
- ) == 0) {
- ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoVersion = TRUE;
- }
- else if (UnicodeCollation->StriColl (
- UnicodeCollation,
- L"-nonest",
- CurrentArg
- ) == 0) {
- ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoNest = TRUE;
- }
- else if (UnicodeCollation->StriColl (
- UnicodeCollation,
- L"-delay",
- CurrentArg
- ) == 0) {
- ShellInfoObject.ShellInitSettings.BitUnion.Bits.Delay = TRUE;
+ } else if (UnicodeCollation->StriColl (
+ UnicodeCollation,
+ L"-noconsolein",
+ CurrentArg
+ ) == 0)
+ {
+ ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleIn = TRUE;
+ } else if (UnicodeCollation->StriColl (
+ UnicodeCollation,
+ L"-nointerrupt",
+ CurrentArg
+ ) == 0)
+ {
+ ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoInterrupt = TRUE;
+ } else if (UnicodeCollation->StriColl (
+ UnicodeCollation,
+ L"-nomap",
+ CurrentArg
+ ) == 0)
+ {
+ ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoMap = TRUE;
+ } else if (UnicodeCollation->StriColl (
+ UnicodeCollation,
+ L"-noversion",
+ CurrentArg
+ ) == 0)
+ {
+ ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoVersion = TRUE;
+ } else if (UnicodeCollation->StriColl (
+ UnicodeCollation,
+ L"-nonest",
+ CurrentArg
+ ) == 0)
+ {
+ ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoNest = TRUE;
+ } else if (UnicodeCollation->StriColl (
+ UnicodeCollation,
+ L"-delay",
+ CurrentArg
+ ) == 0)
+ {
+ ShellInfoObject.ShellInitSettings.BitUnion.Bits.Delay = TRUE;
// Check for optional delay value following "-delay"
if ((LoopVar + 1) >= gEfiShellParametersProtocol->Argc) {
DelayValueStr = NULL;
} else {
DelayValueStr = gEfiShellParametersProtocol->Argv[LoopVar + 1];
}
- if (DelayValueStr != NULL){
+
+ if (DelayValueStr != NULL) {
if (*DelayValueStr == L':') {
DelayValueStr++;
}
- if (!EFI_ERROR(ShellConvertStringToUint64 (
- DelayValueStr,
- &DelayValue,
- FALSE,
- FALSE
- ))) {
+
+ if (!EFI_ERROR (
+ ShellConvertStringToUint64 (
+ DelayValueStr,
+ &DelayValue,
+ FALSE,
+ FALSE
+ )
+ ))
+ {
ShellInfoObject.ShellInitSettings.Delay = (UINTN)DelayValue;
LoopVar++;
}
@@ -1019,11 +1092,15 @@ ProcessCommandLine( UnicodeCollation,
L"-exit",
CurrentArg
- ) == 0) {
- ShellInfoObject.ShellInitSettings.BitUnion.Bits.Exit = TRUE;
+ ) == 0)
+ {
+ ShellInfoObject.ShellInitSettings.BitUnion.Bits.Exit = TRUE;
} else if (StrnCmp (L"-", CurrentArg, 1) == 0) {
// Unrecognized option
- ShellPrintHiiEx(-1, -1, NULL,
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
STRING_TOKEN (STR_GEN_PROBLEM),
ShellInfoObject.HiiHandle,
CurrentArg
@@ -1038,29 +1115,32 @@ ProcessCommandLine( }
ShellInfoObject.ShellInitSettings.FileName = NULL;
- Size = 0;
+ Size = 0;
//
// If first argument contains a space, then add double quotes before the argument
//
if (StrStr (CurrentArg, L" ") != NULL) {
- StrnCatGrow(&ShellInfoObject.ShellInitSettings.FileName, &Size, L"\"", 0);
+ StrnCatGrow (&ShellInfoObject.ShellInitSettings.FileName, &Size, L"\"", 0);
if (ShellInfoObject.ShellInitSettings.FileName == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
}
- StrnCatGrow(&ShellInfoObject.ShellInitSettings.FileName, &Size, CurrentArg, 0);
+
+ StrnCatGrow (&ShellInfoObject.ShellInitSettings.FileName, &Size, CurrentArg, 0);
if (ShellInfoObject.ShellInitSettings.FileName == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
+
//
// If first argument contains a space, then add double quotes after the argument
//
if (StrStr (CurrentArg, L" ") != NULL) {
- StrnCatGrow(&ShellInfoObject.ShellInitSettings.FileName, &Size, L"\"", 0);
+ StrnCatGrow (&ShellInfoObject.ShellInitSettings.FileName, &Size, L"\"", 0);
if (ShellInfoObject.ShellInitSettings.FileName == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
}
+
//
// We found `file-name`.
//
@@ -1068,49 +1148,58 @@ ProcessCommandLine( LoopVar++;
// Add `file-name-options`
- for (Size = 0 ; LoopVar < gEfiShellParametersProtocol->Argc ; LoopVar++) {
- ASSERT((ShellInfoObject.ShellInitSettings.FileOptions == NULL && Size == 0) || (ShellInfoObject.ShellInitSettings.FileOptions != NULL));
+ for (Size = 0; LoopVar < gEfiShellParametersProtocol->Argc; LoopVar++) {
+ ASSERT ((ShellInfoObject.ShellInitSettings.FileOptions == NULL && Size == 0) || (ShellInfoObject.ShellInitSettings.FileOptions != NULL));
//
// Add a space between arguments
//
if (ShellInfoObject.ShellInitSettings.FileOptions != NULL) {
- StrnCatGrow(&ShellInfoObject.ShellInitSettings.FileOptions, &Size, L" ", 0);
+ StrnCatGrow (&ShellInfoObject.ShellInitSettings.FileOptions, &Size, L" ", 0);
if (ShellInfoObject.ShellInitSettings.FileOptions == NULL) {
- SHELL_FREE_NON_NULL(ShellInfoObject.ShellInitSettings.FileName);
+ SHELL_FREE_NON_NULL (ShellInfoObject.ShellInitSettings.FileName);
return (EFI_OUT_OF_RESOURCES);
}
}
+
//
// If an argument contains a space, then add double quotes before the argument
//
if (StrStr (gEfiShellParametersProtocol->Argv[LoopVar], L" ") != NULL) {
- StrnCatGrow(&ShellInfoObject.ShellInitSettings.FileOptions,
- &Size,
- L"\"",
- 0);
+ StrnCatGrow (
+ &ShellInfoObject.ShellInitSettings.FileOptions,
+ &Size,
+ L"\"",
+ 0
+ );
if (ShellInfoObject.ShellInitSettings.FileOptions == NULL) {
- SHELL_FREE_NON_NULL(ShellInfoObject.ShellInitSettings.FileName);
+ SHELL_FREE_NON_NULL (ShellInfoObject.ShellInitSettings.FileName);
return (EFI_OUT_OF_RESOURCES);
}
}
- StrnCatGrow(&ShellInfoObject.ShellInitSettings.FileOptions,
- &Size,
- gEfiShellParametersProtocol->Argv[LoopVar],
- 0);
+
+ StrnCatGrow (
+ &ShellInfoObject.ShellInitSettings.FileOptions,
+ &Size,
+ gEfiShellParametersProtocol->Argv[LoopVar],
+ 0
+ );
if (ShellInfoObject.ShellInitSettings.FileOptions == NULL) {
- SHELL_FREE_NON_NULL(ShellInfoObject.ShellInitSettings.FileName);
+ SHELL_FREE_NON_NULL (ShellInfoObject.ShellInitSettings.FileName);
return (EFI_OUT_OF_RESOURCES);
}
+
//
// If an argument contains a space, then add double quotes after the argument
//
if (StrStr (gEfiShellParametersProtocol->Argv[LoopVar], L" ") != NULL) {
- StrnCatGrow(&ShellInfoObject.ShellInitSettings.FileOptions,
- &Size,
- L"\"",
- 0);
+ StrnCatGrow (
+ &ShellInfoObject.ShellInitSettings.FileOptions,
+ &Size,
+ L"\"",
+ 0
+ );
if (ShellInfoObject.ShellInitSettings.FileOptions == NULL) {
- SHELL_FREE_NON_NULL(ShellInfoObject.ShellInitSettings.FileName);
+ SHELL_FREE_NON_NULL (ShellInfoObject.ShellInitSettings.FileName);
return (EFI_OUT_OF_RESOURCES);
}
}
@@ -1139,14 +1228,14 @@ ProcessCommandLine( **/
CHAR16 *
LocateStartupScript (
- IN EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath,
- IN EFI_DEVICE_PATH_PROTOCOL *FileDevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath,
+ IN EFI_DEVICE_PATH_PROTOCOL *FileDevicePath
)
{
- CHAR16 *StartupScriptPath;
- CHAR16 *TempSpot;
- CONST CHAR16 *MapName;
- UINTN Size;
+ CHAR16 *StartupScriptPath;
+ CHAR16 *TempSpot;
+ CONST CHAR16 *MapName;
+ UINTN Size;
StartupScriptPath = NULL;
Size = 0;
@@ -1163,12 +1252,13 @@ LocateStartupScript ( //
return NULL;
}
+
TempSpot = StrStr (StartupScriptPath, L";");
if (TempSpot != NULL) {
*TempSpot = CHAR_NULL;
}
- InternalEfiShellSetEnv(L"homefilesystem", StartupScriptPath, TRUE);
+ InternalEfiShellSetEnv (L"homefilesystem", StartupScriptPath, TRUE);
StartupScriptPath = StrnCatGrow (&StartupScriptPath, &Size, ((FILEPATH_DEVICE_PATH *)FileDevicePath)->PathName, 0);
PathRemoveLastItem (StartupScriptPath);
@@ -1197,91 +1287,98 @@ LocateStartupScript ( @retval EFI_SUCCESS the variable is initialized.
**/
EFI_STATUS
-DoStartupScript(
- IN EFI_DEVICE_PATH_PROTOCOL *ImagePath,
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath
+DoStartupScript (
+ IN EFI_DEVICE_PATH_PROTOCOL *ImagePath,
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath
)
{
- EFI_STATUS Status;
- EFI_STATUS CalleeStatus;
- UINTN Delay;
- EFI_INPUT_KEY Key;
- CHAR16 *FileStringPath;
- CHAR16 *FullFileStringPath;
- UINTN NewSize;
+ EFI_STATUS Status;
+ EFI_STATUS CalleeStatus;
+ UINTN Delay;
+ EFI_INPUT_KEY Key;
+ CHAR16 *FileStringPath;
+ CHAR16 *FullFileStringPath;
+ UINTN NewSize;
Key.UnicodeChar = CHAR_NULL;
Key.ScanCode = 0;
- if (!ShellInfoObject.ShellInitSettings.BitUnion.Bits.Startup && ShellInfoObject.ShellInitSettings.FileName != NULL) {
+ if (!ShellInfoObject.ShellInitSettings.BitUnion.Bits.Startup && (ShellInfoObject.ShellInitSettings.FileName != NULL)) {
//
// launch something else instead
//
- NewSize = StrSize(ShellInfoObject.ShellInitSettings.FileName);
+ NewSize = StrSize (ShellInfoObject.ShellInitSettings.FileName);
if (ShellInfoObject.ShellInitSettings.FileOptions != NULL) {
- NewSize += StrSize(ShellInfoObject.ShellInitSettings.FileOptions) + sizeof(CHAR16);
+ NewSize += StrSize (ShellInfoObject.ShellInitSettings.FileOptions) + sizeof (CHAR16);
}
- FileStringPath = AllocateZeroPool(NewSize);
+
+ FileStringPath = AllocateZeroPool (NewSize);
if (FileStringPath == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
- StrCpyS(FileStringPath, NewSize/sizeof(CHAR16), ShellInfoObject.ShellInitSettings.FileName);
+
+ StrCpyS (FileStringPath, NewSize/sizeof (CHAR16), ShellInfoObject.ShellInitSettings.FileName);
if (ShellInfoObject.ShellInitSettings.FileOptions != NULL) {
- StrnCatS(FileStringPath, NewSize/sizeof(CHAR16), L" ", NewSize/sizeof(CHAR16) - StrLen(FileStringPath) -1);
- StrnCatS(FileStringPath, NewSize/sizeof(CHAR16), ShellInfoObject.ShellInitSettings.FileOptions, NewSize/sizeof(CHAR16) - StrLen(FileStringPath) -1);
+ StrnCatS (FileStringPath, NewSize/sizeof (CHAR16), L" ", NewSize/sizeof (CHAR16) - StrLen (FileStringPath) -1);
+ StrnCatS (FileStringPath, NewSize/sizeof (CHAR16), ShellInfoObject.ShellInitSettings.FileOptions, NewSize/sizeof (CHAR16) - StrLen (FileStringPath) -1);
}
- Status = RunShellCommand(FileStringPath, &CalleeStatus);
+
+ Status = RunShellCommand (FileStringPath, &CalleeStatus);
if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.Exit == TRUE) {
- ShellCommandRegisterExit(gEfiShellProtocol->BatchIsActive(), (UINT64)CalleeStatus);
+ ShellCommandRegisterExit (gEfiShellProtocol->BatchIsActive (), (UINT64)CalleeStatus);
}
- FreePool(FileStringPath);
- return (Status);
+ FreePool (FileStringPath);
+ return (Status);
}
//
// for shell level 0 we do no scripts
// Without the Startup bit overriding we allow for nostartup to prevent scripts
//
- if ( (PcdGet8(PcdShellSupportLevel) < 1)
- || (ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoStartup && !ShellInfoObject.ShellInitSettings.BitUnion.Bits.Startup)
- ){
+ if ( (PcdGet8 (PcdShellSupportLevel) < 1)
+ || (ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoStartup && !ShellInfoObject.ShellInitSettings.BitUnion.Bits.Startup)
+ )
+ {
return (EFI_SUCCESS);
}
- gST->ConOut->EnableCursor(gST->ConOut, FALSE);
+ gST->ConOut->EnableCursor (gST->ConOut, FALSE);
//
// print out our warning and see if they press a key
//
for ( Status = EFI_UNSUPPORTED, Delay = ShellInfoObject.ShellInitSettings.Delay
- ; Delay != 0 && EFI_ERROR(Status)
- ; Delay--
- ){
- ShellPrintHiiEx(0, gST->ConOut->Mode->CursorRow, NULL, STRING_TOKEN (STR_SHELL_STARTUP_QUESTION), ShellInfoObject.HiiHandle, Delay);
+ ; Delay != 0 && EFI_ERROR (Status)
+ ; Delay--
+ )
+ {
+ ShellPrintHiiEx (0, gST->ConOut->Mode->CursorRow, NULL, STRING_TOKEN (STR_SHELL_STARTUP_QUESTION), ShellInfoObject.HiiHandle, Delay);
gBS->Stall (1000000);
if (!ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoConsoleIn) {
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
}
}
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_CRLF), ShellInfoObject.HiiHandle);
- gST->ConOut->EnableCursor(gST->ConOut, TRUE);
+
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SHELL_CRLF), ShellInfoObject.HiiHandle);
+ gST->ConOut->EnableCursor (gST->ConOut, TRUE);
//
// ESC was pressed
//
- if (Status == EFI_SUCCESS && Key.UnicodeChar == 0 && Key.ScanCode == SCAN_ESC) {
+ if ((Status == EFI_SUCCESS) && (Key.UnicodeChar == 0) && (Key.ScanCode == SCAN_ESC)) {
return (EFI_SUCCESS);
}
FileStringPath = LocateStartupScript (ImagePath, FilePath);
if (FileStringPath != NULL) {
- FullFileStringPath = FullyQualifyPath(FileStringPath);
+ FullFileStringPath = FullyQualifyPath (FileStringPath);
if (FullFileStringPath == NULL) {
Status = RunScriptFile (FileStringPath, NULL, FileStringPath, ShellInfoObject.NewShellParametersProtocol);
} else {
Status = RunScriptFile (FullFileStringPath, NULL, FullFileStringPath, ShellInfoObject.NewShellParametersProtocol);
- FreePool(FullFileStringPath);
+ FreePool (FullFileStringPath);
}
+
FreePool (FileStringPath);
} else {
//
@@ -1314,36 +1411,36 @@ DoShellPrompt ( EFI_STATUS Status;
LIST_ENTRY OldBufferList;
- CurDir = NULL;
+ CurDir = NULL;
//
// Get screen setting to decide size of the command line buffer
//
gST->ConOut->QueryMode (gST->ConOut, gST->ConOut->Mode->Mode, &Column, &Row);
- BufferSize = Column * Row * sizeof (CHAR16);
- CmdLine = AllocateZeroPool (BufferSize);
+ BufferSize = Column * Row * sizeof (CHAR16);
+ CmdLine = AllocateZeroPool (BufferSize);
if (CmdLine == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- SaveBufferList(&OldBufferList);
- CurDir = ShellInfoObject.NewEfiShellProtocol->GetEnv(L"cwd");
+ SaveBufferList (&OldBufferList);
+ CurDir = ShellInfoObject.NewEfiShellProtocol->GetEnv (L"cwd");
//
// Prompt for input
//
gST->ConOut->SetCursorPosition (gST->ConOut, 0, gST->ConOut->Mode->CursorRow);
- if (CurDir != NULL && StrLen(CurDir) > 1) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_CURDIR), ShellInfoObject.HiiHandle, CurDir);
+ if ((CurDir != NULL) && (StrLen (CurDir) > 1)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SHELL_CURDIR), ShellInfoObject.HiiHandle, CurDir);
} else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_SHELL), ShellInfoObject.HiiHandle);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SHELL_SHELL), ShellInfoObject.HiiHandle);
}
//
// Read a line from the console
//
- Status = ShellInfoObject.NewEfiShellProtocol->ReadFile(ShellInfoObject.NewShellParametersProtocol->StdIn, &BufferSize, CmdLine);
+ Status = ShellInfoObject.NewEfiShellProtocol->ReadFile (ShellInfoObject.NewShellParametersProtocol->StdIn, &BufferSize, CmdLine);
//
// Null terminate the string and parse it
@@ -1355,13 +1452,13 @@ DoShellPrompt ( Status = gBS->CheckEvent (ShellInfoObject.NewEfiShellProtocol->ExecutionBreak);
CmdLine[BufferSize / sizeof (CHAR16)] = CHAR_NULL;
- Status = RunCommand(CmdLine);
+ Status = RunCommand (CmdLine);
}
//
// Done with this command
//
- RestoreBufferList(&OldBufferList);
+ RestoreBufferList (&OldBufferList);
FreePool (CmdLine);
return Status;
}
@@ -1372,12 +1469,12 @@ DoShellPrompt ( @param Buffer Something to pass to FreePool when the shell is exiting.
**/
-VOID*
+VOID *
AddBufferToFreeList (
- VOID *Buffer
+ VOID *Buffer
)
{
- BUFFER_LIST *BufferListEntry;
+ BUFFER_LIST *BufferListEntry;
if (Buffer == NULL) {
return (NULL);
@@ -1393,7 +1490,6 @@ AddBufferToFreeList ( return (Buffer);
}
-
/**
Create a new buffer list and stores the old one to OldBufferList
@@ -1401,7 +1497,7 @@ AddBufferToFreeList ( **/
VOID
SaveBufferList (
- OUT LIST_ENTRY *OldBufferList
+ OUT LIST_ENTRY *OldBufferList
)
{
CopyMem (OldBufferList, &ShellInfoObject.BufferToFreeList.Link, sizeof (LIST_ENTRY));
@@ -1415,38 +1511,36 @@ SaveBufferList ( **/
VOID
RestoreBufferList (
- IN OUT LIST_ENTRY *OldBufferList
+ IN OUT LIST_ENTRY *OldBufferList
)
{
FreeBufferList (&ShellInfoObject.BufferToFreeList);
CopyMem (&ShellInfoObject.BufferToFreeList.Link, OldBufferList, sizeof (LIST_ENTRY));
}
-
/**
Add a buffer to the Line History List
@param Buffer The line buffer to add.
**/
VOID
-AddLineToCommandHistory(
- IN CONST CHAR16 *Buffer
+AddLineToCommandHistory (
+ IN CONST CHAR16 *Buffer
)
{
- BUFFER_LIST *Node;
- BUFFER_LIST *Walker;
+ BUFFER_LIST *Node;
+ BUFFER_LIST *Walker;
UINT16 MaxHistoryCmdCount;
UINT16 Count;
- Count = 0;
- MaxHistoryCmdCount = PcdGet16(PcdShellMaxHistoryCommandCount);
+ Count = 0;
+ MaxHistoryCmdCount = PcdGet16 (PcdShellMaxHistoryCommandCount);
if (MaxHistoryCmdCount == 0) {
- return ;
+ return;
}
-
- Node = AllocateZeroPool(sizeof(BUFFER_LIST));
+ Node = AllocateZeroPool (sizeof (BUFFER_LIST));
if (Node == NULL) {
return;
}
@@ -1457,22 +1551,25 @@ AddLineToCommandHistory( return;
}
- for ( Walker = (BUFFER_LIST*)GetFirstNode(&ShellInfoObject.ViewingSettings.CommandHistory.Link)
- ; !IsNull(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Walker->Link)
- ; Walker = (BUFFER_LIST*)GetNextNode(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Walker->Link)
- ){
+ for ( Walker = (BUFFER_LIST *)GetFirstNode (&ShellInfoObject.ViewingSettings.CommandHistory.Link)
+ ; !IsNull (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Walker->Link)
+ ; Walker = (BUFFER_LIST *)GetNextNode (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Walker->Link)
+ )
+ {
Count++;
}
- if (Count < MaxHistoryCmdCount){
- InsertTailList(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Node->Link);
+
+ if (Count < MaxHistoryCmdCount) {
+ InsertTailList (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Node->Link);
} else {
- Walker = (BUFFER_LIST*)GetFirstNode(&ShellInfoObject.ViewingSettings.CommandHistory.Link);
- RemoveEntryList(&Walker->Link);
+ Walker = (BUFFER_LIST *)GetFirstNode (&ShellInfoObject.ViewingSettings.CommandHistory.Link);
+ RemoveEntryList (&Walker->Link);
if (Walker->Buffer != NULL) {
- FreePool(Walker->Buffer);
+ FreePool (Walker->Buffer);
}
- FreePool(Walker);
- InsertTailList(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Node->Link);
+
+ FreePool (Walker);
+ InsertTailList (&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Node->Link);
}
}
@@ -1490,21 +1587,23 @@ AddLineToCommandHistory( @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
**/
EFI_STATUS
-ShellConvertAlias(
- IN OUT CHAR16 **CommandString
+ShellConvertAlias (
+ IN OUT CHAR16 **CommandString
)
{
CONST CHAR16 *NewString;
- NewString = ShellInfoObject.NewEfiShellProtocol->GetAlias(*CommandString, NULL);
+ NewString = ShellInfoObject.NewEfiShellProtocol->GetAlias (*CommandString, NULL);
if (NewString == NULL) {
return (EFI_SUCCESS);
}
- FreePool(*CommandString);
- *CommandString = AllocateCopyPool(StrSize(NewString), NewString);
+
+ FreePool (*CommandString);
+ *CommandString = AllocateCopyPool (StrSize (NewString), NewString);
if (*CommandString == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
+
return (EFI_SUCCESS);
}
@@ -1514,29 +1613,29 @@ ShellConvertAlias( @param[in,out] CmdLine The command line to update.
**/
EFI_STATUS
-StripUnreplacedEnvironmentVariables(
- IN OUT CHAR16 *CmdLine
+StripUnreplacedEnvironmentVariables (
+ IN OUT CHAR16 *CmdLine
)
{
- CHAR16 *FirstPercent;
- CHAR16 *FirstQuote;
- CHAR16 *SecondPercent;
- CHAR16 *SecondQuote;
- CHAR16 *CurrentLocator;
-
- for (CurrentLocator = CmdLine ; CurrentLocator != NULL ; ) {
- FirstQuote = FindNextInstance(CurrentLocator, L"\"", TRUE);
- FirstPercent = FindNextInstance(CurrentLocator, L"%", TRUE);
- SecondPercent = FirstPercent!=NULL?FindNextInstance(FirstPercent+1, L"%", TRUE):NULL;
- if (FirstPercent == NULL || SecondPercent == NULL) {
+ CHAR16 *FirstPercent;
+ CHAR16 *FirstQuote;
+ CHAR16 *SecondPercent;
+ CHAR16 *SecondQuote;
+ CHAR16 *CurrentLocator;
+
+ for (CurrentLocator = CmdLine; CurrentLocator != NULL; ) {
+ FirstQuote = FindNextInstance (CurrentLocator, L"\"", TRUE);
+ FirstPercent = FindNextInstance (CurrentLocator, L"%", TRUE);
+ SecondPercent = FirstPercent != NULL ? FindNextInstance (FirstPercent+1, L"%", TRUE) : NULL;
+ if ((FirstPercent == NULL) || (SecondPercent == NULL)) {
//
// If we ever don't have 2 % we are done.
//
break;
}
- if (FirstQuote!= NULL && FirstQuote < FirstPercent) {
- SecondQuote = FindNextInstance(FirstQuote+1, L"\"", TRUE);
+ if ((FirstQuote != NULL) && (FirstQuote < FirstPercent)) {
+ SecondQuote = FindNextInstance (FirstQuote+1, L"\"", TRUE);
//
// Quote is first found
//
@@ -1546,31 +1645,36 @@ StripUnreplacedEnvironmentVariables( // restart after the pair of "
//
CurrentLocator = SecondQuote + 1;
- } else /* FirstPercent < SecondQuote */{
+ } else {
+ /* FirstPercent < SecondQuote */
//
// Restart on the first percent
//
CurrentLocator = FirstPercent;
}
+
continue;
}
- if (FirstQuote == NULL || SecondPercent < FirstQuote) {
- if (IsValidEnvironmentVariableName(FirstPercent, SecondPercent)) {
+ if ((FirstQuote == NULL) || (SecondPercent < FirstQuote)) {
+ if (IsValidEnvironmentVariableName (FirstPercent, SecondPercent)) {
//
// We need to remove from FirstPercent to SecondPercent
//
- CopyMem(FirstPercent, SecondPercent + 1, StrSize(SecondPercent + 1));
+ CopyMem (FirstPercent, SecondPercent + 1, StrSize (SecondPercent + 1));
//
// don't need to update the locator. both % characters are gone.
//
} else {
CurrentLocator = SecondPercent + 1;
}
+
continue;
}
+
CurrentLocator = FirstQuote;
}
+
return (EFI_SUCCESS);
}
@@ -1585,69 +1689,75 @@ StripUnreplacedEnvironmentVariables( @retval NULL An error occurred.
@return The new command line with no environment variables present.
**/
-CHAR16*
+CHAR16 *
ShellConvertVariables (
- IN CONST CHAR16 *OriginalCommandLine
+ IN CONST CHAR16 *OriginalCommandLine
)
{
- CONST CHAR16 *MasterEnvList;
- UINTN NewSize;
- CHAR16 *NewCommandLine1;
- CHAR16 *NewCommandLine2;
- CHAR16 *Temp;
- UINTN ItemSize;
- CHAR16 *ItemTemp;
- SCRIPT_FILE *CurrentScriptFile;
- ALIAS_LIST *AliasListNode;
-
- ASSERT(OriginalCommandLine != NULL);
+ CONST CHAR16 *MasterEnvList;
+ UINTN NewSize;
+ CHAR16 *NewCommandLine1;
+ CHAR16 *NewCommandLine2;
+ CHAR16 *Temp;
+ UINTN ItemSize;
+ CHAR16 *ItemTemp;
+ SCRIPT_FILE *CurrentScriptFile;
+ ALIAS_LIST *AliasListNode;
+
+ ASSERT (OriginalCommandLine != NULL);
ItemSize = 0;
- NewSize = StrSize(OriginalCommandLine);
- CurrentScriptFile = ShellCommandGetCurrentScriptFile();
+ NewSize = StrSize (OriginalCommandLine);
+ CurrentScriptFile = ShellCommandGetCurrentScriptFile ();
Temp = NULL;
- ///@todo update this to handle the %0 - %9 for scripting only (borrow from line 1256 area) ? ? ?
+ /// @todo update this to handle the %0 - %9 for scripting only (borrow from line 1256 area) ? ? ?
//
// calculate the size required for the post-conversion string...
//
if (CurrentScriptFile != NULL) {
- for (AliasListNode = (ALIAS_LIST*)GetFirstNode(&CurrentScriptFile->SubstList)
- ; !IsNull(&CurrentScriptFile->SubstList, &AliasListNode->Link)
- ; AliasListNode = (ALIAS_LIST*)GetNextNode(&CurrentScriptFile->SubstList, &AliasListNode->Link)
- ){
- for (Temp = StrStr(OriginalCommandLine, AliasListNode->Alias)
- ; Temp != NULL
- ; Temp = StrStr(Temp+1, AliasListNode->Alias)
- ){
+ for (AliasListNode = (ALIAS_LIST *)GetFirstNode (&CurrentScriptFile->SubstList)
+ ; !IsNull (&CurrentScriptFile->SubstList, &AliasListNode->Link)
+ ; AliasListNode = (ALIAS_LIST *)GetNextNode (&CurrentScriptFile->SubstList, &AliasListNode->Link)
+ )
+ {
+ for (Temp = StrStr (OriginalCommandLine, AliasListNode->Alias)
+ ; Temp != NULL
+ ; Temp = StrStr (Temp+1, AliasListNode->Alias)
+ )
+ {
//
// we need a preceding and if there is space no ^ preceding (if no space ignore)
//
- if ((((Temp-OriginalCommandLine)>2) && *(Temp-2) != L'^') || ((Temp-OriginalCommandLine)<=2)) {
- NewSize += StrSize(AliasListNode->CommandString);
+ if ((((Temp-OriginalCommandLine) > 2) && (*(Temp-2) != L'^')) || ((Temp-OriginalCommandLine) <= 2)) {
+ NewSize += StrSize (AliasListNode->CommandString);
}
}
}
}
- for (MasterEnvList = EfiShellGetEnv(NULL)
- ; MasterEnvList != NULL && *MasterEnvList != CHAR_NULL //&& *(MasterEnvList+1) != CHAR_NULL
- ; MasterEnvList += StrLen(MasterEnvList) + 1
- ){
- if (StrSize(MasterEnvList) > ItemSize) {
- ItemSize = StrSize(MasterEnvList);
+ for (MasterEnvList = EfiShellGetEnv (NULL)
+ ; MasterEnvList != NULL && *MasterEnvList != CHAR_NULL // && *(MasterEnvList+1) != CHAR_NULL
+ ; MasterEnvList += StrLen (MasterEnvList) + 1
+ )
+ {
+ if (StrSize (MasterEnvList) > ItemSize) {
+ ItemSize = StrSize (MasterEnvList);
}
- for (Temp = StrStr(OriginalCommandLine, MasterEnvList)
- ; Temp != NULL
- ; Temp = StrStr(Temp+1, MasterEnvList)
- ){
+
+ for (Temp = StrStr (OriginalCommandLine, MasterEnvList)
+ ; Temp != NULL
+ ; Temp = StrStr (Temp+1, MasterEnvList)
+ )
+ {
//
// we need a preceding and following % and if there is space no ^ preceding (if no space ignore)
//
- if (*(Temp-1) == L'%' && *(Temp+StrLen(MasterEnvList)) == L'%' &&
- ((((Temp-OriginalCommandLine)>2) && *(Temp-2) != L'^') || ((Temp-OriginalCommandLine)<=2))) {
- NewSize+=StrSize(EfiShellGetEnv(MasterEnvList));
+ if ((*(Temp-1) == L'%') && (*(Temp+StrLen (MasterEnvList)) == L'%') &&
+ ((((Temp-OriginalCommandLine) > 2) && (*(Temp-2) != L'^')) || ((Temp-OriginalCommandLine) <= 2)))
+ {
+ NewSize += StrSize (EfiShellGetEnv (MasterEnvList));
}
}
}
@@ -1656,58 +1766,65 @@ ShellConvertVariables ( // now do the replacements...
//
NewCommandLine1 = AllocateZeroPool (NewSize);
- NewCommandLine2 = AllocateZeroPool(NewSize);
- ItemTemp = AllocateZeroPool(ItemSize+(2*sizeof(CHAR16)));
- if (NewCommandLine1 == NULL || NewCommandLine2 == NULL || ItemTemp == NULL) {
- SHELL_FREE_NON_NULL(NewCommandLine1);
- SHELL_FREE_NON_NULL(NewCommandLine2);
- SHELL_FREE_NON_NULL(ItemTemp);
+ NewCommandLine2 = AllocateZeroPool (NewSize);
+ ItemTemp = AllocateZeroPool (ItemSize+(2*sizeof (CHAR16)));
+ if ((NewCommandLine1 == NULL) || (NewCommandLine2 == NULL) || (ItemTemp == NULL)) {
+ SHELL_FREE_NON_NULL (NewCommandLine1);
+ SHELL_FREE_NON_NULL (NewCommandLine2);
+ SHELL_FREE_NON_NULL (ItemTemp);
return (NULL);
}
+
CopyMem (NewCommandLine1, OriginalCommandLine, StrSize (OriginalCommandLine));
- for (MasterEnvList = EfiShellGetEnv(NULL)
- ; MasterEnvList != NULL && *MasterEnvList != CHAR_NULL
- ; MasterEnvList += StrLen(MasterEnvList) + 1
- ){
- StrCpyS( ItemTemp,
- ((ItemSize+(2*sizeof(CHAR16)))/sizeof(CHAR16)),
- L"%"
- );
- StrCatS( ItemTemp,
- ((ItemSize+(2*sizeof(CHAR16)))/sizeof(CHAR16)),
- MasterEnvList
- );
- StrCatS( ItemTemp,
- ((ItemSize+(2*sizeof(CHAR16)))/sizeof(CHAR16)),
- L"%"
- );
- ShellCopySearchAndReplace(NewCommandLine1, NewCommandLine2, NewSize, ItemTemp, EfiShellGetEnv(MasterEnvList), TRUE, FALSE);
- StrCpyS(NewCommandLine1, NewSize/sizeof(CHAR16), NewCommandLine2);
+ for (MasterEnvList = EfiShellGetEnv (NULL)
+ ; MasterEnvList != NULL && *MasterEnvList != CHAR_NULL
+ ; MasterEnvList += StrLen (MasterEnvList) + 1
+ )
+ {
+ StrCpyS (
+ ItemTemp,
+ ((ItemSize+(2*sizeof (CHAR16)))/sizeof (CHAR16)),
+ L"%"
+ );
+ StrCatS (
+ ItemTemp,
+ ((ItemSize+(2*sizeof (CHAR16)))/sizeof (CHAR16)),
+ MasterEnvList
+ );
+ StrCatS (
+ ItemTemp,
+ ((ItemSize+(2*sizeof (CHAR16)))/sizeof (CHAR16)),
+ L"%"
+ );
+ ShellCopySearchAndReplace (NewCommandLine1, NewCommandLine2, NewSize, ItemTemp, EfiShellGetEnv (MasterEnvList), TRUE, FALSE);
+ StrCpyS (NewCommandLine1, NewSize/sizeof (CHAR16), NewCommandLine2);
}
+
if (CurrentScriptFile != NULL) {
- for (AliasListNode = (ALIAS_LIST*)GetFirstNode(&CurrentScriptFile->SubstList)
- ; !IsNull(&CurrentScriptFile->SubstList, &AliasListNode->Link)
- ; AliasListNode = (ALIAS_LIST*)GetNextNode(&CurrentScriptFile->SubstList, &AliasListNode->Link)
- ){
- ShellCopySearchAndReplace(NewCommandLine1, NewCommandLine2, NewSize, AliasListNode->Alias, AliasListNode->CommandString, TRUE, FALSE);
- StrCpyS(NewCommandLine1, NewSize/sizeof(CHAR16), NewCommandLine2);
+ for (AliasListNode = (ALIAS_LIST *)GetFirstNode (&CurrentScriptFile->SubstList)
+ ; !IsNull (&CurrentScriptFile->SubstList, &AliasListNode->Link)
+ ; AliasListNode = (ALIAS_LIST *)GetNextNode (&CurrentScriptFile->SubstList, &AliasListNode->Link)
+ )
+ {
+ ShellCopySearchAndReplace (NewCommandLine1, NewCommandLine2, NewSize, AliasListNode->Alias, AliasListNode->CommandString, TRUE, FALSE);
+ StrCpyS (NewCommandLine1, NewSize/sizeof (CHAR16), NewCommandLine2);
}
}
//
// Remove non-existent environment variables
//
- StripUnreplacedEnvironmentVariables(NewCommandLine1);
+ StripUnreplacedEnvironmentVariables (NewCommandLine1);
//
// Now cleanup any straggler intentionally ignored "%" characters
//
- ShellCopySearchAndReplace(NewCommandLine1, NewCommandLine2, NewSize, L"^%", L"%", TRUE, FALSE);
- StrCpyS(NewCommandLine1, NewSize/sizeof(CHAR16), NewCommandLine2);
+ ShellCopySearchAndReplace (NewCommandLine1, NewCommandLine2, NewSize, L"^%", L"%", TRUE, FALSE);
+ StrCpyS (NewCommandLine1, NewSize/sizeof (CHAR16), NewCommandLine2);
- FreePool(NewCommandLine2);
- FreePool(ItemTemp);
+ FreePool (NewCommandLine2);
+ FreePool (ItemTemp);
return (NewCommandLine1);
}
@@ -1723,24 +1840,24 @@ ShellConvertVariables ( @retval other Some error occurs when executing the split command.
**/
EFI_STATUS
-RunSplitCommand(
+RunSplitCommand (
IN CONST CHAR16 *CmdLine,
IN SHELL_FILE_HANDLE StdIn,
IN SHELL_FILE_HANDLE StdOut
)
{
- EFI_STATUS Status;
- CHAR16 *NextCommandLine;
- CHAR16 *OurCommandLine;
- UINTN Size1;
- UINTN Size2;
- SPLIT_LIST *Split;
- SHELL_FILE_HANDLE TempFileHandle;
- BOOLEAN Unicode;
+ EFI_STATUS Status;
+ CHAR16 *NextCommandLine;
+ CHAR16 *OurCommandLine;
+ UINTN Size1;
+ UINTN Size2;
+ SPLIT_LIST *Split;
+ SHELL_FILE_HANDLE TempFileHandle;
+ BOOLEAN Unicode;
- ASSERT(StdOut == NULL);
+ ASSERT (StdOut == NULL);
- ASSERT(StrStr(CmdLine, L"|") != NULL);
+ ASSERT (StrStr (CmdLine, L"|") != NULL);
Status = EFI_SUCCESS;
NextCommandLine = NULL;
@@ -1748,70 +1865,74 @@ RunSplitCommand( Size1 = 0;
Size2 = 0;
- NextCommandLine = StrnCatGrow(&NextCommandLine, &Size1, StrStr(CmdLine, L"|")+1, 0);
- OurCommandLine = StrnCatGrow(&OurCommandLine , &Size2, CmdLine , StrStr(CmdLine, L"|") - CmdLine);
+ NextCommandLine = StrnCatGrow (&NextCommandLine, &Size1, StrStr (CmdLine, L"|")+1, 0);
+ OurCommandLine = StrnCatGrow (&OurCommandLine, &Size2, CmdLine, StrStr (CmdLine, L"|") - CmdLine);
- if (NextCommandLine == NULL || OurCommandLine == NULL) {
- SHELL_FREE_NON_NULL(OurCommandLine);
- SHELL_FREE_NON_NULL(NextCommandLine);
+ if ((NextCommandLine == NULL) || (OurCommandLine == NULL)) {
+ SHELL_FREE_NON_NULL (OurCommandLine);
+ SHELL_FREE_NON_NULL (NextCommandLine);
return (EFI_OUT_OF_RESOURCES);
- } else if (StrStr(OurCommandLine, L"|") != NULL || Size1 == 0 || Size2 == 0) {
- SHELL_FREE_NON_NULL(OurCommandLine);
- SHELL_FREE_NON_NULL(NextCommandLine);
+ } else if ((StrStr (OurCommandLine, L"|") != NULL) || (Size1 == 0) || (Size2 == 0)) {
+ SHELL_FREE_NON_NULL (OurCommandLine);
+ SHELL_FREE_NON_NULL (NextCommandLine);
return (EFI_INVALID_PARAMETER);
- } else if (NextCommandLine[0] == L'a' &&
- (NextCommandLine[1] == L' ' || NextCommandLine[1] == CHAR_NULL)
- ){
- CopyMem(NextCommandLine, NextCommandLine+1, StrSize(NextCommandLine) - sizeof(NextCommandLine[0]));
+ } else if ((NextCommandLine[0] == L'a') &&
+ ((NextCommandLine[1] == L' ') || (NextCommandLine[1] == CHAR_NULL))
+ )
+ {
+ CopyMem (NextCommandLine, NextCommandLine+1, StrSize (NextCommandLine) - sizeof (NextCommandLine[0]));
while (NextCommandLine[0] == L' ') {
- CopyMem(NextCommandLine, NextCommandLine+1, StrSize(NextCommandLine) - sizeof(NextCommandLine[0]));
+ CopyMem (NextCommandLine, NextCommandLine+1, StrSize (NextCommandLine) - sizeof (NextCommandLine[0]));
}
+
if (NextCommandLine[0] == CHAR_NULL) {
- SHELL_FREE_NON_NULL(OurCommandLine);
- SHELL_FREE_NON_NULL(NextCommandLine);
+ SHELL_FREE_NON_NULL (OurCommandLine);
+ SHELL_FREE_NON_NULL (NextCommandLine);
return (EFI_INVALID_PARAMETER);
}
+
Unicode = FALSE;
} else {
Unicode = TRUE;
}
-
//
// make a SPLIT_LIST item and add to list
//
- Split = AllocateZeroPool(sizeof(SPLIT_LIST));
+ Split = AllocateZeroPool (sizeof (SPLIT_LIST));
if (Split == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- Split->SplitStdIn = StdIn;
- Split->SplitStdOut = ConvertEfiFileProtocolToShellHandle(CreateFileInterfaceMem(Unicode), NULL);
- ASSERT(Split->SplitStdOut != NULL);
- InsertHeadList(&ShellInfoObject.SplitList.Link, &Split->Link);
- Status = RunCommand(OurCommandLine);
+ Split->SplitStdIn = StdIn;
+ Split->SplitStdOut = ConvertEfiFileProtocolToShellHandle (CreateFileInterfaceMem (Unicode), NULL);
+ ASSERT (Split->SplitStdOut != NULL);
+ InsertHeadList (&ShellInfoObject.SplitList.Link, &Split->Link);
+
+ Status = RunCommand (OurCommandLine);
//
// move the output from the first to the in to the second.
//
- TempFileHandle = Split->SplitStdOut;
+ TempFileHandle = Split->SplitStdOut;
if (Split->SplitStdIn == StdIn) {
Split->SplitStdOut = NULL;
} else {
- Split->SplitStdOut = Split->SplitStdIn;
+ Split->SplitStdOut = Split->SplitStdIn;
}
- Split->SplitStdIn = TempFileHandle;
+
+ Split->SplitStdIn = TempFileHandle;
ShellInfoObject.NewEfiShellProtocol->SetFilePosition (Split->SplitStdIn, 0);
- if (!EFI_ERROR(Status)) {
- Status = RunCommand(NextCommandLine);
+ if (!EFI_ERROR (Status)) {
+ Status = RunCommand (NextCommandLine);
}
//
// remove the top level from the ScriptList
//
- ASSERT((SPLIT_LIST*)GetFirstNode(&ShellInfoObject.SplitList.Link) == Split);
- RemoveEntryList(&Split->Link);
+ ASSERT ((SPLIT_LIST *)GetFirstNode (&ShellInfoObject.SplitList.Link) == Split);
+ RemoveEntryList (&Split->Link);
//
// Note that the original StdIn is now the StdOut...
@@ -1819,13 +1940,14 @@ RunSplitCommand( if (Split->SplitStdOut != NULL) {
ShellInfoObject.NewEfiShellProtocol->CloseFile (Split->SplitStdOut);
}
+
if (Split->SplitStdIn != NULL) {
ShellInfoObject.NewEfiShellProtocol->CloseFile (Split->SplitStdIn);
}
- FreePool(Split);
- FreePool(NextCommandLine);
- FreePool(OurCommandLine);
+ FreePool (Split);
+ FreePool (NextCommandLine);
+ FreePool (OurCommandLine);
return (Status);
}
@@ -1840,16 +1962,18 @@ RunSplitCommand( @retval EFI_OUT_OF_RESOURCES a memory allocation failed.
**/
EFI_STATUS
-ShellSubstituteVariables(
- IN CHAR16 **CmdLine
+ShellSubstituteVariables (
+ IN CHAR16 **CmdLine
)
{
- CHAR16 *NewCmdLine;
- NewCmdLine = ShellConvertVariables(*CmdLine);
- SHELL_FREE_NON_NULL(*CmdLine);
+ CHAR16 *NewCmdLine;
+
+ NewCmdLine = ShellConvertVariables (*CmdLine);
+ SHELL_FREE_NON_NULL (*CmdLine);
if (NewCmdLine == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
+
*CmdLine = NewCmdLine;
return (EFI_SUCCESS);
}
@@ -1864,56 +1988,58 @@ ShellSubstituteVariables( @retval EFI_OUT_OF_RESOURCES a memory allocation failed.
**/
EFI_STATUS
-ShellSubstituteAliases(
- IN CHAR16 **CmdLine
+ShellSubstituteAliases (
+ IN CHAR16 **CmdLine
)
{
CHAR16 *NewCmdLine;
CHAR16 *CommandName;
EFI_STATUS Status;
UINTN PostAliasSize;
- ASSERT(CmdLine != NULL);
- ASSERT(*CmdLine!= NULL);
+ ASSERT (CmdLine != NULL);
+ ASSERT (*CmdLine != NULL);
CommandName = NULL;
- if (StrStr((*CmdLine), L" ") == NULL){
- StrnCatGrow(&CommandName, NULL, (*CmdLine), 0);
+ if (StrStr ((*CmdLine), L" ") == NULL) {
+ StrnCatGrow (&CommandName, NULL, (*CmdLine), 0);
} else {
- StrnCatGrow(&CommandName, NULL, (*CmdLine), StrStr((*CmdLine), L" ") - (*CmdLine));
+ StrnCatGrow (&CommandName, NULL, (*CmdLine), StrStr ((*CmdLine), L" ") - (*CmdLine));
}
//
// This cannot happen 'inline' since the CmdLine can need extra space.
//
NewCmdLine = NULL;
- if (!ShellCommandIsCommandOnList(CommandName)) {
+ if (!ShellCommandIsCommandOnList (CommandName)) {
//
// Convert via alias
//
- Status = ShellConvertAlias(&CommandName);
- if (EFI_ERROR(Status)){
+ Status = ShellConvertAlias (&CommandName);
+ if (EFI_ERROR (Status)) {
return (Status);
}
+
PostAliasSize = 0;
- NewCmdLine = StrnCatGrow(&NewCmdLine, &PostAliasSize, CommandName, 0);
+ NewCmdLine = StrnCatGrow (&NewCmdLine, &PostAliasSize, CommandName, 0);
if (NewCmdLine == NULL) {
- SHELL_FREE_NON_NULL(CommandName);
- SHELL_FREE_NON_NULL(*CmdLine);
+ SHELL_FREE_NON_NULL (CommandName);
+ SHELL_FREE_NON_NULL (*CmdLine);
return (EFI_OUT_OF_RESOURCES);
}
- NewCmdLine = StrnCatGrow(&NewCmdLine, &PostAliasSize, StrStr((*CmdLine), L" "), 0);
+
+ NewCmdLine = StrnCatGrow (&NewCmdLine, &PostAliasSize, StrStr ((*CmdLine), L" "), 0);
if (NewCmdLine == NULL) {
- SHELL_FREE_NON_NULL(CommandName);
- SHELL_FREE_NON_NULL(*CmdLine);
+ SHELL_FREE_NON_NULL (CommandName);
+ SHELL_FREE_NON_NULL (*CmdLine);
return (EFI_OUT_OF_RESOURCES);
}
} else {
- NewCmdLine = StrnCatGrow(&NewCmdLine, NULL, (*CmdLine), 0);
+ NewCmdLine = StrnCatGrow (&NewCmdLine, NULL, (*CmdLine), 0);
}
- SHELL_FREE_NON_NULL(*CmdLine);
- SHELL_FREE_NON_NULL(CommandName);
+ SHELL_FREE_NON_NULL (*CmdLine);
+ SHELL_FREE_NON_NULL (CommandName);
//
// re-assign the passed in double pointer to point to our newly allocated buffer
@@ -1935,46 +2061,48 @@ ShellSubstituteAliases( @retval Efi_Application the name is an application (.EFI).
**/
SHELL_OPERATION_TYPES
-GetOperationType(
- IN CONST CHAR16 *CmdName
+GetOperationType (
+ IN CONST CHAR16 *CmdName
)
{
- CHAR16* FileWithPath;
- CONST CHAR16* TempLocation;
- CONST CHAR16* TempLocation2;
+ CHAR16 *FileWithPath;
+ CONST CHAR16 *TempLocation;
+ CONST CHAR16 *TempLocation2;
FileWithPath = NULL;
//
// test for an internal command.
//
- if (ShellCommandIsCommandOnList(CmdName)) {
+ if (ShellCommandIsCommandOnList (CmdName)) {
return (Internal_Command);
}
//
// Test for file system change request. anything ending with first : and cant have spaces.
//
- if (CmdName[(StrLen(CmdName)-1)] == L':') {
- if ( StrStr(CmdName, L" ") != NULL
- || StrLen(StrStr(CmdName, L":")) > 1
- ) {
+ if (CmdName[(StrLen (CmdName)-1)] == L':') {
+ if ( (StrStr (CmdName, L" ") != NULL)
+ || (StrLen (StrStr (CmdName, L":")) > 1)
+ )
+ {
return (Unknown_Invalid);
}
+
return (File_Sys_Change);
}
//
// Test for a file
//
- if ((FileWithPath = ShellFindFilePathEx(CmdName, mExecutableExtensions)) != NULL) {
+ if ((FileWithPath = ShellFindFilePathEx (CmdName, mExecutableExtensions)) != NULL) {
//
// See if that file has a script file extension
//
- if (StrLen(FileWithPath) > 4) {
- TempLocation = FileWithPath+StrLen(FileWithPath)-4;
+ if (StrLen (FileWithPath) > 4) {
+ TempLocation = FileWithPath+StrLen (FileWithPath)-4;
TempLocation2 = mScriptExtension;
- if (StringNoCaseCompare((VOID*)(&TempLocation), (VOID*)(&TempLocation2)) == 0) {
- SHELL_FREE_NON_NULL(FileWithPath);
+ if (StringNoCaseCompare ((VOID *)(&TempLocation), (VOID *)(&TempLocation2)) == 0) {
+ SHELL_FREE_NON_NULL (FileWithPath);
return (Script_File_Name);
}
}
@@ -1982,11 +2110,11 @@ GetOperationType( //
// Was a file, but not a script. we treat this as an application.
//
- SHELL_FREE_NON_NULL(FileWithPath);
+ SHELL_FREE_NON_NULL (FileWithPath);
return (Efi_Application);
}
- SHELL_FREE_NON_NULL(FileWithPath);
+ SHELL_FREE_NON_NULL (FileWithPath);
//
// No clue what this is... return invalid flag...
//
@@ -2003,23 +2131,23 @@ GetOperationType( @retval EFI_NOT_FOUND The operation type is unknown or invalid.
**/
EFI_STATUS
-IsValidSplit(
- IN CONST CHAR16 *CmdLine
+IsValidSplit (
+ IN CONST CHAR16 *CmdLine
)
{
- CHAR16 *Temp;
- CHAR16 *FirstParameter;
- CHAR16 *TempWalker;
- EFI_STATUS Status;
+ CHAR16 *Temp;
+ CHAR16 *FirstParameter;
+ CHAR16 *TempWalker;
+ EFI_STATUS Status;
- Temp = NULL;
+ Temp = NULL;
- Temp = StrnCatGrow(&Temp, NULL, CmdLine, 0);
+ Temp = StrnCatGrow (&Temp, NULL, CmdLine, 0);
if (Temp == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
- FirstParameter = StrStr(Temp, L"|");
+ FirstParameter = StrStr (Temp, L"|");
if (FirstParameter != NULL) {
*FirstParameter = CHAR_NULL;
}
@@ -2029,26 +2157,27 @@ IsValidSplit( //
// Process the command line
//
- Status = ProcessCommandLineToFinal(&Temp);
+ Status = ProcessCommandLineToFinal (&Temp);
- if (!EFI_ERROR(Status)) {
- FirstParameter = AllocateZeroPool(StrSize(CmdLine));
+ if (!EFI_ERROR (Status)) {
+ FirstParameter = AllocateZeroPool (StrSize (CmdLine));
if (FirstParameter == NULL) {
- SHELL_FREE_NON_NULL(Temp);
+ SHELL_FREE_NON_NULL (Temp);
return (EFI_OUT_OF_RESOURCES);
}
- TempWalker = (CHAR16*)Temp;
- if (!EFI_ERROR(GetNextParameter(&TempWalker, &FirstParameter, StrSize(CmdLine), TRUE))) {
- if (GetOperationType(FirstParameter) == Unknown_Invalid) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND), ShellInfoObject.HiiHandle, FirstParameter);
- SetLastError(SHELL_NOT_FOUND);
+
+ TempWalker = (CHAR16 *)Temp;
+ if (!EFI_ERROR (GetNextParameter (&TempWalker, &FirstParameter, StrSize (CmdLine), TRUE))) {
+ if (GetOperationType (FirstParameter) == Unknown_Invalid) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND), ShellInfoObject.HiiHandle, FirstParameter);
+ SetLastError (SHELL_NOT_FOUND);
Status = EFI_NOT_FOUND;
}
}
}
- SHELL_FREE_NON_NULL(Temp);
- SHELL_FREE_NON_NULL(FirstParameter);
+ SHELL_FREE_NON_NULL (Temp);
+ SHELL_FREE_NON_NULL (FirstParameter);
return Status;
}
@@ -2061,8 +2190,8 @@ IsValidSplit( @retval EFI_ABORTED CmdLine has at least one invalid command or application.
**/
EFI_STATUS
-VerifySplit(
- IN CONST CHAR16 *CmdLine
+VerifySplit (
+ IN CONST CHAR16 *CmdLine
)
{
CONST CHAR16 *TempSpot;
@@ -2071,30 +2200,31 @@ VerifySplit( //
// If this was the only item, then get out
//
- if (!ContainsSplit(CmdLine)) {
+ if (!ContainsSplit (CmdLine)) {
return (EFI_SUCCESS);
}
//
// Verify up to the pipe or end character
//
- Status = IsValidSplit(CmdLine);
- if (EFI_ERROR(Status)) {
+ Status = IsValidSplit (CmdLine);
+ if (EFI_ERROR (Status)) {
return (Status);
}
//
// recurse to verify the next item
//
- TempSpot = FindFirstCharacter(CmdLine, L"|", L'^') + 1;
- if (*TempSpot == L'a' &&
- (*(TempSpot + 1) == L' ' || *(TempSpot + 1) == CHAR_NULL)
- ) {
+ TempSpot = FindFirstCharacter (CmdLine, L"|", L'^') + 1;
+ if ((*TempSpot == L'a') &&
+ ((*(TempSpot + 1) == L' ') || (*(TempSpot + 1) == CHAR_NULL))
+ )
+ {
// If it's an ASCII pipe '|a'
TempSpot += 1;
}
- return (VerifySplit(TempSpot));
+ return (VerifySplit (TempSpot));
}
/**
@@ -2106,15 +2236,15 @@ VerifySplit( @return an error occurred.
**/
EFI_STATUS
-ProcessNewSplitCommandLine(
- IN CONST CHAR16 *CmdLine
+ProcessNewSplitCommandLine (
+ IN CONST CHAR16 *CmdLine
)
{
- SPLIT_LIST *Split;
- EFI_STATUS Status;
+ SPLIT_LIST *Split;
+ EFI_STATUS Status;
- Status = VerifySplit(CmdLine);
- if (EFI_ERROR(Status)) {
+ Status = VerifySplit (CmdLine);
+ if (EFI_ERROR (Status)) {
return (Status);
}
@@ -2123,18 +2253,20 @@ ProcessNewSplitCommandLine( //
// are we in an existing split???
//
- if (!IsListEmpty(&ShellInfoObject.SplitList.Link)) {
- Split = (SPLIT_LIST*)GetFirstNode(&ShellInfoObject.SplitList.Link);
+ if (!IsListEmpty (&ShellInfoObject.SplitList.Link)) {
+ Split = (SPLIT_LIST *)GetFirstNode (&ShellInfoObject.SplitList.Link);
}
if (Split == NULL) {
- Status = RunSplitCommand(CmdLine, NULL, NULL);
+ Status = RunSplitCommand (CmdLine, NULL, NULL);
} else {
- Status = RunSplitCommand(CmdLine, Split->SplitStdIn, Split->SplitStdOut);
+ Status = RunSplitCommand (CmdLine, Split->SplitStdIn, Split->SplitStdOut);
}
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_INVALID_SPLIT), ShellInfoObject.HiiHandle, CmdLine);
+
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SHELL_INVALID_SPLIT), ShellInfoObject.HiiHandle, CmdLine);
}
+
return (Status);
}
@@ -2146,28 +2278,29 @@ ProcessNewSplitCommandLine( @retval EFI_SUCCESS The operation was successful.
**/
EFI_STATUS
-ChangeMappedDrive(
- IN CONST CHAR16 *CmdLine
+ChangeMappedDrive (
+ IN CONST CHAR16 *CmdLine
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+
Status = EFI_SUCCESS;
//
// make sure we are the right operation
//
- ASSERT(CmdLine[(StrLen(CmdLine)-1)] == L':' && StrStr(CmdLine, L" ") == NULL);
+ ASSERT (CmdLine[(StrLen (CmdLine)-1)] == L':' && StrStr (CmdLine, L" ") == NULL);
//
// Call the protocol API to do the work
//
- Status = ShellInfoObject.NewEfiShellProtocol->SetCurDir(NULL, CmdLine);
+ Status = ShellInfoObject.NewEfiShellProtocol->SetCurDir (NULL, CmdLine);
//
// Report any errors
//
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_INVALID_MAPPING), ShellInfoObject.HiiHandle, CmdLine);
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SHELL_INVALID_MAPPING), ShellInfoObject.HiiHandle, CmdLine);
}
return (Status);
@@ -2181,31 +2314,31 @@ ChangeMappedDrive( @param[in,out] CmdLine pointer to the command line to update
**/
EFI_STATUS
-DoHelpUpdate(
- IN OUT CHAR16 **CmdLine
+DoHelpUpdate (
+ IN OUT CHAR16 **CmdLine
)
{
- CHAR16 *CurrentParameter;
- CHAR16 *Walker;
- CHAR16 *NewCommandLine;
- EFI_STATUS Status;
- UINTN NewCmdLineSize;
+ CHAR16 *CurrentParameter;
+ CHAR16 *Walker;
+ CHAR16 *NewCommandLine;
+ EFI_STATUS Status;
+ UINTN NewCmdLineSize;
Status = EFI_SUCCESS;
- CurrentParameter = AllocateZeroPool(StrSize(*CmdLine));
+ CurrentParameter = AllocateZeroPool (StrSize (*CmdLine));
if (CurrentParameter == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
Walker = *CmdLine;
- while(Walker != NULL && *Walker != CHAR_NULL) {
- if (!EFI_ERROR(GetNextParameter(&Walker, &CurrentParameter, StrSize(*CmdLine), TRUE))) {
- if (StrStr(CurrentParameter, L"-?") == CurrentParameter) {
+ while (Walker != NULL && *Walker != CHAR_NULL) {
+ if (!EFI_ERROR (GetNextParameter (&Walker, &CurrentParameter, StrSize (*CmdLine), TRUE))) {
+ if (StrStr (CurrentParameter, L"-?") == CurrentParameter) {
CurrentParameter[0] = L' ';
CurrentParameter[1] = L' ';
- NewCmdLineSize = StrSize(L"help ") + StrSize(*CmdLine);
- NewCommandLine = AllocateZeroPool(NewCmdLineSize);
+ NewCmdLineSize = StrSize (L"help ") + StrSize (*CmdLine);
+ NewCommandLine = AllocateZeroPool (NewCmdLineSize);
if (NewCommandLine == NULL) {
Status = EFI_OUT_OF_RESOURCES;
break;
@@ -2214,16 +2347,16 @@ DoHelpUpdate( //
// We know the space is sufficient since we just calculated it.
//
- StrnCpyS(NewCommandLine, NewCmdLineSize/sizeof(CHAR16), L"help ", 5);
- StrnCatS(NewCommandLine, NewCmdLineSize/sizeof(CHAR16), *CmdLine, StrLen(*CmdLine));
- SHELL_FREE_NON_NULL(*CmdLine);
+ StrnCpyS (NewCommandLine, NewCmdLineSize/sizeof (CHAR16), L"help ", 5);
+ StrnCatS (NewCommandLine, NewCmdLineSize/sizeof (CHAR16), *CmdLine, StrLen (*CmdLine));
+ SHELL_FREE_NON_NULL (*CmdLine);
*CmdLine = NewCommandLine;
break;
}
}
}
- SHELL_FREE_NON_NULL(CurrentParameter);
+ SHELL_FREE_NON_NULL (CurrentParameter);
return (Status);
}
@@ -2234,18 +2367,22 @@ DoHelpUpdate( @param[in] ErrorCode the error code to put into lasterror.
**/
EFI_STATUS
-SetLastError(
- IN CONST SHELL_STATUS ErrorCode
+SetLastError (
+ IN CONST SHELL_STATUS ErrorCode
)
{
- CHAR16 LeString[19];
- if (sizeof(EFI_STATUS) == sizeof(UINT64)) {
- UnicodeSPrint(LeString, sizeof(LeString), L"0x%Lx", ErrorCode);
+ CHAR16 LeString[19];
+
+ if (sizeof (EFI_STATUS) == sizeof (UINT64)) {
+ UnicodeSPrint (LeString, sizeof (LeString), L"0x%Lx", ErrorCode);
} else {
- UnicodeSPrint(LeString, sizeof(LeString), L"0x%x", ErrorCode);
+ UnicodeSPrint (LeString, sizeof (LeString), L"0x%x", ErrorCode);
}
- DEBUG_CODE(InternalEfiShellSetEnv(L"debuglasterror", LeString, TRUE););
- InternalEfiShellSetEnv(L"lasterror", LeString, TRUE);
+
+ DEBUG_CODE (
+ InternalEfiShellSetEnv (L"debuglasterror", LeString, TRUE);
+ );
+ InternalEfiShellSetEnv (L"lasterror", LeString, TRUE);
return (EFI_SUCCESS);
}
@@ -2260,40 +2397,42 @@ SetLastError( @return some other error occurred
**/
EFI_STATUS
-ProcessCommandLineToFinal(
- IN OUT CHAR16 **CmdLine
+ProcessCommandLineToFinal (
+ IN OUT CHAR16 **CmdLine
)
{
- EFI_STATUS Status;
- TrimSpaces(CmdLine);
+ EFI_STATUS Status;
+
+ TrimSpaces (CmdLine);
- Status = ShellSubstituteAliases(CmdLine);
- if (EFI_ERROR(Status)) {
+ Status = ShellSubstituteAliases (CmdLine);
+ if (EFI_ERROR (Status)) {
return (Status);
}
- TrimSpaces(CmdLine);
+ TrimSpaces (CmdLine);
- Status = ShellSubstituteVariables(CmdLine);
- if (EFI_ERROR(Status)) {
+ Status = ShellSubstituteVariables (CmdLine);
+ if (EFI_ERROR (Status)) {
return (Status);
}
+
ASSERT (*CmdLine != NULL);
- TrimSpaces(CmdLine);
+ TrimSpaces (CmdLine);
//
// update for help parsing
//
- if (StrStr(*CmdLine, L"?") != NULL) {
+ if (StrStr (*CmdLine, L"?") != NULL) {
//
// This may do nothing if the ? does not indicate help.
// Save all the details for in the API below.
//
- Status = DoHelpUpdate(CmdLine);
+ Status = DoHelpUpdate (CmdLine);
}
- TrimSpaces(CmdLine);
+ TrimSpaces (CmdLine);
return (EFI_SUCCESS);
}
@@ -2312,43 +2451,43 @@ ProcessCommandLineToFinal( @retval EFI_ABORTED The command's operation was aborted.
**/
EFI_STATUS
-RunInternalCommand(
+RunInternalCommand (
IN CONST CHAR16 *CmdLine,
IN CHAR16 *FirstParameter,
IN EFI_SHELL_PARAMETERS_PROTOCOL *ParamProtocol,
OUT EFI_STATUS *CommandStatus
-)
+ )
{
- EFI_STATUS Status;
- UINTN Argc;
- CHAR16 **Argv;
- SHELL_STATUS CommandReturnedStatus;
- BOOLEAN LastError;
- CHAR16 *Walker;
- CHAR16 *NewCmdLine;
+ EFI_STATUS Status;
+ UINTN Argc;
+ CHAR16 **Argv;
+ SHELL_STATUS CommandReturnedStatus;
+ BOOLEAN LastError;
+ CHAR16 *Walker;
+ CHAR16 *NewCmdLine;
NewCmdLine = AllocateCopyPool (StrSize (CmdLine), CmdLine);
if (NewCmdLine == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- for (Walker = NewCmdLine; Walker != NULL && *Walker != CHAR_NULL ; Walker++) {
- if (*Walker == L'^' && *(Walker+1) == L'#') {
- CopyMem(Walker, Walker+1, StrSize(Walker) - sizeof(Walker[0]));
+ for (Walker = NewCmdLine; Walker != NULL && *Walker != CHAR_NULL; Walker++) {
+ if ((*Walker == L'^') && (*(Walker+1) == L'#')) {
+ CopyMem (Walker, Walker+1, StrSize (Walker) - sizeof (Walker[0]));
}
}
//
// get the argc and argv updated for internal commands
//
- Status = UpdateArgcArgv(ParamProtocol, NewCmdLine, Internal_Command, &Argv, &Argc);
- if (!EFI_ERROR(Status)) {
+ Status = UpdateArgcArgv (ParamProtocol, NewCmdLine, Internal_Command, &Argv, &Argc);
+ if (!EFI_ERROR (Status)) {
//
// Run the internal command.
//
- Status = ShellCommandRunCommandHandler(FirstParameter, &CommandReturnedStatus, &LastError);
+ Status = ShellCommandRunCommandHandler (FirstParameter, &CommandReturnedStatus, &LastError);
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
if (CommandStatus != NULL) {
if (CommandReturnedStatus != SHELL_SUCCESS) {
*CommandStatus = (EFI_STATUS)(CommandReturnedStatus | MAX_BIT);
@@ -2362,23 +2501,23 @@ RunInternalCommand( // some commands do not update last error.
//
if (LastError) {
- SetLastError(CommandReturnedStatus);
+ SetLastError (CommandReturnedStatus);
}
//
// Pass thru the exitcode from the app.
//
- if (ShellCommandGetExit()) {
+ if (ShellCommandGetExit ()) {
//
// An Exit was requested ("exit" command), pass its value up.
//
Status = CommandReturnedStatus;
- } else if (CommandReturnedStatus != SHELL_SUCCESS && IsScriptOnlyCommand(FirstParameter)) {
+ } else if ((CommandReturnedStatus != SHELL_SUCCESS) && IsScriptOnlyCommand (FirstParameter)) {
//
// Always abort when a script only command fails for any reason
//
Status = EFI_ABORTED;
- } else if (ShellCommandGetCurrentScriptFile() != NULL && CommandReturnedStatus == SHELL_ABORTED) {
+ } else if ((ShellCommandGetCurrentScriptFile () != NULL) && (CommandReturnedStatus == SHELL_ABORTED)) {
//
// Abort when in a script and a command aborted
//
@@ -2391,7 +2530,7 @@ RunInternalCommand( // This is guaranteed to be called after UpdateArgcArgv no matter what else happened.
// This is safe even if the update API failed. In this case, it may be a no-op.
//
- RestoreArgcArgv(ParamProtocol, &Argv, &Argc);
+ RestoreArgcArgv (ParamProtocol, &Argv, &Argc);
//
// If a script is running and the command is not a script only command, then
@@ -2400,10 +2539,11 @@ RunInternalCommand( // Script only commands have to be able halt the script since the script will
// not operate if they are failing.
//
- if ( ShellCommandGetCurrentScriptFile() != NULL
- && !IsScriptOnlyCommand(FirstParameter)
- && Status != EFI_ABORTED
- ) {
+ if ( (ShellCommandGetCurrentScriptFile () != NULL)
+ && !IsScriptOnlyCommand (FirstParameter)
+ && (Status != EFI_ABORTED)
+ )
+ {
Status = EFI_SUCCESS;
}
@@ -2424,13 +2564,13 @@ RunInternalCommand( @retval EFI_ABORTED The command's operation was aborted.
**/
EFI_STATUS
-RunCommandOrFile(
+RunCommandOrFile (
IN SHELL_OPERATION_TYPES Type,
IN CONST CHAR16 *CmdLine,
IN CHAR16 *FirstParameter,
IN EFI_SHELL_PARAMETERS_PROTOCOL *ParamProtocol,
OUT EFI_STATUS *CommandStatus
-)
+ )
{
EFI_STATUS Status;
EFI_STATUS StartStatus;
@@ -2439,24 +2579,24 @@ RunCommandOrFile( EFI_DEVICE_PATH_PROTOCOL *DevPath;
SHELL_STATUS CalleeExitStatus;
- Status = EFI_SUCCESS;
- CommandWithPath = NULL;
- DevPath = NULL;
- CalleeExitStatus = SHELL_INVALID_PARAMETER;
+ Status = EFI_SUCCESS;
+ CommandWithPath = NULL;
+ DevPath = NULL;
+ CalleeExitStatus = SHELL_INVALID_PARAMETER;
switch (Type) {
- case Internal_Command:
- Status = RunInternalCommand(CmdLine, FirstParameter, ParamProtocol, CommandStatus);
+ case Internal_Command:
+ Status = RunInternalCommand (CmdLine, FirstParameter, ParamProtocol, CommandStatus);
break;
- case Script_File_Name:
- case Efi_Application:
+ case Script_File_Name:
+ case Efi_Application:
//
// Process a fully qualified path
//
- if (StrStr(FirstParameter, L":") != NULL) {
+ if (StrStr (FirstParameter, L":") != NULL) {
ASSERT (CommandWithPath == NULL);
- if (ShellIsFile(FirstParameter) == EFI_SUCCESS) {
- CommandWithPath = StrnCatGrow(&CommandWithPath, NULL, FirstParameter, 0);
+ if (ShellIsFile (FirstParameter) == EFI_SUCCESS) {
+ CommandWithPath = StrnCatGrow (&CommandWithPath, NULL, FirstParameter, 0);
}
}
@@ -2464,37 +2604,39 @@ RunCommandOrFile( // Process a relative path and also check in the path environment variable
//
if (CommandWithPath == NULL) {
- CommandWithPath = ShellFindFilePathEx(FirstParameter, mExecutableExtensions);
+ CommandWithPath = ShellFindFilePathEx (FirstParameter, mExecutableExtensions);
}
//
// This should be impossible now.
//
- ASSERT(CommandWithPath != NULL);
+ ASSERT (CommandWithPath != NULL);
//
// Make sure that path is not just a directory (or not found)
//
- if (!EFI_ERROR(ShellIsDirectory(CommandWithPath))) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND), ShellInfoObject.HiiHandle, FirstParameter);
- SetLastError(SHELL_NOT_FOUND);
+ if (!EFI_ERROR (ShellIsDirectory (CommandWithPath))) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND), ShellInfoObject.HiiHandle, FirstParameter);
+ SetLastError (SHELL_NOT_FOUND);
}
+
switch (Type) {
- case Script_File_Name:
- FullCommandWithPath = FullyQualifyPath(CommandWithPath);
+ case Script_File_Name:
+ FullCommandWithPath = FullyQualifyPath (CommandWithPath);
if (FullCommandWithPath == NULL) {
Status = RunScriptFile (CommandWithPath, NULL, CmdLine, ParamProtocol);
} else {
Status = RunScriptFile (FullCommandWithPath, NULL, CmdLine, ParamProtocol);
- FreePool(FullCommandWithPath);
+ FreePool (FullCommandWithPath);
}
+
break;
- case Efi_Application:
+ case Efi_Application:
//
// Get the device path of the application image
//
- DevPath = ShellInfoObject.NewEfiShellProtocol->GetDevicePathFromFilePath(CommandWithPath);
- if (DevPath == NULL){
+ DevPath = ShellInfoObject.NewEfiShellProtocol->GetDevicePathFromFilePath (CommandWithPath);
+ if (DevPath == NULL) {
Status = EFI_OUT_OF_RESOURCES;
break;
}
@@ -2502,20 +2644,20 @@ RunCommandOrFile( //
// Execute the device path
//
- Status = InternalShellExecuteDevicePath(
- &gImageHandle,
- DevPath,
- CmdLine,
- NULL,
- &StartStatus
- );
-
- SHELL_FREE_NON_NULL(DevPath);
-
- if(EFI_ERROR (Status)) {
- CalleeExitStatus = (SHELL_STATUS) (Status & (~MAX_BIT));
+ Status = InternalShellExecuteDevicePath (
+ &gImageHandle,
+ DevPath,
+ CmdLine,
+ NULL,
+ &StartStatus
+ );
+
+ SHELL_FREE_NON_NULL (DevPath);
+
+ if (EFI_ERROR (Status)) {
+ CalleeExitStatus = (SHELL_STATUS)(Status & (~MAX_BIT));
} else {
- CalleeExitStatus = (SHELL_STATUS) StartStatus;
+ CalleeExitStatus = (SHELL_STATUS)StartStatus;
}
if (CommandStatus != NULL) {
@@ -2526,7 +2668,7 @@ RunCommandOrFile( // Update last error status.
//
// Status is an EFI_STATUS. Clear top bit to convert to SHELL_STATUS
- SetLastError(CalleeExitStatus);
+ SetLastError (CalleeExitStatus);
break;
default:
//
@@ -2534,6 +2676,7 @@ RunCommandOrFile( //
break;
}
+
break;
default:
//
@@ -2542,7 +2685,7 @@ RunCommandOrFile( break;
}
- SHELL_FREE_NON_NULL(CommandWithPath);
+ SHELL_FREE_NON_NULL (CommandWithPath);
return (Status);
}
@@ -2560,51 +2703,51 @@ RunCommandOrFile( @retval EFI_ABORTED The command's operation was aborted.
**/
EFI_STATUS
-SetupAndRunCommandOrFile(
+SetupAndRunCommandOrFile (
IN SHELL_OPERATION_TYPES Type,
IN CHAR16 *CmdLine,
IN CHAR16 *FirstParameter,
IN EFI_SHELL_PARAMETERS_PROTOCOL *ParamProtocol,
OUT EFI_STATUS *CommandStatus
-)
+ )
{
- EFI_STATUS Status;
- SHELL_FILE_HANDLE OriginalStdIn;
- SHELL_FILE_HANDLE OriginalStdOut;
- SHELL_FILE_HANDLE OriginalStdErr;
- SYSTEM_TABLE_INFO OriginalSystemTableInfo;
- CONST SCRIPT_FILE *ConstScriptFile;
+ EFI_STATUS Status;
+ SHELL_FILE_HANDLE OriginalStdIn;
+ SHELL_FILE_HANDLE OriginalStdOut;
+ SHELL_FILE_HANDLE OriginalStdErr;
+ SYSTEM_TABLE_INFO OriginalSystemTableInfo;
+ CONST SCRIPT_FILE *ConstScriptFile;
//
// Update the StdIn, StdOut, and StdErr for redirection to environment variables, files, etc... unicode and ASCII
//
- Status = UpdateStdInStdOutStdErr(ParamProtocol, CmdLine, &OriginalStdIn, &OriginalStdOut, &OriginalStdErr, &OriginalSystemTableInfo);
+ Status = UpdateStdInStdOutStdErr (ParamProtocol, CmdLine, &OriginalStdIn, &OriginalStdOut, &OriginalStdErr, &OriginalSystemTableInfo);
//
// The StdIn, StdOut, and StdErr are set up.
// Now run the command, script, or application
//
- if (!EFI_ERROR(Status)) {
- TrimSpaces(&CmdLine);
- Status = RunCommandOrFile(Type, CmdLine, FirstParameter, ParamProtocol, CommandStatus);
+ if (!EFI_ERROR (Status)) {
+ TrimSpaces (&CmdLine);
+ Status = RunCommandOrFile (Type, CmdLine, FirstParameter, ParamProtocol, CommandStatus);
}
//
// Now print errors
//
- if (EFI_ERROR(Status)) {
- ConstScriptFile = ShellCommandGetCurrentScriptFile();
- if (ConstScriptFile == NULL || ConstScriptFile->CurrentCommand == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_ERROR), ShellInfoObject.HiiHandle, (VOID*)(Status));
+ if (EFI_ERROR (Status)) {
+ ConstScriptFile = ShellCommandGetCurrentScriptFile ();
+ if ((ConstScriptFile == NULL) || (ConstScriptFile->CurrentCommand == NULL)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SHELL_ERROR), ShellInfoObject.HiiHandle, (VOID *)(Status));
} else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_ERROR_SCRIPT), ShellInfoObject.HiiHandle, (VOID*)(Status), ConstScriptFile->CurrentCommand->Line);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SHELL_ERROR_SCRIPT), ShellInfoObject.HiiHandle, (VOID *)(Status), ConstScriptFile->CurrentCommand->Line);
}
}
//
// put back the original StdIn, StdOut, and StdErr
//
- RestoreStdInStdOutStdErr(ParamProtocol, &OriginalStdIn, &OriginalStdOut, &OriginalStdErr, &OriginalSystemTableInfo);
+ RestoreStdInStdOutStdErr (ParamProtocol, &OriginalStdIn, &OriginalStdOut, &OriginalStdErr, &OriginalSystemTableInfo);
return (Status);
}
@@ -2622,32 +2765,32 @@ SetupAndRunCommandOrFile( @retval EFI_ABORTED The command's operation was aborted.
**/
EFI_STATUS
-RunShellCommand(
- IN CONST CHAR16 *CmdLine,
- OUT EFI_STATUS *CommandStatus
+RunShellCommand (
+ IN CONST CHAR16 *CmdLine,
+ OUT EFI_STATUS *CommandStatus
)
{
- EFI_STATUS Status;
- CHAR16 *CleanOriginal;
- CHAR16 *FirstParameter;
- CHAR16 *TempWalker;
- SHELL_OPERATION_TYPES Type;
- CONST CHAR16 *CurDir;
-
- ASSERT(CmdLine != NULL);
- if (StrLen(CmdLine) == 0) {
+ EFI_STATUS Status;
+ CHAR16 *CleanOriginal;
+ CHAR16 *FirstParameter;
+ CHAR16 *TempWalker;
+ SHELL_OPERATION_TYPES Type;
+ CONST CHAR16 *CurDir;
+
+ ASSERT (CmdLine != NULL);
+ if (StrLen (CmdLine) == 0) {
return (EFI_SUCCESS);
}
- Status = EFI_SUCCESS;
- CleanOriginal = NULL;
+ Status = EFI_SUCCESS;
+ CleanOriginal = NULL;
- CleanOriginal = StrnCatGrow(&CleanOriginal, NULL, CmdLine, 0);
+ CleanOriginal = StrnCatGrow (&CleanOriginal, NULL, CmdLine, 0);
if (CleanOriginal == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
- TrimSpaces(&CleanOriginal);
+ TrimSpaces (&CleanOriginal);
//
// NULL out comments (leveraged from RunScriptFileHandle() ).
@@ -2665,71 +2808,73 @@ RunShellCommand( }
}
- TrimSpaces(&CleanOriginal);
+ TrimSpaces (&CleanOriginal);
//
// Handle case that passed in command line is just 1 or more " " characters.
//
if (StrLen (CleanOriginal) == 0) {
- SHELL_FREE_NON_NULL(CleanOriginal);
+ SHELL_FREE_NON_NULL (CleanOriginal);
return (EFI_SUCCESS);
}
- Status = ProcessCommandLineToFinal(&CleanOriginal);
- if (EFI_ERROR(Status)) {
- SHELL_FREE_NON_NULL(CleanOriginal);
+ Status = ProcessCommandLineToFinal (&CleanOriginal);
+ if (EFI_ERROR (Status)) {
+ SHELL_FREE_NON_NULL (CleanOriginal);
return (Status);
}
//
// We don't do normal processing with a split command line (output from one command input to another)
//
- if (ContainsSplit(CleanOriginal)) {
- Status = ProcessNewSplitCommandLine(CleanOriginal);
- SHELL_FREE_NON_NULL(CleanOriginal);
+ if (ContainsSplit (CleanOriginal)) {
+ Status = ProcessNewSplitCommandLine (CleanOriginal);
+ SHELL_FREE_NON_NULL (CleanOriginal);
return (Status);
}
//
// We need the first parameter information so we can determine the operation type
//
- FirstParameter = AllocateZeroPool(StrSize(CleanOriginal));
+ FirstParameter = AllocateZeroPool (StrSize (CleanOriginal));
if (FirstParameter == NULL) {
- SHELL_FREE_NON_NULL(CleanOriginal);
+ SHELL_FREE_NON_NULL (CleanOriginal);
return (EFI_OUT_OF_RESOURCES);
}
+
TempWalker = CleanOriginal;
- if (!EFI_ERROR(GetNextParameter(&TempWalker, &FirstParameter, StrSize(CleanOriginal), TRUE))) {
+ if (!EFI_ERROR (GetNextParameter (&TempWalker, &FirstParameter, StrSize (CleanOriginal), TRUE))) {
//
// Depending on the first parameter we change the behavior
//
- switch (Type = GetOperationType(FirstParameter)) {
- case File_Sys_Change:
+ switch (Type = GetOperationType (FirstParameter)) {
+ case File_Sys_Change:
Status = ChangeMappedDrive (FirstParameter);
break;
- case Internal_Command:
- case Script_File_Name:
- case Efi_Application:
- Status = SetupAndRunCommandOrFile(Type, CleanOriginal, FirstParameter, ShellInfoObject.NewShellParametersProtocol, CommandStatus);
+ case Internal_Command:
+ case Script_File_Name:
+ case Efi_Application:
+ Status = SetupAndRunCommandOrFile (Type, CleanOriginal, FirstParameter, ShellInfoObject.NewShellParametersProtocol, CommandStatus);
break;
default:
//
// Whatever was typed, it was invalid.
//
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND), ShellInfoObject.HiiHandle, FirstParameter);
- SetLastError(SHELL_NOT_FOUND);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND), ShellInfoObject.HiiHandle, FirstParameter);
+ SetLastError (SHELL_NOT_FOUND);
break;
}
} else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND), ShellInfoObject.HiiHandle, FirstParameter);
- SetLastError(SHELL_NOT_FOUND);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SHELL_NOT_FOUND), ShellInfoObject.HiiHandle, FirstParameter);
+ SetLastError (SHELL_NOT_FOUND);
}
+
//
// Check whether the current file system still exists. If not exist, we need update "cwd" and gShellCurMapping.
//
CurDir = EfiShellGetCurDir (NULL);
if (CurDir != NULL) {
- if (EFI_ERROR(ShellFileExists (CurDir))) {
+ if (EFI_ERROR (ShellFileExists (CurDir))) {
//
// EfiShellSetCurDir() cannot set current directory to NULL.
// EfiShellSetEnv() is not allowed to set the "cwd" variable.
@@ -2740,8 +2885,8 @@ RunShellCommand( }
}
- SHELL_FREE_NON_NULL(CleanOriginal);
- SHELL_FREE_NON_NULL(FirstParameter);
+ SHELL_FREE_NON_NULL (CleanOriginal);
+ SHELL_FREE_NON_NULL (FirstParameter);
return (Status);
}
@@ -2758,11 +2903,11 @@ RunShellCommand( @retval EFI_ABORTED The command's operation was aborted.
**/
EFI_STATUS
-RunCommand(
- IN CONST CHAR16 *CmdLine
+RunCommand (
+ IN CONST CHAR16 *CmdLine
)
{
- return (RunShellCommand(CmdLine, NULL));
+ return (RunShellCommand (CmdLine, NULL));
}
/**
@@ -2779,28 +2924,28 @@ RunScriptFileHandle ( IN CONST CHAR16 *Name
)
{
- EFI_STATUS Status;
- SCRIPT_FILE *NewScriptFile;
- UINTN LoopVar;
- UINTN PrintBuffSize;
- CHAR16 *CommandLine;
- CHAR16 *CommandLine2;
- CHAR16 *CommandLine3;
- SCRIPT_COMMAND_LIST *LastCommand;
- BOOLEAN Ascii;
- BOOLEAN PreScriptEchoState;
- BOOLEAN PreCommandEchoState;
- CONST CHAR16 *CurDir;
- UINTN LineCount;
- CHAR16 LeString[50];
- LIST_ENTRY OldBufferList;
-
- ASSERT(!ShellCommandGetScriptExit());
-
- PreScriptEchoState = ShellCommandGetEchoState();
- PrintBuffSize = PcdGet16(PcdShellPrintBufferSize);
-
- NewScriptFile = (SCRIPT_FILE*)AllocateZeroPool(sizeof(SCRIPT_FILE));
+ EFI_STATUS Status;
+ SCRIPT_FILE *NewScriptFile;
+ UINTN LoopVar;
+ UINTN PrintBuffSize;
+ CHAR16 *CommandLine;
+ CHAR16 *CommandLine2;
+ CHAR16 *CommandLine3;
+ SCRIPT_COMMAND_LIST *LastCommand;
+ BOOLEAN Ascii;
+ BOOLEAN PreScriptEchoState;
+ BOOLEAN PreCommandEchoState;
+ CONST CHAR16 *CurDir;
+ UINTN LineCount;
+ CHAR16 LeString[50];
+ LIST_ENTRY OldBufferList;
+
+ ASSERT (!ShellCommandGetScriptExit ());
+
+ PreScriptEchoState = ShellCommandGetEchoState ();
+ PrintBuffSize = PcdGet16 (PcdShellPrintBufferSize);
+
+ NewScriptFile = (SCRIPT_FILE *)AllocateZeroPool (sizeof (SCRIPT_FILE));
if (NewScriptFile == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
@@ -2808,10 +2953,10 @@ RunScriptFileHandle ( //
// Set up the name
//
- ASSERT(NewScriptFile->ScriptName == NULL);
- NewScriptFile->ScriptName = StrnCatGrow(&NewScriptFile->ScriptName, NULL, Name, 0);
+ ASSERT (NewScriptFile->ScriptName == NULL);
+ NewScriptFile->ScriptName = StrnCatGrow (&NewScriptFile->ScriptName, NULL, Name, 0);
if (NewScriptFile->ScriptName == NULL) {
- DeleteScriptFileStruct(NewScriptFile);
+ DeleteScriptFileStruct (NewScriptFile);
return (EFI_OUT_OF_RESOURCES);
}
@@ -2820,21 +2965,22 @@ RunScriptFileHandle ( //
NewScriptFile->Argc = ShellInfoObject.NewShellParametersProtocol->Argc;
if (NewScriptFile->Argc != 0) {
- NewScriptFile->Argv = (CHAR16**)AllocateZeroPool(NewScriptFile->Argc * sizeof(CHAR16*));
+ NewScriptFile->Argv = (CHAR16 **)AllocateZeroPool (NewScriptFile->Argc * sizeof (CHAR16 *));
if (NewScriptFile->Argv == NULL) {
- DeleteScriptFileStruct(NewScriptFile);
+ DeleteScriptFileStruct (NewScriptFile);
return (EFI_OUT_OF_RESOURCES);
}
+
//
// Put the full path of the script file into Argv[0] as required by section
// 3.6.2 of version 2.2 of the shell specification.
//
- NewScriptFile->Argv[0] = StrnCatGrow(&NewScriptFile->Argv[0], NULL, NewScriptFile->ScriptName, 0);
- for (LoopVar = 1 ; LoopVar < 10 && LoopVar < NewScriptFile->Argc; LoopVar++) {
- ASSERT(NewScriptFile->Argv[LoopVar] == NULL);
- NewScriptFile->Argv[LoopVar] = StrnCatGrow(&NewScriptFile->Argv[LoopVar], NULL, ShellInfoObject.NewShellParametersProtocol->Argv[LoopVar], 0);
+ NewScriptFile->Argv[0] = StrnCatGrow (&NewScriptFile->Argv[0], NULL, NewScriptFile->ScriptName, 0);
+ for (LoopVar = 1; LoopVar < 10 && LoopVar < NewScriptFile->Argc; LoopVar++) {
+ ASSERT (NewScriptFile->Argv[LoopVar] == NULL);
+ NewScriptFile->Argv[LoopVar] = StrnCatGrow (&NewScriptFile->Argv[LoopVar], NULL, ShellInfoObject.NewShellParametersProtocol->Argv[LoopVar], 0);
if (NewScriptFile->Argv[LoopVar] == NULL) {
- DeleteScriptFileStruct(NewScriptFile);
+ DeleteScriptFileStruct (NewScriptFile);
return (EFI_OUT_OF_RESOURCES);
}
}
@@ -2842,24 +2988,25 @@ RunScriptFileHandle ( NewScriptFile->Argv = NULL;
}
- InitializeListHead(&NewScriptFile->CommandList);
- InitializeListHead(&NewScriptFile->SubstList);
+ InitializeListHead (&NewScriptFile->CommandList);
+ InitializeListHead (&NewScriptFile->SubstList);
//
// Now build the list of all script commands.
//
LineCount = 0;
- while(!ShellFileHandleEof(Handle)) {
- CommandLine = ShellFileHandleReturnLine(Handle, &Ascii);
+ while (!ShellFileHandleEof (Handle)) {
+ CommandLine = ShellFileHandleReturnLine (Handle, &Ascii);
LineCount++;
- if (CommandLine == NULL || StrLen(CommandLine) == 0 || CommandLine[0] == '#') {
- SHELL_FREE_NON_NULL(CommandLine);
+ if ((CommandLine == NULL) || (StrLen (CommandLine) == 0) || (CommandLine[0] == '#')) {
+ SHELL_FREE_NON_NULL (CommandLine);
continue;
}
- NewScriptFile->CurrentCommand = AllocateZeroPool(sizeof(SCRIPT_COMMAND_LIST));
+
+ NewScriptFile->CurrentCommand = AllocateZeroPool (sizeof (SCRIPT_COMMAND_LIST));
if (NewScriptFile->CurrentCommand == NULL) {
- SHELL_FREE_NON_NULL(CommandLine);
- DeleteScriptFileStruct(NewScriptFile);
+ SHELL_FREE_NON_NULL (CommandLine);
+ DeleteScriptFileStruct (NewScriptFile);
return (EFI_OUT_OF_RESOURCES);
}
@@ -2867,7 +3014,7 @@ RunScriptFileHandle ( NewScriptFile->CurrentCommand->Data = NULL;
NewScriptFile->CurrentCommand->Line = LineCount;
- InsertTailList(&NewScriptFile->CommandList, &NewScriptFile->CurrentCommand->Link);
+ InsertTailList (&NewScriptFile->CommandList, &NewScriptFile->CurrentCommand->Link);
}
//
@@ -2878,38 +3025,41 @@ RunScriptFileHandle ( //
// Now enumerate through the commands and run each one.
//
- CommandLine = AllocateZeroPool(PrintBuffSize);
+ CommandLine = AllocateZeroPool (PrintBuffSize);
if (CommandLine == NULL) {
- DeleteScriptFileStruct(NewScriptFile);
+ DeleteScriptFileStruct (NewScriptFile);
return (EFI_OUT_OF_RESOURCES);
}
- CommandLine2 = AllocateZeroPool(PrintBuffSize);
+
+ CommandLine2 = AllocateZeroPool (PrintBuffSize);
if (CommandLine2 == NULL) {
- FreePool(CommandLine);
- DeleteScriptFileStruct(NewScriptFile);
+ FreePool (CommandLine);
+ DeleteScriptFileStruct (NewScriptFile);
return (EFI_OUT_OF_RESOURCES);
}
- for ( NewScriptFile->CurrentCommand = (SCRIPT_COMMAND_LIST *)GetFirstNode(&NewScriptFile->CommandList)
- ; !IsNull(&NewScriptFile->CommandList, &NewScriptFile->CurrentCommand->Link)
- ; // conditional increment in the body of the loop
- ){
- ASSERT(CommandLine2 != NULL);
- StrnCpyS( CommandLine2,
- PrintBuffSize/sizeof(CHAR16),
- NewScriptFile->CurrentCommand->Cl,
- PrintBuffSize/sizeof(CHAR16) - 1
- );
+ for ( NewScriptFile->CurrentCommand = (SCRIPT_COMMAND_LIST *)GetFirstNode (&NewScriptFile->CommandList)
+ ; !IsNull (&NewScriptFile->CommandList, &NewScriptFile->CurrentCommand->Link)
+ ; // conditional increment in the body of the loop
+ )
+ {
+ ASSERT (CommandLine2 != NULL);
+ StrnCpyS (
+ CommandLine2,
+ PrintBuffSize/sizeof (CHAR16),
+ NewScriptFile->CurrentCommand->Cl,
+ PrintBuffSize/sizeof (CHAR16) - 1
+ );
- SaveBufferList(&OldBufferList);
+ SaveBufferList (&OldBufferList);
//
// NULL out comments
//
- for (CommandLine3 = CommandLine2 ; CommandLine3 != NULL && *CommandLine3 != CHAR_NULL ; CommandLine3++) {
+ for (CommandLine3 = CommandLine2; CommandLine3 != NULL && *CommandLine3 != CHAR_NULL; CommandLine3++) {
if (*CommandLine3 == L'^') {
if ( *(CommandLine3+1) == L':') {
- CopyMem(CommandLine3, CommandLine3+1, StrSize(CommandLine3) - sizeof(CommandLine3[0]));
+ CopyMem (CommandLine3, CommandLine3+1, StrSize (CommandLine3) - sizeof (CommandLine3[0]));
} else if (*(CommandLine3+1) == L'#') {
CommandLine3++;
}
@@ -2918,15 +3068,16 @@ RunScriptFileHandle ( }
}
- if (CommandLine2 != NULL && StrLen(CommandLine2) >= 1) {
+ if ((CommandLine2 != NULL) && (StrLen (CommandLine2) >= 1)) {
//
// Due to variability in starting the find and replace action we need to have both buffers the same.
//
- StrnCpyS( CommandLine,
- PrintBuffSize/sizeof(CHAR16),
- CommandLine2,
- PrintBuffSize/sizeof(CHAR16) - 1
- );
+ StrnCpyS (
+ CommandLine,
+ PrintBuffSize/sizeof (CHAR16),
+ CommandLine2,
+ PrintBuffSize/sizeof (CHAR16) - 1
+ );
//
// Remove the %0 to %9 from the command line (if we have some arguments)
@@ -2934,154 +3085,167 @@ RunScriptFileHandle ( if (NewScriptFile->Argv != NULL) {
switch (NewScriptFile->Argc) {
default:
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PrintBuffSize, L"%9", NewScriptFile->Argv[9], FALSE, FALSE);
- ASSERT_EFI_ERROR(Status);
+ Status = ShellCopySearchAndReplace (CommandLine2, CommandLine, PrintBuffSize, L"%9", NewScriptFile->Argv[9], FALSE, FALSE);
+ ASSERT_EFI_ERROR (Status);
case 9:
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PrintBuffSize, L"%8", NewScriptFile->Argv[8], FALSE, FALSE);
- ASSERT_EFI_ERROR(Status);
+ Status = ShellCopySearchAndReplace (CommandLine, CommandLine2, PrintBuffSize, L"%8", NewScriptFile->Argv[8], FALSE, FALSE);
+ ASSERT_EFI_ERROR (Status);
case 8:
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PrintBuffSize, L"%7", NewScriptFile->Argv[7], FALSE, FALSE);
- ASSERT_EFI_ERROR(Status);
+ Status = ShellCopySearchAndReplace (CommandLine2, CommandLine, PrintBuffSize, L"%7", NewScriptFile->Argv[7], FALSE, FALSE);
+ ASSERT_EFI_ERROR (Status);
case 7:
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PrintBuffSize, L"%6", NewScriptFile->Argv[6], FALSE, FALSE);
- ASSERT_EFI_ERROR(Status);
+ Status = ShellCopySearchAndReplace (CommandLine, CommandLine2, PrintBuffSize, L"%6", NewScriptFile->Argv[6], FALSE, FALSE);
+ ASSERT_EFI_ERROR (Status);
case 6:
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PrintBuffSize, L"%5", NewScriptFile->Argv[5], FALSE, FALSE);
- ASSERT_EFI_ERROR(Status);
+ Status = ShellCopySearchAndReplace (CommandLine2, CommandLine, PrintBuffSize, L"%5", NewScriptFile->Argv[5], FALSE, FALSE);
+ ASSERT_EFI_ERROR (Status);
case 5:
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PrintBuffSize, L"%4", NewScriptFile->Argv[4], FALSE, FALSE);
- ASSERT_EFI_ERROR(Status);
+ Status = ShellCopySearchAndReplace (CommandLine, CommandLine2, PrintBuffSize, L"%4", NewScriptFile->Argv[4], FALSE, FALSE);
+ ASSERT_EFI_ERROR (Status);
case 4:
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PrintBuffSize, L"%3", NewScriptFile->Argv[3], FALSE, FALSE);
- ASSERT_EFI_ERROR(Status);
+ Status = ShellCopySearchAndReplace (CommandLine2, CommandLine, PrintBuffSize, L"%3", NewScriptFile->Argv[3], FALSE, FALSE);
+ ASSERT_EFI_ERROR (Status);
case 3:
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PrintBuffSize, L"%2", NewScriptFile->Argv[2], FALSE, FALSE);
- ASSERT_EFI_ERROR(Status);
+ Status = ShellCopySearchAndReplace (CommandLine, CommandLine2, PrintBuffSize, L"%2", NewScriptFile->Argv[2], FALSE, FALSE);
+ ASSERT_EFI_ERROR (Status);
case 2:
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PrintBuffSize, L"%1", NewScriptFile->Argv[1], FALSE, FALSE);
- ASSERT_EFI_ERROR(Status);
+ Status = ShellCopySearchAndReplace (CommandLine2, CommandLine, PrintBuffSize, L"%1", NewScriptFile->Argv[1], FALSE, FALSE);
+ ASSERT_EFI_ERROR (Status);
case 1:
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PrintBuffSize, L"%0", NewScriptFile->Argv[0], FALSE, FALSE);
- ASSERT_EFI_ERROR(Status);
+ Status = ShellCopySearchAndReplace (CommandLine, CommandLine2, PrintBuffSize, L"%0", NewScriptFile->Argv[0], FALSE, FALSE);
+ ASSERT_EFI_ERROR (Status);
break;
case 0:
break;
}
}
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PrintBuffSize, L"%1", L"\"\"", FALSE, FALSE);
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PrintBuffSize, L"%2", L"\"\"", FALSE, FALSE);
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PrintBuffSize, L"%3", L"\"\"", FALSE, FALSE);
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PrintBuffSize, L"%4", L"\"\"", FALSE, FALSE);
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PrintBuffSize, L"%5", L"\"\"", FALSE, FALSE);
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PrintBuffSize, L"%6", L"\"\"", FALSE, FALSE);
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PrintBuffSize, L"%7", L"\"\"", FALSE, FALSE);
- Status = ShellCopySearchAndReplace(CommandLine, CommandLine2, PrintBuffSize, L"%8", L"\"\"", FALSE, FALSE);
- Status = ShellCopySearchAndReplace(CommandLine2, CommandLine, PrintBuffSize, L"%9", L"\"\"", FALSE, FALSE);
-
- StrnCpyS( CommandLine2,
- PrintBuffSize/sizeof(CHAR16),
- CommandLine,
- PrintBuffSize/sizeof(CHAR16) - 1
- );
+
+ Status = ShellCopySearchAndReplace (CommandLine2, CommandLine, PrintBuffSize, L"%1", L"\"\"", FALSE, FALSE);
+ Status = ShellCopySearchAndReplace (CommandLine, CommandLine2, PrintBuffSize, L"%2", L"\"\"", FALSE, FALSE);
+ Status = ShellCopySearchAndReplace (CommandLine2, CommandLine, PrintBuffSize, L"%3", L"\"\"", FALSE, FALSE);
+ Status = ShellCopySearchAndReplace (CommandLine, CommandLine2, PrintBuffSize, L"%4", L"\"\"", FALSE, FALSE);
+ Status = ShellCopySearchAndReplace (CommandLine2, CommandLine, PrintBuffSize, L"%5", L"\"\"", FALSE, FALSE);
+ Status = ShellCopySearchAndReplace (CommandLine, CommandLine2, PrintBuffSize, L"%6", L"\"\"", FALSE, FALSE);
+ Status = ShellCopySearchAndReplace (CommandLine2, CommandLine, PrintBuffSize, L"%7", L"\"\"", FALSE, FALSE);
+ Status = ShellCopySearchAndReplace (CommandLine, CommandLine2, PrintBuffSize, L"%8", L"\"\"", FALSE, FALSE);
+ Status = ShellCopySearchAndReplace (CommandLine2, CommandLine, PrintBuffSize, L"%9", L"\"\"", FALSE, FALSE);
+
+ StrnCpyS (
+ CommandLine2,
+ PrintBuffSize/sizeof (CHAR16),
+ CommandLine,
+ PrintBuffSize/sizeof (CHAR16) - 1
+ );
LastCommand = NewScriptFile->CurrentCommand;
- for (CommandLine3 = CommandLine2 ; CommandLine3[0] == L' ' ; CommandLine3++);
+ for (CommandLine3 = CommandLine2; CommandLine3[0] == L' '; CommandLine3++) {
+ }
- if (CommandLine3 != NULL && CommandLine3[0] == L':' ) {
+ if ((CommandLine3 != NULL) && (CommandLine3[0] == L':')) {
//
// This line is a goto target / label
//
} else {
- if (CommandLine3 != NULL && StrLen(CommandLine3) > 0) {
+ if ((CommandLine3 != NULL) && (StrLen (CommandLine3) > 0)) {
if (CommandLine3[0] == L'@') {
//
// We need to save the current echo state
// and disable echo for just this command.
//
- PreCommandEchoState = ShellCommandGetEchoState();
- ShellCommandSetEchoState(FALSE);
- Status = RunCommand(CommandLine3+1);
+ PreCommandEchoState = ShellCommandGetEchoState ();
+ ShellCommandSetEchoState (FALSE);
+ Status = RunCommand (CommandLine3+1);
//
// If command was "@echo -off" or "@echo -on" then don't restore echo state
//
- if (StrCmp (L"@echo -off", CommandLine3) != 0 &&
- StrCmp (L"@echo -on", CommandLine3) != 0) {
+ if ((StrCmp (L"@echo -off", CommandLine3) != 0) &&
+ (StrCmp (L"@echo -on", CommandLine3) != 0))
+ {
//
// Now restore the pre-'@' echo state.
//
- ShellCommandSetEchoState(PreCommandEchoState);
+ ShellCommandSetEchoState (PreCommandEchoState);
}
} else {
- if (ShellCommandGetEchoState()) {
- CurDir = ShellInfoObject.NewEfiShellProtocol->GetEnv(L"cwd");
- if (CurDir != NULL && StrLen(CurDir) > 1) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_CURDIR), ShellInfoObject.HiiHandle, CurDir);
+ if (ShellCommandGetEchoState ()) {
+ CurDir = ShellInfoObject.NewEfiShellProtocol->GetEnv (L"cwd");
+ if ((CurDir != NULL) && (StrLen (CurDir) > 1)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SHELL_CURDIR), ShellInfoObject.HiiHandle, CurDir);
} else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_SHELL), ShellInfoObject.HiiHandle);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SHELL_SHELL), ShellInfoObject.HiiHandle);
}
- ShellPrintEx(-1, -1, L"%s\r\n", CommandLine2);
+
+ ShellPrintEx (-1, -1, L"%s\r\n", CommandLine2);
}
- Status = RunCommand(CommandLine3);
+
+ Status = RunCommand (CommandLine3);
}
}
- if (ShellCommandGetScriptExit()) {
+ if (ShellCommandGetScriptExit ()) {
//
// ShellCommandGetExitCode() always returns a UINT64
//
- UnicodeSPrint(LeString, sizeof(LeString), L"0x%Lx", ShellCommandGetExitCode());
- DEBUG_CODE(InternalEfiShellSetEnv(L"debuglasterror", LeString, TRUE););
- InternalEfiShellSetEnv(L"lasterror", LeString, TRUE);
+ UnicodeSPrint (LeString, sizeof (LeString), L"0x%Lx", ShellCommandGetExitCode ());
+ DEBUG_CODE (
+ InternalEfiShellSetEnv (L"debuglasterror", LeString, TRUE);
+ );
+ InternalEfiShellSetEnv (L"lasterror", LeString, TRUE);
- ShellCommandRegisterExit(FALSE, 0);
+ ShellCommandRegisterExit (FALSE, 0);
Status = EFI_SUCCESS;
- RestoreBufferList(&OldBufferList);
+ RestoreBufferList (&OldBufferList);
break;
}
- if (ShellGetExecutionBreakFlag()) {
- RestoreBufferList(&OldBufferList);
+
+ if (ShellGetExecutionBreakFlag ()) {
+ RestoreBufferList (&OldBufferList);
break;
}
- if (EFI_ERROR(Status)) {
- RestoreBufferList(&OldBufferList);
+
+ if (EFI_ERROR (Status)) {
+ RestoreBufferList (&OldBufferList);
break;
}
- if (ShellCommandGetExit()) {
- RestoreBufferList(&OldBufferList);
+
+ if (ShellCommandGetExit ()) {
+ RestoreBufferList (&OldBufferList);
break;
}
}
+
//
// If that commend did not update the CurrentCommand then we need to advance it...
//
if (LastCommand == NewScriptFile->CurrentCommand) {
- NewScriptFile->CurrentCommand = (SCRIPT_COMMAND_LIST *)GetNextNode(&NewScriptFile->CommandList, &NewScriptFile->CurrentCommand->Link);
- if (!IsNull(&NewScriptFile->CommandList, &NewScriptFile->CurrentCommand->Link)) {
+ NewScriptFile->CurrentCommand = (SCRIPT_COMMAND_LIST *)GetNextNode (&NewScriptFile->CommandList, &NewScriptFile->CurrentCommand->Link);
+ if (!IsNull (&NewScriptFile->CommandList, &NewScriptFile->CurrentCommand->Link)) {
NewScriptFile->CurrentCommand->Reset = TRUE;
}
}
} else {
- NewScriptFile->CurrentCommand = (SCRIPT_COMMAND_LIST *)GetNextNode(&NewScriptFile->CommandList, &NewScriptFile->CurrentCommand->Link);
- if (!IsNull(&NewScriptFile->CommandList, &NewScriptFile->CurrentCommand->Link)) {
+ NewScriptFile->CurrentCommand = (SCRIPT_COMMAND_LIST *)GetNextNode (&NewScriptFile->CommandList, &NewScriptFile->CurrentCommand->Link);
+ if (!IsNull (&NewScriptFile->CommandList, &NewScriptFile->CurrentCommand->Link)) {
NewScriptFile->CurrentCommand->Reset = TRUE;
}
}
- RestoreBufferList(&OldBufferList);
- }
+ RestoreBufferList (&OldBufferList);
+ }
- FreePool(CommandLine);
- FreePool(CommandLine2);
+ FreePool (CommandLine);
+ FreePool (CommandLine2);
ShellCommandSetNewScript (NULL);
//
// Only if this was the last script reset the state.
//
- if (ShellCommandGetCurrentScriptFile()==NULL) {
- ShellCommandSetEchoState(PreScriptEchoState);
+ if (ShellCommandGetCurrentScriptFile () == NULL) {
+ ShellCommandSetEchoState (PreScriptEchoState);
}
+
return (EFI_SUCCESS);
}
@@ -3103,39 +3267,38 @@ RunScriptFile ( IN EFI_SHELL_PARAMETERS_PROTOCOL *ParamProtocol
)
{
- EFI_STATUS Status;
- SHELL_FILE_HANDLE FileHandle;
- UINTN Argc;
- CHAR16 **Argv;
+ EFI_STATUS Status;
+ SHELL_FILE_HANDLE FileHandle;
+ UINTN Argc;
+ CHAR16 **Argv;
- if (ShellIsFile(ScriptPath) != EFI_SUCCESS) {
+ if (ShellIsFile (ScriptPath) != EFI_SUCCESS) {
return (EFI_INVALID_PARAMETER);
}
//
// get the argc and argv updated for scripts
//
- Status = UpdateArgcArgv(ParamProtocol, CmdLine, Script_File_Name, &Argv, &Argc);
- if (!EFI_ERROR(Status)) {
-
+ Status = UpdateArgcArgv (ParamProtocol, CmdLine, Script_File_Name, &Argv, &Argc);
+ if (!EFI_ERROR (Status)) {
if (Handle == NULL) {
//
// open the file
//
- Status = ShellOpenFileByName(ScriptPath, &FileHandle, EFI_FILE_MODE_READ, 0);
- if (!EFI_ERROR(Status)) {
+ Status = ShellOpenFileByName (ScriptPath, &FileHandle, EFI_FILE_MODE_READ, 0);
+ if (!EFI_ERROR (Status)) {
//
// run it
//
- Status = RunScriptFileHandle(FileHandle, ScriptPath);
+ Status = RunScriptFileHandle (FileHandle, ScriptPath);
//
// now close the file
//
- ShellCloseFile(&FileHandle);
+ ShellCloseFile (&FileHandle);
}
} else {
- Status = RunScriptFileHandle(Handle, ScriptPath);
+ Status = RunScriptFileHandle (Handle, ScriptPath);
}
}
@@ -3143,7 +3306,7 @@ RunScriptFile ( // This is guaranteed to be called after UpdateArgcArgv no matter what else happened.
// This is safe even if the update API failed. In this case, it may be a no-op.
//
- RestoreArgcArgv(ParamProtocol, &Argv, &Argc);
+ RestoreArgcArgv (ParamProtocol, &Argv, &Argc);
return (Status);
}
@@ -3158,26 +3321,28 @@ RunScriptFile ( @return the location of the first character in the string
@retval CHAR_NULL no instance of any character in CharacterList was found in String
**/
-CONST CHAR16*
-FindFirstCharacter(
- IN CONST CHAR16 *String,
- IN CONST CHAR16 *CharacterList,
- IN CONST CHAR16 EscapeCharacter
+CONST CHAR16 *
+FindFirstCharacter (
+ IN CONST CHAR16 *String,
+ IN CONST CHAR16 *CharacterList,
+ IN CONST CHAR16 EscapeCharacter
)
{
- UINT32 WalkChar;
- UINT32 WalkStr;
+ UINT32 WalkChar;
+ UINT32 WalkStr;
- for (WalkStr = 0; WalkStr < StrLen(String); WalkStr++) {
+ for (WalkStr = 0; WalkStr < StrLen (String); WalkStr++) {
if (String[WalkStr] == EscapeCharacter) {
WalkStr++;
continue;
}
- for (WalkChar = 0; WalkChar < StrLen(CharacterList); WalkChar++) {
+
+ for (WalkChar = 0; WalkChar < StrLen (CharacterList); WalkChar++) {
if (String[WalkStr] == CharacterList[WalkChar]) {
return (&String[WalkStr]);
}
}
}
- return (String + StrLen(String));
+
+ return (String + StrLen (String));
}
diff --git a/ShellPkg/Application/Shell/Shell.h b/ShellPkg/Application/Shell/Shell.h index e6eb150..89b4ac6 100644 --- a/ShellPkg/Application/Shell/Shell.h +++ b/ShellPkg/Application/Shell/Shell.h @@ -51,75 +51,75 @@ #include "ConsoleWrappers.h"
#include "FileHandleWrappers.h"
-extern CONST CHAR16 mNoNestingEnvVarName[];
-extern CONST CHAR16 mNoNestingTrue[];
-extern CONST CHAR16 mNoNestingFalse[];
+extern CONST CHAR16 mNoNestingEnvVarName[];
+extern CONST CHAR16 mNoNestingTrue[];
+extern CONST CHAR16 mNoNestingFalse[];
typedef struct {
- LIST_ENTRY Link; ///< Standard linked list handler.
- SHELL_FILE_HANDLE SplitStdOut; ///< ConsoleOut for use in the split.
- SHELL_FILE_HANDLE SplitStdIn; ///< ConsoleIn for use in the split.
+ LIST_ENTRY Link; ///< Standard linked list handler.
+ SHELL_FILE_HANDLE SplitStdOut; ///< ConsoleOut for use in the split.
+ SHELL_FILE_HANDLE SplitStdIn; ///< ConsoleIn for use in the split.
} SPLIT_LIST;
typedef struct {
- UINT32 Startup:1; ///< Was "-startup" found on command line.
- UINT32 NoStartup:1; ///< Was "-nostartup" found on command line.
- UINT32 NoConsoleOut:1; ///< Was "-noconsoleout" found on command line.
- UINT32 NoConsoleIn:1; ///< Was "-noconsolein" found on command line.
- UINT32 NoInterrupt:1; ///< Was "-nointerrupt" found on command line.
- UINT32 NoMap:1; ///< Was "-nomap" found on command line.
- UINT32 NoVersion:1; ///< Was "-noversion" found on command line.
- UINT32 Delay:1; ///< Was "-delay[:n] found on command line
- UINT32 Exit:1; ///< Was "-_exit" found on command line
- UINT32 NoNest:1; ///< Was "-nonest" found on command line
- UINT32 Reserved:7; ///< Extra bits
+ UINT32 Startup : 1; ///< Was "-startup" found on command line.
+ UINT32 NoStartup : 1; ///< Was "-nostartup" found on command line.
+ UINT32 NoConsoleOut : 1; ///< Was "-noconsoleout" found on command line.
+ UINT32 NoConsoleIn : 1; ///< Was "-noconsolein" found on command line.
+ UINT32 NoInterrupt : 1; ///< Was "-nointerrupt" found on command line.
+ UINT32 NoMap : 1; ///< Was "-nomap" found on command line.
+ UINT32 NoVersion : 1; ///< Was "-noversion" found on command line.
+ UINT32 Delay : 1; ///< Was "-delay[:n] found on command line
+ UINT32 Exit : 1; ///< Was "-_exit" found on command line
+ UINT32 NoNest : 1; ///< Was "-nonest" found on command line
+ UINT32 Reserved : 7; ///< Extra bits
} SHELL_BITS;
typedef union {
- SHELL_BITS Bits;
- UINT16 AllBits;
+ SHELL_BITS Bits;
+ UINT16 AllBits;
} SHELL_BIT_UNION;
typedef struct {
- SHELL_BIT_UNION BitUnion;
- UINTN Delay; ///< Seconds of delay default:5.
- CHAR16 *FileName; ///< Filename to run upon successful initialization.
- CHAR16 *FileOptions; ///< Options to pass to FileName.
+ SHELL_BIT_UNION BitUnion;
+ UINTN Delay; ///< Seconds of delay default:5.
+ CHAR16 *FileName; ///< Filename to run upon successful initialization.
+ CHAR16 *FileOptions; ///< Options to pass to FileName.
} SHELL_INIT_SETTINGS;
typedef struct {
- BUFFER_LIST CommandHistory;
- UINTN VisibleRowNumber;
- UINTN OriginalVisibleRowNumber;
- BOOLEAN InsertMode; ///< Is the current typing mode insert (FALSE = overwrite).
+ BUFFER_LIST CommandHistory;
+ UINTN VisibleRowNumber;
+ UINTN OriginalVisibleRowNumber;
+ BOOLEAN InsertMode; ///< Is the current typing mode insert (FALSE = overwrite).
} SHELL_VIEWING_SETTINGS;
typedef struct {
- EFI_SHELL_PARAMETERS_PROTOCOL *NewShellParametersProtocol;
- EFI_SHELL_PROTOCOL *NewEfiShellProtocol;
- BOOLEAN PageBreakEnabled;
- BOOLEAN RootShellInstance;
- SHELL_INIT_SETTINGS ShellInitSettings;
- BUFFER_LIST BufferToFreeList; ///< List of buffers that were returned to the user to free.
- SHELL_VIEWING_SETTINGS ViewingSettings;
- EFI_HII_HANDLE HiiHandle; ///< Handle from HiiLib.
- UINTN LogScreenCount; ///< How many screens of log information to save.
- EFI_EVENT UserBreakTimer; ///< Timer event for polling for CTRL-C.
- EFI_DEVICE_PATH_PROTOCOL *ImageDevPath; ///< DevicePath for ourselves.
- EFI_DEVICE_PATH_PROTOCOL *FileDevPath; ///< DevicePath for ourselves.
- CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo; ///< Pointer for ConsoleInformation.
- EFI_SHELL_PARAMETERS_PROTOCOL *OldShellParameters; ///< old shell parameters to reinstall upon exiting.
- SHELL_PROTOCOL_HANDLE_LIST OldShellList; ///< List of other instances to reinstall when closing.
- SPLIT_LIST SplitList; ///< List of Splits in FILO stack.
- VOID *CtrlCNotifyHandle1; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
- VOID *CtrlCNotifyHandle2; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
- VOID *CtrlCNotifyHandle3; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
- VOID *CtrlCNotifyHandle4; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
- VOID *CtrlSNotifyHandle1; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
- VOID *CtrlSNotifyHandle2; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
- VOID *CtrlSNotifyHandle3; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
- VOID *CtrlSNotifyHandle4; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
- BOOLEAN HaltOutput; ///< TRUE to start a CTRL-S halt.
+ EFI_SHELL_PARAMETERS_PROTOCOL *NewShellParametersProtocol;
+ EFI_SHELL_PROTOCOL *NewEfiShellProtocol;
+ BOOLEAN PageBreakEnabled;
+ BOOLEAN RootShellInstance;
+ SHELL_INIT_SETTINGS ShellInitSettings;
+ BUFFER_LIST BufferToFreeList; ///< List of buffers that were returned to the user to free.
+ SHELL_VIEWING_SETTINGS ViewingSettings;
+ EFI_HII_HANDLE HiiHandle; ///< Handle from HiiLib.
+ UINTN LogScreenCount; ///< How many screens of log information to save.
+ EFI_EVENT UserBreakTimer; ///< Timer event for polling for CTRL-C.
+ EFI_DEVICE_PATH_PROTOCOL *ImageDevPath; ///< DevicePath for ourselves.
+ EFI_DEVICE_PATH_PROTOCOL *FileDevPath; ///< DevicePath for ourselves.
+ CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo; ///< Pointer for ConsoleInformation.
+ EFI_SHELL_PARAMETERS_PROTOCOL *OldShellParameters; ///< old shell parameters to reinstall upon exiting.
+ SHELL_PROTOCOL_HANDLE_LIST OldShellList; ///< List of other instances to reinstall when closing.
+ SPLIT_LIST SplitList; ///< List of Splits in FILO stack.
+ VOID *CtrlCNotifyHandle1; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
+ VOID *CtrlCNotifyHandle2; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
+ VOID *CtrlCNotifyHandle3; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
+ VOID *CtrlCNotifyHandle4; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
+ VOID *CtrlSNotifyHandle1; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
+ VOID *CtrlSNotifyHandle2; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
+ VOID *CtrlSNotifyHandle3; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
+ VOID *CtrlSNotifyHandle4; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
+ BOOLEAN HaltOutput; ///< TRUE to start a CTRL-S halt.
} SHELL_INFO;
#pragma pack(1)
@@ -127,12 +127,12 @@ typedef struct { /// HII specific Vendor Device Path definition.
///
typedef struct {
- VENDOR_DEVICE_PATH VendorDevicePath;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH VendorDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL End;
} SHELL_MAN_HII_VENDOR_DEVICE_PATH;
#pragma pack()
-extern SHELL_INFO ShellInfoObject;
+extern SHELL_INFO ShellInfoObject;
/**
Converts the command line to its post-processed form. this replaces variables and alias' per UEFI Shell spec.
@@ -144,8 +144,8 @@ extern SHELL_INFO ShellInfoObject; @return some other error occurred
**/
EFI_STATUS
-ProcessCommandLineToFinal(
- IN OUT CHAR16 **CmdLine
+ProcessCommandLineToFinal (
+ IN OUT CHAR16 **CmdLine
);
/**
@@ -154,8 +154,8 @@ ProcessCommandLineToFinal( @param[in] ErrorCode the error code to put into lasterror
**/
EFI_STATUS
-SetLastError(
- IN CONST SHELL_STATUS ErrorCode
+SetLastError (
+ IN CONST SHELL_STATUS ErrorCode
);
/**
@@ -164,7 +164,7 @@ SetLastError( @retval EFI_SUCCESS all init commands were run successfully.
**/
EFI_STATUS
-SetBuiltInAlias(
+SetBuiltInAlias (
VOID
);
@@ -184,8 +184,8 @@ SetBuiltInAlias( **/
EFI_STATUS
GetDevicePathsForImageAndFile (
- IN OUT EFI_DEVICE_PATH_PROTOCOL **DevPath,
- IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevPath,
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath
);
/**
@@ -216,7 +216,7 @@ GetDevicePathsForImageAndFile ( @retval EFI_SUCCESS the variable is initialized.
**/
EFI_STATUS
-ProcessCommandLine(
+ProcessCommandLine (
VOID
);
@@ -231,9 +231,9 @@ ProcessCommandLine( @retval EFI_SUCCESS The variable is initialized.
**/
EFI_STATUS
-DoStartupScript(
- IN EFI_DEVICE_PATH_PROTOCOL *ImagePath,
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath
+DoStartupScript (
+ IN EFI_DEVICE_PATH_PROTOCOL *ImagePath,
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath
);
/**
@@ -255,9 +255,9 @@ DoShellPrompt ( @param Buffer Something to pass to FreePool when the shell is exiting.
**/
-VOID*
-AddBufferToFreeList(
- VOID *Buffer
+VOID *
+AddBufferToFreeList (
+ VOID *Buffer
);
/**
@@ -266,8 +266,8 @@ AddBufferToFreeList( @param Buffer[in] The line buffer to add.
**/
VOID
-AddLineToCommandHistory(
- IN CONST CHAR16 *Buffer
+AddLineToCommandHistory (
+ IN CONST CHAR16 *Buffer
);
/**
@@ -281,8 +281,8 @@ AddLineToCommandHistory( @retval EFI_ABORTED the command's operation was aborted
**/
EFI_STATUS
-RunCommand(
- IN CONST CHAR16 *CmdLine
+RunCommand (
+ IN CONST CHAR16 *CmdLine
);
/**
@@ -298,12 +298,11 @@ RunCommand( @retval EFI_ABORTED The command's operation was aborted.
**/
EFI_STATUS
-RunShellCommand(
- IN CONST CHAR16 *CmdLine,
- OUT EFI_STATUS *CommandStatus
+RunShellCommand (
+ IN CONST CHAR16 *CmdLine,
+ OUT EFI_STATUS *CommandStatus
);
-
/**
Function to process a NSH script file via SHELL_FILE_HANDLE.
@@ -346,11 +345,11 @@ RunScriptFile ( @return the location of the first character in the string
@retval CHAR_NULL no instance of any character in CharacterList was found in String
**/
-CONST CHAR16*
-FindFirstCharacter(
- IN CONST CHAR16 *String,
- IN CONST CHAR16 *CharacterList,
- IN CONST CHAR16 EscapeCharacter
+CONST CHAR16 *
+FindFirstCharacter (
+ IN CONST CHAR16 *String,
+ IN CONST CHAR16 *CharacterList,
+ IN CONST CHAR16 EscapeCharacter
);
/**
@@ -359,8 +358,8 @@ FindFirstCharacter( @param[in] String pointer to the string to trim them off.
**/
EFI_STATUS
-TrimSpaces(
- IN CHAR16 **String
+TrimSpaces (
+ IN CHAR16 **String
);
/**
@@ -371,7 +370,7 @@ TrimSpaces( **/
VOID
SaveBufferList (
- OUT LIST_ENTRY *OldBufferList
+ OUT LIST_ENTRY *OldBufferList
);
/**
@@ -381,10 +380,7 @@ SaveBufferList ( **/
VOID
RestoreBufferList (
- IN OUT LIST_ENTRY *OldBufferList
+ IN OUT LIST_ENTRY *OldBufferList
);
-
-
#endif //_SHELL_INTERNAL_HEADER_
-
diff --git a/ShellPkg/Application/Shell/ShellEnvVar.c b/ShellPkg/Application/Shell/ShellEnvVar.c index 04fed3b..b97cfe9 100644 --- a/ShellPkg/Application/Shell/ShellEnvVar.c +++ b/ShellPkg/Application/Shell/ShellEnvVar.c @@ -14,7 +14,7 @@ //
// The list is used to cache the environment variables.
//
-ENV_VAR_LIST gShellEnvVarList;
+ENV_VAR_LIST gShellEnvVarList;
/**
Reports whether an environment variable is Volatile or Non-Volatile.
@@ -27,8 +27,8 @@ ENV_VAR_LIST gShellEnvVarList; **/
EFI_STATUS
IsVolatileEnv (
- IN CONST CHAR16 *EnvVarName,
- OUT BOOLEAN *Volatile
+ IN CONST CHAR16 *EnvVarName,
+ OUT BOOLEAN *Volatile
)
{
EFI_STATUS Status;
@@ -38,29 +38,35 @@ IsVolatileEnv ( ASSERT (Volatile != NULL);
- Size = 0;
+ Size = 0;
Buffer = NULL;
//
// get the variable
//
- Status = gRT->GetVariable((CHAR16*)EnvVarName,
- &gShellVariableGuid,
- &Attribs,
- &Size,
- Buffer);
+ Status = gRT->GetVariable (
+ (CHAR16 *)EnvVarName,
+ &gShellVariableGuid,
+ &Attribs,
+ &Size,
+ Buffer
+ );
if (Status == EFI_BUFFER_TOO_SMALL) {
- Buffer = AllocateZeroPool(Size);
+ Buffer = AllocateZeroPool (Size);
if (Buffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- Status = gRT->GetVariable((CHAR16*)EnvVarName,
- &gShellVariableGuid,
- &Attribs,
- &Size,
- Buffer);
- FreePool(Buffer);
+
+ Status = gRT->GetVariable (
+ (CHAR16 *)EnvVarName,
+ &gShellVariableGuid,
+ &Attribs,
+ &Size,
+ Buffer
+ );
+ FreePool (Buffer);
}
+
//
// not found means volatile
//
@@ -68,6 +74,7 @@ IsVolatileEnv ( *Volatile = TRUE;
return EFI_SUCCESS;
}
+
if (EFI_ERROR (Status)) {
return Status;
}
@@ -75,7 +82,7 @@ IsVolatileEnv ( //
// check for the Non Volatile bit
//
- *Volatile = !(BOOLEAN) ((Attribs & EFI_VARIABLE_NON_VOLATILE) == EFI_VARIABLE_NON_VOLATILE);
+ *Volatile = !(BOOLEAN)((Attribs & EFI_VARIABLE_NON_VOLATILE) == EFI_VARIABLE_NON_VOLATILE);
return EFI_SUCCESS;
}
@@ -85,30 +92,33 @@ IsVolatileEnv ( @param[in] List The pointer to pointer to list.
**/
VOID
-FreeEnvironmentVariableList(
- IN LIST_ENTRY *List
+FreeEnvironmentVariableList (
+ IN LIST_ENTRY *List
)
{
- ENV_VAR_LIST *Node;
+ ENV_VAR_LIST *Node;
ASSERT (List != NULL);
if (List == NULL) {
return;
}
- for ( Node = (ENV_VAR_LIST*)GetFirstNode(List)
- ; !IsListEmpty(List)
- ; Node = (ENV_VAR_LIST*)GetFirstNode(List)
- ){
- ASSERT(Node != NULL);
- RemoveEntryList(&Node->Link);
+ for ( Node = (ENV_VAR_LIST *)GetFirstNode (List)
+ ; !IsListEmpty (List)
+ ; Node = (ENV_VAR_LIST *)GetFirstNode (List)
+ )
+ {
+ ASSERT (Node != NULL);
+ RemoveEntryList (&Node->Link);
if (Node->Key != NULL) {
- FreePool(Node->Key);
+ FreePool (Node->Key);
}
+
if (Node->Val != NULL) {
- FreePool(Node->Val);
+ FreePool (Node->Val);
}
- FreePool(Node);
+
+ FreePool (Node);
}
}
@@ -121,18 +131,18 @@ FreeEnvironmentVariableList( @retval EFI_SUCCESS the list was created successfully.
**/
EFI_STATUS
-GetEnvironmentVariableList(
- IN OUT LIST_ENTRY *ListHead
+GetEnvironmentVariableList (
+ IN OUT LIST_ENTRY *ListHead
)
{
- CHAR16 *VariableName;
- UINTN NameSize;
- UINTN NameBufferSize;
- EFI_STATUS Status;
- EFI_GUID Guid;
- UINTN ValSize;
- UINTN ValBufferSize;
- ENV_VAR_LIST *VarList;
+ CHAR16 *VariableName;
+ UINTN NameSize;
+ UINTN NameBufferSize;
+ EFI_STATUS Status;
+ EFI_GUID Guid;
+ UINTN ValSize;
+ UINTN ValBufferSize;
+ ENV_VAR_LIST *VarList;
if (ListHead == NULL) {
return (EFI_INVALID_PARAMETER);
@@ -140,34 +150,36 @@ GetEnvironmentVariableList( Status = EFI_SUCCESS;
- ValBufferSize = INIT_DATA_BUFFER_SIZE;
+ ValBufferSize = INIT_DATA_BUFFER_SIZE;
NameBufferSize = INIT_NAME_BUFFER_SIZE;
- VariableName = AllocateZeroPool(NameBufferSize);
+ VariableName = AllocateZeroPool (NameBufferSize);
if (VariableName == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
+
*VariableName = CHAR_NULL;
- while (!EFI_ERROR(Status)) {
+ while (!EFI_ERROR (Status)) {
NameSize = NameBufferSize;
- Status = gRT->GetNextVariableName(&NameSize, VariableName, &Guid);
- if (Status == EFI_NOT_FOUND){
+ Status = gRT->GetNextVariableName (&NameSize, VariableName, &Guid);
+ if (Status == EFI_NOT_FOUND) {
Status = EFI_SUCCESS;
break;
} else if (Status == EFI_BUFFER_TOO_SMALL) {
NameBufferSize = NameSize > NameBufferSize * 2 ? NameSize : NameBufferSize * 2;
- SHELL_FREE_NON_NULL(VariableName);
- VariableName = AllocateZeroPool(NameBufferSize);
+ SHELL_FREE_NON_NULL (VariableName);
+ VariableName = AllocateZeroPool (NameBufferSize);
if (VariableName == NULL) {
Status = EFI_OUT_OF_RESOURCES;
break;
}
+
NameSize = NameBufferSize;
- Status = gRT->GetNextVariableName(&NameSize, VariableName, &Guid);
+ Status = gRT->GetNextVariableName (&NameSize, VariableName, &Guid);
}
- if (!EFI_ERROR(Status) && CompareGuid(&Guid, &gShellVariableGuid)){
- VarList = AllocateZeroPool(sizeof(ENV_VAR_LIST));
+ if (!EFI_ERROR (Status) && CompareGuid (&Guid, &gShellVariableGuid)) {
+ VarList = AllocateZeroPool (sizeof (ENV_VAR_LIST));
if (VarList == NULL) {
Status = EFI_OUT_OF_RESOURCES;
} else {
@@ -177,12 +189,13 @@ GetEnvironmentVariableList( //
VarList->Val = AllocateZeroPool (ValSize + sizeof (CHAR16));
if (VarList->Val == NULL) {
- SHELL_FREE_NON_NULL(VarList);
- Status = EFI_OUT_OF_RESOURCES;
- break;
+ SHELL_FREE_NON_NULL (VarList);
+ Status = EFI_OUT_OF_RESOURCES;
+ break;
}
- Status = SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(VariableName, &VarList->Atts, &ValSize, VarList->Val);
- if (Status == EFI_BUFFER_TOO_SMALL){
+
+ Status = SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES (VariableName, &VarList->Atts, &ValSize, VarList->Val);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
ValBufferSize = ValSize > ValBufferSize * 2 ? ValSize : ValBufferSize * 2;
SHELL_FREE_NON_NULL (VarList->Val);
//
@@ -190,34 +203,36 @@ GetEnvironmentVariableList( //
VarList->Val = AllocateZeroPool (ValBufferSize + sizeof (CHAR16));
if (VarList->Val == NULL) {
- SHELL_FREE_NON_NULL(VarList);
+ SHELL_FREE_NON_NULL (VarList);
Status = EFI_OUT_OF_RESOURCES;
break;
}
ValSize = ValBufferSize;
- Status = SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(VariableName, &VarList->Atts, &ValSize, VarList->Val);
+ Status = SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES (VariableName, &VarList->Atts, &ValSize, VarList->Val);
}
- if (!EFI_ERROR(Status)) {
- VarList->Key = AllocateCopyPool(StrSize(VariableName), VariableName);
+
+ if (!EFI_ERROR (Status)) {
+ VarList->Key = AllocateCopyPool (StrSize (VariableName), VariableName);
if (VarList->Key == NULL) {
- SHELL_FREE_NON_NULL(VarList->Val);
- SHELL_FREE_NON_NULL(VarList);
+ SHELL_FREE_NON_NULL (VarList->Val);
+ SHELL_FREE_NON_NULL (VarList);
Status = EFI_OUT_OF_RESOURCES;
} else {
- InsertTailList(ListHead, &VarList->Link);
+ InsertTailList (ListHead, &VarList->Link);
}
} else {
- SHELL_FREE_NON_NULL(VarList->Val);
- SHELL_FREE_NON_NULL(VarList);
+ SHELL_FREE_NON_NULL (VarList->Val);
+ SHELL_FREE_NON_NULL (VarList);
}
} // if (VarList == NULL) ... else ...
} // compare guid
} // while
+
SHELL_FREE_NON_NULL (VariableName);
- if (EFI_ERROR(Status)) {
- FreeEnvironmentVariableList(ListHead);
+ if (EFI_ERROR (Status)) {
+ FreeEnvironmentVariableList (ListHead);
}
return (Status);
@@ -236,51 +251,56 @@ GetEnvironmentVariableList( @retval EFI_SUCCESS the list was Set successfully.
**/
EFI_STATUS
-SetEnvironmentVariableList(
- IN LIST_ENTRY *ListHead
+SetEnvironmentVariableList (
+ IN LIST_ENTRY *ListHead
)
{
- ENV_VAR_LIST VarList;
- ENV_VAR_LIST *Node;
- EFI_STATUS Status;
- UINTN Size;
+ ENV_VAR_LIST VarList;
+ ENV_VAR_LIST *Node;
+ EFI_STATUS Status;
+ UINTN Size;
- InitializeListHead(&VarList.Link);
+ InitializeListHead (&VarList.Link);
//
// Delete all the current environment variables
//
- Status = GetEnvironmentVariableList(&VarList.Link);
- ASSERT_EFI_ERROR(Status);
-
- for ( Node = (ENV_VAR_LIST*)GetFirstNode(&VarList.Link)
- ; !IsNull(&VarList.Link, &Node->Link)
- ; Node = (ENV_VAR_LIST*)GetNextNode(&VarList.Link, &Node->Link)
- ){
+ Status = GetEnvironmentVariableList (&VarList.Link);
+ ASSERT_EFI_ERROR (Status);
+
+ for ( Node = (ENV_VAR_LIST *)GetFirstNode (&VarList.Link)
+ ; !IsNull (&VarList.Link, &Node->Link)
+ ; Node = (ENV_VAR_LIST *)GetNextNode (&VarList.Link, &Node->Link)
+ )
+ {
if (Node->Key != NULL) {
- Status = SHELL_DELETE_ENVIRONMENT_VARIABLE(Node->Key);
+ Status = SHELL_DELETE_ENVIRONMENT_VARIABLE (Node->Key);
}
- ASSERT_EFI_ERROR(Status);
+
+ ASSERT_EFI_ERROR (Status);
}
- FreeEnvironmentVariableList(&VarList.Link);
+ FreeEnvironmentVariableList (&VarList.Link);
//
// set all the variables from the list
//
- for ( Node = (ENV_VAR_LIST*)GetFirstNode(ListHead)
- ; !IsNull(ListHead, &Node->Link)
- ; Node = (ENV_VAR_LIST*)GetNextNode(ListHead, &Node->Link)
- ){
+ for ( Node = (ENV_VAR_LIST *)GetFirstNode (ListHead)
+ ; !IsNull (ListHead, &Node->Link)
+ ; Node = (ENV_VAR_LIST *)GetNextNode (ListHead, &Node->Link)
+ )
+ {
Size = StrSize (Node->Val) - sizeof (CHAR16);
if (Node->Atts & EFI_VARIABLE_NON_VOLATILE) {
- Status = SHELL_SET_ENVIRONMENT_VARIABLE_NV(Node->Key, Size, Node->Val);
+ Status = SHELL_SET_ENVIRONMENT_VARIABLE_NV (Node->Key, Size, Node->Val);
} else {
Status = SHELL_SET_ENVIRONMENT_VARIABLE_V (Node->Key, Size, Node->Val);
}
- ASSERT_EFI_ERROR(Status);
+
+ ASSERT_EFI_ERROR (Status);
}
- FreeEnvironmentVariableList(ListHead);
+
+ FreeEnvironmentVariableList (ListHead);
return (Status);
}
@@ -299,8 +319,8 @@ SetEnvironmentVariableList( @sa SetEnvironmentVariableList
**/
EFI_STATUS
-SetEnvironmentVariables(
- IN CONST CHAR16 **Environment
+SetEnvironmentVariables (
+ IN CONST CHAR16 **Environment
)
{
CONST CHAR16 *CurrentString;
@@ -318,61 +338,65 @@ SetEnvironmentVariables( // Build a list identical to the ones used for get/set list functions above
//
for ( CurrentCount = 0
- ;
- ; CurrentCount++
- ){
+ ;
+ ; CurrentCount++
+ )
+ {
CurrentString = Environment[CurrentCount];
if (CurrentString == NULL) {
break;
}
- ASSERT(StrStr(CurrentString, L"=") != NULL);
- Node = AllocateZeroPool(sizeof(ENV_VAR_LIST));
+
+ ASSERT (StrStr (CurrentString, L"=") != NULL);
+ Node = AllocateZeroPool (sizeof (ENV_VAR_LIST));
if (Node == NULL) {
- SetEnvironmentVariableList(&VarList->Link);
+ SetEnvironmentVariableList (&VarList->Link);
return (EFI_OUT_OF_RESOURCES);
}
- Node->Key = AllocateZeroPool((StrStr(CurrentString, L"=") - CurrentString + 1) * sizeof(CHAR16));
+ Node->Key = AllocateZeroPool ((StrStr (CurrentString, L"=") - CurrentString + 1) * sizeof (CHAR16));
if (Node->Key == NULL) {
- SHELL_FREE_NON_NULL(Node);
- SetEnvironmentVariableList(&VarList->Link);
+ SHELL_FREE_NON_NULL (Node);
+ SetEnvironmentVariableList (&VarList->Link);
return (EFI_OUT_OF_RESOURCES);
}
//
// Copy the string into the Key, leaving the last character allocated as NULL to terminate
//
- StrnCpyS( Node->Key,
- StrStr(CurrentString, L"=") - CurrentString + 1,
- CurrentString,
- StrStr(CurrentString, L"=") - CurrentString
- );
+ StrnCpyS (
+ Node->Key,
+ StrStr (CurrentString, L"=") - CurrentString + 1,
+ CurrentString,
+ StrStr (CurrentString, L"=") - CurrentString
+ );
//
// ValueSize = TotalSize - already removed size - size for '=' + size for terminator (the last 2 items cancel each other)
//
- Node->Val = AllocateCopyPool(StrSize(CurrentString) - StrSize(Node->Key), CurrentString + StrLen(Node->Key) + 1);
+ Node->Val = AllocateCopyPool (StrSize (CurrentString) - StrSize (Node->Key), CurrentString + StrLen (Node->Key) + 1);
if (Node->Val == NULL) {
- SHELL_FREE_NON_NULL(Node->Key);
- SHELL_FREE_NON_NULL(Node);
- SetEnvironmentVariableList(&VarList->Link);
+ SHELL_FREE_NON_NULL (Node->Key);
+ SHELL_FREE_NON_NULL (Node);
+ SetEnvironmentVariableList (&VarList->Link);
return (EFI_OUT_OF_RESOURCES);
}
Node->Atts = EFI_VARIABLE_BOOTSERVICE_ACCESS;
if (VarList == NULL) {
- VarList = AllocateZeroPool(sizeof(ENV_VAR_LIST));
+ VarList = AllocateZeroPool (sizeof (ENV_VAR_LIST));
if (VarList == NULL) {
- SHELL_FREE_NON_NULL(Node->Key);
- SHELL_FREE_NON_NULL(Node->Val);
- SHELL_FREE_NON_NULL(Node);
+ SHELL_FREE_NON_NULL (Node->Key);
+ SHELL_FREE_NON_NULL (Node->Val);
+ SHELL_FREE_NON_NULL (Node);
return (EFI_OUT_OF_RESOURCES);
}
- InitializeListHead(&VarList->Link);
+
+ InitializeListHead (&VarList->Link);
}
- InsertTailList(&VarList->Link, &Node->Link);
+ InsertTailList (&VarList->Link, &Node->Link);
} // for loop
//
@@ -380,7 +404,7 @@ SetEnvironmentVariables( // this function also frees the memory and deletes all pre-existing
// shell-guid based environment variables.
//
- return (SetEnvironmentVariableList(&VarList->Link));
+ return (SetEnvironmentVariableList (&VarList->Link));
}
/**
@@ -400,28 +424,30 @@ SetEnvironmentVariables( **/
EFI_STATUS
ShellFindEnvVarInList (
- IN CONST CHAR16 *Key,
- OUT CHAR16 **Value,
- OUT UINTN *ValueSize,
- OUT UINT32 *Atts OPTIONAL
+ IN CONST CHAR16 *Key,
+ OUT CHAR16 **Value,
+ OUT UINTN *ValueSize,
+ OUT UINT32 *Atts OPTIONAL
)
{
- ENV_VAR_LIST *Node;
+ ENV_VAR_LIST *Node;
- if (Key == NULL || Value == NULL || ValueSize == NULL) {
+ if ((Key == NULL) || (Value == NULL) || (ValueSize == NULL)) {
return SHELL_INVALID_PARAMETER;
}
- for ( Node = (ENV_VAR_LIST*)GetFirstNode(&gShellEnvVarList.Link)
- ; !IsNull(&gShellEnvVarList.Link, &Node->Link)
- ; Node = (ENV_VAR_LIST*)GetNextNode(&gShellEnvVarList.Link, &Node->Link)
- ){
- if (Node->Key != NULL && StrCmp(Key, Node->Key) == 0) {
- *Value = AllocateCopyPool(StrSize(Node->Val), Node->Val);
- *ValueSize = StrSize(Node->Val);
+ for ( Node = (ENV_VAR_LIST *)GetFirstNode (&gShellEnvVarList.Link)
+ ; !IsNull (&gShellEnvVarList.Link, &Node->Link)
+ ; Node = (ENV_VAR_LIST *)GetNextNode (&gShellEnvVarList.Link, &Node->Link)
+ )
+ {
+ if ((Node->Key != NULL) && (StrCmp (Key, Node->Key) == 0)) {
+ *Value = AllocateCopyPool (StrSize (Node->Val), Node->Val);
+ *ValueSize = StrSize (Node->Val);
if (Atts != NULL) {
*Atts = Node->Atts;
}
+
return EFI_SUCCESS;
}
}
@@ -444,17 +470,17 @@ ShellFindEnvVarInList ( **/
EFI_STATUS
ShellAddEnvVarToList (
- IN CONST CHAR16 *Key,
- IN CONST CHAR16 *Value,
- IN UINTN ValueSize,
- IN UINT32 Atts
+ IN CONST CHAR16 *Key,
+ IN CONST CHAR16 *Value,
+ IN UINTN ValueSize,
+ IN UINT32 Atts
)
{
- ENV_VAR_LIST *Node;
- CHAR16 *LocalKey;
- CHAR16 *LocalValue;
+ ENV_VAR_LIST *Node;
+ CHAR16 *LocalKey;
+ CHAR16 *LocalValue;
- if (Key == NULL || Value == NULL || ValueSize == 0) {
+ if ((Key == NULL) || (Value == NULL) || (ValueSize == 0)) {
return EFI_INVALID_PARAMETER;
}
@@ -466,14 +492,15 @@ ShellAddEnvVarToList ( //
// Update the variable value if it exists in gShellEnvVarList.
//
- for ( Node = (ENV_VAR_LIST*)GetFirstNode(&gShellEnvVarList.Link)
- ; !IsNull(&gShellEnvVarList.Link, &Node->Link)
- ; Node = (ENV_VAR_LIST*)GetNextNode(&gShellEnvVarList.Link, &Node->Link)
- ){
- if (Node->Key != NULL && StrCmp(Key, Node->Key) == 0) {
+ for ( Node = (ENV_VAR_LIST *)GetFirstNode (&gShellEnvVarList.Link)
+ ; !IsNull (&gShellEnvVarList.Link, &Node->Link)
+ ; Node = (ENV_VAR_LIST *)GetNextNode (&gShellEnvVarList.Link, &Node->Link)
+ )
+ {
+ if ((Node->Key != NULL) && (StrCmp (Key, Node->Key) == 0)) {
Node->Atts = Atts;
- SHELL_FREE_NON_NULL(Node->Val);
- Node->Val = LocalValue;
+ SHELL_FREE_NON_NULL (Node->Val);
+ Node->Val = LocalValue;
return EFI_SUCCESS;
}
}
@@ -482,21 +509,23 @@ ShellAddEnvVarToList ( // If the environment variable key doesn't exist in list just insert
// a new node.
//
- LocalKey = AllocateCopyPool (StrSize(Key), Key);
+ LocalKey = AllocateCopyPool (StrSize (Key), Key);
if (LocalKey == NULL) {
FreePool (LocalValue);
return EFI_OUT_OF_RESOURCES;
}
- Node = (ENV_VAR_LIST*)AllocateZeroPool (sizeof(ENV_VAR_LIST));
+
+ Node = (ENV_VAR_LIST *)AllocateZeroPool (sizeof (ENV_VAR_LIST));
if (Node == NULL) {
FreePool (LocalKey);
FreePool (LocalValue);
return EFI_OUT_OF_RESOURCES;
}
- Node->Key = LocalKey;
- Node->Val = LocalValue;
+
+ Node->Key = LocalKey;
+ Node->Val = LocalValue;
Node->Atts = Atts;
- InsertTailList(&gShellEnvVarList.Link, &Node->Link);
+ InsertTailList (&gShellEnvVarList.Link, &Node->Link);
return EFI_SUCCESS;
}
@@ -512,24 +541,25 @@ ShellAddEnvVarToList ( **/
EFI_STATUS
ShellRemvoeEnvVarFromList (
- IN CONST CHAR16 *Key
+ IN CONST CHAR16 *Key
)
{
- ENV_VAR_LIST *Node;
+ ENV_VAR_LIST *Node;
if (Key == NULL) {
return EFI_INVALID_PARAMETER;
}
- for ( Node = (ENV_VAR_LIST*)GetFirstNode(&gShellEnvVarList.Link)
- ; !IsNull(&gShellEnvVarList.Link, &Node->Link)
- ; Node = (ENV_VAR_LIST*)GetNextNode(&gShellEnvVarList.Link, &Node->Link)
- ){
- if (Node->Key != NULL && StrCmp(Key, Node->Key) == 0) {
- SHELL_FREE_NON_NULL(Node->Key);
- SHELL_FREE_NON_NULL(Node->Val);
- RemoveEntryList(&Node->Link);
- SHELL_FREE_NON_NULL(Node);
+ for ( Node = (ENV_VAR_LIST *)GetFirstNode (&gShellEnvVarList.Link)
+ ; !IsNull (&gShellEnvVarList.Link, &Node->Link)
+ ; Node = (ENV_VAR_LIST *)GetNextNode (&gShellEnvVarList.Link, &Node->Link)
+ )
+ {
+ if ((Node->Key != NULL) && (StrCmp (Key, Node->Key) == 0)) {
+ SHELL_FREE_NON_NULL (Node->Key);
+ SHELL_FREE_NON_NULL (Node->Val);
+ RemoveEntryList (&Node->Link);
+ SHELL_FREE_NON_NULL (Node);
return EFI_SUCCESS;
}
}
@@ -547,9 +577,9 @@ ShellInitEnvVarList ( VOID
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
- InitializeListHead(&gShellEnvVarList.Link);
+ InitializeListHead (&gShellEnvVarList.Link);
Status = GetEnvironmentVariableList (&gShellEnvVarList.Link);
return Status;
@@ -565,8 +595,7 @@ ShellFreeEnvVarList ( )
{
FreeEnvironmentVariableList (&gShellEnvVarList.Link);
- InitializeListHead(&gShellEnvVarList.Link);
+ InitializeListHead (&gShellEnvVarList.Link);
return;
}
-
diff --git a/ShellPkg/Application/Shell/ShellEnvVar.h b/ShellPkg/Application/Shell/ShellEnvVar.h index 6c8552e..2eeecfc 100644 --- a/ShellPkg/Application/Shell/ShellEnvVar.h +++ b/ShellPkg/Application/Shell/ShellEnvVar.h @@ -15,17 +15,16 @@ #define _SHELL_ENVIRONMENT_VARIABLE_HEADER_
typedef struct {
- LIST_ENTRY Link;
- CHAR16 *Key;
- CHAR16 *Val;
- UINT32 Atts;
+ LIST_ENTRY Link;
+ CHAR16 *Key;
+ CHAR16 *Val;
+ UINT32 Atts;
} ENV_VAR_LIST;
//
// The list is used to cache the environment variables.
//
-extern ENV_VAR_LIST gShellEnvVarList;
-
+extern ENV_VAR_LIST gShellEnvVarList;
/**
Reports whether an environment variable is Volatile or Non-Volatile.
@@ -38,8 +37,8 @@ extern ENV_VAR_LIST gShellEnvVarList; **/
EFI_STATUS
IsVolatileEnv (
- IN CONST CHAR16 *EnvVarName,
- OUT BOOLEAN *Volatile
+ IN CONST CHAR16 *EnvVarName,
+ OUT BOOLEAN *Volatile
);
/**
@@ -73,7 +72,7 @@ IsVolatileEnv ( @retval other An error occurred
@sa SetVariable
**/
-#define SHELL_SET_ENVIRONMENT_VARIABLE_NV(EnvVarName,BufferSize,Buffer) \
+#define SHELL_SET_ENVIRONMENT_VARIABLE_NV(EnvVarName, BufferSize, Buffer) \
(gRT->SetVariable((CHAR16*)EnvVarName, \
&gShellVariableGuid, \
EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS, \
@@ -93,7 +92,7 @@ IsVolatileEnv ( @retval other An error occurred
@sa SetVariable
**/
-#define SHELL_GET_ENVIRONMENT_VARIABLE(EnvVarName,BufferSize,Buffer) \
+#define SHELL_GET_ENVIRONMENT_VARIABLE(EnvVarName, BufferSize, Buffer) \
(gRT->GetVariable((CHAR16*)EnvVarName, \
&gShellVariableGuid, \
0, \
@@ -114,7 +113,7 @@ IsVolatileEnv ( @retval other An error occurred
@sa SetVariable
**/
-#define SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(EnvVarName,Atts,BufferSize,Buffer) \
+#define SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(EnvVarName, Atts, BufferSize, Buffer) \
(gRT->GetVariable((CHAR16*)EnvVarName, \
&gShellVariableGuid, \
Atts, \
@@ -134,7 +133,7 @@ IsVolatileEnv ( @retval other An error occurred
@sa SetVariable
**/
-#define SHELL_SET_ENVIRONMENT_VARIABLE_V(EnvVarName,BufferSize,Buffer) \
+#define SHELL_SET_ENVIRONMENT_VARIABLE_V(EnvVarName, BufferSize, Buffer) \
(gRT->SetVariable((CHAR16*)EnvVarName, \
&gShellVariableGuid, \
EFI_VARIABLE_BOOTSERVICE_ACCESS, \
@@ -150,8 +149,8 @@ IsVolatileEnv ( @retval EFI_SUCCESS the list was created successfully.
**/
EFI_STATUS
-GetEnvironmentVariableList(
- IN OUT LIST_ENTRY *List
+GetEnvironmentVariableList (
+ IN OUT LIST_ENTRY *List
);
/**
@@ -167,8 +166,8 @@ GetEnvironmentVariableList( @retval EFI_SUCCESS The list was Set successfully.
**/
EFI_STATUS
-SetEnvironmentVariableList(
- IN LIST_ENTRY *List
+SetEnvironmentVariableList (
+ IN LIST_ENTRY *List
);
/**
@@ -187,8 +186,8 @@ SetEnvironmentVariableList( @sa SetEnvironmentVariableList
**/
EFI_STATUS
-SetEnvironmentVariables(
- IN CONST CHAR16 **Environment
+SetEnvironmentVariables (
+ IN CONST CHAR16 **Environment
);
/**
@@ -197,8 +196,8 @@ SetEnvironmentVariables( @param[in] List The pointer to pointer to list.
**/
VOID
-FreeEnvironmentVariableList(
- IN LIST_ENTRY *List
+FreeEnvironmentVariableList (
+ IN LIST_ENTRY *List
);
/**
@@ -218,10 +217,10 @@ FreeEnvironmentVariableList( **/
EFI_STATUS
ShellFindEnvVarInList (
- IN CONST CHAR16 *Key,
- OUT CHAR16 **Value,
- OUT UINTN *ValueSize,
- OUT UINT32 *Atts OPTIONAL
+ IN CONST CHAR16 *Key,
+ OUT CHAR16 **Value,
+ OUT UINTN *ValueSize,
+ OUT UINT32 *Atts OPTIONAL
);
/**
@@ -239,10 +238,10 @@ ShellFindEnvVarInList ( **/
EFI_STATUS
ShellAddEnvVarToList (
- IN CONST CHAR16 *Key,
- IN CONST CHAR16 *Value,
- IN UINTN ValueSize,
- IN UINT32 Atts
+ IN CONST CHAR16 *Key,
+ IN CONST CHAR16 *Value,
+ IN UINTN ValueSize,
+ IN UINT32 Atts
);
/**
@@ -256,7 +255,7 @@ ShellAddEnvVarToList ( **/
EFI_STATUS
ShellRemvoeEnvVarFromList (
- IN CONST CHAR16 *Key
+ IN CONST CHAR16 *Key
);
/**
@@ -279,4 +278,3 @@ ShellFreeEnvVarList ( );
#endif //_SHELL_ENVIRONMENT_VARIABLE_HEADER_
-
diff --git a/ShellPkg/Application/Shell/ShellManParser.c b/ShellPkg/Application/Shell/ShellManParser.c index d5a85cb..5c823cd 100644 --- a/ShellPkg/Application/Shell/ShellManParser.c +++ b/ShellPkg/Application/Shell/ShellManParser.c @@ -17,15 +17,14 @@ EFI_HII_HANDLE mShellManHiiHandle = NULL;
EFI_HANDLE mShellManDriverHandle = NULL;
-
SHELL_MAN_HII_VENDOR_DEVICE_PATH mShellManHiiDevicePath = {
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
SHELL_MAN_HII_GUID
@@ -34,8 +33,8 @@ SHELL_MAN_HII_VENDOR_DEVICE_PATH mShellManHiiDevicePath = { END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
- (UINT8) (END_DEVICE_PATH_LENGTH),
- (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
+ (UINT8)(END_DEVICE_PATH_LENGTH),
+ (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
}
}
};
@@ -52,11 +51,12 @@ SHELL_MAN_HII_VENDOR_DEVICE_PATH mShellManHiiDevicePath = { **/
CHAR16 *
GetExecuatableFileName (
- IN CONST CHAR16 *NameString
+ IN CONST CHAR16 *NameString
)
{
CHAR16 *Buffer;
CHAR16 *SuffixStr;
+
if (NameString == NULL) {
return (NULL);
}
@@ -64,31 +64,33 @@ GetExecuatableFileName ( //
// Fix the file name
//
- if (StrnCmp(NameString+StrLen(NameString)-StrLen(L".efi"), L".efi", StrLen(L".efi"))==0) {
- Buffer = AllocateCopyPool(StrSize(NameString), NameString);
- } else if (StrnCmp(NameString+StrLen(NameString)-StrLen(L".man"), L".man", StrLen(L".man"))==0) {
- Buffer = AllocateCopyPool(StrSize(NameString), NameString);
+ if (StrnCmp (NameString+StrLen (NameString)-StrLen (L".efi"), L".efi", StrLen (L".efi")) == 0) {
+ Buffer = AllocateCopyPool (StrSize (NameString), NameString);
+ } else if (StrnCmp (NameString+StrLen (NameString)-StrLen (L".man"), L".man", StrLen (L".man")) == 0) {
+ Buffer = AllocateCopyPool (StrSize (NameString), NameString);
if (Buffer != NULL) {
- SuffixStr = Buffer+StrLen(Buffer)-StrLen(L".man");
- StrnCpyS (SuffixStr, StrSize(L".man")/sizeof(CHAR16), L".efi", StrLen(L".efi"));
+ SuffixStr = Buffer+StrLen (Buffer)-StrLen (L".man");
+ StrnCpyS (SuffixStr, StrSize (L".man")/sizeof (CHAR16), L".efi", StrLen (L".efi"));
}
} else {
- Buffer = AllocateZeroPool(StrSize(NameString) + StrLen(L".efi")*sizeof(CHAR16));
+ Buffer = AllocateZeroPool (StrSize (NameString) + StrLen (L".efi")*sizeof (CHAR16));
if (Buffer != NULL) {
- StrnCpyS( Buffer,
- (StrSize(NameString) + StrLen(L".efi")*sizeof(CHAR16))/sizeof(CHAR16),
- NameString,
- StrLen(NameString)
- );
- StrnCatS( Buffer,
- (StrSize(NameString) + StrLen(L".efi")*sizeof(CHAR16))/sizeof(CHAR16),
- L".efi",
- StrLen(L".efi")
- );
+ StrnCpyS (
+ Buffer,
+ (StrSize (NameString) + StrLen (L".efi")*sizeof (CHAR16))/sizeof (CHAR16),
+ NameString,
+ StrLen (NameString)
+ );
+ StrnCatS (
+ Buffer,
+ (StrSize (NameString) + StrLen (L".efi")*sizeof (CHAR16))/sizeof (CHAR16),
+ L".efi",
+ StrLen (L".efi")
+ );
}
}
- return (Buffer);
+ return (Buffer);
}
/**
@@ -103,34 +105,39 @@ GetExecuatableFileName ( @return the new filename with .man as the extension.
**/
CHAR16 *
-GetManFileName(
- IN CONST CHAR16 *ManFileName
+GetManFileName (
+ IN CONST CHAR16 *ManFileName
)
{
- CHAR16 *Buffer;
+ CHAR16 *Buffer;
+
if (ManFileName == NULL) {
return (NULL);
}
+
//
// Fix the file name
//
- if (StrnCmp(ManFileName+StrLen(ManFileName)-4, L".man", 4)==0) {
- Buffer = AllocateCopyPool(StrSize(ManFileName), ManFileName);
+ if (StrnCmp (ManFileName+StrLen (ManFileName)-4, L".man", 4) == 0) {
+ Buffer = AllocateCopyPool (StrSize (ManFileName), ManFileName);
} else {
- Buffer = AllocateZeroPool(StrSize(ManFileName) + 4*sizeof(CHAR16));
+ Buffer = AllocateZeroPool (StrSize (ManFileName) + 4*sizeof (CHAR16));
if (Buffer != NULL) {
- StrnCpyS( Buffer,
- (StrSize(ManFileName) + 4*sizeof(CHAR16))/sizeof(CHAR16),
- ManFileName,
- StrLen(ManFileName)
- );
- StrnCatS( Buffer,
- (StrSize(ManFileName) + 4*sizeof(CHAR16))/sizeof(CHAR16),
- L".man",
- 4
- );
+ StrnCpyS (
+ Buffer,
+ (StrSize (ManFileName) + 4*sizeof (CHAR16))/sizeof (CHAR16),
+ ManFileName,
+ StrLen (ManFileName)
+ );
+ StrnCatS (
+ Buffer,
+ (StrSize (ManFileName) + 4*sizeof (CHAR16))/sizeof (CHAR16),
+ L".man",
+ 4
+ );
}
}
+
return (Buffer);
}
@@ -149,22 +156,23 @@ GetManFileName( @retval EFI_NOT_FOUND The file was not found.
**/
EFI_STATUS
-SearchPathForFile(
- IN CONST CHAR16 *FileName,
- OUT SHELL_FILE_HANDLE *Handle
+SearchPathForFile (
+ IN CONST CHAR16 *FileName,
+ OUT SHELL_FILE_HANDLE *Handle
)
{
- CHAR16 *FullFileName;
- EFI_STATUS Status;
+ CHAR16 *FullFileName;
+ EFI_STATUS Status;
- if ( FileName == NULL
- || Handle == NULL
- || StrLen(FileName) == 0
- ){
+ if ( (FileName == NULL)
+ || (Handle == NULL)
+ || (StrLen (FileName) == 0)
+ )
+ {
return (EFI_INVALID_PARAMETER);
}
- FullFileName = ShellFindFilePath(FileName);
+ FullFileName = ShellFindFilePath (FileName);
if (FullFileName == NULL) {
return (EFI_NOT_FOUND);
}
@@ -172,8 +180,8 @@ SearchPathForFile( //
// now open that file
//
- Status = EfiShellOpenFileByName(FullFileName, Handle, EFI_FILE_MODE_READ);
- FreePool(FullFileName);
+ Status = EfiShellOpenFileByName (FullFileName, Handle, EFI_FILE_MODE_READ);
+ FreePool (FullFileName);
return (Status);
}
@@ -197,7 +205,7 @@ SearchPathForFile( an allocated buffer.
**/
EFI_STATUS
-ManFileFindSections(
+ManFileFindSections (
IN SHELL_FILE_HANDLE Handle,
IN CONST CHAR16 *Sections,
OUT CHAR16 **HelpText,
@@ -205,75 +213,84 @@ ManFileFindSections( IN BOOLEAN Ascii
)
{
- EFI_STATUS Status;
- CHAR16 *ReadLine;
- UINTN Size;
- BOOLEAN CurrentlyReading;
- CHAR16 *SectionName;
- UINTN SectionLen;
- BOOLEAN Found;
-
- if ( Handle == NULL
- || HelpText == NULL
- || HelpSize == NULL
- ){
+ EFI_STATUS Status;
+ CHAR16 *ReadLine;
+ UINTN Size;
+ BOOLEAN CurrentlyReading;
+ CHAR16 *SectionName;
+ UINTN SectionLen;
+ BOOLEAN Found;
+
+ if ( (Handle == NULL)
+ || (HelpText == NULL)
+ || (HelpSize == NULL)
+ )
+ {
return (EFI_INVALID_PARAMETER);
}
- Status = EFI_SUCCESS;
- CurrentlyReading = FALSE;
- Size = 1024;
- Found = FALSE;
+ Status = EFI_SUCCESS;
+ CurrentlyReading = FALSE;
+ Size = 1024;
+ Found = FALSE;
- ReadLine = AllocateZeroPool(Size);
+ ReadLine = AllocateZeroPool (Size);
if (ReadLine == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
- for (;!ShellFileHandleEof(Handle);Size = 1024) {
- Status = ShellFileHandleReadLine(Handle, ReadLine, &Size, TRUE, &Ascii);
+ for ( ; !ShellFileHandleEof (Handle); Size = 1024) {
+ Status = ShellFileHandleReadLine (Handle, ReadLine, &Size, TRUE, &Ascii);
if (ReadLine[0] == L'#') {
//
// Skip comment lines
//
continue;
}
+
//
// ignore too small of buffer...
//
if (Status == EFI_BUFFER_TOO_SMALL) {
Status = EFI_SUCCESS;
}
- if (EFI_ERROR(Status)) {
+
+ if (EFI_ERROR (Status)) {
break;
- } else if (StrnCmp(ReadLine, L".TH", 3) == 0) {
+ } else if (StrnCmp (ReadLine, L".TH", 3) == 0) {
//
// we hit the end of this commands section so stop.
//
break;
- } else if (StrnCmp(ReadLine, L".SH", 3) == 0) {
+ } else if (StrnCmp (ReadLine, L".SH", 3) == 0) {
if (Sections == NULL) {
CurrentlyReading = TRUE;
continue;
}
+
//
// we found a section
//
if (CurrentlyReading) {
CurrentlyReading = FALSE;
}
+
//
// is this a section we want to read in?
//
for ( SectionName = ReadLine + 3
- ; *SectionName == L' '
- ; SectionName++);
- SectionLen = StrLen(SectionName);
- SectionName = StrStr(Sections, SectionName);
+ ; *SectionName == L' '
+ ; SectionName++)
+ {
+ }
+
+ SectionLen = StrLen (SectionName);
+ SectionName = StrStr (Sections, SectionName);
if (SectionName == NULL) {
continue;
}
- if (*(SectionName + SectionLen) == CHAR_NULL || *(SectionName + SectionLen) == L',') {
+
+ if ((*(SectionName + SectionLen) == CHAR_NULL) || (*(SectionName + SectionLen) == L',')) {
CurrentlyReading = TRUE;
}
} else if (CurrentlyReading) {
@@ -281,15 +298,17 @@ ManFileFindSections( //
// copy and save the current line.
//
- ASSERT((*HelpText == NULL && *HelpSize == 0) || (*HelpText != NULL));
+ ASSERT ((*HelpText == NULL && *HelpSize == 0) || (*HelpText != NULL));
StrnCatGrow (HelpText, HelpSize, ReadLine, 0);
StrnCatGrow (HelpText, HelpSize, L"\r\n", 0);
}
}
- FreePool(ReadLine);
- if (!Found && !EFI_ERROR(Status)) {
+
+ FreePool (ReadLine);
+ if (!Found && !EFI_ERROR (Status)) {
return (EFI_NOT_FOUND);
}
+
return (Status);
}
@@ -315,12 +334,12 @@ ManFileFindSections( @retval FALSE Line did not contain the Title Header
**/
BOOLEAN
-IsTitleHeader(
- IN CONST CHAR16 *Command,
- IN CHAR16 *Line,
- OUT CHAR16 **BriefDesc OPTIONAL,
- OUT UINTN *BriefSize OPTIONAL,
- OUT BOOLEAN *Found
+IsTitleHeader (
+ IN CONST CHAR16 *Command,
+ IN CHAR16 *Line,
+ OUT CHAR16 **BriefDesc OPTIONAL,
+ OUT UINTN *BriefSize OPTIONAL,
+ OUT BOOLEAN *Found
)
{
// The states of a simple state machine used to recognize a title header line
@@ -334,86 +353,84 @@ IsTitleHeader( BOOLEAN ReturnValue; // TRUE if this the Title Header line of *some* MAN file.
BOOLEAN ReturnFound; // TRUE if this the Title Header line of *the desired* MAN file.
- ReturnValue = FALSE;
- ReturnFound = FALSE;
+ ReturnValue = FALSE;
+ ReturnFound = FALSE;
CommandIndex = 0;
- State = LookForThMacro;
+ State = LookForThMacro;
do {
-
if (*Line == L'\0') {
break;
}
switch (State) {
-
// Handle "^\s*.TH\s"
// Go to state LookForCommandName if the title header macro is present; otherwise,
// eat white space. If we see something other than white space, this is not a
// title header line.
case LookForThMacro:
- if (StrnCmp (L".TH ", Line, 4) == 0 || StrnCmp (L".TH\t", Line, 4) == 0) {
+ if ((StrnCmp (L".TH ", Line, 4) == 0) || (StrnCmp (L".TH\t", Line, 4) == 0)) {
Line += 4;
State = LookForCommandName;
- }
- else if (*Line == L' ' || *Line == L'\t') {
+ } else if ((*Line == L' ') || (*Line == L'\t')) {
Line++;
- }
- else {
+ } else {
State = Final;
}
- break;
+
+ break;
// Handle "\s*"
// Eat any "extra" whitespace after the title header macro (we have already seen
// at least one white space character). Go to state CompareCommands when a
// non-white space is seen.
case LookForCommandName:
- if (*Line == L' ' || *Line == L'\t') {
+ if ((*Line == L' ') || (*Line == L'\t')) {
Line++;
- }
- else {
+ } else {
ReturnValue = TRUE; // This is *some* command's title header line.
- State = CompareCommands;
+ State = CompareCommands;
// Do not increment Line; it points to the first character of the command
// name on the title header line.
}
- break;
+
+ break;
// Handle "(\S)\s"
// Compare Command to the title header command name, ignoring case. When we
// reach the end of the command (i.e. we see white space), the next state
// depends on whether the caller wants a copy of the Brief Description.
case CompareCommands:
- if (*Line == L' ' || *Line == L'\t') {
+ if ((*Line == L' ') || (*Line == L'\t')) {
ReturnFound = TRUE; // This is the desired command's title header line.
- State = (BriefDesc == NULL) ? Final : GetBriefDescription;
- }
- else if (CharToUpper (*Line) != CharToUpper (*(Command + CommandIndex++))) {
+ State = (BriefDesc == NULL) ? Final : GetBriefDescription;
+ } else if (CharToUpper (*Line) != CharToUpper (*(Command + CommandIndex++))) {
State = Final;
}
+
Line++;
- break;
+ break;
// Handle "[\s01]*(.*)$"
// Skip whitespace, '0', and '1' characters, if any, prior to the brief description.
// Return the description to the caller.
case GetBriefDescription:
- if (*Line != L' ' && *Line != L'\t' && *Line != L'0' && *Line != L'1') {
- *BriefSize = StrSize(Line);
- *BriefDesc = AllocateZeroPool(*BriefSize);
+ if ((*Line != L' ') && (*Line != L'\t') && (*Line != L'0') && (*Line != L'1')) {
+ *BriefSize = StrSize (Line);
+ *BriefDesc = AllocateZeroPool (*BriefSize);
if (*BriefDesc != NULL) {
- StrCpyS(*BriefDesc, (*BriefSize)/sizeof(CHAR16), Line);
+ StrCpyS (*BriefDesc, (*BriefSize)/sizeof (CHAR16), Line);
}
+
State = Final;
}
+
Line++;
- break;
+ break;
default:
- break;
+ break;
}
-
} while (State < Final);
*Found = ReturnFound;
@@ -441,7 +458,7 @@ IsTitleHeader( an allocated buffer if requested.
**/
EFI_STATUS
-ManFileFindTitleSection(
+ManFileFindTitleSection (
IN SHELL_FILE_HANDLE Handle,
IN CONST CHAR16 *Command,
OUT CHAR16 **BriefDesc OPTIONAL,
@@ -455,18 +472,19 @@ ManFileFindTitleSection( BOOLEAN Found;
UINTN Start;
- if ( Handle == NULL
- || Command == NULL
- || (BriefDesc != NULL && BriefSize == NULL)
- ){
+ if ( (Handle == NULL)
+ || (Command == NULL)
+ || ((BriefDesc != NULL) && (BriefSize == NULL))
+ )
+ {
return (EFI_INVALID_PARAMETER);
}
- Status = EFI_SUCCESS;
- Size = 1024;
- Found = FALSE;
+ Status = EFI_SUCCESS;
+ Size = 1024;
+ Found = FALSE;
- ReadLine = AllocateZeroPool(Size);
+ ReadLine = AllocateZeroPool (Size);
if (ReadLine == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
@@ -474,20 +492,21 @@ ManFileFindTitleSection( //
// Do not pass any leading path information that may be present to IsTitleHeader().
//
- Start = StrLen(Command);
- while ((Start != 0)
- && (*(Command + Start - 1) != L'\\')
- && (*(Command + Start - 1) != L'/')
- && (*(Command + Start - 1) != L':')) {
+ Start = StrLen (Command);
+ while ( (Start != 0)
+ && (*(Command + Start - 1) != L'\\')
+ && (*(Command + Start - 1) != L'/')
+ && (*(Command + Start - 1) != L':'))
+ {
--Start;
}
- for (;!ShellFileHandleEof(Handle);Size = 1024) {
- Status = ShellFileHandleReadLine(Handle, ReadLine, &Size, TRUE, Ascii);
+ for ( ; !ShellFileHandleEof (Handle); Size = 1024) {
+ Status = ShellFileHandleReadLine (Handle, ReadLine, &Size, TRUE, Ascii);
//
// ignore too small of buffer...
//
- if (EFI_ERROR(Status) && Status != EFI_BUFFER_TOO_SMALL) {
+ if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
break;
}
@@ -498,7 +517,7 @@ ManFileFindTitleSection( }
}
- FreePool(ReadLine);
+ FreePool (ReadLine);
return (Status);
}
@@ -533,32 +552,33 @@ ManFileFindTitleSection( @retval EFI_NOT_FOUND There is no help text available for Command.
**/
EFI_STATUS
-ProcessManFile(
- IN CONST CHAR16 *ManFileName,
- IN CONST CHAR16 *Command,
- IN CONST CHAR16 *Sections OPTIONAL,
- OUT CHAR16 **BriefDesc OPTIONAL,
- OUT CHAR16 **HelpText
+ProcessManFile (
+ IN CONST CHAR16 *ManFileName,
+ IN CONST CHAR16 *Command,
+ IN CONST CHAR16 *Sections OPTIONAL,
+ OUT CHAR16 **BriefDesc OPTIONAL,
+ OUT CHAR16 **HelpText
)
{
- CHAR16 *TempString;
- SHELL_FILE_HANDLE FileHandle;
- EFI_HANDLE CmdFileImgHandle;
- EFI_STATUS Status;
- UINTN HelpSize;
- UINTN BriefSize;
- UINTN StringIdWalker;
- BOOLEAN Ascii;
- CHAR16 *CmdFileName;
- CHAR16 *CmdFilePathName;
- EFI_DEVICE_PATH_PROTOCOL *FileDevPath;
- EFI_DEVICE_PATH_PROTOCOL *DevPath;
- EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
-
- if ( ManFileName == NULL
- || Command == NULL
- || HelpText == NULL
- ){
+ CHAR16 *TempString;
+ SHELL_FILE_HANDLE FileHandle;
+ EFI_HANDLE CmdFileImgHandle;
+ EFI_STATUS Status;
+ UINTN HelpSize;
+ UINTN BriefSize;
+ UINTN StringIdWalker;
+ BOOLEAN Ascii;
+ CHAR16 *CmdFileName;
+ CHAR16 *CmdFilePathName;
+ EFI_DEVICE_PATH_PROTOCOL *FileDevPath;
+ EFI_DEVICE_PATH_PROTOCOL *DevPath;
+ EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
+
+ if ( (ManFileName == NULL)
+ || (Command == NULL)
+ || (HelpText == NULL)
+ )
+ {
return (EFI_INVALID_PARAMETER);
}
@@ -577,47 +597,49 @@ ProcessManFile( //
// See if it's in HII first
//
- TempString = ShellCommandGetCommandHelp(Command);
+ TempString = ShellCommandGetCommandHelp (Command);
if (TempString != NULL) {
FileHandle = ConvertEfiFileProtocolToShellHandle (CreateFileInterfaceMem (TRUE), NULL);
- HelpSize = StrLen (TempString) * sizeof (CHAR16);
+ HelpSize = StrLen (TempString) * sizeof (CHAR16);
ShellWriteFile (FileHandle, &HelpSize, TempString);
ShellSetFilePosition (FileHandle, 0);
HelpSize = 0;
BriefSize = 0;
- Status = ManFileFindTitleSection(FileHandle, Command, BriefDesc, &BriefSize, &Ascii);
- if (!EFI_ERROR(Status) && HelpText != NULL){
- Status = ManFileFindSections(FileHandle, Sections, HelpText, &HelpSize, Ascii);
+ Status = ManFileFindTitleSection (FileHandle, Command, BriefDesc, &BriefSize, &Ascii);
+ if (!EFI_ERROR (Status) && (HelpText != NULL)) {
+ Status = ManFileFindSections (FileHandle, Sections, HelpText, &HelpSize, Ascii);
}
+
ShellCloseFile (&FileHandle);
} else {
//
// If the image is a external app, check .MAN file first.
//
- FileHandle = NULL;
- TempString = GetManFileName(ManFileName);
+ FileHandle = NULL;
+ TempString = GetManFileName (ManFileName);
if (TempString == NULL) {
return (EFI_INVALID_PARAMETER);
}
- Status = SearchPathForFile(TempString, &FileHandle);
- if (EFI_ERROR(Status)) {
- FileDevPath = FileDevicePath(NULL, TempString);
- DevPath = AppendDevicePath (ShellInfoObject.ImageDevPath, FileDevPath);
- Status = InternalOpenFileDevicePath(DevPath, &FileHandle, EFI_FILE_MODE_READ, 0);
- SHELL_FREE_NON_NULL(FileDevPath);
- SHELL_FREE_NON_NULL(DevPath);
+ Status = SearchPathForFile (TempString, &FileHandle);
+ if (EFI_ERROR (Status)) {
+ FileDevPath = FileDevicePath (NULL, TempString);
+ DevPath = AppendDevicePath (ShellInfoObject.ImageDevPath, FileDevPath);
+ Status = InternalOpenFileDevicePath (DevPath, &FileHandle, EFI_FILE_MODE_READ, 0);
+ SHELL_FREE_NON_NULL (FileDevPath);
+ SHELL_FREE_NON_NULL (DevPath);
}
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
HelpSize = 0;
BriefSize = 0;
- Status = ManFileFindTitleSection(FileHandle, Command, BriefDesc, &BriefSize, &Ascii);
- if (!EFI_ERROR(Status) && HelpText != NULL){
- Status = ManFileFindSections(FileHandle, Sections, HelpText, &HelpSize, Ascii);
+ Status = ManFileFindTitleSection (FileHandle, Command, BriefDesc, &BriefSize, &Ascii);
+ if (!EFI_ERROR (Status) && (HelpText != NULL)) {
+ Status = ManFileFindSections (FileHandle, Sections, HelpText, &HelpSize, Ascii);
}
- ShellInfoObject.NewEfiShellProtocol->CloseFile(FileHandle);
- if (!EFI_ERROR(Status)) {
+
+ ShellInfoObject.NewEfiShellProtocol->CloseFile (FileHandle);
+ if (!EFI_ERROR (Status)) {
//
// Get help text from .MAN file success.
//
@@ -628,23 +650,25 @@ ProcessManFile( //
// Load the app image to check EFI_HII_PACKAGE_LIST_PROTOCOL.
//
- CmdFileName = GetExecuatableFileName(TempString);
+ CmdFileName = GetExecuatableFileName (TempString);
if (CmdFileName == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
+
//
// If the file in CWD then use the file name, else use the full
// path name.
//
- CmdFilePathName = ShellFindFilePath(CmdFileName);
+ CmdFilePathName = ShellFindFilePath (CmdFileName);
if (CmdFilePathName == NULL) {
Status = EFI_NOT_FOUND;
goto Done;
}
- DevPath = ShellInfoObject.NewEfiShellProtocol->GetDevicePathFromFilePath(CmdFilePathName);
- Status = gBS->LoadImage(FALSE, gImageHandle, DevPath, NULL, 0, &CmdFileImgHandle);
- if(EFI_ERROR(Status)) {
+
+ DevPath = ShellInfoObject.NewEfiShellProtocol->GetDevicePathFromFilePath (CmdFilePathName);
+ Status = gBS->LoadImage (FALSE, gImageHandle, DevPath, NULL, 0, &CmdFileImgHandle);
+ if (EFI_ERROR (Status)) {
//
// With EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created
// with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now.
@@ -654,18 +678,20 @@ ProcessManFile( if (Status == EFI_SECURITY_VIOLATION) {
gBS->UnloadImage (CmdFileImgHandle);
}
+
*HelpText = NULL;
goto Done;
}
- Status = gBS->OpenProtocol(
+
+ Status = gBS->OpenProtocol (
CmdFileImgHandle,
&gEfiHiiPackageListProtocolGuid,
- (VOID**)&PackageListHeader,
+ (VOID **)&PackageListHeader,
gImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
- if(EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
*HelpText = NULL;
goto Done;
}
@@ -679,60 +705,62 @@ ProcessManFile( EFI_NATIVE_INTERFACE,
&mShellManHiiDevicePath
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto Done;
}
Status = gHiiDatabase->NewPackageList (
- gHiiDatabase,
- PackageListHeader,
- mShellManDriverHandle,
- &mShellManHiiHandle
- );
+ gHiiDatabase,
+ PackageListHeader,
+ mShellManDriverHandle,
+ &mShellManHiiHandle
+ );
if (EFI_ERROR (Status)) {
goto Done;
}
StringIdWalker = 1;
do {
- SHELL_FREE_NON_NULL(TempString);
- if (BriefDesc != NULL) {
- SHELL_FREE_NON_NULL(*BriefDesc);
- }
- TempString = HiiGetString (mShellManHiiHandle, (EFI_STRING_ID)StringIdWalker, NULL);
- if (TempString == NULL) {
- Status = EFI_NOT_FOUND;
- goto Done;
- }
- FileHandle = ConvertEfiFileProtocolToShellHandle (CreateFileInterfaceMem (TRUE), NULL);
- HelpSize = StrLen (TempString) * sizeof (CHAR16);
- ShellWriteFile (FileHandle, &HelpSize, TempString);
- ShellSetFilePosition (FileHandle, 0);
- HelpSize = 0;
- BriefSize = 0;
- Status = ManFileFindTitleSection(FileHandle, Command, BriefDesc, &BriefSize, &Ascii);
- if (!EFI_ERROR(Status) && HelpText != NULL){
- Status = ManFileFindSections(FileHandle, Sections, HelpText, &HelpSize, Ascii);
- }
- ShellCloseFile (&FileHandle);
- if (!EFI_ERROR(Status)){
- //
- // Found what we need and return
- //
- goto Done;
- }
+ SHELL_FREE_NON_NULL (TempString);
+ if (BriefDesc != NULL) {
+ SHELL_FREE_NON_NULL (*BriefDesc);
+ }
- StringIdWalker += 1;
- } while (StringIdWalker < 0xFFFF && TempString != NULL);
+ TempString = HiiGetString (mShellManHiiHandle, (EFI_STRING_ID)StringIdWalker, NULL);
+ if (TempString == NULL) {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
+ FileHandle = ConvertEfiFileProtocolToShellHandle (CreateFileInterfaceMem (TRUE), NULL);
+ HelpSize = StrLen (TempString) * sizeof (CHAR16);
+ ShellWriteFile (FileHandle, &HelpSize, TempString);
+ ShellSetFilePosition (FileHandle, 0);
+ HelpSize = 0;
+ BriefSize = 0;
+ Status = ManFileFindTitleSection (FileHandle, Command, BriefDesc, &BriefSize, &Ascii);
+ if (!EFI_ERROR (Status) && (HelpText != NULL)) {
+ Status = ManFileFindSections (FileHandle, Sections, HelpText, &HelpSize, Ascii);
+ }
+
+ ShellCloseFile (&FileHandle);
+ if (!EFI_ERROR (Status)) {
+ //
+ // Found what we need and return
+ //
+ goto Done;
+ }
+
+ StringIdWalker += 1;
+ } while (StringIdWalker < 0xFFFF && TempString != NULL);
}
Done:
if (mShellManDriverHandle != NULL) {
gBS->UninstallProtocolInterface (
- mShellManDriverHandle,
- &gEfiDevicePathProtocolGuid,
- &mShellManHiiDevicePath
+ mShellManDriverHandle,
+ &gEfiDevicePathProtocolGuid,
+ &mShellManHiiDevicePath
);
mShellManDriverHandle = NULL;
}
@@ -746,12 +774,11 @@ Done: Status = gBS->UnloadImage (CmdFileImgHandle);
}
- SHELL_FREE_NON_NULL(TempString);
- SHELL_FREE_NON_NULL(CmdFileName);
- SHELL_FREE_NON_NULL(CmdFilePathName);
- SHELL_FREE_NON_NULL(FileDevPath);
- SHELL_FREE_NON_NULL(DevPath);
+ SHELL_FREE_NON_NULL (TempString);
+ SHELL_FREE_NON_NULL (CmdFileName);
+ SHELL_FREE_NON_NULL (CmdFilePathName);
+ SHELL_FREE_NON_NULL (FileDevPath);
+ SHELL_FREE_NON_NULL (DevPath);
return (Status);
}
-
diff --git a/ShellPkg/Application/Shell/ShellManParser.h b/ShellPkg/Application/Shell/ShellManParser.h index 04031e0..388ae2a 100644 --- a/ShellPkg/Application/Shell/ShellManParser.h +++ b/ShellPkg/Application/Shell/ShellManParser.h @@ -39,12 +39,12 @@ @retval EFI_NOT_FOUND There is no help text available for Command.
**/
EFI_STATUS
-ProcessManFile(
- IN CONST CHAR16 *ManFileName,
- IN CONST CHAR16 *Command,
- IN CONST CHAR16 *Sections OPTIONAL,
- OUT CHAR16 **BriefDesc,
- OUT CHAR16 **HelpText
+ProcessManFile (
+ IN CONST CHAR16 *ManFileName,
+ IN CONST CHAR16 *Command,
+ IN CONST CHAR16 *Sections OPTIONAL,
+ OUT CHAR16 **BriefDesc,
+ OUT CHAR16 **HelpText
);
/**
@@ -66,7 +66,7 @@ ProcessManFile( an allocated buffer.
**/
EFI_STATUS
-ManFileFindSections(
+ManFileFindSections (
IN SHELL_FILE_HANDLE Handle,
IN CONST CHAR16 *Sections,
OUT CHAR16 **HelpText,
@@ -75,4 +75,3 @@ ManFileFindSections( );
#endif //_SHELL_MAN_FILE_PARSER_HEADER_
-
diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.c b/ShellPkg/Application/Shell/ShellParametersProtocol.c index 7e0c8ce..64d67d9 100644 --- a/ShellPkg/Application/Shell/ShellParametersProtocol.c +++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c @@ -12,22 +12,22 @@ #include "Shell.h"
-BOOLEAN AsciiRedirection = FALSE;
+BOOLEAN AsciiRedirection = FALSE;
/**
Return the next parameter's end from a command line string.
@param[in] String the string to parse
**/
-CONST CHAR16*
-FindEndOfParameter(
- IN CONST CHAR16 *String
+CONST CHAR16 *
+FindEndOfParameter (
+ IN CONST CHAR16 *String
)
{
- CONST CHAR16 *First;
- CONST CHAR16 *CloseQuote;
+ CONST CHAR16 *First;
+ CONST CHAR16 *CloseQuote;
- First = FindFirstCharacter(String, L" \"", L'^');
+ First = FindFirstCharacter (String, L" \"", L'^');
//
// nothing, all one parameter remaining
@@ -79,51 +79,51 @@ FindEndOfParameter( @return EFI_NOT_FOUND A closing " could not be found on the specified string
**/
EFI_STATUS
-GetNextParameter(
+GetNextParameter (
IN OUT CHAR16 **Walker,
IN OUT CHAR16 **TempParameter,
IN CONST UINTN Length,
IN BOOLEAN StripQuotation
)
{
- CONST CHAR16 *NextDelim;
-
- if (Walker == NULL
- ||*Walker == NULL
- ||TempParameter == NULL
- ||*TempParameter == NULL
- ){
+ CONST CHAR16 *NextDelim;
+
+ if ( (Walker == NULL)
+ || (*Walker == NULL)
+ || (TempParameter == NULL)
+ || (*TempParameter == NULL)
+ )
+ {
return (EFI_INVALID_PARAMETER);
}
-
//
// make sure we dont have any leading spaces
//
while ((*Walker)[0] == L' ') {
- (*Walker)++;
+ (*Walker)++;
}
//
// make sure we still have some params now...
//
- if (StrLen(*Walker) == 0) {
-DEBUG_CODE_BEGIN();
- *Walker = NULL;
-DEBUG_CODE_END();
+ if (StrLen (*Walker) == 0) {
+ DEBUG_CODE_BEGIN ();
+ *Walker = NULL;
+ DEBUG_CODE_END ();
return (EFI_INVALID_PARAMETER);
}
- NextDelim = FindEndOfParameter(*Walker);
+ NextDelim = FindEndOfParameter (*Walker);
- if (NextDelim == NULL){
-DEBUG_CODE_BEGIN();
- *Walker = NULL;
-DEBUG_CODE_END();
+ if (NextDelim == NULL) {
+ DEBUG_CODE_BEGIN ();
+ *Walker = NULL;
+ DEBUG_CODE_END ();
return (EFI_NOT_FOUND);
}
- StrnCpyS(*TempParameter, Length / sizeof(CHAR16), (*Walker), NextDelim - *Walker);
+ StrnCpyS (*TempParameter, Length / sizeof (CHAR16), (*Walker), NextDelim - *Walker);
//
// Add a CHAR_NULL if we didn't get one via the copy
@@ -135,33 +135,32 @@ DEBUG_CODE_END(); //
// Update Walker for the next iteration through the function
//
- *Walker = (CHAR16*)NextDelim;
+ *Walker = (CHAR16 *)NextDelim;
//
// Remove any non-escaped quotes in the string
// Remove any remaining escape characters in the string
//
- for (NextDelim = FindFirstCharacter(*TempParameter, L"\"^", CHAR_NULL)
- ; *NextDelim != CHAR_NULL
- ; NextDelim = FindFirstCharacter(NextDelim, L"\"^", CHAR_NULL)
- ) {
+ for (NextDelim = FindFirstCharacter (*TempParameter, L"\"^", CHAR_NULL)
+ ; *NextDelim != CHAR_NULL
+ ; NextDelim = FindFirstCharacter (NextDelim, L"\"^", CHAR_NULL)
+ )
+ {
if (*NextDelim == L'^') {
-
//
// eliminate the escape ^
//
- CopyMem ((CHAR16*)NextDelim, NextDelim + 1, StrSize (NextDelim + 1));
+ CopyMem ((CHAR16 *)NextDelim, NextDelim + 1, StrSize (NextDelim + 1));
NextDelim++;
} else if (*NextDelim == L'\"') {
-
//
// eliminate the unescaped quote
//
if (StripQuotation) {
- CopyMem ((CHAR16*)NextDelim, NextDelim + 1, StrSize (NextDelim + 1));
- } else{
+ CopyMem ((CHAR16 *)NextDelim, NextDelim + 1, StrSize (NextDelim + 1));
+ } else {
NextDelim++;
- }
+ }
}
}
@@ -189,11 +188,11 @@ DEBUG_CODE_END(); @return EFI_OUT_OF_RESOURCES a memory allocation failed.
**/
EFI_STATUS
-ParseCommandLineToArgs(
- IN CONST CHAR16 *CommandLine,
- IN BOOLEAN StripQuotation,
- IN OUT CHAR16 ***Argv,
- IN OUT UINTN *Argc
+ParseCommandLineToArgs (
+ IN CONST CHAR16 *CommandLine,
+ IN BOOLEAN StripQuotation,
+ IN OUT CHAR16 ***Argv,
+ IN OUT UINTN *Argc
)
{
UINTN Count;
@@ -204,34 +203,35 @@ ParseCommandLineToArgs( UINTN Size;
EFI_STATUS Status;
- ASSERT(Argc != NULL);
- ASSERT(Argv != NULL);
+ ASSERT (Argc != NULL);
+ ASSERT (Argv != NULL);
- if (CommandLine == NULL || StrLen(CommandLine)==0) {
+ if ((CommandLine == NULL) || (StrLen (CommandLine) == 0)) {
(*Argc) = 0;
(*Argv) = NULL;
return (EFI_SUCCESS);
}
- NewCommandLine = AllocateCopyPool(StrSize(CommandLine), CommandLine);
- if (NewCommandLine == NULL){
+ NewCommandLine = AllocateCopyPool (StrSize (CommandLine), CommandLine);
+ if (NewCommandLine == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
- TrimSpaces(&NewCommandLine);
- Size = StrSize(NewCommandLine);
- TempParameter = AllocateZeroPool(Size);
+ TrimSpaces (&NewCommandLine);
+ Size = StrSize (NewCommandLine);
+ TempParameter = AllocateZeroPool (Size);
if (TempParameter == NULL) {
- SHELL_FREE_NON_NULL(NewCommandLine);
+ SHELL_FREE_NON_NULL (NewCommandLine);
return (EFI_OUT_OF_RESOURCES);
}
- for ( Count = 0
- , Walker = (CHAR16*)NewCommandLine
- ; Walker != NULL && *Walker != CHAR_NULL
- ; Count++
- ) {
- if (EFI_ERROR(GetNextParameter(&Walker, &TempParameter, Size, TRUE))) {
+ for ( Count = 0,
+ Walker = (CHAR16 *)NewCommandLine
+ ; Walker != NULL && *Walker != CHAR_NULL
+ ; Count++
+ )
+ {
+ if (EFI_ERROR (GetNextParameter (&Walker, &TempParameter, Size, TRUE))) {
break;
}
}
@@ -239,35 +239,37 @@ ParseCommandLineToArgs( //
// lets allocate the pointer array
//
- (*Argv) = AllocateZeroPool((Count)*sizeof(CHAR16*));
+ (*Argv) = AllocateZeroPool ((Count)*sizeof (CHAR16 *));
if (*Argv == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
- *Argc = 0;
- Walker = (CHAR16*)NewCommandLine;
- while(Walker != NULL && *Walker != CHAR_NULL) {
- SetMem16(TempParameter, Size, CHAR_NULL);
- if (EFI_ERROR(GetNextParameter(&Walker, &TempParameter, Size, StripQuotation))) {
+ *Argc = 0;
+ Walker = (CHAR16 *)NewCommandLine;
+ while (Walker != NULL && *Walker != CHAR_NULL) {
+ SetMem16 (TempParameter, Size, CHAR_NULL);
+ if (EFI_ERROR (GetNextParameter (&Walker, &TempParameter, Size, StripQuotation))) {
Status = EFI_INVALID_PARAMETER;
goto Done;
}
- NewParam = AllocateCopyPool(StrSize(TempParameter), TempParameter);
- if (NewParam == NULL){
+ NewParam = AllocateCopyPool (StrSize (TempParameter), TempParameter);
+ if (NewParam == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
- ((CHAR16**)(*Argv))[(*Argc)] = NewParam;
+
+ ((CHAR16 **)(*Argv))[(*Argc)] = NewParam;
(*Argc)++;
}
- ASSERT(Count >= (*Argc));
+
+ ASSERT (Count >= (*Argc));
Status = EFI_SUCCESS;
Done:
- SHELL_FREE_NON_NULL(TempParameter);
- SHELL_FREE_NON_NULL(NewCommandLine);
+ SHELL_FREE_NON_NULL (TempParameter);
+ SHELL_FREE_NON_NULL (NewCommandLine);
return (Status);
}
@@ -293,32 +295,32 @@ CreatePopulateInstallShellParametersProtocol ( IN OUT BOOLEAN *RootShellInstance
)
{
- EFI_STATUS Status;
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
- CHAR16 *FullCommandLine;
- UINTN Size;
+ EFI_STATUS Status;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+ CHAR16 *FullCommandLine;
+ UINTN Size;
- Size = 0;
+ Size = 0;
FullCommandLine = NULL;
- LoadedImage = NULL;
+ LoadedImage = NULL;
//
// Assert for valid parameters
//
- ASSERT(NewShellParameters != NULL);
- ASSERT(RootShellInstance != NULL);
+ ASSERT (NewShellParameters != NULL);
+ ASSERT (RootShellInstance != NULL);
//
// See if we have a shell parameters placed on us
//
Status = gBS->OpenProtocol (
- gImageHandle,
- &gEfiShellParametersProtocolGuid,
- (VOID **) &ShellInfoObject.OldShellParameters,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
+ gImageHandle,
+ &gEfiShellParametersProtocolGuid,
+ (VOID **)&ShellInfoObject.OldShellParameters,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
//
// if we don't then we must be the root shell (error is expected)
//
@@ -329,7 +331,7 @@ CreatePopulateInstallShellParametersProtocol ( //
// Allocate the new structure
//
- *NewShellParameters = AllocateZeroPool(sizeof(EFI_SHELL_PARAMETERS_PROTOCOL));
+ *NewShellParameters = AllocateZeroPool (sizeof (EFI_SHELL_PARAMETERS_PROTOCOL));
if ((*NewShellParameters) == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
@@ -338,52 +340,57 @@ CreatePopulateInstallShellParametersProtocol ( // get loaded image protocol
//
Status = gBS->OpenProtocol (
- gImageHandle,
- &gEfiLoadedImageProtocolGuid,
- (VOID **) &LoadedImage,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- ASSERT_EFI_ERROR(Status);
+ gImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **)&LoadedImage,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ ASSERT_EFI_ERROR (Status);
//
// Build the full command line
//
- Status = SHELL_GET_ENVIRONMENT_VARIABLE(L"ShellOpt", &Size, FullCommandLine);
+ Status = SHELL_GET_ENVIRONMENT_VARIABLE (L"ShellOpt", &Size, FullCommandLine);
if (Status == EFI_BUFFER_TOO_SMALL) {
- FullCommandLine = AllocateZeroPool(Size + LoadedImage->LoadOptionsSize);
- Status = SHELL_GET_ENVIRONMENT_VARIABLE(L"ShellOpt", &Size, FullCommandLine);
+ FullCommandLine = AllocateZeroPool (Size + LoadedImage->LoadOptionsSize);
+ Status = SHELL_GET_ENVIRONMENT_VARIABLE (L"ShellOpt", &Size, FullCommandLine);
}
+
if (Status == EFI_NOT_FOUND) {
//
// no parameters via environment... ok
//
} else {
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return (Status);
}
}
- if (Size == 0 && LoadedImage->LoadOptionsSize != 0) {
- ASSERT(FullCommandLine == NULL);
+
+ if ((Size == 0) && (LoadedImage->LoadOptionsSize != 0)) {
+ ASSERT (FullCommandLine == NULL);
//
// Now we need to include a NULL terminator in the size.
//
- Size = LoadedImage->LoadOptionsSize + sizeof(FullCommandLine[0]);
- FullCommandLine = AllocateZeroPool(Size);
+ Size = LoadedImage->LoadOptionsSize + sizeof (FullCommandLine[0]);
+ FullCommandLine = AllocateZeroPool (Size);
}
+
if (FullCommandLine != NULL) {
CopyMem (FullCommandLine, LoadedImage->LoadOptions, LoadedImage->LoadOptionsSize);
//
// Populate Argc and Argv
//
- Status = ParseCommandLineToArgs(FullCommandLine,
- TRUE,
- &(*NewShellParameters)->Argv,
- &(*NewShellParameters)->Argc);
+ Status = ParseCommandLineToArgs (
+ FullCommandLine,
+ TRUE,
+ &(*NewShellParameters)->Argv,
+ &(*NewShellParameters)->Argc
+ );
- FreePool(FullCommandLine);
+ FreePool (FullCommandLine);
- ASSERT_EFI_ERROR(Status);
+ ASSERT_EFI_ERROR (Status);
} else {
(*NewShellParameters)->Argv = NULL;
(*NewShellParameters)->Argc = 0;
@@ -396,10 +403,12 @@ CreatePopulateInstallShellParametersProtocol ( (*NewShellParameters)->StdIn = &FileInterfaceStdIn;
(*NewShellParameters)->StdOut = &FileInterfaceStdOut;
(*NewShellParameters)->StdErr = &FileInterfaceStdErr;
- Status = gBS->InstallProtocolInterface(&gImageHandle,
+ Status = gBS->InstallProtocolInterface (
+ &gImageHandle,
&gEfiShellParametersProtocolGuid,
EFI_NATIVE_INTERFACE,
- (VOID*)(*NewShellParameters));
+ (VOID *)(*NewShellParameters)
+ );
} else {
//
// copy from the existing ones
@@ -407,10 +416,12 @@ CreatePopulateInstallShellParametersProtocol ( (*NewShellParameters)->StdIn = ShellInfoObject.OldShellParameters->StdIn;
(*NewShellParameters)->StdOut = ShellInfoObject.OldShellParameters->StdOut;
(*NewShellParameters)->StdErr = ShellInfoObject.OldShellParameters->StdErr;
- Status = gBS->ReinstallProtocolInterface(gImageHandle,
- &gEfiShellParametersProtocolGuid,
- (VOID*)ShellInfoObject.OldShellParameters,
- (VOID*)(*NewShellParameters));
+ Status = gBS->ReinstallProtocolInterface (
+ gImageHandle,
+ &gEfiShellParametersProtocolGuid,
+ (VOID *)ShellInfoObject.OldShellParameters,
+ (VOID *)(*NewShellParameters)
+ );
}
return (Status);
@@ -433,36 +444,46 @@ CleanUpShellParametersProtocol ( IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *NewShellParameters
)
{
- EFI_STATUS Status;
- UINTN LoopCounter;
+ EFI_STATUS Status;
+ UINTN LoopCounter;
//
// If the old exists we need to restore it
//
if (ShellInfoObject.OldShellParameters != NULL) {
- Status = gBS->ReinstallProtocolInterface(gImageHandle,
- &gEfiShellParametersProtocolGuid,
- (VOID*)NewShellParameters,
- (VOID*)ShellInfoObject.OldShellParameters);
- DEBUG_CODE(ShellInfoObject.OldShellParameters = NULL;);
+ Status = gBS->ReinstallProtocolInterface (
+ gImageHandle,
+ &gEfiShellParametersProtocolGuid,
+ (VOID *)NewShellParameters,
+ (VOID *)ShellInfoObject.OldShellParameters
+ );
+ DEBUG_CODE (
+ ShellInfoObject.OldShellParameters = NULL;
+ );
} else {
//
// No old one, just uninstall us...
//
- Status = gBS->UninstallProtocolInterface(gImageHandle,
- &gEfiShellParametersProtocolGuid,
- (VOID*)NewShellParameters);
+ Status = gBS->UninstallProtocolInterface (
+ gImageHandle,
+ &gEfiShellParametersProtocolGuid,
+ (VOID *)NewShellParameters
+ );
}
+
if (NewShellParameters->Argv != NULL) {
for ( LoopCounter = 0
- ; LoopCounter < NewShellParameters->Argc
- ; LoopCounter++
- ){
- FreePool(NewShellParameters->Argv[LoopCounter]);
+ ; LoopCounter < NewShellParameters->Argc
+ ; LoopCounter++
+ )
+ {
+ FreePool (NewShellParameters->Argv[LoopCounter]);
}
- FreePool(NewShellParameters->Argv);
+
+ FreePool (NewShellParameters->Argv);
}
- FreePool(NewShellParameters);
+
+ FreePool (NewShellParameters);
return (Status);
}
@@ -475,29 +496,31 @@ CleanUpShellParametersProtocol ( @return An error upon failure.
**/
EFI_STATUS
-IsUnicodeFile(
- IN CONST CHAR16 *FileName
+IsUnicodeFile (
+ IN CONST CHAR16 *FileName
)
{
- SHELL_FILE_HANDLE Handle;
- EFI_STATUS Status;
- UINT64 OriginalFilePosition;
- UINTN CharSize;
- CHAR16 CharBuffer;
-
- Status = gEfiShellProtocol->OpenFileByName(FileName, &Handle, EFI_FILE_MODE_READ);
- if (EFI_ERROR(Status)) {
+ SHELL_FILE_HANDLE Handle;
+ EFI_STATUS Status;
+ UINT64 OriginalFilePosition;
+ UINTN CharSize;
+ CHAR16 CharBuffer;
+
+ Status = gEfiShellProtocol->OpenFileByName (FileName, &Handle, EFI_FILE_MODE_READ);
+ if (EFI_ERROR (Status)) {
return (Status);
}
- gEfiShellProtocol->GetFilePosition(Handle, &OriginalFilePosition);
- gEfiShellProtocol->SetFilePosition(Handle, 0);
- CharSize = sizeof(CHAR16);
- Status = gEfiShellProtocol->ReadFile(Handle, &CharSize, &CharBuffer);
- if (EFI_ERROR(Status) || CharBuffer != gUnicodeFileTag) {
+
+ gEfiShellProtocol->GetFilePosition (Handle, &OriginalFilePosition);
+ gEfiShellProtocol->SetFilePosition (Handle, 0);
+ CharSize = sizeof (CHAR16);
+ Status = gEfiShellProtocol->ReadFile (Handle, &CharSize, &CharBuffer);
+ if (EFI_ERROR (Status) || (CharBuffer != gUnicodeFileTag)) {
Status = EFI_BUFFER_TOO_SMALL;
}
- gEfiShellProtocol->SetFilePosition(Handle, OriginalFilePosition);
- gEfiShellProtocol->CloseFile(Handle);
+
+ gEfiShellProtocol->SetFilePosition (Handle, OriginalFilePosition);
+ gEfiShellProtocol->CloseFile (Handle);
return (Status);
}
@@ -510,16 +533,16 @@ IsUnicodeFile( **/
VOID
StripQuotes (
- IN OUT CHAR16 *TheString
+ IN OUT CHAR16 *TheString
)
{
- BOOLEAN RemoveNow;
+ BOOLEAN RemoveNow;
- for (RemoveNow = FALSE ; TheString != NULL && *TheString != CHAR_NULL ; TheString++) {
- if (*TheString == L'^' && *(TheString + 1) == L'\"') {
+ for (RemoveNow = FALSE; TheString != NULL && *TheString != CHAR_NULL; TheString++) {
+ if ((*TheString == L'^') && (*(TheString + 1) == L'\"')) {
TheString++;
} else if (*TheString == L'\"') {
- RemoveNow = (BOOLEAN)!RemoveNow;
+ RemoveNow = (BOOLEAN) !RemoveNow;
} else if (RemoveNow) {
*TheString = L' ';
}
@@ -535,10 +558,10 @@ StripQuotes ( **/
VOID
CalculateEfiHdrCrc (
- IN OUT EFI_TABLE_HEADER *Hdr
+ IN OUT EFI_TABLE_HEADER *Hdr
)
{
- UINT32 Crc;
+ UINT32 Crc;
Hdr->CRC32 = 0;
@@ -559,9 +582,9 @@ CalculateEfiHdrCrc ( @retval NULL FileName was invalid.
@return The modified FileName.
**/
-CHAR16*
+CHAR16 *
FixFileName (
- IN CHAR16 *FileName
+ IN CHAR16 *FileName
)
{
CHAR16 *Copy;
@@ -573,15 +596,16 @@ FixFileName ( if (FileName[0] == L'\"') {
Copy = FileName+1;
- if ((TempLocation = StrStr(Copy , L"\"")) != NULL) {
+ if ((TempLocation = StrStr (Copy, L"\"")) != NULL) {
TempLocation[0] = CHAR_NULL;
}
} else {
Copy = FileName;
- while(Copy[0] == L' ') {
+ while (Copy[0] == L' ') {
Copy++;
}
- if ((TempLocation = StrStr(Copy , L" ")) != NULL) {
+
+ if ((TempLocation = StrStr (Copy, L" ")) != NULL) {
TempLocation[0] = CHAR_NULL;
}
}
@@ -601,9 +625,9 @@ FixFileName ( @retval NULL FileName was invalid.
@return The modified FileName.
**/
-CHAR16*
+CHAR16 *
FixVarName (
- IN CHAR16 *FileName
+ IN CHAR16 *FileName
)
{
CHAR16 *Copy;
@@ -613,15 +637,14 @@ FixVarName ( if (FileName[0] == L'%') {
Copy = FileName+1;
- if ((TempLocation = StrStr(Copy , L"%")) != NULL) {
+ if ((TempLocation = StrStr (Copy, L"%")) != NULL) {
TempLocation[0] = CHAR_NULL;
}
}
- return (FixFileName(Copy));
+ return (FixFileName (Copy));
}
-
/**
Write the unicode file tag to the specified file.
@@ -635,22 +658,24 @@ FixVarName ( **/
EFI_STATUS
WriteFileTag (
- IN SHELL_FILE_HANDLE FileHandle
+ IN SHELL_FILE_HANDLE FileHandle
)
{
- CHAR16 FileTag;
- UINTN Size;
- EFI_STATUS Status;
+ CHAR16 FileTag;
+ UINTN Size;
+ EFI_STATUS Status;
FileTag = gUnicodeFileTag;
- Size = sizeof FileTag;
- Status = ShellInfoObject.NewEfiShellProtocol->WriteFile (FileHandle, &Size,
- &FileTag);
+ Size = sizeof FileTag;
+ Status = ShellInfoObject.NewEfiShellProtocol->WriteFile (
+ FileHandle,
+ &Size,
+ &FileTag
+ );
ASSERT (EFI_ERROR (Status) || Size == sizeof FileTag);
return Status;
}
-
/**
Function will replace the current StdIn and StdOut in the ShellParameters protocol
structure by parsing NewCommandLine. The current values are returned to the
@@ -669,7 +694,7 @@ WriteFileTag ( @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
**/
EFI_STATUS
-UpdateStdInStdOutStdErr(
+UpdateStdInStdOutStdErr (
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
IN CHAR16 *NewCommandLine,
OUT SHELL_FILE_HANDLE *OldStdIn,
@@ -678,323 +703,353 @@ UpdateStdInStdOutStdErr( OUT SYSTEM_TABLE_INFO *SystemTableInfo
)
{
- CHAR16 *CommandLineCopy;
- CHAR16 *CommandLineWalker;
- CHAR16 *StdErrFileName;
- CHAR16 *StdOutFileName;
- CHAR16 *StdInFileName;
- CHAR16 *StdInVarName;
- CHAR16 *StdOutVarName;
- CHAR16 *StdErrVarName;
- EFI_STATUS Status;
- SHELL_FILE_HANDLE TempHandle;
- UINT64 FileSize;
- BOOLEAN OutUnicode;
- BOOLEAN InUnicode;
- BOOLEAN ErrUnicode;
- BOOLEAN OutAppend;
- BOOLEAN ErrAppend;
- UINTN Size;
- SPLIT_LIST *Split;
- CHAR16 *FirstLocation;
- BOOLEAN Volatile;
-
- OutUnicode = TRUE;
- InUnicode = TRUE;
+ CHAR16 *CommandLineCopy;
+ CHAR16 *CommandLineWalker;
+ CHAR16 *StdErrFileName;
+ CHAR16 *StdOutFileName;
+ CHAR16 *StdInFileName;
+ CHAR16 *StdInVarName;
+ CHAR16 *StdOutVarName;
+ CHAR16 *StdErrVarName;
+ EFI_STATUS Status;
+ SHELL_FILE_HANDLE TempHandle;
+ UINT64 FileSize;
+ BOOLEAN OutUnicode;
+ BOOLEAN InUnicode;
+ BOOLEAN ErrUnicode;
+ BOOLEAN OutAppend;
+ BOOLEAN ErrAppend;
+ UINTN Size;
+ SPLIT_LIST *Split;
+ CHAR16 *FirstLocation;
+ BOOLEAN Volatile;
+
+ OutUnicode = TRUE;
+ InUnicode = TRUE;
AsciiRedirection = FALSE;
- ErrUnicode = TRUE;
- StdInVarName = NULL;
- StdOutVarName = NULL;
- StdErrVarName = NULL;
- StdErrFileName = NULL;
- StdInFileName = NULL;
- StdOutFileName = NULL;
- ErrAppend = FALSE;
- OutAppend = FALSE;
- CommandLineCopy = NULL;
- FirstLocation = NULL;
-
- if (ShellParameters == NULL || SystemTableInfo == NULL || OldStdIn == NULL || OldStdOut == NULL || OldStdErr == NULL) {
+ ErrUnicode = TRUE;
+ StdInVarName = NULL;
+ StdOutVarName = NULL;
+ StdErrVarName = NULL;
+ StdErrFileName = NULL;
+ StdInFileName = NULL;
+ StdOutFileName = NULL;
+ ErrAppend = FALSE;
+ OutAppend = FALSE;
+ CommandLineCopy = NULL;
+ FirstLocation = NULL;
+
+ if ((ShellParameters == NULL) || (SystemTableInfo == NULL) || (OldStdIn == NULL) || (OldStdOut == NULL) || (OldStdErr == NULL)) {
return (EFI_INVALID_PARAMETER);
}
- SystemTableInfo->ConIn = gST->ConIn;
- SystemTableInfo->ConInHandle = gST->ConsoleInHandle;
- SystemTableInfo->ConOut = gST->ConOut;
- SystemTableInfo->ConOutHandle = gST->ConsoleOutHandle;
- SystemTableInfo->ErrOut = gST->StdErr;
- SystemTableInfo->ErrOutHandle = gST->StandardErrorHandle;
- *OldStdIn = ShellParameters->StdIn;
- *OldStdOut = ShellParameters->StdOut;
- *OldStdErr = ShellParameters->StdErr;
+ SystemTableInfo->ConIn = gST->ConIn;
+ SystemTableInfo->ConInHandle = gST->ConsoleInHandle;
+ SystemTableInfo->ConOut = gST->ConOut;
+ SystemTableInfo->ConOutHandle = gST->ConsoleOutHandle;
+ SystemTableInfo->ErrOut = gST->StdErr;
+ SystemTableInfo->ErrOutHandle = gST->StandardErrorHandle;
+ *OldStdIn = ShellParameters->StdIn;
+ *OldStdOut = ShellParameters->StdOut;
+ *OldStdErr = ShellParameters->StdErr;
if (NewCommandLine == NULL) {
return (EFI_SUCCESS);
}
- CommandLineCopy = StrnCatGrow(&CommandLineCopy, NULL, NewCommandLine, 0);
+ CommandLineCopy = StrnCatGrow (&CommandLineCopy, NULL, NewCommandLine, 0);
if (CommandLineCopy == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
- Status = EFI_SUCCESS;
- Split = NULL;
- FirstLocation = CommandLineCopy + StrLen(CommandLineCopy);
- StripQuotes(CommandLineCopy);
+ Status = EFI_SUCCESS;
+ Split = NULL;
+ FirstLocation = CommandLineCopy + StrLen (CommandLineCopy);
+
+ StripQuotes (CommandLineCopy);
- if (!IsListEmpty(&ShellInfoObject.SplitList.Link)) {
- Split = (SPLIT_LIST*)GetFirstNode(&ShellInfoObject.SplitList.Link);
- if (Split != NULL && Split->SplitStdIn != NULL) {
- ShellParameters->StdIn = Split->SplitStdIn;
+ if (!IsListEmpty (&ShellInfoObject.SplitList.Link)) {
+ Split = (SPLIT_LIST *)GetFirstNode (&ShellInfoObject.SplitList.Link);
+ if ((Split != NULL) && (Split->SplitStdIn != NULL)) {
+ ShellParameters->StdIn = Split->SplitStdIn;
}
- if (Split != NULL && Split->SplitStdOut != NULL) {
+
+ if ((Split != NULL) && (Split->SplitStdOut != NULL)) {
ShellParameters->StdOut = Split->SplitStdOut;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>>v ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 12, L' ');
- StdErrVarName = CommandLineWalker += 6;
- ErrAppend = TRUE;
- if (StrStr(CommandLineWalker, L" 2>>v ") != NULL) {
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 2>>v ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 12, L' ');
+ StdErrVarName = CommandLineWalker += 6;
+ ErrAppend = TRUE;
+ if (StrStr (CommandLineWalker, L" 2>>v ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>>v ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 12, L' ');
- StdOutVarName = CommandLineWalker += 6;
- OutAppend = TRUE;
- if (StrStr(CommandLineWalker, L" 1>>v ") != NULL) {
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 1>>v ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 12, L' ');
+ StdOutVarName = CommandLineWalker += 6;
+ OutAppend = TRUE;
+ if (StrStr (CommandLineWalker, L" 1>>v ") != NULL) {
Status = EFI_NOT_FOUND;
}
- } else if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >>v ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 10, L' ');
- StdOutVarName = CommandLineWalker += 5;
- OutAppend = TRUE;
- if (StrStr(CommandLineWalker, L" >>v ") != NULL) {
+ } else if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" >>v ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 10, L' ');
+ StdOutVarName = CommandLineWalker += 5;
+ OutAppend = TRUE;
+ if (StrStr (CommandLineWalker, L" >>v ") != NULL) {
Status = EFI_NOT_FOUND;
}
- } else if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >v ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 8, L' ');
- StdOutVarName = CommandLineWalker += 4;
- OutAppend = FALSE;
- if (StrStr(CommandLineWalker, L" >v ") != NULL) {
+ } else if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" >v ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 8, L' ');
+ StdOutVarName = CommandLineWalker += 4;
+ OutAppend = FALSE;
+ if (StrStr (CommandLineWalker, L" >v ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>>a ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 12, L' ');
- StdOutFileName = CommandLineWalker += 6;
- OutAppend = TRUE;
- OutUnicode = FALSE;
- if (StrStr(CommandLineWalker, L" 1>>a ") != NULL) {
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 1>>a ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 12, L' ');
+ StdOutFileName = CommandLineWalker += 6;
+ OutAppend = TRUE;
+ OutUnicode = FALSE;
+ if (StrStr (CommandLineWalker, L" 1>>a ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>> ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 10, L' ');
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 1>> ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 10, L' ');
if (StdOutFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdOutFileName = CommandLineWalker += 5;
- OutAppend = TRUE;
+ StdOutFileName = CommandLineWalker += 5;
+ OutAppend = TRUE;
}
- if (StrStr(CommandLineWalker, L" 1>> ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" 1>> ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >> ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 8, L' ');
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" >> ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 8, L' ');
if (StdOutFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdOutFileName = CommandLineWalker += 4;
- OutAppend = TRUE;
+ StdOutFileName = CommandLineWalker += 4;
+ OutAppend = TRUE;
}
- if (StrStr(CommandLineWalker, L" >> ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" >> ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >>a ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 10, L' ');
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" >>a ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 10, L' ');
if (StdOutFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdOutFileName = CommandLineWalker += 5;
- OutAppend = TRUE;
- OutUnicode = FALSE;
+ StdOutFileName = CommandLineWalker += 5;
+ OutAppend = TRUE;
+ OutUnicode = FALSE;
}
- if (StrStr(CommandLineWalker, L" >>a ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" >>a ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>a ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 10, L' ');
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 1>a ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 10, L' ');
if (StdOutFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdOutFileName = CommandLineWalker += 5;
- OutAppend = FALSE;
- OutUnicode = FALSE;
+ StdOutFileName = CommandLineWalker += 5;
+ OutAppend = FALSE;
+ OutUnicode = FALSE;
}
- if (StrStr(CommandLineWalker, L" 1>a ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" 1>a ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" >a ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 8, L' ');
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" >a ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 8, L' ');
if (StdOutFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdOutFileName = CommandLineWalker += 4;
- OutAppend = FALSE;
- OutUnicode = FALSE;
+ StdOutFileName = CommandLineWalker += 4;
+ OutAppend = FALSE;
+ OutUnicode = FALSE;
}
- if (StrStr(CommandLineWalker, L" >a ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" >a ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>> ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 10, L' ');
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 2>> ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 10, L' ');
if (StdErrFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdErrFileName = CommandLineWalker += 5;
- ErrAppend = TRUE;
+ StdErrFileName = CommandLineWalker += 5;
+ ErrAppend = TRUE;
}
- if (StrStr(CommandLineWalker, L" 2>> ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" 2>> ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>v ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 10, L' ');
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 2>v ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 10, L' ');
if (StdErrVarName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdErrVarName = CommandLineWalker += 5;
- ErrAppend = FALSE;
+ StdErrVarName = CommandLineWalker += 5;
+ ErrAppend = FALSE;
}
- if (StrStr(CommandLineWalker, L" 2>v ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" 2>v ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1>v ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 10, L' ');
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 1>v ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 10, L' ');
if (StdOutVarName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdOutVarName = CommandLineWalker += 5;
- OutAppend = FALSE;
+ StdOutVarName = CommandLineWalker += 5;
+ OutAppend = FALSE;
}
- if (StrStr(CommandLineWalker, L" 1>v ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" 1>v ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2>a ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 10, L' ');
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 2>a ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 10, L' ');
if (StdErrFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdErrFileName = CommandLineWalker += 5;
- ErrAppend = FALSE;
- ErrUnicode = FALSE;
+ StdErrFileName = CommandLineWalker += 5;
+ ErrAppend = FALSE;
+ ErrUnicode = FALSE;
}
- if (StrStr(CommandLineWalker, L" 2>a ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" 2>a ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 2> ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 8, L' ');
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 2> ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 8, L' ');
if (StdErrFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdErrFileName = CommandLineWalker += 4;
- ErrAppend = FALSE;
+ StdErrFileName = CommandLineWalker += 4;
+ ErrAppend = FALSE;
}
- if (StrStr(CommandLineWalker, L" 2> ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" 2> ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" 1> ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 8, L' ');
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" 1> ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 8, L' ');
if (StdOutFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdOutFileName = CommandLineWalker += 4;
- OutAppend = FALSE;
+ StdOutFileName = CommandLineWalker += 4;
+ OutAppend = FALSE;
}
- if (StrStr(CommandLineWalker, L" 1> ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" 1> ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" > ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 6, L' ');
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" > ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 6, L' ');
if (StdOutFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdOutFileName = CommandLineWalker += 3;
- OutAppend = FALSE;
+ StdOutFileName = CommandLineWalker += 3;
+ OutAppend = FALSE;
}
- if (StrStr(CommandLineWalker, L" > ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" > ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" < ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 6, L' ');
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" < ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 6, L' ');
if (StdInFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdInFileName = CommandLineWalker += 3;
+ StdInFileName = CommandLineWalker += 3;
}
- if (StrStr(CommandLineWalker, L" < ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" < ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" <a ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 8, L' ');
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" <a ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 8, L' ');
if (StdInFileName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdInFileName = CommandLineWalker += 4;
- InUnicode = FALSE;
+ StdInFileName = CommandLineWalker += 4;
+ InUnicode = FALSE;
AsciiRedirection = TRUE;
}
- if (StrStr(CommandLineWalker, L" <a ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" <a ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
- if (!EFI_ERROR(Status) && (CommandLineWalker = StrStr(CommandLineCopy, L" <v ")) != NULL) {
- FirstLocation = MIN(CommandLineWalker, FirstLocation);
- SetMem16(CommandLineWalker, 8, L' ');
+
+ if (!EFI_ERROR (Status) && ((CommandLineWalker = StrStr (CommandLineCopy, L" <v ")) != NULL)) {
+ FirstLocation = MIN (CommandLineWalker, FirstLocation);
+ SetMem16 (CommandLineWalker, 8, L' ');
if (StdInVarName != NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- StdInVarName = CommandLineWalker += 4;
+ StdInVarName = CommandLineWalker += 4;
}
- if (StrStr(CommandLineWalker, L" <v ") != NULL) {
+
+ if (StrStr (CommandLineWalker, L" <v ") != NULL) {
Status = EFI_NOT_FOUND;
}
}
@@ -1002,43 +1057,48 @@ UpdateStdInStdOutStdErr( //
// re-populate the string to support any filenames that were in quotes.
//
- StrnCpyS(CommandLineCopy, StrSize(CommandLineCopy)/sizeof(CHAR16), NewCommandLine, StrLen(NewCommandLine));
+ StrnCpyS (CommandLineCopy, StrSize (CommandLineCopy)/sizeof (CHAR16), NewCommandLine, StrLen (NewCommandLine));
- if (FirstLocation != CommandLineCopy + StrLen(CommandLineCopy)
- && (((UINTN)FirstLocation - (UINTN)CommandLineCopy)/sizeof(CHAR16) < StrLen(NewCommandLine))
- ){
- *(NewCommandLine + ((UINTN)FirstLocation - (UINTN)CommandLineCopy)/sizeof(CHAR16)) = CHAR_NULL;
+ if ( (FirstLocation != CommandLineCopy + StrLen (CommandLineCopy))
+ && (((UINTN)FirstLocation - (UINTN)CommandLineCopy)/sizeof (CHAR16) < StrLen (NewCommandLine))
+ )
+ {
+ *(NewCommandLine + ((UINTN)FirstLocation - (UINTN)CommandLineCopy)/sizeof (CHAR16)) = CHAR_NULL;
}
- if (!EFI_ERROR(Status)) {
-
+ if (!EFI_ERROR (Status)) {
if (StdErrFileName != NULL) {
- if ((StdErrFileName = FixFileName(StdErrFileName)) == NULL) {
+ if ((StdErrFileName = FixFileName (StdErrFileName)) == NULL) {
Status = EFI_INVALID_PARAMETER;
}
}
+
if (StdOutFileName != NULL) {
- if ((StdOutFileName = FixFileName(StdOutFileName)) == NULL) {
+ if ((StdOutFileName = FixFileName (StdOutFileName)) == NULL) {
Status = EFI_INVALID_PARAMETER;
}
}
+
if (StdInFileName != NULL) {
- if ((StdInFileName = FixFileName(StdInFileName)) == NULL) {
+ if ((StdInFileName = FixFileName (StdInFileName)) == NULL) {
Status = EFI_INVALID_PARAMETER;
}
}
+
if (StdErrVarName != NULL) {
- if ((StdErrVarName = FixVarName(StdErrVarName)) == NULL) {
+ if ((StdErrVarName = FixVarName (StdErrVarName)) == NULL) {
Status = EFI_INVALID_PARAMETER;
}
}
+
if (StdOutVarName != NULL) {
- if ((StdOutVarName = FixVarName(StdOutVarName)) == NULL) {
+ if ((StdOutVarName = FixVarName (StdOutVarName)) == NULL) {
Status = EFI_INVALID_PARAMETER;
}
}
+
if (StdInVarName != NULL) {
- if ((StdInVarName = FixVarName(StdInVarName)) == NULL) {
+ if ((StdInVarName = FixVarName (StdInVarName)) == NULL) {
Status = EFI_INVALID_PARAMETER;
}
}
@@ -1047,52 +1107,53 @@ UpdateStdInStdOutStdErr( // Verify not the same and not duplicating something from a split
//
if (
- //
- // Check that no 2 filenames are the same
- //
- (StdErrFileName != NULL && StdOutFileName!= NULL && StringNoCaseCompare(&StdErrFileName, &StdOutFileName) == 0)
- ||(StdErrFileName != NULL && StdInFileName != NULL && StringNoCaseCompare(&StdErrFileName, &StdInFileName ) == 0)
- ||(StdOutFileName != NULL && StdInFileName != NULL && StringNoCaseCompare(&StdOutFileName, &StdInFileName ) == 0)
- //
- // Check that no 2 variable names are the same
- //
- ||(StdErrVarName != NULL && StdInVarName != NULL && StringNoCaseCompare(&StdErrVarName , &StdInVarName ) == 0)
- ||(StdOutVarName != NULL && StdInVarName != NULL && StringNoCaseCompare(&StdOutVarName , &StdInVarName ) == 0)
- ||(StdErrVarName != NULL && StdOutVarName != NULL && StringNoCaseCompare(&StdErrVarName , &StdOutVarName ) == 0)
- //
- // When a split (using | operator) is in place some are not allowed
- //
- ||(Split != NULL && Split->SplitStdIn != NULL && (StdInVarName != NULL || StdInFileName != NULL))
- ||(Split != NULL && Split->SplitStdOut != NULL && (StdOutVarName != NULL || StdOutFileName != NULL))
- //
- // Check that nothing is trying to be output to 2 locations.
- //
- ||(StdErrFileName != NULL && StdErrVarName != NULL)
- ||(StdOutFileName != NULL && StdOutVarName != NULL)
- ||(StdInFileName != NULL && StdInVarName != NULL)
- //
- // Check for no volatile environment variables
- //
- ||(StdErrVarName != NULL && !EFI_ERROR (IsVolatileEnv (StdErrVarName, &Volatile)) && !Volatile)
- ||(StdOutVarName != NULL && !EFI_ERROR (IsVolatileEnv (StdOutVarName, &Volatile)) && !Volatile)
- //
- // Cant redirect during a reconnect operation.
- //
- ||(StrStr(NewCommandLine, L"connect -r") != NULL
- && (StdOutVarName != NULL || StdOutFileName != NULL || StdErrFileName != NULL || StdErrVarName != NULL))
- //
- // Check that filetypes (Unicode/Ascii) do not change during an append
- //
- ||(StdOutFileName != NULL && OutUnicode && OutAppend && (!EFI_ERROR(ShellFileExists(StdOutFileName)) && EFI_ERROR(IsUnicodeFile(StdOutFileName))))
- ||(StdErrFileName != NULL && ErrUnicode && ErrAppend && (!EFI_ERROR(ShellFileExists(StdErrFileName)) && EFI_ERROR(IsUnicodeFile(StdErrFileName))))
- ||(StdOutFileName != NULL && !OutUnicode && OutAppend && (!EFI_ERROR(ShellFileExists(StdOutFileName)) && !EFI_ERROR(IsUnicodeFile(StdOutFileName))))
- ||(StdErrFileName != NULL && !ErrUnicode && ErrAppend && (!EFI_ERROR(ShellFileExists(StdErrFileName)) && !EFI_ERROR(IsUnicodeFile(StdErrFileName))))
- ){
- Status = EFI_INVALID_PARAMETER;
+ //
+ // Check that no 2 filenames are the same
+ //
+ ((StdErrFileName != NULL) && (StdOutFileName != NULL) && (StringNoCaseCompare (&StdErrFileName, &StdOutFileName) == 0))
+ || ((StdErrFileName != NULL) && (StdInFileName != NULL) && (StringNoCaseCompare (&StdErrFileName, &StdInFileName) == 0))
+ || ((StdOutFileName != NULL) && (StdInFileName != NULL) && (StringNoCaseCompare (&StdOutFileName, &StdInFileName) == 0))
+ //
+ // Check that no 2 variable names are the same
+ //
+ || ((StdErrVarName != NULL) && (StdInVarName != NULL) && (StringNoCaseCompare (&StdErrVarName, &StdInVarName) == 0))
+ || ((StdOutVarName != NULL) && (StdInVarName != NULL) && (StringNoCaseCompare (&StdOutVarName, &StdInVarName) == 0))
+ || ((StdErrVarName != NULL) && (StdOutVarName != NULL) && (StringNoCaseCompare (&StdErrVarName, &StdOutVarName) == 0))
+ //
+ // When a split (using | operator) is in place some are not allowed
+ //
+ || ((Split != NULL) && (Split->SplitStdIn != NULL) && ((StdInVarName != NULL) || (StdInFileName != NULL)))
+ || ((Split != NULL) && (Split->SplitStdOut != NULL) && ((StdOutVarName != NULL) || (StdOutFileName != NULL)))
+ //
+ // Check that nothing is trying to be output to 2 locations.
+ //
+ || ((StdErrFileName != NULL) && (StdErrVarName != NULL))
+ || ((StdOutFileName != NULL) && (StdOutVarName != NULL))
+ || ((StdInFileName != NULL) && (StdInVarName != NULL))
+ //
+ // Check for no volatile environment variables
+ //
+ || ((StdErrVarName != NULL) && !EFI_ERROR (IsVolatileEnv (StdErrVarName, &Volatile)) && !Volatile)
+ || ((StdOutVarName != NULL) && !EFI_ERROR (IsVolatileEnv (StdOutVarName, &Volatile)) && !Volatile)
+ //
+ // Cant redirect during a reconnect operation.
+ //
+ || ( (StrStr (NewCommandLine, L"connect -r") != NULL)
+ && ((StdOutVarName != NULL) || (StdOutFileName != NULL) || (StdErrFileName != NULL) || (StdErrVarName != NULL)))
+ //
+ // Check that filetypes (Unicode/Ascii) do not change during an append
+ //
+ || ((StdOutFileName != NULL) && OutUnicode && OutAppend && (!EFI_ERROR (ShellFileExists (StdOutFileName)) && EFI_ERROR (IsUnicodeFile (StdOutFileName))))
+ || ((StdErrFileName != NULL) && ErrUnicode && ErrAppend && (!EFI_ERROR (ShellFileExists (StdErrFileName)) && EFI_ERROR (IsUnicodeFile (StdErrFileName))))
+ || ((StdOutFileName != NULL) && !OutUnicode && OutAppend && (!EFI_ERROR (ShellFileExists (StdOutFileName)) && !EFI_ERROR (IsUnicodeFile (StdOutFileName))))
+ || ((StdErrFileName != NULL) && !ErrUnicode && ErrAppend && (!EFI_ERROR (ShellFileExists (StdErrFileName)) && !EFI_ERROR (IsUnicodeFile (StdErrFileName))))
+ )
+ {
+ Status = EFI_INVALID_PARAMETER;
ShellParameters->StdIn = *OldStdIn;
ShellParameters->StdOut = *OldStdOut;
ShellParameters->StdErr = *OldStdErr;
- } else if (!EFI_ERROR(Status)){
+ } else if (!EFI_ERROR (Status)) {
//
// Open the Std<Whatever> and we should not have conflicts here...
//
@@ -1105,62 +1166,69 @@ UpdateStdInStdOutStdErr( //
// delete existing file.
//
- ShellInfoObject.NewEfiShellProtocol->DeleteFileByName(StdErrFileName);
+ ShellInfoObject.NewEfiShellProtocol->DeleteFileByName (StdErrFileName);
}
- Status = ShellOpenFileByName(StdErrFileName, &TempHandle, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE,0);
- if (!ErrAppend && ErrUnicode && !EFI_ERROR(Status)) {
+
+ Status = ShellOpenFileByName (StdErrFileName, &TempHandle, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE, 0);
+ if (!ErrAppend && ErrUnicode && !EFI_ERROR (Status)) {
Status = WriteFileTag (TempHandle);
}
- if (!ErrUnicode && !EFI_ERROR(Status)) {
- TempHandle = CreateFileInterfaceFile(TempHandle, FALSE);
- ASSERT(TempHandle != NULL);
+
+ if (!ErrUnicode && !EFI_ERROR (Status)) {
+ TempHandle = CreateFileInterfaceFile (TempHandle, FALSE);
+ ASSERT (TempHandle != NULL);
}
- if (!EFI_ERROR(Status)) {
+
+ if (!EFI_ERROR (Status)) {
ShellParameters->StdErr = TempHandle;
- gST->StdErr = CreateSimpleTextOutOnFile(TempHandle, &gST->StandardErrorHandle, gST->StdErr);
+ gST->StdErr = CreateSimpleTextOutOnFile (TempHandle, &gST->StandardErrorHandle, gST->StdErr);
}
}
//
// StdOut to a file
//
- if (!EFI_ERROR(Status) && StdOutFileName != NULL) {
+ if (!EFI_ERROR (Status) && (StdOutFileName != NULL)) {
if (!OutAppend) {
//
// delete existing file.
//
- ShellInfoObject.NewEfiShellProtocol->DeleteFileByName(StdOutFileName);
+ ShellInfoObject.NewEfiShellProtocol->DeleteFileByName (StdOutFileName);
}
- Status = ShellOpenFileByName(StdOutFileName, &TempHandle, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE,0);
+
+ Status = ShellOpenFileByName (StdOutFileName, &TempHandle, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE, 0);
if (TempHandle == NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
if (gUnicodeCollation->MetaiMatch (gUnicodeCollation, StdOutFileName, L"NUL")) {
- //no-op
- } else if (!OutAppend && OutUnicode && !EFI_ERROR(Status)) {
+ // no-op
+ } else if (!OutAppend && OutUnicode && !EFI_ERROR (Status)) {
Status = WriteFileTag (TempHandle);
} else if (OutAppend) {
- Status = ShellInfoObject.NewEfiShellProtocol->GetFileSize(TempHandle, &FileSize);
- if (!EFI_ERROR(Status)) {
+ Status = ShellInfoObject.NewEfiShellProtocol->GetFileSize (TempHandle, &FileSize);
+ if (!EFI_ERROR (Status)) {
//
// When appending to a new unicode file, write the file tag.
// Otherwise (ie. when appending to a new ASCII file, or an
// existent file with any encoding), just seek to the end.
//
Status = (FileSize == 0 && OutUnicode) ?
- WriteFileTag (TempHandle) :
- ShellInfoObject.NewEfiShellProtocol->SetFilePosition (
- TempHandle,
- FileSize);
+ WriteFileTag (TempHandle) :
+ ShellInfoObject.NewEfiShellProtocol->SetFilePosition (
+ TempHandle,
+ FileSize
+ );
}
}
- if (!OutUnicode && !EFI_ERROR(Status)) {
- TempHandle = CreateFileInterfaceFile(TempHandle, FALSE);
- ASSERT(TempHandle != NULL);
+
+ if (!OutUnicode && !EFI_ERROR (Status)) {
+ TempHandle = CreateFileInterfaceFile (TempHandle, FALSE);
+ ASSERT (TempHandle != NULL);
}
- if (!EFI_ERROR(Status)) {
+
+ if (!EFI_ERROR (Status)) {
ShellParameters->StdOut = TempHandle;
- gST->ConOut = CreateSimpleTextOutOnFile(TempHandle, &gST->ConsoleOutHandle, gST->ConOut);
+ gST->ConOut = CreateSimpleTextOutOnFile (TempHandle, &gST->ConsoleOutHandle, gST->ConOut);
}
}
}
@@ -1168,52 +1236,55 @@ UpdateStdInStdOutStdErr( //
// StdOut to a var
//
- if (!EFI_ERROR(Status) && StdOutVarName != NULL) {
+ if (!EFI_ERROR (Status) && (StdOutVarName != NULL)) {
if (!OutAppend) {
//
// delete existing variable.
//
- SHELL_SET_ENVIRONMENT_VARIABLE_V(StdOutVarName, 0, L"");
+ SHELL_SET_ENVIRONMENT_VARIABLE_V (StdOutVarName, 0, L"");
}
- TempHandle = CreateFileInterfaceEnv(StdOutVarName);
- ASSERT(TempHandle != NULL);
+
+ TempHandle = CreateFileInterfaceEnv (StdOutVarName);
+ ASSERT (TempHandle != NULL);
ShellParameters->StdOut = TempHandle;
- gST->ConOut = CreateSimpleTextOutOnFile(TempHandle, &gST->ConsoleOutHandle, gST->ConOut);
+ gST->ConOut = CreateSimpleTextOutOnFile (TempHandle, &gST->ConsoleOutHandle, gST->ConOut);
}
//
// StdErr to a var
//
- if (!EFI_ERROR(Status) && StdErrVarName != NULL) {
+ if (!EFI_ERROR (Status) && (StdErrVarName != NULL)) {
if (!ErrAppend) {
//
// delete existing variable.
//
- SHELL_SET_ENVIRONMENT_VARIABLE_V(StdErrVarName, 0, L"");
+ SHELL_SET_ENVIRONMENT_VARIABLE_V (StdErrVarName, 0, L"");
}
- TempHandle = CreateFileInterfaceEnv(StdErrVarName);
- ASSERT(TempHandle != NULL);
+
+ TempHandle = CreateFileInterfaceEnv (StdErrVarName);
+ ASSERT (TempHandle != NULL);
ShellParameters->StdErr = TempHandle;
- gST->StdErr = CreateSimpleTextOutOnFile(TempHandle, &gST->StandardErrorHandle, gST->StdErr);
+ gST->StdErr = CreateSimpleTextOutOnFile (TempHandle, &gST->StandardErrorHandle, gST->StdErr);
}
//
// StdIn from a var
//
- if (!EFI_ERROR(Status) && StdInVarName != NULL) {
- TempHandle = CreateFileInterfaceEnv(StdInVarName);
+ if (!EFI_ERROR (Status) && (StdInVarName != NULL)) {
+ TempHandle = CreateFileInterfaceEnv (StdInVarName);
if (TempHandle == NULL) {
Status = EFI_OUT_OF_RESOURCES;
} else {
if (!InUnicode) {
- TempHandle = CreateFileInterfaceFile(TempHandle, FALSE);
+ TempHandle = CreateFileInterfaceFile (TempHandle, FALSE);
}
+
Size = 0;
- if (TempHandle == NULL || ((EFI_FILE_PROTOCOL*)TempHandle)->Read(TempHandle, &Size, NULL) != EFI_BUFFER_TOO_SMALL) {
+ if ((TempHandle == NULL) || (((EFI_FILE_PROTOCOL *)TempHandle)->Read (TempHandle, &Size, NULL) != EFI_BUFFER_TOO_SMALL)) {
Status = EFI_INVALID_PARAMETER;
} else {
ShellParameters->StdIn = TempHandle;
- gST->ConIn = CreateSimpleTextInOnFile(TempHandle, &gST->ConsoleInHandle);
+ gST->ConIn = CreateSimpleTextInOnFile (TempHandle, &gST->ConsoleInHandle);
}
}
}
@@ -1221,37 +1292,40 @@ UpdateStdInStdOutStdErr( //
// StdIn from a file
//
- if (!EFI_ERROR(Status) && StdInFileName != NULL) {
- Status = ShellOpenFileByName(
- StdInFileName,
- &TempHandle,
- EFI_FILE_MODE_READ,
- 0);
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status) && (StdInFileName != NULL)) {
+ Status = ShellOpenFileByName (
+ StdInFileName,
+ &TempHandle,
+ EFI_FILE_MODE_READ,
+ 0
+ );
+ if (!EFI_ERROR (Status)) {
if (!InUnicode) {
//
// Create the ASCII->Unicode conversion layer
//
- TempHandle = CreateFileInterfaceFile(TempHandle, FALSE);
+ TempHandle = CreateFileInterfaceFile (TempHandle, FALSE);
}
+
ShellParameters->StdIn = TempHandle;
- gST->ConIn = CreateSimpleTextInOnFile(TempHandle, &gST->ConsoleInHandle);
+ gST->ConIn = CreateSimpleTextInOnFile (TempHandle, &gST->ConsoleInHandle);
}
}
}
}
- FreePool(CommandLineCopy);
- CalculateEfiHdrCrc(&gST->Hdr);
+ FreePool (CommandLineCopy);
+
+ CalculateEfiHdrCrc (&gST->Hdr);
- if (gST->ConIn == NULL ||gST->ConOut == NULL) {
+ if ((gST->ConIn == NULL) || (gST->ConOut == NULL)) {
Status = EFI_OUT_OF_RESOURCES;
}
if (Status == EFI_NOT_FOUND) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_REDUNDA_REDIR), ShellInfoObject.HiiHandle);
- } else if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SHELL_INVALID_REDIR), ShellInfoObject.HiiHandle);
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SHELL_REDUNDA_REDIR), ShellInfoObject.HiiHandle);
+ } else if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SHELL_INVALID_REDIR), ShellInfoObject.HiiHandle);
}
return (Status);
@@ -1276,57 +1350,67 @@ RestoreStdInStdOutStdErr ( IN SYSTEM_TABLE_INFO *SystemTableInfo
)
{
- SPLIT_LIST *Split;
-
- if (ShellParameters == NULL
- ||OldStdIn == NULL
- ||OldStdOut == NULL
- ||OldStdErr == NULL
- ||SystemTableInfo == NULL) {
+ SPLIT_LIST *Split;
+
+ if ( (ShellParameters == NULL)
+ || (OldStdIn == NULL)
+ || (OldStdOut == NULL)
+ || (OldStdErr == NULL)
+ || (SystemTableInfo == NULL))
+ {
return (EFI_INVALID_PARAMETER);
}
- if (!IsListEmpty(&ShellInfoObject.SplitList.Link)) {
- Split = (SPLIT_LIST*)GetFirstNode(&ShellInfoObject.SplitList.Link);
+
+ if (!IsListEmpty (&ShellInfoObject.SplitList.Link)) {
+ Split = (SPLIT_LIST *)GetFirstNode (&ShellInfoObject.SplitList.Link);
} else {
Split = NULL;
}
+
if (ShellParameters->StdIn != *OldStdIn) {
- if ((Split != NULL && Split->SplitStdIn != ShellParameters->StdIn) || Split == NULL) {
- gEfiShellProtocol->CloseFile(ShellParameters->StdIn);
+ if (((Split != NULL) && (Split->SplitStdIn != ShellParameters->StdIn)) || (Split == NULL)) {
+ gEfiShellProtocol->CloseFile (ShellParameters->StdIn);
}
+
ShellParameters->StdIn = *OldStdIn;
}
+
if (ShellParameters->StdOut != *OldStdOut) {
- if ((Split != NULL && Split->SplitStdOut != ShellParameters->StdOut) || Split == NULL) {
- gEfiShellProtocol->CloseFile(ShellParameters->StdOut);
+ if (((Split != NULL) && (Split->SplitStdOut != ShellParameters->StdOut)) || (Split == NULL)) {
+ gEfiShellProtocol->CloseFile (ShellParameters->StdOut);
}
+
ShellParameters->StdOut = *OldStdOut;
}
+
if (ShellParameters->StdErr != *OldStdErr) {
- gEfiShellProtocol->CloseFile(ShellParameters->StdErr);
+ gEfiShellProtocol->CloseFile (ShellParameters->StdErr);
ShellParameters->StdErr = *OldStdErr;
}
if (gST->ConIn != SystemTableInfo->ConIn) {
- CloseSimpleTextInOnFile(gST->ConIn);
- gST->ConIn = SystemTableInfo->ConIn;
- gST->ConsoleInHandle = SystemTableInfo->ConInHandle;
+ CloseSimpleTextInOnFile (gST->ConIn);
+ gST->ConIn = SystemTableInfo->ConIn;
+ gST->ConsoleInHandle = SystemTableInfo->ConInHandle;
}
+
if (gST->ConOut != SystemTableInfo->ConOut) {
- CloseSimpleTextOutOnFile(gST->ConOut);
- gST->ConOut = SystemTableInfo->ConOut;
- gST->ConsoleOutHandle = SystemTableInfo->ConOutHandle;
+ CloseSimpleTextOutOnFile (gST->ConOut);
+ gST->ConOut = SystemTableInfo->ConOut;
+ gST->ConsoleOutHandle = SystemTableInfo->ConOutHandle;
}
+
if (gST->StdErr != SystemTableInfo->ErrOut) {
- CloseSimpleTextOutOnFile(gST->StdErr);
- gST->StdErr = SystemTableInfo->ErrOut;
- gST->StandardErrorHandle = SystemTableInfo->ErrOutHandle;
+ CloseSimpleTextOutOnFile (gST->StdErr);
+ gST->StdErr = SystemTableInfo->ErrOut;
+ gST->StandardErrorHandle = SystemTableInfo->ErrOutHandle;
}
- CalculateEfiHdrCrc(&gST->Hdr);
+ CalculateEfiHdrCrc (&gST->Hdr);
return (EFI_SUCCESS);
}
+
/**
Function will replace the current Argc and Argv in the ShellParameters protocol
structure by parsing NewCommandLine. The current values are returned to the
@@ -1346,7 +1430,7 @@ RestoreStdInStdOutStdErr ( @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
**/
EFI_STATUS
-UpdateArgcArgv(
+UpdateArgcArgv (
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
IN CONST CHAR16 *NewCommandLine,
IN SHELL_OPERATION_TYPES Type,
@@ -1354,14 +1438,15 @@ UpdateArgcArgv( OUT UINTN *OldArgc OPTIONAL
)
{
- BOOLEAN StripParamQuotation;
+ BOOLEAN StripParamQuotation;
- ASSERT(ShellParameters != NULL);
+ ASSERT (ShellParameters != NULL);
StripParamQuotation = TRUE;
if (OldArgc != NULL) {
*OldArgc = ShellParameters->Argc;
}
+
if (OldArgc != NULL) {
*OldArgv = ShellParameters->Argv;
}
@@ -1370,11 +1455,12 @@ UpdateArgcArgv( StripParamQuotation = FALSE;
}
- return ParseCommandLineToArgs( NewCommandLine,
- StripParamQuotation,
- &(ShellParameters->Argv),
- &(ShellParameters->Argc)
- );
+ return ParseCommandLineToArgs (
+ NewCommandLine,
+ StripParamQuotation,
+ &(ShellParameters->Argv),
+ &(ShellParameters->Argc)
+ );
}
/**
@@ -1387,28 +1473,32 @@ UpdateArgcArgv( @param[in] OldArgc pointer to old number of items in Argv list
**/
VOID
-RestoreArgcArgv(
+RestoreArgcArgv (
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
IN CHAR16 ***OldArgv,
IN UINTN *OldArgc
)
{
- UINTN LoopCounter;
- ASSERT(ShellParameters != NULL);
- ASSERT(OldArgv != NULL);
- ASSERT(OldArgc != NULL);
+ UINTN LoopCounter;
+
+ ASSERT (ShellParameters != NULL);
+ ASSERT (OldArgv != NULL);
+ ASSERT (OldArgc != NULL);
if (ShellParameters->Argv != NULL) {
for ( LoopCounter = 0
- ; LoopCounter < ShellParameters->Argc
- ; LoopCounter++
- ){
- FreePool(ShellParameters->Argv[LoopCounter]);
+ ; LoopCounter < ShellParameters->Argc
+ ; LoopCounter++
+ )
+ {
+ FreePool (ShellParameters->Argv[LoopCounter]);
}
- FreePool(ShellParameters->Argv);
+
+ FreePool (ShellParameters->Argv);
}
+
ShellParameters->Argv = *OldArgv;
- *OldArgv = NULL;
+ *OldArgv = NULL;
ShellParameters->Argc = *OldArgc;
- *OldArgc = 0;
+ *OldArgc = 0;
}
diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.h b/ShellPkg/Application/Shell/ShellParametersProtocol.h index c502506..2d12fa9 100644 --- a/ShellPkg/Application/Shell/ShellParametersProtocol.h +++ b/ShellPkg/Application/Shell/ShellParametersProtocol.h @@ -75,7 +75,7 @@ CleanUpShellParametersProtocol ( @retval EFI_OUT_OF_RESOURCES a memory allocation failed.
**/
EFI_STATUS
-UpdateArgcArgv(
+UpdateArgcArgv (
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
IN CONST CHAR16 *NewCommandLine,
IN SHELL_OPERATION_TYPES Type,
@@ -93,19 +93,19 @@ UpdateArgcArgv( @param[in] OldArgc pointer to old number of items in Argv list
**/
VOID
-RestoreArgcArgv(
+RestoreArgcArgv (
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
IN CHAR16 ***OldArgv,
IN UINTN *OldArgc
);
typedef struct {
- EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;
- EFI_HANDLE ConInHandle;
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;
- EFI_HANDLE ConOutHandle;
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ErrOut;
- EFI_HANDLE ErrOutHandle;
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;
+ EFI_HANDLE ConInHandle;
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;
+ EFI_HANDLE ConOutHandle;
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ErrOut;
+ EFI_HANDLE ErrOutHandle;
} SYSTEM_TABLE_INFO;
/**
@@ -126,7 +126,7 @@ typedef struct { @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
**/
EFI_STATUS
-UpdateStdInStdOutStdErr(
+UpdateStdInStdOutStdErr (
IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,
IN CHAR16 *NewCommandLine,
OUT SHELL_FILE_HANDLE *OldStdIn,
@@ -172,11 +172,11 @@ RestoreStdInStdOutStdErr ( @return EFI_OUT_OF_RESOURCES a memory allocation failed.
**/
EFI_STATUS
-ParseCommandLineToArgs(
- IN CONST CHAR16 *CommandLine,
- IN BOOLEAN StripQuotation,
- IN OUT CHAR16 ***Argv,
- IN OUT UINTN *Argc
+ParseCommandLineToArgs (
+ IN CONST CHAR16 *CommandLine,
+ IN BOOLEAN StripQuotation,
+ IN OUT CHAR16 ***Argv,
+ IN OUT UINTN *Argc
);
/**
@@ -200,7 +200,7 @@ ParseCommandLineToArgs( @return EFI_NOT_FOUND A closing " could not be found on the specified string
**/
EFI_STATUS
-GetNextParameter(
+GetNextParameter (
IN OUT CHAR16 **Walker,
IN OUT CHAR16 **TempParameter,
IN CONST UINTN Length,
@@ -208,4 +208,3 @@ GetNextParameter( );
#endif //_SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_
-
diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c index e79c390..509eb60 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.c +++ b/ShellPkg/Application/Shell/ShellProtocol.c @@ -27,11 +27,11 @@ EFI_STATUS
EFIAPI
EfiShellClose (
- IN SHELL_FILE_HANDLE FileHandle
+ IN SHELL_FILE_HANDLE FileHandle
)
{
- ShellFileHandleRemove(FileHandle);
- return (FileHandleClose(ConvertShellHandleToEfiFileProtocol(FileHandle)));
+ ShellFileHandleRemove (FileHandle);
+ return (FileHandleClose (ConvertShellHandleToEfiFileProtocol (FileHandle)));
}
/**
@@ -44,8 +44,8 @@ EfiShellClose ( @retval FALSE gEfiBlockIoProtocolGuid was not found.
**/
BOOLEAN
-InternalShellProtocolIsBlockIoPresent(
- IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
+InternalShellProtocolIsBlockIoPresent (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
EFI_DEVICE_PATH_PROTOCOL *DevicePathCopy;
@@ -54,12 +54,13 @@ InternalShellProtocolIsBlockIoPresent( Handle = NULL;
- DevicePathCopy = (EFI_DEVICE_PATH_PROTOCOL*)DevicePath;
- Status = gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid, &DevicePathCopy, &Handle);
+ DevicePathCopy = (EFI_DEVICE_PATH_PROTOCOL *)DevicePath;
+ Status = gBS->LocateDevicePath (&gEfiBlockIoProtocolGuid, &DevicePathCopy, &Handle);
- if ((Handle != NULL) && (!EFI_ERROR(Status))) {
+ if ((Handle != NULL) && (!EFI_ERROR (Status))) {
return (TRUE);
}
+
return (FALSE);
}
@@ -73,8 +74,8 @@ InternalShellProtocolIsBlockIoPresent( @retval FALSE gEfiSimpleFileSystemProtocolGuid was not found.
**/
BOOLEAN
-InternalShellProtocolIsSimpleFileSystemPresent(
- IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
+InternalShellProtocolIsSimpleFileSystemPresent (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
EFI_DEVICE_PATH_PROTOCOL *DevicePathCopy;
@@ -83,16 +84,16 @@ InternalShellProtocolIsSimpleFileSystemPresent( Handle = NULL;
- DevicePathCopy = (EFI_DEVICE_PATH_PROTOCOL*)DevicePath;
- Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid, &DevicePathCopy, &Handle);
+ DevicePathCopy = (EFI_DEVICE_PATH_PROTOCOL *)DevicePath;
+ Status = gBS->LocateDevicePath (&gEfiSimpleFileSystemProtocolGuid, &DevicePathCopy, &Handle);
- if ((Handle != NULL) && (!EFI_ERROR(Status))) {
+ if ((Handle != NULL) && (!EFI_ERROR (Status))) {
return (TRUE);
}
+
return (FALSE);
}
-
/**
This function creates a mapping for a device path.
@@ -114,19 +115,19 @@ InternalShellProtocolIsSimpleFileSystemPresent( **/
EFI_STATUS
EFIAPI
-EfiShellSetMap(
- IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL,
- IN CONST CHAR16 *Mapping
+EfiShellSetMap (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL,
+ IN CONST CHAR16 *Mapping
)
{
EFI_STATUS Status;
SHELL_MAP_LIST *MapListNode;
- if (Mapping == NULL){
+ if (Mapping == NULL) {
return (EFI_INVALID_PARAMETER);
}
- if (Mapping[StrLen(Mapping)-1] != ':') {
+ if (Mapping[StrLen (Mapping)-1] != ':') {
return (EFI_INVALID_PARAMETER);
}
@@ -134,21 +135,23 @@ EfiShellSetMap( // Delete the mapping
//
if (DevicePath == NULL) {
- if (IsListEmpty(&gShellMapList.Link)) {
+ if (IsListEmpty (&gShellMapList.Link)) {
return (EFI_NOT_FOUND);
}
- for ( MapListNode = (SHELL_MAP_LIST *)GetFirstNode(&gShellMapList.Link)
- ; !IsNull(&gShellMapList.Link, &MapListNode->Link)
- ; MapListNode = (SHELL_MAP_LIST *)GetNextNode(&gShellMapList.Link, &MapListNode->Link)
- ){
- if (StringNoCaseCompare(&MapListNode->MapName, &Mapping) == 0) {
- RemoveEntryList(&MapListNode->Link);
- SHELL_FREE_NON_NULL(MapListNode->DevicePath);
- SHELL_FREE_NON_NULL(MapListNode->MapName);
- SHELL_FREE_NON_NULL(MapListNode->CurrentDirectoryPath);
- FreePool(MapListNode);
- return (EFI_SUCCESS);
- }
+
+ for ( MapListNode = (SHELL_MAP_LIST *)GetFirstNode (&gShellMapList.Link)
+ ; !IsNull (&gShellMapList.Link, &MapListNode->Link)
+ ; MapListNode = (SHELL_MAP_LIST *)GetNextNode (&gShellMapList.Link, &MapListNode->Link)
+ )
+ {
+ if (StringNoCaseCompare (&MapListNode->MapName, &Mapping) == 0) {
+ RemoveEntryList (&MapListNode->Link);
+ SHELL_FREE_NON_NULL (MapListNode->DevicePath);
+ SHELL_FREE_NON_NULL (MapListNode->MapName);
+ SHELL_FREE_NON_NULL (MapListNode->CurrentDirectoryPath);
+ FreePool (MapListNode);
+ return (EFI_SUCCESS);
+ }
} // for loop
//
@@ -160,16 +163,17 @@ EfiShellSetMap( //
// make sure this is a valid to add device path
//
- ///@todo add BlockIo to this test...
- if (!InternalShellProtocolIsSimpleFileSystemPresent(DevicePath)
- && !InternalShellProtocolIsBlockIoPresent(DevicePath)) {
+ /// @todo add BlockIo to this test...
+ if ( !InternalShellProtocolIsSimpleFileSystemPresent (DevicePath)
+ && !InternalShellProtocolIsBlockIoPresent (DevicePath))
+ {
return (EFI_INVALID_PARAMETER);
}
//
// First make sure there is no old mapping
//
- Status = EfiShellSetMap(NULL, Mapping);
+ Status = EfiShellSetMap (NULL, Mapping);
if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_FOUND)) {
return (Status);
}
@@ -177,9 +181,9 @@ EfiShellSetMap( //
// now add the new one.
//
- Status = ShellCommandAddMapItemAndUpdatePath(Mapping, DevicePath, 0, FALSE);
+ Status = ShellCommandAddMapItemAndUpdatePath (Mapping, DevicePath, 0, FALSE);
- return(Status);
+ return (Status);
}
/**
@@ -197,8 +201,8 @@ EfiShellSetMap( **/
CONST EFI_DEVICE_PATH_PROTOCOL *
EFIAPI
-EfiShellGetDevicePathFromMap(
- IN CONST CHAR16 *Mapping
+EfiShellGetDevicePathFromMap (
+ IN CONST CHAR16 *Mapping
)
{
SHELL_MAP_LIST *MapListItem;
@@ -208,19 +212,20 @@ EfiShellGetDevicePathFromMap( NewName = NULL;
Size = 0;
- StrnCatGrow(&NewName, &Size, Mapping, 0);
- if (Mapping[StrLen(Mapping)-1] != L':') {
- StrnCatGrow(&NewName, &Size, L":", 0);
+ StrnCatGrow (&NewName, &Size, Mapping, 0);
+ if (Mapping[StrLen (Mapping)-1] != L':') {
+ StrnCatGrow (&NewName, &Size, L":", 0);
}
- MapListItem = ShellCommandFindMapItem(NewName);
+ MapListItem = ShellCommandFindMapItem (NewName);
- FreePool(NewName);
+ FreePool (NewName);
if (MapListItem != NULL) {
return (MapListItem->DevicePath);
}
- return(NULL);
+
+ return (NULL);
}
/**
@@ -245,103 +250,109 @@ EfiShellGetDevicePathFromMap( **/
CONST CHAR16 *
EFIAPI
-EfiShellGetMapFromDevicePath(
- IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
+EfiShellGetMapFromDevicePath (
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
)
{
- SHELL_MAP_LIST *Node;
- CHAR16 *PathForReturn;
- UINTN PathSize;
-// EFI_HANDLE PathHandle;
-// EFI_HANDLE MapHandle;
-// EFI_STATUS Status;
-// EFI_DEVICE_PATH_PROTOCOL *DevicePathCopy;
-// EFI_DEVICE_PATH_PROTOCOL *MapPathCopy;
-
- if (DevicePath == NULL || *DevicePath == NULL) {
+ SHELL_MAP_LIST *Node;
+ CHAR16 *PathForReturn;
+ UINTN PathSize;
+
+ // EFI_HANDLE PathHandle;
+ // EFI_HANDLE MapHandle;
+ // EFI_STATUS Status;
+ // EFI_DEVICE_PATH_PROTOCOL *DevicePathCopy;
+ // EFI_DEVICE_PATH_PROTOCOL *MapPathCopy;
+
+ if ((DevicePath == NULL) || (*DevicePath == NULL)) {
return (NULL);
}
PathForReturn = NULL;
PathSize = 0;
- for ( Node = (SHELL_MAP_LIST *)GetFirstNode(&gShellMapList.Link)
- ; !IsNull(&gShellMapList.Link, &Node->Link)
- ; Node = (SHELL_MAP_LIST *)GetNextNode(&gShellMapList.Link, &Node->Link)
- ){
+ for ( Node = (SHELL_MAP_LIST *)GetFirstNode (&gShellMapList.Link)
+ ; !IsNull (&gShellMapList.Link, &Node->Link)
+ ; Node = (SHELL_MAP_LIST *)GetNextNode (&gShellMapList.Link, &Node->Link)
+ )
+ {
//
// check for exact match
//
- if (DevicePathCompare(DevicePath, &Node->DevicePath) == 0) {
- ASSERT((PathForReturn == NULL && PathSize == 0) || (PathForReturn != NULL));
+ if (DevicePathCompare (DevicePath, &Node->DevicePath) == 0) {
+ ASSERT ((PathForReturn == NULL && PathSize == 0) || (PathForReturn != NULL));
if (PathSize != 0) {
- PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, L";", 0);
+ PathForReturn = StrnCatGrow (&PathForReturn, &PathSize, L";", 0);
}
- PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, Node->MapName, 0);
+
+ PathForReturn = StrnCatGrow (&PathForReturn, &PathSize, Node->MapName, 0);
}
}
+
if (PathForReturn != NULL) {
while (!IsDevicePathEndType (*DevicePath)) {
*DevicePath = NextDevicePathNode (*DevicePath);
}
+
SetDevicePathEndNode (*DevicePath);
}
-/*
- ///@todo finish code for inexact matches.
- if (PathForReturn == NULL) {
- PathSize = 0;
- DevicePathCopy = DuplicateDevicePath(*DevicePath);
- ASSERT(DevicePathCopy != NULL);
- Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid, &DevicePathCopy, &PathHandle);
- ASSERT_EFI_ERROR(Status);
- //
- // check each of the device paths we have to get the root of the path for consist mappings
- //
- for ( Node = (SHELL_MAP_LIST *)GetFirstNode(&gShellMapList.Link)
- ; !IsNull(&gShellMapList.Link, &Node->Link)
- ; Node = (SHELL_MAP_LIST *)GetNextNode(&gShellMapList.Link, &Node->Link)
- ){
- if ((Node->Flags & SHELL_MAP_FLAGS_CONSIST) == 0) {
- continue;
- }
- MapPathCopy = DuplicateDevicePath(Node->DevicePath);
- ASSERT(MapPathCopy != NULL);
- Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid, &MapPathCopy, &MapHandle);
- if (MapHandle == PathHandle) {
+ /*
+ ///@todo finish code for inexact matches.
+ if (PathForReturn == NULL) {
+ PathSize = 0;
+
+ DevicePathCopy = DuplicateDevicePath(*DevicePath);
+ ASSERT(DevicePathCopy != NULL);
+ Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid, &DevicePathCopy, &PathHandle);
+ ASSERT_EFI_ERROR(Status);
+ //
+ // check each of the device paths we have to get the root of the path for consist mappings
+ //
+ for ( Node = (SHELL_MAP_LIST *)GetFirstNode(&gShellMapList.Link)
+ ; !IsNull(&gShellMapList.Link, &Node->Link)
+ ; Node = (SHELL_MAP_LIST *)GetNextNode(&gShellMapList.Link, &Node->Link)
+ ){
+ if ((Node->Flags & SHELL_MAP_FLAGS_CONSIST) == 0) {
+ continue;
+ }
+ MapPathCopy = DuplicateDevicePath(Node->DevicePath);
+ ASSERT(MapPathCopy != NULL);
+ Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid, &MapPathCopy, &MapHandle);
+ if (MapHandle == PathHandle) {
- *DevicePath = DevicePathCopy;
+ *DevicePath = DevicePathCopy;
- MapPathCopy = NULL;
- DevicePathCopy = NULL;
- PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, Node->MapName, 0);
- PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, L";", 0);
- break;
- }
- }
- //
- // now add on the non-consistent mappings
- //
- for ( Node = (SHELL_MAP_LIST *)GetFirstNode(&gShellMapList.Link)
- ; !IsNull(&gShellMapList.Link, &Node->Link)
- ; Node = (SHELL_MAP_LIST *)GetNextNode(&gShellMapList.Link, &Node->Link)
- ){
- if ((Node->Flags & SHELL_MAP_FLAGS_CONSIST) != 0) {
- continue;
+ MapPathCopy = NULL;
+ DevicePathCopy = NULL;
+ PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, Node->MapName, 0);
+ PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, L";", 0);
+ break;
+ }
}
- MapPathCopy = Node->DevicePath;
- ASSERT(MapPathCopy != NULL);
- Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid, &MapPathCopy, &MapHandle);
- if (MapHandle == PathHandle) {
- PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, Node->MapName, 0);
- PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, L";", 0);
- break;
+ //
+ // now add on the non-consistent mappings
+ //
+ for ( Node = (SHELL_MAP_LIST *)GetFirstNode(&gShellMapList.Link)
+ ; !IsNull(&gShellMapList.Link, &Node->Link)
+ ; Node = (SHELL_MAP_LIST *)GetNextNode(&gShellMapList.Link, &Node->Link)
+ ){
+ if ((Node->Flags & SHELL_MAP_FLAGS_CONSIST) != 0) {
+ continue;
+ }
+ MapPathCopy = Node->DevicePath;
+ ASSERT(MapPathCopy != NULL);
+ Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid, &MapPathCopy, &MapHandle);
+ if (MapHandle == PathHandle) {
+ PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, Node->MapName, 0);
+ PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, L";", 0);
+ break;
+ }
}
}
- }
-*/
+ */
- return (AddBufferToFreeList(PathForReturn));
+ return (AddBufferToFreeList (PathForReturn));
}
/**
@@ -359,71 +370,76 @@ EfiShellGetMapFromDevicePath( **/
CHAR16 *
EFIAPI
-EfiShellGetFilePathFromDevicePath(
- IN CONST EFI_DEVICE_PATH_PROTOCOL *Path
+EfiShellGetFilePathFromDevicePath (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *Path
)
{
EFI_DEVICE_PATH_PROTOCOL *DevicePathCopy;
- EFI_DEVICE_PATH_PROTOCOL *MapPathCopy;
- SHELL_MAP_LIST *MapListItem;
- CHAR16 *PathForReturn;
- UINTN PathSize;
- EFI_HANDLE PathHandle;
- EFI_HANDLE MapHandle;
- EFI_STATUS Status;
- FILEPATH_DEVICE_PATH *FilePath;
- FILEPATH_DEVICE_PATH *AlignedNode;
+ EFI_DEVICE_PATH_PROTOCOL *MapPathCopy;
+ SHELL_MAP_LIST *MapListItem;
+ CHAR16 *PathForReturn;
+ UINTN PathSize;
+ EFI_HANDLE PathHandle;
+ EFI_HANDLE MapHandle;
+ EFI_STATUS Status;
+ FILEPATH_DEVICE_PATH *FilePath;
+ FILEPATH_DEVICE_PATH *AlignedNode;
PathForReturn = NULL;
- PathSize = 0;
+ PathSize = 0;
- DevicePathCopy = (EFI_DEVICE_PATH_PROTOCOL*)Path;
- ASSERT(DevicePathCopy != NULL);
+ DevicePathCopy = (EFI_DEVICE_PATH_PROTOCOL *)Path;
+ ASSERT (DevicePathCopy != NULL);
if (DevicePathCopy == NULL) {
return (NULL);
}
- ///@todo BlockIo?
- Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid, &DevicePathCopy, &PathHandle);
- if (EFI_ERROR(Status)) {
+ /// @todo BlockIo?
+ Status = gBS->LocateDevicePath (&gEfiSimpleFileSystemProtocolGuid, &DevicePathCopy, &PathHandle);
+
+ if (EFI_ERROR (Status)) {
return (NULL);
}
+
//
// check each of the device paths we have to get the root of the path
//
- for ( MapListItem = (SHELL_MAP_LIST *)GetFirstNode(&gShellMapList.Link)
- ; !IsNull(&gShellMapList.Link, &MapListItem->Link)
- ; MapListItem = (SHELL_MAP_LIST *)GetNextNode(&gShellMapList.Link, &MapListItem->Link)
- ){
- MapPathCopy = (EFI_DEVICE_PATH_PROTOCOL*)MapListItem->DevicePath;
- ASSERT(MapPathCopy != NULL);
- ///@todo BlockIo?
- Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid, &MapPathCopy, &MapHandle);
+ for ( MapListItem = (SHELL_MAP_LIST *)GetFirstNode (&gShellMapList.Link)
+ ; !IsNull (&gShellMapList.Link, &MapListItem->Link)
+ ; MapListItem = (SHELL_MAP_LIST *)GetNextNode (&gShellMapList.Link, &MapListItem->Link)
+ )
+ {
+ MapPathCopy = (EFI_DEVICE_PATH_PROTOCOL *)MapListItem->DevicePath;
+ ASSERT (MapPathCopy != NULL);
+ /// @todo BlockIo?
+ Status = gBS->LocateDevicePath (&gEfiSimpleFileSystemProtocolGuid, &MapPathCopy, &MapHandle);
if (MapHandle == PathHandle) {
- ASSERT((PathForReturn == NULL && PathSize == 0) || (PathForReturn != NULL));
- PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, MapListItem->MapName, 0);
+ ASSERT ((PathForReturn == NULL && PathSize == 0) || (PathForReturn != NULL));
+ PathForReturn = StrnCatGrow (&PathForReturn, &PathSize, MapListItem->MapName, 0);
//
// go through all the remaining nodes in the device path
//
- for ( FilePath = (FILEPATH_DEVICE_PATH*)DevicePathCopy
- ; !IsDevicePathEnd (&FilePath->Header)
- ; FilePath = (FILEPATH_DEVICE_PATH*)NextDevicePathNode (&FilePath->Header)
- ){
+ for ( FilePath = (FILEPATH_DEVICE_PATH *)DevicePathCopy
+ ; !IsDevicePathEnd (&FilePath->Header)
+ ; FilePath = (FILEPATH_DEVICE_PATH *)NextDevicePathNode (&FilePath->Header)
+ )
+ {
//
// If any node is not a file path node, then the conversion can not be completed
//
- if ((DevicePathType(&FilePath->Header) != MEDIA_DEVICE_PATH) ||
- (DevicePathSubType(&FilePath->Header) != MEDIA_FILEPATH_DP)) {
- FreePool(PathForReturn);
+ if ((DevicePathType (&FilePath->Header) != MEDIA_DEVICE_PATH) ||
+ (DevicePathSubType (&FilePath->Header) != MEDIA_FILEPATH_DP))
+ {
+ FreePool (PathForReturn);
return NULL;
}
//
// append the path part onto the filepath.
//
- ASSERT((PathForReturn == NULL && PathSize == 0) || (PathForReturn != NULL));
+ ASSERT ((PathForReturn == NULL && PathSize == 0) || (PathForReturn != NULL));
- AlignedNode = AllocateCopyPool (DevicePathNodeLength(FilePath), FilePath);
+ AlignedNode = AllocateCopyPool (DevicePathNodeLength (FilePath), FilePath);
if (AlignedNode == NULL) {
FreePool (PathForReturn);
return NULL;
@@ -438,19 +454,22 @@ EfiShellGetFilePathFromDevicePath( if ((PathSize != 0) &&
(PathForReturn != NULL) &&
(PathForReturn[PathSize / sizeof (CHAR16) - 1] != L'\\') &&
- (AlignedNode->PathName[0] != L'\\')) {
+ (AlignedNode->PathName[0] != L'\\'))
+ {
PathForReturn = StrnCatGrow (&PathForReturn, &PathSize, L"\\", 1);
}
- PathForReturn = StrnCatGrow(&PathForReturn, &PathSize, AlignedNode->PathName, 0);
- FreePool(AlignedNode);
+ PathForReturn = StrnCatGrow (&PathForReturn, &PathSize, AlignedNode->PathName, 0);
+ FreePool (AlignedNode);
} // for loop of remaining nodes
}
+
if (PathForReturn != NULL) {
break;
}
} // for loop of paths to check
- return(PathForReturn);
+
+ return (PathForReturn);
}
/**
@@ -468,8 +487,8 @@ EfiShellGetFilePathFromDevicePath( **/
EFI_DEVICE_PATH_PROTOCOL *
EFIAPI
-EfiShellGetDevicePathFromFilePath(
- IN CONST CHAR16 *Path
+EfiShellGetDevicePathFromFilePath (
+ IN CONST CHAR16 *Path
)
{
CHAR16 *MapName;
@@ -490,25 +509,29 @@ EfiShellGetDevicePathFromFilePath( MapName = NULL;
NewPath = NULL;
- if (StrStr(Path, L":") == NULL) {
- Cwd = EfiShellGetCurDir(NULL);
+ if (StrStr (Path, L":") == NULL) {
+ Cwd = EfiShellGetCurDir (NULL);
if (Cwd == NULL) {
return (NULL);
}
- Size = StrSize(Cwd) + StrSize(Path);
- NewPath = AllocateZeroPool(Size);
+
+ Size = StrSize (Cwd) + StrSize (Path);
+ NewPath = AllocateZeroPool (Size);
if (NewPath == NULL) {
return (NULL);
}
- StrCpyS(NewPath, Size/sizeof(CHAR16), Cwd);
- StrCatS(NewPath, Size/sizeof(CHAR16), L"\\");
+
+ StrCpyS (NewPath, Size/sizeof (CHAR16), Cwd);
+ StrCatS (NewPath, Size/sizeof (CHAR16), L"\\");
if (*Path == L'\\') {
Path++;
- while (PathRemoveLastItem(NewPath)) ;
+ while (PathRemoveLastItem (NewPath)) {
+ }
}
- StrCatS(NewPath, Size/sizeof(CHAR16), Path);
- DevicePathForReturn = EfiShellGetDevicePathFromFilePath(NewPath);
- FreePool(NewPath);
+
+ StrCatS (NewPath, Size/sizeof (CHAR16), Path);
+ DevicePathForReturn = EfiShellGetDevicePathFromFilePath (NewPath);
+ FreePool (NewPath);
return (DevicePathForReturn);
}
@@ -516,16 +539,16 @@ EfiShellGetDevicePathFromFilePath( //
// find the part before (but including) the : for the map name
//
- ASSERT((MapName == NULL && Size == 0) || (MapName != NULL));
- MapName = StrnCatGrow(&MapName, &Size, Path, (StrStr(Path, L":")-Path+1));
- if (MapName == NULL || MapName[StrLen(MapName)-1] != L':') {
+ ASSERT ((MapName == NULL && Size == 0) || (MapName != NULL));
+ MapName = StrnCatGrow (&MapName, &Size, Path, (StrStr (Path, L":")-Path+1));
+ if ((MapName == NULL) || (MapName[StrLen (MapName)-1] != L':')) {
return (NULL);
}
//
// look up the device path in the map
//
- DevicePath = EfiShellGetDevicePathFromMap(MapName);
+ DevicePath = EfiShellGetDevicePathFromMap (MapName);
if (DevicePath == NULL) {
//
// Must have been a bad Mapname
@@ -536,38 +559,40 @@ EfiShellGetDevicePathFromFilePath( //
// make a copy for LocateDevicePath to modify (also save a pointer to call FreePool with)
//
- DevicePathCopyForFree = DevicePathCopy = DuplicateDevicePath(DevicePath);
+ DevicePathCopyForFree = DevicePathCopy = DuplicateDevicePath (DevicePath);
if (DevicePathCopy == NULL) {
- FreePool(MapName);
+ FreePool (MapName);
return (NULL);
}
//
// get the handle
//
- ///@todo BlockIo?
- Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid, &DevicePathCopy, &Handle);
- if (EFI_ERROR(Status)) {
+ /// @todo BlockIo?
+ Status = gBS->LocateDevicePath (&gEfiSimpleFileSystemProtocolGuid, &DevicePathCopy, &Handle);
+ if (EFI_ERROR (Status)) {
if (DevicePathCopyForFree != NULL) {
- FreePool(DevicePathCopyForFree);
+ FreePool (DevicePathCopyForFree);
}
- FreePool(MapName);
+
+ FreePool (MapName);
return (NULL);
}
//
// build the full device path
//
- if ((*(Path+StrLen(MapName)) != CHAR_NULL) &&
- (*(Path+StrLen(MapName)+1) == CHAR_NULL)) {
- DevicePathForReturn = FileDevicePath(Handle, L"\\");
+ if ((*(Path+StrLen (MapName)) != CHAR_NULL) &&
+ (*(Path+StrLen (MapName)+1) == CHAR_NULL))
+ {
+ DevicePathForReturn = FileDevicePath (Handle, L"\\");
} else {
- DevicePathForReturn = FileDevicePath(Handle, Path+StrLen(MapName));
+ DevicePathForReturn = FileDevicePath (Handle, Path+StrLen (MapName));
}
- FreePool(MapName);
+ FreePool (MapName);
if (DevicePathCopyForFree != NULL) {
- FreePool(DevicePathCopyForFree);
+ FreePool (DevicePathCopyForFree);
}
return (DevicePathForReturn);
@@ -611,29 +636,30 @@ EfiShellGetDevicePathFromFilePath( **/
EFI_STATUS
EFIAPI
-EfiShellGetDeviceName(
- IN EFI_HANDLE DeviceHandle,
- IN EFI_SHELL_DEVICE_NAME_FLAGS Flags,
- IN CHAR8 *Language,
- OUT CHAR16 **BestDeviceName
+EfiShellGetDeviceName (
+ IN EFI_HANDLE DeviceHandle,
+ IN EFI_SHELL_DEVICE_NAME_FLAGS Flags,
+ IN CHAR8 *Language,
+ OUT CHAR16 **BestDeviceName
)
{
- EFI_STATUS Status;
- EFI_COMPONENT_NAME2_PROTOCOL *CompName2;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_HANDLE *HandleList;
- UINTN HandleCount;
- UINTN LoopVar;
- CHAR16 *DeviceNameToReturn;
- CHAR8 *Lang;
- UINTN ParentControllerCount;
- EFI_HANDLE *ParentControllerBuffer;
- UINTN ParentDriverCount;
- EFI_HANDLE *ParentDriverBuffer;
-
- if (BestDeviceName == NULL ||
- DeviceHandle == NULL
- ){
+ EFI_STATUS Status;
+ EFI_COMPONENT_NAME2_PROTOCOL *CompName2;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_HANDLE *HandleList;
+ UINTN HandleCount;
+ UINTN LoopVar;
+ CHAR16 *DeviceNameToReturn;
+ CHAR8 *Lang;
+ UINTN ParentControllerCount;
+ EFI_HANDLE *ParentControllerBuffer;
+ UINTN ParentDriverCount;
+ EFI_HANDLE *ParentDriverBuffer;
+
+ if ((BestDeviceName == NULL) ||
+ (DeviceHandle == NULL)
+ )
+ {
return (EFI_INVALID_PARAMETER);
}
@@ -641,133 +667,145 @@ EfiShellGetDeviceName( // make sure one of the 2 supported bits is on
//
if (((Flags & EFI_DEVICE_NAME_USE_COMPONENT_NAME) == 0) &&
- ((Flags & EFI_DEVICE_NAME_USE_DEVICE_PATH) == 0)) {
+ ((Flags & EFI_DEVICE_NAME_USE_DEVICE_PATH) == 0))
+ {
return (EFI_INVALID_PARAMETER);
}
- DeviceNameToReturn = NULL;
- *BestDeviceName = NULL;
- HandleList = NULL;
- HandleCount = 0;
- Lang = NULL;
+ DeviceNameToReturn = NULL;
+ *BestDeviceName = NULL;
+ HandleList = NULL;
+ HandleCount = 0;
+ Lang = NULL;
if ((Flags & EFI_DEVICE_NAME_USE_COMPONENT_NAME) != 0) {
- Status = ParseHandleDatabaseByRelationship(
- NULL,
- DeviceHandle,
- HR_DRIVER_BINDING_HANDLE|HR_DEVICE_DRIVER,
- &HandleCount,
- &HandleList);
- for (LoopVar = 0; LoopVar < HandleCount ; LoopVar++){
+ Status = ParseHandleDatabaseByRelationship (
+ NULL,
+ DeviceHandle,
+ HR_DRIVER_BINDING_HANDLE|HR_DEVICE_DRIVER,
+ &HandleCount,
+ &HandleList
+ );
+ for (LoopVar = 0; LoopVar < HandleCount; LoopVar++) {
//
// Go through those handles until we get one that passes for GetComponentName
//
- Status = gBS->OpenProtocol(
- HandleList[LoopVar],
- &gEfiComponentName2ProtocolGuid,
- (VOID**)&CompName2,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (EFI_ERROR(Status)) {
- Status = gBS->OpenProtocol(
- HandleList[LoopVar],
- &gEfiComponentNameProtocolGuid,
- (VOID**)&CompName2,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ Status = gBS->OpenProtocol (
+ HandleList[LoopVar],
+ &gEfiComponentName2ProtocolGuid,
+ (VOID **)&CompName2,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
+ Status = gBS->OpenProtocol (
+ HandleList[LoopVar],
+ &gEfiComponentNameProtocolGuid,
+ (VOID **)&CompName2,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
}
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
continue;
}
- Lang = GetBestLanguageForDriver(CompName2->SupportedLanguages, Language, FALSE);
- Status = CompName2->GetControllerName(CompName2, DeviceHandle, NULL, Lang, &DeviceNameToReturn);
- FreePool(Lang);
+
+ Lang = GetBestLanguageForDriver (CompName2->SupportedLanguages, Language, FALSE);
+ Status = CompName2->GetControllerName (CompName2, DeviceHandle, NULL, Lang, &DeviceNameToReturn);
+ FreePool (Lang);
Lang = NULL;
- if (!EFI_ERROR(Status) && DeviceNameToReturn != NULL) {
+ if (!EFI_ERROR (Status) && (DeviceNameToReturn != NULL)) {
break;
}
}
+
if (HandleList != NULL) {
- FreePool(HandleList);
+ FreePool (HandleList);
}
//
// Now check the parent controller using this as the child.
//
- if (DeviceNameToReturn == NULL){
- PARSE_HANDLE_DATABASE_PARENTS(DeviceHandle, &ParentControllerCount, &ParentControllerBuffer);
- for (LoopVar = 0 ; LoopVar < ParentControllerCount ; LoopVar++) {
- PARSE_HANDLE_DATABASE_UEFI_DRIVERS(ParentControllerBuffer[LoopVar], &ParentDriverCount, &ParentDriverBuffer);
- for (HandleCount = 0 ; HandleCount < ParentDriverCount ; HandleCount++) {
+ if (DeviceNameToReturn == NULL) {
+ PARSE_HANDLE_DATABASE_PARENTS (DeviceHandle, &ParentControllerCount, &ParentControllerBuffer);
+ for (LoopVar = 0; LoopVar < ParentControllerCount; LoopVar++) {
+ PARSE_HANDLE_DATABASE_UEFI_DRIVERS (ParentControllerBuffer[LoopVar], &ParentDriverCount, &ParentDriverBuffer);
+ for (HandleCount = 0; HandleCount < ParentDriverCount; HandleCount++) {
//
// try using that driver's component name with controller and our driver as the child.
//
- Status = gBS->OpenProtocol(
- ParentDriverBuffer[HandleCount],
- &gEfiComponentName2ProtocolGuid,
- (VOID**)&CompName2,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (EFI_ERROR(Status)) {
- Status = gBS->OpenProtocol(
- ParentDriverBuffer[HandleCount],
- &gEfiComponentNameProtocolGuid,
- (VOID**)&CompName2,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ Status = gBS->OpenProtocol (
+ ParentDriverBuffer[HandleCount],
+ &gEfiComponentName2ProtocolGuid,
+ (VOID **)&CompName2,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
+ Status = gBS->OpenProtocol (
+ ParentDriverBuffer[HandleCount],
+ &gEfiComponentNameProtocolGuid,
+ (VOID **)&CompName2,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
}
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
continue;
}
- Lang = GetBestLanguageForDriver(CompName2->SupportedLanguages, Language, FALSE);
- Status = CompName2->GetControllerName(CompName2, ParentControllerBuffer[LoopVar], DeviceHandle, Lang, &DeviceNameToReturn);
- FreePool(Lang);
+
+ Lang = GetBestLanguageForDriver (CompName2->SupportedLanguages, Language, FALSE);
+ Status = CompName2->GetControllerName (CompName2, ParentControllerBuffer[LoopVar], DeviceHandle, Lang, &DeviceNameToReturn);
+ FreePool (Lang);
Lang = NULL;
- if (!EFI_ERROR(Status) && DeviceNameToReturn != NULL) {
+ if (!EFI_ERROR (Status) && (DeviceNameToReturn != NULL)) {
break;
}
-
-
-
}
- SHELL_FREE_NON_NULL(ParentDriverBuffer);
- if (!EFI_ERROR(Status) && DeviceNameToReturn != NULL) {
+
+ SHELL_FREE_NON_NULL (ParentDriverBuffer);
+ if (!EFI_ERROR (Status) && (DeviceNameToReturn != NULL)) {
break;
}
}
- SHELL_FREE_NON_NULL(ParentControllerBuffer);
+
+ SHELL_FREE_NON_NULL (ParentControllerBuffer);
}
+
//
// dont return on fail since we will try device path if that bit is on
//
- if (DeviceNameToReturn != NULL){
- ASSERT(BestDeviceName != NULL);
- StrnCatGrow(BestDeviceName, NULL, DeviceNameToReturn, 0);
+ if (DeviceNameToReturn != NULL) {
+ ASSERT (BestDeviceName != NULL);
+ StrnCatGrow (BestDeviceName, NULL, DeviceNameToReturn, 0);
return (EFI_SUCCESS);
}
}
+
if ((Flags & EFI_DEVICE_NAME_USE_DEVICE_PATH) != 0) {
- Status = gBS->OpenProtocol(
- DeviceHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID**)&DevicePath,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (!EFI_ERROR(Status)) {
+ Status = gBS->OpenProtocol (
+ DeviceHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **)&DevicePath,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (!EFI_ERROR (Status)) {
//
// use device path to text on the device path
//
- *BestDeviceName = ConvertDevicePathToText(DevicePath, TRUE, TRUE);
+ *BestDeviceName = ConvertDevicePathToText (DevicePath, TRUE, TRUE);
return (EFI_SUCCESS);
}
}
+
//
// none of the selected bits worked.
//
@@ -792,47 +830,52 @@ EfiShellGetDeviceName( **/
EFI_STATUS
EFIAPI
-EfiShellOpenRootByHandle(
- IN EFI_HANDLE DeviceHandle,
- OUT SHELL_FILE_HANDLE *FileHandle
+EfiShellOpenRootByHandle (
+ IN EFI_HANDLE DeviceHandle,
+ OUT SHELL_FILE_HANDLE *FileHandle
)
{
- EFI_STATUS Status;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
- EFI_FILE_PROTOCOL *RealFileHandle;
- EFI_DEVICE_PATH_PROTOCOL *DevPath;
+ EFI_STATUS Status;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
+ EFI_FILE_PROTOCOL *RealFileHandle;
+ EFI_DEVICE_PATH_PROTOCOL *DevPath;
//
// get the simple file system interface
//
- Status = gBS->OpenProtocol(DeviceHandle,
- &gEfiSimpleFileSystemProtocolGuid,
- (VOID**)&SimpleFileSystem,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (EFI_ERROR(Status)) {
+ Status = gBS->OpenProtocol (
+ DeviceHandle,
+ &gEfiSimpleFileSystemProtocolGuid,
+ (VOID **)&SimpleFileSystem,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
return (EFI_NOT_FOUND);
}
- Status = gBS->OpenProtocol(DeviceHandle,
- &gEfiDevicePathProtocolGuid,
- (VOID**)&DevPath,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (EFI_ERROR(Status)) {
+ Status = gBS->OpenProtocol (
+ DeviceHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID **)&DevPath,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
return (EFI_NOT_FOUND);
}
+
//
// Open the root volume now...
//
- Status = SimpleFileSystem->OpenVolume(SimpleFileSystem, &RealFileHandle);
- if (EFI_ERROR(Status)) {
+ Status = SimpleFileSystem->OpenVolume (SimpleFileSystem, &RealFileHandle);
+ if (EFI_ERROR (Status)) {
return Status;
}
- *FileHandle = ConvertEfiFileProtocolToShellHandle(RealFileHandle, EfiShellGetMapFromDevicePath(&DevPath));
+ *FileHandle = ConvertEfiFileProtocolToShellHandle (RealFileHandle, EfiShellGetMapFromDevicePath (&DevPath));
return (EFI_SUCCESS);
}
@@ -855,13 +898,13 @@ EfiShellOpenRootByHandle( **/
EFI_STATUS
EFIAPI
-EfiShellOpenRoot(
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- OUT SHELL_FILE_HANDLE *FileHandle
+EfiShellOpenRoot (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ OUT SHELL_FILE_HANDLE *FileHandle
)
{
- EFI_STATUS Status;
- EFI_HANDLE Handle;
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
if (FileHandle == NULL) {
return (EFI_INVALID_PARAMETER);
@@ -870,15 +913,17 @@ EfiShellOpenRoot( //
// find the handle of the device with that device handle and the file system
//
- ///@todo BlockIo?
- Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid,
- &DevicePath,
- &Handle);
- if (EFI_ERROR(Status)) {
+ /// @todo BlockIo?
+ Status = gBS->LocateDevicePath (
+ &gEfiSimpleFileSystemProtocolGuid,
+ &DevicePath,
+ &Handle
+ );
+ if (EFI_ERROR (Status)) {
return (EFI_NOT_FOUND);
}
- return (EfiShellOpenRootByHandle(Handle, FileHandle));
+ return (EfiShellOpenRootByHandle (Handle, FileHandle));
}
/**
@@ -894,9 +939,10 @@ EfiShellBatchIsActive ( VOID
)
{
- if (ShellCommandGetCurrentScriptFile() == NULL) {
+ if (ShellCommandGetCurrentScriptFile () == NULL) {
return (FALSE);
}
+
return (TRUE);
}
@@ -914,62 +960,67 @@ EfiShellBatchIsActive ( @retval other an error occurred.
**/
EFI_STATUS
-InternalOpenFileDevicePath(
- IN OUT EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- OUT SHELL_FILE_HANDLE *FileHandle,
- IN UINT64 OpenMode,
- IN UINT64 Attributes OPTIONAL
+InternalOpenFileDevicePath (
+ IN OUT EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ OUT SHELL_FILE_HANDLE *FileHandle,
+ IN UINT64 OpenMode,
+ IN UINT64 Attributes OPTIONAL
)
{
- EFI_STATUS Status;
- FILEPATH_DEVICE_PATH *FilePathNode;
- EFI_HANDLE Handle;
- SHELL_FILE_HANDLE ShellHandle;
- EFI_FILE_PROTOCOL *Handle1;
- EFI_FILE_PROTOCOL *Handle2;
- FILEPATH_DEVICE_PATH *AlignedNode;
+ EFI_STATUS Status;
+ FILEPATH_DEVICE_PATH *FilePathNode;
+ EFI_HANDLE Handle;
+ SHELL_FILE_HANDLE ShellHandle;
+ EFI_FILE_PROTOCOL *Handle1;
+ EFI_FILE_PROTOCOL *Handle2;
+ FILEPATH_DEVICE_PATH *AlignedNode;
if (FileHandle == NULL) {
return (EFI_INVALID_PARAMETER);
}
- *FileHandle = NULL;
- Handle1 = NULL;
- Handle2 = NULL;
- Handle = NULL;
- ShellHandle = NULL;
- FilePathNode = NULL;
- AlignedNode = NULL;
- Status = EfiShellOpenRoot(DevicePath, &ShellHandle);
+ *FileHandle = NULL;
+ Handle1 = NULL;
+ Handle2 = NULL;
+ Handle = NULL;
+ ShellHandle = NULL;
+ FilePathNode = NULL;
+ AlignedNode = NULL;
- if (!EFI_ERROR(Status)) {
- Handle1 = ConvertShellHandleToEfiFileProtocol(ShellHandle);
+ Status = EfiShellOpenRoot (DevicePath, &ShellHandle);
+
+ if (!EFI_ERROR (Status)) {
+ Handle1 = ConvertShellHandleToEfiFileProtocol (ShellHandle);
if (Handle1 != NULL) {
//
// chop off the beginning part before the file system part...
//
- ///@todo BlockIo?
- Status = gBS->LocateDevicePath(&gEfiSimpleFileSystemProtocolGuid,
- &DevicePath,
- &Handle);
- if (!EFI_ERROR(Status)) {
+ /// @todo BlockIo?
+ Status = gBS->LocateDevicePath (
+ &gEfiSimpleFileSystemProtocolGuid,
+ &DevicePath,
+ &Handle
+ );
+ if (!EFI_ERROR (Status)) {
//
// To access as a file system, the file path should only
// contain file path components. Follow the file path nodes
// and find the target file
//
for ( FilePathNode = (FILEPATH_DEVICE_PATH *)DevicePath
- ; !IsDevicePathEnd (&FilePathNode->Header)
- ; FilePathNode = (FILEPATH_DEVICE_PATH *) NextDevicePathNode (&FilePathNode->Header)
- ){
- SHELL_FREE_NON_NULL(AlignedNode);
- AlignedNode = AllocateCopyPool (DevicePathNodeLength(FilePathNode), FilePathNode);
+ ; !IsDevicePathEnd (&FilePathNode->Header)
+ ; FilePathNode = (FILEPATH_DEVICE_PATH *)NextDevicePathNode (&FilePathNode->Header)
+ )
+ {
+ SHELL_FREE_NON_NULL (AlignedNode);
+ AlignedNode = AllocateCopyPool (DevicePathNodeLength (FilePathNode), FilePathNode);
//
// For file system access each node should be a file path component
//
- if (DevicePathType (&FilePathNode->Header) != MEDIA_DEVICE_PATH ||
- DevicePathSubType (&FilePathNode->Header) != MEDIA_FILEPATH_DP
- ) {
+ if ((DevicePathType (&FilePathNode->Header) != MEDIA_DEVICE_PATH) ||
+ (DevicePathSubType (&FilePathNode->Header) != MEDIA_FILEPATH_DP)
+ )
+ {
Status = EFI_UNSUPPORTED;
break;
}
@@ -985,14 +1036,13 @@ InternalOpenFileDevicePath( //
if (IsDevicePathEnd ((NextDevicePathNode (&FilePathNode->Header)))) {
Status = Handle2->Open (
- Handle2,
- &Handle1,
- AlignedNode->PathName,
- OpenMode,
- Attributes
- );
+ Handle2,
+ &Handle1,
+ AlignedNode->PathName,
+ OpenMode,
+ Attributes
+ );
} else {
-
//
// This is not the last node and we dont want to 'create' existing
// directory entries...
@@ -1003,26 +1053,27 @@ InternalOpenFileDevicePath( // prevents error on existing files/directories
//
Status = Handle2->Open (
- Handle2,
- &Handle1,
- AlignedNode->PathName,
- OpenMode &~EFI_FILE_MODE_CREATE,
- Attributes
- );
+ Handle2,
+ &Handle1,
+ AlignedNode->PathName,
+ OpenMode &~EFI_FILE_MODE_CREATE,
+ Attributes
+ );
//
// if above failed now open and create the 'item'
// if OpenMode EFI_FILE_MODE_CREATE bit was on (but disabled above)
//
if ((EFI_ERROR (Status)) && ((OpenMode & EFI_FILE_MODE_CREATE) != 0)) {
Status = Handle2->Open (
- Handle2,
- &Handle1,
- AlignedNode->PathName,
- OpenMode,
- Attributes
- );
+ Handle2,
+ &Handle1,
+ AlignedNode->PathName,
+ OpenMode,
+ Attributes
+ );
}
}
+
//
// Close the last node
//
@@ -1038,14 +1089,16 @@ InternalOpenFileDevicePath( }
}
}
- SHELL_FREE_NON_NULL(AlignedNode);
- if (EFI_ERROR(Status)) {
+
+ SHELL_FREE_NON_NULL (AlignedNode);
+ if (EFI_ERROR (Status)) {
if (Handle1 != NULL) {
- ShellInfoObject.NewEfiShellProtocol->CloseFile(Handle1);
+ ShellInfoObject.NewEfiShellProtocol->CloseFile (Handle1);
}
} else {
- *FileHandle = ConvertEfiFileProtocolToShellHandle(Handle1, ShellFileHandleGetPath(ShellHandle));
+ *FileHandle = ConvertEfiFileProtocolToShellHandle (Handle1, ShellFileHandleGetPath (ShellHandle));
}
+
return (Status);
}
@@ -1087,10 +1140,10 @@ InternalOpenFileDevicePath( **/
EFI_STATUS
EFIAPI
-EfiShellCreateFile(
- IN CONST CHAR16 *FileName,
- IN UINT64 FileAttribs,
- OUT SHELL_FILE_HANDLE *FileHandle
+EfiShellCreateFile (
+ IN CONST CHAR16 *FileName,
+ IN UINT64 FileAttribs,
+ OUT SHELL_FILE_HANDLE *FileHandle
)
{
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
@@ -1101,30 +1154,32 @@ EfiShellCreateFile( // Is this for an environment variable
// do we start with >v
//
- if (StrStr(FileName, L">v") == FileName) {
+ if (StrStr (FileName, L">v") == FileName) {
Status = IsVolatileEnv (FileName + 2, &Volatile);
if (EFI_ERROR (Status)) {
return Status;
}
+
if (!Volatile) {
return (EFI_INVALID_PARAMETER);
}
- *FileHandle = CreateFileInterfaceEnv(FileName+2);
+
+ *FileHandle = CreateFileInterfaceEnv (FileName+2);
return (EFI_SUCCESS);
}
//
// We are opening a regular file.
//
- DevicePath = EfiShellGetDevicePathFromFilePath(FileName);
+ DevicePath = EfiShellGetDevicePathFromFilePath (FileName);
if (DevicePath == NULL) {
return (EFI_NOT_FOUND);
}
- Status = InternalOpenFileDevicePath(DevicePath, FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, FileAttribs);
- FreePool(DevicePath);
+ Status = InternalOpenFileDevicePath (DevicePath, FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, FileAttribs);
+ FreePool (DevicePath);
- return(Status);
+ return (Status);
}
/**
@@ -1146,12 +1201,12 @@ EfiShellCreateFile( **/
EFI_STATUS
EFIAPI
-EfiShellRegisterGuidName(
- IN CONST EFI_GUID *Guid,
- IN CONST CHAR16 *GuidName
+EfiShellRegisterGuidName (
+ IN CONST EFI_GUID *Guid,
+ IN CONST CHAR16 *GuidName
)
{
- return (AddNewGuidNameMapping(Guid, GuidName, NULL));
+ return (AddNewGuidNameMapping (Guid, GuidName, NULL));
}
/**
@@ -1208,43 +1263,45 @@ EfiShellRegisterGuidName( **/
EFI_STATUS
EFIAPI
-EfiShellOpenFileByName(
- IN CONST CHAR16 *FileName,
- OUT SHELL_FILE_HANDLE *FileHandle,
- IN UINT64 OpenMode
+EfiShellOpenFileByName (
+ IN CONST CHAR16 *FileName,
+ OUT SHELL_FILE_HANDLE *FileHandle,
+ IN UINT64 OpenMode
)
{
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_STATUS Status;
- BOOLEAN Volatile;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_STATUS Status;
+ BOOLEAN Volatile;
*FileHandle = NULL;
//
// Is this for StdIn
//
- if (StrCmp(FileName, L">i") == 0) {
+ if (StrCmp (FileName, L">i") == 0) {
//
// make sure not writing to StdIn
//
if ((OpenMode & EFI_FILE_MODE_WRITE) != 0) {
return (EFI_INVALID_PARAMETER);
}
+
*FileHandle = ShellInfoObject.NewShellParametersProtocol->StdIn;
- ASSERT(*FileHandle != NULL);
+ ASSERT (*FileHandle != NULL);
return (EFI_SUCCESS);
}
//
// Is this for StdOut
//
- if (StrCmp(FileName, L">o") == 0) {
+ if (StrCmp (FileName, L">o") == 0) {
//
// make sure not writing to StdIn
//
if ((OpenMode & EFI_FILE_MODE_READ) != 0) {
return (EFI_INVALID_PARAMETER);
}
+
*FileHandle = &FileInterfaceStdOut;
return (EFI_SUCCESS);
}
@@ -1252,8 +1309,9 @@ EfiShellOpenFileByName( //
// Is this for NUL / NULL file
//
- if ((gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16*)FileName, L"NUL") == 0) ||
- (gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16*)FileName, L"NULL") == 0)) {
+ if ((gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16 *)FileName, L"NUL") == 0) ||
+ (gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16 *)FileName, L"NULL") == 0))
+ {
*FileHandle = &FileInterfaceNulFile;
return (EFI_SUCCESS);
}
@@ -1261,13 +1319,14 @@ EfiShellOpenFileByName( //
// Is this for StdErr
//
- if (StrCmp(FileName, L">e") == 0) {
+ if (StrCmp (FileName, L">e") == 0) {
//
// make sure not writing to StdIn
//
if ((OpenMode & EFI_FILE_MODE_READ) != 0) {
return (EFI_INVALID_PARAMETER);
}
+
*FileHandle = &FileInterfaceStdErr;
return (EFI_SUCCESS);
}
@@ -1276,23 +1335,26 @@ EfiShellOpenFileByName( // Is this for an environment variable
// do we start with >v
//
- if (StrStr(FileName, L">v") == FileName) {
+ if (StrStr (FileName, L">v") == FileName) {
Status = IsVolatileEnv (FileName + 2, &Volatile);
if (EFI_ERROR (Status)) {
return Status;
}
+
if (!Volatile &&
- ((OpenMode & EFI_FILE_MODE_WRITE) != 0)) {
+ ((OpenMode & EFI_FILE_MODE_WRITE) != 0))
+ {
return (EFI_INVALID_PARAMETER);
}
- *FileHandle = CreateFileInterfaceEnv(FileName+2);
+
+ *FileHandle = CreateFileInterfaceEnv (FileName+2);
return (EFI_SUCCESS);
}
//
// We are opening a regular file.
//
- DevicePath = EfiShellGetDevicePathFromFilePath(FileName);
+ DevicePath = EfiShellGetDevicePathFromFilePath (FileName);
if (DevicePath == NULL) {
return (EFI_NOT_FOUND);
@@ -1301,10 +1363,10 @@ EfiShellOpenFileByName( //
// Copy the device path, open the file, then free the memory
//
- Status = InternalOpenFileDevicePath(DevicePath, FileHandle, OpenMode, 0); // 0 = no specific file attributes
- FreePool(DevicePath);
+ Status = InternalOpenFileDevicePath (DevicePath, FileHandle, OpenMode, 0); // 0 = no specific file attributes
+ FreePool (DevicePath);
- return(Status);
+ return (Status);
}
/**
@@ -1320,29 +1382,32 @@ EfiShellOpenFileByName( **/
EFI_STATUS
EFIAPI
-EfiShellDeleteFileByName(
- IN CONST CHAR16 *FileName
+EfiShellDeleteFileByName (
+ IN CONST CHAR16 *FileName
)
{
- SHELL_FILE_HANDLE FileHandle;
- EFI_STATUS Status;
+ SHELL_FILE_HANDLE FileHandle;
+ EFI_STATUS Status;
FileHandle = NULL;
//
// get a handle to the file
//
- Status = EfiShellCreateFile(FileName,
- 0,
- &FileHandle);
- if (EFI_ERROR(Status)) {
+ Status = EfiShellCreateFile (
+ FileName,
+ 0,
+ &FileHandle
+ );
+ if (EFI_ERROR (Status)) {
return (Status);
}
+
//
// now delete the file
//
- ShellFileHandleRemove(FileHandle);
- return (ShellInfoObject.NewEfiShellProtocol->DeleteFile(FileHandle));
+ ShellFileHandleRemove (FileHandle);
+ return (ShellInfoObject.NewEfiShellProtocol->DeleteFile (FileHandle));
}
/**
@@ -1392,32 +1457,32 @@ EfiShellEnablePageBreak ( @retval EFI_UNSUPPORTED Nested shell invocations are not allowed.
**/
EFI_STATUS
-InternalShellExecuteDevicePath(
- IN CONST EFI_HANDLE *ParentImageHandle,
- IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- IN CONST CHAR16 *CommandLine OPTIONAL,
- IN CONST CHAR16 **Environment OPTIONAL,
- OUT EFI_STATUS *StartImageStatus OPTIONAL
+InternalShellExecuteDevicePath (
+ IN CONST EFI_HANDLE *ParentImageHandle,
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ IN CONST CHAR16 *CommandLine OPTIONAL,
+ IN CONST CHAR16 **Environment OPTIONAL,
+ OUT EFI_STATUS *StartImageStatus OPTIONAL
)
{
- EFI_STATUS Status;
- EFI_STATUS StartStatus;
- EFI_STATUS CleanupStatus;
- EFI_HANDLE NewHandle;
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
- LIST_ENTRY OrigEnvs;
- EFI_SHELL_PARAMETERS_PROTOCOL ShellParamsProtocol;
- CHAR16 *ImagePath;
- UINTN Index;
- CHAR16 *Walker;
- CHAR16 *NewCmdLine;
+ EFI_STATUS Status;
+ EFI_STATUS StartStatus;
+ EFI_STATUS CleanupStatus;
+ EFI_HANDLE NewHandle;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+ LIST_ENTRY OrigEnvs;
+ EFI_SHELL_PARAMETERS_PROTOCOL ShellParamsProtocol;
+ CHAR16 *ImagePath;
+ UINTN Index;
+ CHAR16 *Walker;
+ CHAR16 *NewCmdLine;
if (ParentImageHandle == NULL) {
return (EFI_INVALID_PARAMETER);
}
- InitializeListHead(&OrigEnvs);
- ZeroMem(&ShellParamsProtocol, sizeof(EFI_SHELL_PARAMETERS_PROTOCOL));
+ InitializeListHead (&OrigEnvs);
+ ZeroMem (&ShellParamsProtocol, sizeof (EFI_SHELL_PARAMETERS_PROTOCOL));
NewHandle = NULL;
@@ -1426,9 +1491,9 @@ InternalShellExecuteDevicePath( return EFI_OUT_OF_RESOURCES;
}
- for (Walker = NewCmdLine; Walker != NULL && *Walker != CHAR_NULL ; Walker++) {
- if (*Walker == L'^' && *(Walker+1) == L'#') {
- CopyMem(Walker, Walker+1, StrSize(Walker) - sizeof(Walker[0]));
+ for (Walker = NewCmdLine; Walker != NULL && *Walker != CHAR_NULL; Walker++) {
+ if ((*Walker == L'^') && (*(Walker+1) == L'#')) {
+ CopyMem (Walker, Walker+1, StrSize (Walker) - sizeof (Walker[0]));
}
}
@@ -1436,67 +1501,71 @@ InternalShellExecuteDevicePath( // Load the image with:
// FALSE - not from boot manager and NULL, 0 being not already in memory
//
- Status = gBS->LoadImage(
- FALSE,
- *ParentImageHandle,
- (EFI_DEVICE_PATH_PROTOCOL*)DevicePath,
- NULL,
- 0,
- &NewHandle);
+ Status = gBS->LoadImage (
+ FALSE,
+ *ParentImageHandle,
+ (EFI_DEVICE_PATH_PROTOCOL *)DevicePath,
+ NULL,
+ 0,
+ &NewHandle
+ );
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
if (NewHandle != NULL) {
- gBS->UnloadImage(NewHandle);
+ gBS->UnloadImage (NewHandle);
}
+
FreePool (NewCmdLine);
return (Status);
}
- Status = gBS->OpenProtocol(
- NewHandle,
- &gEfiLoadedImageProtocolGuid,
- (VOID**)&LoadedImage,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (!EFI_ERROR(Status)) {
+ Status = gBS->OpenProtocol (
+ NewHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **)&LoadedImage,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+
+ if (!EFI_ERROR (Status)) {
//
// If the image is not an app abort it.
//
- if (LoadedImage->ImageCodeType != EfiLoaderCode){
- ShellPrintHiiEx(
+ if (LoadedImage->ImageCodeType != EfiLoaderCode) {
+ ShellPrintHiiEx (
-1,
-1,
NULL,
STRING_TOKEN (STR_SHELL_IMAGE_NOT_APP),
ShellInfoObject.HiiHandle
- );
+ );
goto UnloadImage;
}
- ASSERT(LoadedImage->LoadOptionsSize == 0);
+ ASSERT (LoadedImage->LoadOptionsSize == 0);
if (NewCmdLine != NULL) {
- LoadedImage->LoadOptionsSize = (UINT32)StrSize(NewCmdLine);
- LoadedImage->LoadOptions = (VOID*)NewCmdLine;
+ LoadedImage->LoadOptionsSize = (UINT32)StrSize (NewCmdLine);
+ LoadedImage->LoadOptions = (VOID *)NewCmdLine;
}
//
// Save our current environment settings for later restoration if necessary
//
if (Environment != NULL) {
- Status = GetEnvironmentVariableList(&OrigEnvs);
- if (!EFI_ERROR(Status)) {
- Status = SetEnvironmentVariables(Environment);
+ Status = GetEnvironmentVariableList (&OrigEnvs);
+ if (!EFI_ERROR (Status)) {
+ Status = SetEnvironmentVariables (Environment);
}
}
//
// Initialize and install a shell parameters protocol on the image.
//
- ShellParamsProtocol.StdIn = ShellInfoObject.NewShellParametersProtocol->StdIn;
- ShellParamsProtocol.StdOut = ShellInfoObject.NewShellParametersProtocol->StdOut;
- ShellParamsProtocol.StdErr = ShellInfoObject.NewShellParametersProtocol->StdErr;
- Status = UpdateArgcArgv(&ShellParamsProtocol, NewCmdLine, Efi_Application, NULL, NULL);
+ ShellParamsProtocol.StdIn = ShellInfoObject.NewShellParametersProtocol->StdIn;
+ ShellParamsProtocol.StdOut = ShellInfoObject.NewShellParametersProtocol->StdOut;
+ ShellParamsProtocol.StdErr = ShellInfoObject.NewShellParametersProtocol->StdErr;
+ Status = UpdateArgcArgv (&ShellParamsProtocol, NewCmdLine, Efi_Application, NULL, NULL);
if (EFI_ERROR (Status)) {
goto UnloadImage;
}
@@ -1520,38 +1589,40 @@ InternalShellExecuteDevicePath( Status = EFI_OUT_OF_RESOURCES;
goto UnloadImage;
}
+
ShellParamsProtocol.Argc = 1;
} else {
// Free the string UpdateArgcArgv put in Argv[0];
FreePool (ShellParamsProtocol.Argv[0]);
}
+
ShellParamsProtocol.Argv[0] = ImagePath;
}
- Status = gBS->InstallProtocolInterface(&NewHandle, &gEfiShellParametersProtocolGuid, EFI_NATIVE_INTERFACE, &ShellParamsProtocol);
- ASSERT_EFI_ERROR(Status);
+ Status = gBS->InstallProtocolInterface (&NewHandle, &gEfiShellParametersProtocolGuid, EFI_NATIVE_INTERFACE, &ShellParamsProtocol);
+ ASSERT_EFI_ERROR (Status);
- ///@todo initialize and install ShellInterface protocol on the new image for compatibility if - PcdGetBool(PcdShellSupportOldProtocols)
+ /// @todo initialize and install ShellInterface protocol on the new image for compatibility if - PcdGetBool(PcdShellSupportOldProtocols)
//
// now start the image and if the caller wanted the return code pass it to them...
//
- if (!EFI_ERROR(Status)) {
- StartStatus = gBS->StartImage(
- NewHandle,
- 0,
- NULL
- );
+ if (!EFI_ERROR (Status)) {
+ StartStatus = gBS->StartImage (
+ NewHandle,
+ 0,
+ NULL
+ );
if (StartImageStatus != NULL) {
*StartImageStatus = StartStatus;
}
- CleanupStatus = gBS->UninstallProtocolInterface(
- NewHandle,
- &gEfiShellParametersProtocolGuid,
- &ShellParamsProtocol
- );
- ASSERT_EFI_ERROR(CleanupStatus);
+ CleanupStatus = gBS->UninstallProtocolInterface (
+ NewHandle,
+ &gEfiShellParametersProtocolGuid,
+ &ShellParamsProtocol
+ );
+ ASSERT_EFI_ERROR (CleanupStatus);
goto FreeAlloc;
}
@@ -1568,19 +1639,20 @@ FreeAlloc: FreePool (ShellParamsProtocol.Argv[Index]);
}
}
+
FreePool (ShellParamsProtocol.Argv);
}
}
// Restore environment variables
- if (!IsListEmpty(&OrigEnvs)) {
- CleanupStatus = SetEnvironmentVariableList(&OrigEnvs);
+ if (!IsListEmpty (&OrigEnvs)) {
+ CleanupStatus = SetEnvironmentVariableList (&OrigEnvs);
ASSERT_EFI_ERROR (CleanupStatus);
}
FreePool (NewCmdLine);
- return(Status);
+ return (Status);
}
/**
@@ -1603,39 +1675,39 @@ FreeAlloc: @retval EFI_UNSUPPORTED Nested shell invocations are not allowed.
**/
EFI_STATUS
-InternalShellExecute(
- IN CONST CHAR16 *CommandLine OPTIONAL,
- IN CONST CHAR16 **Environment OPTIONAL,
- OUT EFI_STATUS *StartImageStatus OPTIONAL
+InternalShellExecute (
+ IN CONST CHAR16 *CommandLine OPTIONAL,
+ IN CONST CHAR16 **Environment OPTIONAL,
+ OUT EFI_STATUS *StartImageStatus OPTIONAL
)
{
- EFI_STATUS Status;
- EFI_STATUS CleanupStatus;
- LIST_ENTRY OrigEnvs;
+ EFI_STATUS Status;
+ EFI_STATUS CleanupStatus;
+ LIST_ENTRY OrigEnvs;
- InitializeListHead(&OrigEnvs);
+ InitializeListHead (&OrigEnvs);
//
// Save our current environment settings for later restoration if necessary
//
if (Environment != NULL) {
- Status = GetEnvironmentVariableList(&OrigEnvs);
- if (!EFI_ERROR(Status)) {
- Status = SetEnvironmentVariables(Environment);
+ Status = GetEnvironmentVariableList (&OrigEnvs);
+ if (!EFI_ERROR (Status)) {
+ Status = SetEnvironmentVariables (Environment);
} else {
return Status;
}
}
- Status = RunShellCommand(CommandLine, StartImageStatus);
+ Status = RunShellCommand (CommandLine, StartImageStatus);
// Restore environment variables
- if (!IsListEmpty(&OrigEnvs)) {
- CleanupStatus = SetEnvironmentVariableList(&OrigEnvs);
+ if (!IsListEmpty (&OrigEnvs)) {
+ CleanupStatus = SetEnvironmentVariableList (&OrigEnvs);
ASSERT_EFI_ERROR (CleanupStatus);
}
- return(Status);
+ return (Status);
}
/**
@@ -1646,9 +1718,9 @@ InternalShellExecute( **/
STATIC
BOOLEAN
-NestingEnabled(
+NestingEnabled (
VOID
-)
+ )
{
EFI_STATUS Status;
CHAR16 *Temp;
@@ -1663,15 +1735,16 @@ NestingEnabled( if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoNest) {
TempSize = 0;
Temp = NULL;
- Status = SHELL_GET_ENVIRONMENT_VARIABLE(mNoNestingEnvVarName, &TempSize, Temp);
+ Status = SHELL_GET_ENVIRONMENT_VARIABLE (mNoNestingEnvVarName, &TempSize, Temp);
if (Status == EFI_BUFFER_TOO_SMALL) {
- Temp = AllocateZeroPool(TempSize + sizeof(CHAR16));
+ Temp = AllocateZeroPool (TempSize + sizeof (CHAR16));
if (Temp != NULL) {
- Status = SHELL_GET_ENVIRONMENT_VARIABLE(mNoNestingEnvVarName, &TempSize, Temp);
+ Status = SHELL_GET_ENVIRONMENT_VARIABLE (mNoNestingEnvVarName, &TempSize, Temp);
}
}
- Temp2 = StrnCatGrow(&Temp2, NULL, mNoNestingTrue, 0);
- if (Temp != NULL && Temp2 != NULL && StringNoCaseCompare(&Temp, &Temp2) == 0) {
+
+ Temp2 = StrnCatGrow (&Temp2, NULL, mNoNestingTrue, 0);
+ if ((Temp != NULL) && (Temp2 != NULL) && (StringNoCaseCompare (&Temp, &Temp2) == 0)) {
//
// Use the no nesting method.
//
@@ -1679,8 +1752,8 @@ NestingEnabled( }
}
- SHELL_FREE_NON_NULL(Temp);
- SHELL_FREE_NON_NULL(Temp2);
+ SHELL_FREE_NON_NULL (Temp);
+ SHELL_FREE_NON_NULL (Temp2);
return (RetVal);
}
@@ -1720,11 +1793,11 @@ NestingEnabled( **/
EFI_STATUS
EFIAPI
-EfiShellExecute(
- IN EFI_HANDLE *ParentImageHandle,
- IN CHAR16 *CommandLine OPTIONAL,
- IN CHAR16 **Environment OPTIONAL,
- OUT EFI_STATUS *StatusCode OPTIONAL
+EfiShellExecute (
+ IN EFI_HANDLE *ParentImageHandle,
+ IN CHAR16 *CommandLine OPTIONAL,
+ IN CHAR16 **Environment OPTIONAL,
+ OUT EFI_STATUS *StatusCode OPTIONAL
)
{
EFI_STATUS Status;
@@ -1732,48 +1805,50 @@ EfiShellExecute( EFI_DEVICE_PATH_PROTOCOL *DevPath;
UINTN Size;
- if ((PcdGet8(PcdShellSupportLevel) < 1)) {
+ if ((PcdGet8 (PcdShellSupportLevel) < 1)) {
return (EFI_UNSUPPORTED);
}
- if (NestingEnabled()) {
+ if (NestingEnabled ()) {
DevPath = AppendDevicePath (ShellInfoObject.ImageDevPath, ShellInfoObject.FileDevPath);
- DEBUG_CODE_BEGIN();
- Temp = ConvertDevicePathToText(ShellInfoObject.FileDevPath, TRUE, TRUE);
- FreePool(Temp);
- Temp = ConvertDevicePathToText(ShellInfoObject.ImageDevPath, TRUE, TRUE);
- FreePool(Temp);
- Temp = ConvertDevicePathToText(DevPath, TRUE, TRUE);
- FreePool(Temp);
- DEBUG_CODE_END();
+ DEBUG_CODE_BEGIN ();
+ Temp = ConvertDevicePathToText (ShellInfoObject.FileDevPath, TRUE, TRUE);
+ FreePool (Temp);
+ Temp = ConvertDevicePathToText (ShellInfoObject.ImageDevPath, TRUE, TRUE);
+ FreePool (Temp);
+ Temp = ConvertDevicePathToText (DevPath, TRUE, TRUE);
+ FreePool (Temp);
+ DEBUG_CODE_END ();
Temp = NULL;
Size = 0;
- ASSERT((Temp == NULL && Size == 0) || (Temp != NULL));
- StrnCatGrow(&Temp, &Size, L"Shell.efi -exit ", 0);
- StrnCatGrow(&Temp, &Size, CommandLine, 0);
-
- Status = InternalShellExecuteDevicePath(
- ParentImageHandle,
- DevPath,
- Temp,
- (CONST CHAR16**)Environment,
- StatusCode);
+ ASSERT ((Temp == NULL && Size == 0) || (Temp != NULL));
+ StrnCatGrow (&Temp, &Size, L"Shell.efi -exit ", 0);
+ StrnCatGrow (&Temp, &Size, CommandLine, 0);
+
+ Status = InternalShellExecuteDevicePath (
+ ParentImageHandle,
+ DevPath,
+ Temp,
+ (CONST CHAR16 **)Environment,
+ StatusCode
+ );
//
// de-allocate and return
//
- FreePool(DevPath);
- FreePool(Temp);
+ FreePool (DevPath);
+ FreePool (Temp);
} else {
- Status = InternalShellExecute(
- (CONST CHAR16*)CommandLine,
- (CONST CHAR16**)Environment,
- StatusCode);
+ Status = InternalShellExecute (
+ (CONST CHAR16 *)CommandLine,
+ (CONST CHAR16 **)Environment,
+ StatusCode
+ );
}
- return(Status);
+ return (Status);
}
/**
@@ -1785,24 +1860,29 @@ EfiShellExecute( @param FileListNode pointer to the list node to free
**/
VOID
-InternalFreeShellFileInfoNode(
- IN EFI_SHELL_FILE_INFO *FileListNode
+InternalFreeShellFileInfoNode (
+ IN EFI_SHELL_FILE_INFO *FileListNode
)
{
if (FileListNode->Info != NULL) {
- FreePool((VOID*)FileListNode->Info);
+ FreePool ((VOID *)FileListNode->Info);
}
+
if (FileListNode->FileName != NULL) {
- FreePool((VOID*)FileListNode->FileName);
+ FreePool ((VOID *)FileListNode->FileName);
}
+
if (FileListNode->FullName != NULL) {
- FreePool((VOID*)FileListNode->FullName);
+ FreePool ((VOID *)FileListNode->FullName);
}
+
if (FileListNode->Handle != NULL) {
- ShellInfoObject.NewEfiShellProtocol->CloseFile(FileListNode->Handle);
+ ShellInfoObject.NewEfiShellProtocol->CloseFile (FileListNode->Handle);
}
- FreePool(FileListNode);
+
+ FreePool (FileListNode);
}
+
/**
Frees the file list.
@@ -1817,26 +1897,28 @@ InternalFreeShellFileInfoNode( **/
EFI_STATUS
EFIAPI
-EfiShellFreeFileList(
- IN EFI_SHELL_FILE_INFO **FileList
+EfiShellFreeFileList (
+ IN EFI_SHELL_FILE_INFO **FileList
)
{
- EFI_SHELL_FILE_INFO *ShellFileListItem;
+ EFI_SHELL_FILE_INFO *ShellFileListItem;
- if (FileList == NULL || *FileList == NULL) {
+ if ((FileList == NULL) || (*FileList == NULL)) {
return (EFI_INVALID_PARAMETER);
}
- for ( ShellFileListItem = (EFI_SHELL_FILE_INFO*)GetFirstNode(&(*FileList)->Link)
- ; !IsListEmpty(&(*FileList)->Link)
- ; ShellFileListItem = (EFI_SHELL_FILE_INFO*)GetFirstNode(&(*FileList)->Link)
- ){
- RemoveEntryList(&ShellFileListItem->Link);
- InternalFreeShellFileInfoNode(ShellFileListItem);
+ for ( ShellFileListItem = (EFI_SHELL_FILE_INFO *)GetFirstNode (&(*FileList)->Link)
+ ; !IsListEmpty (&(*FileList)->Link)
+ ; ShellFileListItem = (EFI_SHELL_FILE_INFO *)GetFirstNode (&(*FileList)->Link)
+ )
+ {
+ RemoveEntryList (&ShellFileListItem->Link);
+ InternalFreeShellFileInfoNode (ShellFileListItem);
}
- InternalFreeShellFileInfoNode(*FileList);
+
+ InternalFreeShellFileInfoNode (*FileList);
*FileList = NULL;
- return(EFI_SUCCESS);
+ return (EFI_SUCCESS);
}
/**
@@ -1851,17 +1933,17 @@ EfiShellFreeFileList( **/
EFI_STATUS
EFIAPI
-EfiShellRemoveDupInFileList(
- IN EFI_SHELL_FILE_INFO **FileList
+EfiShellRemoveDupInFileList (
+ IN EFI_SHELL_FILE_INFO **FileList
)
{
- EFI_STATUS Status;
- EFI_SHELL_FILE_INFO *Duplicates;
- EFI_SHELL_FILE_INFO *ShellFileListItem;
- EFI_SHELL_FILE_INFO *ShellFileListItem2;
- EFI_SHELL_FILE_INFO *TempNode;
+ EFI_STATUS Status;
+ EFI_SHELL_FILE_INFO *Duplicates;
+ EFI_SHELL_FILE_INFO *ShellFileListItem;
+ EFI_SHELL_FILE_INFO *ShellFileListItem2;
+ EFI_SHELL_FILE_INFO *TempNode;
- if (FileList == NULL || *FileList == NULL) {
+ if ((FileList == NULL) || (*FileList == NULL)) {
return (EFI_INVALID_PARAMETER);
}
@@ -1874,35 +1956,41 @@ EfiShellRemoveDupInFileList( EfiShellFreeFileList (&Duplicates);
return EFI_SUCCESS;
}
+
//
// Fall back to the slow method that needs no extra memory, and so cannot
// fail.
//
- for ( ShellFileListItem = (EFI_SHELL_FILE_INFO*)GetFirstNode(&(*FileList)->Link)
- ; !IsNull(&(*FileList)->Link, &ShellFileListItem->Link)
- ; ShellFileListItem = (EFI_SHELL_FILE_INFO*)GetNextNode(&(*FileList)->Link, &ShellFileListItem->Link)
- ){
- for ( ShellFileListItem2 = (EFI_SHELL_FILE_INFO*)GetNextNode(&(*FileList)->Link, &ShellFileListItem->Link)
- ; !IsNull(&(*FileList)->Link, &ShellFileListItem2->Link)
- ; ShellFileListItem2 = (EFI_SHELL_FILE_INFO*)GetNextNode(&(*FileList)->Link, &ShellFileListItem2->Link)
- ){
- if (gUnicodeCollation->StriColl(
- gUnicodeCollation,
- (CHAR16*)ShellFileListItem->FullName,
- (CHAR16*)ShellFileListItem2->FullName) == 0
- ){
- TempNode = (EFI_SHELL_FILE_INFO *)GetPreviousNode(
+ for ( ShellFileListItem = (EFI_SHELL_FILE_INFO *)GetFirstNode (&(*FileList)->Link)
+ ; !IsNull (&(*FileList)->Link, &ShellFileListItem->Link)
+ ; ShellFileListItem = (EFI_SHELL_FILE_INFO *)GetNextNode (&(*FileList)->Link, &ShellFileListItem->Link)
+ )
+ {
+ for ( ShellFileListItem2 = (EFI_SHELL_FILE_INFO *)GetNextNode (&(*FileList)->Link, &ShellFileListItem->Link)
+ ; !IsNull (&(*FileList)->Link, &ShellFileListItem2->Link)
+ ; ShellFileListItem2 = (EFI_SHELL_FILE_INFO *)GetNextNode (&(*FileList)->Link, &ShellFileListItem2->Link)
+ )
+ {
+ if (gUnicodeCollation->StriColl (
+ gUnicodeCollation,
+ (CHAR16 *)ShellFileListItem->FullName,
+ (CHAR16 *)ShellFileListItem2->FullName
+ ) == 0
+ )
+ {
+ TempNode = (EFI_SHELL_FILE_INFO *)GetPreviousNode (
&(*FileList)->Link,
&ShellFileListItem2->Link
);
- RemoveEntryList(&ShellFileListItem2->Link);
- InternalFreeShellFileInfoNode(ShellFileListItem2);
+ RemoveEntryList (&ShellFileListItem2->Link);
+ InternalFreeShellFileInfoNode (ShellFileListItem2);
// Set ShellFileListItem2 to PreviousNode so we don't access Freed
// memory in GetNextNode in the loop expression above.
ShellFileListItem2 = TempNode;
}
}
}
+
return (EFI_SUCCESS);
}
@@ -1910,12 +1998,12 @@ EfiShellRemoveDupInFileList( // This is the same structure as the external version, but it has no CONST qualifiers.
//
typedef struct {
- LIST_ENTRY Link; ///< Linked list members.
- EFI_STATUS Status; ///< Status of opening the file. Valid only if Handle != NULL.
- CHAR16 *FullName; ///< Fully qualified filename.
- CHAR16 *FileName; ///< name of this file.
- SHELL_FILE_HANDLE Handle; ///< Handle for interacting with the opened file or NULL if closed.
- EFI_FILE_INFO *Info; ///< Pointer to the FileInfo struct for this file or NULL.
+ LIST_ENTRY Link; ///< Linked list members.
+ EFI_STATUS Status; ///< Status of opening the file. Valid only if Handle != NULL.
+ CHAR16 *FullName; ///< Fully qualified filename.
+ CHAR16 *FileName; ///< name of this file.
+ SHELL_FILE_HANDLE Handle; ///< Handle for interacting with the opened file or NULL if closed.
+ EFI_FILE_INFO *Info; ///< Pointer to the FileInfo struct for this file or NULL.
} EFI_SHELL_FILE_INFO_NO_CONST;
/**
@@ -1927,43 +2015,46 @@ typedef struct { @retval NULL a memory allocation error occurred
@return != NULL a pointer to the new node
**/
-EFI_SHELL_FILE_INFO*
-InternalDuplicateShellFileInfo(
- IN EFI_SHELL_FILE_INFO *Node,
- IN BOOLEAN Save
+EFI_SHELL_FILE_INFO *
+InternalDuplicateShellFileInfo (
+ IN EFI_SHELL_FILE_INFO *Node,
+ IN BOOLEAN Save
)
{
- EFI_SHELL_FILE_INFO_NO_CONST *NewNode;
+ EFI_SHELL_FILE_INFO_NO_CONST *NewNode;
//
// try to confirm that the objects are in sync
//
- ASSERT(sizeof(EFI_SHELL_FILE_INFO_NO_CONST) == sizeof(EFI_SHELL_FILE_INFO));
+ ASSERT (sizeof (EFI_SHELL_FILE_INFO_NO_CONST) == sizeof (EFI_SHELL_FILE_INFO));
- NewNode = AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO));
+ NewNode = AllocateZeroPool (sizeof (EFI_SHELL_FILE_INFO));
if (NewNode == NULL) {
return (NULL);
}
- NewNode->FullName = AllocateCopyPool(StrSize(Node->FullName), Node->FullName);
- NewNode->FileName = AllocateCopyPool(StrSize(Node->FileName), Node->FileName);
- NewNode->Info = AllocateCopyPool((UINTN)Node->Info->Size, Node->Info);
- if ( NewNode->FullName == NULL
- || NewNode->FileName == NULL
- || NewNode->Info == NULL
- ){
- SHELL_FREE_NON_NULL(NewNode->FullName);
- SHELL_FREE_NON_NULL(NewNode->FileName);
- SHELL_FREE_NON_NULL(NewNode->Info);
- SHELL_FREE_NON_NULL(NewNode);
- return(NULL);
+
+ NewNode->FullName = AllocateCopyPool (StrSize (Node->FullName), Node->FullName);
+ NewNode->FileName = AllocateCopyPool (StrSize (Node->FileName), Node->FileName);
+ NewNode->Info = AllocateCopyPool ((UINTN)Node->Info->Size, Node->Info);
+ if ( (NewNode->FullName == NULL)
+ || (NewNode->FileName == NULL)
+ || (NewNode->Info == NULL)
+ )
+ {
+ SHELL_FREE_NON_NULL (NewNode->FullName);
+ SHELL_FREE_NON_NULL (NewNode->FileName);
+ SHELL_FREE_NON_NULL (NewNode->Info);
+ SHELL_FREE_NON_NULL (NewNode);
+ return (NULL);
}
+
NewNode->Status = Node->Status;
NewNode->Handle = Node->Handle;
if (!Save) {
Node->Handle = NULL;
}
- return((EFI_SHELL_FILE_INFO*)NewNode);
+ return ((EFI_SHELL_FILE_INFO *)NewNode);
}
/**
@@ -1980,70 +2071,75 @@ InternalDuplicateShellFileInfo( @return a pointer to the newly allocated structure.
**/
EFI_SHELL_FILE_INFO *
-CreateAndPopulateShellFileInfo(
- IN CONST CHAR16 *BasePath,
- IN CONST EFI_STATUS Status,
- IN CONST CHAR16 *FileName,
- IN CONST SHELL_FILE_HANDLE Handle,
- IN CONST EFI_FILE_INFO *Info
+CreateAndPopulateShellFileInfo (
+ IN CONST CHAR16 *BasePath,
+ IN CONST EFI_STATUS Status,
+ IN CONST CHAR16 *FileName,
+ IN CONST SHELL_FILE_HANDLE Handle,
+ IN CONST EFI_FILE_INFO *Info
)
{
- EFI_SHELL_FILE_INFO *ShellFileListItem;
- CHAR16 *TempString;
- UINTN Size;
+ EFI_SHELL_FILE_INFO *ShellFileListItem;
+ CHAR16 *TempString;
+ UINTN Size;
TempString = NULL;
- Size = 0;
+ Size = 0;
- ShellFileListItem = AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO));
+ ShellFileListItem = AllocateZeroPool (sizeof (EFI_SHELL_FILE_INFO));
if (ShellFileListItem == NULL) {
return (NULL);
}
- if (Info != NULL && Info->Size != 0) {
- ShellFileListItem->Info = AllocateZeroPool((UINTN)Info->Size);
+
+ if ((Info != NULL) && (Info->Size != 0)) {
+ ShellFileListItem->Info = AllocateZeroPool ((UINTN)Info->Size);
if (ShellFileListItem->Info == NULL) {
- FreePool(ShellFileListItem);
+ FreePool (ShellFileListItem);
return (NULL);
}
- CopyMem(ShellFileListItem->Info, Info, (UINTN)Info->Size);
+
+ CopyMem (ShellFileListItem->Info, Info, (UINTN)Info->Size);
} else {
ShellFileListItem->Info = NULL;
}
+
if (FileName != NULL) {
- ASSERT(TempString == NULL);
- ShellFileListItem->FileName = StrnCatGrow(&TempString, 0, FileName, 0);
+ ASSERT (TempString == NULL);
+ ShellFileListItem->FileName = StrnCatGrow (&TempString, 0, FileName, 0);
if (ShellFileListItem->FileName == NULL) {
- FreePool(ShellFileListItem->Info);
- FreePool(ShellFileListItem);
+ FreePool (ShellFileListItem->Info);
+ FreePool (ShellFileListItem);
return (NULL);
}
} else {
ShellFileListItem->FileName = NULL;
}
- Size = 0;
+
+ Size = 0;
TempString = NULL;
if (BasePath != NULL) {
- ASSERT((TempString == NULL && Size == 0) || (TempString != NULL));
- TempString = StrnCatGrow(&TempString, &Size, BasePath, 0);
+ ASSERT ((TempString == NULL && Size == 0) || (TempString != NULL));
+ TempString = StrnCatGrow (&TempString, &Size, BasePath, 0);
if (TempString == NULL) {
- FreePool((VOID*)ShellFileListItem->FileName);
- SHELL_FREE_NON_NULL(ShellFileListItem->Info);
- FreePool(ShellFileListItem);
+ FreePool ((VOID *)ShellFileListItem->FileName);
+ SHELL_FREE_NON_NULL (ShellFileListItem->Info);
+ FreePool (ShellFileListItem);
return (NULL);
}
}
+
if (ShellFileListItem->FileName != NULL) {
- ASSERT((TempString == NULL && Size == 0) || (TempString != NULL));
- TempString = StrnCatGrow(&TempString, &Size, ShellFileListItem->FileName, 0);
+ ASSERT ((TempString == NULL && Size == 0) || (TempString != NULL));
+ TempString = StrnCatGrow (&TempString, &Size, ShellFileListItem->FileName, 0);
if (TempString == NULL) {
- FreePool((VOID*)ShellFileListItem->FileName);
- FreePool(ShellFileListItem->Info);
- FreePool(ShellFileListItem);
+ FreePool ((VOID *)ShellFileListItem->FileName);
+ FreePool (ShellFileListItem->Info);
+ FreePool (ShellFileListItem);
return (NULL);
}
}
- TempString = PathCleanUpDirectories(TempString);
+ TempString = PathCleanUpDirectories (TempString);
ShellFileListItem->FullName = TempString;
ShellFileListItem->Status = Status;
@@ -2068,48 +2164,50 @@ CreateAndPopulateShellFileInfo( **/
EFI_STATUS
EFIAPI
-EfiShellFindFilesInDir(
- IN SHELL_FILE_HANDLE FileDirHandle,
- OUT EFI_SHELL_FILE_INFO **FileList
+EfiShellFindFilesInDir (
+ IN SHELL_FILE_HANDLE FileDirHandle,
+ OUT EFI_SHELL_FILE_INFO **FileList
)
{
- EFI_SHELL_FILE_INFO *ShellFileList;
- EFI_SHELL_FILE_INFO *ShellFileListItem;
- EFI_FILE_INFO *FileInfo;
- EFI_STATUS Status;
- BOOLEAN NoFile;
- CHAR16 *TempString;
- CHAR16 *BasePath;
- UINTN Size;
- CHAR16 *TempSpot;
+ EFI_SHELL_FILE_INFO *ShellFileList;
+ EFI_SHELL_FILE_INFO *ShellFileListItem;
+ EFI_FILE_INFO *FileInfo;
+ EFI_STATUS Status;
+ BOOLEAN NoFile;
+ CHAR16 *TempString;
+ CHAR16 *BasePath;
+ UINTN Size;
+ CHAR16 *TempSpot;
BasePath = NULL;
- Status = FileHandleGetFileName(FileDirHandle, &BasePath);
- if (EFI_ERROR(Status)) {
+ Status = FileHandleGetFileName (FileDirHandle, &BasePath);
+ if (EFI_ERROR (Status)) {
return (Status);
}
- if (ShellFileHandleGetPath(FileDirHandle) != NULL) {
- TempString = NULL;
- Size = 0;
- TempString = StrnCatGrow(&TempString, &Size, ShellFileHandleGetPath(FileDirHandle), 0);
+ if (ShellFileHandleGetPath (FileDirHandle) != NULL) {
+ TempString = NULL;
+ Size = 0;
+ TempString = StrnCatGrow (&TempString, &Size, ShellFileHandleGetPath (FileDirHandle), 0);
if (TempString == NULL) {
- SHELL_FREE_NON_NULL(BasePath);
+ SHELL_FREE_NON_NULL (BasePath);
return (EFI_OUT_OF_RESOURCES);
}
- TempSpot = StrStr(TempString, L";");
+
+ TempSpot = StrStr (TempString, L";");
if (TempSpot != NULL) {
*TempSpot = CHAR_NULL;
}
- TempString = StrnCatGrow(&TempString, &Size, BasePath, 0);
+ TempString = StrnCatGrow (&TempString, &Size, BasePath, 0);
if (TempString == NULL) {
- SHELL_FREE_NON_NULL(BasePath);
+ SHELL_FREE_NON_NULL (BasePath);
return (EFI_OUT_OF_RESOURCES);
}
- SHELL_FREE_NON_NULL(BasePath);
- BasePath = TempString;
+
+ SHELL_FREE_NON_NULL (BasePath);
+ BasePath = TempString;
}
NoFile = FALSE;
@@ -2118,28 +2216,31 @@ EfiShellFindFilesInDir( FileInfo = NULL;
Status = EFI_SUCCESS;
-
- for ( Status = FileHandleFindFirstFile(FileDirHandle, &FileInfo)
- ; !EFI_ERROR(Status) && !NoFile
- ; Status = FileHandleFindNextFile(FileDirHandle, FileInfo, &NoFile)
- ){
+ for ( Status = FileHandleFindFirstFile (FileDirHandle, &FileInfo)
+ ; !EFI_ERROR (Status) && !NoFile
+ ; Status = FileHandleFindNextFile (FileDirHandle, FileInfo, &NoFile)
+ )
+ {
if (ShellFileList == NULL) {
- ShellFileList = (EFI_SHELL_FILE_INFO*)AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO));
+ ShellFileList = (EFI_SHELL_FILE_INFO *)AllocateZeroPool (sizeof (EFI_SHELL_FILE_INFO));
if (ShellFileList == NULL) {
SHELL_FREE_NON_NULL (BasePath);
return EFI_OUT_OF_RESOURCES;
}
- InitializeListHead(&ShellFileList->Link);
+
+ InitializeListHead (&ShellFileList->Link);
}
+
//
// allocate a new EFI_SHELL_FILE_INFO and populate it...
//
- ShellFileListItem = CreateAndPopulateShellFileInfo(
- BasePath,
- EFI_SUCCESS, // success since we didn't fail to open it...
- FileInfo->FileName,
- NULL, // no handle since not open
- FileInfo);
+ ShellFileListItem = CreateAndPopulateShellFileInfo (
+ BasePath,
+ EFI_SUCCESS, // success since we didn't fail to open it...
+ FileInfo->FileName,
+ NULL, // no handle since not open
+ FileInfo
+ );
if (ShellFileListItem == NULL) {
Status = EFI_OUT_OF_RESOURCES;
//
@@ -2147,16 +2248,19 @@ EfiShellFindFilesInDir( //
break;
}
- InsertTailList(&ShellFileList->Link, &ShellFileListItem->Link);
+
+ InsertTailList (&ShellFileList->Link, &ShellFileListItem->Link);
}
- if (EFI_ERROR(Status)) {
- EfiShellFreeFileList(&ShellFileList);
+
+ if (EFI_ERROR (Status)) {
+ EfiShellFreeFileList (&ShellFileList);
*FileList = NULL;
} else {
*FileList = ShellFileList;
}
- SHELL_FREE_NON_NULL(BasePath);
- return(Status);
+
+ SHELL_FREE_NON_NULL (BasePath);
+ return (Status);
}
/**
@@ -2178,22 +2282,22 @@ EfiShellFindFilesInDir( **/
EFI_STATUS
EFIAPI
-EfiShellGetGuidFromName(
- IN CONST CHAR16 *GuidName,
- OUT EFI_GUID *Guid
+EfiShellGetGuidFromName (
+ IN CONST CHAR16 *GuidName,
+ OUT EFI_GUID *Guid
)
{
EFI_GUID *NewGuid;
EFI_STATUS Status;
- if (Guid == NULL || GuidName == NULL) {
+ if ((Guid == NULL) || (GuidName == NULL)) {
return (EFI_INVALID_PARAMETER);
}
- Status = GetGuidFromStringName(GuidName, NULL, &NewGuid);
+ Status = GetGuidFromStringName (GuidName, NULL, &NewGuid);
- if (!EFI_ERROR(Status)) {
- CopyGuid(Guid, NewGuid);
+ if (!EFI_ERROR (Status)) {
+ CopyGuid (Guid, NewGuid);
}
return (Status);
@@ -2218,30 +2322,28 @@ EfiShellGetGuidFromName( **/
EFI_STATUS
EFIAPI
-EfiShellGetGuidName(
- IN CONST EFI_GUID *Guid,
- OUT CONST CHAR16 **GuidName
+EfiShellGetGuidName (
+ IN CONST EFI_GUID *Guid,
+ OUT CONST CHAR16 **GuidName
)
{
- CHAR16 *Name;
+ CHAR16 *Name;
- if (Guid == NULL || GuidName == NULL) {
+ if ((Guid == NULL) || (GuidName == NULL)) {
return (EFI_INVALID_PARAMETER);
}
- Name = GetStringNameFromGuid(Guid, NULL);
- if (Name == NULL || StrLen(Name) == 0) {
- SHELL_FREE_NON_NULL(Name);
+ Name = GetStringNameFromGuid (Guid, NULL);
+ if ((Name == NULL) || (StrLen (Name) == 0)) {
+ SHELL_FREE_NON_NULL (Name);
return (EFI_NOT_FOUND);
}
- *GuidName = AddBufferToFreeList(Name);
+ *GuidName = AddBufferToFreeList (Name);
return (EFI_SUCCESS);
}
-
-
/**
If FileHandle is a directory then the function reads from FileHandle and reads in
each of the FileInfo structures. If one of them matches the Pattern's first
@@ -2265,53 +2367,58 @@ EfiShellGetGuidName( @retval EFI_OUT_OF_RESOURCES a memory allocation failed
**/
EFI_STATUS
-ShellSearchHandle(
- IN CONST CHAR16 *FilePattern,
- IN EFI_UNICODE_COLLATION_PROTOCOL *UnicodeCollation,
- IN SHELL_FILE_HANDLE FileHandle,
- IN OUT EFI_SHELL_FILE_INFO **FileList,
- IN CONST EFI_SHELL_FILE_INFO *ParentNode OPTIONAL,
- IN CONST CHAR16 *MapName
+ShellSearchHandle (
+ IN CONST CHAR16 *FilePattern,
+ IN EFI_UNICODE_COLLATION_PROTOCOL *UnicodeCollation,
+ IN SHELL_FILE_HANDLE FileHandle,
+ IN OUT EFI_SHELL_FILE_INFO **FileList,
+ IN CONST EFI_SHELL_FILE_INFO *ParentNode OPTIONAL,
+ IN CONST CHAR16 *MapName
)
{
- EFI_STATUS Status;
- CONST CHAR16 *NextFilePatternStart;
- CHAR16 *CurrentFilePattern;
- EFI_SHELL_FILE_INFO *ShellInfo;
- EFI_SHELL_FILE_INFO *ShellInfoNode;
- EFI_SHELL_FILE_INFO *NewShellNode;
- EFI_FILE_INFO *FileInfo;
- BOOLEAN Directory;
- CHAR16 *NewFullName;
- UINTN Size;
-
- if ( FilePattern == NULL
- || UnicodeCollation == NULL
- || FileList == NULL
- ){
+ EFI_STATUS Status;
+ CONST CHAR16 *NextFilePatternStart;
+ CHAR16 *CurrentFilePattern;
+ EFI_SHELL_FILE_INFO *ShellInfo;
+ EFI_SHELL_FILE_INFO *ShellInfoNode;
+ EFI_SHELL_FILE_INFO *NewShellNode;
+ EFI_FILE_INFO *FileInfo;
+ BOOLEAN Directory;
+ CHAR16 *NewFullName;
+ UINTN Size;
+
+ if ( (FilePattern == NULL)
+ || (UnicodeCollation == NULL)
+ || (FileList == NULL)
+ )
+ {
return (EFI_INVALID_PARAMETER);
}
- ShellInfo = NULL;
+
+ ShellInfo = NULL;
CurrentFilePattern = NULL;
if (*FilePattern == L'\\') {
FilePattern++;
}
- for( NextFilePatternStart = FilePattern
- ; *NextFilePatternStart != CHAR_NULL && *NextFilePatternStart != L'\\'
- ; NextFilePatternStart++);
+ for ( NextFilePatternStart = FilePattern
+ ; *NextFilePatternStart != CHAR_NULL && *NextFilePatternStart != L'\\'
+ ; NextFilePatternStart++)
+ {
+ }
- CurrentFilePattern = AllocateZeroPool((NextFilePatternStart-FilePattern+1)*sizeof(CHAR16));
+ CurrentFilePattern = AllocateZeroPool ((NextFilePatternStart-FilePattern+1)*sizeof (CHAR16));
if (CurrentFilePattern == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- StrnCpyS(CurrentFilePattern, NextFilePatternStart-FilePattern+1, FilePattern, NextFilePatternStart-FilePattern);
+ StrnCpyS (CurrentFilePattern, NextFilePatternStart-FilePattern+1, FilePattern, NextFilePatternStart-FilePattern);
- if (CurrentFilePattern[0] == CHAR_NULL
- &&NextFilePatternStart[0] == CHAR_NULL
- ){
+ if ( (CurrentFilePattern[0] == CHAR_NULL)
+ && (NextFilePatternStart[0] == CHAR_NULL)
+ )
+ {
//
// we want the parent or root node (if no parent)
//
@@ -2319,64 +2426,68 @@ ShellSearchHandle( //
// We want the root node. create the node.
//
- FileInfo = FileHandleGetInfo(FileHandle);
- NewShellNode = CreateAndPopulateShellFileInfo(
- MapName,
- EFI_SUCCESS,
- L"\\",
- FileHandle,
- FileInfo
- );
- SHELL_FREE_NON_NULL(FileInfo);
+ FileInfo = FileHandleGetInfo (FileHandle);
+ NewShellNode = CreateAndPopulateShellFileInfo (
+ MapName,
+ EFI_SUCCESS,
+ L"\\",
+ FileHandle,
+ FileInfo
+ );
+ SHELL_FREE_NON_NULL (FileInfo);
} else {
//
// Add the current parameter FileHandle to the list, then end...
//
- NewShellNode = InternalDuplicateShellFileInfo((EFI_SHELL_FILE_INFO*)ParentNode, TRUE);
+ NewShellNode = InternalDuplicateShellFileInfo ((EFI_SHELL_FILE_INFO *)ParentNode, TRUE);
}
+
if (NewShellNode == NULL) {
Status = EFI_OUT_OF_RESOURCES;
} else {
NewShellNode->Handle = NULL;
if (*FileList == NULL) {
- *FileList = AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO));
- InitializeListHead(&((*FileList)->Link));
+ *FileList = AllocateZeroPool (sizeof (EFI_SHELL_FILE_INFO));
+ InitializeListHead (&((*FileList)->Link));
}
//
// Add to the returning to use list
//
- InsertTailList(&(*FileList)->Link, &NewShellNode->Link);
+ InsertTailList (&(*FileList)->Link, &NewShellNode->Link);
Status = EFI_SUCCESS;
}
} else {
- Status = EfiShellFindFilesInDir(FileHandle, &ShellInfo);
+ Status = EfiShellFindFilesInDir (FileHandle, &ShellInfo);
- if (!EFI_ERROR(Status)){
- if (StrStr(NextFilePatternStart, L"\\") != NULL){
+ if (!EFI_ERROR (Status)) {
+ if (StrStr (NextFilePatternStart, L"\\") != NULL) {
Directory = TRUE;
} else {
Directory = FALSE;
}
- for ( ShellInfoNode = (EFI_SHELL_FILE_INFO*)GetFirstNode(&ShellInfo->Link)
- ; !IsNull (&ShellInfo->Link, &ShellInfoNode->Link)
- ; ShellInfoNode = (EFI_SHELL_FILE_INFO*)GetNextNode(&ShellInfo->Link, &ShellInfoNode->Link)
- ){
- if (UnicodeCollation->MetaiMatch(UnicodeCollation, (CHAR16*)ShellInfoNode->FileName, CurrentFilePattern)){
- if (ShellInfoNode->FullName != NULL && StrStr(ShellInfoNode->FullName, L":") == NULL) {
- Size = StrSize (ShellInfoNode->FullName) + StrSize (MapName);
- NewFullName = AllocateZeroPool(Size);
+
+ for ( ShellInfoNode = (EFI_SHELL_FILE_INFO *)GetFirstNode (&ShellInfo->Link)
+ ; !IsNull (&ShellInfo->Link, &ShellInfoNode->Link)
+ ; ShellInfoNode = (EFI_SHELL_FILE_INFO *)GetNextNode (&ShellInfo->Link, &ShellInfoNode->Link)
+ )
+ {
+ if (UnicodeCollation->MetaiMatch (UnicodeCollation, (CHAR16 *)ShellInfoNode->FileName, CurrentFilePattern)) {
+ if ((ShellInfoNode->FullName != NULL) && (StrStr (ShellInfoNode->FullName, L":") == NULL)) {
+ Size = StrSize (ShellInfoNode->FullName) + StrSize (MapName);
+ NewFullName = AllocateZeroPool (Size);
if (NewFullName == NULL) {
Status = EFI_OUT_OF_RESOURCES;
} else {
- StrCpyS(NewFullName, Size / sizeof(CHAR16), MapName);
- StrCatS(NewFullName, Size / sizeof(CHAR16), ShellInfoNode->FullName);
- FreePool ((VOID *) ShellInfoNode->FullName);
+ StrCpyS (NewFullName, Size / sizeof (CHAR16), MapName);
+ StrCatS (NewFullName, Size / sizeof (CHAR16), ShellInfoNode->FullName);
+ FreePool ((VOID *)ShellInfoNode->FullName);
ShellInfoNode->FullName = NewFullName;
}
}
- if (Directory && !EFI_ERROR(Status) && ShellInfoNode->FullName != NULL && ShellInfoNode->FileName != NULL){
+
+ if (Directory && !EFI_ERROR (Status) && (ShellInfoNode->FullName != NULL) && (ShellInfoNode->FileName != NULL)) {
//
// should be a directory
//
@@ -2384,15 +2495,17 @@ ShellSearchHandle( //
// don't open the . and .. directories
//
- if ( (StrCmp(ShellInfoNode->FileName, L".") != 0)
- && (StrCmp(ShellInfoNode->FileName, L"..") != 0)
- ){
+ if ( (StrCmp (ShellInfoNode->FileName, L".") != 0)
+ && (StrCmp (ShellInfoNode->FileName, L"..") != 0)
+ )
+ {
//
//
//
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
break;
}
+
//
// Open the directory since we need that handle in the next recursion.
//
@@ -2401,11 +2514,11 @@ ShellSearchHandle( //
// recurse with the next part of the pattern
//
- Status = ShellSearchHandle(NextFilePatternStart, UnicodeCollation, ShellInfoNode->Handle, FileList, ShellInfoNode, MapName);
- EfiShellClose(ShellInfoNode->Handle);
+ Status = ShellSearchHandle (NextFilePatternStart, UnicodeCollation, ShellInfoNode->Handle, FileList, ShellInfoNode, MapName);
+ EfiShellClose (ShellInfoNode->Handle);
ShellInfoNode->Handle = NULL;
}
- } else if (!EFI_ERROR(Status)) {
+ } else if (!EFI_ERROR (Status)) {
//
// should be a file
//
@@ -2413,38 +2526,41 @@ ShellSearchHandle( //
// copy the information we need into a new Node
//
- NewShellNode = InternalDuplicateShellFileInfo(ShellInfoNode, FALSE);
+ NewShellNode = InternalDuplicateShellFileInfo (ShellInfoNode, FALSE);
if (NewShellNode == NULL) {
Status = EFI_OUT_OF_RESOURCES;
}
+
if (*FileList == NULL) {
- *FileList = AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO));
- InitializeListHead(&((*FileList)->Link));
+ *FileList = AllocateZeroPool (sizeof (EFI_SHELL_FILE_INFO));
+ InitializeListHead (&((*FileList)->Link));
}
//
// Add to the returning to use list
//
- InsertTailList(&(*FileList)->Link, &NewShellNode->Link);
+ InsertTailList (&(*FileList)->Link, &NewShellNode->Link);
}
}
- if (EFI_ERROR(Status)) {
+
+ if (EFI_ERROR (Status)) {
break;
}
}
- if (EFI_ERROR(Status)) {
- EfiShellFreeFileList(&ShellInfo);
+
+ if (EFI_ERROR (Status)) {
+ EfiShellFreeFileList (&ShellInfo);
} else {
- Status = EfiShellFreeFileList(&ShellInfo);
+ Status = EfiShellFreeFileList (&ShellInfo);
}
}
}
- if (*FileList == NULL || (*FileList != NULL && IsListEmpty(&(*FileList)->Link))) {
+ if ((*FileList == NULL) || ((*FileList != NULL) && IsListEmpty (&(*FileList)->Link))) {
Status = EFI_NOT_FOUND;
}
- FreePool(CurrentFilePattern);
+ FreePool (CurrentFilePattern);
return (Status);
}
@@ -2476,65 +2592,71 @@ ShellSearchHandle( **/
EFI_STATUS
EFIAPI
-EfiShellFindFiles(
- IN CONST CHAR16 *FilePattern,
- OUT EFI_SHELL_FILE_INFO **FileList
+EfiShellFindFiles (
+ IN CONST CHAR16 *FilePattern,
+ OUT EFI_SHELL_FILE_INFO **FileList
)
{
- EFI_STATUS Status;
- CHAR16 *PatternCopy;
- CHAR16 *PatternCurrentLocation;
- EFI_DEVICE_PATH_PROTOCOL *RootDevicePath;
- SHELL_FILE_HANDLE RootFileHandle;
- CHAR16 *MapName;
- UINTN Count;
-
- if ( FilePattern == NULL
- || FileList == NULL
- || StrStr(FilePattern, L":") == NULL
- ){
+ EFI_STATUS Status;
+ CHAR16 *PatternCopy;
+ CHAR16 *PatternCurrentLocation;
+ EFI_DEVICE_PATH_PROTOCOL *RootDevicePath;
+ SHELL_FILE_HANDLE RootFileHandle;
+ CHAR16 *MapName;
+ UINTN Count;
+
+ if ( (FilePattern == NULL)
+ || (FileList == NULL)
+ || (StrStr (FilePattern, L":") == NULL)
+ )
+ {
return (EFI_INVALID_PARAMETER);
}
- Status = EFI_SUCCESS;
+
+ Status = EFI_SUCCESS;
RootDevicePath = NULL;
RootFileHandle = NULL;
MapName = NULL;
- PatternCopy = AllocateCopyPool(StrSize(FilePattern), FilePattern);
+ PatternCopy = AllocateCopyPool (StrSize (FilePattern), FilePattern);
if (PatternCopy == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
- PatternCopy = PathCleanUpDirectories(PatternCopy);
+ PatternCopy = PathCleanUpDirectories (PatternCopy);
- Count = StrStr(PatternCopy, L":") - PatternCopy + 1;
+ Count = StrStr (PatternCopy, L":") - PatternCopy + 1;
ASSERT (Count <= StrLen (PatternCopy));
- ASSERT(MapName == NULL);
- MapName = StrnCatGrow(&MapName, NULL, PatternCopy, Count);
+ ASSERT (MapName == NULL);
+ MapName = StrnCatGrow (&MapName, NULL, PatternCopy, Count);
if (MapName == NULL) {
Status = EFI_OUT_OF_RESOURCES;
} else {
- RootDevicePath = EfiShellGetDevicePathFromFilePath(PatternCopy);
+ RootDevicePath = EfiShellGetDevicePathFromFilePath (PatternCopy);
if (RootDevicePath == NULL) {
Status = EFI_INVALID_PARAMETER;
} else {
- Status = EfiShellOpenRoot(RootDevicePath, &RootFileHandle);
- if (!EFI_ERROR(Status)) {
+ Status = EfiShellOpenRoot (RootDevicePath, &RootFileHandle);
+ if (!EFI_ERROR (Status)) {
for ( PatternCurrentLocation = PatternCopy
- ; *PatternCurrentLocation != ':'
- ; PatternCurrentLocation++);
+ ; *PatternCurrentLocation != ':'
+ ; PatternCurrentLocation++)
+ {
+ }
+
PatternCurrentLocation++;
- Status = ShellSearchHandle(PatternCurrentLocation, gUnicodeCollation, RootFileHandle, FileList, NULL, MapName);
- EfiShellClose(RootFileHandle);
+ Status = ShellSearchHandle (PatternCurrentLocation, gUnicodeCollation, RootFileHandle, FileList, NULL, MapName);
+ EfiShellClose (RootFileHandle);
}
- FreePool(RootDevicePath);
+
+ FreePool (RootDevicePath);
}
}
- SHELL_FREE_NON_NULL(PatternCopy);
- SHELL_FREE_NON_NULL(MapName);
+ SHELL_FREE_NON_NULL (PatternCopy);
+ SHELL_FREE_NON_NULL (MapName);
- return(Status);
+ return (Status);
}
/**
@@ -2554,49 +2676,51 @@ EfiShellFindFiles( **/
EFI_STATUS
EFIAPI
-EfiShellOpenFileList(
- IN CHAR16 *Path,
- IN UINT64 OpenMode,
- IN OUT EFI_SHELL_FILE_INFO **FileList
+EfiShellOpenFileList (
+ IN CHAR16 *Path,
+ IN UINT64 OpenMode,
+ IN OUT EFI_SHELL_FILE_INFO **FileList
)
{
- EFI_STATUS Status;
- EFI_SHELL_FILE_INFO *ShellFileListItem;
- CHAR16 *Path2;
- UINTN Path2Size;
- CONST CHAR16 *CurDir;
- BOOLEAN Found;
+ EFI_STATUS Status;
+ EFI_SHELL_FILE_INFO *ShellFileListItem;
+ CHAR16 *Path2;
+ UINTN Path2Size;
+ CONST CHAR16 *CurDir;
+ BOOLEAN Found;
- PathCleanUpDirectories(Path);
+ PathCleanUpDirectories (Path);
- Path2Size = 0;
- Path2 = NULL;
+ Path2Size = 0;
+ Path2 = NULL;
- if (FileList == NULL || *FileList == NULL) {
+ if ((FileList == NULL) || (*FileList == NULL)) {
return (EFI_INVALID_PARAMETER);
}
- if (*Path == L'.' && *(Path+1) == L'\\') {
- Path+=2;
+ if ((*Path == L'.') && (*(Path+1) == L'\\')) {
+ Path += 2;
}
//
// convert a local path to an absolute path
//
- if (StrStr(Path, L":") == NULL) {
- CurDir = EfiShellGetCurDir(NULL);
- ASSERT((Path2 == NULL && Path2Size == 0) || (Path2 != NULL));
- StrnCatGrow(&Path2, &Path2Size, CurDir, 0);
- StrnCatGrow(&Path2, &Path2Size, L"\\", 0);
+ if (StrStr (Path, L":") == NULL) {
+ CurDir = EfiShellGetCurDir (NULL);
+ ASSERT ((Path2 == NULL && Path2Size == 0) || (Path2 != NULL));
+ StrnCatGrow (&Path2, &Path2Size, CurDir, 0);
+ StrnCatGrow (&Path2, &Path2Size, L"\\", 0);
if (*Path == L'\\') {
Path++;
- while (PathRemoveLastItem(Path2)) ;
+ while (PathRemoveLastItem (Path2)) {
+ }
}
- ASSERT((Path2 == NULL && Path2Size == 0) || (Path2 != NULL));
- StrnCatGrow(&Path2, &Path2Size, Path, 0);
+
+ ASSERT ((Path2 == NULL && Path2Size == 0) || (Path2 != NULL));
+ StrnCatGrow (&Path2, &Path2Size, Path, 0);
} else {
- ASSERT(Path2 == NULL);
- StrnCatGrow(&Path2, NULL, Path, 0);
+ ASSERT (Path2 == NULL);
+ StrnCatGrow (&Path2, NULL, Path, 0);
}
PathCleanUpDirectories (Path2);
@@ -2604,11 +2728,11 @@ EfiShellOpenFileList( //
// do the search
//
- Status = EfiShellFindFiles(Path2, FileList);
+ Status = EfiShellFindFiles (Path2, FileList);
- FreePool(Path2);
+ FreePool (Path2);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
return (Status);
}
@@ -2616,20 +2740,22 @@ EfiShellOpenFileList( //
// We had no errors so open all the files (that are not already opened...)
//
- for ( ShellFileListItem = (EFI_SHELL_FILE_INFO*)GetFirstNode(&(*FileList)->Link)
- ; !IsNull(&(*FileList)->Link, &ShellFileListItem->Link)
- ; ShellFileListItem = (EFI_SHELL_FILE_INFO*)GetNextNode(&(*FileList)->Link, &ShellFileListItem->Link)
- ){
- if (ShellFileListItem->Status == 0 && ShellFileListItem->Handle == NULL) {
+ for ( ShellFileListItem = (EFI_SHELL_FILE_INFO *)GetFirstNode (&(*FileList)->Link)
+ ; !IsNull (&(*FileList)->Link, &ShellFileListItem->Link)
+ ; ShellFileListItem = (EFI_SHELL_FILE_INFO *)GetNextNode (&(*FileList)->Link, &ShellFileListItem->Link)
+ )
+ {
+ if ((ShellFileListItem->Status == 0) && (ShellFileListItem->Handle == NULL)) {
ShellFileListItem->Status = EfiShellOpenFileByName (ShellFileListItem->FullName, &ShellFileListItem->Handle, OpenMode);
- Found = TRUE;
+ Found = TRUE;
}
}
if (!Found) {
return (EFI_NOT_FOUND);
}
- return(EFI_SUCCESS);
+
+ return (EFI_SUCCESS);
}
/**
@@ -2656,79 +2782,83 @@ EfiShellOpenFileList( **/
CONST CHAR16 *
EFIAPI
-EfiShellGetEnvEx(
- IN CONST CHAR16 *Name,
- OUT UINT32 *Attributes OPTIONAL
+EfiShellGetEnvEx (
+ IN CONST CHAR16 *Name,
+ OUT UINT32 *Attributes OPTIONAL
)
{
- EFI_STATUS Status;
- VOID *Buffer;
- UINTN Size;
- ENV_VAR_LIST *Node;
- CHAR16 *CurrentWriteLocation;
+ EFI_STATUS Status;
+ VOID *Buffer;
+ UINTN Size;
+ ENV_VAR_LIST *Node;
+ CHAR16 *CurrentWriteLocation;
- Size = 0;
+ Size = 0;
Buffer = NULL;
if (Name == NULL) {
-
//
// Build the semi-colon delimited list. (2 passes)
//
- for ( Node = (ENV_VAR_LIST*)GetFirstNode(&gShellEnvVarList.Link)
- ; !IsNull(&gShellEnvVarList.Link, &Node->Link)
- ; Node = (ENV_VAR_LIST*)GetNextNode(&gShellEnvVarList.Link, &Node->Link)
- ){
- ASSERT(Node->Key != NULL);
- Size += StrSize(Node->Key);
+ for ( Node = (ENV_VAR_LIST *)GetFirstNode (&gShellEnvVarList.Link)
+ ; !IsNull (&gShellEnvVarList.Link, &Node->Link)
+ ; Node = (ENV_VAR_LIST *)GetNextNode (&gShellEnvVarList.Link, &Node->Link)
+ )
+ {
+ ASSERT (Node->Key != NULL);
+ Size += StrSize (Node->Key);
}
- Size += 2*sizeof(CHAR16);
+ Size += 2*sizeof (CHAR16);
- Buffer = AllocateZeroPool(Size);
+ Buffer = AllocateZeroPool (Size);
if (Buffer == NULL) {
return (NULL);
}
- CurrentWriteLocation = (CHAR16*)Buffer;
- for ( Node = (ENV_VAR_LIST*)GetFirstNode(&gShellEnvVarList.Link)
- ; !IsNull(&gShellEnvVarList.Link, &Node->Link)
- ; Node = (ENV_VAR_LIST*)GetNextNode(&gShellEnvVarList.Link, &Node->Link)
- ){
- ASSERT(Node->Key != NULL);
- StrCpyS( CurrentWriteLocation,
- (Size)/sizeof(CHAR16) - (CurrentWriteLocation - ((CHAR16*)Buffer)),
- Node->Key
- );
- CurrentWriteLocation += StrLen(CurrentWriteLocation) + 1;
- }
+ CurrentWriteLocation = (CHAR16 *)Buffer;
+ for ( Node = (ENV_VAR_LIST *)GetFirstNode (&gShellEnvVarList.Link)
+ ; !IsNull (&gShellEnvVarList.Link, &Node->Link)
+ ; Node = (ENV_VAR_LIST *)GetNextNode (&gShellEnvVarList.Link, &Node->Link)
+ )
+ {
+ ASSERT (Node->Key != NULL);
+ StrCpyS (
+ CurrentWriteLocation,
+ (Size)/sizeof (CHAR16) - (CurrentWriteLocation - ((CHAR16 *)Buffer)),
+ Node->Key
+ );
+ CurrentWriteLocation += StrLen (CurrentWriteLocation) + 1;
+ }
} else {
//
// We are doing a specific environment variable
//
- Status = ShellFindEnvVarInList(Name, (CHAR16**)&Buffer, &Size, Attributes);
+ Status = ShellFindEnvVarInList (Name, (CHAR16 **)&Buffer, &Size, Attributes);
- if (EFI_ERROR(Status)){
+ if (EFI_ERROR (Status)) {
//
// get the size we need for this EnvVariable
//
- Status = SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(Name, Attributes, &Size, Buffer);
+ Status = SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES (Name, Attributes, &Size, Buffer);
if (Status == EFI_BUFFER_TOO_SMALL) {
//
// Allocate the space and recall the get function
//
- Buffer = AllocateZeroPool(Size);
- Status = SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(Name, Attributes, &Size, Buffer);
+ Buffer = AllocateZeroPool (Size);
+ Status = SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES (Name, Attributes, &Size, Buffer);
}
+
//
// we didn't get it (might not exist)
// free the memory if we allocated any and return NULL
//
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
if (Buffer != NULL) {
- FreePool(Buffer);
+ FreePool (Buffer);
}
+
return (NULL);
} else {
//
@@ -2746,7 +2876,7 @@ EfiShellGetEnvEx( //
// return the buffer
//
- return (AddBufferToFreeList(Buffer));
+ return (AddBufferToFreeList (Buffer));
}
/**
@@ -2774,11 +2904,11 @@ EfiShellGetEnvEx( **/
CONST CHAR16 *
EFIAPI
-EfiShellGetEnv(
- IN CONST CHAR16 *Name
+EfiShellGetEnv (
+ IN CONST CHAR16 *Name
)
{
- return (EfiShellGetEnvEx(Name, NULL));
+ return (EfiShellGetEnvEx (Name, NULL));
}
/**
@@ -2792,23 +2922,25 @@ EfiShellGetEnv( @retval EFI_SUCCESS The environment variable was successfully updated.
**/
EFI_STATUS
-InternalEfiShellSetEnv(
- IN CONST CHAR16 *Name,
- IN CONST CHAR16 *Value,
- IN BOOLEAN Volatile
+InternalEfiShellSetEnv (
+ IN CONST CHAR16 *Name,
+ IN CONST CHAR16 *Value,
+ IN BOOLEAN Volatile
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
- if (Value == NULL || StrLen(Value) == 0) {
- Status = SHELL_DELETE_ENVIRONMENT_VARIABLE(Name);
- if (!EFI_ERROR(Status)) {
- ShellRemvoeEnvVarFromList(Name);
+ if ((Value == NULL) || (StrLen (Value) == 0)) {
+ Status = SHELL_DELETE_ENVIRONMENT_VARIABLE (Name);
+ if (!EFI_ERROR (Status)) {
+ ShellRemvoeEnvVarFromList (Name);
}
} else {
- SHELL_DELETE_ENVIRONMENT_VARIABLE(Name);
- Status = ShellAddEnvVarToList(
- Name, Value, StrSize(Value),
+ SHELL_DELETE_ENVIRONMENT_VARIABLE (Name);
+ Status = ShellAddEnvVarToList (
+ Name,
+ Value,
+ StrSize (Value),
EFI_VARIABLE_BOOTSERVICE_ACCESS | (Volatile ? 0 : EFI_VARIABLE_NON_VOLATILE)
);
if (!EFI_ERROR (Status)) {
@@ -2816,10 +2948,11 @@ InternalEfiShellSetEnv( ? SHELL_SET_ENVIRONMENT_VARIABLE_V (Name, StrSize (Value) - sizeof (CHAR16), Value)
: SHELL_SET_ENVIRONMENT_VARIABLE_NV (Name, StrSize (Value) - sizeof (CHAR16), Value);
if (EFI_ERROR (Status)) {
- ShellRemvoeEnvVarFromList(Name);
+ ShellRemvoeEnvVarFromList (Name);
}
}
}
+
return Status;
}
@@ -2846,15 +2979,16 @@ InternalEfiShellSetEnv( **/
EFI_STATUS
EFIAPI
-EfiShellSetEnv(
- IN CONST CHAR16 *Name,
- IN CONST CHAR16 *Value,
- IN BOOLEAN Volatile
+EfiShellSetEnv (
+ IN CONST CHAR16 *Name,
+ IN CONST CHAR16 *Value,
+ IN BOOLEAN Volatile
)
{
- if (Name == NULL || *Name == CHAR_NULL) {
+ if ((Name == NULL) || (*Name == CHAR_NULL)) {
return (EFI_INVALID_PARAMETER);
}
+
//
// Make sure we dont 'set' a predefined read only variable
//
@@ -2865,11 +2999,13 @@ EfiShellSetEnv( (StrCmp (Name, L"uefishellversion") == 0) ||
(StrCmp (Name, L"uefiversion") == 0) ||
(!ShellInfoObject.ShellInitSettings.BitUnion.Bits.NoNest &&
- StrCmp (Name, mNoNestingEnvVarName) == 0)
- ) {
+ (StrCmp (Name, mNoNestingEnvVarName) == 0))
+ )
+ {
return (EFI_INVALID_PARAMETER);
}
- return (InternalEfiShellSetEnv(Name, Value, Volatile));
+
+ return (InternalEfiShellSetEnv (Name, Value, Volatile));
}
/**
@@ -2890,30 +3026,32 @@ EfiShellSetEnv( **/
CONST CHAR16 *
EFIAPI
-EfiShellGetCurDir(
- IN CONST CHAR16 *FileSystemMapping OPTIONAL
+EfiShellGetCurDir (
+ IN CONST CHAR16 *FileSystemMapping OPTIONAL
)
{
- CHAR16 *PathToReturn;
- UINTN Size;
- SHELL_MAP_LIST *MapListItem;
- if (!IsListEmpty(&gShellMapList.Link)) {
+ CHAR16 *PathToReturn;
+ UINTN Size;
+ SHELL_MAP_LIST *MapListItem;
+
+ if (!IsListEmpty (&gShellMapList.Link)) {
//
// if parameter is NULL, use current
//
if (FileSystemMapping == NULL) {
- return (EfiShellGetEnv(L"cwd"));
+ return (EfiShellGetEnv (L"cwd"));
} else {
- Size = 0;
+ Size = 0;
PathToReturn = NULL;
- MapListItem = ShellCommandFindMapItem(FileSystemMapping);
+ MapListItem = ShellCommandFindMapItem (FileSystemMapping);
if (MapListItem != NULL) {
- ASSERT((PathToReturn == NULL && Size == 0) || (PathToReturn != NULL));
- PathToReturn = StrnCatGrow(&PathToReturn, &Size, MapListItem->MapName, 0);
- PathToReturn = StrnCatGrow(&PathToReturn, &Size, MapListItem->CurrentDirectoryPath, 0);
+ ASSERT ((PathToReturn == NULL && Size == 0) || (PathToReturn != NULL));
+ PathToReturn = StrnCatGrow (&PathToReturn, &Size, MapListItem->MapName, 0);
+ PathToReturn = StrnCatGrow (&PathToReturn, &Size, MapListItem->CurrentDirectoryPath, 0);
}
}
- return (AddBufferToFreeList(PathToReturn));
+
+ return (AddBufferToFreeList (PathToReturn));
} else {
return (NULL);
}
@@ -2948,9 +3086,9 @@ EfiShellGetCurDir( **/
EFI_STATUS
EFIAPI
-EfiShellSetCurDir(
- IN CONST CHAR16 *FileSystem OPTIONAL,
- IN CONST CHAR16 *Dir
+EfiShellSetCurDir (
+ IN CONST CHAR16 *FileSystem OPTIONAL,
+ IN CONST CHAR16 *Dir
)
{
CHAR16 *MapName;
@@ -2967,33 +3105,34 @@ EfiShellSetCurDir( TempString = NULL;
DirectoryName = NULL;
- if ((FileSystem == NULL && Dir == NULL) || Dir == NULL) {
+ if (((FileSystem == NULL) && (Dir == NULL)) || (Dir == NULL)) {
return (EFI_INVALID_PARAMETER);
}
- if (IsListEmpty(&gShellMapList.Link)){
+ if (IsListEmpty (&gShellMapList.Link)) {
return (EFI_NOT_FOUND);
}
- DirectoryName = StrnCatGrow(&DirectoryName, NULL, Dir, 0);
- ASSERT(DirectoryName != NULL);
+ DirectoryName = StrnCatGrow (&DirectoryName, NULL, Dir, 0);
+ ASSERT (DirectoryName != NULL);
- PathCleanUpDirectories(DirectoryName);
+ PathCleanUpDirectories (DirectoryName);
if (FileSystem == NULL) {
//
// determine the file system mapping to use
//
- if (StrStr(DirectoryName, L":") != NULL) {
- ASSERT(MapName == NULL);
- MapName = StrnCatGrow(&MapName, NULL, DirectoryName, (StrStr(DirectoryName, L":")-DirectoryName+1));
+ if (StrStr (DirectoryName, L":") != NULL) {
+ ASSERT (MapName == NULL);
+ MapName = StrnCatGrow (&MapName, NULL, DirectoryName, (StrStr (DirectoryName, L":")-DirectoryName+1));
}
+
//
// find the file system mapping's entry in the list
// or use current
//
if (MapName != NULL) {
- MapListItem = ShellCommandFindMapItem(MapName);
+ MapListItem = ShellCommandFindMapItem (MapName);
//
// make that the current file system mapping
@@ -3007,87 +3146,97 @@ EfiShellSetCurDir( if (MapListItem == NULL) {
FreePool (DirectoryName);
- SHELL_FREE_NON_NULL(MapName);
+ SHELL_FREE_NON_NULL (MapName);
return (EFI_NOT_FOUND);
}
//
// now update the MapListItem's current directory
//
- if (MapListItem->CurrentDirectoryPath != NULL && DirectoryName[StrLen(DirectoryName) - 1] != L':') {
- FreePool(MapListItem->CurrentDirectoryPath);
+ if ((MapListItem->CurrentDirectoryPath != NULL) && (DirectoryName[StrLen (DirectoryName) - 1] != L':')) {
+ FreePool (MapListItem->CurrentDirectoryPath);
MapListItem->CurrentDirectoryPath = NULL;
}
+
if (MapName != NULL) {
- TempLen = StrLen(MapName);
- if (TempLen != StrLen(DirectoryName)) {
- ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
- MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName+StrLen(MapName), 0);
+ TempLen = StrLen (MapName);
+ if (TempLen != StrLen (DirectoryName)) {
+ ASSERT ((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
+ MapListItem->CurrentDirectoryPath = StrnCatGrow (&MapListItem->CurrentDirectoryPath, &Size, DirectoryName+StrLen (MapName), 0);
}
+
FreePool (MapName);
} else {
- ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
- MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName, 0);
+ ASSERT ((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
+ MapListItem->CurrentDirectoryPath = StrnCatGrow (&MapListItem->CurrentDirectoryPath, &Size, DirectoryName, 0);
}
- if ((MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] == L'\\') || (MapListItem->CurrentDirectoryPath == NULL)) {
- ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
+
+ if (((MapListItem->CurrentDirectoryPath != NULL) && (MapListItem->CurrentDirectoryPath[StrLen (MapListItem->CurrentDirectoryPath)-1] == L'\\')) || (MapListItem->CurrentDirectoryPath == NULL)) {
+ ASSERT ((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
if (MapListItem->CurrentDirectoryPath != NULL) {
- MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] = CHAR_NULL;
- }
+ MapListItem->CurrentDirectoryPath[StrLen (MapListItem->CurrentDirectoryPath)-1] = CHAR_NULL;
+ }
}
} else {
//
// cant have a mapping in the directory...
//
- if (StrStr(DirectoryName, L":") != NULL) {
+ if (StrStr (DirectoryName, L":") != NULL) {
FreePool (DirectoryName);
return (EFI_INVALID_PARAMETER);
}
+
//
// FileSystem != NULL
//
- MapListItem = ShellCommandFindMapItem(FileSystem);
+ MapListItem = ShellCommandFindMapItem (FileSystem);
if (MapListItem == NULL) {
FreePool (DirectoryName);
return (EFI_INVALID_PARAMETER);
}
-// gShellCurMapping = MapListItem;
+
+ // gShellCurMapping = MapListItem;
if (DirectoryName != NULL) {
//
// change current dir on that file system
//
if (MapListItem->CurrentDirectoryPath != NULL) {
- FreePool(MapListItem->CurrentDirectoryPath);
- DEBUG_CODE(MapListItem->CurrentDirectoryPath = NULL;);
+ FreePool (MapListItem->CurrentDirectoryPath);
+ DEBUG_CODE (
+ MapListItem->CurrentDirectoryPath = NULL;
+ );
}
-// ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
-// MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, FileSystem, 0);
- ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
- MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);
- ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
- MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName, 0);
- if (MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] == L'\\') {
- ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
- MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] = CHAR_NULL;
+
+ // ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
+ // MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, FileSystem, 0);
+ ASSERT ((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
+ MapListItem->CurrentDirectoryPath = StrnCatGrow (&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);
+ ASSERT ((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
+ MapListItem->CurrentDirectoryPath = StrnCatGrow (&MapListItem->CurrentDirectoryPath, &Size, DirectoryName, 0);
+ if ((MapListItem->CurrentDirectoryPath != NULL) && (MapListItem->CurrentDirectoryPath[StrLen (MapListItem->CurrentDirectoryPath)-1] == L'\\')) {
+ ASSERT ((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));
+ MapListItem->CurrentDirectoryPath[StrLen (MapListItem->CurrentDirectoryPath)-1] = CHAR_NULL;
}
}
}
+
FreePool (DirectoryName);
//
// if updated the current directory then update the environment variable
//
if (MapListItem == gShellCurMapping) {
Size = 0;
- ASSERT((TempString == NULL && Size == 0) || (TempString != NULL));
- StrnCatGrow(&TempString, &Size, MapListItem->MapName, 0);
- ASSERT((TempString == NULL && Size == 0) || (TempString != NULL));
- StrnCatGrow(&TempString, &Size, MapListItem->CurrentDirectoryPath, 0);
- Status = InternalEfiShellSetEnv(L"cwd", TempString, TRUE);
- FreePool(TempString);
+ ASSERT ((TempString == NULL && Size == 0) || (TempString != NULL));
+ StrnCatGrow (&TempString, &Size, MapListItem->MapName, 0);
+ ASSERT ((TempString == NULL && Size == 0) || (TempString != NULL));
+ StrnCatGrow (&TempString, &Size, MapListItem->CurrentDirectoryPath, 0);
+ Status = InternalEfiShellSetEnv (L"cwd", TempString, TRUE);
+ FreePool (TempString);
return (Status);
}
- return(EFI_SUCCESS);
+
+ return (EFI_SUCCESS);
}
/**
@@ -3117,45 +3266,47 @@ EfiShellSetCurDir( **/
EFI_STATUS
EFIAPI
-EfiShellGetHelpText(
- IN CONST CHAR16 *Command,
- IN CONST CHAR16 *Sections OPTIONAL,
- OUT CHAR16 **HelpText
+EfiShellGetHelpText (
+ IN CONST CHAR16 *Command,
+ IN CONST CHAR16 *Sections OPTIONAL,
+ OUT CHAR16 **HelpText
)
{
CONST CHAR16 *ManFileName;
CHAR16 *FixCommand;
EFI_STATUS Status;
- ASSERT(HelpText != NULL);
+ ASSERT (HelpText != NULL);
FixCommand = NULL;
- ManFileName = ShellCommandGetManFileNameHandler(Command);
+ ManFileName = ShellCommandGetManFileNameHandler (Command);
if (ManFileName != NULL) {
- return (ProcessManFile(ManFileName, Command, Sections, NULL, HelpText));
+ return (ProcessManFile (ManFileName, Command, Sections, NULL, HelpText));
} else {
- if ((StrLen(Command)> 4)
- && (Command[StrLen(Command)-1] == L'i' || Command[StrLen(Command)-1] == L'I')
- && (Command[StrLen(Command)-2] == L'f' || Command[StrLen(Command)-2] == L'F')
- && (Command[StrLen(Command)-3] == L'e' || Command[StrLen(Command)-3] == L'E')
- && (Command[StrLen(Command)-4] == L'.')
- ) {
- FixCommand = AllocateZeroPool(StrSize(Command) - 4 * sizeof (CHAR16));
+ if ( (StrLen (Command) > 4)
+ && ((Command[StrLen (Command)-1] == L'i') || (Command[StrLen (Command)-1] == L'I'))
+ && ((Command[StrLen (Command)-2] == L'f') || (Command[StrLen (Command)-2] == L'F'))
+ && ((Command[StrLen (Command)-3] == L'e') || (Command[StrLen (Command)-3] == L'E'))
+ && (Command[StrLen (Command)-4] == L'.')
+ )
+ {
+ FixCommand = AllocateZeroPool (StrSize (Command) - 4 * sizeof (CHAR16));
if (FixCommand == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- StrnCpyS( FixCommand,
- (StrSize(Command) - 4 * sizeof (CHAR16))/sizeof(CHAR16),
- Command,
- StrLen(Command)-4
- );
- Status = ProcessManFile(FixCommand, FixCommand, Sections, NULL, HelpText);
- FreePool(FixCommand);
+ StrnCpyS (
+ FixCommand,
+ (StrSize (Command) - 4 * sizeof (CHAR16))/sizeof (CHAR16),
+ Command,
+ StrLen (Command)-4
+ );
+ Status = ProcessManFile (FixCommand, FixCommand, Sections, NULL, HelpText);
+ FreePool (FixCommand);
return Status;
} else {
- return (ProcessManFile(Command, Command, Sections, NULL, HelpText));
+ return (ProcessManFile (Command, Command, Sections, NULL, HelpText));
}
}
}
@@ -3170,11 +3321,11 @@ EfiShellGetHelpText( **/
BOOLEAN
EFIAPI
-EfiShellGetPageBreak(
+EfiShellGetPageBreak (
VOID
)
{
- return(ShellInfoObject.PageBreakEnabled);
+ return (ShellInfoObject.PageBreakEnabled);
}
/**
@@ -3187,11 +3338,11 @@ EfiShellGetPageBreak( **/
BOOLEAN
EFIAPI
-EfiShellIsRootShell(
+EfiShellIsRootShell (
VOID
)
{
- return(ShellInfoObject.RootShellInstance);
+ return (ShellInfoObject.RootShellInstance);
}
/**
@@ -3204,23 +3355,22 @@ EfiShellIsRootShell( @return !NULL a list of all alias'
**/
CHAR16 *
-InternalEfiShellGetListAlias(
+InternalEfiShellGetListAlias (
VOID
)
{
-
- EFI_STATUS Status;
- EFI_GUID Guid;
- CHAR16 *VariableName;
- UINTN NameSize;
- UINTN NameBufferSize;
- CHAR16 *RetVal;
- UINTN RetSize;
+ EFI_STATUS Status;
+ EFI_GUID Guid;
+ CHAR16 *VariableName;
+ UINTN NameSize;
+ UINTN NameBufferSize;
+ CHAR16 *RetVal;
+ UINTN RetSize;
NameBufferSize = INIT_NAME_BUFFER_SIZE;
- VariableName = AllocateZeroPool(NameBufferSize);
- RetSize = 0;
- RetVal = NULL;
+ VariableName = AllocateZeroPool (NameBufferSize);
+ RetSize = 0;
+ RetVal = NULL;
if (VariableName == NULL) {
return (NULL);
@@ -3230,37 +3380,38 @@ InternalEfiShellGetListAlias( while (TRUE) {
NameSize = NameBufferSize;
- Status = gRT->GetNextVariableName(&NameSize, VariableName, &Guid);
- if (Status == EFI_NOT_FOUND){
+ Status = gRT->GetNextVariableName (&NameSize, VariableName, &Guid);
+ if (Status == EFI_NOT_FOUND) {
break;
} else if (Status == EFI_BUFFER_TOO_SMALL) {
NameBufferSize = NameSize > NameBufferSize * 2 ? NameSize : NameBufferSize * 2;
- SHELL_FREE_NON_NULL(VariableName);
- VariableName = AllocateZeroPool(NameBufferSize);
+ SHELL_FREE_NON_NULL (VariableName);
+ VariableName = AllocateZeroPool (NameBufferSize);
if (VariableName == NULL) {
Status = EFI_OUT_OF_RESOURCES;
- SHELL_FREE_NON_NULL(RetVal);
+ SHELL_FREE_NON_NULL (RetVal);
RetVal = NULL;
break;
}
NameSize = NameBufferSize;
- Status = gRT->GetNextVariableName(&NameSize, VariableName, &Guid);
+ Status = gRT->GetNextVariableName (&NameSize, VariableName, &Guid);
}
if (EFI_ERROR (Status)) {
- SHELL_FREE_NON_NULL(RetVal);
+ SHELL_FREE_NON_NULL (RetVal);
RetVal = NULL;
break;
}
- if (CompareGuid(&Guid, &gShellAliasGuid)){
- ASSERT((RetVal == NULL && RetSize == 0) || (RetVal != NULL));
- RetVal = StrnCatGrow(&RetVal, &RetSize, VariableName, 0);
- RetVal = StrnCatGrow(&RetVal, &RetSize, L";", 0);
+ if (CompareGuid (&Guid, &gShellAliasGuid)) {
+ ASSERT ((RetVal == NULL && RetSize == 0) || (RetVal != NULL));
+ RetVal = StrnCatGrow (&RetVal, &RetSize, VariableName, 0);
+ RetVal = StrnCatGrow (&RetVal, &RetSize, L";", 0);
} // compare guid
} // while
- SHELL_FREE_NON_NULL(VariableName);
+
+ SHELL_FREE_NON_NULL (VariableName);
return (RetVal);
}
@@ -3275,16 +3426,17 @@ InternalEfiShellGetListAlias( **/
CHAR16 *
ToLower (
- CHAR16 *Str
+ CHAR16 *Str
)
{
- UINTN Index;
+ UINTN Index;
for (Index = 0; Str[Index] != L'\0'; Index++) {
- if (Str[Index] >= L'A' && Str[Index] <= L'Z') {
+ if ((Str[Index] >= L'A') && (Str[Index] <= L'Z')) {
Str[Index] -= (CHAR16)(L'A' - L'a');
}
}
+
return Str;
}
@@ -3308,9 +3460,9 @@ ToLower ( **/
CONST CHAR16 *
EFIAPI
-EfiShellGetAlias(
- IN CONST CHAR16 *Alias,
- OUT BOOLEAN *Volatile OPTIONAL
+EfiShellGetAlias (
+ IN CONST CHAR16 *Alias,
+ OUT BOOLEAN *Volatile OPTIONAL
)
{
CHAR16 *RetVal;
@@ -3326,27 +3478,32 @@ EfiShellGetAlias( if (AliasLower == NULL) {
return NULL;
}
+
ToLower (AliasLower);
if (Volatile == NULL) {
GetVariable2 (AliasLower, &gShellAliasGuid, (VOID **)&AliasVal, NULL);
- FreePool(AliasLower);
- return (AddBufferToFreeList(AliasVal));
+ FreePool (AliasLower);
+ return (AddBufferToFreeList (AliasVal));
}
+
RetSize = 0;
- RetVal = NULL;
- Status = gRT->GetVariable(AliasLower, &gShellAliasGuid, &Attribs, &RetSize, RetVal);
+ RetVal = NULL;
+ Status = gRT->GetVariable (AliasLower, &gShellAliasGuid, &Attribs, &RetSize, RetVal);
if (Status == EFI_BUFFER_TOO_SMALL) {
- RetVal = AllocateZeroPool(RetSize);
- Status = gRT->GetVariable(AliasLower, &gShellAliasGuid, &Attribs, &RetSize, RetVal);
+ RetVal = AllocateZeroPool (RetSize);
+ Status = gRT->GetVariable (AliasLower, &gShellAliasGuid, &Attribs, &RetSize, RetVal);
}
- if (EFI_ERROR(Status)) {
+
+ if (EFI_ERROR (Status)) {
if (RetVal != NULL) {
- FreePool(RetVal);
+ FreePool (RetVal);
}
- FreePool(AliasLower);
+
+ FreePool (AliasLower);
return (NULL);
}
+
if ((EFI_VARIABLE_NON_VOLATILE & Attribs) == EFI_VARIABLE_NON_VOLATILE) {
*Volatile = FALSE;
} else {
@@ -3354,9 +3511,10 @@ EfiShellGetAlias( }
FreePool (AliasLower);
- return (AddBufferToFreeList(RetVal));
+ return (AddBufferToFreeList (RetVal));
}
- return (AddBufferToFreeList(InternalEfiShellGetListAlias()));
+
+ return (AddBufferToFreeList (InternalEfiShellGetListAlias ()));
}
/**
@@ -3376,10 +3534,10 @@ EfiShellGetAlias( @retval EFI_NOT_FOUND the Alias intended to be deleted was not found
**/
EFI_STATUS
-InternalSetAlias(
- IN CONST CHAR16 *Command,
- IN CONST CHAR16 *Alias,
- IN BOOLEAN Volatile
+InternalSetAlias (
+ IN CONST CHAR16 *Command,
+ IN CONST CHAR16 *Alias,
+ IN BOOLEAN Volatile
)
{
EFI_STATUS Status;
@@ -3395,6 +3553,7 @@ InternalSetAlias( Alias = Command;
DeleteAlias = TRUE;
}
+
ASSERT (Alias != NULL);
//
@@ -3404,15 +3563,18 @@ InternalSetAlias( if (AliasLower == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
ToLower (AliasLower);
if (DeleteAlias) {
Status = gRT->SetVariable (AliasLower, &gShellAliasGuid, 0, 0, NULL);
} else {
Status = gRT->SetVariable (
- AliasLower, &gShellAliasGuid,
+ AliasLower,
+ &gShellAliasGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | (Volatile ? 0 : EFI_VARIABLE_NON_VOLATILE),
- StrSize (Command), (VOID *) Command
+ StrSize (Command),
+ (VOID *)Command
);
}
@@ -3444,36 +3606,36 @@ InternalSetAlias( **/
EFI_STATUS
EFIAPI
-EfiShellSetAlias(
- IN CONST CHAR16 *Command,
- IN CONST CHAR16 *Alias,
- IN BOOLEAN Replace,
- IN BOOLEAN Volatile
+EfiShellSetAlias (
+ IN CONST CHAR16 *Command,
+ IN CONST CHAR16 *Alias,
+ IN BOOLEAN Replace,
+ IN BOOLEAN Volatile
)
{
- if (ShellCommandIsOnAliasList(Alias==NULL?Command:Alias)) {
+ if (ShellCommandIsOnAliasList ((Alias == NULL) ? Command : Alias)) {
//
// cant set over a built in alias
//
return (EFI_ACCESS_DENIED);
- } else if (Command == NULL || *Command == CHAR_NULL || StrLen(Command) == 0) {
+ } else if ((Command == NULL) || (*Command == CHAR_NULL) || (StrLen (Command) == 0)) {
//
// Command is null or empty
//
return (EFI_INVALID_PARAMETER);
- } else if (EfiShellGetAlias(Command, NULL) != NULL && !Replace) {
+ } else if ((EfiShellGetAlias (Command, NULL) != NULL) && !Replace) {
//
// Alias already exists, Replace not set
//
return (EFI_ACCESS_DENIED);
} else {
- return (InternalSetAlias(Command, Alias, Volatile));
+ return (InternalSetAlias (Command, Alias, Volatile));
}
}
// Pure FILE_HANDLE operations are passed to FileHandleLib
// these functions are indicated by the *
-EFI_SHELL_PROTOCOL mShellProtocol = {
+EFI_SHELL_PROTOCOL mShellProtocol = {
EfiShellExecute,
EfiShellGetEnv,
EfiShellSetEnv,
@@ -3496,21 +3658,21 @@ EFI_SHELL_PROTOCOL mShellProtocol = { EfiShellDisablePageBreak,
EfiShellGetPageBreak,
EfiShellGetDeviceName,
- (EFI_SHELL_GET_FILE_INFO)FileHandleGetInfo, //*
- (EFI_SHELL_SET_FILE_INFO)FileHandleSetInfo, //*
+ (EFI_SHELL_GET_FILE_INFO)FileHandleGetInfo, // *
+ (EFI_SHELL_SET_FILE_INFO)FileHandleSetInfo, // *
EfiShellOpenFileByName,
EfiShellClose,
EfiShellCreateFile,
- (EFI_SHELL_READ_FILE)FileHandleRead, //*
- (EFI_SHELL_WRITE_FILE)FileHandleWrite, //*
- (EFI_SHELL_DELETE_FILE)FileHandleDelete, //*
+ (EFI_SHELL_READ_FILE)FileHandleRead, // *
+ (EFI_SHELL_WRITE_FILE)FileHandleWrite, // *
+ (EFI_SHELL_DELETE_FILE)FileHandleDelete, // *
EfiShellDeleteFileByName,
- (EFI_SHELL_GET_FILE_POSITION)FileHandleGetPosition, //*
- (EFI_SHELL_SET_FILE_POSITION)FileHandleSetPosition, //*
- (EFI_SHELL_FLUSH_FILE)FileHandleFlush, //*
+ (EFI_SHELL_GET_FILE_POSITION)FileHandleGetPosition, // *
+ (EFI_SHELL_SET_FILE_POSITION)FileHandleSetPosition, // *
+ (EFI_SHELL_FLUSH_FILE)FileHandleFlush, // *
EfiShellFindFiles,
EfiShellFindFilesInDir,
- (EFI_SHELL_GET_FILE_SIZE)FileHandleGetSize, //*
+ (EFI_SHELL_GET_FILE_SIZE)FileHandleGetSize, // *
EfiShellOpenRoot,
EfiShellOpenRootByHandle,
NULL,
@@ -3554,79 +3716,91 @@ CreatePopulateInstallShellProtocol ( return (EFI_INVALID_PARAMETER);
}
- BufferSize = 0;
- Buffer = NULL;
+ BufferSize = 0;
+ Buffer = NULL;
OldProtocolNode = NULL;
- InitializeListHead(&ShellInfoObject.OldShellList.Link);
+ InitializeListHead (&ShellInfoObject.OldShellList.Link);
//
// Initialize EfiShellProtocol object...
//
- Status = gBS->CreateEvent(0,
- 0,
- NULL,
- NULL,
- &mShellProtocol.ExecutionBreak);
- if (EFI_ERROR(Status)) {
+ Status = gBS->CreateEvent (
+ 0,
+ 0,
+ NULL,
+ NULL,
+ &mShellProtocol.ExecutionBreak
+ );
+ if (EFI_ERROR (Status)) {
return (Status);
}
//
// Get the size of the buffer we need.
//
- Status = gBS->LocateHandle(ByProtocol,
- &gEfiShellProtocolGuid,
- NULL,
- &BufferSize,
- Buffer);
+ Status = gBS->LocateHandle (
+ ByProtocol,
+ &gEfiShellProtocolGuid,
+ NULL,
+ &BufferSize,
+ Buffer
+ );
if (Status == EFI_BUFFER_TOO_SMALL) {
//
// Allocate and recall with buffer of correct size
//
- Buffer = AllocateZeroPool(BufferSize);
+ Buffer = AllocateZeroPool (BufferSize);
if (Buffer == NULL) {
return (EFI_OUT_OF_RESOURCES);
}
- Status = gBS->LocateHandle(ByProtocol,
- &gEfiShellProtocolGuid,
- NULL,
- &BufferSize,
- Buffer);
- if (EFI_ERROR(Status)) {
- FreePool(Buffer);
+
+ Status = gBS->LocateHandle (
+ ByProtocol,
+ &gEfiShellProtocolGuid,
+ NULL,
+ &BufferSize,
+ Buffer
+ );
+ if (EFI_ERROR (Status)) {
+ FreePool (Buffer);
return (Status);
}
+
//
// now overwrite each of them, but save the info to restore when we end.
//
- for (HandleCounter = 0 ; HandleCounter < (BufferSize/sizeof(EFI_HANDLE)) ; HandleCounter++) {
- Status = gBS->OpenProtocol(Buffer[HandleCounter],
- &gEfiShellProtocolGuid,
- (VOID **) &OldShell,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (!EFI_ERROR(Status)) {
- OldProtocolNode = AllocateZeroPool(sizeof(SHELL_PROTOCOL_HANDLE_LIST));
+ for (HandleCounter = 0; HandleCounter < (BufferSize/sizeof (EFI_HANDLE)); HandleCounter++) {
+ Status = gBS->OpenProtocol (
+ Buffer[HandleCounter],
+ &gEfiShellProtocolGuid,
+ (VOID **)&OldShell,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (!EFI_ERROR (Status)) {
+ OldProtocolNode = AllocateZeroPool (sizeof (SHELL_PROTOCOL_HANDLE_LIST));
if (OldProtocolNode == NULL) {
if (!IsListEmpty (&ShellInfoObject.OldShellList.Link)) {
CleanUpShellProtocol (&mShellProtocol);
}
+
Status = EFI_OUT_OF_RESOURCES;
break;
}
+
//
// reinstall over the old one...
//
OldProtocolNode->Handle = Buffer[HandleCounter];
OldProtocolNode->Interface = OldShell;
- Status = gBS->ReinstallProtocolInterface(
- OldProtocolNode->Handle,
- &gEfiShellProtocolGuid,
- OldProtocolNode->Interface,
- (VOID*)(&mShellProtocol));
- if (!EFI_ERROR(Status)) {
+ Status = gBS->ReinstallProtocolInterface (
+ OldProtocolNode->Handle,
+ &gEfiShellProtocolGuid,
+ OldProtocolNode->Interface,
+ (VOID *)(&mShellProtocol)
+ );
+ if (!EFI_ERROR (Status)) {
//
// we reinstalled successfully. log this so we can reverse it later.
//
@@ -3634,31 +3808,34 @@ CreatePopulateInstallShellProtocol ( //
// add to the list for subsequent...
//
- InsertTailList(&ShellInfoObject.OldShellList.Link, &OldProtocolNode->Link);
+ InsertTailList (&ShellInfoObject.OldShellList.Link, &OldProtocolNode->Link);
}
}
}
- FreePool(Buffer);
+
+ FreePool (Buffer);
} else if (Status == EFI_NOT_FOUND) {
- ASSERT(IsListEmpty(&ShellInfoObject.OldShellList.Link));
+ ASSERT (IsListEmpty (&ShellInfoObject.OldShellList.Link));
//
// no one else published yet. just publish it ourselves.
//
Status = gBS->InstallProtocolInterface (
- &gImageHandle,
- &gEfiShellProtocolGuid,
- EFI_NATIVE_INTERFACE,
- (VOID*)(&mShellProtocol));
+ &gImageHandle,
+ &gEfiShellProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ (VOID *)(&mShellProtocol)
+ );
}
- if (PcdGetBool(PcdShellSupportOldProtocols)){
- ///@todo support ShellEnvironment2
- ///@todo do we need to support ShellEnvironment (not ShellEnvironment2) also?
+ if (PcdGetBool (PcdShellSupportOldProtocols)) {
+ /// @todo support ShellEnvironment2
+ /// @todo do we need to support ShellEnvironment (not ShellEnvironment2) also?
}
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR (Status)) {
*NewShell = &mShellProtocol;
}
+
return (Status);
}
@@ -3677,16 +3854,17 @@ CleanUpShellProtocol ( IN OUT EFI_SHELL_PROTOCOL *NewShell
)
{
- SHELL_PROTOCOL_HANDLE_LIST *Node2;
+ SHELL_PROTOCOL_HANDLE_LIST *Node2;
//
// if we need to restore old protocols...
//
- if (!IsListEmpty(&ShellInfoObject.OldShellList.Link)) {
- for (Node2 = (SHELL_PROTOCOL_HANDLE_LIST *) GetFirstNode (&ShellInfoObject.OldShellList.Link)
+ if (!IsListEmpty (&ShellInfoObject.OldShellList.Link)) {
+ for (Node2 = (SHELL_PROTOCOL_HANDLE_LIST *)GetFirstNode (&ShellInfoObject.OldShellList.Link)
; !IsListEmpty (&ShellInfoObject.OldShellList.Link)
- ; Node2 = (SHELL_PROTOCOL_HANDLE_LIST *) GetFirstNode (&ShellInfoObject.OldShellList.Link)
- ) {
+ ; Node2 = (SHELL_PROTOCOL_HANDLE_LIST *)GetFirstNode (&ShellInfoObject.OldShellList.Link)
+ )
+ {
RemoveEntryList (&Node2->Link);
gBS->ReinstallProtocolInterface (Node2->Handle, &gEfiShellProtocolGuid, NewShell, Node2->Interface);
FreePool (Node2);
@@ -3697,6 +3875,7 @@ CleanUpShellProtocol ( //
gBS->UninstallProtocolInterface (gImageHandle, &gEfiShellProtocolGuid, NewShell);
}
+
return EFI_SUCCESS;
}
@@ -3712,32 +3891,34 @@ CleanUpShellEnvironment ( IN OUT EFI_SHELL_PROTOCOL *NewShell
)
{
- EFI_STATUS Status;
- EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *SimpleEx;
+ EFI_STATUS Status;
+ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *SimpleEx;
CleanUpShellProtocol (NewShell);
- Status = gBS->CloseEvent(NewShell->ExecutionBreak);
+ Status = gBS->CloseEvent (NewShell->ExecutionBreak);
NewShell->ExecutionBreak = NULL;
- Status = gBS->OpenProtocol(
- gST->ConsoleInHandle,
- &gEfiSimpleTextInputExProtocolGuid,
- (VOID**)&SimpleEx,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+ Status = gBS->OpenProtocol (
+ gST->ConsoleInHandle,
+ &gEfiSimpleTextInputExProtocolGuid,
+ (VOID **)&SimpleEx,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
if (!EFI_ERROR (Status)) {
- Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlCNotifyHandle1);
- Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlCNotifyHandle2);
- Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlCNotifyHandle3);
- Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlCNotifyHandle4);
- Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlSNotifyHandle1);
- Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlSNotifyHandle2);
- Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlSNotifyHandle3);
- Status = SimpleEx->UnregisterKeyNotify(SimpleEx, ShellInfoObject.CtrlSNotifyHandle4);
+ Status = SimpleEx->UnregisterKeyNotify (SimpleEx, ShellInfoObject.CtrlCNotifyHandle1);
+ Status = SimpleEx->UnregisterKeyNotify (SimpleEx, ShellInfoObject.CtrlCNotifyHandle2);
+ Status = SimpleEx->UnregisterKeyNotify (SimpleEx, ShellInfoObject.CtrlCNotifyHandle3);
+ Status = SimpleEx->UnregisterKeyNotify (SimpleEx, ShellInfoObject.CtrlCNotifyHandle4);
+ Status = SimpleEx->UnregisterKeyNotify (SimpleEx, ShellInfoObject.CtrlSNotifyHandle1);
+ Status = SimpleEx->UnregisterKeyNotify (SimpleEx, ShellInfoObject.CtrlSNotifyHandle2);
+ Status = SimpleEx->UnregisterKeyNotify (SimpleEx, ShellInfoObject.CtrlSNotifyHandle3);
+ Status = SimpleEx->UnregisterKeyNotify (SimpleEx, ShellInfoObject.CtrlSNotifyHandle4);
}
+
return (Status);
}
@@ -3750,23 +3931,27 @@ CleanUpShellEnvironment ( **/
EFI_STATUS
EFIAPI
-NotificationFunction(
- IN EFI_KEY_DATA *KeyData
+NotificationFunction (
+ IN EFI_KEY_DATA *KeyData
)
{
- if ( ((KeyData->Key.UnicodeChar == L'c') &&
- (KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED) || KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED))) ||
+ if (((KeyData->Key.UnicodeChar == L'c') &&
+ ((KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED)) || (KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED)))) ||
(KeyData->Key.UnicodeChar == 3)
- ){
+ )
+ {
if (ShellInfoObject.NewEfiShellProtocol->ExecutionBreak == NULL) {
return (EFI_UNSUPPORTED);
}
- return (gBS->SignalEvent(ShellInfoObject.NewEfiShellProtocol->ExecutionBreak));
- } else if ((KeyData->Key.UnicodeChar == L's') &&
- (KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED) || KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED))
- ){
+
+ return (gBS->SignalEvent (ShellInfoObject.NewEfiShellProtocol->ExecutionBreak));
+ } else if ((KeyData->Key.UnicodeChar == L's') &&
+ ((KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED)) || (KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED)))
+ )
+ {
ShellInfoObject.HaltOutput = TRUE;
}
+
return (EFI_SUCCESS);
}
@@ -3778,28 +3963,30 @@ NotificationFunction( @retval EFI_OUT_OF_RESOURCES There is not enough memory available.
**/
EFI_STATUS
-InernalEfiShellStartMonitor(
+InernalEfiShellStartMonitor (
VOID
)
{
- EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *SimpleEx;
- EFI_KEY_DATA KeyData;
- EFI_STATUS Status;
-
- Status = gBS->OpenProtocol(
- gST->ConsoleInHandle,
- &gEfiSimpleTextInputExProtocolGuid,
- (VOID**)&SimpleEx,
- gImageHandle,
- NULL,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL);
- if (EFI_ERROR(Status)) {
- ShellPrintHiiEx(
+ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *SimpleEx;
+ EFI_KEY_DATA KeyData;
+ EFI_STATUS Status;
+
+ Status = gBS->OpenProtocol (
+ gST->ConsoleInHandle,
+ &gEfiSimpleTextInputExProtocolGuid,
+ (VOID **)&SimpleEx,
+ gImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
+ ShellPrintHiiEx (
-1,
-1,
NULL,
STRING_TOKEN (STR_SHELL_NO_IN_EX),
- ShellInfoObject.HiiHandle);
+ ShellInfoObject.HiiHandle
+ );
return (EFI_SUCCESS);
}
@@ -3812,37 +3999,43 @@ InernalEfiShellStartMonitor( KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED;
KeyData.Key.UnicodeChar = L'c';
- Status = SimpleEx->RegisterKeyNotify(
- SimpleEx,
- &KeyData,
- NotificationFunction,
- &ShellInfoObject.CtrlCNotifyHandle1);
+ Status = SimpleEx->RegisterKeyNotify (
+ SimpleEx,
+ &KeyData,
+ NotificationFunction,
+ &ShellInfoObject.CtrlCNotifyHandle1
+ );
- KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED;
- if (!EFI_ERROR(Status)) {
- Status = SimpleEx->RegisterKeyNotify(
- SimpleEx,
- &KeyData,
- NotificationFunction,
- &ShellInfoObject.CtrlCNotifyHandle2);
+ KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED;
+ if (!EFI_ERROR (Status)) {
+ Status = SimpleEx->RegisterKeyNotify (
+ SimpleEx,
+ &KeyData,
+ NotificationFunction,
+ &ShellInfoObject.CtrlCNotifyHandle2
+ );
}
- KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED;
- KeyData.Key.UnicodeChar = 3;
- if (!EFI_ERROR(Status)) {
- Status = SimpleEx->RegisterKeyNotify(
- SimpleEx,
- &KeyData,
- NotificationFunction,
- &ShellInfoObject.CtrlCNotifyHandle3);
- }
- KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED;
- if (!EFI_ERROR(Status)) {
- Status = SimpleEx->RegisterKeyNotify(
- SimpleEx,
- &KeyData,
- NotificationFunction,
- &ShellInfoObject.CtrlCNotifyHandle4);
+
+ KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED;
+ KeyData.Key.UnicodeChar = 3;
+ if (!EFI_ERROR (Status)) {
+ Status = SimpleEx->RegisterKeyNotify (
+ SimpleEx,
+ &KeyData,
+ NotificationFunction,
+ &ShellInfoObject.CtrlCNotifyHandle3
+ );
+ }
+
+ KeyData.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED;
+ if (!EFI_ERROR (Status)) {
+ Status = SimpleEx->RegisterKeyNotify (
+ SimpleEx,
+ &KeyData,
+ NotificationFunction,
+ &ShellInfoObject.CtrlCNotifyHandle4
+ );
}
+
return (Status);
}
-
diff --git a/ShellPkg/Application/Shell/ShellProtocol.h b/ShellPkg/Application/Shell/ShellProtocol.h index 472d98d..3d872ff 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.h +++ b/ShellPkg/Application/Shell/ShellProtocol.h @@ -14,13 +14,13 @@ #include "Shell.h"
typedef struct {
- LIST_ENTRY Link;
- EFI_SHELL_PROTOCOL *Interface;
- EFI_HANDLE Handle;
+ LIST_ENTRY Link;
+ EFI_SHELL_PROTOCOL *Interface;
+ EFI_HANDLE Handle;
} SHELL_PROTOCOL_HANDLE_LIST;
// flags values...
-#define SHELL_MAP_FLAGS_CONSIST BIT1
+#define SHELL_MAP_FLAGS_CONSIST BIT1
/**
Function to create and install on the current handle.
@@ -87,9 +87,9 @@ CleanUpShellEnvironment ( **/
EFI_STATUS
EFIAPI
-EfiShellSetMap(
- IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL,
- IN CONST CHAR16 *Mapping
+EfiShellSetMap (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL,
+ IN CONST CHAR16 *Mapping
);
/**
@@ -107,8 +107,8 @@ EfiShellSetMap( **/
CONST EFI_DEVICE_PATH_PROTOCOL *
EFIAPI
-EfiShellGetDevicePathFromMap(
- IN CONST CHAR16 *Mapping
+EfiShellGetDevicePathFromMap (
+ IN CONST CHAR16 *Mapping
);
/**
@@ -130,8 +130,8 @@ EfiShellGetDevicePathFromMap( **/
CONST CHAR16 *
EFIAPI
-EfiShellGetMapFromDevicePath(
- IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
+EfiShellGetMapFromDevicePath (
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
);
/**
@@ -149,8 +149,8 @@ EfiShellGetMapFromDevicePath( **/
CHAR16 *
EFIAPI
-EfiShellGetFilePathFromDevicePath(
- IN CONST EFI_DEVICE_PATH_PROTOCOL *Path
+EfiShellGetFilePathFromDevicePath (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *Path
);
/**
@@ -166,8 +166,8 @@ EfiShellGetFilePathFromDevicePath( **/
EFI_DEVICE_PATH_PROTOCOL *
EFIAPI
-EfiShellGetDevicePathFromFilePath(
- IN CONST CHAR16 *Path
+EfiShellGetDevicePathFromFilePath (
+ IN CONST CHAR16 *Path
);
/**
@@ -208,11 +208,11 @@ EfiShellGetDevicePathFromFilePath( **/
EFI_STATUS
EFIAPI
-EfiShellGetDeviceName(
- IN EFI_HANDLE DeviceHandle,
- IN EFI_SHELL_DEVICE_NAME_FLAGS Flags,
- IN CHAR8 *Language,
- OUT CHAR16 **BestDeviceName
+EfiShellGetDeviceName (
+ IN EFI_HANDLE DeviceHandle,
+ IN EFI_SHELL_DEVICE_NAME_FLAGS Flags,
+ IN CHAR8 *Language,
+ OUT CHAR16 **BestDeviceName
);
/**
@@ -232,9 +232,9 @@ EfiShellGetDeviceName( **/
EFI_STATUS
EFIAPI
-EfiShellOpenRootByHandle(
- IN EFI_HANDLE DeviceHandle,
- OUT SHELL_FILE_HANDLE *FileHandle
+EfiShellOpenRootByHandle (
+ IN EFI_HANDLE DeviceHandle,
+ OUT SHELL_FILE_HANDLE *FileHandle
);
/**
@@ -255,9 +255,9 @@ EfiShellOpenRootByHandle( **/
EFI_STATUS
EFIAPI
-EfiShellOpenRoot(
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- OUT SHELL_FILE_HANDLE *FileHandle
+EfiShellOpenRoot (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ OUT SHELL_FILE_HANDLE *FileHandle
);
/**
@@ -287,11 +287,11 @@ EfiShellBatchIsActive ( @retval other an error occurred.
**/
EFI_STATUS
-InternalOpenFileDevicePath(
- IN OUT EFI_DEVICE_PATH_PROTOCOL *DevicePath2,
- OUT SHELL_FILE_HANDLE *FileHandle,
- IN UINT64 OpenMode,
- IN UINT64 Attributes OPTIONAL
+InternalOpenFileDevicePath (
+ IN OUT EFI_DEVICE_PATH_PROTOCOL *DevicePath2,
+ OUT SHELL_FILE_HANDLE *FileHandle,
+ IN UINT64 OpenMode,
+ IN UINT64 Attributes OPTIONAL
);
/**
@@ -332,10 +332,10 @@ InternalOpenFileDevicePath( **/
EFI_STATUS
EFIAPI
-EfiShellCreateFile(
- IN CONST CHAR16 *FileName,
- IN UINT64 FileAttribs,
- OUT SHELL_FILE_HANDLE *FileHandle
+EfiShellCreateFile (
+ IN CONST CHAR16 *FileName,
+ IN UINT64 FileAttribs,
+ OUT SHELL_FILE_HANDLE *FileHandle
);
/**
@@ -392,10 +392,10 @@ EfiShellCreateFile( **/
EFI_STATUS
EFIAPI
-EfiShellOpenFileByName(
- IN CONST CHAR16 *FileName,
- OUT SHELL_FILE_HANDLE *FileHandle,
- IN UINT64 OpenMode
+EfiShellOpenFileByName (
+ IN CONST CHAR16 *FileName,
+ OUT SHELL_FILE_HANDLE *FileHandle,
+ IN UINT64 OpenMode
);
/**
@@ -412,8 +412,8 @@ EfiShellOpenFileByName( **/
EFI_STATUS
EFIAPI
-EfiShellDeleteFileByName(
- IN CONST CHAR16 *FileName
+EfiShellDeleteFileByName (
+ IN CONST CHAR16 *FileName
);
/**
@@ -456,12 +456,12 @@ EfiShellEnablePageBreak ( @retval EFI_UNSUPPORTED Nested shell invocations are not allowed.
**/
EFI_STATUS
-InternalShellExecuteDevicePath(
- IN CONST EFI_HANDLE *ParentImageHandle,
- IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- IN CONST CHAR16 *CommandLine OPTIONAL,
- IN CONST CHAR16 **Environment OPTIONAL,
- OUT EFI_STATUS *StartImageStatus OPTIONAL
+InternalShellExecuteDevicePath (
+ IN CONST EFI_HANDLE *ParentImageHandle,
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ IN CONST CHAR16 *CommandLine OPTIONAL,
+ IN CONST CHAR16 **Environment OPTIONAL,
+ OUT EFI_STATUS *StartImageStatus OPTIONAL
);
/**
@@ -497,11 +497,11 @@ InternalShellExecuteDevicePath( **/
EFI_STATUS
EFIAPI
-EfiShellExecute(
- IN EFI_HANDLE *ParentImageHandle,
- IN CHAR16 *CommandLine OPTIONAL,
- IN CHAR16 **Environment OPTIONAL,
- OUT EFI_STATUS *StatusCode OPTIONAL
+EfiShellExecute (
+ IN EFI_HANDLE *ParentImageHandle,
+ IN CHAR16 *CommandLine OPTIONAL,
+ IN CHAR16 **Environment OPTIONAL,
+ OUT EFI_STATUS *StatusCode OPTIONAL
);
/**
@@ -513,8 +513,8 @@ EfiShellExecute( @param FileListNode pointer to the list node to free
**/
VOID
-FreeShellFileInfoNode(
- IN EFI_SHELL_FILE_INFO *FileListNode
+FreeShellFileInfoNode (
+ IN EFI_SHELL_FILE_INFO *FileListNode
);
/**
@@ -531,8 +531,8 @@ FreeShellFileInfoNode( **/
EFI_STATUS
EFIAPI
-EfiShellFreeFileList(
- IN EFI_SHELL_FILE_INFO **FileList
+EfiShellFreeFileList (
+ IN EFI_SHELL_FILE_INFO **FileList
);
/**
@@ -547,8 +547,8 @@ EfiShellFreeFileList( **/
EFI_STATUS
EFIAPI
-EfiShellRemoveDupInFileList(
- IN EFI_SHELL_FILE_INFO **FileList
+EfiShellRemoveDupInFileList (
+ IN EFI_SHELL_FILE_INFO **FileList
);
/**
@@ -563,12 +563,12 @@ EfiShellRemoveDupInFileList( **/
EFI_SHELL_FILE_INFO *
-CreateAndPopulateShellFileInfo(
- IN CONST CHAR16 *BasePath,
- IN CONST EFI_STATUS Status,
- IN CONST CHAR16 *FileName,
- IN CONST SHELL_FILE_HANDLE Handle,
- IN CONST EFI_FILE_INFO *Info
+CreateAndPopulateShellFileInfo (
+ IN CONST CHAR16 *BasePath,
+ IN CONST EFI_STATUS Status,
+ IN CONST CHAR16 *FileName,
+ IN CONST SHELL_FILE_HANDLE Handle,
+ IN CONST EFI_FILE_INFO *Info
);
/**
@@ -586,9 +586,9 @@ CreateAndPopulateShellFileInfo( **/
EFI_STATUS
EFIAPI
-EfiShellFindFilesInDir(
- IN SHELL_FILE_HANDLE FileDirHandle,
- OUT EFI_SHELL_FILE_INFO **FileList
+EfiShellFindFilesInDir (
+ IN SHELL_FILE_HANDLE FileDirHandle,
+ OUT EFI_SHELL_FILE_INFO **FileList
);
/**
@@ -619,9 +619,9 @@ EfiShellFindFilesInDir( **/
EFI_STATUS
EFIAPI
-EfiShellFindFiles(
- IN CONST CHAR16 *FilePattern,
- OUT EFI_SHELL_FILE_INFO **FileList
+EfiShellFindFiles (
+ IN CONST CHAR16 *FilePattern,
+ OUT EFI_SHELL_FILE_INFO **FileList
);
/**
@@ -641,10 +641,10 @@ EfiShellFindFiles( **/
EFI_STATUS
EFIAPI
-EfiShellOpenFileList(
- IN CHAR16 *Path,
- IN UINT64 OpenMode,
- IN OUT EFI_SHELL_FILE_INFO **FileList
+EfiShellOpenFileList (
+ IN CHAR16 *Path,
+ IN UINT64 OpenMode,
+ IN OUT EFI_SHELL_FILE_INFO **FileList
);
/**
@@ -660,8 +660,8 @@ EfiShellOpenFileList( **/
CONST CHAR16 *
EFIAPI
-EfiShellGetEnv(
- IN CONST CHAR16 *Name
+EfiShellGetEnv (
+ IN CONST CHAR16 *Name
);
/**
@@ -687,10 +687,10 @@ EfiShellGetEnv( **/
EFI_STATUS
EFIAPI
-EfiShellSetEnv(
- IN CONST CHAR16 *Name,
- IN CONST CHAR16 *Value,
- IN BOOLEAN Volatile
+EfiShellSetEnv (
+ IN CONST CHAR16 *Name,
+ IN CONST CHAR16 *Value,
+ IN BOOLEAN Volatile
);
/**
@@ -709,8 +709,8 @@ EfiShellSetEnv( **/
CONST CHAR16 *
EFIAPI
-EfiShellGetCurDir(
- IN CONST CHAR16 *FileSystemMapping OPTIONAL
+EfiShellGetCurDir (
+ IN CONST CHAR16 *FileSystemMapping OPTIONAL
);
/**
@@ -738,9 +738,9 @@ EfiShellGetCurDir( **/
EFI_STATUS
EFIAPI
-EfiShellSetCurDir(
- IN CONST CHAR16 *FileSystem OPTIONAL,
- IN CONST CHAR16 *Dir
+EfiShellSetCurDir (
+ IN CONST CHAR16 *FileSystem OPTIONAL,
+ IN CONST CHAR16 *Dir
);
/**
@@ -770,10 +770,10 @@ EfiShellSetCurDir( **/
EFI_STATUS
EFIAPI
-EfiShellGetHelpText(
- IN CONST CHAR16 *Command,
- IN CONST CHAR16 *Sections OPTIONAL,
- OUT CHAR16 **HelpText
+EfiShellGetHelpText (
+ IN CONST CHAR16 *Command,
+ IN CONST CHAR16 *Sections OPTIONAL,
+ OUT CHAR16 **HelpText
);
/**
@@ -786,7 +786,7 @@ EfiShellGetHelpText( **/
BOOLEAN
EFIAPI
-EfiShellGetPageBreak(
+EfiShellGetPageBreak (
VOID
);
@@ -800,7 +800,7 @@ EfiShellGetPageBreak( **/
BOOLEAN
EFIAPI
-EfiShellIsRootShell(
+EfiShellIsRootShell (
VOID
);
@@ -823,9 +823,9 @@ EfiShellIsRootShell( **/
CONST CHAR16 *
EFIAPI
-EfiShellGetAlias(
- IN CONST CHAR16 *Command,
- OUT BOOLEAN *Volatile OPTIONAL
+EfiShellGetAlias (
+ IN CONST CHAR16 *Command,
+ OUT BOOLEAN *Volatile OPTIONAL
);
/**
@@ -845,10 +845,10 @@ EfiShellGetAlias( @retval EFI_NOT_FOUND the Alias intended to be deleted was not found
**/
EFI_STATUS
-InternalSetAlias(
- IN CONST CHAR16 *Command,
- IN CONST CHAR16 *Alias OPTIONAL,
- IN BOOLEAN Volatile
+InternalSetAlias (
+ IN CONST CHAR16 *Command,
+ IN CONST CHAR16 *Alias OPTIONAL,
+ IN BOOLEAN Volatile
);
/**
@@ -873,11 +873,11 @@ InternalSetAlias( **/
EFI_STATUS
EFIAPI
-EfiShellSetAlias(
- IN CONST CHAR16 *Command,
- IN CONST CHAR16 *Alias OPTIONAL,
- IN BOOLEAN Replace,
- IN BOOLEAN Volatile
+EfiShellSetAlias (
+ IN CONST CHAR16 *Command,
+ IN CONST CHAR16 *Alias OPTIONAL,
+ IN BOOLEAN Replace,
+ IN BOOLEAN Volatile
);
/**
@@ -889,8 +889,8 @@ EfiShellSetAlias( @param FileListNode pointer to the list node to free
**/
VOID
-InternalFreeShellFileInfoNode(
- IN EFI_SHELL_FILE_INFO *FileListNode
+InternalFreeShellFileInfoNode (
+ IN EFI_SHELL_FILE_INFO *FileListNode
);
/**
@@ -904,10 +904,10 @@ InternalFreeShellFileInfoNode( @retval EFI_SUCCESS The environment variable was successfully updated.
**/
EFI_STATUS
-InternalEfiShellSetEnv(
- IN CONST CHAR16 *Name,
- IN CONST CHAR16 *Value,
- IN BOOLEAN Volatile
+InternalEfiShellSetEnv (
+ IN CONST CHAR16 *Name,
+ IN CONST CHAR16 *Value,
+ IN BOOLEAN Volatile
);
/**
@@ -918,7 +918,7 @@ InternalEfiShellSetEnv( @retval EFI_OUT_OF_RESOURCES There is not enough memory available.
**/
EFI_STATUS
-InernalEfiShellStartMonitor(
+InernalEfiShellStartMonitor (
VOID
);
@@ -931,8 +931,8 @@ InernalEfiShellStartMonitor( **/
EFI_STATUS
EFIAPI
-NotificationFunction(
- IN EFI_KEY_DATA *KeyData
+NotificationFunction (
+ IN EFI_KEY_DATA *KeyData
);
-#endif //_SHELL_PROTOCOL_HEADER_
+#endif //_SHELL_PROTOCOL_HEADER_
|