blob: d012d1b3f2dede82422825cf79d60d8c20a12b0d (
plain)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/* -*- c-file-style: "stroustrup" -*- */
#include "hdf5.h"
#include <stdio.h>
#include <stdlib.h>
int
main(void)
{
int ret_val = EXIT_SUCCESS;
//! <!-- [create] -->
{
__label__ fail_set;
// enable ONLY filter plugins
if (H5PLset_loading_state(H5PL_FILTER_PLUGIN) < 0) {
ret_val = EXIT_FAILURE;
goto fail_set;
}
// ensure that "/tmp" is at the front of the search path list
if (H5PLprepend("/tmp") < 0) {
ret_val = EXIT_FAILURE;
}
fail_set:;
}
//! <!-- [create] -->
//! <!-- [read] -->
{
__label__ fail_read;
unsigned size, mask;
char buf[255];
// retrieve the number of entries in the plugin path list
if (H5PLsize(&size) < 0) {
ret_val = EXIT_FAILURE;
goto fail_read;
}
printf("Number of stored plugin paths: %d\n", size);
// check the plugin state mask
if (H5PLget_loading_state(&mask) < 0) {
ret_val = EXIT_FAILURE;
goto fail_read;
}
printf("Filter plugins %s be loaded.\n", (mask & H5PL_FILTER_PLUGIN) == 1 ? "can" : "can't");
printf("VOL plugins %s be loaded.\n", (mask & H5PL_VOL_PLUGIN) == 2 ? "can" : "can't");
// print the paths in the plugin path list
for (unsigned i = 0; i < size; ++i) {
if (H5PLget(i, buf, 255) < 0) {
ret_val = EXIT_FAILURE;
break;
}
printf("%s\n", buf);
}
fail_read:;
}
//! <!-- [read] -->
//! <!-- [update] -->
{
// replace "/tmp" with something more sensible
if (H5PLreplace("/foo/bar", 0) < 0) {
ret_val = EXIT_FAILURE;
}
}
//! <!-- [update] -->
//! <!-- [delete] -->
{
__label__ fail_delete;
unsigned size;
if (H5PLsize(&size) < 0) {
ret_val = EXIT_FAILURE;
goto fail_delete;
}
// clean out the list of plugin paths
for (int i = size - 1; i >= 0; --i) {
if (H5PLremove(i) < 0) {
ret_val = EXIT_FAILURE;
break;
}
}
fail_delete:;
}
//! <!-- [delete] -->
return ret_val;
}
|