/* ** Modular Logfile Analyzer ** Copyright 2000 Jan Kneschke ** ** Homepage: http://www.modlogan.org ** 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, and provided that the above copyright and permission notice is included with all distributed copies of this or derived software. 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA ** ** $Id: plugin_config.c,v 1.15 2003/01/15 21:06:18 ostborn Exp $ */ #include #include #include #include #include #include #include #include "mconfig.h" #include "mstate.h" #include "mlocale.h" #include "mhash.h" #include "mlist.h" #include "mdatatypes.h" #include "mplugins.h" #include "plugin_config.h" int mplugins_output_text_dlinit(mconfig *ext_conf) { config_output *conf = NULL; if (0 != strcmp(ext_conf->version, VERSION)) { M_DEBUG2(ext_conf->debug_level, M_DEBUG_SECTION_INIT, M_DEBUG_LEVEL_ERRORS, "version string doesn't match: (mla) %s != (plugin) %s\n", ext_conf->version, VERSION); return -1; } conf = malloc(sizeof(config_output)); memset(conf, 0, sizeof(config_output)); ext_conf->plugin_conf = conf; return 0; } int mplugins_output_text_dlclose(mconfig *ext_conf) { free(ext_conf->plugin_conf); ext_conf->plugin_conf = NULL; return 0; } int mplugins_output_text_parse_config(mconfig *ext_conf, const char *filename, const char *section) { config_output *conf = ext_conf->plugin_conf; const mconfig_values config_values[] = { /* strings */ {"hostname", M_CONFIG_TYPE_STRING, M_CONFIG_VALUE_OVERWRITE, &(conf->hostname)}, {"outputdir", M_CONFIG_TYPE_STRING, M_CONFIG_VALUE_OVERWRITE, &(conf->outputdir)}, {NULL, M_CONFIG_TYPE_INT, 0, NULL} }; return mconfig_parse_section(ext_conf, filename, section, config_values); } int mplugins_output_text_set_defaults(mconfig *ext_conf) { config_output *conf = ext_conf->plugin_conf; #define LOCALHOST "localhost" if (conf->hostname == NULL) { conf->hostname = malloc(strlen(LOCALHOST)+1); strcpy(conf->hostname, LOCALHOST); } return 0; } int mplugins_init(mplugin *func) { func->dlinit = mplugins_output_text_dlinit; func->dlclose = mplugins_output_text_dlclose; func->parse_config = mplugins_output_text_parse_config; func->set_defaults = mplugins_output_text_set_defaults; func->get_next_record = NULL; func->insert_record = NULL; func->gen_report = mplugins_output_text_generate_monthly_output; func->gen_history = NULL; return 0; }