+#if NCURSES_XNAMES
+#define NUM_BOOLEANS(tp) (tp)->num_Booleans
+#define NUM_NUMBERS(tp) (tp)->num_Numbers
+#define NUM_STRINGS(tp) (tp)->num_Strings
+#define EXT_NAMES(tp,i,limit,index,table) (i >= limit) ? tp->ext_Names[index] : table[i]
+#else
+#define NUM_BOOLEANS(tp) BOOLCOUNT
+#define NUM_NUMBERS(tp) NUMCOUNT
+#define NUM_STRINGS(tp) STRCOUNT
+#define EXT_NAMES(tp,i,limit,index,table) table[i]
+#endif
+
+#define NUM_EXT_NAMES(tp) (unsigned) ((tp)->ext_Booleans + (tp)->ext_Numbers + (tp)->ext_Strings)
+
+#define for_each_boolean(n,tp) for(n = 0; n < NUM_BOOLEANS(tp); n++)
+#define for_each_number(n,tp) for(n = 0; n < NUM_NUMBERS(tp); n++)
+#define for_each_string(n,tp) for(n = 0; n < NUM_STRINGS(tp); n++)
+
+#if NCURSES_XNAMES
+#define for_each_ext_boolean(n,tp) for(n = BOOLCOUNT; n < NUM_BOOLEANS(tp); n++)
+#define for_each_ext_number(n,tp) for(n = NUMCOUNT; n < NUM_NUMBERS(tp); n++)
+#define for_each_ext_string(n,tp) for(n = STRCOUNT; n < NUM_STRINGS(tp); n++)
+#endif
+
+#define ExtBoolname(tp,i,names) EXT_NAMES(tp, i, BOOLCOUNT, (i - (tp->num_Booleans - tp->ext_Booleans)), names)
+#define ExtNumname(tp,i,names) EXT_NAMES(tp, i, NUMCOUNT, (i - (tp->num_Numbers - tp->ext_Numbers)) + tp->ext_Booleans, names)
+#define ExtStrname(tp,i,names) EXT_NAMES(tp, i, STRCOUNT, (i - (tp->num_Strings - tp->ext_Strings)) + (tp->ext_Numbers + tp->ext_Booleans), names)
+
+extern NCURSES_EXPORT_VAR(ENTRY *) _nc_head;
+extern NCURSES_EXPORT_VAR(ENTRY *) _nc_tail;