#include <time.h>
#include "db_key.h"
#include "db.h"


Go to the source code of this file.
Defines | |
| #define | _XOPEN_SOURCE 600 |
| #define | SQL_BUF_LEN 65536 |
Functions | |
| int | db_double2str (double _v, char *_s, int *_l) |
| int | db_int2str (int _v, char *_s, int *_l) |
| int | db_longlong2str (long long _v, char *_s, int *_l) |
| int | db_print_columns (char *_b, const int _l, const db_key_t *_c, const int _n) |
| int | db_print_set (const db_con_t *_c, char *_b, const int _l, const db_key_t *_k, const db_val_t *_v, const int _n, int(*val2str)(const db_con_t *, const db_val_t *, char *, int *)) |
| int | db_print_values (const db_con_t *_c, char *_b, const int _l, const db_val_t *_v, const int _n, int(*val2str)(const db_con_t *, const db_val_t *, char *, int *)) |
| int | db_print_where (const db_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(*val2str)(const db_con_t *, const db_val_t *, char *, int *)) |
| int | db_str2double (const char *_s, double *_v) |
| int | db_str2int (const char *_s, int *_v) |
| int | db_str2longlong (const char *_s, long long *_v) |
| int | db_str2time (const char *_s, time_t *_v) |
| int | db_time2str (time_t _v, char *_s, int *_l) |
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.h.
| #define _XOPEN_SOURCE 600 |
| #define SQL_BUF_LEN 65536 |
maximal SQL buffer length for database drivers
Definition at line 39 of file db_ut.h.
Referenced by db_do_delete(), db_do_insert(), db_do_query(), db_do_replace(), db_do_update(), and db_insert_update().
| int db_double2str | ( | double | _v, | |
| char * | _s, | |||
| int * | _l | |||
| ) | [inline] |
Converts a double value into a char pointer.
| _v | source value | |
| _s | target value | |
| _l | available length and target length |
Definition at line 151 of file db_ut.c.
References LM_ERR, and snprintf.
Referenced by bdb_val2str(), and db_val2str().
| int db_int2str | ( | int | _v, | |
| char * | _s, | |||
| int * | _l | |||
| ) | [inline] |
Converts a integer value in a char pointer.
| _v | source value | |
| _s | target value | |
| _l | available length and target length |
Definition at line 105 of file db_ut.c.
References LM_ERR, and snprintf.
Referenced by bdb_val2str(), and db_val2str().
| int db_longlong2str | ( | long long | _v, | |
| char * | _s, | |||
| int * | _l | |||
| ) | [inline] |
Converts a long long value in a char pointer.
| _v | source value | |
| _s | target value | |
| _l | available length and target length |
Definition at line 128 of file db_ut.c.
References LM_ERR, and snprintf.
Referenced by db_val2str().
| int db_print_columns | ( | char * | _b, | |
| const int | _l, | |||
| const db_key_t * | _c, | |||
| const int | _n | |||
| ) | [inline] |
Print columns for a SQL statement, separated by commas.
| _b | target char | |
| _l | length of the target | |
| _c | keys that should be printed | |
| _n | number of keys |
Definition at line 237 of file db_ut.c.
References len, LM_ERR, s, and snprintf.
Referenced by db_do_insert(), db_do_query(), db_do_replace(), and db_insert_update().
| int db_print_set | ( | const db_con_t * | _c, | |
| char * | _b, | |||
| const int | _l, | |||
| const db_key_t * | _k, | |||
| const db_val_t * | _v, | |||
| const int | _n, | |||
| int(*)(const db_con_t *, const db_val_t *, char *, int *) | val2str | |||
| ) |
Print set clause for a SQL statement.
| _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 |
Definition at line 341 of file db_ut.c.
References len, LM_ERR, s, and snprintf.
Referenced by db_do_update(), and db_insert_update().
| int db_print_values | ( | const db_con_t * | _c, | |
| char * | _b, | |||
| const int | _l, | |||
| const db_val_t * | _v, | |||
| const int | _n, | |||
| int(*)(const db_con_t *, const db_val_t *, char *, int *) | val2str | |||
| ) |
Print values for a SQL statement.
| _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 |
Definition at line 268 of file db_ut.c.
Referenced by db_do_insert(), db_do_replace(), and db_insert_update().
| int db_print_where | ( | const db_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 db_con_t *, const db_val_t *, char *, int *) | val2str | |||
| ) |
Print where clause for a SQL statement.
| _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 |
Definition at line 297 of file db_ut.c.
References len, LM_ERR, s, and snprintf.
Referenced by db_do_delete(), db_do_query(), and db_do_update().
| int db_str2double | ( | const char * | _s, | |
| double * | _v | |||
| ) | [inline] |
Converts a char into a double value.
| _s | source value | |
| _v | target value |
Definition at line 89 of file db_ut.c.
References LM_ERR.
Referenced by bdb_str2val(), and db_str2val().
| int db_str2int | ( | const char * | _s, | |
| int * | _v | |||
| ) | [inline] |
Converts a char into an integer value.
| _s | source value | |
| _v | target value |
Definition at line 45 of file db_ut.c.
References LM_ERR.
Referenced by bdb_str2val(), and db_str2val().
| int db_str2longlong | ( | const char * | _s, | |
| long long * | _v | |||
| ) | [inline] |
Converts a char into an long long value.
| _s | source value | |
| _v | target value |
Definition at line 66 of file db_ut.c.
References LM_ERR.
Referenced by db_str2val().
| int db_str2time | ( | const char * | _s, | |
| time_t * | _v | |||
| ) | [inline] |
Converts a char into a time_t value.
| _s | source value | |
| _v | target value |
Definition at line 174 of file db_ut.c.
Referenced by bdb_str2val(), and db_str2val().
| int db_time2str | ( | time_t | _v, | |
| char * | _s, | |||
| int * | _l | |||
| ) | [inline] |
Convert a time_t value to string.
| _v | source value | |
| _s | target value | |
| _l | available length and target length |
Definition at line 203 of file db_ut.c.
Referenced by db_val2str(), and get_all_db_ucontacts().
1.5.6