]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/RegularExpressionProtocol.h
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Include / Protocol / RegularExpressionProtocol.h
CommitLineData
6f7c885a
ED
1/** @file\r
2 This section defines the Regular Expression Protocol. This protocol isused to match\r
3 Unicode strings against Regular Expression patterns.\r
4\r
497a5fb1 5Copyright (c) 2015-2018, Intel Corporation. All rights reserved.<BR>\r
9344f092 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
6f7c885a 7\r
497a5fb1
SZ
8 @par Revision Reference:\r
9 This Protocol was introduced in UEFI Specification 2.5.\r
10\r
6f7c885a
ED
11**/\r
12\r
13#ifndef __REGULAR_EXPRESSION_PROTOCOL_H__\r
14#define __REGULAR_EXPRESSION_PROTOCOL_H__\r
15\r
16#define EFI_REGULAR_EXPRESSION_PROTOCOL_GUID \\r
17 { \\r
18 0xB3F79D9A, 0x436C, 0xDC11, {0xB0, 0x52, 0xCD, 0x85, 0xDF, 0x52, 0x4C, 0xE6 } \\r
19 }\r
20\r
21#define EFI_REGEX_SYNTAX_TYPE_POSIX_EXTENDED_GUID \\r
22 { \\r
23 0x5F05B20F, 0x4A56, 0xC231, {0xFA, 0x0B, 0xA7, 0xB1, 0xF1, 0x10, 0x04, 0x1D } \\r
24 }\r
25\r
26#define EFI_REGEX_SYNTAX_TYPE_PERL_GUID \\r
27 { \\r
28 0x63E60A51, 0x497D, 0xD427, {0xC4, 0xA5, 0xB8, 0xAB, 0xDC, 0x3A, 0xAE, 0xB6 } \\r
29 }\r
30\r
31#define EFI_REGEX_SYNTAX_TYPE_ECMA_262_GUID \\r
32 { \\r
33 0x9A473A4A, 0x4CEB, 0xB95A, {0x41, 0x5E, 0x5B, 0xA0, 0xBC, 0x63, 0x9B, 0x2E } \\r
34 }\r
35\r
36typedef struct _EFI_REGULAR_EXPRESSION_PROTOCOL EFI_REGULAR_EXPRESSION_PROTOCOL;\r
37\r
38\r
39typedef struct {\r
40 CONST CHAR16 *CapturePtr; // Pointer to the start of the captured sub-expression\r
41 // within matched String.\r
42\r
43 UINTN Length; // Length of captured sub-expression.\r
44} EFI_REGEX_CAPTURE;\r
45\r
46typedef EFI_GUID EFI_REGEX_SYNTAX_TYPE;\r
47\r
48//\r
49// Protocol member functions\r
50//\r
51/**\r
52 Returns information about the regular expression syntax types supported\r
53 by the implementation.\r
54\r
55 This A pointer to the EFI_REGULAR_EXPRESSION_PROTOCOL\r
56 instance.\r
57\r
58 RegExSyntaxTypeListSize On input, the size in bytes of RegExSyntaxTypeList.\r
59 On output with a return code of EFI_SUCCESS, the\r
60 size in bytes of the data returned in\r
61 RegExSyntaxTypeList. On output with a return code\r
62 of EFI_BUFFER_TOO_SMALL, the size of\r
63 RegExSyntaxTypeListrequired to obtain the list.\r
64\r
65 RegExSyntaxTypeList A caller-allocated memory buffer filled by the\r
66 driver with one EFI_REGEX_SYNTAX_TYPEelement\r
67 for each supported Regular expression syntax\r
68 type. The list must not change across multiple\r
69 calls to the same driver. The first syntax\r
70 type in the list is the default type for the\r
71 driver.\r
72\r
73 @retval EFI_SUCCESS The regular expression syntax types list\r
74 was returned successfully.\r
75 @retval EFI_UNSUPPORTED The service is not supported by this driver.\r
76 @retval EFI_DEVICE_ERROR The list of syntax types could not be\r
77 retrieved due to a hardware or firmware error.\r
78 @retval EFI_BUFFER_TOO_SMALL The buffer RegExSyntaxTypeList is too small\r
79 to hold the result.\r
80 @retval EFI_INVALID_PARAMETER RegExSyntaxTypeListSize is NULL\r
81\r
82**/\r
83typedef\r
84EFI_STATUS\r
85(EFIAPI *EFI_REGULAR_EXPRESSION_GET_INFO) (\r
86 IN EFI_REGULAR_EXPRESSION_PROTOCOL *This,\r
87 IN OUT UINTN *RegExSyntaxTypeListSize,\r
88 OUT EFI_REGEX_SYNTAX_TYPE *RegExSyntaxTypeList\r
89 );\r
90\r
91/**\r
92 Checks if the input string matches to the regular expression pattern.\r
93\r
94 This A pointer to the EFI_REGULAR_EXPRESSION_PROTOCOL instance.\r
95 Type EFI_REGULAR_EXPRESSION_PROTOCOL is defined in Section\r
96 XYZ.\r
97\r
98 String A pointer to a NULL terminated string to match against the\r
99 regular expression string specified by Pattern.\r
100\r
101 Pattern A pointer to a NULL terminated string that represents the\r
102 regular expression.\r
103\r
104 SyntaxType A pointer to the EFI_REGEX_SYNTAX_TYPE that identifies the\r
105 regular expression syntax type to use. May be NULL in which\r
106 case the function will use its default regular expression\r
107 syntax type.\r
108\r
109 Result On return, points to TRUE if String fully matches against\r
110 the regular expression Pattern using the regular expression\r
111 SyntaxType. Otherwise, points to FALSE.\r
112\r
113 Captures A Pointer to an array of EFI_REGEX_CAPTURE objects to receive\r
114 the captured groups in the event of a match. The full\r
115 sub-string match is put in Captures[0], and the results of N\r
116 capturing groups are put in Captures[1:N]. If Captures is\r
117 NULL, then this function doesn't allocate the memory for the\r
118 array and does not build up the elements. It only returns the\r
119 number of matching patterns in CapturesCount. If Captures is\r
120 not NULL, this function returns a pointer to an array and\r
121 builds up the elements in the array. CapturesCount is also\r
122 updated to the number of matching patterns found. It is the\r
123 caller's responsibility to free the memory pool in Captures\r
124 and in each CapturePtr in the array elements.\r
125\r
126 CapturesCount On output, CapturesCount is the number of matching patterns\r
127 found in String. Zero means no matching patterns were found\r
128 in the string.\r
129\r
130 @retval EFI_SUCCESS The regular expression string matching\r
131 completed successfully.\r
132 @retval EFI_UNSUPPORTED The regular expression syntax specified by\r
133 SyntaxTypeis not supported by this driver.\r
134 @retval EFI_DEVICE_ERROR The regular expression string matching\r
135 failed due to a hardware or firmware error.\r
136 @retval EFI_INVALID_PARAMETER String, Pattern, Result, or CapturesCountis\r
137 NULL.\r
138\r
139**/\r
140typedef\r
141EFI_STATUS\r
142(EFIAPI *EFI_REGULAR_EXPRESSION_MATCH) (\r
143 IN EFI_REGULAR_EXPRESSION_PROTOCOL *This,\r
144 IN CHAR16 *String,\r
145 IN CHAR16 *Pattern,\r
146 IN EFI_REGEX_SYNTAX_TYPE *SyntaxType, OPTIONAL\r
147 OUT BOOLEAN *Result,\r
148 OUT EFI_REGEX_CAPTURE **Captures, OPTIONAL\r
149 OUT UINTN *CapturesCount\r
150 );\r
151\r
152struct _EFI_REGULAR_EXPRESSION_PROTOCOL {\r
153 EFI_REGULAR_EXPRESSION_MATCH MatchString;\r
154 EFI_REGULAR_EXPRESSION_GET_INFO GetInfo;\r
155} ;\r
156\r
157extern EFI_GUID gEfiRegularExpressionProtocolGuid;\r
158\r
159//\r
160// For regular expression rules specified in the POSIX Extended Regular\r
161// Expression (ERE) Syntax:\r
162//\r
163extern EFI_GUID gEfiRegexSyntaxTypePosixExtendedGuid;\r
164\r
165//\r
166// For regular expression rules specifiedin the ECMA 262 Specification\r
167//\r
168extern EFI_GUID gEfiRegexSyntaxTypeEcma262Guid;\r
169\r
170//\r
171// For regular expression rules specified in the Perl standard:\r
172//\r
173extern EFI_GUID gEfiRegexSyntaxTypePerlGuid;\r
174\r
175#endif\r