:: Re: [DNG] gcc error: "error: unkno…
トップ ページ
このメッセージを削除
このメッセージに返信
著者: aitor_czr
日付:  
To: Edward Bartolo
CC: dng
題目: Re: [DNG] gcc error: "error: unknown type name,,, ‘GtkObject’"
Hi Edward,

The following code reads line by line the textual output of 'backend 6':

#include <stdio.h>

main()
{
FILE * fp;
char str[1024];

fp = popen ("/usr/lib/netman/bin/backend 6", "r");

if (fp == NULL) return -1;

   fgets (str, 1024, fp);
   while (!feof (fp))
   {
     printf ("%s", str);
     fgets (str, 1024, fp);
   }
   pclose (fp);
   return 0;
}


I will have a look at your code.

Thanks,

    Aitor.


On 06/12/15 08:40, Edward Bartolo wrote:
> Hi Aitor,
>
> The best way for you is to use the backend's code for reference. What
> you want is already implemented there. TProcesss was used to trap the
> background cli commands output although there are instances where that
> output is discarded.
>
> What you need is this from the CLI backend's code (core_functions.c):
> [ code snippet from getDefaultDevices() ]
>
> FILE * shell_reader;
> char scan_buffer[1024];
>
> [...]
>
> shell_reader = popen(command, "r");
>     if(!shell_reader) {
>         fprintf(
>             stderr,
>             "ERROR: getDefaultDevices(): "
>             "popen() failed (Error: %s)\n",
>             strerror(errno)
>         );

>                 
>         return -1;
>     }

>             
>     char* ptr;
>     while((fgets(scan_buffer, 1024, shell_reader))) {
>       ptr = (char*) scan_buffer;
>         if (strstr((char *) scan_buffer, "lo") == ptr)
>             continue;
>         else if (strstr((char *) scan_buffer, "wl") == ptr) {
>             snprintf(
>                 _wl,
>                 1024,
>                 "%s",
>                 (char*) scan_buffer
>             );
>         } else if (
>             strstr((char *) scan_buffer, "eth") == ptr ||
>             strstr((char *) scan_buffer, "en") == ptr    
>         ) {
>             snprintf(
>                 _eth,
>                 1024,
>                 "%s",
>                 (char*) scan_buffer
>             );
>         }
>     }

>     
>     pclose(shell_reader);

>     
>
> Ask again if you in the event you may need more help.
>
>
> Edward
>
>
> On 05/12/2015, aitor_czr<aitor_czr@???> wrote:
>> >Hi Edward,
>> >
>> >I'm trying to scan the existing connections. As i can see in the
>> >TForm1.btnLoadExistingClick(Sender: TObject) method, you used 'TProcess'
>> >for running external applications. In C this must be replaced by the
>> >'system' command.
>> >
>> >Now i'm looking at the TProcess options. For example:
>> >
>> > Proc.Executable := 'cat';
>> > Proc.Parameters.Add('/etc/network/interfaces');
>> > Proc.Options := [poUsePipes, poWaitOnExit];
>> > Proc.Execute;
>> >
>> >Here are the definitions:
>> >
>> >http://olympiad.cs.uct.ac.za/docs/fpc-2.4.4/fcl/process/tprocess.options.html
>> >
>> >Cheers,
>> >
>> >     Aitor.

>> >
>> >On 12/04/2015 01:00 PM, Edward Bartolo<edbarx@???> wrote:
>>> >>Hi Aitor,
>>> >>
>>> >>I succeeded to run my trial gtk3 application with events without
>>> >>errors. I always wanted to learn coding GUI applications for Linux in
>>> >>C/C++. This can be a good exercise.
>>> >>
>>> >>Edward
>>> >>
>>> >>
>>> >>On 02/12/2015, aitor_czr<aitor_czr@???> wrote:
>>>>> >>> >Woow !!
>>>>> >>> >
>>>>> >>> >On 02/12/15 12:08, Edward Bartolo wrote:
>>>>>>> >>>> >>priv = (Private*) g_malloc (sizeof (struct _Private));