db: the database access layer.


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.

Function Documentation

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.

Parameters:
db a valid database handle
p a pointer to a libparticle packet
timestamp the timestamp of the packet in unixtime
Returns:
0 on success -1 on failure

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

Parameters:
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.

Parameters:
q a valid query-handle
time a pointer to an int for storage of the packets timestamp ( can be NULL )
Returns:
a valid p_packet or 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

Parameters:
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");
First it will look for a library particledb_name_of_the_backend( here mysql5 ) and load this library ( if it exists). After that the library is used to open a connection to the specified database It is important that the specified user has sufficient access rights for the intended operation ( query or write ).
Parameters:
db_id location of the database
Returns:
a valid p_db or NULL

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.*

Parameters:
db_id location of the database
searchpaths a colon-seperated list of plugin searchpaths, for example; "/lib/;/usr/lib/;plugins/;particle"
Returns:
a valid p_db or NULL

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);

Parameters:
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
Returns:
a valid p_query handle on success or NULL

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

Parameters:
filter a handle to a libparticle filter
db see p_db_query
start see p_db_query
stop see p_db_query
See also:
p_db_query, p_filter_create, p_filter_add


Generated on Tue Apr 10 15:22:26 2007 for libparticle by  doxygen 1.5.1