attribute.c revision 0a44ef6d9afbfe052a7e975f55ea0d2954b62a82
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
*/
/* $Id: attribute.c 157 2006-04-26 15:07:55Z ktou $ */
#pragma ident "%Z%%M% %I% %E% SMI"
/*LINTLIBRARY*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <alloca.h>
#include <papi.h>
static void
{
switch (type) {
case PAPI_STRING:
break;
case PAPI_COLLECTION:
int i;
}
break;
default: /* don't need to free anything extra */
break;
}
}
}
static void
{
int i;
}
}
static void
{
}
}
void
{
int i;
papiAttributeFree(list[i]);
}
}
static papi_attribute_t **
{
/* allows a NULL collection that is "empty" or "no value" */
if (collection != NULL) {
int i;
i++) {
papi_attribute_t *a = collection[i];
NULL);
int j;
&result,
a->values[j]);
}
}
}
}
return (result);
}
static papi_attribute_value_t *
{
switch (type) {
case PAPI_STRING:
} else
break;
case PAPI_INTEGER:
break;
case PAPI_BOOLEAN:
break;
case PAPI_RANGE:
break;
case PAPI_RESOLUTION:
break;
case PAPI_DATETIME:
break;
case PAPI_COLLECTION:
break;
case PAPI_METADATA:
break;
default: /* unknown type, fail to duplicate */
}
}
return (result);
}
static papi_attribute_t *
{
}
return (result);
}
static papi_status_t
{
return (PAPI_BAD_ARGUMENT);
return (PAPI_TEMPORARY_ERROR);
}
return (PAPI_OK);
}
{
return (PAPI_BAD_ARGUMENT);
return (PAPI_BAD_ARGUMENT); /* RANGE must have min <= max */
if (flags == 0) /* if it wasn't set, set a default behaviour */
/* look for an existing one */
return (PAPI_CONFLICT); /* EXISTS */
return (PAPI_CONFLICT); /* TYPE CONFLICT */
/* if we don't have one, create it and add it to the list */
/* if we don't have one by now, it's most likely an alloc fail */
return (PAPI_TEMPORARY_ERROR);
/*
* if we are replacing, clear any existing values, but don't free
* until after we have replaced the values, in case we are replacing
* a collection with a relocated version of the original collection.
*/
}
/* free old values if we replaced them */
return (result);
}
{
}
{
}
{
}
{
}
{
PAPI_RESOLUTION, &v));
}
{
PAPI_DATETIME, &v));
}
{
PAPI_COLLECTION, &v));
}
{
PAPI_METADATA, &v));
}
{
return (PAPI_BAD_ARGUMENT);
return (PAPI_NOT_FOUND);
return (PAPI_OK);
}
{
int i;
return (NULL);
return ((papi_attribute_t *)list[i]);
return (NULL);
}
{
return (NULL);
return (result);
}
{
return (PAPI_BAD_ARGUMENT);
return (PAPI_NOT_FOUND);
return (PAPI_NOT_POSSIBLE);
} else
return (PAPI_NOT_FOUND);
return (PAPI_GONE);
return (PAPI_OK);
}
{
return (PAPI_BAD_ARGUMENT);
PAPI_STRING, &value);
return (status);
}
{
return (PAPI_BAD_ARGUMENT);
PAPI_INTEGER, &value);
return (status);
}
{
return (PAPI_BAD_ARGUMENT);
PAPI_BOOLEAN, &value);
return (status);
}
{
return (PAPI_BAD_ARGUMENT);
PAPI_RANGE, &value);
}
return (status);
}
char *name, int *x, int *y,
{
return (PAPI_BAD_ARGUMENT);
PAPI_RESOLUTION, &value);
}
return (status);
}
{
return (PAPI_BAD_ARGUMENT);
PAPI_DATETIME, &value);
}
return (status);
}
{
if (collection == NULL)
return (PAPI_BAD_ARGUMENT);
PAPI_COLLECTION, &value);
}
return (status);
}
{
return (PAPI_BAD_ARGUMENT);
PAPI_METADATA, &value);
return (status);
}
/*
* Description: The given string contains one or more attributes, in the
* following form:
* "aaaa=true bbbbb=1 ccccc=abcd"
* extract the next attribute from that string; the 'next'
* parameter should be set to zero to extract the first attribute
* in the string.
*
*/
static char *
{
int len = 0;
{
start++;
}
}
}
}
if (len == 0) {
}
if (len > 0) {
}
}
}
return (result);
} /* _getNextAttr() */
/*
* Description: Parse the given attribute string value and transform it into
* the papi_attribute_value_t in the papi_attribute_t structure.
*
*/
static papi_status_t
{
int len = 0;
int i = 0;
char *papiString = NULL;
return (result);
}
return (result);
}
/*
* TODO - need to sort out 'resolution', 'dateandtime' & 'collection' values
*/
/* string value */
if (papiString != NULL) {
} else {
}
/* boolean = true */
/* boolean = false */
} else {
/* is value an integer or a range ? */
i = 0;
(value[i] == '-')) {
if (value[i] == '-') {
tmp1[i] = '\0';
}
i++;
}
} else {
}
} else {
/* is value a resolution ? */
i = 0;
while (((value[i] >= '0') &&
(value[i] <= '9')) ||
(value[i] == 'x')) {
if (value[i] == 'x') {
tmp1[i] = '\0';
{
} else {
}
}
i++;
}
avalues[0]->
} else {
avalues[0]->
resolution.units = 0;
}
}
}
}
}
}
}
} else {
}
i = 0;
i++;
}
} else {
}
return (result);
} /* _parseAttrValue() */
/*
* Description: Parse the given attribute string and transform it into the
* papi_attribute_t structure.
*
*/
static papi_status_t
{
char *p = NULL;
if (p != NULL) {
*p = '\0';
p++; /* pointer to value */
} else {
char value;
/* boolean - no value so assume 'true' */
string += 2;
value = PAPI_FALSE;
} else
sizeof (papi_attribute_value_t *) * 2);
} else {
sizeof (papi_attribute_value_t));
} else {
}
}
}
}
} else {
}
return (result);
} /* _parseAttributeString() */
{
int next = 0;
char *attrString = NULL;
== 0)) {
/* add this attribute to the list */
} else {
}
}
}
}
else
{
}
return (result);
}
static papi_status_t
{
int rc, i;
return (PAPI_OK);
case PAPI_STRING:
break;
case PAPI_INTEGER: {
char string[24];
}
break;
case PAPI_BOOLEAN:
"false"), buflen);
break;
case PAPI_RANGE: {
char string[24];
}
break;
case PAPI_RESOLUTION: {
char string[24];
? 'c' : 'i'));
}
break;
case PAPI_DATETIME: {
char string[64];
}}
break;
case PAPI_COLLECTION: {
#ifdef DEBUG
char prefix[256];
#else
#endif
}
break;
default: {
char string[32];
}
}
return (PAPI_NOT_POSSIBLE);
}
return (PAPI_OK);
}
{
int i;
return (PAPI_BAD_ARGUMENT);
buffer[0] = '\0';
if (!delim)
delim = " ";
#ifdef DEBUG
#endif
}
return (status);
}
static int
{
int i;
return (0);
}
return (1);
}
static papi_status_t
{
int i = 0;
return (PAPI_BAD_ARGUMENT);
i++;
return (status);
}
void
{
int i;
return;
for (i = 0; attributes[i] != NULL; i++)
}
void
{
int i;
return;
for (i = 0; attributes[i] != NULL; i++)
else
}
void
char *prefix_fmt, ...)
{
void *mem;
size += 1024;
}
if (attributes) {
size = 0;
size += 1024;
}
}
}