TianoCore EDK2 master
Loading...
Searching...
No Matches
ShellParametersProtocol.h File Reference
#include "Shell.h"

Go to the source code of this file.

Data Structures

struct  SYSTEM_TABLE_INFO
 

Enumerations

enum  SHELL_OPERATION_TYPES {
  Internal_Command , Script_File_Name , Efi_Application , File_Sys_Change ,
  Unknown_Invalid
}
 

Functions

EFI_STATUS CreatePopulateInstallShellParametersProtocol (IN OUT EFI_SHELL_PARAMETERS_PROTOCOL **NewShellParameters, IN OUT BOOLEAN *RootShellInstance)
 
EFI_STATUS CleanUpShellParametersProtocol (IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *NewShellParameters)
 
EFI_STATUS UpdateArgcArgv (IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters, IN CONST CHAR16 *NewCommandLine, IN SHELL_OPERATION_TYPES Type, OUT CHAR16 ***OldArgv, OUT UINTN *OldArgc)
 
VOID RestoreArgcArgv (IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters, IN CHAR16 ***OldArgv, IN UINTN *OldArgc)
 
EFI_STATUS UpdateStdInStdOutStdErr (IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters, IN CHAR16 *NewCommandLine, OUT SHELL_FILE_HANDLE *OldStdIn, OUT SHELL_FILE_HANDLE *OldStdOut, OUT SHELL_FILE_HANDLE *OldStdErr, OUT SYSTEM_TABLE_INFO *SystemTableInfo)
 
EFI_STATUS RestoreStdInStdOutStdErr (IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters, IN SHELL_FILE_HANDLE *OldStdIn, IN SHELL_FILE_HANDLE *OldStdOut, IN SHELL_FILE_HANDLE *OldStdErr, IN SYSTEM_TABLE_INFO *SystemTableInfo)
 
EFI_STATUS ParseCommandLineToArgs (IN CONST CHAR16 *CommandLine, IN BOOLEAN StripQuotation, IN OUT CHAR16 ***Argv, IN OUT UINTN *Argc)
 
EFI_STATUS GetNextParameter (IN OUT CHAR16 **Walker, IN OUT CHAR16 **TempParameter, IN CONST UINTN Length, IN BOOLEAN StripQuotation)
 

Detailed Description

Member functions of EFI_SHELL_PARAMETERS_PROTOCOL and functions for creation, manipulation, and initialization of EFI_SHELL_PARAMETERS_PROTOCOL.

Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file ShellParametersProtocol.h.

Enumeration Type Documentation

◆ SHELL_OPERATION_TYPES

enum SHELL_OPERATION_TYPES

Definition at line 15 of file ShellParametersProtocol.h.

Function Documentation

◆ CleanUpShellParametersProtocol()

EFI_STATUS CleanUpShellParametersProtocol ( IN OUT EFI_SHELL_PARAMETERS_PROTOCOL NewShellParameters)

frees all memory used by creation and installation of shell parameters protocol and if there was an old version installed it will restore that one.

Parameters
NewShellParametersthe interface of EFI_SHELL_PARAMETERS_PROTOCOL that is being cleaned up.
Return values
EFI_SUCCESSthe cleanup was successful
Returns
other the cleanup failed
See also
ReinstallProtocolInterface
UninstallProtocolInterface

Definition at line 447 of file ShellParametersProtocol.c.

◆ CreatePopulateInstallShellParametersProtocol()

EFI_STATUS CreatePopulateInstallShellParametersProtocol ( IN OUT EFI_SHELL_PARAMETERS_PROTOCOL **  NewShellParameters,
IN OUT BOOLEAN *  RootShellInstance 
)

creates a new EFI_SHELL_PARAMETERS_PROTOCOL instance and populates it and then installs it on our handle and if there is an existing version of the protocol that one is cached for removal later.

Parameters
[in,out]NewShellParameterson a successful return, a pointer to pointer to the newly installed interface.
[in,out]RootShellInstanceon a successful return, pointer to boolean. TRUE if this is the root shell instance.
Return values
EFI_SUCCESSthe operation completed successfully.
Returns
other the operation failed.
See also
ReinstallProtocolInterface
InstallProtocolInterface
ParseCommandLineToArgs

Definition at line 293 of file ShellParametersProtocol.c.

◆ GetNextParameter()

EFI_STATUS GetNextParameter ( IN OUT CHAR16 **  Walker,
IN OUT CHAR16 **  TempParameter,
IN CONST UINTN  Length,
IN BOOLEAN  StripQuotation 
)

return the next parameter from a command line string;

This function moves the next parameter from Walker into TempParameter and moves Walker up past that parameter for recursive calling. When the final parameter is moved *Walker will be set to NULL;

Temp Parameter must be large enough to hold the parameter before calling this function.

Parameters
[in,out]Walkerpointer to string of command line. Adjusted to remaining command line on return
[in,out]TempParameterpointer to string of command line item extracted.
[in]LengthLength of (*TempParameter) in bytes
[in]StripQuotationif TRUE then strip the quotation marks surrounding the parameters.
Returns
EFI_INVALID_PARAMETER A required parameter was NULL or pointed to a NULL or empty string.
EFI_NOT_FOUND A closing " could not be found on the specified string Return the next parameter from a command line string. This function moves the next parameter from Walker into TempParameter and moves Walker up past that parameter for recursive calling. When the final parameter is moved *Walker will be set to NULL; Temp Parameter must be large enough to hold the parameter before calling this function. This will also remove all remaining ^ characters after processing. @param [in, out] Walker pointer to string of command line. Adjusted to remaining command line on return @param [in, out] TempParameter pointer to string of command line item extracted. @param [in] Length buffer size of TempParameter. @param [in] StripQuotation if TRUE then strip the quotation marks surrounding the parameters. @return EFI_INVALID_PARAMETER A required parameter was NULL or pointed to a NULL or empty string. @return EFI_NOT_FOUND A closing " could not be found on the specified string

Definition at line 82 of file ShellParametersProtocol.c.

◆ ParseCommandLineToArgs()

EFI_STATUS ParseCommandLineToArgs ( IN CONST CHAR16 *  CommandLine,
IN BOOLEAN  StripQuotation,
IN OUT CHAR16 ***  Argv,
IN OUT UINTN Argc 
)

function to populate Argc and Argv.

This function parses the CommandLine and divides it into standard C style Argc/Argv parameters for inclusion in EFI_SHELL_PARAMETERS_PROTOCOL. this supports space delimited and quote surrounded parameter definition.

Parameters
[in]CommandLineString of command line to parse
[in]StripQuotationif TRUE then strip the quotation marks surrounding the parameters.
[in,out]Argvpointer to array of strings; one for each parameter
[in,out]Argcpointer to number of strings in Argv array
Returns
EFI_SUCCESS the operation was successful
EFI_INVALID_PARAMETER some parameters are invalid
EFI_OUT_OF_RESOURCES a memory allocation failed.

Function to populate Argc and Argv.

This function parses the CommandLine and divides it into standard C style Argc/Argv parameters for inclusion in EFI_SHELL_PARAMETERS_PROTOCOL. this supports space delimited and quote surrounded parameter definition.

All special character processing (alias, environment variable, redirection, etc... must be complete before calling this API.

Parameters
[in]CommandLineString of command line to parse
[in]StripQuotationif TRUE then strip the quotation marks surrounding the parameters.
[in,out]Argvpointer to array of strings; one for each parameter
[in,out]Argcpointer to number of strings in Argv array
Returns
EFI_SUCCESS the operation was successful
EFI_INVALID_PARAMETER some parameters are invalid
EFI_OUT_OF_RESOURCES a memory allocation failed.

Definition at line 191 of file ShellParametersProtocol.c.

◆ RestoreArgcArgv()

VOID RestoreArgcArgv ( IN OUT EFI_SHELL_PARAMETERS_PROTOCOL ShellParameters,
IN CHAR16 ***  OldArgv,
IN UINTN OldArgc 
)

Function will replace the current Argc and Argv in the ShellParameters protocol structure with Argv and Argc. The current values are de-allocated and the OldArgv must not be deallocated by the caller.

Parameters
[in,out]ShellParameterspointer to parameter structure to modify
[in]OldArgvpointer to old list of parameters
[in]OldArgcpointer to old number of items in Argv list

Definition at line 1499 of file ShellParametersProtocol.c.

◆ RestoreStdInStdOutStdErr()

EFI_STATUS RestoreStdInStdOutStdErr ( IN OUT EFI_SHELL_PARAMETERS_PROTOCOL ShellParameters,
IN SHELL_FILE_HANDLE *  OldStdIn,
IN SHELL_FILE_HANDLE *  OldStdOut,
IN SHELL_FILE_HANDLE *  OldStdErr,
IN SYSTEM_TABLE_INFO SystemTableInfo 
)

Function will replace the current StdIn and StdOut in the ShellParameters protocol structure with StdIn and StdOut. The current values are de-allocated.

Parameters
[in,out]ShellParametersPointer to parameter structure to modify.
[in]OldStdInPointer to old StdIn.
[in]OldStdOutPointer to old StdOut.
[in]OldStdErrPointer to old StdErr.
[in]SystemTableInfoPointer to old system table information.

Definition at line 1368 of file ShellParametersProtocol.c.

◆ UpdateArgcArgv()

EFI_STATUS UpdateArgcArgv ( IN OUT EFI_SHELL_PARAMETERS_PROTOCOL ShellParameters,
IN CONST CHAR16 *  NewCommandLine,
IN SHELL_OPERATION_TYPES  Type,
OUT CHAR16 ***  OldArgv,
OUT UINTN OldArgc 
)

Function will replace the current Argc and Argv in the ShellParameters protocol structure by parsing NewCommandLine. The current values are returned to the user.

Parameters
[in,out]ShellParameterspointer to parameter structure to modify
[in]NewCommandLinethe new command line to parse and use
[in]Typethe type of operation.
[out]OldArgvpointer to old list of parameters
[out]OldArgcpointer to old number of items in Argv list
Return values
EFI_SUCCESSoperation was successful, Argv and Argc are valid
Returns
EFI_INVALID_PARAMETER some parameters are invalid
Return values
EFI_OUT_OF_RESOURCESa memory allocation failed.

◆ UpdateStdInStdOutStdErr()

EFI_STATUS UpdateStdInStdOutStdErr ( IN OUT EFI_SHELL_PARAMETERS_PROTOCOL ShellParameters,
IN CHAR16 *  NewCommandLine,
OUT SHELL_FILE_HANDLE *  OldStdIn,
OUT SHELL_FILE_HANDLE *  OldStdOut,
OUT SHELL_FILE_HANDLE *  OldStdErr,
OUT SYSTEM_TABLE_INFO SystemTableInfo 
)

Function will replace the current StdIn and StdOut in the ShellParameters protocol structure by parsing NewCommandLine. The current values are returned to the user.

This will also update the system table.

Parameters
[in,out]ShellParametersPointer to parameter structure to modify.
[in]NewCommandLineThe new command line to parse and use.
[out]OldStdInPointer to old StdIn.
[out]OldStdOutPointer to old StdOut.
[out]OldStdErrPointer to old StdErr.
[out]SystemTableInfoPointer to old system table information.
Return values
EFI_SUCCESSOperation was successful, Argv and Argc are valid.
EFI_OUT_OF_RESOURCESA memory allocation failed.

Definition at line 701 of file ShellParametersProtocol.c.