4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 * String conversion routine for segment flags.
33 #include "entry_msg.h"
35 #define ENTSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
36 MSG_FLG_EC_BUILTIN_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
37 MSG_FLG_EC_USED_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
38 MSG_FLG_EC_CATCHALL_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
39 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
42 * Ensure that Conv_ent_flags_buf_t is large enough:
44 * ENTSZ is the real minimum size of the buffer required by conv_ent_flags().
45 * However, Conv_ent_flags_buf_t uses CONV_ENT_FLAGS_BUFSIZE to set the
46 * buffer size. We do things this way because the definition of ENTSZ uses
47 * information that is not available in the environment of other programs
48 * that include the conv.h header file.
50 #if (CONV_ENT_FLAGS_BUFSIZE != ENTSZ) && !defined(__lint)
51 #define REPORT_BUFSIZE ENTSZ
52 #include "report_bufsize.h"
53 #error "CONV_ENT_FLAGS_BUFSIZE does not match ENTSZ"
57 conv_ent_flags(ec_flags_t flags
, Conv_ent_flags_buf_t
*ent_flags_buf
)
59 static Val_desc vda
[] = {
60 { FLG_EC_BUILTIN
, MSG_FLG_EC_BUILTIN
},
61 { FLG_EC_USED
, MSG_FLG_EC_USED
},
62 { FLG_EC_CATCHALL
, MSG_FLG_EC_CATCHALL
},
65 static CONV_EXPN_FIELD_ARG conv_arg
= {
66 NULL
, sizeof (ent_flags_buf
->buf
) };
69 return (MSG_ORIG(MSG_GBL_ZERO
));
71 conv_arg
.buf
= ent_flags_buf
->buf
;
72 conv_arg
.oflags
= conv_arg
.rflags
= flags
;
73 (void) conv_expn_field(&conv_arg
, vda
, 0);
75 return ((const char *)ent_flags_buf
->buf
);
79 #define ECFSZ CONV_EXPN_FIELD_DEF_PREFIX_SIZE + \
80 MSG_TYP_ECF_PATH_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
81 MSG_TYP_ECF_BASENAME_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
82 MSG_TYP_ECF_OBJNAME_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
83 MSG_FLG_ECF_ARMEMBER_SIZE + CONV_EXPN_FIELD_DEF_SEP_SIZE + \
84 CONV_INV_BUFSIZE + CONV_EXPN_FIELD_DEF_SUFFIX_SIZE
87 * Ensure that Conv_ent_flags_buf_t is large enough:
89 * ENTSZ is the real minimum size of the buffer required by conv_ent_flags().
90 * However, Conv_ent_flags_buf_t uses CONV_ENT_FLAGS_BUFSIZE to set the
91 * buffer size. We do things this way because the definition of ENTSZ uses
92 * information that is not available in the environment of other programs
93 * that include the conv.h header file.
95 #if (CONV_ENT_FILES_FLAGS_BUFSIZE != ECFSZ) && !defined(__lint)
96 #define REPORT_BUFSIZE ECFSZ
97 #include "report_bufsize.h"
98 #error "CONV_ENT_FILES_FLAGS_BUFSIZE does not match ECFSZ"
102 * Make a string representation of the End_desc_file edf_flags field.
105 conv_ent_files_flags(Word flags
, Conv_fmt_flags_t fmt_flags
,
106 Conv_ent_files_flags_buf_t
*flags_buf
)
108 static const Msg types
[] = {
109 MSG_TYP_ECF_PATH
, MSG_TYP_ECF_BASENAME
, MSG_TYP_ECF_OBJNAME
111 #if TYP_ECF_NUM != (TYP_ECF_OBJNAME + 1)
112 #error "types has grown"
115 static Val_desc vda
[] = {
116 { FLG_ECF_ARMEMBER
, MSG_FLG_ECF_ARMEMBER
},
120 static const char *leading_str_arr
[2];
121 static CONV_EXPN_FIELD_ARG conv_arg
= {
122 NULL
, sizeof (flags_buf
->buf
), leading_str_arr
};
126 type_idx
= flags
& TYP_ECF_MASK
;
127 if (type_idx
< TYP_ECF_NUM
) {
128 leading_str_arr
[0] = MSG_ORIG(types
[type_idx
]);
129 flags
&= ~TYP_ECF_MASK
;
131 leading_str_arr
[0] = NULL
;
134 conv_arg
.buf
= flags_buf
->buf
;
135 conv_arg
.oflags
= conv_arg
.rflags
= flags
;
137 (void) conv_expn_field(&conv_arg
, vda
, fmt_flags
);
139 return (conv_arg
.buf
);