termiosproc.inc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. {
  2. This file is part of the Free Pascal run time library.
  3. (c) 2000-2003 by Marco van de Voort
  4. member of the Free Pascal development team.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. Termios implementation for FreeBSD
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY;without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. }
  12. {******************************************************************************
  13. IOCtl and Termios calls
  14. ******************************************************************************}
  15. Procedure CFMakeRaw(var tios:TermIOS);
  16. begin
  17. with tios do
  18. begin
  19. c_iflag:=c_iflag and (not (IMAXBEL or IXOFF or INPCK or BRKINT or
  20. PARMRK or ISTRIP or INLCR or IGNCR or ICRNL or IXON or
  21. IGNPAR));
  22. c_iflag:=c_iflag OR IGNBRK;
  23. c_oflag:=c_oflag and (not OPOST);
  24. c_lflag:=c_lflag and (not (ECHO or ECHOE or ECHOK or ECHONL or ICANON or
  25. ISIG or IEXTEN or NOFLSH or TOSTOP or PENDIN));
  26. c_cflag:=(c_cflag and (not (CSIZE or PARENB))) or (CS8 OR cread);
  27. c_cc[VMIN]:=1;
  28. c_cc[VTIME]:=0;
  29. end;
  30. end;
  31. Function real_tcsendbreak(fd,duration:cint):cint;cdecl;external name 'tcsendbreak';
  32. Function TCSendBreak(fd,duration:cint):cint; {$ifdef VER2_0}inline;{$endif}
  33. begin
  34. TCSendBreak:=real_tcsendbreak(fd,duration);
  35. end;
  36. Function TCSetPGrp(fd,id:cint):cint; {$ifdef VER2_0}inline;{$endif}
  37. begin
  38. TCSetPGrp:=fpIOCtl(fd,TIOCSPGRP,pointer(id));
  39. end;
  40. Function TCGetPGrp(fd:cint;var id:cint):cint; {$ifdef VER2_0}inline;{$endif}
  41. begin
  42. TCGetPGrp:=fpIOCtl(fd,TIOCGPGRP,@id);
  43. end;
  44. Function real_tcdrain(fd:cint):cint;cdecl;external name 'tcdrain';
  45. Function TCDrain(fd:cint) :cint;inline;
  46. begin
  47. TCDrain:=real_tcdrain(fd);
  48. end;
  49. Function real_tcflow(fd,act:cint):cint;cdecl;external name 'tcflow';
  50. Function TCFlow(fd,act:cint) :cint;inline;
  51. begin
  52. TCFlow:=real_tcflow(fd,act);
  53. end;
  54. Function real_tcflush(fd,qsel:cint):cint;cdecl;external name 'tcflush';
  55. Function TCFlush(fd,qsel:cint):cint; inline;
  56. begin
  57. TCFlush:=real_tcflush(fd,qsel);
  58. end;
  59. Function IsATTY (Handle:cint):cint;
  60. {
  61. Check if the filehandle described by 'handle' is a TTY (Terminal)
  62. }
  63. var
  64. t : Termios;
  65. begin
  66. IsAtty:=ord(TCGetAttr(Handle,t) <> -1);
  67. end;
  68. Function IsATTY(var f: text):cint; {$ifdef VER2_0}inline;{$endif}
  69. {
  70. Idem as previous, only now for text variables.
  71. }
  72. begin
  73. IsATTY:=IsaTTY(textrec(f).handle);
  74. end;