You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by jf...@apache.org on 2002/03/09 19:40:26 UTC
cvs commit: jakarta-commons-sandbox/daemon/src/native/unix/native arguments.c arguments.h debug.h
jfclere 02/03/09 10:40:26
Modified: daemon/src/native/unix/native arguments.c arguments.h
debug.h
Log:
Add parameters to run as a service, to install as a service and remove it.
Revision Changes Path
1.3 +47 -25 jakarta-commons-sandbox/daemon/src/native/unix/native/arguments.c
Index: arguments.c
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/unix/native/arguments.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- arguments.c 19 Feb 2002 03:38:12 -0000 1.2
+++ arguments.c 9 Mar 2002 18:40:26 -0000 1.3
@@ -55,7 +55,7 @@
* *
* ========================================================================= */
-/* @version $Id: arguments.c,v 1.2 2002/02/19 03:38:12 remm Exp $ */
+/* @version $Id: arguments.c,v 1.3 2002/03/09 18:40:26 jfclere Exp $ */
#include "jsvc.h"
/* Return the argument of a command line option */
@@ -84,6 +84,9 @@
args->vers=false; // Don't display version
args->help=false; // Don't display help
args->chck=false; // Don't do a check-only startup
+ args->install=false; // Don't install as a service
+ args->remove=false; // Don't remove the installed service
+ args->service=false; // Don't run as a service
args->name=NULL; // No VM version name
args->home=NULL; // No default JAVA_HOME
args->onum=0; // Zero arguments, but let's have some room
@@ -157,6 +160,15 @@
} else if (strcmp(argv[x],"-nodetach")==0) {
args->dtch=false;
+ } else if (strcmp(argv[x],"-service")==0) {
+ args->service=true;
+
+ } else if (strcmp(argv[x],"-install")==0) {
+ args->install=true;
+
+ } else if (strcmp(argv[x],"-remove")==0) {
+ args->remove=true;
+
} else if (strcmp(argv[x],"-pidfile")==0) {
args->pidf=optional(argc,argv,x++);
if (args->pidf==NULL) {
@@ -206,6 +218,30 @@
return(args);
}
+static char *IsYesNo(bool par)
+{
+ switch (par) {
+ case false: return("No");
+ case true: return("Yes");
+ }
+ return ("[Error]");
+}
+static char *IsTrueFalse(bool par)
+{
+ switch (par) {
+ case false: return("False");
+ case true: return("True");
+ }
+ return ("[Error]");
+}
+static char *IsEnabledDisabled(bool par)
+{
+ switch (par) {
+ case true: return("Enabled");
+ case false: return("Disabled");
+ }
+ return ("[Error]");
+}
/* Main entry point: parse command line arguments and dump them */
arg_data *arguments(int argc, char *argv[]) {
@@ -222,33 +258,19 @@
log_debug("+-- DUMPING PARSED COMMAND LINE ARGUMENTS --------------");
- switch (args->dtch) {
- case false: temp="False"; break;
- case true: temp="True"; break;
- default: temp="[Error]"; break;
- }
- log_debug("| Detach: %s",temp);
+ log_debug("| Detach: %s",IsTrueFalse(args->dtch));
- switch (args->vers) {
- case false: temp="No"; break;
- case true: temp="Yes"; break;
- default: temp="[Error]"; break;
- }
- log_debug("| Show Version: %s",temp);
+ log_debug("| Show Version: %s",IsYesNo(args->vers));
- switch (args->help) {
- case false: temp="No"; break;
- case true: temp="Yes"; break;
- default: temp="[Error]"; break;
- }
- log_debug("| Show Help: %s",temp);
+ log_debug("| Show Help: %s",IsYesNo(args->help));
- switch (args->chck) {
- case true: temp="Enabled"; break;
- case false: temp="Disabled"; break;
- default: temp="[Error]"; break;
- }
- log_debug("| Check Only: %s",temp);
+ log_debug("| Check Only: %s",IsEnabledDisabled(args->chck));
+
+ log_debug("| Run as service: %s",IsYesNo(args->service));
+
+ log_debug("| Install service: %s",IsYesNo(args->install));
+
+ log_debug("| Remove service: %s",IsYesNo(args->remove));
log_debug("| JVM Name: \"%s\"",args->name);
log_debug("| Java Home: \"%s\"",args->home);
1.2 +14 -1 jakarta-commons-sandbox/daemon/src/native/unix/native/arguments.h
Index: arguments.h
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/unix/native/arguments.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- arguments.h 18 Feb 2002 21:15:41 -0000 1.1
+++ arguments.h 9 Mar 2002 18:40:26 -0000 1.2
@@ -55,7 +55,7 @@
* *
* ========================================================================= */
-/* @version $Id: arguments.h,v 1.1 2002/02/18 21:15:41 remm Exp $ */
+/* @version $Id: arguments.h,v 1.2 2002/03/09 18:40:26 jfclere Exp $ */
#ifndef __JSVC_ARGUMENTS_H__
#define __JSVC_ARGUMENTS_H__
@@ -89,6 +89,12 @@
bool help;
/** Only check environment without running the service. */
bool chck;
+ /** Install as a service (win32) */
+ bool install;
+ /** Remove when installed as a service (win32) */
+ bool remove;
+ /** Run as a service (win32) */
+ bool service;
} arg_data;
/**
@@ -99,6 +105,13 @@
* @return A pointer to a arg_data structure containing the parsed command
* line arguments, or NULL if an error was detected.
*/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
arg_data *arguments(int argc, char *argv[]);
+#ifdef __cplusplus
+}
+#endif
#endif /* ifndef __JSVC_ARGUMENTS_H__ */
1.2 +8 -1 jakarta-commons-sandbox/daemon/src/native/unix/native/debug.h
Index: debug.h
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/native/unix/native/debug.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- debug.h 18 Feb 2002 21:15:42 -0000 1.1
+++ debug.h 9 Mar 2002 18:40:26 -0000 1.2
@@ -55,13 +55,16 @@
* *
* ========================================================================= */
-/* @version $Id: debug.h,v 1.1 2002/02/18 21:15:42 remm Exp $ */
+/* @version $Id: debug.h,v 1.2 2002/03/09 18:40:26 jfclere Exp $ */
#ifndef __JSVC_DEBUG_H__
#define __JSVC_DEBUG_H__
/**
* Wether debugging is enabled or not.
*/
+#ifdef __cplusplus
+extern "C" {
+#endif
extern bool log_debug_flag;
/**
@@ -84,5 +87,9 @@
* @param ... Any optional parameter for the message.
*/
void log_error(const char *fmt, ...);
+
+#ifdef __cplusplus
+}
+#endif
#endif /* ifndef __JSVC_DEBUG_H__ */
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>