Merge branch 'swima'
[strongswan.git] / src / libimcv / plugins / imc_swima / sw_collector / sw_collector_history.h
1 /*
2 * Copyright (C) 2017 Andreas Steffen
3 * HSR Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup sw_collector_history_t sw_collector_history
18 * @{ @ingroup imc_swima
19 */
20
21 #ifndef SW_COLLECTOR_HISTORY_H_
22 #define SW_COLLECTOR_HISTORY_H_
23
24 #include "sw_collector_db.h"
25
26 #include <library.h>
27 #include <utils/debug.h>
28 #include <utils/lexparser.h>
29
30 typedef struct sw_collector_history_t sw_collector_history_t;
31 typedef enum sw_collector_history_op_t sw_collector_history_op_t;
32
33 /**
34 * Define major history event operations
35 */
36 enum sw_collector_history_op_t {
37 SW_OP_INSTALL,
38 SW_OP_UPGRADE,
39 SW_OP_REMOVE
40 };
41
42 /**
43 * Software collector history object
44 */
45 struct sw_collector_history_t {
46
47 /**
48 * Get OS and product strings
49 *
50 * @param product Product string formed from OS info
51 * @return OS string formed from OS info
52 */
53 char* (*get_os)(sw_collector_history_t *this, char **product);
54
55 /**
56 * Extract timestamp from event in installation history
57 *
58 * @param args Arguments to be processed
59 * @param buf timestamp buffer for 21 byte RFC 3339 string
60 * @return TRUE if extraction succeeded
61 */
62 bool (*extract_timestamp)(sw_collector_history_t *this, chunk_t args,
63 char *buf);
64
65 /**
66 * Extract packages from event in installation history
67 *
68 * @param args Arguments to be processed
69 * @param eid Primary key pointing to current event
70 * @param op Extraction operation
71 * @return TRUE if extraction succeeded
72 */
73 bool (*extract_packages)(sw_collector_history_t *this, chunk_t args,
74 uint32_t eid, sw_collector_history_op_t op);
75
76 /**
77 * Merge packages from initial installation
78 *
79 * @return TRUE if merge succeeded
80 */
81 bool (*merge_installed_packages)(sw_collector_history_t *this);
82
83 /**
84 * Destroy sw_collector_history_t object
85 */
86 void (*destroy)(sw_collector_history_t *this);
87
88 };
89
90 /**
91 * Create an sw_collector_history_t instance
92 *
93 * @param db Internal reference to collector database
94 * @param source Software event source number
95 */
96 sw_collector_history_t* sw_collector_history_create(sw_collector_db_t *db,
97 uint8_t source);
98
99 #endif /** SW_COLLECTOR_HISTORY_H_ @}*/