set_curterm(TERMINAL * termp) { TERMINAL *oldterm; T((T_CALLED("set_curterm(%p)"), termp)); _nc_lock_global(curses); oldterm = cur_term; if (SP) SP->_term = termp; #if BROKEN_LINKER || USE_REENTRANT _nc_prescreen._cur_term = termp; #else cur_term = termp; #endif if (termp != 0) { ospeed = _nc_ospeed(termp->_baudrate); if (termp->type.Strings) { PC = (char) ((pad_char != NULL) ? pad_char[0] : 0); } } _nc_unlock_global(curses); T((T_RETURN("%p"), oldterm)); return (oldterm); }
wecho_wchar(WINDOW *win, const cchar_t * wch) { PUTC_DATA; int n; int code = ERR; TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wecho_wchar(%p, %s)"), win, _tracech_t(wch))); if (win != 0) { PUTC_INIT; while (PUTC_i < CCHARW_MAX) { if ((PUTC_ch = wch->chars[PUTC_i++]) == L'\0') break; if ((PUTC_n = wcrtomb(PUTC_buf, PUTC_ch, &PUT_st)) <= 0) { code = ERR; if (is8bits(PUTC_ch)) code = waddch(win, UChar(PUTC_ch) | wch->attr); break; } for (n = 0; n < PUTC_n; n++) { if ((code = waddch(win, UChar(PUTC_buf[n]) | wch->attr)) == ERR) { break; } } if (code == ERR) break; } wrefresh(win); } TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code)); return (code); }
wadd_wch(WINDOW *win, const cchar_t *wch) { PUTC_DATA; int n; int code = ERR; TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wadd_wch(%p, %s)"), win, _tracech_t(wch))); if (win != 0) { PUTC_INIT; for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) { attr_t attrs = (wch->attr & A_ATTRIBUTES); if ((PUTC_ch = wch->chars[PUTC_i]) == L'\0') break; if ((PUTC_n = wcrtomb(PUTC_buf, PUTC_ch, &PUT_st)) <= 0) { code = ERR; if (is8bits(PUTC_ch)) code = waddch(win, UChar(PUTC_ch) | attrs); break; } for (n = 0; n < PUTC_n; n++) { if ((code = waddch(win, UChar(PUTC_buf[n]) | attrs)) == ERR) { break; } } if (code == ERR) break; } } TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code)); return (code); }
static void _nc_va_tracef(const char *fmt, va_list ap) { static const char Called[] = T_CALLED(""); static const char Return[] = T_RETURN(""); bool before = FALSE; bool after = FALSE; unsigned doit = _nc_tracing; int save_err = errno; if (strlen(fmt) >= sizeof(Called) - 1) { if (!strncmp(fmt, Called, sizeof(Called) - 1)) { before = TRUE; TraceLevel++; } else if (!strncmp(fmt, Return, sizeof(Return) - 1)) { after = TRUE; } if (before || after) { if ((TraceLevel <= 1) || (doit & TRACE_ICALLS) != 0) doit &= (TRACE_CALLS | TRACE_CCALLS); else doit = 0; } } if (doit != 0) { if (TraceFP == 0) TraceFP = stderr; #ifdef USE_PTHREADS /* * TRACE_ICALLS is "really" needed to show normal use with threaded * applications, since anything can be running during a napms(), * making it appear in the hierarchical trace as it other functions * are being called. * * Rather than add the complication of a per-thread stack, just * show the thread-id in each line of the trace. */ # if USE_WEAK_SYMBOLS if ((pthread_self)) # endif fprintf(TraceFP, "%#lx:", (long) (void *) pthread_self()); #endif if (before || after) { int n; for (n = 1; n < TraceLevel; n++) fputs("+ ", TraceFP); } vfprintf(TraceFP, fmt, ap); fputc('\n', TraceFP); fflush(TraceFP); } if (after && TraceLevel) TraceLevel--; errno = save_err; }
getcchar(const cchar_t *wcval, wchar_t *wch, attr_t *attrs, short *color_pair, void *opts) { wchar_t *wp; int len; int code = ERR; TR(TRACE_CCALLS, (T_CALLED("getcchar(%p,%p,%p,%p,%p)"), wcval, wch, attrs, color_pair, opts)); if (opts == NULL) { len = (wp = wmemchr(wcval->chars, L'\0', CCHARW_MAX)) ? wp - wcval->chars : CCHARW_MAX; if (wch == NULL) { code = len; } else if (attrs == 0 || color_pair == 0) { code = ERR; } else if (len >= 0) { *attrs = AttrOf(*wcval) & A_ATTRIBUTES; *color_pair = GetPair(*wcval); wmemcpy(wch, wcval->chars, (unsigned) len); wch[len] = L'\0'; code = OK; } } TR(TRACE_CCALLS, (T_RETURN("%d"), code)); return (code); }
NCURSES_SP_NAME(set_curterm) (NCURSES_SP_DCLx TERMINAL * termp) { TERMINAL *oldterm; T((T_CALLED("set_curterm(%p)"), (void *) termp)); _nc_lock_global(curses); oldterm = cur_term; if (SP_PARM) SP_PARM->_term = termp; #if USE_REENTRANT CurTerm = termp; #else cur_term = termp; #endif if (termp != 0) { #ifdef USE_TERM_DRIVER TERMINAL_CONTROL_BLOCK *TCB = (TERMINAL_CONTROL_BLOCK *) termp; ospeed = (NCURSES_OSPEED) _nc_ospeed(termp->_baudrate); if (TCB->drv->isTerminfo && termp->type.Strings) { PC = (char) ((pad_char != NULL) ? pad_char[0] : 0); } TCB->csp = SP_PARM; #else ospeed = (NCURSES_OSPEED) _nc_ospeed(termp->_baudrate); if (termp->type.Strings) { PC = (char) ((pad_char != NULL) ? pad_char[0] : 0); } #endif } _nc_unlock_global(curses); T((T_RETURN("%p"), (void *) oldterm)); return (oldterm); }
set_curterm(TERMINAL * termp) { TERMINAL *oldterm = cur_term; T((T_CALLED("set_curterm(%p)"), termp)); if ((cur_term = termp) != 0) { ospeed = _nc_ospeed(cur_term->_baudrate); PC = (pad_char != NULL) ? pad_char[0] : 0; } T((T_RETURN("%p"), oldterm)); return (oldterm); }
int waddch(WINDOW *win, const chtype ch) { int code = ERR; TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_CALLED("waddch(%p, %s)"), win, _tracechtype(ch))); if (win && (waddch_nosync(win, ch) != ERR)) { _nc_synchook(win); code = OK; } TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_RETURN("%d"), code)); return(code); }
wadd_wch(WINDOW *win, const cchar_t *wch) { int code = ERR; TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wadd_wch(%p, %s)"), (void *) win, _tracecchar_t(wch))); if (win && (wadd_wch_nosync(win, *wch) != ERR)) { _nc_synchook(win); code = OK; } TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code)); return (code); }
void _tracef(const char *fmt, ...) { static const char Called[] = T_CALLED(""); static const char Return[] = T_RETURN(""); static int level; va_list ap; bool before = FALSE; bool after = FALSE; int doit = _nc_tracing; int save_err = errno; if (strlen(fmt) >= sizeof(Called) - 1) { if (!strncmp(fmt, Called, sizeof(Called)-1)) { before = TRUE; level++; } else if (!strncmp(fmt, Return, sizeof(Return)-1)) { after = TRUE; } if (before || after) { if ((level <= 1) || (doit & TRACE_ICALLS) != 0) doit &= (TRACE_CALLS|TRACE_CCALLS); else doit = 0; } } if (doit != 0) { if (tracefp == 0) tracefp = stderr; if (before || after) { int n; for (n = 1; n < level; n++) fputs("+ ", tracefp); } va_start(ap, fmt); vfprintf(tracefp, fmt, ap); fputc('\n', tracefp); va_end(ap); fflush(tracefp); } if (after && level) level--; errno = save_err; }
setcchar(cchar_t *wcval, const wchar_t *wch, const attr_t attrs, short color_pair, const void *opts) { unsigned i; unsigned len; int code = OK; TR(TRACE_CCALLS, (T_CALLED("setcchar(%p,%s,%lu,%d,%p)"), (void *) wcval, _nc_viswbuf(wch), (unsigned long) attrs, color_pair, opts)); len = (unsigned) wcslen(wch); if (opts != NULL || (len > 1 && wcwidth(wch[0]) < 0)) { code = ERR; } else { if (len > CCHARW_MAX) len = CCHARW_MAX; /* * If we have a following spacing-character, stop at that point. We * are only interested in adding non-spacing characters. */ for (i = 1; i < len; ++i) { if (wcwidth(wch[i]) != 0) { len = i; break; } } memset(wcval, 0, sizeof(*wcval)); if (len != 0) { SetAttr(*wcval, attrs | (attr_t) ColorPair(color_pair)); SetPair(CHDEREF(wcval), color_pair); memcpy(&wcval->chars, wch, len * sizeof(wchar_t)); TR(TRACE_CCALLS, ("copy %d wchars, first is %s", len, _tracecchar_t(wcval))); } } TR(TRACE_CCALLS, (T_RETURN("%d"), code)); return (code); }
int wechochar(WINDOW *win, const chtype ch) { int code = ERR; TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_CALLED("wechochar(%p, %s)"), win, _tracechtype(ch))); if (win && (waddch_nosync(win, ch) != ERR)) { bool save_immed = win->_immed; win->_immed = TRUE; _nc_synchook(win); win->_immed = save_immed; code = OK; } TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_RETURN("%d"), code)); return(code); }
set_term(SCREEN *screenp) { SCREEN *oldSP; T((T_CALLED("set_term(%p)"), screenp)); oldSP = SP; _nc_set_screen(screenp); set_curterm(SP->_term); curscr = SP->_curscr; newscr = SP->_newscr; stdscr = SP->_stdscr; COLORS = SP->_color_count; COLOR_PAIRS = SP->_pair_count; T((T_RETURN("%p"), oldSP)); return (oldSP); }
_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; }
getcchar(const cchar_t *wcval, wchar_t *wch, attr_t *attrs, short *color_pair, void *opts) { wchar_t *wp; int len; int code = ERR; TR(TRACE_CCALLS, (T_CALLED("getcchar(%p,%p,%p,%p,%p)"), (const void *) wcval, (void *) wch, (void *) attrs, (void *) color_pair, opts)); if (opts == NULL) { len = ((wp = wmemchr(wcval->chars, L'\0', CCHARW_MAX)) ? (int) (wp - wcval->chars) : CCHARW_MAX); if (wch == NULL) { /* * If the value is a null, set the length to 1. * If the value is not a null, return the length plus 1 for null. */ code = (len < CCHARW_MAX) ? (len + 1) : CCHARW_MAX; } else if (attrs == 0 || color_pair == 0) { code = ERR; } else if (len >= 0) { *attrs = AttrOf(*wcval) & A_ATTRIBUTES; *color_pair = (short) GetPair(*wcval); wmemcpy(wch, wcval->chars, (unsigned) len); wch[len] = L'\0'; code = OK; } } TR(TRACE_CCALLS, (T_RETURN("%d"), code)); return (code); }
set_term(SCREEN *screenp) { SCREEN *oldSP; SCREEN *newSP; T((T_CALLED("set_term(%p)"), (void *) screenp)); _nc_lock_global(curses); oldSP = CURRENT_SCREEN; _nc_set_screen(screenp); newSP = screenp; if (newSP != 0) { TINFO_SET_CURTERM(newSP, newSP->_term); #if !USE_REENTRANT curscr = CurScreen(newSP); newscr = NewScreen(newSP); stdscr = StdScreen(newSP); COLORS = newSP->_color_count; COLOR_PAIRS = newSP->_pair_count; #endif } else { TINFO_SET_CURTERM(oldSP, 0); #if !USE_REENTRANT curscr = 0; newscr = 0; stdscr = 0; COLORS = 0; COLOR_PAIRS = 0; #endif } _nc_unlock_global(curses); T((T_RETURN("%p"), (void *) oldSP)); return (oldSP); }
set_term(SCREEN *screenp) { SCREEN *oldSP; SCREEN *newSP; T((T_CALLED("set_term(%p)"), screenp)); _nc_lock_global(curses); oldSP = SP; _nc_set_screen(screenp); newSP = SP; if (newSP != 0) { set_curterm(newSP->_term); #if !USE_REENTRANT curscr = newSP->_curscr; newscr = newSP->_newscr; stdscr = newSP->_stdscr; COLORS = newSP->_color_count; COLOR_PAIRS = newSP->_pair_count; #endif } else { set_curterm(0); #if !USE_REENTRANT curscr = 0; newscr = 0; stdscr = 0; COLORS = 0; COLOR_PAIRS = 0; #endif } _nc_unlock_global(curses); T((T_RETURN("%p"), oldSP)); return (oldSP); }
setcchar(cchar_t * wcval, const wchar_t * wch, const attr_t attrs, short color_pair, const void *opts) { int i; int len; int code = OK; TR(TRACE_CCALLS, (T_CALLED("setcchar(%p,%s,%ld,%d,%p)"), wcval, _nc_viswbuf(wch), attrs, color_pair, opts)); if (opts != NULL || (len = wcslen(wch)) > CCHARW_MAX || (len > 0 && wcwidth(wch[0]) < 0)) { code = ERR; } else { for (i = 1; i < len; ++i) { if (wcwidth(wch[i]) != 0) { code = ERR; break; } } if (code != ERR) { memset(wcval, 0, sizeof(*wcval)); if (len != 0) { SetAttr(*wcval, attrs | color_pair); memcpy(&wcval->chars, wch, len * sizeof(wchar_t)); TR(TRACE_CCALLS, ("copy %d wchars, first is %s", len, _tracecchar_t(wcval))); } } } TR(TRACE_CCALLS, (T_RETURN("%d"), code)); return (code); }
void traverse_stmt_g(statement_t *stmt,void (*pre_s) (statement_t *), void (*post_s) (statement_t *),void (*e) (expr_t *), void (*d) (symboltable_t *)) { DB0(60,"traverse_stmt_g(,,,,)\n"); if (stmt == NULL) { return; } if (pre_s) (*pre_s)(stmt); switch (T_TYPE(stmt)) { case S_NULL: case S_EXIT: case S_END: case S_HALT: case S_CONTINUE: case S_ZPROF: /* MDD */ break; case S_WRAP: case S_REFLECT: traverse_wrap_g(T_WRAP(stmt), pre_s, post_s, e, d); break; case S_COMM: traverse_comm_g(T_COMM(stmt), pre_s, post_s, e, d); break; case S_REGION_SCOPE: RMSPushScope(T_REGION(stmt)); traverse_region_g(T_REGION(stmt),pre_s,post_s,e,d); RMSPopScope(T_REGION(stmt)); break; case S_MLOOP: traverse_mloop_g(T_MLOOP(stmt),pre_s,post_s,e,d); break; case S_NLOOP: traverse_nloop_g(T_NLOOP(stmt),pre_s,post_s,e,d); break; case S_COMPOUND: case S_MSCAN: if (d != NULL) (*d)(T_CMPD_DECL(stmt)); traverse_stmtls_g(T_CMPD_STLS(stmt),pre_s,post_s,e,d); break; case S_EXPR: if (e != NULL) (*e)(T_EXPR(stmt)); break; case S_IF: traverse_if_g(T_IF(stmt),pre_s,post_s,e,d); break; case S_LOOP: traverse_loop_g(T_LOOP(stmt),pre_s,post_s,e,d); break; case S_RETURN: if (e != NULL && T_RETURN(stmt) != NULL) (*e)(T_RETURN(stmt)); break; case S_IO: if (e != NULL) (*e)(IO_EXPR1(T_IO(stmt))); break; default: DB1(70,"Type of structure == %d\n",ST_TYPE(stmt)); INT_FATAL(stmt, "Bad statementtype (%d) in traverse_stmt_g()",T_TYPE(stmt)); } if (post_s) (*post_s)(stmt); }
_nc_retrace_form(FORM *code) { T((T_RETURN("%p"), code)); return code; }
_nc_retrace_form_hook(Form_Hook code) { T((T_RETURN("%p"), code)); return code; }
_nc_retrace_field(FIELD *code) { T((T_RETURN("%p"), code)); return code; }
_nc_retrace_field_type(FIELDTYPE *code) { T((T_RETURN("%p"), code)); return code; }
_nc_retrace_attr_t(attr_t code) { T((T_RETURN("%s"), _traceattr(code))); return code; }
_nc_retrace_chtype (chtype code) { T((T_RETURN("%s"), _tracechtype(code))); return code; }
_nc_retrace_void_ptr(void *code) { T((T_RETURN("%p"), code)); return code; }
_nc_retrace_int(int code) { T((T_RETURN("%d"), code)); return code; }
_nc_retrace_win(WINDOW *code) { T((T_RETURN("%p"), code)); return code; }
_nc_retrace_sp(SCREEN * code) { T((T_RETURN("%p"), code)); return code; }
_nc_retrace_ptr(char *code) { T((T_RETURN("%s"), _nc_visbuf(code))); return code; }