Afternoon Larry & Ignacio,

I've updated the patch to use a .properties file and
to remove the dependency on shlwapi.dll (uses _splitpath/_makepath instead).
I also added a flag to indicate in the log what settings (properties or
registry) 
were being used.
Also brought the code style into line with the rest of the file (sorry).
The patch is now against the 1.6 revision in CVS (previously from the 3.2.3
distro)

It was a mission to create a minimal diff for this as the files in CVS have
a 
mix of DOS and Unix LFs. Had to do a manual merge to stop the editor
converting the LFs.

regards

tim

> -----Original Message-----
> From: Larry Isaacs [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, 8 September 2001 11:16
> To: 'Ignacio J. Ortega '
> Cc: ''[EMAIL PROTECTED]' '
> Subject: RE: PATCH: Multiple Tomcat 3.2 ISAPI redirectors on the one
> machi ne
> 
> 
> Hi, 
> 
> I'm replying directly because my posts from home hit the moderater and
> I don't way to annoy Craig. :)
> 
> I can see the need for this.  I would prefer to hack the string rather
> than add a dependency on shlwapi.dll.
> 
> Cheers,
> Larry
>  
> 
> -----Original Message-----
> From: Ignacio J. Ortega
> To: '[EMAIL PROTECTED]'
> Cc: '[EMAIL PROTECTED]'; 'Larry Isaacs'
> Sent: 9/7/01 4:42 PM
> Subject: RE: PATCH: Multiple Tomcat 3.2 ISAPI redirectors on 
> the one machi ne
> 
> Hola Tim:
> 
> I like this patch.. 
> 
> Larry can we include it for Tomcat 3.3 ?
> 
> I propose to change the file name from .ini to .properties..
> 
> And please send the patch following the guidelines at
> <http://jakarta.apache.org/site/source.html>..
> 
> Basically: 
> 
> * cvs diff -u 
> * As an attached file not inline 
> * follow the same code conventions used by the patched code .
> 
> 
> Saludos ,
> Ignacio J. Ortega
> 
> 
> > -----Mensaje original-----
> > De: Tim Whittington [mailto:[EMAIL PROTECTED]]
> > Enviado el: viernes 7 de septiembre de 2001 7:15
> > Para: '[EMAIL PROTECTED]'
> > Asunto: PATCH: Multiple Tomcat 3.2 ISAPI redirectors on the 
> > one machine
> > 
> > 
> > Afternoon tomcat-dev (It's late afternoon down here in New Zealand)
> > 
> > We have multiple applications that use the IIS ASAPI 
> > redirector to talk to 
> > Tomcat instances. They all get installed separately and its a 
> > pain in the 
> > arse to find the worker and worker mount files and merge in 
> > your settings
> > during installation.
> > So I've patched the ISAPI redirector to get the redirector to 
> > load it's 
> > properties from an ini file, with one ini file per filter.
> > 
> > It works like this :
> >     1) You install the ISAPI filter DLL in a virtual directory.
> >     2) In the same directory you put a properties file of 
> > the same name
> > (except for the extension)
> >             i.e. /jakarta/isapi_redirect.dll and
> > /jakarta/isapi_redirect.ini
> >     3) The ini file is a property file with exactly the 
> > same properties
> > as used to be put in the registry
> >     i.e.
> >     worker_file=C:\tomcat\conf\workers.properties
> >     worker_mount_file=C:\tomcat\conf\uriworkermap.properties
> >     log_level=error
> >     log_file=C:\tomcat\logs\isapi_redirector.log
> >     extension_uri=/jakarta/isapi_redirect.dll
> >     4) The filter loads this ini file and gets its settings from it.
> >     5) If the filter can't find the ini file it uses the 
> > registry (old
> > behaviour) == 1 ASAPI per machine.
> >     6) You can then install another filter, with another 
> > ini file, and
> > not have the two conflict.
> > diffs follow ....
> > 
> > One gotcha, the DLL needs shlwapi.dll for the 
> > PathRenameExtension (Ships in
> > IE 4.0)
> > If this is a problem then someone can hack the 
> ini_file_name string to
> > overwrite the file extension ...
> > Also a flag and DEBUG print to indicate whether the ini file 
> > is being used
> > could be useful ....
> > 
> > 
> > cheers
> > 
> > tim
> > 
> > -- src/native/iis/asapi.dsp ---
> > 56c56
> > < # ADD LINK32 wsock32.lib advapi32.lib /nologo /dll /machine:I386
> > /out:"isapi_release/isapi_redirect.dll"
> > ---
> > > # ADD LINK32 wsock32.lib advapi32.lib shlwapi.lib /nologo /dll
> > /machine:I386 /out:"isapi_release/isapi_redirect.dll"
> > 82c82
> > < # ADD LINK32 wsock32.lib advapi32.lib /nologo /dll /debug 
> > /machine:I386
> > /out:"isapi_debug/isapi_redirect.dll" /pdbtype:sept
> > ---
> > > # ADD LINK32 wsock32.lib advapi32.lib shlwapi.lib /nologo 
> > /dll /debug
> > /machine:I386 /out:"isapi_debug/isapi_redirect.dll" /pdbtype:sept
> > 
> > 
> > -- src/native/iis/jk_isapi_plugin.c ---
> > 
> > 61a62,66
> > > #include <stdio.h>
> > > #include <stdlib.h>
> > > #include <windows.h>
> > > #include <shlwapi.h>
> > > 
> > 121a127
> > > static char ini_file_name[_MAX_PATH];
> > 614a621,629
> > >   if( GetModuleFileName( hInst, ini_file_name, sizeof( 
> > ini_file_name )
> > ) ) {
> > >           if( !PathRenameExtension( ini_file_name, ".ini" ) ) {
> > >                   fReturn = FALSE;
> > >           }
> > >   } else {
> > >           fReturn = FALSE;
> > >   }
> > > 
> > > 
> > 621a637
> > > 
> > 628a645,651
> > >         jk_log(logger, JK_LOG_DEBUG, "Using log file 
> > %s.\n", log_file);
> > >         jk_log(logger, JK_LOG_DEBUG, "Using log level 
> > %d.\n", log_level);
> > >         jk_log(logger, JK_LOG_DEBUG, "Using extension uri %s.\n",
> > extension_uri);
> > >         jk_log(logger, JK_LOG_DEBUG, "Using worker file %s.\n",
> > worker_file);
> > >         jk_log(logger, JK_LOG_DEBUG, "Using worker mount 
> > file %s.\n",
> > worker_mount_file);
> > > 
> > > 
> > 668a692
> > >   char *tmp;
> > 669a694,735
> > >     
> > >   jk_map_t *map;
> > >   if( map_alloc( &map ) ) {
> > >           if( !map_read_properties( map, ini_file_name ) ) {
> > >                   ok = JK_FALSE;
> > >           }
> > >   } else {
> > >           ok = JK_FALSE;
> > >   }
> > >   if( ok ) {
> > >           tmp = map_get_string( map, JK_LOG_FILE_TAG, NULL );
> > >           if(tmp) {
> > >                   strcpy(log_file, tmp);
> > >           } else {
> > >                   ok = JK_FALSE;
> > >           }
> > >           tmp = map_get_string( map, JK_LOG_LEVEL_TAG, NULL );
> > >           if(tmp) {
> > >                   log_level = jk_parse_log_level(tmp);
> > >           } else {
> > >                   ok = JK_FALSE;
> > >           }
> > >           tmp = map_get_string( map, EXTENSION_URI_TAG, NULL );
> > >           if(tmp) {
> > >                   strcpy(extension_uri, tmp);
> > >           } else {
> > >                   ok = JK_FALSE;
> > >           }
> > >           tmp = map_get_string( map, JK_WORKER_FILE_TAG, NULL );
> > >           if(tmp) {
> > >                   strcpy(worker_file, tmp);
> > >           } else {
> > >                   ok = JK_FALSE;
> > >           }
> > >           tmp = map_get_string( map, JK_MOUNT_FILE_TAG, NULL );
> > >           if(tmp) {
> > >                   strcpy(worker_mount_file, tmp);
> > >           } else {
> > >                   ok = JK_FALSE;
> > >           }
> > >   
> > >   } else {
> > 725c791
> > < 
> > ---
> > >   }
> > 
> > 
> 

Index: jk_isapi_plugin.c
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat-connectors/jk/native/iis/jk_isapi_plugin.c,v
retrieving revision 1.6
diff -u -w -r1.6 jk_isapi_plugin.c
--- jk_isapi_plugin.c   2001/06/24 15:37:43     1.6
+++ jk_isapi_plugin.c   2001/09/10 02:07:19
@@ -125,6 +125,8 @@
 
 static char *SERVER_NAME = "SERVER_NAME";
 
+static char ini_file_name[MAX_PATH];
+static int using_ini_file = JK_FALSE;
 static int                                     is_inited       = JK_FALSE;
 static int                                     is_mapread      = JK_FALSE;
 static jk_uri_worker_map_t     *uw_map         = NULL; 
@@ -645,6 +647,10 @@
                     LPVOID lpReserved)      // Reserved parameter for future use
 {
     BOOL fReturn = TRUE;
+    char drive[_MAX_DRIVE];
+    char dir[_MAX_DIR];
+    char fname[_MAX_FNAME];
+    char file_name[_MAX_PATH];
 
     switch (ulReason) {
         case DLL_PROCESS_DETACH:
@@ -657,6 +663,12 @@
         default:
         break;
     } 
+    if (GetModuleFileName( hInst, file_name, sizeof(file_name))) {
+        _splitpath( file_name, drive, dir, fname, NULL );
+        _makepath( ini_file_name, drive, dir, fname, ".properties" );
+    } else {
+        fReturn = JK_FALSE;
+    }
 
     return fReturn;
 }
@@ -696,6 +708,16 @@
         }
     }
 
+    if (using_ini_file) {
+        jk_log(logger, JK_LOG_DEBUG, "Using ini file %s.\n", ini_file_name);
+    } else {
+        jk_log(logger, JK_LOG_DEBUG, "Using registry.\n");
+    }
+    jk_log(logger, JK_LOG_DEBUG, "Using log file %s.\n", log_file);
+    jk_log(logger, JK_LOG_DEBUG, "Using log level %d.\n", log_level);
+    jk_log(logger, JK_LOG_DEBUG, "Using extension uri %s.\n", extension_uri);
+    jk_log(logger, JK_LOG_DEBUG, "Using worker file %s.\n", worker_file);
+    jk_log(logger, JK_LOG_DEBUG, "Using worker mount file %s.\n", worker_mount_file);
        return rc;
 }
 
@@ -714,6 +736,51 @@
     HKEY hkey;
     long rc;
     int  ok = JK_TRUE;
+    char *tmp;
+    jk_map_t *map;
+
+    if (map_alloc(&map)) {
+        if (map_read_properties(map, ini_file_name)) {
+            using_ini_file = JK_TRUE;
+        } else {
+            ok = JK_FALSE;
+        }
+    } else {
+        ok = JK_FALSE;
+    }
+    if (ok) {
+        tmp = map_get_string(map, JK_LOG_FILE_TAG, NULL);
+        if (tmp) {
+            strcpy(log_file, tmp);
+        } else {
+            ok = JK_FALSE;
+        }
+        tmp = map_get_string(map, JK_LOG_LEVEL_TAG, NULL);
+        if (tmp) {
+            log_level = jk_parse_log_level(tmp);
+        } else {
+            ok = JK_FALSE;
+        }
+        tmp = map_get_string(map, EXTENSION_URI_TAG, NULL);
+        if (tmp) {
+            strcpy(extension_uri, tmp);
+        } else {
+            ok = JK_FALSE;
+        }
+        tmp = map_get_string(map, JK_WORKER_FILE_TAG, NULL);
+        if (tmp) {
+            strcpy(worker_file, tmp);
+        } else {
+            ok = JK_FALSE;
+        }
+        tmp = map_get_string(map, JK_MOUNT_FILE_TAG, NULL);
+        if (tmp) {
+            strcpy(worker_mount_file, tmp);
+        } else {
+            ok = JK_FALSE;
+        }
+    
+    } else {
     rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
                       REGISTRY_LOCATION,
                       (DWORD)0,         
@@ -769,7 +836,7 @@
     }
 
     RegCloseKey(hkey);
-
+    }    
     return ok;
 }
 

Reply via email to