ncurses 6.2 - patch 20200816
[ncurses.git] / Ada95 / gen / gen.c
1 /****************************************************************************
2  * Copyright 2020 Thomas E. Dickey                                          *
3  * Copyright 1998-2014,2016 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:  Juergen Pfeifer, 1996                                         *
32  *      and:  Thomas E. Dickey, 1998                                        *
33  *      and:  Nicolas Boulenguez, 2011                                      *
34  ****************************************************************************/
35
36 /*
37     Version Control
38     $Id: gen.c,v 1.77 2020/08/16 18:05:05 tom Exp $
39   --------------------------------------------------------------------------*/
40 /*
41   This program prints on its standard output the source for the
42   Terminal_Interface.Curses_Constants Ada package specification. This pure
43   package only exports C constants to the Ada compiler.
44  */
45
46 #ifdef HAVE_CONFIG_H
47 #include <ncurses_cfg.h>
48 #else
49 #include <ncurses.h>
50 #endif
51
52 #include <stdlib.h>
53 #include <string.h>
54
55 #include <menu.h>
56 #include <form.h>
57
58 #undef UCHAR
59 #undef UINT
60 #undef ULONG
61
62 typedef unsigned char UCHAR;
63 typedef unsigned int UINT;
64 typedef unsigned long ULONG;
65
66 /* These global variables will be set by main () */
67 static int little_endian;
68 static const char *my_program_invocation_name = NULL;
69
70 static void
71 my_error(const char *message)
72 {
73   fprintf(stderr, "%s: %s\n", my_program_invocation_name, message);
74   exit(EXIT_FAILURE);
75 }
76
77 static void
78 print_constant(FILE * fp,
79                const char *name,
80                UINT value)
81 {
82   fprintf(fp, "   %-28s : constant := %u;\n", name, value);
83 }
84
85 static void
86 print_long_val(FILE * fp,
87                const char *name,
88                long value)
89 {
90   fprintf(fp, "   %-28s : constant := %ld;\n", name, value);
91 }
92
93 static void
94 print_size_of(FILE * fp,
95               const char *name,
96               size_t value)
97 {
98   fprintf(fp, "   %-28s : constant := %lu;\n", name, value);
99 }
100
101 #define PRINT_NAMED_CONSTANT(name) \
102   print_long_val (fp, #name, name)
103
104 static void
105 print_comment(FILE * fp, const char *message)
106 {
107   fprintf(fp, "\n   --  %s\n\n", message);
108 }
109
110 /*
111  * Make sure that KEY_MIN and KEY_MAX are defined.
112  * main () will protest if KEY_MIN == 256
113  */
114 #ifndef KEY_MAX
115 #  define KEY_MAX 0777
116 #endif
117 #ifndef KEY_MIN
118 #  define KEY_MIN 0401
119 #endif
120
121 static UCHAR
122 bit_is_set(const UCHAR * const data,
123            const UINT offset)
124 {
125   const UCHAR byte = data[offset >> 3];
126   UINT bit;
127
128   if (little_endian)
129     bit = offset;               /* offset */
130   else                          /* or */
131     bit = ~offset;              /* 7 - offset */
132   bit &= 7;                     /* modulo 8 */
133   return (UCHAR) (byte & (1 << bit));
134 }
135
136 /* Find lowest and highest used offset in a byte array. */
137 /* Returns 0 if and only if all bits are unset. */
138 static int
139 find_pos(const UCHAR * const data,
140          const UINT sizeof_data,
141          UINT * const low,
142          UINT * const high)
143 {
144   const UINT last = (sizeof_data << 3) - 1;
145   UINT offset;
146
147   for (offset = last; !bit_is_set(data, offset); offset--)
148     if (!offset)                /* All bits are 0. */
149       return 0;
150   *high = offset;
151
152   for (offset = 0; !bit_is_set(data, offset); offset++)
153     {
154     }
155   *low = offset;
156
157   return -1;
158 }
159
160 #define PRINT_BITMASK(c_type, ada_name, mask_macro)                     \
161   {                                                                     \
162     UINT first, last;                                                   \
163     c_type mask = (mask_macro);                                         \
164     if (!find_pos ((UCHAR *)&mask, sizeof (mask), &first, &last))       \
165       my_error ("failed to locate " ada_name);                          \
166     print_constant (fp, ada_name "_First", first);                      \
167     print_constant (fp, ada_name "_Last", last);                        \
168   }
169
170 #define PRINT_NAMED_BITMASK(c_type, mask_macro)         \
171   PRINT_BITMASK (c_type, #mask_macro, mask_macro)
172
173 #define STRUCT_OFFSET(record, field)                                    \
174   {                                                                     \
175     UINT first, last;                                                   \
176     record mask;                                                        \
177     memset (&mask, 0, sizeof (mask));                                   \
178     memset (&mask.field, 0xff, sizeof(mask.field));                     \
179     if (!find_pos ((UCHAR *)&mask, sizeof (mask), &first, &last))       \
180       my_error ("failed to locate" #record "_" #field);                 \
181     print_constant (fp, #record "_" #field "_First", first);            \
182     print_constant (fp, #record "_" #field "_Last", last);              \
183   }
184
185 /*--------------------*/
186 /*  Start of main (). */
187 /*--------------------*/
188
189 int
190 main(int argc, const char *argv[])
191 {
192   FILE *fp = 0;
193   const int x = 0x12345678;
194
195   little_endian = (*((const char *)&x) == 0x78);
196
197   my_program_invocation_name = argv[0];
198
199   if (KEY_MIN == 256)
200     my_error("unexpected value for KEY_MIN: 256");
201
202   if (argc == 3)
203     {
204       fp = fopen(argv[2], "wb");
205     }
206   else if (argc == 2)
207     {
208       fp = stdout;
209     }
210   else
211     {
212       my_error("Only one or two arguments expected (DFT_ARG_SUFFIX)");
213     }
214
215   if ((strlen(argv[0]) + strlen(__FILE__)) > 25)
216     {
217       fprintf(fp, "--  Generated by the C program %.40s.\n",
218               my_program_invocation_name);
219     }
220   else
221     {
222       fprintf(fp, "--  Generated by the C program %s (source %s).\n",
223               my_program_invocation_name,
224               __FILE__);
225     }
226   fprintf(fp, "--  Do not edit this file directly.\n");
227   fprintf(fp, "--  The values provided here may vary on your system.\n");
228   fprintf(fp, "\n");
229   fprintf(fp, "with System;\n");
230   fprintf(fp, "package Terminal_Interface.Curses_Constants is\n");
231   fprintf(fp, "   pragma Pure;\n");
232   fprintf(fp, "\n");
233
234   fprintf(fp, "   DFT_ARG_SUFFIX : constant String := \"%s\";\n", argv[1]);
235   fprintf(fp,
236           "   Bit_Order : constant System.Bit_Order := System.%s_Order_First;\n",
237           little_endian ? "Low" : "High");
238   print_size_of(fp, "Sizeof_Bool", 8 * sizeof(bool));
239
240   PRINT_NAMED_CONSTANT(OK);
241   PRINT_NAMED_CONSTANT(ERR);
242   fprintf(fp,
243           "   pragma Warnings (Off); -- redefinition of Standard.True and False\n");
244   PRINT_NAMED_CONSTANT(TRUE);
245   PRINT_NAMED_CONSTANT(FALSE);
246   fprintf(fp, "   pragma Warnings (On);\n");
247
248   print_comment(fp, "Version of the ncurses library from extensions(3NCURSES)");
249   PRINT_NAMED_CONSTANT(NCURSES_VERSION_MAJOR);
250   PRINT_NAMED_CONSTANT(NCURSES_VERSION_MINOR);
251   fprintf(fp, "   Version : constant String := \"%d.%d\";\n",
252           NCURSES_VERSION_MAJOR, NCURSES_VERSION_MINOR);
253
254   print_comment(fp, "Character non-color attributes from attr(3NCURSES)");
255   fprintf(fp, "   --  attr_t and chtype may be signed in C.\n");
256   fprintf(fp, "   type attr_t is mod 2 ** %lu;\n", (long unsigned)(8 * sizeof(attr_t)));
257   PRINT_NAMED_BITMASK(attr_t, A_CHARTEXT);
258   PRINT_NAMED_BITMASK(attr_t, A_COLOR);
259   PRINT_BITMASK(attr_t, "Attr", A_ATTRIBUTES & ~A_COLOR);
260   PRINT_NAMED_BITMASK(attr_t, A_STANDOUT);
261   PRINT_NAMED_BITMASK(attr_t, A_UNDERLINE);
262   PRINT_NAMED_BITMASK(attr_t, A_REVERSE);
263   PRINT_NAMED_BITMASK(attr_t, A_BLINK);
264   PRINT_NAMED_BITMASK(attr_t, A_DIM);
265   PRINT_NAMED_BITMASK(attr_t, A_BOLD);
266   PRINT_NAMED_BITMASK(attr_t, A_PROTECT);
267   PRINT_NAMED_BITMASK(attr_t, A_INVIS);
268   PRINT_NAMED_BITMASK(attr_t, A_ALTCHARSET);
269   PRINT_NAMED_BITMASK(attr_t, A_HORIZONTAL);
270   PRINT_NAMED_BITMASK(attr_t, A_LEFT);
271   PRINT_NAMED_BITMASK(attr_t, A_LOW);
272   PRINT_NAMED_BITMASK(attr_t, A_RIGHT);
273   PRINT_NAMED_BITMASK(attr_t, A_TOP);
274   PRINT_NAMED_BITMASK(attr_t, A_VERTICAL);
275   print_size_of(fp, "chtype_Size", 8 * sizeof(chtype));
276
277   print_comment(fp, "predefined color numbers from color(3NCURSES)");
278   PRINT_NAMED_CONSTANT(COLOR_BLACK);
279   PRINT_NAMED_CONSTANT(COLOR_RED);
280   PRINT_NAMED_CONSTANT(COLOR_GREEN);
281   PRINT_NAMED_CONSTANT(COLOR_YELLOW);
282   PRINT_NAMED_CONSTANT(COLOR_BLUE);
283   PRINT_NAMED_CONSTANT(COLOR_MAGENTA);
284   PRINT_NAMED_CONSTANT(COLOR_CYAN);
285   PRINT_NAMED_CONSTANT(COLOR_WHITE);
286
287   print_comment(fp, "ETI return codes from ncurses.h");
288   PRINT_NAMED_CONSTANT(E_OK);
289   PRINT_NAMED_CONSTANT(E_SYSTEM_ERROR);
290   PRINT_NAMED_CONSTANT(E_BAD_ARGUMENT);
291   PRINT_NAMED_CONSTANT(E_POSTED);
292   PRINT_NAMED_CONSTANT(E_CONNECTED);
293   PRINT_NAMED_CONSTANT(E_BAD_STATE);
294   PRINT_NAMED_CONSTANT(E_NO_ROOM);
295   PRINT_NAMED_CONSTANT(E_NOT_POSTED);
296   PRINT_NAMED_CONSTANT(E_UNKNOWN_COMMAND);
297   PRINT_NAMED_CONSTANT(E_NO_MATCH);
298   PRINT_NAMED_CONSTANT(E_NOT_SELECTABLE);
299   PRINT_NAMED_CONSTANT(E_NOT_CONNECTED);
300   PRINT_NAMED_CONSTANT(E_REQUEST_DENIED);
301   PRINT_NAMED_CONSTANT(E_INVALID_FIELD);
302   PRINT_NAMED_CONSTANT(E_CURRENT);
303
304   print_comment(fp, "Input key codes not defined in any ncurses manpage");
305   PRINT_NAMED_CONSTANT(KEY_MIN);
306   PRINT_NAMED_CONSTANT(KEY_MAX);
307 #ifdef KEY_CODE_YES
308   PRINT_NAMED_CONSTANT(KEY_CODE_YES);
309 #endif
310
311   print_comment(fp, "Input key codes from getch(3NCURSES)");
312   PRINT_NAMED_CONSTANT(KEY_BREAK);
313   PRINT_NAMED_CONSTANT(KEY_DOWN);
314   PRINT_NAMED_CONSTANT(KEY_UP);
315   PRINT_NAMED_CONSTANT(KEY_LEFT);
316   PRINT_NAMED_CONSTANT(KEY_RIGHT);
317   PRINT_NAMED_CONSTANT(KEY_HOME);
318   PRINT_NAMED_CONSTANT(KEY_BACKSPACE);
319   PRINT_NAMED_CONSTANT(KEY_F0);
320 #define PRINT_NAMED_FUNC_KEY(name) print_constant(fp, "KEY_F"#name, KEY_F(name))
321   PRINT_NAMED_FUNC_KEY(1);
322   PRINT_NAMED_FUNC_KEY(2);
323   PRINT_NAMED_FUNC_KEY(3);
324   PRINT_NAMED_FUNC_KEY(4);
325   PRINT_NAMED_FUNC_KEY(5);
326   PRINT_NAMED_FUNC_KEY(6);
327   PRINT_NAMED_FUNC_KEY(7);
328   PRINT_NAMED_FUNC_KEY(8);
329   PRINT_NAMED_FUNC_KEY(9);
330   PRINT_NAMED_FUNC_KEY(10);
331   PRINT_NAMED_FUNC_KEY(11);
332   PRINT_NAMED_FUNC_KEY(12);
333   PRINT_NAMED_FUNC_KEY(13);
334   PRINT_NAMED_FUNC_KEY(14);
335   PRINT_NAMED_FUNC_KEY(15);
336   PRINT_NAMED_FUNC_KEY(16);
337   PRINT_NAMED_FUNC_KEY(17);
338   PRINT_NAMED_FUNC_KEY(18);
339   PRINT_NAMED_FUNC_KEY(19);
340   PRINT_NAMED_FUNC_KEY(20);
341   PRINT_NAMED_FUNC_KEY(21);
342   PRINT_NAMED_FUNC_KEY(22);
343   PRINT_NAMED_FUNC_KEY(23);
344   PRINT_NAMED_FUNC_KEY(24);
345   PRINT_NAMED_CONSTANT(KEY_DL);
346   PRINT_NAMED_CONSTANT(KEY_IL);
347   PRINT_NAMED_CONSTANT(KEY_DC);
348   PRINT_NAMED_CONSTANT(KEY_IC);
349   PRINT_NAMED_CONSTANT(KEY_EIC);
350   PRINT_NAMED_CONSTANT(KEY_CLEAR);
351   PRINT_NAMED_CONSTANT(KEY_EOS);
352   PRINT_NAMED_CONSTANT(KEY_EOL);
353   PRINT_NAMED_CONSTANT(KEY_SF);
354   PRINT_NAMED_CONSTANT(KEY_SR);
355   PRINT_NAMED_CONSTANT(KEY_NPAGE);
356   PRINT_NAMED_CONSTANT(KEY_PPAGE);
357   PRINT_NAMED_CONSTANT(KEY_STAB);
358   PRINT_NAMED_CONSTANT(KEY_CTAB);
359   PRINT_NAMED_CONSTANT(KEY_CATAB);
360   PRINT_NAMED_CONSTANT(KEY_ENTER);
361   PRINT_NAMED_CONSTANT(KEY_SRESET);
362   PRINT_NAMED_CONSTANT(KEY_RESET);
363   PRINT_NAMED_CONSTANT(KEY_PRINT);
364   PRINT_NAMED_CONSTANT(KEY_LL);
365   PRINT_NAMED_CONSTANT(KEY_A1);
366   PRINT_NAMED_CONSTANT(KEY_A3);
367   PRINT_NAMED_CONSTANT(KEY_B2);
368   PRINT_NAMED_CONSTANT(KEY_C1);
369   PRINT_NAMED_CONSTANT(KEY_C3);
370   PRINT_NAMED_CONSTANT(KEY_BTAB);
371   PRINT_NAMED_CONSTANT(KEY_BEG);
372   PRINT_NAMED_CONSTANT(KEY_CANCEL);
373   PRINT_NAMED_CONSTANT(KEY_CLOSE);
374   PRINT_NAMED_CONSTANT(KEY_COMMAND);
375   PRINT_NAMED_CONSTANT(KEY_COPY);
376   PRINT_NAMED_CONSTANT(KEY_CREATE);
377   PRINT_NAMED_CONSTANT(KEY_END);
378   PRINT_NAMED_CONSTANT(KEY_EXIT);
379   PRINT_NAMED_CONSTANT(KEY_FIND);
380   PRINT_NAMED_CONSTANT(KEY_HELP);
381   PRINT_NAMED_CONSTANT(KEY_MARK);
382   PRINT_NAMED_CONSTANT(KEY_MESSAGE);
383   PRINT_NAMED_CONSTANT(KEY_MOVE);
384   PRINT_NAMED_CONSTANT(KEY_NEXT);
385   PRINT_NAMED_CONSTANT(KEY_OPEN);
386   PRINT_NAMED_CONSTANT(KEY_OPTIONS);
387   PRINT_NAMED_CONSTANT(KEY_PREVIOUS);
388   PRINT_NAMED_CONSTANT(KEY_REDO);
389   PRINT_NAMED_CONSTANT(KEY_REFERENCE);
390   PRINT_NAMED_CONSTANT(KEY_REFRESH);
391   PRINT_NAMED_CONSTANT(KEY_REPLACE);
392   PRINT_NAMED_CONSTANT(KEY_RESTART);
393   PRINT_NAMED_CONSTANT(KEY_RESUME);
394   PRINT_NAMED_CONSTANT(KEY_SAVE);
395   PRINT_NAMED_CONSTANT(KEY_SBEG);
396   PRINT_NAMED_CONSTANT(KEY_SCANCEL);
397   PRINT_NAMED_CONSTANT(KEY_SCOMMAND);
398   PRINT_NAMED_CONSTANT(KEY_SCOPY);
399   PRINT_NAMED_CONSTANT(KEY_SCREATE);
400   PRINT_NAMED_CONSTANT(KEY_SDC);
401   PRINT_NAMED_CONSTANT(KEY_SDL);
402   PRINT_NAMED_CONSTANT(KEY_SELECT);
403   PRINT_NAMED_CONSTANT(KEY_SEND);
404   PRINT_NAMED_CONSTANT(KEY_SEOL);
405   PRINT_NAMED_CONSTANT(KEY_SEXIT);
406   PRINT_NAMED_CONSTANT(KEY_SFIND);
407   PRINT_NAMED_CONSTANT(KEY_SHELP);
408   PRINT_NAMED_CONSTANT(KEY_SHOME);
409   PRINT_NAMED_CONSTANT(KEY_SIC);
410   PRINT_NAMED_CONSTANT(KEY_SLEFT);
411   PRINT_NAMED_CONSTANT(KEY_SMESSAGE);
412   PRINT_NAMED_CONSTANT(KEY_SMOVE);
413   PRINT_NAMED_CONSTANT(KEY_SNEXT);
414   PRINT_NAMED_CONSTANT(KEY_SOPTIONS);
415   PRINT_NAMED_CONSTANT(KEY_SPREVIOUS);
416   PRINT_NAMED_CONSTANT(KEY_SPRINT);
417   PRINT_NAMED_CONSTANT(KEY_SREDO);
418   PRINT_NAMED_CONSTANT(KEY_SREPLACE);
419   PRINT_NAMED_CONSTANT(KEY_SRIGHT);
420   PRINT_NAMED_CONSTANT(KEY_SRSUME);
421   PRINT_NAMED_CONSTANT(KEY_SSAVE);
422   PRINT_NAMED_CONSTANT(KEY_SSUSPEND);
423   PRINT_NAMED_CONSTANT(KEY_SUNDO);
424   PRINT_NAMED_CONSTANT(KEY_SUSPEND);
425   PRINT_NAMED_CONSTANT(KEY_UNDO);
426   PRINT_NAMED_CONSTANT(KEY_MOUSE);
427   PRINT_NAMED_CONSTANT(KEY_RESIZE);
428
429   print_comment(fp, "alternate character codes (ACS) from addch(3NCURSES)");
430 #define PRINT_ACS(name) print_size_of (fp, #name, (size_t)(&name - &acs_map[0]))
431   PRINT_ACS(ACS_ULCORNER);
432   PRINT_ACS(ACS_LLCORNER);
433   PRINT_ACS(ACS_URCORNER);
434   PRINT_ACS(ACS_LRCORNER);
435   PRINT_ACS(ACS_LTEE);
436   PRINT_ACS(ACS_RTEE);
437   PRINT_ACS(ACS_BTEE);
438   PRINT_ACS(ACS_TTEE);
439   PRINT_ACS(ACS_HLINE);
440   PRINT_ACS(ACS_VLINE);
441   PRINT_ACS(ACS_PLUS);
442   PRINT_ACS(ACS_S1);
443   PRINT_ACS(ACS_S9);
444   PRINT_ACS(ACS_DIAMOND);
445   PRINT_ACS(ACS_CKBOARD);
446   PRINT_ACS(ACS_DEGREE);
447   PRINT_ACS(ACS_PLMINUS);
448   PRINT_ACS(ACS_BULLET);
449   PRINT_ACS(ACS_LARROW);
450   PRINT_ACS(ACS_RARROW);
451   PRINT_ACS(ACS_DARROW);
452   PRINT_ACS(ACS_UARROW);
453   PRINT_ACS(ACS_BOARD);
454   PRINT_ACS(ACS_LANTERN);
455   PRINT_ACS(ACS_BLOCK);
456   PRINT_ACS(ACS_S3);
457   PRINT_ACS(ACS_S7);
458   PRINT_ACS(ACS_LEQUAL);
459   PRINT_ACS(ACS_GEQUAL);
460   PRINT_ACS(ACS_PI);
461   PRINT_ACS(ACS_NEQUAL);
462   PRINT_ACS(ACS_STERLING);
463
464   print_comment(fp, "Menu_Options from opts(3MENU)");
465   PRINT_NAMED_BITMASK(Menu_Options, O_ONEVALUE);
466   PRINT_NAMED_BITMASK(Menu_Options, O_SHOWDESC);
467   PRINT_NAMED_BITMASK(Menu_Options, O_ROWMAJOR);
468   PRINT_NAMED_BITMASK(Menu_Options, O_IGNORECASE);
469   PRINT_NAMED_BITMASK(Menu_Options, O_SHOWMATCH);
470   PRINT_NAMED_BITMASK(Menu_Options, O_NONCYCLIC);
471   print_size_of(fp, "Menu_Options_Size", 8 * sizeof(Menu_Options));
472
473   print_comment(fp, "Item_Options from menu_opts(3MENU)");
474   PRINT_NAMED_BITMASK(Item_Options, O_SELECTABLE);
475   print_size_of(fp, "Item_Options_Size", 8 * sizeof(Item_Options));
476
477   print_comment(fp, "Field_Options from field_opts(3FORM)");
478   PRINT_NAMED_BITMASK(Field_Options, O_VISIBLE);
479   PRINT_NAMED_BITMASK(Field_Options, O_ACTIVE);
480   PRINT_NAMED_BITMASK(Field_Options, O_PUBLIC);
481   PRINT_NAMED_BITMASK(Field_Options, O_EDIT);
482   PRINT_NAMED_BITMASK(Field_Options, O_WRAP);
483   PRINT_NAMED_BITMASK(Field_Options, O_BLANK);
484   PRINT_NAMED_BITMASK(Field_Options, O_AUTOSKIP);
485   PRINT_NAMED_BITMASK(Field_Options, O_NULLOK);
486   PRINT_NAMED_BITMASK(Field_Options, O_PASSOK);
487   PRINT_NAMED_BITMASK(Field_Options, O_STATIC);
488   print_size_of(fp, "Field_Options_Size", 8 * sizeof(Field_Options));
489
490   print_comment(fp, "Field_Options from opts(3FORM)");
491   PRINT_NAMED_BITMASK(Field_Options, O_NL_OVERLOAD);
492   PRINT_NAMED_BITMASK(Field_Options, O_BS_OVERLOAD);
493   /*  Field_Options_Size is defined below */
494
495   print_comment(fp, "MEVENT structure from mouse(3NCURSES)");
496   STRUCT_OFFSET(MEVENT, id);
497   STRUCT_OFFSET(MEVENT, x);
498   STRUCT_OFFSET(MEVENT, y);
499   STRUCT_OFFSET(MEVENT, z);
500   STRUCT_OFFSET(MEVENT, bstate);
501   print_size_of(fp, "MEVENT_Size", 8 * sizeof(MEVENT));
502
503   print_comment(fp, "mouse events from mouse(3NCURSES)");
504   {
505     mmask_t all_events;
506
507 #define PRINT_MOUSE_EVENT(event)                \
508     print_constant (fp, #event, event);         \
509     all_events |= event
510
511     all_events = 0;
512     PRINT_MOUSE_EVENT(BUTTON1_RELEASED);
513     PRINT_MOUSE_EVENT(BUTTON1_PRESSED);
514     PRINT_MOUSE_EVENT(BUTTON1_CLICKED);
515     PRINT_MOUSE_EVENT(BUTTON1_DOUBLE_CLICKED);
516     PRINT_MOUSE_EVENT(BUTTON1_TRIPLE_CLICKED);
517 #ifdef BUTTON1_RESERVED_EVENT
518     PRINT_MOUSE_EVENT(BUTTON1_RESERVED_EVENT);
519 #endif
520     print_constant(fp, "all_events_button_1", (UINT) all_events);
521
522     all_events = 0;
523     PRINT_MOUSE_EVENT(BUTTON2_RELEASED);
524     PRINT_MOUSE_EVENT(BUTTON2_PRESSED);
525     PRINT_MOUSE_EVENT(BUTTON2_CLICKED);
526     PRINT_MOUSE_EVENT(BUTTON2_DOUBLE_CLICKED);
527     PRINT_MOUSE_EVENT(BUTTON2_TRIPLE_CLICKED);
528 #ifdef BUTTON2_RESERVED_EVENT
529     PRINT_MOUSE_EVENT(BUTTON2_RESERVED_EVENT);
530 #endif
531     print_constant(fp, "all_events_button_2", (UINT) all_events);
532
533     all_events = 0;
534     PRINT_MOUSE_EVENT(BUTTON3_RELEASED);
535     PRINT_MOUSE_EVENT(BUTTON3_PRESSED);
536     PRINT_MOUSE_EVENT(BUTTON3_CLICKED);
537     PRINT_MOUSE_EVENT(BUTTON3_DOUBLE_CLICKED);
538     PRINT_MOUSE_EVENT(BUTTON3_TRIPLE_CLICKED);
539 #ifdef BUTTON3_RESERVED_EVENT
540     PRINT_MOUSE_EVENT(BUTTON3_RESERVED_EVENT);
541 #endif
542     print_constant(fp, "all_events_button_3", (UINT) all_events);
543
544     all_events = 0;
545     PRINT_MOUSE_EVENT(BUTTON4_RELEASED);
546     PRINT_MOUSE_EVENT(BUTTON4_PRESSED);
547     PRINT_MOUSE_EVENT(BUTTON4_CLICKED);
548     PRINT_MOUSE_EVENT(BUTTON4_DOUBLE_CLICKED);
549     PRINT_MOUSE_EVENT(BUTTON4_TRIPLE_CLICKED);
550 #ifdef BUTTON4_RESERVED_EVENT
551     PRINT_MOUSE_EVENT(BUTTON4_RESERVED_EVENT);
552 #endif
553     print_constant(fp, "all_events_button_4", (UINT) all_events);
554   }
555   PRINT_NAMED_CONSTANT(BUTTON_CTRL);
556   PRINT_NAMED_CONSTANT(BUTTON_SHIFT);
557   PRINT_NAMED_CONSTANT(BUTTON_ALT);
558   PRINT_NAMED_CONSTANT(REPORT_MOUSE_POSITION);
559   PRINT_NAMED_CONSTANT(ALL_MOUSE_EVENTS);
560
561   print_comment(fp, "trace selection from trace(3NCURSES)");
562   PRINT_NAMED_BITMASK(UINT, TRACE_TIMES);
563   PRINT_NAMED_BITMASK(UINT, TRACE_TPUTS);
564   PRINT_NAMED_BITMASK(UINT, TRACE_UPDATE);
565   PRINT_NAMED_BITMASK(UINT, TRACE_MOVE);
566   PRINT_NAMED_BITMASK(UINT, TRACE_CHARPUT);
567   PRINT_NAMED_BITMASK(UINT, TRACE_CALLS);
568   PRINT_NAMED_BITMASK(UINT, TRACE_VIRTPUT);
569   PRINT_NAMED_BITMASK(UINT, TRACE_IEVENT);
570   PRINT_NAMED_BITMASK(UINT, TRACE_BITS);
571   PRINT_NAMED_BITMASK(UINT, TRACE_ICALLS);
572   PRINT_NAMED_BITMASK(UINT, TRACE_CCALLS);
573   PRINT_NAMED_BITMASK(UINT, TRACE_DATABASE);
574   PRINT_NAMED_BITMASK(UINT, TRACE_ATTRS);
575   print_size_of(fp, "Trace_Size", 8 * sizeof(UINT));
576
577   fprintf(fp, "end Terminal_Interface.Curses_Constants;\n");
578   exit(EXIT_SUCCESS);
579 }