:: Re: [DNG] gcc error: "error: unkno…
Página Inicial
Delete this message
Reply to this message
Autor: aitor_czr
Data:  
Para: Edward Bartolo
CC: dng
Assunto: Re: [DNG] gcc error: "error: unknown type name,,, ‘GtkObject’"
Ok, thanks. I'm looking at the backend :)

On 12/06/2015 08:45 AM, Edward Bartolo wrote:
> Hi Aitor,
>
> As you can see, popen runs the command opening a pipe to trap its
> textual output. shell_reader is a pointer to the actual output reader.
> fgets reads the shell_reader line by line until it returns false. It
> places lines in buffer using 1024 as a size limit in the quoted code
> snippet. The read string in buffer is null terminated.
>
> This should set you going.
>
> Edward
>
> On 06/12/2015, Edward Bartolo<edbarx@???> 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));