}
else
new_svcstatus->plugin_output=strdup("Service is not scheduled to be checked...");
}
}
new_svcstatus->next=NULL;
new_svcstatus->nexthash=NULL;
/* add new servicestatus to servicestatus chained hash list */
if(!add_servicestatus_to_hashlist(new_svcstatus))
return ERROR;
/* object cache file is already sorted, so just add new items to end of list */
if(servicestatus_list==NULL){
servicestatus_list=new_svcstatus;
servicestatus_list_tail=new_svcstatus;
}
else{
servicestatus_list_tail->next=new_svcstatus;
servicestatus_list_tail=new_svcstatus;
}
return OK;
}
/******************************************************************/
/*********************** CLEANUP FUNCTIONS ************************/
/******************************************************************/
/* free all memory for status data */
void free_status_data(void){
hoststatus *this_hoststatus;
hoststatus *next_hoststatus;
servicestatus *this_svcstatus;
servicestatus *next_svcstatus;
/* free memory for the host status list */
for(this_hoststatus=hoststatus_list;this_hoststatus!=NULL;this_hoststatus=next_hoststatus){
next_hoststatus=this_hoststatus->next;
free(this_hoststatus->host_name);
free(this_hoststatus->plugin_output);
free(this_hoststatus->perf_data);
free(this_hoststatus);
}
/* free memory for the service status list */
for(this_svcstatus=servicestatus_list;this_svcstatus!=NULL;this_svcstatus=next_svcstatus){
next_svcstatus=this_svcstatus->next;
free(this_svcstatus->host_name);
free(this_svcstatus->description);
free(this_svcstatus->plugin_output);
free(this_svcstatus->perf_data);
free(this_svcstatus);
}
/* free hash lists reset list pointers */
free(hoststatus_hashlist);
free(servicestatus_hashlist);
hoststatus_hashlist=NULL;
servicestatus_hashlist=NULL;
hoststatus_list=NULL;
servicestatus_list=NULL;
return;
}
/******************************************************************/
/************************ SEARCH FUNCTIONS ************************/
/******************************************************************/
/* find a host status entry */
hoststatus *find_hoststatus(char *host_name){
hoststatus *temp_hoststatus;
if(host_name==NULL || hoststatus_hashlist==NULL)
return NULL;
for(temp_hoststatus=hoststatus_hashlist[hashfunc1(host_name,HOSTSTATUS_HASHSLOTS)];temp_hoststatus &&
compare_hashdata1(temp_hoststatus->host_name,host_name)<0;temp_hoststatus=temp_hoststatus->nexthash);
if(temp_hoststatus && (compare_hashdata1(temp_hoststatus->host_name,host_name)==0))
return temp_hoststatus;
return NULL;
}
/* find a service status entry */
servicestatus *find_servicestatus(char *host_name,char *svc_desc){
servicestatus *temp_servicestatus;
=5= |