xref: /illumos-gate/usr/src/cmd/scadm/sparc/mpxu/common/process_command.c (revision 20a7641f9918de8574b8b3b47dbe35c4bfc78df1)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * process_command.c: parse the command line and call the proper function
29  * to process the command
30  */
31 
32 #include <libintl.h>
33 #include <stdio.h>
34 #include <string.h>
35 #include <sys/types.h>
36 #include <unistd.h>
37 
38 #include "adm.h"
39 
40 
41 void
42 ADM_Process_command(int argc, char *argv[])
43 {
44 	if (strcasecmp(argv[1], "help") == 0)
45 		ADM_Process_help();
46 
47 	else if (strcasecmp(argv[1], "send_event") == 0)
48 		ADM_Process_send_event(argc, argv);
49 
50 	else if (strcasecmp(argv[1], "modem_setup") == 0)
51 		ADM_Process_modem_setup();
52 
53 	else if (strcasecmp(argv[1], "date") == 0)
54 		ADM_Process_date(argc, argv);
55 
56 	else if (strcasecmp(argv[1], "set") == 0)
57 		ADM_Process_set(argc, argv);
58 
59 	else if (strcasecmp(argv[1], "show") == 0)
60 		ADM_Process_show(argc, argv);
61 
62 	else if (strcasecmp(argv[1], "resetrsc") == 0)
63 		ADM_Process_reset(argc, argv);
64 
65 	else if (strcasecmp(argv[1], "download") == 0)
66 		ADM_Process_download(argc, argv);
67 
68 	else if (strcasecmp(argv[1], "useradd") == 0)
69 		ADM_Process_useradd(argc, argv);
70 
71 	else if (strcasecmp(argv[1], "userdel") == 0)
72 		ADM_Process_userdel(argc, argv);
73 
74 	else if (strcasecmp(argv[1], "usershow") == 0)
75 		ADM_Process_usershow(argc, argv);
76 
77 	else if (strcasecmp(argv[1], "userpassword") == 0)
78 		ADM_Process_userpassword(argc, argv);
79 
80 	else if (strcasecmp(argv[1], "userperm") == 0)
81 		ADM_Process_userperm(argc, argv);
82 
83 	else if (strcasecmp(argv[1], "status") == 0)
84 		ADM_Process_status(0);
85 
86 	else if (strcasecmp(argv[1], "version") == 0) {
87 		if (argc == 3) {
88 			if (strcasecmp(argv[2], "-v") == 0) {
89 				ADM_Process_status(1);
90 			} else {
91 				(void) fprintf(stderr, "\n%s\n\n",
92 				    gettext("USAGE: scadm version [-v]"));
93 			}
94 		} else
95 			ADM_Process_status(0);
96 
97 	} else if (strcasecmp(argv[1], "loghistory") == 0 ||
98 	    strcasecmp(argv[1], "lhist") == 0) {
99 
100 		if (argc == 2) {
101 			ADM_Process_event_log(0);
102 		} else if (argc == 3 && strcmp(argv[2], "-a") == 0) {
103 			ADM_Process_event_log(1);
104 		} else {
105 			(void) fprintf(stderr, "\n%s\n\n",
106 			    gettext("USAGE: scadm loghistory [-a]"));
107 			exit(-1);
108 		}
109 
110 	} else if (strcasecmp(argv[1], "shownetwork") == 0) {
111 
112 		if (argc != 2) {
113 			(void) fprintf(stderr, "\n%s\n\n",
114 			    gettext("USAGE: scadm shownetwork"));
115 			exit(-1);
116 		}
117 		ADM_Process_show_network();
118 
119 	} else if (strcasecmp(argv[1], "consolehistory") == 0) {
120 
121 		if (argc == 2) {
122 			ADM_Process_console_log(0);
123 		} else if (argc == 3 && strcmp(argv[2], "-a") == 0) {
124 			ADM_Process_console_log(1);
125 		} else {
126 			(void) fprintf(stderr, "\n%s\n\n",
127 			    gettext("USAGE: scadm consolehistory [-a]"));
128 			exit(-1);
129 		}
130 
131 	} else if (strcasecmp(argv[1], "fruhistory") == 0) {
132 
133 		if (argc == 2) {
134 			ADM_Process_fru_log(0);
135 		} else if (argc == 3 && strcmp(argv[2], "-a") == 0) {
136 			ADM_Process_fru_log(1);
137 		} else {
138 			(void) fprintf(stderr, "\n%s\n\n",
139 			    gettext("USAGE: scadm fruhistory [-a]"));
140 			exit(-1);
141 		}
142 
143 	} else {
144 		(void) fprintf(stderr, "\n%s - \"%s\"\n",
145 		    gettext("scadm: command unknown"), argv[1]);
146 		ADM_Usage();
147 		exit(-1);
148 	}
149 }
150