1
0
mirror of https://github.com/adtools/clib2.git synced 2025-12-08 14:59:05 +00:00

- 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
This commit is contained in:
Olaf Barthel
2005-03-03 15:02:26 +00:00
parent dd380f8479
commit 0deb0e3e2d
4 changed files with 70 additions and 9 deletions

View File

@ -1,5 +1,5 @@
# #
# $Id: GNUmakefile.68k,v 1.3 2004-10-25 19:50:33 obarthel Exp $ # $Id: GNUmakefile.68k,v 1.4 2005-03-03 15:02:24 obarthel Exp $
# #
# :ts=8 # :ts=8
# #
@ -47,11 +47,11 @@ LIBS = -lm -lc -lgcc
############################################################################## ##############################################################################
all: test fgets_test iotest sscanf_test printf_test sprintf_test stack_size_test \ all: test fgets_test iotest sscanf_test printf_test sprintf_test stack_size_test \
translate_test strtok_test translate_test strtok_test uname
clean: clean:
$(DELETE) #?.o #?.map test fgets_test iotest sscanf_test printf_test sprintf_test \ $(DELETE) #?.o #?.map test fgets_test iotest sscanf_test printf_test sprintf_test \
stack_size_test translate_test strtok_test stack_size_test translate_test strtok_test uname
############################################################################## ##############################################################################
@ -91,6 +91,10 @@ translate_test : translate_test.o
@echo "Linking $@" @echo "Linking $@"
$(CC) $(CFLAGS) -o $@ translate_test.o -lunix $(LIBS) -Wl,--cref,-M,-Map=$@.map $(CC) $(CFLAGS) -o $@ translate_test.o -lunix $(LIBS) -Wl,--cref,-M,-Map=$@.map
uname: uname.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ uname.o -lunix $(LIBS) -Wl,--cref,-M,-Map=$@.map
############################################################################## ##############################################################################
mkid: mkid:

View File

@ -1,5 +1,5 @@
# #
# $Id: GNUmakefile.os4,v 1.3 2005-03-03 14:46:10 obarthel Exp $ # $Id: GNUmakefile.os4,v 1.4 2005-03-03 15:02:25 obarthel Exp $
# #
# :ts=8 # :ts=8
# #
@ -39,11 +39,11 @@ LIBS = -lm -lc
############################################################################## ##############################################################################
all: test fgets_test iotest sscanf_test printf_test sprintf_test stack_size_test \ all: test fgets_test iotest sscanf_test printf_test sprintf_test stack_size_test \
translate_test strtok_test translate_test strtok_test uname
clean: clean:
$(DELETE) *.o *.map test fgets_test iotest sscanf_test printf_test sprintf_test \ $(DELETE) *.o *.map test fgets_test iotest sscanf_test printf_test sprintf_test \
stack_size_test translate_test strtok_test stack_size_test translate_test strtok_test uname
############################################################################## ##############################################################################
@ -82,3 +82,7 @@ stack_size_test : stack_size_test.o
translate_test : translate_test.o translate_test : translate_test.o
@echo "Linking $@" @echo "Linking $@"
$(CC) $(CFLAGS) -o $@ translate_test.o -lunix $(LIBS) -Wl,--cref,-M,-Map=$@.map $(CC) $(CFLAGS) -o $@ translate_test.o -lunix $(LIBS) -Wl,--cref,-M,-Map=$@.map
uname : uname.o
@echo "Linking $@"
$(CC) $(CFLAGS) -o $@ uname.o -lunix $(LIBS) -Wl,--cref,-M,-Map=$@.map

View File

@ -1,5 +1,5 @@
# #
# $Id: smakefile,v 1.3 2004-10-25 19:50:33 obarthel Exp $ # $Id: smakefile,v 1.4 2005-03-03 15:02:26 obarthel Exp $
# #
# :ts=8 # :ts=8
# #
@ -63,10 +63,10 @@ AFLAGS = \
############################################################################## ##############################################################################
all: setup test fgets_test iotest sscanf_test printf_test sprintf_test stack_size_test translate_test strtok_test cleanup all: setup test fgets_test iotest sscanf_test printf_test sprintf_test stack_size_test translate_test strtok_test uname cleanup
clean: clean:
-delete \#?.o \#?.map test fgets_test iotest sscanf_test printf_test sprintf_test stack_size_test translate_test strtok_test -delete \#?.o \#?.map test fgets_test iotest sscanf_test printf_test sprintf_test stack_size_test translate_test strtok_test uname
############################################################################## ##############################################################################
@ -125,6 +125,11 @@ translate_test: translate_test.o
@slink $(LIB)startup.o translate_test.o to $@ lib $(LIB)c.lib addsym \ @slink $(LIB)startup.o translate_test.o to $@ lib $(LIB)c.lib addsym \
map $@.map,fhx fwidth 32 pwidth 32 swidth 32 map $@.map,fhx fwidth 32 pwidth 32 swidth 32
uname: uname.o
@echo "Linking $@"
@slink $(LIB)startup.o uname.o to $@ lib $(LIB)c.lib addsym \
map $@.map,fhx fwidth 32 pwidth 32 swidth 32
############################################################################## ##############################################################################
mkid: mkid:

48
test_programs/uname.c Normal file
View File

@ -0,0 +1,48 @@
#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: */