termiosproc.inc 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Peter Vreman
  5. member of the Free Pascal development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This file contains the implementation of several termio(s) functions
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. {******************************************************************************
  14. IOCtl and Termios calls
  15. ******************************************************************************}
  16. Function TCGetAttr(fd:cint;var tios:TermIOS):cint; cdecl; external 'c' name 'tcgetattr';
  17. Function TCSetAttr(fd:cint;OptAct:cint;const tios:TermIOS):cint; cdecl; external 'c' name 'tcsetattr';
  18. Procedure CFSetISpeed(var tios:TermIOS;speed:Cardinal); cdecl; external 'c' name 'cfsetispeed';
  19. Procedure CFSetOSpeed(var tios:TermIOS;speed:Cardinal); cdecl; external 'c' name 'cfsetospeed';
  20. Procedure CFMakeRaw(var tios:TermIOS); cdecl; external 'c' name 'cfmakeraw';
  21. Function TCSendBreak(fd,duration:cint):cint;
  22. begin
  23. TCSendBreak:=fpIOCtl(fd,TIOCSBRK,nil);
  24. end;
  25. Function TCSetPGrp(fd,id:cint):cint;
  26. begin
  27. TCSetPGrp:=fpIOCtl(fd,TIOCSPGRP,pointer(id));
  28. end;
  29. Function TCGetPGrp(fd:cint;var id:cint):cint;
  30. begin
  31. TCGetPGrp:=fpIOCtl(fd,TIOCGPGRP,@id);
  32. end;
  33. Function TCDrain(fd:cint):cint;
  34. begin
  35. TCDrain:=fpIOCtl(fd,TIOCDRAIN,nil); {Should set timeout to 1 first?}
  36. end;
  37. Function TCFlow(fd,act:cint):cint;
  38. begin
  39. case act OF
  40. TCOOFF : TCFlow:=fpIoctl(fd,TIOCSTOP,nil);
  41. TCOOn : TCFlow:=fpIOctl(Fd,TIOCStart,nil);
  42. TCIOFF : {N/I}
  43. end;
  44. end;
  45. Function TCFlush(fd,qsel:cint):cint;
  46. begin
  47. TCFlush:=fpIOCtl(fd,TIOCFLUSH,pointer(qsel));
  48. end;
  49. Function IsATTY (Handle:cint):cint;
  50. {
  51. Check if the filehandle described by 'handle' is a TTY (Terminal)
  52. }
  53. var
  54. t : Termios;
  55. begin
  56. IsAtty:=TCGetAttr(Handle,t);
  57. end;
  58. Function IsATTY(var f: text):cint;
  59. {
  60. Idem as previous, only now for text variables.
  61. }
  62. begin
  63. IsATTY:=IsaTTY(textrec(f).handle);
  64. end;
  65. {
  66. $Log$
  67. Revision 1.1 2004-01-04 20:05:38 jonas
  68. * first working version of the Darwin/Mac OS X (for PowerPC) RTL
  69. Several non-essential units are still missing, but make cycle works
  70. Revision 1.2 2003/12/16 19:43:53 marco
  71. * nil <-> 0 changes
  72. Revision 1.1 2003/11/19 17:15:31 marco
  73. * termio new includefile
  74. }