]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Include/Library/ShellLib.h
Upgrade ShellLib and fix bug with param parsing
[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
4Copyright (c) 2006 - 2009, Intel Corporation\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#if !defined(__SHELL_LIB__)\r
16#define __SHELL_LIB__\r
17\r
18#include <Protocol/SimpleFileSystem.h>\r
94b17fa1 19#include <Protocol/EfiShell.h>\r
20\r
21/**\r
22 This function will retrieve the information about the file for the handle \r
23 specified and store it in allocated pool memory.\r
24\r
69817bf8 25 This function allocates a buffer to store the file's information. It is the \r
26 caller's responsibility to free the buffer\r
94b17fa1 27\r
28 @param FileHandle The file handle of the file for which information is \r
29 being requested.\r
30\r
31 @retval NULL information could not be retrieved.\r
32\r
33 @return the information about the file\r
34**/\r
35EFI_FILE_INFO*\r
36EFIAPI\r
37ShellGetFileInfo (\r
38 IN EFI_FILE_HANDLE FileHandle\r
39 );\r
40\r
41/**\r
42 This function will set the information about the file for the opened handle \r
43 specified.\r
44\r
45 @param FileHandle The file handle of the file for which information \r
46 is being set\r
47\r
48 @param FileInfo The infotmation to set.\r
49\r
9eb53ac3 50 @retval EFI_SUCCESS The information was set.\r
94b17fa1 51 @retval EFI_UNSUPPORTED The InformationType is not known.\r
52 @retval EFI_NO_MEDIA The device has no medium.\r
53 @retval EFI_DEVICE_ERROR The device reported an error.\r
54 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
55 @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r
56 @retval EFI_ACCESS_DENIED The file was opened read only.\r
57 @retval EFI_VOLUME_FULL The volume is full.\r
58**/\r
59EFI_STATUS\r
60EFIAPI\r
61ShellSetFileInfo (\r
62 IN EFI_FILE_HANDLE FileHandle,\r
63 IN EFI_FILE_INFO *FileInfo\r
64 );\r
65\r
66/**\r
67 This function will open a file or directory referenced by DevicePath.\r
68\r
69 This function opens a file with the open mode according to the file path. The \r
70 Attributes is valid only for EFI_FILE_MODE_CREATE.\r
71\r
72 @param FilePath on input the device path to the file. On output \r
73 the remaining device path.\r
74 @param DeviceHandle pointer to the system device handle.\r
75 @param FileHandle pointer to the file handle.\r
76 @param OpenMode the mode to open the file with.\r
77 @param Attributes the file's file attributes.\r
78\r
79 @retval EFI_SUCCESS The information was set.\r
80 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
81 @retval EFI_UNSUPPORTED Could not open the file path. \r
82 @retval EFI_NOT_FOUND The specified file could not be found on the \r
83 device or the file system could not be found on \r
84 the device.\r
85 @retval EFI_NO_MEDIA The device has no medium.\r
86 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the \r
87 medium is no longer supported.\r
88 @retval EFI_DEVICE_ERROR The device reported an error.\r
89 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
90 @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r
91 @retval EFI_ACCESS_DENIED The file was opened read only.\r
92 @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the \r
93 file.\r
94 @retval EFI_VOLUME_FULL The volume is full.\r
95**/\r
96EFI_STATUS\r
97EFIAPI\r
98ShellOpenFileByDevicePath(\r
99 IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,\r
100 OUT EFI_HANDLE *DeviceHandle,\r
101 OUT EFI_FILE_HANDLE *FileHandle,\r
102 IN UINT64 OpenMode,\r
103 IN UINT64 Attributes\r
104 );\r
105\r
106/**\r
107 This function will open a file or directory referenced by filename.\r
108\r
69817bf8 109 If return is EFI_SUCCESS, the Filehandle is the opened file's handle; \r
94b17fa1 110 otherwise, the Filehandle is NULL. The Attributes is valid only for \r
111 EFI_FILE_MODE_CREATE.\r
112\r
113 @param FileName pointer to file name\r
114 @param FileHandle pointer to the file handle.\r
115 @param OpenMode the mode to open the file with.\r
116 @param Attributes the file's file attributes.\r
117\r
9eb53ac3 118 @retval EFI_SUCCESS The information was set.\r
94b17fa1 119 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
9eb53ac3 120 @retval EFI_UNSUPPORTED Could not open the file path. \r
94b17fa1 121 @retval EFI_NOT_FOUND The specified file could not be found on the \r
122 device or the file system could not be found \r
123 on the device.\r
9eb53ac3 124 @retval EFI_NO_MEDIA The device has no medium.\r
125 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the \r
94b17fa1 126 medium is no longer supported.\r
9eb53ac3 127 @retval EFI_DEVICE_ERROR The device reported an error.\r
94b17fa1 128 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
9eb53ac3 129 @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r
130 @retval EFI_ACCESS_DENIED The file was opened read only.\r
94b17fa1 131 @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the \r
132 file.\r
9eb53ac3 133 @retval EFI_VOLUME_FULL The volume is full.\r
94b17fa1 134**/\r
135EFI_STATUS\r
136EFIAPI\r
137ShellOpenFileByName(\r
b82bfcc1 138 IN CONST CHAR16 *FilePath,\r
94b17fa1 139 OUT EFI_FILE_HANDLE *FileHandle,\r
140 IN UINT64 OpenMode,\r
141 IN UINT64 Attributes\r
142 );\r
143\r
144/**\r
145 This function create a directory\r
146\r
147 If return is EFI_SUCCESS, the Filehandle is the opened directory's handle; \r
148 otherwise, the Filehandle is NULL. If the directory already existed, this \r
149 function opens the existing directory.\r
150\r
151 @param DirectoryName pointer to Directory name\r
152 @param FileHandle pointer to the file handle.\r
153\r
154 @retval EFI_SUCCESS The information was set.\r
155 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
156 @retval EFI_UNSUPPORTED Could not open the file path. \r
157 @retval EFI_NOT_FOUND The specified file could not be found on the \r
158 device or the file system could not be found \r
159 on the device.\r
9eb53ac3 160 @retval EFI_NO_MEDIA The device has no medium.\r
161 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the \r
94b17fa1 162 medium is no longer supported.\r
9eb53ac3 163 @retval EFI_DEVICE_ERROR The device reported an error.\r
94b17fa1 164 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
9eb53ac3 165 @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r
166 @retval EFI_ACCESS_DENIED The file was opened read only.\r
94b17fa1 167 @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the \r
168 file.\r
9eb53ac3 169 @retval EFI_VOLUME_FULL The volume is full.\r
94b17fa1 170**/\r
171EFI_STATUS\r
172EFIAPI\r
173ShellCreateDirectory(\r
b82bfcc1 174 IN CONST CHAR16 *DirectoryName,\r
94b17fa1 175 OUT EFI_FILE_HANDLE *FileHandle\r
176 );\r
177\r
178/**\r
179 This function reads information from an opened file.\r
180\r
181 If FileHandle is not a directory, the function reads the requested number of \r
69817bf8 182 bytes from the file at the file's current position and returns them in Buffer. \r
94b17fa1 183 If the read goes beyond the end of the file, the read length is truncated to the\r
69817bf8 184 end of the file. The file's current position is increased by the number of bytes \r
94b17fa1 185 returned. If FileHandle is a directory, the function reads the directory entry \r
69817bf8 186 at the file's current position and returns the entry in Buffer. If the Buffer \r
94b17fa1 187 is not large enough to hold the current directory entry, then \r
188 EFI_BUFFER_TOO_SMALL is returned and the current file position is not updated. \r
189 BufferSize is set to be the size of the buffer needed to read the entry. On \r
190 success, the current position is updated to the next directory entry. If there \r
191 are no more directory entries, the read returns a zero-length buffer. \r
192 EFI_FILE_INFO is the structure returned as the directory entry.\r
193\r
194 @param FileHandle the opened file handle\r
195 \r
196 @param ReadSize on input the size of buffer in bytes. on return \r
197 the number of bytes written.\r
198\r
199 @param Buffer the buffer to put read data into.\r
200\r
9eb53ac3 201 @retval EFI_SUCCESS Data was read.\r
202 @retval EFI_NO_MEDIA The device has no media.\r
203 @retval EFI_DEVICE_ERROR The device reported an error.\r
204 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
205 @retval EFI_BUFFER_TO_SMALL Buffer is too small. ReadSize contains required \r
94b17fa1 206 size.\r
207\r
208**/\r
209EFI_STATUS\r
210EFIAPI\r
211ShellReadFile(\r
212 IN EFI_FILE_HANDLE FileHandle,\r
213 IN OUT UINTN *ReadSize,\r
214 OUT VOID *Buffer\r
215 );\r
216\r
217/**\r
218 Write data to a file.\r
219\r
220 This function writes the specified number of bytes to the file at the current \r
221 file position. The current file position is advanced the actual number of bytes \r
222 written, which is returned in BufferSize. Partial writes only occur when there \r
69817bf8 223 has been a data error during the write attempt (such as "volume space full"). \r
94b17fa1 224 The file is automatically grown to hold the data if required. Direct writes to \r
225 opened directories are not supported.\r
226\r
227 @param FileHandle The opened file for writing\r
228\r
229 @param BufferSize on input the number of bytes in Buffer. On output\r
230 the number of bytes written.\r
231\r
232 @param Buffer the buffer containing data to write is stored.\r
233\r
234 @retval EFI_SUCCESS Data was written.\r
9eb53ac3 235 @retval EFI_UNSUPPORTED Writes to an open directory are not supported.\r
94b17fa1 236 @retval EFI_NO_MEDIA The device has no media.\r
9eb53ac3 237 @retval EFI_DEVICE_ERROR The device reported an error.\r
94b17fa1 238 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
239 @retval EFI_WRITE_PROTECTED The device is write-protected.\r
9eb53ac3 240 @retval EFI_ACCESS_DENIED The file was open for read only.\r
241 @retval EFI_VOLUME_FULL The volume is full.\r
94b17fa1 242**/\r
243EFI_STATUS\r
244EFIAPI\r
245ShellWriteFile(\r
246 IN EFI_FILE_HANDLE FileHandle,\r
247 IN OUT UINTN *BufferSize,\r
08d7f8e8 248 IN VOID *Buffer\r
94b17fa1 249 );\r
250\r
251/** \r
252 Close an open file handle.\r
253\r
69817bf8 254 This function closes a specified file handle. All "dirty" cached file data is \r
94b17fa1 255 flushed to the device, and the file is closed. In all cases the handle is \r
256 closed.\r
257\r
258@param FileHandle the file handle to close.\r
259\r
260@retval EFI_SUCCESS the file handle was closed sucessfully.\r
261@retval INVALID_PARAMETER One of the parameters has an invalid value.\r
262**/\r
263EFI_STATUS\r
264EFIAPI\r
265ShellCloseFile (\r
266 IN EFI_FILE_HANDLE *FileHandle\r
267 );\r
268\r
269/**\r
270 Delete a file and close the handle\r
271\r
272 This function closes and deletes a file. In all cases the file handle is closed.\r
273 If the file cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is \r
274 returned, but the handle is still closed.\r
275\r
276 @param FileHandle the file handle to delete\r
277\r
278 @retval EFI_SUCCESS the file was closed sucessfully\r
279 @retval EFI_WARN_DELETE_FAILURE the handle was closed, but the file was not \r
280 deleted\r
281 @retval INVALID_PARAMETER One of the parameters has an invalid value.\r
282**/\r
283EFI_STATUS\r
284EFIAPI\r
285ShellDeleteFile (\r
286 IN EFI_FILE_HANDLE *FileHandle\r
287 );\r
288\r
289/**\r
290 Set the current position in a file.\r
291\r
292 This function sets the current file position for the handle to the position \r
293 supplied. With the exception of seeking to position 0xFFFFFFFFFFFFFFFF, only\r
294 absolute positioning is supported, and seeking past the end of the file is \r
295 allowed (a subsequent write would grow the file). Seeking to position \r
296 0xFFFFFFFFFFFFFFFF causes the current position to be set to the end of the file.\r
297 If FileHandle is a directory, the only position that may be set is zero. This \r
298 has the effect of starting the read process of the directory entries over.\r
299\r
300 @param FileHandle The file handle on which the position is being set\r
301\r
302 @param Position Byte position from begining of file\r
303\r
304 @retval EFI_SUCCESS Operation completed sucessfully.\r
305 @retval EFI_UNSUPPORTED the seek request for non-zero is not valid on \r
306 directories.\r
307 @retval INVALID_PARAMETER One of the parameters has an invalid value.\r
308**/\r
309EFI_STATUS\r
310EFIAPI\r
311ShellSetFilePosition (\r
312 IN EFI_FILE_HANDLE FileHandle,\r
313 IN UINT64 Position\r
314 );\r
315\r
316/** \r
317 Gets a file's current position\r
318\r
319 This function retrieves the current file position for the file handle. For \r
320 directories, the current file position has no meaning outside of the file \r
321 system driver and as such the operation is not supported. An error is returned\r
322 if FileHandle is a directory.\r
323\r
324 @param FileHandle The open file handle on which to get the position.\r
325 @param Position Byte position from begining of file.\r
326\r
327 @retval EFI_SUCCESS the operation completed sucessfully.\r
328 @retval INVALID_PARAMETER One of the parameters has an invalid value.\r
329 @retval EFI_UNSUPPORTED the request is not valid on directories.\r
330**/\r
331EFI_STATUS\r
332EFIAPI\r
333ShellGetFilePosition (\r
334 IN EFI_FILE_HANDLE FileHandle,\r
335 OUT UINT64 *Position\r
336 );\r
337\r
338/**\r
339 Flushes data on a file\r
340 \r
341 This function flushes all modified data associated with a file to a device.\r
342\r
343 @param FileHandle The file handle on which to flush data\r
344\r
345 @retval EFI_SUCCESS The data was flushed.\r
346 @retval EFI_NO_MEDIA The device has no media.\r
347 @retval EFI_DEVICE_ERROR The device reported an error.\r
348 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
349 @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r
350 @retval EFI_ACCESS_DENIED The file was opened for read only.\r
351**/\r
352EFI_STATUS\r
353EFIAPI\r
354ShellFlushFile (\r
355 IN EFI_FILE_HANDLE FileHandle\r
356 );\r
357\r
358/**\r
359 Retrieves the first file from a directory\r
360\r
361 This function takes an open directory handle and gets the first file \r
362 in the directory's info. Caller can use ShellFindNextFile() to get \r
363 subsequent files.\r
364\r
d2b4564b 365 Caller must use FreePool on *Buffer opon completion of all file searching.\r
366\r
94b17fa1 367 @param DirHandle The file handle of the directory to search\r
d2b4564b 368 @param Buffer Pointer to pointer to buffer for file's information\r
94b17fa1 369\r
370 @retval EFI_SUCCESS Found the first file.\r
371 @retval EFI_NOT_FOUND Cannot find the directory.\r
372 @retval EFI_NO_MEDIA The device has no media.\r
373 @retval EFI_DEVICE_ERROR The device reported an error.\r
374 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
375 @return ShellReadFile\r
376**/\r
377EFI_STATUS\r
378EFIAPI\r
379ShellFindFirstFile (\r
380 IN EFI_FILE_HANDLE DirHandle,\r
d2b4564b 381 OUT EFI_FILE_INFO **Buffer\r
94b17fa1 382 );\r
383\r
384/**\r
385 Retrieves the next file in a directory.\r
386\r
387 To use this function, caller must call the ShellFindFirstFile() to get the \r
388 first file, and then use this function get other files. This function can be \r
389 called for several times to get each file's information in the directory. If \r
390 the call of ShellFindNextFile() got the last file in the directory, the next \r
391 call of this function has no file to get. *NoFile will be set to TRUE and the \r
392 data in Buffer is meaningless. \r
393\r
394 @param DirHandle the file handle of the directory\r
395 @param Buffer pointer to buffer for file's information\r
396 @param NoFile pointer to boolean when last file is found\r
397\r
398 @retval EFI_SUCCESS Found the next file.\r
399 @retval EFI_NO_MEDIA The device has no media.\r
400 @retval EFI_DEVICE_ERROR The device reported an error.\r
401 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
402**/\r
403EFI_STATUS\r
404EFIAPI\r
405ShellFindNextFile(\r
406 IN EFI_FILE_HANDLE DirHandle,\r
407 OUT EFI_FILE_INFO *Buffer,\r
408 OUT BOOLEAN *NoFile\r
409 );\r
410\r
411/**\r
412 Retrieve the size of a file.\r
413\r
69817bf8 414 This function extracts the file size info from the FileHandle's EFI_FILE_INFO \r
94b17fa1 415 data.\r
416\r
417 @param FileHandle file handle from which size is retrieved\r
418 @param Size pointer to size\r
419\r
420 @retval EFI_SUCCESS operation was completed sucessfully\r
421 @retval EFI_DEVICE_ERROR cannot access the file\r
422**/\r
423EFI_STATUS\r
424EFIAPI\r
425ShellGetFileSize (\r
426 IN EFI_FILE_HANDLE FileHandle,\r
427 OUT UINT64 *Size\r
428 );\r
429\r
430/**\r
431 Retrieves the status of the break execution flag\r
432\r
433 this function is useful to check whether the application is being asked to halt by the shell.\r
434\r
435 @retval TRUE the execution break is enabled\r
436 @retval FALSE the execution break is not enabled\r
437**/\r
438BOOLEAN\r
439EFIAPI\r
440ShellGetExecutionBreakFlag(\r
441 VOID\r
442 );\r
443\r
444/**\r
445 return the value of an environment variable\r
446\r
447 this function gets the value of the environment variable set by the \r
448 ShellSetEnvironmentVariable function\r
449\r
450 @param EnvKey The key name of the environment variable.\r
451\r
452 @retval NULL the named environment variable does not exist.\r
453 @return != NULL pointer to the value of the environment variable\r
454**/\r
455CONST CHAR16*\r
456EFIAPI\r
457ShellGetEnvironmentVariable (\r
9b3bf083 458 IN CONST CHAR16 *EnvKey\r
94b17fa1 459 );\r
460\r
461/**\r
462 set the value of an environment variable\r
463\r
464This function changes the current value of the specified environment variable. If the\r
465environment variable exists and the Value is an empty string, then the environment\r
466variable is deleted. If the environment variable exists and the Value is not an empty\r
467string, then the value of the environment variable is changed. If the environment\r
468variable does not exist and the Value is an empty string, there is no action. If the\r
469environment variable does not exist and the Value is a non-empty string, then the\r
470environment variable is created and assigned the specified value.\r
471\r
472 This is not supported pre-UEFI Shell 2.0.\r
473\r
474 @param EnvKey The key name of the environment variable.\r
475 @param EnvVal The Value of the environment variable\r
476 @param Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).\r
477\r
478 @retval EFI_SUCCESS the operation was completed sucessfully\r
479 @retval EFI_UNSUPPORTED This operation is not allowed in pre UEFI 2.0 Shell environments\r
480**/\r
481EFI_STATUS\r
482EFIAPI\r
483ShellSetEnvironmentVariable (\r
484 IN CONST CHAR16 *EnvKey,\r
485 IN CONST CHAR16 *EnvVal,\r
486 IN BOOLEAN Volatile\r
487 );\r
488\r
489/**\r
490 cause the shell to parse and execute a command line.\r
491\r
492 This function creates a nested instance of the shell and executes the specified\r
493command (CommandLine) with the specified environment (Environment). Upon return,\r
494the status code returned by the specified command is placed in StatusCode.\r
495If Environment is NULL, then the current environment is used and all changes made\r
496by the commands executed will be reflected in the current environment. If the\r
497Environment is non-NULL, then the changes made will be discarded.\r
498The CommandLine is executed from the current working directory on the current\r
499device.\r
500\r
501EnvironmentVariables and Status are only supported for UEFI Shell 2.0.\r
502Output is only supported for pre-UEFI Shell 2.0\r
503\r
504 @param ImageHandle Parent image that is starting the operation\r
505 @param CommandLine pointer to null terminated command line.\r
506 @param Output true to display debug output. false to hide it.\r
507 @param EnvironmentVariables optional pointer to array of environment variables\r
508 in the form "x=y". if NULL current set is used.\r
509 @param Status the status of the run command line.\r
510\r
511 @retval EFI_SUCCESS the operation completed sucessfully. Status\r
512 contains the status code returned.\r
513 @retval EFI_INVALID_PARAMETER a parameter contains an invalid value\r
514 @retval EFI_OUT_OF_RESOURCES out of resources\r
515 @retval EFI_UNSUPPORTED the operation is not allowed.\r
516**/\r
517EFI_STATUS\r
518EFIAPI\r
519ShellExecute (\r
520 IN EFI_HANDLE *ParentHandle,\r
521 IN CHAR16 *CommandLine,\r
522 IN BOOLEAN Output,\r
523 IN CHAR16 **EnvironmentVariables,\r
524 OUT EFI_STATUS *Status\r
525 );\r
526\r
527/**\r
528 Retreives the current directory path\r
529\r
69817bf8 530 If the DeviceName is NULL, it returns the current device's current directory \r
94b17fa1 531 name. If the DeviceName is not NULL, it returns the current directory name \r
532 on specified drive.\r
533\r
534 @param DeviceName the name of the drive to get directory on\r
535\r
536 @retval NULL the directory does not exist\r
537 @return != NULL the directory\r
538**/\r
539CONST CHAR16*\r
540EFIAPI\r
541ShellGetCurrentDir (\r
542 IN CHAR16 *DeviceName OPTIONAL\r
543 );\r
544\r
545/**\r
546 sets (enabled or disabled) the page break mode\r
547\r
548 when page break mode is enabled the screen will stop scrolling \r
549 and wait for operator input before scrolling a subsequent screen.\r
550\r
551 @param CurrentState TRUE to enable and FALSE to disable\r
552**/\r
553VOID \r
554EFIAPI\r
555ShellSetPageBreakMode (\r
556 IN BOOLEAN CurrentState\r
557 );\r
558\r
559/**\r
560 Opens a group of files based on a path.\r
561\r
562 This function uses the Arg to open all the matching files. Each matched \r
563 file has a SHELL_FILE_ARG structure to record the file information. These \r
564 structures are placed on the list ListHead. Users can get the SHELL_FILE_ARG \r
565 structures from ListHead to access each file. This function supports wildcards\r
566 and will process '?' and '*' as such. the list must be freed with a call to \r
567 ShellCloseFileMetaArg().\r
568\r
eb646684 569 If you are NOT appending to an existing list *ListHead must be NULL. If \r
570 *ListHead is NULL then it must be callee freed.\r
94b17fa1 571\r
572 @param Arg pointer to path string\r
573 @param OpenMode mode to open files with\r
574 @param ListHead head of linked list of results\r
575\r
576 @retval EFI_SUCCESS the operation was sucessful and the list head \r
577 contains the list of opened files\r
578 #retval EFI_UNSUPPORTED a previous ShellOpenFileMetaArg must be closed first.\r
579 *ListHead is set to NULL.\r
580 @return != EFI_SUCCESS the operation failed\r
581\r
582 @sa InternalShellConvertFileListType\r
583**/\r
584EFI_STATUS\r
585EFIAPI\r
586ShellOpenFileMetaArg (\r
587 IN CHAR16 *Arg,\r
588 IN UINT64 OpenMode,\r
589 IN OUT EFI_SHELL_FILE_INFO **ListHead\r
590 );\r
591\r
592/**\r
593 Free the linked list returned from ShellOpenFileMetaArg\r
594\r
595 @param ListHead the pointer to free\r
596\r
597 @retval EFI_SUCCESS the operation was sucessful\r
598 @retval EFI_INVALID_PARAMETER A parameter was invalid\r
599**/\r
600EFI_STATUS\r
601EFIAPI\r
602ShellCloseFileMetaArg (\r
603 IN OUT EFI_SHELL_FILE_INFO **ListHead\r
604 );\r
605\r
606typedef enum {\r
607 TypeFlag = 0,\r
608 TypeValue,\r
609 TypePosition,\r
9eb53ac3 610 TypeStart,\r
94b17fa1 611 TypeMax,\r
612} ParamType;\r
613\r
614typedef struct {\r
615 CHAR16 *Name;\r
616 ParamType Type;\r
617} SHELL_PARAM_ITEM;\r
618\r
d2b4564b 619\r
620/// Helper structure for no parameters (besides -? and -b)\r
621extern SHELL_PARAM_ITEM EmptyParamList[];\r
622\r
94b17fa1 623/**\r
624 Checks the command line arguments passed against the list of valid ones. \r
625 Optionally removes NULL values first.\r
626 \r
627 If no initialization is required, then return RETURN_SUCCESS.\r
628 \r
629 @param CheckList pointer to list of parameters to check\r
630 @param CheckPackage Package of checked values\r
631 @param ProblemParam optional pointer to pointer to unicode string for \r
632 the paramater that caused failure.\r
633 @param AutoPageBreak will automatically set PageBreakEnabled\r
634\r
635 @retval EFI_SUCCESS The operation completed sucessfully.\r
636 @retval EFI_OUT_OF_RESOURCES A memory allocation failed\r
637 @retval EFI_INVALID_PARAMETER A parameter was invalid\r
638 @retval EFI_VOLUME_CORRUPTED the command line was corrupt. an argument was \r
639 duplicated. the duplicated command line argument \r
640 was returned in ProblemParam if provided.\r
641 @retval EFI_DEVICE_ERROR the commands contained 2 opposing arguments. one\r
642 of the command line arguments was returned in \r
643 ProblemParam if provided.\r
644 @retval EFI_NOT_FOUND a argument required a value that was missing. \r
645 the invalid command line argument was returned in\r
646 ProblemParam if provided.\r
647**/\r
648EFI_STATUS\r
649EFIAPI\r
2247dde4 650ShellCommandLineParseEx (\r
94b17fa1 651 IN CONST SHELL_PARAM_ITEM *CheckList,\r
652 OUT LIST_ENTRY **CheckPackage,\r
653 OUT CHAR16 **ProblemParam OPTIONAL,\r
2247dde4 654 IN BOOLEAN AutoPageBreak,\r
655 IN BOOLEAN AlwaysAllowNumbers\r
94b17fa1 656 );\r
657\r
2247dde4 658// make it easy to upgrade from older versions of the shell library.\r
659#define ShellCommandLineParse(CheckList,CheckPackage,ProblemParam,AutoPageBreak) ShellCommandLineParseEx(CheckList,CheckPackage,ProblemParam,AutoPageBreak,FALSE)\r
660\r
94b17fa1 661/**\r
662 Frees shell variable list that was returned from ShellCommandLineParse.\r
663\r
664 This function will free all the memory that was used for the CheckPackage\r
665 list of postprocessed shell arguments.\r
666\r
667 this function has no return value.\r
668\r
669 if CheckPackage is NULL, then return\r
670\r
671 @param CheckPackage the list to de-allocate\r
672 **/\r
673VOID\r
674EFIAPI\r
675ShellCommandLineFreeVarList (\r
676 IN LIST_ENTRY *CheckPackage\r
677 );\r
678\r
679/**\r
680 Checks for presence of a flag parameter\r
681\r
682 flag arguments are in the form of "-<Key>" or "/<Key>", but do not have a value following the key\r
683\r
684 if CheckPackage is NULL then return FALSE.\r
685 if KeyString is NULL then ASSERT()\r
686 \r
687 @param CheckPackage The package of parsed command line arguments\r
688 @param KeyString the Key of the command line argument to check for\r
689\r
690 @retval TRUE the flag is on the command line\r
691 @retval FALSE the flag is not on the command line\r
692 **/\r
693BOOLEAN\r
694EFIAPI\r
695ShellCommandLineGetFlag (\r
696 IN CONST LIST_ENTRY *CheckPackage,\r
697 IN CHAR16 *KeyString\r
698 );\r
699\r
700/**\r
701 returns value from command line argument\r
702\r
703 value parameters are in the form of "-<Key> value" or "/<Key> value"\r
704 \r
705 if CheckPackage is NULL, then return NULL;\r
706\r
707 @param CheckPackage The package of parsed command line arguments\r
708 @param KeyString the Key of the command line argument to check for\r
709\r
710 @retval NULL the flag is not on the command line\r
711 @return !=NULL pointer to unicode string of the value\r
712 **/\r
713CONST CHAR16*\r
714EFIAPI\r
715ShellCommandLineGetValue (\r
716 IN CONST LIST_ENTRY *CheckPackage,\r
717 IN CHAR16 *KeyString\r
718 );\r
719\r
720/**\r
721 returns raw value from command line argument\r
722\r
723 raw value parameters are in the form of "value" in a specific position in the list\r
724 \r
725 if CheckPackage is NULL, then return NULL;\r
726\r
727 @param CheckPackage The package of parsed command line arguments\r
728 @param Position the position of the value \r
729\r
730 @retval NULL the flag is not on the command line\r
731 @return !=NULL pointer to unicode string of the value\r
732 **/\r
733CONST CHAR16*\r
734EFIAPI\r
735ShellCommandLineGetRawValue (\r
736 IN CONST LIST_ENTRY *CheckPackage,\r
737 IN UINT32 Position\r
738 );\r
739\r
2247dde4 740/**\r
741 returns the number of command line value parameters that were parsed. \r
742 \r
743 this will not include flags.\r
744\r
745 @retval (UINTN)-1 No parsing has ocurred\r
746 @return other The number of value parameters found\r
747**/\r
748UINTN\r
749EFIAPI\r
750ShellCommandLineGetCount(\r
751 VOID\r
752 );\r
753\r
d2b4564b 754/**\r
755 This function causes the shell library to initialize itself. If the shell library\r
756 is already initialized it will de-initialize all the current protocol poitners and\r
757 re-populate them again.\r
758\r
759 When the library is used with PcdShellLibAutoInitialize set to true this function\r
760 will return EFI_SUCCESS and perform no actions.\r
761\r
762 This function is intended for internal access for shell commands only.\r
763\r
764 @retval EFI_SUCCESS the initialization was complete sucessfully\r
765\r
766**/\r
767EFI_STATUS\r
768EFIAPI\r
769ShellInitialize (\r
770 );\r
771\r
b1f95a06 772/**\r
773 Print at a specific location on the screen.\r
774\r
775 This function will move the cursor to a given screen location, print the specified string, \r
776 and return the cursor to the original locaiton. \r
777 \r
778 If -1 is specified for either the Row or Col the current screen location for BOTH \r
779 will be used and the cursor's position will not be moved back to an original location.\r
780\r
781 if either Row or Col is out of range for the current console, then ASSERT\r
782 if Format is NULL, then ASSERT\r
783\r
784 In addition to the standard %-based flags as supported by UefiLib Print() this supports \r
785 the following additional flags:\r
786 %N - Set output attribute to normal\r
787 %H - Set output attribute to highlight\r
788 %E - Set output attribute to error\r
789 %B - Set output attribute to blue color\r
790 %V - Set output attribute to green color\r
791\r
792 Note: The background color is controlled by the shell command cls.\r
793\r
794 @param[in] Row the row to print at\r
795 @param[in] Col the column to print at\r
796 @param[in] Format the format string\r
797\r
798 @return the number of characters printed to the screen\r
799**/\r
800\r
801UINTN\r
802EFIAPI\r
803ShellPrintEx(\r
804 IN INT32 Col OPTIONAL,\r
805 IN INT32 Row OPTIONAL,\r
806 IN CONST CHAR16 *Format,\r
807 ...\r
808 );\r
809\r
2247dde4 810/**\r
811 Print at a specific location on the screen.\r
812\r
813 This function will move the cursor to a given screen location, print the specified string, \r
814 and return the cursor to the original locaiton. \r
815 \r
816 If -1 is specified for either the Row or Col the current screen location for BOTH \r
817 will be used and the cursor's position will not be moved back to an original location.\r
818\r
819 if either Row or Col is out of range for the current console, then ASSERT\r
820 if Format is NULL, then ASSERT\r
821\r
822 In addition to the standard %-based flags as supported by UefiLib Print() this supports \r
823 the following additional flags:\r
824 %N - Set output attribute to normal\r
825 %H - Set output attribute to highlight\r
826 %E - Set output attribute to error\r
827 %B - Set output attribute to blue color\r
828 %V - Set output attribute to green color\r
829\r
830 Note: The background color is controlled by the shell command cls.\r
831\r
832 @param[in] Row the row to print at\r
833 @param[in] Col the column to print at\r
834 @param[in] HiiFormatStringId the format string Id for getting from Hii\r
835 @param[in] HiiFormatHandle the format string Handle for getting from Hii\r
836\r
837 @return the number of characters printed to the screen\r
838**/\r
839UINTN\r
840EFIAPI\r
841ShellPrintHiiEx(\r
842 IN INT32 Col OPTIONAL,\r
843 IN INT32 Row OPTIONAL,\r
844 IN CONST EFI_STRING_ID HiiFormatStringId,\r
845 IN CONST EFI_HANDLE HiiFormatHandle,\r
846 ...\r
847 );\r
848\r
849/**\r
850 Function to determine if a given filename represents a file or a directory.\r
851\r
852 @param[in] DirName Path to directory to test.\r
853\r
854 @retval EFI_SUCCESS The Path represents a directory\r
855 @retval EFI_NOT_FOUND The Path does not represent a directory\r
856 @return other The path failed to open\r
857**/\r
858EFI_STATUS\r
859EFIAPI\r
860ShellIsDirectory(\r
861 IN CONST CHAR16 *DirName\r
862 );\r
863\r
864\r
e9880e25 865#endif // __SHELL_LIB__\r