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

term.h File Reference

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 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 }

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

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 }

char* term_end void   ) 
 

Definition at line 180 of file term.c.

Referenced by main().

00181 { 00182 return enddata; 00183 }

char* term_prep void   ) 
 

Definition at line 175 of file term.c.

00176 { 00177 return prepdata; 00178 }

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

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 }

char* term_quit void   ) 
 

Definition at line 185 of file term.c.

Referenced by main().

00186 { 00187 return quitdata; 00188 }

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

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 }


Generated on Fri Sep 24 21:03:54 2004 for Asterisk by doxygen 1.3.8