\n");
+ }
+
+
+ /* step 2 - the user wants to select a hostgroup */
+ else if(select_hostgroups == TRUE) {
+ printf("
Step 2: Select Hostgroup
\n");
+
+ printf("
\n");
+
+ printf("\n");
+
+ printf("
\n");
+ }
+
+ /* step 2 - the user wants to select a host */
+ else if(select_hosts == TRUE) {
+ printf("
Step 2: Select Host
\n");
+
+ printf("
\n");
+
+ printf("\n");
+
+ printf("
\n");
+
+ printf("
Tip: If you want to have the option of getting the availability data in CSV format, select '** ALL HOSTS **' from the pull-down menu.\n");
+ }
+
+ /* step 2 - the user wants to select a servicegroup */
+ else if(select_servicegroups == TRUE) {
+ printf("
Step 2: Select Servicegroup
\n");
+
+ printf("
\n");
+
+ printf("\n");
+
+ printf("
\n");
+ }
+
+ /* step 2 - the user wants to select a service */
+ else if(select_services == TRUE) {
+
+ printf("\n");
+
+ printf("
Step 2: Select Service
\n");
+
+ printf("
\n");
+
+ printf("\n");
+
+ printf("
\n");
+
+ printf("
Tip: If you want to have the option of getting the availability data in CSV format, select '** ALL SERVICES **' from the pull-down menu.\n");
+ }
+
+
+ /* generate availability report */
+ else if(display_type != DISPLAY_NO_AVAIL) {
+
+ /* check authorization */
+ is_authorized = TRUE;
+ if((display_type == DISPLAY_HOST_AVAIL && show_all_hosts == FALSE) || (display_type == DISPLAY_SERVICE_AVAIL && show_all_services == FALSE)) {
+
+ if(display_type == DISPLAY_HOST_AVAIL && show_all_hosts == FALSE)
+ is_authorized = is_authorized_for_host(find_host(host_name), ¤t_authdata);
+ else
+ is_authorized = is_authorized_for_service(find_service(host_name, svc_description), ¤t_authdata);
+ }
+
+ if(is_authorized == FALSE)
+ printf("
It appears as though you are not authorized to view information for the specified %s...
\n", (display_type == DISPLAY_HOST_AVAIL) ? "host" : "service");
+
+ else {
+
+ time(&report_start_time);
+
+ /* create list of subjects to collect availability data for */
+ create_subject_list();
+
+ /* read in all necessary archived state data */
+ read_archived_state_data();
+
+ /* compute availability data */
+ compute_availability();
+
+ time(&report_end_time);
+
+ if(output_format == HTML_OUTPUT) {
+ get_time_breakdown((time_t)(report_end_time - report_start_time), &days, &hours, &minutes, &seconds);
+ printf("
[ Availability report completed in %d min %d sec ]
\n", minutes, seconds);
+ printf("
\n");
+ }
+
+ /* display availability data */
+ if(display_type == DISPLAY_HOST_AVAIL)
+ display_host_availability();
+ else if(display_type == DISPLAY_SERVICE_AVAIL)
+ display_service_availability();
+ else if(display_type == DISPLAY_HOSTGROUP_AVAIL)
+ display_hostgroup_availability();
+ else if(display_type == DISPLAY_SERVICEGROUP_AVAIL)
+ display_servicegroup_availability();
+
+ /* free memory allocated to availability data */
+ free_availability_data();
+ }
+ }
+
+
+ /* step 1 - ask the user what kind of report they want */
+ else {
+
+ printf("
Step 1: Select Report Type
\n");
+
+ printf("
\n");
+
+ printf("\n");
+
+ printf("
\n");
+ }
+
+
+ document_footer();
+
+ /* free all other allocated memory */
+ free_memory();
+
+ return OK;
+ }
+
+
+
+void document_header(int use_stylesheet) {
+ char date_time[MAX_DATETIME_LENGTH];
+ time_t current_time;
+ time_t expire_time;
+
+ printf("Cache-Control: no-store\r\n");
+ printf("Pragma: no-cache\r\n");
+
+ time(¤t_time);
+ get_time_string(¤t_time, date_time, sizeof(date_time), HTTP_DATE_TIME);
+ printf("Last-Modified: %s\r\n", date_time);
+
+ expire_time = (time_t)0;
+ get_time_string(&expire_time, date_time, sizeof(date_time), HTTP_DATE_TIME);
+ printf("Expires: %s\r\n", date_time);
+
+ if(output_format == HTML_OUTPUT)
+ printf("Content-type: text/html\r\n\r\n");
+ else {
+ printf("Content-type: text/csv\r\n\r\n");
+ return;
+ }
+
+ if(embedded == TRUE || output_format == CSV_OUTPUT)
+ return;
+
+ printf("\n");
+ printf("\n");
+ printf("\n", url_images_path);
+ printf("\n");
+ printf("Nagios Availability\n");
+ printf("\n");
+
+ if(use_stylesheet == TRUE) {
+ printf("\n", url_stylesheets_path, COMMON_CSS);
+ printf("\n", url_stylesheets_path, AVAIL_CSS);
+ }
+
+ printf("\n");
+
+ printf("\n");
+
+ /* include user SSI header */
+ include_ssi_files(AVAIL_CGI, SSI_HEADER);
+
+ return;
+ }
+
+
+
+void document_footer(void) {
+
+ if(output_format != HTML_OUTPUT)
+ return;
+
+ if(embedded == TRUE)
+ return;
+
+ /* include user SSI footer */
+ include_ssi_files(AVAIL_CGI, SSI_FOOTER);
+
+ printf("\n");
+ printf("\n");
+
+ return;
+ }
+
+
+
+int process_cgivars(void) {
+ char **variables;
+ int error = FALSE;
+ int x;
+
+ variables = getcgivars();
+
+ for(x = 0; variables[x] != NULL; x++) {
+
+ /* do some basic length checking on the variable identifier to prevent buffer overflows */
+ if(strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) {
+ x++;
+ continue;
+ }
+
+ /* we found the hostgroup argument */
+ else if(!strcmp(variables[x], "hostgroup")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if((hostgroup_name = (char *)strdup(variables[x])) == NULL)
+ hostgroup_name = "";
+ strip_html_brackets(hostgroup_name);
+
+ display_type = DISPLAY_HOSTGROUP_AVAIL;
+ show_all_hostgroups = (strcmp(hostgroup_name, "all")) ? FALSE : TRUE;
+ }
+
+ /* we found the servicegroup argument */
+ else if(!strcmp(variables[x], "servicegroup")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if((servicegroup_name = (char *)strdup(variables[x])) == NULL)
+ servicegroup_name = "";
+ strip_html_brackets(servicegroup_name);
+
+ display_type = DISPLAY_SERVICEGROUP_AVAIL;
+ show_all_servicegroups = (strcmp(servicegroup_name, "all")) ? FALSE : TRUE;
+ }
+
+ /* we found the host argument */
+ else if(!strcmp(variables[x], "host")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if((host_name = (char *)strdup(variables[x])) == NULL)
+ host_name = "";
+ strip_html_brackets(host_name);
+
+ display_type = DISPLAY_HOST_AVAIL;
+ show_all_hosts = (strcmp(host_name, "all")) ? FALSE : TRUE;
+ }
+
+ /* we found the service description argument */
+ else if(!strcmp(variables[x], "service")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if((svc_description = (char *)strdup(variables[x])) == NULL)
+ svc_description = "";
+ strip_html_brackets(svc_description);
+
+ display_type = DISPLAY_SERVICE_AVAIL;
+ show_all_services = (strcmp(svc_description, "all")) ? FALSE : TRUE;
+ }
+
+ /* we found first time argument */
+ else if(!strcmp(variables[x], "t1")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ t1 = (time_t)strtoul(variables[x], NULL, 10);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = FALSE;
+ }
+
+ /* we found first time argument */
+ else if(!strcmp(variables[x], "t2")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ t2 = (time_t)strtoul(variables[x], NULL, 10);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = FALSE;
+ }
+
+ /* we found the assume initial states option */
+ else if(!strcmp(variables[x], "assumeinitialstates")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(!strcmp(variables[x], "yes"))
+ assume_initial_states = TRUE;
+ else
+ assume_initial_states = FALSE;
+ }
+
+ /* we found the assume state during program not running option */
+ else if(!strcmp(variables[x], "assumestatesduringnotrunning")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(!strcmp(variables[x], "yes"))
+ assume_states_during_notrunning = TRUE;
+ else
+ assume_states_during_notrunning = FALSE;
+ }
+
+ /* we found the initial assumed host state option */
+ else if(!strcmp(variables[x], "initialassumedhoststate")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ initial_assumed_host_state = atoi(variables[x]);
+ }
+
+ /* we found the initial assumed service state option */
+ else if(!strcmp(variables[x], "initialassumedservicestate")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ initial_assumed_service_state = atoi(variables[x]);
+ }
+
+ /* we found the assume state retention option */
+ else if(!strcmp(variables[x], "assumestateretention")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(!strcmp(variables[x], "yes"))
+ assume_state_retention = TRUE;
+ else
+ assume_state_retention = FALSE;
+ }
+
+ /* we found the include soft states option */
+ else if(!strcmp(variables[x], "includesoftstates")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(!strcmp(variables[x], "yes"))
+ include_soft_states = TRUE;
+ else
+ include_soft_states = FALSE;
+ }
+
+ /* we found the backtrack archives argument */
+ else if(!strcmp(variables[x], "backtrack")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ backtrack_archives = atoi(variables[x]);
+ if(backtrack_archives < 0)
+ backtrack_archives = 0;
+ if(backtrack_archives > MAX_ARCHIVE_BACKTRACKS)
+ backtrack_archives = MAX_ARCHIVE_BACKTRACKS;
+
+#ifdef DEBUG
+ printf("BACKTRACK ARCHIVES: %d\n", backtrack_archives);
+#endif
+ }
+
+ /* we found the standard timeperiod argument */
+ else if(!strcmp(variables[x], "timeperiod")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(!strcmp(variables[x], "today"))
+ timeperiod_type = TIMEPERIOD_TODAY;
+ else if(!strcmp(variables[x], "yesterday"))
+ timeperiod_type = TIMEPERIOD_YESTERDAY;
+ else if(!strcmp(variables[x], "thisweek"))
+ timeperiod_type = TIMEPERIOD_THISWEEK;
+ else if(!strcmp(variables[x], "lastweek"))
+ timeperiod_type = TIMEPERIOD_LASTWEEK;
+ else if(!strcmp(variables[x], "thismonth"))
+ timeperiod_type = TIMEPERIOD_THISMONTH;
+ else if(!strcmp(variables[x], "lastmonth"))
+ timeperiod_type = TIMEPERIOD_LASTMONTH;
+ else if(!strcmp(variables[x], "thisquarter"))
+ timeperiod_type = TIMEPERIOD_THISQUARTER;
+ else if(!strcmp(variables[x], "lastquarter"))
+ timeperiod_type = TIMEPERIOD_LASTQUARTER;
+ else if(!strcmp(variables[x], "thisyear"))
+ timeperiod_type = TIMEPERIOD_THISYEAR;
+ else if(!strcmp(variables[x], "lastyear"))
+ timeperiod_type = TIMEPERIOD_LASTYEAR;
+ else if(!strcmp(variables[x], "last24hours"))
+ timeperiod_type = TIMEPERIOD_LAST24HOURS;
+ else if(!strcmp(variables[x], "last7days"))
+ timeperiod_type = TIMEPERIOD_LAST7DAYS;
+ else if(!strcmp(variables[x], "last31days"))
+ timeperiod_type = TIMEPERIOD_LAST31DAYS;
+ else if(!strcmp(variables[x], "custom"))
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ else
+ continue;
+
+ convert_timeperiod_to_times(timeperiod_type);
+ compute_time_from_parts = FALSE;
+ }
+
+ /* we found the embed option */
+ else if(!strcmp(variables[x], "embedded"))
+ embedded = TRUE;
+
+ /* we found the noheader option */
+ else if(!strcmp(variables[x], "noheader"))
+ display_header = FALSE;
+
+ /* we found the CSV output option */
+ else if(!strcmp(variables[x], "csvoutput")) {
+ display_header = FALSE;
+ output_format = CSV_OUTPUT;
+ }
+
+ /* we found the log entries option */
+ else if(!strcmp(variables[x], "show_log_entries"))
+ show_log_entries = TRUE;
+
+ /* we found the full log entries option */
+ else if(!strcmp(variables[x], "full_log_entries"))
+ full_log_entries = TRUE;
+
+ /* we found the get date parts option */
+ else if(!strcmp(variables[x], "get_date_parts"))
+ get_date_parts = TRUE;
+
+ /* we found the report type selection option */
+ else if(!strcmp(variables[x], "report_type")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+ if(!strcmp(variables[x], "hostgroups"))
+ select_hostgroups = TRUE;
+ else if(!strcmp(variables[x], "servicegroups"))
+ select_servicegroups = TRUE;
+ else if(!strcmp(variables[x], "hosts"))
+ select_hosts = TRUE;
+ else
+ select_services = TRUE;
+ }
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "smon")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ start_month = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "sday")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ start_day = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "syear")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ start_year = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "smin")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ start_minute = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "ssec")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ start_second = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "shour")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ start_hour = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "emon")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ end_month = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "eday")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ end_day = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "eyear")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ end_year = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "emin")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ end_minute = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "esec")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ end_second = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "ehour")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ end_hour = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+ /* we found the show scheduled downtime option */
+ else if(!strcmp(variables[x], "showscheduleddowntime")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(!strcmp(variables[x], "yes"))
+ show_scheduled_downtime = TRUE;
+ else
+ show_scheduled_downtime = FALSE;
+ }
+
+ /* we found the report timeperiod option */
+ else if(!strcmp(variables[x], "rpttimeperiod")) {
+ timeperiod *temp_timeperiod;
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ for(temp_timeperiod = timeperiod_list; temp_timeperiod != NULL; temp_timeperiod = temp_timeperiod->next) {
+ if(!strcmp(url_encode(temp_timeperiod->name), variables[x])) {
+ current_timeperiod = temp_timeperiod;
+ break;
+ }
+ }
+ }
+
+ }
+
+ /* free memory allocated to the CGI variables */
+ free_cgivars(variables);
+
+ return error;
+ }
+
+
+
+/* computes availability data for all subjects */
+void compute_availability(void) {
+ avail_subject *temp_subject;
+ time_t current_time;
+
+ time(¤t_time);
+
+ for(temp_subject = subject_list; temp_subject != NULL; temp_subject = temp_subject->next) {
+ compute_subject_availability(temp_subject, current_time);
+ compute_subject_downtime(temp_subject, current_time);
+ }
+
+ return;
+ }
+
+
+
+/* computes availability data for a given subject */
+void compute_subject_availability(avail_subject *subject, time_t current_time) {
+ archived_state *temp_as;
+ archived_state *last_as;
+ time_t a;
+ time_t b;
+ int current_state = AS_NO_DATA;
+ int have_some_real_data = FALSE;
+ hoststatus *hststatus = NULL;
+ servicestatus *svcstatus = NULL;
+ int first_real_state = AS_NO_DATA;
+ time_t initial_assumed_time;
+ int initial_assumed_state = AS_NO_DATA;
+ int error;
+
+
+ /* if left hand of graph is after current time, we can't do anything at all.... */
+ if(t1 > current_time)
+ return;
+
+ /* get current state of host or service if possible */
+ if(subject->type == HOST_SUBJECT)
+ hststatus = find_hoststatus(subject->host_name);
+ else
+ svcstatus = find_servicestatus(subject->host_name, subject->service_description);
+
+
+ /************************************/
+ /* INSERT CURRENT STATE (IF WE CAN) */
+ /************************************/
+
+ /* if current time DOES NOT fall within graph bounds, so we can't do anything as far as assuming current state */
+
+ /* if we don't have any data, assume current state (if possible) */
+ if(subject->as_list == NULL && current_time > t1 && current_time <= t2) {
+
+ /* we don't have any historical information, but the current time falls within the reporting period, so use */
+ /* the current status of the host/service as the starting data */
+ if(subject->type == HOST_SUBJECT) {
+ if(hststatus != NULL) {
+
+ if(hststatus->status == HOST_DOWN)
+ subject->last_known_state = AS_HOST_DOWN;
+ else if(hststatus->status == HOST_UNREACHABLE)
+ subject->last_known_state = AS_HOST_UNREACHABLE;
+ else if(hststatus->status == HOST_UP)
+ subject->last_known_state = AS_HOST_UP;
+ else
+ subject->last_known_state = AS_NO_DATA;
+
+ if(subject->last_known_state != AS_NO_DATA) {
+
+ /* add a dummy archived state item, so something can get graphed */
+ add_archived_state(subject->last_known_state, AS_HARD_STATE, t1, "Current Host State Assumed (Faked Log Entry)", subject);
+
+ /* use the current state as the last known real state */
+ first_real_state = subject->last_known_state;
+ }
+ }
+ }
+ else {
+ if(svcstatus != NULL) {
+
+ if(svcstatus->status == SERVICE_OK)
+ subject->last_known_state = AS_SVC_OK;
+ else if(svcstatus->status == SERVICE_WARNING)
+ subject->last_known_state = AS_SVC_WARNING;
+ else if(svcstatus->status == SERVICE_CRITICAL)
+ subject->last_known_state = AS_SVC_CRITICAL;
+ else if(svcstatus->status == SERVICE_UNKNOWN)
+ subject->last_known_state = AS_SVC_UNKNOWN;
+ else
+ subject->last_known_state = AS_NO_DATA;
+
+ if(subject->last_known_state != AS_NO_DATA) {
+
+ /* add a dummy archived state item, so something can get graphed */
+ add_archived_state(subject->last_known_state, AS_HARD_STATE, t1, "Current Service State Assumed (Faked Log Entry)", subject);
+
+ /* use the current state as the last known real state */
+ first_real_state = subject->last_known_state;
+ }
+ }
+ }
+ }
+
+
+
+ /******************************************/
+ /* INSERT FIRST ASSUMED STATE (IF WE CAN) */
+ /******************************************/
+
+ if((subject->type == HOST_SUBJECT && initial_assumed_host_state != AS_NO_DATA) || (subject->type == SERVICE_SUBJECT && initial_assumed_service_state != AS_NO_DATA)) {
+
+ /* see if its okay to assume initial state for this subject */
+ error = FALSE;
+ if(subject->type == SERVICE_SUBJECT) {
+ if(initial_assumed_service_state != AS_SVC_OK && initial_assumed_service_state != AS_SVC_WARNING && initial_assumed_service_state != AS_SVC_UNKNOWN && initial_assumed_service_state != AS_SVC_CRITICAL && initial_assumed_service_state != AS_CURRENT_STATE)
+ error = TRUE;
+ else
+ initial_assumed_state = initial_assumed_service_state;
+ if(initial_assumed_service_state == AS_CURRENT_STATE && svcstatus == NULL)
+ error = TRUE;
+ }
+ else {
+ if(initial_assumed_host_state != AS_HOST_UP && initial_assumed_host_state != AS_HOST_DOWN && initial_assumed_host_state != AS_HOST_UNREACHABLE && initial_assumed_host_state != AS_CURRENT_STATE)
+ error = TRUE;
+ else
+ initial_assumed_state = initial_assumed_host_state;
+ if(initial_assumed_host_state == AS_CURRENT_STATE && hststatus == NULL)
+ error = TRUE;
+ }
+
+ /* get the current state if applicable */
+ if(((subject->type == HOST_SUBJECT && initial_assumed_host_state == AS_CURRENT_STATE) || (subject->type == SERVICE_SUBJECT && initial_assumed_service_state == AS_CURRENT_STATE)) && error == FALSE) {
+ if(subject->type == SERVICE_SUBJECT) {
+ switch(svcstatus->status) {
+ case SERVICE_OK:
+ initial_assumed_state = AS_SVC_OK;
+ break;
+ case SERVICE_WARNING:
+ initial_assumed_state = AS_SVC_WARNING;
+ break;
+ case SERVICE_UNKNOWN:
+ initial_assumed_state = AS_SVC_UNKNOWN;
+ break;
+ case SERVICE_CRITICAL:
+ initial_assumed_state = AS_SVC_CRITICAL;
+ break;
+ default:
+ error = TRUE;
+ break;
+ }
+ }
+ else {
+ switch(hststatus->status) {
+ case HOST_DOWN:
+ initial_assumed_state = AS_HOST_DOWN;
+ break;
+ case HOST_UNREACHABLE:
+ initial_assumed_state = AS_HOST_UNREACHABLE;
+ break;
+ case HOST_UP:
+ initial_assumed_state = AS_HOST_UP;
+ break;
+ default:
+ error = TRUE;
+ break;
+ }
+ }
+ }
+
+ if(error == FALSE) {
+
+ /* add this assumed state entry before any entries in the list and <= t1 */
+ if(subject->as_list == NULL)
+ initial_assumed_time = t1;
+ else if(subject->as_list->time_stamp > t1)
+ initial_assumed_time = t1;
+ else
+ initial_assumed_time = subject->as_list->time_stamp - 1;
+
+ if(subject->type == HOST_SUBJECT)
+ add_archived_state(initial_assumed_state, AS_HARD_STATE, initial_assumed_time, "First Host State Assumed (Faked Log Entry)", subject);
+ else
+ add_archived_state(initial_assumed_state, AS_HARD_STATE, initial_assumed_time, "First Service State Assumed (Faked Log Entry)", subject);
+ }
+ }
+
+
+
+
+ /**************************************/
+ /* BAIL OUT IF WE DON'T HAVE ANYTHING */
+ /**************************************/
+
+ have_some_real_data = FALSE;
+ for(temp_as = subject->as_list; temp_as != NULL; temp_as = temp_as->next) {
+ if(temp_as->entry_type != AS_NO_DATA && temp_as->entry_type != AS_PROGRAM_START && temp_as->entry_type != AS_PROGRAM_END) {
+ have_some_real_data = TRUE;
+ break;
+ }
+ }
+ if(have_some_real_data == FALSE)
+ return;
+
+
+
+
+ last_as = NULL;
+ subject->earliest_time = t2;
+ subject->latest_time = t1;
+
+
+#ifdef DEBUG
+ printf("--- BEGINNING/MIDDLE SECTION --- \n");
+#endif
+
+ /**********************************/
+ /* BEGINNING/MIDDLE SECTION */
+ /**********************************/
+
+ for(temp_as = subject->as_list; temp_as != NULL; temp_as = temp_as->next) {
+
+ /* keep this as last known state if this is the first entry or if it occurs before the starting point of the graph */
+ if((temp_as->time_stamp <= t1 || temp_as == subject->as_list) && (temp_as->entry_type != AS_NO_DATA && temp_as->entry_type != AS_PROGRAM_END && temp_as->entry_type != AS_PROGRAM_START)) {
+ subject->last_known_state = temp_as->entry_type;
+#ifdef DEBUG
+ printf("SETTING LAST KNOWN STATE=%d \n", subject->last_known_state);
+#endif
+ }
+
+ /* skip this entry if it occurs before the starting point of the graph */
+ if(temp_as->time_stamp <= t1) {
+#ifdef DEBUG
+ printf("SKIPPING PRE-EVENT: %d @ %lu \n", temp_as->entry_type, temp_as->time_stamp);
+#endif
+ last_as = temp_as;
+ continue;
+ }
+
+ /* graph this span if we're not on the first item */
+ if(last_as != NULL) {
+
+ a = last_as->time_stamp;
+ b = temp_as->time_stamp;
+
+ /* we've already passed the last time displayed in the graph */
+ if(a > t2)
+ break;
+
+ /* only graph this data if its on the graph */
+ else if(b > t1) {
+
+ /* clip last time if it exceeds graph limits */
+ if(b > t2)
+ b = t2;
+
+ /* clip first time if it precedes graph limits */
+ if(a < t1)
+ a = t1;
+
+ /* save this time if its the earliest we've graphed */
+ if(a < subject->earliest_time) {
+ subject->earliest_time = a;
+ subject->earliest_state = last_as->entry_type;
+ }
+
+ /* save this time if its the latest we've graphed */
+ if(b > subject->latest_time) {
+ subject->latest_time = b;
+ subject->latest_state = last_as->entry_type;
+ }
+
+ /* compute availability times for this chunk */
+ compute_subject_availability_times(last_as->entry_type, temp_as->entry_type, last_as->time_stamp, a, b, subject, temp_as);
+
+ /* return if we've reached the end of the graph limits */
+ if(b >= t2) {
+ last_as = temp_as;
+ break;
+ }
+ }
+ }
+
+
+ /* keep track of the last item */
+ last_as = temp_as;
+ }
+
+
+#ifdef DEBUG
+ printf("--- END SECTION --- \n");
+#endif
+
+ /**********************************/
+ /* END SECTION */
+ /**********************************/
+
+ if(last_as != NULL) {
+
+ /* don't process an entry that is beyond the limits of the graph */
+ if(last_as->time_stamp < t2) {
+
+ time(¤t_time);
+ b = current_time;
+ if(b > t2)
+ b = t2;
+
+ a = last_as->time_stamp;
+ if(a < t1)
+ a = t1;
+
+ /* fake the current state (it doesn't really matter for graphing) */
+ if(subject->type == HOST_SUBJECT)
+ current_state = AS_HOST_UP;
+ else
+ current_state = AS_SVC_OK;
+
+ /* compute availability times for last state */
+ compute_subject_availability_times(last_as->entry_type, current_state, last_as->time_stamp, a, b, subject, last_as);
+ }
+ }
+
+
+ return;
+ }
+
+
+/* computes availability times */
+void compute_subject_availability_times(int first_state, int last_state, time_t real_start_time, time_t start_time, time_t end_time, avail_subject *subject, archived_state *as) {
+ int start_state;
+ int end_state;
+ unsigned long state_duration;
+ struct tm *t;
+ unsigned long midnight_today;
+ int weekday;
+ timerange *temp_timerange;
+ unsigned long temp_duration;
+ unsigned long temp_end;
+ unsigned long temp_start;
+ unsigned long start;
+ unsigned long end;
+
+#ifdef DEBUG
+ if(subject->type == HOST_SUBJECT)
+ printf("HOST '%s'...\n", subject->host_name);
+ else
+ printf("SERVICE '%s' ON HOST '%s'...\n", subject->service_description, subject->host_name);
+
+ printf("COMPUTING %d->%d FROM %lu to %lu (%lu seconds) FOR %s \n", first_state, last_state, start_time, end_time, (end_time - start_time), (subject->type == HOST_SUBJECT) ? "HOST" : "SERVICE");
+#endif
+
+ /* clip times if necessary */
+ if(start_time < t1)
+ start_time = t1;
+ if(end_time > t2)
+ end_time = t2;
+
+ /* make sure this is a valid time */
+ if(start_time > t2)
+ return;
+ if(end_time < t1)
+ return;
+
+ /* MickeM - attempt to handle the current time_period (if any) */
+ if(current_timeperiod != NULL) {
+ t = localtime((time_t *)&start_time);
+ state_duration = 0;
+
+ /* calculate the start of the day (midnight, 00:00 hours) */
+ t->tm_sec = 0;
+ t->tm_min = 0;
+ t->tm_hour = 0;
+ t->tm_isdst = -1;
+ midnight_today = (unsigned long)mktime(t);
+ weekday = t->tm_wday;
+
+ while(midnight_today < end_time) {
+ temp_duration = 0;
+ temp_end = min(86400, end_time - midnight_today);
+ temp_start = 0;
+ if(start_time > midnight_today)
+ temp_start = start_time - midnight_today;
+#ifdef DEBUG
+ printf("Matching: %ld -> %ld. (%ld -> %ld) \n", temp_start, temp_end, midnight_today + temp_start, midnight_today + temp_end);
+#endif
+ /* check all time ranges for this day of the week */
+ for(temp_timerange = current_timeperiod->days[weekday]; temp_timerange != NULL; temp_timerange = temp_timerange->next) {
+
+#ifdef DEBUG
+ printf("
\n");
+ }
+
+ /* get archive to use */
+ get_log_archive_to_use(archive, archive_file, sizeof(archive_file) - 1);
+
+ /* cut the pathname for security, and the remaining slash for clarity */
+ archive_basename = (char *)&archive_file;
+ if(strrchr((char *)&archive_basename, '/') != NULL)
+ archive_basename = strrchr((char *)&archive_file, '/') + 1;
+
+ /* now it's safe to print the filename */
+ printf("
File: %s
\n", archive_basename);
+
+ return;
+ }
+
+
+
+/* prints the additional notes or action url for a hostgroup (with macros substituted) */
+void print_extra_hostgroup_url(char *group_name, char *url) {
+ char input_buffer[MAX_INPUT_BUFFER] = "";
+ char output_buffer[MAX_INPUT_BUFFER] = "";
+ char *temp_buffer;
+ int in_macro = FALSE;
+ hostgroup *temp_hostgroup = NULL;
+
+ if(group_name == NULL || url == NULL)
+ return;
+
+ temp_hostgroup = find_hostgroup(group_name);
+ if(temp_hostgroup == NULL) {
+ printf("%s", url);
+ return;
+ }
+
+ strncpy(input_buffer, url, sizeof(input_buffer) - 1);
+ input_buffer[sizeof(input_buffer) - 1] = '\x0';
+
+ for(temp_buffer = my_strtok(input_buffer, "$"); temp_buffer != NULL; temp_buffer = my_strtok(NULL, "$")) {
+
+ if(in_macro == FALSE) {
+ if(strlen(output_buffer) + strlen(temp_buffer) < sizeof(output_buffer) - 1) {
+ strncat(output_buffer, temp_buffer, sizeof(output_buffer) - strlen(output_buffer) - 1);
+ output_buffer[sizeof(output_buffer) - 1] = '\x0';
+ }
+ in_macro = TRUE;
+ }
+ else {
+
+ if(strlen(output_buffer) + strlen(temp_buffer) < sizeof(output_buffer) - 1) {
+
+ if(!strcmp(temp_buffer, "HOSTGROUPNAME"))
+ strncat(output_buffer, url_encode(temp_hostgroup->group_name), sizeof(output_buffer) - strlen(output_buffer) - 1);
+ }
+
+ in_macro = FALSE;
+ }
+ }
+
+ printf("%s", output_buffer);
+
+ return;
+ }
+
+
+
+/* prints the additional notes or action url for a servicegroup (with macros substituted) */
+void print_extra_servicegroup_url(char *group_name, char *url) {
+ char input_buffer[MAX_INPUT_BUFFER] = "";
+ char output_buffer[MAX_INPUT_BUFFER] = "";
+ char *temp_buffer;
+ int in_macro = FALSE;
+ servicegroup *temp_servicegroup = NULL;
+
+ if(group_name == NULL || url == NULL)
+ return;
+
+ temp_servicegroup = find_servicegroup(group_name);
+ if(temp_servicegroup == NULL) {
+ printf("%s", url);
+ return;
+ }
+
+ strncpy(input_buffer, url, sizeof(input_buffer) - 1);
+ input_buffer[sizeof(input_buffer) - 1] = '\x0';
+
+ for(temp_buffer = my_strtok(input_buffer, "$"); temp_buffer != NULL; temp_buffer = my_strtok(NULL, "$")) {
+
+ if(in_macro == FALSE) {
+ if(strlen(output_buffer) + strlen(temp_buffer) < sizeof(output_buffer) - 1) {
+ strncat(output_buffer, temp_buffer, sizeof(output_buffer) - strlen(output_buffer) - 1);
+ output_buffer[sizeof(output_buffer) - 1] = '\x0';
+ }
+ in_macro = TRUE;
+ }
+ else {
+
+ if(strlen(output_buffer) + strlen(temp_buffer) < sizeof(output_buffer) - 1) {
+
+ if(!strcmp(temp_buffer, "SERVICEGROUPNAME"))
+ strncat(output_buffer, url_encode(temp_servicegroup->group_name), sizeof(output_buffer) - strlen(output_buffer) - 1);
+ }
+
+ in_macro = FALSE;
+ }
+ }
+
+ printf("%s", output_buffer);
+
+ return;
+ }
+
+
+
+/* include user-defined SSI footers or headers */
+void include_ssi_files(char *cgi_name, int type) {
+ char common_ssi_file[MAX_INPUT_BUFFER];
+ char cgi_ssi_file[MAX_INPUT_BUFFER];
+ char raw_cgi_name[MAX_INPUT_BUFFER];
+ char *stripped_cgi_name;
+ int x;
+
+ /* common header or footer */
+ snprintf(common_ssi_file, sizeof(common_ssi_file) - 1, "%scommon-%s.ssi", physical_ssi_path, (type == SSI_HEADER) ? "header" : "footer");
+ common_ssi_file[sizeof(common_ssi_file) - 1] = '\x0';
+
+ /* CGI-specific header or footer */
+ strncpy(raw_cgi_name, cgi_name, sizeof(raw_cgi_name) - 1);
+ raw_cgi_name[sizeof(raw_cgi_name) - 1] = '\x0';
+ stripped_cgi_name = strtok(raw_cgi_name, ".");
+ snprintf(cgi_ssi_file, sizeof(cgi_ssi_file) - 1, "%s%s-%s.ssi", physical_ssi_path, (stripped_cgi_name == NULL) ? "" : stripped_cgi_name, (type == SSI_HEADER) ? "header" : "footer");
+ cgi_ssi_file[sizeof(cgi_ssi_file) - 1] = '\x0';
+
+ if(type == SSI_HEADER) {
+ printf("\n\n");
+ include_ssi_file(common_ssi_file);
+ include_ssi_file(cgi_ssi_file);
+ }
+ else {
+ include_ssi_file(cgi_ssi_file);
+ include_ssi_file(common_ssi_file);
+ printf("\n\n");
+ }
+
+ return;
+ }
+
+
+
+/* include user-defined SSI footer or header */
+void include_ssi_file(char *filename) {
+ char buffer[MAX_INPUT_BUFFER];
+ FILE *fp;
+ struct stat stat_result;
+ int call_return;
+
+ /* if file is executable, we want to run it rather than print it */
+ call_return = stat(filename, &stat_result);
+
+ /* file is executable */
+ if(call_return == 0 && (stat_result.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) {
+
+ /* must flush output stream first so that output
+ from script shows up in correct place. Other choice
+ is to open program under pipe and copy the data from
+ the program to our output stream.
+ */
+ fflush(stdout);
+
+ /* ignore return status from system call. */
+ call_return = system(filename);
+
+ return;
+ }
+
+ /* an error occurred trying to stat() the file */
+ else if(call_return != 0) {
+
+ /* Handle error conditions. Assume that standard posix error codes and errno are available. If not, comment this section out. */
+ switch(errno) {
+ case ENOTDIR: /* - A component of the path is not a directory. */
+ case ELOOP: /* Too many symbolic links encountered while traversing the path. */
+ case EFAULT: /* Bad address. */
+ case ENOMEM: /* Out of memory (i.e. kernel memory). */
+ case ENAMETOOLONG: /* File name too long. */
+ printf(" A stat call returned %d while looking for the file %s. ", errno, filename);
+ return;
+ case EACCES: /* Permission denied. -- The file should be accessible by nagios. */
+ printf(" A stat call returned a permissions error(%d) while looking for the file %s. ", errno, filename);
+ return;
+ case ENOENT: /* A component of the path file_name does not exist, or the path is an empty string. Just return if the file doesn't exist. */
+ return;
+ default:
+ return;
+ }
+ }
+
+ fp = fopen(filename, "r");
+ if(fp == NULL)
+ return;
+
+ /* print all lines in the SSI file */
+ while(fgets(buffer, (int)(sizeof(buffer) - 1), fp) != NULL)
+ printf("%s", buffer);
+
+ fclose(fp);
+
+ return;
+ }
+
+
+/* displays an error if CGI config file could not be read */
+void cgi_config_file_error(char *config_file) {
+
+ printf("
Whoops!
\n");
+
+ printf("
Error: Could not open CGI config file '%s' for reading!
\n", config_file);
+
+ printf("
\n");
+ printf("Here are some things you should check in order to resolve this error:\n");
+ printf("
\n");
+
+ printf("
\n");
+ printf("
\n");
+
+ printf("
Make sure you've installed a CGI config file in its proper location. See the error message about for details on where the CGI is expecting to find the configuration file. A sample CGI configuration file (named cgi.cfg) can be found in the sample-config/ subdirectory of the Nagios source code distribution.\n");
+ printf("
Make sure the user your web server is running as has permission to read the CGI config file.\n");
+
+ printf("
\n");
+ printf("\n");
+
+ printf("
\n");
+ printf("Make sure you read the documentation on installing and configuring Nagios thoroughly before continuing. If all else fails, try sending a message to one of the mailing lists. More information can be found at http://www.nagios.org.\n");
+ printf("
\n");
+
+ return;
+ }
+
+
+
+/* displays an error if main config file could not be read */
+void main_config_file_error(char *config_file) {
+
+ printf("
Whoops!
\n");
+
+ printf("
Error: Could not open main config file '%s' for reading!
\n", config_file);
+
+ printf("
\n");
+ printf("Here are some things you should check in order to resolve this error:\n");
+ printf("
\n");
+
+ printf("
\n");
+ printf("
\n");
+
+ printf("
Make sure you've installed a main config file in its proper location. See the error message about for details on where the CGI is expecting to find the configuration file. A sample main configuration file (named nagios.cfg) can be found in the sample-config/ subdirectory of the Nagios source code distribution.\n");
+ printf("
Make sure the user your web server is running as has permission to read the main config file.\n");
+
+ printf("
\n");
+ printf("\n");
+
+ printf("
\n");
+ printf("Make sure you read the documentation on installing and configuring Nagios thoroughly before continuing. If all else fails, try sending a message to one of the mailing lists. More information can be found at http://www.nagios.org.\n");
+ printf("
\n");
+
+ return;
+ }
+
+
+/* displays an error if object data could not be read */
+void object_data_error(void) {
+
+ printf("
Whoops!
\n");
+
+ printf("
Error: Could not read object configuration data!
\n");
+
+ printf("
\n");
+ printf("Here are some things you should check in order to resolve this error:\n");
+ printf("
\n");
+
+ printf("
\n");
+ printf("
\n");
+
+ printf("
Verify configuration options using the -v command-line option to check for errors.\n");
+ printf("
Check the Nagios log file for messages relating to startup or status data errors.\n");
+
+ printf("
\n");
+ printf("\n");
+
+ printf("
\n");
+ printf("Make sure you read the documentation on installing, configuring and running Nagios thoroughly before continuing. If all else fails, try sending a message to one of the mailing lists. More information can be found at http://www.nagios.org.\n");
+ printf("
\n");
+
+ return;
+ }
+
+
+/* displays an error if status data could not be read */
+void status_data_error(void) {
+
+ printf("
Whoops!
\n");
+
+ printf("
Error: Could not read host and service status information!
\n");
+
+ printf("
\n");
+ printf("The most common cause of this error message (especially for new users), is the fact that Nagios is not actually running. If Nagios is indeed not running, this is a normal error message. It simply indicates that the CGIs could not obtain the current status of hosts and services that are being monitored. If you've just installed things, make sure you read the documentation on starting Nagios.\n");
+ printf("
\n");
+
+ printf("
\n");
+ printf("Some other things you should check in order to resolve this error include:\n");
+ printf("
\n");
+
+ printf("
\n");
+ printf("
\n");
+
+ printf("
Check the Nagios log file for messages relating to startup or status data errors.\n");
+ printf("
Always verify configuration options using the -v command-line option before starting or restarting Nagios!\n");
+
+ printf("
\n");
+ printf("\n");
+
+ printf("
\n");
+ printf("Make sure you read the documentation on installing, configuring and running Nagios thoroughly before continuing. If all else fails, try sending a message to one of the mailing lists. More information can be found at http://www.nagios.org.\n");
+ printf("
\n");
+
+ return;
+ }
+
+
+
+
+/* displays context-sensitive help window */
+void display_context_help(char *chid) {
+ char *icon = CONTEXT_HELP_ICON1;
+
+ if(show_context_help == FALSE)
+ return;
+
+ /* change icon if necessary */
+ if(!strcmp(chid, CONTEXTHELP_TAC))
+ icon = CONTEXT_HELP_ICON2;
+
+ printf("\n", url_context_help_path, chid, url_context_help_path, chid, url_images_path, icon);
+
+ return;
+ }
+
+
+
+void display_splunk_host_url(host *hst) {
+
+ if(enable_splunk_integration == FALSE)
+ return;
+ if(hst == NULL)
+ return;
+
+ printf("\n", splunk_url, url_encode(hst->name), url_images_path, SPLUNK_SMALL_WHITE_ICON);
+
+ return;
+ }
+
+
+
+void display_splunk_service_url(service *svc) {
+
+ if(enable_splunk_integration == FALSE)
+ return;
+ if(svc == NULL)
+ return;
+
+ printf("\n", url_encode(svc->description), url_images_path, SPLUNK_SMALL_WHITE_ICON);
+
+ return;
+ }
+
+
+
+void display_splunk_generic_url(char *buf, int icon) {
+ char *newbuf = NULL;
+
+ if(enable_splunk_integration == FALSE)
+ return;
+ if(buf == NULL)
+ return;
+
+ if((newbuf = (char *)strdup(buf)) == NULL)
+ return;
+
+ strip_splunk_query_terms(newbuf);
+
+ printf("", splunk_url, url_encode(newbuf));
+ if(icon > 0)
+ printf("", url_images_path, (icon == 1) ? SPLUNK_SMALL_WHITE_ICON : SPLUNK_SMALL_BLACK_ICON);
+ printf("\n");
+
+ free(newbuf);
+
+ return;
+ }
+
+
+/* strip quotes and from string */
+void strip_splunk_query_terms(char *buffer) {
+ register int x;
+ register int y;
+ register int z;
+
+ if(buffer == NULL || buffer[0] == '\x0')
+ return;
+
+ /* remove all occurances in string */
+ z = (int)strlen(buffer);
+ for(x = 0, y = 0; x < z; x++) {
+ if(buffer[x] == '\'' || buffer[x] == '\"' || buffer[x] == ';' || buffer[x] == ':' || buffer[x] == ',' || buffer[x] == '-' || buffer[x] == '=')
+ buffer[y++] = ' ';
+ else
+ buffer[y++] = buffer[x];
+ }
+ buffer[y++] = '\x0';
+
+ return;
+ }
+
+
diff --git a/cgi/cmd.c b/cgi/cmd.c
new file mode 100644
index 0000000..6fc2939
--- /dev/null
+++ b/cgi/cmd.c
@@ -0,0 +1,2822 @@
+/**************************************************************************
+ *
+ * CMD.C - Nagios Command CGI
+ *
+ * Copyright (c) 1999-2010 Ethan Galstad (egalstad@nagios.org)
+ * Last Modified: 08-28-2010
+ *
+ * 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.
+ *************************************************************************/
+
+#include "../include/config.h"
+#include "../include/common.h"
+#include "../include/objects.h"
+#include "../include/comments.h"
+#include "../include/downtime.h"
+
+#include "../include/cgiutils.h"
+#include "../include/cgiauth.h"
+#include "../include/getcgi.h"
+
+extern const char *extcmd_get_name(int id);
+
+extern char main_config_file[MAX_FILENAME_LENGTH];
+extern char url_html_path[MAX_FILENAME_LENGTH];
+extern char url_images_path[MAX_FILENAME_LENGTH];
+extern char command_file[MAX_FILENAME_LENGTH];
+extern char comment_file[MAX_FILENAME_LENGTH];
+
+extern char url_stylesheets_path[MAX_FILENAME_LENGTH];
+
+extern int nagios_process_state;
+
+extern int check_external_commands;
+
+extern int use_authentication;
+
+extern int lock_author_names;
+
+extern scheduled_downtime *scheduled_downtime_list;
+extern comment *comment_list;
+
+extern int date_format;
+
+
+#define MAX_AUTHOR_LENGTH 64
+#define MAX_COMMENT_LENGTH 1024
+
+#define HTML_CONTENT 0
+#define WML_CONTENT 1
+
+
+char *host_name = "";
+char *hostgroup_name = "";
+char *servicegroup_name = "";
+char *service_desc = "";
+char *comment_author = "";
+char *comment_data = "";
+char *start_time_string = "";
+char *end_time_string = "";
+
+unsigned long comment_id = 0;
+unsigned long downtime_id = 0;
+int notification_delay = 0;
+int schedule_delay = 0;
+int persistent_comment = FALSE;
+int sticky_ack = FALSE;
+int send_notification = FALSE;
+int force_check = FALSE;
+int plugin_state = STATE_OK;
+char plugin_output[MAX_INPUT_BUFFER] = "";
+char performance_data[MAX_INPUT_BUFFER] = "";
+time_t start_time = 0L;
+time_t end_time = 0L;
+int affect_host_and_services = FALSE;
+int propagate_to_children = FALSE;
+int fixed = FALSE;
+unsigned long duration = 0L;
+unsigned long triggered_by = 0L;
+int child_options = 0;
+int force_notification = 0;
+int broadcast_notification = 0;
+
+int command_type = CMD_NONE;
+int command_mode = CMDMODE_REQUEST;
+
+int content_type = HTML_CONTENT;
+
+int display_header = TRUE;
+
+authdata current_authdata;
+
+void show_command_help(int);
+void request_command_data(int);
+void commit_command_data(int);
+int commit_command(int);
+int write_command_to_file(char *);
+void clean_comment_data(char *);
+
+void document_header(int);
+void document_footer(void);
+int process_cgivars(void);
+
+int string_to_time(char *, time_t *);
+
+
+
+int main(void) {
+ int result = OK;
+
+ /* get the arguments passed in the URL */
+ process_cgivars();
+
+ /* reset internal variables */
+ reset_cgi_vars();
+
+ /* read the CGI configuration file */
+ result = read_cgi_config_file(get_cgi_config_location());
+ if(result == ERROR) {
+ document_header(FALSE);
+ if(content_type == WML_CONTENT)
+ printf("
\n");
+ }
+
+ /* authorized_for_read_only should take priority */
+ if(is_authorized_for_read_only(¤t_authdata) == TRUE) {
+ printf("
It appears as though you do not have permission to submit the command you requested...
\n");
+ printf("
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI ");
+ printf("and check the authorization options in your CGI configuration file.
You are requesting to ");
+
+ switch(cmd) {
+
+ case CMD_ADD_HOST_COMMENT:
+ case CMD_ADD_SVC_COMMENT:
+ printf("add a %s comment", (cmd == CMD_ADD_HOST_COMMENT) ? "host" : "service");
+ break;
+
+ case CMD_DEL_HOST_COMMENT:
+ case CMD_DEL_SVC_COMMENT:
+ printf("delete a %s comment", (cmd == CMD_DEL_HOST_COMMENT) ? "host" : "service");
+ break;
+
+ case CMD_DELAY_HOST_NOTIFICATION:
+ case CMD_DELAY_SVC_NOTIFICATION:
+ printf("delay a %s notification", (cmd == CMD_DELAY_HOST_NOTIFICATION) ? "host" : "service");
+ break;
+
+ case CMD_SCHEDULE_SVC_CHECK:
+ printf("schedule a service check");
+ break;
+
+ case CMD_ENABLE_SVC_CHECK:
+ case CMD_DISABLE_SVC_CHECK:
+ printf("%s active checks of a particular service", (cmd == CMD_ENABLE_SVC_CHECK) ? "enable" : "disable");
+ break;
+
+ case CMD_ENABLE_NOTIFICATIONS:
+ case CMD_DISABLE_NOTIFICATIONS:
+ printf("%s notifications", (cmd == CMD_ENABLE_NOTIFICATIONS) ? "enable" : "disable");
+ break;
+
+ case CMD_SHUTDOWN_PROCESS:
+ case CMD_RESTART_PROCESS:
+ printf("%s the Nagios process", (cmd == CMD_SHUTDOWN_PROCESS) ? "shutdown" : "restart");
+ break;
+
+ case CMD_ENABLE_HOST_SVC_CHECKS:
+ case CMD_DISABLE_HOST_SVC_CHECKS:
+ printf("%s active checks of all services on a host", (cmd == CMD_ENABLE_HOST_SVC_CHECKS) ? "enable" : "disable");
+ break;
+
+ case CMD_SCHEDULE_HOST_SVC_CHECKS:
+ printf("schedule a check of all services for a host");
+ break;
+
+ case CMD_DEL_ALL_HOST_COMMENTS:
+ case CMD_DEL_ALL_SVC_COMMENTS:
+ printf("delete all comments for a %s", (cmd == CMD_DEL_ALL_HOST_COMMENTS) ? "host" : "service");
+ break;
+
+ case CMD_ENABLE_SVC_NOTIFICATIONS:
+ case CMD_DISABLE_SVC_NOTIFICATIONS:
+ printf("%s notifications for a service", (cmd == CMD_ENABLE_SVC_NOTIFICATIONS) ? "enable" : "disable");
+ break;
+
+ case CMD_ENABLE_HOST_NOTIFICATIONS:
+ case CMD_DISABLE_HOST_NOTIFICATIONS:
+ printf("%s notifications for a host", (cmd == CMD_ENABLE_HOST_NOTIFICATIONS) ? "enable" : "disable");
+ break;
+
+ case CMD_ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST:
+ case CMD_DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST:
+ printf("%s notifications for all hosts and services beyond a host", (cmd == CMD_ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST) ? "enable" : "disable");
+ break;
+
+ case CMD_ENABLE_HOST_SVC_NOTIFICATIONS:
+ case CMD_DISABLE_HOST_SVC_NOTIFICATIONS:
+ printf("%s notifications for all services on a host", (cmd == CMD_ENABLE_HOST_SVC_NOTIFICATIONS) ? "enable" : "disable");
+ break;
+
+ case CMD_ACKNOWLEDGE_HOST_PROBLEM:
+ case CMD_ACKNOWLEDGE_SVC_PROBLEM:
+ printf("acknowledge a %s problem", (cmd == CMD_ACKNOWLEDGE_HOST_PROBLEM) ? "host" : "service");
+ break;
+
+ case CMD_START_EXECUTING_SVC_CHECKS:
+ case CMD_STOP_EXECUTING_SVC_CHECKS:
+ printf("%s executing active service checks", (cmd == CMD_START_EXECUTING_SVC_CHECKS) ? "start" : "stop");
+ break;
+
+ case CMD_START_ACCEPTING_PASSIVE_SVC_CHECKS:
+ case CMD_STOP_ACCEPTING_PASSIVE_SVC_CHECKS:
+ printf("%s accepting passive service checks", (cmd == CMD_START_ACCEPTING_PASSIVE_SVC_CHECKS) ? "start" : "stop");
+ break;
+
+ case CMD_ENABLE_PASSIVE_SVC_CHECKS:
+ case CMD_DISABLE_PASSIVE_SVC_CHECKS:
+ printf("%s accepting passive service checks for a particular service", (cmd == CMD_ENABLE_PASSIVE_SVC_CHECKS) ? "start" : "stop");
+ break;
+
+ case CMD_ENABLE_EVENT_HANDLERS:
+ case CMD_DISABLE_EVENT_HANDLERS:
+ printf("%s event handlers", (cmd == CMD_ENABLE_EVENT_HANDLERS) ? "enable" : "disable");
+ break;
+
+ case CMD_ENABLE_HOST_EVENT_HANDLER:
+ case CMD_DISABLE_HOST_EVENT_HANDLER:
+ printf("%s the event handler for a particular host", (cmd == CMD_ENABLE_HOST_EVENT_HANDLER) ? "enable" : "disable");
+ break;
+
+ case CMD_ENABLE_SVC_EVENT_HANDLER:
+ case CMD_DISABLE_SVC_EVENT_HANDLER:
+ printf("%s the event handler for a particular service", (cmd == CMD_ENABLE_SVC_EVENT_HANDLER) ? "enable" : "disable");
+ break;
+
+ case CMD_ENABLE_HOST_CHECK:
+ case CMD_DISABLE_HOST_CHECK:
+ printf("%s active checks of a particular host", (cmd == CMD_ENABLE_HOST_CHECK) ? "enable" : "disable");
+ break;
+
+ case CMD_STOP_OBSESSING_OVER_SVC_CHECKS:
+ case CMD_START_OBSESSING_OVER_SVC_CHECKS:
+ printf("%s obsessing over service checks", (cmd == CMD_STOP_OBSESSING_OVER_SVC_CHECKS) ? "stop" : "start");
+ break;
+
+ case CMD_REMOVE_HOST_ACKNOWLEDGEMENT:
+ case CMD_REMOVE_SVC_ACKNOWLEDGEMENT:
+ printf("remove a %s acknowledgement", (cmd == CMD_REMOVE_HOST_ACKNOWLEDGEMENT) ? "host" : "service");
+ break;
+
+ case CMD_SCHEDULE_HOST_DOWNTIME:
+ case CMD_SCHEDULE_SVC_DOWNTIME:
+ printf("schedule downtime for a particular %s", (cmd == CMD_SCHEDULE_HOST_DOWNTIME) ? "host" : "service");
+ break;
+
+ case CMD_SCHEDULE_HOST_SVC_DOWNTIME:
+ printf("schedule downtime for all services for a particular host");
+ break;
+
+ case CMD_PROCESS_HOST_CHECK_RESULT:
+ case CMD_PROCESS_SERVICE_CHECK_RESULT:
+ printf("submit a passive check result for a particular %s", (cmd == CMD_PROCESS_HOST_CHECK_RESULT) ? "host" : "service");
+ break;
+
+ case CMD_ENABLE_HOST_FLAP_DETECTION:
+ case CMD_DISABLE_HOST_FLAP_DETECTION:
+ printf("%s flap detection for a particular host", (cmd == CMD_ENABLE_HOST_FLAP_DETECTION) ? "enable" : "disable");
+ break;
+
+ case CMD_ENABLE_SVC_FLAP_DETECTION:
+ case CMD_DISABLE_SVC_FLAP_DETECTION:
+ printf("%s flap detection for a particular service", (cmd == CMD_ENABLE_SVC_FLAP_DETECTION) ? "enable" : "disable");
+ break;
+
+ case CMD_ENABLE_FLAP_DETECTION:
+ case CMD_DISABLE_FLAP_DETECTION:
+ printf("%s flap detection for hosts and services", (cmd == CMD_ENABLE_FLAP_DETECTION) ? "enable" : "disable");
+ break;
+
+ case CMD_ENABLE_HOSTGROUP_SVC_NOTIFICATIONS:
+ case CMD_DISABLE_HOSTGROUP_SVC_NOTIFICATIONS:
+ printf("%s notifications for all services in a particular hostgroup", (cmd == CMD_ENABLE_HOSTGROUP_SVC_NOTIFICATIONS) ? "enable" : "disable");
+ break;
+
+ case CMD_ENABLE_HOSTGROUP_HOST_NOTIFICATIONS:
+ case CMD_DISABLE_HOSTGROUP_HOST_NOTIFICATIONS:
+ printf("%s notifications for all hosts in a particular hostgroup", (cmd == CMD_ENABLE_HOSTGROUP_HOST_NOTIFICATIONS) ? "enable" : "disable");
+ break;
+
+ case CMD_ENABLE_HOSTGROUP_SVC_CHECKS:
+ case CMD_DISABLE_HOSTGROUP_SVC_CHECKS:
+ printf("%s active checks of all services in a particular hostgroup", (cmd == CMD_ENABLE_HOSTGROUP_SVC_CHECKS) ? "enable" : "disable");
+ break;
+
+ case CMD_DEL_HOST_DOWNTIME:
+ case CMD_DEL_SVC_DOWNTIME:
+ printf("cancel scheduled downtime for a particular %s", (cmd == CMD_DEL_HOST_DOWNTIME) ? "host" : "service");
+ break;
+
+ case CMD_ENABLE_FAILURE_PREDICTION:
+ case CMD_DISABLE_FAILURE_PREDICTION:
+ printf("%s failure prediction for hosts and service", (cmd == CMD_ENABLE_FAILURE_PREDICTION) ? "enable" : "disable");
+ break;
+
+ case CMD_ENABLE_PERFORMANCE_DATA:
+ case CMD_DISABLE_PERFORMANCE_DATA:
+ printf("%s performance data processing for hosts and services", (cmd == CMD_ENABLE_PERFORMANCE_DATA) ? "enable" : "disable");
+ break;
+
+ case CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME:
+ printf("schedule downtime for all hosts in a particular hostgroup");
+ break;
+
+ case CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME:
+ printf("schedule downtime for all services in a particular hostgroup");
+ break;
+
+ case CMD_START_EXECUTING_HOST_CHECKS:
+ case CMD_STOP_EXECUTING_HOST_CHECKS:
+ printf("%s executing host checks", (cmd == CMD_START_EXECUTING_HOST_CHECKS) ? "start" : "stop");
+ break;
+
+ case CMD_START_ACCEPTING_PASSIVE_HOST_CHECKS:
+ case CMD_STOP_ACCEPTING_PASSIVE_HOST_CHECKS:
+ printf("%s accepting passive host checks", (cmd == CMD_START_ACCEPTING_PASSIVE_HOST_CHECKS) ? "start" : "stop");
+ break;
+
+ case CMD_ENABLE_PASSIVE_HOST_CHECKS:
+ case CMD_DISABLE_PASSIVE_HOST_CHECKS:
+ printf("%s accepting passive checks for a particular host", (cmd == CMD_ENABLE_PASSIVE_HOST_CHECKS) ? "start" : "stop");
+ break;
+
+ case CMD_START_OBSESSING_OVER_HOST_CHECKS:
+ case CMD_STOP_OBSESSING_OVER_HOST_CHECKS:
+ printf("%s obsessing over host checks", (cmd == CMD_START_OBSESSING_OVER_HOST_CHECKS) ? "start" : "stop");
+ break;
+
+ case CMD_SCHEDULE_HOST_CHECK:
+ printf("schedule a host check");
+ break;
+
+ case CMD_START_OBSESSING_OVER_SVC:
+ case CMD_STOP_OBSESSING_OVER_SVC:
+ printf("%s obsessing over a particular service", (cmd == CMD_START_OBSESSING_OVER_SVC) ? "start" : "stop");
+ break;
+
+ case CMD_START_OBSESSING_OVER_HOST:
+ case CMD_STOP_OBSESSING_OVER_HOST:
+ printf("%s obsessing over a particular host", (cmd == CMD_START_OBSESSING_OVER_HOST) ? "start" : "stop");
+ break;
+
+ case CMD_ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS:
+ case CMD_DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS:
+ printf("%s notifications for all services in a particular servicegroup", (cmd == CMD_ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS) ? "enable" : "disable");
+ break;
+
+ case CMD_ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS:
+ case CMD_DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS:
+ printf("%s notifications for all hosts in a particular servicegroup", (cmd == CMD_ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS) ? "enable" : "disable");
+ break;
+
+ case CMD_ENABLE_SERVICEGROUP_SVC_CHECKS:
+ case CMD_DISABLE_SERVICEGROUP_SVC_CHECKS:
+ printf("%s active checks of all services in a particular servicegroup", (cmd == CMD_ENABLE_SERVICEGROUP_SVC_CHECKS) ? "enable" : "disable");
+ break;
+
+ case CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME:
+ printf("schedule downtime for all hosts in a particular servicegroup");
+ break;
+
+ case CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME:
+ printf("schedule downtime for all services in a particular servicegroup");
+ break;
+
+ case CMD_SEND_CUSTOM_HOST_NOTIFICATION:
+ case CMD_SEND_CUSTOM_SVC_NOTIFICATION:
+ printf("send a custom %s notification", (cmd == CMD_SEND_CUSTOM_HOST_NOTIFICATION) ? "host" : "service");
+ break;
+
+ default:
+ printf("execute an unknown command. Shame on you!
");
+ return;
+ }
+
+ printf("
\n");
+
+ printf("
\n");
+ printf("
\n");
+
+ printf("
\n");
+ printf("
\n");
+ printf("
\n");
+
+ printf("
Command Options
\n");
+
+ printf("
\n");
+ printf("
\n");
+ printf("\n");
+ printf("
\n");
+ printf("
\n");
+ printf("
\n");
+
+ printf("
\n");
+ printf("
\n");
+
+ /* show information about the command... */
+ show_command_help(cmd);
+
+ printf("
\n");
+ printf("
\n");
+ printf("
\n");
+
+ printf("
\n");
+ printf("\n");
+
+ printf("
Please enter all required information before committing the command. Required fields are marked in red. Failure to supply all required values will result in an error.
");
+
+ return;
+ }
+
+
+void commit_command_data(int cmd) {
+ char *error_string = NULL;
+ int result = OK;
+ int authorized = FALSE;
+ service *temp_service;
+ host *temp_host;
+ hostgroup *temp_hostgroup;
+ comment *temp_comment;
+ scheduled_downtime *temp_downtime;
+ servicegroup *temp_servicegroup = NULL;
+ contact *temp_contact = NULL;
+
+
+ /* get authentication information */
+ get_authentication_information(¤t_authdata);
+
+ /* get name to use for author */
+ if(lock_author_names == TRUE) {
+ temp_contact = find_contact(current_authdata.username);
+ if(temp_contact != NULL && temp_contact->alias != NULL)
+ comment_author = temp_contact->alias;
+ else
+ comment_author = current_authdata.username;
+ }
+
+ switch(cmd) {
+ case CMD_ADD_HOST_COMMENT:
+ case CMD_ACKNOWLEDGE_HOST_PROBLEM:
+
+ /* make sure we have author name, and comment data... */
+ if(!strcmp(comment_author, "")) {
+ if(!error_string)
+ error_string = strdup("Author was not entered");
+ }
+ if(!strcmp(comment_data, "")) {
+ if(!error_string)
+ error_string = strdup("Comment was not entered");
+ }
+
+ /* clean up the comment data */
+ clean_comment_data(comment_author);
+ clean_comment_data(comment_data);
+
+ /* see if the user is authorized to issue a command... */
+ temp_host = find_host(host_name);
+ if(is_authorized_for_host_commands(temp_host, ¤t_authdata) == TRUE)
+ authorized = TRUE;
+ break;
+
+ case CMD_ADD_SVC_COMMENT:
+ case CMD_ACKNOWLEDGE_SVC_PROBLEM:
+
+ /* make sure we have author name, and comment data... */
+ if(!strcmp(comment_author, "")) {
+ if(!error_string)
+ error_string = strdup("Author was not entered");
+ }
+ if(!strcmp(comment_data, "")) {
+ if(!error_string)
+ error_string = strdup("Comment was not entered");
+ }
+
+ /* clean up the comment data */
+ clean_comment_data(comment_author);
+ clean_comment_data(comment_data);
+
+ /* see if the user is authorized to issue a command... */
+ temp_service = find_service(host_name, service_desc);
+ if(is_authorized_for_service_commands(temp_service, ¤t_authdata) == TRUE)
+ authorized = TRUE;
+ break;
+
+ case CMD_DEL_HOST_COMMENT:
+ case CMD_DEL_SVC_COMMENT:
+
+ /* check the sanity of the comment id */
+ if(comment_id == 0) {
+ if(!error_string)
+ error_string = strdup("Comment id cannot be 0");
+ }
+
+ /* find the comment */
+ if(cmd == CMD_DEL_HOST_COMMENT)
+ temp_comment = find_host_comment(comment_id);
+ else
+ temp_comment = find_service_comment(comment_id);
+
+ /* see if the user is authorized to issue a command... */
+ if(cmd == CMD_DEL_HOST_COMMENT && temp_comment != NULL) {
+ temp_host = find_host(temp_comment->host_name);
+ if(is_authorized_for_host_commands(temp_host, ¤t_authdata) == TRUE)
+ authorized = TRUE;
+ }
+ if(cmd == CMD_DEL_SVC_COMMENT && temp_comment != NULL) {
+ temp_service = find_service(temp_comment->host_name, temp_comment->service_description);
+ if(is_authorized_for_service_commands(temp_service, ¤t_authdata) == TRUE)
+ authorized = TRUE;
+ }
+
+ /* free comment data */
+ free_comment_data();
+
+ break;
+
+ case CMD_DEL_HOST_DOWNTIME:
+ case CMD_DEL_SVC_DOWNTIME:
+
+ /* check the sanity of the downtime id */
+ if(downtime_id == 0) {
+ if(!error_string)
+ error_string = strdup("Downtime id cannot be 0");
+ }
+
+ /* find the downtime entry */
+ if(cmd == CMD_DEL_HOST_DOWNTIME)
+ temp_downtime = find_host_downtime(downtime_id);
+ else
+ temp_downtime = find_service_downtime(downtime_id);
+
+ /* see if the user is authorized to issue a command... */
+ if(cmd == CMD_DEL_HOST_DOWNTIME && temp_downtime != NULL) {
+ temp_host = find_host(temp_downtime->host_name);
+ if(is_authorized_for_host_commands(temp_host, ¤t_authdata) == TRUE)
+ authorized = TRUE;
+ }
+ if(cmd == CMD_DEL_SVC_DOWNTIME && temp_downtime != NULL) {
+ temp_service = find_service(temp_downtime->host_name, temp_downtime->service_description);
+ if(is_authorized_for_service_commands(temp_service, ¤t_authdata) == TRUE)
+ authorized = TRUE;
+ }
+
+ /* free downtime data */
+ free_downtime_data();
+
+ break;
+
+ case CMD_SCHEDULE_SVC_CHECK:
+ case CMD_ENABLE_SVC_CHECK:
+ case CMD_DISABLE_SVC_CHECK:
+ case CMD_DEL_ALL_SVC_COMMENTS:
+ case CMD_ENABLE_SVC_NOTIFICATIONS:
+ case CMD_DISABLE_SVC_NOTIFICATIONS:
+ case CMD_ENABLE_PASSIVE_SVC_CHECKS:
+ case CMD_DISABLE_PASSIVE_SVC_CHECKS:
+ case CMD_ENABLE_SVC_EVENT_HANDLER:
+ case CMD_DISABLE_SVC_EVENT_HANDLER:
+ case CMD_REMOVE_SVC_ACKNOWLEDGEMENT:
+ case CMD_PROCESS_SERVICE_CHECK_RESULT:
+ case CMD_SCHEDULE_SVC_DOWNTIME:
+ case CMD_DELAY_SVC_NOTIFICATION:
+ case CMD_ENABLE_SVC_FLAP_DETECTION:
+ case CMD_DISABLE_SVC_FLAP_DETECTION:
+ case CMD_START_OBSESSING_OVER_SVC:
+ case CMD_STOP_OBSESSING_OVER_SVC:
+
+ /* make sure we have author name and comment data... */
+ if(cmd == CMD_SCHEDULE_SVC_DOWNTIME) {
+ if(!strcmp(comment_data, "")) {
+ if(!error_string)
+ error_string = strdup("Comment was not entered");
+ }
+ else if(!strcmp(comment_author, "")) {
+ if(!error_string)
+ error_string = strdup("Author was not entered");
+ }
+ }
+
+ /* see if the user is authorized to issue a command... */
+ temp_service = find_service(host_name, service_desc);
+ if(is_authorized_for_service_commands(temp_service, ¤t_authdata) == TRUE)
+ authorized = TRUE;
+
+ /* make sure we have passive check info (if necessary) */
+ if(cmd == CMD_PROCESS_SERVICE_CHECK_RESULT && !strcmp(plugin_output, "")) {
+ if(!error_string)
+ error_string = strdup("Plugin output cannot be blank");
+ }
+
+ /* make sure we have a notification delay (if necessary) */
+ if(cmd == CMD_DELAY_SVC_NOTIFICATION && notification_delay <= 0) {
+ if(!error_string)
+ error_string = strdup("Notification delay must be greater than 0");
+ }
+
+ /* clean up the comment data if scheduling downtime */
+ if(cmd == CMD_SCHEDULE_SVC_DOWNTIME) {
+ clean_comment_data(comment_author);
+ clean_comment_data(comment_data);
+ }
+
+ /* make sure we have check time (if necessary) */
+ if(cmd == CMD_SCHEDULE_SVC_CHECK && start_time == (time_t)0) {
+ if(!error_string)
+ error_string = strdup("Start time must be non-zero or bad format has been submitted.");
+ }
+
+ /* make sure we have start/end times for downtime (if necessary) */
+ if(cmd == CMD_SCHEDULE_SVC_DOWNTIME && (start_time == (time_t)0 || end_time == (time_t)0 || end_time < start_time)) {
+ if(!error_string)
+ error_string = strdup("Start or end time not valid");
+ }
+
+ break;
+
+ case CMD_ENABLE_NOTIFICATIONS:
+ case CMD_DISABLE_NOTIFICATIONS:
+ case CMD_SHUTDOWN_PROCESS:
+ case CMD_RESTART_PROCESS:
+ case CMD_START_EXECUTING_SVC_CHECKS:
+ case CMD_STOP_EXECUTING_SVC_CHECKS:
+ case CMD_START_ACCEPTING_PASSIVE_SVC_CHECKS:
+ case CMD_STOP_ACCEPTING_PASSIVE_SVC_CHECKS:
+ case CMD_ENABLE_EVENT_HANDLERS:
+ case CMD_DISABLE_EVENT_HANDLERS:
+ case CMD_START_OBSESSING_OVER_SVC_CHECKS:
+ case CMD_STOP_OBSESSING_OVER_SVC_CHECKS:
+ case CMD_ENABLE_FLAP_DETECTION:
+ case CMD_DISABLE_FLAP_DETECTION:
+ case CMD_ENABLE_FAILURE_PREDICTION:
+ case CMD_DISABLE_FAILURE_PREDICTION:
+ case CMD_ENABLE_PERFORMANCE_DATA:
+ case CMD_DISABLE_PERFORMANCE_DATA:
+ case CMD_START_EXECUTING_HOST_CHECKS:
+ case CMD_STOP_EXECUTING_HOST_CHECKS:
+ case CMD_START_ACCEPTING_PASSIVE_HOST_CHECKS:
+ case CMD_STOP_ACCEPTING_PASSIVE_HOST_CHECKS:
+ case CMD_START_OBSESSING_OVER_HOST_CHECKS:
+ case CMD_STOP_OBSESSING_OVER_HOST_CHECKS:
+
+ /* see if the user is authorized to issue a command... */
+ if(is_authorized_for_system_commands(¤t_authdata) == TRUE)
+ authorized = TRUE;
+ break;
+
+ case CMD_ENABLE_HOST_SVC_CHECKS:
+ case CMD_DISABLE_HOST_SVC_CHECKS:
+ case CMD_DEL_ALL_HOST_COMMENTS:
+ case CMD_SCHEDULE_HOST_SVC_CHECKS:
+ case CMD_ENABLE_HOST_NOTIFICATIONS:
+ case CMD_DISABLE_HOST_NOTIFICATIONS:
+ case CMD_ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST:
+ case CMD_DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST:
+ case CMD_ENABLE_HOST_SVC_NOTIFICATIONS:
+ case CMD_DISABLE_HOST_SVC_NOTIFICATIONS:
+ case CMD_ENABLE_HOST_EVENT_HANDLER:
+ case CMD_DISABLE_HOST_EVENT_HANDLER:
+ case CMD_ENABLE_HOST_CHECK:
+ case CMD_DISABLE_HOST_CHECK:
+ case CMD_REMOVE_HOST_ACKNOWLEDGEMENT:
+ case CMD_SCHEDULE_HOST_DOWNTIME:
+ case CMD_SCHEDULE_HOST_SVC_DOWNTIME:
+ case CMD_DELAY_HOST_NOTIFICATION:
+ case CMD_ENABLE_HOST_FLAP_DETECTION:
+ case CMD_DISABLE_HOST_FLAP_DETECTION:
+ case CMD_PROCESS_HOST_CHECK_RESULT:
+ case CMD_ENABLE_PASSIVE_HOST_CHECKS:
+ case CMD_DISABLE_PASSIVE_HOST_CHECKS:
+ case CMD_SCHEDULE_HOST_CHECK:
+ case CMD_START_OBSESSING_OVER_HOST:
+ case CMD_STOP_OBSESSING_OVER_HOST:
+
+ /* make sure we have author name and comment data... */
+ if(cmd == CMD_SCHEDULE_HOST_DOWNTIME || cmd == CMD_SCHEDULE_HOST_SVC_DOWNTIME) {
+ if(!strcmp(comment_data, "")) {
+ if(!error_string)
+ error_string = strdup("Comment was not entered");
+ }
+ else if(!strcmp(comment_author, "")) {
+ if(!error_string)
+ error_string = strdup("Author was not entered");
+ }
+ }
+
+ /* see if the user is authorized to issue a command... */
+ temp_host = find_host(host_name);
+ if(is_authorized_for_host_commands(temp_host, ¤t_authdata) == TRUE)
+ authorized = TRUE;
+
+ /* clean up the comment data if scheduling downtime */
+ if(cmd == CMD_SCHEDULE_HOST_DOWNTIME || cmd == CMD_SCHEDULE_HOST_SVC_DOWNTIME) {
+ clean_comment_data(comment_author);
+ clean_comment_data(comment_data);
+ }
+
+ /* make sure we have a notification delay (if necessary) */
+ if(cmd == CMD_DELAY_HOST_NOTIFICATION && notification_delay <= 0) {
+ if(!error_string)
+ error_string = strdup("Notification delay must be greater than 0");
+ }
+
+ /* make sure we have start/end times for downtime (if necessary) */
+ if((cmd == CMD_SCHEDULE_HOST_DOWNTIME || cmd == CMD_SCHEDULE_HOST_SVC_DOWNTIME) && (start_time == (time_t)0 || end_time == (time_t)0 || start_time > end_time)) {
+ if(!error_string)
+ error_string = strdup("Start or end time not valid");
+ }
+
+ /* make sure we have check time (if necessary) */
+ if((cmd == CMD_SCHEDULE_HOST_CHECK || cmd == CMD_SCHEDULE_HOST_SVC_CHECKS) && start_time == (time_t)0) {
+ if(!error_string)
+ error_string = strdup("Start time must be non-zero or bad format has been submitted.");
+ }
+
+ /* make sure we have passive check info (if necessary) */
+ if(cmd == CMD_PROCESS_HOST_CHECK_RESULT && !strcmp(plugin_output, "")) {
+ if(!error_string)
+ error_string = strdup("Plugin output cannot be blank");
+ }
+
+ break;
+
+ case CMD_ENABLE_HOSTGROUP_SVC_NOTIFICATIONS:
+ case CMD_DISABLE_HOSTGROUP_SVC_NOTIFICATIONS:
+ case CMD_ENABLE_HOSTGROUP_HOST_NOTIFICATIONS:
+ case CMD_DISABLE_HOSTGROUP_HOST_NOTIFICATIONS:
+ case CMD_ENABLE_HOSTGROUP_SVC_CHECKS:
+ case CMD_DISABLE_HOSTGROUP_SVC_CHECKS:
+ case CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME:
+ case CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME:
+
+ /* make sure we have author and comment data */
+ if(cmd == CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME || cmd == CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME) {
+ if(!strcmp(comment_data, "")) {
+ if(!error_string)
+ error_string = strdup("Comment was not entered");
+ }
+ else if(!strcmp(comment_author, "")) {
+ if(!error_string)
+ error_string = strdup("Author was not entered");
+ }
+ }
+
+ /* make sure we have start/end times for downtime */
+ if((cmd == CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME || cmd == CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME) && (start_time == (time_t)0 || end_time == (time_t)0 || start_time > end_time)) {
+ if(!error_string)
+ error_string = strdup("Start or end time not valid");
+ }
+
+ /* see if the user is authorized to issue a command... */
+ temp_hostgroup = find_hostgroup(hostgroup_name);
+ if(is_authorized_for_hostgroup_commands(temp_hostgroup, ¤t_authdata) == TRUE)
+ authorized = TRUE;
+
+ /* clean up the comment data if scheduling downtime */
+ if(cmd == CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME || cmd == CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME) {
+ clean_comment_data(comment_author);
+ clean_comment_data(comment_data);
+ }
+
+ break;
+
+ case CMD_ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS:
+ case CMD_DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS:
+ case CMD_ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS:
+ case CMD_DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS:
+ case CMD_ENABLE_SERVICEGROUP_SVC_CHECKS:
+ case CMD_DISABLE_SERVICEGROUP_SVC_CHECKS:
+ case CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME:
+ case CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME:
+
+ /* make sure we have author and comment data */
+ if(cmd == CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME || cmd == CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME) {
+ if(!strcmp(comment_data, "")) {
+ if(!error_string)
+ error_string = strdup("Comment was not entered");
+ }
+ else if(!strcmp(comment_author, "")) {
+ if(!error_string)
+ error_string = strdup("Author was not entered");
+ }
+ }
+
+ /* make sure we have start/end times for downtime */
+ if((cmd == CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME || cmd == CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME) && (start_time == (time_t)0 || end_time == (time_t)0 || start_time > end_time)) {
+ if(!error_string)
+ error_string = strdup("Start or end time not valid");
+ }
+
+ /* see if the user is authorized to issue a command... */
+
+ temp_servicegroup = find_servicegroup(servicegroup_name);
+ if(is_authorized_for_servicegroup_commands(temp_servicegroup, ¤t_authdata) == TRUE)
+ authorized = TRUE;
+
+ break;
+
+ case CMD_SEND_CUSTOM_HOST_NOTIFICATION:
+ case CMD_SEND_CUSTOM_SVC_NOTIFICATION:
+
+ /* make sure we have author and comment data */
+ if(!strcmp(comment_data, "")) {
+ if(!error_string)
+ error_string = strdup("Comment was not entered");
+ }
+ else if(!strcmp(comment_author, "")) {
+ if(!error_string)
+ error_string = strdup("Author was not entered");
+ }
+
+ /* see if the user is authorized to issue a command... */
+ if(cmd == CMD_SEND_CUSTOM_HOST_NOTIFICATION) {
+ temp_host = find_host(host_name);
+ if(is_authorized_for_host_commands(temp_host, ¤t_authdata) == TRUE)
+ authorized = TRUE;
+ }
+ else {
+ temp_service = find_service(host_name, service_desc);
+ if(is_authorized_for_service_commands(temp_service, ¤t_authdata) == TRUE)
+ authorized = TRUE;
+ }
+ break;
+
+ default:
+ if(!error_string) error_string = strdup("An error occurred while processing your command!");
+ }
+
+
+ /* to be safe, we are going to REQUIRE that the authentication functionality is enabled... */
+ if(use_authentication == FALSE) {
+ if(content_type == WML_CONTENT)
+ printf("
Error: Authentication is not enabled!
\n");
+ else {
+ printf("
\n");
+ printf("
Sorry Dave, I can't let you do that...
");
+ printf("
");
+ printf("It seems that you have chosen to not use the authentication functionality of the CGIs.
");
+ printf("I don't want to be personally responsible for what may happen as a result of allowing unauthorized users to issue commands to Nagios,");
+ printf("so you'll have to disable this safeguard if you are really stubborn and want to invite trouble.
");
+ printf("Read the section on CGI authentication in the HTML documentation to learn how you can enable authentication and why you should want to.\n");
+ printf("
\n");
+ printf("\n");
+ }
+ }
+
+ /* the user is not authorized to issue the given command */
+ else if(authorized == FALSE) {
+ if(content_type == WML_CONTENT)
+ printf("
Error: You're not authorized to commit that command!
\n");
+ else {
+ printf("
Sorry, but you are not authorized to commit the specified command.
\n");
+ printf("
Read the section of the documentation that deals with authentication and authorization in the CGIs for more information.
\n");
+ }
+ }
+ }
+
+ return;
+ }
+
+__attribute__((format(printf, 2, 3)))
+static int cmd_submitf(int id, const char *fmt, ...) {
+ char cmd[MAX_EXTERNAL_COMMAND_LENGTH];
+ const char *command;
+ int len, len2;
+ va_list ap;
+
+ command = extcmd_get_name(id);
+ /*
+ * We disallow sending 'CHANGE' commands from the cgi's
+ * until we do proper session handling to prevent cross-site
+ * request forgery
+ */
+ if(!command || (strlen(command) > 6 && !memcmp("CHANGE", command, 6)))
+ return ERROR;
+
+ len = snprintf(cmd, sizeof(cmd) - 1, "[%lu] %s;", time(NULL), command);
+ if(len < 0)
+ return ERROR;
+
+ if(fmt) {
+ va_start(ap, fmt);
+ len2 = vsnprintf(&cmd[len], sizeof(cmd) - len - 1, fmt, ap);
+ va_end(ap);
+ if(len2 < 0)
+ return ERROR;
+ }
+
+ return write_command_to_file(cmd);
+ }
+
+
+
+/* commits a command for processing */
+int commit_command(int cmd) {
+ time_t current_time;
+ time_t scheduled_time;
+ time_t notification_time;
+ int result;
+
+ /* get the current time */
+ time(¤t_time);
+
+ /* get the scheduled time */
+ scheduled_time = current_time + (schedule_delay * 60);
+
+ /* get the notification time */
+ notification_time = current_time + (notification_delay * 60);
+
+ /*
+ * these are supposed to be implanted inside the
+ * completed commands shipped off to nagios and
+ * must therefore never contain ';'
+ */
+ if(host_name && strchr(host_name, ';'))
+ return ERROR;
+ if(service_desc && strchr(service_desc, ';'))
+ return ERROR;
+ if(comment_author && strchr(comment_author, ';'))
+ return ERROR;
+ if(hostgroup_name && strchr(hostgroup_name, ';'))
+ return ERROR;
+ if(servicegroup_name && strchr(servicegroup_name, ';'))
+ return ERROR;
+
+ /* decide how to form the command line... */
+ switch(cmd) {
+
+ /* commands without arguments */
+ case CMD_START_EXECUTING_SVC_CHECKS:
+ case CMD_STOP_EXECUTING_SVC_CHECKS:
+ case CMD_START_ACCEPTING_PASSIVE_SVC_CHECKS:
+ case CMD_STOP_ACCEPTING_PASSIVE_SVC_CHECKS:
+ case CMD_ENABLE_EVENT_HANDLERS:
+ case CMD_DISABLE_EVENT_HANDLERS:
+ case CMD_START_OBSESSING_OVER_SVC_CHECKS:
+ case CMD_STOP_OBSESSING_OVER_SVC_CHECKS:
+ case CMD_ENABLE_FLAP_DETECTION:
+ case CMD_DISABLE_FLAP_DETECTION:
+ case CMD_ENABLE_FAILURE_PREDICTION:
+ case CMD_DISABLE_FAILURE_PREDICTION:
+ case CMD_ENABLE_PERFORMANCE_DATA:
+ case CMD_DISABLE_PERFORMANCE_DATA:
+ case CMD_START_EXECUTING_HOST_CHECKS:
+ case CMD_STOP_EXECUTING_HOST_CHECKS:
+ case CMD_START_ACCEPTING_PASSIVE_HOST_CHECKS:
+ case CMD_STOP_ACCEPTING_PASSIVE_HOST_CHECKS:
+ case CMD_START_OBSESSING_OVER_HOST_CHECKS:
+ case CMD_STOP_OBSESSING_OVER_HOST_CHECKS:
+ result = cmd_submitf(cmd, NULL);
+ break;
+
+ /** simple host commands **/
+ case CMD_ENABLE_HOST_FLAP_DETECTION:
+ case CMD_DISABLE_HOST_FLAP_DETECTION:
+ case CMD_ENABLE_PASSIVE_HOST_CHECKS:
+ case CMD_DISABLE_PASSIVE_HOST_CHECKS:
+ case CMD_START_OBSESSING_OVER_HOST:
+ case CMD_STOP_OBSESSING_OVER_HOST:
+ case CMD_DEL_ALL_HOST_COMMENTS:
+ case CMD_ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST:
+ case CMD_DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST:
+ case CMD_ENABLE_HOST_EVENT_HANDLER:
+ case CMD_DISABLE_HOST_EVENT_HANDLER:
+ case CMD_ENABLE_HOST_CHECK:
+ case CMD_DISABLE_HOST_CHECK:
+ case CMD_REMOVE_HOST_ACKNOWLEDGEMENT:
+ result = cmd_submitf(cmd, "%s", host_name);
+ break;
+
+ /** simple service commands **/
+ case CMD_ENABLE_SVC_FLAP_DETECTION:
+ case CMD_DISABLE_SVC_FLAP_DETECTION:
+ case CMD_ENABLE_PASSIVE_SVC_CHECKS:
+ case CMD_DISABLE_PASSIVE_SVC_CHECKS:
+ case CMD_START_OBSESSING_OVER_SVC:
+ case CMD_STOP_OBSESSING_OVER_SVC:
+ case CMD_DEL_ALL_SVC_COMMENTS:
+ case CMD_ENABLE_SVC_NOTIFICATIONS:
+ case CMD_DISABLE_SVC_NOTIFICATIONS:
+ case CMD_ENABLE_SVC_EVENT_HANDLER:
+ case CMD_DISABLE_SVC_EVENT_HANDLER:
+ case CMD_ENABLE_SVC_CHECK:
+ case CMD_DISABLE_SVC_CHECK:
+ case CMD_REMOVE_SVC_ACKNOWLEDGEMENT:
+ result = cmd_submitf(cmd, "%s;%s", host_name, service_desc);
+ break;
+
+ case CMD_ADD_HOST_COMMENT:
+ result = cmd_submitf(cmd, "%s;%d;%s;%s", host_name, persistent_comment, comment_author, comment_data);
+ break;
+
+ case CMD_ADD_SVC_COMMENT:
+ result = cmd_submitf(cmd, "%s;%s;%d;%s;%s", host_name, service_desc, persistent_comment, comment_author, comment_data);
+ break;
+
+ case CMD_DEL_HOST_COMMENT:
+ case CMD_DEL_SVC_COMMENT:
+ result = cmd_submitf(cmd, "%lu", comment_id);
+ break;
+
+ case CMD_DELAY_HOST_NOTIFICATION:
+ result = cmd_submitf(cmd, "%s;%lu", host_name, notification_time);
+ break;
+
+ case CMD_DELAY_SVC_NOTIFICATION:
+ result = cmd_submitf(cmd, "%s;%s;%lu", host_name, service_desc, notification_time);
+ break;
+
+ case CMD_SCHEDULE_SVC_CHECK:
+ case CMD_SCHEDULE_FORCED_SVC_CHECK:
+ if(force_check == TRUE)
+ cmd = CMD_SCHEDULE_FORCED_SVC_CHECK;
+ result = cmd_submitf(cmd, "%s;%s;%lu", host_name, service_desc, start_time);
+ break;
+
+ case CMD_DISABLE_NOTIFICATIONS:
+ case CMD_ENABLE_NOTIFICATIONS:
+ case CMD_SHUTDOWN_PROCESS:
+ case CMD_RESTART_PROCESS:
+ result = cmd_submitf(cmd, "%lu", scheduled_time);
+ break;
+
+ case CMD_ENABLE_HOST_SVC_CHECKS:
+ case CMD_DISABLE_HOST_SVC_CHECKS:
+ result = cmd_submitf(cmd, "%s", host_name);
+ if(affect_host_and_services == TRUE) {
+ cmd = (cmd == CMD_ENABLE_HOST_SVC_CHECKS) ? CMD_ENABLE_HOST_CHECK : CMD_DISABLE_HOST_CHECK;
+ result |= cmd_submitf(cmd, "%s", host_name);
+ }
+ break;
+
+ case CMD_SCHEDULE_HOST_SVC_CHECKS:
+ if(force_check == TRUE)
+ cmd = CMD_SCHEDULE_FORCED_HOST_SVC_CHECKS;
+ result = cmd_submitf(cmd, "%s;%lu", host_name, scheduled_time);
+ break;
+
+ case CMD_ENABLE_HOST_NOTIFICATIONS:
+ case CMD_DISABLE_HOST_NOTIFICATIONS:
+ if(propagate_to_children == TRUE)
+ cmd = (cmd == CMD_ENABLE_HOST_NOTIFICATIONS) ? CMD_ENABLE_HOST_AND_CHILD_NOTIFICATIONS : CMD_DISABLE_HOST_AND_CHILD_NOTIFICATIONS;
+ result = cmd_submitf(cmd, "%s", host_name);
+ break;
+
+ case CMD_ENABLE_HOST_SVC_NOTIFICATIONS:
+ case CMD_DISABLE_HOST_SVC_NOTIFICATIONS:
+ result = cmd_submitf(cmd, "%s", host_name);
+ if(affect_host_and_services == TRUE) {
+ cmd = (cmd == CMD_ENABLE_HOST_SVC_NOTIFICATIONS) ? CMD_ENABLE_HOST_NOTIFICATIONS : CMD_DISABLE_HOST_NOTIFICATIONS;
+ result |= cmd_submitf(cmd, "%s", host_name);
+ }
+ break;
+
+ case CMD_ACKNOWLEDGE_HOST_PROBLEM:
+ result = cmd_submitf(cmd, "%s;%d;%d;%d;%s;%s", host_name, (sticky_ack == TRUE) ? ACKNOWLEDGEMENT_STICKY : ACKNOWLEDGEMENT_NORMAL, send_notification, persistent_comment, comment_author, comment_data);
+ break;
+
+ case CMD_ACKNOWLEDGE_SVC_PROBLEM:
+ result = cmd_submitf(cmd, "%s;%s;%d;%d;%d;%s;%s", host_name, service_desc, (sticky_ack == TRUE) ? ACKNOWLEDGEMENT_STICKY : ACKNOWLEDGEMENT_NORMAL, send_notification, persistent_comment, comment_author, comment_data);
+ break;
+
+ case CMD_PROCESS_SERVICE_CHECK_RESULT:
+ result = cmd_submitf(cmd, "%s;%s;%d;%s|%s", host_name, service_desc, plugin_state, plugin_output, performance_data);
+ break;
+
+ case CMD_PROCESS_HOST_CHECK_RESULT:
+ result = cmd_submitf(cmd, "%s;%d;%s|%s", host_name, plugin_state, plugin_output, performance_data);
+ break;
+
+ case CMD_SCHEDULE_HOST_DOWNTIME:
+ if(child_options == 1)
+ cmd = CMD_SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME;
+ else if(child_options == 2)
+ cmd = CMD_SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME;
+
+ result = cmd_submitf(cmd, "%s;%lu;%lu;%d;%lu;%lu;%s;%s", host_name, start_time, end_time, fixed, triggered_by, duration, comment_author, comment_data);
+ break;
+
+ case CMD_SCHEDULE_HOST_SVC_DOWNTIME:
+ result = cmd_submitf(cmd, "%s;%lu;%lu;%d;%lu;%lu;%s;%s", host_name, start_time, end_time, fixed, triggered_by, duration, comment_author, comment_data);
+ break;
+
+ case CMD_SCHEDULE_SVC_DOWNTIME:
+ result = cmd_submitf(cmd, "%s;%s;%lu;%lu;%d;%lu;%lu;%s;%s", host_name, service_desc, start_time, end_time, fixed, triggered_by, duration, comment_author, comment_data);
+ break;
+
+ case CMD_DEL_HOST_DOWNTIME:
+ case CMD_DEL_SVC_DOWNTIME:
+ result = cmd_submitf(cmd, "%lu", downtime_id);
+ break;
+
+ case CMD_SCHEDULE_HOST_CHECK:
+ if(force_check == TRUE)
+ cmd = CMD_SCHEDULE_FORCED_HOST_CHECK;
+ result = cmd_submitf(cmd, "%s;%lu", host_name, start_time);
+ break;
+
+ case CMD_SEND_CUSTOM_HOST_NOTIFICATION:
+ result = cmd_submitf(cmd, "%s;%d;%s;%s", host_name, (force_notification | broadcast_notification), comment_author, comment_data);
+ break;
+
+ case CMD_SEND_CUSTOM_SVC_NOTIFICATION:
+ result = cmd_submitf(cmd, "%s;%s;%d;%s;%s", host_name, service_desc, (force_notification | broadcast_notification), comment_author, comment_data);
+ break;
+
+
+ /***** HOSTGROUP COMMANDS *****/
+
+ case CMD_ENABLE_HOSTGROUP_SVC_NOTIFICATIONS:
+ case CMD_DISABLE_HOSTGROUP_SVC_NOTIFICATIONS:
+ result = cmd_submitf(cmd, "%s", hostgroup_name);
+ if(affect_host_and_services == TRUE) {
+ cmd = (cmd == CMD_ENABLE_HOSTGROUP_SVC_NOTIFICATIONS) ? CMD_ENABLE_HOSTGROUP_HOST_NOTIFICATIONS : CMD_DISABLE_HOSTGROUP_HOST_NOTIFICATIONS;
+ result |= cmd_submitf(cmd, "%s", hostgroup_name);
+ }
+ break;
+
+ case CMD_ENABLE_HOSTGROUP_HOST_NOTIFICATIONS:
+ case CMD_DISABLE_HOSTGROUP_HOST_NOTIFICATIONS:
+ result = cmd_submitf(cmd, "%s", hostgroup_name);
+ break;
+
+ case CMD_ENABLE_HOSTGROUP_SVC_CHECKS:
+ case CMD_DISABLE_HOSTGROUP_SVC_CHECKS:
+ result = cmd_submitf(cmd, "%s", hostgroup_name);
+ if(affect_host_and_services == TRUE) {
+ cmd = (cmd == CMD_ENABLE_HOSTGROUP_SVC_CHECKS) ? CMD_ENABLE_HOSTGROUP_HOST_CHECKS : CMD_DISABLE_HOSTGROUP_HOST_CHECKS;
+ result |= cmd_submitf(cmd, "%s", hostgroup_name);
+ }
+ break;
+
+ case CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME:
+ result = cmd_submitf(cmd, "%s;%lu;%lu;%d;0;%lu;%s;%s", hostgroup_name, start_time, end_time, fixed, duration, comment_author, comment_data);
+ break;
+
+ case CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME:
+ result = cmd_submitf(cmd, "%s;%lu;%lu;%d;0;%lu;%s;%s", hostgroup_name, start_time, end_time, fixed, duration, comment_author, comment_data);
+ if(affect_host_and_services == TRUE)
+ result |= cmd_submitf(CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME, "%s;%lu;%lu;%d;0;%lu;%s;%s", hostgroup_name, start_time, end_time, fixed, duration, comment_author, comment_data);
+ break;
+
+
+ /***** SERVICEGROUP COMMANDS *****/
+
+ case CMD_ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS:
+ case CMD_DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS:
+ result = cmd_submitf(cmd, "%s", servicegroup_name);
+ if(affect_host_and_services == TRUE) {
+ cmd = (cmd == CMD_ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS) ? CMD_ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS : CMD_DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS;
+ result |= cmd_submitf(cmd, "%s", servicegroup_name);
+ }
+ break;
+
+ case CMD_ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS:
+ case CMD_DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS:
+ result = cmd_submitf(cmd, "%s", servicegroup_name);
+ break;
+
+ case CMD_ENABLE_SERVICEGROUP_SVC_CHECKS:
+ case CMD_DISABLE_SERVICEGROUP_SVC_CHECKS:
+ result = cmd_submitf(cmd, "%s", servicegroup_name);
+ if(affect_host_and_services == TRUE) {
+ cmd = (cmd == CMD_ENABLE_SERVICEGROUP_SVC_CHECKS) ? CMD_ENABLE_SERVICEGROUP_HOST_CHECKS : CMD_DISABLE_SERVICEGROUP_HOST_CHECKS;
+ result |= cmd_submitf(cmd, "%s", servicegroup_name);
+ }
+ break;
+
+ case CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME:
+ result = cmd_submitf(cmd, "%s;%lu;%lu;%d;0;%lu;%s;%s", servicegroup_name, start_time, end_time, fixed, duration, comment_author, comment_data);
+ break;
+
+ case CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME:
+ result = cmd_submitf(cmd, "%s;%lu;%lu;%d;0;%lu;%s;%s", servicegroup_name, start_time, end_time, fixed, duration, comment_author, comment_data);
+ if(affect_host_and_services == TRUE)
+ result |= cmd_submitf(CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME, "%s;%lu;%lu;%d;0;%lu;%s;%s", servicegroup_name, start_time, end_time, fixed, duration, comment_author, comment_data);
+ break;
+
+ default:
+ return ERROR;
+ break;
+ }
+
+ return result;
+ }
+
+
+
+/* write a command entry to the command file */
+int write_command_to_file(char *cmd) {
+ FILE *fp;
+ struct stat statbuf;
+
+ /*
+ * Commands are not allowed to have newlines in them, as
+ * that allows malicious users to hand-craft requests that
+ * bypass the access-restrictions.
+ */
+ if(!cmd || !*cmd || strchr(cmd, '\n'))
+ return ERROR;
+
+ /* bail out if the external command file doesn't exist */
+ if(stat(command_file, &statbuf)) {
+
+ if(content_type == WML_CONTENT)
+ printf("
Error: Could not stat() external command file!
\n");
+ else {
+ printf("
Error: Could not stat() command file '%s'!
\n", command_file);
+ printf("
");
+ printf("The external command file may be missing, Nagios may not be running, and/or Nagios may not be checking external commands.\n");
+ printf("
\n");
+ }
+
+ return ERROR;
+ }
+
+ /* open the command for writing (since this is a pipe, it will really be appended) */
+ fp = fopen(command_file, "w");
+ if(fp == NULL) {
+
+ if(content_type == WML_CONTENT)
+ printf("
Error: Could not open command file for update!
\n");
+ else {
+ printf("
Error: Could not open command file '%s' for update!
\n", command_file);
+ printf("
");
+ printf("The permissions on the external command file and/or directory may be incorrect. Read the FAQs on how to setup proper permissions.\n");
+ printf("
\n");
+ }
+
+ return ERROR;
+ }
+
+ /* write the command to file */
+ fprintf(fp, "%s\n", cmd);
+
+ /* flush buffer */
+ fflush(fp);
+
+ fclose(fp);
+
+ return OK;
+ }
+
+
+/* strips out semicolons from comment data */
+void clean_comment_data(char *buffer) {
+ int x;
+ int y;
+
+ y = (int)strlen(buffer);
+
+ for(x = 0; x < y; x++) {
+ if(buffer[x] == ';')
+ buffer[x] = ' ';
+ }
+
+ return;
+ }
+
+
+/* display information about a command */
+void show_command_help(cmd) {
+
+ printf("
Command Description
\n");
+ printf("
\n");
+ printf("
\n");
+
+ /* decide what information to print out... */
+ switch(cmd) {
+
+ case CMD_ADD_HOST_COMMENT:
+ printf("This command is used to add a comment for the specified host. If you work with other administrators, you may find it useful to share information about a host\n");
+ printf("that is having problems if more than one of you may be working on it. If you do not check the 'persistent' option, the comment will be automatically be deleted\n");
+ printf("the next time Nagios is restarted.\n");
+ break;
+
+ case CMD_ADD_SVC_COMMENT:
+ printf("This command is used to add a comment for the specified service. If you work with other administrators, you may find it useful to share information about a host\n");
+ printf("or service that is having problems if more than one of you may be working on it. If you do not check the 'persistent' option, the comment will automatically be\n");
+ printf("deleted the next time Nagios is restarted.\n");
+ break;
+
+ case CMD_DEL_HOST_COMMENT:
+ printf("This command is used to delete a specific host comment.\n");
+ break;
+
+ case CMD_DEL_SVC_COMMENT:
+ printf("This command is used to delete a specific service comment.\n");
+ break;
+
+ case CMD_DELAY_HOST_NOTIFICATION:
+ printf("This command is used to delay the next problem notification that is sent out for the specified host. The notification delay will be disregarded if\n");
+ printf("the host changes state before the next notification is scheduled to be sent out. This command has no effect if the host is currently UP.\n");
+ break;
+
+ case CMD_DELAY_SVC_NOTIFICATION:
+ printf("This command is used to delay the next problem notification that is sent out for the specified service. The notification delay will be disregarded if\n");
+ printf("the service changes state before the next notification is scheduled to be sent out. This command has no effect if the service is currently in an OK state.\n");
+ break;
+
+ case CMD_SCHEDULE_SVC_CHECK:
+ printf("This command is used to schedule the next check of a particular service. Nagios will re-queue the service to be checked at the time you specify.\n");
+ printf("If you select the force check option, Nagios will force a check of the service regardless of both what time the scheduled check occurs and whether or not checks are enabled for the service.\n");
+ break;
+
+ case CMD_ENABLE_SVC_CHECK:
+ printf("This command is used to enable active checks of a service.\n");
+ break;
+
+ case CMD_DISABLE_SVC_CHECK:
+ printf("This command is used to disable active checks of a service.\n");
+ break;
+
+ case CMD_DISABLE_NOTIFICATIONS:
+ printf("This command is used to disable host and service notifications on a program-wide basis.\n");
+ break;
+
+ case CMD_ENABLE_NOTIFICATIONS:
+ printf("This command is used to enable host and service notifications on a program-wide basis.\n");
+ break;
+
+ case CMD_SHUTDOWN_PROCESS:
+ printf("This command is used to shutdown the Nagios process. Note: Once the Nagios has been shutdown, it cannot be restarted via the web interface!\n");
+ break;
+
+ case CMD_RESTART_PROCESS:
+ printf("This command is used to restart the Nagios process. Executing a restart command is equivalent to sending the process a HUP signal.\n");
+ printf("All information will be flushed from memory, the configuration files will be re-read, and Nagios will start monitoring with the new configuration information.\n");
+ break;
+
+ case CMD_ENABLE_HOST_SVC_CHECKS:
+ printf("This command is used to enable active checks of all services associated with the specified host. This does not enable checks of the host unless you check the 'Enable for host too' option.\n");
+ break;
+
+ case CMD_DISABLE_HOST_SVC_CHECKS:
+ printf("This command is used to disable active checks of all services associated with the specified host. When a service is disabled Nagios will not monitor the service. Doing this will prevent any notifications being sent out for\n");
+ printf("the specified service while it is disabled. In order to have Nagios check the service in the future you will have to re-enable the service.\n");
+ printf("Note that disabling service checks may not necessarily prevent notifications from being sent out about the host which those services are associated with. This does not disable checks of the host unless you check the 'Disable for host too' option.\n");
+ break;
+
+ case CMD_SCHEDULE_HOST_SVC_CHECKS:
+ printf("This command is used to scheduled the next check of all services on the specified host. If you select the force check option, Nagios will force a check of all services on the host regardless of both what time the scheduled checks occur and whether or not checks are enabled for those services.\n");
+ break;
+
+ case CMD_DEL_ALL_HOST_COMMENTS:
+ printf("This command is used to delete all comments associated with the specified host.\n");
+ break;
+
+ case CMD_DEL_ALL_SVC_COMMENTS:
+ printf("This command is used to delete all comments associated with the specified service.\n");
+ break;
+
+ case CMD_ENABLE_SVC_NOTIFICATIONS:
+ printf("This command is used to enable notifications for the specified service. Notifications will only be sent out for the\n");
+ printf("service state types you defined in your service definition.\n");
+ break;
+
+ case CMD_DISABLE_SVC_NOTIFICATIONS:
+ printf("This command is used to prevent notifications from being sent out for the specified service. You will have to re-enable notifications\n");
+ printf("for this service before any alerts can be sent out in the future.\n");
+ break;
+
+ case CMD_ENABLE_HOST_NOTIFICATIONS:
+ printf("This command is used to enable notifications for the specified host. Notifications will only be sent out for the\n");
+ printf("host state types you defined in your host definition. Note that this command does not enable notifications\n");
+ printf("for services associated with this host.\n");
+ break;
+
+ case CMD_DISABLE_HOST_NOTIFICATIONS:
+ printf("This command is used to prevent notifications from being sent out for the specified host. You will have to re-enable notifications for this host\n");
+ printf("before any alerts can be sent out in the future. Note that this command does not disable notifications for services associated with this host.\n");
+ break;
+
+ case CMD_ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST:
+ printf("This command is used to enable notifications for all hosts and services that lie \"beyond\" the specified host\n");
+ printf("(from the view of Nagios).\n");
+ break;
+
+ case CMD_DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST:
+ printf("This command is used to temporarily prevent notifications from being sent out for all hosts and services that lie\n");
+ printf("\"beyond\" the specified host (from the view of Nagios).\n");
+ break;
+
+ case CMD_ENABLE_HOST_SVC_NOTIFICATIONS:
+ printf("This command is used to enable notifications for all services on the specified host. Notifications will only be sent out for the\n");
+ printf("service state types you defined in your service definition. This does not enable notifications for the host unless you check the 'Enable for host too' option.\n");
+ break;
+
+ case CMD_DISABLE_HOST_SVC_NOTIFICATIONS:
+ printf("This command is used to prevent notifications from being sent out for all services on the specified host. You will have to re-enable notifications for\n");
+ printf("all services associated with this host before any alerts can be sent out in the future. This does not prevent notifications from being sent out about the host unless you check the 'Disable for host too' option.\n");
+ break;
+
+ case CMD_ACKNOWLEDGE_HOST_PROBLEM:
+ printf("This command is used to acknowledge a host problem. When a host problem is acknowledged, future notifications about problems are temporarily disabled until the host changes from its current state.\n");
+ printf("If you want acknowledgement to disable notifications until the host recovers, check the 'Sticky Acknowledgement' checkbox.\n");
+ printf("Contacts for this host will receive a notification about the acknowledgement, so they are aware that someone is working on the problem. Additionally, a comment will also be added to the host.\n");
+ printf("Make sure to enter your name and fill in a brief description of what you are doing in the comment field. If you would like the host comment to remain once the acknowledgement is removed, check\n");
+ printf("the 'Persistent Comment' checkbox. If you do not want an acknowledgement notification sent out to the appropriate contacts, uncheck the 'Send Notification' checkbox.\n");
+ break;
+
+ case CMD_ACKNOWLEDGE_SVC_PROBLEM:
+ printf("This command is used to acknowledge a service problem. When a service problem is acknowledged, future notifications about problems are temporarily disabled until the service changes from its current state.\n");
+ printf("If you want acknowledgement to disable notifications until the service recovers, check the 'Sticky Acknowledgement' checkbox.\n");
+ printf("Contacts for this service will receive a notification about the acknowledgement, so they are aware that someone is working on the problem. Additionally, a comment will also be added to the service.\n");
+ printf("Make sure to enter your name and fill in a brief description of what you are doing in the comment field. If you would like the service comment to remain once the acknowledgement is removed, check\n");
+ printf("the 'Persistent Comment' checkbox. If you do not want an acknowledgement notification sent out to the appropriate contacts, uncheck the 'Send Notification' checkbox.\n");
+ break;
+
+ case CMD_START_EXECUTING_SVC_CHECKS:
+ printf("This command is used to resume execution of active service checks on a program-wide basis. Individual services which are disabled will still not be checked.\n");
+ break;
+
+ case CMD_STOP_EXECUTING_SVC_CHECKS:
+ printf("This command is used to temporarily stop Nagios from actively executing any service checks. This will have the side effect of preventing any notifications from being sent out (for any and all services and hosts).\n");
+ printf("Service checks will not be executed again until you issue a command to resume service check execution.\n");
+ break;
+
+ case CMD_START_ACCEPTING_PASSIVE_SVC_CHECKS:
+ printf("This command is used to make Nagios start accepting passive service check results that it finds in the external command file\n");
+ break;
+
+ case CMD_STOP_ACCEPTING_PASSIVE_SVC_CHECKS:
+ printf("This command is use to make Nagios stop accepting passive service check results that it finds in the external command file. All passive check results that are found will be ignored.\n");
+ break;
+
+ case CMD_ENABLE_PASSIVE_SVC_CHECKS:
+ printf("This command is used to allow Nagios to accept passive service check results that it finds in the external command file for this particular service.\n");
+ break;
+
+ case CMD_DISABLE_PASSIVE_SVC_CHECKS:
+ printf("This command is used to stop Nagios accepting passive service check results that it finds in the external command file for this particular service. All passive check results that are found for this service will be ignored.\n");
+ break;
+
+ case CMD_ENABLE_EVENT_HANDLERS:
+ printf("This command is used to allow Nagios to run host and service event handlers.\n");
+ break;
+
+ case CMD_DISABLE_EVENT_HANDLERS:
+ printf("This command is used to temporarily prevent Nagios from running any host or service event handlers.\n");
+ break;
+
+ case CMD_ENABLE_SVC_EVENT_HANDLER:
+ printf("This command is used to allow Nagios to run the service event handler for a particular service when necessary (if one is defined).\n");
+ break;
+
+ case CMD_DISABLE_SVC_EVENT_HANDLER:
+ printf("This command is used to temporarily prevent Nagios from running the service event handler for a particular service.\n");
+ break;
+
+ case CMD_ENABLE_HOST_EVENT_HANDLER:
+ printf("This command is used to allow Nagios to run the host event handler for a particular service when necessary (if one is defined).\n");
+ break;
+
+ case CMD_DISABLE_HOST_EVENT_HANDLER:
+ printf("This command is used to temporarily prevent Nagios from running the host event handler for a particular host.\n");
+ break;
+
+ case CMD_ENABLE_HOST_CHECK:
+ printf("This command is used to enable active checks of this host.\n");
+ break;
+
+ case CMD_DISABLE_HOST_CHECK:
+ printf("This command is used to temporarily prevent Nagios from actively checking the status of a particular host. If Nagios needs to check the status of this host, it will assume that it is in the same state that it was in before checks were disabled.\n");
+ break;
+
+ case CMD_START_OBSESSING_OVER_SVC_CHECKS:
+ printf("This command is used to have Nagios start obsessing over service checks. Read the documentation on distributed monitoring for more information on this.\n");
+ break;
+
+ case CMD_STOP_OBSESSING_OVER_SVC_CHECKS:
+ printf("This command is used stop Nagios from obsessing over service checks.\n");
+ break;
+
+ case CMD_REMOVE_HOST_ACKNOWLEDGEMENT:
+ printf("This command is used to remove an acknowledgement for a particular host problem. Once the acknowledgement is removed, notifications may start being\n");
+ printf("sent out about the host problem. \n");
+ break;
+
+ case CMD_REMOVE_SVC_ACKNOWLEDGEMENT:
+ printf("This command is used to remove an acknowledgement for a particular service problem. Once the acknowledgement is removed, notifications may start being\n");
+ printf("sent out about the service problem.\n");
+ break;
+
+ case CMD_PROCESS_SERVICE_CHECK_RESULT:
+ printf("This command is used to submit a passive check result for a particular service. It is particularly useful for resetting security-related services to OK states once they have been dealt with.\n");
+ break;
+
+ case CMD_PROCESS_HOST_CHECK_RESULT:
+ printf("This command is used to submit a passive check result for a particular host.\n");
+ break;
+
+ case CMD_SCHEDULE_HOST_DOWNTIME:
+ printf("This command is used to schedule downtime for a particular host. During the specified downtime, Nagios will not send notifications out about the host.\n");
+ printf("When the scheduled downtime expires, Nagios will send out notifications for this host as it normally would. Scheduled downtimes are preserved\n");
+ printf("across program shutdowns and restarts. Both the start and end times should be specified in the following format: mm/dd/yyyy hh:mm:ss.\n");
+ printf("If you select the fixed option, the downtime will be in effect between the start and end times you specify. If you do not select the fixed\n");
+ printf("option, Nagios will treat this as \"flexible\" downtime. Flexible downtime starts when the host goes down or becomes unreachable (sometime between the\n");
+ printf("start and end times you specified) and lasts as long as the duration of time you enter. The duration fields do not apply for fixed downtime.\n");
+ break;
+
+ case CMD_SCHEDULE_HOST_SVC_DOWNTIME:
+ printf("This command is used to schedule downtime for all services on a particular host. During the specified downtime, Nagios will not send notifications out about the host.\n");
+ printf("Normally, a host in downtime will not send alerts about any services in a failed state. This option will explicitly set downtime for all services for this host.\n");
+ printf("When the scheduled downtime expires, Nagios will send out notifications for this host as it normally would. Scheduled downtimes are preserved\n");
+ printf("across program shutdowns and restarts. Both the start and end times should be specified in the following format: mm/dd/yyyy hh:mm:ss.\n");
+ printf("If you select the fixed option, the downtime will be in effect between the start and end times you specify. If you do not select the fixed\n");
+ printf("option, Nagios will treat this as \"flexible\" downtime. Flexible downtime starts when the host goes down or becomes unreachable (sometime between the\n");
+ printf("start and end times you specified) and lasts as long as the duration of time you enter. The duration fields do not apply for fixed downtime.\n");
+ break;
+
+ case CMD_SCHEDULE_SVC_DOWNTIME:
+ printf("This command is used to schedule downtime for a particular service. During the specified downtime, Nagios will not send notifications out about the service.\n");
+ printf("When the scheduled downtime expires, Nagios will send out notifications for this service as it normally would. Scheduled downtimes are preserved\n");
+ printf("across program shutdowns and restarts. Both the start and end times should be specified in the following format: mm/dd/yyyy hh:mm:ss.\n");
+ printf("If you select the fixed option, the downtime will be in effect between the start and end times you specify. If you do not select the fixed\n");
+ printf("option, Nagios will treat this as \"flexible\" downtime. Flexible downtime starts when the service enters a non-OK state (sometime between the\n");
+ printf("start and end times you specified) and lasts as long as the duration of time you enter. The duration fields do not apply for fixed downtime.\n");
+ break;
+
+ case CMD_ENABLE_HOST_FLAP_DETECTION:
+ printf("This command is used to enable flap detection for a specific host. If flap detection is disabled on a program-wide basis, this will have no effect,\n");
+ break;
+
+ case CMD_DISABLE_HOST_FLAP_DETECTION:
+ printf("This command is used to disable flap detection for a specific host.\n");
+ break;
+
+ case CMD_ENABLE_SVC_FLAP_DETECTION:
+ printf("This command is used to enable flap detection for a specific service. If flap detection is disabled on a program-wide basis, this will have no effect,\n");
+ break;
+
+ case CMD_DISABLE_SVC_FLAP_DETECTION:
+ printf("This command is used to disable flap detection for a specific service.\n");
+ break;
+
+ case CMD_ENABLE_FLAP_DETECTION:
+ printf("This command is used to enable flap detection for hosts and services on a program-wide basis. Individual hosts and services may have flap detection disabled.\n");
+ break;
+
+ case CMD_DISABLE_FLAP_DETECTION:
+ printf("This command is used to disable flap detection for hosts and services on a program-wide basis.\n");
+ break;
+
+ case CMD_ENABLE_HOSTGROUP_SVC_NOTIFICATIONS:
+ printf("This command is used to enable notifications for all services in the specified hostgroup. Notifications will only be sent out for the\n");
+ printf("service state types you defined in your service definitions. This does not enable notifications for the hosts in this hostgroup unless you check the 'Enable for hosts too' option.\n");
+ break;
+
+ case CMD_DISABLE_HOSTGROUP_SVC_NOTIFICATIONS:
+ printf("This command is used to prevent notifications from being sent out for all services in the specified hostgroup. You will have to re-enable notifications for\n");
+ printf("all services in this hostgroup before any alerts can be sent out in the future. This does not prevent notifications from being sent out about the hosts in this hostgroup unless you check the 'Disable for hosts too' option.\n");
+ break;
+
+ case CMD_ENABLE_HOSTGROUP_HOST_NOTIFICATIONS:
+ printf("This command is used to enable notifications for all hosts in the specified hostgroup. Notifications will only be sent out for the\n");
+ printf("host state types you defined in your host definitions.\n");
+ break;
+
+ case CMD_DISABLE_HOSTGROUP_HOST_NOTIFICATIONS:
+ printf("This command is used to prevent notifications from being sent out for all hosts in the specified hostgroup. You will have to re-enable notifications for\n");
+ printf("all hosts in this hostgroup before any alerts can be sent out in the future.\n");
+ break;
+
+ case CMD_ENABLE_HOSTGROUP_SVC_CHECKS:
+ printf("This command is used to enable active checks of all services in the specified hostgroup. This does not enable active checks of the hosts in the hostgroup unless you check the 'Enable for hosts too' option.\n");
+ break;
+
+ case CMD_DISABLE_HOSTGROUP_SVC_CHECKS:
+ printf("This command is used to disable active checks of all services in the specified hostgroup. This does not disable checks of the hosts in the hostgroup unless you check the 'Disable for hosts too' option.\n");
+ break;
+
+ case CMD_DEL_HOST_DOWNTIME:
+ printf("This command is used to cancel active or pending scheduled downtime for the specified host.\n");
+ break;
+
+ case CMD_DEL_SVC_DOWNTIME:
+ printf("This command is used to cancel active or pending scheduled downtime for the specified service.\n");
+ break;
+
+ case CMD_ENABLE_FAILURE_PREDICTION:
+ printf("This command is used to enable failure prediction for hosts and services on a program-wide basis. Individual hosts and services may have failure prediction disabled.\n");
+ break;
+
+ case CMD_DISABLE_FAILURE_PREDICTION:
+ printf("This command is used to disable failure prediction for hosts and services on a program-wide basis.\n");
+ break;
+
+ case CMD_ENABLE_PERFORMANCE_DATA:
+ printf("This command is used to enable the processing of performance data for hosts and services on a program-wide basis. Individual hosts and services may have performance data processing disabled.\n");
+ break;
+
+ case CMD_DISABLE_PERFORMANCE_DATA:
+ printf("This command is used to disable the processing of performance data for hosts and services on a program-wide basis.\n");
+ break;
+
+ case CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME:
+ printf("This command is used to schedule downtime for all hosts in a particular hostgroup. During the specified downtime, Nagios will not send notifications out about the hosts.\n");
+ printf("When the scheduled downtime expires, Nagios will send out notifications for the hosts as it normally would. Scheduled downtimes are preserved\n");
+ printf("across program shutdowns and restarts. Both the start and end times should be specified in the following format: mm/dd/yyyy hh:mm:ss.\n");
+ printf("If you select the fixed option, the downtime will be in effect between the start and end times you specify. If you do not select the fixed\n");
+ printf("option, Nagios will treat this as \"flexible\" downtime. Flexible downtime starts when a host goes down or becomes unreachable (sometime between the\n");
+ printf("start and end times you specified) and lasts as long as the duration of time you enter. The duration fields do not apply for fixed dowtime.\n");
+ break;
+
+ case CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME:
+ printf("This command is used to schedule downtime for all services in a particular hostgroup. During the specified downtime, Nagios will not send notifications out about the services.\n");
+ printf("When the scheduled downtime expires, Nagios will send out notifications for the services as it normally would. Scheduled downtimes are preserved\n");
+ printf("across program shutdowns and restarts. Both the start and end times should be specified in the following format: mm/dd/yyyy hh:mm:ss.\n");
+ printf("If you select the fixed option, the downtime will be in effect between the start and end times you specify. If you do not select the fixed\n");
+ printf("option, Nagios will treat this as \"flexible\" downtime. Flexible downtime starts when a service enters a non-OK state (sometime between the\n");
+ printf("start and end times you specified) and lasts as long as the duration of time you enter. The duration fields do not apply for fixed dowtime.\n");
+ printf("Note that scheduling downtime for services does not automatically schedule downtime for the hosts those services are associated with. If you want to also schedule downtime for all hosts in the hostgroup, check the 'Schedule downtime for hosts too' option.\n");
+ break;
+
+ case CMD_START_EXECUTING_HOST_CHECKS:
+ printf("This command is used to enable active host checks on a program-wide basis.\n");
+ break;
+
+ case CMD_STOP_EXECUTING_HOST_CHECKS:
+ printf("This command is used to disable active host checks on a program-wide basis.\n");
+ break;
+
+ case CMD_START_ACCEPTING_PASSIVE_HOST_CHECKS:
+ printf("This command is used to have Nagios start obsessing over host checks. Read the documentation on distributed monitoring for more information on this.\n");
+ break;
+
+ case CMD_STOP_ACCEPTING_PASSIVE_HOST_CHECKS:
+ printf("This command is used to stop Nagios from obsessing over host checks.\n");
+ break;
+
+ case CMD_ENABLE_PASSIVE_HOST_CHECKS:
+ printf("This command is used to allow Nagios to accept passive host check results that it finds in the external command file for a particular host.\n");
+ break;
+
+ case CMD_DISABLE_PASSIVE_HOST_CHECKS:
+ printf("This command is used to stop Nagios from accepting passive host check results that it finds in the external command file for a particular host. All passive check results that are found for this host will be ignored.\n");
+ break;
+
+ case CMD_START_OBSESSING_OVER_HOST_CHECKS:
+ printf("This command is used to have Nagios start obsessing over host checks. Read the documentation on distributed monitoring for more information on this.\n");
+ break;
+
+ case CMD_STOP_OBSESSING_OVER_HOST_CHECKS:
+ printf("This command is used to stop Nagios from obsessing over host checks.\n");
+ break;
+
+ case CMD_SCHEDULE_HOST_CHECK:
+ printf("This command is used to schedule the next check of a particular host. Nagios will re-queue the host to be checked at the time you specify.\n");
+ printf("If you select the force check option, Nagios will force a check of the host regardless of both what time the scheduled check occurs and whether or not checks are enabled for the host.\n");
+ break;
+
+ case CMD_START_OBSESSING_OVER_SVC:
+ printf("This command is used to have Nagios start obsessing over a particular service.\n");
+ break;
+
+ case CMD_STOP_OBSESSING_OVER_SVC:
+ printf("This command is used to stop Nagios from obsessing over a particular service.\n");
+ break;
+
+ case CMD_START_OBSESSING_OVER_HOST:
+ printf("This command is used to have Nagios start obsessing over a particular host.\n");
+ break;
+
+ case CMD_STOP_OBSESSING_OVER_HOST:
+ printf("This command is used to stop Nagios from obsessing over a particular host.\n");
+ break;
+
+ case CMD_ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS:
+ printf("This command is used to enable notifications for all services in the specified servicegroup. Notifications will only be sent out for the\n");
+ printf("service state types you defined in your service definitions. This does not enable notifications for the hosts in this servicegroup unless you check the 'Enable for hosts too' option.\n");
+ break;
+
+ case CMD_DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS:
+ printf("This command is used to prevent notifications from being sent out for all services in the specified servicegroup. You will have to re-enable notifications for\n");
+ printf("all services in this servicegroup before any alerts can be sent out in the future. This does not prevent notifications from being sent out about the hosts in this servicegroup unless you check the 'Disable for hosts too' option.\n");
+ break;
+
+ case CMD_ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS:
+ printf("This command is used to enable notifications for all hosts in the specified servicegroup. Notifications will only be sent out for the\n");
+ printf("host state types you defined in your host definitions.\n");
+ break;
+
+ case CMD_DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS:
+ printf("This command is used to prevent notifications from being sent out for all hosts in the specified servicegroup. You will have to re-enable notifications for\n");
+ printf("all hosts in this servicegroup before any alerts can be sent out in the future.\n");
+ break;
+
+ case CMD_ENABLE_SERVICEGROUP_SVC_CHECKS:
+ printf("This command is used to enable active checks of all services in the specified servicegroup. This does not enable active checks of the hosts in the servicegroup unless you check the 'Enable for hosts too' option.\n");
+ break;
+
+ case CMD_DISABLE_SERVICEGROUP_SVC_CHECKS:
+ printf("This command is used to disable active checks of all services in the specified servicegroup. This does not disable checks of the hosts in the servicegroup unless you check the 'Disable for hosts too' option.\n");
+ break;
+
+ case CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME:
+ printf("This command is used to schedule downtime for all hosts in a particular servicegroup. During the specified downtime, Nagios will not send notifications out about the hosts.\n");
+ printf("When the scheduled downtime expires, Nagios will send out notifications for the hosts as it normally would. Scheduled downtimes are preserved\n");
+ printf("across program shutdowns and restarts. Both the start and end times should be specified in the following format: mm/dd/yyyy hh:mm:ss.\n");
+ printf("If you select the fixed option, the downtime will be in effect between the start and end times you specify. If you do not select the fixed\n");
+ printf("option, Nagios will treat this as \"flexible\" downtime. Flexible downtime starts when a host goes down or becomes unreachable (sometime between the\n");
+ printf("start and end times you specified) and lasts as long as the duration of time you enter. The duration fields do not apply for fixed dowtime.\n");
+ break;
+
+ case CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME:
+ printf("This command is used to schedule downtime for all services in a particular servicegroup. During the specified downtime, Nagios will not send notifications out about the services.\n");
+ printf("When the scheduled downtime expires, Nagios will send out notifications for the services as it normally would. Scheduled downtimes are preserved\n");
+ printf("across program shutdowns and restarts. Both the start and end times should be specified in the following format: mm/dd/yyyy hh:mm:ss.\n");
+ printf("If you select the fixed option, the downtime will be in effect between the start and end times you specify. If you do not select the fixed\n");
+ printf("option, Nagios will treat this as \"flexible\" downtime. Flexible downtime starts when a service enters a non-OK state (sometime between the\n");
+ printf("start and end times you specified) and lasts as long as the duration of time you enter. The duration fields do not apply for fixed dowtime.\n");
+ printf("Note that scheduling downtime for services does not automatically schedule downtime for the hosts those services are associated with. If you want to also schedule downtime for all hosts in the servicegroup, check the 'Schedule downtime for hosts too' option.\n");
+ break;
+
+ case CMD_SEND_CUSTOM_HOST_NOTIFICATION:
+ case CMD_SEND_CUSTOM_SVC_NOTIFICATION:
+ printf("This command is used to send a custom notification about the specified %s. Useful in emergencies when you need to notify admins of an issue regarding a monitored system or service.\n", (cmd == CMD_SEND_CUSTOM_HOST_NOTIFICATION) ? "host" : "service");
+ printf("Custom notifications normally follow the regular notification logic in Nagios. Selecting the Forced option will force the notification to be sent out, regardless of the time restrictions, whether or not notifications are enabled, etc. Selecting the Broadcast option causes the notification to be sent out to all normal (non-escalated) and escalated contacts. These options allow you to override the normal notification logic if you need to get an important message out.\n");
+ break;
+
+ default:
+ printf("Sorry, but no information is available for this command.");
+ }
+
+ printf("
\n");
+ printf("
\n");
+
+ return;
+ }
+
+
+
+/* converts a time string to a UNIX timestamp, respecting the date_format option */
+int string_to_time(char *buffer, time_t *t) {
+ struct tm lt;
+ int ret = 0;
+
+
+ /* Initialize some variables just in case they don't get parsed
+ by the sscanf() call. A better solution is to also check the
+ CGI input for validity, but this should suffice to prevent
+ strange problems if the input is not valid.
+ Jan 15 2003 Steve Bonds */
+ lt.tm_mon = 0;
+ lt.tm_mday = 1;
+ lt.tm_year = 1900;
+ lt.tm_hour = 0;
+ lt.tm_min = 0;
+ lt.tm_sec = 0;
+ lt.tm_wday = 0;
+ lt.tm_yday = 0;
+
+
+ if(date_format == DATE_FORMAT_EURO)
+ ret = sscanf(buffer, "%02d-%02d-%04d %02d:%02d:%02d", <.tm_mday, <.tm_mon, <.tm_year, <.tm_hour, <.tm_min, <.tm_sec);
+ else if(date_format == DATE_FORMAT_ISO8601 || date_format == DATE_FORMAT_STRICT_ISO8601)
+ ret = sscanf(buffer, "%04d-%02d-%02d%*[ T]%02d:%02d:%02d", <.tm_year, <.tm_mon, <.tm_mday, <.tm_hour, <.tm_min, <.tm_sec);
+ else
+ ret = sscanf(buffer, "%02d-%02d-%04d %02d:%02d:%02d", <.tm_mon, <.tm_mday, <.tm_year, <.tm_hour, <.tm_min, <.tm_sec);
+
+ if(ret != 6)
+ return ERROR;
+
+ lt.tm_mon--;
+ lt.tm_year -= 1900;
+
+ /* tell mktime() to try and compute DST automatically */
+ lt.tm_isdst = -1;
+
+ *t = mktime(<);
+
+ return OK;
+ }
diff --git a/cgi/config.c b/cgi/config.c
new file mode 100644
index 0000000..ae1c693
--- /dev/null
+++ b/cgi/config.c
@@ -0,0 +1,2483 @@
+/***********************************************************************
+ *
+ * CONFIG.C - Nagios Configuration CGI (View Only)
+ *
+ * Copyright (c) 1999-2009 Ethan Galstad (egalstad@nagios.org)
+ * Last Modified: 05-15-2009
+ *
+ * This CGI program will display various configuration information.
+ *
+ *
+ * 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.
+ ***********************************************************************/
+
+#include "../include/config.h"
+#include "../include/common.h"
+#include "../include/objects.h"
+#include "../include/macros.h"
+#include "../include/cgiutils.h"
+#include "../include/cgiauth.h"
+#include "../include/getcgi.h"
+
+static nagios_macros *mac;
+
+extern char main_config_file[MAX_FILENAME_LENGTH];
+extern char url_html_path[MAX_FILENAME_LENGTH];
+extern char url_docs_path[MAX_FILENAME_LENGTH];
+extern char url_images_path[MAX_FILENAME_LENGTH];
+extern char url_logo_images_path[MAX_FILENAME_LENGTH];
+extern char url_stylesheets_path[MAX_FILENAME_LENGTH];
+
+extern host *host_list;
+extern service *service_list;
+extern hostgroup *hostgroup_list;
+extern servicegroup *servicegroup_list;
+extern contactgroup *contactgroup_list;
+extern command *command_list;
+extern timeperiod *timeperiod_list;
+extern contact *contact_list;
+extern servicedependency *servicedependency_list;
+extern serviceescalation *serviceescalation_list;
+extern hostdependency *hostdependency_list;
+extern hostescalation *hostescalation_list;
+
+
+#define DISPLAY_NONE 0
+#define DISPLAY_HOSTS 1
+#define DISPLAY_HOSTGROUPS 2
+#define DISPLAY_CONTACTS 3
+#define DISPLAY_CONTACTGROUPS 4
+#define DISPLAY_SERVICES 5
+#define DISPLAY_TIMEPERIODS 6
+#define DISPLAY_COMMANDS 7
+#define DISPLAY_HOSTGROUPESCALATIONS 8 /* no longer implemented */
+#define DISPLAY_SERVICEDEPENDENCIES 9
+#define DISPLAY_SERVICEESCALATIONS 10
+#define DISPLAY_HOSTDEPENDENCIES 11
+#define DISPLAY_HOSTESCALATIONS 12
+#define DISPLAY_SERVICEGROUPS 15
+#define DISPLAY_COMMAND_EXPANSION 16211
+
+void document_header(int);
+void document_footer(void);
+int process_cgivars(void);
+
+void display_options(void);
+
+void display_hosts(void);
+void display_hostgroups(void);
+void display_servicegroups(void);
+void display_contacts(void);
+void display_contactgroups(void);
+void display_services(void);
+void display_timeperiods(void);
+void display_commands(void);
+void display_servicedependencies(void);
+void display_serviceescalations(void);
+void display_hostdependencies(void);
+void display_hostescalations(void);
+void display_command_expansion(void);
+
+void unauthorized_message(void);
+
+
+authdata current_authdata;
+
+int display_type = DISPLAY_NONE;
+char to_expand[MAX_COMMAND_BUFFER];
+char hashed_color[8];
+
+int embedded = FALSE;
+
+void print_expand_input(int type) {
+ char *seldesc = "";
+
+ if(type == DISPLAY_COMMAND_EXPANSION) return; /* Has its own form, w/ larger */
+ else if(type == DISPLAY_SERVICES) {
+ seldesc = " Services Named or on Host";
+ }
+ else if(type == DISPLAY_SERVICEDEPENDENCIES) {
+ seldesc = " Dependencies with Host";
+ }
+ else if(type == DISPLAY_SERVICEESCALATIONS) {
+ seldesc = " Escalations on Host";
+ }
+ else if(type == DISPLAY_HOSTDEPENDENCIES) {
+ seldesc = " Dependencies on/of Host";
+ }
+ else if(type == DISPLAY_HOSTESCALATIONS) {
+ seldesc = " Escalations for Host";
+ }
+ printf("
Show Only%s:
\n", seldesc);
+ printf("
", html_encode(to_expand, FALSE));
+ }
+
+int main(void) {
+ int result = OK;
+ mac = get_global_macros();
+
+ /* get the arguments passed in the URL */
+ process_cgivars();
+
+ /* reset internal variables */
+ reset_cgi_vars();
+
+ /* read the CGI configuration file */
+ result = read_cgi_config_file(get_cgi_config_location());
+ if(result == ERROR) {
+ document_header(FALSE);
+ cgi_config_file_error(get_cgi_config_location());
+ document_footer();
+ return ERROR;
+ }
+
+ /* read the main configuration file */
+ result = read_main_config_file(main_config_file);
+ if(result == ERROR) {
+ document_header(FALSE);
+ main_config_file_error(main_config_file);
+ document_footer();
+ return ERROR;
+ }
+
+ /* read all object configuration data */
+ result = read_all_object_configuration_data(main_config_file, READ_ALL_OBJECT_DATA);
+ if(result == ERROR) {
+ document_header(FALSE);
+ object_data_error();
+ document_footer();
+ return ERROR;
+ }
+
+ /* initialize macros */
+ init_macros();
+
+ document_header(TRUE);
+
+ /* get authentication information */
+ get_authentication_information(¤t_authdata);
+
+ /* begin top table */
+ printf("
\n");
+ printf("
\n");
+
+ /* left column of the first row */
+ printf("
It appears as though you do not have permission to view the configuration information you requested...
\n");
+ printf("
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI ");
+ printf("and check the authorization options in your CGI configuration file.
It appears as though you do not have permission to view process information...
\n");
+ printf("
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI ");
+ printf("and check the authorization options in your CGI configuration file.
It appears as though Nagios is not running, so commands are temporarily unavailable...\n");
+ if(!strcmp(nagios_check_command, "")) {
+ printf("
\n");
+ printf("Hint: It looks as though you have not defined a command for checking the process state by supplying a value for the nagios_check_command option in the CGI configuration file. \n");
+ printf("Read the documentation for more information on checking the status of the Nagios process in the CGIs.\n");
+ }
+ printf("
\n");
+ }
+
+ printf("
\n");
+ printf("
\n");
+
+ printf("
\n");
+ printf("
\n");
+ }
+
+
+void show_host_info(void) {
+ hoststatus *temp_hoststatus;
+ host *temp_host;
+ char date_time[MAX_DATETIME_LENGTH];
+ char state_duration[48];
+ char status_age[48];
+ char state_string[MAX_INPUT_BUFFER];
+ char *bg_class = "";
+ char *buf = NULL;
+ int days;
+ int hours;
+ int minutes;
+ int seconds;
+ time_t current_time;
+ time_t t;
+ int duration_error = FALSE;
+
+
+ /* get host info */
+ temp_host = find_host(host_name);
+
+ /* make sure the user has rights to view host information */
+ if(is_authorized_for_host(temp_host, ¤t_authdata) == FALSE) {
+
+ printf("
It appears as though you do not have permission to view information for this host...
\n");
+ printf("
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI ");
+ printf("and check the authorization options in your CGI configuration file.
\n");
+
+ return;
+ }
+
+ /* get host status info */
+ temp_hoststatus = find_hoststatus(host_name);
+
+ /* make sure host information exists */
+ if(temp_host == NULL) {
+ printf("
\n");
+ printf("\n");
+
+ return;
+ }
+
+
+void show_service_info(void) {
+ service *temp_service;
+ char date_time[MAX_DATETIME_LENGTH];
+ char status_age[48];
+ char state_duration[48];
+ servicestatus *temp_svcstatus;
+ char state_string[MAX_INPUT_BUFFER];
+ char *bg_class = "";
+ char *buf = NULL;
+ int days;
+ int hours;
+ int minutes;
+ int seconds;
+ time_t t;
+ time_t current_time;
+ int duration_error = FALSE;
+
+ /* find the service */
+ temp_service = find_service(host_name, service_desc);
+
+ /* make sure the user has rights to view service information */
+ if(is_authorized_for_service(temp_service, ¤t_authdata) == FALSE) {
+
+ printf("
It appears as though you do not have permission to view information for this service...
\n");
+ printf("
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI ");
+ printf("and check the authorization options in your CGI configuration file.
\n");
+
+ return;
+ }
+
+ /* get service status info */
+ temp_svcstatus = find_servicestatus(host_name, service_desc);
+
+ /* make sure service information exists */
+ if(temp_service == NULL) {
+ printf("
\n");
+
+ return;
+ }
+
+
+
+
+void show_hostgroup_info(void) {
+ hostgroup *temp_hostgroup;
+
+
+ /* get hostgroup info */
+ temp_hostgroup = find_hostgroup(hostgroup_name);
+
+ /* make sure the user has rights to view hostgroup information */
+ if(is_authorized_for_hostgroup(temp_hostgroup, ¤t_authdata) == FALSE) {
+
+ printf("
It appears as though you do not have permission to view information for this hostgroup...
\n");
+ printf("
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI ");
+ printf("and check the authorization options in your CGI configuration file.
\n");
+
+
+
+ return;
+ }
+
+
+
+
+void show_servicegroup_info() {
+ servicegroup *temp_servicegroup;
+
+
+ /* get servicegroup info */
+ temp_servicegroup = find_servicegroup(servicegroup_name);
+
+ /* make sure the user has rights to view servicegroup information */
+ if(is_authorized_for_servicegroup(temp_servicegroup, ¤t_authdata) == FALSE) {
+
+ printf("
It appears as though you do not have permission to view information for this servicegroup...
\n");
+ printf("
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI ");
+ printf("and check the authorization options in your CGI configuration file.
\n");
+
+
+ /***** ACTIVE SERVICE CHECKS *****/
+
+ printf("
\n");
+ printf("
Services Actively Checked:
\n");
+ printf("
\n");
+
+ /* fake this so we don't divide by zero for just showing the table */
+ if(total_active_service_checks == 0)
+ total_active_service_checks = 1;
+
+ printf("
\n");
+
+
+ /* fake this so we don't divide by zero for just showing the table */
+ if(total_passive_service_checks == 0)
+ total_passive_service_checks = 1;
+
+ printf("
\n");
+
+ /* fake this so we don't divide by zero for just showing the table */
+ if(total_active_host_checks == 0)
+ total_active_host_checks = 1;
+
+ printf("
\n");
+
+
+ /* fake this so we don't divide by zero for just showing the table */
+ if(total_passive_host_checks == 0)
+ total_passive_host_checks = 1;
+
+ printf("
\n");
+
+ return;
+ }
+
+
+
+/* shows check scheduling queue */
+void show_scheduling_queue(void) {
+ sortdata *temp_sortdata;
+ servicestatus *temp_svcstatus = NULL;
+ hoststatus *temp_hststatus = NULL;
+ char date_time[MAX_DATETIME_LENGTH];
+ char temp_url[MAX_INPUT_BUFFER];
+ int odd = 0;
+ char *bgclass = "";
+
+
+ /* make sure the user has rights to view system information */
+ if(is_authorized_for_system_information(¤t_authdata) == FALSE) {
+
+ printf("
It appears as though you do not have permission to view process information...
\n");
+ printf("
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI ");
+ printf("and check the authorization options in your CGI configuration file.
\n");
+ }
+
+ /* read and process state data */
+ else {
+
+ /* allocate memory */
+ tsdata = NULL;
+ if(breakdown_type == BREAKDOWN_MONTHLY)
+ total_buckets = 12;
+ else if(breakdown_type == BREAKDOWN_DAY_OF_MONTH)
+ total_buckets = 31;
+ else if(breakdown_type == BREAKDOWN_DAY_OF_WEEK)
+ total_buckets = 7;
+ else
+ total_buckets = 96;
+
+ tsdata = (timeslice_data *)malloc(sizeof(timeslice_data) * total_buckets);
+ if(tsdata == NULL)
+ return ERROR;
+
+ for(x = 0; x < total_buckets; x++) {
+ tsdata[x].service_ok = 0L;
+ tsdata[x].service_unknown = 0L;
+ tsdata[x].service_warning = 0L;
+ tsdata[x].service_critical = 0L;
+ tsdata[x].host_up = 0L;
+ tsdata[x].host_down = 0L;
+ tsdata[x].host_unreachable = 0L;
+ }
+
+ /* read in all necessary archived state data */
+ read_archived_state_data();
+
+#ifdef DEBUG
+ printf("Done reading archived state data.\n");
+#endif
+
+ /* location of image template */
+ snprintf(image_template, sizeof(image_template) - 1, "%s/%s", physical_images_path, HISTOGRAM_IMAGE);
+ image_template[sizeof(image_template) - 1] = '\x0';
+
+ /* allocate buffer for storing image */
+ image_file = fopen(image_template, "r");
+ if(image_file != NULL) {
+ histogram_image = gdImageCreateFromPng(image_file);
+ fclose(image_file);
+ }
+ if(histogram_image == NULL)
+ histogram_image = gdImageCreate(image_width, image_height);
+ if(histogram_image == NULL) {
+#ifdef DEBUG
+ printf("Error: Could not allocate memory for image\n");
+#endif
+ return ERROR;
+ }
+
+ /* allocate colors used for drawing */
+ color_white = gdImageColorAllocate(histogram_image, 255, 255, 255);
+ color_black = gdImageColorAllocate(histogram_image, 0, 0, 0);
+ color_red = gdImageColorAllocate(histogram_image, 255, 0, 0);
+ color_darkred = gdImageColorAllocate(histogram_image, 128, 0, 0);
+ color_green = gdImageColorAllocate(histogram_image, 0, 128, 0);
+ color_yellow = gdImageColorAllocate(histogram_image, 176, 178, 20);
+ color_orange = gdImageColorAllocate(histogram_image, 255, 100, 25);
+ color_lightgray = gdImageColorAllocate(histogram_image, 192, 192, 192);
+
+ /* set transparency index */
+ gdImageColorTransparent(histogram_image, color_white);
+
+ /* make sure the graphic is interlaced */
+ gdImageInterlace(histogram_image, 1);
+
+#ifdef DEBUG
+ printf("Starting to graph data...\n");
+#endif
+
+ /* graph archived state histogram data */
+ graph_all_histogram_data();
+
+#ifdef DEBUG
+ printf("Done graphing data.\n");
+#endif
+
+ /* use STDOUT for writing the image data... */
+ image_file = stdout;
+
+#ifdef DEBUG
+ image_file = fopen("/tmp/histogram.png", "w");
+#endif
+
+ /* write the image to to STDOUT */
+ gdImagePng(histogram_image, image_file);
+
+#ifdef DEBUG
+ fclose(image_file);
+#endif
+
+ /* free memory allocated to image */
+ gdImageDestroy(histogram_image);
+
+ /* free memory allocated for data */
+ free(tsdata);
+ }
+ }
+
+
+ /* show user a selection of hosts and services to choose from... */
+ if(display_type == DISPLAY_NO_HISTOGRAM || input_type != GET_INPUT_NONE) {
+
+ /* ask the user for what host they want a report for */
+ if(input_type == GET_INPUT_HOST_TARGET) {
+
+ printf("
\n");
+ printf("
Step 2: Select Host
\n");
+ printf("
\n");
+
+ printf("
\n");
+
+ printf("\n");
+
+ printf("
\n");
+ }
+
+ /* ask the user for what service they want a report for */
+ else if(input_type == GET_INPUT_SERVICE_TARGET) {
+
+ printf("\n");
+
+
+ printf("
\n");
+ printf("
Step 2: Select Service
\n");
+ printf("
\n");
+
+ printf("
\n");
+
+ printf("\n");
+
+ printf("
\n");
+ }
+
+ /* ask the user for report range and options */
+ else if(input_type == GET_INPUT_OPTIONS) {
+
+ time(¤t_time);
+ t = localtime(¤t_time);
+
+ start_day = 1;
+ start_year = t->tm_year + 1900;
+ end_day = t->tm_mday;
+ end_year = t->tm_year + 1900;
+
+ printf("
\n");
+ printf("
Step 3: Select Report Options
\n");
+ printf("
\n");
+
+ printf("
\n");
+
+ printf("\n");
+
+ printf("
\n");
+ }
+
+ /* as the user whether they want a graph for a host or service */
+ else {
+ printf("
No history information was found ");
+ if(display_type == DISPLAY_HOSTS)
+ printf("%s", (show_all_hosts == TRUE) ? "" : "for this host ");
+ else
+ printf("for this service ");
+ printf("in %s log file
", (log_archive == 0) ? "the current" : "this archived");
+ }
+
+ printf("\n");
+
+ my_free(input);
+ my_free(input2);
+
+ if(use_lifo == TRUE)
+ free_lifo_memory();
+ else
+ mmap_fclose(thefile);
+
+ return;
+ }
diff --git a/cgi/notifications.c b/cgi/notifications.c
new file mode 100644
index 0000000..633e1f2
--- /dev/null
+++ b/cgi/notifications.c
@@ -0,0 +1,777 @@
+/************************************************************************
+ *
+ * NOTIFICATIONS.C - Nagios Notifications CGI
+ *
+ * Copyright (c) 1999-2008 Ethan Galstad (egalstad@nagios.org)
+ * Last Modified: 01-08-2008
+ *
+ * This CGI program will display the notification events for
+ * a given host or contact or for all contacts/hosts.
+ *
+ * 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.
+ ***********************************************************************/
+
+#include "../include/config.h"
+#include "../include/common.h"
+
+#include "../include/getcgi.h"
+#include "../include/cgiutils.h"
+#include "../include/cgiauth.h"
+
+extern char main_config_file[MAX_FILENAME_LENGTH];
+extern char url_html_path[MAX_FILENAME_LENGTH];
+extern char url_images_path[MAX_FILENAME_LENGTH];
+extern char url_docs_path[MAX_FILENAME_LENGTH];
+extern char url_stylesheets_path[MAX_FILENAME_LENGTH];
+
+extern int log_rotation_method;
+
+
+#define FIND_HOST 1
+#define FIND_CONTACT 2
+#define FIND_SERVICE 3
+
+#define MAX_QUERYNAME_LENGTH 256
+
+#define SERVICE_NOTIFICATION 0
+#define HOST_NOTIFICATION 1
+
+#define SERVICE_NOTIFICATION_STRING "] SERVICE NOTIFICATION:"
+#define HOST_NOTIFICATION_STRING "] HOST NOTIFICATION:"
+
+void display_notifications(void);
+
+void document_header(int);
+void document_footer(void);
+int process_cgivars(void);
+
+authdata current_authdata;
+
+char log_file_to_use[MAX_FILENAME_LENGTH];
+int log_archive = 0;
+
+int query_type = FIND_HOST;
+int find_all = TRUE;
+char *query_contact_name = "";
+char *query_host_name = "";
+char *query_svc_description = "";
+
+int notification_options = NOTIFICATION_ALL;
+int use_lifo = TRUE;
+
+int embedded = FALSE;
+int display_header = TRUE;
+
+
+int main(void) {
+ int result = OK;
+ char temp_buffer[MAX_INPUT_BUFFER];
+ char temp_buffer2[MAX_INPUT_BUFFER];
+
+
+ /* get the arguments passed in the URL */
+ process_cgivars();
+
+ /* reset internal variables */
+ reset_cgi_vars();
+
+ /* read the CGI configuration file */
+ result = read_cgi_config_file(get_cgi_config_location());
+ if(result == ERROR) {
+ document_header(FALSE);
+ cgi_config_file_error(get_cgi_config_location());
+ document_footer();
+ return ERROR;
+ }
+
+ /* read the main configuration file */
+ result = read_main_config_file(main_config_file);
+ if(result == ERROR) {
+ document_header(FALSE);
+ main_config_file_error(main_config_file);
+ document_footer();
+ return ERROR;
+ }
+
+ /* read all object configuration data */
+ result = read_all_object_configuration_data(main_config_file, READ_ALL_OBJECT_DATA);
+ if(result == ERROR) {
+ document_header(FALSE);
+ object_data_error();
+ document_footer();
+ return ERROR;
+ }
+
+
+ document_header(TRUE);
+
+ /* get authentication information */
+ get_authentication_information(¤t_authdata);
+
+ /* determine what log file we should use */
+ get_log_archive_to_use(log_archive, log_file_to_use, (int)sizeof(log_file_to_use));
+
+
+ if(display_header == TRUE) {
+
+ /* begin top table */
+ printf("
No notifications have been recorded");
+ if(find_all == FALSE) {
+ if(query_type == FIND_SERVICE)
+ printf(" for this service");
+ else if(query_type == FIND_CONTACT)
+ printf(" for this contact");
+ else
+ printf(" for this host");
+ }
+ printf(" in %s log file
", (log_archive == 0) ? "the current" : "this archived");
+ }
+
+ free(input);
+
+ if(use_lifo == TRUE)
+ free_lifo_memory();
+ else
+ mmap_fclose(thefile);
+
+ return;
+ }
diff --git a/cgi/outages.c b/cgi/outages.c
new file mode 100644
index 0000000..ee274ba
--- /dev/null
+++ b/cgi/outages.c
@@ -0,0 +1,697 @@
+/**************************************************************************
+ *
+ * OUTAGES.C - Nagios Network Outages CGI
+ *
+ * Copyright (c) 1999-2008 Ethan Galstad (egalstad@nagios.org)
+ * Last Modified: 01-08-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.
+ *************************************************************************/
+
+#include "../include/config.h"
+#include "../include/common.h"
+#include "../include/objects.h"
+#include "../include/comments.h"
+#include "../include/statusdata.h"
+
+#include "../include/cgiutils.h"
+#include "../include/getcgi.h"
+#include "../include/cgiauth.h"
+
+extern int refresh_rate;
+extern time_t program_start;
+
+extern host *host_list;
+extern service *service_list;
+extern hoststatus *hoststatus_list;
+extern servicestatus *servicestatus_list;
+
+extern char main_config_file[MAX_FILENAME_LENGTH];
+extern char url_html_path[MAX_FILENAME_LENGTH];
+extern char url_stylesheets_path[MAX_FILENAME_LENGTH];
+extern char url_images_path[MAX_FILENAME_LENGTH];
+extern char url_logo_images_path[MAX_FILENAME_LENGTH];
+extern char log_file[MAX_FILENAME_LENGTH];
+
+
+/* HOSTOUTAGE structure */
+typedef struct hostoutage_struct {
+ host *hst;
+ int severity;
+ int affected_child_hosts;
+ int affected_child_services;
+ unsigned long monitored_time;
+ unsigned long time_up;
+ float percent_time_up;
+ unsigned long time_down;
+ float percent_time_down;
+ unsigned long time_unreachable;
+ float percent_time_unreachable;
+ struct hostoutage_struct *next;
+ } hostoutage;
+
+
+/* HOSTOUTAGESORT structure */
+typedef struct hostoutagesort_struct {
+ hostoutage *outage;
+ struct hostoutagesort_struct *next;
+ } hostoutagesort;
+
+
+void document_header(int);
+void document_footer(void);
+int process_cgivars(void);
+
+void display_network_outages(void);
+void find_hosts_causing_outages(void);
+void calculate_outage_effects(void);
+void calculate_outage_effect_of_host(host *, int *, int *);
+int is_route_to_host_blocked(host *);
+int number_of_host_services(host *);
+void add_hostoutage(host *);
+void sort_hostoutages(void);
+void free_hostoutage_list(void);
+void free_hostoutagesort_list(void);
+
+
+authdata current_authdata;
+
+hostoutage *hostoutage_list = NULL;
+hostoutagesort *hostoutagesort_list = NULL;
+
+int service_severity_divisor = 4; /* default = services are 1/4 as important as hosts */
+
+int embedded = FALSE;
+int display_header = TRUE;
+
+
+
+
+int main(void) {
+ int result = OK;
+
+
+ /* get the arguments passed in the URL */
+ process_cgivars();
+
+ /* reset internal variables */
+ reset_cgi_vars();
+
+ /* read the CGI configuration file */
+ result = read_cgi_config_file(get_cgi_config_location());
+ if(result == ERROR) {
+ document_header(FALSE);
+ cgi_config_file_error(get_cgi_config_location());
+ document_footer();
+ return ERROR;
+ }
+
+ /* read the main configuration file */
+ result = read_main_config_file(main_config_file);
+ if(result == ERROR) {
+ document_header(FALSE);
+ main_config_file_error(main_config_file);
+ document_footer();
+ return ERROR;
+ }
+
+ /* read all object configuration data */
+ result = read_all_object_configuration_data(main_config_file, READ_ALL_OBJECT_DATA);
+ if(result == ERROR) {
+ document_header(FALSE);
+ object_data_error();
+ document_footer();
+ return ERROR;
+ }
+
+ /* read all status data */
+ result = read_all_status_data(get_cgi_config_location(), READ_ALL_STATUS_DATA);
+ if(result == ERROR) {
+ document_header(FALSE);
+ status_data_error();
+ document_footer();
+ free_memory();
+ return ERROR;
+ }
+
+ document_header(TRUE);
+
+ /* get authentication information */
+ get_authentication_information(¤t_authdata);
+
+ if(display_header == TRUE) {
+
+ /* begin top table */
+ printf("
\n");
+ printf("
\n");
+
+ /* left column of the first row */
+ printf("
It appears as though you do not have permission to view information you requested...
\n");
+ printf("
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI ");
+ printf("and check the authorization options in your CGI configuration file.
\n");
+
+ return;
+ }
+
+ /* find all hosts that are causing network outages */
+ find_hosts_causing_outages();
+
+ /* calculate outage effects */
+ calculate_outage_effects();
+
+ /* sort the outage list by severity */
+ sort_hostoutages();
+
+ /* count the number of top-level hosts that are down and the ones that are actually blocking children hosts */
+ for(temp_hostoutage = hostoutage_list; temp_hostoutage != NULL; temp_hostoutage = temp_hostoutage->next) {
+ number_of_problem_hosts++;
+ if(temp_hostoutage->affected_child_hosts > 1)
+ number_of_blocking_problem_hosts++;
+ }
+
+ /* display the problem hosts... */
+ printf("
It appears as though you do not have permission to view the log file...
\n");
+ printf("
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI and check the authorization options in your CGI configuration file.
", EXTINFO_CGI, DISPLAY_HOST_INFO, url_encode(temp_status->host_name), url_images_path, ACKNOWLEDGEMENT_ICON, STATUS_ICON_WIDTH, STATUS_ICON_HEIGHT);
+ }
+ /* only show comments if this is a non-read-only user */
+ if(is_authorized_for_read_only(¤t_authdata) == FALSE) {
+ if(total_comments > 0)
+ printf("
\n");
+ total_comments = number_of_service_comments(temp_service->host_name, temp_service->description);
+ /* only show comments if this is a non-read-only user */
+ if(is_authorized_for_read_only(¤t_authdata) == FALSE) {
+ if(total_comments > 0) {
+ printf("
\n");
+
+ /* mod to account for paging */
+ if(visible_entries != 0)
+ last_host = temp_status->host_name;
+ }
+
+ }
+
+ printf("
\n");
+
+ /* if user couldn't see anything, print out some helpful info... */
+ if(user_has_seen_something == FALSE) {
+
+ if(servicestatus_list != NULL) {
+ printf("
It appears as though you do not have permission to view information for any of the services you requested...
\n");
+ printf("
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI ");
+ printf("and check the authorization options in your CGI configuration file.
\n");
+ }
+ else {
+ printf("
There doesn't appear to be any service status information in the status log...
\n");
+ printf("Make sure that Nagios is running and that you have specified the location of you status log correctly in the configuration files.
\n");
+ }
+ }
+ else {
+ /* do page numbers if applicable */
+ create_pagenumbers(total_entries, visible_entries, temp_url, TRUE);
+ }
+
+ return;
+ }
+
+
+
+
+/* display a detailed listing of the status of all hosts... */
+void show_host_detail(void) {
+ time_t t;
+ char date_time[MAX_DATETIME_LENGTH];
+ char state_duration[48];
+ char status[MAX_INPUT_BUFFER];
+ char temp_buffer[MAX_INPUT_BUFFER];
+ char temp_url[MAX_INPUT_BUFFER];
+ char *processed_string = NULL;
+ char *status_class = "";
+ char *status_bg_class = "";
+ hoststatus *temp_status = NULL;
+ hostgroup *temp_hostgroup = NULL;
+ host *temp_host = NULL;
+ hostsort *temp_hostsort = NULL;
+ int odd = 0;
+ int total_comments = 0;
+ int user_has_seen_something = FALSE;
+ int use_sort = FALSE;
+ int result = OK;
+ int first_entry = TRUE;
+ int days;
+ int hours;
+ int minutes;
+ int seconds;
+ int duration_error = FALSE;
+ int total_entries = 0;
+ int visible_entries = 0;
+// int show_host = FALSE;
+
+
+ /* sort the host list if necessary */
+ if(sort_type != SORT_NONE) {
+ result = sort_hosts(sort_type, sort_option);
+ if(result == ERROR)
+ use_sort = FALSE;
+ else
+ use_sort = TRUE;
+ }
+ else
+ use_sort = FALSE;
+
+
+// printf("
\n");
+
+ /* if user couldn't see anything, print out some helpful info... */
+ if(user_has_seen_something == FALSE) {
+
+ if(hoststatus_list != NULL) {
+ printf("
It appears as though you do not have permission to view information for any of the hosts you requested...
\n");
+ printf("
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI ");
+ printf("and check the authorization options in your CGI configuration file.
\n");
+ }
+ else {
+ printf("
There doesn't appear to be any host status information in the status log...
\n");
+ printf("Make sure that Nagios is running and that you have specified the location of you status log correctly in the configuration files.
\n");
+ }
+ }
+
+ else {
+ /* do page numbers if applicable */
+ create_pagenumbers(total_entries, visible_entries, temp_url, FALSE);
+ }
+ return;
+ }
+
+
+
+
+/* show an overview of servicegroup(s)... */
+void show_servicegroup_overviews(void) {
+ servicegroup *temp_servicegroup = NULL;
+ int current_column;
+ int user_has_seen_something = FALSE;
+ int servicegroup_error = FALSE;
+
+
+ //printf("
\n");
+
+ printf("
\n");
+ printf("
\n");
+
+ printf("
\n");
+
+ show_filters();
+
+ printf("
");
+
+ printf("
\n");
+
+ printf("
Service Overview For ");
+ if(show_all_servicegroups == TRUE)
+ printf("All Service Groups");
+ else
+ printf("Service Group '%s'", servicegroup_name);
+ printf("
\n");
+
+ printf(" ");
+
+ printf("
\n");
+
+ printf("
\n");
+
+ printf("
\n");
+ printf("
\n");
+
+ //printf("\n");
+
+
+ /* display status overviews for all servicegroups */
+ if(show_all_servicegroups == TRUE) {
+
+
+ printf("
\n");
+ printf("
\n");
+
+ current_column = 1;
+
+ /* loop through all servicegroups... */
+ for(temp_servicegroup = servicegroup_list; temp_servicegroup != NULL; temp_servicegroup = temp_servicegroup->next) {
+
+ /* make sure the user is authorized to view at least one host in this servicegroup */
+ if(is_authorized_for_servicegroup(temp_servicegroup, ¤t_authdata) == FALSE)
+ continue;
+
+ if(current_column == 1)
+ printf("
It appears as though you do not have permission to view information for any of the hosts you requested...
\n");
+ printf("
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI ");
+ printf("and check the authorization options in your CGI configuration file.
\n");
+ }
+ else {
+ printf("
There are no service groups defined.
\n");
+ }
+
+ printf("
\n");
+ //printf("\n");
+ }
+
+ return;
+ }
+
+
+
+/* shows an overview of a specific servicegroup... */
+void show_servicegroup_overview(servicegroup *temp_servicegroup) {
+ servicesmember *temp_member;
+ host *temp_host;
+ host *last_host;
+ hoststatus *temp_hoststatus = NULL;
+ int odd = 0;
+
+
+ printf("
It appears as though you do not have permission to view information for any of the hosts you requested...
\n");
+ printf("
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI ");
+ printf("and check the authorization options in your CGI configuration file.
\n");
+ }
+ else {
+ printf("
There are no service groups defined.
\n");
+ }
+
+ printf("
\n");
+ }
+
+ /* we couldn't find the servicegroup */
+ else if(servicegroup_error == TRUE) {
+ printf("
\n");
+ printf("
Sorry, but servicegroup '%s' doesn't seem to exist...
\n", servicegroup_name);
+ printf("
\n");
+ }
+
+ return;
+ }
+
+
+
+/* displays status summary information for a specific servicegroup */
+void show_servicegroup_summary(servicegroup *temp_servicegroup, int odd) {
+ char *status_bg_class = "";
+
+ if(odd == 1)
+ status_bg_class = "Even";
+ else
+ status_bg_class = "Odd";
+
+ printf("
It appears as though you do not have permission to view information for any of the hosts you requested...
\n");
+ printf("
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI ");
+ printf("and check the authorization options in your CGI configuration file.
\n");
+ }
+ else {
+ printf("
There are no service groups defined.
\n");
+ }
+
+ printf("
\n");
+ }
+
+ /* we couldn't find the servicegroup */
+ else if(servicegroup_error == TRUE) {
+ printf("
\n");
+ printf("
Sorry, but servicegroup '%s' doesn't seem to exist...
It appears as though you do not have permission to view information for any of the hosts you requested...
\n");
+ printf("
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI ");
+ printf("and check the authorization options in your CGI configuration file.
\n");
+ }
+ else {
+ printf("
There doesn't appear to be any host status information in the status log...
\n");
+ printf("Make sure that Nagios is running and that you have specified the location of you status log correctly in the configuration files.
\n");
+ }
+
+ printf("
\n");
+ printf("\n");
+ }
+
+ return;
+ }
+
+
+
+/* shows an overview of a specific hostgroup... */
+void show_hostgroup_overview(hostgroup *hstgrp) {
+ hostsmember *temp_member = NULL;
+ host *temp_host = NULL;
+ hoststatus *temp_hoststatus = NULL;
+ int odd = 0;
+
+ /* make sure the user is authorized to view this hostgroup */
+ if(is_authorized_for_hostgroup(hstgrp, ¤t_authdata) == FALSE)
+ return;
+
+ printf("
It appears as though you do not have permission to view information for any of the hosts you requested...
\n");
+ printf("
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI ");
+ printf("and check the authorization options in your CGI configuration file.
\n");
+ }
+ else {
+ printf("
There doesn't appear to be any host status information in the status log...
\n");
+ printf("Make sure that Nagios is running and that you have specified the location of you status log correctly in the configuration files.
\n");
+ }
+
+ printf("
\n");
+ }
+
+ /* we couldn't find the hostgroup */
+ else if(hostgroup_error == TRUE) {
+ printf("
\n");
+ printf("
Sorry, but hostgroup '%s' doesn't seem to exist...
\n", hostgroup_name);
+ printf("
\n");
+ }
+
+ return;
+ }
+
+
+
+/* displays status summary information for a specific hostgroup */
+void show_hostgroup_summary(hostgroup *temp_hostgroup, int odd) {
+ char *status_bg_class = "";
+
+ if(odd == 1)
+ status_bg_class = "Even";
+ else
+ status_bg_class = "Odd";
+
+ printf("
It appears as though you do not have permission to view information for any of the hosts you requested...
\n");
+ printf("
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI ");
+ printf("and check the authorization options in your CGI configuration file.
\n");
+ }
+ else {
+ printf("
There doesn't appear to be any host status information in the status log...
\n");
+ printf("Make sure that Nagios is running and that you have specified the location of you status log correctly in the configuration files.
\n");
+ }
+
+ printf("
\n");
+ }
+
+ /* we couldn't find the hostgroup */
+ else if(hostgroup_error == TRUE) {
+ printf("
\n");
+ printf("
Sorry, but hostgroup '%s' doesn't seem to exist...
\n", hostgroup_name);
+ printf("
\n");
+ }
+
+ return;
+ }
+
+
+/* displays status grid for a specific hostgroup */
+void show_hostgroup_grid(hostgroup *temp_hostgroup) {
+ hostsmember *temp_member;
+ char *status_bg_class = "";
+ char *host_status_class = "";
+ char *service_status_class = "";
+ host *temp_host;
+ service *temp_service;
+ hoststatus *temp_hoststatus;
+ servicestatus *temp_servicestatus;
+ char *processed_string = NULL;
+ int odd = 0;
+ int current_item;
+
+
+ printf("
\n");
+ }
+
+ if(mode == CREATE_IMAGE || (mode == CREATE_HTML && use_map == TRUE)) {
+
+ /* draw timestamps */
+ draw_timestamps();
+
+ /* draw horizontal lines */
+ draw_horizontal_grid_lines();
+
+ /* draw state time breakdowns */
+ draw_time_breakdowns();
+ }
+
+ if(mode == CREATE_IMAGE) {
+
+ /* use STDOUT for writing the image data... */
+ image_file = stdout;
+
+#ifndef DEBUG
+ /* write the image to file */
+ gdImagePng(trends_image, image_file);
+#endif
+#ifdef DEBUG
+ image_file = fopen("trends.png", "w");
+ if(image_file == NULL)
+ printf("Could not open trends.png for writing!\n");
+ else {
+ gdImagePng(trends_image, image_file);
+ fclose(image_file);
+ }
+#endif
+
+ /* free memory allocated to image */
+ gdImageDestroy(trends_image);
+ }
+ }
+
+
+ /* show user a selection of hosts and services to choose from... */
+ if(display_type == DISPLAY_NO_TRENDS || input_type != GET_INPUT_NONE) {
+
+ /* ask the user for what host they want a report for */
+ if(input_type == GET_INPUT_HOST_TARGET) {
+
+ printf("
\n");
+ printf("
Step 2: Select Host
\n");
+ printf("
\n");
+
+ printf("
\n");
+
+ printf("\n");
+
+ printf("
\n");
+ }
+
+ /* ask the user for what service they want a report for */
+ else if(input_type == GET_INPUT_SERVICE_TARGET) {
+
+ printf("\n");
+
+
+ printf("
\n");
+ printf("
Step 2: Select Service
\n");
+ printf("
\n");
+
+ printf("
\n");
+
+ printf("\n");
+
+ printf("
\n");
+ }
+
+ /* ask the user for report range and options */
+ else if(input_type == GET_INPUT_OPTIONS) {
+
+ time(¤t_time);
+ t = localtime(¤t_time);
+
+ start_day = 1;
+ start_year = t->tm_year + 1900;
+ end_day = t->tm_mday;
+ end_year = t->tm_year + 1900;
+
+ printf("
\n");
+ printf("
Step 3: Select Report Options
\n");
+ printf("
\n");
+
+ printf("
\n");
+
+ printf("\n");
+
+ printf("
\n");
+
+ /*
+ printf("
\n");
+ printf("Note: Choosing the 'suppress image map' option will make the report run approximately twice as fast as it would otherwise, but it will prevent you from being able to zoom in on specific time periods.\n");
+ printf("
\n");
+ */
+ }
+
+ /* as the user whether they want a graph for a host or service */
+ else {
+ printf("
\n");
+ printf("
Step 1: Select Report Type
\n");
+ printf("
\n");
+
+ printf("
\n");
+
+ printf("\n");
+
+ printf("
\n");
+ }
+
+ }
+
+ document_footer();
+
+ /* free memory allocated to the archived state data list */
+ free_archived_state_list();
+
+ /* free all other allocated memory */
+ free_memory();
+
+ return OK;
+ }
+
+
+
+void document_header(int use_stylesheet) {
+ char date_time[MAX_DATETIME_LENGTH];
+ time_t current_time;
+ time_t expire_time;
+
+ if(mode == CREATE_HTML) {
+ printf("Cache-Control: no-store\r\n");
+ printf("Pragma: no-cache\r\n");
+
+ time(¤t_time);
+ get_time_string(¤t_time, date_time, sizeof(date_time), HTTP_DATE_TIME);
+ printf("Last-Modified: %s\r\n", date_time);
+
+ expire_time = (time_t)0;
+ get_time_string(&expire_time, date_time, sizeof(date_time), HTTP_DATE_TIME);
+ printf("Expires: %s\r\n", date_time);
+
+ printf("Content-type: text/html\r\n\r\n");
+
+ if(embedded == TRUE)
+ return;
+
+ printf("\n");
+ printf("\n");
+ printf("\n", url_images_path);
+ printf("\n");
+ printf("Nagios Trends\n");
+ printf("\n");
+
+ if(use_stylesheet == TRUE) {
+ printf("\n", url_stylesheets_path, COMMON_CSS);
+ printf("\n", url_stylesheets_path, TRENDS_CSS);
+ }
+
+ /* write JavaScript code for popup window */
+ if(display_type != DISPLAY_NO_TRENDS)
+ write_popup_code();
+
+ printf("\n");
+
+ printf("\n");
+
+ /* include user SSI header */
+ include_ssi_files(TRENDS_CGI, SSI_HEADER);
+
+ printf("\n");
+ }
+
+ else {
+ printf("Cache-Control: no-store\r\n");
+ printf("Pragma: no-cache\r\n");
+
+ time(¤t_time);
+ get_time_string(¤t_time, date_time, sizeof(date_time), HTTP_DATE_TIME);
+ printf("Last-Modified: %s\r\n", date_time);
+
+ expire_time = (time_t)0L;
+ get_time_string(&expire_time, date_time, sizeof(date_time), HTTP_DATE_TIME);
+ printf("Expires: %s\r\n", date_time);
+
+ printf("Content-Type: image/png\r\n\r\n");
+ }
+
+ return;
+ }
+
+
+
+void document_footer(void) {
+
+ if(embedded == TRUE)
+ return;
+
+ if(mode == CREATE_HTML) {
+
+ /* include user SSI footer */
+ include_ssi_files(TRENDS_CGI, SSI_FOOTER);
+
+ printf("\n");
+ printf("\n");
+ }
+
+ return;
+ }
+
+
+
+int process_cgivars(void) {
+ char **variables;
+ int error = FALSE;
+ int x;
+
+ variables = getcgivars();
+
+ for(x = 0; variables[x] != NULL; x++) {
+
+ /* do some basic length checking on the variable identifier to prevent buffer overflows */
+ if(strlen(variables[x]) >= MAX_INPUT_BUFFER - 1) {
+ x++;
+ continue;
+ }
+
+ /* we found the host argument */
+ else if(!strcmp(variables[x], "host")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if((host_name = (char *)strdup(variables[x])) == NULL)
+ host_name = "";
+ strip_html_brackets(host_name);
+
+ display_type = DISPLAY_HOST_TRENDS;
+ }
+
+ /* we found the node width argument */
+ else if(!strcmp(variables[x], "service")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if((svc_description = (char *)strdup(variables[x])) == NULL)
+ svc_description = "";
+ strip_html_brackets(svc_description);
+
+ display_type = DISPLAY_SERVICE_TRENDS;
+ }
+
+ /* we found first time argument */
+ else if(!strcmp(variables[x], "t1")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ t1 = (time_t)strtoul(variables[x], NULL, 10);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ }
+
+ /* we found first time argument */
+ else if(!strcmp(variables[x], "t2")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ t2 = (time_t)strtoul(variables[x], NULL, 10);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ }
+
+ /* we found the image creation option */
+ else if(!strcmp(variables[x], "createimage")) {
+ mode = CREATE_IMAGE;
+ }
+
+ /* we found the assume initial states option */
+ else if(!strcmp(variables[x], "assumeinitialstates")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(!strcmp(variables[x], "yes"))
+ assume_initial_states = TRUE;
+ else
+ assume_initial_states = FALSE;
+ }
+
+ /* we found the initial assumed host state option */
+ else if(!strcmp(variables[x], "initialassumedhoststate")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ initial_assumed_host_state = atoi(variables[x]);
+ }
+
+ /* we found the initial assumed service state option */
+ else if(!strcmp(variables[x], "initialassumedservicestate")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ initial_assumed_service_state = atoi(variables[x]);
+ }
+
+ /* we found the assume state during program not running option */
+ else if(!strcmp(variables[x], "assumestatesduringnotrunning")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(!strcmp(variables[x], "yes"))
+ assume_states_during_notrunning = TRUE;
+ else
+ assume_states_during_notrunning = FALSE;
+ }
+
+ /* we found the assume state retention option */
+ else if(!strcmp(variables[x], "assumestateretention")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(!strcmp(variables[x], "yes"))
+ assume_state_retention = TRUE;
+ else
+ assume_state_retention = FALSE;
+ }
+
+ /* we found the include soft states option */
+ else if(!strcmp(variables[x], "includesoftstates")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(!strcmp(variables[x], "yes"))
+ include_soft_states = TRUE;
+ else
+ include_soft_states = FALSE;
+ }
+
+ /* we found the zoom factor argument */
+ else if(!strcmp(variables[x], "zoom")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ zoom_factor = atoi(variables[x]);
+ if(zoom_factor == 0)
+ zoom_factor = 1;
+ }
+
+ /* we found the backtrack archives argument */
+ else if(!strcmp(variables[x], "backtrack")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ backtrack_archives = atoi(variables[x]);
+ if(backtrack_archives < 0)
+ backtrack_archives = 0;
+ if(backtrack_archives > MAX_ARCHIVE_BACKTRACKS)
+ backtrack_archives = MAX_ARCHIVE_BACKTRACKS;
+ }
+
+ /* we found the standard timeperiod argument */
+ else if(!strcmp(variables[x], "timeperiod")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(!strcmp(variables[x], "today"))
+ timeperiod_type = TIMEPERIOD_TODAY;
+ else if(!strcmp(variables[x], "yesterday"))
+ timeperiod_type = TIMEPERIOD_YESTERDAY;
+ else if(!strcmp(variables[x], "thisweek"))
+ timeperiod_type = TIMEPERIOD_THISWEEK;
+ else if(!strcmp(variables[x], "lastweek"))
+ timeperiod_type = TIMEPERIOD_LASTWEEK;
+ else if(!strcmp(variables[x], "thismonth"))
+ timeperiod_type = TIMEPERIOD_THISMONTH;
+ else if(!strcmp(variables[x], "lastmonth"))
+ timeperiod_type = TIMEPERIOD_LASTMONTH;
+ else if(!strcmp(variables[x], "thisquarter"))
+ timeperiod_type = TIMEPERIOD_THISQUARTER;
+ else if(!strcmp(variables[x], "lastquarter"))
+ timeperiod_type = TIMEPERIOD_LASTQUARTER;
+ else if(!strcmp(variables[x], "thisyear"))
+ timeperiod_type = TIMEPERIOD_THISYEAR;
+ else if(!strcmp(variables[x], "lastyear"))
+ timeperiod_type = TIMEPERIOD_LASTYEAR;
+ else if(!strcmp(variables[x], "nextproblem"))
+ timeperiod_type = TIMEPERIOD_NEXTPROBLEM;
+ else if(!strcmp(variables[x], "last24hours"))
+ timeperiod_type = TIMEPERIOD_LAST24HOURS;
+ else if(!strcmp(variables[x], "last7days"))
+ timeperiod_type = TIMEPERIOD_LAST7DAYS;
+ else if(!strcmp(variables[x], "last31days"))
+ timeperiod_type = TIMEPERIOD_LAST31DAYS;
+ else if(!strcmp(variables[x], "custom"))
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ else
+ continue;
+
+ convert_timeperiod_to_times(timeperiod_type);
+ }
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "smon")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ start_month = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "sday")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ start_day = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "syear")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ start_year = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "smin")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ start_minute = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "ssec")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ start_second = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "shour")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ start_hour = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "emon")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ end_month = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "eday")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ end_day = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "eyear")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ end_year = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "emin")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ end_minute = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "esec")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ end_second = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+ /* we found time argument */
+ else if(!strcmp(variables[x], "ehour")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(timeperiod_type != TIMEPERIOD_CUSTOM)
+ continue;
+
+ end_hour = atoi(variables[x]);
+ timeperiod_type = TIMEPERIOD_CUSTOM;
+ compute_time_from_parts = TRUE;
+ }
+
+ /* we found the embed option */
+ else if(!strcmp(variables[x], "embedded"))
+ embedded = TRUE;
+
+ /* we found the noheader option */
+ else if(!strcmp(variables[x], "noheader"))
+ display_header = FALSE;
+
+ /* we found the nopopups option */
+ else if(!strcmp(variables[x], "nopopups"))
+ display_popups = FALSE;
+
+ /* we found the nomap option */
+ else if(!strcmp(variables[x], "nomap")) {
+ display_popups = FALSE;
+ use_map = FALSE;
+ }
+
+ /* we found the input option */
+ else if(!strcmp(variables[x], "input")) {
+ x++;
+ if(variables[x] == NULL) {
+ error = TRUE;
+ break;
+ }
+
+ if(!strcmp(variables[x], "gethost"))
+ input_type = GET_INPUT_HOST_TARGET;
+ else if(!strcmp(variables[x], "getservice"))
+ input_type = GET_INPUT_SERVICE_TARGET;
+ else if(!strcmp(variables[x], "getoptions"))
+ input_type = GET_INPUT_OPTIONS;
+ else
+ input_type = GET_INPUT_TARGET_TYPE;
+ }
+
+ /* we found the small image option */
+ else if(!strcmp(variables[x], "smallimage"))
+ small_image = TRUE;
+
+ }
+
+ /* free memory allocated to the CGI variables */
+ free_cgivars(variables);
+
+ return error;
+ }
+
+
+
+/* top level routine for graphic all trend data */
+void graph_all_trend_data(void) {
+ archived_state *temp_as;
+ archived_state *last_as;
+ time_t a;
+ time_t b;
+ time_t current_time;
+ int current_state = AS_NO_DATA;
+ int have_some_real_data = FALSE;
+ hoststatus *hststatus = NULL;
+ servicestatus *svcstatus = NULL;
+ unsigned long wobble = 300;
+ int first_real_state = AS_NO_DATA;
+ time_t initial_assumed_time;
+ int initial_assumed_state = AS_SVC_OK;
+ int error = FALSE;
+
+
+ time(¤t_time);
+
+ /* if left hand of graph is after current time, we can't do anything at all.... */
+ if(t1 > current_time)
+ return;
+
+ /* find current state for host or service */
+ if(display_type == DISPLAY_HOST_TRENDS)
+ hststatus = find_hoststatus(host_name);
+ else
+ svcstatus = find_servicestatus(host_name, svc_description);
+
+
+ /************************************/
+ /* INSERT CURRENT STATE (IF WE CAN) */
+ /************************************/
+
+ /* if current time DOES NOT fall within graph bounds, so we can't do anything as far as assuming current state */
+ /* the "wobble" value is necessary because when the CGI is called to do the PNG generation, t2 will actually be less that current_time by a bit */
+
+ /* if we don't have any data, assume current state (if possible) */
+ if(as_list == NULL && current_time > t1 && current_time < (t2 + wobble)) {
+
+ /* we don't have any historical information, but the current time falls within the reporting period, so use */
+ /* the current status of the host/service as the starting data */
+ if(display_type == DISPLAY_HOST_TRENDS) {
+ if(hststatus != NULL) {
+
+ if(hststatus->status == HOST_DOWN)
+ last_known_state = AS_HOST_DOWN;
+ else if(hststatus->status == HOST_UNREACHABLE)
+ last_known_state = AS_HOST_UNREACHABLE;
+ else
+ last_known_state = AS_HOST_UP;
+
+ /* add a dummy archived state item, so something can get graphed */
+ add_archived_state(last_known_state, AS_HARD_STATE, t1, "Current Host State Assumed (Faked Log Entry)");
+
+ /* use the current state as the last known real state */
+ first_real_state = last_known_state;
+ }
+ }
+ else {
+ if(svcstatus != NULL) {
+
+ if(svcstatus->status == SERVICE_OK)
+ last_known_state = AS_SVC_OK;
+ else if(svcstatus->status == SERVICE_WARNING)
+ last_known_state = AS_SVC_WARNING;
+ else if(svcstatus->status == SERVICE_CRITICAL)
+ last_known_state = AS_SVC_CRITICAL;
+ else if(svcstatus->status == SERVICE_UNKNOWN)
+ last_known_state = AS_SVC_UNKNOWN;
+
+ /* add a dummy archived state item, so something can get graphed */
+ add_archived_state(last_known_state, AS_HARD_STATE, t1, "Current Service State Assumed (Faked Log Entry)");
+
+ /* use the current state as the last known real state */
+ first_real_state = last_known_state;
+ }
+ }
+ }
+
+
+ /******************************************/
+ /* INSERT FIRST ASSUMED STATE (IF WE CAN) */
+ /******************************************/
+
+ if((display_type == DISPLAY_HOST_TRENDS && initial_assumed_host_state != AS_NO_DATA) || (display_type == DISPLAY_SERVICE_TRENDS && initial_assumed_service_state != AS_NO_DATA)) {
+
+ /* see if its okay to assume initial state for this subject */
+ error = FALSE;
+ if(display_type == DISPLAY_SERVICE_TRENDS) {
+ if(initial_assumed_service_state != AS_SVC_OK && initial_assumed_service_state != AS_SVC_WARNING && initial_assumed_service_state != AS_SVC_UNKNOWN && initial_assumed_service_state != AS_SVC_CRITICAL && initial_assumed_service_state != AS_CURRENT_STATE)
+ error = TRUE;
+ else
+ initial_assumed_state = initial_assumed_service_state;
+ if(initial_assumed_service_state == AS_CURRENT_STATE && svcstatus == NULL)
+ error = TRUE;
+ }
+ else {
+ if(initial_assumed_host_state != AS_HOST_UP && initial_assumed_host_state != AS_HOST_DOWN && initial_assumed_host_state != AS_HOST_UNREACHABLE && initial_assumed_host_state != AS_CURRENT_STATE)
+ error = TRUE;
+ else
+ initial_assumed_state = initial_assumed_host_state;
+ if(initial_assumed_host_state == AS_CURRENT_STATE && hststatus == NULL)
+ error = TRUE;
+ }
+
+ /* get the current state if applicable */
+ if(((display_type == DISPLAY_HOST_TRENDS && initial_assumed_host_state == AS_CURRENT_STATE) || (display_type == DISPLAY_SERVICE_TRENDS && initial_assumed_service_state == AS_CURRENT_STATE)) && error == FALSE) {
+ if(display_type == DISPLAY_HOST_TRENDS) {
+ switch(hststatus->status) {
+ case HOST_DOWN:
+ initial_assumed_state = AS_HOST_DOWN;
+ break;
+ case HOST_UNREACHABLE:
+ initial_assumed_state = AS_HOST_UNREACHABLE;
+ break;
+ case HOST_UP:
+ initial_assumed_state = AS_HOST_UP;
+ break;
+ default:
+ error = TRUE;
+ break;
+ }
+ }
+ else {
+ switch(svcstatus->status) {
+ case SERVICE_OK:
+ initial_assumed_state = AS_SVC_OK;
+ break;
+ case SERVICE_WARNING:
+ initial_assumed_state = AS_SVC_WARNING;
+ break;
+ case SERVICE_UNKNOWN:
+ initial_assumed_state = AS_SVC_UNKNOWN;
+ break;
+ case SERVICE_CRITICAL:
+ initial_assumed_state = AS_SVC_CRITICAL;
+ break;
+ default:
+ error = TRUE;
+ break;
+ }
+ }
+ }
+
+ if(error == FALSE) {
+
+ /* add this assumed state entry before any entries in the list and <= t1 */
+ if(as_list == NULL)
+ initial_assumed_time = t1;
+ else if(as_list->time_stamp > t1)
+ initial_assumed_time = t1;
+ else
+ initial_assumed_time = as_list->time_stamp - 1;
+
+ if(display_type == DISPLAY_HOST_TRENDS)
+ add_archived_state(initial_assumed_state, AS_HARD_STATE, initial_assumed_time, "First Host State Assumed (Faked Log Entry)");
+ else
+ add_archived_state(initial_assumed_state, AS_HARD_STATE, initial_assumed_time, "First Service State Assumed (Faked Log Entry)");
+ }
+ }
+
+
+
+
+ /**************************************/
+ /* BAIL OUT IF WE DON'T HAVE ANYTHING */
+ /**************************************/
+
+ have_some_real_data = FALSE;
+ for(temp_as = as_list; temp_as != NULL; temp_as = temp_as->next) {
+ if(temp_as->entry_type != AS_NO_DATA && temp_as->entry_type != AS_PROGRAM_START && temp_as->entry_type != AS_PROGRAM_END) {
+ have_some_real_data = TRUE;
+ break;
+ }
+ }
+ if(have_some_real_data == FALSE)
+ return;
+
+
+
+
+ /* if we're creating the HTML, start map code... */
+ if(mode == CREATE_HTML)
+ printf("\n");
+
+ return;
+ }
+
+
+
+/* graphs trend data */
+void graph_trend_data(int first_state, int last_state, time_t real_start_time, time_t start_time, time_t end_time, char *state_info) {
+ int start_state;
+ int end_state;
+ int start_pixel = 0;
+ int end_pixel = 0;
+ int color_to_use = 0;
+ int height = 0;
+ double start_pixel_ratio;
+ double end_pixel_ratio;
+ char temp_buffer[MAX_INPUT_BUFFER];
+ char state_string[MAX_INPUT_BUFFER];
+ char end_timestring[MAX_INPUT_BUFFER];
+ char start_timestring[MAX_INPUT_BUFFER];
+ time_t center_time;
+ time_t next_start_time;
+ time_t next_end_time;
+ int days = 0;
+ int hours = 0;
+ int minutes = 0;
+ int seconds = 0;
+
+ /* can't graph if we don't have data... */
+ if(first_state == AS_NO_DATA || last_state == AS_NO_DATA)
+ return;
+ if(first_state == AS_PROGRAM_START && (last_state == AS_PROGRAM_END || last_state == AS_PROGRAM_START)) {
+ if(assume_initial_states == FALSE)
+ return;
+ }
+ if(first_state == AS_PROGRAM_END) {
+ if(assume_states_during_notrunning == TRUE)
+ first_state = last_known_state;
+ else
+ return;
+ }
+
+ /* special case if first entry was program start */
+ if(first_state == AS_PROGRAM_START) {
+#ifdef DEBUG
+ printf("First state=program start!\n");
+#endif
+ if(assume_initial_states == TRUE) {
+#ifdef DEBUG
+ printf("\tWe are assuming initial states...\n");
+#endif
+ if(assume_state_retention == TRUE) {
+ start_state = last_known_state;
+#ifdef DEBUG
+ printf("\tWe are assuming state retention (%d)...\n", start_state);
+#endif
+ }
+ else {
+#ifdef DEBUG
+ printf("\tWe are NOT assuming state retention...\n");
+#endif
+ if(display_type == DISPLAY_HOST_TRENDS)
+ start_state = AS_HOST_UP;
+ else
+ start_state = AS_SVC_OK;
+ }
+ }
+ else {
+#ifdef DEBUG
+ printf("We ARE NOT assuming initial states!\n");
+#endif
+ return;
+ }
+ }
+ else {
+ start_state = first_state;
+ last_known_state = first_state;
+ }
+
+ /* special case if last entry was program stop */
+ if(last_state == AS_PROGRAM_END)
+ end_state = first_state;
+ else
+ end_state = last_state;
+
+#ifdef DEBUG
+ printf("Graphing state %d\n", start_state);
+ printf("\tfrom %s", ctime(&start_time));
+ printf("\tto %s", ctime(&end_time));
+#endif
+
+ if(start_time < t1)
+ start_time = t1;
+ if(end_time > t2)
+ end_time = t2;
+ if(end_time < t1 || start_time > t2)
+ return;
+
+ /* calculate the first and last pixels to use */
+ if(start_time == t1)
+ start_pixel = 0;
+ else {
+ start_pixel_ratio = ((double)(start_time - t1)) / ((double)(t2 - t1));
+ start_pixel = (int)(start_pixel_ratio * (drawing_width - 1));
+ }
+ if(end_time == t1)
+ end_pixel = 0;
+ else {
+ end_pixel_ratio = ((double)(end_time - t1)) / ((double)(t2 - t1));
+ end_pixel = (int)(end_pixel_ratio * (drawing_width - 1));
+ }
+
+#ifdef DEBUG
+ printf("\tPixel %d to %d\n\n", start_pixel, end_pixel);
+#endif
+
+
+ /* we're creating the image, so draw... */
+ if(mode == CREATE_IMAGE) {
+
+ /* figure out the color to use for drawing */
+ switch(start_state) {
+ case AS_HOST_UP:
+ color_to_use = color_green;
+ height = 60;
+ break;
+ case AS_HOST_DOWN:
+ color_to_use = color_red;
+ height = 40;
+ break;
+ case AS_HOST_UNREACHABLE:
+ color_to_use = color_darkred;
+ height = 20;
+ break;
+ case AS_SVC_OK:
+ color_to_use = color_green;
+ height = 80;
+ break;
+ case AS_SVC_WARNING:
+ color_to_use = color_yellow;
+ height = 60;
+ break;
+ case AS_SVC_UNKNOWN:
+ color_to_use = color_orange;
+ height = 40;
+ break;
+ case AS_SVC_CRITICAL:
+ color_to_use = color_red;
+ height = 20;
+ break;
+ default:
+ color_to_use = color_black;
+ height = 0;
+ break;
+ }
+
+ /* draw a rectangle */
+ if(start_state != AS_NO_DATA)
+ gdImageFilledRectangle(trends_image, start_pixel + drawing_x_offset, drawing_height - height + drawing_y_offset, end_pixel + drawing_x_offset, drawing_height + drawing_y_offset, color_to_use);
+ }
+
+ /* else we're creating the HTML, so write map area code... */
+ else {
+
+
+ /* figure out the the state string to use */
+ switch(start_state) {
+ case AS_HOST_UP:
+ strcpy(state_string, "UP");
+ height = 60;
+ break;
+ case AS_HOST_DOWN:
+ strcpy(state_string, "DOWN");
+ height = 40;
+ break;
+ case AS_HOST_UNREACHABLE:
+ strcpy(state_string, "UNREACHABLE");
+ height = 20;
+ break;
+ case AS_SVC_OK:
+ strcpy(state_string, "OK");
+ height = 80;
+ break;
+ case AS_SVC_WARNING:
+ strcpy(state_string, "WARNING");
+ height = 60;
+ break;
+ case AS_SVC_UNKNOWN:
+ strcpy(state_string, "UNKNOWN");
+ height = 40;
+ break;
+ case AS_SVC_CRITICAL:
+ strcpy(state_string, "CRITICAL");
+ height = 20;
+ break;
+ default:
+ strcpy(state_string, "?");
+ height = 5;
+ break;
+ }
+
+ /* get the center of this time range */
+ center_time = start_time + ((end_time - start_time) / 2);
+
+ /* determine next start and end time range with zoom factor */
+ if(zoom_factor > 0) {
+ next_start_time = center_time - (((t2 - t1) / 2) / zoom_factor);
+ next_end_time = center_time + (((t2 - t1) / 2) / zoom_factor);
+ }
+ else {
+ next_start_time = center_time + (((t2 - t1) / 2) * zoom_factor);
+ next_end_time = center_time - (((t2 - t1) / 2) * zoom_factor);
+ }
+
+ printf(" 0)
+ printf("&backtrack=%d", backtrack_archives);
+ printf("&zoom=%d", zoom_factor);
+
+ printf("' ");
+
+ /* display popup text */
+ if(display_popups == TRUE) {
+
+ snprintf(start_timestring, sizeof(start_timestring) - 1, "%s", ctime(&real_start_time));
+ start_timestring[sizeof(start_timestring) - 1] = '\x0';
+ start_timestring[strlen(start_timestring) - 1] = '\x0';
+
+ snprintf(end_timestring, sizeof(end_timestring) - 1, "%s", ctime(&end_time));
+ end_timestring[sizeof(end_timestring) - 1] = '\x0';
+ end_timestring[strlen(end_timestring) - 1] = '\x0';
+
+ /* calculate total time in this state */
+ get_time_breakdown((time_t)(end_time - start_time), &days, &hours, &minutes, &seconds);
+
+ /* sanitize plugin output */
+ sanitize_plugin_output(state_info);
+
+ printf("onMouseOver='showPopup(\"");
+ snprintf(temp_buffer, sizeof(temp_buffer) - 1, "%s Time Range: %s to %s Duration: %dd %dh %dm %ds State Info: %s", state_string, start_timestring, end_timestring, days, hours, minutes, seconds, (state_info == NULL) ? "N/A" : state_info);
+ temp_buffer[sizeof(temp_buffer) - 1] = '\x0';
+ printf("%s", temp_buffer);
+ printf("\",event)' onMouseOut='hidePopup()'");
+ }
+
+ printf(">\n");
+
+ }
+
+
+ /* calculate time in this state */
+ switch(start_state) {
+ case AS_HOST_UP:
+ time_up += (unsigned long)(end_time - start_time);
+ break;
+ case AS_HOST_DOWN:
+ time_down += (unsigned long)(end_time - start_time);
+ break;
+ case AS_HOST_UNREACHABLE:
+ time_unreachable += (unsigned long)(end_time - start_time);
+ break;
+ case AS_SVC_OK:
+ time_ok += (unsigned long)(end_time - start_time);
+ break;
+ case AS_SVC_WARNING:
+ time_warning += (unsigned long)(end_time - start_time);
+ break;
+ case AS_SVC_UNKNOWN:
+ time_unknown += (unsigned long)(end_time - start_time);
+ break;
+ case AS_SVC_CRITICAL:
+ time_critical += (unsigned long)(end_time - start_time);
+ break;
+ default:
+ break;
+ }
+
+ return;
+ }
+
+
+
+/* convert current host state to archived state value */
+int convert_host_state_to_archived_state(int current_status) {
+
+ if(current_status == HOST_UP)
+ return AS_HOST_UP;
+ if(current_status == HOST_DOWN)
+ return AS_HOST_DOWN;
+ if(current_status == HOST_UNREACHABLE)
+ return AS_HOST_UNREACHABLE;
+
+ return AS_NO_DATA;
+ }
+
+
+/* convert current service state to archived state value */
+int convert_service_state_to_archived_state(int current_status) {
+
+ if(current_status == SERVICE_OK)
+ return AS_SVC_OK;
+ if(current_status == SERVICE_UNKNOWN)
+ return AS_SVC_UNKNOWN;
+ if(current_status == SERVICE_WARNING)
+ return AS_SVC_WARNING;
+ if(current_status == SERVICE_CRITICAL)
+ return AS_SVC_CRITICAL;
+
+ return AS_NO_DATA;
+ }
+
+
+
+/* adds an archived state entry */
+void add_archived_state(int entry_type, int state_type, time_t time_stamp, char *state_info) {
+ archived_state *last_as = NULL;
+ archived_state *temp_as = NULL;
+ archived_state *new_as = NULL;
+
+#ifdef DEBUG
+ printf("Added state %d @ %s", state_type, ctime(&time_stamp));
+#endif
+
+ /* allocate memory for the new entry */
+ new_as = (archived_state *)malloc(sizeof(archived_state));
+ if(new_as == NULL)
+ return;
+
+ /* allocate memory fo the state info */
+ if(state_info != NULL) {
+ new_as->state_info = (char *)malloc(strlen(state_info) + 1);
+ if(new_as->state_info != NULL)
+ strcpy(new_as->state_info, state_info);
+ }
+ else new_as->state_info = NULL;
+
+ new_as->entry_type = entry_type;
+ new_as->processed_state = entry_type;
+ new_as->state_type = state_type;
+ new_as->time_stamp = time_stamp;
+
+ /* add the new entry to the list in memory, sorted by time */
+ last_as = as_list;
+ for(temp_as = as_list; temp_as != NULL; temp_as = temp_as->next) {
+ if(new_as->time_stamp < temp_as->time_stamp) {
+ new_as->next = temp_as;
+ if(temp_as == as_list)
+ as_list = new_as;
+ else
+ last_as->next = new_as;
+ break;
+ }
+ else
+ last_as = temp_as;
+ }
+ if(as_list == NULL) {
+ new_as->next = NULL;
+ as_list = new_as;
+ }
+ else if(temp_as == NULL) {
+ new_as->next = NULL;
+ last_as->next = new_as;
+ }
+
+ return;
+ }
+
+
+/* frees memory allocated to the archived state list */
+void free_archived_state_list(void) {
+ archived_state *this_as = NULL;
+ archived_state *next_as = NULL;
+
+ for(this_as = as_list; this_as != NULL;) {
+ next_as = this_as->next;
+ if(this_as->state_info != NULL)
+ free(this_as->state_info);
+ free(this_as);
+ this_as = next_as;
+ }
+
+ as_list = NULL;
+
+ return;
+ }
+
+
+/* reads log files for archived state data */
+void read_archived_state_data(void) {
+ char filename[MAX_FILENAME_LENGTH];
+ int newest_archive = 0;
+ int oldest_archive = 0;
+ int current_archive;
+
+#ifdef DEBUG
+ printf("Determining archives to use...\n");
+#endif
+
+ /* determine earliest archive to use */
+ oldest_archive = determine_archive_to_use_from_time(t1);
+ if(log_rotation_method != LOG_ROTATION_NONE)
+ oldest_archive += backtrack_archives;
+
+ /* determine most recent archive to use */
+ newest_archive = determine_archive_to_use_from_time(t2);
+
+ if(oldest_archive < newest_archive)
+ oldest_archive = newest_archive;
+
+#ifdef DEBUG
+ printf("Oldest archive: %d\n", oldest_archive);
+ printf("Newest archive: %d\n", newest_archive);
+#endif
+
+ /* read in all the necessary archived logs */
+ for(current_archive = newest_archive; current_archive <= oldest_archive; current_archive++) {
+
+ /* get the name of the log file that contains this archive */
+ get_log_archive_to_use(current_archive, filename, sizeof(filename) - 1);
+
+#ifdef DEBUG
+ printf("\tCurrent archive: %d (%s)\n", current_archive, filename);
+#endif
+
+ /* scan the log file for archived state data */
+ scan_log_file_for_archived_state_data(filename);
+ }
+
+ return;
+ }
+
+
+
+/* grabs archives state data from a log file */
+void scan_log_file_for_archived_state_data(char *filename) {
+ char *input = NULL;
+ char *input2 = NULL;
+ char entry_host_name[MAX_INPUT_BUFFER];
+ char entry_svc_description[MAX_INPUT_BUFFER];
+ char *plugin_output = NULL;
+ char *temp_buffer = NULL;
+ time_t time_stamp;
+ mmapfile *thefile = NULL;
+ int state_type = 0;
+
+ /* print something so browser doesn't time out */
+ if(mode == CREATE_HTML) {
+ printf(" ");
+ fflush(NULL);
+ }
+
+ if((thefile = mmap_fopen(filename)) == NULL) {
+#ifdef DEBUG
+ printf("Could not open file '%s' for reading.\n", filename);
+#endif
+ return;
+ }
+
+#ifdef DEBUG
+ printf("Scanning log file '%s' for archived state data...\n", filename);
+#endif
+
+ while(1) {
+
+ /* free memory */
+ free(input);
+ free(input2);
+ input = NULL;
+ input2 = NULL;
+
+ /* read the next line */
+ if((input = mmap_fgets(thefile)) == NULL)
+ break;
+
+ strip(input);
+
+ if((input2 = strdup(input)) == NULL)
+ continue;
+
+ temp_buffer = my_strtok(input2, "]");
+ time_stamp = (temp_buffer == NULL) ? (time_t)0 : (time_t)strtoul(temp_buffer + 1, NULL, 10);
+
+ /* program starts/restarts */
+ if(strstr(input, " starting..."))
+ add_archived_state(AS_PROGRAM_START, AS_NO_DATA, time_stamp, "Program start");
+ if(strstr(input, " restarting..."))
+ add_archived_state(AS_PROGRAM_START, AS_NO_DATA, time_stamp, "Program restart");
+
+ /* program stops */
+ if(strstr(input, " shutting down..."))
+ add_archived_state(AS_PROGRAM_END, AS_NO_DATA, time_stamp, "Normal program termination");
+ if(strstr(input, "Bailing out"))
+ add_archived_state(AS_PROGRAM_END, AS_NO_DATA, time_stamp, "Abnormal program termination");
+
+ if(display_type == DISPLAY_HOST_TRENDS) {
+ if(strstr(input, "HOST ALERT:") || strstr(input, "INITIAL HOST STATE:") || strstr(input, "CURRENT HOST STATE:")) {
+
+ free(input2);
+ if((input2 = strdup(input)) == NULL)
+ continue;
+
+ /* get host name */
+ temp_buffer = my_strtok(input2, "]");
+ temp_buffer = my_strtok(NULL, ":");
+ temp_buffer = my_strtok(NULL, ";");
+ strncpy(entry_host_name, (temp_buffer == NULL) ? "" : temp_buffer + 1, sizeof(entry_host_name));
+ entry_host_name[sizeof(entry_host_name) - 1] = '\x0';
+
+ if(strcmp(host_name, entry_host_name))
+ continue;
+
+ /* state types */
+ if(strstr(input, ";SOFT;")) {
+ if(include_soft_states == FALSE)
+ continue;
+ state_type = AS_SOFT_STATE;
+ }
+ if(strstr(input, ";HARD;"))
+ state_type = AS_HARD_STATE;
+
+ /* get the plugin output */
+ temp_buffer = my_strtok(NULL, ";");
+ temp_buffer = my_strtok(NULL, ";");
+ temp_buffer = my_strtok(NULL, ";");
+ plugin_output = my_strtok(NULL, "\n");
+
+ if(strstr(input, ";DOWN;"))
+ add_archived_state(AS_HOST_DOWN, state_type, time_stamp, plugin_output);
+ else if(strstr(input, ";UNREACHABLE;"))
+ add_archived_state(AS_HOST_UNREACHABLE, state_type, time_stamp, plugin_output);
+ else if(strstr(input, ";RECOVERY") || strstr(input, ";UP;"))
+ add_archived_state(AS_HOST_UP, state_type, time_stamp, plugin_output);
+ else
+ add_archived_state(AS_NO_DATA, AS_NO_DATA, time_stamp, plugin_output);
+ }
+ }
+ if(display_type == DISPLAY_SERVICE_TRENDS) {
+ if(strstr(input, "SERVICE ALERT:") || strstr(input, "INITIAL SERVICE STATE:") || strstr(input, "CURRENT SERVICE STATE:")) {
+
+ free(input2);
+ if((input2 = strdup(input)) == NULL)
+ continue;
+
+ /* get host name */
+ temp_buffer = my_strtok(input2, "]");
+ temp_buffer = my_strtok(NULL, ":");
+ temp_buffer = my_strtok(NULL, ";");
+ strncpy(entry_host_name, (temp_buffer == NULL) ? "" : temp_buffer + 1, sizeof(entry_host_name));
+ entry_host_name[sizeof(entry_host_name) - 1] = '\x0';
+
+ if(strcmp(host_name, entry_host_name))
+ continue;
+
+ /* get service description */
+ temp_buffer = my_strtok(NULL, ";");
+ strncpy(entry_svc_description, (temp_buffer == NULL) ? "" : temp_buffer, sizeof(entry_svc_description));
+ entry_svc_description[sizeof(entry_svc_description) - 1] = '\x0';
+
+ if(strcmp(svc_description, entry_svc_description))
+ continue;
+
+ /* state types */
+ if(strstr(input, ";SOFT;")) {
+ if(include_soft_states == FALSE)
+ continue;
+ state_type = AS_SOFT_STATE;
+ }
+ if(strstr(input, ";HARD;"))
+ state_type = AS_HARD_STATE;
+
+ /* get the plugin output */
+ temp_buffer = my_strtok(NULL, ";");
+ temp_buffer = my_strtok(NULL, ";");
+ temp_buffer = my_strtok(NULL, ";");
+ plugin_output = my_strtok(NULL, "\n");
+
+ if(strstr(input, ";CRITICAL;"))
+ add_archived_state(AS_SVC_CRITICAL, state_type, time_stamp, plugin_output);
+ else if(strstr(input, ";WARNING;"))
+ add_archived_state(AS_SVC_WARNING, state_type, time_stamp, plugin_output);
+ else if(strstr(input, ";UNKNOWN;"))
+ add_archived_state(AS_SVC_UNKNOWN, state_type, time_stamp, plugin_output);
+ else if(strstr(input, ";RECOVERY;") || strstr(input, ";OK;"))
+ add_archived_state(AS_SVC_OK, state_type, time_stamp, plugin_output);
+ else
+ add_archived_state(AS_NO_DATA, AS_NO_DATA, time_stamp, plugin_output);
+
+ }
+ }
+
+ }
+
+ /* free memory and close the file */
+ free(input);
+ free(input2);
+ mmap_fclose(thefile);
+
+ return;
+ }
+
+
+
+/* write JavaScript code and layer for popup window */
+void write_popup_code(void) {
+ char *border_color = "#000000";
+ char *background_color = "#ffffcc";
+ int border = 1;
+ int padding = 3;
+ int x_offset = 3;
+ int y_offset = 3;
+
+ printf("\n");
+
+ return;
+ }
+
+
+
+
+/* write timestamps */
+void draw_timestamps(void) {
+ int last_timestamp = 0;
+ archived_state *temp_as;
+ double start_pixel_ratio;
+ int start_pixel;
+
+ if(mode != CREATE_IMAGE)
+ return;
+
+ /* draw first timestamp */
+ draw_timestamp(0, t1);
+ last_timestamp = 0;
+
+ for(temp_as = as_list; temp_as != NULL; temp_as = temp_as->next) {
+
+ if(temp_as->time_stamp < t1 || temp_as->time_stamp > t2)
+ continue;
+
+ start_pixel_ratio = ((double)(temp_as->time_stamp - t1)) / ((double)(t2 - t1));
+ start_pixel = (int)(start_pixel_ratio * (drawing_width - 1));
+
+ /* draw start timestamp if possible */
+ if((start_pixel > last_timestamp + MIN_TIMESTAMP_SPACING) && (start_pixel < drawing_width - 1 - MIN_TIMESTAMP_SPACING)) {
+ draw_timestamp(start_pixel, temp_as->time_stamp);
+ last_timestamp = start_pixel;
+ }
+ }
+
+ /* draw last timestamp */
+ draw_timestamp(drawing_width - 1, t2);
+
+ return;
+ }
+
+
+/* write timestamp below graph */
+void draw_timestamp(int ts_pixel, time_t ts_time) {
+ char temp_buffer[MAX_INPUT_BUFFER];
+ int string_height;
+ int string_width;
+
+ snprintf(temp_buffer, sizeof(temp_buffer) - 1, "%s", ctime(&ts_time));
+ temp_buffer[sizeof(temp_buffer) - 1] = '\x0';
+ temp_buffer[strlen(temp_buffer) - 1] = '\x0';
+
+ string_height = gdFontSmall->h;
+ string_width = gdFontSmall->w * strlen(temp_buffer);
+
+ if(small_image == FALSE)
+ gdImageStringUp(trends_image, gdFontSmall, ts_pixel + drawing_x_offset - (string_height / 2), drawing_y_offset + drawing_height + string_width + 5, (unsigned char *)temp_buffer, color_black);
+
+ /* draw a dashed vertical line at this point */
+ if(ts_pixel > 0 && ts_pixel < (drawing_width - 1))
+ draw_dashed_line(ts_pixel + drawing_x_offset, drawing_y_offset, ts_pixel + drawing_x_offset, drawing_y_offset + drawing_height, color_black);
+
+ return;
+ }
+
+
+
+/* draw total state times */
+void draw_time_breakdowns(void) {
+ char temp_buffer[MAX_INPUT_BUFFER];
+ unsigned long total_time = 0L;
+ unsigned long total_state_time;
+ unsigned long time_indeterminate = 0L;
+ int string_height;
+
+ if(mode == CREATE_HTML)
+ return;
+
+ if(small_image == TRUE)
+ return;
+
+ total_time = (unsigned long)(t2 - t1);
+
+ if(display_type == DISPLAY_HOST_TRENDS)
+ total_state_time = time_up + time_down + time_unreachable;
+ else
+ total_state_time = time_ok + time_warning + time_unknown + time_critical;
+
+ if(total_state_time >= total_time)
+ time_indeterminate = 0L;
+ else
+ time_indeterminate = total_time - total_state_time;
+
+ string_height = gdFontSmall->h;
+
+ if(display_type == DISPLAY_HOST_TRENDS) {
+
+ get_time_breakdown_string(total_time, time_up, "Up", &temp_buffer[0], sizeof(temp_buffer));
+ gdImageString(trends_image, gdFontSmall, drawing_x_offset + drawing_width + 20, drawing_y_offset + 5, (unsigned char *)temp_buffer, color_darkgreen);
+ gdImageString(trends_image, gdFontSmall, drawing_x_offset - 10 - (gdFontSmall->w * 2), drawing_y_offset + 5, (unsigned char *)"Up", color_darkgreen);
+
+ get_time_breakdown_string(total_time, time_down, "Down", &temp_buffer[0], sizeof(temp_buffer));
+ gdImageString(trends_image, gdFontSmall, drawing_x_offset + drawing_width + 20, drawing_y_offset + 25, (unsigned char *)temp_buffer, color_red);
+ gdImageString(trends_image, gdFontSmall, drawing_x_offset - 10 - (gdFontSmall->w * 4), drawing_y_offset + 25, (unsigned char *)"Down", color_red);
+
+ get_time_breakdown_string(total_time, time_unreachable, "Unreachable", &temp_buffer[0], sizeof(temp_buffer));
+ gdImageString(trends_image, gdFontSmall, drawing_x_offset + drawing_width + 20, drawing_y_offset + 45, (unsigned char *)temp_buffer, color_darkred);
+ gdImageString(trends_image, gdFontSmall, drawing_x_offset - 10 - (gdFontSmall->w * 11), drawing_y_offset + 45, (unsigned char *)"Unreachable", color_darkred);
+
+ get_time_breakdown_string(total_time, time_indeterminate, "Indeterminate", &temp_buffer[0], sizeof(temp_buffer));
+ gdImageString(trends_image, gdFontSmall, drawing_x_offset + drawing_width + 20, drawing_y_offset + 65, (unsigned char *)temp_buffer, color_black);
+ gdImageString(trends_image, gdFontSmall, drawing_x_offset - 10 - (gdFontSmall->w * 13), drawing_y_offset + 65, (unsigned char *)"Indeterminate", color_black);
+ }
+ else {
+ get_time_breakdown_string(total_time, time_ok, "Ok", &temp_buffer[0], sizeof(temp_buffer));
+ gdImageString(trends_image, gdFontSmall, drawing_x_offset + drawing_width + 20, drawing_y_offset + 5, (unsigned char *)temp_buffer, color_darkgreen);
+ gdImageString(trends_image, gdFontSmall, drawing_x_offset - 10 - (gdFontSmall->w * 2), drawing_y_offset + 5, (unsigned char *)"Ok", color_darkgreen);
+
+ get_time_breakdown_string(total_time, time_warning, "Warning", &temp_buffer[0], sizeof(temp_buffer));
+ gdImageString(trends_image, gdFontSmall, drawing_x_offset + drawing_width + 20, drawing_y_offset + 25, (unsigned char *)temp_buffer, color_yellow);
+ gdImageString(trends_image, gdFontSmall, drawing_x_offset - 10 - (gdFontSmall->w * 7), drawing_y_offset + 25, (unsigned char *)"Warning", color_yellow);
+
+ get_time_breakdown_string(total_time, time_unknown, "Unknown", &temp_buffer[0], sizeof(temp_buffer));
+ gdImageString(trends_image, gdFontSmall, drawing_x_offset + drawing_width + 20, drawing_y_offset + 45, (unsigned char *)temp_buffer, color_orange);
+ gdImageString(trends_image, gdFontSmall, drawing_x_offset - 10 - (gdFontSmall->w * 7), drawing_y_offset + 45, (unsigned char *)"Unknown", color_orange);
+
+ get_time_breakdown_string(total_time, time_critical, "Critical", &temp_buffer[0], sizeof(temp_buffer));
+ gdImageString(trends_image, gdFontSmall, drawing_x_offset + drawing_width + 20, drawing_y_offset + 65, (unsigned char *)temp_buffer, color_red);
+ gdImageString(trends_image, gdFontSmall, drawing_x_offset - 10 - (gdFontSmall->w * 8), drawing_y_offset + 65, (unsigned char *)"Critical", color_red);
+
+ get_time_breakdown_string(total_time, time_indeterminate, "Indeterminate", &temp_buffer[0], sizeof(temp_buffer));
+ gdImageString(trends_image, gdFontSmall, drawing_x_offset + drawing_width + 20, drawing_y_offset + 85, (unsigned char *)temp_buffer, color_black);
+ gdImageString(trends_image, gdFontSmall, drawing_x_offset - 10 - (gdFontSmall->w * 13), drawing_y_offset + 85, (unsigned char *)"Indeterminate", color_black);
+ }
+
+ return;
+ }
+
+
+void get_time_breakdown_string(unsigned long total_time, unsigned long state_time, char *state_string, char *buffer, int buffer_length) {
+ int days;
+ int hours;
+ int minutes;
+ int seconds;
+ double percent_time;
+
+ get_time_breakdown(state_time, &days, &hours, &minutes, &seconds);
+ if(total_time == 0L)
+ percent_time = 0.0;
+ else
+ percent_time = ((double)state_time / total_time) * 100.0;
+ snprintf(buffer, buffer_length - 1, "%-13s: (%.3f%%) %dd %dh %dm %ds", state_string, percent_time, days, hours, minutes, seconds);
+ buffer[buffer_length - 1] = '\x0';
+
+ return;
+ }
+
+
+void convert_timeperiod_to_times(int type) {
+ time_t current_time;
+ struct tm *t;
+
+ /* get the current time */
+ time(¤t_time);
+
+ t = localtime(¤t_time);
+
+ t->tm_sec = 0;
+ t->tm_min = 0;
+ t->tm_hour = 0;
+ t->tm_isdst = -1;
+
+ switch(type) {
+ case TIMEPERIOD_LAST24HOURS:
+ t1 = current_time - (60 * 60 * 24);
+ t2 = current_time;
+ break;
+ case TIMEPERIOD_TODAY:
+ t1 = mktime(t);
+ t2 = current_time;
+ break;
+ case TIMEPERIOD_YESTERDAY:
+ t1 = (time_t)(mktime(t) - (60 * 60 * 24));
+ t2 = (time_t)mktime(t);
+ break;
+ case TIMEPERIOD_THISWEEK:
+ t1 = (time_t)(mktime(t) - (60 * 60 * 24 * t->tm_wday));
+ t2 = current_time;
+ break;
+ case TIMEPERIOD_LASTWEEK:
+ t1 = (time_t)(mktime(t) - (60 * 60 * 24 * t->tm_wday) - (60 * 60 * 24 * 7));
+ t2 = (time_t)(mktime(t) - (60 * 60 * 24 * t->tm_wday));
+ break;
+ case TIMEPERIOD_THISMONTH:
+ t->tm_mday = 1;
+ t1 = mktime(t);
+ t2 = current_time;
+ break;
+ case TIMEPERIOD_LASTMONTH:
+ t->tm_mday = 1;
+ t2 = mktime(t);
+ if(t->tm_mon == 0) {
+ t->tm_mon = 11;
+ t->tm_year--;
+ }
+ else
+ t->tm_mon--;
+ t1 = mktime(t);
+ break;
+ case TIMEPERIOD_THISQUARTER:
+ break;
+ case TIMEPERIOD_LASTQUARTER:
+ break;
+ case TIMEPERIOD_THISYEAR:
+ t->tm_mon = 0;
+ t->tm_mday = 1;
+ t1 = mktime(t);
+ t2 = current_time;
+ break;
+ case TIMEPERIOD_LASTYEAR:
+ t->tm_mon = 0;
+ t->tm_mday = 1;
+ t2 = mktime(t);
+ t->tm_year--;
+ t1 = mktime(t);
+ break;
+ case TIMEPERIOD_NEXTPROBLEM:
+ /* Time period will be defined later */
+ break;
+ case TIMEPERIOD_LAST7DAYS:
+ t2 = current_time;
+ t1 = current_time - (7 * 24 * 60 * 60);
+ break;
+ case TIMEPERIOD_LAST31DAYS:
+ t2 = current_time;
+ t1 = current_time - (31 * 24 * 60 * 60);
+ break;
+ default:
+ break;
+ }
+
+ return;
+ }
+
+
+void compute_report_times(void) {
+ time_t current_time;
+ struct tm *st;
+ struct tm *et;
+
+ /* get the current time */
+ time(¤t_time);
+
+ st = localtime(¤t_time);
+
+ st->tm_sec = start_second;
+ st->tm_min = start_minute;
+ st->tm_hour = start_hour;
+ st->tm_mday = start_day;
+ st->tm_mon = start_month - 1;
+ st->tm_year = start_year - 1900;
+ st->tm_isdst = -1;
+
+ t1 = mktime(st);
+
+ et = localtime(¤t_time);
+
+ et->tm_sec = end_second;
+ et->tm_min = end_minute;
+ et->tm_hour = end_hour;
+ et->tm_mday = end_day;
+ et->tm_mon = end_month - 1;
+ et->tm_year = end_year - 1900;
+ et->tm_isdst = -1;
+
+ t2 = mktime(et);
+ }
+
+
+
+/* draws a dashed line */
+void draw_dashed_line(int x1, int y1, int x2, int y2, int color) {
+ int styleDashed[12];
+
+ styleDashed[0] = color;
+ styleDashed[1] = color;
+ styleDashed[2] = gdTransparent;
+ styleDashed[3] = gdTransparent;
+ styleDashed[4] = color;
+ styleDashed[5] = color;
+ styleDashed[6] = gdTransparent;
+ styleDashed[7] = gdTransparent;
+ styleDashed[8] = color;
+ styleDashed[9] = color;
+ styleDashed[10] = gdTransparent;
+ styleDashed[11] = gdTransparent;
+
+ /* sets current style to a dashed line */
+ gdImageSetStyle(trends_image, styleDashed, 12);
+
+ /* draws a line (dashed) */
+ gdImageLine(trends_image, x1, y1, x2, y2, gdStyled);
+
+ return;
+ }
+
+
+/* draws horizontal grid lines */
+void draw_horizontal_grid_lines(void) {
+
+ if(mode == CREATE_HTML)
+ return;
+
+ if(small_image == TRUE)
+ return;
+
+ draw_dashed_line(drawing_x_offset, drawing_y_offset + 10, drawing_x_offset + drawing_width, drawing_y_offset + 10, color_black);
+ draw_dashed_line(drawing_x_offset, drawing_y_offset + 30, drawing_x_offset + drawing_width, drawing_y_offset + 30, color_black);
+ draw_dashed_line(drawing_x_offset, drawing_y_offset + 50, drawing_x_offset + drawing_width, drawing_y_offset + 50, color_black);
+ if(display_type == DISPLAY_SERVICE_TRENDS)
+ draw_dashed_line(drawing_x_offset, drawing_y_offset + 70, drawing_x_offset + drawing_width, drawing_y_offset + 70, color_black);
+
+ return;
+ }
diff --git a/common/.gitignore b/common/.gitignore
new file mode 100644
index 0000000..f3c7a7c
--- /dev/null
+++ b/common/.gitignore
@@ -0,0 +1 @@
+Makefile
diff --git a/common/Makefile.in b/common/Makefile.in
new file mode 100644
index 0000000..b0d74f6
--- /dev/null
+++ b/common/Makefile.in
@@ -0,0 +1,39 @@
+############################
+# Makefile for Nagios
+#
+# Last Modified: 04-08-2003
+############################
+
+# Source code directories
+SRC_BASE=../common
+SRC_CGI=../cgi
+
+CC=@CC@
+CFLAGS=@CFLAGS@ @DEFS@
+LDFLAGS=@LDFLAGS@ @LIBS@
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+LOGDIR=@localstatedir@
+CFGDIR=@sysconfdir@
+BINDIR=@bindir@
+CGIDIR=@sbindir@
+HTMLDIR=@datarootdir@
+INSTALL=@INSTALL@
+INSTALL_OPTS=@INSTALL_OPTS@
+COMMAND_OPTS=@COMMAND_OPTS@
+
+CP=@CP@
+
+
+clean:
+ rm -f core *.o
+ rm -f *~
+
+distclean: clean
+ rm -f Makefile
+
+devclean: distclean
+
+install:
+
diff --git a/common/comments.c b/common/comments.c
new file mode 100644
index 0000000..72070bb
--- /dev/null
+++ b/common/comments.c
@@ -0,0 +1,742 @@
+/*****************************************************************************
+ *
+ * COMMENTS.C - Comment functions for Nagios
+ *
+ * Copyright (c) 1999-2010 Ethan Galstad (egalstad@nagios.org)
+ * Last Modified: 08-28-2010
+ *
+ * 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.
+ *
+ *****************************************************************************/
+
+#include "../include/config.h"
+#include "../include/common.h"
+#include "../include/comments.h"
+#include "../include/objects.h"
+
+/***** IMPLEMENTATION-SPECIFIC INCLUDES *****/
+
+#ifdef USE_XCDDEFAULT
+#include "../xdata/xcddefault.h"
+#endif
+
+#ifdef NSCORE
+#include "../include/nagios.h"
+#include "../include/broker.h"
+#endif
+
+#ifdef NSCGI
+#include "../include/cgiutils.h"
+#endif
+
+
+comment *comment_list = NULL;
+int defer_comment_sorting = 0;
+comment **comment_hashlist = NULL;
+
+
+
+
+#ifdef NSCORE
+pthread_mutex_t nagios_comment_lock = PTHREAD_MUTEX_INITIALIZER;
+
+/******************************************************************/
+/**************** INITIALIZATION/CLEANUP FUNCTIONS ****************/
+/******************************************************************/
+
+
+/* initializes comment data */
+int initialize_comment_data(char *config_file) {
+ int result = OK;
+
+ /**** IMPLEMENTATION-SPECIFIC CALLS ****/
+#ifdef USE_XCDDEFAULT
+ result = xcddefault_initialize_comment_data(config_file);
+#endif
+
+ return result;
+ }
+
+
+/* removes old/invalid comments */
+int cleanup_comment_data(char *config_file) {
+ int result = OK;
+
+ /**** IMPLEMENTATION-SPECIFIC CALLS ****/
+#ifdef USE_XCDDEFAULT
+ result = xcddefault_cleanup_comment_data(config_file);
+#endif
+
+ return result;
+ }
+
+
+
+/******************************************************************/
+/****************** COMMENT OUTPUT FUNCTIONS **********************/
+/******************************************************************/
+
+
+/* adds a new host or service comment */
+int add_new_comment(int type, int entry_type, char *host_name, char *svc_description, time_t entry_time, char *author_name, char *comment_data, int persistent, int source, int expires, time_t expire_time, unsigned long *comment_id) {
+ int result = OK;
+ unsigned long new_comment_id = 0L;
+
+ if(type == HOST_COMMENT)
+ result = add_new_host_comment(entry_type, host_name, entry_time, author_name, comment_data, persistent, source, expires, expire_time, &new_comment_id);
+ else
+ result = add_new_service_comment(entry_type, host_name, svc_description, entry_time, author_name, comment_data, persistent, source, expires, expire_time, &new_comment_id);
+
+ /* add an event to expire comment data if necessary... */
+ if(expires == TRUE)
+ schedule_new_event(EVENT_EXPIRE_COMMENT, FALSE, expire_time, FALSE, 0, NULL, TRUE, (void *)new_comment_id, NULL, 0);
+
+ /* save comment id */
+ if(comment_id != NULL)
+ *comment_id = new_comment_id;
+
+ return result;
+ }
+
+
+/* adds a new host comment */
+int add_new_host_comment(int entry_type, char *host_name, time_t entry_time, char *author_name, char *comment_data, int persistent, int source, int expires, time_t expire_time, unsigned long *comment_id) {
+ int result = OK;
+ unsigned long new_comment_id = 0L;
+
+ /**** IMPLEMENTATION-SPECIFIC CALLS ****/
+#ifdef USE_XCDDEFAULT
+ result = xcddefault_add_new_host_comment(entry_type, host_name, entry_time, author_name, comment_data, persistent, source, expires, expire_time, &new_comment_id);
+#endif
+
+ /* save comment id */
+ if(comment_id != NULL)
+ *comment_id = new_comment_id;
+
+#ifdef USE_EVENT_BROKER
+ /* send data to event broker */
+ broker_comment_data(NEBTYPE_COMMENT_ADD, NEBFLAG_NONE, NEBATTR_NONE, HOST_COMMENT, entry_type, host_name, NULL, entry_time, author_name, comment_data, persistent, source, expires, expire_time, new_comment_id, NULL);
+#endif
+
+ return result;
+ }
+
+
+/* adds a new service comment */
+int add_new_service_comment(int entry_type, char *host_name, char *svc_description, time_t entry_time, char *author_name, char *comment_data, int persistent, int source, int expires, time_t expire_time, unsigned long *comment_id) {
+ int result = OK;
+ unsigned long new_comment_id = 0L;
+
+ /**** IMPLEMENTATION-SPECIFIC CALLS ****/
+#ifdef USE_XCDDEFAULT
+ result = xcddefault_add_new_service_comment(entry_type, host_name, svc_description, entry_time, author_name, comment_data, persistent, source, expires, expire_time, &new_comment_id);
+#endif
+
+ /* save comment id */
+ if(comment_id != NULL)
+ *comment_id = new_comment_id;
+
+#ifdef USE_EVENT_BROKER
+ /* send data to event broker */
+ broker_comment_data(NEBTYPE_COMMENT_ADD, NEBFLAG_NONE, NEBATTR_NONE, SERVICE_COMMENT, entry_type, host_name, svc_description, entry_time, author_name, comment_data, persistent, source, expires, expire_time, new_comment_id, NULL);
+#endif
+
+ return result;
+ }
+
+
+
+/******************************************************************/
+/***************** COMMENT DELETION FUNCTIONS *********************/
+/******************************************************************/
+
+
+/* deletes a host or service comment */
+int delete_comment(int type, unsigned long comment_id) {
+ int result = OK;
+ comment *this_comment = NULL;
+ comment *last_comment = NULL;
+ comment *next_comment = NULL;
+ int hashslot = 0;
+ comment *this_hash = NULL;
+ comment *last_hash = NULL;
+
+ /* lock the comments so we can modify them safely */
+#ifdef NSCORE
+ pthread_mutex_lock(&nagios_comment_lock);
+#endif
+
+ /* find the comment we should remove */
+ for(this_comment = comment_list, last_comment = comment_list; this_comment != NULL; this_comment = next_comment) {
+ next_comment = this_comment->next;
+
+ /* we found the comment we should delete */
+ if(this_comment->comment_id == comment_id && this_comment->comment_type == type)
+ break;
+
+ last_comment = this_comment;
+ }
+
+ /* remove the comment from the list in memory */
+ if(this_comment != NULL) {
+
+#ifdef USE_EVENT_BROKER
+ /* send data to event broker */
+ broker_comment_data(NEBTYPE_COMMENT_DELETE, NEBFLAG_NONE, NEBATTR_NONE, type, this_comment->entry_type, this_comment->host_name, this_comment->service_description, this_comment->entry_time, this_comment->author, this_comment->comment_data, this_comment->persistent, this_comment->source, this_comment->expires, this_comment->expire_time, comment_id, NULL);
+#endif
+
+ /* first remove from chained hash list */
+ hashslot = hashfunc(this_comment->host_name, NULL, COMMENT_HASHSLOTS);
+ last_hash = NULL;
+ for(this_hash = comment_hashlist[hashslot]; this_hash; this_hash = this_hash->nexthash) {
+ if(this_hash == this_comment) {
+ if(last_hash)
+ last_hash->nexthash = this_hash->nexthash;
+ else {
+ if(this_hash->nexthash)
+ comment_hashlist[hashslot] = this_hash->nexthash;
+ else
+ comment_hashlist[hashslot] = NULL;
+ }
+ break;
+ }
+ last_hash = this_hash;
+ }
+
+ /* then removed from linked list */
+ if(comment_list == this_comment)
+ comment_list = this_comment->next;
+ else
+ last_comment->next = next_comment;
+
+ /* free memory */
+ my_free(this_comment->host_name);
+ my_free(this_comment->service_description);
+ my_free(this_comment->author);
+ my_free(this_comment->comment_data);
+ my_free(this_comment);
+
+ result = OK;
+ }
+ else
+ result = ERROR;
+
+ /**** IMPLEMENTATION-SPECIFIC CALLS ****/
+#ifdef USE_XCDDEFAULT
+ if(type == HOST_COMMENT)
+ result = xcddefault_delete_host_comment(comment_id);
+ else
+ result = xcddefault_delete_service_comment(comment_id);
+#endif
+
+#ifdef NSCORE
+ pthread_mutex_unlock(&nagios_comment_lock);
+#endif
+
+ return result;
+ }
+
+
+/* deletes a host comment */
+int delete_host_comment(unsigned long comment_id) {
+ int result = OK;
+
+ /* delete the comment from memory */
+ result = delete_comment(HOST_COMMENT, comment_id);
+
+ return result;
+ }
+
+
+
+/* deletes a service comment */
+int delete_service_comment(unsigned long comment_id) {
+ int result = OK;
+
+ /* delete the comment from memory */
+ result = delete_comment(SERVICE_COMMENT, comment_id);
+
+ return result;
+ }
+
+
+/* deletes all comments for a particular host or service */
+int delete_all_comments(int type, char *host_name, char *svc_description) {
+ int result = OK;
+
+ if(type == HOST_COMMENT)
+ result = delete_all_host_comments(host_name);
+ else
+ result = delete_all_service_comments(host_name, svc_description);
+
+ return result;
+ }
+
+
+/* deletes all comments for a particular host */
+int delete_all_host_comments(char *host_name) {
+ int result = OK;
+ comment *temp_comment = NULL;
+ comment *next_comment = NULL;
+
+ if(host_name == NULL)
+ return ERROR;
+
+ /* delete host comments from memory */
+ for(temp_comment = get_first_comment_by_host(host_name); temp_comment != NULL; temp_comment = next_comment) {
+ next_comment = get_next_comment_by_host(host_name, temp_comment);
+ if(temp_comment->comment_type == HOST_COMMENT)
+ delete_comment(HOST_COMMENT, temp_comment->comment_id);
+ }
+
+ return result;
+ }
+
+
+/* deletes all non-persistent acknowledgement comments for a particular host */
+int delete_host_acknowledgement_comments(host *hst) {
+ int result = OK;
+ comment *temp_comment = NULL;
+ comment *next_comment = NULL;
+
+ if(hst == NULL)
+ return ERROR;
+
+ /* delete comments from memory */
+ temp_comment = get_first_comment_by_host(hst->name);
+ while(temp_comment) {
+ next_comment = get_next_comment_by_host(hst->name, temp_comment);
+ if(temp_comment->comment_type == HOST_COMMENT && temp_comment->entry_type == ACKNOWLEDGEMENT_COMMENT && temp_comment->persistent == FALSE) {
+ delete_comment(HOST_COMMENT, temp_comment->comment_id);
+ }
+ temp_comment = next_comment;
+ }
+
+ return result;
+ }
+
+
+/* deletes all comments for a particular service */
+int delete_all_service_comments(char *host_name, char *svc_description) {
+ int result = OK;
+ comment *temp_comment = NULL;
+ comment *next_comment = NULL;
+
+ if(host_name == NULL || svc_description == NULL)
+ return ERROR;
+
+ /* delete service comments from memory */
+ for(temp_comment = comment_list; temp_comment != NULL; temp_comment = next_comment) {
+ next_comment = temp_comment->next;
+ if(temp_comment->comment_type == SERVICE_COMMENT && !strcmp(temp_comment->host_name, host_name) && !strcmp(temp_comment->service_description, svc_description))
+ delete_comment(SERVICE_COMMENT, temp_comment->comment_id);
+ }
+
+ return result;
+ }
+
+
+/* deletes all non-persistent acknowledgement comments for a particular service */
+int delete_service_acknowledgement_comments(service *svc) {
+ int result = OK;
+ comment *temp_comment = NULL;
+ comment *next_comment = NULL;
+
+ if(svc == NULL)
+ return ERROR;
+
+ /* delete comments from memory */
+ for(temp_comment = comment_list; temp_comment != NULL; temp_comment = next_comment) {
+ next_comment = temp_comment->next;
+ if(temp_comment->comment_type == SERVICE_COMMENT && !strcmp(temp_comment->host_name, svc->host_name) && !strcmp(temp_comment->service_description, svc->description) && temp_comment->entry_type == ACKNOWLEDGEMENT_COMMENT && temp_comment->persistent == FALSE)
+ delete_comment(SERVICE_COMMENT, temp_comment->comment_id);
+ }
+
+ return result;
+ }
+
+
+/* checks for an expired comment (and removes it) */
+int check_for_expired_comment(unsigned long comment_id) {
+ comment *temp_comment = NULL;
+
+ /* check all comments */
+ for(temp_comment = comment_list; temp_comment != NULL; temp_comment = temp_comment->next) {
+
+ /* delete the now expired comment */
+ if(temp_comment->comment_id == comment_id && temp_comment->expires == TRUE && temp_comment->expire_time < time(NULL)) {
+ delete_comment(temp_comment->comment_type, comment_id);
+ break;
+ }
+ }
+
+ return OK;
+ }
+
+
+#endif
+
+
+
+
+
+/******************************************************************/
+/****************** CHAINED HASH FUNCTIONS ************************/
+/******************************************************************/
+
+/* adds comment to hash list in memory */
+int add_comment_to_hashlist(comment *new_comment) {
+ comment *temp_comment = NULL;
+ comment *lastpointer = NULL;
+ int hashslot = 0;
+
+ /* initialize hash list */
+ if(comment_hashlist == NULL) {
+ int i;
+
+ comment_hashlist = (comment **)malloc(sizeof(comment *) * COMMENT_HASHSLOTS);
+ if(comment_hashlist == NULL)
+ return 0;
+
+ for(i = 0; i < COMMENT_HASHSLOTS; i++)
+ comment_hashlist[i] = NULL;
+ }
+
+ if(!new_comment)
+ return 0;
+
+ hashslot = hashfunc(new_comment->host_name, NULL, COMMENT_HASHSLOTS);
+ lastpointer = NULL;
+ for(temp_comment = comment_hashlist[hashslot]; temp_comment && compare_hashdata(temp_comment->host_name, NULL, new_comment->host_name, NULL) < 0; temp_comment = temp_comment->nexthash) {
+ if(compare_hashdata(temp_comment->host_name, NULL, new_comment->host_name, NULL) >= 0)
+ break;
+ lastpointer = temp_comment;
+ }
+
+ /* multiples are allowed */
+ if(lastpointer)
+ lastpointer->nexthash = new_comment;
+ else
+ comment_hashlist[hashslot] = new_comment;
+ new_comment->nexthash = temp_comment;
+
+ return 1;
+ }
+
+
+
+/******************************************************************/
+/******************** ADDITION FUNCTIONS **************************/
+/******************************************************************/
+
+
+/* adds a host comment to the list in memory */
+int add_host_comment(int entry_type, char *host_name, time_t entry_time, char *author, char *comment_data, unsigned long comment_id, int persistent, int expires, time_t expire_time, int source) {
+ int result = OK;
+
+ result = add_comment(HOST_COMMENT, entry_type, host_name, NULL, entry_time, author, comment_data, comment_id, persistent, expires, expire_time, source);
+
+ return result;
+ }
+
+
+
+/* adds a service comment to the list in memory */
+int add_service_comment(int entry_type, char *host_name, char *svc_description, time_t entry_time, char *author, char *comment_data, unsigned long comment_id, int persistent, int expires, time_t expire_time, int source) {
+ int result = OK;
+
+ result = add_comment(SERVICE_COMMENT, entry_type, host_name, svc_description, entry_time, author, comment_data, comment_id, persistent, expires, expire_time, source);
+
+ return result;
+ }
+
+
+
+/* adds a comment to the list in memory */
+int add_comment(int comment_type, int entry_type, char *host_name, char *svc_description, time_t entry_time, char *author, char *comment_data, unsigned long comment_id, int persistent, int expires, time_t expire_time, int source) {
+ comment *new_comment = NULL;
+ comment *last_comment = NULL;
+ comment *temp_comment = NULL;
+ int result = OK;
+
+ /* make sure we have the data we need */
+ if(host_name == NULL || author == NULL || comment_data == NULL || (comment_type == SERVICE_COMMENT && svc_description == NULL))
+ return ERROR;
+
+ /* allocate memory for the comment */
+ if((new_comment = (comment *)calloc(1, sizeof(comment))) == NULL)
+ return ERROR;
+
+ /* duplicate vars */
+ if((new_comment->host_name = (char *)strdup(host_name)) == NULL)
+ result = ERROR;
+ if(comment_type == SERVICE_COMMENT) {
+ if((new_comment->service_description = (char *)strdup(svc_description)) == NULL)
+ result = ERROR;
+ }
+ if((new_comment->author = (char *)strdup(author)) == NULL)
+ result = ERROR;
+ if((new_comment->comment_data = (char *)strdup(comment_data)) == NULL)
+ result = ERROR;
+
+ new_comment->comment_type = comment_type;
+ new_comment->entry_type = entry_type;
+ new_comment->source = source;
+ new_comment->entry_time = entry_time;
+ new_comment->comment_id = comment_id;
+ new_comment->persistent = (persistent == TRUE) ? TRUE : FALSE;
+ new_comment->expires = (expires == TRUE) ? TRUE : FALSE;
+ new_comment->expire_time = expire_time;
+
+ /* add comment to hash list */
+ if(result == OK) {
+ if(!add_comment_to_hashlist(new_comment))
+ result = ERROR;
+ }
+
+ /* handle errors */
+ if(result == ERROR) {
+ my_free(new_comment->comment_data);
+ my_free(new_comment->author);
+ my_free(new_comment->service_description);
+ my_free(new_comment->host_name);
+ my_free(new_comment);
+ return ERROR;
+ }
+
+ if(defer_comment_sorting) {
+ new_comment->next = comment_list;
+ comment_list = new_comment;
+ }
+ else {
+ /* add new comment to comment list, sorted by comment id,
+ * but lock the list first so broker threads doesn't crash
+ * out in case they're modifying this list too
+ */
+#ifdef NSCORE
+ pthread_mutex_lock(&nagios_comment_lock);
+#endif
+ last_comment = comment_list;
+ for(temp_comment = comment_list; temp_comment != NULL; temp_comment = temp_comment->next) {
+ if(new_comment->comment_id < temp_comment->comment_id) {
+ new_comment->next = temp_comment;
+ if(temp_comment == comment_list)
+ comment_list = new_comment;
+ else
+ last_comment->next = new_comment;
+ break;
+ }
+ else
+ last_comment = temp_comment;
+ }
+ if(comment_list == NULL) {
+ new_comment->next = NULL;
+ comment_list = new_comment;
+ }
+ else if(temp_comment == NULL) {
+ new_comment->next = NULL;
+ last_comment->next = new_comment;
+ }
+#ifdef NSCORE
+ pthread_mutex_unlock(&nagios_comment_lock);
+#endif
+ }
+
+#ifdef NSCORE
+#ifdef USE_EVENT_BROKER
+ /* send data to event broker */
+ broker_comment_data(NEBTYPE_COMMENT_LOAD, NEBFLAG_NONE, NEBATTR_NONE, comment_type, entry_type, host_name, svc_description, entry_time, author, comment_data, persistent, source, expires, expire_time, comment_id, NULL);
+#endif
+#endif
+
+ return OK;
+ }
+
+static int comment_compar(const void *p1, const void *p2) {
+ comment *c1 = *(comment **)p1;
+ comment *c2 = *(comment **)p2;
+ return (c1->comment_id < c2->comment_id) ? -1 : (c1->comment_id - c2->comment_id);
+ }
+
+int sort_comments(void) {
+ comment **array, *temp_comment;
+ unsigned long i = 0, unsorted_comments = 0;
+
+ if(!defer_comment_sorting)
+ return OK;
+ defer_comment_sorting = 0;
+
+ temp_comment = comment_list;
+ while(temp_comment != NULL) {
+ temp_comment = temp_comment->next;
+ unsorted_comments++;
+ }
+
+ if(!unsorted_comments)
+ return OK;
+
+ if(!(array = malloc(sizeof(*array) * unsorted_comments)))
+ return ERROR;
+ while(comment_list) {
+ array[i++] = comment_list;
+ comment_list = comment_list->next;
+ }
+
+ qsort((void *)array, i, sizeof(*array), comment_compar);
+ comment_list = temp_comment = array[0];
+ for(i = 1; i < unsorted_comments; i++) {
+ temp_comment->next = array[i];
+ temp_comment = temp_comment->next;
+ }
+ temp_comment->next = NULL;
+ my_free(array);
+ return OK;
+ }
+
+/******************************************************************/
+/********************* CLEANUP FUNCTIONS **************************/
+/******************************************************************/
+
+/* frees memory allocated for the comment data */
+void free_comment_data(void) {
+ comment *this_comment = NULL;
+ comment *next_comment = NULL;
+
+ /* free memory for the comment list */
+ for(this_comment = comment_list; this_comment != NULL; this_comment = next_comment) {
+ next_comment = this_comment->next;
+ my_free(this_comment->host_name);
+ my_free(this_comment->service_description);
+ my_free(this_comment->author);
+ my_free(this_comment->comment_data);
+ my_free(this_comment);
+ }
+
+ /* free hash list and reset list pointer */
+ my_free(comment_hashlist);
+ comment_hashlist = NULL;
+ comment_list = NULL;
+
+ return;
+ }
+
+
+
+
+/******************************************************************/
+/********************* UTILITY FUNCTIONS **************************/
+/******************************************************************/
+
+/* get the number of comments associated with a particular host */
+int number_of_host_comments(char *host_name) {
+ comment *temp_comment = NULL;
+ int total_comments = 0;
+
+ if(host_name == NULL)
+ return 0;
+
+ for(temp_comment = get_first_comment_by_host(host_name); temp_comment != NULL; temp_comment = get_next_comment_by_host(host_name, temp_comment)) {
+ if(temp_comment->comment_type == HOST_COMMENT)
+ total_comments++;
+ }
+
+ return total_comments;
+ }
+
+
+/* get the number of comments associated with a particular service */
+int number_of_service_comments(char *host_name, char *svc_description) {
+ comment *temp_comment = NULL;
+ int total_comments = 0;
+
+ if(host_name == NULL || svc_description == NULL)
+ return 0;
+
+ for(temp_comment = get_first_comment_by_host(host_name); temp_comment != NULL; temp_comment = get_next_comment_by_host(host_name, temp_comment)) {
+ if(temp_comment->comment_type == SERVICE_COMMENT && !strcmp(temp_comment->service_description, svc_description))
+ total_comments++;
+ }
+
+ return total_comments;
+ }
+
+
+
+/******************************************************************/
+/********************* TRAVERSAL FUNCTIONS ************************/
+/******************************************************************/
+
+comment *get_first_comment_by_host(char *host_name) {
+
+ return get_next_comment_by_host(host_name, NULL);
+ }
+
+
+comment *get_next_comment_by_host(char *host_name, comment *start) {
+ comment *temp_comment = NULL;
+
+ if(host_name == NULL || comment_hashlist == NULL)
+ return NULL;
+
+ if(start == NULL)
+ temp_comment = comment_hashlist[hashfunc(host_name, NULL, COMMENT_HASHSLOTS)];
+ else
+ temp_comment = start->nexthash;
+
+ for(; temp_comment && compare_hashdata(temp_comment->host_name, NULL, host_name, NULL) < 0; temp_comment = temp_comment->nexthash);
+
+ if(temp_comment && compare_hashdata(temp_comment->host_name, NULL, host_name, NULL) == 0)
+ return temp_comment;
+
+ return NULL;
+ }
+
+
+
+/******************************************************************/
+/********************** SEARCH FUNCTIONS **************************/
+/******************************************************************/
+
+/* find a service comment by id */
+comment *find_service_comment(unsigned long comment_id) {
+
+ return find_comment(comment_id, SERVICE_COMMENT);
+ }
+
+
+/* find a host comment by id */
+comment *find_host_comment(unsigned long comment_id) {
+
+ return find_comment(comment_id, HOST_COMMENT);
+ }
+
+
+/* find a comment by id */
+comment *find_comment(unsigned long comment_id, int comment_type) {
+ comment *temp_comment = NULL;
+
+ for(temp_comment = comment_list; temp_comment != NULL; temp_comment = temp_comment->next) {
+ if(temp_comment->comment_id == comment_id && temp_comment->comment_type == comment_type)
+ return temp_comment;
+ }
+
+ return NULL;
+ }
+
+
+
+
+
diff --git a/common/downtime.c b/common/downtime.c
new file mode 100644
index 0000000..a749163
--- /dev/null
+++ b/common/downtime.c
@@ -0,0 +1,1260 @@
+/*****************************************************************************
+ *
+ * DOWNTIME.C - Scheduled downtime functions for Nagios
+ *
+ * Copyright (c) 2000-2008 Ethan Galstad (egalstad@nagios.org)
+ * Last Modified: 02-17-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.
+ *
+ *****************************************************************************/
+
+#include "../include/config.h"
+#include "../include/common.h"
+#include "../include/comments.h"
+#include "../include/downtime.h"
+#include "../include/objects.h"
+#include "../include/statusdata.h"
+
+/***** IMPLEMENTATION-SPECIFIC INCLUDES *****/
+
+#ifdef USE_XDDDEFAULT
+#include "../xdata/xdddefault.h"
+#endif
+
+#ifdef NSCORE
+#include "../include/nagios.h"
+#include "../include/broker.h"
+#endif
+
+#ifdef NSCGI
+#include "../include/cgiutils.h"
+#endif
+
+
+scheduled_downtime *scheduled_downtime_list = NULL;
+int defer_downtime_sorting = 0;
+
+#ifdef NSCORE
+extern timed_event *event_list_high;
+extern timed_event *event_list_high_tail;
+pthread_mutex_t nagios_downtime_lock = PTHREAD_MUTEX_INITIALIZER;
+#endif
+
+
+
+#ifdef NSCORE
+
+/******************************************************************/
+/**************** INITIALIZATION/CLEANUP FUNCTIONS ****************/
+/******************************************************************/
+
+
+/* initializes scheduled downtime data */
+int initialize_downtime_data(char *config_file) {
+ int result = OK;
+
+ log_debug_info(DEBUGL_FUNCTIONS, 0, "initialize_downtime_data()\n");
+
+ /**** IMPLEMENTATION-SPECIFIC CALLS ****/
+#ifdef USE_XDDDEFAULT
+ result = xdddefault_initialize_downtime_data(config_file);
+#endif
+
+ return result;
+ }
+
+
+/* cleans up scheduled downtime data */
+int cleanup_downtime_data(char *config_file) {
+ int result = OK;
+
+ log_debug_info(DEBUGL_FUNCTIONS, 0, "cleanup_downtime_data()\n");
+
+ /**** IMPLEMENTATION-SPECIFIC CALLS ****/
+#ifdef USE_XDDDEFAULT
+ result = xdddefault_cleanup_downtime_data(config_file);
+#endif
+
+ /* free memory allocated to downtime data */
+ free_downtime_data();
+
+ return result;
+ }
+
+
+/******************************************************************/
+/********************** SCHEDULING FUNCTIONS **********************/
+/******************************************************************/
+
+/* schedules a host or service downtime */
+int schedule_downtime(int type, char *host_name, char *service_description, time_t entry_time, char *author, char *comment_data, time_t start_time, time_t end_time, int fixed, unsigned long triggered_by, unsigned long duration, unsigned long *new_downtime_id) {
+ unsigned long downtime_id = 0L;
+
+ log_debug_info(DEBUGL_FUNCTIONS, 0, "schedule_downtime()\n");
+
+ /* don't add old or invalid downtimes */
+
+ if(start_time >= end_time || end_time <= time(NULL)) {
+ log_debug_info(DEBUGL_DOWNTIME, 1, "Invalid start (%lu) or end (%lu) times\n",
+ start_time, end_time);
+ return ERROR;
+ }
+
+
+ /* add a new downtime entry */
+ add_new_downtime(type, host_name, service_description, entry_time, author, comment_data, start_time, end_time, fixed, triggered_by, duration, &downtime_id, FALSE, FALSE);
+
+ /* register the scheduled downtime */
+ register_downtime(type, downtime_id);
+
+ /* return downtime id */
+ if(new_downtime_id != NULL)
+ *new_downtime_id = downtime_id;
+
+ return OK;
+ }
+
+
+/* unschedules a host or service downtime */
+int unschedule_downtime(int type, unsigned long downtime_id) {
+ scheduled_downtime *temp_downtime = NULL;
+ scheduled_downtime *next_downtime = NULL;
+ host *hst = NULL;
+ service *svc = NULL;
+ timed_event *temp_event = NULL;
+#ifdef USE_EVENT_BROKER
+ int attr = 0;
+#endif
+
+ log_debug_info(DEBUGL_FUNCTIONS, 0, "unschedule_downtime()\n");
+
+ /* find the downtime entry in the list in memory */
+ if((temp_downtime = find_downtime(type, downtime_id)) == NULL)
+ return ERROR;
+
+ /* find the host or service associated with this downtime */
+ if(temp_downtime->type == HOST_DOWNTIME) {
+ if((hst = find_host(temp_downtime->host_name)) == NULL)
+ return ERROR;
+ }
+ else {
+ if((svc = find_service(temp_downtime->host_name, temp_downtime->service_description)) == NULL)
+ return ERROR;
+ }
+
+ /* decrement pending flex downtime if necessary ... */
+ if(temp_downtime->fixed == FALSE && temp_downtime->incremented_pending_downtime == TRUE) {
+ if(temp_downtime->type == HOST_DOWNTIME)
+ hst->pending_flex_downtime--;
+ else
+ svc->pending_flex_downtime--;
+ }
+
+ /* decrement the downtime depth variable and update status data if necessary */
+ if(temp_downtime->is_in_effect == TRUE) {
+
+#ifdef USE_EVENT_BROKER
+ /* send data to event broker */
+ attr = NEBATTR_DOWNTIME_STOP_CANCELLED;
+ broker_downtime_data(NEBTYPE_DOWNTIME_STOP, NEBFLAG_NONE, attr, temp_downtime->type, temp_downtime->host_name, temp_downtime->service_description, temp_downtime->entry_time, temp_downtime->author, temp_downtime->comment, temp_downtime->start_time, temp_downtime->end_time, temp_downtime->fixed, temp_downtime->triggered_by, temp_downtime->duration, temp_downtime->downtime_id, NULL);
+#endif
+
+ if(temp_downtime->type == HOST_DOWNTIME) {
+
+ hst->scheduled_downtime_depth--;
+ update_host_status(hst, FALSE);
+
+ /* log a notice - this is parsed by the history CGI */
+ if(hst->scheduled_downtime_depth == 0) {
+
+ logit(NSLOG_INFO_MESSAGE, FALSE, "HOST DOWNTIME ALERT: %s;CANCELLED; Scheduled downtime for host has been cancelled.\n", hst->name);
+
+ /* send a notification */
+ host_notification(hst, NOTIFICATION_DOWNTIMECANCELLED, NULL, NULL, NOTIFICATION_OPTION_NONE);
+ }
+ }
+
+ else {
+
+ svc->scheduled_downtime_depth--;
+ update_service_status(svc, FALSE);
+
+ /* log a notice - this is parsed by the history CGI */
+ if(svc->scheduled_downtime_depth == 0) {
+
+ logit(NSLOG_INFO_MESSAGE, FALSE, "SERVICE DOWNTIME ALERT: %s;%s;CANCELLED; Scheduled downtime for service has been cancelled.\n", svc->host_name, svc->description);
+
+ /* send a notification */
+ service_notification(svc, NOTIFICATION_DOWNTIMECANCELLED, NULL, NULL, NOTIFICATION_OPTION_NONE);
+ }
+ }
+ }
+
+ /* remove scheduled entry from event queue */
+ for(temp_event = event_list_high; temp_event != NULL; temp_event = temp_event->next) {
+ if(temp_event->event_type != EVENT_SCHEDULED_DOWNTIME)
+ continue;
+ if(((unsigned long)temp_event->event_data) == downtime_id)
+ break;
+ }
+ if(temp_event != NULL) {
+ remove_event(temp_event, &event_list_high, &event_list_high_tail);
+ my_free(temp_event->event_data);
+ my_free(temp_event);
+ }
+
+ /* delete downtime entry */
+ if(temp_downtime->type == HOST_DOWNTIME)
+ delete_host_downtime(downtime_id);
+ else
+ delete_service_downtime(downtime_id);
+
+ /* unschedule all downtime entries that were triggered by this one */
+ while(1) {
+
+ for(temp_downtime = scheduled_downtime_list; temp_downtime != NULL; temp_downtime = next_downtime) {
+ next_downtime = temp_downtime->next;
+ if(temp_downtime->triggered_by == downtime_id) {
+ unschedule_downtime(ANY_DOWNTIME, temp_downtime->downtime_id);
+ break;
+ }
+ }
+
+ if(temp_downtime == NULL)
+ break;
+ }
+
+ return OK;
+ }
+
+
+
+/* registers scheduled downtime (schedules it, adds comments, etc.) */
+int register_downtime(int type, unsigned long downtime_id) {
+ char *temp_buffer = NULL;
+ char start_time_string[MAX_DATETIME_LENGTH] = "";
+ char flex_start_string[MAX_DATETIME_LENGTH] = "";
+ char end_time_string[MAX_DATETIME_LENGTH] = "";
+ scheduled_downtime *temp_downtime = NULL;
+ host *hst = NULL;
+ service *svc = NULL;
+ char *type_string = NULL;
+ int hours = 0;
+ int minutes = 0;
+ int seconds = 0;
+ unsigned long *new_downtime_id = NULL;
+ int was_in_effect = FALSE;
+
+ log_debug_info(DEBUGL_FUNCTIONS, 0, "register_downtime( %d, %lu)\n", type,
+ downtime_id);
+
+ /* find the downtime entry in memory */
+ temp_downtime = find_downtime(type, downtime_id);
+ if(temp_downtime == NULL) {
+ log_debug_info(DEBUGL_DOWNTIME, 0, "Cannot find downtime ID: %lu\n", downtime_id);
+ return ERROR;
+ }
+
+ /* find the host or service associated with this downtime */
+ if(temp_downtime->type == HOST_DOWNTIME) {
+ if((hst = find_host(temp_downtime->host_name)) == NULL) {
+ log_debug_info(DEBUGL_DOWNTIME, 1,
+ "Cannot find host (%s) for downtime ID: %lu\n",
+ temp_downtime->host_name, downtime_id);
+ return ERROR;
+ }
+ }
+ else {
+ if((svc = find_service(temp_downtime->host_name, temp_downtime->service_description)) == NULL) {
+ log_debug_info(DEBUGL_DOWNTIME, 1,
+ "Cannot find service (%s) for host (%s) for downtime ID: %lu\n",
+ temp_downtime->service_description, temp_downtime->host_name,
+ downtime_id);
+ return ERROR;
+ }
+ }
+
+ /* create the comment */
+ get_datetime_string(&(temp_downtime->start_time), start_time_string, MAX_DATETIME_LENGTH, SHORT_DATE_TIME);
+ get_datetime_string(&(temp_downtime->flex_downtime_start), flex_start_string, MAX_DATETIME_LENGTH, SHORT_DATE_TIME);
+ get_datetime_string(&(temp_downtime->end_time), end_time_string, MAX_DATETIME_LENGTH, SHORT_DATE_TIME);
+ hours = temp_downtime->duration / 3600;
+ minutes = ((temp_downtime->duration - (hours * 3600)) / 60);
+ seconds = temp_downtime->duration - (hours * 3600) - (minutes * 60);
+ if(temp_downtime->type == HOST_DOWNTIME)
+ type_string = "host";
+ else
+ type_string = "service";
+ if(temp_downtime->fixed == TRUE)
+ asprintf(&temp_buffer, "This %s has been scheduled for fixed downtime from %s to %s. Notifications for the %s will not be sent out during that time period.", type_string, start_time_string, end_time_string, type_string);
+ else
+ asprintf(&temp_buffer, "This %s has been scheduled for flexible downtime starting between %s and %s and lasting for a period of %d hours and %d minutes. Notifications for the %s will not be sent out during that time period.", type_string, start_time_string, end_time_string, hours, minutes, type_string);
+
+
+ log_debug_info(DEBUGL_DOWNTIME, 0, "Scheduled Downtime Details:\n");
+ if(temp_downtime->type == HOST_DOWNTIME) {
+ log_debug_info(DEBUGL_DOWNTIME, 0, " Type: Host Downtime\n");
+ log_debug_info(DEBUGL_DOWNTIME, 0, " Host: %s\n", hst->name);
+ }
+ else {
+ log_debug_info(DEBUGL_DOWNTIME, 0, " Type: Service Downtime\n");
+ log_debug_info(DEBUGL_DOWNTIME, 0, " Host: %s\n", svc->host_name);
+ log_debug_info(DEBUGL_DOWNTIME, 0, " Service: %s\n", svc->description);
+ }
+ log_debug_info(DEBUGL_DOWNTIME, 0, " Fixed/Flex: %s\n", (temp_downtime->fixed == TRUE) ? "Fixed" : "Flexible");
+ log_debug_info(DEBUGL_DOWNTIME, 0, " Start: %s\n", start_time_string);
+ if(temp_downtime->flex_downtime_start) {
+ log_debug_info(DEBUGL_DOWNTIME, 0, " Flex Start: %s\n", flex_start_string);
+ }
+ log_debug_info(DEBUGL_DOWNTIME, 0, " End: %s\n", end_time_string);
+ log_debug_info(DEBUGL_DOWNTIME, 0, " Duration: %dh %dm %ds\n", hours, minutes, seconds);
+ log_debug_info(DEBUGL_DOWNTIME, 0, " Downtime ID: %lu\n", temp_downtime->downtime_id);
+ log_debug_info(DEBUGL_DOWNTIME, 0, " Trigger ID: %lu\n", temp_downtime->triggered_by);
+
+
+ /* add a non-persistent comment to the host or service regarding the scheduled outage */
+ if(temp_downtime->type == SERVICE_DOWNTIME)
+ add_new_comment(SERVICE_COMMENT, DOWNTIME_COMMENT, svc->host_name, svc->description, time(NULL), ( NULL == temp_downtime->author ? "(Nagios Process)" : temp_downtime->author), temp_buffer, 0, COMMENTSOURCE_INTERNAL, FALSE, (time_t)0, &(temp_downtime->comment_id));
+ else
+ add_new_comment(HOST_COMMENT, DOWNTIME_COMMENT, hst->name, NULL, time(NULL), ( NULL == temp_downtime->author ? "(Nagios Process)" : temp_downtime->author), temp_buffer, 0, COMMENTSOURCE_INTERNAL, FALSE, (time_t)0, &(temp_downtime->comment_id));
+
+ my_free(temp_buffer);
+
+ /*** SCHEDULE DOWNTIME - FLEXIBLE (NON-FIXED) DOWNTIME IS HANDLED AT A LATER POINT ***/
+
+ /* only non-triggered downtime is scheduled... */
+ if((temp_downtime->triggered_by == 0) && ((TRUE == temp_downtime->fixed) ||
+ ((FALSE == temp_downtime->fixed) &&
+ (TRUE == temp_downtime->is_in_effect)))) {
+ /* If this is a fixed downtime, schedule the event to start it. If this
+ is a flexible downtime, normally we wait for one of the
+ check_pending_flex_*_downtime() functions to start it, but if the
+ downtime is already in effect, this means that we are restarting
+ Nagios and the downtime was in effect when we last shutdown
+ Nagios, so we should restart the flexible downtime now. This
+ should work even if the downtime has ended because the
+ handle_scheduled_dowtime() function will immediately schedule
+ another downtime event which will end the downtime. */
+ if((new_downtime_id = (unsigned long *)malloc(sizeof(unsigned long *)))) {
+ *new_downtime_id = downtime_id;
+ /*temp_downtime->start_event = schedule_new_event(EVENT_SCHEDULED_DOWNTIME, TRUE, temp_downtime->start_time, FALSE, 0, NULL, FALSE, (void *)new_downtime_id, NULL, 0); */
+ schedule_new_event(EVENT_SCHEDULED_DOWNTIME, TRUE, temp_downtime->start_time, FALSE, 0, NULL, FALSE, (void *)new_downtime_id, NULL, 0);
+ /* Turn off is_in_effect flag so handle_scheduled_downtime() will
+ handle it correctly */
+ was_in_effect = temp_downtime->is_in_effect;
+ temp_downtime->is_in_effect = FALSE;
+ }
+ }
+
+ /* If the downtime is triggered and was in effect, mark it as not in
+ effect so it gets scheduled correctly */
+ if((temp_downtime->triggered_by != 0) &&
+ (TRUE == temp_downtime->is_in_effect)) {
+ was_in_effect = temp_downtime->is_in_effect;
+ temp_downtime->is_in_effect = FALSE;
+ }
+
+ if((FALSE == temp_downtime->fixed) && (FALSE == was_in_effect)) {
+ /* increment pending flex downtime counter */
+ if(temp_downtime->type == HOST_DOWNTIME)
+ hst->pending_flex_downtime++;
+ else
+ svc->pending_flex_downtime++;
+ temp_downtime->incremented_pending_downtime = TRUE;
+
+ /* Since a flex downtime may never start, schedule an expiring event in
+ case the event is never triggered. The expire event will NOT cancel
+ a downtime event that is in effect */
+ log_debug_info(DEBUGL_DOWNTIME, 1, "Scheduling downtime expire event in case flexible downtime is never triggered\n");
+ /*temp_downtime->stop_event = schedule_new_event(EVENT_EXPIRE_DOWNTIME, TRUE, (temp_downtime->end_time + 1), FALSE, 0, NULL, FALSE, NULL, NULL, 0);*/
+ schedule_new_event(EVENT_EXPIRE_DOWNTIME, TRUE, (temp_downtime->end_time + 1), FALSE, 0, NULL, FALSE, NULL, NULL, 0);
+ }
+
+
+#ifdef PROBABLY_NOT_NEEDED
+ /*** FLEXIBLE DOWNTIME SANITY CHECK - ADDED 02/17/2008 ****/
+
+ /* if host/service is in a non-OK/UP state right now, see if we should start flexible time immediately */
+ /* this is new logic added in 3.0rc3 */
+ if(temp_downtime->fixed == FALSE) {
+ if(temp_downtime->type == HOST_DOWNTIME)
+ check_pending_flex_host_downtime(hst);
+ else
+ check_pending_flex_service_downtime(svc);
+ }
+#endif
+
+ return OK;
+ }
+
+
+
+/* handles scheduled downtime (id passed from timed event queue) */
+int handle_scheduled_downtime_by_id(unsigned long downtime_id) {
+ scheduled_downtime *temp_downtime = NULL;
+
+ log_debug_info(DEBUGL_FUNCTIONS, 0, "handle_scheduled_downtime_by_id()\n");
+
+ /* find the downtime entry */
+ if((temp_downtime = find_downtime(ANY_DOWNTIME, downtime_id)) == NULL) {
+ log_debug_info(DEBUGL_DOWNTIME, 1, "Unable to find downtime id: %lu\n",
+ downtime_id);
+ return ERROR;
+ }
+
+ /* handle the downtime */
+ return handle_scheduled_downtime(temp_downtime);
+ }
+
+
+
+/* handles scheduled host or service downtime */
+int handle_scheduled_downtime(scheduled_downtime *temp_downtime) {
+ scheduled_downtime *this_downtime = NULL;
+ host *hst = NULL;
+ service *svc = NULL;
+ time_t event_time = 0L;
+ //time_t current_time = 0L;
+ unsigned long *new_downtime_id = NULL;
+#ifdef USE_EVENT_BROKER
+ int attr = 0;
+#endif
+
+
+ log_debug_info(DEBUGL_FUNCTIONS, 0, "handle_scheduled_downtime()\n");
+
+ if(temp_downtime == NULL)
+ return ERROR;
+
+ /* find the host or service associated with this downtime */
+ if(temp_downtime->type == HOST_DOWNTIME) {
+ if((hst = find_host(temp_downtime->host_name)) == NULL) {
+ log_debug_info(DEBUGL_DOWNTIME, 1, "Unable to find host (%s) for downtime\n", temp_downtime->host_name);
+ return ERROR;
+ }
+ }
+ else {
+ if((svc = find_service(temp_downtime->host_name, temp_downtime->service_description)) == NULL) {
+ log_debug_info(DEBUGL_DOWNTIME, 1, "Unable to find service (%s) host (%s) for downtime\n", temp_downtime->service_description, temp_downtime->host_name);
+ return ERROR;
+
+ }
+ }
+
+
+ /* have we come to the end of the scheduled downtime? */
+ if(temp_downtime->is_in_effect == TRUE) {
+
+#ifdef USE_EVENT_BROKER
+ /* send data to event broker */
+ attr = NEBATTR_DOWNTIME_STOP_NORMAL;
+ broker_downtime_data(NEBTYPE_DOWNTIME_STOP, NEBFLAG_NONE, attr, temp_downtime->type, temp_downtime->host_name, temp_downtime->service_description, temp_downtime->entry_time, temp_downtime->author, temp_downtime->comment, temp_downtime->start_time, temp_downtime->end_time, temp_downtime->fixed, temp_downtime->triggered_by, temp_downtime->duration, temp_downtime->downtime_id, NULL);
+#endif
+
+ /* decrement the downtime depth variable */
+ if(temp_downtime->type == HOST_DOWNTIME)
+ hst->scheduled_downtime_depth--;
+ else
+ svc->scheduled_downtime_depth--;
+
+ if(temp_downtime->type == HOST_DOWNTIME && hst->scheduled_downtime_depth == 0) {
+
+ log_debug_info(DEBUGL_DOWNTIME, 0, "Host '%s' has exited from a period of scheduled downtime (id=%lu).\n", hst->name, temp_downtime->downtime_id);
+
+ /* log a notice - this one is parsed by the history CGI */
+ logit(NSLOG_INFO_MESSAGE, FALSE, "HOST DOWNTIME ALERT: %s;STOPPED; Host has exited from a period of scheduled downtime", hst->name);
+
+ /* send a notification */
+ host_notification(hst, NOTIFICATION_DOWNTIMEEND, temp_downtime->author, temp_downtime->comment, NOTIFICATION_OPTION_NONE);
+ }
+
+ else if(temp_downtime->type == SERVICE_DOWNTIME && svc->scheduled_downtime_depth == 0) {
+
+ log_debug_info(DEBUGL_DOWNTIME, 0, "Service '%s' on host '%s' has exited from a period of scheduled downtime (id=%lu).\n", svc->description, svc->host_name, temp_downtime->downtime_id);
+
+ /* log a notice - this one is parsed by the history CGI */
+ logit(NSLOG_INFO_MESSAGE, FALSE, "SERVICE DOWNTIME ALERT: %s;%s;STOPPED; Service has exited from a period of scheduled downtime", svc->host_name, svc->description);
+
+ /* send a notification */
+ service_notification(svc, NOTIFICATION_DOWNTIMEEND, temp_downtime->author, temp_downtime->comment, NOTIFICATION_OPTION_NONE);
+ }
+
+
+ /* update the status data */
+ if(temp_downtime->type == HOST_DOWNTIME)
+ update_host_status(hst, FALSE);
+ else
+ update_service_status(svc, FALSE);
+
+ /* decrement pending flex downtime if necessary */
+ if(temp_downtime->fixed == FALSE && temp_downtime->incremented_pending_downtime == TRUE) {
+ if(temp_downtime->type == HOST_DOWNTIME) {
+ if(hst->pending_flex_downtime > 0)
+ hst->pending_flex_downtime--;
+ }
+ else {
+ if(svc->pending_flex_downtime > 0)
+ svc->pending_flex_downtime--;
+ }
+ }
+
+ /* handle (stop) downtime that is triggered by this one */
+ while(1) {
+
+ /* list contents might change by recursive calls, so we use this inefficient method to prevent segfaults */
+ for(this_downtime = scheduled_downtime_list; this_downtime != NULL; this_downtime = this_downtime->next) {
+ if(this_downtime->triggered_by == temp_downtime->downtime_id) {
+ handle_scheduled_downtime(this_downtime);
+ break;
+ }
+ }
+
+ if(this_downtime == NULL)
+ break;
+ }
+
+ /* delete downtime entry */
+ if(temp_downtime->type == HOST_DOWNTIME)
+ delete_host_downtime(temp_downtime->downtime_id);
+ else
+ delete_service_downtime(temp_downtime->downtime_id);
+ }
+
+ /* else we are just starting the scheduled downtime */
+ else {
+
+#ifdef USE_EVENT_BROKER
+ /* send data to event broker */
+ broker_downtime_data(NEBTYPE_DOWNTIME_START, NEBFLAG_NONE, NEBATTR_NONE, temp_downtime->type, temp_downtime->host_name, temp_downtime->service_description, temp_downtime->entry_time, temp_downtime->author, temp_downtime->comment, temp_downtime->start_time, temp_downtime->end_time, temp_downtime->fixed, temp_downtime->triggered_by, temp_downtime->duration, temp_downtime->downtime_id, NULL);
+#endif
+
+ if(temp_downtime->type == HOST_DOWNTIME && hst->scheduled_downtime_depth == 0) {
+
+ log_debug_info(DEBUGL_DOWNTIME, 0, "Host '%s' has entered a period of scheduled downtime (id=%lu).\n", hst->name, temp_downtime->downtime_id);
+
+ /* log a notice - this one is parsed by the history CGI */
+ logit(NSLOG_INFO_MESSAGE, FALSE, "HOST DOWNTIME ALERT: %s;STARTED; Host has entered a period of scheduled downtime", hst->name);
+
+ /* send a notification */
+ if(FALSE == temp_downtime->start_notification_sent) {
+ host_notification(hst, NOTIFICATION_DOWNTIMESTART, temp_downtime->author, temp_downtime->comment, NOTIFICATION_OPTION_NONE);
+ temp_downtime->start_notification_sent = TRUE;
+ }
+ }
+
+ else if(temp_downtime->type == SERVICE_DOWNTIME && svc->scheduled_downtime_depth == 0) {
+
+ log_debug_info(DEBUGL_DOWNTIME, 0, "Service '%s' on host '%s' has entered a period of scheduled downtime (id=%lu).\n", svc->description, svc->host_name, temp_downtime->downtime_id);
+
+ /* log a notice - this one is parsed by the history CGI */
+ logit(NSLOG_INFO_MESSAGE, FALSE, "SERVICE DOWNTIME ALERT: %s;%s;STARTED; Service has entered a period of scheduled downtime", svc->host_name, svc->description);
+
+ /* send a notification */
+ if(FALSE == temp_downtime->start_notification_sent) {
+ service_notification(svc, NOTIFICATION_DOWNTIMESTART, temp_downtime->author, temp_downtime->comment, NOTIFICATION_OPTION_NONE);
+ temp_downtime->start_notification_sent = TRUE;
+ }
+ }
+
+ /* increment the downtime depth variable */
+ if(temp_downtime->type == HOST_DOWNTIME)
+ hst->scheduled_downtime_depth++;
+ else
+ svc->scheduled_downtime_depth++;
+
+ /* set the in effect flag */
+ temp_downtime->is_in_effect = TRUE;
+
+ /* update the status data */
+ if(temp_downtime->type == HOST_DOWNTIME)
+ update_host_status(hst, FALSE);
+ else
+ update_service_status(svc, FALSE);
+
+ /* schedule an event to end the downtime */
+ if(temp_downtime->fixed == FALSE) {
+ event_time = (time_t)((unsigned long)temp_downtime->flex_downtime_start
+ + temp_downtime->duration);
+ }
+ else {
+ event_time = temp_downtime->end_time;
+ }
+ if((new_downtime_id = (unsigned long *)malloc(sizeof(unsigned long *)))) {
+ *new_downtime_id = temp_downtime->downtime_id;
+ schedule_new_event(EVENT_SCHEDULED_DOWNTIME, TRUE, event_time, FALSE, 0, NULL, FALSE, (void *)new_downtime_id, NULL, 0);
+ }
+
+ /* handle (start) downtime that is triggered by this one */
+ for(this_downtime = scheduled_downtime_list; this_downtime != NULL; this_downtime = this_downtime->next) {
+ if(this_downtime->triggered_by == temp_downtime->downtime_id)
+ handle_scheduled_downtime(this_downtime);
+ }
+ }
+
+ return OK;
+ }
+
+
+
+/* checks for flexible (non-fixed) host downtime that should start now */
+int check_pending_flex_host_downtime(host *hst) {
+ scheduled_downtime *temp_downtime = NULL;
+ time_t current_time = 0L;
+ unsigned long * new_downtime_id = NULL;
+
+ log_debug_info(DEBUGL_FUNCTIONS, 0, "check_pending_flex_host_downtime()\n");
+
+ if(hst == NULL)
+ return ERROR;
+
+ time(¤t_time);
+
+ /* if host is currently up, nothing to do */
+ if(hst->current_state == HOST_UP)
+ return OK;
+
+ /* check all downtime entries */
+ for(temp_downtime = scheduled_downtime_list; temp_downtime != NULL; temp_downtime = temp_downtime->next) {
+
+ if(temp_downtime->type != HOST_DOWNTIME)
+ continue;
+
+ if(temp_downtime->fixed == TRUE)
+ continue;
+
+ if(temp_downtime->is_in_effect == TRUE)
+ continue;
+
+ /* triggered downtime entries should be ignored here */
+ if(temp_downtime->triggered_by != 0)
+ continue;
+
+ /* this entry matches our host! */
+ if(find_host(temp_downtime->host_name) == hst) {
+
+ /* if the time boundaries are okay, start this scheduled downtime */
+ if(temp_downtime->start_time <= current_time && current_time <= temp_downtime->end_time) {
+
+ log_debug_info(DEBUGL_DOWNTIME, 0, "Flexible downtime (id=%lu) for host '%s' starting now...\n", temp_downtime->downtime_id, hst->name);
+
+ temp_downtime->flex_downtime_start = current_time;
+ if((new_downtime_id = (unsigned long *)malloc(sizeof(unsigned long *)))) {
+ *new_downtime_id = temp_downtime->downtime_id;
+ /*temp_downtime->start_event = schedule_new_event(EVENT_SCHEDULED_DOWNTIME, TRUE, temp_downtime->flex_downtime_start, FALSE, 0, NULL, FALSE, (void *)new_downtime_id, NULL, 0);*/
+ schedule_new_event(EVENT_SCHEDULED_DOWNTIME, TRUE, temp_downtime->flex_downtime_start, FALSE, 0, NULL, FALSE, (void *)new_downtime_id, NULL, 0);
+ }
+ }
+ }
+ }
+
+ return OK;
+ }
+
+
+/* checks for flexible (non-fixed) service downtime that should start now */
+int check_pending_flex_service_downtime(service *svc) {
+ scheduled_downtime *temp_downtime = NULL;
+ time_t current_time = 0L;
+ unsigned long * new_downtime_id = NULL;
+
+
+ log_debug_info(DEBUGL_FUNCTIONS, 0, "check_pending_flex_service_downtime()\n");
+
+ if(svc == NULL)
+ return ERROR;
+
+ time(¤t_time);
+
+ /* if service is currently ok, nothing to do */
+ if(svc->current_state == STATE_OK)
+ return OK;
+
+ /* check all downtime entries */
+ for(temp_downtime = scheduled_downtime_list; temp_downtime != NULL; temp_downtime = temp_downtime->next) {
+
+ if(temp_downtime->type != SERVICE_DOWNTIME)
+ continue;
+
+ if(temp_downtime->fixed == TRUE)
+ continue;
+
+ if(temp_downtime->is_in_effect == TRUE)
+ continue;
+
+ /* triggered downtime entries should be ignored here */
+ if(temp_downtime->triggered_by != 0)
+ continue;
+
+ /* this entry matches our service! */
+ if(find_service(temp_downtime->host_name, temp_downtime->service_description) == svc) {
+
+ /* if the time boundaries are okay, start this scheduled downtime */
+ if(temp_downtime->start_time <= current_time && current_time <= temp_downtime->end_time) {
+
+ log_debug_info(DEBUGL_DOWNTIME, 0, "Flexible downtime (id=%lu) for service '%s' on host '%s' starting now...\n", temp_downtime->downtime_id, svc->description, svc->host_name);
+
+ temp_downtime->flex_downtime_start = current_time;
+ if((new_downtime_id = (unsigned long *)malloc(sizeof(unsigned long *)))) {
+ *new_downtime_id = temp_downtime->downtime_id;
+ schedule_new_event(EVENT_SCHEDULED_DOWNTIME, TRUE, temp_downtime->flex_downtime_start, FALSE, 0, NULL, FALSE, (void *)new_downtime_id, NULL, 0);
+ }
+ }
+ }
+ }
+
+ return OK;
+ }
+
+
+/* checks for (and removes) expired downtime entries */
+int check_for_expired_downtime(void) {
+ scheduled_downtime *temp_downtime = NULL;
+ scheduled_downtime *next_downtime = NULL;
+ time_t current_time = 0L;
+
+
+ log_debug_info(DEBUGL_FUNCTIONS, 0, "check_for_expired_downtime()\n");
+
+ time(¤t_time);
+
+ /* check all downtime entries... */
+ for(temp_downtime = scheduled_downtime_list; temp_downtime != NULL; temp_downtime = next_downtime) {
+
+ next_downtime = temp_downtime->next;
+
+ /* this entry should be removed */
+ if(temp_downtime->is_in_effect == FALSE && temp_downtime->end_time < current_time) {
+
+ log_debug_info(DEBUGL_DOWNTIME, 0, "Expiring %s downtime (id=%lu)...\n", (temp_downtime->type == HOST_DOWNTIME) ? "host" : "service", temp_downtime->downtime_id);
+
+ /* delete the downtime entry */
+ if(temp_downtime->type == HOST_DOWNTIME)
+ delete_host_downtime(temp_downtime->downtime_id);
+ else
+ delete_service_downtime(temp_downtime->downtime_id);
+ }
+ }
+
+ return OK;
+ }
+
+
+
+/******************************************************************/
+/************************* SAVE FUNCTIONS *************************/
+/******************************************************************/
+
+
+/* save a host or service downtime */
+int add_new_downtime(int type, char *host_name, char *service_description, time_t entry_time, char *author, char *comment_data, time_t start_time, time_t end_time, int fixed, unsigned long triggered_by, unsigned long duration, unsigned long *downtime_id, int is_in_effect, int start_notification_sent) {
+ int result = OK;
+
+ if(type == HOST_DOWNTIME)
+ result = add_new_host_downtime(host_name, entry_time, author, comment_data, start_time, end_time, fixed, triggered_by, duration, downtime_id, is_in_effect, start_notification_sent);
+ else
+ result = add_new_service_downtime(host_name, service_description, entry_time, author, comment_data, start_time, end_time, fixed, triggered_by, duration, downtime_id, is_in_effect, start_notification_sent);
+
+ return result;
+ }
+
+
+/* saves a host downtime entry */
+int add_new_host_downtime(char *host_name, time_t entry_time, char *author, char *comment_data, time_t start_time, time_t end_time, int fixed, unsigned long triggered_by, unsigned long duration, unsigned long *downtime_id, int is_in_effect, int start_notification_sent) {
+ int result = OK;
+ unsigned long new_downtime_id = 0L;
+
+ if(host_name == NULL)
+ return ERROR;
+
+ /**** IMPLEMENTATION-SPECIFIC CALLS ****/
+#ifdef USE_XDDDEFAULT
+ result = xdddefault_add_new_host_downtime(host_name, entry_time, author, comment_data, start_time, end_time, fixed, triggered_by, duration, &new_downtime_id, is_in_effect, start_notification_sent);
+#endif
+
+ /* save downtime id */
+ if(downtime_id != NULL)
+ *downtime_id = new_downtime_id;
+
+#ifdef USE_EVENT_BROKER
+ /* send data to event broker */
+ broker_downtime_data(NEBTYPE_DOWNTIME_ADD, NEBFLAG_NONE, NEBATTR_NONE, HOST_DOWNTIME, host_name, NULL, entry_time, author, comment_data, start_time, end_time, fixed, triggered_by, duration, new_downtime_id, NULL);
+#endif
+
+ return result;
+ }
+
+
+/* saves a service downtime entry */
+int add_new_service_downtime(char *host_name, char *service_description, time_t entry_time, char *author, char *comment_data, time_t start_time, time_t end_time, int fixed, unsigned long triggered_by, unsigned long duration, unsigned long *downtime_id, int is_in_effect, int start_notification_sent) {
+ int result = OK;
+ unsigned long new_downtime_id = 0L;
+
+ if(host_name == NULL || service_description == NULL)
+ return ERROR;
+
+ /**** IMPLEMENTATION-SPECIFIC CALLS ****/
+#ifdef USE_XDDDEFAULT
+ result = xdddefault_add_new_service_downtime(host_name, service_description, entry_time, author, comment_data, start_time, end_time, fixed, triggered_by, duration, &new_downtime_id, is_in_effect, start_notification_sent);
+#endif
+
+ /* save downtime id */
+ if(downtime_id != NULL)
+ *downtime_id = new_downtime_id;
+
+#ifdef USE_EVENT_BROKER
+ /* send data to event broker */
+ broker_downtime_data(NEBTYPE_DOWNTIME_ADD, NEBFLAG_NONE, NEBATTR_NONE, SERVICE_DOWNTIME, host_name, service_description, entry_time, author, comment_data, start_time, end_time, fixed, triggered_by, duration, new_downtime_id, NULL);
+#endif
+
+ return result;
+ }
+
+
+
+/******************************************************************/
+/*********************** DELETION FUNCTIONS ***********************/
+/******************************************************************/
+
+
+/* deletes a scheduled host or service downtime entry from the list in memory */
+int delete_downtime(int type, unsigned long downtime_id) {
+ int result = OK;
+ scheduled_downtime *this_downtime = NULL;
+ scheduled_downtime *last_downtime = NULL;
+ scheduled_downtime *next_downtime = NULL;
+
+#ifdef NSCORE
+ pthread_mutex_lock(&nagios_downtime_lock);
+#endif
+ /* find the downtime we should remove */
+ for(this_downtime = scheduled_downtime_list, last_downtime = scheduled_downtime_list; this_downtime != NULL; this_downtime = next_downtime) {
+ next_downtime = this_downtime->next;
+
+ /* we found the downtime we should delete */
+ if(this_downtime->downtime_id == downtime_id && this_downtime->type == type)
+ break;
+
+ last_downtime = this_downtime;
+ }
+
+ /* remove the downtime from the list in memory */
+ if(this_downtime != NULL) {
+
+ /* first remove the comment associated with this downtime */
+ if(this_downtime->type == HOST_DOWNTIME)
+ delete_host_comment(this_downtime->comment_id);
+ else
+ delete_service_comment(this_downtime->comment_id);
+
+#ifdef USE_EVENT_BROKER
+ /* send data to event broker */
+ broker_downtime_data(NEBTYPE_DOWNTIME_DELETE, NEBFLAG_NONE, NEBATTR_NONE, type, this_downtime->host_name, this_downtime->service_description, this_downtime->entry_time, this_downtime->author, this_downtime->comment, this_downtime->start_time, this_downtime->end_time, this_downtime->fixed, this_downtime->triggered_by, this_downtime->duration, downtime_id, NULL);
+#endif
+
+ if(scheduled_downtime_list == this_downtime)
+ scheduled_downtime_list = this_downtime->next;
+ else
+ last_downtime->next = next_downtime;
+
+ /* free memory */
+ my_free(this_downtime->host_name);
+ my_free(this_downtime->service_description);
+ my_free(this_downtime->author);
+ my_free(this_downtime->comment);
+ my_free(this_downtime);
+
+ result = OK;
+ }
+ else
+ result = ERROR;
+
+#ifdef NSCORE
+ pthread_mutex_unlock(&nagios_downtime_lock);
+#endif
+
+ return result;
+ }
+
+
+/* deletes a scheduled host downtime entry */
+int delete_host_downtime(unsigned long downtime_id) {
+ int result = OK;
+
+ /* delete the downtime from memory */
+ delete_downtime(HOST_DOWNTIME, downtime_id);
+
+ /**** IMPLEMENTATION-SPECIFIC CALLS ****/
+#ifdef USE_XDDDEFAULT
+ result = xdddefault_delete_host_downtime(downtime_id);
+#endif
+
+ return result;
+ }
+
+
+/* deletes a scheduled service downtime entry */
+int delete_service_downtime(unsigned long downtime_id) {
+ int result = OK;
+
+ /* delete the downtime from memory */
+ delete_downtime(SERVICE_DOWNTIME, downtime_id);
+
+ /**** IMPLEMENTATION-SPECIFIC CALLS ****/
+#ifdef USE_XDDDEFAULT
+ result = xdddefault_delete_service_downtime(downtime_id);
+#endif
+
+ return result;
+ }
+
+/*
+Deletes all host and service downtimes on a host by hostname, optionally filtered by service description, start time and comment.
+All char* must be set or NULL - "" will silently fail to match
+Returns number deleted
+*/
+int delete_downtime_by_hostname_service_description_start_time_comment(char *hostname, char *service_description, time_t start_time, char *comment) {
+ scheduled_downtime *temp_downtime;
+ scheduled_downtime *next_downtime;
+ int deleted = 0;
+
+ /* Do not allow deletion of everything - must have at least 1 filter on */
+ if(hostname == NULL && service_description == NULL && start_time == 0 && comment == NULL)
+ return deleted;
+
+ for(temp_downtime = scheduled_downtime_list; temp_downtime != NULL; temp_downtime = next_downtime) {
+ next_downtime = temp_downtime->next;
+ if(start_time != 0 && temp_downtime->start_time != start_time) {
+ continue;
+ }
+ if(comment != NULL && strcmp(temp_downtime->comment, comment) != 0)
+ continue;
+ if(temp_downtime->type == HOST_DOWNTIME) {
+ /* If service is specified, then do not delete the host downtime */
+ if(service_description != NULL)
+ continue;
+ if(hostname != NULL && strcmp(temp_downtime->host_name, hostname) != 0)
+ continue;
+ }
+ else if(temp_downtime->type == SERVICE_DOWNTIME) {
+ if(hostname != NULL && strcmp(temp_downtime->host_name, hostname) != 0)
+ continue;
+ if(service_description != NULL && strcmp(temp_downtime->service_description, service_description) != 0)
+ continue;
+ }
+
+ unschedule_downtime(temp_downtime->type, temp_downtime->downtime_id);
+ deleted++;
+ }
+ return deleted;
+ }
+
+#endif
+
+
+
+
+
+/******************************************************************/
+/******************** ADDITION FUNCTIONS **************************/
+/******************************************************************/
+
+/* adds a host downtime entry to the list in memory */
+int add_host_downtime(char *host_name, time_t entry_time, char *author, char *comment_data, time_t start_time, time_t flex_downtime_start, time_t end_time, int fixed, unsigned long triggered_by, unsigned long duration, unsigned long downtime_id, int is_in_effect, int start_notification_sent) {
+ int result = OK;
+
+ result = add_downtime(HOST_DOWNTIME, host_name, NULL, entry_time, author, comment_data, start_time, flex_downtime_start, end_time, fixed, triggered_by, duration, downtime_id, is_in_effect, start_notification_sent);
+
+ return result;
+ }
+
+
+/* adds a service downtime entry to the list in memory */
+int add_service_downtime(char *host_name, char *svc_description, time_t entry_time, char *author, char *comment_data, time_t start_time, time_t flex_downtime_start, time_t end_time, int fixed, unsigned long triggered_by, unsigned long duration, unsigned long downtime_id, int is_in_effect, int start_notification_sent) {
+ int result = OK;
+
+ result = add_downtime(SERVICE_DOWNTIME, host_name, svc_description, entry_time, author, comment_data, start_time, flex_downtime_start, end_time, fixed, triggered_by, duration, downtime_id, is_in_effect, start_notification_sent);
+
+ return result;
+ }
+
+
+/* adds a host or service downtime entry to the list in memory */
+int add_downtime(int downtime_type, char *host_name, char *svc_description, time_t entry_time, char *author, char *comment_data, time_t start_time, time_t flex_downtime_start, time_t end_time, int fixed, unsigned long triggered_by, unsigned long duration, unsigned long downtime_id, int is_in_effect, int start_notification_sent) {
+ scheduled_downtime *new_downtime = NULL;
+ scheduled_downtime *last_downtime = NULL;
+ scheduled_downtime *temp_downtime = NULL;
+ int result = OK;
+
+ log_debug_info(DEBUGL_FUNCTIONS, 0, "add_downtime()\n");
+
+ /* don't add triggered downtimes that don't have a valid parent */
+ if(triggered_by > 0 && find_downtime(ANY_DOWNTIME, triggered_by) == NULL) {
+ log_debug_info(DEBUGL_DOWNTIME, 1,
+ "Downtime is triggered, but has no valid parent\n");
+ return ERROR;
+ }
+
+ /* we don't have enough info */
+ if(host_name == NULL || (downtime_type == SERVICE_DOWNTIME && svc_description == NULL)) {
+ log_debug_info(DEBUGL_DOWNTIME, 1,
+ "Host name (%s) or service description (%s) is null\n",
+ ((NULL == host_name) ? "null" : host_name),
+ ((NULL == svc_description) ? "null" : svc_description));
+ return ERROR;
+ }
+
+ /* allocate memory for the downtime */
+ if((new_downtime = (scheduled_downtime *)calloc(1, sizeof(scheduled_downtime))) == NULL)
+ return ERROR;
+
+ /* duplicate vars */
+ if((new_downtime->host_name = (char *)strdup(host_name)) == NULL) {
+ log_debug_info(DEBUGL_DOWNTIME, 1,
+ "Unable to allocate memory for new downtime's host name\n");
+ result = ERROR;
+ }
+ if(downtime_type == SERVICE_DOWNTIME) {
+ if((new_downtime->service_description = (char *)strdup(svc_description)) == NULL) {
+ log_debug_info(DEBUGL_DOWNTIME, 1,
+ "Unable to allocate memory for new downtime's service description\n");
+ result = ERROR;
+ }
+ }
+ if(author) {
+ if((new_downtime->author = (char *)strdup(author)) == NULL) {
+ log_debug_info(DEBUGL_DOWNTIME, 1,
+ "Unable to allocate memory for new downtime's author\n");
+ result = ERROR;
+ }
+ }
+ if(comment_data) {
+ if((new_downtime->comment = (char *)strdup(comment_data)) == NULL)
+ result = ERROR;
+ }
+
+ /* handle errors */
+ if(result == ERROR) {
+ my_free(new_downtime->comment);
+ my_free(new_downtime->author);
+ my_free(new_downtime->service_description);
+ my_free(new_downtime->host_name);
+ my_free(new_downtime);
+ return ERROR;
+ }
+
+ new_downtime->type = downtime_type;
+ new_downtime->entry_time = entry_time;
+ new_downtime->start_time = start_time;
+ new_downtime->flex_downtime_start = flex_downtime_start;
+ new_downtime->end_time = end_time;
+ new_downtime->fixed = (fixed > 0) ? TRUE : FALSE;
+ new_downtime->triggered_by = triggered_by;
+ new_downtime->duration = duration;
+ new_downtime->downtime_id = downtime_id;
+ new_downtime->is_in_effect = is_in_effect;
+ new_downtime->start_notification_sent = start_notification_sent;
+
+ if(defer_downtime_sorting) {
+ new_downtime->next = scheduled_downtime_list;
+ scheduled_downtime_list = new_downtime;
+ }
+ else {
+ /*
+ * add new downtime to downtime list, sorted by start time,
+ * but lock the lists first so broker modules fiddling
+ * with them at the same time doesn't crash out.
+ */
+#ifdef NSCORE
+ pthread_mutex_lock(&nagios_downtime_lock);
+#endif
+ last_downtime = scheduled_downtime_list;
+ for(temp_downtime = scheduled_downtime_list; temp_downtime != NULL; temp_downtime = temp_downtime->next) {
+ if(new_downtime->start_time < temp_downtime->start_time) {
+ new_downtime->next = temp_downtime;
+ if(temp_downtime == scheduled_downtime_list)
+ scheduled_downtime_list = new_downtime;
+ else
+ last_downtime->next = new_downtime;
+ break;
+ }
+ else
+ last_downtime = temp_downtime;
+ }
+ if(scheduled_downtime_list == NULL) {
+ new_downtime->next = NULL;
+ scheduled_downtime_list = new_downtime;
+ }
+ else if(temp_downtime == NULL) {
+ new_downtime->next = NULL;
+ last_downtime->next = new_downtime;
+ }
+#ifdef NSCORE
+ pthread_mutex_unlock(&nagios_downtime_lock);
+#endif
+ }
+#ifdef NSCORE
+#ifdef USE_EVENT_BROKER
+ /* send data to event broker */
+ broker_downtime_data(NEBTYPE_DOWNTIME_LOAD, NEBFLAG_NONE, NEBATTR_NONE, downtime_type, host_name, svc_description, entry_time, author, comment_data, start_time, end_time, fixed, triggered_by, duration, downtime_id, NULL);
+#endif
+#endif
+
+ return OK;
+ }
+
+static int downtime_compar(const void *p1, const void *p2) {
+ scheduled_downtime *d1 = *(scheduled_downtime **)p1;
+ scheduled_downtime *d2 = *(scheduled_downtime **)p2;
+
+ /*
+ If the start times of two downtimes are equal and one is triggered but
+ but the other is not, the triggered downtime should be later in the
+ list than the untriggered one. This is so they are written to the
+ retention.dat and status.dat in the correct order.
+
+ Previously the triggered downtime always appeared before its
+ triggering downtime in those files. When the downtimes were read
+ from those files, either on a core restart or by the CGIs, the
+ triggered downtime would be discarded because the triggering
+ downtime did not yet exist.
+
+ The most common case for this is when a downtime is created and
+ the option is selected to create triggered downtimes on all child
+ objects. This change in the sort order does NOT resolve the
+ case where a manually created, triggered downtime is created with
+ a start time earlier than the triggering downtime.
+
+ This would need to be resolved by comparing the triggered_by value
+ with the downtime ID regardless of the start time. However, this
+ should be a relatively rare case and only caused by intentional
+ scheduling by a human. This change was not implemented because it
+ would cause the downtime list to be out of time order and the
+ implications of this were not well understood.
+ */
+
+ if(d1->start_time == d2->start_time) {
+ if(( d1->triggered_by == 0 && d2->triggered_by != 0) ||
+ ( d1->triggered_by != 0 && d2->triggered_by == 0)) {
+ return d1->triggered_by == 0 ? -1 : 1;
+ }
+ }
+ return (d1->start_time < d2->start_time) ? -1 : (d1->start_time - d2->start_time);
+ }
+
+int sort_downtime(void) {
+ scheduled_downtime **array, *temp_downtime;
+ unsigned long i = 0, unsorted_downtimes = 0;
+
+ log_debug_info(DEBUGL_FUNCTIONS, 0, "sort_downtime()\n");
+
+ if(!defer_downtime_sorting)
+ return OK;
+ defer_downtime_sorting = 0;
+
+ temp_downtime = scheduled_downtime_list;
+ while(temp_downtime != NULL) {
+ temp_downtime = temp_downtime->next;
+ unsorted_downtimes++;
+ }
+
+ if(!unsorted_downtimes)
+ return OK;
+
+ if(!(array = malloc(sizeof(*array) * unsorted_downtimes)))
+ return ERROR;
+ while(scheduled_downtime_list) {
+ array[i++] = scheduled_downtime_list;
+ scheduled_downtime_list = scheduled_downtime_list->next;
+ }
+
+ qsort((void *)array, i, sizeof(*array), downtime_compar);
+ scheduled_downtime_list = temp_downtime = array[0];
+ for(i = 1; i < unsorted_downtimes; i++) {
+ temp_downtime->next = array[i];
+ temp_downtime = temp_downtime->next;
+ }
+ temp_downtime->next = NULL;
+ my_free(array);
+ return OK;
+ }
+
+
+
+/******************************************************************/
+/************************ SEARCH FUNCTIONS ************************/
+/******************************************************************/
+
+/* finds a specific downtime entry */
+scheduled_downtime *find_downtime(int type, unsigned long downtime_id) {
+ scheduled_downtime *temp_downtime = NULL;
+
+ log_debug_info(DEBUGL_FUNCTIONS, 0, "find_downtime()\n");
+
+ for(temp_downtime = scheduled_downtime_list; temp_downtime != NULL; temp_downtime = temp_downtime->next) {
+ log_debug_info(DEBUGL_DOWNTIME, 2, "find_downtime() looking at type %d, id: %lu\n", type, downtime_id);
+
+ if(type != ANY_DOWNTIME && temp_downtime->type != type)
+ continue;
+ if(temp_downtime->downtime_id == downtime_id)
+ return temp_downtime;
+ }
+
+ return NULL;
+ }
+
+
+/* finds a specific host downtime entry */
+scheduled_downtime *find_host_downtime(unsigned long downtime_id) {
+
+ return find_downtime(HOST_DOWNTIME, downtime_id);
+ }
+
+
+/* finds a specific service downtime entry */
+scheduled_downtime *find_service_downtime(unsigned long downtime_id) {
+
+ return find_downtime(SERVICE_DOWNTIME, downtime_id);
+ }
+
+
+
+/******************************************************************/
+/********************* CLEANUP FUNCTIONS **************************/
+/******************************************************************/
+
+/* frees memory allocated for the scheduled downtime data */
+void free_downtime_data(void) {
+ scheduled_downtime *this_downtime = NULL;
+ scheduled_downtime *next_downtime = NULL;
+
+ /* free memory for the scheduled_downtime list */
+ for(this_downtime = scheduled_downtime_list; this_downtime != NULL; this_downtime = next_downtime) {
+ next_downtime = this_downtime->next;
+ my_free(this_downtime->host_name);
+ my_free(this_downtime->service_description);
+ my_free(this_downtime->author);
+ my_free(this_downtime->comment);
+ my_free(this_downtime);
+ }
+
+ /* reset list pointer */
+ scheduled_downtime_list = NULL;
+
+ return;
+ }
+
+
diff --git a/common/macros.c b/common/macros.c
new file mode 100644
index 0000000..815b2b3
--- /dev/null
+++ b/common/macros.c
@@ -0,0 +1,3356 @@
+/*****************************************************************************
+ *
+ * MACROS.C - Common macro functions for Nagios
+ *
+ * Copyright (c) 1999-2010 Ethan Galstad (egalstad@nagios.org)
+ * Last Modified: 08-06-2010
+ *
+ * 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.
+ *
+ *****************************************************************************/
+
+#include "../include/macros.h"
+#include "../include/config.h"
+#include "../include/common.h"
+#include "../include/objects.h"
+#include "../include/statusdata.h"
+#include "../include/comments.h"
+#ifdef NSCORE
+#include "../include/nagios.h"
+#else
+#include "../include/cgiutils.h"
+#endif
+
+#ifdef NSCORE
+extern int use_large_installation_tweaks;
+extern int enable_environment_macros;
+#endif
+
+extern char *illegal_output_chars;
+
+extern contact *contact_list;
+extern contactgroup *contactgroup_list;
+extern host *host_list;
+extern hostgroup *hostgroup_list;
+extern service *service_list;
+extern servicegroup *servicegroup_list;
+extern command *command_list;
+extern timeperiod *timeperiod_list;
+
+char *macro_x_names[MACRO_X_COUNT]; /* the macro names */
+char *macro_user[MAX_USER_MACROS]; /* $USERx$ macros */
+
+struct macro_key_code {
+ char *name; /* macro key name */
+ int code; /* numeric macro code, usable in case statements */
+ int clean_options;
+ char *value;
+ };
+
+struct macro_key_code macro_keys[MACRO_X_COUNT];
+
+/*
+ * These point to their corresponding pointer arrays in global_macros
+ * AFTER macros have been initialized.
+ *
+ * They really only exist so that eventbroker modules that reference
+ * them won't need to be re-compiled, although modules that rely
+ * on their values after having run a certain command will require an
+ * update
+ */
+char **macro_x = NULL;
+
+/*
+ * scoped to this file to prevent (unintentional) mischief,
+ * but see base/notifications.c for how to use it
+ */
+static nagios_macros global_macros;
+
+
+nagios_macros *get_global_macros(void) {
+ return &global_macros;
+ }
+
+/******************************************************************/
+/************************ MACRO FUNCTIONS *************************/
+/******************************************************************/
+
+/*
+ * locate a macro key based on its name by using a binary search
+ * over all keys. O(log(n)) complexity and a vast improvement over
+ * the previous linear scan
+ */
+const struct macro_key_code *find_macro_key(const char *name) {
+ unsigned int high, low = 0;
+ int value;
+ struct macro_key_code *key;
+
+ high = MACRO_X_COUNT;
+ while(high - low > 0) {
+ unsigned int mid = low + ((high - low) / 2);
+ key = ¯o_keys[mid];
+ value = strcmp(name, key->name);
+ if(value == 0) {
+ return key;
+ }
+ if(value > 0)
+ low = mid + 1;
+ else
+ high = mid;
+ }
+ return NULL;
+ }
+
+
+/*
+ * replace macros in notification commands with their values,
+ * the thread-safe version
+ */
+int process_macros_r(nagios_macros *mac, char *input_buffer, char **output_buffer, int options) {
+ char *temp_buffer = NULL;
+ char *save_buffer = NULL;
+ char *buf_ptr = NULL;
+ char *delim_ptr = NULL;
+ int in_macro = FALSE;
+ int x = 0;
+ char *selected_macro = NULL;
+ char *original_macro = NULL;
+ char *cleaned_macro = NULL;
+ int clean_macro = FALSE;
+ int found_macro_x = FALSE;
+ int result = OK;
+ int clean_options = 0;
+ int free_macro = FALSE;
+ int macro_options = 0;
+
+ log_debug_info(DEBUGL_FUNCTIONS, 0, "process_macros_r()\n");
+
+ if(output_buffer == NULL)
+ return ERROR;
+
+ *output_buffer = (char *)strdup("");
+
+ if(input_buffer == NULL)
+ return ERROR;
+
+ in_macro = FALSE;
+
+ log_debug_info(DEBUGL_MACROS, 1, "**** BEGIN MACRO PROCESSING ***********\n");
+ log_debug_info(DEBUGL_MACROS, 1, "Processing: '%s'\n", input_buffer);
+
+ /* use a duplicate of original buffer, so we don't modify the original */
+ save_buffer = buf_ptr = (input_buffer ? strdup(input_buffer) : NULL);
+
+ while(buf_ptr) {
+
+ /* save pointer to this working part of buffer */
+ temp_buffer = buf_ptr;
+
+ /* find the next delimiter - terminate preceding string and advance buffer pointer for next run */
+ if((delim_ptr = strchr(buf_ptr, '$'))) {
+ delim_ptr[0] = '\x0';
+ buf_ptr = (char *)delim_ptr + 1;
+ }
+ /* no delimiter found - we already have the last of the buffer */
+ else
+ buf_ptr = NULL;
+
+ log_debug_info(DEBUGL_MACROS, 2, " Processing part: '%s'\n", temp_buffer);
+
+ selected_macro = NULL;
+ found_macro_x = FALSE;
+ clean_macro = FALSE;
+
+ /* we're in plain text... */
+ if(in_macro == FALSE) {
+
+ /* add the plain text to the end of the already processed buffer */
+ *output_buffer = (char *)realloc(*output_buffer, strlen(*output_buffer) + strlen(temp_buffer) + 1);
+ strcat(*output_buffer, temp_buffer);
+
+ log_debug_info(DEBUGL_MACROS, 2, " Not currently in macro. Running output (%lu): '%s'\n", (unsigned long)strlen(*output_buffer), *output_buffer);
+ in_macro = TRUE;
+ }
+
+ /* looks like we're in a macro, so process it... */
+ else {
+
+ /* reset clean options */
+ clean_options = 0;
+
+ /* grab the macro value */
+ result = grab_macro_value_r(mac, temp_buffer, &selected_macro, &clean_options, &free_macro);
+ log_debug_info(DEBUGL_MACROS, 2, " Processed '%s', Clean Options: %d, Free: %d\n", temp_buffer, clean_options, free_macro);
+
+ /* an error occurred - we couldn't parse the macro, so continue on */
+ if(result == ERROR) {
+ log_debug_info(DEBUGL_MACROS, 0, " WARNING: An error occurred processing macro '%s'!\n", temp_buffer);
+ if(free_macro == TRUE)
+ my_free(selected_macro);
+ }
+
+ /* we already have a macro... */
+ if(result == OK)
+ x = 0;
+
+ /* an escaped $ is done by specifying two $$ next to each other */
+ else if(!strcmp(temp_buffer, "")) {
+ log_debug_info(DEBUGL_MACROS, 2, " Escaped $. Running output (%lu): '%s'\n", (unsigned long)strlen(*output_buffer), *output_buffer);
+ *output_buffer = (char *)realloc(*output_buffer, strlen(*output_buffer) + 2);
+ strcat(*output_buffer, "$");
+ }
+
+ /* a non-macro, just some user-defined string between two $s */
+ else {
+ log_debug_info(DEBUGL_MACROS, 2, " Non-macro. Running output (%lu): '%s'\n", (unsigned long)strlen(*output_buffer), *output_buffer);
+
+ /* add the plain text to the end of the already processed buffer */
+ *output_buffer = (char *)realloc(*output_buffer, strlen(*output_buffer) + strlen(temp_buffer) + 3);
+ strcat(*output_buffer, "$");
+ strcat(*output_buffer, temp_buffer);
+ strcat(*output_buffer, "$");
+ }
+
+ /* insert macro */
+ if(selected_macro != NULL) {
+ log_debug_info(DEBUGL_MACROS, 2, " Processed '%s', Clean Options: %d, Free: %d\n", temp_buffer, clean_options, free_macro);
+
+ /* include any cleaning options passed back to us */
+ macro_options = (options | clean_options);
+
+ log_debug_info(DEBUGL_MACROS, 2, " Cleaning options: global=%d, local=%d, effective=%d\n", options, clean_options, macro_options);
+
+ /* URL encode the macro if requested - this allocates new memory */
+ if(macro_options & URL_ENCODE_MACRO_CHARS) {
+ original_macro = selected_macro;
+ selected_macro = get_url_encoded_string(selected_macro);
+ if(free_macro == TRUE) {
+ my_free(original_macro);
+ }
+ free_macro = TRUE;
+ }
+
+ /* some macros are cleaned... */
+ if(clean_macro == TRUE || ((macro_options & STRIP_ILLEGAL_MACRO_CHARS) || (macro_options & ESCAPE_MACRO_CHARS))) {
+
+ /* add the (cleaned) processed macro to the end of the already processed buffer */
+ if(selected_macro != NULL && (cleaned_macro = clean_macro_chars(selected_macro, macro_options)) != NULL) {
+ *output_buffer = (char *)realloc(*output_buffer, strlen(*output_buffer) + strlen(cleaned_macro) + 1);
+ strcat(*output_buffer, cleaned_macro);
+
+ log_debug_info(DEBUGL_MACROS, 2, " Cleaned macro. Running output (%lu): '%s'\n", (unsigned long)strlen(*output_buffer), *output_buffer);
+ }
+ }
+
+ /* others are not cleaned */
+ else {
+ /* add the processed macro to the end of the already processed buffer */
+ if(selected_macro != NULL) {
+ *output_buffer = (char *)realloc(*output_buffer, strlen(*output_buffer) + strlen(selected_macro) + 1);
+ strcat(*output_buffer, selected_macro);
+
+ log_debug_info(DEBUGL_MACROS, 2, " Uncleaned macro. Running output (%lu): '%s'\n", (unsigned long)strlen(*output_buffer), *output_buffer);
+ }
+ }
+
+ /* free memory if necessary (if we URL encoded the macro or we were told to do so by grab_macro_value()) */
+ if(free_macro == TRUE)
+ my_free(selected_macro);
+
+ log_debug_info(DEBUGL_MACROS, 2, " Just finished macro. Running output (%lu): '%s'\n", (unsigned long)strlen(*output_buffer), *output_buffer);
+ }
+
+ in_macro = FALSE;
+ }
+ }
+
+ /* free copy of input buffer */
+ my_free(save_buffer);
+
+ log_debug_info(DEBUGL_MACROS, 1, " Done. Final output: '%s'\n", *output_buffer);
+ log_debug_info(DEBUGL_MACROS, 1, "**** END MACRO PROCESSING *************\n");
+
+ return OK;
+ }
+
+int process_macros(char *input_buffer, char **output_buffer, int options) {
+ return process_macros_r(&global_macros, input_buffer, output_buffer, options);
+ }
+
+/******************************************************************/
+/********************** MACRO GRAB FUNCTIONS **********************/
+/******************************************************************/
+
+/* grab macros that are specific to a particular host */
+int grab_host_macros_r(nagios_macros *mac, host *hst) {
+ /* clear host-related macros */
+ clear_host_macros_r(mac);
+ clear_hostgroup_macros_r(mac);
+
+ /* save pointer to host */
+ mac->host_ptr = hst;
+ mac->hostgroup_ptr = NULL;
+
+ if(hst == NULL)
+ return ERROR;
+
+#ifdef NSCORE
+ /* save pointer to host's first/primary hostgroup */
+ if(hst->hostgroups_ptr)
+ mac->hostgroup_ptr = (hostgroup *)hst->hostgroups_ptr->object_ptr;
+#endif
+
+ return OK;
+ }
+
+int grab_host_macros(host *hst) {
+ return grab_host_macros_r(&global_macros, hst);
+ }
+
+
+/* grab hostgroup macros */
+int grab_hostgroup_macros_r(nagios_macros *mac, hostgroup *hg) {
+ /* clear hostgroup macros */
+ clear_hostgroup_macros_r(mac);
+
+ /* save the hostgroup pointer for later */
+ mac->hostgroup_ptr = hg;
+
+ if(hg == NULL)
+ return ERROR;
+
+ return OK;
+ }
+
+int grab_hostgroup_macros(hostgroup *hg) {
+ return grab_hostgroup_macros_r(&global_macros, hg);
+ }
+
+
+/* grab macros that are specific to a particular service */
+int grab_service_macros_r(nagios_macros *mac, service *svc) {
+
+ /* clear service-related macros */
+ clear_service_macros_r(mac);
+ clear_servicegroup_macros_r(mac);
+
+ /* save pointer for later */
+ mac->service_ptr = svc;
+ mac->servicegroup_ptr = NULL;
+
+ if(svc == NULL)
+ return ERROR;
+
+#ifdef NSCORE
+ /* save first/primary servicegroup pointer for later */
+ if(svc->servicegroups_ptr)
+ mac->servicegroup_ptr = (servicegroup *)svc->servicegroups_ptr->object_ptr;
+#endif
+
+ return OK;
+ }
+
+int grab_service_macros(service *svc) {
+ return grab_service_macros_r(&global_macros, svc);
+ }
+
+
+/* grab macros that are specific to a particular servicegroup */
+int grab_servicegroup_macros_r(nagios_macros *mac, servicegroup *sg) {
+ /* clear servicegroup macros */
+ clear_servicegroup_macros_r(mac);
+
+ /* save the pointer for later */
+ mac->servicegroup_ptr = sg;
+
+ if(sg == NULL)
+ return ERROR;
+
+ return OK;
+ }
+
+int grab_servicegroup_macros(servicegroup *sg) {
+ return grab_servicegroup_macros_r(&global_macros, sg);
+ }
+
+
+/* grab macros that are specific to a particular contact */
+int grab_contact_macros_r(nagios_macros *mac, contact *cntct) {
+ /* clear contact-related macros */
+ clear_contact_macros_r(mac);
+ clear_contactgroup_macros_r(mac);
+
+ /* save pointer to contact for later */
+ mac->contact_ptr = cntct;
+ mac->contactgroup_ptr = NULL;
+
+ if(cntct == NULL)
+ return ERROR;
+
+#ifdef NSCORE
+ /* save pointer to first/primary contactgroup for later */
+ if(cntct->contactgroups_ptr)
+ mac->contactgroup_ptr = (contactgroup *)cntct->contactgroups_ptr->object_ptr;
+#endif
+
+ return OK;
+ }
+
+int grab_contact_macros(contact *cntct) {
+ return grab_contact_macros_r(&global_macros, cntct);
+ }
+
+
+/******************************************************************/
+/******************* MACRO GENERATION FUNCTIONS *******************/
+/******************************************************************/
+
+/* this is the big one */
+int grab_macro_value_r(nagios_macros *mac, char *macro_buffer, char **output, int *clean_options, int *free_macro) {
+ char *buf = NULL;
+ char *ptr = NULL;
+ char *macro_name = NULL;
+ char *arg[2] = {NULL, NULL};
+ contact *temp_contact = NULL;
+ contactgroup *temp_contactgroup = NULL;
+ contactsmember *temp_contactsmember = NULL;
+ char *temp_buffer = NULL;
+ int delimiter_len = 0;
+ int x, result = OK;
+ const struct macro_key_code *mkey;
+
+ /* for the early cases, this is the default */
+ *free_macro = FALSE;
+
+ if(output == NULL)
+ return ERROR;
+
+ /* clear the old macro value */
+ my_free(*output);
+
+ if(macro_buffer == NULL || clean_options == NULL || free_macro == NULL)
+ return ERROR;
+
+
+ /*
+ * We handle argv and user macros first, since those are by far
+ * the most commonly accessed ones (3.4 and 1.005 per check,
+ * respectively). Since neither of them requires that we copy
+ * the original buffer, we can also get away with some less
+ * code for these simple cases.
+ */
+ if(strstr(macro_buffer, "ARG") == macro_buffer) {
+
+ /* which arg do we want? */
+ x = atoi(macro_buffer + 3);
+
+ if(x <= 0 || x > MAX_COMMAND_ARGUMENTS) {
+ return ERROR;
+ }
+
+ /* use a pre-computed macro value */
+ *output = mac->argv[x - 1];
+ return OK;
+ }
+
+ if(strstr(macro_buffer, "USER") == macro_buffer) {
+
+ /* which macro do we want? */
+ x = atoi(macro_buffer + 4);
+
+ if(x <= 0 || x > MAX_USER_MACROS) {
+ return ERROR;
+ }
+
+ /* use a pre-computed macro value */
+ *output = macro_user[x - 1];
+ return OK;
+ }
+
+ /* most frequently used "x" macro gets a shortcut */
+ if(mac->host_ptr && !strcmp(macro_buffer, "HOSTADDRESS")) {
+ if(mac->host_ptr->address)
+ *output = mac->host_ptr->address;
+ return OK;
+ }
+
+ /* work with a copy of the original buffer */
+ if((buf = (char *)strdup(macro_buffer)) == NULL)
+ return ERROR;
+
+ /* BY DEFAULT, TELL CALLER TO FREE MACRO BUFFER WHEN DONE */
+ *free_macro = TRUE;
+
+ /* macro name is at start of buffer */
+ macro_name = buf;
+
+ /* see if there's an argument - if so, this is most likely an on-demand macro */
+ if((ptr = strchr(buf, ':'))) {
+
+ ptr[0] = '\x0';
+ ptr++;
+
+ /* save the first argument - host name, hostgroup name, etc. */
+ arg[0] = ptr;
+
+ /* try and find a second argument */
+ if((ptr = strchr(ptr, ':'))) {
+
+ ptr[0] = '\x0';
+ ptr++;
+
+ /* save second argument - service description or delimiter */
+ arg[1] = ptr;
+ }
+ }
+
+ if((mkey = find_macro_key(macro_name))) {
+ log_debug_info(DEBUGL_MACROS, 2, " macros[%d] (%s) match.\n", mkey->code, macro_x_names[mkey->code]);
+ if(mkey->clean_options) {
+ *clean_options |= mkey->clean_options;
+ log_debug_info(DEBUGL_MACROS, 2, " New clean options: %d\n", *clean_options);
+ }
+
+ /* get the macro value */
+ result = grab_macrox_value_r(mac, mkey->code, arg[0], arg[1], output, free_macro);
+ }
+ /***** CONTACT ADDRESS MACROS *****/
+ /* NOTE: the code below should be broken out into a separate function */
+ else if(strstr(macro_name, "CONTACTADDRESS") == macro_name) {
+
+ /* which address do we want? */
+ x = atoi(macro_name + 14) - 1;
+
+ /* regular macro */
+ if(arg[0] == NULL) {
+
+ /* use the saved pointer */
+ if((temp_contact = mac->contact_ptr) == NULL) {
+ my_free(buf);
+ return ERROR;
+ }
+
+ /* get the macro value by reference, so no need to free() */
+ *free_macro = FALSE;
+ result = grab_contact_address_macro(x, temp_contact, output);
+ }
+
+ /* on-demand macro */
+ else {
+
+ /* on-demand contact macro with a contactgroup and a delimiter */
+ if(arg[1] != NULL) {
+
+ if((temp_contactgroup = find_contactgroup(arg[0])) == NULL)
+ return ERROR;
+
+ delimiter_len = strlen(arg[1]);
+
+ /* concatenate macro values for all contactgroup members */
+ for(temp_contactsmember = temp_contactgroup->members; temp_contactsmember != NULL; temp_contactsmember = temp_contactsmember->next) {
+
+#ifdef NSCORE
+ if((temp_contact = temp_contactsmember->contact_ptr) == NULL)
+ continue;
+ if((temp_contact = find_contact(temp_contactsmember->contact_name)) == NULL)
+ continue;
+#endif
+
+ /* get the macro value for this contact */
+ grab_contact_address_macro(x, temp_contact, &temp_buffer);
+
+ if(temp_buffer == NULL)
+ continue;
+
+ /* add macro value to already running macro */
+ if(*output == NULL)
+ *output = (char *)strdup(temp_buffer);
+ else {
+ if((*output = (char *)realloc(*output, strlen(*output) + strlen(temp_buffer) + delimiter_len + 1)) == NULL)
+ continue;
+ strcat(*output, arg[1]);
+ strcat(*output, temp_buffer);
+ }
+ my_free(temp_buffer);
+ }
+ }
+
+ /* else on-demand contact macro */
+ else {
+
+ /* find the contact */
+ if((temp_contact = find_contact(arg[0])) == NULL) {
+ my_free(buf);
+ return ERROR;
+ }
+
+ /* get the macro value */
+ result = grab_contact_address_macro(x, temp_contact, output);
+ }
+ }
+ }
+
+ /***** CUSTOM VARIABLE MACROS *****/
+ else if(macro_name[0] == '_') {
+
+ /* get the macro value */
+ result = grab_custom_macro_value_r(mac, macro_name, arg[0], arg[1], output);
+ }
+
+ /* no macro matched... */
+ else {
+ log_debug_info(DEBUGL_MACROS, 0, " WARNING: Could not find a macro matching '%s'!\n", macro_name);
+ result = ERROR;
+ }
+
+ /* free memory */
+ my_free(buf);
+
+ return result;
+ }
+
+int grab_macro_value(char *macro_buffer, char **output, int *clean_options, int *free_macro) {
+ return grab_macro_value_r(&global_macros, macro_buffer, output, clean_options, free_macro);
+ }
+
+
+int grab_macrox_value_r(nagios_macros *mac, int macro_type, char *arg1, char *arg2, char **output, int *free_macro) {
+ host *temp_host = NULL;
+ hostgroup *temp_hostgroup = NULL;
+ hostsmember *temp_hostsmember = NULL;
+ service *temp_service = NULL;
+ servicegroup *temp_servicegroup = NULL;
+ servicesmember *temp_servicesmember = NULL;
+ contact *temp_contact = NULL;
+ contactgroup *temp_contactgroup = NULL;
+ contactsmember *temp_contactsmember = NULL;
+ char *temp_buffer = NULL;
+ int result = OK;
+ int delimiter_len = 0;
+ int free_sub_macro = FALSE;
+#ifdef NSCORE
+ register int x;
+ int authorized = TRUE;
+ int problem = TRUE;
+ int hosts_up = 0;
+ int hosts_down = 0;
+ int hosts_unreachable = 0;
+ int hosts_down_unhandled = 0;
+ int hosts_unreachable_unhandled = 0;
+ int host_problems = 0;
+ int host_problems_unhandled = 0;
+ int services_ok = 0;
+ int services_warning = 0;
+ int services_unknown = 0;
+ int services_critical = 0;
+ int services_warning_unhandled = 0;
+ int services_unknown_unhandled = 0;
+ int services_critical_unhandled = 0;
+ int service_problems = 0;
+ int service_problems_unhandled = 0;
+#endif
+
+
+ if(output == NULL || free_macro == NULL)
+ return ERROR;
+
+ /* BY DEFAULT, TELL CALLER TO FREE MACRO BUFFER WHEN DONE */
+ *free_macro = TRUE;
+
+ /* handle the macro */
+ switch(macro_type) {
+
+ /***************/
+ /* HOST MACROS */
+ /***************/
+ case MACRO_HOSTNAME:
+ case MACRO_HOSTALIAS:
+ case MACRO_HOSTADDRESS:
+ case MACRO_LASTHOSTCHECK:
+ case MACRO_LASTHOSTSTATECHANGE:
+ case MACRO_HOSTOUTPUT:
+ case MACRO_HOSTPERFDATA:
+ case MACRO_HOSTSTATE:
+ case MACRO_HOSTSTATEID:
+ case MACRO_HOSTATTEMPT:
+ case MACRO_HOSTEXECUTIONTIME:
+ case MACRO_HOSTLATENCY:
+ case MACRO_HOSTDURATION:
+ case MACRO_HOSTDURATIONSEC:
+ case MACRO_HOSTDOWNTIME:
+ case MACRO_HOSTSTATETYPE:
+ case MACRO_HOSTPERCENTCHANGE:
+ case MACRO_HOSTACKAUTHOR:
+ case MACRO_HOSTACKCOMMENT:
+ case MACRO_LASTHOSTUP:
+ case MACRO_LASTHOSTDOWN:
+ case MACRO_LASTHOSTUNREACHABLE:
+ case MACRO_HOSTCHECKCOMMAND:
+ case MACRO_HOSTDISPLAYNAME:
+ case MACRO_HOSTACTIONURL:
+ case MACRO_HOSTNOTESURL:
+ case MACRO_HOSTNOTES:
+ case MACRO_HOSTCHECKTYPE:
+ case MACRO_LONGHOSTOUTPUT:
+ case MACRO_HOSTNOTIFICATIONNUMBER:
+ case MACRO_HOSTNOTIFICATIONID:
+ case MACRO_HOSTEVENTID:
+ case MACRO_LASTHOSTEVENTID:
+ case MACRO_HOSTGROUPNAMES:
+ case MACRO_HOSTACKAUTHORNAME:
+ case MACRO_HOSTACKAUTHORALIAS:
+ case MACRO_MAXHOSTATTEMPTS:
+ case MACRO_TOTALHOSTSERVICES:
+ case MACRO_TOTALHOSTSERVICESOK:
+ case MACRO_TOTALHOSTSERVICESWARNING:
+ case MACRO_TOTALHOSTSERVICESUNKNOWN:
+ case MACRO_TOTALHOSTSERVICESCRITICAL:
+ case MACRO_HOSTPROBLEMID:
+ case MACRO_LASTHOSTPROBLEMID:
+ case MACRO_LASTHOSTSTATE:
+ case MACRO_LASTHOSTSTATEID:
+
+ /* a standard host macro */
+ if(arg2 == NULL) {
+
+ /* find the host for on-demand macros */
+ if(arg1) {
+ if((temp_host = find_host(arg1)) == NULL)
+ return ERROR;
+ }
+
+ /* else use saved host pointer */
+ else if((temp_host = mac->host_ptr) == NULL)
+ return ERROR;
+
+ /* get the host macro value */
+ result = grab_standard_host_macro_r(mac, macro_type, temp_host, output, free_macro);
+ }
+
+ /* a host macro with a hostgroup name and delimiter */
+ else {
+
+ if((temp_hostgroup = find_hostgroup(arg1)) == NULL)
+ return ERROR;
+
+ delimiter_len = strlen(arg2);
+
+ /* concatenate macro values for all hostgroup members */
+ for(temp_hostsmember = temp_hostgroup->members; temp_hostsmember != NULL; temp_hostsmember = temp_hostsmember->next) {
+
+#ifdef NSCORE
+ if((temp_host = temp_hostsmember->host_ptr) == NULL)
+ continue;
+#else
+ if((temp_host = find_host(temp_hostsmember->host_name)) == NULL)
+ continue;
+#endif
+
+ /* get the macro value for this host */
+ grab_standard_host_macro_r(mac, macro_type, temp_host, &temp_buffer, &free_sub_macro);
+
+ if(temp_buffer == NULL)
+ continue;
+
+ /* add macro value to already running macro */
+ if(*output == NULL)
+ *output = (char *)strdup(temp_buffer);
+ else {
+ if((*output = (char *)realloc(*output, strlen(*output) + strlen(temp_buffer) + delimiter_len + 1)) == NULL)
+ continue;
+ strcat(*output, arg2);
+ strcat(*output, temp_buffer);
+ }
+ if(free_sub_macro == TRUE)
+ my_free(temp_buffer);
+ }
+ }
+ break;
+
+ /********************/
+ /* HOSTGROUP MACROS */
+ /********************/
+ case MACRO_HOSTGROUPNAME:
+ case MACRO_HOSTGROUPALIAS:
+ case MACRO_HOSTGROUPNOTES:
+ case MACRO_HOSTGROUPNOTESURL:
+ case MACRO_HOSTGROUPACTIONURL:
+ case MACRO_HOSTGROUPMEMBERS:
+
+ /* a standard hostgroup macro */
+ /* use the saved hostgroup pointer */
+ if(arg1 == NULL) {
+ if((temp_hostgroup = mac->hostgroup_ptr) == NULL)
+ return ERROR;
+ }
+
+ /* else find the hostgroup for on-demand macros */
+ else {
+ if((temp_hostgroup = find_hostgroup(arg1)) == NULL)
+ return ERROR;
+ }
+
+ /* get the hostgroup macro value */
+ result = grab_standard_hostgroup_macro_r(mac, macro_type, temp_hostgroup, output);
+ break;
+
+ /******************/
+ /* SERVICE MACROS */
+ /******************/
+ case MACRO_SERVICEDESC:
+ case MACRO_SERVICESTATE:
+ case MACRO_SERVICESTATEID:
+ case MACRO_SERVICEATTEMPT:
+ case MACRO_LASTSERVICECHECK:
+ case MACRO_LASTSERVICESTATECHANGE:
+ case MACRO_SERVICEOUTPUT:
+ case MACRO_SERVICEPERFDATA:
+ case MACRO_SERVICEEXECUTIONTIME:
+ case MACRO_SERVICELATENCY:
+ case MACRO_SERVICEDURATION:
+ case MACRO_SERVICEDURATIONSEC:
+ case MACRO_SERVICEDOWNTIME:
+ case MACRO_SERVICESTATETYPE:
+ case MACRO_SERVICEPERCENTCHANGE:
+ case MACRO_SERVICEACKAUTHOR:
+ case MACRO_SERVICEACKCOMMENT:
+ case MACRO_LASTSERVICEOK:
+ case MACRO_LASTSERVICEWARNING:
+ case MACRO_LASTSERVICEUNKNOWN:
+ case MACRO_LASTSERVICECRITICAL:
+ case MACRO_SERVICECHECKCOMMAND:
+ case MACRO_SERVICEDISPLAYNAME:
+ case MACRO_SERVICEACTIONURL:
+ case MACRO_SERVICENOTESURL:
+ case MACRO_SERVICENOTES:
+ case MACRO_SERVICECHECKTYPE:
+ case MACRO_LONGSERVICEOUTPUT:
+ case MACRO_SERVICENOTIFICATIONNUMBER:
+ case MACRO_SERVICENOTIFICATIONID:
+ case MACRO_SERVICEEVENTID:
+ case MACRO_LASTSERVICEEVENTID:
+ case MACRO_SERVICEGROUPNAMES:
+ case MACRO_SERVICEACKAUTHORNAME:
+ case MACRO_SERVICEACKAUTHORALIAS:
+ case MACRO_MAXSERVICEATTEMPTS:
+ case MACRO_SERVICEISVOLATILE:
+ case MACRO_SERVICEPROBLEMID:
+ case MACRO_LASTSERVICEPROBLEMID:
+ case MACRO_LASTSERVICESTATE:
+ case MACRO_LASTSERVICESTATEID:
+
+ /* use saved service pointer */
+ if(arg1 == NULL && arg2 == NULL) {
+
+ if((temp_service = mac->service_ptr) == NULL)
+ return ERROR;
+
+ result = grab_standard_service_macro_r(mac, macro_type, temp_service, output, free_macro);
+ }
+
+ /* else and ondemand macro... */
+ else {
+
+ /* if first arg is blank, it means use the current host name */
+ if(arg1 == NULL || arg1[0] == '\x0') {
+
+ if(mac->host_ptr == NULL)
+ return ERROR;
+
+ if((temp_service = find_service(mac->host_ptr->name, arg2))) {
+
+ /* get the service macro value */
+ result = grab_standard_service_macro_r(mac, macro_type, temp_service, output, free_macro);
+ }
+ }
+
+ /* on-demand macro with both host and service name */
+ else if((temp_service = find_service(arg1, arg2))) {
+
+ /* get the service macro value */
+ result = grab_standard_service_macro_r(mac, macro_type, temp_service, output, free_macro);
+ }
+
+ /* else we have a service macro with a servicegroup name and a delimiter... */
+ else if(arg1 && arg2) {
+
+ if((temp_servicegroup = find_servicegroup(arg1)) == NULL)
+ return ERROR;
+
+ delimiter_len = strlen(arg2);
+
+ /* concatenate macro values for all servicegroup members */
+ for(temp_servicesmember = temp_servicegroup->members; temp_servicesmember != NULL; temp_servicesmember = temp_servicesmember->next) {
+
+#ifdef NSCORE
+ if((temp_service = temp_servicesmember->service_ptr) == NULL)
+ continue;
+#else
+ if((temp_service = find_service(temp_servicesmember->host_name, temp_servicesmember->service_description)) == NULL)
+ continue;
+#endif
+
+ /* get the macro value for this service */
+ grab_standard_service_macro_r(mac, macro_type, temp_service, &temp_buffer, &free_sub_macro);
+
+ if(temp_buffer == NULL)
+ continue;
+
+ /* add macro value to already running macro */
+ if(*output == NULL)
+ *output = (char *)strdup(temp_buffer);
+ else {
+ if((*output = (char *)realloc(*output, strlen(*output) + strlen(temp_buffer) + delimiter_len + 1)) == NULL)
+ continue;
+ strcat(*output, arg2);
+ strcat(*output, temp_buffer);
+ }
+ if(free_sub_macro == TRUE)
+ my_free(temp_buffer);
+ }
+ }
+ else
+ return ERROR;
+ }
+ break;
+
+ /***********************/
+ /* SERVICEGROUP MACROS */
+ /***********************/
+ case MACRO_SERVICEGROUPNAME:
+ case MACRO_SERVICEGROUPALIAS:
+ case MACRO_SERVICEGROUPNOTES:
+ case MACRO_SERVICEGROUPNOTESURL:
+ case MACRO_SERVICEGROUPACTIONURL:
+ case MACRO_SERVICEGROUPMEMBERS:
+ /* a standard servicegroup macro */
+ /* use the saved servicegroup pointer */
+ if(arg1 == NULL) {
+ if((temp_servicegroup = mac->servicegroup_ptr) == NULL)
+ return ERROR;
+ }
+
+ /* else find the servicegroup for on-demand macros */
+ else {
+ if((temp_servicegroup = find_servicegroup(arg1)) == NULL)
+ return ERROR;
+ }
+
+ /* get the servicegroup macro value */
+ result = grab_standard_servicegroup_macro_r(mac, macro_type, temp_servicegroup, output);
+ break;
+
+ /******************/
+ /* CONTACT MACROS */
+ /******************/
+ case MACRO_CONTACTNAME:
+ case MACRO_CONTACTALIAS:
+ case MACRO_CONTACTEMAIL:
+ case MACRO_CONTACTPAGER:
+ case MACRO_CONTACTGROUPNAMES:
+ /* a standard contact macro */
+ if(arg2 == NULL) {
+
+ /* find the contact for on-demand macros */
+ if(arg1) {
+ if((temp_contact = find_contact(arg1)) == NULL)
+ return ERROR;
+ }
+
+ /* else use saved contact pointer */
+ else if((temp_contact = mac->contact_ptr) == NULL)
+ return ERROR;
+
+ /* get the contact macro value */
+ result = grab_standard_contact_macro_r(mac, macro_type, temp_contact, output);
+ }
+
+ /* a contact macro with a contactgroup name and delimiter */
+ else {
+
+ if((temp_contactgroup = find_contactgroup(arg1)) == NULL)
+ return ERROR;
+
+ delimiter_len = strlen(arg2);
+
+ /* concatenate macro values for all contactgroup members */
+ for(temp_contactsmember = temp_contactgroup->members; temp_contactsmember != NULL; temp_contactsmember = temp_contactsmember->next) {
+
+#ifdef NSCORE
+ if((temp_contact = temp_contactsmember->contact_ptr) == NULL)
+ continue;
+#else
+ if((temp_contact = find_contact(temp_contactsmember->contact_name)) == NULL)
+ continue;
+#endif
+
+ /* get the macro value for this contact */
+ grab_standard_contact_macro_r(mac, macro_type, temp_contact, &temp_buffer);
+
+ if(temp_buffer == NULL)
+ continue;
+
+ /* add macro value to already running macro */
+ if(*output == NULL)
+ *output = (char *)strdup(temp_buffer);
+ else {
+ if((*output = (char *)realloc(*output, strlen(*output) + strlen(temp_buffer) + delimiter_len + 1)) == NULL)
+ continue;
+ strcat(*output, arg2);
+ strcat(*output, temp_buffer);
+ }
+ my_free(temp_buffer);
+ }
+ }
+ break;
+
+ /***********************/
+ /* CONTACTGROUP MACROS */
+ /***********************/
+ case MACRO_CONTACTGROUPNAME:
+ case MACRO_CONTACTGROUPALIAS:
+ case MACRO_CONTACTGROUPMEMBERS:
+ /* a standard contactgroup macro */
+ /* use the saved contactgroup pointer */
+ if(arg1 == NULL) {
+ if((temp_contactgroup = mac->contactgroup_ptr) == NULL)
+ return ERROR;
+ }
+
+ /* else find the contactgroup for on-demand macros */
+ else {
+ if((temp_contactgroup = find_contactgroup(arg1)) == NULL)
+ return ERROR;
+ }
+
+ /* get the contactgroup macro value */
+ result = grab_standard_contactgroup_macro(macro_type, temp_contactgroup, output);
+ break;
+
+ /***********************/
+ /* NOTIFICATION MACROS */
+ /***********************/
+ case MACRO_NOTIFICATIONTYPE:
+ case MACRO_NOTIFICATIONNUMBER:
+ case MACRO_NOTIFICATIONRECIPIENTS:
+ case MACRO_NOTIFICATIONISESCALATED:
+ case MACRO_NOTIFICATIONAUTHOR:
+ case MACRO_NOTIFICATIONAUTHORNAME:
+ case MACRO_NOTIFICATIONAUTHORALIAS:
+ case MACRO_NOTIFICATIONCOMMENT:
+
+ /* notification macros have already been pre-computed */
+ *output = mac->x[macro_type];
+ *free_macro = FALSE;
+ break;
+
+ /********************/
+ /* DATE/TIME MACROS */
+ /********************/
+ case MACRO_LONGDATETIME:
+ case MACRO_SHORTDATETIME:
+ case MACRO_DATE:
+ case MACRO_TIME:
+ case MACRO_TIMET:
+ case MACRO_ISVALIDTIME:
+ case MACRO_NEXTVALIDTIME:
+
+ /* calculate macros */
+ result = grab_datetime_macro_r(mac, macro_type, arg1, arg2, output);
+ break;
+
+ /*****************/
+ /* STATIC MACROS */
+ /*****************/
+ case MACRO_ADMINEMAIL:
+ case MACRO_ADMINPAGER:
+ case MACRO_MAINCONFIGFILE:
+ case MACRO_STATUSDATAFILE:
+ case MACRO_RETENTIONDATAFILE:
+ case MACRO_OBJECTCACHEFILE:
+ case MACRO_TEMPFILE:
+ case MACRO_LOGFILE:
+ case MACRO_RESOURCEFILE:
+ case MACRO_COMMANDFILE:
+ case MACRO_HOSTPERFDATAFILE:
+ case MACRO_SERVICEPERFDATAFILE:
+ case MACRO_PROCESSSTARTTIME:
+ case MACRO_TEMPPATH:
+ case MACRO_EVENTSTARTTIME:
+
+ /* no need to do any more work - these are already precomputed for us */
+ *output = global_macros.x[macro_type];
+ *free_macro = FALSE;
+ break;
+
+ /******************/
+ /* SUMMARY MACROS */
+ /******************/
+ case MACRO_TOTALHOSTSUP:
+ case MACRO_TOTALHOSTSDOWN:
+ case MACRO_TOTALHOSTSUNREACHABLE:
+ case MACRO_TOTALHOSTSDOWNUNHANDLED:
+ case MACRO_TOTALHOSTSUNREACHABLEUNHANDLED:
+ case MACRO_TOTALHOSTPROBLEMS:
+ case MACRO_TOTALHOSTPROBLEMSUNHANDLED:
+ case MACRO_TOTALSERVICESOK:
+ case MACRO_TOTALSERVICESWARNING:
+ case MACRO_TOTALSERVICESCRITICAL:
+ case MACRO_TOTALSERVICESUNKNOWN:
+ case MACRO_TOTALSERVICESWARNINGUNHANDLED:
+ case MACRO_TOTALSERVICESCRITICALUNHANDLED:
+ case MACRO_TOTALSERVICESUNKNOWNUNHANDLED:
+ case MACRO_TOTALSERVICEPROBLEMS:
+ case MACRO_TOTALSERVICEPROBLEMSUNHANDLED:
+
+#ifdef NSCORE
+ /* generate summary macros if needed */
+ if(mac->x[MACRO_TOTALHOSTSUP] == NULL) {
+
+ /* get host totals */
+ for(temp_host = host_list; temp_host != NULL; temp_host = temp_host->next) {
+
+ /* filter totals based on contact if necessary */
+ if(mac->contact_ptr != NULL)
+ authorized = is_contact_for_host(temp_host, mac->contact_ptr);
+
+ if(authorized == TRUE) {
+ problem = TRUE;
+
+ if(temp_host->current_state == HOST_UP && temp_host->has_been_checked == TRUE)
+ hosts_up++;
+ else if(temp_host->current_state == HOST_DOWN) {
+ if(temp_host->scheduled_downtime_depth > 0)
+ problem = FALSE;
+ if(temp_host->problem_has_been_acknowledged == TRUE)
+ problem = FALSE;
+ if(temp_host->checks_enabled == FALSE)
+ problem = FALSE;
+ if(problem == TRUE)
+ hosts_down_unhandled++;
+ hosts_down++;
+ }
+ else if(temp_host->current_state == HOST_UNREACHABLE) {
+ if(temp_host->scheduled_downtime_depth > 0)
+ problem = FALSE;
+ if(temp_host->problem_has_been_acknowledged == TRUE)
+ problem = FALSE;
+ if(temp_host->checks_enabled == FALSE)
+ problem = FALSE;
+ if(problem == TRUE)
+ hosts_down_unhandled++;
+ hosts_unreachable++;
+ }
+ }
+ }
+
+ host_problems = hosts_down + hosts_unreachable;
+ host_problems_unhandled = hosts_down_unhandled + hosts_unreachable_unhandled;
+
+ /* get service totals */
+ for(temp_service = service_list; temp_service != NULL; temp_service = temp_service->next) {
+
+ /* filter totals based on contact if necessary */
+ if(mac->contact_ptr != NULL)
+ authorized = is_contact_for_service(temp_service, mac->contact_ptr);
+
+ if(authorized == TRUE) {
+ problem = TRUE;
+
+ if(temp_service->current_state == STATE_OK && temp_service->has_been_checked == TRUE)
+ services_ok++;
+ else if(temp_service->current_state == STATE_WARNING) {
+ temp_host = find_host(temp_service->host_name);
+ if(temp_host != NULL && (temp_host->current_state == HOST_DOWN || temp_host->current_state == HOST_UNREACHABLE))
+ problem = FALSE;
+ if(temp_service->scheduled_downtime_depth > 0)
+ problem = FALSE;
+ if(temp_service->problem_has_been_acknowledged == TRUE)
+ problem = FALSE;
+ if(temp_service->checks_enabled == FALSE)
+ problem = FALSE;
+ if(problem == TRUE)
+ services_warning_unhandled++;
+ services_warning++;
+ }
+ else if(temp_service->current_state == STATE_UNKNOWN) {
+ temp_host = find_host(temp_service->host_name);
+ if(temp_host != NULL && (temp_host->current_state == HOST_DOWN || temp_host->current_state == HOST_UNREACHABLE))
+ problem = FALSE;
+ if(temp_service->scheduled_downtime_depth > 0)
+ problem = FALSE;
+ if(temp_service->problem_has_been_acknowledged == TRUE)
+ problem = FALSE;
+ if(temp_service->checks_enabled == FALSE)
+ problem = FALSE;
+ if(problem == TRUE)
+ services_unknown_unhandled++;
+ services_unknown++;
+ }
+ else if(temp_service->current_state == STATE_CRITICAL) {
+ temp_host = find_host(temp_service->host_name);
+ if(temp_host != NULL && (temp_host->current_state == HOST_DOWN || temp_host->current_state == HOST_UNREACHABLE))
+ problem = FALSE;
+ if(temp_service->scheduled_downtime_depth > 0)
+ problem = FALSE;
+ if(temp_service->problem_has_been_acknowledged == TRUE)
+ problem = FALSE;
+ if(temp_service->checks_enabled == FALSE)
+ problem = FALSE;
+ if(problem == TRUE)
+ services_critical_unhandled++;
+ services_critical++;
+ }
+ }
+ }
+
+ service_problems = services_warning + services_critical + services_unknown;
+ service_problems_unhandled = services_warning_unhandled + services_critical_unhandled + services_unknown_unhandled;
+
+ /* these macros are time-intensive to compute, and will likely be used together, so save them all for future use */
+ for(x = MACRO_TOTALHOSTSUP; x <= MACRO_TOTALSERVICEPROBLEMSUNHANDLED; x++)
+ my_free(mac->x[x]);
+ asprintf(&mac->x[MACRO_TOTALHOSTSUP], "%d", hosts_up);
+ asprintf(&mac->x[MACRO_TOTALHOSTSDOWN], "%d", hosts_down);
+ asprintf(&mac->x[MACRO_TOTALHOSTSUNREACHABLE], "%d", hosts_unreachable);
+ asprintf(&mac->x[MACRO_TOTALHOSTSDOWNUNHANDLED], "%d", hosts_down_unhandled);
+ asprintf(&mac->x[MACRO_TOTALHOSTSUNREACHABLEUNHANDLED], "%d", hosts_unreachable_unhandled);
+ asprintf(&mac->x[MACRO_TOTALHOSTPROBLEMS], "%d", host_problems);
+ asprintf(&mac->x[MACRO_TOTALHOSTPROBLEMSUNHANDLED], "%d", host_problems_unhandled);
+ asprintf(&mac->x[MACRO_TOTALSERVICESOK], "%d", services_ok);
+ asprintf(&mac->x[MACRO_TOTALSERVICESWARNING], "%d", services_warning);
+ asprintf(&mac->x[MACRO_TOTALSERVICESCRITICAL], "%d", services_critical);
+ asprintf(&mac->x[MACRO_TOTALSERVICESUNKNOWN], "%d", services_unknown);
+ asprintf(&mac->x[MACRO_TOTALSERVICESWARNINGUNHANDLED], "%d", services_warning_unhandled);
+ asprintf(&mac->x[MACRO_TOTALSERVICESCRITICALUNHANDLED], "%d", services_critical_unhandled);
+ asprintf(&mac->x[MACRO_TOTALSERVICESUNKNOWNUNHANDLED], "%d", services_unknown_unhandled);
+ asprintf(&mac->x[MACRO_TOTALSERVICEPROBLEMS], "%d", service_problems);
+ asprintf(&mac->x[MACRO_TOTALSERVICEPROBLEMSUNHANDLED], "%d", service_problems_unhandled);
+ }
+
+ /* return only the macro the user requested */
+ *output = mac->x[macro_type];
+
+ /* tell caller to NOT free memory when done */
+ *free_macro = FALSE;
+#endif
+ break;
+
+ default:
+ log_debug_info(DEBUGL_MACROS, 0, "UNHANDLED MACRO #%d! THIS IS A BUG!\n", macro_type);
+ return ERROR;
+ break;
+ }
+
+ return result;
+ }
+
+int grab_macrox_value(int macro_type, char *arg1, char *arg2, char **output, int *free_macro) {
+ return grab_macrox_value_r(&global_macros, macro_type, arg1, arg2, output, free_macro);
+ }
+
+
+/* calculates the value of a custom macro */
+int grab_custom_macro_value_r(nagios_macros *mac, char *macro_name, char *arg1, char *arg2, char **output) {
+ host *temp_host = NULL;
+ hostgroup *temp_hostgroup = NULL;
+ hostsmember *temp_hostsmember = NULL;
+ service *temp_service = NULL;
+ servicegroup *temp_servicegroup = NULL;
+ servicesmember *temp_servicesmember = NULL;
+ contact *temp_contact = NULL;
+ contactgroup *temp_contactgroup = NULL;
+ contactsmember *temp_contactsmember = NULL;
+ int delimiter_len = 0;
+ char *temp_buffer = NULL;
+ int result = OK;
+
+ if(macro_name == NULL || output == NULL)
+ return ERROR;
+
+ /***** CUSTOM HOST MACRO *****/
+ if(strstr(macro_name, "_HOST") == macro_name) {
+
+ /* a standard host macro */
+ if(arg2 == NULL) {
+
+ /* find the host for on-demand macros */
+ if(arg1) {
+ if((temp_host = find_host(arg1)) == NULL)
+ return ERROR;
+ }
+
+ /* else use saved host pointer */
+ else if((temp_host = mac->host_ptr) == NULL)
+ return ERROR;
+
+ /* get the host macro value */
+ result = grab_custom_object_macro_r(mac, macro_name + 5, temp_host->custom_variables, output);
+ }
+
+ /* a host macro with a hostgroup name and delimiter */
+ else {
+ if((temp_hostgroup = find_hostgroup(arg1)) == NULL)
+ return ERROR;
+
+ delimiter_len = strlen(arg2);
+
+ /* concatenate macro values for all hostgroup members */
+ for(temp_hostsmember = temp_hostgroup->members; temp_hostsmember != NULL; temp_hostsmember = temp_hostsmember->next) {
+
+#ifdef NSCORE
+ if((temp_host = temp_hostsmember->host_ptr) == NULL)
+ continue;
+#else
+ if((temp_host = find_host(temp_hostsmember->host_name)) == NULL)
+ continue;
+#endif
+
+ /* get the macro value for this host */
+ grab_custom_macro_value_r(mac, macro_name, temp_host->name, NULL, &temp_buffer);
+
+ if(temp_buffer == NULL)
+ continue;
+
+ /* add macro value to already running macro */
+ if(*output == NULL)
+ *output = (char *)strdup(temp_buffer);
+ else {
+ if((*output = (char *)realloc(*output, strlen(*output) + strlen(temp_buffer) + delimiter_len + 1)) == NULL)
+ continue;
+ strcat(*output, arg2);
+ strcat(*output, temp_buffer);
+ }
+ my_free(temp_buffer);
+ }
+ }
+ }
+
+ /***** CUSTOM SERVICE MACRO *****/
+ else if(strstr(macro_name, "_SERVICE") == macro_name) {
+
+ /* use saved service pointer */
+ if(arg1 == NULL && arg2 == NULL) {
+
+ if((temp_service = mac->service_ptr) == NULL)
+ return ERROR;
+
+ /* get the service macro value */
+ result = grab_custom_object_macro_r(mac, macro_name + 8, temp_service->custom_variables, output);
+ }
+
+ /* else and ondemand macro... */
+ else {
+
+ /* if first arg is blank, it means use the current host name */
+ if(mac->host_ptr == NULL)
+ return ERROR;
+ if((temp_service = find_service((mac->host_ptr) ? mac->host_ptr->name : NULL, arg2))) {
+
+ /* get the service macro value */
+ result = grab_custom_object_macro_r(mac, macro_name + 8, temp_service->custom_variables, output);
+ }
+
+ /* else we have a service macro with a servicegroup name and a delimiter... */
+ else {
+
+ if((temp_servicegroup = find_servicegroup(arg1)) == NULL)
+ return ERROR;
+
+ delimiter_len = strlen(arg2);
+
+ /* concatenate macro values for all servicegroup members */
+ for(temp_servicesmember = temp_servicegroup->members; temp_servicesmember != NULL; temp_servicesmember = temp_servicesmember->next) {
+
+#ifdef NSCORE
+ if((temp_service = temp_servicesmember->service_ptr) == NULL)
+ continue;
+#else
+ if((temp_service = find_service(temp_servicesmember->host_name, temp_servicesmember->service_description)) == NULL)
+ continue;
+#endif
+
+ /* get the macro value for this service */
+ grab_custom_macro_value_r(mac, macro_name, temp_service->host_name, temp_service->description, &temp_buffer);
+
+ if(temp_buffer == NULL)
+ continue;
+
+ /* add macro value to already running macro */
+ if(*output == NULL)
+ *output = (char *)strdup(temp_buffer);
+ else {
+ if((*output = (char *)realloc(*output, strlen(*output) + strlen(temp_buffer) + delimiter_len + 1)) == NULL)
+ continue;
+ strcat(*output, arg2);
+ strcat(*output, temp_buffer);
+ }
+ my_free(temp_buffer);
+ }
+ }
+ }
+ }
+
+ /***** CUSTOM CONTACT VARIABLE *****/
+ else if(strstr(macro_name, "_CONTACT") == macro_name) {
+
+ /* a standard contact macro */
+ if(arg2 == NULL) {
+
+ /* find the contact for on-demand macros */
+ if(arg1) {
+ if((temp_contact = find_contact(arg1)) == NULL)
+ return ERROR;
+ }
+
+ /* else use saved contact pointer */
+ else if((temp_contact = mac->contact_ptr) == NULL)
+ return ERROR;
+
+ /* get the contact macro value */
+ result = grab_custom_object_macro_r(mac, macro_name + 8, temp_contact->custom_variables, output);
+ }
+
+ /* a contact macro with a contactgroup name and delimiter */
+ else {
+
+ if((temp_contactgroup = find_contactgroup(arg1)) == NULL)
+ return ERROR;
+
+ delimiter_len = strlen(arg2);
+
+ /* concatenate macro values for all contactgroup members */
+ for(temp_contactsmember = temp_contactgroup->members; temp_contactsmember != NULL; temp_contactsmember = temp_contactsmember->next) {
+
+#ifdef NSCORE
+ if((temp_contact = temp_contactsmember->contact_ptr) == NULL)
+ continue;
+#else
+ if((temp_contact = find_contact(temp_contactsmember->contact_name)) == NULL)
+ continue;
+#endif
+
+ /* get the macro value for this contact */
+ grab_custom_macro_value_r(mac, macro_name, temp_contact->name, NULL, &temp_buffer);
+
+ if(temp_buffer == NULL)
+ continue;
+
+ /* add macro value to already running macro */
+ if(*output == NULL)
+ *output = (char *)strdup(temp_buffer);
+ else {
+ if((*output = (char *)realloc(*output, strlen(*output) + strlen(temp_buffer) + delimiter_len + 1)) == NULL)
+ continue;
+ strcat(*output, arg2);
+ strcat(*output, temp_buffer);
+ }
+ my_free(temp_buffer);
+ }
+ }
+ }
+
+ else
+ return ERROR;
+
+ return result;
+ }
+
+int grab_custom_macro_value(char *macro_name, char *arg1, char *arg2, char **output) {
+ return grab_custom_macro_value_r(&global_macros, macro_name, arg1, arg2, output);
+ }
+
+
+/* calculates a date/time macro */
+int grab_datetime_macro_r(nagios_macros *mac, int macro_type, char *arg1, char *arg2, char **output) {
+ time_t current_time = 0L;
+ timeperiod *temp_timeperiod = NULL;
+ time_t test_time = 0L;
+#ifdef NSCORE
+ time_t next_valid_time = 0L;
+#endif
+
+ if(output == NULL)
+ return ERROR;
+
+ /* get the current time */
+ time(¤t_time);
+
+ /* parse args, do prep work */
+ switch(macro_type) {
+
+ case MACRO_ISVALIDTIME:
+ case MACRO_NEXTVALIDTIME:
+
+ /* find the timeperiod */
+ if((temp_timeperiod = find_timeperiod(arg1)) == NULL)
+ return ERROR;
+
+ /* what timestamp should we use? */
+ if(arg2)
+ test_time = (time_t)strtoul(arg2, NULL, 0);
+ else
+ test_time = current_time;
+ break;
+
+ default:
+ break;
+ }
+
+ /* calculate the value */
+ switch(macro_type) {
+
+ case MACRO_LONGDATETIME:
+ if(*output == NULL)
+ *output = (char *)malloc(MAX_DATETIME_LENGTH);
+ if(*output)
+ get_datetime_string(¤t_time, *output, MAX_DATETIME_LENGTH, LONG_DATE_TIME);
+ break;
+
+ case MACRO_SHORTDATETIME:
+ if(*output == NULL)
+ *output = (char *)malloc(MAX_DATETIME_LENGTH);
+ if(*output)
+ get_datetime_string(¤t_time, *output, MAX_DATETIME_LENGTH, SHORT_DATE_TIME);
+ break;
+
+ case MACRO_DATE:
+ if(*output == NULL)
+ *output = (char *)malloc(MAX_DATETIME_LENGTH);
+ if(*output)
+ get_datetime_string(¤t_time, *output, MAX_DATETIME_LENGTH, SHORT_DATE);
+ break;
+
+ case MACRO_TIME:
+ if(*output == NULL)
+ *output = (char *)malloc(MAX_DATETIME_LENGTH);
+ if(*output)
+ get_datetime_string(¤t_time, *output, MAX_DATETIME_LENGTH, SHORT_TIME);
+ break;
+
+ case MACRO_TIMET:
+ asprintf(output, "%lu", (unsigned long)current_time);
+ break;
+
+#ifdef NSCORE
+ case MACRO_ISVALIDTIME:
+ asprintf(output, "%d", (check_time_against_period(test_time, temp_timeperiod) == OK) ? 1 : 0);
+ break;
+
+ case MACRO_NEXTVALIDTIME:
+ get_next_valid_time(test_time, &next_valid_time, temp_timeperiod);
+ if(next_valid_time == test_time && check_time_against_period(test_time, temp_timeperiod) == ERROR)
+ next_valid_time = (time_t)0L;
+ asprintf(output, "%lu", (unsigned long)next_valid_time);
+ break;
+#endif
+
+ default:
+ return ERROR;
+ break;
+ }
+
+ return OK;
+ }
+
+int grab_datetime_macro(int macro_type, char *arg1, char *arg2, char **output) {
+ return grab_datetime_macro_r(&global_macros, macro_type, arg1, arg2, output);
+ }
+
+
+/* calculates a host macro */
+int grab_standard_host_macro_r(nagios_macros *mac, int macro_type, host *temp_host, char **output, int *free_macro) {
+ char *temp_buffer = NULL;
+#ifdef NSCORE
+ hostgroup *temp_hostgroup = NULL;
+ servicesmember *temp_servicesmember = NULL;
+ service *temp_service = NULL;
+ objectlist *temp_objectlist = NULL;
+ time_t current_time = 0L;
+ unsigned long duration = 0L;
+ int days = 0;
+ int hours = 0;
+ int minutes = 0;
+ int seconds = 0;
+ char *buf1 = NULL;
+ char *buf2 = NULL;
+ int total_host_services = 0;
+ int total_host_services_ok = 0;
+ int total_host_services_warning = 0;
+ int total_host_services_unknown = 0;
+ int total_host_services_critical = 0;
+#endif
+
+ if(temp_host == NULL || output == NULL || free_macro == NULL)
+ return ERROR;
+
+ /* BY DEFAULT TELL CALLER TO FREE MACRO BUFFER WHEN DONE */
+ *free_macro = TRUE;
+
+ /* get the macro */
+ switch(macro_type) {
+
+ case MACRO_HOSTNAME:
+ *output = (char *)strdup(temp_host->name);
+ break;
+ case MACRO_HOSTDISPLAYNAME:
+ if(temp_host->display_name)
+ *output = (char *)strdup(temp_host->display_name);
+ break;
+ case MACRO_HOSTALIAS:
+ *output = (char *)strdup(temp_host->alias);
+ break;
+ case MACRO_HOSTADDRESS:
+ *output = (char *)strdup(temp_host->address);
+ break;
+#ifdef NSCORE
+ case MACRO_HOSTSTATE:
+ if(temp_host->current_state == HOST_DOWN)
+ *output = (char *)strdup("DOWN");
+ else if(temp_host->current_state == HOST_UNREACHABLE)
+ *output = (char *)strdup("UNREACHABLE");
+ else
+ *output = (char *)strdup("UP");
+ break;
+ case MACRO_HOSTSTATEID:
+ asprintf(output, "%d", temp_host->current_state);
+ break;
+ case MACRO_LASTHOSTSTATE:
+ if(temp_host->last_state == HOST_DOWN)
+ *output = (char *)strdup("DOWN");
+ else if(temp_host->last_state == HOST_UNREACHABLE)
+ *output = (char *)strdup("UNREACHABLE");
+ else
+ *output = (char *)strdup("UP");
+ break;
+ case MACRO_LASTHOSTSTATEID:
+ asprintf(output, "%d", temp_host->last_state);
+ break;
+ case MACRO_HOSTCHECKTYPE:
+ asprintf(output, "%s", (temp_host->check_type == HOST_CHECK_PASSIVE) ? "PASSIVE" : "ACTIVE");
+ break;
+ case MACRO_HOSTSTATETYPE:
+ asprintf(output, "%s", (temp_host->state_type == HARD_STATE) ? "HARD" : "SOFT");
+ break;
+ case MACRO_HOSTOUTPUT:
+ if(temp_host->plugin_output)
+ *output = (char *)strdup(temp_host->plugin_output);
+ break;
+ case MACRO_LONGHOSTOUTPUT:
+ if(temp_host->long_plugin_output)
+ *output = (char *)strdup(temp_host->long_plugin_output);
+ break;
+ case MACRO_HOSTPERFDATA:
+ if(temp_host->perf_data)
+ *output = (char *)strdup(temp_host->perf_data);
+ break;
+#endif
+ case MACRO_HOSTCHECKCOMMAND:
+ if(temp_host->host_check_command)
+ *output = (char *)strdup(temp_host->host_check_command);
+ break;
+#ifdef NSCORE
+ case MACRO_HOSTATTEMPT:
+ asprintf(output, "%d", temp_host->current_attempt);
+ break;
+ case MACRO_MAXHOSTATTEMPTS:
+ asprintf(output, "%d", temp_host->max_attempts);
+ break;
+ case MACRO_HOSTDOWNTIME:
+ asprintf(output, "%d", temp_host->scheduled_downtime_depth);
+ break;
+ case MACRO_HOSTPERCENTCHANGE:
+ asprintf(output, "%.2f", temp_host->percent_state_change);
+ break;
+ case MACRO_HOSTDURATIONSEC:
+ case MACRO_HOSTDURATION:
+ time(¤t_time);
+ duration = (unsigned long)(current_time - temp_host->last_state_change);
+
+ if(macro_type == MACRO_HOSTDURATIONSEC)
+ asprintf(output, "%lu", duration);
+ else {
+
+ days = duration / 86400;
+ duration -= (days * 86400);
+ hours = duration / 3600;
+ duration -= (hours * 3600);
+ minutes = duration / 60;
+ duration -= (minutes * 60);
+ seconds = duration;
+ asprintf(output, "%dd %dh %dm %ds", days, hours, minutes, seconds);
+ }
+ break;
+ case MACRO_HOSTEXECUTIONTIME:
+ asprintf(output, "%.3f", temp_host->execution_time);
+ break;
+ case MACRO_HOSTLATENCY:
+ asprintf(output, "%.3f", temp_host->latency);
+ break;
+ case MACRO_LASTHOSTCHECK:
+ asprintf(output, "%lu", (unsigned long)temp_host->last_check);
+ break;
+ case MACRO_LASTHOSTSTATECHANGE:
+ asprintf(output, "%lu", (unsigned long)temp_host->last_state_change);
+ break;
+ case MACRO_LASTHOSTUP:
+ asprintf(output, "%lu", (unsigned long)temp_host->last_time_up);
+ break;
+ case MACRO_LASTHOSTDOWN:
+ asprintf(output, "%lu", (unsigned long)temp_host->last_time_down);
+ break;
+ case MACRO_LASTHOSTUNREACHABLE:
+ asprintf(output, "%lu", (unsigned long)temp_host->last_time_unreachable);
+ break;
+ case MACRO_HOSTNOTIFICATIONNUMBER:
+ asprintf(output, "%d", temp_host->current_notification_number);
+ break;
+ case MACRO_HOSTNOTIFICATIONID:
+ asprintf(output, "%lu", temp_host->current_notification_id);
+ break;
+ case MACRO_HOSTEVENTID:
+ asprintf(output, "%lu", temp_host->current_event_id);
+ break;
+ case MACRO_LASTHOSTEVENTID:
+ asprintf(output, "%lu", temp_host->last_event_id);
+ break;
+ case MACRO_HOSTPROBLEMID:
+ asprintf(output, "%lu", temp_host->current_problem_id);
+ break;
+ case MACRO_LASTHOSTPROBLEMID:
+ asprintf(output, "%lu", temp_host->last_problem_id);
+ break;
+#endif
+ case MACRO_HOSTACTIONURL:
+ if(temp_host->action_url)
+ *output = (char *)strdup(temp_host->action_url);
+ break;
+ case MACRO_HOSTNOTESURL:
+ if(temp_host->notes_url)
+ *output = (char *)strdup(temp_host->notes_url);
+ break;
+ case MACRO_HOSTNOTES:
+ if(temp_host->notes)
+ *output = (char *)strdup(temp_host->notes);
+ break;
+#ifdef NSCORE
+ case MACRO_HOSTGROUPNAMES:
+ /* find all hostgroups this host is associated with */
+ for(temp_objectlist = temp_host->hostgroups_ptr; temp_objectlist != NULL; temp_objectlist = temp_objectlist->next) {
+
+ if((temp_hostgroup = (hostgroup *)temp_objectlist->object_ptr) == NULL)
+ continue;
+
+ asprintf(&buf1, "%s%s%s", (buf2) ? buf2 : "", (buf2) ? "," : "", temp_hostgroup->group_name);
+ my_free(buf2);
+ buf2 = buf1;
+ }
+ if(buf2) {
+ *output = (char *)strdup(buf2);
+ my_free(buf2);
+ }
+ break;
+ case MACRO_TOTALHOSTSERVICES:
+ case MACRO_TOTALHOSTSERVICESOK:
+ case MACRO_TOTALHOSTSERVICESWARNING:
+ case MACRO_TOTALHOSTSERVICESUNKNOWN:
+ case MACRO_TOTALHOSTSERVICESCRITICAL:
+
+ /* generate host service summary macros (if they haven't already been computed) */
+ if(mac->x[MACRO_TOTALHOSTSERVICES] == NULL) {
+
+ for(temp_servicesmember = temp_host->services; temp_servicesmember != NULL; temp_servicesmember = temp_servicesmember->next) {
+ if((temp_service = temp_servicesmember->service_ptr) == NULL)
+ continue;
+
+ total_host_services++;
+
+ switch(temp_service->current_state) {
+ case STATE_OK:
+ total_host_services_ok++;
+ break;
+ case STATE_WARNING:
+ total_host_services_warning++;
+ break;
+ case STATE_UNKNOWN:
+ total_host_services_unknown++;
+ break;
+ case STATE_CRITICAL:
+ total_host_services_critical++;
+ break;
+ default:
+ break;
+ }
+ }
+
+ /* these macros are time-intensive to compute, and will likely be used together, so save them all for future use */
+ my_free(mac->x[MACRO_TOTALHOSTSERVICES]);
+ asprintf(&mac->x[MACRO_TOTALHOSTSERVICES], "%d", total_host_services);
+ my_free(mac->x[MACRO_TOTALHOSTSERVICESOK]);
+ asprintf(&mac->x[MACRO_TOTALHOSTSERVICESOK], "%d", total_host_services_ok);
+ my_free(mac->x[MACRO_TOTALHOSTSERVICESWARNING]);
+ asprintf(&mac->x[MACRO_TOTALHOSTSERVICESWARNING], "%d", total_host_services_warning);
+ my_free(mac->x[MACRO_TOTALHOSTSERVICESUNKNOWN]);
+ asprintf(&mac->x[MACRO_TOTALHOSTSERVICESUNKNOWN], "%d", total_host_services_unknown);
+ my_free(mac->x[MACRO_TOTALHOSTSERVICESCRITICAL]);
+ asprintf(&mac->x[MACRO_TOTALHOSTSERVICESCRITICAL], "%d", total_host_services_critical);
+ }
+
+ /* return only the macro the user requested */
+ *output = mac->x[macro_type];
+
+ /* tell caller to NOT free memory when done */
+ *free_macro = FALSE;
+ break;
+#endif
+ /***************/
+ /* MISC MACROS */
+ /***************/
+ case MACRO_HOSTACKAUTHOR:
+ case MACRO_HOSTACKAUTHORNAME:
+ case MACRO_HOSTACKAUTHORALIAS:
+ case MACRO_HOSTACKCOMMENT:
+ /* no need to do any more work - these are already precomputed elsewhere */
+ /* NOTE: these macros won't work as on-demand macros */
+ *output = mac->x[macro_type];
+ *free_macro = FALSE;
+ break;
+
+ default:
+ log_debug_info(DEBUGL_MACROS, 0, "UNHANDLED HOST MACRO #%d! THIS IS A BUG!\n", macro_type);
+ return ERROR;
+ break;
+ }
+
+ /* post-processing */
+ /* notes, notes URL and action URL macros may themselves contain macros, so process them... */
+ switch(macro_type) {
+ case MACRO_HOSTACTIONURL:
+ case MACRO_HOSTNOTESURL:
+ process_macros_r(mac, *output, &temp_buffer, URL_ENCODE_MACRO_CHARS);
+ my_free(*output);
+ *output = temp_buffer;
+ break;
+ case MACRO_HOSTNOTES:
+ process_macros_r(mac, *output, &temp_buffer, 0);
+ my_free(*output);
+ *output = temp_buffer;
+ break;
+ default:
+ break;
+ }
+
+ return OK;
+ }
+
+int grab_standard_host_macro(int macro_type, host *temp_host, char **output, int *free_macro) {
+ return grab_standard_host_macro_r(&global_macros, macro_type, temp_host, output, free_macro);
+ }
+
+
+/* computes a hostgroup macro */
+int grab_standard_hostgroup_macro_r(nagios_macros *mac, int macro_type, hostgroup *temp_hostgroup, char **output) {
+ hostsmember *temp_hostsmember = NULL;
+ char *temp_buffer = NULL;
+ unsigned int temp_len = 0;
+ unsigned int init_len = 0;
+
+ if(temp_hostgroup == NULL || output == NULL)
+ return ERROR;
+
+ /* get the macro value */
+ switch(macro_type) {
+ case MACRO_HOSTGROUPNAME:
+ *output = (char *)strdup(temp_hostgroup->group_name);
+ break;
+ case MACRO_HOSTGROUPALIAS:
+ if(temp_hostgroup->alias)
+ *output = (char *)strdup(temp_hostgroup->alias);
+ break;
+ case MACRO_HOSTGROUPMEMBERS:
+ /* make the calculations for total string length */
+ for(temp_hostsmember = temp_hostgroup->members; temp_hostsmember != NULL; temp_hostsmember = temp_hostsmember->next) {
+ if(temp_hostsmember->host_name == NULL)
+ continue;
+ if(temp_len == 0) {
+ temp_len += strlen(temp_hostsmember->host_name) + 1;
+ }
+ else {
+ temp_len += strlen(temp_hostsmember->host_name) + 2;
+ }
+ }
+ /* allocate or reallocate the memory buffer */
+ if(*output == NULL) {
+ *output = (char *)malloc(temp_len);
+ }
+ else {
+ init_len = strlen(*output);
+ temp_len += init_len;
+ *output = (char *)realloc(*output, temp_len);
+ }
+ /* now fill in the string with the member names */
+ for(temp_hostsmember = temp_hostgroup->members; temp_hostsmember != NULL; temp_hostsmember = temp_hostsmember->next) {
+ if(temp_hostsmember->host_name == NULL)
+ continue;
+ temp_buffer = *output + init_len;
+ if(init_len == 0) { /* If our buffer didn't contain anything, we just need to write "%s,%s" */
+ init_len += sprintf(temp_buffer, "%s", temp_hostsmember->host_name);
+ }
+ else {
+ init_len += sprintf(temp_buffer, ",%s", temp_hostsmember->host_name);
+ }
+ }
+ break;
+ case MACRO_HOSTGROUPACTIONURL:
+ if(temp_hostgroup->action_url)
+ *output = (char *)strdup(temp_hostgroup->action_url);
+ break;
+ case MACRO_HOSTGROUPNOTESURL:
+ if(temp_hostgroup->notes_url)
+ *output = (char *)strdup(temp_hostgroup->notes_url);
+ break;
+ case MACRO_HOSTGROUPNOTES:
+ if(temp_hostgroup->notes)
+ *output = (char *)strdup(temp_hostgroup->notes);
+ break;
+ default:
+ log_debug_info(DEBUGL_MACROS, 0, "UNHANDLED HOSTGROUP MACRO #%d! THIS IS A BUG!\n", macro_type);
+ return ERROR;
+ break;
+ }
+
+ /* post-processing */
+ /* notes, notes URL and action URL macros may themselves contain macros, so process them... */
+ switch(macro_type) {
+ case MACRO_HOSTGROUPACTIONURL:
+ case MACRO_HOSTGROUPNOTESURL:
+ process_macros_r(mac, *output, &temp_buffer, URL_ENCODE_MACRO_CHARS);
+ my_free(*output);
+ *output = temp_buffer;
+ break;
+ case MACRO_HOSTGROUPNOTES:
+ process_macros_r(mac, *output, &temp_buffer, 0);
+ my_free(*output);
+ *output = temp_buffer;
+ break;
+ default:
+ break;
+ }
+
+ return OK;
+ }
+
+int grab_standard_hostgroup_macro(int macro_type, hostgroup *temp_hostgroup, char **output) {
+ return grab_standard_hostgroup_macro_r(&global_macros, macro_type, temp_hostgroup, output);
+ }
+
+
+/* computes a service macro */
+int grab_standard_service_macro_r(nagios_macros *mac, int macro_type, service *temp_service, char **output, int *free_macro) {
+ char *temp_buffer = NULL;
+#ifdef NSCORE
+ servicegroup *temp_servicegroup = NULL;
+ objectlist *temp_objectlist = NULL;
+ time_t current_time = 0L;
+ unsigned long duration = 0L;
+ int days = 0;
+ int hours = 0;
+ int minutes = 0;
+ int seconds = 0;
+ char *buf1 = NULL;
+ char *buf2 = NULL;
+#endif
+
+ if(temp_service == NULL || output == NULL)
+ return ERROR;
+
+ /* BY DEFAULT TELL CALLER TO FREE MACRO BUFFER WHEN DONE */
+ *free_macro = TRUE;
+
+ /* get the macro value */
+ switch(macro_type) {
+ case MACRO_SERVICEDESC:
+ *output = (char *)strdup(temp_service->description);
+ break;
+ case MACRO_SERVICEDISPLAYNAME:
+ if(temp_service->display_name)
+ *output = (char *)strdup(temp_service->display_name);
+ break;
+#ifdef NSCORE
+ case MACRO_SERVICEOUTPUT:
+ if(temp_service->plugin_output)
+ *output = (char *)strdup(temp_service->plugin_output);
+ break;
+ case MACRO_LONGSERVICEOUTPUT:
+ if(temp_service->long_plugin_output)
+ *output = (char *)strdup(temp_service->long_plugin_output);
+ break;
+ case MACRO_SERVICEPERFDATA:
+ if(temp_service->perf_data)
+ *output = (char *)strdup(temp_service->perf_data);
+ break;
+#endif
+ case MACRO_SERVICECHECKCOMMAND:
+ if(temp_service->service_check_command)
+ *output = (char *)strdup(temp_service->service_check_command);
+ break;
+#ifdef NSCORE
+ case MACRO_SERVICECHECKTYPE:
+ *output = (char *)strdup((temp_service->check_type == SERVICE_CHECK_PASSIVE) ? "PASSIVE" : "ACTIVE");
+ break;
+ case MACRO_SERVICESTATETYPE:
+ *output = (char *)strdup((temp_service->state_type == HARD_STATE) ? "HARD" : "SOFT");
+ break;
+ case MACRO_SERVICESTATE:
+ if(temp_service->current_state == STATE_OK)
+ *output = (char *)strdup("OK");
+ else if(temp_service->current_state == STATE_WARNING)
+ *output = (char *)strdup("WARNING");
+ else if(temp_service->current_state == STATE_CRITICAL)
+ *output = (char *)strdup("CRITICAL");
+ else
+ *output = (char *)strdup("UNKNOWN");
+ break;
+ case MACRO_SERVICESTATEID:
+ asprintf(output, "%d", temp_service->current_state);
+ break;
+ case MACRO_LASTSERVICESTATE:
+ if(temp_service->last_state == STATE_OK)
+ *output = (char *)strdup("OK");
+ else if(temp_service->last_state == STATE_WARNING)
+ *output = (char *)strdup("WARNING");
+ else if(temp_service->last_state == STATE_CRITICAL)
+ *output = (char *)strdup("CRITICAL");
+ else
+ *output = (char *)strdup("UNKNOWN");
+ break;
+ case MACRO_LASTSERVICESTATEID:
+ asprintf(output, "%d", temp_service->last_state);
+ break;
+#endif
+ case MACRO_SERVICEISVOLATILE:
+ asprintf(output, "%d", temp_service->is_volatile);
+ break;
+#ifdef NSCORE
+ case MACRO_SERVICEATTEMPT:
+ asprintf(output, "%d", temp_service->current_attempt);
+ break;
+ case MACRO_MAXSERVICEATTEMPTS:
+ asprintf(output, "%d", temp_service->max_attempts);
+ break;
+ case MACRO_SERVICEEXECUTIONTIME:
+ asprintf(output, "%.3f", temp_service->execution_time);
+ break;
+ case MACRO_SERVICELATENCY:
+ asprintf(output, "%.3f", temp_service->latency);
+ break;
+ case MACRO_LASTSERVICECHECK:
+ asprintf(output, "%lu", (unsigned long)temp_service->last_check);
+ break;
+ case MACRO_LASTSERVICESTATECHANGE:
+ asprintf(output, "%lu", (unsigned long)temp_service->last_state_change);
+ break;
+ case MACRO_LASTSERVICEOK:
+ asprintf(output, "%lu", (unsigned long)temp_service->last_time_ok);
+ break;
+ case MACRO_LASTSERVICEWARNING:
+ asprintf(output, "%lu", (unsigned long)temp_service->last_time_warning);
+ break;
+ case MACRO_LASTSERVICEUNKNOWN:
+ asprintf(output, "%lu", (unsigned long)temp_service->last_time_unknown);
+ break;
+ case MACRO_LASTSERVICECRITICAL:
+ asprintf(output, "%lu", (unsigned long)temp_service->last_time_critical);
+ break;
+ case MACRO_SERVICEDOWNTIME:
+ asprintf(output, "%d", temp_service->scheduled_downtime_depth);
+ break;
+ case MACRO_SERVICEPERCENTCHANGE:
+ asprintf(output, "%.2f", temp_service->percent_state_change);
+ break;
+ case MACRO_SERVICEDURATIONSEC:
+ case MACRO_SERVICEDURATION:
+
+ time(¤t_time);
+ duration = (unsigned long)(current_time - temp_service->last_state_change);
+
+ /* get the state duration in seconds */
+ if(macro_type == MACRO_SERVICEDURATIONSEC)
+ asprintf(output, "%lu", duration);
+
+ /* get the state duration */
+ else {
+ days = duration / 86400;
+ duration -= (days * 86400);
+ hours = duration / 3600;
+ duration -= (hours * 3600);
+ minutes = duration / 60;
+ duration -= (minutes * 60);
+ seconds = duration;
+ asprintf(output, "%dd %dh %dm %ds", days, hours, minutes, seconds);
+ }
+ break;
+ case MACRO_SERVICENOTIFICATIONNUMBER:
+ asprintf(output, "%d", temp_service->current_notification_number);
+ break;
+ case MACRO_SERVICENOTIFICATIONID:
+ asprintf(output, "%lu", temp_service->current_notification_id);
+ break;
+ case MACRO_SERVICEEVENTID:
+ asprintf(output, "%lu", temp_service->current_event_id);
+ break;
+ case MACRO_LASTSERVICEEVENTID:
+ asprintf(output, "%lu", temp_service->last_event_id);
+ break;
+ case MACRO_SERVICEPROBLEMID:
+ asprintf(output, "%lu", temp_service->current_problem_id);
+ break;
+ case MACRO_LASTSERVICEPROBLEMID:
+ asprintf(output, "%lu", temp_service->last_problem_id);
+ break;
+#endif
+ case MACRO_SERVICEACTIONURL:
+ if(temp_service->action_url)
+ *output = (char *)strdup(temp_service->action_url);
+ break;
+ case MACRO_SERVICENOTESURL:
+ if(temp_service->notes_url)
+ *output = (char *)strdup(temp_service->notes_url);
+ break;
+ case MACRO_SERVICENOTES:
+ if(temp_service->notes)
+ *output = (char *)strdup(temp_service->notes);
+ break;
+#ifdef NSCORE
+ case MACRO_SERVICEGROUPNAMES:
+ /* find all servicegroups this service is associated with */
+ for(temp_objectlist = temp_service->servicegroups_ptr; temp_objectlist != NULL; temp_objectlist = temp_objectlist->next) {
+
+ if((temp_servicegroup = (servicegroup *)temp_objectlist->object_ptr) == NULL)
+ continue;
+
+ asprintf(&buf1, "%s%s%s", (buf2) ? buf2 : "", (buf2) ? "," : "", temp_servicegroup->group_name);
+ my_free(buf2);
+ buf2 = buf1;
+ }
+ if(buf2) {
+ *output = (char *)strdup(buf2);
+ my_free(buf2);
+ }
+ break;
+#endif
+ /***************/
+ /* MISC MACROS */
+ /***************/
+ case MACRO_SERVICEACKAUTHOR:
+ case MACRO_SERVICEACKAUTHORNAME:
+ case MACRO_SERVICEACKAUTHORALIAS:
+ case MACRO_SERVICEACKCOMMENT:
+ /* no need to do any more work - these are already precomputed elsewhere */
+ /* NOTE: these macros won't work as on-demand macros */
+ *output = mac->x[macro_type];
+ *free_macro = FALSE;
+ break;
+
+ default:
+ log_debug_info(DEBUGL_MACROS, 0, "UNHANDLED SERVICE MACRO #%d! THIS IS A BUG!\n", macro_type);
+ return ERROR;
+ break;
+ }
+
+ /* post-processing */
+ /* notes, notes URL and action URL macros may themselves contain macros, so process them... */
+ switch(macro_type) {
+ case MACRO_SERVICEACTIONURL:
+ case MACRO_SERVICENOTESURL:
+ process_macros_r(mac, *output, &temp_buffer, URL_ENCODE_MACRO_CHARS);
+ my_free(*output);
+ *output = temp_buffer;
+ break;
+ case MACRO_SERVICENOTES:
+ process_macros_r(mac, *output, &temp_buffer, 0);
+ my_free(*output);
+ *output = temp_buffer;
+ break;
+ default:
+ break;
+ }
+
+ return OK;
+ }
+
+int grab_standard_service_macro(int macro_type, service *temp_service, char **output, int *free_macro) {
+ return grab_standard_service_macro_r(&global_macros, macro_type, temp_service, output, free_macro);
+ }
+
+
+/* computes a servicegroup macro */
+int grab_standard_servicegroup_macro_r(nagios_macros *mac, int macro_type, servicegroup *temp_servicegroup, char **output) {
+ servicesmember *temp_servicesmember = NULL;
+ char *temp_buffer = NULL;
+ unsigned int temp_len = 0;
+ unsigned int init_len = 0;
+
+ if(temp_servicegroup == NULL || output == NULL)
+ return ERROR;
+
+ /* get the macro value */
+ switch(macro_type) {
+ case MACRO_SERVICEGROUPNAME:
+ *output = (char *)strdup(temp_servicegroup->group_name);
+ break;
+ case MACRO_SERVICEGROUPALIAS:
+ if(temp_servicegroup->alias)
+ *output = (char *)strdup(temp_servicegroup->alias);
+ break;
+ case MACRO_SERVICEGROUPMEMBERS:
+ /* make the calculations for total string length */
+ for(temp_servicesmember = temp_servicegroup->members; temp_servicesmember != NULL; temp_servicesmember = temp_servicesmember->next) {
+ if(temp_servicesmember->host_name == NULL || temp_servicesmember->service_description == NULL)
+ continue;
+ if(temp_len == 0) {
+ temp_len += strlen(temp_servicesmember->host_name) + strlen(temp_servicesmember->service_description) + 2;
+ }
+ else {
+ temp_len += strlen(temp_servicesmember->host_name) + strlen(temp_servicesmember->service_description) + 3;
+ }
+ }
+ /* allocate or reallocate the memory buffer */
+ if(*output == NULL) {
+ *output = (char *)malloc(temp_len);
+ }
+ else {
+ init_len = strlen(*output);
+ temp_len += init_len;
+ *output = (char *)realloc(*output, temp_len);
+ }
+ /* now fill in the string with the group members */
+ for(temp_servicesmember = temp_servicegroup->members; temp_servicesmember != NULL; temp_servicesmember = temp_servicesmember->next) {
+ if(temp_servicesmember->host_name == NULL || temp_servicesmember->service_description == NULL)
+ continue;
+ temp_buffer = *output + init_len;
+ if(init_len == 0) { /* If our buffer didn't contain anything, we just need to write "%s,%s" */
+ init_len += sprintf(temp_buffer, "%s,%s", temp_servicesmember->host_name, temp_servicesmember->service_description);
+ }
+ else { /* Now we need to write ",%s,%s" */
+ init_len += sprintf(temp_buffer, ",%s,%s", temp_servicesmember->host_name, temp_servicesmember->service_description);
+ }
+ }
+ break;
+ case MACRO_SERVICEGROUPACTIONURL:
+ if(temp_servicegroup->action_url)
+ *output = (char *)strdup(temp_servicegroup->action_url);
+ break;
+ case MACRO_SERVICEGROUPNOTESURL:
+ if(temp_servicegroup->notes_url)
+ *output = (char *)strdup(temp_servicegroup->notes_url);
+ break;
+ case MACRO_SERVICEGROUPNOTES:
+ if(temp_servicegroup->notes)
+ *output = (char *)strdup(temp_servicegroup->notes);
+ break;
+ default:
+ log_debug_info(DEBUGL_MACROS, 0, "UNHANDLED SERVICEGROUP MACRO #%d! THIS IS A BUG!\n", macro_type);
+ return ERROR;
+ }
+
+ /* post-processing */
+ /* notes, notes URL and action URL macros may themselves contain macros, so process them... */
+ switch(macro_type) {
+ case MACRO_SERVICEGROUPACTIONURL:
+ case MACRO_SERVICEGROUPNOTESURL:
+ process_macros_r(mac, *output, &temp_buffer, URL_ENCODE_MACRO_CHARS);
+ my_free(*output);
+ *output = temp_buffer;
+ break;
+ case MACRO_SERVICEGROUPNOTES:
+ process_macros_r(mac, *output, &temp_buffer, 0);
+ my_free(*output);
+ *output = temp_buffer;
+ break;
+ default:
+ break;
+ }
+
+ return OK;
+ }
+
+int grab_standard_servicegroup_macro(int macro_type, servicegroup *temp_servicegroup, char **output) {
+ return grab_standard_servicegroup_macro_r(&global_macros, macro_type, temp_servicegroup, output);
+ }
+
+
+/* computes a contact macro */
+int grab_standard_contact_macro_r(nagios_macros *mac, int macro_type, contact *temp_contact, char **output) {
+#ifdef NSCORE
+ contactgroup *temp_contactgroup = NULL;
+ objectlist *temp_objectlist = NULL;
+ char *buf1 = NULL;
+ char *buf2 = NULL;
+#endif
+
+ if(temp_contact == NULL || output == NULL)
+ return ERROR;
+
+ /* get the macro value */
+ switch(macro_type) {
+ case MACRO_CONTACTNAME:
+ *output = (char *)strdup(temp_contact->name);
+ break;
+ case MACRO_CONTACTALIAS:
+ *output = (char *)strdup(temp_contact->alias);
+ break;
+ case MACRO_CONTACTEMAIL:
+ if(temp_contact->email)
+ *output = (char *)strdup(temp_contact->email);
+ break;
+ case MACRO_CONTACTPAGER:
+ if(temp_contact->pager)
+ *output = (char *)strdup(temp_contact->pager);
+ break;
+#ifdef NSCORE
+ case MACRO_CONTACTGROUPNAMES:
+ /* get the contactgroup names */
+ /* find all contactgroups this contact is a member of */
+ for(temp_objectlist = temp_contact->contactgroups_ptr; temp_objectlist != NULL; temp_objectlist = temp_objectlist->next) {
+
+ if((temp_contactgroup = (contactgroup *)temp_objectlist->object_ptr) == NULL)
+ continue;
+
+ asprintf(&buf1, "%s%s%s", (buf2) ? buf2 : "", (buf2) ? "," : "", temp_contactgroup->group_name);
+ my_free(buf2);
+ buf2 = buf1;
+ }
+ if(buf2) {
+ *output = (char *)strdup(buf2);
+ my_free(buf2);
+ }
+ break;
+#endif
+ default:
+ log_debug_info(DEBUGL_MACROS, 0, "UNHANDLED CONTACT MACRO #%d! THIS IS A BUG!\n", macro_type);
+ return ERROR;
+ }
+
+ return OK;
+ }
+
+int grab_standard_contact_macro(int macro_type, contact *temp_contact, char **output) {
+ return grab_standard_contact_macro_r(&global_macros, macro_type, temp_contact, output);
+ }
+
+
+/* computes a contact address macro */
+int grab_contact_address_macro(int macro_num, contact *temp_contact, char **output) {
+ if(macro_num < 0 || macro_num >= MAX_CONTACT_ADDRESSES)
+ return ERROR;
+
+ if(temp_contact == NULL || output == NULL)
+ return ERROR;
+
+ /* get the macro */
+ if(temp_contact->address[macro_num])
+ *output = temp_contact->address[macro_num];
+
+ return OK;
+ }
+
+
+
+/* computes a contactgroup macro */
+int grab_standard_contactgroup_macro(int macro_type, contactgroup *temp_contactgroup, char **output) {
+ contactsmember *temp_contactsmember = NULL;
+
+ if(temp_contactgroup == NULL || output == NULL)
+ return ERROR;
+
+ /* get the macro value */
+ switch(macro_type) {
+ case MACRO_CONTACTGROUPNAME:
+ *output = (char *)strdup(temp_contactgroup->group_name);
+ break;
+ case MACRO_CONTACTGROUPALIAS:
+ if(temp_contactgroup->alias)
+ *output = (char *)strdup(temp_contactgroup->alias);
+ break;
+ case MACRO_CONTACTGROUPMEMBERS:
+ /* get the member list */
+ for(temp_contactsmember = temp_contactgroup->members; temp_contactsmember != NULL; temp_contactsmember = temp_contactsmember->next) {
+ if(temp_contactsmember->contact_name == NULL)
+ continue;
+ if(*output == NULL)
+ *output = (char *)strdup(temp_contactsmember->contact_name);
+ else if((*output = (char *)realloc(*output, strlen(*output) + strlen(temp_contactsmember->contact_name) + 2))) {
+ strcat(*output, ",");
+ strcat(*output, temp_contactsmember->contact_name);
+ }
+ }
+ break;
+ default:
+ log_debug_info(DEBUGL_MACROS, 0, "UNHANDLED CONTACTGROUP MACRO #%d! THIS IS A BUG!\n", macro_type);
+ return ERROR;
+ }
+
+ return OK;
+ }
+
+
+/* computes a custom object macro */
+int grab_custom_object_macro_r(nagios_macros *mac, char *macro_name, customvariablesmember *vars, char **output) {
+ customvariablesmember *temp_customvariablesmember = NULL;
+ int result = ERROR;
+
+ if(macro_name == NULL || vars == NULL || output == NULL)
+ return ERROR;
+
+ /* get the custom variable */
+ for(temp_customvariablesmember = vars; temp_customvariablesmember != NULL; temp_customvariablesmember = temp_customvariablesmember->next) {
+
+ if(temp_customvariablesmember->variable_name == NULL)
+ continue;
+
+ if(!strcmp(macro_name, temp_customvariablesmember->variable_name)) {
+ if(temp_customvariablesmember->variable_value)
+ *output = (char *)strdup(temp_customvariablesmember->variable_value);
+ result = OK;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+int grab_custom_object_macro(char *macro_name, customvariablesmember *vars, char **output) {
+ return grab_custom_object_macro_r(&global_macros, macro_name, vars, output);
+ }
+
+
+/******************************************************************/
+/********************* MACRO STRING FUNCTIONS *********************/
+/******************************************************************/
+
+/* cleans illegal characters in macros before output */
+char *clean_macro_chars(char *macro, int options) {
+ register int x = 0;
+ register int y = 0;
+ register int z = 0;
+ register int ch = 0;
+ register int len = 0;
+ register int illegal_char = 0;
+
+ if(macro == NULL)
+ return "";
+
+ len = (int)strlen(macro);
+
+ /* strip illegal characters out of macro */
+ if(options & STRIP_ILLEGAL_MACRO_CHARS) {
+
+ for(y = 0, x = 0; x < len; x++) {
+
+ /*ch=(int)macro[x];*/
+ /* allow non-ASCII characters (Japanese, etc) */
+ ch = macro[x] & 0xff;
+
+ /* illegal ASCII characters */
+ if(ch < 32 || ch == 127)
+ continue;
+
+ /* illegal user-specified characters */
+ illegal_char = FALSE;
+ if(illegal_output_chars != NULL) {
+ for(z = 0; illegal_output_chars[z] != '\x0'; z++) {
+ if(ch == (int)illegal_output_chars[z]) {
+ illegal_char = TRUE;
+ break;
+ }
+ }
+ }
+
+ if(illegal_char == FALSE)
+ macro[y++] = macro[x];
+ }
+
+ macro[y++] = '\x0';
+ }
+
+#ifdef ON_HOLD_FOR_NOW
+ /* escape nasty character in macro */
+ if(options & ESCAPE_MACRO_CHARS) {
+ }
+#endif
+
+ return macro;
+ }
+
+
+
+/* encodes a string in proper URL format */
+char *get_url_encoded_string(char *input) {
+ register int x = 0;
+ register int y = 0;
+ char *encoded_url_string = NULL;
+ char temp_expansion[6] = "";
+
+
+ /* bail if no input */
+ if(input == NULL)
+ return NULL;
+
+ /* allocate enough memory to escape all characters if necessary */
+ if((encoded_url_string = (char *)malloc((strlen(input) * 3) + 1)) == NULL)
+ return NULL;
+
+ /* check/encode all characters */
+ for(x = 0, y = 0; input[x] != (char)'\x0'; x++) {
+
+ /* alpha-numeric characters and a few other characters don't get encoded */
+ if(((char)input[x] >= '0' && (char)input[x] <= '9') || ((char)input[x] >= 'A' && (char)input[x] <= 'Z') || ((char)input[x] >= (char)'a' && (char)input[x] <= (char)'z') || (char)input[x] == (char)'.' || (char)input[x] == (char)'-' || (char)input[x] == (char)'_' || (char)input[x] == (char)':' || (char)input[x] == (char)'/' || (char)input[x] == (char)'?' || (char)input[x] == (char)'=' || (char)input[x] == (char)'&') {
+ encoded_url_string[y] = input[x];
+ y++;
+ }
+
+ /* spaces are pluses */
+ else if((char)input[x] <= (char)' ') {
+ encoded_url_string[y] = '+';
+ y++;
+ }
+
+ /* anything else gets represented by its hex value */
+ else {
+ encoded_url_string[y] = '\x0';
+ sprintf(temp_expansion, "%%%02X", (unsigned int)(input[x] & 0xFF));
+ strcat(encoded_url_string, temp_expansion);
+ y += 3;
+ }
+ }
+
+ /* terminate encoded string */
+ encoded_url_string[y] = '\x0';
+
+ return encoded_url_string;
+ }
+
+
+static int macro_key_cmp(const void *a_, const void *b_) {
+ struct macro_key_code *a = (struct macro_key_code *)a_;
+ struct macro_key_code *b = (struct macro_key_code *)b_;
+
+ return strcmp(a->name, b->name);
+ }
+
+
+/******************************************************************/
+/***************** MACRO INITIALIZATION FUNCTIONS *****************/
+/******************************************************************/
+
+/* initializes global macros */
+int init_macros(void) {
+ init_macrox_names();
+ int x;
+
+ /*
+ * non-volatile macros are free()'d when they're set.
+ * We must do this in order to not lose the constant
+ * ones when we get SIGHUP or a RESTART_PROGRAM event
+ * from the command fifo. Otherwise a memset() would
+ * have been better.
+ */
+ clear_volatile_macros_r(&global_macros);
+
+ /* backwards compatibility hack */
+ macro_x = global_macros.x;
+
+ /*
+ * Now build an ordered list of X macro names so we can
+ * do binary lookups later and avoid a ton of strcmp()'s
+ * for each and every check that gets run. A hash table
+ * is actually slower, since the most frequently used
+ * keys are so long and a binary lookup is completed in
+ * 7 steps for up to ~200 keys, worst case.
+ */
+ for(x = 0; x < MACRO_X_COUNT; x++) {
+ macro_keys[x].code = x;
+ macro_keys[x].name = macro_x_names[x];
+ macro_keys[x].clean_options = 0;
+
+ /* host/service output/perfdata and author/comment macros should get cleaned */
+ if((x >= 16 && x <= 19) || (x >= 49 && x <= 52) || (x >= 99 && x <= 100) || (x >= 124 && x <= 127)) {
+ macro_keys[x].clean_options = (STRIP_ILLEGAL_MACRO_CHARS | ESCAPE_MACRO_CHARS);
+ }
+ /* url macros should get cleaned */
+ if((x >= 125 && x <= 126) || (x >= 128 && x <= 129) || (x >= 77 && x <= 78) || (x >= 74 && x <= 75)) {
+ macro_keys[x].clean_options = URL_ENCODE_MACRO_CHARS;
+ }
+ }
+
+ qsort(macro_keys, x, sizeof(struct macro_key_code), macro_key_cmp);
+ return OK;
+ }
+
+/*
+ * initializes the names of macros, using this nifty little macro
+ * which ensures we never add any typos to the list
+ */
+#define add_macrox_name(name) macro_x_names[MACRO_##name] = strdup(#name)
+int init_macrox_names(void) {
+ register int x = 0;
+
+ /* initialize macro names */
+ for(x = 0; x < MACRO_X_COUNT; x++)
+ macro_x_names[x] = NULL;
+
+ /* initialize each macro name */
+ add_macrox_name(HOSTNAME);
+ add_macrox_name(HOSTALIAS);
+ add_macrox_name(HOSTADDRESS);
+ add_macrox_name(SERVICEDESC);
+ add_macrox_name(SERVICESTATE);
+ add_macrox_name(SERVICESTATEID);
+ add_macrox_name(SERVICEATTEMPT);
+ add_macrox_name(SERVICEISVOLATILE);
+ add_macrox_name(LONGDATETIME);
+ add_macrox_name(SHORTDATETIME);
+ add_macrox_name(DATE);
+ add_macrox_name(TIME);
+ add_macrox_name(TIMET);
+ add_macrox_name(LASTHOSTCHECK);
+ add_macrox_name(LASTSERVICECHECK);
+ add_macrox_name(LASTHOSTSTATECHANGE);
+ add_macrox_name(LASTSERVICESTATECHANGE);
+ add_macrox_name(HOSTOUTPUT);
+ add_macrox_name(SERVICEOUTPUT);
+ add_macrox_name(HOSTPERFDATA);
+ add_macrox_name(SERVICEPERFDATA);
+ add_macrox_name(CONTACTNAME);
+ add_macrox_name(CONTACTALIAS);
+ add_macrox_name(CONTACTEMAIL);
+ add_macrox_name(CONTACTPAGER);
+ add_macrox_name(ADMINEMAIL);
+ add_macrox_name(ADMINPAGER);
+ add_macrox_name(HOSTSTATE);
+ add_macrox_name(HOSTSTATEID);
+ add_macrox_name(HOSTATTEMPT);
+ add_macrox_name(NOTIFICATIONTYPE);
+ add_macrox_name(NOTIFICATIONNUMBER);
+ add_macrox_name(NOTIFICATIONISESCALATED);
+ add_macrox_name(HOSTEXECUTIONTIME);
+ add_macrox_name(SERVICEEXECUTIONTIME);
+ add_macrox_name(HOSTLATENCY);
+ add_macrox_name(SERVICELATENCY);
+ add_macrox_name(HOSTDURATION);
+ add_macrox_name(SERVICEDURATION);
+ add_macrox_name(HOSTDURATIONSEC);
+ add_macrox_name(SERVICEDURATIONSEC);
+ add_macrox_name(HOSTDOWNTIME);
+ add_macrox_name(SERVICEDOWNTIME);
+ add_macrox_name(HOSTSTATETYPE);
+ add_macrox_name(SERVICESTATETYPE);
+ add_macrox_name(HOSTPERCENTCHANGE);
+ add_macrox_name(SERVICEPERCENTCHANGE);
+ add_macrox_name(HOSTGROUPNAME);
+ add_macrox_name(HOSTGROUPALIAS);
+ add_macrox_name(SERVICEGROUPNAME);
+ add_macrox_name(SERVICEGROUPALIAS);
+ add_macrox_name(HOSTACKAUTHOR);
+ add_macrox_name(HOSTACKCOMMENT);
+ add_macrox_name(SERVICEACKAUTHOR);
+ add_macrox_name(SERVICEACKCOMMENT);
+ add_macrox_name(LASTSERVICEOK);
+ add_macrox_name(LASTSERVICEWARNING);
+ add_macrox_name(LASTSERVICEUNKNOWN);
+ add_macrox_name(LASTSERVICECRITICAL);
+ add_macrox_name(LASTHOSTUP);
+ add_macrox_name(LASTHOSTDOWN);
+ add_macrox_name(LASTHOSTUNREACHABLE);
+ add_macrox_name(SERVICECHECKCOMMAND);
+ add_macrox_name(HOSTCHECKCOMMAND);
+ add_macrox_name(MAINCONFIGFILE);
+ add_macrox_name(STATUSDATAFILE);
+ add_macrox_name(HOSTDISPLAYNAME);
+ add_macrox_name(SERVICEDISPLAYNAME);
+ add_macrox_name(RETENTIONDATAFILE);
+ add_macrox_name(OBJECTCACHEFILE);
+ add_macrox_name(TEMPFILE);
+ add_macrox_name(LOGFILE);
+ add_macrox_name(RESOURCEFILE);
+ add_macrox_name(COMMANDFILE);
+ add_macrox_name(HOSTPERFDATAFILE);
+ add_macrox_name(SERVICEPERFDATAFILE);
+ add_macrox_name(HOSTACTIONURL);
+ add_macrox_name(HOSTNOTESURL);
+ add_macrox_name(HOSTNOTES);
+ add_macrox_name(SERVICEACTIONURL);
+ add_macrox_name(SERVICENOTESURL);
+ add_macrox_name(SERVICENOTES);
+ add_macrox_name(TOTALHOSTSUP);
+ add_macrox_name(TOTALHOSTSDOWN);
+ add_macrox_name(TOTALHOSTSUNREACHABLE);
+ add_macrox_name(TOTALHOSTSDOWNUNHANDLED);
+ add_macrox_name(TOTALHOSTSUNREACHABLEUNHANDLED);
+ add_macrox_name(TOTALHOSTPROBLEMS);
+ add_macrox_name(TOTALHOSTPROBLEMSUNHANDLED);
+ add_macrox_name(TOTALSERVICESOK);
+ add_macrox_name(TOTALSERVICESWARNING);
+ add_macrox_name(TOTALSERVICESCRITICAL);
+ add_macrox_name(TOTALSERVICESUNKNOWN);
+ add_macrox_name(TOTALSERVICESWARNINGUNHANDLED);
+ add_macrox_name(TOTALSERVICESCRITICALUNHANDLED);
+ add_macrox_name(TOTALSERVICESUNKNOWNUNHANDLED);
+ add_macrox_name(TOTALSERVICEPROBLEMS);
+ add_macrox_name(TOTALSERVICEPROBLEMSUNHANDLED);
+ add_macrox_name(PROCESSSTARTTIME);
+ add_macrox_name(HOSTCHECKTYPE);
+ add_macrox_name(SERVICECHECKTYPE);
+ add_macrox_name(LONGHOSTOUTPUT);
+ add_macrox_name(LONGSERVICEOUTPUT);
+ add_macrox_name(TEMPPATH);
+ add_macrox_name(HOSTNOTIFICATIONNUMBER);
+ add_macrox_name(SERVICENOTIFICATIONNUMBER);
+ add_macrox_name(HOSTNOTIFICATIONID);
+ add_macrox_name(SERVICENOTIFICATIONID);
+ add_macrox_name(HOSTEVENTID);
+ add_macrox_name(LASTHOSTEVENTID);
+ add_macrox_name(SERVICEEVENTID);
+ add_macrox_name(LASTSERVICEEVENTID);
+ add_macrox_name(HOSTGROUPNAMES);
+ add_macrox_name(SERVICEGROUPNAMES);
+ add_macrox_name(HOSTACKAUTHORNAME);
+ add_macrox_name(HOSTACKAUTHORALIAS);
+ add_macrox_name(SERVICEACKAUTHORNAME);
+ add_macrox_name(SERVICEACKAUTHORALIAS);
+ add_macrox_name(MAXHOSTATTEMPTS);
+ add_macrox_name(MAXSERVICEATTEMPTS);
+ add_macrox_name(TOTALHOSTSERVICES);
+ add_macrox_name(TOTALHOSTSERVICESOK);
+ add_macrox_name(TOTALHOSTSERVICESWARNING);
+ add_macrox_name(TOTALHOSTSERVICESUNKNOWN);
+ add_macrox_name(TOTALHOSTSERVICESCRITICAL);
+ add_macrox_name(HOSTGROUPNOTES);
+ add_macrox_name(HOSTGROUPNOTESURL);
+ add_macrox_name(HOSTGROUPACTIONURL);
+ add_macrox_name(SERVICEGROUPNOTES);
+ add_macrox_name(SERVICEGROUPNOTESURL);
+ add_macrox_name(SERVICEGROUPACTIONURL);
+ add_macrox_name(HOSTGROUPMEMBERS);
+ add_macrox_name(SERVICEGROUPMEMBERS);
+ add_macrox_name(CONTACTGROUPNAME);
+ add_macrox_name(CONTACTGROUPALIAS);
+ add_macrox_name(CONTACTGROUPMEMBERS);
+ add_macrox_name(CONTACTGROUPNAMES);
+ add_macrox_name(NOTIFICATIONRECIPIENTS);
+ add_macrox_name(NOTIFICATIONAUTHOR);
+ add_macrox_name(NOTIFICATIONAUTHORNAME);
+ add_macrox_name(NOTIFICATIONAUTHORALIAS);
+ add_macrox_name(NOTIFICATIONCOMMENT);
+ add_macrox_name(EVENTSTARTTIME);
+ add_macrox_name(HOSTPROBLEMID);
+ add_macrox_name(LASTHOSTPROBLEMID);
+ add_macrox_name(SERVICEPROBLEMID);
+ add_macrox_name(LASTSERVICEPROBLEMID);
+ add_macrox_name(ISVALIDTIME);
+ add_macrox_name(NEXTVALIDTIME);
+ add_macrox_name(LASTHOSTSTATE);
+ add_macrox_name(LASTHOSTSTATEID);
+ add_macrox_name(LASTSERVICESTATE);
+ add_macrox_name(LASTSERVICESTATEID);
+
+ return OK;
+ }
+
+
+/******************************************************************/
+/********************* MACRO CLEANUP FUNCTIONS ********************/
+/******************************************************************/
+
+/* free memory associated with the macrox names */
+int free_macrox_names(void) {
+ register int x = 0;
+
+ /* free each macro name */
+ for(x = 0; x < MACRO_X_COUNT; x++)
+ my_free(macro_x_names[x]);
+
+ return OK;
+ }
+
+
+
+/* clear argv macros - used in commands */
+int clear_argv_macros_r(nagios_macros *mac) {
+ register int x = 0;
+
+ /* command argument macros */
+ for(x = 0; x < MAX_COMMAND_ARGUMENTS; x++)
+ my_free(mac->argv[x]);
+
+ return OK;
+ }
+
+int clear_argv_macros(void) {
+ return clear_argv_macros_r(&global_macros);
+ }
+
+/*
+ * copies non-volatile macros from global macro_x to **dest, which
+ * must be large enough to hold at least MACRO_X_COUNT entries.
+ * We use a shortlived macro to save up on typing
+ */
+#define cp_macro(name) dest[MACRO_##name] = global_macros.x[MACRO_##name]
+void copy_constant_macros(char **dest) {
+ cp_macro(ADMINEMAIL);
+ cp_macro(ADMINPAGER);
+ cp_macro(MAINCONFIGFILE);
+ cp_macro(STATUSDATAFILE);
+ cp_macro(RETENTIONDATAFILE);
+ cp_macro(OBJECTCACHEFILE);
+ cp_macro(TEMPFILE);
+ cp_macro(LOGFILE);
+ cp_macro(RESOURCEFILE);
+ cp_macro(COMMANDFILE);
+ cp_macro(HOSTPERFDATAFILE);
+ cp_macro(SERVICEPERFDATAFILE);
+ cp_macro(PROCESSSTARTTIME);
+ cp_macro(TEMPPATH);
+ cp_macro(EVENTSTARTTIME);
+ }
+#undef cp_macro
+
+/* clear all macros that are not "constant" (i.e. they change throughout the course of monitoring) */
+int clear_volatile_macros_r(nagios_macros *mac) {
+ customvariablesmember *this_customvariablesmember = NULL;
+ customvariablesmember *next_customvariablesmember = NULL;
+ register int x = 0;
+
+ for(x = 0; x < MACRO_X_COUNT; x++) {
+ switch(x) {
+
+ case MACRO_ADMINEMAIL:
+ case MACRO_ADMINPAGER:
+ case MACRO_MAINCONFIGFILE:
+ case MACRO_STATUSDATAFILE:
+ case MACRO_RETENTIONDATAFILE:
+ case MACRO_OBJECTCACHEFILE:
+ case MACRO_TEMPFILE:
+ case MACRO_LOGFILE:
+ case MACRO_RESOURCEFILE:
+ case MACRO_COMMANDFILE:
+ case MACRO_HOSTPERFDATAFILE:
+ case MACRO_SERVICEPERFDATAFILE:
+ case MACRO_PROCESSSTARTTIME:
+ case MACRO_TEMPPATH:
+ case MACRO_EVENTSTARTTIME:
+ /* these don't change during the course of monitoring, so no need to free them */
+ break;
+ default:
+ my_free(mac->x[x]);
+ break;
+ }
+ }
+
+ /* contact address macros */
+ for(x = 0; x < MAX_CONTACT_ADDRESSES; x++)
+ my_free(mac->contactaddress[x]);
+
+ /* clear macro pointers */
+ mac->host_ptr = NULL;
+ mac->hostgroup_ptr = NULL;
+ mac->service_ptr = NULL;
+ mac->servicegroup_ptr = NULL;
+ mac->contact_ptr = NULL;
+ mac->contactgroup_ptr = NULL;
+
+ /* clear on-demand macro */
+ my_free(mac->ondemand);
+
+ /* clear ARGx macros */
+ clear_argv_macros_r(mac);
+
+ /* clear custom host variables */
+ for(this_customvariablesmember = mac->custom_host_vars; this_customvariablesmember != NULL; this_customvariablesmember = next_customvariablesmember) {
+ next_customvariablesmember = this_customvariablesmember->next;
+ my_free(this_customvariablesmember->variable_name);
+ my_free(this_customvariablesmember->variable_value);
+ my_free(this_customvariablesmember);
+ }
+ mac->custom_host_vars = NULL;
+
+ /* clear custom service variables */
+ for(this_customvariablesmember = mac->custom_service_vars; this_customvariablesmember != NULL; this_customvariablesmember = next_customvariablesmember) {
+ next_customvariablesmember = this_customvariablesmember->next;
+ my_free(this_customvariablesmember->variable_name);
+ my_free(this_customvariablesmember->variable_value);
+ my_free(this_customvariablesmember);
+ }
+ mac->custom_service_vars = NULL;
+
+ /* clear custom contact variables */
+ for(this_customvariablesmember = mac->custom_contact_vars; this_customvariablesmember != NULL; this_customvariablesmember = next_customvariablesmember) {
+ next_customvariablesmember = this_customvariablesmember->next;
+ my_free(this_customvariablesmember->variable_name);
+ my_free(this_customvariablesmember->variable_value);
+ my_free(this_customvariablesmember);
+ }
+ mac->custom_contact_vars = NULL;
+
+ return OK;
+ }
+
+
+int clear_volatile_macros(void) {
+ return clear_volatile_macros_r(&global_macros);
+ }
+
+
+/* clear service macros */
+int clear_service_macros_r(nagios_macros *mac) {
+ customvariablesmember *this_customvariablesmember = NULL;
+ customvariablesmember *next_customvariablesmember = NULL;
+
+ /* FIXME: strings. make these not be strdup()'s anymore */
+ my_free(mac->x[MACRO_SERVICEDESC]);
+ my_free(mac->x[MACRO_SERVICEDISPLAYNAME]);
+ my_free(mac->x[MACRO_SERVICEOUTPUT]);
+ my_free(mac->x[MACRO_LONGSERVICEOUTPUT]);
+ my_free(mac->x[MACRO_SERVICEPERFDATA]);
+
+ /* these are recursive but persistent. what to do? */
+ my_free(mac->x[MACRO_SERVICECHECKCOMMAND]);
+ my_free(mac->x[MACRO_SERVICEACTIONURL]);
+ my_free(mac->x[MACRO_SERVICENOTESURL]);
+ my_free(mac->x[MACRO_SERVICENOTES]);
+
+ my_free(mac->x[MACRO_SERVICECHECKTYPE]);
+ my_free(mac->x[MACRO_SERVICESTATETYPE]);
+ my_free(mac->x[MACRO_SERVICESTATE]);
+ my_free(mac->x[MACRO_SERVICEISVOLATILE]);
+ my_free(mac->x[MACRO_SERVICESTATEID]);
+ my_free(mac->x[MACRO_SERVICEATTEMPT]);
+ my_free(mac->x[MACRO_MAXSERVICEATTEMPTS]);
+ my_free(mac->x[MACRO_SERVICEEXECUTIONTIME]);
+ my_free(mac->x[MACRO_SERVICELATENCY]);
+ my_free(mac->x[MACRO_LASTSERVICECHECK]);
+ my_free(mac->x[MACRO_LASTSERVICESTATECHANGE]);
+ my_free(mac->x[MACRO_LASTSERVICEOK]);
+ my_free(mac->x[MACRO_LASTSERVICEWARNING]);
+ my_free(mac->x[MACRO_LASTSERVICEUNKNOWN]);
+ my_free(mac->x[MACRO_LASTSERVICECRITICAL]);
+ my_free(mac->x[MACRO_SERVICEDOWNTIME]);
+ my_free(mac->x[MACRO_SERVICEPERCENTCHANGE]);
+ my_free(mac->x[MACRO_SERVICEDURATIONSEC]);
+ my_free(mac->x[MACRO_SERVICEDURATION]);
+ my_free(mac->x[MACRO_SERVICENOTIFICATIONNUMBER]);
+ my_free(mac->x[MACRO_SERVICENOTIFICATIONID]);
+ my_free(mac->x[MACRO_SERVICEEVENTID]);
+ my_free(mac->x[MACRO_LASTSERVICEEVENTID]);
+ my_free(mac->x[MACRO_SERVICEGROUPNAMES]);
+ my_free(mac->x[MACRO_SERVICEPROBLEMID]);
+ my_free(mac->x[MACRO_LASTSERVICEPROBLEMID]);
+
+ /* clear custom service variables */
+ for(this_customvariablesmember = mac->custom_service_vars; this_customvariablesmember != NULL; this_customvariablesmember = next_customvariablesmember) {
+ next_customvariablesmember = this_customvariablesmember->next;
+ my_free(this_customvariablesmember->variable_name);
+ my_free(this_customvariablesmember->variable_value);
+ my_free(this_customvariablesmember);
+ }
+ mac->custom_service_vars = NULL;
+
+ /* clear pointers */
+ mac->service_ptr = NULL;
+
+ return OK;
+ }
+
+int clear_service_macros(void) {
+ return clear_service_macros_r(&global_macros);
+ }
+
+/* clear host macros */
+int clear_host_macros_r(nagios_macros *mac) {
+ customvariablesmember *this_customvariablesmember = NULL;
+ customvariablesmember *next_customvariablesmember = NULL;
+
+ /* FIXME: strings; Fix these to not be strdup()'s anymore */
+ my_free(mac->x[MACRO_HOSTNAME]);
+ my_free(mac->x[MACRO_HOSTDISPLAYNAME]);
+ my_free(mac->x[MACRO_HOSTALIAS]);
+ my_free(mac->x[MACRO_HOSTADDRESS]);
+ my_free(mac->x[MACRO_HOSTOUTPUT]);
+ my_free(mac->x[MACRO_LONGHOSTOUTPUT]);
+ my_free(mac->x[MACRO_HOSTPERFDATA]);
+
+ /* these are recursive but persistent. what to do? */
+ my_free(mac->x[MACRO_HOSTCHECKCOMMAND]);
+ my_free(mac->x[MACRO_HOSTACTIONURL]);
+ my_free(mac->x[MACRO_HOSTNOTESURL]);
+ my_free(mac->x[MACRO_HOSTNOTES]);
+
+ /* numbers or by necessity autogenerated strings */
+ my_free(mac->x[MACRO_HOSTSTATE]);
+ my_free(mac->x[MACRO_HOSTSTATEID]);
+ my_free(mac->x[MACRO_HOSTCHECKTYPE]);
+ my_free(mac->x[MACRO_HOSTSTATETYPE]);
+ my_free(mac->x[MACRO_HOSTATTEMPT]);
+ my_free(mac->x[MACRO_MAXHOSTATTEMPTS]);
+ my_free(mac->x[MACRO_HOSTDOWNTIME]);
+ my_free(mac->x[MACRO_HOSTPERCENTCHANGE]);
+ my_free(mac->x[MACRO_HOSTDURATIONSEC]);
+ my_free(mac->x[MACRO_HOSTDURATION]);
+ my_free(mac->x[MACRO_HOSTEXECUTIONTIME]);
+ my_free(mac->x[MACRO_HOSTLATENCY]);
+ my_free(mac->x[MACRO_LASTHOSTCHECK]);
+ my_free(mac->x[MACRO_LASTHOSTSTATECHANGE]);
+ my_free(mac->x[MACRO_LASTHOSTUP]);
+ my_free(mac->x[MACRO_LASTHOSTDOWN]);
+ my_free(mac->x[MACRO_LASTHOSTUNREACHABLE]);
+ my_free(mac->x[MACRO_HOSTNOTIFICATIONNUMBER]);
+ my_free(mac->x[MACRO_HOSTNOTIFICATIONID]);
+ my_free(mac->x[MACRO_HOSTEVENTID]);
+ my_free(mac->x[MACRO_LASTHOSTEVENTID]);
+ my_free(mac->x[MACRO_HOSTGROUPNAMES]);
+ my_free(mac->x[MACRO_TOTALHOSTSERVICES]);
+ my_free(mac->x[MACRO_TOTALHOSTSERVICESOK]);
+ my_free(mac->x[MACRO_TOTALHOSTSERVICESWARNING]);
+ my_free(mac->x[MACRO_TOTALHOSTSERVICESUNKNOWN]);
+ my_free(mac->x[MACRO_TOTALHOSTSERVICESCRITICAL]);
+ my_free(mac->x[MACRO_HOSTPROBLEMID]);
+ my_free(mac->x[MACRO_LASTHOSTPROBLEMID]);
+
+
+ /* clear custom host variables */
+ for(this_customvariablesmember = mac->custom_host_vars; this_customvariablesmember != NULL; this_customvariablesmember = next_customvariablesmember) {
+ next_customvariablesmember = this_customvariablesmember->next;
+ my_free(this_customvariablesmember->variable_name);
+ my_free(this_customvariablesmember->variable_value);
+ my_free(this_customvariablesmember);
+ }
+ mac->custom_host_vars = NULL;
+
+ /* clear pointers */
+ mac->host_ptr = NULL;
+
+ return OK;
+ }
+
+int clear_host_macros(void) {
+ return clear_host_macros_r(&global_macros);
+ }
+
+
+/* clear hostgroup macros */
+int clear_hostgroup_macros_r(nagios_macros *mac) {
+ /* FIXME: make these not strdup()'s */
+ my_free(mac->x[MACRO_HOSTGROUPNAME]);
+ my_free(mac->x[MACRO_HOSTGROUPALIAS]);
+
+ /* generated but persistent. what to do? */
+ my_free(mac->x[MACRO_HOSTGROUPACTIONURL]);
+ my_free(mac->x[MACRO_HOSTGROUPNOTESURL]);
+ my_free(mac->x[MACRO_HOSTGROUPNOTES]);
+
+ /* generated */
+ my_free(mac->x[MACRO_HOSTGROUPMEMBERS]);
+
+ /* clear pointers */
+ mac->hostgroup_ptr = NULL;
+
+ return OK;
+ }
+
+int clear_hostgroup_macros(void) {
+ return clear_hostgroup_macros_r(&global_macros);
+ }
+
+
+/* clear servicegroup macros */
+int clear_servicegroup_macros_r(nagios_macros *mac) {
+ /* FIXME: these should not be strdup()'s */
+ my_free(mac->x[MACRO_SERVICEGROUPNAME]);
+ my_free(mac->x[MACRO_SERVICEGROUPALIAS]);
+
+ /* generated but persistent. what to do? */
+ my_free(mac->x[MACRO_SERVICEGROUPACTIONURL]);
+ my_free(mac->x[MACRO_SERVICEGROUPNOTESURL]);
+ my_free(mac->x[MACRO_SERVICEGROUPNOTES]);
+
+ /* generated */
+ my_free(mac->x[MACRO_SERVICEGROUPMEMBERS]);
+
+ /* clear pointers */
+ mac->servicegroup_ptr = NULL;
+
+ return OK;
+ }
+
+int clear_servicegroup_macros(void) {
+ return clear_servicegroup_macros_r(&global_macros);
+ }
+
+
+/* clear contact macros */
+int clear_contact_macros_r(nagios_macros *mac) {
+ register int x;
+ customvariablesmember *this_customvariablesmember = NULL;
+ customvariablesmember *next_customvariablesmember = NULL;
+
+ /* FIXME: these should not be strdup()'d */
+ my_free(mac->x[MACRO_CONTACTNAME]);
+ my_free(mac->x[MACRO_CONTACTALIAS]);
+ my_free(mac->x[MACRO_CONTACTEMAIL]);
+ my_free(mac->x[MACRO_CONTACTPAGER]);
+
+ /* generated per contact */
+ my_free(mac->x[MACRO_CONTACTGROUPNAMES]);
+
+ /* clear contact addresses */
+ for(x = 0; x < MAX_CONTACT_ADDRESSES; x++)
+ my_free(mac->contactaddress[x]);
+
+ /* clear custom contact variables */
+ for(this_customvariablesmember = mac->custom_contact_vars; this_customvariablesmember != NULL; this_customvariablesmember = next_customvariablesmember) {
+ next_customvariablesmember = this_customvariablesmember->next;
+ my_free(this_customvariablesmember->variable_name);
+ my_free(this_customvariablesmember->variable_value);
+ my_free(this_customvariablesmember);
+ }
+ mac->custom_contact_vars = NULL;
+
+ /* clear pointers */
+ mac->contact_ptr = NULL;
+
+ return OK;
+ }
+
+int clear_contact_macros(void) {
+ return clear_contact_macros_r(&global_macros);
+ }
+
+
+/* clear contactgroup macros */
+int clear_contactgroup_macros_r(nagios_macros *mac) {
+ my_free(mac->x[MACRO_CONTACTGROUPNAME]);
+ my_free(mac->x[MACRO_CONTACTGROUPALIAS]);
+ my_free(mac->x[MACRO_CONTACTGROUPMEMBERS]);
+
+ /* clear pointers */
+ mac->contactgroup_ptr = NULL;
+
+ return OK;
+ }
+
+int clear_contactgroup_macros(void) {
+ return clear_contactgroup_macros_r(&global_macros);
+ }
+
+
+/* clear summary macros */
+int clear_summary_macros_r(nagios_macros *mac) {
+ register int x;
+
+ for(x = MACRO_TOTALHOSTSUP; x <= MACRO_TOTALSERVICEPROBLEMSUNHANDLED; x++)
+ my_free(mac->x[x]);
+
+ return OK;
+ }
+
+int clear_summary_macros(void) {
+ return clear_summary_macros_r(&global_macros);
+ }
+
+
+/******************************************************************/
+/****************** ENVIRONMENT MACRO FUNCTIONS *******************/
+/******************************************************************/
+
+#ifdef NSCORE
+
+/* sets or unsets all macro environment variables */
+int set_all_macro_environment_vars_r(nagios_macros *mac, int set) {
+ if(enable_environment_macros == FALSE)
+ return ERROR;
+
+ set_macrox_environment_vars_r(mac, set);
+ set_argv_macro_environment_vars_r(mac, set);
+ set_custom_macro_environment_vars_r(mac, set);
+ set_contact_address_environment_vars_r(mac, set);
+
+ return OK;
+ }
+
+int set_all_macro_environment_vars(int set) {
+ return set_all_macro_environment_vars_r(&global_macros, set);
+ }
+
+
+/* sets or unsets macrox environment variables */
+int set_macrox_environment_vars_r(nagios_macros *mac, int set) {
+ register int x = 0;
+ int free_macro = FALSE;
+ int generate_macro = TRUE;
+
+ /* set each of the macrox environment variables */
+ for(x = 0; x < MACRO_X_COUNT; x++) {
+
+ free_macro = FALSE;
+
+ /* generate the macro value if it hasn't already been done */
+ /* THIS IS EXPENSIVE */
+ if(set == TRUE) {
+
+ generate_macro = TRUE;
+
+ /* skip summary macro generation if lage installation tweaks are enabled */
+ if((x >= MACRO_TOTALHOSTSUP && x <= MACRO_TOTALSERVICEPROBLEMSUNHANDLED) && use_large_installation_tweaks == TRUE)
+ generate_macro = FALSE;
+
+ if(mac->x[x] == NULL && generate_macro == TRUE)
+ grab_macrox_value_r(mac, x, NULL, NULL, &mac->x[x], &free_macro);
+ }
+
+ /* set the value */
+ set_macro_environment_var(macro_x_names[x], mac->x[x], set);
+ }
+
+ return OK;
+ }
+
+int set_macrox_environment_vars(int set) {
+ return set_macrox_environment_vars_r(&global_macros, set);
+ }
+
+
+/* sets or unsets argv macro environment variables */
+int set_argv_macro_environment_vars_r(nagios_macros *mac, int set) {
+ char *macro_name = NULL;
+ register int x = 0;
+
+ /* set each of the argv macro environment variables */
+ for(x = 0; x < MAX_COMMAND_ARGUMENTS; x++) {
+ asprintf(¯o_name, "ARG%d", x + 1);
+ set_macro_environment_var(macro_name, mac->argv[x], set);
+ my_free(macro_name);
+ }
+
+ return OK;
+ }
+
+int set_argv_macro_environment_vars(int set) {
+ return set_argv_macro_environment_vars_r(&global_macros, set);
+ }
+
+
+/* sets or unsets custom host/service/contact macro environment variables */
+int set_custom_macro_environment_vars_r(nagios_macros *mac, int set) {
+ customvariablesmember *temp_customvariablesmember = NULL;
+ host *temp_host = NULL;
+ service *temp_service = NULL;
+ contact *temp_contact = NULL;
+ char *customvarname = NULL;
+
+ /***** CUSTOM HOST VARIABLES *****/
+ /* generate variables and save them for later */
+ if((temp_host = mac->host_ptr) && set == TRUE) {
+ for(temp_customvariablesmember = temp_host->custom_variables; temp_customvariablesmember != NULL; temp_customvariablesmember = temp_customvariablesmember->next) {
+ asprintf(&customvarname, "_HOST%s", temp_customvariablesmember->variable_name);
+ add_custom_variable_to_object(&mac->custom_host_vars, customvarname, temp_customvariablesmember->variable_value);
+ my_free(customvarname);
+ }
+ }
+ /* set variables */
+ for(temp_customvariablesmember = mac->custom_host_vars; temp_customvariablesmember != NULL; temp_customvariablesmember = temp_customvariablesmember->next) {
+ set_macro_environment_var(temp_customvariablesmember->variable_name, clean_macro_chars(temp_customvariablesmember->variable_value, STRIP_ILLEGAL_MACRO_CHARS | ESCAPE_MACRO_CHARS), set);
+ }
+
+ /***** CUSTOM SERVICE VARIABLES *****/
+ /* generate variables and save them for later */
+ if((temp_service = mac->service_ptr) && set == TRUE) {
+ for(temp_customvariablesmember = temp_service->custom_variables; temp_customvariablesmember != NULL; temp_customvariablesmember = temp_customvariablesmember->next) {
+ asprintf(&customvarname, "_SERVICE%s", temp_customvariablesmember->variable_name);
+ add_custom_variable_to_object(&mac->custom_service_vars, customvarname, temp_customvariablesmember->variable_value);
+ my_free(customvarname);
+ }
+ }
+ /* set variables */
+ for(temp_customvariablesmember = mac->custom_service_vars; temp_customvariablesmember != NULL; temp_customvariablesmember = temp_customvariablesmember->next)
+ set_macro_environment_var(temp_customvariablesmember->variable_name, clean_macro_chars(temp_customvariablesmember->variable_value, STRIP_ILLEGAL_MACRO_CHARS | ESCAPE_MACRO_CHARS), set);
+
+ /***** CUSTOM CONTACT VARIABLES *****/
+ /* generate variables and save them for later */
+ if((temp_contact = mac->contact_ptr) && set == TRUE) {
+ for(temp_customvariablesmember = temp_contact->custom_variables; temp_customvariablesmember != NULL; temp_customvariablesmember = temp_customvariablesmember->next) {
+ asprintf(&customvarname, "_CONTACT%s", temp_customvariablesmember->variable_name);
+ add_custom_variable_to_object(&mac->custom_contact_vars, customvarname, temp_customvariablesmember->variable_value);
+ my_free(customvarname);
+ }
+ }
+ /* set variables */
+ for(temp_customvariablesmember = mac->custom_contact_vars; temp_customvariablesmember != NULL; temp_customvariablesmember = temp_customvariablesmember->next)
+ set_macro_environment_var(temp_customvariablesmember->variable_name, clean_macro_chars(temp_customvariablesmember->variable_value, STRIP_ILLEGAL_MACRO_CHARS | ESCAPE_MACRO_CHARS), set);
+
+ return OK;
+ }
+
+int set_custom_macro_environment_vars(int set) {
+ return set_custom_macro_environment_vars_r(&global_macros, set);
+ }
+
+
+/* sets or unsets contact address environment variables */
+int set_contact_address_environment_vars_r(nagios_macros *mac, int set) {
+ char *varname = NULL;
+ register int x;
+
+ /* these only get set during notifications */
+ if(mac->contact_ptr == NULL)
+ return OK;
+
+ for(x = 0; x < MAX_CONTACT_ADDRESSES; x++) {
+ asprintf(&varname, "CONTACTADDRESS%d", x);
+ set_macro_environment_var(varname, mac->contact_ptr->address[x], set);
+ my_free(varname);
+ }
+
+ return OK;
+ }
+
+int set_contact_address_environment_vars(int set) {
+ return set_contact_address_environment_vars_r(&global_macros, set);
+ }
+
+
+/* sets or unsets a macro environment variable */
+int set_macro_environment_var(char *name, char *value, int set) {
+ char *env_macro_name = NULL;
+
+ /* we won't mess with null variable names */
+ if(name == NULL)
+ return ERROR;
+
+ /* create environment var name */
+ asprintf(&env_macro_name, "%s%s", MACRO_ENV_VAR_PREFIX, name);
+
+ /* set or unset the environment variable */
+ set_environment_var(env_macro_name, value, set);
+
+ /* free allocated memory */
+ my_free(env_macro_name);
+
+ return OK;
+ }
+
+
+#endif
diff --git a/common/objects.c b/common/objects.c
new file mode 100644
index 0000000..d16f75d
--- /dev/null
+++ b/common/objects.c
@@ -0,0 +1,3613 @@
+/*****************************************************************************
+ *
+ * OBJECTS.C - Object addition and search functions for Nagios
+ *
+ * Copyright (c) 1999-2008 Ethan Galstad (egalstad@nagios.org)
+ * Last Modified: 11-30-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.
+ *
+ *****************************************************************************/
+
+#include "../include/config.h"
+#include "../include/common.h"
+#include "../include/objects.h"
+#include "../include/skiplist.h"
+
+#ifdef NSCORE
+#include "../include/nagios.h"
+#endif
+
+#ifdef NSCGI
+#include "../include/cgiutils.h"
+#endif
+
+/**** IMPLEMENTATION-SPECIFIC HEADER FILES ****/
+
+#ifdef USE_XODTEMPLATE /* template-based routines */
+#include "../xdata/xodtemplate.h"
+#endif
+
+
+host *host_list = NULL, *host_list_tail = NULL;
+service *service_list = NULL, *service_list_tail = NULL;
+contact *contact_list = NULL, *contact_list_tail = NULL;
+contactgroup *contactgroup_list = NULL, *contactgroup_list_tail = NULL;
+hostgroup *hostgroup_list = NULL, *hostgroup_list_tail = NULL;
+servicegroup *servicegroup_list = NULL, *servicegroup_list_tail = NULL;
+command *command_list = NULL, *command_list_tail = NULL;
+timeperiod *timeperiod_list = NULL, *timeperiod_list_tail = NULL;
+serviceescalation *serviceescalation_list = NULL, *serviceescalation_list_tail = NULL;
+servicedependency *servicedependency_list = NULL, *servicedependency_list_tail = NULL;
+hostdependency *hostdependency_list = NULL, *hostdependency_list_tail = NULL;
+hostescalation *hostescalation_list = NULL, *hostescalation_list_tail = NULL;
+
+skiplist *object_skiplists[NUM_OBJECT_SKIPLISTS];
+
+
+#ifdef NSCORE
+int __nagios_object_structure_version = CURRENT_OBJECT_STRUCTURE_VERSION;
+extern int use_precached_objects;
+#endif
+
+
+
+/******************************************************************/
+/******* TOP-LEVEL HOST CONFIGURATION DATA INPUT FUNCTION *********/
+/******************************************************************/
+
+
+/* read all host configuration data from external source */
+int read_object_config_data(char *main_config_file, int options, int cache, int precache) {
+ int result = OK;
+
+ /* initialize object skiplists */
+ init_object_skiplists();
+
+ /********* IMPLEMENTATION-SPECIFIC INPUT FUNCTION ********/
+#ifdef USE_XODTEMPLATE
+ /* read in data from all text host config files (template-based) */
+ result = xodtemplate_read_config_data(main_config_file, options, cache, precache);
+ if(result != OK)
+ return ERROR;
+#endif
+
+ return result;
+ }
+
+
+
+/******************************************************************/
+/******************** SKIPLIST FUNCTIONS **************************/
+/******************************************************************/
+
+int init_object_skiplists(void) {
+ int x = 0;
+
+ for(x = 0; x < NUM_OBJECT_SKIPLISTS; x++)
+ object_skiplists[x] = NULL;
+
+ object_skiplists[HOST_SKIPLIST] = skiplist_new(15, 0.5, FALSE, FALSE, skiplist_compare_host);
+ object_skiplists[SERVICE_SKIPLIST] = skiplist_new(15, 0.5, FALSE, FALSE, skiplist_compare_service);
+
+ object_skiplists[COMMAND_SKIPLIST] = skiplist_new(10, 0.5, FALSE, FALSE, skiplist_compare_command);
+ object_skiplists[TIMEPERIOD_SKIPLIST] = skiplist_new(10, 0.5, FALSE, FALSE, skiplist_compare_timeperiod);
+ object_skiplists[CONTACT_SKIPLIST] = skiplist_new(10, 0.5, FALSE, FALSE, skiplist_compare_contact);
+ object_skiplists[CONTACTGROUP_SKIPLIST] = skiplist_new(10, 0.5, FALSE, FALSE, skiplist_compare_contactgroup);
+ object_skiplists[HOSTGROUP_SKIPLIST] = skiplist_new(10, 0.5, FALSE, FALSE, skiplist_compare_hostgroup);
+ object_skiplists[SERVICEGROUP_SKIPLIST] = skiplist_new(10, 0.5, FALSE, FALSE, skiplist_compare_servicegroup);
+
+ object_skiplists[HOSTESCALATION_SKIPLIST] = skiplist_new(15, 0.5, TRUE, FALSE, skiplist_compare_hostescalation);
+ object_skiplists[SERVICEESCALATION_SKIPLIST] = skiplist_new(15, 0.5, TRUE, FALSE, skiplist_compare_serviceescalation);
+ object_skiplists[HOSTDEPENDENCY_SKIPLIST] = skiplist_new(15, 0.5, TRUE, FALSE, skiplist_compare_hostdependency);
+ object_skiplists[SERVICEDEPENDENCY_SKIPLIST] = skiplist_new(15, 0.5, TRUE, FALSE, skiplist_compare_servicedependency);
+
+ return OK;
+ }
+
+
+
+int free_object_skiplists(void) {
+ int x = 0;
+
+ for(x = 0; x < NUM_OBJECT_SKIPLISTS; x++)
+ skiplist_free(&object_skiplists[x]);
+
+ return OK;
+ }
+
+
+int skiplist_compare_text(const char *val1a, const char *val1b, const char *val2a, const char *val2b) {
+ int result = 0;
+
+ /* check first name */
+ if(val1a == NULL && val2a == NULL)
+ result = 0;
+ else if(val1a == NULL)
+ result = 1;
+ else if(val2a == NULL)
+ result = -1;
+ else
+ result = strcmp(val1a, val2a);
+
+ /* check second name if necessary */
+ if(result == 0) {
+ if(val1b == NULL && val2b == NULL)
+ result = 0;
+ else if(val1b == NULL)
+ result = 1;
+ else if(val2b == NULL)
+ result = -1;
+ else
+ result = strcmp(val1b, val2b);
+ }
+
+ return result;
+ }
+
+
+int skiplist_compare_host(void *a, void *b) {
+ host *oa = NULL;
+ host *ob = NULL;
+
+ oa = (host *)a;
+ ob = (host *)b;
+
+ if(oa == NULL && ob == NULL)
+ return 0;
+ if(oa == NULL)
+ return 1;
+ if(ob == NULL)
+ return -1;
+
+ return skiplist_compare_text(oa->name, NULL, ob->name, NULL);
+ }
+
+
+int skiplist_compare_service(void *a, void *b) {
+ service *oa = NULL;
+ service *ob = NULL;
+
+ oa = (service *)a;
+ ob = (service *)b;
+
+ if(oa == NULL && ob == NULL)
+ return 0;
+ if(oa == NULL)
+ return 1;
+ if(ob == NULL)
+ return -1;
+
+ return skiplist_compare_text(oa->host_name, oa->description, ob->host_name, ob->description);
+ }
+
+
+int skiplist_compare_command(void *a, void *b) {
+ command *oa = NULL;
+ command *ob = NULL;
+
+ oa = (command *)a;
+ ob = (command *)b;
+
+ if(oa == NULL && ob == NULL)
+ return 0;
+ if(oa == NULL)
+ return 1;
+ if(ob == NULL)
+ return -1;
+
+ return skiplist_compare_text(oa->name, NULL, ob->name, NULL);
+ }
+
+
+int skiplist_compare_timeperiod(void *a, void *b) {
+ timeperiod *oa = NULL;
+ timeperiod *ob = NULL;
+
+ oa = (timeperiod *)a;
+ ob = (timeperiod *)b;
+
+ if(oa == NULL && ob == NULL)
+ return 0;
+ if(oa == NULL)
+ return 1;
+ if(ob == NULL)
+ return -1;
+
+ return skiplist_compare_text(oa->name, NULL, ob->name, NULL);
+ }
+
+
+int skiplist_compare_contact(void *a, void *b) {
+ contact *oa = NULL;
+ contact *ob = NULL;
+
+ oa = (contact *)a;
+ ob = (contact *)b;
+
+ if(oa == NULL && ob == NULL)
+ return 0;
+ if(oa == NULL)
+ return 1;
+ if(ob == NULL)
+ return -1;
+
+ return skiplist_compare_text(oa->name, NULL, ob->name, NULL);
+ }
+
+
+int skiplist_compare_contactgroup(void *a, void *b) {
+ contactgroup *oa = NULL;
+ contactgroup *ob = NULL;
+
+ oa = (contactgroup *)a;
+ ob = (contactgroup *)b;
+
+ if(oa == NULL && ob == NULL)
+ return 0;
+ if(oa == NULL)
+ return 1;
+ if(ob == NULL)
+ return -1;
+
+ return skiplist_compare_text(oa->group_name, NULL, ob->group_name, NULL);
+ }
+
+
+int skiplist_compare_hostgroup(void *a, void *b) {
+ hostgroup *oa = NULL;
+ hostgroup *ob = NULL;
+
+ oa = (hostgroup *)a;
+ ob = (hostgroup *)b;
+
+ if(oa == NULL && ob == NULL)
+ return 0;
+ if(oa == NULL)
+ return 1;
+ if(ob == NULL)
+ return -1;
+
+ return skiplist_compare_text(oa->group_name, NULL, ob->group_name, NULL);
+ }
+
+
+int skiplist_compare_servicegroup(void *a, void *b) {
+ servicegroup *oa = NULL;
+ servicegroup *ob = NULL;
+
+ oa = (servicegroup *)a;
+ ob = (servicegroup *)b;
+
+ if(oa == NULL && ob == NULL)
+ return 0;
+ if(oa == NULL)
+ return 1;
+ if(ob == NULL)
+ return -1;
+
+ return skiplist_compare_text(oa->group_name, NULL, ob->group_name, NULL);
+ }
+
+
+int skiplist_compare_hostescalation(void *a, void *b) {
+ hostescalation *oa = NULL;
+ hostescalation *ob = NULL;
+
+ oa = (hostescalation *)a;
+ ob = (hostescalation *)b;
+
+ if(oa == NULL && ob == NULL)
+ return 0;
+ if(oa == NULL)
+ return 1;
+ if(ob == NULL)
+ return -1;
+
+ return skiplist_compare_text(oa->host_name, NULL, ob->host_name, NULL);
+ }
+
+
+int skiplist_compare_serviceescalation(void *a, void *b) {
+ serviceescalation *oa = NULL;
+ serviceescalation *ob = NULL;
+
+ oa = (serviceescalation *)a;
+ ob = (serviceescalation *)b;
+
+ if(oa == NULL && ob == NULL)
+ return 0;
+ if(oa == NULL)
+ return 1;
+ if(ob == NULL)
+ return -1;
+
+ return skiplist_compare_text(oa->host_name, oa->description, ob->host_name, ob->description);
+ }
+
+
+int skiplist_compare_hostdependency(void *a, void *b) {
+ hostdependency *oa = NULL;
+ hostdependency *ob = NULL;
+
+ oa = (hostdependency *)a;
+ ob = (hostdependency *)b;
+
+ if(oa == NULL && ob == NULL)
+ return 0;
+ if(oa == NULL)
+ return 1;
+ if(ob == NULL)
+ return -1;
+
+ return skiplist_compare_text(oa->dependent_host_name, NULL, ob->dependent_host_name, NULL);
+ }
+
+
+int skiplist_compare_servicedependency(void *a, void *b) {
+ servicedependency *oa = NULL;
+ servicedependency *ob = NULL;
+
+ oa = (servicedependency *)a;
+ ob = (servicedependency *)b;
+
+ if(oa == NULL && ob == NULL)
+ return 0;
+ if(oa == NULL)
+ return 1;
+ if(ob == NULL)
+ return -1;
+
+ return skiplist_compare_text(oa->dependent_host_name, oa->dependent_service_description, ob->dependent_host_name, ob->dependent_service_description);
+ }
+
+
+int get_host_count(void) {
+
+ if(object_skiplists[HOST_SKIPLIST])
+ return object_skiplists[HOST_SKIPLIST]->items;
+
+ return 0;
+ }
+
+
+int get_service_count(void) {
+
+ if(object_skiplists[SERVICE_SKIPLIST])
+ return object_skiplists[SERVICE_SKIPLIST]->items;
+
+ return 0;
+ }
+
+
+
+
+/******************************************************************/
+/**************** OBJECT ADDITION FUNCTIONS ***********************/
+/******************************************************************/
+
+
+
+/* add a new timeperiod to the list in memory */
+timeperiod *add_timeperiod(char *name, char *alias) {
+ timeperiod *new_timeperiod = NULL;
+ int result = OK;
+
+ /* make sure we have the data we need */
+ if((name == NULL || !strcmp(name, "")) || (alias == NULL || !strcmp(alias, ""))) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Name or alias for timeperiod is NULL\n");
+ return NULL;
+ }
+
+ /* allocate memory for the new timeperiod */
+ if((new_timeperiod = calloc(1, sizeof(timeperiod))) == NULL)
+ return NULL;
+
+ /* copy string vars */
+ if((new_timeperiod->name = (char *)strdup(name)) == NULL)
+ result = ERROR;
+ if((new_timeperiod->alias = (char *)strdup(alias)) == NULL)
+ result = ERROR;
+
+ /* add new timeperiod to skiplist */
+ if(result == OK) {
+ result = skiplist_insert(object_skiplists[TIMEPERIOD_SKIPLIST], (void *)new_timeperiod);
+ switch(result) {
+ case SKIPLIST_ERROR_DUPLICATE:
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Timeperiod '%s' has already been defined\n", name);
+ result = ERROR;
+ break;
+ case SKIPLIST_OK:
+ result = OK;
+ break;
+ default:
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Could not add timeperiod '%s' to skiplist\n", name);
+ result = ERROR;
+ break;
+ }
+ }
+
+ /* handle errors */
+ if(result == ERROR) {
+ my_free(new_timeperiod->alias);
+ my_free(new_timeperiod->name);
+ my_free(new_timeperiod);
+ return NULL;
+ }
+
+ /* timeperiods are registered alphabetically, so add new items to tail of list */
+ if(timeperiod_list == NULL) {
+ timeperiod_list = new_timeperiod;
+ timeperiod_list_tail = timeperiod_list;
+ }
+ else {
+ timeperiod_list_tail->next = new_timeperiod;
+ timeperiod_list_tail = new_timeperiod;
+ }
+
+ return new_timeperiod;
+ }
+
+
+
+
+/* adds a new exclusion to a timeperiod */
+timeperiodexclusion *add_exclusion_to_timeperiod(timeperiod *period, char *name) {
+ timeperiodexclusion *new_timeperiodexclusion = NULL;
+
+ /* make sure we have enough data */
+ if(period == NULL || name == NULL)
+ return NULL;
+
+ if((new_timeperiodexclusion = (timeperiodexclusion *)malloc(sizeof(timeperiodexclusion))) == NULL)
+ return NULL;
+
+ new_timeperiodexclusion->timeperiod_name = (char *)strdup(name);
+
+ new_timeperiodexclusion->next = period->exclusions;
+ period->exclusions = new_timeperiodexclusion;
+
+ return new_timeperiodexclusion;
+ }
+
+
+
+
+/* add a new timerange to a timeperiod */
+timerange *add_timerange_to_timeperiod(timeperiod *period, int day, unsigned long start_time, unsigned long end_time) {
+ timerange *new_timerange = NULL;
+
+ /* make sure we have the data we need */
+ if(period == NULL)
+ return NULL;
+
+ if(day < 0 || day > 6) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Day %d is not valid for timeperiod '%s'\n", day, period->name);
+ return NULL;
+ }
+ if(start_time < 0 || start_time > 86400) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Start time %lu on day %d is not valid for timeperiod '%s'\n", start_time, day, period->name);
+ return NULL;
+ }
+ if(end_time < 0 || end_time > 86400) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: End time %lu on day %d is not value for timeperiod '%s'\n", end_time, day, period->name);
+ return NULL;
+ }
+
+ /* allocate memory for the new time range */
+ if((new_timerange = malloc(sizeof(timerange))) == NULL)
+ return NULL;
+
+ new_timerange->range_start = start_time;
+ new_timerange->range_end = end_time;
+
+ /* add the new time range to the head of the range list for this day */
+ new_timerange->next = period->days[day];
+ period->days[day] = new_timerange;
+
+ return new_timerange;
+ }
+
+
+/* add a new exception to a timeperiod */
+daterange *add_exception_to_timeperiod(timeperiod *period, int type, int syear, int smon, int smday, int swday, int swday_offset, int eyear, int emon, int emday, int ewday, int ewday_offset, int skip_interval) {
+ daterange *new_daterange = NULL;
+
+ /* make sure we have the data we need */
+ if(period == NULL)
+ return NULL;
+
+ /* allocate memory for the date range range */
+ if((new_daterange = malloc(sizeof(daterange))) == NULL)
+ return NULL;
+
+ new_daterange->times = NULL;
+ new_daterange->next = NULL;
+
+ new_daterange->type = type;
+ new_daterange->syear = syear;
+ new_daterange->smon = smon;
+ new_daterange->smday = smday;
+ new_daterange->swday = swday;
+ new_daterange->swday_offset = swday_offset;
+ new_daterange->eyear = eyear;
+ new_daterange->emon = emon;
+ new_daterange->emday = emday;
+ new_daterange->ewday = ewday;
+ new_daterange->ewday_offset = ewday_offset;
+ new_daterange->skip_interval = skip_interval;
+
+ /* add the new date range to the head of the range list for this exception type */
+ new_daterange->next = period->exceptions[type];
+ period->exceptions[type] = new_daterange;
+
+ return new_daterange;
+ }
+
+
+
+/* add a new timerange to a daterange */
+timerange *add_timerange_to_daterange(daterange *drange, unsigned long start_time, unsigned long end_time) {
+ timerange *new_timerange = NULL;
+
+ /* make sure we have the data we need */
+ if(drange == NULL)
+ return NULL;
+
+ if(start_time < 0 || start_time > 86400) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Start time %lu is not valid for timeperiod\n", start_time);
+ return NULL;
+ }
+ if(end_time < 0 || end_time > 86400) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: End time %lu is not value for timeperiod\n", end_time);
+ return NULL;
+ }
+
+ /* allocate memory for the new time range */
+ if((new_timerange = malloc(sizeof(timerange))) == NULL)
+ return NULL;
+
+ new_timerange->range_start = start_time;
+ new_timerange->range_end = end_time;
+
+ /* add the new time range to the head of the range list for this date range */
+ new_timerange->next = drange->times;
+ drange->times = new_timerange;
+
+ return new_timerange;
+ }
+
+
+
+/* add a new host definition */
+host *add_host(char *name, char *display_name, char *alias, char *address, char *check_period, int initial_state, double check_interval, double retry_interval, int max_attempts, int notify_up, int notify_down, int notify_unreachable, int notify_flapping, int notify_downtime, double notification_interval, double first_notification_delay, char *notification_period, int notifications_enabled, char *check_command, int checks_enabled, int accept_passive_checks, char *event_handler, int event_handler_enabled, int flap_detection_enabled, double low_flap_threshold, double high_flap_threshold, int flap_detection_on_up, int flap_detection_on_down, int flap_detection_on_unreachable, int stalk_on_up, int stalk_on_down, int stalk_on_unreachable, int process_perfdata, int failure_prediction_enabled, char *failure_prediction_options, int check_freshness, int freshness_threshold, char *notes, char *notes_url, char *action_url, char *icon_image, char *icon_image_alt, char *vrml_image, char *statusmap_image, int x_2d, int y_2d, int have_2d_coords, double x_3d, double y_3d, double z_3d, int have_3d_coords, int should_be_drawn, int retain_status_information, int retain_nonstatus_information, int obsess_over_host) {
+ host *new_host = NULL;
+ int result = OK;
+#ifdef NSCORE
+ int x = 0;
+#endif
+
+ /* make sure we have the data we need */
+ if((name == NULL || !strcmp(name, "")) || (address == NULL || !strcmp(address, ""))) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Host name or address is NULL\n");
+ return NULL;
+ }
+
+ /* check values */
+ if(max_attempts <= 0) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Invalid max_check_attempts value for host '%s'\n", name);
+ return NULL;
+ }
+ if(check_interval < 0) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Invalid check_interval value for host '%s'\n", name);
+ return NULL;
+ }
+ if(notification_interval < 0) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Invalid notification_interval value for host '%s'\n", name);
+ return NULL;
+ }
+ if(first_notification_delay < 0) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Invalid first_notification_delay value for host '%s'\n", name);
+ return NULL;
+ }
+ if(freshness_threshold < 0) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Invalid freshness_threshold value for host '%s'\n", name);
+ return NULL;
+ }
+
+ /* allocate memory for a new host */
+ if((new_host = (host *)calloc(1, sizeof(host))) == NULL)
+ return NULL;
+
+ /* duplicate string vars */
+ if((new_host->name = (char *)strdup(name)) == NULL)
+ result = ERROR;
+ if((new_host->display_name = (char *)strdup((display_name == NULL) ? name : display_name)) == NULL)
+ result = ERROR;
+ if((new_host->alias = (char *)strdup((alias == NULL) ? name : alias)) == NULL)
+ result = ERROR;
+ if((new_host->address = (char *)strdup(address)) == NULL)
+ result = ERROR;
+ if(check_period) {
+ if((new_host->check_period = (char *)strdup(check_period)) == NULL)
+ result = ERROR;
+ }
+ if(notification_period) {
+ if((new_host->notification_period = (char *)strdup(notification_period)) == NULL)
+ result = ERROR;
+ }
+ if(check_command) {
+ if((new_host->host_check_command = (char *)strdup(check_command)) == NULL)
+ result = ERROR;
+ }
+ if(event_handler) {
+ if((new_host->event_handler = (char *)strdup(event_handler)) == NULL)
+ result = ERROR;
+ }
+ if(failure_prediction_options) {
+ if((new_host->failure_prediction_options = (char *)strdup(failure_prediction_options)) == NULL)
+ result = ERROR;
+ }
+ if(notes) {
+ if((new_host->notes = (char *)strdup(notes)) == NULL)
+ result = ERROR;
+ }
+ if(notes_url) {
+ if((new_host->notes_url = (char *)strdup(notes_url)) == NULL)
+ result = ERROR;
+ }
+ if(action_url) {
+ if((new_host->action_url = (char *)strdup(action_url)) == NULL)
+ result = ERROR;
+ }
+ if(icon_image) {
+ if((new_host->icon_image = (char *)strdup(icon_image)) == NULL)
+ result = ERROR;
+ }
+ if(icon_image_alt) {
+ if((new_host->icon_image_alt = (char *)strdup(icon_image_alt)) == NULL)
+ result = ERROR;
+ }
+ if(vrml_image) {
+ if((new_host->vrml_image = (char *)strdup(vrml_image)) == NULL)
+ result = ERROR;
+ }
+ if(statusmap_image) {
+ if((new_host->statusmap_image = (char *)strdup(statusmap_image)) == NULL)
+ result = ERROR;
+ }
+
+
+ /* duplicate non-string vars */
+ new_host->max_attempts = max_attempts;
+ new_host->check_interval = check_interval;
+ new_host->retry_interval = retry_interval;
+ new_host->notification_interval = notification_interval;
+ new_host->first_notification_delay = first_notification_delay;
+ new_host->notify_on_recovery = (notify_up > 0) ? TRUE : FALSE;
+ new_host->notify_on_down = (notify_down > 0) ? TRUE : FALSE;
+ new_host->notify_on_unreachable = (notify_unreachable > 0) ? TRUE : FALSE;
+ new_host->notify_on_flapping = (notify_flapping > 0) ? TRUE : FALSE;
+ new_host->notify_on_downtime = (notify_downtime > 0) ? TRUE : FALSE;
+ new_host->flap_detection_enabled = (flap_detection_enabled > 0) ? TRUE : FALSE;
+ new_host->low_flap_threshold = low_flap_threshold;
+ new_host->high_flap_threshold = high_flap_threshold;
+ new_host->flap_detection_on_up = (flap_detection_on_up > 0) ? TRUE : FALSE;
+ new_host->flap_detection_on_down = (flap_detection_on_down > 0) ? TRUE : FALSE;
+ new_host->flap_detection_on_unreachable = (flap_detection_on_unreachable > 0) ? TRUE : FALSE;
+ new_host->stalk_on_up = (stalk_on_up > 0) ? TRUE : FALSE;
+ new_host->stalk_on_down = (stalk_on_down > 0) ? TRUE : FALSE;
+ new_host->stalk_on_unreachable = (stalk_on_unreachable > 0) ? TRUE : FALSE;
+ new_host->process_performance_data = (process_perfdata > 0) ? TRUE : FALSE;
+ new_host->check_freshness = (check_freshness > 0) ? TRUE : FALSE;
+ new_host->freshness_threshold = freshness_threshold;
+ new_host->checks_enabled = (checks_enabled > 0) ? TRUE : FALSE;
+ new_host->accept_passive_host_checks = (accept_passive_checks > 0) ? TRUE : FALSE;
+ new_host->event_handler_enabled = (event_handler_enabled > 0) ? TRUE : FALSE;
+ new_host->failure_prediction_enabled = (failure_prediction_enabled > 0) ? TRUE : FALSE;
+ new_host->x_2d = x_2d;
+ new_host->y_2d = y_2d;
+ new_host->have_2d_coords = (have_2d_coords > 0) ? TRUE : FALSE;
+ new_host->x_3d = x_3d;
+ new_host->y_3d = y_3d;
+ new_host->z_3d = z_3d;
+ new_host->have_3d_coords = (have_3d_coords > 0) ? TRUE : FALSE;
+ new_host->should_be_drawn = (should_be_drawn > 0) ? TRUE : FALSE;
+ new_host->obsess_over_host = (obsess_over_host > 0) ? TRUE : FALSE;
+ new_host->retain_status_information = (retain_status_information > 0) ? TRUE : FALSE;
+ new_host->retain_nonstatus_information = (retain_nonstatus_information > 0) ? TRUE : FALSE;
+#ifdef NSCORE
+ new_host->current_state = initial_state;
+ new_host->current_event_id = 0L;
+ new_host->last_event_id = 0L;
+ new_host->current_problem_id = 0L;
+ new_host->last_problem_id = 0L;
+ new_host->last_state = initial_state;
+ new_host->last_hard_state = initial_state;
+ new_host->check_type = HOST_CHECK_ACTIVE;
+ new_host->last_host_notification = (time_t)0;
+ new_host->next_host_notification = (time_t)0;
+ new_host->next_check = (time_t)0;
+ new_host->should_be_scheduled = TRUE;
+ new_host->last_check = (time_t)0;
+ new_host->current_attempt = (initial_state == HOST_UP) ? 1 : max_attempts;
+ new_host->state_type = HARD_STATE;
+ new_host->execution_time = 0.0;
+ new_host->is_executing = FALSE;
+ new_host->latency = 0.0;
+ new_host->last_state_change = (time_t)0;
+ new_host->last_hard_state_change = (time_t)0;
+ new_host->last_time_up = (time_t)0;
+ new_host->last_time_down = (time_t)0;
+ new_host->last_time_unreachable = (time_t)0;
+ new_host->has_been_checked = FALSE;
+ new_host->is_being_freshened = FALSE;
+ new_host->problem_has_been_acknowledged = FALSE;
+ new_host->acknowledgement_type = ACKNOWLEDGEMENT_NONE;
+ new_host->notifications_enabled = (notifications_enabled > 0) ? TRUE : FALSE;
+ new_host->notified_on_down = FALSE;
+ new_host->notified_on_unreachable = FALSE;
+ new_host->current_notification_number = 0;
+ new_host->current_notification_id = 0L;
+ new_host->no_more_notifications = FALSE;
+ new_host->check_flapping_recovery_notification = FALSE;
+ new_host->scheduled_downtime_depth = 0;
+ new_host->check_options = CHECK_OPTION_NONE;
+ new_host->pending_flex_downtime = 0;
+ for(x = 0; x < MAX_STATE_HISTORY_ENTRIES; x++)
+ new_host->state_history[x] = STATE_OK;
+ new_host->state_history_index = 0;
+ new_host->last_state_history_update = (time_t)0;
+ new_host->is_flapping = FALSE;
+ new_host->flapping_comment_id = 0;
+ new_host->percent_state_change = 0.0;
+ new_host->total_services = 0;
+ new_host->total_service_check_interval = 0L;
+ new_host->modified_attributes = MODATTR_NONE;
+ new_host->circular_path_checked = FALSE;
+ new_host->contains_circular_path = FALSE;
+#endif
+
+ /* add new host to skiplist */
+ if(result == OK) {
+ result = skiplist_insert(object_skiplists[HOST_SKIPLIST], (void *)new_host);
+ switch(result) {
+ case SKIPLIST_ERROR_DUPLICATE:
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Host '%s' has already been defined\n", name);
+ result = ERROR;
+ break;
+ case SKIPLIST_OK:
+ result = OK;
+ break;
+ default:
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Could not add host '%s' to skiplist\n", name);
+ result = ERROR;
+ break;
+ }
+ }
+
+ /* handle errors */
+ if(result == ERROR) {
+#ifdef NSCORE
+ my_free(new_host->plugin_output);
+ my_free(new_host->long_plugin_output);
+ my_free(new_host->perf_data);
+#endif
+ my_free(new_host->statusmap_image);
+ my_free(new_host->vrml_image);
+ my_free(new_host->icon_image_alt);
+ my_free(new_host->icon_image);
+ my_free(new_host->action_url);
+ my_free(new_host->notes_url);
+ my_free(new_host->notes);
+ my_free(new_host->failure_prediction_options);
+ my_free(new_host->event_handler);
+ my_free(new_host->host_check_command);
+ my_free(new_host->notification_period);
+ my_free(new_host->check_period);
+ my_free(new_host->address);
+ my_free(new_host->alias);
+ my_free(new_host->display_name);
+ my_free(new_host->name);
+ my_free(new_host);
+ return NULL;
+ }
+
+ /* hosts are sorted alphabetically, so add new items to tail of list */
+ if(host_list == NULL) {
+ host_list = new_host;
+ host_list_tail = host_list;
+ }
+ else {
+ host_list_tail->next = new_host;
+ host_list_tail = new_host;
+ }
+
+ return new_host;
+ }
+
+
+
+hostsmember *add_parent_host_to_host(host *hst, char *host_name) {
+ hostsmember *new_hostsmember = NULL;
+ int result = OK;
+
+ /* make sure we have the data we need */
+ if(hst == NULL || host_name == NULL || !strcmp(host_name, "")) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Host is NULL or parent host name is NULL\n");
+ return NULL;
+ }
+
+ /* a host cannot be a parent/child of itself */
+ if(!strcmp(host_name, hst->name)) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Host '%s' cannot be a child/parent of itself\n", hst->name);
+ return NULL;
+ }
+
+ /* allocate memory */
+ if((new_hostsmember = (hostsmember *)calloc(1, sizeof(hostsmember))) == NULL)
+ return NULL;
+
+ /* duplicate string vars */
+ if((new_hostsmember->host_name = (char *)strdup(host_name)) == NULL)
+ result = ERROR;
+
+ /* handle errors */
+ if(result == ERROR) {
+ my_free(new_hostsmember->host_name);
+ my_free(new_hostsmember);
+ return NULL;
+ }
+
+ /* add the parent host entry to the host definition */
+ new_hostsmember->next = hst->parent_hosts;
+ hst->parent_hosts = new_hostsmember;
+
+ return new_hostsmember;
+ }
+
+
+
+hostsmember *add_child_link_to_host(host *hst, host *child_ptr) {
+ hostsmember *new_hostsmember = NULL;
+
+ /* make sure we have the data we need */
+ if(hst == NULL || child_ptr == NULL)
+ return NULL;
+
+ /* allocate memory */
+ if((new_hostsmember = (hostsmember *)malloc(sizeof(hostsmember))) == NULL)
+ return NULL;
+
+ /* initialize values */
+ new_hostsmember->host_name = NULL;
+#ifdef NSCORE
+ new_hostsmember->host_ptr = child_ptr;
+#endif
+
+ /* add the child entry to the host definition */
+ new_hostsmember->next = hst->child_hosts;
+ hst->child_hosts = new_hostsmember;
+
+ return new_hostsmember;
+ }
+
+
+
+servicesmember *add_service_link_to_host(host *hst, service *service_ptr) {
+ servicesmember *new_servicesmember = NULL;
+
+ /* make sure we have the data we need */
+ if(hst == NULL || service_ptr == NULL)
+ return NULL;
+
+ /* allocate memory */
+ if((new_servicesmember = (servicesmember *)calloc(1, sizeof(servicesmember))) == NULL)
+ return NULL;
+
+ /* initialize values */
+#ifdef NSCORE
+ new_servicesmember->service_ptr = service_ptr;
+#endif
+
+ /* add the child entry to the host definition */
+ new_servicesmember->next = hst->services;
+ hst->services = new_servicesmember;
+
+ return new_servicesmember;
+ }
+
+
+
+/* add a new contactgroup to a host */
+contactgroupsmember *add_contactgroup_to_host(host *hst, char *group_name) {
+ contactgroupsmember *new_contactgroupsmember = NULL;
+ int result = OK;
+
+ /* make sure we have the data we need */
+ if(hst == NULL || (group_name == NULL || !strcmp(group_name, ""))) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Host or contactgroup member is NULL\n");
+ return NULL;
+ }
+
+ /* allocate memory for a new member */
+ if((new_contactgroupsmember = calloc(1, sizeof(contactgroupsmember))) == NULL)
+ return NULL;
+
+ /* duplicate string vars */
+ if((new_contactgroupsmember->group_name = (char *)strdup(group_name)) == NULL)
+ result = ERROR;
+
+ /* handle errors */
+ if(result == ERROR) {
+ my_free(new_contactgroupsmember->group_name);
+ my_free(new_contactgroupsmember);
+ return NULL;
+ }
+
+ /* add the new member to the head of the member list */
+ new_contactgroupsmember->next = hst->contact_groups;
+ hst->contact_groups = new_contactgroupsmember;;
+
+ return new_contactgroupsmember;
+ }
+
+
+
+/* adds a contact to a host */
+contactsmember *add_contact_to_host(host *hst, char *contact_name) {
+
+ return add_contact_to_object(&hst->contacts, contact_name);
+ }
+
+
+
+/* adds a custom variable to a host */
+customvariablesmember *add_custom_variable_to_host(host *hst, char *varname, char *varvalue) {
+
+ return add_custom_variable_to_object(&hst->custom_variables, varname, varvalue);
+ }
+
+
+
+/* add a new host group to the list in memory */
+hostgroup *add_hostgroup(char *name, char *alias, char *notes, char *notes_url, char *action_url) {
+ hostgroup *new_hostgroup = NULL;
+ int result = OK;
+
+ /* make sure we have the data we need */
+ if(name == NULL || !strcmp(name, "")) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Hostgroup name is NULL\n");
+ return NULL;
+ }
+
+ /* allocate memory */
+ if((new_hostgroup = (hostgroup *)calloc(1, sizeof(hostgroup))) == NULL)
+ return NULL;
+
+ /* duplicate vars */
+ if((new_hostgroup->group_name = (char *)strdup(name)) == NULL)
+ result = ERROR;
+ if((new_hostgroup->alias = (char *)strdup((alias == NULL) ? name : alias)) == NULL)
+ result = ERROR;
+ if(notes) {
+ if((new_hostgroup->notes = (char *)strdup(notes)) == NULL)
+ result = ERROR;
+ }
+ if(notes_url) {
+ if((new_hostgroup->notes_url = (char *)strdup(notes_url)) == NULL)
+ result = ERROR;
+ }
+ if(action_url) {
+ if((new_hostgroup->action_url = (char *)strdup(action_url)) == NULL)
+ result = ERROR;
+ }
+
+ /* add new host group to skiplist */
+ if(result == OK) {
+ result = skiplist_insert(object_skiplists[HOSTGROUP_SKIPLIST], (void *)new_hostgroup);
+ switch(result) {
+ case SKIPLIST_ERROR_DUPLICATE:
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Hostgroup '%s' has already been defined\n", name);
+ result = ERROR;
+ break;
+ case SKIPLIST_OK:
+ result = OK;
+ break;
+ default:
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Could not add hostgroup '%s' to skiplist\n", name);
+ result = ERROR;
+ break;
+ }
+ }
+
+ /* handle errors */
+ if(result == ERROR) {
+ my_free(new_hostgroup->alias);
+ my_free(new_hostgroup->group_name);
+ my_free(new_hostgroup);
+ return NULL;
+ }
+
+ /* hostgroups are sorted alphabetically, so add new items to tail of list */
+ if(hostgroup_list == NULL) {
+ hostgroup_list = new_hostgroup;
+ hostgroup_list_tail = hostgroup_list;
+ }
+ else {
+ hostgroup_list_tail->next = new_hostgroup;
+ hostgroup_list_tail = new_hostgroup;
+ }
+
+ return new_hostgroup;
+ }
+
+
+/* add a new host to a host group */
+hostsmember *add_host_to_hostgroup(hostgroup *temp_hostgroup, char *host_name) {
+ hostsmember *new_member = NULL;
+ hostsmember *last_member = NULL;
+ hostsmember *temp_member = NULL;
+ int result = OK;
+
+ /* make sure we have the data we need */
+ if(temp_hostgroup == NULL || (host_name == NULL || !strcmp(host_name, ""))) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Hostgroup or group member is NULL\n");
+ return NULL;
+ }
+
+ /* allocate memory for a new member */
+ if((new_member = calloc(1, sizeof(hostsmember))) == NULL)
+ return NULL;
+
+ /* duplicate vars */
+ if((new_member->host_name = (char *)strdup(host_name)) == NULL)
+ result = ERROR;
+
+ /* handle errors */
+ if(result == ERROR) {
+ my_free(new_member->host_name);
+ my_free(new_member);
+ return NULL;
+ }
+
+ /* add the new member to the member list, sorted by host name */
+ last_member = temp_hostgroup->members;
+ for(temp_member = temp_hostgroup->members; temp_member != NULL; temp_member = temp_member->next) {
+ if(strcmp(new_member->host_name, temp_member->host_name) < 0) {
+ new_member->next = temp_member;
+ if(temp_member == temp_hostgroup->members)
+ temp_hostgroup->members = new_member;
+ else
+ last_member->next = new_member;
+ break;
+ }
+ else
+ last_member = temp_member;
+ }
+ if(temp_hostgroup->members == NULL) {
+ new_member->next = NULL;
+ temp_hostgroup->members = new_member;
+ }
+ else if(temp_member == NULL) {
+ new_member->next = NULL;
+ last_member->next = new_member;
+ }
+
+ return new_member;
+ }
+
+
+/* add a new service group to the list in memory */
+servicegroup *add_servicegroup(char *name, char *alias, char *notes, char *notes_url, char *action_url) {
+ servicegroup *new_servicegroup = NULL;
+ int result = OK;
+
+ /* make sure we have the data we need */
+ if(name == NULL || !strcmp(name, "")) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Servicegroup name is NULL\n");
+ return NULL;
+ }
+
+ /* allocate memory */
+ if((new_servicegroup = (servicegroup *)calloc(1, sizeof(servicegroup))) == NULL)
+ return NULL;
+
+ /* duplicate vars */
+ if((new_servicegroup->group_name = (char *)strdup(name)) == NULL)
+ result = ERROR;
+ if((new_servicegroup->alias = (char *)strdup((alias == NULL) ? name : alias)) == NULL)
+ result = ERROR;
+ if(notes) {
+ if((new_servicegroup->notes = (char *)strdup(notes)) == NULL)
+ result = ERROR;
+ }
+ if(notes_url) {
+ if((new_servicegroup->notes_url = (char *)strdup(notes_url)) == NULL)
+ result = ERROR;
+ }
+ if(action_url) {
+ if((new_servicegroup->action_url = (char *)strdup(action_url)) == NULL)
+ result = ERROR;
+ }
+
+ /* add new service group to skiplist */
+ if(result == OK) {
+ result = skiplist_insert(object_skiplists[SERVICEGROUP_SKIPLIST], (void *)new_servicegroup);
+ switch(result) {
+ case SKIPLIST_ERROR_DUPLICATE:
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Servicegroup '%s' has already been defined\n", name);
+ result = ERROR;
+ break;
+ case SKIPLIST_OK:
+ result = OK;
+ break;
+ default:
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Could not add servicegroup '%s' to skiplist\n", name);
+ result = ERROR;
+ break;
+ }
+ }
+
+ /* handle errors */
+ if(result == ERROR) {
+ my_free(new_servicegroup->alias);
+ my_free(new_servicegroup->group_name);
+ my_free(new_servicegroup);
+ return NULL;
+ }
+
+ /* servicegroups are sorted alphabetically, so add new items to tail of list */
+ if(servicegroup_list == NULL) {
+ servicegroup_list = new_servicegroup;
+ servicegroup_list_tail = servicegroup_list;
+ }
+ else {
+ servicegroup_list_tail->next = new_servicegroup;
+ servicegroup_list_tail = new_servicegroup;
+ }
+
+ return new_servicegroup;
+ }
+
+
+/* add a new service to a service group */
+servicesmember *add_service_to_servicegroup(servicegroup *temp_servicegroup, char *host_name, char *svc_description) {
+ servicesmember *new_member = NULL;
+ servicesmember *last_member = NULL;
+ servicesmember *temp_member = NULL;
+ int result = OK;
+
+ /* make sure we have the data we need */
+ if(temp_servicegroup == NULL || (host_name == NULL || !strcmp(host_name, "")) || (svc_description == NULL || !strcmp(svc_description, ""))) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Servicegroup or group member is NULL\n");
+ return NULL;
+ }
+
+ /* allocate memory for a new member */
+ if((new_member = calloc(1, sizeof(servicesmember))) == NULL)
+ return NULL;
+
+ /* duplicate vars */
+ if((new_member->host_name = (char *)strdup(host_name)) == NULL)
+ result = ERROR;
+ if((new_member->service_description = (char *)strdup(svc_description)) == NULL)
+ result = ERROR;
+
+ /* handle errors */
+ if(result == ERROR) {
+ my_free(new_member->service_description);
+ my_free(new_member->host_name);
+ my_free(new_member);
+ return NULL;
+ }
+
+ /* add new member to member list, sorted by host name then service description */
+ last_member = temp_servicegroup->members;
+ for(temp_member = temp_servicegroup->members; temp_member != NULL; temp_member = temp_member->next) {
+
+ if(strcmp(new_member->host_name, temp_member->host_name) < 0) {
+ new_member->next = temp_member;
+ if(temp_member == temp_servicegroup->members)
+ temp_servicegroup->members = new_member;
+ else
+ last_member->next = new_member;
+ break;
+ }
+
+ else if(strcmp(new_member->host_name, temp_member->host_name) == 0 && strcmp(new_member->service_description, temp_member->service_description) < 0) {
+ new_member->next = temp_member;
+ if(temp_member == temp_servicegroup->members)
+ temp_servicegroup->members = new_member;
+ else
+ last_member->next = new_member;
+ break;
+ }
+
+ else
+ last_member = temp_member;
+ }
+ if(temp_servicegroup->members == NULL) {
+ new_member->next = NULL;
+ temp_servicegroup->members = new_member;
+ }
+ else if(temp_member == NULL) {
+ new_member->next = NULL;
+ last_member->next = new_member;
+ }
+
+ return new_member;
+ }
+
+
+/* add a new contact to the list in memory */
+contact *add_contact(char *name, char *alias, char *email, char *pager, char **addresses, char *svc_notification_period, char *host_notification_period, int notify_service_ok, int notify_service_critical, int notify_service_warning, int notify_service_unknown, int notify_service_flapping, int notify_service_downtime, int notify_host_up, int notify_host_down, int notify_host_unreachable, int notify_host_flapping, int notify_host_downtime, int host_notifications_enabled, int service_notifications_enabled, int can_submit_commands, int retain_status_information, int retain_nonstatus_information) {
+ contact *new_contact = NULL;
+ int x = 0;
+ int result = OK;
+
+ /* make sure we have the data we need */
+ if(name == NULL || !strcmp(name, "")) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Contact name is NULL\n");
+ return NULL;
+ }
+
+ /* allocate memory for a new contact */
+ if((new_contact = (contact *)calloc(1, sizeof(contact))) == NULL)
+ return NULL;
+
+ /* duplicate vars */
+ if((new_contact->name = (char *)strdup(name)) == NULL)
+ result = ERROR;
+ if((new_contact->alias = (char *)strdup((alias == NULL) ? name : alias)) == NULL)
+ result = ERROR;
+ if(email) {
+ if((new_contact->email = (char *)strdup(email)) == NULL)
+ result = ERROR;
+ }
+ if(pager) {
+ if((new_contact->pager = (char *)strdup(pager)) == NULL)
+ result = ERROR;
+ }
+ if(svc_notification_period) {
+ if((new_contact->service_notification_period = (char *)strdup(svc_notification_period)) == NULL)
+ result = ERROR;
+ }
+ if(host_notification_period) {
+ if((new_contact->host_notification_period = (char *)strdup(host_notification_period)) == NULL)
+ result = ERROR;
+ }
+ if(addresses) {
+ for(x = 0; x < MAX_CONTACT_ADDRESSES; x++) {
+ if(addresses[x]) {
+ if((new_contact->address[x] = (char *)strdup(addresses[x])) == NULL)
+ result = ERROR;
+ }
+ }
+ }
+
+ new_contact->notify_on_service_recovery = (notify_service_ok > 0) ? TRUE : FALSE;
+ new_contact->notify_on_service_critical = (notify_service_critical > 0) ? TRUE : FALSE;
+ new_contact->notify_on_service_warning = (notify_service_warning > 0) ? TRUE : FALSE;
+ new_contact->notify_on_service_unknown = (notify_service_unknown > 0) ? TRUE : FALSE;
+ new_contact->notify_on_service_flapping = (notify_service_flapping > 0) ? TRUE : FALSE;
+ new_contact->notify_on_service_downtime = (notify_service_downtime > 0) ? TRUE : FALSE;
+ new_contact->notify_on_host_recovery = (notify_host_up > 0) ? TRUE : FALSE;
+ new_contact->notify_on_host_down = (notify_host_down > 0) ? TRUE : FALSE;
+ new_contact->notify_on_host_unreachable = (notify_host_unreachable > 0) ? TRUE : FALSE;
+ new_contact->notify_on_host_flapping = (notify_host_flapping > 0) ? TRUE : FALSE;
+ new_contact->notify_on_host_downtime = (notify_host_downtime > 0) ? TRUE : FALSE;
+ new_contact->host_notifications_enabled = (host_notifications_enabled > 0) ? TRUE : FALSE;
+ new_contact->service_notifications_enabled = (service_notifications_enabled > 0) ? TRUE : FALSE;
+ new_contact->can_submit_commands = (can_submit_commands > 0) ? TRUE : FALSE;
+ new_contact->retain_status_information = (retain_status_information > 0) ? TRUE : FALSE;
+ new_contact->retain_nonstatus_information = (retain_nonstatus_information > 0) ? TRUE : FALSE;
+#ifdef NSCORE
+ new_contact->last_host_notification = (time_t)0L;
+ new_contact->last_service_notification = (time_t)0L;
+ new_contact->modified_attributes = MODATTR_NONE;
+ new_contact->modified_host_attributes = MODATTR_NONE;
+ new_contact->modified_service_attributes = MODATTR_NONE;
+
+ new_contact->host_notification_period_ptr = NULL;
+ new_contact->service_notification_period_ptr = NULL;
+ new_contact->contactgroups_ptr = NULL;
+#endif
+
+ /* add new contact to skiplist */
+ if(result == OK) {
+ result = skiplist_insert(object_skiplists[CONTACT_SKIPLIST], (void *)new_contact);
+ switch(result) {
+ case SKIPLIST_ERROR_DUPLICATE:
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Contact '%s' has already been defined\n", name);
+ result = ERROR;
+ break;
+ case SKIPLIST_OK:
+ result = OK;
+ break;
+ default:
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Could not add contact '%s' to skiplist\n", name);
+ result = ERROR;
+ break;
+ }
+ }
+
+ /* handle errors */
+ if(result == ERROR) {
+ for(x = 0; x < MAX_CONTACT_ADDRESSES; x++)
+ my_free(new_contact->address[x]);
+ my_free(new_contact->name);
+ my_free(new_contact->alias);
+ my_free(new_contact->email);
+ my_free(new_contact->pager);
+ my_free(new_contact->service_notification_period);
+ my_free(new_contact->host_notification_period);
+ my_free(new_contact);
+ return NULL;
+ }
+
+ /* contacts are sorted alphabetically, so add new items to tail of list */
+ if(contact_list == NULL) {
+ contact_list = new_contact;
+ contact_list_tail = contact_list;
+ }
+ else {
+ contact_list_tail->next = new_contact;
+ contact_list_tail = new_contact;
+ }
+
+ return new_contact;
+ }
+
+
+
+/* adds a host notification command to a contact definition */
+commandsmember *add_host_notification_command_to_contact(contact *cntct, char *command_name) {
+ commandsmember *new_commandsmember = NULL;
+ int result = OK;
+
+ /* make sure we have the data we need */
+ if(cntct == NULL || (command_name == NULL || !strcmp(command_name, ""))) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Contact or host notification command is NULL\n");
+ return NULL;
+ }
+
+ /* allocate memory */
+ if((new_commandsmember = calloc(1, sizeof(commandsmember))) == NULL)
+ return NULL;
+
+ /* duplicate vars */
+ if((new_commandsmember->command = (char *)strdup(command_name)) == NULL)
+ result = ERROR;
+
+ /* handle errors */
+ if(result == ERROR) {
+ my_free(new_commandsmember->command);
+ my_free(new_commandsmember);
+ return NULL;
+ }
+
+ /* add the notification command */
+ new_commandsmember->next = cntct->host_notification_commands;
+ cntct->host_notification_commands = new_commandsmember;
+
+ return new_commandsmember;
+ }
+
+
+
+/* adds a service notification command to a contact definition */
+commandsmember *add_service_notification_command_to_contact(contact *cntct, char *command_name) {
+ commandsmember *new_commandsmember = NULL;
+ int result = OK;
+
+ /* make sure we have the data we need */
+ if(cntct == NULL || (command_name == NULL || !strcmp(command_name, ""))) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Contact or service notification command is NULL\n");
+ return NULL;
+ }
+
+ /* allocate memory */
+ if((new_commandsmember = calloc(1, sizeof(commandsmember))) == NULL)
+ return NULL;
+
+ /* duplicate vars */
+ if((new_commandsmember->command = (char *)strdup(command_name)) == NULL)
+ result = ERROR;
+
+ /* handle errors */
+ if(result == ERROR) {
+ my_free(new_commandsmember->command);
+ my_free(new_commandsmember);
+ return NULL;
+ }
+
+ /* add the notification command */
+ new_commandsmember->next = cntct->service_notification_commands;
+ cntct->service_notification_commands = new_commandsmember;
+
+ return new_commandsmember;
+ }
+
+
+
+/* adds a custom variable to a contact */
+customvariablesmember *add_custom_variable_to_contact(contact *cntct, char *varname, char *varvalue) {
+
+ return add_custom_variable_to_object(&cntct->custom_variables, varname, varvalue);
+ }
+
+
+
+/* add a new contact group to the list in memory */
+contactgroup *add_contactgroup(char *name, char *alias) {
+ contactgroup *new_contactgroup = NULL;
+ int result = OK;
+
+ /* make sure we have the data we need */
+ if(name == NULL || !strcmp(name, "")) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Contactgroup name is NULL\n");
+ return NULL;
+ }
+
+ /* allocate memory for a new contactgroup entry */
+ if((new_contactgroup = calloc(1, sizeof(contactgroup))) == NULL)
+ return NULL;
+
+ /* duplicate vars */
+ if((new_contactgroup->group_name = (char *)strdup(name)) == NULL)
+ result = ERROR;
+ if((new_contactgroup->alias = (char *)strdup((alias == NULL) ? name : alias)) == NULL)
+ result = ERROR;
+
+ /* add new contact group to skiplist */
+ if(result == OK) {
+ result = skiplist_insert(object_skiplists[CONTACTGROUP_SKIPLIST], (void *)new_contactgroup);
+ switch(result) {
+ case SKIPLIST_ERROR_DUPLICATE:
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Contactgroup '%s' has already been defined\n", name);
+ result = ERROR;
+ break;
+ case SKIPLIST_OK:
+ result = OK;
+ break;
+ default:
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Could not add contactgroup '%s' to skiplist\n", name);
+ result = ERROR;
+ break;
+ }
+ }
+
+ /* handle errors */
+ if(result == ERROR) {
+ my_free(new_contactgroup->alias);
+ my_free(new_contactgroup->group_name);
+ my_free(new_contactgroup);
+ return NULL;
+ }
+
+ /* contactgroups are sorted alphabetically, so add new items to tail of list */
+ if(contactgroup_list == NULL) {
+ contactgroup_list = new_contactgroup;
+ contactgroup_list_tail = contactgroup_list;
+ }
+ else {
+ contactgroup_list_tail->next = new_contactgroup;
+ contactgroup_list_tail = new_contactgroup;
+ }
+
+ return new_contactgroup;
+ }
+
+
+
+/* add a new member to a contact group */
+contactsmember *add_contact_to_contactgroup(contactgroup *grp, char *contact_name) {
+ contactsmember *new_contactsmember = NULL;
+ int result = OK;
+
+ /* make sure we have the data we need */
+ if(grp == NULL || (contact_name == NULL || !strcmp(contact_name, ""))) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Contactgroup or contact name is NULL\n");
+ return NULL;
+ }
+
+ /* allocate memory for a new member */
+ if((new_contactsmember = calloc(1, sizeof(contactsmember))) == NULL)
+ return NULL;
+
+ /* duplicate vars */
+ if((new_contactsmember->contact_name = (char *)strdup(contact_name)) == NULL)
+ result = ERROR;
+
+ /* handle errors */
+ if(result == ERROR) {
+ my_free(new_contactsmember->contact_name);
+ my_free(new_contactsmember);
+ return NULL;
+ }
+
+ /* add the new member to the head of the member list */
+ new_contactsmember->next = grp->members;
+ grp->members = new_contactsmember;
+
+ return new_contactsmember;
+ }
+
+
+
+/* add a new service to the list in memory */
+service *add_service(char *host_name, char *description, char *display_name, char *check_period, int initial_state, int max_attempts, int parallelize, int accept_passive_checks, double check_interval, double retry_interval, double notification_interval, double first_notification_delay, char *notification_period, int notify_recovery, int notify_unknown, int notify_warning, int notify_critical, int notify_flapping, int notify_downtime, int notifications_enabled, int is_volatile, char *event_handler, int event_handler_enabled, char *check_command, int checks_enabled, int flap_detection_enabled, double low_flap_threshold, double high_flap_threshold, int flap_detection_on_ok, int flap_detection_on_warning, int flap_detection_on_unknown, int flap_detection_on_critical, int stalk_on_ok, int stalk_on_warning, int stalk_on_unknown, int stalk_on_critical, int process_perfdata, int failure_prediction_enabled, char *failure_prediction_options, int check_freshness, int freshness_threshold, char *notes, char *notes_url, char *action_url, char *icon_image, char *icon_image_alt, int retain_status_information, int retain_nonstatus_information, int obsess_over_service) {
+ service *new_service = NULL;
+ int result = OK;
+#ifdef NSCORE
+ int x = 0;
+#endif
+
+ /* make sure we have everything we need */
+ if((host_name == NULL || !strcmp(host_name, "")) || (description == NULL || !strcmp(description, "")) || (check_command == NULL || !strcmp(check_command, ""))) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Service description, host name, or check command is NULL\n");
+ return NULL;
+ }
+
+ /* check values */
+ if(max_attempts <= 0 || check_interval < 0 || retry_interval <= 0 || notification_interval < 0) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Invalid max_attempts, check_interval, retry_interval, or notification_interval value for service '%s' on host '%s'\n", description, host_name);
+ return NULL;
+ }
+
+ if(first_notification_delay < 0) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Invalid first_notification_delay value for service '%s' on host '%s'\n", description, host_name);
+ return NULL;
+ }
+
+ /* allocate memory */
+ if((new_service = (service *)calloc(1, sizeof(service))) == NULL)
+ return NULL;
+
+ /* duplicate vars */
+ if((new_service->host_name = (char *)strdup(host_name)) == NULL)
+ result = ERROR;
+ if((new_service->description = (char *)strdup(description)) == NULL)
+ result = ERROR;
+ if((new_service->display_name = (char *)strdup((display_name == NULL) ? description : display_name)) == NULL)
+ result = ERROR;
+ if((new_service->service_check_command = (char *)strdup(check_command)) == NULL)
+ result = ERROR;
+ if(event_handler) {
+ if((new_service->event_handler = (char *)strdup(event_handler)) == NULL)
+ result = ERROR;
+ }
+ if(notification_period) {
+ if((new_service->notification_period = (char *)strdup(notification_period)) == NULL)
+ result = ERROR;
+ }
+ if(check_period) {
+ if((new_service->check_period = (char *)strdup(check_period)) == NULL)
+ result = ERROR;
+ }
+ if(failure_prediction_options) {
+ if((new_service->failure_prediction_options = (char *)strdup(failure_prediction_options)) == NULL)
+ result = ERROR;
+ }
+ if(notes) {
+ if((new_service->notes = (char *)strdup(notes)) == NULL)
+ result = ERROR;
+ }
+ if(notes_url) {
+ if((new_service->notes_url = (char *)strdup(notes_url)) == NULL)
+ result = ERROR;
+ }
+ if(action_url) {
+ if((new_service->action_url = (char *)strdup(action_url)) == NULL)
+ result = ERROR;
+ }
+ if(icon_image) {
+ if((new_service->icon_image = (char *)strdup(icon_image)) == NULL)
+ result = ERROR;
+ }
+ if(icon_image_alt) {
+ if((new_service->icon_image_alt = (char *)strdup(icon_image_alt)) == NULL)
+ result = ERROR;
+ }
+
+ new_service->check_interval = check_interval;
+ new_service->retry_interval = retry_interval;
+ new_service->max_attempts = max_attempts;
+ new_service->parallelize = (parallelize > 0) ? TRUE : FALSE;
+ new_service->notification_interval = notification_interval;
+ new_service->first_notification_delay = first_notification_delay;
+ new_service->notify_on_unknown = (notify_unknown > 0) ? TRUE : FALSE;
+ new_service->notify_on_warning = (notify_warning > 0) ? TRUE : FALSE;
+ new_service->notify_on_critical = (notify_critical > 0) ? TRUE : FALSE;
+ new_service->notify_on_recovery = (notify_recovery > 0) ? TRUE : FALSE;
+ new_service->notify_on_flapping = (notify_flapping > 0) ? TRUE : FALSE;
+ new_service->notify_on_downtime = (notify_downtime > 0) ? TRUE : FALSE;
+ new_service->is_volatile = (is_volatile > 0) ? TRUE : FALSE;
+ new_service->flap_detection_enabled = (flap_detection_enabled > 0) ? TRUE : FALSE;
+ new_service->low_flap_threshold = low_flap_threshold;
+ new_service->high_flap_threshold = high_flap_threshold;
+ new_service->flap_detection_on_ok = (flap_detection_on_ok > 0) ? TRUE : FALSE;
+ new_service->flap_detection_on_warning = (flap_detection_on_warning > 0) ? TRUE : FALSE;
+ new_service->flap_detection_on_unknown = (flap_detection_on_unknown > 0) ? TRUE : FALSE;
+ new_service->flap_detection_on_critical = (flap_detection_on_critical > 0) ? TRUE : FALSE;
+ new_service->stalk_on_ok = (stalk_on_ok > 0) ? TRUE : FALSE;
+ new_service->stalk_on_warning = (stalk_on_warning > 0) ? TRUE : FALSE;
+ new_service->stalk_on_unknown = (stalk_on_unknown > 0) ? TRUE : FALSE;
+ new_service->stalk_on_critical = (stalk_on_critical > 0) ? TRUE : FALSE;
+ new_service->process_performance_data = (process_perfdata > 0) ? TRUE : FALSE;
+ new_service->check_freshness = (check_freshness > 0) ? TRUE : FALSE;
+ new_service->freshness_threshold = freshness_threshold;
+ new_service->accept_passive_service_checks = (accept_passive_checks > 0) ? TRUE : FALSE;
+ new_service->event_handler_enabled = (event_handler_enabled > 0) ? TRUE : FALSE;
+ new_service->checks_enabled = (checks_enabled > 0) ? TRUE : FALSE;
+ new_service->retain_status_information = (retain_status_information > 0) ? TRUE : FALSE;
+ new_service->retain_nonstatus_information = (retain_nonstatus_information > 0) ? TRUE : FALSE;
+ new_service->notifications_enabled = (notifications_enabled > 0) ? TRUE : FALSE;
+ new_service->obsess_over_service = (obsess_over_service > 0) ? TRUE : FALSE;
+ new_service->failure_prediction_enabled = (failure_prediction_enabled > 0) ? TRUE : FALSE;
+#ifdef NSCORE
+ new_service->problem_has_been_acknowledged = FALSE;
+ new_service->acknowledgement_type = ACKNOWLEDGEMENT_NONE;
+ new_service->check_type = SERVICE_CHECK_ACTIVE;
+ new_service->current_attempt = (initial_state == STATE_OK) ? 1 : max_attempts;
+ new_service->current_state = initial_state;
+ new_service->current_event_id = 0L;
+ new_service->last_event_id = 0L;
+ new_service->current_problem_id = 0L;
+ new_service->last_problem_id = 0L;
+ new_service->last_state = initial_state;
+ new_service->last_hard_state = initial_state;
+ new_service->state_type = HARD_STATE;
+ new_service->host_problem_at_last_check = FALSE;
+ new_service->check_flapping_recovery_notification = FALSE;
+ new_service->next_check = (time_t)0;
+ new_service->should_be_scheduled = TRUE;
+ new_service->last_check = (time_t)0;
+ new_service->last_notification = (time_t)0;
+ new_service->next_notification = (time_t)0;
+ new_service->no_more_notifications = FALSE;
+ new_service->last_state_change = (time_t)0;
+ new_service->last_hard_state_change = (time_t)0;
+ new_service->last_time_ok = (time_t)0;
+ new_service->last_time_warning = (time_t)0;
+ new_service->last_time_unknown = (time_t)0;
+ new_service->last_time_critical = (time_t)0;
+ new_service->has_been_checked = FALSE;
+ new_service->is_being_freshened = FALSE;
+ new_service->notified_on_unknown = FALSE;
+ new_service->notified_on_warning = FALSE;
+ new_service->notified_on_critical = FALSE;
+ new_service->current_notification_number = 0;
+ new_service->current_notification_id = 0L;
+ new_service->latency = 0.0;
+ new_service->execution_time = 0.0;
+ new_service->is_executing = FALSE;
+ new_service->check_options = CHECK_OPTION_NONE;
+ new_service->scheduled_downtime_depth = 0;
+ new_service->pending_flex_downtime = 0;
+ for(x = 0; x < MAX_STATE_HISTORY_ENTRIES; x++)
+ new_service->state_history[x] = STATE_OK;
+ new_service->state_history_index = 0;
+ new_service->is_flapping = FALSE;
+ new_service->flapping_comment_id = 0;
+ new_service->percent_state_change = 0.0;
+ new_service->modified_attributes = MODATTR_NONE;
+#endif
+
+ /* add new service to skiplist */
+ if(result == OK) {
+ result = skiplist_insert(object_skiplists[SERVICE_SKIPLIST], (void *)new_service);
+ switch(result) {
+ case SKIPLIST_ERROR_DUPLICATE:
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Service '%s' on host '%s' has already been defined\n", description, host_name);
+ result = ERROR;
+ break;
+ case SKIPLIST_OK:
+ result = OK;
+ break;
+ default:
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Could not add service '%s' on host '%s' to skiplist\n", description, host_name);
+ result = ERROR;
+ break;
+ }
+ }
+
+ /* handle errors */
+ if(result == ERROR) {
+#ifdef NSCORE
+ my_free(new_service->perf_data);
+ my_free(new_service->plugin_output);
+ my_free(new_service->long_plugin_output);
+#endif
+ my_free(new_service->failure_prediction_options);
+ my_free(new_service->notification_period);
+ my_free(new_service->event_handler);
+ my_free(new_service->service_check_command);
+ my_free(new_service->description);
+ my_free(new_service->host_name);
+ my_free(new_service->display_name);
+ my_free(new_service);
+ return NULL;
+ }
+
+ /* services are sorted alphabetically, so add new items to tail of list */
+ if(service_list == NULL) {
+ service_list = new_service;
+ service_list_tail = service_list;
+ }
+ else {
+ service_list_tail->next = new_service;
+ service_list_tail = new_service;
+ }
+
+ return new_service;
+ }
+
+
+
+/* adds a contact group to a service */
+contactgroupsmember *add_contactgroup_to_service(service *svc, char *group_name) {
+ contactgroupsmember *new_contactgroupsmember = NULL;
+ int result = OK;
+
+ /* bail out if we weren't given the data we need */
+ if(svc == NULL || (group_name == NULL || !strcmp(group_name, ""))) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Service or contactgroup name is NULL\n");
+ return NULL;
+ }
+
+ /* allocate memory for the contactgroups member */
+ if((new_contactgroupsmember = calloc(1, sizeof(contactgroupsmember))) == NULL)
+ return NULL;
+
+ /* duplicate vars */
+ if((new_contactgroupsmember->group_name = (char *)strdup(group_name)) == NULL)
+ result = ERROR;
+
+ /* handle errors */
+ if(result == ERROR) {
+ my_free(new_contactgroupsmember);
+ return NULL;
+ }
+
+ /* add this contactgroup to the service */
+ new_contactgroupsmember->next = svc->contact_groups;
+ svc->contact_groups = new_contactgroupsmember;
+
+ return new_contactgroupsmember;
+ }
+
+
+
+/* adds a contact to a service */
+contactsmember *add_contact_to_service(service *svc, char *contact_name) {
+
+ return add_contact_to_object(&svc->contacts, contact_name);
+ }
+
+
+
+/* adds a custom variable to a service */
+customvariablesmember *add_custom_variable_to_service(service *svc, char *varname, char *varvalue) {
+
+ return add_custom_variable_to_object(&svc->custom_variables, varname, varvalue);
+ }
+
+
+
+/* add a new command to the list in memory */
+command *add_command(char *name, char *value) {
+ command *new_command = NULL;
+ int result = OK;
+
+ /* make sure we have the data we need */
+ if((name == NULL || !strcmp(name, "")) || (value == NULL || !strcmp(value, ""))) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Command name of command line is NULL\n");
+ return NULL;
+ }
+
+ /* allocate memory for the new command */
+ if((new_command = (command *)calloc(1, sizeof(command))) == NULL)
+ return NULL;
+
+ /* duplicate vars */
+ if((new_command->name = (char *)strdup(name)) == NULL)
+ result = ERROR;
+ if((new_command->command_line = (char *)strdup(value)) == NULL)
+ result = ERROR;
+
+ /* add new command to skiplist */
+ if(result == OK) {
+ result = skiplist_insert(object_skiplists[COMMAND_SKIPLIST], (void *)new_command);
+ switch(result) {
+ case SKIPLIST_ERROR_DUPLICATE:
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Command '%s' has already been defined\n", name);
+ result = ERROR;
+ break;
+ case SKIPLIST_OK:
+ result = OK;
+ break;
+ default:
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Could not add command '%s' to skiplist\n", name);
+ result = ERROR;
+ break;
+ }
+ }
+
+ /* handle errors */
+ if(result == ERROR) {
+ my_free(new_command->command_line);
+ my_free(new_command->name);
+ my_free(new_command);
+ return NULL;
+ }
+
+ /* commands are sorted alphabetically, so add new items to tail of list */
+ if(command_list == NULL) {
+ command_list = new_command;
+ command_list_tail = command_list;
+ }
+ else {
+ command_list_tail->next = new_command;
+ command_list_tail = new_command;
+ }
+
+ return new_command;
+ }
+
+
+
+/* add a new service escalation to the list in memory */
+serviceescalation *add_serviceescalation(char *host_name, char *description, int first_notification, int last_notification, double notification_interval, char *escalation_period, int escalate_on_warning, int escalate_on_unknown, int escalate_on_critical, int escalate_on_recovery) {
+ serviceescalation *new_serviceescalation = NULL;
+ int result = OK;
+
+ /* make sure we have the data we need */
+ if((host_name == NULL || !strcmp(host_name, "")) || (description == NULL || !strcmp(description, ""))) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Service escalation host name or description is NULL\n");
+ return NULL;
+ }
+
+#ifdef TEST
+ printf("NEW SVC ESCALATION: %s/%s = %d/%d/%.3f\n", host_name, description, first_notification, last_notification, notification_interval);
+#endif
+
+ /* allocate memory for a new service escalation entry */
+ if((new_serviceescalation = calloc(1, sizeof(serviceescalation))) == NULL)
+ return NULL;
+
+ /* duplicate vars */
+ if((new_serviceescalation->host_name = (char *)strdup(host_name)) == NULL)
+ result = ERROR;
+ if((new_serviceescalation->description = (char *)strdup(description)) == NULL)
+ result = ERROR;
+ if(escalation_period) {
+ if((new_serviceescalation->escalation_period = (char *)strdup(escalation_period)) == NULL)
+ result = ERROR;
+ }
+
+ new_serviceescalation->first_notification = first_notification;
+ new_serviceescalation->last_notification = last_notification;
+ new_serviceescalation->notification_interval = (notification_interval <= 0) ? 0 : notification_interval;
+ new_serviceescalation->escalate_on_recovery = (escalate_on_recovery > 0) ? TRUE : FALSE;
+ new_serviceescalation->escalate_on_warning = (escalate_on_warning > 0) ? TRUE : FALSE;
+ new_serviceescalation->escalate_on_unknown = (escalate_on_unknown > 0) ? TRUE : FALSE;
+ new_serviceescalation->escalate_on_critical = (escalate_on_critical > 0) ? TRUE : FALSE;
+
+ /* add new serviceescalation to skiplist */
+ if(result == OK) {
+ result = skiplist_insert(object_skiplists[SERVICEESCALATION_SKIPLIST], (void *)new_serviceescalation);
+ switch(result) {
+ case SKIPLIST_OK:
+ result = OK;
+ break;
+ default:
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Could not add escalation for service '%s' on host '%s' to skiplist\n", description, host_name);
+ result = ERROR;
+ break;
+ }
+ }
+
+ /* handle errors */
+ if(result == ERROR) {
+ my_free(new_serviceescalation->host_name);
+ my_free(new_serviceescalation->description);
+ my_free(new_serviceescalation->escalation_period);
+ my_free(new_serviceescalation);
+ return NULL;
+ }
+
+ /* service escalations are sorted alphabetically, so add new items to tail of list */
+ if(serviceescalation_list == NULL) {
+ serviceescalation_list = new_serviceescalation;
+ serviceescalation_list_tail = serviceescalation_list;
+ }
+ else {
+ serviceescalation_list_tail->next = new_serviceescalation;
+ serviceescalation_list_tail = new_serviceescalation;
+ }
+
+ return new_serviceescalation;
+ }
+
+
+
+/* adds a contact group to a service escalation */
+contactgroupsmember *add_contactgroup_to_serviceescalation(serviceescalation *se, char *group_name) {
+ contactgroupsmember *new_contactgroupsmember = NULL;
+ int result = OK;
+
+ /* bail out if we weren't given the data we need */
+ if(se == NULL || (group_name == NULL || !strcmp(group_name, ""))) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Service escalation or contactgroup name is NULL\n");
+ return NULL;
+ }
+
+ /* allocate memory for the contactgroups member */
+ if((new_contactgroupsmember = (contactgroupsmember *)calloc(1, sizeof(contactgroupsmember))) == NULL)
+ return NULL;
+
+ /* duplicate vars */
+ if((new_contactgroupsmember->group_name = (char *)strdup(group_name)) == NULL)
+ result = ERROR;
+
+ /* handle errors */
+ if(result == ERROR) {
+ my_free(new_contactgroupsmember->group_name);
+ my_free(new_contactgroupsmember);
+ return NULL;
+ }
+
+ /* add this contactgroup to the service escalation */
+ new_contactgroupsmember->next = se->contact_groups;
+ se->contact_groups = new_contactgroupsmember;
+
+ return new_contactgroupsmember;
+ }
+
+
+
+/* adds a contact to a service escalation */
+contactsmember *add_contact_to_serviceescalation(serviceescalation *se, char *contact_name) {
+
+ return add_contact_to_object(&se->contacts, contact_name);
+ }
+
+
+
+/* adds a service dependency definition */
+servicedependency *add_service_dependency(char *dependent_host_name, char *dependent_service_description, char *host_name, char *service_description, int dependency_type, int inherits_parent, int fail_on_ok, int fail_on_warning, int fail_on_unknown, int fail_on_critical, int fail_on_pending, char *dependency_period) {
+ servicedependency *new_servicedependency = NULL;
+ int result = OK;
+
+ /* make sure we have what we need */
+ if((host_name == NULL || !strcmp(host_name, "")) || (service_description == NULL || !strcmp(service_description, ""))) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: NULL master service description/host name in service dependency definition\n");
+ return NULL;
+ }
+ if((dependent_host_name == NULL || !strcmp(dependent_host_name, "")) || (dependent_service_description == NULL || !strcmp(dependent_service_description, ""))) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: NULL dependent service description/host name in service dependency definition\n");
+ return NULL;
+ }
+
+ /* allocate memory for a new service dependency entry */
+ if((new_servicedependency = (servicedependency *)calloc(1, sizeof(servicedependency))) == NULL)
+ return NULL;
+
+ /* duplicate vars */
+ if((new_servicedependency->dependent_host_name = (char *)strdup(dependent_host_name)) == NULL)
+ result = ERROR;
+ if((new_servicedependency->dependent_service_description = (char *)strdup(dependent_service_description)) == NULL)
+ result = ERROR;
+ if((new_servicedependency->host_name = (char *)strdup(host_name)) == NULL)
+ result = ERROR;
+ if((new_servicedependency->service_description = (char *)strdup(service_description)) == NULL)
+ result = ERROR;
+ if(dependency_period) {
+ if((new_servicedependency->dependency_period = (char *)strdup(dependency_period)) == NULL)
+ result = ERROR;
+ }
+
+ new_servicedependency->dependency_type = (dependency_type == EXECUTION_DEPENDENCY) ? EXECUTION_DEPENDENCY : NOTIFICATION_DEPENDENCY;
+ new_servicedependency->inherits_parent = (inherits_parent > 0) ? TRUE : FALSE;
+ new_servicedependency->fail_on_ok = (fail_on_ok == 1) ? TRUE : FALSE;
+ new_servicedependency->fail_on_warning = (fail_on_warning == 1) ? TRUE : FALSE;
+ new_servicedependency->fail_on_unknown = (fail_on_unknown == 1) ? TRUE : FALSE;
+ new_servicedependency->fail_on_critical = (fail_on_critical == 1) ? TRUE : FALSE;
+ new_servicedependency->fail_on_pending = (fail_on_pending == 1) ? TRUE : FALSE;
+#ifdef NSCORE
+ new_servicedependency->circular_path_checked = FALSE;
+ new_servicedependency->contains_circular_path = FALSE;
+#endif
+
+ /* add new service dependency to skiplist */
+ if(result == OK) {
+ result = skiplist_insert(object_skiplists[SERVICEDEPENDENCY_SKIPLIST], (void *)new_servicedependency);
+ switch(result) {
+ case SKIPLIST_OK:
+ result = OK;
+ break;
+ default:
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Could not add service dependency to skiplist\n");
+ result = ERROR;
+ break;
+ }
+ }
+
+ /* handle errors */
+ if(result == ERROR) {
+ my_free(new_servicedependency->host_name);
+ my_free(new_servicedependency->service_description);
+ my_free(new_servicedependency->dependent_host_name);
+ my_free(new_servicedependency->dependent_service_description);
+ my_free(new_servicedependency);
+ return NULL;
+ }
+
+ /* service dependencies are sorted alphabetically, so add new items to tail of list */
+ if(servicedependency_list == NULL) {
+ servicedependency_list = new_servicedependency;
+ servicedependency_list_tail = servicedependency_list;
+ }
+ else {
+ servicedependency_list_tail->next = new_servicedependency;
+ servicedependency_list_tail = new_servicedependency;
+ }
+
+ return new_servicedependency;
+ }
+
+
+/* adds a host dependency definition */
+hostdependency *add_host_dependency(char *dependent_host_name, char *host_name, int dependency_type, int inherits_parent, int fail_on_up, int fail_on_down, int fail_on_unreachable, int fail_on_pending, char *dependency_period) {
+ hostdependency *new_hostdependency = NULL;
+ int result = OK;
+
+ /* make sure we have what we need */
+ if((dependent_host_name == NULL || !strcmp(dependent_host_name, "")) || (host_name == NULL || !strcmp(host_name, ""))) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: NULL host name in host dependency definition\n");
+ return NULL;
+ }
+
+ /* allocate memory for a new host dependency entry */
+ if((new_hostdependency = (hostdependency *)calloc(1, sizeof(hostdependency))) == NULL)
+ return NULL;
+
+ /* duplicate vars */
+ if((new_hostdependency->dependent_host_name = (char *)strdup(dependent_host_name)) == NULL)
+ result = ERROR;
+ if((new_hostdependency->host_name = (char *)strdup(host_name)) == NULL)
+ result = ERROR;
+ if(dependency_period) {
+ if((new_hostdependency->dependency_period = (char *)strdup(dependency_period)) == NULL)
+ result = ERROR;
+ }
+
+ new_hostdependency->dependency_type = (dependency_type == EXECUTION_DEPENDENCY) ? EXECUTION_DEPENDENCY : NOTIFICATION_DEPENDENCY;
+ new_hostdependency->inherits_parent = (inherits_parent > 0) ? TRUE : FALSE;
+ new_hostdependency->fail_on_up = (fail_on_up == 1) ? TRUE : FALSE;
+ new_hostdependency->fail_on_down = (fail_on_down == 1) ? TRUE : FALSE;
+ new_hostdependency->fail_on_unreachable = (fail_on_unreachable == 1) ? TRUE : FALSE;
+ new_hostdependency->fail_on_pending = (fail_on_pending == 1) ? TRUE : FALSE;
+#ifdef NSCORE
+ new_hostdependency->circular_path_checked = FALSE;
+ new_hostdependency->contains_circular_path = FALSE;
+#endif
+
+ /* add new host dependency to skiplist */
+ if(result == OK) {
+ result = skiplist_insert(object_skiplists[HOSTDEPENDENCY_SKIPLIST], (void *)new_hostdependency);
+ switch(result) {
+ case SKIPLIST_OK:
+ result = OK;
+ break;
+ default:
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Could not add host dependency to skiplist\n");
+ result = ERROR;
+ break;
+ }
+ }
+
+ /* handle errors */
+ if(result == ERROR) {
+ my_free(new_hostdependency->host_name);
+ my_free(new_hostdependency->dependent_host_name);
+ my_free(new_hostdependency);
+ return NULL;
+ }
+
+ /* host dependencies are sorted alphabetically, so add new items to tail of list */
+ if(hostdependency_list == NULL) {
+ hostdependency_list = new_hostdependency;
+ hostdependency_list_tail = hostdependency_list;
+ }
+ else {
+ hostdependency_list_tail->next = new_hostdependency;
+ hostdependency_list_tail = new_hostdependency;
+ }
+
+ return new_hostdependency;
+ }
+
+
+
+/* add a new host escalation to the list in memory */
+hostescalation *add_hostescalation(char *host_name, int first_notification, int last_notification, double notification_interval, char *escalation_period, int escalate_on_down, int escalate_on_unreachable, int escalate_on_recovery) {
+ hostescalation *new_hostescalation = NULL;
+ int result = OK;
+
+ /* make sure we have the data we need */
+ if(host_name == NULL || !strcmp(host_name, "")) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Host escalation host name is NULL\n");
+ return NULL;
+ }
+
+#ifdef TEST
+ printf("NEW HST ESCALATION: %s = %d/%d/%.3f\n", host_name, first_notification, last_notification, notification_interval);
+#endif
+
+ /* allocate memory for a new host escalation entry */
+ if((new_hostescalation = calloc(1, sizeof(hostescalation))) == NULL)
+ return NULL;
+
+ /* duplicate vars */
+ if((new_hostescalation->host_name = (char *)strdup(host_name)) == NULL)
+ result = ERROR;
+ if(escalation_period) {
+ if((new_hostescalation->escalation_period = (char *)strdup(escalation_period)) == NULL)
+ result = ERROR;
+ }
+
+ new_hostescalation->first_notification = first_notification;
+ new_hostescalation->last_notification = last_notification;
+ new_hostescalation->notification_interval = (notification_interval <= 0) ? 0 : notification_interval;
+ new_hostescalation->escalate_on_recovery = (escalate_on_recovery > 0) ? TRUE : FALSE;
+ new_hostescalation->escalate_on_down = (escalate_on_down > 0) ? TRUE : FALSE;
+ new_hostescalation->escalate_on_unreachable = (escalate_on_unreachable > 0) ? TRUE : FALSE;
+
+ /* add new hostescalation to skiplist */
+ if(result == OK) {
+ result = skiplist_insert(object_skiplists[HOSTESCALATION_SKIPLIST], (void *)new_hostescalation);
+ switch(result) {
+ case SKIPLIST_OK:
+ result = OK;
+ break;
+ default:
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Could not add hostescalation '%s' to skiplist\n", host_name);
+ result = ERROR;
+ break;
+ }
+ }
+
+ /* handle errors */
+ if(result == ERROR) {
+ my_free(new_hostescalation->host_name);
+ my_free(new_hostescalation->escalation_period);
+ my_free(new_hostescalation);
+ return NULL;
+ }
+
+ /* host escalations are sorted alphabetically, so add new items to tail of list */
+ if(hostescalation_list == NULL) {
+ hostescalation_list = new_hostescalation;
+ hostescalation_list_tail = hostescalation_list;
+ }
+ else {
+ hostescalation_list_tail->next = new_hostescalation;
+ hostescalation_list_tail = new_hostescalation;
+ }
+
+ return new_hostescalation;
+ }
+
+
+
+/* adds a contact group to a host escalation */
+contactgroupsmember *add_contactgroup_to_hostescalation(hostescalation *he, char *group_name) {
+ contactgroupsmember *new_contactgroupsmember = NULL;
+ int result = OK;
+
+ /* bail out if we weren't given the data we need */
+ if(he == NULL || (group_name == NULL || !strcmp(group_name, ""))) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Host escalation or contactgroup name is NULL\n");
+ return NULL;
+ }
+
+ /* allocate memory for the contactgroups member */
+ if((new_contactgroupsmember = (contactgroupsmember *)calloc(1, sizeof(contactgroupsmember))) == NULL)
+ return NULL;
+
+ /* duplicate vars */
+ if((new_contactgroupsmember->group_name = (char *)strdup(group_name)) == NULL)
+ result = ERROR;
+
+ /* handle errors */
+ if(result == ERROR) {
+ my_free(new_contactgroupsmember->group_name);
+ my_free(new_contactgroupsmember);
+ return NULL;
+ }
+
+ /* add this contactgroup to the host escalation */
+ new_contactgroupsmember->next = he->contact_groups;
+ he->contact_groups = new_contactgroupsmember;
+
+ return new_contactgroupsmember;
+ }
+
+
+
+/* adds a contact to a host escalation */
+contactsmember *add_contact_to_hostescalation(hostescalation *he, char *contact_name) {
+
+ return add_contact_to_object(&he->contacts, contact_name);
+ }
+
+
+
+/* adds a contact to an object */
+contactsmember *add_contact_to_object(contactsmember **object_ptr, char *contactname) {
+ contactsmember *new_contactsmember = NULL;
+
+ /* make sure we have the data we need */
+ if(object_ptr == NULL) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Contact object is NULL\n");
+ return NULL;
+ }
+
+ if(contactname == NULL || !strcmp(contactname, "")) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Contact name is NULL\n");
+ return NULL;
+ }
+
+ /* allocate memory for a new member */
+ if((new_contactsmember = malloc(sizeof(contactsmember))) == NULL) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Could not allocate memory for contact\n");
+ return NULL;
+ }
+ if((new_contactsmember->contact_name = (char *)strdup(contactname)) == NULL) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Could not allocate memory for contact name\n");
+ my_free(new_contactsmember);
+ return NULL;
+ }
+
+ /* set initial values */
+#ifdef NSCORE
+ new_contactsmember->contact_ptr = NULL;
+#endif
+
+ /* add the new contact to the head of the contact list */
+ new_contactsmember->next = *object_ptr;
+ *object_ptr = new_contactsmember;
+
+ return new_contactsmember;
+ }
+
+
+
+/* adds a custom variable to an object */
+customvariablesmember *add_custom_variable_to_object(customvariablesmember **object_ptr, char *varname, char *varvalue) {
+ customvariablesmember *new_customvariablesmember = NULL;
+
+ /* make sure we have the data we need */
+ if(object_ptr == NULL) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Custom variable object is NULL\n");
+ return NULL;
+ }
+
+ if(varname == NULL || !strcmp(varname, "")) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Custom variable name is NULL\n");
+ return NULL;
+ }
+
+ /* allocate memory for a new member */
+ if((new_customvariablesmember = malloc(sizeof(customvariablesmember))) == NULL) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Could not allocate memory for custom variable\n");
+ return NULL;
+ }
+ if((new_customvariablesmember->variable_name = (char *)strdup(varname)) == NULL) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Could not allocate memory for custom variable name\n");
+ my_free(new_customvariablesmember);
+ return NULL;
+ }
+ if(varvalue) {
+ if((new_customvariablesmember->variable_value = (char *)strdup(varvalue)) == NULL) {
+ logit(NSLOG_CONFIG_ERROR, TRUE, "Error: Could not allocate memory for custom variable value\n");
+ my_free(new_customvariablesmember->variable_name);
+ my_free(new_customvariablesmember);
+ return NULL;
+ }
+ }
+ else
+ new_customvariablesmember->variable_value = NULL;
+
+ /* set initial values */
+ new_customvariablesmember->has_been_modified = FALSE;
+
+ /* add the new member to the head of the member list */
+ new_customvariablesmember->next = *object_ptr;
+ *object_ptr = new_customvariablesmember;
+
+ return new_customvariablesmember;
+ }
+
+
+
+
+/******************************************************************/
+/******************** OBJECT SEARCH FUNCTIONS *********************/
+/******************************************************************/
+
+/* given a timeperiod name and a starting point, find a timeperiod from the list in memory */
+timeperiod * find_timeperiod(char *name) {
+ timeperiod temp_timeperiod;
+
+ if(name == NULL)
+ return NULL;
+
+ temp_timeperiod.name = name;
+
+ return skiplist_find_first(object_skiplists[TIMEPERIOD_SKIPLIST], &temp_timeperiod, NULL);
+ }
+
+
+/* given a host name, find it in the list in memory */
+host * find_host(char *name) {
+ host temp_host;
+
+ if(name == NULL)
+ return NULL;
+
+ temp_host.name = name;
+
+ return skiplist_find_first(object_skiplists[HOST_SKIPLIST], &temp_host, NULL);
+ }
+
+
+/* find a hostgroup from the list in memory */
+hostgroup * find_hostgroup(char *name) {
+ hostgroup temp_hostgroup;
+
+ if(name == NULL)
+ return NULL;
+
+ temp_hostgroup.group_name = name;
+
+ return skiplist_find_first(object_skiplists[HOSTGROUP_SKIPLIST], &temp_hostgroup, NULL);
+ }
+
+
+/* find a servicegroup from the list in memory */
+servicegroup * find_servicegroup(char *name) {
+ servicegroup temp_servicegroup;
+
+ if(name == NULL)
+ return NULL;
+
+ temp_servicegroup.group_name = name;
+
+ return skiplist_find_first(object_skiplists[SERVICEGROUP_SKIPLIST], &temp_servicegroup, NULL);
+ }
+
+
+/* find a contact from the list in memory */
+contact * find_contact(char *name) {
+ contact temp_contact;
+
+ if(name == NULL)
+ return NULL;
+
+ temp_contact.name = name;
+
+ return skiplist_find_first(object_skiplists[CONTACT_SKIPLIST], &temp_contact, NULL);
+ }
+
+
+/* find a contact group from the list in memory */
+contactgroup * find_contactgroup(char *name) {
+ contactgroup temp_contactgroup;
+
+ if(name == NULL)
+ return NULL;
+
+ temp_contactgroup.group_name = name;
+
+ return skiplist_find_first(object_skiplists[CONTACTGROUP_SKIPLIST], &temp_contactgroup, NULL);
+ }
+
+
+/* given a command name, find a command from the list in memory */
+command * find_command(char *name) {
+ command temp_command;
+
+ if(name == NULL)
+ return NULL;
+
+ temp_command.name = name;
+
+ return skiplist_find_first(object_skiplists[COMMAND_SKIPLIST], &temp_command, NULL);
+ }
+
+
+/* given a host/service name, find the service in the list in memory */
+service * find_service(char *host_name, char *svc_desc) {
+ service temp_service;
+
+ if(host_name == NULL || svc_desc == NULL)
+ return NULL;
+
+ temp_service.host_name = host_name;
+ temp_service.description = svc_desc;
+
+ return skiplist_find_first(object_skiplists[SERVICE_SKIPLIST], &temp_service, NULL);
+ }
+
+
+
+
+/******************************************************************/
+/******************* OBJECT TRAVERSAL FUNCTIONS *******************/
+/******************************************************************/
+
+hostescalation *get_first_hostescalation_by_host(char *host_name, void **ptr) {
+ hostescalation temp_hostescalation;
+
+ if(host_name == NULL)
+ return NULL;
+
+ temp_hostescalation.host_name = host_name;
+
+ return skiplist_find_first(object_skiplists[HOSTESCALATION_SKIPLIST], &temp_hostescalation, ptr);
+ }
+
+
+hostescalation *get_next_hostescalation_by_host(char *host_name, void **ptr) {
+ hostescalation temp_hostescalation;
+
+ if(host_name == NULL)
+ return NULL;
+
+ temp_hostescalation.host_name = host_name;
+
+ return skiplist_find_next(object_skiplists[HOSTESCALATION_SKIPLIST], &temp_hostescalation, ptr);
+ }
+
+
+serviceescalation *get_first_serviceescalation_by_service(char *host_name, char *svc_description, void **ptr) {
+ serviceescalation temp_serviceescalation;
+
+ if(host_name == NULL || svc_description == NULL)
+ return NULL;
+
+ temp_serviceescalation.host_name = host_name;
+ temp_serviceescalation.description = svc_description;
+
+ return skiplist_find_first(object_skiplists[SERVICEESCALATION_SKIPLIST], &temp_serviceescalation, ptr);
+ }
+
+
+serviceescalation *get_next_serviceescalation_by_service(char *host_name, char *svc_description, void **ptr) {
+ serviceescalation temp_serviceescalation;
+
+ if(host_name == NULL || svc_description == NULL)
+ return NULL;
+
+ temp_serviceescalation.host_name = host_name;
+ temp_serviceescalation.description = svc_description;
+
+ return skiplist_find_next(object_skiplists[SERVICEESCALATION_SKIPLIST], &temp_serviceescalation, ptr);
+ }
+
+
+hostdependency *get_first_hostdependency_by_dependent_host(char *host_name, void **ptr) {
+ hostdependency temp_hostdependency;
+
+ if(host_name == NULL)
+ return NULL;
+
+ temp_hostdependency.dependent_host_name = host_name;
+
+ return skiplist_find_first(object_skiplists[HOSTDEPENDENCY_SKIPLIST], &temp_hostdependency, ptr);
+ }
+
+
+hostdependency *get_next_hostdependency_by_dependent_host(char *host_name, void **ptr) {
+ hostdependency temp_hostdependency;
+
+ if(host_name == NULL || ptr == NULL)
+ return NULL;
+
+ temp_hostdependency.dependent_host_name = host_name;
+
+ return skiplist_find_next(object_skiplists[HOSTDEPENDENCY_SKIPLIST], &temp_hostdependency, ptr);
+ }
+
+
+servicedependency *get_first_servicedependency_by_dependent_service(char *host_name, char *svc_description, void **ptr) {
+ servicedependency temp_servicedependency;
+
+ if(host_name == NULL || svc_description == NULL)
+ return NULL;
+
+ temp_servicedependency.dependent_host_name = host_name;
+ temp_servicedependency.dependent_service_description = svc_description;
+
+ return skiplist_find_first(object_skiplists[SERVICEDEPENDENCY_SKIPLIST], &temp_servicedependency, ptr);
+ }
+
+
+servicedependency *get_next_servicedependency_by_dependent_service(char *host_name, char *svc_description, void **ptr) {
+ servicedependency temp_servicedependency;
+
+ if(host_name == NULL || svc_description == NULL || ptr == NULL)
+ return NULL;
+
+ temp_servicedependency.dependent_host_name = host_name;
+ temp_servicedependency.dependent_service_description = svc_description;
+
+ return skiplist_find_next(object_skiplists[SERVICEDEPENDENCY_SKIPLIST], &temp_servicedependency, ptr);
+
+ return NULL;
+ }
+
+
+#ifdef NSCORE
+/* adds a object to a list of objects */
+int add_object_to_objectlist(objectlist **list, void *object_ptr) {
+ objectlist *temp_item = NULL;
+ objectlist *new_item = NULL;
+
+ if(list == NULL || object_ptr == NULL)
+ return ERROR;
+
+ /* skip this object if its already in the list */
+ for(temp_item = *list; temp_item; temp_item = temp_item->next) {
+ if(temp_item->object_ptr == object_ptr)
+ break;
+ }
+ if(temp_item)
+ return OK;
+
+ /* allocate memory for a new list item */
+ if((new_item = (objectlist *)malloc(sizeof(objectlist))) == NULL)
+ return ERROR;
+
+ /* initialize vars */
+ new_item->object_ptr = object_ptr;
+
+ /* add new item to head of list */
+ new_item->next = *list;
+ *list = new_item;
+
+ return OK;
+ }
+
+
+
+/* frees memory allocated to a temporary object list */
+int free_objectlist(objectlist **temp_list) {
+ objectlist *this_objectlist = NULL;
+ objectlist *next_objectlist = NULL;
+
+ if(temp_list == NULL)
+ return ERROR;
+
+ /* free memory allocated to object list */
+ for(this_objectlist = *temp_list; this_objectlist != NULL; this_objectlist = next_objectlist) {
+ next_objectlist = this_objectlist->next;
+ my_free(this_objectlist);
+ }
+
+ *temp_list = NULL;
+
+ return OK;
+ }
+#endif
+
+
+
+/******************************************************************/
+/********************* OBJECT QUERY FUNCTIONS *********************/
+/******************************************************************/
+
+/* determines whether or not a specific host is an immediate child of another host */
+int is_host_immediate_child_of_host(host *parent_host, host *child_host) {
+ hostsmember *temp_hostsmember = NULL;
+
+ /* not enough data */
+ if(child_host == NULL)
+ return FALSE;
+
+ /* root/top-level hosts */
+ if(parent_host == NULL) {
+ if(child_host->parent_hosts == NULL)
+ return TRUE;
+ }
+
+ /* mid-level/bottom hosts */
+ else {
+
+ for(temp_hostsmember = child_host->parent_hosts; temp_hostsmember != NULL; temp_hostsmember = temp_hostsmember->next) {
+#ifdef NSCORE
+ if(temp_hostsmember->host_ptr == parent_host)
+ return TRUE;
+#else
+ if(!strcmp(temp_hostsmember->host_name, parent_host->name))
+ return TRUE;
+#endif
+ }
+ }
+
+ return FALSE;
+ }
+
+
+/* determines whether or not a specific host is an immediate parent of another host */
+int is_host_immediate_parent_of_host(host *child_host, host *parent_host) {
+
+ if(is_host_immediate_child_of_host(parent_host, child_host) == TRUE)
+ return TRUE;
+
+ return FALSE;
+ }
+
+
+/* returns a count of the immediate children for a given host */
+/* NOTE: This function is only used by the CGIS */
+int number_of_immediate_child_hosts(host *hst) {
+ int children = 0;
+ host *temp_host = NULL;
+
+ for(temp_host = host_list; temp_host != NULL; temp_host = temp_host->next) {
+ if(is_host_immediate_child_of_host(hst, temp_host) == TRUE)
+ children++;
+ }
+
+ return children;
+ }
+
+
+/* returns a count of the total children for a given host */
+/* NOTE: This function is only used by the CGIS */
+int number_of_total_child_hosts(host *hst) {
+ int children = 0;
+ host *temp_host = NULL;
+
+ for(temp_host = host_list; temp_host != NULL; temp_host = temp_host->next) {
+ if(is_host_immediate_child_of_host(hst, temp_host) == TRUE)
+ children += number_of_total_child_hosts(temp_host) + 1;
+ }
+
+ return children;
+ }
+
+
+/* get the number of immediate parent hosts for a given host */
+/* NOTE: This function is only used by the CGIS */
+int number_of_immediate_parent_hosts(host *hst) {
+ int parents = 0;
+ host *temp_host = NULL;
+
+ for(temp_host = host_list; temp_host != NULL; temp_host = temp_host->next) {
+ if(is_host_immediate_parent_of_host(hst, temp_host) == TRUE) {
+ parents++;
+ }
+ }
+
+ return parents;
+ }
+
+
+/* get the total number of parent hosts for a given host */
+/* NOTE: This function is only used by the CGIS */
+int number_of_total_parent_hosts(host *hst) {
+ int parents = 0;
+ host *temp_host = NULL;
+
+ for(temp_host = host_list; temp_host != NULL; temp_host = temp_host->next) {
+ if(is_host_immediate_parent_of_host(hst, temp_host) == TRUE) {
+ parents += number_of_total_parent_hosts(temp_host) + 1;
+ }
+ }
+
+ return parents;
+ }
+
+
+/* tests whether a host is a member of a particular hostgroup */
+/* NOTE: This function is only used by the CGIS */
+int is_host_member_of_hostgroup(hostgroup *group, host *hst) {
+ hostsmember *temp_hostsmember = NULL;
+
+ if(group == NULL || hst == NULL)
+ return FALSE;
+
+ for(temp_hostsmember = group->members; temp_hostsmember != NULL; temp_hostsmember = temp_hostsmember->next) {
+#ifdef NSCORE
+ if(temp_hostsmember->host_ptr == hst)
+ return TRUE;
+#else
+ if(!strcmp(temp_hostsmember->host_name, hst->name))
+ return TRUE;
+#endif
+ }
+
+ return FALSE;
+ }
+
+
+/* tests whether a host is a member of a particular servicegroup */
+/* NOTE: This function is only used by the CGIS */
+int is_host_member_of_servicegroup(servicegroup *group, host *hst) {
+ servicesmember *temp_servicesmember = NULL;
+
+ if(group == NULL || hst == NULL)
+ return FALSE;
+
+ for(temp_servicesmember = group->members; temp_servicesmember != NULL; temp_servicesmember = temp_servicesmember->next) {
+#ifdef NSCORE
+ if(temp_servicesmember->service_ptr != NULL && temp_servicesmember->service_ptr->host_ptr == hst)
+ return TRUE;
+#else
+ if(!strcmp(temp_servicesmember->host_name, hst->name))
+ return TRUE;
+#endif
+ }
+
+ return FALSE;
+ }
+
+
+/* tests whether a service is a member of a particular servicegroup */
+/* NOTE: This function is only used by the CGIS */
+int is_service_member_of_servicegroup(servicegroup *group, service *svc) {
+ servicesmember *temp_servicesmember = NULL;
+
+ if(group == NULL || svc == NULL)
+ return FALSE;
+
+ for(temp_servicesmember = group->members; temp_servicesmember != NULL; temp_servicesmember = temp_servicesmember->next) {
+#ifdef NSCORE
+ if(temp_servicesmember->service_ptr == svc)
+ return TRUE;
+#else
+ if(!strcmp(temp_servicesmember->host_name, svc->host_name) && !strcmp(temp_servicesmember->service_description, svc->description))
+ return TRUE;
+#endif
+ }
+
+ return FALSE;
+ }
+
+
+/*
+ * tests whether a contact is a member of a particular contactgroup.
+ * The mk-livestatus eventbroker module uses this, so it must hang
+ * around until 4.0 to prevent api breakage.
+ * The cgi's stopped using it quite long ago though, so we need only
+ * compile it if we're building the core
+ */
+int is_contact_member_of_contactgroup(contactgroup *group, contact *cntct) {
+ contactsmember *member;
+ contact *temp_contact = NULL;
+
+ if(!group || !cntct)
+ return FALSE;
+
+ /* search all contacts in this contact group */
+ for(member = group->members; member; member = member->next) {
+#ifdef NSCORE
+ temp_contact = member->contact_ptr;
+#else
+ temp_contact = find_contact(member->contact_name);
+#endif
+ if(temp_contact == NULL)
+ continue;
+ if(temp_contact == cntct)
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+/* tests whether a contact is a contact for a particular host */
+int is_contact_for_host(host *hst, contact *cntct) {
+ contactsmember *temp_contactsmember = NULL;
+ contact *temp_contact = NULL;
+ contactgroupsmember *temp_contactgroupsmember = NULL;
+ contactgroup *temp_contactgroup = NULL;
+
+ if(hst == NULL || cntct == NULL) {
+ return FALSE;
+ }
+
+ /* search all individual contacts of this host */
+ for(temp_contactsmember = hst->contacts; temp_contactsmember != NULL; temp_contactsmember = temp_contactsmember->next) {
+#ifdef NSCORE
+ temp_contact = temp_contactsmember->contact_ptr;
+#else
+ temp_contact = find_contact(temp_contactsmember->contact_name);
+#endif
+ if(temp_contact == NULL)
+ continue;
+ if(temp_contact == cntct)
+ return TRUE;
+ }
+
+ /* search all contactgroups of this host */
+ for(temp_contactgroupsmember = hst->contact_groups; temp_contactgroupsmember != NULL; temp_contactgroupsmember = temp_contactgroupsmember->next) {
+#ifdef NSCORE
+ temp_contactgroup = temp_contactgroupsmember->group_ptr;
+#else
+ temp_contactgroup = find_contactgroup(temp_contactgroupsmember->group_name);
+#endif
+ if(temp_contactgroup == NULL)
+ continue;
+ if(is_contact_member_of_contactgroup(temp_contactgroup, cntct))
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+
+
+/* tests whether or not a contact is an escalated contact for a particular host */
+int is_escalated_contact_for_host(host *hst, contact *cntct) {
+ contactsmember *temp_contactsmember = NULL;
+ contact *temp_contact = NULL;
+ hostescalation *temp_hostescalation = NULL;
+ contactgroupsmember *temp_contactgroupsmember = NULL;
+ contactgroup *temp_contactgroup = NULL;
+ void *ptr = NULL;
+
+
+ /* search all host escalations */
+ for(temp_hostescalation = get_first_hostescalation_by_host(hst->name, &ptr); temp_hostescalation != NULL; temp_hostescalation = get_next_hostescalation_by_host(hst->name, &ptr)) {
+
+ /* search all contacts of this host escalation */
+ for(temp_contactsmember = temp_hostescalation->contacts; temp_contactsmember != NULL; temp_contactsmember = temp_contactsmember->next) {
+#ifdef NSCORE
+ temp_contact = temp_contactsmember->contact_ptr;
+#else
+ temp_contact = find_contact(temp_contactsmember->contact_name);
+#endif
+ if(temp_contact == NULL)
+ continue;
+ if(temp_contact == cntct)
+ return TRUE;
+ }
+
+ /* search all contactgroups of this host escalation */
+ for(temp_contactgroupsmember = temp_hostescalation->contact_groups; temp_contactgroupsmember != NULL; temp_contactgroupsmember = temp_contactgroupsmember->next) {
+#ifdef NSCORE
+ temp_contactgroup = temp_contactgroupsmember->group_ptr;
+#else
+ temp_contactgroup = find_contactgroup(temp_contactgroupsmember->group_name);
+#endif
+ if(temp_contactgroup == NULL)
+ continue;
+ if(is_contact_member_of_contactgroup(temp_contactgroup, cntct))
+ return TRUE;
+
+ }
+ }
+
+ return FALSE;
+ }
+
+
+/* tests whether a contact is a contact for a particular service */
+int is_contact_for_service(service *svc, contact *cntct) {
+ contactsmember *temp_contactsmember = NULL;
+ contact *temp_contact = NULL;
+ contactgroupsmember *temp_contactgroupsmember = NULL;
+ contactgroup *temp_contactgroup = NULL;
+
+ if(svc == NULL || cntct == NULL)
+ return FALSE;
+
+ /* search all individual contacts of this service */
+ for(temp_contactsmember = svc->contacts; temp_contactsmember != NULL; temp_contactsmember = temp_contactsmember->next) {
+#ifdef NSCORE
+ temp_contact = temp_contactsmember->contact_ptr;
+#else
+ temp_contact = find_contact(temp_contactsmember->contact_name);
+#endif
+
+ if(temp_contact == cntct)
+ return TRUE;
+ }
+
+ /* search all contactgroups of this service */
+ for(temp_contactgroupsmember = svc->contact_groups; temp_contactgroupsmember != NULL; temp_contactgroupsmember = temp_contactgroupsmember->next) {
+#ifdef NSCORE
+ temp_contactgroup = temp_contactgroupsmember->group_ptr;
+#else
+ temp_contactgroup = find_contactgroup(temp_contactgroupsmember->group_name);
+#endif
+ if(temp_contactgroup == NULL)
+ continue;
+ if(is_contact_member_of_contactgroup(temp_contactgroup, cntct))
+ return TRUE;
+
+ }
+
+ return FALSE;
+ }
+
+
+
+/* tests whether or not a contact is an escalated contact for a particular service */
+int is_escalated_contact_for_service(service *svc, contact *cntct) {
+ serviceescalation *temp_serviceescalation = NULL;
+ contactsmember *temp_contactsmember = NULL;
+ contact *temp_contact = NULL;
+ contactgroupsmember *temp_contactgroupsmember = NULL;
+ contactgroup *temp_contactgroup = NULL;
+ void *ptr = NULL;
+
+ /* search all the service escalations */
+ for(temp_serviceescalation = get_first_serviceescalation_by_service(svc->host_name, svc->description, &ptr); temp_serviceescalation != NULL; temp_serviceescalation = get_next_serviceescalation_by_service(svc->host_name, svc->description, &ptr)) {
+
+ /* search all contacts of this service escalation */
+ for(temp_contactsmember = temp_serviceescalation->contacts; temp_contactsmember != NULL; temp_contactsmember = temp_contactsmember->next) {
+#ifdef NSCORE
+ temp_contact = temp_contactsmember->contact_ptr;
+#else
+ temp_contact = find_contact(temp_contactsmember->contact_name);
+#endif
+ if(temp_contact == NULL)
+ continue;
+ if(temp_contact == cntct)
+ return TRUE;
+ }
+
+ /* search all contactgroups of this service escalation */
+ for(temp_contactgroupsmember = temp_serviceescalation->contact_groups; temp_contactgroupsmember != NULL; temp_contactgroupsmember = temp_contactgroupsmember->next) {
+#ifdef NSCORE
+ temp_contactgroup = temp_contactgroupsmember->group_ptr;
+#else
+ temp_contactgroup = find_contactgroup(temp_contactgroupsmember->group_name);
+#endif
+ if(temp_contactgroup == NULL)
+ continue;
+ if(is_contact_member_of_contactgroup(temp_contactgroup, cntct))
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+ }
+
+
+#ifdef NSCORE
+
+/* checks to see if there exists a circular dependency for a service */
+int check_for_circular_servicedependency_path(servicedependency *root_dep, servicedependency *dep, int dependency_type) {
+ servicedependency *temp_sd = NULL;
+
+ if(root_dep == NULL || dep == NULL)
+ return FALSE;
+
+ /* this is not the proper dependency type */
+ if(root_dep->dependency_type != dependency_type || dep->dependency_type != dependency_type)
+ return FALSE;
+
+ /* don't go into a loop, don't bother checking anymore if we know this dependency already has a loop */
+ if(root_dep->contains_circular_path == TRUE)
+ return TRUE;
+
+ /* dependency has already been checked - there is a path somewhere, but it may not be for this particular dep... */
+ /* this should speed up detection for some loops */
+ if(dep->circular_path_checked == TRUE)
+ return FALSE;
+
+ /* set the check flag so we don't get into an infinite loop */
+ dep->circular_path_checked = TRUE;
+
+ /* is this service dependent on the root service? */
+ if(dep != root_dep) {
+ if(root_dep->dependent_service_ptr == dep->master_service_ptr) {
+ root_dep->contains_circular_path = TRUE;
+ dep->contains_circular_path = TRUE;
+ return TRUE;
+ }
+ }
+
+ /* notification dependencies are ok at this point as long as they don't inherit */
+ if(dependency_type == NOTIFICATION_DEPENDENCY && dep->inherits_parent == FALSE)
+ return FALSE;
+
+ /* check all parent dependencies */
+ for(temp_sd = servicedependency_list; temp_sd != NULL; temp_sd = temp_sd->next) {
+
+ /* only check parent dependencies */
+ if(dep->master_service_ptr != temp_sd->dependent_service_ptr)
+ continue;
+
+ if(check_for_circular_servicedependency_path(root_dep, temp_sd, dependency_type) == TRUE)
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+
+/* checks to see if there exists a circular dependency for a host */
+int check_for_circular_hostdependency_path(hostdependency *root_dep, hostdependency *dep, int dependency_type) {
+ hostdependency *temp_hd = NULL;
+
+ if(root_dep == NULL || dep == NULL)
+ return FALSE;
+
+ /* this is not the proper dependency type */
+ if(root_dep->dependency_type != dependency_type || dep->dependency_type != dependency_type)
+ return FALSE;
+
+ /* don't go into a loop, don't bother checking anymore if we know this dependency already has a loop */
+ if(root_dep->contains_circular_path == TRUE)
+ return TRUE;
+
+ /* dependency has already been checked - there is a path somewhere, but it may not be for this particular dep... */
+ /* this should speed up detection for some loops */
+ if(dep->circular_path_checked == TRUE)
+ return FALSE;
+
+ /* set the check flag so we don't get into an infinite loop */
+ dep->circular_path_checked = TRUE;
+
+ /* is this host dependent on the root host? */
+ if(dep != root_dep) {
+ if(root_dep->dependent_host_ptr == dep->master_host_ptr) {
+ root_dep->contains_circular_path = TRUE;
+ dep->contains_circular_path = TRUE;
+ return TRUE;
+ }
+ }
+
+ /* notification dependencies are ok at this point as long as they don't inherit */
+ if(dependency_type == NOTIFICATION_DEPENDENCY && dep->inherits_parent == FALSE)
+ return FALSE;
+
+ /* check all parent dependencies */
+ for(temp_hd = hostdependency_list; temp_hd != NULL; temp_hd = temp_hd->next) {
+
+ /* only check parent dependencies */
+ if(dep->master_host_ptr != temp_hd->dependent_host_ptr)
+ continue;
+
+ if(check_for_circular_hostdependency_path(root_dep, temp_hd, dependency_type) == TRUE)
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+#endif
+
+
+
+
+/******************************************************************/
+/******************* OBJECT DELETION FUNCTIONS ********************/
+/******************************************************************/
+
+
+/* free all allocated memory for objects */
+int free_object_data(void) {
+ timeperiod *this_timeperiod = NULL;
+ timeperiod *next_timeperiod = NULL;
+ daterange *this_daterange = NULL;
+ daterange *next_daterange = NULL;
+ timerange *this_timerange = NULL;
+ timerange *next_timerange = NULL;
+ timeperiodexclusion *this_timeperiodexclusion = NULL;
+ timeperiodexclusion *next_timeperiodexclusion = NULL;
+ host *this_host = NULL;
+ host *next_host = NULL;
+ hostsmember *this_hostsmember = NULL;
+ hostsmember *next_hostsmember = NULL;
+ hostgroup *this_hostgroup = NULL;
+ hostgroup *next_hostgroup = NULL;
+ servicegroup *this_servicegroup = NULL;
+ servicegroup *next_servicegroup = NULL;
+ servicesmember *this_servicesmember = NULL;
+ servicesmember *next_servicesmember = NULL;
+ contact *this_contact = NULL;
+ contact *next_contact = NULL;
+ contactgroup *this_contactgroup = NULL;
+ contactgroup *next_contactgroup = NULL;
+ contactsmember *this_contactsmember = NULL;
+ contactsmember *next_contactsmember = NULL;
+ contactgroupsmember *this_contactgroupsmember = NULL;
+ contactgroupsmember *next_contactgroupsmember = NULL;
+ customvariablesmember *this_customvariablesmember = NULL;
+ customvariablesmember *next_customvariablesmember = NULL;
+ service *this_service = NULL;
+ service *next_service = NULL;
+ command *this_command = NULL;
+ command *next_command = NULL;
+ commandsmember *this_commandsmember = NULL;
+ commandsmember *next_commandsmember = NULL;
+ serviceescalation *this_serviceescalation = NULL;
+ serviceescalation *next_serviceescalation = NULL;
+ servicedependency *this_servicedependency = NULL;
+ servicedependency *next_servicedependency = NULL;
+ hostdependency *this_hostdependency = NULL;
+ hostdependency *next_hostdependency = NULL;
+ hostescalation *this_hostescalation = NULL;
+ hostescalation *next_hostescalation = NULL;
+ register int x = 0;
+ register int i = 0;
+
+
+ /**** free memory for the timeperiod list ****/
+ this_timeperiod = timeperiod_list;
+ while(this_timeperiod != NULL) {
+
+ /* free the exception time ranges contained in this timeperiod */
+ for(x = 0; x < DATERANGE_TYPES; x++) {
+
+ for(this_daterange = this_timeperiod->exceptions[x]; this_daterange != NULL; this_daterange = next_daterange) {
+ next_daterange = this_daterange->next;
+ for(this_timerange = this_daterange->times; this_timerange != NULL; this_timerange = next_timerange) {
+ next_timerange = this_timerange->next;
+ my_free(this_timerange);
+ }
+ my_free(this_daterange);
+ }
+ }
+
+ /* free the day time ranges contained in this timeperiod */
+ for(x = 0; x < 7; x++) {
+
+ for(this_timerange = this_timeperiod->days[x]; this_timerange != NULL; this_timerange = next_timerange) {
+ next_timerange = this_timerange->next;
+ my_free(this_timerange);
+ }
+ }
+
+ /* free exclusions */
+ for(this_timeperiodexclusion = this_timeperiod->exclusions; this_timeperiodexclusion != NULL; this_timeperiodexclusion = next_timeperiodexclusion) {
+ next_timeperiodexclusion = this_timeperiodexclusion->next;
+ my_free(this_timeperiodexclusion->timeperiod_name);
+ my_free(this_timeperiodexclusion);
+ }
+
+ next_timeperiod = this_timeperiod->next;
+ my_free(this_timeperiod->name);
+ my_free(this_timeperiod->alias);
+ my_free(this_timeperiod);
+ this_timeperiod = next_timeperiod;
+ }
+
+ /* reset pointers */
+ timeperiod_list = NULL;
+
+
+ /**** free memory for the host list ****/
+ this_host = host_list;
+ while(this_host != NULL) {
+
+ next_host = this_host->next;
+
+ /* free memory for parent hosts */
+ this_hostsmember = this_host->parent_hosts;
+ while(this_hostsmember != NULL) {
+ next_hostsmember = this_hostsmember->next;
+ my_free(this_hostsmember->host_name);
+ my_free(this_hostsmember);
+ this_hostsmember = next_hostsmember;
+ }
+
+ /* free memory for child host links */
+ this_hostsmember = this_host->child_hosts;
+ while(this_hostsmember != NULL) {
+ next_hostsmember = this_hostsmember->next;
+ my_free(this_hostsmember->host_name);
+ my_free(this_hostsmember);
+ this_hostsmember = next_hostsmember;
+ }
+
+ /* free memory for service links */
+ this_servicesmember = this_host->services;
+ while(this_servicesmember != NULL) {
+ next_servicesmember = this_servicesmember->next;
+ my_free(this_servicesmember->host_name);
+ my_free(this_servicesmember->service_description);
+ my_free(this_servicesmember);
+ this_servicesmember = next_servicesmember;
+ }
+
+ /* free memory for contact groups */
+ this_contactgroupsmember = this_host->contact_groups;
+ while(this_contactgroupsmember != NULL) {
+ next_contactgroupsmember = this_contactgroupsmember->next;
+ my_free(this_contactgroupsmember->group_name);
+ my_free(this_contactgroupsmember);
+ this_contactgroupsmember = next_contactgroupsmember;
+ }
+
+ /* free memory for contacts */
+ this_contactsmember = this_host->contacts;
+ while(this_contactsmember != NULL) {
+ next_contactsmember = this_contactsmember->next;
+ my_free(this_contactsmember->contact_name);
+ my_free(this_contactsmember);
+ this_contactsmember = next_contactsmember;
+ }
+
+ /* free memory for custom variables */
+ this_customvariablesmember = this_host->custom_variables;
+ while(this_customvariablesmember != NULL) {
+ next_customvariablesmember = this_customvariablesmember->next;
+ my_free(this_customvariablesmember->variable_name);
+ my_free(this_customvariablesmember->variable_value);
+ my_free(this_customvariablesmember);
+ this_customvariablesmember = next_customvariablesmember;
+ }
+
+ my_free(this_host->name);
+ my_free(this_host->display_name);
+ my_free(this_host->alias);
+ my_free(this_host->address);
+#ifdef NSCORE
+ my_free(this_host->plugin_output);
+ my_free(this_host->long_plugin_output);
+ my_free(this_host->perf_data);
+
+ free_objectlist(&this_host->hostgroups_ptr);
+#endif
+ my_free(this_host->check_period);
+ my_free(this_host->host_check_command);
+ my_free(this_host->event_handler);
+ my_free(this_host->failure_prediction_options);
+ my_free(this_host->notification_period);
+ my_free(this_host->notes);
+ my_free(this_host->notes_url);
+ my_free(this_host->action_url);
+ my_free(this_host->icon_image);
+ my_free(this_host->icon_image_alt);
+ my_free(this_host->vrml_image);
+ my_free(this_host->statusmap_image);
+ my_free(this_host);
+ this_host = next_host;
+ }
+
+ /* reset pointers */
+ host_list = NULL;
+
+
+ /**** free memory for the host group list ****/
+ this_hostgroup = hostgroup_list;
+ while(this_hostgroup != NULL) {
+
+ /* free memory for the group members */
+ this_hostsmember = this_hostgroup->members;
+ while(this_hostsmember != NULL) {
+ next_hostsmember = this_hostsmember->next;
+ my_free(this_hostsmember->host_name);
+ my_free(this_hostsmember);
+ this_hostsmember = next_hostsmember;
+ }
+
+ next_hostgroup = this_hostgroup->next;
+ my_free(this_hostgroup->group_name);
+ my_free(this_hostgroup->alias);
+ my_free(this_hostgroup->notes);
+ my_free(this_hostgroup->notes_url);
+ my_free(this_hostgroup->action_url);
+ my_free(this_hostgroup);
+ this_hostgroup = next_hostgroup;
+ }
+
+ /* reset pointers */
+ hostgroup_list = NULL;
+
+
+ /**** free memory for the service group list ****/
+ this_servicegroup = servicegroup_list;
+ while(this_servicegroup != NULL) {
+
+ /* free memory for the group members */
+ this_servicesmember = this_servicegroup->members;
+ while(this_servicesmember != NULL) {
+ next_servicesmember = this_servicesmember->next;
+ my_free(this_servicesmember->host_name);
+ my_free(this_servicesmember->service_description);
+ my_free(this_servicesmember);
+ this_servicesmember = next_servicesmember;
+ }
+
+ next_servicegroup = this_servicegroup->next;
+ my_free(this_servicegroup->group_name);
+ my_free(this_servicegroup->alias);
+ my_free(this_servicegroup->notes);
+ my_free(this_servicegroup->notes_url);
+ my_free(this_servicegroup->action_url);
+ my_free(this_servicegroup);
+ this_servicegroup = next_servicegroup;
+ }
+
+ /* reset pointers */
+ servicegroup_list = NULL;
+
+
+ /**** free memory for the contact list ****/
+ this_contact = contact_list;
+ while(this_contact != NULL) {
+
+ /* free memory for the host notification commands */
+ this_commandsmember = this_contact->host_notification_commands;
+ while(this_commandsmember != NULL) {
+ next_commandsmember = this_commandsmember->next;
+ if(this_commandsmember->command != NULL)
+ my_free(this_commandsmember->command);
+ my_free(this_commandsmember);
+ this_commandsmember = next_commandsmember;
+ }
+
+ /* free memory for the service notification commands */
+ this_commandsmember = this_contact->service_notification_commands;
+ while(this_commandsmember != NULL) {
+ next_commandsmember = this_commandsmember->next;
+ if(this_commandsmember->command != NULL)
+ my_free(this_commandsmember->command);
+ my_free(this_commandsmember);
+ this_commandsmember = next_commandsmember;
+ }
+
+ /* free memory for custom variables */
+ this_customvariablesmember = this_contact->custom_variables;
+ while(this_customvariablesmember != NULL) {
+ next_customvariablesmember = this_customvariablesmember->next;
+ my_free(this_customvariablesmember->variable_name);
+ my_free(this_customvariablesmember->variable_value);
+ my_free(this_customvariablesmember);
+ this_customvariablesmember = next_customvariablesmember;
+ }
+
+ next_contact = this_contact->next;
+ my_free(this_contact->name);
+ my_free(this_contact->alias);
+ my_free(this_contact->email);
+ my_free(this_contact->pager);
+ for(i = 0; i < MAX_CONTACT_ADDRESSES; i++)
+ my_free(this_contact->address[i]);
+ my_free(this_contact->host_notification_period);
+ my_free(this_contact->service_notification_period);
+
+#ifdef NSCORE
+ free_objectlist(&this_contact->contactgroups_ptr);
+#endif
+
+ my_free(this_contact);
+ this_contact = next_contact;
+ }
+
+ /* reset pointers */
+ contact_list = NULL;
+
+
+ /**** free memory for the contact group list ****/
+ this_contactgroup = contactgroup_list;
+ while(this_contactgroup != NULL) {
+
+ /* free memory for the group members */
+ this_contactsmember = this_contactgroup->members;
+ while(this_contactsmember != NULL) {
+ next_contactsmember = this_contactsmember->next;
+ my_free(this_contactsmember->contact_name);
+ my_free(this_contactsmember);
+ this_contactsmember = next_contactsmember;
+ }
+
+ next_contactgroup = this_contactgroup->next;
+ my_free(this_contactgroup->group_name);
+ my_free(this_contactgroup->alias);
+ my_free(this_contactgroup);
+ this_contactgroup = next_contactgroup;
+ }
+
+ /* reset pointers */
+ contactgroup_list = NULL;
+
+
+ /**** free memory for the service list ****/
+ this_service = service_list;
+ while(this_service != NULL) {
+
+ next_service = this_service->next;
+
+ /* free memory for contact groups */
+ this_contactgroupsmember = this_service->contact_groups;
+ while(this_contactgroupsmember != NULL) {
+ next_contactgroupsmember = this_contactgroupsmember->next;
+ my_free(this_contactgroupsmember->group_name);
+ my_free(this_contactgroupsmember);
+ this_contactgroupsmember = next_contactgroupsmember;
+ }
+
+ /* free memory for contacts */
+ this_contactsmember = this_service->contacts;
+ while(this_contactsmember != NULL) {
+ next_contactsmember = this_contactsmember->next;
+ my_free(this_contactsmember->contact_name);
+ my_free(this_contactsmember);
+ this_contactsmember = next_contactsmember;
+ }
+
+ /* free memory for custom variables */
+ this_customvariablesmember = this_service->custom_variables;
+ while(this_customvariablesmember != NULL) {
+ next_customvariablesmember = this_customvariablesmember->next;
+ my_free(this_customvariablesmember->variable_name);
+ my_free(this_customvariablesmember->variable_value);
+ my_free(this_customvariablesmember);
+ this_customvariablesmember = next_customvariablesmember;
+ }
+
+ my_free(this_service->host_name);
+ my_free(this_service->description);
+ my_free(this_service->display_name);
+ my_free(this_service->service_check_command);
+#ifdef NSCORE
+ my_free(this_service->plugin_output);
+ my_free(this_service->long_plugin_output);
+ my_free(this_service->perf_data);
+
+ my_free(this_service->event_handler_args);
+ my_free(this_service->check_command_args);
+
+ free_objectlist(&this_service->servicegroups_ptr);
+#endif
+ my_free(this_service->notification_period);
+ my_free(this_service->check_period);
+ my_free(this_service->event_handler);
+ my_free(this_service->failure_prediction_options);
+ my_free(this_service->notes);
+ my_free(this_service->notes_url);
+ my_free(this_service->action_url);
+ my_free(this_service->icon_image);
+ my_free(this_service->icon_image_alt);
+ my_free(this_service);
+ this_service = next_service;
+ }
+
+ /* reset pointers */
+ service_list = NULL;
+
+
+ /**** free memory for the command list ****/
+ this_command = command_list;
+ while(this_command != NULL) {
+ next_command = this_command->next;
+ my_free(this_command->name);
+ my_free(this_command->command_line);
+ my_free(this_command);
+ this_command = next_command;
+ }
+
+ /* reset pointers */
+ command_list = NULL;
+
+
+ /**** free memory for the service escalation list ****/
+ this_serviceescalation = serviceescalation_list;
+ while(this_serviceescalation != NULL) {
+
+ /* free memory for the contact group members */
+ this_contactgroupsmember = this_serviceescalation->contact_groups;
+ while(this_contactgroupsmember != NULL) {
+ next_contactgroupsmember = this_contactgroupsmember->next;
+ my_free(this_contactgroupsmember->group_name);
+ my_free(this_contactgroupsmember);
+ this_contactgroupsmember = next_contactgroupsmember;
+ }
+
+ /* free memory for contacts */
+ this_contactsmember = this_serviceescalation->contacts;
+ while(this_contactsmember != NULL) {
+ next_contactsmember = this_contactsmember->next;
+ my_free(this_contactsmember->contact_name);
+ my_free(this_contactsmember);
+ this_contactsmember = next_contactsmember;
+ }
+
+ next_serviceescalation = this_serviceescalation->next;
+ my_free(this_serviceescalation->host_name);
+ my_free(this_serviceescalation->description);
+ my_free(this_serviceescalation->escalation_period);
+ my_free(this_serviceescalation);
+ this_serviceescalation = next_serviceescalation;
+ }
+
+ /* reset pointers */
+ serviceescalation_list = NULL;
+
+
+ /**** free memory for the service dependency list ****/
+ this_servicedependency = servicedependency_list;
+ while(this_servicedependency != NULL) {
+ next_servicedependency = this_servicedependency->next;
+ my_free(this_servicedependency->dependency_period);
+ my_free(this_servicedependency->dependent_host_name);
+ my_free(this_servicedependency->dependent_service_description);
+ my_free(this_servicedependency->host_name);
+ my_free(this_servicedependency->service_description);
+ my_free(this_servicedependency);
+ this_servicedependency = next_servicedependency;
+ }
+
+ /* reset pointers */
+ servicedependency_list = NULL;
+
+
+ /**** free memory for the host dependency list ****/
+ this_hostdependency = hostdependency_list;
+ while(this_hostdependency != NULL) {
+ next_hostdependency = this_hostdependency->next;
+ my_free(this_hostdependency->dependency_period);
+ my_free(this_hostdependency->dependent_host_name);
+ my_free(this_hostdependency->host_name);
+ my_free(this_hostdependency);
+ this_hostdependency = next_hostdependency;
+ }
+
+ /* reset pointers */
+ hostdependency_list = NULL;
+
+
+ /**** free memory for the host escalation list ****/
+ this_hostescalation = hostescalation_list;
+ while(this_hostescalation != NULL) {
+
+ /* free memory for the contact group members */
+ this_contactgroupsmember = this_hostescalation->contact_groups;
+ while(this_contactgroupsmember != NULL) {
+ next_contactgroupsmember = this_contactgroupsmember->next;
+ my_free(this_contactgroupsmember->group_name);
+ my_free(this_contactgroupsmember);
+ this_contactgroupsmember = next_contactgroupsmember;
+ }
+
+ /* free memory for contacts */
+ this_contactsmember = this_hostescalation->contacts;
+ while(this_contactsmember != NULL) {
+ next_contactsmember = this_contactsmember->next;
+ my_free(this_contactsmember->contact_name);
+ my_free(this_contactsmember);
+ this_contactsmember = next_contactsmember;
+ }
+
+ next_hostescalation = this_hostescalation->next;
+ my_free(this_hostescalation->host_name);
+ my_free(this_hostescalation->escalation_period);
+ my_free(this_hostescalation);
+ this_hostescalation = next_hostescalation;
+ }
+
+ /* reset pointers */
+ hostescalation_list = NULL;
+
+ /* free object skiplists */
+ free_object_skiplists();
+
+ return OK;
+ }
+
diff --git a/common/shared.c b/common/shared.c
new file mode 100644
index 0000000..2e61d80
--- /dev/null
+++ b/common/shared.c
@@ -0,0 +1,511 @@
+#include "../include/config.h"
+#include "../include/common.h"
+
+/*
+ * This file holds random utility functions shared by cgi's and
+ * core.
+ */
+extern int date_format;
+
+/* fix the problem with strtok() skipping empty options between tokens */
+char *my_strtok(char *buffer, char *tokens) {
+ char *token_position = NULL;
+ char *sequence_head = NULL;
+ static char *my_strtok_buffer = NULL;
+ static char *original_my_strtok_buffer = NULL;
+
+ if(buffer != NULL) {
+ my_free(original_my_strtok_buffer);
+ if((my_strtok_buffer = (char *)strdup(buffer)) == NULL)
+ return NULL;
+ original_my_strtok_buffer = my_strtok_buffer;
+ }
+
+ sequence_head = my_strtok_buffer;
+
+ if(sequence_head[0] == '\x0')
+ return NULL;
+
+ token_position = strchr(my_strtok_buffer, tokens[0]);
+
+ if(token_position == NULL) {
+ my_strtok_buffer = strchr(my_strtok_buffer, '\x0');
+ return sequence_head;
+ }
+
+ token_position[0] = '\x0';
+ my_strtok_buffer = token_position + 1;
+
+ return sequence_head;
+ }
+
+/* fixes compiler problems under Solaris, since strsep() isn't included */
+/* this code is taken from the glibc source */
+char *my_strsep(char **stringp, const char *delim) {
+ char *begin, *end;
+
+ begin = *stringp;
+ if(begin == NULL)
+ return NULL;
+
+ /* A frequent case is when the delimiter string contains only one
+ * character. Here we don't need to call the expensive `strpbrk'
+ * function and instead work using `strchr'. */
+ if(delim[0] == '\0' || delim[1] == '\0') {
+ char ch = delim[0];
+
+ if(ch == '\0' || begin[0] == '\0')
+ end = NULL;
+ else {
+ if(*begin == ch)
+ end = begin;
+ else
+ end = strchr(begin + 1, ch);
+ }
+ }
+ else {
+ /* find the end of the token. */
+ end = strpbrk(begin, delim);
+ }
+
+ if(end) {
+ /* terminate the token and set *STRINGP past NUL character. */
+ *end++ = '\0';
+ *stringp = end;
+ }
+ else
+ /* no more delimiters; this is the last token. */
+ *stringp = NULL;
+
+ return begin;
+ }
+
+/* open a file read-only via mmap() */
+mmapfile *mmap_fopen(char *filename) {
+ mmapfile *new_mmapfile = NULL;
+ int fd = 0;
+ void *mmap_buf = NULL;
+ struct stat statbuf;
+ int mode = O_RDONLY;
+ unsigned long file_size = 0L;
+
+ if(filename == NULL)
+ return NULL;
+
+ /* allocate memory */
+ if((new_mmapfile = (mmapfile *) malloc(sizeof(mmapfile))) == NULL)
+ return NULL;
+
+ /* open the file */
+ if((fd = open(filename, mode)) == -1) {
+ my_free(new_mmapfile);
+ return NULL;
+ }
+
+ /* get file info */
+ if((fstat(fd, &statbuf)) == -1) {
+ close(fd);
+ my_free(new_mmapfile);
+ return NULL;
+ }
+
+ /* get file size */
+ file_size = (unsigned long)statbuf.st_size;
+
+ /* only mmap() if we have a file greater than 0 bytes */
+ if(file_size > 0) {
+
+ /* mmap() the file - allocate one extra byte for processing zero-byte files */
+ if((mmap_buf =
+ (void *)mmap(0, file_size, PROT_READ, MAP_PRIVATE, fd,
+ 0)) == MAP_FAILED) {
+ close(fd);
+ my_free(new_mmapfile);
+ return NULL;
+ }
+ }
+ else
+ mmap_buf = NULL;
+
+ /* populate struct info for later use */
+ new_mmapfile->path = (char *)strdup(filename);
+ new_mmapfile->fd = fd;
+ new_mmapfile->file_size = (unsigned long)file_size;
+ new_mmapfile->current_position = 0L;
+ new_mmapfile->current_line = 0L;
+ new_mmapfile->mmap_buf = mmap_buf;
+
+ return new_mmapfile;
+ }
+
+/* close a file originally opened via mmap() */
+int mmap_fclose(mmapfile * temp_mmapfile) {
+
+ if(temp_mmapfile == NULL)
+ return ERROR;
+
+ /* un-mmap() the file */
+ if(temp_mmapfile->file_size > 0L)
+ munmap(temp_mmapfile->mmap_buf, temp_mmapfile->file_size);
+
+ /* close the file */
+ close(temp_mmapfile->fd);
+
+ /* free memory */
+ my_free(temp_mmapfile->path);
+ my_free(temp_mmapfile);
+
+ return OK;
+ }
+
+/* gets one line of input from an mmap()'ed file */
+char *mmap_fgets(mmapfile * temp_mmapfile) {
+ char *buf = NULL;
+ unsigned long x = 0L;
+ int len = 0;
+
+ if(temp_mmapfile == NULL)
+ return NULL;
+
+ /* size of file is 0 bytes */
+ if(temp_mmapfile->file_size == 0L)
+ return NULL;
+
+ /* we've reached the end of the file */
+ if(temp_mmapfile->current_position >= temp_mmapfile->file_size)
+ return NULL;
+
+ /* find the end of the string (or buffer) */
+ for(x = temp_mmapfile->current_position; x < temp_mmapfile->file_size;
+ x++) {
+ if(*((char *)(temp_mmapfile->mmap_buf) + x) == '\n') {
+ x++;
+ break;
+ }
+ }
+
+ /* calculate length of line we just read */
+ len = (int)(x - temp_mmapfile->current_position);
+
+ /* allocate memory for the new line */
+ if((buf = (char *)malloc(len + 1)) == NULL)
+ return NULL;
+
+ /* copy string to newly allocated memory and terminate the string */
+ memcpy(buf,
+ ((char *)(temp_mmapfile->mmap_buf) +
+ temp_mmapfile->current_position), len);
+ buf[len] = '\x0';
+
+ /* update the current position */
+ temp_mmapfile->current_position = x;
+
+ /* increment the current line */
+ temp_mmapfile->current_line++;
+
+ return buf;
+ }
+
+/* gets one line of input from an mmap()'ed file (may be contained on more than one line in the source file) */
+char *mmap_fgets_multiline(mmapfile * temp_mmapfile) {
+ char *buf = NULL;
+ char *tempbuf = NULL;
+ char *stripped = NULL;
+ int len = 0;
+ int len2 = 0;
+ int end = 0;
+
+ if(temp_mmapfile == NULL)
+ return NULL;
+
+ while(1) {
+
+ my_free(tempbuf);
+
+ if((tempbuf = mmap_fgets(temp_mmapfile)) == NULL)
+ break;
+
+ if(buf == NULL) {
+ len = strlen(tempbuf);
+ if((buf = (char *)malloc(len + 1)) == NULL)
+ break;
+ memcpy(buf, tempbuf, len);
+ buf[len] = '\x0';
+ }
+ else {
+ /* strip leading white space from continuation lines */
+ stripped = tempbuf;
+ while(*stripped == ' ' || *stripped == '\t')
+ stripped++;
+ len = strlen(stripped);
+ len2 = strlen(buf);
+ if((buf =
+ (char *)realloc(buf, len + len2 + 1)) == NULL)
+ break;
+ strcat(buf, stripped);
+ len += len2;
+ buf[len] = '\x0';
+ }
+
+ if(len == 0)
+ break;
+
+ /* handle Windows/DOS CR/LF */
+ if(len >= 2 && buf[len - 2] == '\r')
+ end = len - 3;
+ /* normal Unix LF */
+ else if(len >= 1 && buf[len - 1] == '\n')
+ end = len - 2;
+ else
+ end = len - 1;
+
+ /* two backslashes found. unescape first backslash first and break */
+ if(end >= 1 && buf[end - 1] == '\\' && buf[end] == '\\') {
+ buf[end] = '\n';
+ buf[end + 1] = '\x0';
+ break;
+ }
+
+ /* one backslash found. continue reading the next line */
+ else if(end > 0 && buf[end] == '\\')
+ buf[end] = '\x0';
+
+ /* no continuation marker was found, so break */
+ else
+ break;
+ }
+
+ my_free(tempbuf);
+
+ return buf;
+ }
+
+/* strip newline, carriage return, and tab characters from beginning and end of a string */
+void strip(char *buffer) {
+ register int x, z;
+ int len;
+
+ if(buffer == NULL || buffer[0] == '\x0')
+ return;
+
+ /* strip end of string */
+ len = (int)strlen(buffer);
+ for(x = len - 1; x >= 0; x--) {
+ switch(buffer[x]) {
+ case ' ':
+ case '\n':
+ case '\r':
+ case '\t':
+ buffer[x] = '\x0';
+ continue;
+ }
+ break;
+ }
+
+ /* if we stripped all of it, just return */
+ if(!x)
+ return;
+
+ /* save last position for later... */
+ z = x;
+
+ /* strip beginning of string (by shifting) */
+ /* NOTE: this is very expensive to do, so avoid it whenever possible */
+ for(x = 0;; x++) {
+ switch(buffer[x]) {
+ case ' ':
+ case '\n':
+ case '\r':
+ case '\t':
+ continue;
+ }
+ break;
+ }
+
+ if(x > 0 && z > 0) {
+ /* new length of the string after we stripped the end */
+ len = z + 1;
+
+ /* shift chars towards beginning of string to remove leading whitespace */
+ for(z = x; z < len; z++)
+ buffer[z - x] = buffer[z];
+ buffer[len - x] = '\x0';
+ }
+ }
+
+/**************************************************
+ *************** HASH FUNCTIONS *******************
+ **************************************************/
+/* dual hash function */
+int hashfunc(const char *name1, const char *name2, int hashslots) {
+ unsigned int i, result;
+
+ result = 0;
+
+ if(name1)
+ for(i = 0; i < strlen(name1); i++)
+ result += name1[i];
+
+ if(name2)
+ for(i = 0; i < strlen(name2); i++)
+ result += name2[i];
+
+ result = result % hashslots;
+
+ return result;
+ }
+
+/* dual hash data comparison */
+int compare_hashdata(const char *val1a, const char *val1b, const char *val2a,
+ const char *val2b) {
+ int result = 0;
+
+ /* NOTE: If hash calculation changes, update the compare_strings() function! */
+
+ /* check first name */
+ if(val1a == NULL && val2a == NULL)
+ result = 0;
+ else if(val1a == NULL)
+ result = 1;
+ else if(val2a == NULL)
+ result = -1;
+ else
+ result = strcmp(val1a, val2a);
+
+ /* check second name if necessary */
+ if(result == 0) {
+ if(val1b == NULL && val2b == NULL)
+ result = 0;
+ else if(val1b == NULL)
+ result = 1;
+ else if(val2b == NULL)
+ result = -1;
+ else
+ result = strcmp(val1b, val2b);
+ }
+
+ return result;
+ }
+/*
+ * given a date/time in time_t format, produce a corresponding
+ * date/time string, including timezone
+ */
+void get_datetime_string(time_t * raw_time, char *buffer, int buffer_length,
+ int type) {
+ time_t t;
+ struct tm *tm_ptr, tm_s;
+ int hour;
+ int minute;
+ int second;
+ int month;
+ int day;
+ int year;
+ char *weekdays[7] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
+ char *months[12] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept",
+ "Oct", "Nov", "Dec"
+ };
+ char *tzone = "";
+
+ if(raw_time == NULL)
+ time(&t);
+ else
+ t = *raw_time;
+
+ if(type == HTTP_DATE_TIME)
+ tm_ptr = gmtime_r(&t, &tm_s);
+ else
+ tm_ptr = localtime_r(&t, &tm_s);
+
+ hour = tm_ptr->tm_hour;
+ minute = tm_ptr->tm_min;
+ second = tm_ptr->tm_sec;
+ month = tm_ptr->tm_mon + 1;
+ day = tm_ptr->tm_mday;
+ year = tm_ptr->tm_year + 1900;
+
+#ifdef HAVE_TM_ZONE
+ tzone = (char *)(tm_ptr->tm_zone);
+#else
+ tzone = (tm_ptr->tm_isdst) ? tzname[1] : tzname[0];
+#endif
+
+ /* ctime() style date/time */
+ if(type == LONG_DATE_TIME)
+ snprintf(buffer, buffer_length, "%s %s %d %02d:%02d:%02d %s %d",
+ weekdays[tm_ptr->tm_wday], months[tm_ptr->tm_mon], day,
+ hour, minute, second, tzone, year);
+
+ /* short date/time */
+ else if(type == SHORT_DATE_TIME) {
+ if(date_format == DATE_FORMAT_EURO)
+ snprintf(buffer, buffer_length,
+ "%02d-%02d-%04d %02d:%02d:%02d", day, month,
+ year, hour, minute, second);
+ else if(date_format == DATE_FORMAT_ISO8601
+ || date_format == DATE_FORMAT_STRICT_ISO8601)
+ snprintf(buffer, buffer_length,
+ "%04d-%02d-%02d%c%02d:%02d:%02d", year, month,
+ day,
+ (date_format ==
+ DATE_FORMAT_STRICT_ISO8601) ? 'T' : ' ', hour,
+ minute, second);
+ else
+ snprintf(buffer, buffer_length,
+ "%02d-%02d-%04d %02d:%02d:%02d", month, day,
+ year, hour, minute, second);
+ }
+
+ /* short date */
+ else if(type == SHORT_DATE) {
+ if(date_format == DATE_FORMAT_EURO)
+ snprintf(buffer, buffer_length, "%02d-%02d-%04d", day,
+ month, year);
+ else if(date_format == DATE_FORMAT_ISO8601
+ || date_format == DATE_FORMAT_STRICT_ISO8601)
+ snprintf(buffer, buffer_length, "%04d-%02d-%02d", year,
+ month, day);
+ else
+ snprintf(buffer, buffer_length, "%02d-%02d-%04d", month,
+ day, year);
+ }
+
+ /* expiration date/time for HTTP headers */
+ else if(type == HTTP_DATE_TIME)
+ snprintf(buffer, buffer_length,
+ "%s, %02d %s %d %02d:%02d:%02d GMT",
+ weekdays[tm_ptr->tm_wday], day, months[tm_ptr->tm_mon],
+ year, hour, minute, second);
+
+ /* short time */
+ else
+ snprintf(buffer, buffer_length, "%02d:%02d:%02d", hour, minute,
+ second);
+
+ buffer[buffer_length - 1] = '\x0';
+ }
+
+/* get days, hours, minutes, and seconds from a raw time_t format or total seconds */
+void get_time_breakdown(unsigned long raw_time, int *days, int *hours,
+ int *minutes, int *seconds) {
+ unsigned long temp_time;
+ int temp_days;
+ int temp_hours;
+ int temp_minutes;
+ int temp_seconds;
+
+ temp_time = raw_time;
+
+ temp_days = temp_time / 86400;
+ temp_time -= (temp_days * 86400);
+ temp_hours = temp_time / 3600;
+ temp_time -= (temp_hours * 3600);
+ temp_minutes = temp_time / 60;
+ temp_time -= (temp_minutes * 60);
+ temp_seconds = (int)temp_time;
+
+ *days = temp_days;
+ *hours = temp_hours;
+ *minutes = temp_minutes;
+ *seconds = temp_seconds;
+ }
diff --git a/common/skiplist.c b/common/skiplist.c
new file mode 100644
index 0000000..02bfaf3
--- /dev/null
+++ b/common/skiplist.c
@@ -0,0 +1,558 @@
+/************************************************************************
+ *
+ * SKIPLIST.C - Skiplist functions for use in Nagios event/object lists
+ *
+ * Copyright (c) 2008 Ethan Galstad
+ * Last Modified: 02-28-2008
+ *
+ * Notes:
+ *
+ * These function implement a slightly modified skiplist from that
+ * described by William Pugh (ftp://ftp.cs.umd.edu/pub/skipLists/skiplists.pdf).
+ * The structures and function were modified to allow the list to act
+ * like a priority queue for the Nagios event list/queue(s). Multiple nodes with
+ * the same key value are allowed on the list to accomodate multiple events
+ * occurring at the same (second) point in time. Implemented peek() and pop()
+ * functions to allow for quick event queue processing, and a method to delete
+ * a specific list item, based on its pointer, rather than its data value. Again,
+ * this is useful for the Nagios event queue.
+ *
+ * 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.
+ ************************************************************************/
+
+#include "../include/config.h"
+#include "../include/common.h"
+
+#include "../include/skiplist.h"
+
+
+
+skiplist *skiplist_new(int max_levels, float level_probability, int allow_duplicates, int append_duplicates, int (*compare_function)(void *, void *)) {
+ skiplist *newlist = NULL;
+
+ /* alloc memory for new list structure */
+ if((newlist = (skiplist *)malloc(sizeof(skiplist)))) {
+
+ /* initialize levels, etc. */
+ newlist->current_level = 0;
+ newlist->max_levels = max_levels;
+ newlist->level_probability = level_probability;
+ newlist->allow_duplicates = allow_duplicates;
+ newlist->append_duplicates = append_duplicates;
+ newlist->items = 0;
+ newlist->compare_function = compare_function;
+
+ /* initialize head node */
+ newlist->head = skiplist_new_node(newlist, max_levels);
+ }
+
+ return newlist;
+ }
+
+
+int skiplist_insert(skiplist *list, void *data) {
+ skiplistnode **update = NULL;
+ skiplistnode *thisnode = NULL;
+ skiplistnode *nextnode = NULL;
+ skiplistnode *newnode = NULL;
+ int level = 0;
+ int x = 0;
+
+ if(list == NULL || data == NULL) {
+ return SKIPLIST_ERROR_ARGS;
+ }
+
+ /* initialize update vector */
+ if((update = (skiplistnode **)malloc(sizeof(skiplistnode *) * list->max_levels)) == NULL) {
+ return SKIPLIST_ERROR_MEMORY;
+ }
+ for(x = 0; x < list->max_levels; x++)
+ update[x] = NULL;
+
+ /* check to make sure we don't have duplicates */
+ /* NOTE: this could made be more efficient */
+ if(list->allow_duplicates == FALSE) {
+ if(skiplist_find_first(list, data, NULL))
+ return SKIPLIST_ERROR_DUPLICATE;
+ }
+
+ /* find proper position for insert, remember pointers with an update vector */
+ thisnode = list->head;
+ for(level = list->current_level; level >= 0; level--) {
+
+ while((nextnode = thisnode->forward[level])) {
+ if(list->append_duplicates == TRUE) {
+ if(list->compare_function(nextnode->data, data) > 0)
+ break;
+ }
+ else {
+ if(list->compare_function(nextnode->data, data) >= 0)
+ break;
+ }
+ thisnode = nextnode;
+ }
+
+ update[level] = thisnode;
+ }
+
+ /* get a random level the new node should be inserted at */
+ level = skiplist_random_level(list);
+ /*printf("INSERTION LEVEL: %d\n",level);*/
+
+ /* we're adding a new level... */
+ if(level > list->current_level) {
+ /*printf("NEW LEVEL!\n");*/
+ list->current_level++;
+ level = list->current_level;
+ update[level] = list->head;
+ }
+
+ /* create a new node */
+ if((newnode = skiplist_new_node(list, level)) == NULL) {
+ /*printf("NODE ERROR\n");*/
+ free(update);
+ return SKIPLIST_ERROR_MEMORY;
+ }
+ newnode->data = data;
+
+ /* update pointers to insert node at proper location */
+ do {
+ thisnode = update[level];
+ newnode->forward[level] = thisnode->forward[level];
+ thisnode->forward[level] = newnode;
+
+ }
+ while(--level >= 0);
+
+ /* update counters */
+ list->items++;
+
+ /* free memory */
+ free(update);
+
+ return SKIPLIST_OK;
+ }
+
+
+
+skiplistnode *skiplist_new_node(skiplist *list, int node_levels) {
+ skiplistnode *newnode = NULL;
+ register int x = 0;
+
+ if(list == NULL)
+ return NULL;
+
+ if(node_levels < 0 || node_levels > list->max_levels)
+ return NULL;
+
+ /* allocate memory for node + variable number of level pointers */
+ if((newnode = (skiplistnode *)malloc(sizeof(skiplistnode) + (node_levels * sizeof(skiplistnode *))))) {
+
+ /* initialize forward pointers */
+ for(x = 0; x < node_levels; x++)
+ newnode->forward[x] = NULL;
+
+ /* initialize data pointer */
+ newnode->data = NULL;
+ }
+
+ return newnode;
+ }
+
+
+int skiplist_random_level(skiplist *list) {
+ int level = 0;
+ float r = 0.0;
+
+ if(list == NULL)
+ return -1;
+
+ for(level = 0; level < list->max_levels; level++) {
+ r = ((float)rand() / (float)RAND_MAX);
+ if(r > list->level_probability)
+ break;
+ }
+
+ return (level >= list->max_levels) ? list->max_levels - 1 : level;
+ }
+
+
+int skiplist_empty(skiplist *list) {
+ skiplistnode *this = NULL;
+ skiplistnode *next = NULL;
+ int level = 0;
+
+ if(list == NULL)
+ return ERROR;
+
+ /* free all list nodes (but not header) */
+ for(this = list->head->forward[0]; this != NULL; this = next) {
+ next = this->forward[0];
+ free(this);
+ }
+
+ /* reset level pointers */
+ for(level = list->current_level; level >= 0; level--)
+ list->head->forward[level] = NULL;
+
+ /* reset list level */
+ list->current_level = 0;
+
+ /* reset items */
+ list->items = 0;
+
+ return OK;
+ }
+
+
+
+int skiplist_free(skiplist **list) {
+ skiplistnode *this = NULL;
+ skiplistnode *next = NULL;
+
+ if(list == NULL)
+ return ERROR;
+ if(*list == NULL)
+ return OK;
+
+ /* free header and all list nodes */
+ for(this = (*list)->head; this != NULL; this = next) {
+ next = this->forward[0];
+ free(this);
+ }
+
+ /* free list structure */
+ free(*list);
+ *list = NULL;
+
+ return OK;
+ }
+
+
+
+/* get first item in list */
+void *skiplist_peek(skiplist *list) {
+
+ if(list == NULL)
+ return NULL;
+
+ /* return first item */
+ return list->head->forward[0]->data;
+ }
+
+
+
+/* get/remove first item in list */
+void *skiplist_pop(skiplist *list) {
+ skiplistnode *thisnode = NULL;
+ void *data = NULL;
+ int level = 0;
+
+ if(list == NULL)
+ return NULL;
+
+ /* get first item */
+ thisnode = list->head->forward[0];
+ if(thisnode == NULL)
+ return NULL;
+
+ /* get data for first item */
+ data = thisnode->data;
+
+ /* remove first item from queue - update forward links from head to first node */
+ for(level = 0; level <= list->current_level; level++) {
+ if(list->head->forward[level] == thisnode)
+ list->head->forward[level] = thisnode->forward[level];
+ }
+
+ /* free deleted node */
+ free(thisnode);
+
+ /* adjust items */
+ list->items--;
+
+ return data;
+ }
+
+
+
+/* get first item in list */
+void *skiplist_get_first(skiplist *list, void **node_ptr) {
+ skiplistnode *thisnode = NULL;
+
+ if(list == NULL)
+ return NULL;
+
+ /* get first node */
+ thisnode = list->head->forward[0];
+
+ /* return pointer to node */
+ if(node_ptr)
+ *node_ptr = (void *)thisnode;
+
+ if(thisnode)
+ return thisnode->data;
+ else
+ return NULL;
+ }
+
+
+
+/* get next item in list */
+void *skiplist_get_next(void **node_ptr) {
+ skiplistnode *thisnode = NULL;
+ skiplistnode *nextnode = NULL;
+
+ if(node_ptr == NULL || *node_ptr == NULL)
+ return NULL;
+
+ thisnode = (skiplistnode *)(*node_ptr);
+ nextnode = thisnode->forward[0];
+
+ *node_ptr = (void *)nextnode;
+
+ if(nextnode)
+ return nextnode->data;
+ else
+ return NULL;
+ }
+
+
+
+/* first first item in list */
+void *skiplist_find_first(skiplist *list, void *data, void **node_ptr) {
+ skiplistnode *thisnode = NULL;
+ skiplistnode *nextnode = NULL;
+ int level = 0;
+
+ if(list == NULL || data == NULL)
+ return NULL;
+
+ thisnode = list->head;
+ for(level = list->current_level; level >= 0; level--) {
+ while((nextnode = thisnode->forward[level])) {
+ if(list->compare_function(nextnode->data, data) >= 0)
+ break;
+ thisnode = nextnode;
+ }
+ }
+
+ /* we found it! */
+ if(nextnode && list->compare_function(nextnode->data, data) == 0) {
+ if(node_ptr)
+ *node_ptr = (void *)nextnode;
+ return nextnode->data;
+ }
+ else {
+ if(node_ptr)
+ *node_ptr = NULL;
+ }
+
+ return NULL;
+ }
+
+
+
+/* find next match */
+void *skiplist_find_next(skiplist *list, void *data, void **node_ptr) {
+ skiplistnode *thisnode = NULL;
+ skiplistnode *nextnode = NULL;
+
+ if(list == NULL || data == NULL || node_ptr == NULL)
+ return NULL;
+ if(*node_ptr == NULL)
+ return NULL;
+
+ thisnode = (skiplistnode *)(*node_ptr);
+ nextnode = thisnode->forward[0];
+
+ if(nextnode) {
+ if(list->compare_function(nextnode->data, data) == 0) {
+ *node_ptr = (void *)nextnode;
+ return nextnode->data;
+ }
+ }
+
+ *node_ptr = NULL;
+ return NULL;
+ }
+
+
+
+/* delete (all) matching item(s) from list */
+int skiplist_delete(skiplist *list, void *data) {
+
+ return skiplist_delete_all(list, data);
+ }
+
+
+
+/* delete first matching item from list */
+int skiplist_delete_first(skiplist *list, void *data) {
+ skiplistnode **update = NULL;
+ skiplistnode *thisnode = NULL;
+ skiplistnode *nextnode = NULL;
+ int level = 0;
+ int top_level = 0;
+ int deleted = FALSE;
+ int x = 0;
+
+ if(list == NULL || data == NULL)
+ return ERROR;
+
+ /* initialize update vector */
+ if((update = (skiplistnode **)malloc(sizeof(skiplistnode *) * list->max_levels)) == NULL)
+ return ERROR;
+ for(x = 0; x < list->max_levels; x++)
+ update[x] = NULL;
+
+ /* find location in list */
+ thisnode = list->head;
+ for(top_level = level = list->current_level; level >= 0; level--) {
+ while((nextnode = thisnode->forward[level])) {
+ if(list->compare_function(nextnode->data, data) >= 0)
+ break;
+ thisnode = nextnode;
+ }
+ update[level] = thisnode;
+ }
+
+ /* we found a match! */
+ if(list->compare_function(nextnode->data, data) == 0) {
+
+ /* adjust level pointers to bypass (soon to be) removed node */
+ for(level = 0; level <= top_level; level++) {
+
+ thisnode = update[level];
+ if(thisnode->forward[level] != nextnode)
+ break;
+
+ thisnode->forward[level] = nextnode->forward[level];
+ }
+
+ /* free node memory */
+ free(nextnode);
+
+ /* adjust top/current level of list is necessary */
+ while(list->head->forward[top_level] == NULL && top_level > 0)
+ top_level--;
+ list->current_level = top_level;
+
+ /* adjust items */
+ list->items--;
+
+ deleted = TRUE;
+ }
+
+ /* free memory */
+ free(update);
+
+ return deleted;
+ }
+
+
+
+/* delete all matching items from list */
+int skiplist_delete_all(skiplist *list, void *data) {
+ int deleted = 0;
+ int total_deleted = 0;
+
+ /* NOTE: there is a more efficient way to do this... */
+ while((deleted = skiplist_delete_first(list, data)) == 1)
+ total_deleted++;
+
+ return total_deleted;
+ }
+
+
+
+/* delete specific node from list */
+int skiplist_delete_node(skiplist *list, void *node_ptr) {
+ void *data = NULL;
+ skiplistnode **update = NULL;
+ skiplistnode *thenode = NULL;
+ skiplistnode *thisnode = NULL;
+ skiplistnode *nextnode = NULL;
+ int level = 0;
+ int top_level = 0;
+ int deleted = FALSE;
+ int x = 0;
+
+ if(list == NULL || node_ptr == NULL)
+ return ERROR;
+
+ /* we'll need the data from the node to first find the node */
+ thenode = (skiplistnode *)node_ptr;
+ data = thenode->data;
+
+ /* initialize update vector */
+ if((update = (skiplistnode **)malloc(sizeof(skiplistnode *) * list->max_levels)) == NULL)
+ return ERROR;
+ for(x = 0; x < list->max_levels; x++)
+ update[x] = NULL;
+
+ /* find location in list */
+ thisnode = list->head;
+ for(top_level = level = list->current_level; level >= 0; level--) {
+ while((nextnode = thisnode->forward[level])) {
+
+ /* next node would be too far */
+ if(list->compare_function(nextnode->data, data) > 0)
+ break;
+ /* this is the exact node we want */
+ if(list->compare_function(nextnode->data, data) == 0 && nextnode == thenode)
+ break;
+
+ thisnode = nextnode;
+ }
+ update[level] = thisnode;
+ }
+
+ /* we found a match! (value + pointers match) */
+ if(nextnode && list->compare_function(nextnode->data, data) == 0 && nextnode == thenode) {
+
+ /* adjust level pointers to bypass (soon to be) removed node */
+ for(level = 0; level <= top_level; level++) {
+
+ thisnode = update[level];
+ if(thisnode->forward[level] != nextnode)
+ break;
+
+ thisnode->forward[level] = nextnode->forward[level];
+ }
+
+ /* free node memory */
+ free(nextnode);
+
+ /* adjust top/current level of list is necessary */
+ while(list->head->forward[top_level] == NULL && top_level > 0)
+ top_level--;
+ list->current_level = top_level;
+
+ /* adjust items */
+ list->items--;
+
+ deleted = TRUE;
+ }
+
+ /* free memory */
+ free(update);
+
+ return deleted;
+ }
+
+
+
diff --git a/common/snprintf.c b/common/snprintf.c
new file mode 100644
index 0000000..d7018eb
--- /dev/null
+++ b/common/snprintf.c
@@ -0,0 +1,1459 @@
+/*
+ * NOTE: If you change this file, please merge it into rsync, samba, etc.
+ */
+
+/*
+ * Copyright Patrick Powell 1995
+ * This code is based on code written by Patrick Powell (papowell@astart.com)
+ * It may be used for any purpose as long as this notice remains intact
+ * on all source code distributions
+ */
+
+/**************************************************************
+ * Original:
+ * Patrick Powell Tue Apr 11 09:48:21 PDT 1995
+ * A bombproof version of doprnt (dopr) included.
+ * Sigh. This sort of thing is always nasty do deal with. Note that
+ * the version here does not include floating point...
+ *
+ * snprintf() is used instead of sprintf() as it does limit checks
+ * for string length. This covers a nasty loophole.
+ *
+ * The other functions are there to prevent NULL pointers from
+ * causing nast effects.
+ *
+ * More Recently:
+ * Brandon Long 9/15/96 for mutt 0.43
+ * This was ugly. It is still ugly. I opted out of floating point
+ * numbers, but the formatter understands just about everything
+ * from the normal C string format, at least as far as I can tell from
+ * the Solaris 2.5 printf(3S) man page.
+ *
+ * Brandon Long 10/22/97 for mutt 0.87.1
+ * Ok, added some minimal floating point support, which means this
+ * probably requires libm on most operating systems. Don't yet
+ * support the exponent (e,E) and sigfig (g,G). Also, fmtint()
+ * was pretty badly broken, it just wasn't being exercised in ways
+ * which showed it, so that's been fixed. Also, formated the code
+ * to mutt conventions, and removed dead code left over from the
+ * original. Also, there is now a builtin-test, just compile with:
+ * gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm
+ * and run snprintf for results.
+ *
+ * Thomas Roessler 01/27/98 for mutt 0.89i
+ * The PGP code was using unsigned hexadecimal formats.
+ * Unfortunately, unsigned formats simply didn't work.
+ *
+ * Michael Elkins 03/05/98 for mutt 0.90.8
+ * The original code assumed that both snprintf() and vsnprintf() were
+ * missing. Some systems only have snprintf() but not vsnprintf(), so
+ * the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF.
+ *
+ * Andrew Tridgell (tridge@samba.org) Oct 1998
+ * fixed handling of %.0f
+ * added test for HAVE_LONG_DOUBLE
+ *
+ * tridge@samba.org, idra@samba.org, April 2001
+ * got rid of fcvt code (twas buggy and made testing harder)
+ * added C99 semantics
+ *
+ * date: 2002/12/19 19:56:31; author: herb; state: Exp; lines: +2 -0
+ * actually print args for %g and %e
+ *
+ * date: 2002/06/03 13:37:52; author: jmcd; state: Exp; lines: +8 -0
+ * Since includes.h isn't included here, VA_COPY has to be defined here. I don't
+ * see any include file that is guaranteed to be here, so I'm defining it
+ * locally. Fixes AIX and Solaris builds.
+ *
+ * date: 2002/06/03 03:07:24; author: tridge; state: Exp; lines: +5 -13
+ * put the ifdef for HAVE_VA_COPY in one place rather than in lots of
+ * functions
+ *
+ * date: 2002/05/17 14:51:22; author: jmcd; state: Exp; lines: +21 -4
+ * Fix usage of va_list passed as an arg. Use __va_copy before using it
+ * when it exists.
+ *
+ * date: 2002/04/16 22:38:04; author: idra; state: Exp; lines: +20 -14
+ * Fix incorrect zpadlen handling in fmtfp.
+ * Thanks to Ollie Oldham for spotting it.
+ * few mods to make it easier to compile the tests.
+ * addedd the "Ollie" test to the floating point ones.
+ *
+ * Martin Pool (mbp@samba.org) April 2003
+ * Remove NO_CONFIG_H so that the test case can be built within a source
+ * tree with less trouble.
+ * Remove unnecessary SAFE_FREE() definition.
+ *
+ * Martin Pool (mbp@samba.org) May 2003
+ * Put in a prototype for dummy_snprintf() to quiet compiler warnings.
+ *
+ * Move #endif to make sure VA_COPY, LDOUBLE, etc are defined even
+ * if the C library has some snprintf functions already.
+ *
+ * Darren Tucker (dtucker@zip.com.au) 2005
+ * Fix bug allowing read overruns of the source string with "%.*s"
+ * Usually harmless unless the read runs outside the process' allocation
+ * (eg if your malloc does guard pages) in which case it will segfault.
+ * From OpenSSH. Also added test for same.
+ *
+ * Simo Sorce (idra@samba.org) Jan 2006
+ *
+ * Add support for position independent parameters
+ * fix fmtstr now it conforms to sprintf wrt min.max
+ *
+ **************************************************************/
+
+#ifndef NO_CONFIG_H
+/* 02/28/2006 EG changed path to config.h to match Nagios distro */
+#include "../include/config.h"
+#else
+#define NULL 0
+#endif
+
+#ifdef TEST_SNPRINTF /* need math library headers for testing */
+
+/* In test mode, we pretend that this system doesn't have any snprintf
+ * functions, regardless of what config.h says. */
+# undef HAVE_SNPRINTF
+# undef HAVE_VSNPRINTF
+# undef HAVE_C99_VSNPRINTF
+# undef HAVE_ASPRINTF
+# undef HAVE_VASPRINTF
+# include
+#endif /* TEST_SNPRINTF */
+
+#ifdef HAVE_STRING_H
+#include
+#endif
+
+#ifdef HAVE_STRINGS_H
+#include
+#endif
+#ifdef HAVE_CTYPE_H
+#include
+#endif
+#include
+#include
+#ifdef HAVE_STDLIB_H
+#include
+#endif
+
+#if defined(HAVE_SNPRINTF) && defined(HAVE_VSNPRINTF) && defined(HAVE_C99_VSNPRINTF)
+/* only include stdio.h if we are not re-defining snprintf or vsnprintf */
+#include
+/* make the compiler happy with an empty file */
+void dummy_snprintf(void);
+void dummy_snprintf(void) {}
+#endif /* HAVE_SNPRINTF, etc */
+
+#ifdef HAVE_LONG_DOUBLE
+#define LDOUBLE long double
+#else
+#define LDOUBLE double
+#endif
+
+#ifdef HAVE_LONG_LONG
+#define LLONG long long
+#else
+#define LLONG long
+#endif
+
+#ifndef VA_COPY
+#ifdef HAVE_VA_COPY
+#define VA_COPY(dest, src) va_copy(dest, src)
+#else
+#ifdef HAVE___VA_COPY
+#define VA_COPY(dest, src) __va_copy(dest, src)
+#else
+#define VA_COPY(dest, src) (dest) = (src)
+#endif
+#endif
+
+/*
+ * dopr(): poor man's version of doprintf
+ */
+
+/* format read states */
+#define DP_S_DEFAULT 0
+#define DP_S_FLAGS 1
+#define DP_S_MIN 2
+#define DP_S_DOT 3
+#define DP_S_MAX 4
+#define DP_S_MOD 5
+#define DP_S_CONV 6
+#define DP_S_DONE 7
+
+/* format flags - Bits */
+#define DP_F_MINUS (1 << 0)
+#define DP_F_PLUS (1 << 1)
+#define DP_F_SPACE (1 << 2)
+#define DP_F_NUM (1 << 3)
+#define DP_F_ZERO (1 << 4)
+#define DP_F_UP (1 << 5)
+#define DP_F_UNSIGNED (1 << 6)
+
+/* Conversion Flags */
+#define DP_C_CHAR 1
+#define DP_C_SHORT 2
+#define DP_C_LONG 3
+#define DP_C_LDOUBLE 4
+#define DP_C_LLONG 5
+
+/* Chunk types */
+#define CNK_FMT_STR 0
+#define CNK_INT 1
+#define CNK_OCTAL 2
+#define CNK_UINT 3
+#define CNK_HEX 4
+#define CNK_FLOAT 5
+#define CNK_CHAR 6
+#define CNK_STRING 7
+#define CNK_PTR 8
+#define CNK_NUM 9
+#define CNK_PRCNT 10
+
+#define char_to_int(p) ((p)- '0')
+#ifndef MAX
+#define MAX(p,q) (((p) >= (q)) ? (p) : (q))
+#endif
+
+/* yes this really must be a ||. Don't muck with this (tridge) */
+#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
+
+struct pr_chunk {
+ int type; /* chunk type */
+ int num; /* parameter number */
+ int min;
+ int max;
+ int flags;
+ int cflags;
+ int start;
+ int len;
+ LLONG value;
+ LDOUBLE fvalue;
+ char *strvalue;
+ void *pnum;
+ struct pr_chunk *min_star;
+ struct pr_chunk *max_star;
+ struct pr_chunk *next;
+ };
+
+struct pr_chunk_x {
+ struct pr_chunk **chunks;
+ int num;
+ };
+
+static size_t dopr(char *buffer, size_t maxlen, const char *format,
+ va_list args_in);
+static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
+ char *value, int flags, int min, int max);
+static void fmtint(char *buffer, size_t *currlen, size_t maxlen,
+ long value, int base, int min, int max, int flags);
+static void fmtfp(char *buffer, size_t *currlen, size_t maxlen,
+ LDOUBLE fvalue, int min, int max, int flags);
+static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c);
+static struct pr_chunk *new_chunk(void);
+static int add_cnk_list_entry(struct pr_chunk_x **list,
+ int max_num, struct pr_chunk *chunk);
+
+static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args_in) {
+ char ch;
+ int state;
+ int pflag;
+ int pnum;
+ int pfirst;
+ size_t currlen;
+ va_list args;
+ const char *base;
+ struct pr_chunk *chunks = NULL;
+ struct pr_chunk *cnk = NULL;
+ struct pr_chunk_x *clist = NULL;
+ int max_pos;
+ size_t ret = -1;
+
+ VA_COPY(args, args_in);
+
+ state = DP_S_DEFAULT;
+ pfirst = 1;
+ pflag = 0;
+ pnum = 0;
+
+ max_pos = 0;
+ base = format;
+ ch = *format++;
+
+ /* retrieve the string structure as chunks */
+ while(state != DP_S_DONE) {
+ if(ch == '\0')
+ state = DP_S_DONE;
+
+ switch(state) {
+ case DP_S_DEFAULT:
+
+ if(cnk) {
+ cnk->next = new_chunk();
+ cnk = cnk->next;
+ }
+ else {
+ cnk = new_chunk();
+ }
+ if(!cnk) goto done;
+ if(!chunks) chunks = cnk;
+
+ if(ch == '%') {
+ state = DP_S_FLAGS;
+ ch = *format++;
+ }
+ else {
+ cnk->type = CNK_FMT_STR;
+ cnk->start = format - base - 1;
+ while((ch != '\0') && (ch != '%')) ch = *format++;
+ cnk->len = format - base - cnk->start - 1;
+ }
+ break;
+ case DP_S_FLAGS:
+ switch(ch) {
+ case '-':
+ cnk->flags |= DP_F_MINUS;
+ ch = *format++;
+ break;
+ case '+':
+ cnk->flags |= DP_F_PLUS;
+ ch = *format++;
+ break;
+ case ' ':
+ cnk->flags |= DP_F_SPACE;
+ ch = *format++;
+ break;
+ case '#':
+ cnk->flags |= DP_F_NUM;
+ ch = *format++;
+ break;
+ case '0':
+ cnk->flags |= DP_F_ZERO;
+ ch = *format++;
+ break;
+ case 'I':
+ /* internationalization not supported yet */
+ ch = *format++;
+ break;
+ default:
+ state = DP_S_MIN;
+ break;
+ }
+ break;
+ case DP_S_MIN:
+ if(isdigit((unsigned char)ch)) {
+ cnk->min = 10 * cnk->min + char_to_int(ch);
+ ch = *format++;
+ }
+ else if(ch == '$') {
+ if(!pfirst && !pflag) {
+ /* parameters must be all positioned or none */
+ goto done;
+ }
+ if(pfirst) {
+ pfirst = 0;
+ pflag = 1;
+ }
+ if(cnk->min == 0) /* what ?? */
+ goto done;
+ cnk->num = cnk->min;
+ cnk->min = 0;
+ ch = *format++;
+ }
+ else if(ch == '*') {
+ if(pfirst) pfirst = 0;
+ cnk->min_star = new_chunk();
+ if(!cnk->min_star) /* out of memory :-( */
+ goto done;
+ cnk->min_star->type = CNK_INT;
+ if(pflag) {
+ int num;
+ ch = *format++;
+ if(!isdigit((unsigned char)ch)) {
+ /* parameters must be all positioned or none */
+ goto done;
+ }
+ for(num = 0; isdigit((unsigned char)ch); ch = *format++) {
+ num = 10 * num + char_to_int(ch);
+ }
+ cnk->min_star->num = num;
+ if(ch != '$') /* what ?? */
+ goto done;
+ }
+ else {
+ cnk->min_star->num = ++pnum;
+ }
+ max_pos = add_cnk_list_entry(&clist, max_pos, cnk->min_star);
+ if(max_pos == 0) /* out of memory :-( */
+ goto done;
+ ch = *format++;
+ state = DP_S_DOT;
+ }
+ else {
+ if(pfirst) pfirst = 0;
+ state = DP_S_DOT;
+ }
+ break;
+ case DP_S_DOT:
+ if(ch == '.') {
+ state = DP_S_MAX;
+ ch = *format++;
+ }
+ else {
+ state = DP_S_MOD;
+ }
+ break;
+ case DP_S_MAX:
+ if(isdigit((unsigned char)ch)) {
+ if(cnk->max < 0)
+ cnk->max = 0;
+ cnk->max = 10 * cnk->max + char_to_int(ch);
+ ch = *format++;
+ }
+ else if(ch == '$') {
+ if(!pfirst && !pflag) {
+ /* parameters must be all positioned or none */
+ goto done;
+ }
+ if(cnk->max <= 0) /* what ?? */
+ goto done;
+ cnk->num = cnk->max;
+ cnk->max = -1;
+ ch = *format++;
+ }
+ else if(ch == '*') {
+ cnk->max_star = new_chunk();
+ if(!cnk->max_star) /* out of memory :-( */
+ goto done;
+ cnk->max_star->type = CNK_INT;
+ if(pflag) {
+ int num;
+ ch = *format++;
+ if(!isdigit((unsigned char)ch)) {
+ /* parameters must be all positioned or none */
+ goto done;
+ }
+ for(num = 0; isdigit((unsigned char)ch); ch = *format++) {
+ num = 10 * num + char_to_int(ch);
+ }
+ cnk->max_star->num = num;
+ if(ch != '$') /* what ?? */
+ goto done;
+ }
+ else {
+ cnk->max_star->num = ++pnum;
+ }
+ max_pos = add_cnk_list_entry(&clist, max_pos, cnk->max_star);
+ if(max_pos == 0) /* out of memory :-( */
+ goto done;
+
+ ch = *format++;
+ state = DP_S_MOD;
+ }
+ else {
+ state = DP_S_MOD;
+ }
+ break;
+ case DP_S_MOD:
+ switch(ch) {
+ case 'h':
+ cnk->cflags = DP_C_SHORT;
+ ch = *format++;
+ if(ch == 'h') {
+ cnk->cflags = DP_C_CHAR;
+ ch = *format++;
+ }
+ break;
+ case 'l':
+ cnk->cflags = DP_C_LONG;
+ ch = *format++;
+ if(ch == 'l') { /* It's a long long */
+ cnk->cflags = DP_C_LLONG;
+ ch = *format++;
+ }
+ break;
+ case 'L':
+ cnk->cflags = DP_C_LDOUBLE;
+ ch = *format++;
+ break;
+ default:
+ break;
+ }
+ state = DP_S_CONV;
+ break;
+ case DP_S_CONV:
+ if(cnk->num == 0) cnk->num = ++pnum;
+ max_pos = add_cnk_list_entry(&clist, max_pos, cnk);
+ if(max_pos == 0) /* out of memory :-( */
+ goto done;
+
+ switch(ch) {
+ case 'd':
+ case 'i':
+ cnk->type = CNK_INT;
+ break;
+ case 'o':
+ cnk->type = CNK_OCTAL;
+ cnk->flags |= DP_F_UNSIGNED;
+ break;
+ case 'u':
+ cnk->type = CNK_UINT;
+ cnk->flags |= DP_F_UNSIGNED;
+ break;
+ case 'X':
+ cnk->flags |= DP_F_UP;
+ case 'x':
+ cnk->type = CNK_HEX;
+ cnk->flags |= DP_F_UNSIGNED;
+ break;
+ case 'A':
+ /* hex float not supported yet */
+ case 'E':
+ case 'G':
+ case 'F':
+ cnk->flags |= DP_F_UP;
+ case 'a':
+ /* hex float not supported yet */
+ case 'e':
+ case 'f':
+ case 'g':
+ cnk->type = CNK_FLOAT;
+ break;
+ case 'c':
+ cnk->type = CNK_CHAR;
+ break;
+ case 's':
+ cnk->type = CNK_STRING;
+ break;
+ case 'p':
+ cnk->type = CNK_PTR;
+ break;
+ case 'n':
+ cnk->type = CNK_NUM;
+ break;
+ case '%':
+ cnk->type = CNK_PRCNT;
+ break;
+ default:
+ /* Unknown, bail out*/
+ goto done;
+ }
+ ch = *format++;
+ state = DP_S_DEFAULT;
+ break;
+ case DP_S_DONE:
+ break;
+ default:
+ /* hmm? */
+ break; /* some picky compilers need this */
+ }
+ }
+
+ /* retieve the format arguments */
+ for(pnum = 0; pnum < max_pos; pnum++) {
+ int i;
+
+ if(clist[pnum].num == 0) {
+ /* ignoring a parameter should not be permitted
+ * all parameters must be matched at least once
+ * BUT seem some system ignore this rule ...
+ * at least my glibc based system does --SSS
+ */
+#ifdef DEBUG_SNPRINTF
+ printf("parameter at position %d not used\n", pnum + 1);
+#endif
+ /* eat the parameter */
+ va_arg(args, int);
+ continue;
+ }
+ for(i = 1; i < clist[pnum].num; i++) {
+ if(clist[pnum].chunks[0]->type != clist[pnum].chunks[i]->type) {
+ /* nooo noo no!
+ * all the references to a parameter
+ * must be of the same type
+ */
+ goto done;
+ }
+ }
+ cnk = clist[pnum].chunks[0];
+ switch(cnk->type) {
+ case CNK_INT:
+ if(cnk->cflags == DP_C_SHORT)
+ cnk->value = va_arg(args, int);
+ else if(cnk->cflags == DP_C_LONG)
+ cnk->value = va_arg(args, long int);
+ else if(cnk->cflags == DP_C_LLONG)
+ cnk->value = va_arg(args, LLONG);
+ else
+ cnk->value = va_arg(args, int);
+
+ for(i = 1; i < clist[pnum].num; i++) {
+ clist[pnum].chunks[i]->value = cnk->value;
+ }
+ break;
+
+ case CNK_OCTAL:
+ case CNK_UINT:
+ case CNK_HEX:
+ if(cnk->cflags == DP_C_SHORT)
+ cnk->value = va_arg(args, unsigned int);
+ else if(cnk->cflags == DP_C_LONG)
+ cnk->value = (long)va_arg(args, unsigned long int);
+ else if(cnk->cflags == DP_C_LLONG)
+ cnk->value = (LLONG)va_arg(args, unsigned LLONG);
+ else
+ cnk->value = (long)va_arg(args, unsigned int);
+
+ for(i = 1; i < clist[pnum].num; i++) {
+ clist[pnum].chunks[i]->value = cnk->value;
+ }
+ break;
+
+ case CNK_FLOAT:
+ if(cnk->cflags == DP_C_LDOUBLE)
+ cnk->fvalue = va_arg(args, LDOUBLE);
+ else
+ cnk->fvalue = va_arg(args, double);
+
+ for(i = 1; i < clist[pnum].num; i++) {
+ clist[pnum].chunks[i]->fvalue = cnk->fvalue;
+ }
+ break;
+
+ case CNK_CHAR:
+ cnk->value = va_arg(args, int);
+
+ for(i = 1; i < clist[pnum].num; i++) {
+ clist[pnum].chunks[i]->value = cnk->value;
+ }
+ break;
+
+ case CNK_STRING:
+ cnk->strvalue = va_arg(args, char *);
+ if(!cnk->strvalue) cnk->strvalue = "(NULL)";
+
+ for(i = 1; i < clist[pnum].num; i++) {
+ clist[pnum].chunks[i]->strvalue = cnk->strvalue;
+ }
+ break;
+
+ case CNK_PTR:
+ cnk->strvalue = va_arg(args, void *);
+ for(i = 1; i < clist[pnum].num; i++) {
+ clist[pnum].chunks[i]->strvalue = cnk->strvalue;
+ }
+ break;
+
+ case CNK_NUM:
+ if(cnk->cflags == DP_C_CHAR)
+ cnk->pnum = va_arg(args, char *);
+ else if(cnk->cflags == DP_C_SHORT)
+ cnk->pnum = va_arg(args, short int *);
+ else if(cnk->cflags == DP_C_LONG)
+ cnk->pnum = va_arg(args, long int *);
+ else if(cnk->cflags == DP_C_LLONG)
+ cnk->pnum = va_arg(args, LLONG *);
+ else
+ cnk->pnum = va_arg(args, int *);
+
+ for(i = 1; i < clist[pnum].num; i++) {
+ clist[pnum].chunks[i]->pnum = cnk->pnum;
+ }
+ break;
+
+ case CNK_PRCNT:
+ break;
+
+ default:
+ /* what ?? */
+ goto done;
+ }
+ }
+ /* print out the actual string from chunks */
+ currlen = 0;
+ cnk = chunks;
+ while(cnk) {
+ int len, min, max;
+
+ if(cnk->min_star) min = cnk->min_star->value;
+ else min = cnk->min;
+ if(cnk->max_star) max = cnk->max_star->value;
+ else max = cnk->max;
+
+ switch(cnk->type) {
+
+ case CNK_FMT_STR:
+ if(maxlen != 0 && maxlen > currlen) {
+ if(maxlen > (currlen + cnk->len)) len = cnk->len;
+ else len = maxlen - currlen;
+
+ memcpy(&(buffer[currlen]), &(base[cnk->start]), len);
+ }
+ currlen += cnk->len;
+
+ break;
+
+ case CNK_INT:
+ case CNK_UINT:
+ fmtint(buffer, &currlen, maxlen, cnk->value, 10, min, max, cnk->flags);
+ break;
+
+ case CNK_OCTAL:
+ fmtint(buffer, &currlen, maxlen, cnk->value, 8, min, max, cnk->flags);
+ break;
+
+ case CNK_HEX:
+ fmtint(buffer, &currlen, maxlen, cnk->value, 16, min, max, cnk->flags);
+ break;
+
+ case CNK_FLOAT:
+ fmtfp(buffer, &currlen, maxlen, cnk->fvalue, min, max, cnk->flags);
+ break;
+
+ case CNK_CHAR:
+ dopr_outch(buffer, &currlen, maxlen, cnk->value);
+ break;
+
+ case CNK_STRING:
+ if(max == -1) {
+ max = strlen(cnk->strvalue);
+ }
+ fmtstr(buffer, &currlen, maxlen, cnk->strvalue, cnk->flags, min, max);
+ break;
+
+ case CNK_PTR:
+ fmtint(buffer, &currlen, maxlen, (long)(cnk->strvalue), 16, min, max, cnk->flags);
+ break;
+
+ case CNK_NUM:
+ if(cnk->cflags == DP_C_CHAR)
+ *((char *)(cnk->pnum)) = (char)currlen;
+ else if(cnk->cflags == DP_C_SHORT)
+ *((short int *)(cnk->pnum)) = (short int)currlen;
+ else if(cnk->cflags == DP_C_LONG)
+ *((long int *)(cnk->pnum)) = (long int)currlen;
+ else if(cnk->cflags == DP_C_LLONG)
+ *((LLONG *)(cnk->pnum)) = (LLONG)currlen;
+ else
+ *((int *)(cnk->pnum)) = (int)currlen;
+ break;
+
+ case CNK_PRCNT:
+ dopr_outch(buffer, &currlen, maxlen, '%');
+ break;
+
+ default:
+ /* what ?? */
+ goto done;
+ }
+ cnk = cnk->next;
+ }
+ if(maxlen != 0) {
+ if(currlen < maxlen - 1)
+ buffer[currlen] = '\0';
+ else if(maxlen > 0)
+ buffer[maxlen - 1] = '\0';
+ }
+ ret = currlen;
+
+done:
+ while(chunks) {
+ cnk = chunks->next;
+ free(chunks);
+ chunks = cnk;
+ }
+ if(clist) {
+ for(pnum = 0; pnum < max_pos; pnum++) {
+ if(clist[pnum].chunks) free(clist[pnum].chunks);
+ }
+ free(clist);
+ }
+ return ret;
+ }
+
+static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
+ char *value, int flags, int min, int max) {
+ int padlen, strln; /* amount to pad */
+ int cnt = 0;
+
+#ifdef DEBUG_SNPRINTF
+ printf("fmtstr min=%d max=%d s=[%s]\n", min, max, value);
+#endif
+ if(value == 0) {
+ value = "";
+ }
+
+ for(strln = 0; strln < max && value[strln]; ++strln); /* strlen */
+ padlen = min - strln;
+ if(padlen < 0)
+ padlen = 0;
+ if(flags & DP_F_MINUS)
+ padlen = -padlen; /* Left Justify */
+
+ while(padlen > 0) {
+ dopr_outch(buffer, currlen, maxlen, ' ');
+ --padlen;
+ }
+ while(*value && (cnt < max)) {
+ dopr_outch(buffer, currlen, maxlen, *value++);
+ ++cnt;
+ }
+ while(padlen < 0) {
+ dopr_outch(buffer, currlen, maxlen, ' ');
+ ++padlen;
+ }
+ }
+
+/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */
+
+static void fmtint(char *buffer, size_t *currlen, size_t maxlen,
+ long value, int base, int min, int max, int flags) {
+ int signvalue = 0;
+ unsigned long uvalue;
+ char convert[20];
+ int place = 0;
+ int spadlen = 0; /* amount to space pad */
+ int zpadlen = 0; /* amount to zero pad */
+ int caps = 0;
+
+ if(max < 0)
+ max = 0;
+
+ uvalue = value;
+
+ if(!(flags & DP_F_UNSIGNED)) {
+ if(value < 0) {
+ signvalue = '-';
+ uvalue = -value;
+ }
+ else {
+ if(flags & DP_F_PLUS) /* Do a sign (+/i) */
+ signvalue = '+';
+ else if(flags & DP_F_SPACE)
+ signvalue = ' ';
+ }
+ }
+
+ if(flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
+
+ do {
+ convert[place++] =
+ (caps ? "0123456789ABCDEF" : "0123456789abcdef")
+ [uvalue % (unsigned)base ];
+ uvalue = (uvalue / (unsigned)base);
+ }
+ while(uvalue && (place < 20));
+ if(place == 20) place--;
+ convert[place] = 0;
+
+ zpadlen = max - place;
+ spadlen = min - MAX(max, place) - (signvalue ? 1 : 0);
+ if(zpadlen < 0) zpadlen = 0;
+ if(spadlen < 0) spadlen = 0;
+ if(flags & DP_F_ZERO) {
+ zpadlen = MAX(zpadlen, spadlen);
+ spadlen = 0;
+ }
+ if(flags & DP_F_MINUS)
+ spadlen = -spadlen; /* Left Justifty */
+
+#ifdef DEBUG_SNPRINTF
+ printf("zpad: %d, spad: %d, min: %d, max: %d, place: %d\n",
+ zpadlen, spadlen, min, max, place);
+#endif
+
+ /* Spaces */
+ while(spadlen > 0) {
+ dopr_outch(buffer, currlen, maxlen, ' ');
+ --spadlen;
+ }
+
+ /* Sign */
+ if(signvalue)
+ dopr_outch(buffer, currlen, maxlen, signvalue);
+
+ /* Zeros */
+ if(zpadlen > 0) {
+ while(zpadlen > 0) {
+ dopr_outch(buffer, currlen, maxlen, '0');
+ --zpadlen;
+ }
+ }
+
+ /* Digits */
+ while(place > 0)
+ dopr_outch(buffer, currlen, maxlen, convert[--place]);
+
+ /* Left Justified spaces */
+ while(spadlen < 0) {
+ dopr_outch(buffer, currlen, maxlen, ' ');
+ ++spadlen;
+ }
+ }
+
+static LDOUBLE abs_val(LDOUBLE value) {
+ LDOUBLE result = value;
+
+ if(value < 0)
+ result = -value;
+
+ return result;
+ }
+
+static LDOUBLE POW10(int exp) {
+ LDOUBLE result = 1;
+
+ while(exp) {
+ result *= 10;
+ exp--;
+ }
+
+ return result;
+ }
+
+static LLONG ROUND(LDOUBLE value) {
+ LLONG intpart;
+
+ intpart = (LLONG)value;
+ value = value - intpart;
+ if(value >= 0.5) intpart++;
+
+ return intpart;
+ }
+
+/* a replacement for modf that doesn't need the math library. Should
+ be portable, but slow */
+static double my_modf(double x0, double *iptr) {
+ int i;
+ long l;
+ double x = x0;
+ double f = 1.0;
+
+ for(i = 0; i < 100; i++) {
+ l = (long)x;
+ if(l <= (x + 1) && l >= (x - 1)) break;
+ x *= 0.1;
+ f *= 10.0;
+ }
+
+ if(i == 100) {
+ /* yikes! the number is beyond what we can handle. What do we do? */
+ (*iptr) = 0;
+ return 0;
+ }
+
+ if(i != 0) {
+ double i2;
+ double ret;
+
+ ret = my_modf(x0 - l * f, &i2);
+ (*iptr) = l * f + i2;
+ return ret;
+ }
+
+ (*iptr) = l;
+ return x - (*iptr);
+ }
+
+
+static void fmtfp(char *buffer, size_t *currlen, size_t maxlen,
+ LDOUBLE fvalue, int min, int max, int flags) {
+ int signvalue = 0;
+ double ufvalue;
+ char iconvert[311];
+ char fconvert[311];
+ int iplace = 0;
+ int fplace = 0;
+ int padlen = 0; /* amount to pad */
+ int zpadlen = 0;
+ int caps = 0;
+ int idx;
+ double intpart;
+ double fracpart;
+ double temp;
+
+ /*
+ * AIX manpage says the default is 0, but Solaris says the default
+ * is 6, and sprintf on AIX defaults to 6
+ */
+ if(max < 0)
+ max = 6;
+
+ ufvalue = abs_val(fvalue);
+
+ if(fvalue < 0) {
+ signvalue = '-';
+ }
+ else {
+ if(flags & DP_F_PLUS) { /* Do a sign (+/i) */
+ signvalue = '+';
+ }
+ else {
+ if(flags & DP_F_SPACE)
+ signvalue = ' ';
+ }
+ }
+
+#if 0
+ if(flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
+#endif
+
+#if 0
+ if(max == 0) ufvalue += 0.5; /* if max = 0 we must round */
+#endif
+
+ /*
+ * Sorry, we only support 9 digits past the decimal because of our
+ * conversion method
+ */
+ if(max > 9)
+ max = 9;
+
+ /* We "cheat" by converting the fractional part to integer by
+ * multiplying by a factor of 10
+ */
+
+ temp = ufvalue;
+ my_modf(temp, &intpart);
+
+ fracpart = ROUND((POW10(max)) * (ufvalue - intpart));
+
+ if(fracpart >= POW10(max)) {
+ intpart++;
+ fracpart -= POW10(max);
+ }
+
+
+ /* Convert integer part */
+ do {
+ temp = intpart * 0.1;
+ my_modf(temp, &intpart);
+ idx = (int)((temp - intpart + 0.05) * 10.0);
+ /* idx = (int) (((double)(temp*0.1) -intpart +0.05) *10.0); */
+ /* printf ("%llf, %f, %x\n", temp, intpart, idx); */
+ iconvert[iplace++] =
+ (caps ? "0123456789ABCDEF" : "0123456789abcdef")[idx];
+ }
+ while(intpart && (iplace < 311));
+ if(iplace == 311) iplace--;
+ iconvert[iplace] = 0;
+
+ /* Convert fractional part */
+ if(fracpart) {
+ do {
+ temp = fracpart * 0.1;
+ my_modf(temp, &fracpart);
+ idx = (int)((temp - fracpart + 0.05) * 10.0);
+ /* idx = (int) ((((temp/10) -fracpart) +0.05) *10); */
+ /* printf ("%lf, %lf, %ld\n", temp, fracpart, idx ); */
+ fconvert[fplace++] =
+ (caps ? "0123456789ABCDEF" : "0123456789abcdef")[idx];
+ }
+ while(fracpart && (fplace < 311));
+ if(fplace == 311) fplace--;
+ }
+ fconvert[fplace] = 0;
+
+ /* -1 for decimal point, another -1 if we are printing a sign */
+ padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
+ zpadlen = max - fplace;
+ if(zpadlen < 0) zpadlen = 0;
+ if(padlen < 0)
+ padlen = 0;
+ if(flags & DP_F_MINUS)
+ padlen = -padlen; /* Left Justifty */
+
+ if((flags & DP_F_ZERO) && (padlen > 0)) {
+ if(signvalue) {
+ dopr_outch(buffer, currlen, maxlen, signvalue);
+ --padlen;
+ signvalue = 0;
+ }
+ while(padlen > 0) {
+ dopr_outch(buffer, currlen, maxlen, '0');
+ --padlen;
+ }
+ }
+ while(padlen > 0) {
+ dopr_outch(buffer, currlen, maxlen, ' ');
+ --padlen;
+ }
+ if(signvalue)
+ dopr_outch(buffer, currlen, maxlen, signvalue);
+
+ while(iplace > 0)
+ dopr_outch(buffer, currlen, maxlen, iconvert[--iplace]);
+
+#ifdef DEBUG_SNPRINTF
+ printf("fmtfp: fplace=%d zpadlen=%d\n", fplace, zpadlen);
+#endif
+
+ /*
+ * Decimal point. This should probably use locale to find the correct
+ * char to print out.
+ */
+ if(max > 0) {
+ dopr_outch(buffer, currlen, maxlen, '.');
+
+ while(zpadlen > 0) {
+ dopr_outch(buffer, currlen, maxlen, '0');
+ --zpadlen;
+ }
+
+ while(fplace > 0)
+ dopr_outch(buffer, currlen, maxlen, fconvert[--fplace]);
+ }
+
+ while(padlen < 0) {
+ dopr_outch(buffer, currlen, maxlen, ' ');
+ ++padlen;
+ }
+ }
+
+static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) {
+ if(*currlen < maxlen) {
+ buffer[(*currlen)] = c;
+ }
+ (*currlen)++;
+ }
+
+static struct pr_chunk *new_chunk(void) {
+ struct pr_chunk *new_c = (struct pr_chunk *)malloc(sizeof(struct pr_chunk));
+
+ if(!new_c)
+ return NULL;
+
+ new_c->type = 0;
+ new_c->num = 0;
+ new_c->min = 0;
+ new_c->min_star = NULL;
+ new_c->max = -1;
+ new_c->max_star = NULL;
+ new_c->flags = 0;
+ new_c->cflags = 0;
+ new_c->start = 0;
+ new_c->len = 0;
+ new_c->value = 0;
+ new_c->fvalue = 0;
+ new_c->strvalue = NULL;
+ new_c->pnum = NULL;
+ new_c->next = NULL;
+
+ return new_c;
+ }
+
+static int add_cnk_list_entry(struct pr_chunk_x **list,
+ int max_num, struct pr_chunk *chunk) {
+ struct pr_chunk_x *l;
+ struct pr_chunk **c;
+ int max;
+ int cnum;
+ int i, pos;
+
+ if(chunk->num > max_num) {
+ max = chunk->num;
+
+ if(*list == NULL) {
+ l = (struct pr_chunk_x *)malloc(sizeof(struct pr_chunk_x) * max);
+ pos = 0;
+ }
+ else {
+ l = (struct pr_chunk_x *)realloc(*list, sizeof(struct pr_chunk_x) * max);
+ pos = max_num;
+ }
+ if(l == NULL) {
+ for(i = 0; i < max; i++) {
+ if((*list)[i].chunks) free((*list)[i].chunks);
+ }
+ return 0;
+ }
+ for(i = pos; i < max; i++) {
+ l[i].chunks = NULL;
+ l[i].num = 0;
+ }
+ }
+ else {
+ l = *list;
+ max = max_num;
+ }
+
+ i = chunk->num - 1;
+ cnum = l[i].num + 1;
+ if(l[i].chunks == NULL) {
+ c = (struct pr_chunk **)malloc(sizeof(struct pr_chunk *) * cnum);
+ }
+ else {
+ c = (struct pr_chunk **)realloc(l[i].chunks, sizeof(struct pr_chunk *) * cnum);
+ }
+ if(c == NULL) {
+ for(i = 0; i < max; i++) {
+ if(l[i].chunks) free(l[i].chunks);
+ }
+ return 0;
+ }
+ c[l[i].num] = chunk;
+ l[i].chunks = c;
+ l[i].num = cnum;
+
+ *list = l;
+ return max;
+ }
+
+int smb_vsnprintf(char *str, size_t count, const char *fmt, va_list args) {
+ return dopr(str, count, fmt, args);
+ }
+#define vsnprintf smb_vsnprintf
+#endif
+
+/* yes this really must be a ||. Don't muck with this (tridge)
+ *
+ * The logic for these two is that we need our own definition if the
+ * OS *either* has no definition of *sprintf, or if it does have one
+ * that doesn't work properly according to the autoconf test.
+ */
+#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
+int smb_snprintf(char *str, size_t count, const char *fmt, ...) {
+ size_t ret;
+ va_list ap;
+
+ va_start(ap, fmt);
+ ret = vsnprintf(str, count, fmt, ap);
+ va_end(ap);
+ return ret;
+ }
+#define snprintf smb_snprintf
+#endif
+
+#endif
+
+#ifndef HAVE_VASPRINTF
+int vasprintf(char **ptr, const char *format, va_list ap) {
+ int ret;
+ va_list ap2;
+
+ VA_COPY(ap2, ap);
+
+ ret = vsnprintf(NULL, 0, format, ap2);
+ if(ret <= 0) return ret;
+
+ (*ptr) = (char *)malloc(ret + 1);
+ if(!*ptr) return -1;
+
+ VA_COPY(ap2, ap);
+
+ ret = vsnprintf(*ptr, ret + 1, format, ap2);
+
+ return ret;
+ }
+#endif
+
+
+#ifndef HAVE_ASPRINTF
+int asprintf(char **ptr, const char *format, ...) {
+ va_list ap;
+ int ret;
+
+ *ptr = NULL;
+ va_start(ap, format);
+ ret = vasprintf(ptr, format, ap);
+ va_end(ap);
+
+ return ret;
+ }
+#endif
+
+#ifdef TEST_SNPRINTF
+
+int sprintf(char *str, const char *fmt, ...);
+
+int main(void) {
+ char buf1[1024];
+ char buf2[1024];
+ char *buf3;
+ char *fp_fmt[] = {
+ "%1.1f",
+ "%-1.5f",
+ "%1.5f",
+ "%123.9f",
+ "%10.5f",
+ "% 10.5f",
+ "%+22.9f",
+ "%+4.9f",
+ "%01.3f",
+ "%4f",
+ "%3.1f",
+ "%3.2f",
+ "%.0f",
+ "%f",
+ "%-8.8f",
+ "%-9.9f",
+ NULL
+ };
+ double fp_nums[] = { 6442452944.1234, -1.5, 134.21, 91340.2, 341.1234, 203.9, 0.96, 0.996,
+ 0.9996, 1.996, 4.136, 5.030201, 0.00205,
+ /* END LIST */ 0
+ };
+ char *int_fmt[] = {
+ "%-1.5d",
+ "%1.5d",
+ "%123.9d",
+ "%5.5d",
+ "%10.5d",
+ "% 10.5d",
+ "%+22.33d",
+ "%01.3d",
+ "%4d",
+ "%d",
+ NULL
+ };
+ long int_nums[] = { -1, 134, 91340, 341, 0203, 0, 1234567890};
+ char *str_fmt[] = {
+ "%10.5s",
+ "%-10.5s",
+ "%5.10s",
+ "%-5.10s",
+ "%10.1s",
+ "%0.10s",
+ "%10.0s",
+ "%1.10s",
+ "%s",
+ "%.1s",
+ "%.10s",
+ "%10s",
+ NULL
+ };
+ char *str_vals[] = {"hello", "a", "", "a longer string", NULL};
+ int x, y;
+ int fail = 0;
+ int num = 0;
+ int l1, l2;
+
+ printf("Testing snprintf format codes against system sprintf...\n");
+
+ for(x = 0; fp_fmt[x] ; x++) {
+ for(y = 0; fp_nums[y] != 0 ; y++) {
+ buf1[0] = buf2[0] = '\0';
+ l1 = snprintf(NULL, 0, fp_fmt[x], fp_nums[y]);
+ l2 = snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]);
+ sprintf(buf2, fp_fmt[x], fp_nums[y]);
+ buf1[1023] = buf1[1023] = '\0';
+ if(strcmp(buf1, buf2) || (l1 != l2)) {
+ printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n",
+ fp_fmt[x], l1, buf1, l2, buf2);
+ fail++;
+ }
+ num++;
+ }
+ }
+
+ for(x = 0; int_fmt[x] ; x++) {
+ for(y = 0; int_nums[y] != 0 ; y++) {
+ buf1[0] = buf2[0] = '\0';
+ l1 = snprintf(NULL, 0, int_fmt[x], int_nums[y]);
+ l2 = snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]);
+ sprintf(buf2, int_fmt[x], int_nums[y]);
+ buf1[1023] = buf1[1023] = '\0';
+ if(strcmp(buf1, buf2) || (l1 != l2)) {
+ printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n",
+ int_fmt[x], l1, buf1, l2, buf2);
+ fail++;
+ }
+ num++;
+ }
+ }
+
+ for(x = 0; str_fmt[x] ; x++) {
+ for(y = 0; str_vals[y] != 0 ; y++) {
+ buf1[0] = buf2[0] = '\0';
+ l1 = snprintf(NULL, 0, str_fmt[x], str_vals[y]);
+ l2 = snprintf(buf1, sizeof(buf1), str_fmt[x], str_vals[y]);
+ sprintf(buf2, str_fmt[x], str_vals[y]);
+ buf1[1023] = buf1[1023] = '\0';
+ if(strcmp(buf1, buf2) || (l1 != l2)) {
+ printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n",
+ str_fmt[x], l1, buf1, l2, buf2);
+ fail++;
+ }
+ num++;
+ }
+ }
+
+#define BUFSZ 2048
+
+ buf1[0] = buf2[0] = '\0';
+ if((buf3 = malloc(BUFSZ)) == NULL) {
+ fail++;
+ }
+ else {
+ num++;
+ memset(buf3, 'a', BUFSZ);
+ snprintf(buf1, sizeof(buf1), "%.*s", 1, buf3);
+ buf1[1023] = '\0';
+ if(strcmp(buf1, "a") != 0) {
+ printf("length limit buf1 '%s' expected 'a'\n", buf1);
+ fail++;
+ }
+ }
+
+ buf1[0] = buf2[0] = '\0';
+ l1 = snprintf(buf1, sizeof(buf1), "%4$*1$d %2$s %3$*1$.*1$f", 3, "pos test", 12.3456, 9);
+ l2 = sprintf(buf2, "%4$*1$d %2$s %3$*1$.*1$f", 3, "pos test", 12.3456, 9);
+ buf1[1023] = buf1[1023] = '\0';
+ if(strcmp(buf1, buf2) || (l1 != l2)) {
+ printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n",
+ "%4$*1$d %2$s %3$*1$.*1$f", l1, buf1, l2, buf2);
+ fail++;
+ }
+
+ buf1[0] = buf2[0] = '\0';
+ l1 = snprintf(buf1, sizeof(buf1), "%4$*4$d %2$s %3$*4$.*4$f", 3, "pos test", 12.3456, 9);
+ l2 = sprintf(buf2, "%4$*4$d %2$s %3$*4$.*4$f", 3, "pos test", 12.3456, 9);
+ buf1[1023] = buf1[1023] = '\0';
+ if(strcmp(buf1, buf2)) {
+ printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n",
+ "%4$*1$d %2$s %3$*1$.*1$f", l1, buf1, l2, buf2);
+ fail++;
+ }
+#if 0
+ buf1[0] = buf2[0] = '\0';
+ l1 = snprintf(buf1, sizeof(buf1), "%lld", (LLONG)1234567890);
+ l2 = sprintf(buf2, "%lld", (LLONG)1234567890);
+ buf1[1023] = buf1[1023] = '\0';
+ if(strcmp(buf1, buf2)) {
+ printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n",
+ "%lld", l1, buf1, l2, buf2);
+ fail++;
+ }
+
+ buf1[0] = buf2[0] = '\0';
+ l1 = snprintf(buf1, sizeof(buf1), "%Lf", (LDOUBLE)890.1234567890123);
+ l2 = sprintf(buf2, "%Lf", (LDOUBLE)890.1234567890123);
+ buf1[1023] = buf1[1023] = '\0';
+ if(strcmp(buf1, buf2)) {
+ printf("snprintf doesn't match Format: %s\n\tsnprintf(%d) = [%s]\n\t sprintf(%d) = [%s]\n",
+ "%Lf", l1, buf1, l2, buf2);
+ fail++;
+ }
+#endif
+ printf("%d tests failed out of %d.\n", fail, num);
+
+ printf("seeing how many digits we support\n");
+ {
+ double v0 = 0.12345678901234567890123456789012345678901;
+ for(x = 0; x < 100; x++) {
+ double p = pow(10, x);
+ double r = v0 * p;
+ snprintf(buf1, sizeof(buf1), "%1.1f", r);
+ sprintf(buf2, "%1.1f", r);
+ if(strcmp(buf1, buf2)) {
+ printf("we seem to support %d digits\n", x - 1);
+ break;
+ }
+ }
+ }
+
+ return 0;
+ }
+#endif /* TEST_SNPRINTF */
diff --git a/common/statusdata.c b/common/statusdata.c
new file mode 100644
index 0000000..87e2c7c
--- /dev/null
+++ b/common/statusdata.c
@@ -0,0 +1,575 @@
+/*****************************************************************************
+ *
+ * STATUSDATA.C - External status data for Nagios CGIs
+ *
+ * Copyright (c) 2000-2006 Ethan Galstad (egalstad@nagios.org)
+ * Last Modified: 10-19-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/objects.h"
+#include "../include/statusdata.h"
+
+#ifdef NSCORE
+#include "../include/nagios.h"
+#include "../include/broker.h"
+#endif
+#ifdef NSCGI
+#include "../include/cgiutils.h"
+#endif
+
+/**** IMPLEMENTATION SPECIFIC HEADER FILES ****/
+
+#ifdef USE_XSDDEFAULT
+#include "../xdata/xsddefault.h" /* default routines */
+#endif
+
+
+#ifdef NSCORE
+extern int aggregate_status_updates;
+#endif
+
+#ifdef NSCGI
+hoststatus *hoststatus_list = NULL;
+hoststatus *hoststatus_list_tail = NULL;
+servicestatus *servicestatus_list = NULL;
+servicestatus *servicestatus_list_tail = NULL;
+
+hoststatus **hoststatus_hashlist = NULL;
+servicestatus **servicestatus_hashlist = NULL;
+
+extern int use_pending_states;
+#endif
+
+
+
+#ifdef NSCORE
+
+/******************************************************************/
+/****************** TOP-LEVEL OUTPUT FUNCTIONS ********************/
+/******************************************************************/
+
+/* initializes status data at program start */
+int initialize_status_data(char *config_file) {
+ int result = OK;
+
+ /**** IMPLEMENTATION-SPECIFIC CALLS ****/
+#ifdef USE_XSDDEFAULT
+ result = xsddefault_initialize_status_data(config_file);
+#endif
+
+ return result;
+ }
+
+
+/* update all status data (aggregated dump) */
+int update_all_status_data(void) {
+ int result = OK;
+
+#ifdef USE_EVENT_BROKER
+ /* send data to event broker */
+ broker_aggregated_status_data(NEBTYPE_AGGREGATEDSTATUS_STARTDUMP, NEBFLAG_NONE, NEBATTR_NONE, NULL);
+#endif
+
+ /**** IMPLEMENTATION-SPECIFIC CALLS ****/
+#ifdef USE_XSDDEFAULT
+ result = xsddefault_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);
+#endif
+
+ if(result != OK)
+ return ERROR;
+
+ return OK;
+ }
+
+
+/* cleans up status data before program termination */
+int cleanup_status_data(char *config_file, int delete_status_data) {
+ int result = OK;
+
+ /**** IMPLEMENTATION-SPECIFIC CALLS ****/
+#ifdef USE_XSDDEFAULT
+ result = xsddefault_cleanup_status_data(config_file, delete_status_data);
+#endif
+
+ return result;
+ }
+
+
+
+/* updates program status info */
+int update_program_status(int aggregated_dump) {
+
+#ifdef USE_EVENT_BROKER
+ /* send data to event broker (non-aggregated dumps only) */
+ if(aggregated_dump == FALSE)
+ broker_program_status(NEBTYPE_PROGRAMSTATUS_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, NULL);
+#endif
+
+ /* currently a noop if aggregated updates is TRUE */
+
+ /* update all status data if we're not aggregating updates */
+ if(aggregate_status_updates == FALSE)
+ update_all_status_data();
+
+ return OK;
+ }
+
+
+
+/* updates host status info */
+int update_host_status(host *hst, int aggregated_dump) {
+
+#ifdef USE_EVENT_BROKER
+ /* send data to event broker (non-aggregated dumps only) */
+ if(aggregated_dump == FALSE)
+ broker_host_status(NEBTYPE_HOSTSTATUS_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, hst, NULL);
+#endif
+
+ /* currently a noop if aggregated updates is TRUE */
+
+ /* update all status data if we're not aggregating updates */
+ if(aggregate_status_updates == FALSE)
+ update_all_status_data();
+
+ return OK;
+ }
+
+
+
+/* updates service status info */
+int update_service_status(service *svc, int aggregated_dump) {
+
+#ifdef USE_EVENT_BROKER
+ /* send data to event broker (non-aggregated dumps only) */
+ if(aggregated_dump == FALSE)
+ broker_service_status(NEBTYPE_SERVICESTATUS_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, svc, NULL);
+#endif
+
+ /* currently a noop if aggregated updates is TRUE */
+
+ /* update all status data if we're not aggregating updates */
+ if(aggregate_status_updates == FALSE)
+ update_all_status_data();
+
+ return OK;
+ }
+
+
+
+/* updates contact status info */
+int update_contact_status(contact *cntct, int aggregated_dump) {
+
+#ifdef USE_EVENT_BROKER
+ /* send data to event broker (non-aggregated dumps only) */
+ if(aggregated_dump == FALSE)
+ broker_contact_status(NEBTYPE_CONTACTSTATUS_UPDATE, NEBFLAG_NONE, NEBATTR_NONE, cntct, NULL);
+#endif
+
+ /* currently a noop if aggregated updates is TRUE */
+
+ /* update all status data if we're not aggregating updates */
+ if(aggregate_status_updates == FALSE)
+ update_all_status_data();
+
+ return OK;
+ }
+#endif
+
+
+
+
+
+#ifdef NSCGI
+
+/******************************************************************/
+/******************* TOP-LEVEL INPUT FUNCTIONS ********************/
+/******************************************************************/
+
+
+/* reads in all status data */
+int read_status_data(char *config_file, int options) {
+ int result = OK;
+
+ /**** IMPLEMENTATION-SPECIFIC CALLS ****/
+#ifdef USE_XSDDEFAULT
+ result = xsddefault_read_status_data(config_file, options);
+#endif
+#ifdef USE_XSDDB
+ result = xsddb_read_status_data(config_file, options);
+#endif
+
+ return result;
+ }
+
+
+
+/******************************************************************/
+/****************** CHAINED HASH FUNCTIONS ************************/
+/******************************************************************/
+
+/* adds hoststatus to hash list in memory */
+int add_hoststatus_to_hashlist(hoststatus *new_hoststatus) {
+ hoststatus *temp_hoststatus = NULL;
+ hoststatus *lastpointer = NULL;
+ int hashslot = 0;
+ int i = 0;
+
+ /* initialize hash list */
+ if(hoststatus_hashlist == NULL) {
+
+ hoststatus_hashlist = (hoststatus **)malloc(sizeof(hoststatus *) * HOSTSTATUS_HASHSLOTS);
+ if(hoststatus_hashlist == NULL)
+ return 0;
+
+ for(i = 0; i < HOSTSTATUS_HASHSLOTS; i++)
+ hoststatus_hashlist[i] = NULL;
+ }
+
+ if(!new_hoststatus)
+ return 0;
+
+ hashslot = hashfunc(new_hoststatus->host_name, NULL, HOSTSTATUS_HASHSLOTS);
+ lastpointer = NULL;
+ for(temp_hoststatus = hoststatus_hashlist[hashslot]; temp_hoststatus && compare_hashdata(temp_hoststatus->host_name, NULL, new_hoststatus->host_name, NULL) < 0; temp_hoststatus = temp_hoststatus->nexthash)
+ lastpointer = temp_hoststatus;
+
+ if(!temp_hoststatus || (compare_hashdata(temp_hoststatus->host_name, NULL, new_hoststatus->host_name, NULL) != 0)) {
+ if(lastpointer)
+ lastpointer->nexthash = new_hoststatus;
+ else
+ hoststatus_hashlist[hashslot] = new_hoststatus;
+ new_hoststatus->nexthash = temp_hoststatus;
+
+ return 1;
+ }
+
+ /* else already exists */
+ return 0;
+ }
+
+
+int add_servicestatus_to_hashlist(servicestatus *new_servicestatus) {
+ servicestatus *temp_servicestatus = NULL, *lastpointer = NULL;
+ int hashslot = 0;
+ int i = 0;
+
+ /* initialize hash list */
+ if(servicestatus_hashlist == NULL) {
+
+ servicestatus_hashlist = (servicestatus **)malloc(sizeof(servicestatus *) * SERVICESTATUS_HASHSLOTS);
+ if(servicestatus_hashlist == NULL)
+ return 0;
+
+ for(i = 0; i < SERVICESTATUS_HASHSLOTS; i++)
+ servicestatus_hashlist[i] = NULL;
+ }
+
+ if(!new_servicestatus)
+ return 0;
+
+ hashslot = hashfunc(new_servicestatus->host_name, new_servicestatus->description, SERVICESTATUS_HASHSLOTS);
+ lastpointer = NULL;
+ for(temp_servicestatus = servicestatus_hashlist[hashslot]; temp_servicestatus && compare_hashdata(temp_servicestatus->host_name, temp_servicestatus->description, new_servicestatus->host_name, new_servicestatus->description) < 0; temp_servicestatus = temp_servicestatus->nexthash)
+ lastpointer = temp_servicestatus;
+
+ if(!temp_servicestatus || (compare_hashdata(temp_servicestatus->host_name, temp_servicestatus->description, new_servicestatus->host_name, new_servicestatus->description) != 0)) {
+ if(lastpointer)
+ lastpointer->nexthash = new_servicestatus;
+ else
+ servicestatus_hashlist[hashslot] = new_servicestatus;
+ new_servicestatus->nexthash = temp_servicestatus;
+
+
+ return 1;
+ }
+
+ /* else already exists */
+ return 0;
+ }
+
+
+
+/******************************************************************/
+/********************** ADDITION FUNCTIONS ************************/
+/******************************************************************/
+
+
+/* adds a host status entry to the list in memory */
+int add_host_status(hoststatus *new_hoststatus) {
+ char date_string[MAX_DATETIME_LENGTH];
+
+ /* make sure we have what we need */
+ if(new_hoststatus == NULL)
+ return ERROR;
+ if(new_hoststatus->host_name == NULL)
+ return ERROR;
+
+ /* massage host status a bit */
+ if(new_hoststatus != NULL) {
+ switch(new_hoststatus->status) {
+ case 0:
+ new_hoststatus->status = HOST_UP;
+ break;
+ case 1:
+ new_hoststatus->status = HOST_DOWN;
+ break;
+ case 2:
+ new_hoststatus->status = HOST_UNREACHABLE;
+ break;
+ default:
+ new_hoststatus->status = HOST_UP;
+ break;
+ }
+ if(new_hoststatus->has_been_checked == FALSE) {
+ if(use_pending_states == TRUE)
+ new_hoststatus->status = HOST_PENDING;
+ my_free(new_hoststatus->plugin_output);
+ if(new_hoststatus->should_be_scheduled == TRUE) {
+ get_time_string(&new_hoststatus->next_check, date_string, sizeof(date_string), LONG_DATE_TIME);
+ asprintf(&new_hoststatus->plugin_output, "Host check scheduled for %s", date_string);
+ }
+ else {
+ /* passive-only hosts that have just been scheduled for a forced check */
+ if(new_hoststatus->checks_enabled == FALSE && new_hoststatus->next_check != (time_t)0L && (new_hoststatus->check_options & CHECK_OPTION_FORCE_EXECUTION)) {
+ get_time_string(&new_hoststatus->next_check, date_string, sizeof(date_string), LONG_DATE_TIME);
+ asprintf(&new_hoststatus->plugin_output, "Forced host check scheduled for %s", date_string);
+ }
+ /* passive-only hosts not scheduled to be checked */
+ else
+ new_hoststatus->plugin_output = (char *)strdup("Host is not scheduled to be checked...");
+ }
+ }
+ }
+
+ new_hoststatus->next = NULL;
+ new_hoststatus->nexthash = NULL;
+
+ /* add new hoststatus to hoststatus chained hash list */
+ if(!add_hoststatus_to_hashlist(new_hoststatus))
+ return ERROR;
+
+ /* object cache file is already sorted, so just add new items to end of list */
+ if(hoststatus_list == NULL) {
+ hoststatus_list = new_hoststatus;
+ hoststatus_list_tail = new_hoststatus;
+ }
+ else {
+ hoststatus_list_tail->next = new_hoststatus;
+ hoststatus_list_tail = new_hoststatus;
+ }
+
+ return OK;
+ }
+
+
+/* adds a service status entry to the list in memory */
+int add_service_status(servicestatus *new_svcstatus) {
+ char date_string[MAX_DATETIME_LENGTH];
+
+ /* make sure we have what we need */
+ if(new_svcstatus == NULL)
+ return ERROR;
+ if(new_svcstatus->host_name == NULL || new_svcstatus->description == NULL)
+ return ERROR;
+
+
+ /* massage service status a bit */
+ if(new_svcstatus != NULL) {
+ switch(new_svcstatus->status) {
+ case 0:
+ new_svcstatus->status = SERVICE_OK;
+ break;
+ case 1:
+ new_svcstatus->status = SERVICE_WARNING;
+ break;
+ case 2:
+ new_svcstatus->status = SERVICE_CRITICAL;
+ break;
+ case 3:
+ new_svcstatus->status = SERVICE_UNKNOWN;
+ break;
+ default:
+ new_svcstatus->status = SERVICE_OK;
+ break;
+ }
+ if(new_svcstatus->has_been_checked == FALSE) {
+ if(use_pending_states == TRUE)
+ new_svcstatus->status = SERVICE_PENDING;
+ my_free(new_svcstatus->plugin_output);
+ if(new_svcstatus->should_be_scheduled == TRUE) {
+ get_time_string(&new_svcstatus->next_check, date_string, sizeof(date_string), LONG_DATE_TIME);
+ asprintf(&new_svcstatus->plugin_output, "Service check scheduled for %s", date_string);
+ }
+ else {
+ /* passive-only services that have just been scheduled for a forced check */
+ if(new_svcstatus->checks_enabled == FALSE && new_svcstatus->next_check != (time_t)0L && (new_svcstatus->check_options & CHECK_OPTION_FORCE_EXECUTION)) {
+ get_time_string(&new_svcstatus->next_check, date_string, sizeof(date_string), LONG_DATE_TIME);
+ asprintf(&new_svcstatus->plugin_output, "Forced service check scheduled for %s", date_string);
+ }
+ /* passive-only services not scheduled to be checked */
+ else
+ new_svcstatus->plugin_output = (char *)strdup("Service is not scheduled to be checked...");
+ }
+ }
+ }
+
+ new_svcstatus->next = NULL;
+ new_svcstatus->nexthash = NULL;
+
+ /* add new servicestatus to servicestatus chained hash list */
+ if(!add_servicestatus_to_hashlist(new_svcstatus))
+ return ERROR;
+
+ /* object cache file is already sorted, so just add new items to end of list */
+ if(servicestatus_list == NULL) {
+ servicestatus_list = new_svcstatus;
+ servicestatus_list_tail = new_svcstatus;
+ }
+ else {
+ servicestatus_list_tail->next = new_svcstatus;
+ servicestatus_list_tail = new_svcstatus;
+ }
+
+ return OK;
+ }
+
+
+
+
+
+/******************************************************************/
+/*********************** CLEANUP FUNCTIONS ************************/
+/******************************************************************/
+
+
+/* free all memory for status data */
+void free_status_data(void) {
+ hoststatus *this_hoststatus = NULL;
+ hoststatus *next_hoststatus = NULL;
+ servicestatus *this_svcstatus = NULL;
+ servicestatus *next_svcstatus = NULL;
+
+ /* free memory for the host status list */
+ for(this_hoststatus = hoststatus_list; this_hoststatus != NULL; this_hoststatus = next_hoststatus) {
+ next_hoststatus = this_hoststatus->next;
+ my_free(this_hoststatus->host_name);
+ my_free(this_hoststatus->plugin_output);
+ my_free(this_hoststatus->long_plugin_output);
+ my_free(this_hoststatus->perf_data);
+ my_free(this_hoststatus);
+ }
+
+ /* free memory for the service status list */
+ for(this_svcstatus = servicestatus_list; this_svcstatus != NULL; this_svcstatus = next_svcstatus) {
+ next_svcstatus = this_svcstatus->next;
+ my_free(this_svcstatus->host_name);
+ my_free(this_svcstatus->description);
+ my_free(this_svcstatus->plugin_output);
+ my_free(this_svcstatus->long_plugin_output);
+ my_free(this_svcstatus->perf_data);
+ my_free(this_svcstatus);
+ }
+
+ /* free hash lists reset list pointers */
+ my_free(hoststatus_hashlist);
+ my_free(servicestatus_hashlist);
+ hoststatus_list = NULL;
+ servicestatus_list = NULL;
+
+ return;
+ }
+
+
+
+
+/******************************************************************/
+/************************ SEARCH FUNCTIONS ************************/
+/******************************************************************/
+
+
+/* find a host status entry */
+hoststatus *find_hoststatus(char *host_name) {
+ hoststatus *temp_hoststatus = NULL;
+
+ if(host_name == NULL || hoststatus_hashlist == NULL)
+ return NULL;
+
+ for(temp_hoststatus = hoststatus_hashlist[hashfunc(host_name, NULL, HOSTSTATUS_HASHSLOTS)]; temp_hoststatus && compare_hashdata(temp_hoststatus->host_name, NULL, host_name, NULL) < 0; temp_hoststatus = temp_hoststatus->nexthash);
+
+ if(temp_hoststatus && (compare_hashdata(temp_hoststatus->host_name, NULL, host_name, NULL) == 0))
+ return temp_hoststatus;
+
+ return NULL;
+ }
+
+
+/* find a service status entry */
+servicestatus *find_servicestatus(char *host_name, char *svc_desc) {
+ servicestatus *temp_servicestatus = NULL;
+
+ if(host_name == NULL || svc_desc == NULL || servicestatus_hashlist == NULL)
+ return NULL;
+
+ for(temp_servicestatus = servicestatus_hashlist[hashfunc(host_name, svc_desc, SERVICESTATUS_HASHSLOTS)]; temp_servicestatus && compare_hashdata(temp_servicestatus->host_name, temp_servicestatus->description, host_name, svc_desc) < 0; temp_servicestatus = temp_servicestatus->nexthash);
+
+ if(temp_servicestatus && (compare_hashdata(temp_servicestatus->host_name, temp_servicestatus->description, host_name, svc_desc) == 0))
+ return temp_servicestatus;
+
+ return NULL;
+ }
+
+
+
+
+/******************************************************************/
+/*********************** UTILITY FUNCTIONS ************************/
+/******************************************************************/
+
+
+/* gets the total number of services of a certain state for a specific host */
+int get_servicestatus_count(char *host_name, int type) {
+ servicestatus *temp_status = NULL;
+ int count = 0;
+
+ if(host_name == NULL)
+ return 0;
+
+ for(temp_status = servicestatus_list; temp_status != NULL; temp_status = temp_status->next) {
+ if(temp_status->status & type) {
+ if(!strcmp(host_name, temp_status->host_name))
+ count++;
+ }
+ }
+
+ return count;
+ }
+
+
+
+#endif
+
diff --git a/config.guess b/config.guess
new file mode 100755
index 0000000..2b03b48
--- /dev/null
+++ b/config.guess
@@ -0,0 +1,1510 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
+# Inc.
+
+timestamp='2006-12-08'
+
+# This file 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.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Originally written by Per Bothner .
+# Please send patches to . Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub. If it succeeds, it prints the system name on stdout, and
+# exits with 0. Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to ."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help" >&2
+ exit 1 ;;
+ * )
+ break ;;
+ esac
+done
+
+if test $# != 0; then
+ echo "$me: too many arguments$help" >&2
+ exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,) echo "int x;" > $dummy.c ;
+ for c in cc gcc c89 c99 ; do
+ if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+ CC_FOR_BUILD="$c"; break ;
+ fi ;
+ done ;
+ if test x"$CC_FOR_BUILD" = x ; then
+ CC_FOR_BUILD=no_compiler_found ;
+ fi
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+ PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ *:NetBSD:*:*)
+ # NetBSD (nbsd) targets should (where applicable) match one or
+ # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
+ # switched to ELF, *-*-netbsd* would select the old
+ # object file format. This provides both forward
+ # compatibility and a consistent mechanism for selecting the
+ # object file format.
+ #
+ # Note: NetBSD doesn't particularly care about the vendor
+ # portion of the name. We always set it to "unknown".
+ sysctl="sysctl -n hw.machine_arch"
+ UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+ /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+ case "${UNAME_MACHINE_ARCH}" in
+ armeb) machine=armeb-unknown ;;
+ arm*) machine=arm-unknown ;;
+ sh3el) machine=shl-unknown ;;
+ sh3eb) machine=sh-unknown ;;
+ sh5el) machine=sh5le-unknown ;;
+ *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+ esac
+ # The Operating System including object format, if it has switched
+ # to ELF recently, or will in the future.
+ case "${UNAME_MACHINE_ARCH}" in
+ arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+ eval $set_cc_for_build
+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep __ELF__ >/dev/null
+ then
+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+ # Return netbsd for either. FIX?
+ os=netbsd
+ else
+ os=netbsdelf
+ fi
+ ;;
+ *)
+ os=netbsd
+ ;;
+ esac
+ # The OS release
+ # Debian GNU/NetBSD machines have a different userland, and
+ # thus, need a distinct triplet. However, they do not need
+ # kernel version information, so it can be replaced with a
+ # suitable tag, in the style of linux-gnu.
+ case "${UNAME_VERSION}" in
+ Debian*)
+ release='-gnu'
+ ;;
+ *)
+ release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ ;;
+ esac
+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+ # contains redundant information, the shorter form:
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ echo "${machine}-${os}${release}"
+ exit ;;
+ *:OpenBSD:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+ echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+ exit ;;
+ *:ekkoBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+ exit ;;
+ *:SolidBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+ exit ;;
+ macppc:MirBSD:*:*)
+ echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ *:MirBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ alpha:OSF1:*:*)
+ case $UNAME_RELEASE in
+ *4.0)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ ;;
+ *5.*)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+ ;;
+ esac
+ # According to Compaq, /usr/sbin/psrinfo has been available on
+ # OSF/1 and Tru64 systems produced since 1995. I hope that
+ # covers most systems running today. This code pipes the CPU
+ # types through head -n 1, so we only detect the type of CPU 0.
+ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+ case "$ALPHA_CPU_TYPE" in
+ "EV4 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "EV4.5 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "LCA4 (21066/21068)")
+ UNAME_MACHINE="alpha" ;;
+ "EV5 (21164)")
+ UNAME_MACHINE="alphaev5" ;;
+ "EV5.6 (21164A)")
+ UNAME_MACHINE="alphaev56" ;;
+ "EV5.6 (21164PC)")
+ UNAME_MACHINE="alphapca56" ;;
+ "EV5.7 (21164PC)")
+ UNAME_MACHINE="alphapca57" ;;
+ "EV6 (21264)")
+ UNAME_MACHINE="alphaev6" ;;
+ "EV6.7 (21264A)")
+ UNAME_MACHINE="alphaev67" ;;
+ "EV6.8CB (21264C)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8AL (21264B)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8CX (21264D)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.9A (21264/EV69A)")
+ UNAME_MACHINE="alphaev69" ;;
+ "EV7 (21364)")
+ UNAME_MACHINE="alphaev7" ;;
+ "EV7.9 (21364A)")
+ UNAME_MACHINE="alphaev79" ;;
+ esac
+ # A Pn.n version is a patched version.
+ # A Vn.n version is a released version.
+ # A Tn.n version is a released field test version.
+ # A Xn.n version is an unreleased experimental baselevel.
+ # 1.2 uses "1.2" for uname -r.
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ exit ;;
+ Alpha\ *:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # Should we change UNAME_MACHINE based on the output of uname instead
+ # of the specific Alpha model?
+ echo alpha-pc-interix
+ exit ;;
+ 21064:Windows_NT:50:3)
+ echo alpha-dec-winnt3.5
+ exit ;;
+ Amiga*:UNIX_System_V:4.0:*)
+ echo m68k-unknown-sysv4
+ exit ;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-amigaos
+ exit ;;
+ *:[Mm]orph[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-morphos
+ exit ;;
+ *:OS/390:*:*)
+ echo i370-ibm-openedition
+ exit ;;
+ *:z/VM:*:*)
+ echo s390-ibm-zvmoe
+ exit ;;
+ *:OS400:*:*)
+ echo powerpc-ibm-os400
+ exit ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ echo arm-acorn-riscix${UNAME_RELEASE}
+ exit ;;
+ arm:riscos:*:*|arm:RISCOS:*:*)
+ echo arm-unknown-riscos
+ exit ;;
+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit ;;
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+ # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+ if test "`(/bin/universe) 2>/dev/null`" = att ; then
+ echo pyramid-pyramid-sysv3
+ else
+ echo pyramid-pyramid-bsd
+ fi
+ exit ;;
+ NILE*:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+ exit ;;
+ DRS?6000:unix:4.0:6*)
+ echo sparc-icl-nx6
+ exit ;;
+ DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+ case `/usr/bin/uname -p` in
+ sparc) echo sparc-icl-nx7; exit ;;
+ esac ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+ echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ i86pc:SunOS:5.*:*)
+ echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:6*:*)
+ # According to config.sub, this is the proper way to canonicalize
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
+ # it's likely to be more like Solaris than SunOS4.
+ echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:*:*)
+ case "`/usr/bin/arch -k`" in
+ Series*|S4*)
+ UNAME_RELEASE=`uname -v`
+ ;;
+ esac
+ # Japanese Language versions have a version number like `4.1.3-JL'.
+ echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+ exit ;;
+ sun3*:SunOS:*:*)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ exit ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+ case "`/bin/arch`" in
+ sun3)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ ;;
+ sun4)
+ echo sparc-sun-sunos${UNAME_RELEASE}
+ ;;
+ esac
+ exit ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos${UNAME_RELEASE}
+ exit ;;
+ # The situation for MiNT is a little confusing. The machine name
+ # can be virtually everything (everything which is not
+ # "atarist" or "atariste" at least should have a processor
+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
+ # to the lowercase version "mint" (or "freemint"). Finally
+ # the system name "TOS" denotes a system which is actually not
+ # MiNT. But MiNT is downward compatible to TOS, so this should
+ # be no problem.
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ echo m68k-milan-mint${UNAME_RELEASE}
+ exit ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ echo m68k-hades-mint${UNAME_RELEASE}
+ exit ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ echo m68k-unknown-mint${UNAME_RELEASE}
+ exit ;;
+ m68k:machten:*:*)
+ echo m68k-apple-machten${UNAME_RELEASE}
+ exit ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten${UNAME_RELEASE}
+ exit ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+ exit ;;
+ RISC*:ULTRIX:*:*)
+ echo mips-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ VAX*:ULTRIX*:*:*)
+ echo vax-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
+ exit ;;
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+ #if defined (host_mips) && defined (MIPSEB)
+ #if defined (SYSTYPE_SYSV)
+ printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_SVR4)
+ printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+ printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+ #endif
+ #endif
+ exit (-1);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c &&
+ dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+ SYSTEM_NAME=`$dummy $dummyarg` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo mips-mips-riscos${UNAME_RELEASE}
+ exit ;;
+ Motorola:PowerMAX_OS:*:*)
+ echo powerpc-motorola-powermax
+ exit ;;
+ Motorola:*:4.3:PL8-*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:Power_UNIX:*:*)
+ echo powerpc-harris-powerunix
+ exit ;;
+ m88k:CX/UX:7*:*)
+ echo m88k-harris-cxux7
+ exit ;;
+ m88k:*:4*:R4*)
+ echo m88k-motorola-sysv4
+ exit ;;
+ m88k:*:3*:R3*)
+ echo m88k-motorola-sysv3
+ exit ;;
+ AViiON:dgux:*:*)
+ # DG/UX returns AViiON for all architectures
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+ then
+ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+ [ ${TARGET_BINARY_INTERFACE}x = x ]
+ then
+ echo m88k-dg-dgux${UNAME_RELEASE}
+ else
+ echo m88k-dg-dguxbcs${UNAME_RELEASE}
+ fi
+ else
+ echo i586-dg-dgux${UNAME_RELEASE}
+ fi
+ exit ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ echo m88k-dolphin-sysv3
+ exit ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ echo m88k-motorola-sysv3
+ exit ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ echo m88k-tektronix-sysv3
+ exit ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ echo m68k-tektronix-bsd
+ exit ;;
+ *:IRIX*:*:*)
+ echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+ exit ;;
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ i*86:AIX:*:*)
+ echo i386-ibm-aix
+ exit ;;
+ ia64:AIX:*:*)
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+ exit ;;
+ *:AIX:2:3)
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include
+
+ main()
+ {
+ if (!__power_pc())
+ exit(1);
+ puts("powerpc-ibm-aix3.2.5");
+ exit(0);
+ }
+EOF
+ if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+ then
+ echo "$SYSTEM_NAME"
+ else
+ echo rs6000-ibm-aix3.2.5
+ fi
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+ echo rs6000-ibm-aix3.2.4
+ else
+ echo rs6000-ibm-aix3.2
+ fi
+ exit ;;
+ *:AIX:*:[45])
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+ IBM_ARCH=rs6000
+ else
+ IBM_ARCH=powerpc
+ fi
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+ exit ;;
+ *:AIX:*:*)
+ echo rs6000-ibm-aix
+ exit ;;
+ ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+ echo romp-ibm-bsd4.4
+ exit ;;
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
+ echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
+ exit ;; # report: romp-ibm BSD 4.3
+ *:BOSX:*:*)
+ echo rs6000-bull-bosx
+ exit ;;
+ DPX/2?00:B.O.S.:*:*)
+ echo m68k-bull-sysv3
+ exit ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ echo m68k-hp-bsd
+ exit ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ echo m68k-hp-bsd4.4
+ exit ;;
+ 9000/[34678]??:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ case "${UNAME_MACHINE}" in
+ 9000/31? ) HP_ARCH=m68000 ;;
+ 9000/[34]?? ) HP_ARCH=m68k ;;
+ 9000/[678][0-9][0-9])
+ if [ -x /usr/bin/getconf ]; then
+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+ case "${sc_cpu_version}" in
+ 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+ 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+ 532) # CPU_PA_RISC2_0
+ case "${sc_kernel_bits}" in
+ 32) HP_ARCH="hppa2.0n" ;;
+ 64) HP_ARCH="hppa2.0w" ;;
+ '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
+ esac ;;
+ esac
+ fi
+ if [ "${HP_ARCH}" = "" ]; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+
+ #define _HPUX_SOURCE
+ #include
+ #include
+
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+ test -z "$HP_ARCH" && HP_ARCH=hppa
+ fi ;;
+ esac
+ if [ ${HP_ARCH} = "hppa2.0w" ]
+ then
+ eval $set_cc_for_build
+
+ # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+ # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
+ # generating 64-bit code. GNU and HP use different nomenclature:
+ #
+ # $ CC_FOR_BUILD=cc ./config.guess
+ # => hppa2.0w-hp-hpux11.23
+ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+ # => hppa64-hp-hpux11.23
+
+ if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+ grep __LP64__ >/dev/null
+ then
+ HP_ARCH="hppa2.0w"
+ else
+ HP_ARCH="hppa64"
+ fi
+ fi
+ echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+ exit ;;
+ ia64:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ia64-hp-hpux${HPUX_REV}
+ exit ;;
+ 3050*:HI-UX:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include
+ int
+ main ()
+ {
+ long cpu = sysconf (_SC_CPU_VERSION);
+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
+ results, however. */
+ if (CPU_IS_PA_RISC (cpu))
+ {
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+ default: puts ("hppa-hitachi-hiuxwe2"); break;
+ }
+ }
+ else if (CPU_IS_HP_MC68K (cpu))
+ puts ("m68k-hitachi-hiuxwe2");
+ else puts ("unknown-hitachi-hiuxwe2");
+ exit (0);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo unknown-hitachi-hiuxwe2
+ exit ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+ echo hppa1.1-hp-bsd
+ exit ;;
+ 9000/8??:4.3bsd:*:*)
+ echo hppa1.0-hp-bsd
+ exit ;;
+ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+ exit ;;
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+ echo hppa1.1-hp-osf
+ exit ;;
+ hp8??:OSF1:*:*)
+ echo hppa1.0-hp-osf
+ exit ;;
+ i*86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo ${UNAME_MACHINE}-unknown-osf1mk
+ else
+ echo ${UNAME_MACHINE}-unknown-osf1
+ fi
+ exit ;;
+ parisc*:Lites*:*:*)
+ echo hppa1.1-hp-lites
+ exit ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ echo c1-convex-bsd
+ exit ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ echo c34-convex-bsd
+ exit ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ echo c38-convex-bsd
+ exit ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ echo c4-convex-bsd
+ exit ;;
+ CRAY*Y-MP:*:*:*)
+ echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*[A-Z]90:*:*:*)
+ echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+ -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*T3E:*:*:*)
+ echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*SV1:*:*:*)
+ echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ *:UNICOS/mp:*:*)
+ echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+ FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ 5000:UNIX_System_V:4.*:*)
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+ echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+ echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+ exit ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:FreeBSD:*:*)
+ case ${UNAME_MACHINE} in
+ pc98)
+ echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ amd64)
+ echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ *)
+ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ esac
+ exit ;;
+ i*:CYGWIN*:*)
+ echo ${UNAME_MACHINE}-pc-cygwin
+ exit ;;
+ i*:MINGW*:*)
+ echo ${UNAME_MACHINE}-pc-mingw32
+ exit ;;
+ i*:windows32*:*)
+ # uname -m includes "-pc" on this system.
+ echo ${UNAME_MACHINE}-mingw32
+ exit ;;
+ i*:PW*:*)
+ echo ${UNAME_MACHINE}-pc-pw32
+ exit ;;
+ x86:Interix*:[3456]*)
+ echo i586-pc-interix${UNAME_RELEASE}
+ exit ;;
+ EM64T:Interix*:[3456]* | authenticamd:Interix*:[3456]*)
+ echo x86_64-unknown-interix${UNAME_RELEASE}
+ exit ;;
+ [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+ echo i${UNAME_MACHINE}-pc-mks
+ exit ;;
+ i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+ # UNAME_MACHINE based on the output of uname instead of i386?
+ echo i586-pc-interix
+ exit ;;
+ i*:UWIN*:*)
+ echo ${UNAME_MACHINE}-pc-uwin
+ exit ;;
+ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+ echo x86_64-unknown-cygwin
+ exit ;;
+ p*:CYGWIN*:*)
+ echo powerpcle-unknown-cygwin
+ exit ;;
+ prep*:SunOS:5.*:*)
+ echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ *:GNU:*:*)
+ # the GNU system
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ exit ;;
+ *:GNU/*:*:*)
+ # other systems with GNU libc and userland
+ echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+ exit ;;
+ i*86:Minix:*:*)
+ echo ${UNAME_MACHINE}-pc-minix
+ exit ;;
+ arm*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ avr32*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ cris:Linux:*:*)
+ echo cris-axis-linux-gnu
+ exit ;;
+ crisv32:Linux:*:*)
+ echo crisv32-axis-linux-gnu
+ exit ;;
+ frv:Linux:*:*)
+ echo frv-unknown-linux-gnu
+ exit ;;
+ ia64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ m32r*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ m68*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ mips:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips
+ #undef mipsel
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mipsel
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^CPU/{
+ s: ::g
+ p
+ }'`"
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+ ;;
+ mips64:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips64
+ #undef mips64el
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mips64el
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips64
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^CPU/{
+ s: ::g
+ p
+ }'`"
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+ ;;
+ or32:Linux:*:*)
+ echo or32-unknown-linux-gnu
+ exit ;;
+ ppc:Linux:*:*)
+ echo powerpc-unknown-linux-gnu
+ exit ;;
+ ppc64:Linux:*:*)
+ echo powerpc64-unknown-linux-gnu
+ exit ;;
+ alpha:Linux:*:*)
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+ EV5) UNAME_MACHINE=alphaev5 ;;
+ EV56) UNAME_MACHINE=alphaev56 ;;
+ PCA56) UNAME_MACHINE=alphapca56 ;;
+ PCA57) UNAME_MACHINE=alphapca56 ;;
+ EV6) UNAME_MACHINE=alphaev6 ;;
+ EV67) UNAME_MACHINE=alphaev67 ;;
+ EV68*) UNAME_MACHINE=alphaev68 ;;
+ esac
+ objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+ if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+ exit ;;
+ parisc:Linux:*:* | hppa:Linux:*:*)
+ # Look for CPU level
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+ PA7*) echo hppa1.1-unknown-linux-gnu ;;
+ PA8*) echo hppa2.0-unknown-linux-gnu ;;
+ *) echo hppa-unknown-linux-gnu ;;
+ esac
+ exit ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ echo hppa64-unknown-linux-gnu
+ exit ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ echo ${UNAME_MACHINE}-ibm-linux
+ exit ;;
+ sh64*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ sh*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ vax:Linux:*:*)
+ echo ${UNAME_MACHINE}-dec-linux-gnu
+ exit ;;
+ x86_64:Linux:*:*)
+ echo x86_64-unknown-linux-gnu
+ exit ;;
+ xtensa:Linux:*:*)
+ echo xtensa-unknown-linux-gnu
+ exit ;;
+ i*86:Linux:*:*)
+ # The BFD linker knows what the default object file format is, so
+ # first see if it will tell us. cd to the root directory to prevent
+ # problems with other programs or directories called `ld' in the path.
+ # Set LC_ALL=C to ensure ld outputs messages in English.
+ ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
+ | sed -ne '/supported targets:/!d
+ s/[ ][ ]*/ /g
+ s/.*supported targets: *//
+ s/ .*//
+ p'`
+ case "$ld_supported_targets" in
+ elf32-i386)
+ TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+ ;;
+ a.out-i386-linux)
+ echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+ exit ;;
+ coff-i386)
+ echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+ exit ;;
+ "")
+ # Either a pre-BFD a.out linker (linux-gnuoldld) or
+ # one that does not give us useful --help.
+ echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+ exit ;;
+ esac
+ # Determine whether the default compiler is a.out or elf
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include
+ #ifdef __ELF__
+ # ifdef __GLIBC__
+ # if __GLIBC__ >= 2
+ LIBC=gnu
+ # else
+ LIBC=gnulibc1
+ # endif
+ # else
+ LIBC=gnulibc1
+ # endif
+ #else
+ #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+ LIBC=gnu
+ #else
+ LIBC=gnuaout
+ #endif
+ #endif
+ #ifdef __dietlibc__
+ LIBC=dietlibc
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^LIBC/{
+ s: ::g
+ p
+ }'`"
+ test x"${LIBC}" != x && {
+ echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+ exit
+ }
+ test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
+ ;;
+ i*86:DYNIX/ptx:4*:*)
+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+ # earlier versions are messed up and put the nodename in both
+ # sysname and nodename.
+ echo i386-sequent-sysv4
+ exit ;;
+ i*86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+ exit ;;
+ i*86:OS/2:*:*)
+ # If we were able to find `uname', then EMX Unix compatibility
+ # is probably installed.
+ echo ${UNAME_MACHINE}-pc-os2-emx
+ exit ;;
+ i*86:XTS-300:*:STOP)
+ echo ${UNAME_MACHINE}-unknown-stop
+ exit ;;
+ i*86:atheos:*:*)
+ echo ${UNAME_MACHINE}-unknown-atheos
+ exit ;;
+ i*86:syllable:*:*)
+ echo ${UNAME_MACHINE}-pc-syllable
+ exit ;;
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ i*86:*DOS:*:*)
+ echo ${UNAME_MACHINE}-pc-msdosdjgpp
+ exit ;;
+ i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+ UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+ echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+ fi
+ exit ;;
+ i*86:*:5:[678]*)
+ # UnixWare 7.x, OpenUNIX and OpenServer 6.
+ case `/bin/uname -X | grep "^Machine"` in
+ *486*) UNAME_MACHINE=i486 ;;
+ *Pentium) UNAME_MACHINE=i586 ;;
+ *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+ esac
+ echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+ exit ;;
+ i*86:*:3.2:*)
+ if test -f /usr/options/cb.name; then
+ UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then
+ UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+ (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
+ echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+ else
+ echo ${UNAME_MACHINE}-pc-sysv32
+ fi
+ exit ;;
+ pc:*:*:*)
+ # Left here for compatibility:
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i386.
+ echo i386-pc-msdosdjgpp
+ exit ;;
+ Intel:Mach:3*:*)
+ echo i386-pc-mach3
+ exit ;;
+ paragon:*:*:*)
+ echo i860-intel-osf1
+ exit ;;
+ i860:*:4.*:*) # i860-SVR4
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+ echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+ else # Add other i860-SVR4 vendors below as they are discovered.
+ echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
+ fi
+ exit ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ echo m68010-convergent-sysv
+ exit ;;
+ mc68k:UNIX:SYSTEM5:3.51m)
+ echo m68k-convergent-sysv
+ exit ;;
+ M680?0:D-NIX:5.3:*)
+ echo m68k-diab-dnix
+ exit ;;
+ M68*:*:R3V[5678]*:*)
+ test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+ OS_REL=''
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4; exit; } ;;
+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+ echo m68k-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ mc68030:UNIX_System_V:4.*:*)
+ echo m68k-atari-sysv4
+ exit ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ rs6000:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+ echo powerpc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv${UNAME_RELEASE}
+ exit ;;
+ RM*:ReliantUNIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ RM*:SINIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ *:SINIX-*:*:*)
+ if uname -p 2>/dev/null >/dev/null ; then
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ echo ${UNAME_MACHINE}-sni-sysv4
+ else
+ echo ns32k-sni-sysv
+ fi
+ exit ;;
+ PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says
+ echo i586-unisys-sysv4
+ exit ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes .
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+ exit ;;
+ *:*:*:FTX*)
+ # From seanf@swdc.stratus.com.
+ echo i860-stratus-sysv4
+ exit ;;
+ i*86:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo ${UNAME_MACHINE}-stratus-vos
+ exit ;;
+ *:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo hppa1.1-stratus-vos
+ exit ;;
+ mc68*:A/UX:*:*)
+ echo m68k-apple-aux${UNAME_RELEASE}
+ exit ;;
+ news*:NEWS-OS:6*:*)
+ echo mips-sony-newsos6
+ exit ;;
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+ if [ -d /usr/nec ]; then
+ echo mips-nec-sysv${UNAME_RELEASE}
+ else
+ echo mips-unknown-sysv${UNAME_RELEASE}
+ fi
+ exit ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+ exit ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+ exit ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+ exit ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-5:SUPER-UX:*:*)
+ echo sx5-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-6:SUPER-UX:*:*)
+ echo sx6-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-7:SUPER-UX:*:*)
+ echo sx7-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-8:SUPER-UX:*:*)
+ echo sx8-nec-superux${UNAME_RELEASE}
+ exit ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Rhapsody:*:*)
+ echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Darwin:*:*)
+ UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+ case $UNAME_PROCESSOR in
+ unknown) UNAME_PROCESSOR=powerpc ;;
+ esac
+ echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+ exit ;;
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
+ UNAME_PROCESSOR=`uname -p`
+ if test "$UNAME_PROCESSOR" = "x86"; then
+ UNAME_PROCESSOR=i386
+ UNAME_MACHINE=pc
+ fi
+ echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+ exit ;;
+ *:QNX:*:4*)
+ echo i386-pc-qnx
+ exit ;;
+ NSE-?:NONSTOP_KERNEL:*:*)
+ echo nse-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ NSR-?:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ *:NonStop-UX:*:*)
+ echo mips-compaq-nonstopux
+ exit ;;
+ BS2000:POSIX*:*:*)
+ echo bs2000-siemens-sysv
+ exit ;;
+ DS/*:UNIX_System_V:*:*)
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+ exit ;;
+ *:Plan9:*:*)
+ # "uname -m" is not consistent, so use $cputype instead. 386
+ # is converted to i386 for consistency with other x86
+ # operating systems.
+ if test "$cputype" = "386"; then
+ UNAME_MACHINE=i386
+ else
+ UNAME_MACHINE="$cputype"
+ fi
+ echo ${UNAME_MACHINE}-unknown-plan9
+ exit ;;
+ *:TOPS-10:*:*)
+ echo pdp10-unknown-tops10
+ exit ;;
+ *:TENEX:*:*)
+ echo pdp10-unknown-tenex
+ exit ;;
+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+ echo pdp10-dec-tops20
+ exit ;;
+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+ echo pdp10-xkl-tops20
+ exit ;;
+ *:TOPS-20:*:*)
+ echo pdp10-unknown-tops20
+ exit ;;
+ *:ITS:*:*)
+ echo pdp10-unknown-its
+ exit ;;
+ SEI:*:*:SEIUX)
+ echo mips-sei-seiux${UNAME_RELEASE}
+ exit ;;
+ *:DragonFly:*:*)
+ echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ exit ;;
+ *:*VMS:*:*)
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ case "${UNAME_MACHINE}" in
+ A*) echo alpha-dec-vms ; exit ;;
+ I*) echo ia64-dec-vms ; exit ;;
+ V*) echo vax-dec-vms ; exit ;;
+ esac ;;
+ *:XENIX:*:SysV)
+ echo i386-pc-xenix
+ exit ;;
+ i*86:skyos:*:*)
+ echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+ exit ;;
+ i*86:rdos:*:*)
+ echo ${UNAME_MACHINE}-pc-rdos
+ exit ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <
+# include
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
+ I don't know.... */
+ printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include
+ printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+ "4"
+#else
+ ""
+#endif
+ ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+ printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+ printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+ int version;
+ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+ if (version < 4)
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ else
+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+ exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+ printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+ printf ("ns32k-encore-mach\n"); exit (0);
+#else
+ printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+ printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+ printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+ printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+ struct utsname un;
+
+ uname(&un);
+
+ if (strncmp(un.version, "V2", 2) == 0) {
+ printf ("i386-sequent-ptx2\n"); exit (0);
+ }
+ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+ printf ("i386-sequent-ptx1\n"); exit (0);
+ }
+ printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+# include
+# if defined (BSD)
+# if BSD == 43
+ printf ("vax-dec-bsd4.3\n"); exit (0);
+# else
+# if BSD == 199006
+ printf ("vax-dec-bsd4.3reno\n"); exit (0);
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# endif
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# else
+ printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+ printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+ exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+ case `getsysinfo -f cpu_type` in
+ c1*)
+ echo c1-convex-bsd
+ exit ;;
+ c2*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ c34*)
+ echo c34-convex-bsd
+ exit ;;
+ c38*)
+ echo c38-convex-bsd
+ exit ;;
+ c4*)
+ echo c4-convex-bsd
+ exit ;;
+ esac
+fi
+
+cat >&2 < in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo = `(hostinfo) 2>/dev/null`
+/bin/universe = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/config.sub b/config.sub
new file mode 100755
index 0000000..4b8cc7b
--- /dev/null
+++ b/config.sub
@@ -0,0 +1,1619 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
+# Inc.
+
+timestamp='2006-12-08'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine. It does not imply ALL GNU software can.
+#
+# This file 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.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Please send patches to . Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support. The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+ $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to ."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help"
+ exit 1 ;;
+
+ *local*)
+ # First pass through any local machine types.
+ echo $1
+ exit ;;
+
+ * )
+ break ;;
+ esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+ exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+ exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+ nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
+ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
+ os=-$maybe_os
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ ;;
+ *)
+ basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+ if [ $basic_machine != $1 ]
+ then os=`echo $1 | sed 's/.*-/-/'`
+ else os=; fi
+ ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work. We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+ -sun*os*)
+ # Prevent following clause from handling this invalid input.
+ ;;
+ -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+ -apple | -axis | -knuth | -cray)
+ os=
+ basic_machine=$1
+ ;;
+ -sim | -cisco | -oki | -wec | -winbond)
+ os=
+ basic_machine=$1
+ ;;
+ -scout)
+ ;;
+ -wrs)
+ os=-vxworks
+ basic_machine=$1
+ ;;
+ -chorusos*)
+ os=-chorusos
+ basic_machine=$1
+ ;;
+ -chorusrdb)
+ os=-chorusrdb
+ basic_machine=$1
+ ;;
+ -hiux*)
+ os=-hiuxwe2
+ ;;
+ -sco6)
+ os=-sco5v6
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5)
+ os=-sco3.2v5
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco4)
+ os=-sco3.2v4
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2.[4-9]*)
+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2v[4-9]*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5v6*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco*)
+ os=-sco3.2v2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -udk*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -isc)
+ os=-isc2.2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -clix*)
+ basic_machine=clipper-intergraph
+ ;;
+ -isc*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -lynx*)
+ os=-lynxos
+ ;;
+ -ptx*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+ ;;
+ -windowsnt*)
+ os=`echo $os | sed -e 's/windowsnt/winnt/'`
+ ;;
+ -psos*)
+ os=-psos
+ ;;
+ -mint | -mint[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+ # Recognize the basic CPU types without company name.
+ # Some are omitted here because they have special meanings below.
+ 1750a | 580 \
+ | a29k \
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+ | am33_2.0 \
+ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+ | bfin \
+ | c4x | clipper \
+ | d10v | d30v | dlx | dsp16xx \
+ | fido | fr30 | frv \
+ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | i370 | i860 | i960 | ia64 \
+ | ip2k | iq2000 \
+ | m32c | m32r | m32rle | m68000 | m68k | m88k \
+ | maxq | mb | microblaze | mcore \
+ | mips | mipsbe | mipseb | mipsel | mipsle \
+ | mips16 \
+ | mips64 | mips64el \
+ | mips64vr | mips64vrel \
+ | mips64orion | mips64orionel \
+ | mips64vr4100 | mips64vr4100el \
+ | mips64vr4300 | mips64vr4300el \
+ | mips64vr5000 | mips64vr5000el \
+ | mips64vr5900 | mips64vr5900el \
+ | mipsisa32 | mipsisa32el \
+ | mipsisa32r2 | mipsisa32r2el \
+ | mipsisa64 | mipsisa64el \
+ | mipsisa64r2 | mipsisa64r2el \
+ | mipsisa64sb1 | mipsisa64sb1el \
+ | mipsisa64sr71k | mipsisa64sr71kel \
+ | mipstx39 | mipstx39el \
+ | mn10200 | mn10300 \
+ | mt \
+ | msp430 \
+ | nios | nios2 \
+ | ns16k | ns32k \
+ | or32 \
+ | pdp10 | pdp11 | pj | pjl \
+ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+ | pyramid \
+ | score \
+ | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+ | sh64 | sh64le \
+ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+ | spu | strongarm \
+ | tahoe | thumb | tic4x | tic80 | tron \
+ | v850 | v850e \
+ | we32k \
+ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+ | z8k)
+ basic_machine=$basic_machine-unknown
+ ;;
+ m6811 | m68hc11 | m6812 | m68hc12)
+ # Motorola 68HC11/12.
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+ ;;
+ ms1)
+ basic_machine=mt-unknown
+ ;;
+
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i*86 | x86_64)
+ basic_machine=$basic_machine-pc
+ ;;
+ # Object if more than one company name word.
+ *-*-*)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+ # Recognize the basic CPU types with company name.
+ 580-* \
+ | a29k-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
+ | avr-* | avr32-* \
+ | bfin-* | bs2000-* \
+ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+ | clipper-* | craynv-* | cydra-* \
+ | d10v-* | d30v-* | dlx-* \
+ | elxsi-* \
+ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+ | h8300-* | h8500-* \
+ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+ | i*86-* | i860-* | i960-* | ia64-* \
+ | ip2k-* | iq2000-* \
+ | m32c-* | m32r-* | m32rle-* \
+ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+ | m88110-* | m88k-* | maxq-* | mcore-* \
+ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+ | mips16-* \
+ | mips64-* | mips64el-* \
+ | mips64vr-* | mips64vrel-* \
+ | mips64orion-* | mips64orionel-* \
+ | mips64vr4100-* | mips64vr4100el-* \
+ | mips64vr4300-* | mips64vr4300el-* \
+ | mips64vr5000-* | mips64vr5000el-* \
+ | mips64vr5900-* | mips64vr5900el-* \
+ | mipsisa32-* | mipsisa32el-* \
+ | mipsisa32r2-* | mipsisa32r2el-* \
+ | mipsisa64-* | mipsisa64el-* \
+ | mipsisa64r2-* | mipsisa64r2el-* \
+ | mipsisa64sb1-* | mipsisa64sb1el-* \
+ | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+ | mipstx39-* | mipstx39el-* \
+ | mmix-* \
+ | mt-* \
+ | msp430-* \
+ | nios-* | nios2-* \
+ | none-* | np1-* | ns16k-* | ns32k-* \
+ | orion-* \
+ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+ | pyramid-* \
+ | romp-* | rs6000-* \
+ | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+ | sparclite-* \
+ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
+ | tahoe-* | thumb-* \
+ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+ | tron-* \
+ | v850-* | v850e-* | vax-* \
+ | we32k-* \
+ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+ | xstormy16-* | xtensa-* \
+ | ymp-* \
+ | z8k-*)
+ ;;
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 386bsd)
+ basic_machine=i386-unknown
+ os=-bsd
+ ;;
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ basic_machine=m68000-att
+ ;;
+ 3b*)
+ basic_machine=we32k-att
+ ;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ abacus)
+ basic_machine=abacus-unknown
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=-scout
+ ;;
+ alliant | fx80)
+ basic_machine=fx80-alliant
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=-bsd
+ ;;
+ amd64)
+ basic_machine=x86_64-pc
+ ;;
+ amd64-*)
+ basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=-sysv
+ ;;
+ amiga | amiga-*)
+ basic_machine=m68k-unknown
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-unknown
+ os=-amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-unknown
+ os=-sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=-sysv
+ ;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=-bsd
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ os=-aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=-dynix
+ ;;
+ c90)
+ basic_machine=c90-cray
+ os=-unicos
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=-bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=-bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=-bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=-bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=-bsd
+ ;;
+ cray | j90)
+ basic_machine=j90-cray
+ os=-unicos
+ ;;
+ craynv)
+ basic_machine=craynv-cray
+ os=-unicosmp
+ ;;
+ cr16c)
+ basic_machine=cr16c-unknown
+ os=-elf
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+ crisv32 | crisv32-* | etraxfs*)
+ basic_machine=crisv32-axis
+ ;;
+ cris | cris-* | etrax*)
+ basic_machine=cris-axis
+ ;;
+ crx)
+ basic_machine=crx-unknown
+ os=-elf
+ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+ decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ ;;
+ decsystem10* | dec10*)
+ basic_machine=pdp10-dec
+ os=-tops10
+ ;;
+ decsystem20* | dec20*)
+ basic_machine=pdp10-dec
+ os=-tops20
+ ;;
+ delta | 3300 | motorola-3300 | motorola-delta \
+ | 3300-motorola | delta-motorola)
+ basic_machine=m68k-motorola
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=-sysv3
+ ;;
+ djgpp)
+ basic_machine=i586-pc
+ os=-msdosdjgpp
+ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
+ ;;
+ dpx2* | dpx2*-bull)
+ basic_machine=m68k-bull
+ os=-sysv3
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=-ebmon
+ ;;
+ elxsi)
+ basic_machine=elxsi-elxsi
+ os=-bsd
+ ;;
+ encore | umax | mmax)
+ basic_machine=ns32k-encore
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=-ose
+ ;;
+ fx2800)
+ basic_machine=i860-alliant
+ ;;
+ genix)
+ basic_machine=ns32k-ns
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=-sysv
+ ;;
+ go32)
+ basic_machine=i386-pc
+ os=-go32
+ ;;
+ h3050r* | hiux*)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=-hms
+ ;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=-xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=-hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=-sysv3
+ ;;
+ hp300-*)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=-bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=-hpux
+ ;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ basic_machine=m68000-hp
+ ;;
+ hp9k3[2-9][0-9])
+ basic_machine=m68k-hp
+ ;;
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hppa-next)
+ os=-nextstep3
+ ;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=-osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=-proelf
+ ;;
+ i370-ibm* | ibm*)
+ basic_machine=i370-ibm
+ ;;
+# I'm not sure what "Sysv32" means. Should this be sysv3.2?
+ i*86v32)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv32
+ ;;
+ i*86v4*)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv4
+ ;;
+ i*86v)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv
+ ;;
+ i*86sol2)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-solaris2
+ ;;
+ i386mach)
+ basic_machine=i386-mach
+ os=-mach
+ ;;
+ i386-vsta | vsta)
+ basic_machine=i386-unknown
+ os=-vsta
+ ;;
+ iris | iris4d)
+ basic_machine=mips-sgi
+ case $os in
+ -irix*)
+ ;;
+ *)
+ os=-irix4
+ ;;
+ esac
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=-sysv
+ ;;
+ m88k-omron*)
+ basic_machine=m88k-omron
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=-sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=-sysv
+ ;;
+ mingw32)
+ basic_machine=i386-pc
+ os=-mingw32
+ ;;
+ miniframe)
+ basic_machine=m68000-convergent
+ ;;
+ *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+ mips3*-*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+ ;;
+ mips3*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ morphos)
+ basic_machine=powerpc-unknown
+ os=-morphos
+ ;;
+ msdos)
+ basic_machine=i386-pc
+ os=-msdos
+ ;;
+ ms1-*)
+ basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=-sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-unknown
+ os=-netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ os=-linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=-newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=-newsos
+ ;;
+ news-3600 | risc-news)
+ basic_machine=mips-sony
+ os=-newsos
+ ;;
+ necv70)
+ basic_machine=v70-nec
+ os=-sysv
+ ;;
+ next | m*-next )
+ basic_machine=m68k-next
+ case $os in
+ -nextstep* )
+ ;;
+ -ns2*)
+ os=-nextstep2
+ ;;
+ *)
+ os=-nextstep3
+ ;;
+ esac
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=-cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=-cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=-nindy
+ ;;
+ mon960)
+ basic_machine=i960-intel
+ os=-mon960
+ ;;
+ nonstopux)
+ basic_machine=mips-compaq
+ os=-nonstopux
+ ;;
+ np1)
+ basic_machine=np1-gould
+ ;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
+ op50n-* | op60c-*)
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ openrisc | openrisc-*)
+ basic_machine=or32-unknown
+ ;;
+ os400)
+ basic_machine=powerpc-ibm
+ os=-os400
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=-ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=-os68k
+ ;;
+ pa-hitachi)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=-osf
+ ;;
+ pbd)
+ basic_machine=sparc-tti
+ ;;
+ pbb)
+ basic_machine=m68k-tti
+ ;;
+ pc532 | pc532-*)
+ basic_machine=ns32k-pc532
+ ;;
+ pc98)
+ basic_machine=i386-pc
+ ;;
+ pc98-*)
+ basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium | p5 | k5 | k6 | nexgen | viac3)
+ basic_machine=i586-pc
+ ;;
+ pentiumpro | p6 | 6x86 | athlon | athlon_*)
+ basic_machine=i686-pc
+ ;;
+ pentiumii | pentium2 | pentiumiii | pentium3)
+ basic_machine=i686-pc
+ ;;
+ pentium4)
+ basic_machine=i786-pc
+ ;;
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+ basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumpro-* | p6-* | 6x86-* | athlon-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium4-*)
+ basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pn)
+ basic_machine=pn-gould
+ ;;
+ power) basic_machine=power-ibm
+ ;;
+ ppc) basic_machine=powerpc-unknown
+ ;;
+ ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppcle | powerpclittle | ppc-le | powerpc-little)
+ basic_machine=powerpcle-unknown
+ ;;
+ ppcle-* | powerpclittle-*)
+ basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64) basic_machine=powerpc64-unknown
+ ;;
+ ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+ basic_machine=powerpc64le-unknown
+ ;;
+ ppc64le-* | powerpc64little-*)
+ basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ps2)
+ basic_machine=i386-ibm
+ ;;
+ pw32)
+ basic_machine=i586-unknown
+ os=-pw32
+ ;;
+ rdos)
+ basic_machine=i386-pc
+ os=-rdos
+ ;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ rm[46]00)
+ basic_machine=mips-siemens
+ ;;
+ rtpc | rtpc-*)
+ basic_machine=romp-ibm
+ ;;
+ s390 | s390-*)
+ basic_machine=s390-ibm
+ ;;
+ s390x | s390x-*)
+ basic_machine=s390x-ibm
+ ;;
+ sa29200)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ sb1)
+ basic_machine=mipsisa64sb1-unknown
+ ;;
+ sb1el)
+ basic_machine=mipsisa64sb1el-unknown
+ ;;
+ sde)
+ basic_machine=mipsisa32-sde
+ os=-elf
+ ;;
+ sei)
+ basic_machine=mips-sei
+ os=-seiux
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ ;;
+ sh)
+ basic_machine=sh-hitachi
+ os=-hms
+ ;;
+ sh5el)
+ basic_machine=sh5le-unknown
+ ;;
+ sh64)
+ basic_machine=sh64-unknown
+ ;;
+ sparclite-wrs | simso-wrs)
+ basic_machine=sparclite-wrs
+ os=-vxworks
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ os=-sysv2
+ ;;
+ spur)
+ basic_machine=spur-unknown
+ ;;
+ st2000)
+ basic_machine=m68k-tandem
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ os=-sysv4
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ os=-sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ os=-sunos4
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ os=-sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ os=-sunos4
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ os=-sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ os=-sunos4
+ ;;
+ sun4sol2)
+ basic_machine=sparc-sun
+ os=-solaris2
+ ;;
+ sun3 | sun3-*)
+ basic_machine=m68k-sun
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ ;;
+ sv1)
+ basic_machine=sv1-cray
+ os=-unicos
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ os=-dynix
+ ;;
+ t3e)
+ basic_machine=alphaev5-cray
+ os=-unicos
+ ;;
+ t90)
+ basic_machine=t90-cray
+ os=-unicos
+ ;;
+ tic54x | c54x*)
+ basic_machine=tic54x-unknown
+ os=-coff
+ ;;
+ tic55x | c55x*)
+ basic_machine=tic55x-unknown
+ os=-coff
+ ;;
+ tic6x | c6x*)
+ basic_machine=tic6x-unknown
+ os=-coff
+ ;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
+ toad1)
+ basic_machine=pdp10-xkl
+ os=-tops20
+ ;;
+ tower | tower-32)
+ basic_machine=m68k-ncr
+ ;;
+ tpf)
+ basic_machine=s390x-ibm
+ os=-tpf
+ ;;
+ udi29k)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ os=-sym1
+ ;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=-none
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ os=-sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ os=-vms
+ ;;
+ vpp*|vx|vx-*)
+ basic_machine=f301-fujitsu
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ os=-vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=-vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ os=-vxworks
+ ;;
+ w65*)
+ basic_machine=w65-wdc
+ os=-none
+ ;;
+ w89k-*)
+ basic_machine=hppa1.1-winbond
+ os=-proelf
+ ;;
+ xbox)
+ basic_machine=i686-pc
+ os=-mingw32
+ ;;
+ xps | xps100)
+ basic_machine=xps100-honeywell
+ ;;
+ ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
+ z8k-*-coff)
+ basic_machine=z8k-unknown
+ os=-sim
+ ;;
+ none)
+ basic_machine=none-none
+ os=-none
+ ;;
+
+# Here we handle the default manufacturer of certain CPU types. It is in
+# some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ basic_machine=hppa1.1-winbond
+ ;;
+ op50n)
+ basic_machine=hppa1.1-oki
+ ;;
+ op60c)
+ basic_machine=hppa1.1-oki
+ ;;
+ romp)
+ basic_machine=romp-ibm
+ ;;
+ mmix)
+ basic_machine=mmix-knuth
+ ;;
+ rs6000)
+ basic_machine=rs6000-ibm
+ ;;
+ vax)
+ basic_machine=vax-dec
+ ;;
+ pdp10)
+ # there are many clones, so DEC is not a safe bet
+ basic_machine=pdp10-unknown
+ ;;
+ pdp11)
+ basic_machine=pdp11-dec
+ ;;
+ we32k)
+ basic_machine=we32k-att
+ ;;
+ sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
+ basic_machine=sh-unknown
+ ;;
+ sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+ basic_machine=sparc-sun
+ ;;
+ cydra)
+ basic_machine=cydra-cydrome
+ ;;
+ orion)
+ basic_machine=orion-highlevel
+ ;;
+ orion105)
+ basic_machine=clipper-highlevel
+ ;;
+ mac | mpw | mac-mpw)
+ basic_machine=m68k-apple
+ ;;
+ pmac | pmac-mpw)
+ basic_machine=powerpc-apple
+ ;;
+ *-unknown)
+ # Make sure to match an already-canonicalized machine name.
+ ;;
+ *)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+ *-digital*)
+ basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+ ;;
+ *-commodore*)
+ basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+ ;;
+ *)
+ ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+ # First match some system type aliases
+ # that might get confused with valid system types.
+ # -solaris* is a basic system type, with this one exception.
+ -solaris1 | -solaris1.*)
+ os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ ;;
+ -solaris)
+ os=-solaris2
+ ;;
+ -svr4*)
+ os=-sysv4
+ ;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
+ -gnu/linux*)
+ os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+ ;;
+ # First accept the basic system types.
+ # The portable systems comes first.
+ # Each alternative MUST END IN A *, to match a version number.
+ # -sysv* is not here because it comes later, after sysvr4.
+ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+ | -openbsd* | -solidbsd* \
+ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+ | -skyos* | -haiku* | -rdos* | -toppers*)
+ # Remember, each alternative MUST END IN *, to match a version number.
+ ;;
+ -qnx*)
+ case $basic_machine in
+ x86-* | i*86-*)
+ ;;
+ *)
+ os=-nto$os
+ ;;
+ esac
+ ;;
+ -nto-qnx*)
+ ;;
+ -nto*)
+ os=`echo $os | sed -e 's|nto|nto-qnx|'`
+ ;;
+ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+ ;;
+ -mac*)
+ os=`echo $os | sed -e 's|mac|macos|'`
+ ;;
+ -linux-dietlibc)
+ os=-linux-dietlibc
+ ;;
+ -linux*)
+ os=`echo $os | sed -e 's|linux|linux-gnu|'`
+ ;;
+ -sunos5*)
+ os=`echo $os | sed -e 's|sunos5|solaris2|'`
+ ;;
+ -sunos6*)
+ os=`echo $os | sed -e 's|sunos6|solaris3|'`
+ ;;
+ -opened*)
+ os=-openedition
+ ;;
+ -os400*)
+ os=-os400
+ ;;
+ -wince*)
+ os=-wince
+ ;;
+ -osfrose*)
+ os=-osfrose
+ ;;
+ -osf*)
+ os=-osf
+ ;;
+ -utek*)
+ os=-bsd
+ ;;
+ -dynix*)
+ os=-bsd
+ ;;
+ -acis*)
+ os=-aos
+ ;;
+ -atheos*)
+ os=-atheos
+ ;;
+ -syllable*)
+ os=-syllable
+ ;;
+ -386bsd)
+ os=-bsd
+ ;;
+ -ctix* | -uts*)
+ os=-sysv
+ ;;
+ -nova*)
+ os=-rtmk-nova
+ ;;
+ -ns2 )
+ os=-nextstep2
+ ;;
+ -nsk*)
+ os=-nsk
+ ;;
+ # Preserve the version number of sinix5.
+ -sinix5.*)
+ os=`echo $os | sed -e 's|sinix|sysv|'`
+ ;;
+ -sinix*)
+ os=-sysv4
+ ;;
+ -tpf*)
+ os=-tpf
+ ;;
+ -triton*)
+ os=-sysv3
+ ;;
+ -oss*)
+ os=-sysv3
+ ;;
+ -svr4)
+ os=-sysv4
+ ;;
+ -svr3)
+ os=-sysv3
+ ;;
+ -sysvr4)
+ os=-sysv4
+ ;;
+ # This must come after -sysvr4.
+ -sysv*)
+ ;;
+ -ose*)
+ os=-ose
+ ;;
+ -es1800*)
+ os=-ose
+ ;;
+ -xenix)
+ os=-xenix
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ os=-mint
+ ;;
+ -aros*)
+ os=-aros
+ ;;
+ -kaos*)
+ os=-kaos
+ ;;
+ -zvmoe)
+ os=-zvmoe
+ ;;
+ -none)
+ ;;
+ *)
+ # Get rid of the `-' at the beginning of $os.
+ os=`echo $os | sed 's/[^-]*-//'`
+ echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system. Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+ score-*)
+ os=-elf
+ ;;
+ spu-*)
+ os=-elf
+ ;;
+ *-acorn)
+ os=-riscix1.2
+ ;;
+ arm*-rebel)
+ os=-linux
+ ;;
+ arm*-semi)
+ os=-aout
+ ;;
+ c4x-* | tic4x-*)
+ os=-coff
+ ;;
+ # This must come before the *-dec entry.
+ pdp10-*)
+ os=-tops20
+ ;;
+ pdp11-*)
+ os=-none
+ ;;
+ *-dec | vax-*)
+ os=-ultrix4.2
+ ;;
+ m68*-apollo)
+ os=-domain
+ ;;
+ i386-sun)
+ os=-sunos4.0.2
+ ;;
+ m68000-sun)
+ os=-sunos3
+ # This also exists in the configure program, but was not the
+ # default.
+ # os=-sunos4
+ ;;
+ m68*-cisco)
+ os=-aout
+ ;;
+ mips*-cisco)
+ os=-elf
+ ;;
+ mips*-*)
+ os=-elf
+ ;;
+ or32-*)
+ os=-coff
+ ;;
+ *-tti) # must be before sparc entry or we get the wrong os.
+ os=-sysv3
+ ;;
+ sparc-* | *-sun)
+ os=-sunos4.1.1
+ ;;
+ *-be)
+ os=-beos
+ ;;
+ *-haiku)
+ os=-haiku
+ ;;
+ *-ibm)
+ os=-aix
+ ;;
+ *-knuth)
+ os=-mmixware
+ ;;
+ *-wec)
+ os=-proelf
+ ;;
+ *-winbond)
+ os=-proelf
+ ;;
+ *-oki)
+ os=-proelf
+ ;;
+ *-hp)
+ os=-hpux
+ ;;
+ *-hitachi)
+ os=-hiux
+ ;;
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+ os=-sysv
+ ;;
+ *-cbm)
+ os=-amigaos
+ ;;
+ *-dg)
+ os=-dgux
+ ;;
+ *-dolphin)
+ os=-sysv3
+ ;;
+ m68k-ccur)
+ os=-rtu
+ ;;
+ m88k-omron*)
+ os=-luna
+ ;;
+ *-next )
+ os=-nextstep
+ ;;
+ *-sequent)
+ os=-ptx
+ ;;
+ *-crds)
+ os=-unos
+ ;;
+ *-ns)
+ os=-genix
+ ;;
+ i370-*)
+ os=-mvs
+ ;;
+ *-next)
+ os=-nextstep3
+ ;;
+ *-gould)
+ os=-sysv
+ ;;
+ *-highlevel)
+ os=-bsd
+ ;;
+ *-encore)
+ os=-bsd
+ ;;
+ *-sgi)
+ os=-irix
+ ;;
+ *-siemens)
+ os=-sysv4
+ ;;
+ *-masscomp)
+ os=-rtu
+ ;;
+ f30[01]-fujitsu | f700-fujitsu)
+ os=-uxpv
+ ;;
+ *-rom68k)
+ os=-coff
+ ;;
+ *-*bug)
+ os=-coff
+ ;;
+ *-apple)
+ os=-macos
+ ;;
+ *-atari*)
+ os=-mint
+ ;;
+ *)
+ os=-none
+ ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer. We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+ *-unknown)
+ case $os in
+ -riscix*)
+ vendor=acorn
+ ;;
+ -sunos*)
+ vendor=sun
+ ;;
+ -aix*)
+ vendor=ibm
+ ;;
+ -beos*)
+ vendor=be
+ ;;
+ -hpux*)
+ vendor=hp
+ ;;
+ -mpeix*)
+ vendor=hp
+ ;;
+ -hiux*)
+ vendor=hitachi
+ ;;
+ -unos*)
+ vendor=crds
+ ;;
+ -dgux*)
+ vendor=dg
+ ;;
+ -luna*)
+ vendor=omron
+ ;;
+ -genix*)
+ vendor=ns
+ ;;
+ -mvs* | -opened*)
+ vendor=ibm
+ ;;
+ -os400*)
+ vendor=ibm
+ ;;
+ -ptx*)
+ vendor=sequent
+ ;;
+ -tpf*)
+ vendor=ibm
+ ;;
+ -vxsim* | -vxworks* | -windiss*)
+ vendor=wrs
+ ;;
+ -aux*)
+ vendor=apple
+ ;;
+ -hms*)
+ vendor=hitachi
+ ;;
+ -mpw* | -macos*)
+ vendor=apple
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ vendor=atari
+ ;;
+ -vos*)
+ vendor=stratus
+ ;;
+ esac
+ basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+ ;;
+esac
+
+echo $basic_machine$os
+exit
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/configure b/configure
new file mode 100755
index 0000000..e285f0c
--- /dev/null
+++ b/configure
@@ -0,0 +1,8860 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.59.
+#
+# Copyright (C) 2003 Free Software Foundation, Inc.
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+ set -o posix
+fi
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+ LC_TELEPHONE LC_TIME
+do
+ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+ eval $as_var=C; export $as_var
+ else
+ $as_unset $as_var
+ fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)$' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+ /^X\/\(\/\/\)$/{ s//\1/; q; }
+ /^X\/\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ echo "#! /bin/sh" >conf$$.sh
+ echo "exit 0" >>conf$$.sh
+ chmod +x conf$$.sh
+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -f conf$$.sh
+fi
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" || {
+ # Find who we are. Look in the path if we contain no path at all
+ # relative or not.
+ case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+
+ ;;
+ esac
+ # We did not find ourselves, most probably we were run as `sh COMMAND'
+ # in which case we are not to be found in the path.
+ if test "x$as_myself" = x; then
+ as_myself=$0
+ fi
+ if test ! -f "$as_myself"; then
+ { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
+ { (exit 1); exit 1; }; }
+ fi
+ case $CONFIG_SHELL in
+ '')
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for as_base in sh bash ksh sh5; do
+ case $as_dir in
+ /*)
+ if ("$as_dir/$as_base" -c '
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
+ $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+ $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+ CONFIG_SHELL=$as_dir/$as_base
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+ fi;;
+ esac
+ done
+done
+;;
+ esac
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line before each line; the second 'sed' does the real
+ # work. The second script uses 'N' to pair each line-number line
+ # with the numbered line, and appends trailing '-' during
+ # substitution so that $LINENO is not a special case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
+ sed '=' <$as_myself |
+ sed '
+ N
+ s,$,-,
+ : loop
+ s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+ t loop
+ s,-$,,
+ s,^['$as_cr_digits']*\n,,
+ ' >$as_me.lineno &&
+ chmod +x $as_me.lineno ||
+ { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensible to this).
+ . ./$as_me.lineno
+ # Exit status is that of the last command.
+ exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+ *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T=' ' ;;
+ *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+ *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+ # We could just check for DJGPP; but this test a) works b) is more generic
+ # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+ if test -f conf$$.exe; then
+ # Don't use ln at all; we don't have any links
+ as_ln_s='cp -p'
+ else
+ as_ln_s='ln -s'
+ fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" $as_nl"
+
+# CDPATH.
+$as_unset CDPATH
+
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+exec 6>&1
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_config_libobj_dir=.
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+# Maximum number of lines to put in a shell here document.
+# This variable seems obsolete. It should probably be removed, and
+# only ac_max_sed_lines should be used.
+: ${ac_max_here_lines=38}
+
+# Identity of this package.
+PACKAGE_NAME=
+PACKAGE_TARNAME=
+PACKAGE_VERSION=
+PACKAGE_STRING=
+PACKAGE_BUGREPORT=
+
+ac_unique_file="base/nagios.c"
+ac_default_prefix=/usr/local/nagios
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include
+#if HAVE_SYS_TYPES_H
+# include
+#endif
+#if HAVE_SYS_STAT_H
+# include
+#endif
+#if STDC_HEADERS
+# include
+# include
+#else
+# if HAVE_STDLIB_H
+# include
+# endif
+#endif
+#if HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+# include
+# endif
+# include
+#endif
+#if HAVE_STRINGS_H
+# include
+#endif
+#if HAVE_INTTYPES_H
+# include
+#else
+# if HAVE_STDINT_H
+# include
+# endif
+#endif
+#if HAVE_UNISTD_H
+# include
+#endif"
+
+ac_subdirs_all="$ac_subdirs_all tap"
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA INSTALL build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT SET_MAKE STRIP CPP EGREP SNPRINTF_O SOCKETLIBS THREADLIBS nagios_user nagios_grp INSTALL_OPTS command_user command_grp COMMAND_OPTS MAIL_PROG HTTPD_CONF CHECKRESULTDIR TMPDIR init_dir lockfile XSDC XSDH XCDC XCDH XRDC XRDH XODC XODH XPDC XPDH XDDC XDDH htmurl cgiurl BROKER_LDFLAGS BROKERLIBS MOD_CFLAGS MOD_LDFLAGS BROKER_O BROKER_H nagios_name nagiostats_name PATH_TO_TRACEROUTE PACKDIR VERSION subdirs USE_LIBTAP CGIEXTRAS GDLIBS PERLLIBS PERLDIR PERLXSI_O BASEEXTRALIBS INITDIR INSTALLPERLSTUFF USE_EVENTBROKER PERL LIBOBJS LTLIBOBJS'
+ac_subst_files=''
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+ac_prev=
+for ac_option
+do
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case $ac_option in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir=$ac_optarg ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build_alias ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build_alias=$ac_optarg ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file=$ac_optarg ;;
+
+ --config-cache | -C)
+ cache_file=config.cache ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir=$ac_optarg ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+ { (exit 1); exit 1; }; }
+ ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+ eval "enable_$ac_feature=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+ { (exit 1); exit 1; }; }
+ ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+ case $ac_option in
+ *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_$ac_feature='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix=$ac_optarg ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he | -h)
+ ac_init_help=long ;;
+ -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+ ac_init_help=recursive ;;
+ -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+ ac_init_help=short ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host_alias ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host_alias=$ac_optarg ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir=$ac_optarg ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir=$ac_optarg ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir=$ac_optarg ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir=$ac_optarg ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir=$ac_optarg ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir=$ac_optarg ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c | -n)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir=$ac_optarg ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix=$ac_optarg ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix=$ac_optarg ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix=$ac_optarg ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name=$ac_optarg ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir=$ac_optarg ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir=$ac_optarg ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site=$ac_optarg ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir=$ac_optarg ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir=$ac_optarg ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target_alias ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target_alias=$ac_optarg ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers | -V)
+ ac_init_version=: ;;
+
+ -with-* | --with-*)
+ ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid package name: $ac_package" >&2
+ { (exit 1); exit 1; }; }
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case $ac_option in
+ *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_$ac_package='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid package name: $ac_package" >&2
+ { (exit 1); exit 1; }; }
+ ac_package=`echo $ac_package | sed 's/-/_/g'`
+ eval "with_$ac_package=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes=$ac_optarg ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries=$ac_optarg ;;
+
+ -*) { echo "$as_me: error: unrecognized option: $ac_option
+Try \`$0 --help' for more information." >&2
+ { (exit 1); exit 1; }; }
+ ;;
+
+ *=*)
+ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
+ { (exit 1); exit 1; }; }
+ ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
+ eval "$ac_envvar='$ac_optarg'"
+ export $ac_envvar ;;
+
+ *)
+ # FIXME: should be removed in autoconf 3.0.
+ echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+ echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+ : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+ { echo "$as_me: error: missing argument to $ac_option" >&2
+ { (exit 1); exit 1; }; }
+fi
+
+# Be sure to have absolute paths.
+for ac_var in exec_prefix prefix
+do
+ eval ac_val=$`echo $ac_var`
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
+ *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# Be sure to have absolute paths.
+for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
+ localstatedir libdir includedir oldincludedir infodir mandir
+do
+ eval ac_val=$`echo $ac_var`
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* ) ;;
+ *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+ if test "x$build_alias" = x; then
+ cross_compiling=maybe
+ echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+ If a cross compiler is detected then cross compile mode will be used." >&2
+ elif test "x$build_alias" != "x$host_alias"; then
+ cross_compiling=yes
+ fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_confdir=`(dirname "$0") 2>/dev/null ||
+$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$0" : 'X\(//\)[^/]' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$0" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
+ { (exit 1); exit 1; }; }
+ else
+ { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
+ { (exit 1); exit 1; }; }
+ fi
+fi
+(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
+ { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
+ { (exit 1); exit 1; }; }
+srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
+ac_env_build_alias_set=${build_alias+set}
+ac_env_build_alias_value=$build_alias
+ac_cv_env_build_alias_set=${build_alias+set}
+ac_cv_env_build_alias_value=$build_alias
+ac_env_host_alias_set=${host_alias+set}
+ac_env_host_alias_value=$host_alias
+ac_cv_env_host_alias_set=${host_alias+set}
+ac_cv_env_host_alias_value=$host_alias
+ac_env_target_alias_set=${target_alias+set}
+ac_env_target_alias_value=$target_alias
+ac_cv_env_target_alias_set=${target_alias+set}
+ac_cv_env_target_alias_value=$target_alias
+ac_env_CC_set=${CC+set}
+ac_env_CC_value=$CC
+ac_cv_env_CC_set=${CC+set}
+ac_cv_env_CC_value=$CC
+ac_env_CFLAGS_set=${CFLAGS+set}
+ac_env_CFLAGS_value=$CFLAGS
+ac_cv_env_CFLAGS_set=${CFLAGS+set}
+ac_cv_env_CFLAGS_value=$CFLAGS
+ac_env_LDFLAGS_set=${LDFLAGS+set}
+ac_env_LDFLAGS_value=$LDFLAGS
+ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
+ac_cv_env_LDFLAGS_value=$LDFLAGS
+ac_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_env_CPPFLAGS_value=$CPPFLAGS
+ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_cv_env_CPPFLAGS_value=$CPPFLAGS
+ac_env_CPP_set=${CPP+set}
+ac_env_CPP_value=$CPP
+ac_cv_env_CPP_set=${CPP+set}
+ac_cv_env_CPP_value=$CPP
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat <<_ACEOF
+\`configure' configures this package to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE. See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+ -h, --help display this help and exit
+ --help=short display options specific to this package
+ --help=recursive display the short help of all the included packages
+ -V, --version display version information and exit
+ -q, --quiet, --silent do not print \`checking...' messages
+ --cache-file=FILE cache test results in FILE [disabled]
+ -C, --config-cache alias for \`--cache-file=config.cache'
+ -n, --no-create do not create output files
+ --srcdir=DIR find the sources in DIR [configure dir or \`..']
+
+_ACEOF
+
+ cat <<_ACEOF
+Installation directories:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+ --bindir=DIR user executables [EPREFIX/bin]
+ --sbindir=DIR system admin executables [EPREFIX/sbin]
+ --libexecdir=DIR program executables [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --libdir=DIR object code libraries [EPREFIX/lib]
+ --includedir=DIR C header files [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc [/usr/include]
+ --infodir=DIR info documentation [PREFIX/info]
+ --mandir=DIR man documentation [PREFIX/man]
+_ACEOF
+
+ cat <<\_ACEOF
+
+System types:
+ --build=BUILD configure for building on BUILD [guessed]
+ --host=HOST cross-compile to build programs to run on HOST [BUILD]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+
+ cat <<\_ACEOF
+
+Optional Features:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+--disable-statusmap=disables compilation of statusmap CGI
+--disable-statuswrl=disables compilation of statuswrl (VRML) CGI
+--enable-nanosleep enables use of nanosleep (instead of sleep) in event timing
+--enable-event-broker enables integration of event broker routines
+--enable-embedded-perl will enable embedded Perl interpreter
+--enable-cygwin enables building under the CYGWIN environment
+ --enable-libtap Enable built-in libtap for unit-testing (default:
+ no).
+
+Optional Packages:
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --with-nagios-user=
+ sets user name to run nagios
+ --with-nagios-group=
+ sets group name to run nagios
+ --with-command-user=
+ sets user name for command access
+ --with-command-group=
+ sets group name for command access
+--with-mail= sets path to equivalent program to mail
+--with-httpd-conf= sets path to Apache conf.d directory
+--with-checkresult-dir= sets path to check results spool directory
+--with-temp-dir= sets path to temp directory
+--with-init-dir= sets directory to place init script into
+--with-lockfile= sets path and file name for lock file
+--with-gd-lib=DIR sets location of the gd library
+--with-gd-inc=DIR sets location of the gd include files
+--with-cgiurl= sets URL for cgi programs (do not use a trailing slash)
+--with-htmurl= sets URL for public html
+--with-perlcache turns on cacheing of internally compiled Perl scripts
+
+Some influential environment variables:
+ CC C compiler command
+ CFLAGS C compiler flags
+ LDFLAGS linker flags, e.g. -L if you have libraries in a
+ nonstandard directory
+ CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have
+ headers in a nonstandard directory
+ CPP C preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+_ACEOF
+fi
+
+if test "$ac_init_help" = "recursive"; then
+ # If there are subdirs, report their specific --help.
+ ac_popdir=`pwd`
+ for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+ test -d $ac_dir || continue
+ ac_builddir=.
+
+if test "$ac_dir" != .; then
+ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+ ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+ .) # No --srcdir option. We are building in place.
+ ac_srcdir=.
+ if test -z "$ac_top_builddir"; then
+ ac_top_srcdir=.
+ else
+ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+ fi ;;
+ [\\/]* | ?:[\\/]* ) # Absolute path.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir ;;
+ *) # Relative path.
+ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+
+# Do not use `cd foo && pwd` to compute absolute paths, because
+# the directories may not exist.
+case `pwd` in
+.) ac_abs_builddir="$ac_dir";;
+*)
+ case "$ac_dir" in
+ .) ac_abs_builddir=`pwd`;;
+ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
+ *) ac_abs_builddir=`pwd`/"$ac_dir";;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_builddir=${ac_top_builddir}.;;
+*)
+ case ${ac_top_builddir}. in
+ .) ac_abs_top_builddir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
+ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_srcdir=$ac_srcdir;;
+*)
+ case $ac_srcdir in
+ .) ac_abs_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
+ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_srcdir=$ac_top_srcdir;;
+*)
+ case $ac_top_srcdir in
+ .) ac_abs_top_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
+ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
+ esac;;
+esac
+
+ cd $ac_dir
+ # Check for guested configure; otherwise get Cygnus style configure.
+ if test -f $ac_srcdir/configure.gnu; then
+ echo
+ $SHELL $ac_srcdir/configure.gnu --help=recursive
+ elif test -f $ac_srcdir/configure; then
+ echo
+ $SHELL $ac_srcdir/configure --help=recursive
+ elif test -f $ac_srcdir/configure.ac ||
+ test -f $ac_srcdir/configure.in; then
+ echo
+ $ac_configure --help
+ else
+ echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+ fi
+ cd $ac_popdir
+ done
+fi
+
+test -n "$ac_init_help" && exit 0
+if $ac_init_version; then
+ cat <<\_ACEOF
+
+Copyright (C) 2003 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+ exit 0
+fi
+exec 5>config.log
+cat >&5 <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by $as_me, which was
+generated by GNU Autoconf 2.59. Invocation command line was
+
+ $ $0 $@
+
+_ACEOF
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
+
+/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+hostinfo = `(hostinfo) 2>/dev/null || echo unknown`
+/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
+/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ echo "PATH: $as_dir"
+done
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_sep=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+ for ac_arg
+ do
+ case $ac_arg in
+ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ continue ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+ ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ case $ac_pass in
+ 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
+ 2)
+ ac_configure_args1="$ac_configure_args1 '$ac_arg'"
+ if test $ac_must_keep_next = true; then
+ ac_must_keep_next=false # Got value, back to normal.
+ else
+ case $ac_arg in
+ *=* | --config-cache | -C | -disable-* | --disable-* \
+ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+ | -with-* | --with-* | -without-* | --without-* | --x)
+ case "$ac_configure_args0 " in
+ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+ esac
+ ;;
+ -* ) ac_must_keep_next=true ;;
+ esac
+ fi
+ ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
+ # Get rid of the leading space.
+ ac_sep=" "
+ ;;
+ esac
+ done
+done
+$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
+$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log. We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Be sure not to use single quotes in there, as some shells,
+# such as our DU 5.0 friend, will then `close' the trap.
+trap 'exit_status=$?
+ # Save into config.log some information that might help in debugging.
+ {
+ echo
+
+ cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+ echo
+ # The following way of writing the cache mishandles newlines in values,
+{
+ (set) 2>&1 |
+ case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ sed -n \
+ "s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
+ ;;
+ *)
+ sed -n \
+ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+ ;;
+ esac;
+}
+ echo
+
+ cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_vars
+ do
+ eval ac_val=$`echo $ac_var`
+ echo "$ac_var='"'"'$ac_val'"'"'"
+ done | sort
+ echo
+
+ if test -n "$ac_subst_files"; then
+ cat <<\_ASBOX
+## ------------- ##
+## Output files. ##
+## ------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_files
+ do
+ eval ac_val=$`echo $ac_var`
+ echo "$ac_var='"'"'$ac_val'"'"'"
+ done | sort
+ echo
+ fi
+
+ if test -s confdefs.h; then
+ cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+ echo
+ sed "/^$/d" confdefs.h | sort
+ echo
+ fi
+ test "$ac_signal" != 0 &&
+ echo "$as_me: caught signal $ac_signal"
+ echo "$as_me: exit $exit_status"
+ } >&5
+ rm -f core *.core &&
+ rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
+ exit $exit_status
+ ' 0
+for ac_signal in 1 2 13 15; do
+ trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo >confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
+echo "$as_me: loading site script $ac_site_file" >&6;}
+ sed 's/^/| /' "$ac_site_file" >&5
+ . "$ac_site_file"
+ fi
+done
+
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in `(set) 2>&1 |
+ sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
+ eval ac_old_set=\$ac_cv_env_${ac_var}_set
+ eval ac_new_set=\$ac_env_${ac_var}_set
+ eval ac_old_val="\$ac_cv_env_${ac_var}_value"
+ eval ac_new_val="\$ac_env_${ac_var}_value"
+ case $ac_old_set,$ac_new_set in
+ set,)
+ { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,set)
+ { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+ if test "x$ac_old_val" != "x$ac_new_val"; then
+ { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
+echo "$as_me: former value: $ac_old_val" >&2;}
+ { echo "$as_me:$LINENO: current value: $ac_new_val" >&5
+echo "$as_me: current value: $ac_new_val" >&2;}
+ ac_cache_corrupted=:
+ fi;;
+ esac
+ # Pass precious variables to config.status.
+ if test "$ac_new_set" = set; then
+ case $ac_new_val in
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+ ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+ *) ac_arg=$ac_var=$ac_new_val ;;
+ esac
+ case " $ac_configure_args " in
+ *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
+ *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ esac
+ fi
+done
+if $ac_cache_corrupted; then
+ { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
+echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+ { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ac_config_headers="$ac_config_headers include/config.h include/snprintf.h"
+
+
+
+PKG_NAME=nagios
+PKG_VERSION="3.5.1"
+PKG_HOME_URL="http://www.nagios.org/"
+PKG_REL_DATE="08-30-2013"
+
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+ if test -f $ac_dir/install-sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f $ac_dir/install.sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ elif test -f $ac_dir/shtool; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/shtool install -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
+echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"
+ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
+echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in
+ ./ | .// | /cC/* | \
+ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+ ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
+ /usr/ucb/* ) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
+ if test $ac_prog = install &&
+ grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ elif test $ac_prog = install &&
+ grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # program-specific install script used by HP pwplus--don't use.
+ :
+ else
+ ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+ break 3
+ fi
+ fi
+ done
+ done
+ ;;
+esac
+done
+
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL=$ac_cv_path_install
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+ INSTALL=$ac_install_sh
+ fi
+fi
+echo "$as_me:$LINENO: result: $INSTALL" >&5
+echo "${ECHO_T}$INSTALL" >&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+
+
+# Make sure we can run config.sub.
+$ac_config_sub sun4 >/dev/null 2>&1 ||
+ { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5
+echo "$as_me: error: cannot run $ac_config_sub" >&2;}
+ { (exit 1); exit 1; }; }
+
+echo "$as_me:$LINENO: checking build system type" >&5
+echo $ECHO_N "checking build system type... $ECHO_C" >&6
+if test "${ac_cv_build+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_build_alias=$build_alias
+test -z "$ac_cv_build_alias" &&
+ ac_cv_build_alias=`$ac_config_guess`
+test -z "$ac_cv_build_alias" &&
+ { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
+echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
+ { (exit 1); exit 1; }; }
+ac_cv_build=`$ac_config_sub $ac_cv_build_alias` ||
+ { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;}
+ { (exit 1); exit 1; }; }
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_build" >&5
+echo "${ECHO_T}$ac_cv_build" >&6
+build=$ac_cv_build
+build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+
+echo "$as_me:$LINENO: checking host system type" >&5
+echo $ECHO_N "checking host system type... $ECHO_C" >&6
+if test "${ac_cv_host+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_host_alias=$host_alias
+test -z "$ac_cv_host_alias" &&
+ ac_cv_host_alias=$ac_cv_build_alias
+ac_cv_host=`$ac_config_sub $ac_cv_host_alias` ||
+ { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
+ { (exit 1); exit 1; }; }
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_host" >&5
+echo "${ECHO_T}$ac_cv_host" >&6
+host=$ac_cv_host
+host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}gcc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="gcc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ CC=$ac_ct_CC
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ CC=$ac_ct_CC
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+fi
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# != 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+ fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in cl
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$CC" && break
+ done
+fi
+if test -z "$CC"; then
+ ac_ct_CC=$CC
+ for ac_prog in cl
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$ac_ct_CC" && break
+done
+
+ CC=$ac_ct_CC
+fi
+
+fi
+
+
+test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&5
+echo "$as_me: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+
+# Provide some information about the compiler.
+echo "$as_me:$LINENO:" \
+ "checking for C compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5
+ (eval $ac_compiler --version &5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5
+ (eval $ac_compiler -v &5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5
+ (eval $ac_compiler -V &5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
+echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6
+ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
+ (eval $ac_link_default) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # Find the output, starting from the most likely. This scheme is
+# not robust to junk in `.', hence go to wildcards (a.*) only as a last
+# resort.
+
+# Be careful to initialize this variable, since it used to be cached.
+# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
+ac_cv_exeext=
+# b.out is created by i960 compilers.
+for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
+do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
+ ;;
+ conftest.$ac_ext )
+ # This is the source file.
+ ;;
+ [ab].out )
+ # We found the default executable, but exeext='' is most
+ # certainly right.
+ break;;
+ *.* )
+ ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ # FIXME: I believe we export ac_cv_exeext for Libtool,
+ # but it would be cool to find out if it's true. Does anybody
+ # maintain Libtool? --akim.
+ export ac_cv_exeext
+ break;;
+ * )
+ break;;
+ esac
+done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
+See \`config.log' for more details." >&5
+echo "$as_me: error: C compiler cannot create executables
+See \`config.log' for more details." >&2;}
+ { (exit 77); exit 77; }; }
+fi
+
+ac_exeext=$ac_cv_exeext
+echo "$as_me:$LINENO: result: $ac_file" >&5
+echo "${ECHO_T}$ac_file" >&6
+
+# Check the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:$LINENO: checking whether the C compiler works" >&5
+echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
+# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
+# If not cross compiling, check that we can run a simple program.
+if test "$cross_compiling" != yes; then
+ if { ac_try='./$ac_file'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cross_compiling=no
+ else
+ if test "$cross_compiling" = maybe; then
+ cross_compiling=yes
+ else
+ { { echo "$as_me:$LINENO: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ fi
+fi
+echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+rm -f a.out a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+# Check the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
+echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
+echo "$as_me:$LINENO: result: $cross_compiling" >&5
+echo "${ECHO_T}$cross_compiling" >&6
+
+echo "$as_me:$LINENO: checking for suffix of executables" >&5
+echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
+ *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ export ac_cv_exeext
+ break;;
+ * ) break;;
+ esac
+done
+else
+ { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest$ac_cv_exeext
+echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
+echo "${ECHO_T}$ac_cv_exeext" >&6
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+echo "$as_me:$LINENO: checking for suffix of object files" >&5
+echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
+if test "${ac_cv_objext+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
+ *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+ break;;
+ esac
+done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
+echo "${ECHO_T}$ac_cv_objext" >&6
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
+if test "${ac_cv_c_compiler_gnu+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_compiler_gnu=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_compiler_gnu=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
+GCC=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+CFLAGS="-g"
+echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
+echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_g+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_prog_cc_g=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_prog_cc_g=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
+echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_stdc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_prog_cc_stdc=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include
+#include
+#include
+#include
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+ char **p;
+ int i;
+{
+ return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+ char *s;
+ va_list v;
+ va_start (v,p);
+ s = g (p, va_arg (v,int));
+ va_end (v);
+ return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
+ function prototypes and stuff, but not '\xHH' hex character constants.
+ These don't provoke an error unfortunately, instead are silently treated
+ as 'x'. The following induces an error, until -std1 is added to get
+ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
+ array size at least. It's necessary to write '\x00'==0 to get something
+ that's true only with -std1. */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
+ ;
+ return 0;
+}
+_ACEOF
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX -qlanglvl=ansi
+# Ultrix and OSF/1 -std1
+# HP-UX 10.20 and later -Ae
+# HP-UX older versions -Aa -D_HPUX_SOURCE
+# SVR4 -Xc -D__EXTENSIONS__
+for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+ CC="$ac_save_CC $ac_arg"
+ rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_prog_cc_stdc=$ac_arg
+break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext
+done
+rm -f conftest.$ac_ext conftest.$ac_objext
+CC=$ac_save_CC
+
+fi
+
+case "x$ac_cv_prog_cc_stdc" in
+ x|xno)
+ echo "$as_me:$LINENO: result: none needed" >&5
+echo "${ECHO_T}none needed" >&6 ;;
+ *)
+ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
+ CC="$CC $ac_cv_prog_cc_stdc" ;;
+esac
+
+# Some people use a C++ compiler to compile C. Since we use `exit',
+# in C++ we need to declare it. In case someone uses the same compiler
+# for both compiling C and C++ we need to have the C++ compiler decide
+# the declaration of exit, since it's the most demanding environment.
+cat >conftest.$ac_ext <<_ACEOF
+#ifndef __cplusplus
+ choke me
+#endif
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ for ac_declaration in \
+ '' \
+ 'extern "C" void std::exit (int) throw (); using std::exit;' \
+ 'extern "C" void std::exit (int); using std::exit;' \
+ 'extern "C" void exit (int) throw ();' \
+ 'extern "C" void exit (int);' \
+ 'void exit (int);'
+do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_declaration
+#include
+int
+main ()
+{
+exit (42);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+continue
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_declaration
+int
+main ()
+{
+exit (42);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+rm -f conftest*
+if test -n "$ac_declaration"; then
+ echo '#ifdef __cplusplus' >>confdefs.h
+ echo $ac_declaration >>confdefs.h
+ echo '#endif' >>confdefs.h
+fi
+
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6
+set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'`
+if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.make <<\_ACEOF
+all:
+ @echo 'ac_maketemp="$(MAKE)"'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=`
+if test -n "$ac_maketemp"; then
+ eval ac_cv_prog_make_${ac_make}_set=yes
+else
+ eval ac_cv_prog_make_${ac_make}_set=no
+fi
+rm -f conftest.make
+fi
+if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+ SET_MAKE=
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+ SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+# Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_STRIP+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $STRIP in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_STRIP="$STRIP" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_STRIP="$as_dir/$ac_word$ac_exec_ext"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+ test -z "$ac_cv_path_STRIP" && ac_cv_path_STRIP="true"
+ ;;
+esac
+fi
+STRIP=$ac_cv_path_STRIP
+
+if test -n "$STRIP"; then
+ echo "$as_me:$LINENO: result: $STRIP" >&5
+echo "${ECHO_T}$STRIP" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
+echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+ if test "${ac_cv_prog_CPP+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # Double quotes because CPP needs to be expanded
+ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+ do
+ ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer to if __STDC__ is defined, since
+ # exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include
+#else
+# include
+#endif
+ Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ # Broken: success on invalid input.
+continue
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ break
+fi
+
+ done
+ ac_cv_prog_CPP=$CPP
+
+fi
+ CPP=$ac_cv_prog_CPP
+else
+ ac_cv_prog_CPP=$CPP
+fi
+echo "$as_me:$LINENO: result: $CPP" >&5
+echo "${ECHO_T}$CPP" >&6
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer to if __STDC__ is defined, since
+ # exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include
+#else
+# include
+#endif
+ Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ # Broken: success on invalid input.
+continue
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ :
+else
+ { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&5
+echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+echo "$as_me:$LINENO: checking for egrep" >&5
+echo $ECHO_N "checking for egrep... $ECHO_C" >&6
+if test "${ac_cv_prog_egrep+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+ then ac_cv_prog_egrep='grep -E'
+ else ac_cv_prog_egrep='egrep'
+ fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
+echo "${ECHO_T}$ac_cv_prog_egrep" >&6
+ EGREP=$ac_cv_prog_egrep
+
+
+echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
+if test "${ac_cv_header_stdc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include
+#include
+#include
+#include
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_header_stdc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_header_stdc=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then
+ :
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ exit(2);
+ exit (0);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_header_stdc=no
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
+
+fi
+
+echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5
+echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6
+if test "${ac_cv_header_time+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include
+#include
+#include
+
+int
+main ()
+{
+if ((struct tm *) 0)
+return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_header_time=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_header_time=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5
+echo "${ECHO_T}$ac_cv_header_time" >&6
+if test $ac_cv_header_time = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define TIME_WITH_SYS_TIME 1
+_ACEOF
+
+fi
+
+echo "$as_me:$LINENO: checking for sys/wait.h that is POSIX.1 compatible" >&5
+echo $ECHO_N "checking for sys/wait.h that is POSIX.1 compatible... $ECHO_C" >&6
+if test "${ac_cv_header_sys_wait_h+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include
+#include
+#ifndef WEXITSTATUS
+# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
+#endif
+#ifndef WIFEXITED
+# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
+#endif
+
+int
+main ()
+{
+ int s;
+ wait (&s);
+ s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_header_sys_wait_h=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_header_sys_wait_h=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_sys_wait_h" >&5
+echo "${ECHO_T}$ac_cv_header_sys_wait_h" >&6
+if test $ac_cv_header_sys_wait_h = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SYS_WAIT_H 1
+_ACEOF
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+
+
+
+
+
+
+
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+ inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_Header=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+for ac_header in arpa/inet.h ctype.h dirent.h errno.h fcntl.h getopt.h grp.h libgen.h limits.h math.h netdb.h netinet/in.h pthread.h pthreads.h pwd.h regex.h signal.h socket.h stdarg.h string.h strings.h sys/mman.h sys/types.h sys/time.h sys/resource.h sys/wait.h sys/socket.h sys/stat.h sys/timeb.h sys/un.h sys/ipc.h sys/msg.h sys/poll.h syslog.h uio.h unistd.h locale.h wchar.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+ # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ (
+ cat <<\_ASBOX
+## ------------------------------------------ ##
+## Report this to the AC_PACKAGE_NAME lists. ##
+## ------------------------------------------ ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
+echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
+if test "${ac_cv_c_const+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+/* FIXME: Include the comments suggested by Paul. */
+#ifndef __cplusplus
+ /* Ultrix mips cc rejects this. */
+ typedef int charset[2];
+ const charset x;
+ /* SunOS 4.1.1 cc rejects this. */
+ char const *const *ccp;
+ char **p;
+ /* NEC SVR4.0.2 mips cc rejects this. */
+ struct point {int x, y;};
+ static struct point const zero = {0,0};
+ /* AIX XL C 1.02.0.0 rejects this.
+ It does not let you subtract one const X* pointer from another in
+ an arm of an if-expression whose if-part is not a constant
+ expression */
+ const char *g = "string";
+ ccp = &g + (g ? g-g : 0);
+ /* HPUX 7.0 cc rejects these. */
+ ++ccp;
+ p = (char**) ccp;
+ ccp = (char const *const *) p;
+ { /* SCO 3.2v4 cc rejects this. */
+ char *t;
+ char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+ *t++ = 0;
+ }
+ { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
+ int x[] = {25, 17};
+ const int *foo = &x[0];
+ ++foo;
+ }
+ { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+ typedef const int *iptr;
+ iptr p = 0;
+ ++p;
+ }
+ { /* AIX XL C 1.02.0.0 rejects this saying
+ "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+ struct s { int j; const int *ap[3]; };
+ struct s *b; b->j = 5;
+ }
+ { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+ const int foo = 10;
+ }
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_c_const=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_c_const=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5
+echo "${ECHO_T}$ac_cv_c_const" >&6
+if test $ac_cv_c_const = no; then
+
+cat >>confdefs.h <<\_ACEOF
+#define const
+_ACEOF
+
+fi
+
+echo "$as_me:$LINENO: checking whether struct tm is in sys/time.h or time.h" >&5
+echo $ECHO_N "checking whether struct tm is in sys/time.h or time.h... $ECHO_C" >&6
+if test "${ac_cv_struct_tm+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include
+#include
+
+int
+main ()
+{
+struct tm *tp; tp->tm_sec;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_struct_tm=time.h
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_struct_tm=sys/time.h
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_struct_tm" >&5
+echo "${ECHO_T}$ac_cv_struct_tm" >&6
+if test $ac_cv_struct_tm = sys/time.h; then
+
+cat >>confdefs.h <<\_ACEOF
+#define TM_IN_SYS_TIME 1
+_ACEOF
+
+fi
+
+echo "$as_me:$LINENO: checking for struct tm.tm_zone" >&5
+echo $ECHO_N "checking for struct tm.tm_zone... $ECHO_C" >&6
+if test "${ac_cv_member_struct_tm_tm_zone+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include
+#include <$ac_cv_struct_tm>
+
+
+int
+main ()
+{
+static struct tm ac_aggr;
+if (ac_aggr.tm_zone)
+return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_member_struct_tm_tm_zone=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include
+#include <$ac_cv_struct_tm>
+
+
+int
+main ()
+{
+static struct tm ac_aggr;
+if (sizeof ac_aggr.tm_zone)
+return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_member_struct_tm_tm_zone=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_member_struct_tm_tm_zone=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_member_struct_tm_tm_zone" >&5
+echo "${ECHO_T}$ac_cv_member_struct_tm_tm_zone" >&6
+if test $ac_cv_member_struct_tm_tm_zone = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_TM_TM_ZONE 1
+_ACEOF
+
+
+fi
+
+if test "$ac_cv_member_struct_tm_tm_zone" = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_TM_ZONE 1
+_ACEOF
+
+else
+ echo "$as_me:$LINENO: checking for tzname" >&5
+echo $ECHO_N "checking for tzname... $ECHO_C" >&6
+if test "${ac_cv_var_tzname+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include
+#ifndef tzname /* For SGI. */
+extern char *tzname[]; /* RS6000 and others reject char **tzname. */
+#endif
+
+int
+main ()
+{
+atoi(*tzname);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_var_tzname=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_var_tzname=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_var_tzname" >&5
+echo "${ECHO_T}$ac_cv_var_tzname" >&6
+ if test $ac_cv_var_tzname = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_TZNAME 1
+_ACEOF
+
+ fi
+fi
+
+echo "$as_me:$LINENO: checking for mode_t" >&5
+echo $ECHO_N "checking for mode_t... $ECHO_C" >&6
+if test "${ac_cv_type_mode_t+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+if ((mode_t *) 0)
+ return 0;
+if (sizeof (mode_t))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_type_mode_t=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_mode_t=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_mode_t" >&5
+echo "${ECHO_T}$ac_cv_type_mode_t" >&6
+if test $ac_cv_type_mode_t = yes; then
+ :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define mode_t int
+_ACEOF
+
+fi
+
+echo "$as_me:$LINENO: checking for pid_t" >&5
+echo $ECHO_N "checking for pid_t... $ECHO_C" >&6
+if test "${ac_cv_type_pid_t+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+if ((pid_t *) 0)
+ return 0;
+if (sizeof (pid_t))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_type_pid_t=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_pid_t=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5
+echo "${ECHO_T}$ac_cv_type_pid_t" >&6
+if test $ac_cv_type_pid_t = yes; then
+ :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define pid_t int
+_ACEOF
+
+fi
+
+echo "$as_me:$LINENO: checking for size_t" >&5
+echo $ECHO_N "checking for size_t... $ECHO_C" >&6
+if test "${ac_cv_type_size_t+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+if ((size_t *) 0)
+ return 0;
+if (sizeof (size_t))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_type_size_t=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_size_t=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5
+echo "${ECHO_T}$ac_cv_type_size_t" >&6
+if test $ac_cv_type_size_t = yes; then
+ :
+else
+
+cat >>confdefs.h <<_ACEOF
+#define size_t unsigned
+_ACEOF
+
+fi
+
+echo "$as_me:$LINENO: checking return type of signal handlers" >&5
+echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6
+if test "${ac_cv_type_signal+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include
+#include
+#ifdef signal
+# undef signal
+#endif
+#ifdef __cplusplus
+extern "C" void (*signal (int, void (*)(int)))(int);
+#else
+void (*signal ()) ();
+#endif
+
+int
+main ()
+{
+int i;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_type_signal=void
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_signal=int
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5
+echo "${ECHO_T}$ac_cv_type_signal" >&6
+
+cat >>confdefs.h <<_ACEOF
+#define RETSIGTYPE $ac_cv_type_signal
+_ACEOF
+
+
+echo "$as_me:$LINENO: checking for uid_t in sys/types.h" >&5
+echo $ECHO_N "checking for uid_t in sys/types.h... $ECHO_C" >&6
+if test "${ac_cv_type_uid_t+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "uid_t" >/dev/null 2>&1; then
+ ac_cv_type_uid_t=yes
+else
+ ac_cv_type_uid_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_uid_t" >&5
+echo "${ECHO_T}$ac_cv_type_uid_t" >&6
+if test $ac_cv_type_uid_t = no; then
+
+cat >>confdefs.h <<\_ACEOF
+#define uid_t int
+_ACEOF
+
+
+cat >>confdefs.h <<\_ACEOF
+#define gid_t int
+_ACEOF
+
+fi
+
+echo "$as_me:$LINENO: checking type of array argument to getgroups" >&5
+echo $ECHO_N "checking type of array argument to getgroups... $ECHO_C" >&6
+if test "${ac_cv_type_getgroups+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test "$cross_compiling" = yes; then
+ ac_cv_type_getgroups=cross
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Thanks to Mike Rendell for this test. */
+#include
+#define NGID 256
+#undef MAX
+#define MAX(x, y) ((x) > (y) ? (x) : (y))
+
+int
+main ()
+{
+ gid_t gidset[NGID];
+ int i, n;
+ union { gid_t gval; long lval; } val;
+
+ val.lval = -1;
+ for (i = 0; i < NGID; i++)
+ gidset[i] = val.gval;
+ n = getgroups (sizeof (gidset) / MAX (sizeof (int), sizeof (gid_t)) - 1,
+ gidset);
+ /* Exit non-zero if getgroups seems to require an array of ints. This
+ happens when gid_t is short but getgroups modifies an array of ints. */
+ exit ((n > 0 && gidset[n] != val.gval) ? 1 : 0);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_type_getgroups=gid_t
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_type_getgroups=int
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+if test $ac_cv_type_getgroups = cross; then
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "getgroups.*int.*gid_t" >/dev/null 2>&1; then
+ ac_cv_type_getgroups=gid_t
+else
+ ac_cv_type_getgroups=int
+fi
+rm -f conftest*
+
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_getgroups" >&5
+echo "${ECHO_T}$ac_cv_type_getgroups" >&6
+
+cat >>confdefs.h <<_ACEOF
+#define GETGROUPS_T $ac_cv_type_getgroups
+_ACEOF
+
+
+
+
+echo "$as_me:$LINENO: checking for va_copy" >&5
+echo $ECHO_N "checking for va_copy... $ECHO_C" >&6
+if test "${ac_cv_HAVE_VA_COPY+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include
+va_list ap1,ap2;
+int
+main ()
+{
+va_copy(ap1,ap2);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_HAVE_VA_COPY=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_HAVE_VA_COPY=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_HAVE_VA_COPY" >&5
+echo "${ECHO_T}$ac_cv_HAVE_VA_COPY" >&6
+if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_VA_COPY 1
+_ACEOF
+
+else
+ echo "$as_me:$LINENO: checking for __va_copy" >&5
+echo $ECHO_N "checking for __va_copy... $ECHO_C" >&6
+if test "${ac_cv_HAVE___VA_COPY+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include
+ va_list ap1,ap2;
+int
+main ()
+{
+__va_copy(ap1,ap2);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_HAVE___VA_COPY=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_HAVE___VA_COPY=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_HAVE___VA_COPY" >&5
+echo "${ECHO_T}$ac_cv_HAVE___VA_COPY" >&6
+ if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE___VA_COPY 1
+_ACEOF
+
+ fi
+fi
+
+echo "$as_me:$LINENO: checking for vsnprintf" >&5
+echo $ECHO_N "checking for vsnprintf... $ECHO_C" >&6
+if test "${ac_cv_func_vsnprintf+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define vsnprintf to an innocuous variant, in case declares vsnprintf.
+ For example, HP-UX 11i declares gettimeofday. */
+#define vsnprintf innocuous_vsnprintf
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char vsnprintf (); below.
+ Prefer to if __STDC__ is defined, since
+ exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include
+#else
+# include
+#endif
+
+#undef vsnprintf
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char vsnprintf ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_vsnprintf) || defined (__stub___vsnprintf)
+choke me
+#else
+char (*f) () = vsnprintf;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != vsnprintf;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_func_vsnprintf=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_vsnprintf=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_vsnprintf" >&5
+echo "${ECHO_T}$ac_cv_func_vsnprintf" >&6
+if test $ac_cv_func_vsnprintf = yes; then
+ :
+else
+ SNPRINTF_O=../common/snprintf.o
+fi
+
+echo "$as_me:$LINENO: checking for snprintf" >&5
+echo $ECHO_N "checking for snprintf... $ECHO_C" >&6
+if test "${ac_cv_func_snprintf+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define snprintf to an innocuous variant, in case declares snprintf.
+ For example, HP-UX 11i declares gettimeofday. */
+#define snprintf innocuous_snprintf
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char snprintf (); below.
+ Prefer to if __STDC__ is defined, since
+ exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include
+#else
+# include
+#endif
+
+#undef snprintf
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char snprintf ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_snprintf) || defined (__stub___snprintf)
+choke me
+#else
+char (*f) () = snprintf;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != snprintf;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_func_snprintf=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_snprintf=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_snprintf" >&5
+echo "${ECHO_T}$ac_cv_func_snprintf" >&6
+if test $ac_cv_func_snprintf = yes; then
+ :
+else
+ SNPRINTF_O=../common/snprintf.o
+fi
+
+echo "$as_me:$LINENO: checking for asprintf" >&5
+echo $ECHO_N "checking for asprintf... $ECHO_C" >&6
+if test "${ac_cv_func_asprintf+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define asprintf to an innocuous variant, in case declares asprintf.
+ For example, HP-UX 11i declares gettimeofday. */
+#define asprintf innocuous_asprintf
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char asprintf (); below.
+ Prefer to if __STDC__ is defined, since
+ exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include
+#else
+# include
+#endif
+
+#undef asprintf
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char asprintf ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_asprintf) || defined (__stub___asprintf)
+choke me
+#else
+char (*f) () = asprintf;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != asprintf;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_func_asprintf=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_asprintf=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_asprintf" >&5
+echo "${ECHO_T}$ac_cv_func_asprintf" >&6
+if test $ac_cv_func_asprintf = yes; then
+ :
+else
+ SNPRINTF_O=../common/snprintf.o
+fi
+
+echo "$as_me:$LINENO: checking for vasprintf" >&5
+echo $ECHO_N "checking for vasprintf... $ECHO_C" >&6
+if test "${ac_cv_func_vasprintf+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define vasprintf to an innocuous variant, in case declares vasprintf.
+ For example, HP-UX 11i declares gettimeofday. */
+#define vasprintf innocuous_vasprintf
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char vasprintf (); below.
+ Prefer to if __STDC__ is defined, since
+ exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include
+#else
+# include
+#endif
+
+#undef vasprintf
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char vasprintf ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_vasprintf) || defined (__stub___vasprintf)
+choke me
+#else
+char (*f) () = vasprintf;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != vasprintf;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_func_vasprintf=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_vasprintf=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_vasprintf" >&5
+echo "${ECHO_T}$ac_cv_func_vasprintf" >&6
+if test $ac_cv_func_vasprintf = yes; then
+ :
+else
+ SNPRINTF_O=../common/snprintf.o
+fi
+
+
+echo "$as_me:$LINENO: checking for C99 vsnprintf" >&5
+echo $ECHO_N "checking for C99 vsnprintf... $ECHO_C" >&6
+if test "${ac_cv_HAVE_C99_VSNPRINTF+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+if test "$cross_compiling" = yes; then
+ ac_cv_HAVE_C99_VSNPRINTF=cross
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include
+#include
+void foo(const char *format, ...) {
+ va_list ap;
+ int len;
+ char buf[5];
+
+ va_start(ap, format);
+ len = vsnprintf(buf, 0, format, ap);
+ va_end(ap);
+ if (len != 5) exit(1);
+
+ va_start(ap, format);
+ len = vsnprintf(0, 0, format, ap);
+ va_end(ap);
+ if (len != 5) exit(1);
+
+ if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
+
+ exit(0);
+}
+main() { foo("hello"); }
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_HAVE_C99_VSNPRINTF=yes
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_HAVE_C99_VSNPRINTF=no
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_HAVE_C99_VSNPRINTF" >&5
+echo "${ECHO_T}$ac_cv_HAVE_C99_VSNPRINTF" >&6
+if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_C99_VSNPRINTF 1
+_ACEOF
+
+fi
+
+
+
+
+echo "$as_me:$LINENO: checking for library containing getservbyname" >&5
+echo $ECHO_N "checking for library containing getservbyname... $ECHO_C" >&6
+if test "${ac_cv_search_getservbyname+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+ac_cv_search_getservbyname=no
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char getservbyname ();
+int
+main ()
+{
+getservbyname ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_search_getservbyname="none required"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+if test "$ac_cv_search_getservbyname" = no; then
+ for ac_lib in nsl; do
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char getservbyname ();
+int
+main ()
+{
+getservbyname ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_search_getservbyname="-l$ac_lib"
+break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ done
+fi
+LIBS=$ac_func_search_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_search_getservbyname" >&5
+echo "${ECHO_T}$ac_cv_search_getservbyname" >&6
+if test "$ac_cv_search_getservbyname" != no; then
+ test "$ac_cv_search_getservbyname" = "none required" || LIBS="$ac_cv_search_getservbyname $LIBS"
+ if test "$ac_cv_search_getservbyname" != "none required"; then
+ SOCKETLIBS="$SOCKETLIBS -lnsl"
+ fi
+fi
+
+echo "$as_me:$LINENO: checking for library containing connect" >&5
+echo $ECHO_N "checking for library containing connect... $ECHO_C" >&6
+if test "${ac_cv_search_connect+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+ac_cv_search_connect=no
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char connect ();
+int
+main ()
+{
+connect ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_search_connect="none required"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+if test "$ac_cv_search_connect" = no; then
+ for ac_lib in socket; do
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char connect ();
+int
+main ()
+{
+connect ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_search_connect="-l$ac_lib"
+break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ done
+fi
+LIBS=$ac_func_search_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_search_connect" >&5
+echo "${ECHO_T}$ac_cv_search_connect" >&6
+if test "$ac_cv_search_connect" != no; then
+ test "$ac_cv_search_connect" = "none required" || LIBS="$ac_cv_search_connect $LIBS"
+ if test "$ac_cv_search_connect" != "none required"; then
+ SOCKETLIBS="$SOCKETLIBS -lsocket"
+ fi
+fi
+
+
+
+
+
+
+
+
+for ac_func in initgroups setenv strdup strstr strtoul unsetenv
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case declares $ac_func.
+ For example, HP-UX 11i declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer to if __STDC__ is defined, since
+ exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include
+#else
+# include
+#endif
+
+#undef $ac_func
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+echo "$as_me:$LINENO: checking for type of socket size" >&5
+echo $ECHO_N "checking for type of socket size... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include
+#include
+#include
+
+int
+main ()
+{
+int a = send(1, (const void *) 0, (size_t) 0, (int) 0);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+
+cat >>confdefs.h <<\_ACEOF
+#define SOCKET_SIZE_TYPE size_t
+_ACEOF
+ echo "$as_me:$LINENO: result: size_t" >&5
+echo "${ECHO_T}size_t" >&6
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+cat >>confdefs.h <<\_ACEOF
+#define SOCKET_SIZE_TYPE int
+_ACEOF
+ echo "$as_me:$LINENO: result: int" >&5
+echo "${ECHO_T}int" >&6
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+THREADLIBS=""
+have_pthreads="no"
+
+
+
+echo "$as_me:$LINENO: checking for pthread_create in -lcma" >&5
+echo $ECHO_N "checking for pthread_create in -lcma... $ECHO_C" >&6
+if test "${ac_cv_lib_cma_pthread_create+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lcma $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char pthread_create ();
+int
+main ()
+{
+pthread_create ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_cma_pthread_create=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_cma_pthread_create=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_cma_pthread_create" >&5
+echo "${ECHO_T}$ac_cv_lib_cma_pthread_create" >&6
+if test $ac_cv_lib_cma_pthread_create = yes; then
+ THREADLIBS="$THREADLIBS -lpthread"
+fi
+
+if test $ac_cv_lib_cma_pthread_create = yes; then
+ have_pthreads="yes"
+fi
+
+echo "$as_me:$LINENO: checking for pthread_create in -lpthread" >&5
+echo $ECHO_N "checking for pthread_create in -lpthread... $ECHO_C" >&6
+if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpthread $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char pthread_create ();
+int
+main ()
+{
+pthread_create ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_pthread_pthread_create=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_pthread_pthread_create=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_pthread_create" >&5
+echo "${ECHO_T}$ac_cv_lib_pthread_pthread_create" >&6
+if test $ac_cv_lib_pthread_pthread_create = yes; then
+ THREADLIBS="$THREADLIBS -lpthread"
+fi
+
+if test $ac_cv_lib_pthread_pthread_create = yes; then
+ have_pthreads="yes"
+else
+ echo "$as_me:$LINENO: checking for pthread_mutex_init in -lpthread" >&5
+echo $ECHO_N "checking for pthread_mutex_init in -lpthread... $ECHO_C" >&6
+if test "${ac_cv_lib_pthread_pthread_mutex_init+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpthread $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char pthread_mutex_init ();
+int
+main ()
+{
+pthread_mutex_init ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_pthread_pthread_mutex_init=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_pthread_pthread_mutex_init=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_pthread_mutex_init" >&5
+echo "${ECHO_T}$ac_cv_lib_pthread_pthread_mutex_init" >&6
+if test $ac_cv_lib_pthread_pthread_mutex_init = yes; then
+ THREADLIBS="$THREADLIBS -lpthread"
+fi
+
+ if test $ac_cv_lib_pthread_pthread_mutex_init = yes; then
+ have_pthreads="yes"
+ fi
+fi
+
+if test $have_pthreads = "no"; then
+ echo "$as_me:$LINENO: checking for pthread_create in -lpthreads" >&5
+echo $ECHO_N "checking for pthread_create in -lpthreads... $ECHO_C" >&6
+if test "${ac_cv_lib_pthreads_pthread_create+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpthreads $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char pthread_create ();
+int
+main ()
+{
+pthread_create ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_pthreads_pthread_create=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_pthreads_pthread_create=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_pthreads_pthread_create" >&5
+echo "${ECHO_T}$ac_cv_lib_pthreads_pthread_create" >&6
+if test $ac_cv_lib_pthreads_pthread_create = yes; then
+ THREADLIBS="$THREADLIBS -lpthreads"
+fi
+
+ if test $ac_cv_lib_pthreads_pthread_create = yes; then
+ have_pthreads="yes"
+ fi
+fi
+
+if test $have_pthreads = "no"; then
+
+ echo "$as_me:$LINENO: checking for pthread_create in -llthread" >&5
+echo $ECHO_N "checking for pthread_create in -llthread... $ECHO_C" >&6
+if test "${ac_cv_lib_lthread_pthread_create+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-llthread -L/usr/local/lib $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char pthread_create ();
+int
+main ()
+{
+pthread_create ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_lthread_pthread_create=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_lthread_pthread_create=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_lthread_pthread_create" >&5
+echo "${ECHO_T}$ac_cv_lib_lthread_pthread_create" >&6
+if test $ac_cv_lib_lthread_pthread_create = yes; then
+
+ CFLAGS="-D_THREAD_SAFE -I/usr/local/include/pthread/linuxthreads -I/usr/include $CFLAGS"
+ THREADLIBS="-L/usr/local/lib -llthread -llgcc_r"
+
+else
+
+ echo "$as_me:$LINENO: checking if we need -pthread for threads" >&5
+echo $ECHO_N "checking if we need -pthread for threads... $ECHO_C" >&6
+ if test "${ac_ldflag_pthread+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+ ac_save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="-pthread $LDFLAGS"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+ char pthread_create();
+
+int
+main ()
+{
+pthread_create();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "ac_ldflag_pthread=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "ac_ldflag_pthread=no"
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext,
+ THREADLIBS="$ac_save_LDFLAGS"
+
+fi
+
+ if eval "test \"`echo $ac_ldflag_pthread`\" = yes"; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+ else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+ fi
+
+fi
+
+
+fi
+
+
+
+echo "$as_me:$LINENO: checking for library containing nanosleep" >&5
+echo $ECHO_N "checking for library containing nanosleep... $ECHO_C" >&6
+if test "${ac_cv_search_nanosleep+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+ac_cv_search_nanosleep=no
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char nanosleep ();
+int
+main ()
+{
+nanosleep ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_search_nanosleep="none required"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+if test "$ac_cv_search_nanosleep" = no; then
+ for ac_lib in rt posix4; do
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char nanosleep ();
+int
+main ()
+{
+nanosleep ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_search_nanosleep="-l$ac_lib"
+break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ done
+fi
+LIBS=$ac_func_search_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_search_nanosleep" >&5
+echo "${ECHO_T}$ac_cv_search_nanosleep" >&6
+if test "$ac_cv_search_nanosleep" != no; then
+ test "$ac_cv_search_nanosleep" = "none required" || LIBS="$ac_cv_search_nanosleep $LIBS"
+
+else
+
+ echo "Error: nanosleep() needed for timing operations."
+ exit 1
+
+fi
+
+
+
+# Check whether --with-nagios_user or --without-nagios_user was given.
+if test "${with_nagios_user+set}" = set; then
+ withval="$with_nagios_user"
+ nagios_user=$withval
+else
+ nagios_user=nagios
+fi;
+
+# Check whether --with-nagios_group or --without-nagios_group was given.
+if test "${with_nagios_group+set}" = set; then
+ withval="$with_nagios_group"
+ nagios_grp=$withval
+else
+ nagios_grp=nagios
+fi;
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_NAGIOS_USER "$nagios_user"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_NAGIOS_GROUP "$nagios_grp"
+_ACEOF
+
+INSTALL_OPTS="-o $nagios_user -g $nagios_grp"
+
+
+
+# Check whether --with-command_user or --without-command_user was given.
+if test "${with_command_user+set}" = set; then
+ withval="$with_command_user"
+ command_user=$withval
+else
+ command_user=$nagios_user
+fi;
+
+# Check whether --with-command_group or --without-command_group was given.
+if test "${with_command_group+set}" = set; then
+ withval="$with_command_group"
+ command_grp=$withval
+else
+ command_grp=$nagios_grp
+fi;
+
+
+COMMAND_OPTS="-o $command_user -g $command_grp"
+
+
+MAIL_PROG=no
+
+# Check whether --with-mail or --without-mail was given.
+if test "${with_mail+set}" = set; then
+ withval="$with_mail"
+ MAIL_PROG=$withval
+else
+ MAIL_PROG=no
+fi;
+if test x$MAIL_PROG = xno; then
+ # Extract the first word of "mail", so it can be a program name with args.
+set dummy mail; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_MAIL_PROG+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $MAIL_PROG in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_MAIL_PROG="$MAIL_PROG" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_MAIL_PROG="$as_dir/$ac_word$ac_exec_ext"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+ ;;
+esac
+fi
+MAIL_PROG=$ac_cv_path_MAIL_PROG
+
+if test -n "$MAIL_PROG"; then
+ echo "$as_me:$LINENO: result: $MAIL_PROG" >&5
+echo "${ECHO_T}$MAIL_PROG" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test x$MAIL_PROG = x; then
+ MAIL_PROG="/bin/mail"
+fi
+
+
+HTTP_CONF=no
+
+# Check whether --with-httpd_conf or --without-httpd_conf was given.
+if test "${with_httpd_conf+set}" = set; then
+ withval="$with_httpd_conf"
+ HTTPD_CONF=$withval
+else
+ HTTPD_CONF=no
+fi;
+if test x$HTTPD_CONF = xno; then
+ if test -d /etc/httpd/conf.d; then
+ HTTPD_CONF="/etc/httpd/conf.d"
+ elif test -d /etc/apache2/conf.d; then
+ HTTPD_CONF="/etc/apache2/conf.d"
+ elif test -d /etc/apache/conf.d; then
+ HTTPD_CONF="/etc/apache/conf.d"
+ else
+ HTTPD_CONF="/etc/httpd/conf.d"
+ fi
+fi
+
+
+CHECKRESULTDIR=no
+
+# Check whether --with-checkresult-dir or --without-checkresult-dir was given.
+if test "${with_checkresult_dir+set}" = set; then
+ withval="$with_checkresult_dir"
+ CHECKRESULTDIR=$withval
+else
+ CHECKRESULTDIR=no
+fi;
+if test x$CHECKRESULTDIR = xno; then
+ CHECKRESULTDIR="$localstatedir/spool/checkresults"
+fi
+
+
+TMPDIR=no
+
+# Check whether --with-temp-dir or --without-temp-dir was given.
+if test "${with_temp_dir+set}" = set; then
+ withval="$with_temp_dir"
+ TMPDIR=$withval
+else
+ TMPDIR=no
+fi;
+if test x$TMPDIR = xno; then
+ TMPDIR="/tmp"
+fi
+
+
+init_dir=/etc/rc.d/init.d
+if test -d /etc/rc.d/init.d; then
+ init_dir="/etc/rc.d/init.d"
+elif test -d /usr/local/etc/rc.d; then
+ init_dir="/usr/local/etc/rc.d"
+elif test -d /etc/rc.d; then
+ init_dir="/etc/rc.d"
+elif test -d /etc/init.d; then
+ init_dir="/etc/init.d"
+elif test -d /sbin/init.d; then
+ init_dir="/sbin/init.d"
+fi
+
+
+# Check whether --with-init_dir or --without-init_dir was given.
+if test "${with_init_dir+set}" = set; then
+ withval="$with_init_dir"
+ init_dir=$withval
+fi;
+
+
+
+# Check whether --with-lockfile or --without-lockfile was given.
+if test "${with_lockfile+set}" = set; then
+ withval="$with_lockfile"
+ lockfile=$withval
+else
+ lockfile=$localstatedir/nagios.lock
+fi;
+
+
+
+
+XSDTYPE=default
+XCDTYPE=default
+XRDTYPE=default
+XODTYPE=template
+XPDTYPE=default
+XDDTYPE=default
+
+XSDCOMMENT=
+XCDCOMMENT=
+XRDCOMMENT=
+XODCOMMENT=
+XPDCOMMENT=
+XDDCOMMENT=
+
+USE_MYSQL=no
+USE_PGSQL=no
+
+
+cat >>confdefs.h <<_ACEOF
+#define USE_XSDDEFAULT
+_ACEOF
+
+XSDC="xsddefault.c"
+XSDH="xsddefault.h"
+XSDCOMMENT="Default (text file)"
+echo "We'll use default routines (in xdata/xsddefault.*) for status data I/O..."
+
+
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define USE_XCDDEFAULT
+_ACEOF
+
+XCDC="xcddefault.c"
+XCDH="xcddefault.h"
+XCDCOMMENT="Default (text file)"
+echo "We'll use default routines (in xdata/xcddefault.*) for comment data I/O..."
+
+
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define USE_XRDDEFAULT
+_ACEOF
+
+XRDC="xrddefault.c"
+XRDH="xrddefault.h"
+XRDCOMMENT="Default (text file)"
+echo "We'll use default routines (in xdata/xrddefault.*) for retention data I/O..."
+
+
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define USE_XODTEMPLATE
+_ACEOF
+
+XODC="xodtemplate.c"
+XODH="xodtemplate.h"
+XODCOMMENT="Template-based (text file)"
+echo "We'll use template-based routines (in xdata/xodtemplate.*) for object data I/O..."
+
+
+
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define USE_XPDDEFAULT
+_ACEOF
+
+XPDC="xpddefault.c"
+XPDH="xpddefault.h"
+XPDCOMMENT="Default (external commands)"
+echo "We'll use default routines (in xdata/xpddefault.*) for performance data I/O..."
+
+
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define USE_XDDDEFAULT
+_ACEOF
+
+XDDC="xdddefault.c"
+XDDH="xdddefault.h"
+XDDCOMMENT="Default (text file)"
+echo "We'll use default routines (in xdata/xdddefault.*) for scheduled downtime data I/O..."
+
+
+
+
+
+# Check whether --with-gd-lib or --without-gd-lib was given.
+if test "${with_gd_lib+set}" = set; then
+ withval="$with_gd_lib"
+
+ LDFLAGS="${LDFLAGS} -L${withval}"
+ LD_RUN_PATH="${withval}${LD_RUN_PATH:+:}${LD_RUN_PATH}"
+
+fi;
+
+# Check whether --with-gd-inc or --without-gd-inc was given.
+if test "${with_gd_inc+set}" = set; then
+ withval="$with_gd_inc"
+
+ CFLAGS="${CFLAGS} -I${withval}"
+
+fi;
+
+
+TRYGD=yep
+
+TRYSTATUSMAP=yep
+# Check whether --enable-statusmap or --disable-statusmap was given.
+if test "${enable_statusmap+set}" = set; then
+ enableval="$enable_statusmap"
+ TRYSTATUSMAP=nope
+fi;
+
+
+TRYSTATUSWRL=yep
+# Check whether --enable-statuswrl or --disable-statuswrl was given.
+if test "${enable_statuswrl+set}" = set; then
+ enableval="$enable_statuswrl"
+ TRYSTATUSWRL=nope
+fi;
+
+if test x$TRYSTATUSWRL = xyep; then
+
+cat >>confdefs.h <<_ACEOF
+#define USE_STATUSWRL
+_ACEOF
+
+ CGIEXTRAS="$CGIEXTRAS statuswrl.cgi"
+fi
+
+
+
+
+
+
+if test x$TRYGD = xyep; then
+
+ echo "$as_me:$LINENO: checking for main in -liconv" >&5
+echo $ECHO_N "checking for main in -liconv... $ECHO_C" >&6
+if test "${ac_cv_lib_iconv_main+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-liconv $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+
+int
+main ()
+{
+main ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_iconv_main=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_iconv_main=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_iconv_main" >&5
+echo "${ECHO_T}$ac_cv_lib_iconv_main" >&6
+if test $ac_cv_lib_iconv_main = yes; then
+ ICONV=-liconv
+fi
+
+
+
+ echo "$as_me:$LINENO: checking for gdImagePng in -lgd (order 1)" >&5
+echo $ECHO_N "checking for gdImagePng in -lgd (order 1)... $ECHO_C" >&6
+ ac_lib_var=`echo gd'_'gdImagePng'_'1 | sed 'y%./+-%__p_%'`
+ if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_save_LIBS="$LIBS"
+ LIBS="-lgd -lttf -lpng -ljpeg -lz -lm $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+ /* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char gdImagePng();
+
+int
+main ()
+{
+gdImagePng()
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LIBS="$ac_save_LIBS"
+
+fi
+ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+ GDLIBFOUND=yep
+ GDLIBS="-lgd -lttf -lpng -ljpeg -lz -lm"
+
+ else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+ :
+ fi
+
+
+ if test x$GDLIBFOUND = x; then
+ echo "$as_me:$LINENO: checking for gdImagePng in -lgd (order 2)" >&5
+echo $ECHO_N "checking for gdImagePng in -lgd (order 2)... $ECHO_C" >&6
+ ac_lib_var=`echo gd'_'gdImagePng'_'2 | sed 'y%./+-%__p_%'`
+ if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_save_LIBS="$LIBS"
+ LIBS="-lgd $ICONV -lpng -ljpeg -lz -lm $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+ /* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char gdImagePng();
+
+int
+main ()
+{
+gdImagePng()
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LIBS="$ac_save_LIBS"
+
+fi
+ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+ GDLIBFOUND=yep
+ GDLIBS="-lgd $ICONV -lpng -ljpeg -lz -lm"
+
+ else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+ :
+ fi
+
+ fi
+
+ if test x$GDLIBFOUND = x; then
+ echo "$as_me:$LINENO: checking for gdImagePng in -lgd (order 3)" >&5
+echo $ECHO_N "checking for gdImagePng in -lgd (order 3)... $ECHO_C" >&6
+ ac_lib_var=`echo gd'_'gdImagePng'_'3 | sed 'y%./+-%__p_%'`
+ if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_save_LIBS="$LIBS"
+ LIBS="-lgd $ICONV -lz -lm -lpng $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+ /* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char gdImagePng();
+
+int
+main ()
+{
+gdImagePng()
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LIBS="$ac_save_LIBS"
+
+fi
+ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+ GDLIBFOUND=yep
+ GDLIBS="-lgd $ICONV -lz -lm -lpng"
+
+ else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+ :
+ fi
+
+ fi
+
+ if test x$GDLIBFOUND = x; then
+ echo "$as_me:$LINENO: checking for gdImagePng in -lgd (order 4)" >&5
+echo $ECHO_N "checking for gdImagePng in -lgd (order 4)... $ECHO_C" >&6
+ ac_lib_var=`echo gd'_'gdImagePng'_'4 | sed 'y%./+-%__p_%'`
+ if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_save_LIBS="$LIBS"
+ LIBS="-lgd $ICONV -lpng -lz -lm $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+ /* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char gdImagePng();
+
+int
+main ()
+{
+gdImagePng()
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LIBS="$ac_save_LIBS"
+
+fi
+ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+ GDLIBFOUND=yep
+ GDLIBS="-lgd $ICONV -lpng -lz -lm"
+
+ else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+ :
+ fi
+
+ fi
+
+ if test x$GDLIBFOUND = x; then
+ echo ""
+ echo ""
+ echo "*** GD, PNG, and/or JPEG libraries could not be located... *********"
+ echo ""
+ echo "Boutell's GD library is required to compile the statusmap, trends"
+ echo "and histogram CGIs. Get it from http://www.boutell.com/gd/, compile"
+ echo "it, and use the --with-gd-lib and --with-gd-inc arguments to specify"
+ echo "the locations of the GD library and include files."
+ echo ""
+ echo "NOTE: In addition to the gd-devel library, you'll also need to make"
+ echo " sure you have the png-devel and jpeg-devel libraries installed"
+ echo " on your system."
+ echo ""
+ echo "NOTE: After you install the necessary libraries on your system:"
+ echo " 1. Make sure /etc/ld.so.conf has an entry for the directory in"
+ echo " which the GD, PNG, and JPEG libraries are installed."
+ echo " 2. Run 'ldconfig' to update the run-time linker options."
+ echo " 3. Run 'make clean' in the Nagios distribution to clean out"
+ echo " any old references to your previous compile."
+ echo " 4. Rerun the configure script."
+ echo ""
+ echo "NOTE: If you can't get the configure script to recognize the GD libs"
+ echo " on your system, get over it and move on to other things. The"
+ echo " CGIs that use the GD libs are just a small part of the entire"
+ echo " Nagios package. Get everything else working first and then"
+ echo " revisit the problem. Make sure to check the nagios-users"
+ echo " mailing list archives for possible solutions to GD library"
+ echo " problems when you resume your troubleshooting."
+ echo ""
+ echo "********************************************************************"
+ echo ""
+ echo ""
+
+ else
+ echo "GD library was found!"
+ if test x$TRYSTATUSMAP = xyep; then
+
+cat >>confdefs.h <<_ACEOF
+#define USE_STATUSMAP
+_ACEOF
+
+ CGIEXTRAS="$CGIEXTRAS statusmap.cgi"
+ echo "$as_me:$LINENO: checking for gdImageCreateTrueColor in -lgd" >&5
+echo $ECHO_N "checking for gdImageCreateTrueColor in -lgd... $ECHO_C" >&6
+if test "${ac_cv_lib_gd_gdImageCreateTrueColor+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgd $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char gdImageCreateTrueColor ();
+int
+main ()
+{
+gdImageCreateTrueColor ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_gd_gdImageCreateTrueColor=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_gd_gdImageCreateTrueColor=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_gd_gdImageCreateTrueColor" >&5
+echo "${ECHO_T}$ac_cv_lib_gd_gdImageCreateTrueColor" >&6
+if test $ac_cv_lib_gd_gdImageCreateTrueColor = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_GDIMAGECREATETRUECOLOR 1
+_ACEOF
+
+fi
+
+ fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define USE_TRENDS
+_ACEOF
+
+ CGIEXTRAS="$CGIEXTRAS trends.cgi"
+
+
+cat >>confdefs.h <<_ACEOF
+#define USE_HISTOGRAM
+_ACEOF
+
+ CGIEXTRAS="$CGIEXTRAS histogram.cgi"
+ fi
+fi
+
+
+# Check whether --with-cgiurl or --without-cgiurl was given.
+if test "${with_cgiurl+set}" = set; then
+ withval="$with_cgiurl"
+ cgiurl=$withval
+else
+ cgiurl=/nagios/cgi-bin
+fi;
+
+# Check whether --with-htmurl or --without-htmurl was given.
+if test "${with_htmurl+set}" = set; then
+ withval="$with_htmurl"
+ htmurl=$withval
+else
+ htmurl=/nagios
+fi;
+
+
+
+USE_NANOSLEEP=yes
+# Check whether --enable-nanosleep or --disable-nanosleep was given.
+if test "${enable_nanosleep+set}" = set; then
+ enableval="$enable_nanosleep"
+ USE_NANOSLEEP=$enableval
+else
+ USE_NANOSLEEP=yes
+fi;
+if test x$USE_NANOSLEEP = xyes; then
+
+cat >>confdefs.h <<_ACEOF
+#define USE_NANOSLEEP
+_ACEOF
+
+fi
+
+USE_EVENTBROKER=yes
+# Check whether --enable-event-broker or --disable-event-broker was given.
+if test "${enable_event_broker+set}" = set; then
+ enableval="$enable_event_broker"
+ USE_EVENTBROKER=$enableval
+else
+ USE_EVENTBROKER=yes
+fi;
+
+BROKER_LDFLAGS=""
+BROKERLIBS="";
+some_dl_found="no";
+if test x$USE_EVENTBROKER = xyes; then
+
+ if test "${ac_cv_header_ltdl_h+set}" = set; then
+ echo "$as_me:$LINENO: checking for ltdl.h" >&5
+echo $ECHO_N "checking for ltdl.h... $ECHO_C" >&6
+if test "${ac_cv_header_ltdl_h+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_ltdl_h" >&5
+echo "${ECHO_T}$ac_cv_header_ltdl_h" >&6
+else
+ # Is the header compilable?
+echo "$as_me:$LINENO: checking ltdl.h usability" >&5
+echo $ECHO_N "checking ltdl.h usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking ltdl.h presence" >&5
+echo $ECHO_N "checking ltdl.h presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: ltdl.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: ltdl.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: ltdl.h: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: ltdl.h: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: ltdl.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: ltdl.h: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: ltdl.h: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: ltdl.h: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: ltdl.h: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: ltdl.h: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: ltdl.h: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: ltdl.h: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: ltdl.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: ltdl.h: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: ltdl.h: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: ltdl.h: in the future, the compiler will take precedence" >&2;}
+ (
+ cat <<\_ASBOX
+## ------------------------------------------ ##
+## Report this to the AC_PACKAGE_NAME lists. ##
+## ------------------------------------------ ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+echo "$as_me:$LINENO: checking for ltdl.h" >&5
+echo $ECHO_N "checking for ltdl.h... $ECHO_C" >&6
+if test "${ac_cv_header_ltdl_h+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_header_ltdl_h=$ac_header_preproc
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_ltdl_h" >&5
+echo "${ECHO_T}$ac_cv_header_ltdl_h" >&6
+
+fi
+if test $ac_cv_header_ltdl_h = yes; then
+
+ echo "$as_me:$LINENO: checking for lt_dlinit in -lltdl" >&5
+echo $ECHO_N "checking for lt_dlinit in -lltdl... $ECHO_C" >&6
+if test "${ac_cv_lib_ltdl_lt_dlinit+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lltdl $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char lt_dlinit ();
+int
+main ()
+{
+lt_dlinit ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_ltdl_lt_dlinit=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_ltdl_lt_dlinit=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_ltdl_lt_dlinit" >&5
+echo "${ECHO_T}$ac_cv_lib_ltdl_lt_dlinit" >&6
+if test $ac_cv_lib_ltdl_lt_dlinit = yes; then
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_LTDL_H
+_ACEOF
+
+ some_dl_found="yes"
+ BROKERLIBS="$BROKERLIBS -lltdl"
+
+fi
+
+
+fi
+
+
+ if test "x$some_dl_found" != xyes; then
+ if test "${ac_cv_header_dlfcn_h+set}" = set; then
+ echo "$as_me:$LINENO: checking for dlfcn.h" >&5
+echo $ECHO_N "checking for dlfcn.h... $ECHO_C" >&6
+if test "${ac_cv_header_dlfcn_h+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_dlfcn_h" >&5
+echo "${ECHO_T}$ac_cv_header_dlfcn_h" >&6
+else
+ # Is the header compilable?
+echo "$as_me:$LINENO: checking dlfcn.h usability" >&5
+echo $ECHO_N "checking dlfcn.h usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking dlfcn.h presence" >&5
+echo $ECHO_N "checking dlfcn.h presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: dlfcn.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: dlfcn.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: dlfcn.h: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: dlfcn.h: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: dlfcn.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: dlfcn.h: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: dlfcn.h: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: dlfcn.h: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: dlfcn.h: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: dlfcn.h: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: dlfcn.h: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: dlfcn.h: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: dlfcn.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: dlfcn.h: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: dlfcn.h: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: dlfcn.h: in the future, the compiler will take precedence" >&2;}
+ (
+ cat <<\_ASBOX
+## ------------------------------------------ ##
+## Report this to the AC_PACKAGE_NAME lists. ##
+## ------------------------------------------ ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+echo "$as_me:$LINENO: checking for dlfcn.h" >&5
+echo $ECHO_N "checking for dlfcn.h... $ECHO_C" >&6
+if test "${ac_cv_header_dlfcn_h+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_header_dlfcn_h=$ac_header_preproc
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_dlfcn_h" >&5
+echo "${ECHO_T}$ac_cv_header_dlfcn_h" >&6
+
+fi
+if test $ac_cv_header_dlfcn_h = yes; then
+
+ echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dlopen ();
+int
+main ()
+{
+dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_dl_dlopen=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dl_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
+if test $ac_cv_lib_dl_dlopen = yes; then
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_DLFCN_H
+_ACEOF
+
+ some_dl_found="yes"
+ BROKERLIBS="$BROKERLIBS -ldl"
+
+fi
+
+
+fi
+
+
+ fi
+
+ # Check how to export functions from the broker executable, needed
+ # when dynamically loaded drivers are loaded (so that they can find
+ # broker functions).
+ # OS'es with ELF executables using the GNU linker (Linux and recent *BSD,
+ # in rare cases Solaris) typically need '-Wl,-export-dynamic' (i.e. pass
+ # -export-dynamic to the linker - also known as -rdynamic and some other
+ # variants); some sysVr4 system(s) instead need(s) '-Wl,-Bexport'.
+ # AIX 4.x (perhaps only for x>=2) wants -Wl,-bexpall,-brtl and doesn't
+ # reliably return an error for others, thus we separate it out.
+ # Otherwise we assume that if the linker accepts the flag, it is needed.
+ echo "$as_me:$LINENO: checking for extra flags needed to export symbols" >&5
+echo $ECHO_N "checking for extra flags needed to export symbols... $ECHO_C" >&6
+ case $host_os in
+ aix4*|aix5*)
+ BROKER_LDFLAGS="$BROKER_LDFLAGS -Wl,-bexpall,-brtl"
+ ;;
+ bsdi*)
+ BROKER_LDFLAGS="$BROKER_LDFLAGS -rdynamic"
+ ;;
+ *)
+ save_ldflags="$LDFLAGS"
+ LDFLAGS=-Wl,-export-dynamic
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ BROKER_LDFLAGS="$BROKER_LDFLAGS -Wl,-export-dynamic"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+ LDFLAGS=-Wl,-Bexport
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ BROKER_LDFLAGS="$BROKER_LDFLAGS -Wl,-Bexport"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+echo "$as_me:$LINENO: result: none" >&5
+echo "${ECHO_T}none" >&6
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS="$save_ldflags"
+ ;;
+ esac
+
+
+ test "x$BROKER_LDFLAGS" != x && echo "$as_me:$LINENO: result: $BROKER_LDFLAGS" >&5
+echo "${ECHO_T}$BROKER_LDFLAGS" >&6
+
+
+ echo "$as_me:$LINENO: checking for linker flags for loadable modules" >&5
+echo $ECHO_N "checking for linker flags for loadable modules... $ECHO_C" >&6
+ case $host_os in
+ solaris2*|sysv4*)
+ MOD_LDFLAGS="-G"
+ ;;
+ aix4*|aix5*)
+ #MOD_LDFLAGS="-G -bnoentry -bexpall"
+ MOD_LDFLAGS="-G -bM:SRE -bnoentry -bexpall"
+ ;;
+ freebsd2*)
+ # Non-ELF GNU linker
+ MOD_LDFLAGS="-Bshareable"
+ ;;
+ darwin*)
+ # Mach-O linker, a shared lib and a loadable
+ # object file is not the same thing.
+ MOD_LDFLAGS="-bundle -flat_namespace -undefined suppress"
+ MOD_CFLAGS="$MOD_CFLAGS -fno-common"
+ ;;
+ linux* | k*bsd*-gnu*)
+ # assume GNU linker and ELF
+ MOD_LDFLAGS="-shared"
+ MOD_CFLAGS="-fPIC"
+ ;;
+ freebsd*)
+ MOD_LDFLAGS="-shared"
+ MOD_CFLAGS="-fPIC"
+ ;;
+ *)
+ # assume GNU linker and ELF
+ MOD_LDFLAGS="-shared"
+ ;;
+ esac
+ echo "$as_me:$LINENO: result: $MOD_LDFLAGS" >&5
+echo "${ECHO_T}$MOD_LDFLAGS" >&6
+
+
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define USE_EVENT_BROKER
+_ACEOF
+
+ BROKER_O="broker.o nebmods.o"
+
+ BROKER_H="../include/broker.h ../include/nebmods.h ../include/nebmodules.h ../include/nebcallbacks.h ../include/neberrors.h"
+
+fi
+
+
+USEPERL=no;
+INSTALLPERLSTUFF=no;
+# Check whether --enable-embedded-perl or --disable-embedded-perl was given.
+if test "${enable_embedded_perl+set}" = set; then
+ enableval="$enable_embedded_perl"
+
+ USEPERL=$enableval
+
+
+else
+ USEPERL=no
+fi;
+
+PERLCACHE=yes;
+
+# Check whether --with-perlcache or --without-perlcache was given.
+if test "${with_perlcache+set}" = set; then
+ withval="$with_perlcache"
+
+ PERLCACHE=$withval
+
+
+else
+
+
+cat >>confdefs.h <<\_ACEOF
+#define DO_CLEAN "1"
+_ACEOF
+
+ PERLCACHE=yes;
+
+fi;
+
+if test x$USEPERL = xyes; then
+
+
+cat >>confdefs.h <<_ACEOF
+#define EMBEDDEDPERL
+_ACEOF
+
+ PERLLIBS="`perl -MExtUtils::Embed -e ldopts`"
+ PERLDIR="`perl -MConfig -e 'print $Config{installsitearch}'`"
+ CFLAGS="${CFLAGS} `perl -MExtUtils::Embed -e ccopts`"
+ USEPERL=yes
+ INSTALLPERLSTUFF=yes;
+ PERLXSI_O=perlxsi.o
+ OBJS="${OBJS} ${PERLXSI_O}"
+ echo "creating base/perlxsi.c"
+ perl -MExtUtils::Embed -e xsinit -- -o base/perlxsi.c
+
+ echo "Embedded Perl interpreter will be compiled in..."
+
+ if test x$PERLCACHE = xyes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define DO_CLEAN "0"
+_ACEOF
+
+ PERLCACHE=yes;
+ echo "Internally compiled Perl scripts will be cached..."
+ else
+
+cat >>confdefs.h <<\_ACEOF
+#define DO_CLEAN "1"
+_ACEOF
+
+ echo "Internally compiled Perl scripts will NOT be cached..."
+ fi
+fi
+
+if test x$USEPERL = xyes; then
+ if (perl -e 'use Config;exit -1 unless ($Config{'usethreads'});'); then
+ echo "Using threaded perl"
+
+cat >>confdefs.h <<_ACEOF
+#define THREADEDPERL
+_ACEOF
+
+ fi
+fi
+
+
+nagios_name=nagios
+nagiostats_name=nagiostats
+cygwin=no
+# Check whether --enable-cygwin or --disable-cygwin was given.
+if test "${enable_cygwin+set}" = set; then
+ enableval="$enable_cygwin"
+
+ cygwin=$enableval
+
+fi;
+if test x$cygwin = xyes; then
+ CFLAGS="${CFLAGS} -DCYGWIN"
+ nagios_name=nagios.exe;
+ nagiostats_name=nagiostats.exe;
+fi
+
+
+
+
+
+# Extract the first word of "traceroute", so it can be a program name with args.
+set dummy traceroute; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_PATH_TO_TRACEROUTE+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $PATH_TO_TRACEROUTE in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_PATH_TO_TRACEROUTE="$PATH_TO_TRACEROUTE" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_PATH_TO_TRACEROUTE="$as_dir/$ac_word$ac_exec_ext"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+ ;;
+esac
+fi
+PATH_TO_TRACEROUTE=$ac_cv_path_PATH_TO_TRACEROUTE
+
+if test -n "$PATH_TO_TRACEROUTE"; then
+ echo "$as_me:$LINENO: result: $PATH_TO_TRACEROUTE" >&5
+echo "${ECHO_T}$PATH_TO_TRACEROUTE" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define TRACEROUTE_COMMAND "$PATH_TO_TRACEROUTE"
+_ACEOF
+
+
+
+
+VERSION=$PKG_VERSION
+PACKDIR=`pwd`/pkg
+
+
+
+echo "$as_me:$LINENO: checking for type va_list" >&5
+echo $ECHO_N "checking for type va_list... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+#include
+#include
+#include
+#else
+#include
+#include
+#include
+#endif
+int
+main ()
+{
+va_list args;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+cat >>confdefs.h <<\_ACEOF
+#define NEED_VA_LIST
+_ACEOF
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+# Check whether --enable-libtap or --disable-libtap was given.
+if test "${enable_libtap+set}" = set; then
+ enableval="$enable_libtap"
+ enable_libtap=$enableval
+else
+ enable_libtap=no
+fi;
+#Disabled for moment
+#AM_CONDITIONAL([USE_LIBTAP_LOCAL],[test "$enable_libtap" = "yes"])
+
+# Disabled for moment
+# If not local, check if we can use the system one
+#if test "$enable_libtap" != "yes" ; then
+# dnl Check for libtap, to run perl-like tests
+# AC_CHECK_LIB(tap, plan_tests,
+# enable_libtap="yes"
+# )
+#fi
+
+# Finally, define tests if we use libtap
+if test "$enable_libtap" = "yes" ; then
+
+
+subdirs="$subdirs tap"
+
+ USE_LIBTAP=yes
+else
+ USE_LIBTAP=no
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+# Extract the first word of "perl", so it can be a program name with args.
+set dummy perl; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_PERL+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $PERL in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_PERL="$PERL" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_PERL="$as_dir/$ac_word$ac_exec_ext"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+ ;;
+esac
+fi
+PERL=$ac_cv_path_PERL
+
+if test -n "$PERL"; then
+ echo "$as_me:$LINENO: result: $PERL" >&5
+echo "${ECHO_T}$PERL" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+
+ ac_config_files="$ac_config_files Makefile subst pkginfo base/Makefile common/Makefile contrib/Makefile cgi/Makefile html/Makefile module/Makefile xdata/Makefile daemon-init t/Makefile t-tap/Makefile"
+
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=/{
+s/:*\$(srcdir):*/:/;
+s/:*\${srcdir}:*/:/;
+s/:*@srcdir@:*/:/;
+s/^\([^=]*=[ ]*\):*/\1/;
+s/:*$//;
+s/^[^=]*=[ ]*$//;
+}'
+fi
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+ # 1. Remove the extension, and $U if already installed.
+ ac_i=`echo "$ac_i" |
+ sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
+ # 2. Add them.
+ ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
+ ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+
+: ${CONFIG_STATUS=./config.status}
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
+echo "$as_me: creating $CONFIG_STATUS" >&6;}
+cat >$CONFIG_STATUS <<_ACEOF
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+ set -o posix
+fi
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+ LC_TELEPHONE LC_TIME
+do
+ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+ eval $as_var=C; export $as_var
+ else
+ $as_unset $as_var
+ fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)$' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+ /^X\/\(\/\/\)$/{ s//\1/; q; }
+ /^X\/\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ echo "#! /bin/sh" >conf$$.sh
+ echo "exit 0" >>conf$$.sh
+ chmod +x conf$$.sh
+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -f conf$$.sh
+fi
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" || {
+ # Find who we are. Look in the path if we contain no path at all
+ # relative or not.
+ case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+
+ ;;
+ esac
+ # We did not find ourselves, most probably we were run as `sh COMMAND'
+ # in which case we are not to be found in the path.
+ if test "x$as_myself" = x; then
+ as_myself=$0
+ fi
+ if test ! -f "$as_myself"; then
+ { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
+echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ case $CONFIG_SHELL in
+ '')
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for as_base in sh bash ksh sh5; do
+ case $as_dir in
+ /*)
+ if ("$as_dir/$as_base" -c '
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
+ $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+ $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+ CONFIG_SHELL=$as_dir/$as_base
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+ fi;;
+ esac
+ done
+done
+;;
+ esac
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line before each line; the second 'sed' does the real
+ # work. The second script uses 'N' to pair each line-number line
+ # with the numbered line, and appends trailing '-' during
+ # substitution so that $LINENO is not a special case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
+ sed '=' <$as_myself |
+ sed '
+ N
+ s,$,-,
+ : loop
+ s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+ t loop
+ s,-$,,
+ s,^['$as_cr_digits']*\n,,
+ ' >$as_me.lineno &&
+ chmod +x $as_me.lineno ||
+ { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
+echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensible to this).
+ . ./$as_me.lineno
+ # Exit status is that of the last command.
+ exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+ *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T=' ' ;;
+ *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+ *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+ # We could just check for DJGPP; but this test a) works b) is more generic
+ # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+ if test -f conf$$.exe; then
+ # Don't use ln at all; we don't have any links
+ as_ln_s='cp -p'
+ else
+ as_ln_s='ln -s'
+ fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" $as_nl"
+
+# CDPATH.
+$as_unset CDPATH
+
+exec 6>&1
+
+# Open the log real soon, to keep \$[0] and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling. Logging --version etc. is OK.
+exec 5>>config.log
+{
+ echo
+ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+} >&5
+cat >&5 <<_CSEOF
+
+This file was extended by $as_me, which was
+generated by GNU Autoconf 2.59. Invocation command line was
+
+ CONFIG_FILES = $CONFIG_FILES
+ CONFIG_HEADERS = $CONFIG_HEADERS
+ CONFIG_LINKS = $CONFIG_LINKS
+ CONFIG_COMMANDS = $CONFIG_COMMANDS
+ $ $0 $@
+
+_CSEOF
+echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
+echo >&5
+_ACEOF
+
+# Files that config.status was made for.
+if test -n "$ac_config_files"; then
+ echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_headers"; then
+ echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_links"; then
+ echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_commands"; then
+ echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+ac_cs_usage="\
+\`$as_me' instantiates files from templates according to the
+current configuration.
+
+Usage: $0 [OPTIONS] [FILE]...
+
+ -h, --help print this help, then exit
+ -V, --version print version number, then exit
+ -q, --quiet do not print progress messages
+ -d, --debug don't remove temporary files
+ --recheck update $as_me by reconfiguring in the same conditions
+ --file=FILE[:TEMPLATE]
+ instantiate the configuration file FILE
+ --header=FILE[:TEMPLATE]
+ instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Report bugs to ."
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+ac_cs_version="\\
+config.status
+configured by $0, generated by GNU Autoconf 2.59,
+ with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
+
+Copyright (C) 2003 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+srcdir=$srcdir
+INSTALL="$INSTALL"
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+# If no file are specified by the user, then we need to provide default
+# value. By we need to know if files were specified by the user.
+ac_need_defaults=:
+while test $# != 0
+do
+ case $1 in
+ --*=*)
+ ac_option=`expr "x$1" : 'x\([^=]*\)='`
+ ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
+ ac_shift=:
+ ;;
+ -*)
+ ac_option=$1
+ ac_optarg=$2
+ ac_shift=shift
+ ;;
+ *) # This is not an option, so the user has probably given explicit
+ # arguments.
+ ac_option=$1
+ ac_need_defaults=false;;
+ esac
+
+ case $ac_option in
+ # Handling of the options.
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ ac_cs_recheck=: ;;
+ --version | --vers* | -V )
+ echo "$ac_cs_version"; exit 0 ;;
+ --he | --h)
+ # Conflict between --help and --header
+ { { echo "$as_me:$LINENO: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&2;}
+ { (exit 1); exit 1; }; };;
+ --help | --hel | -h )
+ echo "$ac_cs_usage"; exit 0 ;;
+ --debug | --d* | -d )
+ debug=: ;;
+ --file | --fil | --fi | --f )
+ $ac_shift
+ CONFIG_FILES="$CONFIG_FILES $ac_optarg"
+ ac_need_defaults=false;;
+ --header | --heade | --head | --hea )
+ $ac_shift
+ CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
+ ac_need_defaults=false;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil | --si | --s)
+ ac_cs_silent=: ;;
+
+ # This is an error.
+ -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2;}
+ { (exit 1); exit 1; }; } ;;
+
+ *) ac_config_targets="$ac_config_targets $1" ;;
+
+ esac
+ shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+ exec 6>/dev/null
+ ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+if \$ac_cs_recheck; then
+ echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
+ exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+fi
+
+_ACEOF
+
+
+
+
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+for ac_config_target in $ac_config_targets
+do
+ case "$ac_config_target" in
+ # Handling of arguments.
+ "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+ "subst" ) CONFIG_FILES="$CONFIG_FILES subst" ;;
+ "pkginfo" ) CONFIG_FILES="$CONFIG_FILES pkginfo" ;;
+ "base/Makefile" ) CONFIG_FILES="$CONFIG_FILES base/Makefile" ;;
+ "common/Makefile" ) CONFIG_FILES="$CONFIG_FILES common/Makefile" ;;
+ "contrib/Makefile" ) CONFIG_FILES="$CONFIG_FILES contrib/Makefile" ;;
+ "cgi/Makefile" ) CONFIG_FILES="$CONFIG_FILES cgi/Makefile" ;;
+ "html/Makefile" ) CONFIG_FILES="$CONFIG_FILES html/Makefile" ;;
+ "module/Makefile" ) CONFIG_FILES="$CONFIG_FILES module/Makefile" ;;
+ "xdata/Makefile" ) CONFIG_FILES="$CONFIG_FILES xdata/Makefile" ;;
+ "daemon-init" ) CONFIG_FILES="$CONFIG_FILES daemon-init" ;;
+ "t/Makefile" ) CONFIG_FILES="$CONFIG_FILES t/Makefile" ;;
+ "t-tap/Makefile" ) CONFIG_FILES="$CONFIG_FILES t-tap/Makefile" ;;
+ "include/config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS include/config.h" ;;
+ "include/snprintf.h" ) CONFIG_HEADERS="$CONFIG_HEADERS include/snprintf.h" ;;
+ *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
+echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used. Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+ test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+ test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+fi
+
+# Have a temporary directory for convenience. Make it in the build tree
+# simply because there is no reason to put it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Create a temporary directory, and hook for its removal unless debugging.
+$debug ||
+{
+ trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
+ trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+
+# Create a (secure) tmp directory for tmp files.
+
+{
+ tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
+ test -n "$tmp" && test -d "$tmp"
+} ||
+{
+ tmp=./confstat$$-$RANDOM
+ (umask 077 && mkdir $tmp)
+} ||
+{
+ echo "$me: cannot create a temporary directory in ." >&2
+ { (exit 1); exit 1; }
+}
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+
+#
+# CONFIG_FILES section.
+#
+
+# No need to generate the scripts if there are no CONFIG_FILES.
+# This happens for instance when ./config.status config.h
+if test -n "\$CONFIG_FILES"; then
+ # Protect against being on the right side of a sed subst in config.status.
+ sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
+ s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
+s,@SHELL@,$SHELL,;t t
+s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
+s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
+s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
+s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
+s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
+s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
+s,@exec_prefix@,$exec_prefix,;t t
+s,@prefix@,$prefix,;t t
+s,@program_transform_name@,$program_transform_name,;t t
+s,@bindir@,$bindir,;t t
+s,@sbindir@,$sbindir,;t t
+s,@libexecdir@,$libexecdir,;t t
+s,@datadir@,$datadir,;t t
+s,@sysconfdir@,$sysconfdir,;t t
+s,@sharedstatedir@,$sharedstatedir,;t t
+s,@localstatedir@,$localstatedir,;t t
+s,@libdir@,$libdir,;t t
+s,@includedir@,$includedir,;t t
+s,@oldincludedir@,$oldincludedir,;t t
+s,@infodir@,$infodir,;t t
+s,@mandir@,$mandir,;t t
+s,@build_alias@,$build_alias,;t t
+s,@host_alias@,$host_alias,;t t
+s,@target_alias@,$target_alias,;t t
+s,@DEFS@,$DEFS,;t t
+s,@ECHO_C@,$ECHO_C,;t t
+s,@ECHO_N@,$ECHO_N,;t t
+s,@ECHO_T@,$ECHO_T,;t t
+s,@LIBS@,$LIBS,;t t
+s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
+s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
+s,@INSTALL_DATA@,$INSTALL_DATA,;t t
+s,@INSTALL@,$INSTALL,;t t
+s,@build@,$build,;t t
+s,@build_cpu@,$build_cpu,;t t
+s,@build_vendor@,$build_vendor,;t t
+s,@build_os@,$build_os,;t t
+s,@host@,$host,;t t
+s,@host_cpu@,$host_cpu,;t t
+s,@host_vendor@,$host_vendor,;t t
+s,@host_os@,$host_os,;t t
+s,@CC@,$CC,;t t
+s,@CFLAGS@,$CFLAGS,;t t
+s,@LDFLAGS@,$LDFLAGS,;t t
+s,@CPPFLAGS@,$CPPFLAGS,;t t
+s,@ac_ct_CC@,$ac_ct_CC,;t t
+s,@EXEEXT@,$EXEEXT,;t t
+s,@OBJEXT@,$OBJEXT,;t t
+s,@SET_MAKE@,$SET_MAKE,;t t
+s,@STRIP@,$STRIP,;t t
+s,@CPP@,$CPP,;t t
+s,@EGREP@,$EGREP,;t t
+s,@SNPRINTF_O@,$SNPRINTF_O,;t t
+s,@SOCKETLIBS@,$SOCKETLIBS,;t t
+s,@THREADLIBS@,$THREADLIBS,;t t
+s,@nagios_user@,$nagios_user,;t t
+s,@nagios_grp@,$nagios_grp,;t t
+s,@INSTALL_OPTS@,$INSTALL_OPTS,;t t
+s,@command_user@,$command_user,;t t
+s,@command_grp@,$command_grp,;t t
+s,@COMMAND_OPTS@,$COMMAND_OPTS,;t t
+s,@MAIL_PROG@,$MAIL_PROG,;t t
+s,@HTTPD_CONF@,$HTTPD_CONF,;t t
+s,@CHECKRESULTDIR@,$CHECKRESULTDIR,;t t
+s,@TMPDIR@,$TMPDIR,;t t
+s,@init_dir@,$init_dir,;t t
+s,@lockfile@,$lockfile,;t t
+s,@XSDC@,$XSDC,;t t
+s,@XSDH@,$XSDH,;t t
+s,@XCDC@,$XCDC,;t t
+s,@XCDH@,$XCDH,;t t
+s,@XRDC@,$XRDC,;t t
+s,@XRDH@,$XRDH,;t t
+s,@XODC@,$XODC,;t t
+s,@XODH@,$XODH,;t t
+s,@XPDC@,$XPDC,;t t
+s,@XPDH@,$XPDH,;t t
+s,@XDDC@,$XDDC,;t t
+s,@XDDH@,$XDDH,;t t
+s,@htmurl@,$htmurl,;t t
+s,@cgiurl@,$cgiurl,;t t
+s,@BROKER_LDFLAGS@,$BROKER_LDFLAGS,;t t
+s,@BROKERLIBS@,$BROKERLIBS,;t t
+s,@MOD_CFLAGS@,$MOD_CFLAGS,;t t
+s,@MOD_LDFLAGS@,$MOD_LDFLAGS,;t t
+s,@BROKER_O@,$BROKER_O,;t t
+s,@BROKER_H@,$BROKER_H,;t t
+s,@nagios_name@,$nagios_name,;t t
+s,@nagiostats_name@,$nagiostats_name,;t t
+s,@PATH_TO_TRACEROUTE@,$PATH_TO_TRACEROUTE,;t t
+s,@PACKDIR@,$PACKDIR,;t t
+s,@VERSION@,$VERSION,;t t
+s,@subdirs@,$subdirs,;t t
+s,@USE_LIBTAP@,$USE_LIBTAP,;t t
+s,@CGIEXTRAS@,$CGIEXTRAS,;t t
+s,@GDLIBS@,$GDLIBS,;t t
+s,@PERLLIBS@,$PERLLIBS,;t t
+s,@PERLDIR@,$PERLDIR,;t t
+s,@PERLXSI_O@,$PERLXSI_O,;t t
+s,@BASEEXTRALIBS@,$BASEEXTRALIBS,;t t
+s,@INITDIR@,$INITDIR,;t t
+s,@INSTALLPERLSTUFF@,$INSTALLPERLSTUFF,;t t
+s,@USE_EVENTBROKER@,$USE_EVENTBROKER,;t t
+s,@PERL@,$PERL,;t t
+s,@LIBOBJS@,$LIBOBJS,;t t
+s,@LTLIBOBJS@,$LTLIBOBJS,;t t
+CEOF
+
+_ACEOF
+
+ cat >>$CONFIG_STATUS <<\_ACEOF
+ # Split the substitutions into bite-sized pieces for seds with
+ # small command number limits, like on Digital OSF/1 and HP-UX.
+ ac_max_sed_lines=48
+ ac_sed_frag=1 # Number of current file.
+ ac_beg=1 # First line for current file.
+ ac_end=$ac_max_sed_lines # Line after last line for current file.
+ ac_more_lines=:
+ ac_sed_cmds=
+ while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+ else
+ sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+ fi
+ if test ! -s $tmp/subs.frag; then
+ ac_more_lines=false
+ else
+ # The purpose of the label and of the branching condition is to
+ # speed up the sed processing (if there are no `@' at all, there
+ # is no need to browse any of the substitutions).
+ # These are the two extra sed commands mentioned above.
+ (echo ':t
+ /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
+ fi
+ ac_sed_frag=`expr $ac_sed_frag + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_lines`
+ fi
+ done
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+ fi
+fi # test -n "$CONFIG_FILES"
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case $ac_file in
+ - | *:- | *:-:* ) # input from stdin
+ cat >$tmp/stdin
+ ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ * ) ac_file_in=$ac_file.in ;;
+ esac
+
+ # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
+ ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ { if $as_mkdir_p; then
+ mkdir -p "$ac_dir"
+ else
+ as_dir="$ac_dir"
+ as_dirs=
+ while test ! -d "$as_dir"; do
+ as_dirs="$as_dir $as_dirs"
+ as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ done
+ test ! -n "$as_dirs" || mkdir $as_dirs
+ fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+ { (exit 1); exit 1; }; }; }
+
+ ac_builddir=.
+
+if test "$ac_dir" != .; then
+ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+ ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+ .) # No --srcdir option. We are building in place.
+ ac_srcdir=.
+ if test -z "$ac_top_builddir"; then
+ ac_top_srcdir=.
+ else
+ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+ fi ;;
+ [\\/]* | ?:[\\/]* ) # Absolute path.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir ;;
+ *) # Relative path.
+ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+
+# Do not use `cd foo && pwd` to compute absolute paths, because
+# the directories may not exist.
+case `pwd` in
+.) ac_abs_builddir="$ac_dir";;
+*)
+ case "$ac_dir" in
+ .) ac_abs_builddir=`pwd`;;
+ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
+ *) ac_abs_builddir=`pwd`/"$ac_dir";;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_builddir=${ac_top_builddir}.;;
+*)
+ case ${ac_top_builddir}. in
+ .) ac_abs_top_builddir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
+ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_srcdir=$ac_srcdir;;
+*)
+ case $ac_srcdir in
+ .) ac_abs_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
+ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_srcdir=$ac_top_srcdir;;
+*)
+ case $ac_top_srcdir in
+ .) ac_abs_top_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
+ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
+ esac;;
+esac
+
+
+ case $INSTALL in
+ [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+ *) ac_INSTALL=$ac_top_builddir$INSTALL ;;
+ esac
+
+ if test x"$ac_file" != x-; then
+ { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+ rm -f "$ac_file"
+ fi
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated by config.status. */
+ if test x"$ac_file" = x-; then
+ configure_input=
+ else
+ configure_input="$ac_file. "
+ fi
+ configure_input=$configure_input"Generated from `echo $ac_file_in |
+ sed 's,.*/,,'` by configure."
+
+ # First look for the input files in the build tree, otherwise in the
+ # src tree.
+ ac_file_inputs=`IFS=:
+ for f in $ac_file_in; do
+ case $f in
+ -) echo $tmp/stdin ;;
+ [\\/$]*)
+ # Absolute (can't be DOS-style, as IFS=:)
+ test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ echo "$f";;
+ *) # Relative
+ if test -f "$f"; then
+ # Build tree
+ echo "$f"
+ elif test -f "$srcdir/$f"; then
+ # Source tree
+ echo "$srcdir/$f"
+ else
+ # /dev/null tree
+ { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ fi;;
+ esac
+ done` || { (exit 1); exit 1; }
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+ sed "$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s,@configure_input@,$configure_input,;t t
+s,@srcdir@,$ac_srcdir,;t t
+s,@abs_srcdir@,$ac_abs_srcdir,;t t
+s,@top_srcdir@,$ac_top_srcdir,;t t
+s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t
+s,@builddir@,$ac_builddir,;t t
+s,@abs_builddir@,$ac_abs_builddir,;t t
+s,@top_builddir@,$ac_top_builddir,;t t
+s,@abs_top_builddir@,$ac_abs_top_builddir,;t t
+s,@INSTALL@,$ac_INSTALL,;t t
+" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
+ rm -f $tmp/stdin
+ if test x"$ac_file" != x-; then
+ mv $tmp/out $ac_file
+ else
+ cat $tmp/out
+ rm -f $tmp/out
+ fi
+
+done
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+#
+# CONFIG_HEADER section.
+#
+
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)'
+ac_dB='[ ].*$,\1#\2'
+ac_dC=' '
+ac_dD=',;t'
+# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_uB='$,\1#\2define\3'
+ac_uC=' '
+ac_uD=',;t'
+
+for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case $ac_file in
+ - | *:- | *:-:* ) # input from stdin
+ cat >$tmp/stdin
+ ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ * ) ac_file_in=$ac_file.in ;;
+ esac
+
+ test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+
+ # First look for the input files in the build tree, otherwise in the
+ # src tree.
+ ac_file_inputs=`IFS=:
+ for f in $ac_file_in; do
+ case $f in
+ -) echo $tmp/stdin ;;
+ [\\/$]*)
+ # Absolute (can't be DOS-style, as IFS=:)
+ test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ # Do quote $f, to prevent DOS paths from being IFS'd.
+ echo "$f";;
+ *) # Relative
+ if test -f "$f"; then
+ # Build tree
+ echo "$f"
+ elif test -f "$srcdir/$f"; then
+ # Source tree
+ echo "$srcdir/$f"
+ else
+ # /dev/null tree
+ { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ fi;;
+ esac
+ done` || { (exit 1); exit 1; }
+ # Remove the trailing spaces.
+ sed 's/[ ]*$//' $ac_file_inputs >$tmp/in
+
+_ACEOF
+
+# Transform confdefs.h into two sed scripts, `conftest.defines' and
+# `conftest.undefs', that substitutes the proper values into
+# config.h.in to produce config.h. The first handles `#define'
+# templates, and the second `#undef' templates.
+# And first: Protect against being on the right side of a sed subst in
+# config.status. Protect against being in an unquoted here document
+# in config.status.
+rm -f conftest.defines conftest.undefs
+# Using a here document instead of a string reduces the quoting nightmare.
+# Putting comments in sed scripts is not portable.
+#
+# `end' is used to avoid that the second main sed command (meant for
+# 0-ary CPP macros) applies to n-ary macro definitions.
+# See the Autoconf documentation for `clear'.
+cat >confdef2sed.sed <<\_ACEOF
+s/[\\&,]/\\&/g
+s,[\\$`],\\&,g
+t clear
+: clear
+s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp
+t end
+s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
+: end
+_ACEOF
+# If some macros were called several times there might be several times
+# the same #defines, which is useless. Nevertheless, we may not want to
+# sort them, since we want the *last* AC-DEFINE to be honored.
+uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
+sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
+rm -f confdef2sed.sed
+
+# This sed command replaces #undef with comments. This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+cat >>conftest.undefs <<\_ACEOF
+s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
+_ACEOF
+
+# Break up conftest.defines because some shells have a limit on the size
+# of here documents, and old seds have small limits too (100 cmds).
+echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
+echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
+echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
+echo ' :' >>$CONFIG_STATUS
+rm -f conftest.tail
+while grep . conftest.defines >/dev/null
+do
+ # Write a limited-size here document to $tmp/defines.sed.
+ echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS
+ # Speed up: don't consider the non `#define' lines.
+ echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS
+ # Work around the forget-to-reset-the-flag bug.
+ echo 't clr' >>$CONFIG_STATUS
+ echo ': clr' >>$CONFIG_STATUS
+ sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
+ echo 'CEOF
+ sed -f $tmp/defines.sed $tmp/in >$tmp/out
+ rm -f $tmp/in
+ mv $tmp/out $tmp/in
+' >>$CONFIG_STATUS
+ sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
+ rm -f conftest.defines
+ mv conftest.tail conftest.defines
+done
+rm -f conftest.defines
+echo ' fi # grep' >>$CONFIG_STATUS
+echo >>$CONFIG_STATUS
+
+# Break up conftest.undefs because some shells have a limit on the size
+# of here documents, and old seds have small limits too (100 cmds).
+echo ' # Handle all the #undef templates' >>$CONFIG_STATUS
+rm -f conftest.tail
+while grep . conftest.undefs >/dev/null
+do
+ # Write a limited-size here document to $tmp/undefs.sed.
+ echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS
+ # Speed up: don't consider the non `#undef'
+ echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS
+ # Work around the forget-to-reset-the-flag bug.
+ echo 't clr' >>$CONFIG_STATUS
+ echo ': clr' >>$CONFIG_STATUS
+ sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
+ echo 'CEOF
+ sed -f $tmp/undefs.sed $tmp/in >$tmp/out
+ rm -f $tmp/in
+ mv $tmp/out $tmp/in
+' >>$CONFIG_STATUS
+ sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
+ rm -f conftest.undefs
+ mv conftest.tail conftest.undefs
+done
+rm -f conftest.undefs
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated by config.status. */
+ if test x"$ac_file" = x-; then
+ echo "/* Generated by configure. */" >$tmp/config.h
+ else
+ echo "/* $ac_file. Generated by configure. */" >$tmp/config.h
+ fi
+ cat $tmp/in >>$tmp/config.h
+ rm -f $tmp/in
+ if test x"$ac_file" != x-; then
+ if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
+ { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
+echo "$as_me: $ac_file is unchanged" >&6;}
+ else
+ ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ { if $as_mkdir_p; then
+ mkdir -p "$ac_dir"
+ else
+ as_dir="$ac_dir"
+ as_dirs=
+ while test ! -d "$as_dir"; do
+ as_dirs="$as_dir $as_dirs"
+ as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ done
+ test ! -n "$as_dirs" || mkdir $as_dirs
+ fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+ { (exit 1); exit 1; }; }; }
+
+ rm -f $ac_file
+ mv $tmp/config.h $ac_file
+ fi
+ else
+ cat $tmp/config.h
+ rm -f $tmp/config.h
+ fi
+done
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+{ (exit 0); exit 0; }
+_ACEOF
+chmod +x $CONFIG_STATUS
+ac_clean_files=$ac_clean_files_save
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded. So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status. When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+ ac_cs_success=:
+ ac_config_status_args=
+ test "$silent" = yes &&
+ ac_config_status_args="$ac_config_status_args --quiet"
+ exec 5>/dev/null
+ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+ exec 5>>config.log
+ # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+ # would make configure fail if this is the last instruction.
+ $ac_cs_success || { (exit 1); exit 1; }
+fi
+
+#
+# CONFIG_SUBDIRS section.
+#
+if test "$no_recursion" != yes; then
+
+ # Remove --cache-file and --srcdir arguments so they do not pile up.
+ ac_sub_configure_args=
+ ac_prev=
+ for ac_arg in $ac_configure_args; do
+ if test -n "$ac_prev"; then
+ ac_prev=
+ continue
+ fi
+ case $ac_arg in
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \
+ | --c=*)
+ ;;
+ --config-cache | -C)
+ ;;
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ ;;
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ ;;
+ *) ac_sub_configure_args="$ac_sub_configure_args $ac_arg" ;;
+ esac
+ done
+
+ # Always prepend --prefix to ensure using the same prefix
+ # in subdir configurations.
+ ac_sub_configure_args="--prefix=$prefix $ac_sub_configure_args"
+
+ ac_popdir=`pwd`
+ for ac_dir in : $subdirs; do test "x$ac_dir" = x: && continue
+
+ # Do not complain, so a configure script can configure whichever
+ # parts of a large source tree are present.
+ test -d $srcdir/$ac_dir || continue
+
+ { echo "$as_me:$LINENO: configuring in $ac_dir" >&5
+echo "$as_me: configuring in $ac_dir" >&6;}
+ { if $as_mkdir_p; then
+ mkdir -p "$ac_dir"
+ else
+ as_dir="$ac_dir"
+ as_dirs=
+ while test ! -d "$as_dir"; do
+ as_dirs="$as_dir $as_dirs"
+ as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ done
+ test ! -n "$as_dirs" || mkdir $as_dirs
+ fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+ { (exit 1); exit 1; }; }; }
+
+ ac_builddir=.
+
+if test "$ac_dir" != .; then
+ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+ ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+ .) # No --srcdir option. We are building in place.
+ ac_srcdir=.
+ if test -z "$ac_top_builddir"; then
+ ac_top_srcdir=.
+ else
+ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+ fi ;;
+ [\\/]* | ?:[\\/]* ) # Absolute path.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir ;;
+ *) # Relative path.
+ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+
+# Do not use `cd foo && pwd` to compute absolute paths, because
+# the directories may not exist.
+case `pwd` in
+.) ac_abs_builddir="$ac_dir";;
+*)
+ case "$ac_dir" in
+ .) ac_abs_builddir=`pwd`;;
+ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
+ *) ac_abs_builddir=`pwd`/"$ac_dir";;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_builddir=${ac_top_builddir}.;;
+*)
+ case ${ac_top_builddir}. in
+ .) ac_abs_top_builddir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
+ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_srcdir=$ac_srcdir;;
+*)
+ case $ac_srcdir in
+ .) ac_abs_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
+ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_srcdir=$ac_top_srcdir;;
+*)
+ case $ac_top_srcdir in
+ .) ac_abs_top_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
+ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
+ esac;;
+esac
+
+
+ cd $ac_dir
+
+ # Check for guested configure; otherwise get Cygnus style configure.
+ if test -f $ac_srcdir/configure.gnu; then
+ ac_sub_configure="$SHELL '$ac_srcdir/configure.gnu'"
+ elif test -f $ac_srcdir/configure; then
+ ac_sub_configure="$SHELL '$ac_srcdir/configure'"
+ elif test -f $ac_srcdir/configure.in; then
+ ac_sub_configure=$ac_configure
+ else
+ { echo "$as_me:$LINENO: WARNING: no configuration information is in $ac_dir" >&5
+echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2;}
+ ac_sub_configure=
+ fi
+
+ # The recursion is here.
+ if test -n "$ac_sub_configure"; then
+ # Make the cache file name correct relative to the subdirectory.
+ case $cache_file in
+ [\\/]* | ?:[\\/]* ) ac_sub_cache_file=$cache_file ;;
+ *) # Relative path.
+ ac_sub_cache_file=$ac_top_builddir$cache_file ;;
+ esac
+
+ { echo "$as_me:$LINENO: running $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&5
+echo "$as_me: running $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&6;}
+ # The eval makes quoting arguments work.
+ eval $ac_sub_configure $ac_sub_configure_args \
+ --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir ||
+ { { echo "$as_me:$LINENO: error: $ac_sub_configure failed for $ac_dir" >&5
+echo "$as_me: error: $ac_sub_configure failed for $ac_dir" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+
+ cd $ac_popdir
+ done
+fi
+
+
+
+perl subst include/locations.h
+perl subst html/config.inc.php
+
+
+echo ""
+echo "Creating sample config files in sample-config/ ..."
+
+perl subst sample-config/nagios.cfg
+perl subst sample-config/cgi.cfg
+perl subst sample-config/resource.cfg
+perl subst sample-config/httpd.conf
+perl subst sample-config/mrtg.cfg
+
+perl subst sample-config/template-object/templates.cfg
+perl subst sample-config/template-object/commands.cfg
+perl subst sample-config/template-object/timeperiods.cfg
+perl subst sample-config/template-object/contacts.cfg
+
+perl subst sample-config/template-object/localhost.cfg
+perl subst sample-config/template-object/windows.cfg
+perl subst sample-config/template-object/printer.cfg
+perl subst sample-config/template-object/switch.cfg
+
+
+
+
+echo ""
+echo ""
+echo "$as_me:$LINENO: result: *** Configuration summary for $PKG_NAME $PKG_VERSION $PKG_REL_DATE ***:" >&5
+echo "${ECHO_T}*** Configuration summary for $PKG_NAME $PKG_VERSION $PKG_REL_DATE ***:" >&6
+
+echo ""
+echo " General Options:"
+echo " -------------------------"
+
+echo "$as_me:$LINENO: result: Nagios executable: $nagios_name" >&5
+echo "${ECHO_T} Nagios executable: $nagios_name" >&6
+echo "$as_me:$LINENO: result: Nagios user/group: $nagios_user,$nagios_grp" >&5
+echo "${ECHO_T} Nagios user/group: $nagios_user,$nagios_grp" >&6
+echo "$as_me:$LINENO: result: Command user/group: $command_user,$command_grp" >&5
+echo "${ECHO_T} Command user/group: $command_user,$command_grp" >&6
+if test x$USEPERL = xyes; then
+if test x$PERLCACHE = xyes; then
+echo "$as_me:$LINENO: result: Embedded Perl: yes, with caching" >&5
+echo "${ECHO_T} Embedded Perl: yes, with caching" >&6
+else
+echo "$as_me:$LINENO: result: Embedded Perl: yes, without caching" >&5
+echo "${ECHO_T} Embedded Perl: yes, without caching" >&6
+fi
+else
+echo "$as_me:$LINENO: result: Embedded Perl: no" >&5
+echo "${ECHO_T} Embedded Perl: no" >&6
+fi
+if test x$USE_EVENTBROKER = xyes; then
+echo "$as_me:$LINENO: result: Event Broker: yes" >&5
+echo "${ECHO_T} Event Broker: yes" >&6
+else
+echo "$as_me:$LINENO: result: Event Broker: no" >&5
+echo "${ECHO_T} Event Broker: no" >&6
+fi
+echo "$as_me:$LINENO: result: Install \${prefix}: $prefix" >&5
+echo "${ECHO_T} Install \${prefix}: $prefix" >&6
+echo "$as_me:$LINENO: result: Lock file: $lockfile" >&5
+echo "${ECHO_T} Lock file: $lockfile" >&6
+echo "$as_me:$LINENO: result: Check result directory: $CHECKRESULTDIR" >&5
+echo "${ECHO_T} Check result directory: $CHECKRESULTDIR" >&6
+echo "$as_me:$LINENO: result: Init directory: $init_dir" >&5
+echo "${ECHO_T} Init directory: $init_dir" >&6
+echo "$as_me:$LINENO: result: Apache conf.d directory: $HTTPD_CONF" >&5
+echo "${ECHO_T} Apache conf.d directory: $HTTPD_CONF" >&6
+echo "$as_me:$LINENO: result: Mail program: $MAIL_PROG" >&5
+echo "${ECHO_T} Mail program: $MAIL_PROG" >&6
+echo "$as_me:$LINENO: result: Host OS: $host_os" >&5
+echo "${ECHO_T} Host OS: $host_os" >&6
+
+echo ""
+echo " Web Interface Options:"
+echo " ------------------------"
+
+echo "$as_me:$LINENO: result: HTML URL: http://localhost$htmurl/" >&5
+echo "${ECHO_T} HTML URL: http://localhost$htmurl/" >&6
+echo "$as_me:$LINENO: result: CGI URL: http://localhost$cgiurl/" >&5
+echo "${ECHO_T} CGI URL: http://localhost$cgiurl/" >&6
+echo "$as_me:$LINENO: result: Traceroute (used by WAP): $PATH_TO_TRACEROUTE" >&5
+echo "${ECHO_T} Traceroute (used by WAP): $PATH_TO_TRACEROUTE" >&6
+
+
+
+
+echo ""
+echo ""
+echo "Review the options above for accuracy. If they look okay,"
+echo "type 'make all' to compile the main program and CGIs."
+echo ""
+
diff --git a/configure.in b/configure.in
new file mode 100644
index 0000000..b575b02
--- /dev/null
+++ b/configure.in
@@ -0,0 +1,880 @@
+dnl Process this -*-m4-*- file with autoconf to produce a configure script.
+
+dnl Disable caching
+define([AC_CACHE_LOAD],)
+define([AC_CACHE_SAVE],)
+
+AC_INIT(base/nagios.c)
+AC_CONFIG_HEADER(include/config.h include/snprintf.h)
+AC_PREFIX_DEFAULT(/usr/local/nagios)
+
+PKG_NAME=nagios
+PKG_VERSION="3.5.1"
+PKG_HOME_URL="http://www.nagios.org/"
+PKG_REL_DATE="08-30-2013"
+
+dnl Figure out how to invoke "install" and what install options to use.
+AC_PROG_INSTALL
+AC_SUBST(INSTALL)
+
+dnl What OS are we running?
+AC_CANONICAL_HOST
+
+dnl Checks for programs.
+AC_PROG_CC
+AC_PROG_MAKE_SET
+AC_PATH_PROG([STRIP],[strip],[true])
+
+dnl Checks for header files.
+AC_HEADER_STDC
+AC_HEADER_TIME
+AC_HEADER_SYS_WAIT
+AC_CHECK_HEADERS(arpa/inet.h ctype.h dirent.h errno.h fcntl.h getopt.h grp.h libgen.h limits.h math.h netdb.h netinet/in.h pthread.h pthreads.h pwd.h regex.h signal.h socket.h stdarg.h string.h strings.h sys/mman.h sys/types.h sys/time.h sys/resource.h sys/wait.h sys/socket.h sys/stat.h sys/timeb.h sys/un.h sys/ipc.h sys/msg.h sys/poll.h syslog.h uio.h unistd.h locale.h wchar.h)
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_STRUCT_TM
+AC_STRUCT_TIMEZONE
+AC_TYPE_MODE_T
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+AC_TYPE_SIGNAL
+AC_TYPE_GETGROUPS
+
+
+dnl Check for asprintf() and friends...
+AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
+AC_TRY_LINK([#include
+va_list ap1,ap2;], [va_copy(ap1,ap2);],
+ac_cv_HAVE_VA_COPY=yes,
+ac_cv_HAVE_VA_COPY=no)])
+if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
+ AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
+else
+ AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
+ AC_TRY_LINK([#include
+ va_list ap1,ap2;], [__va_copy(ap1,ap2);],
+ ac_cv_HAVE___VA_COPY=yes,
+ ac_cv_HAVE___VA_COPY=no)])
+ if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
+ AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
+ fi
+fi
+
+AC_CHECK_FUNC(vsnprintf,,SNPRINTF_O=../common/snprintf.o)
+AC_CHECK_FUNC(snprintf,,SNPRINTF_O=../common/snprintf.o)
+AC_CHECK_FUNC(asprintf,,SNPRINTF_O=../common/snprintf.o)
+AC_CHECK_FUNC(vasprintf,,SNPRINTF_O=../common/snprintf.o)
+
+AC_CACHE_CHECK([for C99 vsnprintf],ac_cv_HAVE_C99_VSNPRINTF,[
+AC_TRY_RUN([
+#include
+#include
+void foo(const char *format, ...) {
+ va_list ap;
+ int len;
+ char buf[5];
+
+ va_start(ap, format);
+ len = vsnprintf(buf, 0, format, ap);
+ va_end(ap);
+ if (len != 5) exit(1);
+
+ va_start(ap, format);
+ len = vsnprintf(0, 0, format, ap);
+ va_end(ap);
+ if (len != 5) exit(1);
+
+ if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
+
+ exit(0);
+}
+main() { foo("hello"); }
+],
+ac_cv_HAVE_C99_VSNPRINTF=yes,ac_cv_HAVE_C99_VSNPRINTF=no,ac_cv_HAVE_C99_VSNPRINTF=cross)])
+if test x"$ac_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
+ AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Define if system has C99 compatible vsnprintf])
+fi
+
+dnl AC_CHECK_FUNC(snprintf,AC_DEFINE(HAVE_SNPRINTF),SNPRINTF_O=../common/snprintf.o)
+AC_SUBST(SNPRINTF_O)
+
+
+dnl Checks for library functions.
+AC_SEARCH_LIBS([getservbyname],[nsl],
+ [if test "$ac_cv_search_getservbyname" != "none required"; then
+ SOCKETLIBS="$SOCKETLIBS -lnsl"
+ fi])
+AC_SEARCH_LIBS([connect],[socket],
+ [if test "$ac_cv_search_connect" != "none required"; then
+ SOCKETLIBS="$SOCKETLIBS -lsocket"
+ fi])
+AC_SUBST(SOCKETLIBS)
+AC_CHECK_FUNCS(initgroups setenv strdup strstr strtoul unsetenv)
+
+AC_MSG_CHECKING(for type of socket size)
+AC_TRY_COMPILE([#include
+#include
+#include
+],
+[int a = send(1, (const void *) 0, (size_t) 0, (int) 0);],
+[AC_DEFINE(SOCKET_SIZE_TYPE, size_t, [typedef for socket size]) AC_MSG_RESULT(size_t)],
+[AC_DEFINE(SOCKET_SIZE_TYPE, int, [typedef for socket size]) AC_MSG_RESULT(int)])
+
+
+dnl Test for pthreads support - taken from ICU FreeBSD Port configure script
+THREADLIBS=""
+have_pthreads="no"
+
+dnl FreeBSD: Try ports/linuxthreads first - Mammad Zadeh
+dnl FreeBSD -pthread check - Jonathan McDowell
+AC_DEFUN([AC_PTHREAD_FREEBSD],[
+ AC_CHECK_LIB(lthread,pthread_create,[
+ CFLAGS="-D_THREAD_SAFE -I/usr/local/include/pthread/linuxthreads -I/usr/include $CFLAGS"
+ THREADLIBS="-L/usr/local/lib -llthread -llgcc_r"
+ ],[
+ AC_MSG_CHECKING([if we need -pthread for threads])
+ AC_CACHE_VAL(ac_ldflag_pthread,[
+ ac_save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="-pthread $LDFLAGS"
+ AC_TRY_LINK([
+ char pthread_create();
+ ],
+ pthread_create();,
+ eval "ac_ldflag_pthread=yes",
+ eval "ac_ldflag_pthread=no"
+ ),
+ THREADLIBS="$ac_save_LDFLAGS"
+ ])
+ if eval "test \"`echo $ac_ldflag_pthread`\" = yes"; then
+ AC_MSG_RESULT(yes)
+ else
+ AC_MSG_RESULT(no)
+ fi
+ ],-L/usr/local/lib)
+ ])
+
+dnl Test for HPUX cma threads first..
+AC_CHECK_LIB(cma,pthread_create,THREADLIBS="$THREADLIBS -lpthread")
+if test $ac_cv_lib_cma_pthread_create = yes; then
+ have_pthreads="yes"
+fi
+
+dnl special pthread handling
+dnl AIX uses pthreads instead of pthread, and HP/UX uses cma
+dnl FreeBSD users -pthread
+AC_CHECK_LIB(pthread,pthread_create,THREADLIBS="$THREADLIBS -lpthread")
+if test $ac_cv_lib_pthread_pthread_create = yes; then
+ have_pthreads="yes"
+else
+ dnl For HP 11
+ AC_CHECK_LIB(pthread,pthread_mutex_init,THREADLIBS="$THREADLIBS -lpthread")
+ if test $ac_cv_lib_pthread_pthread_mutex_init = yes; then
+ have_pthreads="yes"
+ fi
+fi
+
+dnl AIX uses pthreads instead of pthread
+if test $have_pthreads = "no"; then
+ AC_CHECK_LIB(pthreads,pthread_create,THREADLIBS="$THREADLIBS -lpthreads")
+ if test $ac_cv_lib_pthreads_pthread_create = yes; then
+ have_pthreads="yes"
+ fi
+fi
+
+dnl all other thread tests fail, try BSD's -pthread
+if test $have_pthreads = "no"; then
+ AC_PTHREAD_FREEBSD
+fi
+
+AC_SUBST(THREADLIBS)
+
+dnl Solaris needs rt or posix4 libraries for nanosleep()
+AC_SEARCH_LIBS(nanosleep,[rt posix4],,[
+ echo "Error: nanosleep() needed for timing operations."
+ exit 1
+ ])
+
+AC_ARG_WITH(nagios_user,AC_HELP_STRING([--with-nagios-user=],[sets user name to run nagios]),nagios_user=$withval,nagios_user=nagios)
+AC_ARG_WITH(nagios_group,AC_HELP_STRING([--with-nagios-group=],[sets group name to run nagios]),nagios_grp=$withval,nagios_grp=nagios)
+AC_SUBST(nagios_user)
+AC_SUBST(nagios_grp)
+AC_DEFINE_UNQUOTED(DEFAULT_NAGIOS_USER,"$nagios_user",[user name to run nagios])
+AC_DEFINE_UNQUOTED(DEFAULT_NAGIOS_GROUP,"$nagios_grp",[group name to run nagios])
+INSTALL_OPTS="-o $nagios_user -g $nagios_grp"
+AC_SUBST(INSTALL_OPTS)
+
+AC_ARG_WITH(command_user,AC_HELP_STRING([--with-command-user=],[sets user name for command access]),command_user=$withval,command_user=$nagios_user)
+AC_ARG_WITH(command_group,AC_HELP_STRING([--with-command-group=],[sets group name for command access]),command_grp=$withval,command_grp=$nagios_grp)
+AC_SUBST(command_user)
+AC_SUBST(command_grp)
+COMMAND_OPTS="-o $command_user -g $command_grp"
+AC_SUBST(COMMAND_OPTS)
+
+dnl Check for location of mail program
+MAIL_PROG=no
+AC_ARG_WITH(mail,--with-mail= sets path to equivalent program to mail,MAIL_PROG=$withval,MAIL_PROG=no)
+if test x$MAIL_PROG = xno; then
+ AC_PATH_PROG(MAIL_PROG,mail)
+fi
+dnl Fix for systems that don't (yet) have mail/mailx installed...
+if test x$MAIL_PROG = x; then
+ MAIL_PROG="/bin/mail"
+fi
+AC_SUBST(MAIL_PROG)
+
+dnl Check for location of Apache conf.d directory
+HTTP_CONF=no
+AC_ARG_WITH(httpd_conf,--with-httpd-conf= sets path to Apache conf.d directory,HTTPD_CONF=$withval,HTTPD_CONF=no)
+if test x$HTTPD_CONF = xno; then
+ if test -d /etc/httpd/conf.d; then
+ HTTPD_CONF="/etc/httpd/conf.d"
+ elif test -d /etc/apache2/conf.d; then
+ HTTPD_CONF="/etc/apache2/conf.d"
+ elif test -d /etc/apache/conf.d; then
+ HTTPD_CONF="/etc/apache/conf.d"
+ else
+ HTTPD_CONF="/etc/httpd/conf.d"
+ fi
+fi
+AC_SUBST(HTTPD_CONF)
+
+dnl Location of check result path
+CHECKRESULTDIR=no
+AC_ARG_WITH(checkresult-dir,--with-checkresult-dir= sets path to check results spool directory,CHECKRESULTDIR=$withval,CHECKRESULTDIR=no)
+if test x$CHECKRESULTDIR = xno; then
+ CHECKRESULTDIR="$localstatedir/spool/checkresults"
+fi
+AC_SUBST(CHECKRESULTDIR)
+
+dnl Location of check result path
+TMPDIR=no
+AC_ARG_WITH(temp-dir,--with-temp-dir= sets path to temp directory,TMPDIR=$withval,TMPDIR=no)
+if test x$TMPDIR = xno; then
+ TMPDIR="/tmp"
+fi
+AC_SUBST(TMPDIR)
+
+dnl Check for location of init scripts
+init_dir=/etc/rc.d/init.d
+if test -d /etc/rc.d/init.d; then
+ init_dir="/etc/rc.d/init.d"
+elif test -d /usr/local/etc/rc.d; then
+ init_dir="/usr/local/etc/rc.d"
+elif test -d /etc/rc.d; then
+ init_dir="/etc/rc.d"
+elif test -d /etc/init.d; then
+ init_dir="/etc/init.d"
+elif test -d /sbin/init.d; then
+ init_dir="/sbin/init.d"
+fi
+
+dnl User can override init script location
+AC_ARG_WITH(init_dir,--with-init-dir= sets directory to place init script into,init_dir=$withval)
+AC_SUBST(init_dir)
+
+dnl User can override lock file location
+AC_ARG_WITH(lockfile,--with-lockfile= sets path and file name for lock file,lockfile=$withval,lockfile=$localstatedir/nagios.lock)
+AC_SUBST(lockfile)
+
+
+
+dnl Default xdata routines...
+XSDTYPE=default
+XCDTYPE=default
+XRDTYPE=default
+XODTYPE=template
+XPDTYPE=default
+XDDTYPE=default
+
+XSDCOMMENT=
+XCDCOMMENT=
+XRDCOMMENT=
+XODCOMMENT=
+XPDCOMMENT=
+XDDCOMMENT=
+
+USE_MYSQL=no
+USE_PGSQL=no
+
+dnl Status data
+AC_DEFINE_UNQUOTED(USE_XSDDEFAULT,,[use default routines (in xdata/xsddefault.*) for status data I/O...])
+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_SUBST(XSDC)
+AC_SUBST(XSDH)
+
+
+dnl Comment data
+AC_DEFINE_UNQUOTED(USE_XCDDEFAULT,,[use default routines (in xdata/xcddefault.*) for comment data I/O...])
+XCDC="xcddefault.c"
+XCDH="xcddefault.h"
+XCDCOMMENT="Default (text file)"
+echo "We'll use default routines (in xdata/xcddefault.*) for comment data I/O..."
+AC_SUBST(XCDC)
+AC_SUBST(XCDH)
+
+
+dnl Retention data
+AC_DEFINE_UNQUOTED(USE_XRDDEFAULT,,[use default routines (in xdata/xrddefault.*) for retention data I/O...])
+XRDC="xrddefault.c"
+XRDH="xrddefault.h"
+XRDCOMMENT="Default (text file)"
+echo "We'll use default routines (in xdata/xrddefault.*) for retention data I/O..."
+AC_SUBST(XRDC)
+AC_SUBST(XRDH)
+
+
+dnl Object data
+AC_DEFINE_UNQUOTED(USE_XODTEMPLATE,,[use template-based routines (in xdata/xodtemplate.*) for object data I/O...])
+XODC="xodtemplate.c"
+XODH="xodtemplate.h"
+XODCOMMENT="Template-based (text file)"
+echo "We'll use template-based routines (in xdata/xodtemplate.*) for object data I/O..."
+AC_SUBST(XODC)
+AC_SUBST(XODH)
+
+
+
+dnl Performance data
+AC_DEFINE_UNQUOTED(USE_XPDDEFAULT,,[use default routines (in xdata/xpddefault.*) for performance data I/O...])
+XPDC="xpddefault.c"
+XPDH="xpddefault.h"
+XPDCOMMENT="Default (external commands)"
+echo "We'll use default routines (in xdata/xpddefault.*) for performance data I/O..."
+AC_SUBST(XPDC)
+AC_SUBST(XPDH)
+
+
+dnl Downtime data
+AC_DEFINE_UNQUOTED(USE_XDDDEFAULT,,[use default routines (in xdata/xdddefault.*) for scheduled downtime data I/O...])
+XDDC="xdddefault.c"
+XDDH="xdddefault.h"
+XDDCOMMENT="Default (text file)"
+echo "We'll use default routines (in xdata/xdddefault.*) for scheduled downtime data I/O..."
+AC_SUBST(XDDC)
+AC_SUBST(XDDH)
+
+
+dnl Optional GD library and include paths
+AC_ARG_WITH(gd-lib,--with-gd-lib=DIR sets location of the gd library,[
+ LDFLAGS="${LDFLAGS} -L${withval}"
+ LD_RUN_PATH="${withval}${LD_RUN_PATH:+:}${LD_RUN_PATH}"
+ ])
+AC_ARG_WITH(gd-inc,--with-gd-inc=DIR sets location of the gd include files,[
+ CFLAGS="${CFLAGS} -I${withval}"
+ ])
+
+
+TRYGD=yep
+
+dnl statusmap CGI enabled by default, unless users chooses not to use it
+TRYSTATUSMAP=yep
+AC_ARG_ENABLE(statusmap,--disable-statusmap=disables compilation of statusmap CGI,TRYSTATUSMAP=nope)
+
+
+dnl statuswrl CGI enabled by default, unless users chooses not to use it
+TRYSTATUSWRL=yep
+AC_ARG_ENABLE(statuswrl,--disable-statuswrl=disables compilation of statuswrl (VRML) CGI,TRYSTATUSWRL=nope)
+
+if test x$TRYSTATUSWRL = xyep; then
+ AC_DEFINE_UNQUOTED(USE_STATUSWRL,,[statuswrl CGI enabled by default, unless users chooses not to use it])
+ CGIEXTRAS="$CGIEXTRAS statuswrl.cgi"
+fi
+
+
+dnl JMD_CHECK_LIB_ORDER(LIBRARY, FUNCTION, ORDER [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
+dnl [, OTHER-LIBRARIES]]])
+ AC_DEFUN([JMD_CHECK_LIB_ORDER],
+ [AC_MSG_CHECKING([for $2 in -l$1 (order $3)])
+ dnl Use a cache variable name containing both the library and function name,
+ dnl because the test really is for library $1 defining function $2, not
+ dnl just for library $1. Separate tests with the same $1 and different $2s
+ dnl may have different results.
+ ac_lib_var=`echo $1['_']$2['_']$3 | sed 'y%./+-%__p_%'`
+ AC_CACHE_VAL(ac_cv_lib_$ac_lib_var,
+ [ac_save_LIBS="$LIBS"
+ LIBS="-l$1 $6 $LIBS"
+ AC_TRY_LINK(dnl
+ ifelse([AC_LANG], [FORTRAN77], ,
+ ifelse([$2], [main], , dnl Avoid conflicting decl of main.
+[/* Override any gcc2 internal prototype to avoid an error. */
+]ifelse([AC_LANG], CPLUSPLUS, [#ifdef __cplusplus
+extern "C"
+#endif
+])dnl
+[/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $2();
+])),
+ [$2()],
+ eval "ac_cv_lib_$ac_lib_var=yes",
+ eval "ac_cv_lib_$ac_lib_var=no")
+ LIBS="$ac_save_LIBS"
+ ])dnl
+ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ AC_MSG_RESULT(yes)
+ ifelse([$4], ,
+ [changequote(, )dnl
+ ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+ changequote([, ])dnl
+ AC_DEFINE_UNQUOTED($ac_tr_lib)
+ LIBS="-l$1 $LIBS"
+ ], [$4])
+ else
+ AC_MSG_RESULT(no)
+ ifelse([$5], , , [$5
+ ])dnl
+ fi
+ ])
+
+
+
+dnl Should we try and detect the GD libs?
+if test x$TRYGD = xyep; then
+
+ dnl libiconv is required on some systems - tack it on if found
+ AC_CHECK_LIB(iconv,main,ICONV=-liconv,)
+
+ dnl See if the GD lib is available and supports PNG images...
+
+ dnl GD > 1.8.3 requires the TrueType library to be present as well, so test for that first...
+ JMD_CHECK_LIB_ORDER(gd,gdImagePng,1,[
+ GDLIBFOUND=yep
+ GDLIBS="-lgd -lttf -lpng -ljpeg -lz -lm"
+ ],:,[-lttf -lpng -ljpeg -lz -lm])
+
+ dnl GD > 1.8.1 requires the jpeg library to be present as well, so test for that...
+ if test x$GDLIBFOUND = x; then
+ JMD_CHECK_LIB_ORDER(gd,gdImagePng,2,[
+ GDLIBFOUND=yep
+ GDLIBS="-lgd $ICONV -lpng -ljpeg -lz -lm"
+ ],:,[$ICONV -lpng -ljpeg -lz -lm])
+ fi
+
+ dnl If we failed the first test, try without jpeg library
+ if test x$GDLIBFOUND = x; then
+ JMD_CHECK_LIB_ORDER(gd,gdImagePng,3,[
+ GDLIBFOUND=yep
+ GDLIBS="-lgd $ICONV -lz -lm -lpng"
+ ],:,[$ICONV -lz -lm -lpng])
+ fi
+
+ dnl We failed again, so try a different library ordering (without jpeg libs)
+ if test x$GDLIBFOUND = x; then
+ JMD_CHECK_LIB_ORDER(gd,gdImagePng,4,[
+ GDLIBFOUND=yep
+ GDLIBS="-lgd $ICONV -lpng -lz -lm"
+ ],:,[$ICONV -lpng -lz -lm])
+ fi
+
+ dnl Did we find the necessary GD libraries?
+ if test x$GDLIBFOUND = x; then
+ echo ""
+ echo ""
+ echo "*** GD, PNG, and/or JPEG libraries could not be located... *********"
+ echo ""
+ echo "Boutell's GD library is required to compile the statusmap, trends"
+ echo "and histogram CGIs. Get it from http://www.boutell.com/gd/, compile"
+ echo "it, and use the --with-gd-lib and --with-gd-inc arguments to specify"
+ echo "the locations of the GD library and include files."
+ echo ""
+ echo "NOTE: In addition to the gd-devel library, you'll also need to make"
+ echo " sure you have the png-devel and jpeg-devel libraries installed"
+ echo " on your system."
+ echo ""
+ echo "NOTE: After you install the necessary libraries on your system:"
+ echo " 1. Make sure /etc/ld.so.conf has an entry for the directory in"
+ echo " which the GD, PNG, and JPEG libraries are installed."
+ echo " 2. Run 'ldconfig' to update the run-time linker options."
+ echo " 3. Run 'make clean' in the Nagios distribution to clean out"
+ echo " any old references to your previous compile."
+ echo " 4. Rerun the configure script."
+ echo ""
+ echo "NOTE: If you can't get the configure script to recognize the GD libs"
+ echo " on your system, get over it and move on to other things. The"
+ echo " CGIs that use the GD libs are just a small part of the entire"
+ echo " Nagios package. Get everything else working first and then"
+ echo " revisit the problem. Make sure to check the nagios-users"
+ echo " mailing list archives for possible solutions to GD library"
+ echo " problems when you resume your troubleshooting."
+ echo ""
+ echo "********************************************************************"
+ echo ""
+ echo ""
+
+ dnl We found the GD lib!
+ else
+ echo "GD library was found!"
+ if test x$TRYSTATUSMAP = xyep; then
+ AC_DEFINE_UNQUOTED(USE_STATUSMAP,,[defined if the user chose to include status map])
+ CGIEXTRAS="$CGIEXTRAS statusmap.cgi"
+ AC_CHECK_LIB(gd,gdImageCreateTrueColor,
+ AC_DEFINE(HAVE_GDIMAGECREATETRUECOLOR,1,
+ [Define if your gd library has gdImageCreateTrueColor]))
+ fi
+
+ dnl compile trends CGI
+ AC_DEFINE_UNQUOTED(USE_TRENDS,,[compile trends CGI])
+ CGIEXTRAS="$CGIEXTRAS trends.cgi"
+
+ dnl compile histogram CGI
+ AC_DEFINE_UNQUOTED(USE_HISTOGRAM,,[compile histogram CGI])
+ CGIEXTRAS="$CGIEXTRAS histogram.cgi"
+ fi
+fi
+
+AC_ARG_WITH(cgiurl,--with-cgiurl= sets URL for cgi programs (do not use a trailing slash),cgiurl=$withval,cgiurl=/nagios/cgi-bin)
+AC_ARG_WITH(htmurl,--with-htmurl= sets URL for public html,htmurl=$withval,htmurl=/nagios)
+AC_SUBST(htmurl)
+AC_SUBST(cgiurl)
+
+USE_NANOSLEEP=yes
+AC_ARG_ENABLE(nanosleep,--enable-nanosleep enables use of nanosleep (instead of sleep) in event timing,USE_NANOSLEEP=$enableval,USE_NANOSLEEP=yes)
+if test x$USE_NANOSLEEP = xyes; then
+ AC_DEFINE_UNQUOTED(USE_NANOSLEEP,,[enables use of nanosleep (instead of sleep)])
+fi
+
+USE_EVENTBROKER=yes
+AC_ARG_ENABLE(event-broker,--enable-event-broker enables integration of event broker routines,USE_EVENTBROKER=$enableval,USE_EVENTBROKER=yes)
+
+BROKER_LDFLAGS=""
+BROKERLIBS="";
+some_dl_found="no";
+if test x$USE_EVENTBROKER = xyes; then
+
+ dnl Which loader library should we use? libtdl or dl?
+ dnl Hopefully this will be portable and not give us headaches...
+ AC_CHECK_HEADER(ltdl.h,[
+ AC_CHECK_LIB(ltdl,lt_dlinit,[
+ AC_DEFINE(HAVE_LTDL_H,,[Which loader library should we use? libtdl or dl?])
+ some_dl_found="yes"
+ BROKERLIBS="$BROKERLIBS -lltdl"
+ ])
+ ])
+ if test "x$some_dl_found" != xyes; then
+ AC_CHECK_HEADER(dlfcn.h,[
+ AC_CHECK_LIB(dl,dlopen,[
+ AC_DEFINE(HAVE_DLFCN_H,,[Which loader library should we use? libtdl or dl?])
+ some_dl_found="yes"
+ BROKERLIBS="$BROKERLIBS -ldl"
+ ])
+ ])
+ fi
+
+ dnl - Modified from www.erlang.org
+ # Check how to export functions from the broker executable, needed
+ # when dynamically loaded drivers are loaded (so that they can find
+ # broker functions).
+ # OS'es with ELF executables using the GNU linker (Linux and recent *BSD,
+ # in rare cases Solaris) typically need '-Wl,-export-dynamic' (i.e. pass
+ # -export-dynamic to the linker - also known as -rdynamic and some other
+ # variants); some sysVr4 system(s) instead need(s) '-Wl,-Bexport'.
+ # AIX 4.x (perhaps only for x>=2) wants -Wl,-bexpall,-brtl and doesn't
+ # reliably return an error for others, thus we separate it out.
+ # Otherwise we assume that if the linker accepts the flag, it is needed.
+ AC_MSG_CHECKING(for extra flags needed to export symbols)
+ case $host_os in
+ aix4*|aix5*)
+ BROKER_LDFLAGS="$BROKER_LDFLAGS -Wl,-bexpall,-brtl"
+ ;;
+ bsdi*)
+ BROKER_LDFLAGS="$BROKER_LDFLAGS -rdynamic"
+ ;;
+ *)
+ save_ldflags="$LDFLAGS"
+ LDFLAGS=-Wl,-export-dynamic
+ AC_TRY_LINK(,,[BROKER_LDFLAGS="$BROKER_LDFLAGS -Wl,-export-dynamic"], [
+ LDFLAGS=-Wl,-Bexport
+ AC_TRY_LINK(,,[BROKER_LDFLAGS="$BROKER_LDFLAGS -Wl,-Bexport"],
+ AC_MSG_RESULT(none))])
+ LDFLAGS="$save_ldflags"
+ ;;
+ esac
+ AC_SUBST(BROKER_LDFLAGS)
+ AC_SUBST(BROKERLIBS)
+ test "x$BROKER_LDFLAGS" != x && AC_MSG_RESULT([$BROKER_LDFLAGS])
+
+
+ dnl - Modified version from www.erlang.org
+ dnl - Some 12/15/05 mods made after reading http://xaxxon.slackworks.com/phuku/dl.html
+ AC_MSG_CHECKING(for linker flags for loadable modules)
+ case $host_os in
+ solaris2*|sysv4*)
+ MOD_LDFLAGS="-G"
+ ;;
+ aix4*|aix5*)
+ #MOD_LDFLAGS="-G -bnoentry -bexpall"
+ MOD_LDFLAGS="-G -bM:SRE -bnoentry -bexpall"
+ ;;
+ freebsd2*)
+ # Non-ELF GNU linker
+ MOD_LDFLAGS="-Bshareable"
+ ;;
+ darwin*)
+ # Mach-O linker, a shared lib and a loadable
+ # object file is not the same thing.
+ MOD_LDFLAGS="-bundle -flat_namespace -undefined suppress"
+ MOD_CFLAGS="$MOD_CFLAGS -fno-common"
+ ;;
+ linux* | k*bsd*-gnu*)
+ # assume GNU linker and ELF
+ MOD_LDFLAGS="-shared"
+ MOD_CFLAGS="-fPIC"
+ ;;
+ freebsd*)
+ MOD_LDFLAGS="-shared"
+ MOD_CFLAGS="-fPIC"
+ ;;
+ *)
+ # assume GNU linker and ELF
+ MOD_LDFLAGS="-shared"
+ ;;
+ esac
+ AC_MSG_RESULT([$MOD_LDFLAGS])
+ AC_SUBST(MOD_CFLAGS)
+ AC_SUBST(MOD_LDFLAGS)
+
+
+ AC_DEFINE_UNQUOTED(USE_EVENT_BROKER,,[defined to bring in the event broker objects])
+ BROKER_O="broker.o nebmods.o"
+ AC_SUBST(BROKER_O)
+ BROKER_H="../include/broker.h ../include/nebmods.h ../include/nebmodules.h ../include/nebcallbacks.h ../include/neberrors.h"
+ AC_SUBST(BROKER_H)
+fi
+
+
+USEPERL=no;
+INSTALLPERLSTUFF=no;
+AC_ARG_ENABLE(embedded-perl,--enable-embedded-perl will enable embedded Perl interpreter,[
+ USEPERL=$enableval
+ ]
+ ,USEPERL=no)
+
+PERLCACHE=yes;
+AC_ARG_WITH(perlcache,--with-perlcache turns on cacheing of internally compiled Perl scripts,[
+ PERLCACHE=$withval
+ ]
+ ,[
+ AC_DEFINE(DO_CLEAN,"1",[whether to clean cached compiled perl])
+ PERLCACHE=yes;
+ ])
+
+dnl Is embedded Perl being compiled in?
+if test x$USEPERL = xyes; then
+
+ AC_DEFINE_UNQUOTED(EMBEDDEDPERL,,[Is embedded Perl being compiled in?])
+ PERLLIBS="`perl -MExtUtils::Embed -e ldopts`"
+ PERLDIR="`perl -MConfig -e 'print $Config{installsitearch}'`"
+ CFLAGS="${CFLAGS} `perl -MExtUtils::Embed -e ccopts`"
+ USEPERL=yes
+ INSTALLPERLSTUFF=yes;
+ PERLXSI_O=perlxsi.o
+ OBJS="${OBJS} ${PERLXSI_O}"
+ echo "creating base/perlxsi.c"
+ perl -MExtUtils::Embed -e xsinit -- -o base/perlxsi.c
+
+ echo "Embedded Perl interpreter will be compiled in..."
+
+ dnl Is caching enabled?
+ if test x$PERLCACHE = xyes; then
+ AC_DEFINE(DO_CLEAN,"0",[whether to clean cached compiled perl])
+ PERLCACHE=yes;
+ echo "Internally compiled Perl scripts will be cached..."
+ else
+ AC_DEFINE(DO_CLEAN,"1",[whether to clean cached compiled perl])
+ echo "Internally compiled Perl scripts will NOT be cached..."
+ fi
+fi
+
+dnl Test if we're using threaded Perl (patch by Chip Ach)
+if test x$USEPERL = xyes; then
+ if (perl -e 'use Config;exit -1 unless ($Config{'usethreads'});'); then
+ echo "Using threaded perl"
+ AC_DEFINE_UNQUOTED(THREADEDPERL,,[defined if we're using threaded Perl])
+ fi
+fi
+
+
+dnl Option for compiling under CYGWIN
+nagios_name=nagios
+nagiostats_name=nagiostats
+cygwin=no
+AC_ARG_ENABLE(cygwin,--enable-cygwin enables building under the CYGWIN environment,[
+ cygwin=$enableval
+ ])
+if test x$cygwin = xyes; then
+ CFLAGS="${CFLAGS} -DCYGWIN"
+ nagios_name=nagios.exe;
+ nagiostats_name=nagiostats.exe;
+fi
+AC_SUBST(nagios_name)
+AC_SUBST(nagiostats_name)
+
+
+dnl Should predictive failure routines be compiled in?
+dnl AC_ARG_ENABLE(failure-prediction,--enable-failure-prediction will enable integration with failure prediction module (NOT HERE YET!),[
+dnl AC_DEFINE_UNQUOTED(PREDICT_FAILURES)
+dnl BASEEXTRALIBS="$BASEEXTRALIBS \$(FDATALIBS)"
+dnl echo "Failure prediction routines (incomplete!) will be compiled in..."
+dnl ])
+
+dnl Find traceroute
+AC_PATH_PROG(PATH_TO_TRACEROUTE,traceroute)
+AC_DEFINE_UNQUOTED(TRACEROUTE_COMMAND,"$PATH_TO_TRACEROUTE",[traceroute command to use])
+
+
+
+dnl Package directory for Solaris pkgmk (and other OSs, eventually)
+dnl VERSION=`grep 1.0 include/common.h | cut -d ' ' -f 3 | sed 's/"//g'`
+VERSION=$PKG_VERSION
+PACKDIR=`pwd`/pkg
+AC_SUBST(PACKDIR)
+AC_SUBST(VERSION)
+
+AC_MSG_CHECKING(for type va_list)
+AC_TRY_COMPILE([#ifdef __STDC__
+#include
+#include
+#include
+#else
+#include
+#include
+#include
+#endif],
+[va_list args;],
+[AC_MSG_RESULT(yes)],
+[AC_DEFINE(NEED_VA_LIST,,[defined if va_list fails to compile]) AC_MSG_RESULT(no)])
+
+dnl Check if we should build local libtap
+dnl From Nagios Plugins
+dnl Have disabled autodetection of system library until later
+AC_ARG_ENABLE(libtap,
+ AC_HELP_STRING([--enable-libtap],
+ [Enable built-in libtap for unit-testing (default: no).]),
+ [enable_libtap=$enableval],
+ [enable_libtap=no])
+#Disabled for moment
+#AM_CONDITIONAL([USE_LIBTAP_LOCAL],[test "$enable_libtap" = "yes"])
+
+# Disabled for moment
+# If not local, check if we can use the system one
+#if test "$enable_libtap" != "yes" ; then
+# dnl Check for libtap, to run perl-like tests
+# AC_CHECK_LIB(tap, plan_tests,
+# enable_libtap="yes"
+# )
+#fi
+
+# Finally, define tests if we use libtap
+if test "$enable_libtap" = "yes" ; then
+ AC_CONFIG_SUBDIRS([tap])
+ USE_LIBTAP=yes
+else
+ USE_LIBTAP=no
+fi
+
+
+AC_SUBST(USE_LIBTAP)
+AC_SUBST(CGIEXTRAS)
+AC_SUBST(GDLIBS)
+AC_SUBST(PERLLIBS)
+AC_SUBST(PERLDIR)
+AC_SUBST(PERLXSI_O)
+AC_SUBST(BASEEXTRALIBS)
+AC_SUBST(INITDIR)
+AC_SUBST(INSTALLPERLSTUFF)
+AC_SUBST(USE_EVENTBROKER)
+
+AC_PATH_PROG(PERL,perl)
+
+AC_OUTPUT(Makefile subst pkginfo base/Makefile common/Makefile contrib/Makefile cgi/Makefile html/Makefile module/Makefile xdata/Makefile daemon-init t/Makefile t-tap/Makefile)
+
+
+perl subst include/locations.h
+perl subst html/config.inc.php
+
+
+echo ""
+echo "Creating sample config files in sample-config/ ..."
+
+perl subst sample-config/nagios.cfg
+perl subst sample-config/cgi.cfg
+perl subst sample-config/resource.cfg
+perl subst sample-config/httpd.conf
+perl subst sample-config/mrtg.cfg
+
+perl subst sample-config/template-object/templates.cfg
+perl subst sample-config/template-object/commands.cfg
+perl subst sample-config/template-object/timeperiods.cfg
+perl subst sample-config/template-object/contacts.cfg
+
+perl subst sample-config/template-object/localhost.cfg
+perl subst sample-config/template-object/windows.cfg
+perl subst sample-config/template-object/printer.cfg
+perl subst sample-config/template-object/switch.cfg
+
+
+
+
+dnl Review options
+echo ""
+echo ""
+AC_MSG_RESULT([*** Configuration summary for $PKG_NAME $PKG_VERSION $PKG_REL_DATE ***:])
+
+echo ""
+echo " General Options:"
+echo " -------------------------"
+
+AC_MSG_RESULT([ Nagios executable: $nagios_name])
+AC_MSG_RESULT([ Nagios user/group: $nagios_user,$nagios_grp])
+AC_MSG_RESULT([ Command user/group: $command_user,$command_grp])
+if test x$USEPERL = xyes; then
+if test x$PERLCACHE = xyes; then
+AC_MSG_RESULT([ Embedded Perl: yes, with caching])
+else
+AC_MSG_RESULT([ Embedded Perl: yes, without caching])
+fi
+else
+AC_MSG_RESULT([ Embedded Perl: no])
+fi
+if test x$USE_EVENTBROKER = xyes; then
+AC_MSG_RESULT([ Event Broker: yes])
+else
+AC_MSG_RESULT([ Event Broker: no])
+fi
+AC_MSG_RESULT([ Install \${prefix}: $prefix])
+AC_MSG_RESULT([ Lock file: $lockfile])
+AC_MSG_RESULT([ Check result directory: $CHECKRESULTDIR])
+AC_MSG_RESULT([ Init directory: $init_dir])
+AC_MSG_RESULT([ Apache conf.d directory: $HTTPD_CONF])
+AC_MSG_RESULT([ Mail program: $MAIL_PROG])
+AC_MSG_RESULT([ Host OS: $host_os])
+
+echo ""
+echo " Web Interface Options:"
+echo " ------------------------"
+
+AC_MSG_RESULT([ HTML URL: http://localhost$htmurl/])
+AC_MSG_RESULT([ CGI URL: http://localhost$cgiurl/])
+AC_MSG_RESULT([ Traceroute (used by WAP): $PATH_TO_TRACEROUTE])
+
+dnl echo ""
+dnl echo " External Data Routines:"
+dnl echo " ------------------------"
+
+dnl AC_MSG_RESULT([ Status data: $XSDCOMMENT])
+dnl AC_MSG_RESULT([ Comment data: $XCDCOMMENT])
+dnl AC_MSG_RESULT([ Downtime data: $XDDCOMMENT])
+dnl AC_MSG_RESULT([ Peformance data: $XPDCOMMENT])
+
+
+echo ""
+echo ""
+echo "Review the options above for accuracy. If they look okay,"
+echo "type 'make all' to compile the main program and CGIs."
+echo ""
+
diff --git a/contrib/.gitignore b/contrib/.gitignore
new file mode 100644
index 0000000..4f1e93a
--- /dev/null
+++ b/contrib/.gitignore
@@ -0,0 +1,2 @@
+perlxsi.c
+Makefile
diff --git a/contrib/Makefile.in b/contrib/Makefile.in
new file mode 100644
index 0000000..addf145
--- /dev/null
+++ b/contrib/Makefile.in
@@ -0,0 +1,90 @@
+###############################
+# Makefile for contrib software
+#
+# Last Modified: 05-19-2008
+###############################
+
+CC=@CC@
+CFLAGS=@CFLAGS@ @DEFS@
+LDFLAGS=@LDFLAGS@ @LIBS@
+
+# Source code directories
+SRC_INCLUDE=../include
+SRC_COMMON=../common
+SRC_CGI=../cgi
+
+# Generated automatically from configure script
+SNPRINTF_O=@SNPRINTF_O@
+INSTALL=@INSTALL@
+INSTALL_OPTS=@INSTALL_OPTS@
+
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+CGIDIR=@sbindir@
+BINDIR=@bindir@
+
+CGIS=traceroute.cgi daemonchk.cgi
+UTILS=mini_epn new_mini_epn convertcfg
+ALL=$(CGIS) $(UTILS)
+
+
+CGI_C=$(SRC_CGI)/getcgi.c
+CGI_O=$(SRC_CGI)/getcgi.o $(SNPRINTF_O)
+CGI_H=$(SRC_INCLUDE)/getcgi.h
+COMMON_H=$(SRC_INCLUDE)/config.h $(SRC_INCLUDE)/common.h $(SRC_INCLUDE)/locations.h
+
+##############################################################################
+# standard targets (all, clean, distclean, devclean, install)
+
+all: $(ALL)
+
+clean:
+ rm -f convertcfg daemonchk.cgi mini_epn new_mini_epn core *.o
+ rm -f */*/*~
+ rm -f */*~
+ rm -f *~
+
+distclean: clean
+ rm -f Makefile
+
+devclean: distclean
+
+install:
+ $(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(CGIDIR)
+ $(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(BINDIR)
+ for f in $(CGIS); do $(INSTALL) -m 775 $(INSTALL_OPTS) $$f $(DESTDIR)$(CGIDIR); done
+ for f in $(UTILS); do $(INSTALL) -m 775 $(INSTALL_OPTS) $$f $(DESTDIR)$(BINDIR); done
+
+##############################################################################
+# rules and dependencies for actual target programs
+
+daemonchk.cgi: daemonchk.o $(CGI_O) $(CGI_H) $(COMMON_H)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(CGI_O)
+
+daemonchk.o: daemonchk.c
+ $(CC) $(CLFAGS) -c -o $@ $< -I$(SRC_INCLUDE)
+
+mini_epn: mini_epn.c
+ perl -MExtUtils::Embed -e xsinit
+ $(CC) $(CFLAGS) -c perlxsi.c `perl -MExtUtils::Embed -e ccopts`
+ $(CC) $(CFLAGS) -c mini_epn.c `perl -MExtUtils::Embed -e ccopts`
+ $(CC) $(CFLAGS) $(LDFLAGS) perlxsi.o mini_epn.o `perl -MExtUtils::Embed -e ccopts -e ldopts` -o $@
+
+new_mini_epn: new_mini_epn.c
+ perl -MExtUtils::Embed -e xsinit
+ $(CC) $(CFLAGS) -c perlxsi.c `perl -MExtUtils::Embed -e ccopts`
+ $(CC) $(CFLAGS) -c new_mini_epn.c `perl -MExtUtils::Embed -e ccopts`
+ $(CC) $(CFLAGS) $(LDFLAGS) perlxsi.o new_mini_epn.o `perl -MExtUtils::Embed -e ccopts -e ldopts` -o $@
+
+##############################################################################
+# dependencies
+
+$(CGI_O): $(CGI_C)
+ cd $(SRC_CGI) && make $(CGI_O)
+
+##############################################################################
+# implicit rules
+
+%.cgi : %.c
+ $(CC) $(CFLAGS) $(LDFLAGS) $< $(CGI_O) -o $@
diff --git a/contrib/README b/contrib/README
new file mode 100644
index 0000000..fac2630
--- /dev/null
+++ b/contrib/README
@@ -0,0 +1,48 @@
+#####################
+Nagios Contrib README
+#####################
+
+This directory contains various programs, scripts, etc. that
+have been contribed by various people. Read the source code
+if you want to find who did what.
+
+Here is a description of what you'll find...
+
+
+Conversion Programs:
+--------------------
+
+- convertcfg.c is a program to quickly convert old "host" config
+ files to the new template-based object config files. It can also
+ convert extended host information definitions. Type 'make convertcfg'
+ to compile the utility.
+
+
+Additional CGIs:
+----------------
+
+- traceroute.cgi is (surprise) a CGI that allows you to do a traceroute
+ to a specific IP address. Simply do a 'chmod +x' to make it executeable
+ and place it in the CGI directory (i.e. /usr/local/nagios/sbin).
+ Requires Perl.
+
+- daemonchk.c is a CGI contributed by Karl DeBisschop that can test to
+ see whether or not the Nagios process is running.
+
+
+Miscellaneous Goodies:
+----------------------
+
+- htaccess.sample is a *sample* .htaccess file that can be used with
+ Apache to require password authentication for access to the web
+ interface.
+
+- mini_epn.c is a mini embedded Perl interpreter that can be used to
+ test the feasibility of running various Perl plugins with the
+ embedded Perl interpreter compiled in.
+
+
+
+
+
+
diff --git a/contrib/convertcfg.c b/contrib/convertcfg.c
new file mode 100644
index 0000000..15bf22b
--- /dev/null
+++ b/contrib/convertcfg.c
@@ -0,0 +1,747 @@
+/************************************************************************
+ *
+ * CONVERTCFG.C - Config File Convertor
+ *
+ * Copyright (c) 2001-2005 Ethan Galstad (egalstad@nagios.org)
+ * Last Modified: 08-12-2005
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include
+#include
+#include
+
+char *my_strsep(char **, const char *);
+
+int main(int argc, char **argv) {
+ FILE *fp;
+ char *temp_ptr;
+ char *temp_ptr2;
+ char input[8096];
+ int notify_recovery;
+ int notify_warning;
+ int notify_critical;
+ int notify_down;
+ int notify_unreachable;
+ int option;
+ int have_template = 0;
+ int x = 0, y = 0;
+ char *host_name;
+ char *service_description;
+ char *host_name2;
+ char *service_description2;
+
+ if(argc != 3) {
+ printf("Nagios Config File Converter\n");
+ printf("Written by Ethan Galstad (egalstad@nagios.org)\n");
+ printf("Last Modified: 08-12-2005\n");
+ printf("\n");
+ printf("Usage: %s