You can use the uname
function to find out some information about
the type of computer your program is running on. This function and the
associated data type are declared in the header file
`sys/utsname.h'.
As a bonus, uname
also gives some information identifying the
particular system your program is running on. This is the same information
which you can get with functions targetted to this purpose described in
section Host Identification.
utsname
structure is used to hold information returned
by the uname
function. It has the following members:
char sysname[]
char release[]
char version[]
char machine[]
machine
is supposed to describe just the
hardware, it consists of the first two parts of the configuration name:
`cpu-manufacturer'. For example, it might be one of these:
"sparc-sun"
,"i386-anything"
,"m68k-hp"
,"m68k-sony"
,"m68k-sun"
,"mips-dec"
char nodename[]
gethostname
;
see section Host Identification.
gethostname() is implemented with a call to uname().
char domainname[]
getdomainname
; see section Host Identification. This element
is a relatively recent invention and use of it is not as portable as
use of the rest of the structure.
uname
function fills in the structure pointed to by
info with information about the operating system and host machine.
A non-negative value indicates that the data was successfully stored.
-1
as the value indicates an error. The only error possible is
EFAULT
, which we normally don't mention as it is always a
possibility.
Go to the first, previous, next, last section, table of contents.