7 messages in net.java.dev.jna.usersRe: [jna-users] Reading back function...
FromSent OnAttachments
Bob LittleOct 13, 2008 1:34 pm 
Michael WhiteOct 13, 2008 3:34 pm 
Timothy WallOct 13, 2008 5:11 pm 
Bob LittleOct 14, 2008 7:07 pm 
Timothy WallOct 14, 2008 8:03 pm 
Bob LittleOct 15, 2008 6:18 am 
Timothy WallOct 15, 2008 6:45 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] Reading back function argumentsActions...
From:Bob Little (rlit@webfrontdevelopment.com)
Date:Oct 14, 2008 7:07:50 pm
List:net.java.dev.jna.users

Sorry, I have not explained very well. Let me try to correct that. I am only a novice C programmer, so please bear with me.

Here is what I have, and what I have done to test:

/* Original C Code definition */ void QMCall(char * subrname, short int argc, ...)

/* My Java Interface */ public void QMCall(String, String, String, String);

/* Java Implementation */ public void QMCall(String subName, String in, String out, String err) { System.out.println("Inside method, calling lib function with:"); System.out.println("in="+in+", out="+out+", err="+err); /* Call the native library function */ QM.INSTANCE.QMCall(subName,3,in,out,err); System.out.println("Inside method, returned from library function:"); System.out.println("in="+in+", out="+out+", err="+err); return; }

I set up a test class:

public class qmtest { public static void main(String[] args) { int ok; QMLib qm=new QMLib(); ok=qm.QMConnect("localhost",-1,"qmuser","qmuser999","QMUSERS"); String subName="TEST"; String iList=new String("1"); String oList=new String("2"); String eList=new String("3"); System.out.println("Invoking method qm.QMCall"); qm.QMCall(subName,iList,oList,eList); System.out.println("Returned from method qm.QMCall:"); System.out.print("iList="+iList); System.out.print(" oList="+oList); System.out.println(" eList="+eList); } }

/* the database subroutine being called... */ LIST.ITEM BP TEST Page 1 TEST 001: SUBROUTINE(I.LIST,O.LIST,E.LIST) 002: OPEN 'RDL.TMP' TO RDL.TMP.FILE THEN 003: REC=I.LIST:" , ":O.LIST:", ":E.LIST 004: WRITE REC ON RDL.TMP.FILE,'TEST.ARGUMENTS' 005: END 006: I.LIST="IN" 007: O.LIST="OUT" 008: E.LIST="ERR" 009: RETURN 010: END :

The above subroutine "TEST" takes the 3 arguments, implicitly sets their values to "IN", "OUT", and "ERR" and returns them. As such, the values of in, out and err should be changed from 1,2,3 to IN, OUT, ERR. To verify that the subroutine is in fact being called, I open a file and write the arguments out to it.

java qmtest Invoking method qm.QMCall Inside method, calling lib function with: in=1, out=2, err=3 Inside method, returned from library function: in=1, out=2, err=3 Returned from method: iList=1 oList=2 eList=3

I was expecting iList=IN oList=OUT eList=ERR

The database sub routine is being called correctly, and is getting the right values: LIST.ITEM RDL.TMP Page 1 TEST.ARGUMENTS 001: 1 , 2, 3

I hope this explanation has enough information, and that it makes sense.

-bob

Timothy Wall wrote:

On Oct 13, 2008, at 4:34 PM, Bob Little wrote:

Hello,

I need to invoke a C function having this signature:

void functionName(char* subroutineName ,short argc, char* argv...)

This calls a database subroutine which in turn modifies the arguments in the argv list it is passed.

Assuming you actually mean

char* argv[]

then if you pass a String[] any modifications made by the callee will be reflected in the original argument.