From: zipplet Date: Tue, 9 Feb 2010 21:18:27 +0000 (+0000) Subject: Move string types to pgtypes.pas and port dnscore X-Git-Url: http://www.lcore.org/git/lcore.git/commitdiff_plain/d0705a212a4b27b3cf9a3aaf007db8b6db443092?hp=8e7497020dcd3c9f6b1b035aea011edeb76e6f8c Move string types to pgtypes.pas and port dnscore git-svn-id: file:///svnroot/lcore/branches/delphi2010@68 b1de8a11-f9be-4011-bde0-cc7ace90066a --- diff --git a/dnscore.pas b/dnscore.pas index 4cb52e2..86cad69 100644 --- a/dnscore.pas +++ b/dnscore.pas @@ -85,7 +85,7 @@ var useaf:integer = useaf_default; { (temporarily) use a different nameserver, regardless of the dnsserverlist } -var overridednsserver:string; +var overridednsserver:ansistring; const maxnamelength=127; @@ -125,16 +125,16 @@ type tdnsstate=record id:word; recursioncount:integer; - queryname:string; + queryname:ansistring; requesttype:word; parsepacket:boolean; - resultstr:string; + resultstr:ansistring; resultbin:tbinip; resultlist:tbiniplist; resultaction:integer; numrr1:array[0..3] of integer; numrr2:integer; - rrdata:string; + rrdata:ansistring; sendpacketlen:integer; sendpacket:tdnspacket; recvpacketlen:integer; @@ -165,20 +165,20 @@ type //function buildrequest(const name:string;var packet:tdnspacket;requesttype:word):integer; //returns the DNS name used to reverse look up an IP, such as 4.3.2.1.in-addr.arpa for 1.2.3.4 -function makereversename(const binip:tbinip):string; +function makereversename(const binip:tbinip):ansistring; -procedure setstate_request_init(const name:string;var state:tdnsstate); +procedure setstate_request_init(const name:ansistring;var state:tdnsstate); //set up state for a foward lookup. A family value of AF_INET6 will give only //ipv6 results. Any other value will give only ipv4 results -procedure setstate_forward(const name:string;var state:tdnsstate;family:integer); +procedure setstate_forward(const name:ansistring;var state:tdnsstate;family:integer); procedure setstate_reverse(const binip:tbinip;var state:tdnsstate); procedure setstate_failure(var state:tdnsstate); //procedure setstate_return(const rrp:trrpointer;len:integer;var state:tdnsstate); //for custom raw lookups such as TXT, as desired by the user -procedure setstate_custom(const name:string; requesttype:integer; var state:tdnsstate); +procedure setstate_custom(const name:ansistring; requesttype:integer; var state:tdnsstate); procedure state_process(var state:tdnsstate); @@ -195,7 +195,7 @@ var //getcurrentsystemnameserver returns the nameserver the app should use and sets //id to the id of that nameserver. id should later be used to report how laggy //the servers response was and if it was timed out. -function getcurrentsystemnameserver(var id:integer) :string; +function getcurrentsystemnameserver(var id:integer) :ansistring; procedure reportlag(id:integer;lag:integer); //lag should be in microseconds and should be -1 to report a timeout //var @@ -213,9 +213,9 @@ var {$endif} var - failurereason:string; + failurereason:ansistring; -function getquerytype(s:string):integer; +function getquerytype(s:ansistring):integer; implementation @@ -228,7 +228,7 @@ uses -function getquerytype(s:string):integer; +function getquerytype(s:ansistring):integer; begin s := uppercase(s); result := 0; @@ -244,10 +244,10 @@ begin if (s = 'SPF') then result := querytype_spf; end; -function buildrequest(const name:string;var packet:tdnspacket;requesttype:word):integer; +function buildrequest(const name:ansistring;var packet:tdnspacket;requesttype:word):integer; var a,b:integer; - s:string; + s:ansistring; arr:array[0..sizeof(packet)-1] of byte absolute packet; begin { writeln('buildrequest: name: ',name);} @@ -289,9 +289,9 @@ begin arr[result-4] := requesttype shr 8; end; -function makereversename(const binip:tbinip):string; +function makereversename(const binip:tbinip):ansistring; var - name:string; + name:ansistring; a,b:integer; begin name := ''; @@ -323,10 +323,10 @@ doesnt read beyond len. empty result + non null failurereason: failure empty result + null failurereason: internal use } -function decodename(const packet:tdnspacket;len,start,recursion:integer;var numread:integer):string; +function decodename(const packet:tdnspacket;len,start,recursion:integer;var numread:integer):ansistring; var arr:array[0..sizeof(packet)-1] of byte absolute packet; - s:string; + s:ansistring; a,b:integer; begin numread := 0; @@ -385,7 +385,7 @@ end; {==============================================================================} -function getrawfromrr(const rrp:trrpointer;len:integer):string; +function getrawfromrr(const rrp:trrpointer;len:integer):ansistring; begin setlength(result,htons(trr(rrp.p^).datalen)); uniquestring(result); @@ -441,7 +441,7 @@ begin end; end; -procedure setstate_request_init(const name:string;var state:tdnsstate); +procedure setstate_request_init(const name:ansistring;var state:tdnsstate); begin {destroy things properly} state.resultstr := ''; @@ -452,7 +452,7 @@ begin state.parsepacket := false; end; -procedure setstate_forward(const name:string;var state:tdnsstate;family:integer); +procedure setstate_forward(const name:ansistring;var state:tdnsstate;family:integer); begin setstate_request_init(name,state); state.forwardfamily := family; @@ -468,7 +468,7 @@ begin state.requesttype := querytype_ptr; end; -procedure setstate_custom(const name:string; requesttype:integer; var state:tdnsstate); +procedure setstate_custom(const name:ansistring; requesttype:integer; var state:tdnsstate); begin setstate_request_init(name,state); state.requesttype := requesttype; @@ -656,7 +656,7 @@ var currentdnsserver : pip_addr_string; {$else} t:textfile; - s:string; + s:ansistring; a:integer; {$endif} begin @@ -717,7 +717,7 @@ begin end; end; -function getcurrentsystemnameserver(var id:integer):string; +function getcurrentsystemnameserver(var id:integer):ansistring; var counter : integer; @@ -757,7 +757,7 @@ end; function getv6localips:tbiniplist; var t:textfile; - s,s2:string; + s,s2:ansistring; ip:tbinip; a:integer; begin diff --git a/dnswin.pas b/dnswin.pas index 02539e9..847f0fd 100644 --- a/dnswin.pas +++ b/dnswin.pas @@ -2,7 +2,7 @@ unit dnswin; interface -uses binipstuff,classes,lcore; +uses binipstuff,classes,lcore,pgtypes; {$include lcoreconfig.inc} @@ -42,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 diff --git a/lcore.pas b/lcore.pas index d0fc568..0f6eaef 100755 --- a/lcore.pas +++ b/lcore.pas @@ -48,19 +48,6 @@ interface absoloutemaxs:integer=0; type - {$IF CompilerVersion >= 20.0} - { Delphi 2009/2010 widestring is the default string type } - thostname = ansistring; - tbufferstring = ansistring; - tipstring = ansistring; - {$else} - { Old pre-unicode delphi, todo: need to check if ansistring is available - in all older versions of delphi } - thostname = string; - tbufferstring = string; - tipstring = string; - {$ifend} - {$ifdef ver1_0} sigset= array[0..31] of longint; {$endif} diff --git a/pgtypes.pas b/pgtypes.pas index 3c48e26..4dfd66d 100755 --- a/pgtypes.pas +++ b/pgtypes.pas @@ -16,5 +16,9 @@ interface {$endif} paddrint=^taddrint; + thostname = ansistring; + tbufferstring = ansistring; + tipstring = ansistring; + implementation end.