From 8bffcf295dad495a39dabb9c6915c1692738b3fa Mon Sep 17 00:00:00 2001 From: zipplet Date: Sun, 14 Feb 2010 01:57:00 +0000 Subject: [PATCH] Type fix for binipstuff and revert btime git-svn-id: file:///svnroot/lcore/branches/delphi2010@77 b1de8a11-f9be-4011-bde0-cc7ace90066a --- binipstuff.pas | 28 ++++++++++++++-------------- btime.pas | 20 ++++++++++---------- pgtypes.pas | 3 ++- readtxt2.pas | 4 ++-- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/binipstuff.pas b/binipstuff.pas index 40b5f9f..cfc7c1b 100644 --- a/binipstuff.pas +++ b/binipstuff.pas @@ -118,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=tipstring; + tbiniplist=tbufferstring; function biniplist_new:tbiniplist; procedure biniplist_add(var l:tbiniplist;ip:tbinip); @@ -128,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):tipstring; +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:tipstring;var binip:tbinip):boolean; -function ipstrtobinf(const s:tipstring):tbinip; -function ipbintostr(const binip:tbinip):tipstring; +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):tipstring; -function ip6strtobin(const s:tipstring;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; @@ -149,7 +149,7 @@ function comparebinipmask(ip1,ip2:tbinip;bits:integer):boolean; procedure addipsoffamily(var l:tbiniplist;const l2:tbiniplist;family:integer); {deprecated} -function longip(s:tipstring):longint; +function longip(s:thostname):longint; function needconverttov4(const ip:tbinip):boolean; procedure converttov4(var ip:tbinip); @@ -222,7 +222,7 @@ end; {internal} {converts dotted v4 IP to longint. returns host endian order} -function longip(s:tipstring):longint; +function longip(s:thostname):longint; var l:longint; a,b:integer; @@ -277,7 +277,7 @@ begin ipstrtobin(s,result); end; -function ipstrtobin(const s:tipstring;var binip:tbinip):boolean; +function ipstrtobin(const s:thostname;var binip:tbinip):boolean; begin binip.family := 0; result := false; @@ -299,7 +299,7 @@ begin end; end; -function ipbintostr(const binip:tbinip):tipstring; +function ipbintostr(const binip:tbinip):thostname; var a:integer; begin @@ -335,7 +335,7 @@ written by beware {fpc has hostaddrtostr6 and strtohostaddr6 but the later isnt implemented yet} -function ip6bintostr(const bin:tin6_addr):tipstring; +function ip6bintostr(const bin:tin6_addr):thostname; {base16 with lowercase output} function makehex(w:word):ansistring; begin @@ -393,7 +393,7 @@ begin end; end; -function ip6strtobin(const s:tipstring;var bin:tin6_addr):boolean; +function ip6strtobin(const s:thostname;var bin:tin6_addr):boolean; var a,b:integer; fields:array[0..7] of ansistring; @@ -592,7 +592,7 @@ begin l := l + copy(l2,biniplist_prefixlen+1,maxlongint); end; -function biniplist_tostr(const l:tbiniplist):tipstring; +function biniplist_tostr(const l:tbiniplist):thostname; var a:integer; begin diff --git a/btime.pas b/btime.pas index ea199c6..9bb9550 100644 --- a/btime.pas +++ b/btime.pas @@ -20,7 +20,7 @@ const var timezone:integer; - timezonestr:ansistring; + timezonestr:string; irctime,unixtime:integer; tickcount:integer; settimebias:integer; @@ -39,8 +39,8 @@ procedure gettimezone; procedure timehandler; procedure init; -function timestring(i:integer):ansistring; -function timestrshort(i:integer):ansistring; +function timestring(i:integer):string; +function timestrshort(i:integer):string; {$ifdef win32} function unixtimefloat_systemtime:float; @@ -543,13 +543,13 @@ begin if timezone >= 0 then timezonestr := '+' else timezonestr := '-'; l := abs(timezone) div 60; - timezonestr := timezonestr + ansichar(l div 600 mod 10+48)+ansichar(l div 60 mod 10+48)+':'+ansichar(l div 10 mod 6+48)+ansichar(l mod 10+48); + 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):ansistring; +function timestrshort(i:integer):string; const - 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'); + 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'); var y,m,d,h,min,sec,ms:word; t:tdatetime; @@ -562,10 +562,10 @@ begin inttostr(y); end; -function timestring(i:integer):ansistring; +function timestring(i:integer):string; const - 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'); + 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'); var y,m,d,h,min,sec,ms:word; t:tdatetime; diff --git a/pgtypes.pas b/pgtypes.pas index 4dfd66d..d42a6b2 100755 --- a/pgtypes.pas +++ b/pgtypes.pas @@ -16,9 +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; - tipstring = ansistring; implementation end. diff --git a/readtxt2.pas b/readtxt2.pas index 8f74e6c..a5f7de4 100644 --- a/readtxt2.pas +++ b/readtxt2.pas @@ -32,7 +32,7 @@ type sourcestream:tstream; destroysourcestream:boolean; constructor create(asourcestream: tstream; adestroysourcestream:boolean); - constructor createf(filename : ansistring); + constructor createf(filename : string); function readline:ansistring; function eof:boolean; @@ -59,7 +59,7 @@ begin destroysourcestream := false; end; -constructor treadtxt.createf(filename : ansistring); +constructor treadtxt.createf(filename: string); begin create(tfilestream.create(filename,fmOpenRead),true); end; -- 2.30.2