From 601f2e02ce55d560620a1792a538fb50d5e4ad76 Mon Sep 17 00:00:00 2001 From: Tomas Hajny <hajny@freepascal.org> Date: Sun, 15 Feb 2004 21:34:06 +0000 Subject: [PATCH] * overloaded ExecuteProcess added, EnvStr param changed to longint --- rtl/go32v2/dos.pp | 11 ++++++-- rtl/go32v2/sysutils.pp | 24 +++++++++++++++- rtl/inc/dosh.inc | 2 +- rtl/netware/dos.pp | 11 ++++++-- rtl/netware/sysutils.pp | 25 ++++++++++++++++- rtl/os2/dos.pas | 59 +++++++++++++++++++++++++++------------- rtl/os2/sysutils.pp | 32 ++++++++++++++-------- rtl/template/sysutils.pp | 25 ++++++++++++++++- rtl/unix/dos.pp | 11 ++++++-- rtl/watcom/dos.pp | 11 ++++++-- rtl/watcom/sysutils.pp | 25 ++++++++++++++++- rtl/win32/dos.pp | 11 ++++++-- 12 files changed, 202 insertions(+), 45 deletions(-) diff --git a/rtl/go32v2/dos.pp b/rtl/go32v2/dos.pp index a9d0a8a403..553829bd74 100644 --- a/rtl/go32v2/dos.pp +++ b/rtl/go32v2/dos.pp @@ -167,7 +167,11 @@ End; --- Exec --- ******************************************************************************} +{$ifdef HASTHREADVAR} +threadvar +{$else HASTHREADVAR} var +{$endif HASTHREADVAR} lastdosexitcode : word; procedure exec(const path : pathstr;const comline : comstr); @@ -892,7 +896,7 @@ begin end; -function envstr(index : integer) : string; +function envstr (Index: longint): string; begin if (index<=0) or (index>envcount) then begin @@ -946,7 +950,10 @@ End; end. { $Log$ - Revision 1.18 2004-02-09 12:03:16 michael + Revision 1.19 2004-02-15 21:34:06 hajny + * overloaded ExecuteProcess added, EnvStr param changed to longint + + Revision 1.18 2004/02/09 12:03:16 michael + Switched to single interface in dosh.inc Revision 1.17 2004/01/06 00:58:35 florian diff --git a/rtl/go32v2/sysutils.pp b/rtl/go32v2/sysutils.pp index d75c433457..2740c00425 100644 --- a/rtl/go32v2/sysutils.pp +++ b/rtl/go32v2/sysutils.pp @@ -782,6 +782,25 @@ begin Result := DosExitCode; end; + +function ExecuteProcess (const Path: AnsiString; + const ComLine: array of AnsiString): integer; + +var + CommandLine: AnsiString; + I: integer; + +begin + Commandline := ''; + for I := 0 to High (ComLine) do + if Pos (' ', ComLine [I]) <> 0 then + CommandLine := CommandLine + ' ' + '"' + ComLine [I] + '"' + else + CommandLine := CommandLine + ' ' + Comline [I]; + ExecuteProcess := ExecuteProcess (Path, CommandLine); +end; + + {************************************************************************* Sleep (copied from crt.Delay) *************************************************************************} @@ -860,7 +879,10 @@ Finalization end. { $Log$ - Revision 1.23 2004-01-25 13:05:08 jonas + Revision 1.24 2004-02-15 21:34:06 hajny + * overloaded ExecuteProcess added, EnvStr param changed to longint + + Revision 1.23 2004/01/25 13:05:08 jonas * fixed compilation errors Revision 1.22 2004/01/20 23:09:14 hajny diff --git a/rtl/inc/dosh.inc b/rtl/inc/dosh.inc index 5286fb933f..c8a1f40f7b 100644 --- a/rtl/inc/dosh.inc +++ b/rtl/inc/dosh.inc @@ -105,7 +105,7 @@ function GetLongName(var p : String) : boolean; {Environment} Function EnvCount: longint; -Function EnvStr(index: integer): string; +Function EnvStr (Index: longint): string; Function GetEnv(envvar: string): string; {Misc} diff --git a/rtl/netware/dos.pp b/rtl/netware/dos.pp index 5c3f82fb95..7aad7d1dc0 100644 --- a/rtl/netware/dos.pp +++ b/rtl/netware/dos.pp @@ -134,7 +134,11 @@ End; --- Exec --- ******************************************************************************} +{$ifdef HASTHREADVAR} +threadvar +{$else HASTHREADVAR} var +{$endif HASTHREADVAR} lastdosexitcode : word; procedure exec(const path : pathstr;const comline : comstr); @@ -691,7 +695,7 @@ begin end; -function envstr(index : integer) : string; +function envstr (index: longint) : string; begin envstr := ''; {is there a netware function to do that ?????} ConsolePrintf ('warning: fpc dos.envstr not implemented'#13#10,0); @@ -746,7 +750,10 @@ end; end. { $Log$ - Revision 1.7 2004-02-09 12:03:16 michael + Revision 1.8 2004-02-15 21:34:06 hajny + * overloaded ExecuteProcess added, EnvStr param changed to longint + + Revision 1.7 2004/02/09 12:03:16 michael + Switched to single interface in dosh.inc Revision 1.6 2003/03/25 18:17:54 armin diff --git a/rtl/netware/sysutils.pp b/rtl/netware/sysutils.pp index def25e6d04..67fee7fab3 100644 --- a/rtl/netware/sysutils.pp +++ b/rtl/netware/sysutils.pp @@ -509,6 +509,26 @@ begin Result := DosExitCode; end; + +function ExecuteProcess (const Path: AnsiString; + const ComLine: array of AnsiString): integer; + +var + CommandLine: AnsiString; + I: integer; + +begin + Commandline := ''; + for I := 0 to High (ComLine) do + if Pos (' ', ComLine [I]) <> 0 then + CommandLine := CommandLine + ' ' + '"' + ComLine [I] + '"' + else + CommandLine := CommandLine + ' ' + Comline [I]; + ExecuteProcess := ExecuteProcess (Path, CommandLine); +end; + + + {**************************************************************************** Initialization code ****************************************************************************} @@ -522,7 +542,10 @@ end. { $Log$ - Revision 1.14 2004-01-20 23:11:20 hajny + Revision 1.15 2004-02-15 21:34:06 hajny + * overloaded ExecuteProcess added, EnvStr param changed to longint + + Revision 1.14 2004/01/20 23:11:20 hajny * ExecuteProcess fixes, ProcessID and ThreadID added Revision 1.13 2003/11/26 20:00:19 florian diff --git a/rtl/os2/dos.pas b/rtl/os2/dos.pas index 4337937d47..3d85207719 100644 --- a/rtl/os2/dos.pas +++ b/rtl/os2/dos.pas @@ -93,10 +93,7 @@ const (* For compatibility with VP/2, used for runflags in Exec procedure. *) ExecFlags: cardinal = ord (efwait); -var - dosexitcodevar:word; - -{$I dosh.inc} +{$i dosh.inc} {OS/2 specific functions} @@ -160,14 +157,21 @@ begin DosError := integer (RC); end; -procedure exec(const path:pathstr;const comline:comstr); +{$ifdef HASTHREADVAR} +threadvar +{$else HASTHREADVAR} +var +{$endif HASTHREADVAR} + LastDosExitCode: longint; + +procedure exec (const path:pathstr;const comline:comstr); {Execute a program.} begin - dosexitcodevar:=word(exec(path,execrunflags(ExecFlags),efdefault,comline)); + LastDosExitCode := Exec (Path, ExecRunFlags (ExecFlags), efDefault, ComLine); end; -function exec(path:pathstr;runflags:execrunflags;winflags:execwinflags; - const comline:comstr):longint; +function Exec (path:pathstr;runflags:execrunflags;winflags:execwinflags; + const comline:comstr): longint; {Execute a program. More suitable for OS/2 than the exec above.} var args:Pbytearray; env:Pbytearray; @@ -257,6 +261,13 @@ begin a system function I ever wrote!} end; + +function DosExitCode: word; +begin + DosExitCode := LastDosExitCode and $FFFF; +end; + + function dosversion:word; {Returns OS/2 version} var @@ -425,7 +436,7 @@ begin envcount:=envc; end; -function envstr(index : integer) : string; +function envstr (index : longint) : string; var hp:Pchar; @@ -628,31 +639,33 @@ begin DosError := integer (RC); end; -function DosExitCode: word; -begin - DosExitCode:=dosexitcodevar; -end; -Procedure Intr(intno: byte; var regs: registers); + +{****************************************************************************** + --- Not Supported --- +******************************************************************************} + +procedure Keep (ExitCode: word); begin end; -Procedure MSDos(var regs: registers); +procedure GetIntVec (IntNo: byte; var Vector: pointer); begin end; -Procedure GetIntVec(intno: byte; var vector: pointer); +procedure SetIntVec (IntNo: byte; Vector: pointer); begin end; -Procedure SetIntVec(intno: byte; vector: pointer); +procedure Intr (IntNo: byte; var Regs: Registers); begin end; -Procedure Keep(exitcode: word); +procedure MsDos (var Regs: Registers); begin end; + function GetShortName(var p : String) : boolean; begin GetShortName:=true; @@ -661,12 +674,20 @@ end; function GetLongName(var p : String) : boolean; begin GetLongName:=true; +{$WARNING EA .longname support should be probably added here} end; + + +begin + LastDosExitCode := 0; end. { $Log$ - Revision 1.35 2004-02-15 08:02:44 yuri + Revision 1.36 2004-02-15 21:34:06 hajny + * overloaded ExecuteProcess added, EnvStr param changed to longint + + Revision 1.35 2004/02/15 08:02:44 yuri * fixes for dosh.inc * Executeprocess iverloaded function * updated todo diff --git a/rtl/os2/sysutils.pp b/rtl/os2/sysutils.pp index e8b3d528a5..8c704fa7ae 100644 --- a/rtl/os2/sysutils.pp +++ b/rtl/os2/sysutils.pp @@ -944,18 +944,25 @@ begin raise E; end; -function ExecuteProcess(Const Path: AnsiString; Const ComLine: Array of AnsiString):integer; -Var - CommandLine : AnsiString; - i : Integer; +function ExecuteProcess (const Path: AnsiString; + const ComLine: array of AnsiString): integer; + +var + CommandLine: AnsiString; + I: integer; + +begin + Commandline := ''; + for I := 0 to High (ComLine) do + if Pos (' ', ComLine [I]) <> 0 then + CommandLine := CommandLine + ' ' + '"' + ComLine [I] + '"' + else + CommandLine := CommandLine + ' ' + Comline [I]; + ExecuteProcess := ExecuteProcess (Path, CommandLine); +end; + -Begin - Commandline:=''; - For i:=0 to high(ComLine) Do - Commandline:=CommandLine+' '+Comline[i]; - ExecuteProcess:=ExecuteProcess(Path,CommandLine); -End; {**************************************************************************** Initialization code @@ -970,7 +977,10 @@ end. { $Log$ - Revision 1.41 2004-02-15 08:02:44 yuri + Revision 1.42 2004-02-15 21:36:10 hajny + * overloaded ExecuteProcess added, EnvStr param changed to longint + + Revision 1.41 2004/02/15 08:02:44 yuri * fixes for dosh.inc * Executeprocess iverloaded function * updated todo diff --git a/rtl/template/sysutils.pp b/rtl/template/sysutils.pp index 4e52126106..5d0694a97a 100644 --- a/rtl/template/sysutils.pp +++ b/rtl/template/sysutils.pp @@ -271,6 +271,26 @@ begin Result := DosExitCode; end; + +function ExecuteProcess (const Path: AnsiString; + const ComLine: array of AnsiString): integer; + +var + CommandLine: AnsiString; + I: integer; + +begin + Commandline := ''; + for I := 0 to High (ComLine) do + if Pos (' ', ComLine [I]) <> 0 then + CommandLine := CommandLine + ' ' + '"' + ComLine [I] + '"' + else + CommandLine := CommandLine + ' ' + Comline [I]; + ExecuteProcess := ExecuteProcess (Path, CommandLine); +end; + + + {**************************************************************************** Initialization code ****************************************************************************} @@ -284,7 +304,10 @@ Finalization end. { $Log$ - Revision 1.4 2004-01-20 23:12:49 hajny + Revision 1.5 2004-02-15 21:36:10 hajny + * overloaded ExecuteProcess added, EnvStr param changed to longint + + Revision 1.4 2004/01/20 23:12:49 hajny * ExecuteProcess fixes, ProcessID and ThreadID added Revision 1.3 2003/03/29 15:16:26 hajny diff --git a/rtl/unix/dos.pp b/rtl/unix/dos.pp index 9ba0368050..fce2d9e761 100644 --- a/rtl/unix/dos.pp +++ b/rtl/unix/dos.pp @@ -223,7 +223,11 @@ End; --- Exec --- ******************************************************************************} +{$ifdef HASTHREADVAR} +threadvar +{$else HASTHREADVAR} var +{$endif HASTHREADVAR} LastDosExitCode: word; Procedure Exec (Const Path: PathStr; Const ComLine: ComStr); @@ -683,7 +687,7 @@ End; -Function EnvStr(Index: Integer): String; +Function EnvStr (Index: longint): String; Var i : longint; p : ppchar; @@ -824,7 +828,10 @@ End. { $Log$ - Revision 1.25 2004-02-09 17:01:28 marco + Revision 1.26 2004-02-15 21:36:10 hajny + * overloaded ExecuteProcess added, EnvStr param changed to longint + + Revision 1.25 2004/02/09 17:01:28 marco * fixes to get it working under FreeBSD, and probably Linux too Revision 1.24 2004/02/09 12:03:16 michael diff --git a/rtl/watcom/dos.pp b/rtl/watcom/dos.pp index 20818f29f6..dab2cd4288 100644 --- a/rtl/watcom/dos.pp +++ b/rtl/watcom/dos.pp @@ -167,7 +167,11 @@ End; --- Exec --- ******************************************************************************} +{$ifdef HASTHREADVAR} +threadvar +{$else HASTHREADVAR} var +{$endif HASTHREADVAR} lastdosexitcode : word; procedure exec(const path : pathstr;const comline : comstr); @@ -892,7 +896,7 @@ begin end; -function envstr(index : integer) : string; +function EnvStr (Index: longint): string; begin if (index<=0) or (index>envcount) then begin @@ -947,7 +951,10 @@ end. { $Log$ - Revision 1.5 2004-02-09 12:03:16 michael + Revision 1.6 2004-02-15 21:36:10 hajny + * overloaded ExecuteProcess added, EnvStr param changed to longint + + Revision 1.5 2004/02/09 12:03:16 michael + Switched to single interface in dosh.inc Revision 1.4 2003/10/18 09:18:29 hajny diff --git a/rtl/watcom/sysutils.pp b/rtl/watcom/sysutils.pp index 56300c1b12..c64c2e5d8e 100644 --- a/rtl/watcom/sysutils.pp +++ b/rtl/watcom/sysutils.pp @@ -782,6 +782,26 @@ begin Result := DosExitCode; end; + +function ExecuteProcess (const Path: AnsiString; + const ComLine: array of AnsiString): integer; + +var + CommandLine: AnsiString; + I: integer; + +begin + Commandline := ''; + for I := 0 to High (ComLine) do + if Pos (' ', ComLine [I]) <> 0 then + CommandLine := CommandLine + ' ' + '"' + ComLine [I] + '"' + else + CommandLine := CommandLine + ' ' + Comline [I]; + ExecuteProcess := ExecuteProcess (Path, CommandLine); +end; + + + {************************************************************************* Sleep (copied from crt.Delay) *************************************************************************} @@ -861,7 +881,10 @@ end. { $Log$ - Revision 1.4 2004-01-20 23:12:49 hajny + Revision 1.5 2004-02-15 21:36:10 hajny + * overloaded ExecuteProcess added, EnvStr param changed to longint + + Revision 1.4 2004/01/20 23:12:49 hajny * ExecuteProcess fixes, ProcessID and ThreadID added Revision 1.3 2003/12/15 15:57:49 peter diff --git a/rtl/win32/dos.pp b/rtl/win32/dos.pp index 334d9b19e7..e9bb7eb273 100644 --- a/rtl/win32/dos.pp +++ b/rtl/win32/dos.pp @@ -309,7 +309,11 @@ type function CloseHandle(h : TWin32Handle) : longint; stdcall; external 'kernel32' name 'CloseHandle'; +{$ifdef HASTHREADVAR} +threadvar +{$else HASTHREADVAR} var +{$endif HASTHREADVAR} lastdosexitcode : longint; procedure exec(const path : pathstr;const comline : comstr); @@ -851,7 +855,7 @@ begin end; -Function EnvStr(index: integer): string; +Function EnvStr (Index: longint): string; var hp,p : pchar; count,i : longint; @@ -956,7 +960,10 @@ begin end. { $Log$ - Revision 1.23 2004-02-09 12:03:16 michael + Revision 1.24 2004-02-15 21:36:10 hajny + * overloaded ExecuteProcess added, EnvStr param changed to longint + + Revision 1.23 2004/02/09 12:03:16 michael + Switched to single interface in dosh.inc Revision 1.22 2004/01/06 00:58:35 florian