Asterisk - The Open Source Telephony Project  18.5.0
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 <[email protected]>
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 name The name of the formatter, usually the sorcery object type.
77  * \param formatter An ao2_callback_fn that outputs the formatted data.
78  * \retval 0 Success, non-zero on failure
79  */
81 
82 /*!
83  * \brief Unregisters a CLI formatter.
84  *
85  * \param name The name of the formatter, usually the sorcery object type.
86  * \retval 0 Success, non-zero on failure
87  */
89 
90 /*!
91  * \brief Looks up a CLI formatter by type.
92  *
93  * \param name The name of the formatter, usually the sorcery object type.
94  * \retval Pointer to formatter entry structure
95  */
97 
98 /*!
99  * \brief Prints a sorcery object's ast_variable list
100  *
101  * \param obj The sorcery object
102  * \param arg The ast_sip_cli_context.
103  * \retval 0 Success, non-zero on failure
104  */
105 int ast_sip_cli_print_sorcery_objectset(void *obj, void *arg, int flags);
106 
107 char *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_ */
struct ast_str * output_buffer
Definition: res_pjsip_cli.h:36
Definition: res_pjsip_cli.h:52
descriptor for a cli entry.
Definition: cli.h:171
const char * args
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
int() ao2_callback_fn(void *obj, void *arg, int flags)
Type of a generic callback function.
Definition: astobj2.h:1230
struct ao2_container * container
Definition: res_fax.c:502
int ast_sip_unregister_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Unregisters a CLI formatter.
Definition: pjsip_cli.c:326
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
static const char name[]
Definition: cdr_mysql.c:74
static int regex(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
Definition: func_strings.c:948
Standard Command Line Interface.
ao2_callback_fn * print_header
Definition: res_pjsip_cli.h:60
enum queue_result id
Definition: app_queue.c:1507
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
Generic container type.
ao2_callback_fn * print_body
Definition: res_pjsip_cli.h:62
int ast_sip_cli_print_sorcery_objectset(void *obj, void *arg, int flags)
Prints a sorcery object&#39;s ast_variable list.
Definition: pjsip_cli.c:36
const char * name
Definition: res_pjsip_cli.h:58
unsigned show_details_only_level_0
Definition: res_pjsip_cli.h:46
static struct test_val a