113 size_t len = strlen(
"Custom:");
116 if (strncasecmp(data,
"Custom:",
len)) {
117 ast_log(
LOG_WARNING,
"The DEVICE_STATE function can only be used to set 'Custom:' device state!\n");
204 "Usage: devstate list\n"
205 " List all custom device states that have been set by using\n"
206 " the DEVICE_STATE dialplan function.\n";
212 if (
a->argc != e->
args)
216 "---------------------------------------------------------------------\n"
217 "--- Custom Device States --------------------------------------------\n"
218 "---------------------------------------------------------------------\n"
222 for (; db_entry; db_entry = db_entry->
next) {
223 const char *dev_name = strrchr(db_entry->
key,
'/') + 1;
224 if (dev_name <= (
const char *) 1)
226 ast_cli(
a->fd,
"--- Name: 'Custom:%s' State: '%s'\n"
227 "---\n", dev_name, db_entry->
data);
233 "---------------------------------------------------------------------\n"
234 "---------------------------------------------------------------------\n"
243 const char *dev, *
state;
248 e->
command =
"devstate change";
250 "Usage: devstate change <device> <state>\n"
251 " Change a custom device to a new state.\n"
252 " The possible values for the state are:\n"
253 "UNKNOWN | NOT_INUSE | INUSE | BUSY | INVALID | UNAVAILABLE | RINGING\n"
254 "RINGINUSE | ONHOLD\n"
257 " devstate change Custom:mystate1 INUSE\n"
258 " devstate change Custom:mystate1 NOT_INUSE\n"
263 static const char *
const cmds[] = {
"UNKNOWN",
"NOT_INUSE",
"INUSE",
"BUSY",
264 "UNAVAILABLE",
"RINGING",
"RINGINUSE",
"ONHOLD",
NULL };
266 if (
a->pos == e->
args + 1)
273 if (
a->argc != e->
args + 2)
276 len = strlen(
"Custom:");
277 dev =
a->argv[e->
args];
280 if (strncasecmp(dev,
"Custom:",
len)) {
281 ast_cli(
a->fd,
"The devstate command can only be used to set 'Custom:' device state!\n");
309 .
name =
"DEVICE_STATE",
339 for (; db_entry; db_entry = db_entry->
next) {
340 const char *dev_name = strrchr(db_entry->
key,
'/') + 1;
341 if (dev_name <= (
const char *) 1)
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()
Asterisk main include file. File version handling, generic pbx functions.
General Asterisk PBX channel definitions.
Standard Command Line Interface.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
#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.
char * strsep(char **str, const char *delims)
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)