Re: request for help



On Mon, 20 August 20:07 christophe barbe wrote:
> I've attached to this mail a patch which is supposed to add an option in
> the preferences dialogbox.

I don't understand why you are using the uname command to get the system name.
After all uname() is a system call and it is Posix.  Why not take the simpler
approach and use that?  You also avoid the overhead of creating pipes, fork
and exec and then reading from a file descriptor.  Lost of system calls
replaced with just one.  Got to be better.

Call it once during initialisation to get the system name and just save the
string for use later.

Try something like

#include <sys/utsname.h>

char *
get_system_name (void)
{
  struct utsname buf;
  char *sysname;

  uname (&buf);
  sysname = malloc (strlen (buf.sysname) + strlen (buf.release) + 2);
  sprintf (sysname, "%s %s", buf.sysname, buf.release);
  return sysname;
}

obviously that needs error checks but its the right sequence of actions.

Brian




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