/* * bronx_filter.c -- Message filtering functionality. * * Copyright (C) 2007 Groundwork Open Source * Written by Daniel Emmanuel Feinsmith * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301, USA. * * Change Log: * DEF Created on September 17, 2007, 1:00 PM */ #include "bronx.h" #include "bronx_route.h" #include "bronx_config.h" #include "bronx_log.h" /* * Functionality. */ void filter_message(route_definition *route, message *msg) { char *key = "LastPluginOutput", *value; value = apr_hash_get(msg->properties, (void*)key, APR_HASH_KEY_STRING); if (value == NULL) return; if (!strncmp(value, "[TEST] ", 7)) { normalize_plugin_output(value, "B4"); apr_hash_set(msg->properties, (void*)key, APR_HASH_KEY_STRING, value); } else { if(route->filter_type == BRONX_FILTER_TYPE_BOTH) return; else { char *before_pipe, *after_pipe = NULL, *last; if ((before_pipe = apr_strtok(value, "|", &last)) != NULL) after_pipe = apr_strtok(NULL, "|", &last); switch(route->filter_type) { case BRONX_FILTER_TYPE_PLUGIN: if (before_pipe == NULL) before_pipe = ""; apr_hash_set(msg->properties, (void*)key, APR_HASH_KEY_STRING, before_pipe); bronx_logprintf(BRONX_LOGGING_DEBUG, "(route: %s) PLUGIN FILTER: value=%s", route->route_name, before_pipe); break; case BRONX_FILTER_TYPE_PERF: if (after_pipe == NULL) after_pipe = ""; apr_hash_set(msg->properties, (void*)key, APR_HASH_KEY_STRING, after_pipe); bronx_logprintf(BRONX_LOGGING_DEBUG, "(route: %s) PERF FILTER: value=%s", route->route_name, after_pipe); break; } } } }