static char sccsid
[] = "@(#)dis.c 1.2 (Berkeley) %G%";
** Dis -- VDU page display program
** "dis [-t<timeout>] [-c<refresh count>] [-u]"
** Bugs and comments to: Piers Lauder
extern char PC
, *BC
, *UP
;
#define putcm(cp,p,c) if(*cp++!=c){\
short Width
; /* width - 1 */
short Length
; /* length - 1 */
case 't': timeout
= atoi(&argv
[0][1]);
case 'c': rcount
= atoi(&argv
[0][1]);
case 'u': setbuf(stdin
, NULL
);
default: fprintf(stderr
, "%s: bad arg - %s\n", name
, argv
[0] );
if ( (Buf
= malloc(size
)) == (char *)0 )
fprintf(stderr
, "No memory\n");
/** on stack to avoid setjmp **/
if ( timeout
== 0 || setjmp(alrmbuf
) == 0 )
signal(SIGALRM
, alrmcatch
);
while ( (c
= getchar()) != EOF
)
case '\f': if ( cp
!= p
)
case '\t': c
= cp
- &p
[line
*width
] + 1;
case '\n': while ( cp
< ep
)
if ( (line
= (ep
-p
)/width
) < Length
)
register int x
= pos
%width
;
register int y
= pos
/width
;
putc(Buf
[pos
++], stdout
);
tputs(tgoto(CM
, x
, y
), 1, outc
);
if ( oy
== (y
-1) && x
== 0 )
if ( ox
!= Width
|| !amflag
)
tputs(tgoto(CM
, x
, y
), oy
<y
?y
-oy
:oy
-y
, outc
);
if ( y
==Length
&& x
==Width
&& amflag
)
if ( tgetent(bp
, getenv("TERM")) != 1 )
terror("no \"termcap\" entry");
if ( (CL
= tgetstr("cl", &area
)) == (char *)0 )
if ( (CM
= tgetstr("cm", &area
)) == (char *)0 )
terror("no cursor addressing");
UP
= tgetstr("up", &area
);
BC
= tgetstr("bc", &area
);
if ( tgetflag("am") == 1 )
if ( (cp
= getenv("WIDTH")) != (char *)0 )
if ( (length
= tgetnum("li")) > MAXLEN
)
warn("length truncated");
if ( (cp
= tgetstr("pc", &area
)) != (char *)0 )
fprintf(stderr
, "Warning: %s\n", s
);
fprintf(stderr
, "Terminal capability error - %s\n", s
);