mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-23 13:31:43 +02:00
+ Added GetEnvironmentVariableCount and GetEnvironmentString calls
This commit is contained in:
parent
62d4f7dd52
commit
fbb13b5266
@ -255,6 +255,20 @@ begin
|
||||
Result:=StrPas(beos.Getenv(PChar(EnvVar)));
|
||||
end;
|
||||
|
||||
Function GetEnvironmentVariableCount : Integer;
|
||||
|
||||
begin
|
||||
// Result:=FPCCountEnvVar(EnvP);
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
|
||||
begin
|
||||
// Result:=FPCGetEnvStrFromP(Envp,Index);
|
||||
Result:='';
|
||||
end;
|
||||
|
||||
|
||||
function ExecuteProcess (const Path: AnsiString; const ComLine: AnsiString):
|
||||
integer;
|
||||
@ -309,7 +323,10 @@ Finalization
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.9 2004-02-15 21:26:37 hajny
|
||||
Revision 1.10 2004-12-11 11:32:44 michael
|
||||
+ Added GetEnvironmentVariableCount and GetEnvironmentString calls
|
||||
|
||||
Revision 1.9 2004/02/15 21:26:37 hajny
|
||||
* overloaded ExecuteProcess added, EnvStr param changed to longint
|
||||
|
||||
Revision 1.8 2004/01/20 23:09:14 hajny
|
||||
|
@ -1092,6 +1092,20 @@ begin
|
||||
GetEnvironmentVariable := StrPas (GetEnvPChar (EnvVar));
|
||||
end;
|
||||
|
||||
Function GetEnvironmentVariableCount : Integer;
|
||||
|
||||
begin
|
||||
// Result:=FPCCountEnvVar(EnvP);
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
|
||||
begin
|
||||
// Result:=FPCGetEnvStrFromP(Envp,Index);
|
||||
Result:='';
|
||||
end;
|
||||
|
||||
|
||||
{$ASMMODE INTEL}
|
||||
procedure Sleep (Milliseconds: cardinal);
|
||||
@ -1207,7 +1221,10 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.16 2004-02-22 15:01:49 hajny
|
||||
Revision 1.17 2004-12-11 11:32:44 michael
|
||||
+ Added GetEnvironmentVariableCount and GetEnvironmentString calls
|
||||
|
||||
Revision 1.16 2004/02/22 15:01:49 hajny
|
||||
* lots of fixes (regcall, THandle, string operations in sysutils, longint2cardinal according to OS/2 docs, dosh.inc, ...)
|
||||
|
||||
Revision 1.15 2004/02/15 21:26:37 hajny
|
||||
|
@ -739,27 +739,23 @@ end;
|
||||
****************************************************************************}
|
||||
|
||||
Function GetEnvironmentVariable(Const EnvVar : String) : String;
|
||||
var
|
||||
hp : ppchar;
|
||||
lenvvar,hs : string;
|
||||
eqpos : longint;
|
||||
|
||||
begin
|
||||
lenvvar:=upcase(envvar);
|
||||
hp:=envp;
|
||||
Result:='';
|
||||
while assigned(hp^) do
|
||||
begin
|
||||
hs:=strpas(hp^);
|
||||
eqpos:=pos('=',hs);
|
||||
if upcase(copy(hs,1,eqpos-1))=lenvvar then
|
||||
begin
|
||||
Result:=copy(hs,eqpos+1,length(hs)-eqpos);
|
||||
exit;
|
||||
end;
|
||||
inc(hp);
|
||||
end;
|
||||
Result:=FPCGetEnvVarFromP(envp,EnvVar);
|
||||
end;
|
||||
|
||||
Function GetEnvironmentVariableCount : Integer;
|
||||
|
||||
begin
|
||||
Result:=FPCCountEnvVar(EnvP);
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
|
||||
begin
|
||||
Result:=FPCGetEnvStrFromP(Envp,Index);
|
||||
end;
|
||||
|
||||
|
||||
function ExecuteProcess(Const Path: AnsiString; Const ComLine: AnsiString):integer;
|
||||
var
|
||||
@ -879,7 +875,10 @@ Finalization
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.24 2004-02-15 21:34:06 hajny
|
||||
Revision 1.25 2004-12-11 11:32:44 michael
|
||||
+ Added GetEnvironmentVariableCount and GetEnvironmentString calls
|
||||
|
||||
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
|
||||
|
@ -622,6 +622,20 @@ begin
|
||||
*)
|
||||
end;
|
||||
|
||||
Function GetEnvironmentVariableCount : Integer;
|
||||
|
||||
begin
|
||||
// Result:=FPCCountEnvVar(EnvP);
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
|
||||
begin
|
||||
// Result:=FPCGetEnvStrFromP(Envp,Index);
|
||||
Result:='';
|
||||
end;
|
||||
|
||||
function ExecuteProcess(Const Path: AnsiString; Const ComLine: AnsiString):integer;
|
||||
var
|
||||
s: AnsiString;
|
||||
@ -685,7 +699,10 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.3 2004-10-14 16:27:11 mazen
|
||||
Revision 1.4 2004-12-11 11:32:44 michael
|
||||
+ Added GetEnvironmentVariableCount and GetEnvironmentString calls
|
||||
|
||||
Revision 1.3 2004/10/14 16:27:11 mazen
|
||||
* First implementation of ExecuteProcess
|
||||
|
||||
Revision 1.2 2004/09/30 10:42:05 mazen
|
||||
|
@ -424,7 +424,20 @@ Function GetEnvironmentVariable(Const EnvVar : String) : String;
|
||||
begin
|
||||
Result:=Dos.Getenv(shortstring(EnvVar));
|
||||
end;
|
||||
Function GetEnvironmentVariableCount : Integer;
|
||||
|
||||
begin
|
||||
// Result:=FPCCountEnvVar(EnvP);
|
||||
Result:=Dos.envCount;
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
|
||||
begin
|
||||
// Result:=FPCGetEnvStrFromP(Envp,Index);
|
||||
Result:=Dos.EnvStr(Index);
|
||||
end;
|
||||
|
||||
function ExecuteProcess (const Path: AnsiString; const ComLine: AnsiString):
|
||||
integer;
|
||||
var
|
||||
@ -475,7 +488,10 @@ Finalization
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.1 2004-06-06 00:58:02 karoly
|
||||
Revision 1.2 2004-12-11 11:32:44 michael
|
||||
+ Added GetEnvironmentVariableCount and GetEnvironmentString calls
|
||||
|
||||
Revision 1.1 2004/06/06 00:58:02 karoly
|
||||
* initial revision
|
||||
|
||||
}
|
||||
|
@ -508,6 +508,20 @@ begin
|
||||
Result:=StrPas(_getenv(PChar(EnvVar)));
|
||||
end;
|
||||
|
||||
Function GetEnvironmentVariableCount : Integer;
|
||||
|
||||
begin
|
||||
// Result:=FPCCountEnvVar(EnvP);
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
|
||||
begin
|
||||
// Result:=FPCGetEnvStrFromP(Envp,Index);
|
||||
Result:='';
|
||||
end;
|
||||
|
||||
|
||||
function ExecuteProcess(Const Path: AnsiString; Const ComLine: AnsiString):integer;
|
||||
|
||||
@ -564,7 +578,10 @@ end.
|
||||
{
|
||||
|
||||
$Log$
|
||||
Revision 1.16 2004-08-01 20:02:48 armin
|
||||
Revision 1.17 2004-12-11 11:32:44 michael
|
||||
+ Added GetEnvironmentVariableCount and GetEnvironmentString calls
|
||||
|
||||
Revision 1.16 2004/08/01 20:02:48 armin
|
||||
* changed dir separator from \ to /
|
||||
* long namespace by default
|
||||
* dos.exec implemented
|
||||
|
@ -582,6 +582,20 @@ begin
|
||||
Result:=StrPas(libc.getenv(PChar(EnvVar)));
|
||||
end;
|
||||
|
||||
Function GetEnvironmentVariableCount : Integer;
|
||||
|
||||
begin
|
||||
// Result:=FPCCountEnvVar(EnvP);
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
|
||||
begin
|
||||
// Result:=FPCGetEnvStrFromP(Envp,Index);
|
||||
Result:='';
|
||||
end;
|
||||
|
||||
|
||||
function ExecuteProcess(Const Path: AnsiString; Const ComLine: AnsiString):integer;
|
||||
|
||||
@ -638,7 +652,10 @@ end.
|
||||
{
|
||||
|
||||
$Log$
|
||||
Revision 1.4 2004-09-26 19:23:34 armin
|
||||
Revision 1.5 2004-12-11 11:32:44 michael
|
||||
+ Added GetEnvironmentVariableCount and GetEnvironmentString calls
|
||||
|
||||
Revision 1.4 2004/09/26 19:23:34 armin
|
||||
* exiting threads at nlm unload
|
||||
* renamed some libc functions
|
||||
|
||||
|
@ -14,6 +14,67 @@
|
||||
|
||||
**********************************************************************}
|
||||
|
||||
{ ---------------------------------------------------------------------
|
||||
Environment variable auxiliary routines
|
||||
---------------------------------------------------------------------}
|
||||
Const
|
||||
FPC_EnvCount : Integer = -1;
|
||||
|
||||
Function FPCCountEnvVar(EP : PPChar) : integer;
|
||||
|
||||
begin
|
||||
If (FPC_EnvCount=-1) then
|
||||
begin
|
||||
FPC_EnvCount:=0;
|
||||
If (EP<>Nil) then
|
||||
While (EP^<>Nil) do
|
||||
begin
|
||||
Inc(FPC_EnvCount);
|
||||
Inc(EP);
|
||||
end;
|
||||
end;
|
||||
Result:=FPC_EnvCount;
|
||||
end;
|
||||
|
||||
Function FPCGetEnvVarFromP(EP : PPChar; EnvVar : String) : String;
|
||||
|
||||
var
|
||||
hp : ppchar;
|
||||
lenvvar,hs : string;
|
||||
eqpos : longint;
|
||||
|
||||
begin
|
||||
lenvvar:=upcase(envvar);
|
||||
hp:=EP;
|
||||
Result:='';
|
||||
If (hp<>Nil) then
|
||||
while assigned(hp^) do
|
||||
begin
|
||||
hs:=strpas(hp^);
|
||||
eqpos:=pos('=',hs);
|
||||
if upcase(copy(hs,1,eqpos-1))=lenvvar then
|
||||
begin
|
||||
Result:=copy(hs,eqpos+1,length(hs)-eqpos);
|
||||
exit;
|
||||
end;
|
||||
inc(hp);
|
||||
end;
|
||||
end;
|
||||
|
||||
Function FPCGetEnvStrFromP(EP : PPChar; Index : Integer) : String;
|
||||
|
||||
begin
|
||||
Result:='';
|
||||
while assigned(EP^) and (Index>1) do
|
||||
begin
|
||||
Dec(Index);
|
||||
inc(EP);
|
||||
end;
|
||||
If Assigned(EP^) then
|
||||
Result:=StrPas(EP^);
|
||||
end;
|
||||
|
||||
|
||||
{ ---------------------------------------------------------------------
|
||||
Application name
|
||||
---------------------------------------------------------------------}
|
||||
@ -146,7 +207,10 @@ end;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.2 2004-10-10 10:28:34 michael
|
||||
Revision 1.3 2004-12-11 11:33:15 michael
|
||||
+ Added GetEnvironmentVariableCount and GetEnvironmentString calls
|
||||
|
||||
Revision 1.2 2004/10/10 10:28:34 michael
|
||||
+ Implementation of GetTempDir and GetTempFileName
|
||||
|
||||
Revision 1.1 2004/08/05 07:28:01 michael
|
||||
|
@ -20,6 +20,8 @@ Function GetLastOSError : Integer;
|
||||
{$endif}
|
||||
Procedure RaiseLastOSError;
|
||||
Function GetEnvironmentVariable(Const EnvVar : String) : String;
|
||||
Function GetEnvironmentVariableCount : Integer;
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
{$IFDEF HAS_SLEEP}
|
||||
procedure Sleep(milliseconds: Cardinal);
|
||||
{$ENDIF}
|
||||
@ -53,7 +55,10 @@ Var
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.8 2004-10-10 10:28:34 michael
|
||||
Revision 1.9 2004-12-11 11:33:15 michael
|
||||
+ Added GetEnvironmentVariableCount and GetEnvironmentString calls
|
||||
|
||||
Revision 1.8 2004/10/10 10:28:34 michael
|
||||
+ Implementation of GetTempDir and GetTempFileName
|
||||
|
||||
Revision 1.7 2004/08/05 07:28:01 michael
|
||||
|
@ -875,6 +875,18 @@ begin
|
||||
GetEnvironmentVariable := StrPas (GetEnvPChar (EnvVar));
|
||||
end;
|
||||
|
||||
Function GetEnvironmentVariableCount : Integer;
|
||||
|
||||
begin
|
||||
Result:=FPCCountEnvVar(EnvP);
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
|
||||
begin
|
||||
Result:=FPCGetEnvStrFromP(Envp,Index);
|
||||
end;
|
||||
|
||||
|
||||
procedure Sleep (Milliseconds: cardinal);
|
||||
|
||||
@ -1018,7 +1030,10 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.46 2004-12-06 22:11:47 hajny
|
||||
Revision 1.47 2004-12-11 11:32:44 michael
|
||||
+ Added GetEnvironmentVariableCount and GetEnvironmentString calls
|
||||
|
||||
Revision 1.46 2004/12/06 22:11:47 hajny
|
||||
* one more fix for ExecuteProcess
|
||||
|
||||
Revision 1.45 2004/12/06 18:50:21 hajny
|
||||
|
@ -532,6 +532,22 @@ begin
|
||||
Result:=Dos.Getenv(shortstring(EnvVar));
|
||||
end;
|
||||
|
||||
Function GetEnvironmentVariableCount : Integer;
|
||||
|
||||
begin
|
||||
// Bad bad bad...
|
||||
Result:=Dos.EnvCount;
|
||||
// Result:=FPCCountEnvVar(EnvP);
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
|
||||
begin
|
||||
// Bad bad bad...
|
||||
Result:=Dos.EnvStr(Index);
|
||||
// Result:=FPCGetEnvStrFromP(Envp,Index);
|
||||
end;
|
||||
|
||||
|
||||
{****************************************************************************
|
||||
Initialization code
|
||||
@ -545,7 +561,10 @@ Finalization
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.9 2003-11-26 20:00:19 florian
|
||||
Revision 1.10 2004-12-11 11:32:44 michael
|
||||
+ Added GetEnvironmentVariableCount and GetEnvironmentString calls
|
||||
|
||||
Revision 1.9 2003/11/26 20:00:19 florian
|
||||
* error handling for Variants improved
|
||||
|
||||
Revision 1.8 2003/10/25 23:43:59 hajny
|
||||
|
@ -249,6 +249,18 @@ begin
|
||||
Result:=StrPas(beos.Getenv(PChar(EnvVar)));
|
||||
end;
|
||||
|
||||
Function GetEnvironmentVariableCount : Integer;
|
||||
|
||||
begin
|
||||
Result:=FPCCountEnvVar(EnvP);
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
|
||||
begin
|
||||
Result:=FPCGetEnvStrFromP(Envp,Index);
|
||||
end;
|
||||
|
||||
function ExecuteProcess(Const Path: AnsiString; Const ComLine: AnsiString):integer;
|
||||
|
||||
var
|
||||
@ -304,7 +316,10 @@ Finalization
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.5 2004-02-15 21:36:10 hajny
|
||||
Revision 1.6 2004-12-11 11:32:44 michael
|
||||
+ Added GetEnvironmentVariableCount and GetEnvironmentString calls
|
||||
|
||||
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
|
||||
|
@ -874,6 +874,19 @@ begin
|
||||
Result:=StrPas(BaseUnix.FPGetenv(PChar(EnvVar)));
|
||||
end;
|
||||
|
||||
Function GetEnvironmentVariableCount : Integer;
|
||||
|
||||
begin
|
||||
Result:=FPCCountEnvVar(EnvP);
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
|
||||
begin
|
||||
Result:=FPCGetEnvStrFromP(Envp,Index);
|
||||
end;
|
||||
|
||||
|
||||
{$define FPC_USE_FPEXEC} // leave the old code under IFDEF for a while.
|
||||
function ExecuteProcess(Const Path: AnsiString; Const ComLine: AnsiString):integer;
|
||||
var
|
||||
@ -1091,7 +1104,10 @@ end.
|
||||
{
|
||||
|
||||
$Log$
|
||||
Revision 1.54 2004-11-14 15:10:44 marco
|
||||
Revision 1.55 2004-12-11 11:32:44 michael
|
||||
+ Added GetEnvironmentVariableCount and GetEnvironmentString calls
|
||||
|
||||
Revision 1.54 2004/11/14 15:10:44 marco
|
||||
* resolution of now increased to ms
|
||||
|
||||
Revision 1.53 2004/11/06 17:24:07 marco
|
||||
|
@ -739,27 +739,24 @@ end;
|
||||
****************************************************************************}
|
||||
|
||||
Function GetEnvironmentVariable(Const EnvVar : String) : String;
|
||||
var
|
||||
hp : ppchar;
|
||||
lenvvar,hs : string;
|
||||
eqpos : longint;
|
||||
|
||||
begin
|
||||
lenvvar:=upcase(envvar);
|
||||
hp:=envp;
|
||||
Result:='';
|
||||
while assigned(hp^) do
|
||||
begin
|
||||
hs:=strpas(hp^);
|
||||
eqpos:=pos('=',hs);
|
||||
if upcase(copy(hs,1,eqpos-1))=lenvvar then
|
||||
begin
|
||||
Result:=copy(hs,eqpos+1,length(hs)-eqpos);
|
||||
exit;
|
||||
end;
|
||||
inc(hp);
|
||||
end;
|
||||
Result:=FPCGetEnvVarFromP(envp,EnvVar);
|
||||
end;
|
||||
|
||||
Function GetEnvironmentVariableCount : Integer;
|
||||
|
||||
begin
|
||||
Result:=FPCCountEnvVar(EnvP);
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
|
||||
begin
|
||||
Result:=FPCGetEnvStrFromP(Envp,Index);
|
||||
end;
|
||||
|
||||
|
||||
function ExecuteProcess(Const Path: AnsiString; Const ComLine: AnsiString):integer;
|
||||
|
||||
var
|
||||
@ -881,7 +878,10 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.5 2004-02-15 21:36:10 hajny
|
||||
Revision 1.6 2004-12-11 11:32:44 michael
|
||||
+ Added GetEnvironmentVariableCount and GetEnvironmentString calls
|
||||
|
||||
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
|
||||
|
@ -675,6 +675,45 @@ begin
|
||||
FreeEnvironmentStrings(p);
|
||||
end;
|
||||
|
||||
Function GetEnvironmentVariableCount : Integer;
|
||||
|
||||
var
|
||||
hp,p : pchar;
|
||||
begin
|
||||
Result:=0;
|
||||
p:=GetEnvironmentStrings;
|
||||
hp:=p;
|
||||
If (Hp<>Nil) then
|
||||
while hp^<>#0 do
|
||||
begin
|
||||
Inc(Result);
|
||||
hp:=hp+strlen(hp)+1;
|
||||
end;
|
||||
FreeEnvironmentStrings(p);
|
||||
end;
|
||||
|
||||
Function GetEnvironmentString(Index : Integer) : String;
|
||||
|
||||
var
|
||||
hp,p : pchar;
|
||||
begin
|
||||
Result:='';
|
||||
p:=GetEnvironmentStrings;
|
||||
hp:=p;
|
||||
If (Hp<>Nil) then
|
||||
begin
|
||||
while hp^<>#0 and (Index>1) do
|
||||
begin
|
||||
Dex(Index);
|
||||
hp:=hp+strlen(hp)+1;
|
||||
end;
|
||||
If (hp^<>#0) then
|
||||
Result:=StrPas(HP);
|
||||
end;
|
||||
FreeEnvironmentStrings(p);
|
||||
end;
|
||||
|
||||
|
||||
function ExecuteProcess(Const Path: AnsiString; Const ComLine: AnsiString):integer;
|
||||
var
|
||||
SI: TStartupInfo;
|
||||
@ -966,7 +1005,10 @@ Finalization
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.37 2004-08-06 13:23:21 michael
|
||||
Revision 1.38 2004-12-11 11:32:44 michael
|
||||
+ Added GetEnvironmentVariableCount and GetEnvironmentString calls
|
||||
|
||||
Revision 1.37 2004/08/06 13:23:21 michael
|
||||
+ Ver 1.0 does not handle initialized variables well
|
||||
|
||||
Revision 1.36 2004/08/05 12:55:29 michael
|
||||
|
Loading…
Reference in New Issue
Block a user