\r
{$include lcoreconfig.inc}\r
\r
-{$ifndef win32}\r
-uses sockets;\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
{$ifdef win32}\r
AF_INET=2;\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=tbufferstring;\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):thostname;\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:thostname;var binip:tbinip):boolean;\r
+function ipstrtobinf(const s:thostname):tbinip;\r
+function ipbintostr(const binip:tbinip):thostname;\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):thostname;\r
+function ip6strtobin(const s:thostname;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:thostname):longint;\r
\r
function needconverttov4(const ip:tbinip):boolean;\r
procedure converttov4(var ip:tbinip);\r
procedure converttov6(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:thostname):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:thostname;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):thostname;\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):thostname;\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:thostname;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):thostname;\r
var\r
a:integer;\r
begin\r