+#if USE_CODE_LISTS
+static void
+demo_termcap(NCURSES_CONST char *name)
+{
+ unsigned n;
+ NCURSES_CONST char *cap;
+
+ if (db_list) {
+ putenv(next_dbitem());
+ }
+ printf("Terminal type \"%s\"\n", name);
+#if HAVE_SETUPTERM
+ setupterm(name, 1, (int *) 0);
+#else
+ setterm(name);
+#endif
+ save_screen();
+
+ if (b_opt) {
+ for (n = 0;; ++n) {
+ cap = boolcodes[n];
+ if (cap == 0)
+ break;
+ dumpit(cap);
+ }
+ }
+
+ if (n_opt) {
+ for (n = 0;; ++n) {
+ cap = numcodes[n];
+ if (cap == 0)
+ break;
+ dumpit(cap);
+ }
+ }
+
+ if (s_opt) {
+ for (n = 0;; ++n) {
+ cap = strcodes[n];
+ if (cap == 0)
+ break;
+ dumpit(cap);
+ }
+ }
+}
+
+static void
+usage(void)
+{
+ static const char *msg[] =
+ {
+ "Usage: demo_termcap [options] [terminal]",
+ "",
+ "If no options are given, print all (boolean, numeric, string)",
+ "capabilities for the given terminal, using short names.",
+ "",
+ "Options:",
+ " -a try all names, print capabilities found",
+ " -b print boolean-capabilities",
+ " -d LIST colon-separated list of databases to use",
+ " -e NAME environment variable to set with -d option",
+ " -n print numeric-capabilities",
+ " -q quiet (prints only counts)",
+ " -r COUNT repeat for given count",
+ " -s print string-capabilities",
+ };
+ unsigned n;
+ for (n = 0; n < SIZEOF(msg); ++n) {
+ fprintf(stderr, "%s\n", msg[n]);
+ }
+ ExitProgram(EXIT_FAILURE);
+}
+#endif
+