mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +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 {
|
} else {
|
||||||
if (option_verbose > 3)
|
if (option_verbose > 3)
|
||||||
ast_verbose(VERBOSE_PREFIX_4"Realtime Lookup: family:'%s' colmatch:'%s' value:'%s'\n",family,colmatch,value);
|
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) {
|
for (itt = var; itt; itt = itt->next) {
|
||||||
if(prefix) {
|
if(prefix) {
|
||||||
len = strlen(prefix) + strlen(itt->name) + 2;
|
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;
|
struct iax2_peer *peer=NULL;
|
||||||
time_t regseconds, nowtime;
|
time_t regseconds, nowtime;
|
||||||
int dynamic=0;
|
int dynamic=0;
|
||||||
var = ast_load_realtime("iaxfriends", "name", peername);
|
var = ast_load_realtime("iaxfriends", "name", peername, NULL);
|
||||||
if (var) {
|
if (var) {
|
||||||
/* Make sure it's not a user only... */
|
/* Make sure it's not a user only... */
|
||||||
peer = build_peer(peername, var);
|
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 *var;
|
||||||
struct ast_variable *tmp;
|
struct ast_variable *tmp;
|
||||||
struct iax2_user *user=NULL;
|
struct iax2_user *user=NULL;
|
||||||
var = ast_load_realtime("iaxfriends", "name", username);
|
var = ast_load_realtime("iaxfriends", "name", username, NULL);
|
||||||
if (var) {
|
if (var) {
|
||||||
/* Make sure it's not a user only... */
|
/* Make sure it's not a user only... */
|
||||||
user = build_user(username, var);
|
user = build_user(username, var);
|
||||||
|
@@ -1055,9 +1055,9 @@ static struct sip_peer *realtime_peer(const char *peername, struct sockaddr_in *
|
|||||||
if (sin)
|
if (sin)
|
||||||
ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr);
|
ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr);
|
||||||
if (peername)
|
if (peername)
|
||||||
var = ast_load_realtime("sipfriends", "name", peername);
|
var = ast_load_realtime("sipfriends", "name", peername, NULL);
|
||||||
else
|
else
|
||||||
var = ast_load_realtime("sipfriends", "ipaddr", iabuf);
|
var = ast_load_realtime("sipfriends", "ipaddr", iabuf, NULL);
|
||||||
if (var) {
|
if (var) {
|
||||||
/* Make sure it's not a user only... */
|
/* Make sure it's not a user only... */
|
||||||
peer = build_peer(peername, var);
|
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 *var;
|
||||||
struct ast_variable *tmp;
|
struct ast_variable *tmp;
|
||||||
struct sip_user *user=NULL;
|
struct sip_user *user=NULL;
|
||||||
var = ast_load_realtime("sipfriends", "name", username);
|
var = ast_load_realtime("sipfriends", "name", username, NULL);
|
||||||
if (var) {
|
if (var) {
|
||||||
/* Make sure it's not a user only... */
|
/* Make sure it's not a user only... */
|
||||||
user = build_user(username, var);
|
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;
|
struct ast_config_reg *reg;
|
||||||
char db[256]="";
|
char db[256]="";
|
||||||
char table[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));
|
reg = get_ast_cust_config_keyword(family, db, sizeof(db), table, sizeof(table));
|
||||||
if (reg && reg->realtime_func)
|
if (reg && reg->realtime_func)
|
||||||
return reg->realtime_func(db, table, keyfield, lookup);
|
res = reg->realtime_func(db, table, ap);
|
||||||
return NULL;
|
va_end(ap);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ast_update_realtime(const char *family, const char *keyfield, const char *lookup, ...)
|
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
|
* that unlike the variables in ast_config, the resulting list of variables
|
||||||
* MUST be fred with ast_free_runtime() as there is no container.
|
* 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
|
//! Update realtime configuration
|
||||||
/*!
|
/*!
|
||||||
|
@@ -30,7 +30,7 @@ struct ast_category;
|
|||||||
struct ast_config_reg {
|
struct ast_config_reg {
|
||||||
char name[CONFIG_KEYWORD_STRLEN];
|
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_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);
|
int (*update_func)(const char *database, const char *table, const char *keyfield, const char *entity, va_list ap);
|
||||||
struct ast_config_reg *next;
|
struct ast_config_reg *next;
|
||||||
};
|
};
|
||||||
|
@@ -31,13 +31,14 @@ STANDARD_LOCAL_USER;
|
|||||||
|
|
||||||
LOCAL_USER_DECL;
|
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;
|
odbc_obj *obj;
|
||||||
SQLHSTMT stmt;
|
SQLHSTMT stmt;
|
||||||
char sql[256];
|
char sql[256];
|
||||||
char coltitle[256];
|
char coltitle[256];
|
||||||
char rowdata[2048];
|
char rowdata[2048];
|
||||||
|
const char *newparam, *newval;
|
||||||
char *stringp;
|
char *stringp;
|
||||||
char *chunk;
|
char *chunk;
|
||||||
SQLSMALLINT collen;
|
SQLSMALLINT collen;
|
||||||
@@ -50,6 +51,10 @@ static struct ast_variable *realtime_odbc(const char *database, const char *tabl
|
|||||||
SQLSMALLINT datatype;
|
SQLSMALLINT datatype;
|
||||||
SQLSMALLINT decimaldigits;
|
SQLSMALLINT decimaldigits;
|
||||||
SQLSMALLINT nullable;
|
SQLSMALLINT nullable;
|
||||||
|
va_list aq;
|
||||||
|
|
||||||
|
va_copy(aq, ap);
|
||||||
|
|
||||||
|
|
||||||
if (!table)
|
if (!table)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -64,7 +69,19 @@ static struct ast_variable *realtime_odbc(const char *database, const char *tabl
|
|||||||
return NULL;
|
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);
|
res = SQLPrepare(stmt, sql, SQL_NTS);
|
||||||
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
|
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
|
||||||
@@ -72,7 +89,14 @@ static struct ast_variable *realtime_odbc(const char *database, const char *tabl
|
|||||||
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
|
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
|
||||||
return NULL;
|
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);
|
res = SQLExecute(stmt);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user