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