79 static DBPool *pool = NULL;
    87 static inline int pgsql_update(
const Octstr *sql)
    92 #if defined(DLR_TRACE)    98         error(0, 
"PGSQL: Database pool got no connection! DB update failed!");
   103         error(0, 
"PGSQL: DB update failed!");
   110 static inline List *pgsql_select(
const Octstr *sql)
   115 #if defined(DLR_TRACE)   121         error(0, 
"PGSQL: Database pool got no connection! DB operation failed!");
   126         error(0, 
"PGSQL: Select failed!");
   133 static void dlr_pgsql_shutdown()
   140 static void dlr_pgsql_add(
struct dlr_entry *entry)
   144     sql = 
octstr_format(
"INSERT INTO \"%s\" (\"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\") VALUES "   145                         "('%s', '%s', '%s', '%s', '%s', '%s', '%d', '%s', '%d');",
   157     if (!pgsql_update(sql))
   176     sql = 
octstr_format(
"SELECT \"%S\", \"%S\", \"%S\", \"%S\", \"%S\", "   177           "\"%S\" FROM \"%S\" WHERE \"%S\"='%S' AND \"%S\"='%S' %S LIMIT 1;",
   182     result = pgsql_select(sql);
   186     if (result == NULL || 
gwlist_len(result) < 1) {
   187         debug(
"dlr.pgsql", 0, 
"no rows found");
   194     debug(
"dlr.pgsql", 0, 
"Found entry, col1=%s, col2=%s, col3=%s, col4=%s, col5=%s col6=%s",
   225     debug(
"dlr.pgsql", 0, 
"removing DLR from database");
   231     sql = 
octstr_format(
"DELETE FROM \"%S\" WHERE oid = (SELECT oid FROM "   232           "\"%S\" WHERE \"%S\"='%S' AND \"%S\"='%S' %S LIMIT 1);",
   236     if (!pgsql_update(sql))
   247     debug(
"dlr.pgsql", 0, 
"updating DLR status in database");
   253     sql = 
octstr_format(
"UPDATE \"%S\" SET \"%S\"=%d WHERE oid = (SELECT "   254         "oid FROM \"%S\" WHERE \"%S\"='%S' AND \"%S\"='%S' %S LIMIT 1);",
   258     if (!pgsql_update(sql))
   265 static long dlr_pgsql_messages(
void)
   273     res = pgsql_select(sql);
   277         error(0, 
"PGSQL: Could not get count of DLR table");
   290 static void dlr_pgsql_flush(
void)
   303     .dlr_add = dlr_pgsql_add,
   304     .dlr_get = dlr_pgsql_get,
   305     .dlr_update = dlr_pgsql_update,
   306     .dlr_remove = dlr_pgsql_remove,
   307     .dlr_shutdown = dlr_pgsql_shutdown,
   308     .dlr_messages = dlr_pgsql_messages,
   309     .dlr_flush = dlr_pgsql_flush
   317     Octstr *pgsql_host, *pgsql_user, *pgsql_pass, *pgsql_db, *pgsql_id;
   328         panic(0, 
"DLR: PgSQL: group 'dlr-db' is not specified!");
   331         panic(0, 
"DLR: PgSQL: directive 'id' is not specified!");
   367     panic(0, 
"DLR: PgSQL: connection settings for id '%s' are not specified!",
   378         panic(0, 
"DLR: PgSQL: directive 'host' is not specified!");
   380         panic(0, 
"DLR: PgSQL: directive 'username' is not specified!");
   382         panic(0, 
"DLR: PgSQL: directive 'password' is not specified!");
   384         panic(0, 
"DLR: PgSQL: directive 'database' is not specified!");
   390     db_conf = gw_malloc(
sizeof(
DBConf));
   409         panic(0,
"DLR: PgSQL: database pool has no connections!");
 void error(int err, const char *fmt,...)
 
void octstr_replace(Octstr *haystack, Octstr *needle, Octstr *repl)
 
long dbpool_conn_count(DBPool *p)
 
DBPool * dbpool_create(enum db_type db_type, DBConf *conf, unsigned int connections)
 
gw_assert(wtls_machine->packet_to_send !=NULL)
 
void dlr_db_fields_destroy(struct dlr_db_fields *fields)
 
struct dlr_entry * dlr_entry_create(void)
 
long gwlist_len(List *list)
 
void * gwlist_get(List *list, long pos)
 
#define cfg_get(grp, varname)
 
#define octstr_get_cstr(ostr)
 
static struct pid_list * found
 
void dbpool_conn_produce(DBPoolConn *conn)
 
static struct dlr_storage * handles
 
Octstr * octstr_imm(const char *cstr)
 
void * gwlist_extract_first(List *list)
 
struct dlr_storage * dlr_init_pgsql(Cfg *cfg)
 
#define octstr_duplicate(ostr)
 
List * cfg_get_multi_group(Cfg *cfg, Octstr *name)
 
void warning(int err, const char *fmt,...)
 
Octstr * octstr_format(const char *fmt,...)
 
void octstr_destroy(Octstr *ostr)
 
void octstr_destroy_item(void *os)
 
void dbpool_destroy(DBPool *p)
 
int dbpool_conn_update(DBPoolConn *conn, const Octstr *sql, List *binds)
 
void dlr_entry_destroy(struct dlr_entry *dlr)
 
void debug(const char *place, int err, const char *fmt,...)
 
int cfg_get_integer(long *n, CfgGroup *grp, Octstr *varname)
 
int dbpool_conn_select(DBPoolConn *conn, const Octstr *sql, List *binds, List **result)
 
DBPoolConn * dbpool_conn_consume(DBPool *p)
 
CfgGroup * cfg_get_single_group(Cfg *cfg, Octstr *name)
 
struct dlr_db_fields * dlr_db_fields_create(CfgGroup *grp)
 
int octstr_compare(const Octstr *ostr1, const Octstr *ostr2)
 
void gwlist_destroy(List *list, gwlist_item_destructor_t *destructor)