xref: /titanic_41/usr/src/cmd/prtdiag/main.c (revision 3c112a2b34403220c06c3e2fcac403358cfba168)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 
23 /*
24  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 /*
29  * Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
30  * All rights reserved.
31  */
32 
33 #pragma ident	"%Z%%M%	%I%	%E% SMI"
34 
35 #include <stdio.h>
36 #include <locale.h>
37 #include <stdlib.h>
38 #include <libintl.h>
39 #include <string.h>
40 #include <unistd.h>
41 #include <zone.h>
42 
43 extern int do_prominfo(int, char *, int, int);
44 
45 static char *
46 setprogname(char *name)
47 {
48 	char	*p;
49 
50 	if (p = strrchr(name, '/'))
51 		return (p + 1);
52 	else
53 		return (name);
54 }
55 
56 int
57 main(int argc, char *argv[])
58 {
59 	int	c;
60 	int	syserrlog = 0;
61 	char	*progname = setprogname(argv[0]);
62 	int	print_flag = 1;
63 	int	logging = 0;
64 
65 	(void) setlocale(LC_ALL, "");
66 	(void) textdomain(TEXT_DOMAIN);
67 
68 	if (getzoneid() != GLOBAL_ZONEID) {
69 		(void) fprintf(stderr,
70 		    gettext("%s can only be run in the global zone\n"),
71 		    progname);
72 		return (1);
73 	}
74 
75 	while ((c = getopt(argc, argv, "vl")) != -1)  {
76 		switch (c)  {
77 		case 'v':
78 			++syserrlog;
79 			break;
80 
81 		case 'l':
82 			logging = 1;
83 			break;
84 
85 		default:
86 			(void) fprintf(stderr, "Usage: %s [-lv]\n", progname);
87 			return (1);
88 		}
89 	}
90 
91 	return (do_prominfo(syserrlog, progname, logging, print_flag));
92 }
93