1
2 #include "cs_config.h"
3
4 #include <stdio.h>
5 #include <string.h>
6
7 #include "util/neo_misc.h"
8 #include "util/neo_hdf.h"
9
main(void)10 int main(void) {
11 HDF *hdf_1, *hdf_2;
12 HDF *cur_node,*last_node;
13
14 hdf_init(&hdf_1);
15
16 hdf_read_file(hdf_1,"hdf_copy_test.hdf");
17 hdf_dump(hdf_1,NULL);
18
19 cur_node = hdf_get_obj(hdf_1,"Chart");
20 last_node = cur_node;
21
22 cur_node = hdf_get_obj(cur_node,"next_stage");
23 while (hdf_get_obj(cur_node,"next_stage") && strcmp(hdf_get_value(cur_node,"Bucket.FieldId",""),"QUEUE")) {
24 last_node = cur_node;
25 cur_node = hdf_get_obj(cur_node,"next_stage");
26 }
27
28 if (hdf_get_obj(cur_node,"next_stage")) {
29 hdf_copy(hdf_1,"TempHolderPlace",hdf_get_obj(cur_node,"next_stage"));
30 }
31 ne_warn("Delete tree from node: %s", hdf_obj_name(last_node));
32 hdf_remove_tree(last_node,"next_stage");
33
34 hdf_dump(hdf_1,NULL);
35 fprintf(stderr,"-----------------\n");
36
37
38 hdf_copy(last_node,"next_stage",hdf_get_obj(hdf_1,"TempHolderPlace"));
39 hdf_dump(hdf_1,NULL);
40
41 /* Test copy and destroy, make sure we actually copy everything and
42 * don't reference anything */
43 hdf_init(&hdf_2);
44 hdf_copy(hdf_2, "", hdf_1);
45 hdf_destroy(&hdf_1);
46 hdf_dump(hdf_2, NULL);
47 hdf_destroy(&hdf_2);
48
49 return 0;
50 }
51