I am trying to use JNA and execute with a pointer to a pointer but I keep having trouble. I am able to use other functions in the class, however the arguments in this function are giving me trouble. My interface and java where works fine, and i can use the other methods, however "execute_file" & "alenkaexecute" is giving me trouble. Is my method declaration off? I am thinking maybe i should have a string array instead of PointerByReference? At the bottom i included the c++ with execute_file.
Thank you!
public interface libcvm extends Library{
void alenkaInit(PointerByReference av);
int execute_file(int ac, PointerByReference av);
void alenkaClose();
int alenkaExecute(ByteBuffer s);
}
public static void main(String[] args) {
libcvm libcvm = (libcvm) Native.loadLibrary("libcvm.so", libcvm.class);
PointerByReference pref = new PointerByReference();
libcvm.execute_file(2, pref);
Pointer p = pref.getValue();
}
int execute_file(int ac, char **av)
{
bool just_once = 0;
string script;
process_count = 6200000;
verbose = 0;
total_buffer_size = 0;
for (int i = 1; i < ac; i++) {
if(strcmp(av[i],"-l") == 0) {
process_count = atoff(av[i+1]);
}
else if(strcmp(av[i],"-v") == 0) {
verbose = 1;
}
else if(strcmp(av[i],"-i") == 0) {
interactive = 1;
break;
}
else if(strcmp(av[i],"-s") == 0) {
just_once = 1;
interactive = 1;
script = av[i+1];
};
};
load_col_data(data_dict, "data.dictionary");
if (!interactive) {
if((yyin = fopen(av[ac-1], "r")) == NULL) {
perror(av[ac-1]);
exit(1);
};
if(yyparse()) {
printf("SQL scan parse failed\n");
exit(1);
};
//exit(0);
scan_state = 1;
std::clock_t start1 = std::clock();
load_vars();
statement_count = 0;
clean_queues();
yyin = fopen(av[ac-1], "r");
PROC_FLUSH_BUF ( yyin );
statement_count = 0;
extern FILE *yyin;
context = CreateCudaDevice(0, av, verbose);
hash_seed = 100;
if(!yyparse()) {
if(verbose)
cout << "SQL scan parse worked " << endl;
}
else
cout << "SQL scan parse failed" << endl;
fclose(yyin);
for (map<string,CudaSet*>::iterator it=varNames.begin() ; it != varNames.end(); ++it ) {
(*it).second->free();
};
if(alloced_sz) {
cudaFree(alloced_tmp);
};
if(verbose) {
cout<< "cycle time " << ( ( std::clock() - start1 ) / (double)CLOCKS_PER_SEC ) << " " << getFreeMem() << endl;
};
}
else {
context = CreateCudaDevice(0, av, verbose);
hash_seed = 100;
if(!just_once)
getline(cin, script);
while (script != "exit" && script != "EXIT") {
used_vars.clear();
yy_scan_string(script.c_str());
scan_state = 0;
statement_count = 0;
clean_queues();
if(yyparse()) {
printf("SQL scan parse failed \n");
getline(cin, script);
continue;
};
scan_state = 1;
load_vars();
statement_count = 0;
clean_queues();
yy_scan_string(script.c_str());
std::clock_t start1 = std::clock();
if(!yyparse()) {
if(verbose)
cout << "SQL scan parse worked " << endl;
};
for (map<string,CudaSet*>::iterator it=varNames.begin() ; it != varNames.end(); ++it ) {
(*it).second->free();
};
varNames.clear();
if(verbose) {
cout<< "cycle time " << ( ( std::clock() - start1 ) / (double)CLOCKS_PER_SEC ) << endl;
};
if(!just_once)
getline(cin, script);
else
script = "exit";
};
if(alloced_sz) {
cudaFree(alloced_tmp);
alloced_sz = 0;
};
while(!buffer_names.empty()) {
delete [] buffers[buffer_names.front()];
buffer_sizes.erase(buffer_names.front());
buffers.erase(buffer_names.front());
buffer_names.pop();
};
};
if(save_dict)
save_col_data(data_dict,"data.dictionary");
return 0;
}