8987 bootadm: add bootfile fallback to unix
[unleashed.git] / usr / src / cmd / msgfmt / util.c
blobf2ddbaa7694bd8ec621cde9e0f6f15592488fccf
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.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include "common.h"
31 /*PRINTFLIKE1*/
32 void
33 error(char *err, ...)
35 va_list ap;
36 va_start(ap, err);
38 (void) fprintf(stderr, gettext(ERR_ERROR));
39 (void) vfprintf(stderr, err, ap);
40 va_end(ap);
41 exit(2);
44 /*PRINTFLIKE1*/
45 void
46 warning(char *err, ...)
48 va_list ap;
49 va_start(ap, err);
51 (void) fprintf(stderr, gettext(WARN_WARNING));
52 (void) vfprintf(stderr, err, ap);
53 va_end(ap);
56 /*PRINTFLIKE1*/
57 void
58 diag(char *err, ...)
60 va_list ap;
61 va_start(ap, err);
63 (void) vfprintf(stderr, err, ap);
64 va_end(ap);
67 void *
68 Xmalloc(size_t size)
70 void *t;
72 t = malloc(size);
73 if (!t) {
74 error(gettext(ERR_MALLOC));
75 /* NOTREACHED */
77 return (t);
80 void *
81 Xcalloc(size_t nelem, size_t elsize)
83 void *t;
85 t = calloc(nelem, elsize);
86 if (!t) {
87 error(gettext(ERR_MALLOC));
88 /* NOTREACHED */
90 return (t);
93 void *
94 Xrealloc(void *ptr, size_t size)
96 void *t;
98 t = realloc(ptr, size);
99 if (!t) {
100 free(ptr);
101 error(gettext(ERR_MALLOC));
102 /* NOTREACHED */
104 return (t);
107 char *
108 Xstrdup(const char *str)
110 char *t;
112 t = strdup(str);
113 if (!t) {
114 error(gettext(ERR_MALLOC));
115 /* NOTREACHED */
117 return (t);