00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #include <stdlib.h>
00045 #include <stddef.h>
00046 #include <string.h>
00047 #include <assert.h>
00048 #include <ctype.h>
00049
00050 #include <menu.h>
00051 #include <form.h>
00052
00053 #define RES_NAME "Reserved"
00054
00055 static const char *model = "";
00056 static int little_endian = 0;
00057
00058 typedef struct
00059 {
00060 const char *name;
00061 unsigned long attr;
00062 }
00063 name_attribute_pair;
00064
00065 static int
00066 find_pos(char *s, unsigned len, int *low, int *high)
00067 {
00068 unsigned int i, j;
00069 int l = 0;
00070
00071 *high = -1;
00072 *low = 8 * len;
00073
00074 for (i = 0; i < len; i++, s++)
00075 {
00076 if (*s)
00077 {
00078 for (j = 0; j < 8 * sizeof(char); j++)
00079
00080 {
00081 if (((little_endian && ((*s) & 0x01)) ||
00082 (!little_endian && ((*s) & 0x80))))
00083 {
00084 if (l > *high)
00085 *high = l;
00086 if (l < *low)
00087 *low = l;
00088 }
00089 l++;
00090 if (little_endian)
00091 *s >>= 1;
00092 else
00093 *s <<= 1;
00094 }
00095 }
00096 else
00097 l += 8;
00098 }
00099 return (*high >= 0 && (*low <= *high)) ? *low : -1;
00100 }
00101
00102
00103
00104
00105
00106
00107
00108 static void
00109 gen_reps
00110 (const name_attribute_pair * nap,
00111 const char *name,
00112 int len,
00113 int bias)
00114 {
00115 int i, n, l, cnt = 0, low, high;
00116 int width = strlen(RES_NAME) + 3;
00117 unsigned long a;
00118 unsigned long mask = 0;
00119
00120 assert(nap != NULL);
00121
00122 for (i = 0; nap[i].name != (char *)0; i++)
00123 {
00124 cnt++;
00125 l = strlen(nap[i].name);
00126 if (l > width)
00127 width = l;
00128 }
00129 assert(width > 0);
00130
00131 printf(" type %s is\n", name);
00132 printf(" record\n");
00133 for (i = 0; nap[i].name != (char *)0; i++)
00134 {
00135 printf(" %-*s : Boolean;\n", width, nap[i].name);
00136 }
00137 printf(" end record;\n");
00138 printf(" pragma Convention (C, %s);\n\n", name);
00139
00140 printf(" for %s use\n", name);
00141 printf(" record\n");
00142
00143 for (i = 0; nap[i].name != (char *)0; i++)
00144 {
00145 a = nap[i].attr;
00146 mask |= a;
00147 l = find_pos((char *)&a, sizeof(a), &low, &high);
00148 if (l >= 0)
00149 printf(" %-*s at 0 range %2d .. %2d;\n", width, nap[i].name,
00150 low - bias, high - bias);
00151 }
00152 i = 1;
00153 n = cnt;
00154 printf(" end record;\n");
00155 printf(" for %s'Size use %d;\n", name, 8 * len);
00156 printf(" -- Please note: this rep. clause is generated and may be\n");
00157 printf(" -- different on your system.");
00158 }
00159
00160 static void
00161 chtype_rep(const char *name, attr_t mask)
00162 {
00163 attr_t x = -1;
00164 attr_t t = x & mask;
00165 int low, high;
00166 int l = find_pos((char *)&t, sizeof(t), &low, &high);
00167
00168 if (l >= 0)
00169 printf(" %-5s at 0 range %2d .. %2d;\n", name, low, high);
00170 }
00171
00172 static void
00173 gen_chtype_rep(const char *name)
00174 {
00175 printf(" for %s use\n record\n", name);
00176 chtype_rep("Ch", A_CHARTEXT);
00177 chtype_rep("Color", A_COLOR);
00178 chtype_rep("Attr", (A_ATTRIBUTES & ~A_COLOR));
00179 printf(" end record;\n for %s'Size use %ld;\n",
00180 name, (long)(8 * sizeof(chtype)));
00181
00182 printf(" -- Please note: this rep. clause is generated and may be\n");
00183 printf(" -- different on your system.\n");
00184 }
00185
00186 static void
00187 mrep_rep(const char *name, void *rec)
00188 {
00189 int low, high;
00190 int l = find_pos((char *)rec, sizeof(MEVENT), &low, &high);
00191
00192 if (l >= 0)
00193 printf(" %-7s at 0 range %3d .. %3d;\n", name, low, high);
00194 }
00195
00196 static void
00197 gen_mrep_rep(const char *name)
00198 {
00199 MEVENT x;
00200
00201 printf(" for %s use\n record\n", name);
00202
00203 memset(&x, 0, sizeof(x));
00204 x.id = -1;
00205 mrep_rep("Id", &x);
00206
00207 memset(&x, 0, sizeof(x));
00208 x.x = -1;
00209 mrep_rep("X", &x);
00210
00211 memset(&x, 0, sizeof(x));
00212 x.y = -1;
00213 mrep_rep("Y", &x);
00214
00215 memset(&x, 0, sizeof(x));
00216 x.z = -1;
00217 mrep_rep("Z", &x);
00218
00219 memset(&x, 0, sizeof(x));
00220 x.bstate = -1;
00221 mrep_rep("Bstate", &x);
00222
00223 printf(" end record;\n");
00224 printf(" -- Please note: this rep. clause is generated and may be\n");
00225 printf(" -- different on your system.\n");
00226 }
00227
00228 static void
00229 gen_attr_set(const char *name)
00230 {
00231
00232
00233
00234 static const name_attribute_pair nap[] =
00235 {
00236 #if A_STANDOUT
00237 {"Stand_Out", A_STANDOUT},
00238 #endif
00239 #if A_UNDERLINE
00240 {"Under_Line", A_UNDERLINE},
00241 #endif
00242 #if A_REVERSE
00243 {"Reverse_Video", A_REVERSE},
00244 #endif
00245 #if A_BLINK
00246 {"Blink", A_BLINK},
00247 #endif
00248 #if A_DIM
00249 {"Dim_Character", A_DIM},
00250 #endif
00251 #if A_BOLD
00252 {"Bold_Character", A_BOLD},
00253 #endif
00254 #if A_ALTCHARSET
00255 {"Alternate_Character_Set", A_ALTCHARSET},
00256 #endif
00257 #if A_INVIS
00258 {"Invisible_Character", A_INVIS},
00259 #endif
00260 #if A_PROTECT
00261 {"Protected_Character", A_PROTECT},
00262 #endif
00263 #if A_HORIZONTAL
00264 {"Horizontal", A_HORIZONTAL},
00265 #endif
00266 #if A_LEFT
00267 {"Left", A_LEFT},
00268 #endif
00269 #if A_LOW
00270 {"Low", A_LOW},
00271 #endif
00272 #if A_RIGHT
00273 {"Right", A_RIGHT},
00274 #endif
00275 #if A_TOP
00276 {"Top", A_TOP},
00277 #endif
00278 #if A_VERTICAL
00279 {"Vertical", A_VERTICAL},
00280 #endif
00281 {(char *)0, 0}
00282 };
00283 chtype attr = A_ATTRIBUTES & ~A_COLOR;
00284 int start = -1;
00285 int len = 0;
00286 int i, set;
00287 for (i = 0; i < (int)(8 * sizeof(chtype)); i++)
00288
00289 {
00290 set = attr & 1;
00291 if (set)
00292 {
00293 if (start < 0)
00294 start = i;
00295 if (start >= 0)
00296 {
00297 len++;
00298 }
00299 }
00300 attr = attr >> 1;
00301 }
00302 gen_reps(nap, name, (len + 7) / 8, little_endian ? start : 0);
00303 }
00304
00305 static void
00306 gen_trace(const char *name)
00307 {
00308 static const name_attribute_pair nap[] =
00309 {
00310 {"Times", TRACE_TIMES},
00311 {"Tputs", TRACE_TPUTS},
00312 {"Update", TRACE_UPDATE},
00313 {"Cursor_Move", TRACE_MOVE},
00314 {"Character_Output", TRACE_CHARPUT},
00315 {"Calls", TRACE_CALLS},
00316 {"Virtual_Puts", TRACE_VIRTPUT},
00317 {"Input_Events", TRACE_IEVENT},
00318 {"TTY_State", TRACE_BITS},
00319 {"Internal_Calls", TRACE_ICALLS},
00320 {"Character_Calls", TRACE_CCALLS},
00321 {"Termcap_TermInfo", TRACE_DATABASE},
00322 {(char *)0, 0}
00323 };
00324 gen_reps(nap, name, sizeof(int), 0);
00325 }
00326
00327 static void
00328 gen_menu_opt_rep(const char *name)
00329 {
00330 static const name_attribute_pair nap[] =
00331 {
00332 #ifdef O_ONEVALUE
00333 {"One_Valued", O_ONEVALUE},
00334 #endif
00335 #ifdef O_SHOWDESC
00336 {"Show_Descriptions", O_SHOWDESC},
00337 #endif
00338 #ifdef O_ROWMAJOR
00339 {"Row_Major_Order", O_ROWMAJOR},
00340 #endif
00341 #ifdef O_IGNORECASE
00342 {"Ignore_Case", O_IGNORECASE},
00343 #endif
00344 #ifdef O_SHOWMATCH
00345 {"Show_Matches", O_SHOWMATCH},
00346 #endif
00347 #ifdef O_NONCYCLIC
00348 {"Non_Cyclic", O_NONCYCLIC},
00349 #endif
00350 {(char *)0, 0}
00351 };
00352 gen_reps(nap, name, sizeof(int), 0);
00353 }
00354
00355 static void
00356 gen_item_opt_rep(const char *name)
00357 {
00358 static const name_attribute_pair nap[] =
00359 {
00360 #ifdef O_SELECTABLE
00361 {"Selectable", O_SELECTABLE},
00362 #endif
00363 {(char *)0, 0}
00364 };
00365 gen_reps(nap, name, sizeof(int), 0);
00366 }
00367
00368 static void
00369 gen_form_opt_rep(const char *name)
00370 {
00371 static const name_attribute_pair nap[] =
00372 {
00373 #ifdef O_NL_OVERLOAD
00374 {"NL_Overload", O_NL_OVERLOAD},
00375 #endif
00376 #ifdef O_BS_OVERLOAD
00377 {"BS_Overload", O_BS_OVERLOAD},
00378 #endif
00379 {(char *)0, 0}
00380 };
00381 gen_reps(nap, name, sizeof(int), 0);
00382 }
00383
00384
00385
00386
00387 static void
00388 gen_field_opt_rep(const char *name)
00389 {
00390 static const name_attribute_pair nap[] =
00391 {
00392 #ifdef O_VISIBLE
00393 {"Visible", O_VISIBLE},
00394 #endif
00395 #ifdef O_ACTIVE
00396 {"Active", O_ACTIVE},
00397 #endif
00398 #ifdef O_PUBLIC
00399 {"Public", O_PUBLIC},
00400 #endif
00401 #ifdef O_EDIT
00402 {"Edit", O_EDIT},
00403 #endif
00404 #ifdef O_WRAP
00405 {"Wrap", O_WRAP},
00406 #endif
00407 #ifdef O_BLANK
00408 {"Blank", O_BLANK},
00409 #endif
00410 #ifdef O_AUTOSKIP
00411 {"Auto_Skip", O_AUTOSKIP},
00412 #endif
00413 #ifdef O_NULLOK
00414 {"Null_Ok", O_NULLOK},
00415 #endif
00416 #ifdef O_PASSOK
00417 {"Pass_Ok", O_PASSOK},
00418 #endif
00419 #ifdef O_STATIC
00420 {"Static", O_STATIC},
00421 #endif
00422 {(char *)0, 0}
00423 };
00424 gen_reps(nap, name, sizeof(int), 0);
00425 }
00426
00427
00428
00429
00430 static void
00431 keydef(const char *name, const char *old_name, int value, int mode)
00432 {
00433 if (mode == 0)
00434 printf(" %-30s : constant Special_Key_Code := 8#%3o#;\n", name, value);
00435 else
00436 {
00437
00438
00439 const char *s = old_name;
00440 const char *t = name;
00441
00442 while (*s && *t && (toupper(*s++) == toupper(*t++)));
00443 if (*s || *t)
00444 printf(" %-16s : Special_Key_Code renames %s;\n", old_name, name);
00445 }
00446 }
00447
00448
00449
00450
00451
00452
00453
00454
00455 static void
00456 gen_keydefs(int mode)
00457 {
00458 char buf[16];
00459 char obuf[16];
00460 int i;
00461
00462 #ifdef KEY_CODE_YES
00463 keydef("Key_Code_Yes", "KEY_CODE_YES", KEY_CODE_YES, mode);
00464 #endif
00465 #ifdef KEY_MIN
00466 keydef("Key_Min", "KEY_MIN", KEY_MIN, mode);
00467 #endif
00468 #ifdef KEY_BREAK
00469 keydef("Key_Break", "KEY_BREAK", KEY_BREAK, mode);
00470 #endif
00471 #ifdef KEY_DOWN
00472 keydef("Key_Cursor_Down", "KEY_DOWN", KEY_DOWN, mode);
00473 #endif
00474 #ifdef KEY_UP
00475 keydef("Key_Cursor_Up", "KEY_UP", KEY_UP, mode);
00476 #endif
00477 #ifdef KEY_LEFT
00478 keydef("Key_Cursor_Left", "KEY_LEFT", KEY_LEFT, mode);
00479 #endif
00480 #ifdef KEY_RIGHT
00481 keydef("Key_Cursor_Right", "KEY_RIGHT", KEY_RIGHT, mode);
00482 #endif
00483 #ifdef KEY_HOME
00484 keydef("Key_Home", "KEY_HOME", KEY_HOME, mode);
00485 #endif
00486 #ifdef KEY_BACKSPACE
00487 keydef("Key_Backspace", "KEY_BACKSPACE", KEY_BACKSPACE, mode);
00488 #endif
00489 #ifdef KEY_F0
00490 keydef("Key_F0", "KEY_F0", KEY_F0, mode);
00491 #endif
00492 #ifdef KEY_F
00493 for (i = 1; i <= 24; i++)
00494 {
00495 sprintf(buf, "Key_F%d", i);
00496 sprintf(obuf, "KEY_F%d", i);
00497 keydef(buf, obuf, KEY_F(i), mode);
00498 }
00499 #endif
00500 #ifdef KEY_DL
00501 keydef("Key_Delete_Line", "KEY_DL", KEY_DL, mode);
00502 #endif
00503 #ifdef KEY_IL
00504 keydef("Key_Insert_Line", "KEY_IL", KEY_IL, mode);
00505 #endif
00506 #ifdef KEY_DC
00507 keydef("Key_Delete_Char", "KEY_DC", KEY_DC, mode);
00508 #endif
00509 #ifdef KEY_IC
00510 keydef("Key_Insert_Char", "KEY_IC", KEY_IC, mode);
00511 #endif
00512 #ifdef KEY_EIC
00513 keydef("Key_Exit_Insert_Mode", "KEY_EIC", KEY_EIC, mode);
00514 #endif
00515 #ifdef KEY_CLEAR
00516 keydef("Key_Clear_Screen", "KEY_CLEAR", KEY_CLEAR, mode);
00517 #endif
00518 #ifdef KEY_EOS
00519 keydef("Key_Clear_End_Of_Screen", "KEY_EOS", KEY_EOS, mode);
00520 #endif
00521 #ifdef KEY_EOL
00522 keydef("Key_Clear_End_Of_Line", "KEY_EOL", KEY_EOL, mode);
00523 #endif
00524 #ifdef KEY_SF
00525 keydef("Key_Scroll_1_Forward", "KEY_SF", KEY_SF, mode);
00526 #endif
00527 #ifdef KEY_SR
00528 keydef("Key_Scroll_1_Backward", "KEY_SR", KEY_SR, mode);
00529 #endif
00530 #ifdef KEY_NPAGE
00531 keydef("Key_Next_Page", "KEY_NPAGE", KEY_NPAGE, mode);
00532 #endif
00533 #ifdef KEY_PPAGE
00534 keydef("Key_Previous_Page", "KEY_PPAGE", KEY_PPAGE, mode);
00535 #endif
00536 #ifdef KEY_STAB
00537 keydef("Key_Set_Tab", "KEY_STAB", KEY_STAB, mode);
00538 #endif
00539 #ifdef KEY_CTAB
00540 keydef("Key_Clear_Tab", "KEY_CTAB", KEY_CTAB, mode);
00541 #endif
00542 #ifdef KEY_CATAB
00543 keydef("Key_Clear_All_Tabs", "KEY_CATAB", KEY_CATAB, mode);
00544 #endif
00545 #ifdef KEY_ENTER
00546 keydef("Key_Enter_Or_Send", "KEY_ENTER", KEY_ENTER, mode);
00547 #endif
00548 #ifdef KEY_SRESET
00549 keydef("Key_Soft_Reset", "KEY_SRESET", KEY_SRESET, mode);
00550 #endif
00551 #ifdef KEY_RESET
00552 keydef("Key_Reset", "KEY_RESET", KEY_RESET, mode);
00553 #endif
00554 #ifdef KEY_PRINT
00555 keydef("Key_Print", "KEY_PRINT", KEY_PRINT, mode);
00556 #endif
00557 #ifdef KEY_LL
00558 keydef("Key_Bottom", "KEY_LL", KEY_LL, mode);
00559 #endif
00560 #ifdef KEY_A1
00561 keydef("Key_Upper_Left_Of_Keypad", "KEY_A1", KEY_A1, mode);
00562 #endif
00563 #ifdef KEY_A3
00564 keydef("Key_Upper_Right_Of_Keypad", "KEY_A3", KEY_A3, mode);
00565 #endif
00566 #ifdef KEY_B2
00567 keydef("Key_Center_Of_Keypad", "KEY_B2", KEY_B2, mode);
00568 #endif
00569 #ifdef KEY_C1
00570 keydef("Key_Lower_Left_Of_Keypad", "KEY_C1", KEY_C1, mode);
00571 #endif
00572 #ifdef KEY_C3
00573 keydef("Key_Lower_Right_Of_Keypad", "KEY_C3", KEY_C3, mode);
00574 #endif
00575 #ifdef KEY_BTAB
00576 keydef("Key_Back_Tab", "KEY_BTAB", KEY_BTAB, mode);
00577 #endif
00578 #ifdef KEY_BEG
00579 keydef("Key_Beginning", "KEY_BEG", KEY_BEG, mode);
00580 #endif
00581 #ifdef KEY_CANCEL
00582 keydef("Key_Cancel", "KEY_CANCEL", KEY_CANCEL, mode);
00583 #endif
00584 #ifdef KEY_CLOSE
00585 keydef("Key_Close", "KEY_CLOSE", KEY_CLOSE, mode);
00586 #endif
00587 #ifdef KEY_COMMAND
00588 keydef("Key_Command", "KEY_COMMAND", KEY_COMMAND, mode);
00589 #endif
00590 #ifdef KEY_COPY
00591 keydef("Key_Copy", "KEY_COPY", KEY_COPY, mode);
00592 #endif
00593 #ifdef KEY_CREATE
00594 keydef("Key_Create", "KEY_CREATE", KEY_CREATE, mode);
00595 #endif
00596 #ifdef KEY_END
00597 keydef("Key_End", "KEY_END", KEY_END, mode);
00598 #endif
00599 #ifdef KEY_EXIT
00600 keydef("Key_Exit", "KEY_EXIT", KEY_EXIT, mode);
00601 #endif
00602 #ifdef KEY_FIND
00603 keydef("Key_Find", "KEY_FIND", KEY_FIND, mode);
00604 #endif
00605 #ifdef KEY_HELP
00606 keydef("Key_Help", "KEY_HELP", KEY_HELP, mode);
00607 #endif
00608 #ifdef KEY_MARK
00609 keydef("Key_Mark", "KEY_MARK", KEY_MARK, mode);
00610 #endif
00611 #ifdef KEY_MESSAGE
00612 keydef("Key_Message", "KEY_MESSAGE", KEY_MESSAGE, mode);
00613 #endif
00614 #ifdef KEY_MOVE
00615 keydef("Key_Move", "KEY_MOVE", KEY_MOVE, mode);
00616 #endif
00617 #ifdef KEY_NEXT
00618 keydef("Key_Next", "KEY_NEXT", KEY_NEXT, mode);
00619 #endif
00620 #ifdef KEY_OPEN
00621 keydef("Key_Open", "KEY_OPEN", KEY_OPEN, mode);
00622 #endif
00623 #ifdef KEY_OPTIONS
00624 keydef("Key_Options", "KEY_OPTIONS", KEY_OPTIONS, mode);
00625 #endif
00626 #ifdef KEY_PREVIOUS
00627 keydef("Key_Previous", "KEY_PREVIOUS", KEY_PREVIOUS, mode);
00628 #endif
00629 #ifdef KEY_REDO
00630 keydef("Key_Redo", "KEY_REDO", KEY_REDO, mode);
00631 #endif
00632 #ifdef KEY_REFERENCE
00633 keydef("Key_Reference", "KEY_REFERENCE", KEY_REFERENCE, mode);
00634 #endif
00635 #ifdef KEY_REFRESH
00636 keydef("Key_Refresh", "KEY_REFRESH", KEY_REFRESH, mode);
00637 #endif
00638 #ifdef KEY_REPLACE
00639 keydef("Key_Replace", "KEY_REPLACE", KEY_REPLACE, mode);
00640 #endif
00641 #ifdef KEY_RESTART
00642 keydef("Key_Restart", "KEY_RESTART", KEY_RESTART, mode);
00643 #endif
00644 #ifdef KEY_RESUME
00645 keydef("Key_Resume", "KEY_RESUME", KEY_RESUME, mode);
00646 #endif
00647 #ifdef KEY_SAVE
00648 keydef("Key_Save", "KEY_SAVE", KEY_SAVE, mode);
00649 #endif
00650 #ifdef KEY_SBEG
00651 keydef("Key_Shift_Begin", "KEY_SBEG", KEY_SBEG, mode);
00652 #endif
00653 #ifdef KEY_SCANCEL
00654 keydef("Key_Shift_Cancel", "KEY_SCANCEL", KEY_SCANCEL, mode);
00655 #endif
00656 #ifdef KEY_SCOMMAND
00657 keydef("Key_Shift_Command", "KEY_SCOMMAND", KEY_SCOMMAND, mode);
00658 #endif
00659 #ifdef KEY_SCOPY
00660 keydef("Key_Shift_Copy", "KEY_SCOPY", KEY_SCOPY, mode);
00661 #endif
00662 #ifdef KEY_SCREATE
00663 keydef("Key_Shift_Create", "KEY_SCREATE", KEY_SCREATE, mode);
00664 #endif
00665 #ifdef KEY_SDC
00666 keydef("Key_Shift_Delete_Char", "KEY_SDC", KEY_SDC, mode);
00667 #endif
00668 #ifdef KEY_SDL
00669 keydef("Key_Shift_Delete_Line", "KEY_SDL", KEY_SDL, mode);
00670 #endif
00671 #ifdef KEY_SELECT
00672 keydef("Key_Select", "KEY_SELECT", KEY_SELECT, mode);
00673 #endif
00674 #ifdef KEY_SEND
00675 keydef("Key_Shift_End", "KEY_SEND", KEY_SEND, mode);
00676 #endif
00677 #ifdef KEY_SEOL
00678 keydef("Key_Shift_Clear_End_Of_Line", "KEY_SEOL", KEY_SEOL, mode);
00679 #endif
00680 #ifdef KEY_SEXIT
00681 keydef("Key_Shift_Exit", "KEY_SEXIT", KEY_SEXIT, mode);
00682 #endif
00683 #ifdef KEY_SFIND
00684 keydef("Key_Shift_Find", "KEY_SFIND", KEY_SFIND, mode);
00685 #endif
00686 #ifdef KEY_SHELP
00687 keydef("Key_Shift_Help", "KEY_SHELP", KEY_SHELP, mode);
00688 #endif
00689 #ifdef KEY_SHOME
00690 keydef("Key_Shift_Home", "KEY_SHOME", KEY_SHOME, mode);
00691 #endif
00692 #ifdef KEY_SIC
00693 keydef("Key_Shift_Insert_Char", "KEY_SIC", KEY_SIC, mode);
00694 #endif
00695 #ifdef KEY_SLEFT
00696 keydef("Key_Shift_Cursor_Left", "KEY_SLEFT", KEY_SLEFT, mode);
00697 #endif
00698 #ifdef KEY_SMESSAGE
00699 keydef("Key_Shift_Message", "KEY_SMESSAGE", KEY_SMESSAGE, mode);
00700 #endif
00701 #ifdef KEY_SMOVE
00702 keydef("Key_Shift_Move", "KEY_SMOVE", KEY_SMOVE, mode);
00703 #endif
00704 #ifdef KEY_SNEXT
00705 keydef("Key_Shift_Next_Page", "KEY_SNEXT", KEY_SNEXT, mode);
00706 #endif
00707 #ifdef KEY_SOPTIONS
00708 keydef("Key_Shift_Options", "KEY_SOPTIONS", KEY_SOPTIONS, mode);
00709 #endif
00710 #ifdef KEY_SPREVIOUS
00711 keydef("Key_Shift_Previous_Page", "KEY_SPREVIOUS", KEY_SPREVIOUS, mode);
00712 #endif
00713 #ifdef KEY_SPRINT
00714 keydef("Key_Shift_Print", "KEY_SPRINT", KEY_SPRINT, mode);
00715 #endif
00716 #ifdef KEY_SREDO
00717 keydef("Key_Shift_Redo", "KEY_SREDO", KEY_SREDO, mode);
00718 #endif
00719 #ifdef KEY_SREPLACE
00720 keydef("Key_Shift_Replace", "KEY_SREPLACE", KEY_SREPLACE, mode);
00721 #endif
00722 #ifdef KEY_SRIGHT
00723 keydef("Key_Shift_Cursor_Right", "KEY_SRIGHT", KEY_SRIGHT, mode);
00724 #endif
00725 #ifdef KEY_SRSUME
00726 keydef("Key_Shift_Resume", "KEY_SRSUME", KEY_SRSUME, mode);
00727 #endif
00728 #ifdef KEY_SSAVE
00729 keydef("Key_Shift_Save", "KEY_SSAVE", KEY_SSAVE, mode);
00730 #endif
00731 #ifdef KEY_SSUSPEND
00732 keydef("Key_Shift_Suspend", "KEY_SSUSPEND", KEY_SSUSPEND, mode);
00733 #endif
00734 #ifdef KEY_SUNDO
00735 keydef("Key_Shift_Undo", "KEY_SUNDO", KEY_SUNDO, mode);
00736 #endif
00737 #ifdef KEY_SUSPEND
00738 keydef("Key_Suspend", "KEY_SUSPEND", KEY_SUSPEND, mode);
00739 #endif
00740 #ifdef KEY_UNDO
00741 keydef("Key_Undo", "KEY_UNDO", KEY_UNDO, mode);
00742 #endif
00743 #ifdef KEY_MOUSE
00744 keydef("Key_Mouse", "KEY_MOUSE", KEY_MOUSE, mode);
00745 #endif
00746 #ifdef KEY_RESIZE
00747 keydef("Key_Resize", "KEY_RESIZE", KEY_RESIZE, mode);
00748 #endif
00749 }
00750
00751
00752
00753
00754
00755
00756 static void
00757 acs_def(const char *name, chtype *a)
00758 {
00759 int c = a - &acs_map[0];
00760
00761 printf(" %-24s : constant Character := ", name);
00762 if (isprint(c) && (c != '`'))
00763 printf("'%c';\n", c);
00764 else
00765 printf("Character'Val (%d);\n", c);
00766 }
00767
00768
00769
00770
00771 static void
00772 gen_acs(void)
00773 {
00774 #ifdef ACS_ULCORNER
00775 acs_def("ACS_Upper_Left_Corner", &ACS_ULCORNER);
00776 #endif
00777 #ifdef ACS_LLCORNER
00778 acs_def("ACS_Lower_Left_Corner", &ACS_LLCORNER);
00779 #endif
00780 #ifdef ACS_URCORNER
00781 acs_def("ACS_Upper_Right_Corner", &ACS_URCORNER);
00782 #endif
00783 #ifdef ACS_LRCORNER
00784 acs_def("ACS_Lower_Right_Corner", &ACS_LRCORNER);
00785 #endif
00786 #ifdef ACS_LTEE
00787 acs_def("ACS_Left_Tee", &ACS_LTEE);
00788 #endif
00789 #ifdef ACS_RTEE
00790 acs_def("ACS_Right_Tee", &ACS_RTEE);
00791 #endif
00792 #ifdef ACS_BTEE
00793 acs_def("ACS_Bottom_Tee", &ACS_BTEE);
00794 #endif
00795 #ifdef ACS_TTEE
00796 acs_def("ACS_Top_Tee", &ACS_TTEE);
00797 #endif
00798 #ifdef ACS_HLINE
00799 acs_def("ACS_Horizontal_Line", &ACS_HLINE);
00800 #endif
00801 #ifdef ACS_VLINE
00802 acs_def("ACS_Vertical_Line", &ACS_VLINE);
00803 #endif
00804 #ifdef ACS_PLUS
00805 acs_def("ACS_Plus_Symbol", &ACS_PLUS);
00806 #endif
00807 #ifdef ACS_S1
00808 acs_def("ACS_Scan_Line_1", &ACS_S1);
00809 #endif
00810 #ifdef ACS_S9
00811 acs_def("ACS_Scan_Line_9", &ACS_S9);
00812 #endif
00813 #ifdef ACS_DIAMOND
00814 acs_def("ACS_Diamond", &ACS_DIAMOND);
00815 #endif
00816 #ifdef ACS_CKBOARD
00817 acs_def("ACS_Checker_Board", &ACS_CKBOARD);
00818 #endif
00819 #ifdef ACS_DEGREE
00820 acs_def("ACS_Degree", &ACS_DEGREE);
00821 #endif
00822 #ifdef ACS_PLMINUS
00823 acs_def("ACS_Plus_Minus", &ACS_PLMINUS);
00824 #endif
00825 #ifdef ACS_BULLET
00826 acs_def("ACS_Bullet", &ACS_BULLET);
00827 #endif
00828 #ifdef ACS_LARROW
00829 acs_def("ACS_Left_Arrow", &ACS_LARROW);
00830 #endif
00831 #ifdef ACS_RARROW
00832 acs_def("ACS_Right_Arrow", &ACS_RARROW);
00833 #endif
00834 #ifdef ACS_DARROW
00835 acs_def("ACS_Down_Arrow", &ACS_DARROW);
00836 #endif
00837 #ifdef ACS_UARROW
00838 acs_def("ACS_Up_Arrow", &ACS_UARROW);
00839 #endif
00840 #ifdef ACS_BOARD
00841 acs_def("ACS_Board_Of_Squares", &ACS_BOARD);
00842 #endif
00843 #ifdef ACS_LANTERN
00844 acs_def("ACS_Lantern", &ACS_LANTERN);
00845 #endif
00846 #ifdef ACS_BLOCK
00847 acs_def("ACS_Solid_Block", &ACS_BLOCK);
00848 #endif
00849 #ifdef ACS_S3
00850 acs_def("ACS_Scan_Line_3", &ACS_S3);
00851 #endif
00852 #ifdef ACS_S7
00853 acs_def("ACS_Scan_Line_7", &ACS_S7);
00854 #endif
00855 #ifdef ACS_LEQUAL
00856 acs_def("ACS_Less_Or_Equal", &ACS_LEQUAL);
00857 #endif
00858 #ifdef ACS_GEQUAL
00859 acs_def("ACS_Greater_Or_Equal", &ACS_GEQUAL);
00860 #endif
00861 #ifdef ACS_PI
00862 acs_def("ACS_PI", &ACS_PI);
00863 #endif
00864 #ifdef ACS_NEQUAL
00865 acs_def("ACS_Not_Equal", &ACS_NEQUAL);
00866 #endif
00867 #ifdef ACS_STERLING
00868 acs_def("ACS_Sterling", &ACS_STERLING);
00869 #endif
00870 }
00871
00872 #define GEN_EVENT(name,value) \
00873 printf(" %-25s : constant Event_Mask := 8#%011lo#;\n", \
00874 #name, value)
00875
00876 #define GEN_MEVENT(name) \
00877 printf(" %-25s : constant Event_Mask := 8#%011lo#;\n", \
00878 #name, name)
00879
00880 static
00881 void
00882 gen_mouse_events(void)
00883 {
00884 mmask_t all1 = 0;
00885 mmask_t all2 = 0;
00886 mmask_t all3 = 0;
00887 mmask_t all4 = 0;
00888
00889 #ifdef BUTTON1_RELEASED
00890 GEN_MEVENT(BUTTON1_RELEASED);
00891 all1 |= BUTTON1_RELEASED;
00892 #endif
00893 #ifdef BUTTON1_PRESSED
00894 GEN_MEVENT(BUTTON1_PRESSED);
00895 all1 |= BUTTON1_PRESSED;
00896 #endif
00897 #ifdef BUTTON1_CLICKED
00898 GEN_MEVENT(BUTTON1_CLICKED);
00899 all1 |= BUTTON1_CLICKED;
00900 #endif
00901 #ifdef BUTTON1_DOUBLE_CLICKED
00902 GEN_MEVENT(BUTTON1_DOUBLE_CLICKED);
00903 all1 |= BUTTON1_DOUBLE_CLICKED;
00904 #endif
00905 #ifdef BUTTON1_TRIPLE_CLICKED
00906 GEN_MEVENT(BUTTON1_TRIPLE_CLICKED);
00907 all1 |= BUTTON1_TRIPLE_CLICKED;
00908 #endif
00909 #ifdef BUTTON1_RESERVED_EVENT
00910 GEN_MEVENT(BUTTON1_RESERVED_EVENT);
00911 all1 |= BUTTON1_RESERVED_EVENT;
00912 #endif
00913 #ifdef BUTTON2_RELEASED
00914 GEN_MEVENT(BUTTON2_RELEASED);
00915 all2 |= BUTTON2_RELEASED;
00916 #endif
00917 #ifdef BUTTON2_PRESSED
00918 GEN_MEVENT(BUTTON2_PRESSED);
00919 all2 |= BUTTON2_PRESSED;
00920 #endif
00921 #ifdef BUTTON2_CLICKED
00922 GEN_MEVENT(BUTTON2_CLICKED);
00923 all2 |= BUTTON2_CLICKED;
00924 #endif
00925 #ifdef BUTTON2_DOUBLE_CLICKED
00926 GEN_MEVENT(BUTTON2_DOUBLE_CLICKED);
00927 all2 |= BUTTON2_DOUBLE_CLICKED;
00928 #endif
00929 #ifdef BUTTON2_TRIPLE_CLICKED
00930 GEN_MEVENT(BUTTON2_TRIPLE_CLICKED);
00931 all2 |= BUTTON2_TRIPLE_CLICKED;
00932 #endif
00933 #ifdef BUTTON2_RESERVED_EVENT
00934 GEN_MEVENT(BUTTON2_RESERVED_EVENT);
00935 all2 |= BUTTON2_RESERVED_EVENT;
00936 #endif
00937 #ifdef BUTTON3_RELEASED
00938 GEN_MEVENT(BUTTON3_RELEASED);
00939 all3 |= BUTTON3_RELEASED;
00940 #endif
00941 #ifdef BUTTON3_PRESSED
00942 GEN_MEVENT(BUTTON3_PRESSED);
00943 all3 |= BUTTON3_PRESSED;
00944 #endif
00945 #ifdef BUTTON3_CLICKED
00946 GEN_MEVENT(BUTTON3_CLICKED);
00947 all3 |= BUTTON3_CLICKED;
00948 #endif
00949 #ifdef BUTTON3_DOUBLE_CLICKED
00950 GEN_MEVENT(BUTTON3_DOUBLE_CLICKED);
00951 all3 |= BUTTON3_DOUBLE_CLICKED;
00952 #endif
00953 #ifdef BUTTON3_TRIPLE_CLICKED
00954 GEN_MEVENT(BUTTON3_TRIPLE_CLICKED);
00955 all3 |= BUTTON3_TRIPLE_CLICKED;
00956 #endif
00957 #ifdef BUTTON3_RESERVED_EVENT
00958 GEN_MEVENT(BUTTON3_RESERVED_EVENT);
00959 all3 |= BUTTON3_RESERVED_EVENT;
00960 #endif
00961 #ifdef BUTTON4_RELEASED
00962 GEN_MEVENT(BUTTON4_RELEASED);
00963 all4 |= BUTTON4_RELEASED;
00964 #endif
00965 #ifdef BUTTON4_PRESSED
00966 GEN_MEVENT(BUTTON4_PRESSED);
00967 all4 |= BUTTON4_PRESSED;
00968 #endif
00969 #ifdef BUTTON4_CLICKED
00970 GEN_MEVENT(BUTTON4_CLICKED);
00971 all4 |= BUTTON4_CLICKED;
00972 #endif
00973 #ifdef BUTTON4_DOUBLE_CLICKED
00974 GEN_MEVENT(BUTTON4_DOUBLE_CLICKED);
00975 all4 |= BUTTON4_DOUBLE_CLICKED;
00976 #endif
00977 #ifdef BUTTON4_TRIPLE_CLICKED
00978 GEN_MEVENT(BUTTON4_TRIPLE_CLICKED);
00979 all4 |= BUTTON4_TRIPLE_CLICKED;
00980 #endif
00981 #ifdef BUTTON4_RESERVED_EVENT
00982 GEN_MEVENT(BUTTON4_RESERVED_EVENT);
00983 all4 |= BUTTON4_RESERVED_EVENT;
00984 #endif
00985 #ifdef BUTTON_CTRL
00986 GEN_MEVENT(BUTTON_CTRL);
00987 #endif
00988 #ifdef BUTTON_SHIFT
00989 GEN_MEVENT(BUTTON_SHIFT);
00990 #endif
00991 #ifdef BUTTON_ALT
00992 GEN_MEVENT(BUTTON_ALT);
00993 #endif
00994 #ifdef REPORT_MOUSE_POSITION
00995 GEN_MEVENT(REPORT_MOUSE_POSITION);
00996 #endif
00997 #ifdef ALL_MOUSE_EVENTS
00998 GEN_MEVENT(ALL_MOUSE_EVENTS);
00999 #endif
01000
01001 GEN_EVENT(BUTTON1_EVENTS, all1);
01002 GEN_EVENT(BUTTON2_EVENTS, all2);
01003 GEN_EVENT(BUTTON3_EVENTS, all3);
01004 GEN_EVENT(BUTTON4_EVENTS, all4);
01005 }
01006
01007
01008
01009
01010
01011
01012 static void
01013 prologue(const char *name)
01014 {
01015 printf("-- %s binding.\n", name);
01016 printf("-- This module is generated. Please don't change it manually!\n");
01017 printf("-- Run the generator instead.\n-- |");
01018
01019 printf("define(`M4_BIT_ORDER',`%s_Order_First')",
01020 little_endian ? "Low" : "High");
01021 }
01022
01023
01024
01025
01026
01027 static void
01028 basedefs(void)
01029 {
01030 prologue("curses");
01031 #ifndef KEY_MAX
01032 # define KEY_MAX 0777
01033 #endif
01034 printf("define(`M4_KEY_MAX',`8#%o#')", KEY_MAX);
01035 #ifndef KEY_MIN
01036 # define KEY_MIN 0401
01037 #endif
01038 if (KEY_MIN == 256)
01039 {
01040 fprintf(stderr, "Unexpected value for KEY_MIN: %d\n", KEY_MIN);
01041 exit(1);
01042 }
01043 printf("define(`M4_SPECIAL_FIRST',`8#%o#')", KEY_MIN - 1);
01044 }
01045
01046
01047
01048
01049 static void
01050 menu_basedefs(void)
01051 {
01052 prologue("menu");
01053 }
01054
01055
01056
01057
01058 static void
01059 form_basedefs(void)
01060 {
01061 prologue("form");
01062 }
01063
01064
01065
01066
01067 static void
01068 mouse_basedefs(void)
01069 {
01070 prologue("mouse");
01071 }
01072
01073
01074
01075
01076 static void
01077 color_def(const char *name, int value)
01078 {
01079 printf(" %-16s : constant Color_Number := %d;\n", name, value);
01080 }
01081
01082 #define HAVE_USE_DEFAULT_COLORS 1
01083
01084
01085
01086
01087 static void
01088 gen_color(void)
01089 {
01090 #ifdef HAVE_USE_DEFAULT_COLORS
01091 color_def("Default_Color", -1);
01092 #endif
01093 #ifdef COLOR_BLACK
01094 color_def("Black", COLOR_BLACK);
01095 #endif
01096 #ifdef COLOR_RED
01097 color_def("Red", COLOR_RED);
01098 #endif
01099 #ifdef COLOR_GREEN
01100 color_def("Green", COLOR_GREEN);
01101 #endif
01102 #ifdef COLOR_YELLOW
01103 color_def("Yellow", COLOR_YELLOW);
01104 #endif
01105 #ifdef COLOR_BLUE
01106 color_def("Blue", COLOR_BLUE);
01107 #endif
01108 #ifdef COLOR_MAGENTA
01109 color_def("Magenta", COLOR_MAGENTA);
01110 #endif
01111 #ifdef COLOR_CYAN
01112 color_def("Cyan", COLOR_CYAN);
01113 #endif
01114 #ifdef COLOR_WHITE
01115 color_def("White", COLOR_WHITE);
01116 #endif
01117 }
01118
01119
01120
01121
01122 static void
01123 gen_linkopts(void)
01124 {
01125 printf(" pragma Linker_Options (\"-lncurses%s\");\n", model);
01126 }
01127
01128
01129
01130
01131 static void
01132 gen_menu_linkopts(void)
01133 {
01134 printf(" pragma Linker_Options (\"-lmenu%s\");\n", model);
01135 }
01136
01137
01138
01139
01140 static void
01141 gen_form_linkopts(void)
01142 {
01143 printf(" pragma Linker_Options (\"-lform%s\");\n", model);
01144 }
01145
01146
01147
01148
01149 static void
01150 gen_panel_linkopts(void)
01151 {
01152 printf(" pragma Linker_Options (\"-lpanel%s\");\n", model);
01153 }
01154
01155 static void
01156 gen_version_info(void)
01157 {
01158 static const char *v1 =
01159 " NC_Major_Version : constant := %d; -- Major version of the library\n";
01160 static const char *v2 =
01161 " NC_Minor_Version : constant := %d; -- Minor version of the library\n";
01162 static const char *v3 =
01163 " NC_Version : constant String := %c%d.%d%c; -- Version of library\n";
01164
01165 printf(v1, NCURSES_VERSION_MAJOR);
01166 printf(v2, NCURSES_VERSION_MINOR);
01167 printf(v3, '"', NCURSES_VERSION_MAJOR, NCURSES_VERSION_MINOR, '"');
01168 }
01169
01170 static int
01171 eti_gen(char *buf, int code, const char *name, int *etimin, int *etimax)
01172 {
01173 sprintf(buf, " E_%-16s : constant Eti_Error := %d;\n", name, code);
01174 if (code < *etimin)