79 static DBPool *pool = NULL;
    93 static long sdb_conn_type = SDB_OTHER;
    96 static const char* sdb_get_limit_str()
    98     switch (sdb_conn_type) {
   100             return "AND ROWNUM < 2";
   110 static void dlr_sdb_shutdown()
   116 static int gw_sdb_query(
char *query,
   117                         int (*callback)(
int, 
char **, 
void *), 
void *closure)
   124         error(0, 
"SDB: Database pool got no connection!");
   128     rows = sdb_query(pc->
conn, query, callback, closure);
   135 static void dlr_sdb_add(
struct dlr_entry *dlr)
   140     sql = 
octstr_format(
"INSERT INTO %s (%s, %s, %s, %s, %s, %s, %s, %s, %s) VALUES "   141                         "('%s', '%s', '%s', '%s', '%s', '%s', '%d', '%s', '%d')",
   153 #if defined(DLR_TRACE)   167 static int sdb_callback_add(
int n, 
char **p, 
void *data)
   172         debug(
"dlr.sdb", 0, 
"SDB: Result has incorrect number of columns: %d", n);
   176 #if defined(DLR_TRACE)   177     debug(
"dlr.sdb", 0, 
"row=%s,%s,%s,%s,%s,%s",p[0],p[1],p[2],p[3],p[4],p[5]);
   181         debug(
"dlr.sdb", 0, 
"SDB: Row already stored.");
   185     res->
mask = atoi(p[0]);
   195 static int sdb_callback_msgs(
int n, 
char **p, 
void *data)
   197     long *count = (
long *) data;
   200         debug(
"dlr.sdb", 0, 
"SDB: Result has incorrect number of columns: %d", n);
   204 #if defined(DLR_TRACE)   205     debug(
"dlr.sdb", 0, 
"SDB: messages=%s",p[0]);
   226     sql = 
octstr_format(
"SELECT %S, %S, %S, %S, %S, %S FROM %S WHERE %S='%S' "   230           fields->
field_ts, ts, like, sdb_get_limit_str());
   232 #if defined(DLR_TRACE)   240         error(0, 
"SDB: error in finding DLR");
   243     else if (state == 0) {
   262     debug(
"dlr.sdb", 0, 
"SDB: updating DLR status in database");
   269     sql = 
octstr_format(
"UPDATE %S SET %S=%d WHERE %S='%S' AND %S='%S' %S %s",
   273 #if defined(DLR_TRACE)   281         error(0, 
"SDB: error in updating DLR");
   291     debug(
"dlr.sdb", 0, 
"removing DLR from database");
   292     if (sdb_conn_type == SDB_POSTGRES) {
   305        sql = 
octstr_format(
"DELETE FROM %S WHERE oid = (SELECT oid FROM %S "   306              "WHERE %S='%S' AND %S='%S' %S LIMIT 1", fields->
table,
   315        sql = 
octstr_format(
"DELETE FROM %S WHERE %S='%S' AND %S='%S' %S %s",
   317              like, sdb_get_limit_str());
   320 #if defined(DLR_TRACE)   328         error(0, 
"SDB: error in deleting DLR");
   333 static long dlr_sdb_messages(
void)
   341 #if defined(DLR_TRACE)   348         error(0, 
"SDB: error in selecting ammount of waiting DLRs");
   355 static void dlr_sdb_flush(
void)
   362 #if defined(DLR_TRACE)   369         error(0, 
"SDB: error in flusing DLR table");
   376     .dlr_add = dlr_sdb_add,
   377     .dlr_get = dlr_sdb_get,
   378     .dlr_update = dlr_sdb_update,
   379     .dlr_remove = dlr_sdb_remove,
   380     .dlr_shutdown = dlr_sdb_shutdown,
   381     .dlr_messages = dlr_sdb_messages,
   382     .dlr_flush = dlr_sdb_flush
   399         panic(0, 
"DLR: SDB: group 'dlr-db' is not specified!");
   402         panic(0, 
"DLR: SDB: directive 'id' is not specified!");
   423     panic(0, 
"DLR: SDB: connection settings for id '%s' are not specified!",
   434         panic(0, 
"DLR: SDB: directive 'url' is not specified!");
   437         sdb_conn_type = SDB_ORACLE;
   439         warning(0, 
"DLR[sdb]: Please use native MySQL support, instead of libsdb.");
   440         sdb_conn_type = SDB_MYSQL;
   443         sdb_conn_type = SDB_POSTGRES;
   446         sdb_conn_type = SDB_OTHER;
   453     db_conf = gw_malloc(
sizeof(
DBConf));
   459     db_conf->
sdb->
url = sdb_url;
   468         panic(0,
"DLR: SDB: database pool has no connections!");
 void error(int err, const char *fmt,...)
 
void info(int err, const char *fmt,...)
 
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 octstr_search(const Octstr *haystack, const Octstr *needle, 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)
 
#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)
 
#define octstr_create(cstr)
 
void dbpool_destroy(DBPool *p)
 
struct dlr_storage * dlr_init_sdb(Cfg *cfg)
 
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)
 
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)