Home | History | Annotate | Download | only in prtfru
      1  0  stevel /*
      2  0  stevel  * CDDL HEADER START
      3  0  stevel  *
      4  0  stevel  * The contents of this file are subject to the terms of the
      5  0  stevel  * Common Development and Distribution License, Version 1.0 only
      6  0  stevel  * (the "License").  You may not use this file except in compliance
      7  0  stevel  * with the License.
      8  0  stevel  *
      9  0  stevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10  0  stevel  * or http://www.opensolaris.org/os/licensing.
     11  0  stevel  * See the License for the specific language governing permissions
     12  0  stevel  * and limitations under the License.
     13  0  stevel  *
     14  0  stevel  * When distributing Covered Code, include this CDDL HEADER in each
     15  0  stevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16  0  stevel  * If applicable, add the following below this CDDL HEADER, with the
     17  0  stevel  * fields enclosed by brackets "[]" replaced with your own identifying
     18  0  stevel  * information: Portions Copyright [yyyy] [name of copyright owner]
     19  0  stevel  *
     20  0  stevel  * CDDL HEADER END
     21  0  stevel  */
     22  0  stevel /*
     23  0  stevel  * Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
     24  0  stevel  * Use is subject to license terms.
     25  0  stevel  */
     26  0  stevel 
     27  0  stevel #pragma ident	"%Z%%M%	%I%	%E% SMI"
     28  0  stevel 
     29  0  stevel #include <libintl.h>
     30  0  stevel #include <locale.h>
     31  0  stevel #include <stdio.h>
     32  0  stevel 
     33  0  stevel #include "libfru.h"
     34  0  stevel #include "prtfru.h"
     35  0  stevel 
     36  0  stevel 
     37  0  stevel static void
     38  0  stevel usage(const char *command)
     39  0  stevel {
     40  0  stevel 	(void) fprintf(stderr,
     41  0  stevel 		gettext("Usage:  %s [ -d ] | [ -clx ] [ container ]\n"),
     42  0  stevel 		command);
     43  0  stevel }
     44  0  stevel 
     45  0  stevel int
     46  0  stevel main(int argc, char *argv[])
     47  0  stevel {
     48  0  stevel 	char  *command = argv[0], *searchpath = NULL;
     49  0  stevel 
     50  0  stevel 	int   containers_only = 0, dtd = 0, list_only = 0, nodtd = 0, option,
     51  0  stevel 		status, xml = 0;
     52  0  stevel 
     53  0  stevel 
     54  0  stevel 	(void) setlocale(LC_ALL, "");
     55  0  stevel 	(void) textdomain(TEXT_DOMAIN);
     56  0  stevel 
     57  0  stevel 	opterr = 0;	/*  "getopt" should not print to "stderr"  */
     58  0  stevel 	while ((option = getopt(argc, argv, "cdlx")) != EOF) {
     59  0  stevel 		switch (option) {
     60  0  stevel 		case 'c':
     61  0  stevel 			containers_only = 1;
     62  0  stevel 			nodtd = 1;
     63  0  stevel 			break;
     64  0  stevel 		case 'd':
     65  0  stevel 			dtd = 1;
     66  0  stevel 			break;
     67  0  stevel 		case 'l':
     68  0  stevel 			list_only = 1;
     69  0  stevel 			nodtd = 1;
     70  0  stevel 			break;
     71  0  stevel 		case 'x':
     72  0  stevel 			xml = 1;
     73  0  stevel 			nodtd = 1;
     74  0  stevel 			break;
     75  0  stevel 		default:
     76  0  stevel 			usage(command);
     77  0  stevel 			return (1);
     78  0  stevel 		}
     79  0  stevel 	}
     80  0  stevel 
     81  0  stevel 	argc -= optind;
     82  0  stevel 	argv += optind;
     83  0  stevel 
     84  0  stevel 	if (dtd) {
     85  0  stevel 		if (nodtd || (argc > 0)) {
     86  0  stevel 			usage(command);
     87  0  stevel 			(void) fprintf(stderr,
     88  0  stevel 			    gettext("Specify \"-d\" alone\n"));
     89  0  stevel 			return (1);
     90  0  stevel 		}
     91  0  stevel 
     92  0  stevel 		return (output_dtd());
     93  0  stevel 	}
     94  0  stevel 
     95  0  stevel 	switch (argc) {
     96  0  stevel 	case 0:
     97  0  stevel 		break;
     98  0  stevel 	case 1:
     99  0  stevel 		searchpath = argv[0];
    100  0  stevel 		if (!searchpath[0]) {
    101  0  stevel 			usage(command);
    102  0  stevel 			(void) fprintf(stderr,
    103  0  stevel 			    gettext("\"container\" should not be empty\n"));
    104  0  stevel 			return (1);
    105  0  stevel 		}
    106  0  stevel 		break;
    107  0  stevel 	default:
    108  0  stevel 		usage(command);
    109  0  stevel 		return (1);
    110  0  stevel 	}
    111  0  stevel 
    112  0  stevel 
    113  0  stevel 	/*
    114  0  stevel 	 * Select the data source and print all the data
    115  0  stevel 	 */
    116  0  stevel 	if ((status = fru_open_data_source("picl")) != FRU_SUCCESS) {
    117  0  stevel 		(void) fprintf(stderr,
    118  0  stevel 		    gettext("Error opening FRU ID data source:  %s\n"),
    119  0  stevel 		    fru_strerror(status));
    120  0  stevel 		return (1);
    121  0  stevel 	}
    122  0  stevel 
    123  0  stevel 	return (prtfru(searchpath, containers_only, list_only, xml));
    124  0  stevel }
    125