|
@@ -29,6 +29,9 @@ Interface
|
|
{$ifdef Go32v2}
|
|
{$ifdef Go32v2}
|
|
{$define implemented}
|
|
{$define implemented}
|
|
{$endif}
|
|
{$endif}
|
|
|
|
+{$ifdef Win32}
|
|
|
|
+{$define implemented}
|
|
|
|
+{$endif}
|
|
{$ifdef linux}
|
|
{$ifdef linux}
|
|
{$define implemented}
|
|
{$define implemented}
|
|
{$endif}
|
|
{$endif}
|
|
@@ -69,6 +72,9 @@ Uses
|
|
{$ifdef go32v2}
|
|
{$ifdef go32v2}
|
|
go32,
|
|
go32,
|
|
{$endif go32v2}
|
|
{$endif go32v2}
|
|
|
|
+{$ifdef win32}
|
|
|
|
+ windows,
|
|
|
|
+{$endif win32}
|
|
{$ifdef linux}
|
|
{$ifdef linux}
|
|
linux,
|
|
linux,
|
|
{$endif linux}
|
|
{$endif linux}
|
|
@@ -89,11 +95,13 @@ var
|
|
|
|
|
|
{$ifdef TP}
|
|
{$ifdef TP}
|
|
|
|
|
|
|
|
+{$ifndef win32}
|
|
const
|
|
const
|
|
UnusedHandle = -1;
|
|
UnusedHandle = -1;
|
|
StdInputHandle = 0;
|
|
StdInputHandle = 0;
|
|
StdOutputHandle = 1;
|
|
StdOutputHandle = 1;
|
|
StdErrorHandle = 2;
|
|
StdErrorHandle = 2;
|
|
|
|
+{$endif win32}
|
|
|
|
|
|
Type
|
|
Type
|
|
PtrRec = packed record
|
|
PtrRec = packed record
|
|
@@ -165,6 +173,14 @@ end;
|
|
|
|
|
|
{$endif def go32v2}
|
|
{$endif def go32v2}
|
|
|
|
|
|
|
|
+{$ifdef win32}
|
|
|
|
+Function FdClose (Handle : Longint) : boolean;
|
|
|
|
+begin
|
|
|
|
+ { Do we need this ?? }
|
|
|
|
+ FdClose:=true;
|
|
|
|
+end;
|
|
|
|
+{$endif}
|
|
|
|
+
|
|
{$ifdef TP}
|
|
{$ifdef TP}
|
|
Function FdClose (Handle : Longint) : boolean;
|
|
Function FdClose (Handle : Longint) : boolean;
|
|
begin
|
|
begin
|
|
@@ -209,8 +225,12 @@ function ChangeRedirOut(Const Redir : String; AppendToFile : Boolean) : Boolean;
|
|
ChangeRedirOut:=True;
|
|
ChangeRedirOut:=True;
|
|
OutRedirDisabled:=False;
|
|
OutRedirDisabled:=False;
|
|
{$else}
|
|
{$else}
|
|
|
|
+{$ifdef win32}
|
|
|
|
+ if SetStdHandle(Std_Output_Handle,FileRec(FOUT^).Handle) then
|
|
|
|
+{$else not win32}
|
|
if dup(StdOutputHandle,TempHOut) and
|
|
if dup(StdOutputHandle,TempHOut) and
|
|
dup2(FileRec(FOUT^).Handle,StdOutputHandle) then
|
|
dup2(FileRec(FOUT^).Handle,StdOutputHandle) then
|
|
|
|
+{$endif not win32}
|
|
begin
|
|
begin
|
|
ChangeRedirOut:=True;
|
|
ChangeRedirOut:=True;
|
|
OutRedirDisabled:=False;
|
|
OutRedirDisabled:=False;
|
|
@@ -236,8 +256,12 @@ function ChangeRedirIn(Const Redir : String) : Boolean;
|
|
ChangeRedirIn:=True;
|
|
ChangeRedirIn:=True;
|
|
InRedirDisabled:=False;
|
|
InRedirDisabled:=False;
|
|
{$else}
|
|
{$else}
|
|
|
|
+{$ifdef win32}
|
|
|
|
+ if SetStdHandle(Std_Input_Handle,FileRec(FIN^).Handle) then
|
|
|
|
+{$else not win32}
|
|
if dup(StdInputHandle,TempHIn) and
|
|
if dup(StdInputHandle,TempHIn) and
|
|
dup2(FileRec(FIN^).Handle,StdInputHandle) then
|
|
dup2(FileRec(FIN^).Handle,StdInputHandle) then
|
|
|
|
+{$endif not win32}
|
|
begin
|
|
begin
|
|
ChangeRedirIn:=True;
|
|
ChangeRedirIn:=True;
|
|
InRedirDisabled:=False;
|
|
InRedirDisabled:=False;
|
|
@@ -267,8 +291,12 @@ function ChangeRedirError(Const Redir : String; AppendToFile : Boolean) : Boolea
|
|
ChangeRedirError:=True;
|
|
ChangeRedirError:=True;
|
|
ErrorRedirDisabled:=False;
|
|
ErrorRedirDisabled:=False;
|
|
{$else}
|
|
{$else}
|
|
|
|
+{$ifdef win32}
|
|
|
|
+ if SetStdHandle(Std_Error_Handle,FileRec(FERR^).Handle) then
|
|
|
|
+{$else not win32}
|
|
if dup(StdErrorHandle,TempHError) and
|
|
if dup(StdErrorHandle,TempHError) and
|
|
dup2(FileRec(FERR^).Handle,StdErrorHandle) then
|
|
dup2(FileRec(FERR^).Handle,StdErrorHandle) then
|
|
|
|
+{$endif not win32}
|
|
begin
|
|
begin
|
|
ChangeRedirError:=True;
|
|
ChangeRedirError:=True;
|
|
ErrorRedirDisabled:=False;
|
|
ErrorRedirDisabled:=False;
|
|
@@ -320,8 +348,12 @@ end;
|
|
Handles^[StdOutputHandle]:=OldHandleOut;
|
|
Handles^[StdOutputHandle]:=OldHandleOut;
|
|
OldHandleOut:=StdOutputHandle;
|
|
OldHandleOut:=StdOutputHandle;
|
|
{$else}
|
|
{$else}
|
|
|
|
+{$ifdef win32}
|
|
|
|
+ SetStdHandle(Std_Output_Handle,StdOutputHandle);
|
|
|
|
+{$else not win32}
|
|
dup2(TempHOut,StdOutputHandle);
|
|
dup2(TempHOut,StdOutputHandle);
|
|
-{$endif}
|
|
|
|
|
|
+{$endif not win32}
|
|
|
|
+{$endif FPC}
|
|
Close (FOUT^);
|
|
Close (FOUT^);
|
|
fdClose(TempHOut);
|
|
fdClose(TempHOut);
|
|
RedirChangedOut:=false;
|
|
RedirChangedOut:=false;
|
|
@@ -337,7 +369,11 @@ end;
|
|
Handles^[StdInputHandle]:=OldHandleIn;
|
|
Handles^[StdInputHandle]:=OldHandleIn;
|
|
OldHandleIn:=StdInputHandle;
|
|
OldHandleIn:=StdInputHandle;
|
|
{$else}
|
|
{$else}
|
|
|
|
+{$ifdef win32}
|
|
|
|
+ SetStdHandle(Std_Input_Handle,StdInputHandle);
|
|
|
|
+{$else not win32}
|
|
dup2(TempHIn,StdInputHandle);
|
|
dup2(TempHIn,StdInputHandle);
|
|
|
|
+{$endif not win32}
|
|
{$endif}
|
|
{$endif}
|
|
Close (FIn^);
|
|
Close (FIn^);
|
|
fdClose(TempHIn);
|
|
fdClose(TempHIn);
|
|
@@ -354,7 +390,11 @@ end;
|
|
{$ifndef FPC}
|
|
{$ifndef FPC}
|
|
Handles^[StdInputHandle]:=OldHandleIn;
|
|
Handles^[StdInputHandle]:=OldHandleIn;
|
|
{$else}
|
|
{$else}
|
|
|
|
+{$ifdef win32}
|
|
|
|
+ SetStdHandle(Std_Input_Handle,StdInputHandle);
|
|
|
|
+{$else not win32}
|
|
dup2(TempHIn,StdInputHandle);
|
|
dup2(TempHIn,StdInputHandle);
|
|
|
|
+{$endif not win32}
|
|
{$endif}
|
|
{$endif}
|
|
InRedirDisabled:=True;
|
|
InRedirDisabled:=True;
|
|
end;
|
|
end;
|
|
@@ -370,7 +410,11 @@ end;
|
|
Handles:=Ptr (prefseg, PWord (Ptr (prefseg, $34))^);
|
|
Handles:=Ptr (prefseg, PWord (Ptr (prefseg, $34))^);
|
|
Handles^[StdInputHandle]:=Handles^[FileRec (FIn^).Handle];
|
|
Handles^[StdInputHandle]:=Handles^[FileRec (FIn^).Handle];
|
|
{$else}
|
|
{$else}
|
|
|
|
+{$ifdef win32}
|
|
|
|
+ SetStdHandle(Std_Input_Handle,FileRec(FIn^).Handle);
|
|
|
|
+{$else not win32}
|
|
dup2(FileRec(FIn^).Handle,StdInputHandle);
|
|
dup2(FileRec(FIn^).Handle,StdInputHandle);
|
|
|
|
+{$endif not win32}
|
|
{$endif}
|
|
{$endif}
|
|
InRedirDisabled:=False;
|
|
InRedirDisabled:=False;
|
|
end;
|
|
end;
|
|
@@ -385,7 +429,11 @@ end;
|
|
{$ifndef FPC}
|
|
{$ifndef FPC}
|
|
Handles^[StdOutputHandle]:=OldHandleOut;
|
|
Handles^[StdOutputHandle]:=OldHandleOut;
|
|
{$else}
|
|
{$else}
|
|
|
|
+{$ifdef win32}
|
|
|
|
+ SetStdHandle(Std_Output_Handle,StdOutputHandle);
|
|
|
|
+{$else not win32}
|
|
dup2(TempHOut,StdOutputHandle);
|
|
dup2(TempHOut,StdOutputHandle);
|
|
|
|
+{$endif not win32}
|
|
{$endif}
|
|
{$endif}
|
|
OutRedirDisabled:=True;
|
|
OutRedirDisabled:=True;
|
|
end;
|
|
end;
|
|
@@ -401,7 +449,11 @@ end;
|
|
Handles:=Ptr (prefseg, PWord (Ptr (prefseg, $34))^);
|
|
Handles:=Ptr (prefseg, PWord (Ptr (prefseg, $34))^);
|
|
Handles^[StdOutputHandle]:=Handles^[FileRec (FOut^).Handle];
|
|
Handles^[StdOutputHandle]:=Handles^[FileRec (FOut^).Handle];
|
|
{$else}
|
|
{$else}
|
|
|
|
+{$ifdef win32}
|
|
|
|
+ SetStdHandle(Std_Output_Handle,FileRec(FOut^).Handle);
|
|
|
|
+{$else not win32}
|
|
dup2(FileRec(FOut^).Handle,StdOutputHandle);
|
|
dup2(FileRec(FOut^).Handle,StdOutputHandle);
|
|
|
|
+{$endif not win32}
|
|
{$endif}
|
|
{$endif}
|
|
OutRedirDisabled:=False;
|
|
OutRedirDisabled:=False;
|
|
end;
|
|
end;
|
|
@@ -416,7 +468,11 @@ end;
|
|
Handles^[StdErrorHandle]:=OldHandleError;
|
|
Handles^[StdErrorHandle]:=OldHandleError;
|
|
OldHandleError:=StdErrorHandle;
|
|
OldHandleError:=StdErrorHandle;
|
|
{$else}
|
|
{$else}
|
|
|
|
+{$ifdef win32}
|
|
|
|
+ SetStdHandle(Std_Error_Handle,StdErrorHandle);
|
|
|
|
+{$else not win32}
|
|
dup2(TempHError,StdErrorHandle);
|
|
dup2(TempHError,StdErrorHandle);
|
|
|
|
+{$endif not win32}
|
|
{$endif}
|
|
{$endif}
|
|
Close (FERR^);
|
|
Close (FERR^);
|
|
fdClose(TempHError);
|
|
fdClose(TempHError);
|
|
@@ -433,7 +489,11 @@ end;
|
|
{$ifndef FPC}
|
|
{$ifndef FPC}
|
|
Handles^[StdErrorHandle]:=OldHandleError;
|
|
Handles^[StdErrorHandle]:=OldHandleError;
|
|
{$else}
|
|
{$else}
|
|
|
|
+{$ifdef win32}
|
|
|
|
+ SetStdHandle(Std_Error_Handle,StdErrorHandle);
|
|
|
|
+{$else not win32}
|
|
dup2(TempHError,StdErrorHandle);
|
|
dup2(TempHError,StdErrorHandle);
|
|
|
|
+{$endif not win32}
|
|
{$endif}
|
|
{$endif}
|
|
ErrorRedirDisabled:=True;
|
|
ErrorRedirDisabled:=True;
|
|
end;
|
|
end;
|
|
@@ -449,7 +509,11 @@ end;
|
|
Handles:=Ptr (prefseg, PWord (Ptr (prefseg, $34))^);
|
|
Handles:=Ptr (prefseg, PWord (Ptr (prefseg, $34))^);
|
|
Handles^[StdErrorHandle]:=Handles^[FileRec (FErr^).Handle];
|
|
Handles^[StdErrorHandle]:=Handles^[FileRec (FErr^).Handle];
|
|
{$else}
|
|
{$else}
|
|
|
|
+{$ifdef win32}
|
|
|
|
+ SetStdHandle(Std_Error_Handle,FileRec(FErr^).Handle);
|
|
|
|
+{$else not win32}
|
|
dup2(FileRec(FERR^).Handle,StdErrorHandle);
|
|
dup2(FileRec(FERR^).Handle,StdErrorHandle);
|
|
|
|
+{$endif not win32}
|
|
{$endif}
|
|
{$endif}
|
|
ErrorRedirDisabled:=False;
|
|
ErrorRedirDisabled:=False;
|
|
end;
|
|
end;
|
|
@@ -457,6 +521,10 @@ end;
|
|
{............................................................................}
|
|
{............................................................................}
|
|
|
|
|
|
procedure DosExecute(ProgName, ComLine : String);
|
|
procedure DosExecute(ProgName, ComLine : String);
|
|
|
|
+{$ifdef win32}
|
|
|
|
+ var
|
|
|
|
+ StoreInherit : BOOL;
|
|
|
|
+{$endif win32}
|
|
|
|
|
|
Begin
|
|
Begin
|
|
{$IfDef MsDos}
|
|
{$IfDef MsDos}
|
|
@@ -467,7 +535,14 @@ end;
|
|
{$ifdef linux}
|
|
{$ifdef linux}
|
|
Shell(Progname+' '+Comline);
|
|
Shell(Progname+' '+Comline);
|
|
{$else}
|
|
{$else}
|
|
|
|
+{$ifdef win32}
|
|
|
|
+ StoreInherit:=ExecInheritsHandles;
|
|
|
|
+ ExecInheritsHandles:=true;
|
|
|
|
+{$endif win32}
|
|
Dos.Exec (ProgName, ComLine);
|
|
Dos.Exec (ProgName, ComLine);
|
|
|
|
+{$ifdef win32}
|
|
|
|
+ ExecInheritsHandles:=StoreInherit;
|
|
|
|
+{$endif win32}
|
|
{$endif}
|
|
{$endif}
|
|
IOStatus:=DosError;
|
|
IOStatus:=DosError;
|
|
ExecuteResult:=DosExitCode;
|
|
ExecuteResult:=DosExitCode;
|
|
@@ -533,8 +608,9 @@ end;
|
|
|
|
|
|
{$else not implemented}
|
|
{$else not implemented}
|
|
|
|
|
|
|
|
+
|
|
{*****************************************************************************
|
|
{*****************************************************************************
|
|
- Linux
|
|
|
|
|
|
+ Fake
|
|
*****************************************************************************}
|
|
*****************************************************************************}
|
|
|
|
|
|
function ExecuteRedir (Const ProgName, ComLine, RedirStdIn, RedirStdOut, RedirStdErr : String) : boolean;
|
|
function ExecuteRedir (Const ProgName, ComLine, RedirStdIn, RedirStdOut, RedirStdErr : String) : boolean;
|
|
@@ -640,7 +716,10 @@ Begin
|
|
End.
|
|
End.
|
|
{
|
|
{
|
|
$Log$
|
|
$Log$
|
|
- Revision 1.20 1999-08-05 16:54:36 peter
|
|
|
|
|
|
+ Revision 1.21 1999-09-21 11:28:22 pierre
|
|
|
|
+ + Redir for win32
|
|
|
|
+
|
|
|
|
+ Revision 1.20 1999/08/05 16:54:36 peter
|
|
* win32 fixes
|
|
* win32 fixes
|
|
|
|
|
|
Revision 1.19 1999/08/03 20:22:36 peter
|
|
Revision 1.19 1999/08/03 20:22:36 peter
|