Re: [fpc-pascal] RE: Get Local IP using glib (eth0,eth1)

2006-10-06 Thread TOUZEAU DAVID
Many thanks to the community To reply to Graeme : why not just use the /sbin/ifconfig output ? Simply to be more dev compliance... using an external program is slower and sometime ifconfig doesn't exist or is deleted on target computers. To reply to Marco : And the only "good" solution is a po

Re: [fpc-pascal] RE: Get Local IP using glib (eth0,eth1)

2006-10-06 Thread Marco van de Voort
> > Better, but still Linux only. For a good solution, > > a resolver unit that accesses libc should be > > written that is portable (unlike the libc unit) > > If I understood correctly, the OP had two questions: > > 1. Retrieve a list of interface names on a *linux* system. > 2. Return the IP ad

Re: [fpc-pascal] RE: Get Local IP using glib (eth0,eth1)

2006-10-06 Thread Graeme Geldenhuys
I have these two functions in my .bashrc file. You only need to run "ii" for the cool output. Now back to the question - If it is for linux only, why not just use the /sbin/ifconfig output. After all, it is accurate and seem much easier than all those libc/library methods. I pull the IPs and I

[fpc-pascal] RE: Get Local IP using glib (eth0,eth1)

2006-10-06 Thread Jeff Pohlmeyer
Better, but still Linux only. For a good solution, a resolver unit that accesses libc should be written that is portable (unlike the libc unit) If I understood correctly, the OP had two questions: 1. Retrieve a list of interface names on a *linux* system. 2. Return the IP address for a given *

Re: [fpc-pascal] RE: Get Local IP using glib (eth0,eth1)

2006-10-06 Thread TOUZEAU DAVID
Many Thanks for this way jeff... /proc/net/dev is more compatible Impressed it for your information. My program will run only on linux system... Marco van de Voort a écrit : I would parse /proc/net/dev instead Better, but still Linux only. For a good solution, a resolver unit that ac

Re: [fpc-pascal] RE: Get Local IP using glib (eth0,eth1)

2006-10-06 Thread Marco van de Voort
> I would parse /proc/net/dev instead Better, but still Linux only. For a good solution, a resolver unit that accesses libc should be written that is portable (unlike the libc unit) ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://

[fpc-pascal] RE: Get Local IP using glib (eth0,eth1)

2006-10-06 Thread Jeff Pohlmeyer
how can i list wich interface loaded without need to parse /etc/networks/...? I would parse /proc/net/dev instead program ifnames; var s:shortstring; f:text; p:LongInt; begin assign(f,'/proc/net/dev'); reset(f); while not eof(f) do begin readln(f,s); p:=pos(':',s); if ( p

Re: [fpc-pascal] RE: Get Local IP using glib (eth0,eth1)

2006-10-06 Thread TOUZEAU DAVID
OK i understand that i using i386 no 64 bits Marco van de Voort a écrit : This function works perfectly without need to regex ifconfig... And i use glibc I develop only on linux system. Note that it is linux/x86 only. No 64-bit, or other platforms. -- David Touzeau --

Re: [fpc-pascal] RE: Get Local IP using glib (eth0,eth1)

2006-10-06 Thread Marco van de Voort
> This function works perfectly without need to regex ifconfig... And i > use glibc > I develop only on linux system. Note that it is linux/x86 only. No 64-bit, or other platforms. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lis

Re: [fpc-pascal] RE: Get Local IP using glib (eth0,eth1)

2006-10-06 Thread TOUZEAU DAVID
Many Thanks Jeff and Micha. This function works perfectly without need to regex ifconfig... And i use glibc I develop only on linux system. Great respects... Just another question... (this because i came from Windows OS) how can i list wich interface loaded without need to parse /etc/networks

Re: [fpc-pascal] RE: Get Local IP using glib (eth0,eth1)

2006-10-05 Thread Micha Nelissen
Jeff Pohlmeyer wrote: >> > function to read the local IP eth0/eth1 using glibc library. > > This one is a little cleaner... > > program ip_addr; > {$MODE OBJFPC} > > uses libc; It doesn't seem like you're using libc specific functions ? You can also write a fpc 'native' one using fpsocket and f

[fpc-pascal] RE: Get Local IP using glib (eth0,eth1)

2006-10-05 Thread Jeff Pohlmeyer
> function to read the local IP eth0/eth1 using glibc library. program ip_addr; ... end. Please ignore my last post - This one is a little cleaner... program ip_addr; {$MODE OBJFPC} uses libc; function GetIPAddressOfInterface( if_name:ansistring):ansistring; var ifr : ifreq; sock : lo

[fpc-pascal] RE: Get Local IP using glib (eth0,eth1)

2006-10-05 Thread Jeff Pohlmeyer
I'm trying to write a function to read the local IP eth0/eth1 using glibc library... program ip_addr; {$MODE OBJFPC} uses libc; const IP_NAMESIZE = 16; type ipstr = array[0..IP_NAMESIZE-1] of char; function GetIPAddressOfInterface( if_name:ansistring):ansistring; var ifr : ifreq; tmp:ips