* clean for non-unix, non-windows platforms

git-svn-id: trunk@5309 -
This commit is contained in:
Almindor 2006-11-10 16:34:04 +00:00
parent 84d5552deb
commit b922783481
6 changed files with 83 additions and 26 deletions

View File

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

View File

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

View File

@ -36,7 +36,27 @@ const
SOL_SOCKET = $ffff;
LMSG = 0;
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;
SOCKET_ERROR = -1;
{$IFDEF LINUX} // TODO: fix this crap, some don't even have MSD_NOSIGNAL
@ -49,17 +69,13 @@ const
LDEFAULT_BACKLOG = 5;
BUFFER_SIZE = 65536;
{$IFDEF WINDOWS}
{$IFNDEF UNIX}
type
TInetSockAddr = TSockAddrin;
{$ENDIF}
{ 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;
const timeout: PTimeVal): 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 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
{$IFDEF WINDOWS}
{$IFNDEF UNIX}
{$IFDEF WINDOWS}
uses
Windows;
@ -109,6 +131,15 @@ begin
Result:=Tmp;
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;
begin
Result:=WSAGetLastError;
@ -187,7 +218,7 @@ begin
end;
{$ELSE}
// unix
uses
Errors;
@ -253,14 +284,9 @@ end;
{$ENDIF}
function NetAddrToStr(const Entry: Cardinal): string; inline;
function StrToHostAddr(const IP: string): Cardinal; inline;
begin
Result:=Sockets.NetAddrToStr(in_addr(Entry));
end;
function StrToNetAddr(const IP: string): Cardinal; inline;
begin
Result:=Cardinal(Sockets.StrToNetAddr(IP));
Result:=Cardinal(Sockets.StrToHostAddr(IP));
end;
function HostAddrToStr(const Entry: Cardinal): string; inline;
@ -268,9 +294,14 @@ begin
Result:=Sockets.HostAddrToStr(in_addr(Entry));
end;
function StrToHostAddr(const IP: string): Cardinal; inline;
function StrToNetAddr(const IP: string): Cardinal; inline;
begin
Result:=Cardinal(Sockets.StrToHostAddr(IP));
Result:=Cardinal(Sockets.StrToNetAddr(IP));
end;
function NetAddrToStr(const Entry: Cardinal): string; inline;
begin
Result:=Sockets.NetAddrToStr(in_addr(Entry));
end;
end.

View File

@ -74,11 +74,22 @@ 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}
function GMTToLocalTime(ADateTime: TDateTime): TDateTime;

View File

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

View File

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