/*****************************************************************************
*
* XCDDEFAULT.C - Default external comment data routines for Nagios
*
* Copyright (c) 2000-2006 Ethan Galstad (nagios@nagios.org)
* Last Modified: 05-20-2006
*
* License:
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
/*********** COMMON HEADER FILES ***********/
#include "../include/config.h"
#include "../include/common.h"
#include "../include/locations.h"
#include "../include/comments.h"
#ifdef NSCORE
#include "../include/objects.h"
#include "../include/nagios.h"
#endif
#ifdef NSCGI
#include "../include/cgiutils.h"
#endif
/**** IMPLEMENTATION SPECIFIC HEADER FILES ****/
#include "xcddefault.h"
char xcddefault_comment_file[MAX_FILENAME_LENGTH]="";
char xcddefault_temp_file[MAX_FILENAME_LENGTH]="";
#ifdef NSCORE
unsigned long current_comment_id=0;
extern comment *comment_list;
extern char *macro_x[MACRO_X_COUNT];
#endif
/******************************************************************/
/***************** COMMON CONFIG INITIALIZATION ******************/
/******************************************************************/
/* grab configuration information from appropriate config file(s) */
int xcddefault_grab_config_info(char *config_file){
char *input=NULL;
mmapfile *thefile;
#ifdef NSCGI
char *input2=NULL;
mmapfile *thefile2;
char *temp_buffer;
#endif
/*** CORE PASSES IN MAIN CONFIG FILE, CGIS PASS IN CGI CONFIG FILE! ***/
/* initialize the location of the comment and temp */
strncpy(xcddefault_comment_file,DEFAULT_COMMENT_FILE,sizeof(xcddefault_comment_file)-1);
strncpy(xcddefault_temp_file,DEFAULT_TEMP_FILE,sizeof(xcddefault_temp_file)-1);
xcddefault_comment_file[sizeof(xcddefault_comment_file)-1]='\x0';
xcddefault_temp_file[sizeof(xcddefault_temp_file)-1]='\x0';
/* open the config file for reading */
if((thefile=mmap_fopen(config_file))==NULL)
return ERROR;
/* read in all lines from the config file */
while(1){
/* free memory */
free(input);
/* read the next line */
if((input=mmap_fgets(thefile))==NULL)
break;
strip(input);
/* skip blank lines and comments */
if(input[0]=='#' || input[0]=='\x0')
continue;
#ifdef NSCGI
/* CGI needs to find and read contents of main config file, since it was passed the name of the CGI config file */
=1= |