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