1 /****************************************************************************
2 * Copyright 2018-2021,2023 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 #include <curses.priv.h>
36 MODULE_ID("$Id: report_offsets.c,v 1.23 2023/09/23 16:47:57 tom Exp $")
38 #define show_size(type) \
41 printf("%5lu " #type "\n", (unsigned long)sizeof(type))
42 #define show_offset(type,member) \
43 next = (unsigned long)offsetof(type,member); \
45 printf("?? incorrect order for " #type "." #member "\n"); \
46 printf("%5lu %c " #type "." #member "\n", next, flag ? *flag : ' '); \
50 #if NCURSES_WIDECHAR && NCURSES_EXT_COLORS
51 #define show_COLORS(type,member) { flag = "c"; show_offset(type,member); }
53 #define show_COLORS(type,member) /* nothing */
56 #ifdef USE_TERM_DRIVER
57 #define show_DRIVER(type,member) { flag = "d"; show_offset(type,member); }
59 #define show_DRIVER(type,member) /* nothing */
63 #define show_MLEAKS(type,member) { flag = "L"; show_offset(type,member); }
65 #define show_MLEAKS(type,member) /* nothing */
68 #define show_NORMAL(type,member) { flag = "n"; show_offset(type,member); }
69 #define show_OPTION(type,member) { flag = "+"; show_offset(type,member); }
72 #define show_REENTR(type,member) { flag = "r"; show_offset(type,member); }
74 #define show_REENTR(type,member) /* nothing */
78 #define show_SPFUNC(type,member) { flag = "s"; show_offset(type,member); }
80 #define show_SPFUNC(type,member) /* nothing */
84 #define show_THREAD(type,member) { flag = "t"; show_offset(type,member); }
86 #define show_THREAD(type,member) /* nothing */
90 #define show_TRACES(type,member) { flag = "T"; show_offset(type,member); }
92 #define show_TRACES(type,member) /* nothing */
96 #define show_WIDECH(type,member) { flag = "w"; show_offset(type,member); }
98 #define show_WIDECH(type,member) /* nothing */
104 const char *flag = 0;
105 unsigned long last, next;
107 printf("Size/offsets of data structures:\n");
111 #if USE_WIDEC_SUPPORT
116 show_size(NCURSES_BOOL);
120 show_offset(SCREEN, _ifd);
121 show_offset(SCREEN, _fifo);
122 show_offset(SCREEN, _fifohead);
123 show_offset(SCREEN, _direct_color);
124 show_offset(SCREEN, _panelHook);
125 show_offset(SCREEN, jump);
126 show_offset(SCREEN, rsp);
127 #if NCURSES_NO_PADDING
128 show_OPTION(SCREEN, _no_padding);
131 show_OPTION(SCREEN, _ht_cost);
134 show_OPTION(SCREEN, _use_ritm);
137 show_OPTION(SCREEN, _extended_key);
139 #if NCURSES_EXT_FUNCS
140 show_OPTION(SCREEN, _assumed_color);
143 show_OPTION(SCREEN, _mouse_gpm_loaded);
145 show_OPTION(SCREEN, _dlopen_gpm);
149 show_OPTION(SCREEN, _emxmouse_wfd);
152 show_OPTION(SCREEN, _sysmouse_fifo);
154 show_DRIVER(SCREEN, _drv_mouse_fifo);
156 show_OPTION(SCREEN, _resize);
158 #ifdef USE_SP_WINDOWLIST
159 show_NORMAL(SCREEN, _windowlist);
161 show_REENTR(SCREEN, _ttytype);
162 show_SPFUNC(SCREEN, use_tioctl);
163 show_WIDECH(SCREEN, _screen_acs_fix);
164 show_COLORS(SCREEN, _ordered_pairs);
165 show_TRACES(SCREEN, tracechr_buf);
169 show_offset(TERMINAL, type);
170 show_offset(TERMINAL, Filedes);
171 show_offset(TERMINAL, Ottyb);
172 show_offset(TERMINAL, Nttyb);
173 show_offset(TERMINAL, _baudrate);
174 show_offset(TERMINAL, _termname);
175 show_offset(TERMINAL, tparm_state);
176 #if HAVE_INIT_EXTENDED_COLOR
177 show_COLORS(TERMINAL, type2);
183 show_OPTION(TERMTYPE, ext_str_table);
184 show_OPTION(TERMTYPE, ext_Strings);
188 show_size(TPARM_STATE);
189 show_offset(TPARM_STATE, stack);
190 show_offset(TPARM_STATE, stack_ptr);
191 show_offset(TPARM_STATE, out_buff);
192 show_offset(TPARM_STATE, fmt_buff);
193 show_offset(TPARM_STATE, static_vars);
194 show_TRACES(TPARM_STATE, tname);
198 show_WIDECH(WINDOW, _bkgrnd);
199 show_COLORS(WINDOW, _color);
202 show_size(NCURSES_GLOBALS);
203 show_offset(NCURSES_GLOBALS, init_signals);
204 show_offset(NCURSES_GLOBALS, tgetent_cache);
205 show_offset(NCURSES_GLOBALS, dbd_vars);
207 show_offset(NCURSES_GLOBALS, cached_tparm);
209 show_DRIVER(NCURSES_GLOBALS, term_driver);
210 #ifndef USE_SP_WINDOWLIST
211 show_NORMAL(NCURSES_GLOBALS, _nc_windowlist);
213 #if USE_HOME_TERMINFO
214 show_OPTION(NCURSES_GLOBALS, home_terminfo);
216 #if !USE_SAFE_SPRINTF
217 show_OPTION(NCURSES_GLOBALS, safeprint_rows);
219 show_THREAD(NCURSES_GLOBALS, mutex_curses);
220 #if USE_PTHREADS_EINTR
221 show_THREAD(NCURSES_GLOBALS, read_thread);
223 show_WIDECH(NCURSES_GLOBALS, key_name);
224 show_TRACES(NCURSES_GLOBALS, trace_opened);
225 show_MLEAKS(NCURSES_GLOBALS, leak_checking);
228 show_size(NCURSES_PRESCREEN);
229 show_offset(NCURSES_PRESCREEN, tparm_state);
230 show_offset(NCURSES_PRESCREEN, saved_tty);
231 show_offset(NCURSES_PRESCREEN, use_tioctl);
232 show_offset(NCURSES_PRESCREEN, _outch);
233 #ifndef USE_SP_RIPOFF
234 show_NORMAL(NCURSES_PRESCREEN, rippedoff);
236 #if NCURSES_NO_PADDING
237 show_OPTION(NCURSES_PRESCREEN, _no_padding);
240 show_offset(NCURSES_PRESCREEN, real_acs_map);
242 show_REENTR(NCURSES_PRESCREEN, real_acs_map);
244 #if BROKEN_LINKER || USE_REENTRANT
245 show_TRACES(NCURSES_PRESCREEN, _outchars);