summaryrefslogtreecommitdiffstats
path: root/src/H5O.c
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2004-07-14 21:45:23 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2004-07-14 21:45:23 (GMT)
commitfbc2aaadafb3dfb23842ee4c89bad4bfdb6d3077 (patch)
tree6c92298234945fc1c59f9b46e0e399a5e26690bc /src/H5O.c
parent9b2aafa18b550a34b39acd78d32e04af49c3cbbb (diff)
downloadhdf5-fbc2aaadafb3dfb23842ee4c89bad4bfdb6d3077.zip
hdf5-fbc2aaadafb3dfb23842ee4c89bad4bfdb6d3077.tar.gz
hdf5-fbc2aaadafb3dfb23842ee4c89bad4bfdb6d3077.tar.bz2
[svn-r8879]
Purpose: New feature Description: New API H5Tencode and H5Tdecode. Given object ID, H5Tencode encodes object information into a binary form. H5Tdecode decode an object information in a binary form, reconstructs the object and return a new object ID. Solution: Use object header functions H5O_dtype_decode and H5O_dtype_encode to facilitate them. The encoded binary is exactly like object header information. This is the first step checkin. Will check in H5Sencode and H5Sdecode later. Platforms tested: h5committed and fuss. Misc. update: will update release.txt after 2nd step checkin.
Diffstat (limited to 'src/H5O.c')
-rw-r--r--src/H5O.c97
1 files changed, 97 insertions, 0 deletions
diff --git a/src/H5O.c b/src/H5O.c
index 0ee7706..609b7c6 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -3427,6 +3427,103 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5O_encode
+ *
+ * Purpose: Encode an object(data type and simple data space only)
+ * description into a buffer.
+ *
+ * Return: Success: Non-negative
+ *
+ * Failure: Negative
+ *
+ * Programmer: Raymond Lu
+ * slu@ncsa.uiuc.edu
+ * July 13, 2004
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_encode(unsigned char *buf, void *obj, size_t *nalloc, hid_t type_id)
+{
+ const H5O_class_t *type; /* Actual H5O class type for the ID */
+ size_t size; /* size of the message*/
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5O_encode,FAIL);
+
+ /* check args */
+ if(type_id<0 || type_id>=(hid_t)(sizeof(message_type_g)/sizeof(message_type_g[0])))
+ HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, "invalid object type");
+
+ /* map the type ID to the actual type object */
+ if((type=message_type_g[type_id])==NULL)
+ HGOTO_ERROR (H5E_OHDR, H5E_BADTYPE, FAIL, "unable to find object type");
+
+ /* check buffer size */
+ if ((size=(type->raw_size)(NULL, obj))<0)
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode message");
+
+ /* Don't encode if buffer size isn't big enough */
+ if(!buf || *nalloc<size) {
+ *nalloc = size;
+ HGOTO_DONE(ret_value);
+ }
+
+ /* Encode */
+ if ((type->encode)(NULL, buf, obj)<0)
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode message");
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_decode
+ *
+ * Purpose: Decode a binary object(data type and data space only)
+ * description and return a new object handle.
+ *
+ * Return: Success: Object ID(non-negative)
+ *
+ * Failure: Negative
+ *
+ * Programmer: Raymond Lu
+ * slu@ncsa.uiuc.edu
+ * July 14, 2004
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+void*
+H5O_decode(unsigned char *buf, hid_t type_id)
+{
+ const H5O_class_t *type; /* Actual H5O class type for the ID */
+ size_t size; /* size of the message*/
+ void *ret_value=NULL; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5O_decode,NULL);
+
+ /* check args */
+ if(type_id<0 || type_id>=(hid_t)(sizeof(message_type_g)/sizeof(message_type_g[0])))
+ HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, NULL, "invalid object type");
+
+ /* map the type ID to the actual type object */
+ if((type=message_type_g[type_id])==NULL)
+ HGOTO_ERROR (H5E_OHDR, H5E_BADTYPE, NULL, "unable to find object type");
+
+ /* decode */
+ ret_value = (type->decode)(NULL, 0, buf, NULL);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
* Function: H5O_debug_id
*
* Purpose: Act as a proxy for calling the 'debug' method for a