1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _LIBZFS_JNI_UTIL_H 28 #define _LIBZFS_JNI_UTIL_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 #include <jni.h> 37 #include <regex.h> 38 #include <libnvpair.h> 39 40 /* 41 * Constants 42 */ 43 44 #define ZFSJNI_PACKAGE_DATA "com/sun/zfs/common/model/" 45 46 /* 47 * Types 48 */ 49 50 typedef struct zjni_Object { 51 jclass class; 52 jobject object; 53 jmethodID constructor; 54 } zjni_Object_t; 55 56 typedef struct zjni_Collection { 57 zjni_Object_t super; 58 59 jmethodID method_add; 60 jmethodID method_size; 61 jmethodID method_toArray; 62 } zjni_Collection_t; 63 64 typedef struct zjni_ArrayList { 65 zjni_Collection_t super; 66 } zjni_ArrayList_t; 67 68 typedef struct zjni_DatasetSet { 69 zjni_Collection_t super; 70 } zjni_DatasetSet_t; 71 72 typedef struct zjni_ArrayCallbackData { 73 JNIEnv *env; 74 zjni_Collection_t *list; 75 } zjni_ArrayCallbackData_t; 76 77 /* Signature for function to free data */ 78 typedef void (*zjni_free_f)(void *); 79 80 /* 81 * Function prototypes 82 */ 83 84 void zjni_free_array(void **array, zjni_free_f); 85 void zjni_throw_exception(JNIEnv *, const char *, ...); 86 jstring zjni_get_matched_string(JNIEnv *, char *, regmatch_t *); 87 void zjni_get_dataset_from_snapshot(const char *, char *, size_t); 88 jobjectArray zjni_Collection_to_array(JNIEnv *, zjni_Collection_t *, char *); 89 void zjni_new_ArrayList(JNIEnv *, zjni_ArrayList_t *); 90 void zjni_new_DatasetSet(JNIEnv *, zjni_DatasetSet_t *); 91 jobject zjni_int_to_boolean(JNIEnv *, uint64_t); 92 jobject zjni_str_to_long(JNIEnv *, char *); 93 jobject zjni_long_to_Long(JNIEnv *, uint64_t); 94 jobject zjni_str_to_date(JNIEnv *, char *); 95 jobjectArray zjni_c_string_array_to_java(JNIEnv *, char **, int); 96 char **zjni_java_string_array_to_c(JNIEnv *, jobjectArray); 97 int zjni_count_elements(void **); 98 nvpair_t *zjni_nvlist_walk_nvpair( 99 nvlist_t *, const char *, data_type_t, nvpair_t *); 100 101 #ifdef __cplusplus 102 } 103 #endif 104 105 #endif /* _LIBZFS_JNI_UTIL_H */ 106