40 int max_name_width = 13;
41 int max_value_width = 14;
55 for (i = objset; i; i = i->
next) {
57 width = strlen(i->
name);
58 max_name_width = width > max_name_width ? width : max_name_width;
61 width = strlen(i->
value);
62 max_value_width = width > max_value_width ? width : max_value_width;
66 separator =
ast_alloca(max_name_width + max_value_width + 8);
68 memset(separator,
'=', max_name_width + max_value_width + 3);
69 separator[max_name_width + max_value_width + 3] = 0;
76 for (i = objset; i; i = i->
next) {
89 size_t wordlen = strlen(word);
94 const char *
id = formatter_entry->
get_id(
object);
95 if (!strncasecmp(word,
id, wordlen)) {
98 ao2_t_ref(
object, -1,
"toss iterator endpoint ptr before break");
114 int is_container = 0;
117 const char *object_id;
118 char formatter_type[64];
124 .show_details_only_level_0 = 0,
134 object_id = a->
argv[3];
141 int l = strlen(cmd2);
142 snprintf(formatter_type, 64,
"%*.*sy", l - 3, l - 3, cmd2);
150 if (!strcmp(cmd1,
"show")) {
160 && strcmp(object_id,
"like") == 0) {
182 if (!formatter_entry) {
189 formatter_entry->print_header(
NULL, &context, 0);
191 "==========================================================================================\n\n");
194 container = formatter_entry->get_container(regex);
196 ast_cli(a->
fd,
"No container returned for object type %s.\n",
221 ast_cli(a->
fd,
"No object specified.\n");
225 object = formatter_entry->retrieve_by_id(object_id);
228 ast_cli(a->
fd,
"Unable to find object %s.\n\n", object_id);
231 formatter_entry->print_body(
object, &context, 0);
243 const char *right_key = arg;
248 right_key = right_obj->
name;
251 cmp = strcmp(left_obj->
name, right_key);
254 cmp = strncmp(left_obj->
name, right_key, strlen(right_key));
268 const char *right_key = arg;
273 right_key = right_obj->
name;
276 if (strcmp(left_obj->
name, right_key) == 0) {;
281 if (strncmp(left_obj->
name, right_key, strlen(right_key)) == 0) {
321 ao2_link(formatter_registry, formatter);
330 if (
ao2_ref(formatter, -1) == 2) {
342 e->
command =
"pjsip show version";
344 "Usage: pjsip show version\n" 345 " Show the version of pjproject that res_pjsip is running against\n";
351 ast_cli(a->
fd,
"PJPROJECT version currently running against: %s\n", pj_get_version());
365 if (!formatter_registry) {
378 ao2_ref(formatter_registry, -1);
#define ao2_t_ref(o, delta, tag)
Reference/unreference an object and return the old refcount.
struct ast_str * output_buffer
struct ast_variable * next
struct ao2_container *(* get_container)(const char *regex)
static int formatter_hash(const void *obj, int flags)
#define AST_CLI_DEFINE(fn, txt,...)
struct ast_variable * ast_variable_list_sort(struct ast_variable *head)
Performs an in-place sort on the variable list by ascending name.
Asterisk main include file. File version handling, generic pbx functions.
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
void ast_sip_destroy_cli(void)
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
The arg parameter is a search key, but is not an object.
static int force_inline attribute_pure ast_ends_with(const char *str, const char *suffix)
static int formatter_compare(void *obj, void *arg, int flags)
descriptor for a cli entry.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define ao2_callback(c, flags, cb_fn, arg)
struct ast_sip_cli_formatter_entry * ast_sip_lookup_cli_formatter(const char *name)
Looks up a CLI formatter by type.
Generic (perhaps overly so) hashtable implementation Hash Table support in Asterisk.
Structure for variables, used for configurations and for channel variables.
static int formatter_sort(const void *obj, const void *arg, int flags)
Assume that the ao2_container is already locked.
int(* iterate)(void *container, ao2_callback_fn callback, void *args)
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
static char * handle_pjsip_show_version(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define ast_strdup(str)
A wrapper for strdup()
void ast_cli(int fd, const char *fmt,...)
int ast_sip_unregister_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Unregisters a CLI formatter.
#define ast_strlen_zero(foo)
int ast_sip_initialize_cli(void)
The arg parameter is a partial search key similar to OBJ_SEARCH_KEY.
char * ast_sip_cli_traverse_objects(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static struct ao2_container * formatter_registry
int ast_sip_cli_print_sorcery_objectset(void *obj, void *arg, int flags)
Prints a sorcery object's ast_variable list.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Access Control of various sorts.
#define ao2_ref(o, delta)
void *(* retrieve_by_id)(const char *id)
struct ao2_container * container
static struct ast_cli_entry pjsip_cli[]
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
static void dump_str_and_free(int fd, struct ast_str *buf)
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
#define ao2_t_iterator_next(iter, tag)
static void complete_show_sorcery_object(struct ao2_container *container, struct ast_sip_cli_formatter_entry *formatter_entry, const char *word)
#define ast_sorcery_objectset_create(sorcery, object)
Create an object set (KVP list) for an object.
static int regex(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
#define ao2_find(container, arg, flags)
const char *(* get_id)(const void *obj)
The arg parameter is an object of the same type.
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Standard Command Line Interface.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#define ao2_unlink_flags(container, obj, flags)
ao2_callback_fn * print_header
Search option field mask.
static char context[AST_MAX_CONTEXT]
int ast_cli_completion_add(char *value)
Add a result to a request for completion options.
ao2_callback_fn * print_body
const char *const cmda[AST_MAX_CMD_LEN]
int ast_sip_register_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Registers a CLI formatter.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Sorcery Data Access Layer API.
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
unsigned show_details_only_level_0
#define ao2_link(container, obj)