+static void gen_version_info (void)
+{
+ static const char* v1 =
+ " NC_Major_Version : constant := %d; -- Major version of the library\n";
+ static const char* v2 =
+ " NC_Minor_Version : constant := %d; -- Minor version of the library\n";
+ static const char* v3 =
+ " NC_Version : constant String := %c%d.%d%c; -- Version of library\n";
+
+ printf(v1, NCURSES_VERSION_MAJOR);
+ printf(v2, NCURSES_VERSION_MINOR);
+ printf(v3, '"',NCURSES_VERSION_MAJOR,NCURSES_VERSION_MINOR,'"');
+}
+
+static int
+eti_gen(char*buf, int code, const char* name, int* etimin, int* etimax)
+{
+ sprintf(buf," E_%-16s : constant Eti_Error := %d;\n",name,code);
+ if (code < *etimin)
+ *etimin = code;
+ if (code > *etimax)
+ *etimax = code;
+ return strlen(buf);
+}
+
+#define GEN_OFFSET(member,itype) \
+ if (sizeof(((WINDOW*)0)->member)==sizeof(itype)) { \
+ o = offsetof(WINDOW, member); \
+ if ((o%sizeof(itype) == 0)) { \
+ printf(" Offset%-*s : constant Natural := %2ld; -- %s\n", \
+ 12, #member, o/sizeof(itype),#itype); \
+ } \
+ }
+
+static void
+gen_offsets(void)
+{
+ long o;
+ const char* s_bool = "";
+
+ GEN_OFFSET(_maxy,short);
+ GEN_OFFSET(_maxx,short);
+ GEN_OFFSET(_begy,short);
+ GEN_OFFSET(_begx,short);
+ GEN_OFFSET(_cury,short);
+ GEN_OFFSET(_curx,short);
+ GEN_OFFSET(_yoffset,short);
+ GEN_OFFSET(_pary,int);
+ GEN_OFFSET(_parx,int);
+ if (sizeof(bool) == sizeof(char)) {
+ GEN_OFFSET(_notimeout,char);
+ GEN_OFFSET(_clear,char);
+ GEN_OFFSET(_leaveok,char);
+ GEN_OFFSET(_scroll,char);
+ GEN_OFFSET(_idlok,char);
+ GEN_OFFSET(_idcok,char);
+ GEN_OFFSET(_immed,char);
+ GEN_OFFSET(_sync,char);
+ GEN_OFFSET(_use_keypad,char);
+ s_bool = "char";
+ } else if (sizeof(bool) == sizeof(short)) {
+ GEN_OFFSET(_notimeout,short);
+ GEN_OFFSET(_clear,short);
+ GEN_OFFSET(_leaveok,short);
+ GEN_OFFSET(_scroll,short);
+ GEN_OFFSET(_idlok,short);
+ GEN_OFFSET(_idcok,short);
+ GEN_OFFSET(_immed,short);
+ GEN_OFFSET(_sync,short);
+ GEN_OFFSET(_use_keypad,short);
+ s_bool = "short";
+ } else if (sizeof(bool) == sizeof(int)) {
+ GEN_OFFSET(_notimeout,int);
+ GEN_OFFSET(_clear,int);
+ GEN_OFFSET(_leaveok,int);
+ GEN_OFFSET(_scroll,int);
+ GEN_OFFSET(_idlok,int);
+ GEN_OFFSET(_idcok,int);
+ GEN_OFFSET(_immed,int);
+ GEN_OFFSET(_sync,int);
+ GEN_OFFSET(_use_keypad,int);
+ s_bool = "int";
+ }
+ printf(" Sizeof%-*s : constant Natural := %2ld; -- %s\n",
+ 12, "_bool", (long) sizeof(bool),"bool");
+ /* In ncurses _maxy and _maxx needs an offset for the "public"
+ * value
+ */
+ printf(" Offset%-*s : constant Natural := %2d; -- %s\n",
+ 12, "_XY",1,"int");
+ printf("\n");
+ printf(" type Curses_Bool is mod 2 ** Interfaces.C.%s'Size;\n",s_bool);
+}