diff options
author | nthnluu <nate1299@me.com> | 2024-01-28 21:20:27 -0500 |
---|---|---|
committer | nthnluu <nate1299@me.com> | 2024-01-28 21:20:27 -0500 |
commit | c63f340d90800895f007de64b7d2d14624263331 (patch) | |
tree | 2c0849fa597dd6da831c8707b6f2603403778d7b /user/bin/uname.c |
Created student weenix repository
Diffstat (limited to 'user/bin/uname.c')
-rw-r--r-- | user/bin/uname.c | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/user/bin/uname.c b/user/bin/uname.c new file mode 100644 index 0000000..942f330 --- /dev/null +++ b/user/bin/uname.c @@ -0,0 +1,93 @@ +/* + * FILE: uname.c + * AUTHOR: kma + * DESCR: uname. whee! + */ + +#include <stdio.h> +#include <sys/utsname.h> + +char *TAS = + "weenix brought to you by:\n" + "1998: jal, dep, kma, mcc, cd, tor\n" + "1999: mbe, tc, kma, mahrens, tor\n" + "2000: ahl, mahrens, mba, pdemoreu, it\n" + "2001: pgriess, pdemoreu, gc3, rmanches, dg\n" + "2002: kit, eschrock\n" + "2005: afenn\n" + "2006: afenn\n" + "2007: dap, joel\n" + "and the number 0xe\n"; + +static int doflag(int c); + +static struct utsname un; + +int main(int argc, char **argv) +{ + int ii; + + uname(&un); + + for (ii = 1; ii < argc; ii++) + { + if (argv[ii][0] == '-') + { + char *str; + str = &argv[ii][1]; + while (*str) + { + if (doflag(*str++) < 0) + { + goto usage; + } + } + } + } + + if (argc == 1) + { + doflag('s'); + } + fprintf(stdout, "\n"); + return 0; + +usage: + return 1; +} + +static int doflag(int c) +{ + switch (c) + { + case 'a': + printf("%s", TAS); + printf("%s ", un.sysname); + printf("%s ", un.nodename); + printf("%s ", un.release); + printf("%s ", un.version); + printf("%s ", un.machine); + break; + case 's': + printf("%s", un.sysname); + break; + case 'n': + printf("%s", un.nodename); + break; + case 'r': + printf("%s", un.release); + break; + case 'T': + printf("%s", TAS); + break; + case 'v': + printf("%s", un.version); + break; + case 'm': + printf("%s", un.machine); + break; + default: + return -1; + } + return 0; +} |