+ /* fill in the header */
+#if NCURSES_EXT_NUMBERS
+ if (need_ints) {
+ convert_numbers = convert_32bit;
+ LITTLE_ENDIAN(buf, MAGIC2);
+ } else {
+ convert_numbers = convert_16bit;
+ LITTLE_ENDIAN(buf, MAGIC);
+ }
+#else
+ LITTLE_ENDIAN(buf, MAGIC);
+#endif
+ LITTLE_ENDIAN(buf + 2, min(namelen, MAX_NAME_SIZE + 1));
+ LITTLE_ENDIAN(buf + 4, boolmax);
+ LITTLE_ENDIAN(buf + 6, nummax);
+ LITTLE_ENDIAN(buf + 8, strmax);
+ LITTLE_ENDIAN(buf + 10, nextfree);
+
+ /* write out the header */
+ TRACE_OUT(("Header of %s @%d", namelist, *offset));
+ if (Write(buf, 12, 1) != 1
+ || Write(namelist, sizeof(char), namelen) != namelen)
+ return (ERR);
+
+ for (i = 0; i < boolmax; i++)
+ if (tp->Booleans[i] == TRUE)
+ buf[i] = TRUE;
+ else
+ buf[i] = FALSE;
+ if (Write(buf, sizeof(char), boolmax) != boolmax)
+ return (ERR);
+
+ if (even_boundary(namelen + boolmax))
+ return (ERR);
+
+ TRACE_OUT(("Numerics begin at %04x", *offset));
+
+ /* the numerics */
+ numlen = convert_numbers(buf, tp->Numbers, nummax);
+ if (Write(buf, numlen, nummax) != nummax)
+ return (ERR);
+
+ TRACE_OUT(("String offsets begin at %04x", *offset));
+
+ /* the string offsets */
+ convert_shorts(buf, offsets, strmax);
+ if (Write(buf, SIZEOF_SHORT, strmax) != strmax)
+ return (ERR);
+
+ TRACE_OUT(("String table begins at %04x", *offset));
+
+ /* the strings */
+ for (i = 0; i < strmax; i++)
+ if (VALID_STRING(tp->Strings[i]))
+ if (!WRITE_STRING(tp->Strings[i]))
+ return (ERR);