version 1.2, 1996/06/26 05:42:07 |
version 1.3, 1998/02/24 00:06:00 |
|
|
static char rcsid[] = "$OpenBSD$"; |
static char rcsid[] = "$OpenBSD$"; |
#endif /* not lint */ |
#endif /* not lint */ |
|
|
|
#include <sys/param.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <locale.h> |
#include <locale.h> |
#include <unistd.h> |
#include <unistd.h> |
#include <sys/utsname.h> |
#include <sys/utsname.h> |
|
#include <sys/sysctl.h> |
#include <err.h> |
#include <err.h> |
|
|
static void usage(); |
static void usage(); |
|
|
#define PRINT_VERSION 0x08 |
#define PRINT_VERSION 0x08 |
#define PRINT_MACHINE 0x10 |
#define PRINT_MACHINE 0x10 |
#define PRINT_ALL 0x1f |
#define PRINT_ALL 0x1f |
|
#define PRINT_PROCESSOR 0x20 |
|
|
int |
int |
main(argc, argv) |
main(argc, argv) |
|
|
|
|
setlocale(LC_ALL, ""); |
setlocale(LC_ALL, ""); |
|
|
while ((c = getopt(argc,argv,"amnrsv")) != -1 ) { |
while ((c = getopt(argc,argv,"amnrsvp")) != -1 ) { |
switch ( c ) { |
switch ( c ) { |
case 'a': |
case 'a': |
print_mask |= PRINT_ALL; |
print_mask |= PRINT_ALL; |
|
|
case 'v': |
case 'v': |
print_mask |= PRINT_VERSION; |
print_mask |= PRINT_VERSION; |
break; |
break; |
|
case 'p': |
|
print_mask |= PRINT_PROCESSOR; |
|
break; |
default: |
default: |
usage(); |
usage(); |
/* NOTREACHED */ |
/* NOTREACHED */ |
|
|
if (space++) putchar(' '); |
if (space++) putchar(' '); |
fputs(u.machine, stdout); |
fputs(u.machine, stdout); |
} |
} |
|
if (print_mask & PRINT_PROCESSOR) { |
|
char buf[1024]; |
|
size_t len; |
|
int mib[2]; |
|
|
|
if (space++) putchar(' '); |
|
mib[0] = CTL_HW; |
|
mib[1] = HW_MODEL; |
|
len = sizeof(buf); |
|
if (sysctl(mib, 2, &buf, &len, NULL, 0) == -1) |
|
err(1, "sysctl"); |
|
printf("%.*s", len, buf); |
|
} |
putchar('\n'); |
putchar('\n'); |
|
|
exit(0); |
exit(0); |