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 62 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().
00063 { 00064 const char *res = "UNKNOWN"; 00065 00066 switch (state) { 00067 case AST_EXTENSION_NOT_INUSE: 00068 res = "NOT_INUSE"; 00069 break; 00070 case AST_EXTENSION_INUSE: 00071 res = "INUSE"; 00072 break; 00073 case AST_EXTENSION_BUSY: 00074 res = "BUSY"; 00075 break; 00076 case AST_EXTENSION_UNAVAILABLE: 00077 res = "UNAVAILABLE"; 00078 break; 00079 case AST_EXTENSION_RINGING: 00080 res = "RINGING"; 00081 break; 00082 case AST_EXTENSION_INUSE | AST_EXTENSION_RINGING: 00083 res = "RINGINUSE"; 00084 break; 00085 case AST_EXTENSION_INUSE | AST_EXTENSION_ONHOLD: 00086 res = "HOLDINUSE"; 00087 break; 00088 case AST_EXTENSION_ONHOLD: 00089 res = "ONHOLD"; 00090 break; 00091 } 00092 00093 return res; 00094 }
| static int extstate_read | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Definition at line 96 of file func_extstate.c.
References ast_copy_string(), ast_extension_state(), ast_extstate_str(), ast_log(), ast_strlen_zero(), context, exten, LOG_WARNING, and strsep().
00098 { 00099 char *exten, *context; 00100 00101 if (ast_strlen_zero(data)) { 00102 ast_log(LOG_WARNING, "EXTENSION_STATE requires an extension\n"); 00103 return -1; 00104 } 00105 00106 context = exten = data; 00107 strsep(&context, "@"); 00108 if (ast_strlen_zero(context)) 00109 context = "default"; 00110 00111 if (ast_strlen_zero(exten)) { 00112 ast_log(LOG_WARNING, "EXTENSION_STATE requires an extension\n"); 00113 return -1; 00114 } 00115 00116 ast_copy_string(buf, 00117 ast_extstate_str(ast_extension_state(chan, context, exten)), len); 00118 00119 return 0; 00120 }
| static int load_module | ( | void | ) | [static] |
Definition at line 136 of file func_extstate.c.
References ast_custom_function_register, AST_MODULE_LOAD_DECLINE, and AST_MODULE_LOAD_SUCCESS.
00137 { 00138 int res; 00139 00140 res = ast_custom_function_register(&extstate_function); 00141 00142 return res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS; 00143 }
| static int unload_module | ( | void | ) | [static] |
Definition at line 127 of file func_extstate.c.
References ast_custom_function_unregister().
00128 { 00129 int res; 00130 00131 res = ast_custom_function_unregister(&extstate_function); 00132 00133 return res; 00134 }
struct ast_custom_function extstate_function [static] |
{
.name = "EXTENSION_STATE",
.read = extstate_read,
}
Definition at line 122 of file func_extstate.c.
1.6.1