k9core

Unnamed repository
Log | Files | Refs | LICENSE

commit 41fac48fb081a1252c19db70535c7e8094c9058b
parent 7f4a6e2733a3fb90269519a4d122a87aa3737570
Author: qorg11 <qorg@vxempire.xyz>
Date:   Fri, 21 Aug 2020 09:31:06 +0200

Added uname, works but probably not as it should, initial commit for
this and i'll fix it if needed later (probably i forgot some flags,
programming is hard)

Diffstat:
Asrc/uname.c | 49+++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+), 0 deletions(-)

diff --git a/src/uname.c b/src/uname.c @@ -0,0 +1,49 @@ +#include <stdio.h> +#include <sys/utsname.h> +#include <getopt.h> + +int +main(int argc, char *argv[]) +{ + int c; + int all = 0; + int machine = 0; + int node_name = 0; + int kernel_release = 0; + int kernel_name = 0; + struct utsname kernel_info; + while((c = getopt(argc, argv, "amnrsv")) != -1) + { + switch(c) + { + case 'a': all = 1; break; + case 'm': machine = 1; break; + case 'n': node_name = 1; break; + case 'r': kernel_release = 1; break; + case 's': kernel_name = 1; break; + } + } + uname(&kernel_info); + if(all) + { + printf("%s %s %s %s %s\n", + kernel_info.machine, + kernel_info.nodename, + kernel_info.release, + kernel_info.sysname, + kernel_info.version); + } + else{ + if(machine) + printf("%s ",kernel_info.machine); + if(node_name) + printf("%s ",kernel_info.nodename); + if(kernel_release) + printf("%s ",kernel_info.release); + if(kernel_name) + printf("%s ",kernel_info.sysname); + printf("\n"); + } + + return 0; +}