Defines | Functions

db_ut.c File Reference

Utility functions for database drivers. More...

#include <time.h>
#include <limits.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../../mem/mem.h"
#include "../../dprint.h"
#include "db_ut.h"
Include dependency graph for db_ut.c:

Go to the source code of this file.

Defines

Functions


Detailed Description

This utility methods are used from the database SQL driver to convert values and print SQL queries from the internal API representation.

Definition in file db_ut.c.


Function Documentation

int db_double2str ( double  _v,
char *  _s,
int *  _l 
) [inline]
Parameters:
_v source value
_s target value
_l available length and target length
Returns:
zero on sucess, negative on conversion errors

Definition at line 179 of file db_ut.c.

Referenced by db_val2str().

Here is the caller graph for this function:

int db_int2str ( int  _v,
char *  _s,
int *  _l 
) [inline]
Parameters:
_v source value
_s target value
_l available length and target length
Returns:
zero on sucess, negative on conversion errors

Definition at line 133 of file db_ut.c.

Referenced by db_val2str().

Here is the caller graph for this function:

int db_longlong2str ( long long  _v,
char *  _s,
int *  _l 
) [inline]
Parameters:
_v source value
_s target value
_l available length and target length
Returns:
zero on sucess, negative on conversion errors

Definition at line 156 of file db_ut.c.

Referenced by db_val2pv_spec(), and db_val2str().

Here is the caller graph for this function:

int db_print_columns ( char *  _b,
const int  _l,
const db_key_t _c,
const int  _n 
) [inline]
Parameters:
_b target char
_l length of the target
_c keys that should be printed
_n number of keys
Returns:
the length of the printed result on success, negative on errors

Definition at line 265 of file db_ut.c.

Referenced by db_do_replace(), and db_mysql_insert_update().

Here is the caller graph for this function:

int db_print_set ( const db1_con_t _c,
char *  _b,
const int  _l,
const db_key_t _k,
const db_val_t _v,
const int  _n,
int(*)(const db1_con_t *, const db_val_t *, char *, int *)  val2str 
)
Parameters:
_c structure representing database connection
_b target char
_l length of the target
_k keys that should be printed
_v vals that should be printed
_n number of key/value pairs
(*val2str) function pointer to a db specific conversion function
Returns:
the length of the printed result on success, negative on errors

Definition at line 383 of file db_ut.c.

Referenced by db_do_update(), and db_mysql_insert_update().

Here is the caller graph for this function:

int db_print_values ( const db1_con_t _c,
char *  _b,
const int  _l,
const db_val_t _v,
const int  _n,
int(*)(const db1_con_t *, const db_val_t *, char *, int *)  val2str 
)
Parameters:
_c structure representing database connection
_b target char
_l length of the target
_v values that should be printed
_n number of values
(*val2str) function pointer to a db specific conversion function
Returns:
the length of the printed result on success, negative on errors

Definition at line 296 of file db_ut.c.

Referenced by db_do_replace(), and db_mysql_insert_update().

Here is the caller graph for this function:

int db_print_where ( const db1_con_t _c,
char *  _b,
const int  _l,
const db_key_t _k,
const db_op_t _o,
const db_val_t _v,
const int  _n,
int(*)(const db1_con_t *, const db_val_t *, char *, int *)  val2str 
)
Parameters:
_c structure representing database connection
_b target char
_l length of the target
_k keys that should be printed
_o optional operators
_v values that should be printed
_n number of key/value pairs
(*val2str) function pointer to a db specific conversion function
Returns:
the length of the printed result on success, negative on errors

Definition at line 325 of file db_ut.c.

References OP_BITWISE_AND.

Referenced by db_do_delete(), and db_do_update().

Here is the caller graph for this function:

int db_str2double ( const char *  _s,
double *  _v 
) [inline]
Parameters:
_s source value
_v target value
Returns:
zero on sucess, negative on conversion errors

Definition at line 117 of file db_ut.c.

Referenced by bdb_str2val(), and db_str2val().

Here is the caller graph for this function:

int db_str2int ( const char *  _s,
int *  _v 
) [inline]
Parameters:
_s source value
_v target value
Returns:
zero on sucess, negative on conversion errors

Definition at line 73 of file db_ut.c.

Referenced by bdb_str2val(), and db_str2val().

Here is the caller graph for this function:

int db_str2longlong ( const char *  _s,
long long *  _v 
) [inline]
Parameters:
_s source value
_v target value
Returns:
zero on sucess, negative on conversion errors

Definition at line 94 of file db_ut.c.

Referenced by db_str2val().

Here is the caller graph for this function:

int db_str2time ( const char *  _s,
time_t *  _v 
) [inline]
Parameters:
_s source value
_v target value
Returns:
zero on sucess, negative on conversion errors

Definition at line 202 of file db_ut.c.

Referenced by bdb_str2val(), and db_str2val().

Here is the caller graph for this function:

int db_time2str ( time_t  _v,
char *  _s,
int *  _l 
) [inline]
Parameters:
_v source value
_s target value
_l available length and target length
Returns:
zero on sucess, negative on conversion errors
Todo:
This functions add quotes to the time value. This should be done in the val2str function, as some databases like db_berkeley don't need or like this at all.

Definition at line 231 of file db_ut.c.

Referenced by db_val2str(), and get_all_db_ucontacts().

Here is the caller graph for this function:

int db_val2pv_spec ( struct sip_msg msg,
db_val_t dbval,
pv_spec_t *  pvs 
)
Parameters:
msg sip msg structure
dbval database value
pvs pv_spec where to put the database value
Returns:
0 on success, -1 on failure

Definition at line 421 of file db_ut.c.

References db_val_t::bitmap_val, db_val_t::blob_val, DB1_BIGINT, DB1_BITMAP, DB1_BLOB, DB1_DATETIME, DB1_INT, DB1_STR, DB1_STRING, db_longlong2str(), db_val_t::int_val, _str::len, db_val_t::ll_val, db_val_t::nul, _str::s, db_val_t::str_val, db_val_t::string_val, db_val_t::time_val, db_val_t::type, and db_val_t::val.

Here is the call graph for this function: