main.c (7c478bd95313f5f23a4c958a745db2134aa03244) main.c (84ab085a13f931bc78e7415e7ce921dbaa14fcb3)
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 *

--- 5 unchanged lines hidden (view full) ---

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 */
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 *

--- 5 unchanged lines hidden (view full) ---

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
22/*
23/*
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Copyright 2005 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
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"
32
34
33#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.7 */
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>
34
42
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>
43extern int do_prominfo(int, char *, int, int);
43
44
44/*
45 * function prototypes
46 */
47extern int do_prominfo(int syserrlog, char *progname,
48 int logging, int print_flag);
49static char *setprogname(char *name);
45static char *
46setprogname(char *name)
47{
48 char *p;
50
49
51void
50 if (p = strrchr(name, '/'))
51 return (p + 1);
52 else
53 return (name);
54}
55
56int
52main(int argc, char *argv[])
53{
54 int c;
55 int syserrlog = 0;
57main(int argc, char *argv[])
58{
59 int c;
60 int syserrlog = 0;
56 char *usage = "%s [ -v ] [ -l ]\n";
57 char *progname;
61 char *progname = setprogname(argv[0]);
58 int print_flag = 1;
59 int logging = 0;
60
62 int print_flag = 1;
63 int logging = 0;
64
61 /* set up for internationalization */
62 (void) setlocale(LC_ALL, "");
63 (void) textdomain(TEXT_DOMAIN);
64
65 (void) setlocale(LC_ALL, "");
66 (void) textdomain(TEXT_DOMAIN);
67
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);
68 if (getzoneid() != GLOBAL_ZONEID) {
69 (void) fprintf(stderr,
70 gettext("%s can only be run in the global zone\n"),
71 progname);
70 exit(1);
71 /*NOTREACHED*/
72 return (1);
72 }
73 }
74
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:
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:
84 (void) fprintf(stderr, usage, progname);
85 exit(1);
86 /*NOTREACHED*/
86 (void) fprintf(stderr, "Usage: %s [-lv]\n", progname);
87 return (1);
87 }
88 }
89
88 }
89 }
90
90 /*
91 * for sun4u do_prominfo() is in libprtdiag
92 */
93 exit(do_prominfo(syserrlog, progname, logging, print_flag));
91 return (do_prominfo(syserrlog, progname, logging, print_flag));
94}
92}
95
96static char *
97setprogname(char *name)
98{
99 char *p;
100
101 if (p = strrchr(name, '/'))
102 return (p + 1);
103 else
104 return (name);
105}