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