Home | History | Annotate | Download | only in bart
      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 2003 Sun Microsystems, Inc.  All rights reserved.
     24  * Use is subject to license terms.
     25  */
     26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
     27 
     28 #include <signal.h>
     29 #include <unistd.h>
     30 #include <locale.h>
     31 #include <sys/acl.h>
     32 #include "bart.h"
     33 
     34 int
     35 main(int argc, char **argv)
     36 {
     37 	/* Make sure we are in the correct locale */
     38 	(void) setlocale(LC_ALL, "");
     39 	(void) textdomain(TEXT_DOMAIN);
     40 
     41 	/* Superficial check of the arguments.  Note usage() exits the pgm */
     42 	if (argc < 2)
     43 		usage();
     44 
     45 	/*
     46 	 * OK, hand it off to bart_create() or bart_compare().
     47 	 *
     48 	 * Since the command line was 'bart create ..',  or 'bart compare ..',
     49 	 * those subcommands should start parsing options at &argv[1], and
     50 	 *  (argc-1) to be consistent.
     51 	 */
     52 	if (strcmp(argv[1], "create") == 0)
     53 		return (bart_create((argc-1), (argv+1)));
     54 	else if (strcmp(argv[1], "compare") == 0) {
     55 		return (bart_compare((argc-1), (argv+1)));
     56 
     57 	} else usage();
     58 
     59 	return (FATAL_EXIT);
     60 }
     61 void
     62 usage()
     63 {
     64 	(void) fprintf(stderr, USAGE_MSG);
     65 	exit(FATAL_EXIT);
     66 }
     67 void *
     68 safe_calloc(size_t size)
     69 {
     70 	char	*ptr;
     71 
     72 	ptr = calloc((size_t)1, size);
     73 	if (ptr == NULL)
     74 		exit(FATAL_EXIT);
     75 	else return (ptr);
     76 
     77 	/* NOTREACHED */
     78 }
     79