2 * filter-visitor-ir-normalize-glob-patterns.c
4 * LTTng filter IR normalize string
6 * Copyright 2017 - Philippe Proulx <pproulx@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>
31 #include <common/string-utils/string-utils.h>
33 #include "filter-ast.h"
34 #include "filter-parser.h"
35 #include "filter-ir.h"
38 int normalize_glob_patterns(struct ir_op
*node
)
43 fprintf(stderr
, "[error] %s: unknown op type\n", __func__
);
47 return normalize_glob_patterns(node
->u
.root
.child
);
50 if (node
->data_type
== IR_DATA_STRING
) {
51 enum ir_load_string_type type
=
52 node
->u
.load
.u
.string
.type
;
53 if (type
== IR_LOAD_STRING_TYPE_GLOB_STAR_END
||
54 type
== IR_LOAD_STRING_TYPE_GLOB_STAR
) {
55 assert(node
->u
.load
.u
.string
.value
);
56 strutils_normalize_star_glob_pattern(
57 node
->u
.load
.u
.string
.value
);
64 return normalize_glob_patterns(node
->u
.unary
.child
);
67 int ret
= normalize_glob_patterns(node
->u
.binary
.left
);
71 return normalize_glob_patterns(node
->u
.binary
.right
);
77 ret
= normalize_glob_patterns(node
->u
.logical
.left
);
80 return normalize_glob_patterns(node
->u
.logical
.right
);
86 * This function normalizes all the globbing literal strings with
87 * utils_normalize_glob_pattern(). See the documentation of
88 * utils_normalize_glob_pattern() for more details.
91 int filter_visitor_ir_normalize_glob_patterns(struct filter_parser_ctx
*ctx
)
93 return normalize_glob_patterns(ctx
->ir_root
);