]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Include/Library/ShellCommandLib.h
udk2010.up2.shell initial release.
[mirror_edk2.git] / ShellPkg / Include / Library / ShellCommandLib.h
CommitLineData
a405b86d 1/** @file\r
2 Provides interface to shell internal functions for shell commands.\r
3\r
4 This library is for use ONLY by shell commands linked into the shell application.\r
5 This library will not funciton if it is used for UEFI Shell 2.0 Applications.\r
6\r
7 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
8 This program and the accompanying materials\r
9 are licensed and made available under the terms and conditions of the BSD License\r
10 which accompanies this distribution. The full text of the license may be found at\r
11 http://opensource.org/licenses/bsd-license.php.\r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16**/\r
17\r
18#ifndef _SHELL_COMMAND_LIB_\r
19#define _SHELL_COMMAND_LIB_\r
20\r
21#include <Uefi.h>\r
22#include <ShellBase.h>\r
23\r
24#include <Protocol/EfiShell.h>\r
25#include <Protocol/EfiShellParameters.h>\r
26#include <Protocol/UnicodeCollation.h>\r
27#include <Protocol/DevicePathToText.h>\r
28#include <Protocol/SimpleFileSystem.h>\r
29\r
30#include <Library/UefiBootServicesTableLib.h>\r
31\r
32//\r
33// The extern global protocol poionters.\r
34//\r
35extern EFI_SHELL_PROTOCOL *gEfiShellProtocol;\r
36extern EFI_SHELL_PARAMETERS_PROTOCOL *gEfiShellParametersProtocol;\r
37extern EFI_UNICODE_COLLATION_PROTOCOL *gUnicodeCollation;\r
38extern EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *gDevPathToText;\r
39extern CONST CHAR16* SupportLevel[];\r
40\r
41//\r
42// The map list objects.\r
43//\r
44typedef struct {\r
45 LIST_ENTRY Link;\r
46 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
47 CHAR16 *MapName;\r
48 CHAR16 *CurrentDirectoryPath;\r
49 UINT64 Flags;\r
50} SHELL_MAP_LIST;\r
51/// List of Mappings - DeviceName and Drive Letter(ism).\r
52extern SHELL_MAP_LIST gShellMapList;\r
53/// Pointer to node of current directory in the mMapList.\r
54extern SHELL_MAP_LIST *gShellCurDir;\r
55\r
56/**\r
57 Returns the help MAN fileName for a given shell command.\r
58\r
59 @retval !NULL The unicode string of the MAN filename.\r
60 @retval NULL An error ocurred.\r
61\r
62**/\r
63typedef\r
64CONST CHAR16 *\r
65(EFIAPI *SHELL_GET_MAN_FILENAME)(\r
66 VOID\r
67 );\r
68\r
69/**\r
70 Runs a shell command on a given command line.\r
71\r
72 The specific operation of a given shell command is specified in the UEFI Shell\r
73 Specification 2.0, or in the source of the given command.\r
74\r
75 Upon completion of the command run the shell protocol and environment variables\r
76 may have been updated due to the operation.\r
77\r
78 @param[in] ImageHandle The ImageHandle to the app, or NULL if\r
79 the command built into shell.\r
80 @param[in] SystemTable The pointer to the system table.\r
81\r
82 @retval RETURN_SUCCESS The shell command was sucessful.\r
83 @retval RETURN_UNSUPPORTED The command is not supported.\r
84**/\r
85typedef\r
86SHELL_STATUS\r
87(EFIAPI *SHELL_RUN_COMMAND)(\r
88 IN EFI_HANDLE ImageHandle,\r
89 IN EFI_SYSTEM_TABLE *SystemTable\r
90 );\r
91\r
92/**\r
93 Registers the handlers of type SHELL_RUN_COMMAND and\r
94 SHELL_GET_MAN_FILENAME for each shell command.\r
95\r
96 If the ShellSupportLevel is greater than the value of\r
97 PcdShellSupportLevel, then return RETURN_UNSUPPORTED.\r
98\r
99 Registers the the handlers specified by GetHelpInfoHandler and CommandHandler\r
100 with the command specified by CommandString. If the command named by\r
101 CommandString has already been registered, then return\r
102 RETURN_ALREADY_STARTED.\r
103\r
104 If there are not enough resources available to register the handlers, then\r
105 RETURN_OUT_OF_RESOURCES is returned.\r
106\r
107 If CommandString is NULL, then ASSERT().\r
108 If GetHelpInfoHandler is NULL, then ASSERT().\r
109 If CommandHandler is NULL, then ASSERT().\r
110 If ProfileName is NULL, then ASSERT().\r
111\r
112 @param[in] CommandString The pointer to the command name. This is the\r
113 name to look for on the command line in\r
114 the shell.\r
115 @param[in] CommandHandler The pointer to a function that runs the\r
116 specified command.\r
117 @param[in] GetManFileName The pointer to a function that provides man\r
118 filename.\r
119 @param[in] ShellMinSupportLevel The minimum Shell Support Level which has this\r
120 function.\r
121 @param[in] ProfileName The profile name to require for support of this\r
122 function.\r
123 @param[in] CanAffectLE Indicates whether this command's return value\r
124 can change the LASTERROR environment variable.\r
125 @param[in] HiiHandle The handle of this command's HII entry.\r
126 @param[in] ManFormatHelp The HII locator for the help text.\r
127\r
128 @retval RETURN_SUCCESS The handlers were registered.\r
129 @retval RETURN_OUT_OF_RESOURCES There are not enough resources available to\r
130 register the shell command.\r
131 @retval RETURN_UNSUPPORTED The ShellMinSupportLevel was higher than the\r
132 currently allowed support level.\r
133 @retval RETURN_ALREADY_STARTED The CommandString represents a command that\r
134 is already registered. Only one handler set for\r
135 a given command is allowed.\r
136 @sa SHELL_GET_MAN_FILENAME\r
137 @sa SHELL_RUN_COMMAND\r
138**/\r
139RETURN_STATUS\r
140EFIAPI\r
141ShellCommandRegisterCommandName (\r
142 IN CONST CHAR16 *CommandString,\r
143 IN SHELL_RUN_COMMAND CommandHandler,\r
144 IN SHELL_GET_MAN_FILENAME GetManFileName,\r
145 IN UINT32 ShellMinSupportLevel,\r
146 IN CONST CHAR16 *ProfileName,\r
147 IN CONST BOOLEAN CanAffectLE,\r
148 IN CONST EFI_HANDLE HiiHandle,\r
149 IN CONST EFI_STRING_ID ManFormatHelp\r
150 );\r
151\r
152/**\r
153 Checks if a command string has been registered for CommandString, and if so, it runs\r
154 the previously registered handler for that command with the command line.\r
155\r
156 If CommandString is NULL, then ASSERT().\r
157\r
158 If Sections is specified, then each section name listed will be compared in a case sensitive\r
159 manner to the section names described in Appendix B UEFI Shell 2.0 Specification. If the section exists,\r
160 it is appended to the returned help text. If the section does not exist, no\r
161 information is returned. If Sections is NULL, then all help text information\r
162 available is returned.\r
163\r
164 @param[in] CommandString The pointer to the command name. This is the name\r
165 found on the command line in the shell.\r
166 @param[in,out] RetVal The pointer to the return value from the command handler.\r
167\r
168 @param[in,out] CanAffectLE Indicates whether this command's return value\r
169 needs to be placed into LASTERROR environment variable.\r
170\r
171 @retval RETURN_SUCCESS The handler was run.\r
172 @retval RETURN_NOT_FOUND The CommandString did not match a registered\r
173 command name.\r
174 @sa SHELL_RUN_COMMAND\r
175**/\r
176RETURN_STATUS\r
177EFIAPI\r
178ShellCommandRunCommandHandler (\r
179 IN CONST CHAR16 *CommandString,\r
180 IN OUT SHELL_STATUS *RetVal,\r
181 IN OUT BOOLEAN *CanAffectLE OPTIONAL\r
182 );\r
183\r
184/**\r
185 Checks if a command string has been registered for CommandString, and if so, it\r
186 returns the MAN filename specified for that command.\r
187\r
188 If CommandString is NULL, then ASSERT().\r
189\r
190 @param[in] CommandString The pointer to the command name. This is the name\r
191 found on the command line in the shell.\r
192\r
193 @retval NULL The CommandString was not a registered command.\r
194 @retval other The name of the MAN file.\r
195 @sa SHELL_GET_MAN_FILENAME\r
196**/\r
197CONST CHAR16*\r
198EFIAPI\r
199ShellCommandGetManFileNameHandler (\r
200 IN CONST CHAR16 *CommandString\r
201 );\r
202\r
203\r
204typedef struct {\r
205 LIST_ENTRY Link;\r
206 CHAR16 *CommandString;\r
207} COMMAND_LIST;\r
208\r
209/**\r
210 Get the list of all available shell internal commands. This is a linked list,\r
211 via the LIST_ENTRY structure. Enumerate through it using the BaseLib linked\r
212 list functions. Do not modify the values.\r
213\r
214 @return A linked list of all available shell commands.\r
215**/\r
216CONST COMMAND_LIST*\r
217EFIAPI\r
218ShellCommandGetCommandList (\r
219 VOID\r
220 );\r
221\r
222typedef struct {\r
223 LIST_ENTRY Link;\r
224 CHAR16 *CommandString;\r
225 CHAR16 *Alias;\r
226} ALIAS_LIST;\r
227\r
228/**\r
229 Registers aliases to be set as part of the initialization of the shell application.\r
230\r
231 If Command is NULL, then ASSERT().\r
232 If Alias is NULL, then ASSERT().\r
233\r
234 @param[in] Command The pointer to the Command.\r
235 @param[in] Alias The pointer to Alias.\r
236\r
237 @retval RETURN_SUCCESS The handlers were registered.\r
238 @retval RETURN_OUT_OF_RESOURCES There are not enough resources available to\r
239 register the shell command.\r
240**/\r
241RETURN_STATUS\r
242EFIAPI\r
243ShellCommandRegisterAlias (\r
244 IN CONST CHAR16 *Command,\r
245 IN CONST CHAR16 *Alias\r
246 );\r
247\r
248/**\r
249 Get the list of all shell alias commands. This is a linked list,\r
250 via LIST_ENTRY structure. Enumerate through it using the BaseLib linked\r
251 list functions. Do not modify the values.\r
252\r
253 @return A linked list of all requested shell aliases.\r
254**/\r
255CONST ALIAS_LIST*\r
256EFIAPI\r
257ShellCommandGetInitAliasList (\r
258 VOID\r
259 );\r
260\r
261/**\r
262 Determine if a given alias is on the list of built in aliases.\r
263\r
264 @param[in] Alias The alias to test for.\r
265\r
266 @retval TRUE The alias is a built in alias.\r
267 @retval FALSE The alias is not a built in alias.\r
268**/\r
269BOOLEAN\r
270EFIAPI\r
271ShellCommandIsOnAliasList (\r
272 IN CONST CHAR16 *Alias\r
273 );\r
274\r
275/**\r
276 Checks if a command is already on the list.\r
277\r
278 @param[in] CommandString The command string to check for on the list.\r
279\r
280 @retval TRUE CommandString represents a registered command.\r
281 @retval FALSE CommandString does not represent a registered command.\r
282**/\r
283BOOLEAN\r
284EFIAPI\r
285ShellCommandIsCommandOnList (\r
286 IN CONST CHAR16 *CommandString\r
287 );\r
288\r
289/**\r
290 Get the help text for a command.\r
291\r
292 @param[in] CommandString The command name.\r
293\r
294 @retval NULL No help text was found.\r
295 @return The string of the help text. The caller required to free.\r
296**/\r
297CHAR16*\r
298EFIAPI\r
299ShellCommandGetCommandHelp (\r
300 IN CONST CHAR16 *CommandString\r
301 );\r
302\r
303/**\r
304 Function to make sure that the above pointers are valid.\r
305**/\r
306EFI_STATUS\r
307EFIAPI\r
308CommandInit (\r
309 VOID\r
310 );\r
311\r
312/**\r
313 Function to determine current state of ECHO. Echo determines if lines from scripts\r
314 and ECHO commands are enabled.\r
315\r
316 @retval TRUE Echo is currently enabled.\r
317 @retval FALSE Echo is currently disabled.\r
318**/\r
319BOOLEAN\r
320EFIAPI\r
321ShellCommandGetEchoState (\r
322 VOID\r
323 );\r
324\r
325/**\r
326 Function to set current state of ECHO. Echo determines if lines from scripts\r
327 and ECHO commands are enabled.\r
328\r
329 @param[in] State TRUE to enable Echo, FALSE otherwise.\r
330**/\r
331VOID\r
332EFIAPI\r
333ShellCommandSetEchoState (\r
334 IN BOOLEAN State\r
335 );\r
336\r
337\r
338\r
339/**\r
340 Indicate that the current shell or script should exit.\r
341\r
342 @param[in] ScriptOnly TRUE if exiting a script; FALSE otherwise.\r
343**/\r
344VOID\r
345EFIAPI\r
346ShellCommandRegisterExit (\r
347 IN BOOLEAN ScriptOnly\r
348 );\r
349\r
350/**\r
351 Retrieve the Exit indicator.\r
352\r
353 @retval TRUE Exit was indicated.\r
354 @retval FALSE Exit was not indicated.\r
355**/\r
356BOOLEAN\r
357EFIAPI\r
358ShellCommandGetExit (\r
359 VOID\r
360 );\r
361\r
362/**\r
363 Retrieve the Exit script indicator.\r
364\r
365 If ShellCommandGetExit returns FALSE, then the return from this is undefined.\r
366\r
367 @retval TRUE ScriptOnly was indicated.\r
368 @retval FALSE ScriptOnly was not indicated.\r
369**/\r
370BOOLEAN\r
371EFIAPI\r
372ShellCommandGetScriptExit (\r
373 VOID\r
374 );\r
375\r
376typedef struct {\r
377 LIST_ENTRY Link; ///< List enumerator items.\r
378 UINTN Line; ///< What line of the script file this was on.\r
379 CHAR16 *Cl; ///< The original command line.\r
380 VOID *Data; ///< The data structure format dependant upon Command. (not always used)\r
381 BOOLEAN Reset; ///< Reset the command (it must be treated like a initial run (but it may have data already))\r
382} SCRIPT_COMMAND_LIST;\r
383\r
384typedef struct {\r
385 CHAR16 *ScriptName; ///< The filename of this script.\r
386 CHAR16 **Argv; ///< The parmameters to the script file.\r
387 UINTN Argc; ///< The count of parameters.\r
388 LIST_ENTRY CommandList; ///< The script converted to a list of commands (SCRIPT_COMMAND_LIST objects).\r
389 SCRIPT_COMMAND_LIST *CurrentCommand; ///< The command currently being operated. If !=NULL must be a member of CommandList.\r
390 LIST_ENTRY SubstList; ///< A list of current script loop alias' (ALIAS_LIST objects) (Used for the for %-based replacement).\r
391} SCRIPT_FILE;\r
392\r
393/**\r
394 Function to return a pointer to the currently running script file object.\r
395\r
396 @retval NULL A script file is not currently running.\r
397 @return A pointer to the current script file object.\r
398**/\r
399SCRIPT_FILE*\r
400EFIAPI\r
401ShellCommandGetCurrentScriptFile (\r
402 VOID\r
403 );\r
404\r
405/**\r
406 Function to set a new script as the currently running one.\r
407\r
408 This function will correctly stack and unstack nested scripts.\r
409\r
410 @param[in] Script The pointer to new script information structure. If NULL,\r
411 it removes and de-allocates the topmost Script structure.\r
412\r
413 @return A pointer to the current running script file after this\r
414 change. It is NULL if removing the final script.\r
415**/\r
416SCRIPT_FILE*\r
417EFIAPI\r
418ShellCommandSetNewScript (\r
419 IN SCRIPT_FILE *Script OPTIONAL\r
420 );\r
421\r
422/**\r
423 Function to get the current Profile string.\r
424\r
425 This is used to retrieve what profiles were installed.\r
426\r
427 @retval NULL There are no installed profiles.\r
428 @return A semicolon-delimited list of profiles.\r
429**/\r
430CONST CHAR16 *\r
431EFIAPI\r
432ShellCommandGetProfileList (\r
433 VOID\r
434 );\r
435\r
436typedef enum {\r
437 MappingTypeFileSystem,\r
438 MappingTypeBlockIo,\r
439 MappingTypeMax\r
440} SHELL_MAPPING_TYPE;\r
441\r
442/**\r
443 Function to generate the next default mapping name.\r
444\r
445 If the return value is not NULL then it must be callee freed.\r
446\r
447 @param Type What kind of mapping name to make.\r
448\r
449 @retval NULL a memory allocation failed.\r
450 @return a new map name string\r
451**/\r
452CHAR16*\r
453EFIAPI\r
454ShellCommandCreateNewMappingName(\r
455 IN CONST SHELL_MAPPING_TYPE Type\r
456 );\r
457\r
458/**\r
459 Function to initialize the table for creating consistent map names.\r
460\r
461 @param[out] Table The pointer to pointer to pointer to DevicePathProtocol object.\r
462\r
463 @retval EFI_SUCCESS The table was created successfully.\r
464**/\r
465EFI_STATUS\r
466EFIAPI\r
467ShellCommandConsistMappingInitialize (\r
468 EFI_DEVICE_PATH_PROTOCOL ***Table\r
469 );\r
470\r
471/**\r
472 Function to uninitialize the table for creating consistent map names.\r
473\r
474 The parameter must have been received from ShellCommandConsistMappingInitialize.\r
475\r
476 @param[out] Table The pointer to pointer to DevicePathProtocol object.\r
477\r
478 @retval EFI_SUCCESS The table was deleted successfully.\r
479**/\r
480EFI_STATUS\r
481EFIAPI\r
482ShellCommandConsistMappingUnInitialize (\r
483 EFI_DEVICE_PATH_PROTOCOL **Table\r
484 );\r
485\r
486/**\r
487 Create a consistent mapped name for the device specified by DevicePath \r
488 based on the Table.\r
489\r
490 This must be called after ShellCommandConsistMappingInitialize() and \r
491 before ShellCommandConsistMappingUnInitialize() is called.\r
492\r
493 @param[in] DeviecPath The pointer to the dev path for the device.\r
494 @param[in] Table The Table of mapping information.\r
495\r
496 @retval NULL A consistent mapped name could not be created.\r
497 @return A pointer to a string allocated from pool with the device name.\r
498**/\r
499CHAR16*\r
500EFIAPI\r
501ShellCommandConsistMappingGenMappingName (\r
502 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
503 IN EFI_DEVICE_PATH_PROTOCOL **Table\r
504 );\r
505\r
506/**\r
507 Function to search the list of mappings for the first matching node on the\r
508 list based on the MapKey.\r
509\r
510 @param[in] MapKey The pointer to the string key to search for in the map.\r
511\r
512 @return the node on the list.\r
513**/\r
514SHELL_MAP_LIST*\r
515EFIAPI\r
516ShellCommandFindMapItem (\r
517 IN CONST CHAR16 *MapKey\r
518 );\r
519\r
520/**\r
521 Function to add a map node to the list of map items and update the "path" environment variable (optionally).\r
522\r
523 If Path is TRUE (during initialization only), the path environment variable will also be updated to include\r
524 default paths on the new map name...\r
525\r
526 Path should be FALSE when this function is called from the protocol SetMap function.\r
527\r
528 @param[in] Name The human readable mapped name.\r
529 @param[in] DevicePath The Device Path for this map.\r
530 @param[in] Flags The Flags attribute for this map item.\r
531 @param[in] Path TRUE to update path, FALSE to skip this step (should only be TRUE during initialization).\r
532\r
533 @retval EFI_SUCCESS The addition was sucessful.\r
534 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
535 @retval EFI_INVALID_PARAMETER A parameter was invalid.\r
536**/\r
537EFI_STATUS\r
538EFIAPI\r
539ShellCommandAddMapItemAndUpdatePath(\r
540 IN CONST CHAR16 *Name,\r
541 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
542 IN CONST UINT64 Flags,\r
543 IN CONST BOOLEAN Path\r
544 );\r
545\r
546/**\r
547 Creates the default map names for each device path in the system with\r
548 a protocol depending on the Type.\r
549\r
550 Also sets up the default path environment variable if Type is FileSystem.\r
551\r
552 @retval EFI_SUCCESS All map names were created sucessfully.\r
553 @retval EFI_NOT_FOUND No protocols were found in the system.\r
554 @return Error returned from gBS->LocateHandle().\r
555\r
556 @sa LocateHandle\r
557**/\r
558EFI_STATUS\r
559EFIAPI\r
560ShellCommandCreateInitialMappingsAndPaths(\r
561 VOID\r
562 );\r
563\r
564/**\r
565 Function to standardize the directory indicators to \ characters.\r
566\r
567 @param[in,out] Path The pointer to the path string to fix.\r
568\r
569 @retval NULL The operation failed.\r
570 @return The Path pointer.\r
571**/\r
572CHAR16*\r
573EFIAPI\r
574ShellCommandCleanPath (\r
575 IN OUT CHAR16 *Path\r
576 );\r
577\r
578/**\r
579 Converts a SHELL_FILE_HANDLE to an EFI_FILE_PROTOCOL*.\r
580\r
581 @param[in] Handle The SHELL_FILE_HANDLE to convert.\r
582\r
583 @return a EFI_FILE_PROTOCOL* representing the same file.\r
584**/\r
585EFI_FILE_PROTOCOL*\r
586EFIAPI\r
587ConvertShellHandleToEfiFileProtocol(\r
588 IN CONST SHELL_FILE_HANDLE Handle\r
589 );\r
590\r
591/**\r
592 Remove a SHELL_FILE_HANDLE frmo the list of SHELL_FILE_HANDLES.\r
593\r
594 @param[in] Handle The SHELL_FILE_HANDLE to remove.\r
595\r
596 @retval TRUE The item was removed.\r
597 @retval FALSE The item was not found.\r
598**/\r
599BOOLEAN\r
600EFIAPI\r
601ShellFileHandleRemove(\r
602 IN CONST SHELL_FILE_HANDLE Handle\r
603 );\r
604\r
605/**\r
606 Converts a EFI_FILE_PROTOCOL* to an SHELL_FILE_HANDLE.\r
607\r
608 @param[in] Handle The pointer to EFI_FILE_PROTOCOL to convert.\r
609 @param[in] Path The path to the file for verification.\r
610\r
611 @return a SHELL_FILE_HANDLE representing the same file.\r
612**/\r
613SHELL_FILE_HANDLE\r
614EFIAPI\r
615ConvertEfiFileProtocolToShellHandle(\r
616 IN CONST EFI_FILE_PROTOCOL *Handle,\r
617 IN CONST CHAR16 *Path\r
618 );\r
619\r
620/**\r
621 Find the path that was logged with the specified SHELL_FILE_HANDLE.\r
622\r
623 @param[in] Handle The SHELL_FILE_HANDLE to query on.\r
624\r
625 @return A pointer to the path for the file.\r
626**/\r
627CONST CHAR16*\r
628EFIAPI\r
629ShellFileHandleGetPath(\r
630 IN CONST SHELL_FILE_HANDLE Handle\r
631 );\r
632\r
633\r
634/**\r
635 Function to determine if a SHELL_FILE_HANDLE is at the end of the file.\r
636\r
637 This will NOT work on directories.\r
638\r
639 If Handle is NULL, then ASSERT.\r
640\r
641 @param[in] Handle the file handle\r
642\r
643 @retval TRUE the position is at the end of the file\r
644 @retval FALSE the position is not at the end of the file\r
645**/\r
646BOOLEAN\r
647EFIAPI\r
648ShellFileHandleEof(\r
649 IN SHELL_FILE_HANDLE Handle\r
650 );\r
651\r
652/**\r
653 Function to read a single line from a SHELL_FILE_HANDLE. The \n is not included in the returned\r
654 buffer. The returned buffer must be callee freed.\r
655\r
656 If the position upon start is 0, then the Ascii Boolean will be set. This should be\r
657 maintained and not changed for all operations with the same file.\r
658\r
659 @param[in] Handle SHELL_FILE_HANDLE to read from.\r
660 @param[in,out] Ascii Boolean value for indicating whether the file is\r
661 Ascii (TRUE) or UCS2 (FALSE).\r
662\r
663 @return The line of text from the file.\r
664\r
665 @sa ShellFileHandleReadLine\r
666**/\r
667CHAR16*\r
668EFIAPI\r
669ShellFileHandleReturnLine(\r
670 IN SHELL_FILE_HANDLE Handle,\r
671 IN OUT BOOLEAN *Ascii\r
672 );\r
673\r
674/**\r
675 Function to read a single line (up to but not including the \n) from a SHELL_FILE_HANDLE.\r
676\r
677 If the position upon start is 0, then the Ascii Boolean will be set. This should be\r
678 maintained and not changed for all operations with the same file.\r
679\r
680 @param[in] Handle SHELL_FILE_HANDLE to read from.\r
681 @param[in,out] Buffer The pointer to buffer to read into.\r
682 @param[in,out] Size The pointer to number of bytes in Buffer.\r
683 @param[in] Truncate If the buffer is large enough, this has no effect.\r
684 If the buffer is is too small and Truncate is TRUE,\r
685 the line will be truncated.\r
686 If the buffer is is too small and Truncate is FALSE,\r
687 then no read will occur.\r
688\r
689 @param[in,out] Ascii Boolean value for indicating whether the file is\r
690 Ascii (TRUE) or UCS2 (FALSE).\r
691\r
692 @retval EFI_SUCCESS The operation was successful. The line is stored in\r
693 Buffer.\r
694 @retval EFI_INVALID_PARAMETER Handle was NULL.\r
695 @retval EFI_INVALID_PARAMETER Size was NULL.\r
696 @retval EFI_BUFFER_TOO_SMALL Size was not large enough to store the line.\r
697 Size was updated to the minimum space required.\r
698 @sa ShellFileHandleRead\r
699**/\r
700EFI_STATUS\r
701EFIAPI\r
702ShellFileHandleReadLine(\r
703 IN SHELL_FILE_HANDLE Handle,\r
704 IN OUT CHAR16 *Buffer,\r
705 IN OUT UINTN *Size,\r
706 IN BOOLEAN Truncate,\r
707 IN OUT BOOLEAN *Ascii\r
708 );\r
709\r
710typedef struct {\r
711 LIST_ENTRY Link;\r
712 void *Buffer;\r
713} BUFFER_LIST;\r
714\r
715/**\r
716 Frees any BUFFER_LIST defined type.\r
717\r
718 @param[in] List The pointer to the list head.\r
719**/\r
720VOID\r
721EFIAPI\r
722FreeBufferList (\r
723 IN BUFFER_LIST *List\r
724 );\r
725\r
726/**\r
727 Chops off last directory or file entry in a path by changing the last '\' to a CHAR_NULL\r
728\r
729 @param[in,out] PathToReturn The pointer to the path to modify.\r
730\r
731 @retval FALSE No directory was found to chop off.\r
732 @retval TRUE A directory was chopped off.\r
733**/\r
734BOOLEAN\r
735EFIAPI\r
736ChopLastSlash(\r
737 IN OUT CHAR16 *PathToReturn\r
738 );\r
739\r
740/**\r
741 Function to clean up paths. Removes the following items:\r
742 single periods in the path (no need for the current directory tag)\r
743 double periods in the path and removes a single parent directory.\r
744\r
745 This will be done inline and the resultant string may be be 'too big'.\r
746\r
747 @param[in] PathToReturn The pointer to the string containing the path.\r
748\r
749 @return PathToReturn is always returned.\r
750**/\r
751CHAR16*\r
752EFIAPI\r
753CleanPath(\r
754 IN CHAR16 *PathToReturn\r
755 );\r
756\r
757#endif //_SHELL_COMMAND_LIB_\r