Subject: Re: uname and machine identity
From: [email-masked] (Mumit Khan)

6 Jan 1999 03:15:36 -0800
Message-ID: <[email-masked]>
References: <AC4D3D80B239D211BC140000F879A2BA0AECB7@NTMAIL>
To: Ian Collins <[email-masked]>
Cc: "Gnu-Win32 (E-mail)" <[email-masked]>

Ian Collins <[email-masked]> writes:
> I need to get a unique system identity from an application running on b20.1.
> On other Unixes, I use,
> 
> typedef struct utsname UTS
> 
> UTS uts;
> 
> uname(uts)

What problem(s) did you have? It should work just fine, at least the POSIX
part. The only gotcha is the domainname parameter, which lots of systems 
either do not implement (SunOS 4.1.x, Newlib in Cygwin) or implement under 
a different name (eg., glibc2 requires __USE_GNU, otherwise __domainname). 
I don't remember offhand if POSIX requires the domainname field; it's
usually not that meaningful, or at best ambiguous as to what it means.

Here's a code snippet out of my platform configuration sources:

  #include <stdio.h>
  #include <sys/utsname.h>

  int 
  main () 
  {
    struct utsname u;

    if (uname (&u)) 
      {
        perror ("uname");
        exit (1);
      }

    printf ("sysname = %s\n", u.sysname);
    printf ("nodename = %s\n", u.nodename);
    printf ("release = %s\n", u.release);
    printf ("version = %s\n", u.version);
    printf ("machine = %s\n", u.machine);

    return 0;
  }

I of course believe there are better ways to configure your software
without using ``uname'' (eg., via a built-time configuration tool
such as GNU configure).

Regards,
Mumit

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".