1 /* tget 1.0 - get termcap values Author: Kees J. Bot
13 "Usage: tget [-flag id] [-num id] [-str id] [-goto col line] [[-echo] string]\n"
18 int main(int argc
, char **argv
)
21 char string
[256], *pstr
;
26 if ((term
= getenv("TERM")) == nil
) {
27 fprintf(stderr
, "tget: $TERM is not set\n");
31 if (tgetent(termbuf
, term
) != 1) {
32 fprintf(stderr
, "tget: no termcap entry for '%s'\n", term
);
36 for (i
= 1; i
< argc
; i
++) {
37 char *option
= argv
[i
];
40 if (option
[0] != '-') {
41 fputs(option
, stdout
);
45 if (++i
== argc
) usage();
48 if (strcmp(option
, "-flag") == 0) {
49 excode
= tgetflag(id
) ? 0 : 1;
51 if (strcmp(option
, "-num") == 0) {
54 if ((num
= tgetnum(id
)) == -1) {
61 if (strcmp(option
, "-str") == 0) {
64 if ((str
= tgetstr(id
, (pstr
= string
, &pstr
))) == nil
) {
68 tputs(str
, 0, putchar
);
71 if (strcmp(option
, "-goto") == 0) {
76 if (++i
== argc
) usage();
79 if ((cm
= tgetstr("cm", (pstr
= string
, &pstr
))) == nil
) {
83 tputs(tgoto(cm
, col
, line
), 0, putchar
);
86 if (strcmp(option
, "-echo") == 0) {