]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Include/Library/ShellCommandLib.h
This refactors 3 functions out of ShellCommandLib and puts them into a new library...
[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
4bbdc0e1 7 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
a405b86d 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
a405b86d 35extern EFI_UNICODE_COLLATION_PROTOCOL *gUnicodeCollation;\r
36extern EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *gDevPathToText;\r
37extern CONST CHAR16* SupportLevel[];\r
38\r
39//\r
40// The map list objects.\r
41//\r
42typedef struct {\r
43 LIST_ENTRY Link;\r
44 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
45 CHAR16 *MapName;\r
46 CHAR16 *CurrentDirectoryPath;\r
47 UINT64 Flags;\r
48} SHELL_MAP_LIST;\r
49/// List of Mappings - DeviceName and Drive Letter(ism).\r
50extern SHELL_MAP_LIST gShellMapList;\r
51/// Pointer to node of current directory in the mMapList.\r
52extern SHELL_MAP_LIST *gShellCurDir;\r
53\r
54/**\r
55 Returns the help MAN fileName for a given shell command.\r
56\r
57 @retval !NULL The unicode string of the MAN filename.\r
58 @retval NULL An error ocurred.\r
59\r
60**/\r
61typedef\r
62CONST CHAR16 *\r
63(EFIAPI *SHELL_GET_MAN_FILENAME)(\r
64 VOID\r
65 );\r
66\r
67/**\r
68 Runs a shell command on a given command line.\r
69\r
70 The specific operation of a given shell command is specified in the UEFI Shell\r
71 Specification 2.0, or in the source of the given command.\r
72\r
73 Upon completion of the command run the shell protocol and environment variables\r
74 may have been updated due to the operation.\r
75\r
76 @param[in] ImageHandle The ImageHandle to the app, or NULL if\r
77 the command built into shell.\r
78 @param[in] SystemTable The pointer to the system table.\r
79\r
80 @retval RETURN_SUCCESS The shell command was sucessful.\r
81 @retval RETURN_UNSUPPORTED The command is not supported.\r
82**/\r
83typedef\r
84SHELL_STATUS\r
85(EFIAPI *SHELL_RUN_COMMAND)(\r
86 IN EFI_HANDLE ImageHandle,\r
87 IN EFI_SYSTEM_TABLE *SystemTable\r
88 );\r
89\r
90/**\r
91 Registers the handlers of type SHELL_RUN_COMMAND and\r
92 SHELL_GET_MAN_FILENAME for each shell command.\r
93\r
94 If the ShellSupportLevel is greater than the value of\r
95 PcdShellSupportLevel, then return RETURN_UNSUPPORTED.\r
96\r
97 Registers the the handlers specified by GetHelpInfoHandler and CommandHandler\r
98 with the command specified by CommandString. If the command named by\r
99 CommandString has already been registered, then return\r
100 RETURN_ALREADY_STARTED.\r
101\r
102 If there are not enough resources available to register the handlers, then\r
103 RETURN_OUT_OF_RESOURCES is returned.\r
104\r
105 If CommandString is NULL, then ASSERT().\r
106 If GetHelpInfoHandler is NULL, then ASSERT().\r
107 If CommandHandler is NULL, then ASSERT().\r
108 If ProfileName is NULL, then ASSERT().\r
109\r
110 @param[in] CommandString The pointer to the command name. This is the\r
111 name to look for on the command line in\r
112 the shell.\r
113 @param[in] CommandHandler The pointer to a function that runs the\r
114 specified command.\r
115 @param[in] GetManFileName The pointer to a function that provides man\r
116 filename.\r
117 @param[in] ShellMinSupportLevel The minimum Shell Support Level which has this\r
118 function.\r
119 @param[in] ProfileName The profile name to require for support of this\r
120 function.\r
121 @param[in] CanAffectLE Indicates whether this command's return value\r
122 can change the LASTERROR environment variable.\r
123 @param[in] HiiHandle The handle of this command's HII entry.\r
124 @param[in] ManFormatHelp The HII locator for the help text.\r
125\r
126 @retval RETURN_SUCCESS The handlers were registered.\r
127 @retval RETURN_OUT_OF_RESOURCES There are not enough resources available to\r
128 register the shell command.\r
129 @retval RETURN_UNSUPPORTED The ShellMinSupportLevel was higher than the\r
130 currently allowed support level.\r
131 @retval RETURN_ALREADY_STARTED The CommandString represents a command that\r
132 is already registered. Only one handler set for\r
133 a given command is allowed.\r
134 @sa SHELL_GET_MAN_FILENAME\r
135 @sa SHELL_RUN_COMMAND\r
136**/\r
137RETURN_STATUS\r
138EFIAPI\r
139ShellCommandRegisterCommandName (\r
140 IN CONST CHAR16 *CommandString,\r
141 IN SHELL_RUN_COMMAND CommandHandler,\r
142 IN SHELL_GET_MAN_FILENAME GetManFileName,\r
143 IN UINT32 ShellMinSupportLevel,\r
144 IN CONST CHAR16 *ProfileName,\r
145 IN CONST BOOLEAN CanAffectLE,\r
146 IN CONST EFI_HANDLE HiiHandle,\r
147 IN CONST EFI_STRING_ID ManFormatHelp\r
148 );\r
149\r
150/**\r
151 Checks if a command string has been registered for CommandString, and if so, it runs\r
152 the previously registered handler for that command with the command line.\r
153\r
154 If CommandString is NULL, then ASSERT().\r
155\r
156 If Sections is specified, then each section name listed will be compared in a case sensitive\r
157 manner to the section names described in Appendix B UEFI Shell 2.0 Specification. If the section exists,\r
158 it is appended to the returned help text. If the section does not exist, no\r
159 information is returned. If Sections is NULL, then all help text information\r
160 available is returned.\r
161\r
162 @param[in] CommandString The pointer to the command name. This is the name\r
163 found on the command line in the shell.\r
164 @param[in,out] RetVal The pointer to the return value from the command handler.\r
165\r
166 @param[in,out] CanAffectLE Indicates whether this command's return value\r
167 needs to be placed into LASTERROR environment variable.\r
168\r
169 @retval RETURN_SUCCESS The handler was run.\r
170 @retval RETURN_NOT_FOUND The CommandString did not match a registered\r
171 command name.\r
172 @sa SHELL_RUN_COMMAND\r
173**/\r
174RETURN_STATUS\r
175EFIAPI\r
176ShellCommandRunCommandHandler (\r
177 IN CONST CHAR16 *CommandString,\r
178 IN OUT SHELL_STATUS *RetVal,\r
179 IN OUT BOOLEAN *CanAffectLE OPTIONAL\r
180 );\r
181\r
182/**\r
183 Checks if a command string has been registered for CommandString, and if so, it\r
184 returns the MAN filename specified for that command.\r
185\r
186 If CommandString is NULL, then ASSERT().\r
187\r
188 @param[in] CommandString The pointer to the command name. This is the name\r
189 found on the command line in the shell.\r
190\r
191 @retval NULL The CommandString was not a registered command.\r
192 @retval other The name of the MAN file.\r
193 @sa SHELL_GET_MAN_FILENAME\r
194**/\r
195CONST CHAR16*\r
196EFIAPI\r
197ShellCommandGetManFileNameHandler (\r
198 IN CONST CHAR16 *CommandString\r
199 );\r
200\r
201\r
202typedef struct {\r
203 LIST_ENTRY Link;\r
204 CHAR16 *CommandString;\r
205} COMMAND_LIST;\r
206\r
207/**\r
208 Get the list of all available shell internal commands. This is a linked list,\r
209 via the LIST_ENTRY structure. Enumerate through it using the BaseLib linked\r
210 list functions. Do not modify the values.\r
211\r
4bbdc0e1 212 @param[in] Sort TRUE to alphabetically sort the values first. FALSE otherwise.\r
213\r
a405b86d 214 @return A linked list of all available shell commands.\r
215**/\r
216CONST COMMAND_LIST*\r
217EFIAPI\r
218ShellCommandGetCommandList (\r
4bbdc0e1 219 IN CONST BOOLEAN Sort\r
a405b86d 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
0ab85bef 422/**\r
423 Function to cleanup all memory from a SCRIPT_FILE structure.\r
424\r
425 @param[in] Script The pointer to the structure to cleanup.\r
426**/\r
427VOID\r
428EFIAPI\r
429DeleteScriptFileStruct (\r
430 IN SCRIPT_FILE *Script\r
431 );\r
432\r
a405b86d 433/**\r
434 Function to get the current Profile string.\r
435\r
436 This is used to retrieve what profiles were installed.\r
437\r
438 @retval NULL There are no installed profiles.\r
439 @return A semicolon-delimited list of profiles.\r
440**/\r
441CONST CHAR16 *\r
442EFIAPI\r
443ShellCommandGetProfileList (\r
444 VOID\r
445 );\r
446\r
447typedef enum {\r
448 MappingTypeFileSystem,\r
449 MappingTypeBlockIo,\r
450 MappingTypeMax\r
451} SHELL_MAPPING_TYPE;\r
452\r
453/**\r
454 Function to generate the next default mapping name.\r
455\r
456 If the return value is not NULL then it must be callee freed.\r
457\r
458 @param Type What kind of mapping name to make.\r
459\r
460 @retval NULL a memory allocation failed.\r
461 @return a new map name string\r
462**/\r
463CHAR16*\r
464EFIAPI\r
465ShellCommandCreateNewMappingName(\r
466 IN CONST SHELL_MAPPING_TYPE Type\r
467 );\r
468\r
469/**\r
470 Function to initialize the table for creating consistent map names.\r
471\r
472 @param[out] Table The pointer to pointer to pointer to DevicePathProtocol object.\r
473\r
474 @retval EFI_SUCCESS The table was created successfully.\r
475**/\r
476EFI_STATUS\r
477EFIAPI\r
478ShellCommandConsistMappingInitialize (\r
479 EFI_DEVICE_PATH_PROTOCOL ***Table\r
480 );\r
481\r
482/**\r
483 Function to uninitialize the table for creating consistent map names.\r
484\r
485 The parameter must have been received from ShellCommandConsistMappingInitialize.\r
486\r
487 @param[out] Table The pointer to pointer to DevicePathProtocol object.\r
488\r
489 @retval EFI_SUCCESS The table was deleted successfully.\r
490**/\r
491EFI_STATUS\r
492EFIAPI\r
493ShellCommandConsistMappingUnInitialize (\r
494 EFI_DEVICE_PATH_PROTOCOL **Table\r
495 );\r
496\r
497/**\r
498 Create a consistent mapped name for the device specified by DevicePath \r
499 based on the Table.\r
500\r
501 This must be called after ShellCommandConsistMappingInitialize() and \r
502 before ShellCommandConsistMappingUnInitialize() is called.\r
503\r
4bbdc0e1 504 @param[in] DevicePath The pointer to the dev path for the device.\r
a405b86d 505 @param[in] Table The Table of mapping information.\r
506\r
507 @retval NULL A consistent mapped name could not be created.\r
508 @return A pointer to a string allocated from pool with the device name.\r
509**/\r
510CHAR16*\r
511EFIAPI\r
512ShellCommandConsistMappingGenMappingName (\r
513 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
514 IN EFI_DEVICE_PATH_PROTOCOL **Table\r
515 );\r
516\r
517/**\r
518 Function to search the list of mappings for the first matching node on the\r
519 list based on the MapKey.\r
520\r
521 @param[in] MapKey The pointer to the string key to search for in the map.\r
522\r
523 @return the node on the list.\r
524**/\r
525SHELL_MAP_LIST*\r
526EFIAPI\r
527ShellCommandFindMapItem (\r
528 IN CONST CHAR16 *MapKey\r
529 );\r
530\r
531/**\r
532 Function to add a map node to the list of map items and update the "path" environment variable (optionally).\r
533\r
534 If Path is TRUE (during initialization only), the path environment variable will also be updated to include\r
535 default paths on the new map name...\r
536\r
537 Path should be FALSE when this function is called from the protocol SetMap function.\r
538\r
539 @param[in] Name The human readable mapped name.\r
540 @param[in] DevicePath The Device Path for this map.\r
541 @param[in] Flags The Flags attribute for this map item.\r
542 @param[in] Path TRUE to update path, FALSE to skip this step (should only be TRUE during initialization).\r
543\r
544 @retval EFI_SUCCESS The addition was sucessful.\r
545 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
546 @retval EFI_INVALID_PARAMETER A parameter was invalid.\r
547**/\r
548EFI_STATUS\r
549EFIAPI\r
550ShellCommandAddMapItemAndUpdatePath(\r
551 IN CONST CHAR16 *Name,\r
552 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
553 IN CONST UINT64 Flags,\r
554 IN CONST BOOLEAN Path\r
555 );\r
556\r
557/**\r
558 Creates the default map names for each device path in the system with\r
559 a protocol depending on the Type.\r
560\r
561 Also sets up the default path environment variable if Type is FileSystem.\r
562\r
563 @retval EFI_SUCCESS All map names were created sucessfully.\r
564 @retval EFI_NOT_FOUND No protocols were found in the system.\r
565 @return Error returned from gBS->LocateHandle().\r
566\r
567 @sa LocateHandle\r
568**/\r
569EFI_STATUS\r
570EFIAPI\r
571ShellCommandCreateInitialMappingsAndPaths(\r
572 VOID\r
573 );\r
574\r
a405b86d 575/**\r
576 Converts a SHELL_FILE_HANDLE to an EFI_FILE_PROTOCOL*.\r
577\r
578 @param[in] Handle The SHELL_FILE_HANDLE to convert.\r
579\r
580 @return a EFI_FILE_PROTOCOL* representing the same file.\r
581**/\r
582EFI_FILE_PROTOCOL*\r
583EFIAPI\r
584ConvertShellHandleToEfiFileProtocol(\r
585 IN CONST SHELL_FILE_HANDLE Handle\r
586 );\r
587\r
588/**\r
589 Remove a SHELL_FILE_HANDLE frmo the list of SHELL_FILE_HANDLES.\r
590\r
591 @param[in] Handle The SHELL_FILE_HANDLE to remove.\r
592\r
593 @retval TRUE The item was removed.\r
594 @retval FALSE The item was not found.\r
595**/\r
596BOOLEAN\r
597EFIAPI\r
598ShellFileHandleRemove(\r
599 IN CONST SHELL_FILE_HANDLE Handle\r
600 );\r
601\r
602/**\r
603 Converts a EFI_FILE_PROTOCOL* to an SHELL_FILE_HANDLE.\r
604\r
605 @param[in] Handle The pointer to EFI_FILE_PROTOCOL to convert.\r
606 @param[in] Path The path to the file for verification.\r
607\r
608 @return a SHELL_FILE_HANDLE representing the same file.\r
609**/\r
610SHELL_FILE_HANDLE\r
611EFIAPI\r
612ConvertEfiFileProtocolToShellHandle(\r
613 IN CONST EFI_FILE_PROTOCOL *Handle,\r
614 IN CONST CHAR16 *Path\r
615 );\r
616\r
617/**\r
618 Find the path that was logged with the specified SHELL_FILE_HANDLE.\r
619\r
620 @param[in] Handle The SHELL_FILE_HANDLE to query on.\r
621\r
622 @return A pointer to the path for the file.\r
623**/\r
624CONST CHAR16*\r
625EFIAPI\r
626ShellFileHandleGetPath(\r
627 IN CONST SHELL_FILE_HANDLE Handle\r
628 );\r
629\r
630\r
631/**\r
632 Function to determine if a SHELL_FILE_HANDLE is at the end of the file.\r
633\r
634 This will NOT work on directories.\r
635\r
636 If Handle is NULL, then ASSERT.\r
637\r
638 @param[in] Handle the file handle\r
639\r
640 @retval TRUE the position is at the end of the file\r
641 @retval FALSE the position is not at the end of the file\r
642**/\r
643BOOLEAN\r
644EFIAPI\r
645ShellFileHandleEof(\r
646 IN SHELL_FILE_HANDLE Handle\r
647 );\r
648\r
649/**\r
650 Function to read a single line from a SHELL_FILE_HANDLE. The \n is not included in the returned\r
651 buffer. The returned buffer must be callee freed.\r
652\r
653 If the position upon start is 0, then the Ascii Boolean will be set. This should be\r
654 maintained and not changed for all operations with the same file.\r
655\r
656 @param[in] Handle SHELL_FILE_HANDLE to read from.\r
657 @param[in,out] Ascii Boolean value for indicating whether the file is\r
658 Ascii (TRUE) or UCS2 (FALSE).\r
659\r
660 @return The line of text from the file.\r
661\r
662 @sa ShellFileHandleReadLine\r
663**/\r
664CHAR16*\r
665EFIAPI\r
666ShellFileHandleReturnLine(\r
667 IN SHELL_FILE_HANDLE Handle,\r
668 IN OUT BOOLEAN *Ascii\r
669 );\r
670\r
671/**\r
672 Function to read a single line (up to but not including the \n) from a SHELL_FILE_HANDLE.\r
673\r
674 If the position upon start is 0, then the Ascii Boolean will be set. This should be\r
675 maintained and not changed for all operations with the same file.\r
676\r
677 @param[in] Handle SHELL_FILE_HANDLE to read from.\r
678 @param[in,out] Buffer The pointer to buffer to read into.\r
679 @param[in,out] Size The pointer to number of bytes in Buffer.\r
680 @param[in] Truncate If the buffer is large enough, this has no effect.\r
681 If the buffer is is too small and Truncate is TRUE,\r
682 the line will be truncated.\r
683 If the buffer is is too small and Truncate is FALSE,\r
684 then no read will occur.\r
685\r
686 @param[in,out] Ascii Boolean value for indicating whether the file is\r
687 Ascii (TRUE) or UCS2 (FALSE).\r
688\r
689 @retval EFI_SUCCESS The operation was successful. The line is stored in\r
690 Buffer.\r
691 @retval EFI_INVALID_PARAMETER Handle was NULL.\r
692 @retval EFI_INVALID_PARAMETER Size was NULL.\r
693 @retval EFI_BUFFER_TOO_SMALL Size was not large enough to store the line.\r
694 Size was updated to the minimum space required.\r
695 @sa ShellFileHandleRead\r
696**/\r
697EFI_STATUS\r
698EFIAPI\r
699ShellFileHandleReadLine(\r
700 IN SHELL_FILE_HANDLE Handle,\r
701 IN OUT CHAR16 *Buffer,\r
702 IN OUT UINTN *Size,\r
703 IN BOOLEAN Truncate,\r
704 IN OUT BOOLEAN *Ascii\r
705 );\r
706\r
707typedef struct {\r
708 LIST_ENTRY Link;\r
709 void *Buffer;\r
710} BUFFER_LIST;\r
711\r
712/**\r
713 Frees any BUFFER_LIST defined type.\r
714\r
715 @param[in] List The pointer to the list head.\r
716**/\r
717VOID\r
718EFIAPI\r
719FreeBufferList (\r
720 IN BUFFER_LIST *List\r
721 );\r
722\r
a405b86d 723#endif //_SHELL_COMMAND_LIB_\r