]> ncurses.scripts.mit.edu Git - ncurses.git/blob - test/demo_termcap.c
ncurses 6.0 - patch 20161224
[ncurses.git] / test / demo_termcap.c
1 /****************************************************************************
2  * Copyright (c) 2005-2015,2016 Free Software Foundation, Inc.              *
3  *                                                                          *
4  * Permission is hereby granted, free of charge, to any person obtaining a  *
5  * copy of this software and associated documentation files (the            *
6  * "Software"), to deal in the Software without restriction, including      *
7  * without limitation the rights to use, copy, modify, merge, publish,      *
8  * distribute, distribute with modifications, sublicense, and/or sell       *
9  * copies of the Software, and to permit persons to whom the Software is    *
10  * furnished to do so, subject to the following conditions:                 *
11  *                                                                          *
12  * The above copyright notice and this permission notice shall be included  *
13  * in all copies or substantial portions of the Software.                   *
14  *                                                                          *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22  *                                                                          *
23  * Except as contained in this notice, the name(s) of the above copyright   *
24  * holders shall not be used in advertising or otherwise to promote the     *
25  * sale, use or other dealings in this Software without prior written       *
26  * authorization.                                                           *
27  ****************************************************************************/
28
29 /*
30  * Author: Thomas E. Dickey
31  *
32  * $Id: demo_termcap.c,v 1.51 2016/09/10 21:22:39 tom Exp $
33  *
34  * A simple demo of the termcap interface.
35  */
36 #define USE_TINFO
37 #include <test.priv.h>
38 #include <sys/stat.h>
39
40 #if NCURSES_XNAMES
41 #if HAVE_TERM_ENTRY_H
42 #include <term_entry.h>
43 #else
44 #undef NCURSES_XNAMES
45 #define NCURSES_XNAMES 0
46 #endif
47 #endif
48
49 #ifdef NCURSES_VERSION
50 #include <termcap.h>
51 #endif
52
53 static void failed(const char *) GCC_NORETURN;
54
55 static void
56 failed(const char *msg)
57 {
58     fprintf(stderr, "%s\n", msg);
59     ExitProgram(EXIT_FAILURE);
60 }
61
62 #if HAVE_TGETENT
63
64 #if defined(HAVE_CURSES_DATA_BOOLNAMES) || defined(DECL_CURSES_DATA_BOOLNAMES)
65 #define USE_CODE_LISTS 1
66 #else
67 #define USE_CODE_LISTS 0
68 #endif
69
70 #define FCOLS 8
71 #define FNAME(type) "%s %-*s = ", #type, FCOLS
72
73 static bool b_opt = FALSE;
74 static bool n_opt = FALSE;
75 static bool s_opt = FALSE;
76 static bool q_opt = FALSE;
77 static bool x_opt = FALSE;
78 static bool y_opt = FALSE;
79
80 static char *d_opt;
81 static char *e_opt;
82 static char **db_list;
83 static int db_item;
84
85 static char *my_blob;
86 static char **my_boolcodes;
87 static char **my_numcodes;
88 static char **my_numvalues;
89 static char **my_strcodes;
90 static char **my_strvalues;
91
92 static long total_values;
93 static long total_b_values;
94 static long total_n_values;
95 static long total_s_values;
96
97 #define isCapName(c) (isgraph(c) && strchr("^=:\\", c) == 0)
98 #define EachCapName(n) n = 33; n < 127; ++n
99
100 static char *
101 make_dbitem(char *p, char *q)
102 {
103     size_t need = strlen(e_opt) + 2 + (size_t) (p - q);
104     char *result = malloc(need);
105     _nc_SPRINTF(result, _nc_SLIMIT(need) "%s=%.*s", e_opt, (int) (p - q), q);
106     return result;
107 }
108
109 static void
110 make_dblist(void)
111 {
112     if (d_opt && e_opt) {
113         int pass;
114
115         for (pass = 0; pass < 2; ++pass) {
116             char *p, *q;
117             size_t count = 0;
118
119             for (p = q = d_opt; *p != '\0'; ++p) {
120                 if (*p == ':') {
121                     if (p != q + 1) {
122                         if (pass) {
123                             db_list[count] = make_dbitem(p, q);
124                         }
125                         count++;
126                     }
127                     q = p + 1;
128                 }
129             }
130             if (p != q + 1) {
131                 if (pass) {
132                     db_list[count] = make_dbitem(p, q);
133                 }
134                 count++;
135             }
136             if (!pass) {
137                 db_list = typeCalloc(char *, count + 1);
138             }
139         }
140     }
141 }
142
143 static char *
144 next_dbitem(void)
145 {
146     char *result = 0;
147
148     if (db_list) {
149         if ((result = db_list[db_item]) == 0) {
150             db_item = 0;
151             result = db_list[0];
152         } else {
153             db_item++;
154         }
155     }
156     printf("** %s\n", result);
157     return result;
158 }
159
160 static void
161 free_dblist(void)
162 {
163     if (db_list) {
164         int n;
165         for (n = 0; db_list[n]; ++n)
166             free(db_list[n]);
167         free(db_list);
168         db_list = 0;
169     }
170 }
171
172 static void
173 show_string(const char *name, const char *value)
174 {
175     printf(FNAME(str), name);
176     if (value == ((char *) -1)) {
177         printf("CANCELLED");
178     } else if (value == ((char *) 0)) {
179         printf("ABSENT");
180     } else {
181         while (*value != 0) {
182             int ch = UChar(*value++);
183             switch (ch) {
184             case '\177':
185                 fputs("^?", stdout);
186                 break;
187             case '\033':
188                 fputs("\\E", stdout);
189                 break;
190             case '\b':
191                 fputs("\\b", stdout);
192                 break;
193             case '\f':
194                 fputs("\\f", stdout);
195                 break;
196             case '\n':
197                 fputs("\\n", stdout);
198                 break;
199             case '\r':
200                 fputs("\\r", stdout);
201                 break;
202             case ' ':
203                 fputs("\\s", stdout);
204                 break;
205             case '\t':
206                 fputs("\\t", stdout);
207                 break;
208             case '^':
209                 fputs("\\^", stdout);
210                 break;
211             case ':':
212                 fputs("\\072", stdout);
213                 break;
214             case '\\':
215                 fputs("\\\\", stdout);
216                 break;
217             default:
218                 if (isgraph(ch))
219                     fputc(ch, stdout);
220                 else if (ch < 32)
221                     printf("^%c", ch + '@');
222                 else
223                     printf("\\%03o", ch);
224                 break;
225             }
226         }
227     }
228     printf("\n");
229 }
230
231 static void
232 show_number(const char *name, int value)
233 {
234     printf(FNAME(num), name);
235     printf(" %d\n", value);
236 }
237
238 static void
239 dumpit(NCURSES_CONST char *cap)
240 {
241     /*
242      * One of the limitations of the termcap interface is that the library
243      * cannot determine the size of the buffer passed via tgetstr(), nor the
244      * amount of space remaining.  This demo simply reuses the whole buffer
245      * for each call; a normal termcap application would try to use the buffer
246      * to hold all of the strings extracted from the terminal entry.
247      */
248     char area[1024], *ap = area;
249     char *str;
250     int num;
251
252     if ((str = tgetstr(cap, &ap)) != 0) {
253         total_values++;
254         total_s_values++;
255         if (!q_opt) {
256             /*
257              * Note that the strings returned are mostly terminfo format, since
258              * ncurses does not convert except for a handful of special cases.
259              */
260             show_string(cap, str);
261         }
262     } else if ((num = tgetnum(cap)) >= 0) {
263         total_values++;
264         total_n_values++;
265         if (!q_opt) {
266             show_number(cap, num);
267         }
268     } else if (tgetflag(cap) > 0) {
269         total_values++;
270         total_b_values++;
271         if (!q_opt) {
272             printf(FNAME(flg), cap);
273             printf("%s\n", "true");
274         }
275     }
276
277     if (!q_opt)
278         fflush(stdout);
279 }
280
281 static void
282 brute_force(const char *name)
283 {
284     char buffer[1024];
285
286     if (db_list) {
287         putenv(next_dbitem());
288     }
289     if (!q_opt)
290         printf("Terminal type \"%s\"\n", name);
291     if (tgetent(buffer, name) >= 0) {
292         char cap[3];
293         int c1, c2;
294
295         cap[2] = 0;
296         for (EachCapName(c1)) {
297             cap[0] = (char) c1;
298             if (isCapName(c1)) {
299                 for (EachCapName(c2)) {
300                     cap[1] = (char) c2;
301                     if (isCapName(c2)) {
302                         dumpit(cap);
303                     }
304                 }
305             }
306         }
307     }
308 }
309
310 #if NCURSES_XNAMES
311 static void
312 dump_xname(NCURSES_CONST char *cap)
313 {
314     if (strlen(cap) == 2)
315         dumpit(cap);
316 }
317 #endif
318
319 static void
320 demo_termcap(NCURSES_CONST char *name)
321 {
322     unsigned n;
323     NCURSES_CONST char *cap;
324     char buffer[1024];
325
326     if (db_list) {
327         putenv(next_dbitem());
328     }
329     if (!q_opt)
330         printf("Terminal type \"%s\"\n", name);
331     if (tgetent(buffer, name) >= 0) {
332
333         if (b_opt) {
334             for (n = 0;; ++n) {
335                 cap = my_boolcodes[n];
336                 if (cap == 0)
337                     break;
338                 dumpit(cap);
339             }
340         }
341
342         if (n_opt) {
343             for (n = 0;; ++n) {
344                 cap = my_numcodes[n];
345                 if (cap == 0)
346                     break;
347                 dumpit(cap);
348             }
349         }
350
351         if (s_opt) {
352             for (n = 0;; ++n) {
353                 cap = my_strcodes[n];
354                 if (cap == 0)
355                     break;
356                 dumpit(cap);
357             }
358         }
359 #ifdef NCURSES_VERSION
360         if (x_opt && (my_blob == 0) && y_opt) {
361 #if NCURSES_XNAMES
362             TERMTYPE *term = &(cur_term->type);
363             if (term != 0
364                 && ((NUM_BOOLEANS(term) != BOOLCOUNT)
365                     || (NUM_NUMBERS(term) != NUMCOUNT)
366                     || (NUM_STRINGS(term) != STRCOUNT))) {
367                 for (n = BOOLCOUNT; n < NUM_BOOLEANS(term); ++n) {
368                     dump_xname(ExtBoolname(term, (int) n, boolnames));
369                 }
370                 for (n = NUMCOUNT; n < NUM_NUMBERS(term); ++n) {
371                     dump_xname(ExtNumname(term, (int) n, numnames));
372                 }
373                 for (n = STRCOUNT; n < NUM_STRINGS(term); ++n) {
374                     dump_xname(ExtStrname(term, (int) n, strnames));
375                 }
376             }
377 #endif
378         }
379 #endif
380     }
381 }
382
383 typedef enum {
384     pDefault = 0
385     ,pComment
386     ,pDescription
387     ,pEscaped
388     ,pNewline
389     ,pName
390     ,pNumber
391     ,pString
392 } STATE;
393
394 static void
395 parse_description(const char *input_name)
396 {
397     static char empty[1];
398
399     FILE *fp;
400     struct stat sb;
401     size_t count_bools = 0;
402     size_t count_nums = 0;
403     size_t count_strs = 0;
404     size_t len;
405     size_t j, k;
406     STATE state;
407
408     if (stat(input_name, &sb) != 0
409         || (sb.st_mode & S_IFMT) != S_IFREG) {
410         failed("input is not a file");
411     }
412
413     if (sb.st_size == 0) {
414         failed("input is empty");
415     }
416
417     /*
418      * None of the arrays could be larger than the input-file, and since it
419      * is small, just allocate the maximum for simplicity.
420      */
421     if ((my_blob = malloc((size_t) sb.st_size + 1)) == 0 ||
422         (my_boolcodes = typeCalloc(char *, sb.st_size)) == 0 ||
423           (my_numcodes = typeCalloc(char *, sb.st_size)) == 0 ||
424           (my_numvalues = typeCalloc(char *, sb.st_size)) == 0 ||
425           (my_strcodes = typeCalloc(char *, sb.st_size)) == 0 ||
426           (my_strvalues = typeCalloc(char *, sb.st_size)) == 0) {
427         failed("cannot allocate memory for input-file");
428     }
429
430     if ((fp = fopen(input_name, "r")) == 0)
431         failed("cannot open input-file");
432     len = fread(my_blob, sizeof(char), (size_t) sb.st_size, fp);
433     my_blob[sb.st_size] = '\0';
434     fclose(fp);
435
436     /*
437      * First, get rid of comments and escaped newlines, as well as repeated
438      * colons to construct a canonical entry.
439      *
440      * FIXME: actually this should make an additional pass just to strip
441      * comment-lines and escaped newlines.  But it is workable for infocmp
442      * output.
443      */
444     state = pNewline;
445     for (j = k = 0; j < len; ++j) {
446         int ch = my_blob[j];
447         if (ch == '\t') {
448             ch = ' ';
449         }
450         switch (state) {
451         case pNewline:
452             if (ch == ' ') {
453                 continue;
454             }
455             if (ch == '#') {
456                 state = pComment;
457                 continue;
458             }
459             state = pDefault;
460             /* FALLTHRU */
461         case pDefault:
462             switch (ch) {
463             case '|':
464                 state = pDescription;
465                 continue;
466             case '\\':
467                 state = pEscaped;
468                 continue;
469             case '\n':
470                 state = pNewline;
471                 continue;
472             case ' ':
473             case ':':
474                 break;
475             default:
476                 state = pName;
477                 break;
478             }
479             my_blob[k++] = (char) ch;
480             break;
481         case pComment:
482             if (ch == '\n')
483                 state = pNewline;
484             break;
485         case pDescription:
486             switch (ch) {
487             case ':':
488                 state = pDefault;
489                 break;
490             case '\n':
491                 state = pNewline;
492                 break;
493             }
494             break;
495         case pEscaped:
496             if (ch != '\n') {
497                 my_blob[k++] = (char) ch;
498                 state = pDefault;
499             } else {
500                 state = pNewline;
501             }
502             break;
503         case pName:
504             switch (ch) {
505             case '\n':
506                 state = pNewline;
507                 continue;
508             case ' ':
509             case ':':
510                 state = pDefault;
511                 break;
512             case '#':
513                 state = pNumber;
514                 break;
515             case '|':
516                 state = pDescription;
517                 continue;
518             }
519             my_blob[k++] = (char) ch;
520             break;
521         case pNumber:
522             switch (ch) {
523             case '\n':
524                 state = pNewline;
525                 continue;
526             case ':':
527                 state = pDefault;
528                 break;
529             case ' ':
530                 state = pDefault;
531                 continue;
532             }
533             my_blob[k++] = (char) ch;
534             break;
535         case pString:
536             switch (ch) {
537             case '\\':
538                 if (my_blob[j + 1] == '\0') {
539                     state = pDefault;
540                     continue;
541                 }
542                 break;
543             case '\n':
544                 state = pNewline;
545                 continue;
546             case ':':
547                 state = pDefault;
548                 break;
549             }
550             my_blob[k++] = (char) ch;
551             break;
552         default:
553             /* not used */
554             break;
555         }
556     }
557     my_blob[k] = '\0';
558
559     /*
560      * Then, parse what's left, making indexes of the names and values.
561      */
562     state = pDefault;
563     for (j = 0; my_blob[j] != '\0'; ++j) {
564         switch (state) {
565         case pDefault:
566             switch (my_blob[j]) {
567             case '\\':
568                 state = pEscaped;
569                 break;
570             case ':':
571                 my_blob[j] = '\0';
572                 if (my_blob[j + 1] != '\0' && my_blob[j + 1] != ':')
573                     state = pName;
574                 break;
575             case ' ':
576                 break;
577             default:
578                 break;
579             }
580         case pEscaped:
581             break;
582         case pName:
583             state = pDefault;
584             /*
585              * Commented-out capabilities might be accessible (they are in
586              * ncurses).
587              */
588             if (my_blob[j] == '.' && my_blob[j + 1] == '.') {
589                 j += 2;
590             }
591             if (my_blob[j + 1] != '\0') {
592                 switch (my_blob[j + 2]) {
593                 case '#':
594                     my_numvalues[count_nums] = &my_blob[j + 3];
595                     my_numcodes[count_nums++] = &my_blob[j];
596                     my_blob[j + 2] = '\0';
597                     state = pNumber;
598                     j += 2;
599                     break;
600                 case '=':
601                     my_strvalues[count_strs] = &my_blob[j + 3];
602                     my_strcodes[count_strs++] = &my_blob[j];
603                     my_blob[j + 2] = '\0';
604                     state = pString;
605                     j += 2;
606                     break;
607                 default:
608                     if (my_blob[j + 2] == '@') {
609                         /*
610                          * We cannot get the type for a cancelled item
611                          * directly, but can infer it assuming the input
612                          * came from infocmp, which puts the data in a
613                          * known order.
614                          */
615                         if (count_strs) {
616                             my_strvalues[count_strs] = empty;
617                             my_strcodes[count_strs++] = &my_blob[j];
618                         } else if (count_nums) {
619                             my_numvalues[count_nums] = empty;
620                             my_numcodes[count_nums++] = &my_blob[j];
621                         } else {
622                             my_boolcodes[count_bools++] = &my_blob[j];
623                         }
624                     } else {
625                         my_boolcodes[count_bools++] = &my_blob[j];
626                     }
627                     j++;
628                     break;
629                 }
630             }
631             break;
632         case pNumber:
633             if (!isdigit(UChar(my_blob[j]))) {
634                 --j;
635                 state = pDefault;
636             }
637             break;
638         case pString:
639             switch (my_blob[j]) {
640             case '\\':
641                 if (my_blob[j + 1] == '\0') {
642                     state = pDefault;
643                     continue;
644                 } else {
645                     ++j;
646                 }
647                 break;
648             case '\n':
649                 state = pNewline;
650                 continue;
651             case ':':
652                 --j;
653                 state = pDefault;
654                 break;
655             }
656             break;
657         case pNewline:
658         case pComment:
659         case pDescription:
660         default:
661             break;
662         }
663     }
664     my_boolcodes[count_bools] = 0;
665     my_numcodes[count_nums] = 0;
666     my_numvalues[count_nums] = 0;
667     my_strcodes[count_strs] = 0;
668     my_strvalues[count_strs] = 0;
669
670 #if 0
671     printf("bools:%d\n", (int) count_bools);
672     for (j = 0; my_boolcodes[j]; ++j)
673         printf("%5d:%s\n", (int) j, my_boolcodes[j]);
674
675     printf("numbers:%d\n", (int) count_nums);
676     for (j = 0; my_numcodes[j]; ++j)
677         printf("%5d:%s(%s)\n", (int) j, my_numcodes[j], my_numvalues[j]);
678
679     printf("strings:%d\n", (int) count_strs);
680     for (j = 0; my_strcodes[j]; ++j)
681         printf("%5d:%s(%s)\n", (int) j, my_strcodes[j], my_strvalues[j]);
682 #endif
683 }
684
685 #if USE_CODE_LISTS
686 static char **
687 copy_code_list(NCURSES_CONST char *const *list)
688 {
689     int pass;
690     size_t count;
691     size_t length = 1;
692     char **result = 0;
693     char *blob = 0;
694     char *unused = 0;
695
696     for (pass = 0; pass < 2; ++pass) {
697         for (count = 0; list[count] != 0; ++count) {
698             size_t chunk = strlen(list[count]) + 1;
699             if (pass == 0) {
700                 length += chunk;
701             } else {
702                 result[count] = unused;
703                 _nc_STRCPY(unused, list[count], length);
704                 unused += chunk;
705             }
706         }
707         if (pass == 0) {
708             blob = malloc(length);
709             result = typeCalloc(char *, count + 1);
710             unused = blob;
711             if (blob == 0 || result == 0)
712                 failed("copy_code_list failed");
713         }
714     }
715
716     return result;
717 }
718 #endif
719
720 static void
721 usage(void)
722 {
723     static const char *msg[] =
724     {
725         "Usage: demo_termcap [options] [terminal]",
726         "",
727         "If no options are given, print all (boolean, numeric, string)",
728         "capabilities for the given terminal, using short names.",
729         "",
730         "Options:",
731         " -a       try all names, print capabilities found",
732         " -b       print boolean-capabilities",
733         " -d LIST  colon-separated list of databases to use",
734         " -e NAME  environment variable to set with -d option",
735         " -i NAME  terminal description to use as names for \"-a\" option, etc.",
736         " -n       print numeric-capabilities",
737         " -q       quiet (prints only counts)",
738         " -r COUNT repeat for given count",
739         " -s       print string-capabilities",
740         " -v       print termcap-variables",
741 #ifdef NCURSES_VERSION
742         " -x       print extended capabilities",
743 #endif
744     };
745     unsigned n;
746     for (n = 0; n < SIZEOF(msg); ++n) {
747         fprintf(stderr, "%s\n", msg[n]);
748     }
749     ExitProgram(EXIT_FAILURE);
750 }
751
752 int
753 main(int argc, char *argv[])
754 {
755     int n;
756     char *name;
757     bool a_opt = FALSE;
758     bool v_opt = FALSE;
759     char *input_name = 0;
760
761     int repeat;
762     int r_opt = 1;
763
764     while ((n = getopt(argc, argv, "abd:e:i:nqr:svxy")) != -1) {
765         switch (n) {
766         case 'a':
767             a_opt = TRUE;
768             break;
769         case 'b':
770             b_opt = TRUE;
771             break;
772         case 'd':
773             d_opt = optarg;
774             break;
775         case 'e':
776             e_opt = optarg;
777             break;
778         case 'i':
779             input_name = optarg;
780             break;
781         case 'n':
782             n_opt = TRUE;
783             break;
784         case 'q':
785             q_opt = TRUE;
786             break;
787         case 'r':
788             if ((r_opt = atoi(optarg)) <= 0)
789                 usage();
790             break;
791         case 's':
792             s_opt = TRUE;
793             break;
794         case 'v':
795             v_opt = TRUE;
796             break;
797 #if NCURSES_XNAMES
798         case 'x':
799             x_opt = TRUE;
800             break;
801         case 'y':
802             y_opt = TRUE;
803             x_opt = TRUE;
804             break;
805 #endif
806         default:
807             usage();
808             break;
809         }
810     }
811
812 #if HAVE_USE_EXTENDED_NAMES
813     use_extended_names(x_opt);
814 #endif
815
816     if (!(b_opt || n_opt || s_opt)) {
817         b_opt = TRUE;
818         n_opt = TRUE;
819         s_opt = TRUE;
820     }
821
822     make_dblist();
823
824     if (a_opt) {
825         for (repeat = 0; repeat < r_opt; ++repeat) {
826             if (optind < argc) {
827                 for (n = optind; n < argc; ++n) {
828                     brute_force(argv[n]);
829                 }
830             } else if ((name = getenv("TERM")) != 0) {
831                 brute_force(name);
832             } else {
833                 static char dumb[] = "dumb";
834                 brute_force(dumb);
835             }
836         }
837     } else {
838         if (input_name != 0) {
839             parse_description(input_name);
840         }
841 #if USE_CODE_LISTS
842         else {
843             my_boolcodes = copy_code_list(boolcodes);
844             my_numcodes = copy_code_list(numcodes);
845             my_strcodes = copy_code_list(strcodes);
846         }
847 #else
848         else {
849             failed("no capability-lists available (use -i option)");
850         }
851 #endif /* USE_CODE_LISTS */
852         for (repeat = 0; repeat < r_opt; ++repeat) {
853             if (optind < argc) {
854                 for (n = optind; n < argc; ++n) {
855                     demo_termcap(argv[n]);
856                 }
857             } else if ((name = getenv("TERM")) != 0) {
858                 demo_termcap(name);
859             } else {
860                 static char dumb[] = "dumb";
861                 demo_termcap(dumb);
862             }
863         }
864     }
865
866     printf("%ld values (%ld booleans, %ld numbers, %ld strings)\n",
867            total_values, total_b_values, total_n_values, total_s_values);
868
869 #if defined(NCURSES_VERSION) || defined(HAVE_CURSES_DATA_OSPEED)
870     if (v_opt) {
871         show_number("PC", PC);
872         show_string("UP", UP);
873         show_string("BC", BC);
874         show_number("ospeed", ospeed);
875     }
876 #endif
877
878     free_dblist();
879
880     ExitProgram(EXIT_SUCCESS);
881 }
882
883 #else
884 int
885 main(int argc GCC_UNUSED,
886      char *argv[]GCC_UNUSED)
887 {
888     failed("This program requires termcap");
889 }
890 #endif