640 number_to_scaled_string is duplicated in several commands
[unleashed.git] / usr / src / cmd / prtfru / main.c
blob511d16966dfc31b08155660fef47021645604155
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
23 * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <libintl.h>
30 #include <locale.h>
31 #include <stdio.h>
33 #include "libfru.h"
34 #include "prtfru.h"
37 static void
38 usage(const char *command)
40 (void) fprintf(stderr,
41 gettext("Usage: %s [ -d ] | [ -clx ] [ container ]\n"),
42 command);
45 int
46 main(int argc, char *argv[])
48 char *command = argv[0], *searchpath = NULL;
50 int containers_only = 0, dtd = 0, list_only = 0, nodtd = 0, option,
51 status, xml = 0;
54 (void) setlocale(LC_ALL, "");
55 (void) textdomain(TEXT_DOMAIN);
57 opterr = 0; /* "getopt" should not print to "stderr" */
58 while ((option = getopt(argc, argv, "cdlx")) != EOF) {
59 switch (option) {
60 case 'c':
61 containers_only = 1;
62 nodtd = 1;
63 break;
64 case 'd':
65 dtd = 1;
66 break;
67 case 'l':
68 list_only = 1;
69 nodtd = 1;
70 break;
71 case 'x':
72 xml = 1;
73 nodtd = 1;
74 break;
75 default:
76 usage(command);
77 return (1);
81 argc -= optind;
82 argv += optind;
84 if (dtd) {
85 if (nodtd || (argc > 0)) {
86 usage(command);
87 (void) fprintf(stderr,
88 gettext("Specify \"-d\" alone\n"));
89 return (1);
92 return (output_dtd());
95 switch (argc) {
96 case 0:
97 break;
98 case 1:
99 searchpath = argv[0];
100 if (!searchpath[0]) {
101 usage(command);
102 (void) fprintf(stderr,
103 gettext("\"container\" should not be empty\n"));
104 return (1);
106 break;
107 default:
108 usage(command);
109 return (1);
114 * Select the data source and print all the data
116 if ((status = fru_open_data_source("picl")) != FRU_SUCCESS) {
117 (void) fprintf(stderr,
118 gettext("Error opening FRU ID data source: %s\n"),
119 fru_strerror(status));
120 return (1);
123 return (prtfru(searchpath, containers_only, list_only, xml));