db_val.c File Reference

#include "db_ut.h"
#include <stdio.h>
#include <time.h>

Include dependency graph for db_val.c:

Go to the source code of this file.

Functions

int db_str2val (const db_type_t _t, db_val_t *_v, const char *_s, const int _l, const unsigned int _cpy)
 Convert a str to a db value.
int db_val2str (const db_con_t *_c, const db_val_t *_v, char *_s, int *_len)
 Convert a numerical value to a string.


Function Documentation

int db_str2val ( const db_type_t  _t,
db_val_t _v,
const char *  _s,
const int  _l,
const unsigned int  _cpy 
)

Convert a str to a db value.

Convert a str to a db value, copy strings if _cpy is not zero. Copying is not necessary if the result from the database client library is freed after the result inside the server is processed. If the result is freed earlier, e.g. because its saved inside some temporary storage, then it must be copied in order to be use it reliable.

Parameters:
_t destination value type
_v destination value
_s source string
_l string length
_cpy when set to zero does not copy strings, otherwise copy strings
Returns:
0 on success, negative on error

Definition at line 45 of file db_val.c.

References DB_BIGINT, DB_BITMAP, DB_BLOB, DB_DATETIME, DB_DOUBLE, DB_INT, DB_STR, db_str2double(), db_str2int(), db_str2longlong(), db_str2time(), DB_STRING, LM_DBG, LM_ERR, NULL, pkg_malloc, s, _str::s, VAL_BIGINT, VAL_BLOB, VAL_DOUBLE, VAL_FREE, VAL_INT, VAL_NULL, VAL_STR, VAL_STRING, VAL_TIME, and VAL_TYPE.

Referenced by db_mysql_convert_row(), db_postgres_str2val(), and db_unixodbc_str2val().

int db_val2str ( const db_con_t _c,
const db_val_t _v,
char *  _s,
int *  _len 
)

Convert a numerical value to a string.

Convert a numerical value to a string, used when converting result from a query. Implement common functionality needed from the databases, does parameter checking.

Parameters:
_c database connection
_v source value
_s target string
_len target string length
Returns:
0 on success, negative on error, 1 if value must be converted by other means

Definition at line 202 of file db_val.c.

References DB_BIGINT, DB_BITMAP, DB_DATETIME, DB_DOUBLE, db_double2str(), DB_INT, db_int2str(), db_longlong2str(), db_time2str(), LM_ERR, snprintf, VAL_BIGINT, VAL_BITMAP, VAL_DOUBLE, VAL_INT, VAL_NULL, VAL_TIME, and VAL_TYPE.

Referenced by db_mysql_val2str(), db_postgres_val2str(), and db_unixodbc_val2str().


Generated on Tue May 22 14:00:35 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6