Code

store: Don't return an error if an updated host is too old.
[sysdb.git] / src / include / core / store.h
1 /*
2  * syscollector - src/include/core/store.h
3  * Copyright (C) 2012 Sebastian 'tokkee' Harl <sh@tokkee.org>
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
19  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
28 #ifndef SC_CORE_STORE_H
29 #define SC_CORE_STORE_H 1
31 #include "syscollector.h"
32 #include "core/object.h"
33 #include "utils/time.h"
34 #include "utils/llist.h"
36 #include <stdio.h>
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
42 typedef struct {
43         sc_object_t parent;
45         sc_time_t last_update;
46         char *name;
47 } sc_store_obj_t;
48 #define SC_STORE_OBJ_INIT { SC_OBJECT_INIT, 0, NULL }
49 #define SC_STORE_OBJ(obj) ((sc_store_obj_t *)(obj))
51 typedef struct {
52         sc_store_obj_t parent;
53 #define svc_last_update parent.last_update
54 #define svc_name parent.name
56         char *hostname;
57 } sc_service_t;
58 #define SC_SVC_INIT { SC_STORE_OBJ_INIT, NULL }
59 #define SC_SVC(obj) ((sc_service_t *)(obj))
61 typedef struct {
62         sc_store_obj_t parent;
63 #define host_last_update parent.last_update
64 #define host_name parent.name
66         sc_llist_t *services;
67 } sc_host_t;
68 #define SC_HOST_INIT { SC_STORE_OBJ_INIT, NULL }
69 #define SC_HOST(obj) ((sc_host_t *)(obj))
71 sc_host_t *
72 sc_host_create(char *name);
74 sc_host_t *
75 sc_host_clone(const sc_host_t *host);
77 int
78 sc_store_host(const sc_host_t *host);
80 const sc_host_t *
81 sc_store_get_host(char *name);
83 sc_service_t *
84 sc_service_create(char *hostname, char *name);
86 sc_service_t *
87 sc_service_clone(const sc_service_t *svc);
89 int
90 sc_store_service(const sc_service_t *svc);
92 const sc_service_t *
93 sc_store_get_service(const sc_host_t *host, char *name);
95 int
96 sc_store_dump(FILE *fh);
98 #ifdef __cplusplus
99 } /* extern "C" */
100 #endif
102 #endif /* ! SC_CORE_STORE_H */
104 /* vim: set tw=78 sw=4 ts=4 noexpandtab : */