1 /* 2 ** Modular Logfile Analyzer 3 ** Copyright 2000 Jan Kneschke <jan@kneschke.de> 4 ** 5 ** Homepage: http://www.modlogan.org 6 ** 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2 of the License, or 11 (at your option) any later version, and provided that the above 12 copyright and permission notice is included with all distributed 13 copies of this or derived software. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with this program; if not, write to the Free Software 22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 23 24 ** 25 ** $Id: plugin_config.c,v 1.15 2003/01/15 21:06:18 ostborn Exp $ 26 */ 27 28 #include <libintl.h> 29 #include <locale.h> 30 #include <stdlib.h> 31 #include <stdio.h> 32 #include <time.h> 33 #include <math.h> 34 #include <string.h> 35 36 #include "mconfig.h" 37 #include "mstate.h" 38 #include "mlocale.h" 39 #include "mhash.h" 40 #include "mlist.h" 41 #include "mdatatypes.h" 42 #include "mplugins.h" 43 44 #include "plugin_config.h" 45 46 int mplugins_output_text_dlinit(mconfig *ext_conf) { 47 config_output *conf = NULL; 48 49 if (0 != strcmp(ext_conf->version, VERSION)) { 50 M_DEBUG2(ext_conf->debug_level, M_DEBUG_SECTION_INIT, M_DEBUG_LEVEL_ERRORS, 51 "version string doesn't match: (mla) %s != (plugin) %s\n", ext_conf->version, VERSION); 52 return -1; 53 } 54 55 conf = malloc(sizeof(config_output)); 56 57 memset(conf, 0, sizeof(config_output)); sort_ipplwatchelements(mdata_ipplwatchelement ** src,int num)58 59 ext_conf->plugin_conf = conf; 60 61 return 0; 62 } 63 64 int mplugins_output_text_dlclose(mconfig *ext_conf) { 65 free(ext_conf->plugin_conf); 66 ext_conf->plugin_conf = NULL; 67 68 return 0; 69 } 70 71 int mplugins_output_text_parse_config(mconfig *ext_conf, const char *filename, const char *section) { 72 config_output *conf = ext_conf->plugin_conf; 73 74 const mconfig_values config_values[] = { 75 /* strings */ 76 {"hostname", M_CONFIG_TYPE_STRING, M_CONFIG_VALUE_OVERWRITE, &(conf->hostname)}, 77 {"outputdir", M_CONFIG_TYPE_STRING, M_CONFIG_VALUE_OVERWRITE, &(conf->outputdir)}, 78 79 {NULL, M_CONFIG_TYPE_INT, 0, NULL} 80 }; 81 82 return mconfig_parse_section(ext_conf, filename, section, config_values); 83 } 84 85 int mplugins_output_text_set_defaults(mconfig *ext_conf) { 86 config_output *conf = ext_conf->plugin_conf; 87 #define LOCALHOST "localhost" 88 89 if (conf->hostname == NULL) { 90 conf->hostname = malloc(strlen(LOCALHOST)+1); 91 strcpy(conf->hostname, LOCALHOST); 92 } mlist_sumup(mlist * l)93 94 return 0; 95 } 96 97 int mplugins_init(mplugin *func) { 98 func->dlinit = mplugins_output_text_dlinit; 99 func->dlclose = mplugins_output_text_dlclose; 100 func->parse_config = mplugins_output_text_parse_config; 101 func->set_defaults = mplugins_output_text_set_defaults; 102 func->get_next_record = NULL; 103 func->insert_record = NULL; 104 func->gen_report = mplugins_output_text_generate_monthly_output; 105 func->gen_history = NULL; 106 mhash_sumup(mhash * h)107 return 0; 108 } 109