andya 01/06/27 12:13:32 Modified: jk/native/domino jk_dsapi_plugin.c Log: Fixed bizarre line end corruption. Must be something to do with using WinCVS in line end translation mode. Revision Changes Path 1.9 +199 -179 jakarta-tomcat-connectors/jk/native/domino/jk_dsapi_plugin.c Index: jk_dsapi_plugin.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/domino/jk_dsapi_plugin.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- jk_dsapi_plugin.c 2001/06/22 16:59:58 1.8 +++ jk_dsapi_plugin.c 2001/06/27 19:13:29 1.9 @@ -58,7 +58,7 @@ /*************************************************************************** * Description: DSAPI plugin for Lotus Domino * * Author: Andy Armstrong <[EMAIL PROTECTED]> * - * Version: $Revision: 1.8 $ * + * Version: $Revision: 1.9 $ * ***************************************************************************/ /* Based on the IIS redirector by Gal Shachor <[EMAIL PROTECTED]> */ @@ -100,7 +100,8 @@ #define VERSION "1.0.3" #define VERSION_STRING "Jakarta/DSAPI/" VERSION /* What we call ourselves */ -#define FILTERDESC "Apache Tomcat Interceptor (" VERSION_STRING ")" +#define FILTERDESC "Apache Tomcat Interceptor (" VERSION_STRING ")" + #define SERVERDFLT "Lotus Domino" /* Registry location of configuration data */ #define REGISTRY_LOCATION "Software\\Apache Software Foundation\\Jakarta Dsapi Redirector\\1.0" @@ -120,16 +121,19 @@ static jk_logger_t *logger = NULL; static int logLevel = JK_LOG_EMERG_LEVEL; -static jk_pool_t cfgPool; - +static jk_pool_t cfgPool; + + + static const char *logFile; static const char *workerFile; static const char *workerMountFile; static const char *tomcatStart; static const char *tomcatStop; - -#if defined(JK_VERSION) && JK_VERSION >= MAKEVERSION(1, 2, 0, 1) -static jk_worker_env_t worker_env; + + +#if defined(JK_VERSION) && JK_VERSION >= MAKEVERSION(1, 2, 0, 1) +static jk_worker_env_t worker_env; #endif static char *crlf = "\r\n"; @@ -260,73 +264,76 @@ printf("\n"); } #endif - -/* Get the value of a server (CGI) variable as a string - */ -static int GetVariable(private_ws_t *ws, char *hdrName, - char *buf, DWORD bufsz, char **dest, const char *dflt) -{ - int errID; - - if (ws->context->GetServerVariable(ws->context, hdrName, buf, bufsz, &errID)) - *dest = jk_pool_strdup(&ws->p, buf); - else - *dest = jk_pool_strdup(&ws->p, dflt); - - DEBUG(("%s = %s\n", hdrName, *dest)); - - return JK_TRUE; -} - -/* Get the value of a server (CGI) variable as an integer - */ -static int GetVariableInt(private_ws_t *ws, char *hdrName, - char *buf, DWORD bufsz, int *dest, int dflt) -{ - int errID; - - if (ws->context->GetServerVariable(ws->context, hdrName, buf, bufsz, &errID)) - *dest = atoi(buf); - else - *dest = dflt; - - DEBUG(("%s = %d\n", hdrName, *dest)); - - return JK_TRUE; -} -/* Get the value of a server (CGI) variable as an integer - */ -static int GetVariableBool(private_ws_t *ws, char *hdrName, - char *buf, DWORD bufsz, int *dest, int dflt) -{ - int errID; - - if (ws->context->GetServerVariable(ws->context, hdrName, buf, bufsz, &errID)) - { - if (isdigit(buf[0])) - *dest = atoi(buf) != 0; - else if (NoCaseStrCmp(buf, "yes") == 0 || NoCaseStrCmp(buf, "on") == 0) - *dest = 1; - else - *dest = 0; - } - else - { - *dest = dflt; - } - - DEBUG(("%s = %d\n", hdrName, *dest)); - - return JK_TRUE; -} - -/* A couple of utility macros to supply standard arguments to GetVariable() and - * GetVariableInt(). - */ -#define GETVARIABLE(name, dest, dflt) GetVariable(ws, (name), workBuf, sizeof(workBuf), (dest), (dflt)) -#define GETVARIABLEINT(name, dest, dflt) GetVariableInt(ws, (name), workBuf, sizeof(workBuf), (dest), (dflt)) -#define GETVARIABLEBOOL(name, dest, dflt) GetVariableBool(ws, (name), workBuf, sizeof(workBuf), (dest), (dflt)) + +/* Get the value of a server (CGI) variable as a string + + */ + +static int GetVariable(private_ws_t *ws, char *hdrName, + char *buf, DWORD bufsz, char **dest, const char *dflt) +{ + int errID; + + if (ws->context->GetServerVariable(ws->context, hdrName, buf, bufsz, &errID)) + *dest = jk_pool_strdup(&ws->p, buf); + else + *dest = jk_pool_strdup(&ws->p, dflt); + + DEBUG(("%s = %s\n", hdrName, *dest)); + + return JK_TRUE; +} + +/* Get the value of a server (CGI) variable as an integer + */ +static int GetVariableInt(private_ws_t *ws, char *hdrName, + char *buf, DWORD bufsz, int *dest, int dflt) +{ + int errID; + + if (ws->context->GetServerVariable(ws->context, hdrName, buf, bufsz, &errID)) + *dest = atoi(buf); + else + *dest = dflt; + + DEBUG(("%s = %d\n", hdrName, *dest)); + + return JK_TRUE; +} +/* Get the value of a server (CGI) variable as an integer + */ +static int GetVariableBool(private_ws_t *ws, char *hdrName, + char *buf, DWORD bufsz, int *dest, int dflt) +{ + int errID; + + if (ws->context->GetServerVariable(ws->context, hdrName, buf, bufsz, &errID)) + { + if (isdigit(buf[0])) + *dest = atoi(buf) != 0; + else if (NoCaseStrCmp(buf, "yes") == 0 || NoCaseStrCmp(buf, "on") == 0) + *dest = 1; + else + *dest = 0; + } + else + { + *dest = dflt; + } + + DEBUG(("%s = %d\n", hdrName, *dest)); + + return JK_TRUE; +} + +/* A couple of utility macros to supply standard arguments to GetVariable() and + * GetVariableInt(). + */ +#define GETVARIABLE(name, dest, dflt) GetVariable(ws, (name), workBuf, sizeof(workBuf), (dest), (dflt)) +#define GETVARIABLEINT(name, dest, dflt) GetVariableInt(ws, (name), workBuf, sizeof(workBuf), (dest), (dflt)) +#define GETVARIABLEBOOL(name, dest, dflt) GetVariableBool(ws, (name), workBuf, sizeof(workBuf), (dest), (dflt)) + /* Return 1 iff the supplied string contains "web-inf" (in any case * variation. We don't allow URIs containing web-inf, although * FindPathElem() actually looks for the string bounded by path punctuation @@ -439,7 +446,6 @@ jk_log(logger, JK_LOG_ERROR, "jk_ws_service_t::StartResponse, NULL parameters\n"); return JK_FALSE; - } static int JK_METHOD Read(jk_ws_service_t * s, void *bytes, unsigned len, unsigned *countp) @@ -542,8 +548,10 @@ wc_close(logger); if (logger) jk_close_file_logger(&logger); - - initDone = JK_FALSE; + + + initDone = JK_FALSE; + } if (NULL != tomcatStop && '\0' != *tomcatStop) @@ -558,7 +566,8 @@ return kFilterHandledEvent; } - + + /* Called when Domino loads the filter. Reads a load of config data from * the registry and elsewhere and displays a banner. */ @@ -836,35 +845,47 @@ GETVARIABLEINT("SERVER_PORT", &s->server_port, 80); GETVARIABLE("SERVER_SOFTWARE", &s->server_software, SERVERDFLT); GETVARIABLEINT("CONTENT_LENGTH", &s->content_length, 0); - - + /* SSL Support */ GETVARIABLEBOOL("HTTPS", &s->is_ssl, 0); - - if (ws->reqData->requestMethod < 0 || - ws->reqData->requestMethod >= sizeof(methodName) / sizeof(methodName[0])) - return JK_FALSE; - - s->method = methodName[ws->reqData->requestMethod]; - - s->headers_names = NULL; - s->headers_values = NULL; - s->num_headers = 0; + + if (ws->reqData->requestMethod < 0 || + + ws->reqData->requestMethod >= sizeof(methodName) / sizeof(methodName[0])) + + return JK_FALSE; + + + + s->method = methodName[ws->reqData->requestMethod]; + + + + s->headers_names = NULL; + + s->headers_values = NULL; + + s->num_headers = 0; + + s->ssl_cert_len = fr.clientCertLen; s->ssl_cert = fr.clientCert; s->ssl_cipher = NULL; /* required by Servlet 2.3 Api */ s->ssl_session = NULL; - -#if defined(JK_VERSION) && JK_VERSION >= MAKEVERSION(1, 2, 0, 1) - s->ssl_key_size = -1; /* required by Servlet 2.3 Api, added in jtc */ -#endif - - if (s->is_ssl) - { - int dummy; -#if 0 + + +#if defined(JK_VERSION) && JK_VERSION >= MAKEVERSION(1, 2, 0, 1) + s->ssl_key_size = -1; /* required by Servlet 2.3 Api, added in jtc */ +#endif + + if (s->is_ssl) + { + int dummy; + +#if 0 + char *sslNames[] = { "CERT_ISSUER", "CERT_SUBJECT", "CERT_COOKIE", "CERT_FLAGS", "CERT_SERIALNUMBER", @@ -876,24 +897,23 @@ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; - unsigned i, varCount = 0; -#endif +#endif DEBUG(("SSL request\n")); - -#if defined(JK_VERSION) && JK_VERSION >= MAKEVERSION(1, 2, 0, 1) - /* Read the variable into a dummy variable: we do this for the side effect of - * reading it into workBuf. - */ - GETVARIABLEINT("HTTPS_KEYSIZE", &dummy, 0); - if (workBuf[0] == '[') - s->ssl_key_size = atoi(workBuf+1); -#else - (void) dummy; -#endif - + +#if defined(JK_VERSION) && JK_VERSION >= MAKEVERSION(1, 2, 0, 1) + /* Read the variable into a dummy variable: we do this for the side effect of + * reading it into workBuf. + */ + GETVARIABLEINT("HTTPS_KEYSIZE", &dummy, 0); + if (workBuf[0] == '[') + s->ssl_key_size = atoi(workBuf+1); +#else + (void) dummy; +#endif + #if 0 for (i = 0; i < sizeof(sslNames)/sizeof(sslNames[0]); i++) { @@ -901,13 +921,13 @@ if (sslValues[i]) varCount++; } - /* Andy, some SSL vars must be mapped directly in s->ssl_cipher, - * ssl->session and s->ssl_key_size - * ie: - * Cipher could be "RC4-MD5" - * KeySize 128 (bits) - * SessionID a string containing the UniqID used in SSL dialogue - */ + /* Andy, some SSL vars must be mapped directly in s->ssl_cipher, + * ssl->session and s->ssl_key_size + * ie: + * Cipher could be "RC4-MD5" + * KeySize 128 (bits) + * SessionID a string containing the UniqID used in SSL dialogue + */ if (varCount > 0) { unsigned j; @@ -927,7 +947,8 @@ } s->num_attributes = varCount; } -#endif +#endif + } /* Duplicate all the headers now */ @@ -965,65 +986,64 @@ { char *uri = fr.URL; char *workerName, *qp; - - if (!initDone) - { - /* One time initialisation which is deferred so that we have the name of - * the server software to plug into worker_env - */ - int ok = JK_FALSE; - jk_map_t *map = NULL; - - DEBUG(("Initialising worker map\n")); - - if (map_alloc(&map)) - { - if (map_read_properties(map, workerMountFile)) - if (uri_worker_map_alloc(&uw_map, map, logger)) - ok = JK_TRUE; - map_free(&map); - } - - DEBUG(("Got the URI worker map\n")); - - if (ok) - { - ok = JK_FALSE; - DEBUG(("About to allocate map\n")); - if (map_alloc(&map)) - { - DEBUG(("About to read %s\n", workerFile)); - if (map_read_properties(map, workerFile)) - { -#if defined(JK_VERSION) && JK_VERSION >= MAKEVERSION(1, 2, 0, 1) - char server[256]; - - worker_env.uri_to_worker = uw_map; - if (context->GetServerVariable(context, "SERVER_SOFTWARE", server, sizeof(server)-1, &errID)) - worker_env.server_name = jk_pool_strdup(&cfgPool, server); - else - worker_env.server_name = SERVERDFLT; - - DEBUG(("Server name %s\n", worker_env.server_name)); - - if (wc_open(map, &worker_env, logger)) - ok = JK_TRUE; -#else - if (wc_open(map, logger)) - ok = JK_TRUE; -#endif - DEBUG(("OK = %d\n", ok)); - } - - DEBUG(("Read %s, OK = %d\n", workerFile, ok)); - map_free(&map); - } - } - - if (!ok) return kFilterError; - initDone = JK_TRUE; - } - + + if (!initDone) + { + /* One time initialisation which is deferred so that we have the name of + * the server software to plug into worker_env + */ + int ok = JK_FALSE; + jk_map_t *map = NULL; + + DEBUG(("Initialising worker map\n")); + + if (map_alloc(&map)) + { + if (map_read_properties(map, workerMountFile)) + if (uri_worker_map_alloc(&uw_map, map, logger)) + ok = JK_TRUE; + map_free(&map); + } + + DEBUG(("Got the URI worker map\n")); + + if (ok) + { + ok = JK_FALSE; + DEBUG(("About to allocate map\n")); + if (map_alloc(&map)) + { + DEBUG(("About to read %s\n", workerFile)); + if (map_read_properties(map, workerFile)) + { +#if defined(JK_VERSION) && JK_VERSION >= MAKEVERSION(1, 2, 0, 1) + char server[256]; + + worker_env.uri_to_worker = uw_map; + if (context->GetServerVariable(context, "SERVER_SOFTWARE", server, sizeof(server)-1, &errID)) + worker_env.server_name = jk_pool_strdup(&cfgPool, server); + else + worker_env.server_name = SERVERDFLT; + + DEBUG(("Server name %s\n", worker_env.server_name)); + + if (wc_open(map, &worker_env, logger)) + ok = JK_TRUE; +#else + if (wc_open(map, logger)) + ok = JK_TRUE; +#endif + DEBUG(("OK = %d\n", ok)); + } + + DEBUG(("Read %s, OK = %d\n", workerFile, ok)); + map_free(&map); + } + } + + if (!ok) return kFilterError; + initDone = JK_TRUE; + } if (qp = strchr(uri, '?'), qp != NULL) *qp = '\0'; workerName = map_uri_to_worker(uw_map, uri, logger);