Changeset 1552 for trunk/bindings
- Timestamp:
- 07/10/10 03:38:14 (20 months ago)
- File:
-
- 1 edited
-
trunk/bindings/java/native/NexusFile.c (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bindings/java/native/NexusFile.c
r1543 r1552 37 37 the integer first before it can do useful work. 38 38 39 40 39 */ 41 40 #include <stdlib.h> … … 53 52 #endif 54 53 55 //#define DEBUG 56 #ifdef DEBUG 57 static FILE *fd = NULL; 58 #endif 59 60 static jclass nexusException; // Global variable 54 #define DEBUG 55 61 56 static JavaVM *jvm; // Global variable 62 57 63 58 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { 64 59 JNIEnv *env; 60 jclass nexusException; 65 61 66 62 jint ret = (*vm)->GetEnv(vm, (void **)&env, JNI_VERSION_1_1); … … 68 64 assert(ret == JNI_OK); 69 65 70 // Find and store the NexusException class for use in JapiError 66 jvm = vm; 67 71 68 nexusException = (*env)->FindClass(env,"org/nexusformat/NexusException"); 72 assert(nexusException); 73 74 jvm = vm; 69 if (nexusException) { 70 fprintf(stderr, "cannot find NexusException - this will not work. Terminating."); 71 assert(nexusException); 72 } 75 73 76 74 return JNI_VERSION_1_1; … … 84 82 --------------------------------------------------------------------------*/ 85 83 static void JapiError(void *pData, char *text) { 86 // better ignore the env passed in via pData, it is unsafe due to #21987 JNIEnv *env;84 JNIEnv *env = pData; 85 jclass nexusException; 88 86 89 87 #ifdef DEBUG 90 fprintf( fd,"JapiError called with: %s\n", text);91 #endif 92 93 (*jvm)->AttachCurrentThread (jvm, (void **) &env, NULL);88 fprintf(stderr,"JapiError called with: %s\n", text); 89 #endif 90 91 /* (*jvm)->AttachCurrentThread (jvm, (void **) &env, NULL); */ 94 92 95 93 if (env == NULL) { … … 98 96 } 99 97 98 // Find and store the NexusException class for use in JapiError 99 nexusException = (*env)->FindClass(env,"org/nexusformat/NexusException"); 100 100 (*env)->ThrowNew(env, nexusException, text); 101 101 } … … 111 111 int iRet; 112 112 113 #ifdef DEBUG114 if(fd == NULL)115 {116 fd = fopen("jnexusdebug.dat","w");117 }118 #endif119 113 /* set error handler */ 120 114 NXMSetTError(env,JapiError); 121 115 122 116 /* extract the filename as a C char* */ 123 fileName = (char *) (*env)->GetStringUTFChars(env, filename,0);117 fileName = (char *) (*env)->GetStringUTFChars(env, filename, 0); 124 118 125 119 /* call NXopen */ 126 120 #ifdef DEBUG 127 fprintf( fd,"Calling NXopen on %s, with %d\n", fileName,access);121 fprintf(stderr,"Calling NXopen on %s, with %d\n", fileName, access); 128 122 #endif 129 123 iRet = NXopen(fileName,access,&handle); 130 124 131 125 #ifdef DEBUG 132 fprintf( fd,"Handle %d allocated for %s\n", handle, fileName);126 fprintf(stderr,"Handle allocated for %s\n", fileName); 133 127 #endif 134 128 … … 163 157 HHRemoveHandle(handle); 164 158 165 166 159 /* call NXflush */ 167 160 iRet = NXflush(&nxhandle); … … 191 184 nxhandle = (NXhandle)HHGetPointer(handle); 192 185 #ifdef DEBUG 193 fprintf( fd,"closing handle %d, nxhandle %d\n", handle, nxhandle);186 fprintf(stderr,"closing handle %d, nxhandle %d\n", handle, nxhandle); 194 187 #endif 195 188 … … 251 244 if(iRet != NX_OK) 252 245 { 253 fprintf( fd,"Cleanup code called after raising Exception\n");246 fprintf(stderr,"Cleanup code called after raising Exception\n"); 254 247 } 255 248 #endif … … 282 275 if(iRet != NX_OK) 283 276 { 284 fprintf( fd,"Cleanup code called after raising Exception\n");277 fprintf(stderr,"Cleanup code called after raising Exception\n"); 285 278 } 286 279 #endif … … 312 305 if(iRet != NX_OK) 313 306 { 314 fprintf( fd,"Cleanup code called after raising Exception\n");307 fprintf(stderr,"Cleanup code called after raising Exception\n"); 315 308 } 316 309 #endif … … 480 473 481 474 #ifdef DEBUG 482 fprintf( fd,"Compressing at %d with type %d\n", nxhandle, comp_type);475 fprintf(stderr,"Compressing at %d with type %d\n", nxhandle, comp_type); 483 476 #endif 484 477 iRet = NXcompress(nxhandle,comp_type); … … 510 503 if(iRet != NX_OK) 511 504 { 512 HEprint( fd,0);505 HEprint(stderr,0); 513 506 } 514 507 #endif … … 626 619 if(iRet != NX_OK) 627 620 { 628 HEprint( fd,0);621 HEprint(stderr,0); 629 622 } 630 623 #endif … … 686 679 iargs = (*env)->GetIntArrayElements(env,args,0); 687 680 #ifdef DEBUG 688 fprintf( fd,"nxgetattr converted types \n");681 fprintf(stderr,"nxgetattr converted types \n"); 689 682 #endif 690 683 … … 692 685 iType = iargs[1]; 693 686 #ifdef DEBUG 694 fprintf( fd,"nxgetattr: iLen %d, iType: %d\n",iLen, iType);687 fprintf(stderr,"nxgetattr: iLen %d, iType: %d\n",iLen, iType); 695 688 #endif 696 689 … … 699 692 iargs[1] = iType; 700 693 #ifdef DEBUG 701 fprintf( fd,"nxgetattr cleaning up \n");694 fprintf(stderr,"nxgetattr cleaning up \n"); 702 695 #endif 703 696 … … 1310 1303 } 1311 1304 } 1312 1313 1314 1315 1316 1317 1318 1319 1320
Note: See TracChangeset
for help on using the changeset viewer.
