Wed Jan 8 2020 09:49:51

Asterisk developer's documentation


term.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2005, Digium, Inc.
5  *
6  * Mark Spencer <markster@digium.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 /*! \file
20  * \brief Handy terminal functions for vt* terms
21  */
22 
23 #ifndef _ASTERISK_TERM_H
24 #define _ASTERISK_TERM_H
25 
26 #if defined(__cplusplus) || defined(c_plusplus)
27 extern "C" {
28 #endif
29 
30 #define ESC 0x1b
31 
32 /*! \name Terminal Attributes
33 */
34 /*@{ */
35 #define ATTR_RESET 0
36 #define ATTR_BRIGHT 1
37 #define ATTR_DIM 2
38 #define ATTR_UNDER 4
39 #define ATTR_BLINK 5
40 #define ATTR_REVER 7
41 #define ATTR_HIDDEN 8
42 /*@} */
43 
44 /*! \name Terminal Colors
45 */
46 /*@{ */
47 #define COLOR_BLACK 30
48 #define COLOR_GRAY (30 | 128)
49 #define COLOR_RED 31
50 #define COLOR_BRRED (31 | 128)
51 #define COLOR_GREEN 32
52 #define COLOR_BRGREEN (32 | 128)
53 #define COLOR_BROWN 33
54 #define COLOR_YELLOW (33 | 128)
55 #define COLOR_BLUE 34
56 #define COLOR_BRBLUE (34 | 128)
57 #define COLOR_MAGENTA 35
58 #define COLOR_BRMAGENTA (35 | 128)
59 #define COLOR_CYAN 36
60 #define COLOR_BRCYAN (36 | 128)
61 #define COLOR_WHITE 37
62 #define COLOR_BRWHITE (37 | 128)
63 /*@} */
64 
65 /*! \brief Maximum number of characters needed for a color escape sequence,
66  * plus a null char */
67 #define AST_TERM_MAX_ESCAPE_CHARS 23
68 
69 char *term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout);
70 
71 /*!
72  * \brief Append a color sequence to an ast_str
73  *
74  * \param str The string to append to
75  * \param fgcolor foreground color
76  * \param bgcolor background color
77  *
78  * \retval 0 success
79  * \retval -1 failure
80  */
81 int ast_term_color_code(struct ast_str **str, int fgcolor, int bgcolor);
82 
83 /*!
84  * \brief Write a color sequence to a string
85  *
86  * \param outbuf the location to write to
87  * \param fgcolor foreground color
88  * \param bgcolor background color
89  * \param maxout maximum number of characters to write
90  *
91  * \return outbuf
92  */
93 char *term_color_code(char *outbuf, int fgcolor, int bgcolor, int maxout);
94 
95 char *term_strip(char *outbuf, const char *inbuf, int maxout);
96 
97 void term_filter_escapes(char *line);
98 
99 char *term_prompt(char *outbuf, const char *inbuf, int maxout);
100 
101 char *term_prep(void);
102 
103 char *term_end(void);
104 
105 char *term_quit(void);
106 
107 #if defined(__cplusplus) || defined(c_plusplus)
108 }
109 #endif
110 
111 #endif /* _ASTERISK_TERM_H */
int ast_term_color_code(struct ast_str **str, int fgcolor, int bgcolor)
Append a color sequence to an ast_str.
Definition: term.c:242
char * term_strip(char *outbuf, const char *inbuf, int maxout)
Definition: term.c:287
const char * str
Definition: app_jack.c:144
static int inbuf(struct baseio *bio, FILE *fi)
utility used by inchar(), for base_encode()
char * term_prep(void)
Definition: term.c:360
char * term_color_code(char *outbuf, int fgcolor, int bgcolor, int maxout)
Write a color sequence to a string.
Definition: term.c:264
void term_filter_escapes(char *line)
Definition: term.c:338
char * term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout)
Definition: term.c:184
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:364
char * term_prompt(char *outbuf, const char *inbuf, int maxout)
Definition: term.c:309
char * term_end(void)
Definition: term.c:365
char * term_quit(void)
Definition: term.c:370