diff --git a/bin/uname/Makefile b/bin/uname/Makefile new file mode 100644 index 0000000..6176d1f --- /dev/null +++ b/bin/uname/Makefile @@ -0,0 +1,22 @@ +# @(#)Makefile 8.1 (Berkeley) 6/6/93 +# +# Modified for GNO (Apple IIgs) and dmake(1) by Steve Reeves, January 1998 +# +# $Id: Makefile,v 1.1 1998/02/17 02:50:27 gdr-ftp Exp $ + +PROG= uname + +BINDIR= /usr/bin + +DEFINES+= -DNOID + +# Default stack size and optimization (can be overridden by cmd line) +# These values have been tested and certified as working +.IF $(STACK) == $(NULL) +STACK= 1024 +.END +.IF $(OPTIMIZE) == $(NULL) +OPTIMIZE= 127 +.END + +.INCLUDE: /src/gno/prog.mk diff --git a/bin/uname/tests/dotests b/bin/uname/tests/dotests new file mode 100644 index 0000000..aa4083d --- /dev/null +++ b/bin/uname/tests/dotests @@ -0,0 +1,129 @@ +# Tests for tr command; invoked by command file "fulltests" +# Adapted from a test script written by Dave Tribby +# +# $Id: dotests,v 1.1 1998/02/17 02:50:35 gdr-ftp Exp $ + +# Location of the command to be tested +set testcmd="../uname" + +# Record starting time +echo -n "Testing command $testcmd beginning at" +date + +echo "Setting hostname for tests" +/bin/hostname testhost + +set cmp="uname.out" +set dest="/tmp/$cmp" +echo "Getting the OS name (the default when no arguments)" +$testcmd > $dest +echo " Completion status = $status" +echo "Checking results against control file $cmp (no differences expected)" +cmp $cmp $dest +echo " Completion status = $status" +echo "" + +set cmp="uname.aopt.out" +set dest="/tmp/$cmp" +echo "Getting all information about the system" +$testcmd -a > $dest +echo " Completion status = $status" +echo "Checking results against control file $cmp (no differences expected)" +cmp $cmp $dest +echo " Completion status = $status" +echo "" + +set cmp="uname.mopt.out" +set dest="/tmp/$cmp" +echo "Getting the machine type" +$testcmd -m > $dest +echo " Completion status = $status" +echo "Checking results against control file $cmp (no differences expected)" +cmp $cmp $dest +echo " Completion status = $status" +echo "" + +set cmp="uname.nopt.out" +set dest="/tmp/$cmp" +echo "Getting the node name" +$testcmd -n > $dest +echo " Completion status = $status" +echo "Checking results against control file $cmp (no differences expected)" +cmp $cmp $dest +echo " Completion status = $status" +echo "" + +set cmp="uname.ropt.out" +set dest="/tmp/$cmp" +echo "Getting the release level" +$testcmd -r > $dest +echo " Completion status = $status" +echo "Checking results against control file $cmp (no differences expected)" +cmp $cmp $dest +echo " Completion status = $status" +echo "" + +set cmp="uname.sopt.out" +set dest="/tmp/$cmp" +echo "Getting the OS name" +$testcmd -s > $dest +echo " Completion status = $status" +echo "Checking results against control file $cmp (no differences expected)" +cmp $cmp $dest +echo " Completion status = $status" +echo "" + +set cmp="uname.vopt.out" +set dest="/tmp/$cmp" +echo "Getting the version level" +$testcmd -v > $dest +echo " Completion status = $status" +echo "Checking results against control file $cmp (no differences expected)" +cmp $cmp $dest +echo " Completion status = $status" +echo "" + +set cmp="uname.msopt.out" +set dest="/tmp/$cmp" +echo "Getting the machine type and OS name" +$testcmd -ms > $dest +echo " Completion status = $status" +echo "Checking results against control file $cmp (no differences expected)" +cmp $cmp $dest +echo " Completion status = $status" +echo "" + +set cmp="uname.rvopt.out" +set dest="/tmp/$cmp" +echo "Getting the release and version levels" +$testcmd -rv > $dest +echo " Completion status = $status" +echo "Checking results against control file $cmp (no differences expected)" +cmp $cmp $dest +echo " Completion status = $status" +echo "" + +echo "***** Version *****" + +set cmp="uname.ver.out" +set dest="/tmp/$cmp" + +echo "Printing version information" +$testcmd -V > $dest +echo " Completion status = $status" +echo "Checking results against control file $cmp (no differences expected)" +cmp $cmp $dest +echo " Completion status = $status" +echo "" + +echo "***** Error Messages *****" + +set cmp="uname.err.out" +set dest="/tmp/$cmp" + +echo "Expected error: illegal option" +$testcmd -x >& $dest +echo " Error completion status = $status (expected: 1)" +echo "Checking results against control file $cmp (no differences expected)" +cmp $cmp $dest +echo " Completion status = $status" diff --git a/bin/uname/tests/fulltests b/bin/uname/tests/fulltests new file mode 100644 index 0000000..3f77081 --- /dev/null +++ b/bin/uname/tests/fulltests @@ -0,0 +1,29 @@ +# gsh script to run tests and collect results +# Written by Dave Tribby * August 1997 +# $Id: fulltests,v 1.1 1998/02/17 02:50:36 gdr-ftp Exp $ + +# Name of gsh script containing test cases +set command="dotests" +# Sometimes the file type is modified by editing; make it executable +chtyp -l exec $command + +# Filenames for raw and modified results +set raw_file="/tmp/rawlist" +set result_file="test.list" + +# Location of tr command that knows how to handle classes +set trcmd="/src/gno/usr.bin/tr/tr" + +# --- Begin the tests --- + +echo -n "Executing test script \"$command\" from directory " +pwd + +# Create a new gsh invocation and record all I/O +echo "$command ; exit" | script $raw_file + +# Cleanup control chars using either of the following... +echo "Done with tests. Removing control characters from results file" +$trcmd -c -ds '[:print:]\r' '\r' < $raw_file > $result_file + +echo "Tests results have been saved as \"$result_file\"" diff --git a/bin/uname/tests/uname.aopt.out b/bin/uname/tests/uname.aopt.out new file mode 100644 index 0000000..c13ca5a --- /dev/null +++ b/bin/uname/tests/uname.aopt.out @@ -0,0 +1 @@ +GNO/ME testhost 6 2.0 IIgs/ROM1 diff --git a/bin/uname/tests/uname.err.out b/bin/uname/tests/uname.err.out new file mode 100644 index 0000000..62e74f2 --- /dev/null +++ b/bin/uname/tests/uname.err.out @@ -0,0 +1,2 @@ +uname: illegal option -- x +usage: uname [-amnrsvV] diff --git a/bin/uname/tests/uname.mopt.out b/bin/uname/tests/uname.mopt.out new file mode 100644 index 0000000..aa659f1 --- /dev/null +++ b/bin/uname/tests/uname.mopt.out @@ -0,0 +1 @@ +IIgs/ROM1 diff --git a/bin/uname/tests/uname.msopt.out b/bin/uname/tests/uname.msopt.out new file mode 100644 index 0000000..842a2ae --- /dev/null +++ b/bin/uname/tests/uname.msopt.out @@ -0,0 +1 @@ +GNO/ME IIgs/ROM1 diff --git a/bin/uname/tests/uname.nopt.out b/bin/uname/tests/uname.nopt.out new file mode 100644 index 0000000..31ffb21 --- /dev/null +++ b/bin/uname/tests/uname.nopt.out @@ -0,0 +1 @@ +testhost diff --git a/bin/uname/tests/uname.out b/bin/uname/tests/uname.out new file mode 100644 index 0000000..bdd32bd --- /dev/null +++ b/bin/uname/tests/uname.out @@ -0,0 +1 @@ +GNO/ME diff --git a/bin/uname/tests/uname.ropt.out b/bin/uname/tests/uname.ropt.out new file mode 100644 index 0000000..1e8b314 --- /dev/null +++ b/bin/uname/tests/uname.ropt.out @@ -0,0 +1 @@ +6 diff --git a/bin/uname/tests/uname.rvopt.out b/bin/uname/tests/uname.rvopt.out new file mode 100644 index 0000000..42b5b02 --- /dev/null +++ b/bin/uname/tests/uname.rvopt.out @@ -0,0 +1 @@ +6 2.0 diff --git a/bin/uname/tests/uname.sopt.out b/bin/uname/tests/uname.sopt.out new file mode 100644 index 0000000..bdd32bd --- /dev/null +++ b/bin/uname/tests/uname.sopt.out @@ -0,0 +1 @@ +GNO/ME diff --git a/bin/uname/tests/uname.ver.out b/bin/uname/tests/uname.ver.out new file mode 100644 index 0000000..d0fe7c8 --- /dev/null +++ b/bin/uname/tests/uname.ver.out @@ -0,0 +1 @@ +uname v3.0 diff --git a/bin/uname/tests/uname.vopt.out b/bin/uname/tests/uname.vopt.out new file mode 100644 index 0000000..cd5ac03 --- /dev/null +++ b/bin/uname/tests/uname.vopt.out @@ -0,0 +1 @@ +2.0 diff --git a/bin/uname/uname.1 b/bin/uname/uname.1 new file mode 100644 index 0000000..2b0f9a5 --- /dev/null +++ b/bin/uname/uname.1 @@ -0,0 +1,110 @@ +.\" Copyright (c) 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)uname.1 8.3 (Berkeley) 4/8/94 +.\" +.\" Modified for GNO (Apple IIgs) by Steve Reeves and Devin Reade's bsd2man +.\" +.\" $Id: uname.1,v 1.1 1998/02/17 02:50:28 gdr-ftp Exp $ +.\" +.TH UNAME 1 "January 23, 1998" GNO "Commands and Applications" +.SH NAME +.B uname +\- display information about the system +.SH SYNOPSIS +.B uname +[ +.B \-amnrsv +] +.br +.B uname +.B \-V +.SH DESCRIPTION +By default, the +.B uname +command writes the name of the operating system implementation to +standard output. +When options are specified, strings representing one or more system +characteristics are written to standard output. +.SH OPTIONS +.IP \fB\-a\fP +Behave as though the options +.BR \-m , +.BR \-n , +.BR \-r , +.BR \-s , +and +.B \-v +were specified. +.IP \fB\-m\fP +Write the type of the current hardware platform to standard output. +.IP \fB\-n\fP +Write the name of the system to standard output. +.IP \fB\-r\fP +Write the current release level of the operating system +to standard output. +.IP \fB\-s\fP +Write the name of the operating system implementation to standard output. +.IP \fB\-v\fP +Write the version level of this release of the operating system +to standard output. +.IP \fB\-V\fP +Write version information for the +.B uname +command and exit. +.LP +If the +.B \-a +flag is specified, or multiple flags are specified, all +output is written on a single line, separated by spaces. +.SH "RETURN VALUES" +The +.B uname +utility exits 0 on success, and >0 if an error occurs. +.SH VERSION +This manual page documents +.B uname +version 3.0. +.SH HISTORY +Version 1.0 (February 1994) of +.B uname +for GNO was written by Phil Vandry . +Version 2.0 (September 1994) +was written by Ian Schmidt . +.SH STANDARDS +The +.B uname +command is expected to conform to the +.SM IEEE +Std1003.2 (``POSIX.2'') +specification. +.SH SEE ALSO +.BR uname (3) diff --git a/bin/uname/uname.c b/bin/uname/uname.c new file mode 100644 index 0000000..1ff74b9 --- /dev/null +++ b/bin/uname/uname.c @@ -0,0 +1,246 @@ +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Modified for GNO (Apple IIGS) by Steve Reeves, January 1998 + * + * Added conditional compilation based on these macros: + * + * __ORCAC__ for constructs unacceptable to the compiler, + * __GNO__ for changes not related to the compiler, + * __STDC__ or __P() from for ISO C prototyping, + * __STACK_CHECK__ for reporting stack space usage, + * NOID for excluding copyright and version control strings + * + * $Id: uname.c,v 1.1 1998/02/17 02:50:29 gdr-ftp Exp $ + * + */ + +#ifndef NOID +#ifndef lint +static char copyright[] = +"@(#) Copyright (c) 1993\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +static char sccsid[] = "@(#)uname.c 8.2 (Berkeley) 5/4/95"; +#endif /* not lint */ +#endif + +#ifndef __GNO__ +#include +#include +#else +#include +#endif + +#include +#include +#include +#include + +void usage __P((void)); + +#if defined(__GNO__) && defined(__STACK_CHECK__) +/* Interface to check on how much stack space a C program uses. */ +#ifndef _GNO_GNO_H_ +#include +#endif +static void report_stack(void) +{ + fprintf(stderr,"\n ==> %d stack bytes used <== \n", _endStackCheck()); +} +#endif + +int +#ifndef __STDC__ +main(argc, argv) + int argc; + char *argv[]; +#else +main(int argc, char *argv[]) +#endif +{ +#define MFLAG 0x01 +#define NFLAG 0x02 +#define RFLAG 0x04 +#define SFLAG 0x08 +#define VFLAG 0x10 + u_int flags; +#ifndef __GNO__ + int ch, mib[2]; + size_t len, tlen; + char *p, *prefix, buf[1024]; +#else + int ch; + char *prefix; + static struct utsname name; +#endif + +#if defined(__GNO__) && defined(__STACK_CHECK__) + _beginStackCheck(); + atexit(report_stack); +#endif + + flags = 0; + while ((ch = getopt(argc, argv, "amnrsvV")) != -1) + switch(ch) { + case 'a': + flags |= (MFLAG | NFLAG | RFLAG | SFLAG | VFLAG); + break; + case 'm': + flags |= MFLAG; + break; + case 'n': + flags |= NFLAG; + break; + case 'r': + flags |= RFLAG; + break; + case 's': + flags |= SFLAG; + break; + case 'v': + flags |= VFLAG; + break; + case 'V': + printf("uname v3.0\n"); + exit(0); + case '?': + default: + usage(); + } + + argc -= optind; +#ifndef __ORCAC__ + argv += optind; +#else + argv = argv + optind; +#endif + + if (argc) + usage(); + + if (!flags) + flags |= SFLAG; + + prefix = ""; + +#ifndef __GNO__ + if (flags & SFLAG) { + mib[0] = CTL_KERN; + mib[1] = KERN_OSTYPE; + len = sizeof(buf); + if (sysctl(mib, 2, &buf, &len, NULL, 0) == -1) + err(1, "sysctl"); + (void)printf("%s%.*s", prefix, len, buf); + prefix = " "; + } + if (flags & NFLAG) { + mib[0] = CTL_KERN; + mib[1] = KERN_HOSTNAME; + len = sizeof(buf); + if (sysctl(mib, 2, &buf, &len, NULL, 0) == -1) + err(1, "sysctl"); + (void)printf("%s%.*s", prefix, len, buf); + prefix = " "; + } + if (flags & RFLAG) { + mib[0] = CTL_KERN; + mib[1] = KERN_OSRELEASE; + len = sizeof(buf); + if (sysctl(mib, 2, &buf, &len, NULL, 0) == -1) + err(1, "sysctl"); + (void)printf("%s%.*s", prefix, len, buf); + prefix = " "; + } + if (flags & VFLAG) { + mib[0] = CTL_KERN; + mib[1] = KERN_VERSION; + len = sizeof(buf); + if (sysctl(mib, 2, &buf, &len, NULL, 0) == -1) + err(1, "sysctl"); + for (p = buf, tlen = len; tlen--; ++p) + if (*p == '\n' || *p == '\t') + *p = ' '; + (void)printf("%s%.*s", prefix, len, buf); + prefix = " "; + } + if (flags & MFLAG) { + mib[0] = CTL_HW; + mib[1] = HW_MACHINE; + len = sizeof(buf); + if (sysctl(mib, 2, &buf, &len, NULL, 0) == -1) + err(1, "sysctl"); + (void)printf("%s%.*s", prefix, len, buf); + prefix = " "; + } + +#else /* __GNO__ */ + + if (uname(&name) == -1) + err(1, "uname"); + + if (flags & SFLAG) { + printf("%s%s", prefix, name.sysname); + prefix = " "; + } + if (flags & NFLAG) { + printf("%s%s", prefix, name.nodename); + prefix = " "; + } + if (flags & RFLAG) { + printf("%s%s", prefix, name.release); + prefix = " "; + } + if (flags & VFLAG) { + printf("%s%s", prefix, name.version); + prefix = " "; + } + if (flags & MFLAG) { + printf("%s%s", prefix, name.machine); + prefix = " "; + } +#endif + + (void)printf("\n"); + exit (0); +} + +void +usage __P((void)) +{ + (void)fprintf(stderr, "usage: uname [-amnrsvV]\n"); + exit(1); +} diff --git a/bin/uname/uname.desc b/bin/uname/uname.desc new file mode 100644 index 0000000..83331ed --- /dev/null +++ b/bin/uname/uname.desc @@ -0,0 +1,9 @@ +Name: uname +Version: 3.0 (January 23, 1998) +Shell: GNO +Author: Steve Reeves (from FreeBSD code) +Contact: stever@gate.net +Where: /usr/bin +FTP: ground.isca.uiowa.edu apple2.caltech.edu trenco.myrias.com + + Display information about the system. diff --git a/bin/uname/uname.rez b/bin/uname/uname.rez new file mode 100644 index 0000000..7d881c8 --- /dev/null +++ b/bin/uname/uname.rez @@ -0,0 +1,32 @@ +/* + * Resources for uname + * + * $Id: uname.rez,v 1.1 1998/02/17 02:50:32 gdr-ftp Exp $ + */ + +#define PROG "uname" +#define DESC "Display information about the system." + +#include "Types.rez" + +/* + * Version + */ +resource rVersion (1, purgeable3) { + { 3, 0, 0, /* Version 3.0.0 */ + release, /* development|alpha|beta|final|release */ + 0 }, /* non-final release number */ + verUS, /* Country */ + PROG, /* Program name */ + DESC " Released with GNO/ME." +}; + + +/* + * Comment + */ +resource rComment (1, purgeable3) { + PROG " v3.0 (January 23, 1998)\n" + "GNO utility: " DESC "\n" + "Ported from FreeBSD code by Steve Reeves." +};