:: Re: [DNG] gcc error: "error: unknow…
Góra strony
Delete this message
Reply to this message
Autor: Edward Bartolo
Data:  
Dla: aitor_czr
CC: dng
Temat: Re: [DNG] gcc error: "error: unknown type name,,, ‘GtkObject’"
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));
>
>