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