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