/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Descriptor parsing functions
*/
#include <sys/inttypes.h>
if ((buf)[0] == 0) { \
break; \
} else { \
}
/*
* ibmf_utils_unpack_data:
*
* parser function which takes a format string, a void pointer, and a character
* buffer and parses the buffer according to the identifiers in the format
* string. Copies the data from the buffer and places into the structure,
* taking care of byte swapping and any padding due to 64-bit Solaris. Modified
*
* The data and structure length parameters can be larger than the number of
* bytes specified in the format. unpack_data will use the smallest of the
* three values, stopping when it finishes parsing the format string or reaches
* the end of one of the two buffers.
*/
void
void *structure,
{
int fmt;
int multiplier = 0;
if (fmt == 'c') {
/*
* account for possible hole in structure
* due to unaligned data
*/
~(_CHAR_ALIGNMENT - 1));
break;
if (multiplier) {
multiplier--;
}
if (multiplier == 0) {
format++;
}
} else if (fmt == 's') {
/*
* account for possible hole in structure
* due to unaligned data
*/
~(_SHORT_ALIGNMENT - 1));
break;
data += 2;
if (multiplier) {
multiplier--;
}
if (multiplier == 0) {
format++;
}
} else if (fmt == 'l') {
/*
* account for possible hole in structure
* due to unaligned data
*/
~(_INT_ALIGNMENT - 1));
break;
data += 4;
if (multiplier) {
multiplier--;
}
if (multiplier == 0) {
format++;
}
} else if (fmt == 'L') {
/*
* account for possible hole in structure
* due to unaligned data
*/
~(_LONG_LONG_ALIGNMENT - 1));
break;
/*
* note: data[0] is cast to uint64_t so that the
* compiler wouldn't treat the results of the shifts
* as a 32bit quantity; we really want to get 64bits
* out of this.
*/
data[7];
data += 8;
if (multiplier) {
multiplier--;
}
if (multiplier == 0) {
format++;
}
format++;
} else {
multiplier = 0;
break;
}
}
}
/*
* ibmf_utils_pack_data:
*
* parser function which takes a format string, a void pointer, and a character
* buffer and parses the structure according to the identifiers in the format
* string. Copies the data from the structure and places in the buffer, taking
* care of byte swapping and any padding due to 64-bit Solaris. Modified from
*
*/
void
{
int fmt;
int multiplier = 0;
if (fmt == 'c') {
/*
* account for possible hole in structure
* due to unaligned data
*/
~(_CHAR_ALIGNMENT - 1));
break;
}
if (multiplier) {
multiplier--;
}
if (multiplier == 0) {
format++;
}
} else if (fmt == 's') {
/*
* account for possible hole in structure
* due to unaligned data
*/
~(_SHORT_ALIGNMENT - 1));
break;
/* do an endian-independent copy */
sp++;
data += 2;
if (multiplier) {
multiplier--;
}
if (multiplier == 0) {
format++;
}
} else if (fmt == 'l') {
/*
* account for possible hole in structure
* due to unaligned data
*/
~(_INT_ALIGNMENT - 1));
break;
/* do an endian-independent copy */
lp++;
data += 4;
if (multiplier) {
multiplier--;
}
if (multiplier == 0) {
format++;
}
} else if (fmt == 'L') {
/*
* account for possible hole in structure
* due to unaligned data
*/
~(_LONG_LONG_ALIGNMENT - 1));
break;
/* do an endian-independent copy */
llp++;
data += 8;
if (multiplier) {
multiplier--;
}
if (multiplier == 0) {
format++;
}
format++;
} else {
multiplier = 0;
break;
}
}
}