home *** CD-ROM | disk | FTP | other *** search
/ Computer Club Elmshorn Atari PD / CCE_PD.iso / pc / 0600 / CCE_0636.ZIP / CCE_0636 / CURSES / CRSSRC12.ZOO / src / tgetflag.c < prev    next >
C/C++ Source or Header  |  1991-09-27  |  2KB  |  95 lines

  1. /************************************************************************
  2.  *                                    *
  3.  *            Copyright (c) 1982, Fred Fish            *
  4.  *                All Rights Reserved                *
  5.  *                                    *
  6.  *    This software and/or documentation is released for public    *
  7.  *    distribution for personal, non-commercial use only.        *
  8.  *    Limited rights to use, modify, and redistribute are hereby    *
  9.  *    granted for non-commercial purposes, provided that all        *
  10.  *    copyright notices remain intact and all changes are clearly    *
  11.  *    documented.  The author makes no warranty of any kind with    *
  12.  *    respect to this product and explicitly disclaims any implied    *
  13.  *    warranties of merchantability or fitness for any particular    *
  14.  *    purpose.                            *
  15.  *                                    *
  16.  ************************************************************************
  17.  */
  18.  
  19.  
  20. /*
  21.  *  LIBRARY FUNCTION
  22.  *
  23.  *    tgetflag   extract boolean termcap capability
  24.  *
  25.  *  KEY WORDS
  26.  *
  27.  *    termcap
  28.  *
  29.  *  SYNOPSIS
  30.  *
  31.  *    tgetflag(id)
  32.  *    char *id;
  33.  *
  34.  *  DESCRIPTION
  35.  *
  36.  *    Returns TRUE if specified id is present in terminal
  37.  *    entry, FALSE otherwise.
  38.  *
  39.  */
  40.  
  41. #include <stdio.h>
  42. #include <string.h>
  43. #include <termcap.h>
  44.  
  45. #ifndef _COMPILER_H
  46. #  include <compiler.h>
  47. #endif
  48.  
  49. #define TRUE 1
  50. #define FALSE 0
  51. # ifdef MSDOS
  52. # define index strchr
  53. # endif
  54.  
  55. extern char *_tcpbuf;        /* Termcap entry buffer pointer */
  56.  
  57. /*
  58.  *  PSEUDO CODE
  59.  *
  60.  *    Begin tgetflag
  61.  *        Initialize pointer to the termcap entry buffer.
  62.  *        While there is a field to process
  63.  *        Skip over the field separator character.
  64.  *        If this is the entry we want then
  65.  *            If entry is identifier only then
  66.  *            Return TRUE
  67.  *            Else
  68.  *            Return FALSE
  69.  *            End if
  70.  *        End if
  71.  *        End while
  72.  *        Return FALSE as default.
  73.  *    End tgetflag
  74.  *
  75.  */
  76.  
  77. int tgetflag(id)
  78. char *id;
  79. {
  80.     char *bp;
  81.  
  82.     bp = _tcpbuf;
  83.     while ((bp = index(bp,':')) != NULL) {
  84.     bp++;
  85.     if (*bp++ == id[0] && *bp != '\0' && *bp++ == id[1]) {
  86.         if (*bp == '\0' || *bp++ == ':') {
  87.         return(TRUE);
  88.         } else {
  89.         return(FALSE);
  90.         }
  91.     }
  92.     }
  93.     return(FALSE);
  94. }
  95.