1
0
mirror of https://github.com/adtools/clib2.git synced 2025-12-08 14:59:05 +00:00
Files
amiga-clib2/test_programs/uname.c
Olaf Barthel 0deb0e3e2d - Added uname command, as contributed by Peter Bengtsson. Thank you very much!
git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14855 87f5fb63-7c3d-0410-a384-fd976d0f7a62
2005-03-03 15:02:26 +00:00

49 lines
1.2 KiB
C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/utsname.h>
int main(int cnt,char *arg[])
{
struct utsname uinfo;
int Ret=EXIT_SUCCESS;
if(cnt>1 && (!strcmp(arg[1],"-h") || !strcmp(arg[1],"--help"))) {
printf(
" -a\tPrint all information.\n"
" -m\tPrint the machine type.\n"
" -n\tPrint the node (host) name.\n"
" -r\tPrint the OS release.\n"
" -s\tPrint the OS name.\n"
" -v\tPrint the OS version.\n\n"
" -h or --help displays this message.\n\n"
);
} else {
if(!uname(&uinfo)) {
if(cnt<2 || !strcmp(arg[1],"-s")) {
printf("%s\n",uinfo.sysname);
} else if(!strcmp(arg[1],"-a")) {
printf("%s %s %s %s %s\n",uinfo.sysname,uinfo.version,uinfo.release,uinfo.nodename,uinfo.machine);
} else if(!strcmp(arg[1],"-m")) {
printf("%s\n",uinfo.machine);
} else if(!strcmp(arg[1],"-n")) {
printf("%s\n",uinfo.nodename);
} else if(!strcmp(arg[1],"-r")) {
printf("%s\n",uinfo.release);
} else if(!strcmp(arg[1],"-v")) {
printf("%s\n",uinfo.version);
} else {
printf("Unknown option \"%s\"!\nTry -h or --help.\n",arg[1]);
Ret=EXIT_FAILURE;
}
} else {
printf("Unknown error!\n");
}
}
return(Ret);
}
/* vi:set ts=3: */