costin 01/12/04 11:04:48 Modified: jk/native2/common jk_channel_socket.c jk_handler_logon.c jk_jni_worker.c Log: Use getStrProp / getIntProp, avoid duplicating the same lines n times in jk_util. We should eventually move to explicit bean-style getter/setter, but this can be done later. Update the structure names - now we have fewer names to remember :-) Revision Changes Path 1.3 +2 -3 jakarta-tomcat-connectors/jk/native2/common/jk_channel_socket.c Index: jk_channel_socket.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_channel_socket.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- jk_channel_socket.c 2001/12/02 01:05:25 1.2 +++ jk_channel_socket.c 2001/12/04 19:04:48 1.3 @@ -73,7 +73,6 @@ #include "jk_env.h" #include "jk_channel.h" #include "jk_global.h" -#include "jk_util.h" #include <string.h> @@ -149,8 +148,8 @@ short port=socketInfo->port; struct sockaddr_in *rc=&socketInfo->addr; - port = jk_get_worker_port(props, worker_name, port); - host = jk_get_worker_host(props, worker_name, host); + port = map_getIntProp( props, "worker", worker_name, "port", port ); + host = map_getStrProp( props, "worker", worker_name, "host", host); _this->worker=worker; _this->logger=l; 1.3 +3 -7 jakarta-tomcat-connectors/jk/native2/common/jk_handler_logon.c Index: jk_handler_logon.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_handler_logon.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- jk_handler_logon.c 2001/12/02 01:05:25 1.2 +++ jk_handler_logon.c 2001/12/04 19:04:48 1.3 @@ -58,16 +58,12 @@ /** * Description: AJP14 Login handler * Author: Henri Gomez <[EMAIL PROTECTED]> - * Version: $Revision: 1.2 $ + * Version: $Revision: 1.3 $ */ #include "jk_global.h" -#include "jk_context.h" #include "jk_pool.h" -#include "jk_util.h" #include "jk_msg_buff.h" -#include "jk_ajp_common.h" -#include "jk_ajp14.h" #include "jk_md5.h" #include "jk_logger.h" #include "jk_service.h" @@ -130,7 +126,7 @@ * * INIT + REPLY / NEGO + REPLY */ -static int handle_logon(ajp_endpoint_t *ae, +static int handle_logon(jk_endpoint_t *ae, jk_msg_buf_t *msg, jk_logger_t *l) { @@ -197,7 +193,7 @@ return JK_FALSE; } -int logon(ajp_endpoint_t *ae, +int logon(jk_endpoint_t *ae, jk_logger_t *l) { jk_pool_t *p = &ae->pool; 1.3 +102 -14 jakarta-tomcat-connectors/jk/native2/common/jk_jni_worker.c Index: jk_jni_worker.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_jni_worker.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- jk_jni_worker.c 2001/12/02 01:05:25 1.2 +++ jk_jni_worker.c 2001/12/04 19:04:48 1.3 @@ -59,7 +59,7 @@ * Description: In process JNI worker * * Author: Gal Shachor <[EMAIL PROTECTED]> * * Based on: * - * Version: $Revision: 1.2 $ * + * Version: $Revision: 1.3 $ * ***************************************************************************/ #if !defined(WIN32) && !defined(NETWARE) @@ -69,7 +69,6 @@ #include <jni.h> #include "jk_pool.h" -#include "jk_util.h" #include "jk_env.h" #if defined LINUX && defined APACHE2_SIGHACK @@ -256,6 +255,84 @@ } #endif + +char **jk_parse_sysprops(jk_pool_t *p, + const char *sysprops) +{ + char **rc = NULL; + + if(p && sysprops) { + char *prps = jk_pool_strdup(p, sysprops); + if(prps && strlen(prps)) { + unsigned num_of_prps; + + for(num_of_prps = 1; *sysprops ; sysprops++) { + if('*' == *sysprops) { + num_of_prps++; + } + } + + rc = jk_pool_alloc(p, (num_of_prps + 1) * sizeof(char *)); + if(rc) { + unsigned i = 0; + char *tmp = strtok(prps, "*"); + + while(tmp && i < num_of_prps) { + rc[i] = tmp; + tmp = strtok(NULL, "*"); + i++; + } + rc[i] = NULL; + } + } + } + + return rc; +} + + +int jk_file_exists(const char *f) +{ + if(f) { + struct stat st; + if((0 == stat(f, &st)) && (st.st_mode & S_IFREG)) { + return JK_TRUE; + } + } + return JK_FALSE; +} + + +void jk_append_libpath(jk_pool_t *p, + const char *libpath) +{ + char *env = NULL; + char *current = getenv(PATH_ENV_VARIABLE); + + if(current) { + env = jk_pool_alloc(p, strlen(PATH_ENV_VARIABLE) + + strlen(current) + + strlen(libpath) + 5); + if(env) { + sprintf(env, "%s=%s%c%s", + PATH_ENV_VARIABLE, + libpath, + PATH_SEPERATOR, + current); + } + } else { + env = jk_pool_alloc(p, strlen(PATH_ENV_VARIABLE) + + strlen(libpath) + 5); + if(env) { + sprintf(env, "%s=%s", PATH_ENV_VARIABLE, libpath); + } + } + + if(env) { + putenv(env); + } +} + static int JK_METHOD service(jk_endpoint_t *e, jk_ws_service_t *s, jk_logger_t *l, @@ -366,15 +443,18 @@ return JK_TRUE; } - if(jk_get_worker_mx(props, p->name, (unsigned int *)&mem_config)) { + mem_config= map_getIntProp( props, "worker", p->name, "mx", -1 ); + if( mem_config != -1 ) { p->tomcat_mx = mem_config; } - if(jk_get_worker_ms(props, p->name, (unsigned int *)&mem_config)) { + mem_config= map_getIntProp( props, "worker", p->name, "ms", -1 ); + if(mem_config != -1 ) { p->tomcat_ms = mem_config; } - if(jk_get_worker_classpath(props, p->name, &str_config)) { + str_config= map_getStrProp( props, "worker", p->name, "class_path", NULL ); + if(str_config != NULL ) { p->tomcat_classpath = jk_pool_strdup(&p->p, str_config); } @@ -383,7 +463,8 @@ return JK_FALSE; } - if(jk_get_worker_jvm_path(props, p->name, &str_config)) { + str_config= map_getStrProp( props, "worker", p->name, "jvm_lib", NULL ); + if(str_config != NULL ) { p->jvm_dll_path = jk_pool_strdup(&p->p, str_config); } @@ -392,33 +473,40 @@ return JK_FALSE; } - if(jk_get_worker_cmd_line(props, p->name, &str_config)) { + str_config= map_getStrProp( props, "worker", p->name, "cmd_line", NULL ); + if(str_config != NULL ) { p->tomcat_cmd_line = jk_pool_strdup(&p->p, str_config); } - if(jk_get_worker_stdout(props, p->name, &str_config)) { + str_config= map_getStrProp( props, "worker", p->name, "stdout", NULL ); + if(str_config!= NULL ) { p->stdout_name = jk_pool_strdup(&p->p, str_config); } - if(jk_get_worker_stderr(props, p->name, &str_config)) { + str_config= map_getStrProp( props, "worker", p->name, "stderr", NULL ); + if(str_config!= NULL ) { p->stderr_name = jk_pool_strdup(&p->p, str_config); } - if(jk_get_worker_sysprops(props, p->name, &str_config)) { + str_config= map_getStrProp( props, "worker", p->name, "sysprops", NULL ); + if(str_config!= NULL ) { p->sysprops = jk_parse_sysprops(&p->p, str_config); } #ifdef JNI_VERSION_1_2 - if(jk_get_worker_str_prop(props, p->name, "java2opts", &str_config)) { + str_config= map_getStrProp( props, "worker", p->name, "java2opts", NULL ); + if( str_config != NULL ) { /* l->jkLog(l, JK_LOG_DEBUG, "Got opts: %s\n", str_config); */ - p->java2opts = jk_parse_sysprops(&p->p, str_config); + p->java2opts = jk_parse_sysprops(&p->p, str_config); } - if(jk_get_worker_int_prop(props, p->name, "java2lax", &mem_config)) { + mem_config= map_getIntProp( props, "worker", p->name, "java2lax", -1 ); + if(mem_config != -1 ) { p->java2lax = mem_config ? JK_TRUE : JK_FALSE; } #endif - if(jk_get_worker_libpath(props, p->name, &str_config)) { + str_config= map_getStrProp( props, "worker", p->name, "ld_path", NULL ); + if(str_config!= NULL ) { jk_append_libpath(&p->p, str_config); }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>