Annotation of embedaddon/strongswan/src/sw-collector/sw_collector_db.h, revision 1.1.1.1
1.1 misho 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_db_t sw_collector_db
18: * @{ @ingroup sw_collector
19: */
20:
21: #ifndef SW_COLLECTOR_DB_H_
22: #define SW_COLLECTOR_DB_H_
23:
24: #include <library.h>
25:
26: typedef struct sw_collector_db_t sw_collector_db_t;
27: typedef enum sw_collector_db_query_t sw_collector_db_query_t;
28:
29: /**
30: * Type of software identifier queries
31: */
32: enum sw_collector_db_query_t {
33: SW_QUERY_ALL,
34: SW_QUERY_INSTALLED,
35: SW_QUERY_REMOVED
36: };
37:
38: /**
39: * Software collector database object
40: */
41: struct sw_collector_db_t {
42:
43: /**
44: * bAdd event to database
45: *
46: * @param timestamp Timestamp in 20 octet RFC 3339 format
47: * @return Primary key pointing to event ID or 0 if failed
48: */
49: uint32_t (*add_event)(sw_collector_db_t *this, char *timestamp);
50:
51: /**
52: * Get last event, zero EID if none exists
53: *
54: * @param eid Primary key pointing to last event
55: * @param epoch Epoch
56: * @param last_time Timestamp in 20 octet RFC 3339 format of last event
57: * @return
58: */
59: bool (*get_last_event)(sw_collector_db_t *this, uint32_t *eid,
60: uint32_t *epoch, char **last_time);
61:
62: /**
63: * Add software identifier event to database
64: *
65: * @param eid Foreign key pointing to an event ID
66: * @param sw_id Foreign key pointing to a software identifier
67: * @param action 1 for CREATION, 2 for deletion
68: * @return TRUE if successful
69: */
70: bool (*add_sw_event)(sw_collector_db_t *this, uint32_t eid, uint32_t sw_id,
71: uint8_t action);
72:
73: /**
74: * Set software_identifier, checking if the identifier already exists
75: *
76: * @param name Software identifier
77: * @param package Software package
78: * @param version Version of software package
79: * @param source Source ID of the software collector
80: * @param installed Installation status to be set, TRUE if installed
81: * @return Primary key pointing to SW ID or 0 if failed
82: */
83: uint32_t (*set_sw_id)(sw_collector_db_t *this, char *name, char *package,
84: char *version, uint8_t source, bool installed);
85:
86: /**
87: * Get software_identifier record
88: *
89: * @param name Software identifier
90: * @param package Software package
91: * @param version Version of software package
92: * @param source Source ID of the software collector
93: * @param installed Installation status
94: * @return Primary key pointing to SW ID or 0 if failed
95: */
96: uint32_t (*get_sw_id)(sw_collector_db_t *this, char *name, char **package,
97: char **version, uint8_t *source, bool *installed);
98:
99: /**
100: * Get number of installed or removed software identifiers
101: *
102: * @param type Query type (ALL, INSTALLED, REMOVED)
103: * @return Count
104: */
105: uint32_t (*get_sw_id_count)(sw_collector_db_t *this,
106: sw_collector_db_query_t type);
107:
108: /**
109: * Update the software identifier version
110: *
111: * @param sw_id Primary key of software identifier
112: * @param name Software identifier
113: * @param version Package version
114: * @param installed Installation status
115: * @return TRUE if update successful
116: */
117: bool (*update_sw_id)(sw_collector_db_t *this, uint32_t sw_id, char *name,
118: char *version, bool installed);
119:
120: /**
121: * Update the package name
122: *
123: * @param package_filter Package name[s] to be changed
124: * @param package New package name
125: * @return TRUE if update successful
126: */
127: int (*update_package)(sw_collector_db_t *this, char *package_filter,
128: char *package);
129:
130: /**
131: * Enumerate over all collected [installed] software identities
132: *
133: * @param type Query type (ALL, INSTALLED, REMOVED)
134: * @param package If not NULL enumerate over all package versions
135: * @return Enumerator
136: */
137: enumerator_t* (*create_sw_enumerator)(sw_collector_db_t *this,
138: sw_collector_db_query_t type,
139: char *package);
140:
141: /**
142: * Destroy sw_collector_db_t object
143: */
144: void (*destroy)(sw_collector_db_t *this);
145:
146: };
147:
148: /**
149: * Create an sw_collector_db_t instance
150: *
151: * @param uri database URI
152: */
153: sw_collector_db_t* sw_collector_db_create(char *uri);
154:
155: #endif /** SW_COLLECTOR_DB_H_ @}*/
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>