btc_horse/JNI/native_impl.c

29 lines
778 B
C

//native_impl.c
#include <jni.h>
#include <stdio.h>
#include <string.h>
// JNI functions for com.example.cezenBTC.service.NativeBridge
JNIEXPORT jstring JNICALL
Java_com_example_cezenBTC_service_NativeBridge_hello(JNIEnv *env, jclass clazz, jstring jname) {
(void)clazz; // unused
const char *name = jname ? (*env)->GetStringUTFChars(env, jname, NULL) : "World";
char buf[256];
snprintf(buf, sizeof(buf), "Hello from JNI, %s!", (name && *name) ? name : "World");
if (jname) {
(*env)->ReleaseStringUTFChars(env, jname, name);
}
return (*env)->NewStringUTF(env, buf);
}
JNIEXPORT jint JNICALL
Java_com_example_cezenBTC_service_NativeBridge_add(JNIEnv *env, jclass clazz, jint a, jint b) {
(void)env; (void)clazz;
return a + b;
}