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