Prechádzať zdrojové kódy

* move TZSeconds to lcommon

git-svn-id: trunk@5356 -
Almindor 19 rokov pred
rodič
commit
6d34a8a864
3 zmenil súbory, kde vykonal 29 pridanie a 40 odobranie
  1. 25 2
      fcl/lnet/lcommon.pp
  2. 3 0
      fcl/lnet/lhttp.pp
  3. 1 38
      fcl/lnet/lhttputil.pp

+ 25 - 2
fcl/lnet/lcommon.pp

@@ -93,11 +93,13 @@ type
 
   function IsBlockError(const anError: Integer): Boolean; inline;
 
+  function TZSeconds: Integer; inline;
+
   function StrToHostAddr(const IP: string): Cardinal; inline;
   function HostAddrToStr(const Entry: Cardinal): string; inline;
   function StrToNetAddr(const IP: string): Cardinal; inline;
   function NetAddrToStr(const Entry: Cardinal): string; inline;
-
+  
 implementation
 
 {$IFNDEF UNIX}
@@ -131,6 +133,17 @@ begin
   Result:=Tmp;
 end;
 
+function TZSeconds: integer; inline;
+var
+  lInfo: Windows.TIME_ZONE_INFORMATION;
+begin
+  { lInfo.Bias is in minutes }
+  if Windows.GetTimeZoneInformation(@lInfo) <> $FFFFFFFF then
+    Result := lInfo.Bias * 60
+  else
+    Result := 0;
+end;
+
 {$ELSE}
 
 function LStrError(const Ernum: Longint; const UseUTF8: Boolean = False): string;
@@ -138,6 +151,11 @@ begin
   Result:=IntToStr(Ernum); // TODO: fix for non-windows winsock users
 end;
 
+function TZSeconds: integer; inline;
+begin
+  Result:=0; // todo: fix for non-windows non unix
+end;
+
 {$ENDIF}
 
 function LSocketError: Longint;
@@ -220,7 +238,7 @@ end;
 {$ELSE}
 // unix
 uses
-  Errors;
+  Errors, UnixUtil;
 
 function LStrError(const Ernum: Longint; const UseUTF8: Boolean = False): string;
 begin
@@ -282,6 +300,11 @@ begin
   Result:=(anError = ESysEWOULDBLOCK) or (anError = ESysENOBUFS);
 end;
 
+function TZSeconds: Integer; inline;
+begin
+  Result := unixutil.TZSeconds;
+end;
+
 {$ENDIF}
 
 function StrToHostAddr(const IP: string): Cardinal; inline;

+ 3 - 0
fcl/lnet/lhttp.pp

@@ -477,6 +477,9 @@ type
 
 implementation
 
+uses
+  lCommon;
+
 const
   RequestBufferSize = 1024;
   DataBufferSize = 16*1024;

+ 1 - 38
fcl/lnet/lhttputil.pp

@@ -30,9 +30,6 @@ interface
 
 uses
   sysutils, 
-{$ifdef UNIX}
-  unixutil,
-{$endif}
   strutils;
 
 const
@@ -43,7 +40,6 @@ const
 type
   PSearchRec = ^TSearchRec;
 
-function TZSeconds: integer;
 function GMTToLocalTime(ADateTime: TDateTime): TDateTime;
 function LocalTimeToGMT(ADateTime: TDateTime): TDateTime;
 function TryHTTPDateStrToDateTime(ADateStr: pchar; var ADest: TDateTime): boolean;
@@ -57,41 +53,8 @@ function HexToNum(AChar: char): byte;
 
 implementation
 
-{$ifdef WINDOWS}
-
 uses
-  windows;
-
-function TZSeconds: integer;
-var
-  lInfo: Windows.TIME_ZONE_INFORMATION;
-begin
-  { lInfo.Bias is in minutes }
-  if Windows.GetTimeZoneInformation(@lInfo) <> $FFFFFFFF then
-    Result := lInfo.Bias * 60
-  else
-    Result := 0;
-end;
-
-{$else}
-
-{$ifdef UNIX}
-
-function TZSeconds: integer; inline;
-begin
-  Result := unixutil.TZSeconds;
-end;
-
-{$else}
-
-function TZSeconds: integer; inline;
-begin
-  Result := 0; // TODO: implement for non windows, non unix
-end;
-
-{$endif}
-
-{$endif}
+  lCommon;
 
 function GMTToLocalTime(ADateTime: TDateTime): TDateTime;
 begin