7 #define sql_update dbpool_conn_update 8 #define sql_select dbpool_conn_select 10 static Octstr *sqlbox_logtable;
11 static Octstr *sqlbox_insert_table;
17 static DBPool *pool = NULL;
19 void sqlbox_configure_oracle(
Cfg*
cfg)
26 panic(0,
"SQLBOX: Oracle: group 'sqlbox' is not specified!");
29 if (sqlbox_logtable == NULL) {
30 panic(0,
"Parameter 'sql-log-table' not configured.");
33 if (sqlbox_insert_table == NULL) {
34 panic(0,
"Parameter 'sql-insert-table' not configured.");
39 error(0,
"Oracle: DBPool Error!");
44 sql =
octstr_format(SQLBOX_ORACLE_CREATE_LOG_TABLE, sqlbox_logtable, sqlbox_logtable);
45 #if defined(SQLBOX_TRACE) 48 sql_update(pc, sql, NULL);
51 sql =
octstr_format(SQLBOX_ORACLE_CREATE_INSERT_TABLE, sqlbox_insert_table, sqlbox_insert_table);
52 #if defined(SQLBOX_TRACE) 55 sql_update(pc, sql, NULL);
60 sql =
octstr_format(SQLBOX_ORACLE_CREATE_LOG_SEQUENCE, sqlbox_logtable);
61 #if defined(SQLBOX_TRACE) 64 sql_update(pc, sql, NULL);
67 sql =
octstr_format(SQLBOX_ORACLE_CREATE_INSERT_SEQUENCE, sqlbox_insert_table);
68 #if defined(SQLBOX_TRACE) 71 sql_update(pc, sql, NULL);
74 sql =
octstr_format(SQLBOX_ORACLE_CREATE_LOG_TRIGGER, sqlbox_logtable, sqlbox_logtable, sqlbox_logtable);
75 #if defined(SQLBOX_TRACE) 78 sql_update(pc, sql, NULL);
81 sql =
octstr_format(SQLBOX_ORACLE_CREATE_INSERT_TRIGGER, sqlbox_insert_table, sqlbox_insert_table, sqlbox_insert_table);
82 #if defined(SQLBOX_TRACE) 85 sql_update(pc, sql, NULL);
93 #define octstr_null_create(x) ((x != NULL) ? octstr_create(x) : octstr_create("")) 94 #define atol_null(x) ((x != NULL) ? atol(x) : -1) 95 #define get_oracle_octstr_col(x) (octstr_create(octstr_get_cstr(gwlist_get(row,x)))) 96 #define get_oracle_long_col(x) (atol(octstr_get_cstr(gwlist_get(row,x)))) 97 Msg *oracle_fetch_msg()
107 error(0,
"Oracle: DBPool error!");
111 sql =
octstr_format(SQLBOX_ORACLE_SELECT_QUERY, sqlbox_insert_table);
112 #if defined(SQLBOX_TRACE) 115 if (sql_select(pc, sql, NULL, &res) != 0) {
120 id = get_oracle_octstr_col(0);
124 msg->sms.foreign_id = get_oracle_octstr_col(0);
125 msg->sms.sender = get_oracle_octstr_col(2);
126 msg->sms.receiver = get_oracle_octstr_col(3);
127 msg->sms.udhdata = get_oracle_octstr_col(4);
128 msg->sms.msgdata = get_oracle_octstr_col(5);
129 msg->sms.time = get_oracle_long_col(6);
130 msg->sms.smsc_id = get_oracle_octstr_col(7);
131 msg->sms.service = get_oracle_octstr_col(8);
132 msg->sms.account = get_oracle_octstr_col(9);
134 msg->sms.sms_type = get_oracle_long_col(11);
135 msg->sms.mclass = get_oracle_long_col(12);
136 msg->sms.mwi = get_oracle_long_col(13);
137 msg->sms.coding = get_oracle_long_col(14);
138 msg->sms.compress = get_oracle_long_col(15);
139 msg->sms.validity = get_oracle_long_col(16);
140 msg->sms.deferred = get_oracle_long_col(17);
141 msg->sms.dlr_mask = get_oracle_long_col(18);
142 msg->sms.dlr_url = get_oracle_octstr_col(19);
143 msg->sms.pid = get_oracle_long_col(20);
144 msg->sms.alt_dcs = get_oracle_long_col(21);
145 msg->sms.rpi = get_oracle_long_col(22);
146 msg->sms.charset = get_oracle_octstr_col(23);
147 msg->sms.binfo = get_oracle_octstr_col(25);
148 msg->sms.binfo = get_oracle_octstr_col(26);
153 msg->sms.boxc_id= get_oracle_octstr_col(24);
156 delet =
octstr_format(SQLBOX_ORACLE_DELETE_QUERY, sqlbox_insert_table);
159 #if defined(SQLBOX_TRACE) 162 sql_update(pc, delet, binds);
175 static Octstr *get_numeric_value_or_return_null(
long int num)
180 static Octstr *get_string_value_or_return_null(
Octstr *str)
185 #define st_num(x) (stuffer[stuffcount++] = get_numeric_value_or_return_null(x)) 186 #define st_str(x) (stuffer[stuffcount++] = get_string_value_or_return_null(x)) 197 error(0,
"Oracle: DBPool Error!");
201 sql =
octstr_format(SQLBOX_ORACLE_INSERT_QUERY, sqlbox_logtable);
229 #if defined(SQLBOX_TRACE) 232 sql_update(pc, sql, binds);
233 while (stuffcount > 0) {
250 Octstr *oracle_user, *oracle_pass, *oracle_tnsname, *oracle_id;
261 panic(0,
"SQLBOX: Oracle: group 'sqlbox' is not specified!");
264 panic(0,
"SQLBOX: Oracle: directive 'id' is not specified!");
282 panic(0,
"SQLBOX: Oracle: connection settings for id '%s' are not specified!",
293 panic(0,
"SQLBOX: Oracle: directive 'username' is not specified!");
295 panic(0,
"SQLBOX: Oracle: directive 'password' is not specified!");
297 panic(0,
"SQLBOX: Oracle: directive 'tnsname' is not specified!");
302 db_conf = gw_malloc(
sizeof(
DBConf));
319 panic(0,
"SQLBOX: Oracle: database pool has no connections!");
327 res->
sql_enter = sqlbox_configure_oracle;
void error(int err, const char *fmt,...)
int(* sql_fetch_msg_list)(List *, long)
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 gwlist_append(List *list, void *item)
long gwlist_len(List *list)
void * gwlist_get(List *list, long pos)
#define cfg_get(grp, varname)
void(* sql_save_list)(List *, Octstr *, int)
#define octstr_get_cstr(ostr)
static struct pid_list * found
void dbpool_conn_produce(DBPoolConn *conn)
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)
Octstr * octstr_format(const char *fmt,...)
void octstr_destroy(Octstr *ostr)
#define octstr_create(cstr)
void octstr_destroy_item(void *os)
void dbpool_destroy(DBPool *p)
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)
static XMLRPCDocument * msg
void(* sql_save_msg)(Msg *, Octstr *)
int octstr_compare(const Octstr *ostr1, const Octstr *ostr2)
void gwlist_destroy(List *list, gwlist_item_destructor_t *destructor)