2005-05-01 04:53:00 +04:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2006-02-07 06:32:36 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2005-05-01 04:53:00 +04:00
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
2006-02-07 06:32:36 +03:00
|
|
|
*
|
2005-05-01 04:53:00 +04:00
|
|
|
* Additional copyrights may follow
|
2006-02-07 06:32:36 +03:00
|
|
|
*
|
2005-05-01 04:53:00 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
2006-02-07 06:32:36 +03:00
|
|
|
|
2005-05-01 04:53:00 +04:00
|
|
|
#include "orte_config.h"
|
|
|
|
|
2006-02-07 06:32:36 +03:00
|
|
|
#include "orte/mca/errmgr/errmgr.h"
|
2005-05-01 04:53:00 +04:00
|
|
|
|
2006-02-07 06:32:36 +03:00
|
|
|
#include "orte/dss/dss_internal.h"
|
2005-05-01 04:53:00 +04:00
|
|
|
|
|
|
|
|
2006-02-07 06:32:36 +03:00
|
|
|
int orte_dss_peek(orte_buffer_t *buffer, orte_data_type_t *type,
|
2005-05-01 04:53:00 +04:00
|
|
|
size_t *num_vals)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
orte_buffer_t tmp;
|
2005-05-01 04:58:06 +04:00
|
|
|
size_t n=1;
|
|
|
|
orte_data_type_t local_type;
|
2005-05-01 04:53:00 +04:00
|
|
|
|
|
|
|
/* check for errors */
|
|
|
|
if (buffer == NULL) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
|
|
|
|
return ORTE_ERR_BAD_PARAM;
|
|
|
|
}
|
|
|
|
|
2005-05-01 04:58:06 +04:00
|
|
|
/* Double check and ensure that there is data left in the buffer. */
|
|
|
|
|
|
|
|
if (buffer->unpack_ptr >= buffer->base_ptr + buffer->bytes_used) {
|
|
|
|
*type = ORTE_NULL;
|
|
|
|
*num_vals = 0;
|
2006-02-07 06:32:36 +03:00
|
|
|
return ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER;
|
2005-05-01 04:58:06 +04:00
|
|
|
}
|
|
|
|
|
2005-05-01 04:53:00 +04:00
|
|
|
/* cheat: unpack from a copy of the buffer -- leaving all the
|
|
|
|
original pointers intact */
|
|
|
|
tmp = *buffer;
|
|
|
|
|
2005-05-01 04:58:06 +04:00
|
|
|
if (ORTE_SUCCESS != (
|
2006-02-07 06:32:36 +03:00
|
|
|
ret = orte_dss_get_data_type(&tmp, &local_type))) {
|
2005-05-01 04:58:06 +04:00
|
|
|
*type = ORTE_NULL;
|
|
|
|
*num_vals = 0;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
if (ORTE_SIZE != local_type) { /* if the length wasn't first, then error */
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_UNPACK_FAILURE);
|
|
|
|
*type = ORTE_NULL;
|
|
|
|
*num_vals = 0;
|
|
|
|
return ORTE_ERR_UNPACK_FAILURE;
|
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
if (ORTE_SUCCESS != (ret = orte_dss_unpack_sizet(&tmp, num_vals, &n, ORTE_SIZE))) {
|
2005-05-01 04:53:00 +04:00
|
|
|
ORTE_ERROR_LOG(ret);
|
2005-05-01 04:58:06 +04:00
|
|
|
*type = ORTE_NULL;
|
|
|
|
*num_vals = 0;
|
2005-05-01 04:53:00 +04:00
|
|
|
return ret;
|
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
if (ORTE_SUCCESS != (ret = orte_dss_get_data_type(&tmp, type))) {
|
2005-05-01 04:53:00 +04:00
|
|
|
ORTE_ERROR_LOG(ret);
|
2005-05-01 04:58:06 +04:00
|
|
|
*type = ORTE_NULL;
|
|
|
|
*num_vals = 0;
|
2005-05-01 04:53:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2006-02-07 06:32:36 +03:00
|
|
|
|
|
|
|
int orte_dss_peek_type(orte_buffer_t *buffer, orte_data_type_t *type)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
orte_buffer_t tmp;
|
|
|
|
|
|
|
|
/* check for errors */
|
|
|
|
if (buffer == NULL) {
|
|
|
|
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
|
|
|
|
return ORTE_ERR_BAD_PARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Double check and ensure that there is data left in the buffer. */
|
|
|
|
|
|
|
|
if (buffer->unpack_ptr >= buffer->base_ptr + buffer->bytes_used) {
|
|
|
|
*type = ORTE_UNDEF;
|
|
|
|
return ORTE_ERR_UNPACK_READ_PAST_END_OF_BUFFER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cheat: unpack from a copy of the buffer -- leaving all the
|
|
|
|
original pointers intact */
|
|
|
|
tmp = *buffer;
|
|
|
|
|
|
|
|
if (ORTE_SUCCESS != (
|
|
|
|
ret = orte_dss_get_data_type(&tmp, type))) {
|
|
|
|
*type = ORTE_UNDEF;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ORTE_SUCCESS;
|
|
|
|
}
|