mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
Oops, we have to be able to pass multiple restrictions for when we go to voicemail...
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3937 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -109,7 +109,7 @@ static int realtime_exec(struct ast_channel *chan, void *data)
|
||||
} else {
|
||||
if (option_verbose > 3)
|
||||
ast_verbose(VERBOSE_PREFIX_4"Realtime Lookup: family:'%s' colmatch:'%s' value:'%s'\n",family,colmatch,value);
|
||||
if ((var = ast_load_realtime(family, colmatch, value))) {
|
||||
if ((var = ast_load_realtime(family, colmatch, value, NULL))) {
|
||||
for (itt = var; itt; itt = itt->next) {
|
||||
if(prefix) {
|
||||
len = strlen(prefix) + strlen(itt->name) + 2;
|
||||
|
@@ -1992,7 +1992,7 @@ static struct iax2_peer *realtime_peer(const char *peername)
|
||||
struct iax2_peer *peer=NULL;
|
||||
time_t regseconds, nowtime;
|
||||
int dynamic=0;
|
||||
var = ast_load_realtime("iaxfriends", "name", peername);
|
||||
var = ast_load_realtime("iaxfriends", "name", peername, NULL);
|
||||
if (var) {
|
||||
/* Make sure it's not a user only... */
|
||||
peer = build_peer(peername, var);
|
||||
@@ -2041,7 +2041,7 @@ static struct iax2_user *realtime_user(const char *username)
|
||||
struct ast_variable *var;
|
||||
struct ast_variable *tmp;
|
||||
struct iax2_user *user=NULL;
|
||||
var = ast_load_realtime("iaxfriends", "name", username);
|
||||
var = ast_load_realtime("iaxfriends", "name", username, NULL);
|
||||
if (var) {
|
||||
/* Make sure it's not a user only... */
|
||||
user = build_user(username, var);
|
||||
|
@@ -1055,9 +1055,9 @@ static struct sip_peer *realtime_peer(const char *peername, struct sockaddr_in *
|
||||
if (sin)
|
||||
ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr);
|
||||
if (peername)
|
||||
var = ast_load_realtime("sipfriends", "name", peername);
|
||||
var = ast_load_realtime("sipfriends", "name", peername, NULL);
|
||||
else
|
||||
var = ast_load_realtime("sipfriends", "ipaddr", iabuf);
|
||||
var = ast_load_realtime("sipfriends", "ipaddr", iabuf, NULL);
|
||||
if (var) {
|
||||
/* Make sure it's not a user only... */
|
||||
peer = build_peer(peername, var);
|
||||
@@ -1147,7 +1147,7 @@ static struct sip_user *realtime_user(const char *username)
|
||||
struct ast_variable *var;
|
||||
struct ast_variable *tmp;
|
||||
struct sip_user *user=NULL;
|
||||
var = ast_load_realtime("sipfriends", "name", username);
|
||||
var = ast_load_realtime("sipfriends", "name", username, NULL);
|
||||
if (var) {
|
||||
/* Make sure it's not a user only... */
|
||||
user = build_user(username, var);
|
||||
|
10
config.c
10
config.c
@@ -416,15 +416,19 @@ int ast_save(char *configfile, struct ast_config *cfg, char *generator)
|
||||
}
|
||||
|
||||
|
||||
struct ast_variable *ast_load_realtime(const char *family, const char *keyfield, const char *lookup)
|
||||
struct ast_variable *ast_load_realtime(const char *family, ...)
|
||||
{
|
||||
struct ast_config_reg *reg;
|
||||
char db[256]="";
|
||||
char table[256]="";
|
||||
struct ast_variable *res=NULL;
|
||||
va_list ap;
|
||||
va_start(ap, family);
|
||||
reg = get_ast_cust_config_keyword(family, db, sizeof(db), table, sizeof(table));
|
||||
if (reg && reg->realtime_func)
|
||||
return reg->realtime_func(db, table, keyfield, lookup);
|
||||
return NULL;
|
||||
res = reg->realtime_func(db, table, ap);
|
||||
va_end(ap);
|
||||
return res;
|
||||
}
|
||||
|
||||
int ast_update_realtime(const char *family, const char *keyfield, const char *lookup, ...)
|
||||
|
@@ -114,7 +114,7 @@ int ast_category_exist(struct ast_config *config, char *category_name);
|
||||
* that unlike the variables in ast_config, the resulting list of variables
|
||||
* MUST be fred with ast_free_runtime() as there is no container.
|
||||
*/
|
||||
struct ast_variable *ast_load_realtime(const char *family, const char *keyfield, const char *lookup);
|
||||
struct ast_variable *ast_load_realtime(const char *family, ...);
|
||||
|
||||
//! Update realtime configuration
|
||||
/*!
|
||||
|
@@ -30,7 +30,7 @@ struct ast_category;
|
||||
struct ast_config_reg {
|
||||
char name[CONFIG_KEYWORD_STRLEN];
|
||||
struct ast_config *(*static_func)(const char *database, const char *table, const char *, struct ast_config *,struct ast_category **,struct ast_variable **,int);
|
||||
struct ast_variable *(*realtime_func)(const char *database, const char *table, const char *keyfield, const char *entity);
|
||||
struct ast_variable *(*realtime_func)(const char *database, const char *table, va_list ap);
|
||||
int (*update_func)(const char *database, const char *table, const char *keyfield, const char *entity, va_list ap);
|
||||
struct ast_config_reg *next;
|
||||
};
|
||||
|
@@ -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)) {
|
||||
|
Reference in New Issue
Block a user