Uname.pm 23.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640
#
# This is not a runnable script, it is a Perl module, a collection of variables, subroutines, etc.
# To get help about exported variables and subroutines, execute the following command:
#
#     perldoc Uname.pm
#
# or see POD (Plain Old Documentation) embedded to the source...
#
#
#//===----------------------------------------------------------------------===//
#//
#// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
#// See https://llvm.org/LICENSE.txt for license information.
#// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#//
#//===----------------------------------------------------------------------===//
#

package Uname;

use strict;
use warnings;
use warnings::register;
use Exporter;

use POSIX;
use File::Glob ":glob";
use Net::Domain qw{};

# Following code does not work with Perl 5.6 on Linux* OS and Windows* OS:
#
#     use if $^O eq "darwin", tools => qw{};
#
# The workaround for Perl 5.6:
#
BEGIN {
    if ( $^O eq "darwin" or $^O eq "linux" ) {
	require tools;
        import tools;
    }; # if
    if ( $^O eq "MSWin32" ) {
        require Win32;
    }; # if
}; # BEGIN

my $mswin = qr{\A(?:MSWin32|Windows_NT)\z};

my @posix = qw{ kernel_name fqdn kernel_release kernel_version machine };
    # Properties supported by POSIX::uname().
my @linux =
    qw{ processor hardware_platform operating_system };
    # Properties reported by uname in Linux* OS.
my @base = ( @posix, @linux );
    # Base properties.
my @aux =
    (
        qw{ host_name domain_name },
        map( "operating_system_$_", qw{ name release codename description } )
    );
    # Auxiliary properties.
my @all = ( @base, @aux );
    # All the properties.
my @meta = qw{ base_names all_names value };
    # Meta functions.

our $VERSION     = "0.07";
our @ISA         = qw{ Exporter };
our @EXPORT      = qw{};
our @EXPORT_OK   = ( @all, @meta );
our %EXPORT_TAGS =
    (
        base => [ @base ],
        all  => [ @all  ],
        meta => [ @meta ],
    );

my %values;
    # Hash of values. Some values are strings, some may be references to code which should be
    # evaluated to get real value. This trick is implemented because call to Net::Domain::hostfqdn()
    # is relatively slow.

# Get values from POSIX::uname().
@values{ @posix } = POSIX::uname();

# On some systems POSIX::uname() returns "short" node name (without domain name). To be consistent
# on all systems, we will get node name from alternative source.
if ( $^O =~ m/cygwin/i ) {
    # Function from Net::Domain module works well, but on Cygwin it prints to
    # stderr "domainname: not found". So we will use environment variables for now.
    $values{ fqdn } = lc( $ENV{ COMPUTERNAME } . "." . $ENV{ USERDNSDOMAIN } );
} else {
    # On systems other than Cygwin, let us use Net::Domain::hostfqdn(), but do it only node name
    # is really requested.
    $values{ fqdn } =
        sub {
            my $fqdn = Net::Domain::hostfqdn(); # "fqdn" stands for "fully qualified domain name".
            # On some systems POSIX::uname() and Net::Domain::hostfqdn() reports different names.
            # Let us issue a warning if they significantly different. Names are insignificantly
            # different if POSIX::uname() matches the beginning of Net::Domain::hostfqdn().
            if (
                $fqdn eq substr( $fqdn, 0, length( $fqdn ) )
                &&
                (
                    length( $fqdn ) == length( $fqdn )
                    ||
                    substr( $fqdn, length( $fqdn ), 1 ) eq "."
                )
            ) {
                # Ok.
            } else {
                warnings::warnif(
                    "POSIX::uname() and Net::Domain::hostfqdn() reported different names: " .
                        "\"$values{ fqdn }\" and \"$fqdn\" respectively\n"
                );
            }; # if
            return $fqdn;
        }; # sub
}; # if

if ( $^O =~ $mswin ) {
    if (
        $values{ machine } =~ m{\A(?:x86|[56]86)\z}
        and
        exists( $ENV{ PROCESSOR_ARCHITECTURE } ) and $ENV{ PROCESSOR_ARCHITECTURE } eq "x86"
        and
        exists( $ENV{ PROCESSOR_ARCHITEW6432 } )
    ) {
        if ( $ENV{ PROCESSOR_ARCHITEW6432 } eq "AMD64" ) {
            $values{ machine } = "x86_64";
        }; # if
    }; # if
}; # if

# Some values are not returned by POSIX::uname(), let us compute them.

# processor.
$values{ processor } = $values{ machine };

# hardware_platform.
if ( 0 ) {
} elsif ( $^O eq "linux" or $^O eq "freebsd" or $^O eq "netbsd" ) {
    if ( 0 ) {
    } elsif ( $values{ machine } =~ m{\Ai[3456]86\z} ) {
        $values{ hardware_platform } = "i386";
    } elsif ( $values{ machine } =~ m{\A(x86_64|amd64)\z} ) {
        $values{ hardware_platform } = "x86_64";
    } elsif ( $values{ machine } =~ m{\Aarmv7\D*\z} ) {
        $values{ hardware_platform } = "arm";
    } elsif ( $values{ machine } =~ m{\Appc64le\z} ) {
        $values{ hardware_platform } = "ppc64le";
    } elsif ( $values{ machine } =~ m{\Appc64\z} ) {
        $values{ hardware_platform } = "ppc64";
    } elsif ( $values{ machine } =~ m{\Aaarch64\z} ) {
        $values{ hardware_platform } = "aarch64";
    } elsif ( $values{ machine } =~ m{\Amips64\z} ) {
        $values{ hardware_platform } = "mips64";
    } elsif ( $values{ machine } =~ m{\Amips\z} ) {
        $values{ hardware_platform } = "mips";
    } elsif ( $values{ machine } =~ m{\Ariscv64\z} ) {
        $values{ hardware_platform } = "riscv64";
    } else {
        die "Unsupported machine (\"$values{ machine }\") returned by POSIX::uname(); stopped";
    }; # if
} elsif ( $^O eq "darwin" ) {
    if ( 0 ) {
    } elsif ( $values{ machine } eq "x86" or $values{ machine } eq "i386" ) {
        $values{ hardware_platform } =
            sub {
                my $platform = "i386";
                # Some OSes on Intel(R) 64 still reports "i386" machine. Verify it by using
                # the value returned by 'sysctl -n hw.optional.x86_64'. On Intel(R) 64-bit systems the
                # value == 1; on 32-bit systems the 'hw.optional.x86_64' property either does not exist
                # or the value == 0. The path variable does not contain a path to sysctl when
                # started by crontab.
                my $sysctl = ( which( "sysctl" ) or "/usr/sbin/sysctl" );
                my $output;
                debug( "Executing $sysctl..." );
                execute( [ $sysctl, "-n", "hw.optional.x86_64" ], -stdout => \$output, -stderr => undef );
                chomp( $output );
                if ( 0 ) {
                } elsif ( "$output" eq "" or "$output" eq "0" ) {
                    $platform = "i386";
                } elsif ( "$output" eq "1" ) {
                    $platform = "x86_64";
                } else {
                    die "Unsupported value (\"$output\") returned by \"$sysctl -n hw.optional.x86_64\"; stopped";
                }; # if
                return $platform;
            }; # sub {
    } elsif ( $values{ machine } eq "x86_64" ) {
	# Some OS X* versions report "x86_64".
	$values{ hardware_platform } = "x86_64";
    } else {
        die "Unsupported machine (\"$values{ machine }\") returned by POSIX::uname(); stopped";
    }; # if
} elsif ( $^O =~ $mswin ) {
    if ( 0 ) {
    } elsif ( $values{ machine } =~ m{\A(?:x86|[56]86)\z} ) {
        $values{ hardware_platform } = "i386";
    } elsif ( $values{ machine } eq "x86_64" or $values{ machine } eq "amd64" ) {
        # ActivePerl for IA-32 architecture returns "x86_64", while ActivePerl for Intel(R) 64 returns "amd64".
        $values{ hardware_platform } = "x86_64";
    } else {
        die "Unsupported machine (\"$values{ machine }\") returned by POSIX::uname(); stopped";
    }; # if
} elsif ( $^O eq "cygwin" ) {
    if ( 0 ) {
    } elsif ( $values{ machine } =~ m{\Ai[3456]86\z} ) {
        $values{ hardware_platform } = "i386";
    } elsif ( $values{ machine } eq "x86_64" ) {
        $values{ hardware_platform } = "x86_64";
    } else {
        die "Unsupported machine (\"$values{ machine }\") returned by POSIX::uname(); stopped";
    }; # if
} else {
    die "Unsupported OS (\"$^O\"); stopped";
}; # if

# operating_system.
if ( 0 ) {
} elsif ( $values{ kernel_name } eq "Linux" ) {
    $values{ operating_system } = "GNU/Linux";
    my $release;    # Name of chosen "*-release" file.
    my $bulk;       # Content of release file.
    # On Ubuntu, lsb-release is quite informative, e. g.:
    #     DISTRIB_ID=Ubuntu
    #     DISTRIB_RELEASE=9.04
    #     DISTRIB_CODENAME=jaunty
    #     DISTRIB_DESCRIPTION="Ubuntu 9.04"
    # Try lsb-release first. But on some older systems lsb-release is not informative.
    # It may contain just one line:
    #     LSB_VERSION="1.3"
    $release = "/etc/lsb-release";
    if ( -e $release ) {
        $bulk = read_file( $release );
    } else {
        $bulk = "";
    }; # if
    if ( $bulk =~ m{^DISTRIB_} ) {
        # Ok, this lsb-release is informative.
        $bulk =~ m{^DISTRIB_ID\s*=\s*(.*?)\s*$}m
            or runtime_error( "$release: There is no DISTRIB_ID:", $bulk, "(eof)" );
        $values{ operating_system_name } = $1;
        $bulk =~ m{^DISTRIB_RELEASE\s*=\s*(.*?)\s*$}m
            or runtime_error( "$release: There is no DISTRIB_RELEASE:", $bulk, "(eof)" );
        $values{ operating_system_release } = $1;
        $bulk =~ m{^DISTRIB_CODENAME\s*=\s*(.*?)\s*$}m
            or runtime_error( "$release: There is no DISTRIB_CODENAME:", $bulk, "(eof)" );
        $values{ operating_system_codename } = $1;
        $bulk =~ m{^DISTRIB_DESCRIPTION\s*="?\s*(.*?)"?\s*$}m
            or runtime_error( "$release: There is no DISTRIB_DESCRIPTION:", $bulk, "(eof)" );
        $values{ operating_system_description } = $1;
    } else {
        # Oops. lsb-release is missed or not informative. Try other *-release files.
        $release = "/etc/system-release";
        if ( not -e $release ) {    # Use /etc/system-release" if such file exists.
            # Otherwise try other "/etc/*-release" files, but ignore "/etc/lsb-release".
            my @releases = grep( $_ ne "/etc/lsb-release", bsd_glob( "/etc/*-release" ) );
            # On some Fedora systems there are two files: fedora-release and redhat-release
            # with identical content. If fedora-release present, ignore redjat-release.
            if ( grep( $_ eq "/etc/fedora-release", @releases ) ) {
                @releases = grep( $_ ne "/etc/redhat-release", @releases );
            }; # if
            if ( @releases == 1 ) {
                $release = $releases[ 0 ];
            } else {
                if ( @releases == 0 ) {
                    # No *-release files found, try debian_version.
                    $release = "/etc/debian_version";
                    if ( not -e $release ) {
                        $release = undef;
                        warning( "No release files found in \"/etc/\" directory." );
                    }; # if
                } else {
                    $release = undef;
                    warning( "More than one release files found in \"/etc/\" directory:", @releases );
                }; # if
            }; # if
        }; # if
        if ( defined( $release ) ) {
            $bulk = read_file( $release );
            if ( $release =~ m{system|redhat|fedora} ) {
                # Red Hat or Fedora. Parse the first line of file.
                # Typical values of *-release (one of):
                #     Red Hat Enterprise Linux* OS Server release 5.2 (Tikanga)
                #     Red Hat Enterprise Linux* OS AS release 3 (Taroon Update 4)
                #     Fedora release 10 (Cambridge)
                $bulk =~ m{\A(.*)$}m
                    or runtime_error( "$release: Cannot find the first line:", $bulk, "(eof)" );
                my $first_line = $1;
                $values{ operating_system_description } = $first_line;
                $first_line =~ m{\A(.*?)\s+release\s+(.*?)(?:\s+\((.*?)(?:\s+Update\s+(.*?))?\))?\s*$}
                    or runtime_error( "$release:1: Cannot parse line:", $first_line );
                $values{ operating_system_name    }  = $1;
                $values{ operating_system_release }  = $2 . ( defined( $4 ) ? ".$4" : "" );
                $values{ operating_system_codename } = $3;
            } elsif ( $release =~ m{SuSE} ) {
                # Typical SuSE-release:
                #     SUSE Linux* OS Enterprise Server 10 (x86_64)
                #     VERSION = 10
                #     PATCHLEVEL = 2
                $bulk =~ m{\A(.*)$}m
                    or runtime_error( "$release: Cannot find the first line:", $bulk, "(eof)" );
                my $first_line = $1;
                $values{ operating_system_description } = $first_line;
                $first_line =~ m{^(.*?)\s*(\d+)\s*\(.*?\)\s*$}
                    or runtime_error( "$release:1: Cannot parse line:", $first_line );
                $values{ operating_system_name } = $1;
                $bulk =~ m{^VERSION\s*=\s*(.*)\s*$}m
                    or runtime_error( "$release: There is no VERSION:", $bulk, "(eof)" );
                $values{ operating_system_release } = $1;
                if ( $bulk =~ m{^PATCHLEVEL\s*=\s*(.*)\s*$}m ) {
                    $values{ operating_system_release } .= ".$1";
                }; # if
            } elsif ( $release =~ m{debian_version} ) {
                # Debian. The file debian_version contains just version number, nothing more:
                #     4.0
                my $name = "Debian";
                $bulk =~ m{\A(.*)$}m
                    or runtime_error( "$release: Cannot find the first line:", $bulk, "(eof)" );
                my $version = $1;
                $values{ operating_system_name        } = $name;
                $values{ operating_system_release     } = $version;
                $values{ operating_system_codename    } = "unknown";
                $values{ operating_system_description } = sprintf( "%s %s", $name, $version );
            }; # if
        }; # if
    }; # if
    if ( not defined( $values{ operating_system_name } ) ) {
        $values{ operating_system_name } = "GNU/Linux";
    }; # if
} elsif ( $values{ kernel_name } eq "Darwin" ) {
    my %codenames = (
        10.4 => "Tiger",
        10.5 => "Leopard",
        10.6 => "Snow Leopard",
    );
   my $darwin;
   my $get_os_info =
       sub {
           my ( $name ) = @_;
           if ( not defined $darwin ) {
               $darwin->{ operating_system } = "Darwin";
               # sw_vers prints OS X* version to stdout:
               #     ProductName:       OS X*
               #     ProductVersion:    10.4.11
               #     BuildVersion:      8S2167
               # It does not print codename, so we code OS X* codenames here.
               my $sw_vers = which( "sw_vers" ) || "/usr/bin/sw_vers";
               my $output;
               debug( "Executing $sw_vers..." );
               execute( [ $sw_vers ], -stdout => \$output, -stderr => undef );
               $output =~ m{^ProductName:\s*(.*)\s*$}m
                   or runtime_error( "There is no ProductName in sw_vers output:", $output, "(eof)" );
               my $name = $1;
               $output =~ m{^ProductVersion:\s*(.*)\s*$}m
                   or runtime_error( "There is no ProductVersion in sw_vers output:", $output, "(eof)" );
               my $release = $1;
               # Sometimes release reported as "10.4.11" (3 components), sometimes as "10.6".
               # Handle both variants.
               $release =~ m{^(\d+.\d+)(?:\.\d+)?(?=\s|$)}
                   or runtime_error( "Cannot parse OS X* version: $release" );
               my $version = $1;
               my $codename = ( $codenames{ $version } or "unknown" );
               $darwin->{ operating_system_name        } = $name;
               $darwin->{ operating_system_release     } = $release;
               $darwin->{ operating_system_codename    } = $codename;
               $darwin->{ operating_system_description } = sprintf( "%s %s (%s)", $name, $release, $codename );
           }; # if
           return $darwin->{ $name };
       }; # sub
    $values{ operating_system             } = sub { $get_os_info->( "operating_system"             ); };
    $values{ operating_system_name        } = sub { $get_os_info->( "operating_system_name"        ); };
    $values{ operating_system_release     } = sub { $get_os_info->( "operating_system_release"     ); };
    $values{ operating_system_codename    } = sub { $get_os_info->( "operating_system_codename"    ); };
    $values{ operating_system_description } = sub { $get_os_info->( "operating_system_description" ); };
} elsif ( $values{ kernel_name } =~ m{\AWindows[ _]NT\z} ) {
    $values{ operating_system } = "MS Windows";
    # my @os_name = Win32::GetOSName();
    # $values{ operating_system_release } = $os_name[ 0 ];
    # $values{ operating_system_update  } = $os_name[ 1 ];
} elsif ( $values{ kernel_name } =~ m{\ACYGWIN_NT-} ) {
    $values{ operating_system } = "MS Windows";
} elsif ( $values{ kernel_name } =~ m{\AFreeBSD} ) {
    $values{ operating_system } = "FreeBSD";
} elsif ( $values{ kernel_name } =~ m{\ANetBSD} ) {
    $values{ operating_system } = "NetBSD";
} else {
    die "Unsupported kernel_name (\"$values{ kernel_name }\") returned by POSIX::uname(); stopped";
}; # if

# host_name and domain_name
$values{ host_name } =
    sub {
        my $fqdn = value( "fqdn" );
        $fqdn =~ m{\A([^.]*)(?:\.(.*))?\z};
        my $host_name = $1;
        if ( not defined( $host_name ) or $host_name eq "" ) {
            die "Unexpected error: undefined or empty host name; stopped";
        }; # if
        return $host_name;
    };
$values{ domain_name } =
    sub {
        my $fqdn = value( "fqdn" );
        $fqdn =~ m{\A([^.]*)(?:\.(.*))?\z};
        my $domain_name = $2;
        if ( not defined( $domain_name ) or $domain_name eq "" ) {
            die "Unexpected error: undefined or empty domain name; stopped";
        }; # if
        return $domain_name;
    };

# Replace undefined values with "unknown".
foreach my $name ( @all ) {
    if ( not defined( $values{ $name } ) ) {
        $values{ $name } = "unknown";
    }; # if
}; # foreach $name

# Export functions reporting properties.
foreach my $name ( @all ) {
    no strict "refs";
    *$name = sub { return value( $name ); };
}; # foreach $name

# This function returns base names.
sub base_names {
    return @base;
}; # sub base_names

# This function returns all the names.
sub all_names {
    return @all;
}; # sub all_names

# This function returns value by the specified name.
sub value($) {
    my $name = shift( @_ );
    if ( ref( $values{ $name } ) ) {
        my $value = $values{ $name }->();
        $values{ $name } = $value;
    }; # if
    return $values{ $name };
}; # sub value

return 1;

__END__

=pod

=head1 NAME

B<Uname.pm> -- A few subroutines to get system information usually provided by
C</bin/uname> and C<POSIX::uname()>.

=head1 SYNOPSIS

    use Uname;

    # Base property functions.
    $kernel_name       = Uname::kernel_name();
    $fqdn              = Uname::fqdn();
    $kernel_release    = Uname::kernel_release();
    $kernel_version    = Uname::kernel_version();
    $machine           = Uname::machine();
    $processor         = Uname::processor();
    $hardware_platform = Uname::hardware_platform();
    $operating_system  = Uname::operating_system();

    # Auxiliary property functions.
    $host_name         = Uname::host_name();
    $domain_name       = Uname::domain_name();
    $os_name           = Uname::operating_system_name();
    $os_release        = Uname::operating_system_release();
    $os_codename       = Uname::operating_system_codename();
    $os_description    = Uname::operating_system_description();

    # Meta functions.
    @base_names  = Uname::base_names();
    @all_names   = Uname::all_names();
    $kernel_name = Uname::value( "kernel_name" );

=head1 DESCRIPTION

B<Uname.pm> resembles functionality found in C<POSIX::uname()> function or in C<uname> program.
However, both C<POSIX::uname()> and C</bin/uname> have some disadvantages:

=over

=item *

C<uname> may be not available in some environments, for example, in Windows* OS
(C<uname> may be found in some third-party software packages, like MKS Toolkit or Cygwin, but it is
not a part of OS).

=item *

There are many different versions of C<uname>. For example, C<uname> on OS X* does not
recognize options C<-i>, C<-o>, and any long options.

=item *

Different versions of C<uname> may report the same property differently. For example,
C<uname> on Linux* OS reports machine as C<i686>, while C<uname> on OS X* reports the same machine as
C<x86>.

=item *

C<POSIX::uname()> returns list of values. I cannot recall what is the fourth element of the list.

=back

=head2 Base Functions

Base property functions provide the information as C<uname> program.

=over

=item B<kernel_name()>

Returns the kernel name, as reported by C<POSIX::uname()>.

=item B<fqdn()>

Returns the FQDN, fully qualified domain name. On some systems C<POSIX::uname()> reports short node
name (with no domain name), on others C<POSIX::uname()> reports full node name. This
function strive to return FQDN always (by refining C<POSIX::uname()> with
C<Net::Domain::hostfqdn()>).

=item B<kernel_release()>

Returns the kernel release string, as reported by C<POSIX::uname()>. Usually the string consists of
several numbers, separated by dots and dashes, but may also include some non-numeric substrings like
"smp".

=item B<kernel_version()>

Returns the kernel version string, as reported by C<POSIX::uname()>. It is B<not> several
dot-separated numbers but much longer string describing the kernel.
For example, on Linux* OS it includes build date.
If you look for something identifying the kernel, look at L<kernel_release>.

=item B<machine()>

Returns the machine hardware name, as reported by POSIX::uname(). Not reliable. Different OSes may
report the same machine hardware name differently. For example, Linux* OS reports C<i686>, while OS X*
reports C<x86> on the same machine.

=item B<processor()>

Returns the processor type. Not reliable. Usually the same as C<machine>.

=item B<hardware_platform()>

One of: C<i386> or C<x86_64>.

=item B<operating_system()>

One of: C<GNU/Linux>, C<OS X*>, or C<MS Windows>.

=back

=head2 Auxiliary Functions

Auxiliary functions extends base functions with information not reported by C<uname> program.

Auxiliary functions collect information from different sources. For example, on OS X*, they may
call C<sw_vers> program to find out OS release; on Linux* OS they may parse C</etc/redhat-release> file,
etc.

=over

=item B<host_name()>

Returns host name (FQDN with dropped domain part).

=item B<domain_name()>

Returns domain name (FQDN with dropped host part).

=item B<operating_system_name>

Name of operating system or name of Linux* OS distribution, like "Fedora" or
"Red Hat Enterprise Linux* OS Server".

=item B<operating_system_release>

Release (version) of operating system or Linux* OS distribution. Usually it is a series of
dot-separated numbers.

=item B<operating_system_codename>

Codename of operating system release or Linux* OS distribution. For example, Fedora 10 is "Cambridge"
while OS X* 10.4 is "Tiger".

=item B<operating_system_description>

Longer string. Usually it includes all the operating system properting mentioned above -- name,
release, codename in parentheses.

=back

=head2 Meta Functions

=over

=item B<base_names()>

This function returns the list of base property names.

=item B<all_names()>

This function returns the list of all property names.

=item B<value(> I<name> B<)>

This function returns the value of the property specified by I<name>.

=back

=head1 EXAMPLES

    use Uname;

    print( Uname::string(), "\n" );

    foreach my $name ( Uname::all_names() ) {
        print( "$name=\"" . Uname::value( $name ) . "\"\n" );
    }; # foreach $name

=head1 SEE ALSO

L<POSIX::uname>, L<uname>.

=cut

# end of file #