Sat Apr 26 2014 22:02:51

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"
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, .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 200 of file func_dialplan.c.

static void __unreg_module ( void  ) [static]

Definition at line 200 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_strlen_zero(), context, LOG_WARNING, and S_COR.

{
   int priority_int;
   AST_DECLARE_APP_ARGS(args,
      AST_APP_ARG(context);
      AST_APP_ARG(extension);
      AST_APP_ARG(priority);
   );

   if (!chan) {
      ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
      return -1;
   }

   AST_STANDARD_APP_ARGS(args, parse);

   if (ast_strlen_zero(args.context)) {
      args.context = ast_strdupa(ast_channel_context(chan));
   }

   if (ast_strlen_zero(args.extension)) {
      ast_log(LOG_WARNING, "Syntax: VALID_EXTEN([<context>],<extension>[,<priority>]) - missing argument <extension>!\n");
      return -1;
   }

   if (ast_strlen_zero(args.priority)) {
      priority_int = 1;
   } else {
      priority_int = atoi(args.priority);
   }

   if (ast_exists_extension(chan, args.context, args.extension, priority_int,
      S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))) {
       ast_copy_string(buffer, "1", buflen);
   } else {
       ast_copy_string(buffer, "0", buflen);
   }

   return 0;
}
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_strlen_zero(), context, exten, LOG_ERROR, parse(), and S_COR.

{
   char *parse;
   AST_DECLARE_APP_ARGS(args,
      AST_APP_ARG(context);
      AST_APP_ARG(exten);
      AST_APP_ARG(priority);
   );

   strcpy(buf, "0");

   if (ast_strlen_zero(data)) {
      ast_log(LOG_ERROR, "DIALPLAN_EXISTS() requires an argument\n");
      return -1;
   }

   parse = ast_strdupa(data);
   AST_STANDARD_APP_ARGS(args, parse);

   if (!ast_strlen_zero(args.priority)) {
      int priority_num;
      if (sscanf(args.priority, "%30d", &priority_num) == 1 && priority_num > 0) {
         int res;
         res = ast_exists_extension(chan, args.context, args.exten, priority_num,
            !chan ? NULL :
            S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL));
         if (res)
            strcpy(buf, "1");
      } else {
         int res;
         res = ast_findlabel_extension(chan, args.context, args.exten, args.priority,
            !chan ? NULL :
            S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL));
         if (res > 0)
            strcpy(buf, "1");
      }
   } else if (!ast_strlen_zero(args.exten)) {
      int res;
      res = ast_exists_extension(chan, args.context, args.exten, 1,
         !chan ? NULL :
         S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL));
      if (res)
         strcpy(buf, "1");
   } else if (!ast_strlen_zero(args.context)) {
      if (ast_context_find(args.context))
         strcpy(buf, "1");
   } else {
      ast_log(LOG_ERROR, "Invalid arguments provided to DIALPLAN_EXISTS\n");
      return -1;
   }

   return 0;
}
static int load_module ( void  ) [static]

Definition at line 189 of file func_dialplan.c.

References ast_custom_function_register.

static int unload_module ( void  ) [static]

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

Definition at line 200 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 200 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.