sw-collector: Moved to its own directory and added man page
[strongswan.git] / src / 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 sw_collector
19 */
20
21 #ifndef SW_COLLECTOR_HISTORY_H_
22 #define SW_COLLECTOR_HISTORY_H_
23
24 #include "sw_collector_history.h"
25 #include "sw_collector_info.h"
26 #include "sw_collector_db.h"
27
28 #include <library.h>
29 #include <utils/debug.h>
30 #include <utils/lexparser.h>
31
32 typedef struct sw_collector_history_t sw_collector_history_t;
33 typedef enum sw_collector_history_op_t sw_collector_history_op_t;
34
35 /**
36 * Define major history event operations
37 */
38 enum sw_collector_history_op_t {
39 SW_OP_INSTALL,
40 SW_OP_UPGRADE,
41 SW_OP_REMOVE
42 };
43
44 /**
45 * Software collector history object
46 */
47 struct sw_collector_history_t {
48
49 /**
50 * Extract timestamp from event in installation history
51 *
52 * @param args Arguments to be processed
53 * @param buf timestamp buffer for 21 byte RFC 3339 string
54 * @return TRUE if extraction succeeded
55 */
56 bool (*extract_timestamp)(sw_collector_history_t *this, chunk_t args,
57 char *buf);
58
59 /**
60 * Extract packages from event in installation history
61 *
62 * @param args Arguments to be processed
63 * @param eid Primary key pointing to current event
64 * @param op Extraction operation
65 * @return TRUE if extraction succeeded
66 */
67 bool (*extract_packages)(sw_collector_history_t *this, chunk_t args,
68 uint32_t eid, sw_collector_history_op_t op);
69
70 /**
71 * Merge packages from initial installation
72 *
73 * @return TRUE if merge succeeded
74 */
75 bool (*merge_installed_packages)(sw_collector_history_t *this);
76
77 /**
78 * Destroy sw_collector_history_t object
79 */
80 void (*destroy)(sw_collector_history_t *this);
81
82 };
83
84 /**
85 * Create an sw_collector_history_t instance
86 *
87 * @param info Internal reference to collector info
88 * @param db Internal reference to collector database
89 * @param source Software event source number
90 */
91 sw_collector_history_t* sw_collector_history_create(sw_collector_info_t *info,
92 sw_collector_db_t *db,
93 uint8_t source);
94
95 #endif /** SW_COLLECTOR_HISTORY_H_ @}*/