]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Application/Shell/ShellParametersProtocol.h
ShellPkg: Document ParseCommandLineToArgs returns EFI_INVALID_PARAMETER
[mirror_edk2.git] / ShellPkg / Application / Shell / ShellParametersProtocol.h
CommitLineData
a405b86d 1/** @file\r
2 Member functions of EFI_SHELL_PARAMETERS_PROTOCOL and functions for creation,\r
3 manipulation, and initialization of EFI_SHELL_PARAMETERS_PROTOCOL.\r
4\r
4ccd9214 5 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
56ba3746 6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
a405b86d 7\r
8**/\r
9\r
10#ifndef _SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_\r
11#define _SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_\r
12\r
a405b86d 13#include "Shell.h"\r
14\r
d1c275c6
QS
15typedef enum {\r
16 Internal_Command,\r
17 Script_File_Name,\r
18 Efi_Application,\r
19 File_Sys_Change,\r
20 Unknown_Invalid\r
21} SHELL_OPERATION_TYPES;\r
22\r
a405b86d 23/**\r
24 creates a new EFI_SHELL_PARAMETERS_PROTOCOL instance and populates it and then\r
25 installs it on our handle and if there is an existing version of the protocol\r
26 that one is cached for removal later.\r
27\r
4ff7e37b 28 @param[in, out] NewShellParameters on a successful return, a pointer to pointer\r
a405b86d 29 to the newly installed interface.\r
4ff7e37b 30 @param[in, out] RootShellInstance on a successful return, pointer to boolean.\r
a405b86d 31 TRUE if this is the root shell instance.\r
32\r
33 @retval EFI_SUCCESS the operation completed successfully.\r
34 @return other the operation failed.\r
35 @sa ReinstallProtocolInterface\r
36 @sa InstallProtocolInterface\r
37 @sa ParseCommandLineToArgs\r
38**/\r
39EFI_STATUS\r
a405b86d 40CreatePopulateInstallShellParametersProtocol (\r
41 IN OUT EFI_SHELL_PARAMETERS_PROTOCOL **NewShellParameters,\r
42 IN OUT BOOLEAN *RootShellInstance\r
43 );\r
44\r
45/**\r
6a5033ca 46 frees all memory used by creation and installation of shell parameters protocol\r
a405b86d 47 and if there was an old version installed it will restore that one.\r
48\r
49 @param NewShellParameters the interface of EFI_SHELL_PARAMETERS_PROTOCOL that is\r
50 being cleaned up.\r
51\r
52 @retval EFI_SUCCESS the cleanup was successful\r
53 @return other the cleanup failed\r
54 @sa ReinstallProtocolInterface\r
55 @sa UninstallProtocolInterface\r
56**/\r
57EFI_STATUS\r
a405b86d 58CleanUpShellParametersProtocol (\r
59 IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *NewShellParameters\r
60 );\r
61\r
62/**\r
6a5033ca 63 Function will replace the current Argc and Argv in the ShellParameters protocol\r
a405b86d 64 structure by parsing NewCommandLine. The current values are returned to the\r
65 user.\r
66\r
4ff7e37b 67 @param[in, out] ShellParameters pointer to parameter structure to modify\r
a405b86d 68 @param[in] NewCommandLine the new command line to parse and use\r
d1c275c6 69 @param[in] Type the type of operation.\r
a405b86d 70 @param[out] OldArgv pointer to old list of parameters\r
71 @param[out] OldArgc pointer to old number of items in Argv list\r
72\r
6a5033ca 73 @retval EFI_SUCCESS operation was successful, Argv and Argc are valid\r
a405b86d 74 @retval EFI_OUT_OF_RESOURCES a memory allocation failed.\r
75**/\r
76EFI_STATUS\r
a405b86d 77UpdateArgcArgv(\r
78 IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r
79 IN CONST CHAR16 *NewCommandLine,\r
d1c275c6 80 IN SHELL_OPERATION_TYPES Type,\r
a405b86d 81 OUT CHAR16 ***OldArgv,\r
82 OUT UINTN *OldArgc\r
83 );\r
84\r
85/**\r
6a5033ca 86 Function will replace the current Argc and Argv in the ShellParameters protocol\r
a405b86d 87 structure with Argv and Argc. The current values are de-allocated and the\r
88 OldArgv must not be deallocated by the caller.\r
89\r
4ff7e37b
ED
90 @param[in, out] ShellParameters pointer to parameter structure to modify\r
91 @param[in] OldArgv pointer to old list of parameters\r
92 @param[in] OldArgc pointer to old number of items in Argv list\r
a405b86d 93**/\r
94VOID\r
a405b86d 95RestoreArgcArgv(\r
96 IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r
97 IN CHAR16 ***OldArgv,\r
98 IN UINTN *OldArgc\r
99 );\r
100\r
8be0ba36 101typedef struct {\r
102 EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;\r
103 EFI_HANDLE ConInHandle;\r
104 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;\r
105 EFI_HANDLE ConOutHandle;\r
4ccd9214
ED
106 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ErrOut;\r
107 EFI_HANDLE ErrOutHandle;\r
8be0ba36 108} SYSTEM_TABLE_INFO;\r
109\r
a405b86d 110/**\r
6a5033ca 111 Function will replace the current StdIn and StdOut in the ShellParameters protocol\r
a405b86d 112 structure by parsing NewCommandLine. The current values are returned to the\r
113 user.\r
114\r
fb84495a 115 This will also update the system table.\r
a405b86d 116\r
4ff7e37b
ED
117 @param[in, out] ShellParameters Pointer to parameter structure to modify.\r
118 @param[in] NewCommandLine The new command line to parse and use.\r
119 @param[out] OldStdIn Pointer to old StdIn.\r
120 @param[out] OldStdOut Pointer to old StdOut.\r
121 @param[out] OldStdErr Pointer to old StdErr.\r
122 @param[out] SystemTableInfo Pointer to old system table information.\r
a405b86d 123\r
6a5033ca 124 @retval EFI_SUCCESS Operation was successful, Argv and Argc are valid.\r
a405b86d 125 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
126**/\r
127EFI_STATUS\r
a405b86d 128UpdateStdInStdOutStdErr(\r
129 IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r
fb84495a 130 IN CHAR16 *NewCommandLine,\r
8be0ba36 131 OUT SHELL_FILE_HANDLE *OldStdIn,\r
132 OUT SHELL_FILE_HANDLE *OldStdOut,\r
133 OUT SHELL_FILE_HANDLE *OldStdErr,\r
134 OUT SYSTEM_TABLE_INFO *SystemTableInfo\r
a405b86d 135 );\r
136\r
137/**\r
6a5033ca 138 Function will replace the current StdIn and StdOut in the ShellParameters protocol\r
a405b86d 139 structure with StdIn and StdOut. The current values are de-allocated.\r
140\r
4ff7e37b
ED
141 @param[in, out] ShellParameters Pointer to parameter structure to modify.\r
142 @param[in] OldStdIn Pointer to old StdIn.\r
143 @param[in] OldStdOut Pointer to old StdOut.\r
144 @param[in] OldStdErr Pointer to old StdErr.\r
145 @param[in] SystemTableInfo Pointer to old system table information.\r
a405b86d 146**/\r
147EFI_STATUS\r
a405b86d 148RestoreStdInStdOutStdErr (\r
149 IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r
8be0ba36 150 IN SHELL_FILE_HANDLE *OldStdIn,\r
151 IN SHELL_FILE_HANDLE *OldStdOut,\r
152 IN SHELL_FILE_HANDLE *OldStdErr,\r
153 IN SYSTEM_TABLE_INFO *SystemTableInfo\r
a405b86d 154 );\r
155\r
156/**\r
157 function to populate Argc and Argv.\r
158\r
159 This function parses the CommandLine and divides it into standard C style Argc/Argv\r
160 parameters for inclusion in EFI_SHELL_PARAMETERS_PROTOCOL. this supports space\r
161 delimited and quote surrounded parameter definition.\r
162\r
d1c275c6
QS
163 @param[in] CommandLine String of command line to parse\r
164 @param[in] StripQuotation if TRUE then strip the quotation marks surrounding\r
165 the parameters.\r
166 @param[in, out] Argv pointer to array of strings; one for each parameter\r
167 @param[in, out] Argc pointer to number of strings in Argv array\r
a405b86d 168\r
6a5033ca 169 @return EFI_SUCCESS the operation was successful\r
ddb7050c 170 @return EFI_INVALID_PARAMETER some parameters are invalid\r
a405b86d 171 @return EFI_OUT_OF_RESOURCES a memory allocation failed.\r
172**/\r
173EFI_STATUS\r
a405b86d 174ParseCommandLineToArgs(\r
175 IN CONST CHAR16 *CommandLine,\r
d1c275c6
QS
176 IN BOOLEAN StripQuotation,\r
177 IN OUT CHAR16 ***Argv,\r
178 IN OUT UINTN *Argc\r
a405b86d 179 );\r
180\r
1219c85d
RN
181/**\r
182 return the next parameter from a command line string;\r
183\r
184 This function moves the next parameter from Walker into TempParameter and moves\r
185 Walker up past that parameter for recursive calling. When the final parameter\r
186 is moved *Walker will be set to NULL;\r
187\r
188 Temp Parameter must be large enough to hold the parameter before calling this\r
189 function.\r
190\r
191 @param[in, out] Walker pointer to string of command line. Adjusted to\r
6a5033ca 192 remaining command line on return\r
1219c85d
RN
193 @param[in, out] TempParameter pointer to string of command line item extracted.\r
194 @param[in] Length Length of (*TempParameter) in bytes\r
195 @param[in] StripQuotation if TRUE then strip the quotation marks surrounding\r
196 the parameters.\r
197\r
6a5033ca 198 @return EFI_INVALID_PARAMETER A required parameter was NULL or pointed to a NULL or empty string.\r
1219c85d
RN
199 @return EFI_NOT_FOUND A closing " could not be found on the specified string\r
200**/\r
201EFI_STATUS\r
1219c85d
RN
202GetNextParameter(\r
203 IN OUT CHAR16 **Walker,\r
204 IN OUT CHAR16 **TempParameter,\r
205 IN CONST UINTN Length,\r
206 IN BOOLEAN StripQuotation\r
207 );\r
208\r
a405b86d 209#endif //_SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_\r
210\r