From 257fdc360d4c80e606358c108c890c5367436a12 Mon Sep 17 00:00:00 2001 From: zipplet Date: Tue, 9 Feb 2010 22:30:17 +0000 Subject: [PATCH] More string type fixes git-svn-id: file:///svnroot/lcore/branches/delphi2010@70 b1de8a11-f9be-4011-bde0-cc7ace90066a --- binipstuff.pas | 50 ++++++++++++++++++++++++------------------------- blinklist.pas | 4 ++-- bsearchtree.pas | 16 ++++++++-------- btime.pas | 18 +++++++++--------- fastmd5.pas | 10 +++++----- lcorernd.pas | 8 ++++---- readtxt2.pas | 6 +++--- wcore.pas | 2 +- 8 files changed, 56 insertions(+), 58 deletions(-) diff --git a/binipstuff.pas b/binipstuff.pas index 675b03e..40b5f9f 100644 --- a/binipstuff.pas +++ b/binipstuff.pas @@ -8,11 +8,9 @@ interface {$include lcoreconfig.inc} -{$ifndef win32} -{$ifdef ipv6} -uses sockets; -{$endif} -{$endif} +uses + {$ifndef win32}{$ifdef ipv6}sockets,{$endif}{$endif} + pgtypes; {$ifdef fpc} {$mode delphi} @@ -23,7 +21,7 @@ uses sockets; {$include uint32.inc} const - hexchars:array[0..15] of char='0123456789abcdef'; + hexchars:array[0..15] of ansichar='0123456789abcdef'; AF_INET=2; {$ifdef win32} AF_INET6=23; @@ -120,7 +118,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=tipstring; function biniplist_new:tbiniplist; procedure biniplist_add(var l:tbiniplist;ip:tbinip); @@ -130,18 +128,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):tipstring; 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:tipstring;var binip:tbinip):boolean; +function ipstrtobinf(const s:tipstring):tbinip; +function ipbintostr(const binip:tbinip):tipstring; {$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):tipstring; +function ip6strtobin(const s:tipstring;var bin:tin6_addr):boolean; {$endif} function comparebinip(const ip1,ip2:tbinip):boolean; @@ -151,13 +149,13 @@ 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:tipstring):longint; function needconverttov4(const ip:tbinip):boolean; procedure converttov4(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 @@ -192,7 +190,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);} @@ -224,11 +222,11 @@ end; {internal} {converts dotted v4 IP to longint. returns host endian order} -function longip(s:string):longint; +function longip(s:tipstring):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 @@ -279,7 +277,7 @@ begin ipstrtobin(s,result); end; -function ipstrtobin(const s:string;var binip:tbinip):boolean; +function ipstrtobin(const s:tipstring;var binip:tbinip):boolean; begin binip.family := 0; result := false; @@ -301,7 +299,7 @@ begin end; end; -function ipbintostr(const binip:tbinip):string; +function ipbintostr(const binip:tbinip):tipstring; var a:integer; begin @@ -337,9 +335,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):tipstring; {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]; @@ -395,10 +393,10 @@ begin end; end; -function ip6strtobin(const s:string;var bin:tin6_addr):boolean; +function ip6strtobin(const s:tipstring;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; @@ -538,7 +536,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); @@ -594,7 +592,7 @@ begin l := l + copy(l2,biniplist_prefixlen+1,maxlongint); end; -function biniplist_tostr(const l:tbiniplist):string; +function biniplist_tostr(const l:tbiniplist):tipstring; 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/btime.pas b/btime.pas index 9bb9550..de279df 100644 --- a/btime.pas +++ b/btime.pas @@ -20,7 +20,7 @@ const var timezone:integer; - timezonestr:string; + timezonestr:ansistring; irctime,unixtime:integer; tickcount:integer; settimebias:integer; @@ -39,8 +39,8 @@ procedure gettimezone; procedure timehandler; procedure init; -function timestring(i:integer):string; -function timestrshort(i:integer):string; +function timestring(i:integer):ansistring; +function timestrshort(i:integer):ansistring; {$ifdef win32} function unixtimefloat_systemtime:float; @@ -546,10 +546,10 @@ begin timezonestr := timezonestr + char(l div 600 mod 10+48)+char(l div 60 mod 10+48)+':'+char(l div 10 mod 6+48)+char(l mod 10+48); end; -function timestrshort(i:integer):string; +function timestrshort(i:integer):ansistring; const - weekday:array[0..6] of string[4]=('Thu','Fri','Sat','Sun','Mon','Tue','Wed'); - month:array[0..11] of string[4]=('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); + weekday:array[0..6] of ansistring =('Thu','Fri','Sat','Sun','Mon','Tue','Wed'); + month:array[0..11] of ansistring =('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); var y,m,d,h,min,sec,ms:word; t:tdatetime; @@ -562,10 +562,10 @@ begin inttostr(y); end; -function timestring(i:integer):string; +function timestring(i:integer):ansistring; const - weekday:array[0..6] of string[10]=('Thursday','Friday','Saturday','Sunday','Monday','Tuesday','Wednesday'); - month:array[0..11] of string[10]=('January','February','March','April','May','June','July','August','September','October','November','December'); + weekday:array[0..6] of ansistring =('Thursday','Friday','Saturday','Sunday','Monday','Tuesday','Wednesday'); + month:array[0..11] of ansistring =('January','February','March','April','May','June','July','August','September','October','November','December'); var y,m,d,h,min,sec,ms:word; t:tdatetime; 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/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/readtxt2.pas b/readtxt2.pas index 84c5765..8f74e6c 100644 --- a/readtxt2.pas +++ b/readtxt2.pas @@ -32,9 +32,9 @@ type sourcestream:tstream; destroysourcestream:boolean; constructor create(asourcestream: tstream; adestroysourcestream:boolean); - constructor createf(filename : string); + constructor createf(filename : ansistring); - 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 : ansistring); 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