Need help w/ ANSI-sequence "send screen to host"
Chip Rosenthal
chip at chinacat.Unicom.COM
Sat Feb 2 17:02:09 AEST 1991
This seems to get asked every three months. Below is a hack, provided
more as an example rather than a polished utility.
P.S. Yes...it does leave the `dumped' screen rather than the starting
screen selected. If anybody knows how to fix this bug, I'd love to see
the solution.
P.P.S. I haven't even attempted to think through whether this utility
would work on a system with multiple display adapters. My guess is that
it probably wouldn't.
------------------------------------------------------------------------------
>From chip Sun Oct 14 18:48:00 CDT 1990
>Newsgroups: comp.unix.xenix.sco,comp.unix.sysv386
>Subject: Re: Screen Dumps
>Subject: screen dump
># Bourne sheel script to write the screen
># to standard output
I posted a "prtscrn" utility to comp.unix.xenix a few months back for
Herc displays. I hacked on it a bit, and have a version which should run
in all text modes. It's been tested on ODT as well as XENIX.
Usage would be something along the lines of "prtscrn 3 > /tmp/screen.dump"
to save the contents of screen 3 to a file. This is not a clean & polished
program - just a quick hack which does the trick. It works by slurping
in the text directly from the display adapter memory.
--- cut here -----------------------------------------------------------------
#include <stdio.h>
#include <fcntl.h>
#include <sys/machdep.h>
#define USAGE "usage: %s [screen_num]\n"
#define SCREENS 12
struct {
int s_code;
int s_cols;
int s_lines;
} scrtab[] = {
{ M_B40x25, 40, 25 },
{ M_C40x25, 40, 25 },
{ M_B80x25, 80, 25 },
{ M_C80x25, 80, 25 },
{ M_BG320, -1, -1 },
{ M_CG320, -1, -1 },
{ M_BG640, -1, -1 },
{ M_EGAMONO80x25, 80, 25 },
{ M_CG320_D, -1, -1 },
{ M_CG640_E, -1, -1 },
{ M_EGAMONOAPA, -1, -1 },
{ M_CG640x350, -1, -1 },
{ M_ENHMONOAPA2, -1, -1 },
{ M_ENH_CG640, -1, -1 },
{ M_ENH_B40x25, 40, 25 },
{ M_ENH_C40x25, 40, 25 },
{ M_ENH_B80x25, 80, 25 },
{ M_ENH_C80x25, 80, 25 },
{ M_VGA_40x25, 40, 25 },
{ M_VGA_80x25, 80, 25 },
{ M_VGA_M80x25, 80, 25 },
{ M_VGA11, -1, -1 },
{ M_VGA12, -1, -1 },
{ M_VGA13, -1, -1 },
{ M_ENH_B80x43, 80, 43 },
{ M_ENH_C80x43, 80, 43 },
{ M_HGC_P0, -1, -1 },
{ M_HGC_P1, -1, -1 },
{ M_MCA_MODE, -1, -1 },
{ -1, -1, -1 },
};
main(argc,argv)
int argc;
char *argv[];
{
char *disp_mem, scrname[64];
int screen_num, disp_mode, disp_fd, num_cols, num_lines, line, col, i;
switch ( argc ) {
case 1:
screen_num = 0;
strcpy(scrname,"/dev/tty");
break;
case 2:
screen_num = atoi(argv[1]);
if ( screen_num < 1 || screen_num > SCREENS ) {
fprintf(stderr,"%s: bad screen number specified\n",argv[0]);
exit(1);
}
sprintf(scrname,"/dev/tty%02d",screen_num);
fprintf(stderr,"\033[%dz",screen_num-1);
fflush(stderr);
break;
default:
fprintf(stderr,USAGE,argv[0]);
exit(1);
}
if ( (disp_fd=open(scrname,O_RDWR)) < 0 ) {
fprintf(stderr,"%s: could not open '%s'\n",argv[0],scrname);
exit(1);
}
if ( (disp_mode=ioctl(disp_fd,CONS_GET,0)) < 0 ) {
fprintf(stderr,"%s: could not get display type\n",argv[0]);
exit(1);
}
if ( (disp_mem=(char *)ioctl(disp_fd,MAPCONS,0)) == NULL ) {
fprintf(stderr,"%s: could not map display memory\n",argv[0]);
exit(1);
}
for ( i=0 ; scrtab[i].s_code>=0 && scrtab[i].s_code!=disp_mode ; ++i ) ;
num_cols = scrtab[i].s_cols;
num_lines = scrtab[i].s_lines;
if ( num_cols < 0 || num_lines < 0 ) {
fprintf(stderr,"%s: display not in supported text mode\n",argv[0]);
exit(1);
}
for ( line = 0 ; line < num_lines ; ++line ) {
for ( col = 0 ; col < num_cols ; ++col ) {
putchar(*disp_mem);
disp_mem += 2;
}
putchar('\n');
}
exit(0);
}
--- cut here -----------------------------------------------------------------
--
Chip Rosenthal 512-482-8260 | If software look-and-feel can be protected,
Unicom Systems Development | then I'd like to claim a copyright upon
<chip at chinacat.Unicom.COM> | `Memory fault - core dumped'.
More information about the Comp.unix.xenix.sco
mailing list