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