:: Re: [DNG] simple-netaid-gtk is comm…
Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: aitor_czr
Fecha:  
A: dng
Asunto: Re: [DNG] simple-netaid-gtk is comming soon
Hi again,

El 21/07/18 a las 11:44, aitor_czr escribió:
> Here you are an example about how to use this library in a C code file:
>
>
>
> /***************  BEGIN  **********************/
>
> #include <netstat.h>
>
> int main()
> {
>     netstat *ns;         // struct defined in netstat.h
>
>     ns = g_new0(netstat, 1);
>     if(!ns) {
>         printf("Memory failure\n");
>         exit( EXIT_FAILURE );
>     }
>
>     ns->fnetd = (FNETD*)malloc(sizeof(FNETD));
>     ns->fnetd->netdevlist = (NETDEVLIST*)malloc(sizeof(NETDEVLIST));
>
>
>     netinfo(ns->fnetd->netdevlist);      // THIS LINE DOES THE WORK ! !
>
>
>     / * *
>       *  And now we can get the netdev information:
>
>     // The name of the wired device:
>     GString *wired_device =  g_string_new
> (ns->fnetd->netdevlist->info.wired_device_name);
>
>     // The name of the wireless device:
>     GString *wireless_device = g_string_new
> (ns->fnetd->netdevlist->info.wireless_device_name);
>
>     // Are we connected or disconnected?
>     gboolean connected = ns->fnetd->netdevlist->info.connected;
>
> // Is the wire plugged or unplugged?
>     gboolean plugged = ns->fnetd->netdevlist->info.plug;
>
>     // The label of the status of the network connection will be
> something like: "Connected to wlan2 Euskaltel-58YA (90%)"
> GString *label = g_string_new (ns->fnetd->netdevlist->info.label);
>      / *
>        *      etc....
>        *  */
>
>
>      // Free the memory:
>
>     if(ns->fnetd->netdev_fp) netproc_close(ns->fnetd->netdev_fp);
>     netproc_netdevlist_clear(ns->fnetd->netdevlist);
>     free(ns->fnetd->netdevlist);
> //netproc_netdevlist_clear(ns->fnetd->netdevlist);
>     free(ns->fnetd);
>
>     return 0;
> }
>
> /*************** END   **********************/


This example was only for anything but a trivial example program and
code contains errors.
Here you are a further detailed example of C code using the
"libsn_netstat.so" shared library:

http://gnuinos.org/backend.tar.bz2

Uncompress the folder and run the "build" script. Don't forget to
install libiw-dev and cmake.

HTH,

  Aitor.