\r
- implementation does not depend on other ipv6 code such as the tin6_addr type,\r
the parameter can also be untyped.\r
-- it is host endian neutral - binary format is aways network order\r
+- it is host endian neutral - binary format is always network order\r
- it supports compression of zeroes\r
- it supports ::ffff:192.168.12.34 style addresses\r
- they are made to do the Right Thing, more efficient implementations are possible\r
end;\r
end;\r
\r
- {run length atleast 2 0 words}\r
+ {run length at least 2 0 words}\r
if (runlength = 1) then begin\r
runlength := 0;\r
runbegin := 0;\r
-\r
{ Copyright (C) 2005 Bas Steendijk\r
For conditions of distribution and use, see copyright notice in zlib_license.txt\r
- which is included in the package\r
- ----------------------------------------------------------------------------- }\r
-\r
+ which is included in the package\r
+ ----------------------------------------------------------------------------- }\r
unit blinklist;\r
+\r
{$ifdef fpc}\r
{$mode delphi}\r
{$endif}\r
mmtime_lastresult := result;\r
end;\r
\r
-{ free pascals tsystemtime is incomaptible with windows api calls\r
+{ free pascals tsystemtime is incompatible with windows api calls\r
so we declare it ourselves - plugwash\r
}\r
{$ifdef fpc}\r
onrequestdone:tsocketevent;\r
\r
//addr and port allow the application to specify a dns server specifically\r
- //for this dnsasync object. This is not a reccomended mode of operation\r
+ //for this dnsasync object. This is not a recommended mode of operation\r
//because it limits the app to one dns server but is kept for compatibility\r
//and special uses.\r
addr,port:ansistring;\r
procedure dnsresultbin(var binip:tbinip); //get result of dnslookup as a tbinip\r
property dnsresultlist : tbiniplist read fresultlist;\r
procedure forwardlookup(const name:ansistring); //start forward lookup,\r
- //preffering ipv4\r
+ //preferring ipv4\r
procedure reverselookup(const binip:tbinip); //start reverse lookup\r
procedure customlookup(const name:ansistring;querytype:integer); //start custom type lookup\r
\r
{\r
\r
code wanting to use this dns system should act as follows (note: app\r
- developers will probablly want to use dnsasync or dnssync or write a similar\r
- wrapper unit of thier own).\r
+ developers will probably want to use dnsasync or dnssync or write a similar\r
+ wrapper unit of their own).\r
\r
for normal lookups call setstate_forward or setstate_reverse to set up the\r
state, for more obscure lookups use setstate_request_init and fill in other\r
- relavent state manually.\r
+ relevant state manually.\r
\r
call state_process which will do processing on the information in the state\r
and return an action\r
action_sendpacket means that dnscore wants the code that calls it to send\r
the packet in sendpacket/sendpacketlen and then start (or go back to) listening\r
for\r
- action_done means the request has completed (either suceeded or failed)\r
+ action_done means the request has completed (either succeeded or failed)\r
\r
callers should resend the last packet they tried to send if they have not\r
been asked to send a new packet for more than some timeout value they choose.\r
following ways.\r
\r
on failure state.resultstr will be an empty string and state.resultbin will\r
- be zeroed out (easilly detected by the fact that it will have a family of 0)\r
+ be zeroed out (easily detected by the fact that it will have a family of 0)\r
\r
on success for a A or AAAA lookup state.resultstr will be an empty string\r
- and state.resultbin will contain the result (note: AAAA lookups require IPV6\r
+ and state.resultbin will contain the result (note: AAAA lookups require IPv6\r
enabled).\r
\r
- if an A lookup fails and the code is built with ipv6 enabled then the code\r
+ if an A lookup fails and the code is built with IPv6 enabled then the code\r
will return any AAAA records with the same name. The reverse does not apply\r
- so if an application preffers IPV6 but wants IPV4 results as well it must\r
- check them seperately.\r
+ so if an application prefers IPv6 but wants IPv4 results as well it must\r
+ check them separately.\r
\r
on success for any other type of lookup state.resultstr will be an empty\r
\r
note the state contains ansistrings, setstate_init with a null name parameter\r
- can be used to clean theese up if required.\r
+ can be used to clean these up if required.\r
\r
- callers may use setstate_failure to mark the state as failed themseleves\r
+ callers may use setstate_failure to mark the state as failed themselves\r
before passing it on to other code, for example this may be done in the event\r
of a timeout.\r
}\r
end;\r
\r
//commenting out functions from interface that do not have documented semantics\r
-//and probablly should not be called from outside this unit, reenable them\r
+//and probably should not be called from outside this unit, reenable them\r
//if you must but please document them at the same time --plugwash\r
\r
//function buildrequest(const name:string;var packet:tdnspacket;requesttype:word):integer;\r
\r
procedure setstate_request_init(const name:ansistring;var state:tdnsstate);\r
\r
-//set up state for a foward lookup. A family value of AF_INET6 will give only\r
+//set up state for a forward lookup. A family value of AF_INET6 will give only\r
//ipv6 results. Any other value will give only ipv4 results\r
procedure setstate_forward(const name:ansistring;var state:tdnsstate;family:integer);\r
\r
goto failure;\r
end;\r
\r
- {do /ets/hosts lookup here}\r
+ {do /etc/hosts lookup here}\r
state.sendpacketlen := buildrequest(state.queryname,state.sendpacket,state.requesttype);\r
if state.sendpacketlen = 0 then begin\r
failurereason := 'building request packet failed';\r
var\r
counter : integer;\r
begin\r
- {override the name server choice here, instead of overriding it whereever it's called\r
+ {override the name server choice here, instead of overriding it wherever it's called\r
setting ID to -1 causes it to be ignored in reportlag}\r
if (overridednsserver <> '') then begin\r
result := ipstrtobinf(overridednsserver);\r
end;\r
\r
if not assigned(dnsserverlag) then populatednsserverlist;\r
- if dnsserverlag.count=0 then raise exception.create('no dns servers availible');\r
+ if dnsserverlag.count=0 then raise exception.create('no dns servers available');\r
id := 0;\r
if dnsserverlag.count >1 then begin\r
for counter := dnsserverlag.count-1 downto 1 do begin\r
\r
//convert a name to an IP\r
//will return v4 or v6 depending on what seems favorable, or manual preference setting\r
-//on error the binip will have a family of 0 (other fiels are also currently\r
+//on error the binip will have a family of 0 (other fields are also currently\r
//zeroed out but may be used for further error information in future)\r
-//timeout is in miliseconds, it is ignored when using windows dns\r
+//timeout is in milliseconds, it is ignored when using windows dns\r
function forwardlookup(name:ansistring;timeout:integer):tbinip;\r
\r
//convert a name to a list of all IP's returned\r
receivebufsize=packetbasesize*8;\r
\r
var\r
- absoloutemaxs:integer=0;\r
+ absolutemaxs:integer=0;\r
\r
type\r
{$ifdef ver1_0}\r
public\r
state : tsocketstate ;\r
ComponentOptions : TWSocketOptions;\r
- fdhandlein : Longint ; {file discriptor}\r
- fdhandleout : Longint ; {file discriptor}\r
+ fdhandlein : Longint ; {file descriptor}\r
+ fdhandleout : Longint ; {file descriptor}\r
\r
onsessionclosed : tsocketevent ;\r
ondataAvailable : tsocketevent ;\r
// finitialevent : boolean ;\r
fontimer : tnotifyevent ;\r
fenabled : boolean ;\r
- finterval : integer ; {miliseconds, default 1000}\r
+ finterval : integer ; {milliseconds, default 1000}\r
{$ifndef mswindows}\r
procedure resettimes;\r
{$endif}\r
procedure setenabled(newvalue : boolean);\r
procedure setinterval(newvalue : integer);\r
public\r
- //making theese public for now, this code should probablly be restructured later though\r
+ //making these public for now, this code should probably be restructured later though\r
prevtimer : tltimer ;\r
nexttimer : tltimer ;\r
nextts : ttimeval ;\r
if (numread=0) and (not mustrefreshfds) then begin\r
{if i remember correctly numread=0 is caused by eof\r
if this isn't dealt with then you get a cpu eating infinite loop\r
- however if onsessionconencted has called processmessages that could\r
+ however if onsessionconnected has called processmessages that could\r
cause us to drop to here with an empty recvq and nothing left to read\r
and we don't want that to cause the socket to close}\r
\r
end else begin\r
currenttasklocal := currenttask; //needed in case called from a task\r
end;\r
- // note i don't bother to sestroy the links here as that will happen when\r
+ // note i don't bother to destroy the links here as that will happen when\r
// the list of tasks is processed anyway\r
while assigned(currenttasklocal) do begin\r
if currenttasklocal.obj = aobj then begin\r
ExtCtrls;\r
{$I unixstuff.inc}\r
var\r
- giochannels : array[0..absoloutemaxs] of pgiochannel;\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
the aim of this unit is to provide randomness in a consistent way, using OS specific methods for seeding\r
\r
this unit uses MD5 for performance and code size, but it is made so it is easy to use a different hash,\r
-as long as it is atleat 128 bits, and a multiple of the "word size" (32 bits)\r
+as long as it is at least 128 bits, and a multiple of the "word size" (32 bits)\r
\r
goals:\r
\r
\r
- for the numbers to be\r
- random: pass diehard and similar tests\r
- - unique: generate UUID's\r
+ - unique: generate UUIDs\r
- secure: difficult for a remote attacker to guess the internal state, even\r
when given some output\r
\r
typical intended uses:\r
- anything that needs random numbers without extreme demands on security or\r
speed should be able to use this\r
- - seeding other (faster) RNG's\r
- - generation of passwords, UUID's, cookies, and session keys\r
+ - seeding other (faster) RNGs\r
+ - generation of passwords, UUIDs, cookies, and session keys\r
- randomizing protocol fields to protect against spoofing attacks\r
- randomness for games\r
\r
this is not intended to be directly used for:\r
-- high securirity purposes (generating RSA root keys etc)\r
+- high security purposes (generating RSA root keys etc)\r
- needing random numbers at very high rates (disk wiping, some simulations, etc)\r
\r
performance:\r
hashpasssize=48; {this number has to be small enough that hashing this size uses only one block transform}\r
\r
var\r
- {the seed part of this buffer must be atleast as big as the OS seed (windows: 104 bytes, unix: 36 bytes)}\r
+ {the seed part of this buffer must be at least as big as the OS seed (windows: 104 bytes, unix: 36 bytes)}\r
pool:array[0..(pooldwords+seeddwords-1)] of wordtype;\r
reseedcountdown:integer;\r
\r
{$include unixstuff.inc}\r
\r
const\r
- absoloutemaxs_select = (sizeof(fdset)*8)-1;\r
+ absolutemaxs_select = (sizeof(fdset)*8)-1;\r
\r
var\r
- fdreverse:array[0..absoloutemaxs_select] of tlasio;\r
+ fdreverse:array[0..absolutemaxs_select] of tlasio;\r
type\r
tselecteventcore=class(teventcore)\r
public\r
procedure processasios(var fdsr,fdsw:fdset);//inline;\r
var\r
currentsocket : tlasio ;\r
- socketcount : integer ; // for debugging perposes :)\r
+ socketcount : integer ; // for debugging purposes :)\r
dw,bt:integer;\r
currentfdword:fdword;\r
fd : integer;\r
//writeln('entering processasios');\r
{ inc(lcoretestcount);}\r
\r
- //the message loop will exit if all lasio's and ltimer's and lsignal's are destroyed\r
+ //the message loop will exit if all lasios and ltimers and lsignals are destroyed\r
//if (not assigned(firstasin)) and (not assigned(firsttimer)) and (not assigned(firstsignal)) then exit;\r
\r
\r
- sockets which are released may not be freed because theyre never processed by the loop\r
made new code for handling this, using asinreleaseflag\r
\r
- - when/why does the mustrefreshfds select apply, sheck if i did it correctly?\r
+ - when/why does the mustrefreshfds select apply, check if i did it correctly?\r
\r
- what happens if calling handlefdtrigger for a socket which does not have an event\r
}\r
\r
repeat\r
\r
- //the message loop will exit if all lasio's and ltimer's and lsignal's are destroyed\r
+ //the message loop will exit if all lasios and ltimers and lsignals are destroyed\r
processtasks;\r
//currenttask := nil;\r
{beware}\r
\r
end else begin\r
gettimeofday(tvnow);\r
- tv_substract(tv,tvnow);\r
+ tv_subtract(tv,tvnow);\r
\r
//writeln('timers active');\r
if tv.tv_sec < 0 then begin\r
procedure tselecteventcore.rmasterset(fd : integer;islistensocket : boolean);\r
begin\r
//writeln('rmasterset called with fd ',fd);\r
- if fd > absoloutemaxs then raise esocketexception.create('file discriptor out of range');\r
+ if fd > absolutemaxs then raise esocketexception.create('file descriptor out of range');\r
if fd > maxs then maxs := fd;\r
if fd_isset(fd,fdsrmaster) then exit;\r
fd_set(fd,fdsrmaster);\r
procedure tselecteventcore.wmasterset(fd : integer);\r
begin\r
//writeln('wmasterset called with fd ',fd);\r
- if fd > absoloutemaxs then raise esocketexception.create('file discriptor out of range');\r
+ if fd > absolutemaxs then raise esocketexception.create('file descriptor out of range');\r
if fd > maxs then maxs := fd;\r
\r
if fd_isset(fd,fdswmaster) then exit;\r
inited := true;\r
eventcore := tselecteventcore.create;\r
\r
- absoloutemaxs := absoloutemaxs_select;\r
+ absolutemaxs := absolutemaxs_select;\r
\r
maxs := 0;\r
fd_zero(fdsrmaster);\r
if readtrigger or writetrigger then lasio.handlefdtrigger(readtrigger,writetrigger);\r
end;\r
// don't reset the event manually for listen sockets to avoid unwanted\r
- // extra onsessionavailible events\r
+ // extra onsessionavailable events\r
if (taddrint(findtree(@fdwatches,inttostr(socket))) and (FD_ACCEPT)) = 0 then dowsaasyncselect(socket,0,0); // if not a listen socket reset watches\r
end;\r
end else if (ahwnd=hwndlcore) and (aumsg=wm_dotasks) then begin\r
timerwrapperinterface := twintimerwrapperinterface.create(nil);\r
\r
WSAStartup(2, GInitData);\r
- absoloutemaxs := maxlongint;\r
+ absolutemaxs := maxlongint;\r
\r
wcoreinit;\r
\r
----------------------------------------------------------------------------- }\r
\r
//this unit provides a rough approximation of windows messages on linux\r
-//it is usefull for multithreaded applications on linux to communicate back to\r
+//it is useful for multithreaded applications on linux to communicate back to\r
//the main lcore thread\r
//This unit is *nix only, on windows you should use the real thing\r
\r
lcorelinkpiperecv : tlasio;\r
windows : thashtable;\r
//I would rather things crash immediately\r
- //if they use an insufficiant size type\r
+ //if they use an insufficient size type\r
//than crash after over four billion\r
//windows have been made ;)\r
nextwindowhandle : qword = $100000000;\r
//swriteln('duplicate window class registered with different settings');\r
raise exception.create('duplicate window class registered with different settings');\r
end else begin\r
- //swriteln('duplicate window class registered with same settings, tollerated');\r
+ //swriteln('duplicate window class registered with same settings, tolerated');\r
end;\r
end else begin\r
//swriteln('about to allocate memory for new windowclass');\r
window := twindow(findtree(@windows,inttostr(ahwnd)));\r
if window <> nil then begin\r
freemem(window.extrawindowmemory);\r
- //writeln('aboute to delete window from windows structure');\r
+ //writeln('about to delete window from windows structure');\r
deltree(@windows,inttostr(ahwnd));\r
//writeln('deleted window from windows structure');\r
windowthreaddata := tthreaddata(findtree(@threaddata,inttostr(taddrint(window.threadid))));\r
{$endif}\r
\r
// cdecl procedures are not name mangled\r
-// so USING something unlikely to cause colliesions in the global namespace\r
+// so USING something unlikely to cause collisions in the global namespace\r
// is a good idea\r
procedure lsignal_handler( Sig : Integer);cdecl;\r
var\r
currentsignal : tlsignal;\r
begin\r
-// writeln('in lsignal_hanler');\r
+// writeln('in lsignal_handler');\r
currentsignal := firstsignal;\r
while assigned(currentsignal) do begin\r
if assigned(currentsignal.onsignal) then currentsignal.onsignal(currentsignal,sig);\r
if assigned(signalloopback) then begin\r
signalloopback.sendstr(' ');\r
end;\r
-// writeln('left lsignal_hanler');\r
+// writeln('left lsignal_handler');\r
end;\r
\r
{$ifdef freebsd}\r
\r
beware (20030905)\r
* if connect failed (conn refused) set state to connected and call internalclose, to get closed handler (instead of fdclose)\r
-* (lcore) if closing the fd's in internalcose, set fd's to -1 because closing an fd makes it invalid\r
+* (lcore) if closing the fd's in internalclose, set fds to -1 because closing an fd makes it invalid\r
\r
beware (20030927)\r
* fixed: on connect failed, tried to close fdhandle's which were already set to -1, added check\r
\r
//host : THostentry ;\r
\r
- //mainthread : boolean ; //for debuggin only\r
+ //mainthread : boolean ; //for debugging only\r
addr:thostname;\r
port:ansistring;\r
localaddr:thostname;\r
if fdhandlein >= 0 then begin\r
{one *can* get here without fd -beware}\r
eventcore.rmasterclr(fdhandlein);\r
- myfdclose(fdhandlein); // we musnt leak file discriptors\r
+ myfdclose(fdhandlein); // we musnt leak file descriptors\r
eventcore.setfdreverse(fdhandlein,nil);\r
fdhandlein := -1;\r
end;\r
\r
function tlsocket.accept : longint;\r
var\r
- FromAddrSize : LongInt; // i don't realy know what to do with these at this\r
+ FromAddrSize : LongInt; // i don't really know what to do with these at this\r
FromAddr : TInetSockAddrV; // at this point time will tell :)\r
a:integer;\r
begin\r
if result = -1 then begin\r
raise esocketexception.create('error '+inttostr({$ifdef mswindows}getlasterror{$else}socketerror{$endif})+' while accepting');\r
end;\r
- if result > absoloutemaxs then begin\r
+ if result > absolutemaxs then begin\r
myfdclose(result);\r
a := result;\r
{ result := -1;}\r
- raise esocketexception.create('file discriptor out of range: '+inttostr(a));\r
+ raise esocketexception.create('file descriptor out of range: '+inttostr(a));\r
end;\r
end;\r
\r
exit;\r
end;\r
if (state =wsconnecting) and writetrigger then begin\r
- // code for dealing with the reults of a non-blocking connect is\r
+ // code for dealing with the results of a non-blocking connect is\r
// rather complex\r
- // if just write is triggered it means connect suceeded\r
+ // if just write is triggered it means connect succeeded\r
// if both read and write are triggered it can mean 2 things\r
- // 1: connect ok and data availible\r
+ // 1: connect ok and data available\r
// 2: connect fail\r
// to find out which you must read from the socket and look for errors\r
- // there if we read successfully we drop through into the code for fireing\r
+ // there if we read successfully we drop through into the code for firing\r
// the read event\r
if not readtrigger then begin\r
state := wsconnected;\r
exit;\r
end;\r
// if things went well here we are now in the state wsconnected with data sitting in our receive buffer\r
- // so we drop down into the processing for data availible\r
+ // so we drop down into the processing for data available\r
end;\r
if fdhandlein >= 0 then begin\r
if state = wsconnected then begin\r
\r
procedure tv_add(var tv:ttimeval;msec:integer);\r
function tv_compare(const tv1,tv2:ttimeval):boolean;\r
-procedure tv_substract(var tv:ttimeval;const tv2:ttimeval);\r
+procedure tv_subtract(var tv:ttimeval;const tv2:ttimeval);\r
procedure msectotimeval(var tv:ttimeval;msec:integer);\r
\r
//tv_invalidtimebig will always compare as greater than any valid timeval\r
end else result := tv1.tv_sec > tv2.tv_sec;\r
end;\r
\r
-procedure tv_substract(var tv:ttimeval;const tv2:ttimeval);\r
+procedure tv_subtract(var tv:ttimeval;const tv2:ttimeval);\r
begin\r
dec(tv.tv_usec,tv2.tv_usec);\r
if tv.tv_usec < 0 then begin\r
d := -1;\r
for a := bufpointer to b do begin\r
c := buf[a];\r
- //check if the character can possiblly be a line ending before getting\r
+ //check if the character can possibly be a line ending before getting\r
//into the more complex checks that depend on eol type\r
if (c = 10) or (c = 13) then case allowedeol of\r
eoltype_any: begin\r
'', dwstyle, CW_USEDEFAULT, CW_USEDEFAULT,100, 100, hwnd(0), 0, HInstance, nil);\r
//swriteln('about to check result of createwindowex');\r
if hWndMain = hwnd(0) then raise exception.create('CreateWindowEx failed');\r
- //swriteln('about to store reference to self in extra windo memory');\r
+ //swriteln('about to store reference to self in extra window memory');\r
setwindowlongptr(hwndmain,0,taddrint(self));\r
//swriteln('finished twindowobject.create , hwndmain='+inttohex(taddrint(hwndmain),16));\r
end;\r
initialdone:boolean;\r
prevtimer:tltimer;\r
nexttimer:tltimer;\r
- interval:integer; {miliseconds, default 1000}\r
+ interval:integer; {milliseconds, default 1000}\r
nextts:integer;\r
property enabled:boolean read fenabled write setenabled;\r
constructor create(aowner:tcomponent);override;\r
var\r
hwndwcore:hwnd;\r
firsttimer:tltimer;\r
- timesubstract:integer;\r
+ timesubtract:integer;\r
firsttask,lasttask,currenttask:tltask;\r
\r
procedure tlcomponent.release;\r
end;\r
\r
tvnow := timegettime;\r
- if (tvnow and ((-1) shl rollover_bits)) <> timesubstract then begin\r
+ if (tvnow and ((-1) shl rollover_bits)) <> timesubtract then begin\r
currenttimer := firsttimer;\r
while assigned(currenttimer) do begin\r
dec(currenttimer.nextts,(1 shl rollover_bits));\r
currenttimer := currenttimer.nexttimer;\r
end;\r
- timesubstract := tvnow and ((-1) shl rollover_bits);\r
+ timesubtract := tvnow and ((-1) shl rollover_bits);\r
end;\r
tvnow := tvnow and ((1 shl rollover_bits)-1);\r
\r
end else begin\r
currenttasklocal := currenttask; //needed in case called from a task\r
end;\r
- // note i don't bother to sestroy the links here as that will happen when\r
+ // note i don't bother to destroy the links here as that will happen when\r
// the list of tasks is processed anyway\r
while assigned(currenttasklocal) do begin\r
if currenttasklocal.obj = aobj then begin\r
----------------------------------------------------------------------------- } \r
\r
unit wmessages;\r
-//this unit contains varions functions and types to make it easier to write\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
\r
interface\r