2011-06-02 20:32:05 +01:00
|
|
|
/* See LICENSE file for copyright and license details. */
|
|
|
|
#include <sys/utsname.h>
|
2015-02-14 21:02:41 +01:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2014-11-13 18:29:30 +01:00
|
|
|
|
2011-06-02 20:32:05 +01:00
|
|
|
#include "util.h"
|
|
|
|
|
2013-06-14 20:20:47 +02:00
|
|
|
static void
|
|
|
|
usage(void)
|
|
|
|
{
|
|
|
|
eprintf("usage: %s [-amnrsv]\n", argv0);
|
|
|
|
}
|
|
|
|
|
2011-06-02 20:32:05 +01:00
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
struct utsname u;
|
2015-02-07 22:15:56 +01:00
|
|
|
int mflag = 0, nflag = 0, rflag = 0, sflag = 0, vflag = 0;
|
2011-06-02 20:32:05 +01:00
|
|
|
|
2013-06-14 20:20:47 +02:00
|
|
|
ARGBEGIN {
|
|
|
|
case 'a':
|
2014-11-13 21:24:47 +01:00
|
|
|
mflag = nflag = rflag = sflag = vflag = 1;
|
2013-06-14 20:20:47 +02:00
|
|
|
break;
|
|
|
|
case 'm':
|
2014-11-13 21:24:47 +01:00
|
|
|
mflag = 1;
|
2013-06-14 20:20:47 +02:00
|
|
|
break;
|
|
|
|
case 'n':
|
2014-11-13 21:24:47 +01:00
|
|
|
nflag = 1;
|
2013-06-14 20:20:47 +02:00
|
|
|
break;
|
|
|
|
case 'r':
|
2014-11-13 21:24:47 +01:00
|
|
|
rflag = 1;
|
2013-06-14 20:20:47 +02:00
|
|
|
break;
|
|
|
|
case 's':
|
2014-11-13 21:24:47 +01:00
|
|
|
sflag = 1;
|
2013-06-14 20:20:47 +02:00
|
|
|
break;
|
|
|
|
case 'v':
|
2014-11-13 21:24:47 +01:00
|
|
|
vflag = 1;
|
2013-06-14 20:20:47 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
usage();
|
|
|
|
} ARGEND;
|
2015-02-07 22:15:56 +01:00
|
|
|
|
2014-11-13 21:24:47 +01:00
|
|
|
if (uname(&u) < 0)
|
2011-06-02 21:15:35 +01:00
|
|
|
eprintf("uname:");
|
2011-06-02 20:32:05 +01:00
|
|
|
|
2014-11-13 18:29:30 +01:00
|
|
|
if (sflag || !(nflag || rflag || vflag || mflag))
|
2011-06-10 02:56:13 +01:00
|
|
|
putword(u.sysname);
|
2014-11-13 18:29:30 +01:00
|
|
|
if (nflag)
|
2011-06-10 02:56:13 +01:00
|
|
|
putword(u.nodename);
|
2014-11-13 18:29:30 +01:00
|
|
|
if (rflag)
|
2011-06-10 02:56:13 +01:00
|
|
|
putword(u.release);
|
2014-11-13 18:29:30 +01:00
|
|
|
if (vflag)
|
2011-06-10 02:56:13 +01:00
|
|
|
putword(u.version);
|
2014-11-13 18:29:30 +01:00
|
|
|
if (mflag)
|
2011-06-10 02:56:13 +01:00
|
|
|
putword(u.machine);
|
2011-06-02 20:32:05 +01:00
|
|
|
putchar('\n');
|
2013-06-14 20:20:47 +02:00
|
|
|
|
2014-10-02 23:46:04 +01:00
|
|
|
return 0;
|
2011-06-02 20:32:05 +01:00
|
|
|
}
|