|
Lines 122-132
Link Here
|
| 122 |
*/ |
122 |
*/ |
| 123 |
JNIEXPORT jint JNICALL Java_org_eclipse_tptp_platform_execution_datacollection_BaseAgent_register0(JNIEnv *env, jobject thisObj, jstring name) |
123 |
JNIEXPORT jint JNICALL Java_org_eclipse_tptp_platform_execution_datacollection_BaseAgent_register0(JNIEnv *env, jobject thisObj, jstring name) |
| 124 |
{ |
124 |
{ |
| 125 |
char *cargv = "X"; |
|
|
| 126 |
//No command line args hence the env to be picked up. |
| 127 |
//TODO: Need to pass command line args to the Java agent from the command line. |
| 128 |
baseAgentImpl->processCommandLine(0, &cargv); |
| 129 |
|
| 130 |
jint returnValue = -1; |
125 |
jint returnValue = -1; |
| 131 |
/* Convert the Unicode Strings into UTF-8 ones */ |
126 |
/* Convert the Unicode Strings into UTF-8 ones */ |
| 132 |
const char *asciiName = env->GetStringUTFChars(name,NULL); |
127 |
const char *asciiName = env->GetStringUTFChars(name,NULL); |
|
Lines 932-934
Link Here
|
| 932 |
{ |
927 |
{ |
| 933 |
return processCmdCallBkWCtxt(cmd, DEFAULT_PROVIDER); |
928 |
return processCmdCallBkWCtxt(cmd, DEFAULT_PROVIDER); |
| 934 |
} |
929 |
} |
|
|
930 |
|
| 931 |
/* |
| 932 |
* Class: org_eclipse_tptp_platform_execution_datacollection_BaseAgent |
| 933 |
* Method: processCommandLine0 |
| 934 |
* Signature: ([Ljava/lang/String;)V |
| 935 |
*/ |
| 936 |
JNIEXPORT void JNICALL Java_org_eclipse_tptp_platform_execution_datacollection_BaseAgent_processCommandLine0 |
| 937 |
(JNIEnv *env, jobject obj, jobjectArray args) { |
| 938 |
|
| 939 |
int len = env->GetArrayLength(args); |
| 940 |
if (len <= 0) return; |
| 941 |
|
| 942 |
char** argv = (char**) malloc(len*sizeof(char*)); |
| 943 |
if (argv == NULL) return; |
| 944 |
|
| 945 |
for (int i=0; i<len; i++) { |
| 946 |
jstring arg = (jstring) env->GetObjectArrayElement(args, i); |
| 947 |
char* s = (char*) env->GetStringUTFChars(arg, 0); |
| 948 |
|
| 949 |
int slen = strlen(s); |
| 950 |
argv[i] = (char*) malloc(slen+1); |
| 951 |
if (argv[i] == NULL) return; |
| 952 |
|
| 953 |
strcpy (argv[i], s); |
| 954 |
|
| 955 |
env->ReleaseStringUTFChars(arg, s); |
| 956 |
} |
| 957 |
|
| 958 |
baseAgentImpl->processCommandLine(len, argv); |
| 959 |
|
| 960 |
for (i=0; i<len; i++) free(argv[i]); |
| 961 |
|
| 962 |
free(argv); |
| 963 |
} |