diff -uNr nagios.orig/common/statusdata.c nagios/common/statusdata.c
--- nagios.orig/common/statusdata.c	2008-06-15 12:29:27.000000000 -0400
+++ nagios/common/statusdata.c	2008-06-15 09:44:14.000000000 -0400
@@ -43,6 +43,10 @@
 #include "../xdata/xsddefault.h"		/* default routines */
 #endif
 
+#ifdef USE_XSDJSON
+#include "../xdata/xsdjson.h"		/* JSON routines */
+#endif
+
 
 #ifdef NSCORE
 extern int      aggregate_status_updates;
@@ -75,6 +79,9 @@
 	result=xsddefault_initialize_status_data(config_file);
 #endif
 
+#ifdef USE_XSDJSON
+	result=xsdjson_initialize_status_data(config_file);
+#endif
 	return result;
         }
 
@@ -93,6 +100,10 @@
 	result=xsddefault_save_status_data();
 #endif
 
+#ifdef USE_XSDJSON
+	result=xsdjson_save_status_data();
+#endif
+
 #ifdef USE_EVENT_BROKER
 	/* send data to event broker */
 	broker_aggregated_status_data(NEBTYPE_AGGREGATEDSTATUS_ENDDUMP,NEBFLAG_NONE,NEBATTR_NONE,NULL);
@@ -114,6 +125,10 @@
 	result=xsddefault_cleanup_status_data(config_file,delete_status_data);
 #endif
 
+#ifdef USE_XSDJSON
+	result=xsdjson_cleanup_status_data(config_file,delete_status_data);
+#endif
+
 	return result;
         }
 
@@ -201,6 +216,9 @@
 #ifdef USE_XSDDB
 	result=xsddb_read_status_data(config_file,options);
 #endif
+#ifdef USE_XSDJSON
+	result=xsdjson_read_status_data(config_file,options);
+#endif
 
 	return result;
         }
diff -uNr nagios.orig/configure.in nagios/configure.in
--- nagios.orig/configure.in	2008-06-15 12:29:27.000000000 -0400
+++ nagios/configure.in	2008-06-15 12:12:26.000000000 -0400
@@ -219,11 +219,24 @@
 USE_PGSQL=no
 
 dnl Status data
-AC_DEFINE_UNQUOTED(USE_XSDDEFAULT)
-XSDC="xsddefault.c"
-XSDH="xsddefault.h"
-XSDCOMMENT="Default (text file)"
-echo "We'll use default routines (in xdata/xsddefault.*) for status data I/O..."
+AC_ARG_ENABLE(xsdjson,
+	AC_HELP_STRING([--enable-xsdjson],
+		[Enables JSON format for status file (default: no)]),
+	[enable_xsdjson=$enableval],
+	[enable_xsdjson=no])
+if test "$enable_xsdjson" = "yes" ; then
+	AC_DEFINE_UNQUOTED(USE_XSDJSON)
+	XSDC="xsdjson.c"
+	XSDH="xsdjson.h"
+	XSDCOMMENT="JSON"
+	echo "We'll use JSON routines (in xdata/xsdjson.*) for status data I/O..."
+else
+	AC_DEFINE_UNQUOTED(USE_XSDDEFAULT)
+	XSDC="xsddefault.c"
+	XSDH="xsddefault.h"
+	XSDCOMMENT="Default (text file)"
+	echo "We'll use default routines (in xdata/xsddefault.*) for status data I/O..."
+fi
 AC_SUBST(XSDC)
 AC_SUBST(XSDH)
 
diff -uNr nagios.orig/xdata/xsdjson.c nagios/xdata/xsdjson.c
--- nagios.orig/xdata/xsdjson.c	1969-12-31 19:00:00.000000000 -0500
+++ nagios/xdata/xsdjson.c	2008-06-15 09:46:52.000000000 -0400
@@ -0,0 +1,1030 @@
+/*****************************************************************************
+ *
+ * XSDJSON.C - JSON external status data input routines for Nagios
+ *
+ * Copyright (c) 2008 Yann JOUANIN (yann.jouanin@intelunix.fr)
+ * Last Modified:   06-15-2008
+ *
+ * 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/statusdata.h"
+
+#ifdef NSCORE
+#include "../include/nagios.h"
+#endif
+
+#ifdef NSCGI
+#include "../include/cgiutils.h"
+#endif
+
+
+/**** IMPLEMENTATION SPECIFIC HEADER FILES ****/
+#include "xsdjson.h"
+
+
+
+#ifdef NSCGI
+time_t program_start;
+int daemon_mode;
+time_t last_command_check;
+time_t last_log_rotation;
+int enable_notifications;
+int execute_service_checks;
+int accept_passive_service_checks;
+int execute_host_checks;
+int accept_passive_host_checks;
+int enable_event_handlers;
+int obsess_over_services;
+int obsess_over_hosts;
+int check_service_freshness;
+int check_host_freshness;
+int enable_flap_detection;
+int enable_failure_prediction;
+int process_performance_data;
+int nagios_pid;
+#endif
+
+#ifdef NSCORE
+extern time_t program_start;
+extern int nagios_pid;
+extern int daemon_mode;
+extern time_t last_command_check;
+extern time_t last_log_rotation;
+extern int enable_notifications;
+extern int execute_service_checks;
+extern int accept_passive_service_checks;
+extern int execute_host_checks;
+extern int accept_passive_host_checks;
+extern int enable_event_handlers;
+extern int obsess_over_services;
+extern int obsess_over_hosts;
+extern int check_service_freshness;
+extern int check_host_freshness;
+extern int enable_flap_detection;
+extern int enable_failure_prediction;
+extern int process_performance_data;
+extern int aggregate_status_updates;
+extern int check_external_commands;
+
+extern int external_command_buffer_slots;
+extern int check_result_buffer_slots;
+extern circular_buffer external_command_buffer;
+extern circular_buffer service_result_buffer;
+
+extern char *macro_x[MACRO_X_COUNT];
+
+extern host *host_list;
+extern service *service_list;
+
+extern unsigned long  modified_host_process_attributes;
+extern unsigned long  modified_service_process_attributes;
+extern char           *global_host_event_handler;
+extern char           *global_service_event_handler;
+#endif
+
+
+char xsdjson_status_log[MAX_FILENAME_LENGTH]="";
+char xsdjson_temp_file[MAX_FILENAME_LENGTH]="";
+
+#ifdef NSCORE
+char xsdjson_aggregate_temp_file[MAX_INPUT_BUFFER];
+#endif
+
+
+
+/******************************************************************/
+/***************** COMMON CONFIG INITIALIZATION  ******************/
+/******************************************************************/
+
+/* grab configuration information */
+int xsdjson_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 status log */
+	strncpy(xsdjson_status_log,DEFAULT_STATUS_FILE,sizeof(xsdjson_status_log)-1);
+	strncpy(xsdjson_temp_file,DEFAULT_TEMP_FILE,sizeof(xsdjson_temp_file)-1);
+	xsdjson_status_log[sizeof(xsdjson_status_log)-1]='\x0';
+	xsdjson_temp_file[sizeof(xsdjson_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 main 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 */
+		if(strstr(input,"main_config_file")==input){
+
+			temp_buffer=strtok(input,"=");
+			temp_buffer=strtok(NULL,"\n");
+			if(temp_buffer==NULL)
+				continue;
+
+			if((thefile2=mmap_fopen(temp_buffer))==NULL)
+				continue;
+
+			/* read in all lines from the main config file */
+			while(1){
+
+				/* free memory */
+				free(input2);
+
+				/* read the next line */
+				if((input2=mmap_fgets(thefile2))==NULL)
+					break;
+
+				strip(input2);
+
+				/* skip blank lines and comments */
+				if(input2[0]=='#' || input2[0]=='\x0')
+					continue;
+
+				xsdjson_grab_config_directives(input2);
+			        }
+
+			/* free memory and close the file */
+			free(input2);
+			mmap_fclose(thefile2);
+		        }
+#endif
+
+#ifdef NSCORE
+		/* core reads variables directly from the main config file */
+		xsdjson_grab_config_directives(input);
+#endif
+	        }
+
+	/* free memory and close the file */
+	free(input);
+	mmap_fclose(thefile);
+
+	/* we didn't find the status log name */
+	if(!strcmp(xsdjson_status_log,""))
+		return ERROR;
+
+	/* we didn't find the temp file */
+	if(!strcmp(xsdjson_temp_file,""))
+		return ERROR;
+
+#ifdef NSCORE
+	/* save the status file macro */
+	if(macro_x[MACRO_STATUSDATAFILE]!=NULL)
+		free(macro_x[MACRO_STATUSDATAFILE]);
+	macro_x[MACRO_STATUSDATAFILE]=(char *)strdup(xsdjson_status_log);
+	if(macro_x[MACRO_STATUSDATAFILE]!=NULL)
+		strip(macro_x[MACRO_STATUSDATAFILE]);
+#endif
+
+	return OK;
+        }
+
+
+void xsdjson_grab_config_directives(char *input_buffer){
+	char *temp_buffer;
+
+	/* status log definition */
+	if((strstr(input_buffer,"status_file")==input_buffer) || (strstr(input_buffer,"xsdjson_status_log")==input_buffer)){
+		temp_buffer=strtok(input_buffer,"=");
+		temp_buffer=strtok(NULL,"\n");
+		if(temp_buffer==NULL)
+			return;
+		strncpy(xsdjson_status_log,temp_buffer,sizeof(xsdjson_status_log)-1);
+		xsdjson_status_log[sizeof(xsdjson_status_log)-1]='\x0';
+	        }
+
+
+	/* temp file definition */
+	if((strstr(input_buffer,"temp_file")==input_buffer) || (strstr(input_buffer,"xsdjson_temp_file")==input_buffer)){
+		temp_buffer=strtok(input_buffer,"=");
+		temp_buffer=strtok(NULL,"\n");
+		if(temp_buffer==NULL)
+			return;
+		strncpy(xsdjson_temp_file,temp_buffer,sizeof(xsdjson_temp_file)-1);
+		xsdjson_temp_file[sizeof(xsdjson_temp_file)-1]='\x0';
+	        }
+
+	return;
+        }
+
+
+
+#ifdef NSCORE
+
+/******************************************************************/
+/********************* INIT/CLEANUP FUNCTIONS *********************/
+/******************************************************************/
+
+
+/* initialize status data */
+int xsdjson_initialize_status_data(char *config_file){
+	int result;
+
+	/* grab configuration data */
+	result=xsdjson_grab_config_info(config_file);
+	if(result==ERROR)
+		return ERROR;
+
+	/* delete the old status log (it might not exist) */
+	unlink(xsdjson_status_log);
+
+	return OK;
+        }
+
+
+/* cleanup status data before terminating */
+int xsdjson_cleanup_status_data(char *config_file, int delete_status_data){
+
+	/* delete the status log */
+	if(delete_status_data==TRUE){
+		if(unlink(xsdjson_status_log))
+			return ERROR;
+	        }
+
+	return OK;
+        }
+
+
+/******************************************************************/
+/****************** STATUS DATA OUTPUT FUNCTIONS ******************/
+/******************************************************************/
+
+/* write all status data to file */
+int xsdjson_save_status_data(void){
+	char temp_buffer[MAX_INPUT_BUFFER];
+	host *temp_host;
+	service *temp_service2;
+	service *temp_service;
+	time_t current_time;
+	int fd=0;
+	FILE *fp=NULL;
+	int used_check_result_buffer_slots=0;
+	int high_check_result_buffer_slots=0;
+	int used_external_command_buffer_slots=0;
+	int high_external_command_buffer_slots=0;
+	char * temp_str;
+	char * temp_str2;
+
+	temp_str = (char*) malloc(1024*sizeof(char));
+
+	/* open a safe temp file for output */
+	snprintf(xsdjson_aggregate_temp_file,sizeof(xsdjson_aggregate_temp_file)-1,"%sXXXXXX",xsdjson_temp_file);
+	xsdjson_aggregate_temp_file[sizeof(xsdjson_aggregate_temp_file)-1]='\x0';
+	if((fd=mkstemp(xsdjson_aggregate_temp_file))==-1){
+
+		/* log an error */
+		snprintf(temp_buffer,sizeof(temp_buffer),"Error: Unable to create temp file for writing status data!\n");
+		temp_buffer[sizeof(temp_buffer)-1]='\x0';
+		write_to_logs_and_console(temp_buffer,NSLOG_RUNTIME_ERROR,TRUE);
+
+		return ERROR;
+	        }
+	fp=fdopen(fd,"w");
+	if(fp==NULL){
+
+		close(fd);
+		unlink(xsdjson_aggregate_temp_file);
+
+		/* log an error */
+		snprintf(temp_buffer,sizeof(temp_buffer),"Error: Unable to open temp file '%s' for writing status data!\n",xsdjson_aggregate_temp_file);
+		temp_buffer[sizeof(temp_buffer)-1]='\x0';
+		write_to_logs_and_console(temp_buffer,NSLOG_RUNTIME_ERROR,TRUE);
+
+		return ERROR;
+	        }
+
+	/* get number of items in the check result buffer */
+	pthread_mutex_lock(&service_result_buffer.buffer_lock);
+	used_check_result_buffer_slots=service_result_buffer.items;
+	high_check_result_buffer_slots=service_result_buffer.high;
+	pthread_mutex_unlock(&service_result_buffer.buffer_lock);
+
+	/* get number of items in the command buffer */
+	if(check_external_commands==TRUE){
+		pthread_mutex_lock(&external_command_buffer.buffer_lock);
+		used_external_command_buffer_slots=external_command_buffer.items;
+		high_external_command_buffer_slots=external_command_buffer.high;
+		pthread_mutex_unlock(&external_command_buffer.buffer_lock);
+		}
+	else{
+		used_external_command_buffer_slots=0;
+		high_external_command_buffer_slots=0;
+		}
+
+	/* write version info to status file */
+	/*fprintf(fp,"########################################\n");
+	fprintf(fp,"#      NAGIOS STATUS FILE JSON FORMATTED\n");
+	fprintf(fp,"#\n");
+	fprintf(fp,"# THIS FILE IS AUTOMATICALLY GENERATED\n");
+	fprintf(fp,"# BY NAGIOS.  DO NOT MODIFY THIS FILE!\n");
+	fprintf(fp,"########################################\n\n");*/
+
+	time(&current_time);
+	fprintf(fp,"{\n");
+	/* write file info */
+	fprintf(fp,"\"info\":{\n");
+	fprintf(fp,"\t\"created\":%lu,\n",current_time);
+	fprintf(fp,"\t\"version\":\"%s\"\n",PROGRAM_VERSION);
+	fprintf(fp,"\t},\n\n");
+
+	/* save program status data */
+	fprintf(fp,"\"program\":{\n");
+	fprintf(fp,"\t\"modified_host_attributes\":%lu,\n",modified_host_process_attributes);
+	fprintf(fp,"\t\"modified_service_attributes\":%lu,\n",modified_service_process_attributes);
+	fprintf(fp,"\t\"nagios_pid\":%d,\n",nagios_pid);
+	fprintf(fp,"\t\"daemon_mode\":%d,\n",daemon_mode);
+	fprintf(fp,"\t\"program_start\":%lu,\n",program_start);
+	fprintf(fp,"\t\"last_command_check\":%lu,\n",last_command_check);
+	fprintf(fp,"\t\"last_log_rotation\":%lu,\n",last_log_rotation);
+	fprintf(fp,"\t\"enable_notifications\":%d,\n",enable_notifications);
+	fprintf(fp,"\t\"active_service_checks_enabled\":%d,\n",execute_service_checks);
+	fprintf(fp,"\t\"passive_service_checks_enabled\":%d,\n",accept_passive_service_checks);
+	fprintf(fp,"\t\"active_host_checks_enabled\":%d,\n",execute_host_checks);
+	fprintf(fp,"\t\"passive_host_checks_enabled\":%d,\n",accept_passive_host_checks);
+	fprintf(fp,"\t\"enable_event_handlers\":%d,\n",enable_event_handlers);
+	fprintf(fp,"\t\"obsess_over_services\":%d,\n",obsess_over_services);
+	fprintf(fp,"\t\"obsess_over_hosts\":%d,\n",obsess_over_hosts);
+	fprintf(fp,"\t\"check_service_freshness\":%d,\n",check_service_freshness);
+	fprintf(fp,"\t\"check_host_freshness\":%d,\n",check_host_freshness);
+	fprintf(fp,"\t\"enable_flap_detection\":%d,\n",enable_flap_detection);
+	fprintf(fp,"\t\"enable_failure_prediction\":%d,\n",enable_failure_prediction);
+	fprintf(fp,"\t\"process_performance_data\":%d,\n",process_performance_data);
+	fprintf(fp,"\t\"global_host_event_handler\":\"%s\",\n",(global_host_event_handler==NULL)?"":global_host_event_handler);
+	fprintf(fp,"\t\"global_service_event_handler\":\"%s\",\n",(global_service_event_handler==NULL)?"":global_service_event_handler);
+	fprintf(fp,"\t\"total_external_command_buffer_slots\":%d,\n",external_command_buffer_slots);
+	fprintf(fp,"\t\"used_external_command_buffer_slots\":%d,\n",used_external_command_buffer_slots);
+	fprintf(fp,"\t\"high_external_command_buffer_slots\":%d,\n",high_external_command_buffer_slots);
+	fprintf(fp,"\t\"total_check_result_buffer_slots\":%d,\n",check_result_buffer_slots);
+	fprintf(fp,"\t\"used_check_result_buffer_slots\":%d,\n",used_check_result_buffer_slots);
+	fprintf(fp,"\t\"high_check_result_buffer_slots\":%d\n",high_check_result_buffer_slots);
+	fprintf(fp,"\t},\n\n");
+
+	
+
+	/* save host status data */
+	fprintf(fp,"\"host\":{\n");
+	for(temp_host=host_list;temp_host!=NULL;temp_host=temp_host->next){
+
+		
+		fprintf(fp,"\t\"%s\":{\n",temp_host->name);
+		fprintf(fp,"\t\t\"modified_attributes\":%lu,\n",temp_host->modified_attributes);
+		fprintf(fp,"\t\t\"check_command\":\"%s\",\n",(temp_host->host_check_command==NULL)?"":temp_host->host_check_command);
+		fprintf(fp,"\t\t\"event_handler\":\"%s\",\n",(temp_host->event_handler==NULL)?"":temp_host->event_handler);
+		fprintf(fp,"\t\t\"has_been_checked\":%d,\n",temp_host->has_been_checked);
+		fprintf(fp,"\t\t\"should_be_scheduled\":%d,\n",temp_host->should_be_scheduled);
+		fprintf(fp,"\t\t\"check_execution_time\":%.3f,\n",temp_host->execution_time);
+		fprintf(fp,"\t\t\"check_latency\":%.3f,\n",temp_host->latency);
+		fprintf(fp,"\t\t\"check_type\":%d,\n",temp_host->check_type);
+		fprintf(fp,"\t\t\"current_state\":%d,\n",temp_host->current_state);
+		fprintf(fp,"\t\t\"last_hard_state\":%d,\n",temp_host->last_hard_state);
+		fprintf(fp,"\t\t\"plugin_output\":\"%s\",\n",(temp_host->plugin_output==NULL)?"":temp_host->plugin_output);
+		fprintf(fp,"\t\t\"performance_data\":\"%s\",\n",(temp_host->perf_data==NULL)?"":temp_host->perf_data);
+		fprintf(fp,"\t\t\"last_check\":%lu,\n",temp_host->last_check);
+		fprintf(fp,"\t\t\"next_check\":%lu,\n",temp_host->next_check);
+		fprintf(fp,"\t\t\"current_attempt\":%d,\n",temp_host->current_attempt);
+		fprintf(fp,"\t\t\"max_attempts\":%d,\n",temp_host->max_attempts);
+		fprintf(fp,"\t\t\"state_type\":%d,\n",temp_host->state_type);
+		fprintf(fp,"\t\t\"last_state_change\":%lu,\n",temp_host->last_state_change);
+		fprintf(fp,"\t\t\"last_hard_state_change\":%lu,\n",temp_host->last_hard_state_change);
+		fprintf(fp,"\t\t\"last_time_up\":%lu,\n",temp_host->last_time_up);
+		fprintf(fp,"\t\t\"last_time_down\":%lu,\n",temp_host->last_time_down);
+		fprintf(fp,"\t\t\"last_time_unreachable\":%lu,\n",temp_host->last_time_unreachable);
+		fprintf(fp,"\t\t\"last_notification\":%lu,\n",temp_host->last_host_notification);
+		fprintf(fp,"\t\t\"next_notification\":%lu,\n",temp_host->next_host_notification);
+		fprintf(fp,"\t\t\"no_more_notifications\":%d,\n",temp_host->no_more_notifications);
+		fprintf(fp,"\t\t\"current_notification_number\":%d,\n",temp_host->current_notification_number);
+		fprintf(fp,"\t\t\"notifications_enabled\":%d,\n",temp_host->notifications_enabled);
+		fprintf(fp,"\t\t\"problem_has_been_acknowledged\":%d,\n",temp_host->problem_has_been_acknowledged);
+		fprintf(fp,"\t\t\"acknowledgement_type\":%d,\n",temp_host->acknowledgement_type);
+		fprintf(fp,"\t\t\"active_checks_enabled\":%d,\n",temp_host->checks_enabled);
+		fprintf(fp,"\t\t\"passive_checks_enabled\":%d,\n",temp_host->accept_passive_host_checks);
+		fprintf(fp,"\t\t\"event_handler_enabled\":%d,\n",temp_host->event_handler_enabled);
+		fprintf(fp,"\t\t\"flap_detection_enabled\":%d,\n",temp_host->flap_detection_enabled);
+		fprintf(fp,"\t\t\"failure_prediction_enabled\":%d,\n",temp_host->failure_prediction_enabled);
+		fprintf(fp,"\t\t\"process_performance_data\":%d,\n",temp_host->process_performance_data);
+		fprintf(fp,"\t\t\"obsess_over_host\":%d,\n",temp_host->obsess_over_host);
+		fprintf(fp,"\t\t\"last_update\":%lu,\n",current_time);
+		fprintf(fp,"\t\t\"is_flapping\":%d,\n",temp_host->is_flapping);
+		fprintf(fp,"\t\t\"percent_state_change\":%.2f,\n",temp_host->percent_state_change);
+		fprintf(fp,"\t\t\"scheduled_downtime_depth\":%d\n",temp_host->scheduled_downtime_depth);
+		/*
+		fprintf(fp,"\t\"state_history=");
+		for(x=0;x<MAX_STATE_HISTORY_ENTRIES;x++)
+			fprintf(fp,"%s%d",(x>0)?",":"",temp_host->state_history[(x+temp_host->state_history_index)%MAX_STATE_HISTORY_ENTRIES]);
+		fprintf(fp,"\n");
+		*/
+		fprintf(fp,"\t\t}");
+		if (temp_host->next != NULL) fprintf(fp,",");
+		fprintf(fp,"\n");
+	        }
+	fprintf(fp,"\t},\n\n");
+	/* save service status data */
+	fprintf(fp,"\"service\":{\n");
+	for(temp_service=service_list;temp_service!=NULL;temp_service=temp_service->next){
+		
+		
+		if (strcmp(temp_service->host_name,temp_str)){
+			fprintf(fp,"\t\"%s\":{\n",temp_service->host_name);
+			strcpy(temp_str,temp_service->host_name);
+		}
+
+		
+		//fprintf(fp,"\t\"host_name\":\"%s\",\n",temp_service->host_name);
+		fprintf(fp,"\t\t\"%s\":{\n",temp_service->description);
+		fprintf(fp,"\t\t\t\"modified_attributes\":%lu,\n",temp_service->modified_attributes);
+		fprintf(fp,"\t\t\t\"check_command\":\"%s\",\n",(temp_service->service_check_command==NULL)?"":temp_service->service_check_command);
+		fprintf(fp,"\t\t\t\"event_handler\":\"%s\",\n",(temp_service->event_handler==NULL)?"":temp_service->event_handler);
+		fprintf(fp,"\t\t\t\"has_been_checked\":%d,\n",temp_service->has_been_checked);
+		fprintf(fp,"\t\t\t\"should_be_scheduled\":%d,\n",temp_service->should_be_scheduled);
+		fprintf(fp,"\t\t\t\"check_execution_time\":%.3f,\n",temp_service->execution_time);
+		fprintf(fp,"\t\t\t\"check_latency\":%.3f,\n",temp_service->latency);
+		fprintf(fp,"\t\t\t\"check_type\":%d,\n",temp_service->check_type);
+		fprintf(fp,"\t\t\t\"current_state\":%d,\n",temp_service->current_state);
+		fprintf(fp,"\t\t\t\"last_hard_state\":%d,\n",temp_service->last_hard_state);
+		fprintf(fp,"\t\t\t\"current_attempt\":%d,\n",temp_service->current_attempt);
+		fprintf(fp,"\t\t\t\"max_attempts\":%d,\n",temp_service->max_attempts);
+		fprintf(fp,"\t\t\t\"state_type\":%d,\n",temp_service->state_type);
+		fprintf(fp,"\t\t\t\"last_state_change\":%lu,\n",temp_service->last_state_change);
+		fprintf(fp,"\t\t\t\"last_hard_state_change\":%lu,\n",temp_service->last_hard_state_change);
+		fprintf(fp,"\t\t\t\"last_time_ok\":%lu,\n",temp_service->last_time_ok);
+		fprintf(fp,"\t\t\t\"last_time_warning\":%lu,\n",temp_service->last_time_warning);
+		fprintf(fp,"\t\t\t\"last_time_unknown\":%lu,\n",temp_service->last_time_unknown);
+		fprintf(fp,"\t\t\t\"last_time_critical\":%lu,\n",temp_service->last_time_critical);
+		fprintf(fp,"\t\t\t\"plugin_output\":\"%s\",\n",(temp_service->plugin_output==NULL)?"":temp_service->plugin_output);
+		fprintf(fp,"\t\t\t\"performance_data\":\"%s\",\n",(temp_service->perf_data==NULL)?"":temp_service->perf_data);
+		fprintf(fp,"\t\t\t\"last_check\":%lu,\n",temp_service->last_check);
+		fprintf(fp,"\t\t\t\"next_check\":%lu,\n",temp_service->next_check);
+		fprintf(fp,"\t\t\t\"current_notification_number\":%d,\n",temp_service->current_notification_number);
+		fprintf(fp,"\t\t\t\"last_notification\":%lu,\n",temp_service->last_notification);
+		fprintf(fp,"\t\t\t\"next_notification\":%lu,\n",temp_service->next_notification);
+		fprintf(fp,"\t\t\t\"no_more_notifications\":%d,\n",temp_service->no_more_notifications);
+		fprintf(fp,"\t\t\t\"notifications_enabled\":%d,\n",temp_service->notifications_enabled);
+		fprintf(fp,"\t\t\t\"active_checks_enabled\":%d,\n",temp_service->checks_enabled);
+		fprintf(fp,"\t\t\t\"passive_checks_enabled\":%d,\n",temp_service->accept_passive_service_checks);
+		fprintf(fp,"\t\t\t\"event_handler_enabled\":%d,\n",temp_service->event_handler_enabled);
+		fprintf(fp,"\t\t\t\"problem_has_been_acknowledged\":%d,\n",temp_service->problem_has_been_acknowledged);
+		fprintf(fp,"\t\t\t\"acknowledgement_type\":%d,\n",temp_service->acknowledgement_type);
+		fprintf(fp,"\t\t\t\"flap_detection_enabled\":%d,\n",temp_service->flap_detection_enabled);
+		fprintf(fp,"\t\t\t\"failure_prediction_enabled\":%d,\n",temp_service->failure_prediction_enabled);
+		fprintf(fp,"\t\t\t\"process_performance_data\":%d,\n",temp_service->process_performance_data);
+		fprintf(fp,"\t\t\t\"obsess_over_service\":%d,\n",temp_service->obsess_over_service);
+		fprintf(fp,"\t\t\t\"last_update\":%lu,\n",current_time);
+		fprintf(fp,"\t\t\t\"is_flapping\":%d,\n",temp_service->is_flapping);
+		fprintf(fp,"\t\t\t\"percent_state_change\":%.2f,\n",temp_service->percent_state_change);
+		fprintf(fp,"\t\t\t\"scheduled_downtime_depth\":%d\n",temp_service->scheduled_downtime_depth);
+		/*
+		fprintf(fp,"\t\"state_history=");
+		for(x=0;x<MAX_STATE_HISTORY_ENTRIES;x++)
+			fprintf(fp,"%s%d",(x>0)?",":"",temp_service->state_history[(x+temp_service->state_history_index)%MAX_STATE_HISTORY_ENTRIES]);
+		fprintf(fp,"\n");
+		*/
+		fprintf(fp,"\t\t\t}");
+		
+		/* If there is another service */
+		if (temp_service->next != NULL) {
+		
+		/*If the service is next service is not located on the same host than the current on */	
+		if (strcmp(temp_service->host_name,temp_service->next->host_name)) 
+			fprintf(fp,"\n\t\t},\n");
+		else
+			fprintf(fp,",\n");
+		}
+		else 
+		/* If it is the last service*/
+		{
+		fprintf(fp,"\n\t\t}\n\t}\n}\n");	
+		}
+	        }
+		
+	
+	/* reset file permissions */
+	fchmod(fd,S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
+
+	/* close the temp file */
+	fclose(fp);
+
+	/* move the temp file to the status log (overwrite the old status log) */
+	if(my_rename(xsdjson_aggregate_temp_file,xsdjson_status_log)){
+
+		/* log an error */
+		snprintf(temp_buffer,sizeof(temp_buffer),"Error: Unable to update status data file '%s'!\n",xsdjson_status_log);
+		temp_buffer[sizeof(temp_buffer)-1]='\x0';
+		write_to_logs_and_console(temp_buffer,NSLOG_RUNTIME_ERROR,TRUE);
+
+		return ERROR;
+	        }
+
+	return OK;
+        }
+
+#endif
+
+
+
+#ifdef NSCGI
+
+/******************************************************************/
+/****************** DEFAULT DATA INPUT FUNCTIONS ******************/
+/******************************************************************/
+
+/* read all program, host, and service status information */
+int xsdjson_read_status_data(char *config_file,int options){
+#ifdef BAD_MMAP
+	char *input=NULL;
+	mmapfile *thefile;
+#else
+	char input[2048]="";
+	char *hostnametemp;
+	FILE *fp=NULL;
+#endif
+	int data_type=XSDJSON_NO_DATA;
+	hoststatus *temp_hoststatus=NULL;
+	servicestatus *temp_servicestatus=NULL;
+	char *var;
+	char *val;
+	int result;
+	int is_host_set=0;
+
+	/* grab configuration data */
+	result=xsdjson_grab_config_info(config_file);
+	if(result==ERROR)
+		return ERROR;
+
+	/* open the status file for reading */
+#ifdef BAD_MMAP
+	if((thefile=mmap_fopen(xsdjson_status_log))==NULL)
+		return ERROR;
+#else
+	if((fp=fopen(xsdjson_status_log,"r"))==NULL)
+		return ERROR;
+#endif
+
+	/* read all lines in the status file */
+	while(1){
+
+#ifdef BAD_MMAP
+		/* free memory */
+		free(input);
+
+		/* read the next line */
+		if((input=mmap_fgets(thefile))==NULL)
+			break;
+#else
+		strcpy(input,"");
+		if(fgets(input,sizeof(input),fp)==NULL)
+			break;
+#endif
+
+		strip(input);
+
+		/* skip blank lines and comments */
+		if(input[0]=='#' || input[0]=='\x0')
+			continue;
+
+		else if(!strcmp(input,"\"info\":{"))
+			data_type=XSDJSON_INFO_DATA;
+		else if(!strcmp(input,"\"program\":{"))
+			data_type=XSDJSON_PROGRAM_DATA;
+		else if(!strcmp(input,"\"host\":{")){
+			data_type=XSDJSON_HOST_DATA;
+			temp_hoststatus=(hoststatus *)malloc(sizeof(hoststatus));
+			if(temp_hoststatus){
+				temp_hoststatus->host_name=NULL;
+				temp_hoststatus->plugin_output=NULL;
+				temp_hoststatus->perf_data=NULL;
+			        }
+		        }
+		else if(!strcmp(input,"\"service\":{")){
+			data_type=XSDJSON_SERVICE_DATA;
+			temp_servicestatus=(servicestatus *)malloc(sizeof(servicestatus));
+			if(temp_servicestatus){
+				temp_servicestatus->host_name=NULL;
+				temp_servicestatus->description=NULL;
+				temp_servicestatus->plugin_output=NULL;
+				temp_servicestatus->perf_data=NULL;
+			        }
+		        }
+
+		else if(!strcmp(input,"}") || !strcmp(input,"},")){
+
+			
+			switch(data_type){
+
+			case XSDJSON_INFO_DATA:
+				if (!strcmp(input,"}"))
+				data_type=XSDJSON_NO_DATA;
+		        	
+				break;
+
+			case XSDJSON_PROGRAM_DATA:
+				if (!strcmp(input,"}"))
+				data_type=XSDJSON_NO_DATA;
+		        	
+				break;
+
+			case XSDJSON_HOST_DATA:
+				add_host_status(temp_hoststatus);
+				if (!strcmp(input,"}")){
+					temp_hoststatus=NULL;
+					data_type=XSDJSON_NO_DATA;
+					}
+				if (!strcmp(input,"},")){
+					temp_hoststatus=(hoststatus *)malloc(sizeof(hoststatus));
+					if(temp_hoststatus){
+						temp_hoststatus->host_name=NULL;
+						temp_hoststatus->plugin_output=NULL;
+						temp_hoststatus->perf_data=NULL;
+			        	}
+				}
+				break;
+
+			case XSDJSON_SERVICE_DATA:
+				
+				if (!strcmp(input,"}")){
+					if (is_host_set) {
+					add_service_status(temp_servicestatus);
+					is_host_set=0;
+					}
+					else {
+					temp_servicestatus=NULL;
+					data_type=XSDJSON_NO_DATA;
+					free(hostnametemp);
+					}
+				}
+						
+				if (!strcmp(input,"},")){
+					add_service_status(temp_servicestatus);
+					temp_servicestatus=(servicestatus *)malloc(sizeof(servicestatus));
+					if(temp_servicestatus){
+						temp_servicestatus->host_name=NULL;
+						temp_servicestatus->description=NULL;
+						temp_servicestatus->plugin_output=NULL;
+						temp_servicestatus->perf_data=NULL;
+					}
+				}
+
+				
+				break;
+
+			default:
+				break;
+			        }
+		        }
+
+		else if(data_type!=XSDJSON_NO_DATA){
+			
+			switch(data_type) {
+			
+				case XSDJSON_HOST_DATA:	
+				if(temp_hoststatus!=NULL){
+					if(strstr (input, "\":{")!=NULL) {
+						val=strtok(input,":");
+						strip_quotes(val);
+						temp_hoststatus->host_name=strdup(val);
+						continue;
+					}
+				}
+				break;
+
+				case XSDJSON_SERVICE_DATA:	
+				if(temp_servicestatus!=NULL){
+					if(strstr (input, "\":{")!=NULL) {
+						
+						val=strtok(input,":");
+						strip_quotes(val);
+						if (!is_host_set){
+						hostnametemp=strdup(val);
+						is_host_set=1;
+						}
+						else
+						{
+						temp_servicestatus->host_name=strdup(hostnametemp);	
+						temp_servicestatus->description=strdup(val);
+						}
+						continue;
+					}
+				}
+				break;
+
+			}
+			var=strtok(input,":");
+			val=strtok(NULL,",\n");
+			if(val==NULL)
+				continue;
+
+			switch(data_type){
+
+			case XSDJSON_INFO_DATA:
+				break;
+
+			case XSDJSON_PROGRAM_DATA:
+				/* NOTE: some vars are not read, as they are not used by the CGIs (modified attributes, event handler commands, etc.) */
+				if(!strcmp(var,"\"nagios_pid\""))
+					nagios_pid=atoi(val);
+				else if(!strcmp(var,"\"daemon_mode\""))
+					daemon_mode=(atoi(val)>0)?TRUE:FALSE;
+				else if(!strcmp(var,"\"program_start\""))
+					program_start=strtoul(val,NULL,10);
+				else if(!strcmp(var,"\"last_command_check\""))
+					last_command_check=strtoul(val,NULL,10);
+				else if(!strcmp(var,"\"last_log_rotation\""))
+					last_log_rotation=strtoul(val,NULL,10);
+				else if(!strcmp(var,"\"enable_notifications\""))
+					enable_notifications=(atoi(val)>0)?TRUE:FALSE;
+				else if(!strcmp(var,"\"active_service_checks_enabled\""))
+					execute_service_checks=(atoi(val)>0)?TRUE:FALSE;
+				else if(!strcmp(var,"\"passive_service_checks_enabled\""))
+					accept_passive_service_checks=(atoi(val)>0)?TRUE:FALSE;
+				else if(!strcmp(var,"\"active_host_checks_enabled\""))
+					execute_host_checks=(atoi(val)>0)?TRUE:FALSE;
+				else if(!strcmp(var,"\"passive_host_checks_enabled\""))
+					accept_passive_host_checks=(atoi(val)>0)?TRUE:FALSE;
+				else if(!strcmp(var,"\"enable_event_handlers\""))
+					enable_event_handlers=(atoi(val)>0)?TRUE:FALSE;
+				else if(!strcmp(var,"\"obsess_over_services\""))
+					obsess_over_services=(atoi(val)>0)?TRUE:FALSE;
+				else if(!strcmp(var,"\"obsess_over_hosts\""))
+					obsess_over_hosts=(atoi(val)>0)?TRUE:FALSE;
+				else if(!strcmp(var,"\"check_service_freshness\""))
+					check_service_freshness=(atoi(val)>0)?TRUE:FALSE;
+				else if(!strcmp(var,"\"check_host_freshness\""))
+					check_host_freshness=(atoi(val)>0)?TRUE:FALSE;
+				else if(!strcmp(var,"\"enable_flap_detection\""))
+					enable_flap_detection=(atoi(val)>0)?TRUE:FALSE;
+				else if(!strcmp(var,"\"enable_failure_prediction\""))
+					enable_failure_prediction=(atoi(val)>0)?TRUE:FALSE;
+				else if(!strcmp(var,"\"process_performance_data\""))
+					process_performance_data=(atoi(val)>0)?TRUE:FALSE;
+				break;
+
+			case XSDJSON_HOST_DATA:
+				/* NOTE: some vars are not read, as they are not used by the CGIs (modified attributes, event handler commands, etc.) */
+				if(temp_hoststatus!=NULL){
+					/*if(!strcmp(var,"\"host_name\"")) {
+						strip_quotes(val);
+						temp_hoststatus->host_name=strdup(val);}*/
+					if(!strcmp(var,"\"has_been_checked\""))
+						temp_hoststatus->has_been_checked=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"should_be_scheduled\""))
+						temp_hoststatus->should_be_scheduled=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"check_execution_time\""))
+						temp_hoststatus->execution_time=strtod(val,NULL);
+					else if(!strcmp(var,"\"check_latency\""))
+						temp_hoststatus->latency=strtod(val,NULL);
+					else if(!strcmp(var,"\"check_type\""))
+						temp_hoststatus->check_type=atoi(val);
+					else if(!strcmp(var,"\"current_state\""))
+						temp_hoststatus->status=atoi(val);
+					else if(!strcmp(var,"\"last_hard_state\""))
+						temp_hoststatus->last_hard_state=atoi(val);
+					else if(!strcmp(var,"\"plugin_output\"")){
+						strip_quotes(val);
+						temp_hoststatus->plugin_output=strdup(val);}
+					else if(!strcmp(var,"\"performance_data\"")){
+						strip_quotes(val);
+						temp_hoststatus->perf_data=strdup(val);}
+					else if(!strcmp(var,"\"current_attempt\""))
+						temp_hoststatus->current_attempt=atoi(val);
+					else if(!strcmp(var,"\"max_attempts\""))
+						temp_hoststatus->max_attempts=atoi(val);
+					else if(!strcmp(var,"\"last_check\""))
+						temp_hoststatus->last_check=strtoul(val,NULL,10);
+					else if(!strcmp(var,"\"next_check\""))
+						temp_hoststatus->next_check=strtoul(val,NULL,10);
+					else if(!strcmp(var,"\"current_attempt\""))
+						temp_hoststatus->current_attempt=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"state_type\""))
+						temp_hoststatus->state_type=atoi(val);
+					else if(!strcmp(var,"\"last_state_change\""))
+						temp_hoststatus->last_state_change=strtoul(val,NULL,10);
+					else if(!strcmp(var,"\"last_hard_state_change\""))
+						temp_hoststatus->last_hard_state_change=strtoul(val,NULL,10);
+					else if(!strcmp(var,"\"last_time_up\""))
+						temp_hoststatus->last_time_up=strtoul(val,NULL,10);
+					else if(!strcmp(var,"\"last_time_down\""))
+						temp_hoststatus->last_time_down=strtoul(val,NULL,10);
+					else if(!strcmp(var,"\"last_time_unreachable\""))
+						temp_hoststatus->last_time_unreachable=strtoul(val,NULL,10);
+					else if(!strcmp(var,"\"last_notification\""))
+						temp_hoststatus->last_notification=strtoul(val,NULL,10);
+					else if(!strcmp(var,"\"next_notification\""))
+						temp_hoststatus->next_notification=strtoul(val,NULL,10);
+					else if(!strcmp(var,"\"no_more_notifications\""))
+						temp_hoststatus->no_more_notifications=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"current_notification_number\""))
+						temp_hoststatus->current_notification_number=atoi(val);
+					else if(!strcmp(var,"\"notifications_enabled\""))
+						temp_hoststatus->notifications_enabled=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"problem_has_been_acknowledged\""))
+						temp_hoststatus->problem_has_been_acknowledged=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"acknowledgement_type\""))
+						temp_hoststatus->acknowledgement_type=atoi(val);
+					else if(!strcmp(var,"\"active_checks_enabled\""))
+						temp_hoststatus->checks_enabled=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"passive_checks_enabled\""))
+						temp_hoststatus->accept_passive_host_checks=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"event_handler_enabled\""))
+						temp_hoststatus->event_handler_enabled=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"flap_detection_enabled\""))
+						temp_hoststatus->flap_detection_enabled=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"failure_prediction_enabled\""))
+						temp_hoststatus->failure_prediction_enabled=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"process_performance_data\""))
+						temp_hoststatus->process_performance_data=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"obsess_over_host\""))
+						temp_hoststatus->obsess_over_host=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"last_update\""))
+						temp_hoststatus->last_update=strtoul(val,NULL,10);
+					else if(!strcmp(var,"\"is_flapping\""))
+						temp_hoststatus->is_flapping=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"percent_state_change\""))
+						temp_hoststatus->percent_state_change=strtod(val,NULL);
+					else if(!strcmp(var,"\"scheduled_downtime_depth\""))
+						temp_hoststatus->scheduled_downtime_depth=atoi(val);
+					/*
+					else if(!strcmp(var,"\"state_history\"")){
+						temp_ptr=val;
+						for(x=0;x<MAX_STATE_HISTORY_ENTRIES;x++)
+							temp_hoststatus->state_history[x]=atoi(my_strsep(&temp_ptr,","));
+						temp_hoststatus->state_history_index=0;
+					        }
+					*/
+				        }
+				break;
+
+			case XSDJSON_SERVICE_DATA:
+				/* NOTE: some vars are not read, as they are not used by the CGIs (modified attributes, event handler commands, etc.) */
+				if(temp_servicestatus!=NULL){
+					if(!strcmp(var,"\"host_name\"")){
+						strip_quotes(val);
+						temp_servicestatus->host_name=strdup(val);}
+					else if(!strcmp(var,"\"service_description\"")){
+						strip_quotes(val);
+						temp_servicestatus->description=strdup(val);}
+					else if(!strcmp(var,"\"has_been_checked\""))
+						temp_servicestatus->has_been_checked=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"should_be_scheduled\""))
+						temp_servicestatus->should_be_scheduled=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"check_execution_time\""))
+						temp_servicestatus->execution_time=strtod(val,NULL);
+					else if(!strcmp(var,"\"check_latency\""))
+						temp_servicestatus->latency=strtod(val,NULL);
+					else if(!strcmp(var,"\"check_type\""))
+						temp_servicestatus->check_type=atoi(val);
+					else if(!strcmp(var,"\"current_state\""))
+						temp_servicestatus->status=atoi(val);
+					else if(!strcmp(var,"\"last_hard_state\""))
+						temp_servicestatus->last_hard_state=atoi(val);
+					else if(!strcmp(var,"\"current_attempt\""))
+						temp_servicestatus->current_attempt=atoi(val);
+					else if(!strcmp(var,"\"max_attempts\""))
+						temp_servicestatus->max_attempts=atoi(val);
+					else if(!strcmp(var,"\"state_type\""))
+						temp_servicestatus->state_type=atoi(val);
+					else if(!strcmp(var,"\"last_state_change\""))
+						temp_servicestatus->last_state_change=strtoul(val,NULL,10);
+					else if(!strcmp(var,"\"last_hard_state_change\""))
+						temp_servicestatus->last_hard_state_change=strtoul(val,NULL,10);
+					else if(!strcmp(var,"\"last_time_ok\""))
+						temp_servicestatus->last_time_ok=strtoul(val,NULL,10);
+					else if(!strcmp(var,"\"last_time_warning\""))
+						temp_servicestatus->last_time_warning=strtoul(val,NULL,10);
+					else if(!strcmp(var,"\"last_time_unknown\""))
+						temp_servicestatus->last_time_unknown=strtoul(val,NULL,10);
+					else if(!strcmp(var,"\"last_time_critical\""))
+						temp_servicestatus->last_time_critical=strtoul(val,NULL,10);
+					else if(!strcmp(var,"\"plugin_output\"")) {
+						strip_quotes(val);
+						temp_servicestatus->plugin_output=strdup(val);}
+					else if(!strcmp(var,"\"performance_data\"")){
+						strip_quotes(val);
+						temp_servicestatus->perf_data=strdup(val);}
+					else if(!strcmp(var,"\"last_check\""))
+						temp_servicestatus->last_check=strtoul(val,NULL,10);
+					else if(!strcmp(var,"\"next_check\""))
+						temp_servicestatus->next_check=strtoul(val,NULL,10);
+					else if(!strcmp(var,"\"current_notification_number\""))
+						temp_servicestatus->current_notification_number=atoi(val);
+					else if(!strcmp(var,"\"last_notification\""))
+						temp_servicestatus->last_notification=strtoul(val,NULL,10);
+					else if(!strcmp(var,"\"next_notification\""))
+						temp_servicestatus->next_notification=strtoul(val,NULL,10);
+					else if(!strcmp(var,"\"no_more_notifications\""))
+						temp_servicestatus->no_more_notifications=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"notifications_enabled\""))
+						temp_servicestatus->notifications_enabled=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"active_checks_enabled\""))
+						temp_servicestatus->checks_enabled=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"passive_checks_enabled\""))
+						temp_servicestatus->accept_passive_service_checks=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"event_handler_enabled\""))
+						temp_servicestatus->event_handler_enabled=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"problem_has_been_acknowledged\""))
+						temp_servicestatus->problem_has_been_acknowledged=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"acknowledgement_type\""))
+						temp_servicestatus->acknowledgement_type=atoi(val);
+					else if(!strcmp(var,"\"flap_detection_enabled\""))
+						temp_servicestatus->flap_detection_enabled=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"failure_prediction_enabled\""))
+						temp_servicestatus->failure_prediction_enabled=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"process_performance_data\""))
+						temp_servicestatus->process_performance_data=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"obsess_over_service\""))
+						temp_servicestatus->obsess_over_service=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"last_update\""))
+						temp_servicestatus->last_update=strtoul(val,NULL,10);
+					else if(!strcmp(var,"\"is_flapping\""))
+						temp_servicestatus->is_flapping=(atoi(val)>0)?TRUE:FALSE;
+					else if(!strcmp(var,"\"percent_state_change\""))
+						temp_servicestatus->percent_state_change=strtod(val,NULL);
+					else if(!strcmp(var,"\"scheduled_downtime_depth\""))
+						temp_servicestatus->scheduled_downtime_depth=atoi(val);
+					/*
+					else if(!strcmp(var,"\"state_history\"")){
+						temp_ptr=val;
+						for(x=0;x<MAX_STATE_HISTORY_ENTRIES;x++)
+							temp_servicestatus->state_history[x]=atoi(my_strsep(&temp_ptr,","));
+						temp_servicestatus->state_history_index=0;
+					        }
+					*/
+				        }
+				break;
+
+			default:
+				break;
+			        }
+
+		        }
+	        }
+
+	/* free memory and close the file */
+#ifdef BAD_MMAP
+	free(input);
+	mmap_fclose(thefile);
+#else
+	fclose(fp);
+#endif
+
+	return OK;
+        }
+
+#endif
+
+
+void strip_quotes(char *string) {
+int i=0;
+int j=0;
+
+for (i=0;i<strlen(string);i++) {
+	if (string[i]=='"'){
+		for (j=i;j<strlen(string);j++)
+			string[j]=string[j+1]; }
+	}
+
+}
+
+
diff -uNr nagios.orig/xdata/xsdjson.h nagios/xdata/xsdjson.h
--- nagios.orig/xdata/xsdjson.h	1969-12-31 19:00:00.000000000 -0500
+++ nagios/xdata/xsdjson.h	2008-06-15 09:47:04.000000000 -0400
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ *
+ * XSDJSON.H - Header file for default status data routines
+ *
+ * Copyright (c) 2008 Yann Jouanin (yann.jouanin@intelunix.fr)
+ * Last Modified:   06-15-2008
+ *
+ * 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.
+ *
+ *****************************************************************************/
+
+#ifdef NSCORE
+int xsdjson_initialize_status_data(char *);
+int xsdjson_cleanup_status_data(char *,int);
+int xsdjson_save_status_data(void);
+#endif
+
+#ifdef NSCGI
+
+#define XSDJSON_NO_DATA          0
+#define XSDJSON_INFO_DATA        1
+#define XSDJSON_PROGRAM_DATA     2
+#define XSDJSON_HOST_DATA        3
+#define XSDJSON_SERVICE_DATA     4
+
+int xsdjson_read_status_data(char *,int);
+#endif
+
+int xsdjson_grab_config_info(char *);
+void xsdjson_grab_config_directives(char *);
+void strip_quotes(char *string);
