Annotation of src/usr.bin/arch/arch.c, Revision 1.2
1.1 tholo 1: /*
2: * Copyright (c) 1994 SigmaSoft, Th. Lockert <tholo@sigmasoft.com>
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms, with or without
6: * modification, are permitted provided that the following conditions
7: * are met:
8: * 1. Redistributions of source code must retain the above copyright
9: * notice, this list of conditions and the following disclaimer.
10: * 2. Redistributions in binary form must reproduce the above copyright
11: * notice, this list of conditions and the following disclaimer in the
12: * documentation and/or other materials provided with the distribution.
13: * 3. All advertising materials mentioning features or use of this software
14: * must display the following acknowledgement:
15: * This product includes software developed by SigmaSoft, Th. Lockert.
16: * 4. The name of the author may not be used to endorse or promote products
17: * derived from this software without specific prior written permission.
18: *
19: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20: * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21: * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22: * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25: * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27: * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29: */
30:
31: #ifndef lint
1.2 ! tholo 32: static char rcsid[] = "$OpenBSD: arch.c,v 1.1 1996/06/23 04:22:36 tholo Exp $";
1.1 tholo 33: #endif /* not lint */
34:
1.2 ! tholo 35: #include <stdio.h>
! 36: #include <locale.h>
! 37: #include <unistd.h>
1.1 tholo 38: #include <sys/param.h>
1.2 ! tholo 39: #include <sys/utsname.h>
! 40: #include <err.h>
! 41:
! 42: static void usage __P((void));
1.1 tholo 43:
44: int
45: main(argc, argv)
46: int argc;
47: char *argv[];
48: {
1.2 ! tholo 49: struct utsname uts;
! 50: char *arch;
! 51: int c;
! 52:
! 53: setlocale(LC_ALL, "");
! 54:
! 55: arch = MACHINE_ARCH;
! 56: while ((c = getopt(argc, argv, "k")) != -1)
! 57: switch (c) {
! 58: case 'k':
! 59: arch = MACHINE;
! 60: break;
! 61: default:
! 62: usage();
! 63: /* NOTREASCHED */
! 64: }
! 65: if (optind != argc) {
! 66: usage();
! 67: /* NOTREACHED */
! 68: }
! 69: if (uname(&uts)) {
! 70: err(1, NULL);
! 71: /* NOTREACHED */
! 72: }
! 73: fputs(uts.sysname, stdout);
! 74: fputc('.', stdout);
! 75: fputs(arch, stdout);
! 76: fputc('\n', stdout);
1.1 tholo 77: exit(0);
1.2 ! tholo 78: }
! 79:
! 80: static void
! 81: usage()
! 82: {
! 83: fprintf(stderr, "usage: arch [-k]\n");
! 84: exit(1);
1.1 tholo 85: }