mirror of
git://git.suckless.org/sbase
synced 2024-12-29 02:22:27 +00:00
953ebf3573
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
64 lines
994 B
C
64 lines
994 B
C
/* See LICENSE file for copyright and license details. */
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <sys/utsname.h>
|
|
#include "util.h"
|
|
|
|
static void
|
|
usage(void)
|
|
{
|
|
eprintf("usage: %s [-amnrsv]\n", argv0);
|
|
}
|
|
|
|
int
|
|
main(int argc, char *argv[])
|
|
{
|
|
bool mflag = false;
|
|
bool nflag = false;
|
|
bool rflag = false;
|
|
bool sflag = false;
|
|
bool vflag = false;
|
|
struct utsname u;
|
|
|
|
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;
|
|
if(uname(&u) == -1)
|
|
eprintf("uname:");
|
|
|
|
if(sflag || !(nflag || rflag || vflag || mflag))
|
|
putword(u.sysname);
|
|
if(nflag)
|
|
putword(u.nodename);
|
|
if(rflag)
|
|
putword(u.release);
|
|
if(vflag)
|
|
putword(u.version);
|
|
if(mflag)
|
|
putword(u.machine);
|
|
putchar('\n');
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|