1 /*****************************************************************************
2  *
3  * OBJECTS.H - Header file for object addition/search functions
4  *
5  * Copyright (c) 1999-2006 Ethan Galstad (nagios@nagios.org)
6  * Last Modified: 03-21-2006
7  *
8  * License:
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  *
23  *****************************************************************************/
24 
25 
26 #ifndef _OBJECTS_H
27 #define _OBJECTS_H
28 
29 #include "config.h"
30 #include "common.h"
31 
32 #ifdef __cplusplus
33   extern "C" {
34 #endif
35 
36 
37 
38 /*************** CURRENT OBJECT REVISION **************/
39 
40 #define CURRENT_OBJECT_STRUCTURE_VERSION        2
41 
42 
43 
44 /***************** OBJECT SIZE LIMITS *****************/
45 
46 #define MAX_HOSTNAME_LENGTH            		64	/* max. host name length */
47 #define MAX_SERVICEDESC_LENGTH			64	/* max. service description length */
48 #define MAX_PLUGINOUTPUT_LENGTH			332	/* max. length of plugin output */
49 
50 #define MAX_STATE_HISTORY_ENTRIES		21	/* max number of old states to keep track of for flap detection */
51 
52 #define MAX_CONTACT_ADDRESSES                   6       /* max number of custom addresses a contact can have */
53 
54 
55 
56 /***************** CHAINED HASH LIMITS ****************/
57 
58 #define SERVICE_HASHSLOTS                      1024
59 #define HOST_HASHSLOTS                         1024
60 #define COMMAND_HASHSLOTS                      256
61 #define TIMEPERIOD_HASHSLOTS                   64
62 #define CONTACT_HASHSLOTS                      128
63 #define CONTACTGROUP_HASHSLOTS                 64
64 #define HOSTGROUP_HASHSLOTS                    128
65 #define SERVICEGROUP_HASHSLOTS                 128
66 #define HOSTEXTINFO_HASHSLOTS                  1024
67 #define SERVICEEXTINFO_HASHSLOTS               1024
68 
69 #define HOSTDEPENDENCY_HASHSLOTS               1024
70 #define SERVICEDEPENDENCY_HASHSLOTS            1024
71 #define HOSTESCALATION_HASHSLOTS               1024
72 #define SERVICEESCALATION_HASHSLOTS            1024
73 
74 
75 
76 /****************** DATA STRUCTURES *******************/
77 
78 /* TIMERANGE structure */
79 typedef struct timerange_struct{
80 	unsigned long range_start;
81 	unsigned long range_end;
82 	struct timerange_struct *next;
83         }timerange;
84 
85 
86 /* TIMEPERIOD structure */
87 typedef struct timeperiod_struct{
88 	char    *name;
89 	char    *alias;
90 	timerange *days[7];
91 	struct 	timeperiod_struct *next;
92 	struct 	timeperiod_struct *nexthash;
93 	}timeperiod;
94 
95 
96 /* CONTACTGROUPMEMBER structure */
97 typedef struct contactgroupmember_struct{
98 	char    *contact_name;
99 	struct  contactgroupmember_struct *next;
100         }contactgroupmember;
101 
102 
103 /* CONTACTGROUP structure */
104 typedef struct contactgroup_struct{
105 	char	*group_name;
106 	char    *alias;
107 	contactgroupmember *members;
108 	struct	contactgroup_struct *next;
109 	struct	contactgroup_struct *nexthash;
110 	}contactgroup;
111 
112 
113 /* CONTACTGROUPSMEMBER structure */
114 typedef struct contactgroupsmember_struct{
115 	char *group_name;
116 	struct contactgroupsmember_struct *next;
117         }contactgroupsmember;
118 
119 
120 /* HOSTSMEMBER structure */
121 typedef struct hostsmember_struct{
122 	char *host_name;
123 	struct hostsmember_struct *next;
124         }hostsmember;
125 
126 
127 /* HOST structure */
128 typedef struct host_struct{
129 	char    *name;
130 	char	*alias;
131 	char    *address;
132         hostsmember *parent_hosts;
133 	char    *host_check_command;
134 	int     check_interval;
135 	int     max_attempts;
136 	char    *event_handler;
137 	contactgroupsmember *contact_groups;
138 	int     notification_interval;
139 	int	notify_on_down;
140 	int	notify_on_unreachable;
141 	int     notify_on_recovery;
142 	int     notify_on_flapping;
143 	char	*notification_period;
144 	char    *check_period;
145 	int     flap_detection_enabled;
146 	double  low_flap_threshold;
147 	double  high_flap_threshold;
148 	int     stalk_on_up;
149 	int     stalk_on_down;
150 	int     stalk_on_unreachable;
151 	int     check_freshness;
152 	int     freshness_threshold;
153 	int     process_performance_data;
154 	int     checks_enabled;
155 	int     accept_passive_host_checks;
156 	int     event_handler_enabled;
157 	int     retain_status_information;
158 	int     retain_nonstatus_information;
159 	int     failure_prediction_enabled;
160 	char    *failure_prediction_options;
161 	int     obsess_over_host;
162 #ifdef NSCORE
163 	int     problem_has_been_acknowledged;
164 	int     acknowledgement_type;
165 	int     check_type;
166 	int     current_state;
167 	int     last_state;
168 	int     last_hard_state;
169 	char	*plugin_output;
170 	char    *perf_data;
171         int     state_type;
172 	int     current_attempt;
173 	double  latency;
174 	double  execution_time;
175 	int     check_options;
176 	int     notifications_enabled;
177 	time_t  last_host_notification;
178 	time_t  next_host_notification;
179 	time_t  next_check;
180 	int     should_be_scheduled;
181 	time_t  last_check;
182 	time_t	last_state_change;
183 	time_t	last_hard_state_change;
184 	time_t  last_time_up;
185 	time_t  last_time_down;
186 	time_t  last_time_unreachable;
187 	int     has_been_checked;
188 	int     is_being_freshened;
189 	int     notified_on_down;
190 	int     notified_on_unreachable;
191 	int     current_notification_number;
192 	int     no_more_notifications;
193 	int     check_flapping_recovery_notification;
194 	int     scheduled_downtime_depth;
195 	int     pending_flex_downtime;
196 	int     state_history[MAX_STATE_HISTORY_ENTRIES];    /* flap detection */
197 	int     state_history_index;
198 	time_t  last_state_history_update;
199 	int     is_flapping;
200 	unsigned long flapping_comment_id;
201 	double  percent_state_change;
202 	int     total_services;
203 	unsigned long total_service_check_interval;
204 	unsigned long modified_attributes;
205 	int     circular_path_checked;
206 	int     contains_circular_path;
207 #endif
208 	struct  host_struct *next;
209 	struct  host_struct *nexthash;
210         }host;
211 
212 
213 /* HOSTGROUPMEMBER structure */
214 typedef struct hostgroupmember_struct{
215 	char    *host_name;
216 	struct  hostgroupmember_struct *next;
217         }hostgroupmember;
218 
219 
220 /* HOSTGROUP structure */
221 typedef struct hostgroup_struct{
222 	char 	*group_name;
223 	char    *alias;
224 	hostgroupmember *members;
225 	struct	hostgroup_struct *next;
226 	struct	hostgroup_struct *nexthash;
227 	}hostgroup;
228 
229 
230 /* SERVICEGROUPMEMBER structure */
231 typedef struct servicegroupmember_struct{
232 	char    *host_name;
233 	char    *service_description;
234 	struct  servicegroupmember_struct *next;
235         }servicegroupmember;
236 
237 
238 /* SERVICEGROUP structure */
239 typedef struct servicegroup_struct{
240 	char 	*group_name;
241 	char    *alias;
242 	servicegroupmember *members;
243 	struct	servicegroup_struct *next;
244 	struct	servicegroup_struct *nexthash;
245 	}servicegroup;
246 
247 
248 /* COMMANDSMEMBER structure */
249 typedef struct commandsmember_struct{
250 	char	*command;
251 	struct	commandsmember_struct *next;
252 	}commandsmember;
253 
254 
255 /* CONTACT structure */
256 typedef struct contact_struct{
257 	char	*name;
258 	char	*alias;
259 	char	*email;
260 	char	*pager;
261 	char    *address[MAX_CONTACT_ADDRESSES];
262 	commandsmember *host_notification_commands;
263 	commandsmember *service_notification_commands;
264 	int     notify_on_service_unknown;
265 	int     notify_on_service_warning;
266 	int     notify_on_service_critical;
267 	int     notify_on_service_recovery;
268 	int     notify_on_service_flapping;
269 	int 	notify_on_host_down;
270 	int	notify_on_host_unreachable;
271 	int	notify_on_host_recovery;
272 	int     notify_on_host_flapping;
273 	char	*host_notification_period;
274 	char	*service_notification_period;
275 	struct	contact_struct *next;
276 	struct	contact_struct *nexthash;
277 	}contact;
278 
279 
280 
281 /* SERVICE structure */
282 typedef struct service_struct{
283 	char	*host_name;
284 	char	*description;
285         char    *service_check_command;
286 	char    *event_handler;
287 	int	check_interval;
288 	int     retry_interval;
289 	int	max_attempts;
290 	int     parallelize;
291 	contactgroupsmember *contact_groups;
292 	int	notification_interval;
293 	int     notify_on_unknown;
294 	int	notify_on_warning;
295 	int	notify_on_critical;
296 	int	notify_on_recovery;
297 	int     notify_on_flapping;
298 	int     stalk_on_ok;
299 	int     stalk_on_warning;
300 	int     stalk_on_unknown;
301 	int     stalk_on_critical;
302 	int     is_volatile;
303 	char	*notification_period;
304 	char	*check_period;
305 	int     flap_detection_enabled;
306 	double  low_flap_threshold;
307 	double  high_flap_threshold;
308 	int     process_performance_data;
309 	int     check_freshness;
310 	int     freshness_threshold;
311 	int     accept_passive_service_checks;
312 	int     event_handler_enabled;
313 	int	checks_enabled;
314 	int     retain_status_information;
315 	int     retain_nonstatus_information;
316 	int     notifications_enabled;
317 	int     obsess_over_service;
318 	int     failure_prediction_enabled;
319 	char    *failure_prediction_options;
320 #ifdef NSCORE
321 	int     problem_has_been_acknowledged;
322 	int     acknowledgement_type;
323 	int     host_problem_at_last_check;
324 #ifdef REMOVED_041403
325 	int     no_recovery_notification;
326 #endif
327 	int     check_type;
328 	int	current_state;
329 	int	last_state;
330 	int	last_hard_state;
331 	char	*plugin_output;
332 	char    *perf_data;
333         int     state_type;
334 	time_t	next_check;
335 	int     should_be_scheduled;
336 	time_t	last_check;
337 	int	current_attempt;
338 	time_t	last_notification;
339 	time_t  next_notification;
340 	int     no_more_notifications;
341 	int     check_flapping_recovery_notification;
342 	time_t	last_state_change;
343 	time_t	last_hard_state_change;
344 	time_t  last_time_ok;
345 	time_t  last_time_warning;
346 	time_t  last_time_unknown;
347 	time_t  last_time_critical;
348 	int     has_been_checked;
349 	int     is_being_freshened;
350 	int     notified_on_unknown;
351 	int     notified_on_warning;
352 	int     notified_on_critical;
353 	int     current_notification_number;
354 	double  latency;
355 	double  execution_time;
356 	int     is_executing;
357 	int     check_options;
358 	int     scheduled_downtime_depth;
359 	int     pending_flex_downtime;
360 	int     state_history[MAX_STATE_HISTORY_ENTRIES];    /* flap detection */
361 	int     state_history_index;
362 	int     is_flapping;
363 	unsigned long flapping_comment_id;
364 	double  percent_state_change;
365 	unsigned long modified_attributes;
366 #endif
367 	struct service_struct *next;
368 	struct service_struct *nexthash;
369 	}service;
370 
371 
372 /* COMMAND structure */
373 typedef struct command_struct{
374 	char    *name;
375 	char    *command_line;
376 	struct command_struct *next;
377 	struct command_struct *nexthash;
378         }command;
379 
380 
381 /* SERVICE ESCALATION structure */
382 typedef struct serviceescalation_struct{
383 	char    *host_name;
384 	char    *description;
385 	int     first_notification;
386 	int     last_notification;
387 	int     notification_interval;
388 	char    *escalation_period;
389 	int     escalate_on_recovery;
390 	int     escalate_on_warning;
391 	int     escalate_on_unknown;
392 	int     escalate_on_critical;
393 	contactgroupsmember *contact_groups;
394 	struct  serviceescalation_struct *next;
395 	struct  serviceescalation_struct *nexthash;
396         }serviceescalation;
397 
398 
399 /* SERVICE DEPENDENCY structure */
400 typedef struct servicedependency_struct{
401 	int     dependency_type;
402 	char    *dependent_host_name;
403 	char    *dependent_service_description;
404 	char    *host_name;
405 	char    *service_description;
406 	int     inherits_parent;
407 	int     fail_on_ok;
408 	int     fail_on_warning;
409 	int     fail_on_unknown;
410 	int     fail_on_critical;
411 	int     fail_on_pending;
412 #ifdef NSCORE
413 	int     circular_path_checked;
414 	int     contains_circular_path;
415 #endif
416 	struct servicedependency_struct *next;
417 	struct servicedependency_struct *nexthash;
418         }servicedependency;
419 
420 
421 /* HOST ESCALATION structure */
422 typedef struct hostescalation_struct{
423 	char    *host_name;
424 	int     first_notification;
425 	int     last_notification;
426 	int     notification_interval;
427 	char    *escalation_period;
428 	int     escalate_on_recovery;
429 	int     escalate_on_down;
430 	int     escalate_on_unreachable;
431 	contactgroupsmember *contact_groups;
432 	struct  hostescalation_struct *next;
433 	struct  hostescalation_struct *nexthash;
434         }hostescalation;
435 
436 
437 /* HOST DEPENDENCY structure */
438 typedef struct hostdependency_struct{
439 	int     dependency_type;
440 	char    *dependent_host_name;
441 	char    *host_name;
442 	int     inherits_parent;
443 	int     fail_on_up;
444 	int     fail_on_down;
445 	int     fail_on_unreachable;
446 	int     fail_on_pending;
447 #ifdef NSCORE
448 	int     circular_path_checked;
449 	int     contains_circular_path;
450 #endif
451 	struct hostdependency_struct *next;
452 	struct hostdependency_struct *nexthash;
453         }hostdependency;
454 
455 
456 /* EXTENDED HOST INFO structure */
457 typedef struct hostextinfo_struct{
458 	char *host_name;
459 	char *notes;
460 	char *notes_url;
461 	char *action_url;
462 	char *icon_image;
463 	char *vrml_image;
464 	char *statusmap_image;
465 	char *icon_image_alt;
466 	int have_2d_coords;
467 	int x_2d;
468 	int y_2d;
469 	int have_3d_coords;
470 	double x_3d;
471 	double y_3d;
472 	double z_3d;
473 	int should_be_drawn;
474 	struct hostextinfo_struct *next;
475 	struct hostextinfo_struct *nexthash;
476         }hostextinfo;
477 
478 
479 /* EXTENDED SERVICE INFO structure */
480 typedef struct serviceextinfo_struct{
481 	char *host_name;
482 	char *description;
483 	char *notes;
484 	char *notes_url;
485 	char *action_url;
486 	char *icon_image;
487 	char *icon_image_alt;
488 	struct serviceextinfo_struct *next;
489 	struct serviceextinfo_struct *nexthash;
490         }serviceextinfo;
491 
492 
493 
494 /****************** HASH STRUCTURES ********************/
495 
496 typedef struct host_cursor_struct{
497 	int     host_hashchain_iterator;
498 	host    *current_host_pointer;
499         }host_cursor;
500 
501 
502 
503 
504 
505 /********************* FUNCTIONS **********************/
506 
507 /**** DEBUG functions ****/
508 /* RMO: 9/25/01
509    Send debug output to stdout. Does nothing if 'level' is
510    not enabled by a corresponding 'DEBUGn' define.
511    Accepts format string (fmt) and variable-length arg list
512    (as printf does). Prints to stdout and, if NSCGI environment,
513    surrounded with HTML comment delimiters to be viewed through
514    browser's 'view source' option.
515 
516    Use as: dbg_print((level,fmt,...)); [NOTE double parens]
517 
518    The macro def below causes dbg_print(()) calls to vaporize
519    if none of the DEBUGn levels are defined.
520 */
521 #if defined(DEBUG0) || defined(DEBUG1) || defined(DEBUG2) || defined(DEBUG3) || defined(DEBUG4) || defined(DEBUG5) || defined(DEBUG6) || defined(DEBUG7) || defined(DEBUG8) || defined(DEBUG9) || defined(DEBUG10) || defined(DEBUG11)
522 #define dbg_print(args) dbg_print_x args
523 #else
524 #define dbg_print(args)
525 #endif
526 
527 
528 /**** Top-level input functions ****/
529 int read_object_config_data(char *,int,int);        /* reads all external configuration data of specific types */
530 
531 /**** Object Creation Functions ****/
532 contact *add_contact(char *,char *,char *,char *,char **,char *,char *,int,int,int,int,int,int,int,int,int);	/* adds a contact definition */
533 commandsmember *add_service_notification_command_to_contact(contact *,char *);				/* adds a service notification command to a contact definition */
534 commandsmember *add_host_notification_command_to_contact(contact *,char *);				/* adds a host notification command to a contact definition */
535 host *add_host(char *,char *,char *,char *,int,int,int,int,int,int,int,char *,int,char *,int,int,char *,int,int,double,double,int,int,int,int,int,char *,int,int,int,int,int);	/* adds a host definition */
536 hostsmember *add_parent_host_to_host(host *,char *);							/* adds a parent host to a host definition */
537 contactgroupsmember *add_contactgroup_to_host(host *,char *);					        /* adds a contactgroup to a host definition */
538 timeperiod *add_timeperiod(char *,char *);								/* adds a timeperiod definition */
539 timerange *add_timerange_to_timeperiod(timeperiod *,int,unsigned long,unsigned long);			/* adds a timerange to a timeperiod definition */
540 hostgroup *add_hostgroup(char *,char *);								/* adds a hostgroup definition */
541 hostgroupmember *add_host_to_hostgroup(hostgroup *, char *);						/* adds a host to a hostgroup definition */
542 servicegroup *add_servicegroup(char *,char *);                                                          /* adds a servicegroup definition */
543 servicegroupmember *add_service_to_servicegroup(servicegroup *,char *,char *);                          /* adds a service to a servicegroup definition */
544 contactgroup *add_contactgroup(char *,char *);								/* adds a contactgroup definition */
545 contactgroupmember *add_contact_to_contactgroup(contactgroup *,char *);					/* adds a contact to a contact group definition */
546 command *add_command(char *,char *);									/* adds a command definition */
547 service *add_service(char *,char *,char *,int,int,int,int,int,int,char *,int,int,int,int,int,int,int,char *,int,char *,int,int,double,double,int,int,int,int,int,int,char *,int,int,int,int,int);	/* adds a service definition */
548 contactgroupsmember *add_contactgroup_to_service(service *,char *);					/* adds a contact group to a service definition */
549 serviceescalation *add_serviceescalation(char *,char *,int,int,int,char *,int,int,int,int);             /* adds a service escalation definition */
550 contactgroupsmember *add_contactgroup_to_serviceescalation(serviceescalation *,char *);                 /* adds a contact group to a service escalation definition */
551 servicedependency *add_service_dependency(char *,char *,char *,char *,int,int,int,int,int,int,int);     /* adds a service dependency definition */
552 hostdependency *add_host_dependency(char *,char *,int,int,int,int,int,int);                             /* adds a host dependency definition */
553 hostescalation *add_hostescalation(char *,int,int,int,char *,int,int,int);                              /* adds a host escalation definition */
554 contactgroupsmember *add_contactgroup_to_hostescalation(hostescalation *,char *);                       /* adds a contact group to a host escalation definition */
555 hostextinfo *add_hostextinfo(char *,char *,char *,char *,char *,char *,char *,char *,int,int,double,double,double,int,int); /* adds an extended host info definition */
556 serviceextinfo *add_serviceextinfo(char *,char *,char *,char *,char *,char *,char *);                          /* add an extended service info definition */
557 
558 
559 /**** Object Hash Functions ****/
560 int add_host_to_hashlist(host *);
561 int add_service_to_hashlist(service *);
562 int add_command_to_hashlist(command *);
563 int add_timeperiod_to_hashlist(timeperiod *);
564 int add_contact_to_hashlist(contact *);
565 int add_contactgroup_to_hashlist(contactgroup *);
566 int add_hostgroup_to_hashlist(hostgroup *);
567 int add_servicegroup_to_hashlist(servicegroup *);
568 int add_hostdependency_to_hashlist(hostdependency *);
569 int add_servicedependency_to_hashlist(servicedependency *);
570 int add_hostescalation_to_hashlist(hostescalation *);
571 int add_serviceescalation_to_hashlist(serviceescalation *);
572 int add_hostextinfo_to_hashlist(hostextinfo *);
573 int add_serviceextinfo_to_hashlist(serviceextinfo *);
574 
575 
576 /**** Object Search Functions ****/
577 timeperiod * find_timeperiod(char *);						                /* finds a timeperiod object */
578 host * find_host(char *);									/* finds a host object */
579 hostgroup * find_hostgroup(char *);						                /* finds a hostgroup object */
580 servicegroup * find_servicegroup(char *);					                /* finds a servicegroup object */
581 contact * find_contact(char *);							                /* finds a contact object */
582 contactgroup * find_contactgroup(char *);					                /* finds a contactgroup object */
583 contactgroupmember *find_contactgroupmember(char *,contactgroup *);	                        /* finds a contactgroup member object */
584 command * find_command(char *);							                /* finds a command object */
585 service * find_service(char *,char *);								/* finds a service object */
586 hostextinfo *find_hostextinfo(char *);				                                /* find an extended host info object */
587 serviceextinfo *find_serviceextinfo(char *,char *);                                             /* find an extended service info object */
588 
589 
590 /**** Object Traversal Functions ****/
591 void move_first_service(void);									/* sets up the static memory area for get_next_service */
592 service *get_next_service(void);								/* returns the next service, NULL at the end of the list */
593 int find_all_services_by_host(char *);							        /* sets up the static memory area for get_next_service_by_host */
594 service *get_next_service_by_host(void);							/* returns the next service for the host, NULL at the end of the list */
595 void move_first_host(void);									/* sets up the static memory area for get_next_host */
596 host *get_next_host(void);									/* returns the next host, NULL at the end of the list */
597 void *get_host_cursor(void);					                                /* allocate memory for the host cursor */
598 host *get_next_host_cursor(void *v_cursor);							/* return the next host, NULL at the end of the list */
599 void free_host_cursor(void *cursor);								/* free allocated cursor memory */
600 void *get_next_N(void **hashchain, int hashslots, int *iterator, void *current, void *next);
601 
602 hostescalation *get_first_hostescalation_by_host(char *);
603 hostescalation *get_next_hostescalation_by_host(char *,hostescalation *);
604 serviceescalation *get_first_serviceescalation_by_service(char *,char *);
605 serviceescalation *get_next_serviceescalation_by_service(char *,char *,serviceescalation *);
606 hostdependency *get_first_hostdependency_by_dependent_host(char *);
607 hostdependency *get_next_hostdependency_by_dependent_host(char *,hostdependency *);
608 servicedependency *get_first_servicedependency_by_dependent_service(char *,char *);
609 servicedependency *get_next_servicedependency_by_dependent_service(char *,char *,servicedependency *);
610 
611 
612 
613 /**** Object Query Functions ****/
614 int is_host_immediate_child_of_host(host *,host *);	                /* checks if a host is an immediate child of another host */
615 int is_host_primary_immediate_child_of_host(host *,host *);             /* checks if a host is an immediate child (and primary child) of another host */
616 int is_host_immediate_parent_of_host(host *,host *);	                /* checks if a host is an immediate child of another host */
617 int is_host_member_of_hostgroup(hostgroup *,host *);		        /* tests whether or not a host is a member of a specific hostgroup */
618 int is_host_member_of_servicegroup(servicegroup *,host *);	        /* tests whether or not a service is a member of a specific servicegroup */
619 int is_service_member_of_servicegroup(servicegroup *,service *);	/* tests whether or not a service is a member of a specific servicegroup */
620 int is_contact_member_of_contactgroup(contactgroup *, contact *);	/* tests whether or not a contact is a member of a specific contact group */
621 int is_contact_for_hostgroup(hostgroup *,contact *);	                /* tests whether or not a contact is a member of a specific hostgroup */
622 int is_contact_for_servicegroup(servicegroup *,contact *);	        /* tests whether or not a contact is a member of a specific servicegroup */
623 int is_contact_for_host(host *,contact *);			        /* tests whether or not a contact is a contact member for a specific host */
624 int is_escalated_contact_for_host(host *,contact *);                    /* checks whether or not a contact is an escalated contact for a specific host */
625 int is_contact_for_service(service *,contact *);		        /* tests whether or not a contact is a contact member for a specific service */
626 int is_escalated_contact_for_service(service *,contact *);              /* checks whether or not a contact is an escalated contact for a specific service */
627 int is_host_immediate_parent_of_host(host *,host *);		        /* tests whether or not a host is an immediate parent of another host */
628 
629 int number_of_immediate_child_hosts(host *);		                /* counts the number of immediate child hosts for a particular host */
630 int number_of_total_child_hosts(host *);				/* counts the number of total child hosts for a particular host */
631 int number_of_immediate_parent_hosts(host *);				/* counts the number of immediate parents hosts for a particular host */
632 int number_of_total_parent_hosts(host *);				/* counts the number of total parents hosts for a particular host */
633 
634 #ifdef NSCORE
635 int check_for_circular_path(host *,host *);                             /* checks if a circular path exists for a given host */
636 int check_for_circular_servicedependency(servicedependency *,servicedependency *,int);   /* checks if a circular dependency exists for a given service */
637 int check_for_circular_hostdependency(hostdependency *,hostdependency *,int);   /* checks if a circular dependency exists for a given host */
638 #endif
639 
640 
641 /**** Object Cleanup Functions ****/
642 int free_object_data(void);                             /* frees all allocated memory for the object definitions */
643 int free_extended_data(void);                           /* frees memory allocated to the extended host/service information */
644 
645 #ifdef __cplusplus
646   }
647 #endif
648 
649 #endif
650