/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <strings.h>
#include <_machelf.h>
#include "_conv.h"
#include "globals_msg.h"
/*
* Map an integer into a descriptive string.
*
* entry:
* inv_buf - A buffer into which this routine can format
* a result string, if necessary.
* val - The value for which a string is desired.
* flags - CONV_FMT_* values to be passed to conv_invalid_val() if
* necessary. The caller is reponsible for having examined
* the CONV_FMT_ALT_* part of flags and passing the proper
* msg array.
* num_msg - # of Msg entries in msg.
* msg - Array of num_msg Msg items corresponding to the possible
* strings corresponding to val.
* local_sgs_msg - Message string table from module from which
* this function is called.
*
* exit:
* If val lies in the range [0-(num_msg-1)], then the string
* corresponding to it is returned. If val is outside the range,
* conv_invalid_val() is called to format an ASCII representation
* of it into inv_buf, and that is returned.
*/
/*ARGSUSED5*/
static const char *
const char *local_sgs_msg)
{
/* If we get here, it's an unknown value */
}
/*
* Map an integer into a descriptive string from a NULL terminated
* array of Val_desc or Val_desc2 descriptors.
*
* entry:
* inv_buf - A buffer into which this routine can format
* a result string, if necessary.
* val is to be interpreted. Items with a non-0 osabi or machine
* that do not match are quietly ignored.
* val - The value for which a string is desired.
* flags - CONV_FMT_* values to be passed to conv_invalid_val() if
* necessary. The caller is reponsible for having examined
* the CONV_FMT_ALT_* part of flags and passing the proper
* descriptor array.
* vdp - Pointer to NULL terminated array of Val_desc descriptors.
* local_sgs_msg - Message string table from module from which
* this function is called.
*
* exit:
* If val is found in the vdp array, and in the osabi version of
* this function if the osabi matches, then the string corresponding
* val is returned. If a string for val is not found, conv_invalid_val()
* is called to format an ASCII representation of it into inv_buf, and
* that is returned.
*/
/*ARGSUSED4*/
static const char *
{
}
/* If we get here, it's an unknown value */
}
/*ARGSUSED6*/
static const char *
const char *local_sgs_msg)
{
continue;
}
/* If we get here, it's an unknown value */
}
/*
* Process an array of conv_ds_XXX_t structures and call the appropriate
* map functions for the format of the strings given.
*/
const char *
const char *local_sgs_msg)
{
continue;
case CONV_DS_MSGARR:
/*LINTED*/
case CONV_DS_VD:
/*LINTED*/
case CONV_DS_VD2:
/*LINTED*/
}
}
}
/*
* Iterate over every message string in a given array of Msg codes,
* calling a user supplied callback for each one.
*
* entry:
* basevalue - Value corresponding to the first Msg in the array.
* local_sgs_msg - Pointer to the __sgs_msg array for the
* libconv module making the call.
* num_msg - # of items in array referenced by msg
* msg - Array of Msg indexes for the strings to iterate over.
* The value corresponding to each element of msg must be:
* value[i] = basevalue + i
* func, uvalue - User supplied function to be called for each
* string in msg. uvalue is an arbitrary user supplied pointer
* to be passed to func.
* local_sgs_msg - Pointer to the __sgs_msg array for the
* libconv module making the call.
*
* exit:
* The callback function is called for every non-zero item in
* msg[]. If any callback returns CONV_ITER_DONE, execution stops
* with that item and the function returns immediately. Otherwise,
* it continues to the end of the array.
*
* The value from the last callback is returned.
*/
/*ARGSUSED5*/
static conv_iter_ret_t
{
if (*msg != 0)
return (CONV_ITER_DONE);
}
return (CONV_ITER_CONT);
}
/*
* Iterate over every message string in a given array of Val_desc or
* Val_desc2 descriptors, calling a user supplied callback for each one.
*
* entry:
* strings are desired. Strings with a non-0 osabi or machine
* that do not match are quietly ignored.
* vdp - Pointer to NULL terminated array of Val_desc descriptors.
* func, uvalue - User supplied function to be called for each
* string in msg. uvalue is an arbitrary user supplied pointer
* to be passed to func.
* local_sgs_msg - Pointer to the __sgs_msg array for the
* libconv module making the call.
*
* exit:
* The callback function is called for every descriptor referenced by
* vdp. In the case of the OSABI-version of this function, strings from
* the wrong osabi are not used. If any callback returns CONV_ITER_DONE,
* execution stops with that item and the function returns immediately.
* Otherwise, it continues to the end of the array.
*
* The value from the last callback is returned.
*/
/*ARGSUSED3*/
const char *local_sgs_msg)
{
return (CONV_ITER_DONE);
}
return (CONV_ITER_CONT);
}
/*ARGSUSED5*/
{
continue;
return (CONV_ITER_DONE);
}
return (CONV_ITER_CONT);
}
/*
* Process an array of conv_ds_XXX_t structures and call the appropriate
* iteration functions for the format of the strings given.
*/
{
case CONV_DS_MSGARR:
/*LINTED*/
return (CONV_ITER_DONE);
break;
case CONV_DS_VD:
/*LINTED*/
return (CONV_ITER_DONE);
break;
case CONV_DS_VD2:
/*LINTED*/
return (CONV_ITER_DONE);
break;
}
}
return (CONV_ITER_CONT);
}
/*
* Initialize the uvalue block prior to use of an interation function
* employing conv_iter_strtol().
*
* entry:
* str - String to be matched to a value
* uvalue - Pointer to uninitialized uvalue block
*
* exit:
* Initializes the uvalue block for use. Returns True (1) if a non-empty
* string was supplied, and False (0).
*/
int
{
const char *tail;
while (conv_strproc_isspace(*str))
str++;
tail--;
return (uvalue->csl_strlen > 0);
}
/*
* conv_iter_strtol() is used with iteration functions to map a string
* to the value of its corresponding ELF constant.
*
* entry:
* str - String supplied by this iteration
* value - Value of ELF constant corresponding to str
* uvalue - Pointer to conv_strtol_uvalue_t block previously
* initialized by a call to conv_iter_strtol_init().
*/
{
return (CONV_ITER_DONE); /* Found it. Stop now. */
}
return (CONV_ITER_CONT); /* Keep looking */
}