Asterisk - The Open Source Telephony Project GIT-master-a358458
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 148 of file func_extstate.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 148 of file func_extstate.c.

◆ ast_extstate_str()

static const char * ast_extstate_str ( int  state)
static

Definition at line 64 of file func_extstate.c.

65{
66 const char *res = "UNKNOWN";
67
68 switch (state) {
70 res = "NOT_INUSE";
71 break;
73 res = "INUSE";
74 break;
76 res = "BUSY";
77 break;
79 res = "UNAVAILABLE";
80 break;
82 res = "RINGING";
83 break;
85 res = "RINGINUSE";
86 break;
88 res = "HOLDINUSE";
89 break;
91 res = "ONHOLD";
92 break;
93 }
94
95 return res;
96}
@ 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 148 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 98 of file func_extstate.c.

100{
101 char *exten, *context;
102
103 if (ast_strlen_zero(data)) {
104 ast_log(LOG_WARNING, "EXTENSION_STATE requires an extension\n");
105 return -1;
106 }
107
108 context = exten = data;
109 strsep(&context, "@");
111 context = "default";
112
113 if (ast_strlen_zero(exten)) {
114 ast_log(LOG_WARNING, "EXTENSION_STATE requires an extension\n");
115 return -1;
116 }
117
120
121 return 0;
122}
#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:64
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
char * strsep(char **str, const char *delims)
#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:3170
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 139 of file func_extstate.c.

140{
141 int res;
142
144
146}
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:1558

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 130 of file func_extstate.c.

131{
132 int res;
133
135
136 return res;
137}
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 148 of file func_extstate.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 148 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: func_extstate.c:98

Definition at line 124 of file func_extstate.c.

Referenced by load_module(), and unload_module().