linux.dup(original,result);\r
end;\r
{$define gettimeofdaysec := gettimeofday}\r
+ const\r
+ IPPROTO_UDP=17;\r
+ IPPROTO_ICMP=1;\r
+ function ntohs(invalue:word):word;inline;\r
+ var\r
+ invaluebytes : array[0..1] of byte absolute invalue;\r
+ resultbytes : array[0..1] of byte absolute result;\r
+ begin\r
+ {$ifdef endian_little}\r
+ resultbytes[0] := invaluebytes[1];\r
+ resultbytes[1] := invaluebytes[0];\r
+ {$else}\r
+ result := invalue;\r
+ {$endif}\r
+ end; \r
+ {$define need_v6constants}\r
{$else}\r
\r
{$define sigprocmask := fpsigprocmask}\r
{$ifndef ver1_9_2}\r
{$define flock := fpflock}\r
{$ifndef ver1_9_4}\r
- procedure Execl(Todo:string);inline;\r
+ //beware: this is needed because FPC_FULLVERSION >= 30200 breaks delphi 6 even inside an ifdef it shouldn't process\r
+ {$ifdef fpc}\r
+ {$ifdef ver3}\r
+ {$ifndef ver3_0}{$ifndef ver3_1}{$define fpc_3_2_or_later}{$endif}{$endif}\r
+ {$endif}\r
+ {$ifdef ver4}{$define fpc_3_2_or_later}{$endif}\r
+ {$endif}\r
+ {$ifdef fpc_3_2_or_later}\r
+ procedure Execl(Todo:rawbytestring);inline;\r
+ {$else}\r
+ procedure Execl(Todo:string);inline;\r
+ {$endif}\r
var\r
p : ppchar;\r
begin\r
- p := unixutil.StringToPPChar(Todo,1);\r
+ p := unixutil.StringToPPChar(Todo,0);\r
if (p=nil) or (p^=nil) then exit;\r
fpexecv(p^,p);\r
end;\r
+ function SendTo(Sock: LongInt; const Buf;BufLen: LongInt;Flags: LongInt;var Addr;AddrLen: LongInt):LongInt;\r
+ begin\r
+ result := fpsendto(sock,@buf,buflen,flags,@addr,addrlen);\r
+ end;\r
+ function RecvFrom(Sock: LongInt;var Buf;Buflen: LongInt;Flags: LongInt;var Addr;var addrlen: Longint):LongInt;\r
+ begin\r
+ result := fprecvfrom(sock,@buf,buflen,flags,@addr,@addrlen);\r
+ end;\r
+ {$define socket := fpsocket}\r
+ function Bind(Sock: LongInt;const Addr;AddrLen: LongInt):Boolean;\r
+ begin\r
+ result := fpbind(sock,@addr,addrlen) = 0;\r
+ end;\r
+ function SetSocketOptions(Sock: LongInt;Level: LongInt;OptName: LongInt;const OptVal;optlen: LongInt):LongInt;\r
+ begin\r
+ result := fpsetsockopt(sock,level,optname,@optval,optlen);\r
+ end;\r
+ function Connect(Sock: LongInt;const Addr;Addrlen: LongInt):Boolean;\r
+ begin\r
+ result := fpconnect(sock,@addr,addrlen) >= 0;\r
+ end;\r
+ function listen(Sock: LongInt;MaxConnect: LongInt):Boolean;\r
+ begin\r
+ result := fplisten(sock,maxconnect) = 0;\r
+ end; \r
+ function GetPeerName(Sock: LongInt; var Addr;var Addrlen: LongInt):LongInt;\r
+ begin\r
+ result := fpgetpeername(sock,@addr,@addrlen);\r
+ end;\r
+ function GetSocketName(Sock: LongInt; var Addr;var Addrlen: LongInt):LongInt;\r
+ begin\r
+ result := fpgetsockname(sock,@addr,@addrlen);\r
+ end;\r
+ function Accept(Sock: LongInt; var Addr; var Addrlen: LongInt):LongInt;\r
+ begin\r
+ result := fpaccept(sock,@addr,@addrlen);\r
+ end;\r
{$endif}\r
{$endif}\r
+ {$ifdef ver2_0}\r
+ const\r
+ IPPROTO_UDP=17;\r
+ IPPROTO_ICMP=1;\r
+ {$define need_v6constants}\r
+ {$endif}\r
+ {$ifdef ver1_9}\r
+ const\r
+ IPPROTO_UDP=17;\r
+ IPPROTO_ICMP=1;\r
+ function ntohs(invalue:word):word;inline;\r
+ var\r
+ invaluebytes : array[0..1] of byte absolute invalue;\r
+ resultbytes : array[0..1] of byte absolute result;\r
+ begin\r
+ {$ifdef endian_little}\r
+ resultbytes[0] := invaluebytes[1];\r
+ resultbytes[1] := invaluebytes[0];\r
+ {$else}\r
+ result := invalue;\r
+ {$endif}\r
+ end;\r
+ {$define need_v6constants}\r
+ {$endif}\r
procedure gettimeofday(var tv:ttimeval);inline;\r
begin\r
fpgettimeofday(@tv,nil); \r
sys_eintr=esyseintr;\r
\r
{$endif}\r
+ {$ifdef need_v6constants}\r
+ {$ifdef linux} \r
+ //the below values are only known correct on linux, I don't support \r
+ //1.0.x on any other unix platform atm anyway --plugwash\r
+ const \r
+ IPPROTO_IPV6 = 41;\r
+ IPV6_V6ONLY = 26;\r
+ {$endif}\r
+ {$endif}\r
+ {$ifdef freebsd}\r
+ //freepascal doesn't seem to define IPV6_V6ONLY on freebsd, the definition\r
+ //here is taken from the include files of a freebsd 8 system\r
+ const\r
+ IPV6_V6ONLY = 27;\r
+ {$endif}\r
+\r
{$endif}\r
+\r
+ \r