]> ncurses.scripts.mit.edu Git - ncurses.git/blob - ncurses/report_offsets.c
ncurses 6.3 - patch 20220514
[ncurses.git] / ncurses / report_offsets.c
1 /****************************************************************************
2  * Copyright 2018-2020,2021 Thomas E. Dickey                                *
3  * Copyright 2017 Free Software Foundation, Inc.                            *
4  *                                                                          *
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:                 *
12  *                                                                          *
13  * The above copyright notice and this permission notice shall be included  *
14  * in all copies or substantial portions of the Software.                   *
15  *                                                                          *
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.                               *
23  *                                                                          *
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       *
27  * authorization.                                                           *
28  ****************************************************************************/
29
30 /****************************************************************************
31  *  Author: Thomas E. Dickey                                                *
32  ****************************************************************************/
33
34 #include <curses.priv.h>
35
36 MODULE_ID("$Id: report_offsets.c,v 1.22 2021/08/19 19:51:33 tom Exp $")
37
38 #define show_size(type) \
39         flag = 0; \
40         last = 0; \
41         printf("%5lu   " #type "\n", (unsigned long)sizeof(type))
42 #define show_offset(type,member) \
43         next = (unsigned long)offsetof(type,member); \
44         if (last > next) \
45                 printf("?? incorrect order for " #type "." #member "\n"); \
46         printf("%5lu %c " #type "." #member "\n", next, flag ? *flag : ' '); \
47         last = next; \
48         flag = 0
49
50 #if NCURSES_WIDECHAR && NCURSES_EXT_COLORS
51 #define show_COLORS(type,member) { flag = "c"; show_offset(type,member); }
52 #else
53 #define show_COLORS(type,member)        /* nothing */
54 #endif
55
56 #ifdef USE_TERM_DRIVER
57 #define show_DRIVER(type,member) { flag = "d"; show_offset(type,member); }
58 #else
59 #define show_DRIVER(type,member)        /* nothing */
60 #endif
61
62 #if NO_LEAKS
63 #define show_MLEAKS(type,member) { flag = "L"; show_offset(type,member); }
64 #else
65 #define show_MLEAKS(type,member)        /* nothing */
66 #endif
67
68 #ifdef USE_TERM_DRIVER
69 #define show_NORMAL(type,member)        /* nothing */
70 #else
71 #define show_NORMAL(type,member) { flag = "n"; show_offset(type,member); }
72 #endif
73
74 #define show_OPTION(type,member) { flag = "+"; show_offset(type,member); }
75
76 #if USE_REENTRANT
77 #define show_REENTR(type,member) { flag = "r"; show_offset(type,member); }
78 #else
79 #define show_REENTR(type,member)        /* nothing */
80 #endif
81
82 #if NCURSES_SP_FUNCS
83 #define show_SPFUNC(type,member) { flag = "s"; show_offset(type,member); }
84 #else
85 #define show_SPFUNC(type,member)        /* nothing */
86 #endif
87
88 #ifdef USE_PTHREADS
89 #define show_THREAD(type,member) { flag = "t"; show_offset(type,member); }
90 #else
91 #define show_THREAD(type,member)        /* nothing */
92 #endif
93
94 #ifdef TRACE
95 #define show_TRACES(type,member) { flag = "T"; show_offset(type,member); }
96 #else
97 #define show_TRACES(type,member)        /* nothing */
98 #endif
99
100 #if USE_WIDEC_SUPPORT
101 #define show_WIDECH(type,member) { flag = "w"; show_offset(type,member); }
102 #else
103 #define show_WIDECH(type,member)        /* nothing */
104 #endif
105
106 int
107 main(void)
108 {
109     const char *flag = 0;
110     unsigned long last, next;
111
112     printf("Size/offsets of data structures:\n");
113
114     show_size(attr_t);
115     show_size(chtype);
116 #if USE_WIDEC_SUPPORT
117     show_size(cchar_t);
118 #endif
119     show_size(mmask_t);
120     show_size(MEVENT);
121     show_size(NCURSES_BOOL);
122
123     printf("\n");
124     show_size(SCREEN);
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);
134 #endif
135 #if USE_HARD_TABS
136     show_OPTION(SCREEN, _ht_cost);
137 #endif
138 #if USE_ITALIC
139     show_OPTION(SCREEN, _use_ritm);
140 #endif
141 #if USE_KLIBC_KBD
142     show_OPTION(SCREEN, _extended_key);
143 #endif
144 #if NCURSES_EXT_FUNCS
145     show_OPTION(SCREEN, _assumed_color);
146 #endif
147 #if USE_GPM_SUPPORT
148     show_OPTION(SCREEN, _mouse_gpm_loaded);
149 #ifdef HAVE_LIBDL
150     show_OPTION(SCREEN, _dlopen_gpm);
151 #endif
152 #endif
153 #if USE_EMX_MOUSE
154     show_OPTION(SCREEN, _emxmouse_wfd);
155 #endif
156 #if USE_SYSMOUSE
157     show_OPTION(SCREEN, _sysmouse_fifo);
158 #endif
159     show_DRIVER(SCREEN, _drv_mouse_fifo);
160 #if USE_SIZECHANGE
161     show_OPTION(SCREEN, _resize);
162 #endif
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);
169
170     printf("\n");
171     show_size(TERMINAL);
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     show_offset(TERMINAL, tparm_state);
179 #if HAVE_INIT_EXTENDED_COLOR
180     show_COLORS(TERMINAL, type2);
181 #endif
182
183     printf("\n");
184     show_size(TERMTYPE);
185 #if NCURSES_XNAMES
186     show_OPTION(TERMTYPE, ext_str_table);
187     show_OPTION(TERMTYPE, ext_Strings);
188 #endif
189
190     printf("\n");
191     show_size(TPARM_STATE);
192     show_offset(TPARM_STATE, stack);
193     show_offset(TPARM_STATE, stack_ptr);
194     show_offset(TPARM_STATE, out_buff);
195     show_offset(TPARM_STATE, fmt_buff);
196     show_offset(TPARM_STATE, static_vars);
197     show_TRACES(TPARM_STATE, tname);
198
199     printf("\n");
200     show_size(WINDOW);
201     show_WIDECH(WINDOW, _bkgrnd);
202     show_COLORS(WINDOW, _color);
203
204     printf("\n");
205     show_size(NCURSES_GLOBALS);
206     show_offset(NCURSES_GLOBALS, init_signals);
207     show_offset(NCURSES_GLOBALS, tgetent_cache);
208     show_offset(NCURSES_GLOBALS, dbd_vars);
209 #if HAVE_TSEARCH
210     show_offset(NCURSES_GLOBALS, cached_tparm);
211 #endif
212     show_DRIVER(NCURSES_GLOBALS, term_driver);
213     show_NORMAL(NCURSES_GLOBALS, _nc_windowlist);
214 #if USE_HOME_TERMINFO
215     show_OPTION(NCURSES_GLOBALS, home_terminfo);
216 #endif
217 #if !USE_SAFE_SPRINTF
218     show_OPTION(NCURSES_GLOBALS, safeprint_rows);
219 #endif
220     show_THREAD(NCURSES_GLOBALS, mutex_curses);
221 #if USE_PTHREADS_EINTR
222     show_THREAD(NCURSES_GLOBALS, read_thread);
223 #endif
224     show_WIDECH(NCURSES_GLOBALS, key_name);
225     show_TRACES(NCURSES_GLOBALS, trace_opened);
226     show_MLEAKS(NCURSES_GLOBALS, leak_checking);
227
228     printf("\n");
229     show_size(NCURSES_PRESCREEN);
230     show_offset(NCURSES_PRESCREEN, tparm_state);
231     show_offset(NCURSES_PRESCREEN, saved_tty);
232     show_offset(NCURSES_PRESCREEN, use_tioctl);
233     show_offset(NCURSES_PRESCREEN, _outch);
234 #ifndef USE_SP_RIPOFF
235     show_NORMAL(NCURSES_PRESCREEN, rippedoff);
236 #endif
237 #if NCURSES_NO_PADDING
238     show_OPTION(NCURSES_PRESCREEN, _no_padding);
239 #endif
240 #if BROKEN_LINKER
241     show_offset(NCURSES_PRESCREEN, real_acs_map);
242 #else
243     show_REENTR(NCURSES_PRESCREEN, real_acs_map);
244 #endif
245 #if BROKEN_LINKER || USE_REENTRANT
246     show_TRACES(NCURSES_PRESCREEN, _outchars);
247 #endif
248
249     return EXIT_SUCCESS;
250 }