**/\r
EFI_STATUS\r
TypeFileByHandle (\r
- IN SHELL_FILE_HANDLE Handle,\r
- IN BOOLEAN Ascii,\r
- IN BOOLEAN UCS2\r
+ IN SHELL_FILE_HANDLE Handle,\r
+ IN BOOLEAN Ascii,\r
+ IN BOOLEAN UCS2\r
)\r
{\r
UINTN ReadSize;\r
CHAR16 AsciiChar;\r
CHAR16 Ucs2Char;\r
\r
- ReadSize = PcdGet32(PcdShellFileOperationSize);\r
- AllocatedBuffer = AllocateZeroPool(ReadSize);\r
+ ReadSize = PcdGet32 (PcdShellFileOperationSize);\r
+ AllocatedBuffer = AllocateZeroPool (ReadSize);\r
if (AllocatedBuffer == NULL) {\r
return (EFI_OUT_OF_RESOURCES);\r
}\r
\r
- Status = ShellSetFilePosition(Handle, 0);\r
- ASSERT_EFI_ERROR(Status);\r
+ Status = ShellSetFilePosition (Handle, 0);\r
+ ASSERT_EFI_ERROR (Status);\r
\r
- while (ReadSize == ((UINTN)PcdGet32(PcdShellFileOperationSize))) {\r
+ while (ReadSize == ((UINTN)PcdGet32 (PcdShellFileOperationSize))) {\r
Buffer = AllocatedBuffer;\r
- ZeroMem(Buffer, ReadSize);\r
- Status = ShellReadFile(Handle, &ReadSize, Buffer);\r
- if (EFI_ERROR(Status)){\r
+ ZeroMem (Buffer, ReadSize);\r
+ Status = ShellReadFile (Handle, &ReadSize, Buffer);\r
+ if (EFI_ERROR (Status)) {\r
break;\r
}\r
\r
if (!(Ascii|UCS2)) {\r
- if (*(UINT16*)Buffer == gUnicodeFileTag) {\r
+ if (*(UINT16 *)Buffer == gUnicodeFileTag) {\r
UCS2 = TRUE;\r
} else {\r
Ascii = TRUE;\r
\r
if (Ascii) {\r
LoopSize = ReadSize;\r
- for (LoopVar = 0 ; LoopVar < LoopSize ; LoopVar++) {\r
+ for (LoopVar = 0; LoopVar < LoopSize; LoopVar++) {\r
//\r
// The valid range of ASCII characters is 0x20-0x7E.\r
// Display "." when there is an invalid character.\r
//\r
AsciiChar = CHAR_NULL;\r
- AsciiChar = ((CHAR8*)Buffer)[LoopVar];\r
- if (AsciiChar == '\r' || AsciiChar == '\n') {\r
+ AsciiChar = ((CHAR8 *)Buffer)[LoopVar];\r
+ if ((AsciiChar == '\r') || (AsciiChar == '\n')) {\r
//\r
// Allow Line Feed (LF) (0xA) & Carriage Return (CR) (0xD)\r
// characters to be displayed as is.\r
//\r
- if ((AsciiChar == '\n' && LoopVar == 0) ||\r
- (AsciiChar == '\n' && ((CHAR8*)Buffer)[LoopVar-1] != '\r')) {\r
+ if (((AsciiChar == '\n') && (LoopVar == 0)) ||\r
+ ((AsciiChar == '\n') && (((CHAR8 *)Buffer)[LoopVar-1] != '\r')))\r
+ {\r
//\r
// In case file begin with single line Feed or Line Feed (0xA) is\r
// encountered & Carriage Return (0xD) was not previous character,\r
//\r
// For all other characters which are not printable, display '.'\r
//\r
- if (AsciiChar < 0x20 || AsciiChar >= 0x7F) {\r
+ if ((AsciiChar < 0x20) || (AsciiChar >= 0x7F)) {\r
AsciiChar = '.';\r
}\r
}\r
+\r
ShellPrintEx (-1, -1, L"%c", AsciiChar);\r
}\r
} else {\r
- if (*(UINT16*)Buffer == gUnicodeFileTag) {\r
+ if (*(UINT16 *)Buffer == gUnicodeFileTag) {\r
//\r
// For unicode files, skip displaying the byte order marker.\r
//\r
- Buffer = ((UINT16*)Buffer) + 1;\r
+ Buffer = ((UINT16 *)Buffer) + 1;\r
LoopSize = (ReadSize / (sizeof (CHAR16))) - 1;\r
} else {\r
LoopSize = ReadSize / (sizeof (CHAR16));\r
}\r
\r
- for (LoopVar = 0 ; LoopVar < LoopSize ; LoopVar++) {\r
+ for (LoopVar = 0; LoopVar < LoopSize; LoopVar++) {\r
//\r
// An invalid range of characters is 0x0-0x1F.\r
// Display "." when there is an invalid character.\r
//\r
Ucs2Char = CHAR_NULL;\r
- Ucs2Char = ((CHAR16*)Buffer)[LoopVar];\r
- if (Ucs2Char == '\r' || Ucs2Char == '\n') {\r
+ Ucs2Char = ((CHAR16 *)Buffer)[LoopVar];\r
+ if ((Ucs2Char == '\r') || (Ucs2Char == '\n')) {\r
//\r
// Allow Line Feed (LF) (0xA) & Carriage Return (CR) (0xD)\r
// characters to be displayed as is.\r
//\r
- if ((Ucs2Char == '\n' && LoopVar == 0) ||\r
- (Ucs2Char == '\n' && ((CHAR16*)Buffer)[LoopVar-1] != '\r')) {\r
+ if (((Ucs2Char == '\n') && (LoopVar == 0)) ||\r
+ ((Ucs2Char == '\n') && (((CHAR16 *)Buffer)[LoopVar-1] != '\r')))\r
+ {\r
//\r
// In case file begin with single line Feed or Line Feed (0xA) is\r
// encountered & Carriage Return (0xD) was not previous character,\r
ShellPrintEx (-1, -1, L"\r\n");\r
continue;\r
}\r
- }\r
- else if (Ucs2Char < 0x20) {\r
+ } else if (Ucs2Char < 0x20) {\r
//\r
// For all other characters which are not printable, display '.'\r
//\r
Ucs2Char = L'.';\r
}\r
+\r
ShellPrintEx (-1, -1, L"%c", Ucs2Char);\r
}\r
}\r
\r
- if (ShellGetExecutionBreakFlag()) {\r
+ if (ShellGetExecutionBreakFlag ()) {\r
break;\r
}\r
}\r
+\r
FreePool (AllocatedBuffer);\r
ShellPrintEx (-1, -1, L"\r\n");\r
return (Status);\r
}\r
\r
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {\r
- {L"-a", TypeFlag},\r
- {L"-u", TypeFlag},\r
- {NULL, TypeMax}\r
- };\r
+STATIC CONST SHELL_PARAM_ITEM ParamList[] = {\r
+ { L"-a", TypeFlag },\r
+ { L"-u", TypeFlag },\r
+ { NULL, TypeMax }\r
+};\r
\r
/**\r
Function for 'type' command.\r
IN EFI_SYSTEM_TABLE *SystemTable\r
)\r
{\r
- EFI_STATUS Status;\r
- LIST_ENTRY *Package;\r
- CHAR16 *ProblemParam;\r
- CONST CHAR16 *Param;\r
- SHELL_STATUS ShellStatus;\r
- UINTN ParamCount;\r
- EFI_SHELL_FILE_INFO *FileList;\r
- EFI_SHELL_FILE_INFO *Node;\r
- BOOLEAN AsciiMode;\r
- BOOLEAN UnicodeMode;\r
-\r
- ProblemParam = NULL;\r
- ShellStatus = SHELL_SUCCESS;\r
- ParamCount = 0;\r
- FileList = NULL;\r
+ EFI_STATUS Status;\r
+ LIST_ENTRY *Package;\r
+ CHAR16 *ProblemParam;\r
+ CONST CHAR16 *Param;\r
+ SHELL_STATUS ShellStatus;\r
+ UINTN ParamCount;\r
+ EFI_SHELL_FILE_INFO *FileList;\r
+ EFI_SHELL_FILE_INFO *Node;\r
+ BOOLEAN AsciiMode;\r
+ BOOLEAN UnicodeMode;\r
+\r
+ ProblemParam = NULL;\r
+ ShellStatus = SHELL_SUCCESS;\r
+ ParamCount = 0;\r
+ FileList = NULL;\r
\r
//\r
// initialize the shell lib (we must be in non-auto-init...)\r
//\r
- Status = ShellInitialize();\r
- ASSERT_EFI_ERROR(Status);\r
+ Status = ShellInitialize ();\r
+ ASSERT_EFI_ERROR (Status);\r
\r
- Status = CommandInit();\r
- ASSERT_EFI_ERROR(Status);\r
+ Status = CommandInit ();\r
+ ASSERT_EFI_ERROR (Status);\r
\r
//\r
// parse the command line\r
//\r
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);\r
- if (EFI_ERROR(Status)) {\r
- if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"type", ProblemParam);\r
- FreePool(ProblemParam);\r
+ if (EFI_ERROR (Status)) {\r
+ if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {\r
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"type", ProblemParam);\r
+ FreePool (ProblemParam);\r
ShellStatus = SHELL_INVALID_PARAMETER;\r
} else {\r
- ASSERT(FALSE);\r
+ ASSERT (FALSE);\r
}\r
} else {\r
//\r
// check for "-?"\r
//\r
- if (ShellCommandLineGetFlag(Package, L"-?")) {\r
- ASSERT(FALSE);\r
+ if (ShellCommandLineGetFlag (Package, L"-?")) {\r
+ ASSERT (FALSE);\r
}\r
- AsciiMode = ShellCommandLineGetFlag(Package, L"-a");\r
- UnicodeMode = ShellCommandLineGetFlag(Package, L"-u");\r
+\r
+ AsciiMode = ShellCommandLineGetFlag (Package, L"-a");\r
+ UnicodeMode = ShellCommandLineGetFlag (Package, L"-u");\r
\r
if (AsciiMode && UnicodeMode) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel3HiiHandle, L"type", L"-a & -u");\r
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel3HiiHandle, L"type", L"-a & -u");\r
ShellStatus = SHELL_INVALID_PARAMETER;\r
- } else if (ShellCommandLineGetRawValue(Package, 1) == NULL) {\r
+ } else if (ShellCommandLineGetRawValue (Package, 1) == NULL) {\r
//\r
// we insufficient parameters\r
//\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel3HiiHandle, L"type");\r
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel3HiiHandle, L"type");\r
ShellStatus = SHELL_INVALID_PARAMETER;\r
} else {\r
//\r
// get a list with each file specified by parameters\r
// if parameter is a directory then add all the files below it to the list\r
//\r
- for ( ParamCount = 1, Param = ShellCommandLineGetRawValue(Package, ParamCount)\r
- ; Param != NULL\r
- ; ParamCount++, Param = ShellCommandLineGetRawValue(Package, ParamCount)\r
- ){\r
- Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_READ, &FileList);\r
- if (EFI_ERROR(Status)) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"type", (CHAR16*)Param);\r
+ for ( ParamCount = 1, Param = ShellCommandLineGetRawValue (Package, ParamCount)\r
+ ; Param != NULL\r
+ ; ParamCount++, Param = ShellCommandLineGetRawValue (Package, ParamCount)\r
+ )\r
+ {\r
+ Status = ShellOpenFileMetaArg ((CHAR16 *)Param, EFI_FILE_MODE_READ, &FileList);\r
+ if (EFI_ERROR (Status)) {\r
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"type", (CHAR16 *)Param);\r
ShellStatus = SHELL_NOT_FOUND;\r
break;\r
}\r
+\r
//\r
// make sure we completed the param parsing sucessfully...\r
// Also make sure that any previous action was sucessful\r
//\r
// check that we have at least 1 file\r
//\r
- if (FileList == NULL || IsListEmpty(&FileList->Link)) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel3HiiHandle, L"type", Param);\r
+ if ((FileList == NULL) || IsListEmpty (&FileList->Link)) {\r
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel3HiiHandle, L"type", Param);\r
continue;\r
} else {\r
//\r
// loop through the list and make sure we are not aborting...\r
//\r
- for ( Node = (EFI_SHELL_FILE_INFO*)GetFirstNode(&FileList->Link)\r
- ; !IsNull(&FileList->Link, &Node->Link) && !ShellGetExecutionBreakFlag()\r
- ; Node = (EFI_SHELL_FILE_INFO*)GetNextNode(&FileList->Link, &Node->Link)\r
- ){\r
-\r
- if (ShellGetExecutionBreakFlag()) {\r
+ for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode (&FileList->Link)\r
+ ; !IsNull (&FileList->Link, &Node->Link) && !ShellGetExecutionBreakFlag ()\r
+ ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode (&FileList->Link, &Node->Link)\r
+ )\r
+ {\r
+ if (ShellGetExecutionBreakFlag ()) {\r
break;\r
}\r
\r
//\r
// make sure the file opened ok\r
//\r
- if (EFI_ERROR(Node->Status)){\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"type", Node->FileName);\r
+ if (EFI_ERROR (Node->Status)) {\r
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"type", Node->FileName);\r
ShellStatus = SHELL_NOT_FOUND;\r
continue;\r
}\r
//\r
// make sure its not a directory\r
//\r
- if (FileHandleIsDirectory(Node->Handle) == EFI_SUCCESS) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_IS_DIR), gShellLevel3HiiHandle, L"type", Node->FileName);\r
+ if (FileHandleIsDirectory (Node->Handle) == EFI_SUCCESS) {\r
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_IS_DIR), gShellLevel3HiiHandle, L"type", Node->FileName);\r
ShellStatus = SHELL_NOT_FOUND;\r
continue;\r
}\r
// do it\r
//\r
Status = TypeFileByHandle (Node->Handle, AsciiMode, UnicodeMode);\r
- if (EFI_ERROR(Status)) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_TYP_ERROR), gShellLevel3HiiHandle, L"type", Node->FileName);\r
+ if (EFI_ERROR (Status)) {\r
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_TYP_ERROR), gShellLevel3HiiHandle, L"type", Node->FileName);\r
ShellStatus = SHELL_INVALID_PARAMETER;\r
}\r
- ASSERT(ShellStatus == SHELL_SUCCESS);\r
+\r
+ ASSERT (ShellStatus == SHELL_SUCCESS);\r
}\r
}\r
}\r
+\r
//\r
// Free the fileList\r
//\r
- if (FileList != NULL && !IsListEmpty(&FileList->Link)) {\r
- Status = ShellCloseFileMetaArg(&FileList);\r
+ if ((FileList != NULL) && !IsListEmpty (&FileList->Link)) {\r
+ Status = ShellCloseFileMetaArg (&FileList);\r
}\r
- ASSERT_EFI_ERROR(Status);\r
+\r
+ ASSERT_EFI_ERROR (Status);\r
FileList = NULL;\r
}\r
}\r
ShellCommandLineFreeVarList (Package);\r
}\r
\r
- if (ShellGetExecutionBreakFlag()) {\r
+ if (ShellGetExecutionBreakFlag ()) {\r
return (SHELL_ABORTED);\r
}\r
\r
return (ShellStatus);\r
}\r
-\r