X-Git-Url: http://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=test%2Fdemo_termcap.c;h=e5c747b3120a5ecb48a8822a195091fe968c6623;hb=5242fccf157e715ed878455a3efea6c82b840eb5;hp=20a38e7e075e88b35947552d342b98bbc61dd0e8;hpb=55ccd2b959766810cf7db8d1c4462f338ce0afc8;p=ncurses.git diff --git a/test/demo_termcap.c b/test/demo_termcap.c index 20a38e7e..e5c747b3 100644 --- a/test/demo_termcap.c +++ b/test/demo_termcap.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2005 Free Software Foundation, Inc. * + * Copyright (c) 2005-2006,2007 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 * @@ -29,12 +29,15 @@ /* * 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.6 2007/02/03 18:51:23 tom Exp $ * * A simple demo of the termcap interface. */ +#define USE_TINFO #include +#if HAVE_TGETENT + #define isCapName(c) (isgraph(c) && strchr("^#=:\\", c) == 0) static void @@ -106,19 +109,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 +158,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