Thu Apr 28 2011 17:13:36

Asterisk developer's documentation


term.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 1999 - 2005, Digium, Inc.
00005  *
00006  * Mark Spencer <markster@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! \file
00020  * \brief Handy terminal functions for vt* terms
00021  */
00022 
00023 #ifndef _ASTERISK_TERM_H
00024 #define _ASTERISK_TERM_H
00025 
00026 #if defined(__cplusplus) || defined(c_plusplus)
00027 extern "C" {
00028 #endif
00029 
00030 #define ESC 0x1b
00031 
00032 /*! \name Terminal Attributes 
00033 */
00034 /*@{ */
00035 #define ATTR_RESET   0
00036 #define ATTR_BRIGHT  1
00037 #define ATTR_DIM  2
00038 #define ATTR_UNDER   4
00039 #define ATTR_BLINK   5
00040 #define ATTR_REVER   7
00041 #define ATTR_HIDDEN  8
00042 /*@} */
00043 
00044 /*! \name Terminal Colors
00045 */
00046 /*@{ */
00047 #define COLOR_BLACK  30
00048 #define COLOR_GRAY   (30 | 128)
00049 #define COLOR_RED 31
00050 #define COLOR_BRRED  (31 | 128)
00051 #define COLOR_GREEN  32
00052 #define COLOR_BRGREEN   (32 | 128)
00053 #define COLOR_BROWN  33
00054 #define COLOR_YELLOW (33 | 128)
00055 #define COLOR_BLUE   34
00056 #define COLOR_BRBLUE (34 | 128)
00057 #define COLOR_MAGENTA   35
00058 #define COLOR_BRMAGENTA (35 | 128)
00059 #define COLOR_CYAN      36
00060 #define COLOR_BRCYAN    (36 | 128)
00061 #define COLOR_WHITE     37
00062 #define COLOR_BRWHITE   (37 | 128)
00063 /*@} */
00064 
00065 /*! \brief Maximum number of characters needed for a color escape sequence,
00066  *         plus a null char */
00067 #define AST_TERM_MAX_ESCAPE_CHARS   23
00068 
00069 char *term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout);
00070 
00071 /*!
00072  * \brief Append a color sequence to an ast_str
00073  *
00074  * \param str The string to append to
00075  * \param fgcolor foreground color
00076  * \param bgcolor background color
00077  *
00078  * \retval 0 success
00079  * \retval -1 failure
00080  */
00081 int ast_term_color_code(struct ast_str **str, int fgcolor, int bgcolor);
00082 
00083 /*!
00084  * \brief Write a color sequence to a string
00085  *
00086  * \param outbuf the location to write to
00087  * \param fgcolor foreground color
00088  * \param bgcolor background color
00089  * \param maxout maximum number of characters to write
00090  *
00091  * \return outbuf
00092  */
00093 char *term_color_code(char *outbuf, int fgcolor, int bgcolor, int maxout);
00094 
00095 char *term_strip(char *outbuf, char *inbuf, int maxout);
00096 
00097 void term_filter_escapes(char *line);
00098 
00099 char *term_prompt(char *outbuf, const char *inbuf, int maxout);
00100 
00101 char *term_prep(void);
00102 
00103 char *term_end(void);
00104 
00105 char *term_quit(void);
00106 
00107 #if defined(__cplusplus) || defined(c_plusplus)
00108 }
00109 #endif
00110 
00111 #endif /* _ASTERISK_TERM_H */