111 size_t len = strlen(
"Custom:");
114 if (strncasecmp(data,
"Custom:", len)) {
115 ast_log(
LOG_WARNING,
"The DEVICE_STATE function can only be used to set 'Custom:' device state!\n");
127 ast_log(
LOG_ERROR,
"DEVICE_STATE function given invalid state value '%s'\n", value);
168 context = exten =
args.exten;
202 "Usage: devstate list\n" 203 " List all custom device states that have been set by using\n" 204 " the DEVICE_STATE dialplan function.\n";
214 "---------------------------------------------------------------------\n" 215 "--- Custom Device States --------------------------------------------\n" 216 "---------------------------------------------------------------------\n" 220 for (; db_entry; db_entry = db_entry->
next) {
221 const char *dev_name = strrchr(db_entry->
key,
'/') + 1;
222 if (dev_name <= (
const char *) 1)
224 ast_cli(a->
fd,
"--- Name: 'Custom:%s' State: '%s'\n" 225 "---\n", dev_name, db_entry->
data);
231 "---------------------------------------------------------------------\n" 232 "---------------------------------------------------------------------\n" 241 const char *dev, *
state;
246 e->
command =
"devstate change";
248 "Usage: devstate change <device> <state>\n" 249 " Change a custom device to a new state.\n" 250 " The possible values for the state are:\n" 251 "UNKNOWN | NOT_INUSE | INUSE | BUSY | INVALID | UNAVAILABLE | RINGING\n" 252 "RINGINUSE | ONHOLD\n" 255 " devstate change Custom:mystate1 INUSE\n" 256 " devstate change Custom:mystate1 NOT_INUSE\n" 261 static const char *
const cmds[] = {
"UNKNOWN",
"NOT_INUSE",
"INUSE",
"BUSY",
262 "UNAVAILABLE",
"RINGING",
"RINGINUSE",
"ONHOLD",
NULL };
274 len = strlen(
"Custom:");
278 if (strncasecmp(dev,
"Custom:", len)) {
279 ast_cli(a->
fd,
"The devstate command can only be used to set 'Custom:' device state!\n");
292 ast_cli(a->
fd,
"Changing %s to %s\n", dev, state);
307 .
name =
"DEVICE_STATE",
337 for (; db_entry; db_entry = db_entry->
next) {
338 const char *dev_name = strrchr(db_entry->
key,
'/') + 1;
339 if (dev_name <= (
const char *) 1)
enum sip_cc_notify_state state
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 char exten[AST_MAX_EXTENSION]
Main Channel structure associated with a channel.
#define AST_CLI_DEFINE(fn, txt,...)
ast_device_state
Device States.
Asterisk main include file. File version handling, generic pbx functions.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
#define ast_test_flag(p, flag)
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
descriptor for a cli entry.
void ast_db_freetree(struct ast_db_entry *entry)
Free structure created by ast_db_gettree()
static int hint_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static const struct ast_app_option hint_options[128]
int ast_devstate_prov_del(const char *label)
Remove device state provider.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
int ast_devstate_prov_add(const char *label, ast_devstate_prov_cb_type callback)
Add device state provider.
void ast_cli(int fd, const char *fmt,...)
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
int args
This gets set in ast_cli_register()
#define ast_strlen_zero(foo)
static int load_module(void)
char * ast_cli_complete(const char *word, const char *const choices[], int pos)
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
static struct ast_custom_function hint_function
struct ast_db_entry * next
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.
General Asterisk PBX channel definitions.
static enum ast_device_state custom_devstate_callback(const char *data)
Data structure associated with a custom dialplan function.
A set of macros to manage forward-linked lists.
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.
Core PBX routines and definitions.
const char * ast_devstate_str(enum ast_device_state devstate) attribute_pure
Convert device state to text string that is easier to parse.
struct ast_db_entry * ast_db_gettree(const char *family, const char *keytree)
Get a list of values within the astdb tree.
static char * handle_cli_devstate_list(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static struct ast_custom_function devstate_function
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static char * handle_cli_devstate_change(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
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 char astdb_family[]
int ast_db_get(const char *family, const char *key, char *value, int valuelen)
Get key value specified by family/key.
Structure used to handle boolean flags.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
char * strsep(char **str, const char *delims)
Standard Command Line Interface.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
static int devstate_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
int ast_db_put(const char *family, const char *key, const char *value)
Store value addressed by family/key.
static char context[AST_MAX_CONTEXT]
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
Persistant data storage (akin to *doze registry)
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define ast_custom_function_register(acf)
Register a custom function.
static struct ast_cli_entry cli_funcdevstate[]
#define AST_APP_ARG(name)
Define an application argument.