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
19 #include <common/macros.h>
20 #include <common/compat/errno.h>
22 #include "filter-ast.h"
23 #include "filter-parser.h"
24 #include "filter-ir.h"
26 enum parse_char_result
{
27 PARSE_CHAR_UNKNOWN
= -2,
28 PARSE_CHAR_WILDCARD
= -1,
29 PARSE_CHAR_NORMAL
= 0,
33 enum parse_char_result
parse_char(const char **p
)
41 return PARSE_CHAR_NORMAL
;
43 return PARSE_CHAR_UNKNOWN
;
46 return PARSE_CHAR_WILDCARD
;
48 return PARSE_CHAR_NORMAL
;
53 int validate_string(struct ir_op
*node
)
58 fprintf(stderr
, "[error] %s: unknown op type\n", __func__
);
62 return validate_string(node
->u
.root
.child
);
67 if (node
->data_type
== IR_DATA_STRING
) {
70 assert(node
->u
.load
.u
.string
.value
);
71 str
= node
->u
.load
.u
.string
.value
;
74 enum parse_char_result res
;
80 res
= parse_char(&str
);
84 case PARSE_CHAR_UNKNOWN
:
87 "Unsupported escape character detected.\n");
89 case PARSE_CHAR_NORMAL
:
99 return validate_string(node
->u
.unary
.child
);
102 int ret
= validate_string(node
->u
.binary
.left
);
106 return validate_string(node
->u
.binary
.right
);
112 ret
= validate_string(node
->u
.logical
.left
);
115 return validate_string(node
->u
.logical
.right
);
121 int filter_visitor_ir_validate_string(struct filter_parser_ctx
*ctx
)
123 return validate_string(ctx
->ir_root
);
This page took 0.031388 seconds and 4 git commands to generate.