1 /*****************************************************************************
2  *
3  * OBJECTS.H - Header file for object addition/search functions
4  *
5  * Copyright (c) 1999-2007 Ethan Galstad (nagios@nagios.org)
6  * Last Modified: 11-10-2007
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        307     /* increment when changes are made to data structures... */
41 	                                                /* Nagios 3 starts at 300, Nagios 4 at 400, etc. */
42 
43 
44 
45 /***************** OBJECT SIZE LIMITS *****************/
46 
47 #define MAX_STATE_HISTORY_ENTRIES		21	/* max number of old states to keep track of for flap detection */
48 #define MAX_CONTACT_ADDRESSES                   6       /* max number of custom addresses a contact can have */
49 
50 
51 
52 /***************** SKIP LISTS ****************/
53 
54 #define NUM_OBJECT_SKIPLISTS                   13
55 
56 #define HOST_SKIPLIST                          1
57 #define SERVICE_SKIPLIST                       2
58 #define COMMAND_SKIPLIST                       3
59 #define TIMEPERIOD_SKIPLIST                    4
60 #define CONTACT_SKIPLIST                       5
61 #define CONTACTGROUP_SKIPLIST                  6
62 #define HOSTGROUP_SKIPLIST                     7
63 #define SERVICEGROUP_SKIPLIST                  8
64 #define HOSTDEPENDENCY_SKIPLIST                9
65 #define SERVICEDEPENDENCY_SKIPLIST             10
66 #define HOSTESCALATION_SKIPLIST                11
67 #define SERVICEESCALATION_SKIPLIST             12
68 
69 
70 /****************** DATA STRUCTURES *******************/
71 
72 typedef struct host_struct host;
73 typedef struct service_struct service;
74 typedef struct contact_struct contact;
75 
76 /* OBJECT LIST STRUCTURE */
77 typedef struct objectlist_struct{
78 	void      *object_ptr;
79 	struct objectlist_struct *next;
80         }objectlist;
81 
82 
83 /* TIMERANGE structure */
84 typedef struct timerange_struct{
85 	unsigned long range_start;
86 	unsigned long range_end;
87 	struct timerange_struct *next;
88         }timerange;
89 
90 
91 /* DATERANGE structure */
92 typedef struct daterange_struct{
93 	int type;
94 	int syear;          /* start year */
95 	int smon;           /* start month */
96 	int smday;          /* start day of month (may 3rd, last day in feb) */
97 	int swday;          /* start day of week (thursday) */
98 	int swday_offset;   /* start weekday offset (3rd thursday, last monday in jan) */
99 	int eyear;
100 	int emon;
101 	int emday;
102 	int ewday;
103 	int ewday_offset;
104 	int skip_interval;
105 	timerange *times;
106 	struct daterange_struct *next;
107 	}daterange;
108 
109 
110 /* TIMEPERIODEXCLUSION structure */
111 typedef struct timeperiodexclusion_struct{
112 	char  *timeperiod_name;
113 	struct timeperiod_struct *timeperiod_ptr;
114 	struct timeperiodexclusion_struct *next;
115         }timeperiodexclusion;
116 
117 
118 /* TIMEPERIOD structure */
119 typedef struct timeperiod_struct{
120 	char    *name;
121 	char    *alias;
122 	timerange *days[7];
123 	daterange *exceptions[DATERANGE_TYPES];
124 	timeperiodexclusion *exclusions;
125 	struct 	timeperiod_struct *next;
126 	struct 	timeperiod_struct *nexthash;
127 	}timeperiod;
128 
129 
130 /* CONTACTSMEMBER structure */
131 typedef struct contactsmember_struct{
132 	char    *contact_name;
133 #ifdef NSCORE
134 	contact *contact_ptr;
135 #endif
136 	struct  contactsmember_struct *next;
137         }contactsmember;
138 
139 
140 /* CONTACTGROUP structure */
141 typedef struct contactgroup_struct{
142 	char	*group_name;
143 	char    *alias;
144 	contactsmember *members;
145 	struct	contactgroup_struct *next;
146 	struct	contactgroup_struct *nexthash;
147 	}contactgroup;
148 
149 
150 /* CONTACTGROUPSMEMBER structure */
151 typedef struct contactgroupsmember_struct{
152 	char    *group_name;
153 #ifdef NSCORE
154 	contactgroup *group_ptr;
155 #endif
156 	struct contactgroupsmember_struct *next;
157         }contactgroupsmember;
158 
159 
160 /* CUSTOMVARIABLESMEMBER structure */
161 typedef struct customvariablesmember_struct{
162 	char    *variable_name;
163 	char    *variable_value;
164 	int     has_been_modified;
165 	struct customvariablesmember_struct *next;
166         }customvariablesmember;
167 
168 
169 /* COMMAND structure */
170 typedef struct command_struct{
171 	char    *name;
172 	char    *command_line;
173 	struct command_struct *next;
174 	struct command_struct *nexthash;
175         }command;
176 
177 
178 /* COMMANDSMEMBER structure */
179 typedef struct commandsmember_struct{
180 	char	*command;
181 #ifdef NSCORE
182 	command *command_ptr;
183 #endif
184 	struct	commandsmember_struct *next;
185 	}commandsmember;
186 
187 
188 /* CONTACT structure */
189 struct contact_struct{
190 	char	*name;
191 	char	*alias;
192 	char	*email;
193 	char	*pager;
194 	char    *address[MAX_CONTACT_ADDRESSES];
195 	commandsmember *host_notification_commands;
196 	commandsmember *service_notification_commands;
197 	int     notify_on_service_unknown;
198 	int     notify_on_service_warning;
199 	int     notify_on_service_critical;
200 	int     notify_on_service_recovery;
201 	int     notify_on_service_flapping;
202 	int     notify_on_service_downtime;
203 	int 	notify_on_host_down;
204 	int	notify_on_host_unreachable;
205 	int	notify_on_host_recovery;
206 	int     notify_on_host_flapping;
207 	int     notify_on_host_downtime;
208 	char	*host_notification_period;
209 	char	*service_notification_period;
210 	int     host_notifications_enabled;
211 	int     service_notifications_enabled;
212 	int     can_submit_commands;
213 	int     retain_status_information;
214 	int     retain_nonstatus_information;
215 	customvariablesmember *custom_variables;
216 #ifdef NSCORE
217 	time_t  last_host_notification;
218 	time_t  last_service_notification;
219 	unsigned long modified_attributes;
220 	unsigned long modified_host_attributes;
221 	unsigned long modified_service_attributes;
222 
223 	timeperiod *host_notification_period_ptr;
224 	timeperiod *service_notification_period_ptr;
225 	objectlist *contactgroups_ptr;
226 #endif
227 	struct	contact_struct *next;
228 	struct	contact_struct *nexthash;
229         };
230 
231 
232 /* SERVICESMEMBER structure */
233 typedef struct servicesmember_struct{
234 	char    *host_name;
235 	char    *service_description;
236 #ifdef NSCORE
237 	service *service_ptr;
238 #endif
239 	struct servicesmember_struct *next;
240         }servicesmember;
241 
242 
243 /* HOSTSMEMBER structure */
244 typedef struct hostsmember_struct{
245 	char    *host_name;
246 #ifdef NSCORE
247 	host    *host_ptr;
248 #endif
249 	struct hostsmember_struct *next;
250         }hostsmember;
251 
252 
253 /* HOSTGROUP structure */
254 typedef struct hostgroup_struct{
255 	char 	*group_name;
256 	char    *alias;
257 	hostsmember *members;
258 	char    *notes;
259 	char    *notes_url;
260 	char    *action_url;
261 	struct	hostgroup_struct *next;
262 	struct	hostgroup_struct *nexthash;
263 	}hostgroup;
264 
265 
266 /* HOST structure */
267 struct host_struct{
268 	char    *name;
269 	char    *display_name;
270 	char	*alias;
271 	char    *address;
272         hostsmember *parent_hosts;
273         hostsmember *child_hosts;
274 	servicesmember *services;
275 	char    *host_check_command;
276 	int     initial_state;
277 	double  check_interval;
278 	double  retry_interval;
279 	int     max_attempts;
280 	char    *event_handler;
281 	contactgroupsmember *contact_groups;
282 	contactsmember *contacts;
283 	double  notification_interval;
284 	double  first_notification_delay;
285 	int	notify_on_down;
286 	int	notify_on_unreachable;
287 	int     notify_on_recovery;
288 	int     notify_on_flapping;
289 	int     notify_on_downtime;
290 	char	*notification_period;
291 	char    *check_period;
292 	int     flap_detection_enabled;
293 	double  low_flap_threshold;
294 	double  high_flap_threshold;
295 	int     flap_detection_on_up;
296 	int     flap_detection_on_down;
297 	int     flap_detection_on_unreachable;
298 	int     stalk_on_up;
299 	int     stalk_on_down;
300 	int     stalk_on_unreachable;
301 	int     check_freshness;
302 	int     freshness_threshold;
303 	int     process_performance_data;
304 	int     checks_enabled;
305 	int     accept_passive_host_checks;
306 	int     event_handler_enabled;
307 	int     retain_status_information;
308 	int     retain_nonstatus_information;
309 	int     failure_prediction_enabled;
310 	char    *failure_prediction_options;
311 	int     obsess_over_host;
312 	char    *notes;
313 	char    *notes_url;
314 	char    *action_url;
315 	char    *icon_image;
316 	char    *icon_image_alt;
317 	char    *vrml_image;
318 	char    *statusmap_image;
319 	int     have_2d_coords;
320 	int     x_2d;
321 	int     y_2d;
322 	int     have_3d_coords;
323 	double  x_3d;
324 	double  y_3d;
325 	double  z_3d;
326 	int     should_be_drawn;
327 	customvariablesmember *custom_variables;
328 #ifdef NSCORE
329 	int     problem_has_been_acknowledged;
330 	int     acknowledgement_type;
331 	int     check_type;
332 	int     current_state;
333 	int     last_state;
334 	int     last_hard_state;
335 	char	*plugin_output;
336 	char    *long_plugin_output;
337 	char    *perf_data;
338         int     state_type;
339 	int     current_attempt;
340 	unsigned long current_event_id;
341 	unsigned long last_event_id;
342 	unsigned long current_problem_id;
343 	unsigned long last_problem_id;
344 	double  latency;
345 	double  execution_time;
346 	int     is_executing;
347 	int     check_options;
348 	int     notifications_enabled;
349 	time_t  last_host_notification;
350 	time_t  next_host_notification;
351 	time_t  next_check;
352 	int     should_be_scheduled;
353 	time_t  last_check;
354 	time_t	last_state_change;
355 	time_t	last_hard_state_change;
356 	time_t  last_time_up;
357 	time_t  last_time_down;
358 	time_t  last_time_unreachable;
359 	int     has_been_checked;
360 	int     is_being_freshened;
361 	int     notified_on_down;
362 	int     notified_on_unreachable;
363 	int     current_notification_number;
364 	int     no_more_notifications;
365 	unsigned long current_notification_id;
366 	int     check_flapping_recovery_notification;
367 	int     scheduled_downtime_depth;
368 	int     pending_flex_downtime;
369 	int     state_history[MAX_STATE_HISTORY_ENTRIES];    /* flap detection */
370 	int     state_history_index;
371 	time_t  last_state_history_update;
372 	int     is_flapping;
373 	unsigned long flapping_comment_id;
374 	double  percent_state_change;
375 	int     total_services;
376 	unsigned long total_service_check_interval;
377 	unsigned long modified_attributes;
378 	int     circular_path_checked;
379 	int     contains_circular_path;
380 
381 	command *event_handler_ptr;
382 	command *check_command_ptr;
383 	timeperiod *check_period_ptr;
384 	timeperiod *notification_period_ptr;
385 	objectlist *hostgroups_ptr;
386 #endif
387 	struct  host_struct *next;
388 	struct  host_struct *nexthash;
389         };
390 
391 
392 /* SERVICEGROUP structure */
393 typedef struct servicegroup_struct{
394 	char 	*group_name;
395 	char    *alias;
396 	servicesmember *members;
397 	char    *notes;
398 	char    *notes_url;
399 	char    *action_url;
400 	struct	servicegroup_struct *next;
401 	struct	servicegroup_struct *nexthash;
402 	}servicegroup;
403 
404 
405 /* SERVICE structure */
406 struct service_struct{
407 	char	*host_name;
408 	char	*description;
409 	char    *display_name;
410         char    *service_check_command;
411 	char    *event_handler;
412 	int     initial_state;
413 	double	check_interval;
414 	double  retry_interval;
415 	int	max_attempts;
416 	int     parallelize;
417 	contactgroupsmember *contact_groups;
418 	contactsmember *contacts;
419 	double	notification_interval;
420 	double  first_notification_delay;
421 	int     notify_on_unknown;
422 	int	notify_on_warning;
423 	int	notify_on_critical;
424 	int	notify_on_recovery;
425 	int     notify_on_flapping;
426 	int     notify_on_downtime;
427 	int     stalk_on_ok;
428 	int     stalk_on_warning;
429 	int     stalk_on_unknown;
430 	int     stalk_on_critical;
431 	int     is_volatile;
432 	char	*notification_period;
433 	char	*check_period;
434 	int     flap_detection_enabled;
435 	double  low_flap_threshold;
436 	double  high_flap_threshold;
437 	int     flap_detection_on_ok;
438 	int     flap_detection_on_warning;
439 	int     flap_detection_on_unknown;
440 	int     flap_detection_on_critical;
441 	int     process_performance_data;
442 	int     check_freshness;
443 	int     freshness_threshold;
444 	int     accept_passive_service_checks;
445 	int     event_handler_enabled;
446 	int	checks_enabled;
447 	int     retain_status_information;
448 	int     retain_nonstatus_information;
449 	int     notifications_enabled;
450 	int     obsess_over_service;
451 	int     failure_prediction_enabled;
452 	char    *failure_prediction_options;
453 	char    *notes;
454 	char    *notes_url;
455 	char    *action_url;
456 	char    *icon_image;
457 	char    *icon_image_alt;
458 	customvariablesmember *custom_variables;
459 #ifdef NSCORE
460 	int     problem_has_been_acknowledged;
461 	int     acknowledgement_type;
462 	int     host_problem_at_last_check;
463 	int     check_type;
464 	int	current_state;
465 	int	last_state;
466 	int	last_hard_state;
467 	char	*plugin_output;
468 	char    *long_plugin_output;
469 	char    *perf_data;
470         int     state_type;
471 	time_t	next_check;
472 	int     should_be_scheduled;
473 	time_t	last_check;
474 	int	current_attempt;
475 	unsigned long current_event_id;
476 	unsigned long last_event_id;
477 	unsigned long current_problem_id;
478 	unsigned long last_problem_id;
479 	time_t	last_notification;
480 	time_t  next_notification;
481 	int     no_more_notifications;
482 	int     check_flapping_recovery_notification;
483 	time_t	last_state_change;
484 	time_t	last_hard_state_change;
485 	time_t  last_time_ok;
486 	time_t  last_time_warning;
487 	time_t  last_time_unknown;
488 	time_t  last_time_critical;
489 	int     has_been_checked;
490 	int     is_being_freshened;
491 	int     notified_on_unknown;
492 	int     notified_on_warning;
493 	int     notified_on_critical;
494 	int     current_notification_number;
495         unsigned long current_notification_id;
496 	double  latency;
497 	double  execution_time;
498 	int     is_executing;
499 	int     check_options;
500 	int     scheduled_downtime_depth;
501 	int     pending_flex_downtime;
502 	int     state_history[MAX_STATE_HISTORY_ENTRIES];    /* flap detection */
503 	int     state_history_index;
504 	int     is_flapping;
505 	unsigned long flapping_comment_id;
506 	double  percent_state_change;
507 	unsigned long modified_attributes;
508 
509 	host *host_ptr;
510 	command *event_handler_ptr;
511 	char *event_handler_args;
512 	command *check_command_ptr;
513 	char *check_command_args;
514 	timeperiod *check_period_ptr;
515 	timeperiod *notification_period_ptr;
516 	objectlist *servicegroups_ptr;
517 #endif
518 	struct service_struct *next;
519 	struct service_struct *nexthash;
520 	};
521 
522 
523 /* SERVICE ESCALATION structure */
524 typedef struct serviceescalation_struct{
525 	char    *host_name;
526 	char    *description;
527 	int     first_notification;
528 	int     last_notification;
529 	double  notification_interval;
530 	char    *escalation_period;
531 	int     escalate_on_recovery;
532 	int     escalate_on_warning;
533 	int     escalate_on_unknown;
534 	int     escalate_on_critical;
535 	contactgroupsmember *contact_groups;
536 	contactsmember *contacts;
537 #ifdef NSCORE
538 	service *service_ptr;
539 	timeperiod *escalation_period_ptr;
540 #endif
541 	struct  serviceescalation_struct *next;
542 	struct  serviceescalation_struct *nexthash;
543         }serviceescalation;
544 
545 
546 /* SERVICE DEPENDENCY structure */
547 typedef struct servicedependency_struct{
548 	int     dependency_type;
549 	char    *dependent_host_name;
550 	char    *dependent_service_description;
551 	char    *host_name;
552 	char    *service_description;
553 	char    *dependency_period;
554 	int     inherits_parent;
555 	int     fail_on_ok;
556 	int     fail_on_warning;
557 	int     fail_on_unknown;
558 	int     fail_on_critical;
559 	int     fail_on_pending;
560 #ifdef NSCORE
561 	int     circular_path_checked;
562 	int     contains_circular_path;
563 
564 	service *master_service_ptr;
565 	service *dependent_service_ptr;
566 	timeperiod *dependency_period_ptr;
567 #endif
568 	struct servicedependency_struct *next;
569 	struct servicedependency_struct *nexthash;
570         }servicedependency;
571 
572 
573 /* HOST ESCALATION structure */
574 typedef struct hostescalation_struct{
575 	char    *host_name;
576 	int     first_notification;
577 	int     last_notification;
578 	double  notification_interval;
579 	char    *escalation_period;
580 	int     escalate_on_recovery;
581 	int     escalate_on_down;
582 	int     escalate_on_unreachable;
583 	contactgroupsmember *contact_groups;
584 	contactsmember *contacts;
585 #ifdef NSCORE
586 	host    *host_ptr;
587 	timeperiod *escalation_period_ptr;
588 #endif
589 	struct  hostescalation_struct *next;
590 	struct  hostescalation_struct *nexthash;
591         }hostescalation;
592 
593 
594 /* HOST DEPENDENCY structure */
595 typedef struct hostdependency_struct{
596 	int     dependency_type;
597 	char    *dependent_host_name;
598 	char    *host_name;
599 	char    *dependency_period;
600 	int     inherits_parent;
601 	int     fail_on_up;
602 	int     fail_on_down;
603 	int     fail_on_unreachable;
604 	int     fail_on_pending;
605 #ifdef NSCORE
606 	int     circular_path_checked;
607 	int     contains_circular_path;
608 
609 	host    *master_host_ptr;
610 	host    *dependent_host_ptr;
611 	timeperiod *dependency_period_ptr;
612 #endif
613 	struct hostdependency_struct *next;
614 	struct hostdependency_struct *nexthash;
615         }hostdependency;
616 
617 
618 
619 
620 /****************** HASH STRUCTURES ********************/
621 
622 typedef struct host_cursor_struct{
623 	int     host_hashchain_iterator;
624 	host    *current_host_pointer;
625         }host_cursor;
626 
627 
628 
629 
630 
631 /********************* FUNCTIONS **********************/
632 
633 /**** Top-level input functions ****/
634 int read_object_config_data(char *,int,int,int);        /* reads all external configuration data of specific types */
635 
636 
637 /**** Object Creation Functions ****/
638 contact *add_contact(char *,char *,char *,char *,char **,char *,char *,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int);	/* adds a contact definition */
639 commandsmember *add_service_notification_command_to_contact(contact *,char *);				/* adds a service notification command to a contact definition */
640 commandsmember *add_host_notification_command_to_contact(contact *,char *);				/* adds a host notification command to a contact definition */
641 customvariablesmember *add_custom_variable_to_contact(contact *,char *,char *);                         /* adds a custom variable to a service definition */
642 host *add_host(char *,char *,char *,char *,char *,int,double,double,int,int,int,int,int,int,double,double,char *,int,char *,int,int,char *,int,int,double,double,int,int,int,int,int,int,int,int,char *,int,int,char *,char *,char *,char *,char *,char *,char *,int,int,int,double,double,double,int,int,int,int,int);	/* adds a host definition */
643 hostsmember *add_parent_host_to_host(host *,char *);							/* adds a parent host to a host definition */
644 hostsmember *add_child_link_to_host(host *,host *);						        /* adds a child host to a host definition */
645 contactgroupsmember *add_contactgroup_to_host(host *,char *);					        /* adds a contactgroup to a host definition */
646 contactsmember *add_contact_to_host(host *,char *);                                                     /* adds a contact to a host definition */
647 customvariablesmember *add_custom_variable_to_host(host *,char *,char *);                               /* adds a custom variable to a host definition */
648 timeperiod *add_timeperiod(char *,char *);								/* adds a timeperiod definition */
649 timeperiodexclusion *add_exclusion_to_timeperiod(timeperiod *,char *);                                  /* adds an exclusion to a timeperiod */
650 timerange *add_timerange_to_timeperiod(timeperiod *,int,unsigned long,unsigned long);			/* adds a timerange to a timeperiod definition */
651 daterange *add_exception_to_timeperiod(timeperiod *,int,int,int,int,int,int,int,int,int,int,int,int);
652 timerange *add_timerange_to_daterange(daterange *,unsigned long,unsigned long);
653 hostgroup *add_hostgroup(char *,char *,char *,char *,char *);						/* adds a hostgroup definition */
654 hostsmember *add_host_to_hostgroup(hostgroup *, char *);						/* adds a host to a hostgroup definition */
655 servicegroup *add_servicegroup(char *,char *,char *,char *,char *);                                     /* adds a servicegroup definition */
656 servicesmember *add_service_to_servicegroup(servicegroup *,char *,char *);                              /* adds a service to a servicegroup definition */
657 contactgroup *add_contactgroup(char *,char *);								/* adds a contactgroup definition */
658 contactsmember *add_contact_to_contactgroup(contactgroup *,char *);					/* adds a contact to a contact group definition */
659 command *add_command(char *,char *);									/* adds a command definition */
660 service *add_service(char *,char *,char *,char *,int,int,int,int,double,double,double,double,char *,int,int,int,int,int,int,int,int,char *,int,char *,int,int,double,double,int,int,int,int,int,int,int,int,int,int,char *,int,int,char *,char *,char *,char *,char *,int,int,int);	/* adds a service definition */
661 contactgroupsmember *add_contactgroup_to_service(service *,char *);					/* adds a contact group to a service definition */
662 contactsmember *add_contact_to_service(service *,char *);                                               /* adds a contact to a host definition */
663 serviceescalation *add_serviceescalation(char *,char *,int,int,double,char *,int,int,int,int);          /* adds a service escalation definition */
664 contactgroupsmember *add_contactgroup_to_serviceescalation(serviceescalation *,char *);                 /* adds a contact group to a service escalation definition */
665 contactsmember *add_contact_to_serviceescalation(serviceescalation *,char *);                           /* adds a contact to a service escalation definition */
666 customvariablesmember *add_custom_variable_to_service(service *,char *,char *);                         /* adds a custom variable to a service definition */
667 servicedependency *add_service_dependency(char *,char *,char *,char *,int,int,int,int,int,int,int,char *);     /* adds a service dependency definition */
668 hostdependency *add_host_dependency(char *,char *,int,int,int,int,int,int,char *);                             /* adds a host dependency definition */
669 hostescalation *add_hostescalation(char *,int,int,double,char *,int,int,int);                           /* adds a host escalation definition */
670 contactsmember *add_contact_to_hostescalation(hostescalation *,char *);                                 /* adds a contact to a host escalation definition */
671 contactgroupsmember *add_contactgroup_to_hostescalation(hostescalation *,char *);                       /* adds a contact group to a host escalation definition */
672 
673 contactsmember *add_contact_to_object(contactsmember **,char *);                                        /* adds a contact to an object */
674 customvariablesmember *add_custom_variable_to_object(customvariablesmember **,char *,char *);           /* adds a custom variable to an object */
675 
676 
677 servicesmember *add_service_link_to_host(host *,service *);
678 
679 
680 /*** Object Skiplist Functions ****/
681 int init_object_skiplists(void);
682 int free_object_skiplists(void);
683 int skiplist_compare_text(const char *val1a, const char *val1b, const char *val2a, const char *val2b);
684 int skiplist_compare_host(void *a, void *b);
685 int skiplist_compare_service(void *a, void *b);
686 int skiplist_compare_command(void *a, void *b);
687 int skiplist_compare_timeperiod(void *a, void *b);
688 int skiplist_compare_contact(void *a, void *b);
689 int skiplist_compare_contactgroup(void *a, void *b);
690 int skiplist_compare_hostgroup(void *a, void *b);
691 int skiplist_compare_servicegroup(void *a, void *b);
692 int skiplist_compare_hostescalation(void *a, void *b);
693 int skiplist_compare_serviceescalation(void *a, void *b);
694 int skiplist_compare_hostdependency(void *a, void *b);
695 int skiplist_compare_servicedependency(void *a, void *b);
696 
697 int get_host_count(void);
698 int get_service_count(void);
699 
700 
701 
702 /**** Object Hash Functions ****/
703 int add_servicedependency_to_hashlist(servicedependency *);
704 
705 
706 /**** Object Search Functions ****/
707 timeperiod * find_timeperiod(char *);						                /* finds a timeperiod object */
708 host * find_host(char *);									/* finds a host object */
709 hostgroup * find_hostgroup(char *);						                /* finds a hostgroup object */
710 servicegroup * find_servicegroup(char *);					                /* finds a servicegroup object */
711 contact * find_contact(char *);							                /* finds a contact object */
712 contactgroup * find_contactgroup(char *);					                /* finds a contactgroup object */
713 command * find_command(char *);							                /* finds a command object */
714 service * find_service(char *,char *);								/* finds a service object */
715 
716 
717 /**** Object Traversal Functions ****/
718 hostescalation *get_first_hostescalation_by_host(char *, void **);
719 hostescalation *get_next_hostescalation_by_host(char *,void **);
720 serviceescalation *get_first_serviceescalation_by_service(char *,char *, void **);
721 serviceescalation *get_next_serviceescalation_by_service(char *,char *,void **);
722 hostdependency *get_first_hostdependency_by_dependent_host(char *, void **);
723 hostdependency *get_next_hostdependency_by_dependent_host(char *, void **);
724 servicedependency *get_first_servicedependency_by_dependent_service(char *,char *, void **);
725 servicedependency *get_next_servicedependency_by_dependent_service(char *,char *,void **);
726 
727 #ifdef NSCORE
728 int add_object_to_objectlist(objectlist **,void *);
729 int free_objectlist(objectlist **);
730 #endif
731 
732 
733 /**** Object Query Functions ****/
734 int is_host_immediate_child_of_host(host *,host *);	                /* checks if a host is an immediate child of another host */
735 int is_host_primary_immediate_child_of_host(host *,host *);             /* checks if a host is an immediate child (and primary child) of another host */
736 int is_host_immediate_parent_of_host(host *,host *);	                /* checks if a host is an immediate child of another host */
737 int is_host_member_of_hostgroup(hostgroup *,host *);		        /* tests whether or not a host is a member of a specific hostgroup */
738 int is_host_member_of_servicegroup(servicegroup *,host *);	        /* tests whether or not a service is a member of a specific servicegroup */
739 int is_service_member_of_servicegroup(servicegroup *,service *);	/* tests whether or not a service is a member of a specific servicegroup */
740 int is_contact_member_of_contactgroup(contactgroup *, contact *);	/* tests whether or not a contact is a member of a specific contact group */
741 int is_contact_for_hostgroup(hostgroup *,contact *);	                /* tests whether or not a contact is a member of a specific hostgroup */
742 int is_contact_for_servicegroup(servicegroup *,contact *);	        /* tests whether or not a contact is a member of a specific servicegroup */
743 int is_contact_for_host(host *,contact *);			        /* tests whether or not a contact is a contact member for a specific host */
744 int is_escalated_contact_for_host(host *,contact *);                    /* checks whether or not a contact is an escalated contact for a specific host */
745 int is_contact_for_service(service *,contact *);		        /* tests whether or not a contact is a contact member for a specific service */
746 int is_escalated_contact_for_service(service *,contact *);              /* checks whether or not a contact is an escalated contact for a specific service */
747 int is_host_immediate_parent_of_host(host *,host *);		        /* tests whether or not a host is an immediate parent of another host */
748 
749 int number_of_immediate_child_hosts(host *);		                /* counts the number of immediate child hosts for a particular host */
750 int number_of_total_child_hosts(host *);				/* counts the number of total child hosts for a particular host */
751 int number_of_immediate_parent_hosts(host *);				/* counts the number of immediate parents hosts for a particular host */
752 int number_of_total_parent_hosts(host *);				/* counts the number of total parents hosts for a particular host */
753 
754 #ifdef NSCORE
755 int check_for_circular_host_path(host *,host *);                             /* checks if a circular path exists for a given host */
756 int check_for_circular_servicedependency_path(servicedependency *,servicedependency *,int);   /* checks if a circular dependency exists for a given service */
757 int check_for_circular_hostdependency_path(hostdependency *,hostdependency *,int);   /* checks if a circular dependency exists for a given host */
758 #endif
759 
760 
761 /**** Object Cleanup Functions ****/
762 int free_object_data(void);                             /* frees all allocated memory for the object definitions */
763 
764 
765 
766 
767 #ifdef __cplusplus
768   }
769 #endif
770 
771 #endif
772