version 1.16, 2015/10/09 01:37:09 |
version 1.17, 2015/12/24 15:01:24 |
|
|
*/ |
*/ |
|
|
#include <sys/param.h> /* MACHINE_ARCH */ |
#include <sys/param.h> /* MACHINE_ARCH */ |
|
#include <sys/utsname.h> |
|
|
|
#include <err.h> |
|
#include <locale.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <locale.h> |
|
#include <unistd.h> |
#include <unistd.h> |
#include <sys/utsname.h> |
|
#include <err.h> |
|
|
|
static void usage(void); |
static void usage(void); |
|
|
|
|
case 'n': |
case 'n': |
print_mask |= PRINT_NODENAME; |
print_mask |= PRINT_NODENAME; |
break; |
break; |
|
case 'p': |
|
print_mask |= PRINT_MACHINE_ARCH; |
|
break; |
case 'r': |
case 'r': |
print_mask |= PRINT_RELEASE; |
print_mask |= PRINT_RELEASE; |
break; |
break; |
|
|
case 'v': |
case 'v': |
print_mask |= PRINT_VERSION; |
print_mask |= PRINT_VERSION; |
break; |
break; |
case 'p': |
|
print_mask |= PRINT_MACHINE_ARCH; |
|
break; |
|
default: |
default: |
usage(); |
usage(); |
/* NOTREACHED */ |
/* NOTREACHED */ |
|
|
print_mask = PRINT_SYSNAME; |
print_mask = PRINT_SYSNAME; |
} |
} |
|
|
if (uname(&u)) { |
if (uname(&u)) |
err(1, NULL); |
err(1, NULL); |
/* NOTREACHED */ |
|
} |
|
|
|
if (print_mask & PRINT_SYSNAME) { |
if (print_mask & PRINT_SYSNAME) { |
space++; |
space++; |
fputs(u.sysname, stdout); |
fputs(u.sysname, stdout); |
} |
} |
if (print_mask & PRINT_NODENAME) { |
if (print_mask & PRINT_NODENAME) { |
if (space++) putchar(' '); |
if (space++) |
|
putchar(' '); |
|
|
fputs(u.nodename, stdout); |
fputs(u.nodename, stdout); |
} |
} |
if (print_mask & PRINT_RELEASE) { |
if (print_mask & PRINT_RELEASE) { |
if (space++) putchar(' '); |
if (space++) |
|
putchar(' '); |
|
|
fputs(u.release, stdout); |
fputs(u.release, stdout); |
} |
} |
if (print_mask & PRINT_VERSION) { |
if (print_mask & PRINT_VERSION) { |
if (space++) putchar(' '); |
if (space++) |
|
putchar(' '); |
|
|
fputs(u.version, stdout); |
fputs(u.version, stdout); |
} |
} |
if (print_mask & PRINT_MACHINE) { |
if (print_mask & PRINT_MACHINE) { |
if (space++) putchar(' '); |
if (space++) |
|
putchar(' '); |
|
|
fputs(u.machine, stdout); |
fputs(u.machine, stdout); |
} |
} |
if (print_mask & PRINT_MACHINE_ARCH) { |
if (print_mask & PRINT_MACHINE_ARCH) { |
if (space++) putchar(' '); |
if (space++) |
|
putchar(' '); |
|
|
fputs(MACHINE_ARCH, stdout); |
fputs(MACHINE_ARCH, stdout); |
} |
} |
putchar('\n'); |
putchar('\n'); |
|
|
exit(0); |
return 0; |
/* NOTREACHED */ |
|
} |
} |
|
|
static void |
static void |