Asterisk - The Open Source Telephony Project GIT-master-754dea3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
Functions | Variables
func_extstate.c File Reference

Get the state of a hinted extension for dialplan control. More...

#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/utils.h"
#include "asterisk/devicestate.h"
Include dependency graph for func_extstate.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static const char * ast_extstate_str (int state)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int extstate_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 = "Gets an extension's state in the dialplan" , .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_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_custom_function extstate_function
 

Detailed Description

Get the state of a hinted extension for dialplan control.

Author
Adam Gundy adam@.nosp@m.star.nosp@m.silk..nosp@m.net

Definition in file func_extstate.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 151 of file func_extstate.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 151 of file func_extstate.c.

◆ ast_extstate_str()

static const char * ast_extstate_str ( int  state)
static

Definition at line 67 of file func_extstate.c.

68{
69 const char *res = "UNKNOWN";
70
71 switch (state) {
73 res = "NOT_INUSE";
74 break;
76 res = "INUSE";
77 break;
79 res = "BUSY";
80 break;
82 res = "UNAVAILABLE";
83 break;
85 res = "RINGING";
86 break;
88 res = "RINGINUSE";
89 break;
91 res = "HOLDINUSE";
92 break;
94 res = "ONHOLD";
95 break;
96 }
97
98 return res;
99}
@ AST_EXTENSION_RINGING
Definition: pbx.h:68
@ AST_EXTENSION_NOT_INUSE
Definition: pbx.h:64
@ AST_EXTENSION_INUSE
Definition: pbx.h:65
@ AST_EXTENSION_UNAVAILABLE
Definition: pbx.h:67
@ AST_EXTENSION_ONHOLD
Definition: pbx.h:69
@ AST_EXTENSION_BUSY
Definition: pbx.h:66

References AST_EXTENSION_BUSY, AST_EXTENSION_INUSE, AST_EXTENSION_NOT_INUSE, AST_EXTENSION_ONHOLD, AST_EXTENSION_RINGING, and AST_EXTENSION_UNAVAILABLE.

Referenced by extstate_read().

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 151 of file func_extstate.c.

◆ extstate_read()

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

Definition at line 101 of file func_extstate.c.

103{
104 char *exten, *context;
105
106 if (ast_strlen_zero(data)) {
107 ast_log(LOG_WARNING, "EXTENSION_STATE requires an extension\n");
108 return -1;
109 }
110
111 context = exten = data;
112 strsep(&context, "@");
114 context = "default";
115
116 if (ast_strlen_zero(exten)) {
117 ast_log(LOG_WARNING, "EXTENSION_STATE requires an extension\n");
118 return -1;
119 }
120
123
124 return 0;
125}
char * strsep(char **str, const char *delims)
#define ast_log
Definition: astobj2.c:42
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static const char * ast_extstate_str(int state)
Definition: func_extstate.c:67
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define LOG_WARNING
int ast_extension_state(struct ast_channel *c, const char *context, const char *exten)
Uses hint and devicestate callback to get the state of an extension.
Definition: pbx.c:3185
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425

References ast_copy_string(), ast_extension_state(), ast_extstate_str(), ast_log, ast_strlen_zero(), buf, voicemailpwcheck::context, len(), LOG_WARNING, and strsep().

◆ load_module()

static int load_module ( void  )
static

Definition at line 142 of file func_extstate.c.

143{
144 int res;
145
147
149}
static struct ast_custom_function extstate_function
@ AST_MODULE_LOAD_SUCCESS
Definition: module.h:70
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1559

References ast_custom_function_register, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, and extstate_function.

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 133 of file func_extstate.c.

134{
135 int res;
136
138
139 return res;
140}
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.

References ast_custom_function_unregister(), and extstate_function.

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Gets an extension's state in the dialplan" , .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_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static

Definition at line 151 of file func_extstate.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 151 of file func_extstate.c.

◆ extstate_function

struct ast_custom_function extstate_function
static
Initial value:
= {
.name = "EXTENSION_STATE",
.read = extstate_read,
.read_max = 12,
}
static int extstate_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)

Definition at line 127 of file func_extstate.c.

Referenced by load_module(), and unload_module().