aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_config_odbc.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-10-07 19:57:50 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-10-07 19:57:50 +0000
commit4b70e1861c45067a12e7e7bbc0016595dedaceae (patch)
tree89532a9b97c1cd3fdab1835ab275faf4b3f79ffc /res/res_config_odbc.c
parent4557e78ccd38f08042dce76cd360d5a6bbf46596 (diff)
Oops, we have to be able to pass multiple restrictions for when we go to voicemail...
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3937 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_config_odbc.c')
-rwxr-xr-xres/res_config_odbc.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/res/res_config_odbc.c b/res/res_config_odbc.c
index 2c16e5135..4ccfd6229 100755
--- a/res/res_config_odbc.c
+++ b/res/res_config_odbc.c
@@ -31,13 +31,14 @@ STANDARD_LOCAL_USER;
LOCAL_USER_DECL;
-static struct ast_variable *realtime_odbc(const char *database, const char *table, const char *keyfield, const char *lookup)
+static struct ast_variable *realtime_odbc(const char *database, const char *table, va_list ap)
{
odbc_obj *obj;
SQLHSTMT stmt;
char sql[256];
char coltitle[256];
char rowdata[2048];
+ const char *newparam, *newval;
char *stringp;
char *chunk;
SQLSMALLINT collen;
@@ -50,6 +51,10 @@ static struct ast_variable *realtime_odbc(const char *database, const char *tabl
SQLSMALLINT datatype;
SQLSMALLINT decimaldigits;
SQLSMALLINT nullable;
+ va_list aq;
+
+ va_copy(aq, ap);
+
if (!table)
return NULL;
@@ -64,7 +69,19 @@ static struct ast_variable *realtime_odbc(const char *database, const char *tabl
return NULL;
}
- snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s=?", table, keyfield);
+ newparam = va_arg(aq, const char *);
+ if (!newparam) {
+ SQLFreeHandle (SQL_HANDLE_STMT, stmt);
+ return NULL;
+ }
+ newval = va_arg(aq, const char *);
+
+ snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s=?", table, newparam);
+ while((newparam = va_arg(aq, const char *))) {
+ snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " AND %s=?", newparam);
+ newval = va_arg(aq, const char *);
+ }
+ va_end(aq);
res = SQLPrepare(stmt, sql, SQL_NTS);
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
@@ -72,8 +89,15 @@ static struct ast_variable *realtime_odbc(const char *database, const char *tabl
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
return NULL;
}
- SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(lookup), 0, (void *)lookup, 0, NULL);
+
+ /* Now bind the parameters */
+ x = 1;
+ while((newparam = va_arg(ap, const char *))) {
+ newval = va_arg(ap, const char *);
+ SQLBindParameter(stmt, x++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(newval), 0, (void *)newval, 0, NULL);
+ }
+
res = SQLExecute(stmt);
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {