]>
Commit | Line | Data |
---|---|---|
14b0e578 CS |
1 | /**\r |
2 | @file\r | |
3 | \r | |
4 | EFI_REGULAR_EXPRESSION_PROTOCOL Header File.\r | |
5 | \r | |
6 | Copyright (c) 2015, Hewlett Packard Enterprise Development, L.P.<BR>\r | |
7 | \r | |
8 | This program and the accompanying materials are licensed and made available\r | |
9 | under the terms and conditions of the BSD License that accompanies this\r | |
10 | 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, WITHOUT\r | |
14 | WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
15 | **/\r | |
16 | \r | |
17 | #include "Oniguruma/oniguruma.h"\r | |
18 | \r | |
19 | #include <Uefi.h>\r | |
20 | #include <Protocol/RegularExpressionProtocol.h>\r | |
21 | #include <Library/UefiBootServicesTableLib.h>\r | |
22 | #include <Library/BaseMemoryLib.h>\r | |
23 | #include <Library/MemoryAllocationLib.h>\r | |
24 | #include <Library/DebugLib.h>\r | |
25 | #include <Library/BaseLib.h>\r | |
26 | \r | |
27 | #define ARRAY_SIZE(Array) (sizeof(Array) / sizeof(*Array))\r | |
28 | \r | |
29 | /**\r | |
30 | Checks if the input string matches to the regular expression pattern.\r | |
31 | \r | |
32 | This A pointer to the EFI_REGULAR_EXPRESSION_PROTOCOL instance.\r | |
33 | Type EFI_REGULAR_EXPRESSION_PROTOCOL is defined in Section\r | |
34 | XYZ.\r | |
35 | \r | |
36 | String A pointer to a NULL terminated string to match against the\r | |
37 | regular expression string specified by Pattern.\r | |
38 | \r | |
39 | Pattern A pointer to a NULL terminated string that represents the\r | |
40 | regular expression.\r | |
41 | \r | |
42 | SyntaxType A pointer to the EFI_REGEX_SYNTAX_TYPE that identifies the\r | |
43 | regular expression syntax type to use. May be NULL in which\r | |
44 | case the function will use its default regular expression\r | |
45 | syntax type.\r | |
46 | \r | |
47 | Result On return, points to TRUE if String fully matches against\r | |
48 | the regular expression Pattern using the regular expression\r | |
49 | SyntaxType. Otherwise, points to FALSE.\r | |
50 | \r | |
51 | Captures A Pointer to an array of EFI_REGEX_CAPTURE objects to receive\r | |
52 | the captured groups in the event of a match. The full\r | |
53 | sub-string match is put in Captures[0], and the results of N\r | |
54 | capturing groups are put in Captures[1:N]. If Captures is\r | |
55 | NULL, then this function doesn't allocate the memory for the\r | |
56 | array and does not build up the elements. It only returns the\r | |
57 | number of matching patterns in CapturesCount. If Captures is\r | |
58 | not NULL, this function returns a pointer to an array and\r | |
59 | builds up the elements in the array. CapturesCount is also\r | |
60 | updated to the number of matching patterns found. It is the\r | |
61 | caller's responsibility to free the memory pool in Captures\r | |
62 | and in each CapturePtr in the array elements.\r | |
63 | \r | |
64 | CapturesCount On output, CapturesCount is the number of matching patterns\r | |
65 | found in String. Zero means no matching patterns were found\r | |
66 | in the string.\r | |
67 | \r | |
68 | @retval EFI_SUCCESS The regular expression string matching\r | |
69 | completed successfully.\r | |
70 | @retval EFI_UNSUPPORTED The regular expression syntax specified by\r | |
71 | SyntaxType is not supported by this driver.\r | |
72 | @retval EFI_DEVICE_ERROR The regular expression string matching\r | |
73 | failed due to a hardware or firmware error.\r | |
74 | @retval EFI_INVALID_PARAMETER String, Pattern, Result, or CapturesCountis\r | |
75 | NULL.\r | |
76 | \r | |
77 | **/\r | |
78 | EFI_STATUS\r | |
79 | EFIAPI\r | |
80 | RegularExpressionMatch (\r | |
81 | IN EFI_REGULAR_EXPRESSION_PROTOCOL *This,\r | |
82 | IN CHAR16 *String,\r | |
83 | IN CHAR16 *Pattern,\r | |
84 | IN EFI_REGEX_SYNTAX_TYPE *SyntaxType, OPTIONAL\r | |
85 | OUT BOOLEAN *Result,\r | |
86 | OUT EFI_REGEX_CAPTURE **Captures, OPTIONAL\r | |
87 | OUT UINTN *CapturesCount\r | |
88 | );\r | |
89 | \r | |
90 | /**\r | |
91 | Returns information about the regular expression syntax types supported\r | |
92 | by the implementation.\r | |
93 | \r | |
94 | This A pointer to the EFI_REGULAR_EXPRESSION_PROTOCOL\r | |
95 | instance.\r | |
96 | \r | |
97 | RegExSyntaxTypeListSize On input, the size in bytes of RegExSyntaxTypeList.\r | |
98 | On output with a return code of EFI_SUCCESS, the\r | |
99 | size in bytes of the data returned in\r | |
100 | RegExSyntaxTypeList. On output with a return code\r | |
101 | of EFI_BUFFER_TOO_SMALL, the size of\r | |
102 | RegExSyntaxTypeList required to obtain the list.\r | |
103 | \r | |
104 | RegExSyntaxTypeList A caller-allocated memory buffer filled by the\r | |
105 | driver with one EFI_REGEX_SYNTAX_TYPE element\r | |
106 | for each supported Regular expression syntax\r | |
107 | type. The list must not change across multiple\r | |
108 | calls to the same driver. The first syntax\r | |
109 | type in the list is the default type for the\r | |
110 | driver.\r | |
111 | \r | |
112 | @retval EFI_SUCCESS The regular expression syntax types list\r | |
113 | was returned successfully.\r | |
114 | @retval EFI_UNSUPPORTED The service is not supported by this driver.\r | |
115 | @retval EFI_DEVICE_ERROR The list of syntax types could not be\r | |
116 | retrieved due to a hardware or firmware error.\r | |
117 | @retval EFI_BUFFER_TOO_SMALL The buffer RegExSyntaxTypeList is too small\r | |
118 | to hold the result.\r | |
119 | @retval EFI_INVALID_PARAMETER RegExSyntaxTypeListSize is NULL\r | |
120 | \r | |
121 | **/\r | |
122 | EFI_STATUS\r | |
123 | EFIAPI\r | |
124 | RegularExpressionGetInfo (\r | |
125 | IN EFI_REGULAR_EXPRESSION_PROTOCOL *This,\r | |
126 | IN OUT UINTN *RegExSyntaxTypeListSize,\r | |
127 | OUT EFI_REGEX_SYNTAX_TYPE *RegExSyntaxTypeList\r | |
128 | );\r | |
129 | \r | |
130 | \r |