Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

term.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Defines

#define ESC   0x1b
#define ATTR_RESET   0
#define ATTR_BRIGHT   1
#define ATTR_DIM   2
#define ATTR_UNDER   4
#define ATTR_BLINK   5
#define ATTR_REVER   7
#define ATTR_HIDDEN   8
#define COLOR_BLACK   30
#define COLOR_GRAY   30 | 128
#define COLOR_RED   31
#define COLOR_BRRED   31 | 128
#define COLOR_GREEN   32
#define COLOR_BRGREEN   32 | 128
#define COLOR_BROWN   33
#define COLOR_YELLOW   33 | 128
#define COLOR_BLUE   34
#define COLOR_BRBLUE   34 | 128
#define COLOR_MAGENTA   35
#define COLOR_BRMAGENTA   35 | 128
#define COLOR_CYAN   36
#define COLOR_BRCYAN   36 | 128
#define COLOR_WHITE   37
#define COLOR_BRWHITE   37 | 128

Functions

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)


Define Documentation

#define ATTR_BLINK   5
 

Definition at line 26 of file term.h.

#define ATTR_BRIGHT   1
 

Definition at line 23 of file term.h.

Referenced by term_color(), term_color_code(), term_init(), and term_prompt().

#define ATTR_DIM   2
 

Definition at line 24 of file term.h.

#define ATTR_HIDDEN   8
 

Definition at line 28 of file term.h.

#define ATTR_RESET   0
 

Definition at line 22 of file term.h.

Referenced by term_init().

#define ATTR_REVER   7
 

Definition at line 27 of file term.h.

#define ATTR_UNDER   4
 

Definition at line 25 of file term.h.

#define COLOR_BLACK   30
 

Definition at line 30 of file term.h.

Referenced by ast_frame_dump(), ast_load_resource(), ast_register_translator(), ast_unregister_translator(), main(), term_color(), term_color_code(), term_init(), and term_prompt().

#define COLOR_BLUE   34
 

Definition at line 38 of file term.h.

Referenced by term_prompt().

#define COLOR_BRBLUE   34 | 128
 

Definition at line 39 of file term.h.

#define COLOR_BRCYAN   36 | 128
 

Definition at line 43 of file term.h.

Referenced by ast_frame_dump(), and ast_register_application().

#define COLOR_BRGREEN   32 | 128
 

Definition at line 35 of file term.h.

Referenced by ast_frame_dump().

#define COLOR_BRMAGENTA   35 | 128
 

Definition at line 41 of file term.h.

Referenced by ast_frame_dump().

#define COLOR_BROWN   33
 

Definition at line 36 of file term.h.

Referenced by ast_load_resource(), and term_init().

#define COLOR_BRRED   31 | 128
 

Definition at line 33 of file term.h.

Referenced by ast_frame_dump().

#define COLOR_BRWHITE   37 | 128
 

Definition at line 45 of file term.h.

Referenced by ast_log(), load_modules(), and main().

#define COLOR_CYAN   36
 

Definition at line 42 of file term.h.

#define COLOR_GRAY   30 | 128
 

Definition at line 31 of file term.h.

#define COLOR_GREEN   32
 

Definition at line 34 of file term.h.

#define COLOR_MAGENTA   35
 

Definition at line 40 of file term.h.

Referenced by ast_register_translator(), and ast_unregister_translator().

#define COLOR_RED   31
 

Definition at line 32 of file term.h.

#define COLOR_WHITE   37
 

Definition at line 44 of file term.h.

Referenced by term_color(), term_init(), and term_prompt().

#define COLOR_YELLOW   33 | 128
 

Definition at line 37 of file term.h.

Referenced by ast_frame_dump().

#define ESC   0x1b
 

Definition at line 21 of file term.h.

Referenced by term_color(), term_color_code(), term_init(), term_prompt(), and term_strip().


Function Documentation

char* term_color char *  outbuf,
const char *  inbuf,
int  fgcolor,
int  bgcolor,
int  maxout
 

Definition at line 56 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().

00057 { 00058 int attr=0; 00059 char tmp[40]; 00060 if (!vt100compat) { 00061 strncpy(outbuf, inbuf, maxout -1); 00062 return outbuf; 00063 } 00064 if (!fgcolor && !bgcolor) { 00065 strncpy(outbuf, inbuf, maxout - 1); 00066 return outbuf; 00067 } 00068 if ((fgcolor & 128) && (bgcolor & 128)) { 00069 /* Can't both be highlighted */ 00070 strncpy(outbuf, inbuf, maxout - 1); 00071 return outbuf; 00072 } 00073 if (!bgcolor) 00074 bgcolor = COLOR_BLACK; 00075 00076 if (bgcolor) { 00077 bgcolor &= ~128; 00078 bgcolor += 10; 00079 } 00080 if (fgcolor & 128) { 00081 attr = ATTR_BRIGHT; 00082 fgcolor &= ~128; 00083 } 00084 if (fgcolor && bgcolor) { 00085 snprintf(tmp, sizeof(tmp), "%d;%d", fgcolor, bgcolor); 00086 } else if (bgcolor) { 00087 snprintf(tmp, sizeof(tmp), "%d", bgcolor); 00088 } else if (fgcolor) { 00089 snprintf(tmp, sizeof(tmp), "%d", fgcolor); 00090 } 00091 if (attr) { 00092 snprintf(outbuf, maxout, "%c[%d;%sm%s%c[0;%d;%dm", ESC, attr, tmp, inbuf, ESC, COLOR_WHITE, COLOR_BLACK + 10); 00093 } else { 00094 snprintf(outbuf, maxout, "%c[%sm%s%c[0;%d;%dm", ESC, tmp, inbuf, ESC, COLOR_WHITE, COLOR_BLACK + 10); 00095 } 00096 return outbuf; 00097 }

char* term_color_code char *  outbuf,
int  fgcolor,
int  bgcolor,
int  maxout
 

Definition at line 99 of file term.c.

References ATTR_BRIGHT, COLOR_BLACK, and ESC.

00100 { 00101 int attr=0; 00102 char tmp[40]; 00103 if ((!vt100compat) || (!fgcolor && !bgcolor)) { 00104 *outbuf = '\0'; 00105 return outbuf; 00106 } 00107 if ((fgcolor & 128) && (bgcolor & 128)) { 00108 /* Can't both be highlighted */ 00109 *outbuf = '\0'; 00110 return outbuf; 00111 } 00112 if (!bgcolor) 00113 bgcolor = COLOR_BLACK; 00114 00115 if (bgcolor) { 00116 bgcolor &= ~128; 00117 bgcolor += 10; 00118 } 00119 if (fgcolor & 128) { 00120 attr = ATTR_BRIGHT; 00121 fgcolor &= ~128; 00122 } 00123 if (fgcolor && bgcolor) { 00124 snprintf(tmp, sizeof(tmp), "%d;%d", fgcolor, bgcolor); 00125 } else if (bgcolor) { 00126 snprintf(tmp, sizeof(tmp), "%d", bgcolor); 00127 } else if (fgcolor) { 00128 snprintf(tmp, sizeof(tmp), "%d", fgcolor); 00129 } 00130 if (attr) { 00131 snprintf(outbuf, maxout, "%c[%d;%sm", ESC, attr, tmp); 00132 } else { 00133 snprintf(outbuf, maxout, "%c[%sm", ESC, tmp); 00134 } 00135 return outbuf; 00136 }

char* term_end void   ) 
 

Definition at line 178 of file term.c.

Referenced by main().

00179 { 00180 return enddata; 00181 }

char* term_prep void   ) 
 

Definition at line 173 of file term.c.

00174 { 00175 return prepdata; 00176 }

char* term_prompt char *  outbuf,
const char *  inbuf,
int  maxout
 

Definition at line 159 of file term.c.

References ATTR_BRIGHT, COLOR_BLACK, COLOR_BLUE, COLOR_WHITE, and ESC.

00160 { 00161 if (!vt100compat) { 00162 strncpy(outbuf, inbuf, maxout -1); 00163 return outbuf; 00164 } 00165 snprintf(outbuf, maxout, "%c[%d;%d;%dm%c%c[%d;%d;%dm%s", 00166 ESC, ATTR_BRIGHT, COLOR_BLUE, COLOR_BLACK + 10, 00167 inbuf[0], 00168 ESC, 0, COLOR_WHITE, COLOR_BLACK + 10, 00169 inbuf + 1); 00170 return outbuf; 00171 }

char* term_quit void   ) 
 

Definition at line 183 of file term.c.

Referenced by main().

00184 { 00185 return quitdata; 00186 }

char* term_strip char *  outbuf,
char *  inbuf,
int  maxout
 

Definition at line 138 of file term.c.

References ESC.

00139 { 00140 char *outbuf_ptr = outbuf, *inbuf_ptr = inbuf; 00141 00142 while (outbuf_ptr < outbuf + maxout) { 00143 switch (*inbuf_ptr) { 00144 case ESC: 00145 while (*inbuf_ptr && (*inbuf_ptr != 'm')) 00146 inbuf_ptr++; 00147 break; 00148 default: 00149 *outbuf_ptr = *inbuf_ptr; 00150 outbuf_ptr++; 00151 } 00152 if (! *inbuf_ptr) 00153 break; 00154 inbuf_ptr++; 00155 } 00156 return outbuf; 00157 }


Generated on Sat Jun 12 16:41:48 2004 for Asterisk by doxygen 1.3.7