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 * SPDX-License-Identifier: LGPL-2.1-only
12 #include "filter-ast.hpp"
13 #include "filter-ir.hpp"
14 #include "filter-parser.hpp"
16 #include <common/compat/errno.hpp>
17 #include <common/macros.hpp>
25 enum parse_char_result
{
26 PARSE_CHAR_UNKNOWN
= -2,
27 PARSE_CHAR_WILDCARD
= -1,
28 PARSE_CHAR_NORMAL
= 0,
31 static enum parse_char_result
parse_char(const char **p
)
39 return PARSE_CHAR_NORMAL
;
41 return PARSE_CHAR_UNKNOWN
;
44 return PARSE_CHAR_WILDCARD
;
46 return PARSE_CHAR_NORMAL
;
50 static int validate_string(struct ir_op
*node
)
55 fprintf(stderr
, "[error] %s: unknown op type\n", __func__
);
59 return validate_string(node
->u
.root
.child
);
64 if (node
->data_type
== IR_DATA_STRING
) {
67 LTTNG_ASSERT(node
->u
.load
.u
.string
.value
);
68 str
= node
->u
.load
.u
.string
.value
;
71 enum parse_char_result res
;
77 res
= parse_char(&str
);
81 case PARSE_CHAR_UNKNOWN
:
83 fprintf(stderr
, "Unsupported escape character detected.\n");
85 case PARSE_CHAR_NORMAL
:
95 return validate_string(node
->u
.unary
.child
);
98 int ret
= validate_string(node
->u
.binary
.left
);
102 return validate_string(node
->u
.binary
.right
);
108 ret
= validate_string(node
->u
.logical
.left
);
111 return validate_string(node
->u
.logical
.right
);
116 int filter_visitor_ir_validate_string(struct filter_parser_ctx
*ctx
)
118 return validate_string(ctx
->ir_root
);
This page took 0.030758 seconds and 4 git commands to generate.