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