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