49    "/usr/share/terminfo",
 
   50    "/usr/local/share/misc/terminfo",
 
 
   73    return color ? lookup[color - 30] : 0;
 
 
   81    a = (int) s[0] & 0377;
 
   82    b = (int) s[1] & 0377;
 
   84    if (
a == 0377 && 
b == 0377)
 
   86    if (
a == 0376 && 
b == 0377)
 
 
   92static inline int convint(
unsigned char *s)
 
 
  100#define MAGIC_LEGACY (00432) 
  101#define MAGIC_EXTNUM (01036) 
  103#define HEADER_LEN (12) 
  104#define MAX_COLORS_INDEX (13) 
  108    int bytes_read, bytes_needed, num_size;
 
  109    short magic, sz_names, sz_bools;
 
  110    unsigned char buffer[1024];
 
  112    bytes_read = read(fd, buffer, 
sizeof(buffer));
 
  136    if ((sz_names + sz_bools) & 1) {
 
  141    if (bytes_needed <= bytes_read) {
 
  152            max_colors = 
convint(buffer + offset);
 
  155        if (max_colors > 0) {
 
 
  167    char *term = getenv(
"TERM");
 
  168    char termfile[256] = 
"";
 
  169    int termfd = -1, parseokay = 0, i;
 
  185    for (i = 0; !parseokay && 
termpath[i]; i++) {
 
  186        snprintf(termfile, 
sizeof(termfile), 
"%s/%c/%s", 
termpath[i], *term, term);
 
  188        termfd = open(termfile, O_RDONLY);
 
  201        if (!strcmp(term, 
"linux")) {
 
  203        } 
else if (!strcmp(term, 
"xterm")) {
 
  205        } 
else if (!strcmp(term, 
"xterm-color")) {
 
  207        } 
else if (!strcmp(term, 
"xterm-256color")) {
 
  209        } 
else if (!strncmp(term, 
"Eterm", 5)) {
 
  212        } 
else if (!strcmp(term, 
"vt100")) {
 
  214        } 
else if (!strncmp(term, 
"crt", 3)) {
 
 
  235char *
term_color(
char *outbuf, 
const char *
inbuf, 
int fgcolor, 
int bgcolor, 
int maxout)
 
  265        snprintf(outbuf, maxout, 
"%c[%d;%d;%dm%s%s", 
ESC, attr, fgcolor, bgcolor + 10, 
inbuf, 
term_end());
 
  267        snprintf(outbuf, maxout, 
"%c[%d;%dm%s%s", 
ESC, attr, fgcolor, 
inbuf, 
term_end());
 
 
  275    if (*fgcolor & 128) {
 
 
  309    } 
else if (bgcolor) {
 
 
  331        snprintf(outbuf, maxout, 
"%c[%d;%d;%dm", 
ESC, attr, fgcolor, 
COLOR_BLACK + 10);
 
  332    } 
else if (bgcolor) {
 
  333        snprintf(outbuf, maxout, 
"%c[%d;%d;%dm", 
ESC, attr, fgcolor, bgcolor + 10);
 
  335        snprintf(outbuf, maxout, 
"%c[%d;%dm", 
ESC, attr, fgcolor);
 
 
  364    char *outbuf_ptr = outbuf;
 
  365    const char *inbuf_ptr = 
inbuf;
 
  367    while (outbuf_ptr < outbuf + maxout) {
 
  368        switch (*inbuf_ptr) {
 
  370                while (*inbuf_ptr && (*inbuf_ptr != 
'm'))
 
  374                *outbuf_ptr = *inbuf_ptr;
 
 
  388    int len = strlen(line);
 
  390    for (i = 0; i < 
len; i++) {
 
  393        if ((i < (
len - 2)) &&
 
  394            (line[i + 1] == 0x5B)) {
 
  395            switch (line[i + 2]) {
 
 
Prototypes for public functions only of internal interest,.
Asterisk main include file. File version handling, generic pbx functions.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Asterisk locking-related definitions:
#define ast_opt_force_black_background
#define ast_opt_light_background
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Support for dynamic strings.
char buffer[AST_TERM_MAX_ROTATING_BUFFERS][AST_TERM_MAX_ESCAPE_CHARS]
static int check_colors_allowed(void)
const char * term_quit(void)
static short convshort(unsigned char *s)
int ast_term_color_code(struct ast_str **str, int fgcolor, int bgcolor)
Append a color sequence to an ast_str.
const char * ast_term_reset(void)
Returns the terminal reset code.
static int convint(unsigned char *s)
static int parse_terminfo_file(int fd)
static void check_bgcolor(int *bgcolor)
const char * ast_term_color(int fgcolor, int bgcolor)
Return a color sequence string.
const char * term_end(void)
char * term_color_code(char *outbuf, int fgcolor, int bgcolor, int maxout)
Write a color sequence to a string.
void term_filter_escapes(char *line)
char * term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout)
Colorize a specified string by adding terminal color codes.
static void check_fgcolor(int *fgcolor, int *attr)
char * term_strip(char *outbuf, const char *inbuf, int maxout)
Remove colorings from a specified string.
static const char *const termpath[]
static int opposite(int color)
Handy terminal functions for vt* terms.
#define AST_TERM_MAX_ROTATING_BUFFERS
#define AST_TERM_MAX_ESCAPE_CHARS
Maximum number of characters needed for a color escape sequence, and another one for a trailing reset...
Definitions to aid in the use of thread local storage.
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
static int inbuf(struct baseio *bio, FILE *fi)
utility used by inchar(), for base_encode()