mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 17:59:27 +02:00
* termio new includefile
This commit is contained in:
parent
0f6af75554
commit
880ba0dc9d
50
rtl/freebsd/termio.pp
Normal file
50
rtl/freebsd/termio.pp
Normal file
@ -0,0 +1,50 @@
|
||||
{
|
||||
$Id$
|
||||
This file is part of the Free Pascal run time library.
|
||||
Copyright (c) 1999-2000 by Peter Vreman
|
||||
member of the Free Pascal development team.
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
This file contains the termios interface.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
**********************************************************************}
|
||||
|
||||
unit termio;
|
||||
|
||||
interface
|
||||
|
||||
Uses BaseUnix; // load base unix typing
|
||||
|
||||
// load types + consts
|
||||
|
||||
{$i termios.inc}
|
||||
|
||||
// load default prototypes from unix dir.
|
||||
|
||||
{$i termiosh.inc}
|
||||
|
||||
implementation
|
||||
|
||||
{$i textrec.inc}
|
||||
|
||||
// load implementation for prototypes from current dir.
|
||||
{$i termiosproc.inc}
|
||||
|
||||
// load ttyname from unix dir.
|
||||
{$i ttyname.inc}
|
||||
|
||||
end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.1 2003-11-19 17:15:31 marco
|
||||
* termio new includefile
|
||||
|
||||
|
||||
}
|
139
rtl/freebsd/termiosproc.inc
Normal file
139
rtl/freebsd/termiosproc.inc
Normal file
@ -0,0 +1,139 @@
|
||||
{
|
||||
$Id$
|
||||
This file is part of the Free Pascal run time library.
|
||||
Copyright (c) 1999-2000 by Peter Vreman
|
||||
member of the Free Pascal development team.
|
||||
|
||||
See the file COPYING.FPC, included in this distribution,
|
||||
for details about the copyright.
|
||||
|
||||
This file contains the implementation of several termio(s) functions
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
**********************************************************************}
|
||||
|
||||
{******************************************************************************
|
||||
IOCtl and Termios calls
|
||||
******************************************************************************}
|
||||
|
||||
Function TCGetAttr(fd:cint;var tios:TermIOS):cint;
|
||||
begin
|
||||
TCGETAttr:=fpIoCtl(Fd,TIOCGETA,@tios);
|
||||
end;
|
||||
|
||||
|
||||
Function TCSetAttr(fd:cint;OptAct:cint;const tios:TermIOS):cint;
|
||||
var
|
||||
nr:cint;
|
||||
begin
|
||||
case OptAct of
|
||||
TCSANOW : nr:=TIOCSETA;
|
||||
TCSADRAIN : nr:=TIOCSETAW;
|
||||
TCSAFLUSH : nr:=TIOCSETAF;
|
||||
else
|
||||
begin
|
||||
fpsetErrNo(ESysEINVAL);
|
||||
TCSetAttr:=-1;
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
TCSetAttr:=fpIOCtl(fd,nr,@Tios);
|
||||
end;
|
||||
|
||||
|
||||
Procedure CFSetISpeed(var tios:TermIOS;speed:Cardinal);
|
||||
begin
|
||||
tios.c_ispeed:=speed; {Probably the Bxxxx speed constants}
|
||||
end;
|
||||
|
||||
|
||||
Procedure CFSetOSpeed(var tios:TermIOS;speed:Cardinal);
|
||||
begin
|
||||
tios.c_ospeed:=speed;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
Procedure CFMakeRaw(var tios:TermIOS);
|
||||
begin
|
||||
with tios do
|
||||
begin
|
||||
c_iflag:=c_iflag and (not (IMAXBEL or IXOFF or INPCK or BRKINT or
|
||||
PARMRK or ISTRIP or INLCR or IGNCR or ICRNL or IXON or
|
||||
IGNPAR));
|
||||
c_iflag:=c_iflag OR IGNBRK;
|
||||
c_oflag:=c_oflag and (not OPOST);
|
||||
c_lflag:=c_lflag and (not (ECHO or ECHOE or ECHOK or ECHONL or ICANON or
|
||||
ISIG or IEXTEN or NOFLSH or TOSTOP or PENDIN));
|
||||
c_cflag:=(c_cflag and (not (CSIZE or PARENB))) or (CS8 OR cread);
|
||||
c_cc[VMIN]:=1;
|
||||
c_cc[VTIME]:=0;
|
||||
end;
|
||||
end;
|
||||
|
||||
Function TCSendBreak(fd,duration:cint):cint;
|
||||
begin
|
||||
TCSendBreak:=fpIOCtl(fd,TIOCSBRK,0);
|
||||
end;
|
||||
|
||||
|
||||
Function TCSetPGrp(fd,id:cint):cint;
|
||||
begin
|
||||
TCSetPGrp:=fpIOCtl(fd,TIOCSPGRP,pointer(id));
|
||||
end;
|
||||
|
||||
|
||||
Function TCGetPGrp(fd:cint;var id:cint):cint;
|
||||
begin
|
||||
TCGetPGrp:=fpIOCtl(fd,TIOCGPGRP,@id);
|
||||
end;
|
||||
|
||||
Function TCDrain(fd:cint):cint;
|
||||
begin
|
||||
TCDrain:=fpIOCtl(fd,TIOCDRAIN,0); {Should set timeout to 1 first?}
|
||||
end;
|
||||
|
||||
|
||||
Function TCFlow(fd,act:cint):cint;
|
||||
begin
|
||||
case act OF
|
||||
TCOOFF : TCFlow:=fpIoctl(fd,TIOCSTOP,0);
|
||||
TCOOn : TCFlow:=fpIOctl(Fd,TIOCStart,0);
|
||||
TCIOFF : {N/I}
|
||||
end;
|
||||
end;
|
||||
|
||||
Function TCFlush(fd,qsel:cint):cint;
|
||||
begin
|
||||
TCFlush:=fpIOCtl(fd,TIOCFLUSH,pointer(qsel));
|
||||
end;
|
||||
|
||||
Function IsATTY (Handle:cint):cint;
|
||||
{
|
||||
Check if the filehandle described by 'handle' is a TTY (Terminal)
|
||||
}
|
||||
var
|
||||
t : Termios;
|
||||
begin
|
||||
IsAtty:=TCGetAttr(Handle,t);
|
||||
end;
|
||||
|
||||
|
||||
Function IsATTY(var f: text):cint;
|
||||
{
|
||||
Idem as previous, only now for text variables.
|
||||
}
|
||||
begin
|
||||
IsATTY:=IsaTTY(textrec(f).handle);
|
||||
end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.1 2003-11-19 17:15:31 marco
|
||||
* termio new includefile
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user