\r
interface\r
\r
-uses binipstuff,classes,lcore;\r
+uses binipstuff,classes,lcore,pgtypes;\r
\r
{$include lcoreconfig.inc}\r
\r
//on failure a null string or zeroed out binip will be retuned and error will be\r
//set to a windows error code (error will be left untouched under non error\r
//conditions).\r
-function winforwardlookuplist(name : string;familyhint:integer;var error : integer) : tbiniplist;\r
-function winreverselookup(ip:tbinip;var error:integer):string;\r
+function winforwardlookuplist(name : thostname;familyhint:integer;var error : integer) : tbiniplist;\r
+function winreverselookup(ip:tbinip;var error:integer):thostname;\r
\r
\r
type\r
tdnswinasync=class(tthread)\r
private\r
freverse : boolean;\r
- error : integer;\r
freewhendone : boolean;\r
hadevent : boolean;\r
protected\r
procedure execute; override;\r
public\r
onrequestdone:tsocketevent;\r
- name : string;\r
+ name : thostname;\r
iplist : tbiniplist;\r
\r
- procedure forwardlookup(name:string);\r
+ procedure forwardlookup(name:thostname);\r
procedure reverselookup(ip:tbinip);\r
destructor destroy; override;\r
procedure release;\r
\r
end;\r
\r
+procedure init;\r
+\r
implementation\r
uses\r
- lsocket,pgtypes,sysutils,winsock,windows,messages;\r
+ { zipplet: moved pgtypes to interface because it's needed for the string definitions }\r
+ lsocket,sysutils,winsock,windows,messages;\r
\r
type\r
//taddrinfo = record; //forward declaration\r
ai_socktype : longint;\r
ai_protocol : longint;\r
ai_addrlen : taddrint;\r
- ai_canonname : pchar;\r
+ ai_canonname : pansichar;\r
ai_addr : pinetsockaddrv;\r
ai_next : paddrinfo;\r
end;\r
ppaddrinfo = ^paddrinfo;\r
- tgetaddrinfo = function(nodename : pchar; servname : pchar; hints : paddrinfo;res : ppaddrinfo) : longint; stdcall;\r
+ tgetaddrinfo = function(nodename : pansichar; servname : pansichar; hints : paddrinfo;res : ppaddrinfo) : longint; stdcall;\r
tfreeaddrinfo = procedure(ai : paddrinfo); stdcall;\r
- tgetnameinfo = function(sa:Pinetsockaddrv;salen : longint; host:pchar;hostlen : longint;serv:pchar;servlen:longint;flags:longint) : longint;stdcall;\r
+ tgetnameinfo = function(sa:Pinetsockaddrv;salen : longint; host:pansichar;hostlen : longint;serv:pansichar;servlen:longint;flags:longint) : longint;stdcall;\r
var\r
getaddrinfo : tgetaddrinfo;\r
freeaddrinfo : tfreeaddrinfo;\r
plongint = ^longint;\r
pplongint = ^plongint;\r
\r
-function v4onlygetaddrinfo(nodename : pchar; servname : pchar; hints : paddrinfo;res : ppaddrinfo) : longint; stdcall;\r
+function v4onlygetaddrinfo(nodename : pansichar; servname : pansichar; hints : paddrinfo;res : ppaddrinfo) : longint; stdcall;\r
var\r
output,prev,first : paddrinfo;\r
hostent : phostent;\r
addrlist:^pointer;\r
begin\r
+ output := nil;\r
if hints.ai_family <> af_inet6 then begin\r
result := 0;\r
\r
if a<b then result := a else result := b;\r
end;\r
\r
-function v4onlygetnameinfo(sa:Pinetsockaddrv;salen : longint; host:pchar;hostlen : longint;serv:pchar;servlen:longint;flags:longint) : longint;stdcall;\r
+function v4onlygetnameinfo(sa:Pinetsockaddrv;salen : longint; host:pansichar;hostlen : longint;serv:pansichar;servlen:longint;flags:longint) : longint;stdcall;\r
var\r
hostent : phostent;\r
bytestocopy : integer;\r
var\r
libraryhandle : hmodule;\r
i : integer;\r
- dllname : string;\r
+ dllname : ansistring;\r
\r
begin\r
if assigned(getaddrinfo) then exit; //procvars already populated\r
for i := 0 to 1 do begin\r
if i=0 then dllname := 'Ws2_32.dll' else dllname := 'Wship6.dll';\r
- libraryhandle := LoadLibrary(pchar(dllname));\r
+ libraryhandle := LoadLibraryA(pansichar(dllname));\r
getaddrinfo := getprocaddress(libraryhandle,'getaddrinfo');\r
freeaddrinfo := getprocaddress(libraryhandle,'freeaddrinfo');\r
getnameinfo := getprocaddress(libraryhandle,'getnameinfo');\r
end;\r
\r
\r
-function winforwardlookuplist(name : string;familyhint:integer;var error : integer) : tbiniplist;\r
+function winforwardlookuplist(name : thostname;familyhint:integer;var error : integer) : tbiniplist;\r
var\r
hints: taddrinfo;\r
res0,res : paddrinfo;\r
hints.ai_canonname := nil;\r
hints.ai_addr := nil;\r
hints.ai_next := nil;\r
- getaddrinforesult := getaddrinfo(pchar(name),'1',@hints,@res);\r
+ getaddrinforesult := getaddrinfo(pansichar(name),'1',@hints,@res);\r
res0 := res;\r
result := biniplist_new;\r
if getaddrinforesult = 0 then begin\r
end;\r
end;\r
\r
-function winreverselookup(ip:tbinip;var error : integer):string;\r
+function winreverselookup(ip:tbinip;var error : integer):thostname;\r
var\r
sa : tinetsockaddrv;\r
getnameinforesult : integer;\r
makeinaddrv(ip,'1',sa);\r
populateprocvars;\r
setlength(result,1025);\r
- getnameinforesult := getnameinfo(@sa,sizeof(tinetsockaddrv),pchar(result),length(result),nil,0,0);\r
+ getnameinforesult := getnameinfo(@sa,sizeof(tinetsockaddrv),pansichar(result),length(result),nil,0,0);\r
if getnameinforesult <> 0 then begin\r
error := getnameinforesult;\r
result := '';\r
if assigned (dwas.onrequestdone) then dwas.onrequestdone(dwas,awparam);\r
dwas.hadevent := true;\r
if dwas.freewhendone then dwas.free;\r
+ result := 0; {added returning 0 when handling --beware}\r
end else begin\r
//not passing unknown messages on to defwindowproc will cause window\r
//creation to fail! --plugwash\r
end;\r
end;\r
\r
-procedure tdnswinasync.forwardlookup(name:string);\r
+procedure tdnswinasync.forwardlookup(name:thostname);\r
begin\r
self.name := name;\r
freverse := false;\r
hbrBackground : 0;\r
lpszMenuName : nil;\r
lpszClassName : 'dnswinClass');\r
+procedure init;\r
begin\r
\r
if Windows.RegisterClass(MyWindowClass) = 0 then halt;\r
nil); { CreateParam }\r
//writeln('dnswin hwnd is ',hwnddnswin);\r
//writeln('last error is ',GetLastError);\r
+end;\r
+\r
+\r
end.\r