From f38d9a2149d189fa82b5b5d491f7ed10feffc900 Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Tue, 5 Jun 2012 10:13:32 -0500 Subject: [svn-r22436] add a public routine to get the name of the VOL plugin associated with a File or object --- src/H5VL.c | 30 ++++++++++++++++++++++++++++++ src/H5VLint.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/H5VLprivate.h | 2 +- src/H5VLpublic.h | 1 + 4 files changed, 73 insertions(+), 1 deletion(-) diff --git a/src/H5VL.c b/src/H5VL.c index 686fb81..f4412d2 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -265,3 +265,33 @@ H5VLunregister(hid_t vol_id) done: FUNC_LEAVE_API(ret_value) } /* end H5VLunregister() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLget_plugin_name + * + * Purpose: Returns the plugin name for the VOL associated with the + * object or file ID + * + * Return: Success: The length of the plugin name + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * June, 2012 + * + *------------------------------------------------------------------------- + */ +ssize_t +H5VLget_plugin_name(hid_t id, char *name/*out*/, size_t size) +{ + ssize_t ret_value; + + FUNC_ENTER_API(FAIL) + H5TRACE3("i", "*x", id, name, size); + + if((ret_value = H5VL_get_plugin_name(id, name, size)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "Can't get plugin name") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLget_plugin_name() */ diff --git a/src/H5VLint.c b/src/H5VLint.c index f70e090..00e64c8 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -260,6 +260,47 @@ done: /*------------------------------------------------------------------------- + * Function: H5VL_get_plugin_name + * + * Purpose: Private version of H5VLget_plugin_name + * + * Return: Success: The length of the plugin name + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * June, 2012 + * + *------------------------------------------------------------------------- + */ +ssize_t +H5VL_get_plugin_name(hid_t id, char *name/*out*/, size_t size) +{ + H5VL_class_t *vol_plugin; /* VOL structure attached to id */ + size_t len; + ssize_t ret_value; + + FUNC_ENTER_NOAPI(FAIL) + + if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux (id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Object/File does not contain VOL information") + + len = HDstrlen(vol_plugin->name); + + if(name) { + HDstrncpy(name, vol_plugin->name, MIN(len + 1,size)); + if(len >= size) + name[size-1]='\0'; + } /* end if */ + + /* Set the return value for the API call */ + ret_value = (ssize_t)len; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_get_plugin_name() */ + + +/*------------------------------------------------------------------------- * Function: H5VL_attr_create * * Purpose: Creates an attribute through the VOL diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index 5784926..01754ca 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -45,8 +45,8 @@ struct H5F_t; H5_DLL int H5VL_term_interface(void); H5_DLL H5VL_class_t *H5VL_get_class(hid_t id); -//H5_DLL hsize_t H5VL_sb_size(H5F_t *file); H5_DLL hid_t H5VL_register(const void *cls, size_t size, hbool_t app_ref); +H5_DLL ssize_t H5VL_get_plugin_name(hid_t id, char *name/*out*/, size_t size); H5_DLL herr_t H5VL_close(H5VL_class_t *vol_plugin); H5_DLL hid_t H5VL_attr_create(hid_t loc_id, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t req); diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index fbcb0b5..d0ee1aa 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -258,6 +258,7 @@ extern "C" { /* Function prototypes */ H5_DLL hid_t H5VLregister(const H5VL_class_t *cls); H5_DLL herr_t H5VLunregister(hid_t driver_id); +H5_DLL ssize_t H5VLget_plugin_name(hid_t id, char *name/*out*/, size_t size); #ifdef __cplusplus } -- cgit v0.12