| Asterisk - The Open Source Telephony Project GIT-master-27fb039
    | 
Terminal Routines. More...
#include "asterisk.h"#include "asterisk/_private.h"#include <sys/time.h>#include <signal.h>#include <sys/stat.h>#include <fcntl.h>#include "asterisk/term.h"#include "asterisk/lock.h"#include "asterisk/utils.h"#include "asterisk/threadstorage.h"
Go to the source code of this file.
| Data Structures | |
| struct | commonbuf | 
| Macros | |
| #define | HEADER_LEN (12) | 
| #define | MAGIC_EXTNUM (01036) | 
| #define | MAGIC_LEGACY (00432) | 
| #define | MAX_COLORS_INDEX (13) | 
| Functions | |
| const char * | ast_term_color (int fgcolor, int bgcolor) | 
| Return a color sequence string. | |
| int | ast_term_color_code (struct ast_str **str, int fgcolor, int bgcolor) | 
| Append a color sequence to an ast_str. | |
| int | ast_term_init (void) | 
| const char * | ast_term_reset (void) | 
| Returns the terminal reset code. | |
| AST_THREADSTORAGE_CUSTOM_SCOPE (commonbuf, NULL, ast_free_ptr, static) | |
| static void | check_bgcolor (int *bgcolor) | 
| static int | check_colors_allowed (void) | 
| static void | check_fgcolor (int *fgcolor, int *attr) | 
| static int | convint (unsigned char *s) | 
| static short | convshort (unsigned char *s) | 
| static int | opposite (int color) | 
| static int | parse_terminfo_file (int fd) | 
| char * | term_color (char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout) | 
| Colorize a specified string by adding terminal color codes. | |
| char * | term_color_code (char *outbuf, int fgcolor, int bgcolor, int maxout) | 
| Write a color sequence to a string. | |
| const char * | term_end (void) | 
| void | term_filter_escapes (char *line) | 
| const char * | term_quit (void) | 
| char * | term_strip (char *outbuf, const char *inbuf, int maxout) | 
| Remove colorings from a specified string. | |
| Variables | |
| static char | enddata [80] = "" | 
| static char | quitdata [80] = "" | 
| static const char *const | termpath [] | 
| static int | vt100compat | 
Terminal Routines.
Definition in file term.c.
| const char * ast_term_color | ( | int | fgcolor, | 
| int | bgcolor | ||
| ) | 
Return a color sequence string.
| fgcolor | foreground color | 
| bgcolor | background color | 
Definition at line 341 of file term.c.
References AST_TERM_MAX_ESCAPE_CHARS, AST_TERM_MAX_ROTATING_BUFFERS, ast_threadstorage_get(), buf, commonbuf::buffer, term_color_code(), and commonbuf::which.
Referenced by cli_show_module_options(), cli_show_module_type(), handle_cli_agi_show(), handle_show_function(), handle_showmancmd(), print_app_docs(), print_event_instance(), print_queue(), and set_header().
| int ast_term_color_code | ( | struct ast_str ** | str, | 
| int | fgcolor, | ||
| int | bgcolor | ||
| ) | 
Append a color sequence to an ast_str.
| str | The string to append to | 
| fgcolor | foreground color | 
| bgcolor | background color | 
| 0 | success | 
| -1 | failure | 
Definition at line 296 of file term.c.
References ast_opt_force_black_background, ast_str_append(), check_bgcolor(), check_colors_allowed(), check_fgcolor(), COLOR_BLACK, ESC, and str.
Referenced by ast_xmldoc_printable(), and cli_prompt().
| int ast_term_init | ( | void | ) | 
Provided by term.c
Definition at line 165 of file term.c.
References ast_opt_console, ast_opt_force_black_background, ast_opt_light_background, ast_opt_no_color, ATTR_RESET, COLOR_BLACK, COLOR_WHITE, end, enddata, ESC, parse_terminfo_file(), quitdata, termpath, and vt100compat.
Referenced by ast_remotecontrol(), asterisk_daemon(), and main().
| const char * ast_term_reset | ( | void | ) | 
Returns the terminal reset code.
Definition at line 357 of file term.c.
References term_end().
Referenced by ast_xmldoc_printable(), cli_show_module_options(), cli_show_module_type(), handle_cli_agi_show(), handle_show_function(), handle_showmancmd(), print_app_docs(), print_event_instance(), print_queue(), and set_header().
| AST_THREADSTORAGE_CUSTOM_SCOPE | ( | commonbuf | , | 
| NULL | , | ||
| ast_free_ptr | , | ||
| static | |||
| ) | 
| 
 | static | 
Definition at line 284 of file term.c.
Referenced by ast_term_color_code(), and term_color_code().
| 
 | static | 
Definition at line 291 of file term.c.
References vt100compat.
Referenced by ast_term_color_code(), and term_color_code().
| 
 | static | 
Definition at line 272 of file term.c.
References ast_opt_light_background, ATTR_BRIGHT, and opposite().
Referenced by ast_term_color_code(), and term_color_code().
| 
 | inlinestatic | 
Definition at line 92 of file term.c.
Referenced by parse_terminfo_file().
| 
 | static | 
Definition at line 77 of file term.c.
Referenced by parse_terminfo_file().
| 
 | static | 
Definition at line 62 of file term.c.
References COLOR_BLACK, COLOR_BLUE, COLOR_BROWN, COLOR_CYAN, COLOR_GREEN, COLOR_MAGENTA, and COLOR_RED.
Referenced by check_fgcolor(), and term_color().
| 
 | static | 
Definition at line 106 of file term.c.
References convint(), convshort(), HEADER_LEN, MAGIC_EXTNUM, MAGIC_LEGACY, MAX_COLORS_INDEX, and vt100compat.
Referenced by ast_term_init().
| char * term_color | ( | char * | outbuf, | 
| const char * | inbuf, | ||
| int | fgcolor, | ||
| int | bgcolor, | ||
| int | maxout | ||
| ) | 
Colorize a specified string by adding terminal color codes.
| outbuf | Result buffer | 
| inbuf | Starting string | 
| fgcolor | Foreground color, specified as one of the constants in include/asterisk/term.h. Use '0' if the want the normal terminal foreground color. | 
| bgcolor | Background color, specified as one of the constants in include/asterisk/term.h. Use '0' if you want the normal terminal background color. | 
| maxout | Maximum size of outbuf | 
Definition at line 235 of file term.c.
References ast_copy_string(), ast_opt_force_black_background, ast_opt_light_background, ATTR_BRIGHT, COLOR_BLACK, ESC, inbuf(), opposite(), term_end(), and vt100compat.
Referenced by __ast_register_translator(), ast_frame_dump(), ast_unregister_translator(), handle_dahdi_show_cadences(), lua_pbx_exec(), realtime_exec(), and start_resource().
| char * term_color_code | ( | char * | outbuf, | 
| int | fgcolor, | ||
| int | bgcolor, | ||
| int | maxout | ||
| ) | 
Write a color sequence to a string.
| outbuf | the location to write to | 
| fgcolor | foreground color | 
| bgcolor | background color | 
| maxout | maximum number of characters to write | 
Definition at line 318 of file term.c.
References ast_opt_force_black_background, check_bgcolor(), check_colors_allowed(), check_fgcolor(), COLOR_BLACK, and ESC.
Referenced by ast_term_color().
| const char * term_end | ( | void | ) | 
Definition at line 407 of file term.c.
References enddata.
Referenced by ast_remotecontrol(), ast_term_reset(), asterisk_daemon(), consolehandler(), main(), and term_color().
| void term_filter_escapes | ( | char * | line | ) | 
Definition at line 385 of file term.c.
| const char * term_quit | ( | void | ) | 
Definition at line 412 of file term.c.
References quitdata.
Referenced by ast_el_read_char(), check_init(), main(), and really_quit().
| char * term_strip | ( | char * | outbuf, | 
| const char * | inbuf, | ||
| int | maxout | ||
| ) | 
Remove colorings from a specified string.
| outbuf | the location to write to | 
| inbuf | the original string | 
| maxout | the available size of outbuf | 
Definition at line 362 of file term.c.
Referenced by action_command(), format_log_default(), format_log_json(), and format_log_plain().
| 
 | static | 
Definition at line 45 of file term.c.
Referenced by ast_term_init(), and term_end().
| 
 | static | 
Definition at line 46 of file term.c.
Referenced by ast_term_init(), and term_quit().
| 
 | static | 
Definition at line 48 of file term.c.
Referenced by ast_term_init().
| 
 | static | 
Definition at line 43 of file term.c.
Referenced by ast_term_init(), check_colors_allowed(), parse_terminfo_file(), and term_color().