Asterisk - The Open Source Telephony Project GIT-master-f36a736
res_pjsip_cli.h
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2013, Fairview 5 Engineering, LLC.
5 *
6 * George Joseph <george.joseph@fairview5.com>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19#ifndef RES_PJSIP_CLI_H_
20#define RES_PJSIP_CLI_H_
21
22#include "asterisk/cli.h"
23
24#define CLI_HEADER_FILLER ".........................................................................................."
25#define CLI_DETAIL_FILLER " "
26#define CLI_MAX_WIDTH 90
27#define CLI_LAST_TABSTOP 62
28#define CLI_MAX_TITLE_NAME 8
29#define CLI_INDENT_TO_SPACES(x) ((x * 2) + 1 + CLI_MAX_TITLE_NAME)
30
31/*!
32 * \brief CLI Formatter Context passed to all formatters.
33 */
35 /*! Buffer used to accumulate cli output. */
37 /*! Used to indicate which direction an auth is used for. "I" or "O" */
39 /*! Allows formatters to know how far to indent their output. */
41 /*! Tells a formatter to dump its object_set. */
42 unsigned show_details : 1;
43 /*! Tells a formatter to descend into child objects. */
44 unsigned recurse : 1;
45 /*! Tells a formatter to dump it's object_set only if it's the root object. */
47};
48
49/*!
50 * \brief CLI Formatter Registry Entry
51 */
53 /*! A globally unique name for this formatter. If this formatter entry
54 * is for an existing sorcery object type, then this name must match
55 * the sorcery object type. Otherwise it can be any string as long as
56 * it's globally unique.
57 */
58 const char *name;
59 /*! The callback used to print the object's column headers. */
61 /*! The callback used to print the details of the object. */
63 /*! The function used to retrieve a container of all objects of this type. */
64 struct ao2_container *(* get_container)(const char *regex);
65 /*! The function used to iterate over a container of objects. */
66 int (* iterate)(void *container, ao2_callback_fn callback, void *args);
67 /*! The function used to retrieve a specific object from it's container. */
68 void *(* retrieve_by_id)(const char *id);
69 /*! The function used to retrieve an id string from an object. */
70 const char *(* get_id)(const void *obj);
71};
72
73/*!
74 * \brief Registers a CLI formatter.
75 *
76 * \param formatter An ao2_callback_fn that outputs the formatted data.
77 * \retval 0 Success, non-zero on failure
78 */
80
81/*!
82 * \brief Unregisters a CLI formatter.
83 *
84 * \param formatter The name of the formatter, usually the sorcery object type.
85 * \retval 0 Success, non-zero on failure
86 */
88
89/*!
90 * \brief Looks up a CLI formatter by type.
91 *
92 * \param name The name of the formatter, usually the sorcery object type.
93 * \retval Pointer to formatter entry structure
94 */
96
97/*!
98 * \brief Prints a sorcery object's ast_variable list
99 *
100 * \param obj The sorcery object
101 * \param arg The ast_sip_cli_context
102 * \param flags
103 * \retval 0 Success, non-zero on failure
104 */
105int ast_sip_cli_print_sorcery_objectset(void *obj, void *arg, int flags);
106
107char *ast_sip_cli_traverse_objects(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
108
109
110#endif /* RES_PJSIP_CLI_H_ */
enum queue_result id
Definition: app_queue.c:1667
int() ao2_callback_fn(void *obj, void *arg, int flags)
Type of a generic callback function.
Definition: astobj2.h:1226
Standard Command Line Interface.
static const char name[]
Definition: format_mp3.c:68
static int regex(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
struct ao2_container * container
Definition: res_fax.c:501
int ast_sip_unregister_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Unregisters a CLI formatter.
Definition: pjsip_cli.c:326
int ast_sip_cli_print_sorcery_objectset(void *obj, void *arg, int flags)
Prints a sorcery object's ast_variable list.
Definition: pjsip_cli.c:36
struct ast_sip_cli_formatter_entry * ast_sip_lookup_cli_formatter(const char *name)
Looks up a CLI formatter by type.
Definition: pjsip_cli.c:305
char * ast_sip_cli_traverse_objects(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Definition: pjsip_cli.c:109
int ast_sip_register_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Registers a CLI formatter.
Definition: pjsip_cli.c:310
Generic container type.
descriptor for a cli entry.
Definition: cli.h:171
CLI Formatter Context passed to all formatters.
Definition: res_pjsip_cli.h:34
unsigned show_details_only_level_0
Definition: res_pjsip_cli.h:46
struct ast_str * output_buffer
Definition: res_pjsip_cli.h:36
CLI Formatter Registry Entry.
Definition: res_pjsip_cli.h:52
int(* iterate)(void *container, ao2_callback_fn callback, void *args)
Definition: res_pjsip_cli.h:66
ao2_callback_fn * print_header
Definition: res_pjsip_cli.h:60
const char * name
Definition: res_pjsip_cli.h:58
ao2_callback_fn * print_body
Definition: res_pjsip_cli.h:62
Support for dynamic strings.
Definition: strings.h:623
const char * args
static struct test_val a