119    size_t len = strlen(
"Custom:");
 
  122    if (strncasecmp(data, 
"Custom:", 
len)) {
 
  123        ast_log(
LOG_WARNING, 
"The DEVICE_STATE function can only be used to set 'Custom:' device state!\n");
 
 
  156    char *exten, *context;
 
  176    context = exten = 
args.exten;
 
 
  210            "Usage: devstate list\n" 
  211            "       List all custom device states that have been set by using\n" 
  212            "       the DEVICE_STATE dialplan function.\n";
 
  218    if (
a->argc != e->
args)
 
  222            "---------------------------------------------------------------------\n" 
  223            "--- Custom Device States --------------------------------------------\n" 
  224            "---------------------------------------------------------------------\n" 
  228    for (; db_entry; db_entry = db_entry->
next) {
 
  229        const char *dev_name = strrchr(db_entry->
key, 
'/') + 1;
 
  230        if (dev_name <= (
const char *) 1)
 
  232        ast_cli(
a->fd, 
"--- Name: 'Custom:%s'  State: '%s'\n" 
  233                       "---\n", dev_name, db_entry->
data);
 
  239            "---------------------------------------------------------------------\n" 
  240            "---------------------------------------------------------------------\n" 
 
  249    const char *dev, *
state;
 
  254        e->
command = 
"devstate change";
 
  256            "Usage: devstate change <device> <state>\n" 
  257            "       Change a custom device to a new state.\n" 
  258            "       The possible values for the state are:\n" 
  259            "UNKNOWN | NOT_INUSE | INUSE | BUSY | INVALID | UNAVAILABLE | RINGING\n" 
  260            "RINGINUSE | ONHOLD\n" 
  263            "       devstate change Custom:mystate1 INUSE\n" 
  264            "       devstate change Custom:mystate1 NOT_INUSE\n" 
  269        static const char * 
const cmds[] = { 
"UNKNOWN", 
"NOT_INUSE", 
"INUSE", 
"BUSY",
 
  270                             "UNAVAILABLE", 
"RINGING", 
"RINGINUSE", 
"ONHOLD", 
NULL };
 
  272        if (
a->pos == e->
args + 1)
 
  279    if (
a->argc != e->
args + 2)
 
  282    len = strlen(
"Custom:");
 
  283    dev = 
a->argv[e->
args];
 
  286    if (strncasecmp(dev, 
"Custom:", 
len)) {
 
  287        ast_cli(
a->fd, 
"The devstate command can only be used to set 'Custom:' device state!\n");
 
 
  315    .
name = 
"DEVICE_STATE",
 
 
  345    for (; db_entry; db_entry = db_entry->
next) {
 
  346        const char *dev_name = strrchr(db_entry->
key, 
'/') + 1;
 
  347        if (dev_name <= (
const char *) 1)
 
 
void ast_cli_unregister_multiple(void)
Persistent data storage (akin to *doze registry)
int ast_db_put(const char *family, const char *key, const char *value)
Store value addressed by family/key.
int ast_db_get(const char *family, const char *key, char *value, int valuelen)
Get key value specified by family/key.
struct ast_db_entry * ast_db_gettree(const char *family, const char *keytree)
Get a list of values within the astdb tree.
void ast_db_freetree(struct ast_db_entry *entry)
Free structure created by ast_db_gettree()
char * strsep(char **str, const char *delims)
Asterisk main include file. File version handling, generic pbx functions.
General Asterisk PBX channel definitions.
Standard Command Line Interface.
#define AST_CLI_DEFINE(fn, txt,...)
void ast_cli(int fd, const char *fmt,...)
char * ast_cli_complete(const char *word, const char *const choices[], int pos)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
int ast_devstate_prov_del(const char *label)
Remove device state provider.
const char * ast_devstate_str(enum ast_device_state devstate) attribute_pure
Convert device state to text string that is easier to parse.
int ast_devstate_changed(enum ast_device_state state, enum ast_devstate_cache cachable, const char *fmt,...)
Tells Asterisk the State for Device is changed.
enum ast_device_state ast_devstate_val(const char *val)
Convert device state from text to integer value.
int ast_devstate_prov_add(const char *label, ast_devstate_prov_cb_type callback)
Add device state provider.
ast_device_state
Device States.
static int devstate_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
static char * handle_cli_devstate_change(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static struct ast_cli_entry cli_funcdevstate[]
static int hint_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static enum ast_device_state custom_devstate_callback(const char *data)
static struct ast_custom_function devstate_function
static struct ast_custom_function hint_function
static char * handle_cli_devstate_list(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static const char astdb_family[]
static int load_module(void)
static int unload_module(void)
static int devstate_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static const struct ast_app_option hint_options[128]
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
A set of macros to manage forward-linked lists.
Asterisk module definitions.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODPRI_DEVSTATE_PROVIDER
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
Core PBX routines and definitions.
#define ast_custom_function_register(acf)
Register a custom function.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
int ast_get_hint(char *hint, int hintsize, char *name, int namesize, struct ast_channel *c, const char *context, const char *exten)
If an extension hint exists, return non-zero.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Main Channel structure associated with a channel.
descriptor for a cli entry.
int args
This gets set in ast_cli_register()
Data structure associated with a custom dialplan function.
struct ast_db_entry * next
Structure used to handle boolean flags.
#define ast_test_flag(p, flag)