\r
unit bsearchtree;\r
\r
+{$ifdef fpc}\r
+ {$mode delphi}\r
+{$endif}\r
interface\r
\r
uses blinklist;\r
\r
\r
unit btime;\r
-\r
+{$ifdef fpc}\r
+ {$mode delphi}\r
+{$endif}\r
interface\r
\r
{$ifdef mswindows}\r
\r
implementation\r
\r
-{$ifdef fpc}\r
- {$mode delphi}\r
-{$endif}\r
+\r
\r
uses\r
{$ifdef UNIX}\r
//not seem to have any form of retry code.\r
\r
unit dnsasync;\r
-\r
+{$ifdef fpc}\r
+ {$mode delphi}\r
+{$endif}\r
interface\r
\r
uses\r
+++ /dev/null
-{ Copyright (C) 2005 Bas Steendijk and Peter Green\r
- For conditions of distribution and use, see copyright notice in zlib_license.txt\r
- which is included in the package\r
- ----------------------------------------------------------------------------- }\r
- \r
-unit lcoregtklaz;\r
-{$mode delphi}\r
-interface\r
- \r
-uses baseunix,unix,glib, gdk, gtk,lcore,forms,fd_utils,classes;\r
-//procedure lcoregtklazrun;\r
-const\r
- G_IO_IN=1;\r
- G_IO_OUT=4;\r
- G_IO_PRI=2;\r
- G_IO_ERR=8;\r
-\r
- G_IO_HUP=16;\r
- G_IO_NVAL=32;\r
-type\r
- tlaztimerwrapperinterface=class(ttimerwrapperinterface)\r
- public\r
- function createwrappedtimer : tobject;override;\r
-// procedure setinitialevent(wrappedtimer : tobject;newvalue : boolean);override;\r
- procedure setontimer(wrappedtimer : tobject;newvalue:tnotifyevent);override;\r
- procedure setenabled(wrappedtimer : tobject;newvalue : boolean);override;\r
- procedure setinterval(wrappedtimer : tobject;newvalue : integer);override;\r
- end;\r
-\r
-procedure lcoregtklazinit;\r
-implementation\r
- uses\r
- ExtCtrls;\r
-{$I unixstuff.inc}\r
-var\r
- giochannels : array[0..absolutemaxs] of pgiochannel;\r
-\r
-function iocallback(source:PGIOChannel; condition:TGIOCondition; data:gpointer):gboolean;cdecl;\r
-// return true if we want the callback to stay\r
-var\r
- fd : integer ;\r
- fdsrlocal , fdswlocal : fdset ;\r
- currentasio : tlasio ;\r
-begin\r
- fd := g_io_channel_unix_get_fd(source);\r
- fd_zero(fdsrlocal);\r
- fd_set(fd,fdsrlocal);\r
- fdswlocal := fdsrlocal;\r
- select(fd+1,@fdsrlocal,@fdswlocal,nil,0);\r
- if fd_isset(fd,fdsrlocal) or fd_isset(fd,fdsrlocal) then begin\r
- currentasio := fdreverse[fd];\r
- if assigned(currentasio) then begin\r
- currentasio.handlefdtrigger(fd_isset(currentasio.fdhandlein,fdsrlocal),fd_isset(currentasio.fdhandleout,fdswlocal));\r
- end else begin\r
- rmasterclr(fd);\r
- wmasterclr(fd);\r
- end;\r
- end;\r
- case condition of\r
- G_IO_IN : begin\r
- result := rmasterisset(fd);\r
- end;\r
- G_IO_OUT : begin\r
- result := wmasterisset(fd);\r
- end;\r
- end;\r
-end;\r
-\r
-procedure gtkrmasterset(fd : integer);\r
-begin\r
- if not assigned(giochannels[fd]) then giochannels[fd] := g_io_channel_unix_new(fd);\r
- g_io_add_watch(giochannels[fd],G_IO_IN,iocallback,nil);\r
-end;\r
-\r
-procedure gtkrmasterclr(fd: integer);\r
-begin\r
-end;\r
- \r
-procedure gtkwmasterset(fd : integer);\r
-begin\r
- if not assigned(giochannels[fd]) then giochannels[fd] := g_io_channel_unix_new(fd);\r
- g_io_add_watch(giochannels[fd],G_IO_OUT,iocallback,nil);\r
-end;\r
-\r
-procedure gtkwmasterclr(fd: integer);\r
-begin\r
-end;\r
-\r
-type\r
- tsc = class\r
- procedure dotasksandsink(sender:tobject;error:word);\r
- end;\r
-var\r
- taskloopback : tlloopback;\r
- sc : tsc;\r
-procedure tsc.dotasksandsink(sender:tobject;error:word);\r
-begin\r
- with tlasio(sender) do begin\r
- sinkdata(sender,error);\r
- processtasks;\r
- end;\r
-end;\r
-procedure gtkaddtask(ahandler:ttaskevent;aobj:tobject;awparam,alparam:longint);\r
-begin\r
- taskloopback.sendstr(' ');\r
- \r
-end;\r
-\r
-procedure lcoregtklazinit;\r
-begin\r
- onrmasterset := gtkrmasterset;\r
- onrmasterclr := gtkrmasterclr;\r
- onwmasterset := gtkwmasterset;\r
- onwmasterclr := gtkwmasterclr;\r
- onaddtask := gtkaddtask;\r
- taskloopback := tlloopback.create(nil);\r
- taskloopback.ondataavailable := sc.dotasksandsink;\r
- timerwrapperinterface := tlaztimerwrapperinterface.create(nil);\r
-end;\r
-\r
-function tlaztimerwrapperinterface.createwrappedtimer : tobject;\r
-begin\r
- result := ttimer.create(nil);\r
-end;\r
-procedure tlaztimerwrapperinterface.setontimer(wrappedtimer : tobject;newvalue:tnotifyevent);\r
-begin\r
- ttimer(wrappedtimer).ontimer := newvalue;\r
-end;\r
-procedure tlaztimerwrapperinterface.setenabled(wrappedtimer : tobject;newvalue : boolean);\r
-begin\r
- ttimer(wrappedtimer).enabled := newvalue;\r
-end;\r
-\r
-\r
-procedure tlaztimerwrapperinterface.setinterval(wrappedtimer : tobject;newvalue : integer);\r
-begin\r
- ttimer(wrappedtimer).interval := newvalue;\r
-end;\r
-\r
-\r
-end.\r
-\r
--- /dev/null
+{ Copyright (C) 2005-2017 Robin Green, Bas Steendijk, Peter Green\r
+ For conditions of distribution and use, see copyright notice in zlib_license.\r
+txt\r
+ which is included in the package\r
+ -----------------------------------------------------------------------------\r
+}\r
+\r
+unit lcorelazarus;\r
+{$mode delphi}\r
+interface\r
+\r
+uses\r
+ lcore,\r
+ Classes, SysUtils,Forms,fd_utils,LCLIntf,InterfaceBase,ExtCtrls;\r
+\r
+\r
+procedure lcoreinit;\r
+\r
+implementation\r
+const\r
+ absolutemaxs_select = (sizeof(fdset)*8)-1;\r
+\r
+var\r
+ fdreverse:array[0..absolutemaxs_select] of tlasio;\r
+ fdEventHandlers:array[0..absolutemaxs_select] of PEventHandler;\r
+ fdflags:array[0..absolutemaxs_select] of byte;\r
+ tasksoutstanding : boolean;\r
+type\r
+ tlazaruseventcore=class(teventcore)\r
+ public\r
+ procedure processmessages; override;\r
+ procedure messageloop; override;\r
+ procedure exitmessageloop;override;\r
+ procedure setfdreverse(fd : integer;reverseto : tlasio); override;\r
+ procedure rmasterset(fd : integer;islistensocket : boolean); override;\r
+ procedure rmasterclr(fd: integer); override;\r
+ procedure wmasterset(fd : integer); override;\r
+ procedure wmasterclr(fd: integer); override;\r
+ procedure WaitHandleEvent(AData: PtrInt; AFlags: dword);\r
+ procedure taskcb(Data: PtrInt);\r
+ end;\r
+\r
+ tlaztimerwrapperinterface=class(ttimerwrapperinterface)\r
+ public\r
+ function createwrappedtimer : tobject;override;\r
+// procedure setinitialevent(wrappedtimer : tobject;newvalue : boolean);override;\r
+ procedure setontimer(wrappedtimer : tobject;newvalue:tnotifyevent);override;\r
+ procedure setenabled(wrappedtimer : tobject;newvalue : boolean);override;\r
+ procedure setinterval(wrappedtimer : tobject;newvalue : integer);override;\r
+ end;\r
+const\r
+ G_IO_IN = 1;\r
+ G_IO_OUT = 4;\r
+\r
+procedure tlazaruseventcore.taskcb(Data: PtrInt);\r
+begin\r
+\r
+ tasksoutstanding := false;\r
+ processtasks;\r
+end;\r
+\r
+procedure tlazaruseventcore.WaitHandleEvent(AData: PtrInt; AFlags: dword);\r
+var lasio:tlasio;\r
+begin\r
+ lasio:=fdreverse[AData];\r
+ if lasio<>nil then lasio.handlefdtrigger((AFlags and G_IO_IN)<>0,(AFlags and G_IO_OUT)<>0);\r
+end;\r
+\r
+procedure tlazaruseventcore.processmessages;\r
+begin\r
+ Application.ProcessMessages;\r
+end;\r
+procedure tlazaruseventcore.messageloop;\r
+begin\r
+ Application.Run;\r
+end;\r
+procedure tlazaruseventcore.exitmessageloop;\r
+begin\r
+ Application.Terminate;\r
+end;\r
+procedure tlazaruseventcore.setfdreverse(fd : integer;reverseto : tlasio);\r
+begin\r
+ fdreverse[fd] := reverseto;\r
+\r
+end;\r
+procedure addfdflags(fd : integer;flags:byte);\r
+begin\r
+ fdflags[fd]:=fdflags[fd] or flags;\r
+ if fdEventHandlers[fd]=nil then begin\r
+ fdEventHandlers[fd]:=AddEventHandler(fd,flags,tlazaruseventcore(eventcore).WaitHandleEvent,fd);\r
+ end else begin\r
+\r
+ SetEventHandlerFlags(fdEventHandlers[fd], fdflags[fd]);\r
+ end;\r
+end;\r
+\r
+procedure removefdflags(fd : integer;flags:byte);\r
+begin\r
+ if fdEventHandlers[fd]<>nil then begin\r
+ fdflags[fd]:=fdflags[fd] and (not flags);\r
+ if fdflags[fd]=0 then begin\r
+ RemoveEventHandler(fdEventHandlers[fd]);\r
+ fdEventHandlers[fd]:=nil;\r
+ end else begin\r
+\r
+ SetEventHandlerFlags(fdEventHandlers[fd], fdflags[fd]);\r
+ end;\r
+ end;\r
+end;\r
+\r
+procedure tlazaruseventcore.rmasterset(fd : integer;islistensocket : boolean);\r
+begin\r
+ addfdflags(fd,G_IO_IN);\r
+end;\r
+procedure tlazaruseventcore.rmasterclr(fd: integer);\r
+begin\r
+ removefdflags(fd,G_IO_IN);\r
+end;\r
+procedure tlazaruseventcore.wmasterset(fd : integer);\r
+begin\r
+ addfdflags(fd,G_IO_OUT);\r
+\r
+end;\r
+procedure tlazaruseventcore.wmasterclr(fd: integer);\r
+begin\r
+ removefdflags(fd,G_IO_OUT);\r
+end;\r
+\r
+procedure lazaddtask(ahandler:ttaskevent;aobj:tobject;awparam,alparam:longint);\r
+begin\r
+ if not tasksoutstanding then Application.QueueAsyncCall(tlazaruseventcore(eventcore).taskcb,0);\r
+ tasksoutstanding := true;\r
+end;\r
+\r
+function tlaztimerwrapperinterface.createwrappedtimer : tobject;\r
+begin\r
+ result := ttimer.create(nil);\r
+end;\r
+procedure tlaztimerwrapperinterface.setontimer(wrappedtimer : tobject;newvalue:tnotifyevent);\r
+begin\r
+ ttimer(wrappedtimer).ontimer := newvalue;\r
+end;\r
+procedure tlaztimerwrapperinterface.setenabled(wrappedtimer : tobject;newvalue : boolean);\r
+begin\r
+ ttimer(wrappedtimer).enabled := newvalue;\r
+end;\r
+\r
+\r
+procedure tlaztimerwrapperinterface.setinterval(wrappedtimer : tobject;newvalue : integer);\r
+begin\r
+ ttimer(wrappedtimer).interval := newvalue;\r
+end;\r
+var\r
+ inited:boolean;\r
+procedure lcoreinit;\r
+begin\r
+ if (inited) then exit;\r
+ eventcore := tlazaruseventcore.create;\r
+ onaddtask := lazaddtask;\r
+\r
+ absolutemaxs := absolutemaxs_select;\r
+ inited := true;\r
+end;\r
+\r
+end.\r
+\r
}\r
\r
unit lcorelocalips;\r
-\r
+{$ifdef fpc}\r
+ {$mode delphi}\r
+{$endif}\r
interface\r
\r
uses binipstuff,pgtypes;\r
end;\r
{$endif}\r
\r
-end.\r
+end.\r
\ No newline at end of file
//the main lcore thread\r
//This unit is *nix only, on windows you should use the real thing\r
\r
-unit lmessages;\r
+unit lcoremessages;\r
//windows messages like system based on lcore tasks\r
interface\r
\r
----------------------------------------------------------------------------- }\r
\r
unit lcorernd;\r
-\r
+{$ifdef fpc}\r
+ {$mode delphi}\r
+{$endif}\r
interface\r
\r
{$include lcoreconfig.inc}\r
{$ifndef mswindows}\r
,\r
{$ifndef nomessages}\r
- lmessages,\r
+ lcoremessages,\r
unitwindowobject,\r
{$endif}\r
unitfork\r
procedure winaddtask(ahandler:ttaskevent;aobj:tobject;awparam,alparam:longint);\r
begin\r
if not tasksoutstanding then PostMessage(hwndlcore,wm_dotasks,0,0);\r
+ tasksoutstanding := true;\r
end;\r
type\r
twcoretimer = wcore.tltimer;\r
which is included in the package\r
----------------------------------------------------------------------------- }\r
unit unitfork;\r
-\r
+{$ifdef fpc}\r
+ {$mode delphi}\r
+{$endif}\r
interface\r
\r
procedure dofork(const programname:string);\r
{$ifdef mswindows}\r
windows,messages,wmessages,\r
{$else}\r
- lmessages,\r
+ lcoremessages,\r
{$macro on}\r
- {$define windows := lmessages}\r
+ {$define windows := lcoremessages}\r
{$endif}\r
sysutils,\r
pgtypes;\r
\r
unit wmessages;\r
//this unit contains various functions and types to make it easier to write\r
-//code that works with both real windows messages and lmessages\r
+//code that works with both real windows messages and lcoremessages\r
\r
interface\r
uses windows,messages,pgtypes;\r
\r
//according to MS you are supposed to use get/setwindowlongptr to get/set\r
//pointers in extra window memory so your program can be built for win64, this\r
-//is also the only interface to window memory that lmessages offers but delphi\r
+//is also the only interface to window memory that lcoremessages offers but delphi\r
//doesn't define it so alias it to getwindowlong here for win32.\r
{$ifndef win64} //future proofing ;)\r
function getwindowlongptr(ahwnd:hwnd;nindex:integer) : taddrint;\r