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 #pragma ident "%Z%%M% %I% %E% SMI"
28
29 /*
30 * process_command.c: parse the command line and call the proper function
31 * to process the command
32 */
33
34 #include <libintl.h>
35 #include <stdio.h>
36 #include <string.h>
37 #include <sys/types.h>
38 #include <unistd.h>
39
40 #include "adm.h"
41
42
43 void
ADM_Process_command(int argc,char * argv[])44 ADM_Process_command(int argc, char *argv[])
45 {
46 if (strcasecmp(argv[1], "help") == 0)
47 ADM_Process_help();
48
49 else if (strcasecmp(argv[1], "send_event") == 0)
50 ADM_Process_send_event(argc, argv);
51
52 else if (strcasecmp(argv[1], "modem_setup") == 0)
53 ADM_Process_modem_setup();
54
55 else if (strcasecmp(argv[1], "date") == 0)
56 ADM_Process_date(argc, argv);
57
58 else if (strcasecmp(argv[1], "set") == 0)
59 ADM_Process_set(argc, argv);
60
61 else if (strcasecmp(argv[1], "show") == 0)
62 ADM_Process_show(argc, argv);
63
64 else if (strcasecmp(argv[1], "resetrsc") == 0)
65 ADM_Process_reset(argc, argv);
66
67 else if (strcasecmp(argv[1], "download") == 0)
68 ADM_Process_download(argc, argv);
69
70 else if (strcasecmp(argv[1], "useradd") == 0)
71 ADM_Process_useradd(argc, argv);
72
73 else if (strcasecmp(argv[1], "userdel") == 0)
74 ADM_Process_userdel(argc, argv);
75
76 else if (strcasecmp(argv[1], "usershow") == 0)
77 ADM_Process_usershow(argc, argv);
78
79 else if (strcasecmp(argv[1], "userpassword") == 0)
80 ADM_Process_userpassword(argc, argv);
81
82 else if (strcasecmp(argv[1], "userperm") == 0)
83 ADM_Process_userperm(argc, argv);
84
85 else if (strcasecmp(argv[1], "status") == 0)
86 ADM_Process_status(0);
87
88 else if (strcasecmp(argv[1], "version") == 0) {
89 if (argc == 3) {
90 if (strcasecmp(argv[2], "-v") == 0) {
91 ADM_Process_status(1);
92 } else {
93 (void) fprintf(stderr, "\n%s\n\n",
94 gettext("USAGE: scadm version [-v]"));
95 }
96 } else
97 ADM_Process_status(0);
98
99 } else if (strcasecmp(argv[1], "loghistory") == 0 ||
100 strcasecmp(argv[1], "lhist") == 0) {
101
102 if (argc == 2) {
103 ADM_Process_event_log(0);
104 } else if (argc == 3 && strcmp(argv[2], "-a") == 0) {
105 ADM_Process_event_log(1);
106 } else {
107 (void) fprintf(stderr, "\n%s\n\n",
108 gettext("USAGE: scadm loghistory [-a]"));
109 exit(-1);
110 }
111
112 } else if (strcasecmp(argv[1], "shownetwork") == 0) {
113
114 if (argc != 2) {
115 (void) fprintf(stderr, "\n%s\n\n",
116 gettext("USAGE: scadm shownetwork"));
117 exit(-1);
118 }
119 ADM_Process_show_network();
120
121 } else if (strcasecmp(argv[1], "consolehistory") == 0) {
122
123 if (argc == 2) {
124 ADM_Process_console_log(0);
125 } else if (argc == 3 && strcmp(argv[2], "-a") == 0) {
126 ADM_Process_console_log(1);
127 } else {
128 (void) fprintf(stderr, "\n%s\n\n",
129 gettext("USAGE: scadm consolehistory [-a]"));
130 exit(-1);
131 }
132
133 } else if (strcasecmp(argv[1], "fruhistory") == 0) {
134
135 if (argc == 2) {
136 ADM_Process_fru_log(0);
137 } else if (argc == 3 && strcmp(argv[2], "-a") == 0) {
138 ADM_Process_fru_log(1);
139 } else {
140 (void) fprintf(stderr, "\n%s\n\n",
141 gettext("USAGE: scadm fruhistory [-a]"));
142 exit(-1);
143 }
144
145 } else {
146 (void) fprintf(stderr, "\n%s - \"%s\"\n",
147 gettext("scadm: command unknown"), argv[1]);
148 ADM_Usage();
149 exit(-1);
150 }
151 }
152