示例#1
0
/*--------------------------------------------------------------------------
 NAME
    H5G_user_path_test
 PURPOSE
    Retrieve the user path for an ID
 USAGE
    herr_t H5G_user_path_test(obj_id, user_path, user_path_len)
        hid_t obj_id;           IN: ID to check
        char *user_path;        OUT: Pointer to buffer for User path
        size_t *user_path_len;  OUT: Size of user path
        unsigned *obj_hidden;   OUT: Whether object is hidden
 RETURNS
    Non-negative on success, negative on failure
 DESCRIPTION
    Retrieves the user path for an ID.  A zero for the length is returned in
    the case of no user path.
 GLOBAL VARIABLES
 COMMENTS, BUGS, ASSUMPTIONS
    DO NOT USE THIS FUNCTION FOR ANYTHING EXCEPT TESTING
 EXAMPLES
 REVISION LOG
--------------------------------------------------------------------------*/
herr_t
H5G_user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsigned *obj_hidden)
{
    void *obj_ptr;              /* Pointer to object for ID */
    H5G_entry_t *obj_ent;       /* Pointer to symbol table entry for obj */
    herr_t ret_value = SUCCEED; /* Return value */

    FUNC_ENTER_NOAPI(H5G_user_path_test, FAIL)

    /* Sanity check */
    HDassert(user_path_len);
    HDassert(obj_hidden);

    /* Get pointer to object for ID */
    if(NULL == (obj_ptr = H5I_object(obj_id)))
         HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get object for ID")

    /* Get the symbol table entry */
    switch(H5I_get_type(obj_id)) {
        case H5I_GROUP:
            obj_ent = H5G_entof((H5G_t *)obj_ptr);
            break;

        case H5I_DATASET:
            obj_ent = H5D_entof((H5D_t *)obj_ptr);
            break;

        case H5I_DATATYPE:
            /* Avoid non-named datatypes */
            if(!H5T_is_named((H5T_t *)obj_ptr))
                HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a named datatype")

            obj_ent = H5T_entof((H5T_t *)obj_ptr);
            break;

        default:
            HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown data object type")
    } /* end switch */
    HDassert(obj_ent);

    /* Retrieve a copy of the user path and put it into the buffer */
    if(obj_ent->user_path_r) {
        size_t len = H5RS_len(obj_ent->user_path_r);

        /* Set the user path, if given */
        if(user_path)
            HDstrcpy(user_path, H5RS_get_str(obj_ent->user_path_r));

        /* Set the length of the path */
        *user_path_len = len;

        /* Set the user path hidden flag */
        *obj_hidden = obj_ent->obj_hidden;
    } /* end if */
    else {
        *user_path_len = 0;
        *obj_hidden = 0;
    } /* end else */

done:
    FUNC_LEAVE_NOAPI(ret_value)
}   /* H5G_user_path_test() */
示例#2
0
/*-------------------------------------------------------------------------
 * Function:	H5F_debug
 *
 * Purpose:	Prints a file header to the specified stream.  Each line
 *		is indented and the field name occupies the specified width
 *		number of characters.
 *
 * Errors:
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Robb Matzke
 *		[email protected]
 *		Aug  1 1997
 *
 * Modifications:
 *		Robb Matzke, 1999-07-28
 *		The ADDR argument is passed by value.
 *
 *		Raymond Lu, 2001-10-14
 * 		Changed to the new generic property list.
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5F_debug(H5F_t *f, hid_t dxpl_id, FILE * stream, int indent, int fwidth)
{
    hsize_t userblock_size;
    int     super_vers, freespace_vers, obj_dir_vers, share_head_vers;
    H5P_genplist_t *plist;              /* Property list */
    herr_t      ret_value=SUCCEED;       /* Return value */

    FUNC_ENTER_NOAPI(H5F_debug, FAIL)

    /* check args */
    assert(f);
    assert(stream);
    assert(indent >= 0);
    assert(fwidth >= 0);

    /* Get property list */
    if(NULL == (plist = H5I_object(f->shared->fcpl_id)))
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")

        if(H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size)<0)
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get user block size")
            if(H5P_get(plist, H5F_CRT_SUPER_VERS_NAME, &super_vers)<0)
                HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get super block version")
                if(H5P_get(plist, H5F_CRT_FREESPACE_VERS_NAME, &freespace_vers)<0)
                    HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get super block version")
                    if(H5P_get(plist, H5F_CRT_OBJ_DIR_VERS_NAME, &obj_dir_vers)<0)
                        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object directory version")
                        if(H5P_get(plist, H5F_CRT_SHARE_HEAD_VERS_NAME, &share_head_vers)<0)
                            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get shared-header format version")

                            /* debug */
                            HDfprintf(stream, "%*sFile Super Block...\n", indent, "");

    HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
              "File name:",
              f->name);
    HDfprintf(stream, "%*s%-*s 0x%08x\n", indent, "", fwidth,
              "File access flags",
              (unsigned) (f->shared->flags));
    HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
              "File open reference count:",
              (unsigned) (f->shared->nrefs));
    HDfprintf(stream, "%*s%-*s %a (abs)\n", indent, "", fwidth,
              "Address of super block:", f->shared->super_addr);
    HDfprintf(stream, "%*s%-*s %lu bytes\n", indent, "", fwidth,
              "Size of user block:", (unsigned long) userblock_size);

    HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
              "Super block version number:", (unsigned) super_vers);
    HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
              "Free list version number:", (unsigned) freespace_vers);
    HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
              "Root group symbol table entry version number:", (unsigned) obj_dir_vers);
    HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
              "Shared header version number:", (unsigned) share_head_vers);
    HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth,
              "Size of file offsets (haddr_t type):", (unsigned) f->shared->sizeof_addr);
    HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth,
              "Size of file lengths (hsize_t type):", (unsigned) f->shared->sizeof_size);
    HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
              "Symbol table leaf node 1/2 rank:", f->shared->sym_leaf_k);
    HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
              "Symbol table internal node 1/2 rank:",
              f->shared->btree_k[H5B_SNODE_ID]);
    HDfprintf(stream, "%*s%-*s 0x%08lx\n", indent, "", fwidth,
              "File consistency flags:",
              (unsigned long) (f->shared->consist_flags));
    HDfprintf(stream, "%*s%-*s %a (abs)\n", indent, "", fwidth,
              "Base address:", f->shared->base_addr);
    HDfprintf(stream, "%*s%-*s %a (rel)\n", indent, "", fwidth,
              "Free list address:", f->shared->freespace_addr);

    HDfprintf(stream, "%*s%-*s %a (rel)\n", indent, "", fwidth,
              "Address of driver information block:", f->shared->driver_addr);

    HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
              "Root group symbol table entry:",
              f->shared->root_grp ? "" : "(none)");
    if (f->shared->root_grp) {
        H5G_ent_debug(f, dxpl_id, H5G_entof(f->shared->root_grp), stream,
                      indent+3, MAX(0, fwidth-3), HADDR_UNDEF);
    }

done:
    FUNC_LEAVE_NOAPI(ret_value)
}
示例#3
0
文件: H5I.c 项目: gang-liu/paraview
static herr_t
H5I_debug(H5I_type_t grp)
{
    H5I_id_group_t *grp_ptr;
    H5I_id_info_t *cur;
    H5G_entry_t *ent = NULL;
    int   is, js;
    unsigned int iu;
    herr_t ret_value;  /* Return value */

    FUNC_ENTER_NOAPI(H5I_debug, FAIL);

    fprintf(stderr, "Dumping group %d\n", (int)grp);
    grp_ptr = H5I_id_group_list_g[grp];

    /* Header */
    fprintf(stderr, "   count     = %u\n", grp_ptr->count);
    fprintf(stderr, "   reserved  = %u\n", grp_ptr->reserved);
    fprintf(stderr, "   wrapped   = %u\n", grp_ptr->wrapped);
    fprintf(stderr, "   hash_size = %lu\n", (unsigned long)grp_ptr->hash_size);
    fprintf(stderr, "   ids     = %u\n", grp_ptr->ids);
    fprintf(stderr, "   nextid     = %u\n", grp_ptr->nextid);

    /* Cache */
    fprintf(stderr, "   Cache:\n");
    for (is=0; is<ID_CACHE_SIZE; is++) {
        if (H5I_cache_g[is] && H5I_GROUP(H5I_cache_g[is]->id)==grp) {
            fprintf(stderr, "       Entry-%d, ID=%lu\n",
                    is, (unsigned long)(H5I_cache_g[is]->id));
        }
    }

    /* List */
    fprintf(stderr, "   List:\n");
    for (iu=0; iu<grp_ptr->hash_size; iu++) {
        for (js=0, cur=grp_ptr->id_list[iu]; cur; cur=cur->next, js++) {
            fprintf(stderr, "       #%u.%d\n", iu, js);
            fprintf(stderr, "     id = %lu\n", (unsigned long)(cur->id));
            fprintf(stderr, "     count = %u\n", cur->count);
            fprintf(stderr, "     obj   = 0x%08lx\n", (unsigned long)(cur->obj_ptr));

            /* Get the symbol table entry, so we get get the name */
            switch(grp) {
                case H5I_GROUP:
                    ent = H5G_entof((H5G_t*)cur->obj_ptr);
                    break;
                case H5I_DATASET:
                    ent = H5D_entof((H5D_t*)cur->obj_ptr);
                    break;
                case H5I_DATATYPE:
                    ent = H5T_entof((H5T_t*)cur->obj_ptr);
                    break;
                default:
                    continue;   /* Other types of IDs are not stored in files */
            } /* end switch*/

            if(ent) {
                if(ent->name)
                    fprintf(stderr, "                name = %s\n",ent->name);
                if(ent->old_name)
                    fprintf(stderr, "                old_name = %s\n",ent->old_name);
            } /* end if */
        } /* end for */
    } /* end for */

done:
    FUNC_LEAVE_NOAPI(SUCCEED);
}