X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/6cb6b7ede2d178e03fa817bc28474c175f5a93b9..257fdc360d4c80e606358c108c890c5367436a12:/dnswin.pas diff --git a/dnswin.pas b/dnswin.pas old mode 100755 new mode 100644 index ffe472b..847f0fd --- a/dnswin.pas +++ b/dnswin.pas @@ -2,15 +2,15 @@ unit dnswin; interface -uses binipstuff,classes,lcore; +uses binipstuff,classes,lcore,pgtypes; {$include lcoreconfig.inc} //on failure a null string or zeroed out binip will be retuned and error will be //set to a windows error code (error will be left untouched under non error //conditions). -function winforwardlookuplist(name : string;familyhint:integer;var error : integer) : tbiniplist; -function winreverselookup(ip:tbinip;var error:integer):string; +function winforwardlookuplist(name : thostname;familyhint:integer;var error : integer) : tbiniplist; +function winreverselookup(ip:tbinip;var error:integer):thostname; type @@ -20,7 +20,6 @@ type //release should only be called from the main thread tdnswinasync=class(tthread) private - ipv6preffered : boolean; freverse : boolean; error : integer; freewhendone : boolean; @@ -29,10 +28,10 @@ type procedure execute; override; public onrequestdone:tsocketevent; - name : string; - ip : tbinip; + name : thostname; + iplist : tbiniplist; - procedure forwardlookup(name:string;ipv6preffered:boolean); + procedure forwardlookup(name:thostname); procedure reverselookup(ip:tbinip); destructor destroy; override; procedure release; @@ -43,7 +42,8 @@ type implementation uses - lsocket,pgtypes,sysutils,winsock,windows,messages; + { zipplet: moved pgtypes to interface because it's needed for the string definitions } + lsocket,sysutils,winsock,windows,messages; type //taddrinfo = record; //forward declaration @@ -54,14 +54,14 @@ type ai_socktype : longint; ai_protocol : longint; ai_addrlen : taddrint; - ai_canonname : pchar; + ai_canonname : pansichar; ai_addr : pinetsockaddrv; ai_next : paddrinfo; end; ppaddrinfo = ^paddrinfo; - tgetaddrinfo = function(nodename : pchar; servname : pchar; hints : paddrinfo;res : ppaddrinfo) : longint; stdcall; + tgetaddrinfo = function(nodename : pansichar; servname : pansichar; hints : paddrinfo;res : ppaddrinfo) : longint; stdcall; tfreeaddrinfo = procedure(ai : paddrinfo); stdcall; - tgetnameinfo = function(sa:Pinetsockaddrv;salen : longint; host:pchar;hostlen : longint;serv:pchar;servlen:longint;flags:longint) : longint;stdcall; + tgetnameinfo = function(sa:Pinetsockaddrv;salen : longint; host:pansichar;hostlen : longint;serv:pansichar;servlen:longint;flags:longint) : longint;stdcall; var getaddrinfo : tgetaddrinfo; freeaddrinfo : tfreeaddrinfo; @@ -82,7 +82,7 @@ type plongint = ^longint; pplongint = ^plongint; -function v4onlygetaddrinfo(nodename : pchar; servname : pchar; hints : paddrinfo;res : ppaddrinfo) : longint; stdcall; +function v4onlygetaddrinfo(nodename : pansichar; servname : pansichar; hints : paddrinfo;res : ppaddrinfo) : longint; stdcall; var output,prev,first : paddrinfo; hostent : phostent; @@ -133,7 +133,7 @@ begin if a 0 then begin error := getnameinforesult; result := ''; @@ -281,16 +271,16 @@ begin end; end; -procedure tdnswinasync.forwardlookup(name:string;ipv6preffered:boolean); +procedure tdnswinasync.forwardlookup(name:thostname); begin self.name := name; - self.ipv6preffered := ipv6preffered; freverse := false; resume; end; procedure tdnswinasync.reverselookup(ip:tbinip); begin - self.ip := ip; + iplist := biniplist_new; + biniplist_add(iplist,ip); freverse := true; resume; end; @@ -298,14 +288,14 @@ end; procedure tdnswinasync.execute; var error : integer; - l:tbiniplist; + begin error := 0; if reverse then begin - name := winreverselookup(ip,error); + name := winreverselookup(biniplist_get(iplist,0),error); end else begin - l := winforwardlookuplist(name,0,error); - ip := biniplist_get(l,0); + iplist := winforwardlookuplist(name,0,error); + end; postmessage(hwnddnswin,wm_user,error,taddrint(self)); end;