1 /****************************************************************************
2 * Copyright 2018-2023,2024 Thomas E. Dickey *
3 * Copyright 2017 Free Software Foundation, Inc. *
5 * Permission is hereby granted, free of charge, to any person obtaining a *
6 * copy of this software and associated documentation files (the *
7 * "Software"), to deal in the Software without restriction, including *
8 * without limitation the rights to use, copy, modify, merge, publish, *
9 * distribute, distribute with modifications, sublicense, and/or sell *
10 * copies of the Software, and to permit persons to whom the Software is *
11 * furnished to do so, subject to the following conditions: *
13 * The above copyright notice and this permission notice shall be included *
14 * in all copies or substantial portions of the Software. *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24 * Except as contained in this notice, the name(s) of the above copyright *
25 * holders shall not be used in advertising or otherwise to promote the *
26 * sale, use or other dealings in this Software without prior written *
28 ****************************************************************************/
30 /****************************************************************************
31 * Author: Thomas E. Dickey *
32 ****************************************************************************/
34 #define NEW_PAIR_INTERNAL 1
35 #include <curses.priv.h>
37 MODULE_ID("$Id: report_offsets.c,v 1.28 2024/02/24 15:59:09 tom Exp $")
39 #define show_size(type) \
42 printf("%5lu " #type "\n", (unsigned long)sizeof(type))
43 #define show_name(name) \
44 printf("%5lu " #name "\n", (unsigned long)(name))
45 #define show_offset(type,member) \
46 next = (unsigned long)offsetof(type,member); \
48 printf("?? incorrect order for " #type "." #member "\n"); \
49 printf("%5lu %c " #type "." #member "\n", next, flag ? *flag : ' '); \
53 #if NCURSES_WIDECHAR && NCURSES_EXT_COLORS
54 #define show_COLORS(type,member) { flag = "c"; show_offset(type,member); }
56 #define show_COLORS(type,member) /* nothing */
59 #ifdef USE_TERM_DRIVER
60 #define show_DRIVER(type,member) { flag = "d"; show_offset(type,member); }
62 #define show_DRIVER(type,member) /* nothing */
66 #define show_MLEAKS(type,member) { flag = "L"; show_offset(type,member); }
68 #define show_MLEAKS(type,member) /* nothing */
71 #define show_NORMAL(type,member) { flag = "n"; show_offset(type,member); }
72 #define show_OPTION(type,member) { flag = "+"; show_offset(type,member); }
75 #define show_REENTR(type,member) { flag = "r"; show_offset(type,member); }
77 #define show_REENTR(type,member) /* nothing */
81 #define show_SPFUNC(type,member) { flag = "s"; show_offset(type,member); }
83 #define show_SPFUNC(type,member) /* nothing */
87 #define show_THREAD(type,member) { flag = "t"; show_offset(type,member); }
89 #define show_THREAD(type,member) /* nothing */
93 #define show_TRACES(type,member) { flag = "T"; show_offset(type,member); }
95 #define show_TRACES(type,member) /* nothing */
99 #define show_WIDECH(type,member) { flag = "w"; show_offset(type,member); }
101 #define show_WIDECH(type,member) /* nothing */
107 const char *flag = 0;
108 unsigned long last, next;
110 printf("Size/offsets of data structures:\n");
114 #if USE_WIDEC_SUPPORT
118 show_size(colorpair_t);
120 show_size(rgb_bits_t);
122 show_size(NCURSES_BOOL);
126 printf("Sizes of buffers/arrays:\n");
127 #if USE_WIDEC_SUPPORT
128 show_name(CCHARW_MAX);
131 show_name(FIFO_SIZE);
133 show_name(MB_LEN_MAX);
136 show_name(TRACECHR_BUF);
137 show_name(TRACEMSE_MAX);
142 show_offset(SCREEN, _ifd);
143 show_offset(SCREEN, _fifo);
144 show_offset(SCREEN, _fifohead);
145 show_offset(SCREEN, _direct_color);
146 show_offset(SCREEN, _panelHook);
147 show_offset(SCREEN, jump);
148 show_offset(SCREEN, rsp);
149 #if NCURSES_NO_PADDING
150 show_OPTION(SCREEN, _no_padding);
153 show_OPTION(SCREEN, _ht_cost);
156 show_OPTION(SCREEN, _use_ritm);
159 show_OPTION(SCREEN, _extended_key);
161 #if NCURSES_EXT_FUNCS
162 show_OPTION(SCREEN, _assumed_color);
165 show_OPTION(SCREEN, _mouse_gpm_loaded);
167 show_OPTION(SCREEN, _dlopen_gpm);
171 show_OPTION(SCREEN, _emxmouse_wfd);
174 show_OPTION(SCREEN, _sysmouse_fifo);
176 show_DRIVER(SCREEN, _drv_mouse_fifo);
178 show_OPTION(SCREEN, _resize);
180 #ifdef USE_SP_WINDOWLIST
181 show_NORMAL(SCREEN, _windowlist);
183 show_REENTR(SCREEN, _ttytype);
184 show_SPFUNC(SCREEN, use_tioctl);
185 show_WIDECH(SCREEN, _screen_acs_fix);
186 show_COLORS(SCREEN, _ordered_pairs);
187 show_TRACES(SCREEN, tracechr_buf);
191 show_offset(TERMINAL, type);
192 show_offset(TERMINAL, Filedes);
193 show_offset(TERMINAL, Ottyb);
194 show_offset(TERMINAL, Nttyb);
195 show_offset(TERMINAL, _baudrate);
196 show_offset(TERMINAL, _termname);
197 show_offset(TERMINAL, tparm_state);
198 #if HAVE_INIT_EXTENDED_COLOR
199 show_COLORS(TERMINAL, type2);
205 show_OPTION(TERMTYPE, ext_str_table);
206 show_OPTION(TERMTYPE, ext_Strings);
210 show_size(TPARM_STATE);
211 show_offset(TPARM_STATE, stack);
212 show_offset(TPARM_STATE, stack_ptr);
213 show_offset(TPARM_STATE, out_buff);
214 show_offset(TPARM_STATE, fmt_buff);
215 show_offset(TPARM_STATE, static_vars);
216 show_TRACES(TPARM_STATE, tname);
220 show_WIDECH(WINDOW, _bkgrnd);
221 show_COLORS(WINDOW, _color);
224 show_size(NCURSES_GLOBALS);
225 show_offset(NCURSES_GLOBALS, init_signals);
226 show_offset(NCURSES_GLOBALS, tgetent_cache);
227 show_offset(NCURSES_GLOBALS, dbd_vars);
229 show_offset(NCURSES_GLOBALS, cached_tparm);
231 show_DRIVER(NCURSES_GLOBALS, term_driver);
232 #ifndef USE_SP_WINDOWLIST
233 show_NORMAL(NCURSES_GLOBALS, _nc_windowlist);
235 #if USE_HOME_TERMINFO
236 show_OPTION(NCURSES_GLOBALS, home_terminfo);
238 #if !USE_SAFE_SPRINTF
239 show_OPTION(NCURSES_GLOBALS, safeprint_rows);
241 show_THREAD(NCURSES_GLOBALS, mutex_curses);
242 #if USE_PTHREADS_EINTR
243 show_THREAD(NCURSES_GLOBALS, read_thread);
245 show_WIDECH(NCURSES_GLOBALS, key_name);
246 show_TRACES(NCURSES_GLOBALS, trace_opened);
247 show_TRACES(NCURSES_GLOBALS, trace_level);
248 show_MLEAKS(NCURSES_GLOBALS, leak_checking);
251 show_size(NCURSES_PRESCREEN);
252 show_offset(NCURSES_PRESCREEN, tparm_state);
253 show_offset(NCURSES_PRESCREEN, saved_tty);
254 show_offset(NCURSES_PRESCREEN, use_tioctl);
255 show_offset(NCURSES_PRESCREEN, _outch);
256 #ifndef USE_SP_RIPOFF
257 show_NORMAL(NCURSES_PRESCREEN, rippedoff);
259 #if NCURSES_NO_PADDING
260 show_OPTION(NCURSES_PRESCREEN, _no_padding);
263 show_offset(NCURSES_PRESCREEN, real_acs_map);
265 show_REENTR(NCURSES_PRESCREEN, real_acs_map);
267 #if BROKEN_LINKER || USE_REENTRANT
268 show_TRACES(NCURSES_PRESCREEN, _outchars);