dsdb.c File Reference

DSDB Application Layer C Library. More...

#include <stdlib.h>
#include <string.h>
#include "dsdb.h"

Go to the source code of this file.

Functions

char * dsdb_get_error (DSDB *dsdb)
 Get Last Error Message.

int dsdb_get_status (DSDB *dsdb)
 Get Status of Last Function Call.

void dsdb_set_error (DSDB *dsdb, int status, const char *error)
 Set Function Status and Error Message.

void dsdb_free (DSDB *dsdb)
 Free DSDB Structure.

DSDBdsdb_new (DB_TYPE db_type)
 Create New DSDB Structure.

int dsdb_connect (DSDB *dsdb, const char *db_alias)
 Make Initial Database Connection.

void dsdb_disconnect (DSDB *dsdb)
 Disconnect From Database.

int dsdb_reconnect (DSDB *dsdb)
 Reconnect To Database.

int dsdb_is_connected (DSDB *dsdb)
 Check If Database Connection Has Been Established.

int dsdb_init_process_methods (DSDB *dsdb, const char *site, const char *facility, const char *proc_type, const char *proc_name)
time_t dsdb_text_to_tm (DSDB *dsdb, const char *text, struct tm *tm_time)
char * dsdb_tm_to_text (DSDB *dsdb, const struct tm *tm_time, char *text)
int * dsdb_text_to_bool (DSDB *dsdb, const char *text, int *bool_val)
char * dsdb_bool_to_text (DSDB *dsdb, int bool_val, char *text)
char * dsdb_string_copy (DSDB *dsdb, const char *str_in)
tm * dsdb_tm_copy (DSDB *dsdb, const struct tm *tm_in)
tm * dsdb_tm_create (DSDB *dsdb, const char *time_string)


Detailed Description

DSDB Application Layer C Library.

The DSDB C Library is the base library that applications should use to access the stored procedures in the Data System Database.

Definition in file dsdb.c.


Function Documentation

int dsdb_connect DSDB dsdb,
const char *  db_alias
 

Make Initial Database Connection.

This function must be called to make the initial connection to the database. It will parse the user's .db_connect file looking for the specified db_alias.

Parameters:
dsdb Pointer to the DSDB structure.
db_alias The database alias defined in the user's .db_connect file.
Returns:
  • 0 => Failure
  • 1 => Success
See also:
dsdb_disconnect, dsdb_reconnect

Definition at line 182 of file dsdb.c.

References DSDB::armdb.

void dsdb_disconnect DSDB dsdb  ) 
 

Disconnect From Database.

This function will close the database connection but preserve the settings of the current session. The dsdb_reconnect function can then be called to reconnect to the database.

Parameters:
dsdb Pointer to the DSDB structure.
See also:
dsdb_reconnect

Definition at line 195 of file dsdb.c.

References DSDB::armdb.

void dsdb_free DSDB dsdb  ) 
 

Free DSDB Structure.

This function will close the database connection and free all memory used by the DSDB structure.

Parameters:
dsdb Pointer to the DSDB structure.

Definition at line 120 of file dsdb.c.

References DSDB::armdb, DSDB::facility, DSDB::proc_name, DSDB::proc_type, and DSDB::site.

char* dsdb_get_error DSDB dsdb  ) 
 

Get Last Error Message.

Parameters:
dsdb Pointer to the DSDB structure.
Returns:
The last DSDB error message.

Definition at line 56 of file dsdb.c.

References DSDB::armdb.

int dsdb_get_status DSDB dsdb  ) 
 

Get Status of Last Function Call.

Parameters:
dsdb Pointer to the DSDB structure.
Returns:
The status of the last DSDB function call:
  • DB_NO_ERROR => No error was generated.
  • DB_ERROR => An internal database error was generated.
  • DB_FILE_ERROR => Error reading the user's .db_connect file.
  • DB_MEM_ERROR => Memory allocation error.
  • DB_NULL_RESULT => A NULL result was received from the database query.
  • DB_BAD_RESULT => An invalid result was received from the database query.
  • DB_BAD_INPUT => A bad input value was detected.
See also:
dsdb_get_error

Definition at line 79 of file dsdb.c.

References DSDB::armdb.

int dsdb_is_connected DSDB dsdb  ) 
 

Check If Database Connection Has Been Established.

Parameters:
dsdb Pointer to the DSDB structure.
Returns:
  • 0 => Disconnected
  • 1 => Connected

Definition at line 222 of file dsdb.c.

References DSDB::armdb.

DSDB* dsdb_new DB_TYPE  db_type  ) 
 

Create New DSDB Structure.

Parameters:
db_type The type of the database to connect to. Currently the the underlying ARMDB library only supports PGSQL_DB.
Returns:
The new DSDB structure or NULL if it could not be created.
See also:
dsdb_connect, dsdb_disconnect, dsdb_free, dsdb_reconnect

Definition at line 142 of file dsdb.c.

References DSDB::armdb, and dsdb_set_error().

int dsdb_reconnect DSDB dsdb  ) 
 

Reconnect To Database.

This function will reconnect to the database using the setings defined by the previous database connection.

Parameters:
dsdb Pointer to the DSDB structure.
Returns:
  • 0 => Failure
  • 1 => Success
See also:
dsdb_disconnect

Definition at line 210 of file dsdb.c.

References DSDB::armdb.

void dsdb_set_error DSDB dsdb,
int  status,
const char *  error
 

Set Function Status and Error Message.

This function can be used to set the status and error message of a DSDB function call.

Parameters:
dsdb Pointer to the DSDB structure.
status The status code.
error The error message.

Definition at line 97 of file dsdb.c.

References DSDB::armdb.

Referenced by dsdb_new().


Generated on Fri Aug 25 13:33:58 2006 for DSDB-C_LIB by doxygen 1.3.5