Browse Source

* termio unit

marco 22 years ago
parent
commit
0610caa107

+ 5 - 2
ide/fpdebug.pas

@@ -338,7 +338,7 @@ uses
   {$ifdef VER1_0}
   {$ifdef VER1_0}
     Linux,
     Linux,
   {$else}
   {$else}
-    Unix,
+    termio,
   {$endif}
   {$endif}
 {$endif Unix}
 {$endif Unix}
   Systems,Globals,
   Systems,Globals,
@@ -3603,7 +3603,10 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.47  2003-11-17 10:05:51  marco
+  Revision 1.48  2003-11-19 17:11:39  marco
+   * termio unit
+
+  Revision 1.47  2003/11/17 10:05:51  marco
    * threads for FreeBSD. Not working tho
    * threads for FreeBSD. Not working tho
 
 
   Revision 1.46  2003/03/30 12:12:12  armin
   Revision 1.46  2003/03/30 12:12:12  armin

+ 6 - 3
ide/fpusrscr.pas

@@ -27,7 +27,7 @@ uses
     linux,
     linux,
   {$else}
   {$else}
     baseunix,
     baseunix,
-    unix,
+    termio,
   {$endif}
   {$endif}
 {$endif}
 {$endif}
   video,Objects;
   video,Objects;
@@ -783,7 +783,7 @@ begin
             '0'..'9' :
             '0'..'9' :
               begin { running Linux on native console or native-emulation }
               begin { running Linux on native console or native-emulation }
                 FName:='/dev/vcsa' + ThisTTY[9];
                 FName:='/dev/vcsa' + ThisTTY[9];
-                TTYFd:={$ifdef ver1_0}fdOpen{$else}fpOpen{$endif}(FName, &666, Open_RdWr); { open console }
+                TTYFd:={$ifdef ver1_0}fdOpen{$else}fpOpen{$endif}(FName, &666, O_RdWr); { open console }
                 If TTYFd <>-1 Then
                 If TTYFd <>-1 Then
                   Console:=ttyLinux;
                   Console:=ttyLinux;
               end;
               end;
@@ -1441,7 +1441,10 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.30  2003-11-17 10:05:51  marco
+  Revision 1.31  2003-11-19 17:11:40  marco
+   * termio unit
+
+  Revision 1.30  2003/11/17 10:05:51  marco
    * threads for FreeBSD. Not working tho
    * threads for FreeBSD. Not working tho
 
 
   Revision 1.29  2003/11/14 21:52:58  marco
   Revision 1.29  2003/11/14 21:52:58  marco

+ 5 - 2
ide/wconsole.pas

@@ -22,7 +22,7 @@ interface
 {$Ifdef ver1_0}
 {$Ifdef ver1_0}
      linux;
      linux;
 {$else}
 {$else}
-     Unix;
+     termio;
 {$endif}
 {$endif}
 {$endif UNIX}
 {$endif UNIX}
 
 
@@ -80,7 +80,10 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.5  2002-10-12 19:42:01  hajny
+  Revision 1.6  2003-11-19 17:11:40  marco
+   * termio unit
+
+  Revision 1.5  2002/10/12 19:42:01  hajny
     + OS/2 support
     + OS/2 support
 
 
   Revision 1.4  2002/09/07 15:40:48  peter
   Revision 1.4  2002/09/07 15:40:48  peter

+ 5 - 2
packages/extra/ncurses/ncrt.pp

@@ -30,7 +30,7 @@ Uses
     linux,
     linux,
   {$else}
   {$else}
     baseunix,
     baseunix,
-    unix,
+    termio,
   {$endif}
   {$endif}
 {$endif}
 {$endif}
   ncurses;
   ncurses;
@@ -47,7 +47,10 @@ Begin
 End. { of Unit nCrt }
 End. { of Unit nCrt }
 {
 {
   $Log$
   $Log$
-  Revision 1.4  2003-09-27 12:19:20  peter
+  Revision 1.5  2003-11-19 17:11:40  marco
+   * termio unit
+
+  Revision 1.4  2003/09/27 12:19:20  peter
     * fixed for unix
     * fixed for unix
 
 
   Revision 1.3  2002/09/07 15:43:01  peter
   Revision 1.3  2002/09/07 15:43:01  peter

+ 5 - 2
packages/extra/ncurses/ocrt.pp

@@ -154,7 +154,7 @@ Uses
     linux,
     linux,
   {$else}
   {$else}
     baseunix,
     baseunix,
-    unix,
+    termio,
   {$endif}
   {$endif}
 {$endif}
 {$endif}
   ncurses,panel,menu;
   ncurses,panel,menu;
@@ -3272,7 +3272,10 @@ End. { of Unit oCrt }
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.3  2003-09-27 12:19:20  peter
+  Revision 1.4  2003-11-19 17:11:40  marco
+   * termio unit
+
+  Revision 1.3  2003/09/27 12:19:20  peter
     * fixed for unix
     * fixed for unix
 
 
   Revision 1.2  2002/09/07 15:43:01  peter
   Revision 1.2  2002/09/07 15:43:01  peter

+ 16 - 1
rtl/bsd/bunxtype.inc

@@ -190,6 +190,18 @@ CONST
     WUNTRACED =          2;     { report status of stopped children }
     WUNTRACED =          2;     { report status of stopped children }
 
 
 
 
+  { For File control mechanism }
+  F_GetFd  = 1;
+  F_SetFd  = 2;
+  F_GetFl  = 3;
+  F_SetFl  = 4;
+  F_GetLk  = 5;
+  F_SetLk  = 6;
+  F_SetLkW = 7;
+  F_SetOwn = 8;
+  F_GetOwn = 9;
+
+
 
 
     {*************************************************************************}
     {*************************************************************************}
     {                               SIGNALS                                   }
     {                               SIGNALS                                   }
@@ -202,7 +214,10 @@ CONST
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.4  2003-09-14 20:15:01  marco
+  Revision 1.5  2003-11-19 17:11:40  marco
+   * termio unit
+
+  Revision 1.4  2003/09/14 20:15:01  marco
    * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
    * Unix reform stage two. Remove all calls from Unix that exist in Baseunix.
 
 
   Revision 1.3  2003/08/21 22:23:34  olle
   Revision 1.3  2003/08/21 22:23:34  olle

+ 8 - 3
rtl/bsd/sysctl.pp

@@ -81,13 +81,15 @@ function FPsysctlnametomib (Name: pchar; mibp:plongint;sizep:psize_t):cint;
 
 
 Implementation
 Implementation
 
 
+Uses Syscall;
+
 {temporarily}
 {temporarily}
 {$ifdef FreeBSD}
 {$ifdef FreeBSD}
 CONST  syscall_nr___sysctl                    = 202;
 CONST  syscall_nr___sysctl                    = 202;
 {$endif}
 {$endif}
 
 
-{$I sysnr.inc}
-{$I syscallh.inc}
+{I sysnr.inc}
+{I syscallh.inc}
 
 
 function FPsysctl (Name: pchar; namelen:cuint; oldp:pointer;oldlenp:psize_t; newp:pointer;newlen:size_t):cint;
 function FPsysctl (Name: pchar; namelen:cuint; oldp:pointer;oldlenp:psize_t; newp:pointer;newlen:size_t):cint;
 
 
@@ -138,7 +140,10 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.4  2003-01-05 19:01:28  marco
+  Revision 1.5  2003-11-19 17:11:40  marco
+   * termio unit
+
+  Revision 1.4  2003/01/05 19:01:28  marco
    * FreeBSD compiles now with baseunix mods.
    * FreeBSD compiles now with baseunix mods.
 
 
   Revision 1.3  2002/09/07 16:01:17  peter
   Revision 1.3  2002/09/07 16:01:17  peter

+ 2 - 2
rtl/freebsd/Makefile

@@ -1,5 +1,5 @@
 #
 #
-# Don't edit, this file is generated by FPCMake Version 1.1 [2003/11/18]
+# Don't edit, this file is generated by FPCMake Version 1.1 [2003/11/19]
 #
 #
 default: all
 default: all
 MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx netware openbsd wdosx palmos macos darwin emx watcom
 MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx netware openbsd wdosx palmos macos darwin emx watcom
@@ -231,7 +231,7 @@ GRAPHDIR=$(INC)/graph
 ifndef USELIBGGI
 ifndef USELIBGGI
 USELIBGGI=NO
 USELIBGGI=NO
 endif
 endif
-override TARGET_UNITS+=$(SYSTEMUNIT) objpas strings syscall baseunix unixutil unix initc  dos dl crt objects printer sysutils typinfo systhrds classes math varutils cpu mmx charset ucomplex getopts heaptrc lineinfo errors sockets gpm ipc terminfo video mouse keyboard console serial variants types sysctl
+override TARGET_UNITS+=$(SYSTEMUNIT) objpas strings syscall baseunix unixutil unix initc  dos dl termio objects printer sysutils typinfo systhrds classes math varutils cpu mmx charset ucomplex crt getopts heaptrc lineinfo errors sockets gpm ipc terminfo video mouse keyboard console serial variants types sysctl
 override TARGET_LOADERS+=prt0 cprt0 gprt0
 override TARGET_LOADERS+=prt0 cprt0 gprt0
 override TARGET_RSTS+=math varutils typinfo classes variants
 override TARGET_RSTS+=math varutils typinfo classes variants
 override INSTALL_FPCPACKAGE=y y
 override INSTALL_FPCPACKAGE=y y

+ 2 - 2
rtl/freebsd/Makefile.fpc

@@ -12,9 +12,9 @@ fpcpackage=y
 loaders=prt0 cprt0 gprt0
 loaders=prt0 cprt0 gprt0
 units=$(SYSTEMUNIT) objpas strings syscall baseunix unixutil \
 units=$(SYSTEMUNIT) objpas strings syscall baseunix unixutil \
       unix initc  \
       unix initc  \
-      dos dl crt objects printer \
+      dos dl termio objects printer \
       sysutils typinfo systhrds classes math varutils \
       sysutils typinfo systhrds classes math varutils \
-      cpu mmx charset ucomplex getopts heaptrc lineinfo \
+      cpu mmx charset ucomplex crt getopts heaptrc lineinfo \
       errors sockets gpm ipc terminfo \
       errors sockets gpm ipc terminfo \
       video mouse keyboard console serial variants types sysctl
       video mouse keyboard console serial variants types sysctl
 rsts=math varutils typinfo classes variants
 rsts=math varutils typinfo classes variants

+ 1 - 1
rtl/freebsd/console.pp

@@ -1821,7 +1821,7 @@ function physicalconsole(fd:longint) : boolean;
 
 
 IMPLEMENTATION
 IMPLEMENTATION
 
 
-Uses BaseUnix,Unix;
+Uses BaseUnix,termio;
 
 
 function physicalconsole(fd:longint) : boolean;
 function physicalconsole(fd:longint) : boolean;
 
 

+ 6 - 3
rtl/freebsd/unixsysc.inc

@@ -75,10 +75,10 @@ begin
  do_syscall(syscall_nr_gettimeofday,longint(@tv),longint(@tz));
  do_syscall(syscall_nr_gettimeofday,longint(@tv),longint(@tz));
 end;
 end;
 }
 }
-Function  fdFlush (fd : cint) : cint;
+Function  fsync (fd : cint) : cint;
 
 
 begin
 begin
-  fdflush:=do_syscall(syscall_nr_fsync,fd);
+  fsync:=do_syscall(syscall_nr_fsync,fd);
 end;
 end;
 
 
 Function  Flock (fd,mode : longint) : cint;
 Function  Flock (fd,mode : longint) : cint;
@@ -246,7 +246,10 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.15  2003-11-19 10:12:02  marco
+  Revision 1.16  2003-11-19 17:11:40  marco
+   * termio unit
+
+  Revision 1.15  2003/11/19 10:12:02  marco
    * more cleanups
    * more cleanups
 
 
   Revision 1.14  2003/11/17 10:05:51  marco
   Revision 1.14  2003/11/17 10:05:51  marco

+ 8 - 5
rtl/unix/crt.pp

@@ -111,7 +111,7 @@ procedure CursorOff;
 
 
 Implementation
 Implementation
 
 
-uses BaseUnix ,unix;
+uses BaseUnix ,unix, termio;
 
 
 {
 {
   The definitions of TextRec and FileRec are in separate files.
   The definitions of TextRec and FileRec are in separate files.
@@ -1509,10 +1509,10 @@ end;
 ******************************************************************************}
 ******************************************************************************}
 
 
 var
 var
-  OldIO : Unix.TermIos;
+  OldIO : termio.TermIos;
   inputRaw, outputRaw: boolean;
   inputRaw, outputRaw: boolean;
 
 
-procedure saveRawSettings(const tio: Unix.termios);
+procedure saveRawSettings(const tio: termio.termios);
 Begin
 Begin
   with tio do
   with tio do
    begin
    begin
@@ -1527,7 +1527,7 @@ Begin
    end;
    end;
 end;
 end;
 
 
-procedure restoreRawSettings(tio: Unix.termios);
+procedure restoreRawSettings(tio: termio.termios);
 begin
 begin
   with tio do
   with tio do
     begin
     begin
@@ -1681,7 +1681,10 @@ Finalization
 End.
 End.
 {
 {
   $Log$
   $Log$
-  Revision 1.14  2003-11-17 10:05:51  marco
+  Revision 1.15  2003-11-19 17:11:40  marco
+   * termio unit
+
+  Revision 1.14  2003/11/17 10:05:51  marco
    * threads for FreeBSD. Not working tho
    * threads for FreeBSD. Not working tho
 
 
   Revision 1.13  2003/09/16 20:52:24  marco
   Revision 1.13  2003/09/16 20:52:24  marco

+ 5 - 2
rtl/unix/keyboard.pp

@@ -42,7 +42,7 @@ uses
   Strings,
   Strings,
   TermInfo,
   TermInfo,
 {$endif NotUseTree}
 {$endif NotUseTree}
-  Unix,baseUnix;
+  termio,baseUnix;
 
 
 {$i keyboard.inc}
 {$i keyboard.inc}
 
 
@@ -1532,7 +1532,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.16  2003-11-17 10:05:51  marco
+  Revision 1.17  2003-11-19 17:11:40  marco
+   * termio unit
+
+  Revision 1.16  2003/11/17 10:05:51  marco
    * threads for FreeBSD. Not working tho
    * threads for FreeBSD. Not working tho
 
 
   Revision 1.15  2003/09/16 16:13:56  marco
   Revision 1.15  2003/09/16 16:13:56  marco

+ 6 - 3
rtl/unix/serial.pp

@@ -10,7 +10,7 @@ unit Serial;
 
 
 interface
 interface
 
 
-uses BaseUnix,Unix;
+uses BaseUnix,termio,unix;
 
 
 type
 type
 
 
@@ -70,7 +70,7 @@ implementation
 
 
 function SerOpen(const DeviceName: String): TSerialHandle;
 function SerOpen(const DeviceName: String): TSerialHandle;
 begin
 begin
-  Result := fpopen(DeviceName, OPEN_RDWR or OPEN_NOCTTY);
+  Result := fpopen(DeviceName, O_RDWR or O_NOCTTY);
 end;
 end;
 
 
 procedure SerClose(Handle: TSerialHandle);
 procedure SerClose(Handle: TSerialHandle);
@@ -215,7 +215,10 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.9  2003-11-19 10:54:32  marco
+  Revision 1.10  2003-11-19 17:11:40  marco
+   * termio unit
+
+  Revision 1.9  2003/11/19 10:54:32  marco
    * some simple restructures
    * some simple restructures
 
 
   Revision 1.8  2003/09/14 20:15:01  marco
   Revision 1.8  2003/09/14 20:15:01  marco

+ 5 - 263
rtl/unix/unix.pp

@@ -24,7 +24,7 @@ Uses UnixUtil,BaseUnix;
 
 
 {Get error numbers, some more signal definitions and other OS dependant
 {Get error numbers, some more signal definitions and other OS dependant
  types (that are not POSIX) }
  types (that are not POSIX) }
-{$i errno.inc}
+{i errno.inc}
 {$I signal.inc}
 {$I signal.inc}
 {$i ostypes.inc}
 {$i ostypes.inc}
 
 
@@ -51,13 +51,6 @@ Type
     next : pglob;
     next : pglob;
   end;
   end;
 
 
-{********************
-   IOCtl(TermIOS)
-********************}
-
-{Is too freebsd/Linux specific}
-
-{$I termios.inc}
 
 
 {******************************************************************************
 {******************************************************************************
                             Procedure/Functions
                             Procedure/Functions
@@ -156,25 +149,6 @@ Function  GetDomainName:String;
 Function  GetHostName:String;
 Function  GetHostName:String;
 {$endif}
 {$endif}
 
 
-{**************************
-  IOCtl/Termios Functions
-***************************}
-
-Function  TCGetAttr (fd:cint;var tios:TermIOS):cint;
-Function  TCSetAttr (fd:cint;OptAct:cint;const tios:TermIOS):cint;
-Procedure CFSetISpeed (var tios:TermIOS;speed:Cardinal);
-Procedure CFSetOSpeed (var tios:TermIOS;speed:Cardinal);
-Procedure CFMakeRaw   (var tios:TermIOS);
-Function  TCSendBreak (fd,duration:cint):cint;
-Function  TCSetPGrp   (fd,id:cint)  :cint;
-Function  TCGetPGrp   (fd:cint;var id:cint):cint;
-Function  TCFlush     (fd,qsel:cint):cint;
-Function  TCDrain     (fd:cint)     :cint;
-Function  TCFlow      (fd,act:cint) :cint;
-Function  IsATTY      (Handle:cint) :cint;
-Function  IsATTY      (var f:text)  :cint;
-function  TTYname     (Handle:cint):string;
-function  TTYname     (var F:Text) :string;
 
 
 {**************************
 {**************************
      Memory functions
      Memory functions
@@ -1230,241 +1204,6 @@ begin
   fpKill(fpGetPid,Sig);
   fpKill(fpGetPid,Sig);
 end;
 end;
 
 
-{******************************************************************************
-                         IOCtl and Termios calls
-******************************************************************************}
-
-Function TCGetAttr(fd:cint;var tios:TermIOS):cint;
-begin
- {$ifndef BSD}
-  TCGetAttr:=fpIOCtl(fd,TCGETS,@tios);
- {$else}
-  TCGETAttr:=fpIoCtl(Fd,TIOCGETA,@tios);
- {$endif}
-end;
-
-
-Function TCSetAttr(fd:cint;OptAct:cint;const tios:TermIOS):cint;
-var
-  nr:cint;
-begin
- {$ifndef BSD}
-  case OptAct of
-   TCSANOW   : nr:=TCSETS;
-   TCSADRAIN : nr:=TCSETSW;
-   TCSAFLUSH : nr:=TCSETSF;
- {$else}
-  case OptAct of
-   TCSANOW   : nr:=TIOCSETA;
-   TCSADRAIN : nr:=TIOCSETAW;
-   TCSAFLUSH : nr:=TIOCSETAF;
-  {$endif}
-  else
-   begin
-     fpsetErrNo(ESysEINVAL);
-     TCSetAttr:=-1;
-     exit;
-   end;
-  end;
-  TCSetAttr:=fpIOCtl(fd,nr,@Tios);
-end;
-
-
-Procedure CFSetISpeed(var tios:TermIOS;speed:Cardinal);
-begin
- {$ifndef BSD}
-  tios.c_cflag:=(tios.c_cflag and (not CBAUD)) or speed;
- {$else}
-  tios.c_ispeed:=speed; {Probably the Bxxxx speed constants}
- {$endif}
-end;
-
-
-Procedure CFSetOSpeed(var tios:TermIOS;speed:Cardinal);
-begin
-  {$ifndef BSD}
-   CFSetISpeed(tios,speed);
-  {$else}
-   tios.c_ospeed:=speed;
-  {$endif}
-end;
-
-
-
-Procedure CFMakeRaw(var tios:TermIOS);
-begin
- {$ifndef BSD}
-  with tios do
-   begin
-     c_iflag:=c_iflag and (not (IGNBRK or BRKINT or PARMRK or ISTRIP or
-                                INLCR or IGNCR or ICRNL or IXON));
-     c_oflag:=c_oflag and (not OPOST);
-     c_lflag:=c_lflag and (not (ECHO or ECHONL or ICANON or ISIG or IEXTEN));
-     c_cflag:=(c_cflag and (not (CSIZE or PARENB))) or CS8;
-   end;
- {$else}
-  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;
- {$endif}
-end;
-
-Function TCSendBreak(fd,duration:cint):cint;
-begin
-  {$ifndef BSD}
-  TCSendBreak:=fpIOCtl(fd,TCSBRK,pointer(duration));
-  {$else}
-  TCSendBreak:=fpIOCtl(fd,TIOCSBRK,0);
-  {$endif}
-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
- {$ifndef BSD}
-  TCDrain:=fpIOCtl(fd,TCSBRK,pointer(1));
- {$else}
-  TCDrain:=fpIOCtl(fd,TIOCDRAIN,0); {Should set timeout to 1 first?}
- {$endif}
-end;
-
-
-Function TCFlow(fd,act:cint):cint;
-begin
-  {$ifndef BSD}
-   TCFlow:=fpIOCtl(fd,TCXONC,pointer(act));
-  {$else}
-    case act OF
-     TCOOFF :  TCFlow:=fpIoctl(fd,TIOCSTOP,0);
-     TCOOn  :  TCFlow:=fpIOctl(Fd,TIOCStart,0);
-     TCIOFF :  {N/I}
-    end;
-  {$endif}
-end;
-
-Function TCFlush(fd,qsel:cint):cint;
-begin
- {$ifndef BSD}
-  TCFlush:=fpIOCtl(fd,TCFLSH,pointer(qsel));
- {$else}
-  TCFlush:=fpIOCtl(fd,TIOCFLUSH,pointer(qsel));
- {$endif}
-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;
-
-
-function TTYName(Handle:cint):string;
-{
-  Return the name of the current tty described by handle f.
-  returns empty string in case of an error.
-}
-var
-  mydev     : dev_t;
-  myino     : ino_t;
-  st        : stat;
-
-  function mysearch(n:string): boolean;
-  {searches recursively for the device in the directory given by n,
-    returns true if found and sets the name of the device in ttyname}
-  var dirstream : pdir;
-      d         : pdirent;
-      name      : string;
-      st        : stat;
-  begin
-    dirstream:=fpopendir(n);
-    if (dirstream=nil) then
-     exit(false);
-    d:=fpReaddir(dirstream^);
-    while (d<>nil) do
-     begin
-       name:=n+'/'+strpas(@(d^.d_name));
-     //  fpstat(name,st);
-       if fpstat(name,st)=0 then
-        begin
-          if (fpS_ISDIR(st.st_mode)) and  { if it is a directory }
-             (strpas(@(d^.d_name))<>'.') and    { but not ., .. and fd subdirs }
-             (strpas(@(d^.d_name))<>'..') and
-             (strpas(@(d^.d_name))<>'') and
-             (strpas(@(d^.d_name))<>'fd') then
-           begin                      {we found a directory, search inside it}
-             if mysearch(name) then
-              begin                 {the device is here}
-                fpclosedir(dirstream^);  {then don't continue searching}
-                mysearch:=true;
-                exit;
-              end;
-           end
-          else if (ino_t(d^.d_fileno)=myino) and (st.st_dev=mydev) then
-           begin
-             fpclosedir(dirstream^);
-             ttyname:=name;
-             mysearch:=true;
-             exit;
-           end;
-        end;
-       d:=fpReaddir(dirstream^);
-     end;
-    fpclosedir(dirstream^);
-    mysearch:=false;
-  end;
-
-begin
-  TTYName:='';
-  if (fpfstat(handle,st)=-1) and (isatty (handle)<>-1) then
-   exit;
-  mydev:=st.st_dev;
-  myino:=st.st_ino;
-  mysearch('/dev');
-end;
-
-
-function TTYName(var F:Text):string;
-{
-  Idem as previous, only now for text variables;
-}
-begin
-  TTYName:=TTYName(textrec(f).handle);
-end;
-
 
 
 {******************************************************************************
 {******************************************************************************
                              Utility calls
                              Utility calls
@@ -1641,7 +1380,10 @@ End.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.50  2003-11-19 10:54:32  marco
+  Revision 1.51  2003-11-19 17:11:40  marco
+   * termio unit
+
+  Revision 1.50  2003/11/19 10:54:32  marco
    * some simple restructures
    * some simple restructures
 
 
   Revision 1.49  2003/11/17 11:28:08  marco
   Revision 1.49  2003/11/17 11:28:08  marco

+ 10 - 7
rtl/unix/video.pp

@@ -23,7 +23,7 @@ interface
 implementation
 implementation
 
 
 uses
 uses
-  BaseUnix, Unix, Strings, TermInfo;
+  BaseUnix, Strings, TermInfo, termio;
 
 
 {$i video.inc}
 {$i video.inc}
 
 
@@ -534,10 +534,10 @@ begin
 end;
 end;
 
 
 var
 var
-  InitialVideoTio, preInitVideoTio, postInitVideoTio: Unix.termios;
+  InitialVideoTio, preInitVideoTio, postInitVideoTio: termio.termios;
   inputRaw, outputRaw: boolean;
   inputRaw, outputRaw: boolean;
 
 
-procedure saveRawSettings(const tio: Unix.termios);
+procedure saveRawSettings(const tio: termio.termios);
 Begin
 Begin
   with tio do
   with tio do
    begin
    begin
@@ -552,7 +552,7 @@ Begin
    end;
    end;
 end;
 end;
 
 
-procedure restoreRawSettings(tio: Unix.termios);
+procedure restoreRawSettings(tio: termio.termios);
 begin
 begin
   with tio do
   with tio do
     begin
     begin
@@ -596,7 +596,7 @@ end;
 
 
 procedure prepareDoneVideo;
 procedure prepareDoneVideo;
 var
 var
-  tio: Unix.termios;
+  tio: termio.termios;
 begin
 begin
   TCGetAttr(1,tio);
   TCGetAttr(1,tio);
   saveRawSettings(tio);
   saveRawSettings(tio);
@@ -641,7 +641,7 @@ begin
         Case ThisTTY[9] of
         Case ThisTTY[9] of
          '0'..'9' : begin { running Linux on native console or native-emulation }
          '0'..'9' : begin { running Linux on native console or native-emulation }
                      FName:='/dev/vcsa' + ThisTTY[9];
                      FName:='/dev/vcsa' + ThisTTY[9];
-                     TTYFd:=fpOpen(FName, &666, Open_RdWr); { open console }
+                     TTYFd:=fpOpen(FName, &666, O_RdWr); { open console }
                      IF TTYFd <>-1 Then
                      IF TTYFd <>-1 Then
                        Console:=ttyLinux;
                        Console:=ttyLinux;
                     end;
                     end;
@@ -898,7 +898,10 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.19  2003-11-17 10:05:51  marco
+  Revision 1.20  2003-11-19 17:11:40  marco
+   * termio unit
+
+  Revision 1.19  2003/11/17 10:05:51  marco
    * threads for FreeBSD. Not working tho
    * threads for FreeBSD. Not working tho
 
 
   Revision 1.18  2003/10/26 15:32:25  marco
   Revision 1.18  2003/10/26 15:32:25  marco