mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-29 15:43:56 +00:00
Add Java API for setting the instance path
This commit is contained in:
parent
87ab136d0f
commit
b5c62a19d5
@ -18,7 +18,6 @@ SERVALD_LOCAL_CFLAGS = \
|
||||
-g \
|
||||
-Wall -Wno-unused-variable -Wno-unused-value -Werror \
|
||||
-DSERVALD_VERSION="\"Android\"" -DSERVALD_COPYRIGHT="\"Android\"" \
|
||||
-DINSTANCE_PATH="\"/data/data/org.servalproject/var/serval-node\"" \
|
||||
-DSHELL -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" \
|
||||
-DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" \
|
||||
-DHAVE_FUNC_ATTRIBUTE_ERROR=1 \
|
||||
|
25
instance.c
25
instance.c
@ -18,12 +18,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_JNI_H
|
||||
#include <jni.h>
|
||||
|
||||
// Stop OpenJDK 7 from foisting their UNUSED() macro on us in <jni_md.h>
|
||||
#ifdef UNUSED
|
||||
# undef UNUSED
|
||||
#endif
|
||||
#endif
|
||||
#include "instance.h"
|
||||
#include "str.h"
|
||||
#include "os.h"
|
||||
#include "strbuf.h"
|
||||
#include "strbuf_helpers.h"
|
||||
|
||||
|
||||
/*
|
||||
* A default INSTANCE_PATH can be set on the ./configure command line, eg:
|
||||
*
|
||||
@ -36,9 +45,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* always use an instance path and never fall back to FHS paths.
|
||||
*/
|
||||
#ifdef ANDROID
|
||||
# ifndef INSTANCE_PATH
|
||||
# error Must set INSTANCE_PATH macro on Android systems
|
||||
# endif
|
||||
# define SERVAL_ETC_PATH ""
|
||||
# define SERVAL_RUN_PATH ""
|
||||
# define SYSTEM_LOG_PATH ""
|
||||
@ -98,6 +104,19 @@ const char *instance_path()
|
||||
return instancepath;
|
||||
}
|
||||
|
||||
#ifdef HAVE_JNI_H
|
||||
JNIEXPORT jint JNICALL Java_org_servalproject_servaldna_ServalDCommand_setInstancePath(
|
||||
JNIEnv *env, jobject UNUSED(this), jobject path)
|
||||
{
|
||||
const char *cpath = (*env)->GetStringUTFChars(env, path, NULL);
|
||||
instancepath = strdup(cpath);
|
||||
know_instancepath = 1;
|
||||
(*env)->ReleaseStringUTFChars(env, path, cpath);
|
||||
return (jint)0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static int vformf_path(struct __sourceloc __whence, strbuf b, const char *syspath, const char *fmt, va_list ap)
|
||||
{
|
||||
if (fmt)
|
||||
|
@ -70,6 +70,8 @@ public class ServalDCommand
|
||||
|
||||
public static native int server(IJniServer callback, String keyringPin, String[] entryPins);
|
||||
|
||||
public static native int setInstancePath(String path);
|
||||
|
||||
/**
|
||||
* Common entry point into servald command line.
|
||||
*
|
||||
|
@ -13,7 +13,7 @@ public class ServerControl {
|
||||
private int loopbackMdpPort;
|
||||
private int httpPort=0;
|
||||
private int pid;
|
||||
private static final String restfulUsername="ServalDClient";
|
||||
public static final String restfulUsername="ServalDClient";
|
||||
private ServalDClient client;
|
||||
|
||||
public ServerControl(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user