commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject cvs commit: jakarta-commons-sandbox/daemon/src/native/nt/procrun procrun.c procrun.h
Date Thu, 01 May 2003 13:32:11 GMT
mturk       2003/05/01 06:32:11

  Modified:    daemon/src/native/nt/procrun procrun.c procrun.h
  Log:
  Search for JDK install directory and force setting the JDK/bin
  to childs PATH environment variable. This enables javac to be found.
  
  Revision  Changes    Path
  1.18      +62 -4     jakarta-commons-sandbox/daemon/src/native/nt/procrun/procrun.c
  
  Index: procrun.c
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/nt/procrun/procrun.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- procrun.c	28 Apr 2003 17:17:45 -0000	1.17
  +++ procrun.c	1 May 2003 13:32:11 -0000	1.18
  @@ -392,6 +392,10 @@
           len += strlen(envorg[n]) + 1;        
           cnt++;
       }
  +    if (proc->java.jpath) {
  +        len += strlen(proc->java.jpath) + 2;
  +        cnt++;
  +    }
       p = envp = (char *)pool_calloc(proc->pool, len + 1);
       if (!p)
           return NULL;
  @@ -405,6 +409,16 @@
           else if (STRN_COMPARE(envorg[n], PROCRUN_ENV_STDOUT)) {}
           else if (STRN_COMPARE(envorg[n], PROCRUN_ENV_STDERR)) {}
           else if (STRN_COMPARE(envorg[n], PROCRUN_ENV_PPID)) {}
  +        else if (STRNI_COMPARE(envorg[n], "PATH=") && 
  +                 proc->java.jpath) {
  +            tmp[cnt] = pool_calloc(proc->pool, strlen(envorg[n]) +
  +                                     strlen(proc->java.jpath) + 2);
  +            strcpy(tmp[cnt], envorg[n]);
  +            strcat(tmp[cnt], ";");
  +            strcat(tmp[cnt], proc->java.jpath);
  +            DBPRINTF1("New PATH %s", tmp[cnt]);
  +            ++cnt;
  +        }
           else
               tmp[cnt++] = envorg[n];
       }
  @@ -717,6 +731,49 @@
       return pool_strdup(proc->pool, jbin);
   } 
   
  +static char* procrun_guess_java_home(process_t *proc)
  +{
  +    HKEY hkjs;
  +    char jbin[MAX_PATH+1];
  +    char reg[MAX_PATH+1];
  +    char *cver;
  +    unsigned long err, klen = MAX_PATH;
  +    
  +    strcpy(reg, JAVAHOME_REGKEY);
  +    cver = &reg[sizeof(JAVAHOME_REGKEY)-1];
  +
  +    if ((err = RegOpenKeyEx(HKEY_LOCAL_MACHINE, reg,
  +                            0, KEY_READ, &hkjs)) != ERROR_SUCCESS) {
  +       DBPRINTF0("procrun_guess_jvm() failed to open Registry key\n");
  +       return NULL;
  +    }
  +    if ((err = RegQueryValueEx(hkjs, "CurrentVersion", NULL, NULL, 
  +                               (unsigned char *)cver,
  +                               &klen)) != ERROR_SUCCESS) {
  +        DBPRINTF0("procrun_guess_jvm() failed obtaining Current Java Version\n");
  +        RegCloseKey(hkjs);
  +        return NULL;
  +    }
  +    RegCloseKey(hkjs);
  +    
  +    if ((err = RegOpenKeyEx(HKEY_LOCAL_MACHINE, reg,
  +                            0, KEY_READ, &hkjs) ) != ERROR_SUCCESS) {
  +        DBPRINTF1("procrun_guess_jvm() failed to open Registry key %s\n", reg);
  +        return NULL;
  +    }
  +    klen = MAX_PATH;
  +    if ((err = RegQueryValueEx(hkjs, "JavaHome", NULL, NULL, 
  +                               (unsigned char *)jbin, 
  +                               &klen)) != ERROR_SUCCESS) {
  +        DBPRINTF0("procrun_guess_jvm() failed obtaining Runtime Library\n");
  +        RegCloseKey(hkjs);
  +        return NULL;
  +    }
  +    RegCloseKey(hkjs);
  +    strcat(jbin, "\\bin");
  +    return pool_strdup(proc->pool, jbin);
  +} 
  +
   static int procrun_service_params(process_t *proc)
   {
       HKEY key;
  @@ -955,11 +1012,13 @@
               else
                   proc->java.path = pool_strdup(proc->pool, jvm_path);
               if (strnicmp(jvm_path, "java", 4) == 0) {
  -                proc->java.jpath = procrun_guess_java(proc, jvm_path);
  +                proc->java.jbin = procrun_guess_java(proc, jvm_path);
  +                proc->java.jpath = procrun_guess_java_home(proc);
               }
           }
           DBPRINTF1("jvm dll path %s", proc->java.path);
           DBPRINTF1("java    path %s", proc->java.jpath);
  +        DBPRINTF1("java    bin  %s", proc->java.jbin);
           if (!proc->java.path || !proc->java.start_method)
               return -1;
           /* Try to load the jvm dll */ 
  @@ -1463,7 +1522,7 @@
       DBPRINTF1("Creating process %s.\n", program);
       DBPRINTF1("Creating process %s.\n", env->m->argw);
       /* for java.exe merge Arguments and Java options */
  -    if (env->m->java.jpath) {
  +    if (env->m->java.jbin) {
           int i, j, len = strlen(env->m->argw) + 8192;
           char *opts[64], *nargw;
   
  @@ -1494,7 +1553,7 @@
               strcat(nargw, env->m->java.start_param);
           }
           env->m->argw = nargw;
  -        program = env->m->java.jpath;
  +        program = env->m->java.jbin;
       }
       DBPRINTF2("RUN [%s] %s\n", program, env->m->argw);
       if (env->m->service.account && env->m->service.password &&
  @@ -2546,7 +2605,6 @@
       g_proc_mode = PROCRUN_MODE_WINAPP;
       g_env = env;
       ac_instance = hInstance;
  -
       rv = procrun_main(__argc, __argv, _environ, env);
   
       free_environment(env);
  
  
  
  1.16      +2 -0      jakarta-commons-sandbox/daemon/src/native/nt/procrun/procrun.h
  
  Index: procrun.h
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/nt/procrun/procrun.h,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- procrun.h	28 Apr 2003 17:25:39 -0000	1.15
  +++ procrun.h	1 May 2003 13:32:11 -0000	1.16
  @@ -175,6 +175,7 @@
   #define PROCRUN_REGKEY_RPARAMS      PROCRUN_REGKEY_ROOT "\\%s\\Parameters"
   
   #define JAVASOFT_REGKEY             "SOFTWARE\\JavaSoft\\Java Runtime Environment\\"
  +#define JAVAHOME_REGKEY             "SOFTWARE\\JavaSoft\\Java Development Kit\\"
    
   #define PROCRUN_PARAMS_DISPLAY      "DisplayName"
   #define PROCRUN_PARAMS_IMAGE        "ImagePath"
  @@ -279,6 +280,7 @@
       struct java_t {
           char         *path;
           char         *jpath;
  +        char         *jbin;
           char         *start_class;
           char         *stop_class;
           HMODULE      dll;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message