Functions | |
p_db * | p_db_open (char *db_id) |
Initializes a connection to a database. | |
p_db * | p_db_open_paths (char *db_id, char *searchpaths) |
same as p_db_open but plugin searchpaths are configurable. | |
void | p_db_close (p_db *db) |
Closes a connection to a database. | |
p_query * | p_db_query (p_db *db, time_t start, time_t stop) |
Query data from the database. | |
p_query * | p_db_query_filtered (p_db *db, int filter, time_t start, time_t stop) |
Query filtered data from the database. | |
p_packet * | p_db_fetch (p_query *q, time_t *time) |
Fetch the next packet from the resultset. | |
int | p_db_add (p_db *db, struct p_packet *p, time_t timestamp) |
Add a packet to the database. | |
void | p_db_finalize (p_query *q) |
Finalize a query. |
int p_db_add | ( | p_db * | db, | |
struct p_packet * | p, | |||
time_t | timestamp | |||
) |
Add a packet to the database.
Adds a new libparticle packet to the database. If necessary a new table will be created.
db | a valid database handle | |
p | a pointer to a libparticle packet | |
timestamp | the timestamp of the packet in unixtime |
void p_db_close | ( | p_db * | db | ) |
Closes a connection to a database.
Closes a connection to a database and frees allocated memory. Failure to call p_db_close will result in memory leaks
db | a valid p_db Object |
struct p_packet* p_db_fetch | ( | p_query * | q, | |
time_t * | time | |||
) |
Fetch the next packet from the resultset.
Fetches the next packet from the resultset until all data is fetched or an error is encountered and NULL is returned.
q | a valid query-handle | |
time | a pointer to an int for storage of the packets timestamp ( can be NULL ) |
void p_db_finalize | ( | p_query * | q | ) |
Finalize a query.
Finalizes a query and frees allocated memory Failure to call p_db_finalize will result in memory leaks
q | a valid query-handle |
p_db* p_db_open | ( | char * | db_id | ) |
Initializes a connection to a database.
Initializes a connection to a database. Takes a string formatted name_of_the_backend://backend-specific e.g.
p_db_open("mysql5://packetlog:packetlog@teco142pc.edu:3306/packetlog");
db_id | location of the database |
p_db* p_db_open_paths | ( | char * | db_id, | |
char * | searchpaths | |||
) |
same as p_db_open but plugin searchpaths are configurable.
On win32 platform the / path seperator will be replaced with the \ automatically.
On posix platform the \ path seperator will be replaced with the / automatically.
If you like the system dynamic linker search paths included, specify the special SYSTEM searchpath. "SYSTEM;lib" which will search in the system search paths and the ones supplied.*
db_id | location of the database | |
searchpaths | a colon-seperated list of plugin searchpaths, for example; "/lib/;/usr/lib/;plugins/;particle" |
p_query* p_db_query | ( | p_db * | db, | |
time_t | start, | |||
time_t | stop | |||
) |
Query data from the database.
Queries data from the database. After querying the data it can be read using p_db_fetch. Example:
p_db_query(db,10,20,0);
db | a valid database handle | |
start | Start of the data as Unix-Timestamp (if later than stop, order of packets is reversed) | |
stop | End of the data as Unix-Timestamp |
p_query* p_db_query_filtered | ( | p_db * | db, | |
int | filter, | |||
time_t | start, | |||
time_t | stop | |||
) |
Query filtered data from the database.
Queries filtered data from the database using a libparticle-filter First build a filter using p_filter_create,p_filter_add and p_filter_add_str then call p_db_query_filtered using the received handle
filter | a handle to a libparticle filter | |
db | see p_db_query | |
start | see p_db_query | |
stop | see p_db_query |