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
30 #include <common/macros.h>
32 #include "filter-ast.h"
33 #include "filter-parser.h"
34 #include "filter-ir.h"
36 enum parse_char_result
{
37 PARSE_CHAR_UNKNOWN
= -2,
38 PARSE_CHAR_WILDCARD
= -1,
39 PARSE_CHAR_NORMAL
= 0,
43 enum parse_char_result
parse_char(const char **p
)
51 return PARSE_CHAR_NORMAL
;
53 return PARSE_CHAR_UNKNOWN
;
56 return PARSE_CHAR_WILDCARD
;
58 return PARSE_CHAR_NORMAL
;
63 int validate_string(struct ir_op
*node
)
68 fprintf(stderr
, "[error] %s: unknown op type\n", __func__
);
72 return validate_string(node
->u
.root
.child
);
77 if (node
->data_type
== IR_DATA_STRING
) {
80 assert(node
->u
.load
.u
.string
.value
);
81 str
= node
->u
.load
.u
.string
.value
;
84 enum parse_char_result res
;
90 res
= parse_char(&str
);
94 case PARSE_CHAR_UNKNOWN
:
97 "Unsupported escape character detected.\n");
99 case PARSE_CHAR_NORMAL
:
109 return validate_string(node
->u
.unary
.child
);
112 int ret
= validate_string(node
->u
.binary
.left
);
116 return validate_string(node
->u
.binary
.right
);
122 ret
= validate_string(node
->u
.logical
.left
);
125 return validate_string(node
->u
.logical
.right
);
131 int filter_visitor_ir_validate_string(struct filter_parser_ctx
*ctx
)
133 return validate_string(ctx
->ir_root
);
This page took 0.034547 seconds and 4 git commands to generate.