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;
71 ast_str_append(&
context->output_buffer, 0,
" %-*s : %s\n", max_name_width,
"ParameterName",
"ParameterValue");
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")) {
151 context.show_details_only_level_0 = !is_container;
160 && strcmp(object_id,
"like") == 0) {
182 if (!formatter_entry) {
191 "==========================================================================================\n\n");
196 ast_cli(
a->fd,
"No container returned for object type %s.\n",
212 ast_cli(
a->fd,
"No objects found.\n\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) {
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());
Access Control of various sorts.
Asterisk main include file. File version handling, generic pbx functions.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_strdup(str)
A wrapper for strdup()
#define ao2_t_ref(o, delta, tag)
#define ao2_link(container, obj)
Add an object to a container.
@ AO2_ALLOC_OPT_LOCK_NOLOCK
#define ao2_t_iterator_next(iter, tag)
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
#define ao2_unlink_flags(container, obj, flags)
Remove an object from a container.
#define ao2_find(container, arg, flags)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
@ OBJ_SEARCH_PARTIAL_KEY
The arg parameter is a partial search key similar to OBJ_SEARCH_KEY.
@ OBJ_SEARCH_OBJECT
The arg parameter is an object of the same type.
@ OBJ_NOLOCK
Assume that the ao2_container is already locked.
@ OBJ_SEARCH_MASK
Search option field mask.
@ OBJ_SEARCH_KEY
The arg parameter is a search key, but is not an object.
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
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,...)
int ast_cli_completion_add(char *value)
Add a result to a request for completion options.
void ast_cli(int fd, const char *fmt,...)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
static int regex(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
Generic (perhaps overly so) hashtable implementation Hash Table support in Asterisk.
struct ast_variable * ast_variable_list_sort(struct ast_variable *head)
Performs an in-place sort on the variable list by ascending name.
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
static char * handle_pjsip_show_version(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int ast_sip_unregister_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Unregisters a CLI formatter.
static struct ast_cli_entry pjsip_cli[]
static void dump_str_and_free(int fd, struct ast_str *buf)
int ast_sip_cli_print_sorcery_objectset(void *obj, void *arg, int flags)
Prints a sorcery object's ast_variable list.
struct ast_sip_cli_formatter_entry * ast_sip_lookup_cli_formatter(const char *name)
Looks up a CLI formatter by type.
static int formatter_sort(const void *obj, const void *arg, int flags)
void ast_sip_destroy_cli(void)
static struct ao2_container * formatter_registry
static void complete_show_sorcery_object(struct ao2_container *container, struct ast_sip_cli_formatter_entry *formatter_entry, const char *word)
static int formatter_hash(const void *obj, int flags)
static int formatter_compare(void *obj, void *arg, int flags)
char * ast_sip_cli_traverse_objects(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int ast_sip_register_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Registers a CLI formatter.
int ast_sip_initialize_cli(void)
struct ao2_container * container
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
Sorcery Data Access Layer API.
#define ast_sorcery_objectset_create(sorcery, object)
Create an object set (KVP list) for an object.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
static int force_inline attribute_pure ast_ends_with(const char *str, const char *suffix)
Checks whether a string ends with another.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
descriptor for a cli entry.
const char *const cmda[AST_MAX_CMD_LEN]
CLI Formatter Context passed to all formatters.
CLI Formatter Registry Entry.
int(* iterate)(void *container, ao2_callback_fn callback, void *args)
ao2_callback_fn * print_header
void *(* retrieve_by_id)(const char *id)
const char *(* get_id)(const void *obj)
ao2_callback_fn * print_body
struct ao2_container *(* get_container)(const char *regex)
Support for dynamic strings.
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.