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