]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/demo_termcap.c
ncurses 5.6
[ncurses.git] / test / demo_termcap.c
index 20a38e7e075e88b35947552d342b98bbc61dd0e8..fc9c8ab9ac5e2ba048b5073bea067b6459bb986b 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2005 Free Software Foundation, Inc.                        *
+ * Copyright (c) 2005,2006 Free Software Foundation, Inc.                   *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
 /*
  * Author: Thomas E. Dickey
  *
- * $Id: demo_termcap.c,v 1.2 2005/04/30 14:57:54 tom Exp $
+ * $Id: demo_termcap.c,v 1.5 2006/05/06 19:06:36 tom Exp $
  *
  * A simple demo of the termcap interface.
  */
 #include <test.priv.h>
 
+#if HAVE_TGETENT
+
 #define isCapName(c) (isgraph(c) && strchr("^#=:\\", c) == 0)
 
 static void
@@ -106,19 +108,19 @@ dumpit(char *cap)
        printf("\n");
     } else if ((num = tgetnum(cap)) >= 0) {
        printf("num %s = %d\n", cap, num);
-    } else if ((num = tgetflag(cap)) != 0) {
+    } else if ((num = tgetflag(cap)) > 0) {
        printf("flg %s\n", cap);
     }
     fflush(stdout);
 }
 
 static void
-demo_termcap(char *name)
+demo_termcap(const char *name)
 {
     char buffer[1024];
 
     printf("Terminal type %s\n", name);
-    if (tgetent(buffer, name)) {
+    if (tgetent(buffer, name) >= 0) {
        char cap[3];
        int c1, c2;
 
@@ -155,3 +157,12 @@ main(int argc, char *argv[])
 
     ExitProgram(EXIT_SUCCESS);
 }
+#else
+int
+main(int argc GCC_UNUSED,
+     char *argv[]GCC_UNUSED)
+{
+    printf("This program requires termcap\n");
+    exit(EXIT_FAILURE);
+}
+#endif