#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/time.h>#include <signal.h>#include <errno.h>#include <unistd.h>#include <asterisk/term.h>#include <asterisk/options.h>#include <asterisk/lock.h>#include "asterisk.h"Go to the source code of this file.
Functions | |
| int | term_init (void) |
| char * | term_color (char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout) |
| char * | term_color_code (char *outbuf, int fgcolor, int bgcolor, int maxout) |
| char * | term_strip (char *outbuf, char *inbuf, int maxout) |
| char * | term_prompt (char *outbuf, const char *inbuf, int maxout) |
| char * | term_prep (void) |
| char * | term_end (void) |
| char * | term_quit (void) |
|
||||||||||||||||||||||||
|
Definition at line 58 of file term.c. References ATTR_BRIGHT, COLOR_BLACK, COLOR_WHITE, and ESC. Referenced by ast_frame_dump(), ast_load_resource(), ast_log(), ast_register_application(), ast_register_translator(), ast_unregister_translator(), load_modules(), and main(). 00059 {
00060 int attr=0;
00061 char tmp[40];
00062 if (!vt100compat) {
00063 strncpy(outbuf, inbuf, maxout -1);
00064 return outbuf;
00065 }
00066 if (!fgcolor && !bgcolor) {
00067 strncpy(outbuf, inbuf, maxout - 1);
00068 return outbuf;
00069 }
00070 if ((fgcolor & 128) && (bgcolor & 128)) {
00071 /* Can't both be highlighted */
00072 strncpy(outbuf, inbuf, maxout - 1);
00073 return outbuf;
00074 }
00075 if (!bgcolor)
00076 bgcolor = COLOR_BLACK;
00077
00078 if (bgcolor) {
00079 bgcolor &= ~128;
00080 bgcolor += 10;
00081 }
00082 if (fgcolor & 128) {
00083 attr = ATTR_BRIGHT;
00084 fgcolor &= ~128;
00085 }
00086 if (fgcolor && bgcolor) {
00087 snprintf(tmp, sizeof(tmp), "%d;%d", fgcolor, bgcolor);
00088 } else if (bgcolor) {
00089 snprintf(tmp, sizeof(tmp), "%d", bgcolor);
00090 } else if (fgcolor) {
00091 snprintf(tmp, sizeof(tmp), "%d", fgcolor);
00092 }
00093 if (attr) {
00094 snprintf(outbuf, maxout, "%c[%d;%sm%s%c[0;%d;%dm", ESC, attr, tmp, inbuf, ESC, COLOR_WHITE, COLOR_BLACK + 10);
00095 } else {
00096 snprintf(outbuf, maxout, "%c[%sm%s%c[0;%d;%dm", ESC, tmp, inbuf, ESC, COLOR_WHITE, COLOR_BLACK + 10);
00097 }
00098 return outbuf;
00099 }
|
|
||||||||||||||||||||
|
Definition at line 101 of file term.c. References ATTR_BRIGHT, COLOR_BLACK, and ESC. 00102 {
00103 int attr=0;
00104 char tmp[40];
00105 if ((!vt100compat) || (!fgcolor && !bgcolor)) {
00106 *outbuf = '\0';
00107 return outbuf;
00108 }
00109 if ((fgcolor & 128) && (bgcolor & 128)) {
00110 /* Can't both be highlighted */
00111 *outbuf = '\0';
00112 return outbuf;
00113 }
00114 if (!bgcolor)
00115 bgcolor = COLOR_BLACK;
00116
00117 if (bgcolor) {
00118 bgcolor &= ~128;
00119 bgcolor += 10;
00120 }
00121 if (fgcolor & 128) {
00122 attr = ATTR_BRIGHT;
00123 fgcolor &= ~128;
00124 }
00125 if (fgcolor && bgcolor) {
00126 snprintf(tmp, sizeof(tmp), "%d;%d", fgcolor, bgcolor);
00127 } else if (bgcolor) {
00128 snprintf(tmp, sizeof(tmp), "%d", bgcolor);
00129 } else if (fgcolor) {
00130 snprintf(tmp, sizeof(tmp), "%d", fgcolor);
00131 }
00132 if (attr) {
00133 snprintf(outbuf, maxout, "%c[%d;%sm", ESC, attr, tmp);
00134 } else {
00135 snprintf(outbuf, maxout, "%c[%sm", ESC, tmp);
00136 }
00137 return outbuf;
00138 }
|
|
|
Definition at line 180 of file term.c. Referenced by main(). 00181 {
00182 return enddata;
00183 }
|
|
|
Definition at line 32 of file term.c. References ATTR_BRIGHT, ATTR_RESET, COLOR_BLACK, COLOR_BROWN, COLOR_WHITE, ESC, option_console, option_nocolor, and option_nofork. Referenced by main(). 00033 {
00034 char *term = getenv("TERM");
00035 if (!term)
00036 return 0;
00037 if (!option_console || option_nocolor || !option_nofork)
00038 return 0;
00039 if (!strncasecmp(term, "linux", 5))
00040 vt100compat = 1; else
00041 if (!strncasecmp(term, "xterm", 5))
00042 vt100compat = 1; else
00043 if (!strncasecmp(term, "Eterm", 5))
00044 vt100compat = 1; else
00045 if (!strncasecmp(term, "crt", 3))
00046 vt100compat = 1; else
00047 if (!strncasecmp(term, "vt", 2))
00048 vt100compat = 1;
00049 if (vt100compat) {
00050 /* Make commands show up in nice colors */
00051 snprintf(prepdata, sizeof(prepdata), "%c[%d;%d;%dm", ESC, ATTR_BRIGHT, COLOR_BROWN, COLOR_BLACK + 10);
00052 snprintf(enddata, sizeof(enddata), "%c[%d;%d;%dm", ESC, ATTR_RESET, COLOR_WHITE, COLOR_BLACK + 10);
00053 snprintf(quitdata, sizeof(quitdata), "%c[0m", ESC);
00054 }
00055 return 0;
00056 }
|
|
|
Definition at line 175 of file term.c. 00176 {
00177 return prepdata;
00178 }
|
|
||||||||||||||||
|
Definition at line 161 of file term.c. References ATTR_BRIGHT, COLOR_BLACK, COLOR_BLUE, COLOR_WHITE, and ESC. 00162 {
00163 if (!vt100compat) {
00164 strncpy(outbuf, inbuf, maxout -1);
00165 return outbuf;
00166 }
00167 snprintf(outbuf, maxout, "%c[%d;%d;%dm%c%c[%d;%d;%dm%s",
00168 ESC, ATTR_BRIGHT, COLOR_BLUE, COLOR_BLACK + 10,
00169 inbuf[0],
00170 ESC, 0, COLOR_WHITE, COLOR_BLACK + 10,
00171 inbuf + 1);
00172 return outbuf;
00173 }
|
|
|
Definition at line 185 of file term.c. Referenced by main(). 00186 {
00187 return quitdata;
00188 }
|
|
||||||||||||||||
|
Definition at line 140 of file term.c. References ESC. 00141 {
00142 char *outbuf_ptr = outbuf, *inbuf_ptr = inbuf;
00143
00144 while (outbuf_ptr < outbuf + maxout) {
00145 switch (*inbuf_ptr) {
00146 case ESC:
00147 while (*inbuf_ptr && (*inbuf_ptr != 'm'))
00148 inbuf_ptr++;
00149 break;
00150 default:
00151 *outbuf_ptr = *inbuf_ptr;
00152 outbuf_ptr++;
00153 }
00154 if (! *inbuf_ptr)
00155 break;
00156 inbuf_ptr++;
00157 }
00158 return outbuf;
00159 }
|
1.4.2