1 /****************************************************************************
2 * Copyright (c) 2017,2018 Free Software Foundation, Inc. *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
27 ****************************************************************************/
29 /****************************************************************************
30 * Author: Thomas E. Dickey *
31 ****************************************************************************/
33 #include <curses.priv.h>
35 MODULE_ID("$Id: report_offsets.c,v 1.20 2018/07/07 19:25:40 tom Exp $")
37 #define show_size(type) \
40 printf("%5lu " #type "\n", (unsigned long)sizeof(type))
41 #define show_offset(type,member) \
42 next = (unsigned long)offsetof(type,member); \
44 printf("?? incorrect order for " #type "." #member "\n"); \
45 printf("%5lu %c " #type "." #member "\n", next, flag ? *flag : ' '); \
49 #if NCURSES_WIDECHAR && NCURSES_EXT_COLORS
50 #define show_COLORS(type,member) { flag = "c"; show_offset(type,member); }
52 #define show_COLORS(type,member) /* nothing */
55 #ifdef USE_TERM_DRIVER
56 #define show_DRIVER(type,member) { flag = "d"; show_offset(type,member); }
58 #define show_DRIVER(type,member) /* nothing */
62 #define show_MLEAKS(type,member) { flag = "L"; show_offset(type,member); }
64 #define show_MLEAKS(type,member) /* nothing */
67 #ifdef USE_TERM_DRIVER
68 #define show_NORMAL(type,member) /* nothing */
70 #define show_NORMAL(type,member) { flag = "n"; show_offset(type,member); }
73 #define show_OPTION(type,member) { flag = "+"; show_offset(type,member); }
76 #define show_REENTR(type,member) { flag = "r"; show_offset(type,member); }
78 #define show_REENTR(type,member) /* nothing */
82 #define show_SPFUNC(type,member) { flag = "s"; show_offset(type,member); }
84 #define show_SPFUNC(type,member) /* nothing */
88 #define show_THREAD(type,member) { flag = "t"; show_offset(type,member); }
90 #define show_THREAD(type,member) /* nothing */
94 #define show_TRACES(type,member) { flag = "T"; show_offset(type,member); }
96 #define show_TRACES(type,member) /* nothing */
100 #define show_WIDECH(type,member) { flag = "w"; show_offset(type,member); }
102 #define show_WIDECH(type,member) /* nothing */
108 const char *flag = 0;
109 unsigned long last, next;
111 printf("Size/offsets of data structures:\n");
115 #if USE_WIDEC_SUPPORT
120 show_size(NCURSES_BOOL);
124 show_offset(SCREEN, _ifd);
125 show_offset(SCREEN, _fifo);
126 show_offset(SCREEN, _fifohead);
127 show_offset(SCREEN, _direct_color);
128 show_offset(SCREEN, _panelHook);
129 show_offset(SCREEN, jump);
130 show_offset(SCREEN, rsp);
131 #if NCURSES_NO_PADDING
132 show_OPTION(SCREEN, _no_padding);
135 show_OPTION(SCREEN, _ht_cost);
138 show_OPTION(SCREEN, _use_ritm);
141 show_OPTION(SCREEN, _extended_key);
143 #if NCURSES_EXT_FUNCS
144 show_OPTION(SCREEN, _assumed_color);
147 show_OPTION(SCREEN, _mouse_gpm_loaded);
149 show_OPTION(SCREEN, _dlopen_gpm);
153 show_OPTION(SCREEN, _emxmouse_wfd);
156 show_OPTION(SCREEN, _sysmouse_fifo);
158 show_DRIVER(SCREEN, _drv_mouse_fifo);
160 show_OPTION(SCREEN, _resize);
162 show_DRIVER(SCREEN, _windowlist);
163 show_REENTR(SCREEN, _ttytype);
164 show_SPFUNC(SCREEN, use_tioctl);
165 show_WIDECH(SCREEN, _screen_acs_fix);
166 show_COLORS(SCREEN, _ordered_pairs);
167 show_TRACES(SCREEN, tracechr_buf);
171 show_offset(TERMINAL, type);
172 show_offset(TERMINAL, Filedes);
173 show_offset(TERMINAL, Ottyb);
174 show_offset(TERMINAL, Nttyb);
175 show_offset(TERMINAL, _baudrate);
176 show_offset(TERMINAL, _termname);
177 #if HAVE_INIT_EXTENDED_COLOR
178 show_COLORS(TERMINAL, type2);
184 show_OPTION(TERMTYPE, ext_str_table);
185 show_OPTION(TERMTYPE, ext_Strings);
190 show_WIDECH(WINDOW, _bkgrnd);
191 show_COLORS(WINDOW, _color);
194 show_size(NCURSES_GLOBALS);
195 show_offset(NCURSES_GLOBALS, init_signals);
196 show_DRIVER(NCURSES_GLOBALS, term_driver);
197 show_NORMAL(NCURSES_GLOBALS, _nc_windowlist);
198 #if USE_HOME_TERMINFO
199 show_OPTION(NCURSES_GLOBALS, home_terminfo);
201 #if !USE_SAFE_SPRINTF
202 show_OPTION(NCURSES_GLOBALS, safeprint_rows);
204 show_THREAD(NCURSES_GLOBALS, mutex_curses);
205 #if USE_PTHREADS_EINTR
206 show_THREAD(NCURSES_GLOBALS, read_thread);
208 show_WIDECH(NCURSES_GLOBALS, key_name);
209 show_TRACES(NCURSES_GLOBALS, trace_opened);
210 show_MLEAKS(NCURSES_GLOBALS, leak_checking);
213 show_size(NCURSES_PRESCREEN);
214 show_offset(NCURSES_PRESCREEN, saved_tty);
215 show_offset(NCURSES_PRESCREEN, use_tioctl);
216 show_offset(NCURSES_PRESCREEN, _outch);
217 show_NORMAL(NCURSES_PRESCREEN, rippedoff);
218 #if NCURSES_NO_PADDING
219 show_OPTION(NCURSES_PRESCREEN, _no_padding);
222 show_offset(NCURSES_PRESCREEN, real_acs_map);
224 show_REENTR(NCURSES_PRESCREEN, real_acs_map);