tgetflag.c (1937B)
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 43 #define TRUE 1 44 #define FALSE 0 45 # ifdef MSDOS 46 # define index strchr 47 # endif 48 49 extern char *_tcpbuf; /* Termcap entry buffer pointer */ 50 51 /* 52 * PSEUDO CODE 53 * 54 * Begin tgetflag 55 * Initialize pointer to the termcap entry buffer. 56 * While there is a field to process 57 * Skip over the field separator character. 58 * If this is the entry we want then 59 * If entry is identifier only then 60 * Return TRUE 61 * Else 62 * Return FALSE 63 * End if 64 * End if 65 * End while 66 * Return FALSE as default. 67 * End tgetflag 68 * 69 */ 70 71 tgetflag(id) 72 char *id; 73 { 74 char *bp; 75 extern char *index(); 76 77 bp = _tcpbuf; 78 while ((bp = index(bp,':')) != NULL) { 79 bp++; 80 if (*bp++ == id[0] && *bp != NULL && *bp++ == id[1]) { 81 if (*bp == NULL || *bp++ == ':') { 82 return(TRUE); 83 } else { 84 return(FALSE); 85 } 86 } 87 } 88 return(FALSE); 89 }