start cleanup indentation etc.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@26655 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Luigi Rizzo
2006-05-10 21:12:55 +00:00
parent 466407e814
commit b09dd8708b

View File

@@ -76,34 +76,27 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
*/ */
#define REALTIME_COMMON(mode) \ #define REALTIME_COMMON(mode) \
char *buf; \ const char *ctx = NULL; \
char *opts; \ char *table; \
const char *cxt; \ int res = -1; \
char *table; \ struct ast_variable *var=NULL; \
int res=-1; \ char *buf = ast_strdupa(data); \
struct ast_variable *var=NULL; \ if (buf) { \
buf = ast_strdupa(data); \ char *opts = strchr(buf, '/'); \
if (buf) { \ if (opts) \
opts = strchr(buf, '/'); \ *opts++ = '\0'; \
if (opts) { \ else \
*opts='\0'; \ opts=""; \
opts++; \ table = strchr(buf, '@'); \
} else \ if (table) { \
opts=""; \ *table++ = '\0'; \
table = strchr(buf, '@'); \ ctx = buf; \
if (table) { \ } \
*table = '\0'; \ ctx = S_OR(ctx, context); \
table++;\ table = S_OR(table, "extensions"); \
cxt = buf; \ var = realtime_switch_common(table, ctx, exten, priority, mode); \
} else cxt = NULL; \ }
if (ast_strlen_zero(cxt)) \
cxt = context;\
if (ast_strlen_zero(table)) \
table = "extensions"; \
var = realtime_switch_common(table, cxt, exten, priority, mode); \
} else \
res = -1;
static struct ast_variable *realtime_switch_common(const char *table, const char *context, const char *exten, int priority, int mode) static struct ast_variable *realtime_switch_common(const char *table, const char *context, const char *exten, int priority, int mode)
{ {
@@ -161,7 +154,8 @@ static struct ast_variable *realtime_switch_common(const char *table, const char
static int realtime_exists(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data) static int realtime_exists(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
{ {
REALTIME_COMMON(MODE_MATCH); REALTIME_COMMON(MODE_MATCH);
if (var) ast_variables_destroy(var); if (var)
ast_variables_destroy(var);
if (var) if (var)
res = 1; res = 1;
return res > 0 ? res : 0; return res > 0 ? res : 0;
@@ -170,7 +164,8 @@ static int realtime_exists(struct ast_channel *chan, const char *context, const
static int realtime_canmatch(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data) static int realtime_canmatch(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data)
{ {
REALTIME_COMMON(MODE_CANMATCH); REALTIME_COMMON(MODE_CANMATCH);
if (var) ast_variables_destroy(var); if (var)
ast_variables_destroy(var);
if (var) if (var)
res = 1; res = 1;
return res > 0 ? res : 0; return res > 0 ? res : 0;
@@ -188,13 +183,11 @@ static int realtime_exec(struct ast_channel *chan, const char *context, const ch
struct ast_variable *v; struct ast_variable *v;
REALTIME_COMMON(MODE_MATCH); REALTIME_COMMON(MODE_MATCH);
if (var) { if (var) {
v = var; for (v = var; v ; v = v->next) {
while(v) {
if (!strcasecmp(v->name, "app")) if (!strcasecmp(v->name, "app"))
strncpy(app, v->value, sizeof(app) -1 ); strncpy(app, v->value, sizeof(app) -1 );
else if (!strcasecmp(v->name, "appdata")) else if (!strcasecmp(v->name, "appdata"))
tmp = ast_strdupa(v->value); tmp = ast_strdupa(v->value);
v = v->next;
} }
ast_variables_destroy(var); ast_variables_destroy(var);
if (!ast_strlen_zero(app)) { if (!ast_strlen_zero(app)) {