2003-01-22 04:20:13 +08:00
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
|
* Copyright by The HDF Group. *
|
2003-01-22 04:20:13 +08:00
|
|
|
|
* Copyright by the Board of Trustees of the University of Illinois. *
|
|
|
|
|
* All rights reserved. *
|
|
|
|
|
* *
|
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
|
|
|
|
* the files COPYING and Copyright.html. COPYING can be found at the root *
|
|
|
|
|
* of the source code distribution tree; Copyright.html can be found at the *
|
|
|
|
|
* root level of an installed copy of the electronic HDF5 document set and *
|
|
|
|
|
* is linked from the top-level documents page. It can also be found at *
|
2007-02-07 22:56:24 +08:00
|
|
|
|
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
|
|
|
|
|
* access to either file, you may request a copy from help@hdfgroup.org. *
|
2003-01-22 04:20:13 +08:00
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* Created: H5Obogus.c
|
|
|
|
|
* Jan 21 2003
|
|
|
|
|
* Quincey Koziol <koziol@ncsa.uiuc.edu>
|
|
|
|
|
*
|
|
|
|
|
* Purpose: "bogus" message. This message is guaranteed to never
|
|
|
|
|
* be found in a valid HDF5 file and is only used to
|
|
|
|
|
* generate a test file which verifies the library's
|
|
|
|
|
* correct operation when parsing unknown object header
|
|
|
|
|
* messages.
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2003-02-17 23:54:15 +08:00
|
|
|
|
|
|
|
|
|
#define H5O_PACKAGE /*suppress error about including H5Opkg */
|
|
|
|
|
|
2007-01-23 11:46:31 +08:00
|
|
|
|
#include "H5private.h" /* Generic Functions */
|
|
|
|
|
#include "H5Eprivate.h" /* Error handling */
|
|
|
|
|
#include "H5MMprivate.h" /* Memory management */
|
|
|
|
|
#include "H5Opkg.h" /* Object headers */
|
2003-01-22 04:20:13 +08:00
|
|
|
|
|
|
|
|
|
#ifdef H5O_ENABLE_BOGUS
|
|
|
|
|
|
|
|
|
|
/* PRIVATE PROTOTYPES */
|
2009-02-13 02:47:04 +08:00
|
|
|
|
static void *H5O_bogus_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
|
|
|
|
|
unsigned mesg_flags, unsigned *ioflags, const uint8_t *p);
|
2007-02-04 15:37:15 +08:00
|
|
|
|
static herr_t H5O_bogus_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg);
|
|
|
|
|
static size_t H5O_bogus_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg);
|
2003-02-11 01:26:09 +08:00
|
|
|
|
static herr_t H5O_bogus_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream,
|
2003-01-22 04:20:13 +08:00
|
|
|
|
int indent, int fwidth);
|
|
|
|
|
|
2005-12-04 10:27:37 +08:00
|
|
|
|
/* This message derives from H5O message class */
|
|
|
|
|
const H5O_msg_class_t H5O_MSG_BOGUS[1] = {{
|
2003-01-22 04:20:13 +08:00
|
|
|
|
H5O_BOGUS_ID, /*message id number */
|
|
|
|
|
"bogus", /*message name for debugging */
|
|
|
|
|
0, /*native message size */
|
2007-05-15 04:24:08 +08:00
|
|
|
|
0, /* messages are sharable? */
|
2003-01-22 04:20:13 +08:00
|
|
|
|
H5O_bogus_decode, /*decode message */
|
|
|
|
|
H5O_bogus_encode, /*encode message */
|
|
|
|
|
NULL, /*copy the native value */
|
|
|
|
|
H5O_bogus_size, /*raw message size */
|
|
|
|
|
NULL, /*free internal memory */
|
|
|
|
|
NULL, /*free method */
|
2003-04-14 13:05:46 +08:00
|
|
|
|
NULL, /* file delete method */
|
2003-10-06 05:12:26 +08:00
|
|
|
|
NULL, /* link method */
|
2003-01-22 04:20:13 +08:00
|
|
|
|
NULL, /*set share method */
|
2007-02-04 15:37:15 +08:00
|
|
|
|
NULL, /*can share method */
|
2005-12-04 10:27:37 +08:00
|
|
|
|
NULL, /* pre copy native value to file */
|
2005-11-07 11:13:53 +08:00
|
|
|
|
NULL, /* copy native value to file */
|
|
|
|
|
NULL, /* post copy native value to file */
|
2007-01-19 22:54:46 +08:00
|
|
|
|
NULL, /* get creation index */
|
|
|
|
|
NULL, /* set creation index */
|
2005-11-07 11:13:53 +08:00
|
|
|
|
H5O_bogus_debug /*debug the message */
|
2003-01-22 04:20:13 +08:00
|
|
|
|
}};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: H5O_bogus_decode
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Decode a "bogus" message and return a pointer to a new
|
|
|
|
|
* native message struct.
|
|
|
|
|
*
|
|
|
|
|
* Return: Success: Ptr to new message in native struct.
|
|
|
|
|
*
|
|
|
|
|
* Failure: NULL
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Quincey Koziol
|
|
|
|
|
* koziol@ncsa.uiuc.edu
|
|
|
|
|
* Jan 21 2003
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static void *
|
2009-02-13 02:47:04 +08:00
|
|
|
|
H5O_bogus_decode(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, H5O_t UNUSED *open_oh,
|
|
|
|
|
unsigned UNUSED mesg_flags, unsigned UNUSED *ioflags, const uint8_t *p)
|
2003-01-22 04:20:13 +08:00
|
|
|
|
{
|
2007-01-23 11:46:31 +08:00
|
|
|
|
H5O_bogus_t *mesg = NULL;
|
2003-01-22 04:20:13 +08:00
|
|
|
|
void *ret_value; /* Return value */
|
|
|
|
|
|
2007-05-02 05:00:52 +08:00
|
|
|
|
FUNC_ENTER_NOAPI_NOINIT(H5O_bogus_decode)
|
2003-01-22 04:20:13 +08:00
|
|
|
|
|
|
|
|
|
/* check args */
|
2007-05-02 05:00:52 +08:00
|
|
|
|
HDassert(f);
|
|
|
|
|
HDassert(p);
|
2003-01-22 04:20:13 +08:00
|
|
|
|
|
|
|
|
|
/* Allocate the bogus message */
|
2007-05-02 05:00:52 +08:00
|
|
|
|
if(NULL == (mesg = H5MM_calloc(sizeof(H5O_bogus_t))))
|
|
|
|
|
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
|
2003-01-22 04:20:13 +08:00
|
|
|
|
|
|
|
|
|
/* decode */
|
|
|
|
|
UINT32DECODE(p, mesg->u);
|
|
|
|
|
|
|
|
|
|
/* Validate the bogus info */
|
2007-05-02 05:00:52 +08:00
|
|
|
|
if(mesg->u != H5O_BOGUS_VALUE)
|
|
|
|
|
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "invalid bogus value :-)")
|
2003-01-22 04:20:13 +08:00
|
|
|
|
|
|
|
|
|
/* Set return value */
|
2007-05-02 05:00:52 +08:00
|
|
|
|
ret_value = mesg;
|
2003-01-22 04:20:13 +08:00
|
|
|
|
|
|
|
|
|
done:
|
2007-05-02 05:00:52 +08:00
|
|
|
|
if(ret_value == NULL && mesg != NULL)
|
2003-01-22 04:20:13 +08:00
|
|
|
|
H5MM_xfree(mesg);
|
|
|
|
|
|
2007-05-02 05:00:52 +08:00
|
|
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
2003-01-22 04:20:13 +08:00
|
|
|
|
} /* end H5O_bogus_decode() */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: H5O_bogus_encode
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Encodes a "bogus" message.
|
|
|
|
|
*
|
|
|
|
|
* Return: Non-negative on success/Negative on failure
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Quincey Koziol
|
|
|
|
|
* koziol@ncsa.uiuc.edu
|
|
|
|
|
* Jan 21 2003
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static herr_t
|
2007-02-04 15:37:15 +08:00
|
|
|
|
H5O_bogus_encode(H5F_t UNUSED *f, hbool_t UNUSED disable_shared, uint8_t *p, const void UNUSED *mesg)
|
2003-01-22 04:20:13 +08:00
|
|
|
|
{
|
2007-05-02 05:00:52 +08:00
|
|
|
|
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_bogus_encode)
|
2003-01-22 04:20:13 +08:00
|
|
|
|
|
|
|
|
|
/* check args */
|
2007-05-02 05:00:52 +08:00
|
|
|
|
HDassert(f);
|
|
|
|
|
HDassert(p);
|
|
|
|
|
HDassert(mesg);
|
2003-01-22 04:20:13 +08:00
|
|
|
|
|
|
|
|
|
/* encode */
|
|
|
|
|
UINT32ENCODE(p, H5O_BOGUS_VALUE);
|
|
|
|
|
|
2007-05-02 05:00:52 +08:00
|
|
|
|
FUNC_LEAVE_NOAPI(SUCCEED)
|
2003-01-22 04:20:13 +08:00
|
|
|
|
} /* end H5O_bogus_encode() */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: H5O_bogus_size
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Returns the size of the raw message in bytes not
|
|
|
|
|
* counting the message typ or size fields, but only the data
|
|
|
|
|
* fields. This function doesn't take into account
|
|
|
|
|
* alignment.
|
|
|
|
|
*
|
|
|
|
|
* Return: Success: Message data size in bytes w/o alignment.
|
|
|
|
|
*
|
|
|
|
|
* Failure: Negative
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Quincey Koziol
|
|
|
|
|
* koziol@ncsa.uiuc.edu
|
|
|
|
|
* Jan 21 2003
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static size_t
|
2007-02-04 15:37:15 +08:00
|
|
|
|
H5O_bogus_size(const H5F_t UNUSED *f, hbool_t UNUSED disable_shared, const void UNUSED *mesg)
|
2003-01-22 04:20:13 +08:00
|
|
|
|
{
|
2007-05-02 05:00:52 +08:00
|
|
|
|
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_bogus_size)
|
2003-01-22 04:20:13 +08:00
|
|
|
|
|
2007-05-02 05:00:52 +08:00
|
|
|
|
FUNC_LEAVE_NOAPI(4)
|
2003-01-22 04:20:13 +08:00
|
|
|
|
} /* end H5O_bogus_size() */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: H5O_bogus_debug
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Prints debugging info for the message.
|
|
|
|
|
*
|
|
|
|
|
* Return: Non-negative on success/Negative on failure
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Quincey Koziol
|
|
|
|
|
* koziol@ncsa.uiuc.edu
|
|
|
|
|
* Jan 21 2003
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static herr_t
|
2003-02-13 01:04:40 +08:00
|
|
|
|
H5O_bogus_debug(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg, FILE *stream,
|
2003-01-22 04:20:13 +08:00
|
|
|
|
int indent, int fwidth)
|
|
|
|
|
{
|
|
|
|
|
const H5O_bogus_t *mesg = (const H5O_bogus_t *)_mesg;
|
|
|
|
|
|
2007-05-02 05:00:52 +08:00
|
|
|
|
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_bogus_debug)
|
2003-01-22 04:20:13 +08:00
|
|
|
|
|
|
|
|
|
/* check args */
|
2007-05-02 05:00:52 +08:00
|
|
|
|
HDassert(f);
|
|
|
|
|
HDassert(mesg);
|
|
|
|
|
HDassert(stream);
|
|
|
|
|
HDassert(indent >= 0);
|
|
|
|
|
HDassert(fwidth >= 0);
|
2003-01-22 04:20:13 +08:00
|
|
|
|
|
2007-05-02 05:00:52 +08:00
|
|
|
|
HDfprintf(stream, "%*s%-*s `%u'\n", indent, "", fwidth,
|
2003-01-22 04:20:13 +08:00
|
|
|
|
"Bogus Value:", mesg->u);
|
|
|
|
|
|
2007-05-02 05:00:52 +08:00
|
|
|
|
FUNC_LEAVE_NOAPI(SUCCEED)
|
|
|
|
|
} /* end H5O_bogus_debug() */
|
2003-01-22 04:20:13 +08:00
|
|
|
|
#endif /* H5O_ENABLE_BOGUS */
|
|
|
|
|
|