File: hrepack_vg.c

package info (click to toggle)
libhdf4 4.2.10-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 25,488 kB
  • ctags: 12,954
  • sloc: ansic: 146,962; sh: 14,905; fortran: 12,480; makefile: 922; yacc: 680; pascal: 418; lex: 170; csh: 41
file content (76 lines) | stat: -rw-r--r-- 2,639 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF.  The full HDF 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      *
 * http://hdfgroup.org/products/hdf4/doc/Copyright.html.  If you do not have *
 * access to either file, you may request a copy from help@hdfgroup.org.     *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */


#include <assert.h>
#include "hdf.h"
#include "mfhdf.h"

#include "hrepack_vg.h"
#include "hrepack_utils.h"
#include "hrepack_an.h"


/*-------------------------------------------------------------------------
 * Function: copy_vgroup_attrs
 *
 * Purpose: copy VG attributes
 *
 * Return: FAIL, SUCCEED
 *
 *-------------------------------------------------------------------------
 */

int copy_vgroup_attrs(int32 vg_in, int32 vg_out, char *path,options_t *options) 
{
    int    n_attrs;
    int32  data_type, size,  n_values;
    char   attr_name[H4_MAX_NC_NAME];
    int    i;
    char   *buf=NULL;
    
    if ( options->trip==0 ) 
    {
        return 1;
    }
    
    /* Get the number of attributes attached to this vgroup.  */
    if((n_attrs = Vnattrs2 (vg_in))==FAIL) {
        printf( "Failed to get attributes for <%s>\n", path);
        return-1;
    }
    
    for (i = 0; i < n_attrs; i++) 
    {
        if((Vattrinfo2(vg_in, i, attr_name, &data_type, &n_values, &size, NULL, NULL))==FAIL) {
            printf( "Failed to get attribute %d of <%s>\n", i, path);
            continue;
        }
        if ((buf = (char *)malloc( (size_t) (size * n_values) ))==NULL ) {
            printf( "Failed to get memory for attribute %d of <%s>\n", i, path);
            continue;
        }
        if((Vgetattr2 (vg_in, i, buf))==FAIL){
            printf( "Failed to get attribute %d of <%s>\n", i, path);
            if (buf) free(buf);
            continue;
        }
        if((Vsetattr(vg_out, attr_name, data_type, n_values, buf))==FAIL){
            printf( "Failed to set attribute %d of <%s>\n", i, path);
        }
        if (buf) free(buf);
    }
    return 1;
}