Wed Apr 6 11:30:04 2011

Asterisk developer's documentation


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"

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 = "8586c2a7d357cb591cc3a6607a8f62d1" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
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 146 of file func_extstate.c.

static void __unreg_module ( void   )  [static]

Definition at line 146 of 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 137 of file func_extstate.c.

References ast_custom_function_register, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, and extstate_function.

00138 {
00139    int res;
00140 
00141    res = ast_custom_function_register(&extstate_function);
00142 
00143    return res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS;
00144 }

static int unload_module ( void   )  [static]

Definition at line 128 of file func_extstate.c.

References ast_custom_function_unregister(), and extstate_function.

00129 {
00130    int res;
00131 
00132    res = ast_custom_function_unregister(&extstate_function);
00133 
00134    return res;
00135 }


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 = "8586c2a7d357cb591cc3a6607a8f62d1" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } [static]

Definition at line 146 of file func_extstate.c.

struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 146 of file func_extstate.c.

struct ast_custom_function extstate_function [static]

Initial value:

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

Definition at line 122 of file func_extstate.c.

Referenced by load_module(), and unload_module().


Generated on Wed Apr 6 11:30:04 2011 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7