From: nastytweety <di...@cs...> - 2006-03-04 19:08:17
|
Hello again. I am forwarding the following message and i want to ask if something like that described bellow is possible.Does swig support operations like file-handling.I guess that swig should support whatever operations described in JNI.Does anybody know anything on the subject?I have to present an example of file management using swig java bindings till tuesday.Any info or/and an IDL file would be great. Thanks Nikolaos Diakos ---------- Forwarded message ---------- Date: Fri, 3 Mar 2006 10:24:37 +0200 (EET) From: nastytweety <di...@cs...> To: swi...@li... Subject: [Swig-user] Question regarding file input output Hello all. I am trying to wrap the follow c code with java bindings. #include <stdio.h> struct st { int a; int b; int c; }; int writeBinary(const struct st,char* f); int readBinary(struct st *b,char* f); int main(int argc,char* argv[]) { int medium = 0; struct st myt, it; struct st *ptr; ptr = ⁢ myt.a = 1; myt.b = 2; myt.c = 3; if(writeBinary(myt,argv[1])) exit(1); if((medium = readBinary(ptr,argv[1]))==0) exit(1); myt.a = medium; myt.b=0; myt.c=0; printf("it.a: %d\n", it.a); printf("it.b: %d\n", it.b); if(writeBinary(myt,argv[2])) exit(1); } int writeBinary(const struct st j,char* f) { FILE *outFile; if(!(outFile = fopen(f, "w"))) return 1; fwrite(&j,sizeof(struct st),1,outFile); fclose(outFile); return 0; } int readBinary(struct st *b,char* f) { FILE *inFile; int x=0; if(!(inFile = fopen(f, "r"))) return 1; fread((struct st *)b,sizeof(struct st),1,inFile); x = b->a+b->b; x = x+b->c; x = x/3; fclose(inFile); return x; } Unfortunatelly i haven't made it. Can anyone give me an example of an IDL file wrapping the following code. I am only interested in java bindings. Thanks Nikolaos Diakos ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ Swig-user mailing list Swi...@li... https://lists.sourceforge.net/lists/listinfo/swig-user |