network programming - How can I call ioctl for interface list, or other ioctl stuff, on Free Pascal? -
i've been googling , down, searching on free pascal wiki , on (obscure) mailing lists , have come empty on how use ioctl()
or fpioctl()
on free pascal.
i have bug report free pascal's bugtrack code enumerates network interfaces.
the code not compile since libc
unit has been deprecated.
lot of similar questions libc
point wiki entry talks it's demise.
not give indication on sioc*if*
stuff has gone.
does mean of ioctl
functionality has gone?
using find
, grep
, under /usr/share/fpcsrc/<fpc-version>/, i've been able track usage of fpioctl()
in relation terminals termios
unit. other stuff uses looks it's under other oss.
apart i'm unable find of use if want like:
if ioctl(sock, siocgifconf, @ifc)= 0 begin {...} end;
so, can free pascal community give me pointer what's current situation if 1 wants ioctl
calls under linux?
does baseunix.fpioctl
meet use case? have @ baseunix documentation. found an example of using here (reposted below).
program testrpi; {$mode objfpc}{$h+} uses baseunix, classes, {$ifdef unix}{$ifdef usecthreads} cthreads, {$endif}{$endif} sysutils; const i2c_slave = 1795; var buf : packed array [0..1] of char; c : char; devpath : string = '/dev/i2c-1'; handle : cint; idevaddr : cint = $04; begin try handle := fpopen(devpath,o_rdwr); fpioctl(handle, i2c_slave, pointer(idevaddr)); except writeln('error initalizing i2c'); halt; end; while true begin write('enter digit 1-9:'); readln(c); if (not(c in ['1'..'9'])) begin writeln('oops - try again'); continue; end; buf[0] := chr(ord(c) - ord('0')); try fpwrite(handle, buf, 1); except writeln('error writing'); halt; end; //try buf[0] := #99; sleep(10); try fpread(handle, buf, 1); except writeln('error reading'); halt; end; //try writeln('buf=', ord(buf[0])); end; //while fpclose(handle); end.
Comments
Post a Comment