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"

Include dependency graph for func_dialplan.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
static void __unreg_module (void)
static int acf_isexten_exec (struct ast_channel *chan, const char *cmd, char *parse, char *buffer, size_t buflen)
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 = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND, }
static struct ast_custom_function acf_isexten
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 201 of file func_dialplan.c.

static void __unreg_module ( void   )  [static]

Definition at line 201 of file func_dialplan.c.

static int acf_isexten_exec ( struct ast_channel chan,
const char *  cmd,
char *  parse,
char *  buffer,
size_t  buflen 
) [static]

Definition at line 130 of file func_dialplan.c.

References args, AST_APP_ARG, ast_channel_caller(), ast_channel_context(), ast_copy_string(), AST_DECLARE_APP_ARGS, ast_exists_extension(), ast_log, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero, context, LOG_WARNING, NULL, and S_COR.

00131 {
00132    int priority_int;
00133    AST_DECLARE_APP_ARGS(args,
00134       AST_APP_ARG(context);
00135       AST_APP_ARG(extension);
00136       AST_APP_ARG(priority);
00137    );
00138 
00139    if (!chan) {
00140       ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
00141       return -1;
00142    }
00143 
00144    AST_STANDARD_APP_ARGS(args, parse);
00145 
00146    if (ast_strlen_zero(args.context)) {
00147       args.context = ast_strdupa(ast_channel_context(chan));
00148    }
00149 
00150    if (ast_strlen_zero(args.extension)) {
00151       ast_log(LOG_WARNING, "Syntax: VALID_EXTEN([<context>],<extension>[,<priority>]) - missing argument <extension>!\n");
00152       return -1;
00153    }
00154 
00155    if (ast_strlen_zero(args.priority)) {
00156       priority_int = 1;
00157    } else {
00158       priority_int = atoi(args.priority);
00159    }
00160 
00161    if (ast_exists_extension(chan, args.context, args.extension, priority_int,
00162       S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) {
00163        ast_copy_string(buffer, "1", buflen);
00164    } else {
00165        ast_copy_string(buffer, "0", buflen);
00166    }
00167 
00168    return 0;
00169 }

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

Definition at line 75 of file func_dialplan.c.

References args, AST_APP_ARG, ast_channel_caller(), ast_context_find(), AST_DECLARE_APP_ARGS, ast_exists_extension(), ast_findlabel_extension(), ast_log, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero, context, exten, LOG_ERROR, NULL, parse(), and S_COR.

00077 {
00078    char *parse;
00079    AST_DECLARE_APP_ARGS(args,
00080       AST_APP_ARG(context);
00081       AST_APP_ARG(exten);
00082       AST_APP_ARG(priority);
00083    );
00084 
00085    strcpy(buf, "0");
00086 
00087    if (ast_strlen_zero(data)) {
00088       ast_log(LOG_ERROR, "DIALPLAN_EXISTS() requires an argument\n");
00089       return -1;
00090    }
00091 
00092    parse = ast_strdupa(data);
00093    AST_STANDARD_APP_ARGS(args, parse);
00094 
00095    if (!ast_strlen_zero(args.priority)) {
00096       int priority_num;
00097       if (sscanf(args.priority, "%30d", &priority_num) == 1 && priority_num > 0) {
00098          int res;
00099          res = ast_exists_extension(chan, args.context, args.exten, priority_num,
00100             !chan ? NULL :
00101             S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL));
00102          if (res)
00103             strcpy(buf, "1");
00104       } else {
00105          int res;
00106          res = ast_findlabel_extension(chan, args.context, args.exten, args.priority,
00107             !chan ? NULL :
00108             S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL));
00109          if (res > 0)
00110             strcpy(buf, "1");
00111       }
00112    } else if (!ast_strlen_zero(args.exten)) {
00113       int res;
00114       res = ast_exists_extension(chan, args.context, args.exten, 1,
00115          !chan ? NULL :
00116          S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL));
00117       if (res)
00118          strcpy(buf, "1");
00119    } else if (!ast_strlen_zero(args.context)) {
00120       if (ast_context_find(args.context))
00121          strcpy(buf, "1");
00122    } else {
00123       ast_log(LOG_ERROR, "Invalid arguments provided to DIALPLAN_EXISTS\n");
00124       return -1;
00125    }
00126 
00127    return 0;
00128 }

static int load_module ( void   )  [static]

Definition at line 189 of file func_dialplan.c.

References ast_custom_function_register.

00190 {
00191    int res = ast_custom_function_register(&isexten_function);
00192    res |= ast_custom_function_register(&acf_isexten);
00193    return res;
00194 }

static int unload_module ( void   )  [static]

Definition at line 182 of file func_dialplan.c.

References ast_custom_function_unregister().

00183 {
00184    int res = ast_custom_function_unregister(&isexten_function);
00185    res |= ast_custom_function_unregister(&acf_isexten);
00186    return res;
00187 }


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 = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND, } [static]

Definition at line 201 of file func_dialplan.c.

Initial value:

 {
   .name = "VALID_EXTEN",
   .read = acf_isexten_exec,
}

Definition at line 177 of file func_dialplan.c.

Definition at line 201 of file func_dialplan.c.

Initial value:

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

Definition at line 171 of file func_dialplan.c.


Generated on Thu Apr 16 06:31:16 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6