_tracechtype2(int bufnum, chtype ch)
{
    char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);

    if (result != 0) {
	const char *found;
	attr_t attr = ChAttrOf(ch);

	_nc_STRCPY(result, l_brace, TRACE_BUF_SIZE(bufnum));
	if ((found = _nc_altcharset_name(attr, ch)) != 0) {
	    (void) _nc_trace_bufcat(bufnum, found);
	    attr &= ~A_ALTCHARSET;
	} else
	    (void) _nc_trace_bufcat(bufnum,
				    _nc_tracechar(CURRENT_SCREEN,
						  (int) ChCharOf(ch)));

	if (attr != A_NORMAL) {
	    (void) _nc_trace_bufcat(bufnum, " | ");
	    (void) _nc_trace_bufcat(bufnum,
				    _traceattr2(bufnum + 20, attr));
	}

	result = _nc_trace_bufcat(bufnum, r_brace);
    }
    return result;
}
示例#2
0
文件: visbuf.c 项目: CSU-GH/okl4_3.0
static const char *
_nc_visbuf2n(int bufnum, const char *buf, int len)
{
    char *vbuf;
    char *tp;
    int c;

    if (buf == 0)
	return ("(null)");
    if (buf == CANCELLED_STRING)
	return ("(cancelled)");

    if (len < 0)
	len = strlen(buf);

#ifdef TRACE
    tp = vbuf = _nc_trace_buf(bufnum, (unsigned) (len * 4) + 5);
#else
    {
	static char *mybuf[2];
	mybuf[bufnum] = typeRealloc(char, (unsigned) (len * 4) + 5, mybuf[bufnum]);
	tp = vbuf = mybuf[bufnum];
    }
#endif
    *tp++ = D_QUOTE;
    while ((--len >= 0) && (c = *buf++) != '\0') {
	tp = _nc_vischar(tp, UChar(c));
    }
    *tp++ = D_QUOTE;
    *tp++ = '\0';
    return (vbuf);
}
示例#3
0
_tracecchar_t2(int bufnum, const cchar_t *ch)
{
    char *result = _nc_trace_buf(bufnum, BUFSIZ);
    attr_t attr;
    const char *found;

    if (result != 0) {
	strcpy(result, l_brace);
	if (ch != 0) {
	    attr = AttrOfD(ch);
	    if ((found = _nc_altcharset_name(attr, (chtype) CharOfD(ch))) != 0) {
		(void) _nc_trace_bufcat(bufnum, found);
		attr &= ~A_ALTCHARSET;
	    } else if (isWidecExt(CHDEREF(ch))) {
		(void) _nc_trace_bufcat(bufnum, "{NAC}");
		attr &= ~A_CHARTEXT;
	    } else {
		PUTC_DATA;
		int n;

		PUTC_INIT;
		(void) _nc_trace_bufcat(bufnum, "{ ");
		for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
		    PUTC_ch = ch->chars[PUTC_i];
		    if (PUTC_ch == L'\0') {
			if (PUTC_i == 0)
			    result = _nc_trace_bufcat(bufnum, "\\000");
			break;
		    }
		    PUTC_n = wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st);
		    if (PUTC_n <= 0) {
			if (PUTC_ch != L'\0') {
			    /* it could not be a multibyte sequence */
			    (void) _nc_trace_bufcat(bufnum,
						    _nc_tracechar(CURRENT_SCREEN,
								  UChar(ch->chars[PUTC_i])));
			}
			break;
		    }
		    for (n = 0; n < PUTC_n; n++) {
			if (n)
			    (void) _nc_trace_bufcat(bufnum, ", ");
			(void) _nc_trace_bufcat(bufnum,
						_nc_tracechar(CURRENT_SCREEN,
							      UChar(PUTC_buf[n])));
		    }
		}
		(void) _nc_trace_bufcat(bufnum, " }");
	    }
	    if (attr != A_NORMAL) {
		(void) _nc_trace_bufcat(bufnum, " | ");
		(void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr));
	    }
	}

	result = _nc_trace_bufcat(bufnum, r_brace);
    }
    return result;
}
示例#4
0
const char *
_nc_visbuf2(int bufnum, const char *buf)
/* visibilize a given string */
{
    char *vbuf;
    char *tp;
    int c;

    if (buf == 0)
	return ("(null)");
    if (buf == CANCELLED_STRING)
	return ("(cancelled)");

#ifdef TRACE
    tp = vbuf = _nc_trace_buf(bufnum, (strlen(buf) * 4) + 5);
#else
    {
    static char *mybuf[2];
    mybuf[bufnum] = _nc_doalloc(mybuf[bufnum], (strlen(buf) * 4) + 5);
    tp = vbuf = mybuf[bufnum];
    }
#endif
    *tp++ = '"';
    while ((c = *buf++) != '\0') {
	if (c == '"') {
	    *tp++ = '\\';
	    *tp++ = '"';
	} else if (is7bits(c) && (isgraph(c) || c == ' ')) {
	    *tp++ = c;
	} else if (c == '\n') {
	    *tp++ = '\\';
	    *tp++ = 'n';
	} else if (c == '\r') {
	    *tp++ = '\\';
	    *tp++ = 'r';
	} else if (c == '\b') {
	    *tp++ = '\\';
	    *tp++ = 'b';
	} else if (c == '\033') {
	    *tp++ = '\\';
	    *tp++ = 'e';
	} else if (is7bits(c) && iscntrl(c)) {
	    *tp++ = '\\';
	    *tp++ = '^';
	    *tp++ = '@' + c;
	} else {
	    sprintf(tp, "\\%03o", c & 0xff);
	    tp += strlen(tp);
	}
    }
    *tp++ = '"';
    *tp++ = '\0';
    return (vbuf);
}
示例#5
0
_tracecchar_t2 (int bufnum, const cchar_t *ch)
{
    char *buf = _nc_trace_buf(bufnum, BUFSIZ);
    attr_t attr;
    const char *found;

    strcpy(buf, l_brace);
    if (ch != 0) {
	attr = AttrOfD(ch);
	if ((found = _nc_altcharset_name(attr, CharOfD(ch))) != 0) {
	    (void) _nc_trace_bufcat(bufnum, found);
	    attr &= ~A_ALTCHARSET;
	} else if (isWidecExt(CHDEREF(ch))) {
	    (void) _nc_trace_bufcat(bufnum, "{NAC}");
	    attr &= ~A_CHARTEXT;
	} else {
	    PUTC_DATA;
	    int n;

	    PUTC_INIT;
	    (void) _nc_trace_bufcat(bufnum, "{ ");
	    do {
		PUTC_ch = PUTC_i < CCHARW_MAX ? ch->chars[PUTC_i] : L'\0';
		PUTC_n = wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st);
		if (PUTC_ch == L'\0')
		    --PUTC_n;
		if (PUTC_n <= 0) {
		    if (PUTC_ch != L'\0') {
			/* it could not be a multibyte sequence */
			(void) _nc_trace_bufcat(bufnum, _tracechar(UChar(ch->chars[PUTC_i])));
		    }
		    break;
		}
		for (n = 0; n < PUTC_n; n++) {
		    if (n)
			(void) _nc_trace_bufcat(bufnum, ", ");
		    (void) _nc_trace_bufcat(bufnum, _tracechar(UChar(PUTC_buf[n])));
		}
		++PUTC_i;
	    } while (PUTC_ch != L'\0');
	    (void) _nc_trace_bufcat(bufnum, " }");
	}
	if (attr != A_NORMAL) {
	    (void) _nc_trace_bufcat(bufnum, " | ");
	    (void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr));
	}
    }

    return (_nc_trace_bufcat(bufnum, r_brace));
}
示例#6
0
文件: visbuf.c 项目: mirror/ncurses
static const char *
_nc_visbuf2n(int bufnum, const char *buf, int len)
{
    const char *vbuf = 0;
    char *tp;
    int count;

    if (buf == 0)
	return ("(null)");
    if (buf == CANCELLED_STRING)
	return ("(cancelled)");

    if (len < 0)
	len = (int) strlen(buf);

    count = len;
#ifdef TRACE
    vbuf = tp = _nc_trace_buf(bufnum, NormalLen(len));
#else
    {
	static char *mybuf[NUM_VISBUFS];
	int c;

	if (bufnum < 0) {
	    for (c = 0; c < NUM_VISBUFS; ++c) {
		FreeAndNull(mybuf[c]);
	    }
	    tp = 0;
	} else {
	    mybuf[bufnum] = typeRealloc(char, NormalLen(len), mybuf[bufnum]);
	    vbuf = tp = mybuf[bufnum];
	}
    }
#endif
    if (tp != 0) {
	int c;

	*tp++ = D_QUOTE;
	while ((--count >= 0) && (c = *buf++) != '\0') {
	    tp = VisChar(tp, UChar(c), NormalLen(len));
	}
	*tp++ = D_QUOTE;
	*tp = '\0';
    } else {
	vbuf = ("(_nc_visbuf2n failed)");
    }
    return (vbuf);
}
示例#7
0
文件: visbuf.c 项目: mirror/ncurses
static const char *
_nc_viswbuf2n(int bufnum, const wchar_t *buf, int len)
{
    const char *vbuf;
    char *tp;
    int count;

    if (buf == 0)
	return ("(null)");

    if (len < 0)
	len = (int) wcslen(buf);

    count = len;
#ifdef TRACE
    vbuf = tp = _nc_trace_buf(bufnum, WideLen(len));
#else
    {
	static char *mybuf[NUM_VISBUFS];
	mybuf[bufnum] = typeRealloc(char, WideLen(len), mybuf[bufnum]);
	vbuf = tp = mybuf[bufnum];
    }
#endif
    if (tp != 0) {
	wchar_t c;

	*tp++ = D_QUOTE;
	while ((--count >= 0) && (c = *buf++) != '\0') {
	    char temp[CCHARW_MAX + 80];
	    int j = wctomb(temp, c), k;
	    if (j <= 0) {
		_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
			    "\\u%08X", (unsigned) c);
		j = (int) strlen(temp);
	    }
	    for (k = 0; k < j; ++k) {
		tp = VisChar(tp, UChar(temp[k]), WideLen(len));
	    }
	}
	*tp++ = D_QUOTE;
	*tp = '\0';
    } else {
	vbuf = ("(_nc_viswbuf2n failed)");
    }
    return (vbuf);
}
示例#8
0
_tracechtype2(int bufnum, chtype ch)
{
    const char *found;

    strcpy(_nc_trace_buf(bufnum, BUFSIZ), l_brace);
    if ((found = _nc_altcharset_name(ChAttrOf(ch), ch)) != 0) {
	(void) _nc_trace_bufcat(bufnum, found);
    } else
	(void) _nc_trace_bufcat(bufnum, _tracechar((int)ChCharOf(ch)));

    if (ChAttrOf(ch) != A_NORMAL) {
	(void) _nc_trace_bufcat(bufnum, " | ");
	(void) _nc_trace_bufcat(bufnum,
		_traceattr2(bufnum + 20, ChAttrOf(ch)));
    }

    return (_nc_trace_bufcat(bufnum, r_brace));
}
示例#9
0
_nc_leaks_tinfo(void)
{
#if NO_LEAKS
    char *s;
#endif

    T((T_CALLED("_nc_free_tinfo()")));
#if NO_LEAKS
    _nc_globals.leak_checking = TRUE;
    _nc_free_tparm();
    _nc_tgetent_leaks();

    if (TerminalOf(CURRENT_SCREEN) != 0) {
	del_curterm(TerminalOf(CURRENT_SCREEN));
    }
    _nc_forget_prescr();

    _nc_comp_captab_leaks();
    _nc_free_entries(_nc_head);
    _nc_get_type(0);
    _nc_first_name(0);
    _nc_db_iterator_leaks();
    _nc_keyname_leaks();
#if BROKEN_LINKER || USE_REENTRANT
    _nc_names_leaks();
    _nc_codes_leaks();
    FreeIfNeeded(_nc_prescreen.real_acs_map);
#endif
    _nc_comp_error_leaks();

    if ((s = _nc_home_terminfo()) != 0)
	free(s);

#ifdef TRACE
    T((T_RETURN("")));
    trace(0);
    _nc_trace_buf(-1, (size_t) 0);
#endif

#endif /* NO_LEAKS */
    returnVoid;
}
示例#10
0
static const char *
_nc_viswbuf2n(int bufnum, const wchar_t *buf, int len)
{
    const char *vbuf;
    char *tp;
    wchar_t c;

    if (buf == 0)
	return ("(null)");

    if (len < 0)
	len = (int) wcslen(buf);

#ifdef TRACE
    vbuf = tp = _nc_trace_buf(bufnum, WideLen(len));
#else
    {
	static char *mybuf[2];
	mybuf[bufnum] = typeRealloc(char, WideLen(len), mybuf[bufnum]);
	vbuf = tp = mybuf[bufnum];
    }
#endif
    if (tp != 0) {
	*tp++ = D_QUOTE;
	while ((--len >= 0) && (c = *buf++) != '\0') {
	    char temp[CCHARW_MAX + 80];
	    int j = wctomb(temp, c), k;
	    if (j <= 0) {
		sprintf(temp, "\\u%08X", (unsigned) c);
		j = (int) strlen(temp);
	    }
	    for (k = 0; k < j; ++k) {
		tp = _nc_vischar(tp, UChar(temp[k]));
	    }
	}
	*tp++ = D_QUOTE;
	*tp++ = '\0';
    } else {
	vbuf = ("(_nc_viswbuf2n failed)");
    }
    return (vbuf);
}
示例#11
0
static const char *
_nc_viswbuf2n(int bufnum, const wchar_t *buf, int len)
{
    char *vbuf;
    char *tp;
    wchar_t c;

    if (buf == 0)
	return ("(null)");

    if (len < 0)
	len = wcslen(buf);

#ifdef TRACE
    tp = vbuf = _nc_trace_buf(bufnum, (unsigned) (len * 4) + 5);
#else
    {
	static char *mybuf[2];
	mybuf[bufnum] = typeRealloc(char, (unsigned) (len * 4) + 5, mybuf[bufnum]);
	tp = vbuf = mybuf[bufnum];
    }
#endif
    *tp++ = D_QUOTE;
    while ((--len >= 0) && (c = *buf++) != '\0') {
	char temp[CCHARW_MAX + 80];
	int j = wctomb(temp, c), k;
	if (j <= 0) {
	    sprintf(temp, "\\u%08X", (wint_t) c);
	    j = strlen(temp);
	}
	for (k = 0; k < j; ++k) {
	    tp = _nc_vischar(tp, temp[k]);
	}
    }
    *tp++ = D_QUOTE;
    *tp++ = '\0';
    return (vbuf);
}
示例#12
0
文件: lib_trace.c 项目: vocho/openqnx
const char *_nc_visbuf2(int bufnum, const char *buf)
/* visibilize a given string */
{
char *vbuf;
char *tp;
int c;

	if (buf == 0)
	    return("(null)");

	tp = vbuf = _nc_trace_buf(bufnum, (strlen(buf) * 4) + 5);
	*tp++ = '"';
    	while ((c = *buf++) != '\0') {
		if (c == '"') {
			*tp++ = '\\'; *tp++ = '"';
		} else if (is7bits(c) && (isgraph(c) || c == ' ')) {
			*tp++ = c;
		} else if (c == '\n') {
			*tp++ = '\\'; *tp++ = 'n';
		} else if (c == '\r') {
			*tp++ = '\\'; *tp++ = 'r';
		} else if (c == '\b') {
			*tp++ = '\\'; *tp++ = 'b';
		} else if (c == '\033') {
			*tp++ = '\\'; *tp++ = 'e';
		} else if (is7bits(c) && iscntrl(c)) {
			*tp++ = '\\'; *tp++ = '^'; *tp++ = '@' + c;
		} else {
			sprintf(tp, "\\%03o", c & 0xff);
			tp += strlen(tp);
		}
	}
	*tp++ = '"';
	*tp++ = '\0';
	return(vbuf);
}
示例#13
0
_tracechtype2(int bufnum, chtype ch)
{
    const char *found;
    char *result = _nc_trace_buf(bufnum, BUFSIZ);

    if (result != 0) {
	strcpy(result, l_brace);
	if ((found = _nc_altcharset_name(ChAttrOf(ch), ch)) != 0) {
	    (void) _nc_trace_bufcat(bufnum, found);
	} else
	    (void) _nc_trace_bufcat(bufnum,
				    _nc_tracechar(CURRENT_SCREEN,
						  (int) ChCharOf(ch)));

	if (ChAttrOf(ch) != A_NORMAL) {
	    (void) _nc_trace_bufcat(bufnum, " | ");
	    (void) _nc_trace_bufcat(bufnum,
				    _traceattr2(bufnum + 20, ChAttrOf(ch)));
	}

	result = _nc_trace_bufcat(bufnum, r_brace);
    }
    return result;
}
示例#14
0
static const char *
_nc_visbuf2n(int bufnum, const char *buf, int len)
{
    const char *vbuf;
    char *tp;
    int c;

    if (buf == 0)
	return ("(null)");
    if (buf == CANCELLED_STRING)
	return ("(cancelled)");

    if (len < 0)
	len = (int) strlen(buf);

#ifdef TRACE
    vbuf = tp = _nc_trace_buf(bufnum, NormalLen(len));
#else
    {
	static char *mybuf[4];
	mybuf[bufnum] = typeRealloc(char, NormalLen(len), mybuf[bufnum]);
	vbuf = tp = mybuf[bufnum];
    }
#endif
    if (tp != 0) {
	*tp++ = D_QUOTE;
	while ((--len >= 0) && (c = *buf++) != '\0') {
	    tp = _nc_vischar(tp, UChar(c));
	}
	*tp++ = D_QUOTE;
	*tp++ = '\0';
    } else {
	vbuf = ("(_nc_visbuf2n failed)");
    }
    return (vbuf);
}
示例#15
0
_traceattr2(int bufnum, attr_t newmode)
{
    char *buf = _nc_trace_buf(bufnum, BUFSIZ);
    char temp[80];
    static const struct {
	unsigned int val;
	const char *name;
    } names[] =
    {
	/* *INDENT-OFF* */
	{ A_STANDOUT,		"A_STANDOUT" },
	{ A_UNDERLINE,		"A_UNDERLINE" },
	{ A_REVERSE,		"A_REVERSE" },
	{ A_BLINK,		"A_BLINK" },
	{ A_DIM,		"A_DIM" },
	{ A_BOLD,		"A_BOLD" },
	{ A_ALTCHARSET,		"A_ALTCHARSET" },
	{ A_INVIS,		"A_INVIS" },
	{ A_PROTECT,		"A_PROTECT" },
	{ A_CHARTEXT,		"A_CHARTEXT" },
	{ A_NORMAL,		"A_NORMAL" },
	{ A_COLOR,		"A_COLOR" },
	/* *INDENT-ON* */

    }
#ifndef USE_TERMLIB
    ,
	colors[] =
    {
	/* *INDENT-OFF* */
	{ COLOR_BLACK,		"COLOR_BLACK" },
	{ COLOR_RED,		"COLOR_RED" },
	{ COLOR_GREEN,		"COLOR_GREEN" },
	{ COLOR_YELLOW,		"COLOR_YELLOW" },
	{ COLOR_BLUE,		"COLOR_BLUE" },
	{ COLOR_MAGENTA,	"COLOR_MAGENTA" },
	{ COLOR_CYAN,		"COLOR_CYAN" },
	{ COLOR_WHITE,		"COLOR_WHITE" },
	/* *INDENT-ON* */

    }
#endif /* !USE_TERMLIB */
    ;
    size_t n;
    unsigned save_nc_tracing = _nc_tracing;
    _nc_tracing = 0;

    strcpy(buf, l_brace);

    for (n = 0; n < SIZEOF(names); n++) {
	if ((newmode & names[n].val) != 0) {
	    if (buf[1] != '\0')
		buf = _nc_trace_bufcat(bufnum, "|");
	    buf = _nc_trace_bufcat(bufnum, names[n].name);

	    if (names[n].val == A_COLOR) {
		short pairnum = PAIR_NUMBER(newmode);
#ifdef USE_TERMLIB
		/* pair_content lives in libncurses */
		(void) sprintf(temp, "{%d}", pairnum);
#else
		short fg, bg;

		if (pair_content(pairnum, &fg, &bg) == OK) {
		    (void) sprintf(temp,
				   "{%d = {%s, %s}}",
				   pairnum,
				   COLOR_OF(fg),
				   COLOR_OF(bg));
		} else {
		    (void) sprintf(temp, "{%d}", pairnum);
		}
#endif
		buf = _nc_trace_bufcat(bufnum, temp);
	    }
	}
    }
    if (ChAttrOf(newmode) == A_NORMAL) {
	if (buf[1] != '\0')
	    (void) _nc_trace_bufcat(bufnum, "|");
	(void) _nc_trace_bufcat(bufnum, "A_NORMAL");
    }

    _nc_tracing = save_nc_tracing;
    return (_nc_trace_bufcat(bufnum, r_brace));
}
_tracecchar_t2(int bufnum, const cchar_t *ch)
{
    char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);

    if (result != 0) {
	_nc_STRCPY(result, l_brace, TRACE_BUF_SIZE(bufnum));
	if (ch != 0) {
	    const char *found;
	    attr_t attr = AttrOfD(ch);

	    if ((found = _nc_altcharset_name(attr, (chtype) CharOfD(ch))) != 0) {
		(void) _nc_trace_bufcat(bufnum, found);
		attr &= ~A_ALTCHARSET;
	    } else if (isWidecExt(CHDEREF(ch))) {
		(void) _nc_trace_bufcat(bufnum, "{NAC}");
		attr &= ~A_CHARTEXT;
	    } else {
		PUTC_DATA;
		int n;

		(void) _nc_trace_bufcat(bufnum, "{ ");
		for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
		    PUTC_ch = ch->chars[PUTC_i];
		    if (PUTC_ch == L'\0') {
			if (PUTC_i == 0)
			    (void) _nc_trace_bufcat(bufnum, "\\000");
			break;
		    }
		    PUTC_INIT;
		    PUTC_n = (int) wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st);
		    if (PUTC_n <= 0) {
			if (PUTC_ch != L'\0') {
			    /* it could not be a multibyte sequence */
			    (void) _nc_trace_bufcat(bufnum,
						    _nc_tracechar(CURRENT_SCREEN,
								  UChar(ch->chars[PUTC_i])));
			}
			break;
		    } else if (ch->chars[PUTC_i] > 255) {
			char temp[80];
			_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
				    "{%d:\\u%lx}",
				    wcwidth(ch->chars[PUTC_i]),
				    (unsigned long) ch->chars[PUTC_i]);
			(void) _nc_trace_bufcat(bufnum, temp);
			break;
		    }
		    for (n = 0; n < PUTC_n; n++) {
			if (n)
			    (void) _nc_trace_bufcat(bufnum, ", ");
			(void) _nc_trace_bufcat(bufnum,
						_nc_tracechar(CURRENT_SCREEN,
							      UChar(PUTC_buf[n])));
		    }
		}
		(void) _nc_trace_bufcat(bufnum, " }");
	    }
	    if (attr != A_NORMAL) {
		(void) _nc_trace_bufcat(bufnum, " | ");
		(void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr));
	    }
#if NCURSES_EXT_COLORS
	    /*
	     * Just in case the extended color is different from the chtype
	     * value, trace both.
	     */
	    if (ch->ext_color != PairNumber(attr)) {
		char temp[80];
		_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
			    " X_COLOR{%d:%d}", ch->ext_color, PairNumber(attr));
		(void) _nc_trace_bufcat(bufnum, temp);
	    }
#endif
	}

	result = _nc_trace_bufcat(bufnum, r_brace);
    }
    return result;
}
_traceattr2(int bufnum, chtype newmode)
{
#define DATA(name) { name, { #name } }
    static const struct {
	unsigned int val;
	const char name[14];
    } names[] =
    {
	DATA(A_STANDOUT),
	    DATA(A_UNDERLINE),
	    DATA(A_REVERSE),
	    DATA(A_BLINK),
	    DATA(A_DIM),
	    DATA(A_BOLD),
	    DATA(A_ALTCHARSET),
	    DATA(A_INVIS),
	    DATA(A_PROTECT),
	    DATA(A_CHARTEXT),
	    DATA(A_NORMAL),
	    DATA(A_COLOR),
#if USE_ITALIC
	    DATA(A_ITALIC),
#endif
    }
#ifndef USE_TERMLIB
    ,
	colors[] =
    {
	DATA(COLOR_BLACK),
	    DATA(COLOR_RED),
	    DATA(COLOR_GREEN),
	    DATA(COLOR_YELLOW),
	    DATA(COLOR_BLUE),
	    DATA(COLOR_MAGENTA),
	    DATA(COLOR_CYAN),
	    DATA(COLOR_WHITE),
    }
#endif /* !USE_TERMLIB */
    ;
#undef DATA
    char *result = _nc_trace_buf(bufnum, (size_t) BUFSIZ);

    if (result != 0) {
	size_t n;
	unsigned save_nc_tracing = _nc_tracing;

	_nc_tracing = 0;

	_nc_STRCPY(result, l_brace, TRACE_BUF_SIZE(bufnum));

	for (n = 0; n < SIZEOF(names); n++) {

	    if ((newmode & names[n].val) != 0) {
		if (result[1] != '\0')
		    (void) _nc_trace_bufcat(bufnum, "|");
		result = _nc_trace_bufcat(bufnum, names[n].name);

		if (names[n].val == A_COLOR) {
		    char temp[80];
		    short pairnum = (short) PairNumber(newmode);
#ifdef USE_TERMLIB
		    /* pair_content lives in libncurses */
		    _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
				"{%d}", pairnum);
#else
		    NCURSES_COLOR_T fg, bg;

		    if (pair_content(pairnum, &fg, &bg) == OK) {
			_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
				    "{%d = {%s, %s}}",
				    pairnum,
				    COLOR_OF(fg),
				    COLOR_OF(bg));
		    } else {
			_nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
				    "{%d}", pairnum);
		    }
#endif
		    result = _nc_trace_bufcat(bufnum, temp);
		}
	    }
	}
	if (ChAttrOf(newmode) == A_NORMAL) {
	    if (result != 0 && result[1] != '\0')
		(void) _nc_trace_bufcat(bufnum, "|");
	    (void) _nc_trace_bufcat(bufnum, "A_NORMAL");
	}

	_nc_tracing = save_nc_tracing;
	result = _nc_trace_bufcat(bufnum, r_brace);
    }
    return result;
}
示例#18
0
_nc_trace_ttymode(TTY * tty)
/* describe the state of the terminal control bits exactly */
{
    char *buf;

#ifdef TERMIOS
    static const BITNAMES iflags[] =
    {
	{BRKINT, "BRKINT"},
	{IGNBRK, "IGNBRK"},
	{IGNPAR, "IGNPAR"},
	{PARMRK, "PARMRK"},
	{INPCK, "INPCK"},
	{ISTRIP, "ISTRIP"},
	{INLCR, "INLCR"},
	{IGNCR, "IGNC"},
	{ICRNL, "ICRNL"},
	{IXON, "IXON"},
	{IXOFF, "IXOFF"},
	{0, NULL}
#define ALLIN	(BRKINT|IGNBRK|IGNPAR|PARMRK|INPCK|ISTRIP|INLCR|IGNCR|ICRNL|IXON|IXOFF)
    }, oflags[] =
    {
	{OPOST, "OPOST"},
	{0, NULL}
#define ALLOUT	(OPOST)
    }, cflags[] =
    {
	{CLOCAL, "CLOCAL"},
	{CREAD, "CREAD"},
	{CSTOPB, "CSTOPB"},
#if !defined(CS5) || !defined(CS8)
	{CSIZE, "CSIZE"},
#endif
	{HUPCL, "HUPCL"},
	{PARENB, "PARENB"},
	{PARODD | PARENB, "PARODD"},	/* concession to readability */
	{0, NULL}
#define ALLCTRL	(CLOCAL|CREAD|CSIZE|CSTOPB|HUPCL|PARENB|PARODD)
    }, lflags[] =
    {
	{ECHO, "ECHO"},
	{ECHOE | ECHO, "ECHOE"},	/* concession to readability */
	{ECHOK | ECHO, "ECHOK"},	/* concession to readability */
	{ECHONL, "ECHONL"},
	{ICANON, "ICANON"},
	{ISIG, "ISIG"},
	{NOFLSH, "NOFLSH"},
	{TOSTOP, "TOSTOP"},
	{IEXTEN, "IEXTEN"},
	{0, NULL}
#define ALLLOCAL	(ECHO|ECHONL|ICANON|ISIG|NOFLSH|TOSTOP|IEXTEN)
    };

    buf = _nc_trace_buf(0,
			8 + sizeof(iflags) +
			8 + sizeof(oflags) +
			8 + sizeof(cflags) +
			8 + sizeof(lflags) +
			8);

    if (tty->c_iflag & ALLIN)
	lookup_bits(buf, iflags, "iflags", tty->c_iflag);

    if (tty->c_oflag & ALLOUT)
	lookup_bits(buf, oflags, "oflags", tty->c_oflag);

    if (tty->c_cflag & ALLCTRL)
	lookup_bits(buf, cflags, "cflags", tty->c_cflag);

#if defined(CS5) && defined(CS8)
    {
	static struct {
	    const char *name;
	    int value;
	} csizes[] = {
	    {
		"CS5 ", CS5
	    },
#ifdef CS6
	    {
		"CS6 ", CS6
	    },
#endif
#ifdef CS7
	    {
		"CS7 ", CS7
	    },
#endif
	    {
		"CS8 ", CS8
	    },
	};
	const char *result = "CSIZE? ";
	int value = (tty->c_cflag & CSIZE);
	unsigned n;

	if (value != 0) {
	    for (n = 0; n < SIZEOF(csizes); n++) {
		if (csizes[n].value == value) {
		    result = csizes[n].name;
		    break;
		}
	    }
	}
	strcat(buf, result);
    }
#endif

    if (tty->c_lflag & ALLLOCAL)
	lookup_bits(buf, lflags, "lflags", tty->c_lflag);

#else
    /* reference: ttcompat(4M) on SunOS 4.1 */
#ifndef EVENP
#define EVENP 0
#endif
#ifndef LCASE
#define LCASE 0
#endif
#ifndef LLITOUT
#define LLITOUT 0
#endif
#ifndef ODDP
#define ODDP 0
#endif
#ifndef TANDEM
#define TANDEM 0
#endif

    static const BITNAMES cflags[] =
    {
	{CBREAK, "CBREAK"},
	{CRMOD, "CRMOD"},
	{ECHO, "ECHO"},
	{EVENP, "EVENP"},
	{LCASE, "LCASE"},
	{LLITOUT, "LLITOUT"},
	{ODDP, "ODDP"},
	{RAW, "RAW"},
	{TANDEM, "TANDEM"},
	{XTABS, "XTABS"},
	{0, NULL}
#define ALLCTRL	(CBREAK|CRMOD|ECHO|EVENP|LCASE|LLITOUT|ODDP|RAW|TANDEM|XTABS)
    };

    buf = _nc_trace_buf(0,
			8 + sizeof(cflags));

    if (tty->sg_flags & ALLCTRL) {
	lookup_bits(buf, cflags, "cflags", tty->sg_flags);
    }
#endif
    return (buf);
}
示例#19
0
_nc_freeall(void)
{
    WINDOWLIST *p, *q;
    char *s;

    T((T_CALLED("_nc_freeall()")));
#if NO_LEAKS
    _nc_free_tparm();
    if (_nc_oldnums != 0) {
	FreeAndNull(_nc_oldnums);
    }
#endif
    if (SP != 0) {
	while (_nc_windows != 0) {
	    /* Delete only windows that're not a parent */
	    for (p = _nc_windows; p != 0; p = p->next) {
		bool found = FALSE;

		for (q = _nc_windows; q != 0; q = q->next) {
		    if ((p != q)
			&& (q->win._flags & _SUBWIN)
			&& (&(p->win) == q->win._parent)) {
			found = TRUE;
			break;
		    }
		}

		if (!found) {
		    delwin(&(p->win));
		    break;
		}
	    }
	}
	delscreen(SP);
    }

    del_curterm(cur_term);
    _nc_free_entries(_nc_head);
    _nc_get_type(0);
    _nc_first_name(0);
#if USE_WIDEC_SUPPORT
    FreeIfNeeded(_nc_wacs);
#endif
#if NO_LEAKS
    _nc_alloc_entry_leaks();
    _nc_captoinfo_leaks();
    _nc_comp_scan_leaks();
#endif

    if ((s = _nc_home_terminfo()) != 0)
	free(s);

    (void) _nc_printf_string(0, 0);
#ifdef TRACE
    (void) _nc_trace_buf(-1, 0);
#endif

#if HAVE_LIBDBMALLOC
    malloc_dump(malloc_errfd);
#elif HAVE_LIBDMALLOC
#elif HAVE_LIBMPATROL
    __mp_summary();
#elif HAVE_PURIFY
    purify_all_inuse();
#endif
    returnVoid;
}
示例#20
0
char *_tracechtype2(int bufnum, chtype ch)
{
char	*buf = _nc_trace_buf(bufnum, BUFSIZ);
char	*found = 0;

    strcpy(buf, "{");
    if (ch & A_ALTCHARSET)
    {
	char	*cp;
	static const	struct {unsigned int val; const char *name;}
	names[] =
	{
	    {'l', "ACS_ULCORNER"},	/* upper left corner */
	    {'m', "ACS_LLCORNER"},	/* lower left corner */
	    {'k', "ACS_URCORNER"},	/* upper right corner */
	    {'j', "ACS_LRCORNER"},	/* lower right corner */
	    {'t', "ACS_LTEE"},		/* tee pointing right */
	    {'u', "ACS_RTEE"},		/* tee pointing left */
	    {'v', "ACS_BTEE"},		/* tee pointing up */
	    {'w', "ACS_TTEE"},		/* tee pointing down */
	    {'q', "ACS_HLINE"},		/* horizontal line */
	    {'x', "ACS_VLINE"},		/* vertical line */
	    {'n', "ACS_PLUS"},		/* large plus or crossover */
	    {'o', "ACS_S1"},		/* scan line 1 */
	    {'s', "ACS_S9"},		/* scan line 9 */
	    {'`', "ACS_DIAMOND"},	/* diamond */
	    {'a', "ACS_CKBOARD"},	/* checker board (stipple) */
	    {'f', "ACS_DEGREE"},	/* degree symbol */
	    {'g', "ACS_PLMINUS"},	/* plus/minus */
	    {'~', "ACS_BULLET"},	/* bullet */
	    {',', "ACS_LARROW"},	/* arrow pointing left */
	    {'+', "ACS_RARROW"},	/* arrow pointing right */
	    {'.', "ACS_DARROW"},	/* arrow pointing down */
	    {'-', "ACS_UARROW"},	/* arrow pointing up */
	    {'h', "ACS_BOARD"},		/* board of squares */
	    {'i', "ACS_LANTERN"},	/* lantern symbol */
	    {'0', "ACS_BLOCK"},		/* solid square block */
	    {'p', "ACS_S3"},		/* scan line 3 */
	    {'r', "ACS_S7"},		/* scan line 7 */
	    {'y', "ACS_LEQUAL"},	/* less/equal */
	    {'z', "ACS_GEQUAL"},	/* greater/equal */
	    {'{', "ACS_PI"},		/* Pi */
	    {'|', "ACS_NEQUAL"},	/* not equal */
	    {'}', "ACS_STERLING"},	/* UK pound sign */
	    {'\0',(char *)0}
	},
	*sp;

	for (cp = acs_chars; cp[0] && cp[1]; cp += 2)
	{
	    if (TextOf(cp[1]) == TextOf(ch))
	    {
		found = cp;
		/* don't exit from loop - there may be redefinitions */
	    }
	}

	if (found != 0)
	{
	    ch = TextOf(*found);
	    for (sp = names; sp->val; sp++)
		if (sp->val == ch)
		{
		    (void) strcat(buf, sp->name);
		    ch &= ~A_ALTCHARSET;
		    break;
		}
	}
    }

    if (found == 0)
	(void) strcat(buf, _tracechar(TextOf(ch)));

    if (AttrOf(ch) != A_NORMAL)
	(void) sprintf(buf + strlen(buf), " | %s", _traceattr2(bufnum+20,AttrOf(ch)));

    strcat(buf, "}");
    return(buf);
}
示例#21
0
char *_traceattr2(int bufnum, attr_t newmode)
{
char	*buf = _nc_trace_buf(bufnum, BUFSIZ);
char	*tmp = buf;
static const	struct {unsigned int val; const char *name;}
names[] =
    {
	{ A_STANDOUT,		"A_STANDOUT" },
	{ A_UNDERLINE,		"A_UNDERLINE" },
	{ A_REVERSE,		"A_REVERSE" },
	{ A_BLINK,		"A_BLINK" },
	{ A_DIM,		"A_DIM" },
	{ A_BOLD,		"A_BOLD" },
	{ A_ALTCHARSET,		"A_ALTCHARSET" },
	{ A_INVIS,		"A_INVIS" },
	{ A_PROTECT,		"A_PROTECT" },
	{ A_CHARTEXT,		"A_CHARTEXT" },
	{ A_NORMAL,		"A_NORMAL" },
	{ A_COLOR,		"A_COLOR" },
    },
colors[] =
    {
	{ COLOR_BLACK,		"COLOR_BLACK" },
	{ COLOR_RED,		"COLOR_RED" },
	{ COLOR_GREEN,		"COLOR_GREEN" },
	{ COLOR_YELLOW,		"COLOR_YELLOW" },
	{ COLOR_BLUE,		"COLOR_BLUE" },
	{ COLOR_MAGENTA,	"COLOR_MAGENTA" },
	{ COLOR_CYAN,		"COLOR_CYAN" },
	{ COLOR_WHITE,		"COLOR_WHITE" },
    };
size_t n;
unsigned save_nc_tracing = _nc_tracing;
	_nc_tracing = 0;

	strcpy(tmp++, "{");

	for (n = 0; n < SIZEOF(names); n++) {
		if ((newmode & names[n].val) != 0) {
			if (buf[1] != '\0')
				strcat(tmp, "|");
			strcat(tmp, names[n].name);
			tmp += strlen(tmp);

			if (names[n].val == A_COLOR)
			{
				short pairnum = PAIR_NUMBER(newmode);
				short fg, bg;
	
				if (pair_content(pairnum, &fg, &bg) == OK)
					(void) sprintf(tmp,
						"{%d = {%s, %s}}",
						pairnum,
						COLOR_OF(fg),
						COLOR_OF(bg)
						);
				else
					(void) sprintf(tmp, "{%d}", pairnum);
			}
		}
	}
	if (AttrOf(newmode) == A_NORMAL) {
		if (buf[1] != '\0')
			strcat(tmp, "|");
		strcat(tmp, "A_NORMAL");
	}

	_nc_tracing = save_nc_tracing;
	return (strcat(buf,"}"));
}