{$ifdef fpc}\r
{$mode delphi}\r
{$endif}\r
-{$ifdef win32}\r
+{$ifdef mswindows}\r
{$define nosignal}\r
{$endif}\r
interface\r
uses\r
sysutils,\r
- {$ifndef win32}\r
+ {$ifndef mswindows}\r
{$ifdef VER1_0}\r
linux,\r
{$else}\r
- baseunix,unix,unixutil,\r
+ baseunix,unix,unixutil,sockets,\r
{$endif}\r
fd_utils,\r
{$endif}\r
lasterror:integer;\r
destroying:boolean;\r
recvbufsize:integer;\r
- function receivestr:string; virtual;\r
+ function receivestr:tbufferstring; virtual;\r
procedure close;\r
procedure abort;\r
procedure internalclose(error:word); virtual;\r
procedure dup(invalue:longint);\r
\r
function sendflush : integer;\r
- procedure sendstr(const str : string);virtual;\r
- procedure putstringinsendbuffer(const newstring : string);\r
+ procedure sendstr(const str : tbufferstring);virtual;\r
+ procedure putstringinsendbuffer(const newstring : tbufferstring);\r
function send(data:pointer;len:integer):integer;virtual;\r
procedure putdatainsendbuffer(data:pointer;len:integer); virtual;\r
procedure deletebuffereddata;\r
\r
function RealSend(Data : Pointer; Len : Integer) : Integer; //added for bewarehttpd\r
\r
- procedure myfdclose(fd : integer); virtual;{$ifdef win32}abstract;{$endif}\r
- function myfdwrite(fd: LongInt;const buf;size: LongInt):LongInt; virtual;{$ifdef win32}abstract;{$endif}\r
- function myfdread(fd: LongInt;var buf;size: LongInt):LongInt; virtual;{$ifdef win32}abstract;{$endif}\r
+ procedure myfdclose(fd : integer); virtual;{$ifdef mswindows}abstract;{$endif}\r
+ function myfdwrite(fd: LongInt;const buf;size: LongInt):LongInt; virtual;{$ifdef mswindows}abstract;{$endif}\r
+ function myfdread(fd: LongInt;var buf;size: LongInt):LongInt; virtual;{$ifdef mswindows}abstract;{$endif}\r
protected\r
procedure dupnowatch(invalue:longint);\r
end;\r
fontimer : tnotifyevent ;\r
fenabled : boolean ;\r
finterval : integer ; {miliseconds, default 1000}\r
- {$ifndef win32}\r
+ {$ifndef mswindows}\r
procedure resettimes;\r
{$endif}\r
// procedure setinitialevent(newvalue : boolean);\r
{$ifndef nosignal}\r
uses {sockets,}lloopback,lsignal;\r
{$endif}\r
-{$ifdef win32}\r
+{$ifdef mswindows}\r
uses windows,winsock;\r
{$endif}\r
-{$ifndef win32}\r
+{$ifndef mswindows}\r
{$include unixstuff.inc}\r
{$endif}\r
\r
\r
{!!! added sleep call -beware}\r
procedure sleep(i:integer);\r
+{$ifdef mswindows}\r
+begin\r
+ windows.sleep(i);\r
+{$else}\r
var\r
tv:ttimeval;\r
begin\r
- {$ifdef win32}\r
- windows.sleep(i);\r
- {$else}\r
- tv.tv_sec := i div 1000;\r
- tv.tv_usec := (i mod 1000) * 1000;\r
- select(0,nil,nil,nil,@tv);\r
- {$endif}\r
+ tv.tv_sec := i div 1000;\r
+ tv.tv_usec := (i mod 1000) * 1000;\r
+ select(0,nil,nil,nil,@tv);\r
+{$endif}\r
end;\r
\r
+\r
destructor tlcomponent.destroy;\r
begin\r
disconnecttasks(self);\r
eventcore.wmasterclr(fdhandleout);//fd_clr(fdhandleout,fdswmaster);\r
\r
if closehandles then begin\r
- {$ifndef win32}\r
+ {$ifndef mswindows}\r
//anyone remember why this is here? --plugwash\r
fcntl(fdhandlein,F_SETFL,0);\r
{$endif}\r
myfdclose(fdhandlein);\r
if fdhandleout <> fdhandlein then begin\r
- {$ifndef win32}\r
+ {$ifndef mswindows}\r
fcntl(fdhandleout,F_SETFL,0);\r
{$endif}\r
myfdclose(fdhandleout);\r
end;\r
end;\r
\r
-procedure tlasio.sendstr(const str : string);\r
+procedure tlasio.sendstr(const str : tbufferstring);\r
begin\r
putstringinsendbuffer(str);\r
sendflush;\r
end;\r
\r
-procedure tlasio.putstringinsendbuffer(const newstring : string);\r
+procedure tlasio.putstringinsendbuffer(const newstring : tbufferstring);\r
begin\r
if newstring <> '' then putdatainsendbuffer(@newstring[1],length(newstring));\r
end;\r
fdhandlein := invalue;\r
fdhandleout := invalue;\r
eventcore.setfdreverse(fdhandlein,self);\r
- {$ifndef win32}\r
+ {$ifndef mswindows}\r
fcntl(fdhandlein,F_SETFL,OPEN_NONBLOCK);\r
{$endif}\r
state := wsconnected;\r
internalclose(0);\r
\r
end else begin\r
- {$ifdef win32}\r
+ {$ifdef mswindows}\r
if getlasterror=WSAEWOULDBLOCK then begin\r
//the asynchronous nature of windows messages means we sometimes\r
//get here with the buffer full\r
end else\r
{$endif}\r
begin\r
- internalclose({$ifdef win32}getlasterror{$else}linuxerror{$endif});\r
+ internalclose({$ifdef mswindows}getlasterror{$else}linuxerror{$endif});\r
end \r
end;\r
end;\r
\r
internalclose(0);\r
end else if (numread=-1) then begin\r
- {$ifdef win32}\r
+ {$ifdef mswindows}\r
//sometimes on windows we get stale messages due to the inherent delays\r
//in the windows message queue\r
if WSAGetLastError = wsaewouldblock then begin\r
{$endif}\r
begin\r
numread := 0;\r
- internalclose({$ifdef win32}wsagetlasterror{$else}linuxerror{$endif});\r
+ internalclose({$ifdef mswindows}wsagetlasterror{$else}linuxerror{$endif});\r
end;\r
end else if numread > 0 then recvq.add(@tempbuf,numread);\r
end;\r
end;\r
\r
procedure tlasio.flush;\r
-{$ifdef win32}\r
+{$ifdef mswindows}\r
type fdset = tfdset;\r
{$endif}\r
var\r
tlasio(sender).recvq.del(maxlongint);\r
end;\r
\r
-{$ifndef win32}\r
+{$ifndef mswindows}\r
procedure tltimer.resettimes;\r
begin\r
gettimeofday(nextts);\r
if assigned(timerwrapperinterface) then begin\r
timerwrapperinterface.setenabled(wrappedtimer,newvalue);\r
end else begin\r
- {$ifdef win32}\r
+ {$ifdef mswindows}\r
raise exception.create('non wrapper timers are not permitted on windows');\r
{$else}\r
resettimes;\r
if assigned(timerwrapperinterface) then begin\r
timerwrapperinterface.setinterval(wrappedtimer,newvalue);\r
end else begin\r
- {$ifdef win32}\r
+ {$ifdef mswindows}\r
raise exception.create('non wrapper timers are not permitted on windows');\r
{$else}\r
resettimes;\r
if (result > 0) and assigned(onsenddata) then onsenddata(self,result);\r
eventcore.wmasterset(fdhandleout);\r
end;\r
-{$ifndef win32}\r
+{$ifndef mswindows}\r
procedure tlasio.myfdclose(fd : integer);\r
begin\r
fdclose(fd);\r