]>
Commit | Line | Data |
---|---|---|
94b17fa1 | 1 | /** @file\r |
2 | Provides interface to shell functionality for shell commands and applications.\r | |
3 | \r | |
b3011f40 | 4 | Copyright (c) 2006 - 2010, Intel Corporation<BR>\r |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
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 | |
15 | #if !defined(__SHELL_LIB__)\r | |
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 |
27 | /**\r | |
28 | This function will retrieve the information about the file for the handle \r | |
29 | specified and store it in allocated pool memory.\r | |
30 | \r | |
69817bf8 | 31 | This function allocates a buffer to store the file's information. It is the \r |
18cefebe | 32 | caller's responsibility to free the buffer.\r |
94b17fa1 | 33 | \r |
18cefebe | 34 | @param[in] FileHandle The file handle of the file for which information is \r |
35 | being requested.\r | |
94b17fa1 | 36 | \r |
18cefebe | 37 | @retval NULL Information could not be retrieved.\r |
94b17fa1 | 38 | \r |
18cefebe | 39 | @return The information about the file.\r |
94b17fa1 | 40 | **/\r |
41 | EFI_FILE_INFO*\r | |
42 | EFIAPI\r | |
43 | ShellGetFileInfo (\r | |
44 | IN EFI_FILE_HANDLE FileHandle\r | |
45 | );\r | |
46 | \r | |
47 | /**\r | |
48 | This function will set the information about the file for the opened handle \r | |
49 | specified.\r | |
50 | \r | |
18cefebe | 51 | @param[in] FileHandle The file handle of the file for which information \r |
a5bd42b9 | 52 | is being set.\r |
94b17fa1 | 53 | \r |
18cefebe | 54 | @param[in] FileInfo The infotmation to set.\r |
94b17fa1 | 55 | \r |
9eb53ac3 | 56 | @retval EFI_SUCCESS The information was set.\r |
94b17fa1 | 57 | @retval EFI_UNSUPPORTED The InformationType is not known.\r |
58 | @retval EFI_NO_MEDIA The device has no medium.\r | |
59 | @retval EFI_DEVICE_ERROR The device reported an error.\r | |
60 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r | |
61 | @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r | |
62 | @retval EFI_ACCESS_DENIED The file was opened read only.\r | |
63 | @retval EFI_VOLUME_FULL The volume is full.\r | |
64 | **/\r | |
65 | EFI_STATUS\r | |
66 | EFIAPI\r | |
67 | ShellSetFileInfo (\r | |
68 | IN EFI_FILE_HANDLE FileHandle,\r | |
69 | IN EFI_FILE_INFO *FileInfo\r | |
70 | );\r | |
71 | \r | |
72 | /**\r | |
73 | This function will open a file or directory referenced by DevicePath.\r | |
74 | \r | |
75 | This function opens a file with the open mode according to the file path. The \r | |
76 | Attributes is valid only for EFI_FILE_MODE_CREATE.\r | |
77 | \r | |
b3011f40 | 78 | @param[in] FilePath On input the device path to the file. On output \r |
79 | the remaining device path.\r | |
80 | @param[out] DeviceHandle Pointer to the system device handle.\r | |
81 | @param[out] FileHandle Pointer to the file handle.\r | |
82 | @param[in] OpenMode The mode to open the file with.\r | |
83 | @param[in] Attributes The file's file attributes.\r | |
94b17fa1 | 84 | \r |
85 | @retval EFI_SUCCESS The information was set.\r | |
86 | @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r | |
87 | @retval EFI_UNSUPPORTED Could not open the file path. \r | |
88 | @retval EFI_NOT_FOUND The specified file could not be found on the \r | |
89 | device or the file system could not be found on \r | |
90 | the device.\r | |
91 | @retval EFI_NO_MEDIA The device has no medium.\r | |
92 | @retval EFI_MEDIA_CHANGED The device has a different medium in it or the \r | |
93 | medium is no longer supported.\r | |
94 | @retval EFI_DEVICE_ERROR The device reported an error.\r | |
95 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r | |
96 | @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r | |
97 | @retval EFI_ACCESS_DENIED The file was opened read only.\r | |
98 | @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the \r | |
99 | file.\r | |
100 | @retval EFI_VOLUME_FULL The volume is full.\r | |
101 | **/\r | |
102 | EFI_STATUS\r | |
103 | EFIAPI\r | |
104 | ShellOpenFileByDevicePath(\r | |
105 | IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,\r | |
106 | OUT EFI_HANDLE *DeviceHandle,\r | |
107 | OUT EFI_FILE_HANDLE *FileHandle,\r | |
108 | IN UINT64 OpenMode,\r | |
109 | IN UINT64 Attributes\r | |
110 | );\r | |
111 | \r | |
112 | /**\r | |
113 | This function will open a file or directory referenced by filename.\r | |
114 | \r | |
69817bf8 | 115 | If return is EFI_SUCCESS, the Filehandle is the opened file's handle; \r |
94b17fa1 | 116 | otherwise, the Filehandle is NULL. The Attributes is valid only for \r |
117 | EFI_FILE_MODE_CREATE.\r | |
118 | \r | |
18cefebe | 119 | @param[in] FileName Pointer to file name.\r |
120 | @param[out] FileHandle Pointer to the file handle.\r | |
121 | @param[in] OpenMode The mode to open the file with.\r | |
122 | @param[in] Attributes The file's file attributes.\r | |
94b17fa1 | 123 | \r |
9eb53ac3 | 124 | @retval EFI_SUCCESS The information was set.\r |
94b17fa1 | 125 | @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r |
9eb53ac3 | 126 | @retval EFI_UNSUPPORTED Could not open the file path. \r |
94b17fa1 | 127 | @retval EFI_NOT_FOUND The specified file could not be found on the \r |
128 | device or the file system could not be found \r | |
129 | on the device.\r | |
9eb53ac3 | 130 | @retval EFI_NO_MEDIA The device has no medium.\r |
131 | @retval EFI_MEDIA_CHANGED The device has a different medium in it or the \r | |
94b17fa1 | 132 | medium is no longer supported.\r |
9eb53ac3 | 133 | @retval EFI_DEVICE_ERROR The device reported an error.\r |
94b17fa1 | 134 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r |
9eb53ac3 | 135 | @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r |
136 | @retval EFI_ACCESS_DENIED The file was opened read only.\r | |
94b17fa1 | 137 | @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the \r |
138 | file.\r | |
9eb53ac3 | 139 | @retval EFI_VOLUME_FULL The volume is full.\r |
94b17fa1 | 140 | **/\r |
141 | EFI_STATUS\r | |
142 | EFIAPI\r | |
143 | ShellOpenFileByName(\r | |
b82bfcc1 | 144 | IN CONST CHAR16 *FilePath,\r |
94b17fa1 | 145 | OUT EFI_FILE_HANDLE *FileHandle,\r |
146 | IN UINT64 OpenMode,\r | |
147 | IN UINT64 Attributes\r | |
148 | );\r | |
149 | \r | |
150 | /**\r | |
18cefebe | 151 | This function creates a directory.\r |
94b17fa1 | 152 | \r |
153 | If return is EFI_SUCCESS, the Filehandle is the opened directory's handle; \r | |
154 | otherwise, the Filehandle is NULL. If the directory already existed, this \r | |
155 | function opens the existing directory.\r | |
156 | \r | |
18cefebe | 157 | @param[in] DirectoryName Pointer to Directory name.\r |
158 | @param[out] FileHandle Pointer to the file handle.\r | |
94b17fa1 | 159 | \r |
160 | @retval EFI_SUCCESS The information was set.\r | |
161 | @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r | |
125c2cf4 | 162 | @retval EFI_UNSUPPORTED Could not open the file path. \r |
94b17fa1 | 163 | @retval EFI_NOT_FOUND The specified file could not be found on the \r |
164 | device or the file system could not be found \r | |
165 | on the device.\r | |
9eb53ac3 | 166 | @retval EFI_NO_MEDIA The device has no medium.\r |
167 | @retval EFI_MEDIA_CHANGED The device has a different medium in it or the \r | |
94b17fa1 | 168 | medium is no longer supported.\r |
9eb53ac3 | 169 | @retval EFI_DEVICE_ERROR The device reported an error.\r |
94b17fa1 | 170 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r |
9eb53ac3 | 171 | @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r |
172 | @retval EFI_ACCESS_DENIED The file was opened read only.\r | |
94b17fa1 | 173 | @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the \r |
174 | file.\r | |
9eb53ac3 | 175 | @retval EFI_VOLUME_FULL The volume is full.\r |
94b17fa1 | 176 | **/\r |
177 | EFI_STATUS\r | |
178 | EFIAPI\r | |
179 | ShellCreateDirectory(\r | |
b82bfcc1 | 180 | IN CONST CHAR16 *DirectoryName,\r |
94b17fa1 | 181 | OUT EFI_FILE_HANDLE *FileHandle\r |
182 | );\r | |
183 | \r | |
184 | /**\r | |
185 | This function reads information from an opened file.\r | |
186 | \r | |
187 | If FileHandle is not a directory, the function reads the requested number of \r | |
69817bf8 | 188 | bytes from the file at the file's current position and returns them in Buffer. \r |
94b17fa1 | 189 | If the read goes beyond the end of the file, the read length is truncated to the\r |
69817bf8 | 190 | end of the file. The file's current position is increased by the number of bytes \r |
94b17fa1 | 191 | returned. If FileHandle is a directory, the function reads the directory entry \r |
69817bf8 | 192 | at the file's current position and returns the entry in Buffer. If the Buffer \r |
94b17fa1 | 193 | is not large enough to hold the current directory entry, then \r |
194 | EFI_BUFFER_TOO_SMALL is returned and the current file position is not updated. \r | |
195 | BufferSize is set to be the size of the buffer needed to read the entry. On \r | |
196 | success, the current position is updated to the next directory entry. If there \r | |
197 | are no more directory entries, the read returns a zero-length buffer. \r | |
198 | EFI_FILE_INFO is the structure returned as the directory entry.\r | |
199 | \r | |
18cefebe | 200 | @param[in] FileHandle The opened file handle.\r |
201 | @param[in] ReadSize On input the size of buffer in bytes. On return \r | |
94b17fa1 | 202 | the number of bytes written.\r |
18cefebe | 203 | @param[out] Buffer The buffer to put read data into.\r |
94b17fa1 | 204 | \r |
125c2cf4 | 205 | @retval EFI_SUCCESS Data was read.\r |
206 | @retval EFI_NO_MEDIA The device has no media.\r | |
207 | @retval EFI_DEVICE_ERROR The device reported an error.\r | |
208 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r | |
209 | @retval EFI_BUFFER_TO_SMALL Buffer is too small. ReadSize contains required \r | |
94b17fa1 | 210 | size.\r |
211 | \r | |
212 | **/\r | |
213 | EFI_STATUS\r | |
214 | EFIAPI\r | |
215 | ShellReadFile(\r | |
216 | IN EFI_FILE_HANDLE FileHandle,\r | |
217 | IN OUT UINTN *ReadSize,\r | |
218 | OUT VOID *Buffer\r | |
219 | );\r | |
220 | \r | |
221 | /**\r | |
222 | Write data to a file.\r | |
223 | \r | |
224 | This function writes the specified number of bytes to the file at the current \r | |
225 | file position. The current file position is advanced the actual number of bytes \r | |
226 | written, which is returned in BufferSize. Partial writes only occur when there \r | |
69817bf8 | 227 | has been a data error during the write attempt (such as "volume space full"). \r |
94b17fa1 | 228 | The file is automatically grown to hold the data if required. Direct writes to \r |
229 | opened directories are not supported.\r | |
230 | \r | |
18cefebe | 231 | @param[in] FileHandle The opened file for writing.\r |
94b17fa1 | 232 | \r |
18cefebe | 233 | @param[in] BufferSize On input the number of bytes in Buffer. On output\r |
94b17fa1 | 234 | the number of bytes written.\r |
235 | \r | |
18cefebe | 236 | @param[in] Buffer The buffer containing data to write is stored.\r |
94b17fa1 | 237 | \r |
125c2cf4 | 238 | @retval EFI_SUCCESS Data was written.\r |
239 | @retval EFI_UNSUPPORTED Writes to an open directory are not supported.\r | |
240 | @retval EFI_NO_MEDIA The device has no media.\r | |
241 | @retval EFI_DEVICE_ERROR The device reported an error.\r | |
242 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r | |
243 | @retval EFI_WRITE_PROTECTED The device is write-protected.\r | |
244 | @retval EFI_ACCESS_DENIED The file was open for read only.\r | |
245 | @retval EFI_VOLUME_FULL The volume is full.\r | |
94b17fa1 | 246 | **/\r |
247 | EFI_STATUS\r | |
248 | EFIAPI\r | |
249 | ShellWriteFile(\r | |
250 | IN EFI_FILE_HANDLE FileHandle,\r | |
251 | IN OUT UINTN *BufferSize,\r | |
08d7f8e8 | 252 | IN VOID *Buffer\r |
94b17fa1 | 253 | );\r |
254 | \r | |
255 | /** \r | |
256 | Close an open file handle.\r | |
257 | \r | |
69817bf8 | 258 | This function closes a specified file handle. All "dirty" cached file data is \r |
94b17fa1 | 259 | flushed to the device, and the file is closed. In all cases the handle is \r |
260 | closed.\r | |
261 | \r | |
18cefebe | 262 | @param[in] FileHandle The file handle to close.\r |
94b17fa1 | 263 | \r |
125c2cf4 | 264 | @retval EFI_SUCCESS The file handle was closed sucessfully.\r |
265 | @retval INVALID_PARAMETER One of the parameters has an invalid value.\r | |
94b17fa1 | 266 | **/\r |
267 | EFI_STATUS\r | |
268 | EFIAPI\r | |
269 | ShellCloseFile (\r | |
270 | IN EFI_FILE_HANDLE *FileHandle\r | |
271 | );\r | |
272 | \r | |
273 | /**\r | |
274 | Delete a file and close the handle\r | |
275 | \r | |
276 | This function closes and deletes a file. In all cases the file handle is closed.\r | |
277 | If the file cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is \r | |
278 | returned, but the handle is still closed.\r | |
279 | \r | |
18cefebe | 280 | @param[in] FileHandle The file handle to delete.\r |
94b17fa1 | 281 | \r |
125c2cf4 | 282 | @retval EFI_SUCCESS The file was closed sucessfully.\r |
283 | @retval EFI_WARN_DELETE_FAILURE The handle was closed, but the file was not \r | |
284 | deleted.\r | |
285 | @retval INVALID_PARAMETER One of the parameters has an invalid value.\r | |
94b17fa1 | 286 | **/\r |
287 | EFI_STATUS\r | |
288 | EFIAPI\r | |
289 | ShellDeleteFile (\r | |
290 | IN EFI_FILE_HANDLE *FileHandle\r | |
291 | );\r | |
292 | \r | |
293 | /**\r | |
294 | Set the current position in a file.\r | |
295 | \r | |
296 | This function sets the current file position for the handle to the position \r | |
297 | supplied. With the exception of seeking to position 0xFFFFFFFFFFFFFFFF, only\r | |
298 | absolute positioning is supported, and seeking past the end of the file is \r | |
299 | allowed (a subsequent write would grow the file). Seeking to position \r | |
300 | 0xFFFFFFFFFFFFFFFF causes the current position to be set to the end of the file.\r | |
301 | If FileHandle is a directory, the only position that may be set is zero. This \r | |
302 | has the effect of starting the read process of the directory entries over.\r | |
303 | \r | |
18cefebe | 304 | @param[in] FileHandle The file handle on which the position is being set.\r |
94b17fa1 | 305 | \r |
18cefebe | 306 | @param[in] Position Byte position from begining of file.\r |
94b17fa1 | 307 | \r |
308 | @retval EFI_SUCCESS Operation completed sucessfully.\r | |
18cefebe | 309 | @retval EFI_UNSUPPORTED The seek request for non-zero is not valid on \r |
94b17fa1 | 310 | directories.\r |
311 | @retval INVALID_PARAMETER One of the parameters has an invalid value.\r | |
312 | **/\r | |
313 | EFI_STATUS\r | |
314 | EFIAPI\r | |
315 | ShellSetFilePosition (\r | |
316 | IN EFI_FILE_HANDLE FileHandle,\r | |
317 | IN UINT64 Position\r | |
318 | );\r | |
319 | \r | |
320 | /** \r | |
321 | Gets a file's current position\r | |
322 | \r | |
323 | This function retrieves the current file position for the file handle. For \r | |
324 | directories, the current file position has no meaning outside of the file \r | |
325 | system driver and as such the operation is not supported. An error is returned\r | |
326 | if FileHandle is a directory.\r | |
327 | \r | |
18cefebe | 328 | @param[in] FileHandle The open file handle on which to get the position.\r |
329 | @param[out] Position Byte position from begining of file.\r | |
94b17fa1 | 330 | \r |
18cefebe | 331 | @retval EFI_SUCCESS The operation completed sucessfully.\r |
94b17fa1 | 332 | @retval INVALID_PARAMETER One of the parameters has an invalid value.\r |
18cefebe | 333 | @retval EFI_UNSUPPORTED The request is not valid on directories.\r |
94b17fa1 | 334 | **/\r |
335 | EFI_STATUS\r | |
336 | EFIAPI\r | |
337 | ShellGetFilePosition (\r | |
338 | IN EFI_FILE_HANDLE FileHandle,\r | |
339 | OUT UINT64 *Position\r | |
340 | );\r | |
341 | \r | |
342 | /**\r | |
343 | Flushes data on a file\r | |
344 | \r | |
345 | This function flushes all modified data associated with a file to a device.\r | |
346 | \r | |
18cefebe | 347 | @param[in] FileHandle The file handle on which to flush data.\r |
94b17fa1 | 348 | \r |
349 | @retval EFI_SUCCESS The data was flushed.\r | |
350 | @retval EFI_NO_MEDIA The device has no media.\r | |
351 | @retval EFI_DEVICE_ERROR The device reported an error.\r | |
352 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r | |
353 | @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r | |
354 | @retval EFI_ACCESS_DENIED The file was opened for read only.\r | |
355 | **/\r | |
356 | EFI_STATUS\r | |
357 | EFIAPI\r | |
358 | ShellFlushFile (\r | |
359 | IN EFI_FILE_HANDLE FileHandle\r | |
360 | );\r | |
361 | \r | |
362 | /**\r | |
363 | Retrieves the first file from a directory\r | |
364 | \r | |
365 | This function takes an open directory handle and gets the first file \r | |
366 | in the directory's info. Caller can use ShellFindNextFile() to get \r | |
367 | subsequent files.\r | |
368 | \r | |
d2b4564b | 369 | Caller must use FreePool on *Buffer opon completion of all file searching.\r |
370 | \r | |
18cefebe | 371 | @param[in] DirHandle The file handle of the directory to search\r |
372 | @param[out] Buffer Pointer to pointer to buffer for file's information\r | |
94b17fa1 | 373 | \r |
374 | @retval EFI_SUCCESS Found the first file.\r | |
375 | @retval EFI_NOT_FOUND Cannot find the directory.\r | |
376 | @retval EFI_NO_MEDIA The device has no media.\r | |
377 | @retval EFI_DEVICE_ERROR The device reported an error.\r | |
378 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r | |
379 | @return ShellReadFile\r | |
380 | **/\r | |
381 | EFI_STATUS\r | |
382 | EFIAPI\r | |
383 | ShellFindFirstFile (\r | |
384 | IN EFI_FILE_HANDLE DirHandle,\r | |
d2b4564b | 385 | OUT EFI_FILE_INFO **Buffer\r |
94b17fa1 | 386 | );\r |
387 | \r | |
388 | /**\r | |
389 | Retrieves the next file in a directory.\r | |
390 | \r | |
391 | To use this function, caller must call the ShellFindFirstFile() to get the \r | |
392 | first file, and then use this function get other files. This function can be \r | |
393 | called for several times to get each file's information in the directory. If \r | |
394 | the call of ShellFindNextFile() got the last file in the directory, the next \r | |
395 | call of this function has no file to get. *NoFile will be set to TRUE and the \r | |
396 | data in Buffer is meaningless. \r | |
397 | \r | |
18cefebe | 398 | @param[in] DirHandle The file handle of the directory.\r |
399 | @param[out] Buffer Pointer to buffer for file's information.\r | |
400 | @param[out] NoFile Pointer to boolean when last file is found.\r | |
94b17fa1 | 401 | \r |
402 | @retval EFI_SUCCESS Found the next file.\r | |
403 | @retval EFI_NO_MEDIA The device has no media.\r | |
404 | @retval EFI_DEVICE_ERROR The device reported an error.\r | |
405 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r | |
406 | **/\r | |
407 | EFI_STATUS\r | |
408 | EFIAPI\r | |
409 | ShellFindNextFile(\r | |
410 | IN EFI_FILE_HANDLE DirHandle,\r | |
411 | OUT EFI_FILE_INFO *Buffer,\r | |
412 | OUT BOOLEAN *NoFile\r | |
413 | );\r | |
414 | \r | |
415 | /**\r | |
416 | Retrieve the size of a file.\r | |
417 | \r | |
69817bf8 | 418 | This function extracts the file size info from the FileHandle's EFI_FILE_INFO \r |
94b17fa1 | 419 | data.\r |
420 | \r | |
18cefebe | 421 | @param[in] FileHandle The file handle from which size is retrieved.\r |
422 | @param[out] Size Pointer to size.\r | |
94b17fa1 | 423 | \r |
125c2cf4 | 424 | @retval EFI_SUCCESS The operation was completed sucessfully.\r |
a31bd33c | 425 | @retval EFI_DEVICE_ERROR Cannot access the file.\r |
94b17fa1 | 426 | **/\r |
427 | EFI_STATUS\r | |
428 | EFIAPI\r | |
429 | ShellGetFileSize (\r | |
430 | IN EFI_FILE_HANDLE FileHandle,\r | |
431 | OUT UINT64 *Size\r | |
432 | );\r | |
433 | \r | |
434 | /**\r | |
435 | Retrieves the status of the break execution flag\r | |
436 | \r | |
18cefebe | 437 | This function is useful to check whether the application is being asked to halt by the shell.\r |
94b17fa1 | 438 | \r |
439 | @retval TRUE the execution break is enabled\r | |
440 | @retval FALSE the execution break is not enabled\r | |
441 | **/\r | |
442 | BOOLEAN\r | |
443 | EFIAPI\r | |
444 | ShellGetExecutionBreakFlag(\r | |
445 | VOID\r | |
446 | );\r | |
447 | \r | |
448 | /**\r | |
125c2cf4 | 449 | Return the value of an environment variable.\r |
94b17fa1 | 450 | \r |
125c2cf4 | 451 | This function gets the value of the environment variable set by the \r |
452 | ShellSetEnvironmentVariable function.\r | |
94b17fa1 | 453 | \r |
18cefebe | 454 | @param[in] EnvKey The key name of the environment variable.\r |
94b17fa1 | 455 | \r |
a31bd33c | 456 | @retval NULL The named environment variable does not exist.\r |
125c2cf4 | 457 | @return != NULL pointer to the value of the environment variable.\r |
94b17fa1 | 458 | **/\r |
459 | CONST CHAR16*\r | |
460 | EFIAPI\r | |
461 | ShellGetEnvironmentVariable (\r | |
9b3bf083 | 462 | IN CONST CHAR16 *EnvKey\r |
94b17fa1 | 463 | );\r |
464 | \r | |
465 | /**\r | |
18cefebe | 466 | Set the value of an environment variable.\r |
94b17fa1 | 467 | \r |
125c2cf4 | 468 | This function changes the current value of the specified environment variable. If the\r |
469 | environment variable exists and the Value is an empty string, then the environment\r | |
470 | variable is deleted. If the environment variable exists and the Value is not an empty\r | |
471 | string, then the value of the environment variable is changed. If the environment\r | |
472 | variable does not exist and the Value is an empty string, there is no action. If the\r | |
473 | environment variable does not exist and the Value is a non-empty string, then the\r | |
474 | environment variable is created and assigned the specified value.\r | |
94b17fa1 | 475 | \r |
476 | This is not supported pre-UEFI Shell 2.0.\r | |
477 | \r | |
18cefebe | 478 | @param[in] EnvKey The key name of the environment variable.\r |
479 | @param[in] EnvVal The Value of the environment variable\r | |
480 | @param[in] Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).\r | |
94b17fa1 | 481 | \r |
482 | @retval EFI_SUCCESS the operation was completed sucessfully\r | |
483 | @retval EFI_UNSUPPORTED This operation is not allowed in pre UEFI 2.0 Shell environments\r | |
484 | **/\r | |
485 | EFI_STATUS\r | |
486 | EFIAPI\r | |
487 | ShellSetEnvironmentVariable (\r | |
488 | IN CONST CHAR16 *EnvKey,\r | |
489 | IN CONST CHAR16 *EnvVal,\r | |
490 | IN BOOLEAN Volatile\r | |
491 | );\r | |
492 | \r | |
493 | /**\r | |
125c2cf4 | 494 | Cause the shell to parse and execute a command line.\r |
94b17fa1 | 495 | \r |
496 | This function creates a nested instance of the shell and executes the specified\r | |
125c2cf4 | 497 | command (CommandLine) with the specified environment (Environment). Upon return,\r |
498 | the status code returned by the specified command is placed in StatusCode.\r | |
499 | If Environment is NULL, then the current environment is used and all changes made\r | |
500 | by the commands executed will be reflected in the current environment. If the\r | |
501 | Environment is non-NULL, then the changes made will be discarded.\r | |
502 | The CommandLine is executed from the current working directory on the current\r | |
503 | device.\r | |
94b17fa1 | 504 | \r |
18cefebe | 505 | EnvironmentVariables and Status are only supported for UEFI Shell 2.0 (or later).\r |
125c2cf4 | 506 | Output is only supported for pre-UEFI Shell 2.0\r |
94b17fa1 | 507 | \r |
18cefebe | 508 | @param[in] ImageHandle Parent image that is starting the operation.\r |
509 | @param[in] CommandLine Pointer to null terminated command line.\r | |
510 | @param[in] Output True to display debug output. False to hide it.\r | |
511 | @param[in] EnvironmentVariables Optional pointer to array of environment variables\r | |
512 | in the form "x=y". If NULL current set is used.\r | |
513 | @param[out] Status The status of the run command line.\r | |
94b17fa1 | 514 | \r |
18cefebe | 515 | @retval EFI_SUCCESS The operation completed sucessfully. Status\r |
516 | contains the status code returned.\r | |
517 | @retval EFI_INVALID_PARAMETER A parameter contains an invalid value.\r | |
518 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
519 | @retval EFI_UNSUPPORTED The operation is not allowed.\r | |
94b17fa1 | 520 | **/\r |
521 | EFI_STATUS\r | |
522 | EFIAPI\r | |
523 | ShellExecute (\r | |
524 | IN EFI_HANDLE *ParentHandle,\r | |
525 | IN CHAR16 *CommandLine,\r | |
526 | IN BOOLEAN Output,\r | |
527 | IN CHAR16 **EnvironmentVariables,\r | |
528 | OUT EFI_STATUS *Status\r | |
529 | );\r | |
530 | \r | |
531 | /**\r | |
a31bd33c | 532 | Retreives the current directory path.\r |
94b17fa1 | 533 | \r |
69817bf8 | 534 | If the DeviceName is NULL, it returns the current device's current directory \r |
94b17fa1 | 535 | name. If the DeviceName is not NULL, it returns the current directory name \r |
536 | on specified drive.\r | |
537 | \r | |
18cefebe | 538 | @param[in] DeviceName The name of the file system to get directory on.\r |
94b17fa1 | 539 | \r |
a31bd33c | 540 | @retval NULL The directory does not exist.\r |
18cefebe | 541 | @retval != NULL The directory.\r |
94b17fa1 | 542 | **/\r |
543 | CONST CHAR16*\r | |
544 | EFIAPI\r | |
545 | ShellGetCurrentDir (\r | |
546 | IN CHAR16 *DeviceName OPTIONAL\r | |
547 | );\r | |
548 | \r | |
549 | /**\r | |
125c2cf4 | 550 | Sets (enabled or disabled) the page break mode.\r |
94b17fa1 | 551 | \r |
125c2cf4 | 552 | When page break mode is enabled the screen will stop scrolling \r |
94b17fa1 | 553 | and wait for operator input before scrolling a subsequent screen.\r |
554 | \r | |
18cefebe | 555 | @param[in] CurrentState TRUE to enable and FALSE to disable.\r |
94b17fa1 | 556 | **/\r |
557 | VOID \r | |
558 | EFIAPI\r | |
559 | ShellSetPageBreakMode (\r | |
560 | IN BOOLEAN CurrentState\r | |
561 | );\r | |
562 | \r | |
563 | /**\r | |
564 | Opens a group of files based on a path.\r | |
565 | \r | |
566 | This function uses the Arg to open all the matching files. Each matched \r | |
567 | file has a SHELL_FILE_ARG structure to record the file information. These \r | |
568 | structures are placed on the list ListHead. Users can get the SHELL_FILE_ARG \r | |
569 | structures from ListHead to access each file. This function supports wildcards\r | |
125c2cf4 | 570 | and will process '?' and '*' as such. The list must be freed with a call to \r |
94b17fa1 | 571 | ShellCloseFileMetaArg().\r |
572 | \r | |
eb646684 | 573 | If you are NOT appending to an existing list *ListHead must be NULL. If \r |
574 | *ListHead is NULL then it must be callee freed.\r | |
94b17fa1 | 575 | \r |
18cefebe | 576 | @param[in] Arg Pointer to path string.\r |
577 | @param[in] OpenMode Mode to open files with.\r | |
578 | @param[in] ListHead Head of linked list of results.\r | |
94b17fa1 | 579 | \r |
125c2cf4 | 580 | @retval EFI_SUCCESS The operation was sucessful and the list head \r |
581 | contains the list of opened files.\r | |
a31bd33c | 582 | @retval != EFI_SUCCESS The operation failed.\r |
94b17fa1 | 583 | \r |
584 | @sa InternalShellConvertFileListType\r | |
585 | **/\r | |
586 | EFI_STATUS\r | |
587 | EFIAPI\r | |
588 | ShellOpenFileMetaArg (\r | |
589 | IN CHAR16 *Arg,\r | |
590 | IN UINT64 OpenMode,\r | |
591 | IN OUT EFI_SHELL_FILE_INFO **ListHead\r | |
592 | );\r | |
593 | \r | |
594 | /**\r | |
a31bd33c | 595 | Free the linked list returned from ShellOpenFileMetaArg.\r |
94b17fa1 | 596 | \r |
18cefebe | 597 | @param[in] ListHead The pointer to free.\r |
94b17fa1 | 598 | \r |
a31bd33c | 599 | @retval EFI_SUCCESS The operation was sucessful.\r |
600 | @retval EFI_INVALID_PARAMETER A parameter was invalid.\r | |
94b17fa1 | 601 | **/\r |
602 | EFI_STATUS\r | |
603 | EFIAPI\r | |
604 | ShellCloseFileMetaArg (\r | |
605 | IN OUT EFI_SHELL_FILE_INFO **ListHead\r | |
606 | );\r | |
607 | \r | |
125c2cf4 | 608 | /**\r |
609 | Find a file by searching the CWD and then the path.\r | |
610 | \r | |
a31bd33c | 611 | If FileName is NULL, then ASSERT.\r |
125c2cf4 | 612 | \r |
a31bd33c | 613 | If the return value is not NULL then the memory must be caller freed.\r |
125c2cf4 | 614 | \r |
18cefebe | 615 | @param[in] FileName Filename string.\r |
125c2cf4 | 616 | \r |
a31bd33c | 617 | @retval NULL The file was not found.\r |
18cefebe | 618 | @retval !NULL The path to the file.\r |
125c2cf4 | 619 | **/\r |
620 | CHAR16 *\r | |
621 | EFIAPI\r | |
622 | ShellFindFilePath (\r | |
623 | IN CONST CHAR16 *FileName\r | |
624 | );\r | |
625 | \r | |
b3011f40 | 626 | /**\r |
627 | Find a file by searching the CWD and then the path with a variable set of file \r | |
628 | extensions. If the file is not found it will append each extension in the list \r | |
629 | in the order provided and return the first one that is successful.\r | |
630 | \r | |
631 | If FileName is NULL, then ASSERT.\r | |
632 | If FileExtension is NULL, then behavior is identical to ShellFindFilePath.\r | |
633 | \r | |
634 | If the return value is not NULL then the memory must be caller freed.\r | |
635 | \r | |
636 | @param[in] FileName Filename string.\r | |
637 | @param[in] FileExtension Semi-colon delimeted list of possible extensions.\r | |
638 | \r | |
639 | @retval NULL The file was not found.\r | |
640 | @retval !NULL The path to the file.\r | |
641 | **/\r | |
642 | CHAR16 *\r | |
643 | EFIAPI\r | |
644 | ShellFindFilePathEx (\r | |
645 | IN CONST CHAR16 *FileName,\r | |
646 | IN CONST CHAR16 *FileExtension\r | |
647 | );\r | |
648 | \r | |
94b17fa1 | 649 | typedef enum {\r |
18cefebe | 650 | TypeFlag = 0, ///< A flag that is present or not present only (IE "-a").\r |
651 | TypeValue, ///< A flag that has some data following it with a space (IE "-a 1").\r | |
652 | TypePosition, ///< Some data that did not follow a parameter (IE "filename.txt").\r | |
653 | TypeStart, ///< A flag that has variable value appended to the end (IE "-ad", "-afd", "-adf", etc...).\r | |
654 | TypeDoubleValue, ///< A flag that has 2 space seperated value data following it (IE "-a 1 2").\r | |
655 | TypeMaxValue, ///< A flag followed by all the command line data before the next flag.\r | |
94b17fa1 | 656 | TypeMax,\r |
657 | } ParamType;\r | |
658 | \r | |
659 | typedef struct {\r | |
660 | CHAR16 *Name;\r | |
661 | ParamType Type;\r | |
662 | } SHELL_PARAM_ITEM;\r | |
663 | \r | |
d2b4564b | 664 | \r |
665 | /// Helper structure for no parameters (besides -? and -b)\r | |
666 | extern SHELL_PARAM_ITEM EmptyParamList[];\r | |
667 | \r | |
94b17fa1 | 668 | /**\r |
669 | Checks the command line arguments passed against the list of valid ones. \r | |
670 | Optionally removes NULL values first.\r | |
671 | \r | |
672 | If no initialization is required, then return RETURN_SUCCESS.\r | |
673 | \r | |
18cefebe | 674 | @param[in] CheckList Pointer to list of parameters to check.\r |
675 | @param[out] CheckPackage Package of checked values.\r | |
676 | @param[out] ProblemParam Optional pointer to pointer to unicode string for \r | |
94b17fa1 | 677 | the paramater that caused failure.\r |
18cefebe | 678 | @param[in] AutoPageBreak Will automatically set PageBreakEnabled.\r |
679 | @param[in] AlwaysAllowNumbers Will never fail for number based flags.\r | |
94b17fa1 | 680 | \r |
681 | @retval EFI_SUCCESS The operation completed sucessfully.\r | |
a31bd33c | 682 | @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r |
683 | @retval EFI_INVALID_PARAMETER A parameter was invalid.\r | |
18cefebe | 684 | @retval EFI_VOLUME_CORRUPTED The command line was corrupt. An argument was \r |
a31bd33c | 685 | duplicated. The duplicated command line argument \r |
94b17fa1 | 686 | was returned in ProblemParam if provided.\r |
a31bd33c | 687 | @retval EFI_DEVICE_ERROR The commands contained 2 opposing arguments. One\r |
94b17fa1 | 688 | of the command line arguments was returned in \r |
689 | ProblemParam if provided.\r | |
125c2cf4 | 690 | @retval EFI_NOT_FOUND A argument required a value that was missing. \r |
a31bd33c | 691 | The invalid command line argument was returned in\r |
94b17fa1 | 692 | ProblemParam if provided.\r |
693 | **/\r | |
694 | EFI_STATUS\r | |
695 | EFIAPI\r | |
2247dde4 | 696 | ShellCommandLineParseEx (\r |
94b17fa1 | 697 | IN CONST SHELL_PARAM_ITEM *CheckList,\r |
698 | OUT LIST_ENTRY **CheckPackage,\r | |
699 | OUT CHAR16 **ProblemParam OPTIONAL,\r | |
2247dde4 | 700 | IN BOOLEAN AutoPageBreak,\r |
701 | IN BOOLEAN AlwaysAllowNumbers\r | |
94b17fa1 | 702 | );\r |
703 | \r | |
18cefebe | 704 | /// Make it easy to upgrade from older versions of the shell library.\r |
2247dde4 | 705 | #define ShellCommandLineParse(CheckList,CheckPackage,ProblemParam,AutoPageBreak) ShellCommandLineParseEx(CheckList,CheckPackage,ProblemParam,AutoPageBreak,FALSE)\r |
706 | \r | |
94b17fa1 | 707 | /**\r |
708 | Frees shell variable list that was returned from ShellCommandLineParse.\r | |
709 | \r | |
710 | This function will free all the memory that was used for the CheckPackage\r | |
711 | list of postprocessed shell arguments.\r | |
712 | \r | |
a31bd33c | 713 | If CheckPackage is NULL, then return.\r |
94b17fa1 | 714 | \r |
18cefebe | 715 | @param[in] CheckPackage The list to de-allocate.\r |
94b17fa1 | 716 | **/\r |
717 | VOID\r | |
718 | EFIAPI\r | |
719 | ShellCommandLineFreeVarList (\r | |
720 | IN LIST_ENTRY *CheckPackage\r | |
721 | );\r | |
722 | \r | |
723 | /**\r | |
a31bd33c | 724 | Checks for presence of a flag parameter.\r |
94b17fa1 | 725 | \r |
18cefebe | 726 | Flag arguments are in the form of "-<Key>" or "/<Key>", but do not have a value following the key.\r |
94b17fa1 | 727 | \r |
18cefebe | 728 | If CheckPackage is NULL then return FALSE.\r |
729 | If KeyString is NULL then ASSERT().\r | |
94b17fa1 | 730 | \r |
18cefebe | 731 | @param[in] CheckPackage The package of parsed command line arguments.\r |
732 | @param[in] KeyString The Key of the command line argument to check for.\r | |
94b17fa1 | 733 | \r |
a31bd33c | 734 | @retval TRUE The flag is on the command line.\r |
735 | @retval FALSE The flag is not on the command line.\r | |
94b17fa1 | 736 | **/\r |
737 | BOOLEAN\r | |
738 | EFIAPI\r | |
739 | ShellCommandLineGetFlag (\r | |
740 | IN CONST LIST_ENTRY *CheckPackage,\r | |
741 | IN CHAR16 *KeyString\r | |
742 | );\r | |
743 | \r | |
744 | /**\r | |
a31bd33c | 745 | Returns value from command line argument.\r |
94b17fa1 | 746 | \r |
18cefebe | 747 | Value parameters are in the form of "-<Key> value" or "/<Key> value".\r |
94b17fa1 | 748 | \r |
a31bd33c | 749 | If CheckPackage is NULL, then return NULL.\r |
94b17fa1 | 750 | \r |
36a9d672 | 751 | @param[in] CheckPackage The package of parsed command line arguments.\r |
752 | @param[in] KeyString The Key of the command line argument to check for.\r | |
94b17fa1 | 753 | \r |
a31bd33c | 754 | @retval NULL The flag is not on the command line.\r |
755 | @retval !=NULL Pointer to unicode string of the value.\r | |
94b17fa1 | 756 | **/\r |
757 | CONST CHAR16*\r | |
758 | EFIAPI\r | |
759 | ShellCommandLineGetValue (\r | |
760 | IN CONST LIST_ENTRY *CheckPackage,\r | |
761 | IN CHAR16 *KeyString\r | |
762 | );\r | |
763 | \r | |
764 | /**\r | |
a31bd33c | 765 | Returns raw value from command line argument.\r |
94b17fa1 | 766 | \r |
a31bd33c | 767 | Raw value parameters are in the form of "value" in a specific position in the list.\r |
94b17fa1 | 768 | \r |
36a9d672 | 769 | If CheckPackage is NULL, then return NULL.\r |
94b17fa1 | 770 | \r |
36a9d672 | 771 | @param[in] CheckPackage The package of parsed command line arguments.\r |
772 | @param[in] Position The position of the value.\r | |
94b17fa1 | 773 | \r |
a31bd33c | 774 | @retval NULL The flag is not on the command line.\r |
775 | @retval !=NULL Pointer to unicode string of the value.\r | |
94b17fa1 | 776 | **/\r |
777 | CONST CHAR16*\r | |
778 | EFIAPI\r | |
779 | ShellCommandLineGetRawValue (\r | |
780 | IN CONST LIST_ENTRY *CheckPackage,\r | |
781 | IN UINT32 Position\r | |
782 | );\r | |
783 | \r | |
2247dde4 | 784 | /**\r |
a31bd33c | 785 | Returns the number of command line value parameters that were parsed. \r |
2247dde4 | 786 | \r |
a31bd33c | 787 | This will not include flags.\r |
2247dde4 | 788 | \r |
18cefebe | 789 | @retval (UINTN)-1 No parsing has ocurred.\r |
790 | @return The number of value parameters found.\r | |
2247dde4 | 791 | **/\r |
792 | UINTN\r | |
793 | EFIAPI\r | |
794 | ShellCommandLineGetCount(\r | |
795 | VOID\r | |
796 | );\r | |
797 | \r | |
36a9d672 | 798 | /**\r |
799 | Determins if a parameter is duplicated.\r | |
800 | \r | |
801 | If Param is not NULL then it will point to a callee allocated string buffer \r | |
802 | with the parameter value if a duplicate is found.\r | |
803 | \r | |
804 | If CheckPackage is NULL, then ASSERT.\r | |
805 | \r | |
806 | @param[in] CheckPackage The package of parsed command line arguments.\r | |
807 | @param[out] Param Upon finding one, a pointer to the duplicated parameter.\r | |
808 | \r | |
809 | @retval EFI_SUCCESS No parameters were duplicated.\r | |
810 | @retval EFI_DEVICE_ERROR A duplicate was found.\r | |
811 | **/\r | |
812 | EFI_STATUS\r | |
813 | EFIAPI\r | |
814 | ShellCommandLineCheckDuplicate (\r | |
815 | IN CONST LIST_ENTRY *CheckPackage,\r | |
816 | OUT CHAR16 **Param\r | |
817 | );\r | |
818 | \r | |
d2b4564b | 819 | /**\r |
820 | This function causes the shell library to initialize itself. If the shell library\r | |
821 | is already initialized it will de-initialize all the current protocol poitners and\r | |
822 | re-populate them again.\r | |
823 | \r | |
824 | When the library is used with PcdShellLibAutoInitialize set to true this function\r | |
825 | will return EFI_SUCCESS and perform no actions.\r | |
826 | \r | |
827 | This function is intended for internal access for shell commands only.\r | |
828 | \r | |
829 | @retval EFI_SUCCESS the initialization was complete sucessfully\r | |
830 | \r | |
831 | **/\r | |
832 | EFI_STATUS\r | |
833 | EFIAPI\r | |
834 | ShellInitialize (\r | |
125c2cf4 | 835 | VOID\r |
d2b4564b | 836 | );\r |
837 | \r | |
b1f95a06 | 838 | /**\r |
839 | Print at a specific location on the screen.\r | |
840 | \r | |
a5bd42b9 | 841 | This function will move the cursor to a given screen location and print the specified string.\r |
b1f95a06 | 842 | \r |
843 | If -1 is specified for either the Row or Col the current screen location for BOTH \r | |
a5bd42b9 | 844 | will be used.\r |
b1f95a06 | 845 | \r |
a31bd33c | 846 | If either Row or Col is out of range for the current console, then ASSERT.\r |
847 | If Format is NULL, then ASSERT.\r | |
b1f95a06 | 848 | \r |
849 | In addition to the standard %-based flags as supported by UefiLib Print() this supports \r | |
850 | the following additional flags:\r | |
851 | %N - Set output attribute to normal\r | |
852 | %H - Set output attribute to highlight\r | |
853 | %E - Set output attribute to error\r | |
854 | %B - Set output attribute to blue color\r | |
855 | %V - Set output attribute to green color\r | |
856 | \r | |
857 | Note: The background color is controlled by the shell command cls.\r | |
858 | \r | |
18cefebe | 859 | @param[in] Row The row to print at.\r |
860 | @param[in] Col The column to print at.\r | |
861 | @param[in] Format The format string.\r | |
b1f95a06 | 862 | \r |
18cefebe | 863 | @return The number of characters printed to the screen.\r |
b1f95a06 | 864 | **/\r |
865 | \r | |
866 | UINTN\r | |
867 | EFIAPI\r | |
868 | ShellPrintEx(\r | |
869 | IN INT32 Col OPTIONAL,\r | |
870 | IN INT32 Row OPTIONAL,\r | |
871 | IN CONST CHAR16 *Format,\r | |
872 | ...\r | |
873 | );\r | |
874 | \r | |
2247dde4 | 875 | /**\r |
876 | Print at a specific location on the screen.\r | |
877 | \r | |
a5bd42b9 | 878 | This function will move the cursor to a given screen location and print the specified string.\r |
2247dde4 | 879 | \r |
880 | If -1 is specified for either the Row or Col the current screen location for BOTH \r | |
a5bd42b9 | 881 | will be used.\r |
2247dde4 | 882 | \r |
a5bd42b9 | 883 | If either Row or Col is out of range for the current console, then ASSERT.\r |
884 | If Format is NULL, then ASSERT.\r | |
2247dde4 | 885 | \r |
886 | In addition to the standard %-based flags as supported by UefiLib Print() this supports \r | |
887 | the following additional flags:\r | |
18cefebe | 888 | %N - Set output attribute to normal.\r |
889 | %H - Set output attribute to highlight.\r | |
890 | %E - Set output attribute to error.\r | |
891 | %B - Set output attribute to blue color.\r | |
892 | %V - Set output attribute to green color.\r | |
2247dde4 | 893 | \r |
894 | Note: The background color is controlled by the shell command cls.\r | |
895 | \r | |
18cefebe | 896 | @param[in] Row The row to print at.\r |
897 | @param[in] Col The column to print at.\r | |
898 | @param[in] HiiFormatStringId The format string Id for getting from Hii.\r | |
899 | @param[in] HiiFormatHandle The format string Handle for getting from Hii.\r | |
2247dde4 | 900 | \r |
18cefebe | 901 | @return the number of characters printed to the screen.\r |
2247dde4 | 902 | **/\r |
903 | UINTN\r | |
904 | EFIAPI\r | |
905 | ShellPrintHiiEx(\r | |
906 | IN INT32 Col OPTIONAL,\r | |
907 | IN INT32 Row OPTIONAL,\r | |
908 | IN CONST EFI_STRING_ID HiiFormatStringId,\r | |
909 | IN CONST EFI_HANDLE HiiFormatHandle,\r | |
910 | ...\r | |
911 | );\r | |
912 | \r | |
913 | /**\r | |
a31bd33c | 914 | Function to determine if a given filename represents a directory.\r |
2247dde4 | 915 | \r |
18cefebe | 916 | If DirName is NULL, then ASSERT.\r |
917 | \r | |
2247dde4 | 918 | @param[in] DirName Path to directory to test.\r |
919 | \r | |
a31bd33c | 920 | @retval EFI_SUCCESS The Path represents a directory.\r |
921 | @retval EFI_NOT_FOUND The Path does not represent a directory.\r | |
922 | @retval other The path failed to open.\r | |
2247dde4 | 923 | **/\r |
924 | EFI_STATUS\r | |
925 | EFIAPI\r | |
926 | ShellIsDirectory(\r | |
927 | IN CONST CHAR16 *DirName\r | |
928 | );\r | |
929 | \r | |
a31bd33c | 930 | /**\r |
931 | Function to determine if a given filename represents a file.\r | |
932 | \r | |
b3011f40 | 933 | This will search the CWD only.\r |
934 | \r | |
18cefebe | 935 | If Name is NULL, then ASSERT.\r |
936 | \r | |
a31bd33c | 937 | @param[in] Name Path to file to test.\r |
938 | \r | |
939 | @retval EFI_SUCCESS The Path represents a file.\r | |
940 | @retval EFI_NOT_FOUND The Path does not represent a file.\r | |
941 | @retval other The path failed to open.\r | |
942 | **/\r | |
943 | EFI_STATUS\r | |
944 | EFIAPI\r | |
945 | ShellIsFile(\r | |
946 | IN CONST CHAR16 *Name\r | |
947 | );\r | |
948 | \r | |
b3011f40 | 949 | /**\r |
950 | Function to determine if a given filename represents a file.\r | |
951 | \r | |
952 | This will search the CWD and then the Path.\r | |
953 | \r | |
954 | If Name is NULL, then ASSERT.\r | |
955 | \r | |
956 | @param[in] Name Path to file to test.\r | |
957 | \r | |
958 | @retval EFI_SUCCESS The Path represents a file.\r | |
959 | @retval EFI_NOT_FOUND The Path does not represent a file.\r | |
960 | @retval other The path failed to open.\r | |
961 | **/\r | |
962 | EFI_STATUS\r | |
963 | EFIAPI\r | |
964 | ShellIsFileInPath(\r | |
965 | IN CONST CHAR16 *Name\r | |
966 | );\r | |
967 | \r | |
125c2cf4 | 968 | /**\r |
969 | Function to determine whether a string is decimal or hex representation of a number \r | |
970 | and return the number converted from the string.\r | |
971 | \r | |
972 | @param[in] String String representation of a number\r | |
973 | \r | |
a31bd33c | 974 | @return The unsigned integer result of the conversion.\r |
125c2cf4 | 975 | **/\r |
976 | UINTN\r | |
977 | EFIAPI\r | |
978 | ShellStrToUintn(\r | |
979 | IN CONST CHAR16 *String\r | |
980 | );\r | |
981 | \r | |
982 | /**\r | |
983 | Safely append with automatic string resizing given length of Destination and \r | |
984 | desired length of copy from Source.\r | |
985 | \r | |
a31bd33c | 986 | Append the first D characters of Source to the end of Destination, where D is \r |
125c2cf4 | 987 | the lesser of Count and the StrLen() of Source. If appending those D characters \r |
988 | will fit within Destination (whose Size is given as CurrentSize) and \r | |
989 | still leave room for a null terminator, then those characters are appended, \r | |
990 | starting at the original terminating null of Destination, and a new terminating \r | |
991 | null is appended.\r | |
992 | \r | |
993 | If appending D characters onto Destination will result in a overflow of the size\r | |
994 | given in CurrentSize the string will be grown such that the copy can be performed\r | |
995 | and CurrentSize will be updated to the new size.\r | |
996 | \r | |
997 | If Source is NULL, there is nothing to append, just return the current buffer in \r | |
998 | Destination.\r | |
999 | \r | |
18cefebe | 1000 | If Destination is NULL, then ASSERT().\r |
1001 | If Destination's current length (including NULL terminator) is already more than \r | |
a31bd33c | 1002 | CurrentSize, then ASSERT().\r |
125c2cf4 | 1003 | \r |
a31bd33c | 1004 | @param[in,out] Destination The String to append onto.\r |
1005 | @param[in,out] CurrentSize On call the number of bytes in Destination. On \r | |
18cefebe | 1006 | return possibly the new size (still in bytes). If NULL\r |
125c2cf4 | 1007 | then allocate whatever is needed.\r |
a31bd33c | 1008 | @param[in] Source The String to append from.\r |
1009 | @param[in] Count Maximum number of characters to append. If 0 then \r | |
125c2cf4 | 1010 | all are appended.\r |
1011 | \r | |
18cefebe | 1012 | @return The Destination after apending the Source.\r |
125c2cf4 | 1013 | **/\r |
1014 | CHAR16* \r | |
1015 | EFIAPI\r | |
1016 | StrnCatGrow (\r | |
1017 | IN OUT CHAR16 **Destination,\r | |
1018 | IN OUT UINTN *CurrentSize,\r | |
1019 | IN CONST CHAR16 *Source,\r | |
1020 | IN UINTN Count\r | |
1021 | );\r | |
2247dde4 | 1022 | \r |
b3011f40 | 1023 | /**\r |
1024 | This is a find and replace function. Upon successful return the NewString is a copy of \r | |
1025 | SourceString with each instance of FindTarget replaced with ReplaceWith.\r | |
1026 | \r | |
1027 | If SourceString and NewString overlap the behavior is undefined.\r | |
1028 | \r | |
1029 | If the string would grow bigger than NewSize it will halt and return error.\r | |
1030 | \r | |
1031 | @param[in] SourceString String with source buffer.\r | |
1032 | @param[in,out] NewString String with resultant buffer.\r | |
1033 | @param[in] NewSize Size in bytes of NewString.\r | |
1034 | @param[in] FindTarget String to look for.\r | |
1035 | @param[in] ReplaceWith String to replace FindTarget with.\r | |
969c783b | 1036 | @param[in] SkipPreCarrot If TRUE will skip a FindTarget that has a '^'\r |
1037 | immediately before it.\r | |
b3011f40 | 1038 | \r |
1039 | @retval EFI_INVALID_PARAMETER SourceString was NULL.\r | |
1040 | @retval EFI_INVALID_PARAMETER NewString was NULL.\r | |
1041 | @retval EFI_INVALID_PARAMETER FindTarget was NULL.\r | |
1042 | @retval EFI_INVALID_PARAMETER ReplaceWith was NULL.\r | |
1043 | @retval EFI_INVALID_PARAMETER FindTarget had length < 1.\r | |
1044 | @retval EFI_INVALID_PARAMETER SourceString had length < 1.\r | |
1045 | @retval EFI_BUFFER_TOO_SMALL NewSize was less than the minimum size to hold \r | |
1046 | the new string (truncation occurred).\r | |
969c783b | 1047 | @retval EFI_SUCCESS The string was sucessfully copied with replacement.\r |
b3011f40 | 1048 | **/\r |
1049 | \r | |
1050 | EFI_STATUS\r | |
1051 | EFIAPI\r | |
969c783b | 1052 | ShellCopySearchAndReplace2(\r |
b3011f40 | 1053 | IN CHAR16 CONST *SourceString,\r |
1054 | IN CHAR16 *NewString,\r | |
1055 | IN UINTN NewSize,\r | |
1056 | IN CONST CHAR16 *FindTarget,\r | |
969c783b | 1057 | IN CONST CHAR16 *ReplaceWith,\r |
1058 | IN CONST BOOLEAN SkipPreCarrot\r | |
b3011f40 | 1059 | );\r |
1060 | \r | |
969c783b | 1061 | ///\r |
1062 | /// make upgrades easier from old version\r | |
1063 | ///\r | |
1064 | #define ShellLibCopySearchAndReplace(a,b,c,d,e) ShellCopySearchAndReplace2(a,b,c,d,e,FALSE)\r | |
1065 | \r | |
b3011f40 | 1066 | /**\r |
1067 | Check if a Unicode character is a hexadecimal character.\r | |
1068 | \r | |
1069 | This internal function checks if a Unicode character is a \r | |
1070 | decimal character. The valid hexadecimal character is \r | |
1071 | L'0' to L'9', L'a' to L'f', or L'A' to L'F'.\r | |
1072 | \r | |
1073 | @param[in] Char The character to check.\r | |
1074 | \r | |
1075 | @retval TRUE The Char is a hexadecmial character.\r | |
1076 | @retval FALSE The Char is not a hexadecmial character.\r | |
1077 | \r | |
1078 | **/\r | |
1079 | BOOLEAN\r | |
1080 | EFIAPI\r | |
969c783b | 1081 | ShellIsHexaDecimalDigitCharacter (\r |
b3011f40 | 1082 | IN CHAR16 Char\r |
1083 | );\r | |
1084 | \r | |
e9880e25 | 1085 | #endif // __SHELL_LIB__\r |