X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=ncurses%2Fcurses.priv.h;h=ff57cbf0ba90a04f584b73583e0294c0ce7c53a7;hb=205ea499dbbceba5201d997fbd8b6b1f7f29bd50;hp=55446a8945016a83f95eee885d2aef273e0ac7a2;hpb=81304798ee736c467839c779c9ca5dca48db7bea;p=ncurses.git diff --git a/ncurses/curses.priv.h b/ncurses/curses.priv.h index 55446a89..ff57cbf0 100644 --- a/ncurses/curses.priv.h +++ b/ncurses/curses.priv.h @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2020,2021 Thomas E. Dickey * + * Copyright 2018-2021,2022 Thomas E. Dickey * * Copyright 1998-2017,2018 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -35,7 +35,7 @@ ****************************************************************************/ /* - * $Id: curses.priv.h,v 1.642 2021/06/26 20:23:20 tom Exp $ + * $Id: curses.priv.h,v 1.653 2022/10/23 13:29:26 tom Exp $ * * curses.priv.h * @@ -141,6 +141,10 @@ extern int errno; # endif #endif +#ifndef PRIxPTR +# define PRIxPTR "lx" +#endif + /* include signal.h before curses.h to work-around defect in glibc 2.1.3 */ #include @@ -396,7 +400,7 @@ typedef union { #include -#include +#include #include #define IsPreScreen(sp) (((sp) != 0) && sp->_prescreen) @@ -575,6 +579,10 @@ NCURSES_EXPORT(int *) _nc_ptr_Escdelay (SCREEN *); #endif +#define IS_SUBWIN(w) ((w)->_flags & _SUBWIN) +#define IS_PAD(w) ((w)->_flags & _ISPAD) +#define IS_WRAPPED(w) ((w)->_flags & _WRAPPED) + #define HasHardTabs() (NonEmpty(clear_all_tabs) && NonEmpty(set_tab)) #define TR_MUTEX(data) _tracef("%s@%d: me:%08lX COUNT:%2u/%2d/%6d/%2d/%s%9u: " #data, \ @@ -668,9 +676,14 @@ extern NCURSES_EXPORT(int) _nc_sigprocmask(int, const sigset_t *, sigset_t *); #define _nc_lock_global(name) /* nothing */ #define _nc_try_global(name) 0 #define _nc_unlock_global(name) /* nothing */ - #endif /* USE_PTHREADS */ +#if USE_PTHREADS_EINTR +extern NCURSES_EXPORT(void) _nc_set_read_thread(bool); +#else +#define _nc_set_read_thread(enable) /* nothing */ +#endif + /* * When using sp-funcs, locks are targeted to SCREEN-level granularity. * So the locking is done in the non-sp-func (which calls the sp-func) rather @@ -799,12 +812,6 @@ typedef struct _SLK { #endif /* USE_TERMLIB */ -typedef struct { - WINDOW *win; /* the window used in the hook */ - int line; /* lines to take, < 0 => from bottom*/ - int (*hook)(WINDOW *, int); /* callback for user */ -} ripoff_t; - #if USE_GPM_SUPPORT #undef buttons /* term.h defines this, and gpm uses it! */ #include @@ -832,16 +839,6 @@ typedef int (*TYPE_Gpm_GetEvent) (Gpm_Event *); #endif /* HAVE_LIBDL */ #endif /* USE_GPM_SUPPORT */ -typedef struct { - long sequence; - bool last_used; - char *fix_sgr0; /* this holds the filtered sgr0 string */ - char *last_bufp; /* help with fix_sgr0 leak */ - TERMINAL *last_term; -} TGETENT_CACHE; - -#define TGETENT_MAX 4 - /* * When converting from terminfo to termcap, check for cases where we can trim * octal escapes down to 2-character form. It is useful for terminfo format @@ -852,46 +849,6 @@ typedef struct { #define isoctal(c) ((c) >= '0' && (c) <= '7') -/* - * State of tparm(). - */ -#define STACKSIZE 20 - -typedef struct { - union { - int num; - char *str; - } data; - bool num_type; -} STACK_FRAME; - -#define NUM_VARS 26 - -typedef struct { - const char *tparam_base; - - STACK_FRAME stack[STACKSIZE]; - int stack_ptr; - - char *out_buff; - size_t out_size; - size_t out_used; - - char *fmt_buff; - size_t fmt_size; - - int dynamic_var[NUM_VARS]; - int static_vars[NUM_VARS]; -#ifdef TRACE - const char *tname; -#endif -} TPARM_STATE; - -typedef struct { - char *text; - size_t size; -} TRACEBUF; - /* * The filesystem database normally uses a single-letter for the lower level * of directories. Use a hexadecimal code for filesystems which do not @@ -922,132 +879,8 @@ struct DriverTCB; /* Terminal Control Block forward declaration */ #define INIT_TERM_DRIVER() /* nothing */ #endif -typedef struct { - const char *name; - char *value; -} ITERATOR_VARS; - -/* - * Global data which is not specific to a screen. - */ -typedef struct { - SIG_ATOMIC_T have_sigtstp; - SIG_ATOMIC_T have_sigwinch; - SIG_ATOMIC_T cleanup_nested; - - bool init_signals; - bool init_screen; - - char *comp_sourcename; - char *comp_termtype; - - bool have_tic_directory; - bool keep_tic_directory; - const char *tic_directory; - - char *dbi_list; - int dbi_size; - - char *first_name; - char **keyname_table; - int init_keyname; - - int slk_format; - - int getstr_limit; /* getstr_limit based on POSIX LINE_MAX */ - - char *safeprint_buf; - size_t safeprint_used; - - TGETENT_CACHE tgetent_cache[TGETENT_MAX]; - int tgetent_index; - long tgetent_sequence; - - char *dbd_blob; /* string-heap for dbd_list[] */ - char **dbd_list; /* distinct places to look for data */ - int dbd_size; /* length of dbd_list[] */ - time_t dbd_time; /* cache last updated */ - ITERATOR_VARS dbd_vars[dbdLAST]; - -#if HAVE_TSEARCH - void *cached_tparm; - int count_tparm; -#endif /* HAVE_TSEARCH */ - -#ifdef USE_TERM_DRIVER - int (*term_driver)(struct DriverTCB*, const char*, int*); -#endif - -#ifndef USE_SP_WINDOWLIST - WINDOWLIST *_nc_windowlist; -#define WindowList(sp) _nc_globals._nc_windowlist -#endif - -#if USE_HOME_TERMINFO - char *home_terminfo; -#endif - -#if !USE_SAFE_SPRINTF - int safeprint_cols; - int safeprint_rows; -#endif - -#ifdef USE_PTHREADS - pthread_mutex_t mutex_curses; - pthread_mutex_t mutex_prescreen; - pthread_mutex_t mutex_screen; - pthread_mutex_t mutex_update; - pthread_mutex_t mutex_tst_tracef; - pthread_mutex_t mutex_tracef; - int nested_tracef; - int use_pthreads; -#define _nc_use_pthreads _nc_globals.use_pthreads -#if USE_PTHREADS_EINTR - pthread_t read_thread; /* The reading thread */ -#endif -#endif -#if USE_WIDEC_SUPPORT - char key_name[MB_LEN_MAX + 1]; -#endif - -#ifdef TRACE - bool trace_opened; - char trace_fname[PATH_MAX]; - int trace_level; - FILE *trace_fp; - int trace_fd; - - char *tracearg_buf; - size_t tracearg_used; - - TRACEBUF *tracebuf_ptr; - size_t tracebuf_used; - - char tracechr_buf[40]; - - char *tracedmp_buf; - size_t tracedmp_used; - - unsigned char *tracetry_buf; - size_t tracetry_used; - - char traceatr_color_buf[2][80]; - int traceatr_color_sel; - int traceatr_color_last; -#if !defined(USE_PTHREADS) && USE_REENTRANT - int nested_tracef; -#endif -#endif /* TRACE */ - -#if NO_LEAKS - bool leak_checking; -#endif -} NCURSES_GLOBALS; - extern NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals; -#define N_RIPS 5 - /* The limit reserves one byte for a terminating NUL */ #define my_getstr_limit (_nc_globals.getstr_limit - 1) #define _nc_getstr_limit(n) \ @@ -1057,54 +890,6 @@ extern NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals; ? my_getstr_limit \ : (n))) -#ifdef USE_PTHREADS -typedef struct _prescreen_list { - struct _prescreen_list *next; - pthread_t id; - struct screen *sp; -} PRESCREEN_LIST; -#endif - -/* - * Global data which can be swept up into a SCREEN when one is created. - * It may be modified before the next SCREEN is created. - */ -typedef struct { -#ifdef USE_PTHREADS - PRESCREEN_LIST *allocated; -#else - struct screen * allocated; -#endif - bool use_env; - bool filter_mode; - attr_t previous_attr; - TPARM_STATE tparm_state; - TTY *saved_tty; /* savetty/resetty information */ - bool use_tioctl; - NCURSES_SP_OUTC _outch; /* output handler if not putc */ -#ifndef USE_SP_RIPOFF - ripoff_t rippedoff[N_RIPS]; - ripoff_t *rsp; -#endif -#if NCURSES_NO_PADDING - bool _no_padding; /* flag to set if padding disabled */ -#endif -#if BROKEN_LINKER || USE_REENTRANT - chtype *real_acs_map; - int _LINES; - int _COLS; - int _TABSIZE; - int _ESCDELAY; - TERMINAL *_cur_term; -#endif -#ifdef TRACE -#if BROKEN_LINKER || USE_REENTRANT - long _outchars; - const char *_tputs_trace; -#endif -#endif -} NCURSES_PRESCREEN; - /* * Use screen-specific ripoff data (for softkeys) rather than global. */ @@ -1127,8 +912,7 @@ typedef enum { /* * The SCREEN structure. */ - -struct screen { +typedef struct screen { int _ifd; /* input file descriptor for screen */ int _ofd; /* output file descriptor for screen */ FILE *_ofp; /* output file ptr for screen */ @@ -1412,7 +1196,8 @@ struct screen { const char *_tputs_trace; #endif #endif -}; +#undef SCREEN +} SCREEN; extern NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain; extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; @@ -1730,6 +1515,13 @@ extern NCURSES_EXPORT_VAR(SIG_ATOMIC_T) _nc_have_sigwinch; _nc_err_abort(MSG_NO_MEMORY); \ } while (0) +#define TYPE_CALLOC(type, size, name) \ + do { \ + name = typeCalloc(type, size); \ + if (name == 0) \ + _nc_err_abort(MSG_NO_MEMORY); \ + } while (0) + #define TYPE_REALLOC(type, size, name) \ do { \ name = typeRealloc(type, size, name); \ @@ -1843,6 +1635,8 @@ typedef void VoidFunc(void); #define returnWin(code) TRACE_RETURN1(code,win) #define returnDB(rc) do { TR(TRACE_DATABASE,(T_RETURN("code %d"), (rc))); return (rc); } while (0) +#define returnPtrDB(rc) do { TR(TRACE_DATABASE,(T_RETURN("%p"), (rc))); return (rc); } while (0) +#define returnVoidDB do { TR(TRACE_DATABASE,(T_RETURN(""))); return; } while (0) extern NCURSES_EXPORT(NCURSES_BOOL) _nc_retrace_bool (int); extern NCURSES_EXPORT(NCURSES_CONST void *) _nc_retrace_cvoid_ptr (NCURSES_CONST void *); @@ -1917,6 +1711,8 @@ extern NCURSES_EXPORT(const char *) _nc_viscbuf (const NCURSES_CH_T *, int); #define returnWin(code) return code #define returnDB(code) return code +#define returnPtrDB(rc) return rc +#define returnVoidDB return #endif /* TRACE/!TRACE */ @@ -2440,7 +2236,7 @@ extern NCURSES_EXPORT_VAR(SCREEN *) SP; /* * We don't want to use the lines or columns capabilities internally, because - * if the application is running multiple screens under X, it's quite possible + * if the application is running multiple screens under X, it is quite possible * they could all have type xterm but have different sizes! So... */ #define screen_lines(sp) (sp)->_lines