Ejemplo n.º 1
0
/*-------------------------------------------------------------------------
 * Function:	H5G__link_iterate_table
 *
 * Purpose:     Iterate over table containing a list of links for a group,
 *              making appropriate callbacks
 *
 * Return:	Success:        Non-negative
 *		Failure:	Negative
 *
 * Programmer:	Quincey Koziol
 *	        Nov 20, 2006
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5G__link_iterate_table(const H5G_link_table_t *ltable, hsize_t skip,
    hsize_t *last_lnk, const H5G_lib_iterate_t op, void *op_data)
{
    size_t u;                           /* Local index variable */
    herr_t ret_value = H5_ITER_CONT;   /* Return value */

    FUNC_ENTER_PACKAGE_NOERR

    /* Sanity check */
    HDassert(ltable);
    HDassert(op);

    /* Skip over links, if requested */
    if(last_lnk)
        *last_lnk += skip;

    /* Iterate over link messages */
    H5_ASSIGN_OVERFLOW(/* To: */ u, /* From: */ skip, /* From: */ hsize_t, /* To: */ size_t)
    for(; u < ltable->nlinks && !ret_value; u++) {
        /* Make the callback */
        ret_value = (op)(&(ltable->lnks[u]), op_data);

        /* Increment the number of entries passed through */
        if(last_lnk)
            (*last_lnk)++;
    } /* end for */

    /* Check for callback failure and pass along return value */
    if(ret_value < 0)
        HERROR(H5E_SYM, H5E_CANTNEXT, "iteration operator failed");

    FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G__link_iterate_table() */
Ejemplo n.º 2
0
/*-------------------------------------------------------------------------
 * Function:	H5D__single_idx_iterate
 *
 * Purpose:	Make callback for the single chunk
 *
 * Return:	Non-negative on success/Negative on failure
 *
 * Programmer:	Vailin Choi; July 2010
 *
 *-------------------------------------------------------------------------
 */
static int
H5D__single_idx_iterate(const H5D_chk_idx_info_t *idx_info,
    H5D_chunk_cb_func_t chunk_cb, void *chunk_udata)
{
    H5D_chunk_rec_t chunk_rec;		/* generic chunk record  */
    int ret_value = -1;    		/* Return value */

    FUNC_ENTER_STATIC_NOERR

    /* Sanity checks */
    HDassert(idx_info);
    HDassert(idx_info->f);
    HDassert(idx_info->pline);
    HDassert(idx_info->layout);
    HDassert(idx_info->storage);
    HDassert(chunk_cb);
    HDassert(chunk_udata);
    HDassert(H5F_addr_defined(idx_info->storage->idx_addr));

    /* Initialize generic chunk record */
    HDmemset(&chunk_rec, 0, sizeof(chunk_rec));
    chunk_rec.chunk_addr = idx_info->storage->idx_addr;

    if(idx_info->layout->flags & H5O_LAYOUT_CHUNK_SINGLE_INDEX_WITH_FILTER) {
	chunk_rec.nbytes = idx_info->storage->u.single.nbytes;
	chunk_rec.filter_mask = idx_info->storage->u.single.filter_mask;
    } /* end if */
    else {
	chunk_rec.nbytes = idx_info->layout->size;
	chunk_rec.filter_mask = 0;
    } /* end else */

    /* Make "generic chunk" callback */
    if((ret_value = (*chunk_cb)(&chunk_rec, chunk_udata)) < 0)
	HERROR(H5E_DATASET, H5E_CALLBACK, "failure in generic chunk iterator callback");

    FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D__single_idx_iterate() */
Ejemplo n.º 3
0
int32
vimakecompat(HFILEID f)
{
    VGROUP     *vg;
    VDATA      *vs;
    uint8      *buf = NULL;     /* to store an old vdata or vgroup descriptor  */
    int32       old_bsize = 0, bsize=0;
    int32       aid;
    int32       ret;
    uintn       u;
    uint16      tag=DFTAG_NULL, ref=DFTAG_NULL;
    CONSTR(FUNC, "vimakecompat");

    /* =============================================  */
    /* --- read all vgs and convert each --- */

    /* allocate space for vg */
    if (NULL == (vg =VIget_vgroup_node()))
        HRETURN_ERROR(DFE_NOSPACE, 0);
    ret = aid = Hstartread(f, (uint16) OLD_VGDESCTAG, DFREF_WILDCARD);
    while (ret != FAIL)
      {
          HQuerytagref(aid, &tag, &ref);
          HQuerylength(aid, &bsize);
          if (buf == NULL || bsize > old_bsize)
            {
                if (buf != NULL)
                    HDfree((VOIDP) buf);
                if ((buf = (uint8 *) HDmalloc(bsize)) == NULL)
                    HRETURN_ERROR(DFE_NOSPACE, 0);
                old_bsize = bsize;
            }   /* end if */
          ret = Hgetelement(f, (uint16) OLD_VGDESCTAG, ref, (uint8 *) buf);
          if (ret == FAIL)
            {
                HDfree((VOIDP) buf);
                HRETURN_ERROR(DFE_READERROR, 0)
            }   /* end if */

          oldunpackvg(vg, buf, &bsize);
          /* add new items */
          vg->vgclass = NULL;
          /* vg->vgclass[0] = '\0'; */ 
          vg->extag = 0;
          vg->exref = 0;
          vg->version = 2;  /* version 2 */
          vg->more = 0;
          /* inside each vgroup, change the old tags to new */
          for (u = 0; u < (uintn)vg->nvelt; u++)
              if (vg->tag[u] == OLD_VGDESCTAG)
                  vg->tag[u] = NEW_VGDESCTAG;
              else if (vg->tag[u] == OLD_VSDESCTAG)
                  vg->tag[u] = NEW_VSDESCTAG;
              else  /* BAD */
                  HERROR(DFE_NOTINSET);
          vpackvg(vg, buf, &bsize);

          ret = Hputelement(f, VGDESCTAG, ref, (uint8 *) buf, bsize);
          HDfree((VOIDP) buf);
          if (ret == FAIL)
              HRETURN_ERROR(DFE_WRITEERROR, 0);

          ret = Hnextread(aid, (uint16) OLD_VGDESCTAG, DFREF_WILDCARD, DF_CURRENT);
      }     /* while */