-
Notifications
You must be signed in to change notification settings - Fork 0
/
H5VLpassthru_ext.c
3136 lines (2584 loc) · 110 KB
/
H5VLpassthru_ext.c
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* [email protected]. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Purpose: This is a "pass through" VOL connector, which forwards each
* VOL callback to an underlying connector.
*
* It is designed as an example VOL connector for developers to
* use when creating new connectors, especially connectors that
* are outside of the HDF5 library. As such, it should _NOT_
* include _any_ private HDF5 header files. This connector should
* therefore only make public HDF5 API calls and use standard C /
* POSIX calls.
*
* Note that the HDF5 error stack must be preserved on code paths
* that could be invoked when the underlying VOL connector's
* callback can fail.
*
*/
/* Header files needed */
/* Do NOT include private HDF5 files here! */
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* Public HDF5 file */
#include "hdf5.h"
/* This connector's header */
#include "H5VLpassthru_ext.h"
/**********/
/* Macros */
/**********/
/* Whether to display log messge when callback is invoked */
/* (Uncomment to enable) */
/* #define ENABLE_EXT_PASSTHRU_LOGGING */
/* Hack for missing va_copy() in old Visual Studio editions
* (from H5win2_defs.h - used on VS2012 and earlier)
*/
#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1800)
#define va_copy(D,S) ((D) = (S))
#endif
/************/
/* Typedefs */
/************/
/* The pass through VOL info object */
typedef struct H5VL_pass_through_ext_t {
hid_t under_vol_id; /* ID for underlying VOL connector */
void *under_object; /* Info object for underlying VOL connector */
} H5VL_pass_through_ext_t;
/* The pass through VOL wrapper context */
typedef struct H5VL_pass_through_ext_wrap_ctx_t {
hid_t under_vol_id; /* VOL ID for under VOL */
void *under_wrap_ctx; /* Object wrapping context for under VOL */
} H5VL_pass_through_ext_wrap_ctx_t;
/********************* */
/* Function prototypes */
/********************* */
/* Helper routines */
static herr_t H5VL_pass_through_ext_file_specific_reissue(void *obj, hid_t connector_id,
H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, ...);
static herr_t H5VL_pass_through_ext_request_specific_reissue(void *obj, hid_t connector_id,
H5VL_request_specific_t specific_type, ...);
static herr_t H5VL_pass_through_ext_link_create_reissue(H5VL_link_create_type_t create_type,
void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id,
hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, ...);
static H5VL_pass_through_ext_t *H5VL_pass_through_ext_new_obj(void *under_obj,
hid_t under_vol_id);
static herr_t H5VL_pass_through_ext_free_obj(H5VL_pass_through_ext_t *obj);
/* "Management" callbacks */
static herr_t H5VL_pass_through_ext_init(hid_t vipl_id);
static herr_t H5VL_pass_through_ext_term(void);
/* VOL info callbacks */
static void *H5VL_pass_through_ext_info_copy(const void *info);
static herr_t H5VL_pass_through_ext_info_cmp(int *cmp_value, const void *info1, const void *info2);
static herr_t H5VL_pass_through_ext_info_free(void *info);
static herr_t H5VL_pass_through_ext_info_to_str(const void *info, char **str);
static herr_t H5VL_pass_through_ext_str_to_info(const char *str, void **info);
/* VOL object wrap / retrieval callbacks */
static void *H5VL_pass_through_ext_get_object(const void *obj);
static herr_t H5VL_pass_through_ext_get_wrap_ctx(const void *obj, void **wrap_ctx);
static void *H5VL_pass_through_ext_wrap_object(void *obj, H5I_type_t obj_type,
void *wrap_ctx);
static void *H5VL_pass_through_ext_unwrap_object(void *obj);
static herr_t H5VL_pass_through_ext_free_wrap_ctx(void *obj);
/* Attribute callbacks */
static void *H5VL_pass_through_ext_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req);
static void *H5VL_pass_through_ext_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t aapl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_pass_through_ext_attr_read(void *attr, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req);
static herr_t H5VL_pass_through_ext_attr_write(void *attr, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req);
static herr_t H5VL_pass_through_ext_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_pass_through_ext_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_pass_through_ext_attr_optional(void *obj, H5VL_attr_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_pass_through_ext_attr_close(void *attr, hid_t dxpl_id, void **req);
/* Dataset callbacks */
static void *H5VL_pass_through_ext_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req);
static void *H5VL_pass_through_ext_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_pass_through_ext_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id,
hid_t file_space_id, hid_t plist_id, void *buf, void **req);
static herr_t H5VL_pass_through_ext_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req);
static herr_t H5VL_pass_through_ext_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_pass_through_ext_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_pass_through_ext_dataset_optional(void *obj, H5VL_dataset_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_pass_through_ext_dataset_close(void *dset, hid_t dxpl_id, void **req);
/* Datatype callbacks */
static void *H5VL_pass_through_ext_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req);
static void *H5VL_pass_through_ext_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_pass_through_ext_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_pass_through_ext_datatype_specific(void *obj, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_pass_through_ext_datatype_optional(void *obj, H5VL_datatype_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_pass_through_ext_datatype_close(void *dt, hid_t dxpl_id, void **req);
/* File callbacks */
static void *H5VL_pass_through_ext_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req);
static void *H5VL_pass_through_ext_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_pass_through_ext_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_pass_through_ext_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_pass_through_ext_file_optional(void *file, H5VL_file_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_pass_through_ext_file_close(void *file, hid_t dxpl_id, void **req);
/* Group callbacks */
static void *H5VL_pass_through_ext_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req);
static void *H5VL_pass_through_ext_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_pass_through_ext_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_pass_through_ext_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_pass_through_ext_group_optional(void *obj, H5VL_group_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_pass_through_ext_group_close(void *grp, hid_t dxpl_id, void **req);
/* Link callbacks */
static herr_t H5VL_pass_through_ext_link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_pass_through_ext_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_pass_through_ext_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_pass_through_ext_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_pass_through_ext_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_pass_through_ext_link_optional(void *obj, H5VL_link_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments);
/* Object callbacks */
static void *H5VL_pass_through_ext_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req);
static herr_t H5VL_pass_through_ext_object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, const char *src_name, void *dst_obj, const H5VL_loc_params_t *dst_loc_params, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req);
static herr_t H5VL_pass_through_ext_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_pass_through_ext_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
static herr_t H5VL_pass_through_ext_object_optional(void *obj, H5VL_object_optional_t opt_type, hid_t dxpl_id, void **req, va_list arguments);
/* Container/connector introspection callbacks */
static herr_t H5VL_pass_through_ext_introspect_get_conn_cls(void *obj, H5VL_get_conn_lvl_t lvl, const H5VL_class_t **conn_cls);
static herr_t H5VL_pass_through_ext_introspect_opt_query(void *obj, H5VL_subclass_t cls, int opt_type, hbool_t *supported);
/* Async request callbacks */
static herr_t H5VL_pass_through_ext_request_wait(void *req, uint64_t timeout, H5ES_status_t *status);
static herr_t H5VL_pass_through_ext_request_notify(void *obj, H5VL_request_notify_t cb, void *ctx);
static herr_t H5VL_pass_through_ext_request_cancel(void *req);
static herr_t H5VL_pass_through_ext_request_specific(void *req, H5VL_request_specific_t specific_type, va_list arguments);
static herr_t H5VL_pass_through_ext_request_optional(void *req, H5VL_request_optional_t opt_type, va_list arguments);
static herr_t H5VL_pass_through_ext_request_free(void *req);
/* Blob callbacks */
static herr_t H5VL_pass_through_ext_blob_put(void *obj, const void *buf, size_t size, void *blob_id, void *ctx);
static herr_t H5VL_pass_through_ext_blob_get(void *obj, const void *blob_id, void *buf, size_t size, void *ctx);
static herr_t H5VL_pass_through_ext_blob_specific(void *obj, void *blob_id, H5VL_blob_specific_t specific_type, va_list arguments);
static herr_t H5VL_pass_through_ext_blob_optional(void *obj, void *blob_id, H5VL_blob_optional_t opt_type, va_list arguments);
/* Token callbacks */
static herr_t H5VL_pass_through_ext_token_cmp(void *obj, const H5O_token_t *token1, const H5O_token_t *token2, int *cmp_value);
static herr_t H5VL_pass_through_ext_token_to_str(void *obj, H5I_type_t obj_type, const H5O_token_t *token, char **token_str);
static herr_t H5VL_pass_through_ext_token_from_str(void *obj, H5I_type_t obj_type, const char *token_str, H5O_token_t *token);
/* Generic optional callback */
static herr_t H5VL_pass_through_ext_optional(void *obj, int op_type, hid_t dxpl_id, void **req, va_list arguments);
/*******************/
/* Local variables */
/*******************/
/* Pass through VOL connector class struct */
static const H5VL_class_t H5VL_pass_through_ext_g = {
H5VL_PASSTHRU_EXT_VERSION, /* version */
(H5VL_class_value_t)H5VL_PASSTHRU_EXT_VALUE, /* value */
H5VL_PASSTHRU_EXT_NAME, /* name */
0, /* capability flags */
H5VL_pass_through_ext_init, /* initialize */
H5VL_pass_through_ext_term, /* terminate */
{ /* info_cls */
sizeof(H5VL_pass_through_ext_info_t), /* size */
H5VL_pass_through_ext_info_copy, /* copy */
H5VL_pass_through_ext_info_cmp, /* compare */
H5VL_pass_through_ext_info_free, /* free */
H5VL_pass_through_ext_info_to_str, /* to_str */
H5VL_pass_through_ext_str_to_info /* from_str */
},
{ /* wrap_cls */
H5VL_pass_through_ext_get_object, /* get_object */
H5VL_pass_through_ext_get_wrap_ctx, /* get_wrap_ctx */
H5VL_pass_through_ext_wrap_object, /* wrap_object */
H5VL_pass_through_ext_unwrap_object, /* unwrap_object */
H5VL_pass_through_ext_free_wrap_ctx /* free_wrap_ctx */
},
{ /* attribute_cls */
H5VL_pass_through_ext_attr_create, /* create */
H5VL_pass_through_ext_attr_open, /* open */
H5VL_pass_through_ext_attr_read, /* read */
H5VL_pass_through_ext_attr_write, /* write */
H5VL_pass_through_ext_attr_get, /* get */
H5VL_pass_through_ext_attr_specific, /* specific */
H5VL_pass_through_ext_attr_optional, /* optional */
H5VL_pass_through_ext_attr_close /* close */
},
{ /* dataset_cls */
H5VL_pass_through_ext_dataset_create, /* create */
H5VL_pass_through_ext_dataset_open, /* open */
H5VL_pass_through_ext_dataset_read, /* read */
H5VL_pass_through_ext_dataset_write, /* write */
H5VL_pass_through_ext_dataset_get, /* get */
H5VL_pass_through_ext_dataset_specific, /* specific */
H5VL_pass_through_ext_dataset_optional, /* optional */
H5VL_pass_through_ext_dataset_close /* close */
},
{ /* datatype_cls */
H5VL_pass_through_ext_datatype_commit, /* commit */
H5VL_pass_through_ext_datatype_open, /* open */
H5VL_pass_through_ext_datatype_get, /* get_size */
H5VL_pass_through_ext_datatype_specific, /* specific */
H5VL_pass_through_ext_datatype_optional, /* optional */
H5VL_pass_through_ext_datatype_close /* close */
},
{ /* file_cls */
H5VL_pass_through_ext_file_create, /* create */
H5VL_pass_through_ext_file_open, /* open */
H5VL_pass_through_ext_file_get, /* get */
H5VL_pass_through_ext_file_specific, /* specific */
H5VL_pass_through_ext_file_optional, /* optional */
H5VL_pass_through_ext_file_close /* close */
},
{ /* group_cls */
H5VL_pass_through_ext_group_create, /* create */
H5VL_pass_through_ext_group_open, /* open */
H5VL_pass_through_ext_group_get, /* get */
H5VL_pass_through_ext_group_specific, /* specific */
H5VL_pass_through_ext_group_optional, /* optional */
H5VL_pass_through_ext_group_close /* close */
},
{ /* link_cls */
H5VL_pass_through_ext_link_create, /* create */
H5VL_pass_through_ext_link_copy, /* copy */
H5VL_pass_through_ext_link_move, /* move */
H5VL_pass_through_ext_link_get, /* get */
H5VL_pass_through_ext_link_specific, /* specific */
H5VL_pass_through_ext_link_optional /* optional */
},
{ /* object_cls */
H5VL_pass_through_ext_object_open, /* open */
H5VL_pass_through_ext_object_copy, /* copy */
H5VL_pass_through_ext_object_get, /* get */
H5VL_pass_through_ext_object_specific, /* specific */
H5VL_pass_through_ext_object_optional /* optional */
},
{ /* introspect_cls */
H5VL_pass_through_ext_introspect_get_conn_cls, /* get_conn_cls */
H5VL_pass_through_ext_introspect_opt_query, /* opt_query */
},
{ /* request_cls */
H5VL_pass_through_ext_request_wait, /* wait */
H5VL_pass_through_ext_request_notify, /* notify */
H5VL_pass_through_ext_request_cancel, /* cancel */
H5VL_pass_through_ext_request_specific, /* specific */
H5VL_pass_through_ext_request_optional, /* optional */
H5VL_pass_through_ext_request_free /* free */
},
{ /* blob_cls */
H5VL_pass_through_ext_blob_put, /* put */
H5VL_pass_through_ext_blob_get, /* get */
H5VL_pass_through_ext_blob_specific, /* specific */
H5VL_pass_through_ext_blob_optional /* optional */
},
{ /* token_cls */
H5VL_pass_through_ext_token_cmp, /* cmp */
H5VL_pass_through_ext_token_to_str, /* to_str */
H5VL_pass_through_ext_token_from_str /* from_str */
},
H5VL_pass_through_ext_optional /* optional */
};
/* The connector identification number, initialized at runtime */
static hid_t H5VL_PASSTHRU_EXT_g = H5I_INVALID_HID;
H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_VOL;}
const void *H5PLget_plugin_info(void) {return &H5VL_pass_through_ext_g;}
/*-------------------------------------------------------------------------
* Function: H5VL__pass_through_new_obj
*
* Purpose: Create a new pass through object for an underlying object
*
* Return: Success: Pointer to the new pass through object
* Failure: NULL
*
* Programmer: Quincey Koziol
* Monday, December 3, 2018
*
*-------------------------------------------------------------------------
*/
static H5VL_pass_through_ext_t *
H5VL_pass_through_ext_new_obj(void *under_obj, hid_t under_vol_id)
{
H5VL_pass_through_ext_t *new_obj;
new_obj = (H5VL_pass_through_ext_t *)calloc(1, sizeof(H5VL_pass_through_ext_t));
new_obj->under_object = under_obj;
new_obj->under_vol_id = under_vol_id;
H5Iinc_ref(new_obj->under_vol_id);
return new_obj;
} /* end H5VL__pass_through_new_obj() */
/*-------------------------------------------------------------------------
* Function: H5VL__pass_through_free_obj
*
* Purpose: Release a pass through object
*
* Note: Take care to preserve the current HDF5 error stack
* when calling HDF5 API calls.
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Quincey Koziol
* Monday, December 3, 2018
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_pass_through_ext_free_obj(H5VL_pass_through_ext_t *obj)
{
hid_t err_id;
err_id = H5Eget_current_stack();
H5Idec_ref(obj->under_vol_id);
H5Eset_current_stack(err_id);
free(obj);
return 0;
} /* end H5VL__pass_through_free_obj() */
/*-------------------------------------------------------------------------
* Function: H5VL_pass_through_ext_register
*
* Purpose: Register the pass-through VOL connector and retrieve an ID
* for it.
*
* Return: Success: The ID for the pass-through VOL connector
* Failure: -1
*
* Programmer: Quincey Koziol
* Wednesday, November 28, 2018
*
*-------------------------------------------------------------------------
*/
hid_t
H5VL_pass_through_ext_register(void)
{
/* Singleton register the pass-through VOL connector ID */
if(H5VL_PASSTHRU_EXT_g < 0)
H5VL_PASSTHRU_EXT_g = H5VLregister_connector(&H5VL_pass_through_ext_g, H5P_DEFAULT);
return H5VL_PASSTHRU_EXT_g;
} /* end H5VL_pass_through_ext_register() */
/*-------------------------------------------------------------------------
* Function: H5VL_pass_through_ext_init
*
* Purpose: Initialize this VOL connector, performing any necessary
* operations for the connector that will apply to all containers
* accessed with the connector.
*
* Return: Success: 0
* Failure: -1
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_pass_through_ext_init(hid_t vipl_id)
{
#ifdef ENABLE_EXT_PASSTHRU_LOGGING
printf("------- EXT PASS THROUGH VOL INIT\n");
#endif
/* Shut compiler up about unused parameter */
vipl_id = vipl_id;
return 0;
} /* end H5VL_pass_through_ext_init() */
/*---------------------------------------------------------------------------
* Function: H5VL_pass_through_ext_term
*
* Purpose: Terminate this VOL connector, performing any necessary
* operations for the connector that release connector-wide
* resources (usually created / initialized with the 'init'
* callback).
*
* Return: Success: 0
* Failure: (Can't fail)
*
*---------------------------------------------------------------------------
*/
static herr_t
H5VL_pass_through_ext_term(void)
{
#ifdef ENABLE_EXT_PASSTHRU_LOGGING
printf("------- EXT PASS THROUGH VOL TERM\n");
#endif
/* Reset VOL ID */
H5VL_PASSTHRU_EXT_g = H5I_INVALID_HID;
return 0;
} /* end H5VL_pass_through_ext_term() */
/*---------------------------------------------------------------------------
* Function: H5VL_pass_through_ext_info_copy
*
* Purpose: Duplicate the connector's info object.
*
* Returns: Success: New connector info object
* Failure: NULL
*
*---------------------------------------------------------------------------
*/
static void *
H5VL_pass_through_ext_info_copy(const void *_info)
{
const H5VL_pass_through_ext_info_t *info = (const H5VL_pass_through_ext_info_t *)_info;
H5VL_pass_through_ext_info_t *new_info;
#ifdef ENABLE_EXT_PASSTHRU_LOGGING
printf("------- EXT PASS THROUGH VOL INFO Copy\n");
#endif
/* Allocate new VOL info struct for the pass through connector */
new_info = (H5VL_pass_through_ext_info_t *)calloc(1, sizeof(H5VL_pass_through_ext_info_t));
/* Increment reference count on underlying VOL ID, and copy the VOL info */
new_info->under_vol_id = info->under_vol_id;
H5Iinc_ref(new_info->under_vol_id);
if(info->under_vol_info)
H5VLcopy_connector_info(new_info->under_vol_id, &(new_info->under_vol_info), info->under_vol_info);
return new_info;
} /* end H5VL_pass_through_ext_info_copy() */
/*---------------------------------------------------------------------------
* Function: H5VL_pass_through_ext_info_cmp
*
* Purpose: Compare two of the connector's info objects, setting *cmp_value,
* following the same rules as strcmp().
*
* Return: Success: 0
* Failure: -1
*
*---------------------------------------------------------------------------
*/
static herr_t
H5VL_pass_through_ext_info_cmp(int *cmp_value, const void *_info1, const void *_info2)
{
const H5VL_pass_through_ext_info_t *info1 = (const H5VL_pass_through_ext_info_t *)_info1;
const H5VL_pass_through_ext_info_t *info2 = (const H5VL_pass_through_ext_info_t *)_info2;
#ifdef ENABLE_EXT_PASSTHRU_LOGGING
printf("------- EXT PASS THROUGH VOL INFO Compare\n");
#endif
/* Sanity checks */
assert(info1);
assert(info2);
/* Initialize comparison value */
*cmp_value = 0;
/* Compare under VOL connector classes */
H5VLcmp_connector_cls(cmp_value, info1->under_vol_id, info2->under_vol_id);
if(*cmp_value != 0)
return 0;
/* Compare under VOL connector info objects */
H5VLcmp_connector_info(cmp_value, info1->under_vol_id, info1->under_vol_info, info2->under_vol_info);
if(*cmp_value != 0)
return 0;
return 0;
} /* end H5VL_pass_through_ext_info_cmp() */
/*---------------------------------------------------------------------------
* Function: H5VL_pass_through_ext_info_free
*
* Purpose: Release an info object for the connector.
*
* Note: Take care to preserve the current HDF5 error stack
* when calling HDF5 API calls.
*
* Return: Success: 0
* Failure: -1
*
*---------------------------------------------------------------------------
*/
static herr_t
H5VL_pass_through_ext_info_free(void *_info)
{
H5VL_pass_through_ext_info_t *info = (H5VL_pass_through_ext_info_t *)_info;
hid_t err_id;
#ifdef ENABLE_EXT_PASSTHRU_LOGGING
printf("------- EXT PASS THROUGH VOL INFO Free\n");
#endif
err_id = H5Eget_current_stack();
/* Release underlying VOL ID and info */
if(info->under_vol_info)
H5VLfree_connector_info(info->under_vol_id, info->under_vol_info);
H5Idec_ref(info->under_vol_id);
H5Eset_current_stack(err_id);
/* Free pass through info object itself */
free(info);
return 0;
} /* end H5VL_pass_through_ext_info_free() */
/*---------------------------------------------------------------------------
* Function: H5VL_pass_through_ext_info_to_str
*
* Purpose: Serialize an info object for this connector into a string
*
* Return: Success: 0
* Failure: -1
*
*---------------------------------------------------------------------------
*/
static herr_t
H5VL_pass_through_ext_info_to_str(const void *_info, char **str)
{
const H5VL_pass_through_ext_info_t *info = (const H5VL_pass_through_ext_info_t *)_info;
H5VL_class_value_t under_value = (H5VL_class_value_t)-1;
char *under_vol_string = NULL;
size_t under_vol_str_len = 0;
#ifdef ENABLE_EXT_PASSTHRU_LOGGING
printf("------- EXT PASS THROUGH VOL INFO To String\n");
#endif
/* Get value and string for underlying VOL connector */
H5VLget_value(info->under_vol_id, &under_value);
H5VLconnector_info_to_str(info->under_vol_info, info->under_vol_id, &under_vol_string);
/* Determine length of underlying VOL info string */
if(under_vol_string)
under_vol_str_len = strlen(under_vol_string);
/* Allocate space for our info */
*str = (char *)H5allocate_memory(32 + under_vol_str_len, (hbool_t)0);
assert(*str);
/* Encode our info
* Normally we'd use snprintf() here for a little extra safety, but that
* call had problems on Windows until recently. So, to be as platform-independent
* as we can, we're using sprintf() instead.
*/
sprintf(*str, "under_vol=%u;under_info={%s}", (unsigned)under_value, (under_vol_string ? under_vol_string : ""));
return 0;
} /* end H5VL_pass_through_ext_info_to_str() */
/*---------------------------------------------------------------------------
* Function: H5VL_pass_through_ext_str_to_info
*
* Purpose: Deserialize a string into an info object for this connector.
*
* Return: Success: 0
* Failure: -1
*
*---------------------------------------------------------------------------
*/
static herr_t
H5VL_pass_through_ext_str_to_info(const char *str, void **_info)
{
H5VL_pass_through_ext_info_t *info;
unsigned under_vol_value;
const char *under_vol_info_start, *under_vol_info_end;
hid_t under_vol_id;
void *under_vol_info = NULL;
#ifdef ENABLE_EXT_PASSTHRU_LOGGING
printf("------- EXT PASS THROUGH VOL INFO String To Info\n");
#endif
/* Retrieve the underlying VOL connector value and info */
sscanf(str, "under_vol=%u;", &under_vol_value);
under_vol_id = H5VLregister_connector_by_value((H5VL_class_value_t)under_vol_value, H5P_DEFAULT);
under_vol_info_start = strchr(str, '{');
under_vol_info_end = strrchr(str, '}');
assert(under_vol_info_end > under_vol_info_start);
if(under_vol_info_end != (under_vol_info_start + 1)) {
char *under_vol_info_str;
under_vol_info_str = (char *)malloc((size_t)(under_vol_info_end - under_vol_info_start));
memcpy(under_vol_info_str, under_vol_info_start + 1, (size_t)((under_vol_info_end - under_vol_info_start) - 1));
*(under_vol_info_str + (under_vol_info_end - under_vol_info_start)) = '\0';
H5VLconnector_str_to_info(under_vol_info_str, under_vol_id, &under_vol_info);
free(under_vol_info_str);
} /* end else */
/* Allocate new pass-through VOL connector info and set its fields */
info = (H5VL_pass_through_ext_info_t *)calloc(1, sizeof(H5VL_pass_through_ext_info_t));
info->under_vol_id = under_vol_id;
info->under_vol_info = under_vol_info;
/* Set return value */
*_info = info;
return 0;
} /* end H5VL_pass_through_ext_str_to_info() */
/*---------------------------------------------------------------------------
* Function: H5VL_pass_through_ext_get_object
*
* Purpose: Retrieve the 'data' for a VOL object.
*
* Return: Success: 0
* Failure: -1
*
*---------------------------------------------------------------------------
*/
static void *
H5VL_pass_through_ext_get_object(const void *obj)
{
const H5VL_pass_through_ext_t *o = (const H5VL_pass_through_ext_t *)obj;
#ifdef ENABLE_EXT_PASSTHRU_LOGGING
printf("------- EXT PASS THROUGH VOL Get object\n");
#endif
return H5VLget_object(o->under_object, o->under_vol_id);
} /* end H5VL_pass_through_ext_get_object() */
/*---------------------------------------------------------------------------
* Function: H5VL_pass_through_ext_get_wrap_ctx
*
* Purpose: Retrieve a "wrapper context" for an object
*
* Return: Success: 0
* Failure: -1
*
*---------------------------------------------------------------------------
*/
static herr_t
H5VL_pass_through_ext_get_wrap_ctx(const void *obj, void **wrap_ctx)
{
const H5VL_pass_through_ext_t *o = (const H5VL_pass_through_ext_t *)obj;
H5VL_pass_through_ext_wrap_ctx_t *new_wrap_ctx;
#ifdef ENABLE_EXT_PASSTHRU_LOGGING
printf("------- EXT PASS THROUGH VOL WRAP CTX Get\n");
#endif
/* Allocate new VOL object wrapping context for the pass through connector */
new_wrap_ctx = (H5VL_pass_through_ext_wrap_ctx_t *)calloc(1, sizeof(H5VL_pass_through_ext_wrap_ctx_t));
/* Increment reference count on underlying VOL ID, and copy the VOL info */
new_wrap_ctx->under_vol_id = o->under_vol_id;
H5Iinc_ref(new_wrap_ctx->under_vol_id);
H5VLget_wrap_ctx(o->under_object, o->under_vol_id, &new_wrap_ctx->under_wrap_ctx);
/* Set wrap context to return */
*wrap_ctx = new_wrap_ctx;
return 0;
} /* end H5VL_pass_through_ext_get_wrap_ctx() */
/*---------------------------------------------------------------------------
* Function: H5VL_pass_through_ext_wrap_object
*
* Purpose: Use a "wrapper context" to wrap a data object
*
* Return: Success: Pointer to wrapped object
* Failure: NULL
*
*---------------------------------------------------------------------------
*/
static void *
H5VL_pass_through_ext_wrap_object(void *obj, H5I_type_t obj_type, void *_wrap_ctx)
{
H5VL_pass_through_ext_wrap_ctx_t *wrap_ctx = (H5VL_pass_through_ext_wrap_ctx_t *)_wrap_ctx;
H5VL_pass_through_ext_t *new_obj;
void *under;
#ifdef ENABLE_EXT_PASSTHRU_LOGGING
printf("------- EXT PASS THROUGH VOL WRAP Object\n");
#endif
/* Wrap the object with the underlying VOL */
under = H5VLwrap_object(obj, obj_type, wrap_ctx->under_vol_id, wrap_ctx->under_wrap_ctx);
if(under)
new_obj = H5VL_pass_through_ext_new_obj(under, wrap_ctx->under_vol_id);
else
new_obj = NULL;
return new_obj;
} /* end H5VL_pass_through_ext_wrap_object() */
/*---------------------------------------------------------------------------
* Function: H5VL_pass_through_ext_unwrap_object
*
* Purpose: Unwrap a wrapped object, discarding the wrapper, but returning
* underlying object.
*
* Return: Success: Pointer to unwrapped object
* Failure: NULL
*
*---------------------------------------------------------------------------
*/
static void *
H5VL_pass_through_ext_unwrap_object(void *obj)
{
H5VL_pass_through_ext_t *o = (H5VL_pass_through_ext_t *)obj;
void *under;
#ifdef ENABLE_EXT_PASSTHRU_LOGGING
printf("------- EXT PASS THROUGH VOL UNWRAP Object\n");
#endif
/* Unrap the object with the underlying VOL */
under = H5VLunwrap_object(o->under_object, o->under_vol_id);
if(under)
H5VL_pass_through_ext_free_obj(o);
return under;
} /* end H5VL_pass_through_ext_unwrap_object() */
/*---------------------------------------------------------------------------
* Function: H5VL_pass_through_ext_free_wrap_ctx
*
* Purpose: Release a "wrapper context" for an object
*
* Note: Take care to preserve the current HDF5 error stack
* when calling HDF5 API calls.
*
* Return: Success: 0
* Failure: -1
*
*---------------------------------------------------------------------------
*/
static herr_t
H5VL_pass_through_ext_free_wrap_ctx(void *_wrap_ctx)
{
H5VL_pass_through_ext_wrap_ctx_t *wrap_ctx = (H5VL_pass_through_ext_wrap_ctx_t *)_wrap_ctx;
hid_t err_id;
#ifdef ENABLE_EXT_PASSTHRU_LOGGING
printf("------- EXT PASS THROUGH VOL WRAP CTX Free\n");
#endif
err_id = H5Eget_current_stack();
/* Release underlying VOL ID and wrap context */
if(wrap_ctx->under_wrap_ctx)
H5VLfree_wrap_ctx(wrap_ctx->under_wrap_ctx, wrap_ctx->under_vol_id);
H5Idec_ref(wrap_ctx->under_vol_id);
H5Eset_current_stack(err_id);
/* Free pass through wrap context object itself */
free(wrap_ctx);
return 0;
} /* end H5VL_pass_through_ext_free_wrap_ctx() */
/*-------------------------------------------------------------------------
* Function: H5VL_pass_through_ext_attr_create
*
* Purpose: Creates an attribute on an object.
*
* Return: Success: Pointer to attribute object
* Failure: NULL
*
*-------------------------------------------------------------------------
*/
static void *
H5VL_pass_through_ext_attr_create(void *obj, const H5VL_loc_params_t *loc_params,
const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id,
hid_t aapl_id, hid_t dxpl_id, void **req)
{
H5VL_pass_through_ext_t *attr;
H5VL_pass_through_ext_t *o = (H5VL_pass_through_ext_t *)obj;
void *under;
#ifdef ENABLE_EXT_PASSTHRU_LOGGING
printf("------- EXT PASS THROUGH VOL ATTRIBUTE Create\n");
#endif
under = H5VLattr_create(o->under_object, loc_params, o->under_vol_id, name, type_id, space_id, acpl_id, aapl_id, dxpl_id, req);
if(under) {
attr = H5VL_pass_through_ext_new_obj(under, o->under_vol_id);
/* Check for async request */
if(req && *req)
*req = H5VL_pass_through_ext_new_obj(*req, o->under_vol_id);
} /* end if */
else
attr = NULL;
return (void*)attr;
} /* end H5VL_pass_through_ext_attr_create() */
/*-------------------------------------------------------------------------
* Function: H5VL_pass_through_ext_attr_open
*
* Purpose: Opens an attribute on an object.
*
* Return: Success: Pointer to attribute object
* Failure: NULL
*
*-------------------------------------------------------------------------
*/
static void *
H5VL_pass_through_ext_attr_open(void *obj, const H5VL_loc_params_t *loc_params,
const char *name, hid_t aapl_id, hid_t dxpl_id, void **req)
{
H5VL_pass_through_ext_t *attr;
H5VL_pass_through_ext_t *o = (H5VL_pass_through_ext_t *)obj;
void *under;
#ifdef ENABLE_EXT_PASSTHRU_LOGGING
printf("------- EXT PASS THROUGH VOL ATTRIBUTE Open\n");
#endif
under = H5VLattr_open(o->under_object, loc_params, o->under_vol_id, name, aapl_id, dxpl_id, req);
if(under) {
attr = H5VL_pass_through_ext_new_obj(under, o->under_vol_id);
/* Check for async request */
if(req && *req)
*req = H5VL_pass_through_ext_new_obj(*req, o->under_vol_id);
} /* end if */
else
attr = NULL;
return (void *)attr;
} /* end H5VL_pass_through_ext_attr_open() */
/*-------------------------------------------------------------------------
* Function: H5VL_pass_through_ext_attr_read
*
* Purpose: Reads data from attribute.
*
* Return: Success: 0
* Failure: -1
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_pass_through_ext_attr_read(void *attr, hid_t mem_type_id, void *buf,
hid_t dxpl_id, void **req)
{
H5VL_pass_through_ext_t *o = (H5VL_pass_through_ext_t *)attr;
herr_t ret_value;
#ifdef ENABLE_EXT_PASSTHRU_LOGGING
printf("------- EXT PASS THROUGH VOL ATTRIBUTE Read\n");
#endif
ret_value = H5VLattr_read(o->under_object, o->under_vol_id, mem_type_id, buf, dxpl_id, req);
/* Check for async request */
if(req && *req)
*req = H5VL_pass_through_ext_new_obj(*req, o->under_vol_id);
return ret_value;
} /* end H5VL_pass_through_ext_attr_read() */
/*-------------------------------------------------------------------------
* Function: H5VL_pass_through_ext_attr_write
*
* Purpose: Writes data to attribute.
*
* Return: Success: 0
* Failure: -1
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_pass_through_ext_attr_write(void *attr, hid_t mem_type_id, const void *buf,
hid_t dxpl_id, void **req)
{
H5VL_pass_through_ext_t *o = (H5VL_pass_through_ext_t *)attr;
herr_t ret_value;
#ifdef ENABLE_EXT_PASSTHRU_LOGGING
printf("------- EXT PASS THROUGH VOL ATTRIBUTE Write\n");
#endif
ret_value = H5VLattr_write(o->under_object, o->under_vol_id, mem_type_id, buf, dxpl_id, req);
/* Check for async request */
if(req && *req)
*req = H5VL_pass_through_ext_new_obj(*req, o->under_vol_id);
return ret_value;
} /* end H5VL_pass_through_ext_attr_write() */
/*-------------------------------------------------------------------------
* Function: H5VL_pass_through_ext_attr_get
*
* Purpose: Gets information about an attribute
*
* Return: Success: 0
* Failure: -1
*
*-------------------------------------------------------------------------
*/
static herr_t
H5VL_pass_through_ext_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id,
void **req, va_list arguments)
{
H5VL_pass_through_ext_t *o = (H5VL_pass_through_ext_t *)obj;
herr_t ret_value;
#ifdef ENABLE_EXT_PASSTHRU_LOGGING
printf("------- EXT PASS THROUGH VOL ATTRIBUTE Get\n");
#endif
ret_value = H5VLattr_get(o->under_object, o->under_vol_id, get_type, dxpl_id, req, arguments);
/* Check for async request */
if(req && *req)
*req = H5VL_pass_through_ext_new_obj(*req, o->under_vol_id);
return ret_value;
} /* end H5VL_pass_through_ext_attr_get() */
/*-------------------------------------------------------------------------
* Function: H5VL_pass_through_ext_attr_specific
*
* Purpose: Specific operation on attribute
*
* Return: Success: 0
* Failure: -1