From 13da3d2110165e8501869e896f1f17706f2058c1 Mon Sep 17 00:00:00 2001 From: zipplet Date: Tue, 9 Feb 2010 21:43:58 +0000 Subject: [PATCH 1/1] Fix dnscore (non windows API) lookups git-svn-id: file:///svnroot/lcore/branches/delphi2010@69 b1de8a11-f9be-4011-bde0-cc7ace90066a --- dnsasync.pas | 14 +++++++------- dnscore.pas | 14 +++++++------- dnssync.pas | 20 ++++++++++---------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/dnsasync.pas b/dnsasync.pas index fab858d..4efc205 100644 --- a/dnsasync.pas +++ b/dnsasync.pas @@ -60,18 +60,18 @@ type //for this dnsasync object. This is not a reccomended mode of operation //because it limits the app to one dns server but is kept for compatibility //and special uses. - addr,port:string; + addr,port:ansistring; overrideaf : integer; procedure cancel;//cancel an outstanding dns request - function dnsresult:string; //get result of dnslookup as a string + function dnsresult:ansistring; //get result of dnslookup as a string procedure dnsresultbin(var binip:tbinip); //get result of dnslookup as a tbinip property dnsresultlist : tbiniplist read fresultlist; - procedure forwardlookup(const name:string); //start forward lookup, + procedure forwardlookup(const name:ansistring); //start forward lookup, //preffering ipv4 procedure reverselookup(const binip:tbinip); //start reverse lookup - procedure customlookup(const name:string;querytype:integer); //start custom type lookup + procedure customlookup(const name:ansistring;querytype:integer); //start custom type lookup constructor create(aowner:tcomponent); override; destructor destroy; override; @@ -118,7 +118,7 @@ var Src : TInetSockAddrV; SrcLen : Integer; fromip:tbinip; - fromport:string; + fromport:ansistring; begin socketno := tlsocket(sender).tag; //writeln('got a reply on socket number ',socketno); @@ -153,7 +153,7 @@ end; function tdnsasync.sendquery(socketno:integer;const packet:tdnspacket;len:integer):boolean; var - destination : string; + destination : ansistring; inaddr : tinetsockaddrv; trytolisten:integer; begin @@ -291,10 +291,10 @@ begin inc(numsockused); end; {$endif} + for i := 0 to numsockused-1 do begin asyncprocess(i); end; - end; procedure tdnsasync.reverselookup; diff --git a/dnscore.pas b/dnscore.pas index 86cad69..d0dbbf0 100644 --- a/dnscore.pas +++ b/dnscore.pas @@ -28,7 +28,7 @@ when a packet is received the application should put the packet in recvbuf/recvbuflen , set state.parsepacket and call state_process again - once the app gets action_done it can determine sucess or failure in the + once the app gets action_done it can determine success or failure in the following ways. on failure state.resultstr will be an empty string and state.resultbin will @@ -367,7 +367,7 @@ begin failurereason := 'decoding name: got out of range2'; exit; end; - result := result + char(arr[a]); + result := result + ansichar(arr[a]); end; inc(numread,b+1); @@ -626,18 +626,18 @@ end; type tip_addr_string=packed record Next :pointer; - IpAddress : array[0..15] of char; - ipmask : array[0..15] of char; + IpAddress : array[0..15] of ansichar; + ipmask : array[0..15] of ansichar; context : dword; end; pip_addr_string=^tip_addr_string; tFIXED_INFO=packed record - HostName : array[0..MAX_HOSTNAME_LEN-1] of char; - DomainName : array[0..MAX_DOMAIN_NAME_LEN-1] of char; + HostName : array[0..MAX_HOSTNAME_LEN-1] of ansichar; + DomainName : array[0..MAX_DOMAIN_NAME_LEN-1] of ansichar; currentdnsserver : pip_addr_string; dnsserverlist : tip_addr_string; nodetype : longint; - ScopeId : array[0..MAX_SCOPE_ID_LEN + 4] of char; + ScopeId : array[0..MAX_SCOPE_ID_LEN + 4] of ansichar; enablerouting : longbool; enableproxy : longbool; enabledns : longbool; diff --git a/dnssync.pas b/dnssync.pas index a91d6f1..7d6631c 100644 --- a/dnssync.pas +++ b/dnssync.pas @@ -34,17 +34,17 @@ interface //on error the binip will have a family of 0 (other fiels are also currently //zeroed out but may be used for further error information in future) //timeout is in miliseconds, it is ignored when using windows dns -function forwardlookup(name:string;timeout:integer):tbinip; +function forwardlookup(name:ansistring;timeout:integer):tbinip; //convert a name to a list of all IP's returned //this returns both v4 and v6 IP's, or possibly only v4 or v6, depending on settings //on error, returns an empty list -function forwardlookuplist(name:string;timeout:integer):tbiniplist; +function forwardlookuplist(name:ansistring;timeout:integer):tbiniplist; //convert an IP to a name, on error a null string will be returned, other //details as above -function reverselookup(ip:tbinip;timeout:integer):string; +function reverselookup(ip:tbinip;timeout:integer):ansistring; @@ -110,8 +110,8 @@ end; function sendquery(socknum:integer;const packet:tdnspacket;len:integer):boolean; var a:integer; - addr : string; - port : string; + addr : ansistring; + port : ansistring; inaddr : TInetSockAddrV; begin { writeln('sendquery ',decodename(state.packet,state.packetlen,12,0,a),' ',state.requesttype);} @@ -138,7 +138,7 @@ var inAddrtemp : TInetSockAddrV; a:integer; biniptemp:tbinip; - addr:string; + addr:ansistring; begin //init both sockets smultaneously, always, so they get succesive fd's if fd[0] > 0 then exit; @@ -188,7 +188,7 @@ var Srcx : {$ifdef win32}sockaddr_in{$else}TInetSockAddrV{$endif} absolute Src; SrcLen : Integer; fromip:tbinip; - fromport:string; + fromport:ansistring; begin if timeout < mintimeout then timeout := defaulttimeout; @@ -296,7 +296,7 @@ end; -function forwardlookuplist(name:string;timeout:integer):tbiniplist; +function forwardlookuplist(name:ansistring;timeout:integer):tbiniplist; var dummy : integer; a,b:integer; @@ -367,7 +367,7 @@ begin end; end; -function forwardlookup(name:string;timeout:integer):tbinip; +function forwardlookup(name:ansistring;timeout:integer):tbinip; var listtemp:tbiniplist; begin @@ -375,7 +375,7 @@ begin result := biniplist_get(listtemp,0); end; -function reverselookup(ip:tbinip;timeout:integer):string; +function reverselookup(ip:tbinip;timeout:integer):ansistring; var dummy : integer; begin -- 2.30.2