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"
Go to the source code of this file.
Functions | |
static const char * | ast_extstate_str (int state) |
AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Gets an extension's state in the dialplan") | |
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_custom_function | extstate_function |
Get the state of a hinted extension for dialplan control.
Definition in file func_extstate.c.
static const char* ast_extstate_str | ( | int | state | ) | [static] |
Definition at line 66 of file func_extstate.c.
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().
00067 { 00068 const char *res = "UNKNOWN"; 00069 00070 switch (state) { 00071 case AST_EXTENSION_NOT_INUSE: 00072 res = "NOT_INUSE"; 00073 break; 00074 case AST_EXTENSION_INUSE: 00075 res = "INUSE"; 00076 break; 00077 case AST_EXTENSION_BUSY: 00078 res = "BUSY"; 00079 break; 00080 case AST_EXTENSION_UNAVAILABLE: 00081 res = "UNAVAILABLE"; 00082 break; 00083 case AST_EXTENSION_RINGING: 00084 res = "RINGING"; 00085 break; 00086 case AST_EXTENSION_INUSE | AST_EXTENSION_RINGING: 00087 res = "RINGINUSE"; 00088 break; 00089 case AST_EXTENSION_INUSE | AST_EXTENSION_ONHOLD: 00090 res = "HOLDINUSE"; 00091 break; 00092 case AST_EXTENSION_ONHOLD: 00093 res = "ONHOLD"; 00094 break; 00095 } 00096 00097 return res; 00098 }
static int extstate_read | ( | struct ast_channel * | chan, | |
const char * | cmd, | |||
char * | data, | |||
char * | buf, | |||
size_t | len | |||
) | [static] |
Definition at line 100 of file func_extstate.c.
References ast_copy_string(), ast_extension_state(), ast_extstate_str(), ast_log(), ast_strlen_zero(), context, exten, and LOG_WARNING.
00102 { 00103 char *exten, *context; 00104 00105 if (ast_strlen_zero(data)) { 00106 ast_log(LOG_WARNING, "EXTENSION_STATE requires an extension\n"); 00107 return -1; 00108 } 00109 00110 context = exten = data; 00111 strsep(&context, "@"); 00112 if (ast_strlen_zero(context)) 00113 context = "default"; 00114 00115 if (ast_strlen_zero(exten)) { 00116 ast_log(LOG_WARNING, "EXTENSION_STATE requires an extension\n"); 00117 return -1; 00118 } 00119 00120 ast_copy_string(buf, 00121 ast_extstate_str(ast_extension_state(chan, context, exten)), len); 00122 00123 return 0; 00124 }
static int load_module | ( | void | ) | [static] |
Definition at line 141 of file func_extstate.c.
References ast_custom_function_register, AST_MODULE_LOAD_DECLINE, and AST_MODULE_LOAD_SUCCESS.
00142 { 00143 int res; 00144 00145 res = ast_custom_function_register(&extstate_function); 00146 00147 return res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS; 00148 }
static int unload_module | ( | void | ) | [static] |
Definition at line 132 of file func_extstate.c.
References ast_custom_function_unregister().
00133 { 00134 int res; 00135 00136 res = ast_custom_function_unregister(&extstate_function); 00137 00138 return res; 00139 }
struct ast_custom_function extstate_function [static] |
{ .name = "EXTENSION_STATE", .read = extstate_read, .read_max = 12, }
Definition at line 126 of file func_extstate.c.