X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2Flttng-ctl%2Ffilter-visitor-xml.c;fp=src%2Flib%2Flttng-ctl%2Ffilter-visitor-xml.c;h=0000000000000000000000000000000000000000;hb=d00c599e39ae45ec7c8e12e6bac6b5e58f08f817;hp=b3a1ac9597ca7c1904b58328bc874accf6f7a490;hpb=32dd26fbc3c69fe677a7917535e10ace066e674c;p=lttng-tools.git diff --git a/src/lib/lttng-ctl/filter-visitor-xml.c b/src/lib/lttng-ctl/filter-visitor-xml.c deleted file mode 100644 index b3a1ac959..000000000 --- a/src/lib/lttng-ctl/filter-visitor-xml.c +++ /dev/null @@ -1,253 +0,0 @@ -/* - * filter-visitor-xml.c - * - * LTTng filter XML pretty printer visitor - * - * Copyright 2012 - Mathieu Desnoyers - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License, version 2.1 only, - * as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include -#include -#include -#include -#include "filter-ast.h" -#include "filter-parser.h" - -#define fprintf_dbg(fd, fmt, args...) fprintf(fd, "%s: " fmt, __func__, ## args) - -static -int recursive_visit_print(struct filter_node *node, FILE *stream, int indent); - -static -void print_tabs(FILE *fd, int depth) -{ - int i; - - for (i = 0; i < depth; i++) - fprintf(fd, "\t"); -} - -static -int recursive_visit_print_expression(struct filter_node *node, - FILE *stream, int indent) -{ - if (!node) { - fprintf(stderr, "[error] %s: NULL child\n", __func__); - return -EINVAL; - } - switch (node->u.expression.type) { - case AST_EXP_UNKNOWN: - default: - fprintf(stderr, "[error] %s: unknown expression\n", __func__); - return -EINVAL; - case AST_EXP_STRING: - print_tabs(stream, indent); - fprintf(stream, "\n", - node->u.expression.u.string); - break; - case AST_EXP_CONSTANT: - print_tabs(stream, indent); - fprintf(stream, "\n", - node->u.expression.u.constant); - break; - case AST_EXP_FLOAT_CONSTANT: - print_tabs(stream, indent); - fprintf(stream, "\n", - node->u.expression.u.float_constant); - break; - case AST_EXP_IDENTIFIER: - print_tabs(stream, indent); - fprintf(stream, "\n", - node->u.expression.u.identifier); - while (node->u.expression.next) { - print_tabs(stream, indent); - fprintf(stream, "u.expression.pre_op) { - case AST_LINK_UNKNOWN: - default: - fprintf(stderr, "[error] %s: unknown link\n", __func__); - return -EINVAL; - case AST_LINK_DOT: - fprintf(stream, "."); - break; - case AST_LINK_RARROW: - fprintf(stream, "->"); - break; - } - fprintf(stream, "\"/>\n"); - - node = node->u.expression.next; - if (node->type != NODE_EXPRESSION || - node->u.expression.type != AST_EXP_IDENTIFIER) { - fprintf(stderr, "[error] %s: expecting identifier before link\n", __func__); - return -EINVAL; - } - - print_tabs(stream, indent); - fprintf(stream, "\n", - node->u.expression.u.identifier); - } - break; - case AST_EXP_NESTED: - return recursive_visit_print(node->u.expression.u.child, - stream, indent + 1); - } - return 0; -} - - -static -int recursive_visit_print(struct filter_node *node, FILE *stream, int indent) -{ - int ret; - - if (!node) { - fprintf(stderr, "[error] %s: NULL child\n", __func__); - return -EINVAL; - } - switch (node->type) { - case NODE_UNKNOWN: - default: - fprintf(stderr, "[error] %s: unknown node type\n", __func__); - return -EINVAL; - case NODE_ROOT: - print_tabs(stream, indent); - fprintf(stream, "\n"); - ret = recursive_visit_print(node->u.root.child, stream, - indent + 1); - print_tabs(stream, indent); - fprintf(stream, "\n"); - return ret; - case NODE_EXPRESSION: - print_tabs(stream, indent); - fprintf(stream, "\n"); - ret = recursive_visit_print_expression(node, stream, - indent + 1); - print_tabs(stream, indent); - fprintf(stream, "\n"); - return ret; - case NODE_OP: - print_tabs(stream, indent); - fprintf(stream, ">\""); - break; - case AST_OP_LSHIFT: - fprintf(stream, "\"<<\""); - break; - case AST_OP_AND: - fprintf(stream, "\"&&\""); - break; - case AST_OP_OR: - fprintf(stream, "\"||\""); - break; - case AST_OP_BIN_AND: - fprintf(stream, "\"&\""); - break; - case AST_OP_BIN_OR: - fprintf(stream, "\"|\""); - break; - case AST_OP_BIN_XOR: - fprintf(stream, "\"^\""); - break; - - case AST_OP_EQ: - fprintf(stream, "\"==\""); - break; - case AST_OP_NE: - fprintf(stream, "\"!=\""); - break; - case AST_OP_GT: - fprintf(stream, "\">\""); - break; - case AST_OP_LT: - fprintf(stream, "\"<\""); - break; - case AST_OP_GE: - fprintf(stream, "\">=\""); - break; - case AST_OP_LE: - fprintf(stream, "\"<=\""); - break; - } - fprintf(stream, ">\n"); - ret = recursive_visit_print(node->u.op.lchild, - stream, indent + 1); - if (ret) - return ret; - ret = recursive_visit_print(node->u.op.rchild, - stream, indent + 1); - if (ret) - return ret; - print_tabs(stream, indent); - fprintf(stream, "\n"); - return ret; - case NODE_UNARY_OP: - print_tabs(stream, indent); - fprintf(stream, "\n"); - ret = recursive_visit_print(node->u.unary_op.child, - stream, indent + 1); - print_tabs(stream, indent); - fprintf(stream, "\n"); - return ret; - } - return 0; -} - -int filter_visitor_print_xml(struct filter_parser_ctx *ctx, FILE *stream, - int indent) -{ - return recursive_visit_print(&ctx->ast->root, stream, indent); -}