Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@jakarta.apache.org Received: (qmail 34358 invoked by uid 500); 13 Sep 2001 01:15:51 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: tomcat-dev@jakarta.apache.org Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 34348 invoked by uid 500); 13 Sep 2001 01:15:51 -0000 Delivered-To: apmail-jakarta-tomcat-cvs@apache.org Date: 13 Sep 2001 01:11:25 -0000 Message-ID: <20010913011125.72221.qmail@icarus.apache.org> From: nacho@apache.org To: jakarta-tomcat-cvs@apache.org Subject: cvs commit: jakarta-tomcat/src/native/mod_jk/iis jk_isapi_plugin.c X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N nacho 01/09/12 18:11:25 Modified: src/native/mod_jk/iis jk_isapi_plugin.c Log: With this patch the ISAPI redirector can load it's initial config from a properties file situated in the same virtual dir where the isapi_redirect.dll lies. This patch allows to have multiple Tomcat instances serving various IIS virtual servers be configured in easy way. 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.properties 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 ISAPI per machine. 6) You can then install another filter, with another ini file, and not have the two conflict. Submitted by Tim Whittington [Tim.Whittington at orion.co.nz] Revision Changes Path 1.5 +119 -53 jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c Index: jk_isapi_plugin.c =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- jk_isapi_plugin.c 2001/09/13 00:07:39 1.4 +++ jk_isapi_plugin.c 2001/09/13 01:11:25 1.5 @@ -57,7 +57,7 @@ * Description: ISAPI plugin for IIS/PWS * * Author: Gal Shachor * * Author: Ignacio J. Ortega * - * Version: $Revision: 1.4 $ * + * Version: $Revision: 1.5 $ * ***************************************************************************/ #include @@ -121,6 +121,8 @@ } \ }\ +static char ini_file_name[MAX_PATH]; +static int using_ini_file = JK_FALSE; static int is_inited = JK_FALSE; static jk_uri_worker_map_t *uw_map = NULL; static jk_logger_t *logger = NULL; @@ -615,6 +617,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: @@ -627,6 +633,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; } @@ -638,6 +650,19 @@ if(read_registry_init_data()) { jk_map_t *map; + /* Logging the initialization type: registry or properties file in virtual dir + */ + 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); + if(!jk_open_file_logger(&logger, log_file, log_level)) { logger = NULL; } @@ -677,62 +702,103 @@ HKEY hkey; long rc; int ok = JK_TRUE; - rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, - REGISTRY_LOCATION, - (DWORD)0, - KEY_READ, - &hkey); - if(ERROR_SUCCESS != rc) { - return JK_FALSE; - } + char *tmp; + jk_map_t *map; - if(get_registry_config_parameter(hkey, - JK_LOG_FILE_TAG, - tmpbuf, - sizeof(log_file))) { - strcpy(log_file, tmpbuf); - } else { - ok = JK_FALSE; - } + if (map_alloc(&map)) { + if (map_read_properties(map, ini_file_name)) { + using_ini_file = JK_TRUE; + } + } + if (using_ini_file) { + 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; + } - if(get_registry_config_parameter(hkey, - JK_LOG_LEVEL_TAG, - tmpbuf, - sizeof(tmpbuf))) { - log_level = jk_parse_log_level(tmpbuf); } else { - ok = JK_FALSE; - } - - if(get_registry_config_parameter(hkey, - EXTENSION_URI_TAG, - tmpbuf, - sizeof(extension_uri))) { - strcpy(extension_uri, tmpbuf); - } else { - ok = JK_FALSE; - } - - if(get_registry_config_parameter(hkey, - JK_WORKER_FILE_TAG, - tmpbuf, - sizeof(worker_file))) { - strcpy(worker_file, tmpbuf); - } else { - ok = JK_FALSE; - } - - if(get_registry_config_parameter(hkey, - JK_MOUNT_FILE_TAG, - tmpbuf, - sizeof(worker_mount_file))) { - strcpy(worker_mount_file, tmpbuf); - } else { - ok = JK_FALSE; - } - - RegCloseKey(hkey); + rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, + REGISTRY_LOCATION, + (DWORD)0, + KEY_READ, + &hkey); + if(ERROR_SUCCESS != rc) { + return JK_FALSE; + } + + if(get_registry_config_parameter(hkey, + JK_LOG_FILE_TAG, + tmpbuf, + sizeof(log_file))) { + strcpy(log_file, tmpbuf); + } else { + ok = JK_FALSE; + } + + if(get_registry_config_parameter(hkey, + JK_LOG_LEVEL_TAG, + tmpbuf, + sizeof(tmpbuf))) { + log_level = jk_parse_log_level(tmpbuf); + } else { + ok = JK_FALSE; + } + + if(get_registry_config_parameter(hkey, + EXTENSION_URI_TAG, + tmpbuf, + sizeof(extension_uri))) { + strcpy(extension_uri, tmpbuf); + } else { + ok = JK_FALSE; + } + + if(get_registry_config_parameter(hkey, + JK_WORKER_FILE_TAG, + tmpbuf, + sizeof(worker_file))) { + strcpy(worker_file, tmpbuf); + } else { + ok = JK_FALSE; + } + + if(get_registry_config_parameter(hkey, + JK_MOUNT_FILE_TAG, + tmpbuf, + sizeof(worker_mount_file))) { + strcpy(worker_mount_file, tmpbuf); + } else { + ok = JK_FALSE; + } + RegCloseKey(hkey); + } return ok; }