Browse Source

* clean for non-unix, non-windows platforms

git-svn-id: trunk@5309 -
Almindor 19 years ago
parent
commit
b922783481

+ 1 - 1
fcl/lnet/examples/lftp/lftpclient.pp

@@ -233,7 +233,7 @@ end;
 
 
 function TClient.UserString: string;
 function TClient.UserString: string;
 begin
 begin
-  {$ifdef win32}
+  {$ifdef WINDOWS}
     Result:='USERNAME';
     Result:='USERNAME';
   {$else}
   {$else}
     Result:='USER';
     Result:='USER';

+ 3 - 3
fcl/lnet/examples/lhttp/fphttpd.pp

@@ -27,7 +27,7 @@ program fphttpd;
 
 
 uses
 uses
   SysUtils, Classes, lNet,
   SysUtils, Classes, lNet,
-{$ifndef WINDOWS}
+{$ifdef UNIX}
   BaseUnix, Errors,
   BaseUnix, Errors,
 {$endif}
 {$endif}
   lhttp, lwebserver, lHTTPSettings, lSpawnFCGI;
   lhttp, lwebserver, lHTTPSettings, lSpawnFCGI;
@@ -98,7 +98,7 @@ end;
 
 
 procedure HandleSignals;
 procedure HandleSignals;
 begin
 begin
-  {$ifndef WINDOWS}
+  {$ifdef UNIX}
   FpSignal(SIGTERM, @HandleTermSignal);
   FpSignal(SIGTERM, @HandleTermSignal);
   FpSignal(SIGINT, @HandleTermSignal);
   FpSignal(SIGINT, @HandleTermSignal);
   FpSignal(SIGHUP, signalhandler(SIG_IGN));
   FpSignal(SIGHUP, signalhandler(SIG_IGN));
@@ -107,7 +107,7 @@ begin
 end;
 end;
 
 
 function Daemonize: Integer;
 function Daemonize: Integer;
-  {$ifndef WINDOWS}
+  {$ifdef UNIX}
 var
 var
   PID: TPid;
   PID: TPid;
 begin
 begin

+ 48 - 17
fcl/lnet/lcommon.pp

@@ -36,7 +36,27 @@ const
   SOL_SOCKET = $ffff;
   SOL_SOCKET = $ffff;
   LMSG = 0;
   LMSG = 0;
   SOCKET_ERROR = WinSock2.SOCKET_ERROR;
   SOCKET_ERROR = WinSock2.SOCKET_ERROR;
-  {$ELSE}
+  {$ENDIF}
+
+  {$IFDEF OS2}
+  SOL_SOCKET = WinSock.SOL_SOCKET;
+  LMSG = 0;
+  SOCKET_ERROR = WinSock.SOCKET_ERROR;
+  {$ENDIF}
+
+  {$IFDEF NETWARE}
+  SOL_SOCKET = WinSock.SOL_SOCKET;
+  LMSG = 0;
+  SOCKET_ERROR = WinSock.SOCKET_ERROR;
+  {$ENDIF}
+
+  {$IFDEF NETWLIBC}
+  SOL_SOCKET = WinSock.SOL_SOCKET;
+  LMSG = 0;
+  SOCKET_ERROR = WinSock.SOCKET_ERROR;
+  {$ENDIF}
+
+  {$IFDEF UNIX}
   INVALID_SOCKET = -1;
   INVALID_SOCKET = -1;
   SOCKET_ERROR = -1;
   SOCKET_ERROR = -1;
     {$IFDEF LINUX} // TODO: fix this crap, some don't even have MSD_NOSIGNAL
     {$IFDEF LINUX} // TODO: fix this crap, some don't even have MSD_NOSIGNAL
@@ -49,17 +69,13 @@ const
   LDEFAULT_BACKLOG = 5;
   LDEFAULT_BACKLOG = 5;
   BUFFER_SIZE = 65536;
   BUFFER_SIZE = 65536;
   
   
-  {$IFDEF WINDOWS}
+  {$IFNDEF UNIX}
 type
 type
   TInetSockAddr = TSockAddrin;
   TInetSockAddr = TSockAddrin;
   {$ENDIF}
   {$ENDIF}
   
   
   { Base functions }
   { Base functions }
-  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;
-  {$IFDEF WINDOWS}
+  {$IFNDEF UNIX}
   function fpSelect(const nfds: Integer; const readfds, writefds, exceptfds: PFDSet;
   function fpSelect(const nfds: Integer; const readfds, writefds, exceptfds: PFDSet;
                     const timeout: PTimeVal): Integer; inline;
                     const timeout: PTimeVal): Integer; inline;
   function fpFD_ISSET(const Socket: Integer; var FDSet: TFDSet): Integer; inline;
   function fpFD_ISSET(const Socket: Integer; var FDSet: TFDSet): Integer; inline;
@@ -77,10 +93,16 @@ type
 
 
   function IsBlockError(const anError: Integer): Boolean; inline;
   function IsBlockError(const anError: Integer): Boolean; 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
 implementation
 
 
-{$IFDEF WINDOWS}
+{$IFNDEF UNIX}
 
 
+{$IFDEF WINDOWS}
 uses
 uses
   Windows;
   Windows;
 
 
@@ -109,6 +131,15 @@ begin
   Result:=Tmp;
   Result:=Tmp;
 end;
 end;
 
 
+{$ELSE}
+
+function LStrError(const Ernum: Longint; const UseUTF8: Boolean = False): string;
+begin
+  Result:=IntToStr(Ernum); // TODO: fix for non-windows winsock users
+end;
+
+{$ENDIF}
+
 function LSocketError: Longint;
 function LSocketError: Longint;
 begin
 begin
   Result:=WSAGetLastError;
   Result:=WSAGetLastError;
@@ -187,7 +218,7 @@ begin
 end;
 end;
 
 
 {$ELSE}
 {$ELSE}
-
+// unix
 uses
 uses
   Errors;
   Errors;
 
 
@@ -253,24 +284,24 @@ end;
 
 
 {$ENDIF}
 {$ENDIF}
 
 
-function NetAddrToStr(const Entry: Cardinal): string; inline;
+function StrToHostAddr(const IP: string): Cardinal; inline;
 begin
 begin
-  Result:=Sockets.NetAddrToStr(in_addr(Entry));
+  Result:=Cardinal(Sockets.StrToHostAddr(IP));
 end;
 end;
 
 
-function StrToNetAddr(const IP: string): Cardinal; inline;
+function HostAddrToStr(const Entry: Cardinal): string; inline;
 begin
 begin
-  Result:=Cardinal(Sockets.StrToNetAddr(IP));
+  Result:=Sockets.HostAddrToStr(in_addr(Entry));
 end;
 end;
 
 
-function HostAddrToStr(const Entry: Cardinal): string; inline;
+function StrToNetAddr(const IP: string): Cardinal; inline;
 begin
 begin
-  Result:=Sockets.HostAddrToStr(in_addr(Entry));
+  Result:=Cardinal(Sockets.StrToNetAddr(IP));
 end;
 end;
 
 
-function StrToHostAddr(const IP: string): Cardinal; inline;
+function NetAddrToStr(const Entry: Cardinal): string; inline;
 begin
 begin
-  Result:=Cardinal(Sockets.StrToHostAddr(IP));
+  Result:=Sockets.NetAddrToStr(in_addr(Entry));
 end;
 end;
 
 
 end.
 end.

+ 11 - 0
fcl/lnet/lhttputil.pp

@@ -74,11 +74,22 @@ end;
 
 
 {$else}
 {$else}
 
 
+{$ifdef UNIX}
+
 function TZSeconds: integer; inline;
 function TZSeconds: integer; inline;
 begin
 begin
   Result := unixutil.TZSeconds;
   Result := unixutil.TZSeconds;
 end;
 end;
 
 
+{$else}
+
+function TZSeconds: integer; inline;
+begin
+  Result := 0; // TODO: implement for non windows, non unix
+end;
+
+{$endif}
+
 {$endif}
 {$endif}
 
 
 function GMTToLocalTime(ADateTime: TDateTime): TDateTime;
 function GMTToLocalTime(ADateTime: TDateTime): TDateTime;

+ 3 - 3
fcl/lnet/lspawnfcgi.pp

@@ -11,10 +11,10 @@ uses
 
 
 implementation
 implementation
 
 
-{$ifdef WINDOWS}
-  {$i lspawnfcgiwin.inc}
-{$else}
+{$ifdef UNIX}
   {$i lspawnfcgiunix.inc}
   {$i lspawnfcgiunix.inc}
+{$else}
+  {$i lspawnfcgiwin.inc}
 {$endif}
 {$endif}
 
 
 end.
 end.

+ 16 - 1
fcl/lnet/sys/osunits.inc

@@ -1,7 +1,22 @@
 {$ifdef WINDOWS}
 {$ifdef WINDOWS}
   Winsock2,
   Winsock2,
-{$else}
+{$endif}
+
+{$ifdef UNIX}
   BaseUnix, NetDB,
   BaseUnix, NetDB,
 {$endif}
 {$endif}
+
+{$ifdef NETWARE}
+  WinSock,
+{$endif}
+
+{$ifdef OS2}
+  WinSock,
+{$endif}
+
+{$ifdef NETWLIBC}
+  WinSock,
+{$endif}
+
   SysUtils, Sockets;
   SysUtils, Sockets;