delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/01/06/03:15:36

From: khan AT xraylith DOT wisc DOT edu (Mumit Khan)
Subject: Re: uname and machine identity
6 Jan 1999 03:15:36 -0800 :
Message-ID: <199901060605.AAA04909.cygnus.gnu-win32@modi.xraylith.wisc.edu>
References: <AC4D3D80B239D211BC140000F879A2BA0AECB7 AT NTMAIL>
To: Ian Collins <ianc AT kiwiplan DOT co DOT nz>
Cc: "Gnu-Win32 (E-mail)" <gnu-win32 AT cygnus DOT com>

Ian Collins <ianc AT kiwiplan DOT co DOT nz> 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
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019