Wed Jan 8 2020 09:50:12

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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND, }
 
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 grego.nosp@m.ry@n.nosp@m.etwor.nosp@m.ksen.nosp@m.try.c.nosp@m.o.za
Russell Bryant russe.nosp@m.ll@d.nosp@m.igium.nosp@m..com

Definition in file func_dialplan.c.

Function Documentation

static void __reg_module ( void  )
static

Definition at line 132 of file func_dialplan.c.

static void __unreg_module ( void  )
static

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

59 {
60  char *parse;
64  AST_APP_ARG(priority);
65  );
66 
67  strcpy(buf, "0");
68 
69  if (ast_strlen_zero(data)) {
70  ast_log(LOG_ERROR, "DIALPLAN_EXISTS() requires an argument\n");
71  return -1;
72  }
73 
74  parse = ast_strdupa(data);
76 
77  if (!ast_strlen_zero(args.priority)) {
78  int priority_num;
79  if (sscanf(args.priority, "%30d", &priority_num) == 1 && priority_num > 0) {
80  int res;
81  res = ast_exists_extension(chan, args.context, args.exten, priority_num,
82  !chan ? NULL :
83  S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL));
84  if (res)
85  strcpy(buf, "1");
86  } else {
87  int res;
88  res = ast_findlabel_extension(chan, args.context, args.exten, args.priority,
89  !chan ? NULL :
90  S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL));
91  if (res > 0)
92  strcpy(buf, "1");
93  }
94  } else if (!ast_strlen_zero(args.exten)) {
95  int res;
96  res = ast_exists_extension(chan, args.context, args.exten, 1,
97  !chan ? NULL :
98  S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL));
99  if (res)
100  strcpy(buf, "1");
101  } else if (!ast_strlen_zero(args.context)) {
102  if (ast_context_find(args.context))
103  strcpy(buf, "1");
104  } else {
105  ast_log(LOG_ERROR, "Invalid arguments provided to DIALPLAN_EXISTS\n");
106  return -1;
107  }
108 
109  return 0;
110 }
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:109
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Definition: app.h:572
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:83
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
Definition: pbx.c:5400
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
#define LOG_ERROR
Definition: logger.h:155
static struct @350 args
int ast_findlabel_extension(struct ast_channel *c, const char *context, const char *exten, const char *label, const char *callerid)
Find the priority of an extension that has the specified label.
Definition: pbx.c:5405
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
char data[0]
Definition: astdb.h:33
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
Definition: app.h:604
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:107
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
struct ast_context * ast_context_find(const char *name)
Find a context.
Definition: pbx.c:2971
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
static int load_module ( void  )
static

Definition at line 123 of file func_dialplan.c.

References ast_custom_function_register.

124 {
126 }
static struct ast_custom_function isexten_function
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1164
static int unload_module ( void  )
static

Definition at line 118 of file func_dialplan.c.

References ast_custom_function_unregister().

119 {
121 }
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
Definition: pbx.c:3814
static struct ast_custom_function isexten_function

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

Definition at line 132 of file func_dialplan.c.

Definition at line 132 of file func_dialplan.c.

struct ast_custom_function isexten_function
static
Initial value:
= {
.name = "DIALPLAN_EXISTS",
.read_max = 2,
}
static int isexten_function_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
Definition: func_dialplan.c:57

Definition at line 112 of file func_dialplan.c.