TianoCore EDK2 master
Loading...
Searching...
No Matches
RegularExpressionDxe.c File Reference

Go to the source code of this file.

Macros

#define CHAR16_ENCODING   ONIG_ENCODING_UTF16_LE
 

Functions

STATIC EFI_STATUS OnigurumaMatch (IN CHAR16 *String, IN CHAR16 *Pattern, IN EFI_REGEX_SYNTAX_TYPE *SyntaxType, OUT BOOLEAN *Result, OUT EFI_REGEX_CAPTURE **Captures OPTIONAL, OUT UINTN *CapturesCount)
 
EFI_STATUS EFIAPI RegularExpressionGetInfo (IN EFI_REGULAR_EXPRESSION_PROTOCOL *This, IN OUT UINTN *RegExSyntaxTypeListSize, OUT EFI_REGEX_SYNTAX_TYPE *RegExSyntaxTypeList)
 
EFI_STATUS EFIAPI RegularExpressionMatch (IN EFI_REGULAR_EXPRESSION_PROTOCOL *This, IN CHAR16 *String, IN CHAR16 *Pattern, IN EFI_REGEX_SYNTAX_TYPE *SyntaxType OPTIONAL, OUT BOOLEAN *Result, OUT EFI_REGEX_CAPTURE **Captures OPTIONAL, OUT UINTN *CapturesCount)
 
EFI_STATUS EFIAPI RegularExpressionDxeEntry (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

STATIC EFI_REGEX_SYNTAX_TYPE *CONST mSupportedSyntaxes []
 
STATIC EFI_REGULAR_EXPRESSION_PROTOCOL mProtocolInstance
 

Detailed Description

EFI_REGULAR_EXPRESSION_PROTOCOL Implementation

(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file RegularExpressionDxe.c.

Macro Definition Documentation

◆ CHAR16_ENCODING

#define CHAR16_ENCODING   ONIG_ENCODING_UTF16_LE

Definition at line 25 of file RegularExpressionDxe.c.

Function Documentation

◆ OnigurumaMatch()

STATIC EFI_STATUS OnigurumaMatch ( IN CHAR16 *  String,
IN CHAR16 *  Pattern,
IN EFI_REGEX_SYNTAX_TYPE SyntaxType,
OUT BOOLEAN *  Result,
OUT EFI_REGEX_CAPTURE **Captures  OPTIONAL,
OUT UINTN CapturesCount 
)

Call the Oniguruma regex match API.

Same parameters as RegularExpressionMatch, except SyntaxType is required.

Parameters
StringA pointer to a NULL terminated string to match against the regular expression string specified by Pattern.
PatternA pointer to a NULL terminated string that represents the regular expression.
SyntaxTypeA pointer to the EFI_REGEX_SYNTAX_TYPE that identifies the regular expression syntax type to use. May be NULL in which case the function will use its default regular expression syntax type.
ResultOn return, points to TRUE if String fully matches against the regular expression Pattern using the regular expression SyntaxType. Otherwise, points to FALSE.
CapturesA Pointer to an array of EFI_REGEX_CAPTURE objects to receive the captured groups in the event of a match. The full sub-string match is put in Captures[0], and the results of N capturing groups are put in Captures[1:N]. If Captures is NULL, then this function doesn't allocate the memory for the array and does not build up the elements. It only returns the number of matching patterns in CapturesCount. If Captures is not NULL, this function returns a pointer to an array and builds up the elements in the array. CapturesCount is also updated to the number of matching patterns found. It is the caller's responsibility to free the memory pool in Captures and in each CapturePtr in the array elements.
CapturesCountOn output, CapturesCount is the number of matching patterns found in String. Zero means no matching patterns were found in the string.
Return values
EFI_SUCCESSRegex compilation and match completed successfully.
EFI_DEVICE_ERRORRegex compilation failed.

Definition at line 69 of file RegularExpressionDxe.c.

◆ RegularExpressionDxeEntry()

EFI_STATUS EFIAPI RegularExpressionDxeEntry ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Entry point for RegularExpressionDxe.

Parameters
ImageHandleImage handle this driver.
SystemTablePointer to SystemTable.
Return values
StatusWhether this function complete successfully.

Definition at line 367 of file RegularExpressionDxe.c.

◆ RegularExpressionGetInfo()

EFI_STATUS EFIAPI RegularExpressionGetInfo ( IN EFI_REGULAR_EXPRESSION_PROTOCOL This,
IN OUT UINTN RegExSyntaxTypeListSize,
OUT EFI_REGEX_SYNTAX_TYPE RegExSyntaxTypeList 
)

Returns information about the regular expression syntax types supported by the implementation.

Parameters
ThisA pointer to the EFI_REGULAR_EXPRESSION_PROTOCOL instance.
RegExSyntaxTypeListSizeOn input, the size in bytes of RegExSyntaxTypeList. On output with a return code of EFI_SUCCESS, the size in bytes of the data returned in RegExSyntaxTypeList. On output with a return code of EFI_BUFFER_TOO_SMALL, the size of RegExSyntaxTypeList required to obtain the list.
RegExSyntaxTypeListA caller-allocated memory buffer filled by the driver with one EFI_REGEX_SYNTAX_TYPE element for each supported Regular expression syntax type. The list must not change across multiple calls to the same driver. The first syntax type in the list is the default type for the driver.
Return values
EFI_SUCCESSThe regular expression syntax types list was returned successfully.
EFI_UNSUPPORTEDThe service is not supported by this driver.
EFI_DEVICE_ERRORThe list of syntax types could not be retrieved due to a hardware or firmware error.
EFI_BUFFER_TOO_SMALLThe buffer RegExSyntaxTypeList is too small to hold the result.
EFI_INVALID_PARAMETERRegExSyntaxTypeListSize is NULL

Definition at line 230 of file RegularExpressionDxe.c.

◆ RegularExpressionMatch()

EFI_STATUS EFIAPI RegularExpressionMatch ( IN EFI_REGULAR_EXPRESSION_PROTOCOL This,
IN CHAR16 *  String,
IN CHAR16 *  Pattern,
IN EFI_REGEX_SYNTAX_TYPE *SyntaxType  OPTIONAL,
OUT BOOLEAN *  Result,
OUT EFI_REGEX_CAPTURE **Captures  OPTIONAL,
OUT UINTN CapturesCount 
)

Checks if the input string matches to the regular expression pattern.

Parameters
ThisA pointer to the EFI_REGULAR_EXPRESSION_PROTOCOL instance. Type EFI_REGULAR_EXPRESSION_PROTOCOL is defined in Section XYZ.
StringA pointer to a NULL terminated string to match against the regular expression string specified by Pattern.
PatternA pointer to a NULL terminated string that represents the regular expression.
SyntaxTypeA pointer to the EFI_REGEX_SYNTAX_TYPE that identifies the regular expression syntax type to use. May be NULL in which case the function will use its default regular expression syntax type.
ResultOn return, points to TRUE if String fully matches against the regular expression Pattern using the regular expression SyntaxType. Otherwise, points to FALSE.
CapturesA Pointer to an array of EFI_REGEX_CAPTURE objects to receive the captured groups in the event of a match. The full sub-string match is put in Captures[0], and the results of N capturing groups are put in Captures[1:N]. If Captures is NULL, then this function doesn't allocate the memory for the array and does not build up the elements. It only returns the number of matching patterns in CapturesCount. If Captures is not NULL, this function returns a pointer to an array and builds up the elements in the array. CapturesCount is also updated to the number of matching patterns found. It is the caller's responsibility to free the memory pool in Captures and in each CapturePtr in the array elements.
CapturesCountOn output, CapturesCount is the number of matching patterns found in String. Zero means no matching patterns were found in the string.
Return values
EFI_SUCCESSThe regular expression string matching completed successfully.
EFI_UNSUPPORTEDThe regular expression syntax specified by SyntaxType is not supported by this driver.
EFI_DEVICE_ERRORThe regular expression string matching failed due to a hardware or firmware error.
EFI_INVALID_PARAMETERString, Pattern, Result, or CapturesCountis NULL.

Definition at line 314 of file RegularExpressionDxe.c.

Variable Documentation

◆ mProtocolInstance

Initial value:
= {
}
EFI_STATUS EFIAPI RegularExpressionGetInfo(IN EFI_REGULAR_EXPRESSION_PROTOCOL *This, IN OUT UINTN *RegExSyntaxTypeListSize, OUT EFI_REGEX_SYNTAX_TYPE *RegExSyntaxTypeList)
EFI_STATUS EFIAPI RegularExpressionMatch(IN EFI_REGULAR_EXPRESSION_PROTOCOL *This, IN CHAR16 *String, IN CHAR16 *Pattern, IN EFI_REGEX_SYNTAX_TYPE *SyntaxType OPTIONAL, OUT BOOLEAN *Result, OUT EFI_REGEX_CAPTURE **Captures OPTIONAL, OUT UINTN *CapturesCount)

Definition at line 20 of file RegularExpressionDxe.c.

◆ mSupportedSyntaxes

STATIC EFI_REGEX_SYNTAX_TYPE* CONST mSupportedSyntaxes[]
Initial value:
= {
&gEfiRegexSyntaxTypePosixExtendedGuid,
&gEfiRegexSyntaxTypePerlGuid
}

Definition at line 14 of file RegularExpressionDxe.c.