8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / bart / main.c
blobcdd254b60b636cf9f537d1115f4e999bd220437b
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 2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
28 #include <signal.h>
29 #include <unistd.h>
30 #include <locale.h>
31 #include <sys/acl.h>
32 #include "bart.h"
34 int
35 main(int argc, char **argv)
37 /* Make sure we are in the correct locale */
38 (void) setlocale(LC_ALL, "");
39 (void) textdomain(TEXT_DOMAIN);
41 /* Superficial check of the arguments. Note usage() exits the pgm */
42 if (argc < 2)
43 usage();
46 * OK, hand it off to bart_create() or bart_compare().
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.
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)));
57 } else usage();
59 return (FATAL_EXIT);
61 void
62 usage()
64 (void) fprintf(stderr, USAGE_MSG);
65 exit(FATAL_EXIT);
67 void *
68 safe_calloc(size_t size)
70 char *ptr;
72 ptr = calloc((size_t)1, size);
73 if (ptr == NULL)
74 exit(FATAL_EXIT);
75 else return (ptr);
77 /* NOTREACHED */