]>
Commit | Line | Data |
---|---|---|
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 | |
5 | Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r | |
6 | This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #ifndef _SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_\r | |
17 | #define _SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_\r | |
18 | \r | |
19 | #include "Shell.h"\r | |
20 | \r | |
21 | /**\r | |
22 | creates a new EFI_SHELL_PARAMETERS_PROTOCOL instance and populates it and then\r | |
23 | installs it on our handle and if there is an existing version of the protocol\r | |
24 | that one is cached for removal later.\r | |
25 | \r | |
26 | @param[in, out] NewShellParameters on a successful return, a pointer to pointer\r | |
27 | to the newly installed interface.\r | |
28 | @param[in, out] RootShellInstance on a successful return, pointer to boolean.\r | |
29 | TRUE if this is the root shell instance.\r | |
30 | \r | |
31 | @retval EFI_SUCCESS the operation completed successfully.\r | |
32 | @return other the operation failed.\r | |
33 | @sa ReinstallProtocolInterface\r | |
34 | @sa InstallProtocolInterface\r | |
35 | @sa ParseCommandLineToArgs\r | |
36 | **/\r | |
37 | EFI_STATUS\r | |
38 | EFIAPI\r | |
39 | CreatePopulateInstallShellParametersProtocol (\r | |
40 | IN OUT EFI_SHELL_PARAMETERS_PROTOCOL **NewShellParameters,\r | |
41 | IN OUT BOOLEAN *RootShellInstance\r | |
42 | );\r | |
43 | \r | |
44 | /**\r | |
45 | frees all memory used by createion and installation of shell parameters protocol\r | |
46 | and if there was an old version installed it will restore that one.\r | |
47 | \r | |
48 | @param NewShellParameters the interface of EFI_SHELL_PARAMETERS_PROTOCOL that is\r | |
49 | being cleaned up.\r | |
50 | \r | |
51 | @retval EFI_SUCCESS the cleanup was successful\r | |
52 | @return other the cleanup failed\r | |
53 | @sa ReinstallProtocolInterface\r | |
54 | @sa UninstallProtocolInterface\r | |
55 | **/\r | |
56 | EFI_STATUS\r | |
57 | EFIAPI\r | |
58 | CleanUpShellParametersProtocol (\r | |
59 | IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *NewShellParameters\r | |
60 | );\r | |
61 | \r | |
62 | /**\r | |
63 | Funcion will replace the current Argc and Argv in the ShellParameters protocol\r | |
64 | structure by parsing NewCommandLine. The current values are returned to the\r | |
65 | user.\r | |
66 | \r | |
67 | @param[in, out] ShellParameters pointer to parameter structure to modify\r | |
68 | @param[in] NewCommandLine the new command line to parse and use\r | |
69 | @param[out] OldArgv pointer to old list of parameters\r | |
70 | @param[out] OldArgc pointer to old number of items in Argv list\r | |
71 | \r | |
72 | @retval EFI_SUCCESS operation was sucessful, Argv and Argc are valid\r | |
73 | @retval EFI_OUT_OF_RESOURCES a memory allocation failed.\r | |
74 | **/\r | |
75 | EFI_STATUS\r | |
76 | EFIAPI\r | |
77 | UpdateArgcArgv(\r | |
78 | IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r | |
79 | IN CONST CHAR16 *NewCommandLine,\r | |
80 | OUT CHAR16 ***OldArgv,\r | |
81 | OUT UINTN *OldArgc\r | |
82 | );\r | |
83 | \r | |
84 | /**\r | |
85 | Funcion will replace the current Argc and Argv in the ShellParameters protocol\r | |
86 | structure with Argv and Argc. The current values are de-allocated and the\r | |
87 | OldArgv must not be deallocated by the caller.\r | |
88 | \r | |
89 | @param[in, out] ShellParameters pointer to parameter structure to modify\r | |
90 | @param[in] OldArgv pointer to old list of parameters\r | |
91 | @param[in] OldArgc pointer to old number of items in Argv list\r | |
92 | **/\r | |
93 | VOID\r | |
94 | EFIAPI\r | |
95 | RestoreArgcArgv(\r | |
96 | IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r | |
97 | IN CHAR16 ***OldArgv,\r | |
98 | IN UINTN *OldArgc\r | |
99 | );\r | |
100 | \r | |
101 | typedef 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 | |
106 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ErrOut;\r | |
107 | EFI_HANDLE ErrOutHandle;\r | |
108 | } SYSTEM_TABLE_INFO;\r | |
109 | \r | |
110 | /**\r | |
111 | Funcion will replace the current StdIn and StdOut in the ShellParameters protocol\r | |
112 | structure by parsing NewCommandLine. The current values are returned to the\r | |
113 | user.\r | |
114 | \r | |
115 | This will also update the system table.\r | |
116 | \r | |
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 | |
123 | \r | |
124 | @retval EFI_SUCCESS Operation was sucessful, Argv and Argc are valid.\r | |
125 | @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r | |
126 | **/\r | |
127 | EFI_STATUS\r | |
128 | EFIAPI\r | |
129 | UpdateStdInStdOutStdErr(\r | |
130 | IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r | |
131 | IN CHAR16 *NewCommandLine,\r | |
132 | OUT SHELL_FILE_HANDLE *OldStdIn,\r | |
133 | OUT SHELL_FILE_HANDLE *OldStdOut,\r | |
134 | OUT SHELL_FILE_HANDLE *OldStdErr,\r | |
135 | OUT SYSTEM_TABLE_INFO *SystemTableInfo\r | |
136 | );\r | |
137 | \r | |
138 | /**\r | |
139 | Funcion will replace the current StdIn and StdOut in the ShellParameters protocol\r | |
140 | structure with StdIn and StdOut. The current values are de-allocated.\r | |
141 | \r | |
142 | @param[in, out] ShellParameters Pointer to parameter structure to modify.\r | |
143 | @param[in] OldStdIn Pointer to old StdIn.\r | |
144 | @param[in] OldStdOut Pointer to old StdOut.\r | |
145 | @param[in] OldStdErr Pointer to old StdErr.\r | |
146 | @param[in] SystemTableInfo Pointer to old system table information.\r | |
147 | **/\r | |
148 | EFI_STATUS\r | |
149 | EFIAPI\r | |
150 | RestoreStdInStdOutStdErr (\r | |
151 | IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,\r | |
152 | IN SHELL_FILE_HANDLE *OldStdIn,\r | |
153 | IN SHELL_FILE_HANDLE *OldStdOut,\r | |
154 | IN SHELL_FILE_HANDLE *OldStdErr,\r | |
155 | IN SYSTEM_TABLE_INFO *SystemTableInfo\r | |
156 | );\r | |
157 | \r | |
158 | /**\r | |
159 | function to populate Argc and Argv.\r | |
160 | \r | |
161 | This function parses the CommandLine and divides it into standard C style Argc/Argv\r | |
162 | parameters for inclusion in EFI_SHELL_PARAMETERS_PROTOCOL. this supports space\r | |
163 | delimited and quote surrounded parameter definition.\r | |
164 | \r | |
165 | @param[in] CommandLine String of command line to parse\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 | |
168 | \r | |
169 | @return EFI_SUCCESS the operation was sucessful\r | |
170 | @return EFI_OUT_OF_RESOURCES a memory allocation failed.\r | |
171 | **/\r | |
172 | EFI_STATUS\r | |
173 | EFIAPI\r | |
174 | ParseCommandLineToArgs(\r | |
175 | IN CONST CHAR16 *CommandLine,\r | |
176 | IN OUT CHAR16 ***Argv,\r | |
177 | IN OUT UINTN *Argc\r | |
178 | );\r | |
179 | \r | |
180 | /**\r | |
181 | return the next parameter from a command line string;\r | |
182 | \r | |
183 | This function moves the next parameter from Walker into TempParameter and moves\r | |
184 | Walker up past that parameter for recursive calling. When the final parameter\r | |
185 | is moved *Walker will be set to NULL;\r | |
186 | \r | |
187 | Temp Parameter must be large enough to hold the parameter before calling this\r | |
188 | function.\r | |
189 | \r | |
190 | @param[in, out] Walker pointer to string of command line. Adjusted to\r | |
191 | reminaing command line on return\r | |
192 | @param[in, out] TempParameter pointer to string of command line item extracted.\r | |
193 | @param[in] Length Length of (*TempParameter) in bytes\r | |
194 | \r | |
195 | @return EFI_INALID_PARAMETER A required parameter was NULL or pointed to a NULL or empty string.\r | |
196 | @return EFI_NOT_FOUND A closing " could not be found on the specified string\r | |
197 | **/\r | |
198 | EFI_STATUS\r | |
199 | EFIAPI\r | |
200 | GetNextParameter(\r | |
201 | IN OUT CHAR16 **Walker,\r | |
202 | IN OUT CHAR16 **TempParameter,\r | |
203 | IN CONST UINTN Length\r | |
204 | );\r | |
205 | \r | |
206 | #endif //_SHELL_PARAMETERS_PROTOCOL_PROVIDER_HEADER_\r | |
207 | \r |