3
{*****************************************************************************}
5
{*****************************************************************************}
7
const vcs_device:shortint=-1;
9
function try_grab_vcsa:boolean;
11
{*****************************************************************************}
13
{*****************************************************************************}
15
uses baseunix,strings;
17
function try_grab_vcsa_in_path(path:Pchar;len:cardinal):boolean;
19
const grab_vcsa='/grab_vcsa';
20
grab_vcsa_s:array[1..length(grab_vcsa)] of char=grab_vcsa;
28
getmem(p,len+length(grab_vcsa)+1);
30
move(grab_vcsa_s,(p+len)^,length(grab_vcsa));
31
(p+len+length(grab_vcsa))^:=#0;
32
{Check if file exists.}
33
if fpstat(p,pstat)<>0 then
35
try_grab_vcsa_in_path:=false;
42
halt(255); {fpexec must have failed...}
44
fpwaitpid(child,status,0);
45
try_grab_vcsa_in_path:=status=0; {Return true if success.}
50
function try_grab_vcsa:boolean;
52
{If we cannot open /dev/vcsa0-31 it usually because we do not have
53
permission. At login the owner of the tty you login is set to yourself.
55
This is not done for vcsa, which is kinda strange as vcsa is revoke from
56
you when you log out. We try to call a setuid root helper which chowns
57
the vcsa device so we can get access to the screen buffer...}
63
path:=fpgetenv('PATH');
69
if try_grab_vcsa_in_path(path,p-path) then
77
if try_grab_vcsa_in_path(path,strlen(path)) then
82
procedure detect_linuxvcs;
86
pid,ppid,dummy:integer;
91
{Extremely aggressive VCSA detection. Works even through Midnight
92
Commander. Idea from the C++ Turbo Vision project, credits go
93
to Martynas Kunigelis <algikun@santaka.sc-uni.ktu.lt>.}
97
assign(f,'/proc/'+s+'/stat');
115
if device and $ffffffc0=$00000400 then {/dev/tty*}
117
vcs_device:=device and $3f;
120
until (device=0) {Not attached to a terminal, i.e. an xterm.}
126
{Put in procedure because there are quite a bit of variables which are made