pier 00/11/27 03:05:25 Modified: service/src/native jsvc.h jsvc_help.c jsvc_parse.c jsvc_service.c jsvc_unix.c Added: service/src Makefile service/src/native Makefile service/src/share Makefile Log: Major update Revision Changes Path 1.1 jakarta-tomcat-4.0/service/src/Makefile Index: Makefile =================================================================== all: Makedefs make -C native all make -C share all make -C share javadocs cp native/jsvc ../jsvc cp service.jar ../service.jar clean: Makedefs make -C native clean make -C share clean distclean: clean rm -f Makedefs rm -rf ../javadocs rm -f ../jsvc rm -f ../service.jar Makedefs: Makedefs.orig @echo "### WARNING: Edit Makedefs before issuing make ###" @cp Makedefs.orig Makedefs @exit 1 1.3 +3 -2 jakarta-tomcat-4.0/service/src/native/jsvc.h Index: jsvc.h =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/service/src/native/jsvc.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- jsvc.h 2000/11/27 03:57:56 1.2 +++ jsvc.h 2000/11/27 11:05:14 1.3 @@ -55,7 +55,7 @@ * * * ========================================================================= */ -// CVS $Id: jsvc.h,v 1.2 2000/11/27 03:57:56 pier Exp $ +// CVS $Id: jsvc.h,v 1.3 2000/11/27 11:05:14 pier Exp $ // Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]> #ifndef _JSVC_H_ @@ -65,6 +65,7 @@ #include <strings.h> #include <stdarg.h> #include <stdlib.h> +#include <unistd.h> #include <string.h> #include <limits.h> #include <stdio.h> @@ -124,7 +125,7 @@ /* Defined in jsvc_help.c */ /* ********************** */ // Display the standard help message -int jsvc_help(jsvc_config *); +void jsvc_help(jsvc_config *); /* *********************** */ /* Defined in jsvc_parse.c */ 1.3 +7 -2 jakarta-tomcat-4.0/service/src/native/jsvc_help.c Index: jsvc_help.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/service/src/native/jsvc_help.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- jsvc_help.c 2000/11/27 03:57:56 1.2 +++ jsvc_help.c 2000/11/27 11:05:15 1.3 @@ -55,12 +55,17 @@ * * * ========================================================================= */ -// CVS $Id: jsvc_help.c,v 1.2 2000/11/27 03:57:56 pier Exp $ +// CVS $Id: jsvc_help.c,v 1.3 2000/11/27 11:05:15 pier Exp $ // Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]> #include <jsvc.h> -int jsvc_help(jsvc_config *config) { +/** + * Display the help page file. + * + * @param config The service configuration member. + */ +void jsvc_help(jsvc_config *config) { printf("Usage: %s [@file] [-options] class [args...]\n",config->binary); printf("\n"); printf("Where options include:\n"); 1.3 +27 -2 jakarta-tomcat-4.0/service/src/native/jsvc_parse.c Index: jsvc_parse.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/service/src/native/jsvc_parse.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- jsvc_parse.c 2000/11/27 03:57:56 1.2 +++ jsvc_parse.c 2000/11/27 11:05:15 1.3 @@ -55,7 +55,7 @@ * * * ========================================================================= */ -// CVS $Id: jsvc_parse.c,v 1.2 2000/11/27 03:57:56 pier Exp $ +// CVS $Id: jsvc_parse.c,v 1.3 2000/11/27 11:05:15 pier Exp $ // Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]> #include <jsvc.h> @@ -63,6 +63,16 @@ // Temporary variable used to process the classpath entry static boolean classpath=FALSE; +/** + * Parse command line options. + * + * @param b The binary filename (ala argv[0]) + * @param r The home directory (where the binary resides) + * @param h The JAVA_HOME environment variable (root of JDK or JRE) + * @param argc The number of command line arguments + * @param argv The command line arguments (without argv[0]) + * @return A pointer to a jsvc_config structure or NULL in case of error. + */ jsvc_config *jsvc_parse(char *b, char *r, char *h, int argc, char *argv[]) { jsvc_config *config=(jsvc_config *)malloc(sizeof(jsvc_config)); char *buffer=(char *)malloc(PATH_MAX*sizeof(char)); @@ -75,7 +85,7 @@ } else config->binary=strdup(b); if (r==NULL) { - jsvc_error(JSVC_MARK, "Default configuration filename unspecified"); + jsvc_error(JSVC_MARK, "Home directory unspecified"); return(NULL); } else config->root=strdup(r); @@ -116,6 +126,14 @@ return(config); } +/** + * Parse a single command line argument and set the appropriate value in the + * specified jsvc_config structure. + * + * @param a The command line argument. + * @param conf A pointer to a jsvc_config structure. + * @return TRUE if the option was parsed successfully, FALSE otherwise. + */ boolean jsvc_parse_argument(char *a, jsvc_config *conf) { if (a==NULL) { jsvc_error(JSVC_MARK, "Null argument specified"); @@ -221,6 +239,13 @@ return(TRUE); } +/** + * Parse arguments from a file. + * + * @param f The configuration file to parse. + * @param conf A pointer to a jsvc_config structure. + * @return TRUE if the file was parsed successfully, FALSE otherwise. + */ boolean jsvc_parse_file(char *f, jsvc_config *conf) { char *filename=f; 1.3 +30 -25 jakarta-tomcat-4.0/service/src/native/jsvc_service.c Index: jsvc_service.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/service/src/native/jsvc_service.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- jsvc_service.c 2000/11/27 03:57:57 1.2 +++ jsvc_service.c 2000/11/27 11:05:18 1.3 @@ -55,11 +55,20 @@ * * * ========================================================================= */ -// CVS $Id: jsvc_service.c,v 1.2 2000/11/27 03:57:57 pier Exp $ +// CVS $Id: jsvc_service.c,v 1.3 2000/11/27 11:05:18 pier Exp $ // Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]> #include <jsvc.h> +/** + * This method is registered in the JNI environment to provide logging + * falcilities. Actual logging is performed by jsvc_error wich is system + * dependant. + * + * @param env The JNI environment. + * @param obj The object that is calling this native method. + * @param msg The message to be logged. + */ void jsvc_log(JNIEnv *env, jobject obj, jstring msg) { jboolean copy=JNI_TRUE; const char *message=(*env)->GetStringUTFChars(env, msg, ©); @@ -68,14 +77,16 @@ (*env)->ReleaseStringUTFChars(env, msg, message); } +/** + * Register native methods and prepare the Virtual Machine to invoke the + * service, getting a hold on the helper class. + * + * @param cvs A pointer to a jsvc_config structure. + * @return TRUE if preparation was successful, FALSE otherwise. + */ boolean jsvc_prepare(jsvc_config *cfg) { JNINativeMethod log; - jmethodID method; - jstring name; jclass class; - jboolean ret; - jobjectArray arg; - int x; // Register the native logging method for messages jsvc_debug(JSVC_MARK, "Registering natives"); @@ -103,13 +114,15 @@ return(TRUE); } +/** + * Display the Virtual Machine version information, calling the version method + * in the helper class. + * + * @param cfg A pointer to a jsvc_config structure. + * @return TRUE if we can load the service, FALSE if we need to exit. + */ boolean jsvc_version(jsvc_config *cfg) { - JNINativeMethod log; jmethodID method; - jstring name; - jboolean ret; - jobjectArray arg; - int x; if (cfg->showversion==JSVC_VERSION_NO) return(TRUE); @@ -132,11 +145,15 @@ return(FALSE); } +/** + * Initialize the service. + * + * @param cfg A pointer to a jsvc_config structure. + * @return TRUE if the service was initialized, FALSE otherwise. + */ boolean jsvc_init(jsvc_config *cfg) { - JNINativeMethod log; jmethodID method; jstring name; - jclass class; jboolean ret; jobjectArray arg; int x; @@ -171,12 +188,8 @@ } boolean jsvc_start(jsvc_config *cfg) { - JNINativeMethod log; jmethodID method; - jstring name; jboolean ret; - jobjectArray arg; - int x; // Retrieve the start static method in the helper class jsvc_debug(JSVC_MARK, "Locating start method in \"%s\"",JSVC_HELPER); @@ -196,12 +209,8 @@ } boolean jsvc_restart(jsvc_config *cfg) { - JNINativeMethod log; jmethodID method; - jstring name; jboolean ret; - jobjectArray arg; - int x; // Retrieve the restart static method in the helper class jsvc_debug(JSVC_MARK, "Locating restart method in \"%s\"",JSVC_HELPER); @@ -221,12 +230,8 @@ } boolean jsvc_stop(jsvc_config *cfg) { - JNINativeMethod log; jmethodID method; - jstring name; jboolean ret; - jobjectArray arg; - int x; // Retrieve the stop static method in the helper class jsvc_debug(JSVC_MARK, "Locating stop method in \"%s\"",JSVC_HELPER); 1.3 +1 -2 jakarta-tomcat-4.0/service/src/native/jsvc_unix.c Index: jsvc_unix.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/service/src/native/jsvc_unix.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- jsvc_unix.c 2000/11/27 03:57:57 1.2 +++ jsvc_unix.c 2000/11/27 11:05:18 1.3 @@ -55,7 +55,7 @@ * * * ========================================================================= */ -// CVS $Id: jsvc_unix.c,v 1.2 2000/11/27 03:57:57 pier Exp $ +// CVS $Id: jsvc_unix.c,v 1.3 2000/11/27 11:05:18 pier Exp $ // Author: Pier Fumagalli <mailto:[EMAIL PROTECTED]> #include <jsvc.h> @@ -65,7 +65,6 @@ char *bin; char *root; char *home; - int x; // Resolve the real full path name of the binary root=(char *)malloc(PATH_MAX*sizeof(char)); 1.1 jakarta-tomcat-4.0/service/src/native/Makefile Index: Makefile =================================================================== include ../Makedefs OBJS = jsvc_help.o jsvc_parse.o jsvc_service.o all: jsvc clean: rm -f $(OBJS) jsvc jsvc: jsvc_unix.c $(OBJS) $(CC) $(COPTS) $(CINCS) $(CLIBS) $(OBJS) jsvc_unix.c -o jsvc .c.o: $(CC) $(COPTS) $(CINCS) -c $< -o $@ 1.1 jakarta-tomcat-4.0/service/src/share/Makefile Index: Makefile =================================================================== include ../Makedefs PACKAGES = org.apache.service org.apache.service.helpers all: service.jar service.jar: ../../build SOURCES=`find . -type f | grep \\.java | sort` ; \ $(JAVAC) $(JAVACOPTS) -sourcepath . -d ../../build $$SOURCES ; \ CURDIR=$(PWD) ; \ cd ../../build ; \ $(JAR) -cvf0 $$CURDIR/service.jar * ; \ cd $$CURDIR javadocs: ../../javadocs $(JAVADOC) $(JAVADOCOPTS) -d ../../javadocs $(PACKAGES) clean: rm -rf ../../build rm -f service.jar ../../build: mkdir ../../build ../../javadocs: mkdir ../../javadocs