Thu Apr 28 2011 16:57:10

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"
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
__MODULE_INFO_SECTION 
__mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Gets an extension's state in the dialplan" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, }
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 145 of file func_extstate.c.

static void __unreg_module ( void  ) [static]

Definition at line 145 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().

{
   const char *res = "UNKNOWN";

   switch (state) {
   case AST_EXTENSION_NOT_INUSE:
      res = "NOT_INUSE";
      break;
   case AST_EXTENSION_INUSE:
      res = "INUSE";
      break;
   case AST_EXTENSION_BUSY:
      res = "BUSY";
      break;
   case AST_EXTENSION_UNAVAILABLE:
      res = "UNAVAILABLE";
      break;
   case AST_EXTENSION_RINGING:
      res = "RINGING";
      break;
   case AST_EXTENSION_INUSE | AST_EXTENSION_RINGING:
      res = "RINGINUSE";
      break;
   case AST_EXTENSION_INUSE | AST_EXTENSION_ONHOLD:
      res = "HOLDINUSE";
      break;
   case AST_EXTENSION_ONHOLD:
      res = "ONHOLD";
      break;
   }

   return res;
}
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().

{
   char *exten, *context;

   if (ast_strlen_zero(data)) {
      ast_log(LOG_WARNING, "EXTENSION_STATE requires an extension\n");
      return -1;
   }

   context = exten = data;
   strsep(&context, "@");
   if (ast_strlen_zero(context))
      context = "default";

   if (ast_strlen_zero(exten)) {
      ast_log(LOG_WARNING, "EXTENSION_STATE requires an extension\n");
      return -1;
   }

   ast_copy_string(buf, 
      ast_extstate_str(ast_extension_state(chan, context, exten)), len);

   return 0;
}
static int load_module ( void  ) [static]
static int unload_module ( void  ) [static]

Definition at line 127 of file func_extstate.c.

References ast_custom_function_unregister().

{
   int res;

   res = ast_custom_function_unregister(&extstate_function);

   return res;
}

Variable Documentation

struct ast_module_info __MODULE_INFO_SECTION __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Gets an extension's state in the dialplan" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static]

Definition at line 145 of file func_extstate.c.

Definition at line 145 of file func_extstate.c.

Initial value:
 {
   .name = "EXTENSION_STATE",
   .read = extstate_read,
}

Definition at line 122 of file func_extstate.c.