K&R style function removal. Update functions to ANSI style.
[dragonfly.git] / usr.bin / uac / uac.c
1 /*
2  * Copyright (c) 2000 Andrew Gallatin and David E. O'Brien
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  *    in this position and unchanged.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. The name of the author may not be used to endorse or promote products
15  *    derived from this software withough specific prior written permission
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * $FreeBSD: src/usr.bin/uac/uac.c,v 1.1 2000/01/19 09:47:19 obrien Exp $
29  * $DragonFly: src/usr.bin/uac/Attic/uac.c,v 1.3 2003/10/04 20:36:54 hmp Exp $
30  */
31
32 #include <sys/types.h>
33 #include <machine/sysarch.h>
34 #include <machine/proc.h>
35
36 #include <stdio.h>
37 #include <unistd.h>
38 #include <err.h>
39
40 extern int sysarch(int, char *);
41 static void usage ();
42
43 struct parms {
44         u_int64_t uac;
45 };
46
47 int
48 alpha_setuac(u_int64_t uac)
49 {
50         struct parms p;
51
52         p.uac = uac;
53         return (sysarch(ALPHA_SET_UAC, (char *)&p));
54 }
55
56 int
57 alpha_getuac(u_int64_t *uac)
58 {
59         struct parms p;
60         int error;
61
62         error = sysarch(ALPHA_GET_UAC, (char *)&p);
63         *uac = p.uac;
64         return (error);
65 }
66
67 static void
68 print_uac(u_int64_t uac)
69 {
70
71         printf("parent printing is ");
72         if (uac & MDP_UAC_NOPRINT)
73                 printf("off\n");
74         else 
75                 printf("on\n");
76
77         printf("parent fixup is ");
78         if (uac & MDP_UAC_NOFIX)
79                 printf("off\n");
80         else 
81                 printf("on\n");
82
83         printf("parent sigbus is ");
84         if (uac & MDP_UAC_SIGBUS)
85                 printf("on \n");
86         else 
87                 printf("off\n");
88 }
89
90 int
91 main(int argc, char **argv)
92 {
93         int c;
94         u_int64_t uac;
95
96         if (alpha_getuac(&uac) != 0)
97                 err(1, NULL);
98
99         while ((c = getopt(argc, argv, "fpsr")) != -1) {
100                 switch (c) {
101                 case 'f':
102                         uac |= MDP_UAC_NOFIX;
103                         break;
104                 case 'p':
105                         uac |= MDP_UAC_NOPRINT;
106                         break;
107                 case 's':
108                         uac |= MDP_UAC_SIGBUS;
109                         break;
110                 case 'r':
111                         uac = 0;
112                         break;
113                 default:
114                         usage();
115                         /* NOTREACHED */   
116                 }
117         }
118
119         if (argc != 1) {        
120                 if (alpha_setuac(uac) != 0)
121                         err(1, NULL);
122         }
123
124         print_uac(uac);
125         return 0;
126 }
127
128 static void
129 usage(void)
130 {
131
132         fprintf(stderr, "usage: uac [-fprs]\n");
133 }