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 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* 28 * Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T 29 * All rights reserved. 30 */ 31 32 33 #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.7 */ 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 #include <sys/openpromio.h> 43 44 /* 45 * function prototypes 46 */ 47 extern int do_prominfo(int syserrlog, char *progname, 48 int logging, int print_flag); 49 static char *setprogname(char *name); 50 51 void 52 main(int argc, char *argv[]) 53 { 54 int c; 55 int syserrlog = 0; 56 char *usage = "%s [ -v ] [ -l ]\n"; 57 char *progname; 58 int print_flag = 1; 59 int logging = 0; 60 61 /* set up for internationalization */ 62 (void) setlocale(LC_ALL, ""); 63 (void) textdomain(TEXT_DOMAIN); 64 65 progname = setprogname(argv[0]); 66 if (getzoneid() != GLOBAL_ZONEID) { 67 (void) fprintf(stderr, 68 gettext("%s can only be run in the global zone\n"), 69 progname); 70 exit(1); 71 /*NOTREACHED*/ 72 } 73 while ((c = getopt(argc, argv, "vl")) != -1) { 74 switch (c) { 75 case 'v': 76 ++syserrlog; 77 break; 78 79 case 'l': 80 logging = 1; 81 break; 82 83 default: 84 (void) fprintf(stderr, usage, progname); 85 exit(1); 86 /*NOTREACHED*/ 87 } 88 } 89 90 /* 91 * for sun4u do_prominfo() is in libprtdiag 92 */ 93 exit(do_prominfo(syserrlog, progname, logging, print_flag)); 94 } 95 96 static char * 97 setprogname(char *name) 98 { 99 char *p; 100 101 if (p = strrchr(name, '/')) 102 return (p + 1); 103 else 104 return (name); 105 } 106