2 * filter-visitor-ir-validate-string.c
4 * LTTng filter IR validate string
6 * Copyright 2014 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 * This library is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License, version 2.1 only,
10 * as published by the Free Software Foundation.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
29 #include "filter-ast.h"
30 #include "filter-parser.h"
31 #include "filter-ir.h"
33 enum parse_char_result
{
34 PARSE_CHAR_UNKNOWN
= -2,
35 PARSE_CHAR_WILDCARD
= -1,
36 PARSE_CHAR_NORMAL
= 0,
40 enum parse_char_result
parse_char(const char **p
)
48 return PARSE_CHAR_NORMAL
;
50 return PARSE_CHAR_UNKNOWN
;
53 return PARSE_CHAR_WILDCARD
;
55 return PARSE_CHAR_NORMAL
;
60 int validate_string(struct ir_op
*node
)
65 fprintf(stderr
, "[error] %s: unknown op type\n", __func__
);
69 return validate_string(node
->u
.root
.child
);
74 if (node
->data_type
== IR_DATA_STRING
) {
77 assert(node
->u
.load
.u
.string
);
78 str
= node
->u
.load
.u
.string
;
81 * Make sure that if a non-escaped wildcard is
82 * present, it is the last character of the string.
85 enum parse_char_result res
;
91 res
= parse_char(&str
);
95 case PARSE_CHAR_WILDCARD
:
99 * Found a wildcard followed by non-null
100 * character; unsupported.
104 "Wildcards may only be used as the last character of a string in a filter.\n");
109 case PARSE_CHAR_UNKNOWN
:
112 "Unsupported escape character detected.\n");
114 case PARSE_CHAR_NORMAL
:
124 return validate_string(node
->u
.unary
.child
);
127 int ret
= validate_string(node
->u
.binary
.left
);
131 return validate_string(node
->u
.binary
.right
);
137 ret
= validate_string(node
->u
.logical
.left
);
140 return validate_string(node
->u
.logical
.right
);
145 int filter_visitor_ir_validate_string(struct filter_parser_ctx
*ctx
)
147 return validate_string(ctx
->ir_root
);
This page took 0.033805 seconds and 5 git commands to generate.