\r
{$include lcoreconfig.inc}\r
\r
-{$ifndef win32}\r
-{$ifdef ipv6}\r
-uses sockets;\r
-{$endif}\r
-{$endif}\r
+uses\r
+ {$ifndef win32}{$ifdef ipv6}sockets,{$endif}{$endif}\r
+ pgtypes;\r
\r
{$ifdef fpc}\r
{$mode delphi}\r
{$include uint32.inc}\r
\r
const\r
- hexchars:array[0..15] of char='0123456789abcdef';\r
+ hexchars:array[0..15] of ansichar='0123456789abcdef';\r
AF_INET=2;\r
{$ifdef win32}\r
AF_INET6=23;\r
while this is really just a string, on the interface side it must be treated\r
as an opaque var which is passed as "var" when it needs to be modified}\r
\r
- tbiniplist=string;\r
+ tbiniplist=tipstring;\r
\r
function biniplist_new:tbiniplist;\r
procedure biniplist_add(var l:tbiniplist;ip:tbinip);\r
procedure biniplist_setcount(var l:tbiniplist;newlen:integer);\r
procedure biniplist_free(var l:tbiniplist);\r
procedure biniplist_addlist(var l:tbiniplist;const l2:tbiniplist);\r
-function biniplist_tostr(const l:tbiniplist):string;\r
+function biniplist_tostr(const l:tbiniplist):tipstring;\r
function isbiniplist(const l:tbiniplist):boolean;\r
\r
function htons(w:word):word;\r
function htonl(i:uint32):uint32;\r
\r
-function ipstrtobin(const s:string;var binip:tbinip):boolean;\r
-function ipstrtobinf(const s:string):tbinip;\r
-function ipbintostr(const binip:tbinip):string;\r
+function ipstrtobin(const s:tipstring;var binip:tbinip):boolean;\r
+function ipstrtobinf(const s:tipstring):tbinip;\r
+function ipbintostr(const binip:tbinip):tipstring;\r
{$ifdef ipv6}\r
-function ip6bintostr(const bin:tin6_addr):string;\r
-function ip6strtobin(const s:string;var bin:tin6_addr):boolean;\r
+function ip6bintostr(const bin:tin6_addr):tipstring;\r
+function ip6strtobin(const s:tipstring;var bin:tin6_addr):boolean;\r
{$endif}\r
\r
function comparebinip(const ip1,ip2:tbinip):boolean;\r
procedure addipsoffamily(var l:tbiniplist;const l2:tbiniplist;family:integer);\r
\r
{deprecated}\r
-function longip(s:string):longint;\r
+function longip(s:tipstring):longint;\r
\r
function needconverttov4(const ip:tbinip):boolean;\r
procedure converttov4(var ip:tbinip);\r
\r
function inaddrvtobinip(inaddrv:tinetsockaddrv):tbinip;\r
-function makeinaddrv(addr:tbinip;port:string;var inaddr:tinetsockaddrv):integer;\r
+function makeinaddrv(addr:tbinip;port:ansistring;var inaddr:tinetsockaddrv):integer;\r
function inaddrsize(inaddr:tinetsockaddrv):integer;\r
\r
implementation\r
{$endif}\r
end;\r
\r
-function makeinaddrv(addr:tbinip;port:string;var inaddr:tinetsockaddrv):integer;\r
+function makeinaddrv(addr:tbinip;port:ansistring;var inaddr:tinetsockaddrv):integer;\r
begin\r
result := 0;\r
{ biniptemp := forwardlookup(addr,10);}\r
\r
{internal}\r
{converts dotted v4 IP to longint. returns host endian order}\r
-function longip(s:string):longint;\r
+function longip(s:tipstring):longint;\r
var\r
l:longint;\r
a,b:integer;\r
-function convertbyte(const s:string):integer;\r
+function convertbyte(const s:ansistring):integer;\r
begin\r
result := strtointdef(s,-1);\r
if result < 0 then begin\r
ipstrtobin(s,result);\r
end;\r
\r
-function ipstrtobin(const s:string;var binip:tbinip):boolean;\r
+function ipstrtobin(const s:tipstring;var binip:tbinip):boolean;\r
begin\r
binip.family := 0;\r
result := false;\r
end;\r
end;\r
\r
-function ipbintostr(const binip:tbinip):string;\r
+function ipbintostr(const binip:tbinip):tipstring;\r
var\r
a:integer;\r
begin\r
{fpc has hostaddrtostr6 and strtohostaddr6 but the later isnt implemented yet}\r
\r
\r
-function ip6bintostr(const bin:tin6_addr):string;\r
+function ip6bintostr(const bin:tin6_addr):tipstring;\r
{base16 with lowercase output}\r
-function makehex(w:word):string;\r
+function makehex(w:word):ansistring;\r
begin\r
result := '';\r
if w >= 4096 then result := result + hexchars[w shr 12];\r
end;\r
end;\r
\r
-function ip6strtobin(const s:string;var bin:tin6_addr):boolean;\r
+function ip6strtobin(const s:tipstring;var bin:tin6_addr):boolean;\r
var\r
a,b:integer;\r
- fields:array[0..7] of string;\r
+ fields:array[0..7] of ansistring;\r
fieldcount:integer;\r
emptyfield:integer;\r
wordcount:integer;\r
{-----------biniplist stuff--------------------------------------------------}\r
\r
const\r
- biniplist_prefix='bipl'#0;\r
+ biniplist_prefix: ansistring = 'bipl'#0;\r
//fpc 1.0.x doesn't seem to like use of length function in a constant \r
//definition\r
//biniplist_prefixlen=length(biniplist_prefix);\r
l := l + copy(l2,biniplist_prefixlen+1,maxlongint);\r
end;\r
\r
-function biniplist_tostr(const l:tbiniplist):string;\r
+function biniplist_tostr(const l:tbiniplist):tipstring;\r
var\r
a:integer;\r
begin\r
end;\r
\r
tstringlinklist=class(tlinklist)\r
- s:string;\r
+ s:ansistring;\r
end;\r
\r
tthing=class(tlinklist)\r
- name:string; {name/nick}\r
+ name:ansistring; {name/nick}\r
hashname:integer; {hash of name}\r
end;\r
\r
type\r
thashitem=class(tlinklist)\r
hash:integer;\r
- s:string;\r
+ s:ansistring;\r
p:pointer;\r
end;\r
thashtable=array[0..hashtable_size-1] of thashitem;\r
phashtable=^thashtable;\r
\r
{adds "item" to the tree for name "s". the name must not exist (no checking done)}\r
-procedure addtree(t:phashtable;s:string;item:pointer);\r
+procedure addtree(t:phashtable;s:ansistring;item:pointer);\r
\r
{removes name "s" from the tree. the name must exist (no checking done)}\r
-procedure deltree(t:phashtable;s:string);\r
+procedure deltree(t:phashtable;s:ansistring);\r
\r
{returns the item pointer for s, or nil if not found}\r
-function findtree(t:phashtable;s:string):pointer;\r
+function findtree(t:phashtable;s:ansistring):pointer;\r
\r
implementation\r
\r
-function makehash(s:string):integer;\r
+function makehash(s:ansistring):integer;\r
const\r
shifter=6;\r
var\r
result := (result xor result shr 16) and (hashtable_size-1);\r
end;\r
\r
-procedure addtree(t:phashtable;s:string;item:pointer);\r
+procedure addtree(t:phashtable;s:ansistring;item:pointer);\r
var\r
hash:integer;\r
p:thashitem;\r
linklistadd(tlinklist(t[hash]),tlinklist(p));\r
end;\r
\r
-procedure deltree(t:phashtable;s:string);\r
+procedure deltree(t:phashtable;s:ansistring);\r
var\r
p,p2:thashitem;\r
hash:integer;\r
end;\r
\r
\r
-function findtree(t:phashtable;s:string):pointer;\r
+function findtree(t:phashtable;s:ansistring):pointer;\r
var\r
p:thashitem;\r
hash:integer;\r
\r
var\r
timezone:integer;\r
- timezonestr:string;\r
+ timezonestr:ansistring;\r
irctime,unixtime:integer;\r
tickcount:integer;\r
settimebias:integer;\r
procedure timehandler;\r
procedure init;\r
\r
-function timestring(i:integer):string;\r
-function timestrshort(i:integer):string;\r
+function timestring(i:integer):ansistring;\r
+function timestrshort(i:integer):ansistring;\r
\r
{$ifdef win32}\r
function unixtimefloat_systemtime:float;\r
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);\r
end;\r
\r
-function timestrshort(i:integer):string;\r
+function timestrshort(i:integer):ansistring;\r
const\r
- weekday:array[0..6] of string[4]=('Thu','Fri','Sat','Sun','Mon','Tue','Wed');\r
- month:array[0..11] of string[4]=('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');\r
+ weekday:array[0..6] of ansistring =('Thu','Fri','Sat','Sun','Mon','Tue','Wed');\r
+ month:array[0..11] of ansistring =('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');\r
var\r
y,m,d,h,min,sec,ms:word;\r
t:tdatetime;\r
inttostr(y);\r
end;\r
\r
-function timestring(i:integer):string;\r
+function timestring(i:integer):ansistring;\r
const\r
- weekday:array[0..6] of string[10]=('Thursday','Friday','Saturday','Sunday','Monday','Tuesday','Wednesday');\r
- month:array[0..11] of string[10]=('January','February','March','April','May','June','July','August','September','October','November','December');\r
+ weekday:array[0..6] of ansistring =('Thursday','Friday','Saturday','Sunday','Monday','Tuesday','Wednesday');\r
+ month:array[0..11] of ansistring =('January','February','March','April','May','June','July','August','September','October','November','December');\r
var\r
y,m,d,h,min,sec,ms:word;\r
t:tdatetime;\r
\r
procedure getmd5(const data;len:longint;var result);\r
\r
-function md5tostr(const md5:tmd5):string;\r
+function md5tostr(const md5:tmd5):ansistring;\r
\r
implementation\r
\r
-function inttohex(val,bits:integer):string;\r
+function inttohex(val,bits:integer):ansistring;\r
const\r
- hexchar:array[0..15] of char='0123456789abcdef';\r
+ hexchar:array[0..15] of ansichar='0123456789abcdef';\r
begin\r
inttohex := hexchar[val shr 4]+hexchar[val and $f];\r
end;\r
md5finish(t,result);\r
end;\r
\r
-function md5tostr(const md5:tmd5):string;\r
+function md5tostr(const md5:tmd5):ansistring;\r
var\r
a:integer;\r
- s:string;\r
+ s:ansistring;\r
begin\r
s := '';\r
for a := 0 to 15 do s := s + inttohex(md5[a],2);\r
function randombits(b:integer):longint;\r
\r
{generate a version 4 random uuid}\r
-function generate_uuid:string;\r
+function generate_uuid:ansistring;\r
\r
{$ifndef nolcorernd}\r
\r
end;\r
\r
const\r
- ch:array[0..15] of char='0123456789abcdef';\r
+ ch:array[0..15] of ansichar='0123456789abcdef';\r
\r
-function generate_uuid:string;\r
+function generate_uuid:ansistring;\r
var\r
buf:array[0..7] of word;\r
-function inttohex(w:word):string;\r
+function inttohex(w:word):ansistring;\r
begin\r
result := ch[w shr 12] + ch[(w shr 8) and $f] + ch[(w shr 4) and $f] + ch[w and $f];\r
end;\r
sourcestream:tstream;\r
destroysourcestream:boolean;\r
constructor create(asourcestream: tstream; adestroysourcestream:boolean);\r
- constructor createf(filename : string);\r
+ constructor createf(filename : ansistring);\r
\r
- function readline:string;\r
+ function readline:ansistring;\r
function eof:boolean;\r
destructor destroy; override;\r
private\r
destroysourcestream := false;\r
end;\r
\r
-constructor treadtxt.createf(filename : string);\r
+constructor treadtxt.createf(filename : ansistring);\r
begin\r
create(tfilestream.create(filename,fmOpenRead),true);\r
end;\r
procedure processmessages;\r
\r
var\r
- onshutdown:procedure(s:string);\r
+ onshutdown:procedure(s:ansistring);\r
\r
implementation\r
\r