tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hgo...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/jk/src/native/domino Makefile inifile.c inifile.h mkini.sh config.h dsapi.dsp jk_dsapi_plugin.c
Date Mon, 04 Jun 2001 13:16:09 GMT
hgomez      01/06/04 06:16:09

  Modified:    jk/src/native/domino config.h dsapi.dsp jk_dsapi_plugin.c
  Added:       jk/src/native/domino Makefile inifile.c inifile.h mkini.sh
  Log:
  Updated Domino Connector
  Provided by Andy Armstrong
  
  Revision  Changes    Path
  1.2       +15 -0     jakarta-tomcat-connectors/jk/src/native/domino/config.h
  
  Index: config.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/src/native/domino/config.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- config.h	2001/06/01 08:49:24	1.1
  +++ config.h	2001/06/04 13:16:08	1.2
  @@ -56,19 +56,34 @@
   /***************************************************************************
    * Description: DSAPI plugin for Lotus Domino                              *
    * Author:      Andy Armstrong <andy@tagish.com>                           *
  - * Version:     $Revision: 1.1 $                                             *
  + * Version:     $Revision: 1.2 $                                             *
    ***************************************************************************/
   
   #ifndef __config_h
   #define __config_h
   
   /* the _memicmp() function is available */
  +#if defined(WIN32)
  +
   #define HAVE_MEMICMP
  +#undef USE_INIFILE
  +
  +#elif defined(LINUX)
  +
  +#undef HAVE_MEMICMP
  +#define USE_INIFILE
   
  +#else
  +#error Please define either WIN32 or LINUX
  +#endif
  +
   /* define if you don't have the Notes C API which is available from
    *
    *    http://www.lotus.com/rw/dlcapi.nsf
    */
   /* #undef NO_CAPI */
  +
  +#define DEBUG(args) \
  +	do { /*printf args ;*/ } while (0)
   
   #endif /* __config_h */
  
  
  
  1.2       +8 -0      jakarta-tomcat-connectors/jk/src/native/domino/dsapi.dsp
  
  Index: dsapi.dsp
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/src/native/domino/dsapi.dsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- dsapi.dsp	2001/06/01 08:49:25	1.1
  +++ dsapi.dsp	2001/06/04 13:16:08	1.2
  @@ -98,6 +98,10 @@
   # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
   # Begin Source File
   
  +SOURCE=.\inifile.c
  +# End Source File
  +# Begin Source File
  +
   SOURCE=..\jk\jk_ajp12_worker.c
   # End Source File
   # Begin Source File
  @@ -167,6 +171,10 @@
   # Begin Source File
   
   SOURCE=.\dsapifilter.h
  +# End Source File
  +# Begin Source File
  +
  +SOURCE=.\inifile.h
   # End Source File
   # Begin Source File
   
  
  
  
  1.2       +96 -27    jakarta-tomcat-connectors/jk/src/native/domino/jk_dsapi_plugin.c
  
  Index: jk_dsapi_plugin.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/src/native/domino/jk_dsapi_plugin.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jk_dsapi_plugin.c	2001/06/01 08:49:25	1.1
  +++ jk_dsapi_plugin.c	2001/06/04 13:16:08	1.2
  @@ -56,12 +56,13 @@
   /***************************************************************************
    * Description: DSAPI plugin for Lotus Domino                              *
    * Author:      Andy Armstrong <andy@tagish.com>                           *
  - * Version:     $Revision: 1.1 $                                             *
  + * Version:     $Revision: 1.2 $                                             *
    ***************************************************************************/
   
   /* Based on the IIS redirector by Gal Shachor <shachor@il.ibm.com> */
   
   #include "config.h"
  +#include "inifile.h"
   
   /* JK stuff */
   #include "jk_global.h"
  @@ -100,8 +101,9 @@
   #define FILTERDESC			"Apache Tomcat Interceptor (" VERSION_STRING ")"
   /* Registry location of configuration data */
   #define REGISTRY_LOCATION	"Software\\Apache Software Foundation\\Jakarta Dsapi Redirector\\1.0"
  +#define ININAME				"libtomcat.ini"
   
  -/* Names of registry keys that contain commands to start, stop Tomcat */
  +/* Names of registry keys/ini items that contain commands to start, stop Tomcat */
   #define TOMCAT_START		"tomcat_start"
   #define TOMCAT_STOP			"tomcat_stop"
   #define TOMCAT_STARTSTOP_TO	30000				/* 30 seconds */
  @@ -111,11 +113,24 @@
   static jk_logger_t			*logger		= NULL;
   
   static int					logLevel	= JK_LOG_EMERG_LEVEL;
  -static char					logFile[MAX_PATH];
  -static char					workerFile[MAX_PATH];
  -static char					workerMountFile[MAX_PATH];
  -static char					tomcatStart[MAX_PATH];
  -static char					tomcatStop[MAX_PATH];
  +
  +#ifdef USE_INIFILE
  +static const char *logFile;
  +static const char *workerFile;
  +static const char *workerMountFile;
  +static const char *tomcatStart;
  +static const char *tomcatStop;
  +#else
  +#ifndef MAX_PATH
  +#define MAX_PATH 1024
  +#endif
  +static char	logFile[MAX_PATH];
  +static char	workerFile[MAX_PATH];
  +static char	workerMountFile[MAX_PATH];
  +static char	tomcatStart[MAX_PATH];
  +static char	tomcatStop[MAX_PATH];
  +#endif
  +
   static char					*crlf		= "\r\n";
   
   typedef struct private_ws
  @@ -155,7 +170,9 @@
   static int JK_METHOD Write(jk_ws_service_t * s, const void *b, unsigned l);
   
   static int ReadInitData(void);
  +#ifndef USE_INIFILE
   static int GetRegParam(HKEY hkey, const char *tag, char *b, DWORD sz);
  +#endif
   
   static unsigned int ParsedRequest(FilterContext *context, FilterParsedRequest *reqData);
   
  @@ -246,6 +263,7 @@
   									const char *const *hdrNames,
   									const char *const *hdrValues, unsigned hdrCount)
   {
  +	DEBUG(("StartResponse()\n"));
   	jk_log(logger, JK_LOG_DEBUG, "Into jk_ws_service_t::StartResponse\n");
   
   	if (status < 100 || status > 1000)
  @@ -303,11 +321,11 @@
   			frh.reasonText = (char *) reason;
   			frh.headerText = hdrBuf;
   
  -			//printf("%d %s\n%s", status, reason, hdrBuf);
  +			DEBUG(("%d %s\n%s", status, reason, hdrBuf));
   
   			/* Send the headers */
   			rc = p->context->ServerSupport(p->context, kWriteResponseHeaders, &frh,
NULL, 0, &errID);
  -			
  +
   			/*
   			if (rc)
   			{
  @@ -329,6 +347,7 @@
   
   static int JK_METHOD Read(jk_ws_service_t * s, void *bytes, unsigned len, unsigned *countp)
   {
  +	DEBUG(("Read(%p, %p, %u, %p)\n", s, bytes, len, countp));
   	jk_log(logger, JK_LOG_DEBUG, "Into jk_ws_service_t::Read\n");
   
   	if (s && s->ws_private && bytes && countp)
  @@ -354,6 +373,7 @@
   
   static int JK_METHOD Write(jk_ws_service_t *s, const void *bytes, unsigned len)
   {
  +	DEBUG(("Write(%p, %p, %u)\n", s, bytes, len));
   	jk_log(logger, JK_LOG_DEBUG, "Into jk_ws_service_t::Write\n");
   
   	if (s && s->ws_private && bytes)
  @@ -368,7 +388,7 @@
   		if (!p->responseStarted)
   			StartResponse(s, 200, NULL, NULL, NULL, 0);
   
  -		//printf("Writing %d bytes of content\n", len);
  +		DEBUG(("Writing %d bytes of content\n", len));
   
   		/* Send the data */
   		if (len > 0)
  @@ -382,17 +402,18 @@
   	return JK_FALSE;
   }
   
  -static int RunProg(char *cmd)
  +static int RunProg(const char *cmd)
   {
  +#ifdef WIN32
       STARTUPINFO si;
       PROCESS_INFORMATION pi;
  -    
  +
   	ZeroMemory(&si, sizeof(si));
       si.cb			= sizeof(si);    // Start the child process.
   	si.dwFlags		= STARTF_USESHOWWINDOW;
   	si.wShowWindow	= SW_SHOWMAXIMIZED;
   
  -	if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
  +	if (!CreateProcess(NULL, (char *) cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
   	{
   		DWORD err = GetLastError();
   		AddInLogMessageText("Command \"%s\" (error %u)", NOERROR, cmd, err);
  @@ -403,8 +424,14 @@
   		return TRUE;
   
   	AddInLogMessageText("Command \"%s\" didn't complete in time", NOERROR, cmd);
  -
   	return FALSE;
  +
  +#else
  +	int err = system(cmd);
  +	if (0 == err) return 1;
  +	AddInLogMessageText("Command \"%s\" failed (error %d)", NOERROR, cmd, err);
  +	return 0;
  +#endif
   }
   
   /* Called when the filter is unloaded. Free various resources and
  @@ -422,7 +449,7 @@
   			jk_close_file_logger(&logger);
   	}
   
  -	if (tomcatStop[0])
  +	if (NULL != tomcatStop && '\0' != *tomcatStop)
   	{
   		AddInLogMessageText("Attempting to stop Tomcat: %s", NOERROR, tomcatStop);
   		RunProg(tomcatStop);
  @@ -446,7 +473,7 @@
   	if (!jk_open_file_logger(&logger, logFile, logLevel))
   		logger = NULL;
   
  -	if (tomcatStart[0])
  +	if (NULL != tomcatStart && '\0' != *tomcatStart)
   	{
   		AddInLogMessageText("Attempting to start Tomcat: %s", NOERROR, tomcatStart);
   		RunProg(tomcatStart);
  @@ -497,10 +524,43 @@
    */
   static int ReadInitData(void)
   {
  +#ifdef USE_INIFILE
  +
  +#define GET(tag, var) \
  +	var = inifile_lookup(tag); \
  +	if (NULL == var) \
  +	{ \
  +		AddInLogMessageText("%s not defined in %s", NOERROR, tag, ININAME); \
  +		ok = JK_FALSE; \
  +	}
  +
  +	int ok = JK_TRUE;
  +	ERRTYPE e;
  +	const char *v;
  +
  +	if (e = inifile_read(ININAME), ERRNONE != e)
  +	{
  +		AddInLogMessageText("Error reading: %s, %s", NOERROR, ININAME, ERRTXT(e));
  +		return JK_FALSE;
  +	}
  +
  +	GET(JK_LOG_FILE_TAG, logFile)
  +	GET(JK_LOG_LEVEL_TAG, v);
  +	GET(JK_WORKER_FILE_TAG, workerFile);
  +	GET(JK_MOUNT_FILE_TAG, workerMountFile);
  +
  +	logLevel = (NULL == v) ? 0 : jk_parse_log_level(v);
  +
  +	tomcatStart	= inifile_lookup(TOMCAT_START);
  +	tomcatStop	= inifile_lookup(TOMCAT_STOP);
  +
  +	return ok;
  +
  +#else
  +	int ok = JK_TRUE;
   	char tmpbuf[1024];
   	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;
  @@ -537,9 +597,12 @@
   		strcpy(tomcatStop, tmpbuf);
   
   	RegCloseKey(hkey);
  +
   	return ok;
  +#endif
   }
   
  +#ifndef USE_INIFILE
   static int GetRegParam(HKEY hkey, const char *tag, char *b, DWORD sz)
   {
   	DWORD type = 0;
  @@ -551,10 +614,11 @@
   
   	b[sz] = '\0';
   
  -	//printf("%s = %s\n", tag, b);
  +	DEBUG(("%s = %s\n", tag, b));
   
   	return JK_TRUE;
   }
  +#endif
   
   /* Main entry point for the filter. Called by Domino for every HTTP request.
    */
  @@ -616,7 +680,7 @@
   	else
   		*dest = jk_pool_strdup(&ws->p, dflt);
   
  -	//printf("%s = %s\n", hdrName, *dest);
  +	DEBUG(("%s = %s\n", hdrName, *dest));
   
   	return JK_TRUE;
   }
  @@ -633,12 +697,12 @@
   	else
   		*dest = dflt;
   
  -	//printf("%s = %d\n", hdrName, *dest);
  +	DEBUG(("%s = %d\n", hdrName, *dest));
   
   	return JK_TRUE;
   }
   
  -/* A couple of utility macros to supply standard arguments to GetVariable() and 
  +/* 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))
  @@ -685,7 +749,7 @@
   
   		if (hdrs >= limit)
   			break;
  -		
  +
   		name = nameEnd = value = valueEnd = NULL;
   
   		name = hdrs;
  @@ -708,7 +772,7 @@
   		{
   			s->headers_names[hdrCount]	= MemDup(ws, name, nameEnd);
   			s->headers_values[hdrCount] = MemDup(ws, value, valueEnd);
  -			//printf("%s = %s\n", s->headers_names[hdrCount], s->headers_values[hdrCount]);
  +			DEBUG(("%s = %s\n", s->headers_names[hdrCount], s->headers_values[hdrCount]));
   		}
   		hdrCount++;
   	}
  @@ -812,14 +876,14 @@
   	}
   
   	/* Duplicate all the headers now */
  -	
  +
   	hdrsz = ws->reqData->GetAllHeaders(ws->context, &hdrs, &errID);
  -	//printf("\nGot headers (length %d)\n--------\n%s\n--------\n\n", hdrsz, hdrs);
  +	DEBUG(("\nGot headers (length %d)\n--------\n%s\n--------\n\n", hdrsz, hdrs));
   
   	s->headers_names =
   	s->headers_values = NULL;
   	hdrCount = ParseHeaders(ws, hdrs, hdrsz, s);
  -	//printf("Found %d headers\n", hdrCount);
  +	DEBUG(("Found %d headers\n", hdrCount));
   	s->num_headers = hdrCount;
   	s->headers_names	= jk_pool_alloc(&ws->p, hdrCount * sizeof(char *));
   	s->headers_values	= jk_pool_alloc(&ws->p, hdrCount * sizeof(char *));
  @@ -838,7 +902,7 @@
   	FilterRequest fr;
   	int result = kFilterNotHandled;
   
  -	//printf("\nParsedRequest starting\n");
  +	DEBUG(("\nParsedRequest starting\n"));
   
   	rc = context->GetRequest(context, &fr, &errID);
   
  @@ -851,7 +915,7 @@
   		workerName = map_uri_to_worker(uw_map, uri, logger);
   		if (qp) *qp = '?';
   
  -		//printf("Worker for this URL is %s\n", workerName);
  +		DEBUG(("Worker for this URL is %s\n", workerName));
   
   		if (NULL != workerName)
   		{
  @@ -890,18 +954,23 @@
   					if (worker->get_endpoint(worker, &e, logger))
   					{
   						int recover = JK_FALSE;
  +						DEBUG(("About to call e->service()\n"));
   
   						if (e->service(e, &s, logger, &recover))
   						{
   							result = kFilterHandledRequest;
   							jk_log(logger, JK_LOG_DEBUG, "HttpExtensionProc service() returned OK\n");
  +							DEBUG(("HttpExtensionProc service() returned OK\n"));
   						}
   						else
   						{
   							result = kFilterError;
   							jk_log(logger, JK_LOG_ERROR, "HttpExtensionProc error, service() failed\n");
  +							DEBUG(("HttpExtensionProc error, service() failed\n"));
   						}
  +						DEBUG(("About to call e->done()\n"));
   						e->done(&e, logger);
  +						DEBUG(("Returned OK\n"));
   					}
   				}
   				else
  
  
  
  1.1                  jakarta-tomcat-connectors/jk/src/native/domino/Makefile
  
  Index: Makefile
  ===================================================================
  # Makefile for Tomcat Domino connector
  
  CC=gcc
  LD=gcc -shared
  
  CCFLAGS=-Wall -O3
  LDFLAGS=-shared
  
  #################################################################################
  #										#
  # These will almost certainly need to be changed to match the specifics of your	#
  # Domino and Tomcat installations.						#
  #										#
  #################################################################################
  
  # The root of your Domino installation. Mine's in /usr/local/lotus, but your's
  # may well be /opt/lotus
  NOTESROOT=/usr/local/lotus
  
  # The place where the Notes API is installed
  NOTESAPI=$(NOTESROOT)/notesapi
  
  # The Domino program directory.
  NOTESHOME=$(NOTESROOT)/notes/5061/linux
  
  # The Domino data directory (the directory containing names.nsf)
  NOTESDATA=$(NOTESROOT)/notes/data
  
  # The include path for the Notes C API headers
  NOTESINC=$(NOTESAPI)/include
  
  # Where tomcat is installed. This is where conf, lib, webapps et al normally are
  TOMCATHOME=/usr/local/apache/tomcat
  
  # Your JDK's include directory
  JAVAINC=$(JAVA_HOME)/include
  
  #################################################################################
  #										#
  # You probably won't need to change anything below here.			#
  #										#
  #################################################################################
  
  JKINC=../jk
  LIBS=-lc -ldl -lnotes -L$(NOTESHOME)
  
  INC=-I$(NOTESINC) -I$(JAVAINC) -I$(JKINC)
  DEFS=-DLINUX -DUNIX
  
  JKOBJ = ../jk/jk_ajp12_worker.o ../jk/jk_ajp13.o ../jk/jk_ajp13_worker.o ../jk/jk_connect.o
\
  	../jk/jk_jni_worker.o ../jk/jk_lb_worker.o ../jk/jk_map.o ../jk/jk_msg_buff.o \
  	../jk/jk_nwmain.o ../jk/jk_pool.o ../jk/jk_sockbuf.o ../jk/jk_uri_worker_map.o \
  	../jk/jk_util.o ../jk/jk_worker.o
  
  LOBJ  =	jk_dsapi_plugin.o inifile.o
  OBJ   = $(JKOBJ) $(LOBJ)
  
  TARG  = libtomcat.so
  INI   = libtomcat.ini
  
  all: $(TARG) $(INI) 
  
  $(TARG): $(OBJ)
  	$(LD) $(LDFLAGS) $(LIBS) $(OBJ) -o $(TARG)
  
  $(INI): mkini.sh Makefile
  	./mkini.sh $(TOMCATHOME) > $(INI)
  
  .c.o:
  	$(CC) $(CCFLAGS) $(DEFS) $(INC) -o $@ -c $< 
  
  clean:
  	rm -f $(OBJ)
  
  install: $(TARG) $(INI)
  	cp $(TARG) $(NOTESHOME)
  	cp $(INI) $(NOTESDATA)
  
  # Various dependencies
  jk_dsapi_plugin.o: jk_dsapi_plugin.c config.h inifile.h
  inifile.o: inifile.c config.h inifile.h
  
  
  
  1.1                  jakarta-tomcat-connectors/jk/src/native/domino/inifile.c
  
  Index: inifile.c
  ===================================================================
  /*
   * Copyright (c) 1997-1999 The Java Apache Project.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Java Apache
   *    Project for use in the Apache JServ servlet engine project
   *    <http://java.apache.org/>."
   *
   * 4. The names "Apache JServ", "Apache JServ Servlet Engine" and
   *    "Java Apache Project" must not be used to endorse or promote products
   *    derived from this software without prior written permission.
   *
   * 5. Products derived from this software may not be called "Apache JServ"
   *    nor may "Apache" nor "Apache JServ" appear in their names without
   *    prior written permission of the Java Apache Project.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Java Apache
   *    Project for use in the Apache JServ servlet engine project
   *    <http://java.apache.org/>."
   *
   * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "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 JAVA APACHE PROJECT 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
   * individuals on behalf of the Java Apache Group. For more information
   * on the Java Apache Project and the Apache JServ Servlet Engine project,
   * please see <http://java.apache.org/>.
   *
   */
  
  /***************************************************************************
   * Description: DSAPI plugin for Lotus Domino                              *
   * Author:      Andy Armstrong <andy@tagish.com>                           *
   * Date:        20010603                                                   *
   * Version:     $Revision: 1.1 $                                             *
   ***************************************************************************/
  
  #include "config.h"
  #include "inifile.h"
  #include <ctype.h>
  #include <stdlib.h>
  #include <stdio.h>
  #include <string.h>
  
  /* We have one of these for each ini file line. Once we've read the
   * file and parsed it we'll have an array in key order containing one
   * of these for each configuration item in file.
   */
  typedef struct
  {
  	const char *key;
  	const char *value;
  
  } inifile_key;
  
  static char *file;			/* the text of the ini file				*/
  static inifile_key *keys;	/* an array of keys, one per item		*/
  static size_t klen;			/* length of the key array				*/
  
  /* Text that will prefix all of our error messages */
  #define ERRPFX "INIFILE: "
  /* Various error messages that we can return */
  ERRTYPE inifile_outofmemory		= ERRPFX "Out of memory";
  ERRTYPE inifile_filenotfound	= ERRPFX "File not found";
  ERRTYPE inifile_readerror		= ERRPFX "Error reading file";
  
  /* Discard the current ini file */
  void inifile_dispose(void)
  {
  	if (NULL != file)
  	{
  		free(file);
  		file = NULL;
  	}
  
  	if (NULL != keys)
  	{
  		free(keys);
  		keys = NULL;
  		klen = 0;
  	}
  }
  
  /* Case insensitive string comparison, works like strcmp() */
  static int inifile__stricmp(const char *s1, const char *s2)
  {
  	while (*s1 && tolower(*s1) == tolower(*s2))
  		s1++, s2++;
  	return tolower(*s1) - tolower(*s2);
  }
  
  /* Compare keys, suitable for passing to qsort() */
  static int inifile__cmp(const void *k1, const void *k2)
  {
  	const inifile_key *kk1 = (const inifile_key *) k1;
  	const inifile_key *kk2 = (const inifile_key *) k2;
  	return inifile__stricmp(kk1->key, kk2->key);
  }
  
  /* Various macros to tidy up the parsing code */
  
  /* Skip whitespace */
  #define SKIPSPC() \
  	while (*fp == '\t' || *fp == ' ') fp++
  
  /* Skip to the end of the current line */
  #define SKIPLN() \
  	while (*fp != '\0' && *fp != '\r' && *fp != '\n') fp++
  
  /* Move from the end of the current line to the start of the next */
  #define NEXTLN() \
  	while (*fp == '\r' || *fp == '\n') fp++
  
  /* Build the index. Called when the inifile is loaded by inifile_load()
   */
  static ERRTYPE inifile__index(void)
  {
  	int pass;
  
  	/* Make two passes over the data. First time we're just counting
  	 * the lines that contain values so we can allocate the index, second
  	 * time we build the index.
  	 */
  	for (pass = 0; pass < 2; pass++)
  	{
  		char *fp = file;
  		char *ks = NULL, *ke;	/* key start, end */
  		char *vs = NULL, *ve;	/* value start, end */
  		klen = 0;
  
  		while (*fp != '\0')
  		{
  			SKIPSPC();
  
  			/* turn a comment into an empty line by moving to the next \r|\n */
  			if (*fp == '#' || *fp == ';')
  				SKIPLN();
  
  			if (*fp != '\0' && *fp != '\r' && *fp != '\n')
  			{
  				ks = fp;		/* start of key */
  				while (*fp > ' ' && *fp != '=') fp++;
  				ke = fp;		/* end of key */
  				SKIPSPC();
  				if (*fp == '=') /* lines with no equals are ignored */
  				{
  					fp++; /* past the = */
  					SKIPSPC();
  					vs = fp;
  					SKIPLN();
  					ve = fp;
  					/* back up over any trailing space */
  					while (ve > vs && (ve[-1] == ' ' || ve[-1] == '\t')) ve--;
  					NEXTLN(); /* see note[1] below */
  
  					if (NULL != keys) /* second pass? if so stash a pointer */
  					{
  						*ke = '\0';
  						*ve = '\0';
  						keys[klen].key = ks;
  						keys[klen].value = vs;
  					}
  
  					klen++;
  				}
  			}
  
  			/* [1] you may notice that this macro might get invoked twice
  			 * for any given line. This isn't a problem -- it won't do anything
  			 * if it's called other than at the end of a line, and it needs to
  			 * be called the first time above to move fp past the line end
  			 * before the line end gets trampled on during the stringification
  			 * of the value.
  			 */
  			NEXTLN();
  		}
  
  		if (NULL == keys && (keys = malloc(sizeof(inifile_key) * klen), NULL == keys))
  			return inifile_outofmemory;
  	}
  
  	/* got the index now, sort it so we can search it quickly */
  	qsort(keys, klen, sizeof(inifile_key), inifile__cmp);
  
  	return ERRNONE;
  }
  
  /* Read an INI file from disk
   */
  ERRTYPE inifile_read(const char *name)
  {
  	FILE *fl;
  	ERRTYPE e;
  	size_t flen;
  
  	inifile_dispose();
  
  	if (fl = fopen(name, "r"), NULL == fl)
  		return inifile_filenotfound;
  
  	fseek(fl, 0L, SEEK_END);
  	flen = (size_t) ftell(fl);
  	fseek(fl, 0L, SEEK_SET);
  
  	/* allocate one extra byte for trailing \0
  	 */
  	if (file = malloc(flen+1), NULL == file)
  	{
  		fclose(fl);
  		return inifile_outofmemory;
  	}
  
  	if (fread(file, flen, 1, fl) < 1)
  	{
  		inifile_dispose();
  		fclose(fl);
  		return inifile_readerror;
  	}
  
  	file[flen] = '\0';	/* terminate it to simplify parsing */
  
  	if (e = inifile__index(), ERRNONE != e)
  	{
  		inifile_dispose();
  		fclose(fl);
  	}
  
  	return e;
  }
  
  /* Find the value associated with the given key returning it or NULL
   * if no match is found. Key name matching is case insensitive.
   */
  const char *inifile_lookup(const char *key)
  {
  	int lo, mid, hi, cmp;
  
  	if (NULL == keys)
  		return NULL;
  
  	for (lo = 0, hi = klen-1; lo <= hi; )
  	{
  		mid = (lo + hi) / 2;
  		cmp = inifile__stricmp(key, keys[mid].key);
  		if (cmp < 0)	/* key in array is greater */
  			hi = mid-1;
  		else if (cmp > 0)
  			lo = mid+1;
  		else
  			return keys[mid].value;
  	}
  
  	return NULL;
  }
  
  
  
  1.1                  jakarta-tomcat-connectors/jk/src/native/domino/inifile.h
  
  Index: inifile.h
  ===================================================================
  /*
   * Copyright (c) 1997-1999 The Java Apache Project.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    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. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Java Apache
   *    Project for use in the Apache JServ servlet engine project
   *    <http://java.apache.org/>."
   *
   * 4. The names "Apache JServ", "Apache JServ Servlet Engine" and
   *    "Java Apache Project" must not be used to endorse or promote products
   *    derived from this software without prior written permission.
   *
   * 5. Products derived from this software may not be called "Apache JServ"
   *    nor may "Apache" nor "Apache JServ" appear in their names without
   *    prior written permission of the Java Apache Project.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Java Apache
   *    Project for use in the Apache JServ servlet engine project
   *    <http://java.apache.org/>."
   *
   * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "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 JAVA APACHE PROJECT 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
   * individuals on behalf of the Java Apache Group. For more information
   * on the Java Apache Project and the Apache JServ Servlet Engine project,
   * please see <http://java.apache.org/>.
   *
   */
  
  /***************************************************************************
   * Description: DSAPI plugin for Lotus Domino                              *
   * Author:      Andy Armstrong <andy@tagish.com>                           *
   * Version:     $Revision: 1.1 $                                             *
   ***************************************************************************/
  
  #ifndef __inifile_h
  #define __inifile_h
  
  #define ERRTYPE const char *
  #define ERRFMT  "%s"			/* natural printf format for errors */
  #define ERRTXT(e) (e)			/* macro to return text for an error */
  #define ERRNONE NULL
  extern ERRTYPE inifile_outofmemory;
  extern ERRTYPE inifile_filenotfound;
  extern ERRTYPE inifile_readerror;
  
  /* Discard the current ini file
   */
  void inifile_dispose(void);
  
  /* Read an INI file from disk
   */
  ERRTYPE inifile_read(const char *name);
  
  /* Find the value associated with the given key returning it or NULL
   * if no match is found. Key name matching is case insensitive.
   */
  const char *inifile_lookup(const char *key);
  
  #endif /* __inifile_h */
  
  
  
  1.1                  jakarta-tomcat-connectors/jk/src/native/domino/mkini.sh
  
  Index: mkini.sh
  ===================================================================
  #!/bin/sh
  echo "log_file=$1/logs/domino.log"
  echo "log_level=debug"
  echo "worker_file=$1/conf/workers.properties"
  echo "worker_mount_file=$1/conf/uriworkermap.properties"
  echo "tomcat_start=$1/bin/tomcat.sh start"
  echo "tomcat_stop=$1/bin/tomcat.sh stop"
  
  
  

Mime
View raw message