andya 2003/11/13 09:11:36 Added: jk/native2/server/dsapi/test test.dsp test.c printf_logger.c Log: First release of JK2 Domino redirector. Barely tested. Revision Changes Path 1.1 jakarta-tomcat-connectors/jk/native2/server/dsapi/test/test.dsp Index: test.dsp =================================================================== # Microsoft Developer Studio Project File - Name="test" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=test - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "test.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "test.mak" CFG="test - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "test - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "test - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "test - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /I ".." /I "..\..\..\include" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /I "..\..\..\..\..\..\apr\include" /I "..\..\..\..\..\..\apr-util\include" /I "..\..\..\..\..\..\pcre\include" /I "$(NOTESAPI)\include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_USRDLL" /D "HAVE_JNI" /D "HAS_APR" /D "HAS_PCRE" /D "NT" /D "TESTING" /U "NOUSER" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x809 /d "NDEBUG" # ADD RSC /l 0x809 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libapr.lib libaprutil.lib ws2_32.lib wsock32.lib pcre.lib pcreposix.lib notes.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\..\..\..\apr\Release" /libpath:"..\..\..\..\..\..\pcre\lib" /libpath:"..\..\..\..\..\..\apr-util\Release" /libpath:"$(NOTESAPI)\lib\mswin32" !ELSEIF "$(CFG)" == "test - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I ".." /I "..\..\..\include" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /I "..\..\..\..\..\..\apr\include" /I "..\..\..\..\..\..\apr-util\include" /I "..\..\..\..\..\..\pcre\include" /I "$(NOTESAPI)\include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_USRDLL" /D "HAVE_JNI" /D "HAS_APR" /D "HAS_PCRE" /D "NT" /D "TESTING" /D "NO_CAPI" /U "NOUSER" /FR /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x809 /d "_DEBUG" # ADD RSC /l 0x809 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libapr.lib libaprutil.lib ws2_32.lib wsock32.lib pcre.lib pcreposix.lib notes.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\..\..\..\apr\Release" /libpath:"..\..\..\..\..\..\pcre\lib" /libpath:"..\..\..\..\..\..\apr-util\Release" /libpath:"$(NOTESAPI)\lib\mswin32" !ENDIF # Begin Target # Name "test - Win32 Release" # Name "test - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Group "JK2 Common Source" # PROP Default_Filter "" # Begin Source File SOURCE=..\..\..\common\jk_channel.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_channel_apr_socket.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_channel_jni.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_channel_un.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_config.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_config_file.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_endpoint.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_env.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_handler_logon.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_handler_response.c # End Source File # Begin Source File SOURCE=..\..\..\jni\jk_jni_aprImpl.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_logger_file.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_logger_win32.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_map.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_md5.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_msg_ajp.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_mutex.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_mutex_proc.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_mutex_thread.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_nwmain.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_objCache.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_pool_apr.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_registry.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_requtil.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_shm.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_signal.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_uriEnv.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_uriMap.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_user.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_vm_default.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_worker_ajp13.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_worker_jni.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_worker_lb.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_worker_run.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_worker_status.c # End Source File # Begin Source File SOURCE=..\..\..\common\jk_workerEnv.c # End Source File # End Group # Begin Group "DSAPI Source" # PROP Default_Filter "" # Begin Source File SOURCE=..\jk_dsapi_plugin.c # End Source File # End Group # Begin Source File SOURCE=.\printf_logger.c # End Source File # Begin Source File SOURCE=.\test.c # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Group "JK2 Common Headers" # PROP Default_Filter "" # Begin Source File SOURCE=..\..\..\include\jk_channel.h # End Source File # Begin Source File SOURCE=..\..\..\include\jk_config.h # End Source File # Begin Source File SOURCE=..\..\..\include\jk_endpoint.h # End Source File # Begin Source File SOURCE=..\..\..\include\jk_env.h # End Source File # Begin Source File SOURCE=..\..\..\include\jk_global.h # End Source File # Begin Source File SOURCE=..\..\..\include\jk_handler.h # End Source File # Begin Source File SOURCE=..\..\..\include\jk_logger.h # End Source File # Begin Source File SOURCE=..\..\..\common\jk_logger_win32_message.h # End Source File # Begin Source File SOURCE=..\..\..\include\jk_map.h # End Source File # Begin Source File SOURCE=..\..\..\include\jk_md5.h # End Source File # Begin Source File SOURCE=..\..\..\include\jk_msg.h # End Source File # Begin Source File SOURCE=..\..\..\include\jk_objCache.h # End Source File # Begin Source File SOURCE=..\..\..\include\jk_pool.h # End Source File # Begin Source File SOURCE=..\..\..\common\jk_registry.h # End Source File # Begin Source File SOURCE=..\..\..\include\jk_requtil.h # End Source File # Begin Source File SOURCE=..\..\..\include\jk_service.h # End Source File # Begin Source File SOURCE=..\..\..\include\jk_shm.h # End Source File # Begin Source File SOURCE=..\..\..\include\jk_uriEnv.h # End Source File # Begin Source File SOURCE=..\..\..\include\jk_uriMap.h # End Source File # Begin Source File SOURCE=..\..\..\include\jk_vm.h # End Source File # Begin Source File SOURCE=..\..\..\include\jk_worker.h # End Source File # Begin Source File SOURCE=..\..\..\include\jk_workerEnv.h # End Source File # Begin Source File SOURCE=..\..\..\jni\org_apache_jk_apr_AprImpl.h # End Source File # End Group # Begin Group "DSAPI Headers" # PROP Default_Filter "" # Begin Source File SOURCE=..\config.h # End Source File # Begin Source File SOURCE=..\dsapifilter.h # End Source File # End Group # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # Begin Source File SOURCE=..\..\..\common\jk_logger_win32_message.mc # End Source File # Begin Source File SOURCE=..\..\..\common\jk_logger_win32_message.rc # End Source File # End Group # End Target # End Project 1.1 jakarta-tomcat-connectors/jk/native2/server/dsapi/test/test.c Index: test.c =================================================================== /* test.c */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include "config.h" #include "dsapifilter.h" unsigned int FilterInit(FilterInitData *filterInitData); unsigned int TerminateFilter(unsigned int reserved); unsigned int HttpFilterProc(FilterContext *context, unsigned int eventType, void *eventData); void TestMain(void); #define SERVER "localhost" #define PORT "80" #define URI "/examples/jsp/num/numguess.jsp" #define VERSION "1.1" typedef struct _ServerContext { char *rq; char *hdrs; } ServerContext; /* FilterContext functions */ static int fcGetRequest(struct _FilterContext *context, FilterRequest *fr, unsigned int *errID) { printf("fc.GetRequest(%p, %p, %p)\n", context, fr, errID); fr->method = kRequestGET; fr->URL = URI; fr->version = VERSION; fr->userName = NULL; fr->password = NULL; fr->clientCert = NULL; fr->clientCertLen = 0; fr->contentRead = NULL; fr->contentReadLen = 0; return 1; } static int fcGetRequestContents(struct _FilterContext *context, char **contents, unsigned int *errID) { ServerContext *sc = (ServerContext *) context->serverContext; printf("fc.GetRequestContents(%p, %p, %p)\n", context, contents, errID); *contents = sc->rq; return strlen(sc->rq) + 1; } static int fcGetServerVariable(struct _FilterContext *context, char *name, void *buffer, unsigned int bufferSize, unsigned int *errID) { printf("fc.GetServerVariable(%p, \"%s\", %p, %u, %p)\n", context, name, buffer, bufferSize, errID); if (strcmp(name, "SERVER_NAME") == 0) { strcpy((char *) buffer, SERVER); } else if (strcmp(name, "SERVER_PORT") == 0) { strcpy((char *) buffer, PORT); } else if (strcmp(name, "SERVER_PROTOCOL") == 0) { strcpy((char *) buffer, "HTTP/" VERSION); } else if (strcmp(name, "REMOTE_ADDR") == 0) { strcpy((char *) buffer, "127.0.0.1"); } else if (strcmp(name, "SERVER_SOFTWARE") == 0) { strcpy((char *) buffer, "TestHarness 1.0"); } else { return 0; } return 1; } static int fcWriteClient(struct _FilterContext * context, char *buffer, unsigned int bufferLen, unsigned int reserved, unsigned int *errID) { /* printf("fc.WriteClient(%p, %p, %u, %u, %p)\n", context, buffer, bufferLen, reserved, errID); */ while (bufferLen > 0) { fputc(*buffer++, stdout); bufferLen--; } return 1; } static void *fcAllocMem(struct _FilterContext *context, unsigned int size, unsigned int reserved, unsigned int *errID) { printf("fc.AllocMem(%p, %d, %d, %p)\n", context, size, reserved, errID); return malloc(size); } static int fcServerSupport(struct _FilterContext *context, unsigned int funcType, void *data1, void *data2, unsigned int other, unsigned int *errID) { if (funcType == kWriteResponseHeaders) { FilterResponseHeaders *frh = (FilterResponseHeaders *) data1; printf("%d %s\n%s\n", frh->responseCode, frh->reasonText, frh->headerText); return 1; } else { printf("fc.ServerSupport(%p, %u, %p, %p, %u, %p)\n", context, funcType, data1, data2, other, errID); return 0; } } static int fprGetAllHeaders(FilterContext *context, char **headers, unsigned int *errID) { ServerContext *sc = (ServerContext *) context->serverContext; printf("fpr.GetAllHeaders(%p, %p, %p)\n", context, headers, errID); *headers = sc->hdrs; return strlen(sc->hdrs) + 1; } static int fprGetHeader(FilterContext *context, char *name, char *buffer, unsigned int bufferSize, unsigned int *errID) { printf("fpr.GetHeader(%p, \"%s\", %p, %u, %p)\n", context, name, buffer, bufferSize, errID); return 0; } static void SendRequest(void) { FilterContext fc; FilterParsedRequest fpr; ServerContext sc; int rc; sc.rq = "GET " URI " HTTP/" VERSION; sc.hdrs = "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*\n" "Accept-Language: en-us\n" "User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT)\n" "Host: " SERVER "\n" "Content-length: 0\n"; "Connection: Keep-Alive\n"; fc.contextSize = sizeof(fc); fc.revision = 0; /* or whatever */ fc.serverContext = ≻ fc.serverReserved = 0; fc.securePort = 443; fc.privateContext = NULL; fc.GetRequest = fcGetRequest; fc.GetRequestContents = fcGetRequestContents; fc.GetServerVariable = fcGetServerVariable; fc.WriteClient = fcWriteClient; fc.AllocMem = fcAllocMem; fc.ServerSupport = fcServerSupport; fpr.requestMethod = kRequestGET; fpr.GetAllHeaders = fprGetAllHeaders; fpr.GetHeader = fprGetHeader; fpr.reserved = 0; rc = HttpFilterProc(&fc, kFilterParsedRequest, &fpr); } int main(void) { FilterInitData init; int rc; TestMain(); memset(&init, 0, sizeof(init)); rc = FilterInit(&init); SendRequest(); rc = TerminateFilter(0); return 0; } 1.1 jakarta-tomcat-connectors/jk/native2/server/dsapi/test/printf_logger.c Index: printf_logger.c =================================================================== /* ========================================================================= * * * * The Apache Software License, Version 1.1 * * * * Copyright (c) 1999-2003 The Apache Software Foundation. * * All rights reserved. * * * * ========================================================================= * * * * Redistribution and use in source and binary forms, with or without modi- * * fication, are permitted provided that the following conditions are met: * * * * 1. Redistributions of source code must retain the above copyright notice * * notice, this list of conditions and the following disclaimer. * * * * 2. Redistributions in binary form must reproduce the above copyright * * notice, this list of conditions and the following disclaimer in the * * documentation and/or other materials provided with the distribution. * * * * 3. The end-user documentation included with the redistribution, if any, * * must include the following acknowlegement: * * * * "This product includes software developed by the Apache Software * * Foundation <http://www.apache.org/>." * * * * Alternately, this acknowlegement may appear in the software itself, if * * and wherever such third-party acknowlegements normally appear. * * * * 4. The names "The Jakarta Project", "Jk", and "Apache Software * * Foundation" must not be used to endorse or promote products derived * * from this software without prior written permission. For written * * permission, please contact <[EMAIL PROTECTED]>. * * * * 5. Products derived from this software may not be called "Apache" nor may * * "Apache" appear in their names without prior written permission of the * * Apache Software Foundation. * * * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES * * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * * THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY * * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * * POSSIBILITY OF SUCH DAMAGE. * * * * ========================================================================= * * * * This software consists of voluntary contributions made by many indivi- * * duals on behalf of the Apache Software Foundation. For more information * * on the Apache Software Foundation, please see <http://www.apache.org/>. * * * * ========================================================================= */ /*************************************************************************** * Description: Utility functions (mainly configuration) * * Author: Gal Shachor <[EMAIL PROTECTED]> * * Author: Henri Gomez <[EMAIL PROTECTED]> * * Version: $Revision: 1.1 $ * ***************************************************************************/ #include "jk_env.h" #include "jk_map.h" #include "jk_logger.h" #include <stdio.h> #include <fcntl.h> #define LOG_FORMAT ("log_format") #define HUGE_BUFFER_SIZE (8*1024) #define LOG_LINE_SIZE (1024) /* * define the log format, we're using by default the one from error.log * * [Mon Mar 26 19:44:48 2001] [jk_uri_worker_map.c (155)]: Into jk_uri_worker_map_t::uri_worker_map_alloc * log format used by apache in error.log */ #ifndef JK_TIME_FORMAT #define JK_TIME_FORMAT "[%a %b %d %H:%M:%S %Y] " #endif static const char * jk2_logger_printf_logFmt = JK_TIME_FORMAT; static void jk2_logger_printf_setTimeStr(jk_env_t *env, char *str, int len) { apr_time_exp_t gmt; apr_size_t l; apr_time_exp_gmt(&gmt, apr_time_now()); apr_strftime(str, &l, len, jk2_logger_printf_logFmt, &gmt); } static int JK_METHOD jk2_logger_printf_log(jk_env_t *env, jk_logger_t *l, int level, const char *what) { if (what != NULL) { fprintf(stderr, "%s", what); } return JK_OK; } int jk2_logger_printf_parseLogLevel(jk_env_t *env, const char *level) { if (!level) return JK_LOG_INFO_LEVEL; if (!strcasecmp(level, JK_LOG_INFO_VERB)) return JK_LOG_INFO_LEVEL; if (!strcasecmp(level, JK_LOG_ERROR_VERB)) return JK_LOG_ERROR_LEVEL; if (!strcasecmp(level, JK_LOG_EMERG_VERB)) return JK_LOG_EMERG_LEVEL; return JK_LOG_DEBUG_LEVEL; } static int JK_METHOD jk2_logger_printf_init(jk_env_t *env, jk_logger_t *_this ) { return JK_OK; } static int jk2_logger_printf_close(jk_env_t *env,jk_logger_t *_this) { fflush(stderr); return JK_OK; } static int JK_METHOD jk2_logger_printf_setProperty(jk_env_t *env, jk_bean_t *mbean, char *name, void *valueP ) { #if 0 jk_logger_t *_this = mbean->object; char *value = valueP; if (!strcmp(name, "name")) _this->name = (char *)value; else if (!strcmp(name, "file")) { _this->name = (char *)value; /* Set the file imediately */ jk2_logger_printf_init(env, (jk_logger_t *)mbean->object); } else if (!strcmp(name, "timeFormat")) jk2_logger_printf_logFmt = value; else if (!strcmp(name, "level")) { _this->level = jk2_logger_printf_parseLogLevel(env, value); if( _this->level == 0) { _this->jkLog(env, _this, JK_LOG_INFO, "Level %s %d \n", value, _this->level); } } #endif return JK_OK; } static int JK_METHOD jk2_logger_printf_jkVLog(jk_env_t *env, jk_logger_t *l, const char *file, int line, int level, const char *fmt, va_list args) { int rc = 0; char *buf; char *fmt1; apr_pool_t *aprPool = env->tmpPool->_private; char rfctime[APR_RFC822_DATE_LEN]; apr_time_t time = apr_time_now(); if (!file || !args) return -1; if (l->logger_private == NULL || l->level <= level) { char *f = (char *)(file + strlen(file) - 1); char *slevel; switch (level){ case JK_LOG_INFO_LEVEL: slevel = JK_LOG_INFO_VERB; break; case JK_LOG_ERROR_LEVEL: slevel = JK_LOG_ERROR_VERB; break; case JK_LOG_EMERG_LEVEL: slevel = JK_LOG_EMERG_VERB; break; case JK_LOG_DEBUG_LEVEL: default: slevel = JK_LOG_DEBUG_VERB; break; } while (f != file && *f != '\\' && *f != '/') f--; if (f != file) ++f; /* XXX rfc822_date or apr_ctime ? */ apr_ctime(rfctime, time); fmt1 = apr_psprintf(aprPool, "[%s] (%5s ) [%s (%d)] %s", rfctime, slevel, f, line, fmt); buf = apr_pvsprintf(aprPool, fmt1, args); l->log(env, l, level, buf); } return rc; } static int jk2_logger_printf_jkLog(jk_env_t *env, jk_logger_t *l, const char *file, int line, int level, const char *fmt, ...) { va_list args; int rc; va_start(args, fmt); rc = jk2_logger_printf_jkVLog(env, l, file, line, level, fmt, args); va_end(args); return rc; } int JK_METHOD jk2_logger_printf_factory(jk_env_t *env, jk_pool_t *pool, jk_bean_t *result, const char *type, const char *name) { jk_logger_t *log = (jk_logger_t *)pool->calloc(env, pool, sizeof(jk_logger_t)); if (log == NULL) { fprintf(stderr, "loggerFile.factory(): OutOfMemoryException\n"); return JK_ERR; } log->log = jk2_logger_printf_log; log->logger_private = NULL; log->init =jk2_logger_printf_init; log->jkLog = jk2_logger_printf_jkLog; log->jkVLog = jk2_logger_printf_jkVLog; log->level = JK_LOG_ERROR_LEVEL; jk2_logger_printf_logFmt = JK_TIME_FORMAT; result->object = log; log->mbean = result; result->setAttribute = jk2_logger_printf_setProperty; return JK_OK; }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]