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)
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 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@starsilk.net>

Definition in file func_extstate.c.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 150 of file func_extstate.c.

static void __unreg_module ( void   )  [static]

Definition at line 150 of 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, LOG_WARNING, and strsep().

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 }


Variable Documentation

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

Definition at line 150 of file func_extstate.c.

Initial value:

 {
   .name = "EXTENSION_STATE",
   .read = extstate_read,
   .read_max = 12,
}

Definition at line 126 of file func_extstate.c.


Generated on Thu Apr 16 06:31:17 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6