routines for dealing with the terminal capability data base based on termcap More...
#include <ctype.h>#include <stdio.h>#include <string.h>#include <stdlib.h>#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include "printcap.h"Macros | |
| #define | BUFSIZ 1024 |
| #define | MAXHOP 32 |
| #define | PRINTCAP |
| #define | tgetent pgetent |
| #define | tskip pskip |
| #define | tgetstr pgetstr |
| #define | tdecode pdecode |
| #define | tgetnum pgetnum |
| #define | tgetflag pgetflag |
| #define | tdecode pdecode |
| #define | tnchktc pnchktc |
| #define | tnamatch pnamatch |
| #define | V6 |
Functions | |
| int | getprent (char *cap, char *bp, int bufsize) |
| Similar to tgetent except it returns the next entry instead of doing a lookup. | |
| void | endprent (void) |
| int | tgetent (char *cap, char *bp, const char *name) |
| Get an entry for terminal name in buffer bp, from the termcap file. | |
| int | tnchktc (char *cap) |
| check the last entry, see if it's tc=xxx. | |
| int | tnamatch (const char *np) |
| deals with name matching. | |
| static char * | tskip (char *bp) |
| Skip to the next field. Notice that this is very dumb, not knowing about \: escapes or any such. If necessary, :'s can be put into the termcap file in octal. | |
| int | tgetnum (char *id) |
| Return the (numeric) option id. | |
| int | tgetflag (char *id) |
| Handle a flag option. | |
| static char * | tdecode (char *str, char **area) |
| char * | tgetstr (char *id, char **area) |
| Get a string valued option. | |
| static char * | decodename (char *str, char **area, int bufsize) |
| char * | getpname (char **area, int bufsize) |
Variables | |
| static FILE * | pfp = NULL |
| static char * | tbuf |
| static int | hopcount |
routines for dealing with the terminal capability data base based on termcap
Essentially all the work here is scanning and decoding escapes in string capabilities. We don't use stdio because the editor doesn't, and because living w/o it is not hard.
| #define BUFSIZ 1024 |
| #define MAXHOP 32 |
max number of tc= indirections
| #define PRINTCAP |
| #define tdecode pdecode |
| #define tdecode pdecode |
| #define tgetent pgetent |
| #define tgetflag pgetflag |
| #define tgetnum pgetnum |
| #define tgetstr pgetstr |
| #define tnamatch pnamatch |
| #define tnchktc pnchktc |
| #define tskip pskip |
| #define V6 |
|
static |
| void endprent | ( | void | ) |
| char * getpname | ( | char ** | area, |
| int | bufsize ) |
| int getprent | ( | char * | cap, |
| char * | bp, | ||
| int | bufsize ) |
Similar to tgetent except it returns the next entry instead of doing a lookup.
|
static |
Tdecode does the grunt work to decode the string capability escapes.
| int tgetent | ( | char * | cap, |
| char * | bp, | ||
| const char * | name ) |
Get an entry for terminal name in buffer bp, from the termcap file.
Added a "cap" parameter, so we can use these calls for printcap and papd.conf.
| int tgetflag | ( | char * | id | ) |
Handle a flag option.
Flag options are given "naked", i.e. followed by a : or the end of the buffer.
| int tgetnum | ( | char * | id | ) |
Return the (numeric) option id.
Numeric options look like
i.e. the option string is separated from the numeric value by a # character. If the option is not found we return -1. Note that we handle octal numbers beginning with 0.
| char * tgetstr | ( | char * | id, |
| char ** | area ) |
Get a string valued option.
These are given as
Much decoding is done on the strings, and the strings are placed in area, which is a ref parameter which is updated. No checking on area overflow.
| int tnamatch | ( | const char * | np | ) |
deals with name matching.
The first field of the termcap entry is a sequence of names separated by |'s, so we compare against each such name. The normal : terminator after the last name (before the first field) stops us.
| int tnchktc | ( | char * | cap | ) |
check the last entry, see if it's tc=xxx.
If so, recursively find xxx and append that entry (minus the names) to take the place of the tc=xxx entry. This allows termcap entries to say "like an HP2621 but doesn't turn on the labels". Note that this works because of the left to right scan.
Added a "cap" parameter, so we can use these calls for printcap and papd.conf.
|
static |
Skip to the next field. Notice that this is very dumb, not knowing about \: escapes or any such. If necessary, :'s can be put into the termcap file in octal.
|
static |
detect infinite loops in termcap, init 0
|
static |
printcap data base file pointer
|
static |