11 #include "shared/report.h"
12 #include "shared/sockets.h"
15 unsigned short vc_width
= 0, vc_height
= 0;
16 unsigned short vc_cursor_x
= 0, vc_cursor_y
= 0;
22 /* Open the /dev/vcsX and /dev/vcsaX devices */
23 vcs0
= open(vcs_device
, O_RDONLY
);
25 report(RPT_ERR
, "Could not open %s: %s", vcs_device
, strerror(errno
));
28 vcsa
= open(vcsa_device
, O_RDONLY
);
30 report(RPT_ERR
, "Could not open %s: %s", vcsa_device
, strerror(errno
));
39 unsigned short new_vc_height
;
40 unsigned short new_vc_width
;
43 unsigned char buf
[20];
45 /* Read size and cursor position from /dev/vcsa */
46 lseek(vcsa
, 0, SEEK_SET
);
47 bytes_read
= read(vcsa
, buf
, 4);
48 if (bytes_read
!= 4) {
49 report(RPT_ERR
, "Could not read from %s", vcsa_device
);
52 new_vc_height
= buf
[0];
53 new_vc_width
= buf
[1];
57 /* Screen resize or initial buffer allocation ? */
58 if ((new_vc_width
!= vc_width
) || (new_vc_height
!= vc_height
)) {
59 vc_width
= new_vc_width
;
60 vc_height
= new_vc_height
;
62 if (vc_width
* vc_height
> 0) {
63 vc_buf
= realloc(vc_buf
, vc_width
* vc_height
);
66 report(RPT_ERR
, "malloc failure: %s", strerror(errno
));
69 memset(vc_buf
, ' ', vc_width
* vc_height
);
73 /* Read characters from /dev/cvs0 */
74 lseek(vcs0
, 0, SEEK_SET
);
75 bytes_read
= read(vcs0
, vc_buf
, vc_width
* vc_height
);
76 if (bytes_read
!= vc_width
* vc_height
) {
77 report(RPT_ERR
, "Could not read from %s", vcs_device
);