]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Include/Library/ShellLib.h
update copyright format
[mirror_edk2.git] / ShellPkg / Include / Library / ShellLib.h
CommitLineData
94b17fa1 1/** @file\r
2 Provides interface to shell functionality for shell commands and applications.\r
3\r
1e6e84c7 4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
5 This program and the accompanying materials\r
b3011f40 6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
94b17fa1 9\r
b3011f40 10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
94b17fa1 12\r
13**/\r
14\r
15#if !defined(__SHELL_LIB__)\r
16#define __SHELL_LIB__\r
17\r
b3011f40 18#include <Uefi.h>\r
19#include <Guid/FileInfo.h>\r
94b17fa1 20#include <Protocol/SimpleFileSystem.h>\r
b3011f40 21#include <Protocol/LoadedImage.h>\r
22#include <Protocol/EfiShellInterface.h>\r
23#include <Protocol/EfiShellEnvironment2.h>\r
94b17fa1 24#include <Protocol/EfiShell.h>\r
b3011f40 25#include <Protocol/EfiShellParameters.h>\r
94b17fa1 26\r
27/**\r
1e6e84c7 28 This function will retrieve the information about the file for the handle\r
94b17fa1 29 specified and store it in allocated pool memory.\r
30\r
1e6e84c7 31 This function allocates a buffer to store the file's information. It is the\r
18cefebe 32 caller's responsibility to free the buffer.\r
94b17fa1 33\r
1e6e84c7 34 @param[in] FileHandle The file handle of the file for which information is\r
18cefebe 35 being requested.\r
94b17fa1 36\r
18cefebe 37 @retval NULL Information could not be retrieved.\r
94b17fa1 38\r
18cefebe 39 @return The information about the file.\r
94b17fa1 40**/\r
41EFI_FILE_INFO*\r
42EFIAPI\r
43ShellGetFileInfo (\r
44 IN EFI_FILE_HANDLE FileHandle\r
45 );\r
46\r
47/**\r
1e6e84c7 48 This function will set the information about the file for the opened handle\r
94b17fa1 49 specified.\r
50\r
1e6e84c7 51 @param[in] FileHandle The file handle of the file for which information\r
a5bd42b9 52 is being set.\r
94b17fa1 53\r
18cefebe 54 @param[in] FileInfo The infotmation to set.\r
94b17fa1 55\r
9eb53ac3 56 @retval EFI_SUCCESS The information was set.\r
94b17fa1 57 @retval EFI_UNSUPPORTED The InformationType is not known.\r
58 @retval EFI_NO_MEDIA The device has no medium.\r
59 @retval EFI_DEVICE_ERROR The device reported an error.\r
60 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
61 @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r
62 @retval EFI_ACCESS_DENIED The file was opened read only.\r
63 @retval EFI_VOLUME_FULL The volume is full.\r
64**/\r
65EFI_STATUS\r
66EFIAPI\r
67ShellSetFileInfo (\r
68 IN EFI_FILE_HANDLE FileHandle,\r
69 IN EFI_FILE_INFO *FileInfo\r
70 );\r
71\r
72/**\r
73 This function will open a file or directory referenced by DevicePath.\r
74\r
1e6e84c7 75 This function opens a file with the open mode according to the file path. The\r
94b17fa1 76 Attributes is valid only for EFI_FILE_MODE_CREATE.\r
77\r
1e6e84c7 78 @param[in] FilePath On input the device path to the file. On output\r
b3011f40 79 the remaining device path.\r
80 @param[out] DeviceHandle Pointer to the system device handle.\r
81 @param[out] FileHandle Pointer to the file handle.\r
82 @param[in] OpenMode The mode to open the file with.\r
83 @param[in] Attributes The file's file attributes.\r
94b17fa1 84\r
85 @retval EFI_SUCCESS The information was set.\r
86 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
1e6e84c7 87 @retval EFI_UNSUPPORTED Could not open the file path.\r
88 @retval EFI_NOT_FOUND The specified file could not be found on the\r
89 device or the file system could not be found on\r
94b17fa1 90 the device.\r
91 @retval EFI_NO_MEDIA The device has no medium.\r
1e6e84c7 92 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the\r
94b17fa1 93 medium is no longer supported.\r
94 @retval EFI_DEVICE_ERROR The device reported an error.\r
95 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
96 @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r
97 @retval EFI_ACCESS_DENIED The file was opened read only.\r
1e6e84c7 98 @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the\r
94b17fa1 99 file.\r
100 @retval EFI_VOLUME_FULL The volume is full.\r
101**/\r
102EFI_STATUS\r
103EFIAPI\r
104ShellOpenFileByDevicePath(\r
105 IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,\r
106 OUT EFI_HANDLE *DeviceHandle,\r
107 OUT EFI_FILE_HANDLE *FileHandle,\r
108 IN UINT64 OpenMode,\r
109 IN UINT64 Attributes\r
110 );\r
111\r
112/**\r
113 This function will open a file or directory referenced by filename.\r
114\r
1e6e84c7 115 If return is EFI_SUCCESS, the Filehandle is the opened file's handle;\r
116 otherwise, the Filehandle is NULL. The Attributes is valid only for\r
94b17fa1 117 EFI_FILE_MODE_CREATE.\r
118\r
18cefebe 119 @param[in] FileName Pointer to file name.\r
120 @param[out] FileHandle Pointer to the file handle.\r
121 @param[in] OpenMode The mode to open the file with.\r
122 @param[in] Attributes The file's file attributes.\r
94b17fa1 123\r
9eb53ac3 124 @retval EFI_SUCCESS The information was set.\r
94b17fa1 125 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
1e6e84c7 126 @retval EFI_UNSUPPORTED Could not open the file path.\r
127 @retval EFI_NOT_FOUND The specified file could not be found on the\r
128 device or the file system could not be found\r
94b17fa1 129 on the device.\r
9eb53ac3 130 @retval EFI_NO_MEDIA The device has no medium.\r
1e6e84c7 131 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the\r
94b17fa1 132 medium is no longer supported.\r
9eb53ac3 133 @retval EFI_DEVICE_ERROR The device reported an error.\r
94b17fa1 134 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
9eb53ac3 135 @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r
136 @retval EFI_ACCESS_DENIED The file was opened read only.\r
1e6e84c7 137 @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the\r
94b17fa1 138 file.\r
9eb53ac3 139 @retval EFI_VOLUME_FULL The volume is full.\r
94b17fa1 140**/\r
141EFI_STATUS\r
142EFIAPI\r
143ShellOpenFileByName(\r
b82bfcc1 144 IN CONST CHAR16 *FilePath,\r
94b17fa1 145 OUT EFI_FILE_HANDLE *FileHandle,\r
146 IN UINT64 OpenMode,\r
147 IN UINT64 Attributes\r
148 );\r
149\r
150/**\r
18cefebe 151 This function creates a directory.\r
94b17fa1 152\r
1e6e84c7 153 If return is EFI_SUCCESS, the Filehandle is the opened directory's handle;\r
154 otherwise, the Filehandle is NULL. If the directory already existed, this\r
94b17fa1 155 function opens the existing directory.\r
156\r
18cefebe 157 @param[in] DirectoryName Pointer to Directory name.\r
158 @param[out] FileHandle Pointer to the file handle.\r
94b17fa1 159\r
160 @retval EFI_SUCCESS The information was set.\r
161 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
1e6e84c7 162 @retval EFI_UNSUPPORTED Could not open the file path.\r
163 @retval EFI_NOT_FOUND The specified file could not be found on the\r
164 device or the file system could not be found\r
94b17fa1 165 on the device.\r
9eb53ac3 166 @retval EFI_NO_MEDIA The device has no medium.\r
1e6e84c7 167 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the\r
94b17fa1 168 medium is no longer supported.\r
9eb53ac3 169 @retval EFI_DEVICE_ERROR The device reported an error.\r
94b17fa1 170 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
9eb53ac3 171 @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r
172 @retval EFI_ACCESS_DENIED The file was opened read only.\r
1e6e84c7 173 @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the\r
94b17fa1 174 file.\r
9eb53ac3 175 @retval EFI_VOLUME_FULL The volume is full.\r
94b17fa1 176**/\r
177EFI_STATUS\r
178EFIAPI\r
179ShellCreateDirectory(\r
b82bfcc1 180 IN CONST CHAR16 *DirectoryName,\r
94b17fa1 181 OUT EFI_FILE_HANDLE *FileHandle\r
182 );\r
183\r
184/**\r
185 This function reads information from an opened file.\r
186\r
1e6e84c7 187 If FileHandle is not a directory, the function reads the requested number of\r
188 bytes from the file at the file's current position and returns them in Buffer.\r
94b17fa1 189 If the read goes beyond the end of the file, the read length is truncated to the\r
1e6e84c7 190 end of the file. The file's current position is increased by the number of bytes\r
191 returned. If FileHandle is a directory, the function reads the directory entry\r
192 at the file's current position and returns the entry in Buffer. If the Buffer\r
193 is not large enough to hold the current directory entry, then\r
194 EFI_BUFFER_TOO_SMALL is returned and the current file position is not updated.\r
195 BufferSize is set to be the size of the buffer needed to read the entry. On\r
196 success, the current position is updated to the next directory entry. If there\r
197 are no more directory entries, the read returns a zero-length buffer.\r
94b17fa1 198 EFI_FILE_INFO is the structure returned as the directory entry.\r
199\r
18cefebe 200 @param[in] FileHandle The opened file handle.\r
1e6e84c7 201 @param[in] ReadSize On input the size of buffer in bytes. On return\r
94b17fa1 202 the number of bytes written.\r
18cefebe 203 @param[out] Buffer The buffer to put read data into.\r
94b17fa1 204\r
125c2cf4 205 @retval EFI_SUCCESS Data was read.\r
206 @retval EFI_NO_MEDIA The device has no media.\r
207 @retval EFI_DEVICE_ERROR The device reported an error.\r
208 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
1e6e84c7 209 @retval EFI_BUFFER_TO_SMALL Buffer is too small. ReadSize contains required\r
94b17fa1 210 size.\r
211\r
212**/\r
213EFI_STATUS\r
214EFIAPI\r
215ShellReadFile(\r
216 IN EFI_FILE_HANDLE FileHandle,\r
217 IN OUT UINTN *ReadSize,\r
218 OUT VOID *Buffer\r
219 );\r
220\r
221/**\r
222 Write data to a file.\r
223\r
1e6e84c7 224 This function writes the specified number of bytes to the file at the current\r
225 file position. The current file position is advanced the actual number of bytes\r
226 written, which is returned in BufferSize. Partial writes only occur when there\r
227 has been a data error during the write attempt (such as "volume space full").\r
228 The file is automatically grown to hold the data if required. Direct writes to\r
94b17fa1 229 opened directories are not supported.\r
230\r
18cefebe 231 @param[in] FileHandle The opened file for writing.\r
94b17fa1 232\r
18cefebe 233 @param[in] BufferSize On input the number of bytes in Buffer. On output\r
94b17fa1 234 the number of bytes written.\r
235\r
18cefebe 236 @param[in] Buffer The buffer containing data to write is stored.\r
94b17fa1 237\r
125c2cf4 238 @retval EFI_SUCCESS Data was written.\r
239 @retval EFI_UNSUPPORTED Writes to an open directory are not supported.\r
240 @retval EFI_NO_MEDIA The device has no media.\r
241 @retval EFI_DEVICE_ERROR The device reported an error.\r
242 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
243 @retval EFI_WRITE_PROTECTED The device is write-protected.\r
244 @retval EFI_ACCESS_DENIED The file was open for read only.\r
245 @retval EFI_VOLUME_FULL The volume is full.\r
94b17fa1 246**/\r
247EFI_STATUS\r
248EFIAPI\r
249ShellWriteFile(\r
250 IN EFI_FILE_HANDLE FileHandle,\r
251 IN OUT UINTN *BufferSize,\r
08d7f8e8 252 IN VOID *Buffer\r
94b17fa1 253 );\r
254\r
1e6e84c7 255/**\r
94b17fa1 256 Close an open file handle.\r
257\r
1e6e84c7 258 This function closes a specified file handle. All "dirty" cached file data is\r
259 flushed to the device, and the file is closed. In all cases the handle is\r
94b17fa1 260 closed.\r
261\r
18cefebe 262 @param[in] FileHandle The file handle to close.\r
94b17fa1 263\r
125c2cf4 264 @retval EFI_SUCCESS The file handle was closed sucessfully.\r
265 @retval INVALID_PARAMETER One of the parameters has an invalid value.\r
94b17fa1 266**/\r
267EFI_STATUS\r
268EFIAPI\r
269ShellCloseFile (\r
270 IN EFI_FILE_HANDLE *FileHandle\r
271 );\r
272\r
273/**\r
274 Delete a file and close the handle\r
275\r
276 This function closes and deletes a file. In all cases the file handle is closed.\r
1e6e84c7 277 If the file cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is\r
94b17fa1 278 returned, but the handle is still closed.\r
279\r
18cefebe 280 @param[in] FileHandle The file handle to delete.\r
94b17fa1 281\r
125c2cf4 282 @retval EFI_SUCCESS The file was closed sucessfully.\r
1e6e84c7 283 @retval EFI_WARN_DELETE_FAILURE The handle was closed, but the file was not\r
125c2cf4 284 deleted.\r
285 @retval INVALID_PARAMETER One of the parameters has an invalid value.\r
94b17fa1 286**/\r
287EFI_STATUS\r
288EFIAPI\r
289ShellDeleteFile (\r
290 IN EFI_FILE_HANDLE *FileHandle\r
291 );\r
292\r
293/**\r
294 Set the current position in a file.\r
295\r
1e6e84c7 296 This function sets the current file position for the handle to the position\r
94b17fa1 297 supplied. With the exception of seeking to position 0xFFFFFFFFFFFFFFFF, only\r
1e6e84c7 298 absolute positioning is supported, and seeking past the end of the file is\r
299 allowed (a subsequent write would grow the file). Seeking to position\r
94b17fa1 300 0xFFFFFFFFFFFFFFFF causes the current position to be set to the end of the file.\r
1e6e84c7 301 If FileHandle is a directory, the only position that may be set is zero. This\r
94b17fa1 302 has the effect of starting the read process of the directory entries over.\r
303\r
18cefebe 304 @param[in] FileHandle The file handle on which the position is being set.\r
94b17fa1 305\r
18cefebe 306 @param[in] Position Byte position from begining of file.\r
94b17fa1 307\r
308 @retval EFI_SUCCESS Operation completed sucessfully.\r
1e6e84c7 309 @retval EFI_UNSUPPORTED The seek request for non-zero is not valid on\r
94b17fa1 310 directories.\r
311 @retval INVALID_PARAMETER One of the parameters has an invalid value.\r
312**/\r
313EFI_STATUS\r
314EFIAPI\r
315ShellSetFilePosition (\r
316 IN EFI_FILE_HANDLE FileHandle,\r
317 IN UINT64 Position\r
318 );\r
319\r
1e6e84c7 320/**\r
94b17fa1 321 Gets a file's current position\r
322\r
1e6e84c7 323 This function retrieves the current file position for the file handle. For\r
324 directories, the current file position has no meaning outside of the file\r
94b17fa1 325 system driver and as such the operation is not supported. An error is returned\r
326 if FileHandle is a directory.\r
327\r
18cefebe 328 @param[in] FileHandle The open file handle on which to get the position.\r
329 @param[out] Position Byte position from begining of file.\r
94b17fa1 330\r
18cefebe 331 @retval EFI_SUCCESS The operation completed sucessfully.\r
94b17fa1 332 @retval INVALID_PARAMETER One of the parameters has an invalid value.\r
18cefebe 333 @retval EFI_UNSUPPORTED The request is not valid on directories.\r
94b17fa1 334**/\r
335EFI_STATUS\r
336EFIAPI\r
337ShellGetFilePosition (\r
338 IN EFI_FILE_HANDLE FileHandle,\r
339 OUT UINT64 *Position\r
340 );\r
341\r
342/**\r
343 Flushes data on a file\r
1e6e84c7 344\r
94b17fa1 345 This function flushes all modified data associated with a file to a device.\r
346\r
18cefebe 347 @param[in] FileHandle The file handle on which to flush data.\r
94b17fa1 348\r
349 @retval EFI_SUCCESS The data was flushed.\r
350 @retval EFI_NO_MEDIA The device has no media.\r
351 @retval EFI_DEVICE_ERROR The device reported an error.\r
352 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
353 @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r
354 @retval EFI_ACCESS_DENIED The file was opened for read only.\r
355**/\r
356EFI_STATUS\r
357EFIAPI\r
358ShellFlushFile (\r
359 IN EFI_FILE_HANDLE FileHandle\r
360 );\r
361\r
362/**\r
363 Retrieves the first file from a directory\r
364\r
1e6e84c7 365 This function takes an open directory handle and gets the first file\r
366 in the directory's info. Caller can use ShellFindNextFile() to get\r
94b17fa1 367 subsequent files.\r
368\r
d2b4564b 369 Caller must use FreePool on *Buffer opon completion of all file searching.\r
370\r
18cefebe 371 @param[in] DirHandle The file handle of the directory to search\r
372 @param[out] Buffer Pointer to pointer to buffer for file's information\r
94b17fa1 373\r
374 @retval EFI_SUCCESS Found the first file.\r
375 @retval EFI_NOT_FOUND Cannot find the directory.\r
376 @retval EFI_NO_MEDIA The device has no media.\r
377 @retval EFI_DEVICE_ERROR The device reported an error.\r
378 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
379 @return ShellReadFile\r
380**/\r
381EFI_STATUS\r
382EFIAPI\r
383ShellFindFirstFile (\r
384 IN EFI_FILE_HANDLE DirHandle,\r
d2b4564b 385 OUT EFI_FILE_INFO **Buffer\r
94b17fa1 386 );\r
387\r
388/**\r
389 Retrieves the next file in a directory.\r
390\r
1e6e84c7 391 To use this function, caller must call the ShellFindFirstFile() to get the\r
392 first file, and then use this function get other files. This function can be\r
393 called for several times to get each file's information in the directory. If\r
394 the call of ShellFindNextFile() got the last file in the directory, the next\r
395 call of this function has no file to get. *NoFile will be set to TRUE and the\r
396 data in Buffer is meaningless.\r
94b17fa1 397\r
18cefebe 398 @param[in] DirHandle The file handle of the directory.\r
399 @param[out] Buffer Pointer to buffer for file's information.\r
400 @param[out] NoFile Pointer to boolean when last file is found.\r
94b17fa1 401\r
402 @retval EFI_SUCCESS Found the next file.\r
403 @retval EFI_NO_MEDIA The device has no media.\r
404 @retval EFI_DEVICE_ERROR The device reported an error.\r
405 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
406**/\r
407EFI_STATUS\r
408EFIAPI\r
409ShellFindNextFile(\r
410 IN EFI_FILE_HANDLE DirHandle,\r
411 OUT EFI_FILE_INFO *Buffer,\r
412 OUT BOOLEAN *NoFile\r
413 );\r
414\r
415/**\r
416 Retrieve the size of a file.\r
417\r
1e6e84c7 418 This function extracts the file size info from the FileHandle's EFI_FILE_INFO\r
94b17fa1 419 data.\r
420\r
18cefebe 421 @param[in] FileHandle The file handle from which size is retrieved.\r
422 @param[out] Size Pointer to size.\r
94b17fa1 423\r
125c2cf4 424 @retval EFI_SUCCESS The operation was completed sucessfully.\r
a31bd33c 425 @retval EFI_DEVICE_ERROR Cannot access the file.\r
94b17fa1 426**/\r
427EFI_STATUS\r
428EFIAPI\r
429ShellGetFileSize (\r
430 IN EFI_FILE_HANDLE FileHandle,\r
431 OUT UINT64 *Size\r
432 );\r
433\r
434/**\r
435 Retrieves the status of the break execution flag\r
436\r
18cefebe 437 This function is useful to check whether the application is being asked to halt by the shell.\r
94b17fa1 438\r
439 @retval TRUE the execution break is enabled\r
440 @retval FALSE the execution break is not enabled\r
441**/\r
442BOOLEAN\r
443EFIAPI\r
444ShellGetExecutionBreakFlag(\r
445 VOID\r
446 );\r
447\r
448/**\r
125c2cf4 449 Return the value of an environment variable.\r
94b17fa1 450\r
1e6e84c7 451 This function gets the value of the environment variable set by the\r
125c2cf4 452 ShellSetEnvironmentVariable function.\r
94b17fa1 453\r
18cefebe 454 @param[in] EnvKey The key name of the environment variable.\r
94b17fa1 455\r
a31bd33c 456 @retval NULL The named environment variable does not exist.\r
125c2cf4 457 @return != NULL pointer to the value of the environment variable.\r
94b17fa1 458**/\r
459CONST CHAR16*\r
460EFIAPI\r
461ShellGetEnvironmentVariable (\r
9b3bf083 462 IN CONST CHAR16 *EnvKey\r
94b17fa1 463 );\r
464\r
465/**\r
18cefebe 466 Set the value of an environment variable.\r
94b17fa1 467\r
125c2cf4 468 This function changes the current value of the specified environment variable. If the\r
469 environment variable exists and the Value is an empty string, then the environment\r
470 variable is deleted. If the environment variable exists and the Value is not an empty\r
471 string, then the value of the environment variable is changed. If the environment\r
472 variable does not exist and the Value is an empty string, there is no action. If the\r
473 environment variable does not exist and the Value is a non-empty string, then the\r
474 environment variable is created and assigned the specified value.\r
94b17fa1 475\r
476 This is not supported pre-UEFI Shell 2.0.\r
477\r
18cefebe 478 @param[in] EnvKey The key name of the environment variable.\r
479 @param[in] EnvVal The Value of the environment variable\r
480 @param[in] Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).\r
94b17fa1 481\r
482 @retval EFI_SUCCESS the operation was completed sucessfully\r
483 @retval EFI_UNSUPPORTED This operation is not allowed in pre UEFI 2.0 Shell environments\r
484**/\r
485EFI_STATUS\r
486EFIAPI\r
487ShellSetEnvironmentVariable (\r
488 IN CONST CHAR16 *EnvKey,\r
489 IN CONST CHAR16 *EnvVal,\r
490 IN BOOLEAN Volatile\r
491 );\r
492\r
493/**\r
125c2cf4 494 Cause the shell to parse and execute a command line.\r
94b17fa1 495\r
496 This function creates a nested instance of the shell and executes the specified\r
125c2cf4 497 command (CommandLine) with the specified environment (Environment). Upon return,\r
498 the status code returned by the specified command is placed in StatusCode.\r
499 If Environment is NULL, then the current environment is used and all changes made\r
500 by the commands executed will be reflected in the current environment. If the\r
501 Environment is non-NULL, then the changes made will be discarded.\r
502 The CommandLine is executed from the current working directory on the current\r
503 device.\r
94b17fa1 504\r
18cefebe 505 EnvironmentVariables and Status are only supported for UEFI Shell 2.0 (or later).\r
125c2cf4 506 Output is only supported for pre-UEFI Shell 2.0\r
94b17fa1 507\r
18cefebe 508 @param[in] ImageHandle Parent image that is starting the operation.\r
1e6e84c7 509 @param[in] CommandLine Pointer to NULL terminated command line.\r
18cefebe 510 @param[in] Output True to display debug output. False to hide it.\r
511 @param[in] EnvironmentVariables Optional pointer to array of environment variables\r
512 in the form "x=y". If NULL current set is used.\r
513 @param[out] Status The status of the run command line.\r
94b17fa1 514\r
18cefebe 515 @retval EFI_SUCCESS The operation completed sucessfully. Status\r
516 contains the status code returned.\r
517 @retval EFI_INVALID_PARAMETER A parameter contains an invalid value.\r
518 @retval EFI_OUT_OF_RESOURCES Out of resources.\r
519 @retval EFI_UNSUPPORTED The operation is not allowed.\r
94b17fa1 520**/\r
521EFI_STATUS\r
522EFIAPI\r
523ShellExecute (\r
524 IN EFI_HANDLE *ParentHandle,\r
525 IN CHAR16 *CommandLine,\r
526 IN BOOLEAN Output,\r
527 IN CHAR16 **EnvironmentVariables,\r
528 OUT EFI_STATUS *Status\r
529 );\r
530\r
531/**\r
a31bd33c 532 Retreives the current directory path.\r
94b17fa1 533\r
1e6e84c7 534 If the DeviceName is NULL, it returns the current device's current directory\r
535 name. If the DeviceName is not NULL, it returns the current directory name\r
94b17fa1 536 on specified drive.\r
537\r
18cefebe 538 @param[in] DeviceName The name of the file system to get directory on.\r
94b17fa1 539\r
a31bd33c 540 @retval NULL The directory does not exist.\r
18cefebe 541 @retval != NULL The directory.\r
94b17fa1 542**/\r
543CONST CHAR16*\r
544EFIAPI\r
545ShellGetCurrentDir (\r
546 IN CHAR16 *DeviceName OPTIONAL\r
547 );\r
548\r
549/**\r
125c2cf4 550 Sets (enabled or disabled) the page break mode.\r
94b17fa1 551\r
1e6e84c7 552 When page break mode is enabled the screen will stop scrolling\r
94b17fa1 553 and wait for operator input before scrolling a subsequent screen.\r
554\r
18cefebe 555 @param[in] CurrentState TRUE to enable and FALSE to disable.\r
94b17fa1 556**/\r
1e6e84c7 557VOID\r
94b17fa1 558EFIAPI\r
559ShellSetPageBreakMode (\r
560 IN BOOLEAN CurrentState\r
561 );\r
562\r
563/**\r
564 Opens a group of files based on a path.\r
565\r
1e6e84c7 566 This function uses the Arg to open all the matching files. Each matched\r
567 file has a SHELL_FILE_ARG structure to record the file information. These\r
568 structures are placed on the list ListHead. Users can get the SHELL_FILE_ARG\r
94b17fa1 569 structures from ListHead to access each file. This function supports wildcards\r
1e6e84c7 570 and will process '?' and '*' as such. The list must be freed with a call to\r
94b17fa1 571 ShellCloseFileMetaArg().\r
572\r
1e6e84c7 573 If you are NOT appending to an existing list *ListHead must be NULL. If\r
eb646684 574 *ListHead is NULL then it must be callee freed.\r
94b17fa1 575\r
18cefebe 576 @param[in] Arg Pointer to path string.\r
577 @param[in] OpenMode Mode to open files with.\r
578 @param[in] ListHead Head of linked list of results.\r
94b17fa1 579\r
1e6e84c7 580 @retval EFI_SUCCESS The operation was sucessful and the list head\r
125c2cf4 581 contains the list of opened files.\r
a31bd33c 582 @retval != EFI_SUCCESS The operation failed.\r
94b17fa1 583\r
584 @sa InternalShellConvertFileListType\r
585**/\r
586EFI_STATUS\r
587EFIAPI\r
588ShellOpenFileMetaArg (\r
589 IN CHAR16 *Arg,\r
590 IN UINT64 OpenMode,\r
591 IN OUT EFI_SHELL_FILE_INFO **ListHead\r
592 );\r
593\r
594/**\r
a31bd33c 595 Free the linked list returned from ShellOpenFileMetaArg.\r
94b17fa1 596\r
18cefebe 597 @param[in] ListHead The pointer to free.\r
94b17fa1 598\r
a31bd33c 599 @retval EFI_SUCCESS The operation was sucessful.\r
600 @retval EFI_INVALID_PARAMETER A parameter was invalid.\r
94b17fa1 601**/\r
602EFI_STATUS\r
603EFIAPI\r
604ShellCloseFileMetaArg (\r
605 IN OUT EFI_SHELL_FILE_INFO **ListHead\r
606 );\r
607\r
125c2cf4 608/**\r
609 Find a file by searching the CWD and then the path.\r
610\r
a31bd33c 611 If FileName is NULL, then ASSERT.\r
125c2cf4 612\r
a31bd33c 613 If the return value is not NULL then the memory must be caller freed.\r
125c2cf4 614\r
18cefebe 615 @param[in] FileName Filename string.\r
125c2cf4 616\r
a31bd33c 617 @retval NULL The file was not found.\r
18cefebe 618 @retval !NULL The path to the file.\r
125c2cf4 619**/\r
620CHAR16 *\r
621EFIAPI\r
622ShellFindFilePath (\r
623 IN CONST CHAR16 *FileName\r
624 );\r
625\r
b3011f40 626/**\r
1e6e84c7 627 Find a file by searching the CWD and then the path with a variable set of file\r
628 extensions. If the file is not found it will append each extension in the list\r
b3011f40 629 in the order provided and return the first one that is successful.\r
630\r
631 If FileName is NULL, then ASSERT.\r
632 If FileExtension is NULL, then behavior is identical to ShellFindFilePath.\r
633\r
634 If the return value is not NULL then the memory must be caller freed.\r
635\r
636 @param[in] FileName Filename string.\r
637 @param[in] FileExtension Semi-colon delimeted list of possible extensions.\r
638\r
639 @retval NULL The file was not found.\r
640 @retval !NULL The path to the file.\r
641**/\r
642CHAR16 *\r
643EFIAPI\r
644ShellFindFilePathEx (\r
645 IN CONST CHAR16 *FileName,\r
646 IN CONST CHAR16 *FileExtension\r
647 );\r
648\r
94b17fa1 649typedef enum {\r
18cefebe 650 TypeFlag = 0, ///< A flag that is present or not present only (IE "-a").\r
651 TypeValue, ///< A flag that has some data following it with a space (IE "-a 1").\r
652 TypePosition, ///< Some data that did not follow a parameter (IE "filename.txt").\r
653 TypeStart, ///< A flag that has variable value appended to the end (IE "-ad", "-afd", "-adf", etc...).\r
654 TypeDoubleValue, ///< A flag that has 2 space seperated value data following it (IE "-a 1 2").\r
655 TypeMaxValue, ///< A flag followed by all the command line data before the next flag.\r
94b17fa1 656 TypeMax,\r
657} ParamType;\r
658\r
659typedef struct {\r
660 CHAR16 *Name;\r
661 ParamType Type;\r
662} SHELL_PARAM_ITEM;\r
663\r
d2b4564b 664\r
665/// Helper structure for no parameters (besides -? and -b)\r
666extern SHELL_PARAM_ITEM EmptyParamList[];\r
667\r
94b17fa1 668/**\r
1e6e84c7 669 Checks the command line arguments passed against the list of valid ones.\r
94b17fa1 670 Optionally removes NULL values first.\r
1e6e84c7 671\r
94b17fa1 672 If no initialization is required, then return RETURN_SUCCESS.\r
1e6e84c7 673\r
18cefebe 674 @param[in] CheckList Pointer to list of parameters to check.\r
675 @param[out] CheckPackage Package of checked values.\r
1e6e84c7 676 @param[out] ProblemParam Optional pointer to pointer to unicode string for\r
94b17fa1 677 the paramater that caused failure.\r
18cefebe 678 @param[in] AutoPageBreak Will automatically set PageBreakEnabled.\r
679 @param[in] AlwaysAllowNumbers Will never fail for number based flags.\r
94b17fa1 680\r
681 @retval EFI_SUCCESS The operation completed sucessfully.\r
a31bd33c 682 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
683 @retval EFI_INVALID_PARAMETER A parameter was invalid.\r
1e6e84c7 684 @retval EFI_VOLUME_CORRUPTED The command line was corrupt. An argument was\r
685 duplicated. The duplicated command line argument\r
94b17fa1 686 was returned in ProblemParam if provided.\r
a31bd33c 687 @retval EFI_DEVICE_ERROR The commands contained 2 opposing arguments. One\r
1e6e84c7 688 of the command line arguments was returned in\r
94b17fa1 689 ProblemParam if provided.\r
1e6e84c7 690 @retval EFI_NOT_FOUND A argument required a value that was missing.\r
a31bd33c 691 The invalid command line argument was returned in\r
94b17fa1 692 ProblemParam if provided.\r
693**/\r
694EFI_STATUS\r
695EFIAPI\r
2247dde4 696ShellCommandLineParseEx (\r
94b17fa1 697 IN CONST SHELL_PARAM_ITEM *CheckList,\r
698 OUT LIST_ENTRY **CheckPackage,\r
699 OUT CHAR16 **ProblemParam OPTIONAL,\r
2247dde4 700 IN BOOLEAN AutoPageBreak,\r
701 IN BOOLEAN AlwaysAllowNumbers\r
94b17fa1 702 );\r
703\r
18cefebe 704/// Make it easy to upgrade from older versions of the shell library.\r
2247dde4 705#define ShellCommandLineParse(CheckList,CheckPackage,ProblemParam,AutoPageBreak) ShellCommandLineParseEx(CheckList,CheckPackage,ProblemParam,AutoPageBreak,FALSE)\r
706\r
94b17fa1 707/**\r
708 Frees shell variable list that was returned from ShellCommandLineParse.\r
709\r
710 This function will free all the memory that was used for the CheckPackage\r
711 list of postprocessed shell arguments.\r
712\r
a31bd33c 713 If CheckPackage is NULL, then return.\r
94b17fa1 714\r
18cefebe 715 @param[in] CheckPackage The list to de-allocate.\r
94b17fa1 716 **/\r
717VOID\r
718EFIAPI\r
719ShellCommandLineFreeVarList (\r
720 IN LIST_ENTRY *CheckPackage\r
721 );\r
722\r
723/**\r
a31bd33c 724 Checks for presence of a flag parameter.\r
94b17fa1 725\r
18cefebe 726 Flag arguments are in the form of "-<Key>" or "/<Key>", but do not have a value following the key.\r
94b17fa1 727\r
18cefebe 728 If CheckPackage is NULL then return FALSE.\r
729 If KeyString is NULL then ASSERT().\r
1e6e84c7 730\r
18cefebe 731 @param[in] CheckPackage The package of parsed command line arguments.\r
732 @param[in] KeyString The Key of the command line argument to check for.\r
94b17fa1 733\r
a31bd33c 734 @retval TRUE The flag is on the command line.\r
735 @retval FALSE The flag is not on the command line.\r
94b17fa1 736 **/\r
737BOOLEAN\r
738EFIAPI\r
739ShellCommandLineGetFlag (\r
740 IN CONST LIST_ENTRY *CheckPackage,\r
741 IN CHAR16 *KeyString\r
742 );\r
743\r
744/**\r
a31bd33c 745 Returns value from command line argument.\r
94b17fa1 746\r
18cefebe 747 Value parameters are in the form of "-<Key> value" or "/<Key> value".\r
1e6e84c7 748\r
a31bd33c 749 If CheckPackage is NULL, then return NULL.\r
94b17fa1 750\r
36a9d672 751 @param[in] CheckPackage The package of parsed command line arguments.\r
752 @param[in] KeyString The Key of the command line argument to check for.\r
94b17fa1 753\r
a31bd33c 754 @retval NULL The flag is not on the command line.\r
755 @retval !=NULL Pointer to unicode string of the value.\r
94b17fa1 756 **/\r
757CONST CHAR16*\r
758EFIAPI\r
759ShellCommandLineGetValue (\r
760 IN CONST LIST_ENTRY *CheckPackage,\r
761 IN CHAR16 *KeyString\r
762 );\r
763\r
764/**\r
a31bd33c 765 Returns raw value from command line argument.\r
94b17fa1 766\r
a31bd33c 767 Raw value parameters are in the form of "value" in a specific position in the list.\r
1e6e84c7 768\r
36a9d672 769 If CheckPackage is NULL, then return NULL.\r
94b17fa1 770\r
36a9d672 771 @param[in] CheckPackage The package of parsed command line arguments.\r
772 @param[in] Position The position of the value.\r
94b17fa1 773\r
a31bd33c 774 @retval NULL The flag is not on the command line.\r
775 @retval !=NULL Pointer to unicode string of the value.\r
94b17fa1 776 **/\r
777CONST CHAR16*\r
778EFIAPI\r
779ShellCommandLineGetRawValue (\r
780 IN CONST LIST_ENTRY *CheckPackage,\r
781 IN UINT32 Position\r
782 );\r
783\r
2247dde4 784/**\r
1e6e84c7 785 Returns the number of command line value parameters that were parsed.\r
786\r
a31bd33c 787 This will not include flags.\r
2247dde4 788\r
18cefebe 789 @retval (UINTN)-1 No parsing has ocurred.\r
790 @return The number of value parameters found.\r
2247dde4 791**/\r
792UINTN\r
793EFIAPI\r
794ShellCommandLineGetCount(\r
795 VOID\r
796 );\r
797\r
36a9d672 798/**\r
799 Determins if a parameter is duplicated.\r
800\r
1e6e84c7 801 If Param is not NULL then it will point to a callee allocated string buffer\r
36a9d672 802 with the parameter value if a duplicate is found.\r
803\r
804 If CheckPackage is NULL, then ASSERT.\r
805\r
806 @param[in] CheckPackage The package of parsed command line arguments.\r
807 @param[out] Param Upon finding one, a pointer to the duplicated parameter.\r
808\r
809 @retval EFI_SUCCESS No parameters were duplicated.\r
810 @retval EFI_DEVICE_ERROR A duplicate was found.\r
811 **/\r
812EFI_STATUS\r
813EFIAPI\r
814ShellCommandLineCheckDuplicate (\r
815 IN CONST LIST_ENTRY *CheckPackage,\r
816 OUT CHAR16 **Param\r
817 );\r
818\r
d2b4564b 819/**\r
820 This function causes the shell library to initialize itself. If the shell library\r
821 is already initialized it will de-initialize all the current protocol poitners and\r
822 re-populate them again.\r
823\r
824 When the library is used with PcdShellLibAutoInitialize set to true this function\r
825 will return EFI_SUCCESS and perform no actions.\r
826\r
827 This function is intended for internal access for shell commands only.\r
828\r
829 @retval EFI_SUCCESS the initialization was complete sucessfully\r
830\r
831**/\r
832EFI_STATUS\r
833EFIAPI\r
834ShellInitialize (\r
125c2cf4 835 VOID\r
d2b4564b 836 );\r
837\r
b1f95a06 838/**\r
839 Print at a specific location on the screen.\r
840\r
a5bd42b9 841 This function will move the cursor to a given screen location and print the specified string.\r
1e6e84c7 842\r
843 If -1 is specified for either the Row or Col the current screen location for BOTH\r
a5bd42b9 844 will be used.\r
b1f95a06 845\r
a31bd33c 846 If either Row or Col is out of range for the current console, then ASSERT.\r
847 If Format is NULL, then ASSERT.\r
b1f95a06 848\r
1e6e84c7 849 In addition to the standard %-based flags as supported by UefiLib Print() this supports\r
b1f95a06 850 the following additional flags:\r
851 %N - Set output attribute to normal\r
852 %H - Set output attribute to highlight\r
853 %E - Set output attribute to error\r
854 %B - Set output attribute to blue color\r
855 %V - Set output attribute to green color\r
856\r
857 Note: The background color is controlled by the shell command cls.\r
858\r
18cefebe 859 @param[in] Row The row to print at.\r
860 @param[in] Col The column to print at.\r
861 @param[in] Format The format string.\r
b1f95a06 862\r
18cefebe 863 @return The number of characters printed to the screen.\r
b1f95a06 864**/\r
865\r
866UINTN\r
867EFIAPI\r
868ShellPrintEx(\r
869 IN INT32 Col OPTIONAL,\r
870 IN INT32 Row OPTIONAL,\r
871 IN CONST CHAR16 *Format,\r
872 ...\r
873 );\r
874\r
2247dde4 875/**\r
876 Print at a specific location on the screen.\r
877\r
a5bd42b9 878 This function will move the cursor to a given screen location and print the specified string.\r
1e6e84c7 879\r
880 If -1 is specified for either the Row or Col the current screen location for BOTH\r
a5bd42b9 881 will be used.\r
2247dde4 882\r
a5bd42b9 883 If either Row or Col is out of range for the current console, then ASSERT.\r
884 If Format is NULL, then ASSERT.\r
2247dde4 885\r
1e6e84c7 886 In addition to the standard %-based flags as supported by UefiLib Print() this supports\r
2247dde4 887 the following additional flags:\r
18cefebe 888 %N - Set output attribute to normal.\r
889 %H - Set output attribute to highlight.\r
890 %E - Set output attribute to error.\r
891 %B - Set output attribute to blue color.\r
892 %V - Set output attribute to green color.\r
2247dde4 893\r
894 Note: The background color is controlled by the shell command cls.\r
895\r
18cefebe 896 @param[in] Row The row to print at.\r
897 @param[in] Col The column to print at.\r
1e6e84c7 898 @param[in] Language The language of the string to retrieve. If this parameter\r
899 is NULL, then the current platform language is used.\r
18cefebe 900 @param[in] HiiFormatStringId The format string Id for getting from Hii.\r
901 @param[in] HiiFormatHandle The format string Handle for getting from Hii.\r
2247dde4 902\r
18cefebe 903 @return the number of characters printed to the screen.\r
2247dde4 904**/\r
905UINTN\r
906EFIAPI\r
907ShellPrintHiiEx(\r
908 IN INT32 Col OPTIONAL,\r
909 IN INT32 Row OPTIONAL,\r
1e6e84c7 910 IN CONST CHAR8 *Language OPTIONAL,\r
2247dde4 911 IN CONST EFI_STRING_ID HiiFormatStringId,\r
912 IN CONST EFI_HANDLE HiiFormatHandle,\r
913 ...\r
914 );\r
915\r
916/**\r
a31bd33c 917 Function to determine if a given filename represents a directory.\r
2247dde4 918\r
18cefebe 919 If DirName is NULL, then ASSERT.\r
920\r
2247dde4 921 @param[in] DirName Path to directory to test.\r
922\r
a31bd33c 923 @retval EFI_SUCCESS The Path represents a directory.\r
924 @retval EFI_NOT_FOUND The Path does not represent a directory.\r
925 @retval other The path failed to open.\r
2247dde4 926**/\r
927EFI_STATUS\r
928EFIAPI\r
929ShellIsDirectory(\r
930 IN CONST CHAR16 *DirName\r
931 );\r
932\r
a31bd33c 933/**\r
934 Function to determine if a given filename represents a file.\r
935\r
b3011f40 936 This will search the CWD only.\r
937\r
18cefebe 938 If Name is NULL, then ASSERT.\r
939\r
a31bd33c 940 @param[in] Name Path to file to test.\r
941\r
942 @retval EFI_SUCCESS The Path represents a file.\r
943 @retval EFI_NOT_FOUND The Path does not represent a file.\r
944 @retval other The path failed to open.\r
945**/\r
946EFI_STATUS\r
947EFIAPI\r
948ShellIsFile(\r
949 IN CONST CHAR16 *Name\r
950 );\r
951\r
b3011f40 952/**\r
953 Function to determine if a given filename represents a file.\r
954\r
955 This will search the CWD and then the Path.\r
956\r
957 If Name is NULL, then ASSERT.\r
958\r
959 @param[in] Name Path to file to test.\r
960\r
961 @retval EFI_SUCCESS The Path represents a file.\r
962 @retval EFI_NOT_FOUND The Path does not represent a file.\r
963 @retval other The path failed to open.\r
964**/\r
965EFI_STATUS\r
966EFIAPI\r
967ShellIsFileInPath(\r
968 IN CONST CHAR16 *Name\r
969 );\r
970\r
125c2cf4 971/**\r
1e6e84c7 972 Function to determine whether a string is decimal or hex representation of a number\r
125c2cf4 973 and return the number converted from the string.\r
974\r
975 @param[in] String String representation of a number\r
976\r
a31bd33c 977 @return The unsigned integer result of the conversion.\r
125c2cf4 978**/\r
979UINTN\r
980EFIAPI\r
981ShellStrToUintn(\r
982 IN CONST CHAR16 *String\r
983 );\r
984\r
985/**\r
1e6e84c7 986 Safely append with automatic string resizing given length of Destination and\r
125c2cf4 987 desired length of copy from Source.\r
988\r
1e6e84c7 989 Append the first D characters of Source to the end of Destination, where D is\r
990 the lesser of Count and the StrLen() of Source. If appending those D characters\r
991 will fit within Destination (whose Size is given as CurrentSize) and\r
992 still leave room for a NULL terminator, then those characters are appended,\r
993 starting at the original terminating NULL of Destination, and a new terminating\r
994 NULL is appended.\r
125c2cf4 995\r
996 If appending D characters onto Destination will result in a overflow of the size\r
997 given in CurrentSize the string will be grown such that the copy can be performed\r
998 and CurrentSize will be updated to the new size.\r
999\r
1e6e84c7 1000 If Source is NULL, there is nothing to append, just return the current buffer in\r
125c2cf4 1001 Destination.\r
1002\r
18cefebe 1003 If Destination is NULL, then ASSERT().\r
1e6e84c7 1004 If Destination's current length (including NULL terminator) is already more than\r
a31bd33c 1005 CurrentSize, then ASSERT().\r
125c2cf4 1006\r
a31bd33c 1007 @param[in,out] Destination The String to append onto.\r
1e6e84c7 1008 @param[in,out] CurrentSize On call the number of bytes in Destination. On\r
18cefebe 1009 return possibly the new size (still in bytes). If NULL\r
125c2cf4 1010 then allocate whatever is needed.\r
a31bd33c 1011 @param[in] Source The String to append from.\r
1e6e84c7 1012 @param[in] Count Maximum number of characters to append. If 0 then\r
125c2cf4 1013 all are appended.\r
1014\r
18cefebe 1015 @return The Destination after apending the Source.\r
125c2cf4 1016**/\r
1e6e84c7 1017CHAR16*\r
125c2cf4 1018EFIAPI\r
1019StrnCatGrow (\r
1020 IN OUT CHAR16 **Destination,\r
1021 IN OUT UINTN *CurrentSize,\r
1022 IN CONST CHAR16 *Source,\r
1023 IN UINTN Count\r
1024 );\r
2247dde4 1025\r
b3011f40 1026/**\r
1e6e84c7 1027 This is a find and replace function. Upon successful return the NewString is a copy of\r
b3011f40 1028 SourceString with each instance of FindTarget replaced with ReplaceWith.\r
1029\r
1030 If SourceString and NewString overlap the behavior is undefined.\r
1031\r
1032 If the string would grow bigger than NewSize it will halt and return error.\r
1033\r
1034 @param[in] SourceString String with source buffer.\r
1035 @param[in,out] NewString String with resultant buffer.\r
1036 @param[in] NewSize Size in bytes of NewString.\r
1037 @param[in] FindTarget String to look for.\r
1038 @param[in] ReplaceWith String to replace FindTarget with.\r
969c783b 1039 @param[in] SkipPreCarrot If TRUE will skip a FindTarget that has a '^'\r
1040 immediately before it.\r
b3011f40 1041\r
1042 @retval EFI_INVALID_PARAMETER SourceString was NULL.\r
1043 @retval EFI_INVALID_PARAMETER NewString was NULL.\r
1044 @retval EFI_INVALID_PARAMETER FindTarget was NULL.\r
1045 @retval EFI_INVALID_PARAMETER ReplaceWith was NULL.\r
1046 @retval EFI_INVALID_PARAMETER FindTarget had length < 1.\r
1047 @retval EFI_INVALID_PARAMETER SourceString had length < 1.\r
1e6e84c7 1048 @retval EFI_BUFFER_TOO_SMALL NewSize was less than the minimum size to hold\r
b3011f40 1049 the new string (truncation occurred).\r
969c783b 1050 @retval EFI_SUCCESS The string was sucessfully copied with replacement.\r
b3011f40 1051**/\r
1052\r
1053EFI_STATUS\r
1054EFIAPI\r
969c783b 1055ShellCopySearchAndReplace2(\r
b3011f40 1056 IN CHAR16 CONST *SourceString,\r
1057 IN CHAR16 *NewString,\r
1058 IN UINTN NewSize,\r
1059 IN CONST CHAR16 *FindTarget,\r
969c783b 1060 IN CONST CHAR16 *ReplaceWith,\r
1061 IN CONST BOOLEAN SkipPreCarrot\r
b3011f40 1062 );\r
1063\r
969c783b 1064///\r
1065/// make upgrades easier from old version\r
1066///\r
1067#define ShellLibCopySearchAndReplace(a,b,c,d,e) ShellCopySearchAndReplace2(a,b,c,d,e,FALSE)\r
1068\r
b3011f40 1069/**\r
1070 Check if a Unicode character is a hexadecimal character.\r
1071\r
1e6e84c7 1072 This internal function checks if a Unicode character is a\r
1073 decimal character. The valid hexadecimal character is\r
b3011f40 1074 L'0' to L'9', L'a' to L'f', or L'A' to L'F'.\r
1075\r
1076 @param[in] Char The character to check.\r
1077\r
1078 @retval TRUE The Char is a hexadecmial character.\r
1079 @retval FALSE The Char is not a hexadecmial character.\r
1080\r
1081**/\r
1082BOOLEAN\r
1083EFIAPI\r
969c783b 1084ShellIsHexaDecimalDigitCharacter (\r
b3011f40 1085 IN CHAR16 Char\r
1086 );\r
1087\r
334f978e 1088///\r
1089/// What type of answer is requested\r
1090///\r
1091typedef enum {\r
1092 SHELL_PROMPT_REQUEST_TYPE_YES_NO,\r
1093 SHELL_PROMPT_REQUEST_TYPE_YES_NO_CANCEL,\r
1094 SHELL_PROMPT_REQUEST_TYPE_FREEFORM,\r
1095 SHELL_PROMPT_REQUEST_TYPE_QUIT_CONTINUE,\r
1096 SHELL_PROMPT_REQUEST_TYPE_YES_NO_ALL_CANCEL,\r
1097 SHELL_PROMPT_REQUEST_TYPE_ENTER_TO_COMTINUE,\r
1098 SHELL_PROMPT_REQUEST_TYPE_ANYKEY_TO_COMTINUE,\r
1099 SHELL_PROMPT_REQUEST_TYPE_MAX\r
1100} SHELL_PROMPT_REQUEST_TYPE;\r
1101\r
1102///\r
1103/// what answer was given\r
1104///\r
1105typedef enum {\r
1106 SHELL_PROMPT_RESPONSE_YES,\r
1107 SHELL_PROMPT_RESPONSE_NO,\r
1108 SHELL_PROMPT_RESPONSE_CANCEL,\r
1109 SHELL_PROMPT_RESPONSE_QUIT,\r
1110 SHELL_PROMPT_RESPONSE_CONTINUE,\r
1111 SHELL_PROMPT_RESPONSE_ALL,\r
1112 SHELL_PROMPT_RESPONSE_MAX\r
1113} SHELL_PROMPT_RESPONSE;\r
1114\r
1115/**\r
1116 Prompt the user and return the resultant answer to the requestor.\r
1117\r
1118 This function will display the requested question on the shell prompt and then\r
1119 wait for an apropriate answer to be input from the console.\r
1120\r
1121 if the SHELL_PROMPT_REQUEST_TYPE is SHELL_PROMPT_REQUEST_TYPE_YESNO, SHELL_PROMPT_REQUEST_TYPE_QUIT_CONTINUE\r
1122 or SHELL_PROMPT_REQUEST_TYPE_YESNOCANCEL then *Response is of type SHELL_PROMPT_RESPONSE.\r
1123\r
1124 if the SHELL_PROMPT_REQUEST_TYPE is SHELL_PROMPT_REQUEST_TYPE_FREEFORM then *Response is of type\r
1125 CHAR16*.\r
1126\r
1127 In either case *Response must be callee freed if Response was not NULL;\r
1128\r
1129 @param Type What type of question is asked. This is used to filter the input\r
1130 to prevent invalid answers to question.\r
1131 @param Prompt Pointer to string prompt to use to request input.\r
1132 @param Response Pointer to Response which will be populated upon return.\r
1133\r
1134 @retval EFI_SUCCESS The operation was sucessful.\r
1135 @retval EFI_UNSUPPORTED The operation is not supported as requested.\r
1136 @retval EFI_INVALID_PARAMETER A parameter was invalid.\r
90bfa227 1137 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
334f978e 1138 @return other The operation failed.\r
1139**/\r
1140EFI_STATUS\r
1141EFIAPI\r
1142ShellPromptForResponse (\r
1143 IN SHELL_PROMPT_REQUEST_TYPE Type,\r
1144 IN CHAR16 *Prompt OPTIONAL,\r
1145 IN OUT VOID **Response OPTIONAL\r
1146 );\r
1147\r
1148/**\r
1149 Prompt the user and return the resultant answer to the requestor.\r
1150\r
1151 This function is the same as ShellPromptForResponse, except that the prompt is\r
1152 automatically pulled from HII.\r
1153\r
1154 @param Type What type of question is asked. This is used to filter the input\r
1155 to prevent invalid answers to question.\r
1156 @param Prompt Pointer to string prompt to use to request input.\r
1157 @param Response Pointer to Response which will be populated upon return.\r
1158\r
1159 @retval EFI_SUCCESS the operation was sucessful.\r
1160 @return other the operation failed.\r
1161\r
1162 @sa ShellPromptForResponse\r
1163**/\r
1164EFI_STATUS\r
1165EFIAPI\r
1166ShellPromptForResponseHii (\r
1167 IN SHELL_PROMPT_REQUEST_TYPE Type,\r
1168 IN CONST EFI_STRING_ID HiiFormatStringId,\r
1169 IN CONST EFI_HANDLE HiiFormatHandle,\r
1170 IN OUT VOID **Response\r
1171 );\r
1172\r
1173\r
e9880e25 1174#endif // __SHELL_LIB__\r