Building RAR Expander - A first post

Ben Fowler
2005-02-05
2013-05-08
  • Ben Fowler
    Ben Fowler
    2005-02-05

    On the simple basis posting a message without a patch is
    a bit like travelling on a bus without a ticket, here is basically a note that unrar.c (C source code) contains a
    line of C++. To fix this on my system, I have applied this
    patch.

    Index: UnRAR JNI Layer/unrar.c

    RCS file: /cvsroot/rarexpander/RAR_Expander/UnRAR JNI Layer/unrar.c,v
    retrieving revision 1.3
    diff -U8 -r1.3 unrar.c
    --- UnRAR JNI Layer/unrar.c    7 Jan 2005 23:26:46 -0000    1.3
    +++ UnRAR JNI Layer/unrar.c    5 Feb 2005 09:58:59 -0000
    @@ -165,24 +165,25 @@
    int processData(JNIEnv *current_env, jobject current_obj, unsigned char * block, int size) {
         incrementCurrentUncompressedSize(current_env, current_obj, (long) size);
         return CONTINUE_PROCESSING;
    }

    int needPassword(JNIEnv *current_env, jobject current_obj, char * passwordBuffer, int bufferSize) {
         int length;
         const char * passwordUtf;
    +    jstring passwordJstring;
         jclass cls = (*current_env)->GetObjectClass(current_env, current_obj);
         jmethodID mid = (*current_env)->GetMethodID(current_env, cls, "requestPassword", "()Ljava/lang/String;");
         if (mid == 0) {
             fprintf(stderr, "Could not find method id for requestPassword\n");
             passwordBuffer[0] = 0;
             return STOP_PROCESSING;
         }
    -    jstring passwordJstring = (*current_env)->CallObjectMethod(current_env, current_obj, mid);
    +    passwordJstring = (*current_env)->CallObjectMethod(current_env, current_obj, mid);
         length = (*current_env)->GetStringUTFLength(current_env, passwordJstring);
         if(length == 0 || length >= bufferSize) {
             passwordBuffer[0] = 0;
             return STOP_PROCESSING;
         } else {
             passwordUtf  = (*current_env)->GetStringUTFChars(current_env, passwordJstring, JNI_FALSE);
             strcpy(passwordBuffer, passwordUtf);
             (*current_env)->ReleaseStringUTFChars(current_env, passwordJstring, passwordUtf);               

    I am not claiming that this is either right or the best fix,
    but it does compile.

     
    • Kris Gybels
      Kris Gybels
      2005-03-30

      Sorry about the late reply, I wasn't monitoring this forum so it took me a while to notice this post. I should probably just change the file to have extension .cpp instead of .c ... I'm curious though: did you actually experience a problem building the application without the patch on your system?