|
From: Ethan G. <ega...@us...> - 2007-08-14 22:07:33
|
Update of /cvsroot/nagios/nagios/common In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22620/common Modified Files: objects.c Log Message: New macros, data structure mods Index: objects.c =================================================================== RCS file: /cvsroot/nagios/nagios/common/objects.c,v retrieving revision 1.101 retrieving revision 1.102 diff -C2 -d -r1.101 -r1.102 *** objects.c 31 Jul 2007 12:58:48 -0000 1.101 --- objects.c 14 Aug 2007 22:07:34 -0000 1.102 *************** *** 4,8 **** * * Copyright (c) 1999-2007 Ethan Galstad (na...@na...) ! * Last Modified: 07-30-2007 * * License: --- 4,8 ---- * * Copyright (c) 1999-2007 Ethan Galstad (na...@na...) ! * Last Modified: 08-14-2007 * * License: *************** *** 968,971 **** --- 968,973 ---- new_host->display_name=NULL; new_host->parent_hosts=NULL; + new_host->child_hosts=NULL; + new_host->services=NULL; new_host->contact_groups=NULL; new_host->contacts=NULL; *************** *** 1250,1253 **** --- 1252,1310 ---- + hostsmember *add_child_link_to_host(host *hst, host *child_ptr){ + hostsmember *new_hostsmember=NULL; + int result=OK; + + /* make sure we have the data we need */ + if(hst==NULL || child_ptr==NULL) + return NULL; + + /* allocate memory */ + if((new_hostsmember=(hostsmember *)malloc(sizeof(hostsmember)))==NULL) + return NULL; + + /* initialize values */ + new_hostsmember->host_name=NULL; + #ifdef NSCORE + new_hostsmember->host_ptr=child_ptr; + #endif + + /* add the child entry to the host definition */ + new_hostsmember->next=hst->child_hosts; + hst->child_hosts=new_hostsmember; + + return new_hostsmember; + } + + + + servicesmember *add_service_link_to_host(host *hst, service *service_ptr){ + servicesmember *new_servicesmember=NULL; + int result=OK; + + /* make sure we have the data we need */ + if(hst==NULL || service_ptr==NULL) + return NULL; + + /* allocate memory */ + if((new_servicesmember=(servicesmember *)malloc(sizeof(servicesmember)))==NULL) + return NULL; + + /* initialize values */ + new_servicesmember->host_name=NULL; + new_servicesmember->service_description=NULL; + #ifdef NSCORE + new_servicesmember->service_ptr=service_ptr; + #endif + + /* add the child entry to the host definition */ + new_servicesmember->next=hst->services; + hst->services=new_servicesmember; + + return new_servicesmember; + } + + + /* add a new contactgroup to a host */ contactgroupsmember *add_contactgroup_to_host(host *hst, char *group_name){ *************** *** 3376,3382 **** --- 3433,3441 ---- hostsmember *temp_hostsmember=NULL; + /* not enough data */ if(child_host==NULL) return FALSE; + /* root/top-level hosts */ if(parent_host==NULL){ if(child_host->parent_hosts==NULL) *************** *** 3384,3387 **** --- 3443,3447 ---- } + /* mid-level/bottom hosts */ else{ *************** *** 3412,3415 **** --- 3472,3476 ---- /* returns a count of the immediate children for a given host */ + /* NOTE: This function is only used by the CGIS */ int number_of_immediate_child_hosts(host *hst){ int children=0; *************** *** 3426,3429 **** --- 3487,3491 ---- /* returns a count of the total children for a given host */ + /* NOTE: This function is only used by the CGIS */ int number_of_total_child_hosts(host *hst){ int children=0; *************** *** 3440,3443 **** --- 3502,3506 ---- /* get the number of immediate parent hosts for a given host */ + /* NOTE: This function is only used by the CGIS */ int number_of_immediate_parent_hosts(host *hst){ int parents=0; *************** *** 3456,3459 **** --- 3519,3523 ---- /* get the total number of parent hosts for a given host */ + /* NOTE: This function is only used by the CGIS */ int number_of_total_parent_hosts(host *hst){ int parents=0; *************** *** 3472,3475 **** --- 3536,3540 ---- /* tests whether a host is a member of a particular hostgroup */ + /* NOTE: This function is only used by the CGIS */ int is_host_member_of_hostgroup(hostgroup *group, host *hst){ hostgroupmember *temp_hostgroupmember=NULL; *************** *** 3493,3496 **** --- 3558,3562 ---- /* tests whether a host is a member of a particular servicegroup */ + /* NOTE: This function is only used by the CGIS */ int is_host_member_of_servicegroup(servicegroup *group, host *hst){ servicegroupmember *temp_servicegroupmember=NULL; *************** *** 3514,3517 **** --- 3580,3584 ---- /* tests whether a service is a member of a particular servicegroup */ + /* NOTE: This function is only used by the CGIS */ int is_service_member_of_servicegroup(servicegroup *group, service *svc){ servicegroupmember *temp_servicegroupmember=NULL; *************** *** 3535,3538 **** --- 3602,3606 ---- /* tests whether a contact is a member of a particular contactgroup - used only by the CGIs */ + /* 08/14/07 EG NO LONGER USED */ int is_contact_member_of_contactgroup(contactgroup *group, contact *cntct){ contactgroupmember *temp_contactgroupmember=NULL; *************** *** 3894,3897 **** --- 3962,3967 ---- customvariablesmember *this_customvariablesmember=NULL; customvariablesmember *next_customvariablesmember=NULL; + servicesmember *this_servicesmember=NULL; + servicesmember *next_servicesmember=NULL; service *this_service=NULL; service *next_service=NULL; *************** *** 3973,3976 **** --- 4043,4065 ---- } + /* free memory for child host links */ + this_hostsmember=this_host->child_hosts; + while(this_hostsmember!=NULL){ + next_hostsmember=this_hostsmember->next; + my_free((void **)&this_hostsmember->host_name); + my_free((void **)&this_hostsmember); + this_hostsmember=next_hostsmember; + } + + /* free memory for service links */ + this_servicesmember=this_host->services; + while(this_servicesmember!=NULL){ + next_servicesmember=this_servicesmember->next; + my_free((void **)&this_servicesmember->host_name); + my_free((void **)&this_servicesmember->service_description); + my_free((void **)&this_servicesmember); + this_servicesmember=next_servicesmember; + } + /* free memory for contact groups */ this_contactgroupsmember=this_host->contact_groups; |