]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Include/Library/ShellCommandLib.h
move include file line under #define protection.
[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
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
504 @param[in] DeviecPath The pointer to the dev path for the device.\r
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
575/**\r
576 Function to standardize the directory indicators to \ characters.\r
577\r
578 @param[in,out] Path The pointer to the path string to fix.\r
579\r
580 @retval NULL The operation failed.\r
581 @return The Path pointer.\r
582**/\r
583CHAR16*\r
584EFIAPI\r
585ShellCommandCleanPath (\r
586 IN OUT CHAR16 *Path\r
587 );\r
588\r
589/**\r
590 Converts a SHELL_FILE_HANDLE to an EFI_FILE_PROTOCOL*.\r
591\r
592 @param[in] Handle The SHELL_FILE_HANDLE to convert.\r
593\r
594 @return a EFI_FILE_PROTOCOL* representing the same file.\r
595**/\r
596EFI_FILE_PROTOCOL*\r
597EFIAPI\r
598ConvertShellHandleToEfiFileProtocol(\r
599 IN CONST SHELL_FILE_HANDLE Handle\r
600 );\r
601\r
602/**\r
603 Remove a SHELL_FILE_HANDLE frmo the list of SHELL_FILE_HANDLES.\r
604\r
605 @param[in] Handle The SHELL_FILE_HANDLE to remove.\r
606\r
607 @retval TRUE The item was removed.\r
608 @retval FALSE The item was not found.\r
609**/\r
610BOOLEAN\r
611EFIAPI\r
612ShellFileHandleRemove(\r
613 IN CONST SHELL_FILE_HANDLE Handle\r
614 );\r
615\r
616/**\r
617 Converts a EFI_FILE_PROTOCOL* to an SHELL_FILE_HANDLE.\r
618\r
619 @param[in] Handle The pointer to EFI_FILE_PROTOCOL to convert.\r
620 @param[in] Path The path to the file for verification.\r
621\r
622 @return a SHELL_FILE_HANDLE representing the same file.\r
623**/\r
624SHELL_FILE_HANDLE\r
625EFIAPI\r
626ConvertEfiFileProtocolToShellHandle(\r
627 IN CONST EFI_FILE_PROTOCOL *Handle,\r
628 IN CONST CHAR16 *Path\r
629 );\r
630\r
631/**\r
632 Find the path that was logged with the specified SHELL_FILE_HANDLE.\r
633\r
634 @param[in] Handle The SHELL_FILE_HANDLE to query on.\r
635\r
636 @return A pointer to the path for the file.\r
637**/\r
638CONST CHAR16*\r
639EFIAPI\r
640ShellFileHandleGetPath(\r
641 IN CONST SHELL_FILE_HANDLE Handle\r
642 );\r
643\r
644\r
645/**\r
646 Function to determine if a SHELL_FILE_HANDLE is at the end of the file.\r
647\r
648 This will NOT work on directories.\r
649\r
650 If Handle is NULL, then ASSERT.\r
651\r
652 @param[in] Handle the file handle\r
653\r
654 @retval TRUE the position is at the end of the file\r
655 @retval FALSE the position is not at the end of the file\r
656**/\r
657BOOLEAN\r
658EFIAPI\r
659ShellFileHandleEof(\r
660 IN SHELL_FILE_HANDLE Handle\r
661 );\r
662\r
663/**\r
664 Function to read a single line from a SHELL_FILE_HANDLE. The \n is not included in the returned\r
665 buffer. The returned buffer must be callee freed.\r
666\r
667 If the position upon start is 0, then the Ascii Boolean will be set. This should be\r
668 maintained and not changed for all operations with the same file.\r
669\r
670 @param[in] Handle SHELL_FILE_HANDLE to read from.\r
671 @param[in,out] Ascii Boolean value for indicating whether the file is\r
672 Ascii (TRUE) or UCS2 (FALSE).\r
673\r
674 @return The line of text from the file.\r
675\r
676 @sa ShellFileHandleReadLine\r
677**/\r
678CHAR16*\r
679EFIAPI\r
680ShellFileHandleReturnLine(\r
681 IN SHELL_FILE_HANDLE Handle,\r
682 IN OUT BOOLEAN *Ascii\r
683 );\r
684\r
685/**\r
686 Function to read a single line (up to but not including the \n) from a SHELL_FILE_HANDLE.\r
687\r
688 If the position upon start is 0, then the Ascii Boolean will be set. This should be\r
689 maintained and not changed for all operations with the same file.\r
690\r
691 @param[in] Handle SHELL_FILE_HANDLE to read from.\r
692 @param[in,out] Buffer The pointer to buffer to read into.\r
693 @param[in,out] Size The pointer to number of bytes in Buffer.\r
694 @param[in] Truncate If the buffer is large enough, this has no effect.\r
695 If the buffer is is too small and Truncate is TRUE,\r
696 the line will be truncated.\r
697 If the buffer is is too small and Truncate is FALSE,\r
698 then no read will occur.\r
699\r
700 @param[in,out] Ascii Boolean value for indicating whether the file is\r
701 Ascii (TRUE) or UCS2 (FALSE).\r
702\r
703 @retval EFI_SUCCESS The operation was successful. The line is stored in\r
704 Buffer.\r
705 @retval EFI_INVALID_PARAMETER Handle was NULL.\r
706 @retval EFI_INVALID_PARAMETER Size was NULL.\r
707 @retval EFI_BUFFER_TOO_SMALL Size was not large enough to store the line.\r
708 Size was updated to the minimum space required.\r
709 @sa ShellFileHandleRead\r
710**/\r
711EFI_STATUS\r
712EFIAPI\r
713ShellFileHandleReadLine(\r
714 IN SHELL_FILE_HANDLE Handle,\r
715 IN OUT CHAR16 *Buffer,\r
716 IN OUT UINTN *Size,\r
717 IN BOOLEAN Truncate,\r
718 IN OUT BOOLEAN *Ascii\r
719 );\r
720\r
721typedef struct {\r
722 LIST_ENTRY Link;\r
723 void *Buffer;\r
724} BUFFER_LIST;\r
725\r
726/**\r
727 Frees any BUFFER_LIST defined type.\r
728\r
729 @param[in] List The pointer to the list head.\r
730**/\r
731VOID\r
732EFIAPI\r
733FreeBufferList (\r
734 IN BUFFER_LIST *List\r
735 );\r
736\r
737/**\r
738 Chops off last directory or file entry in a path by changing the last '\' to a CHAR_NULL\r
739\r
740 @param[in,out] PathToReturn The pointer to the path to modify.\r
741\r
742 @retval FALSE No directory was found to chop off.\r
743 @retval TRUE A directory was chopped off.\r
744**/\r
745BOOLEAN\r
746EFIAPI\r
747ChopLastSlash(\r
748 IN OUT CHAR16 *PathToReturn\r
749 );\r
750\r
751/**\r
752 Function to clean up paths. Removes the following items:\r
753 single periods in the path (no need for the current directory tag)\r
754 double periods in the path and removes a single parent directory.\r
755\r
756 This will be done inline and the resultant string may be be 'too big'.\r
757\r
758 @param[in] PathToReturn The pointer to the string containing the path.\r
759\r
760 @return PathToReturn is always returned.\r
761**/\r
762CHAR16*\r
763EFIAPI\r
764CleanPath(\r
765 IN CHAR16 *PathToReturn\r
766 );\r
767\r
768#endif //_SHELL_COMMAND_LIB_\r