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_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: * Extract timestamp from event in installation history
49: *
50: * @param args Arguments to be processed
51: * @param buf timestamp buffer for 21 byte RFC 3339 string
52: * @return TRUE if extraction succeeded
53: */
54: bool (*extract_timestamp)(sw_collector_history_t *this, chunk_t args,
55: char *buf);
56:
57: /**
58: * Extract packages from event in installation history
59: *
60: * @param args Arguments to be processed
61: * @param eid Primary key pointing to current event
62: * @param op Extraction operation
63: * @return TRUE if extraction succeeded
64: */
65: bool (*extract_packages)(sw_collector_history_t *this, chunk_t args,
66: uint32_t eid, sw_collector_history_op_t op);
67:
68: /**
69: * Merge packages from initial installation
70: *
71: * @return TRUE if merge succeeded
72: */
73: bool (*merge_installed_packages)(sw_collector_history_t *this);
74:
75: /**
76: * Destroy sw_collector_history_t object
77: */
78: void (*destroy)(sw_collector_history_t *this);
79:
80: };
81:
82: /**
83: * Create an sw_collector_history_t instance
84: *
85: * @param db Internal reference to collector database
86: * @param source Software event source number
87: */
88: sw_collector_history_t* sw_collector_history_create(sw_collector_db_t *db,
89: uint8_t source);
90:
91: #endif /** SW_COLLECTOR_HISTORY_H_ @}*/
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>