re: More on nm-OpenSwan




I'm trying to implement the ipsec connection startup command

I'm using the function g_spawn_async_with_pipes to call the ipsec binary with the appropriate args.
The process will terminate when successful.

I want to pipe the output of the process (stdout) to a Status window (pop-up widget??) in real-time.

I'm thinking I need to use a GIOChannel to capture the output this way. Can anyone clarify?

example:

<code>
GFILE *output = g_fopen("//dev//stdout", "r");
GIOChannel *connOutput = NULL;
gchar * stdout_buffer;
connOutput = g_io_channel_unix_new(&output);

while (g_io_channel_read_line(&connOutput, &stdout_buffer, NULL, NULL, &error) != (G_IO_STATUS_EOF || G_IO_STATUS_ERROR))
{
   nm_status_update("%s", &stdout_buffer); //pseudo function for now
   if (stdout_buffer == "\n\n")
   {
         g_io_channel_close(&connOutput);
         g_fclose(&output);
         g_free(&stdout_buffer);
         return 0:
 }
}
.....
</code>


Does that make any sense or am I going about this the wrong way?

Thanks for any help.

Steve.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]