aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_directed_pickup.c
diff options
context:
space:
mode:
authorseanbright <seanbright@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-09 01:59:59 +0000
committerseanbright <seanbright@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-09 01:59:59 +0000
commit2034723f38d4ae9c8eb29f45c5611e834ff6cfa9 (patch)
tree5e7ff2cd6ece5b2ac5438a59b2737c5705b928cc /apps/app_directed_pickup.c
parent70ff546e20c930fe8c28001a7cef10d8ee569896 (diff)
In order to move away from nested function use, some changes to the recently introduced
ast_channel_search_locked need to be made. Specifically, the caller needs to be able to pass arbitrary data which in turn is passed to the callback. This patch addresses all of the nested functions currently in asterisk trunk. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@155590 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_directed_pickup.c')
-rw-r--r--apps/app_directed_pickup.c47
1 files changed, 31 insertions, 16 deletions
diff --git a/apps/app_directed_pickup.c b/apps/app_directed_pickup.c
index deca8f3de..7fb5f6fea 100644
--- a/apps/app_directed_pickup.c
+++ b/apps/app_directed_pickup.c
@@ -169,17 +169,30 @@ static int pickup_by_channel(struct ast_channel *chan, char *pickup)
return res;
}
+struct pickup_criteria {
+ const char *exten;
+ const char *context;
+};
+
+static int find_by_exten(struct ast_channel *c, void *data)
+{
+ struct pickup_criteria *info = data;
+
+ return (!strcasecmp(c->macroexten, info->exten) || !strcasecmp(c->exten, info->exten)) &&
+ !strcasecmp(c->dialcontext, info->context) &&
+ can_pickup(c);
+}
+
/* Attempt to pick up specified extension with context */
static int pickup_by_exten(struct ast_channel *chan, const char *exten, const char *context)
{
- auto int find_by_exten(struct ast_channel *c);
- int find_by_exten(struct ast_channel *c) {
- return (!strcasecmp(c->macroexten, exten) || !strcasecmp(c->exten, exten)) &&
- !strcasecmp(c->dialcontext, context) &&
- can_pickup(c);
- }
+ struct ast_channel *target = NULL;
+ struct pickup_criteria search = {
+ .exten = exten,
+ .context = context,
+ };
- struct ast_channel *target = ast_channel_search_locked(find_by_exten);
+ target = ast_channel_search_locked(find_by_exten, &search);
if (target) {
int res = pickup_do(chan, target);
@@ -191,18 +204,20 @@ static int pickup_by_exten(struct ast_channel *chan, const char *exten, const ch
return -1;
}
+static int find_by_mark(struct ast_channel *c, void *data)
+{
+ const char *mark = data;
+ const char *tmp;
+
+ return (tmp = pbx_builtin_getvar_helper(c, PICKUPMARK)) &&
+ !strcasecmp(tmp, mark) &&
+ can_pickup(c);
+}
+
/* Attempt to pick up specified mark */
static int pickup_by_mark(struct ast_channel *chan, const char *mark)
{
- auto int find_by_mark(struct ast_channel *);
- int find_by_mark(struct ast_channel *c) {
- const char *tmp;
- return (tmp = pbx_builtin_getvar_helper(c, PICKUPMARK)) &&
- !strcasecmp(tmp, mark) &&
- can_pickup(c);
- }
-
- struct ast_channel *target = ast_channel_search_locked(find_by_mark);
+ struct ast_channel *target = ast_channel_search_locked(find_by_mark, (char *) mark);
if (target) {
int res = pickup_do(chan, target);