summaryrefslogtreecommitdiffstats
path: root/usr.bin/arch/arch.c
diff options
context:
space:
mode:
authortholo <tholo@openbsd.org>1996-06-29 20:29:34 +0000
committertholo <tholo@openbsd.org>1996-06-29 20:29:34 +0000
commit71070e70a65a33e47dfc17743f5ca2493830e3df (patch)
treead95f56c7bcc4e4fbed1858224e3678026b1e5a3 /usr.bin/arch/arch.c
parentchange: (diff)
downloadwireguard-openbsd-71070e70a65a33e47dfc17743f5ca2493830e3df.tar.xz
wireguard-openbsd-71070e70a65a33e47dfc17743f5ca2493830e3df.zip
Include OS as part of output; add -k option like SunOS
Diffstat (limited to 'usr.bin/arch/arch.c')
-rw-r--r--usr.bin/arch/arch.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/usr.bin/arch/arch.c b/usr.bin/arch/arch.c
index a4a9bee8b31..39b028863ca 100644
--- a/usr.bin/arch/arch.c
+++ b/usr.bin/arch/arch.c
@@ -29,16 +29,57 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: arch.c,v 1.1 1996/06/23 04:22:36 tholo Exp $";
+static char rcsid[] = "$OpenBSD: arch.c,v 1.2 1996/06/29 20:29:34 tholo Exp $";
#endif /* not lint */
+#include <stdio.h>
+#include <locale.h>
+#include <unistd.h>
#include <sys/param.h>
+#include <sys/utsname.h>
+#include <err.h>
+
+static void usage __P((void));
int
main(argc, argv)
int argc;
char *argv[];
{
- puts(MACHINE_ARCH);
+ struct utsname uts;
+ char *arch;
+ int c;
+
+ setlocale(LC_ALL, "");
+
+ arch = MACHINE_ARCH;
+ while ((c = getopt(argc, argv, "k")) != -1)
+ switch (c) {
+ case 'k':
+ arch = MACHINE;
+ break;
+ default:
+ usage();
+ /* NOTREASCHED */
+ }
+ if (optind != argc) {
+ usage();
+ /* NOTREACHED */
+ }
+ if (uname(&uts)) {
+ err(1, NULL);
+ /* NOTREACHED */
+ }
+ fputs(uts.sysname, stdout);
+ fputc('.', stdout);
+ fputs(arch, stdout);
+ fputc('\n', stdout);
exit(0);
}
+
+static void
+usage()
+{
+ fprintf(stderr, "usage: arch [-k]\n");
+ exit(1);
+}