mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-11 07:10:36 +00:00
273270916e
This commit reflects changes to clang-format rules. Unfortunately, these rule changes create a massive change to the codebase, which causes an apparent rewrite of git history. Git blame's --ignore-rev flag can be used to ignore this commit when attempting to `git blame` some code.
36 lines
1.1 KiB
C++
36 lines
1.1 KiB
C++
#include "network_loki_lokinet_LokinetConfig.h"
|
|
#include <llarp.hpp>
|
|
#include "lokinet_jni_common.hpp"
|
|
|
|
extern "C"
|
|
{
|
|
JNIEXPORT jobject JNICALL
|
|
Java_network_loki_lokinet_LokinetConfig_Obtain(JNIEnv* env, jclass)
|
|
{
|
|
llarp_config* conf = llarp_default_config();
|
|
if (conf == nullptr)
|
|
return nullptr;
|
|
return env->NewDirectByteBuffer(conf, llarp_config_size());
|
|
}
|
|
|
|
JNIEXPORT void JNICALL
|
|
Java_network_loki_lokinet_LokinetConfig_Free(JNIEnv* env, jclass, jobject buf)
|
|
{
|
|
llarp_config_free(FromBuffer<llarp_config>(env, buf));
|
|
}
|
|
|
|
JNIEXPORT jboolean JNICALL
|
|
Java_network_loki_lokinet_LokinetConfig_Load(JNIEnv* env, jobject self, jstring fname)
|
|
{
|
|
llarp_config* conf = GetImpl<llarp_config>(env, self);
|
|
if (conf == nullptr)
|
|
return JNI_FALSE;
|
|
return VisitStringAsStringView<jboolean>(
|
|
env, fname, [conf](llarp::string_view val) -> jboolean {
|
|
const auto filename = llarp::string_view_string(val);
|
|
if (llarp_config_read_file(conf, filename.c_str()))
|
|
return JNI_TRUE;
|
|
return JNI_FALSE;
|
|
});
|
|
}
|
|
} |