/src/hdf5/src/H5VLpassthru_int.c
Line | Count | Source |
1 | | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2 | | * Copyright by The HDF Group. * |
3 | | * All rights reserved. * |
4 | | * * |
5 | | * This file is part of HDF5. The full HDF5 copyright notice, including * |
6 | | * terms governing use, modification, and redistribution, is contained in * |
7 | | * the LICENSE file, which can be found at the root of the source code * |
8 | | * distribution tree, or in https://www.hdfgroup.org/licenses. * |
9 | | * If you do not have access to either file, you may request a copy from * |
10 | | * help@hdfgroup.org. * |
11 | | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
12 | | |
13 | | /* |
14 | | * Purpose: Private routines for the internal passthru VOL connector. |
15 | | * |
16 | | * Necessary for using internal library routines, which are |
17 | | * disallowed within the actual passthru VOL connector code. |
18 | | * |
19 | | */ |
20 | | |
21 | | /****************/ |
22 | | /* Module Setup */ |
23 | | /****************/ |
24 | | |
25 | | #define H5VL_FRIEND /* Suppress error about including H5VLpkg */ |
26 | | |
27 | | /***********/ |
28 | | /* Headers */ |
29 | | /***********/ |
30 | | |
31 | | #include "H5private.h" /* Generic Functions */ |
32 | | #include "H5Eprivate.h" /* Error handling */ |
33 | | #include "H5Iprivate.h" /* IDs */ |
34 | | #include "H5Pprivate.h" /* Property lists */ |
35 | | #include "H5VLpkg.h" /* Virtual Object Layer */ |
36 | | |
37 | | #include "H5VLpassthru_private.h" /* Passthru VOL connector */ |
38 | | |
39 | | /* The native passthru VOL connector */ |
40 | | hid_t H5VL_PASSTHRU_g = H5I_INVALID_HID; |
41 | | H5VL_connector_t *H5VL_PASSTHRU_conn_g = NULL; |
42 | | |
43 | | /*------------------------------------------------------------------------- |
44 | | * Function: H5VL__passthru_register |
45 | | * |
46 | | * Purpose: Register the passthru VOL connector and set up an ID for it. |
47 | | * |
48 | | * Return: SUCCEED/FAIL |
49 | | * |
50 | | *------------------------------------------------------------------------- |
51 | | */ |
52 | | herr_t |
53 | | H5VL__passthru_register(void) |
54 | 2 | { |
55 | 2 | herr_t ret_value = SUCCEED; /* Return value */ |
56 | | |
57 | 2 | FUNC_ENTER_PACKAGE |
58 | | |
59 | | /* Register the passthru VOL connector, if it isn't already */ |
60 | 2 | if (NULL == H5VL_PASSTHRU_conn_g) |
61 | 2 | if (NULL == (H5VL_PASSTHRU_conn_g = |
62 | 2 | H5VL__register_connector(&H5VL_pass_through_g, H5P_VOL_INITIALIZE_DEFAULT))) |
63 | 0 | HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, "can't register passthru VOL connector"); |
64 | | |
65 | | /* Get ID for connector */ |
66 | 2 | if (H5I_VOL != H5I_get_type(H5VL_PASSTHRU_g)) { |
67 | 2 | if ((H5VL_PASSTHRU_g = H5I_register(H5I_VOL, H5VL_PASSTHRU_conn_g, false)) < 0) |
68 | 0 | HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, "can't create ID for passthru VOL connector"); |
69 | | |
70 | | /* ID is holding a reference to the connector */ |
71 | 2 | H5VL_conn_inc_rc(H5VL_PASSTHRU_conn_g); |
72 | 2 | } |
73 | | |
74 | 2 | done: |
75 | 2 | FUNC_LEAVE_NOAPI(ret_value) |
76 | 2 | } /* end H5VL__passthru_register() */ |
77 | | |
78 | | /*--------------------------------------------------------------------------- |
79 | | * Function: H5VL__passthru_unregister |
80 | | * |
81 | | * Purpose: Shut down the passthru VOL |
82 | | * |
83 | | * Returns: SUCCEED (Can't fail) |
84 | | * |
85 | | *--------------------------------------------------------------------------- |
86 | | */ |
87 | | herr_t |
88 | | H5VL__passthru_unregister(void) |
89 | 2 | { |
90 | 2 | FUNC_ENTER_PACKAGE_NOERR |
91 | | |
92 | | /* Reset VOL connector info */ |
93 | 2 | H5VL_PASSTHRU_g = H5I_INVALID_HID; |
94 | 2 | H5VL_PASSTHRU_conn_g = NULL; |
95 | | |
96 | 2 | FUNC_LEAVE_NOAPI(SUCCEED) |
97 | 2 | } /* end H5VL__passthru_unregister() */ |