Revision: 2653
http://nagios.svn.sourceforge.net/nagios/?rev=2653&view=rev
Author: estanley375
Date: 2013-03-09 21:46:35 +0000 (Sat, 09 Mar 2013)
Log Message:
-----------
Results of running indent-all.sh
Modified Paths:
--------------
nagioscore/branches/nagios-3-4-x/base/checks.c
nagioscore/branches/nagios-3-4-x/base/config.c
nagioscore/branches/nagios-3-4-x/base/events.c
nagioscore/branches/nagios-3-4-x/base/logging.c
nagioscore/branches/nagios-3-4-x/base/nagios.c
nagioscore/branches/nagios-3-4-x/base/notifications.c
nagioscore/branches/nagios-3-4-x/base/utils.c
nagioscore/branches/nagios-3-4-x/cgi/cgiauth.c
nagioscore/branches/nagios-3-4-x/cgi/cgiutils.c
nagioscore/branches/nagios-3-4-x/cgi/cmd.c
nagioscore/branches/nagios-3-4-x/cgi/getcgi.c
nagioscore/branches/nagios-3-4-x/cgi/history.c
nagioscore/branches/nagios-3-4-x/cgi/status.c
nagioscore/branches/nagios-3-4-x/common/comments.c
nagioscore/branches/nagios-3-4-x/common/downtime.c
nagioscore/branches/nagios-3-4-x/common/macros.c
nagioscore/branches/nagios-3-4-x/xdata/xdddefault.c
nagioscore/branches/nagios-3-4-x/xdata/xodtemplate.c
nagioscore/branches/nagios-3-4-x/xdata/xpddefault.c
nagioscore/branches/nagios-3-4-x/xdata/xrddefault.c
Modified: nagioscore/branches/nagios-3-4-x/base/checks.c
===================================================================
--- nagioscore/branches/nagios-3-4-x/base/checks.c 2013-03-09 21:12:46 UTC (rev 2652)
+++ nagioscore/branches/nagios-3-4-x/base/checks.c 2013-03-09 21:46:35 UTC (rev 2653)
@@ -2084,13 +2084,12 @@
* freshness threshold based on vast heuristical research (ie, "some
* guy once told me the golden ratio is good for loads of stuff").
*/
- if (temp_service->check_type == SERVICE_CHECK_PASSIVE) {
- if (temp_service->last_check < event_start &&
- event_start - last_program_stop < freshness_threshold * 0.618)
- {
+ if(temp_service->check_type == SERVICE_CHECK_PASSIVE) {
+ if(temp_service->last_check < event_start &&
+ event_start - last_program_stop < freshness_threshold * 0.618) {
expiration_time = event_start + freshness_threshold;
+ }
}
- }
log_debug_info(DEBUGL_CHECKS, 2, "HBC: %d, PS: %lu, ES: %lu, LC: %lu, CT: %lu, ET: %lu\n", temp_service->has_been_checked, (unsigned long)program_start, (unsigned long)event_start, (unsigned long)temp_service->last_check, (unsigned long)current_time, (unsigned long)expiration_time);
/* the results for the last check of this service are stale */
@@ -2223,7 +2222,7 @@
return;
}
- if (temp_event) {
+ if(temp_event) {
remove_event(temp_event, &event_list_low, &event_list_low_tail);
my_free(temp_event);
}
@@ -2495,13 +2494,12 @@
* freshness threshold based on vast heuristical research (ie, "some
* guy once told me the golden ratio is good for loads of stuff").
*/
- if (temp_host->check_type == HOST_CHECK_PASSIVE) {
- if (temp_host->last_check < event_start &&
- event_start - last_program_stop > freshness_threshold * 0.618)
- {
+ if(temp_host->check_type == HOST_CHECK_PASSIVE) {
+ if(temp_host->last_check < event_start &&
+ event_start - last_program_stop > freshness_threshold * 0.618) {
expiration_time = event_start + freshness_threshold;
+ }
}
- }
log_debug_info(DEBUGL_CHECKS, 2, "HBC: %d, PS: %lu, ES: %lu, LC: %lu, CT: %lu, ET: %lu\n", temp_host->has_been_checked, (unsigned long)program_start, (unsigned long)event_start, (unsigned long)temp_host->last_check, (unsigned long)current_time, (unsigned long)expiration_time);
Modified: nagioscore/branches/nagios-3-4-x/base/config.c
===================================================================
--- nagioscore/branches/nagios-3-4-x/base/config.c 2013-03-09 21:12:46 UTC (rev 2652)
+++ nagioscore/branches/nagios-3-4-x/base/config.c 2013-03-09 21:46:35 UTC (rev 2653)
@@ -728,23 +728,23 @@
}
}
-
- else if(!strcmp(variable,"service_check_timeout_state")){
- if(!strcmp(value,"o"))
- service_check_timeout_state=STATE_OK;
- else if(!strcmp(value,"w"))
- service_check_timeout_state=STATE_WARNING;
- else if(!strcmp(value,"c"))
- service_check_timeout_state=STATE_CRITICAL;
- else if(!strcmp(value,"u"))
- service_check_timeout_state=STATE_UNKNOWN;
- else{
- asprintf(&error_message,"Illegal value for service_check_timeout_state");
- error=TRUE;
+ else if(!strcmp(variable, "service_check_timeout_state")) {
+
+ if(!strcmp(value, "o"))
+ service_check_timeout_state = STATE_OK;
+ else if(!strcmp(value, "w"))
+ service_check_timeout_state = STATE_WARNING;
+ else if(!strcmp(value, "c"))
+ service_check_timeout_state = STATE_CRITICAL;
+ else if(!strcmp(value, "u"))
+ service_check_timeout_state = STATE_UNKNOWN;
+ else {
+ asprintf(&error_message, "Illegal value for service_check_timeout_state");
+ error = TRUE;
break;
- }
}
+ }
else if(!strcmp(variable, "host_check_timeout")) {
Modified: nagioscore/branches/nagios-3-4-x/base/events.c
===================================================================
--- nagioscore/branches/nagios-3-4-x/base/events.c 2013-03-09 21:12:46 UTC (rev 2652)
+++ nagioscore/branches/nagios-3-4-x/base/events.c 2013-03-09 21:46:35 UTC (rev 2653)
@@ -350,9 +350,9 @@
/* skip services whose checks are currently executing */
if(temp_service->is_executing) {
- log_debug_info(DEBUGL_EVENTS, 2,
- "Service check '%s' on host '%s' is already executing.\n",
- temp_service->description, temp_service->host_name);
+ log_debug_info(DEBUGL_EVENTS, 2,
+ "Service check '%s' on host '%s' is already executing.\n",
+ temp_service->description, temp_service->host_name);
continue;
}
@@ -428,9 +428,9 @@
}
/* create a new service check event */
- log_debug_info(DEBUGL_EVENTS, 2,
- "Scheduling check for service '%s' on host '%s'.\n",
- temp_service->description, temp_service->host_name);
+ log_debug_info(DEBUGL_EVENTS, 2,
+ "Scheduling check for service '%s' on host '%s'.\n",
+ temp_service->description, temp_service->host_name);
schedule_new_event(EVENT_SERVICE_CHECK, FALSE, temp_service->next_check, FALSE, 0, NULL, TRUE, (void *)temp_service, NULL, temp_service->check_options);
}
@@ -522,8 +522,8 @@
/* skip hosts whose checks are currently executing */
if(temp_host->is_executing) {
- log_debug_info(DEBUGL_EVENTS, 2,
- "Host check %s is already executing.\n", temp_host->name);
+ log_debug_info(DEBUGL_EVENTS, 2,
+ "Host check %s is already executing.\n", temp_host->name);
continue;
}
@@ -578,8 +578,8 @@
}
/* schedule a new host check event */
- log_debug_info(DEBUGL_EVENTS, 2, "Scheduling check for host '%s'.\n",
- temp_host->name);
+ log_debug_info(DEBUGL_EVENTS, 2, "Scheduling check for host '%s'.\n",
+ temp_host->name);
schedule_new_event(EVENT_HOST_CHECK, FALSE, temp_host->next_check, FALSE, 0, NULL, TRUE, (void *)temp_host, NULL, temp_host->check_options);
}
@@ -801,22 +801,22 @@
log_debug_info(DEBUGL_FUNCTIONS, 0, "schedule_new_event()\n");
get_datetime_string(&run_time, run_time_string, MAX_DATETIME_LENGTH,
- SHORT_DATE_TIME);
+ SHORT_DATE_TIME);
log_debug_info(DEBUGL_EVENTS, 0, "New Event Details:\n");
log_debug_info(DEBUGL_EVENTS, 0, " Type: %s\n",
- EVENT_TYPE_STR( event_type));
+ EVENT_TYPE_STR(event_type));
log_debug_info(DEBUGL_EVENTS, 0, " High Priority: %s\n",
- ( high_priority ? "Yes" : "No"));
+ (high_priority ? "Yes" : "No"));
log_debug_info(DEBUGL_EVENTS, 0, " Run Time: %s\n",
- run_time_string);
+ run_time_string);
log_debug_info(DEBUGL_EVENTS, 0, " Recurring: %s\n",
- ( recurring ? "Yes" : "No"));
+ (recurring ? "Yes" : "No"));
log_debug_info(DEBUGL_EVENTS, 0, " Event Interval: %lu\n",
- event_interval);
+ event_interval);
log_debug_info(DEBUGL_EVENTS, 0, " Compensate for Time Change: %s\n",
- ( compensate_for_time_change ? "Yes" : "No"));
+ (compensate_for_time_change ? "Yes" : "No"));
log_debug_info(DEBUGL_EVENTS, 0, " Event Options: %d\n",
- event_options);
+ event_options);
if(high_priority == TRUE) {
event_list = &event_list_high;
@@ -947,7 +947,7 @@
log_debug_info(DEBUGL_FUNCTIONS, 0, "remove_event()\n");
- if (!event)
+ if(!event)
return;
#ifdef USE_EVENT_BROKER
@@ -960,18 +960,18 @@
prev_event = event->prev;
next_event = event->next;
- if (prev_event) {
+ if(prev_event) {
prev_event->next = next_event;
}
- if (next_event) {
+ if(next_event) {
next_event->prev = prev_event;
}
- if (!prev_event) {
+ if(!prev_event) {
/* no previous event, so "next" is now first in list */
*event_list = next_event;
}
- if (!next_event) {
+ if(!next_event) {
/* no following event, so "prev" is now last in list */
*event_list_tail = prev_event;
}
Modified: nagioscore/branches/nagios-3-4-x/base/logging.c
===================================================================
--- nagioscore/branches/nagios-3-4-x/base/logging.c 2013-03-09 21:12:46 UTC (rev 2652)
+++ nagioscore/branches/nagios-3-4-x/base/logging.c 2013-03-09 21:46:35 UTC (rev 2653)
@@ -61,32 +61,35 @@
static pthread_mutex_t debug_fp_lock;
/* These simple helpers should most likely be elsewhere */
-static const char *service_state_name(int state)
-{
- switch (state) {
- case STATE_OK: return "OK";
- case STATE_WARNING: return "WARNING";
- case STATE_CRITICAL: return "CRITICAL";
- }
+static const char *service_state_name(int state) {
+ switch(state) {
+ case STATE_OK:
+ return "OK";
+ case STATE_WARNING:
+ return "WARNING";
+ case STATE_CRITICAL:
+ return "CRITICAL";
+ }
return "UNKNOWN";
-}
-
-static const char *host_state_name(int state)
-{
- switch (state) {
- case HOST_UP: return "UP";
- case HOST_DOWN: return "DOWN";
- case HOST_UNREACHABLE: return "UNREACHABLE";
}
+static const char *host_state_name(int state) {
+ switch(state) {
+ case HOST_UP:
+ return "UP";
+ case HOST_DOWN:
+ return "DOWN";
+ case HOST_UNREACHABLE:
+ return "UNREACHABLE";
+ }
+
return "(unknown)";
-}
+ }
-static const char *state_type_name(int state_type)
-{
+static const char *state_type_name(int state_type) {
return state_type == HARD_STATE ? "HARD" : "SOFT";
-}
+ }
/*
* since we don't want child processes to hang indefinitely
@@ -292,11 +295,11 @@
return ERROR;
asprintf(&temp_buffer, "SERVICE ALERT: %s;%s;%s;%s;%d;%s\n",
- svc->host_name, svc->description,
- service_state_name(svc->current_state),
- state_type_name(svc->state_type),
- svc->current_attempt,
- (svc->plugin_output == NULL) ? "" : svc->plugin_output);
+ svc->host_name, svc->description,
+ service_state_name(svc->current_state),
+ state_type_name(svc->state_type),
+ svc->current_attempt,
+ (svc->plugin_output == NULL) ? "" : svc->plugin_output);
write_to_all_logs(temp_buffer, log_options);
@@ -318,11 +321,11 @@
log_options = NSLOG_HOST_UP;
asprintf(&temp_buffer, "HOST ALERT: %s;%s;%s;%d;%s\n",
- hst->name,
- host_state_name(hst->current_state),
- state_type_name(hst->state_type),
- hst->current_attempt,
- (hst->plugin_output == NULL) ? "" : hst->plugin_output);
+ hst->name,
+ host_state_name(hst->current_state),
+ state_type_name(hst->state_type),
+ hst->current_attempt,
+ (hst->plugin_output == NULL) ? "" : hst->plugin_output);
write_to_all_logs(temp_buffer, log_options);
@@ -344,11 +347,11 @@
for(temp_host = host_list; temp_host != NULL; temp_host = temp_host->next) {
asprintf(&temp_buffer, "%s HOST STATE: %s;%s;%s;%d;%s\n", (type == INITIAL_STATES) ? "INITIAL" : "CURRENT",
- temp_host->name,
- host_state_name(temp_host->current_state),
- state_type_name(temp_host->state_type),
- temp_host->current_attempt,
- (temp_host->plugin_output == NULL) ? "" : temp_host->plugin_output);
+ temp_host->name,
+ host_state_name(temp_host->current_state),
+ state_type_name(temp_host->state_type),
+ temp_host->current_attempt,
+ (temp_host->plugin_output == NULL) ? "" : temp_host->plugin_output);
write_to_all_logs_with_timestamp(temp_buffer, NSLOG_INFO_MESSAGE, timestamp);
@@ -376,12 +379,12 @@
continue;
asprintf(&temp_buffer, "%s SERVICE STATE: %s;%s;%s;%s;%d;%s\n",
- (type == INITIAL_STATES) ? "INITIAL" : "CURRENT",
- temp_service->host_name, temp_service->description,
- service_state_name(temp_service->current_state),
- state_type_name(temp_service->state_type),
- temp_service->current_attempt,
- temp_service->plugin_output);
+ (type == INITIAL_STATES) ? "INITIAL" : "CURRENT",
+ temp_service->host_name, temp_service->description,
+ service_state_name(temp_service->current_state),
+ state_type_name(temp_service->state_type),
+ temp_service->current_attempt,
+ temp_service->plugin_output);
write_to_all_logs_with_timestamp(temp_buffer, NSLOG_INFO_MESSAGE, timestamp);
@@ -502,10 +505,10 @@
if(debug_level == DEBUGL_NONE)
return OK;
- if( chown(debug_file, uid, gid) < 0) {
- logit(NSLOG_RUNTIME_WARNING, TRUE,
- "Failed to change ownership on debug log: %s.",
- strerror( errno));
+ if(chown(debug_file, uid, gid) < 0) {
+ logit(NSLOG_RUNTIME_WARNING, TRUE,
+ "Failed to change ownership on debug log: %s.",
+ strerror(errno));
return ERROR;
}
Modified: nagioscore/branches/nagios-3-4-x/base/nagios.c
===================================================================
--- nagioscore/branches/nagios-3-4-x/base/nagios.c 2013-03-09 21:12:46 UTC (rev 2652)
+++ nagioscore/branches/nagios-3-4-x/base/nagios.c 2013-03-09 21:46:35 UTC (rev 2653)
@@ -9,7 +9,7 @@
* Copyright (c) 1999-2009 Ethan Galstad
*
* First Written: 01-28-1999 (start of development)
- * Last Modified:
+ * Last Modified:
*
* Description:
*
@@ -98,7 +98,7 @@
unsigned long syslog_options = 0;
int service_check_timeout = DEFAULT_SERVICE_CHECK_TIMEOUT;
-int service_check_timeout_state=STATE_CRITICAL;
+int service_check_timeout_state = STATE_CRITICAL;
int host_check_timeout = DEFAULT_HOST_CHECK_TIMEOUT;
int event_handler_timeout = DEFAULT_EVENT_HANDLER_TIMEOUT;
int notification_timeout = DEFAULT_NOTIFICATION_TIMEOUT;
Modified: nagioscore/branches/nagios-3-4-x/base/notifications.c
===================================================================
--- nagioscore/branches/nagios-3-4-x/base/notifications.c 2013-03-09 21:12:46 UTC (rev 2652)
+++ nagioscore/branches/nagios-3-4-x/base/notifications.c 2013-03-09 21:46:35 UTC (rev 2653)
@@ -128,7 +128,7 @@
/* create the contact notification list for this service */
- /* 2011-11-01 MF:
+ /* 2011-11-01 MF:
check viability before adding a contact
to the notification list, requires type
this prevents us from running through all
@@ -975,10 +975,10 @@
if((temp_contact = temp_contactsmember->contact_ptr) == NULL)
continue;
/* check now if the contact can be notified */
- if (check_contact_service_notification_viability(temp_contact, svc, type, options) == OK)
+ if(check_contact_service_notification_viability(temp_contact, svc, type, options) == OK)
add_notification(mac, temp_contact);
else
- log_debug_info(DEBUGL_NOTIFICATIONS, 2, "Not adding contact '%s'\n",temp_contact->name);
+ log_debug_info(DEBUGL_NOTIFICATIONS, 2, "Not adding contact '%s'\n", temp_contact->name);
}
log_debug_info(DEBUGL_NOTIFICATIONS, 2, "Adding members of contact groups from service escalation(s) to notification list.\n");
@@ -992,10 +992,10 @@
if((temp_contact = temp_contactsmember->contact_ptr) == NULL)
continue;
/* check now if the contact can be notified */
- if (check_contact_service_notification_viability(temp_contact, svc, type, options) == OK)
+ if(check_contact_service_notification_viability(temp_contact, svc, type, options) == OK)
add_notification(mac, temp_contact);
else
- log_debug_info(DEBUGL_NOTIFICATIONS, 2, "Not adding contact '%s'\n",temp_contact->name);
+ log_debug_info(DEBUGL_NOTIFICATIONS, 2, "Not adding contact '%s'\n", temp_contact->name);
}
}
}
@@ -1011,10 +1011,10 @@
if((temp_contact = temp_contactsmember->contact_ptr) == NULL)
continue;
/* check now if the contact can be notified */
- if (check_contact_service_notification_viability(temp_contact, svc, type, options) == OK)
- add_notification(mac, temp_contact);
- else
- log_debug_info(DEBUGL_NOTIFICATIONS, 2, "Not adding contact '%s'\n",temp_contact->name);
+ if(check_contact_service_notification_viability(temp_contact, svc, type, options) == OK)
+ add_notification(mac, temp_contact);
+ else
+ log_debug_info(DEBUGL_NOTIFICATIONS, 2, "Not adding contact '%s'\n", temp_contact->name);
}
/* add all contacts that belong to contactgroups for this service */
@@ -1025,11 +1025,11 @@
for(temp_contactsmember = temp_contactgroup->members; temp_contactsmember != NULL; temp_contactsmember = temp_contactsmember->next) {
if((temp_contact = temp_contactsmember->contact_ptr) == NULL)
continue;
- /* check now if the contact can be notified */
- if (check_contact_service_notification_viability(temp_contact, svc, type, options) == OK)
- add_notification(mac, temp_contact);
- else
- log_debug_info(DEBUGL_NOTIFICATIONS, 2, "Not adding contact '%s'\n",temp_contact->name);
+ /* check now if the contact can be notified */
+ if(check_contact_service_notification_viability(temp_contact, svc, type, options) == OK)
+ add_notification(mac, temp_contact);
+ else
+ log_debug_info(DEBUGL_NOTIFICATIONS, 2, "Not adding contact '%s'\n", temp_contact->name);
}
}
}
@@ -1107,7 +1107,7 @@
/* reset memory for local macro data */
memset(&mac, 0, sizeof(mac));
- /* 2011-11-01 MF:
+ /* 2011-11-01 MF:
check viability before adding a contact
to the notification list, requires type
this prevents us from running through all
@@ -1912,7 +1912,7 @@
if((temp_contact = temp_contactsmember->contact_ptr) == NULL)
continue;
/* check now if the contact can be notified */
- if (check_contact_host_notification_viability(temp_contact, hst, type, options) == OK)
+ if(check_contact_host_notification_viability(temp_contact, hst, type, options) == OK)
add_notification(mac, temp_contact);
else
log_debug_info(DEBUGL_NOTIFICATIONS, 2, "Not adding contact '%s'\n", temp_contact->name);
@@ -1928,11 +1928,11 @@
for(temp_contactsmember = temp_contactgroup->members; temp_contactsmember != NULL; temp_contactsmember = temp_contactsmember->next) {
if((temp_contact = temp_contactsmember->contact_ptr) == NULL)
continue;
- /* check now if the contact can be notified */
- if (check_contact_host_notification_viability(temp_contact, hst, type, options) == OK)
- add_notification(mac, temp_contact);
- else
- log_debug_info(DEBUGL_NOTIFICATIONS, 2, "Not adding contact '%s'\n", temp_contact->name);
+ /* check now if the contact can be notified */
+ if(check_contact_host_notification_viability(temp_contact, hst, type, options) == OK)
+ add_notification(mac, temp_contact);
+ else
+ log_debug_info(DEBUGL_NOTIFICATIONS, 2, "Not adding contact '%s'\n", temp_contact->name);
}
}
}
@@ -1949,11 +1949,11 @@
for(temp_contactsmember = hst->contacts; temp_contactsmember != NULL; temp_contactsmember = temp_contactsmember->next) {
if((temp_contact = temp_contactsmember->contact_ptr) == NULL)
continue;
- /* check now if the contact can be notified */
- if (check_contact_host_notification_viability(temp_contact, hst, type, options) == OK)
- add_notification(mac, temp_contact);
- else
- log_debug_info(DEBUGL_NOTIFICATIONS, 2, "Not adding contact '%s'\n", temp_contact->name);
+ /* check now if the contact can be notified */
+ if(check_contact_host_notification_viability(temp_contact, hst, type, options) == OK)
+ add_notification(mac, temp_contact);
+ else
+ log_debug_info(DEBUGL_NOTIFICATIONS, 2, "Not adding contact '%s'\n", temp_contact->name);
}
log_debug_info(DEBUGL_NOTIFICATIONS, 2, "Adding members of contact groups for host to notification list.\n");
@@ -1967,11 +1967,11 @@
for(temp_contactsmember = temp_contactgroup->members; temp_contactsmember != NULL; temp_contactsmember = temp_contactsmember->next) {
if((temp_contact = temp_contactsmember->contact_ptr) == NULL)
continue;
- /* check now if the contact can be notified */
- if (check_contact_host_notification_viability(temp_contact, hst, type, options) == OK)
- add_notification(mac, temp_contact);
- else
- log_debug_info(DEBUGL_NOTIFICATIONS, 2, "Not adding contact '%s'\n", temp_contact->name);
+ /* check now if the contact can be notified */
+ if(check_contact_host_notification_viability(temp_contact, hst, type, options) == OK)
+ add_notification(mac, temp_contact);
+ else
+ log_debug_info(DEBUGL_NOTIFICATIONS, 2, "Not adding contact '%s'\n", temp_contact->name);
}
}
}
Modified: nagioscore/branches/nagios-3-4-x/base/utils.c
===================================================================
--- nagioscore/branches/nagios-3-4-x/base/utils.c 2013-03-09 21:12:46 UTC (rev 2652)
+++ nagioscore/branches/nagios-3-4-x/base/utils.c 2013-03-09 21:46:35 UTC (rev 2653)
@@ -2136,7 +2136,7 @@
}
#endif
/* Change the ownership on the debug log file */
- chown_debug_log( uid, gid);
+ chown_debug_log(uid, gid);
if(setuid(uid) == -1) {
logit(NSLOG_RUNTIME_WARNING, TRUE, "Warning: Could not set effective UID=%d", (int)uid);
@@ -2284,8 +2284,8 @@
continue;
/* process the file */
- result = process_check_result_file(file, &check_result_list,
- TRUE, TRUE);
+ result = process_check_result_file(file, &check_result_list,
+ TRUE, TRUE);
/* break out if we encountered an error */
if(result == ERROR)
@@ -2302,7 +2302,7 @@
-/* Find checks that are currently executing. This function is intended to
+/* Find checks that are currently executing. This function is intended to
be used on a Nagios restart to prevent currently executing checks from
being rescheduled. */
int find_executing_checks(char *dirname) {
@@ -2343,7 +2343,7 @@
/* process this if it's a check result file... */
x = strlen(dirfile->d_name);
- if(x == 11 && !strncmp( dirfile->d_name, "check", 5)) {
+ if(x == 11 && !strncmp(dirfile->d_name, "check", 5)) {
if(stat(file, &stat_buf) == -1) {
logit(NSLOG_RUNTIME_WARNING, TRUE, "Warning: Could not stat() check status '%s'.\n", file);
@@ -2365,8 +2365,8 @@
}
/* at this point we have a regular file... */
- log_debug_info(DEBUGL_CHECKS, 2,
- "Looking for still-executing checks in %s.\n", file);
+ log_debug_info(DEBUGL_CHECKS, 2,
+ "Looking for still-executing checks in %s.\n", file);
/* process the file */
result = process_check_result_file(file, &crl, FALSE, FALSE);
@@ -2378,42 +2378,42 @@
time(¤t_time);
/* examine the check results */
- while(( cr = read_check_result(&crl)) != NULL) {
- if( HOST_CHECK == cr->object_check_type) {
- log_debug_info(DEBUGL_CHECKS, 2,
- "Determining whether check for host '%s' is still executing.\n",
- cr->host_name);
+ while((cr = read_check_result(&crl)) != NULL) {
+ if(HOST_CHECK == cr->object_check_type) {
+ log_debug_info(DEBUGL_CHECKS, 2,
+ "Determining whether check for host '%s' is still executing.\n",
+ cr->host_name);
if((host = find_host(cr->host_name)) == NULL) {
- logit(NSLOG_RUNTIME_WARNING, TRUE,
- "Warning: Check status contained host '%s', "
- "but the host could not be found! Ignoring "
- "check.\n", cr->host_name);
+ logit(NSLOG_RUNTIME_WARNING, TRUE,
+ "Warning: Check status contained host '%s', "
+ "but the host could not be found! Ignoring "
+ "check.\n", cr->host_name);
}
- else if( current_time - cr->start_time.tv_sec <
- host_check_timeout) {
- log_debug_info(DEBUGL_CHECKS, 1,
- "Check for host %s is still executing.\n",
- cr->host_name);
+ else if(current_time - cr->start_time.tv_sec <
+ host_check_timeout) {
+ log_debug_info(DEBUGL_CHECKS, 1,
+ "Check for host %s is still executing.\n",
+ cr->host_name);
host->is_executing = TRUE;
}
}
- else if( SERVICE_CHECK == cr->object_check_type) {
- log_debug_info(DEBUGL_CHECKS, 2,
- "Determining whether check for service '%s' on host '%s' is still executing.\n",
- cr->host_name, cr->service_description);
- if((svc = find_service(cr->host_name,
- cr->service_description)) == NULL) {
- logit(NSLOG_RUNTIME_WARNING, TRUE,
- "Warning: Check status contained service '%s' "
- "on host '%s', but the service could not be "
- "found! Ignoring check.\n",
- cr->service_description, cr->host_name);
+ else if(SERVICE_CHECK == cr->object_check_type) {
+ log_debug_info(DEBUGL_CHECKS, 2,
+ "Determining whether check for service '%s' on host '%s' is still executing.\n",
+ cr->host_name, cr->service_description);
+ if((svc = find_service(cr->host_name,
+ cr->service_description)) == NULL) {
+ logit(NSLOG_RUNTIME_WARNING, TRUE,
+ "Warning: Check status contained service '%s' "
+ "on host '%s', but the service could not be "
+ "found! Ignoring check.\n",
+ cr->service_description, cr->host_name);
}
- else if( current_time - cr->start_time.tv_sec <
- service_check_timeout) {
- log_debug_info(DEBUGL_CHECKS, 1,
- "Check for service %s:%s is still executing.\n",
- cr->host_name, cr->service_description);
+ else if(current_time - cr->start_time.tv_sec <
+ service_check_timeout) {
+ log_debug_info(DEBUGL_CHECKS, 1,
+ "Check for service %s:%s is still executing.\n",
+ cr->host_name, cr->service_description);
svc->is_executing = TRUE;
}
}
@@ -2478,8 +2478,8 @@
if(new_cr) {
/* do we have the minimum amount of data? */
- if(new_cr->host_name != NULL &&
- ( !need_output || new_cr->output != NULL)) {
+ if(new_cr->host_name != NULL &&
+ (!need_output || new_cr->output != NULL)) {
/* add check result to list in memory */
add_check_result_to_list(listp, new_cr);
@@ -2574,8 +2574,8 @@
if(new_cr) {
/* do we have the minimum amount of data? */
- if(new_cr->host_name != NULL &&
- ( !need_output || new_cr->output != NULL)) {
+ if(new_cr->host_name != NULL &&
+ (!need_output || new_cr->output != NULL)) {
/* add check result to list in memory */
add_check_result_to_list(listp, new_cr);
@@ -3259,10 +3259,10 @@
return FALSE;
/* grab the first line - we should see Perl. go home if not */
- if (fgets(buf, 80, fp) == NULL || strstr(buf, "/bin/perl") == NULL) {
+ if(fgets(buf, 80, fp) == NULL || strstr(buf, "/bin/perl") == NULL) {
fclose(fp);
return FALSE;
- }
+ }
/* epn directives must be found in first ten lines of plugin */
for(line = 1; line < 10; line++) {
@@ -3275,7 +3275,7 @@
if(strstr(buf, "# nagios:")) {
char *p;
p = strstr(buf + 8, "epn");
- if (!p)
+ if(!p)
continue;
/*
@@ -4135,7 +4135,7 @@
/* free memory for the high priority event list */
this_event = event_list_high;
while(this_event != NULL) {
- if (this_event->event_type == EVENT_SCHEDULED_DOWNTIME)
+ if(this_event->event_type == EVENT_SCHEDULED_DOWNTIME)
my_free(this_event->event_data);
next_event = this_event->next;
my_free(this_event);
@@ -4148,7 +4148,7 @@
/* free memory for the low priority event list */
this_event = event_list_low;
while(this_event != NULL) {
- if (this_event->event_type == EVENT_SCHEDULED_DOWNTIME)
+ if(this_event->event_type == EVENT_SCHEDULED_DOWNTIME)
my_free(this_event->event_data);
next_event = this_event->next;
my_free(this_event);
Modified: nagioscore/branches/nagios-3-4-x/cgi/cgiauth.c
===================================================================
--- nagioscore/branches/nagios-3-4-x/cgi/cgiauth.c 2013-03-09 21:12:46 UTC (rev 2652)
+++ nagioscore/branches/nagios-3-4-x/cgi/cgiauth.c 2013-03-09 21:46:35 UTC (rev 2653)
@@ -336,7 +336,7 @@
if(is_authorized_for_service(temp_service, authinfo) == TRUE)
return TRUE;
}
-
+
/*return TRUE*/;
return FALSE;
}
Modified: nagioscore/branches/nagios-3-4-x/cgi/cgiutils.c
===================================================================
--- nagioscore/branches/nagios-3-4-x/cgi/cgiutils.c 2013-03-09 21:12:46 UTC (rev 2652)
+++ nagioscore/branches/nagios-3-4-x/cgi/cgiutils.c 2013-03-09 21:46:35 UTC (rev 2653)
@@ -329,8 +329,8 @@
else if(!strcmp(var, "refresh_rate"))
refresh_rate = atoi(val);
-
- /* page limit added 2/1/2012 -MG */
+
+ /* page limit added 2/1/2012 -MG */
else if(!strcmp(var, "result_limit"))
result_limit = atoi(val);
@@ -374,11 +374,11 @@
snprintf(url_media_path, sizeof(url_media_path), "%smedia/", url_html_path);
url_media_path[sizeof(url_media_path) - 1] = '\x0';
-
- /* added JS directory 2/1/2012 -MG */
+
+ /* added JS directory 2/1/2012 -MG */
snprintf(url_js_path, sizeof(url_js_path), "%sjs/", url_html_path);
url_js_path[sizeof(url_js_path) - 1] = '\x0';
-
+
}
else if(!strcmp(var, "service_critical_sound"))
@@ -974,104 +974,104 @@
/* we need up to six times the space to do the conversion */
len = (int)strlen(input);
output_max = len * 6;
- if(( outstp = encoded_html_string = (char *)malloc(output_max + 1)) == NULL)
+ if((outstp = encoded_html_string = (char *)malloc(output_max + 1)) == NULL)
return "";
strcpy(encoded_html_string, "");
/* Convert the string to a wide character string */
- if(( wcinput = malloc( len * sizeof( wchar_t))) == NULL) {
+ if((wcinput = malloc(len * sizeof(wchar_t))) == NULL) {
return "";
}
- if(( mbstowcs_result = mbstowcs( wcinput, input, len)) < 0) {
- free( wcinput);
+ if((mbstowcs_result = mbstowcs(wcinput, input, len)) < 0) {
+ free(wcinput);
return "";
}
/* Process all converted characters */
- for( x = 0, inwcp = wcinput; x < mbstowcs_result && '\0' != *inwcp; x++, inwcp++) {
+ for(x = 0, inwcp = wcinput; x < mbstowcs_result && '\0' != *inwcp; x++, inwcp++) {
/* Most ASCII characters don't get encoded */
- if(( *inwcp >= 0x20 && *inwcp <= 0x7e) &&
- ( !( '"' == *inwcp || '&' == *inwcp || '\'' == *inwcp ||
- '<' == *inwcp || '>' == *inwcp))) {
- wctomb_result = wctomb( mbtemp, *inwcp);
- if(( wctomb_result > 0) &&
- ((( outstp - encoded_html_string) + wctomb_result) < output_max)) {
- strncpy( outstp, mbtemp, wctomb_result);
+ if((*inwcp >= 0x20 && *inwcp <= 0x7e) &&
+ (!('"' == *inwcp || '&' == *inwcp || '\'' == *inwcp ||
+ '<' == *inwcp || '>' == *inwcp))) {
+ wctomb_result = wctomb(mbtemp, *inwcp);
+ if((wctomb_result > 0) &&
+ (((outstp - encoded_html_string) + wctomb_result) < output_max)) {
+ strncpy(outstp, mbtemp, wctomb_result);
outstp += wctomb_result;
}
}
/* newlines turn to <BR> tags */
else if(escape_newlines == TRUE && '\n' == *inwcp) {
- strncpy( outstp, "<BR>", 4);
+ strncpy(outstp, "<BR>", 4);
outstp += 4;
}
- else if(escape_newlines == TRUE && '\\' == *inwcp && '\n' == *( inwcp + 1)) {
- strncpy( outstp, "<BR>", 4);
+ else if(escape_newlines == TRUE && '\\' == *inwcp && '\n' == *(inwcp + 1)) {
+ strncpy(outstp, "<BR>", 4);
outstp += 4;
inwcp++; /* needed so loop skips two wide characters */
}
/* TODO - strip all but allowed HTML tags out... */
- else if( '<' == *inwcp) {
+ else if('<' == *inwcp) {
if(escape_html_tags == FALSE) {
- wctomb_result = wctomb( mbtemp, *inwcp);
- if(( wctomb_result > 0) &&
- ((( outstp - encoded_html_string) + wctomb_result) < output_max)) {
- strncpy( outstp, mbtemp, wctomb_result);
+ wctomb_result = wctomb(mbtemp, *inwcp);
+ if((wctomb_result > 0) &&
+ (((outstp - encoded_html_string) + wctomb_result) < output_max)) {
+ strncpy(outstp, mbtemp, wctomb_result);
outstp += wctomb_result;
}
}
else {
- if((( outstp - encoded_html_string) + 4) < output_max) {
- strncpy( outstp, "<", 4);
+ if(((outstp - encoded_html_string) + 4) < output_max) {
+ strncpy(outstp, "<", 4);
outstp += 4;
}
}
}
- else if( '>' == *inwcp) {
+ else if('>' == *inwcp) {
if(escape_html_tags == FALSE) {
- wctomb_result = wctomb( mbtemp, *inwcp);
- if(( wctomb_result > 0) &&
- ((( outstp - encoded_html_string) + wctomb_result) < output_max)) {
- strncpy( outstp, mbtemp, wctomb_result);
+ wctomb_result = wctomb(mbtemp, *inwcp);
+ if((wctomb_result > 0) &&
+ (((outstp - encoded_html_string) + wctomb_result) < output_max)) {
+ strncpy(outstp, mbtemp, wctomb_result);
outstp += wctomb_result;
}
}
else {
- if((( outstp - encoded_html_string) + 4) < output_max) {
- strncpy( outstp, ">", 4);
+ if(((outstp - encoded_html_string) + 4) < output_max) {
+ strncpy(outstp, ">", 4);
outstp += 4;
}
}
}
- /* When not escaping HTML tags, don't encode quotes or ampersands
+ /* When not escaping HTML tags, don't encode quotes or ampersands
(left and right carets are handled above */
- else if((escape_html_tags == FALSE) && ( '"' == *inwcp ||
- '&' == *inwcp || '\'' == *inwcp)) {
- wctomb_result = wctomb( mbtemp, *inwcp);
- if(( wctomb_result > 0) &&
- ((( outstp - encoded_html_string) + wctomb_result) < output_max)) {
- strncpy( outstp, mbtemp, wctomb_result);
+ else if((escape_html_tags == FALSE) && ('"' == *inwcp ||
+ '&' == *inwcp || '\'' == *inwcp)) {
+ wctomb_result = wctomb(mbtemp, *inwcp);
+ if((wctomb_result > 0) &&
+ (((outstp - encoded_html_string) + wctomb_result) < output_max)) {
+ strncpy(outstp, mbtemp, wctomb_result);
outstp += wctomb_result;
}
}
/* for simplicity, all other chars represented by their numeric value */
else {
- sprintf( temp_expansion, "&#%u;", *( unsigned int *)inwcp);
- if((( outstp - encoded_html_string) + strlen( temp_expansion)) <
- output_max) {
- strncpy( outstp, temp_expansion, strlen( temp_expansion));
- outstp += strlen( temp_expansion);
+ sprintf(temp_expansion, "&#%u;", *(unsigned int *)inwcp);
+ if(((outstp - encoded_html_string) + strlen(temp_expansion)) <
+ output_max) {
+ strncpy(outstp, temp_expansion, strlen(temp_expansion));
+ outstp += strlen(temp_expansion);
}
}
}
@@ -1119,46 +1119,46 @@
char temp_expansion[10];
/* If they don't give us anything to do... */
- if( NULL == input) {
+ if(NULL == input) {
return "";
}
/* We need up to six times the space to do the conversion */
len = (int)strlen(input);
output_max = len * 6;
- if(( stp = encoded_html_string = (char *)malloc(output_max + 1)) == NULL)
+ if((stp = encoded_html_string = (char *)malloc(output_max + 1)) == NULL)
return "";
strcpy(encoded_html_string, "");
/* Get the first multibyte character in the input string */
- mbtowc_result = mbtowc( wctemp, input, MB_CUR_MAX);
+ mbtowc_result = mbtowc(wctemp, input, MB_CUR_MAX);
/* Process all characters until a null character is found */
- while( 0 != mbtowc_result) { /* 0 indicates a null character was found */
+ while(0 != mbtowc_result) { /* 0 indicates a null character was found */
- if(( size_t)-2 == mbtowc_result) {
+ if((size_t) - 2 == mbtowc_result) {
/* No complete multibyte character found - try at next memory
address */
input++;
}
- else if((( size_t)-1 == mbtowc_result) && ( EILSEQ == errno)) {
+ else if(((size_t) - 1 == mbtowc_result) && (EILSEQ == errno)) {
/* Invalid multibyte character found - try at next memory address */
input++;
}
- /* Alpha-numeric characters and a few other characters don't get
+ /* Alpha-numeric characters and a few other characters don't get
encoded */
- else if(( *wctemp >= '0' && *wctemp <= '9') ||
- ( *wctemp >= 'A' && *wctemp <= 'Z') ||
- ( *wctemp >= 'a' && *wctemp <= 'z') ||
- ' ' == *wctemp || '-' == *wctemp || '.' == *wctemp ||
- '_' == *wctemp || ':' == *wctemp) {
- wctomb_result = wctomb( mbtemp, wctemp[0]);
- if(( wctomb_result > 0) &&
- ((( stp - encoded_html_string) + wctomb_result) < output_max)) {
- strncpy( stp, mbtemp, wctomb_result);
+ else if((*wctemp >= '0' && *wctemp <= '9') ||
+ (*wctemp >= 'A' && *wctemp <= 'Z') ||
+ (*wctemp >= 'a' && *wctemp <= 'z') ||
+ ' ' == *wctemp || '-' == *wctemp || '.' == *wctemp ||
+ '_' == *wctemp || ':' == *wctemp) {
+ wctomb_result = wctomb(mbtemp, wctemp[0]);
+ if((wctomb_result > 0) &&
+ (((stp - encoded_html_string) + wctomb_result) < output_max)) {
+ strncpy(stp, mbtemp, wctomb_result);
stp += wctomb_result;
}
input += mbtowc_result;
@@ -1166,17 +1166,17 @@
/* Encode everything else (this may be excessive) */
else {
- sprintf( temp_expansion, "&#%u;", ( unsigned int)wctemp[ 0]);
- if((( stp - encoded_html_string) + strlen( temp_expansion)) <
- output_max) {
- strncpy( stp, temp_expansion, strlen( temp_expansion));
- stp += strlen( temp_expansion);
+ sprintf(temp_expansion, "&#%u;", (unsigned int)wctemp[ 0]);
+ if(((stp - encoded_html_string) + strlen(temp_expansion)) <
+ output_max) {
+ strncpy(stp, temp_expansion, strlen(temp_expansion));
+ stp += strlen(temp_expansion);
}
input += mbtowc_result;
}
/* Read the next character */
- mbtowc_result = mbtowc( wctemp, input, MB_CUR_MAX);
+ mbtowc_result = mbtowc(wctemp, input, MB_CUR_MAX);
}
/* Null terminate the encoded string */
Modified: nagioscore/branches/nagios-3-4-x/cgi/cmd.c
===================================================================
--- nagioscore/branches/nagios-3-4-x/cgi/cmd.c 2013-03-09 21:12:46 UTC (rev 2652)
+++ nagioscore/branches/nagios-3-4-x/cgi/cmd.c 2013-03-09 21:46:35 UTC (rev 2653)
@@ -219,7 +219,7 @@
free_object_data();
return OK;
- }
+ }
/* if no command was specified... */
if(command_type == CMD_NONE) {
Modified: nagioscore/branches/nagios-3-4-x/cgi/getcgi.c
===================================================================
--- nagioscore/branches/nagios-3-4-x/cgi/getcgi.c 2013-03-09 21:12:46 UTC (rev 2652)
+++ nagioscore/branches/nagios-3-4-x/cgi/getcgi.c 2013-03-09 21:46:35 UTC (rev 2653)
@@ -129,7 +129,7 @@
/* Attempt to set the locale */
accept_language = getenv("HTTP_ACCEPT_LANGUAGE");
- process_language( accept_language);
+ process_language(accept_language);
/* depending on the request method, read all CGI input into cgiinput */
@@ -142,7 +142,7 @@
/* check for NULL query string environment variable - 04/28/00 (Ludo Bosmans) */
if(getenv("QUERY_STRING") == NULL) {
cgiinput = (char *)malloc(1);
- if(cgiinput != NULL)
+ if(cgiinput != NULL)
cgiinput[0] = '\x0';
}
else
@@ -227,7 +227,7 @@
nvpair = strtok(cgiinput, "&");
while(nvpair) {
pairlist[paircount] = strdup(nvpair);
- if( NULL == pairlist[paircount]) {
+ if(NULL == pairlist[paircount]) {
printf("getcgivars(): Could not allocate memory for name-value pair #%d.\n", paircount);
exit(1);
}
@@ -257,7 +257,7 @@
if((eqpos = strchr(pairlist[i], '=')) != NULL) {
*eqpos = '\0';
cgivars[i * 2 + 1] = strdup(eqpos + 1);
- if( NULL == cgivars[ i * 2 + 1]) {
+ if(NULL == cgivars[ i * 2 + 1]) {
printf("getcgivars(): Could not allocate memory for cgi value #%d.\n", i);
exit(1);
}
@@ -265,7 +265,7 @@
}
else {
cgivars[i * 2 + 1] = strdup("");
- if( NULL == cgivars[ i * 2 + 1]) {
+ if(NULL == cgivars[ i * 2 + 1]) {
printf("getcgivars(): Could not allocate memory for empty stringfor variable value #%d.\n", i);
exit(1);
}
@@ -274,7 +274,7 @@
/* get the variable value (or name/value of there was no real "pair" in the first place) */
cgivars[i * 2] = strdup(pairlist[i]);
- if( NULL == cgivars[ i * 2]) {
+ if(NULL == cgivars[ i * 2]) {
printf("getcgivars(): Could not allocate memory for cgi name #%d.\n", i);
exit(1);
}
@@ -299,42 +299,42 @@
/* Set the locale based on the HTTP_ACCEPT_LANGUAGE variable value sent by
the browser */
-void process_language( char * accept_language) {
+void process_language(char * accept_language) {
accept_languages *accept_langs = NULL;
int x;
char locale_string[ 64];
char * locale = NULL;
char * locale_failsafe[] = { "en_US.utf8", "POSIX", "C" };
- if( accept_language != NULL) {
- accept_langs = parse_accept_languages( accept_language);
- }
+ if(accept_language != NULL) {
+ accept_langs = parse_accept_languages(accept_language);
+ }
- if( NULL != accept_langs) {
+ if(NULL != accept_langs) {
/* Sort the results */
- qsort( accept_langs->languages, accept_langs->count,
- sizeof( accept_langs->languages[ 0]), compare_accept_languages);
+ qsort(accept_langs->languages, accept_langs->count,
+ sizeof(accept_langs->languages[ 0]), compare_accept_languages);
/* Try each language in order of priority */
- for( x = 0; (( x < accept_langs->count) && ( NULL == locale)); x++) {
- snprintf( locale_string, sizeof( locale_string), "%s_%s.%s",
- accept_langs->languages[ x]->language,
- accept_langs->languages[ x]->locality, "utf8");
- locale = setlocale( LC_ALL, locale_string);
+ for(x = 0; ((x < accept_langs->count) && (NULL == locale)); x++) {
+ snprintf(locale_string, sizeof(locale_string), "%s_%s.%s",
+ accept_langs->languages[ x]->language,
+ accept_langs->languages[ x]->locality, "utf8");
+ locale = setlocale(LC_ALL, locale_string);
+ }
+
+ free_accept_languages(accept_langs);
}
-
- free_accept_languages( accept_langs);
- }
- if( NULL == locale) { /* Still isn't set */
+ if(NULL == locale) { /* Still isn't set */
/* Try the fail safe locales */
- for( x = 0; (( x < ( sizeof( locale_failsafe) / sizeof( char *))) &&
- ( NULL == locale)); x++) {
- locale = setlocale( LC_ALL, locale_failsafe[ x]);
+ for(x = 0; ((x < (sizeof(locale_failsafe) / sizeof(char *))) &&
+ (NULL == locale)); x++) {
+ locale = setlocale(LC_ALL, locale_failsafe[ x]);
+ }
}
}
-}
-accept_languages * parse_accept_languages( char * acceptlang) {
+accept_languages * parse_accept_languages(char * acceptlang) {
char * langdup; /* Duplicate of accept language for parsing */
accept_languages *langs = NULL;
char * langtok; /* Language token (language + locality + q value) */
@@ -346,164 +346,164 @@
/* If the browser did not pass an HTTP_ACCEPT_LANGUAGE variable, there
is not much we can do */
- if( NULL == acceptlang) {
+ if(NULL == acceptlang) {
return NULL;
- }
+ }
/* Duplicate the browser supplied HTTP_ACCEPT_LANGUAGE variable */
- if( NULL == ( langdup = strdup( acceptlang))) {
- printf( "Unable to allocate memory for langdup\n");
+ if(NULL == (langdup = strdup(acceptlang))) {
+ printf("Unable to allocate memory for langdup\n");
return NULL;
- }
+ }
/* Initialize the structure to contain the parsed HTTP_ACCEPT_LANGUAGE
information */
- if( NULL == ( langs = malloc( sizeof( accept_languages)))) {
- printf( "Unable to allocate memory for langs\n");
- free( langdup);
+ if(NULL == (langs = malloc(sizeof(accept_languages)))) {
+ printf("Unable to allocate memory for langs\n");
+ free(langdup);
return NULL;
- }
+ }
langs->count = 0;
- langs->languages = ( accept_language **)NULL;
+ langs->languages = (accept_language **)NULL;
/* Tokenize the HTTP_ACCEPT_LANGUAGE string */
- langtok = strtok_r( langdup, ",", &saveptr);
- while( langtok != NULL) {
+ langtok = strtok_r(langdup, ",", &saveptr);
+ while(langtok != NULL) {
/* Bump the count and allocate memory for structures */
langs->count++;
- if( NULL == langs->languages) {
+ if(NULL == langs->languages) {
/* Adding first language */
- if( NULL == ( langs->languages =
- malloc( langs->count * sizeof( accept_language *)))) {
- printf( "Unable to allocate memory for first language\n");
+ if(NULL == (langs->languages =
+ malloc(langs->count * sizeof(accept_language *)))) {
+ printf("Unable to allocate memory for first language\n");
langs->count--;
- free_accept_languages( langs);
- free( langdup);
+ free_accept_languages(langs);
+ free(langdup);
return NULL;
+ }
}
- }
else {
/* Adding additional language */
- if( NULL == ( langs->languages = realloc( langs->languages,
- langs->count * sizeof( accept_language *)))) {
- printf( "Unable to allocate memory for additional language\n");
+ if(NULL == (langs->languages = realloc(langs->languages,
+ langs->count * sizeof(accept_language *)))) {
+ printf("Unable to allocate memory for additional language\n");
langs->count--;
- free_accept_languages( langs);
- free( langdup);
+ free_accept_languages(langs);
+ free(langdup);
return NULL;
+ }
}
- }
- if( NULL == ( langs->languages[ langs->count - 1] =
- malloc( sizeof( accept_language)))) {
- printf( "Unable to allocate memory for language\n");
+ if(NULL == (langs->languages[ langs->count - 1] =
+ malloc(sizeof(accept_language)))) {
+ printf("Unable to allocate memory for language\n");
langs->count--;
- free_accept_languages( langs);
- free( langdup);
+ free_accept_languages(langs);
+ free(langdup);
return NULL;
- }
- langs->languages[ langs->count - 1]->language = ( char *)NULL;
- langs->languages[ langs->count - 1]->locality = ( char *)NULL;
+ }
+ langs->languages[ langs->count - 1]->language = (char *)NULL;
+ langs->languages[ langs->count - 1]->locality = (char *)NULL;
langs->languages[ langs->count - 1]->q = 1.0;
-
+
/* Check to see if there is a q value */
- qdelim = strstr( langtok, ACCEPT_LANGUAGE_Q_DELIMITER);
+ qdelim = strstr(langtok, ACCEPT_LANGUAGE_Q_DELIMITER);
- if( NULL != qdelim) { /* found a q value */
- langs->languages[ langs->count - 1]->q =
- strtod( qdelim + strlen( ACCEPT_LANGUAGE_Q_DELIMITER), NULL);
+ if(NULL != qdelim) { /* found a q value */
+ langs->languages[ langs->count - 1]->q =
+ strtod(qdelim + strlen(ACCEPT_LANGUAGE_Q_DELIMITER), NULL);
langtok[ qdelim - langtok] = '\0';
- }
+ }
/* Check to see if there is a locality specifier */
- if( NULL == ( localitydelim = strchr( langtok, '-'))) {
- localitydelim = strchr( langtok, '_');
- }
+ if(NULL == (localitydelim = strchr(langtok, '-'))) {
+ localitydelim = strchr(langtok, '_');
+ }
- if( NULL != localitydelim) {
+ if(NULL != localitydelim) {
/* We have a locality delimiter, so copy it */
- if( NULL == ( langs->languages[ langs->count - 1]->locality =
- strdup( localitydelim + 1))) {
- printf( "Unable to allocate memory for locality '%s'\n",
- langtok);
- free_accept_languages( langs);
- free( langdup);
+ if(NULL == (langs->languages[ langs->count - 1]->locality =
+ strdup(localitydelim + 1))) {
+ printf("Unable to allocate memory for locality '%s'\n",
+ langtok);
+ free_accept_languages(langs);
+ free(langdup);
return NULL;
- }
+ }
/* Ensure it is upper case */
- for( x = 0, stp = langs->languages[ langs->count - 1]->locality;
- x < strlen( langs->languages[ langs->count - 1]->locality);
- x++, stp++) {
- *stp = toupper( *stp);
- }
+ for(x = 0, stp = langs->languages[ langs->count - 1]->locality;
+ x < strlen(langs->languages[ langs->count - 1]->locality);
+ x++, stp++) {
+ *stp = toupper(*stp);
+ }
/* Then null out the delimiter so the language copy works */
*localitydelim = '\0';
- }
- if( NULL == ( langs->languages[ langs->count - 1]->language =
- strdup( langtok))) {
- printf( "Unable to allocate memory for language '%s'\n",
- langtok);
- free_accept_languages( langs);
- free( langdup);
+ }
+ if(NULL == (langs->languages[ langs->count - 1]->language =
+ strdup(langtok))) {
+ printf("Unable to allocate memory for language '%s'\n",
+ langtok);
+ free_accept_languages(langs);
+ free(langdup);
return NULL;
+ }
+
+ /* Get the next language token */
+ langtok = strtok_r(NULL, ",", &saveptr);
}
- /* Get the next language token */
- langtok = strtok_r( NULL, ",", &saveptr);
+ free(langdup);
+ return langs;
}
- free( langdup);
- return langs;
-}
+int compare_accept_languages(const void *p1, const void *p2) {
+ accept_language * lang1 = *(accept_language **)p1;
+ accept_language * lang2 = *(accept_language **)p2;
-int compare_accept_languages( const void *p1, const void *p2) {
- accept_language * lang1 = *( accept_language **)p1;
- accept_language * lang2 = *( accept_language **)p2;
-
- if( lang1->q == lang2->q) {
- if((( NULL == lang1->locality) && ( NULL == lang2->locality)) ||
- (( NULL != lang1->locality) && ( NULL != lang2->locality))) {
+ if(lang1->q == lang2->q) {
+ if(((NULL == lang1->locality) && (NULL == lang2->locality)) ||
+ ((NULL != lang1->locality) && (NULL != lang2->locality))) {
return 0;
- }
- else if( NULL != lang1->locality) {
+ }
+ else if(NULL != lang1->locality) {
return -1;
- }
+ }
else { /* NULL != lang2->locality */
return 1;
+ }
}
- }
else {
- return( lang2->q > lang1->q);
+ return(lang2->q > lang1->q);
+ }
}
-}
-void free_accept_languages( accept_languages * langs) {
+void free_accept_languages(accept_languages * langs) {
int x;
- if( NULL == langs) {
+ if(NULL == langs) {
return;
- }
+ }
- for( x = 0; x < langs->count; x++) {
- if( NULL != langs->languages[ x]) {
- if( langs->languages[ x]->language != NULL) {
- free( langs->languages[ x]->language);
+ for(x = 0; x < langs->count; x++) {
+ if(NULL != langs->languages[ x]) {
+ if(langs->languages[ x]->language != NULL) {
+ free(langs->languages[ x]->language);
+ }
+ if(langs->languages[ x]->locality != NULL) {
+ free(langs->languages[ x]->locality);
+ }
+ free(langs->languages[ x]);
}
- if( langs->languages[ x]->locality != NULL) {
- free( langs->languages[ x]->locality);
- }
- free( langs->languages[ x]);
}
- }
- if( langs->languages != NULL) {
- free( langs->languages);
- }
- free( langs);
+ if(langs->languages != NULL) {
+ free(langs->languages);
+ }
+ free(langs);
return;
-}
+ }
/* free() memory allocated to storing the CGI variables */
void free_cgivars(char **cgivars) {
Modified: nagioscore/branches/nagios-3-4-x/cgi/history.c
===================================================================
--- nagioscore/branches/nagios-3-4-x/cgi/history.c 2013-03-09 21:12:46 UTC (rev 2652)
+++ nagioscore/branches/nagios-3-4-x/cgi/history.c 2013-03-09 21:46:35 UTC (rev 2653)
@@ -805,22 +805,22 @@
else if(display_type == DISPLAY_HOSTS) {
if(history_type == HOST_HISTORY || history_type == SERVICE_HISTORY) {
- snprintf(match1, sizeof( match1),
- " HOST ALERT: %s;", host_name);
- snprintf(match2, sizeof( match2),
- " SERVICE ALERT: %s;", host_name);
+ snprintf(match1, sizeof(match1),
+ " HOST ALERT: %s;", host_name);
+ snprintf(match2, sizeof(match2),
+ " SERVICE ALERT: %s;", host_name);
}
else if(history_type == HOST_FLAPPING_HISTORY || history_type == SERVICE_FLAPPING_HISTORY) {
- snprintf(match1, sizeof( match1),
- " HOST FLAPPING ALERT: %s;", host_name);
- snprintf(match2, sizeof( match2),
- " SERVICE FLAPPING ALERT: %s;", host_name);
+ snprintf(match1, sizeof(match1),
+ " HOST FLAPPING ALERT: %s;", host_name);
+ snprintf(match2, sizeof(match2),
+ " SERVICE FLAPPING ALERT: %s;", host_name);
}
else if(history_type == HOST_DOWNTIME_HISTORY || history_type == SERVICE_DOWNTIME_HISTORY) {
- snprintf(match1, sizeof( match1),
- " HOST DOWNTIME ALERT: %s;", host_name);
- snprintf(match2, sizeof( match2),
- " SERVICE DOWNTIME ALERT: %s;", host_name);
+ snprintf(match1, sizeof(match1),
+ " HOST DOWNTIME ALERT: %s;", host_name);
+ snprintf(match2, sizeof(match2),
+ " SERVICE DOWNTIME ALERT: %s;", host_name);
}
if(show_all_hosts == TRUE)
@@ -859,11 +859,11 @@
else if(display_type == DISPLAY_SERVICES) {
if(history_type == SERVICE_HISTORY)
- snprintf(match1, sizeof( match1), " SERVICE ALERT: %s;%s;", host_name, svc_description);
+ snprintf(match1, sizeof(match1), " SERVICE ALERT: %s;%s;", host_name, svc_description);
else if(history_type == SERVICE_FLAPPING_HISTORY)
- snprintf(match1, sizeof( match1), " SERVICE FLAPPING ALERT: %s;%s;", host_name, svc_description);
+ snprintf(match1, sizeof(match1), " SERVICE FLAPPING ALERT: %s;%s;", host_name, svc_description);
else if(history_type == SERVICE_DOWNTIME_HISTORY)
- snprintf(match1, sizeof( match1), " SERVICE DOWNTIME ALERT: %s;%s;", host_name, svc_description);
+ snprintf(match1, sizeof(match1), " SERVICE DOWNTIME ALERT: %s;%s;", host_name, svc_description);
if(strstr(temp_buffer, match1) && (history_type == SERVICE_HISTORY || history_type == SERVICE_FLAPPING_HISTORY || history_type == SERVICE_DOWNTIME_HISTORY))
display_line = TRUE;
Modified: nagioscore/branches/nagios-3-4-x/cgi/status.c
===================================================================
--- nagioscore/branches/nagios-3-4-x/cgi/status.c 2013-03-09 21:12:46 UTC (rev 2652)
+++ nagioscore/branches/nagios-3-4-x/cgi/status.c 2013-03-09 21:46:35 UTC (rev 2653)
@@ -128,8 +128,8 @@
void show_hostgroup_grid(hostgroup *);
void show_filters(void);
-void create_pagenumbers(int total_entries,int visible_entries, char *temp_url,int type_service);
-void create_page_limiter(int result_limit,char *temp_url);
+void create_pagenumbers(int total_entries, int visible_entries, char *temp_url, int type_service);
+void create_page_limiter(int result_limit, char *temp_url);
int passes_host_properties_filter(hoststatus *);
int passes_service_properties_filter(servicestatus *);
@@ -158,8 +158,8 @@
int group_style_type = STYLE_OVERVIEW;
int navbar_search = FALSE;
-/* experimental paging feature */
-int temp_result_limit;
+/* experimental paging feature */
+int temp_result_limit;
int page_start;
int limit_results = TRUE;
@@ -554,15 +554,15 @@
printf("<link rel='stylesheet' type='text/css' href='%s%s' />\n", url_stylesheets_path, COMMON_CSS);
printf("<link rel='stylesheet' type='text/css' href='%s%s' />\n", url_stylesheets_path, STATUS_CSS);
}
-
- /* added jquery library 1/31/2012 */
- printf("<script type='text/javascript' src='%s%s'></script>\n",url_js_path, JQUERY_JS);
- /* JS function to append content to elements on page */
- printf("<script type='text/javascript'>\n");
- printf("$(document).ready(function() { $('#top_page_numbers').append($('#bottom_page_numbers').html() ); });");
+
+ /* added jquery library 1/31/2012 */
+ printf("<script type='text/javascript' src='%s%s'></script>\n", url_js_path, JQUERY_JS);
+ /* JS function to append content to elements on page */
+ printf("<script type='text/javascript'>\n");
+ printf("$(document).ready(function() { $('#top_page_numbers').append($('#bottom_page_numbers').html() ); });");
printf("function set_limit(url) { \nthis.location = url+'&limit='+$('#limit').val();\n }");
printf("</script>\n");
-
+
printf("</head>\n");
printf("<body class='status'>\n");
@@ -787,7 +787,7 @@
service_filter = strdup(variables[x]);
strip_html_brackets(service_filter);
}
-
+
/* experimental page limit feature */
else if(!strcmp(variables[x], "start")) {
x++;
@@ -796,23 +796,23 @@
break;
}
page_start = atoi(variables[x]);
- }
+ }
else if(!strcmp(variables[x], "limit")) {
x++;
if(variables[x] == NULL) {
error = TRUE;
break;
}
- temp_result_limit = atoi(variables[x]);
- if(temp_result_limit == 0)
+ temp_result_limit = atoi(variables[x]);
+ if(temp_result_limit == 0)
limit_results = FALSE;
- else
- limit_results = TRUE;
- }
-
+ else
+ limit_results = TRUE;
+ }
+
}
-
+
/* free memory allocated to the CGI variables */
free_cgivars(variables);
@@ -896,9 +896,9 @@
printf("<th class='serviceTotals'>");
printf("<a class='serviceTotals' href='%s?", STATUS_CGI);
- /* paging */
+ /* paging */
if(temp_result_limit)
- printf("limit=%i&",temp_result_limit);
+ printf("limit=%i&", temp_result_limit);
if(display_type == DISPLAY_HOSTS)
printf("host=%s", (host_name == NULL) ? "all" : url_encode(host_name));
else if(display_type == DISPLAY_SERVICEGROUPS)
@@ -911,9 +911,9 @@
printf("<th class='serviceTotals'>");
printf("<a class='serviceTotals' href='%s?", STATUS_CGI);
- /* paging */
+ /* paging */
if(temp_result_limit)
- printf("limit=%i&",temp_result_limit);
+ printf("limit=%i&", temp_result_limit);
if(display_type == DISPLAY_HOSTS)
printf("host=%s", (host_name == NULL) ? "all" : url_encode(host_name));
else if(display_type == DISPLAY_SERVICEGROUPS)
@@ -926,9 +926,9 @@
printf("<th class='serviceTotals'>");
printf("<a class='serviceTotals' href='%s?", STATUS_CGI);
- /* paging */
+ /* paging */
if(temp_result_limit)
- printf("limit=%i&",temp_result_limit);
+ printf("limit=%i&", temp_result_limit);
if(display_type == DISPLAY_HOSTS)
printf("host=%s", (host_name == NULL) ? "all" : url_encode(host_name));
else if(display_type == DISPLAY_SERVICEGROUPS)
@@ -941,9 +941,9 @@
printf("<th class='serviceTotals'>");
printf("<a class='serviceTotals' href='%s?", STATUS_CGI);
- /* paging */
+ /* paging */
if(temp_result_limit)
- printf("limit=%i&",temp_result_limit);
+ printf("limit=%i&", temp_result_limit);
if(display_type == DISPLAY_HOSTS)
printf("host=%s", (host_name == NULL) ? "all" : url_encode(host_name));
else if(display_type == DISPLAY_SERVICEGROUPS)
@@ -956,9 +956,9 @@
printf("<th class='serviceTotals'>");
printf("<a class='serviceTotals' href='%s?", STATUS_CGI);
- /* paging */
+ /* paging */
if(temp_result_limit)
- printf("limit=%i&",temp_result_limit);
+ printf("limit=%i&", temp_result_limit);
if(display_type == DISPLAY_HOSTS)
printf("host=%s", (host_name == NULL) ? "all" : url_encode(host_name));
else if(display_type == DISPLAY_SERVICEGROUPS)
@@ -1000,9 +1000,9 @@
printf("<th class='serviceTotals'>");
printf("<a class='serviceTotals' href='%s?", STATUS_CGI);
- /* paging */
+ /* paging */
if(temp_result_limit)
- printf("limit=%i&",temp_result_limit);
+ printf("limit=%i&", temp_result_limit);
if(display_type == DISPLAY_HOSTS)
printf("host=%s", (host_name == NULL) ? "all" : url_encode(host_name));
else if(display_type == DISPLAY_SERVICEGROUPS)
@@ -1015,9 +1015,9 @@
printf("<th class='serviceTotals'>");
printf("<a class='serviceTotals' href='%s?", STATUS_CGI);
- /* paging */
+ /* paging */
if(temp_result_limit)
- printf("limit=%i&",temp_result_limit);
+ printf("limit=%i&", temp_result_limit);
if(display_type == DISPLAY_HOSTS)
printf("host=%s", (host_name == NULL) ? "all" : url_encode(host_name));
else if(display_type == DISPLAY_SERVICEGROUPS)
@@ -1122,9 +1122,9 @@
printf("<th class='hostTotals'>");
printf("<a class='hostTotals' href='%s?", STATUS_CGI);
- /* paging */
+ /* paging */
if(temp_result_limit)
- printf("limit=%i&",temp_result_limit);
+ printf("limit=%i&", temp_result_limit);
if(display_type == DISPLAY_HOSTS)
printf("host=%s", (host_name == NULL) ? "all" : url_encode(host_name));
else if(display_type == DISPLAY_SERVICEGROUPS)
@@ -1143,9 +1143,9 @@
printf("<th class='hostTotals'>");
printf("<a class='hostTotals' href='%s?", STATUS_CGI);
- /* paging */
+ /* paging */
if(temp_result_limit)
- printf("limit=%i&",temp_result_limit);
+ printf("limit=%i&", temp_result_limit);
if(display_type == DISPLAY_HOSTS)
printf("host=%s", (host_name == NULL) ? "all" : url_encode(host_name));
else if(display_type == DISPLAY_SERVICEGROUPS)
@@ -1164,9 +1164,9 @@
printf("<th class='hostTotals'>");
printf("<a class='hostTotals' href='%s?", STATUS_CGI);
- /* paging */
+ /* paging */
if(temp_result_limit)
- printf("limit=%i&",temp_result_limit);
+ printf("limit=%i&", temp_result_limit);
if(display_type == DISPLAY_HOSTS)
printf("host=%s", (host_name == NULL) ? "all" : url_encode(host_name));
else if(display_type == DISPLAY_SERVICEGROUPS)
@@ -1185,9 +1185,9 @@
printf("<th class='hostTotals'>");
printf("<a class='hostTotals' href='%s?", STATUS_CGI);
- /* paging */
+ /* paging */
if(temp_result_limit)
- printf("limit=%i&",temp_result_limit);
+ printf("limit=%i&", temp_result_limit);
if(display_type == DISPLAY_HOSTS)
printf("host=%s", (host_name == NULL) ? "all" : url_encode(host_name));
else if(display_type == DISPLAY_SERVICEGROUPS)
@@ -1231,9 +1231,9 @@
printf("<th class='hostTotals'>");
printf("<a class='hostTotals' href='%s?", STATUS_CGI);
- /* paging */
+ /* paging */
if(temp_result_limit)
- printf("limit=%i&",temp_result_limit);
+ printf("limit=%i&", temp_result_limit);
if(display_type == DISPLAY_HOSTS)
printf("host=%s", (host_name == NULL) ? "all" : url_encode(host_name));
else if(display_type == DISPLAY_SERVICEGROUPS)
@@ -1252,9 +1252,9 @@
printf("<th class='hostTotals'>");
printf("<a class='hostTotals' href='%s?", STATUS_CGI);
- /* paging */
+ /* paging */
if(temp_result_limit)
- printf("limit=%i&",temp_result_limit);
+ printf("limit=%i&", temp_result_limit);
if(display_type == DISPLAY_HOSTS)
printf("host=%s", (host_name == NULL) ? "all" : url_encode(host_name));
else if(display_type == DISPLAY_SERVICEGROUPS)
@@ -1408,11 +1408,11 @@
- /* handle navigation GET variables */
+ /* handle navigation GET variables */
snprintf(temp_url, sizeof(temp_url) - 1, "%s?", STATUS_CGI);
temp_url[sizeof(temp_url) - 1] = '\x0';
if(display_type == DISPLAY_HOSTS)
- snprintf(temp_buffer, sizeof(temp_buffer) - 1, "%shost=%s", (navbar_search == TRUE) ? "&navbarsearch=1&" : "", (host_name == NULL) ? "all" : url_encode(host_name));
+ snprintf(temp_buffer, sizeof(temp_buffer) - 1, "%shost=%s", (navbar_search == TRUE) ? "&navbarsearch=1&" : "", (host_name == NULL) ? "all" : url_encode(host_name));
else if(display_type == DISPLAY_SERVICEGROUPS)
snprintf(temp_buffer, sizeof(temp_buffer) - 1, "servicegroup=%s&style=detail", url_encode(servicegroup_name));
else
@@ -1444,7 +1444,7 @@
strncat(temp_url, temp_buffer, sizeof(temp_url) - strlen(temp_url) - 1);
temp_url[sizeof(temp_url) - 1] = '\x0';
}
- /*
+ /*
if(temp_result_limit) {
snprintf(temp_buffer, sizeof(temp_buffer) - 1, "&limit=%i", temp_result_limit);
temp_buffer[sizeof(temp_buffer) - 1] = '\x0';
@@ -1452,28 +1452,28 @@
temp_url[sizeof(temp_url) - 1] = '\x0';
}
*/
-
- if (sort_type != SORT_NONE) {
- snprintf(temp_buffer, sizeof(temp_buffer), "&sorttype=%i&sortoption=%i", sort_type, sort_option);
- temp_buffer[sizeof(temp_buffer) - 1] = '\x0';
- strncat(temp_url, temp_buffer, sizeof(temp_url) - strlen(temp_url) - 1);
- temp_url[sizeof(temp_url) - 1] = '\x0';
- }
+ if(sort_type != SORT_NONE) {
+ snprintf(temp_buffer, sizeof(temp_buffer), "&sorttype=%i&sortoption=%i", sort_type, sort_option);
+ temp_buffer[sizeof(temp_buffer) - 1] = '\x0';
+ strncat(temp_url, temp_buffer, sizeof(temp_url) - strlen(temp_url) - 1);
+ temp_url[sizeof(temp_url) - 1] = '\x0';
+ }
+
/* GET input can override cgi.cfg */
- if(limit_results==TRUE)
+ if(limit_results == TRUE)
result_limit = temp_result_limit ? temp_result_limit : result_limit;
- else
- result_limit = 0;
+ else
+ result_limit = 0;
/* select box to set result limit */
- if(result_limit) {
- snprintf(temp_buffer, sizeof(temp_buffer) - 1, "&limit=%i", temp_result_limit);
- temp_buffer[sizeof(temp_buffer) - 1] = '\x0';
- strncat(temp_url, temp_buffer, sizeof(temp_url) - strlen(temp_url) - 1);
- temp_url[sizeof(temp_url) - 1] = '\x0';
- }
- create_page_limiter(result_limit,temp_url);
-
+ if(result_limit) {
+ snprintf(temp_buffer, sizeof(temp_buffer) - 1, "&limit=%i", temp_result_limit);
+ temp_buffer[sizeof(temp_buffer) - 1] = '\x0';
+ strncat(temp_url, temp_buffer, sizeof(temp_url) - strlen(temp_url) - 1);
+ temp_url[sizeof(temp_url) - 1] = '\x0';
+ }
+ create_page_limiter(result_limit, temp_url);
+
/* the main list of services */
printf("<table border=0 width=100%% class='status'>\n");
printf("<tr>\n");
@@ -1504,7 +1504,7 @@
/* check all services... */
while(1) {
-
+
/* get the next service to display */
if(use_sort == TRUE) {
if(first_entry == TRUE)
@@ -1592,18 +1592,18 @@
show_service = TRUE;
}
- /* final checks for display visibility, add to total results. Used for page numbers */
- if(result_limit == 0)
- limit_results = FALSE;
-
- if( (limit_results == TRUE && show_service== TRUE) && ( (total_entries < page_start) || (total_entries >= (page_start + result_limit)) ) ) {
+ /* final checks for display visibility, add to total results. Used for page numbers */
+ if(result_limit == 0)
+ limit_results = FALSE;
+
+ if((limit_results == TRUE && show_service == TRUE) && ((total_entries < page_start) || (total_entries >= (page_start + result_limit)))) {
total_entries++;
- show_service = FALSE;
- }
+ show_service = FALSE;
+ }
/* a visible entry */
if(show_service == TRUE) {
- if(strcmp(last_host, temp_status->host_name) || visible_entries == 0 )
+ if(strcmp(last_host, temp_status->host_name) || visible_entries == 0)
new_host = TRUE;
else
new_host = FALSE;
@@ -1613,15 +1613,15 @@
printf("<tr><td colspan='6'></td></tr>\n");
printf("<tr><td colspan='6'></td></tr>\n");
}
- }
+ }
if(odd)
odd = 0;
else
odd = 1;
-
+
/* keep track of total number of services we're displaying */
- visible_entries++;
+ visible_entries++;
total_entries++;
/* get the last service check time */
@@ -1913,7 +1913,7 @@
printf("</tr>\n");
/* mod to account for paging */
- if(visible_entries != 0)
+ if(visible_entries != 0)
last_host = temp_status->host_name;
}
@@ -1935,10 +1935,10 @@
}
}
else {
- /* do page numbers if applicable */
- create_pagenumbers(total_entries,visible_entries,temp_url,TRUE);
+ /* do page numbers if applicable */
+ create_pagenumbers(total_entries, visible_entries, temp_url, TRUE);
}
-
+
return;
}
@@ -1989,8 +1989,8 @@
// printf("<P>\n");
-
+
printf("<table class='pageTitle' border='0' width='100%%'>\n");
printf("<tr>\n");
@@ -2070,23 +2070,23 @@
temp_buffer[sizeof(temp_buffer) - 1] = '\x0';
strncat(temp_url, temp_buffer, sizeof(temp_url) - strlen(temp_url) - 1);
temp_url[sizeof(temp_url) - 1] = '\x0';
- }
- /*
+ }
+ /*
if(temp_result_limit) {
snprintf(temp_buffer, sizeof(temp_buffer) - 1, "&limit=%i", temp_result_limit);
temp_buffer[sizeof(temp_buffer) - 1] = '\x0';
strncat(temp_url, temp_buffer, sizeof(temp_url) - strlen(temp_url) - 1);
temp_url[sizeof(temp_url) - 1] = '\x0';
- }
+ }
*/
/* GET input can override cgi.cfg */
- if(limit_results==TRUE)
+ if(limit_results == TRUE)
result_limit = temp_result_limit ? temp_result_limit : result_limit;
- else
- result_limit = 0;
+ else
+ result_limit = 0;
/* select box to set result limit */
- create_page_limiter(result_limit,temp_url);
+ create_page_limiter(result_limit, temp_url);
/* the main list of hosts */
@@ -2165,18 +2165,18 @@
total_entries++;
-
- /* final checks for display visibility, add to total results. Used for page numbers */
- if(result_limit == 0)
- limit_results = FALSE;
-
- if( (limit_results == TRUE) && ( (total_entries < page_start) || (total_entries >= (page_start + result_limit)) ) ) {
- continue;
- }
-
- visible_entries++;
-
+ /* final checks for display visibility, add to total results. Used for page numbers */
+ if(result_limit == 0)
+ limit_results = FALSE;
+
+ if((limit_results == TRUE) && ((total_entries < page_start) || (total_entries >= (page_start + result_limit)))) {
+ continue;
+ }
+
+ visible_entries++;
+
+
/* grab macros */
grab_host_macros_r(mac, temp_host);
@@ -2372,8 +2372,8 @@
}
else {
- /* do page numbers if applicable */
- create_pagenumbers(total_entries,visible_entries,temp_url,FALSE);
+ /* do page numbers if applicable */
+ create_pagenumbers(total_entries, visible_entries, temp_url, FALSE);
}
return;
}
@@ -5400,68 +5400,68 @@
return;
}
-void create_pagenumbers(int total_entries,int visible_entries,char *temp_url,int type_service) {
+void create_pagenumbers(int total_entries, int visible_entries, char *temp_url, int type_service) {
- int pages = 1;
- int leftovers = 0;
- int tmp_start;
+ int pages = 1;
+ int leftovers = 0;
+ int tmp_start;
int i;
int next_page;
- int previous_page;
+ int previous_page;
- /* do page numbers if applicable */
+ /* do page numbers if applicable */
if(result_limit > 0 && total_entries > result_limit) {
- pages = (total_entries / result_limit);
- leftovers = (total_entries % result_limit);
- previous_page = (page_start-result_limit) > 0 ? (page_start-result_limit) : 0;
- next_page = (page_start+result_limit) > total_entries ? page_start : (page_start+result_limit);
+ pages = (total_entries / result_limit);
+ leftovers = (total_entries % result_limit);
+ previous_page = (page_start - result_limit) > 0 ? (page_start - result_limit) : 0;
+ next_page = (page_start + result_limit) > total_entries ? page_start : (page_start + result_limit);
printf("<div id='bottom_page_numbers'>\n");
- printf("<div class='inner_numbers'>\n");
- printf("<a href='%s&start=0&limit=%i' class='pagenumber' title='First Page'><img src='%s%s' height='15' width='15' alt='<<' /></a>\n",temp_url,result_limit,url_images_path,FIRST_PAGE_ICON);
- printf("<a href='%s&start=%i&limit=%i' class='pagenumber' title='Previous Page'><img src='%s%s' height='15' width='10' alt='<' /></a>\n",temp_url,previous_page,result_limit,url_images_path,PREVIOUS_PAGE_ICON);
+ printf("<div class='inner_numbers'>\n");
+ printf("<a href='%s&start=0&limit=%i' class='pagenumber' title='First Page'><img src='%s%s' height='15' width='15' alt='<<' /></a>\n", temp_url, result_limit, url_images_path, FIRST_PAGE_ICON);
+ printf("<a href='%s&start=%i&limit=%i' class='pagenumber' title='Previous Page'><img src='%s%s' height='15' width='10' alt='<' /></a>\n", temp_url, previous_page, result_limit, url_images_path, PREVIOUS_PAGE_ICON);
for(i = 0; i < (pages + 1); i++) {
tmp_start = (i * result_limit);
- if(tmp_start == page_start)
- printf("<div class='pagenumber current_page'> %i </div>\n",(i+1));
- else
- printf("<a class='pagenumber' href='%s&start=%i&limit=%i' title='Page %i'> %i </a>\n",temp_url,tmp_start,result_limit,(i+1),(i+1));
+ if(tmp_start == page_start)
+ printf("<div class='pagenumber current_page'> %i </div>\n", (i + 1));
+ else
+ printf("<a class='pagenumber' href='%s&start=%i&limit=%i' title='Page %i'> %i </a>\n", temp_url, tmp_start, result_limit, (i + 1), (i + 1));
}
-
- printf("<a href='%s&start=%i&limit=%i' class='pagenumber' title='Next Page'><img src='%s%s' height='15' width='10' alt='>' /></a>\n",temp_url,(page_start+result_limit),result_limit,url_images_path,NEXT_PAGE_ICON);
- printf("<a href='%s&start=%i&limit=%i' class='pagenumber' title='Last Page'><img src='%s%s' height='15' width='15' alt='>>' /></a>\n",temp_url,((pages)*result_limit),result_limit,url_images_path,LAST_PAGE_ICON);
+
+ printf("<a href='%s&start=%i&limit=%i' class='pagenumber' title='Next Page'><img src='%s%s' height='15' width='10' alt='>' /></a>\n", temp_url, (page_start + result_limit), result_limit, url_images_path, NEXT_PAGE_ICON);
+ printf("<a href='%s&start=%i&limit=%i' class='pagenumber' title='Last Page'><img src='%s%s' height='15' width='15' alt='>>' /></a>\n", temp_url, ((pages)*result_limit), result_limit, url_images_path, LAST_PAGE_ICON);
printf("</div> <!-- end inner_page_numbers div -->\n");
if(type_service == TRUE)
- printf("<br /><div class='itemTotalsTitle'>Results %i - %i of %d Matching Services</div>\n</div>\n",page_start,((page_start+result_limit) > total_entries ? total_entries :(page_start+result_limit) ),total_entries );
- else
- printf("<br /><div class='itemTotalsTitle'>Results %i - %i of %d Matching Hosts</div>\n\n",page_start,((page_start+result_limit) > total_entries ? total_entries :(page_start+result_limit) ),total_entries );
+ printf("<br /><div class='itemTotalsTitle'>Results %i - %i of %d Matching Services</div>\n</div>\n", page_start, ((page_start + result_limit) > total_entries ? total_entries : (page_start + result_limit)), total_entries);
+ else
+ printf("<br /><div class='itemTotalsTitle'>Results %i - %i of %d Matching Hosts</div>\n\n", page_start, ((page_start + result_limit) > total_entries ? total_entries : (page_start + result_limit)), total_entries);
printf("</div> <!-- end bottom_page_numbers div -->\n\n");
}
else {
if(type_service == TRUE)
- printf("<br /><div class='itemTotalsTitle'>Results %i - %i of %d Matching Services</div>\n</div>\n",1,total_entries,total_entries);
- else
- printf("<br /><div class='itemTotalsTitle'>Results %i - %i of %d Matching Hosts</div>\n\n",1,total_entries,total_entries);
-
+ printf("<br /><div class='itemTotalsTitle'>Results %i - %i of %d Matching Services</div>\n</div>\n", 1, total_entries, total_entries);
+ else
+ printf("<br /><div class='itemTotalsTitle'>Results %i - %i of %d Matching Hosts</div>\n\n", 1, total_entries, total_entries);
+
}
-
- /* show total results displayed */
+
+ /* show total results displayed */
//printf("<br /><div class='itemTotalsTitle'>Results %i - %i of %d Matching Services</div>\n</div>\n",page_start,((page_start+result_limit) > total_entries ? total_entries :(page_start+result_limit) ),total_entries );
-
+
}
-void create_page_limiter(int result_limit,char *temp_url) {
+void create_page_limiter(int result_limit, char *temp_url) {
- /* Result Limit Select Box */
+ /* Result Limit Select Box */
printf("<div id='pagelimit'>\n<div id='result_limit'>\n");
printf("<label for='limit'>Limit Results: </label>\n");
- printf("<select onchange='set_limit(\"%s\")' name='limit' id='limit'>\n",temp_url);
- printf("<option %s value='50'>50</option>\n",( (result_limit==50) ? "selected='selected'" : "") );
- printf("<option %s value='100'>100</option>\n",( (result_limit==100) ? "selected='selected'" : "") );
- printf("<option %s value='250'>250</option>\n",( (result_limit==250) ? "selected='selected'" : "") );
- printf("<option %s value='1000'>1000</option>\n",( (result_limit==1000) ? "selected='selected'" : "") );
- printf("<option %s value='0'>All</option>\n",(result_limit==0) ? "selected='selected'" : "");
+ printf("<select onchange='set_limit(\"%s\")' name='limit' id='limit'>\n", temp_url);
+ printf("<option %s value='50'>50</option>\n", ((result_limit == 50) ? "selected='selected'" : ""));
+ printf("<option %s value='100'>100</option>\n", ((result_limit == 100) ? "selected='selected'" : ""));
+ printf("<option %s value='250'>250</option>\n", ((result_limit == 250) ? "selected='selected'" : ""));
+ printf("<option %s value='1000'>1000</option>\n", ((result_limit == 1000) ? "selected='selected'" : ""));
+ printf("<option %s value='0'>All</option>\n", (result_limit == 0) ? "selected='selected'" : "");
printf("</select></div>\n");
printf("<div id='top_page_numbers'></div>\n</div>\n");
//page numbers
Modified: nagioscore/branches/nagios-3-4-x/common/comments.c
===================================================================
--- nagioscore/branches/nagios-3-4-x/common/comments.c 2013-03-09 21:12:46 UTC (rev 2652)
+++ nagioscore/branches/nagios-3-4-x/common/comments.c 2013-03-09 21:46:35 UTC (rev 2653)
@@ -317,7 +317,7 @@
/* delete comments from memory */
temp_comment = get_first_comment_by_host(hst->name);
- while (temp_comment) {
+ 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);
Modified: nagioscore/branches/nagios-3-4-x/common/downtime.c
===================================================================
--- nagioscore/branches/nagios-3-4-x/common/downtime.c 2013-03-09 21:12:46 UTC (rev 2652)
+++ nagioscore/branches/nagios-3-4-x/common/downtime.c 2013-03-09 21:46:35 UTC (rev 2653)
@@ -66,7 +66,7 @@
/* 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 ****/
@@ -81,7 +81,7 @@
/* 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 ****/
@@ -110,8 +110,8 @@
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;
+ start_time, end_time);
+ return ERROR;
}
@@ -259,32 +259,32 @@
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);
+ 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;
+ 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;
+ 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;
+ 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;
}
}
@@ -317,7 +317,7 @@
}
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) {
+ 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);
@@ -337,46 +337,46 @@
/*** 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((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
+ 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
+ /*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((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;
+ 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);
- }
-
+ /* 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 ****/
@@ -398,14 +398,14 @@
/* 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;
+ log_debug_info(DEBUGL_DOWNTIME, 1, "Unable to find downtime id: %lu\n",
+ downtime_id);
+ return ERROR;
}
/* handle the downtime */
@@ -436,14 +436,14 @@
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;
+ 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;
-
+ return ERROR;
+
}
}
@@ -542,7 +542,7 @@
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) {
+ 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;
}
@@ -556,7 +556,7 @@
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) {
+ 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;
}
@@ -579,11 +579,11 @@
/* 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);
+ event_time = (time_t)((unsigned long)temp_downtime->flex_downtime_start
+ + temp_downtime->duration);
}
else {
- event_time = temp_downtime->end_time;
+ event_time = temp_downtime->end_time;
}
if((new_downtime_id = (unsigned long *)malloc(sizeof(unsigned long *)))) {
*new_downtime_id = temp_downtime->downtime_id;
@@ -752,7 +752,7 @@
/* 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 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)
@@ -765,7 +765,7 @@
/* 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 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;
@@ -791,7 +791,7 @@
/* 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 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;
@@ -965,48 +965,48 @@
/******************************************************************/
/* 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;
+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;
+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;
+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;
+ 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;
+ 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 */
@@ -1015,22 +1015,22 @@
/* 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;
+ 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;
+ 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;
+ log_debug_info(DEBUGL_DOWNTIME, 1,
+ "Unable to allocate memory for new downtime's author\n");
+ result = ERROR;
}
}
if(comment_data) {
@@ -1057,8 +1057,8 @@
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;
+ 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;
@@ -1117,7 +1117,7 @@
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)
@@ -1160,12 +1160,12 @@
/* 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)
Modified: nagioscore/branches/nagios-3-4-x/common/macros.c
===================================================================
--- nagioscore/branches/nagios-3-4-x/common/macros.c 2013-03-09 21:12:46 UTC (rev 2652)
+++ nagioscore/branches/nagios-3-4-x/common/macros.c 2013-03-09 21:46:35 UTC (rev 2653)
@@ -58,7 +58,7 @@
int code; /* numeric macro code, usable in case statements */
int clean_options;
char *value;
-};
+ };
struct macro_key_code macro_keys[MACRO_X_COUNT];
@@ -99,14 +99,14 @@
struct macro_key_code *key;
high = MACRO_X_COUNT;
- while (high - low > 0) {
+ while(high - low > 0) {
unsigned int mid = low + ((high - low) / 2);
key = ¯o_keys[mid];
value = strcmp(name, key->name);
- if (value == 0) {
+ if(value == 0) {
return key;
}
- if (value > 0)
+ if(value > 0)
low = mid + 1;
else
high = mid;
@@ -517,9 +517,9 @@
}
}
- if ((mkey = find_macro_key(macro_name))) {
+ 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) {
+ if(mkey->clean_options) {
*clean_options |= mkey->clean_options;
log_debug_info(DEBUGL_MACROS, 2, " New clean options: %d\n", *clean_options);
}
@@ -2545,13 +2545,12 @@
}
-static int macro_key_cmp(const void *a_, const void *b_)
-{
+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);
-}
+ }
/******************************************************************/
@@ -2583,7 +2582,7 @@
* 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++) {
+ for(x = 0; x < MACRO_X_COUNT; x++) {
macro_keys[x].code = x;
macro_keys[x].name = macro_x_names[x];
Modified: nagioscore/branches/nagios-3-4-x/xdata/xdddefault.c
===================================================================
--- nagioscore/branches/nagios-3-4-x/xdata/xdddefault.c 2013-03-09 21:12:46 UTC (rev 2652)
+++ nagioscore/branches/nagios-3-4-x/xdata/xdddefault.c 2013-03-09 21:46:35 UTC (rev 2653)
@@ -101,48 +101,48 @@
/* delete downtimes with invalid host names */
if(find_host(temp_downtime->host_name) == NULL) {
- log_debug_info(DEBUGL_DOWNTIME, 1,
- "Deleting downtime with invalid host name: %s\n",
- temp_downtime->host_name);
+ log_debug_info(DEBUGL_DOWNTIME, 1,
+ "Deleting downtime with invalid host name: %s\n",
+ temp_downtime->host_name);
save = FALSE;
}
/* delete downtimes with invalid service descriptions */
if(temp_downtime->type == SERVICE_DOWNTIME && find_service(temp_downtime->host_name, temp_downtime->service_description) == NULL) {
- log_debug_info(DEBUGL_DOWNTIME, 1,
- "Deleting downtime with invalid service description: %s\n",
- temp_downtime->service_description);
+ log_debug_info(DEBUGL_DOWNTIME, 1,
+ "Deleting downtime with invalid service description: %s\n",
+ temp_downtime->service_description);
save = FALSE;
}
/* delete fixed downtimes that have expired */
- if((TRUE == temp_downtime->fixed) &&
- (temp_downtime->end_time < time(NULL))) {
- log_debug_info(DEBUGL_DOWNTIME, 1,
- "Deleting fixed downtime that expired at: %lu\n",
- temp_downtime->end_time);
+ if((TRUE == temp_downtime->fixed) &&
+ (temp_downtime->end_time < time(NULL))) {
+ log_debug_info(DEBUGL_DOWNTIME, 1,
+ "Deleting fixed downtime that expired at: %lu\n",
+ temp_downtime->end_time);
save = FALSE;
}
/* delete flexible downtimes that never started and have expired */
- if((FALSE == temp_downtime->fixed) &&
- (0 == temp_downtime->flex_downtime_start) &&
- (temp_downtime->end_time < time(NULL))) {
- log_debug_info(DEBUGL_DOWNTIME, 1,
- "Deleting flexible downtime that expired at: %lu\n",
- temp_downtime->end_time);
+ if((FALSE == temp_downtime->fixed) &&
+ (0 == temp_downtime->flex_downtime_start) &&
+ (temp_downtime->end_time < time(NULL))) {
+ log_debug_info(DEBUGL_DOWNTIME, 1,
+ "Deleting flexible downtime that expired at: %lu\n",
+ temp_downtime->end_time);
save = FALSE;
}
/* delete flexible downtimes that started but whose duration
has completed */
- if((FALSE == temp_downtime->fixed) &&
- (0 != temp_downtime->flex_downtime_start) &&
- ((temp_downtime->flex_downtime_start + temp_downtime->duration)
- < time(NULL))) {
- log_debug_info(DEBUGL_DOWNTIME, 1,
- "Deleting flexible downtime whose duration ended at: %lu\n",
- temp_downtime->flex_downtime_start + temp_downtime->duration);
+ if((FALSE == temp_downtime->fixed) &&
+ (0 != temp_downtime->flex_downtime_start) &&
+ ((temp_downtime->flex_downtime_start + temp_downtime->duration)
+ < time(NULL))) {
+ log_debug_info(DEBUGL_DOWNTIME, 1,
+ "Deleting flexible downtime whose duration ended at: %lu\n",
+ temp_downtime->flex_downtime_start + temp_downtime->duration);
save = FALSE;
}
@@ -195,7 +195,7 @@
/******************************************************************/
/* adds a new scheduled host downtime entry */
-int xdddefault_add_new_host_downtime(char *host_name, time_t entry_time, char *author, char *comment, 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){
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|