aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_config_odbc.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-11-22 18:39:40 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-11-22 18:39:40 +0000
commit64355621602d650748c1eb196e696f2898b99e16 (patch)
tree342ac426b962fac14947a01cbd073139b3c9f1b9 /res/res_config_odbc.c
parent2c475b6f0e258017bc88ca63ee94ca7b03931baa (diff)
Realtime improvements
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@4314 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_config_odbc.c')
-rwxr-xr-xres/res_config_odbc.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/res/res_config_odbc.c b/res/res_config_odbc.c
index 512ed9f8e..e6001ae55 100755
--- a/res/res_config_odbc.c
+++ b/res/res_config_odbc.c
@@ -31,19 +31,6 @@ STANDARD_LOCAL_USER;
LOCAL_USER_DECL;
-static void parseop(char *newp, int newplen, char **opo, const char *newparam)
-{
- char *op;
- strncpy(newp, newparam, newplen - 1);
- op = strchr(newp, ' ');
- if (op) {
- *op = '\0';
- op++;
- } else
- op = "=";
- *opo = op;
-}
-
static struct ast_variable *realtime_odbc(const char *database, const char *table, va_list ap)
{
odbc_obj *obj;
@@ -51,7 +38,6 @@ static struct ast_variable *realtime_odbc(const char *database, const char *tabl
char sql[1024];
char coltitle[256];
char rowdata[2048];
- char newp[256];
char *op;
const char *newparam, *newval;
char *stringp;
@@ -90,15 +76,14 @@ static struct ast_variable *realtime_odbc(const char *database, const char *tabl
return NULL;
}
newval = va_arg(aq, const char *);
- parseop(newp, sizeof(newp), &op, newparam);
- snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s %s ?", table, newp, op);
+ if (!strchr(newparam, ' ')) op = " ="; else op = "";
+ snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s%s ?", table, newparam, op);
while((newparam = va_arg(aq, const char *))) {
- parseop(newp, sizeof(newp), &op, newparam);
- snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " AND %s %s ?", newparam, op);
+ if (!strchr(newparam, ' ')) op = " ="; else op = "";
+ snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " AND %s%s ?", newparam, op);
newval = va_arg(aq, const char *);
}
va_end(aq);
-
res = SQLPrepare(stmt, sql, SQL_NTS);
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
ast_log(LOG_WARNING, "SQL Prepare failed![%s]\n", sql);