1 /****************************************************************************
2 * Copyright 2018,2020 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.21 2020/02/02 23:34:34 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 #ifdef USE_TERM_DRIVER
69 #define show_NORMAL(type,member) /* nothing */
71 #define show_NORMAL(type,member) { flag = "n"; show_offset(type,member); }
74 #define show_OPTION(type,member) { flag = "+"; show_offset(type,member); }
77 #define show_REENTR(type,member) { flag = "r"; show_offset(type,member); }
79 #define show_REENTR(type,member) /* nothing */
83 #define show_SPFUNC(type,member) { flag = "s"; show_offset(type,member); }
85 #define show_SPFUNC(type,member) /* nothing */
89 #define show_THREAD(type,member) { flag = "t"; show_offset(type,member); }
91 #define show_THREAD(type,member) /* nothing */
95 #define show_TRACES(type,member) { flag = "T"; show_offset(type,member); }
97 #define show_TRACES(type,member) /* nothing */
100 #if USE_WIDEC_SUPPORT
101 #define show_WIDECH(type,member) { flag = "w"; show_offset(type,member); }
103 #define show_WIDECH(type,member) /* nothing */
109 const char *flag = 0;
110 unsigned long last, next;
112 printf("Size/offsets of data structures:\n");
116 #if USE_WIDEC_SUPPORT
121 show_size(NCURSES_BOOL);
125 show_offset(SCREEN, _ifd);
126 show_offset(SCREEN, _fifo);
127 show_offset(SCREEN, _fifohead);
128 show_offset(SCREEN, _direct_color);
129 show_offset(SCREEN, _panelHook);
130 show_offset(SCREEN, jump);
131 show_offset(SCREEN, rsp);
132 #if NCURSES_NO_PADDING
133 show_OPTION(SCREEN, _no_padding);
136 show_OPTION(SCREEN, _ht_cost);
139 show_OPTION(SCREEN, _use_ritm);
142 show_OPTION(SCREEN, _extended_key);
144 #if NCURSES_EXT_FUNCS
145 show_OPTION(SCREEN, _assumed_color);
148 show_OPTION(SCREEN, _mouse_gpm_loaded);
150 show_OPTION(SCREEN, _dlopen_gpm);
154 show_OPTION(SCREEN, _emxmouse_wfd);
157 show_OPTION(SCREEN, _sysmouse_fifo);
159 show_DRIVER(SCREEN, _drv_mouse_fifo);
161 show_OPTION(SCREEN, _resize);
163 show_DRIVER(SCREEN, _windowlist);
164 show_REENTR(SCREEN, _ttytype);
165 show_SPFUNC(SCREEN, use_tioctl);
166 show_WIDECH(SCREEN, _screen_acs_fix);
167 show_COLORS(SCREEN, _ordered_pairs);
168 show_TRACES(SCREEN, tracechr_buf);
172 show_offset(TERMINAL, type);
173 show_offset(TERMINAL, Filedes);
174 show_offset(TERMINAL, Ottyb);
175 show_offset(TERMINAL, Nttyb);
176 show_offset(TERMINAL, _baudrate);
177 show_offset(TERMINAL, _termname);
178 #if HAVE_INIT_EXTENDED_COLOR
179 show_COLORS(TERMINAL, type2);
185 show_OPTION(TERMTYPE, ext_str_table);
186 show_OPTION(TERMTYPE, ext_Strings);
191 show_WIDECH(WINDOW, _bkgrnd);
192 show_COLORS(WINDOW, _color);
195 show_size(NCURSES_GLOBALS);
196 show_offset(NCURSES_GLOBALS, init_signals);
197 show_DRIVER(NCURSES_GLOBALS, term_driver);
198 show_NORMAL(NCURSES_GLOBALS, _nc_windowlist);
199 #if USE_HOME_TERMINFO
200 show_OPTION(NCURSES_GLOBALS, home_terminfo);
202 #if !USE_SAFE_SPRINTF
203 show_OPTION(NCURSES_GLOBALS, safeprint_rows);
205 show_THREAD(NCURSES_GLOBALS, mutex_curses);
206 #if USE_PTHREADS_EINTR
207 show_THREAD(NCURSES_GLOBALS, read_thread);
209 show_WIDECH(NCURSES_GLOBALS, key_name);
210 show_TRACES(NCURSES_GLOBALS, trace_opened);
211 show_MLEAKS(NCURSES_GLOBALS, leak_checking);
214 show_size(NCURSES_PRESCREEN);
215 show_offset(NCURSES_PRESCREEN, saved_tty);
216 show_offset(NCURSES_PRESCREEN, use_tioctl);
217 show_offset(NCURSES_PRESCREEN, _outch);
218 show_NORMAL(NCURSES_PRESCREEN, rippedoff);
219 #if NCURSES_NO_PADDING
220 show_OPTION(NCURSES_PRESCREEN, _no_padding);
223 show_offset(NCURSES_PRESCREEN, real_acs_map);
225 show_REENTR(NCURSES_PRESCREEN, real_acs_map);