From e27ef2c6aab3a2a8051314bd37bb3b2386775f36 Mon Sep 17 00:00:00 2001 From: zipplet Date: Tue, 16 Feb 2010 22:51:30 +0000 Subject: [PATCH 1/1] Merged with delphi 2010 branch git-svn-id: file:///svnroot/lcore/trunk@79 b1de8a11-f9be-4011-bde0-cc7ace90066a --- binipstuff.pas | 48 ++++++++++++++++++------------------- blinklist.pas | 4 ++-- bsearchtree.pas | 16 ++++++------- dnsasync.pas | 14 +++++------ dnscore.pas | 64 ++++++++++++++++++++++++------------------------- dnssync.pas | 20 ++++++++-------- dnswin.pas | 37 ++++++++++++++-------------- fastmd5.pas | 10 ++++---- lcore.pas | 10 ++++---- lcorernd.pas | 8 +++---- lsocket.pas | 34 +++++++++++++------------- pgtypes.pas | 5 ++++ readtxt2.pas | 4 ++-- wcore.pas | 2 +- 14 files changed, 141 insertions(+), 135 deletions(-) diff --git a/binipstuff.pas b/binipstuff.pas index 8f28a27..ae3d23a 100644 --- a/binipstuff.pas +++ b/binipstuff.pas @@ -8,9 +8,9 @@ interface {$include lcoreconfig.inc} -{$ifndef win32} -uses sockets; -{$endif} +uses + {$ifndef win32}{$ifdef ipv6}sockets,{$endif}{$endif} + pgtypes; {$ifdef fpc} {$mode delphi} @@ -21,7 +21,7 @@ uses sockets; {$include uint32.inc} const - hexchars:array[0..15] of char='0123456789abcdef'; + hexchars:array[0..15] of ansichar='0123456789abcdef'; {$ifdef win32} AF_INET=2; AF_INET6=23; @@ -122,7 +122,7 @@ bin IP list code, by beware while this is really just a string, on the interface side it must be treated as an opaque var which is passed as "var" when it needs to be modified} - tbiniplist=string; + tbiniplist=tbufferstring; function biniplist_new:tbiniplist; procedure biniplist_add(var l:tbiniplist;ip:tbinip); @@ -132,18 +132,18 @@ procedure biniplist_set(var l:tbiniplist;index:integer;ip:tbinip); procedure biniplist_setcount(var l:tbiniplist;newlen:integer); procedure biniplist_free(var l:tbiniplist); procedure biniplist_addlist(var l:tbiniplist;const l2:tbiniplist); -function biniplist_tostr(const l:tbiniplist):string; +function biniplist_tostr(const l:tbiniplist):thostname; function isbiniplist(const l:tbiniplist):boolean; function htons(w:word):word; function htonl(i:uint32):uint32; -function ipstrtobin(const s:string;var binip:tbinip):boolean; -function ipstrtobinf(const s:string):tbinip; -function ipbintostr(const binip:tbinip):string; +function ipstrtobin(const s:thostname;var binip:tbinip):boolean; +function ipstrtobinf(const s:thostname):tbinip; +function ipbintostr(const binip:tbinip):thostname; {$ifdef ipv6} -function ip6bintostr(const bin:tin6_addr):string; -function ip6strtobin(const s:string;var bin:tin6_addr):boolean; +function ip6bintostr(const bin:tin6_addr):thostname; +function ip6strtobin(const s:thostname;var bin:tin6_addr):boolean; {$endif} function comparebinip(const ip1,ip2:tbinip):boolean; @@ -153,14 +153,14 @@ function comparebinipmask(ip1,ip2:tbinip;bits:integer):boolean; procedure addipsoffamily(var l:tbiniplist;const l2:tbiniplist;family:integer); {deprecated} -function longip(s:string):longint; +function longip(s:thostname):longint; function needconverttov4(const ip:tbinip):boolean; procedure converttov4(var ip:tbinip); procedure converttov6(var ip:tbinip); function inaddrvtobinip(inaddrv:tinetsockaddrv):tbinip; -function makeinaddrv(addr:tbinip;port:string;var inaddr:tinetsockaddrv):integer; +function makeinaddrv(addr:tbinip;port:ansistring;var inaddr:tinetsockaddrv):integer; function inaddrsize(inaddr:tinetsockaddrv):integer; implementation @@ -195,7 +195,7 @@ begin {$endif} end; -function makeinaddrv(addr:tbinip;port:string;var inaddr:tinetsockaddrv):integer; +function makeinaddrv(addr:tbinip;port:ansistring;var inaddr:tinetsockaddrv):integer; begin result := 0; { biniptemp := forwardlookup(addr,10);} @@ -227,11 +227,11 @@ end; {internal} {converts dotted v4 IP to longint. returns host endian order} -function longip(s:string):longint; +function longip(s:thostname):longint; var l:longint; a,b:integer; -function convertbyte(const s:string):integer; +function convertbyte(const s:ansistring):integer; begin result := strtointdef(s,-1); if result < 0 then begin @@ -282,7 +282,7 @@ begin ipstrtobin(s,result); end; -function ipstrtobin(const s:string;var binip:tbinip):boolean; +function ipstrtobin(const s:thostname;var binip:tbinip):boolean; begin binip.family := 0; result := false; @@ -304,7 +304,7 @@ begin end; end; -function ipbintostr(const binip:tbinip):string; +function ipbintostr(const binip:tbinip):thostname; var a:integer; begin @@ -340,9 +340,9 @@ written by beware {fpc has hostaddrtostr6 and strtohostaddr6 but the later isnt implemented yet} -function ip6bintostr(const bin:tin6_addr):string; +function ip6bintostr(const bin:tin6_addr):thostname; {base16 with lowercase output} -function makehex(w:word):string; +function makehex(w:word):ansistring; begin result := ''; if w >= 4096 then result := result + hexchars[w shr 12]; @@ -398,10 +398,10 @@ begin end; end; -function ip6strtobin(const s:string;var bin:tin6_addr):boolean; +function ip6strtobin(const s:thostname;var bin:tin6_addr):boolean; var a,b:integer; - fields:array[0..7] of string; + fields:array[0..7] of ansistring; fieldcount:integer; emptyfield:integer; wordcount:integer; @@ -558,7 +558,7 @@ end; {-----------biniplist stuff--------------------------------------------------} const - biniplist_prefix='bipl'#0; + biniplist_prefix: ansistring = 'bipl'#0; //fpc 1.0.x doesn't seem to like use of length function in a constant //definition //biniplist_prefixlen=length(biniplist_prefix); @@ -614,7 +614,7 @@ begin l := l + copy(l2,biniplist_prefixlen+1,maxlongint); end; -function biniplist_tostr(const l:tbiniplist):string; +function biniplist_tostr(const l:tbiniplist):thostname; var a:integer; begin diff --git a/blinklist.pas b/blinklist.pas index 5ab153a..6ce58d8 100644 --- a/blinklist.pas +++ b/blinklist.pas @@ -32,11 +32,11 @@ type end; tstringlinklist=class(tlinklist) - s:string; + s:ansistring; end; tthing=class(tlinklist) - name:string; {name/nick} + name:ansistring; {name/nick} hashname:integer; {hash of name} end; diff --git a/bsearchtree.pas b/bsearchtree.pas index ad61751..d9e3ea2 100644 --- a/bsearchtree.pas +++ b/bsearchtree.pas @@ -17,24 +17,24 @@ const type thashitem=class(tlinklist) hash:integer; - s:string; + s:ansistring; p:pointer; end; thashtable=array[0..hashtable_size-1] of thashitem; phashtable=^thashtable; {adds "item" to the tree for name "s". the name must not exist (no checking done)} -procedure addtree(t:phashtable;s:string;item:pointer); +procedure addtree(t:phashtable;s:ansistring;item:pointer); {removes name "s" from the tree. the name must exist (no checking done)} -procedure deltree(t:phashtable;s:string); +procedure deltree(t:phashtable;s:ansistring); {returns the item pointer for s, or nil if not found} -function findtree(t:phashtable;s:string):pointer; +function findtree(t:phashtable;s:ansistring):pointer; implementation -function makehash(s:string):integer; +function makehash(s:ansistring):integer; const shifter=6; var @@ -48,7 +48,7 @@ begin result := (result xor result shr 16) and (hashtable_size-1); end; -procedure addtree(t:phashtable;s:string;item:pointer); +procedure addtree(t:phashtable;s:ansistring;item:pointer); var hash:integer; p:thashitem; @@ -61,7 +61,7 @@ begin linklistadd(tlinklist(t[hash]),tlinklist(p)); end; -procedure deltree(t:phashtable;s:string); +procedure deltree(t:phashtable;s:ansistring); var p,p2:thashitem; hash:integer; @@ -81,7 +81,7 @@ begin end; -function findtree(t:phashtable;s:string):pointer; +function findtree(t:phashtable;s:ansistring):pointer; var p:thashitem; hash:integer; 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 4cb52e2..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 @@ -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; @@ -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); @@ -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; @@ -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; @@ -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/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 diff --git a/dnswin.pas b/dnswin.pas index e9c2a16..847f0fd 100644 --- 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 @@ -28,10 +28,10 @@ type procedure execute; override; public onrequestdone:tsocketevent; - name : string; + name : thostname; iplist : tbiniplist; - procedure forwardlookup(name:string); + procedure forwardlookup(name:thostname); procedure reverselookup(ip:tbinip); destructor destroy; override; procedure release; @@ -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 @@ -53,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; @@ -81,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; @@ -132,7 +133,7 @@ begin if a 0 then begin error := getnameinforesult; result := ''; @@ -270,7 +271,7 @@ begin end; end; -procedure tdnswinasync.forwardlookup(name:string); +procedure tdnswinasync.forwardlookup(name:thostname); begin self.name := name; freverse := false; diff --git a/fastmd5.pas b/fastmd5.pas index 891d0fc..6455e5c 100644 --- a/fastmd5.pas +++ b/fastmd5.pas @@ -55,13 +55,13 @@ procedure md5finish(var state:tmd5state;var result); procedure getmd5(const data;len:longint;var result); -function md5tostr(const md5:tmd5):string; +function md5tostr(const md5:tmd5):ansistring; implementation -function inttohex(val,bits:integer):string; +function inttohex(val,bits:integer):ansistring; const - hexchar:array[0..15] of char='0123456789abcdef'; + hexchar:array[0..15] of ansichar='0123456789abcdef'; begin inttohex := hexchar[val shr 4]+hexchar[val and $f]; end; @@ -284,10 +284,10 @@ begin md5finish(t,result); end; -function md5tostr(const md5:tmd5):string; +function md5tostr(const md5:tmd5):ansistring; var a:integer; - s:string; + s:ansistring; begin s := ''; for a := 0 to 15 do s := s + inttohex(md5[a],2); diff --git a/lcore.pas b/lcore.pas index bb9eb8d..0f6eaef 100755 --- a/lcore.pas +++ b/lcore.pas @@ -106,7 +106,7 @@ interface lasterror:integer; destroying:boolean; recvbufsize:integer; - function receivestr:string; virtual; + function receivestr:tbufferstring; virtual; procedure close; procedure abort; procedure internalclose(error:word); virtual; @@ -119,8 +119,8 @@ interface procedure dup(invalue:longint); function sendflush : integer; - procedure sendstr(const str : string);virtual; - procedure putstringinsendbuffer(const newstring : string); + procedure sendstr(const str : tbufferstring);virtual; + procedure putstringinsendbuffer(const newstring : tbufferstring); function send(data:pointer;len:integer):integer;virtual; procedure putdatainsendbuffer(data:pointer;len:integer); virtual; procedure deletebuffereddata; @@ -442,13 +442,13 @@ begin end; end; -procedure tlasio.sendstr(const str : string); +procedure tlasio.sendstr(const str : tbufferstring); begin putstringinsendbuffer(str); sendflush; end; -procedure tlasio.putstringinsendbuffer(const newstring : string); +procedure tlasio.putstringinsendbuffer(const newstring : tbufferstring); begin if newstring <> '' then putdatainsendbuffer(@newstring[1],length(newstring)); end; diff --git a/lcorernd.pas b/lcorernd.pas index 673860f..3e43bb1 100644 --- a/lcorernd.pas +++ b/lcorernd.pas @@ -111,7 +111,7 @@ function randominteger(i:longint):longint; function randombits(b:integer):longint; {generate a version 4 random uuid} -function generate_uuid:string; +function generate_uuid:ansistring; {$ifndef nolcorernd} @@ -402,12 +402,12 @@ begin end; const - ch:array[0..15] of char='0123456789abcdef'; + ch:array[0..15] of ansichar='0123456789abcdef'; -function generate_uuid:string; +function generate_uuid:ansistring; var buf:array[0..7] of word; -function inttohex(w:word):string; +function inttohex(w:word):ansistring; begin result := ch[w shr 12] + ch[(w shr 8) and $f] + ch[(w shr 4) and $f] + ch[w and $f]; end; diff --git a/lsocket.pas b/lsocket.pas index 7f61092..a7c6164 100755 --- a/lsocket.pas +++ b/lsocket.pas @@ -94,11 +94,11 @@ type //host : THostentry ; //mainthread : boolean ; //for debuggin only - addr:string; - port:string; - localaddr:string; - localport:string; - proto:string; + addr:thostname; + port:ansistring; + localaddr:thostname; + localport:ansistring; + proto:ansistring; udp,dgram:boolean; listenqueue:integer; {$ifdef secondlistener} @@ -118,15 +118,15 @@ type procedure handlefdtrigger(readtrigger,writetrigger:boolean); override; function send(data:pointer;len:integer):integer;override; - procedure sendstr(const str : string);override; + procedure sendstr(const str : tbufferstring);override; function Receive(Buf:Pointer;BufSize:integer):integer; override; function getpeername(var addr:tsockaddrin;addrlen:integer):integer; virtual; procedure getXaddrbin(var binip:tbinip); virtual; procedure getpeeraddrbin(var binip:tbinip); virtual; - function getXaddr:string; virtual; - function getpeeraddr:string; virtual; - function getXport:string; virtual; - function getpeerport:string; virtual; + function getXaddr:thostname; virtual; + function getpeeraddr:thostname; virtual; + function getXport:ansistring; virtual; + function getpeerport:ansistring; virtual; constructor Create(AOwner: TComponent); override; //this one has to be kept public for now because lcorewsaasyncselect calls it @@ -299,7 +299,7 @@ begin realconnect; end; -procedure tlsocket.sendstr(const str : string); +procedure tlsocket.sendstr(const str : tbufferstring); begin if dgram then begin send(@str[1],length(str)) @@ -377,7 +377,7 @@ var yes,no:longint; socktype:integer; biniptemp:tbinip; - origaddr:string; + origaddr:thostname; begin if state <> wsclosed then close; udp := uppercase(proto) = 'UDP'; @@ -409,7 +409,7 @@ begin fdhandlein := socket(biniptemp.family,socktype,0); {$ifdef ipv6} if (addr = '::') and (origaddr = '') and (fdhandlein < 0) then begin - writeln('failed to create an IPV6 socket with error ',socketerror,'. trying to create an IPV4 one instead'); + {writeln('failed to create an IPV6 socket with error ',socketerror,'. trying to create an IPV4 one instead');} addr := '0.0.0.0'; fdhandlein := socket(PF_INET,socktype,0); end; @@ -754,7 +754,7 @@ begin converttov4(binip); end; -function tlsocket.getXaddr:string; +function tlsocket.getXaddr:thostname; var biniptemp:tbinip; begin @@ -763,7 +763,7 @@ begin if result = '' then result := 'error'; end; -function tlsocket.getpeeraddr:string; +function tlsocket.getpeeraddr:thostname; var biniptemp:tbinip; begin @@ -772,7 +772,7 @@ begin if result = '' then result := 'error'; end; -function tlsocket.getXport:string; +function tlsocket.getXport:ansistring; var addr:tinetsockaddrv; i:integer; @@ -788,7 +788,7 @@ begin result := inttostr(htons(addr.InAddr.port)); end; -function tlsocket.getpeerport:string; +function tlsocket.getpeerport:ansistring; var addr:tinetsockaddrv; i:integer; diff --git a/pgtypes.pas b/pgtypes.pas index 3c48e26..d42a6b2 100755 --- a/pgtypes.pas +++ b/pgtypes.pas @@ -16,5 +16,10 @@ interface {$endif} paddrint=^taddrint; + { string type for storing hostnames or IP addresses as strings } + thostname = ansistring; + { string type for storing data (bytes) } + tbufferstring = ansistring; + implementation end. diff --git a/readtxt2.pas b/readtxt2.pas index 84c5765..a5f7de4 100644 --- a/readtxt2.pas +++ b/readtxt2.pas @@ -34,7 +34,7 @@ type constructor create(asourcestream: tstream; adestroysourcestream:boolean); constructor createf(filename : string); - function readline:string; + function readline:ansistring; function eof:boolean; destructor destroy; override; private @@ -59,7 +59,7 @@ begin destroysourcestream := false; end; -constructor treadtxt.createf(filename : string); +constructor treadtxt.createf(filename: string); begin create(tfilestream.create(filename,fmOpenRead),true); end; diff --git a/wcore.pas b/wcore.pas index f88aa53..d15e803 100755 --- a/wcore.pas +++ b/wcore.pas @@ -65,7 +65,7 @@ procedure exitmessageloop; procedure processmessages; var - onshutdown:procedure(s:string); + onshutdown:procedure(s:ansistring); implementation -- 2.30.2