+static unsigned
+extended_Numbers(TERMTYPE2 *tp)
+{
+ unsigned result = 0;
+ unsigned i;
+
+ for (i = 0; i < tp->ext_Numbers; ++i) {
+ if (tp->Numbers[NUMCOUNT + i] != ABSENT_NUMERIC)
+ result = (i + 1);
+ }
+ return result;
+}
+
+static unsigned
+extended_Strings(TERMTYPE2 *tp)
+{
+ unsigned short result = 0;
+ unsigned short i;
+
+ for (i = 0; i < tp->ext_Strings; ++i) {
+ if (tp->Strings[STRCOUNT + i] != ABSENT_STRING)
+ result = (unsigned short) (i + 1);
+ }
+ return result;
+}
+
+/*
+ * _nc_align_termtype() will extend entries that are referenced in a use=
+ * clause - discard the unneeded data.
+ */
+static bool
+extended_object(TERMTYPE2 *tp)
+{
+ bool result = FALSE;
+
+ if (_nc_user_definable) {
+ result = ((extended_Booleans(tp)
+ + extended_Numbers(tp)
+ + extended_Strings(tp)) != 0);
+ }
+ return result;
+}
+#endif
+
+NCURSES_EXPORT(int)
+_nc_write_object(TERMTYPE2 *tp, char *buffer, unsigned *offset, unsigned limit)
+{
+ char *namelist;
+ size_t namelen, boolmax, nummax, strmax, numlen;
+ char zero = '\0';
+ size_t i;
+ int nextfree;
+ short offsets[MAX_ENTRY_SIZE / 2];
+ unsigned char buf[MAX_ENTRY_SIZE];
+ unsigned last_bool = BOOLWRITE;
+ unsigned last_num = NUMWRITE;
+ unsigned last_str = STRWRITE;
+#if NCURSES_EXT_NUMBERS
+ bool need_ints = FALSE;
+ size_t (*convert_numbers) (unsigned char *, NCURSES_INT2 *, size_t) = convert_32bit;
+#else
+#define convert_numbers convert_shorts
+#endif
+
+#if NCURSES_XNAMES
+ /*
+ * Normally we limit the list of values to exclude the "obsolete"
+ * capabilities. However, if we are accepting extended names, add
+ * these as well, since they are used for supporting translation
+ * to/from termcap.
+ */
+ if (_nc_user_definable) {
+ last_bool = BOOLCOUNT;
+ last_num = NUMCOUNT;
+ last_str = STRCOUNT;
+ }
+#endif
+
+ namelist = tp->term_names;
+ namelen = strlen(namelist) + 1;