1 /* tget 1.0 - get termcap values Author: Kees J. Bot
18 "Usage: tget [-flag id] [-num id] [-str id] [-goto col line] [[-echo] string]\n"
23 int main(int argc
, char **argv
)
26 char string
[256], *pstr
;
31 if ((term
= getenv("TERM")) == nil
) {
32 fprintf(stderr
, "tget: $TERM is not set\n");
36 if (tgetent(termbuf
, term
) != 1) {
37 fprintf(stderr
, "tget: no termcap entry for '%s'\n", term
);
41 for (i
= 1; i
< argc
; i
++) {
42 char *option
= argv
[i
];
45 if (option
[0] != '-') {
46 fputs(option
, stdout
);
50 if (++i
== argc
) usage();
53 if (strcmp(option
, "-flag") == 0) {
54 excode
= tgetflag(id
) ? 0 : 1;
56 if (strcmp(option
, "-num") == 0) {
59 if ((num
= tgetnum(id
)) == -1) {
66 if (strcmp(option
, "-str") == 0) {
69 if ((str
= tgetstr(id
, (pstr
= string
, &pstr
))) == nil
) {
73 tputs(str
, 0, fputchar
);
76 if (strcmp(option
, "-goto") == 0) {
81 if (++i
== argc
) usage();
84 if ((cm
= tgetstr("cm", (pstr
= string
, &pstr
))) == nil
) {
88 tputs(tgoto(cm
, col
, line
), 0, fputchar
);
91 if (strcmp(option
, "-echo") == 0) {