15BOOLEAN AsciiRedirection =
FALSE;
28 CONST CHAR16 *CloseQuote;
35 if (*First == CHAR_NULL) {
52 if (*CloseQuote == CHAR_NULL) {
83 IN OUT CHAR16 **Walker,
84 IN OUT CHAR16 **TempParameter,
86 IN BOOLEAN StripQuotation
89 CONST CHAR16 *NextDelim;
93 || (TempParameter ==
NULL)
94 || (*TempParameter ==
NULL)
97 return (EFI_INVALID_PARAMETER);
103 while ((*Walker)[0] == L
' ') {
110 if (
StrLen (*Walker) == 0) {
114 return (EFI_INVALID_PARAMETER);
119 if (NextDelim ==
NULL) {
123 return (EFI_NOT_FOUND);
126 StrnCpyS (*TempParameter, Length /
sizeof (CHAR16), (*Walker), NextDelim - *Walker);
131 if (*NextDelim != CHAR_NULL) {
132 (*TempParameter)[NextDelim - *Walker] = CHAR_NULL;
138 *Walker = (CHAR16 *)NextDelim;
145 ; *NextDelim != CHAR_NULL
149 if (*NextDelim == L
'^') {
153 CopyMem ((CHAR16 *)NextDelim, NextDelim + 1,
StrSize (NextDelim + 1));
155 }
else if (*NextDelim == L
'\"') {
159 if (StripQuotation) {
160 CopyMem ((CHAR16 *)NextDelim, NextDelim + 1,
StrSize (NextDelim + 1));
193 IN BOOLEAN StripQuotation,
194 IN OUT CHAR16 ***Argv,
199 CHAR16 *TempParameter;
202 CHAR16 *NewCommandLine;
206 ASSERT (Argc !=
NULL);
207 ASSERT (Argv !=
NULL);
209 if ((CommandLine ==
NULL) || (
StrLen (CommandLine) == 0)) {
216 if (NewCommandLine ==
NULL) {
217 return (EFI_OUT_OF_RESOURCES);
221 Size =
StrSize (NewCommandLine);
223 if (TempParameter ==
NULL) {
224 SHELL_FREE_NON_NULL (NewCommandLine);
225 return (EFI_OUT_OF_RESOURCES);
229 Walker = (CHAR16 *)NewCommandLine
230 ; Walker !=
NULL && *Walker != CHAR_NULL
244 Status = EFI_OUT_OF_RESOURCES;
249 Walker = (CHAR16 *)NewCommandLine;
250 while (Walker !=
NULL && *Walker != CHAR_NULL) {
251 SetMem16 (TempParameter, Size, CHAR_NULL);
252 if (EFI_ERROR (
GetNextParameter (&Walker, &TempParameter, Size, StripQuotation))) {
253 Status = EFI_INVALID_PARAMETER;
258 if (NewParam ==
NULL) {
259 Status = EFI_OUT_OF_RESOURCES;
263 ((CHAR16 **)(*Argv))[(*Argc)] = NewParam;
267 ASSERT (Count >= (*Argc));
271 SHELL_FREE_NON_NULL (TempParameter);
272 SHELL_FREE_NON_NULL (NewCommandLine);
295 IN OUT BOOLEAN *RootShellInstance
300 CHAR16 *FullCommandLine;
304 FullCommandLine =
NULL;
310 ASSERT (NewShellParameters !=
NULL);
311 ASSERT (RootShellInstance !=
NULL);
316 Status =
gBS->OpenProtocol (
318 &gEfiShellParametersProtocolGuid,
322 EFI_OPEN_PROTOCOL_GET_PROTOCOL
327 if (EFI_ERROR (Status)) {
328 *RootShellInstance =
TRUE;
335 if ((*NewShellParameters) ==
NULL) {
336 return (EFI_OUT_OF_RESOURCES);
342 Status =
gBS->OpenProtocol (
344 &gEfiLoadedImageProtocolGuid,
345 (VOID **)&LoadedImage,
348 EFI_OPEN_PROTOCOL_GET_PROTOCOL
355 if (Status == EFI_BUFFER_TOO_SMALL) {
357 if (FullCommandLine ==
NULL) {
358 return EFI_OUT_OF_RESOURCES;
364 if (Status == EFI_NOT_FOUND) {
369 if (EFI_ERROR (Status)) {
375 ASSERT (FullCommandLine ==
NULL);
383 if (FullCommandLine !=
NULL) {
391 &(*NewShellParameters)->Argv,
392 &(*NewShellParameters)->Argc
399 (*NewShellParameters)->Argv =
NULL;
400 (*NewShellParameters)->Argc = 0;
406 if (*RootShellInstance) {
410 Status =
gBS->InstallProtocolInterface (
412 &gEfiShellParametersProtocolGuid,
414 (VOID *)(*NewShellParameters)
423 Status =
gBS->ReinstallProtocolInterface (
425 &gEfiShellParametersProtocolGuid,
427 (VOID *)(*NewShellParameters)
458 Status =
gBS->ReinstallProtocolInterface (
460 &gEfiShellParametersProtocolGuid,
461 (VOID *)NewShellParameters,
471 Status =
gBS->UninstallProtocolInterface (
473 &gEfiShellParametersProtocolGuid,
474 (VOID *)NewShellParameters
478 if (NewShellParameters->Argv !=
NULL) {
479 for ( LoopCounter = 0
480 ; LoopCounter < NewShellParameters->Argc
484 FreePool (NewShellParameters->Argv[LoopCounter]);
487 FreePool (NewShellParameters->Argv);
507 SHELL_FILE_HANDLE Handle;
509 UINT64 OriginalFilePosition;
513 Status = gEfiShellProtocol->OpenFileByName (FileName, &Handle, EFI_FILE_MODE_READ);
514 if (EFI_ERROR (Status)) {
518 gEfiShellProtocol->GetFilePosition (Handle, &OriginalFilePosition);
519 gEfiShellProtocol->SetFilePosition (Handle, 0);
520 CharSize =
sizeof (CHAR16);
521 Status = gEfiShellProtocol->ReadFile (Handle, &CharSize, &CharBuffer);
523 Status = EFI_BUFFER_TOO_SMALL;
526 gEfiShellProtocol->SetFilePosition (Handle, OriginalFilePosition);
527 gEfiShellProtocol->CloseFile (Handle);
540 IN OUT CHAR16 *TheString
545 for (RemoveNow =
FALSE; TheString !=
NULL && *TheString != CHAR_NULL; TheString++) {
546 if ((*TheString == L
'^') && (*(TheString + 1) == L
'\"')) {
548 }
else if (*TheString == L
'\"') {
549 RemoveNow = (BOOLEAN) !RemoveNow;
550 }
else if (RemoveNow) {
577 gBS->CalculateCrc32 ((UINT8 *)Hdr, Hdr->HeaderSize, &Crc);
595 CHAR16 *TempLocation;
597 if (FileName ==
NULL) {
601 if (FileName[0] == L
'\"') {
603 if ((TempLocation =
StrStr (Copy, L
"\"")) !=
NULL) {
604 TempLocation[0] = CHAR_NULL;
608 while (Copy[0] == L
' ') {
612 if ((TempLocation =
StrStr (Copy, L
" ")) !=
NULL) {
613 TempLocation[0] = CHAR_NULL;
617 if (Copy[0] == CHAR_NULL) {
638 CHAR16 *TempLocation;
642 if (FileName[0] == L
'%') {
644 if ((TempLocation =
StrStr (Copy, L
"%")) !=
NULL) {
645 TempLocation[0] = CHAR_NULL;
665 IN SHELL_FILE_HANDLE FileHandle
673 Size =
sizeof FileTag;
674 Status = ShellInfoObject.NewEfiShellProtocol->WriteFile (
679 ASSERT (EFI_ERROR (Status) || Size ==
sizeof FileTag);
703 IN CHAR16 *NewCommandLine,
704 OUT SHELL_FILE_HANDLE *OldStdIn,
705 OUT SHELL_FILE_HANDLE *OldStdOut,
706 OUT SHELL_FILE_HANDLE *OldStdErr,
710 CHAR16 *CommandLineCopy;
711 CHAR16 *CommandLineWalker;
712 CHAR16 *StdErrFileName;
713 CHAR16 *StdOutFileName;
714 CHAR16 *StdInFileName;
715 CHAR16 *StdInVarName;
716 CHAR16 *StdOutVarName;
717 CHAR16 *StdErrVarName;
719 SHELL_FILE_HANDLE TempHandle;
728 CHAR16 *FirstLocation;
733 AsciiRedirection =
FALSE;
736 StdOutVarName =
NULL;
737 StdErrVarName =
NULL;
738 StdErrFileName =
NULL;
739 StdInFileName =
NULL;
740 StdOutFileName =
NULL;
743 CommandLineCopy =
NULL;
744 FirstLocation =
NULL;
747 if ((ShellParameters ==
NULL) || (SystemTableInfo ==
NULL) || (OldStdIn ==
NULL) || (OldStdOut ==
NULL) || (OldStdErr ==
NULL)) {
748 return (EFI_INVALID_PARAMETER);
751 SystemTableInfo->ConIn =
gST->
ConIn;
757 *OldStdIn = ShellParameters->StdIn;
758 *OldStdOut = ShellParameters->StdOut;
759 *OldStdErr = ShellParameters->StdErr;
761 if (NewCommandLine ==
NULL) {
765 CommandLineCopy =
StrnCatGrow (&CommandLineCopy,
NULL, NewCommandLine, 0);
766 if (CommandLineCopy ==
NULL) {
767 return (EFI_OUT_OF_RESOURCES);
772 FirstLocation = CommandLineCopy +
StrLen (CommandLineCopy);
779 ShellParameters->StdIn =
Split->SplitStdIn;
783 ShellParameters->StdOut =
Split->SplitStdOut;
787 if (!EFI_ERROR (Status) && ((CommandLineWalker =
StrStr (CommandLineCopy, L
" 2>>v ")) !=
NULL)) {
788 FirstLocation =
MIN (CommandLineWalker, FirstLocation);
789 SetMem16 (CommandLineWalker, 12, L
' ');
790 StdErrVarName = CommandLineWalker += 6;
792 if (
StrStr (CommandLineWalker, L
" 2>>v ") !=
NULL) {
793 Status = EFI_NOT_FOUND;
797 if (!EFI_ERROR (Status) && ((CommandLineWalker =
StrStr (CommandLineCopy, L
" 1>>v ")) !=
NULL)) {
798 FirstLocation =
MIN (CommandLineWalker, FirstLocation);
799 SetMem16 (CommandLineWalker, 12, L
' ');
800 StdOutVarName = CommandLineWalker += 6;
802 if (
StrStr (CommandLineWalker, L
" 1>>v ") !=
NULL) {
803 Status = EFI_NOT_FOUND;
805 }
else if (!EFI_ERROR (Status) && ((CommandLineWalker =
StrStr (CommandLineCopy, L
" >>v ")) !=
NULL)) {
806 FirstLocation =
MIN (CommandLineWalker, FirstLocation);
807 SetMem16 (CommandLineWalker, 10, L
' ');
808 StdOutVarName = CommandLineWalker += 5;
810 if (
StrStr (CommandLineWalker, L
" >>v ") !=
NULL) {
811 Status = EFI_NOT_FOUND;
813 }
else if (!EFI_ERROR (Status) && ((CommandLineWalker =
StrStr (CommandLineCopy, L
" >v ")) !=
NULL)) {
814 FirstLocation =
MIN (CommandLineWalker, FirstLocation);
815 SetMem16 (CommandLineWalker, 8, L
' ');
816 StdOutVarName = CommandLineWalker += 4;
818 if (
StrStr (CommandLineWalker, L
" >v ") !=
NULL) {
819 Status = EFI_NOT_FOUND;
823 if (!EFI_ERROR (Status) && ((CommandLineWalker =
StrStr (CommandLineCopy, L
" 1>>a ")) !=
NULL)) {
824 FirstLocation =
MIN (CommandLineWalker, FirstLocation);
825 SetMem16 (CommandLineWalker, 12, L
' ');
826 StdOutFileName = CommandLineWalker += 6;
829 if (
StrStr (CommandLineWalker, L
" 1>>a ") !=
NULL) {
830 Status = EFI_NOT_FOUND;
834 if (!EFI_ERROR (Status) && ((CommandLineWalker =
StrStr (CommandLineCopy, L
" 1>> ")) !=
NULL)) {
835 FirstLocation =
MIN (CommandLineWalker, FirstLocation);
836 SetMem16 (CommandLineWalker, 10, L
' ');
837 if (StdOutFileName !=
NULL) {
838 Status = EFI_INVALID_PARAMETER;
840 StdOutFileName = CommandLineWalker += 5;
844 if (
StrStr (CommandLineWalker, L
" 1>> ") !=
NULL) {
845 Status = EFI_NOT_FOUND;
849 if (!EFI_ERROR (Status) && ((CommandLineWalker =
StrStr (CommandLineCopy, L
" >> ")) !=
NULL)) {
850 FirstLocation =
MIN (CommandLineWalker, FirstLocation);
851 SetMem16 (CommandLineWalker, 8, L
' ');
852 if (StdOutFileName !=
NULL) {
853 Status = EFI_INVALID_PARAMETER;
855 StdOutFileName = CommandLineWalker += 4;
859 if (
StrStr (CommandLineWalker, L
" >> ") !=
NULL) {
860 Status = EFI_NOT_FOUND;
864 if (!EFI_ERROR (Status) && ((CommandLineWalker =
StrStr (CommandLineCopy, L
" >>a ")) !=
NULL)) {
865 FirstLocation =
MIN (CommandLineWalker, FirstLocation);
866 SetMem16 (CommandLineWalker, 10, L
' ');
867 if (StdOutFileName !=
NULL) {
868 Status = EFI_INVALID_PARAMETER;
870 StdOutFileName = CommandLineWalker += 5;
875 if (
StrStr (CommandLineWalker, L
" >>a ") !=
NULL) {
876 Status = EFI_NOT_FOUND;
880 if (!EFI_ERROR (Status) && ((CommandLineWalker =
StrStr (CommandLineCopy, L
" 1>a ")) !=
NULL)) {
881 FirstLocation =
MIN (CommandLineWalker, FirstLocation);
882 SetMem16 (CommandLineWalker, 10, L
' ');
883 if (StdOutFileName !=
NULL) {
884 Status = EFI_INVALID_PARAMETER;
886 StdOutFileName = CommandLineWalker += 5;
891 if (
StrStr (CommandLineWalker, L
" 1>a ") !=
NULL) {
892 Status = EFI_NOT_FOUND;
896 if (!EFI_ERROR (Status) && ((CommandLineWalker =
StrStr (CommandLineCopy, L
" >a ")) !=
NULL)) {
897 FirstLocation =
MIN (CommandLineWalker, FirstLocation);
898 SetMem16 (CommandLineWalker, 8, L
' ');
899 if (StdOutFileName !=
NULL) {
900 Status = EFI_INVALID_PARAMETER;
902 StdOutFileName = CommandLineWalker += 4;
907 if (
StrStr (CommandLineWalker, L
" >a ") !=
NULL) {
908 Status = EFI_NOT_FOUND;
912 if (!EFI_ERROR (Status) && ((CommandLineWalker =
StrStr (CommandLineCopy, L
" 2>> ")) !=
NULL)) {
913 FirstLocation =
MIN (CommandLineWalker, FirstLocation);
914 SetMem16 (CommandLineWalker, 10, L
' ');
915 if (StdErrFileName !=
NULL) {
916 Status = EFI_INVALID_PARAMETER;
918 StdErrFileName = CommandLineWalker += 5;
922 if (
StrStr (CommandLineWalker, L
" 2>> ") !=
NULL) {
923 Status = EFI_NOT_FOUND;
927 if (!EFI_ERROR (Status) && ((CommandLineWalker =
StrStr (CommandLineCopy, L
" 2>v ")) !=
NULL)) {
928 FirstLocation =
MIN (CommandLineWalker, FirstLocation);
929 SetMem16 (CommandLineWalker, 10, L
' ');
930 if (StdErrVarName !=
NULL) {
931 Status = EFI_INVALID_PARAMETER;
933 StdErrVarName = CommandLineWalker += 5;
937 if (
StrStr (CommandLineWalker, L
" 2>v ") !=
NULL) {
938 Status = EFI_NOT_FOUND;
942 if (!EFI_ERROR (Status) && ((CommandLineWalker =
StrStr (CommandLineCopy, L
" 1>v ")) !=
NULL)) {
943 FirstLocation =
MIN (CommandLineWalker, FirstLocation);
944 SetMem16 (CommandLineWalker, 10, L
' ');
945 if (StdOutVarName !=
NULL) {
946 Status = EFI_INVALID_PARAMETER;
948 StdOutVarName = CommandLineWalker += 5;
952 if (
StrStr (CommandLineWalker, L
" 1>v ") !=
NULL) {
953 Status = EFI_NOT_FOUND;
957 if (!EFI_ERROR (Status) && ((CommandLineWalker =
StrStr (CommandLineCopy, L
" 2>a ")) !=
NULL)) {
958 FirstLocation =
MIN (CommandLineWalker, FirstLocation);
959 SetMem16 (CommandLineWalker, 10, L
' ');
960 if (StdErrFileName !=
NULL) {
961 Status = EFI_INVALID_PARAMETER;
963 StdErrFileName = CommandLineWalker += 5;
968 if (
StrStr (CommandLineWalker, L
" 2>a ") !=
NULL) {
969 Status = EFI_NOT_FOUND;
973 if (!EFI_ERROR (Status) && ((CommandLineWalker =
StrStr (CommandLineCopy, L
" 2> ")) !=
NULL)) {
974 FirstLocation =
MIN (CommandLineWalker, FirstLocation);
975 SetMem16 (CommandLineWalker, 8, L
' ');
976 if (StdErrFileName !=
NULL) {
977 Status = EFI_INVALID_PARAMETER;
979 StdErrFileName = CommandLineWalker += 4;
983 if (
StrStr (CommandLineWalker, L
" 2> ") !=
NULL) {
984 Status = EFI_NOT_FOUND;
988 if (!EFI_ERROR (Status) && ((CommandLineWalker =
StrStr (CommandLineCopy, L
" 1> ")) !=
NULL)) {
989 FirstLocation =
MIN (CommandLineWalker, FirstLocation);
990 SetMem16 (CommandLineWalker, 8, L
' ');
991 if (StdOutFileName !=
NULL) {
992 Status = EFI_INVALID_PARAMETER;
994 StdOutFileName = CommandLineWalker += 4;
998 if (
StrStr (CommandLineWalker, L
" 1> ") !=
NULL) {
999 Status = EFI_NOT_FOUND;
1003 if (!EFI_ERROR (Status) && ((CommandLineWalker =
StrStr (CommandLineCopy, L
" > ")) !=
NULL)) {
1004 FirstLocation =
MIN (CommandLineWalker, FirstLocation);
1005 SetMem16 (CommandLineWalker, 6, L
' ');
1006 if (StdOutFileName !=
NULL) {
1007 Status = EFI_INVALID_PARAMETER;
1009 StdOutFileName = CommandLineWalker += 3;
1013 if (
StrStr (CommandLineWalker, L
" > ") !=
NULL) {
1014 Status = EFI_NOT_FOUND;
1018 if (!EFI_ERROR (Status) && ((CommandLineWalker =
StrStr (CommandLineCopy, L
" < ")) !=
NULL)) {
1019 FirstLocation =
MIN (CommandLineWalker, FirstLocation);
1020 SetMem16 (CommandLineWalker, 6, L
' ');
1021 if (StdInFileName !=
NULL) {
1022 Status = EFI_INVALID_PARAMETER;
1024 StdInFileName = CommandLineWalker += 3;
1027 if (
StrStr (CommandLineWalker, L
" < ") !=
NULL) {
1028 Status = EFI_NOT_FOUND;
1032 if (!EFI_ERROR (Status) && ((CommandLineWalker =
StrStr (CommandLineCopy, L
" <a ")) !=
NULL)) {
1033 FirstLocation =
MIN (CommandLineWalker, FirstLocation);
1034 SetMem16 (CommandLineWalker, 8, L
' ');
1035 if (StdInFileName !=
NULL) {
1036 Status = EFI_INVALID_PARAMETER;
1038 StdInFileName = CommandLineWalker += 4;
1040 AsciiRedirection =
TRUE;
1043 if (
StrStr (CommandLineWalker, L
" <a ") !=
NULL) {
1044 Status = EFI_NOT_FOUND;
1048 if (!EFI_ERROR (Status) && ((CommandLineWalker =
StrStr (CommandLineCopy, L
" <v ")) !=
NULL)) {
1049 FirstLocation =
MIN (CommandLineWalker, FirstLocation);
1050 SetMem16 (CommandLineWalker, 8, L
' ');
1051 if (StdInVarName !=
NULL) {
1052 Status = EFI_INVALID_PARAMETER;
1054 StdInVarName = CommandLineWalker += 4;
1057 if (
StrStr (CommandLineWalker, L
" <v ") !=
NULL) {
1058 Status = EFI_NOT_FOUND;
1065 StrnCpyS (CommandLineCopy,
StrSize (CommandLineCopy)/
sizeof (CHAR16), NewCommandLine,
StrLen (NewCommandLine));
1067 if ( (FirstLocation != CommandLineCopy +
StrLen (CommandLineCopy))
1068 && (((
UINTN)FirstLocation - (
UINTN)CommandLineCopy)/
sizeof (CHAR16) <
StrLen (NewCommandLine))
1071 *(NewCommandLine + ((
UINTN)FirstLocation - (
UINTN)CommandLineCopy)/
sizeof (CHAR16)) = CHAR_NULL;
1074 if (!EFI_ERROR (Status)) {
1075 if (StdErrFileName !=
NULL) {
1077 Status = EFI_INVALID_PARAMETER;
1081 if (StdOutFileName !=
NULL) {
1083 Status = EFI_INVALID_PARAMETER;
1087 if (StdInFileName !=
NULL) {
1089 Status = EFI_INVALID_PARAMETER;
1093 if (StdErrVarName !=
NULL) {
1095 Status = EFI_INVALID_PARAMETER;
1099 if (StdOutVarName !=
NULL) {
1101 Status = EFI_INVALID_PARAMETER;
1105 if (StdInVarName !=
NULL) {
1107 Status = EFI_INVALID_PARAMETER;
1135 || ((StdErrFileName !=
NULL) && (StdErrVarName !=
NULL))
1136 || ((StdOutFileName !=
NULL) && (StdOutVarName !=
NULL))
1137 || ((StdInFileName !=
NULL) && (StdInVarName !=
NULL))
1141 || ((StdErrVarName !=
NULL) && !EFI_ERROR (
IsVolatileEnv (StdErrVarName, &Volatile)) && !Volatile)
1142 || ((StdOutVarName !=
NULL) && !EFI_ERROR (
IsVolatileEnv (StdOutVarName, &Volatile)) && !Volatile)
1146 || ( (
StrStr (NewCommandLine, L
"connect -r") !=
NULL)
1147 && ((StdOutVarName !=
NULL) || (StdOutFileName !=
NULL) || (StdErrFileName !=
NULL) || (StdErrVarName !=
NULL)))
1153 || ((StdOutFileName !=
NULL) && !OutUnicode && OutAppend && (!EFI_ERROR (
ShellFileExists (StdOutFileName)) && !EFI_ERROR (
IsUnicodeFile (StdOutFileName))))
1154 || ((StdErrFileName !=
NULL) && !ErrUnicode && ErrAppend && (!EFI_ERROR (
ShellFileExists (StdErrFileName)) && !EFI_ERROR (
IsUnicodeFile (StdErrFileName))))
1157 Status = EFI_INVALID_PARAMETER;
1158 ShellParameters->StdIn = *OldStdIn;
1159 ShellParameters->StdOut = *OldStdOut;
1160 ShellParameters->StdErr = *OldStdErr;
1161 }
else if (!EFI_ERROR (Status)) {
1169 if (StdErrFileName !=
NULL) {
1174 ShellInfoObject.NewEfiShellProtocol->DeleteFileByName (StdErrFileName);
1177 Status =
ShellOpenFileByName (StdErrFileName, &TempHandle, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE, 0);
1178 if (!ErrAppend && ErrUnicode && !EFI_ERROR (Status)) {
1182 if (!ErrUnicode && !EFI_ERROR (Status)) {
1184 if (TempHandle ==
NULL) {
1185 ASSERT (TempHandle !=
NULL);
1186 Status = EFI_OUT_OF_RESOURCES;
1190 if (!EFI_ERROR (Status)) {
1191 ShellParameters->StdErr = TempHandle;
1199 if (!EFI_ERROR (Status) && (StdOutFileName !=
NULL)) {
1204 ShellInfoObject.NewEfiShellProtocol->DeleteFileByName (StdOutFileName);
1207 Status =
ShellOpenFileByName (StdOutFileName, &TempHandle, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE, 0);
1208 if (TempHandle ==
NULL) {
1209 Status = EFI_INVALID_PARAMETER;
1211 if (gUnicodeCollation->MetaiMatch (gUnicodeCollation, StdOutFileName, L
"NUL")) {
1213 }
else if (!OutAppend && OutUnicode && !EFI_ERROR (Status)) {
1215 }
else if (OutAppend) {
1216 Status = ShellInfoObject.NewEfiShellProtocol->GetFileSize (TempHandle, &FileSize);
1217 if (!EFI_ERROR (Status)) {
1223 Status = (FileSize == 0 && OutUnicode) ?
1225 ShellInfoObject.NewEfiShellProtocol->SetFilePosition (
1232 if (!OutUnicode && !EFI_ERROR (Status)) {
1234 if (TempHandle ==
NULL) {
1235 ASSERT (TempHandle !=
NULL);
1236 Status = EFI_OUT_OF_RESOURCES;
1240 if (!EFI_ERROR (Status)) {
1241 ShellParameters->StdOut = TempHandle;
1250 if (!EFI_ERROR (Status) && (StdOutVarName !=
NULL)) {
1259 if (TempHandle ==
NULL) {
1260 ASSERT (TempHandle !=
NULL);
1261 Status = EFI_OUT_OF_RESOURCES;
1263 ShellParameters->StdOut = TempHandle;
1271 if (!EFI_ERROR (Status) && (StdErrVarName !=
NULL)) {
1280 if (TempHandle ==
NULL) {
1281 ASSERT (TempHandle !=
NULL);
1282 Status = EFI_OUT_OF_RESOURCES;
1284 ShellParameters->StdErr = TempHandle;
1292 if (!EFI_ERROR (Status) && (StdInVarName !=
NULL)) {
1294 if (TempHandle ==
NULL) {
1295 Status = EFI_OUT_OF_RESOURCES;
1302 if ((TempHandle ==
NULL) || (((
EFI_FILE_PROTOCOL *)TempHandle)->Read (TempHandle, &Size,
NULL) != EFI_BUFFER_TOO_SMALL)) {
1303 Status = EFI_INVALID_PARAMETER;
1305 ShellParameters->StdIn = TempHandle;
1314 if (!EFI_ERROR (Status) && (StdInFileName !=
NULL)) {
1321 if (!EFI_ERROR (Status)) {
1329 if (TempHandle ==
NULL) {
1330 Status = EFI_OUT_OF_RESOURCES;
1332 ShellParameters->StdIn = TempHandle;
1345 Status = EFI_OUT_OF_RESOURCES;
1348 if (Status == EFI_NOT_FOUND) {
1350 }
else if (EFI_ERROR (Status)) {
1370 IN SHELL_FILE_HANDLE *OldStdIn,
1371 IN SHELL_FILE_HANDLE *OldStdOut,
1372 IN SHELL_FILE_HANDLE *OldStdErr,
1378 if ( (ShellParameters ==
NULL)
1379 || (OldStdIn ==
NULL)
1380 || (OldStdOut ==
NULL)
1381 || (OldStdErr ==
NULL)
1382 || (SystemTableInfo ==
NULL))
1384 return (EFI_INVALID_PARAMETER);
1393 if (ShellParameters->StdIn != *OldStdIn) {
1395 gEfiShellProtocol->CloseFile (ShellParameters->StdIn);
1398 ShellParameters->StdIn = *OldStdIn;
1401 if (ShellParameters->StdOut != *OldStdOut) {
1403 gEfiShellProtocol->CloseFile (ShellParameters->StdOut);
1406 ShellParameters->StdOut = *OldStdOut;
1409 if (ShellParameters->StdErr != *OldStdErr) {
1410 gEfiShellProtocol->CloseFile (ShellParameters->StdErr);
1411 ShellParameters->StdErr = *OldStdErr;
1414 if (
gST->
ConIn != SystemTableInfo->ConIn) {
1416 gST->
ConIn = SystemTableInfo->ConIn;
1420 if (
gST->
ConOut != SystemTableInfo->ConOut) {
1426 if (
gST->
StdErr != SystemTableInfo->ErrOut) {
1458 IN CONST CHAR16 *NewCommandLine,
1459 IN SHELL_OPERATION_TYPES Type,
1460 OUT CHAR16 ***OldArgv OPTIONAL,
1464 BOOLEAN StripParamQuotation;
1466 ASSERT (ShellParameters !=
NULL);
1467 StripParamQuotation =
TRUE;
1469 if (OldArgc !=
NULL) {
1470 *OldArgc = ShellParameters->Argc;
1473 if (OldArgc !=
NULL) {
1474 *OldArgv = ShellParameters->Argv;
1477 if (Type == Script_File_Name) {
1478 StripParamQuotation =
FALSE;
1483 StripParamQuotation,
1484 &(ShellParameters->Argv),
1485 &(ShellParameters->Argc)
1501 IN CHAR16 ***OldArgv,
1507 ASSERT (ShellParameters !=
NULL);
1508 ASSERT (OldArgv !=
NULL);
1509 ASSERT (OldArgc !=
NULL);
1511 if (ShellParameters->Argv !=
NULL) {
1512 for ( LoopCounter = 0
1513 ; LoopCounter < ShellParameters->Argc
1517 FreePool (ShellParameters->Argv[LoopCounter]);
1523 ShellParameters->Argv = *OldArgv;
1525 ShellParameters->Argc = *OldArgc;
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
RETURN_STATUS EFIAPI StrnCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source, IN UINTN Length)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
CHAR16 *EFIAPI StrStr(IN CONST CHAR16 *String, IN CONST CHAR16 *SearchString)
VOID *EFIAPI SetMem16(OUT VOID *Buffer, IN UINTN Length, IN UINT16 Value)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * CreateSimpleTextOutOnFile(IN SHELL_FILE_HANDLE FileHandleToUse, IN EFI_HANDLE *HandleLocation, IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalProtocol)
EFI_STATUS CloseSimpleTextOutOnFile(IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut)
EFI_STATUS CloseSimpleTextInOnFile(IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *SimpleTextIn)
EFI_SIMPLE_TEXT_INPUT_PROTOCOL * CreateSimpleTextInOnFile(IN SHELL_FILE_HANDLE FileHandleToUse, IN EFI_HANDLE *HandleLocation)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
CONST UINT16 gUnicodeFileTag
EFI_FILE_PROTOCOL FileInterfaceStdIn
EFI_FILE_PROTOCOL * CreateFileInterfaceEnv(IN CONST CHAR16 *EnvName)
EFI_FILE_PROTOCOL FileInterfaceStdErr
EFI_FILE_PROTOCOL FileInterfaceStdOut
EFI_FILE_PROTOCOL * CreateFileInterfaceFile(IN CONST EFI_FILE_PROTOCOL *Template, IN CONST BOOLEAN Unicode)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG_CODE_BEGIN()
#define DEBUG_CODE(Expression)
EFI_STATUS TrimSpaces(IN CHAR16 **String)
CONST CHAR16 * FindFirstCharacter(IN CONST CHAR16 *String, IN CONST CHAR16 *CharacterList, IN CONST CHAR16 EscapeCharacter)
EFI_STATUS IsVolatileEnv(IN CONST CHAR16 *EnvVarName, OUT BOOLEAN *Volatile)
#define SHELL_SET_ENVIRONMENT_VARIABLE_V(EnvVarName, BufferSize, Buffer)
#define SHELL_GET_ENVIRONMENT_VARIABLE(EnvVarName, BufferSize, Buffer)
EFI_STATUS EFIAPI ShellPrintHiiEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR8 *Language OPTIONAL, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle,...)
EFI_STATUS EFIAPI ShellOpenFileByName(IN CONST CHAR16 *FileName, OUT SHELL_FILE_HANDLE *FileHandle, IN UINT64 OpenMode, IN UINT64 Attributes)
CHAR16 *EFIAPI StrnCatGrow(IN OUT CHAR16 **Destination, IN OUT UINTN *CurrentSize, IN CONST CHAR16 *Source, IN UINTN Count)
EFI_STATUS EFIAPI ShellFileExists(IN CONST CHAR16 *Name)
EFI_STATUS CreatePopulateInstallShellParametersProtocol(IN OUT EFI_SHELL_PARAMETERS_PROTOCOL **NewShellParameters, IN OUT BOOLEAN *RootShellInstance)
CHAR16 * FixFileName(IN CHAR16 *FileName)
EFI_STATUS RestoreStdInStdOutStdErr(IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters, IN SHELL_FILE_HANDLE *OldStdIn, IN SHELL_FILE_HANDLE *OldStdOut, IN SHELL_FILE_HANDLE *OldStdErr, IN SYSTEM_TABLE_INFO *SystemTableInfo)
EFI_STATUS ParseCommandLineToArgs(IN CONST CHAR16 *CommandLine, IN BOOLEAN StripQuotation, IN OUT CHAR16 ***Argv, IN OUT UINTN *Argc)
VOID RestoreArgcArgv(IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters, IN CHAR16 ***OldArgv, IN UINTN *OldArgc)
EFI_STATUS CleanUpShellParametersProtocol(IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *NewShellParameters)
EFI_STATUS UpdateArgcArgv(IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters, IN CONST CHAR16 *NewCommandLine, IN SHELL_OPERATION_TYPES Type, OUT CHAR16 ***OldArgv OPTIONAL, OUT UINTN *OldArgc OPTIONAL)
EFI_STATUS GetNextParameter(IN OUT CHAR16 **Walker, IN OUT CHAR16 **TempParameter, IN CONST UINTN Length, IN BOOLEAN StripQuotation)
EFI_STATUS UpdateStdInStdOutStdErr(IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters, IN CHAR16 *NewCommandLine, OUT SHELL_FILE_HANDLE *OldStdIn, OUT SHELL_FILE_HANDLE *OldStdOut, OUT SHELL_FILE_HANDLE *OldStdErr, OUT SYSTEM_TABLE_INFO *SystemTableInfo)
CHAR16 * FixVarName(IN CHAR16 *FileName)
CONST CHAR16 * FindEndOfParameter(IN CONST CHAR16 *String)
EFI_STATUS WriteFileTag(IN SHELL_FILE_HANDLE FileHandle)
EFI_STATUS IsUnicodeFile(IN CONST CHAR16 *FileName)
VOID StripQuotes(IN OUT CHAR16 *TheString)
VOID CalculateEfiHdrCrc(IN OUT EFI_TABLE_HEADER *Hdr)
INTN EFIAPI StringNoCaseCompare(IN CONST VOID *Buffer1, IN CONST VOID *Buffer2)
STATIC CONST CHAR8 ** Split(IN CHAR8 *Strings, IN UINTN Len, OUT UINT32 *NumPtr)
VOID * LoadOptions
A pointer to the image's binary load options.
UINT32 LoadOptionsSize
The size in bytes of LoadOptions.
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * StdErr
EFI_HANDLE ConsoleInHandle
EFI_HANDLE ConsoleOutHandle
EFI_HANDLE StandardErrorHandle
EFI_SIMPLE_TEXT_INPUT_PROTOCOL * ConIn
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut
SPLIT_LIST SplitList
List of Splits in FILO stack.
EFI_SHELL_PARAMETERS_PROTOCOL * OldShellParameters
old shell parameters to reinstall upon exiting.
EFI_HII_HANDLE HiiHandle
Handle from HiiLib.
LIST_ENTRY Link
Standard linked list handler.