h5pImp.c 187 KB
Newer Older
brinn's avatar
brinn committed
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.                                               *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * 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     *
 * help@hdfgroup.org.                                                        *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*
 *  For details of the HDF libraries, see the HDF Documentation at:
 *    http://hdfgroup.org/HDF5/doc/
 *
 */

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#include <stdlib.h>
#include "hdf5.h"
#include "h5util.h"
#include "h5pImp.h"

extern JavaVM *jvm;
extern jobject visit_callback;
extern jobject copy_callback;
extern jobject close_callback;
extern jobject create_callback;
extern jobject compare_callback;
extern jobject get_callback;
extern jobject set_callback;
extern jobject delete_callback;

/********************/
/* Local Prototypes */
/********************/

static herr_t H5P_cls_create_func_cb(hid_t prop_id, void *create_data);
static herr_t H5P_cls_copy_func_cb(hid_t new_prop_id, hid_t old_prop_id, void *copy_data);
static herr_t H5P_cls_close_func_cb(hid_t prop_id, void *close_data);

static herr_t H5P_prp_create_func_cb(const char *name, size_t size, void *value);
static herr_t H5P_prp_copy_func_cb(const char *name, size_t size, void *value);
static herr_t H5P_prp_close_func_cb(const char *name, size_t size, void *value);
static int H5P_prp_compare_func_cb(void *value1, void *value2, size_t size);
static herr_t H5P_prp_get_func_cb(hid_t prop_id, const char *name, size_t size, void *value);
static herr_t H5P_prp_set_func_cb(hid_t prop_id, const char *name, size_t size, void *value);
static herr_t H5P_prp_delete_func_cb(hid_t prop_id, const char *name, size_t size, void *value);

static herr_t H5P_iterate_cb(hid_t prop_id, const char *name, void *op_data);

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pcreate
 * Signature: (J)J
 */
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5__1H5Pcreate
    (JNIEnv *env, jclass clss, jlong type)
{
    hid_t retVal = -1;

    retVal = H5Pcreate((hid_t)type);
    if (retVal < 0)
        h5libraryError(env);

    return (jlong)retVal;
} /* end Java_hdf_hdf5lib_H5__1H5Pcreate */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pclose
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5__1H5Pclose
    (JNIEnv *env, jclass clss, jlong plist)
{
    herr_t retVal = 0;

    if (plist > 0)
        retVal = H5Pclose((hid_t)plist);

    if (retVal < 0)
        h5libraryError(env);

    return (jint)retVal;
} /* end Java_hdf_hdf5lib_H5__1H5Pclose */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pget_class
 * Signature: (J)J
 */
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Pget_1class
    (JNIEnv *env, jclass clss, jlong plist)
{
    hid_t retVal = -1;

    retVal = H5Pget_class((hid_t) plist);
    if (retVal == H5P_ROOT)
        h5libraryError(env);

    return (jlong)retVal;
} /* end Java_hdf_hdf5lib_H5_H5Pget_1class */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pcopy
 * Signature: (J)J
 */
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5__1H5Pcopy
    (JNIEnv *env, jclass clss, jlong plist)
{
    hid_t retVal = -1;

    retVal = H5Pcopy((hid_t)plist);
    if (retVal < 0)
        h5libraryError(env);

    return (jlong)retVal;
} /* end Java_hdf_hdf5lib_H5__1H5Pcopy */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pget_version
 * Signature: (J[I)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pget_1version
    (JNIEnv *env, jclass clss, jlong plist, jintArray version_info)
{
    herr_t   status = -1;
    jint    *theArray;
    jboolean isCopy;

    if (version_info == NULL) {
        h5nullArgument(env, "H5Pget_version:  version_info input array is NULL");
    } /* end if */
    else if (ENVPTR->GetArrayLength(ENVPAR version_info) < 4) {
        h5badArgument(env, "H5Pget_version:  version_info input array < 4");
    } /* end else if */
    else {
        theArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR version_info, &isCopy);
        if (theArray == NULL) {
            h5JNIFatalError(env, "H5Pget_version:  version_info not pinned");
        } /* end if */
        else {
            status = H5Pget_version((hid_t)plist, (unsigned *)&(theArray[0]),
                    (unsigned *)&(theArray[1]), (unsigned *)&(theArray[2]), (unsigned *)&(theArray[3]));
            if (status < 0) {
                ENVPTR->ReleaseIntArrayElements(ENVPAR version_info, theArray, JNI_ABORT);
                h5libraryError(env);
            } /* end if */
            else
                ENVPTR->ReleaseIntArrayElements(ENVPAR version_info, theArray, 0);
        } /* end else */
    } /* end else */

    return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Pget_1version */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pset_userblock
 * Signature: (JJ)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pset_1userblock
    (JNIEnv *env, jclass clss, jlong plist, jlong size)
{
    herr_t retVal = -1;
    long sz = (long)size;

    retVal = H5Pset_userblock((hid_t)plist, (hsize_t)sz);
    if (retVal < 0)
        h5libraryError(env);

    return (jint)retVal;
} /* end Java_hdf_hdf5lib_H5_H5Pset_1userblock */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pget_userblock
 * Signature: (J[J)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pget_1userblock
    (JNIEnv *env, jclass clss, jlong plist, jlongArray size)
{
    herr_t   status = -1;
    jlong   *theArray;
    jboolean isCopy;
    hsize_t  s;

    if (size == NULL) {
        h5nullArgument(env, "H5Pget_userblock:  size is NULL");
    } /* end if */
    else {
        theArray = (jlong*)ENVPTR->GetLongArrayElements(ENVPAR size, &isCopy);
        if (theArray == NULL) {
            h5JNIFatalError(env, "H5Pget_userblock:  size not pinned");
        } /* end if */
        else {
            status = H5Pget_userblock((hid_t)plist, &s);

            if (status < 0) {
                ENVPTR->ReleaseLongArrayElements(ENVPAR size, theArray, JNI_ABORT);
                h5libraryError(env);
            } /* end if */
            else {
                theArray[0] = (jlong)s;
                ENVPTR->ReleaseLongArrayElements(ENVPAR size, theArray, 0);
            } /* end else */
        } /* end else */
    } /* end else */

    return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Pget_1userblock */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pset_sizes
 * Signature: (JII)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pset_1sizes
    (JNIEnv *env, jclass clss, jlong plist, jint sizeof_addr, jint sizeof_size)
{
    herr_t retVal = -1;

    retVal = H5Pset_sizes((hid_t)plist, (size_t)sizeof_addr, (size_t)sizeof_size);
    if (retVal < 0)
        h5libraryError(env);

    return (jint)retVal;
} /* end Java_hdf_hdf5lib_H5_H5Pset_1sizes */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pget_sizes
 * Signature: (J[J)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pget_1sizes
    (JNIEnv *env, jclass clss, jlong plist, jlongArray size)
{
    herr_t   status = -1;
    jlong   *theArray;
    jboolean isCopy;
    size_t   ss;
    size_t   sa;

    if (size == NULL) {
        h5nullArgument(env, "H5Pget_sizes:  size is NULL");
    } /* end if */
    else if (ENVPTR->GetArrayLength(ENVPAR size) < 2) {
        h5badArgument(env, "H5Pget_sizes:  size input array < 2 elements");
    }
    else {
        theArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR size, &isCopy);
        if (theArray == NULL) {
            h5JNIFatalError(env, "H5Pget_sizes:  size not pinned");
        } /* end if */
        else {
            status = H5Pget_sizes((hid_t)plist, &sa, &ss);
            if (status < 0) {
                ENVPTR->ReleaseLongArrayElements(ENVPAR size, theArray, JNI_ABORT);
                h5libraryError(env);
            } /* end if */
            else {
                theArray[0] = (jlong)sa;
                theArray[1] = (jlong)ss;
                ENVPTR->ReleaseLongArrayElements(ENVPAR size, theArray, 0);
            } /* end else */
        } /* end else */
    } /* end else */

    return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Pget_1sizes */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pset_sym_k
 * Signature: (JII)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pset_1sym_1k
    (JNIEnv *env, jclass clss, jlong plist, jint ik, jint lk)
{
    herr_t retVal = -1;

    retVal = H5Pset_sym_k((hid_t)plist, (unsigned)ik, (unsigned)lk);
    if (retVal < 0)
        h5libraryError(env);

    return (jint)retVal;
} /* end Java_hdf_hdf5lib_H5_H5Pset_1sym_1k */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pget_sym_k
 * Signature: (J[I)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pget_1sym_1k
    (JNIEnv *env, jclass clss, jlong plist, jintArray size)
{
    herr_t   status = -1;
    jint    *theArray;
    jboolean isCopy;

    if (size == NULL) {
        h5nullArgument(env, "H5Pget_sym_k:  size is NULL");
    } /* end if */
    else if (ENVPTR->GetArrayLength(ENVPAR size) < 2) {
        h5badArgument(env, "H5Pget_sym_k:  size < 2 elements");
    } /* end else if */
    else {
        theArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR size, &isCopy);
        if (theArray == NULL) {
            h5JNIFatalError(env, "H5Pget_sym_k:  size not pinned");
        } /* end if */
        else {
            status = H5Pget_sym_k((hid_t)plist, (unsigned *)&(theArray[0]), (unsigned *)&(theArray[1]));
            if (status < 0) {
                ENVPTR->ReleaseIntArrayElements(ENVPAR size, theArray, JNI_ABORT);
                h5libraryError(env);
            } /* end if */
            else
                ENVPTR->ReleaseIntArrayElements(ENVPAR size, theArray, 0);
        } /* end else */
    } /* end else */

    return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Pget_1sym_1k */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pset_istore_k
 * Signature: (JI)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pset_1istore_1k
    (JNIEnv *env, jclass clss, jlong plist, jint ik)
{
    herr_t retVal = -1;

    retVal = H5Pset_istore_k((hid_t)plist, (unsigned)ik);
    if (retVal < 0)
        h5libraryError(env);

    return (jint)retVal;
} /* end Java_hdf_hdf5lib_H5_H5Pset_1istore_1k */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pget_istore_k
 * Signature: (J[I)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pget_1istore_1k
    (JNIEnv *env, jclass clss, jlong plist, jintArray ik)
{
    herr_t   status = -1;
    jint    *theArray;
    jboolean isCopy;

    if (ik == NULL) {
        h5nullArgument(env, "H5Pget_store_k:  ik is NULL");
    } /* end if */
    else {
        theArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR ik, &isCopy);
        if (theArray == NULL) {
            h5JNIFatalError(env, "H5Pget_store_k:  size not pinned");
        } /* end if */
        else {
            status = H5Pget_istore_k((hid_t)plist, (unsigned *)&(theArray[0]));
            if (status < 0) {
                ENVPTR->ReleaseIntArrayElements(ENVPAR ik, theArray, JNI_ABORT);
                h5libraryError(env);
            } /* end if */
            else
                ENVPTR->ReleaseIntArrayElements(ENVPAR ik, theArray, 0);
        } /* end else */
    } /* end else */

    return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Pget_1istore_1k */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pset_layout
 * Signature: (JI)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pset_1layout
    (JNIEnv *env, jclass clss, jlong plist, jint layout)
{
    herr_t retVal = -1;

    retVal = H5Pset_layout((hid_t)plist, (H5D_layout_t)layout);
    if (retVal < 0)
        h5libraryError(env);

    return (jint)retVal;
} /* end Java_hdf_hdf5lib_H5_H5Pset_1layout */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pget_layout
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pget_1layout
    (JNIEnv *env, jclass clss, jlong plist)
{
    H5D_layout_t retVal = H5D_LAYOUT_ERROR;

    retVal = H5Pget_layout((hid_t)plist);
    if (retVal == H5D_LAYOUT_ERROR)
        h5libraryError(env);

    return (jint)retVal;
} /* end Java_hdf_hdf5lib_H5_H5Pget_1layout */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pset_chunk
 * Signature: (JI[B)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pset_1chunk
    (JNIEnv *env, jclass clss, jlong plist, jint ndims, jbyteArray dim)
{
    herr_t   status = -1;
    jbyte   *theArray;
    jboolean isCopy;
    hsize_t *da;
    hsize_t *lp;
    jlong   *jlp;
    size_t   i;
    size_t   rank;

    if (dim == NULL) {
        h5nullArgument(env, "H5Pset_chunk:  dim array is NULL");
    } /* end if */
    else {
        i = (size_t)ENVPTR->GetArrayLength(ENVPAR dim);
        rank = i / sizeof(jlong);
        if (rank < ndims) {
            h5badArgument(env, "H5Pset_chunk:  dims array < ndims");
        } /* end if */
        else {
            theArray = (jbyte *)ENVPTR->GetByteArrayElements(ENVPAR dim, &isCopy);
            if (theArray == NULL) {
                h5JNIFatalError(env, "H5Pset_chunk:  dim array not pinned");
            } /* end if */
            else {
                da = lp = (hsize_t *)HDmalloc(rank * sizeof(hsize_t));
                if (da == NULL) {
                    ENVPTR->ReleaseByteArrayElements(ENVPAR dim, theArray, JNI_ABORT);
                    h5JNIFatalError(env,  "H5Pset_chunk:  dims not converted to hsize_t");
                } /* end if */
                else {
                    jlp = (jlong *)theArray;
                    for (i = 0; i < rank; i++) {
                        *lp = (hsize_t)*jlp;
                        lp++;
                        jlp++;
                    } /* end if */

                    status = H5Pset_chunk((hid_t)plist, (int)ndims, da);

                    ENVPTR->ReleaseByteArrayElements(ENVPAR dim, theArray, JNI_ABORT);
                    HDfree(da);

                    if (status < 0)
                        h5libraryError(env);
                } /* end else */
            } /* end else */
        } /* end else */
    } /* end else */

    return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Pset_1chunk */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pget_chunk
 * Signature: (JI[J)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pget_1chunk
    (JNIEnv *env, jclass clss, jlong plist, jint max_ndims, jlongArray dims)
{
    herr_t   status = -1;
    jlong   *theArray;
    jboolean isCopy;
    hsize_t *da;
    int      i;

    if (dims == NULL) {
        h5nullArgument(env, "H5Pget_chunk:  dims is NULL");
    } /* end if */
    else if (ENVPTR->GetArrayLength(ENVPAR dims) < max_ndims) {
        h5badArgument(env, "H5Pget_chunk:  dims array < max_ndims");
    } /* end else if */
    else {
        theArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR dims, &isCopy);
        if (theArray == NULL) {
            h5JNIFatalError(env, "H5Pget_chunk:  input dims not pinned");
        } /* end if */
        else {
            da = (hsize_t *)HDmalloc((size_t)max_ndims * sizeof(hsize_t));
            if (da == NULL) {
                ENVPTR->ReleaseLongArrayElements(ENVPAR dims, theArray, JNI_ABORT);
                h5JNIFatalError(env, "H5Pget_chunk:  dims not converted to hsize_t");
            } /* end if */
            else {
                status = H5Pget_chunk((hid_t)plist, (int)max_ndims, da);

                if (status < 0)  {
                    ENVPTR->ReleaseLongArrayElements(ENVPAR dims, theArray, JNI_ABORT);
                    HDfree (da);
                    h5libraryError(env);
                } /* end if */
                else {
                    for (i = 0; i < max_ndims; i++) {
                        theArray[i] = (jlong)da[i];
                    }
                    HDfree (da);
                    ENVPTR->ReleaseLongArrayElements(ENVPAR dims, theArray, 0);
                } /* end else */
            } /* end else */
        } /* end else */
    } /* end else */

    return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Pget_1chunk */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pset_alignment
 * Signature: (JJJ)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pset_1alignment
    (JNIEnv *env, jclass clss, jlong plist, jlong threshold, jlong alignment)
{
    herr_t retVal = -1;
    long thr = (long)threshold;
    long align = (long)alignment;

    retVal = H5Pset_alignment((hid_t)plist, (hsize_t)thr, (hsize_t)align);
    if (retVal < 0)
        h5libraryError(env);

    return (jint)retVal;
} /* end Java_hdf_hdf5lib_H5_H5Pset_1alignment */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pget_alignment
 * Signature: (J[J)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pget_1alignment
    (JNIEnv *env, jclass clss, jlong plist, jlongArray alignment)
{
    herr_t   status = -1;
    jlong   *theArray;
    jboolean isCopy;
    hsize_t  t;
    hsize_t  a;

    if (alignment == NULL) {
        h5nullArgument(env, "H5Pget_alignment:  input alignment is NULL");
    } /* end if */
    else {
        if (ENVPTR->GetArrayLength(ENVPAR alignment) < 2) {
            h5badArgument(env, "H5Pget_alignment:  alignment input array < 2");
        } /* end if */
        else {
            theArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR alignment, &isCopy);
            if (theArray == NULL) {
                h5JNIFatalError(env, "H5Pget_alignment:  input array not pinned");
            } /* end if */
            else {
                status = H5Pget_alignment((hid_t)plist, &t, &a);
                if (status < 0)  {
                    ENVPTR->ReleaseLongArrayElements(ENVPAR alignment, theArray, JNI_ABORT);
                    h5libraryError(env);
                } /* end if */
                else {
                    theArray[0] = (jlong)t;
                    theArray[1] = (jlong)a;
                    ENVPTR->ReleaseLongArrayElements(ENVPAR alignment, theArray, 0);
                } /* end else */
            } /* end else */
        } /* end else */
    } /* end else */

    return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Pget_1alignment */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pset_external
 * Signature: (JLjava/lang/String;JJ)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pset_1external
    (JNIEnv *env, jclass clss, jlong plist, jstring name, jlong offset, jlong size)
{
    herr_t      status = -1;
    const char *fileName;
    off_t       off;
    hsize_t     sz;
    hid_t       plid;

    plid = (hid_t)plist;
    off = (off_t)offset;
    sz = (hsize_t)size;

    PIN_JAVA_STRING(name, fileName);
    if (fileName != NULL) {
        status = H5Pset_external(plid, fileName, off, sz);

        UNPIN_JAVA_STRING(name, fileName);

        if (status < 0)
            h5libraryError(env);
    }

    return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Pset_1external */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pget_external_count
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pget_1external_1count
    (JNIEnv *env, jclass clss, jlong plist)
{
    int retVal = -1;

    retVal = H5Pget_external_count((hid_t)plist);
    if (retVal < 0)
        h5libraryError(env);

    return (jint)retVal;
} /* end Java_hdf_hdf5lib_H5_H5Pget_1external_1count */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pget_external
 * Signature: (JIJ[Ljava/lang/String;[J)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pget_1external
    (JNIEnv *env, jclass clss, jlong plist, jint idx, jlong name_size,
        jobjectArray name, jlongArray size)
{
    herr_t   status = -1;
    jlong   *theArray;
    jboolean isCopy;
    char    *file = NULL;
    jstring  str;
    off_t    o;
    hsize_t  s;

    if (name_size < 0) {
        h5badArgument(env, "H5Pget_external:  name_size < 0");
    } /* end if */
    else if ((size != NULL) && (ENVPTR->GetArrayLength(ENVPAR size) < 2)) {
        h5badArgument(env, "H5Pget_external:  size input array < 2");
    } /* end else if */
    else {
        if (name_size > 0) {
            file = (char *)HDmalloc(sizeof(char)*(size_t)name_size);
        } /* end else */

        status = H5Pget_external((hid_t) plist, (unsigned)idx, (size_t)name_size,
                file, (off_t *)&o, (hsize_t *)&s);
        if (status < 0) {
            HDfree(file);
            h5libraryError(env);
        } /* end if */
        else {
            if (size != NULL) {
                theArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR size, &isCopy);
                if (theArray == NULL) {
                    h5JNIFatalError( env, "H5Pget_external:  size array not pinned");
                } /* end if */
                else {
                    theArray[0] = o;
                    theArray[1] = (jlong)s;
                    ENVPTR->ReleaseLongArrayElements(ENVPAR size, theArray, 0);
                }
            } /* end if */

            if (file != NULL) {
                /*  NewStringUTF may throw OutOfMemoryError */
                str = ENVPTR->NewStringUTF(ENVPAR file);
                if (str == NULL) {
                    HDfree(file);
                    h5JNIFatalError(env, "H5Pget_external:  return array not created");
                } /* end if */
                else {
                    /*  SetObjectArrayElement may raise exceptions */
                    ENVPTR->SetObjectArrayElement(ENVPAR name, 0, (jobject)str);
                    HDfree(file);
                } /* end else */
            } /* end if */
        } /* end else */
    }

    return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Pget_1external */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pset_fill_value
 * Signature: (JJ[B)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pset_1fill_1value
    (JNIEnv *env, jclass clss, jlong plist_id, jlong type_id, jbyteArray value)
{
    jint     status = -1;
    jbyte   *byteP = NULL;
    jboolean isCopy;

    if (value != NULL) {
        byteP = ENVPTR->GetByteArrayElements(ENVPAR value, &isCopy);
        if (byteP == NULL) {
            h5JNIFatalError(env, "H5Pget_fill_value:  value array not pinned");
        } /* end if */
        else {
            status = H5Pset_fill_value((hid_t)plist_id, (hid_t)type_id, byteP);

            ENVPTR->ReleaseByteArrayElements(ENVPAR value, byteP, JNI_ABORT);
        }
    } /* end if */
    else {
        status = H5Pset_fill_value((hid_t)plist_id, (hid_t)type_id, byteP);
    }

    if (status < 0)
        h5libraryError(env);

    return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Pset_1fill_1value */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pget_fill_value
 * Signature: (JJ[B)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pget_1fill_1value
    (JNIEnv *env, jclass clss, jlong plist_id, jlong type_id, jbyteArray value)
{
    jint     status = -1;
    jbyte   *byteP;
    jboolean isCopy;

    if (value == NULL) {
        h5badArgument(env, "H5Pget_fill_value:  value is NULL");
    } /* end if */
    else {
        byteP = ENVPTR->GetByteArrayElements(ENVPAR value, &isCopy);
        if (byteP == NULL) {
            h5JNIFatalError(env, "H5Pget_fill_value:  value array not pinned");
        } /* end if */
        else {
            status = H5Pget_fill_value((hid_t)plist_id, (hid_t)type_id, byteP);
            if (status < 0) {
                ENVPTR->ReleaseByteArrayElements(ENVPAR value, byteP, JNI_ABORT);
                h5libraryError(env);
            } /* end if */
            else
                ENVPTR->ReleaseByteArrayElements(ENVPAR value, byteP, 0);
        } /* end else */
    } /* end else */

    return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Pget_1fill_1value */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pset_filter
 * Signature: (JIIJ[I)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pset_1filter
    (JNIEnv *env, jclass clss, jlong plist, jint filter, jint flags,
  jlong cd_nelmts, jintArray cd_values)
{
    herr_t   status = -1;
    jint    *theArray;
    jboolean isCopy;

    if (cd_values == NULL) {
        status = H5Pset_filter((hid_t)plist, (H5Z_filter_t)filter,
                (unsigned int)flags, (size_t)cd_nelmts, NULL);
        if (status < 0)
            h5libraryError(env);
    } /* end if */
    else {
        theArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR cd_values, &isCopy);
        if (theArray == NULL) {
            h5JNIFatalError(env, "H5Pset_filter:  input array  not pinned");
        }/* end if */
        else {
            status = H5Pset_filter((hid_t)plist, (H5Z_filter_t)filter,
                    (unsigned int)flags, (size_t)cd_nelmts, (const unsigned int *)theArray);
            ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, theArray, JNI_ABORT);
            if (status < 0)
                h5libraryError(env);
        } /* end else */
    } /* end else */

    return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Pset_1filter */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pget_nfilters
 * Signature: (J)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pget_1nfilters
    (JNIEnv *env, jclass clss, jlong plist)
{
    int retVal = -1;

    retVal = H5Pget_nfilters((hid_t)plist);
    if (retVal < 0)
        h5libraryError(env);

    return (jint)retVal;
} /* end Java_hdf_hdf5lib_H5_H5Pget_1nfilters */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pget_filter
 * Signature: (JI[I[J[IJ[Ljava/lang/String;)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pget_1filter
    (JNIEnv *env, jclass clss, jlong plist, jint filter_number, jintArray flags,
        jlongArray cd_nelmts, jintArray cd_values, jlong namelen, jobjectArray name)
{
    herr_t   status = -1;
    jint    *flagsArray;
    jlong   *cd_nelmtsArray;
    jint    *cd_valuesArray;
    jint     mode = JNI_ABORT;
    jboolean isCopy;
    jstring  str;
    char    *filter;

    if (namelen <= 0) {
        h5badArgument(env, "H5Pget_filter:  namelen <= 0");
    } /* end if */
    else if (flags == NULL) {
        h5badArgument(env, "H5Pget_filter:  flags is NULL");
    } /* end else if */
    else if (cd_nelmts == NULL) {
        h5badArgument(env, "H5Pget_filter:  cd_nelmts is NULL");
    } /* end else if */
    else if (cd_values == NULL) {
        h5badArgument(env, "H5Pget_filter:  cd_values is NULL");
    } /* end else if */
    else {
        filter = (char *)HDmalloc(sizeof(char)*(size_t)namelen);
        if (filter == NULL) {
            h5outOfMemory(env, "H5Pget_filter:  namelen malloc failed");
        } /* end if */
        else {
            flagsArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR flags, &isCopy);
            if (flagsArray == NULL) {
                h5JNIFatalError(env, "H5Pget_filter:  flags array not pinned");
            } /* end if */
            else {
                cd_nelmtsArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR cd_nelmts, &isCopy);
                if (cd_nelmtsArray == NULL) {
                    h5JNIFatalError(env, "H5Pget_filter:  nelmts array not pinned");
                } /* end if */
                else {
                    cd_valuesArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR cd_values, &isCopy);
                    if (cd_valuesArray == NULL)  {
                        h5JNIFatalError(env, "H5Pget_filter:  elmts array not pinned");
                    } /* end if */
                    else {
                        /* direct cast (size_t *)variable fails on 32-bit environment */
                        long long cd_nelmts_temp = *(cd_nelmtsArray);
                        size_t cd_nelmts_t = (size_t)cd_nelmts_temp;
                        unsigned int filter_config;
                        status = H5Pget_filter2((hid_t)plist, (unsigned)filter_number,
                                (unsigned int *)flagsArray, &cd_nelmts_t, (unsigned int *)cd_valuesArray,
                                (size_t)namelen, filter, &filter_config);

                        *cd_nelmtsArray = (jlong)cd_nelmts_t;
                        /* end direct cast special */

                        if (status < 0) {
                            h5libraryError(env);
                        } /* end if */
                        else {
                            mode = 0;

                            /*  NewStringUTF may throw OutOfMemoryError */
                            str = ENVPTR->NewStringUTF(ENVPAR filter);
                            if (str == NULL) {
                                h5JNIFatalError(env, "H5Pget_filter:  return string not pinned");
                            } /* end if */
                            else {
                                /*  SetObjectArrayElement may throw exceptiosn */
                                ENVPTR->SetObjectArrayElement(ENVPAR name, 0, (jobject)str);
                            } /* end else */
                        } /* end else */
                        ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesArray, mode);
                    }
                    ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, mode);
                }
                ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, mode);
            }
            HDfree(filter);
        }
    } /* end else */

    return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Pget_1filter */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pget_driver
 * Signature: (J)J
 */
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Pget_1driver
    (JNIEnv *env, jclass clss, jlong plist)
{
    hid_t retVal = -1;

    retVal = H5Pget_driver((hid_t) plist);
    if (retVal < 0)
        h5libraryError(env);

    return (jlong)retVal;
} /* end Java_hdf_hdf5lib_H5_H5Pget_1driver */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pset_cache
 * Signature: (JIJJD)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pset_1cache
    (JNIEnv *env, jclass clss, jlong plist, jint mdc_nelmts, jlong rdcc_nelmts,
  jlong rdcc_nbytes, jdouble rdcc_w0)
{
    herr_t retVal = -1;

    retVal = H5Pset_cache((hid_t)plist, (int)mdc_nelmts, (size_t)rdcc_nelmts,
                (size_t)rdcc_nbytes, (double) rdcc_w0);
    if (retVal < 0)
        h5libraryError(env);

    return (jint)retVal;
} /* end Java_hdf_hdf5lib_H5_H5Pset_1cache */

/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Pget_cache
 * Signature: (J[I[J[J[D)I
 */
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Pget_1cache
    (JNIEnv *env, jclass clss, jlong plist, jintArray mdc_nelmts,
        jlongArray rdcc_nelmts, jlongArray rdcc_nbytes, jdoubleArray rdcc_w0)
{
    herr_t   status = -1;
    jint     mode;
    jdouble *w0Array = (jdouble *)NULL;
    jlong   *rdcc_nelmtsArray = (jlong *)NULL;
    jlong   *nbytesArray = (jlong *)NULL;
    jboolean isCopy;
For faster browsing, not all history is shown. View entire blame