Sat Mar 10 01:55:25 2012

Asterisk developer's documentation


func_dialplan.c File Reference

Dialplan group functions check if a dialplan entry exists. More...

#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/app.h"

Go to the source code of this file.

Functions

static void __reg_module (void)
static void __unreg_module (void)
static int isexten_function_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int load_module (void)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Dialplan Context/Extension/Priority Checking Functions" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "88eaa8f5c1bd988bedd71113385e0886" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
static struct ast_module_infoast_module_info = &__mod_info
static struct ast_custom_function isexten_function


Detailed Description

Dialplan group functions check if a dialplan entry exists.

Author:
Gregory Nietsky AKA irroot <gregory@networksentry.co.za>

Russell Bryant <russell@digium.com>

Definition in file func_dialplan.c.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 125 of file func_dialplan.c.

static void __unreg_module ( void   )  [static]

Definition at line 125 of file func_dialplan.c.

static int isexten_function_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
) [static]

Definition at line 57 of file func_dialplan.c.

References args, AST_APP_ARG, ast_context_find(), AST_DECLARE_APP_ARGS, ast_exists_extension(), ast_findlabel_extension(), ast_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_channel::caller, context, exten, ast_party_caller::id, LOG_ERROR, ast_party_id::number, parse(), S_COR, ast_party_number::str, and ast_party_number::valid.

00059 {
00060    char *parse;
00061    AST_DECLARE_APP_ARGS(args,
00062       AST_APP_ARG(context);
00063       AST_APP_ARG(exten);
00064       AST_APP_ARG(priority);
00065    );
00066 
00067    strcpy(buf, "0");
00068 
00069    if (ast_strlen_zero(data)) {
00070       ast_log(LOG_ERROR, "DIALPLAN_EXISTS() requires an argument\n");
00071       return -1;
00072    }
00073 
00074    parse = ast_strdupa(data);
00075    AST_STANDARD_APP_ARGS(args, parse);
00076 
00077    if (!ast_strlen_zero(args.priority)) {
00078       int priority_num;
00079       if (sscanf(args.priority, "%30d", &priority_num) == 1 && priority_num > 0) {
00080          int res;
00081          res = ast_exists_extension(chan, args.context, args.exten, priority_num, 
00082             S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL));
00083          if (res)
00084             strcpy(buf, "1");
00085       } else {
00086          int res;
00087          res = ast_findlabel_extension(chan, args.context, args.exten, args.priority,
00088             S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL));
00089          if (res > 0)
00090             strcpy(buf, "1");
00091       }
00092    } else if (!ast_strlen_zero(args.exten)) {
00093       int res;
00094       res = ast_exists_extension(chan, args.context, args.exten, 1, 
00095          S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL));
00096       if (res)
00097          strcpy(buf, "1");
00098    } else if (!ast_strlen_zero(args.context)) {
00099       if (ast_context_find(args.context))
00100          strcpy(buf, "1");
00101    } else {
00102       ast_log(LOG_ERROR, "Invalid arguments provided to DIALPLAN_EXISTS\n");
00103       return -1;
00104    }
00105    
00106    return 0;
00107 }

static int load_module ( void   )  [static]

Definition at line 120 of file func_dialplan.c.

References ast_custom_function_register, and isexten_function.

00121 {
00122    return ast_custom_function_register(&isexten_function);
00123 }

static int unload_module ( void   )  [static]

Definition at line 115 of file func_dialplan.c.

References ast_custom_function_unregister(), and isexten_function.

00116 {
00117    return ast_custom_function_unregister(&isexten_function);
00118 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Dialplan Context/Extension/Priority Checking Functions" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "88eaa8f5c1bd988bedd71113385e0886" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } [static]

Definition at line 125 of file func_dialplan.c.

struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 125 of file func_dialplan.c.

struct ast_custom_function isexten_function [static]

Initial value:

 {
   .name = "DIALPLAN_EXISTS",
   .read = isexten_function_read,
   .read_max = 2,
}

Definition at line 109 of file func_dialplan.c.

Referenced by load_module(), and unload_module().


Generated on Sat Mar 10 01:55:25 2012 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7