mirror of
git://git.suckless.org/sbase
synced 2024-12-25 16:32:37 +00:00
ec8246bbc6
It actually makes the binaries smaller, the code easier to read (gems like "val == true", "val == false" are gone) and actually predictable in the sense of that we actually know what we're working with (one bitwise operator was quite adventurous and should now be fixed). This is also more consistent with the other suckless projects around which don't use boolean types.
64 lines
924 B
C
64 lines
924 B
C
/* See LICENSE file for copyright and license details. */
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <sys/utsname.h>
|
|
#include <unistd.h>
|
|
|
|
#include "util.h"
|
|
|
|
static void
|
|
usage(void)
|
|
{
|
|
eprintf("usage: %s [-amnrsv]\n", argv0);
|
|
}
|
|
|
|
int
|
|
main(int argc, char *argv[])
|
|
{
|
|
int mflag = 0;
|
|
int nflag = 0;
|
|
int rflag = 0;
|
|
int sflag = 0;
|
|
int vflag = 0;
|
|
struct utsname u;
|
|
|
|
ARGBEGIN {
|
|
case 'a':
|
|
mflag = nflag = rflag = sflag = vflag = 1;
|
|
break;
|
|
case 'm':
|
|
mflag = 1;
|
|
break;
|
|
case 'n':
|
|
nflag = 1;
|
|
break;
|
|
case 'r':
|
|
rflag = 1;
|
|
break;
|
|
case 's':
|
|
sflag = 1;
|
|
break;
|
|
case 'v':
|
|
vflag = 1;
|
|
break;
|
|
default:
|
|
usage();
|
|
} ARGEND;
|
|
if (uname(&u) < 0)
|
|
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 0;
|
|
}
|