lcore.org gitweb
/
lcore.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Yet more delphi 2010 fixes
[lcore.git]
/
binipstuff.pas
diff --git
a/binipstuff.pas
b/binipstuff.pas
old mode 100755
(executable)
new mode 100644
(file)
index
70ac401
..
40b5f9f
--- a/
binipstuff.pas
+++ b/
binipstuff.pas
@@
-8,11
+8,9
@@
interface
\r
{$include lcoreconfig.inc}
\r
\r
\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
\r
{$ifdef fpc}
\r
{$mode delphi}
\r
@@
-23,7
+21,7
@@
uses sockets;
{$include uint32.inc}
\r
\r
const
\r
{$include uint32.inc}
\r
\r
const
\r
- hexchars:array[0..15] of char='0123456789abcdef';
\r
+ hexchars:array[0..15] of
ansi
char='0123456789abcdef';
\r
AF_INET=2;
\r
{$ifdef win32}
\r
AF_INET6=23;
\r
AF_INET=2;
\r
{$ifdef win32}
\r
AF_INET6=23;
\r
@@
-86,12
+84,19
@@
type
\r
\r
\r
\r
\r
\r
-
{$ifdef ipv6}
\r
+ {$ifdef ipv6}
\r
{$ifdef ver1_0}
\r
cuint16=word;
\r
cuint32=dword;
\r
sa_family_t=word;
\r
\r
{$ifdef ver1_0}
\r
cuint16=word;
\r
cuint32=dword;
\r
sa_family_t=word;
\r
\r
+ TInetSockAddr6 = packed record
\r
+ sin6_family: word;
\r
+ sin6_port: word;
\r
+ sin6_flowinfo: uint32;
\r
+ sin6_addr: tin6_addr;
\r
+ sin6_scope_id: uint32;
\r
+ end;
\r
{$endif}
\r
{$endif}
\r
TinetSockAddrv = packed record
\r
{$endif}
\r
{$endif}
\r
TinetSockAddrv = packed record
\r
@@
-113,7
+118,7
@@
bin IP list code, by beware
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
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=
tip
string;
\r
\r
function biniplist_new:tbiniplist;
\r
procedure biniplist_add(var l:tbiniplist;ip:tbinip);
\r
\r
function biniplist_new:tbiniplist;
\r
procedure biniplist_add(var l:tbiniplist;ip:tbinip);
\r
@@
-123,18
+128,18
@@
procedure biniplist_set(var l:tbiniplist;index:integer;ip:tbinip);
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
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):
tip
string;
\r
function isbiniplist(const l:tbiniplist):boolean;
\r
\r
function htons(w:word):word;
\r
function htonl(i:uint32):uint32;
\r
\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:
tip
string;var binip:tbinip):boolean;
\r
+function ipstrtobinf(const s:
tip
string):tbinip;
\r
+function ipbintostr(const binip:tbinip):
tip
string;
\r
{$ifdef ipv6}
\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):
tip
string;
\r
+function ip6strtobin(const s:
tip
string;var bin:tin6_addr):boolean;
\r
{$endif}
\r
\r
function comparebinip(const ip1,ip2:tbinip):boolean;
\r
{$endif}
\r
\r
function comparebinip(const ip1,ip2:tbinip):boolean;
\r
@@
-144,13
+149,13
@@
function comparebinipmask(ip1,ip2:tbinip;bits:integer):boolean;
procedure addipsoffamily(var l:tbiniplist;const l2:tbiniplist;family:integer);
\r
\r
{deprecated}
\r
procedure addipsoffamily(var l:tbiniplist;const l2:tbiniplist;family:integer);
\r
\r
{deprecated}
\r
-function longip(s:string):longint;
\r
+function longip(s:
tip
string):longint;
\r
\r
function needconverttov4(const ip:tbinip):boolean;
\r
procedure converttov4(var ip:tbinip);
\r
\r
function inaddrvtobinip(inaddrv:tinetsockaddrv):tbinip;
\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:
ansi
string;var inaddr:tinetsockaddrv):integer;
\r
function inaddrsize(inaddr:tinetsockaddrv):integer;
\r
\r
implementation
\r
function inaddrsize(inaddr:tinetsockaddrv):integer;
\r
\r
implementation
\r
@@
-185,7
+190,7
@@
begin
{$endif}
\r
end;
\r
\r
{$endif}
\r
end;
\r
\r
-function makeinaddrv(addr:tbinip;port:string;var inaddr:tinetsockaddrv):integer;
\r
+function makeinaddrv(addr:tbinip;port:
ansi
string;var inaddr:tinetsockaddrv):integer;
\r
begin
\r
result := 0;
\r
{ biniptemp := forwardlookup(addr,10);}
\r
begin
\r
result := 0;
\r
{ biniptemp := forwardlookup(addr,10);}
\r
@@
-217,11
+222,11
@@
end;
\r
{internal}
\r
{converts dotted v4 IP to longint. returns host endian order}
\r
\r
{internal}
\r
{converts dotted v4 IP to longint. returns host endian order}
\r
-function longip(s:string):longint;
\r
+function longip(s:
tip
string):longint;
\r
var
\r
l:longint;
\r
a,b:integer;
\r
var
\r
l:longint;
\r
a,b:integer;
\r
-function convertbyte(const s:string):integer;
\r
+function convertbyte(const s:
ansi
string):integer;
\r
begin
\r
result := strtointdef(s,-1);
\r
if result < 0 then begin
\r
begin
\r
result := strtointdef(s,-1);
\r
if result < 0 then begin
\r
@@
-272,7
+277,7
@@
begin
ipstrtobin(s,result);
\r
end;
\r
\r
ipstrtobin(s,result);
\r
end;
\r
\r
-function ipstrtobin(const s:string;var binip:tbinip):boolean;
\r
+function ipstrtobin(const s:
tip
string;var binip:tbinip):boolean;
\r
begin
\r
binip.family := 0;
\r
result := false;
\r
begin
\r
binip.family := 0;
\r
result := false;
\r
@@
-294,7
+299,7
@@
begin
end;
\r
end;
\r
\r
end;
\r
end;
\r
\r
-function ipbintostr(const binip:tbinip):string;
\r
+function ipbintostr(const binip:tbinip):
tip
string;
\r
var
\r
a:integer;
\r
begin
\r
var
\r
a:integer;
\r
begin
\r
@@
-317,7
+322,7
@@
end;
\r
{
\r
IPv6 address binary to/from string conversion routines
\r
\r
{
\r
IPv6 address binary to/from string conversion routines
\r
-written by beware
(steendijk at xs4all dot nl)
\r
+written by beware
\r
\r
- implementation does not depend on other ipv6 code such as the tin6_addr type,
\r
the parameter can also be untyped.
\r
\r
- implementation does not depend on other ipv6 code such as the tin6_addr type,
\r
the parameter can also be untyped.
\r
@@
-330,9
+335,9
@@
written by beware (steendijk at xs4all dot nl)
{fpc has hostaddrtostr6 and strtohostaddr6 but the later isnt implemented yet}
\r
\r
\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):
tip
string;
\r
{base16 with lowercase output}
\r
{base16 with lowercase output}
\r
-function makehex(w:word):string;
\r
+function makehex(w:word):
ansi
string;
\r
begin
\r
result := '';
\r
if w >= 4096 then result := result + hexchars[w shr 12];
\r
begin
\r
result := '';
\r
if w >= 4096 then result := result + hexchars[w shr 12];
\r
@@
-388,10
+393,10
@@
begin
end;
\r
end;
\r
\r
end;
\r
end;
\r
\r
-function ip6strtobin(const s:string;var bin:tin6_addr):boolean;
\r
+function ip6strtobin(const s:
tip
string;var bin:tin6_addr):boolean;
\r
var
\r
a,b:integer;
\r
var
\r
a,b:integer;
\r
- fields:array[0..7] of string;
\r
+ fields:array[0..7] of
ansi
string;
\r
fieldcount:integer;
\r
emptyfield:integer;
\r
wordcount:integer;
\r
fieldcount:integer;
\r
emptyfield:integer;
\r
wordcount:integer;
\r
@@
-531,9
+536,13
@@
end;
{-----------biniplist stuff--------------------------------------------------}
\r
\r
const
\r
{-----------biniplist stuff--------------------------------------------------}
\r
\r
const
\r
- biniplist_prefix='bipl'#0;
\r
- biniplist_prefixlen=length(biniplist_prefix);
\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
\r
\r
+ biniplist_prefixlen=5;
\r
+
\r
function biniplist_new:tbiniplist;
\r
begin
\r
result := biniplist_prefix;
\r
function biniplist_new:tbiniplist;
\r
begin
\r
result := biniplist_prefix;
\r
@@
-583,7
+592,7
@@
begin
l := l + copy(l2,biniplist_prefixlen+1,maxlongint);
\r
end;
\r
\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):
tip
string;
\r
var
\r
a:integer;
\r
begin
\r
var
\r
a:integer;
\r
begin
\r