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