[pkg-java] r2794 - in branches/commons-daemon: . upstream
upstream/1.0.2~svn20061127 upstream/1.0.2~svn20061127/src
upstream/1.0.2~svn20061127/src/conf
upstream/1.0.2~svn20061127/src/docs
upstream/1.0.2~svn20061127/src/java
upstream/1.0.2~svn20061127/src/java/org
upstream/1.0.2~svn20061127/src/java/org/apache
upstream/1.0.2~svn20061127/src/java/org/apache/commons
upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon
upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/support
upstream/1.0.2~svn20061127/src/media
upstream/1.0.2~svn20061127/src/native
upstream/1.0.2~svn20061127/src/native/nt
upstream/1.0.2~svn20061127/src/native/nt/executables
upstream/1.0.2~svn20061127/src/native/nt/executables/vdmoniadm
upstream/1.0.2~svn20061127/src/native/nt/executables/vdmonisvc
upstream/1.0.2~svn20061127/src/native/nt/lib
upstream/1.0.2~svn20061127/src/native/nt/moni
upstream/1.0.2~svn20061127/src/native/nt/procrun
upstream/1.0.2~svn20061127/src/native/nt/procrun/apps
upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr
upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/jar2exe
upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr
upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunsrv
upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch
upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/example
upstream/1.0.2~svn20061127/src/native/nt/procrun/include
upstream/1.0.2~svn20061127/src/native/nt/procrun/java
upstream/1.0.2~svn20061127/src/native/nt/procrun/resources
upstream/1.0.2~svn20061127/src/native/nt/procrun/samples
upstream/1.0.2~svn20061127/src/native/nt/procrun/src
upstream/1.0.2~svn20061127/src/native/nt/procrun/testchild
upstream/1.0.2~svn20061127/src/native/nt/procrun/xdocs
upstream/1.0.2~svn20061127/src/native/nt/service
upstream/1.0.2~svn20061127/src/native/nt/signals
upstream/1.0.2~svn20061127/src/native/nt/supcalls_nt
upstream/1.0.2~svn20061127/src/native/unix
upstream/1.0.2~svn20061127/src/native/unix/man
upstream/1.0.2~svn20061127/src/native/unix/native
upstream/1.0.2~svn20061127/src/native/unix/support
upstream/1.0.2~svn20061127/src/samples
upstream/1.0.2~svn20061127/src/test
upstream/1.0.2~svn20061127/src/test/org
upstream/1.0.2~svn20061127/src/test/org/apache
upstream/1.0.2~svn20061127/src/test/org/apache/commons
upstream/1.0.2~svn20061127/src/test/org/apache/commons/daemon
upstream/1.0.2~svn20061127/xdocs
upstream/1.0.2~svn20061127/xdocs/images
upstream/1.0.2~svn20061127/xdocs/style
Marcus Better
marcusb-guest at alioth.debian.org
Tue Nov 28 10:08:31 CET 2006
Author: marcusb-guest
Date: 2006-11-28 10:08:26 +0100 (Tue, 28 Nov 2006)
New Revision: 2794
Added:
branches/commons-daemon/upstream/
branches/commons-daemon/upstream/1.0.2~svn20061127/
branches/commons-daemon/upstream/1.0.2~svn20061127/KEYS
branches/commons-daemon/upstream/1.0.2~svn20061127/LICENSE.txt
branches/commons-daemon/upstream/1.0.2~svn20061127/NOTICE.txt
branches/commons-daemon/upstream/1.0.2~svn20061127/PROPOSAL.html
branches/commons-daemon/upstream/1.0.2~svn20061127/README
branches/commons-daemon/upstream/1.0.2~svn20061127/RELEASE-NOTES.txt
branches/commons-daemon/upstream/1.0.2~svn20061127/STATUS.html
branches/commons-daemon/upstream/1.0.2~svn20061127/build-maven.xml
branches/commons-daemon/upstream/1.0.2~svn20061127/build.properties.sample
branches/commons-daemon/upstream/1.0.2~svn20061127/build.xml
branches/commons-daemon/upstream/1.0.2~svn20061127/doap_daemon.rdf
branches/commons-daemon/upstream/1.0.2~svn20061127/maven.xml
branches/commons-daemon/upstream/1.0.2~svn20061127/project.properties
branches/commons-daemon/upstream/1.0.2~svn20061127/project.xml
branches/commons-daemon/upstream/1.0.2~svn20061127/src/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/conf/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/conf/MANIFEST.MF
branches/commons-daemon/upstream/1.0.2~svn20061127/src/docs/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/docs/daemon.css
branches/commons-daemon/upstream/1.0.2~svn20061127/src/docs/daemon.html
branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/Daemon.java
branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/DaemonContext.java
branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/DaemonController.java
branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/DaemonListener.java
branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/DaemonPermission.java
branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/support/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/support/DaemonLoader.java
branches/commons-daemon/upstream/1.0.2~svn20061127/src/media/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/media/logo.xcf
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/Makefile
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/README
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmoniadm/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmoniadm/icon1.ico
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmoniadm/resource.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmoniadm/vdmoniadm.dsp
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmoniadm/vdmoniadm.dsw
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmoniadm/vdmoniadm.rc
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmonisvc/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmonisvc/resource.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmonisvc/vdmonisvc.dsp
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmonisvc/vdmonisvc.dsw
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmonisvc/vdmonisvc.rc
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/lib/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/lib/moni_inst.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/moni/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/moni/Makefile
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/moni/vdmoniadm.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/moni/vdmonisvc.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/LICENSE
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.dsp
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.manifest
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.rc
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.vcproj
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/jar2exe/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/jar2exe/jar2exe.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/jar2exe/jar2exe.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/jar2exe/jar2exe.rc
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/jar2exe/jar2exe.vcproj
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.dsp
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.manifest
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.rc
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.vcproj
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunsrv/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunsrv/prunsrv.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunsrv/prunsrv.dsp
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunsrv/prunsrv.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunsrv/prunsrv.rc
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunsrv/prunsrv.vcproj
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/MSG00001.bin
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/example/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/example/example.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/example/example.vcproj
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/example/exservice.bat
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/srvbatch.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/srvbatch.rc
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/srvbatch.sln
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/srvbatch.vcproj
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/apxwin.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/cmdline.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/console.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/gui.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/handles.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/javajni.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/log.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/registry.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/rprocess.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/service.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/java/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/java/Test.java
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/libprocrun.dsp
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/libprocrun.vcproj
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/procrun.dsw
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/procrun.sln
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/apsvcmgr.ico
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/jakarta.bmp
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/license.rtf
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/procrunr.ico
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/procruns.ico
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/procrunw.ico
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/sorterd.bmp
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/sorteru.bmp
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/sstatus.bmp
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/susers.bmp
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/toolbar.bmp
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/samples/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/samples/cchild.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/samples/cchild.vcproj
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/cmdline.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/console.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/gui.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/handles.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/javajni.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/log.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/mclib.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/mclib.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/private.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/registry.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/rprocess.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/service.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/utils.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/testchild/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/testchild/testchild.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/testchild/testchild.dsp
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/testchild/testchild.vcproj
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/xdocs/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/xdocs/index.xml
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/service/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/service/Makefile
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/service/instmain.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/service/instsvc.dsp
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/service/instsvc.dsw
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/signals/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/signals/kills.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/supcalls_nt/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/supcalls_nt/vdenv.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/CHANGES.txt
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/INSTALL.txt
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/Makedefs.in
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/Makefile.in
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/configure.in
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/man/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/man/README
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/man/fetch.sh
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/man/jsvc.1.xml
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/Makefile.in
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/Tomcat.sh
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/Tomcat5.sh
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/arguments.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/arguments.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/debug.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/debug.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/dso-dlfcn.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/dso-dyld.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/dso.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/help.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/help.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/home.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/home.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/java.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/java.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/jsvc-unix.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/jsvc.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/location.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/location.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/replace.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/replace.h
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/signals.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/apfunctions.m4
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/apjava.m4
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/apsupport.m4
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/buildconf.sh
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/config.guess
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/config.sub
branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/install.sh
branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/AloneDaemon.sh
branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/AloneService.java
branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/Native.c
branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/Native.sh
branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/README.txt
branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/ServiceDaemon.java
branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/ServiceDaemon.sh
branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/ServiceDaemonReadThread.java
branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/SimpleDaemon.java
branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/SimpleDaemon.sh
branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/build.xml
branches/commons-daemon/upstream/1.0.2~svn20061127/src/test/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/test/org/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/test/org/apache/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/test/org/apache/commons/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/test/org/apache/commons/daemon/
branches/commons-daemon/upstream/1.0.2~svn20061127/src/test/org/apache/commons/daemon/SimpleDaemon.java
branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/
branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/binaries.xml
branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/faq.xml
branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/images/
branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/images/logo.gif
branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/images/logo.png
branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/index.xml
branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/jsvc.xml
branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/navigation.xml
branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/procrun.xml
branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/style/
branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/style/project.css
Log:
Import upstream sources.
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/KEYS
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/KEYS 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/KEYS 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,51 @@
+This file contains the PGP&GPG keys of various Apache developers.
+Please don't use them for email unless you have to. Their main
+purpose is code signing.
+
+Apache users: pgp < KEYS
+Apache developers:
+ (pgpk -ll <your name> && pgpk -xa <your name>) >> this file.
+ or
+ (gpg --fingerprint --list-sigs <your name>
+ && gpg --armor --export <your name>) >> this file.
+
+Apache developers: please ensure that your key is also available via the
+PGP keyservers (such as pgpkeys.mit.edu).
+
+Type Bits/KeyID Date User ID
+pub 1024D/86867BA6 2001-11-22 Jean-Frederic Clere (jfclere) <JFrederic.Clere at fujitsu-siemens.com>
+
+
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: GnuPG v1.3.3 (GNU/Linux)
+
+mQGiBDv9Gx8RBADclmKwDLcibNVipQnhYW+bFIpuQjQnRrqRwn3gXM+/luzzJYJ4
+bbWpw13zjX0EkrAJ8qH2A/d0EIU1eZ0zHrLgRvMUfLGFUX7FFFw18JKFLTVGhG4/
+8sSl3ydHSA2Kd1PF6xjBP7iM7sg5dJfEkyMzvK5H4F0ZpTqy3087wsg1wwCgitRy
+Zg4x3lWZSkOwBj472qaO9GkD/2q6kyWfAK6XFe3GuB5AAs3poMfN1eqW+duM4TA8
+zUiWK0Wxx4JXJbL7n0i4d+JdXJsrjSjF++KKfelcxsrSxoUIBegez25MUSvHe09D
+R3nqkY8CVO+viEtzRBqkSgCMbUjAtfkQ+vp2jDnWSmmkNfY0OYAzt+KRyJKcjUSJ
+gvOOA/45+DN9wuTELoFTvsXh1JgOL/QvW1fmQ2HrcQk94BkzIsfVGWClCiig5gNw
+LCxTbfgA5htpI8U7vPR9/5gH7U8Wy3HR6xQUZxcbttMeYit2VbDEJzF5r5S0pJvD
+vyk3n1kiKU7r49sjhxGgE8J/VvDpO6YcIsDs8LoULwuJTg0DTrRDSmVhbi1GcmVk
+ZXJpYyBDbGVyZSAoamZjbGVyZSkgPEpGcmVkZXJpYy5DbGVyZUBmdWppdHN1LXNp
+ZW1lbnMuY29tPohGBBARAgAGBQJAEVHcAAoJEFd7hHVGA0DQsUsAoK2SuAnTybek
+AJkFmei/kbv59fA+AJ4/smxUz6EGuNmWOYwnHTxPz09c4IhXBBMRAgAXBQI7/Rsf
+BQsHCgMEAxUDAgMWAgECF4AACgkQ0+/mtoaGe6amGQCeJU5VZ8QCi8+PY0QJHPA6
+3e5uPyoAmgOWIwFm8A/xmW8qjEvVAWtbTjZxiJwEEwECAAYFAj/F+7gACgkQN+P0
+X+5l4yHDEwQAwp2yr9mwHIti5D2tvgNDQjOw9K/qbGbQ1IH3f/BLF0J5EHxYxUSt
+E0glh8GPJOi1U+0Jv999W/8xnOs5Tf16d0DmhscXvylxWYGis1PcoqA2zemaWuVM
+nBoJaA89gPiwconEEvdxym7vBGK1Lodz+ote2doiuCsWSjcfl74LFxeInAQTAQIA
+BgUCP8dbpwAKCRArAsNF4kSQGcqYA/9ZkL7Uwy1xZ8EPAQT6eXVCmS743C3Mc2kr
+Cv8CEnsVNQrsQMYzkU2OjsJ09semmIHnvpx14i8cGlLRoKpfNn7V+O6wmMEHr2zn
+HlMtDsgvk8FK12cDGGxUlHr9sz6wOTQyZG3bNLA9iQPUlHAjTTZlISx55i3/opKQ
+yI5LzOMaSrkBDQQ7/RsjEAQAgmxZUhfrnVv0M9qJJw3p/B6KpeENUOwlEE2z46EA
+HGIGYC67EeoXPWgiH9yreKmQYENTnvTPwHpjhYVNOFDad3YB5PdRGEb8fNEbmvfd
+qf/Fe0DocCAVW9lxPGrOZy9o/MOic+3krP24r8Zvcg9AB/yOR9NUQCYr0Wzk7FIE
+pA8AAwUD+QEZVtjanNFNe2rELJjGL09VDIjosgcFA/wyBBtl8tYZRL3ZY4PFlNuo
+3I6RqjK0+vU+GfnmdqFcokUE1uKjFASnNDW8/PYS9Kr/SuNRMccR/iYBNXLEVb5s
+AE/CMpZ4aH+0yS0Qbb2p9/qdtSsZdbkOzG5i0/O+bvr3PidPfHyIiEYEGBECAAYF
+Ajv9GyMACgkQ0+/mtoaGe6Z/VACfX9EytEEDrY0Ab8QIrLKKWIQyhxgAnj2YNJPb
+I+vcsJ1VqwUvX7xQvY3A
+=6E4I
+-----END PGP PUBLIC KEY BLOCK-----
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/LICENSE.txt
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/LICENSE.txt 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/LICENSE.txt 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/NOTICE.txt
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/NOTICE.txt 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/NOTICE.txt 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,2 @@
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/PROPOSAL.html
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/PROPOSAL.html 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/PROPOSAL.html 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,140 @@
+<html>
+<head>
+<title>Proposal for Daemon Package</title>
+</head>
+<body bgcolor="white">
+
+<div align="center">
+<h1>Proposal for <em>Daemon</em> Package</h1>
+</div>
+
+<h3>(0) Rationale</h3>
+
+ <P>
+ Since 1994, the Java™ programming language evolved and became a
+ valid tool to develop, other than applets and client applications,
+ reliable and performant server applications. The major disadvantage of
+ the Java™ platform is that still today the only portable way to
+ start a Java™ applcation relies on a single point of entry: the
+ <CODE><EM CLASS="key">public static void</EM> main(<EM CLASS="ref">String</EM>[])</CODE>
+ method.
+ </P>
+ <P>
+ Having a single-point of entry is a valid solution for client
+ applications, where interactively a user can command to the application
+ to quit (which can terminate the Virtual Machine process at calling the
+ <CODE><EM CLASS="ref">System</EM>.exit(<EM CLASS="key">int</EM>)</CODE>
+ method), but in those cases where the application is not interactive
+ (server applications) there is currently no portable way to notify
+ the Virtual Machine of its imminent shutdown.
+ </P>
+ <P>
+ A server application written in Java might have to perform several tasks
+ before being able to shutdown the Virtual Machine process. For example
+ in the case of a Servlet container, before the VM process is shut down,
+ sessions might need to be serialized to disk, and web applications need
+ to be destroyed.
+ </P>
+ <P>
+ One common solution to this problem is to create (for example) a
+ <CODE><EM CLASS="ref">ServerSocket</EM></CODE> and wait for a particular
+ message to be issued. When the message is received, all operations
+ required to shut down the server applications are performed and at the
+ end the <CODE><EM CLASS="ref">System</EM>.exit</CODE> method is called
+ to terminate the Virtual Machine process. This method, however, implies
+ several disadvantages and risks: for example in case of a system-wide
+ shutdown, it might happen that the Virtual Machine process will be shut
+ down directly by the operating system, without notifying the running
+ server application. Or, for example, if an attacker finds out what is
+ the required message to send to the server, and discovers a way to send
+ this message to the running server application, he can easily interrupt
+ the operation of a server, bypassing all the security restrictions
+ implemented in the operating system.
+ </P>
+ <P>
+ Most multi-user operating systems already have a way in which server
+ applications are started and stopped, under Unix based operating systems
+ non interactive server applications are called <em>daemons</em> and are
+ controlled by the operating system with a set of specified
+ <em>signals</em>. Under Windows such programs are called <em>services</em>
+ and are controlled by appropriate calls to specific functions defined in
+ the application binary, but although the ways of dealing with the problem
+ are different, in both cases the operating system can notify a server
+ application of its imminent shutdown, and the application has the
+ ability to perform certain tasks before its process of execution is
+ destroyed.
+ </P>
+
+<h3>(1) Scope of the Package</h3>
+
+ <P>
+ The scope of this specification is to define an API in line with the
+ current Java™ Platform APIs to support an alternative invocation
+ mechanism which could be used instead of the above mentioned
+ <CODE><EM CLASS="key">public static void</EM> main(<EM CLASS="ref">String</EM>[])</CODE>
+ method. This specification cover the behavior and life cycle of what
+ we define as "Java ™ daemons", or, in other words,
+ non interactive Java™ applications.
+ </P>
+ <P>
+ This specification does not cover how the container of a Java™
+ daemon must be implemented, or how to build a native liaison between
+ the operating system and the <CODE><EM CLASS="ref">Daemon</EM></CODE>
+ interface, but defines the relation between the an operating system
+ process and the <CODE><EM CLASS="ref">Daemon</EM></CODE> implementation
+ life cycle. It should be trivial for implementors to build a native
+ liaison and container for Java™ daemons.
+ </P>
+ <P>
+ This specification, together with the related API documentation, can be
+ used by software deveopers to build portable non interactive applications
+ based on the Java™ platform.
+ </P>
+
+<h3>(1.5) Interaction With Other Packages</h3>
+
+<p><em>Daemon</em> relies only on standard JDK 1.2 (or later) APIs for
+production deployment. It utilizes the JUnit unit testing framework for
+developing and executing unit tests, but this is of interest only to
+developers of the component. Daemon will be a dependency for
+several existing components in the open source world.</p>
+
+<p>No external configuration files are utilized.</p>
+
+
+<h3>(2) Initial Source of the Package</h3>
+
+<p>The original Java classes come from the Jakarta Tomcat 4.0 project.</p>
+
+<p>The proposed package name for the new component is
+<code>org.apache.commons.daemon</code>.</p>
+
+
+<h3>(3) Required Jakarta-Commons Resources</h3>
+
+<ul>
+<li>CVS Repository - New directory <code>daemon</code> in the
+ <code>jakarta-commons</code> CVS repository.</li>
+<li>Mailing List - Discussions will take place on the general
+ <em>commons-dev at jakarta.apache.org</em> mailing list. To help
+ list subscribers identify messages of interest, it is suggested that
+ the message subject of messages about this component be prefixed with
+ [Daemon].</li>
+<li>Bugzilla - New component "Daemon" under the "Commons" product
+ category, with appropriate version identifiers as needed.</li>
+<li>Jyve FAQ - New category "commons-daemon" (when available).</li>
+</ul>
+
+
+<h3>(4) Initial Committers</h3>
+
+<p>The initial committers on the Daemon component shall be:</p>
+<ul>
+<li>Jean-Frederic Clere</li>
+<li>Pier Fumagalli</li>
+<li>Remy Maucherat</li>
+
+
+
+</body>
+</html>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/README
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/README 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/README 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,26 @@
+To build the JAVA part:
+ant dist
+
+To build the native part:
+1 - jsvc:
+ cd src/native/unix; configure; make
+ You need a gnu make.
+ The jsvc executable could be found in dist.
+ There is a INSTALL.txt src/native/unix please have a look to it.
+
+ On windoze the additional step is needed:
+ cd src/native/nt; make
+ There is a README in src/native/nt please have a look to it.
+ The exe files are created in dist.
+2 - procrun:
+ procrun is only for windows
+ cd src/native/nt/procrun; make
+ (It is also possible to use the m$ developement tools).
+
+To build the documentation: (See http://jakarta.apache.org/commons/building.html).
+maven site:generate
+(Do not forget to get ../commons-build: (cd ..; svn co http://svn.apache.org/repos/asf/jakarta/commons/proper/commons-build/trunk/ commons-build))
+
+To deploy the documentation to apache site:
+maven -Dmaven.username=${user.name} site:deploy
+(Check <siteAddress/> in project.xml).
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/RELEASE-NOTES.txt
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/RELEASE-NOTES.txt 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/RELEASE-NOTES.txt 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,31 @@
+$Id: RELEASE-NOTES.txt 170552 2005-05-17 09:02:03Z jfclere $
+
+ Commons Daemon Package
+ Version 1.0.1
+ Release Notes
+
+
+INTRODUCTION:
+
+This document contains the release notes for this version of the Commons
+Daemon package, and highlights changes since the previous version. The
+current release adds new features and bug fixes, and is being done now to
+follow the release early/release often mentality.
+
+
+NEW FEATURES:
+
+* Initial import to Commons, including the daemon Java API, and jsvc
+ for Unix and Windows NT/2K/XP, which allows running a Java program
+ as a native operating system daemon
+
+* Add -wait and -stop parameters. (1.0.1).
+ The -wait parameter is experimental: that a is loop testing for a file in /tmp
+ and waiting n/10 seconds.
+
+* Allow to run as normal user for testing. (1.0.1).
+
+
+BUG FIXES:
+
+1.0.1: 304310, 30177, 27523, 29465, 31614, 33580, 31613, 34851.
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/STATUS.html
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/STATUS.html 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/STATUS.html 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,74 @@
+<html>
+<head>
+<title>Status File for Jakarta Commons "Daemon" Component</title>
+</head>
+<body bgcolor="white">
+
+
+<div align="center">
+<h1>The Jakarta Commons <em>Daemon</em> Component</h1>
+$Id: STATUS.html 155409 2005-02-26 12:57:06Z dirkv $<br />
+<a href="#Introduction">[Introduction]</a>
+<a href="#Dependencies">[Dependencies]</a>
+<a href="#Release Info">[Release Info]</a>
+<a href="#Committers">[Committers]</a>
+<br /><br />
+</div>
+
+
+<a name="Introduction"></a>
+<h3>1. INTRODUCTION</h3>
+
+<p>The <em>Daemon</em> Component contains a set of Java and native code,
+including:</p>
+<ul>
+<li>A set of Java interfaces applications must implement</li>
+<li>Unix native code to control a Java daemon from a Unix operating system</li>
+<li>Win32 code to control a Java daemon from a NT based Windows operating
+system</li>
+</ul>
+<p>This code was originally developped as part of the Tomcat project.</p>
+
+
+<a name="Dependencies"></a>
+<h3>2. DEPENDENCIES</h3>
+
+<p>The <em>Daemon</em> component is dependent upon the following external
+components for development and use:</p>
+<ul>
+<li><a href="http://java.sun.com/j2se">Java Development Kit</a>
+ (Version 1.2 or later)</li>
+<li><a href="http://www.junit.org">JUnit Testing Framework</a>
+ (Version 3.7 or later) - for unit tests only, not required
+ for deployment</li>
+</ul>
+
+
+<a name="Release Info"></a>
+<h3>3. RELEASE INFO</h3>
+
+<p>Current Release: Daemon is yet to be released. We hope it will be RSN.</p>
+
+<p></p>
+
+
+<a name="Committers"></a>
+<h3>4. COMMITTERS</h3>
+
+<p>The following individuals are the primary developers and maintainers of this
+component. Developers who plan to use <em>Daemon</em> in their own
+projects are encouraged to collaborate on the future development of this
+component to ensure that it continues to meet a variety of needs.</p>
+<ul>
+<li>Jean-Frederic Clere</li>
+<li>Pier Fumagalli</li>
+<li>Patrick Luby</li>
+<li>Costin Manolache</li>
+<li>Remy Maucherat</li>
+<li>Yoav Shapira</li>
+<li>Bill Barker</li>
+</ul>
+
+
+</body>
+</html>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/build-maven.xml
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/build-maven.xml 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/build-maven.xml 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,204 @@
+<?xml version="1.0"?>
+
+<project name="maven" default="maven:jar" basedir=".">
+
+ <!-- Give user a chance to override without editing this file
+ (and without typing -D each time they invoke a target) -->
+
+ <!-- Allow any user specific values to override the defaults -->
+ <property file="${user.home}/build.properties" />
+ <!-- Allow user defaults for this build -->
+ <property file="build.properties" />
+ <!-- Set default values for the project -->
+ <property file="project.properties" />
+
+ <!-- maven:start -->
+
+ <!-- ================================================================== -->
+ <!-- D E L E G A T O R S -->
+ <!-- ================================================================== -->
+
+
+ <target name="maven:site">
+ <ant antfile="${maven.home}/plugins/docs/build.xml" target="site"/>
+ </target>
+
+
+ <target name="maven:dist">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="dist"/>
+ </target>
+
+
+ <target name="maven:env">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="env"/>
+ </target>
+
+
+ <target name="maven:test">
+ <ant antfile="${maven.home}/plugins/test/build.xml" target="test"/>
+ </target>
+
+
+ <target name="maven:announce">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="announce"/>
+ </target>
+
+
+ <target name="maven:activity-log">
+ <ant antfile="${maven.home}/plugins/docs/build.xml" target="activity-log"/>
+ </target>
+
+
+ <target name="maven:compile">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="compile"/>
+ </target>
+
+
+ <target name="maven:validate-war">
+ <ant antfile="${maven.home}/plugins/j2ee/build.xml" target="validate-war"/>
+ </target>
+
+
+ <target name="maven:pdf">
+ <ant antfile="${maven.home}/plugins/docs/build.xml" target="pdf"/>
+ </target>
+
+
+ <target name="maven:iutest">
+ <ant antfile="${maven.home}/plugins/iutest/build.xml" target="iutest"/>
+ </target>
+
+
+ <target name="maven:deploy-site">
+ <ant antfile="${maven.home}/plugins/docs/build.xml" target="deploy-site"/>
+ </target>
+
+
+ <target name="maven:deploy-dist">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="deploy-dist"/>
+ </target>
+
+
+ <target name="maven:war">
+ <ant antfile="${maven.home}/plugins/j2ee/build.xml" target="war"/>
+ </target>
+
+
+ <target name="maven:verify-project">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="verify-project"/>
+ </target>
+
+
+ <target name="maven:cvs-change-log">
+ <ant antfile="${maven.home}/plugins/docs/build.xml" target="cvs-change-log"/>
+ </target>
+
+
+ <target name="maven:ear">
+ <ant antfile="${maven.home}/plugins/j2ee/build.xml" target="ear"/>
+ </target>
+
+
+ <target name="maven:cross-ref">
+ <ant antfile="${maven.home}/plugins/docs/build.xml" target="cross-ref"/>
+ </target>
+
+
+ <target name="maven:update-jars">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="update-jars"/>
+ </target>
+
+
+ <target name="maven:validate-pom">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="validate-pom"/>
+ </target>
+
+
+ <target name="maven:install-jar">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="install-jar"/>
+ </target>
+
+
+ <target name="maven:fo">
+ <ant antfile="${maven.home}/plugins/docs/build.xml" target="fo"/>
+ </target>
+
+
+ <target name="maven:javadocs">
+ <ant antfile="${maven.home}/plugins/docs/build.xml" target="javadocs"/>
+ </target>
+
+
+ <target name="maven:validate-struts-war">
+ <ant antfile="${maven.home}/plugins/struts/build.xml" target="validate-struts-war"/>
+ </target>
+
+
+ <target name="maven:task-list">
+ <ant antfile="${maven.home}/plugins/docs/build.xml" target="task-list"/>
+ </target>
+
+
+ <target name="maven:ejb">
+ <ant antfile="${maven.home}/plugins/j2ee/build.xml" target="ejb"/>
+ </target>
+
+
+ <target name="maven:docs">
+ <ant antfile="${maven.home}/plugins/docs/build.xml" target="docs"/>
+ </target>
+
+
+ <target name="maven:clean">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="clean"/>
+ </target>
+
+
+ <target name="maven:dist-build">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="dist-build"/>
+ </target>
+
+
+ <target name="maven:metrics">
+ <ant antfile="${maven.home}/plugins/metrics/build.xml" target="metrics"/>
+ </target>
+
+
+ <target name="maven:docs-quick">
+ <ant antfile="${maven.home}/plugins/docs/build.xml" target="docs-quick"/>
+ </target>
+
+
+ <target name="maven:run-singletest">
+ <ant antfile="${maven.home}/plugins/test/build.xml" target="run-singletest"/>
+ </target>
+
+
+ <target name="maven:check-source">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="check-source"/>
+ </target>
+
+
+ <target name="maven:generate-reactor">
+ <ant antfile="${maven.home}/plugins/reactor/build.xml" target="generate-reactor"/>
+ </target>
+
+
+ <target name="maven:jar">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="jar"/>
+ </target>
+
+
+ <target name="maven:maven-update">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="maven-update"/>
+ </target>
+
+
+ <target name="maven:gump-descriptor">
+ <ant antfile="${maven.home}/plugins/core/build.xml" target="gump-descriptor"/>
+ </target>
+
+
+ <!-- maven:end -->
+
+</project>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/build.properties.sample
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/build.properties.sample 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/build.properties.sample 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,11 @@
+# The directory containing your binary distribution of JUnit,
+# version 3.7 or later
+junit.home = /usr/local/junit3.7
+
+# The pathname of the "junit.jar" JAR file
+junit.jar = ${junit.home}/junit.jar
+
+# Proxy
+# proxy
+maven.proxy.host = proxy.domain
+maven.proxy.port = 80
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/build.xml
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/build.xml 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/build.xml 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,260 @@
+<project name="Daemon" default="dist" basedir=".">
+
+
+<!--
+ "Daemon" component of the Jakarta Commons Subproject
+ $Id: build.xml 469698 2006-10-31 23:10:36Z bayard $
+-->
+
+
+<!-- ========== Initialize Properties ===================================== -->
+
+
+ <property file="build.properties"/> <!-- Component local -->
+ <property file="../build.properties"/> <!-- Commons local -->
+ <property file="${user.home}/build.properties"/> <!-- User local -->
+
+
+<!-- ========== External Dependencies ===================================== -->
+
+
+ <!-- The directory containing your binary distribution of JUnit,
+ version 3.7 or later -->
+ <property name="junit.home" value="/usr/local/junit3.7"/>
+
+
+<!-- ========== Derived Values ============================================ -->
+
+
+ <!-- The pathname of the "junit.jar" JAR file -->
+ <property name="junit.jar" value="${junit.home}/junit.jar"/>
+
+
+<!-- ========== Component Declarations ==================================== -->
+
+
+ <!-- The name of this component -->
+ <property name="component.name" value="daemon"/>
+
+ <!-- The primary package name of this component -->
+ <property name="component.package" value="org.apache.commons.daemon"/>
+
+ <!-- The title of this component -->
+ <property name="component.title" value="Java Daemons"/>
+
+ <!-- The current version number of this component -->
+ <property name="component.version" value="1.0.1"/>
+
+ <!-- The base directory for compilation targets -->
+ <property name="build.home" value="target"/>
+
+ <!-- The base directory for component executable files -->
+ <property name="bin.home" value="src/bin"/>
+
+ <!-- The base directory for component configuration files -->
+ <property name="conf.home" value="src/conf"/>
+
+ <!-- The base directory for distribution targets -->
+ <property name="dist.home" value="dist"/>
+
+ <!-- The base directory for component sources -->
+ <property name="source.home" value="src/java"/>
+
+ <!-- The base directory for unit test sources -->
+ <property name="test.home" value="src/test"/>
+
+ <!-- The ant dir (usefull for non standard layout) -->
+ <property name="ant.lib" value="${ant.home}/lib"/>
+
+ <!-- The pattern to be used to grab ant jars (usefull for non standard layout) -->
+ <property name="ant.jars.pattern" value="*.jar"/>
+
+
+<!-- ========== Compiler Defaults ========================================= -->
+
+
+ <!-- Should Java compilations set the 'debug' compiler option? -->
+ <property name="compile.debug" value="true"/>
+
+ <!-- Should Java compilations set the 'deprecation' compiler option? -->
+ <property name="compile.deprecation" value="true"/>
+
+ <!-- Should Java compilations set the 'optimize' compiler option? -->
+ <property name="compile.optimize" value="true"/>
+
+ <!-- Construct compile classpath -->
+ <path id="compile.classpath">
+ <pathelement location="${build.home}/classes"/>
+ </path>
+
+
+<!-- ========== Test Execution Defaults =================================== -->
+
+
+ <!-- Construct unit test classpath -->
+ <path id="test.classpath">
+ <pathelement location="${build.home}/classes"/>
+ <pathelement location="${build.home}/tests"/>
+ <pathelement location="${junit.jar}"/>
+ </path>
+
+ <!-- Should all tests fail if one does? -->
+ <property name="test.failonerror" value="true"/>
+
+ <!-- The test runner to execute -->
+ <property name="test.runner" value="junit.textui.TestRunner"/>
+
+
+<!-- ========== Executable Targets ======================================== -->
+
+
+ <target name="init"
+ description="Initialize and evaluate conditionals">
+ <echo message="-------- ${component.name} ${component.version} --------"/>
+ <filter token="name" value="${component.name}"/>
+ <filter token="package" value="${component.package}"/>
+ <filter token="version" value="${component.version}"/>
+ </target>
+
+
+ <target name="prepare" depends="init"
+ description="Prepare build directory">
+ <mkdir dir="${build.home}"/>
+ <mkdir dir="${build.home}/classes"/>
+ <mkdir dir="${build.home}/conf"/>
+ <mkdir dir="${build.home}/tests"/>
+ </target>
+
+
+ <target name="static" depends="prepare"
+ description="Copy static files to build directory">
+ <tstamp/>
+ <copy todir="${build.home}/conf" filtering="on">
+ <fileset dir="${conf.home}" includes="*.MF"/>
+ </copy>
+ </target>
+
+
+ <target name="compile" depends="static"
+ description="Compile shareable components">
+ <javac srcdir="${source.home}"
+ destdir="${build.home}/classes"
+ debug="${compile.debug}"
+ deprecation="${compile.deprecation}"
+ optimize="${compile.optimize}">
+ <classpath refid="compile.classpath"/>
+ </javac>
+ <!-- Copy all of the resource files -->
+ <copy todir="${build.home}/classes" filtering="on">
+ <fileset dir="${source.home}" excludes="**/*.java"/>
+ </copy>
+ <!-- Make the English resource files the default resource -->
+ <copy todir="${build.home}/classes" filtering="on">
+ <fileset dir="${source.home}" includes="**/*_en.properties"/>
+ <mapper type="glob" from="*_en.properties" to="*.properties"/>
+ </copy>
+ </target>
+
+
+ <target name="compile.tests" depends="compile"
+ description="Compile unit test cases">
+ <javac srcdir="${test.home}"
+ destdir="${build.home}/tests"
+ debug="${compile.debug}"
+ deprecation="${compile.deprecation}"
+ optimize="${compile.optimize}">
+ <classpath refid="test.classpath"/>
+ </javac>
+ <copy todir="${build.home}/tests" filtering="on">
+ <fileset dir="${test.home}" excludes="**/*.java"/>
+ </copy>
+ </target>
+
+
+ <target name="clean"
+ description="Clean build and distribution directories">
+ <delete dir="${build.home}"/>
+ <delete dir="${dist.home}"/>
+ </target>
+
+
+ <target name="all" depends="clean,compile"
+ description="Clean and compile all components"/>
+
+
+ <target name="javadoc" depends="compile"
+ description="Create component Javadoc documentation">
+ <mkdir dir="${dist.home}"/>
+ <mkdir dir="${dist.home}/docs"/>
+ <mkdir dir="${dist.home}/docs/api"/>
+ <javadoc sourcepath="${source.home}"
+ destdir="${dist.home}/docs/api"
+ packagenames="org.apache.commons.*"
+ author="true"
+ version="true"
+ doctitle="<h1>${component.title}</h1>"
+ windowtitle="${component.title} (Version ${component.version})"
+ bottom="Copyright (c) 2001-2002 - Apache Software Foundation">
+ <classpath refid="compile.classpath"/>
+ <classpath location="${ant.lib}/ant.jar"/>
+ </javadoc>
+ </target>
+
+
+ <target name="dist" depends="compile,javadoc"
+ description="Create binary distribution">
+ <mkdir dir="${dist.home}"/>
+ <mkdir dir="${dist.home}/lib"/>
+ <mkdir dir="${dist.home}/logs"/>
+ <copy file="LICENSE.txt"
+ todir="${dist.home}"/>
+ <copy file="NOTICE.txt"
+ todir="${dist.home}"/>
+ <copy file="RELEASE-NOTES.txt"
+ todir="${dist.home}"/>
+ <copy todir="${dist.home}/bin/unix/jsvc-src">
+ <fileset dir="src/native/unix" />
+ </copy>
+ <fixcrlf srcdir="${dist.home}/bin/unix" eol="lf" />
+ <tar compression="gzip" destfile="${dist.home}/bin/jsvc.tar.gz"
+ basedir="${dist.home}/bin/unix" />
+ <delete dir="${dist.home}/bin/unix" />
+ <antcall target="jar"/>
+ </target>
+
+
+ <target name="jar" depends="compile"
+ description="Create jar">
+ <mkdir dir="${dist.home}"/>
+ <mkdir dir="${dist.home}/bin"/>
+ <mkdir dir="${build.home}/classes/META-INF"/>
+ <copy file="LICENSE.txt"
+ tofile="${build.home}/classes/META-INF/LICENSE.txt"/>
+ <copy file="NOTICE.txt"
+ tofile="${build.home}/classes/META-INF/NOTICE.txt"/>
+ <jar jarfile="${dist.home}/commons-${component.name}.jar"
+ basedir="${build.home}/classes"
+ manifest="${build.home}/conf/MANIFEST.MF"
+ includes="org/apache/commons/daemon/**"/>
+ </target>
+
+
+ <target name="install-jar" depends="jar"
+ description="--> Installs jar file in ${lib.repo}">
+ <copy todir="${lib.repo}" filtering="off">
+ <fileset dir="${dist.home}">
+ <include name="commons-${component.name}.jar"/>
+ </fileset>
+ </copy>
+ </target>
+
+
+<!-- ========== Unit Test Targets ========================================= -->
+
+
+ <target name="test" depends="compile.tests"
+ description="Run all unit test cases">
+ </target>
+
+
+</project>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/doap_daemon.rdf
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/doap_daemon.rdf 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/doap_daemon.rdf 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<rdf:RDF xmlns="http://usefulinc.com/ns/doap#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:asfext="http://projects.apache.org/ns/asfext#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:doap="http://usefulinc.com/ns/doap#" xml:lang="en">
+ <Project rdf:about="http://jakarta.apache.org/commons/daemon/">
+ <name>Apache Jakarta Commons Daemon</name>
+ <homepage rdf:resource="http://jakarta.apache.org/commons/daemon/"/>
+ <programming-language>Java</programming-language>
+ <category rdf:resource="http://projects.apache.org/category/library"/>
+ <license rdf:resource="http://usefulinc.com/doap/licenses/asl20"/>
+ <bug-database rdf:resource="http://issues.apache.org/jira/browse/DAEMON"/>
+ <download-page rdf:resource="http://jakarta.apache.org/site/downloads/downloads_commons-daemon.cgi"/>
+ <asfext:pmc rdf:resource="http://jakarta.apache.org/"/>
+ <shortdesc xml:lang="en">Commons Daemon</shortdesc>
+ <description xml:lang="en">Commons Daemon</description>
+ <repository>
+ <SVNRepository>
+ <browse rdf:resource="http://svn.apache.org/repos/asf/jakarta/commons/proper/daemon/trunk"/>
+ <location rdf:resource="http://svn.apache.org/repos/asf/jakarta/commons/proper/daemon"/>
+ </SVNRepository>
+ </repository>
+ <release>
+ <revision>
+ <name>commons-daemon</name>
+ <created>2005-05-17</created>
+ <version>1.0.1</version>
+ </revision>
+ </release>
+ <mailing-list rdf:resource="http://jakarta.apache.org/site/mail2.html#Commons"/>
+ </Project>
+</rdf:RDF>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/maven.xml
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/maven.xml 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/maven.xml 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,36 @@
+<!--
+ Copyright 2001-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project default="java:jar"
+ xmlns:j="jelly:core">
+
+ <!-- ================================================================== -->
+ <!-- START : C O M M O N S - B U I L D -->
+ <!-- ================================================================== -->
+ <!-- Required: Look and Feel for documentation within distributions -->
+ <!-- ================================================================== -->
+ <postGoal name="xdoc:copy-resources">
+ <copy todir="${basedir}/target/docs/style/" failonerror="false">
+ <fileset dir="${basedir}/../commons-build/xdocs/style">
+ <include name='**/*'/>
+ <exclude name='**/CVS/**'/>
+ </fileset>
+ </copy>
+ </postGoal>
+ <!-- ================================================================== -->
+ <!-- END: C O M M O N S - B U I L D -->
+ <!-- ================================================================== -->
+
+</project>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/project.properties
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/project.properties 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/project.properties 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,24 @@
+##
+# Properties that override Maven build defaults
+##
+
+maven.changelog.factory=org.apache.maven.svnlib.SvnChangeLogFactory
+
+# Jar Manifest Additional Attributes
+maven.jar.manifest.attributes.list=Implementation-Vendor-Id,X-Compile-Source-JDK,X-Compile-Target-JDK
+maven.jar.manifest.attribute.Implementation-Vendor-Id=org.apache
+maven.jar.manifest.attribute.X-Compile-Source-JDK=${maven.compile.source}
+maven.jar.manifest.attribute.X-Compile-Target-JDK=${maven.compile.target}
+
+#maven.checkstyle.properties=${basedir}/checkstyle.xml
+maven.test.failure = false
+maven.junit.fork=true
+maven.linkcheck.enable=false
+
+maven.xdoc.jsl=../commons-build/commons-site.jsl
+maven.xdoc.date=left
+maven.xdoc.version=${pom.currentVersion}
+maven.xdoc.developmentProcessUrl=http://jakarta.apache.org/commons/charter.html
+maven.xdoc.poweredby.image=maven-feather.png
+
+
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/project.properties
___________________________________________________________________
Name: svn:executable
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/project.xml
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/project.xml 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/project.xml 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2001-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project>
+ <pomVersion>3</pomVersion>
+
+ <groupId>commons-daemon</groupId>
+ <artifactId>commons-daemon</artifactId>
+ <currentVersion>1.0.2-SNAPSHOT</currentVersion>
+ <inceptionYear>2003</inceptionYear>
+ <name>Daemon</name>
+ <shortDescription>Commons Daemon</shortDescription>
+ <description>Commons Daemon</description>
+ <logo>/images/logo.png</logo>
+ <url>http://jakarta.apache.org/commons/${pom.artifactId.substring(8)}/</url>
+ <package>org.apache.commons.${pom.artifactId.substring(8)}</package>
+
+ <organization>
+ <name>The Apache Software Foundation</name>
+ <url>http://jakarta.apache.org</url>
+ <logo>http://jakarta.apache.org/images/jakarta-logo.gif</logo>
+ </organization>
+
+ <licenses>
+ <license>
+ <name>The Apache Software License, Version 2.0</name>
+ <url>/LICENSE.txt</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <gumpRepositoryId>jakarta</gumpRepositoryId>
+ <issueTrackingUrl>http://issues.apache.org/jira/</issueTrackingUrl>
+ <siteAddress>people.apache.org</siteAddress>
+ <siteDirectory>/www/jakarta.apache.org/commons/${pom.artifactId.substring(8)}/</siteDirectory>
+ <distributionDirectory>/www/jakarta.apache.org/builds/jakarta-commons/${pom.artifactId.substring(8)}/</distributionDirectory>
+
+ <repository>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/jakarta/commons/proper/${pom.artifactId.substring(8)}/trunk</connection>
+ <url>http://svn.apache.org/repos/asf/jakarta/commons/proper/${pom.artifactId.substring(8)}/trunk</url>
+ </repository>
+
+ <mailingLists>
+ <mailingList>
+ <name>Commons Dev List</name>
+ <subscribe>commons-dev-subscribe at jakarta.apache.org</subscribe>
+ <unsubscribe>commons-dev-unsubscribe at jakarta.apache.org</unsubscribe>
+ <archive>http://mail-archives.apache.org/eyebrowse/SummarizeList?listName=commons-dev@jakarta.apache.org</archive>
+ </mailingList>
+ <mailingList>
+ <name>Commons User List</name>
+ <subscribe>commons-user-subscribe at jakarta.apache.org</subscribe>
+ <unsubscribe>commons-user-unsubscribe at jakarta.apache.org</unsubscribe>
+ <archive>http://mail-archives.apache.org/eyebrowse/SummarizeList?listName=commons-user@jakarta.apache.org</archive>
+ </mailingList>
+ </mailingLists>
+
+ <developers>
+ <developer>
+ <name>Jean-Frederic Clere</name>
+ <id>jfclere</id>
+ <email>jfclere at apache.org</email>
+ <organization>Apache</organization>
+ </developer>
+
+ <developer>
+ <name>Remy Maucherat</name>
+ <id>remm</id>
+ <email>remm at apache.org</email>
+ <organization>Apache</organization>
+ </developer>
+
+ <developer>
+ <name>Yoav Shapira</name>
+ <id>yoavs</id>
+ <email>yoavs at apache.org</email>
+ <organization>Apache</organization>
+ </developer>
+
+ <developer>
+ <name>Bill Barker</name>
+ <id>billbarker</id>
+ <email>billbarker at apache.org</email>
+ <organization>Apache</organization>
+ </developer>
+ </developers>
+
+ <build>
+ <nagEmailAddress>commons-dev at jakarta.apache.org</nagEmailAddress>
+ <sourceDirectory>src/java</sourceDirectory>
+ <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
+ <integrationUnitTestSourceDirectory/>
+ <aspectSourceDirectory/>
+ <unitTest>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ <excludes>
+ <exclude>**/*AbstractTest.java</exclude>
+ </excludes>
+ <resources>
+ <resource>
+ <directory>${pom.build.unitTestSourceDirectory}</directory>
+ <includes>
+ <include>**/*.xml</include>
+ </includes>
+ </resource>
+ </resources>
+ </unitTest>
+ </build>
+
+ <reports>
+ <report>maven-changelog-plugin</report>
+ <report>maven-changes-plugin</report>
+ <report>maven-developer-activity-plugin</report>
+ <report>maven-file-activity-plugin</report>
+ <report>maven-javadoc-plugin</report>
+ <report>maven-jdepend-plugin</report>
+ <report>maven-junit-report-plugin</report>
+ <report>maven-jxr-plugin</report>
+ <report>maven-license-plugin</report>
+ <report>maven-tasklist-plugin</report>
+ </reports>
+</project>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/conf/MANIFEST.MF
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/conf/MANIFEST.MF 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/conf/MANIFEST.MF 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,5 @@
+Extension-Name: @package@
+Specification-Vendor: Apache Software Foundation
+Specification-Version: 1.0
+Implementation-Vendor: Apache Software Foundation
+Implementation-Version: @version@
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/docs/daemon.css
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/docs/daemon.css 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/docs/daemon.css 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,128 @@
+BODY {
+ font-family: arial, helvetica, sans-serif;
+ font-size: 10pt;
+ text-align: justify;
+}
+
+H1 {
+ border-width: 2px;
+ border-style: ridge;
+ border-color: #cccccc;
+ background-color: #ddddff;
+ font-size: 14pt;
+ font-weight: bold;
+ text-align: center;
+ padding: 2px;
+}
+
+H2 {
+ border-width: 2px;
+ border-style: ridge;
+ border-color: #cccccc;
+ background-color: #eeeeff;
+ font-size: 12pt;
+ font-weight: bold;
+ text-align: left;
+ padding: 2px;
+}
+
+H3 {
+ font-size: 10pt;
+ font-weight: bold;
+ text-align: left;
+}
+
+H4 {
+ font-size: 8pt;
+ font-weight: normal;
+ font-style: italic;
+ text-align: center;
+}
+
+P {
+ margin-left: 20px;
+}
+
+P.note {
+ border-width: 1px;
+ border-style: ridge;
+ border-color: #cccccc;
+ background-color: #ffffee;
+ font-size: 8pt;
+ font-weight: normal;
+ text-align: justify;
+ margin-left: 20%;
+ margin-right: 20%;
+ padding: 4px;
+}
+
+P.copyright {
+ font-size: 8pt;
+ font-weight: normal;
+ text-align: center;
+}
+
+PRE {
+ border-width: 1px;
+ border-style: ridge;
+ border-color: #cccccc;
+ background-color: #eeeeee;
+ font-size: 8pt;
+ font-weight: normal;
+ text-align: left;
+ margin-left: 10%;
+ margin-right: 10%;
+ padding: 4px;
+}
+
+CODE {
+ font-size: 8pt;
+ white-space: pre;
+ font-weight: normal;
+}
+
+EM.key {
+ color: #000099;
+ font-style: normal;
+ white-space: pre;
+}
+
+EM.ref {
+ color: #990000;
+ font-style: normal;
+ white-space: pre
+}
+
+EM.com {
+ color: #009900;
+ font-style: normal;
+ white-space: pre
+}
+
+OL {
+ list-style: decimal outside;
+ font-size: 10pt;
+}
+
+OL OL {
+ list-style: lower-alpha outside;
+ font-size: 8pt;
+}
+
+A:link {
+ color: #0000ee;
+ text-decoration: none;
+ white-space: pre;
+}
+
+A:visited {
+ color: #0000ee;
+ text-decoration: none;
+ white-space: pre;
+}
+
+A:active {
+ color: #0000ee;
+ text-decoration: none;
+ white-space: pre;
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/docs/daemon.html
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/docs/daemon.html 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/docs/daemon.html 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,261 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+ <HEAD>
+ <TITLE>Apache Daemon Specification - Version 1.0</TITLE>
+ <LINK REL="stylesheet" TYPE="text/css" HREF="daemon.css" TITLE="daemon">
+ <META HTTP-EQUIV="content-type" CONTENT="text/html; charset=ISO-8859-1">
+ </HEAD>
+ <BODY>
+
+ <H1>Apache Daemon Specification</H1>
+ <H4>Version 1.0</H4>
+
+ <P CLASS="note">
+ <strong>Abstract:</strong>
+ This document specifies the behavior and life cycle of an abstract
+ Java™ daemon, in relation to its native container. In addition
+ it defines a mechanism for controlling a daemon, and its interaction
+ with the native OS process in which its existance is confined.
+ </P>
+
+ <H2>Index</H2>
+ <OL>
+ <LI><A HREF="#1">Introduction</A>
+ <LI><A HREF="#2">Scope of this specification</A>
+ <LI><A HREF="#3">The Daemon interface and its life cycle</A>
+ <OL>
+ <LI><A HREF="#3A">Instantiation</A>
+ <LI><A HREF="#3B">Initialization</A>
+ <LI><A HREF="#3C">Startup</A>
+ <LI><A HREF="#3D">Stop</A>
+ <LI><A HREF="#3E">Destruction</A>
+ </OL>
+ </OL>
+
+ <A NAME="1"><H2>Introduction</H2></A>
+ <P>
+ Since 1994, the Java™ programming language evolved and became a
+ valid tool to develop, other than applets and client applications,
+ reliable and performant server applications. The major disadvantage of
+ the Java™ platform is that still today the only portable way to
+ start a Java™ applcation relies on a single point of entry: the
+ <CODE><EM CLASS="key">public static void</EM> main(<EM CLASS="ref">String</EM>[])</CODE>
+ method.
+ </P>
+ <P>
+ Having a single-point of entry is a valid solution for client
+ applications, where interactively a user can command to the application
+ to quit (which can terminate the Virtual Machine process at calling the
+ <CODE><EM CLASS="ref">System</EM>.exit(<EM CLASS="key">int</EM>)</CODE>
+ method), but in those cases where the application is not interactive
+ (server applications) there is currently no portable way to notify
+ the Virtual Machine of its imminent shutdown.
+ </P>
+ <P>
+ A server application written in Java might have to perform several tasks
+ before being able to shutdown the Virtual Machine process. For example
+ in the case of a Servlet container, before the VM process is shut down,
+ sessions might need to be serialized to disk, and web applications need
+ to be destroyed.
+ </P>
+ <P>
+ One common solution to this problem is to create (for example) a
+ <CODE><EM CLASS="ref">ServerSocket</EM></CODE> and wait for a particular
+ message to be issued. When the message is received, all operations
+ required to shut down the server applications are performed and at the
+ end the <CODE><EM CLASS="ref">System</EM>.exit</CODE> method is called
+ to terminate the Virtual Machine process. This method, however, implies
+ several disadvantages and risks: for example in case of a system-wide
+ shutdown, it might happen that the Virtual Machine process will be shut
+ down directly by the operating system, without notifying the running
+ server application. Or, for example, if an attacker finds out what is
+ the required message to send to the server, and discovers a way to send
+ this message to the running server application, he can easily interrupt
+ the operation of a server, bypassing all the security restrictions
+ implemented in the operating system.
+ </P>
+ <P>
+ Most multi-user operating systems already have a way in which server
+ applications are started and stopped, under Unix based operating systems
+ non interactive server applications are called <em>daemons</em> and are
+ controlled by the operating system with a set of specified
+ <em>signals</em>. Under Windows such programs are called <em>daemons</em>
+ and are controlled by appropriate calls to specific functions defined in
+ the application binary, but although the ways of dealing with the problem
+ are different, in both cases the operating system can notify a server
+ application of its imminent shutdown, and the application has the
+ ability to perform certain tasks before its process of execution is
+ destroyed.
+ </P>
+
+ <A NAME="2"><H2>Scope of this specification</H2></A>
+ <P>
+ The scope of this specification is to define an API in line with the
+ current Java™ Platform APIs to support an alternative invocation
+ mechanism which could be used instead of the above mentioned
+ <CODE><EM CLASS="key">public static void</EM> main(<EM CLASS="ref">String</EM>[])</CODE>
+ method. This specification cover the behavior and life cycle of what
+ we define as "Java ™ daemons", or, in other words,
+ non interactive Java™ applications.
+ </P>
+ <P>
+ This specification does not cover how the container of a Java™
+ daemon must be implemented, or how to build a native liaison between
+ the operating system and the <CODE><EM CLASS="ref">Daemon</EM></CODE>
+ interface, but defines the relation between the an operating system
+ process and the <CODE><EM CLASS="ref">Daemon</EM></CODE> implementation
+ life cycle. It should be trivial for implementors to build a native
+ liaison and container for Java™ daemons.
+ </P>
+ <P>
+ This specification, together with the related API documentation, can be
+ used by software deveopers to build portable non interactive applications
+ based on the Java™ platform.
+ </P>
+
+ <A NAME="3"><H2>The Daemon interface and its life cycle</H2></A>
+ <P>
+ The <CODE><EM CLASS="ref">Daemon</EM></CODE> interface (defined as
+ follows) is the main interface representing a Java™ daemon:
+ </P>
+<PRE>
+<EM CLASS="key">package</EM> org.apache.commons.daemon;
+
+<EM CLASS="key">public interface</EM> <EM CLASS="ref">Daemon</EM>
+<EM CLASS="key">extends</EM> <EM CLASS="ref">Runnable</EM> {
+
+ <EM CLASS="key">public void</EM> init(<EM CLASS="ref">DaemonContext</EM> context)
+ throws <EM CLASS="ref">Exception</EM>;
+
+ <EM CLASS="key">public void</EM> run();
+
+ <EM CLASS="key">public void</EM> die();
+
+ <EM CLASS="key">public void</EM> destroy();
+}</PRE>
+ <P>
+ A daemon is managed through a well defined life cycle that defines how
+ it is loaded, initialized, started, stopped and destroyed. This life
+ cycle is expressed in the API by the <CODE>init(...)</CODE>,
+ <CODE>run()</CODE>, <CODE>die()</CODE> and <CODE>destroy()</CODE> methods
+ of the <CODE><EM CLASS="ref">Daemon</EM></CODE> interface.
+ </P>
+
+ <A NAME="3A"><H3>Instantiation</H3></A>
+ <P>
+ The daemon container is responsible for instantiating daemons. Because
+ of this, concrete implementations of the <CODE><EM CLASS="ref">Daemon</EM></CODE>
+ interface must always expose a public void constructor, which will be
+ used by the daemon container to create instances of the class.
+ For example:
+ </P>
+
+<PRE>
+<EM CLASS="key">package</EM> mypackage;
+
+<EM CLASS="key">import</EM> org.apache.commons.daemon.*;
+
+
+<EM CLASS="key">public class</EM> <EM CLASS="ref">MyDaemon</EM>
+<EM CLASS="key">implements</EM> <EM CLASS="ref">Daemon</EM> {
+
+ <EM CLASS="com">/** This constructor must be here. */</EM>
+ <EM CLASS="key">public</EM> MyDaemon() {
+ super();
+ ...
+ }
+ ...
+}</PRE>
+ <P>
+ Once the Virtual Machine process is started in the underlying operating
+ system, and the Virtual Machine itself is created and configured, the
+ daemon container associated with its native liaison constructs a new
+ instance of the concrete class implementing the
+ <CODE><EM CLASS="ref">Daemon</EM></CODE> instance. It is not defined by
+ this specification how the instance is constructed, or how many instances
+ of one or more concrete daemons implementation can coexist in the same
+ Virtual Machine.
+ </P>
+ <P>
+ As a side note, in case of multiple daemons running within the scope
+ of the same virtual machine, developers should not rely on static
+ methods and variables for proper operation, as it is advisable for
+ security reasons to load each different daemon instance in a separate
+ class loader.
+ </P>
+
+ <A NAME="3B"><H3>Initialization</H3></A>
+ <P>
+ After the daemon instance has been constructed, the container must
+ initialize it before it can be started. Initialization is provided so
+ that a daemon can read persisten configuration data, access native
+ resources, and perform other one-time activities.
+ </P>
+ <P>
+ Under certain operating systems (typically Unix based operating systems),
+ and if the native liaison of the container supports and it is configured
+ accordingly, this method might be called with super-user privileges.
+ For example, within the scope of this method, it might be wise to create
+ all required <CODE><EM CLASS="ref">ServerSocket</EM></CODE> instances (as
+ under several operating systems this requires super-user privileges).
+ </P>
+ <P>
+ That said, it is very important that within the scope of this method
+ "untrusted" data cannot be processed (for example, starting
+ an acceptor thread on a <CODE><EM CLASS="ref">ServerSocket</EM></CODE>
+ which receives and processes data from unknown sources), as this would
+ serious security hazards.
+ </P>
+ <P>
+ The daemon container must guarantee that the <CODE>init(...)</CODE>
+ method is called at least once, and only once on an instance of a
+ daemon object, and that it will be called before any access to the
+ <CODE>run()</CODE>, <CODE>die()</CODE> or <CODE>destroy()</CODE>
+ methods.
+ </P>
+ <P>
+ During initialization, the daemon instance can throw any
+ <CODE><EM CLASS="ref">Exception</EM></CODE> preventing a the successful
+ completion of the <CODE>init(...)</CODE> method. In this case the daemon
+ instance must not be started, and the <CODE>destroy()</CODE> method must
+ not be called before the instance is released by the container to allow
+ garbage collecting.
+ </P>
+
+ <A NAME="3C"><H3>Startup</H3></A>
+ <P>
+ As the <CODE><EM CLASS="ref">Daemon</EM></CODE> interface extends the
+ <CODE><EM CLASS="ref">Runnable</EM></CODE> interface, to start the
+ operation of a daemon, the container calls the <CODE>run()</CODE> method
+ within the scope of a <CODE><EM CLASS="ref">Thread</EM></CODE>. A
+ daemon is said to be "running" until the thread
+ </P>
+
+
+
+ <HR>
+ <P CLASS="copyright">
+ Author Pier Fumagalli
+ <A HREF="mailto:pier.fumagalli at sun.com"><pier.fumagalli at sun.com></A>
+ <BR>
+ Copyright © 2001, The Apache Software Foundation
+ <A HREF="http://www.apache.org/"><http://www.apache.org/></A>
+ <BR>
+ All rights reserved.
+ </P>
+
+ <P CLASS="copyright">
+ Sun, Sun Microsystems, Solaris, and Java are trademarks or registered
+ trademarks of Sun Microsystems, Inc.
+ <A HREF="http://www.sun.com/"><http://www.sun.com/></A>
+ <BR>
+ UNIX® is a registered trademark in the United States and other
+ countries, exclusively licensed through X/Open Company, Ltd.
+ <A HREF="http://www.opengroup.org/"><http://www.opengroup.org/></A>
+ <BR>
+ Windows, WinNT and Win32 are registered trademark of Microsoft Corp.
+ <A HREF="http://www.microsoft.com/"><http://www.microsoft.com/></A>
+ </P>
+ </P>
+ </BODY>
+</HTML>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/Daemon.java
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/Daemon.java 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/Daemon.java 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.daemon;
+
+/**
+ * This interface provides support for native daemon invocation. Using
+ * a platform dependant helper program classes that implement the
+ * <code>Daemon</code> interface can be initialized, started and
+ * stopped according to the convensions of the underlying operating
+ * system.
+ * <p>
+ * Implementors of this interface must also provide a public constructor
+ * with no arguments so that instances can be created in an automated
+ * fashion.
+ * </p>
+ * @author Pier Fumagalli
+ * @author Copyright © 2000-2001 <a href="http://www.apache.org/">The
+ * Apache Software Foundation</a>. All rights reserved.
+ * @version 1.0 <i>(CVS $Revision: 155409 $)</i>
+ */
+public interface Daemon {
+
+ /**
+ * Initialize this <code>Daemon</code> instance.
+ * <p>
+ * This method gets called once the JVM process is created and the
+ * <code>Daemon</code> instance is created thru its empty public
+ * constructor.
+ * </p>
+ * <p>
+ * Under certain operating systems (typically Unix based operating
+ * systems) and if the native invocation framework is configured to do
+ * so, this method might be called with <i>super-user</i> privileges.
+ * </p>
+ * <p>
+ * For example, it might be wise to create <code>ServerSocket</code>
+ * instances within the scope of this method, and perform all operations
+ * requiring <i>super-user</i> privileges in the underlying operating
+ * system.
+ * </p>
+ * <p>
+ * Apart from set up and allocation of native resources, this method
+ * must not start the actual operation of the <code>Daemon</code> (such
+ * as starting threads calling the <code>ServerSocket.accept()</code>
+ * method) as this would impose some serious security hazards. The
+ * start of operation must be performed in the <code>start()</code>
+ * method.
+ * </p>
+ *
+ * @param context A <code>DaemonContext</code> object used to
+ * communicate with the container.
+ *
+ * @exception Exception Any exception preventing a successful
+ * initialization.
+ */
+ public void init(DaemonContext context)
+ throws Exception;
+
+ /**
+ * Start the operation of this <code>Daemon</code> instance. This
+ * method is to be invoked by the environment after the init()
+ * method has been successfully invoked and possibly the security
+ * level of the JVM has been dropped. <code>Implementors of this
+ * method are free to start any number of threads, but need to
+ * return control avfter having done that to enable invocation of
+ * the stop()-method.
+ */
+ public void start()
+ throws Exception;
+
+ /**
+ * Stop the operation of this <code>Daemon</code> instance. Note
+ * that the proper place to free any allocated resources such as
+ * sockets or file descriptors is in the destroy method, as the
+ * container may restart the Daemon by calling start() after
+ * stop().
+ */
+ public void stop()
+ throws Exception;
+
+ /**
+ * Free any resources allocated by this daemon such as file
+ * descriptors or sockets. This method gets called by the container
+ * after stop() has been called, before the JVM exits. The Daemon
+ * can not be restarted after this method has been called without a
+ * new call to the init() method.
+ */
+ public void destroy();
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/DaemonContext.java
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/DaemonContext.java 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/DaemonContext.java 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.daemon;
+
+
+/**
+ * Defines a set of methods that a Daemon instance can use to
+ * communicate with the Daemon container.
+ *
+ * @author Pier Fumagalli
+ * @author Copyright © 2000-2001 <a href="http://www.apache.org/">The
+ * Apache Software Foundation</a>. All rights reserved.
+ * @version 1.0 <i>(CVS $Revision: 155409 $)</i>
+ */
+public interface DaemonContext {
+
+ /**
+ * Returns <code>DaemonController</code> object that can be used
+ * to control the <code>Daemon</code> instance that this
+ * <code>DaemonContext</code> is passed to.
+ */
+ public DaemonController getController();
+
+ /**
+ * Returns an array of <code>String</code> arguments supplied by
+ * the environment. corresponding to the array of arguments given
+ * in the <code>public static void main()</code> method used as an
+ * entry point to most other java programs.
+ */
+ public String[] getArguments();
+
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/DaemonController.java
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/DaemonController.java 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/DaemonController.java 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.daemon;
+
+
+/**
+ *
+ * @author Pier Fumagalli
+ * @author Copyright © 2000-2001 <a href="http://www.apache.org/">The
+ * Apache Software Foundation</a>. All rights reserved.
+ * @version 1.0 <i>(CVS $Revision: 155409 $)</i>
+ */
+public interface DaemonController {
+
+ /**
+ *
+ */
+ public void shutdown()
+ throws IllegalStateException;
+
+ /**
+ *
+ */
+ public void reload()
+ throws IllegalStateException;
+
+ /**
+ *
+ */
+ public void fail()
+ throws IllegalStateException;
+
+ /**
+ *
+ */
+ public void fail(String message)
+ throws IllegalStateException;
+
+ /**
+ *
+ */
+ public void fail(Exception exception)
+ throws IllegalStateException;
+
+ /**
+ *
+ */
+ public void fail(String message, Exception exception)
+ throws IllegalStateException;
+
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/DaemonListener.java
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/DaemonListener.java 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/DaemonListener.java 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.daemon;
+
+import java.util.EventListener;
+
+public interface DaemonListener extends EventListener {
+
+}
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/DaemonPermission.java
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/DaemonPermission.java 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/DaemonPermission.java 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,386 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.daemon;
+
+import java.security.Permission;
+import java.util.StringTokenizer;
+
+/**
+ * This class represents the permissions to control and query the status of
+ * a <code>Daemon</code>. A <code>DaemonPermission</code> consists of a
+ * target name and a list of actions associated with it.
+ * <p>
+ * In this specification version the only available target name for this
+ * permission is "control", but further releases may add more target
+ * names to fine-tune the access that needs to be granted to the caller.
+ * </p>
+ * <p>
+ * Actions are defined by a string of comma-separated values, as shown in the
+ * table below. The empty string implies no permission at all, while the
+ * special "*" value implies all permissions for the given
+ * name:
+ * </p>
+ * <p>
+ * <table width="100%" border="1">
+ * <tr>
+ * <th>Target"Name</th>
+ * <th>Action</th>
+ * <th>Description</th>
+ * </tr>
+ * <tr>
+ * <td rowspan="5">"control"</td>
+ * <td>"start"</td>
+ * <td>
+ * The permission to call the <code>start()</code> method in an instance
+ * of a <code>DaemonController</code> interface.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>"stop"</td>
+ * <td>
+ * The permission to call the <code>stop()</code> method in an instance
+ * of a <code>DaemonController</code> interface.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>"shutdown"</td>
+ * <td>
+ * The permission to call the <code>shutdown()</code> method in an instance
+ * of a <code>DaemonController</code> interface.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>"reload"</td>
+ * <td>
+ * The permission to call the <code>reload()</code> method in an instance
+ * of a <code>DaemonController</code> interface.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>"*"</td>
+ * <td>
+ * The special wildcard action implies all above-mentioned action. This is
+ * equal to construct a permission with the "start, stop, shutdown,
+ * reload" list of actions.
+ * </td>
+ * </tr>
+ * </table>
+ * </p>
+ *
+ * @author Pier Fumagalli
+ * @author Copyright © 2000-2001 <a href="http://www.apache.org/">The
+ * Apache Software Foundation</a>. All rights reserved.
+ * @version 1.0 <i>(CVS $Revision: 155409 $)</i>
+ */
+public final class DaemonPermission extends Permission {
+
+ /* ==================================================================== */
+ /* Constants. */
+
+ /**
+ * The target name when associated with control actions
+ * ("control").
+ */
+ protected static final String CONTROL = "control";
+
+ /**
+ * The target type when associated with control actions.
+ */
+ protected static final int TYPE_CONTROL = 1;
+
+ /**
+ * The action name associated with the permission to call the
+ * <code>DaemonController.start()</code> method.
+ */
+ protected static final String CONTROL_START = "start";
+
+ /**
+ * The action name associated with the permission to call the
+ * <code>DaemonController.stop()</code> method.
+ */
+ protected static final String CONTROL_STOP = "stop";
+
+ /**
+ * The action name associated with the permission to call the
+ * <code>DaemonController.shutdown()</code> method.
+ */
+ protected static final String CONTROL_SHUTDOWN = "shutdown";
+
+ /**
+ * The action name associated with the permission to call the
+ * <code>DaemonController.reload()</code> method.
+ */
+ protected static final String CONTROL_RELOAD = "reload";
+
+ /**
+ * The action mask associated with the permission to call the
+ * <code>DaemonController.start()</code> method.
+ */
+ protected static final int MASK_CONTROL_START = 0x01;
+
+ /**
+ * The action mask associated with the permission to call the
+ * <code>DaemonController.stop()</code> method.
+ */
+ protected static final int MASK_CONTROL_STOP = 0x02;
+
+ /**
+ * The action mask associated with the permission to call the
+ * <code>DaemonController.shutdown()</code> method.
+ */
+ protected static final int MASK_CONTROL_SHUTDOWN = 0x04;
+
+ /**
+ * The action mask associated with the permission to call the
+ * <code>DaemonController.reload()</code> method.
+ */
+ protected static final int MASK_CONTROL_RELOAD = 0x08;
+
+ /**
+ * The "wildcard" action implying all actions for the given
+ * target name.
+ */
+ protected static final String WILDCARD = "*";
+
+ /* ==================================================================== */
+ /* Instance variables */
+
+ /** The type of this permission object. */
+ private transient int type = 0;
+ /** The permission mask associated with this permission object. */
+ private transient int mask = 0;
+ /** The String representation of this permission object. */
+ private transient String desc = null;
+
+ /* ==================================================================== */
+ /* Constructors */
+
+ /**
+ * Create a new <code>DaemonPermission</code> instance with a specified
+ * permission name.
+ * <p>
+ * This constructor will create a new <code>DaemonPermission</code>
+ * instance that <b>will not</b> grant any permission to the caller.
+ *
+ * @param target The target name of this permission.
+ * @exception IllegalArgumentException If the specified target name is not
+ * supported.
+ */
+ public DaemonPermission (String target)
+ throws IllegalArgumentException {
+ // Setup the target name of this permission object.
+ super(target);
+
+ // Check if the permission target name was specified
+ if (target==null)
+ throw new IllegalArgumentException("Null permission name");
+
+ // Check if this is a "control" permission and set up accordingly.
+ if (CONTROL.equalsIgnoreCase(target)) {
+ type=TYPE_CONTROL;
+ return;
+ }
+
+ // If we got here, we have an invalid permission name.
+ throw new IllegalArgumentException("Invalid permission name \""+
+ target+"\" specified");
+ }
+
+ /**
+ * Create a new <code>DaemonPermission</code> instance with a specified
+ * permission name and a specified list of actions.
+ * <p>
+ * </p>
+ *
+ * @param target The target name of this permission.
+ * @param actions The list of actions permitted by this permission.
+ * @exception IllegalArgumentException If the specified target name is not
+ * supported, or the specified list of actions includes an
+ * invalid value.
+ */
+ public DaemonPermission(String target, String actions)
+ throws IllegalArgumentException {
+ // Setup this instance's target name.
+ this(target);
+
+ // Create the appropriate mask if this is a control permission.
+ if (this.type==TYPE_CONTROL) {
+ this.mask=this.createControlMask(actions);
+ return;
+ }
+ }
+
+ /* ==================================================================== */
+ /* Public methods */
+
+ /**
+ * Return the list of actions permitted by this instance of
+ * <code>DaemonPermission</code> in its canonical form.
+ *
+ * @return The canonicalized list of actions.
+ */
+ public String getActions() {
+ if (this.type==TYPE_CONTROL) {
+ return(this.createControlActions(this.mask));
+ }
+ return("");
+ }
+
+ /**
+ * Return the hash code for this <code>DaemonPermission</code> instance.
+ *
+ * @return An hash code value.
+ */
+ public int hashCode() {
+ this.setupDescription();
+ return(this.desc.hashCode());
+ }
+
+ /**
+ * Check if a specified object equals <code>DaemonPermission</code>.
+ *
+ * @return <b>true</b> or <b>false</b> wether the specified object equals
+ * this <code>DaemonPermission</code> instance or not.
+ */
+ public boolean equals(Object object) {
+ if (object == this) return(true);
+
+ if (!(object instanceof DaemonPermission)) return false;
+
+ DaemonPermission that = (DaemonPermission)object;
+
+ if (this.type!=that.type) return(false);
+ return(this.mask==that.mask);
+ }
+
+ /**
+ * Check if this <code>DaemonPermission</code> implies another
+ * <code>Permission</code>.
+ *
+ * @return <b>true</b> or <b>false</b> wether the specified permission
+ * is implied by this <code>DaemonPermission</code> instance or
+ * not.
+ */
+ public boolean implies(Permission permission) {
+ if (permission == this) return(true);
+
+ if (!(permission instanceof DaemonPermission)) return false;
+
+ DaemonPermission that = (DaemonPermission)permission;
+
+ if (this.type!=that.type) return(false);
+ return((this.mask&that.mask)==that.mask);
+ }
+
+ /**
+ * Return a <code>String</code> representation of this instance.
+ *
+ * @return A <code>String</code> representing this
+ * <code>DaemonPermission</code> instance.
+ */
+ public String toString() {
+ this.setupDescription();
+ return(new String(this.desc));
+ }
+
+ /* ==================================================================== */
+ /* Private methods */
+
+ /** Create a String description for this permission instance. */
+ private void setupDescription() {
+ if (this.desc!=null) return;
+
+ StringBuffer buf=new StringBuffer();
+ buf.append(this.getClass().getName());
+ buf.append('[');
+ switch (this.type) {
+ case (TYPE_CONTROL): {
+ buf.append(CONTROL);
+ break;
+ }
+ default: {
+ buf.append("UNKNOWN");
+ break;
+ }
+ }
+ buf.append(':');
+ buf.append(this.getActions());
+ buf.append(']');
+
+ this.desc=buf.toString();
+ }
+
+ /** Create a permission mask for a given control actions string. */
+ private int createControlMask(String actions)
+ throws IllegalArgumentException {
+ if (actions==null) return(0);
+
+ int mask=0;
+ StringTokenizer tok=new StringTokenizer(actions,",",false);
+ while (tok.hasMoreTokens()) {
+ String val=tok.nextToken().trim();
+
+ if (WILDCARD.equals(val)) {
+ return(MASK_CONTROL_START|MASK_CONTROL_STOP|
+ MASK_CONTROL_SHUTDOWN|MASK_CONTROL_RELOAD);
+ } else if (CONTROL_START.equalsIgnoreCase(val)) {
+ mask=mask|MASK_CONTROL_START;
+ } else if (CONTROL_STOP.equalsIgnoreCase(val)) {
+ mask=mask|MASK_CONTROL_STOP;
+ } else if (CONTROL_SHUTDOWN.equalsIgnoreCase(val)) {
+ mask=mask|MASK_CONTROL_SHUTDOWN;
+ } else if (CONTROL_RELOAD.equalsIgnoreCase(val)) {
+ mask=mask|MASK_CONTROL_RELOAD;
+ } else {
+ throw new IllegalArgumentException("Invalid action name \""+
+ val+"\" specified");
+ }
+ }
+ return(mask);
+ }
+
+ /** Create a actions list for a given control permission mask. */
+ private String createControlActions(int mask) {
+ StringBuffer buf=new StringBuffer();
+ boolean sep=false;
+
+ if ((mask&MASK_CONTROL_START)==MASK_CONTROL_START) {
+ sep=true;
+ buf.append(CONTROL_START);
+ }
+
+ if ((mask&MASK_CONTROL_STOP)==MASK_CONTROL_STOP) {
+ if (sep) buf.append(",");
+ else sep=true;
+ buf.append(CONTROL_STOP);
+ }
+
+ if ((mask&MASK_CONTROL_SHUTDOWN)==MASK_CONTROL_SHUTDOWN) {
+ if (sep) buf.append(",");
+ else sep=true;
+ buf.append(CONTROL_SHUTDOWN);
+ }
+
+ if ((mask&MASK_CONTROL_RELOAD)==MASK_CONTROL_RELOAD) {
+ if (sep) buf.append(",");
+ else sep=true;
+ buf.append(CONTROL_RELOAD);
+ }
+
+ return buf.toString();
+ }
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/support/DaemonLoader.java
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/support/DaemonLoader.java 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/java/org/apache/commons/daemon/support/DaemonLoader.java 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,321 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* @version $Id: DaemonLoader.java 155409 2005-02-26 12:57:06Z dirkv $ */
+
+package org.apache.commons.daemon.support;
+
+import org.apache.commons.daemon.Daemon;
+import org.apache.commons.daemon.DaemonContext;
+import org.apache.commons.daemon.DaemonController;
+
+import java.lang.reflect.Method;
+
+public final class DaemonLoader {
+
+ private static Controller controller = null;
+ private static Context context = null;
+ private static Object daemon = null;
+ /* Methods to call */
+ private static Method init = null;
+ private static Method start = null;
+ private static Method stop = null;
+ private static Method destroy = null;
+
+ public static void version() {
+ System.err.println("java version \""+
+ System.getProperty("java.version")+
+ "\"");
+ System.err.println(System.getProperty("java.runtime.name")+
+ " (build "+
+ System.getProperty("java.runtime.version")+
+ ")");
+ System.err.println(System.getProperty("java.vm.name")+
+ " (build "+
+ System.getProperty("java.vm.version")+
+ ", "+
+ System.getProperty("java.vm.info")+
+ ")");
+ }
+
+ public static boolean check(String cn) {
+ try {
+ /* Check the class name */
+ if (cn==null)
+ throw new NullPointerException("Null class name specified");
+
+ /* Get the ClassLoader loading this class */
+ ClassLoader cl=DaemonLoader.class.getClassLoader();
+ if (cl==null) {
+ System.err.println("Cannot retrieve ClassLoader instance");
+ return(false);
+ }
+
+ /* Find the required class */
+ Class c=cl.loadClass(cn);
+
+ /* This should _never_ happen, but doublechecking doesn't harm */
+ if (c==null) throw new ClassNotFoundException(cn);
+
+ /* Create a new instance of the daemon */
+ Object s=c.newInstance();
+
+ } catch (Throwable t) {
+ /* In case we encounter ANY error, we dump the stack trace and
+ return false (load, start and stop won't be called). */
+ t.printStackTrace(System.err);
+ return(false);
+ }
+ /* The class was loaded and instantiated correctly, we can return */
+ return(true);
+ }
+
+ public static boolean load(String cn, String ar[]) {
+ try {
+ /* Make sure any previous instance is garbage collected */
+ System.gc();
+
+ /* Check if the underlying libray supplied a valid list of
+ arguments */
+ if (ar==null) ar=new String[0];
+
+ /* Check the class name */
+ if (cn==null)
+ throw new NullPointerException("Null class name specified");
+
+ /* Get the ClassLoader loading this class */
+ ClassLoader cl=DaemonLoader.class.getClassLoader();
+ if (cl==null) {
+ System.err.println("Cannot retrieve ClassLoader instance");
+ return(false);
+ }
+
+ /* Find the required class */
+ Class c=cl.loadClass(cn);
+
+ /* This should _never_ happen, but doublechecking doesn't harm */
+ if (c==null) throw new ClassNotFoundException(cn);
+
+ /* Check interface */
+ boolean isdaemon = false;
+ try {
+ Class dclass = cl.loadClass("org.apache.commons.daemon.Daemon");
+ isdaemon = dclass.isAssignableFrom(c);
+ } catch(Exception cnfex) {
+ // Swallow if Daemon not found.
+ }
+
+ /* Check methods */
+ Class[] myclass = new Class[1];
+ if (isdaemon) {
+ myclass[0] = DaemonContext.class;
+ } else {
+ myclass[0] = ar.getClass();
+ }
+
+ init = c.getMethod("init",myclass);
+
+ myclass = null;
+ start = c.getMethod("start",myclass);
+
+ stop = c.getMethod("stop",myclass);
+
+ destroy = c.getMethod("destroy",myclass);
+
+ /* Create a new instance of the daemon */
+ daemon=c.newInstance();
+
+ if (isdaemon) {
+ /* Create a new controller instance */
+ controller=new Controller();
+
+ /* Set the availability flag in the controller */
+ controller.setAvailable(false);
+
+ /* Create context */
+ context = new Context();
+ context.setArguments(ar);
+ context.setController(controller);
+
+ /* Now we want to call the init method in the class */
+ Object arg[] = new Object[1];
+ arg[0] = context;
+ init.invoke(daemon,arg);
+ } else {
+ Object arg[] = new Object[1];
+ arg[0] = ar;
+ init.invoke(daemon,arg);
+ }
+
+ } catch (Throwable t) {
+ /* In case we encounter ANY error, we dump the stack trace and
+ return false (load, start and stop won't be called). */
+ t.printStackTrace(System.err);
+ return(false);
+ }
+ /* The class was loaded and instantiated correctly, we can return */
+ return(true);
+ }
+
+ public static boolean start() {
+ try {
+ /* Attempt to start the daemon */
+ Object arg[] = null;
+ start.invoke(daemon,arg);
+
+ /* Set the availability flag in the controller */
+ if (controller != null)
+ controller.setAvailable(true);
+
+ } catch (Throwable t) {
+ /* In case we encounter ANY error, we dump the stack trace and
+ return false (load, start and stop won't be called). */
+ t.printStackTrace(System.err);
+ return(false);
+ }
+ return(true);
+ }
+
+ public static boolean stop() {
+ try {
+ /* Set the availability flag in the controller */
+ if (controller != null)
+ controller.setAvailable(false);
+
+ /* Attempt to stop the daemon */
+ Object arg[] = null;
+ stop.invoke(daemon,arg);
+
+ /* Run garbage collector */
+ System.gc();
+
+ } catch (Throwable t) {
+ /* In case we encounter ANY error, we dump the stack trace and
+ return false (load, start and stop won't be called). */
+ t.printStackTrace(System.err);
+ return(false);
+ }
+ return(true);
+ }
+
+ public static boolean destroy() {
+ try {
+ /* Attempt to stop the daemon */
+ Object arg[] = null;
+ destroy.invoke(daemon,arg);
+
+ /* Run garbage collector */
+ daemon=null;
+ controller=null;
+ System.gc();
+
+ } catch (Throwable t) {
+ /* In case we encounter ANY error, we dump the stack trace and
+ return false (load, start and stop won't be called). */
+ t.printStackTrace(System.err);
+ return(false);
+ }
+ return(true);
+ }
+
+ private static native void shutdown(boolean reload);
+
+ public static class Controller implements DaemonController {
+
+ boolean available=false;
+
+ private Controller() {
+ super();
+ this.setAvailable(false);
+ }
+
+ private boolean isAvailable() {
+ synchronized (this) {
+ return(this.available);
+ }
+ }
+
+ private void setAvailable(boolean available) {
+ synchronized (this) {
+ this.available=available;
+ }
+ }
+
+ public void shutdown() throws IllegalStateException {
+ synchronized (this) {
+ if (!this.isAvailable()) {
+ throw new IllegalStateException();
+ } else {
+ this.setAvailable(false);
+ DaemonLoader.shutdown(false);
+ }
+ }
+ }
+
+ public void reload() throws IllegalStateException {
+ synchronized (this) {
+ if (!this.isAvailable()) {
+ throw new IllegalStateException();
+ } else {
+ this.setAvailable(false);
+ DaemonLoader.shutdown(true);
+ }
+ }
+ }
+
+ public void fail()
+ throws IllegalStateException {
+ }
+
+ public void fail(String message)
+ throws IllegalStateException {
+ }
+
+ public void fail(Exception exception)
+ throws IllegalStateException {
+ }
+
+ public void fail(String message, Exception exception)
+ throws IllegalStateException {
+ }
+
+ }
+
+ public static class Context implements DaemonContext {
+
+ DaemonController controller = null;
+
+ String[] args = null;
+
+ public DaemonController getController() {
+ return controller;
+ }
+
+ public void setController(DaemonController controller) {
+ this.controller = controller;
+ }
+
+ public String[] getArguments() {
+ return args;
+ }
+
+ public void setArguments(String[] args) {
+ this.args = args;
+ }
+
+ }
+
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/media/logo.xcf
===================================================================
(Binary files differ)
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/src/media/logo.xcf
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/Makefile
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/Makefile 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/Makefile 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,6 @@
+all:
+ (cd service; make)
+ (cd moni; make)
+clean:
+ (cd service; make clean)
+ (cd moni; make clean)
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/README
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/README 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/README 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,68 @@
+(Please have a look to procrun (subdirectory), procrun is
+probably what you have to use).
+
+Note: MAKE SURE you first build the java part (using ant) otherwise the dist
+directory is not created).
+
+To build the service utilities for windows you will need:
+- MS Visual C++ (I have used version 5.0).
+- CYGWIN to build the jsvc.exe.
+- A Java Platform 2 compliant SDK to run the service.
+
+Structure of the utilies:
+- bin: exe files.
+- executables/vdmoniadm: project files for the desktop program.
+- executables/vdmonisvc: project files for the sevice wrapper.
+- lib: contains the common include file.
+- moni: contains sources of the vdmoniadm and vdmonisvc.
+- service: contains the sources and the project for the test installer.
+- signals: contains the kill() emulation logic.
+- supcalls_nt: contains the environment emulation logic.
+
+How to use it:
+1 - Build the jsvc.exe (See jakarta-tomcat-4.0/service).
+ It produces:
+ - service.jar
+ - jsvc.exe
+
+2- Create the following directories:
+ c:\home\jakarta\bin
+ c:\home\jakarta\lib
+
+3 - Copy
+ From jakarta-tomcat-4.0/service:
+ service.jar to lib
+ jsvc.exe to bin
+ From winnt:
+ INSTSVC.exe to bin
+ vdmoniadm.exe to bin
+ vdmonisvc to bin.
+
+4 - In a MSDOS windows run INSTSVC
+ It creates all informations to start the service.
+ The service is not started automaticly use control_panel+service and
+ and make it automatic after testing it starts and stops correctly.
+
+ It creates the registry values needed for the environment to start jsvc.exe
+ JAKARTA_HOME
+ CYGWIN (You have to set it to your cygwin directory home).
+ JAVA_HOME (You have to set it to your JAVA_HOME directory).
+ HOSTNAME (not yet used)
+ HOSTPORT (not yet used)
+ I use regedit to modify these values.
+
+5 - Using the explorer go to profiles/allusers/program/startup and add a link
+ to vdmoniadm.exe.
+
+6 - Reboot the machine and logon.
+ You should see a "nice" icon in the System Task-bar indicating that the
+ Java service is running. A right click on the icon calls a small menu.
+ Restart: (not yet implemented).
+ Configure: (not yet implemented).
+ Stop: Stops the java service.
+
+It is still a work in progress and blabla...
+
+Have fun...
+
+ Jean-Frederic <jfrederic.clere AT fujitsu-siemens.com>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmoniadm/icon1.ico
===================================================================
(Binary files differ)
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmoniadm/icon1.ico
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmoniadm/resource.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmoniadm/resource.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmoniadm/resource.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,41 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* @version $Id: resource.h 155409 2005-02-26 12:57:06Z dirkv $ */
+/* Used by vdmoniadm.rc */
+#define NO_ACCESS 1
+#define NO_ACCESS_MONI 2
+#define ALREADY_STOP 3
+#define ERROR_STATUS 4
+#define ALREADY_START 5
+#define CANNOT_START 6
+#define ID_TASKICON 7
+#define CANNOT_START_VDCOM 7
+#define CANNOT_START_VDCONF 8
+#define ID_STOP_VDMONI 40002
+#define ID_PROPRETY 40003
+#define ID_START_VDCOM 40008
+
+/* Next default values for new objects */
+
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 103
+#define _APS_NEXT_COMMAND_VALUE 40009
+#define _APS_NEXT_CONTROL_VALUE 1000
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmoniadm/vdmoniadm.dsp
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmoniadm/vdmoniadm.dsp 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmoniadm/vdmoniadm.dsp 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,121 @@
+# Microsoft Developer Studio Project File - Name="vdmoniadm" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=vdmoniadm - 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 "vdmoniadm.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 "vdmoniadm.mak" CFG="vdmoniadm - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "vdmoniadm - Win32 Release" (based on "Win32 (x86) Application")
+!MESSAGE "vdmoniadm - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "vdmoniadm - 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 "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "." /I "../../lib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /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 /nologo /subsystem:windows /machine:I386
+# ADD LINK32 oldnames.lib msvcrt.lib kernel32.lib advapi32.lib user32.lib gdi32.lib shell32.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib /out:"../../bin/vdmoniadm.exe"
+
+!ELSEIF "$(CFG)" == "vdmoniadm - 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 "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "." /I "../../lib" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /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 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 oldnames.lib msvcrt.lib kernel32.lib advapi32.lib user32.lib gdi32.lib shell32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib /out:"../../bin/vdmoniadm.exe" /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "vdmoniadm - Win32 Release"
+# Name "vdmoniadm - Win32 Debug"
+# Begin Group "moni"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\moni\vdmoniadm.c
+# End Source File
+# End Group
+# Begin Group "lib"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\lib\moni_inst.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\icon1.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\vdmoniadm.rc
+
+!IF "$(CFG)" == "vdmoniadm - Win32 Release"
+
+!ELSEIF "$(CFG)" == "vdmoniadm - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmoniadm/vdmoniadm.dsw
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmoniadm/vdmoniadm.dsw 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmoniadm/vdmoniadm.dsw 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 5.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "vdmoniadm"=.\vdmoniadm.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmoniadm/vdmoniadm.rc
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmoniadm/vdmoniadm.rc 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmoniadm/vdmoniadm.rc 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,344 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// German (Germany) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
+#ifdef _WIN32
+LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+STOPYESNO DIALOG DISCARDABLE 0, 0, 186, 95
+STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "OnServe-Monitor"
+FONT 8, "MS Sans Serif"
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,113,55,50,14
+ PUSHBUTTON "Abbrechen",IDCANCEL,19,56,50,14
+ LTEXT "Sind Sie sicher, daß Sie den OnServe-Monitor beenden wollen?",
+ IDC_STATIC,31,17,120,26
+END
+
+STARTYESNO DIALOG DISCARDABLE 0, 0, 186, 95
+STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "OnServe-Monitor"
+FONT 8, "MS Sans Serif"
+BEGIN
+ PUSHBUTTON "Abbrechen",IDCANCEL,71,54,50,14
+ LTEXT "Der OnServe-Monitor wird gestartet. Bitte warten...",
+ IDC_STATIC,31,17,120,26
+END
+
+PLEASEWAIT DIALOG DISCARDABLE 0, 0, 186, 95
+STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "OnServe-Monitor"
+FONT 8, "MS Sans Serif"
+BEGIN
+ PUSHBUTTON "Abbrechen",IDCANCEL,71,54,50,14
+ LTEXT "Der OnServe Monitor wird beendet. Bitte warten...",
+ IDC_STATIC,31,17,120,26
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE
+BEGIN
+ "STOPYESNO", DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 179
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 88
+ END
+
+ "STARTYESNO", DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 179
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 88
+ END
+
+ "PLEASEWAIT", DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 179
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 88
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+MENU MENU DISCARDABLE
+BEGIN
+ POPUP "no display"
+ BEGIN
+ MENUITEM "Online-Monitor Kommandos.", ID_START_VDCOM
+ MENUITEM "OnServe Konfigurieren.", ID_PROPRETY
+ MENUITEM "Online-Monitor stoppen.", ID_STOP_VDMONI
+ END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ NO_ACCESS "Mit dieser Kennung dürfen Sie OnServe nicht beenden."
+ NO_ACCESS_MONI "Der Dienst kann nicht erreicht werden!"
+ ALREADY_STOP "Der OnServe-Monitor ist nicht gestartet."
+ ERROR_STATUS "Der Zustand des Dienstes kann nicht ermittelt werden."
+ ALREADY_START "Der OnServe-Monitor ist bereits gestartet."
+ CANNOT_START "Der OnServe-Monitor kann nicht gestartet werden."
+ CANNOT_START_VDCOM "Das Kommando-Programm des OnServe-Monitors kann nicht gestartet werden."
+ CANNOT_START_VDCONF "Das OnServe-Konfigurationsprogramm kann nicht gestartet werden."
+END
+
+#endif // German (Germany) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+STARTYESNO DIALOG DISCARDABLE 0, 0, 186, 95
+STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "OnServe Monitor"
+FONT 8, "MS Sans Serif"
+BEGIN
+ PUSHBUTTON "Cancel",IDCANCEL,71,54,50,14
+ LTEXT "The OnServe Monitor is being started. Please Wait....",
+ IDC_STATIC,31,17,120,26
+END
+
+STOPYESNO DIALOG DISCARDABLE 0, 0, 186, 95
+STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "OnServe Monitor"
+FONT 8, "MS Sans Serif"
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,113,55,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,19,56,50,14
+ LTEXT "Are you sure you want to stop the OnServe Monitor?",
+ IDC_STATIC,31,17,120,26
+END
+
+PLEASEWAIT DIALOG DISCARDABLE 0, 0, 186, 95
+STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "OnServe Monitor"
+FONT 8, "MS Sans Serif"
+BEGIN
+ PUSHBUTTON "Cancel",IDCANCEL,71,54,50,14
+ LTEXT "The OnServe Monitor is being stopped. Please Wait....",
+ IDC_STATIC,31,17,120,26
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE
+BEGIN
+ "STARTYESNO", DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 179
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 88
+ END
+
+ "STOPYESNO", DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 179
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 88
+ END
+
+ "PLEASEWAIT", DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 179
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 88
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+MENU MENU DISCARDABLE
+BEGIN
+ POPUP "no display"
+ BEGIN
+ MENUITEM "Restart Jakarta service", ID_START_VDCOM
+ MENUITEM "Configure Jakarta service", ID_PROPRETY
+ MENUITEM "Stop Jakarta service", ID_STOP_VDMONI
+ END
+END
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+ONSERVE ICON DISCARDABLE "icon1.ico"
+
+#ifndef _MAC
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,0,0,1
+ PRODUCTVERSION 1,0,0,1
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "CompanyName", "Siemens AG\0"
+ VALUE "FileDescription", "OnServe Service Administration..\0"
+ VALUE "FileVersion", "3.0.0.1\0"
+ VALUE "InternalName", "vdmoniadm\0"
+ VALUE "LegalCopyright", "Copyright © 1998-2001, Apache Software Foundation \0"
+ VALUE "OriginalFilename", "vdmonisvc.exe\0"
+ VALUE "ProductName", "OnServe\0"
+ VALUE "ProductVersion", "3.0 A00\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+#endif // !_MAC
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ NO_ACCESS "Your login does not allow you to stop OnServe."
+ NO_ACCESS_MONI "Cannot access to the service!"
+ ALREADY_STOP "OnServe Monitor is not running."
+ ERROR_STATUS "Cannot get the status of the service."
+ ALREADY_START "OnServe Monitor is already started."
+ CANNOT_START "Cannot start the OnServe Monitor."
+ CANNOT_START_VDCOM "Cannot start the OnServe monitor commands program."
+ CANNOT_START_VDCONF "Cannot start the OnServe Configuration program."
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmonisvc/resource.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmonisvc/resource.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmonisvc/resource.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,28 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* @version $Id: resource.h 155409 2005-02-26 12:57:06Z dirkv $ */
+/* Used by vdmonisvc.rc */
+
+/* Next default values for new objects */
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 105
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1004
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmonisvc/vdmonisvc.dsp
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmonisvc/vdmonisvc.dsp 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmonisvc/vdmonisvc.dsp 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,122 @@
+# Microsoft Developer Studio Project File - Name="vdmonisvc" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=vdmonisvc - Win32 Release
+!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 "vdmonisvc.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 "vdmonisvc.mak" CFG="vdmonisvc - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "vdmonisvc - Win32 Release" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE "vdmonisvc - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "vdmonisvc - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir ".\vdmonisvc"
+# PROP BASE Intermediate_Dir ".\vdmonisvc"
+# 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" /YX /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "../../lib" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "WINPC" /FR /YX /FD /c
+# ADD BASE RSC /l 0x407 /d "NDEBUG"
+# ADD RSC /l 0x407 /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 /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib gdi32.lib user32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib msvcrt.lib oldnames.lib /nologo /subsystem:console /machine:I386 /nodefaultlib /out:"../../bin/vdmonisvc.exe"
+
+!ELSEIF "$(CFG)" == "vdmonisvc - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir ".\CleanSv0"
+# PROP BASE Intermediate_Dir ".\CleanSv0"
+# 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" /YX /c
+# ADD CPP /nologo /MD /W3 /Gm /GX /Zi /Od /I "../../lib" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "WINPC" /FR /YX /FD /c
+# ADD BASE RSC /l 0x407 /d "_DEBUG"
+# ADD RSC /l 0x407 /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 /nologo /subsystem:console /debug /machine:I386
+# ADD LINK32 user32.lib oldnames.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib msvcrt.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib /out:"../../bin/vdmonisvc.exe"
+
+!ENDIF
+
+# Begin Target
+
+# Name "vdmonisvc - Win32 Release"
+# Name "vdmonisvc - Win32 Debug"
+# Begin Group "supcalls_nt"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\supcalls_nt\vdenv.c
+# End Source File
+# End Group
+# Begin Group "signals"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\signals\kills.c
+# End Source File
+# End Group
+# Begin Group "moni"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\moni\vdmonisvc.c
+# End Source File
+# End Group
+# Begin Group "moni_nt"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\moni_nt\service.c
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\vdmonisvc.rc
+# End Source File
+# End Target
+# End Project
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmonisvc/vdmonisvc.dsw
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmonisvc/vdmonisvc.dsw 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmonisvc/vdmonisvc.dsw 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 5.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "vdmonisvc"=.\vdmonisvc.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmonisvc/vdmonisvc.rc
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmonisvc/vdmonisvc.rc 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/executables/vdmonisvc/vdmonisvc.rc 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,105 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifndef _MAC
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,0,0,1
+ PRODUCTVERSION 1,0,0,1
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "CompanyName", "Siemens AG\0"
+ VALUE "FileDescription", "OnServe Service application.\0"
+ VALUE "FileVersion", "3.0.0.1\0"
+ VALUE "InternalName", "vdmonisvc\0"
+ VALUE "LegalCopyright", "Copyright © 1998-2001, Apache Software Foundation.\0"
+ VALUE "OriginalFilename", "vdmonisvc.exe\0"
+ VALUE "ProductName", "OnServe\0"
+ VALUE "ProductVersion", "3.0 A00\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+#endif // !_MAC
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/lib/moni_inst.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/lib/moni_inst.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/lib/moni_inst.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,30 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * include for the service installation
+ */
+#define SZAPPNAME "JavaService"
+#define SZSERVICENAME "jsvc" // name of service
+#define SZDEPENDENCIES ""
+#define SZSERVICEDISPLAYNAME "Java Service" // name to display
+#define SZKEY_ONSERVE "SOFTWARE\\apache\\jakarta\\1.0"
+#define SZKEY_ONSERVEARG "SOFTWARE\\apache\\jakarta\\1.0\\arguments"
+#define SZKEY_F_DIR "F_DIR"
+#define SZDEFMONISVCPATH "\\vdmonisvc.exe"
+#define SZCYGWINPATH "c:\\gnu"
+#define SZJAKARTA_HOME "c:\\home\\jakarta"
+#define SZJAVA_HOME "c:\\jdk1.3.1"
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/moni/Makefile
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/moni/Makefile 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/moni/Makefile 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,17 @@
+INCLUDE=-I../lib
+BIN=../../../../dist
+all: $(BIN)/vdmoniadm $(BIN)/vdmonisvc
+
+$(BIN)/vdmoniadm: vdmoniadm.c
+ gcc $(INCLUDE) -I../executables/vdmoniadm vdmoniadm.c \
+ -o $(BIN)/vdmoniadm -lgdi32
+$(BIN)/vdmonisvc: vdmonisvc.c vdenv.o kills.o
+ gcc -mno-cygwin -I/usr/include $(INCLUDE) -I../executables/vdmonisvc \
+ -DCYGWIN vdmonisvc.c \
+ -o $(BIN)/vdmonisvc vdenv.o kills.o
+vdenv.o: ../supcalls_nt/vdenv.c
+ gcc $(INCLUDE) -c ../supcalls_nt/vdenv.c
+kills.o: ../signals/kills.c
+ gcc $(INCLUDE) -c ../signals/kills.c
+clean:
+ rm -f vdenv.o kills.o
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/moni/vdmoniadm.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/moni/vdmoniadm.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/moni/vdmoniadm.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,594 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* @version $Id: vdmoniadm.c 155409 2005-02-26 12:57:06Z dirkv $ */
+
+#include <windows.h> /* required for all Windows applications */
+#include <stdio.h> /* for sprintf */
+#include <io.h>
+#include <fcntl.h>
+#include <shellapi.h>
+#include <winuser.h>
+
+#include "resource.h"
+#include "moni_inst.h"
+
+
+
+#define WINWIDTH 680
+#define WINHEIGHT 460
+
+#define CLASSMAIN
+#define VM_ICON_MESS WM_USER+1
+#define VM_ID_TIMER WM_USER+2
+#define VM_START_ICON WM_USER+3
+#define VM_ID_TIMER1 WM_USER+4
+#define VM_ID_TIMER2 WM_USER+5
+
+BOOL InitApplication(HANDLE hInstance);
+
+HANDLE hInst; /* current instance */
+SC_HANDLE hManager=NULL;
+SC_HANDLE hService=NULL;
+int optmode; /* start, stop or check. */
+int flagdown = 0;
+
+#define VDMONISTART 0
+#define VDMONISTOP 1
+#define VDMONICHECK 2
+
+#define NORMALWINDOW WS_OVERLAPPED|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX
+#define ICONWINDOW WS_CAPTION|WS_POPUPWINDOW|WS_MINIMIZEBOX|WS_MAXIMIZEBOX
+
+
+/* display a message read from resources */
+
+static void DisplayMess(HWND hDlg,int item)
+{
+char MessBox[256];
+
+ if (LoadString(hInst,item,MessBox,sizeof(MessBox)))
+ MessageBox(hDlg, MessBox,"ERROR" , MB_OK);
+ else {
+ sprintf(MessBox,"ERROR %d",item);
+ MessageBox(hDlg, MessBox,"ERROR" , MB_OK);
+ }
+}
+/*
+ * MyTaskBarAddIcon - adds an icon to the taskbar status area.
+ * Returns TRUE if successful or FALSE otherwise.
+ * hwnd - handle of the window to receive callback messages
+ * uID - identifier of the icon
+ * hicon - handle of the icon to add
+ * lpszTip - ToolTip text
+ */
+BOOL MyTaskBarAddIcon(HWND hWnd)
+{
+ BOOL res;
+ NOTIFYICONDATA notifyicondata;
+ HICON hicon;
+
+ notifyicondata.cbSize=sizeof(notifyicondata);
+ notifyicondata.hWnd=hWnd;
+ notifyicondata.uID=ID_TASKICON;
+ notifyicondata.uFlags= NIF_ICON|NIF_MESSAGE|NIF_TIP;
+ notifyicondata.uCallbackMessage=VM_ICON_MESS;
+ hicon = LoadIcon(hInst,"OnServe");
+ notifyicondata.hIcon = hicon;
+ strcpy(notifyicondata.szTip,"Jakarta Service");
+
+
+ res = Shell_NotifyIcon(NIM_ADD,¬ifyicondata);
+
+ if (hicon)
+ DestroyIcon(hicon);
+
+ return res;
+}
+/*
+ * MyTaskBarDeleteIcon - deletes an icon from the taskbar
+ * status area.
+ * Returns TRUE if successful or FALSE otherwise.
+ * hwnd - handle of the window that added the icon
+ * uID - identifier of the icon to delete
+ */
+BOOL MyTaskBarDeleteIcon(HWND hwnd)
+{
+ BOOL res;
+ NOTIFYICONDATA tnid;
+
+ tnid.cbSize = sizeof(NOTIFYICONDATA);
+ tnid.hWnd = hwnd;
+ tnid.uID = ID_TASKICON;
+
+ res = Shell_NotifyIcon(NIM_DELETE, &tnid);
+ return res;
+}
+
+/* start the vdcom process */
+void StartVdcom(HWND hDlg)
+{
+STARTUPINFO StartupInfo;
+PROCESS_INFORMATION ProcessInformation;
+
+ memset(&StartupInfo,'\0',sizeof(StartupInfo));
+ StartupInfo.cb = sizeof(STARTUPINFO);
+
+ if (!CreateProcess(NULL,"vdcom.exe",NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,
+ NULL,NULL, &StartupInfo, &ProcessInformation)) {
+ DisplayMess(hDlg,CANNOT_START_VDCOM);
+ return;
+ }
+ /* the handle to the process */
+ CloseHandle(ProcessInformation.hProcess);
+ CloseHandle(ProcessInformation.hThread);
+}
+/* start the vdconf process */
+void StartVdconf(HWND hDlg)
+{
+STARTUPINFO StartupInfo;
+PROCESS_INFORMATION ProcessInformation;
+
+ memset(&StartupInfo,'\0',sizeof(StartupInfo));
+ StartupInfo.cb = sizeof(STARTUPINFO);
+
+ if (!CreateProcess(NULL,"vdconf.exe",NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,
+ NULL,NULL, &StartupInfo, &ProcessInformation)) {
+ DisplayMess(hDlg,CANNOT_START_VDCONF);
+ return;
+ }
+ /* the handle to the process */
+ CloseHandle(ProcessInformation.hProcess);
+ CloseHandle(ProcessInformation.hThread);
+}
+
+/* test if service is running */
+BOOL IsRunning(HWND hDlg)
+{
+ SERVICE_STATUS svcStatus;
+
+ if (!QueryServiceStatus(hService, &svcStatus)) {
+ DisplayMess(hDlg,ERROR_STATUS);
+ PostQuitMessage(0);
+ return(FALSE);
+ }
+ else {
+ if (SERVICE_RUNNING == svcStatus.dwCurrentState)
+ return(TRUE);
+ }
+ return(FALSE);
+
+}
+/* test if service is stoppped */
+BOOL IsStopped(HWND hDlg)
+{
+ SERVICE_STATUS svcStatus;
+
+ if (!QueryServiceStatus(hService, &svcStatus)) {
+ DisplayMess(hDlg,ERROR_STATUS);
+ PostQuitMessage(0);
+ return(FALSE);
+ }
+ else {
+ if (SERVICE_STOPPED == svcStatus.dwCurrentState)
+ return(TRUE);
+ }
+ return(FALSE);
+
+}
+/* Yes/No dialog box */
+LRESULT APIENTRY StopYesNo(
+ HWND hDlg, /* window handle of the dialog box */
+ UINT message, /* type of message */
+ UINT wParam, /* message-specific information */
+ LONG lParam)
+{
+ SERVICE_STATUS svcStatus;
+
+ switch (message) {
+ case WM_COMMAND: /* message: received a command */
+ if (LOWORD(wParam) == IDOK) { /* "OK" box selected */
+ if (!IsStopped(hDlg)) {
+ ControlService(hService, SERVICE_CONTROL_STOP, &svcStatus);
+ EndDialog(hDlg, TRUE);
+ }
+ else
+ EndDialog(hDlg, FALSE);
+ }
+ if (LOWORD(wParam) == IDCANCEL)
+ EndDialog(hDlg, FALSE);
+ return(TRUE);
+ } /* End switch message */
+ return (FALSE); /* Didn't process a message */
+ UNREFERENCED_PARAMETER(lParam);
+}
+/* Please wait stopping dialog box */
+LRESULT APIENTRY PleaseWait(
+ HWND hDlg, /* window handle of the dialog box */
+ UINT message, /* type of message */
+ UINT wParam, /* message-specific information */
+ LONG lParam)
+{
+
+ switch (message) {
+ case WM_INITDIALOG:
+ SetTimer(hDlg,VM_ID_TIMER2,5000,NULL); /* wait 5 seconds. */
+ case WM_COMMAND: /* message: received a command */
+ if (LOWORD(wParam) == IDCANCEL)
+ EndDialog(hDlg, FALSE);
+ return(TRUE);
+ case WM_TIMER:
+ if(IsStopped(hDlg))
+ EndDialog(hDlg, TRUE);
+ else
+ SetTimer(hDlg,VM_ID_TIMER2,5000,NULL); /* wait 5 seconds. */
+ return(TRUE);
+ } /* End switch message */
+ return (FALSE); /* Didn't process a message */
+ UNREFERENCED_PARAMETER(lParam);
+}
+LRESULT APIENTRY StartYesNo(
+ HWND hDlg, /* window handle of the dialog box */
+ UINT message, /* type of message */
+ UINT wParam, /* message-specific information */
+ LONG lParam)
+{
+
+ switch (message) {
+ case WM_INITDIALOG:
+ if (!StartService(hService,0,NULL)) {
+ DisplayMess(hDlg,CANNOT_START);
+ PostQuitMessage(0);
+ }
+ /* test if running, if not set a timer. */
+ /* wait until service is start */
+ if (IsRunning(hDlg))
+ EndDialog(hDlg, TRUE);
+ else
+ SetTimer(hDlg,VM_ID_TIMER1,5000,NULL); /* wait 5 seconds. */
+ return(TRUE);
+
+ case WM_TIMER:
+ if(IsRunning(hDlg))
+ EndDialog(hDlg, TRUE);
+ else
+ SetTimer(hDlg,VM_ID_TIMER1,5000,NULL); /* wait 5 seconds. */
+ return(TRUE);
+
+ case WM_COMMAND: /* message: received a command */
+ if (LOWORD(wParam) == IDCANCEL) {
+ if (IsRunning(hDlg))
+ EndDialog(hDlg, TRUE);
+ else
+ PostQuitMessage(0);
+ }
+ return(TRUE);
+
+ } /* End switch message */
+ return (FALSE); /* Didn't process a message */
+ UNREFERENCED_PARAMETER(lParam);
+}
+
+/* Display the menu */
+
+void ShowMenu(HWND hWnd)
+{
+ HMENU hMenu,hMenu1;
+ POINT point;
+
+ hMenu = LoadMenu(hInst,"MENU");
+ SetMenu(hWnd,hMenu);
+ hMenu1 = GetSubMenu(hMenu,0);
+
+ GetCursorPos(&point);
+
+ SetForegroundWindow(hWnd); /* MS bug. */
+ TrackPopupMenuEx(hMenu1,TPM_RIGHTALIGN|TPM_BOTTOMALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON,
+ point.x,point.y,hWnd,NULL);
+ PostMessage(hWnd, WM_USER, 0, 0); /* MS bug. */
+ DestroyMenu(hMenu);
+
+}
+/****************************************************************************\
+*
+* FUNCTION: InitInstance(HANDLE, int)
+*
+* PURPOSE: Saves instance handle and creates main window
+*
+*\***************************************************************************/
+
+BOOL InitInstance(
+ HANDLE hInstance, /* Current instance identifier. */
+ int nCmdShow) /* Param for first ShowWindow() call. */
+{
+ HWND hWnd; /* Main window handle. */
+ DWORD dwStyle,dwExStyle;
+
+
+ /* Save the instance handle in static variable, which will be used in */
+ /* many subsequence calls from this application to Windows. */
+
+ hInst = hInstance;
+
+ /* Create a main window for this application instance. */
+
+ if (optmode == VDMONISTART || optmode == VDMONICHECK) {
+ dwStyle = ICONWINDOW;
+ dwExStyle = WS_EX_APPWINDOW;
+ }
+ else {
+ dwStyle = NORMALWINDOW;
+ dwExStyle = 0;
+ }
+
+ hWnd = CreateWindowEx(
+ dwExStyle,
+ "OnServe", /* See RegisterClass() call. */
+ "OnServe Monitor Control", /* Text for window title bar. */
+ dwStyle, /* Window style.*/
+ CW_USEDEFAULT, /* Default horizontal position. */
+ CW_USEDEFAULT, /* Default vertical position. */
+ WINWIDTH, /* Windows width. */
+ WINHEIGHT, /* Windows height. */
+ NULL, /* Overlapped windows have no parent. */
+ NULL, /* Use the window class menu. */
+ hInstance, /* This instance owns this window. */
+ NULL /* Pointer not needed. */
+ );
+
+
+ /* If window could not be created, return "failure" */
+
+ if (!hWnd) {
+ return (FALSE);
+ }
+
+ return (TRUE); /* Returns the value from PostQuitMessage */
+
+}
+/****************************************************************************\
+*
+* FUNCTION: MainWndProc(HWND, unsigned, WORD, LONG)
+*
+* PURPOSE: Processes main window messages
+*
+*\***************************************************************************/
+
+LONG APIENTRY MainWndProc(
+ HWND hWnd, /* window handle */
+ UINT message, /* type of message */
+ UINT wParam, /* additional information */
+ LONG lParam) /* additional information */
+{
+ SERVICE_STATUS svcStatus;
+
+ switch (message) {
+ case WM_CREATE:
+
+ /* acces to service manager. */
+ hManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
+ if (hManager==NULL) {
+ DisplayMess(hWnd,NO_ACCESS);
+ PostQuitMessage(0);
+ break;
+ }
+ /* access to monitor service. */
+ hService = OpenService(hManager, SZSERVICENAME, SERVICE_ALL_ACCESS);
+ if (hService==NULL) {
+ DisplayMess(hWnd,NO_ACCESS_MONI);
+ PostQuitMessage(0);
+ break;
+ }
+ /* check if running. */
+ if (QueryServiceStatus(hService, &svcStatus)) {
+ /* and see if the service is stopped */
+ if (SERVICE_STOPPED == svcStatus.dwCurrentState &&
+ optmode == VDMONISTOP) {
+ DisplayMess(hWnd,ALREADY_STOP);
+ PostQuitMessage(0);
+ break;
+ }
+ else if (SERVICE_RUNNING == svcStatus.dwCurrentState &&
+ optmode == VDMONISTART) {
+ DisplayMess(hWnd,ALREADY_START);
+ PostQuitMessage(0);
+ break;
+ }
+
+ }
+ else {
+ DisplayMess(hWnd,ERROR_STATUS);
+ PostQuitMessage(0);
+ break;
+ }
+
+ /* DialogBoxes Yes/No */
+ if (optmode == VDMONISTART)
+ DialogBox(hInst, /* current instance */
+ "StartYesNo", /* resource to use */
+ hWnd, /* parent handle */
+ StartYesNo); /* instance address */
+ else if (optmode == VDMONISTOP)
+ if (DialogBox(hInst,"StopYesNo",hWnd,StopYesNo))
+ DialogBox(hInst,"PleaseWait",hWnd,PleaseWait);
+
+
+ if (optmode == VDMONISTOP)
+ PostQuitMessage(0);
+ else {
+ SetTimer(hWnd,VM_ID_TIMER,5000,NULL);
+ MyTaskBarAddIcon(hWnd);
+ }
+
+ break; /* WM_CREATE */
+
+ case VM_ICON_MESS:
+ switch ((UINT)lParam) {
+ case WM_LBUTTONDBLCLK:
+ StartVdcom(hWnd);
+ break;
+ case WM_RBUTTONDOWN:
+ flagdown = 1;
+ break;
+ case WM_RBUTTONUP:
+ if (flagdown == 1) {
+ flagdown = 2;
+ /* show a menu. */
+ ShowMenu(hWnd);
+ }
+ break;
+ }
+ break;
+
+
+ case WM_TIMER:
+ /* check if service is running */
+ if (QueryServiceStatus(hService, &svcStatus)) {
+ /* and see if the service is stopped */
+ if (SERVICE_STOPPED == svcStatus.dwCurrentState) {
+ MyTaskBarDeleteIcon(hWnd);
+ PostQuitMessage(0);
+ }
+ SetTimer(hWnd,VM_ID_TIMER,5000,NULL);
+ return(0);
+ }
+ break;
+
+ case VM_START_ICON:
+ /* add the icon and timer. */
+ MyTaskBarAddIcon(hWnd);
+ SetTimer(hWnd,VM_ID_TIMER,5000,NULL);
+ break;
+
+ case WM_COMMAND:
+ /* command for the popup menu. */
+ switch (LOWORD(wParam)) {
+ case ID_START_VDCOM:
+ StartVdcom(hWnd);
+ break;
+ case ID_STOP_VDMONI:
+ if (DialogBox(hInst,"StopYesNo",hWnd,StopYesNo))
+ DialogBox(hInst,"PleaseWait",hWnd,PleaseWait);
+ break;
+ case ID_PROPRETY:
+ StartVdconf(hWnd);
+ break;
+
+ }
+ break;
+
+ /*
+ * Clean up.
+ */
+ case WM_DESTROY:
+ if (hService!=NULL)
+ CloseServiceHandle(hService);
+ if (hManager!=NULL)
+ CloseServiceHandle(hManager);
+ PostQuitMessage(0);
+ break;
+
+ default: /* Passes it on if unproccessed */
+ return (DefWindowProc(hWnd, message, wParam, lParam));
+
+ }
+ return (0);
+
+}
+
+/****************************************************************************
+*
+* FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int)
+*
+* PURPOSE: calls initialization function, processes message loop
+*
+*\***************************************************************************/
+
+WINAPI WinMain(
+ HINSTANCE hInstance,
+ HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine,
+ int nCmdShow
+ )
+{
+
+ MSG msg;
+
+ UNREFERENCED_PARAMETER( lpCmdLine );
+ if (strcmp(lpCmdLine,"start")==0)
+ optmode = VDMONISTART;
+ else if (strcmp(lpCmdLine,"stop")==0)
+ optmode = VDMONISTOP;
+ else
+ optmode = VDMONICHECK;
+
+ if (!hPrevInstance) /* Other instances of app running? */
+ if (!InitApplication(hInstance)) /* Initialize shared things */
+ return (FALSE); /* Exits if unable to initialize */
+
+ /*
+ * Perform initializations that apply to a specific instance
+ */
+ if (!InitInstance(hInstance, nCmdShow))
+ return (FALSE);
+
+ /*
+ * Acquire and dispatch messages until a WM_QUIT message is received.
+ */
+ while (GetMessage(&msg, /* message structure */
+ NULL, /* handle of window receiving the message */
+ 0, /* lowest message to examine */
+ 0)) /* highest message to examine */
+ {
+ TranslateMessage(&msg); /* Translates virtual key codes */
+ DispatchMessage(&msg); /* Dispatches message to window */
+ }
+ return (msg.wParam); /* Returns the value from PostQuitMessage */
+}
+
+/****************************************************************************
+*
+* FUNCTION: InitApplication(HANDLE)
+*
+* PURPOSE: Initializes window data and registers window class
+*
+*\***************************************************************************/
+
+BOOL InitApplication(HANDLE hInstance) /* current instance */
+{
+ WNDCLASS wc;
+
+ /* Fill in window class structure with parameters that describe the */
+ /* main window. */
+
+ wc.style = 0; /* Class style(s). */
+ wc.lpfnWndProc = (WNDPROC)MainWndProc;/* Function to retrieve messages for */
+ /* windows of this class. */
+ wc.cbClsExtra = 0; /* No per-class extra data. */
+ wc.cbWndExtra = 0; /* No per-window extra data. */
+ wc.hIcon = LoadIcon (hInstance, "onserve"); /* Icon name from .RC */
+ wc.hInstance = hInstance; /* Application that owns the class. */
+ wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wc.hbrBackground = GetStockObject(WHITE_BRUSH);
+ wc.lpszMenuName = "onservemenu"; /* Name of menu resource in .RC file. */
+ wc.lpszClassName = "OnServe"; /* Name used in call to CreateWindow. */
+
+ /* Register the window class and return success/failure code. */
+
+ return (RegisterClass(&wc));
+
+}
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/moni/vdmonisvc.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/moni/vdmonisvc.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/moni/vdmonisvc.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,707 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* @version $Id: vdmonisvc.c 155409 2005-02-26 12:57:06Z dirkv $ */
+
+/* jsvc monitor service module:
+ * Implements the body of the service.
+ * It reads the register entry and starts the jsvc.
+ */
+
+#include <windows.h>
+#include <winuser.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <process.h>
+#include <time.h>
+#ifdef CYGWIN
+#else
+#include <tchar.h>
+#endif
+#include "moni_inst.h"
+
+/* globals */
+SERVICE_STATUS ssStatus;
+SERVICE_STATUS_HANDLE sshStatusHandle;
+DWORD dwErr;
+HANDLE hServerStopEvent = NULL;
+HANDLE hMonitorProcess = NULL;
+
+/*
+ * NT/other detection
+ * from src/os/win32/service.c (httpd-1.3!).
+ */
+
+BOOL isWindowsNT(void)
+{
+ static BOOL once = FALSE;
+ static BOOL isNT = FALSE;
+
+ if (!once)
+ {
+ OSVERSIONINFO osver;
+ osver.dwOSVersionInfoSize = sizeof(osver);
+ if (GetVersionEx(&osver))
+ if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT)
+ isNT = TRUE;
+ once = TRUE;
+ }
+ return isNT;
+}
+
+/* Event logger routine */
+
+VOID AddToMessageLog(LPTSTR lpszMsg)
+{
+ TCHAR szMsg[256];
+ HANDLE hEventSource;
+ LPTSTR lpszStrings[2];
+
+
+ dwErr = GetLastError();
+
+ /* Use event logging to log the error. */
+
+ if (isWindowsNT())
+ hEventSource = RegisterEventSource(NULL, TEXT(SZSERVICENAME));
+ else
+ hEventSource = NULL;
+
+#ifdef CYGWIN
+ sprintf(szMsg, TEXT("%s ERROR: %d"), TEXT(SZSERVICENAME), dwErr);
+#else
+ _stprintf(szMsg, TEXT("%s ERROR: %d"), TEXT(SZSERVICENAME), dwErr);
+#endif
+ lpszStrings[0] = szMsg;
+ lpszStrings[1] = lpszMsg;
+
+ if (hEventSource != NULL) {
+ ReportEvent(hEventSource, /* handle of event source */
+ EVENTLOG_ERROR_TYPE, /* event type */
+ 0, /* event category */
+ 0, /* event ID */
+ NULL, /* current user's SID */
+ 2, /* strings in lpszStrings */
+ 0, /* no bytes of raw data */
+ lpszStrings, /* array of error strings */
+ NULL); /* no raw data */
+
+ (VOID) DeregisterEventSource(hEventSource);
+ } else {
+ /* Default to a trace file */
+ FILE *log;
+ log = fopen("c:/jakarta-service.log","a+");
+ if (log != NULL) {
+ struct tm *newtime;
+ time_t long_time;
+
+ time( &long_time );
+ newtime = localtime( &long_time );
+
+ if (dwErr)
+ fprintf(log,"%.24s:%s: %s\n",asctime(newtime),szMsg, lpszMsg);
+ else
+ fprintf(log,"%.24s: %s\n",asctime(newtime), lpszMsg);
+ fclose(log);
+ }
+ }
+}
+
+/*
+ *
+ * FUNCTION: ServiceStop
+ *
+ * PURPOSE: Stops the service
+ *
+ * PARAMETERS:
+ * none
+ *
+ * RETURN VALUE:
+ * none
+ *
+ * COMMENTS:
+ * If a ServiceStop procedure is going to
+ * take longer than 3 seconds to execute,
+ * it should spawn a thread to execute the
+ * stop code, and return. Otherwise, the
+ * ServiceControlManager will believe that
+ * the service has stopped responding.
+ *
+ */
+VOID ServiceStop()
+{
+ if ( hServerStopEvent )
+ SetEvent(hServerStopEvent);
+}
+
+/*
+ * Wait for the monitor process to stop
+ */
+int WaitForMonitor(int num)
+{
+ DWORD qreturn;
+ int i;
+
+ for (i=0;i<num;i++) {
+ if (hMonitorProcess == NULL) break;
+ if (GetExitCodeProcess(hMonitorProcess, &qreturn)) {
+ if (qreturn == STILL_ACTIVE) {
+ Sleep(1000);
+ continue;
+ }
+ hMonitorProcess = NULL;
+ break;
+ }
+ break;
+ }
+ if (i==num)
+ return -1;
+ return 0;
+}
+/* This group of functions are provided for the service/console app
+ * to register itself a HandlerRoutine to accept tty or service messages
+ * adapted from src/os/win32/Win9xConHook.c (httpd-1.3!).
+ */
+
+/* This is the WndProc procedure for our invisible window.
+ * When our subclasssed tty window receives the WM_CLOSE, WM_ENDSESSION,
+ * or WM_QUERYENDSESSION messages, the message is dispatched to our hidden
+ * window (this message process), and we call the installed HandlerRoutine
+ * that was registered by the app.
+ */
+#ifndef ENDSESSION_LOGOFF
+#define ENDSESSION_LOGOFF 0x80000000
+#endif
+static LRESULT CALLBACK ttyConsoleCtrlWndProc(HWND hwnd, UINT msg,
+ WPARAM wParam, LPARAM lParam)
+{
+ int qreturn;
+ if (msg == WM_CREATE) {
+ AddToMessageLog(TEXT("ttyConsoleCtrlWndProc WM_CREATE"));
+ return 0;
+ } else if (msg == WM_DESTROY) {
+ AddToMessageLog(TEXT("ttyConsoleCtrlWndProc WM_DESTROY"));
+ return 0;
+ } else if (msg == WM_CLOSE) {
+ /* Call StopService?. */
+ AddToMessageLog(TEXT("ttyConsoleCtrlWndProc WM_CLOSE"));
+ return 0; /* May return 1 if StopService failed. */
+ } else if ((msg == WM_QUERYENDSESSION) || (msg == WM_ENDSESSION)) {
+ if (lParam & ENDSESSION_LOGOFF) {
+ /* Here we have nothing to our hidden windows should stay. */
+ AddToMessageLog(TEXT("ttyConsoleCtrlWndProc LOGOFF"));
+ return(1); /* Otherwise it cancels the logoff */
+ } else {
+ /* Stop Service. */
+ AddToMessageLog(TEXT("ttyConsoleCtrlWndProc SHUTDOWN"));
+ ServiceStop();
+
+ /* Wait until it stops. */
+ qreturn = WaitForMonitor(3);
+
+ if (msg == WM_QUERYENDSESSION) {
+ AddToMessageLog(
+ TEXT("ttyConsoleCtrlWndProc SHUTDOWN (query)"));
+ if (qreturn) {
+ AddToMessageLog(
+ TEXT("Cancelling shutdown: cannot stop service"));
+ return(0);
+ }
+ } else
+ AddToMessageLog(TEXT("ttyConsoleCtrlWndProc SHUTDOWN"));
+ return(1); /* Otherwise it cancels the shutdown. */
+ }
+ }
+ return (DefWindowProc(hwnd, msg, wParam, lParam));
+}
+/* ttyConsoleCreateThread is the process that runs within the user app's
+ * context. It creates and pumps the messages of a hidden monitor window,
+ * watching for messages from the system, or the associated subclassed tty
+ * window. Things can happen in our context that can't be done from the
+ * tty's context, and visa versa, so the subclass procedure and this hidden
+ * window work together to make it all happen.
+ */
+static DWORD WINAPI ttyConsoleCtrlThread()
+{
+ HWND monitor_hwnd;
+ WNDCLASS wc;
+ MSG msg;
+ wc.style = CS_GLOBALCLASS;
+ wc.lpfnWndProc = ttyConsoleCtrlWndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 8;
+ wc.hInstance = NULL;
+ wc.hIcon = NULL;
+ wc.hCursor = NULL;
+ wc.hbrBackground = NULL;
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = "ApacheJakartaService";
+
+ if (!RegisterClass(&wc)) {
+ AddToMessageLog(TEXT("RegisterClass failed"));
+ return 0;
+ }
+
+ /* Create an invisible window */
+ monitor_hwnd = CreateWindow(wc.lpszClassName,
+ "ApacheJakartaService",
+ WS_OVERLAPPED & ~WS_VISIBLE,
+ CW_USEDEFAULT, CW_USEDEFAULT,
+ CW_USEDEFAULT, CW_USEDEFAULT,
+ NULL, NULL,
+ GetModuleHandle(NULL), NULL);
+
+ if (!monitor_hwnd) {
+ AddToMessageLog(TEXT("RegisterClass failed"));
+ return 0;
+ }
+
+ while (GetMessage(&msg, NULL, 0, 0))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+
+ return 0;
+}
+/*
+ * Register the process to resist logoff and start the thread that will receive
+ * the shutdown via a hidden window.
+ */
+BOOL Windows9xServiceCtrlHandler()
+{
+ HANDLE hThread;
+ DWORD tid;
+ HINSTANCE hkernel;
+ DWORD (WINAPI *register_service_process)(DWORD, DWORD) = NULL;
+
+ /* If we have not yet done so */
+ FreeConsole();
+
+ /* Make sure the process will resist logoff */
+ hkernel = LoadLibrary("KERNEL32.DLL");
+ if (!hkernel) {
+ AddToMessageLog(TEXT("LoadLibrary KERNEL32.DLL failed"));
+ return 0;
+ }
+ register_service_process = (DWORD (WINAPI *)(DWORD, DWORD))
+ GetProcAddress(hkernel, "RegisterServiceProcess");
+ if (register_service_process == NULL) {
+ AddToMessageLog(TEXT("dlsym RegisterServiceProcess failed"));
+ return 0;
+ }
+ if (!register_service_process(0,TRUE)) {
+ FreeLibrary(hkernel);
+ AddToMessageLog(TEXT("register_service_process failed"));
+ return 0;
+ }
+ AddToMessageLog(TEXT("jsvc registered as a service"));
+
+ /*
+ * To be handle notice the shutdown, we need a thread and window.
+ */
+ hThread = CreateThread(NULL, 0, ttyConsoleCtrlThread,
+ (LPVOID)NULL, 0, &tid);
+ if (hThread) {
+ CloseHandle(hThread);
+ return TRUE;
+ }
+ AddToMessageLog(TEXT("jsvc shutdown listener start failed"));
+ return TRUE;
+}
+
+/*
+ *
+ * FUNCTION: ReportStatusToSCMgr()
+ *
+ * PURPOSE: Sets the current status of the service and
+ * reports it to the Service Control Manager
+ *
+ * PARAMETERS:
+ * dwCurrentState - the state of the service
+ * dwWin32ExitCode - error code to report
+ * dwWaitHint - worst case estimate to next checkpoint
+ *
+ * RETURN VALUE:
+ * TRUE - success
+ * FALSE - failure
+ *
+ * COMMENTS:
+ *
+ */
+BOOL ReportStatusToSCMgr(DWORD dwCurrentState,
+ DWORD dwWin32ExitCode,
+ DWORD dwWaitHint)
+{
+ static DWORD dwCheckPoint = 1;
+ BOOL fResult = TRUE;
+
+
+ if (dwCurrentState == SERVICE_START_PENDING)
+ ssStatus.dwControlsAccepted = 0;
+ else
+ ssStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
+
+ ssStatus.dwCurrentState = dwCurrentState;
+ ssStatus.dwWin32ExitCode = dwWin32ExitCode;
+ ssStatus.dwWaitHint = dwWaitHint;
+
+ if ( ( dwCurrentState == SERVICE_RUNNING ) ||
+ ( dwCurrentState == SERVICE_STOPPED ) )
+ ssStatus.dwCheckPoint = 0;
+ else
+ ssStatus.dwCheckPoint = dwCheckPoint++;
+
+
+ /* Report the status of the service to the service control manager. */
+
+ if (!(fResult = SetServiceStatus( sshStatusHandle, &ssStatus))) {
+ AddToMessageLog(TEXT("SetServiceStatus"));
+ }
+ return fResult;
+}
+
+/*
+ * Report event to the Service Manager
+ */
+int ReportManager(int event)
+{
+ if (isWindowsNT())
+ return(ReportStatusToSCMgr(
+ event, /* service state */
+ NO_ERROR, /* exit code */
+ 3000)); /* wait hint */
+ return(1);
+}
+
+/*
+ *
+ * FUNCTION: ServiceStart
+ *
+ * PURPOSE: Actual code of the service
+ * that does the work.
+ *
+ * PARAMETERS:
+ * dwArgc - number of command line arguments
+ * lpszArgv - array of command line arguments
+ *
+ * RETURN VALUE:
+ * none
+ *
+ * COMMENTS:
+ * The default behavior is to read the registry and start jsvc.
+ * The service stops when hServerStopEvent is signalled, the jsvc
+ * is stopped via TermPid(pid) (see kills.c).
+ *
+ */
+VOID ServiceStart (DWORD dwArgc, LPTSTR *lpszArgv)
+{
+char Data[512];
+DWORD qreturn;
+STARTUPINFO StartupInfo;
+PROCESS_INFORMATION ProcessInformation;
+char *qptr;
+
+
+ /* Service initialization */
+ ProcessInformation.hProcess = NULL;
+
+ /* report the status to the service control manager. */
+
+ AddToMessageLog(TEXT("ServiceStart: starting"));
+ if (!ReportManager(SERVICE_START_PENDING))
+ goto cleanup;
+
+ /*
+ * create the event object. The control handler function signals
+ * this event when it receives the "stop" control code.
+ *
+ */
+ hServerStopEvent = CreateEvent(
+ NULL, /* no security attributes */
+ TRUE, /* manual reset event */
+ FALSE, /* not-signalled */
+ NULL); /* no name */
+
+ if ( hServerStopEvent == NULL)
+ goto cleanup;
+
+ /* report the status to the service control manager. */
+ if (!ReportManager(SERVICE_START_PENDING))
+ goto cleanup;
+
+ /* Read the registry and set environment. */
+ if (OnServeSetEnv()) {
+ AddToMessageLog(TEXT("ServiceStart: read environment failed"));
+ goto cleanup;
+ }
+
+ if (!ReportManager(SERVICE_START_PENDING))
+ goto cleanup;
+
+ /* set the start path for jsvc.exe */
+ qptr = getenv("JAKARTA_HOME");
+ if (qptr==NULL || strlen(qptr)==0) {
+ AddToMessageLog(TEXT("ServiceStart: read JAKARTA_HOME failed"));
+ goto cleanup;
+ }
+
+ /* Build the start jsvc command according to the registry information. */
+ strcpy(Data,qptr);
+ BuildCommand(Data);
+ AddToMessageLog(TEXT(Data));
+
+ /* create the jsvc process. */
+ AddToMessageLog(TEXT("ServiceStart: start jsvc"));
+ memset(&StartupInfo,'\0',sizeof(StartupInfo));
+ StartupInfo.cb = sizeof(STARTUPINFO);
+
+ if (!CreateProcess(NULL,Data,NULL,NULL,FALSE,
+ DETACHED_PROCESS|NORMAL_PRIORITY_CLASS,
+ NULL,NULL, &StartupInfo, &ProcessInformation))
+ goto cleanup;
+ AddToMessageLog(TEXT("ServiceStart: jsvc started"));
+ CloseHandle(ProcessInformation.hThread);
+ ProcessInformation.hThread = NULL;
+ hMonitorProcess = ProcessInformation.hProcess;
+
+ if (!ReportManager(SERVICE_START_PENDING))
+ goto cleanup;
+
+ /* wait until the process is completly created. */
+/* With the DETACHED_PROCESS it does not work...
+ if (WaitForInputIdle(ProcessInformation.hProcess , INFINITE)) {
+ AddToMessageLog(TEXT("ServiceStart: jsvc stopped after creation"));
+ goto cleanup;
+ }
+ */
+
+ /*
+ * jsvc is now running.
+ * report the status to the service control manager.
+ */
+
+ if (!ReportManager(SERVICE_RUNNING))
+ goto cleanup;
+
+ /* End of initialization */
+
+ /*
+ *
+ * Service is now running, perform work until shutdown:
+ * Check every 60 seconds if the monitor is up.
+ *
+ */
+
+ for (;;) {
+ qreturn = WaitForSingleObject(hServerStopEvent,60000); /* each minutes. */
+
+ if (qreturn == WAIT_FAILED) break;/* something have gone wrong. */
+
+ if (qreturn == WAIT_TIMEOUT) {
+ /* timeout check the monitor. */
+ if (GetExitCodeProcess(ProcessInformation.hProcess, &qreturn)) {
+ if (qreturn == STILL_ACTIVE) continue;
+ }
+ AddToMessageLog(TEXT("ServiceStart: jsvc crashed"));
+ hMonitorProcess = NULL;
+ CloseHandle(hServerStopEvent);
+ CloseHandle(ProcessInformation.hProcess);
+ exit(0); /* exit ungracefully so
+ * Service Control Manager
+ * will attempt a restart. */
+
+ break; /*failed. */
+ }
+
+ /* stop the monitor by signal(event) */
+ sprintf(Data,"ServiceStart: stopping jsvc: %d",
+ ProcessInformation.dwProcessId);
+ AddToMessageLog(Data);
+
+ if (TermPid(ProcessInformation.dwProcessId)) {
+ AddToMessageLog(TEXT("ServiceStart: jsvc stop failed"));
+ break;
+ }
+ WaitForMonitor(6);
+ AddToMessageLog(TEXT("ServiceStart: jsvc stopped"));
+ break; /* finished!!! */
+ }
+
+ cleanup:
+
+ AddToMessageLog(TEXT("ServiceStart: stopped"));
+ if (hServerStopEvent)
+ CloseHandle(hServerStopEvent);
+
+ if (ProcessInformation.hProcess)
+ CloseHandle(ProcessInformation.hProcess);
+
+}
+
+/*
+ *
+ * FUNCTION: service_ctrl
+ *
+ * PURPOSE: This function is called by the SCM whenever
+ * ControlService() is called on this service.
+ *
+ * PARAMETERS:
+ * dwCtrlCode - type of control requested
+ *
+ * RETURN VALUE:
+ * none
+ *
+ * COMMENTS:
+ *
+ */
+VOID WINAPI service_ctrl(DWORD dwCtrlCode)
+{
+ /* Handle the requested control code. */
+ switch(dwCtrlCode)
+ {
+ /* Stop the service.
+ *
+ * SERVICE_STOP_PENDING should be reported before
+ * setting the Stop Event - hServerStopEvent - in
+ * ServiceStop(). This avoids a race condition
+ * which may result in a 1053 - The Service did not respond...
+ * error.
+ */
+ case SERVICE_CONTROL_STOP:
+ ReportStatusToSCMgr(SERVICE_STOP_PENDING, NO_ERROR, 0);
+ ServiceStop();
+ return;
+
+ /* Update the service status. */
+ case SERVICE_CONTROL_INTERROGATE:
+ break;
+
+ /* invalid control code */
+ default:
+ break;
+
+ }
+
+ ReportStatusToSCMgr(ssStatus.dwCurrentState, NO_ERROR, 0);
+}
+
+/*
+ *
+ * FUNCTION: service_main
+ *
+ * PURPOSE: To perform actual initialization of the service
+ *
+ * PARAMETERS:
+ * dwArgc - number of command line arguments
+ * lpszArgv - array of command line arguments
+ *
+ * RETURN VALUE:
+ * none
+ *
+ * COMMENTS:
+ * This routine performs the service initialization and then calls
+ * the user defined ServiceStart() routine to perform majority
+ * of the work.
+ *
+ */
+void WINAPI service_main(DWORD dwArgc, LPTSTR *lpszArgv)
+{
+
+ AddToMessageLog(TEXT("service_main:starting"));
+
+ /* register our service control handler: */
+ sshStatusHandle = RegisterServiceCtrlHandler( TEXT(SZSERVICENAME),
+ service_ctrl);
+
+ if (!sshStatusHandle) {
+ AddToMessageLog(TEXT("service_main:RegisterServiceCtrlHandler failed"));
+ goto cleanup;
+ }
+
+ /* SERVICE_STATUS members that don't change in example */
+ ssStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
+ ssStatus.dwServiceSpecificExitCode = 0;
+
+
+ /* report the status to the service control manager. */
+ if (!ReportStatusToSCMgr(SERVICE_START_PENDING,NO_ERROR,3000)) {
+ AddToMessageLog(TEXT("service_main:ReportStatusToSCMgr failed"));
+ goto cleanup;
+ }
+
+
+ ServiceStart( dwArgc, lpszArgv );
+
+cleanup:
+ /*
+ * try to report the stopped status to the service control manager.
+ */
+ if (sshStatusHandle)
+ (VOID)ReportStatusToSCMgr(
+ SERVICE_STOPPED,
+ dwErr,
+ 0);
+
+ AddToMessageLog(TEXT("service_main:stopped"));
+ return;
+}
+
+/*
+ *
+ * FUNCTION: main
+ *
+ * PURPOSE: entrypoint for service
+ *
+ * PARAMETERS:
+ * argc - number of command line arguments
+ * argv - array of command line arguments
+ *
+ * RETURN VALUE:
+ * none
+ *
+ * COMMENTS:
+ * main() either performs the command line task, or
+ * call StartServiceCtrlDispatcher to register the
+ * main service thread. When the this call returns,
+ * the service has stopped, so exit.
+ *
+ */
+#ifdef CYGWIN
+int main(int argc, char **argv)
+#else
+void _CRTAPI1 main(int argc, char **argv)
+#endif
+{
+ SERVICE_TABLE_ENTRY dispatchTable[] =
+ {
+ { TEXT(SZSERVICENAME), (LPSERVICE_MAIN_FUNCTION)service_main },
+ { NULL, NULL }
+ };
+
+ AddToMessageLog(TEXT("StartService starting"));
+ if (isWindowsNT()) {
+ if (!StartServiceCtrlDispatcher(dispatchTable)) {
+ AddToMessageLog(TEXT("StartServiceCtrlDispatcher failed."));
+ return;
+ }
+ AddToMessageLog(TEXT("StartService started"));
+ } else {
+ Windows9xServiceCtrlHandler();
+ ServiceStart(argc,argv);
+ AddToMessageLog(TEXT("StartService stopped"));
+ }
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/LICENSE
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/LICENSE 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/LICENSE 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,287 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+
+APACHE PORTABLE RUNTIME SUBCOMPONENTS:
+
+The Apache Portable Runtime includes a number of subcomponents with
+separate copyright notices and license terms. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+For the include\apr_md5.h component:
+/*
+ * This is work is derived from material Copyright RSA Data Security, Inc.
+ *
+ * The RSA copyright statement and Licence for that original material is
+ * included below. This is followed by the Apache copyright statement and
+ * licence for the modifications made to that material.
+ */
+
+/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+ rights reserved.
+
+ License to copy and use this software is granted provided that it
+ is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+ Algorithm" in all material mentioning or referencing this software
+ or this function.
+
+ License is also granted to make and use derivative works provided
+ that such works are identified as "derived from the RSA Data
+ Security, Inc. MD5 Message-Digest Algorithm" in all material
+ mentioning or referencing the derived work.
+
+ RSA Data Security, Inc. makes no representations concerning either
+ the merchantability of this software or the suitability of this
+ software for any particular purpose. It is provided "as is"
+ without express or implied warranty of any kind.
+
+ These notices must be retained in any copies of any part of this
+ documentation and/or software.
+ */
+
+For the passwd\apr_md5.c component:
+
+/*
+ * This is work is derived from material Copyright RSA Data Security, Inc.
+ *
+ * The RSA copyright statement and Licence for that original material is
+ * included below. This is followed by the Apache copyright statement and
+ * licence for the modifications made to that material.
+ */
+
+/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
+ */
+
+/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+ rights reserved.
+
+ License to copy and use this software is granted provided that it
+ is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+ Algorithm" in all material mentioning or referencing this software
+ or this function.
+
+ License is also granted to make and use derivative works provided
+ that such works are identified as "derived from the RSA Data
+ Security, Inc. MD5 Message-Digest Algorithm" in all material
+ mentioning or referencing the derived work.
+
+ RSA Data Security, Inc. makes no representations concerning either
+ the merchantability of this software or the suitability of this
+ software for any particular purpose. It is provided "as is"
+ without express or implied warranty of any kind.
+
+ These notices must be retained in any copies of any part of this
+ documentation and/or software.
+ */
+/*
+ * The apr_md5_encode() routine uses much code obtained from the FreeBSD 3.0
+ * MD5 crypt() function, which is licenced as follows:
+ * ----------------------------------------------------------------------------
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * <phk at login.dknet.dk> wrote this file. As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
+ * ----------------------------------------------------------------------------
+ */
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,1705 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apxwin.h"
+#include "apsvcmgr.h"
+
+LPAPXGUISTORE _gui_store = NULL;
+HWND hWndToolbar = NULL;
+HWND hWndList = NULL;
+HWND hWndListHdr = NULL;
+WNDPROC ListViewWinMain;
+WNDPROC ListViewWinHead;
+HWND hWndStatus = NULL;
+HWND hWndModal = NULL;
+LVHITTESTINFO lvLastHit;
+int lvHitItem = -1;
+/* Toolbar buttons
+ * TODO: Localize...
+ */
+TBBUTTON tbButtons[] = {
+ { 4, IDAM_SAVE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
+ { 5, IDAM_NEW, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
+ { 7, IDMS_REFRESH, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
+ {16, IDMV_FILTER, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0},
+ { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0},
+ { 8, IDAM_DELETE, 0, TBSTYLE_BUTTON, 0, 0},
+ { 6, IDMS_PROPERTIES, 0, TBSTYLE_BUTTON, 0, 0},
+ { 0, IDMS_START, 0, TBSTYLE_BUTTON, 0, 0},
+ { 1, IDMS_STOP, 0, TBSTYLE_BUTTON, 0, 0},
+ { 2, IDMS_PAUSE, 0, TBSTYLE_BUTTON, 0, 0},
+ { 3, IDMS_RESTART, 0, TBSTYLE_BUTTON, 0, 0},
+ { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0, 0},
+ {11, IDMH_HELP, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0}
+};
+
+APXLVITEM lvItems[] = {
+ { 0, FALSE, 80, 80, LVCFMT_LEFT, TEXT("Status") },
+ { 0, TRUE, 120, 120, LVCFMT_LEFT, TEXT("Name") },
+ { 0, TRUE, 240, 240, LVCFMT_LEFT, TEXT("Description") },
+ { 0, TRUE, 80, 80, LVCFMT_LEFT, TEXT("Startup Type") },
+ { 0, TRUE, 80, 80, LVCFMT_LEFT, TEXT("Log On As") },
+ { 0, FALSE, 80, 80, LVCFMT_RIGHT, TEXT("Process Id") },
+ { 0, FALSE, 0, 80, LVCFMT_RIGHT, TEXT("# Handles") }
+};
+
+#define NUMTBBUTTONS (sizeof(tbButtons) / sizeof(tbButtons[0]))
+#define NUMLVITEMS (sizeof(lvItems) / sizeof(lvItems[0]))
+
+#define APSVCMGR_CLASS TEXT("APSVCMGR")
+
+/* Display only Started/Paused status */
+#define STAT_STARTED TEXT("Started")
+#define STAT_PAUSED TEXT("Paused")
+#define STAT_STOPPED TEXT("Stopped")
+#define STAT_DISABLED TEXT("Disabled")
+#define STAT_NONE TEXT("")
+#define STAT_SYSTEM L"LocalSystem"
+
+#define START_AUTO L"Automatic"
+#define START_MANUAL L"Manual"
+#define START_DISABLED L"Disabled"
+#define START_BOOT L"Boot"
+#define START_SYSTEM L"SystemInit"
+
+#define SFILT_KEY L"Filters"
+#define SFILT_INAME L"IncludeName"
+#define SFILT_XNAME L"ExcludeName"
+#define SFILT_ISIMG L"IncludeImage"
+#define SFILT_XSIMG L"ExcludeImage"
+
+#define DISPLAY_KEY "Display"
+#define DISPLAY_STATE "GuiState"
+#define EMPTY_PASSWORD L" "
+#define EXPORT_TITLE "Export Services list"
+#define EXPORT_EXTFILT "Comma separated (*.csv)\0*.csv\0Tab Delimited (*.tab)\0*.txt\0All Files(*.*)\0*.*\0"
+
+
+#define WM_TIMER_REFRESH 10
+#define WM_USER_LREFRESH WM_USER + 1
+#define UPD_FAST 10000
+#define UPD_SLOW 60000
+
+static int _toolbarHeight = 0;
+static int _statbarHeight = 0;
+static int _currentTimer = IDMV_UPAUSED;
+static int _currentLitem = 0;
+static int _listviewCols = 0;
+static int _sortOrder = 1;
+static int _sortColumn = 1;
+static LPAPXSERVENTRY _currentEntry = NULL;
+
+static LPWSTR _filterIname = NULL;
+static LPWSTR _filterXname = NULL;
+static LPWSTR _filterIimage = NULL;
+static LPWSTR _filterXimage = NULL;
+static LPSTR _exportFilename = NULL;
+static DWORD _exportIndex = 0;
+/* Main application pool */
+APXHANDLE hPool = NULL;
+APXHANDLE hService = NULL;
+APXHANDLE hRegistry = NULL;
+
+/* Service browse callback declaration */
+BOOL ServiceCallback(APXHANDLE hObject, UINT uMsg,
+ WPARAM wParam, LPARAM lParam);
+
+int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
+{
+ WCHAR szA[1024] = {0};
+ WCHAR szB[1024] = {0};
+ int rc;
+ ListView_GetItemTextW(hWndList, (INT)lParam1, _sortColumn, szA, 1023);
+ ListView_GetItemTextW(hWndList, (INT)lParam2, _sortColumn, szB, 1023);
+ rc = lstrcmpW(szA, szB);
+
+ return rc * _sortOrder;
+}
+
+void DestroyListView()
+{
+ int i, x;
+
+ x = ListView_GetItemCount(hWndList);
+ if (x > 0) {
+ LV_ITEM lvI;
+ lvI.mask = LVIF_PARAM;
+ for (i = 0; i < x; i++) {
+ lvI.iItem = i;
+ lvI.lParam = 0;
+ ListView_GetItem(hWndList, &lvI);
+ if (lvI.lParam) {
+ LPAPXSERVENTRY lpEnt = (LPAPXSERVENTRY)lvI.lParam;
+ apxFree(lpEnt->lpConfig);
+ apxFree(lpEnt);
+ }
+ }
+ }
+ ListView_DeleteAllItems(hWndList);
+ _currentLitem = 0;
+}
+
+BOOL ExportListView(LPCSTR szFileName, DWORD dwIndex)
+{
+ int i, j, x;
+ CHAR szI[SIZ_DESLEN];
+ HANDLE hFile;
+ DWORD dwWriten;
+ LPSTR szD;
+ hFile = CreateFileA(szFileName,
+ GENERIC_WRITE,
+ 0,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if (IS_INVALID_HANDLE(hFile))
+ return FALSE;
+ x = ListView_GetItemCount(hWndList);
+ if (x > 0) {
+ LV_ITEM lvI;
+ lvI.mask = LVIF_PARAM;
+
+ if (dwIndex == 1)
+ szD = ";";
+ else
+ szD = "\t";
+ WriteFile(hFile, "ServiceName", sizeof("ServiceName") - 1, &dwWriten, NULL);
+ for (i = 1; i < NUMLVITEMS; i++) {
+ if (lvItems[i].iWidth) {
+#ifdef _UNICODE
+ WideToAscii(lvItems[i].szLabel, szI);
+#else
+ lstrcpyA(szI, lvItems[i].szLabel);
+#endif
+ WriteFile(hFile, szD, 1, &dwWriten, NULL);
+ WriteFile(hFile, szI, lstrlenA(szI), &dwWriten, NULL);
+ }
+ }
+ WriteFile(hFile, "\r\n", 2, &dwWriten, NULL);
+ for (i = 0; i < x; i++) {
+ lvI.iItem = i;
+ lvI.lParam = 0;
+ ListView_GetItem(hWndList, &lvI);
+ if (lvI.lParam) {
+ LPAPXSERVENTRY lpEnt = (LPAPXSERVENTRY)lvI.lParam;
+ WideToAscii(lpEnt->szServiceName, szI);
+ WriteFile(hFile, szI, lstrlenA(szI), &dwWriten, NULL);
+ WriteFile(hFile, szD, 1, &dwWriten, NULL);
+
+ }
+ for (j = 1; j < _listviewCols - 1; j++) {
+ szI[0] = '\0';
+ ListView_GetItemTextA(hWndList, i, j, szI, SIZ_DESMAX);
+ if (szI[0])
+ WriteFile(hFile, szI, lstrlenA(szI), &dwWriten, NULL);
+ WriteFile(hFile, szD, 1, &dwWriten, NULL);
+ }
+ szI[0] = '\0';
+ ListView_GetItemTextA(hWndList, i, j, szI, SIZ_DESMAX);
+ if (szI[0])
+ WriteFile(hFile, szI, lstrlenA(szI), &dwWriten, NULL);
+ WriteFile(hFile, "\r\n", 2, &dwWriten, NULL);
+ }
+ }
+ CloseHandle(hFile);
+ return TRUE;
+}
+
+void RefreshServices(int iRefresh)
+{
+ int prev = _currentLitem;
+ _currentLitem = 0;
+ apxServiceBrowse(hService, _filterIname, _filterIimage,
+ _filterXname, _filterXimage, WM_USER+1+iRefresh,
+ ServiceCallback, NULL);
+ ListView_SortItemsEx(hWndList, CompareFunc, NULL);
+ if (prev > _currentLitem) {
+ DestroyListView();
+ apxServiceBrowse(hService, _filterIname, _filterIimage,
+ _filterXname, _filterXimage, WM_USER+1,
+ ServiceCallback, NULL);
+ ListView_SortItemsEx(hWndList, CompareFunc, NULL);
+ }
+ if ((lvHitItem = ListView_GetSelectionMark(hWndList)) >= 0) {
+#if 0
+ /* Ensure that the selected is visible */
+ ListView_EnsureVisible(hWndList,lvHitItem, FALSE);
+#endif
+ PostMessage(hWndList, WM_USER_LREFRESH, 0, 0);
+ }
+}
+
+void RestoreRefreshTimer()
+{
+ if (_currentTimer == IDMV_UFAST)
+ SetTimer(_gui_store->hMainWnd, WM_TIMER_REFRESH, UPD_FAST, NULL);
+ else if (_currentTimer == IDMV_USLOW)
+ SetTimer(_gui_store->hMainWnd, WM_TIMER_REFRESH, UPD_SLOW, NULL);
+ else
+ KillTimer(_gui_store->hMainWnd, WM_TIMER_REFRESH);
+}
+
+/* wParam progress dialog handle
+ */
+static BOOL __startServiceCallback(APXHANDLE hObject, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ HWND hDlg = (HWND)hObject;
+ APXHANDLE hSrv;
+ switch (uMsg) {
+ case WM_USER+1:
+ hDlg = (HWND)lParam;
+ hSrv = apxCreateService(hPool, SC_MANAGER_CONNECT, FALSE);
+ if (!hSrv) {
+ EndDialog(hDlg, IDOK);
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND,
+ MAKEWPARAM(IDMS_REFRESH, 0), 0);
+ return FALSE;
+ }
+ if (!apxServiceOpen(hSrv, _currentEntry->szServiceName,
+ GENERIC_READ | GENERIC_EXECUTE)) {
+ apxCloseHandle(hSrv);
+ EndDialog(hDlg, IDOK);
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND,
+ MAKEWPARAM(IDMS_REFRESH, 0), 0);
+ return FALSE;
+ }
+ if (apxServiceControl(hSrv, SERVICE_CONTROL_CONTINUE, WM_USER+2,
+ __startServiceCallback, hDlg)) {
+ _currentEntry->stServiceStatus.dwCurrentState = SERVICE_RUNNING;
+ _currentEntry->stStatusProcess.dwCurrentState = SERVICE_RUNNING;
+
+ }
+ apxCloseHandle(hSrv);
+ EndDialog(hDlg, IDOK);
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND,
+ MAKEWPARAM(IDMS_REFRESH, 0), 0);
+ break;
+ case WM_USER+2:
+ SendMessage(hDlg, WM_USER+1, 0, 0);
+ Sleep(500);
+ break;
+ }
+ return TRUE;
+}
+
+static BOOL __stopServiceCallback(APXHANDLE hObject, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ HWND hDlg = (HWND)hObject;
+ APXHANDLE hSrv;
+ switch (uMsg) {
+ case WM_USER+1:
+ hDlg = (HWND)lParam;
+ hSrv = apxCreateService(hPool, SC_MANAGER_CONNECT, FALSE);
+ if (!hSrv)
+ return FALSE;
+ if (!apxServiceOpen(hSrv, _currentEntry->szServiceName,
+ GENERIC_READ | GENERIC_EXECUTE)) {
+ apxCloseHandle(hSrv);
+ return FALSE;
+ }
+ if (apxServiceControl(hSrv, SERVICE_CONTROL_STOP, WM_USER+2,
+ __stopServiceCallback, hDlg)) {
+ }
+ apxCloseHandle(hSrv);
+ EndDialog(hDlg, IDOK);
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND,
+ MAKEWPARAM(IDMS_REFRESH, 0), 0);
+ break;
+ case WM_USER+2:
+ if (wParam == 4)
+ AplCopyMemory(&_currentEntry->stServiceStatus,
+ (LPVOID)lParam, sizeof(SERVICE_STATUS));
+ SendMessage(hDlg, WM_USER+1, 0, 0);
+ Sleep(100);
+ break;
+ }
+ return TRUE;
+}
+
+static BOOL __restartServiceCallback(APXHANDLE hObject, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ HWND hDlg = (HWND)hObject;
+ APXHANDLE hSrv;
+ switch (uMsg) {
+ case WM_USER+1:
+ hDlg = (HWND)lParam;
+ hSrv = apxCreateService(hPool, SC_MANAGER_CONNECT, FALSE);
+ if (!hSrv)
+ return FALSE;
+ if (!apxServiceOpen(hSrv, _currentEntry->szServiceName,
+ GENERIC_READ | GENERIC_EXECUTE)) {
+ apxCloseHandle(hSrv);
+ return FALSE;
+ }
+ /* TODO: use 128 as controll code */
+ if (apxServiceControl(hSrv, 128, WM_USER+2,
+ __restartServiceCallback, hDlg)) {
+
+ }
+ apxCloseHandle(hSrv);
+ EndDialog(hDlg, IDOK);
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND,
+ MAKEWPARAM(IDMS_REFRESH, 0), 0);
+ break;
+ case WM_USER+2:
+ if (wParam == 4)
+ AplCopyMemory(&_currentEntry->stServiceStatus,
+ (LPVOID)lParam, sizeof(SERVICE_STATUS));
+
+ SendMessage(hDlg, WM_USER+1, 0, 0);
+ Sleep(100);
+ break;
+ }
+ return TRUE;
+}
+
+static BOOL __pauseServiceCallback(APXHANDLE hObject, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ HWND hDlg = (HWND)hObject;
+ APXHANDLE hSrv;
+ switch (uMsg) {
+ case WM_USER+1:
+ hDlg = (HWND)lParam;
+ hSrv = apxCreateService(hPool, SC_MANAGER_CONNECT, FALSE);
+ if (!hSrv)
+ return FALSE;
+ if (!apxServiceOpen(hSrv, _currentEntry->szServiceName,
+ GENERIC_READ | GENERIC_EXECUTE)) {
+ apxCloseHandle(hSrv);
+ return FALSE;
+ }
+ if (apxServiceControl(hSrv, SERVICE_CONTROL_PAUSE, WM_USER+2,
+ __pauseServiceCallback, hDlg)) {
+ }
+ apxCloseHandle(hSrv);
+ EndDialog(hDlg, IDOK);
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND,
+ MAKEWPARAM(IDMS_REFRESH, 0), 0);
+ break;
+ case WM_USER+2:
+ if (wParam == 4)
+ AplCopyMemory(&_currentEntry->stServiceStatus,
+ (LPVOID)lParam, sizeof(SERVICE_STATUS));
+ SendMessage(hDlg, WM_USER+1, 0, 0);
+ Sleep(100);
+ break;
+ }
+ return TRUE;
+}
+
+LRESULT CALLBACK ListViewMainSubclass(HWND hWnd, UINT uMsg, WPARAM wParam,
+ LPARAM lParam)
+{
+ static POINTS mouseClick;
+
+ HMENU hMenu = NULL;
+ HMENU hLoad = NULL;
+ HMENU hMain = NULL;
+ switch (uMsg) {
+ case WM_LBUTTONDOWN:
+ case WM_RBUTTONDOWN:
+ case WM_LBUTTONDBLCLK:
+ mouseClick = MAKEPOINTS(lParam);
+ lvLastHit.pt.x = mouseClick.x;
+ lvLastHit.pt.y = mouseClick.y;
+ case WM_USER_LREFRESH:
+ lvHitItem = ListView_HitTest(hWndList, &lvLastHit);
+ _currentEntry = NULL;
+ hMain = GetMenu(_gui_store->hMainWnd);
+ CallWindowProc(ListViewWinMain, hWnd, uMsg, wParam, lParam);
+ EnableMenuItem(hMain, IDMS_START, MF_BYCOMMAND | MF_GRAYED);
+ EnableMenuItem(hMain, IDMS_STOP, MF_BYCOMMAND | MF_GRAYED);
+ EnableMenuItem(hMain, IDMS_PAUSE, MF_BYCOMMAND | MF_GRAYED);
+ EnableMenuItem(hMain, IDMS_RESTART, MF_BYCOMMAND | MF_GRAYED);
+ EnableMenuItem(hMain, IDAM_DELETE, MF_BYCOMMAND | MF_GRAYED);
+ SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_START, FALSE);
+ SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_STOP, FALSE);
+ SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_PAUSE, FALSE);
+ SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_RESTART, FALSE);
+ SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_PROPERTIES, FALSE);
+ SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDAM_DELETE, FALSE);
+ EnableMenuItem(hMain, IDMS_PROPERTIES, MF_BYCOMMAND | MF_GRAYED);
+
+ if (lvHitItem >= 0) {
+ LV_ITEM lvI;
+ lvI.mask = LVIF_PARAM;
+ lvI.iItem = lvHitItem;
+ lvI.lParam = 0;
+ ListView_GetItem(hWndList, &lvI);
+ if (lvI.lParam) {
+ _currentEntry = (LPAPXSERVENTRY)lvI.lParam;
+ SendMessageW(hWndStatus, WM_SETTEXT, 0, (LPARAM)_currentEntry->szServiceDescription);
+ if (uMsg == WM_RBUTTONDOWN) {
+ hLoad = LoadMenu(_gui_store->hInstance,
+ MAKEINTRESOURCE(IDM_POPUPMENU));
+
+ hMenu = GetSubMenu(hLoad, 0);
+ }
+ switch (_currentEntry->stServiceStatus.dwCurrentState) {
+ case SERVICE_RUNNING:
+ if (_currentEntry->stServiceStatus.dwControlsAccepted & SERVICE_ACCEPT_STOP) {
+ SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_STOP, TRUE);
+ EnableMenuItem(hMain, IDMS_STOP, MF_BYCOMMAND | MF_ENABLED);
+ if (hMenu)
+ EnableMenuItem(hMenu, IDMS_STOP, MF_BYCOMMAND | MF_ENABLED);
+ }
+ if (_currentEntry->stServiceStatus.dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) {
+ SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_PAUSE, TRUE);
+ SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_RESTART, TRUE);
+ EnableMenuItem(hMain, IDMS_PAUSE, MF_BYCOMMAND | MF_ENABLED);
+ EnableMenuItem(hMain, IDMS_RESTART, MF_BYCOMMAND | MF_ENABLED);
+ if (hMenu) {
+ EnableMenuItem(hMenu, IDMS_PAUSE, MF_BYCOMMAND | MF_ENABLED);
+ EnableMenuItem(hMenu, IDMS_RESTART, MF_BYCOMMAND | MF_ENABLED);
+ }
+ }
+ break;
+ case SERVICE_PAUSED:
+ SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_RESTART, TRUE);
+ SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_START, TRUE);
+ EnableMenuItem(hMain, IDMS_RESTART, MF_BYCOMMAND | MF_ENABLED);
+ EnableMenuItem(hMain, IDMS_START, MF_BYCOMMAND | MF_ENABLED);
+ if (hMenu) {
+ EnableMenuItem(hMenu, IDMS_RESTART, MF_BYCOMMAND | MF_ENABLED);
+ EnableMenuItem(hMenu, IDMS_START, MF_BYCOMMAND | MF_ENABLED);
+ }
+ break;
+ case SERVICE_STOPPED:
+ if (_currentEntry->lpConfig->dwStartType != SERVICE_DISABLED) {
+ SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_START, TRUE);
+ EnableMenuItem(hMain, IDMS_START, MF_BYCOMMAND | MF_ENABLED);
+ if (hMenu)
+ EnableMenuItem(hMenu, IDMS_START, MF_BYCOMMAND | MF_ENABLED);
+ }
+ break;
+ default:
+
+ break;
+ }
+ }
+ SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDMS_PROPERTIES, TRUE);
+ EnableMenuItem(hMain, IDMS_PROPERTIES, MF_BYCOMMAND | MF_ENABLED);
+ SendMessage(hWndToolbar, TB_ENABLEBUTTON, IDAM_DELETE, TRUE);
+ EnableMenuItem(hMain, IDAM_DELETE, MF_BYCOMMAND | MF_ENABLED);
+ SetMenuDefaultItem(GetSubMenu(hMain, 1), IDMS_PROPERTIES, FALSE);
+
+ if (hMenu) {
+ POINT pt;
+ EnableMenuItem(hMenu, IDMS_PROPERTIES, MF_BYCOMMAND | MF_ENABLED);
+ SetMenuDefaultItem(hMenu, IDMS_PROPERTIES, FALSE);
+
+ GetCursorPos(&pt);
+ TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON,
+ pt.x, pt.y, 0, _gui_store->hMainWnd, NULL);
+ DestroyMenu(hLoad);
+ hMenu = NULL;
+ hLoad = NULL;
+ }
+ /* Post the Properties message to main window */
+ if (uMsg == WM_LBUTTONDBLCLK) {
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND,
+ MAKEWPARAM(IDMS_PROPERTIES, 0), 0);
+ }
+ }
+ else {
+ SetMenuDefaultItem(GetSubMenu(hMain, 1), -1, FALSE);
+ SendMessageW(hWndStatus, WM_SETTEXT, 0, (LPARAM)(L""));
+ }
+ return TRUE;
+ break;
+ }
+ return CallWindowProc(ListViewWinMain, hWnd, uMsg, wParam, lParam);
+}
+
+LRESULT CALLBACK ListViewHeadSubclass(HWND hWnd, UINT uMsg, WPARAM wParam,
+ LPARAM lParam)
+{
+ DWORD i, n = 0;
+
+ switch (uMsg) {
+ case WM_LBUTTONUP:
+ CallWindowProc(ListViewWinHead, hWnd, uMsg, wParam, lParam);
+ for (i = 0; i < NUMLVITEMS; i++) {
+ if (lvItems[i].iWidth) {
+ lvItems[i].iWidth = ListView_GetColumnWidth(hWndList, n++);
+ }
+ }
+ return TRUE;
+ break;
+
+ }
+ return CallWindowProc(ListViewWinHead, hWnd, uMsg, wParam, lParam);
+}
+
+HWND CreateServiceList(HWND hWndParent)
+{
+ HWND hWndList;
+ RECT rc;
+ LV_COLUMN lvC;
+ DWORD i;
+ HBITMAP hStatBmp;
+ HIMAGELIST hStatImg;
+ DWORD dwStyle;
+
+ dwStyle = WS_TABSTOP |
+ WS_CHILD |
+ WS_VISIBLE |
+ LVS_SINGLESEL |
+ LVS_REPORT;
+
+ GetWindowRect(hWndToolbar, &rc);
+ _toolbarHeight = rc.bottom - rc.top;
+ GetWindowRect(hWndStatus, &rc);
+ _statbarHeight = rc.bottom - rc.top;
+ /* Get the size and position of the parent window. */
+ GetClientRect(hWndParent, &rc);
+
+ /* Create the list view window */
+ hWndList = CreateWindowEx(WS_EX_CLIENTEDGE,
+ WC_LISTVIEW, TEXT(""),
+ dwStyle,
+ 0, _toolbarHeight,
+ rc.right - rc.left,
+ rc.bottom - rc.top - _toolbarHeight - _statbarHeight,
+ hWndParent,
+ (HMENU)IDC_LISTVIEW,
+ _gui_store->hInstance, NULL);
+ if (hWndList == NULL)
+ return NULL;
+ GetClientRect(hWndList, &rc);
+ hStatImg = ImageList_Create(16, 16, ILC_COLOR4, 0, 16);
+ hStatBmp = LoadImage(GetModuleHandleA(NULL), MAKEINTRESOURCE(IDB_SSTATUS),
+ IMAGE_BITMAP, 0, 0, LR_LOADTRANSPARENT);
+
+ ImageList_Add(hStatImg, hStatBmp, NULL);
+ DeleteObject(hStatBmp);
+
+ ListView_SetImageList(hWndList, hStatImg, LVSIL_SMALL);
+ lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
+ _listviewCols = 0;
+ for (i = 0; i < NUMLVITEMS; i++) {
+ lvC.iSubItem = i;
+ lvC.cx = lvItems[i].iWidth;
+ lvC.pszText = lvItems[i].szLabel;
+ lvC.fmt = lvItems[i].iFmt;
+ if (lvItems[i].iWidth > 0) {
+ ListView_InsertColumn(hWndList, i, &lvC );
+ _listviewCols++;
+ }
+ }
+#ifdef LVS_EX_FULLROWSELECT
+ ListView_SetExtendedListViewStyleEx(hWndList, 0,
+ LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);
+#endif
+ hWndListHdr = ListView_GetHeader(hWndList);
+ /* Sub-class */
+ ListViewWinMain = (WNDPROC)((SIZE_T)SetWindowLong(hWndList, GWLP_WNDPROC,
+ (LONG)((SIZE_T)ListViewMainSubclass)));
+
+ ListViewWinHead = (WNDPROC)((SIZE_T)SetWindowLong(hWndListHdr, GWLP_WNDPROC,
+ (LONG)((SIZE_T)ListViewHeadSubclass)));
+
+
+ return hWndList;
+}
+
+static DWORD _propertyChanged;
+/* Service property pages */
+void CALLBACK __propertyCallback(HWND hwndPropSheet, UINT uMsg, LPARAM lParam)
+{
+ switch(uMsg) {
+ case PSCB_PRECREATE:
+ {
+ LPDLGTEMPLATE lpTemplate = (LPDLGTEMPLATE)lParam;
+ if (!(lpTemplate->style & WS_SYSMENU))
+ lpTemplate->style |= WS_SYSMENU;
+ apxCenterWindow(hwndPropSheet, _gui_store->hMainWnd);
+ _propertyChanged = 0;
+ }
+ break;
+ case PSCB_INITIALIZED:
+ break;
+
+ }
+}
+
+BOOL __generalPropertySave(HWND hDlg)
+{
+ APXHANDLE hSrv;
+ WCHAR szN[256];
+ WCHAR szD[256];
+ DWORD dwStartType = SERVICE_NO_CHANGE;
+ int i;
+
+ if (!(TST_BIT_FLAG(_propertyChanged, 1)))
+ return TRUE;
+ CLR_BIT_FLAG(_propertyChanged, 1);
+
+ if (!(hSrv = apxCreateService(hPool, SC_MANAGER_CREATE_SERVICE, FALSE)))
+ return FALSE;
+ if (!apxServiceOpen(hSrv, _currentEntry->szServiceName, SERVICE_ALL_ACCESS)) {
+ apxCloseHandle(hSrv);
+ return FALSE;
+ }
+ GetDlgItemTextW(hDlg, IDC_PPSGDISP, szN, 255);
+ GetDlgItemTextW(hDlg, IDC_PPSGDESC, szD, 1023);
+ i = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_PPSGCMBST));
+ if (i == 0)
+ dwStartType = SERVICE_AUTO_START;
+ else if (i == 1)
+ dwStartType = SERVICE_DEMAND_START;
+ else if (i == 2)
+ dwStartType = SERVICE_DISABLED;
+ apxServiceSetNames(hSrv, NULL, szN, szD, NULL, NULL);
+ apxServiceSetOptions(hSrv, SERVICE_NO_CHANGE, dwStartType, SERVICE_NO_CHANGE);
+
+ apxCloseHandle(hSrv);
+ if (!(TST_BIT_FLAG(_propertyChanged, 2)))
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND, MAKEWPARAM(IDMS_REFRESH, 0), 0);
+
+ return TRUE;
+}
+
+BOOL __generalLogonSave(HWND hDlg)
+{
+ APXHANDLE hSrv;
+ WCHAR szU[64];
+ WCHAR szP[64];
+ WCHAR szC[64];
+ DWORD dwStartType = SERVICE_NO_CHANGE;
+
+ if (!(TST_BIT_FLAG(_propertyChanged, 2)))
+ return TRUE;
+ CLR_BIT_FLAG(_propertyChanged, 2);
+
+ if (!(hSrv = apxCreateService(hPool, SC_MANAGER_CREATE_SERVICE, FALSE)))
+ return FALSE;
+ if (!apxServiceOpen(hSrv, _currentEntry->szServiceName, SERVICE_ALL_ACCESS)) {
+ apxCloseHandle(hSrv);
+ return FALSE;
+ }
+ GetDlgItemTextW(hDlg, IDC_PPSLUSER, szU, 63);
+ GetDlgItemTextW(hDlg, IDC_PPSLPASS, szP, 63);
+ GetDlgItemTextW(hDlg, IDC_PPSLCPASS, szC, 63);
+
+ if (lstrlenW(szU) && lstrcmpiW(szU, STAT_SYSTEM)) {
+ if (szP[0] != L' ' && szC[0] != L' ' && !lstrcmpW(szP, szC))
+ apxServiceSetNames(hSrv, NULL, NULL, NULL, szU, szP);
+ else {
+ MessageBoxW(hDlg, apxLoadResourceW(IDS_VALIDPASS, 0),
+ apxLoadResourceW(IDS_APPLICATION, 1),
+ MB_OK | MB_ICONSTOP);
+ apxCloseHandle(hSrv);
+ return FALSE;
+ }
+ }
+ else {
+ if (IsDlgButtonChecked(hDlg, IDC_PPSLID) == BST_CHECKED)
+ apxServiceSetOptions(hSrv,
+ _currentEntry->stServiceStatus.dwServiceType | SERVICE_INTERACTIVE_PROCESS,
+ SERVICE_NO_CHANGE, SERVICE_NO_CHANGE);
+ else
+ apxServiceSetOptions(hSrv,
+ _currentEntry->stServiceStatus.dwServiceType & ~SERVICE_INTERACTIVE_PROCESS,
+ SERVICE_NO_CHANGE, SERVICE_NO_CHANGE);
+ }
+ apxCloseHandle(hSrv);
+ if (!(TST_BIT_FLAG(_propertyChanged, 1)))
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND, MAKEWPARAM(IDMS_REFRESH, 0), 0);
+ return TRUE;
+}
+
+void __generalPropertyRefresh(HWND hDlg)
+{
+ Button_Enable(GetDlgItem(hDlg, IDC_PPSGSTART), FALSE);
+ Button_Enable(GetDlgItem(hDlg, IDC_PPSGSTOP), FALSE);
+ Button_Enable(GetDlgItem(hDlg, IDC_PPSGPAUSE), FALSE);
+ Button_Enable(GetDlgItem(hDlg, IDC_PPSGRESTART), FALSE);
+ switch (_currentEntry->stServiceStatus.dwCurrentState) {
+ case SERVICE_RUNNING:
+ if (_currentEntry->stServiceStatus.dwControlsAccepted & SERVICE_ACCEPT_STOP ||
+ _currentEntry->lpConfig->dwStartType != SERVICE_DISABLED) {
+ Button_Enable(GetDlgItem(hDlg, IDC_PPSGSTOP), TRUE);
+ SetDlgItemText(hDlg, IDC_PPSGSTATUS, STAT_STARTED);
+ }
+ else
+ SetDlgItemText(hDlg, IDC_PPSGSTATUS, STAT_DISABLED);
+ if (_currentEntry->stServiceStatus.dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) {
+ Button_Enable(GetDlgItem(hDlg, IDC_PPSGPAUSE), TRUE);
+ Button_Enable(GetDlgItem(hDlg, IDC_PPSGRESTART), TRUE);
+ }
+ break;
+ case SERVICE_PAUSED:
+ Button_Enable(GetDlgItem(hDlg, IDC_PPSGSTART), TRUE);
+ Button_Enable(GetDlgItem(hDlg, IDC_PPSGRESTART), TRUE);
+ SetDlgItemText(hDlg, IDC_PPSGSTATUS, STAT_PAUSED);
+ break;
+ case SERVICE_STOPPED:
+ if (_currentEntry->lpConfig->dwStartType != SERVICE_DISABLED) {
+ Button_Enable(GetDlgItem(hDlg, IDC_PPSGSTART), TRUE);
+ SetDlgItemText(hDlg, IDC_PPSGSTATUS, STAT_DISABLED);
+ }
+ else
+ SetDlgItemText(hDlg, IDC_PPSGSTATUS, STAT_STOPPED);
+ break;
+ default:
+ break;
+ }
+}
+
+LRESULT CALLBACK __generalProperty(HWND hDlg,
+ UINT uMessage,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ LPPSHNOTIFY lpShn;
+ WCHAR szBuf[1024];
+
+ switch (uMessage) {
+ case WM_INITDIALOG:
+ {
+ PROPSHEETPAGE *lpPage = (PROPSHEETPAGE *)lParam;
+ LPAPXSERVENTRY lpService;
+ BOOL bLocalSystem = TRUE;
+
+ lpService = ( LPAPXSERVENTRY)lpPage->lParam;
+ SendMessage(GetDlgItem(hDlg, IDC_PPSGDISP), EM_LIMITTEXT, 255, 0);
+ SendMessage(GetDlgItem(hDlg, IDC_PPSGDESC), EM_LIMITTEXT, 1023, 0);
+
+ ComboBox_AddStringW(GetDlgItem(hDlg, IDC_PPSGCMBST), START_AUTO);
+ ComboBox_AddStringW(GetDlgItem(hDlg, IDC_PPSGCMBST), START_MANUAL);
+ ComboBox_AddStringW(GetDlgItem(hDlg, IDC_PPSGCMBST), START_DISABLED);
+ if (_currentEntry->lpConfig->dwStartType == SERVICE_AUTO_START)
+ ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_PPSGCMBST), 0);
+ else if (_currentEntry->lpConfig->dwStartType == SERVICE_DEMAND_START)
+ ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_PPSGCMBST), 1);
+ else if (_currentEntry->lpConfig->dwStartType == SERVICE_DISABLED)
+ ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_PPSGCMBST), 2);
+
+ SetDlgItemTextW(hDlg, IDC_PPSGNAME, _currentEntry->szServiceName);
+ SetDlgItemTextW(hDlg, IDC_PPSGDISP, _currentEntry->lpConfig->lpDisplayName);
+ SetDlgItemTextW(hDlg, IDC_PPSGDESC, _currentEntry->szServiceDescription);
+ SetDlgItemTextW(hDlg, IDC_PPSGDEXE, _currentEntry->lpConfig->lpBinaryPathName);
+ __generalPropertyRefresh(hDlg);
+ }
+ break;
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_PPSGCMBST:
+ if (HIWORD(wParam) == CBN_SELCHANGE) {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 1);
+ }
+ break;
+ case IDC_PPSGDISP:
+ if (HIWORD(wParam) == EN_CHANGE) {
+ GetDlgItemTextW(hDlg, IDC_PPSGDISP, szBuf, 255);
+ if (!lstrcmpW(szBuf, _currentEntry->lpConfig->lpDisplayName)) {
+ PropSheet_UnChanged(GetParent(hDlg), hDlg);
+ CLR_BIT_FLAG(_propertyChanged, 1);
+ }
+ else {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 1);
+ }
+ }
+ break;
+ case IDC_PPSGDESC:
+ if (HIWORD(wParam) == EN_CHANGE) {
+ GetDlgItemTextW(hDlg, IDC_PPSGDESC, szBuf, 1023);
+ if (!lstrcmpW(szBuf, _currentEntry->szServiceDescription)) {
+ PropSheet_UnChanged(GetParent(hDlg), hDlg);
+ CLR_BIT_FLAG(_propertyChanged, 1);
+ }
+ else {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 1);
+ }
+ }
+ break;
+ case IDC_PPSGSTART:
+ apxProgressBox(hDlg, apxLoadResource(IDS_HSSTART, 0),
+ _currentEntry->lpConfig->lpDisplayName,
+ __startServiceCallback, NULL);
+ __generalPropertyRefresh(hDlg);
+ break;
+ case IDC_PPSGSTOP:
+ apxProgressBox(hDlg, apxLoadResource(IDS_HSSTOP, 0),
+ _currentEntry->lpConfig->lpDisplayName,
+ __stopServiceCallback, NULL);
+ __generalPropertyRefresh(hDlg);
+ break;
+ case IDC_PPSGPAUSE:
+ apxProgressBox(hDlg, apxLoadResource(IDS_HSPAUSE, 0),
+ _currentEntry->lpConfig->lpDisplayName,
+ __pauseServiceCallback, NULL);
+ __generalPropertyRefresh(hDlg);
+ break;
+ case IDC_PPSGRESTART:
+ apxProgressBox(hDlg, apxLoadResource(IDS_HSRESTART, 0),
+ _currentEntry->lpConfig->lpDisplayName,
+ __restartServiceCallback, NULL);
+ __generalPropertyRefresh(hDlg);
+ break;
+ }
+ break;
+ case WM_NOTIFY:
+ lpShn = (LPPSHNOTIFY )lParam;
+ switch (lpShn->hdr.code) {
+ case PSN_APPLY: /* sent when OK or Apply button pressed */
+ if (__generalPropertySave(hDlg)) {
+ PropSheet_UnChanged(GetParent(hDlg), hDlg);
+ }
+ else {
+ SET_BIT_FLAG(_propertyChanged, 1);
+ SetWindowLong(hDlg, DWLP_MSGRESULT,
+ PSNRET_INVALID_NOCHANGEPAGE);
+ return TRUE;
+ }
+
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return FALSE;
+}
+
+LRESULT CALLBACK __logonProperty(HWND hDlg,
+ UINT uMessage,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ LPPSHNOTIFY lpShn;
+ WCHAR szBuf[1024];
+ switch (uMessage) {
+ case WM_INITDIALOG:
+ {
+ BOOL bAccount = FALSE;
+
+ SendMessage(GetDlgItem(hDlg, IDC_PPSLUSER), EM_LIMITTEXT, 63, 0);
+ SendMessage(GetDlgItem(hDlg, IDC_PPSLPASS), EM_LIMITTEXT, 63, 0);
+ SendMessage(GetDlgItem(hDlg, IDC_PPSLCPASS), EM_LIMITTEXT, 63, 0);
+ if (lstrcmpiW(_currentEntry->szObjectName, STAT_SYSTEM)) {
+ bAccount = TRUE;
+ CheckRadioButton(hDlg, IDC_PPSLLS, IDC_PPSLUA, IDC_PPSLUA);
+ SetDlgItemTextW(hDlg, IDC_PPSLUSER, _currentEntry->szObjectName);
+ SetDlgItemTextW(hDlg, IDC_PPSLPASS, EMPTY_PASSWORD);
+ SetDlgItemTextW(hDlg, IDC_PPSLCPASS, EMPTY_PASSWORD);
+ }
+ else {
+ CheckRadioButton(hDlg, IDC_PPSLLS, IDC_PPSLUA, IDC_PPSLLS);
+ if (_currentEntry->lpConfig->dwServiceType &
+ SERVICE_INTERACTIVE_PROCESS)
+ CheckDlgButton(hDlg, IDC_PPSLID, BST_CHECKED);
+ }
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLID), !bAccount);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLUSER), bAccount);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLBROWSE), bAccount);
+ EnableWindow(GetDlgItem(hDlg, IDL_PPSLPASS), bAccount);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLPASS), bAccount);
+ EnableWindow(GetDlgItem(hDlg, IDL_PPSLCPASS), bAccount);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLCPASS), bAccount);
+ }
+ break;
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_PPSLLS:
+ SetDlgItemTextW(hDlg, IDC_PPSLUSER, L"");
+ SetDlgItemTextW(hDlg, IDC_PPSLPASS, L"");
+ SetDlgItemTextW(hDlg, IDC_PPSLCPASS, L"");
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLID), TRUE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLUSER), FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLBROWSE), FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDL_PPSLPASS), FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLPASS), FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDL_PPSLCPASS), FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLCPASS), FALSE);
+ CheckRadioButton(hDlg, IDC_PPSLLS, IDC_PPSLUA, (INT)wParam);
+ if (lstrcmpiW(_currentEntry->szObjectName, STAT_SYSTEM)) {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 2);
+ }
+ else {
+ PropSheet_UnChanged(GetParent(hDlg), hDlg);
+ CLR_BIT_FLAG(_propertyChanged, 2);
+ }
+ break;
+ case IDC_PPSLUA:
+ SetDlgItemTextW(hDlg, IDC_PPSLUSER, _currentEntry->szObjectName);
+ SetDlgItemTextW(hDlg, IDC_PPSLPASS, EMPTY_PASSWORD);
+ SetDlgItemTextW(hDlg, IDC_PPSLCPASS, EMPTY_PASSWORD);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLID), FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLUSER), TRUE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLBROWSE), TRUE);
+ EnableWindow(GetDlgItem(hDlg, IDL_PPSLPASS), TRUE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLPASS), TRUE);
+ EnableWindow(GetDlgItem(hDlg, IDL_PPSLCPASS), TRUE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLCPASS), TRUE);
+ CheckRadioButton(hDlg, IDC_PPSLLS, IDC_PPSLUA, (INT)wParam);
+ if (lstrcmpW(_currentEntry->szObjectName, STAT_SYSTEM)) {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 2);
+ }
+ else {
+ PropSheet_UnChanged(GetParent(hDlg), hDlg);
+ CLR_BIT_FLAG(_propertyChanged, 2);
+ }
+ break;
+ case IDC_PPSLID:
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 2);
+ break;
+ case IDC_PPSLUSER:
+ if (HIWORD(wParam) == EN_CHANGE) {
+ GetDlgItemTextW(hDlg, IDC_PPSLUSER, szBuf, 63);
+ if (!lstrcmpiW(szBuf, _currentEntry->szObjectName)) {
+ PropSheet_UnChanged(GetParent(hDlg), hDlg);
+ CLR_BIT_FLAG(_propertyChanged, 2);
+ }
+ else {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 2);
+ }
+ }
+ break;
+ case IDC_PPSLPASS:
+ case IDC_PPSLCPASS:
+ if (HIWORD(wParam) == EN_CHANGE) {
+ WCHAR szP[64];
+ WCHAR szC[64];
+ GetDlgItemTextW(hDlg, IDC_PPSLPASS, szP, 63);
+ GetDlgItemTextW(hDlg, IDC_PPSLCPASS, szC, 63);
+ /* check for valid password match */
+ if (szP[0] == L' ' && szC[0] == L' ') {
+ PropSheet_UnChanged(GetParent(hDlg), hDlg);
+ CLR_BIT_FLAG(_propertyChanged, 2);
+ }
+ else if (!lstrcmpW(szP, szC)) {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 2);
+ }
+ }
+ break;
+ case IDC_PPSLBROWSE:
+ {
+ WCHAR szUser[SIZ_RESLEN];
+ if (apxDlgSelectUser(hDlg, szUser))
+ SetDlgItemTextW(hDlg, IDC_PPSLUSER, szUser);
+ }
+ break;
+ }
+ break;
+ case WM_NOTIFY:
+ lpShn = (LPPSHNOTIFY )lParam;
+ switch (lpShn->hdr.code) {
+ case PSN_APPLY: /* sent when OK or Apply button pressed */
+ if (__generalLogonSave(hDlg))
+ PropSheet_UnChanged(GetParent(hDlg), hDlg);
+ else {
+ SET_BIT_FLAG(_propertyChanged, 2);
+ SetWindowLong(hDlg, DWLP_MSGRESULT,
+ PSNRET_INVALID_NOCHANGEPAGE);
+ return TRUE;
+ }
+
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+ return FALSE;
+}
+
+void __initPpage(PROPSHEETPAGEW *lpPage, INT iDlg, INT iTitle, DLGPROC pfnDlgProc)
+{
+ lpPage->dwSize = sizeof(PROPSHEETPAGE);
+ lpPage->dwFlags = PSP_USETITLE;
+ lpPage->hInstance = _gui_store->hInstance;
+ lpPage->pszTemplate = MAKEINTRESOURCEW(iDlg);
+ lpPage->pszIcon = NULL;
+ lpPage->pfnDlgProc = pfnDlgProc;
+ lpPage->pszTitle = MAKEINTRESOURCEW(iTitle);
+ lpPage->lParam = 0;
+}
+
+INT_PTR ShowServiceProperties(HWND hWnd)
+{
+ PROPSHEETPAGEW psP[5];
+ PROPSHEETHEADERW psH;
+ WCHAR szT[1024] = {0};
+
+ __initPpage(&psP[0], IDD_PROPPAGE_SGENERAL, IDS_PPGENERAL,
+ __generalProperty);
+ __initPpage(&psP[1], IDD_PROPPAGE_LOGON, IDS_PPLOGON,
+ __logonProperty);
+
+ if (_currentEntry && _currentEntry->lpConfig)
+ lstrcpyW(szT, _currentEntry->lpConfig->lpDisplayName);
+ else
+ return (INT_PTR)0;
+ lstrcatW(szT, L" Service Properties");
+
+ psH.dwSize = sizeof(PROPSHEETHEADER);
+ psH.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK | PSH_NOCONTEXTHELP;
+ psH.hwndParent = hWnd;
+ psH.hInstance = _gui_store->hInstance;
+ psH.pszIcon = MAKEINTRESOURCEW(IDI_MAINICON);
+ psH.pszCaption = szT;
+ psH.nPages = 2;
+ psH.ppsp = (LPCPROPSHEETPAGEW) &psP;
+ psH.pfnCallback = (PFNPROPSHEETCALLBACK)__propertyCallback;
+ psH.nStartPage = 0;
+
+ return PropertySheetW(&psH);
+}
+
+static LRESULT CALLBACK __filtersDlgProc(HWND hDlg, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+
+ switch (uMsg) {
+ case WM_INITDIALOG:
+ apxCenterWindow(hDlg, _gui_store->hMainWnd);
+ if (_filterIname)
+ SetDlgItemTextW(hDlg, IDC_FINAME, _filterIname);
+ if (_filterIimage)
+ SetDlgItemTextW(hDlg, IDC_FISIMG, _filterIimage);
+ if (_filterXname)
+ SetDlgItemTextW(hDlg, IDC_FXNAME, _filterXname);
+ if (_filterXimage)
+ SetDlgItemTextW(hDlg, IDC_FXSIMG, _filterXimage);
+ return TRUE;
+ break;
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ {
+ apxFree(_filterIname);
+ _filterIname = apxGetDlgTextW(hPool, hDlg, IDC_FINAME);
+ apxFree(_filterXname);
+ _filterXname = apxGetDlgTextW(hPool, hDlg, IDC_FXNAME);
+ apxFree(_filterIimage);
+ _filterIimage = apxGetDlgTextW(hPool, hDlg, IDC_FISIMG);
+ apxFree(_filterXimage);
+ _filterXimage = apxGetDlgTextW(hPool, hDlg, IDC_FXSIMG);
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND,
+ MAKEWPARAM(IDMS_REFRESH, 0), 0);
+ }
+ case IDCANCEL:
+ EndDialog(hDlg, LOWORD(wParam));
+ return TRUE;
+ }
+ break;
+ }
+ return FALSE;
+}
+
+void EditServiceFilters(HWND hWnd)
+{
+
+ DialogBox(_gui_store->hInstance,
+ MAKEINTRESOURCE(IDD_FILTER),
+ hWnd,
+ (DLGPROC)__filtersDlgProc);
+
+}
+
+static LRESULT CALLBACK __selectColsDlgProc(HWND hDlg, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+
+ switch (uMsg) {
+ case WM_INITDIALOG:
+ apxCenterWindow(hDlg, _gui_store->hMainWnd);
+ CheckDlgButton(hDlg, IDC_CCOL1, lvItems[1].iWidth != 0);
+ CheckDlgButton(hDlg, IDC_CCOL2, lvItems[2].iWidth != 0);
+ CheckDlgButton(hDlg, IDC_CCOL3, lvItems[3].iWidth != 0);
+ CheckDlgButton(hDlg, IDC_CCOL4, lvItems[4].iWidth != 0);
+ CheckDlgButton(hDlg, IDC_CCOL5, lvItems[5].iWidth != 0);
+
+ return TRUE;
+ break;
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ if (IsDlgButtonChecked(hDlg, IDC_CCOL1) != BST_CHECKED)
+ lvItems[1].iWidth = 0;
+ else if (lvItems[1].iWidth == 0)
+ lvItems[1].iWidth = lvItems[1].iDefault;
+ if (IsDlgButtonChecked(hDlg, IDC_CCOL2) != BST_CHECKED)
+ lvItems[2].iWidth = 0;
+ else if (lvItems[2].iWidth == 0)
+ lvItems[2].iWidth = lvItems[2].iDefault;
+ if (IsDlgButtonChecked(hDlg, IDC_CCOL3) != BST_CHECKED)
+ lvItems[3].iWidth = 0;
+ else if (lvItems[3].iWidth == 0)
+ lvItems[3].iWidth = lvItems[3].iDefault;
+ if (IsDlgButtonChecked(hDlg, IDC_CCOL4) != BST_CHECKED)
+ lvItems[4].iWidth = 0;
+ else if (lvItems[4].iWidth == 0)
+ lvItems[4].iWidth = lvItems[4].iDefault;
+ if (IsDlgButtonChecked(hDlg, IDC_CCOL5) != BST_CHECKED)
+ lvItems[5].iWidth = 0;
+ else if (lvItems[5].iWidth == 0)
+ lvItems[5].iWidth = lvItems[5].iDefault;
+ CloseWindow(hWndList);
+ hWndList = CreateServiceList(_gui_store->hMainWnd);
+
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND,
+ MAKEWPARAM(IDMS_REFRESH, 0), 0);
+
+ case IDCANCEL:
+ EndDialog(hDlg, LOWORD(wParam));
+ return TRUE;
+ }
+ break;
+ }
+ return FALSE;
+}
+
+void SelectDisplayColumns(HWND hWnd)
+{
+
+ DialogBox(_gui_store->hInstance,
+ MAKEINTRESOURCE(IDD_SELCOL),
+ hWnd,
+ (DLGPROC)__selectColsDlgProc);
+
+}
+
+LRESULT CALLBACK MainWndProc(HWND hWnd, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ RECT rcP;
+ LPNMHDR lpNmHdr;
+
+ switch (uMsg) {
+ case WM_CREATE:
+
+ hWndToolbar = CreateToolbarEx(hWnd,
+ WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT,
+ IDC_TOOLBAR, NUMTOOLBUTTONS,
+ _gui_store->hInstance, IDB_TOOLBAR,
+ (LPCTBBUTTON)&tbButtons,
+ NUMTBBUTTONS, 16,16,16,16, sizeof(TBBUTTON));
+ hWndStatus = CreateStatusWindow(0x0800 /* SBT_TOOLTIPS */
+ | WS_CHILD | WS_VISIBLE,
+ TEXT(""), hWnd, IDC_STATBAR);
+
+ hWndList = CreateServiceList(hWnd);
+ RefreshServices(0);
+ CheckMenuRadioItem(GetMenu(hWnd), IDMV_UFAST, IDMV_UPAUSED,
+ _currentTimer, MF_BYCOMMAND);
+ RestoreRefreshTimer();
+ return FALSE;
+ break;
+ case WM_SETFOCUS:
+ SetFocus(hWndList);
+ return FALSE;
+ break;
+ case WM_SIZE:
+ MoveWindow(hWndToolbar, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
+ MoveWindow(hWndList, 0, _toolbarHeight, LOWORD(lParam),
+ HIWORD(lParam) - _toolbarHeight - _statbarHeight, TRUE);
+ MoveWindow(hWndStatus, 0, HIWORD(lParam) - _statbarHeight,
+ LOWORD(lParam), HIWORD(lParam), TRUE);
+ GetWindowRect(hWnd, &rcP);
+ _gui_store->stState.rcPosition.top = rcP.top;
+ _gui_store->stState.rcPosition.left = rcP.left;
+ _gui_store->stState.rcPosition.right = ABS(rcP.right - rcP.left);
+ _gui_store->stState.rcPosition.bottom = ABS(rcP.bottom - rcP.top);
+ if (wParam == SIZE_MAXIMIZED)
+ _gui_store->stState.dwShow = SW_SHOWMAXIMIZED;
+ else
+ _gui_store->stState.dwShow = SW_SHOW;
+
+ return FALSE;
+ break;
+ case WM_TIMER:
+ if (wParam == WM_TIMER_REFRESH) {
+ KillTimer(hWnd, WM_TIMER_REFRESH);
+ RefreshServices(1);
+ RestoreRefreshTimer();
+ }
+ break;
+ case WM_NOTIFY:
+ lpNmHdr = (NMHDR FAR *)lParam;
+ switch (lpNmHdr->code) {
+ case TTN_GETDISPINFO:
+ {
+ LPTOOLTIPTEXT lpttt;
+ lpttt = (LPTOOLTIPTEXT)lParam;
+ lpttt->hinst = _gui_store->hInstance;
+ /* Specify the resource identifier of the descriptive
+ * text for the given button.
+ */
+ lpttt->lpszText = MAKEINTRESOURCE(lpttt->hdr.idFrom);
+ }
+ break;
+ case LVN_COLUMNCLICK :
+ {
+ LPNMLISTVIEW pLvi = (LPNMLISTVIEW)lParam;
+ /* Find the real column */
+ if (pLvi->iSubItem >= 0) {
+ INT i, x = 0;
+ for (i = 0; i < NUMLVITEMS; i++) {
+ if (lvItems[i].iWidth && x < pLvi->iSubItem)
+ ++x;
+ else
+ break;
+ }
+ if (lvItems[x].bSortable) {
+ if (_sortColumn == x)
+ _sortOrder *= (-1);
+ else {
+ _sortColumn = x;
+ _sortOrder = 1;
+ }
+ ListView_SortItemsEx(hWndList, CompareFunc, NULL);
+ if ((lvHitItem = ListView_GetSelectionMark(hWndList)) >= 0) {
+ ListView_EnsureVisible(hWndList,lvHitItem, FALSE);
+ }
+ }
+ }
+ }
+ break;
+ /*
+ * Process other notifications here.
+ */
+ default:
+ break;
+ }
+ break;
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDMS_REFRESH:
+ KillTimer(hWnd, WM_TIMER_REFRESH);
+ RefreshServices(1);
+ RestoreRefreshTimer();
+ break;
+ case IDAM_TRY:
+ apxManageTryIconA(hWnd, NIM_ADD, NULL,
+ apxLoadResourceA(IDS_APPLICATION, 0),
+ NULL);
+
+ KillTimer(hWnd, WM_TIMER_REFRESH);
+ ShowWindow(hWnd, SW_HIDE);
+ break;
+ case IDAM_EXIT:
+ SendMessage(hWnd, WM_CLOSE, 0, 0);
+ break;
+ case IDMH_ABOUT:
+ apxAboutBox(hWnd);
+ break;
+ case IDMS_START:
+ apxProgressBox(hWnd, apxLoadResource(IDS_HSSTART, 0),
+ _currentEntry->lpConfig->lpDisplayName,
+ __startServiceCallback, NULL);
+ break;
+ case IDMS_STOP:
+ apxProgressBox(hWnd, apxLoadResource(IDS_HSSTOP, 0),
+ _currentEntry->lpConfig->lpDisplayName,
+ __stopServiceCallback, NULL);
+ break;
+ case IDMS_PAUSE:
+ apxProgressBox(hWnd, apxLoadResource(IDS_HSPAUSE, 0),
+ _currentEntry->lpConfig->lpDisplayName,
+ __pauseServiceCallback, NULL);
+ break;
+ case IDMS_RESTART:
+ apxProgressBox(hWnd, apxLoadResource(IDS_HSRESTART, 0),
+ _currentEntry->lpConfig->lpDisplayName,
+ __restartServiceCallback, NULL);
+ break;
+ case IDMS_PROPERTIES:
+ KillTimer(hWnd, WM_TIMER_REFRESH);
+ ShowServiceProperties(hWnd);
+ RestoreRefreshTimer();
+ break;
+ case IDMV_UFAST:
+ case IDMV_USLOW:
+ case IDMV_UPAUSED:
+ _currentTimer = LOWORD(wParam);
+ CheckMenuRadioItem(GetMenu(hWnd), IDMV_UFAST, IDMV_UPAUSED,
+ _currentTimer, MF_BYCOMMAND);
+ RestoreRefreshTimer();
+ break;
+ case IDAM_DELETE:
+ {
+ TCHAR szT[1024+128];
+#ifndef _UNICODE
+ CHAR dName[1024];
+ WideToAscii(_currentEntry->lpConfig->lpDisplayName, dName);
+#endif
+ if (!_currentEntry || !_currentEntry->lpConfig)
+ return FALSE;
+
+ wsprintf(szT, apxLoadResource(IDS_DELSERVICET, 0),
+#ifdef _UNICODE
+ _currentEntry->lpConfig->lpDisplayName);
+#else
+ dName);
+#endif
+ KillTimer(hWnd, WM_TIMER_REFRESH);
+ if (apxYesNoMessage(apxLoadResource(IDS_DELSERVICEC, 0),
+ szT, TRUE)) {
+ APXHANDLE hSrv;
+ if ((hSrv = apxCreateService(hPool, SC_MANAGER_CONNECT, FALSE))) {
+ if (apxServiceOpen(hSrv, _currentEntry->szServiceName,
+ SERVICE_ALL_ACCESS)) {
+ apxServiceDelete(hSrv);
+ RefreshServices(1);
+ }
+ apxCloseHandle(hSrv);
+ }
+ }
+ RestoreRefreshTimer();
+ }
+ break;
+ case IDMV_FILTER:
+ EditServiceFilters(hWnd);
+ break;
+ case IDMV_SELECTCOLUMNS:
+ SelectDisplayColumns(hWnd);
+ break;
+ case IDAM_SAVE:
+ if (_exportFilename) {
+ ExportListView(_exportFilename, _exportIndex);
+ return FALSE;
+ }
+ case IDAM_SAVEAS:
+ if (_exportFilename)
+ apxFree(_exportFilename);
+ _exportFilename = apxGetFileNameA(hWnd, EXPORT_TITLE,
+ EXPORT_EXTFILT,
+ ".csv", NULL, FALSE,
+ &_exportIndex);
+ if (_exportFilename)
+ ExportListView(_exportFilename, _exportIndex);
+ break;
+ case IDAM_NEW:
+ /* TODO: New service wizard */
+ MessageBox(hWnd, apxLoadResource(IDS_NOTIMPLEMENTED, 0),
+ apxLoadResource(IDS_APPLICATION, 1),
+ MB_OK | MB_ICONINFORMATION);
+ break;
+ default:
+ return DefWindowProc(hWnd, uMsg, wParam, lParam);
+ break;
+ }
+ break;
+ case WM_TRAYMESSAGE:
+ switch(lParam) {
+ case WM_LBUTTONDBLCLK:
+ ShowWindow(hWnd, SW_SHOW);
+ apxManageTryIconA(hWnd, NIM_DELETE, NULL, NULL, NULL);
+ RestoreRefreshTimer();
+ break;
+ }
+ break;
+ case WM_MOUSEWHEEL:
+ {
+ int nScroll;
+ if ((SHORT)HIWORD(wParam) < 0)
+ nScroll = _gui_store->nWhellScroll;
+ else
+ nScroll = _gui_store->nWhellScroll * (-1);
+ ListView_Scroll(hWndList, 0, nScroll * 16);
+ }
+ break;
+ case WM_QUIT:
+ OutputDebugString(TEXT("WM_QUIT"));
+ return DefWindowProc(hWnd, uMsg, wParam, lParam);
+ break;
+ case WM_DESTROY:
+ DestroyListView();
+ apxManageTryIconA(hWnd, NIM_DELETE, NULL, NULL, NULL);
+ OutputDebugString(TEXT("WM_DESTROY"));
+ PostQuitMessage(0);
+ return FALSE;
+ break;
+ default:
+ return DefWindowProc(hWnd, uMsg, wParam, lParam);
+ break;
+ }
+
+ return FALSE;
+}
+
+/* Browse service callback */
+BOOL ServiceCallback(APXHANDLE hObject, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ LPAPXSERVENTRY lpEnt = (LPAPXSERVENTRY)wParam;
+ LV_ITEM lvI;
+ LV_ITEM lvO;
+ INT row = 0x7FFFFFFF;
+ WCHAR szPid[16];
+ LPAPXSERVENTRY lpEntry = NULL;
+ int i;
+
+ AplZeroMemory(&lvI, sizeof(LV_ITEM));
+ lvI.mask = LVIF_IMAGE | LVIF_TEXT | LVIF_PARAM;
+ lvI.iItem = 0x7FFFFFFF;
+ switch (lpEnt->stServiceStatus.dwCurrentState) {
+ case SERVICE_RUNNING:
+ lvI.iImage = 0;
+ lvI.pszText = STAT_STARTED;
+ break;
+ case SERVICE_STOPPED:
+ lvI.iImage = 1;
+ lvI.pszText = STAT_NONE;
+ break;
+ case SERVICE_PAUSED:
+ lvI.iImage = 2;
+ lvI.pszText = STAT_PAUSED;
+ break;
+ default:
+ lvI.iImage = 3;
+ lvI.pszText = STAT_NONE;
+ break;
+ }
+ /* Search the items if this is a refresh callback */
+ if (uMsg == (WM_USER + 2)) {
+ for (i = 0; i < ListView_GetItemCount(hWndList); i++) {
+ lvO.iItem = i;
+ lvO.mask = LVIF_PARAM;
+ ListView_GetItem(hWndList, &lvO);
+ lpEntry = (LPAPXSERVENTRY)lvO.lParam;
+ if (!lstrcmpW(lpEntry->szServiceName, lpEnt->szServiceName)) {
+ row = lvO.iItem;
+ /* release the old config */
+ apxFree(lpEntry->lpConfig);
+ break;
+ }
+ else
+ lpEntry = NULL;
+ }
+ }
+ if (row == 0x7FFFFFFF || !lpEntry)
+ lpEntry = (LPAPXSERVENTRY) apxPoolAlloc(hPool, sizeof(APXSERVENTRY));
+ AplCopyMemory(lpEntry, lpEnt, sizeof(APXSERVENTRY));
+ lvI.lParam = (LPARAM)lpEntry;
+ if (row == 0x7FFFFFFF)
+ row = ListView_InsertItem(hWndList, &lvI);
+ else {
+ lvI.iItem = row;
+ ListView_SetItem(hWndList, &lvI);
+ }
+ if (row == -1)
+ return TRUE;
+
+ ListView_SetItemTextW(hWndList, row, 1, lpEnt->lpConfig->lpDisplayName);
+ i = 2;
+ if (lvItems[2].iWidth > 0) {
+ if (lpEnt->szServiceDescription)
+ ListView_SetItemTextW(hWndList, row, i, lpEnt->szServiceDescription);
+ i++;
+ }
+ if (lvItems[3].iWidth > 0) {
+ if (lpEnt->dwStart == SERVICE_DEMAND_START) {
+ ListView_SetItemTextW(hWndList, row, i, START_MANUAL);
+ }
+ else if (lpEnt->dwStart == SERVICE_AUTO_START) {
+ ListView_SetItemTextW(hWndList, row, i, START_AUTO);
+ }
+ else if (lpEnt->dwStart == SERVICE_DISABLED) {
+ ListView_SetItemTextW(hWndList, row, i, START_DISABLED);
+ }
+ else if (lpEnt->dwStart == SERVICE_BOOT_START) {
+ ListView_SetItemTextW(hWndList, row, i, START_BOOT);
+ }
+ else if (lpEnt->dwStart == SERVICE_SYSTEM_START) {
+ ListView_SetItemTextW(hWndList, row, i, START_SYSTEM);
+ }
+ i++;
+ }
+ if (lvItems[4].iWidth > 0) {
+ ListView_SetItemTextW(hWndList, row, i++, *lpEnt->szObjectName ?
+ lpEnt->szObjectName : STAT_SYSTEM);
+ }
+ if (lvItems[5].iWidth > 0) {
+ if (lpEnt->stStatusProcess.dwProcessId) {
+ wsprintfW(szPid, L"%d", lpEnt->stStatusProcess.dwProcessId);
+ ListView_SetItemTextW(hWndList, row, i, szPid);
+ }
+ i++;
+ }
+ _currentLitem++;
+ return TRUE;
+}
+
+static BOOL loadConfiguration()
+{
+ DWORD dwSize, i;
+ /* Load the GUI State first */
+ if (IS_INVALID_HANDLE(hRegistry))
+ return FALSE;
+
+ dwSize = sizeof(APXGUISTATE);
+ if (apxRegistryGetBinaryA(hRegistry, APXREG_USER, DISPLAY_KEY, DISPLAY_STATE,
+ (LPBYTE)(&(_gui_store->stState)), &dwSize)) {
+ _gui_store->stStartupInfo.wShowWindow = (WORD)_gui_store->stState.dwShow;
+ if (_gui_store->stStartupInfo.wShowWindow == SW_MAXIMIZE) {
+ _gui_store->stState.rcPosition.top = CW_USEDEFAULT;
+ _gui_store->stState.rcPosition.left = CW_USEDEFAULT;
+ _gui_store->stState.rcPosition.bottom = CW_USEDEFAULT;
+ _gui_store->stState.rcPosition.right = CW_USEDEFAULT;
+ }
+ if (_gui_store->stState.nColumnWidth[0] > 50)
+ lvItems[0].iWidth = _gui_store->stState.nColumnWidth[0];
+ if (_gui_store->stState.nColumnWidth[1] > 50)
+ lvItems[1].iWidth = _gui_store->stState.nColumnWidth[1];
+
+ for (i = 2; i < NUMLVITEMS; i++) {
+ lvItems[i].iWidth = _gui_store->stState.nColumnWidth[i];
+ }
+ _sortColumn = _gui_store->stState.nUser[0];
+ _sortOrder = _gui_store->stState.nUser[1];
+ _currentTimer = _gui_store->stState.nUser[2];
+ }
+ _filterIname = apxRegistryGetStringW(hRegistry, APXREG_USER,
+ SFILT_KEY, SFILT_INAME);
+ _filterXname = apxRegistryGetStringW(hRegistry, APXREG_USER,
+ SFILT_KEY, SFILT_XNAME);
+ _filterIimage = apxRegistryGetStringW(hRegistry, APXREG_USER,
+ SFILT_KEY, SFILT_ISIMG);
+ _filterIimage = apxRegistryGetStringW(hRegistry, APXREG_USER,
+ SFILT_KEY, SFILT_XSIMG);
+ /* try to load system defalut filters */
+ if (!_filterIname)
+ _filterIname = apxRegistryGetStringW(hRegistry, APXREG_SOFTWARE,
+ SFILT_KEY, SFILT_INAME);
+ if (!_filterXname)
+ _filterXname = apxRegistryGetStringW(hRegistry, APXREG_SOFTWARE,
+ SFILT_KEY, SFILT_XNAME);
+ if (!_filterIimage)
+ _filterIimage = apxRegistryGetStringW(hRegistry, APXREG_SOFTWARE,
+ SFILT_KEY, SFILT_ISIMG);
+ if (!_filterXimage)
+ _filterXimage = apxRegistryGetStringW(hRegistry, APXREG_SOFTWARE,
+ SFILT_KEY, SFILT_XSIMG);
+
+ return TRUE;
+}
+
+#define REGSET_FILTER(str, key) \
+ APXMACRO_BEGIN \
+ if (str && lstrlenW(str)) \
+ apxRegistrySetStrW(hRegistry, APXREG_USER, SFILT_KEY, key, str); \
+ else \
+ apxRegistryDeleteW(hRegistry, APXREG_USER, SFILT_KEY, key); \
+ APXMACRO_END
+
+static BOOL saveConfiguration()
+{
+ DWORD i;
+ if (IS_INVALID_HANDLE(hRegistry))
+ return FALSE;
+ for (i = 0; i < NUMLVITEMS; i++) {
+ _gui_store->stState.nColumnWidth[i] = lvItems[i].iWidth;
+ }
+ _gui_store->stState.nUser[0] = _sortColumn;
+ _gui_store->stState.nUser[1] = _sortOrder;
+ _gui_store->stState.nUser[2] = _currentTimer;
+
+ apxRegistrySetBinaryA(hRegistry, APXREG_USER, DISPLAY_KEY, DISPLAY_STATE,
+ (LPBYTE)(&(_gui_store->stState)), sizeof(APXGUISTATE));
+ REGSET_FILTER(_filterIname, SFILT_INAME);
+ REGSET_FILTER(_filterXname, SFILT_XNAME);
+ REGSET_FILTER(_filterIimage, SFILT_ISIMG);
+ REGSET_FILTER(_filterXimage, SFILT_XSIMG);
+
+ return TRUE;
+}
+
+/* Main program entry
+ * Since we are inependant from CRT
+ * the arguments are not used
+ */
+#ifdef _NO_CRTLIBRARY
+int xMain(void)
+#else
+int WINAPI WinMain(HINSTANCE hInstance,
+ HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine,
+ int nCmdShow)
+#endif
+{
+ MSG msg;
+
+ apxHandleManagerInitialize();
+ hPool = apxPoolCreate(NULL, 0);
+ hService = apxCreateService(hPool, GENERIC_ALL, TRUE);
+
+ _gui_store = apxGuiInitialize(MainWndProc, APSVCMGR_CLASS);
+
+ if (!_gui_store) {
+ goto cleanup;
+ }
+ hRegistry = apxCreateRegistry(hPool, KEY_ALL_ACCESS, NULL,
+ apxLoadResource(IDS_APPLICATION, 0),
+ APXREG_USER);
+ loadConfiguration();
+ _gui_store->hMainWnd = CreateWindow(_gui_store->szWndClass,
+ apxLoadResource(IDS_APPLICATION, 0),
+ WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
+ _gui_store->stState.rcPosition.left,
+ _gui_store->stState.rcPosition.top,
+ _gui_store->stState.rcPosition.right,
+ _gui_store->stState.rcPosition.bottom,
+ NULL, NULL,
+ _gui_store->hInstance,
+ NULL);
+ if (!_gui_store->hMainWnd) {
+ goto cleanup;
+ }
+
+ ShowWindow(_gui_store->hMainWnd, _gui_store->stStartupInfo.wShowWindow);
+ UpdateWindow(_gui_store->hMainWnd);
+ SetMenuDefaultItem(GetMenu(_gui_store->hMainWnd), IDMS_PROPERTIES, FALSE);
+
+ while (GetMessage(&msg, NULL, 0, 0)) {
+ if(!TranslateAccelerator(_gui_store->hMainWnd,
+ _gui_store->hAccel, &msg)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+ saveConfiguration();
+
+cleanup:
+ apxFree(_filterIname);
+ apxFree(_filterXname);
+ apxFree(_filterIimage);
+ apxFree(_filterXimage);
+ apxFree(_exportFilename);
+ apxCloseHandle(hService);
+ apxHandleManagerDestroy();
+ ExitProcess(0);
+ return 0;
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.dsp
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.dsp 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.dsp 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,173 @@
+# Microsoft Developer Studio Project File - Name="apsvcmgr" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=apsvcmgr - Win32 Unicode 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 "apsvcmgr.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 "apsvcmgr.mak" CFG="apsvcmgr - Win32 Unicode Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "apsvcmgr - Win32 Release" (based on "Win32 (x86) Application")
+!MESSAGE "apsvcmgr - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE "apsvcmgr - Win32 Unicode Release" (based on "Win32 (x86) Application")
+!MESSAGE "apsvcmgr - Win32 Unicode Debug" (based on "Win32 (x86) Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "apsvcmgr - 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 "_WINDOWS" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x41a /d "NDEBUG"
+# ADD RSC /l 0x41a /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 /nologo /subsystem:windows /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 shlwapi.lib comctl32.lib netapi32.lib /nologo /subsystem:windows /machine:I386
+
+!ELSEIF "$(CFG)" == "apsvcmgr - 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 "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x41a /d "_DEBUG"
+# ADD RSC /l 0x41a /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 /nologo /subsystem:windows /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 shlwapi.lib comctl32.lib netapi32.lib /nologo /subsystem:windows /debug /machine:I386 /out:"Debug/apsvcmgrd.exe" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "apsvcmgr - Win32 Unicode Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Unicode Release"
+# PROP BASE Intermediate_Dir "Unicode Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Unicode Release"
+# PROP Intermediate_Dir "Unicode Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x41a /d "NDEBUG"
+# ADD RSC /l 0x41a /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 shlwapi.lib comctl32.lib netapi32.lib /nologo /subsystem:windows /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 shlwapi.lib comctl32.lib netapi32.lib /nologo /subsystem:windows /machine:I386 /out:"Unicode Release/apsvcmgru.exe"
+
+!ELSEIF "$(CFG)" == "apsvcmgr - Win32 Unicode Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Unicode Debug"
+# PROP BASE Intermediate_Dir "Unicode Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Unicode Debug"
+# PROP Intermediate_Dir "Unicode Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x41a /d "_DEBUG"
+# ADD RSC /l 0x41a /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 shlwapi.lib comctl32.lib netapi32.lib /nologo /subsystem:windows /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 shlwapi.lib comctl32.lib netapi32.lib /nologo /subsystem:windows /debug /machine:I386 /out:"Unicode Debug/apsvcmgrdu.exe" /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "apsvcmgr - Win32 Release"
+# Name "apsvcmgr - Win32 Debug"
+# Name "apsvcmgr - Win32 Unicode Release"
+# Name "apsvcmgr - Win32 Unicode Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\apsvcmgr.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\apsvcmgr.h
+# End Source File
+# 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=.\apsvcmgr.rc
+# ADD BASE RSC /l 0x41a
+# ADD RSC /l 0x41a /i "..\..\include" /d "USE_MAINFEST"
+# End Source File
+# End Group
+# End Target
+# End Project
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,117 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#undef PRG_VERSION
+#define PRG_VERSION "2.0.1.0"
+
+#define NUMTOOLBUTTONS 17
+#define IDC_TOOLBAR 2000
+#define IDB_TOOLBAR 2001
+#define IDB_SSTATUS 2002
+#define IDC_LISTVIEW 2003
+
+#define IDM_ARROWUP 2004
+#define IDM_ARROWDOWN 2005
+#define IDS_HSSTART 2006
+#define IDS_HSSTOP 2007
+#define IDS_HSPAUSE 2008
+#define IDS_HSRESTART 2009
+#define IDM_POPUPMENU 2010
+
+#define IDAM_TRY 2100
+#define IDAM_SAVE 2101
+#define IDAM_SAVEAS 2102
+#define IDAM_EXIT 2103
+#define IDAM_NEW 2104
+#define IDAM_DELETE 2105
+
+#define IDMS_START 2110
+#define IDMS_STOP 2111
+#define IDMS_PAUSE 2112
+#define IDMS_RESTART 2113
+#define IDMS_REFRESH 2114
+#define IDMS_PROPERTIES 2115
+#define IDMS_HELP 2116
+
+#define IDMV_UFAST 2120
+#define IDMV_USLOW 2121
+#define IDMV_UPAUSED 2122
+#define IDMV_SELECTCOLUMNS 2123
+#define IDMV_FILTER 2124
+
+#define IDMH_HELP 2130
+#define IDMH_ABOUT 2131
+
+/* Property pages */
+
+#define IDD_PROPPAGE_SGENERAL 2600
+#define IDC_PPSGNAME 2601
+#define IDC_PPSGDISP 2602
+#define IDC_PPSGDESC 2603
+#define IDC_PPSGDEXE 2604
+#define IDC_PPSGCMBST 2605
+#define IDC_PPSGSTATUS 2606
+#define IDC_PPSGSTART 2607
+#define IDC_PPSGSTOP 2608
+#define IDC_PPSGPAUSE 2609
+#define IDC_PPSGRESTART 2610
+
+#define IDD_PROPPAGE_LOGON 2620
+#define IDC_PPSLLS 2621
+#define IDC_PPSLID 2622
+#define IDC_PPSLUA 2623
+#define IDC_PPSLUSER 2624
+#define IDC_PPSLBROWSE 2625
+#define IDC_PPSLPASS 2626
+#define IDC_PPSLCPASS 2627
+#define IDL_PPSLPASS 2628
+#define IDL_PPSLCPASS 2629
+
+
+#define IDD_FILTER 2640
+#define IDC_FINAME 2641
+#define IDC_FXNAME 2642
+#define IDC_FISIMG 2643
+#define IDC_FXSIMG 2644
+
+#define IDD_SELCOL 2650
+#define IDC_CCOL1 2651
+#define IDC_CCOL2 2652
+#define IDC_CCOL3 2653
+#define IDC_CCOL4 2654
+#define IDC_CCOL5 2655
+
+
+#if 0
+#define IDAMS_NEW 3000
+#define IDAMS_DELETE 3001
+#define IDAMS_SAVE 3002
+#define IDMVS_REFRESH 3003
+#define IDMSS_PROPERTIES 3004
+#define IDMSS_START 3005
+#define IDMSS_STOP 3006
+#define IDMSS_PAUSE 3007
+#define IDMSS_RESTART 3008
+#define IDMHS_HELP 3009
+#define IDMVS_FILTER 3010
+#endif
+
+#define IDS_DELSERVICEC 3100
+#define IDS_DELSERVICET 3101
+#define IDS_VALIDPASS 3102
+#define IDS_PPGENERAL 3103
+#define IDS_PPLOGON 3104
+#define IDS_NOTIMPLEMENTED 3105
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.manifest
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.manifest 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.manifest 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+<assemblyIdentity version="2.0.1.0" processorArchitecture="X86" name="Apache.Procrun.Apsvcmgr" type="win32" />
+<description>Service Manager.</description>
+<dependency>
+<dependentAssembly>
+<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="X86" publicKeyToken="6595b64144ccf1df" language="*" />
+</dependentAssembly>
+</dependency>
+</assembly>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.rc
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.rc 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.rc 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,312 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apxwin.h"
+#include "apsvcmgr.h"
+
+#define RSTR_ASM "Apache Service Manager"
+#define RSTR_SCMATS "Service Manager is attempting to "
+
+IDI_MAINICON ICON "../../resources/apsvcmgr.ico"
+IDB_TOOLBAR BITMAP DISCARDABLE "../../resources/toolbar.bmp"
+IDB_SSTATUS BITMAP DISCARDABLE "../../resources/sstatus.bmp"
+IDB_SUSERS BITMAP DISCARDABLE "../../resources/susers.bmp"
+IDR_LICENSE RTF "../../resources/license.rtf"
+BMP_JAKARTA BITMAP "../../resources/jakarta.bmp"
+
+#ifdef USE_MAINFEST
+CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "apsvcmgr.manifest"
+#endif
+
+IDC_APPLICATION MENU
+BEGIN
+ POPUP "&Action"
+ BEGIN
+ MENUITEM "&Minimize to try", IDAM_TRY
+ MENUITEM SEPARATOR
+ MENUITEM "&New", IDAM_NEW
+ MENUITEM "&Delete", IDAM_DELETE, GRAYED
+ MENUITEM SEPARATOR
+ MENUITEM "&Save CRTL+S", IDAM_SAVE
+ MENUITEM "Save &As... CTRL+A", IDAM_SAVEAS
+ MENUITEM SEPARATOR
+ MENUITEM "E&xit", IDAM_EXIT
+ END
+ POPUP "&Service"
+ BEGIN
+ MENUITEM "P&ropeties ...", IDMS_PROPERTIES, GRAYED
+ MENUITEM SEPARATOR
+ MENUITEM "&Start", IDMS_START, GRAYED
+ MENUITEM "S&top", IDMS_STOP, GRAYED
+ MENUITEM "&Pause", IDMS_PAUSE, GRAYED
+ MENUITEM "Res&tart", IDMS_RESTART, GRAYED
+ MENUITEM SEPARATOR
+ MENUITEM "Re&fresh", IDMS_REFRESH
+ MENUITEM SEPARATOR
+ MENUITEM "&Help", IDMS_HELP
+ END
+ POPUP "&View"
+ BEGIN
+ MENUITEM "Re&fresh Now F5", IDMS_REFRESH
+ POPUP "Update speed"
+ BEGIN
+ MENUITEM "10 Seconds", IDMV_UFAST
+ MENUITEM "1 Minute", IDMV_USLOW
+ MENUITEM "Paused", IDMV_UPAUSED
+ END
+ MENUITEM SEPARATOR
+ MENUITEM "Select Columns ...", IDMV_SELECTCOLUMNS
+ MENUITEM "Filter Services ...", IDMV_FILTER
+ END
+ POPUP "&Help"
+ BEGIN
+ MENUITEM "&Help ...", IDMH_HELP
+ MENUITEM "&About", IDMH_ABOUT
+ END
+END
+
+IDM_POPUPMENU MENU DISCARDABLE
+BEGIN
+ POPUP "Popup Menu"
+ BEGIN
+ MENUITEM "Propeties ...", IDMS_PROPERTIES, GRAYED
+ MENUITEM SEPARATOR
+ MENUITEM "Start", IDMS_START, GRAYED
+ MENUITEM "Stop", IDMS_STOP, GRAYED
+ MENUITEM "Pause", IDMS_PAUSE, GRAYED
+ MENUITEM "Restart", IDMS_RESTART, GRAYED
+ MENUITEM SEPARATOR
+ MENUITEM "Refresh", IDMS_REFRESH
+ MENUITEM SEPARATOR
+ MENUITEM "Help", IDMS_HELP, HELP
+ END
+END
+
+IDD_ABOUTBOX DIALOGEX 0, 0, 337, 187
+STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "Apache Service Manager"
+FONT 8, "Microsoft Sans Serif", 400, 0, 0x0
+BEGIN
+ DEFPUSHBUTTON "&OK",IDOK,285,150,50,14
+ CONTROL "",IDC_LICENSE,"RichEdit20A",ES_MULTILINE |
+ ES_READONLY | WS_BORDER | WS_VSCROLL,0,31,335,115
+ CONTROL "BMP_JAKARTA",IDC_STATIC,"Static",SS_BITMAP,0,0,337,30
+ LTEXT " ",IDC_ABOUTAPP,2,150,270,12
+ LTEXT "Copyright © 2000-2003 The Apache Software Foundation.",IDC_STATIC,2,160,270,12
+ LTEXT "http://www.jakarta.org",IDC_STATIC,2,170,270,12
+ PUSHBUTTON "&System Info",IAB_SYSINF,285,170,50,14
+END
+
+IDD_PROGRESS DIALOGEX 0, 0, 322, 92
+STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP |
+ WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_TOPMOST
+CAPTION "Apache Service Manager"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "Cl&ose",IDOK,261,73,50,14
+ PUSHBUTTON "&Cancel",IDCANCEL,202,73,50,14
+ LTEXT " ",
+ IDDP_HEAD,40,4,250,8
+ LTEXT " ",IDDP_TEXT,40,15,250,44
+ CONTROL "",IDDP_PROGRESS,"msctls_progress32",WS_BORDER,10,50,302,
+ 14
+ ICON IDI_MAINICON,IDC_STATIC,10,4,20,20,0,WS_EX_TRANSPARENT
+END
+
+IDD_PROPPAGE_SGENERAL DIALOGEX 0, 0, 260, 186
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ LTEXT "Service Name: ",IDC_STATIC,10,8,52,8
+ LTEXT " ",IDC_PPSGNAME,70,8,240,8
+ LTEXT "Display &name: ",IDC_STATIC,10,23,50,8
+ EDITTEXT IDC_PPSGDISP,70,22,180,14,ES_AUTOHSCROLL
+ LTEXT "&Description: ",IDC_STATIC,10,41,43,8
+ EDITTEXT IDC_PPSGDESC,70,40,180,14,ES_AUTOHSCROLL
+ LTEXT "Pat&h to executable:",IDC_STATIC,10,63,66,8
+ EDITTEXT IDC_PPSGDEXE,10,75,240,14,ES_AUTOHSCROLL | WS_DISABLED
+ LTEXT "Startup typ&e:",IDC_STATIC,10,94,46,8
+ COMBOBOX IDC_PPSGCMBST,70,93,180,80,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+ CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,10,128,240,1
+ LTEXT "Service Status:",IDC_STATIC,10,138,52,8
+ LTEXT " ",IDC_PPSGSTATUS,70,138,240,8
+ PUSHBUTTON "&Start",IDC_PPSGSTART,10,160,55,14,WS_DISABLED
+ PUSHBUTTON "S&top",IDC_PPSGSTOP,71,160,55,14,WS_DISABLED
+ PUSHBUTTON "&Pause",IDC_PPSGPAUSE,132,160,55,14,WS_DISABLED
+ PUSHBUTTON "&Restart",IDC_PPSGRESTART,193,160,55,14,WS_DISABLED
+END
+
+IDD_PROPPAGE_LOGON DIALOGEX 0, 0, 260, 186
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ LTEXT "Log on as:",IDC_STATIC,10,8,51,8
+ CONTROL "&Local System account",IDC_PPSLLS,"Button",
+ BS_AUTORADIOBUTTON,10,23,85,10
+ CONTROL "Allo&w service to interact with desktop",IDC_PPSLID,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,21,37,135,10
+ CONTROL "&This account:",IDC_PPSLUA,"Button",BS_AUTORADIOBUTTON,
+ 10,59,61,10
+ EDITTEXT IDC_PPSLUSER,86,58,114,14,ES_AUTOHSCROLL
+ PUSHBUTTON "&Browse...",IDC_PPSLBROWSE,205,58,50,14
+ LTEXT "&Password:",IDL_PPSLPASS,21,76,36,8
+ EDITTEXT IDC_PPSLPASS,86,75,114,14,ES_PASSWORD | ES_AUTOHSCROLL
+ LTEXT "&Confirm Password:",IDL_PPSLCPASS,20,93,63,8
+ EDITTEXT IDC_PPSLCPASS,86,92,114,14,ES_PASSWORD | ES_AUTOHSCROLL
+END
+
+IDD_FILTER DIALOGEX 0, 0, 296, 199
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_CONTEXTHELP
+CAPTION "Service display filters"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LTEXT "Enter multiple filter match strings separated by the ';' character. '*' is a wildcard.",
+ IDC_STATIC,10,7,278,8
+ DEFPUSHBUTTON "&OK",IDOK,232,175,50,14
+ PUSHBUTTON "&Cancel",IDCANCEL,176,175,50,14
+ GROUPBOX " Service name filters ",IDC_STATIC,10,28,275,62
+ LTEXT "Include:",IDC_STATIC,18,48,27,8
+ EDITTEXT IDC_FINAME,63,46,211,14,ES_AUTOHSCROLL
+ LTEXT "Exclude:",IDC_STATIC,18,66,28,8
+ EDITTEXT IDC_FXNAME,63,64,211,14,ES_AUTOHSCROLL
+ GROUPBOX "Service image path filters",IDC_STATIC,10,102,275,62
+ LTEXT "Include:",IDC_STATIC,17,120,27,8
+ EDITTEXT IDC_FISIMG,63,118,211,14,ES_AUTOHSCROLL
+ LTEXT "Exclude:",IDC_STATIC,17,138,28,8
+ EDITTEXT IDC_FXSIMG,63,136,211,14,ES_AUTOHSCROLL
+END
+
+IDD_SELCOL DIALOGEX 0, 0, 220, 130
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+CAPTION "Select Columns"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,156,105,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,96,105,50,14
+ LTEXT "Select the columns that will apear on the Service view of the Service Manager",
+ IDC_STATIC,16,2,194,16
+ CONTROL "Name",IDC_CCOL1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
+ 16,26,83,10
+ CONTROL "Description",IDC_CCOL2,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,16,39,83,10
+ CONTROL "Startup Type",IDC_CCOL3,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,16,52,83,10
+ CONTROL "Log On As",IDC_CCOL4,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,16,65,83,10
+ CONTROL "Process Id",IDC_CCOL5,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,16,78,83,10
+END
+
+IDD_SELUSER DIALOGEX 0, 0, 410, 201
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU |
+ WS_THICKFRAME
+EXSTYLE WS_EX_CONTEXTHELP
+CAPTION "Select User"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LTEXT "Name:",IDSU_SELNAME,10,183,22,8
+ EDITTEXT IDSU_SELECTED,48,200,213,14,ES_AUTOHSCROLL
+ DEFPUSHBUTTON "OK",IDOK,292,180,50,14,WS_DISABLED
+ PUSHBUTTON "Cancel",IDCANCEL,348,180,50,14
+ LTEXT "Look In:",IDC_STATIC,10,9,27,8
+ CONTROL "",IDSU_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL |
+ LVS_SORTASCENDING | LVS_SHAREIMAGELISTS | LVS_ALIGNLEFT | WS_BORDER |
+ WS_TABSTOP,0,26,410,149,WS_EX_CLIENTEDGE
+ CONTROL "",IDSU_COMBO,"ComboBoxEx32",CBS_DROPDOWNLIST |
+ WS_VSCROLL | WS_TABSTOP,47,6,260,80
+END
+
+IDC_APPLICATION ACCELERATORS
+BEGIN
+ "/", IDMH_ABOUT, ASCII, ALT, NOINVERT
+ "?", IDMH_ABOUT, ASCII, ALT, NOINVERT
+ VK_F1, IDMH_HELP, VIRTKEY, NOINVERT
+ "S", IDAM_SAVE, VIRTKEY, CONTROL, NOINVERT
+ "A", IDAM_SAVEAS, VIRTKEY, CONTROL, NOINVERT
+ "F", IDMV_FILTER, VIRTKEY, CONTROL, NOINVERT
+ VK_F5, IDMS_REFRESH, VIRTKEY, NOINVERT
+END
+
+
+STRINGTABLE
+BEGIN
+ IDS_APPLICATION RSTR_ASM
+ IDS_APPVERSION "Version 1.0.0"
+ IDS_APPFULLNAME RSTR_ASM " Version " PRG_VERSION
+ IDS_APPCOPYRIGHT "Copyright © 2000-2003 The Apache Software Foundation"
+ IDS_APPDESCRIPTION "Apache NT Service Management Tool"
+ IDS_HSSTART RSTR_SCMATS "start the following service ..."
+ IDS_HSSTOP RSTR_SCMATS "stop the following service ..."
+ IDS_HSRESTART RSTR_SCMATS "to restart the following service ..."
+ IDS_HSPAUSE RSTR_SCMATS "to pause the following service ..."
+
+ IDAM_NEW "New Service"
+ IDAM_DELETE "Delete Service"
+ IDAM_SAVE "Export List"
+ IDMS_REFRESH "Refresh"
+ IDMV_FILTER "Filter Services"
+ IDMS_PROPERTIES "Properties"
+ IDMS_START "Start Service"
+ IDMS_STOP "Stop Service"
+ IDMS_PAUSE "Pause Service"
+ IDMS_RESTART "Restart Service"
+ IDMH_HELP "Help"
+
+ IDS_DELSERVICEC "Confirm Delete Service"
+ IDS_DELSERVICET "You cannot undo the effects of this dialog box!\r\n\r\nYou are about to delete '%s' service.\r\nDeleting services may cause your system unusable.\r\n\r\nDo you want to proceed?"
+ IDS_VALIDPASS "Please enter a valid password"
+ IDS_PPGENERAL "General"
+ IDS_PPLOGON "Log On"
+ IDS_NOTIMPLEMENTED "Sorry, but this feature is not implemented yet"
+END
+
+
+1 VERSIONINFO
+ FILEVERSION 2,0,1,0
+ PRODUCTVERSION 2,0,1,0
+ FILEFLAGSMASK 0x3fL
+#if defined(_DEBUG)
+ FILEFLAGS 0x03L
+#else
+ FILEFLAGS 0x02L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "Comments", "NT Service Management Tool\0"
+ VALUE "CompanyName", "Apache Software Foundation\0"
+ VALUE "FileDescription", RSTR_ASM "\0"
+ VALUE "FileVersion", PRG_VERSION
+ VALUE "InternalName", RSTR_ASM "\0"
+ VALUE "LegalCopyright", "Copyright © 2000-2006 The Apache Software Foundation.\0"
+ VALUE "OriginalFilename", "apsvcmgr.exe\0"
+ VALUE "ProductName", RSTR_ASM "\0"
+ VALUE "ProductVersion", PRG_VERSION
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.vcproj
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.vcproj 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/apsvcmgr/apsvcmgr.vcproj 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,404 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8,00"
+ Name="apsvcmgr"
+ ProjectGUID="{E2B48545-30FA-4D6F-B32C-B7B29B35FE45}"
+ RootNamespace="apsvcmgr"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ <Platform
+ Name="x64"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="shlwapi.lib comctl32.lib netapi32.lib"
+ LinkIncremental="2"
+ AdditionalManifestDependencies="type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='X86' publicKeyToken='6595b64144ccf1df' language='*'"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="shlwapi.lib comctl32.lib netapi32.lib"
+ LinkIncremental="1"
+ AdditionalManifestDependencies="type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='X86' publicKeyToken='6595b64144ccf1df' language='*'"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|x64"
+ OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="shlwapi.lib comctl32.lib netapi32.lib"
+ LinkIncremental="2"
+ AdditionalManifestDependencies=""
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ TargetMachine="17"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|x64"
+ OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="shlwapi.lib comctl32.lib netapi32.lib"
+ LinkIncremental="1"
+ AdditionalManifestDependencies=""
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="17"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\apsvcmgr.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\apsvcmgr.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ <File
+ RelativePath=".\apsvcmgr.rc"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="..\..\include"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="..\..\include"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="..\..\include"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="..\..\include"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/jar2exe/jar2exe.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/jar2exe/jar2exe.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/jar2exe/jar2exe.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,542 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* ====================================================================
+ * jar2exe -- convert .jar file to WIN executable.
+ * Contributed by Mladen Turk <mturk at apache.org>
+ * 05 Aug 2003
+ * ====================================================================
+ */
+
+/* Force the JNI vprintf functions */
+#define _DEBUG_JNI 1
+#include "apxwin.h"
+#include <imagehlp.h>
+#include "jar2exe.h"
+#pragma comment( lib, "imagehlp.lib" )
+
+
+#ifdef _DEBUG
+#define LOG_MARK _verbose, __FILE__, __LINE__
+#else
+#define LOG_MARK _verbose, NULL, 0
+#endif
+
+#define EXE_SUFFIX ".EXE"
+#define EXE_SUFFIX_SZ (sizeof(".EXE") - 1)
+#define JAR_LINT "jar2exe Copyright (c) 2000-2003 The Apache Software Foundation."
+
+#define EMBED_SIZE 2048
+#define EMBED_MAX 2044
+
+typedef struct {
+ char s_signature[16];
+ char s_class[EMBED_SIZE];
+ UINT32 s_flags[4];
+ char e_signature[16];
+} st_config;
+
+static char _progname[MAX_PATH+1];
+static char _progpath[MAX_PATH+1];
+static HANDLE _hstub = NULL;
+static BOOL _verbose = FALSE;
+static BOOL _makegui = FALSE;
+static const char *_lint = JAR_LINT;
+static st_config *_config = NULL;
+
+/* zip file header magic */
+static BYTE zip_fh_magic[4] = { '\120', '\113', '\001', '\002'};
+/* end of central directory signature */
+static BYTE zip_ec_magic[4] = { '\120', '\113', '\005', '\006'};
+/* lower case configuration block signature
+ * to enable binary searching
+ */
+static BYTE c_signature[] = {
+ 's', 't', 'a', 'r', 't', 'u', 's', 'e', 'r', 's', 'b', 'l', 'o', 'c', 'k', '\0'
+};
+
+/* space in exe stub for user configuration */
+static BYTE conf_in_exe[EMBED_SIZE + 48] = {
+ 'S', 'T', 'A', 'R', 'T', 'U', 'S', 'E', 'R', 'S', 'B', 'L', 'O', 'C', 'K', '\0',
+
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+
+ '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
+ 'E', 'N', 'D', 'O', 'F', 'U', 'S', 'E', 'R', 'S', 'B', 'L', 'O', 'C', 'K', '\0',
+};
+
+static LPCSTR _usage = JAR_LINT "\n" \
+ "Usage:\n" \
+ " jar2exe [options] <output.exe> <class> <embed.jar> [params ...]\n" \
+ " options:\n" \
+ " -d\t\tdisplay error messages\n" \
+ " -g\t\tmake non-console application\n" \
+ " -m<nn>\t\tInitial memory pool (nn MB)\n" \
+ " -x<nn>\t\tMaximum memory size (nn MB)\n" \
+ " -s<nn>\t\tThread stack size (nn Bytes)\n" \
+ " output.exe\toutput executable\n" \
+ " class\t\tmain class name\n" \
+ " embed.jar\tjar file to embed in stub\n" \
+ " params\t\tJava VM parameters\n";
+
+/* Fix the ZIP central directory
+ * Find the central dir position and
+ * add the stub length offset to each enty.
+ */
+static int fixjar(size_t slen)
+{
+ HANDLE hmap;
+ BYTE *map, *cd, *hd, *mp;
+ size_t len, off, cdir, cpos = 0;
+ int i, nent, rc = 0;
+
+ len = SetFilePointer(_hstub, 0, NULL, FILE_END);
+ if ((hmap = CreateFileMapping(_hstub, NULL,
+ PAGE_READWRITE, 0, 0, NULL)) == NULL) {
+ apxDisplayError(LOG_MARK, "%s unable to map the stub file\n",
+ _progname);
+ return -1;
+ }
+ if ((map = MapViewOfFile(hmap, FILE_MAP_ALL_ACCESS, 0, 0, 0)) == NULL) {
+ apxDisplayError(LOG_MARK, "%s unable to map the view of file\n",
+ _progname);
+ CloseHandle(hmap);
+ }
+ off = len - ZIPOFF_CDIR_CLEN;
+ cd = map + off;
+ mp = CHECK_4_MAGIC(cd, zip_ec_magic) ? cd : NULL;
+ while ((len - off) < (64 * 1024)) {
+ i = 0;
+ if (!mp) {
+ off -= ZIPOFF_CDIR_CLEN;
+ cd = map + off;
+
+ if (!CHECK_4_MAGIC(cd, zip_ec_magic)) {
+ for (; i < ZIPOFF_CDIR_CLEN; i++) {
+ if (CHECK_4_MAGIC((cd + i), zip_ec_magic)) {
+ mp = cd + i;
+ break;
+ }
+ }
+ }
+ else
+ mp = cd;
+ }
+
+ if (mp) {
+ cpos = READ_32_BITS(mp, ZIPOFF_CDIR_OFFSET);
+ nent = READ_16_BITS(mp, ZIPOFF_CDIR_TOTENTRIES);
+ cdir = off + i;
+ break;
+ }
+
+ }
+ if (cpos) {
+ hd = map + cpos + slen;
+ for (i = 0; i < nent; i++) {
+ size_t xl, cl, fl, sp;
+ if (!CHECK_4_MAGIC(hd, zip_fh_magic)) {
+ rc = -1;
+ apxDisplayError(LOG_MARK, "Wrong header at %d\n", hd - map);
+ goto cleanup;
+ }
+ sp = READ_32_BITS(hd, ZIPOFF_FH_LFHOFFSET);
+ fl = READ_16_BITS(hd, ZIPOFF_FH_FNLEN);
+ xl = READ_16_BITS(hd, ZIPOFF_FH_XFLEN);
+ cl = READ_16_BITS(hd, ZIPOFF_FH_FCLEN);
+ if (i == 0 && sp != 0) {
+ apxDisplayError(LOG_MARK, "The first entry is not zero\n");
+ rc = -1;
+ goto cleanup;
+ }
+ WRITE_32_BITS(hd, ZIPOFF_FH_LFHOFFSET, sp + slen);
+ hd += (fl + xl + cl + ZIPLEN_FH);
+ }
+ /* repos to the end of central dir */
+ mp = map + cdir;
+ WRITE_32_BITS(mp, ZIPOFF_CDIR_OFFSET, cpos + slen);
+ }
+cleanup:
+ UnmapViewOfFile(map);
+ CloseHandle(hmap);
+ return rc;
+
+}
+
+/* Merge the stub with jar file
+ * Fix the userblock bounded code.
+ */
+static int merge(LPCSTR jar, size_t slen)
+{
+ HANDLE hjar, hmap;
+ char buff[4096];
+ BYTE bmatch[16];
+
+ DWORD rd, wr;
+ BYTE *map, *ss;
+ int i;
+ if ((hmap = CreateFileMapping(_hstub, NULL,
+ PAGE_READWRITE, 0, 0, NULL)) == NULL) {
+ apxDisplayError(LOG_MARK, "%s unable to map the stub file\n",
+ _progname);
+ return -1;
+ }
+ if ((hjar = CreateFile(jar, GENERIC_READ, 0, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) {
+ apxDisplayError(LOG_MARK, "%s unable to open jar file : %s\n",
+ _progname, jar);
+ return -1;
+ }
+
+ if ((map = MapViewOfFile(hmap, FILE_MAP_ALL_ACCESS, 0, 0, 0)) == NULL) {
+ apxDisplayError(LOG_MARK, "%s unable to map the view of file\n",
+ _progname);
+ CloseHandle(hmap);
+ return -1;
+ }
+ /* convert to upper case */
+ for (i = 0; i < 15; i++)
+ bmatch[i] = c_signature[i] - 32;
+ bmatch[15] = 0;
+ if ((ss = ApcMemSearch(map, bmatch, 16, slen)) != NULL) {
+ st_config cfg;
+ AplCopyMemory(&cfg, ss, sizeof(st_config));
+ AplCopyMemory(ss, _config, sizeof(st_config));
+ }
+ UnmapViewOfFile(map);
+ CloseHandle(hmap);
+ SetFilePointer(_hstub, 0, NULL, FILE_END);
+ while (ReadFile(hjar, buff, 4096, &rd, NULL)) {
+ if (rd)
+ WriteFile(_hstub, buff, rd, &wr, NULL);
+ else
+ break;
+ if (rd != wr) {
+ apxDisplayError(LOG_MARK, "%s mismatch read/write\n(Readed : %d Written %d)\n",
+ _progname, rd, wr);
+ CloseHandle(hjar);
+ return -1;
+ }
+ }
+ CloseHandle(hjar);
+ return 0;
+}
+
+static int
+jar2exe(int argc, char *argv[])
+{
+ int i = 1, l;
+ BY_HANDLE_FILE_INFORMATION stub_inf;
+ char *p;
+ LOADED_IMAGE li;
+
+ while (argc > 1 && *argv[1] == '-') {
+ p = argv[1];
+ /* Check if verbose mode is on */
+ while (*p) {
+ if (*p == 'm') {
+ _config->s_flags[0] = atoi(p + 1);
+ break;
+ }
+ else if (*p == 'x') {
+ _config->s_flags[1] = atoi(p + 1);
+ break;
+ }
+ else if (*p == 's') {
+ _config->s_flags[2] = atoi(p + 1);
+ break;
+ }
+ else if (*p == 'd')
+ _verbose = TRUE;
+ else if (*p == 'g')
+ _makegui = TRUE;
+ ++p;
+ }
+ --argc;
+ ++argv;
+ }
+ if (argc < 4) {
+ SetLastError(ERROR_SUCCESS);
+ apxDisplayError(TRUE, NULL, 0, _usage);
+ return -1;
+ }
+ AplZeroMemory(_config->s_class, EMBED_SIZE);
+ lstrcpyA(_config->s_class, argv[2]);
+ l = lstrlenA(_config->s_class);
+ for (i = 0; i < l; i++) {
+ if (_config->s_class[i] == '.')
+ _config->s_class[i] = '/';
+ }
+ p = (char *)(&(_config->s_class[l+1]));
+ *p++ = '\0';
+ if (argc > 4) {
+ --p;
+ for (i = 4; i < argc; i++) {
+ l += lstrlenA(argv[i]);
+ if (l > EMBED_MAX) {
+ apxDisplayError(LOG_MARK, "%s args are too long (max %d are allowed)\n",
+ _progname, EMBED_MAX);
+ return -1;
+ }
+ lstrcpyA(p, argv[i]);
+ p += lstrlenA(argv[i]);
+ *p++ = '\0';
+ }
+ }
+ *p++ = '\0';
+ DeleteFile(argv[1]);
+ CopyFile(_progpath, argv[1], TRUE);
+ if ((_hstub = CreateFile(argv[1], GENERIC_READ | GENERIC_WRITE, 0, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) {
+ apxDisplayError(LOG_MARK, "%s unable to open stub %s\n",
+ _progname, argv[1]);
+ DeleteFile(argv[1]);
+ return -1;
+ }
+ /* Get original stub size */
+ GetFileInformationByHandle(_hstub, &stub_inf);
+
+ if (merge(argv[3], stub_inf.nFileSizeLow))
+ goto cleanup;
+ if (fixjar(stub_inf.nFileSizeLow))
+ goto cleanup;
+ CloseHandle(_hstub);
+ if (_makegui) {
+ /* Change a portable executable (PE) image Subsytem to GUI.
+ * It will also calculate a new Checksum.
+ */
+ if (MapAndLoad(argv[1], NULL, &li, FALSE, FALSE)) {
+ if (li.FileHeader)
+ li.FileHeader->OptionalHeader.Subsystem = IMAGE_SUBSYSTEM_WINDOWS_GUI;
+ UnMapAndLoad(&li);
+ }
+ else
+ apxDisplayError(LOG_MARK, "%s MapAndLoad %s\n",
+ _progname, argv[1]);
+ }
+ return 0;
+cleanup:
+ CloseHandle(_hstub);
+ DeleteFile(argv[1]);
+ return -1;
+}
+
+/* Run the embedded jar file
+ *
+ */
+int run(int argc, char *argv[])
+{
+ HANDLE hPool, hJava;
+ DWORD rv = 0;
+ apxHandleManagerInitialize();
+ hPool = apxPoolCreate(NULL, 0);
+ /* Use default JVM */
+ hJava = apxCreateJava(hPool, NULL);
+ if (!IS_INVALID_HANDLE(hJava)) {
+ LPSTR lpCmd;
+ if (!apxJavaInitialize(hJava, _progpath,
+ _config->s_class +
+ strlen(_config->s_class) + 1,
+ _config->s_flags[0],
+ _config->s_flags[1],
+ _config->s_flags[2])) {
+ rv = 1;
+ goto cleanup;
+ }
+ lpCmd = apxArrayToMultiSzA(hPool, argc - 1, &argv[1]);
+ if (!apxJavaLoadMainClass(hJava, _config->s_class, NULL, lpCmd)) {
+ rv = 2;
+ goto cleanup;
+ }
+ if (!apxJavaStart(hJava)) {
+ rv = 3;
+ }
+ else
+ apxJavaWait(hJava, INFINITE, FALSE);
+cleanup:
+ apxCloseHandle(hJava);
+ }
+ else {
+ rv = 4;
+ }
+
+ apxHandleManagerDestroy();
+ ExitProcess(rv);
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ char *p;
+ char path[MAX_PATH+1];
+ GetModuleFileName(GetModuleHandle(NULL), path, MAX_PATH);
+ lstrcpyA(_progpath, path);
+
+ _config = (st_config *)conf_in_exe;
+ if (lstrcmpiA(_config->s_signature, c_signature)) {
+ apxDisplayError(LOG_MARK, "%s\nWrong user block signature\n", _lint);
+ ExitProcess(1);
+ }
+ /* remove the path and extension from module name */
+ if ((p = AplRindexA(path, '\\')))
+ *p++ = '\0';
+ else
+ p = &path[0];
+ lstrcpyA(_progname, p);
+ if (lstrlenA(_progname) > EXE_SUFFIX_SZ && ((p = AplRindexA(_progname, '.')) != NULL)) {
+ if (!lstrcmpiA(p, EXE_SUFFIX))
+ *p = '\0';
+ }
+
+ if (lstrcmpiA(_progname, "jar2exe") == 0)
+ return jar2exe(argc, argv);
+ else if (lstrcmpiA(_progname, "jar2exew") == 0) {
+ /* default is to make gui app */
+ _makegui = TRUE;
+ return jar2exe(argc, argv);
+ }
+ else /* run the embedded jar */
+ return run(argc, argv);
+
+ /* NOT REACHED */
+ return 0;
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/jar2exe/jar2exe.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/jar2exe/jar2exe.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/jar2exe/jar2exe.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,86 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* ====================================================================
+ * jar2exe -- convert .jar file to WIN executable.
+ * Contributed by Mladen Turk <mturk at apache.org>
+ * 05 Aug 2003
+ * ====================================================================
+ */
+
+#ifndef _JAR2EXE_H
+#define _JAR2EXE_H
+
+#undef PRG_VERSION
+#define PRG_VERSION "1.0.0.0"
+
+#define ZIPOFF_CDIR_CLEN 20
+#define ZIPOFF_CDIR_DISKNO 4
+#define ZIPOFF_CDIR_FINALDISKNO 6
+#define ZIPOFF_CDIR_ENTRIES 8
+#define ZIPOFF_CDIR_TOTENTRIES 10
+#define ZIPOFF_CDIR_SIZE 12
+#define ZIPOFF_CDIR_OFFSET 16
+
+#define ZIPOFF_FH_VERSION 4
+#define ZIPOFF_FH_NEEDVERSION 6
+#define ZIPOFF_FH_GPBF 8
+#define ZIPOFF_FH_CM 10
+#define ZIPOFF_FH_MTIME 12
+#define ZIPOFF_FH_MDATE 14
+#define ZIPOFF_FH_CRC32 16
+#define ZIPOFF_FH_CSIZE 20
+#define ZIPOFF_FH_USIZE 24
+#define ZIPOFF_FH_FNLEN 28
+#define ZIPOFF_FH_XFLEN 30
+#define ZIPOFF_FH_FCLEN 32
+#define ZIPOFF_FH_DISKNO 34
+#define ZIPOFF_FH_IFATTR 36
+#define ZIPOFF_FH_EFATTR 38
+#define ZIPOFF_FH_LFHOFFSET 42
+#define ZIPLEN_FH 46
+
+#define READ_32_BITS(base, offset) \
+ ((((unsigned char)(base)[offset + 0])) | \
+ (((unsigned char)(base)[offset + 1]) << 8) | \
+ (((unsigned char)(base)[offset + 2]) << 16) | \
+ (((unsigned char)(base)[offset + 3]) << 24))
+
+#define READ_16_BITS(base, offset) \
+ ((((unsigned char)(base)[offset])) | \
+ (((unsigned char)(base)[offset + 1]) << 8)) \
+
+#define WRITE_32_BITS(base, offset, value) { \
+ (base)[offset + 0] = (unsigned char)(value & 0xff); \
+ (base)[offset + 1] = (unsigned char)((value & 0xff00) >> 8); \
+ (base)[offset + 2] = (unsigned char)((value & 0xff0000) >> 16); \
+ (base)[offset + 3] = (unsigned char)((value & 0xff000000) >> 24); \
+}
+
+#define WRITE_16_BITS(base, offset, value) { \
+ (base)[offset + 0] = (unsigned char)(value & 0xff); \
+ (base)[offset + 1] = (unsigned char)((value & 0xff00) >> 8); \
+}
+
+/* shuld be faster then memcmp */
+#define CHECK_4_MAGIC(base, magic) \
+ ( ((base)[0] == (magic)[0]) && \
+ ((base)[1] == (magic)[1]) && \
+ ((base)[2] == (magic)[2]) && \
+ ((base)[3] == (magic)[3]) )
+
+
+#endif /* _JAR2EXE_H */
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/jar2exe/jar2exe.rc
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/jar2exe/jar2exe.rc 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/jar2exe/jar2exe.rc 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,55 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apxwin.h"
+#include "jar2exe.h"
+
+#define RSTR_JAR2EXE "Java jar launcher"
+
+IDI_MAINICON ICON "../../resources/procrunw.ico"
+
+1 VERSIONINFO
+ FILEVERSION 1,0,0,0
+ PRODUCTVERSION 1,0,0,0
+ FILEFLAGSMASK 0x3fL
+#if defined(_DEBUG)
+ FILEFLAGS 0x03L
+#else
+ FILEFLAGS 0x02L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "Comments", "\0"
+ VALUE "CompanyName", "Apache Software Foundation\0"
+ VALUE "FileDescription", RSTR_JAR2EXE "\0"
+ VALUE "FileVersion", PRG_VERSION
+ VALUE "InternalName", RSTR_JAR2EXE "\0"
+ VALUE "LegalCopyright", "Copyright © 2000-2003 The Apache Software Foundation.\0"
+ VALUE "OriginalFilename", "jar2exe.exe\0"
+ VALUE "ProductName", RSTR_JAR2EXE "\0"
+ VALUE "ProductVersion", PRG_VERSION
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/jar2exe/jar2exe.vcproj
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/jar2exe/jar2exe.vcproj 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/jar2exe/jar2exe.vcproj 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="jar2exe"
+ ProjectGUID="{DA9F3DDA-F85A-492A-B914-6A361429FC41}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="..\..\obj\Debug"
+ IntermediateDirectory="..\..\obj\Debug"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=".\;..\..\include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="shlwapi.lib"
+ OutputFile="../../bin/jar2exe.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/jar2exe.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="..\..\include"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="..\..\obj\Release"
+ IntermediateDirectory="..\..\obj\Release"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=".\;..\..\include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="shlwapi.lib"
+ OutputFile="../../bin/jar2exe.exe"
+ LinkIncremental="1"
+ SuppressStartupBanner="TRUE"
+ GenerateDebugInformation="FALSE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="..\..\include"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath=".\jar2exe.c">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ <File
+ RelativePath=".\jar2exe.h">
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+ <File
+ RelativePath=".\jar2exe.rc">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,1725 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* ====================================================================
+ * prunsrv -- Service Runner.
+ * Contributed by Mladen Turk <mturk at apache.org>
+ * 05 Aug 2003
+ * ====================================================================
+ */
+
+/* Force the JNI vprintf functions */
+#define _DEBUG_JNI 1
+#include "apxwin.h"
+#include "prunmgr.h"
+
+LPAPXGUISTORE _gui_store = NULL;
+#define PRUNMGR_CLASS TEXT("PRUNMGR")
+#define TMNU_CONF TEXT("Configure...")
+#define TMNU_START TEXT("Start service")
+#define TMNU_STOP TEXT("Stop service")
+#define TMNU_EXIT TEXT("Exit")
+#define TMNU_ABOUT TEXT("About")
+#define TMNU_DUMP TEXT("Thread Dump")
+
+/* Display only Started/Paused status */
+#define STAT_STARTED TEXT("Started")
+#define STAT_PAUSED TEXT("Paused")
+#define STAT_STOPPED TEXT("Stopped")
+#define STAT_DISABLED TEXT("Disabled")
+#define STAT_NONE TEXT("")
+#define STAT_SYSTEM L"LocalSystem"
+
+#define LOGL_ERROR L"Error"
+#define LOGL_DEBUG L"Debug"
+#define LOGL_INFO L"Info"
+#define LOGL_WARN L"Warning"
+
+
+#define START_AUTO L"Automatic"
+#define START_MANUAL L"Manual"
+#define START_DISABLED L"Disabled"
+#define START_BOOT L"Boot"
+#define START_SYSTEM L"SystemInit"
+#define EMPTY_PASSWORD L" "
+
+/* Main application pool */
+APXHANDLE hPool = NULL;
+APXHANDLE hService = NULL;
+APXHANDLE hRegistry = NULL;
+APXHANDLE hRegserv = NULL;
+HICON hIcoRun = NULL;
+HICON hIcoStop = NULL;
+
+LPAPXSERVENTRY _currentEntry = NULL;
+
+BOOL bEnableTry = FALSE;
+DWORD startPage = 0;
+
+static LPCWSTR _s_log = L"Log";
+static LPCWSTR _s_java = L"Java";
+static LPCWSTR _s_start = L"Start";
+static LPCWSTR _s_stop = L"Stop";
+
+/* Allowed procrun commands */
+static LPCWSTR _commands[] = {
+ L"ES", /* 1 Manage Service (default)*/
+ L"MS", /* 2 Monitor Service */
+ L"MR", /* 3 Monitor Service and start if not runing */
+ L"MQ", /* 4 Quit all running Monitor applications */
+ NULL
+};
+
+/* Allowed procrun parameters */
+static APXCMDLINEOPT _options[] = {
+/* 0 */ { L"AllowMultiInstances", NULL, NULL, APXCMDOPT_INT, NULL, 0},
+ /* NULL terminate the array */
+ { NULL }
+};
+
+/* Create RBUTTON try menu
+ * Configure... (default, or lbutton dblclick)
+ * Start <service name>
+ * Stop <service name>
+ * Exit
+ * Logo
+ */
+static void createRbuttonTryMenu(HWND hWnd)
+{
+ HMENU hMnu;
+ POINT pt;
+ BOOL canStop = FALSE;
+ BOOL canStart = FALSE;
+ hMnu = CreatePopupMenu();
+
+ if (_currentEntry) {
+ if (_currentEntry->stServiceStatus.dwCurrentState == SERVICE_RUNNING) {
+ if (_currentEntry->stServiceStatus.dwControlsAccepted & SERVICE_ACCEPT_STOP)
+ canStop = TRUE;
+ }
+ else if (_currentEntry->stServiceStatus.dwCurrentState == SERVICE_STOPPED) {
+ if (_currentEntry->lpConfig->dwStartType != SERVICE_DISABLED)
+ canStart = TRUE;
+ }
+ }
+ apxAppendMenuItem(hMnu, IDM_TM_CONFIG, TMNU_CONF, TRUE, TRUE);
+ apxAppendMenuItem(hMnu, IDM_TM_START, TMNU_START, FALSE, canStart);
+ apxAppendMenuItem(hMnu, IDM_TM_STOP, TMNU_STOP, FALSE, canStop);
+ apxAppendMenuItem(hMnu, IDM_TM_DUMP, TMNU_DUMP, FALSE, canStop);
+ apxAppendMenuItem(hMnu, IDM_TM_EXIT, TMNU_EXIT, FALSE, TRUE);
+ apxAppendMenuItem(hMnu, -1, NULL, FALSE, FALSE);
+ apxAppendMenuItem(hMnu, IDM_TM_ABOUT, TMNU_ABOUT, FALSE, TRUE);
+
+ /* Ensure we have a focus */
+ if (!SetForegroundWindow(hWnd))
+ SetForegroundWindow(NULL);
+ GetCursorPos(&pt);
+ /* Display the try menu */
+ TrackPopupMenu(hMnu, TPM_LEFTALIGN | TPM_RIGHTBUTTON,
+ pt.x, pt.y, 0, hWnd, NULL);
+ DestroyMenu(hMnu);
+}
+
+/* wParam progress dialog handle
+ */
+static BOOL __startServiceCallback(APXHANDLE hObject, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ HWND hDlg = (HWND)hObject;
+
+ switch (uMsg) {
+ case WM_USER+1:
+ hDlg = (HWND)lParam;
+ if (IS_INVALID_HANDLE(hService)) {
+ EndDialog(hDlg, IDOK);
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND,
+ MAKEWPARAM(IDMS_REFRESH, 0), 0);
+ return FALSE;
+ }
+ if (apxServiceControl(hService, SERVICE_CONTROL_CONTINUE, WM_USER+2,
+ __startServiceCallback, hDlg)) {
+ _currentEntry->stServiceStatus.dwCurrentState = SERVICE_RUNNING;
+ _currentEntry->stStatusProcess.dwCurrentState = SERVICE_RUNNING;
+
+ }
+ EndDialog(hDlg, IDOK);
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND,
+ MAKEWPARAM(IDMS_REFRESH, 0), 0);
+ break;
+ case WM_USER+2:
+ SendMessage(hDlg, WM_USER+1, 0, 0);
+ Sleep(500);
+ break;
+ }
+ return TRUE;
+}
+
+static BOOL __stopServiceCallback(APXHANDLE hObject, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ HWND hDlg = (HWND)hObject;
+
+ switch (uMsg) {
+ case WM_USER+1:
+ hDlg = (HWND)lParam;
+ if (IS_INVALID_HANDLE(hService))
+ return FALSE;
+ if (apxServiceControl(hService, SERVICE_CONTROL_STOP, WM_USER+2,
+ __stopServiceCallback, hDlg)) {
+ }
+ EndDialog(hDlg, IDOK);
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND,
+ MAKEWPARAM(IDMS_REFRESH, 0), 0);
+ break;
+ case WM_USER+2:
+ if (wParam == 4)
+ AplCopyMemory(&_currentEntry->stServiceStatus,
+ (LPVOID)lParam, sizeof(SERVICE_STATUS));
+ SendMessage(hDlg, WM_USER+1, 0, 0);
+ Sleep(100);
+ break;
+ }
+ return TRUE;
+}
+
+static BOOL __restartServiceCallback(APXHANDLE hObject, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ HWND hDlg = (HWND)hObject;
+ switch (uMsg) {
+ case WM_USER+1:
+ hDlg = (HWND)lParam;
+ if (IS_INVALID_HANDLE(hService))
+ return FALSE;
+ /* TODO: use 128 as controll code */
+ if (apxServiceControl(hService, 128, WM_USER+2,
+ __restartServiceCallback, hDlg)) {
+
+ }
+ EndDialog(hDlg, IDOK);
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND,
+ MAKEWPARAM(IDMS_REFRESH, 0), 0);
+ break;
+ case WM_USER+2:
+ if (wParam == 4)
+ AplCopyMemory(&_currentEntry->stServiceStatus,
+ (LPVOID)lParam, sizeof(SERVICE_STATUS));
+
+ SendMessage(hDlg, WM_USER+1, 0, 0);
+ Sleep(100);
+ break;
+ }
+ return TRUE;
+}
+
+static BOOL __pauseServiceCallback(APXHANDLE hObject, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ HWND hDlg = (HWND)hObject;
+ switch (uMsg) {
+ case WM_USER+1:
+ hDlg = (HWND)lParam;
+ if (IS_INVALID_HANDLE(hService))
+ return FALSE;
+ if (apxServiceControl(hService, SERVICE_CONTROL_PAUSE, WM_USER+2,
+ __pauseServiceCallback, hDlg)) {
+ }
+ EndDialog(hDlg, IDOK);
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND,
+ MAKEWPARAM(IDMS_REFRESH, 0), 0);
+ break;
+ case WM_USER+2:
+ if (wParam == 4)
+ AplCopyMemory(&_currentEntry->stServiceStatus,
+ (LPVOID)lParam, sizeof(SERVICE_STATUS));
+ SendMessage(hDlg, WM_USER+1, 0, 0);
+ Sleep(100);
+ break;
+ }
+ return TRUE;
+}
+
+static DWORD _propertyChanged;
+static BOOL _propertyOpened = FALSE;
+static HWND _propertyHwnd = NULL;
+/* Service property pages */
+int CALLBACK __propertyCallback(HWND hwndPropSheet, UINT uMsg, LPARAM lParam)
+{
+ switch(uMsg) {
+ case PSCB_PRECREATE:
+ {
+ LPDLGTEMPLATE lpTemplate = (LPDLGTEMPLATE)lParam;
+ if (!(lpTemplate->style & WS_SYSMENU))
+ lpTemplate->style |= WS_SYSMENU;
+ _propertyHwnd = hwndPropSheet;
+
+ _propertyChanged = 0;
+ _propertyOpened = TRUE;
+ return TRUE;
+ }
+ break;
+ case PSCB_INITIALIZED:
+ break;
+ }
+ return TRUE;
+}
+
+BOOL __generalPropertySave(HWND hDlg)
+{
+ WCHAR szN[256];
+ WCHAR szD[256];
+ DWORD dwStartType = SERVICE_NO_CHANGE;
+ int i;
+
+ if (!(TST_BIT_FLAG(_propertyChanged, 1)))
+ return TRUE;
+ CLR_BIT_FLAG(_propertyChanged, 1);
+
+ if (IS_INVALID_HANDLE(hService))
+ return FALSE;
+ GetDlgItemTextW(hDlg, IDC_PPSGDISP, szN, 255);
+ GetDlgItemTextW(hDlg, IDC_PPSGDESC, szD, 1023);
+ i = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_PPSGCMBST));
+ if (i == 0)
+ dwStartType = SERVICE_AUTO_START;
+ else if (i == 1)
+ dwStartType = SERVICE_DEMAND_START;
+ else if (i == 2)
+ dwStartType = SERVICE_DISABLED;
+ apxServiceSetNames(hService, NULL, szN, szD, NULL, NULL);
+ apxServiceSetOptions(hService, SERVICE_NO_CHANGE, dwStartType, SERVICE_NO_CHANGE);
+
+ if (!(TST_BIT_FLAG(_propertyChanged, 2)))
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND, MAKEWPARAM(IDMS_REFRESH, 0), 0);
+
+ return TRUE;
+}
+
+BOOL __generalLogonSave(HWND hDlg)
+{
+ WCHAR szU[64];
+ WCHAR szP[64];
+ WCHAR szC[64];
+ DWORD dwStartType = SERVICE_NO_CHANGE;
+
+ if (!(TST_BIT_FLAG(_propertyChanged, 2)))
+ return TRUE;
+ CLR_BIT_FLAG(_propertyChanged, 2);
+
+ if (IS_INVALID_HANDLE(hService))
+ return FALSE;
+ GetDlgItemTextW(hDlg, IDC_PPSLUSER, szU, 63);
+ GetDlgItemTextW(hDlg, IDC_PPSLPASS, szP, 63);
+ GetDlgItemTextW(hDlg, IDC_PPSLCPASS, szC, 63);
+
+ if (lstrlenW(szU) && lstrcmpiW(szU, STAT_SYSTEM)) {
+ if (szP[0] != L' ' && szC[0] != L' ' && !lstrcmpW(szP, szC))
+ apxServiceSetNames(hService, NULL, NULL, NULL, szU, szP);
+ else {
+ MessageBoxW(hDlg, apxLoadResourceW(IDS_VALIDPASS, 0),
+ apxLoadResourceW(IDS_APPLICATION, 1),
+ MB_OK | MB_ICONSTOP);
+ return FALSE;
+ }
+ }
+ else {
+ if (IsDlgButtonChecked(hDlg, IDC_PPSLID) == BST_CHECKED)
+ apxServiceSetOptions(hService,
+ _currentEntry->stServiceStatus.dwServiceType | SERVICE_INTERACTIVE_PROCESS,
+ SERVICE_NO_CHANGE, SERVICE_NO_CHANGE);
+ else
+ apxServiceSetOptions(hService,
+ _currentEntry->stServiceStatus.dwServiceType & ~SERVICE_INTERACTIVE_PROCESS,
+ SERVICE_NO_CHANGE, SERVICE_NO_CHANGE);
+ }
+ if (!(TST_BIT_FLAG(_propertyChanged, 1)))
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND, MAKEWPARAM(IDMS_REFRESH, 0), 0);
+ return TRUE;
+}
+
+BOOL __generalLoggingSave(HWND hDlg)
+{
+ WCHAR szB[SIZ_DESLEN];
+
+ if (!(TST_BIT_FLAG(_propertyChanged, 3)))
+ return TRUE;
+ CLR_BIT_FLAG(_propertyChanged, 3);
+
+ if (IS_INVALID_HANDLE(hService))
+ return FALSE;
+
+ GetDlgItemTextW(hDlg, IDC_PPLGLEVEL, szB, SIZ_DESMAX);
+ apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_log, L"Level", szB);
+ GetDlgItemTextW(hDlg, IDC_PPLGPATH, szB, SIZ_DESMAX);
+ apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_log, L"Path", szB);
+ GetDlgItemTextW(hDlg, IDC_PPLGPREFIX, szB, SIZ_DESMAX);
+ apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_log, L"Prefix", szB);
+ GetDlgItemTextW(hDlg, IDC_PPLGSTDOUT, szB, SIZ_DESMAX);
+ apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_log, L"StdOutput", szB);
+ GetDlgItemTextW(hDlg, IDC_PPLGSTDERR, szB, SIZ_DESMAX);
+ apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_log, L"StdError", szB);
+
+ if (!(TST_BIT_FLAG(_propertyChanged, 1)))
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND, MAKEWPARAM(IDMS_REFRESH, 0), 0);
+ return TRUE;
+}
+
+BOOL __generalJvmSave(HWND hDlg)
+{
+ WCHAR szB[SIZ_DESLEN];
+ LPWSTR p, s;
+ DWORD l;
+ if (!(TST_BIT_FLAG(_propertyChanged, 4)))
+ return TRUE;
+ CLR_BIT_FLAG(_propertyChanged, 4);
+
+ if (IS_INVALID_HANDLE(hService))
+ return FALSE;
+ if (!IsDlgButtonChecked(hDlg, IDC_PPJAUTO)) {
+ GetDlgItemTextW(hDlg, IDC_PPJJVM, szB, SIZ_DESMAX);
+ }
+ else
+ lstrcpyW(szB, L"auto");
+ apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_java, L"Jvm", szB);
+ GetDlgItemTextW(hDlg, IDC_PPJCLASSPATH, szB, SIZ_DESMAX);
+ apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_java, L"Classpath", szB);
+
+ l = GetWindowTextLength(GetDlgItem(hDlg, IDC_PPJOPTIONS));
+ p = apxPoolAlloc(hPool, (l + 2) * sizeof(WCHAR));
+ GetDlgItemTextW(hDlg, IDC_PPJOPTIONS, p, l + 1);
+ s = apxCRLFToMszW(hPool, p, &l);
+ apxFree(p);
+ apxRegistrySetMzStrW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_java, L"Options", s, l);
+ if (!GetDlgItemTextW(hDlg, IDC_PPJMS, szB, SIZ_DESMAX))
+ szB[0] = L'\0';
+
+ apxRegistrySetNumW(hRegserv, APXREG_PARAMSOFTWARE, _s_java, L"JvmMs",
+ apxAtoulW(szB));
+ if (!GetDlgItemTextW(hDlg, IDC_PPJMX, szB, SIZ_DESMAX))
+ szB[0] = L'\0';
+ apxRegistrySetNumW(hRegserv, APXREG_PARAMSOFTWARE, _s_java, L"JvmMx",
+ apxAtoulW(szB));
+ if (!GetDlgItemTextW(hDlg, IDC_PPJSS, szB, SIZ_DESMAX))
+ szB[0] = L'\0';
+ apxRegistrySetNumW(hRegserv, APXREG_PARAMSOFTWARE, _s_java, L"JvmSs",
+ apxAtoulW(szB));
+ apxFree(s);
+ if (!(TST_BIT_FLAG(_propertyChanged, 1)))
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND, MAKEWPARAM(IDMS_REFRESH, 0), 0);
+ return TRUE;
+}
+
+BOOL __generalStartSave(HWND hDlg)
+{
+ WCHAR szB[SIZ_DESLEN];
+ LPWSTR p, s;
+ DWORD l;
+
+ if (!(TST_BIT_FLAG(_propertyChanged, 5)))
+ return TRUE;
+ CLR_BIT_FLAG(_propertyChanged, 5);
+
+ if (IS_INVALID_HANDLE(hService))
+ return FALSE;
+
+ GetDlgItemTextW(hDlg, IDC_PPRCLASS, szB, SIZ_DESMAX);
+ apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_start, L"Class", szB);
+ GetDlgItemTextW(hDlg, IDC_PPRIMAGE, szB, SIZ_DESMAX);
+ apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_start, L"Image", szB);
+ GetDlgItemTextW(hDlg, IDC_PPRWPATH, szB, SIZ_DESMAX);
+ apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_start, L"WorkingPath", szB);
+ GetDlgItemTextW(hDlg, IDC_PPRMETHOD, szB, SIZ_DESMAX);
+ apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_start, L"Method", szB);
+ GetDlgItemTextW(hDlg, IDC_PPRMODE, szB, SIZ_DESMAX);
+ apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_start, L"Mode", szB);
+
+ l = GetWindowTextLength(GetDlgItem(hDlg, IDC_PPRARGS));
+ p = apxPoolAlloc(hPool, (l + 2) * sizeof(WCHAR));
+ GetDlgItemTextW(hDlg, IDC_PPRARGS, p, l + 1);
+ s = apxCRLFToMszW(hPool, p, &l);
+ apxFree(p);
+ apxRegistrySetMzStrW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_start, L"Params", s, l);
+ apxFree(s);
+
+ if (!(TST_BIT_FLAG(_propertyChanged, 1)))
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND, MAKEWPARAM(IDMS_REFRESH, 0), 0);
+ return TRUE;
+}
+
+BOOL __generalStopSave(HWND hDlg)
+{
+ WCHAR szB[SIZ_DESLEN];
+ LPWSTR p, s;
+ DWORD l;
+
+ if (!(TST_BIT_FLAG(_propertyChanged, 6)))
+ return TRUE;
+ CLR_BIT_FLAG(_propertyChanged, 6);
+
+ if (IS_INVALID_HANDLE(hService))
+ return FALSE;
+
+ GetDlgItemTextW(hDlg, IDC_PPSCLASS, szB, SIZ_DESMAX);
+ apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_stop, L"Class", szB);
+ GetDlgItemTextW(hDlg, IDC_PPSIMAGE, szB, SIZ_DESMAX);
+ apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_stop, L"Image", szB);
+ GetDlgItemTextW(hDlg, IDC_PPSWPATH, szB, SIZ_DESMAX);
+ apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_stop, L"WorkingPath", szB);
+ GetDlgItemTextW(hDlg, IDC_PPSMETHOD, szB, SIZ_DESMAX);
+ apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_stop, L"Method", szB);
+ GetDlgItemTextW(hDlg, IDC_PPSTIMEOUT, szB, SIZ_DESMAX);
+ apxRegistrySetNumW(hRegserv, APXREG_PARAMSOFTWARE, _s_stop, L"Timeout", apxAtoulW(szB));
+ GetDlgItemTextW(hDlg, IDC_PPSMODE, szB, SIZ_DESMAX);
+ apxRegistrySetStrW(hRegserv, APXREG_PARAMSOFTWARE, _s_stop, L"Mode", szB);
+
+ l = GetWindowTextLength(GetDlgItem(hDlg, IDC_PPSARGS));
+ p = apxPoolAlloc(hPool, (l + 2) * sizeof(WCHAR));
+ GetDlgItemTextW(hDlg, IDC_PPSARGS, p, l + 1);
+ s = apxCRLFToMszW(hPool, p, &l);
+ apxFree(p);
+ apxRegistrySetMzStrW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_stop, L"Params", s, l);
+ apxFree(s);
+
+ if (!(TST_BIT_FLAG(_propertyChanged, 1)))
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND, MAKEWPARAM(IDMS_REFRESH, 0), 0);
+ return TRUE;
+}
+
+void __generalPropertyRefresh(HWND hDlg)
+{
+ Button_Enable(GetDlgItem(hDlg, IDC_PPSGSTART), FALSE);
+ Button_Enable(GetDlgItem(hDlg, IDC_PPSGSTOP), FALSE);
+ Button_Enable(GetDlgItem(hDlg, IDC_PPSGPAUSE), FALSE);
+ Button_Enable(GetDlgItem(hDlg, IDC_PPSGRESTART), FALSE);
+ switch (_currentEntry->stServiceStatus.dwCurrentState) {
+ case SERVICE_RUNNING:
+ if (_currentEntry->stServiceStatus.dwControlsAccepted & SERVICE_ACCEPT_STOP ||
+ _currentEntry->lpConfig->dwStartType != SERVICE_DISABLED) {
+ Button_Enable(GetDlgItem(hDlg, IDC_PPSGSTOP), TRUE);
+ SetDlgItemText(hDlg, IDC_PPSGSTATUS, STAT_STARTED);
+ }
+ else
+ SetDlgItemText(hDlg, IDC_PPSGSTATUS, STAT_DISABLED);
+ if (_currentEntry->stServiceStatus.dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) {
+ Button_Enable(GetDlgItem(hDlg, IDC_PPSGPAUSE), TRUE);
+ Button_Enable(GetDlgItem(hDlg, IDC_PPSGRESTART), TRUE);
+ }
+ break;
+ case SERVICE_PAUSED:
+ Button_Enable(GetDlgItem(hDlg, IDC_PPSGSTART), TRUE);
+ Button_Enable(GetDlgItem(hDlg, IDC_PPSGRESTART), TRUE);
+ SetDlgItemText(hDlg, IDC_PPSGSTATUS, STAT_PAUSED);
+ break;
+ case SERVICE_STOPPED:
+ if (_currentEntry->lpConfig->dwStartType != SERVICE_DISABLED) {
+ Button_Enable(GetDlgItem(hDlg, IDC_PPSGSTART), TRUE);
+ SetDlgItemText(hDlg, IDC_PPSGSTATUS, STAT_STOPPED);
+ }
+ else
+ SetDlgItemText(hDlg, IDC_PPSGSTATUS, STAT_DISABLED);
+ break;
+ default:
+ break;
+ }
+}
+
+static BOOL bpropCentered = FALSE;
+LRESULT CALLBACK __generalProperty(HWND hDlg,
+ UINT uMessage,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ LPPSHNOTIFY lpShn;
+ WCHAR szBuf[1024];
+
+ switch (uMessage) {
+ case WM_INITDIALOG:
+ {
+ if (!bEnableTry)
+ apxCenterWindow(GetParent(hDlg), NULL);
+ else if (!bpropCentered)
+ apxCenterWindow(GetParent(hDlg), NULL);
+ bpropCentered = TRUE;
+ startPage = 0;
+ if (!bEnableTry)
+ apxCenterWindow(GetParent(hDlg), NULL);
+ SendMessage(GetDlgItem(hDlg, IDC_PPSGDISP), EM_LIMITTEXT, 255, 0);
+ SendMessage(GetDlgItem(hDlg, IDC_PPSGDESC), EM_LIMITTEXT, 1023, 0);
+
+ ComboBox_AddStringW(GetDlgItem(hDlg, IDC_PPSGCMBST), START_AUTO);
+ ComboBox_AddStringW(GetDlgItem(hDlg, IDC_PPSGCMBST), START_MANUAL);
+ ComboBox_AddStringW(GetDlgItem(hDlg, IDC_PPSGCMBST), START_DISABLED);
+ if (_currentEntry->lpConfig->dwStartType == SERVICE_AUTO_START)
+ ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_PPSGCMBST), 0);
+ else if (_currentEntry->lpConfig->dwStartType == SERVICE_DEMAND_START)
+ ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_PPSGCMBST), 1);
+ else if (_currentEntry->lpConfig->dwStartType == SERVICE_DISABLED)
+ ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_PPSGCMBST), 2);
+
+ SetDlgItemTextW(hDlg, IDC_PPSGNAME, _currentEntry->szServiceName);
+ SetDlgItemTextW(hDlg, IDC_PPSGDISP, _currentEntry->lpConfig->lpDisplayName);
+ SetDlgItemTextW(hDlg, IDC_PPSGDESC, _currentEntry->szServiceDescription);
+ SetDlgItemTextW(hDlg, IDC_PPSGDEXE, _currentEntry->lpConfig->lpBinaryPathName);
+ __generalPropertyRefresh(hDlg);
+ }
+ break;
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_PPSGCMBST:
+ if (HIWORD(wParam) == CBN_SELCHANGE) {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 1);
+ }
+ break;
+ case IDC_PPSGDISP:
+ if (HIWORD(wParam) == EN_CHANGE) {
+ GetDlgItemTextW(hDlg, IDC_PPSGDISP, szBuf, 255);
+ if (!lstrcmpW(szBuf, _currentEntry->lpConfig->lpDisplayName)) {
+ PropSheet_UnChanged(GetParent(hDlg), hDlg);
+ CLR_BIT_FLAG(_propertyChanged, 1);
+ }
+ else {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 1);
+ }
+ }
+ break;
+ case IDC_PPSGDESC:
+ if (HIWORD(wParam) == EN_CHANGE) {
+ GetDlgItemTextW(hDlg, IDC_PPSGDESC, szBuf, 1023);
+ if (!lstrcmpW(szBuf, _currentEntry->szServiceDescription)) {
+ PropSheet_UnChanged(GetParent(hDlg), hDlg);
+ CLR_BIT_FLAG(_propertyChanged, 1);
+ }
+ else {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 1);
+ }
+ }
+ break;
+ case IDC_PPSGSTART:
+ apxProgressBox(hDlg, apxLoadResource(IDS_HSSTART, 0),
+ _currentEntry->lpConfig->lpDisplayName,
+ __startServiceCallback, NULL);
+ __generalPropertyRefresh(hDlg);
+ break;
+ case IDC_PPSGSTOP:
+ apxProgressBox(hDlg, apxLoadResource(IDS_HSSTOP, 0),
+ _currentEntry->lpConfig->lpDisplayName,
+ __stopServiceCallback, NULL);
+ __generalPropertyRefresh(hDlg);
+ break;
+ case IDC_PPSGPAUSE:
+ apxProgressBox(hDlg, apxLoadResource(IDS_HSPAUSE, 0),
+ _currentEntry->lpConfig->lpDisplayName,
+ __pauseServiceCallback, NULL);
+ __generalPropertyRefresh(hDlg);
+ break;
+ case IDC_PPSGRESTART:
+ apxProgressBox(hDlg, apxLoadResource(IDS_HSRESTART, 0),
+ _currentEntry->lpConfig->lpDisplayName,
+ __restartServiceCallback, NULL);
+ __generalPropertyRefresh(hDlg);
+ break;
+ }
+ break;
+ case WM_NOTIFY:
+ lpShn = (LPPSHNOTIFY )lParam;
+ switch (lpShn->hdr.code) {
+ case PSN_APPLY: /* sent when OK or Apply button pressed */
+ if (__generalPropertySave(hDlg)) {
+ PropSheet_UnChanged(GetParent(hDlg), hDlg);
+ }
+ else {
+ SET_BIT_FLAG(_propertyChanged, 1);
+ SetWindowLong(hDlg, DWLP_MSGRESULT,
+ PSNRET_INVALID_NOCHANGEPAGE);
+ return TRUE;
+ }
+
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return FALSE;
+}
+
+LRESULT CALLBACK __logonProperty(HWND hDlg,
+ UINT uMessage,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ LPPSHNOTIFY lpShn;
+ WCHAR szBuf[1024];
+ switch (uMessage) {
+ case WM_INITDIALOG:
+ {
+ BOOL bAccount = FALSE;
+ startPage = 1;
+ if (!bpropCentered)
+ apxCenterWindow(GetParent(hDlg), NULL);
+ bpropCentered = TRUE;
+
+ SendMessage(GetDlgItem(hDlg, IDC_PPSLUSER), EM_LIMITTEXT, 63, 0);
+ SendMessage(GetDlgItem(hDlg, IDC_PPSLPASS), EM_LIMITTEXT, 63, 0);
+ SendMessage(GetDlgItem(hDlg, IDC_PPSLCPASS), EM_LIMITTEXT, 63, 0);
+ /* Check if we use LocalSystem or user defined account */
+ if (lstrcmpiW(_currentEntry->szObjectName, STAT_SYSTEM)) {
+ bAccount = TRUE;
+ CheckRadioButton(hDlg, IDC_PPSLLS, IDC_PPSLUA, IDC_PPSLUA);
+ SetDlgItemTextW(hDlg, IDC_PPSLUSER, _currentEntry->szObjectName);
+ SetDlgItemTextW(hDlg, IDC_PPSLPASS, EMPTY_PASSWORD);
+ SetDlgItemTextW(hDlg, IDC_PPSLCPASS, EMPTY_PASSWORD);
+ }
+ else {
+ CheckRadioButton(hDlg, IDC_PPSLLS, IDC_PPSLUA, IDC_PPSLLS);
+ if (_currentEntry->lpConfig->dwServiceType &
+ SERVICE_INTERACTIVE_PROCESS)
+ CheckDlgButton(hDlg, IDC_PPSLID, BST_CHECKED);
+ }
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLID), !bAccount);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLUSER), bAccount);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLBROWSE), bAccount);
+ EnableWindow(GetDlgItem(hDlg, IDL_PPSLPASS), bAccount);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLPASS), bAccount);
+ EnableWindow(GetDlgItem(hDlg, IDL_PPSLCPASS), bAccount);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLCPASS), bAccount);
+ }
+ break;
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_PPSLLS:
+ SetDlgItemTextW(hDlg, IDC_PPSLUSER, L"");
+ SetDlgItemTextW(hDlg, IDC_PPSLPASS, L"");
+ SetDlgItemTextW(hDlg, IDC_PPSLCPASS, L"");
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLID), TRUE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLUSER), FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLBROWSE), FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDL_PPSLPASS), FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLPASS), FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDL_PPSLCPASS), FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLCPASS), FALSE);
+ CheckRadioButton(hDlg, IDC_PPSLLS, IDC_PPSLUA, (INT)wParam);
+ if (lstrcmpiW(_currentEntry->szObjectName, STAT_SYSTEM)) {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 2);
+ }
+ else {
+ PropSheet_UnChanged(GetParent(hDlg), hDlg);
+ CLR_BIT_FLAG(_propertyChanged, 2);
+ }
+ break;
+ case IDC_PPSLUA:
+ SetDlgItemTextW(hDlg, IDC_PPSLUSER, _currentEntry->szObjectName);
+ SetDlgItemTextW(hDlg, IDC_PPSLPASS, EMPTY_PASSWORD);
+ SetDlgItemTextW(hDlg, IDC_PPSLCPASS, EMPTY_PASSWORD);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLID), FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLUSER), TRUE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLBROWSE), TRUE);
+ EnableWindow(GetDlgItem(hDlg, IDL_PPSLPASS), TRUE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLPASS), TRUE);
+ EnableWindow(GetDlgItem(hDlg, IDL_PPSLCPASS), TRUE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSLCPASS), TRUE);
+ CheckRadioButton(hDlg, IDC_PPSLLS, IDC_PPSLUA, (INT)wParam);
+ if (lstrcmpW(_currentEntry->szObjectName, STAT_SYSTEM)) {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 2);
+ }
+ else {
+ PropSheet_UnChanged(GetParent(hDlg), hDlg);
+ CLR_BIT_FLAG(_propertyChanged, 2);
+ }
+ break;
+ case IDC_PPSLID:
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 2);
+ break;
+ case IDC_PPSLUSER:
+ if (HIWORD(wParam) == EN_CHANGE) {
+ GetDlgItemTextW(hDlg, IDC_PPSLUSER, szBuf, 63);
+ if (!lstrcmpiW(szBuf, _currentEntry->szObjectName)) {
+ PropSheet_UnChanged(GetParent(hDlg), hDlg);
+ CLR_BIT_FLAG(_propertyChanged, 2);
+ }
+ else {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 2);
+ }
+ }
+ break;
+ case IDC_PPSLPASS:
+ case IDC_PPSLCPASS:
+ if (HIWORD(wParam) == EN_CHANGE) {
+ WCHAR szP[64];
+ WCHAR szC[64];
+ GetDlgItemTextW(hDlg, IDC_PPSLPASS, szP, 63);
+ GetDlgItemTextW(hDlg, IDC_PPSLCPASS, szC, 63);
+ /* check for valid password match */
+ if (szP[0] == L' ' && szC[0] == L' ') {
+ PropSheet_UnChanged(GetParent(hDlg), hDlg);
+ CLR_BIT_FLAG(_propertyChanged, 2);
+ }
+ else if (!lstrcmpW(szP, szC)) {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 2);
+ }
+ }
+ break;
+ case IDC_PPSLBROWSE:
+ {
+ WCHAR szUser[SIZ_RESLEN];
+ if (apxDlgSelectUser(hDlg, szUser))
+ SetDlgItemTextW(hDlg, IDC_PPSLUSER, szUser);
+ }
+ break;
+ }
+ break;
+ case WM_NOTIFY:
+ lpShn = (LPPSHNOTIFY )lParam;
+ switch (lpShn->hdr.code) {
+ case PSN_APPLY: /* sent when OK or Apply button pressed */
+ if (__generalLogonSave(hDlg))
+ PropSheet_UnChanged(GetParent(hDlg), hDlg);
+ else {
+ SET_BIT_FLAG(_propertyChanged, 2);
+ SetWindowLong(hDlg, DWLP_MSGRESULT,
+ PSNRET_INVALID_NOCHANGEPAGE);
+ return TRUE;
+ }
+
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+ return FALSE;
+}
+
+LRESULT CALLBACK __loggingProperty(HWND hDlg,
+ UINT uMessage,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ LPPSHNOTIFY lpShn;
+ LPWSTR lpBuf;
+
+ switch (uMessage) {
+ case WM_INITDIALOG:
+ {
+ LPWSTR b;
+ startPage = 2;
+ if (!bpropCentered)
+ apxCenterWindow(GetParent(hDlg), NULL);
+ bpropCentered = TRUE;
+ ComboBox_AddStringW(GetDlgItem(hDlg, IDC_PPLGLEVEL), LOGL_ERROR);
+ ComboBox_AddStringW(GetDlgItem(hDlg, IDC_PPLGLEVEL), LOGL_INFO);
+ ComboBox_AddStringW(GetDlgItem(hDlg, IDC_PPLGLEVEL), LOGL_WARN);
+ ComboBox_AddStringW(GetDlgItem(hDlg, IDC_PPLGLEVEL), LOGL_DEBUG);
+ if ((b = apxRegistryGetStringW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_log, L"Level")) != NULL) {
+ if (!lstrcmpiW(b, LOGL_ERROR))
+ ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_PPLGLEVEL), 0);
+ else if (!lstrcmpiW(b, LOGL_INFO))
+ ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_PPLGLEVEL), 1);
+ else if (!lstrcmpiW(b, LOGL_WARN))
+ ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_PPLGLEVEL), 2);
+ else
+ ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_PPLGLEVEL), 3);
+ apxFree(b);
+ }
+ else
+ ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_PPLGLEVEL), 0);
+ if ((b = apxRegistryGetStringW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_log, L"Path")) != NULL) {
+ SetDlgItemTextW(hDlg, IDC_PPLGPATH, b);
+ apxFree(b);
+ }
+ if ((b = apxRegistryGetStringW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_log, L"StdOutput")) != NULL) {
+ SetDlgItemTextW(hDlg, IDC_PPLGSTDOUT, b);
+ apxFree(b);
+ }
+ if ((b = apxRegistryGetStringW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_log, L"StdError")) != NULL) {
+ SetDlgItemTextW(hDlg, IDC_PPLGSTDERR, b);
+ apxFree(b);
+ }
+ }
+ break;
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_PPLGLEVEL:
+ if (HIWORD(wParam) == CBN_SELCHANGE) {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 3);
+ }
+ break;
+ case IDC_PPLGPATH:
+ if (HIWORD(wParam) == EN_CHANGE) {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 3);
+ }
+ break;
+ case IDC_PPLGPREFIX:
+ if (HIWORD(wParam) == EN_CHANGE) {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 3);
+ }
+ break;
+ case IDC_PPLGSTDERR:
+ if (HIWORD(wParam) == EN_CHANGE) {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 3);
+ }
+ break;
+ case IDC_PPLGSTDOUT:
+ if (HIWORD(wParam) == EN_CHANGE) {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 3);
+ }
+ break;
+ case IDC_PPLGBPATH:
+ lpBuf = apxBrowseForFolderW(hDlg, apxLoadResourceW(IDS_LGPATHTITLE, 0),
+ NULL);
+ if (lpBuf) {
+ SetDlgItemTextW(hDlg, IDC_PPLGPATH, lpBuf);
+ apxFree(lpBuf);
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 3);
+ }
+ break;
+ case IDC_PPLGBSTDOUT:
+ lpBuf = apxGetFileNameW(hDlg, apxLoadResourceW(IDS_LGSTDOUT, 0),
+ apxLoadResourceW(IDS_ALLFILES, 1), NULL,
+ NULL, FALSE, NULL);
+ if (lpBuf) {
+ SetDlgItemTextW(hDlg, IDC_PPLGSTDOUT, lpBuf);
+ apxFree(lpBuf);
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 3);
+ }
+ break;
+ case IDC_PPLGBSTDERR:
+ lpBuf = apxGetFileNameW(hDlg, apxLoadResourceW(IDS_LGSTDERR, 0),
+ apxLoadResourceW(IDS_ALLFILES, 1), NULL,
+ NULL, FALSE, NULL);
+ if (lpBuf) {
+ SetDlgItemTextW(hDlg, IDC_PPLGSTDERR, lpBuf);
+ apxFree(lpBuf);
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 3);
+ }
+ break;
+ }
+ break;
+ case WM_NOTIFY:
+ lpShn = (LPPSHNOTIFY )lParam;
+ switch (lpShn->hdr.code) {
+ case PSN_APPLY: /* sent when OK or Apply button pressed */
+ if (__generalLoggingSave(hDlg))
+ PropSheet_UnChanged(GetParent(hDlg), hDlg);
+ else {
+ SET_BIT_FLAG(_propertyChanged, 3);
+ SetWindowLong(hDlg, DWLP_MSGRESULT,
+ PSNRET_INVALID_NOCHANGEPAGE);
+ return TRUE;
+ }
+
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+ return FALSE;
+}
+
+LRESULT CALLBACK __jvmProperty(HWND hDlg,
+ UINT uMessage,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ LPPSHNOTIFY lpShn;
+ LPWSTR lpBuf, b;
+ DWORD v;
+ CHAR bn[32];
+
+ switch (uMessage) {
+ case WM_INITDIALOG:
+ {
+ startPage = 3;
+ if (!bpropCentered)
+ apxCenterWindow(GetParent(hDlg), NULL);
+ bpropCentered = TRUE;
+ if ((lpBuf = apxRegistryGetStringW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_java, L"Jvm")) != NULL) {
+ if (!lstrcmpiW(lpBuf, L"auto")) {
+ CheckDlgButton(hDlg, IDC_PPJAUTO, BST_CHECKED);
+ apxFree(lpBuf);
+ lpBuf = apxGetJavaSoftRuntimeLib(hPool);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPJJVM), FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPJBJVM), FALSE);
+ }
+ if (lpBuf) {
+ SetDlgItemTextW(hDlg, IDC_PPJJVM, lpBuf);
+ apxFree(lpBuf);
+ }
+ }
+ if ((lpBuf = apxRegistryGetStringW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_java, L"Classpath")) != NULL) {
+ SetDlgItemTextW(hDlg, IDC_PPJCLASSPATH, lpBuf);
+ apxFree(lpBuf);
+ }
+ if ((lpBuf = apxRegistryGetMzStrW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_java, L"Options", NULL, NULL)) != NULL) {
+ LPWSTR p = apxMszToCRLFW(hPool, lpBuf);
+ SetDlgItemTextW(hDlg, IDC_PPJOPTIONS, p);
+ apxFree(lpBuf);
+ apxFree(p);
+ }
+ v = apxRegistryGetNumberW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_java, L"JvmMs");
+ if (v && v != 0xFFFFFFFF) {
+ wsprintfA(bn, "%d", v);
+ SetDlgItemTextA(hDlg, IDC_PPJMS, bn);
+ }
+ v = apxRegistryGetNumberW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_java, L"JvmMx");
+ if (v && v != 0xFFFFFFFF) {
+ wsprintfA(bn, "%d", v);
+ SetDlgItemTextA(hDlg, IDC_PPJMX, bn);
+ }
+ v = apxRegistryGetNumberW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_java, L"JvmSs");
+ if (v && v != 0xFFFFFFFF) {
+ wsprintfA(bn, "%d", v);
+ SetDlgItemTextA(hDlg, IDC_PPJSS, bn);
+ }
+
+ }
+ break;
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_PPJBJVM:
+ b = apxGetJavaSoftHome(hPool, TRUE);
+ lpBuf = apxGetFileNameW(hDlg, apxLoadResourceW(IDS_PPJBJVM, 0),
+ apxLoadResourceW(IDS_DLLFILES, 1), NULL,
+ b,
+ TRUE, NULL);
+ apxFree(b);
+ if (lpBuf) {
+ SetDlgItemTextW(hDlg, IDC_PPJJVM, lpBuf);
+ apxFree(lpBuf);
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 4);
+ }
+ break;
+ case IDC_PPJAUTO:
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 4);
+ if (IsDlgButtonChecked(hDlg, IDC_PPJAUTO)) {
+ EnableWindow(GetDlgItem(hDlg, IDC_PPJJVM), FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPJBJVM), FALSE);
+ lpBuf = apxGetJavaSoftRuntimeLib(hPool);
+ if (lpBuf) {
+ SetDlgItemTextW(hDlg, IDC_PPJJVM, lpBuf);
+ apxFree(lpBuf);
+ }
+ }
+ else {
+ EnableWindow(GetDlgItem(hDlg, IDC_PPJJVM), TRUE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPJBJVM), TRUE);
+ }
+ break;
+ case IDC_PPJJVM:
+ case IDC_PPJCLASSPATH:
+ case IDC_PPJOPTIONS:
+ case IDC_PPJMX:
+ case IDC_PPJMS:
+ case IDC_PPJSS:
+ if (HIWORD(wParam) == EN_CHANGE) {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 4);
+ }
+ break;
+ }
+ break;
+ case WM_NOTIFY:
+ lpShn = (LPPSHNOTIFY )lParam;
+ switch (lpShn->hdr.code) {
+ case PSN_APPLY: /* sent when OK or Apply button pressed */
+ if (__generalJvmSave(hDlg))
+ PropSheet_UnChanged(GetParent(hDlg), hDlg);
+ else {
+ SET_BIT_FLAG(_propertyChanged, 4);
+ SetWindowLong(hDlg, DWLP_MSGRESULT,
+ PSNRET_INVALID_NOCHANGEPAGE);
+ return TRUE;
+ }
+
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+ return FALSE;
+}
+
+LRESULT CALLBACK __startProperty(HWND hDlg,
+ UINT uMessage,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ LPPSHNOTIFY lpShn;
+ LPWSTR lpBuf, b;
+
+ switch (uMessage) {
+ case WM_INITDIALOG:
+ {
+ startPage = 4;
+ if (!bpropCentered)
+ apxCenterWindow(GetParent(hDlg), NULL);
+ bpropCentered = TRUE;
+
+ ComboBox_AddStringW(GetDlgItem(hDlg, IDC_PPRMODE), L"");
+ ComboBox_AddStringW(GetDlgItem(hDlg, IDC_PPRMODE), L"jvm");
+ ComboBox_AddStringW(GetDlgItem(hDlg, IDC_PPRMODE), _s_java);
+
+ if ((lpBuf = apxRegistryGetStringW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_start, L"Class")) != NULL) {
+ SetDlgItemTextW(hDlg, IDC_PPRCLASS, lpBuf);
+ apxFree(lpBuf);
+ }
+ if ((lpBuf = apxRegistryGetStringW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_start, L"Image")) != NULL) {
+ SetDlgItemTextW(hDlg, IDC_PPRIMAGE, lpBuf);
+ apxFree(lpBuf);
+ }
+ if ((lpBuf = apxRegistryGetStringW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_start, L"WorkingPath")) != NULL) {
+ SetDlgItemTextW(hDlg, IDC_PPRWPATH, lpBuf);
+ apxFree(lpBuf);
+ }
+ if ((lpBuf = apxRegistryGetStringW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_start, L"Method")) != NULL) {
+ SetDlgItemTextW(hDlg, IDC_PPRMETHOD, lpBuf);
+ apxFree(lpBuf);
+ }
+ if ((lpBuf = apxRegistryGetMzStrW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_start, L"Params", NULL, NULL)) != NULL) {
+ b = apxMszToCRLFW(hPool, lpBuf);
+ SetDlgItemTextW(hDlg, IDC_PPRARGS, b);
+ apxFree(lpBuf);
+ apxFree(b);
+ }
+ if ((lpBuf = apxRegistryGetStringW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_start, L"Mode")) != NULL) {
+ if (!lstrcmpiW(lpBuf, L"jvm")) {
+ ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_PPRMODE), 1);
+
+ }
+ else if (!lstrcmpiW(lpBuf, _s_java)) {
+ ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_PPRMODE), 2);
+ }
+ else {
+ ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_PPRMODE), 0);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPRIMAGE), TRUE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPRBIMAGE), TRUE);
+ }
+ apxFree(lpBuf);
+ }
+ }
+ break;
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_PPRBWPATH:
+ lpBuf = apxBrowseForFolderW(hDlg, apxLoadResourceW(IDS_PPWPATH, 0),
+ NULL);
+ if (lpBuf) {
+ SetDlgItemTextW(hDlg, IDC_PPRWPATH, lpBuf);
+ apxFree(lpBuf);
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 5);
+ }
+ break;
+ case IDC_PPRBIMAGE:
+ lpBuf = apxGetFileNameW(hDlg, apxLoadResourceW(IDS_PPIMAGE, 0),
+ apxLoadResourceW(IDS_EXEFILES, 1), NULL,
+ NULL, TRUE, NULL);
+ if (lpBuf) {
+ SetDlgItemTextW(hDlg, IDC_PPRIMAGE, lpBuf);
+ apxFree(lpBuf);
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 5);
+ }
+ break;
+ case IDC_PPRCLASS:
+ case IDC_PPRMETHOD:
+ case IDC_PPRARGS:
+ case IDC_PPRIMAGE:
+ case IDC_PPRWPATH:
+ if (HIWORD(wParam) == EN_CHANGE) {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 5);
+ }
+ break;
+ case IDC_PPRMODE:
+ if (HIWORD(wParam) == CBN_SELCHANGE) {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 5);
+ if (ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_PPRMODE))) {
+ EnableWindow(GetDlgItem(hDlg, IDC_PPRIMAGE), FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPRBIMAGE), FALSE);
+ }
+ else {
+ EnableWindow(GetDlgItem(hDlg, IDC_PPRIMAGE), TRUE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPRBIMAGE), TRUE);
+ }
+ }
+ break;
+
+ }
+ break;
+ case WM_NOTIFY:
+ lpShn = (LPPSHNOTIFY )lParam;
+ switch (lpShn->hdr.code) {
+ case PSN_APPLY: /* sent when OK or Apply button pressed */
+ if (__generalStartSave(hDlg))
+ PropSheet_UnChanged(GetParent(hDlg), hDlg);
+ else {
+ SET_BIT_FLAG(_propertyChanged, 5);
+ SetWindowLong(hDlg, DWLP_MSGRESULT,
+ PSNRET_INVALID_NOCHANGEPAGE);
+ return TRUE;
+ }
+
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+ return FALSE;
+}
+
+LRESULT CALLBACK __stopProperty(HWND hDlg,
+ UINT uMessage,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ LPPSHNOTIFY lpShn;
+ LPWSTR lpBuf, b;
+ DWORD v;
+
+ switch (uMessage) {
+ case WM_INITDIALOG:
+ {
+ startPage = 5;
+ if (!bpropCentered)
+ apxCenterWindow(GetParent(hDlg), NULL);
+ bpropCentered = TRUE;
+
+ ComboBox_AddStringW(GetDlgItem(hDlg, IDC_PPSMODE), L"");
+ ComboBox_AddStringW(GetDlgItem(hDlg, IDC_PPSMODE), L"jvm");
+ ComboBox_AddStringW(GetDlgItem(hDlg, IDC_PPSMODE), _s_java);
+
+ if ((lpBuf = apxRegistryGetStringW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_stop, L"Class")) != NULL) {
+ SetDlgItemTextW(hDlg, IDC_PPSCLASS, lpBuf);
+ apxFree(lpBuf);
+ }
+ if ((lpBuf = apxRegistryGetStringW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_stop, L"Image")) != NULL) {
+ SetDlgItemTextW(hDlg, IDC_PPSIMAGE, lpBuf);
+ apxFree(lpBuf);
+ }
+ if ((lpBuf = apxRegistryGetStringW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_stop, L"WorkingPath")) != NULL) {
+ SetDlgItemTextW(hDlg, IDC_PPSWPATH, lpBuf);
+ apxFree(lpBuf);
+ }
+ if ((lpBuf = apxRegistryGetStringW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_stop, L"Method")) != NULL) {
+ SetDlgItemTextW(hDlg, IDC_PPSMETHOD, lpBuf);
+ apxFree(lpBuf);
+ }
+ if ((lpBuf = apxRegistryGetMzStrW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_stop, L"Params", NULL, NULL)) != NULL) {
+ b = apxMszToCRLFW(hPool, lpBuf);
+ SetDlgItemTextW(hDlg, IDC_PPSARGS, b);
+ apxFree(lpBuf);
+ apxFree(b);
+ }
+ v = apxRegistryGetNumberW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_stop, L"Timeout");
+ {
+ CHAR bn[32];
+ wsprintfA(bn, "%d", v);
+ SetDlgItemTextA(hDlg, IDC_PPSTIMEOUT, bn);
+ }
+ if ((lpBuf = apxRegistryGetStringW(hRegserv, APXREG_PARAMSOFTWARE,
+ _s_stop, L"Mode")) != NULL) {
+ if (!lstrcmpiW(lpBuf, L"jvm")) {
+ ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_PPSMODE), 1);
+
+ }
+ else if (!lstrcmpiW(lpBuf, _s_java)) {
+ ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_PPSMODE), 2);
+ }
+ else {
+ ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_PPSMODE), 0);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSIMAGE), TRUE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSBIMAGE), TRUE);
+ }
+ apxFree(lpBuf);
+ }
+ }
+ break;
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_PPSBWPATH:
+ lpBuf = apxBrowseForFolderW(hDlg, apxLoadResourceW(IDS_PPWPATH, 0),
+ NULL);
+ if (lpBuf) {
+ SetDlgItemTextW(hDlg, IDC_PPSWPATH, lpBuf);
+ apxFree(lpBuf);
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 6);
+ }
+ break;
+ case IDC_PPSBIMAGE:
+ lpBuf = apxGetFileNameW(hDlg, apxLoadResourceW(IDS_PPIMAGE, 0),
+ apxLoadResourceW(IDS_EXEFILES, 1), NULL,
+ NULL, TRUE, NULL);
+ if (lpBuf) {
+ SetDlgItemTextW(hDlg, IDC_PPSIMAGE, lpBuf);
+ apxFree(lpBuf);
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 6);
+ }
+ break;
+ case IDC_PPSCLASS:
+ case IDC_PPSMETHOD:
+ case IDC_PPSTIMEOUT:
+ case IDC_PPSARGS:
+ case IDC_PPSIMAGE:
+ case IDC_PPSWPATH:
+ if (HIWORD(wParam) == EN_CHANGE) {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 6);
+ }
+ break;
+ case IDC_PPSMODE:
+ if (HIWORD(wParam) == CBN_SELCHANGE) {
+ PropSheet_Changed(GetParent(hDlg), hDlg);
+ SET_BIT_FLAG(_propertyChanged, 6);
+ if (ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_PPSMODE))) {
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSIMAGE), FALSE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSBIMAGE), FALSE);
+ }
+ else {
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSIMAGE), TRUE);
+ EnableWindow(GetDlgItem(hDlg, IDC_PPSBIMAGE), TRUE);
+ }
+ }
+ break;
+
+ }
+ break;
+ case WM_NOTIFY:
+ lpShn = (LPPSHNOTIFY )lParam;
+ switch (lpShn->hdr.code) {
+ case PSN_APPLY: /* sent when OK or Apply button pressed */
+ if (__generalStopSave(hDlg))
+ PropSheet_UnChanged(GetParent(hDlg), hDlg);
+ else {
+ SET_BIT_FLAG(_propertyChanged, 6);
+ SetWindowLong(hDlg, DWLP_MSGRESULT,
+ PSNRET_INVALID_NOCHANGEPAGE);
+ return TRUE;
+ }
+
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+ return FALSE;
+}
+
+void __initPpage(PROPSHEETPAGEW *lpPage, INT iDlg, INT iTitle, DLGPROC pfnDlgProc)
+{
+ lpPage->dwSize = sizeof(PROPSHEETPAGE);
+ lpPage->dwFlags = PSP_USETITLE;
+ lpPage->hInstance = _gui_store->hInstance;
+ lpPage->pszTemplate = MAKEINTRESOURCEW(iDlg);
+ lpPage->pszIcon = NULL;
+ lpPage->pfnDlgProc = pfnDlgProc;
+ lpPage->pszTitle = MAKEINTRESOURCEW(iTitle);
+ lpPage->lParam = 0;
+}
+
+void ShowServiceProperties(HWND hWnd)
+{
+ PROPSHEETPAGEW psP[6];
+ PROPSHEETHEADERW psH;
+ WCHAR szT[1024] = {0};
+
+ if (_propertyOpened) {
+ SetForegroundWindow(_gui_store->hMainWnd);
+ return;
+ }
+ __initPpage(&psP[0], IDD_PROPPAGE_SGENERAL, IDS_PPGENERAL,
+ __generalProperty);
+ __initPpage(&psP[1], IDD_PROPPAGE_LOGON, IDS_PPLOGON,
+ __logonProperty);
+ __initPpage(&psP[2], IDD_PROPPAGE_LOGGING, IDS_PPLOGGING,
+ __loggingProperty);
+ __initPpage(&psP[3], IDD_PROPPAGE_JVM, IDS_PPJAVAVM,
+ __jvmProperty);
+ __initPpage(&psP[4], IDD_PROPPAGE_START, IDS_PPSTART,
+ __startProperty);
+ __initPpage(&psP[5], IDD_PROPPAGE_STOP, IDS_PPSTOP,
+ __stopProperty);
+
+ if (_currentEntry && _currentEntry->lpConfig)
+ lstrcpyW(szT, _currentEntry->lpConfig->lpDisplayName);
+ else
+ return;
+ lstrcatW(szT, L" Properties");
+
+ psH.dwSize = sizeof(PROPSHEETHEADER);
+ psH.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK | PSH_NOCONTEXTHELP;
+ psH.hwndParent = bEnableTry ? hWnd : NULL;
+ psH.hInstance = _gui_store->hInstance;
+ psH.pszIcon = MAKEINTRESOURCEW(IDI_MAINICON);
+ psH.pszCaption = szT;
+ psH.nPages = 6;
+ psH.ppsp = (LPCPROPSHEETPAGEW) &psP;
+ psH.pfnCallback = (PFNPROPSHEETCALLBACK)__propertyCallback;
+ psH.nStartPage = startPage;
+
+ PropertySheetW(&psH);
+ _propertyOpened = FALSE;
+ if (!bEnableTry)
+ PostQuitMessage(0);
+ bpropCentered = FALSE;
+
+}
+
+static void signalService(LPCWSTR szServiceName)
+{
+ HANDLE event;
+ WCHAR en[SIZ_DESLEN];
+ int i;
+ lstrcpyW(en, szServiceName);
+ lstrcatW(en, L"SIGNAL");
+ for (i = 0; i < lstrlenW(en); i++) {
+ if (en[i] >= L'a' && en[i] <= L'z')
+ en[i] = en[i] - 32;
+ }
+
+
+ event = OpenEventW(EVENT_MODIFY_STATE, FALSE, en);
+ if (event) {
+ SetEvent(event);
+ CloseHandle(event);
+ }
+ else
+ apxDisplayError(TRUE, NULL, 0, "Unable to open the Event Mutex");
+
+}
+
+LRESULT CALLBACK MainWndProc(HWND hWnd, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ switch (uMsg) {
+ case WM_CREATE:
+ if (bEnableTry) {
+ if (_currentEntry && _currentEntry->lpConfig) {
+ BOOL isRunning = _currentEntry->stServiceStatus.dwCurrentState == SERVICE_RUNNING;
+ apxManageTryIconW(hWnd, NIM_ADD, NULL,
+ _currentEntry->lpConfig->lpDisplayName,
+ isRunning ? hIcoRun : hIcoStop);
+ }
+ else {
+ apxManageTryIconA(hWnd, NIM_ADD, NULL,
+ apxLoadResourceA(IDS_APPLICATION, 0),
+ NULL);
+ }
+ }
+ else
+ ShowServiceProperties(hWnd);
+
+ break;
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDM_TM_CONFIG:
+ ShowServiceProperties(hWnd);
+ break;
+ case IDM_TM_ABOUT:
+ apxAboutBox(hWnd);
+ break;
+ case IDM_TM_EXIT:
+ SendMessage(hWnd, WM_CLOSE, 0, 0);
+ break;
+ case IDM_TM_START:
+ if (!_propertyOpened)
+ apxProgressBox(hWnd, apxLoadResource(IDS_HSSTART, 0),
+ _currentEntry->lpConfig->lpDisplayName,
+ __startServiceCallback, NULL);
+ break;
+ case IDM_TM_STOP:
+ if (!_propertyOpened)
+ apxProgressBox(hWnd, apxLoadResource(IDS_HSSTOP, 0),
+ _currentEntry->lpConfig->lpDisplayName,
+ __stopServiceCallback, NULL);
+ break;
+ case IDM_TM_PAUSE:
+ if (!_propertyOpened)
+ apxProgressBox(hWnd, apxLoadResource(IDS_HSPAUSE, 0),
+ _currentEntry->lpConfig->lpDisplayName,
+ __pauseServiceCallback, NULL);
+ break;
+ case IDM_TM_RESTART:
+ if (!_propertyOpened)
+ apxProgressBox(hWnd, apxLoadResource(IDS_HSRESTART, 0),
+ _currentEntry->lpConfig->lpDisplayName,
+ __restartServiceCallback, NULL);
+ break;
+ case IDM_TM_DUMP:
+ signalService(_currentEntry->szServiceName);
+ break;
+ case IDMS_REFRESH:
+ if (bEnableTry &&
+ (_currentEntry = apxServiceEntry(hService, TRUE)) != NULL) {
+ BOOL isRunning = _currentEntry->stServiceStatus.dwCurrentState == SERVICE_RUNNING;
+ apxManageTryIconW(hWnd, NIM_MODIFY, NULL,
+ _currentEntry->lpConfig->lpDisplayName,
+ isRunning ? hIcoRun : hIcoStop);
+ }
+ break;
+
+ }
+ break;
+ case WM_TRAYMESSAGE:
+ switch(lParam) {
+ case WM_LBUTTONDBLCLK:
+ ShowServiceProperties(hWnd);
+ break;
+ case WM_RBUTTONUP:
+ _currentEntry = apxServiceEntry(hService, TRUE);
+ createRbuttonTryMenu(hWnd);
+ break;
+ }
+ break;
+ case WM_QUIT:
+ return DefWindowProc(hWnd, uMsg, wParam, lParam);
+ break;
+ case WM_DESTROY:
+ if (bEnableTry)
+ apxManageTryIconA(hWnd, NIM_DELETE, NULL, NULL, NULL);
+ PostQuitMessage(0);
+ break;
+ default:
+ return DefWindowProc(hWnd, uMsg, wParam, lParam);
+ break;
+ }
+
+ return FALSE;
+}
+
+static BOOL loadConfiguration()
+{
+ return TRUE;
+}
+
+static BOOL saveConfiguration()
+{
+ return TRUE;
+}
+
+/* Main program entry
+ * Since we are inependant from CRT
+ * the arguments are not used
+ */
+#ifdef _NO_CRTLIBRARY
+int xMain(void)
+#else
+int WINAPI WinMain(HINSTANCE hInstance,
+ HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine,
+ int nCmdShow)
+#endif
+{
+ MSG msg;
+ LPAPXCMDLINE lpCmdline;
+ HANDLE mutex = NULL;
+ BOOL quiet = FALSE;
+
+ apxHandleManagerInitialize();
+ hPool = apxPoolCreate(NULL, 0);
+
+ /* Parse the command line */
+ if ((lpCmdline = apxCmdlineParse(hPool, _options, _commands)) == NULL) {
+ /* TODO: dispalay error message */
+ apxDisplayError(TRUE, NULL, 0, "Error parsing command line");
+ goto cleanup;
+ }
+
+ if (!lpCmdline->dwCmdIndex) {
+ /* Skip sytem error message */
+ SetLastError(ERROR_SUCCESS);
+ apxDisplayError(TRUE, NULL, 0,
+ apxLoadResourceA(IDS_ERRORCMD, 0),
+ lpCmdLine);
+ goto cleanup;
+ }
+ else if (lpCmdline->dwCmdIndex == 4)
+ quiet = TRUE;
+ else if (lpCmdline->dwCmdIndex >= 2)
+ bEnableTry = TRUE;
+ hService = apxCreateService(hPool, SC_MANAGER_CONNECT, FALSE);
+ if (IS_INVALID_HANDLE(hService)) {
+ if (!quiet)
+ apxDisplayError(TRUE, NULL, 0, "Unable to open the Service Manager");
+ goto cleanup;
+ }
+ /* Open the main service handle */
+ if (!apxServiceOpen(hService, lpCmdline->szApplication,
+ GENERIC_READ | GENERIC_EXECUTE)) {
+ LPWSTR w = lpCmdline->szApplication + lstrlenW(lpCmdline->szApplication) - 1;
+ if (*w == L'w')
+ *w = L'\0';
+ if (!apxServiceOpen(hService, lpCmdline->szApplication,
+ GENERIC_READ | GENERIC_EXECUTE)) {
+ if (!quiet)
+ apxDisplayError(TRUE, NULL, 0, "Unable to open the service '%S'",
+ lpCmdline->szApplication);
+ goto cleanup;
+ }
+ }
+ /* Obtain service parameters and status */
+ if (!(_currentEntry = apxServiceEntry(hService, TRUE))) {
+ if (!quiet)
+ apxDisplayError(TRUE, NULL, 0, "Unable to query the service '%S' status",
+ lpCmdline->szApplication);
+ goto cleanup;
+ }
+#ifdef _UNICODE
+ _gui_store = apxGuiInitialize(MainWndProc, lpCmdline->szApplication);
+#else
+ {
+ CHAR szApp[MAX_PATH];
+ _gui_store = apxGuiInitialize(MainWndProc,
+ WideToAscii(lpCmdline->szApplication, szApp));
+ }
+#endif
+ if (!_gui_store) {
+ if (!quiet)
+ apxDisplayError(TRUE, NULL, 0, "Unable to initialize GUI manager");
+ goto cleanup;
+ }
+ hIcoRun = LoadImage(_gui_store->hInstance, MAKEINTRESOURCE(IDI_ICONRUN),
+ IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
+ hIcoStop = LoadImage(_gui_store->hInstance, MAKEINTRESOURCE(IDI_ICONSTOP),
+ IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
+
+ /* Handle //MQ// option */
+ if (lpCmdline->dwCmdIndex == 4) {
+ HANDLE hOther = FindWindow(_gui_store->szWndClass, NULL);
+ if (hOther)
+ SendMessage(hOther, WM_CLOSE, 0, 0);
+ goto cleanup;
+ }
+
+ if (!_options[0].dwValue) {
+ mutex = CreateMutex(NULL, FALSE, _gui_store->szWndMutex);
+ if ((mutex == NULL) || (GetLastError() == ERROR_ALREADY_EXISTS)) {
+ /* Skip sytem error message */
+ SetLastError(ERROR_SUCCESS);
+ if (!quiet)
+ apxDisplayError(TRUE, NULL, 0, apxLoadResourceA(IDS_ALREAY_RUNING, 0),
+ lpCmdline->szApplication);
+ goto cleanup;
+ }
+ }
+ hRegistry = apxCreateRegistry(hPool, KEY_ALL_ACCESS, NULL,
+ apxLoadResource(IDS_APPLICATION, 0),
+ APXREG_USER);
+ loadConfiguration();
+ hRegserv = apxCreateRegistryW(hPool, KEY_READ | KEY_WRITE, PRG_REGROOT,
+ lpCmdline->szApplication,
+ APXREG_SOFTWARE | APXREG_SERVICE);
+
+ if (IS_INVALID_HANDLE(hRegserv)) {
+ if (!quiet)
+ apxDisplayError(TRUE, NULL, 0, apxLoadResourceA(IDS_ERRSREG, 0));
+ return FALSE;
+ }
+ /* Create main invisible window */
+ _gui_store->hMainWnd = CreateWindow(_gui_store->szWndClass,
+ apxLoadResource(IDS_APPLICATION, 0),
+ 0, 0, 0, 0, 0,
+ NULL, NULL,
+ _gui_store->hInstance,
+ NULL);
+
+ if (!_gui_store->hMainWnd) {
+ goto cleanup;
+ }
+ if (lpCmdline->dwCmdIndex == 3)
+ PostMessage(_gui_store->hMainWnd, WM_COMMAND, IDM_TM_START, 0);
+
+ while (GetMessage(&msg, NULL, 0, 0)) {
+ if(!TranslateAccelerator(_gui_store->hMainWnd,
+ _gui_store->hAccel, &msg)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+ saveConfiguration();
+
+cleanup:
+ if (hIcoStop)
+ DestroyIcon(hIcoStop);
+ if (hIcoRun)
+ DestroyIcon(hIcoRun);
+ if (mutex)
+ CloseHandle(mutex);
+ if (lpCmdline)
+ apxCmdlineFree(lpCmdline);
+ apxCloseHandle(hService);
+ apxHandleManagerDestroy();
+ ExitProcess(0);
+ return 0;
+}
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.dsp
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.dsp 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.dsp 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,172 @@
+# Microsoft Developer Studio Project File - Name="prunmgr" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=prunmgr - Win32 Unicode 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 "prunmgr.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 "prunmgr.mak" CFG="prunmgr - Win32 Unicode Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "prunmgr - Win32 Release" (based on "Win32 (x86) Application")
+!MESSAGE "prunmgr - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE "prunmgr - Win32 Unicode Release" (based on "Win32 (x86) Application")
+!MESSAGE "prunmgr - Win32 Unicode Debug" (based on "Win32 (x86) Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "prunmgr - 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 Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x41a /d "NDEBUG"
+# ADD RSC /l 0x41a /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 /nologo /subsystem:windows /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 shlwapi.lib comctl32.lib netapi32.lib /nologo /subsystem:windows /machine:I386
+
+!ELSEIF "$(CFG)" == "prunmgr - 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 "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x41a /d "_DEBUG"
+# ADD RSC /l 0x41a /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 /nologo /subsystem:windows /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 shlwapi.lib comctl32.lib netapi32.lib /nologo /subsystem:windows /debug /machine:I386 /out:"Debug/prunmgrd.exe" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "prunmgr - Win32 Unicode Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Unicode Release"
+# PROP BASE Intermediate_Dir "Unicode Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Unicode Release"
+# PROP Intermediate_Dir "Unicode Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x41a /d "NDEBUG"
+# ADD RSC /l 0x41a /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 shlwapi.lib comctl32.lib netapi32.lib /nologo /subsystem:windows /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 shlwapi.lib comctl32.lib netapi32.lib /nologo /subsystem:windows /machine:I386 /out:"Unicode Release/prunmgru.exe"
+
+!ELSEIF "$(CFG)" == "prunmgr - Win32 Unicode Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Unicode Debug"
+# PROP BASE Intermediate_Dir "Unicode Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Unicode Debug"
+# PROP Intermediate_Dir "Unicode Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x41a /d "_DEBUG"
+# ADD RSC /l 0x41a /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 shlwapi.lib comctl32.lib netapi32.lib /nologo /subsystem:windows /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 shlwapi.lib comctl32.lib netapi32.lib /nologo /subsystem:windows /debug /machine:I386 /out:"Unicode Debug/prunmgrdu.exe" /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "prunmgr - Win32 Release"
+# Name "prunmgr - Win32 Debug"
+# Name "prunmgr - Win32 Unicode Release"
+# Name "prunmgr - Win32 Unicode Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\prunmgr.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\prunmgr.h
+# End Source File
+# 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=.\prunmgr.rc
+# ADD BASE RSC /l 0x41a
+# ADD RSC /l 0x41a /i "..\..\include" /d "USE_MANIFEST"
+# End Source File
+# End Group
+# End Target
+# End Project
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,139 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* ====================================================================
+ * jar2exe -- convert .jar file to WIN32 executable.
+ * Contributed by Mladen Turk <mturk at apache.org>
+ * 05 Aug 2003
+ * ====================================================================
+ */
+
+#ifndef _PRUNMGR_H
+#define _PRUNMGR_H
+
+#undef PRG_VERSION
+#define PRG_VERSION "2.0.1.0"
+#define PRG_REGROOT L"Apache Software Foundation\\Procrun 2.0"
+
+#define IDM_TM_EXIT 2000
+#define IDM_TM_START 2001
+#define IDM_TM_STOP 2002
+#define IDM_TM_PAUSE 2003
+#define IDM_TM_RESTART 2004
+#define IDM_TM_CONFIG 2005
+#define IDM_TM_ABOUT 2006
+#define IDM_TM_DUMP 2007
+
+#define IDMS_REFRESH 2020
+
+#define IDI_ICONSTOP 2030
+#define IDI_ICONRUN 2031
+
+
+
+/* Property pages */
+
+#define IDD_PROPPAGE_SGENERAL 2600
+#define IDC_PPSGNAME 2601
+#define IDC_PPSGDISP 2602
+#define IDC_PPSGDESC 2603
+#define IDC_PPSGDEXE 2604
+#define IDC_PPSGCMBST 2605
+#define IDC_PPSGSTATUS 2606
+#define IDC_PPSGSTART 2607
+#define IDC_PPSGSTOP 2608
+#define IDC_PPSGPAUSE 2609
+#define IDC_PPSGRESTART 2610
+
+#define IDD_PROPPAGE_LOGON 2620
+#define IDC_PPSLLS 2621
+#define IDC_PPSLID 2622
+#define IDC_PPSLUA 2623
+#define IDC_PPSLUSER 2624
+#define IDC_PPSLBROWSE 2625
+#define IDC_PPSLPASS 2626
+#define IDC_PPSLCPASS 2627
+#define IDL_PPSLPASS 2628
+#define IDL_PPSLCPASS 2629
+
+#define IDD_PROPPAGE_LOGGING 2640
+#define IDC_PPLGLEVEL 2641
+#define IDC_PPLGPATH 2642
+#define IDC_PPLGBPATH 2643
+#define IDC_PPLGPREFIX 2644
+#define IDC_PPLGSTDOUT 2645
+#define IDC_PPLGBSTDOUT 2646
+#define IDC_PPLGSTDERR 2647
+#define IDC_PPLGBSTDERR 2648
+
+#define IDD_PROPPAGE_JVM 2660
+#define IDC_PPJAUTO 2661
+#define IDC_PPJJVM 2662
+#define IDC_PPJBJVM 2663
+#define IDC_PPJCLASSPATH 2664
+#define IDC_PPJOPTIONS 2665
+#define IDC_PPJMS 2666
+#define IDC_PPJMX 2667
+#define IDC_PPJSS 2668
+
+#define IDD_PROPPAGE_START 2680
+#define IDC_PPRCLASS 2681
+#define IDC_PPRIMAGE 2682
+#define IDC_PPRBIMAGE 2683
+#define IDC_PPRWPATH 2684
+#define IDC_PPRBWPATH 2685
+#define IDC_PPRMETHOD 2686
+#define IDC_PPRARGS 2687
+#define IDC_PPRTIMEOUT 2688
+#define IDC_PPRMODE 2689
+
+#define IDD_PROPPAGE_STOP 2700
+#define IDC_PPSCLASS 2701
+#define IDC_PPSIMAGE 2702
+#define IDC_PPSBIMAGE 2703
+#define IDC_PPSWPATH 2704
+#define IDC_PPSBWPATH 2705
+#define IDC_PPSMETHOD 2706
+#define IDC_PPSARGS 2707
+#define IDC_PPSTIMEOUT 2708
+#define IDC_PPSMODE 2709
+
+#define IDS_ALREAY_RUNING 3100
+#define IDS_ERRORCMD 3101
+#define IDS_HSSTART 3102
+#define IDS_HSSTOP 3103
+#define IDS_HSPAUSE 3104
+#define IDS_HSRESTART 3105
+#define IDS_VALIDPASS 3106
+#define IDS_PPGENERAL 3107
+#define IDS_PPLOGON 3108
+#define IDS_PPLOGGING 3109
+#define IDS_PPJAVAVM 3110
+#define IDS_PPSTART 3111
+#define IDS_PPSTOP 3112
+#define IDS_LGPATHTITLE 3113
+#define IDS_ALLFILES 3114
+#define IDS_DLLFILES 3115
+#define IDS_EXEFILES 3116
+#define IDS_LGSTDERR 3117
+#define IDS_LGSTDOUT 3118
+#define IDS_PPJBJVM 3119
+#define IDS_PPWPATH 3120
+#define IDS_PPIMAGE 3121
+#define IDS_ERRSREG 3122
+
+#define IDS_NOTIMPLEMENTED 3199
+
+#endif /* _PRUNMGR_H */
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.manifest
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.manifest 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.manifest 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+<assemblyIdentity version="2.0.1.0" processorArchitecture="X86" name="Apache.Procrun.Prunmgr" type="win32" />
+<description>Procrun Service Manager</description>
+<dependency>
+<dependentAssembly>
+<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="X86" publicKeyToken="6595b64144ccf1df" language="*" />
+</dependentAssembly>
+</dependency>
+</assembly>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.rc
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.rc 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.rc 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,291 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apxwin.h"
+#include "prunmgr.h"
+
+#define RSTR_PSM "Procrun Service Manager"
+#define RSTR_SCMATS "Service Manager is attempting to "
+
+IDI_MAINICON ICON "../../resources/procrunw.ico"
+IDI_ICONSTOP ICON "../../resources/procruns.ico"
+IDI_ICONRUN ICON "../../resources/procrunr.ico"
+IDR_LICENSE RTF "../../resources/license.rtf"
+BMP_JAKARTA BITMAP "../../resources/jakarta.bmp"
+
+#if 0
+BMP_APMNUHDR BITMAP "../../resources/apmnuhdr.bmp"
+#endif
+
+#ifdef USE_MAINFEST
+CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "prunmgr.manifest"
+#endif
+
+IDD_ABOUTBOX DIALOGEX 0, 0, 337, 187
+STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "Apache Service Manager"
+FONT 8, "Microsoft Sans Serif", 400, 0, 0x0
+BEGIN
+ DEFPUSHBUTTON "&OK",IDOK,285,150,50,14
+ CONTROL "",IDC_LICENSE,"RichEdit20A",ES_MULTILINE |
+ ES_READONLY | WS_BORDER | WS_VSCROLL,0,31,335,115
+ CONTROL "BMP_JAKARTA",IDC_STATIC,"Static",SS_BITMAP|0x00000040L,0,0,337,30
+ LTEXT " ",IDC_ABOUTAPP,2,150,270,12
+ LTEXT "Copyright © 2000-2003 The Apache Software Foundation.",IDC_STATIC,2,160,270,12
+ LTEXT "http://www.jakarta.org",IDC_STATIC,2,170,270,12
+ PUSHBUTTON "&System Info",IAB_SYSINF,285,170,50,14
+END
+
+IDD_PROGRESS DIALOGEX 0, 0, 322, 92
+STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP |
+ WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_TOPMOST
+CAPTION "Apache Service Manager"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "Cl&ose",IDOK,261,73,50,14
+ PUSHBUTTON "&Cancel",IDCANCEL,202,73,50,14
+ LTEXT " ",
+ IDDP_HEAD,40,4,250,8
+ LTEXT " ",IDDP_TEXT,40,15,250,44
+ CONTROL "",IDDP_PROGRESS,"msctls_progress32",WS_BORDER,10,50,302,
+ 14
+ ICON IDI_MAINICON,IDC_STATIC,10,4,20,20,0,WS_EX_TRANSPARENT
+END
+
+IDD_SELUSER DIALOGEX 0, 0, 410, 201
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU |
+ WS_THICKFRAME
+EXSTYLE WS_EX_CONTEXTHELP
+CAPTION "Select User"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LTEXT "Name:",IDSU_SELNAME,10,183,22,8
+ EDITTEXT IDSU_SELECTED,48,200,213,14,ES_AUTOHSCROLL
+ DEFPUSHBUTTON "OK",IDOK,292,180,50,14,WS_DISABLED
+ PUSHBUTTON "Cancel",IDCANCEL,348,180,50,14
+ LTEXT "Look In:",IDC_STATIC,10,9,27,8
+ CONTROL "",IDSU_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL |
+ LVS_SORTASCENDING | LVS_SHAREIMAGELISTS | LVS_ALIGNLEFT | WS_BORDER |
+ WS_TABSTOP,0,26,410,149,WS_EX_CLIENTEDGE
+ CONTROL "",IDSU_COMBO,"ComboBoxEx32",CBS_DROPDOWNLIST |
+ WS_VSCROLL | WS_TABSTOP,47,6,260,80
+END
+
+IDD_PROPPAGE_SGENERAL DIALOGEX 0, 0, 260, 186
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ LTEXT "Service Name: ",IDC_STATIC,10,8,52,8
+ LTEXT " ",IDC_PPSGNAME,70,8,240,8
+ LTEXT "Display &name: ",IDC_STATIC,10,23,50,8
+ EDITTEXT IDC_PPSGDISP,70,22,180,12,ES_AUTOHSCROLL
+ LTEXT "&Description: ",IDC_STATIC,10,41,43,8
+ EDITTEXT IDC_PPSGDESC,70,40,180,12,ES_AUTOHSCROLL
+ LTEXT "Pat&h to executable:",IDC_STATIC,10,63,66,8
+ EDITTEXT IDC_PPSGDEXE,10,75,240,12,ES_AUTOHSCROLL | WS_DISABLED
+ LTEXT "Startup typ&e:",IDC_STATIC,10,94,46,8
+ COMBOBOX IDC_PPSGCMBST,70,93,180,80,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+ CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,10,128,240,1
+ LTEXT "Service Status:",IDC_STATIC,10,138,52,8
+ LTEXT " ",IDC_PPSGSTATUS,70,138,240,8
+ PUSHBUTTON "&Start",IDC_PPSGSTART,10,160,55,14,WS_DISABLED
+ PUSHBUTTON "S&top",IDC_PPSGSTOP,71,160,55,14,WS_DISABLED
+ PUSHBUTTON "&Pause",IDC_PPSGPAUSE,132,160,55,14,WS_DISABLED
+ PUSHBUTTON "&Restart",IDC_PPSGRESTART,193,160,55,14,WS_DISABLED
+END
+
+IDD_PROPPAGE_LOGON DIALOGEX 0, 0, 260, 186
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ LTEXT "Log on as:",IDC_STATIC,10,8,51,8
+ CONTROL "&Local System account",IDC_PPSLLS,"Button",
+ BS_AUTORADIOBUTTON,10,23,85,10
+ CONTROL "Allo&w service to interact with desktop",IDC_PPSLID,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,21,37,135,10
+ CONTROL "&This account:",IDC_PPSLUA,"Button",BS_AUTORADIOBUTTON,
+ 10,59,61,10
+ EDITTEXT IDC_PPSLUSER,86,58,114,12,ES_AUTOHSCROLL
+ PUSHBUTTON "&Browse...",IDC_PPSLBROWSE,205,57,50,14
+ LTEXT "&Password:",IDL_PPSLPASS,21,76,36,8
+ EDITTEXT IDC_PPSLPASS,86,75,114,12,ES_PASSWORD | ES_AUTOHSCROLL
+ LTEXT "&Confirm Password:",IDL_PPSLCPASS,20,93,63,8
+ EDITTEXT IDC_PPSLCPASS,86,92,114,12,ES_PASSWORD | ES_AUTOHSCROLL
+END
+
+IDD_PROPPAGE_LOGGING DIALOGEX 0, 0, 260, 186
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ LTEXT "&Level:",IDC_STATIC,10,18,46,8
+ COMBOBOX IDC_PPLGLEVEL,70,17,180,80,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+ LTEXT "Log &path: ",IDC_STATIC,10,33,50,8
+ EDITTEXT IDC_PPLGPATH,10,45,218,12,ES_AUTOHSCROLL
+ PUSHBUTTON "...",IDC_PPLGBPATH,232,44,18,14
+ LTEXT "Log prefix: ",IDC_STATIC,10,63,50,8
+ EDITTEXT IDC_PPLGPREFIX,70,62,158,12,ES_AUTOHSCROLL
+
+ LTEXT "Redirect Stdout: ",IDC_STATIC,10,85,80,8
+ EDITTEXT IDC_PPLGSTDOUT,10,97,218,12,ES_AUTOHSCROLL
+ PUSHBUTTON "...",IDC_PPLGBSTDOUT,232,96,18,14
+ LTEXT "Redirect Stderror: ",IDC_STATIC,10,115,80,8
+ EDITTEXT IDC_PPLGSTDERR,10,127,218,12,ES_AUTOHSCROLL
+ PUSHBUTTON "...",IDC_PPLGBSTDERR,232,126,18,14
+END
+
+IDD_PROPPAGE_JVM DIALOGEX 0, 0, 260, 186
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ CONTROL " Use default",IDC_PPJAUTO,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,10,8,72,12
+ LTEXT "Java Virtual Machine: ",IDC_STATIC,10,23,80,8
+ EDITTEXT IDC_PPJJVM,10,35,218,12,ES_AUTOHSCROLL
+ PUSHBUTTON "...",IDC_PPJBJVM,232,34,18,14
+ LTEXT "Java Classpath:",IDC_STATIC,10,53,66,8
+ EDITTEXT IDC_PPJCLASSPATH,10,65,240,12,ES_AUTOHSCROLL
+ LTEXT "Java Options:",IDC_STATIC,10,83,66,8
+ EDITTEXT IDC_PPJOPTIONS,10,95,240,40,ES_MULTILINE | ES_AUTOHSCROLL |
+ ES_WANTRETURN | WS_VSCROLL
+ LTEXT "Initial memory pool:",IDC_STATIC,10,140,80,8
+ EDITTEXT IDC_PPJMS,90,139,100,12,ES_AUTOHSCROLL | ES_NUMBER
+ LTEXT "MB",IDC_STATIC,195,140,25,8
+ LTEXT "Maximum memory pool:",IDC_STATIC,10,156,80,8
+ EDITTEXT IDC_PPJMX,90,155,100,12,ES_AUTOHSCROLL | ES_NUMBER
+ LTEXT "MB",IDC_STATIC,195,156,25,8
+ LTEXT "Thread stack size:",IDC_STATIC,10,172,80,8
+ EDITTEXT IDC_PPJSS,90,171,100,12,ES_AUTOHSCROLL | ES_NUMBER
+ LTEXT "KB",IDC_STATIC,195,172,25,8
+END
+
+IDD_PROPPAGE_START DIALOGEX 0, 0, 260, 186
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ LTEXT "&Class: ",IDC_STATIC,10,8,50,8
+ EDITTEXT IDC_PPRCLASS,10,20,240,12,ES_AUTOHSCROLL
+ LTEXT "Image: ",IDC_STATIC,10,38,80,8
+ EDITTEXT IDC_PPRIMAGE,10,50,218,12,ES_AUTOHSCROLL | WS_DISABLED
+ PUSHBUTTON "...",IDC_PPRBIMAGE,232,49,18,14,WS_DISABLED
+ LTEXT "Working Path: ",IDC_STATIC,10,68,80,8
+ EDITTEXT IDC_PPRWPATH,10,80,218,12,ES_AUTOHSCROLL
+ PUSHBUTTON "...",IDC_PPRBWPATH,232,79,18,14
+ LTEXT "&Method: ",IDC_STATIC,10,98,50,8
+ EDITTEXT IDC_PPRMETHOD,70,97,180,12,ES_AUTOHSCROLL
+ LTEXT "&Arguments: ",IDC_STATIC,10,115,50,8
+ EDITTEXT IDC_PPRARGS,70,114,180,30,ES_MULTILINE | ES_AUTOHSCROLL |
+ ES_WANTRETURN | WS_VSCROLL
+ LTEXT "&Timeout: ",IDC_STATIC,10,150,50,8
+ EDITTEXT IDC_PPRTIMEOUT,70,149,100,12,ES_AUTOHSCROLL | WS_DISABLED
+ LTEXT "sec.",IDC_STATIC,175,150,25,8
+ LTEXT "&Mode: ",IDC_STATIC,10,168,50,8
+ COMBOBOX IDC_PPRMODE,70,167,180,80,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+END
+
+IDD_PROPPAGE_STOP DIALOGEX 0, 0, 260, 186
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ LTEXT "&Class: ",IDC_STATIC,10,8,50,8
+ EDITTEXT IDC_PPSCLASS,10,20,240,12,ES_AUTOHSCROLL
+ LTEXT "Image: ",IDC_STATIC,10,38,80,8
+ EDITTEXT IDC_PPSIMAGE,10,50,218,12,ES_AUTOHSCROLL | WS_DISABLED
+ PUSHBUTTON "...",IDC_PPSBIMAGE,232,49,18,14,WS_DISABLED
+ LTEXT "Working Path: ",IDC_STATIC,10,68,80,8
+ EDITTEXT IDC_PPSWPATH,10,80,218,12,ES_AUTOHSCROLL
+ PUSHBUTTON "...",IDC_PPSBWPATH,232,79,18,14
+ LTEXT "&Method: ",IDC_STATIC,10,98,50,8
+ EDITTEXT IDC_PPSMETHOD,70,97,180,12,ES_AUTOHSCROLL
+ LTEXT "&Arguments: ",IDC_STATIC,10,115,50,8
+ EDITTEXT IDC_PPSARGS,70,114,180,30,ES_MULTILINE | ES_AUTOHSCROLL |
+ ES_WANTRETURN | WS_VSCROLL
+ LTEXT "&Timeout: ",IDC_STATIC,10,150,50,8
+ EDITTEXT IDC_PPSTIMEOUT,70,149,100,12,ES_AUTOHSCROLL | ES_NUMBER
+ LTEXT "sec.",IDC_STATIC,175,150,25,8
+ LTEXT "&Mode: ",IDC_STATIC,10,168,50,8
+ COMBOBOX IDC_PPSMODE,70,167,180,80,CBS_DROPDOWNLIST | WS_VSCROLL |
+ WS_TABSTOP
+END
+
+STRINGTABLE
+BEGIN
+ IDS_APPLICATION RSTR_PSM
+ IDS_APPVERSION "Version 1.0.0"
+ IDS_APPFULLNAME RSTR_PSM " Version " PRG_VERSION
+ IDS_APPCOPYRIGHT "Copyright © 2000-2004 The Apache Software Foundation"
+ IDS_APPDESCRIPTION "Apache Procrun Service Management Tool"
+ IDS_ALREAY_RUNING "An instance of '%S' application is already running"
+ IDS_ERRORCMD "Unknown command line option '%s'\nSee the manual for command line usage."
+ IDS_HSSTART RSTR_SCMATS "start the following service ..."
+ IDS_HSSTOP RSTR_SCMATS "stop the following service ..."
+ IDS_HSRESTART RSTR_SCMATS "to restart the following service ..."
+ IDS_HSPAUSE RSTR_SCMATS "to pause the following service ..."
+ IDS_VALIDPASS "Please enter a valid password"
+ IDS_PPGENERAL "General"
+ IDS_PPLOGON "Log On"
+ IDS_PPLOGGING "Logging"
+ IDS_PPJAVAVM "Java"
+ IDS_PPSTART "Startup"
+ IDS_PPSTOP "Shutdown"
+ IDS_NOTIMPLEMENTED "Sorry, but this feature is not implemented yet"
+ IDS_LGPATHTITLE "Select Log root folder"
+ IDS_ALLFILES "All Files (*.*)\0*.*\0"
+ IDS_DLLFILES "Dynamic Link Libraries (*.dll)\0*.dll\0"
+ IDS_EXEFILES "Executables (*.exe)\0*.exe\0"
+ IDS_LGSTDOUT "Select Stdoutput filename"
+ IDS_LGSTDERR "Select Stderror filename"
+ IDS_PPJBJVM "Select Java Virtual Machine DLL"
+ IDS_PPWPATH "Select Working path"
+ IDS_PPIMAGE "Select Executable Image"
+ IDS_ERRSREG "Unable to open the service registry key"
+END
+
+1 VERSIONINFO
+ FILEVERSION 2,0,1,0
+ PRODUCTVERSION 2,0,1,0
+ FILEFLAGSMASK 0x3fL
+#if defined(_DEBUG)
+ FILEFLAGS 0x03L
+#else
+ FILEFLAGS 0x02L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "Comments", "Procrun Service Management Tool\0"
+ VALUE "CompanyName", "Apache Software Foundation\0"
+ VALUE "FileDescription", RSTR_PSM "\0"
+ VALUE "FileVersion", PRG_VERSION
+ VALUE "InternalName", RSTR_PSM "\0"
+ VALUE "LegalCopyright", "Copyright © 2000-2006 The Apache Software Foundation.\0"
+ VALUE "OriginalFilename", "prunmgr.exe\0"
+ VALUE "ProductName", RSTR_PSM "\0"
+ VALUE "ProductVersion", PRG_VERSION
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.vcproj
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.vcproj 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunmgr/prunmgr.vcproj 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,402 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8,00"
+ Name="prunmgr"
+ ProjectGUID="{1ABB5DF8-8560-4A20-BEA4-88A7E43C6B28}"
+ RootNamespace="prunmgr"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ <Platform
+ Name="x64"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\include;$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="shlwapi.lib comctl32.lib netapi32.lib"
+ LinkIncremental="2"
+ GenerateManifest="true"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|x64"
+ OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\include;$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32"
+ PreprocessorDefinitions="WIN32;WIN64;_DEBUG;_WINDOWS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="shlwapi.lib comctl32.lib netapi32.lib"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ TargetMachine="17"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\include;$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="shlwapi.lib comctl32.lib netapi32.lib"
+ LinkIncremental="1"
+ GenerateManifest="false"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|x64"
+ OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\include;$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32"
+ PreprocessorDefinitions="WIN32;WIN64;NDEBUG;_WINDOWS"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="shlwapi.lib comctl32.lib netapi32.lib"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="17"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\prunmgr.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\prunmgr.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ <File
+ RelativePath=".\prunmgr.rc"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="..\..\include"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="..\..\include"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="..\..\include"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="..\..\include"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunsrv/prunsrv.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunsrv/prunsrv.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunsrv/prunsrv.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,1308 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* ====================================================================
+ * prunsrv -- Service Runner.
+ * Contributed by Mladen Turk <mturk at apache.org>
+ * 05 Aug 2003
+ * ====================================================================
+ */
+
+/* Force the JNI vprintf functions */
+#define _DEBUG_JNI 1
+#include "apxwin.h"
+#include "prunsrv.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <fcntl.h>
+#include <io.h> /* _open_osfhandle */
+
+#define STDIN_FILENO 0
+#define STDOUT_FILENO 1
+#define STDERR_FILENO 2
+
+typedef struct APX_STDWRAP {
+ LPCWSTR szLogPath;
+ LPCWSTR szStdOutFilename;
+ LPCWSTR szStdErrFilename;
+ HANDLE hStdOutFile;
+ HANDLE hStdErrFile;
+ FILE *fpStdOutFile;
+ FILE *fpStdErrFile;
+ FILE fpStdOutSave;
+ FILE fpStdErrSave;
+} APX_STDWRAP;
+
+/* Use static variables instead of #defines */
+static LPCWSTR PRSRV_AUTO = L"auto";
+static LPCWSTR PRSRV_JAVA = L"java";
+static LPCWSTR PRSRV_JVM = L"jvm";
+static LPCWSTR PRSRV_MANUAL = L"manual";
+static LPCWSTR PRSRV_JBIN = L"\\bin\\java.exe";
+static LPCWSTR PRSRV_SIGNAL = L"SIGNAL";
+
+static LPWSTR _service_name = NULL;
+/* Allowed procrun commands */
+static LPCWSTR _commands[] = {
+ L"TS", /* 1 Run Service as console application (default)*/
+ L"RS", /* 2 Run Service */
+ L"SS", /* 3 Stop Service */
+ L"US", /* 4 Update Service parameters */
+ L"IS", /* 5 Install Service */
+ L"DS", /* 6 Delete Service */
+ NULL
+};
+
+/* Allowed procrun parameters */
+static APXCMDLINEOPT _options[] = {
+
+/* 0 */ { L"Description", L"Description", NULL, APXCMDOPT_STR | APXCMDOPT_SRV, NULL, 0},
+/* 1 */ { L"DisplayName", L"DisplayName", NULL, APXCMDOPT_STR | APXCMDOPT_SRV, NULL, 0},
+/* 2 */ { L"Install", L"ImagePath", NULL, APXCMDOPT_STE | APXCMDOPT_SRV, NULL, 0},
+/* 3 */ { L"Startup", L"Startup", NULL, APXCMDOPT_STR | APXCMDOPT_SRV, NULL, 0},
+/* 4 */ { L"DependsOn", L"DependsOn", NULL, APXCMDOPT_MSZ | APXCMDOPT_REG, NULL, 0},
+/* 5 */ { L"Environment", L"Environment", NULL, APXCMDOPT_MSZ | APXCMDOPT_REG, NULL, 0},
+/* 6 */ { L"User", L"User", NULL, APXCMDOPT_STR | APXCMDOPT_REG, NULL, 0},
+/* 7 */ { L"Password", L"Password", NULL, APXCMDOPT_BIN | APXCMDOPT_REG, NULL, 0},
+
+/* 8 */ { L"JavaHome", L"JavaHome", L"Java", APXCMDOPT_STE | APXCMDOPT_REG, NULL, 0},
+/* 9 */ { L"Jvm", L"Jvm", L"Java", APXCMDOPT_STE | APXCMDOPT_REG, NULL, 0},
+/* 10 */ { L"JvmOptions", L"Options", L"Java", APXCMDOPT_MSZ | APXCMDOPT_REG, NULL, 0},
+/* 11 */ { L"Classpath", L"Classpath", L"Java", APXCMDOPT_STE | APXCMDOPT_REG, NULL, 0},
+/* 12 */ { L"JvmMs", L"JvmMs", L"Java", APXCMDOPT_INT | APXCMDOPT_REG, NULL, 0},
+/* 13 */ { L"JvmMx", L"JvmMx", L"Java", APXCMDOPT_INT | APXCMDOPT_REG, NULL, 0},
+/* 14 */ { L"JvmSs", L"JvmSs", L"Java", APXCMDOPT_INT | APXCMDOPT_REG, NULL, 0},
+
+/* 15 */ { L"StopImage", L"Image", L"Stop", APXCMDOPT_STE | APXCMDOPT_REG, NULL, 0},
+/* 16 */ { L"StopPath", L"WorkingPath", L"Stop", APXCMDOPT_STE | APXCMDOPT_REG, NULL, 0},
+/* 17 */ { L"StopClass", L"Class", L"Stop", APXCMDOPT_STR | APXCMDOPT_REG, NULL, 0},
+/* 18 */ { L"StopParams", L"Params", L"Stop", APXCMDOPT_MSZ | APXCMDOPT_REG, NULL, 0},
+/* 19 */ { L"StopMethod", L"Method", L"Stop", APXCMDOPT_STR | APXCMDOPT_REG, NULL, 0},
+/* 20 */ { L"StopMode", L"Mode", L"Stop", APXCMDOPT_STR | APXCMDOPT_REG, NULL, 0},
+/* 21 */ { L"StopTimeout", L"Timeout", L"Stop", APXCMDOPT_INT | APXCMDOPT_REG, NULL, 0},
+
+/* 22 */ { L"StartImage", L"Image", L"Start", APXCMDOPT_STE | APXCMDOPT_REG, NULL, 0},
+/* 23 */ { L"StartPath", L"WorkingPath", L"Start", APXCMDOPT_STE | APXCMDOPT_REG, NULL, 0},
+/* 24 */ { L"StartClass", L"Class", L"Start", APXCMDOPT_STR | APXCMDOPT_REG, NULL, 0},
+/* 25 */ { L"StartParams", L"Params", L"Start", APXCMDOPT_MSZ | APXCMDOPT_REG, NULL, 0},
+/* 26 */ { L"StartMethod", L"Method", L"Start", APXCMDOPT_STR | APXCMDOPT_REG, NULL, 0},
+/* 27 */ { L"StartMode", L"Mode", L"Start", APXCMDOPT_STR | APXCMDOPT_REG, NULL, 0},
+
+/* 28 */ { L"LogPath", L"Path", L"Log", APXCMDOPT_STE | APXCMDOPT_REG, NULL, 0},
+/* 29 */ { L"LogPrefix", L"Prefix", L"Log", APXCMDOPT_STR | APXCMDOPT_REG, NULL, 0},
+/* 30 */ { L"LogLevel", L"Level", L"Log", APXCMDOPT_STR | APXCMDOPT_REG, NULL, 0},
+/* 31 */ { L"StdError", L"StdError", L"Log", APXCMDOPT_STE | APXCMDOPT_REG, NULL, 0},
+/* 32 */ { L"StdOutput", L"StdOutput", L"Log", APXCMDOPT_STE | APXCMDOPT_REG, NULL, 0},
+ /* NULL terminate the array */
+ { NULL }
+};
+
+#define GET_OPT_V(x) _options[x].szValue
+#define GET_OPT_I(x) _options[x].dwValue
+#define GET_OPT_T(x) _options[x].dwType
+
+#define ST_DESCRIPTION GET_OPT_T(0)
+#define ST_DISPLAYNAME GET_OPT_T(1)
+#define ST_INSTALL GET_OPT_T(2)
+#define ST_STARTUP GET_OPT_T(3)
+
+#define SO_DESCRIPTION GET_OPT_V(0)
+#define SO_DISPLAYNAME GET_OPT_V(1)
+#define SO_INSTALL GET_OPT_V(2)
+#define SO_STARTUP GET_OPT_V(3)
+#define SO_DEPENDSON GET_OPT_V(4)
+#define SO_ENVIRONMENT GET_OPT_V(5)
+
+#define SO_USER GET_OPT_V(6)
+#define SO_PASSWORD GET_OPT_V(7)
+
+#define SO_JAVAHOME GET_OPT_V(8)
+#define SO_JVM GET_OPT_V(9)
+#define SO_JVMOPTIONS GET_OPT_V(10)
+#define SO_CLASSPATH GET_OPT_V(11)
+#define SO_JVMMS GET_OPT_I(12)
+#define SO_JVMMX GET_OPT_I(13)
+#define SO_JVMSS GET_OPT_I(14)
+
+#define SO_STOPIMAGE GET_OPT_V(15)
+#define SO_STOPPATH GET_OPT_V(16)
+#define SO_STOPCLASS GET_OPT_V(17)
+#define SO_STOPPARAMS GET_OPT_V(18)
+#define SO_STOPMETHOD GET_OPT_V(19)
+#define SO_STOPMODE GET_OPT_V(20)
+#define SO_STOPTIMEOUT GET_OPT_I(21)
+
+#define SO_STARTIMAGE GET_OPT_V(22)
+#define SO_STARTPATH GET_OPT_V(23)
+#define SO_STARTCLASS GET_OPT_V(24)
+#define SO_STARTPARAMS GET_OPT_V(25)
+#define SO_STARTMETHOD GET_OPT_V(26)
+#define SO_STARTMODE GET_OPT_V(27)
+
+#define SO_LOGPATH GET_OPT_V(28)
+#define SO_LOGPREFIX GET_OPT_V(29)
+#define SO_LOGLEVEL GET_OPT_V(30)
+
+#define SO_STDERROR GET_OPT_V(31)
+#define SO_STDOUTPUT GET_OPT_V(32)
+
+/* Main servic table entry
+ * filled at run-time
+ */
+static SERVICE_TABLE_ENTRYW _service_table[] = {
+ {NULL, NULL},
+ {NULL, NULL}
+};
+
+static SERVICE_STATUS _service_status;
+static SERVICE_STATUS_HANDLE _service_status_handle = NULL;
+/* Set if launched by SCM */
+static BOOL _service_mode = FALSE;
+/* JVM used as worker */
+static BOOL _jni_startup = FALSE;
+/* JVM used for shutdown */
+static BOOL _jni_shutdown = FALSE;
+/* Global variables and objects */
+static APXHANDLE gPool;
+static APXHANDLE gWorker;
+static APX_STDWRAP gStdwrap; /* stdio/stderr redirection */
+
+static LPWSTR _jni_jvmpath = NULL; /* Path to jvm dll */
+static LPSTR _jni_jvmoptions = NULL; /* Path to jvm options */
+
+static LPSTR _jni_classpath = NULL;
+static LPSTR _jni_rparam = NULL; /* Startup arguments */
+static LPSTR _jni_sparam = NULL; /* Shutdown arguments */
+static LPSTR _jni_rmethod = NULL; /* Startup arguments */
+static LPSTR _jni_smethod = NULL; /* Shutdown arguments */
+static CHAR _jni_rclass[SIZ_RESLEN] = {'\0'}; /* Startup class */
+static CHAR _jni_sclass[SIZ_RESLEN] = {'\0'}; /* Shutdown class */
+
+static HANDLE gShutdownEvent = NULL;
+static HANDLE gSignalEvent = NULL;
+static HANDLE gSignalThread = NULL;
+static BOOL gSignalValid = TRUE;
+
+DWORD WINAPI eventThread(LPVOID lpParam)
+{
+ for (;;) {
+ DWORD dw = WaitForSingleObject(gSignalEvent, INFINITE);
+ if (dw == WAIT_OBJECT_0 && gSignalValid) {
+ if (!GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, 0))
+ apxLogWrite(APXLOG_MARK_SYSERR);
+ ResetEvent(gSignalEvent);
+ }
+ else
+ break;
+ }
+ ExitThread(0);
+ return 0;
+}
+
+/* redirect console stdout/stderr to files
+ * so that java messages can get logged
+ * If stderrfile is not specified it will
+ * go to stdoutfile.
+ */
+static BOOL redirectStdStreams(APX_STDWRAP *lpWrapper)
+{
+ BOOL aErr = FALSE;
+ BOOL aOut = FALSE;
+
+ /* Clear up the handles */
+ lpWrapper->fpStdErrFile = NULL;
+ lpWrapper->fpStdOutFile = NULL;
+
+ /* Save the original streams */
+ lpWrapper->fpStdOutSave = *stdout;
+ lpWrapper->fpStdErrSave = *stderr;
+
+ /* redirect to file or console */
+ if (lpWrapper->szStdOutFilename) {
+ if (lstrcmpiW(lpWrapper->szStdOutFilename, PRSRV_AUTO) == 0) {
+ aOut = TRUE;
+ lpWrapper->szStdOutFilename = apxLogFile(gPool,
+ lpWrapper->szLogPath,
+ NULL,
+ L"stdout_");
+ }
+ /* Delete the file if not in append mode
+ * XXX: See if we can use the params instead of that.
+ */
+ if (!aOut)
+ DeleteFileW(lpWrapper->szStdOutFilename);
+ lpWrapper->hStdOutFile = CreateFileW(lpWrapper->szStdOutFilename,
+ GENERIC_WRITE | GENERIC_READ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if (IS_INVALID_HANDLE(lpWrapper->hStdOutFile))
+ return FALSE;
+ /* Allways move to the end of file */
+ SetFilePointer(lpWrapper->hStdOutFile, 0, NULL, FILE_END);
+ }
+ else {
+ lpWrapper->hStdOutFile = CreateFileW(L"CONOUT$",
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ 0,
+ NULL);
+ if (IS_INVALID_HANDLE(lpWrapper->hStdOutFile))
+ return FALSE;
+ }
+ if (lpWrapper->szStdErrFilename) {
+ if (lstrcmpiW(lpWrapper->szStdErrFilename, PRSRV_AUTO) == 0) {
+ aErr = TRUE;
+ lpWrapper->szStdErrFilename = apxLogFile(gPool,
+ lpWrapper->szLogPath,
+ NULL,
+ L"stderr_");
+ }
+ if (!aErr)
+ DeleteFileW(lpWrapper->szStdErrFilename);
+ lpWrapper->hStdErrFile = CreateFileW(lpWrapper->szStdErrFilename,
+ GENERIC_WRITE | GENERIC_READ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if (IS_INVALID_HANDLE(lpWrapper->hStdErrFile))
+ return FALSE;
+ SetFilePointer(lpWrapper->hStdErrFile, 0, NULL, FILE_END);
+ }
+ else if (lpWrapper->szStdOutFilename) {
+ /* Use the same file handle for stderr as for stdout */
+ lpWrapper->szStdErrFilename = lpWrapper->szStdOutFilename;
+ lpWrapper->hStdErrFile = lpWrapper->hStdOutFile;
+ }
+ else {
+ lpWrapper->hStdErrFile = lpWrapper->hStdOutFile;
+ }
+ /* Open the stream buffers
+ * This will redirect all printf to go to the redirected files.
+ * It is used for JNI vprintf functionality.
+ */
+ lpWrapper->fpStdOutFile = _fdopen(_open_osfhandle(
+ (intptr_t)lpWrapper->hStdOutFile,
+ _O_TEXT), "w");
+ lpWrapper->fpStdErrFile = _fdopen(_open_osfhandle(
+ (intptr_t)lpWrapper->hStdErrFile,
+ _O_TEXT), "w");
+ if (lpWrapper->fpStdOutFile) {
+ *stdout = *lpWrapper->fpStdOutFile;
+ setvbuf(stdout, NULL, _IONBF, 0);
+ }
+ if (lpWrapper->fpStdErrFile) {
+ *stderr = *lpWrapper->fpStdErrFile;
+ setvbuf(stderr, NULL, _IONBF, 0);
+ }
+ return TRUE;
+}
+
+static void cleanupStdStreams(APX_STDWRAP *lpWrapper)
+{
+ /* Close the redirectied streams */
+ if (lpWrapper->fpStdOutFile) {
+ fclose(lpWrapper->fpStdOutFile);
+ *stdout = lpWrapper->fpStdOutSave;
+ }
+ if (lpWrapper->fpStdErrFile) {
+ fclose(lpWrapper->fpStdErrFile);
+ *stderr = lpWrapper->fpStdErrSave;
+ }
+}
+
+/* Debugging functions */
+static void printUsage(LPAPXCMDLINE lpCmdline)
+{
+#ifdef _DEBUG
+ int i = 0;
+ fwprintf(stderr, L"Usage: %s //CMD//Servce [--options]\n",
+ lpCmdline->szExecutable);
+ fwprintf(stderr, L" Commands:\n");
+ fwprintf(stderr, L" //IS//ServiceName Install Service\n");
+ fwprintf(stderr, L" //US//ServiceName Update Service parameters\n");
+ fwprintf(stderr, L" //DS//ServiceName Delete Service\n");
+ fwprintf(stderr, L" //RS//ServiceName Run Service\n");
+ fwprintf(stderr, L" //SS//ServiceName Stop Service\n");
+ fwprintf(stderr,
+ L" //TS//ServiceName Run Service as console application\n");
+ fwprintf(stderr, L" Options:\n");
+ while (_options[i].szName) {
+ fwprintf(stderr, L" --%s\n", _options[i].szName);
+ ++i;
+ }
+#endif
+}
+/* Display configuration parameters */
+static void dumpCmdline()
+{
+ int i = 0;
+ while (_options[i].szName) {
+ if (_options[i].dwType & APXCMDOPT_INT)
+ fwprintf(stderr, L"--%-16s %d\n", _options[i].szName,
+ _options[i].dwValue);
+ else if (_options[i].szValue)
+ fwprintf(stderr, L"--%-16s %s\n", _options[i].szName,
+ _options[i].szValue);
+ else
+ fwprintf(stderr, L"--%-16s <NULL>\n", _options[i].szName);
+ ++i;
+ }
+}
+
+static void setInprocEnvironment()
+{
+ LPWSTR p, e;
+
+ if (!SO_ENVIRONMENT)
+ return; /* Nothing to do */
+
+ for (p = SO_ENVIRONMENT; *p; p++) {
+ e = apxExpandStrW(gPool, p);
+ _wputenv(e);
+ apxFree(e);
+ while (*p)
+ p++;
+ }
+}
+
+/* Load the configuration from Registry
+ * loads only nonspecified items
+ */
+static BOOL loadConfiguration(LPAPXCMDLINE lpCmdline)
+{
+ APXHANDLE hRegistry;
+ int i = 0;
+
+ SetLastError(ERROR_SUCCESS);
+ hRegistry = apxCreateRegistryW(gPool, KEY_READ, PRG_REGROOT,
+ lpCmdline->szApplication,
+ APXREG_SOFTWARE | APXREG_SERVICE);
+ if (IS_INVALID_HANDLE(hRegistry)) {
+ apxLogWrite(APXLOG_MARK_SYSERR);
+ return FALSE;
+ }
+ /* browse through options */
+ while (_options[i].szName) {
+ DWORD dwFrom;
+
+ dwFrom = (_options[i].dwType & APXCMDOPT_REG) ? APXREG_PARAMSOFTWARE : APXREG_SERVICE;
+ if (!(_options[i].dwType & APXCMDOPT_FOUND)) {
+ if (_options[i].dwType & APXCMDOPT_STR) {
+ _options[i].szValue = apxRegistryGetStringW(hRegistry,
+ dwFrom,
+ _options[i].szSubkey,
+ _options[i].szRegistry);
+ /* Expand environment variables */
+ if (_options[i].szValue && (_options[i].dwType & APXCMDOPT_STE)) {
+ LPWSTR exp = apxExpandStrW(gPool, _options[i].szValue);
+ if (exp != _options[i].szValue)
+ apxFree(_options[i].szValue);
+ _options[i].szValue = exp;
+ }
+ }
+ else if (_options[i].dwType & APXCMDOPT_INT) {
+ _options[i].dwValue = apxRegistryGetNumberW(hRegistry,
+ dwFrom,
+ _options[i].szSubkey,
+ _options[i].szRegistry);
+ }
+ else if (_options[i].dwType & APXCMDOPT_MSZ) {
+ _options[i].szValue = apxRegistryGetMzStrW(hRegistry,
+ dwFrom,
+ _options[i].szSubkey,
+ _options[i].szRegistry,
+ NULL,
+ &(_options[i].dwValue));
+ }
+ }
+ /* Merge the command line options with registry */
+ else if (_options[i].dwType & APXCMDOPT_ADD) {
+ LPWSTR cv = _options[i].szValue;
+ LPWSTR ov = NULL;
+ if (_options[i].dwType & APXCMDOPT_MSZ) {
+ ov = apxRegistryGetMzStrW(hRegistry, dwFrom,
+ _options[i].szSubkey,
+ _options[i].szRegistry,
+ NULL,
+ &(_options[i].dwValue));
+ _options[i].szValue = apxMultiSzCombine(gPool, ov, cv,
+ &(_options[i].dwValue));
+ if (ov)
+ apxFree(ov);
+ }
+ }
+ ++i;
+ }
+ apxCloseHandle(hRegistry);
+#ifdef _DEBUG
+ dumpCmdline();
+#endif
+ return TRUE;
+}
+
+/* Save changed configuration to registry
+ */
+static BOOL saveConfiguration(LPAPXCMDLINE lpCmdline)
+{
+ APXHANDLE hRegistry;
+ int i = 0;
+ hRegistry = apxCreateRegistryW(gPool, KEY_WRITE, PRG_REGROOT,
+ lpCmdline->szApplication,
+ APXREG_SOFTWARE | APXREG_SERVICE);
+ if (IS_INVALID_HANDLE(hRegistry))
+ return FALSE;
+ /* TODO: Use array size */
+ while (_options[i].szName) {
+ /* Skip the service params */
+ if ((_options[i].dwType & APXCMDOPT_SRV) ||
+ !(_options[i].dwType & APXCMDOPT_FOUND)) {
+ /* Skip non-modified version */
+ }
+ /* Update only modified params */
+ else if (_options[i].dwType & APXCMDOPT_STR)
+ apxRegistrySetStrW(hRegistry, APXREG_PARAMSOFTWARE,
+ _options[i].szSubkey,
+ _options[i].szRegistry,
+ _options[i].szValue);
+ else if (_options[i].dwType & APXCMDOPT_INT)
+ apxRegistrySetNumW(hRegistry, APXREG_PARAMSOFTWARE,
+ _options[i].szSubkey,
+ _options[i].szRegistry,
+ _options[i].dwValue);
+ else if (_options[i].dwType & APXCMDOPT_MSZ)
+ apxRegistrySetMzStrW(hRegistry, APXREG_PARAMSOFTWARE,
+ _options[i].szSubkey,
+ _options[i].szRegistry,
+ _options[i].szValue,
+ _options[i].dwValue);
+ ++i;
+ }
+ apxCloseHandle(hRegistry);
+ return TRUE;
+}
+
+/* Operations */
+static BOOL docmdInstallService(LPAPXCMDLINE lpCmdline)
+{
+ APXHANDLE hService;
+ BOOL rv;
+ DWORD dwStart = SERVICE_DEMAND_START;
+ WCHAR szImage[SIZ_HUGLEN];
+
+ apxLogWrite(APXLOG_MARK_DEBUG "Installing service...");
+ hService = apxCreateService(gPool, SC_MANAGER_CREATE_SERVICE, FALSE);
+ if (IS_INVALID_HANDLE(hService)) {
+ apxLogWrite(APXLOG_MARK_ERROR "Unable to open the Service Manager");
+ return FALSE;
+ }
+ /* Check the startup mode */
+ if ((ST_STARTUP & APXCMDOPT_FOUND) &&
+ lstrcmpiW(SO_STARTUP, PRSRV_AUTO) == 0)
+ dwStart = SERVICE_AUTO_START;
+ /* Check if --Install is provided */
+ if (!SO_INSTALL) {
+ lstrcpyW(szImage, lpCmdline->szExePath);
+ lstrcatW(szImage, L"\\");
+ lstrcatW(szImage, lpCmdline->szExecutable);
+ lstrcatW(szImage, L".exe");
+ }
+ else
+ lstrcpyW(szImage, SO_INSTALL);
+ /* Replace not needed qoutes */
+ apxStrQuoteInplaceW(szImage);
+ /* Add run-service command line option */
+ lstrcatW(szImage, L" //RS//");
+ lstrcatW(szImage, lpCmdline->szApplication);
+ SO_INSTALL = apxPoolStrdupW(gPool, szImage);
+ /* Ensure that option gets saved in the registry */
+ ST_INSTALL |= APXCMDOPT_FOUND;
+#ifdef _DEBUG
+ /* Display configured options */
+ dumpCmdline();
+#endif
+ apxLogWrite(APXLOG_MARK_INFO "Service %S name %S", lpCmdline->szApplication,
+ SO_DISPLAYNAME);
+ rv = apxServiceInstall(hService,
+ lpCmdline->szApplication,
+ SO_DISPLAYNAME, /* --DisplayName */
+ SO_INSTALL,
+ SO_DEPENDSON, /* --DependendsOn */
+ SERVICE_WIN32_OWN_PROCESS,
+ dwStart);
+ /* Set the --Description */
+ if (rv && (ST_DESCRIPTION & APXCMDOPT_FOUND)) {
+ apxLogWrite(APXLOG_MARK_DEBUG "Setting service description %S",
+ SO_DESCRIPTION);
+ apxServiceSetNames(hService, NULL, NULL, SO_DESCRIPTION,
+ NULL, NULL);
+ }
+ apxCloseHandle(hService);
+ if (rv) {
+ saveConfiguration(lpCmdline);
+ apxLogWrite(APXLOG_MARK_INFO "Service %S installed",
+ lpCmdline->szApplication);
+ }
+ else
+ apxLogWrite(APXLOG_MARK_ERROR "Failed installing %S service",
+ lpCmdline->szApplication);
+
+ return rv;
+}
+
+static BOOL docmdDeleteService(LPAPXCMDLINE lpCmdline)
+{
+ APXHANDLE hService;
+ BOOL rv = FALSE;
+
+ apxLogWrite(APXLOG_MARK_INFO "Deleting service...");
+ hService = apxCreateService(gPool, SC_MANAGER_CONNECT, FALSE);
+ if (IS_INVALID_HANDLE(hService)) {
+ apxLogWrite(APXLOG_MARK_ERROR "Unable to open the Service Manager");
+ return FALSE;
+ }
+ /* Delete service will stop the service if running */
+ if (apxServiceOpen(hService, lpCmdline->szApplication, SERVICE_ALL_ACCESS)) {
+ WCHAR szWndManagerClass[SIZ_RESLEN];
+ HANDLE hWndManager = NULL;
+ lstrcpyW(szWndManagerClass, lpCmdline->szApplication);
+ lstrcatW(szWndManagerClass, L"_CLASS");
+ /* Close the monitor application if running */
+ if ((hWndManager = FindWindowW(szWndManagerClass, NULL)) != NULL) {
+ SendMessage(hWndManager, WM_CLOSE, 0, 0);
+ }
+ rv = apxServiceDelete(hService);
+ }
+ if (rv) {
+ /* Delete all service registry settings */
+ apxDeleteRegistryW(PRG_REGROOT, lpCmdline->szApplication, TRUE);
+ apxLogWrite(APXLOG_MARK_DEBUG "Service %S deleted",
+ lpCmdline->szApplication);
+ }
+ else {
+ apxDisplayError(TRUE, NULL, 0, "Unable to delete %S service",
+ lpCmdline->szApplication);
+ }
+ apxCloseHandle(hService);
+ apxLogWrite(APXLOG_MARK_INFO "Delete service finished.");
+ return rv;
+}
+
+static BOOL docmdStopService(LPAPXCMDLINE lpCmdline)
+{
+ APXHANDLE hService;
+ BOOL rv = FALSE;
+
+ apxLogWrite(APXLOG_MARK_INFO "Stopping service...");
+ hService = apxCreateService(gPool, GENERIC_ALL, FALSE);
+ if (IS_INVALID_HANDLE(hService)) {
+ apxLogWrite(APXLOG_MARK_ERROR "Unable to open the Service Manager");
+ return FALSE;
+ }
+
+ SetLastError(ERROR_SUCCESS);
+ /* Open the service */
+ if (apxServiceOpen(hService, lpCmdline->szApplication,
+ GENERIC_READ | GENERIC_EXECUTE)) {
+ rv = apxServiceControl(hService,
+ SERVICE_CONTROL_STOP,
+ 0,
+ NULL,
+ NULL);
+ if (rv)
+ apxLogWrite(APXLOG_MARK_INFO "Service %S stopped",
+ lpCmdline->szApplication);
+ else
+ apxLogWrite(APXLOG_MARK_ERROR "Failed to stop %S service",
+ lpCmdline->szApplication);
+
+ }
+ else
+ apxDisplayError(TRUE, NULL, 0, "Unable to open %S service",
+ lpCmdline->szApplication);
+ apxCloseHandle(hService);
+ apxLogWrite(APXLOG_MARK_INFO "Stop service finished.");
+ return rv;
+}
+
+static BOOL docmdUpdateService(LPAPXCMDLINE lpCmdline)
+{
+ APXHANDLE hService;
+ BOOL rv = FALSE;
+
+ apxLogWrite(APXLOG_MARK_INFO "Updating service...");
+
+ hService = apxCreateService(gPool, SC_MANAGER_CREATE_SERVICE, FALSE);
+ if (IS_INVALID_HANDLE(hService)) {
+ apxLogWrite(APXLOG_MARK_ERROR "Unable to open the Service Manager");
+ return FALSE;
+ }
+ SetLastError(0);
+ /* Open the service */
+ if (apxServiceOpen(hService, lpCmdline->szApplication, SERVICE_ALL_ACCESS)) {
+ apxServiceSetNames(hService,
+ NULL, /* Never update the ImagePath */
+ SO_DISPLAYNAME,
+ SO_DESCRIPTION,
+ NULL,
+ NULL);
+ /* Update the --Startup mode */
+ if (ST_STARTUP & APXCMDOPT_FOUND) {
+ DWORD dwStart = SERVICE_NO_CHANGE;
+ if (!lstrcmpiW(SO_STARTUP, PRSRV_AUTO))
+ dwStart = SERVICE_AUTO_START;
+ else if (!lstrcmpiW(SO_STARTUP, PRSRV_MANUAL))
+ dwStart = SERVICE_DEMAND_START;
+ apxServiceSetOptions(hService,
+ SERVICE_NO_CHANGE,
+ dwStart,
+ SERVICE_NO_CHANGE);
+
+ }
+ apxLogWrite(APXLOG_MARK_INFO "Service %S updated",
+ lpCmdline->szApplication);
+
+ saveConfiguration(lpCmdline);
+ }
+ else
+ apxDisplayError(TRUE, NULL, 0, "Unable to open %S service",
+ lpCmdline->szApplication);
+ apxCloseHandle(hService);
+ apxLogWrite(APXLOG_MARK_INFO "Update service finished.");
+ return rv;
+}
+
+
+/* Report the service status to the SCM
+ */
+int reportServiceStatus(DWORD dwCurrentState,
+ DWORD dwWin32ExitCode,
+ DWORD dwWaitHint)
+{
+ static DWORD dwCheckPoint = 1;
+ BOOL fResult = TRUE;
+
+ if (_service_mode && _service_status_handle) {
+ if (dwCurrentState == SERVICE_START_PENDING)
+ _service_status.dwControlsAccepted = 0;
+ else
+ _service_status.dwControlsAccepted = SERVICE_ACCEPT_STOP;
+
+ _service_status.dwCurrentState = dwCurrentState;
+ _service_status.dwWin32ExitCode = dwWin32ExitCode;
+ _service_status.dwWaitHint = dwWaitHint;
+
+ if ((dwCurrentState == SERVICE_RUNNING) ||
+ (dwCurrentState == SERVICE_STOPPED))
+ _service_status.dwCheckPoint = 0;
+ else
+ _service_status.dwCheckPoint = dwCheckPoint++;
+ fResult = SetServiceStatus(_service_status_handle, &_service_status);
+ if (!fResult) {
+ /* TODO: Deal with error */
+ }
+ }
+ return fResult;
+}
+
+
+BOOL child_callback(APXHANDLE hObject, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ /* TODO: Make stdout and stderr buffers
+ * to prevent streams intermixing when there
+ * is no separate file for each stream
+ */
+ if (uMsg == WM_CHAR) {
+ int ch = LOWORD(wParam);
+ if (lParam)
+ fputc(ch, stderr);
+ else
+ fputc(ch, stdout);
+ }
+ return TRUE;
+}
+
+/* Executed when the service receives stop event */
+static DWORD serviceStop()
+{
+ APXHANDLE hWorker = NULL;
+ DWORD rv = 0;
+ BOOL wait_to_die = FALSE;
+ DWORD timeout = SO_STOPTIMEOUT * 1000;
+
+ apxLogWrite(APXLOG_MARK_INFO "Stopping service...");
+
+ if (IS_INVALID_HANDLE(gWorker)) {
+ apxLogWrite(APXLOG_MARK_INFO "Worker is not defined");
+ return TRUE; /* Nothing to do */
+ }
+ if (_jni_shutdown) {
+ if (!SO_STARTPATH && SO_STOPPATH) {
+ /* If the Working path is specified change the current directory
+ * but only if the start path wasn't specified already.
+ */
+ SetCurrentDirectoryW(SO_STARTPATH);
+ }
+ hWorker = apxCreateJava(gPool, _jni_jvmpath);
+ if (IS_INVALID_HANDLE(hWorker)) {
+ apxLogWrite(APXLOG_MARK_ERROR "Failed creating java %S", _jni_jvmpath);
+ return 1;
+ }
+ if (!apxJavaInitialize(hWorker, _jni_classpath, _jni_jvmoptions,
+ SO_JVMMS, SO_JVMMX, SO_JVMSS)) {
+ rv = 2;
+ apxLogWrite(APXLOG_MARK_ERROR "Failed initializing java %s", _jni_classpath);
+ goto cleanup;
+ }
+ if (!apxJavaLoadMainClass(hWorker, _jni_sclass, _jni_smethod, _jni_sparam)) {
+ rv = 2;
+ apxLogWrite(APXLOG_MARK_ERROR "Failed loading main %s class %s",
+ _jni_rclass, _jni_classpath);
+ goto cleanup;
+ }
+ /* Create sutdown event */
+ gShutdownEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ if (!apxJavaStart(hWorker)) {
+ apxLogWrite(APXLOG_MARK_ERROR "Failed starting java");
+ rv = 3;
+ }
+ else {
+ apxLogWrite(APXLOG_MARK_DEBUG "Waiting for java jni stop worker to finish...");
+ apxJavaWait(hWorker, INFINITE, FALSE);
+ apxLogWrite(APXLOG_MARK_DEBUG "Java jni stop worker finished.");
+ }
+ wait_to_die = TRUE;
+ }
+ else if (SO_STOPMODE) { /* Only in case we have a stop mode */
+ DWORD nArgs;
+ LPWSTR *pArgs;
+ /* Redirect process */
+ hWorker = apxCreateProcessW(gPool,
+ 0,
+ child_callback,
+ SO_USER,
+ SO_PASSWORD,
+ FALSE);
+ if (IS_INVALID_HANDLE(hWorker)) {
+ apxLogWrite(APXLOG_MARK_ERROR "Failed creating process");
+ return 1;
+ }
+ if (!apxProcessSetExecutableW(hWorker, SO_STOPIMAGE)) {
+ apxLogWrite(APXLOG_MARK_ERROR "Failed setting process executable %S",
+ SO_STARTIMAGE);
+ rv = 2;
+ goto cleanup;
+ }
+ /* Assemble the command line */
+ nArgs = apxMultiSzToArrayW(gPool, SO_STOPPARAMS, &pArgs);
+ /* Pass the argv to child process */
+ if (!apxProcessSetCommandArgsW(hWorker, SO_STOPIMAGE,
+ nArgs, pArgs)) {
+ rv = 3;
+ apxLogWrite(APXLOG_MARK_ERROR "Failed setting process arguments (argc=%d)",
+ nArgs);
+ goto cleanup;
+ }
+ /* Set the working path */
+ if (!apxProcessSetWorkingPathW(hWorker, SO_STOPPATH)) {
+ rv = 4;
+ apxLogWrite(APXLOG_MARK_ERROR "Failed setting process working path to %S",
+ SO_STOPPATH);
+ goto cleanup;
+ }
+ /* Finally execute the child process
+ */
+ if (!apxProcessExecute(hWorker)) {
+ rv = 5;
+ apxLogWrite(APXLOG_MARK_ERROR "Failed executing process");
+ goto cleanup;
+ } else {
+ apxLogWrite(APXLOG_MARK_DEBUG "Waiting stop worker to finish...");
+ apxHandleWait(hWorker, INFINITE, FALSE);
+ apxLogWrite(APXLOG_MARK_DEBUG "Stop worker finished.");
+ }
+ wait_to_die = TRUE;
+ }
+cleanup:
+ /* Close Java JNI handle or stop worker
+ * If this is the single JVM instance it will unload
+ * the JVM dll too.
+ * The worker will be closed on service exit.
+ */
+ if (!IS_INVALID_HANDLE(hWorker))
+ apxCloseHandle(hWorker);
+ if (gSignalEvent) {
+ gSignalValid = FALSE;
+ SetEvent(gSignalEvent);
+ WaitForSingleObject(gSignalThread, 1000);
+ CloseHandle(gSignalEvent);
+ CloseHandle(gSignalThread);
+ gSignalEvent = NULL;
+ }
+ SetEvent(gShutdownEvent);
+ if (timeout > 0x7FFFFFFF)
+ timeout = INFINITE; /* If the timeout was '-1' wait forewer */
+ if (wait_to_die && !timeout)
+ timeout = 300 * 1000; /* Use the 5 minute default shutdown */
+
+ if (timeout) {
+ FILETIME fts, fte;
+ ULARGE_INTEGER s, e;
+ DWORD nms;
+ /* Wait to give it a chance to die naturally, then kill it. */
+ apxLogWrite(APXLOG_MARK_DEBUG "Waiting for worker to die naturally...");
+ GetSystemTimeAsFileTime(&fts);
+ rv = apxHandleWait(gWorker, timeout, TRUE);
+ GetSystemTimeAsFileTime(&fte);
+ s.LowPart = fts.dwLowDateTime;
+ s.HighPart = fts.dwHighDateTime;
+ e.LowPart = fte.dwLowDateTime;
+ e.HighPart = fte.dwHighDateTime;
+ nms = (DWORD)((e.QuadPart - s.QuadPart) / 10000);
+ if (rv == WAIT_OBJECT_0) {
+ rv = 0;
+ apxLogWrite(APXLOG_MARK_DEBUG "Worker finished gracefully in %d ms.", nms);
+ }
+ else
+ apxLogWrite(APXLOG_MARK_DEBUG "Worker was killed in %d ms.", nms);
+ }
+ else {
+ apxLogWrite(APXLOG_MARK_DEBUG "Sending WM_CLOSE to worker");
+ apxHandleSendMessage(gWorker, WM_CLOSE, 0, 0);
+ }
+
+ apxLogWrite(APXLOG_MARK_INFO "Service stopped.");
+ return rv;
+}
+
+/* Executed when the service receives start event */
+static DWORD serviceStart()
+{
+ DWORD rv = 0;
+ DWORD nArgs;
+ LPWSTR *pArgs;
+ FILETIME fts;
+
+ apxLogWrite(APXLOG_MARK_INFO "Starting service...");
+
+ if (!IS_INVALID_HANDLE(gWorker)) {
+ apxLogWrite(APXLOG_MARK_INFO "Worker is not defined");
+ return TRUE; /* Nothing to do */
+ }
+ GetSystemTimeAsFileTime(&fts);
+ if (_jni_startup) {
+ if (SO_STARTPATH) {
+ /* If the Working path is specified change the current directory */
+ SetCurrentDirectoryW(SO_STARTPATH);
+ }
+ /* Set the environment using putenv, so JVM can use it */
+ setInprocEnvironment();
+ /* Create the JVM glbal worker */
+ gWorker = apxCreateJava(gPool, _jni_jvmpath);
+ if (IS_INVALID_HANDLE(gWorker)) {
+ apxLogWrite(APXLOG_MARK_ERROR "Failed creating java %S", _jni_jvmpath);
+ return 1;
+ }
+ if (!apxJavaInitialize(gWorker, _jni_classpath, _jni_jvmoptions,
+ SO_JVMMS, SO_JVMMX, SO_JVMSS)) {
+ rv = 2;
+ apxLogWrite(APXLOG_MARK_ERROR "Failed initializing java %s", _jni_classpath);
+ goto cleanup;
+ }
+ if (!apxJavaLoadMainClass(gWorker, _jni_rclass, _jni_rmethod, _jni_rparam)) {
+ rv = 3;
+ apxLogWrite(APXLOG_MARK_ERROR "Failed loading main %s class %s", _jni_rclass, _jni_classpath);
+ goto cleanup;
+ }
+ apxJavaSetOut(gWorker, TRUE, gStdwrap.szStdErrFilename);
+ apxJavaSetOut(gWorker, FALSE, gStdwrap.szStdOutFilename);
+ if (!apxJavaStart(gWorker)) {
+ rv = 4;
+ apxLogWrite(APXLOG_MARK_ERROR "Failed starting Java");
+ goto cleanup;
+ }
+ apxLogWrite(APXLOG_MARK_DEBUG "Java started %s", _jni_rclass);
+ }
+ else {
+ /* Redirect process */
+ gWorker = apxCreateProcessW(gPool,
+ 0,
+ child_callback,
+ SO_USER,
+ SO_PASSWORD,
+ FALSE);
+ if (IS_INVALID_HANDLE(gWorker)) {
+ apxLogWrite(APXLOG_MARK_ERROR "Failed creating process");
+ return 1;
+ }
+ if (!apxProcessSetExecutableW(gWorker, SO_STARTIMAGE)) {
+ apxLogWrite(APXLOG_MARK_ERROR "Failed setting process executable %S",
+ SO_STARTIMAGE);
+ rv = 2;
+ goto cleanup;
+ }
+ /* Assemble the command line */
+ nArgs = apxMultiSzToArrayW(gPool, SO_STARTPARAMS, &pArgs);
+ /* Pass the argv to child process */
+ if (!apxProcessSetCommandArgsW(gWorker, SO_STARTIMAGE,
+ nArgs, pArgs)) {
+ rv = 3;
+ apxLogWrite(APXLOG_MARK_ERROR "Failed setting process arguments (argc=%d)",
+ nArgs);
+ goto cleanup;
+ }
+ /* Set the working path */
+ if (!apxProcessSetWorkingPathW(gWorker, SO_STARTPATH)) {
+ rv = 4;
+ apxLogWrite(APXLOG_MARK_ERROR "Failed setting process working path to %S",
+ SO_STARTPATH);
+ goto cleanup;
+ }
+ /* Finally execute the child process
+ */
+ if (!apxProcessExecute(gWorker)) {
+ rv = 5;
+ apxLogWrite(APXLOG_MARK_ERROR "Failed executing process");
+ goto cleanup;
+ }
+ }
+ if (rv == 0) {
+ FILETIME fte;
+ ULARGE_INTEGER s, e;
+ DWORD nms;
+ GetSystemTimeAsFileTime(&fte);
+ s.LowPart = fts.dwLowDateTime;
+ s.HighPart = fts.dwHighDateTime;
+ e.LowPart = fte.dwLowDateTime;
+ e.HighPart = fte.dwHighDateTime;
+ nms = (DWORD)((e.QuadPart - s.QuadPart) / 10000);
+ apxLogWrite(APXLOG_MARK_INFO "Service started in %d ms.", nms);
+ }
+ return rv;
+cleanup:
+ if (!IS_INVALID_HANDLE(gWorker))
+ apxCloseHandle(gWorker); /* Close the worker handle */
+ gWorker = NULL;
+ return rv;
+}
+
+/* Service control handler
+ */
+void WINAPI service_ctrl_handler(DWORD dwCtrlCode)
+{
+ switch (dwCtrlCode) {
+ case SERVICE_CONTROL_STOP:
+ apxLogWrite(APXLOG_MARK_INFO "Service STOP signaled");
+ reportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 0);
+ /* Call the stop handler that will actualy stop the service */
+ serviceStop();
+ return;
+ case SERVICE_CONTROL_INTERROGATE:
+ break;
+ default:
+ break;
+ }
+ reportServiceStatus(_service_status.dwCurrentState, NO_ERROR, 0);
+}
+
+/* Console control handler
+ *
+ */
+BOOL WINAPI console_handler(DWORD dwCtrlType)
+{
+ switch (dwCtrlType) {
+ case CTRL_BREAK_EVENT:
+ apxLogWrite(APXLOG_MARK_INFO "Console CTRL+BREAK event signaled");
+ return FALSE;
+ case CTRL_C_EVENT:
+ apxLogWrite(APXLOG_MARK_INFO "Console CTRL+C event signaled");
+ serviceStop();
+ return TRUE;
+ case CTRL_CLOSE_EVENT:
+ apxLogWrite(APXLOG_MARK_INFO "Console CTRL+CLOSE event signaled");
+ serviceStop();
+ return TRUE;
+ case CTRL_SHUTDOWN_EVENT:
+ apxLogWrite(APXLOG_MARK_INFO "Console SHUTDOWN event signaled");
+ serviceStop();
+ return TRUE;
+ case CTRL_LOGOFF_EVENT:
+ apxLogWrite(APXLOG_MARK_INFO "Console LOGOFF event signaled");
+ if (!_service_mode) {
+ serviceStop();
+ }
+ return TRUE;
+ break;
+
+ }
+ return FALSE;
+}
+
+/* Main service execution loop */
+void WINAPI serviceMain(DWORD argc, LPTSTR *argv)
+{
+ DWORD rc;
+ _service_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
+ _service_status.dwCurrentState = SERVICE_START_PENDING;
+ _service_status.dwControlsAccepted = SERVICE_ACCEPT_STOP |
+ SERVICE_ACCEPT_PAUSE_CONTINUE;
+ _service_status.dwWin32ExitCode = 0;
+ _service_status.dwCheckPoint = 0;
+ _service_status.dwWaitHint = 0;
+ _service_status.dwServiceSpecificExitCode = 0;
+
+ apxLogWrite(APXLOG_MARK_DEBUG "Inside ServiceMain...");
+
+ if (_service_name) {
+ WCHAR en[SIZ_DESLEN];
+ int i;
+ PSECURITY_ATTRIBUTES sa = GetNullACL();
+ lstrcpyW(en, _service_name);
+ lstrcatW(en, PRSRV_SIGNAL);
+ for (i = 0; i < lstrlenW(en); i++) {
+ if (en[i] >= L'a' && en[i] <= L'z')
+ en[i] = en[i] - 32;
+ }
+ gSignalEvent = CreateEventW(sa, TRUE, FALSE, en);
+ CleanNullACL((void *)sa);
+
+ if (gSignalEvent) {
+ DWORD tid;
+ gSignalThread = CreateThread(NULL, 0, eventThread, NULL, 0, &tid);
+ }
+ }
+ /* Check the StartMode */
+ if (SO_STARTMODE) {
+ if (!lstrcmpiW(SO_STARTMODE, PRSRV_JVM)) {
+ _jni_startup = TRUE;
+ WideToAscii(SO_STARTCLASS, _jni_rclass);
+ /* Exchange all dots with slashes */
+ apxStrCharReplaceA(_jni_rclass, '.', '/');
+ _jni_rparam = MzWideToAscii(SO_STARTPARAMS, (LPSTR)SO_STARTPARAMS);
+ }
+ else if (!lstrcmpiW(SO_STARTMODE, PRSRV_JAVA)) {
+ LPWSTR jx = NULL, szJH = apxGetJavaSoftHome(gPool, FALSE);
+ if (szJH) {
+ jx = apxPoolAlloc(gPool, (lstrlenW(szJH) + 16) * sizeof(WCHAR));
+ lstrcpyW(jx, szJH);
+ lstrcatW(jx, PRSRV_JBIN);
+ SO_STARTPATH = szJH;
+ }
+ /* StartImage now contains the full path to the java.exe */
+ SO_STARTIMAGE = jx;
+ }
+ }
+ /* Check the StopMode */
+ if (SO_STOPMODE) {
+ if (!lstrcmpiW(SO_STOPMODE, PRSRV_JVM)) {
+ _jni_shutdown = TRUE;
+ WideToAscii(SO_STOPCLASS, _jni_sclass);
+ apxStrCharReplaceA(_jni_sclass, '.', '/');
+ _jni_sparam = MzWideToAscii(SO_STOPPARAMS, (LPSTR)SO_STOPPARAMS);
+ }
+ else if (!lstrcmpiW(SO_STOPMODE, PRSRV_JAVA)) {
+ LPWSTR jx = NULL, szJH = apxGetJavaSoftHome(gPool, FALSE);
+ if (szJH) {
+ jx = apxPoolAlloc(gPool, (lstrlenW(szJH) + 16) * sizeof(WCHAR));
+ lstrcpyW(jx, szJH);
+ lstrcatW(jx, PRSRV_JBIN);
+ SO_STOPPATH = szJH;
+ }
+ /* StopImage now contains the full path to the java.exe */
+ SO_STOPIMAGE = jx;
+ }
+ }
+ /* Find the classpath */
+ if (_jni_shutdown || _jni_startup) {
+ if (SO_JVM) {
+ if (lstrcmpW(SO_JVM, PRSRV_AUTO))
+ _jni_jvmpath = SO_JVM;
+ }
+ if (SO_CLASSPATH)
+ _jni_classpath = WideToAscii(SO_CLASSPATH, (LPSTR)SO_CLASSPATH);
+ if (SO_STARTMETHOD)
+ _jni_rmethod = WideToAscii(SO_STARTMETHOD, (LPSTR)SO_STARTMETHOD);
+ if (SO_STOPMETHOD)
+ _jni_smethod = WideToAscii(SO_STOPMETHOD, (LPSTR)SO_STOPMETHOD);
+ if (SO_JVMOPTIONS) {
+ _jni_jvmoptions = MzWideToAscii(SO_JVMOPTIONS, (LPSTR)SO_JVMOPTIONS);
+ }
+ }
+ if (_service_mode) {
+ /* Register Service Control handler */
+ _service_status_handle = RegisterServiceCtrlHandlerW(_service_name,
+ service_ctrl_handler);
+ if (IS_INVALID_HANDLE(_service_status_handle)) {
+ apxLogWrite(APXLOG_MARK_ERROR "Failed to register Service Control for %S",
+ _service_name);
+ goto cleanup;
+ }
+ /* Allocate console so that events gets processed */
+ AllocConsole();
+ }
+ reportServiceStatus(SERVICE_START_PENDING, NO_ERROR, 3000);
+ if ((rc = serviceStart()) == 0) {
+ /* Service is started */
+ DWORD rv;
+ reportServiceStatus(SERVICE_RUNNING, NO_ERROR, 0);
+ apxLogWrite(APXLOG_MARK_DEBUG "Waiting worker to finish...");
+ /* Set console handler to capture CTRL events */
+ SetConsoleCtrlHandler((PHANDLER_ROUTINE)console_handler, TRUE);
+
+ rv = apxHandleWait(gWorker, INFINITE, FALSE);
+ apxLogWrite(APXLOG_MARK_DEBUG "Worker finished.");
+ reportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 0);
+ fflush(stdout);
+ }
+ else {
+ apxLogWrite(APXLOG_MARK_ERROR "ServiceStart returned %d", rc);
+ goto cleanup;
+ }
+ if (gShutdownEvent) {
+ /* Ensure that shutdown thread exits before us */
+ apxLogWrite(APXLOG_MARK_DEBUG "Waiting for ShutdownEvent");
+ WaitForSingleObject(gShutdownEvent, 60 * 1000);
+ apxLogWrite(APXLOG_MARK_DEBUG "ShutdownEvent signaled");
+ CloseHandle(gShutdownEvent);
+ }
+ reportServiceStatus(SERVICE_STOPPED, NO_ERROR, 0);
+
+ return;
+cleanup:
+ /* Cleanup */
+ reportServiceStatus(SERVICE_STOPPED, ERROR_SERVICE_SPECIFIC_ERROR, 0);
+ return;
+}
+
+
+/* Run the service in the debug mode */
+BOOL docmdDebugService(LPAPXCMDLINE lpCmdline)
+{
+ BOOL rv = FALSE;
+
+ _service_mode = FALSE;
+ _service_name = lpCmdline->szApplication;
+ apxLogWrite(APXLOG_MARK_INFO "Debugging Service...");
+ serviceMain(0, NULL);
+ apxLogWrite(APXLOG_MARK_INFO "Debug service finished.");
+
+ return rv;
+}
+
+BOOL docmdRunService(LPAPXCMDLINE lpCmdline)
+{
+ BOOL rv = FALSE;
+ _service_mode = TRUE;
+
+ apxLogWrite(APXLOG_MARK_INFO "Running Service...");
+ _service_name = lpCmdline->szApplication;
+ _service_table[0].lpServiceName = lpCmdline->szApplication;
+ _service_table[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTIONW)serviceMain;
+ rv = (StartServiceCtrlDispatcherW(_service_table) == FALSE);
+ apxLogWrite(APXLOG_MARK_INFO "Run service finished.");
+ return rv;
+}
+
+void __cdecl main(int argc, char **argv)
+{
+ UINT rv = 0;
+
+ LPAPXCMDLINE lpCmdline;
+
+ apxHandleManagerInitialize();
+ /* Create the main Pool */
+ gPool = apxPoolCreate(NULL, 0);
+
+ /* Parse the command line */
+ if ((lpCmdline = apxCmdlineParse(gPool, _options, _commands)) == NULL) {
+ apxLogWrite(APXLOG_MARK_ERROR "Invalid command line arguments");
+ rv = 1;
+ goto cleanup;
+ }
+ apxCmdlineLoadEnvVars(lpCmdline);
+ if (lpCmdline->dwCmdIndex < 5 &&
+ !loadConfiguration(lpCmdline)) {
+ apxLogWrite(APXLOG_MARK_ERROR "Load configuration failed");
+ rv = 2;
+ goto cleanup;
+ }
+
+ apxLogOpen(gPool, SO_LOGPATH, SO_LOGPREFIX);
+ apxLogLevelSetW(NULL, SO_LOGLEVEL);
+ apxLogWrite(APXLOG_MARK_DEBUG "Procrun log initialized");
+
+ AplZeroMemory(&gStdwrap, sizeof(APX_STDWRAP));
+
+ gStdwrap.szLogPath = SO_LOGPATH;
+ /* In debug mode allways use console */
+ if (lpCmdline->dwCmdIndex != 1) {
+ gStdwrap.szStdOutFilename = SO_STDOUTPUT;
+ gStdwrap.szStdErrFilename = SO_STDERROR;
+ }
+ redirectStdStreams(&gStdwrap);
+ switch (lpCmdline->dwCmdIndex) {
+ case 1: /* Run Service as console application */
+ if (!docmdDebugService(lpCmdline))
+ rv = 3;
+ break;
+ case 2: /* Run Service */
+ if (!docmdRunService(lpCmdline))
+ rv = 4;
+ break;
+ case 3: /* Stop Service */
+ if (!docmdStopService(lpCmdline))
+ rv = 5;
+ break;
+ case 4: /* Update Service parameters */
+ if (!docmdUpdateService(lpCmdline))
+ rv = 6;
+ break;
+ case 5: /* Install Service */
+ if (!docmdInstallService(lpCmdline))
+ rv = 7;
+ break;
+ case 6: /* Delete Service */
+ if (!docmdDeleteService(lpCmdline))
+ rv = 8;
+ break;
+ default:
+ /* Unknown command option */
+ apxLogWrite(APXLOG_MARK_ERROR "Unknown command line option");
+ printUsage(lpCmdline);
+ rv = 99;
+ break;
+ }
+
+cleanup:
+ apxLogWrite(APXLOG_MARK_INFO "Procrun finished.");
+ if (lpCmdline)
+ apxCmdlineFree(lpCmdline);
+ if (_service_status_handle)
+ CloseHandle(_service_status_handle);
+ _service_status_handle = NULL;
+ apxLogClose(NULL);
+ apxHandleManagerDestroy();
+ cleanupStdStreams(&gStdwrap);
+ ExitProcess(rv);
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunsrv/prunsrv.dsp
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunsrv/prunsrv.dsp 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunsrv/prunsrv.dsp 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,166 @@
+# Microsoft Developer Studio Project File - Name="prunsrv" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=prunsrv - Win32 Unicode 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 "prunsrv.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 "prunsrv.mak" CFG="prunsrv - Win32 Unicode Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "prunsrv - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "prunsrv - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "prunsrv - Win32 Unicode Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "prunsrv - Win32 Unicode 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)" == "prunsrv - 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 /MD /W3 /GX /O2 /I "..\..\include" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x41a /d "NDEBUG"
+# ADD RSC /l 0x41a /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 shlwapi.lib /nologo /stack:0x40000 /subsystem:console /machine:I386
+
+!ELSEIF "$(CFG)" == "prunsrv - 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 /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x41a /d "_DEBUG"
+# ADD RSC /l 0x41a /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 shlwapi.lib /nologo /stack:0x40000 /subsystem:console /debug /machine:I386 /out:"Debug/prunsrvd.exe" /pdbtype:sept
+
+!ELSEIF "$(CFG)" == "prunsrv - Win32 Unicode Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Unicode Release"
+# PROP BASE Intermediate_Dir "Unicode Release"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Unicode Release"
+# PROP Intermediate_Dir "Unicode Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /YX /FD /c
+# ADD BASE RSC /l 0x41a /d "NDEBUG"
+# ADD RSC /l 0x41a /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 shlwapi.lib /nologo /stack:0x40000 /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 shlwapi.lib /nologo /stack:0x40000 /subsystem:console /machine:I386 /out:"Unicode Release/prunsrvu.exe"
+
+!ELSEIF "$(CFG)" == "prunsrv - Win32 Unicode Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Unicode Debug"
+# PROP BASE Intermediate_Dir "Unicode Debug"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Unicode Debug"
+# PROP Intermediate_Dir "Unicode Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x41a /d "_DEBUG"
+# ADD RSC /l 0x41a /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 shlwapi.lib /nologo /stack:0x40000 /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 shlwapi.lib /nologo /stack:0x40000 /subsystem:console /debug /machine:I386 /out:"Unicode Debug/prunsrvdu.exe" /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "prunsrv - Win32 Release"
+# Name "prunsrv - Win32 Debug"
+# Name "prunsrv - Win32 Unicode Release"
+# Name "prunsrv - Win32 Unicode Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\prunsrv.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\prunsrv.h
+# End Source File
+# 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=.\prunsrv.rc
+# ADD BASE RSC /l 0x41a
+# ADD RSC /l 0x41a /i "..\..\include"
+# End Source File
+# End Group
+# End Target
+# End Project
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunsrv/prunsrv.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunsrv/prunsrv.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunsrv/prunsrv.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,31 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* ====================================================================
+ * jar2exe -- convert .jar file to WIN32 executable.
+ * Contributed by Mladen Turk <mturk at apache.org>
+ * 05 Aug 2003
+ * ====================================================================
+ */
+
+#ifndef _PRUNSRV_H
+#define _PRUNSRV_H
+
+#undef PRG_VERSION
+#define PRG_VERSION "2.0.1.0"
+#define PRG_REGROOT L"Apache Software Foundation\\Procrun 2.0"
+
+#endif /* _PRUNSRV_H */
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunsrv/prunsrv.rc
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunsrv/prunsrv.rc 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunsrv/prunsrv.rc 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,55 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apxwin.h"
+#include "prunsrv.h"
+
+#define RSTR_PRUNSRV "Service Runner"
+
+IDI_MAINICON ICON "../../resources/procrunw.ico"
+
+1 VERSIONINFO
+ FILEVERSION 2,0,1,0
+ PRODUCTVERSION 2,0,1,0
+ FILEFLAGSMASK 0x3fL
+#if defined(_DEBUG)
+ FILEFLAGS 0x03L
+#else
+ FILEFLAGS 0x02L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "Comments", "\0"
+ VALUE "CompanyName", "Apache Software Foundation\0"
+ VALUE "FileDescription", RSTR_PRUNSRV "\0"
+ VALUE "FileVersion", PRG_VERSION
+ VALUE "InternalName", RSTR_PRUNSRV "\0"
+ VALUE "LegalCopyright", "Copyright © 2000-2006 The Apache Software Foundation.\0"
+ VALUE "OriginalFilename", "prunsrv.exe\0"
+ VALUE "ProductName", RSTR_PRUNSRV "\0"
+ VALUE "ProductVersion", PRG_VERSION
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunsrv/prunsrv.vcproj
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunsrv/prunsrv.vcproj 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/prunsrv/prunsrv.vcproj 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,400 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8,00"
+ Name="prunsrv"
+ ProjectGUID="{19338164-D7E8-492D-9D4C-F34766964979}"
+ RootNamespace="prunsrv"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ <Platform
+ Name="x64"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\include;$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="shlwapi.lib"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\include;$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="shlwapi.lib"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|x64"
+ OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\include;$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32"
+ PreprocessorDefinitions="WIN32;WIN64;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="shlwapi.lib"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="17"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|x64"
+ OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\include;$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32"
+ PreprocessorDefinitions="WIN32;WIN64;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="shlwapi.lib"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="17"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\prunsrv.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\prunsrv.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ <File
+ RelativePath=".\prunsrv.rc"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="..\..\include"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="..\..\include"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|x64"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="..\..\include"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|x64"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="..\..\include"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/MSG00001.bin
===================================================================
(Binary files differ)
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/MSG00001.bin
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/example/example.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/example/example.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/example/example.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,59 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <process.h>
+
+HANDLE hGlobalEvent;
+#define EVENT_NAME "ServBatchExampleEvent"
+
+
+int main(int argc, char **argv)
+{
+ int mode = 0;
+ int i;
+
+ for (i = 0; i < argc; i++)
+ fprintf(stdout, "Command line param [%d] = %s\n", i, argv[i]);
+
+ if (argc > 1 && stricmp(argv[1], "stop") == 0)
+ mode = 1;
+
+ if (mode) {
+ fprintf(stdout, "Stopping service\n");
+ hGlobalEvent = OpenEvent(EVENT_MODIFY_STATE, FALSE, EVENT_NAME);
+ if (!hGlobalEvent)
+ fprintf(stderr, "Unable to upen the Global Event\n");
+ else {
+ fprintf(stdout, "Signaling service event\n");
+ SetEvent(hGlobalEvent);
+ }
+
+ }
+ else {
+ fprintf(stdout, "Starting service\n");
+ hGlobalEvent = CreateEvent(NULL, FALSE, FALSE, EVENT_NAME);
+ WaitForSingleObject(hGlobalEvent, INFINITE);
+ fprintf(stdout, "Event Signaled\n");
+ }
+
+ fprintf(stdout, "Service mode %d finished\n", mode);
+ return 0;
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/example/example.vcproj
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/example/example.vcproj 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/example/example.vcproj 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="example"
+ ProjectGUID="{1C38835C-714F-49F3-85FC-9E6372149DF3}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="example.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/example.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/example.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath=".\example.c">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/example/exservice.bat
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/example/exservice.bat 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/example/exservice.bat 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,53 @@
+ at echo off
+REM Copyright 2000-2004 The Apache Software Foundation
+REM
+REM Licensed under the Apache License, Version 2.0 (the "License");
+REM you may not use this file except in compliance with the License.
+REM You may obtain a copy of the License at
+REM
+REM http://www.apache.org/licenses/LICENSE-2.0
+REM
+REM Unless required by applicable law or agreed to in writing, software
+REM distributed under the License is distributed on an "AS IS" BASIS,
+REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+REM See the License for the specific language governing permissions and
+REM limitations under the License.
+REM
+
+ at if not "%ECHO%" == "" echo %ECHO%
+ at if "%OS%" == "Windows_NT" setlocal
+
+set SERVICE_EXECUTABLE=example.exe
+
+REM Figure out the running mode
+
+ at if "%1" == "install" goto cmdInstall
+ at if "%1" == "uninstall" goto cmdUninstall
+ at if "%1" == "start" goto cmdStart
+ at if "%1" == "stop" goto cmdStop
+ at if "%1" == "restart" goto cmdRestart
+echo Usage
+goto cmdEnd
+
+:cmdInstall
+..\Debug\srvbatch.exe -iwdcl SrvbatchExample "%CD%" "Srvbatch Example Service" "This is an Example service" exservice.bat
+goto cmdEnd
+
+:cmdUninstall
+..\Debug\srvbatch.exe -u SrvbatchExample
+goto cmdEnd
+
+:cmdStart
+%SERVICE_EXECUTABLE% start
+goto cmdEnd
+
+:cmdStop
+%SERVICE_EXECUTABLE% stop
+goto cmdEnd
+
+:cmdRestart
+%SERVICE_EXECUTABLE% stop
+%SERVICE_EXECUTABLE% start
+goto cmdEnd
+
+:cmdEnd
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/srvbatch.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/srvbatch.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/srvbatch.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,827 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <process.h>
+
+/* Custom return error values */
+#define ERR_RET_USAGE 1
+#define ERR_RET_VERSION 2
+#define ERR_RET_INSTALL 3
+#define ERR_RET_REMOVE 4
+#define ERR_RET_PARAMS 5
+#define ERR_RET_MODE 6
+
+#define MSG_ERROR 0xC0000001L
+#define MSG_INFO 0x40000002L
+
+
+
+#define MAX_CMDLINE 8192
+/* Extensions On, Old quote style */
+static LPCSTR CMD_DEFAULT = "/E:ON /S /C \"SET SERVICE_PPID=%d && SET SERVICE_NAME=%s && CALL %s %s";
+static LPCSTR REGSERVICE_ROOT = "SYSTEM\\CurrentControlSet\\Services\\";
+static LPCSTR REGSERVICE_LOG = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\";
+
+static LPCSTR REGPARAMS = "\\Parameters";
+static LPCSTR REGDESCRIPTION = "Description";
+static LPCSTR REG_SERVFILE = "ServiceFile";
+static LPCSTR REG_LOGFILE = "LogFile";
+static LPCSTR REG_WPATH = "WorkingPath";
+
+
+/* Main servic table entry
+ * filled at run-time
+ */
+static SERVICE_TABLE_ENTRY _service_table[] = {
+ {NULL, NULL},
+ {NULL, NULL}
+};
+
+static SERVICE_STATUS _service_status;
+static SERVICE_STATUS_HANDLE _service_status_handle = NULL;
+static char _service_name[MAX_PATH + 1];
+static char _service_disp[MAX_PATH + 1];
+static char _service_desc[MAX_PATH * 2 + 1];
+static char _working_path[MAX_PATH + 1];
+static char _service_image[MAX_PATH + 1];
+static char _service_bat[MAX_PATH + 1];
+static char _cmd_exe[MAX_PATH + 1];
+static BOOL _service_log = FALSE;
+
+enum _service_mode_e {
+ mode_none,
+ mode_install,
+ mode_uninstall,
+ mode_debug,
+ mode_run
+};
+
+static enum _service_mode_e _service_mode = mode_none;
+
+static BOOL IsWindowsNT()
+{
+ BOOL rv = FALSE;
+ OSVERSIONINFO osvi;
+
+ ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+
+ if (!GetVersionEx(&osvi))
+ return FALSE;
+
+ switch (osvi.dwPlatformId) {
+ case VER_PLATFORM_WIN32_NT:
+ rv = TRUE;
+ break;
+ default:
+ rv = FALSE;
+ break;
+ }
+ return rv;
+}
+
+
+static BOOL IsServiceRunning(LPCSTR szServiceName)
+{
+ DWORD rc = 0;
+ SC_HANDLE schService;
+ SC_HANDLE schSCManager;
+ SERVICE_STATUS schSStatus;
+
+ schSCManager = OpenSCManager(NULL, NULL,
+ SC_MANAGER_CONNECT);
+ if (!schSCManager)
+ return FALSE;
+
+ schService = OpenService(schSCManager, szServiceName,
+ SERVICE_QUERY_STATUS);
+ if (schService != NULL) {
+ if (QueryServiceStatus(schService, &schSStatus))
+ rc = schSStatus.dwCurrentState;
+ CloseServiceHandle(schService);
+ CloseServiceHandle(schSCManager);
+ return rc == SERVICE_RUNNING ? TRUE : FALSE;
+ }
+ CloseServiceHandle(schSCManager);
+ return FALSE;
+
+}
+
+static void AddToMessageLog(BOOL isError, LPSTR szFormat, ...)
+{
+ char szMsg [MAX_PATH];
+ LPSTR lpszStrings[2];
+ LPVOID lpMsgBuf = NULL;
+ HANDLE hEventSource;
+ DWORD dwErr = GetLastError();
+ WORD wErrType;
+ DWORD dwErrId;
+ WORD nStr;
+ va_list args;
+
+ if (!_service_log && !isError) {
+ /* Nothing to log */
+ return;
+ }
+
+ va_start(args, szFormat);
+ vsprintf(szMsg, szFormat, args);
+ va_end(args);
+
+ if (isError) {
+ nStr = 2;
+ wErrType = EVENTLOG_ERROR_TYPE;
+ dwErrId = MSG_ERROR;
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, LANG_NEUTRAL),
+ (LPSTR) &lpMsgBuf, 0, NULL);
+ lpszStrings[0] = lpMsgBuf;
+ lpszStrings[1] = szMsg;
+ }
+ else {
+ wErrType = EVENTLOG_INFORMATION_TYPE;
+ dwErrId = MSG_INFO;
+ nStr = 1;
+ lpszStrings[0] = szMsg;
+ }
+ /* Use event logging to log the error.
+ */
+ hEventSource = RegisterEventSource(NULL, _service_name);
+
+ if (hEventSource != NULL) {
+ ReportEvent(hEventSource, // handle of event source
+ wErrType, // event type
+ 0, // event category
+ dwErrId, // event ID
+ NULL, // current user's SID
+ nStr, // strings in lpszStrings
+ 0, // no bytes of raw data
+ lpszStrings, // array of error strings
+ NULL); // no raw data
+ DeregisterEventSource(hEventSource);
+ }
+ if (lpMsgBuf)
+ LocalFree(lpMsgBuf);
+}
+
+static void ErrorUsage()
+{
+ if (_service_mode == mode_run)
+ return;
+
+ fprintf(stderr, "srvbatch -- program for running batch files as services.\n\n");
+ fprintf(stderr, "Usage: srvbatch -i service service.bat\n");
+ fprintf(stderr, " -i[wdcl] service workingpath description comment\n"
+ " service.bat\n");
+ fprintf(stderr, " -u service\n");
+ fprintf(stderr, " -t service\n");
+ fprintf(stderr, "Options:\n");
+ fprintf(stderr, " -d Service display name\n");
+ fprintf(stderr, " -c Service description\n");
+ fprintf(stderr, " -w Service working path\n");
+ fprintf(stderr, " -l Turn info logging On\n");
+
+ ExitProcess(ERR_RET_USAGE);
+}
+
+static void DumpParams()
+{
+ if (_service_mode == mode_run)
+ return;
+
+ fprintf(stdout, "Name %s\n", _service_name);
+ fprintf(stdout, "Display %s\n", _service_disp);
+ fprintf(stdout, "Description %s\n", _service_desc);
+ fprintf(stdout, "ImagePath %s\n", _service_image);
+ fprintf(stdout, "Shell %s\n", _cmd_exe);
+ fprintf(stdout, "WorkingPath %s\n", _working_path);
+ fprintf(stdout, "Service Script %s\n", _service_bat);
+
+}
+
+static void BuildCommandLine(char *buf, const char *action)
+{
+
+ ZeroMemory(buf, MAX_CMDLINE);
+ lstrcpy(buf, _cmd_exe);
+ lstrcat(buf, " ");
+ buf += lstrlen(buf);
+
+ sprintf(buf, CMD_DEFAULT, getpid(), _service_name, _service_bat, action);
+ lstrcat(buf, "\"");
+ fprintf(stdout, "Service Cmd %s\n", buf);
+}
+
+/* We could use the ChangeServiceConfig2 on WIN2K+
+ * For now use the registry.
+ */
+static BOOL SetServiceDescription(LPCSTR szServiceName,
+ LPCSTR szDescription)
+{
+ HKEY hKey;
+ CHAR szName[MAX_PATH + 1];
+ DWORD rc;
+
+ if (lstrlen(szServiceName) > MAX_PATH)
+ return FALSE;
+ lstrcpy(szName, REGSERVICE_ROOT);
+ lstrcat(szName, szServiceName);
+
+ rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, szName, 0, KEY_WRITE, &hKey);
+ if (rc != ERROR_SUCCESS) {
+ return FALSE;
+ }
+
+ rc = RegSetValueEx(hKey, REGDESCRIPTION, 0, REG_SZ,
+ (CONST BYTE *)szDescription,
+ lstrlen(szDescription) + 1);
+ CloseHandle(hKey);
+
+ return rc == ERROR_SUCCESS;
+}
+
+/* We could use the ChangeServiceConfig2 on WIN2K+
+ * For now use the registry.
+ */
+static BOOL SetServiceEventLog(LPCSTR szServiceName)
+{
+ HKEY hKey;
+ CHAR szName[MAX_PATH + 1];
+ DWORD dwData;
+
+ if (lstrlen(szServiceName) > MAX_PATH)
+ return FALSE;
+ lstrcpy(szName, REGSERVICE_LOG);
+ lstrcat(szName, szServiceName);
+
+ RegCreateKey(HKEY_LOCAL_MACHINE, szName, &hKey);
+
+ if (!GetModuleFileName(NULL, szName, MAX_PATH)) {
+ RegCloseKey(hKey);
+ return FALSE;
+ }
+
+ RegSetValueEx(hKey, "EventMessageFile", 0, REG_SZ, (LPBYTE)szName,
+ lstrlen(szName) + 1);
+ dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE |
+ EVENTLOG_INFORMATION_TYPE;
+
+ RegSetValueEx(hKey, "TypesSupported", 0, REG_DWORD, (LPBYTE)&dwData,
+ sizeof(DWORD));
+
+ RegFlushKey(hKey);
+ RegCloseKey(hKey);
+
+ return TRUE;
+}
+
+BOOL SetServiceParameters(LPCSTR szServiceName)
+{
+ HKEY hKey;
+ CHAR szName[MAX_PATH + 1];
+ DWORD rc;
+ BOOL rv = TRUE;
+
+ if (lstrlen(szServiceName) > MAX_PATH)
+ return FALSE;
+
+ lstrcpy(szName, REGSERVICE_ROOT);
+ lstrcat(szName, szServiceName);
+ lstrcat(szName, REGPARAMS);
+
+ rc = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
+ szName,
+ 0,
+ NULL,
+ 0,
+ KEY_WRITE,
+ NULL,
+ &hKey,
+ NULL);
+ if (rc != ERROR_SUCCESS) {
+ rv = FALSE;
+ goto cleanup;
+ }
+ rc = RegSetValueEx(hKey, REG_SERVFILE, 0, REG_SZ,
+ (CONST BYTE *)_service_bat,
+ lstrlen(_service_bat) + 1);
+ if (rc != ERROR_SUCCESS) {
+ rv = FALSE;
+ goto cleanup;
+ }
+ if (_service_log) {
+ rc = RegSetValueEx(hKey, REG_LOGFILE, 0, REG_DWORD,
+ (CONST BYTE *)&_service_log,
+ sizeof(DWORD));
+ if (rc != ERROR_SUCCESS) {
+ rv = FALSE;
+ goto cleanup;
+ }
+ }
+ if (lstrlen(_working_path)) {
+ rc = RegSetValueEx(hKey, REG_WPATH, 0, REG_SZ,
+ (CONST BYTE *)_working_path,
+ lstrlen(_working_path) + 1);
+ if (rc != ERROR_SUCCESS) {
+ rv = FALSE;
+ goto cleanup;
+ }
+ }
+
+cleanup:
+ CloseHandle(hKey);
+ return rv;
+}
+
+BOOL GetServiceParameters(LPCSTR szServiceName)
+{
+ HKEY hKey;
+ CHAR szName[MAX_PATH + 1];
+ DWORD rc;
+ BOOL rv = TRUE;
+ DWORD dwType;
+ DWORD dwSize;
+
+ if (lstrlen(szServiceName) > MAX_PATH)
+ return FALSE;
+ lstrcpy(szName, REGSERVICE_ROOT);
+ lstrcat(szName, szServiceName);
+ lstrcat(szName, REGPARAMS);
+ rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, szName, 0, KEY_READ, &hKey);
+ if (rc != ERROR_SUCCESS) {
+ return FALSE;
+ }
+ dwSize = MAX_PATH + 1;
+ rc = RegQueryValueEx(hKey, REG_SERVFILE, NULL, &dwType,
+ (LPBYTE)_service_bat, &dwSize);
+ if (rc != ERROR_SUCCESS || dwType != REG_SZ) {
+ rv = FALSE;
+ goto cleanup;
+ }
+ dwSize = sizeof(DWORD);
+ rc = RegQueryValueEx(hKey, REG_LOGFILE, NULL, &dwType,
+ (LPBYTE)&_service_log, &dwSize);
+ if (rc != ERROR_SUCCESS || dwType != REG_DWORD) {
+ _service_log = FALSE;
+ }
+ dwSize = MAX_PATH + 1;
+ rc = RegQueryValueEx(hKey, REG_WPATH, NULL, &dwType,
+ (LPBYTE)_working_path, &dwSize);
+ if (rc != ERROR_SUCCESS || dwType != REG_SZ) {
+ _working_path[0] = '\0';
+ }
+
+ if (GetSystemDirectory(szName, MAX_PATH + 1)) {
+ lstrcat(szName, "\\cmd.exe");
+ if (strchr(_cmd_exe, ' ')) {
+ _cmd_exe[0] = '"';
+ lstrcpy(&_cmd_exe[1], szName);
+ lstrcat(_cmd_exe, "\"");
+ }
+ else
+ lstrcpy(_cmd_exe, szName);
+ }
+
+cleanup:
+ CloseHandle(hKey);
+ return rv;
+}
+
+BOOL InstallService(LPCSTR szServiceName)
+{
+ char szImage[MAX_PATH + 1];
+ char szPath[MAX_PATH + 1];
+ char *p;
+ BOOL rv = TRUE;
+ SC_HANDLE hManager;
+ SC_HANDLE hService;
+
+ if (!(hManager = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE))) {
+ return FALSE;
+ }
+
+ p = &szImage[1];
+ if (!GetModuleFileName(NULL, p, MAX_PATH)) {
+ rv = FALSE;
+ goto cleanup;
+ }
+ lstrcpy(szPath, p);
+
+ if ((p = strrchr(szPath, '\\'))) {
+ *p = '\0';
+ }
+ szImage[0] = '"';
+ lstrcat(szImage, "\" -r ");
+ lstrcat(szImage, szServiceName);
+ if (!_working_path[0])
+ lstrcpy(_working_path, szPath);
+
+ hService = CreateService(hManager, // SCManager database
+ _service_name, // name of service
+ _service_disp, // name to display
+ SERVICE_ALL_ACCESS, // access required
+ SERVICE_WIN32_OWN_PROCESS, // service type
+ SERVICE_AUTO_START, // start type
+ SERVICE_ERROR_NORMAL, // error control type
+ szImage, // service's binary
+ NULL, // no load svc group
+ NULL, // no tag identifier
+ "Tcpip\0Afd\0", // dependencies
+ NULL, // use SYSTEM account
+ NULL); // no password
+ if (!hService) {
+ rv = FALSE;
+ goto cleanup;
+ }
+cleanup:
+ if (hService)
+ CloseServiceHandle(hService);
+ CloseServiceHandle(hManager);
+
+ return rv;
+}
+
+BOOL RemoveService(LPCSTR szServiceName)
+{
+ BOOL rv = TRUE;
+ SC_HANDLE hManager;
+ SC_HANDLE hService;
+
+ if (!(hManager = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT))) {
+ return FALSE;
+ }
+ hService = OpenService(hManager, _service_name, DELETE);
+ if (!hService) {
+ rv = FALSE;
+ goto cleanup;
+ }
+
+ rv = DeleteService(hService);
+
+cleanup:
+ if (hService)
+ CloseServiceHandle(hService);
+ CloseServiceHandle(hManager);
+ return rv;
+
+}
+
+/* Report the service status to the SCM
+ */
+BOOL ReportServiceStatus(DWORD dwCurrentState,
+ DWORD dwWin32ExitCode,
+ DWORD dwWaitHint)
+{
+ static DWORD dwCheckPoint = 1;
+ BOOL fResult = TRUE;
+
+ if (_service_mode == mode_run && _service_status_handle) {
+ if (dwCurrentState == SERVICE_START_PENDING)
+ _service_status.dwControlsAccepted = 0;
+ else
+ _service_status.dwControlsAccepted = SERVICE_ACCEPT_STOP;
+
+ _service_status.dwCurrentState = dwCurrentState;
+ _service_status.dwWin32ExitCode = dwWin32ExitCode;
+ _service_status.dwWaitHint = dwWaitHint;
+
+ if ((dwCurrentState == SERVICE_RUNNING) ||
+ (dwCurrentState == SERVICE_STOPPED))
+ _service_status.dwCheckPoint = 0;
+ else
+ _service_status.dwCheckPoint = dwCheckPoint++;
+ fResult = SetServiceStatus(_service_status_handle, &_service_status);
+ if (!fResult) {
+ /* TODO: Deal with error */
+ }
+ }
+ return fResult;
+}
+
+static BOOL RunChildProcess(LPCSTR szApplication, LPSTR szCmdLine,
+ LPPROCESS_INFORMATION lpprInfo)
+{
+ STARTUPINFO stInfo;
+ BOOL bResult;
+
+ ZeroMemory(&stInfo, sizeof(stInfo));
+ stInfo.cb = sizeof(stInfo);
+ stInfo.dwFlags = STARTF_USESHOWWINDOW;
+ stInfo.wShowWindow = SW_HIDE;
+
+ bResult = CreateProcess(szApplication,
+ szCmdLine,
+ NULL,
+ NULL,
+ TRUE,
+ CREATE_NEW_PROCESS_GROUP,
+ NULL,
+ _working_path,
+ &stInfo,
+ lpprInfo);
+
+ return bResult;
+}
+
+
+/* Executed when the service receives stop event */
+static DWORD ServiceStop()
+{
+ DWORD rv;
+ PROCESS_INFORMATION prInfo;
+ char cmd[MAX_CMDLINE + 1];
+
+ if (!IsServiceRunning(_service_name)) {
+ AddToMessageLog(FALSE, "Service %s is already stopped", _service_name);
+ return 0;
+ }
+ BuildCommandLine(cmd, "stop");
+ AddToMessageLog(FALSE, "Stopping service %s", _service_name);
+ if (RunChildProcess(_cmd_exe, cmd, &prInfo)) {
+ ReportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 0);
+ rv = WaitForSingleObject(prInfo.hProcess, INFINITE);
+ AddToMessageLog(FALSE, "Stopped service %s", _service_name);
+ CloseHandle(prInfo.hProcess);
+ CloseHandle(prInfo.hThread);
+ return 0;
+ }
+ else {
+ AddToMessageLog(TRUE, "Stopping service %s", _service_name);
+ return 1;
+ }
+}
+
+/* Executed when the service receives restart event */
+static DWORD ServiceRestart()
+{
+ DWORD rv;
+ PROCESS_INFORMATION prInfo;
+ char cmd[MAX_CMDLINE + 1];
+
+ BuildCommandLine(cmd, "restart");
+ ReportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 0);
+ if (RunChildProcess(_cmd_exe, cmd, &prInfo)) {
+ ReportServiceStatus(SERVICE_RUNNING, NO_ERROR, 0);
+ rv = WaitForSingleObject(prInfo.hProcess, INFINITE);
+ printf("Restart Wait %d %d\n", rv, WAIT_OBJECT_0);
+ CloseHandle(prInfo.hProcess);
+ CloseHandle(prInfo.hThread);
+ rv = 0;
+ }
+ else {
+ AddToMessageLog(TRUE, "Restarting service %s", _service_name);
+ rv = 1;
+ }
+ ReportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 0);
+ ReportServiceStatus(SERVICE_STOPPED, NO_ERROR, 0);
+
+ return rv;
+}
+
+/* Service controll handler
+ */
+void WINAPI ServiceCtrlHandler(DWORD dwCtrlCode)
+{
+
+ switch (dwCtrlCode) {
+ case SERVICE_CONTROL_STOP:
+ ReportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 0);
+ /* Call the stop handler that will actualy stop the service */
+ ServiceStop();
+ return;
+ case SERVICE_CONTROL_INTERROGATE:
+ break;
+ default:
+ break;
+ }
+ ReportServiceStatus(_service_status.dwCurrentState, NO_ERROR, 0);
+}
+
+/* Console control handler
+ *
+ */
+BOOL WINAPI ConsoleHandler(DWORD dwCtrlType)
+{
+
+ switch (dwCtrlType) {
+ case CTRL_BREAK_EVENT:
+ if (_service_mode == mode_run) {
+ ServiceStop();
+ return TRUE;
+ }
+ else
+ return FALSE;
+ case CTRL_C_EVENT:
+ case CTRL_CLOSE_EVENT:
+ case CTRL_SHUTDOWN_EVENT:
+ ServiceStop();
+ return TRUE;
+ break;
+ }
+
+ return FALSE;
+}
+
+/* Executed when the service receives start event */
+static DWORD ServiceStart()
+{
+ DWORD rv;
+ PROCESS_INFORMATION prInfo;
+ char cmd[MAX_CMDLINE + 1];
+
+ BuildCommandLine(cmd, "start");
+
+ DumpParams();
+
+ AddToMessageLog(FALSE, "Starting service %s", _service_name);
+ if (RunChildProcess(_cmd_exe, cmd, &prInfo)) {
+ AddToMessageLog(FALSE, "Started service %s", _service_name);
+ ReportServiceStatus(SERVICE_RUNNING, NO_ERROR, 0);
+ SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleHandler, TRUE);
+
+ rv = WaitForSingleObject(prInfo.hProcess, INFINITE);
+ AddToMessageLog(FALSE, "Finished service %s", _service_name);
+ ReportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 0);
+ ReportServiceStatus(SERVICE_STOPPED, NO_ERROR, 0);
+
+ CloseHandle(prInfo.hProcess);
+ CloseHandle(prInfo.hThread);
+ return 0;
+ }
+ else {
+ AddToMessageLog(TRUE, "Starting service %s", _service_name);
+ return 1;
+ }
+}
+
+/* Main service execution loop */
+void WINAPI ServiceMain(DWORD argc, LPTSTR *argv)
+{
+ DWORD rc;
+ _service_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
+ _service_status.dwCurrentState = SERVICE_START_PENDING;
+ _service_status.dwControlsAccepted = SERVICE_ACCEPT_STOP |
+ SERVICE_ACCEPT_PAUSE_CONTINUE;
+ _service_status.dwWin32ExitCode = 0;
+ _service_status.dwCheckPoint = 0;
+ _service_status.dwWaitHint = 0;
+ _service_status.dwServiceSpecificExitCode = 0;
+
+ if (_service_mode == mode_run) {
+ /* Register Service Control handler */
+ _service_status_handle = RegisterServiceCtrlHandler(_service_name,
+ ServiceCtrlHandler);
+ if (!_service_status_handle) {
+ AddToMessageLog(TRUE, "RegisterServiceCtrlHandler failed for %s",
+ _service_name);
+ goto cleanup;
+ }
+ }
+ ReportServiceStatus(SERVICE_START_PENDING, NO_ERROR, 3000);
+ if ((rc = ServiceStart()) == 0) {
+ AddToMessageLog(FALSE, "Service %s Main finished", _service_name);
+ }
+
+ return;
+cleanup:
+ /* Cleanup */
+ ReportServiceStatus(SERVICE_STOPPED, ERROR_SERVICE_SPECIFIC_ERROR, 0);
+ return;
+}
+
+
+void __cdecl main(int argc, char **argv)
+{
+ UINT rv = 0;
+ char *arg;
+ int i;
+ int args_left = 1;
+ int need_desc = 0;
+ int need_disp = 0;
+ int need_path = 0;
+
+ if (argc < 3) {
+ ErrorUsage();
+ }
+
+ if (!IsWindowsNT()) {
+ fprintf(stderr, "This program will run only on Windows NT or higher\n");
+ ExitProcess(ERR_RET_VERSION);
+ }
+
+ for (i = 1; i < argc; i++) {
+ arg = argv[i];
+ if (*arg != '-')
+ break;
+
+ while (*++arg != '\0') {
+ switch (*arg) {
+ case 'i':
+ _service_mode = mode_install;
+ args_left++;
+ break;
+ case 'u':
+ _service_mode = mode_uninstall;
+ break;
+ case 't':
+ _service_mode = mode_debug;
+ break;
+ case 'r':
+ _service_mode = mode_run;
+ break;
+ case 'd':
+ need_disp = 1;
+ args_left++;
+ break;
+ case 'c':
+ need_desc = 1;
+ args_left++;
+ break;
+ case 'w':
+ need_path = 1;
+ args_left++;
+ break;
+ case 'l':
+ _service_log = TRUE;
+ break;
+ default:
+ ErrorUsage();
+ break;
+ }
+ }
+ }
+ if ((argc - i) < args_left)
+ ErrorUsage();
+ lstrcpy(_service_name, argv[i++]);
+ if (need_path)
+ lstrcpy(_working_path, argv[i++]);
+ if (need_disp)
+ lstrcpy(_service_disp, argv[i++]);
+ if (need_desc)
+ lstrcpy(_service_desc, argv[i++]);
+
+ SetServiceEventLog(_service_name);
+ if (_service_mode == mode_install) {
+ lstrcpy(_service_bat, argv[i++]);
+ if (!InstallService(_service_name)) {
+ rv = ERR_RET_INSTALL;
+ AddToMessageLog(TRUE, "Failed installing %s", _service_name);
+ goto cleanup;
+ }
+ SetServiceParameters(_service_name);
+ if (need_desc)
+ SetServiceDescription(_service_name, _service_desc);
+ AddToMessageLog(FALSE, "Installed %s", _service_name);
+ }
+ else if (_service_mode == mode_uninstall) {
+ GetServiceParameters(_service_name);
+ AddToMessageLog(FALSE, "Uninstalling %s", _service_name);
+ ServiceStop();
+ if (!RemoveService(_service_name)) {
+ AddToMessageLog(TRUE, "Failed removing %s", _service_name);
+ rv = ERR_RET_REMOVE;
+ }
+ }
+ else if (_service_mode == mode_run) {
+ GetServiceParameters(_service_name);
+ AddToMessageLog(FALSE, "Initialized %s", _service_name);
+ _service_table[0].lpServiceName = _service_name;
+ _service_table[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)ServiceMain;
+ StartServiceCtrlDispatcher(_service_table);
+ }
+ else if (_service_mode == mode_debug) {
+ GetServiceParameters(_service_name);
+ AddToMessageLog(FALSE, "Debugging %s", _service_name);
+ ServiceMain(argc, argv);
+ }
+ else {
+ AddToMessageLog(TRUE, "Unknown service mode for %s", _service_name);
+ rv = ERR_RET_MODE;
+ }
+
+
+cleanup:
+ AddToMessageLog(FALSE, "SrvBatch finished");
+ ExitProcess(rv);
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/srvbatch.rc
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/srvbatch.rc 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/srvbatch.rc 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,58 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ #include <windows.h>
+
+ #define PRODUCT_VER_STRING "1.0.0.0\0"
+ #define PRODUCT_VER_NAME "ServBatch\0"
+
+ IDI_MAINICON ICON "../../resources/procrunw.ico"
+
+LANGUAGE 0x9,0x1
+1 11 MSG00001.bin
+
+ 1 VERSIONINFO
+ FILEVERSION 1,0,0,0
+ PRODUCTVERSION 1,0,0,0
+ FILEFLAGSMASK 0x3fL
+#if defined(_DEBUG)
+ FILEFLAGS 0x03L
+#else
+ FILEFLAGS 0x02L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "Comments", "\0"
+ VALUE "CompanyName", "Apache Software Foundation\0"
+ VALUE "FileDescription", "Application for running batch files as services\0"
+ VALUE "FileVersion", PRODUCT_VER_STRING
+ VALUE "InternalName", PRODUCT_VER_NAME
+ VALUE "LegalCopyright", "Copyright © 2000-2004 The Apache Software Foundation.\0"
+ VALUE "OriginalFilename", "srvbatch.exe\0"
+ VALUE "ProductVersion", PRODUCT_VER_STRING
+ VALUE "ProductName", PRODUCT_VER_NAME
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/srvbatch.sln
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/srvbatch.sln 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/srvbatch.sln 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,30 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "srvbatch", "srvbatch.vcproj", "{6AD26261-F2A9-4E6A-9CE6-92B4F2AA37AB}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example", "example\example.vcproj", "{1C38835C-714F-49F3-85FC-9E6372149DF3}"
+ ProjectSection(ProjectDependencies) = postProject
+ {6AD26261-F2A9-4E6A-9CE6-92B4F2AA37AB} = {6AD26261-F2A9-4E6A-9CE6-92B4F2AA37AB}
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {6AD26261-F2A9-4E6A-9CE6-92B4F2AA37AB}.Debug.ActiveCfg = Debug|Win32
+ {6AD26261-F2A9-4E6A-9CE6-92B4F2AA37AB}.Debug.Build.0 = Debug|Win32
+ {6AD26261-F2A9-4E6A-9CE6-92B4F2AA37AB}.Release.ActiveCfg = Release|Win32
+ {6AD26261-F2A9-4E6A-9CE6-92B4F2AA37AB}.Release.Build.0 = Release|Win32
+ {1C38835C-714F-49F3-85FC-9E6372149DF3}.Debug.ActiveCfg = Debug|Win32
+ {1C38835C-714F-49F3-85FC-9E6372149DF3}.Debug.Build.0 = Debug|Win32
+ {1C38835C-714F-49F3-85FC-9E6372149DF3}.Release.ActiveCfg = Release|Win32
+ {1C38835C-714F-49F3-85FC-9E6372149DF3}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/srvbatch.vcproj
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/srvbatch.vcproj 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/apps/srvbatch/srvbatch.vcproj 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="srvbatch"
+ ProjectGUID="{6AD26261-F2A9-4E6A-9CE6-92B4F2AA37AB}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/srvbatch.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/srvbatch.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/srvbatch.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath=".\srvbatch.c">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+ <File
+ RelativePath=".\srvbatch.rc">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/apxwin.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/apxwin.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/apxwin.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,207 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _APXWIN_H_INCLUDED_
+#define _APXWIN_H_INCLUDED_
+
+
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#ifndef WIN32_CE
+#define _WIN32_WINNT 0x0400
+#endif
+
+#include <windows.h>
+#include <windowsx.h>
+#include <commdlg.h>
+#include <commctrl.h>
+#include <objbase.h>
+#include <shlobj.h>
+#include <shlwapi.h>
+#include <shellapi.h>
+#include <zmouse.h>
+#include <richedit.h>
+
+#include <lm.h>
+
+#ifndef _INTPTR_T_DEFINED
+#ifdef _WIN64
+typedef __int64 intptr_t;
+#else
+typedef _W64 int intptr_t;
+#endif
+#define _INTPTR_T_DEFINED
+#endif
+
+#define APXMACRO_BEGIN do {
+#define APXMACRO_END } while(0)
+
+#ifdef __cplusplus
+#define __APXBEGIN_DECLS extern "C" {
+#define __APXEND_DECLS }
+#else
+#define __APXBEGIN_DECLS
+#define __APXEND_DECLS
+#endif
+
+#define SET_BIT_FLAG(x, b) ((x) |= (1 << b))
+#define CLR_BIT_FLAG(x, b) ((x) &= ~(1 << b))
+#define TST_BIT_FLAG(x, b) ((x) & (1 << b))
+
+#define IS_INVALID_HANDLE(h) (((h) == NULL || (h) == INVALID_HANDLE_VALUE))
+
+#define DYNOLAD_TYPE_DECLARE(fnName, callconv, retType) \
+ typedef retType (callconv *PFN_##fnName) \
+
+#define DYNLOAD_FPTR_DECLARE(fnName) \
+ PFN_##fnName FP_##fnName
+
+#define DYNLOAD_FPTR(fnName) FP_##fnName
+
+#define DYNLOAD_FPTR_ADDRESS(fnName, dllName) \
+ FP_##fnName = (PFN_##fnName)GetProcAddress( \
+ GetModuleHandle(TEXT(#dllName)), \
+ #fnName)
+
+#define DYNLOAD_FPTR_LOAD(fnName, dllHandle) \
+ FP_##fnName = (PFN_##fnName)GetProcAddress( \
+ dllHandle, \
+ #fnName)
+
+#define DYNLOAD_CALL(fnName) (*FP_##fnName)
+
+#ifndef ABS
+#define ABS(x) (((x) > 0) ? (x) : (x) * (-1))
+#endif
+
+#define SIZ_RESLEN 256
+#define SIZ_RESMAX (SIZ_RESLEN -1)
+#define SIZ_BUFLEN 512
+#define SIZ_BUFMAX (SIZ_BUFLEN -1)
+#define SIZ_DESLEN 1024
+#define SIZ_DESMAX (SIZ_DESLEN -1)
+#define SIZ_HUGLEN 8192
+#define SIZ_HUGMAX (SIZ_HUGLEN -1)
+
+#include "handles.h"
+#include "log.h"
+#include "cmdline.h"
+#include "console.h"
+#include "rprocess.h"
+#include "registry.h"
+#include "service.h"
+#include "javajni.h"
+#include "gui.h"
+
+__APXBEGIN_DECLS
+
+typedef enum {
+ APX_WINVER_UNK = 0,
+ APX_WINVER_UNSUP = 1,
+ APX_WINVER_95 = 10,
+ APX_WINVER_95_B = 11,
+ APX_WINVER_95_OSR2 = 12,
+ APX_WINVER_98 = 14,
+ APX_WINVER_98_SE = 16,
+ APX_WINVER_ME = 18,
+
+ APX_WINVER_UNICODE = 20, /* Prior versions support only narrow chars */
+
+ APX_WINVER_CE_3 = 23, /* CE is an odd beast, not supporting */
+ /* some pre-NT features, such as the */
+ APX_WINVER_NT = 30, /* narrow charset APIs (fooA fns), while */
+ APX_WINVER_NT_3_5 = 35, /* not supporting some NT-family features. */
+ APX_WINVER_NT_3_51 = 36,
+
+ APX_WINVER_NT_4 = 40,
+ APX_WINVER_NT_4_SP2 = 42,
+ APX_WINVER_NT_4_SP3 = 43,
+ APX_WINVER_NT_4_SP4 = 44,
+ APX_WINVER_NT_4_SP5 = 45,
+ APX_WINVER_NT_4_SP6 = 46,
+
+ APX_WINVER_2000 = 50,
+ APX_WINVER_2000_SP1 = 51,
+ APX_WINVER_2000_SP2 = 52,
+ APX_WINVER_XP = 60
+} APX_OSLEVEL;
+
+APX_OSLEVEL apxGetOsLevel();
+LPWSTR AsciiToWide(LPCSTR s, LPWSTR ws);
+LPSTR WideToAscii(LPCWSTR ws, LPSTR s);
+LPSTR MzWideToAscii(LPCWSTR ws, LPSTR s);
+
+typedef struct APXMULTISZ APXMULTISZ;
+typedef APXMULTISZ* LPAPXMULTISZ;
+
+DWORD apxMultiSzToArrayA(APXHANDLE hPool, LPCSTR lpString, LPSTR **lppArray);
+DWORD apxMultiSzToArrayW(APXHANDLE hPool, LPCWSTR lpString, LPWSTR **lppArray);
+LPWSTR apxMultiSzCombine(APXHANDLE hPool, LPCWSTR lpStrA, LPCWSTR lpStrB,
+ LPDWORD lpdwLength);
+
+LPAPXMULTISZ apxMultiSzStrdup(LPCTSTR szSrc);
+LPTSTR apxMultiSzStrcat(LPAPXMULTISZ lpmSz, LPCTSTR szSrc);
+LPCTSTR apxMultiSzGet(LPAPXMULTISZ lpmSz);
+/** Remove the specified character from the string
+ * Replacement is done in-place.
+ */
+LPTSTR apxStrCharRemove(LPTSTR szString, TCHAR chSkip);
+DWORD apxStrUnQuoteInplaceA(LPSTR szString);
+DWORD apxStrUnQuoteInplaceW(LPWSTR szString);
+
+BOOL apxUltohex(ULONG n, LPTSTR lpBuff, DWORD dwBuffLength);
+BOOL apxUptohex(ULONG_PTR n, LPTSTR lpBuff, DWORD dwBuffLength);
+ULONG apxStrToul(LPCTSTR szNum);
+ULONG apxStrToulW(LPCWSTR szNum);
+ULONG apxAtoulW(LPCWSTR szNum);
+
+BOOL apxMakeResourceName(LPCTSTR szPrefix, LPTSTR lpBuff,
+ DWORD dwBuffLength);
+
+INT apxStrMatchA(LPCSTR szString, LPCSTR szPattern, BOOL bIgnoreCase);
+INT apxStrMatchW(LPCWSTR szString, LPCWSTR szPattern, BOOL bIgnoreCase);
+INT apxMultiStrMatchW(LPCWSTR szString, LPCWSTR szPattern,
+ WCHAR chSeparator, BOOL bIgnoreCase);
+LPSTR apxArrayToMultiSzA(APXHANDLE hPool, DWORD nArgs, LPCSTR *lpArgs);
+void apxStrQuoteInplaceW(LPWSTR szString);
+LPWSTR apxMszToCRLFW(APXHANDLE hPool, LPCWSTR szStr);
+LPWSTR apxCRLFToMszW(APXHANDLE hPool, LPCWSTR szStr, LPDWORD lpdwBytes);
+LPSTR apxExpandStrA(APXHANDLE hPool, LPCSTR szString);
+LPWSTR apxExpandStrW(APXHANDLE hPool, LPCWSTR szString);
+void apxStrCharReplaceA(LPSTR szString, CHAR chReplace, CHAR chReplaceWith);
+void apxStrCharReplaceW(LPWSTR szString, WCHAR chReplace, WCHAR chReplaceWith);
+
+
+LPVOID AplFillMemory(PVOID Destination, SIZE_T Length, BYTE Fill);
+void AplZeroMemory(PVOID Destination, SIZE_T Length);
+LPVOID AplCopyMemory(PVOID Destination, const VOID* Source, SIZE_T Length);
+/*
+ * Find the first occurrence of lpFind in lpMem.
+ * dwLen: The length of lpFind
+ * dwSize: The length of lpMem
+ */
+LPBYTE ApcMemSearch(LPCVOID lpMem, LPCVOID lpFind, SIZE_T dwLen, SIZE_T dwSize);
+LPSTR AplRindexA(LPCSTR lpStr, int ch);
+
+#define AplMoveMemory AplCopyMemory
+
+PSECURITY_ATTRIBUTES GetNullACL();
+void CleanNullACL(void *sa);
+
+__APXEND_DECLS
+
+#endif /* _APXWIN_H_INCLUDED_ */
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/cmdline.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/cmdline.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/cmdline.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,76 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _CMDLINE_H_INCLUDED_
+#define _CMDLINE_H_INCLUDED_
+
+__APXBEGIN_DECLS
+
+#define APXCMDOPT_NIL 0x00000000 /* Argopt value not needed */
+#define APXCMDOPT_INT 0x00000001 /* Argopt value is unsigned integer */
+#define APXCMDOPT_STR 0x00000002 /* Argopt value is string */
+#define APXCMDOPT_STE 0x00000006 /* Argopt value is expandable string */
+#define APXCMDOPT_MSZ 0x00000010 /* Multiline string '#' separated */
+#define APXCMDOPT_BIN 0x00000020 /* Encrypted binary */
+
+#define APXCMDOPT_REG 0x00000100 /* Save to registry */
+#define APXCMDOPT_SRV 0x00000200 /* Save to service registry */
+#define APXCMDOPT_USR 0x00000400 /* Save to user registry */
+
+#define APXCMDOPT_FOUND 0x00001000 /* The option is present in cmdline */
+#define APXCMDOPT_ADD 0x00002000 /* The option is present in cmdline as ++*/
+
+
+typedef struct APXCMDLINEOPT APXCMDLINEOPT;
+
+struct APXCMDLINEOPT {
+ LPWSTR szName; /* Long Argument Name */
+ LPWSTR szRegistry; /* Registry Association */
+ LPWSTR szSubkey; /* Registry Association */
+ DWORD dwType; /* Argument type (string, number, multistring */
+ LPWSTR szValue; /* Return string value */
+ DWORD dwValue; /* Return numeric value or present if NIL */
+};
+
+typedef struct APXCMDLINE {
+ APXCMDLINEOPT *lpOptions;
+ LPWSTR szExecutable; /* Parsed argv0 */
+ LPWSTR szExePath; /* Parsed argv0 */
+ LPWSTR szApplication; /* Fist string after //CMD// */
+ DWORD dwCmdIndex; /* Command index */
+ LPWSTR *lpArgvw;
+ DWORD dwArgc;
+ APXHANDLE hPool;
+
+} APXCMDLINE, *LPAPXCMDLINE;
+
+LPAPXCMDLINE apxCmdlineParse(
+ APXHANDLE hPool,
+ APXCMDLINEOPT *lpOptions,
+ LPCWSTR *lpszCommands
+);
+
+void apxCmdlineLoadEnvVars(
+ LPAPXCMDLINE lpCmdline
+);
+
+void apxCmdlineFree(
+ LPAPXCMDLINE lpCmdline
+);
+
+
+__APXEND_DECLS
+
+#endif /* _CMDLINE_H_INCLUDED_ */
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/console.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/console.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/console.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,25 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _CONSOLE_H_INCLUDED_
+#define _CONSOLE_H_INCLUDED_
+
+__APXBEGIN_DECLS
+
+
+
+__APXEND_DECLS
+
+#endif /* _CONSOLE_H_INCLUDED_ */
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/gui.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/gui.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/gui.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,185 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _GUI_H_INCLUDED_
+#define _GUI_H_INCLUDED_
+
+__APXBEGIN_DECLS
+
+
+#define IDC_STATIC -1
+#define IDC_APPLICATION 100
+#define IDI_MAINICON 101
+#define IDC_STATBAR 102
+#define IDB_SUSERS 103
+
+#define IDS_APPLICATION 150
+#define IDS_APPDESCRIPTION 151
+#define IDS_APPVERSION 152
+#define IDS_APPCOPYRIGHT 153
+#define IDS_APPFULLNAME 154
+
+#define IDD_ABOUTBOX 250
+#define IDC_LICENSE 251
+#define IDR_LICENSE 252
+#define IAB_SYSINF 253
+#define IDC_ABOUTAPP 254
+
+#define IDD_PROGRESS 260
+#define IDDP_HEAD 261
+#define IDDP_TEXT 262
+#define IDDP_PROGRESS 263
+
+#define IDD_SELUSER 270
+#define IDSU_SELNAME 271
+#define IDSU_SELECTED 272
+#define IDSU_LIST 273
+#define IDSU_COMBO 274
+
+
+#define WM_TRAYMESSAGE (WM_APP+1)
+
+#define SNDMSGW SendMessageW
+#define SNDMSGA SendMessageA
+#define ComboBox_AddStringW(hwndCtl, lpsz) ((int)(DWORD)SNDMSGW((hwndCtl), CB_ADDSTRING, 0L, (LPARAM)(LPCWSTR)(lpsz)))
+
+#define ListView_SetItemTextW(hwndLV, i, iSubItem_, pszText_) \
+{ LV_ITEMW _ms_lvi;\
+ _ms_lvi.iSubItem = iSubItem_;\
+ _ms_lvi.pszText = pszText_;\
+ SNDMSG((hwndLV), LVM_SETITEMTEXTW, (WPARAM)(i), (LPARAM)(LV_ITEMW *)&_ms_lvi);\
+} ((void)0)
+
+#define ListView_GetItemTextA(hwndLV, i, iSubItem_, pszText_, cchTextMax_) \
+{ LV_ITEMA _ms_lvi;\
+ _ms_lvi.iSubItem = iSubItem_;\
+ _ms_lvi.cchTextMax = cchTextMax_;\
+ _ms_lvi.pszText = pszText_;\
+ SNDMSGA((hwndLV), LVM_GETITEMTEXTA, (WPARAM)(i), (LPARAM)(LV_ITEMA *)&_ms_lvi);\
+} ((void)0)
+
+#define ListView_GetItemTextW(hwndLV, i, iSubItem_, pszText_, cchTextMax_) \
+{ LV_ITEMW _ms_lvi;\
+ _ms_lvi.iSubItem = iSubItem_;\
+ _ms_lvi.cchTextMax = cchTextMax_;\
+ _ms_lvi.pszText = pszText_;\
+ SNDMSG((hwndLV), LVM_GETITEMTEXTW, (WPARAM)(i), (LPARAM)(LV_ITEMW *)&_ms_lvi);\
+} ((void)0)
+
+#define ListView_InsertItemW(hwnd, pitem) \
+ (int)SNDMSGW((hwnd), LVM_INSERTITEMW, 0, (LPARAM)(const LV_ITEMW *)(pitem))
+
+typedef struct APXLVITEM {
+ INT iPosition;
+ BOOL bSortable;
+ INT iWidth;
+ INT iDefault;
+ INT iFmt;
+ LPTSTR szLabel;
+} APXLVITEM, *LPAPXLVITEM;
+
+typedef struct APXGUISTATE {
+ DWORD dwShow;
+ RECT rcPosition;
+ COLORREF bgColor;
+ COLORREF fgColor;
+ COLORREF txColor;
+ INT nColumnWidth[32];
+ INT nUser[8];
+} APXGUISTATE, *LPAPXGUISTATE;
+
+typedef struct APXGUISTORE {
+ HANDLE hInstance;
+ HICON hIcon;
+ HICON hIconSm;
+ HICON hIconHg;
+ HWND hMainWnd;
+ HACCEL hAccel;
+ TCHAR szWndClass[256];
+ TCHAR szWndMutex[256];
+ APXGUISTATE stState;
+ STARTUPINFO stStartupInfo;
+ UINT nWhellScroll;
+
+} APXGUISTORE, *LPAPXGUISTORE;
+
+LPAPXGUISTORE apxGuiInitialize(WNDPROC lpfnWndProc, LPCTSTR szAppName);
+
+BOOL apxCenterWindow(HWND hwndChild, HWND hwndParent);
+
+LPSTR apxLoadResourceA(UINT wID, UINT nBuf);
+LPWSTR apxLoadResourceW(UINT wID, UINT nBuf);
+
+
+void apxAppendMenuItem(HMENU hMenu, UINT idMenu, LPCTSTR szName,
+ BOOL bDefault, BOOL bEnabled);
+void apxAppendMenuItemBmp(HMENU hMenu, UINT idMenu, LPCTSTR szName);
+
+void apxManageTryIconA(HWND hWnd, DWORD dwMessage, LPCSTR szInfoTitle,
+ LPCSTR szInfo, HICON hIcon);
+void apxManageTryIconW(HWND hWnd, DWORD dwMessage, LPCWSTR szInfoTitle,
+ LPCWSTR szInfo, HICON hIcon);
+#ifdef _UNICODE
+#define apxLoadResource apxLoadResourceW
+#else
+#define apxLoadResource apxLoadResourceA
+#endif
+
+void apxAboutBox(HWND hWnd);
+int apxProgressBox(HWND hWnd, LPCTSTR szHeader,
+ LPCWSTR szText,
+ LPAPXFNCALLBACK fnProgressCallback,
+ LPVOID cbData);
+BOOL apxYesNoMessage(LPCTSTR szTitle, LPCTSTR szMessage, BOOL bStop);
+
+BOOL apxCalcStringEllipsis(HDC hDC, LPTSTR szString,
+ int cchMax, UINT uColWidth);
+LPWSTR apxGetDlgTextW(APXHANDLE hPool, HWND hDlg, int nIDDlgItem);
+LPSTR apxGetDlgTextA(APXHANDLE hPool, HWND hDlg, int nIDDlgItem);
+
+#ifdef _UNICODE
+#define apxGetDlgText apxGetDlgTextW
+#else
+#define apxGetDlgText apxGetDlgTextA
+#endif
+
+LPSTR apxBrowseForFolderA(HWND hWnd, LPCSTR szTitle, LPCSTR szName);
+LPWSTR apxBrowseForFolderW(HWND hWnd, LPCWSTR szTitle, LPCWSTR szName);
+
+#ifdef _UNICODE
+#define apxBrowseForFolder apxBrowseForFolderW
+#else
+#define apxBrowseForFolder apxBrowseForFolderA
+#endif
+
+LPSTR apxGetFileNameA(HWND hWnd, LPCSTR szTitle, LPCSTR szFilter,
+ LPCSTR szDefExt, LPCSTR szDefPath, BOOL bOpenOrSave,
+ LPDWORD lpdwFindex);
+
+LPWSTR apxGetFileNameW(HWND hWnd, LPCWSTR szTitle, LPCWSTR szFilter,
+ LPCWSTR szDefExt, LPCWSTR szDefPath, BOOL bOpenOrSave,
+ LPDWORD lpdwFindex);
+
+#ifdef _UNICODE
+#define apxGetFileName apxGetFileNameW
+#else
+#define apxGetFileName apxGetFileNameA
+#endif
+
+LPCWSTR apxDlgSelectUser(HWND hWnd, LPWSTR szUser);
+
+__APXEND_DECLS
+
+#endif /* _GUI_H_INCLUDED_ */
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/handles.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/handles.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/handles.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,191 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _HANDLES_H_INCLUDED_
+#define _HANDLES_H_INCLUDED_
+
+__APXBEGIN_DECLS
+
+#define SAFE_CLOSE_HANDLE(h) \
+ if ((h) != NULL && (h) != INVALID_HANDLE_VALUE) { \
+ CloseHandle((h)); \
+ (h) = NULL; \
+ }
+
+typedef struct stAPXHANDLE stAPXHANDLE;
+typedef stAPXHANDLE* APXHANDLE;
+
+/**
+ * Alignment macros
+ */
+
+/* APR_ALIGN() is only to be used to align on a power of 2 boundary */
+#define APX_ALIGN(size, boundary) \
+ (((size) + ((boundary) - 1)) & ~((boundary) - 1))
+
+/** Default alignment */
+#define APX_ALIGN_DEFAULT(size) APX_ALIGN(size, 16)
+
+
+/** Handle callback function prototype */
+typedef BOOL (*LPAPXFNCALLBACK)(APXHANDLE hObject, UINT uMsg,
+ WPARAM wParam, LPARAM lParam);
+
+#if _MSC_VER >= 1300
+#define APXHANDLE_INVALID ((void *)0xdeadbeefLL)
+#else
+#define APXHANDLE_INVALID ((void *)0xdeadbeefL)
+#endif
+
+#define APXHANDLE_HOOK_FIRST 0
+#define APXHANDLE_HOOK_LAST 1
+
+/** Flags */
+/** handle has its own heap */
+#define APXHANDLE_HAS_HEAP 0x00000001
+/** handle has CriticalSection */
+#define APXHANDLE_HAS_LOCK 0x00000002
+/** handle owns the CriticalSection */
+#define APXHANDLE_OWNS_LOCK 0x00000006
+/** handle has EventThread */
+#define APXHANDLE_HAS_EVENT 0x00000010
+/** handle has UserData */
+#define APXHANDLE_HAS_USERDATA 0x00000020
+
+/** Types */
+#define APXHANDLE_TYPE_INVALID 0xdeadbeef
+#define APXHANDLE_TYPE_POOL 0x01000000
+#define APXHANDLE_TYPE_WINHANDLE 0x02000000
+#define APXHANDLE_TYPE_SERVICE 0x03000000
+#define APXHANDLE_TYPE_LPTR 0x04000000
+#define APXHANDLE_TYPE_CONSOLE 0x05000000
+#define APXHANDLE_TYPE_PROCESS 0x06000000
+#define APXHANDLE_TYPE_JVM 0x07000000
+#define APXHANDLE_TYPE_REGISTRY 0x08000000
+
+/** Initialize the Handle manager
+ * reference counted
+ */
+BOOL apxHandleManagerInitialize();
+/** Destroys the Handle manager
+ * reference counted
+ */
+BOOL apxHandleManagerDestroy();
+/** Create the memory pool
+ * param: hParent parent pool or NULL to use the system pool
+ * dwOptions OR'd flags: APXHANDLE_HAS_HEAP,
+ * APXHANDLE_HAS_LOCK
+ * APXHANDLE_OWNS_LOCK
+ */
+APXHANDLE apxPoolCreate(APXHANDLE hParent, DWORD dwOptions);
+/** Create the memory pool
+ * param: hPpool pool to allocate from or NULL for system pool
+ * dwOptions OR'd flags: see APXHANDLE_TYPE_ and APXHANDLE_HAS_
+ * values
+ * lpData user supplied Data
+ * dwDataSize extra pool user data size, combined with options
+ * the lpData is copied to the internal storage;
+ * fnCallback Optional handle callback function
+ */
+APXHANDLE apxHandleCreate(APXHANDLE hPool, DWORD dwOptions,
+ LPVOID lpData, DWORD dwDataSize,
+ LPAPXFNCALLBACK fnCallback);
+/** Close the handle
+ * Calls the callback function and frees the memory
+ */
+BOOL apxCloseHandle(APXHANDLE hObject);
+/** Get The internal user data
+ */
+LPVOID apxHandleGetUserData(APXHANDLE hObject);
+/** Set The internal user data
+ * params:
+ * lpData user supplied Data
+ * dwDataSize user data size, combined with create options
+ * the lpData is either copied to the internal storage
+ * or assigned.
+ */
+LPVOID apxHandleSetUserData(APXHANDLE hObject, LPVOID lpData,
+ DWORD dwDataSize);
+/** Send the message to the handle
+ * Callback function is executed with WM_COMMAND uMsg
+ */
+BOOL apxHandleSendMessage(APXHANDLE hObject, UINT uMsg,
+ WPARAM wParam, LPARAM lParam);
+
+/** Post the message to the handle
+ * function returns imediately.
+ */
+BOOL apxHandlePostMessage(APXHANDLE hObject, UINT uMsg,
+ WPARAM wParam, LPARAM lParam);
+/** Lock or unlock the handle
+ * If bLock is true lock the handle, otherwise unlock.
+ */
+BOOL apxHandleLock(APXHANDLE hObject, BOOL bLock);
+
+/** Add the callback to the handles hook chain
+ *
+ */
+BOOL apxHandleAddHook(APXHANDLE hObject, DWORD dwWhere,
+ LPAPXFNCALLBACK fnCallback);
+
+DWORD apxHandleWait(APXHANDLE hHandle, DWORD dwMilliseconds,
+ BOOL bKill);
+
+/** General pool memory allocation functions
+ */
+LPVOID apxPoolAlloc(APXHANDLE hPool, DWORD dwSize);
+LPVOID apxPoolCalloc(APXHANDLE hPool, DWORD dwSize);
+LPVOID apxPoolRealloc(APXHANDLE hPool, LPVOID lpMem, DWORD dwNewSize);
+LPTSTR apxPoolStrdup(APXHANDLE hPool, LPCTSTR szSource);
+
+/** General system pool memory allocation functions
+ */
+
+LPVOID apxAlloc(DWORD dwSize);
+LPVOID apxCalloc(DWORD dwSize);
+LPVOID apxRealloc(LPVOID lpMem, DWORD dwNewSize);
+
+LPSTR apxStrdupA(LPCSTR szSource);
+LPWSTR apxStrdupW(LPCWSTR szSource);
+LPSTR apxPoolStrdupA(APXHANDLE hPool, LPCSTR szSource);
+LPWSTR apxPoolStrdupW(APXHANDLE hPool, LPCWSTR szSource);
+
+LPWSTR apxPoolWStrdupA(APXHANDLE hPool, LPCSTR szSource);
+
+#define apxPoolWStrdupW apxPoolStrdupW
+
+#ifdef _UNICODE
+#define apxStrdup apxStrdupW
+#define apxPoolStrdup apxPoolStrdupW
+#else
+#define apxStrdup apxStrdupA
+#define apxPoolStrdup apxPoolStrdupW
+#endif
+
+#ifndef _UNICODE
+#define apxPoolWStrdup apxPoolWStrdupA
+#define apxWStrdup apxWStrdupA
+#else
+#define apxPoolWStrdup apxPoolStrdupW
+#define apxWStrdup apxStrdupW
+#endif
+/** Free the allocated memory
+ * It will call te correct pool if the address is valid
+ */
+VOID apxFree(LPVOID lpMem);
+
+__APXEND_DECLS
+
+#endif /* _HANDLES_H_INCLUDED_ */
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/javajni.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/javajni.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/javajni.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,41 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _JAVAJNI_H_INCLUDED_
+#define _JAVAJNI_H_INCLUDED_
+
+__APXBEGIN_DECLS
+
+APXHANDLE apxCreateJava(APXHANDLE hPool, LPCWSTR szJvmDllPath);
+
+BOOL apxJavaInitialize(APXHANDLE hJava, LPCSTR szClassPath,
+ LPCVOID lpOptions, DWORD dwMs, DWORD dwMx,
+ DWORD dwSs);
+
+BOOL apxJavaLoadMainClass(APXHANDLE hJava, LPCSTR szClassName,
+ LPCSTR szMethodName,
+ LPCVOID lpArguments);
+
+BOOL apxJavaStart(APXHANDLE hJava);
+
+DWORD apxJavaWait(APXHANDLE hJava, DWORD dwMilliseconds, BOOL bKill);
+
+BOOL apxJavaSetOut(APXHANDLE hJava, BOOL setErrorOrOut,
+ LPCWSTR szFilename);
+
+
+__APXEND_DECLS
+
+#endif /* _JAVAJNI_H_INCLUDED_ */
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/log.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/log.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/log.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,101 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* Logfile handling
+ * Use Systemdir/Logfiles/Apache as a default path
+ */
+
+#ifndef _LOG_H_INCLUDED_
+#define _LOG_H_INCLUDED_
+
+__APXBEGIN_DECLS
+
+#define APX_LOGLOCK(file) \
+ APXMACRO_BEGIN \
+ DWORD _lmax = 0; \
+ while(!LockFile(file, 0, 0, 512, 0)) { \
+ Sleep(10); \
+ if (_lmax++ > 1000) break; \
+ } \
+ SetFilePointer(file, 0, NULL, FILE_END); \
+ APXMACRO_END
+
+#define APX_LOGUNLOCK(file) \
+ APXMACRO_BEGIN \
+ UnlockFile(file, 0, 0, 512, 0); \
+ APXMACRO_END
+
+#define APXLOG_LEVEL_DEBUG 0
+#define APXLOG_LEVEL_INFO 1
+#define APXLOG_LEVEL_WARN 2
+#define APXLOG_LEVEL_ERROR 3
+
+#define APXLOG_MARK_INFO NULL, APXLOG_LEVEL_INFO, TRUE, NULL, 0, ""
+#define APXLOG_MARK_WARN NULL, APXLOG_LEVEL_WARN, TRUE, NULL, 0, ""
+#define APXLOG_MARK_ERROR NULL, APXLOG_LEVEL_ERROR, TRUE, __FILE__, __LINE__, ""
+#define APXLOG_MARK_DEBUG NULL, APXLOG_LEVEL_DEBUG, TRUE, __FILE__, __LINE__, ""
+#define APXLOG_MARK_RAW NULL, APXLOG_LEVEL_INFO, FALSE, NULL, 0,
+#define APXLOG_MARK_SYSERR NULL, APXLOG_LEVEL_ERROR, TRUE, __FILE__, __LINE__, NULL
+
+LPWSTR apxLogFile(
+ APXHANDLE hPool,
+ LPCWSTR szPath,
+ LPCWSTR szPrefix,
+ LPCWSTR szName
+);
+
+HANDLE apxLogOpen(
+ APXHANDLE hPool,
+ LPCWSTR szPath,
+ LPCWSTR szPrefix
+);
+
+void apxLogClose(
+ HANDLE hFile
+);
+
+void apxLogLevelSet(
+ HANDLE hFile,
+ DWORD dwLevel
+);
+
+void apxLogLevelSetW(
+ HANDLE hFile,
+ LPCWSTR szLevel
+);
+
+int
+apxLogWrite(
+ HANDLE hFile,
+ DWORD dwLevel,
+ BOOL bTimeStamp,
+ LPCSTR szFile,
+ DWORD dwLine,
+ LPCSTR szFormat,
+ ...
+);
+
+int
+apxDisplayError(
+ BOOL bDisplay,
+ LPCSTR szFile,
+ DWORD dwLine,
+ LPCSTR szFormat,
+ ...
+);
+
+__APXEND_DECLS
+
+#endif /* _LOG_H_INCLUDED_ */
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/registry.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/registry.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/registry.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,145 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _REGISTRY_H_INCLUDED_
+#define _REGISTRY_H_INCLUDED_
+
+__APXBEGIN_DECLS
+
+#define APXREG_SOFTWARE 0x0001
+#define APXREG_SERVICE 0x0002
+#define APXREG_USER 0x0004
+
+#define APXREG_PARAMSOFTWARE 0x0010
+#define APXREG_PARAMSERVICE 0x0020
+#define APXREG_PARAMUSER 0x0040
+
+/** Create or open the process registry keys
+ */
+APXHANDLE apxCreateRegistryA(APXHANDLE hPool, REGSAM samDesired,
+ LPCSTR szRoot, LPCSTR szKeyName,
+ DWORD dwOptions);
+APXHANDLE apxCreateRegistryW(APXHANDLE hPool, REGSAM samDesired,
+ LPCWSTR szRoot, LPCWSTR szKeyName,
+ DWORD dwOptions);
+
+#ifdef _UNICODE
+#define apxCreateRegistry apxCreateRegistryW
+#else
+#define apxCreateRegistry apxCreateRegistryA
+#endif
+
+/** Delete the process registry keys
+ */
+BOOL apxDeleteRegistryA(LPCSTR szRoot, LPCSTR szKeyName,
+ BOOL bDeleteEmpty);
+
+BOOL apxDeleteRegistryW(LPCWSTR szRoot, LPCWSTR szKeyName,
+ BOOL bDeleteEmpty);
+
+#ifdef _UNICODE
+#define apxDeleteRegistry apxDeleteRegistryW
+#else
+#define apxDeleteRegistry apxDeleteRegistryA
+#endif
+
+/** Get the JavaHome path from registry
+ * and set the JAVA_HOME environment variable if not found
+ * If bPreferJre is set use the JRE's path as JAVA_HOME
+ */
+LPWSTR apxGetJavaSoftHome(APXHANDLE hPool, BOOL bPreferJre);
+
+/** Get the Java RuntimeLib from registry (jvm.dll)
+ */
+LPWSTR apxGetJavaSoftRuntimeLib(APXHANDLE hPool);
+
+LPSTR apxRegistryGetStringA(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCSTR szSubkey, LPCSTR szValueName);
+
+LPWSTR apxRegistryGetStringW(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCWSTR szSubkey, LPCWSTR szValueName);
+
+#ifdef _UNICODE
+#define apxRegistryGetString apxRegistryGetStringW
+#else
+#define apxRegistryGetString apxRegistryGetStringA
+#endif
+
+LPBYTE apxRegistryGetBinaryA(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCSTR szSubkey, LPCSTR szValueName,
+ LPBYTE lpData, LPDWORD lpdwLength);
+
+LPBYTE apxRegistryGetBinaryW(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCWSTR szSubkey, LPCWSTR szValueName,
+ LPBYTE lpData, LPDWORD lpdwLength);
+
+#ifdef _UNICODE
+#define apxRegistryGetBinary apxRegistryGetBinaryW
+#else
+#define apxRegistryGetBinary apxRegistryGetBinaryA
+#endif
+
+BOOL apxRegistrySetBinaryA(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCSTR szSubkey, LPCSTR szValueName,
+ const LPBYTE lpData, DWORD dwLength);
+
+BOOL apxRegistrySetBinaryW(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCWSTR szSubkey, LPCWSTR szValueName,
+ const LPBYTE lpData, DWORD dwLength);
+
+LPWSTR apxRegistryGetMzStrW(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCWSTR szSubkey, LPCWSTR szValueName,
+ LPWSTR lpData, LPDWORD lpdwLength);
+
+BOOL apxRegistrySetMzStrW(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCWSTR szSubkey, LPCWSTR szValueName,
+ LPCWSTR lpData, DWORD dwLength);
+
+BOOL apxRegistrySetStrA(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCSTR szSubkey, LPCSTR szValueName,
+ LPCSTR szValue);
+
+BOOL apxRegistrySetStrW(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCWSTR szSubkey, LPCWSTR szValueName,
+ LPCWSTR szValue);
+
+
+#ifdef _UNICODE
+#define apxRegistrySetStr apxRegistrySetStrW
+#else
+#define apxRegistrySetStr apxRegistrySetStrA
+#endif
+
+BOOL apxRegistrySetNumW(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCWSTR szSubkey, LPCWSTR szValueName,
+ DWORD dwValue);
+
+DWORD apxRegistryGetNumberW(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCWSTR szSubkey, LPCWSTR szValueName);
+
+
+BOOL apxRegistryDeleteW(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCWSTR szSubkey, LPCWSTR szValueName);
+
+
+#ifdef _UNICODE
+#define apxRegistryDelete apxRegistryDeleteW
+#else
+#define apxRegistryDelete apxRegistryDeleteA
+#endif
+
+__APXEND_DECLS
+
+#endif /* _REGISTRY_H_INCLUDED_ */
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/rprocess.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/rprocess.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/rprocess.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,75 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _RPROCESS_H_INCLUDED_
+#define _RPROCESS_H_INCLUDED_
+
+__APXBEGIN_DECLS
+
+BOOL apxProcessExecute(APXHANDLE hProcess);
+
+APXHANDLE apxCreateProcessA(APXHANDLE hPool, DWORD dwOptions,
+ LPAPXFNCALLBACK fnCallback,
+ LPCSTR szUsername, LPCSTR szPassword,
+ BOOL bLogonAsService);
+APXHANDLE apxCreateProcessW(APXHANDLE hPool, DWORD dwOptions,
+ LPAPXFNCALLBACK fnCallback,
+ LPCWSTR szUsername, LPCWSTR szPassword,
+ BOOL bLogonAsService);
+
+#ifdef _UNICODE
+#define apxCreateProcess apxCreateProcessW
+#else
+#define apxCreateProcess apxCreateProcessA
+#endif
+
+BOOL apxProcessSetExecutableA(APXHANDLE hProcess, LPCSTR szName);
+BOOL apxProcessSetExecutableW(APXHANDLE hProcess, LPCWSTR szName);
+
+BOOL apxProcessSetCommandLineA(APXHANDLE hProcess, LPCSTR szCmdline);
+BOOL apxProcessSetCommandLineW(APXHANDLE hProcess, LPCWSTR szCmdline);
+BOOL apxProcessSetCommandArgsW(APXHANDLE hProcess, LPCWSTR szTitle,
+ DWORD dwArgc, LPCWSTR *lpArgs);
+
+BOOL apxProcessSetWorkingPathA(APXHANDLE hProcess, LPCSTR szPath);
+BOOL apxProcessSetWorkingPathW(APXHANDLE hProcess, LPCWSTR szPath);
+
+DWORD apxProcessPutcA(APXHANDLE hProcess, INT ch);
+DWORD apxProcessPutcW(APXHANDLE hProcess, INT ch);
+DWORD apxProcessPutsA(APXHANDLE hProcess, LPCSTR szString);
+DWORD apxProcessPutsW(APXHANDLE hProcess, LPCWSTR szString);
+
+#ifndef _UNICODE
+#define apxProcessPutc apxProcessPutcA
+#define apxProcessPuts apxProcessPutsA
+#else
+#define apxProcessPutc apxProcessPutcW
+#define apxProcessPuts apxProcessPutsW
+#endif
+
+DWORD apxProcessWrite(APXHANDLE hProcess, LPCVOID lpData, DWORD dwLen);
+
+VOID apxProcessCloseInputStream(APXHANDLE hProcess);
+BOOL apxProcessFlushStdin(APXHANDLE hProcess);
+
+DWORD apxProcessWait(APXHANDLE hProcess, DWORD dwMilliseconds,
+ BOOL bKill);
+
+BOOL apxProcessRunning(APXHANDLE hProcess);
+
+
+__APXEND_DECLS
+
+#endif /* _RPROCESS_H_INCLUDED_ */
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/service.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/service.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/include/service.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,72 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _SERVICE_H_INCLUDED_
+#define _SERVICE_H_INCLUDED_
+
+__APXBEGIN_DECLS
+
+typedef struct APXSERVENTRY {
+ WCHAR szServiceName[SIZ_RESLEN];
+ WCHAR szObjectName[SIZ_RESLEN];
+ WCHAR szServiceDescription[SIZ_DESLEN];
+ DWORD dwStart;
+ LPQUERY_SERVICE_CONFIGW lpConfig;
+ SERVICE_STATUS stServiceStatus;
+ SERVICE_STATUS_PROCESS stStatusProcess;
+
+} APXSERVENTRY, *LPAPXSERVENTRY;
+
+
+APXHANDLE apxCreateService(APXHANDLE hPool, DWORD dwOptions,
+ BOOL bManagerMode);
+
+BOOL apxServiceOpen(APXHANDLE hService, LPCWSTR szServiceName, DWORD dwOptions);
+
+
+BOOL apxServiceSetNames(APXHANDLE hService, LPCWSTR szImagePath,
+ LPCWSTR szDisplayName, LPCWSTR szDescription,
+ LPCWSTR szUsername, LPCWSTR szPassword);
+
+BOOL apxServiceSetOptions(APXHANDLE hService, DWORD dwServiceType,
+ DWORD dwStartType, DWORD dwErrorControl);
+
+BOOL apxServiceControl(APXHANDLE hService, DWORD dwControl, UINT uMsg,
+ LPAPXFNCALLBACK fnControlCallback,
+ LPVOID lpCbData);
+BOOL apxServiceInstall(APXHANDLE hService, LPCWSTR szServiceName,
+ LPCWSTR szDisplayName, LPCWSTR szImagePath,
+ LPCWSTR lpDependencies, DWORD dwServiceType,
+ DWORD dwStartType);
+
+LPAPXSERVENTRY apxServiceEntry(APXHANDLE hService, BOOL bRequeryStatus);
+
+/** Delete te service
+ * Stops the service if running
+ */
+BOOL apxServiceDelete(APXHANDLE hService);
+
+DWORD apxServiceBrowse(APXHANDLE hService,
+ LPCWSTR szIncludeNamePattern,
+ LPCWSTR szIncludeImagePattern,
+ LPCWSTR szExcludeNamePattern,
+ LPCWSTR szExcludeImagePattern,
+ UINT uMsg,
+ LPAPXFNCALLBACK fnDisplayCallback,
+ LPVOID lpCbData);
+
+__APXEND_DECLS
+
+#endif /* _SERVICE_H_INCLUDED_ */
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/java/Test.java
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/java/Test.java 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/java/Test.java 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,34 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.*;
+import java.lang.*;
+
+public class Test implements Runnable {
+ public static void main (String args[]) {
+ Thread t = new Thread( new Test());
+ t.run();
+ }
+ public void run(){
+ try {
+ System.out.println("Simple Stdout message");
+ System.err.println("Simple Stderr message");
+ Thread.sleep(5000);
+ } catch( Throwable t ) {
+ t.printStackTrace(System.err);
+ }
+ }
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/libprocrun.dsp
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/libprocrun.dsp 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/libprocrun.dsp 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,234 @@
+# Microsoft Developer Studio Project File - Name="libprocrun" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=libprocrun - Win32 Unicode 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 "libprocrun.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 "libprocrun.mak" CFG="libprocrun - Win32 Unicode Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "libprocrun - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "libprocrun - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE "libprocrun - Win32 Unicode Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "libprocrun - Win32 Unicode Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "libprocrun - 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 Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I ".\include" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD BASE RSC /l 0x41a /d "NDEBUG"
+# ADD RSC /l 0x41a /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ELSEIF "$(CFG)" == "libprocrun - 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 Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I ".\include" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x41a /d "_DEBUG"
+# ADD RSC /l 0x41a /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ELSEIF "$(CFG)" == "libprocrun - Win32 Unicode Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Unicode Release"
+# PROP BASE Intermediate_Dir "Unicode Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Unicode Release"
+# PROP Intermediate_Dir "Unicode Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I ".\include" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I ".\include" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "WIN32" /D "NDEBUG" /D "_UNICODE" /D "_LIB" /YX /FD /c
+# ADD BASE RSC /l 0x41a /d "NDEBUG"
+# ADD RSC /l 0x41a /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ELSEIF "$(CFG)" == "libprocrun - Win32 Unicode Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Unicode Debug"
+# PROP BASE Intermediate_Dir "Unicode Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Unicode Debug"
+# PROP Intermediate_Dir "Unicode Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I ".\include" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I ".\include" /I "$(JAVA_HOME)\include" /I "$(JAVA_HOME)\include\win32" /D "WIN32" /D "_DEBUG" /D "_UNICODE" /D "_LIB" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x41a /d "_DEBUG"
+# ADD RSC /l 0x41a /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ENDIF
+
+# Begin Target
+
+# Name "libprocrun - Win32 Release"
+# Name "libprocrun - Win32 Debug"
+# Name "libprocrun - Win32 Unicode Release"
+# Name "libprocrun - Win32 Unicode Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\src\cmdline.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\console.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\gui.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\handles.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\javajni.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\log.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\mclib.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\registry.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\rprocess.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\service.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\utils.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\include\apxwin.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\cmdline.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\console.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\gui.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\handles.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\javajni.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\log.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\mclib.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\src\private.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\registry.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\rprocess.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\service.h
+# End Source File
+# End Group
+# End Target
+# End Project
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/libprocrun.vcproj
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/libprocrun.vcproj 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/libprocrun.vcproj 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,388 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8,00"
+ Name="libprocrun"
+ ProjectGUID="{7F9C3AC9-0AFA-428D-A4AC-1F1E53422B04}"
+ RootNamespace="libprocrun"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ <Platform
+ Name="x64"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=".\include;$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32"
+ PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=".\include;$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32"
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|x64"
+ OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=".\include;$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32"
+ PreprocessorDefinitions="WIN32;WIN64;_DEBUG;_LIB"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|x64"
+ OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=".\include;$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32"
+ PreprocessorDefinitions="WIN32;WIN64;NDEBUG;_LIB"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\src\cmdline.c"
+ >
+ </File>
+ <File
+ RelativePath=".\src\console.c"
+ >
+ </File>
+ <File
+ RelativePath=".\src\gui.c"
+ >
+ </File>
+ <File
+ RelativePath=".\src\handles.c"
+ >
+ </File>
+ <File
+ RelativePath=".\src\javajni.c"
+ >
+ </File>
+ <File
+ RelativePath=".\src\log.c"
+ >
+ </File>
+ <File
+ RelativePath=".\src\mclib.c"
+ >
+ </File>
+ <File
+ RelativePath=".\src\registry.c"
+ >
+ </File>
+ <File
+ RelativePath=".\src\rprocess.c"
+ >
+ </File>
+ <File
+ RelativePath=".\src\service.c"
+ >
+ </File>
+ <File
+ RelativePath=".\src\utils.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\include\apxwin.h"
+ >
+ </File>
+ <File
+ RelativePath=".\include\cmdline.h"
+ >
+ </File>
+ <File
+ RelativePath=".\include\console.h"
+ >
+ </File>
+ <File
+ RelativePath=".\include\gui.h"
+ >
+ </File>
+ <File
+ RelativePath=".\include\handles.h"
+ >
+ </File>
+ <File
+ RelativePath=".\include\javajni.h"
+ >
+ </File>
+ <File
+ RelativePath=".\include\log.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\mclib.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\private.h"
+ >
+ </File>
+ <File
+ RelativePath=".\include\registry.h"
+ >
+ </File>
+ <File
+ RelativePath=".\include\rprocess.h"
+ >
+ </File>
+ <File
+ RelativePath=".\include\service.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/procrun.dsw
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/procrun.dsw 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/procrun.dsw 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,74 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "apsvcmgr"=.\APPS\apsvcmgr\apsvcmgr.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name libprocrun
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "libprocrun"=.\libprocrun.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "prunmgr"=.\APPS\prunmgr\prunmgr.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name libprocrun
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "prunsrv"=.\APPS\prunsrv\prunsrv.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name libprocrun
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/procrun.sln
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/procrun.sln 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/procrun.sln 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,64 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libprocrun", "libprocrun.vcproj", "{7F9C3AC9-0AFA-428D-A4AC-1F1E53422B04}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "prunsrv", "apps\prunsrv\prunsrv.vcproj", "{19338164-D7E8-492D-9D4C-F34766964979}"
+ ProjectSection(ProjectDependencies) = postProject
+ {7F9C3AC9-0AFA-428D-A4AC-1F1E53422B04} = {7F9C3AC9-0AFA-428D-A4AC-1F1E53422B04}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "prunmgr", "apps\prunmgr\prunmgr.vcproj", "{1ABB5DF8-8560-4A20-BEA4-88A7E43C6B28}"
+ ProjectSection(ProjectDependencies) = postProject
+ {7F9C3AC9-0AFA-428D-A4AC-1F1E53422B04} = {7F9C3AC9-0AFA-428D-A4AC-1F1E53422B04}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "apsvcmgr", "apps\apsvcmgr\apsvcmgr.vcproj", "{E2B48545-30FA-4D6F-B32C-B7B29B35FE45}"
+ ProjectSection(ProjectDependencies) = postProject
+ {7F9C3AC9-0AFA-428D-A4AC-1F1E53422B04} = {7F9C3AC9-0AFA-428D-A4AC-1F1E53422B04}
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {7F9C3AC9-0AFA-428D-A4AC-1F1E53422B04}.Debug|Win32.ActiveCfg = Debug|Win32
+ {7F9C3AC9-0AFA-428D-A4AC-1F1E53422B04}.Debug|Win32.Build.0 = Debug|Win32
+ {7F9C3AC9-0AFA-428D-A4AC-1F1E53422B04}.Debug|x64.ActiveCfg = Release|x64
+ {7F9C3AC9-0AFA-428D-A4AC-1F1E53422B04}.Debug|x64.Build.0 = Release|x64
+ {7F9C3AC9-0AFA-428D-A4AC-1F1E53422B04}.Release|Win32.ActiveCfg = Release|Win32
+ {7F9C3AC9-0AFA-428D-A4AC-1F1E53422B04}.Release|Win32.Build.0 = Release|Win32
+ {7F9C3AC9-0AFA-428D-A4AC-1F1E53422B04}.Release|x64.ActiveCfg = Release|x64
+ {7F9C3AC9-0AFA-428D-A4AC-1F1E53422B04}.Release|x64.Build.0 = Release|x64
+ {19338164-D7E8-492D-9D4C-F34766964979}.Debug|Win32.ActiveCfg = Debug|Win32
+ {19338164-D7E8-492D-9D4C-F34766964979}.Debug|Win32.Build.0 = Debug|Win32
+ {19338164-D7E8-492D-9D4C-F34766964979}.Debug|x64.ActiveCfg = Release|x64
+ {19338164-D7E8-492D-9D4C-F34766964979}.Debug|x64.Build.0 = Release|x64
+ {19338164-D7E8-492D-9D4C-F34766964979}.Release|Win32.ActiveCfg = Release|Win32
+ {19338164-D7E8-492D-9D4C-F34766964979}.Release|Win32.Build.0 = Release|Win32
+ {19338164-D7E8-492D-9D4C-F34766964979}.Release|x64.ActiveCfg = Release|x64
+ {19338164-D7E8-492D-9D4C-F34766964979}.Release|x64.Build.0 = Release|x64
+ {1ABB5DF8-8560-4A20-BEA4-88A7E43C6B28}.Debug|Win32.ActiveCfg = Debug|Win32
+ {1ABB5DF8-8560-4A20-BEA4-88A7E43C6B28}.Debug|Win32.Build.0 = Debug|Win32
+ {1ABB5DF8-8560-4A20-BEA4-88A7E43C6B28}.Debug|x64.ActiveCfg = Release|x64
+ {1ABB5DF8-8560-4A20-BEA4-88A7E43C6B28}.Debug|x64.Build.0 = Release|x64
+ {1ABB5DF8-8560-4A20-BEA4-88A7E43C6B28}.Release|Win32.ActiveCfg = Release|Win32
+ {1ABB5DF8-8560-4A20-BEA4-88A7E43C6B28}.Release|Win32.Build.0 = Release|Win32
+ {1ABB5DF8-8560-4A20-BEA4-88A7E43C6B28}.Release|x64.ActiveCfg = Release|x64
+ {1ABB5DF8-8560-4A20-BEA4-88A7E43C6B28}.Release|x64.Build.0 = Release|x64
+ {E2B48545-30FA-4D6F-B32C-B7B29B35FE45}.Debug|Win32.ActiveCfg = Debug|Win32
+ {E2B48545-30FA-4D6F-B32C-B7B29B35FE45}.Debug|Win32.Build.0 = Debug|Win32
+ {E2B48545-30FA-4D6F-B32C-B7B29B35FE45}.Debug|x64.ActiveCfg = Release|x64
+ {E2B48545-30FA-4D6F-B32C-B7B29B35FE45}.Release|Win32.ActiveCfg = Release|Win32
+ {E2B48545-30FA-4D6F-B32C-B7B29B35FE45}.Release|Win32.Build.0 = Release|Win32
+ {E2B48545-30FA-4D6F-B32C-B7B29B35FE45}.Release|x64.ActiveCfg = Release|x64
+ {E2B48545-30FA-4D6F-B32C-B7B29B35FE45}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/apsvcmgr.ico
===================================================================
(Binary files differ)
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/apsvcmgr.ico
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/jakarta.bmp
===================================================================
(Binary files differ)
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/jakarta.bmp
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/license.rtf
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/license.rtf 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/license.rtf 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,33 @@
+{\rtf1\ansi\ansicpg1252\uc1\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset238\fprq2{\*\panose 02020603050405020304}Times New Roman;}
+{\f1\fswiss\fcharset238\fprq2{\*\panose 020b0604020202020204}Arial;}{\f39\froman\fcharset0\fprq2 Times New Roman;}{\f38\froman\fcharset204\fprq2 Times New Roman Cyr;}{\f40\froman\fcharset161\fprq2 Times New Roman Greek;}
+{\f41\froman\fcharset162\fprq2 Times New Roman Tur;}{\f42\froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f43\froman\fcharset178\fprq2 Times New Roman (Arabic);}{\f44\froman\fcharset186\fprq2 Times New Roman Baltic;}
+{\f45\froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\f49\fswiss\fcharset0\fprq2 Arial;}{\f48\fswiss\fcharset204\fprq2 Arial Cyr;}{\f50\fswiss\fcharset161\fprq2 Arial Greek;}{\f51\fswiss\fcharset162\fprq2 Arial Tur;}
+{\f52\fswiss\fcharset177\fprq2 Arial (Hebrew);}{\f53\fswiss\fcharset178\fprq2 Arial (Arabic);}{\f54\fswiss\fcharset186\fprq2 Arial Baltic;}{\f55\fswiss\fcharset163\fprq2 Arial (Vietnamese);}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;
+\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;
+\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext0 Normal;}{\*\cs10 \additive
+\ssemihidden Default Paragraph Font;}{\*\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\trcbpat1\trcfpat1\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv
+\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\lang1024\langfe1024\cgrid\langnp1024\langfenp1024 \snext11 \ssemihidden Normal Table;}{\*\cs15 \additive \ul\cf2 \sbasedon10 Hyperlink;}}
+{\*\latentstyles\lsdstimax156\lsdlockeddef0}{\*\rsidtbl \rsid1379267\rsid3345586\rsid5638524\rsid6496053\rsid6510316\rsid6697379\rsid7028353\rsid9000330\rsid9454304\rsid10124145\rsid10819759\rsid12321742\rsid12593955\rsid14358633\rsid15670059\rsid16132583
+}{\*\generator Microsoft Word 11.0.5604;}{\info{\author Mladen Turk}{\operator Mladen Turk}{\creatim\yr2003\mo4\dy9\hr14\min37}{\revtim\yr2004\mo4\dy7\hr8\min42}{\version14}{\edmins11}{\nofpages1}{\nofwords96}{\nofchars549}
+{\*\company Apache Software Foundation}{\nofcharsws644}{\vern24689}}\margl1417\margr1417\margt1417\margb1417 \widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\horzdoc\dghspace120\dgvspace120\dghorigin1701
+\dgvorigin1984\dghshow0\dgvshow3\jcompress\viewkind4\viewscale100\nolnhtadjtbl\rsidroot9000330 \fet0\sectd \linex0\sectdefaultcl\sftnbj {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang
+{\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang {\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang
+{\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}\pard\plain
+\qc \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0\pararsid14358633 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\b\f1\insrsid16132583\charrsid12321742 The Apache Software License, Version 2.0
+\par }\pard \ql \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0 {\f1\fs18\insrsid16132583\charrsid16132583
+\par }\pard \ql \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0\pararsid9454304 {\f1\fs18\insrsid9454304 }{\f1\fs18\insrsid16132583\charrsid16132583 Copyright 2002-2004 The Apache Software Foundation.
+\par }\pard \ql \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0\pararsid1379267 {\f1\fs18\insrsid16132583\charrsid16132583
+\par }{\f1\fs18\insrsid14358633 }{\f1\fs18\insrsid16132583\charrsid16132583 Licensed under the Apache License, Version 2.0 (the "License");
+\par }{\f1\fs18\insrsid14358633 }{\f1\fs18\insrsid16132583\charrsid16132583 you may not use this file except in compliance with the License.
+\par }{\f1\fs18\insrsid14358633 }{\f1\fs18\insrsid16132583\charrsid16132583 You may obtain a copy of the License at
+\par }{\f1\fs18\insrsid12593955
+\par }{\f1\fs18\insrsid16132583\charrsid16132583
+\par }{\cf2\insrsid6510316 }{\ul\cf2\insrsid16132583\charrsid6510316 http://www.apache.org/licenses/LICENSE-2.0
+\par }{\f1\fs18\insrsid12593955
+\par
+\par }{\f1\fs18\insrsid12321742 \line }{\f1\fs18\insrsid14358633 }{\f1\fs18\insrsid16132583\charrsid16132583 Unless required by applicable law or agreed to in writing, software
+\par }{\f1\fs18\insrsid14358633 }{\f1\fs18\insrsid16132583\charrsid16132583 distributed under the License is distributed on an "AS IS" BASIS,}{\f1\fs18\insrsid14358633 }{\f1\fs18\insrsid16132583\charrsid16132583
+\par }{\f1\fs18\insrsid14358633 }{\f1\fs18\insrsid16132583\charrsid16132583 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+\par }{\f1\fs18\insrsid14358633 }{\f1\fs18\insrsid16132583\charrsid16132583 See the License for the specific language governing permissions and
+\par }{\f1\fs18\insrsid14358633 }{\f1\fs18\insrsid14358633\charrsid16132583 L}{\f1\fs18\insrsid16132583\charrsid16132583 imitations under the License.
+\par }}
\ No newline at end of file
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/procrunr.ico
===================================================================
(Binary files differ)
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/procrunr.ico
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/procruns.ico
===================================================================
(Binary files differ)
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/procruns.ico
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/procrunw.ico
===================================================================
(Binary files differ)
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/procrunw.ico
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/sorterd.bmp
===================================================================
(Binary files differ)
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/sorterd.bmp
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/sorteru.bmp
===================================================================
(Binary files differ)
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/sorteru.bmp
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/sstatus.bmp
===================================================================
(Binary files differ)
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/sstatus.bmp
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/susers.bmp
===================================================================
(Binary files differ)
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/susers.bmp
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/toolbar.bmp
===================================================================
(Binary files differ)
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/resources/toolbar.bmp
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/samples/cchild.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/samples/cchild.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/samples/cchild.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,133 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* Simple console child */
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <conio.h>
+#include <time.h>
+#include <process.h> /* _beginthread, _endthread */
+#include <fcntl.h>
+#include <io.h>
+
+#define STDIN_FILENO 0
+#define STDOUT_FILENO 1
+#define STDERR_FILENO 2
+
+#define STDO_MESSAGE "Simple STDOUT_FILENO message\n"
+#define STDE_MESSAGE "Simple STDERR_FILENO message\n"
+
+#define NLOOPS 5
+#define NTHREADS 10
+
+static int do_echo = 0;
+BOOL WINAPI ControlHandler ( DWORD dwCtrlType )
+{
+ printf("\nCTRL Event %d ", dwCtrlType);
+ switch (dwCtrlType) {
+ case CTRL_BREAK_EVENT:
+ printf("CTRL+BREAK\n");
+ exit(1);
+ return TRUE;
+ case CTRL_C_EVENT:
+ printf("CTRL+C");
+ return TRUE;
+ break;
+
+ }
+ putch('\n');
+ return FALSE;
+}
+
+unsigned __stdcall threadfunc(void *args)
+{
+ int i, p , r;
+ p = (int)(size_t)args;
+ printf("Created thread %d %04x\n", p, GetCurrentThreadId());
+ srand((unsigned)time(NULL) + p);
+ for (i = 0; i < NLOOPS; i++) {
+ r = rand() % 1000;
+ Sleep(r);
+ printf("Thread %d message %d\n", p, i);
+ }
+ printf("Quiting thread %d %04x\n", p, GetCurrentThreadId());
+ _endthreadex(0);
+ return 0;
+}
+
+
+int main(int argc, char *argv[])
+{
+ int i, conio = 0, threads = 0;
+ char buf[256];
+ HANDLE htrd[NTHREADS];
+
+ OutputDebugString("cchild starting");
+ fprintf(stdout, "cchild starting %s\n", argv[0]);
+ fflush(stdout);
+ SetConsoleCtrlHandler(ControlHandler, TRUE);
+ Sleep(1000);
+
+ for (i = 0; i < __argc; i++) {
+ fprintf(stdout, "argv[%d] %s\n", i, __argv[i]);
+ fflush(stdout);
+ if (strcmp(__argv[i], "--") == 0)
+ do_echo = 1;
+ else if (strcmp(__argv[i], "-c") == 0)
+ conio = 1;
+ else if (strcmp(__argv[i], "-t") == 0)
+ threads = 1;
+ }
+ fflush(stdout);
+ fprintf(stderr, "Simple stderr message\n");
+ fflush(stderr);
+ write(STDOUT_FILENO, STDO_MESSAGE, sizeof(STDO_MESSAGE) - 1);
+ write(STDERR_FILENO, STDE_MESSAGE, sizeof(STDE_MESSAGE) - 1);
+
+ if (conio) {
+ cputs("Type 'Y' when finished typing keys...");
+ do {
+ i = getch();
+ i = toupper(i);
+ } while (i != 'Y');
+ putch('\n');
+ }
+ if (do_echo) {
+ cputs("Going to echo loop...\n");
+ while ((i = read(STDIN_FILENO, buf, 256)) > 0) {
+ buf[i] = '\0';
+ fputs(buf, stdout);
+ if (strcmp(buf, "quit\n") == 0)
+ break;
+ }
+ }
+ if (threads) {
+ for (i = 0; i < NTHREADS; i++) {
+ unsigned id;
+ htrd[i] = (HANDLE)_beginthreadex(NULL, 0, threadfunc, (void *)(size_t)i, 0, &id);
+ }
+ WaitForMultipleObjects(10, htrd, TRUE, INFINITE);
+ }
+
+ fprintf(stdout, "cchild finishing\n");
+ fprintf(stdout, "cchild finished\n");
+ Sleep(1000);
+ OutputDebugString("cchild Ended");
+ return 0;
+}
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/samples/cchild.vcproj
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/samples/cchild.vcproj 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/samples/cchild.vcproj 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,227 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="cchild"
+ ProjectGUID="{E9ABF9C5-CCF7-4372-B42A-07584D2441D8}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="..\obj\Release"
+ IntermediateDirectory="..\obj\Release"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../bin/cchild.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ EntryPointSymbol=""
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="..\obj\Debug"
+ IntermediateDirectory="..\obj\Debug"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../bin/cchildd.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/cchild.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Debug Unicode|Win32"
+ OutputDirectory="..\obj\$(ConfigurationName)"
+ IntermediateDirectory="..\obj\$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_UNICODE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../bin/cchildud.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/cchild.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release Unicode|Win32"
+ OutputDirectory="..\obj\$(ConfigurationName)"
+ IntermediateDirectory="..\obj\$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="../bin/cchildu.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath=".\cchild.c">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/cmdline.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/cmdline.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/cmdline.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,276 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apxwin.h"
+#include "private.h"
+
+#define EXE_SUFFIX L".EXE"
+#define EXE_SUFFIXLEN (sizeof(EXE_SUFFIX) / sizeof(WCHAR) - 1)
+
+/* Those two are declared in handles.c */
+extern LPWSTR *_st_sys_argvw;
+extern int _st_sys_argc;
+
+static WCHAR _st_sys_appexe[MAX_PATH];
+/*
+ * argv parsing.
+ * Parse the argv[0] and split to ExePath and
+ * Executable name. Strip the extension ('.exe').
+ * Check for command in argv[1] //CMD//Application
+ * Parse the options --option value or --option==value
+ * break on first argument that doesn't start with '--'
+ */
+LPAPXCMDLINE apxCmdlineParse(
+ APXHANDLE hPool,
+ APXCMDLINEOPT *lpOptions,
+ LPCWSTR *lpszCommands)
+{
+
+ LPAPXCMDLINE lpCmdline = NULL;
+ DWORD l, i = 0, s = 1;
+ LPWSTR p;
+ WCHAR cmd[4];
+ DWORD match;
+ BOOL add;
+ if (_st_sys_argc < 1)
+ return NULL;
+
+ l = lstrlenW(_st_sys_argvw[0]);
+ if (l < EXE_SUFFIXLEN)
+ return NULL;
+ if (!(lpCmdline = (LPAPXCMDLINE)apxPoolCalloc(hPool, sizeof(APXCMDLINE))))
+ return NULL;
+ lpCmdline->hPool = hPool;
+ lpCmdline->lpOptions = lpOptions;
+ lpCmdline->szExePath = _st_sys_argvw[0];
+ p = lpCmdline->szExePath + l;
+
+ while (p > lpCmdline->szExePath) {
+ if (*p == L'\\') {
+ *p++ = L'\0';
+ break;
+ }
+ p--;
+ }
+ /* Find the path if it wasn't specified in the argv[0] */
+ if (p == lpCmdline->szExePath) {
+ WCHAR mh[4096];
+ LPWSTR m;
+ if (GetModuleFileNameW(GetModuleHandle(NULL), mh, 4096)) {
+ lpCmdline->szExePath = apxPoolStrdupW(hPool, mh);
+ m = lpCmdline->szExePath + lstrlenW(lpCmdline->szExePath);
+ while (m > lpCmdline->szExePath) {
+ if (*(m--) == L'\\') {
+ *(++m) = L'\0';
+ break;
+ }
+ }
+ }
+ }
+ lpCmdline->szExecutable = p;
+ p = _st_sys_argvw[0] + l - EXE_SUFFIXLEN;
+ if (lstrcmpiW(p, EXE_SUFFIX) == 0)
+ *p = L'\0';
+ if (lpszCommands && _st_sys_argc > 1 && lstrlenW(_st_sys_argvw[1]) > 5) {
+ if (_st_sys_argvw[1][0] == L'/' &&
+ _st_sys_argvw[1][1] == L'/' &&
+ _st_sys_argvw[1][5] == L'/') { /* allow max tree char command */
+ l = 2;
+ while (_st_sys_argvw[1][l] != L'/') {
+ cmd[l - 2] = _st_sys_argvw[1][l];
+ if (l++ > 3)
+ break;
+ }
+ cmd[l - 2] = L'\0';
+ while (lpszCommands[i]) {
+ if (lstrcmpW(lpszCommands[i++], cmd) == 0) {
+ lpCmdline->dwCmdIndex = i;
+ s = 2;
+ break;
+ }
+ }
+ if (lpCmdline->dwCmdIndex) {
+ _st_sys_argvw[1][l+1] = L'\0';
+ lpCmdline->szApplication = &(_st_sys_argvw[1][l+2]);
+ if (!lstrlenW(lpCmdline->szApplication))
+ lpCmdline->szApplication = _st_sys_argvw[0];
+ }
+ else {
+ apxLogWrite(APXLOG_MARK_ERROR "Unrecognized cmd option %s", cmd);
+ s = 2;
+ }
+ }
+ }
+ else {
+ lpCmdline->szApplication = lpCmdline->szExecutable;
+ lpCmdline->dwCmdIndex = 1;
+ return lpCmdline;
+ }
+ for (i = s; i < (DWORD)_st_sys_argc; i++) {
+ LPWSTR e = NULL;
+ if (_st_sys_argvw[i][0] != L'-' ||
+ _st_sys_argvw[i][1] != L'-') {
+ if (_st_sys_argvw[i][0] != L'+' ||
+ _st_sys_argvw[i][1] != L'+')
+ break;
+ else
+ add = TRUE;
+ }
+ else
+ add = FALSE;
+ p = &(_st_sys_argvw[i][2]);
+ /* Find if the option has '=' char
+ * for --option==value or --option value cases.
+ */
+ while (*p) {
+ if (*p == L'=') {
+ *p = L'\0';
+ e = p + 1;
+ break;
+ }
+ else
+ p++;
+ }
+ match = 0;
+ for (l = 0; lpOptions[l].szName; l++) {
+ if (lstrcmpW(lpOptions[l].szName, &(_st_sys_argvw[i][2])) == 0) {
+ LPWSTR val;
+ /* check if arg is needed */
+ if (e)
+ val = e;
+ else if ((i + 1) < (DWORD)_st_sys_argc)
+ val = _st_sys_argvw[++i];
+ else {
+ lpOptions[l].dwValue = 0;
+ lpOptions[l].szValue = NULL;
+ lpOptions[l].dwType |= APXCMDOPT_FOUND;
+ break;
+ }
+ if (lpOptions[l].dwType & APXCMDOPT_STR)
+ lpOptions[l].szValue = val;
+ else if (lpOptions[l].dwType & APXCMDOPT_INT)
+ lpOptions[l].dwValue = (DWORD)apxAtoulW(val);
+ else if (lpOptions[l].dwType & APXCMDOPT_MSZ) {
+ LPWSTR pp;
+ BOOL insquote = FALSE, indquote=FALSE;
+ DWORD sp = 0;
+ LPWSTR ov = lpOptions[l].szValue;
+ if (lpOptions[l].dwValue > 2) {
+ sp = (lpOptions[l].dwValue - sizeof(WCHAR)) / sizeof(WCHAR);
+ }
+ lpOptions[l].dwValue = (sp + lstrlenW(val) + 2) * sizeof(WCHAR);
+ lpOptions[l].szValue = (LPWSTR)apxPoolCalloc(hPool,
+ lpOptions[l].dwValue);
+ if (sp) {
+ AplMoveMemory(lpOptions[l].szValue, ov, sp * sizeof(WCHAR));
+ apxFree(ov);
+ }
+ pp = val;
+ while(*pp) {
+ if (*pp == L'\'')
+ insquote = !insquote;
+ else if (*pp == L'"') {
+ indquote = !indquote;
+ lpOptions[l].szValue[sp++] = L'"';
+ }
+ else if ((*pp == L'#' || *pp == L';') && !insquote && !indquote)
+ lpOptions[l].szValue[sp++] = L'\0';
+ else
+ lpOptions[l].szValue[sp++] = *pp;
+ pp++;
+ }
+ }
+ lpOptions[l].dwType |= APXCMDOPT_FOUND;
+ if (add)
+ lpOptions[l].dwType |= APXCMDOPT_ADD;
+ match = l + 1;
+ break;
+ }
+ }
+ }
+ if (i < (DWORD)_st_sys_argc) {
+ lpCmdline->dwArgc = _st_sys_argc - i;
+ lpCmdline->lpArgvw = &_st_sys_argvw[i];
+ }
+ return lpCmdline;
+}
+
+/* Used for future expansion */
+void apxCmdlineFree(
+ LPAPXCMDLINE lpCmdline)
+{
+
+ apxFree(lpCmdline);
+}
+
+/*
+ * Environment variables parsing
+ * Each variable is prfixed with PR_
+ * for example 'set PR_JVM=auto' has a same meaning as providing '--Jvm auto'
+ * on the command line.
+ * Multistring varisables are added to the present conf.
+ */
+void apxCmdlineLoadEnvVars(
+ LPAPXCMDLINE lpCmdline)
+{
+ WCHAR szEnv[64];
+ int i = 0;
+ if (!lpCmdline || !lpCmdline->lpOptions)
+ return;
+
+ while (lpCmdline->lpOptions[i].szName) {
+ DWORD l;
+ WCHAR szVar[SIZ_HUGLEN];
+ lstrcpyW(szEnv, L"PR_");
+ lstrcatW(szEnv, lpCmdline->lpOptions[i].szName);
+ l = GetEnvironmentVariableW(szEnv, szVar, SIZ_HUGMAX);
+ if (l == 0 && GetLastError() != ERROR_ENVVAR_NOT_FOUND) {
+ apxLogWrite(APXLOG_MARK_ERROR "Error geting environment variable %S",
+ szEnv);
+ ++i;
+ continue;
+ }
+ if (l && (lpCmdline->lpOptions[i].dwType & APXCMDOPT_STR)) {
+ lpCmdline->lpOptions[i].szValue = apxPoolStrdupW(lpCmdline->hPool, szVar);
+ lpCmdline->lpOptions[i].dwType |= APXCMDOPT_FOUND;
+ }
+ else if (l && (lpCmdline->lpOptions[i].dwType & APXCMDOPT_MSZ)) {
+ LPWSTR pp;
+ BOOL insquote = FALSE, indquote = FALSE;
+ DWORD sp = 0;
+ lpCmdline->lpOptions[i].szValue = apxPoolCalloc(lpCmdline->hPool,
+ (lstrlenW(szVar) + 2) *
+ sizeof(WCHAR));
+ lstrcpyW(lpCmdline->lpOptions[i].szValue, szVar);
+ pp = szVar;
+ while(*pp) {
+ if (*pp == L'\'')
+ insquote = !insquote;
+ else if (*pp == L'"') {
+ indquote = !indquote;
+ lpCmdline->lpOptions[i].szValue[sp++] = L'"';
+ }
+ else if ((*pp == L'#' || *pp == L';') && !insquote && !indquote)
+ lpCmdline->lpOptions[i].szValue[sp++] = L'\0';
+ else
+ lpCmdline->lpOptions[i].szValue[sp++] = *pp;
+ pp++;
+ }
+ lpCmdline->lpOptions[i].dwType |= APXCMDOPT_FOUND | APXCMDOPT_ADD;
+ }
+ ++i;
+ }
+
+}
\ No newline at end of file
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/console.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/console.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/console.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,149 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apxwin.h"
+#include "private.h"
+
+/** Console layout saved in the registry as binary */
+typedef struct stAPXCONSOLE_LAYOUT {
+ /** Main window size */
+ POINT ptSize;
+ /** Main window size and position */
+ RECT rcPos;
+ /** Client window size */
+ POINT ptClientSize;
+ /** Client size and position */
+ RECT rcClientPos;
+ /** Scroll position */
+ POINT ptScrollPos;
+ /** Maximum Scroll position */
+ POINT ptScrollMax;
+ /** Caret position */
+ POINT ptCaretPos;
+ /** Background color */
+ COLORREF clrBackground;
+ /** Text color */
+ COLORREF clrText;
+ /** Selected text background color */
+ COLORREF clrSelectBackground;
+ /** Selected rext color */
+ COLORREF clrSelectText;
+ /** Character size */
+ POINT ptCharSize;
+ /** Current Screen size */
+ POINT ptScreenSize;
+ /** Font size */
+ INT nFontSize;
+ /** Caret size */
+ POINT ptCaretSize;
+ /** Caret Bilnk time in ms */
+ UINT nCaretBlinkTime;
+ /** Typeface name of the font (32 char max including the null terminator) */
+ TCHAR szFontName[32];
+
+} stAPXCONSOLE_LAYOUT, *APXCONSOLE_LAYOUT;
+
+typedef struct stAPXCONSOLE {
+ /** Application instance handle */
+ HINSTANCE hInstance;
+ /** Console Screen Buffer */
+ TCHAR lpScreenBuffer;
+ /** The size of the Console Screen Buffer */
+ DWORD dwScreenBufferSize;
+ /** Main window Handle */
+ HWND hWnd;
+ /** Console window Handle */
+ HWND hConsole;
+ /** Console Window Layout */
+ stAPXCONSOLE_LAYOUT stLayout;
+ /** Console Keyboard Buffer */
+ TCHAR lpKeyboardBuffer;
+ /** The size of the Keyboard Buffer */
+ DWORD dwKeyboardBufferSize;
+ /** Console Handler routine */
+ PHANDLER_ROUTINE fnHandlerRoutine;
+ /** Console Reference Count */
+ DWORD dwReferenceCount;
+} stAPXCONSOLE, *APXCONSOLE;
+
+APXHANDLE __st_sys_console = NULL;
+
+static BOOL __apxConsoleCallback(APXHANDLE hObject, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ APXCONSOLE lpConsole = APXHANDLE_DATA(hObject);
+
+ if (hObject->dwType != APXHANDLE_TYPE_CONSOLE)
+ return FALSE;
+ switch (uMsg) {
+ case WM_CLOSE:
+
+ break;
+ default:
+ break;
+ }
+ return TRUE;
+}
+
+APXHANDLE
+apxAllocConsoleHandle(APXHANDLE hPool)
+{
+ APXHANDLE hConsole;
+
+ hConsole = apxHandleCreate(hPool, APXHANDLE_HAS_EVENT |
+ APXHANDLE_OWNS_LOCK, NULL,
+ sizeof(stAPXCONSOLE),
+ __apxConsoleCallback);
+
+ return hConsole;
+}
+
+BOOL
+apxFreeConsoleHandle(APXHANDLE hConsole)
+{
+ APXCONSOLE lpConsole = APXHANDLE_DATA(hConsole);
+ if (hConsole->dwType != APXHANDLE_TYPE_CONSOLE)
+ return FALSE;
+
+ return apxCloseHandle(hConsole);
+}
+
+
+
+
+
+/** Standard Console Functions */
+BOOL
+apxAllocConsole()
+{
+
+ if (!__st_sys_console) {
+ __st_sys_console = apxAllocConsoleHandle(NULL);
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+BOOL
+apxFreeConsole()
+{
+ if (apxFreeConsoleHandle(__st_sys_console)) {
+ __st_sys_console = NULL;
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/gui.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/gui.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/gui.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,1024 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apxwin.h"
+#include "private.h"
+
+#define BALLON_TIMEOUT 1000
+/* Offset for listview dots */
+#define DOTOFFSET 0
+
+static HMODULE _st_sys_riched;
+static APXGUISTORE _st_sys_gui;
+static HIMAGELIST _st_sel_users_il = NULL;
+static WNDPROC _st_sel_users_lvm;
+
+typedef struct PROGRESS_DLGPARAM {
+ LPCTSTR szHead;
+ LPCWSTR szText;
+ LPVOID cbData;
+ LPAPXFNCALLBACK fnCb;
+ HANDLE hThread;
+ HWND hDialog;
+} PROGRESS_DLGPARAM, *LPPROGRESS_DLGPARAM;
+
+APXLVITEM lvUsers[] = {
+ { 0, FALSE, 180, 180, LVCFMT_LEFT, TEXT("User") },
+ { 0, TRUE, 180, 180, LVCFMT_LEFT, TEXT("Full Name") },
+ { 0, TRUE, 235, 235, LVCFMT_LEFT, TEXT("Comment") }
+};
+
+
+#define NUMLVUSERS (sizeof(lvUsers) / sizeof(lvUsers[0]))
+
+static UINT __getWhellScrollLines()
+{
+ HWND hdlMsWheel;
+ UINT ucNumLines = 3; /* 3 is the default */
+ UINT uiMsh_MsgScrollLines;
+
+ APX_OSLEVEL os = apxGetOsLevel();
+ /* In Windows 9x & Windows NT 3.51, query MSWheel for the
+ * number of scroll lines. In Windows NT 4.0 and later,
+ * use SystemParametersInfo.
+ */
+ if (os < APX_WINVER_NT_4) {
+ hdlMsWheel = FindWindow(MSH_WHEELMODULE_CLASS,
+ MSH_WHEELMODULE_TITLE);
+ if (hdlMsWheel) {
+ uiMsh_MsgScrollLines = RegisterWindowMessage(MSH_SCROLL_LINES);
+ if (uiMsh_MsgScrollLines)
+ ucNumLines = (int)SendMessage(hdlMsWheel,
+ uiMsh_MsgScrollLines,
+ 0, 0);
+ }
+ }
+ else {
+ SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0,
+ &ucNumLines, 0);
+ }
+ return ucNumLines;
+}
+
+/* Initialize the Gui
+ */
+LPAPXGUISTORE apxGuiInitialize(WNDPROC lpfnWndProc, LPCTSTR szAppName)
+{
+ INITCOMMONCONTROLSEX stCmn;
+ WNDCLASSEX wcex;
+
+ _st_sys_gui.hInstance = GetModuleHandleA(NULL);
+ GetStartupInfo(&_st_sys_gui.stStartupInfo);
+
+ lstrcpy(_st_sys_gui.szWndClass, szAppName);
+ lstrcat(_st_sys_gui.szWndClass, TEXT("_CLASS"));
+
+ /* Single instance or general application mutex */
+ lstrcpy(_st_sys_gui.szWndMutex, szAppName);
+ lstrcat(_st_sys_gui.szWndMutex, TEXT("_MUTEX"));
+
+
+ stCmn.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ stCmn.dwICC = ICC_WIN95_CLASSES | ICC_USEREX_CLASSES | ICC_COOL_CLASSES |
+ ICC_INTERNET_CLASSES | ICC_PAGESCROLLER_CLASS | ICC_BAR_CLASSES;
+
+ InitCommonControlsEx(&stCmn);
+
+ _st_sys_riched = LoadLibraryA("RICHED32.DLL");
+ _st_sys_gui.hIconSm = LoadImage(_st_sys_gui.hInstance, MAKEINTRESOURCE(IDI_MAINICON),
+ IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
+ _st_sys_gui.hIcon = LoadImage(_st_sys_gui.hInstance, MAKEINTRESOURCE(IDI_MAINICON),
+ IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR);
+ _st_sys_gui.hIconHg = LoadImage(_st_sys_gui.hInstance, MAKEINTRESOURCE(IDI_MAINICON),
+ IMAGE_ICON, 48, 48, LR_DEFAULTCOLOR);
+ _st_sys_gui.hAccel = LoadAccelerators(_st_sys_gui.hInstance,
+ MAKEINTRESOURCE(IDC_APPLICATION));
+ _st_sys_gui.stState.rcPosition.left = CW_USEDEFAULT;
+ _st_sys_gui.stState.rcPosition.top = CW_USEDEFAULT;
+ _st_sys_gui.stState.rcPosition.right = CW_USEDEFAULT;
+ _st_sys_gui.stState.rcPosition.bottom = CW_USEDEFAULT;
+
+ _st_sys_gui.nWhellScroll = __getWhellScrollLines();
+
+ wcex.cbSize = sizeof(WNDCLASSEX);
+
+ wcex.style = 0;
+ wcex.lpfnWndProc = lpfnWndProc;
+ wcex.cbClsExtra = 0;
+ wcex.cbWndExtra = 0;
+ wcex.hInstance = _st_sys_gui.hInstance;
+ wcex.hIcon = _st_sys_gui.hIcon;
+ wcex.hIconSm = _st_sys_gui.hIconSm;
+ wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wcex.hbrBackground = (HBRUSH)(COLOR_INACTIVEBORDER+1);
+ wcex.lpszMenuName = MAKEINTRESOURCE(IDC_APPLICATION);
+ wcex.lpszClassName = _st_sys_gui.szWndClass;
+
+ if (RegisterClassEx(&wcex)) {
+ return &_st_sys_gui;
+ }
+ else
+ return NULL;
+}
+
+
+BOOL apxCenterWindow(HWND hwndChild, HWND hwndParent)
+{
+ RECT rChild, rParent, rWorkArea;
+ int wChild, hChild, wParent, hParent;
+ int xNew, yNew;
+ BOOL bResult;
+
+ /* Get the Height and Width of the child window */
+ GetWindowRect(hwndChild, &rChild);
+ wChild = rChild.right - rChild.left;
+ hChild = rChild.bottom - rChild.top;
+
+ /* Get the Height and Width of the parent window */
+ GetWindowRect(hwndParent, &rParent);
+ wParent = rParent.right - rParent.left;
+ hParent = rParent.bottom - rParent.top;
+
+ if (wParent < wChild && hParent < hChild) {
+ GetWindowRect(GetDesktopWindow(), &rParent);
+ wParent = rParent.right - rParent.left;
+ hParent = rParent.bottom - rParent.top;
+ }
+ /* Get the limits of the 'workarea' */
+ bResult = SystemParametersInfo(SPI_GETWORKAREA, sizeof(RECT),
+ &rWorkArea, 0);
+ if (!bResult) {
+ rWorkArea.left = rWorkArea.top = 0;
+ rWorkArea.right = GetSystemMetrics(SM_CXSCREEN);
+ rWorkArea.bottom = GetSystemMetrics(SM_CYSCREEN);
+ }
+
+ /* Calculate new X position, then adjust for workarea */
+ xNew = rParent.left + ((wParent - wChild) /2);
+ if (xNew < rWorkArea.left)
+ xNew = rWorkArea.left;
+ else if ((xNew+wChild) > rWorkArea.right)
+ xNew = rWorkArea.right - wChild;
+
+ /* Calculate new Y position, then adjust for workarea */
+ yNew = rParent.top + ((hParent - hChild) /2);
+ if (yNew < rWorkArea.top)
+ yNew = rWorkArea.top;
+ else if ((yNew+hChild) > rWorkArea.bottom)
+ yNew = rWorkArea.bottom - hChild;
+
+ /* Set it, and return */
+ return SetWindowPos(hwndChild, NULL, xNew, yNew, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
+}
+
+/***************************************************************************
+ * Function: LoadRcString
+ *
+ * Purpose: Loads a resource string from string table and returns a pointer
+ * to the string.
+ *
+ * Parameters: wID - resource string id
+ *
+ */
+
+/** Load the resource string with the ID given, and return a
+ * pointer to it. Notice that the buffer is common memory so
+ * the string must be used before this call is made a second time.
+ */
+
+LPSTR apxLoadResourceA(UINT wID, UINT nBuf)
+
+{
+ static CHAR szBuf[4][SIZ_BUFLEN];
+ if (nBuf > 4)
+ return "";
+ if (LoadStringA(_st_sys_gui.hInstance,wID ,szBuf[nBuf], SIZ_BUFMAX) > 0)
+ return szBuf[nBuf];
+ else
+ return "";
+}
+
+LPWSTR apxLoadResourceW(UINT wID, UINT nBuf)
+
+{
+ static WCHAR szBuf[4][SIZ_BUFLEN];
+ if (nBuf > 4)
+ return L"";
+ if (LoadStringW(_st_sys_gui.hInstance,wID ,szBuf[nBuf], SIZ_BUFMAX) > 0)
+ return szBuf[nBuf];
+ else
+ return L"";
+}
+
+/* Add the item to the Try popup menu
+ */
+void apxAppendMenuItem(HMENU hMenu, UINT idMenu, LPCTSTR szName,
+ BOOL bDefault, BOOL bEnabled)
+{
+ MENUITEMINFO miI;
+
+ AplZeroMemory(&miI, sizeof(MENUITEMINFO));
+ miI.cbSize = sizeof(MENUITEMINFO);
+ miI.fMask = MIIM_TYPE | MIIM_STATE;
+ if (szName && lstrlen(szName)) {
+ miI.fMask |= MIIM_ID;
+ miI.fType = MFT_STRING;
+ miI.wID = idMenu;
+ if (bDefault)
+ miI.fState = MFS_DEFAULT;
+ if (!bEnabled)
+ miI.fState |= MFS_DISABLED;
+ miI.dwTypeData = (LPTSTR)szName;
+ }
+ else {
+ miI.fType = MFT_SEPARATOR;
+ }
+ InsertMenuItem(hMenu, idMenu, FALSE, &miI);
+}
+
+/* Add the item to the Try popup menu
+ */
+void apxAppendMenuItemBmp(HMENU hMenu, UINT idMenu, LPCTSTR szName)
+{
+ MENUITEMINFO miI;
+ HBITMAP hBmp;
+
+ hBmp = LoadImage(_st_sys_gui.hInstance, szName,
+ IMAGE_BITMAP, 0, 0,
+ LR_CREATEDIBSECTION | LR_SHARED);
+
+ AplZeroMemory(&miI, sizeof(MENUITEMINFO));
+ miI.cbSize = sizeof(MENUITEMINFO);
+ miI.fMask = MIIM_BITMAP | MFT_MENUBARBREAK;
+
+ miI.hbmpItem = hBmp;
+ InsertMenuItem(hMenu, idMenu, FALSE, &miI);
+}
+
+/* Try icon helper
+ * Add/Change/Delete icon from the windows try.
+ */
+void apxManageTryIconA(HWND hWnd, DWORD dwMessage, LPCSTR szInfoTitle,
+ LPCSTR szInfo, HICON hIcon)
+{
+ static BOOL inTry = FALSE;
+ NOTIFYICONDATAA nId;
+ AplZeroMemory(&nId, sizeof(NOTIFYICONDATAA));
+
+ nId.cbSize = sizeof(NOTIFYICONDATAA);
+ nId.hWnd = hWnd;
+ nId.uID = 0xFF;
+ nId.uCallbackMessage = WM_TRAYMESSAGE;
+ nId.uFlags = NIF_MESSAGE;
+
+ if (dwMessage == NIM_ADD && inTry)
+ return;
+ if (dwMessage != NIM_DELETE) {
+ nId.uFlags |= NIF_ICON;
+ if (! szInfoTitle) {
+ nId.uFlags |= NIF_TIP;
+ lstrcpynA(nId.szTip, szInfo, 63);
+ }
+ else if (szInfo) {
+ nId.uFlags |= NIF_INFO;
+ lstrcpynA(nId.szInfo, szInfo, 255);
+ lstrcpynA(nId.szInfoTitle, szInfoTitle, 63);
+ nId.dwInfoFlags = NIIF_INFO;
+ nId.uTimeout = BALLON_TIMEOUT;
+ }
+
+ nId.hIcon = hIcon ? hIcon : _st_sys_gui.hIconSm;
+ inTry = TRUE;
+ }
+ else
+ inTry = FALSE;
+
+ Shell_NotifyIconA(dwMessage, &nId);
+}
+
+void apxManageTryIconW(HWND hWnd, DWORD dwMessage, LPCWSTR szInfoTitle,
+ LPCWSTR szInfo, HICON hIcon)
+{
+
+ NOTIFYICONDATAW nId;
+ AplZeroMemory(&nId, sizeof(NOTIFYICONDATAW));
+
+ nId.cbSize = sizeof(NOTIFYICONDATAW);
+ nId.hWnd = hWnd;
+ nId.uID = 0xFF;
+ nId.uCallbackMessage = WM_TRAYMESSAGE;
+ nId.uFlags = NIF_MESSAGE;
+
+ if (dwMessage != NIM_DELETE) {
+ nId.uFlags |= NIF_ICON;
+ if (! szInfoTitle) {
+ nId.uFlags |= NIF_TIP;
+ lstrcpynW(nId.szTip, szInfo, 63);
+ }
+ else if (szInfo) {
+ nId.uFlags |= NIF_INFO;
+ lstrcpynW(nId.szInfo, szInfo, 255);
+ lstrcpynW(nId.szInfoTitle, szInfoTitle, 63);
+ nId.dwInfoFlags = NIIF_INFO;
+ nId.uTimeout = BALLON_TIMEOUT;
+ }
+ nId.hIcon = hIcon ? hIcon : _st_sys_gui.hIconSm;
+ }
+
+ Shell_NotifyIconW(dwMessage, &nId);
+}
+
+static void __apxShellAbout(HWND hWnd)
+{
+ TCHAR szApplication[512];
+
+ wsprintf(szApplication , TEXT("About - %s#Windows"),
+ apxLoadResource(IDS_APPLICATION, 0));
+
+ ShellAbout(hWnd, szApplication,
+ apxLoadResource(IDS_APPDESCRIPTION, 1),
+ _st_sys_gui.hIconHg);
+}
+
+
+static LRESULT CALLBACK __apxAboutDlgProc(HWND hDlg, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ static HWND hRich = NULL;
+ static POINT ptScroll;
+ HRSRC hRsrc;
+ HGLOBAL hGlob;
+ LPSTR szTxt;
+
+ switch (uMsg) {
+ case WM_INITDIALOG:
+ apxCenterWindow(hDlg, _st_sys_gui.hMainWnd);
+ hRich = GetDlgItem(hDlg, IDC_LICENSE);
+ hRsrc = FindResource(GetModuleHandleA(NULL), MAKEINTRESOURCE(IDR_LICENSE),
+ TEXT("RTF"));
+ hGlob = LoadResource(GetModuleHandleA(NULL), hRsrc);
+ szTxt = (LPSTR)LockResource(hGlob);
+
+ SendMessageA(hRich, WM_SETTEXT, 0, (LPARAM)szTxt);
+ SetDlgItemText(hDlg, IDC_ABOUTAPP, apxLoadResource(IDS_APPFULLNAME, 0));
+ ptScroll.x = 0;
+ ptScroll.y = 0;
+ return TRUE;
+ break;
+ case WM_COMMAND:
+ if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) {
+ EndDialog(hDlg, LOWORD(wParam));
+ return TRUE;
+ }
+ else if (LOWORD(wParam) == IAB_SYSINF)
+ __apxShellAbout(hDlg);
+ break;
+ case WM_MOUSEWHEEL:
+ {
+ int nScroll, nLines;
+ if ((SHORT)HIWORD(wParam) < 0)
+ nScroll = _st_sys_gui.nWhellScroll;
+ else
+ nScroll = _st_sys_gui.nWhellScroll * (-1);
+ ptScroll.y += (nScroll * 11);
+ if (ptScroll.y < 0)
+ ptScroll.y = 0;
+ nLines = (int)SendMessage(hRich, EM_GETLINECOUNT, 0, 0) + 1;
+ if (ptScroll.y / 11 > nLines)
+ ptScroll.y = nLines * 11;
+ SendMessage(hRich, EM_SETSCROLLPOS, 0, (LPARAM)&ptScroll);
+ }
+ break;
+
+ }
+ return FALSE;
+}
+
+void apxAboutBox(HWND hWnd)
+{
+ DialogBox(_st_sys_gui.hInstance,
+ MAKEINTRESOURCE(IDD_ABOUTBOX),
+ hWnd,
+ (DLGPROC)__apxAboutDlgProc);
+}
+
+static DWORD WINAPI __apxProgressWorkerThread(LPVOID lpParameter)
+{
+ LPPROGRESS_DLGPARAM lpDlgParam = (LPPROGRESS_DLGPARAM)lpParameter;
+
+ (*lpDlgParam->fnCb)(NULL, WM_USER+1, 0, (LPARAM)lpDlgParam->hDialog);
+ CloseHandle(lpDlgParam->hThread);
+ ExitThread(0);
+ return 0;
+}
+
+static LRESULT CALLBACK __apxProgressDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ LPPROGRESS_DLGPARAM lpDlgParam;
+ DWORD dwId;
+ switch (uMsg) {
+ case WM_INITDIALOG:
+ lpDlgParam = (LPPROGRESS_DLGPARAM)lParam;
+ apxCenterWindow(hDlg, _st_sys_gui.hMainWnd);
+ if (lpDlgParam && lpDlgParam->szHead && lpDlgParam->szText) {
+ SetDlgItemText(hDlg, IDDP_HEAD, lpDlgParam->szHead);
+ SetDlgItemTextW(hDlg, IDDP_TEXT, lpDlgParam->szText);
+ }
+ lpDlgParam->hDialog = hDlg;
+ lpDlgParam->hThread = CreateThread(NULL, 0, __apxProgressWorkerThread,
+ lpDlgParam, 0, &dwId);
+ break;
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ EndDialog(hDlg, LOWORD(wParam));
+ return TRUE;
+ break;
+ }
+ break;
+ case WM_USER+1:
+ SendMessage(GetDlgItem(hDlg, IDDP_PROGRESS), PBM_STEPIT, 0, 0);
+ break;
+ }
+ return FALSE;
+}
+
+int apxProgressBox(HWND hWnd, LPCTSTR szHeader,
+ LPCWSTR szText,
+ LPAPXFNCALLBACK fnProgressCallback,
+ LPVOID cbData)
+{
+ PROGRESS_DLGPARAM dlgParam;
+ int rv;
+
+ dlgParam.szHead = szHeader;
+ dlgParam.szText = szText;
+ dlgParam.cbData = cbData;
+ dlgParam.fnCb = fnProgressCallback;
+ dlgParam.hThread = NULL;
+ rv = (int)DialogBoxParam(_st_sys_gui.hInstance,
+ MAKEINTRESOURCE(IDD_PROGRESS),
+ hWnd,
+ (DLGPROC)__apxProgressDlgProc,
+ (LPARAM)&dlgParam);
+ return rv;
+}
+
+BOOL apxYesNoMessage(LPCTSTR szTitle, LPCTSTR szMessage, BOOL bStop)
+{
+ UINT uType = MB_YESNO;
+ int rv;
+
+ if (bStop)
+ uType |= MB_DEFBUTTON2 | MB_ICONEXCLAMATION;
+ else
+ uType |= MB_DEFBUTTON1 | MB_ICONQUESTION;
+
+ rv = MessageBox(_st_sys_gui.hMainWnd, szMessage, szTitle, uType);
+
+ return (rv == IDYES);
+}
+
+LPWSTR apxGetDlgTextW(APXHANDLE hPool, HWND hDlg, int nIDDlgItem)
+{
+ DWORD l, n;
+ LPWSTR szT = NULL;
+
+ l = (DWORD)SendMessageW(GetDlgItem(hDlg, nIDDlgItem), WM_GETTEXTLENGTH, 0, 0);
+ if (l > 0) {
+ szT = apxPoolAlloc(hPool, (l + 1) * sizeof(WCHAR));
+ n = GetDlgItemTextW(hDlg, nIDDlgItem, szT, l + 1);
+ if (n == 0) {
+ apxFree(szT);
+ szT = NULL;
+ }
+ }
+ return szT;
+}
+
+LPSTR apxGetDlgTextA(APXHANDLE hPool, HWND hDlg, int nIDDlgItem)
+{
+ DWORD l, n;
+ LPSTR szT = NULL;
+
+ l = (DWORD)SendMessageA(GetDlgItem(hDlg, nIDDlgItem), WM_GETTEXTLENGTH, 0, 0);
+ if (l > 0) {
+ szT = apxPoolAlloc(hPool, (l + 1));
+ n = GetDlgItemTextA(hDlg, nIDDlgItem, szT, l + 1);
+ if (n == 0) {
+ apxFree(szT);
+ szT = NULL;
+ }
+ }
+ return szT;
+}
+
+/* Browse for folder dialog.
+ */
+LPSTR apxBrowseForFolderA(HWND hWnd, LPCSTR szTitle, LPCSTR szName)
+{
+ BROWSEINFOA bi;
+ LPITEMIDLIST il, ir;
+ LPMALLOC pMalloc;
+ CHAR szPath[MAX_PATH+1];
+ LPSTR rv = NULL;
+
+ AplZeroMemory(&bi, sizeof(BROWSEINFOW));
+ SHGetSpecialFolderLocation(hWnd, CSIDL_DRIVES, &il);
+ bi.lpszTitle = szTitle;
+ bi.pszDisplayName = szPath;
+ bi.hwndOwner = hWnd;
+ bi.ulFlags = BIF_EDITBOX;
+ bi.lpfn = NULL;
+ bi.lParam = 0;
+ bi.iImage = 0;
+ bi.pidlRoot = il;
+
+ if ((ir = SHBrowseForFolderA(&bi)) != NULL) {
+ if (SHGetPathFromIDListA(ir, szPath))
+ rv = apxStrdupA(szPath);
+ }
+ if (SHGetMalloc(&pMalloc)) {
+ pMalloc->lpVtbl->Free(pMalloc, il);
+ pMalloc->lpVtbl->Release(pMalloc);
+ }
+
+ return rv;
+}
+
+LPWSTR apxBrowseForFolderW(HWND hWnd, LPCWSTR szTitle, LPCWSTR szName)
+{
+ BROWSEINFOW bi;
+ LPITEMIDLIST il, ir;
+ LPMALLOC pMalloc;
+ WCHAR szPath[MAX_PATH+1];
+ LPWSTR rv = NULL;
+
+ AplZeroMemory(&bi, sizeof(BROWSEINFOW));
+ SHGetSpecialFolderLocation(hWnd, CSIDL_DRIVES, &il);
+ bi.lpszTitle = szTitle;
+ bi.pszDisplayName = szPath;
+ bi.hwndOwner = hWnd;
+ bi.ulFlags = BIF_EDITBOX;
+ bi.lpfn = NULL;
+ bi.lParam = 0;
+ bi.iImage = 0;
+ bi.pidlRoot = il;
+
+ if ((ir = SHBrowseForFolderW(&bi)) != NULL) {
+ if (SHGetPathFromIDListW(ir, szPath))
+ rv = apxStrdupW(szPath);
+ }
+ if (SHGetMalloc(&pMalloc)) {
+ pMalloc->lpVtbl->Free(pMalloc, il);
+ pMalloc->lpVtbl->Release(pMalloc);
+ }
+
+ return rv;
+}
+
+LPSTR apxGetFileNameA(HWND hWnd, LPCSTR szTitle, LPCSTR szFilter,
+ LPCSTR szDefExt, LPCSTR szDefPath, BOOL bOpenOrSave,
+ LPDWORD lpdwFindex)
+{
+ OPENFILENAMEA lpOf;
+ CHAR szFile[SIZ_BUFLEN];
+ BOOL rv;
+
+ AplZeroMemory(&lpOf, sizeof(OPENFILENAMEA));
+ szFile[0] = '\0';
+ lpOf.lStructSize = sizeof(OPENFILENAMEA);
+ lpOf.hwndOwner = hWnd;
+ lpOf.hInstance = _st_sys_gui.hInstance;
+ lpOf.lpstrTitle = szTitle;
+ lpOf.lpstrFilter = szFilter;
+ lpOf.lpstrDefExt = szDefExt;
+ lpOf.lpstrInitialDir = szDefPath;
+ lpOf.lpstrFile = szFile;
+ lpOf.nMaxFile = SIZ_BUFMAX;
+ lpOf.Flags = OFN_LONGNAMES | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
+
+ if (bOpenOrSave)
+ rv = GetOpenFileNameA(&lpOf);
+ else
+ rv = GetSaveFileNameA(&lpOf);
+
+ if (rv) {
+ if (lpdwFindex)
+ *lpdwFindex = lpOf.nFilterIndex;
+ return apxStrdupA(szFile);
+ }
+ else
+ return NULL;
+}
+
+LPWSTR apxGetFileNameW(HWND hWnd, LPCWSTR szTitle, LPCWSTR szFilter,
+ LPCWSTR szDefExt, LPCWSTR szDefPath, BOOL bOpenOrSave,
+ LPDWORD lpdwFindex)
+{
+ OPENFILENAMEW lpOf;
+ WCHAR szFile[SIZ_BUFLEN];
+ BOOL rv;
+
+ AplZeroMemory(&lpOf, sizeof(OPENFILENAMEW));
+ szFile[0] = L'\0';
+ lpOf.lStructSize = sizeof(OPENFILENAMEW);
+ lpOf.hwndOwner = hWnd;
+ lpOf.hInstance = _st_sys_gui.hInstance;
+ lpOf.lpstrTitle = szTitle;
+ lpOf.lpstrFilter = szFilter;
+ lpOf.lpstrDefExt = szDefExt;
+ lpOf.lpstrInitialDir = szDefPath;
+ lpOf.lpstrFile = szFile;
+ lpOf.nMaxFile = SIZ_BUFMAX;
+ lpOf.Flags = OFN_LONGNAMES | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
+
+ if (bOpenOrSave)
+ rv = GetOpenFileNameW(&lpOf);
+ else
+ rv = GetSaveFileNameW(&lpOf);
+
+ if (rv) {
+ if (lpdwFindex)
+ *lpdwFindex = lpOf.nFilterIndex;
+ return apxStrdupW(szFile);
+ }
+ else
+ return NULL;
+}
+
+static __apxSelectUserDlgResize(HWND hDlg, INT nWidth, INT nHeight)
+{
+ /* Combo box */
+ MoveWindow(GetDlgItem(hDlg, IDSU_COMBO),
+ 70, 10,
+ nWidth - 70,
+ 120,
+ TRUE);
+ /* List Window */
+ MoveWindow(GetDlgItem(hDlg, IDSU_LIST),
+ 0, 36,
+ nWidth,
+ nHeight - 74,
+ TRUE);
+
+ /* Name label */
+ MoveWindow(GetDlgItem(hDlg, IDSU_SELNAME),
+ 16,
+ nHeight - 30,
+ 50,
+ 24,
+ TRUE);
+
+ /* Edit Box */
+ MoveWindow(GetDlgItem(hDlg, IDSU_SELECTED),
+ 70,
+ nHeight - 32,
+ nWidth - 300,
+ 24,
+ TRUE);
+
+ /* OK Button */
+ MoveWindow(GetDlgItem(hDlg, IDOK),
+ nWidth - 200,
+ nHeight - 32,
+ 80,
+ 24,
+ TRUE);
+
+ /* Cancel Button */
+ MoveWindow(GetDlgItem(hDlg, IDCANCEL),
+ nWidth - 110,
+ nHeight - 32,
+ 80,
+ 24,
+ TRUE);
+
+
+}
+
+static LRESULT CALLBACK
+__apxSelectUserCreateLvSubclass(HWND hWnd, UINT uMsg, WPARAM wParam,
+ LPARAM lParam)
+{
+ static POINTS mouseClick;
+ int iS;
+ LVHITTESTINFO iHit;
+ switch (uMsg) {
+ case WM_LBUTTONDBLCLK:
+ /* Call the original window proc */
+ CallWindowProc(_st_sel_users_lvm, hWnd, uMsg, wParam, lParam);
+ mouseClick = MAKEPOINTS(lParam);
+ iHit.pt.x = mouseClick.x;
+ iHit.pt.y = mouseClick.y;
+ iS = ListView_HitTest(hWnd, &iHit);
+ if (iS >= 0) {
+ DWORD i;
+ WCHAR szUser[SIZ_RESLEN] = L"";
+ LPWSTR szP;
+ HWND hCombo;
+ HWND hDlg = GetParent(hWnd);
+ hCombo = GetDlgItem(hDlg, IDSU_COMBO);
+ if ((i = ComboBox_GetCurSel(hCombo)) == 0) {
+ lstrcpyW(szUser, L".\\");
+ }
+ else {
+ COMBOBOXEXITEMW cbEi;
+ cbEi.mask = CBEIF_TEXT;
+ cbEi.iItem = i;
+ cbEi.cchTextMax = SIZ_RESMAX;
+ cbEi.pszText = szUser;
+ SendMessage(hCombo, CBEM_GETITEM, 0, (LPARAM)&cbEi);
+ lstrcatW(szUser, L"\\");
+ }
+ szP = &szUser[lstrlenW(szUser)];
+ ListView_GetItemTextW(hWnd, iS, 0, szP, SIZ_RESMAX);
+ if (*szP) {
+ SetDlgItemTextW(hDlg, IDSU_SELECTED, szUser);
+ }
+ }
+ return TRUE;
+ break;
+ }
+ return CallWindowProc(_st_sel_users_lvm, hWnd, uMsg, wParam, lParam);
+}
+
+#define SUMIN_WIDTH 600
+#define SUMIN_HEIGHT 200
+
+static void __apxSelectUserCreateLv(HWND hDlg)
+{
+ DWORD i;
+ LV_COLUMN lvC;
+ HBITMAP hBmp;
+
+ HWND hList = GetDlgItem(hDlg, IDSU_LIST);
+
+ lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
+ for (i = 0; i < NUMLVUSERS; i++) {
+ lvC.iSubItem = i;
+ lvC.cx = lvUsers[i].iWidth;
+ lvC.pszText = lvUsers[i].szLabel;
+ lvC.fmt = lvUsers[i].iFmt;
+ ListView_InsertColumn(hList, i, &lvC );
+ }
+#ifdef LVS_EX_FULLROWSELECT
+ ListView_SetExtendedListViewStyleEx(hList, 0,
+ LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);
+#endif
+ _st_sel_users_il = ImageList_Create(16, 16, ILC_COLOR4, 0, 16);
+ hBmp = LoadImage(GetModuleHandleA(NULL), MAKEINTRESOURCE(IDB_SUSERS),
+ IMAGE_BITMAP, 0, 0, LR_LOADTRANSPARENT);
+
+ ImageList_Add(_st_sel_users_il, hBmp, NULL);
+ DeleteObject(hBmp);
+
+ ListView_SetImageList(hList, _st_sel_users_il, LVSIL_SMALL);
+ _st_sel_users_lvm = (WNDPROC)((SIZE_T)SetWindowLong(hList, GWLP_WNDPROC,
+ (LONG)((SIZE_T)__apxSelectUserCreateLvSubclass)));
+
+}
+
+static void __apxSelectUserPopulate(HWND hDlg, LPCWSTR szComputer)
+{
+ PNET_DISPLAY_USER pBuff, p;
+ INT row = 0x7FFFFFFF;
+ DWORD res, dwRec, i = 0;
+
+ HWND hList = GetDlgItem(hDlg, IDSU_LIST);
+
+ ListView_DeleteAllItems(hList);
+
+ do {
+ res = NetQueryDisplayInformation(szComputer, 1, i, 1000, MAX_PREFERRED_LENGTH,
+ &dwRec, &pBuff);
+ if ((res == ERROR_SUCCESS) || (res == ERROR_MORE_DATA)) {
+ p = pBuff;
+ for (;dwRec > 0; dwRec--) {
+ LV_ITEMW lvI;
+ AplZeroMemory(&lvI, sizeof(LV_ITEMW));
+ lvI.mask = LVIF_IMAGE | LVIF_TEXT;
+ lvI.iItem = 0x7FFFFFFF;
+ lvI.pszText = p->usri1_name;
+ if (p->usri1_flags & UF_ACCOUNTDISABLE)
+ lvI.iImage = 5;
+ else
+ lvI.iImage = 4;
+ row = ListView_InsertItemW(hList, &lvI);
+ if (row != -1) {
+ if (p->usri1_full_name) {
+ ListView_SetItemTextW(hList, row, 1,
+ p->usri1_full_name);
+ }
+ if (p->usri1_comment) {
+ ListView_SetItemTextW(hList, row, 2,
+ p->usri1_comment);
+ }
+ }
+ i = p->usri1_next_index;
+ p++;
+ }
+ NetApiBufferFree(pBuff);
+ }
+ } while (res == ERROR_MORE_DATA);
+
+}
+
+static void __apxSelectUserCreateCbex(HWND hDlg)
+{
+ COMBOBOXEXITEMW cbEi;
+ LPBYTE lpNetBuf;
+ LPWKSTA_INFO_100 lpWksta;
+ DWORD res;
+ HWND hCombo = GetDlgItem(hDlg, IDSU_COMBO);
+
+#ifndef _UNICODE
+ SendMessageW(hCombo, CBEM_SETUNICODEFORMAT, TRUE, 0);
+#endif
+
+ cbEi.mask = CBEIF_TEXT | CBEIF_INDENT |
+ CBEIF_IMAGE | CBEIF_SELECTEDIMAGE;
+
+ res = NetWkstaGetInfo(NULL, 101, (LPBYTE *)&lpWksta);
+ if (res != ERROR_SUCCESS) {
+ EnableWindow(hCombo, FALSE);
+ return;
+ }
+ /* add localhost computer */
+ cbEi.iItem = 0;
+ cbEi.pszText = (LPWSTR)lpWksta->wki100_computername;
+ cbEi.iIndent = 0;
+ cbEi.iImage = 1;
+ cbEi.iSelectedImage = 1;
+ SendMessageW(hCombo, CBEM_INSERTITEMW, 0, (LPARAM)&cbEi);
+ NetApiBufferFree(lpWksta);
+
+ ComboBox_SetCurSel(hCombo, 0);
+ res = NetGetDCName(NULL, NULL, &lpNetBuf);
+ if ((res == ERROR_SUCCESS) || (res == ERROR_MORE_DATA)) {
+
+ cbEi.iItem = 1;
+ cbEi.pszText = ((LPWSTR)lpNetBuf) + 2;
+ cbEi.iIndent = 0;
+ cbEi.iImage = 0;
+ cbEi.iSelectedImage = 0;
+ SendMessageW(hCombo, CBEM_INSERTITEMW, 0, (LPARAM)&cbEi);
+ EnableWindow(hCombo, TRUE);
+ NetApiBufferFree(lpNetBuf);
+ }
+ else
+ EnableWindow(hCombo, FALSE);
+
+ SendMessageW(hCombo, CBEM_SETIMAGELIST, 0, (LPARAM)_st_sel_users_il);
+}
+
+static LRESULT CALLBACK __apxSelectUserDlgProc(HWND hDlg, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ static HWND hList;
+ static LPWSTR lpUser;
+ RECT r, *l;
+
+ switch (uMsg) {
+ case WM_INITDIALOG:
+ /* Set the application icon */
+ SetClassLong(hDlg, GCLP_HICON,
+ (LONG)(SIZE_T)LoadIcon(_st_sys_gui.hInstance,
+ MAKEINTRESOURCE(IDI_MAINICON)));
+ apxCenterWindow(hDlg, _st_sys_gui.hMainWnd);
+ hList = GetDlgItem(hDlg, IDSU_LIST);
+ __apxSelectUserCreateLv(hDlg);
+ __apxSelectUserCreateCbex(hDlg);
+ GetClientRect(hDlg, &r);
+ /* Resize the controls */
+ __apxSelectUserDlgResize(hDlg, r.right - r.left,
+ r.bottom - r.top);
+ lpUser = (LPWSTR)lParam;
+ __apxSelectUserPopulate(hDlg, NULL);
+ return TRUE;
+ break;
+ case WM_SIZING:
+ l = (LPRECT)lParam;
+ /* limit the window size */
+ switch (wParam) {
+ case WMSZ_BOTTOM:
+ case WMSZ_BOTTOMRIGHT:
+ if ((l->bottom - l->top) < SUMIN_HEIGHT)
+ l->bottom = l->top + SUMIN_HEIGHT;
+ if ((l->right - l->left) < SUMIN_WIDTH)
+ l->right = l->left + SUMIN_WIDTH;
+ break;
+ case WMSZ_TOPLEFT:
+ if ((l->bottom - l->top) < SUMIN_HEIGHT)
+ l->top = l->bottom - SUMIN_HEIGHT;
+ if ((l->right - l->left) < SUMIN_WIDTH)
+ l->left = l->right - SUMIN_WIDTH;
+ break;
+ case WMSZ_TOP:
+ case WMSZ_RIGHT:
+ case WMSZ_TOPRIGHT:
+ if ((l->bottom - l->top) < SUMIN_HEIGHT)
+ l->top = l->bottom - SUMIN_HEIGHT;
+ if ((l->right - l->left) < SUMIN_WIDTH)
+ l->right = l->left + SUMIN_WIDTH;
+ break;
+ case WMSZ_BOTTOMLEFT:
+ case WMSZ_LEFT:
+ if ((l->bottom - l->top) < SUMIN_HEIGHT)
+ l->bottom = l->top + SUMIN_HEIGHT;
+ if ((l->right - l->left) < SUMIN_WIDTH)
+ l->left = l->right - SUMIN_WIDTH;
+ break;
+ }
+ break;
+ case WM_SIZE:
+ __apxSelectUserDlgResize(hDlg, LOWORD(lParam),
+ HIWORD(lParam));
+ GetClientRect(hDlg, &r);
+ InvalidateRect(hDlg, &r, FALSE);
+ break;
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ EndDialog(hDlg, LOWORD(wParam));
+ return TRUE;
+ case IDCANCEL:
+ /* Clear the user name buffer */
+ *lpUser = L'\0';
+ EndDialog(hDlg, LOWORD(wParam));
+ return TRUE;
+ break;
+ case IDSU_SELECTED:
+ if (HIWORD(wParam) == EN_CHANGE) {
+ /* enable OK button if there is a user */
+ GetDlgItemTextW(hDlg, IDSU_SELECTED, lpUser, SIZ_RESMAX);
+ if (lstrlenW(lpUser))
+ Button_Enable(GetDlgItem(hDlg, IDOK), TRUE);
+ else
+ Button_Enable(GetDlgItem(hDlg, IDOK), FALSE);
+ }
+ break;
+ case IDSU_COMBO:
+ if (HIWORD(wParam) == CBN_SELCHANGE) {
+ COMBOBOXEXITEMW cbEi;
+ DWORD i;
+ WCHAR szServer[SIZ_RESLEN] = L"\\\\";
+ HWND hCombo = GetDlgItem(hDlg, IDSU_COMBO);
+ if ((i = ComboBox_GetCurSel(hCombo)) >= 0) {
+ cbEi.mask = CBEIF_TEXT;
+ cbEi.iItem = i;
+ cbEi.cchTextMax = SIZ_RESMAX;
+ cbEi.pszText = &szServer[2];
+ SendMessageW(hCombo, CBEM_GETITEM, 0, (LPARAM)&cbEi);
+ }
+ if (szServer[2])
+ __apxSelectUserPopulate(hDlg, szServer);
+ }
+ break;
+
+ }
+ break;
+ case WM_MOUSEWHEEL:
+ {
+ int nScroll;
+ if ((SHORT)HIWORD(wParam) < 0)
+ nScroll = _st_sys_gui.nWhellScroll;
+ else
+ nScroll = _st_sys_gui.nWhellScroll * (-1);
+ }
+ break;
+
+ }
+ return FALSE;
+}
+
+
+LPCWSTR apxDlgSelectUser(HWND hWnd, LPWSTR szUser)
+{
+ szUser[0] = L'\0';
+
+ DialogBoxParam(_st_sys_gui.hInstance,
+ MAKEINTRESOURCE(IDD_SELUSER),
+ hWnd,
+ (DLGPROC)__apxSelectUserDlgProc,
+ (LPARAM)szUser);
+ if (_st_sel_users_il)
+ ImageList_Destroy(_st_sel_users_il);
+ _st_sel_users_il = NULL;
+ if (szUser[0] != '\0')
+ return szUser;
+ else
+ return NULL;
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/handles.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/handles.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/handles.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,685 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apxwin.h"
+#include "private.h"
+
+#define ALLOCBLOCK_INVALID 0xdeadbeef
+
+typedef struct APXPOOL APXPOOL;
+typedef APXPOOL* LPAPXPOOL;
+
+typedef struct ALLOCBLOCK {
+ DWORD dwSize;
+ APXHANDLE lpPool;
+ APXMEMWORD lpAlign;
+} ALLOCBLOCK, *LPALLOCBLOCK;
+
+struct APXPOOL {
+ TAILQ_HEAD(_lHandles, stAPXHANDLE) lHandles;
+ TAILQ_HEAD(_lPools, stAPXHANDLE) lPools;
+};
+
+static SYSTEM_INFO _st_sys_info;
+static APXHANDLE _st_sys_pool = NULL;
+static int _st_sys_init = 0;
+static LPVOID _st_sys_page = NULL;
+LPWSTR *_st_sys_argvw = NULL;
+int _st_sys_argc = 0;
+
+#ifdef _DEBUG
+static INT _heap_count = 0;
+static INT _heap_alloc_count = 0;
+static INT _heap_realloc_count = 0;
+
+HANDLE HeapCREATE(DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize)
+{
+ _heap_count++;
+ return HeapCreate(flOptions, dwInitialSize, dwMaximumSize);
+}
+
+BOOL HeapDESTROY(HANDLE hHeap)
+{
+ _heap_count--;
+ return HeapDestroy(hHeap);
+}
+
+
+LPVOID HeapALLOC(HANDLE hHeap, DWORD dwFlags, SIZE_T nSize)
+{
+ _heap_alloc_count++;
+ return HeapAlloc(hHeap, dwFlags, nSize);
+}
+
+BOOL HeapFREE(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem)
+{
+ _heap_alloc_count--;
+ return HeapFree(hHeap, dwFlags, lpMem);
+}
+
+LPVOID HeapREALLOC(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem, SIZE_T dwBytes)
+{
+
+ _heap_realloc_count++;
+ return HeapReAlloc(hHeap, dwFlags, lpMem, dwBytes);
+}
+#endif
+
+static LPVOID __apxPoolAllocCore(APXHANDLE hPool,
+ DWORD dwSize, DWORD dwOptions)
+{
+ DWORD dwPhysicalSize;
+ LPALLOCBLOCK lpBlock;
+
+ if (!hPool)
+ hPool = _st_sys_pool;
+ dwPhysicalSize = APX_ALIGN_DEFAULT(dwSize + sizeof(ALLOCBLOCK));
+ lpBlock = HeapALLOC(hPool->hHeap, dwOptions, dwPhysicalSize);
+ lpBlock->dwSize = dwPhysicalSize;
+ lpBlock->lpPool = hPool;
+
+ return ((char *)lpBlock + sizeof(ALLOCBLOCK));
+}
+
+static LPVOID __apxPoolReallocCore(APXHANDLE hPool, LPVOID lpMem,
+ DWORD dwSize, DWORD dwOptions)
+{
+ DWORD dwPhysicalSize;
+ LPALLOCBLOCK lpBlock;
+ LPALLOCBLOCK lpOrg;
+
+ if (!lpMem)
+ return __apxPoolAllocCore(hPool, dwSize, dwOptions);
+ lpOrg = (LPALLOCBLOCK)((char *)lpMem - sizeof(ALLOCBLOCK));
+ if (!hPool)
+ hPool = _st_sys_pool;
+ /* Trying to realloc something that isn't valid */
+ if (lpOrg->lpPool == APXHANDLE_INVALID ||
+ lpOrg->lpPool != hPool)
+ return NULL;
+ dwPhysicalSize = APX_ALIGN_DEFAULT(dwSize + sizeof(ALLOCBLOCK));
+ lpBlock = HeapREALLOC(hPool->hHeap, dwOptions, lpOrg, dwPhysicalSize);
+ lpBlock->dwSize = dwPhysicalSize;
+ lpBlock->lpPool = hPool;
+
+ return ((char *)lpBlock + sizeof(ALLOCBLOCK));
+}
+
+static void __apxPoolFreeCore(LPVOID lpMem)
+{
+ APXHANDLE hPool;
+ LPALLOCBLOCK lpBlock = (LPALLOCBLOCK)((char *)lpMem - sizeof(ALLOCBLOCK));
+
+ if (lpBlock->lpPool != APXHANDLE_INVALID) {
+ hPool = lpBlock->lpPool;
+ lpBlock->lpPool = APXHANDLE_INVALID;
+ }
+ else
+ return;
+ HeapFREE(hPool->hHeap, 0, lpBlock);
+}
+/*
+ *
+ */
+static DWORD WINAPI __apxHandleEventThread(LPVOID lpParameter)
+{
+ APXHANDLE hHandle = (APXHANDLE)lpParameter;
+ DWORD rv = 0;
+ while (hHandle->dwType != APXHANDLE_TYPE_INVALID) {
+ DWORD dwState;
+ dwState = WaitForSingleObject(hHandle->hEventHandle, INFINITE);
+ /* the flags can be changed to invalid meaning we are killing
+ * this event.
+ */
+ if (dwState == WAIT_OBJECT_0 &&
+ hHandle->dwType != APXHANDLE_TYPE_INVALID) {
+ if (hHandle->uMsg && (hHandle->wParam || hHandle->lParam)) {
+ APXCALLHOOK *lpCall;
+ rv = (*hHandle->fnCallback)(hHandle, hHandle->uMsg,
+ hHandle->wParam, hHandle->lParam);
+ TAILQ_FOREACH(lpCall, &hHandle->lCallbacks, queue) {
+ (*lpCall->fnCallback)(hHandle, hHandle->uMsg,
+ hHandle->wParam, hHandle->lParam);
+ }
+ hHandle->uMsg = 0;
+ if (!rv)
+ break;
+ }
+ ResetEvent(hHandle->hEventHandle);
+ SwitchToThread();
+ }
+ else
+ break;
+ }
+ ResetEvent(hHandle->hEventHandle);
+ /* This will rise the Thread waiting function */
+ return 0;
+}
+
+static BOOL __apxPoolCallback(APXHANDLE hObject, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ LPAPXPOOL lpPool;
+ APXHANDLE hCur;
+ if (hObject->dwType != APXHANDLE_TYPE_POOL)
+ return FALSE;
+ lpPool = APXHANDLE_DATA(hObject);
+
+ /* recurse the subpools */
+ TAILQ_FOREACH(hCur, &lpPool->lPools, queue) {
+ __apxPoolCallback(hCur, uMsg, 0, 0);
+ }
+ /* call the handles callback */
+ for(hCur = TAILQ_FIRST(&lpPool->lHandles) ;
+ hCur != NULL ;
+ hCur = TAILQ_FIRST(&lpPool->lHandles)) {
+ apxCloseHandle(hCur);
+ }
+ /* if we are closing this pool destroy the private Heap */
+ if (uMsg == WM_CLOSE) {
+ if (hObject->dwFlags & APXHANDLE_HAS_HEAP)
+ HeapDESTROY(hObject->hHeap);
+ hObject->dwSize = 0;
+ }
+ else if (uMsg == WM_CLEAR)
+ hObject->dwSize = 0;
+
+ return TRUE;
+}
+
+static BOOL __apxHandleCallback(APXHANDLE hObject, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ BOOL rv = FALSE;
+ if (hObject->dwType == APXHANDLE_TYPE_INVALID)
+ return FALSE;
+ /* Default handler handles only close event */
+ if (uMsg != WM_CLOSE)
+ return FALSE;
+ if (hObject->dwType == APXHANDLE_TYPE_WINHANDLE &&
+ !(IS_INVALID_HANDLE(hObject->uData.hWinHandle))) {
+ rv = CloseHandle(hObject->uData.hWinHandle);
+ hObject->uData.hWinHandle = NULL;
+ }
+ /* Invalidate the handle */
+ hObject->dwType = APXHANDLE_TYPE_INVALID;
+
+ if (hObject->dwFlags & APXHANDLE_HAS_EVENT) {
+ DWORD dwState;
+ /* Signal the EventThread to exit */
+ SetEvent(hObject->hEventHandle);
+ /* Wait for EventThread to Exit */
+ dwState = WaitForSingleObject(hObject->hEventThread, 1000);
+ SAFE_CLOSE_HANDLE(hObject->hEventHandle);
+ if (dwState == WAIT_TIMEOUT)
+ TerminateThread(hObject->hEventThread, 0);
+ SAFE_CLOSE_HANDLE(hObject->hEventThread);
+ /* Reset the evant flag */
+ hObject->dwFlags &= ~APXHANDLE_HAS_EVENT;
+ }
+ return rv;
+}
+
+static BOOL __apxCreateSystemPool()
+{
+ LPAPXPOOL lpPool;
+ HANDLE hHeap;
+
+ GetSystemInfo(&_st_sys_info);
+ apxGetOsLevel();
+ /* First create the shared data segment */
+ _st_sys_page = VirtualAlloc(NULL, _st_sys_info.dwAllocationGranularity,
+ MEM_RESERVE, PAGE_NOACCESS);
+ if (!_st_sys_page)
+ return FALSE;
+ _st_sys_page = VirtualAlloc(_st_sys_page, _st_sys_info.dwAllocationGranularity,
+ MEM_COMMIT, PAGE_READWRITE);
+
+ /* Create the main Heap */
+ hHeap = HeapCREATE(0, _st_sys_info.dwAllocationGranularity, 0);
+ _st_sys_pool = HeapALLOC(hHeap, HEAP_ZERO_MEMORY,
+ APX_ALIGN_DEFAULT(APXHANDLE_SZ + sizeof(APXPOOL)));
+ _st_sys_pool->hHeap = hHeap;
+ _st_sys_pool->dwType = APXHANDLE_TYPE_INVALID;
+ if (IS_INVALID_HANDLE(_st_sys_pool->hHeap))
+ return FALSE;
+ _st_sys_pool->fnCallback = __apxPoolCallback;
+ lpPool = APXHANDLE_DATA(_st_sys_pool);
+ /* Initialize the pool and object lists */
+ TAILQ_INIT(&lpPool->lHandles);
+ TAILQ_INIT(&lpPool->lPools);
+ _st_sys_pool->dwType = APXHANDLE_TYPE_POOL;
+
+ /** TODO: For each unsupported function make a surrogate */
+ _st_sys_argvw = CommandLineToArgvW(GetCommandLineW(), &_st_sys_argc);
+
+ return TRUE;
+}
+
+BOOL
+apxHandleManagerInitialize()
+{
+ BOOL rv;
+ if (_st_sys_init++)
+ return TRUE;
+ rv = __apxCreateSystemPool();
+
+ return rv;
+}
+
+BOOL
+apxHandleManagerDestroy()
+{
+ HANDLE hHeap;
+
+ if (--_st_sys_init == 0) {
+ hHeap = _st_sys_pool->hHeap;
+ apxCloseHandle(_st_sys_pool);
+ /* Destroy the main Heap */
+ HeapDESTROY(hHeap);
+ _st_sys_pool = NULL;
+ VirtualFree(_st_sys_page, 0, MEM_RELEASE);
+ GlobalFree(_st_sys_argvw);
+ _st_sys_argvw = NULL;
+ _st_sys_argc = 0;
+#ifdef _DEBUG
+ apxLogWrite(APXLOG_MARK_DEBUG "Alloc Count %d", _heap_alloc_count);
+ apxLogWrite(APXLOG_MARK_DEBUG "Realloc Count %d", _heap_realloc_count);
+ apxLogWrite(APXLOG_MARK_DEBUG "Heap Count %d", _heap_count);
+#endif
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+APXHANDLE
+apxPoolCreate(APXHANDLE hParent, DWORD dwOptions)
+{
+ APXHANDLE hHandle;
+ LPAPXPOOL lpPool;
+ HANDLE hHeap;
+
+ if (IS_INVALID_HANDLE(hParent))
+ hParent = _st_sys_pool;
+ if (hParent->dwType != APXHANDLE_TYPE_POOL) {
+ apxLogWrite(APXLOG_MARK_ERROR "Parent Handle type is not POOL %d",
+ hParent->dwType);
+ return INVALID_HANDLE_VALUE;
+ }
+ /* Allocate the handle from the parent */
+ hHandle = __apxPoolAllocCore(hParent, APXHANDLE_SZ + sizeof(APXPOOL),
+ HEAP_ZERO_MEMORY);
+
+ if (dwOptions & APXHANDLE_HAS_HEAP) {
+ /* Create the private Heap */
+ hHeap = HeapCREATE(0, _st_sys_info.dwAllocationGranularity, 0);
+ hHandle->dwFlags |= APXHANDLE_HAS_HEAP;
+ }
+ else
+ hHeap = hParent->hHeap;
+ hHandle->hHeap = hHeap;
+ hHandle->dwType = APXHANDLE_TYPE_POOL;
+ hHandle->hPool = hParent;
+ hHandle->fnCallback = __apxPoolCallback;
+ lpPool = APXHANDLE_DATA(hHandle);
+ TAILQ_INIT(&lpPool->lHandles);
+ TAILQ_INIT(&lpPool->lPools);
+
+ /* Insert the pool to the head of parent pool */
+ lpPool = APXHANDLE_DATA(hParent);
+ APXHANDLE_SPINLOCK(hParent);
+ TAILQ_INSERT_HEAD(&lpPool->lPools, hHandle, queue);
+ ++hParent->dwSize;
+ APXHANDLE_SPINUNLOCK(hParent);
+
+ return hHandle;
+}
+
+LPVOID
+apxPoolAlloc(APXHANDLE hPool, DWORD dwSize)
+{
+ if (IS_INVALID_HANDLE(hPool) ||
+ (hPool->dwType != APXHANDLE_TYPE_POOL))
+ hPool = _st_sys_pool;
+ return __apxPoolAllocCore(hPool, dwSize, 0);
+}
+
+LPVOID
+apxPoolCalloc(APXHANDLE hPool, DWORD dwSize)
+{
+ if (IS_INVALID_HANDLE(hPool) ||
+ (hPool->dwType != APXHANDLE_TYPE_POOL))
+ hPool = _st_sys_pool;
+ return __apxPoolAllocCore(hPool, dwSize, HEAP_ZERO_MEMORY);
+}
+
+LPVOID
+apxPoolRealloc(APXHANDLE hPool, LPVOID lpMem, DWORD dwNewSize)
+{
+ if (IS_INVALID_HANDLE(hPool) ||
+ (hPool->dwType != APXHANDLE_TYPE_POOL))
+ hPool = _st_sys_pool;
+ return __apxPoolReallocCore(hPool, lpMem, dwNewSize, HEAP_ZERO_MEMORY);
+}
+
+LPVOID
+apxAlloc(DWORD dwSize)
+{
+ return __apxPoolAllocCore(_st_sys_pool, dwSize, 0);
+}
+
+LPVOID
+apxCalloc(DWORD dwSize)
+{
+ return __apxPoolAllocCore(_st_sys_pool, dwSize, HEAP_ZERO_MEMORY);
+}
+
+LPVOID
+apxRealloc(LPVOID lpMem, DWORD dwNewSize)
+{
+ return __apxPoolReallocCore(_st_sys_pool, lpMem, dwNewSize, HEAP_ZERO_MEMORY);
+}
+
+VOID
+apxFree(LPVOID lpMem)
+{
+ if (lpMem)
+ __apxPoolFreeCore(lpMem);
+
+}
+
+LPWSTR
+apxPoolWStrdupA(APXHANDLE hPool, LPCSTR szSource)
+{
+ if (szSource) {
+ LPWSTR szDest;
+ DWORD l = lstrlenA(szSource);
+ szDest = apxPoolAlloc(hPool, (l + 1) * sizeof(WCHAR));
+ AsciiToWide(szSource, szDest);
+ return szDest;
+ }
+ else
+ return NULL;
+}
+
+LPWSTR apxWStrdupA(LPCTSTR szSource)
+{
+ return apxPoolWStrdup(_st_sys_pool, szSource);
+}
+
+LPSTR
+apxPoolStrdupA(APXHANDLE hPool, LPCSTR szSource)
+{
+ if (szSource) {
+ LPSTR szDest;
+ DWORD l = lstrlenA(szSource);
+ szDest = apxPoolAlloc(hPool, l + 1);
+ lstrcpyA(szDest, szSource);
+ return szDest;
+ }
+ else
+ return NULL;
+}
+
+LPWSTR
+apxPoolStrdupW(APXHANDLE hPool, LPCWSTR szSource)
+{
+ if (szSource) {
+ LPWSTR szDest;
+ DWORD l = lstrlenW(szSource);
+ szDest = apxPoolAlloc(hPool, (l + 1) * sizeof(WCHAR));
+ lstrcpyW(szDest, szSource);
+ return szDest;
+ }
+ else
+ return NULL;
+}
+
+LPSTR
+apxStrdupA(LPCSTR szSource)
+{
+ return apxPoolStrdupA(_st_sys_pool, szSource);
+}
+
+LPWSTR
+apxStrdupW(LPCWSTR szSource)
+{
+ return apxPoolStrdupW(_st_sys_pool, szSource);
+}
+
+APXHANDLE
+apxHandleCreate(APXHANDLE hPool, DWORD dwFlags,
+ LPVOID lpData, DWORD dwDataSize,
+ LPAPXFNCALLBACK fnCallback)
+{
+ APXHANDLE hHandle;
+ LPAPXPOOL lpPool;
+
+ if (IS_INVALID_HANDLE(hPool))
+ hPool = _st_sys_pool;
+ if (hPool->dwType != APXHANDLE_TYPE_POOL) {
+ apxLogWrite(APXLOG_MARK_ERROR "Parent Handle type is not POOL %d",
+ hPool->dwType);
+ return INVALID_HANDLE_VALUE;
+ }
+ hHandle = __apxPoolAllocCore(hPool, APXHANDLE_SZ + dwDataSize,
+ HEAP_ZERO_MEMORY);
+
+ hHandle->hPool = hPool;
+ if (fnCallback)
+ hHandle->fnCallback = fnCallback;
+ else
+ hHandle->fnCallback = __apxHandleCallback;
+
+ if (dwFlags & APXHANDLE_TYPE_WINHANDLE) {
+ hHandle->dwFlags |= APXHANDLE_HAS_USERDATA;
+ hHandle->dwFlags |= APXHANDLE_TYPE_WINHANDLE;
+ hHandle->uData.hWinHandle = lpData;
+ }
+ else if (dwFlags & APXHANDLE_TYPE_LPTR) {
+ hHandle->dwFlags |= APXHANDLE_HAS_USERDATA;
+ hHandle->dwFlags |= APXHANDLE_TYPE_LPTR;
+ hHandle->uData.lpPtr = lpData;
+ }
+ else if (dwDataSize && lpData) {
+ hHandle->dwFlags |= APXHANDLE_HAS_USERDATA;
+ AplCopyMemory(APXHANDLE_DATA(hHandle), lpData, dwDataSize);
+ hHandle->dwSize = dwDataSize;
+ }
+
+ if (dwFlags & APXHANDLE_HAS_EVENT) {
+ /* Create the message event and message wathcing thread */
+ hHandle->hEventHandle = CreateEvent(NULL, TRUE, FALSE, NULL);
+ hHandle->hEventThread = CreateThread(NULL, 0, __apxHandleEventThread,
+ hHandle, 0,
+ &(hHandle->hEventThreadId));
+ if (IS_INVALID_HANDLE(hHandle->hEventThread)) {
+ SAFE_CLOSE_HANDLE(hHandle->hEventHandle);
+ }
+ else
+ hHandle->dwFlags |= APXHANDLE_HAS_EVENT;
+ }
+ TAILQ_INIT(&hHandle->lCallbacks);
+ /* Add the handle to the pool's object list */
+ lpPool = APXHANDLE_DATA(hPool);
+ APXHANDLE_SPINLOCK(hPool);
+ TAILQ_INSERT_HEAD(&lpPool->lHandles, hHandle, queue);
+ ++hPool->dwSize;
+ APXHANDLE_SPINUNLOCK(hPool);
+
+ return hHandle;
+}
+
+BOOL
+apxCloseHandle(APXHANDLE hObject)
+{
+ LPAPXPOOL lpPool;
+ APXCALLHOOK *lpCall;
+
+ if (IS_INVALID_HANDLE(hObject) || hObject->dwType == APXHANDLE_TYPE_INVALID)
+ return FALSE;
+ /* Call the user callback first */
+ (*hObject->fnCallback)(hObject, WM_CLOSE, 0, 0);
+ /* Now go through the callback chain */
+ TAILQ_FOREACH(lpCall, &hObject->lCallbacks, queue) {
+ (*lpCall->fnCallback)(hObject, WM_CLOSE, 0, 0);
+ TAILQ_REMOVE(&hObject->lCallbacks, lpCall, queue);
+ __apxPoolFreeCore(lpCall);
+ }
+
+ hObject->dwType = APXHANDLE_TYPE_INVALID;
+ if (hObject->dwFlags & APXHANDLE_HAS_EVENT) {
+ DWORD dwState;
+
+ SetEvent(hObject->hEventHandle);
+ dwState = WaitForSingleObject(hObject->hEventThread, 1000);
+ SAFE_CLOSE_HANDLE(hObject->hEventHandle);
+ if (dwState == WAIT_TIMEOUT)
+ TerminateThread(hObject->hEventThread, 0);
+ SAFE_CLOSE_HANDLE(hObject->hEventThread);
+
+ hObject->dwFlags &= ~APXHANDLE_HAS_EVENT;
+ }
+
+ /* finaly remove the object from the pool's object list */
+ if (!IS_INVALID_HANDLE(hObject->hPool)) {
+ lpPool = APXHANDLE_DATA(hObject->hPool);
+ APXHANDLE_SPINLOCK(hObject->hPool);
+ TAILQ_REMOVE(&lpPool->lHandles, hObject, queue);
+ hObject->hPool->dwSize--;
+ APXHANDLE_SPINUNLOCK(hObject->hPool);
+ __apxPoolFreeCore(hObject);
+ }
+ return TRUE;
+}
+
+LPVOID
+apxHandleGetUserData(APXHANDLE hObject)
+{
+ if (hObject->dwType == APXHANDLE_TYPE_INVALID)
+ return NULL;
+ if (hObject->dwFlags & APXHANDLE_HAS_USERDATA)
+ return APXHANDLE_DATA(hObject);
+ else
+ return hObject->uData.lpPtr;
+}
+
+LPVOID
+apxHandleSetUserData(APXHANDLE hObject, LPVOID lpData, DWORD dwDataSize)
+{
+ if (hObject->dwType == APXHANDLE_TYPE_INVALID)
+ return NULL;
+ if (hObject->dwFlags & APXHANDLE_HAS_USERDATA && hObject->dwSize > 0) {
+ AplCopyMemory(APXHANDLE_DATA(hObject), lpData,
+ MIN(hObject->dwSize, dwDataSize));
+ return APXHANDLE_DATA(hObject);
+ }
+ else {
+ LPVOID lpOrg = hObject->uData.lpPtr;
+ hObject->uData.lpPtr = lpData;
+ return lpOrg;
+ }
+}
+
+BOOL apxHandleSendMessage(APXHANDLE hObject, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ BOOL rv = TRUE;
+ APXCALLHOOK *lpCall;
+ if (hObject->dwType == APXHANDLE_TYPE_INVALID)
+ return FALSE;
+ /* Serialize requests to the callback */
+ APXHANDLE_SPINLOCK(hObject);
+ if (hObject->fnCallback)
+ rv = (*hObject->fnCallback)(hObject, uMsg, wParam, lParam);
+ TAILQ_FOREACH(lpCall, &hObject->lCallbacks, queue) {
+ (*lpCall->fnCallback)(hObject, uMsg, wParam, lParam);
+ }
+ APXHANDLE_SPINUNLOCK(hObject);
+
+ return rv;
+}
+
+BOOL apxHandlePostMessage(APXHANDLE hObject, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ if (hObject->dwType == APXHANDLE_TYPE_INVALID)
+ return FALSE;
+ if (hObject->dwFlags & APXHANDLE_HAS_EVENT) {
+ /* TODO: Create a thread message queue
+ * Right now wait while the event gets nonsignaled
+ */
+ while (WaitForSingleObject(hObject->hEventHandle, 0) == WAIT_OBJECT_0)
+ SwitchToThread();
+ APXHANDLE_SPINLOCK(hObject);
+ SuspendThread(hObject->hEventThread);
+ hObject->uMsg = uMsg;
+ hObject->wParam = wParam;
+ hObject->lParam = lParam;
+ /* Signal the event thread to call the user callback */
+ SetEvent(hObject->hEventHandle);
+ ResumeThread(hObject->hEventThread);
+ APXHANDLE_SPINUNLOCK(hObject);
+
+ return TRUE;
+ }
+ return FALSE;
+}
+
+BOOL apxHandleLock(APXHANDLE hObject, BOOL bLock)
+{
+ if (bLock)
+ APXHANDLE_SPINLOCK(hObject);
+ else
+ APXHANDLE_SPINUNLOCK(hObject);
+
+ return TRUE;
+}
+
+BOOL apxHandleAddHook(APXHANDLE hObject, DWORD dwWhere,
+ LPAPXFNCALLBACK fnCallback)
+{
+ APXCALLHOOK *lpCall;
+
+ if (hObject->dwType == APXHANDLE_TYPE_INVALID || !fnCallback)
+ return FALSE;
+ lpCall = (APXCALLHOOK *)__apxPoolAllocCore(hObject->hPool,
+ sizeof(APXCALLHOOK), 0);
+ if (!lpCall)
+ return FALSE;
+ lpCall->fnCallback = fnCallback;
+ APXHANDLE_SPINLOCK(hObject);
+ if (dwWhere == APXHANDLE_HOOK_FIRST) {
+ TAILQ_INSERT_HEAD(&hObject->lCallbacks, lpCall, queue);
+ }
+ else {
+ TAILQ_INSERT_TAIL(&hObject->lCallbacks, lpCall, queue);
+ }
+ APXHANDLE_SPINUNLOCK(hObject);
+
+ return TRUE;
+}
+
+DWORD apxHandleWait(APXHANDLE hHandle, DWORD dwMilliseconds, BOOL bKill)
+{
+ if (IS_INVALID_HANDLE(hHandle))
+ return WAIT_ABANDONED;
+ if (hHandle->dwType == APXHANDLE_TYPE_JVM)
+ return apxJavaWait(hHandle, dwMilliseconds, bKill);
+ else if (hHandle->dwType == APXHANDLE_TYPE_PROCESS)
+ return apxProcessWait(hHandle, dwMilliseconds, bKill);
+ else
+ return WAIT_ABANDONED;
+}
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/javajni.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/javajni.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/javajni.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,798 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apxwin.h"
+#include "private.h"
+
+#include <jni.h>
+
+#ifndef JNI_VERSION_1_2
+#error -------------------------------------------------------
+#error JAVA 1.1 IS NO LONGER SUPPORTED
+#error -------------------------------------------------------
+#endif
+
+#ifdef JNI_VERSION_1_4
+#define JNI_VERSION_DEFAULT JNI_VERSION_1_4
+#else
+#define JNI_VERSION_DEFAULT JNI_VERSION_1_2
+#endif
+
+/* Standard jvm.dll prototypes
+ * since only single jvm can exist per process
+ * make those global
+ */
+
+DYNOLAD_TYPE_DECLARE(JNI_GetDefaultJavaVMInitArgs, JNICALL, jint)(void *);
+static DYNLOAD_FPTR_DECLARE(JNI_GetDefaultJavaVMInitArgs) = NULL;
+
+DYNOLAD_TYPE_DECLARE(JNI_CreateJavaVM, JNICALL, jint)(JavaVM **, void **, void *);
+static DYNLOAD_FPTR_DECLARE(JNI_CreateJavaVM) = NULL;
+
+DYNOLAD_TYPE_DECLARE(JNI_GetCreatedJavaVMs, JNICALL, jint)(JavaVM **, jsize, jsize *);
+static DYNLOAD_FPTR_DECLARE(JNI_GetCreatedJavaVMs) = NULL;
+
+static HANDLE _st_sys_jvmDllHandle = NULL;
+
+#define JVM_DELETE_CLAZZ(jvm, cl) \
+ APXMACRO_BEGIN \
+ if ((jvm)->lpEnv && (jvm)->##cl.jClazz) { \
+ (*((jvm)->lpEnv))->DeleteGlobalRef((jvm)->lpEnv, (jvm)->##cl.jClazz); \
+ (jvm)->##cl.jClazz = NULL; \
+ } APXMACRO_END
+
+#define JVM_EXCEPTION_CHECK(jvm) \
+ ((*((jvm)->lpEnv))->ExceptionCheck((jvm)->lpEnv) != JNI_OK)
+
+#ifdef _DEBUG
+#define JVM_EXCEPTION_CLEAR(jvm) \
+ APXMACRO_BEGIN \
+ if ((jvm)->lpEnv) { \
+ if ((*((jvm)->lpEnv))->ExceptionCheck((jvm)->lpEnv)) { \
+ (*((jvm)->lpEnv))->ExceptionDescribe((jvm)->lpEnv); \
+ (*((jvm)->lpEnv))->ExceptionClear((jvm)->lpEnv); \
+ } \
+ } APXMACRO_END
+#else
+#define JVM_EXCEPTION_CLEAR(jvm) \
+ APXMACRO_BEGIN \
+ if ((jvm)->lpEnv) { \
+ if ((*((jvm)->lpEnv))->ExceptionCheck((jvm)->lpEnv)) { \
+ (*((jvm)->lpEnv))->ExceptionClear((jvm)->lpEnv); \
+ } \
+ } APXMACRO_END
+#endif
+
+#define JNI_LOCAL_UNREF(obj) \
+ (*(lpJava->lpEnv))->DeleteLocalRef(lpJava->lpEnv, obj)
+
+#define JNICALL_0(fName) \
+ ((*(lpJava->lpEnv))->##fName(lpJava->lpEnv))
+
+#define JNICALL_1(fName, a1) \
+ ((*(lpJava->lpEnv))->##fName(lpJava->lpEnv, (a1)))
+
+#define JNICALL_2(fName, a1, a2) \
+ ((*(lpJava->lpEnv))->##fName(lpJava->lpEnv, (a1), (a2)))
+
+#define JNICALL_3(fName, a1, a2, a3) \
+ ((*(lpJava->lpEnv))->##fName(lpJava->lpEnv, (a1), (a2), (a3)))
+
+#define JNICALL_4(fName, a1, a2, a3, a4) \
+ ((*(lpJava->lpEnv))->##fName(lpJava->lpEnv, (a1), (a2), (a3), (a4)))
+
+typedef struct APXJAVASTDCLAZZ {
+ jclass jClazz;
+ jmethodID jMethod;
+ jobject jObject;
+ jarray jArgs;
+} APXJAVASTDCLAZZ, *LPAPXJAVASTDCLAZZ;
+
+typedef struct APXJAVAVM {
+ DWORD dwOptions;
+ APXJAVASTDCLAZZ clString;
+ APXJAVASTDCLAZZ clWorker;
+ jint iVersion;
+ jsize iVmCount;
+ JNIEnv *lpEnv;
+ JavaVM *lpJvm;
+ /* JVM worker thread info */
+ HANDLE hWorkerThread;
+ DWORD iWorkerThread;
+ DWORD dwWorkerStatus;
+
+} APXJAVAVM, *LPAPXJAVAVM;
+
+#define JAVA_CLASSPATH "-Djava.class.path="
+#define JAVA_CLASSSTRING "java/lang/String"
+
+static __inline BOOL __apxJvmAttach(LPAPXJAVAVM lpJava)
+{
+ jint _iStatus = (*(lpJava->lpJvm))->GetEnv(lpJava->lpJvm,
+ (void **)&(lpJava->lpEnv),
+ lpJava->iVersion);
+ if (_iStatus != JNI_OK) {
+ if (_iStatus == JNI_EDETACHED)
+ _iStatus = (*(lpJava->lpJvm))->AttachCurrentThread(lpJava->lpJvm,
+ (void **)&(lpJava->lpEnv), NULL);
+ }
+ if (_iStatus != JNI_OK) {
+ lpJava->lpEnv = NULL;
+ return FALSE;
+ }
+ else
+ return TRUE;
+}
+
+static __inline BOOL __apxJvmDetach(LPAPXJAVAVM lpJava)
+{
+ jint _iStatus = (*(lpJava->lpJvm))->DetachCurrentThread(lpJava->lpJvm);
+ if (_iStatus != JNI_OK) {
+ lpJava->lpEnv = NULL;
+ return FALSE;
+ }
+ else
+ return TRUE;
+}
+
+static BOOL __apxLoadJvmDll(LPCWSTR szJvmDllPath)
+{
+ UINT errMode;
+ LPWSTR dllJvmPath = (LPWSTR)szJvmDllPath;
+
+ if (!IS_INVALID_HANDLE(_st_sys_jvmDllHandle))
+ return TRUE; /* jvm.dll is already loaded */
+
+ if (!dllJvmPath || *dllJvmPath == L'\0')
+ dllJvmPath = apxGetJavaSoftRuntimeLib(NULL);
+ if (!dllJvmPath)
+ return FALSE;
+ /* Suppress the not found system popup message */
+ errMode = SetErrorMode(SEM_FAILCRITICALERRORS);
+
+ _st_sys_jvmDllHandle = LoadLibraryExW(dllJvmPath, NULL, 0);
+ /* This shuldn't happen, but try to search in %PATH% */
+ if (IS_INVALID_HANDLE(_st_sys_jvmDllHandle))
+ _st_sys_jvmDllHandle = LoadLibraryExW(dllJvmPath, NULL,
+ LOAD_WITH_ALTERED_SEARCH_PATH);
+ /* Restore the error mode signalization */
+ SetErrorMode(errMode);
+ if (IS_INVALID_HANDLE(_st_sys_jvmDllHandle)) {
+ apxLogWrite(APXLOG_MARK_SYSERR);
+ return FALSE;
+ }
+ DYNLOAD_FPTR_LOAD(JNI_GetDefaultJavaVMInitArgs, _st_sys_jvmDllHandle);
+ DYNLOAD_FPTR_LOAD(JNI_CreateJavaVM, _st_sys_jvmDllHandle);
+ DYNLOAD_FPTR_LOAD(JNI_GetCreatedJavaVMs, _st_sys_jvmDllHandle);
+
+ if (!DYNLOAD_FPTR(JNI_GetDefaultJavaVMInitArgs) ||
+ !DYNLOAD_FPTR(JNI_CreateJavaVM) ||
+ !DYNLOAD_FPTR(JNI_GetCreatedJavaVMs)) {
+ apxLogWrite(APXLOG_MARK_SYSERR);
+ FreeLibrary(_st_sys_jvmDllHandle);
+ _st_sys_jvmDllHandle = NULL;
+ return FALSE;
+ }
+
+ /* Real voodo ... */
+ return TRUE;
+}
+
+static BOOL __apxJavaJniCallback(APXHANDLE hObject, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ LPAPXJAVAVM lpJava;
+ DWORD dwJvmRet = 0;
+
+ lpJava = APXHANDLE_DATA(hObject);
+ switch (uMsg) {
+ case WM_CLOSE:
+ if (lpJava->lpJvm) {
+ if (!IS_INVALID_HANDLE(lpJava->hWorkerThread)) {
+ if (GetExitCodeThread(lpJava->hWorkerThread, &dwJvmRet) &&
+ dwJvmRet == STILL_ACTIVE) {
+ TerminateThread(lpJava->hWorkerThread, 5);
+ }
+ }
+ SAFE_CLOSE_HANDLE(lpJava->hWorkerThread);
+ __apxJvmAttach(lpJava);
+ JVM_DELETE_CLAZZ(lpJava, clWorker);
+ JVM_DELETE_CLAZZ(lpJava, clString);
+ __apxJvmDetach(lpJava);
+ /* Check if this is the jvm loader */
+ if (!lpJava->iVmCount && _st_sys_jvmDllHandle) {
+#if 0
+ /* Do not destroy if we terminated the worker thread */
+ if (dwJvmRet != STILL_ACTIVE)
+ (*(lpJava->lpJvm))->DestroyJavaVM(lpJava->lpJvm);
+#endif
+ /* Unload JVM dll */
+ FreeLibrary(_st_sys_jvmDllHandle);
+ _st_sys_jvmDllHandle = NULL;
+ }
+ lpJava->lpJvm = NULL;
+ }
+ break;
+ default:
+ break;
+ }
+ return TRUE;
+}
+
+APXHANDLE
+apxCreateJava(APXHANDLE hPool, LPCWSTR szJvmDllPath)
+{
+
+ APXHANDLE hJava;
+ LPAPXJAVAVM lpJava;
+ jsize iVmCount;
+ JavaVM *lpJvm = NULL;
+
+ if (!__apxLoadJvmDll(szJvmDllPath))
+ return NULL;
+ /*
+ */
+ if (DYNLOAD_FPTR(JNI_GetCreatedJavaVMs)(&lpJvm, 1, &iVmCount) != JNI_OK) {
+ return NULL;
+ }
+ if (iVmCount && !lpJvm)
+ return NULL;
+
+ hJava = apxHandleCreate(hPool, 0,
+ NULL, sizeof(APXJAVAVM),
+ __apxJavaJniCallback);
+ if (IS_INVALID_HANDLE(hJava))
+ return NULL;
+ hJava->dwType = APXHANDLE_TYPE_JVM;
+ lpJava = APXHANDLE_DATA(hJava);
+ lpJava->lpJvm = lpJvm;
+ lpJava->iVmCount = iVmCount;
+ return hJava;
+}
+
+static DWORD __apxMultiSzToJvmOptions(APXHANDLE hPool,
+ LPCSTR lpString,
+ JavaVMOption **lppArray,
+ DWORD nExtra)
+{
+ DWORD i, n = 0, l = 0;
+ char *buff;
+ LPSTR p;
+
+ if (lpString) {
+ l = __apxGetMultiSzLengthA(lpString, &n);
+ }
+ n += nExtra;
+ if (IS_INVALID_HANDLE(hPool))
+ buff = apxPoolAlloc(hPool, (n + 1) * sizeof(JavaVMOption) + (l + 1));
+ else
+ buff = apxAlloc((n + 1) * sizeof(JavaVMOption) + (l + 1));
+
+ *lppArray = (JavaVMOption *)buff;
+ p = (LPSTR)(buff + (n + 1) * sizeof(JavaVMOption));
+ if (lpString)
+ AplCopyMemory(p, lpString, l + 1);
+ for (i = 0; i < (n - nExtra); i++) {
+ DWORD qr = apxStrUnQuoteInplaceA(p);
+ (*lppArray)[i].optionString = p;
+ while (*p)
+ p++;
+ p++;
+ p += qr;
+ }
+
+ return n;
+}
+
+/* a hook for a function that redirects all VM messages. */
+static jint JNICALL __apxJniVfprintf(FILE *fp, const char *format, va_list args)
+{
+ jint rv;
+ CHAR sBuf[1024+16];
+ rv = wvsprintfA(sBuf, format, args);
+ apxLogWrite(APXLOG_MARK_INFO "%s", sBuf);
+ return rv;
+}
+
+
+/* ANSI version only */
+BOOL
+apxJavaInitialize(APXHANDLE hJava, LPCSTR szClassPath,
+ LPCVOID lpOptions, DWORD dwMs, DWORD dwMx,
+ DWORD dwSs)
+{
+ LPAPXJAVAVM lpJava;
+ JDK1_1InitArgs vmArgs11;
+ JavaVMInitArgs vmArgs;
+ JavaVMOption *lpJvmOptions;
+ DWORD i, nOptions, sOptions = 2;
+ BOOL rv = FALSE;
+ if (hJava->dwType != APXHANDLE_TYPE_JVM)
+ return FALSE;
+
+ lpJava = APXHANDLE_DATA(hJava);
+
+ if (lpJava->iVmCount) {
+ if (!lpJava->lpEnv && !__apxJvmAttach(lpJava)) {
+ if (lpJava->iVersion == JNI_VERSION_1_2) {
+ apxLogWrite(APXLOG_MARK_ERROR "Unable To Attach the JVM");
+ return FALSE;
+ }
+ else
+ lpJava->iVersion = JNI_VERSION_1_2;
+ if (!__apxJvmAttach(lpJava)) {
+ apxLogWrite(APXLOG_MARK_ERROR "Unable To Attach the JVM");
+ return FALSE;
+ }
+ }
+ lpJava->iVersion = JNICALL_0(GetVersion);
+ if (lpJava->iVersion < JNI_VERSION_1_2) {
+ apxLogWrite(APXLOG_MARK_ERROR "Unsupported JNI version %#08x", lpJava->iVersion);
+ return FALSE;
+ }
+ rv = TRUE;
+ }
+ else {
+ CHAR iB[3][64];
+ LPSTR szCp;
+ vmArgs11.version = JNI_VERSION_DEFAULT;
+ if (DYNLOAD_FPTR(JNI_GetDefaultJavaVMInitArgs)(&vmArgs11) != JNI_OK) {
+ /* fall back to version 1.2 */
+ if (JNI_VERSION_DEFAULT != JNI_VERSION_1_2) {
+ vmArgs11.version = JNI_VERSION_1_2;
+ if (DYNLOAD_FPTR(JNI_GetDefaultJavaVMInitArgs)(&vmArgs11) != JNI_OK)
+ return FALSE;
+ }
+ else
+ return FALSE;
+ }
+ /* we need at least 1.2 JNI */
+ if ((lpJava->iVersion = vmArgs11.version) < JNI_VERSION_1_2) {
+ apxLogWrite(APXLOG_MARK_ERROR "Unsupported JNI version %d", vmArgs11.version);
+ return FALSE;
+ }
+ if (dwMs)
+ ++sOptions;
+ if (dwMx)
+ ++sOptions;
+ if (dwSs)
+ ++sOptions;
+ nOptions = __apxMultiSzToJvmOptions(hJava->hPool, lpOptions,
+ &lpJvmOptions, sOptions);
+ szCp = apxPoolAlloc(hJava->hPool, sizeof(JAVA_CLASSPATH) + lstrlenA(szClassPath));
+ lstrcpyA(szCp, JAVA_CLASSPATH);
+ lstrcatA(szCp, szClassPath);
+ lpJvmOptions[nOptions - sOptions].optionString = szCp;
+ --sOptions;
+ /* default JNI error printer */
+ lpJvmOptions[nOptions - sOptions].optionString = "vfprintf";
+ lpJvmOptions[nOptions - sOptions].extraInfo = __apxJniVfprintf;
+ --sOptions;
+ if (dwMs) {
+ wsprintfA(iB[0], "-Xms%dm", dwMs);
+ lpJvmOptions[nOptions - sOptions].optionString = iB[0];
+ --sOptions;
+ }
+ if (dwMx) {
+ wsprintfA(iB[1], "-Xmx%dm", dwMx);
+ lpJvmOptions[nOptions - sOptions].optionString = iB[1];
+ --sOptions;
+ }
+ if (dwSs) {
+ wsprintfA(iB[2], "-Xss%dk", dwSs);
+ lpJvmOptions[nOptions - sOptions].optionString = iB[2];
+ --sOptions;
+ }
+ for (i = 0; i < nOptions; i++) {
+ apxLogWrite(APXLOG_MARK_DEBUG "Jvm Option[%d] %s", i,
+ lpJvmOptions[i].optionString);
+ }
+ vmArgs.options = lpJvmOptions;
+ vmArgs.nOptions = nOptions;
+ vmArgs.version = lpJava->iVersion;
+ vmArgs.ignoreUnrecognized = JNI_FALSE;
+ if (DYNLOAD_FPTR(JNI_CreateJavaVM)(&(lpJava->lpJvm),
+ (void **)&(lpJava->lpEnv),
+ &vmArgs) != JNI_OK) {
+ apxLogWrite(APXLOG_MARK_ERROR "CreateJavaVM Failed");
+ rv = FALSE;
+ }
+ else
+ rv = TRUE;
+ apxFree(szCp);
+ apxFree(lpJvmOptions);
+ }
+ /* Load standard classes */
+ if (rv) {
+ jclass jClazz = JNICALL_1(FindClass, JAVA_CLASSSTRING);
+ if (!jClazz) {
+ apxLogWrite(APXLOG_MARK_ERROR "FindClass " JAVA_CLASSSTRING " failed");
+ goto cleanup;
+ }
+ lpJava->clString.jClazz = JNICALL_1(NewGlobalRef, jClazz);
+ JNI_LOCAL_UNREF(jClazz);
+
+ return TRUE;
+ }
+ else
+ return FALSE;
+
+cleanup:
+ JVM_EXCEPTION_CLEAR(lpJava);
+ return FALSE;
+}
+
+BOOL
+apxJavaLoadMainClass(APXHANDLE hJava, LPCSTR szClassName,
+ LPCSTR szMethodName,
+ LPCVOID lpArguments)
+{
+ LPSTR *lpArgs = NULL;
+ DWORD nArgs;
+ LPAPXJAVAVM lpJava;
+ jclass jClazz;
+
+ if (hJava->dwType != APXHANDLE_TYPE_JVM)
+ return FALSE;
+ lpJava = APXHANDLE_DATA(hJava);
+ if (!__apxJvmAttach(lpJava))
+ return FALSE;
+
+ /* Find the class */
+ jClazz = JNICALL_1(FindClass, szClassName);
+ if (!jClazz) {
+ JVM_EXCEPTION_CLEAR(lpJava);
+ apxLogWrite(APXLOG_MARK_ERROR "FindClass %s failed", szClassName);
+ return FALSE;
+ }
+ /* Make the class global so that worker thread can attach */
+ lpJava->clWorker.jClazz = JNICALL_1(NewGlobalRef, jClazz);
+ JNI_LOCAL_UNREF(jClazz);
+
+ if (szMethodName)
+ lpJava->clWorker.jMethod = JNICALL_3(GetStaticMethodID,
+ lpJava->clWorker.jClazz,
+ szMethodName, "([Ljava/lang/String;)V");
+ else
+ lpJava->clWorker.jMethod = JNICALL_3(GetStaticMethodID,
+ lpJava->clWorker.jClazz,
+ "main", "([Ljava/lang/String;)V");
+ if (!lpJava->clWorker.jMethod) {
+ JVM_EXCEPTION_CLEAR(lpJava);
+ apxLogWrite(APXLOG_MARK_ERROR "Static method 'void main(String[])' in Class %s not found", szClassName);
+ return FALSE;
+ }
+ nArgs = apxMultiSzToArrayA(hJava->hPool, lpArguments, &lpArgs);
+ if (nArgs) {
+ DWORD i;
+ lpJava->clWorker.jArgs = JNICALL_3(NewObjectArray, nArgs,
+ lpJava->clString.jClazz, NULL);
+ for (i = 0; i < nArgs; i++) {
+ jstring arg = JNICALL_1(NewStringUTF, lpArgs[i]);
+ JNICALL_3(SetObjectArrayElement, lpJava->clWorker.jArgs, i, arg);
+ apxLogWrite(APXLOG_MARK_DEBUG "argv[%d] = %s", i, lpArgs[i]);
+ }
+ }
+ apxFree(lpArgs);
+ return TRUE;
+}
+
+
+/* Main java application worker thread
+ * It will launch Java main and wait until
+ * it finishes.
+ */
+static DWORD WINAPI __apxJavaWorkerThread(LPVOID lpParameter)
+{
+#define WORKER_EXIT(x) { rv = x; goto finished; }
+ DWORD rv = 0;
+ LPAPXJAVAVM lpJava;
+ APXHANDLE hJava = (APXHANDLE)lpParameter;
+ /* This shouldn't happen */
+ if (hJava->dwType != APXHANDLE_TYPE_JVM)
+ WORKER_EXIT(0);
+ lpJava = APXHANDLE_DATA(hJava);
+ /* Check if we have a class and a method */
+ if (!lpJava->clWorker.jClazz || !lpJava->clWorker.jMethod)
+ WORKER_EXIT(2);
+ if (!__apxJvmAttach(lpJava))
+ WORKER_EXIT(3);
+ lpJava->dwWorkerStatus = 1;
+ JNICALL_3(CallStaticVoidMethod,
+ lpJava->clWorker.jClazz,
+ lpJava->clWorker.jMethod,
+ lpJava->clWorker.jArgs);
+
+ JVM_EXCEPTION_CLEAR(lpJava);
+ __apxJvmDetach(lpJava);
+finished:
+ lpJava->dwWorkerStatus = 0;
+ apxLogWrite(APXLOG_MARK_DEBUG "Java Worker thread finished");
+ ExitThread(rv);
+ /* never gets here but keep the compiler happy */
+ return 0;
+}
+
+
+BOOL
+apxJavaStart(APXHANDLE hJava)
+{
+
+ LPAPXJAVAVM lpJava;
+
+ if (hJava->dwType != APXHANDLE_TYPE_JVM)
+ return FALSE;
+ lpJava = APXHANDLE_DATA(hJava);
+
+ lpJava->hWorkerThread = CreateThread(NULL, 0, __apxJavaWorkerThread,
+ hJava, CREATE_SUSPENDED,
+ &lpJava->iWorkerThread);
+ if (IS_INVALID_HANDLE(lpJava->hWorkerThread)) {
+ apxLogWrite(APXLOG_MARK_SYSERR);
+ return FALSE;
+ }
+ ResumeThread(lpJava->hWorkerThread);
+ /* Give some time to initialize the thread */
+ Sleep(1000);
+ return TRUE;
+}
+
+DWORD
+apxJavaWait(APXHANDLE hJava, DWORD dwMilliseconds, BOOL bKill)
+{
+ DWORD rv;
+ LPAPXJAVAVM lpJava;
+
+ if (hJava->dwType != APXHANDLE_TYPE_JVM)
+ return FALSE;
+ lpJava = APXHANDLE_DATA(hJava);
+
+ if (!lpJava->dwWorkerStatus && lpJava->hWorkerThread)
+ return WAIT_OBJECT_0;
+ rv = WaitForSingleObject(lpJava->hWorkerThread, dwMilliseconds);
+ if (rv == WAIT_TIMEOUT && bKill) {
+ __apxJavaJniCallback(hJava, WM_CLOSE, 0, 0);
+ }
+
+ return rv;
+}
+
+LPVOID
+apxJavaCreateClassV(APXHANDLE hJava, LPCSTR szClassName,
+ LPCSTR szSignature, va_list lpArgs)
+{
+ LPAPXJAVAVM lpJava;
+ jclass clazz;
+ jmethodID ccont;
+ jobject cinst;
+
+ if (hJava->dwType != APXHANDLE_TYPE_JVM)
+ return NULL;
+ lpJava = APXHANDLE_DATA(hJava);
+ if (!__apxJvmAttach(lpJava))
+ return NULL;
+
+ clazz = JNICALL_1(FindClass, szClassName);
+ if (clazz == NULL || (JVM_EXCEPTION_CHECK(lpJava))) {
+ JVM_EXCEPTION_CLEAR(lpJava);
+ apxLogWrite(APXLOG_MARK_ERROR "Could not FindClass %s", szClassName);
+ return NULL;
+ }
+
+ ccont = JNICALL_3(GetMethodID, clazz, "<init>", szSignature);
+ if (ccont == NULL || (JVM_EXCEPTION_CHECK(lpJava))) {
+ JVM_EXCEPTION_CLEAR(lpJava);
+ apxLogWrite(APXLOG_MARK_ERROR "Could not find Constructor %s for %s",
+ szSignature, szClassName);
+ return NULL;
+ }
+
+ cinst = JNICALL_3(NewObjectV, clazz, ccont, lpArgs);
+ if (cinst == NULL || (JVM_EXCEPTION_CHECK(lpJava))) {
+ JVM_EXCEPTION_CLEAR(lpJava);
+ apxLogWrite(APXLOG_MARK_ERROR "Could not create instance of %s",
+ szClassName);
+ return NULL;
+ }
+
+ return cinst;
+}
+
+LPVOID
+apxJavaCreateClass(APXHANDLE hJava, LPCSTR szClassName,
+ LPCSTR szSignature, ...)
+{
+ LPVOID rv;
+ va_list args;
+
+ va_start(args, szSignature);
+ rv = apxJavaCreateClassV(hJava, szClassName, szSignature, args);
+ va_end(args);
+
+ return rv;
+}
+
+LPVOID
+apxJavaCreateStringA(APXHANDLE hJava, LPCSTR szString)
+{
+ LPAPXJAVAVM lpJava;
+ jstring str;
+
+ if (hJava->dwType != APXHANDLE_TYPE_JVM)
+ return NULL;
+ lpJava = APXHANDLE_DATA(hJava);
+
+ str = JNICALL_1(NewStringUTF, szString);
+ if (str == NULL || (JVM_EXCEPTION_CHECK(lpJava))) {
+ JVM_EXCEPTION_CLEAR(lpJava);
+ apxLogWrite(APXLOG_MARK_ERROR "Could not create string for %s",
+ szString);
+ return NULL;
+ }
+
+ return str;
+}
+
+LPVOID
+apxJavaCreateStringW(APXHANDLE hJava, LPCWSTR szString)
+{
+ LPAPXJAVAVM lpJava;
+ jstring str;
+
+ if (hJava->dwType != APXHANDLE_TYPE_JVM)
+ return NULL;
+ lpJava = APXHANDLE_DATA(hJava);
+
+ str = JNICALL_2(NewString, szString, lstrlenW(szString));
+ if (str == NULL || (JVM_EXCEPTION_CHECK(lpJava))) {
+ JVM_EXCEPTION_CLEAR(lpJava);
+ apxLogWrite(APXLOG_MARK_ERROR "Could not create string for %S",
+ szString);
+ return NULL;
+ }
+
+ return str;
+}
+
+jvalue
+apxJavaCallStaticMethodV(APXHANDLE hJava, jclass lpClass, LPCSTR szMethodName,
+ LPCSTR szSignature, va_list lpArgs)
+{
+ LPAPXJAVAVM lpJava;
+ jmethodID method;
+ jvalue rv;
+ LPCSTR s = szSignature;
+ rv.l = 0;
+ if (hJava->dwType != APXHANDLE_TYPE_JVM)
+ return rv;
+ lpJava = APXHANDLE_DATA(hJava);
+
+ while (*s && *s != ')')
+ ++s;
+ if (*s != ')') {
+ return rv;
+ }
+ else
+ ++s;
+ method = JNICALL_3(GetStaticMethodID, lpClass, szMethodName, szSignature);
+ if (method == NULL || (JVM_EXCEPTION_CHECK(lpJava))) {
+ JVM_EXCEPTION_CLEAR(lpJava);
+ apxLogWrite(APXLOG_MARK_ERROR "Could not find method %s with signature %s",
+ szMethodName, szSignature);
+ return rv;
+ }
+ switch (*s) {
+ case 'V':
+ JNICALL_3(CallStaticVoidMethodV, lpClass, method, lpArgs);
+ break;
+ case 'L':
+ case '[':
+ rv.l = JNICALL_3(CallStaticObjectMethodV, lpClass, method, lpArgs);
+ break;
+ case 'Z':
+ rv.z = JNICALL_3(CallStaticBooleanMethodV, lpClass, method, lpArgs);
+ break;
+ case 'B':
+ rv.b = JNICALL_3(CallStaticByteMethodV, lpClass, method, lpArgs);
+ break;
+ case 'C':
+ rv.c = JNICALL_3(CallStaticCharMethodV, lpClass, method, lpArgs);
+ break;
+ case 'S':
+ rv.i = JNICALL_3(CallStaticShortMethodV, lpClass, method, lpArgs);
+ break;
+ case 'I':
+ rv.i = JNICALL_3(CallStaticIntMethodV, lpClass, method, lpArgs);
+ break;
+ case 'J':
+ rv.j = JNICALL_3(CallStaticLongMethodV, lpClass, method, lpArgs);
+ break;
+ case 'F':
+ rv.f = JNICALL_3(CallStaticFloatMethodV, lpClass, method, lpArgs);
+ break;
+ case 'D':
+ rv.d = JNICALL_3(CallStaticDoubleMethodV, lpClass, method, lpArgs);
+ break;
+ default:
+ apxLogWrite(APXLOG_MARK_ERROR "Invalid signature %s for method %s",
+ szSignature, szMethodName);
+ return rv;
+ break;
+ }
+
+ return rv;
+}
+
+jvalue
+apxJavaCallStaticMethod(APXHANDLE hJava, jclass lpClass, LPCSTR szMethodName,
+ LPCSTR szSignature, ...)
+{
+ jvalue rv;
+ va_list args;
+
+ va_start(args, szSignature);
+ rv = apxJavaCallStaticMethodV(hJava, lpClass, szMethodName, szSignature, args);
+ va_end(args);
+
+ return rv;
+}
+
+/* Call the Java:
+ * System.setOut(new PrintStream(new FileOutputStream(filename)));
+ */
+BOOL
+apxJavaSetOut(APXHANDLE hJava, BOOL setErrorOrOut, LPCWSTR szFilename)
+{
+ LPAPXJAVAVM lpJava;
+ jobject fs;
+ jobject ps;
+ jstring fn;
+ jclass sys;
+
+ if (hJava->dwType != APXHANDLE_TYPE_JVM || !szFilename)
+ return FALSE;
+ lpJava = APXHANDLE_DATA(hJava);
+ if (!__apxJvmAttach(lpJava))
+ return FALSE;
+
+ if ((fn = apxJavaCreateStringW(hJava, szFilename)) == NULL)
+ return FALSE;
+ if ((fs = apxJavaCreateClass(hJava, "java/io/FileOutputStream",
+ "(Ljava/lang/String;Z)V", fn, JNI_TRUE)) == NULL)
+ return FALSE;
+ if ((ps = apxJavaCreateClass(hJava, "java/io/PrintStream",
+ "(Ljava/io/OutputStream;)V", fs)) == NULL)
+ return FALSE;
+ sys = JNICALL_1(FindClass, "java/lang/System");
+ if (sys == NULL || (JVM_EXCEPTION_CHECK(lpJava))) {
+ JVM_EXCEPTION_CLEAR(lpJava);
+ apxLogWrite(APXLOG_MARK_ERROR "Could not FindClass java/lang/System");
+ return FALSE;
+ }
+
+ if (setErrorOrOut)
+ apxJavaCallStaticMethod(hJava, sys, "setErr", "(Ljava/io/PrintStream;)V", ps);
+ else
+ apxJavaCallStaticMethod(hJava, sys, "setOut", "(Ljava/io/PrintStream;)V", ps);
+
+ if (JVM_EXCEPTION_CHECK(lpJava)) {
+ JVM_EXCEPTION_CLEAR(lpJava);
+ apxLogWrite(APXLOG_MARK_ERROR "Error calling set method for java/lang/System");
+ return FALSE;
+ }
+ else
+ return TRUE;
+
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/log.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/log.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/log.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,409 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apxwin.h"
+#include "private.h"
+
+#define LINE_SEP "\n"
+
+static LPCSTR _log_level[] = {
+ "[debug] ",
+ "[info] ",
+ "[warn] ",
+ "[error] ",
+ NULL
+};
+
+typedef struct apx_logfile_st {
+ HANDLE hFile;
+ DWORD dwLogLevel;
+ BOOL bRotate;
+ SYSTEMTIME sysTime;
+ WCHAR szPath[MAX_PATH + 1];
+ WCHAR szPrefix[MAX_PATH];
+} apx_logfile_st;
+
+/* Per-application master log file */
+static apx_logfile_st *_st_sys_loghandle = NULL;
+
+static apx_logfile_st _st_sys_errhandle = { NULL, APXLOG_LEVEL_WARN, FALSE};
+
+
+LPWSTR apxLogFile(
+ APXHANDLE hPool,
+ LPCWSTR szPath,
+ LPCWSTR szPrefix,
+ LPCWSTR szName)
+{
+ LPWSTR sRet;
+ WCHAR sPath[MAX_PATH+1];
+ WCHAR sName[MAX_PATH+1];
+ SYSTEMTIME sysTime;
+
+ GetLocalTime(&sysTime);
+ if (!szPath) {
+ if (GetSystemDirectoryW(sPath, MAX_PATH) == 0)
+ return INVALID_HANDLE_VALUE;
+ lstrcatW(sPath, L"\\LogFiles\\");
+ if (!szPrefix)
+ lstrcatW(sPath, L"Apache");
+ else
+ lstrcatW(sPath, szPrefix);
+ wsprintfW(sName, L"\\%s%04d%02d%02d.log",
+ szName,
+ sysTime.wYear,
+ sysTime.wMonth,
+ sysTime.wDay);
+ }
+ else {
+ lstrcpyW(sPath, szPath);
+ if (szPrefix)
+ wsprintfW(sName, L"\\%s", szPrefix);
+ else
+ wsprintfW(sName, L"\\%s%04d%02d%02d.log",
+ szName,
+ sysTime.wYear,
+ sysTime.wMonth,
+ sysTime.wDay);
+ }
+ sRet = apxPoolAlloc(hPool, (MAX_PATH + 1) * sizeof(WCHAR));
+ /* Set default level to info */
+ CreateDirectoryW(sPath, NULL);
+
+ lstrcpyW(sRet, sPath);
+ lstrcatW(sRet, sName);
+
+ return sRet;
+}
+
+/* Open the log file
+ * TODO: format like standard apache error.log
+ * Add the EventLogger
+ */
+HANDLE apxLogOpen(
+ APXHANDLE hPool,
+ LPCWSTR szPath,
+ LPCWSTR szPrefix)
+{
+
+ WCHAR sPath[MAX_PATH+1];
+ WCHAR sName[MAX_PATH+1];
+ SYSTEMTIME sysTime;
+ apx_logfile_st *h;
+
+ GetLocalTime(&sysTime);
+ if (!szPath) {
+ if (GetSystemDirectoryW(sPath, MAX_PATH) == 0)
+ return INVALID_HANDLE_VALUE;
+ lstrcatW(sPath, L"\\LogFiles\\");
+ if (!szPrefix)
+ lstrcatW(sPath, L"Apache");
+ else
+ lstrcatW(sPath, szPrefix);
+ wsprintfW(sName, L"\\%04d%02d%02d.log",
+ sysTime.wYear,
+ sysTime.wMonth,
+ sysTime.wDay);
+ }
+ else {
+ lstrcpyW(sPath, szPath);
+ if (szPrefix)
+ wsprintfW(sName, L"\\%s", szPrefix);
+ else
+ wsprintfW(sName, L"\\jakarta_service_%04d%02d%02d.log",
+ sysTime.wYear,
+ sysTime.wMonth,
+ sysTime.wDay);
+ }
+ if (!(h = (apx_logfile_st *)apxPoolCalloc(hPool, sizeof(apx_logfile_st))))
+ return NULL;
+ /* Set default level to info */
+ h->dwLogLevel = APXLOG_LEVEL_INFO;
+ CreateDirectoryW(sPath, NULL);
+
+ h->sysTime = sysTime;
+ lstrcpyW(h->szPath, sPath);
+ lstrcatW(sPath, sName);
+ if (szPrefix)
+ lstrcpyW(h->szPrefix, szPrefix);
+
+ h->hFile = CreateFileW(sPath,
+ GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH,
+ NULL);
+ /* Set this file as system log file */
+ if (!_st_sys_loghandle)
+ _st_sys_loghandle = h;
+
+ return (HANDLE)h;
+}
+
+void apxLogLevelSet(HANDLE hFile, DWORD dwLevel)
+{
+ apx_logfile_st *lf = (apx_logfile_st *)hFile;
+ if (IS_INVALID_HANDLE(lf))
+ lf = _st_sys_loghandle;
+ if (IS_INVALID_HANDLE(lf))
+ return;
+ if (dwLevel < 4)
+ lf->dwLogLevel = dwLevel;
+}
+
+void apxLogRotateSet(HANDLE hFile, BOOL doRotate)
+{
+ apx_logfile_st *lf = (apx_logfile_st *)hFile;
+ if (IS_INVALID_HANDLE(lf))
+ lf = _st_sys_loghandle;
+ if (IS_INVALID_HANDLE(lf))
+ return;
+ lf->bRotate = doRotate;
+}
+
+void apxLogLevelSetW(HANDLE hFile,
+ LPCWSTR szLevel)
+{
+ apx_logfile_st *lf = (apx_logfile_st *)hFile;
+
+ if (IS_INVALID_HANDLE(lf))
+ lf = _st_sys_loghandle;
+ if (IS_INVALID_HANDLE(lf))
+ return;
+ if (szLevel) {
+ if (!lstrcmpiW(szLevel, L"error"))
+ lf->dwLogLevel = APXLOG_LEVEL_ERROR;
+ else if (!lstrcmpiW(szLevel, L"warn"))
+ lf->dwLogLevel = APXLOG_LEVEL_WARN;
+ else if (!lstrcmpiW(szLevel, L"info"))
+ lf->dwLogLevel = APXLOG_LEVEL_INFO;
+ else if (!lstrcmpiW(szLevel, L"debug"))
+ lf->dwLogLevel = APXLOG_LEVEL_DEBUG;
+ }
+}
+
+static BOOL apx_log_rotate(apx_logfile_st *l,
+ LPSYSTEMTIME lpCtime)
+{
+ WCHAR sPath[MAX_PATH+1];
+
+ /* rotate on daily basis */
+ if (l->sysTime.wDay == lpCtime->wDay)
+ return TRUE;
+ FlushFileBuffers(l->hFile);
+ CloseHandle(l->hFile);
+ l->sysTime = *lpCtime;
+
+ wsprintfW(sPath, L"%s\\%s%04d%02d%02d.log",
+ l->szPath,
+ l->szPrefix,
+ l->sysTime.wYear,
+ l->sysTime.wMonth,
+ l->sysTime.wDay);
+ l->hFile = CreateFileW(sPath,
+ GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH,
+ NULL);
+ if (IS_INVALID_HANDLE(l->hFile))
+ return FALSE;
+ else
+ return TRUE;
+}
+
+int
+apxLogWrite(
+ HANDLE hFile,
+ DWORD dwLevel,
+ BOOL bTimeStamp,
+ LPCSTR szFile,
+ DWORD dwLine,
+ LPCSTR szFormat,
+ ...)
+{
+ va_list args;
+ CHAR buffer[1024+32];
+ LPSTR szBp;
+ int len = 0;
+ LPCSTR f = szFile;
+ CHAR sb[MAX_PATH+1];
+ DWORD wr;
+ DWORD err;
+ BOOL dolock = TRUE;
+ apx_logfile_st *lf = (apx_logfile_st *)hFile;
+
+ if (IS_INVALID_HANDLE(lf))
+ lf = _st_sys_loghandle;
+ if (IS_INVALID_HANDLE(lf)) {
+ lf = &_st_sys_errhandle;
+ lf->hFile = GetStdHandle(STD_ERROR_HANDLE);
+ dolock = FALSE;
+ }
+ if (dwLevel < lf->dwLogLevel)
+ return 0;
+ err = GetLastError(); /* save the last Error code */
+ if (f) {
+ f = (szFile + lstrlenA(szFile) - 1);
+ while(f != szFile && '\\' != *f && '/' != *f)
+ f--;
+ if(f != szFile)
+ f++;
+ }
+ lstrcpyA(buffer, _log_level[dwLevel]);
+ if (!dolock)
+ lstrcatA(buffer, "\n");
+ szBp = &buffer[lstrlenA(buffer)];
+ if (!szFormat) {
+ FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ err,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ szBp,
+ 1000,
+ NULL);
+ }
+ else {
+ va_start(args, szFormat);
+ wvsprintfA(szBp, szFormat, args);
+ va_end(args);
+ }
+ len = lstrlenA(buffer);
+ if (len > 0) {
+ /* Remove trailing line separator */
+ if (buffer[len - 1] == '\n') {
+ buffer[len - 1] = '\0';
+ --len;
+ }
+ if (!IS_INVALID_HANDLE(lf->hFile)) {
+ SYSTEMTIME t;
+ GetLocalTime(&t);
+ if (lf->bRotate) {
+ if (!apx_log_rotate(lf, &t))
+ return 0;
+ }
+ if (dolock) {
+ APX_LOGLOCK(lf->hFile);
+ }
+ if (bTimeStamp) {
+ wsprintfA(sb, "[%d-%02d-%02d %02d:%02d:%02d] ",
+ t.wYear, t.wMonth, t.wDay,
+ t.wHour, t.wMinute, t.wSecond);
+ WriteFile(lf->hFile, sb, lstrlenA(sb), &wr, NULL);
+ }
+ if (f) {
+ wsprintfA(sb, "[%-4d %s] ", dwLine, f);
+ WriteFile(lf->hFile, sb, lstrlenA(sb), &wr, NULL);
+ }
+
+ WriteFile(lf->hFile, buffer, len, &wr, NULL);
+ /* Terminate the line */
+ WriteFile(lf->hFile, LINE_SEP, sizeof(LINE_SEP) - 1, &wr, NULL);
+#ifdef _DEBUG_FULL
+ FlushFileBuffers(lf->hFile);
+#endif
+ if (dolock) {
+ APX_LOGUNLOCK(lf->hFile);
+ }
+ }
+#ifdef _DEBUG_FULL
+ {
+ char tid[1024 + 16];
+ wsprintfA(tid, "[%04X] %s", GetCurrentThreadId(), buffer);
+ OutputDebugStringA(tid);
+ }
+#endif
+ }
+ /* Restore the last Error code */
+ SetLastError(err);
+ return len;
+}
+
+void apxLogClose(
+ HANDLE hFile)
+{
+ apx_logfile_st *lf = (apx_logfile_st *)hFile;
+
+ if (IS_INVALID_HANDLE(lf))
+ lf = _st_sys_loghandle;
+ if (IS_INVALID_HANDLE(lf))
+ return;
+
+ FlushFileBuffers(lf->hFile);
+ CloseHandle(lf->hFile);
+ if (lf == _st_sys_loghandle)
+ _st_sys_loghandle = NULL;
+ apxFree(lf);
+}
+
+int
+apxDisplayError(
+ BOOL bDisplay,
+ LPCSTR szFile,
+ DWORD dwLine,
+ LPCSTR szFormat,
+ ...)
+{
+ va_list args;
+ CHAR buffer[1024+16];
+ CHAR sysbuf[2048];
+ int len = 0, nRet;
+ LPCSTR f = szFile;
+ DWORD err = GetLastError(); /* save the last Error code */
+ if (f) {
+ f = (szFile + lstrlenA(szFile) - 1);
+ while(f != szFile && '\\' != *f && '/' != *f)
+ f--;
+ if(f != szFile)
+ f++;
+ }
+ sysbuf[0] = '\0';
+ if (err != ERROR_SUCCESS) {
+ len = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ err,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ sysbuf,
+ 1000,
+ NULL);
+ sysbuf[len] = 0;
+ }
+ if (szFormat) {
+ va_start(args, szFormat);
+ wvsprintfA(buffer, szFormat, args);
+ va_end(args);
+ if (f) {
+ CHAR sb[MAX_PATH+1];
+ wsprintfA(sb, "\n%s (%d)", f, dwLine);
+ lstrcatA(sysbuf, sb);
+ }
+ lstrcatA(sysbuf, "\n");
+ lstrcatA(sysbuf, buffer);
+ }
+ len = lstrlenA(sysbuf);
+#ifdef _DEBUG_FULL
+ OutputDebugStringA(sysbuf);
+#endif
+ if (len > 0 && bDisplay) {
+ nRet = MessageBoxA(NULL, sysbuf,
+ "Application System Error",
+ MB_ICONERROR | MB_OK | MB_SYSTEMMODAL);
+ }
+ /* Restore the last Error code */
+ SetLastError(err);
+ return len;
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/mclib.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/mclib.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/mclib.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,293 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Copyright (c) 1994
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Andrew Hume of AT&T Bell Laboratories.
+ *
+ * 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. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS 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 REGENTS OR 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.
+ */
+
+#include "apxwin.h"
+#include "private.h"
+
+typedef UINT word; /* "word" used for optimal copy speed */
+#define wsize sizeof(UINT)
+#define wmask (wsize - 1)
+
+LPVOID AplFillMemory(PVOID Destination, SIZE_T Length, BYTE Fill)
+{
+
+ SIZE_T t;
+#ifdef WIN64
+ UINT64 c;
+#else
+ UINT c;
+#endif
+ LPBYTE dst;
+
+ dst = Destination;
+ /*
+ * If not enough words, just fill bytes. A length >= 2 words
+ * guarantees that at least one of them is `complete' after
+ * any necessary alignment. For instance:
+ *
+ * |-----------|-----------|-----------|
+ * |00|01|02|03|04|05|06|07|08|09|0A|00|
+ * ^---------------------^
+ * dst dst+length-1
+ *
+ * but we use a minimum of 3 here since the overhead of the code
+ * to do word writes is substantial.
+ */
+ if (Length < 3 * wsize) {
+ while (Length != 0) {
+ *dst++ = Fill;
+ --Length;
+ }
+ return (Destination);
+ }
+
+ if ((c = Fill) != 0) { /* Fill the word. */
+ c = (c << 8) | c; /* u_int is 16 bits. */
+ c = (c << 16) | c; /* u_int is 32 bits. */
+#ifdef WIN64
+ c = (c << 32) | c; /* u_int is 64 bits. */
+#endif
+ }
+ /* Align destination by filling in bytes. */
+ if ((t = (SIZE_T)dst & wmask) != 0) {
+ t = wsize - t;
+ Length -= t;
+ do {
+ *dst++ = Fill;
+ } while (--t != 0);
+ }
+
+ /* Fill words. Length was >= 2*words so we know t >= 1 here. */
+ t = Length / wsize;
+ do {
+#ifdef WIN64
+ *(UINT64 *)dst = c;
+#else
+ *(UINT *)dst = c;
+#endif
+ dst += wsize;
+ } while (--t != 0);
+
+ /* Mop up trailing bytes, if any. */
+ t = Length & wmask;
+ if (t != 0)
+ do {
+ *dst++ = Fill;
+ } while (--t != 0);
+ return (Destination);
+}
+
+void AplZeroMemory(PVOID Destination, SIZE_T Length)
+{
+
+ SIZE_T t;
+ LPBYTE dst;
+
+ dst = Destination;
+ /*
+ * If not enough words, just fill bytes. A length >= 2 words
+ * guarantees that at least one of them is `complete' after
+ * any necessary alignment. For instance:
+ *
+ * |-----------|-----------|-----------|
+ * |00|01|02|03|04|05|06|07|08|09|0A|00|
+ * ^---------------------^
+ * dst dst+length-1
+ *
+ * but we use a minimum of 3 here since the overhead of the code
+ * to do word writes is substantial.
+ */
+ if (Length < 3 * wsize) {
+ while (Length != 0) {
+ *dst++ = 0;
+ --Length;
+ }
+ return;
+ }
+
+ /* Align destination by filling in bytes. */
+ if ((t = (SIZE_T)dst & wmask) != 0) {
+ t = wsize - t;
+ Length -= t;
+ do {
+ *dst++ = 0;
+ } while (--t != 0);
+ }
+
+ /* Fill words. Length was >= 2*words so we know t >= 1 here. */
+ t = Length / wsize;
+ do {
+ *(UINT *)dst = 0;
+ dst += wsize;
+ } while (--t != 0);
+
+ /* Mop up trailing bytes, if any. */
+ t = Length & wmask;
+ if (t != 0)
+ do {
+ *dst++ = 0;
+ } while (--t != 0);
+}
+
+LPVOID AplCopyMemory(PVOID Destination, const VOID* Source, SIZE_T Length)
+{
+ char *dst = Destination;
+ const char *src = Source;
+ SIZE_T t;
+
+ if (Length == 0 || dst == src) /* nothing to do */
+ goto done;
+
+ /*
+ * Macros: loop-t-times; and loop-t-times, t>0
+ */
+#define TLOOP(s) if (t) TLOOP1(s)
+#define TLOOP1(s) do { s; } while (--t)
+
+ if ((SIZE_T)dst < (SIZE_T)src) {
+ /*
+ * Copy forward.
+ */
+ t = (int)(SIZE_T)src; /* only need low bits */
+ if ((t | (int)(SIZE_T)dst) & wmask) {
+ /*
+ * Try to align operands. This cannot be done
+ * unless the low bits match.
+ */
+ if ((t ^ (int)(SIZE_T)dst) & wmask || Length < wsize)
+ t = Length;
+ else
+ t = wsize - (t & wmask);
+ Length -= t;
+ TLOOP1(*dst++ = *src++);
+ }
+ /*
+ * Copy whole words, then mop up any trailing bytes.
+ */
+ t = Length / wsize;
+ TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize);
+ t = Length & wmask;
+ TLOOP(*dst++ = *src++);
+ } else {
+ /*
+ * Copy backwards. Otherwise essentially the same.
+ * Alignment works as before, except that it takes
+ * (t&wmask) bytes to align, not wsize-(t&wmask).
+ */
+ src += Length;
+ dst += Length;
+ t = (int)(SIZE_T)src;
+ if ((t | (int)(SIZE_T)dst) & wmask) {
+ if ((t ^ (int)(SIZE_T)dst) & wmask || Length <= wsize)
+ t = Length;
+ else
+ t &= wmask;
+ Length -= t;
+ TLOOP1(*--dst = *--src);
+ }
+ t = Length / wsize;
+ TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src);
+ t = Length & wmask;
+ TLOOP(*--dst = *--src);
+ }
+done:
+ return (Destination);
+}
+
+
+INT
+AplMemCmp(LPCVOID lpA, LPCVOID lpB, SIZE_T nBytes)
+{
+ if (nBytes != 0) {
+ const BYTE *p1 = lpA, *p2 = lpB;
+
+ do {
+ if (*p1++ != *p2++)
+ return (*--p1 - *--p2);
+ } while (--nBytes != 0);
+ }
+ return 0;
+}
+
+/*
+ * Find the first occurrence of lpFind in lpMem.
+ * dwLen: The length of lpFind
+ * dwSize: The length of lpMem
+ */
+LPBYTE
+ApcMemSearch(LPCVOID lpMem, LPCVOID lpFind, SIZE_T dwLen, SIZE_T dwSize)
+{
+ BYTE c, sc;
+ SIZE_T cnt = 0;
+ const BYTE *s = lpMem, *find = lpFind;
+
+ if ((c = *find++) != 0) {
+ do {
+ do {
+ sc = *s++;
+ if (cnt++ > dwSize)
+ return NULL;
+ } while (sc != c);
+ } while (AplMemCmp(s, find, dwLen - 1) != 0);
+ s--;
+ }
+ return (LPBYTE)s;
+}
+
+LPSTR
+AplRindexA(LPCSTR lpStr, int ch)
+{
+ LPSTR save;
+
+ for (save = NULL;; ++lpStr) {
+ if (*lpStr == ch)
+ save = (LPSTR)lpStr;
+ if (!*lpStr)
+ return save;
+ }
+ /* NOTREACHED */
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/mclib.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/mclib.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/mclib.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,26 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _MCLIB_H_INCLUDED_
+#define _MCLIB_H_INCLUDED_
+
+#ifndef MIN
+#define MIN(a,b) (((a)<(b)) ? (a) : (b))
+#endif
+#ifndef MAX
+#define MAX(a,b) (((a)>(b)) ? (a) : (b))
+#endif
+
+#endif /* _MCLIB_H_INCLUDED_ */
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/private.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/private.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/private.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,273 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _PRIVATE_H_INCLUDED_
+#define _PRIVATE_H_INCLUDED_
+
+#include "mclib.h"
+
+#ifdef _DEBUG
+
+HANDLE HeapCREATE(DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize);
+BOOL HeapDESTROY(HANDLE hHeap);
+
+LPVOID HeapALLOC(HANDLE hHeap, DWORD dwFlags, SIZE_T nSize);
+BOOL HeapFREE(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem);
+LPVOID HeapREALLOC(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem, SIZE_T dwBytes);
+
+#else
+
+#define HeapCREATE HeapCreate
+#define HeapDESTROY HeapDestroy
+#define HeapALLOC HeapAlloc
+#define HeapFREE HeapFree
+#define HeapREALLOC HeapReAlloc
+
+#endif
+
+/*
+ * Tail queue declarations.
+ */
+#define TAILQ_HEAD(name, type) \
+struct name { \
+ struct type *tqh_first; /* first element */ \
+ struct type **tqh_last; /* addr of last next element */ \
+}
+
+#define TAILQ_HEAD_INITIALIZER(head) \
+ { NULL, &(head).tqh_first }
+
+#define TAILQ_ENTRY(type) \
+struct { \
+ struct type *tqe_next; /* next element */ \
+ struct type **tqe_prev; /* address of previous next element */ \
+}
+
+/*
+ * Tail queue functions.
+ */
+#define TAILQ_CONCAT(head1, head2, field) do { \
+ if (!TAILQ_EMPTY(head2)) { \
+ *(head1)->tqh_last = (head2)->tqh_first; \
+ (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
+ (head1)->tqh_last = (head2)->tqh_last; \
+ TAILQ_INIT((head2)); \
+ } \
+} while (0)
+
+#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
+
+#define TAILQ_FIRST(head) ((head)->tqh_first)
+
+#define TAILQ_FOREACH(var, head, field) \
+ for ((var) = TAILQ_FIRST((head)); \
+ (var); \
+ (var) = TAILQ_NEXT((var), field))
+
+#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
+ for ((var) = TAILQ_LAST((head), headname); \
+ (var); \
+ (var) = TAILQ_PREV((var), headname, field))
+
+#define TAILQ_INIT(head) do { \
+ TAILQ_FIRST((head)) = NULL; \
+ (head)->tqh_last = &TAILQ_FIRST((head)); \
+} while (0)
+
+#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
+ if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
+ TAILQ_NEXT((elm), field)->field.tqe_prev = \
+ &TAILQ_NEXT((elm), field); \
+ else { \
+ (head)->tqh_last = &TAILQ_NEXT((elm), field); \
+ } \
+ TAILQ_NEXT((listelm), field) = (elm); \
+ (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \
+} while (0)
+
+#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
+ (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
+ TAILQ_NEXT((elm), field) = (listelm); \
+ *(listelm)->field.tqe_prev = (elm); \
+ (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \
+} while (0)
+
+#define TAILQ_INSERT_HEAD(head, elm, field) do { \
+ if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \
+ TAILQ_FIRST((head))->field.tqe_prev = \
+ &TAILQ_NEXT((elm), field); \
+ else \
+ (head)->tqh_last = &TAILQ_NEXT((elm), field); \
+ TAILQ_FIRST((head)) = (elm); \
+ (elm)->field.tqe_prev = &TAILQ_FIRST((head)); \
+} while (0)
+
+#define TAILQ_INSERT_TAIL(head, elm, field) do { \
+ TAILQ_NEXT((elm), field) = NULL; \
+ (elm)->field.tqe_prev = (head)->tqh_last; \
+ *(head)->tqh_last = (elm); \
+ (head)->tqh_last = &TAILQ_NEXT((elm), field); \
+} while (0)
+
+#define TAILQ_LAST(head, headname) \
+ (*(((struct headname *)((head)->tqh_last))->tqh_last))
+
+#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
+
+#define TAILQ_PREV(elm, headname, field) \
+ (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+
+#define TAILQ_REMOVE(head, elm, field) do { \
+ if ((TAILQ_NEXT((elm), field)) != NULL) \
+ TAILQ_NEXT((elm), field)->field.tqe_prev = \
+ (elm)->field.tqe_prev; \
+ else { \
+ (head)->tqh_last = (elm)->field.tqe_prev; \
+ } \
+ *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \
+} while (0)
+
+/** Some usefull macros */
+
+#define APXHANDLE_SPINLOCK(h) \
+ APXMACRO_BEGIN \
+ while (InterlockedCompareExchange(&((h)->lvSpin), 1, 0) != 0) { \
+ Sleep(10); \
+ SwitchToThread(); \
+ } \
+ APXMACRO_END
+
+#define APXHANDLE_SPINUNLOCK(h) \
+ APXMACRO_BEGIN \
+ InterlockedExchange(&((h)->lvSpin), 0); \
+ APXMACRO_END
+
+#define APX_SPINLOCK(lock) \
+ APXMACRO_BEGIN \
+ while (InterlockedCompareExchange(&(lock), 1, 0) != 0) \
+ SwitchToThread(); \
+ APXMACRO_END
+
+#define APX_SPINUNLOCK(lock) \
+ APXMACRO_BEGIN \
+ InterlockedExchange(&(lock), 0); \
+ APXMACRO_END
+
+/*
+ * Define a union with types which are likely to have the longest
+ * *relevant* CPU-specific memory word alignment restrictions...
+ */
+typedef union APXMEMWORD {
+ void *vp;
+ void (*fp)(void);
+ char *cp;
+ long l;
+ double d;
+} APXMEMWORD;
+
+typedef struct APXCALLHOOK APXCALLHOOK;
+
+struct APXCALLHOOK {
+
+ LPAPXFNCALLBACK fnCallback;
+ TAILQ_ENTRY(APXCALLHOOK) queue;
+};
+
+struct stAPXHANDLE {
+ /** The type of the handle */
+ DWORD dwType;
+ /** Handle Flags */
+ DWORD dwFlags;
+ /** Handle user data size */
+ DWORD dwSize;
+ /** parameters for event callback */
+ WPARAM wParam;
+ LPARAM lParam;
+ UINT uMsg;
+ /** main callback function (using default if not specified) */
+ LPAPXFNCALLBACK fnCallback;
+ /** callback functions hook list */
+ TAILQ_HEAD(_lCallbacks, APXCALLHOOK) lCallbacks;
+ /** allocation pool */
+ APXHANDLE hPool;
+ /** interlocking value */
+ LONG volatile lvSpin;
+
+ /** message event handle */
+ HANDLE hEventHandle;
+ /** message event thread */
+ HANDLE hEventThread;
+ /** message event thread id */
+ DWORD hEventThreadId;
+ /** private local heap */
+ HANDLE hHeap;
+ /** list enty for pool */
+ TAILQ_ENTRY(stAPXHANDLE) queue;
+ /** small userdata pointer */
+ union {
+ LPVOID lpPtr;
+ HANDLE hWinHandle;
+ double dValue;
+ void (*fpValue)();
+ } uData;
+
+ APXMEMWORD stAlign;
+};
+
+#define APXHANDLE_DATA(h) ((void *)((char*)(h) + sizeof(stAPXHANDLE)))
+#define APXHANDLE_SZ sizeof(stAPXHANDLE)
+
+extern APX_OSLEVEL _st_apx_oslevel;
+
+#define APX_GET_OSLEVEL() ((_st_apx_oslevel == APX_WINVER_UNK) ? apxGetOsLevel() : _st_apx_oslevel)
+
+#ifdef _DEBUG
+void ErrorMessage(LPCTSTR szError, BOOL bFatal);
+#else
+#define ErrorMessage(szError, bFatal) ((void)0)
+#endif
+/* zero separated, double zero terminated string */
+struct APXMULTISZ {
+ DWORD dwAllocated; /* length including terminators */
+ DWORD dwInsert; /* next insert position */
+};
+
+typedef struct APXREGENUM {
+ HKEY hServicesKey;
+ DWORD dwIndex; /* current enum index */
+ DWORD cSubKeys; /* number of subkeys */
+ DWORD cbMaxSubKey; /* longest subkey size */
+ DWORD cchMaxClass; /* longest class string */
+ DWORD cValues; /* number of values for key */
+ DWORD cchMaxValue; /* longest value name */
+ DWORD cbMaxValueData; /* longest value data */
+
+} APXREGENUM, *LPAPXREGENUM;
+
+BOOL apxRegistryEnumServices(LPAPXREGENUM lpEnum, LPAPXSERVENTRY lpEntry);
+
+BOOL apxSetServiceDescriptionW(LPCWSTR szServiceName, LPCWSTR szDescription);
+BOOL apxGetServiceDescriptionW(LPCWSTR szServiceName, LPWSTR szDescription,
+ DWORD dwDescriptionLength);
+BOOL apxGetServiceUserW(LPCWSTR szServiceName, LPWSTR szUser,
+ DWORD dwUserLength);
+
+DWORD __apxGetMultiSzLengthA(LPCSTR lpStr, LPDWORD lpdwCount);
+DWORD __apxGetMultiSzLengthW(LPCWSTR lpStr, LPDWORD lpdwCount);
+LPSTR __apxGetEnvironmentVariableA(APXHANDLE hPool, LPCSTR szName);
+LPWSTR __apxGetEnvironmentVariableW(APXHANDLE hPool, LPCWSTR wsName);
+
+
+#endif /* _PRIVATE_H_INCLUDED_ */
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/registry.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/registry.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/registry.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,1084 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apxwin.h"
+#include "private.h"
+
+static LPCWSTR REGSERVICE_ROOT = L"SYSTEM\\CurrentControlSet\\Services\\";
+static LPCWSTR REGSOFTWARE_ROOT = L"SOFTWARE\\";
+static LPCWSTR REGSERVICE_START = L"Start";
+static LPCWSTR REGSERVICE_USER = L"ObjectName";
+static LPCWSTR REGPARAMS = L"Parameters";
+static LPCWSTR REGDESCRIPTION = L"Description";
+static LPCWSTR REGSEPARATOR = L"\\";
+static LPCWSTR REGAPACHE_ROOT = L"Apache Software Foundation";
+/* predefined java keys */
+static LPCWSTR JRE_REGKEY = L"SOFTWARE\\JavaSoft\\Java Runtime Environment\\";
+static LPCWSTR JDK_REGKEY = L"SOFTWARE\\JavaSoft\\Java Development Kit\\";
+static LPCWSTR JAVA_CURRENT = L"CurrentVersion";
+static LPCWSTR JAVA_RUNTIME = L"RuntimeLib";
+static LPCWSTR JAVA_HOME = L"JAVA_HOME";
+static LPCWSTR JAVAHOME = L"JavaHome";
+
+#define REG_CAN_CREATE(r) \
+ ((r)->samOptions & KEY_CREATE_SUB_KEY)
+
+#define REG_CAN_WRITE(r) \
+ ((r)->samOptions & KEY_SET_VALUE)
+
+
+#define REG_GET_KEY(r, w, k) \
+ APXMACRO_BEGIN \
+ switch(w) { \
+ case APXREG_SOFTWARE: k = (r)->hRootKey; break; \
+ case APXREG_PARAMSOFTWARE: k = (r)->hRparamKey; break; \
+ case APXREG_SERVICE: k = (r)->hServKey; break; \
+ case APXREG_PARAMSERVICE: k = (r)->hSparamKey; break; \
+ case APXREG_USER: k = (r)->hUserKey; break; \
+ case APXREG_PARAMUSER: k = (r)->hUparamKey; break; \
+ default: k = NULL; break; \
+ } APXMACRO_END
+
+
+typedef struct APXREGISTRY APXREGISTRY;
+typedef APXREGISTRY* LPAPXREGISTRY;
+typedef struct APXREGSUBKEY APXREGSUBKEY;
+
+struct APXREGSUBKEY {
+ APXHANDLE hRegistry;
+ HKEY hKey;
+ LPCTSTR syKeyName;
+ TAILQ_ENTRY(APXREGSUBKEY);
+};
+
+struct APXREGISTRY {
+ HKEY hRootKey; /* root key */
+ HKEY hServKey; /* service key */
+ HKEY hUserKey; /* user key */
+ HKEY hCurrKey; /* Current opened key */
+ LPVOID pCurrVal; /* Current value, overwitten on a next call */
+ HKEY hRparamKey; /* root\\Parameters */
+ HKEY hSparamKey; /* service\\Parameters */
+ HKEY hUparamKey; /* service\\Parameters */
+ REGSAM samOptions;
+ /** list enty for opened subkeys */
+ TAILQ_HEAD(_lSubkeys, APXREGSUBKEY) lSubkeys;
+
+};
+
+#define SAFE_CLOSE_KEY(k) \
+ if ((k) != NULL && (k) != INVALID_HANDLE_VALUE) { \
+ RegCloseKey((k)); \
+ (k) = NULL; \
+ }
+
+static BOOL __apxRegistryCallback(APXHANDLE hObject, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ LPAPXREGISTRY lpReg;
+
+ lpReg = APXHANDLE_DATA(hObject);
+ switch (uMsg) {
+ case WM_CLOSE:
+ SAFE_CLOSE_KEY(lpReg->hCurrKey);
+ SAFE_CLOSE_KEY(lpReg->hRparamKey);
+ SAFE_CLOSE_KEY(lpReg->hSparamKey);
+ SAFE_CLOSE_KEY(lpReg->hUparamKey);
+ SAFE_CLOSE_KEY(lpReg->hRootKey);
+ SAFE_CLOSE_KEY(lpReg->hServKey);
+ SAFE_CLOSE_KEY(lpReg->hUserKey);
+ break;
+ default:
+ break;
+ }
+ return TRUE;
+}
+
+LPSTR __apxGetRegistrySzA(APXHANDLE hPool, HKEY hKey, LPCSTR szValueName)
+{
+ LPSTR szRet;
+ DWORD rc;
+ DWORD dwType;
+ DWORD dwSize;
+
+ rc = RegQueryValueExA(hKey, szValueName, NULL, &dwType, NULL, &dwSize);
+ if (rc != ERROR_SUCCESS || dwType != REG_SZ) {
+ return NULL;
+ }
+ if (!(szRet = apxPoolAlloc(hPool, dwSize)))
+ return NULL;
+ RegQueryValueExA(hKey, szValueName, NULL, &dwType, (LPBYTE)szRet, &dwSize);
+
+ return szRet;
+}
+
+LPWSTR __apxGetRegistrySzW(APXHANDLE hPool, HKEY hKey, LPCWSTR wsValueName)
+{
+ LPWSTR wsRet;
+ DWORD rc;
+ DWORD dwType;
+ DWORD dwSize;
+
+ rc = RegQueryValueExW(hKey, wsValueName, NULL, &dwType, NULL, &dwSize);
+ if (rc != ERROR_SUCCESS || dwType != REG_SZ) {
+ return NULL;
+ }
+ if (!(wsRet = apxPoolAlloc(hPool, dwSize * sizeof(WCHAR))))
+ return NULL;
+ RegQueryValueExW(hKey, wsValueName, NULL, &dwType, (LPBYTE)wsRet, &dwSize);
+
+ return wsRet;
+}
+
+BOOL __apxGetRegistryStrW(APXHANDLE hPool, HKEY hKey, LPCWSTR wsValueName,
+ LPWSTR lpRetval, DWORD dwMaxLen)
+{
+ DWORD rc;
+ DWORD dwType;
+ DWORD dwSize = dwMaxLen;
+
+ rc = RegQueryValueExW(hKey, wsValueName, NULL, &dwType, (LPBYTE)lpRetval, &dwSize);
+ if (rc != ERROR_SUCCESS || dwType != REG_SZ) {
+ lpRetval = L'\0';
+ return FALSE;
+ }
+ else
+ return TRUE;
+}
+
+LPBYTE __apxGetRegistryBinaryA(APXHANDLE hPool, HKEY hKey, LPCSTR szValueName,
+ LPDWORD lpdwLength)
+{
+ LPBYTE lpRet;
+ DWORD rc;
+ DWORD dwType;
+ DWORD dwSize;
+
+ rc = RegQueryValueExA(hKey, szValueName, NULL, &dwType, NULL, &dwSize);
+ if (rc != ERROR_SUCCESS || dwSize == 0) {
+ return NULL;
+ }
+ if (!(lpRet = apxPoolAlloc(hPool, dwSize)))
+ return NULL;
+ RegQueryValueExA(hKey, szValueName, NULL, &dwType, lpRet, &dwSize);
+ if (lpdwLength)
+ *lpdwLength = dwSize;
+ return lpRet;
+}
+
+LPBYTE __apxGetRegistryBinaryW(APXHANDLE hPool, HKEY hKey, LPCWSTR wsValueName,
+ LPDWORD lpdwLength)
+{
+ LPBYTE lpRet;
+ DWORD rc;
+ DWORD dwType;
+ DWORD dwSize;
+
+ rc = RegQueryValueExW(hKey, wsValueName, NULL, &dwType, NULL, &dwSize);
+ if (rc != ERROR_SUCCESS || dwSize == 0) {
+ return NULL;
+ }
+ if (!(lpRet = apxPoolAlloc(hPool, dwSize)))
+ return NULL;
+ RegQueryValueExW(hKey, wsValueName, NULL, &dwType, lpRet, &dwSize);
+ if (lpdwLength)
+ *lpdwLength = dwSize;
+
+ return lpRet;
+}
+
+DWORD __apxGetRegistryDwordW(APXHANDLE hPool, HKEY hKey, LPCWSTR wsValueName)
+{
+ DWORD dwRet;
+ DWORD rc;
+ DWORD dwType;
+ DWORD dwSize = sizeof(DWORD);
+
+ rc = RegQueryValueExW(hKey, wsValueName, NULL, &dwType, (LPBYTE)&dwRet, &dwSize);
+ if (rc != ERROR_SUCCESS || dwType != REG_DWORD) {
+ return 0xFFFFFFFF;
+ }
+
+ return dwRet;
+}
+
+
+APXHANDLE
+apxCreateRegistryW(APXHANDLE hPool, REGSAM samDesired,
+ LPCWSTR szRoot,
+ LPCWSTR szKeyName,
+ DWORD dwOptions)
+{
+ APXHANDLE hRegistry;
+ LPAPXREGISTRY lpReg;
+ /* maximum key length is 512 characters. */
+ WCHAR buff[SIZ_BUFLEN];
+ LONG rc = ERROR_SUCCESS;
+ HKEY hRootKey = NULL;
+ HKEY hUserKey = NULL;
+ HKEY hServKey = NULL;
+ HKEY hRparamKey = NULL;
+ HKEY hSparamKey = NULL;
+ HKEY hUparamKey = NULL;
+
+ if (!szKeyName || lstrlenW(szKeyName) > SIZ_RESMAX)
+ return NULL;
+ if (szRoot && lstrlenW(szRoot) > SIZ_RESMAX)
+ return NULL;
+
+ /* make the HKLM\\SOFTWARE key */
+ lstrcpyW(buff, REGSOFTWARE_ROOT);
+ if (szRoot)
+ lstrcatW(buff, szRoot);
+ else
+ lstrcatW(buff, REGAPACHE_ROOT);
+ lstrcatW(buff, REGSEPARATOR);
+ lstrcatW(buff, szKeyName);
+ /* Open or create the root key */
+ if (dwOptions & APXREG_SOFTWARE) {
+ if (samDesired & KEY_CREATE_SUB_KEY)
+ rc = RegCreateKeyExW(HKEY_LOCAL_MACHINE, buff, 0, NULL, 0,
+ samDesired, NULL,
+ &hRootKey, NULL);
+ else
+ rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, buff, 0,
+ samDesired, &hRootKey);
+ if (rc != ERROR_SUCCESS) {
+ hRootKey = NULL;
+ goto cleanup;
+ }
+ /* Open or create the root parameters key */
+ if (samDesired & KEY_CREATE_SUB_KEY)
+ rc = RegCreateKeyExW(hRootKey, REGPARAMS, 0, NULL, 0,
+ samDesired, NULL,
+ &hRparamKey, NULL);
+ else
+ rc = RegOpenKeyExW(hRootKey, REGPARAMS, 0,
+ samDesired, &hRparamKey);
+ if (rc != ERROR_SUCCESS) {
+ hRparamKey = NULL;
+ goto cleanup;
+ }
+ }
+
+ if (dwOptions & APXREG_USER) {
+ /* Open or create the users root key */
+ if (samDesired & KEY_CREATE_SUB_KEY)
+ rc = RegCreateKeyExW(HKEY_CURRENT_USER, buff, 0, NULL, 0,
+ samDesired, NULL,
+ &hUserKey, NULL);
+ else
+ rc = RegOpenKeyExW(HKEY_CURRENT_USER, buff, 0,
+ samDesired, &hUserKey);
+ if (rc != ERROR_SUCCESS) {
+ hUserKey = NULL;
+ goto cleanup;
+ }
+ /* Open or create the users parameters key */
+ if (samDesired & KEY_CREATE_SUB_KEY)
+ rc = RegCreateKeyExW(hUserKey, REGPARAMS, 0, NULL, 0,
+ samDesired, NULL,
+ &hUparamKey, NULL);
+ else
+ rc = RegOpenKeyExW(hUserKey, REGPARAMS, 0,
+ samDesired, &hUparamKey);
+ if (rc != ERROR_SUCCESS) {
+ hUparamKey = NULL;
+ goto cleanup;
+ }
+ }
+ /* Check if we need a service key */
+ if (dwOptions & APXREG_SERVICE) {
+ lstrcpyW(buff, REGSERVICE_ROOT);
+ lstrcatW(buff, szKeyName);
+ /* Service has to be created allready */
+ rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, buff, 0,
+ samDesired, &hServKey);
+ if (rc != ERROR_SUCCESS) {
+ hServKey = NULL;
+ goto cleanup;
+ }
+ /* Open or create the root parameters key */
+ if (samDesired & KEY_CREATE_SUB_KEY)
+ rc = RegCreateKeyExW(hServKey, REGPARAMS, 0, NULL, 0,
+ samDesired, NULL,
+ &hSparamKey, NULL);
+ else
+ rc = RegOpenKeyExW(hServKey, REGPARAMS, 0,
+ samDesired, &hSparamKey);
+ if (rc != ERROR_SUCCESS) {
+ hSparamKey = NULL;
+ goto cleanup;
+ }
+ }
+ hRegistry = apxHandleCreate(hPool, 0,
+ NULL, sizeof(APXREGISTRY),
+ __apxRegistryCallback);
+ if (IS_INVALID_HANDLE(hRegistry))
+ return NULL;
+ hRegistry->dwType = APXHANDLE_TYPE_REGISTRY;
+ lpReg = APXHANDLE_DATA(hRegistry);
+ lpReg->samOptions = samDesired;
+ lpReg->hRootKey = hRootKey;
+ lpReg->hUserKey = hUserKey;
+ lpReg->hServKey = hServKey;
+ lpReg->hRparamKey = hRparamKey;
+ lpReg->hUparamKey = hUparamKey;
+ lpReg->hSparamKey = hSparamKey;
+ TAILQ_INIT(&lpReg->lSubkeys);
+
+ SetLastError(rc);
+ return hRegistry;
+
+cleanup:
+ SAFE_CLOSE_KEY(hRparamKey);
+ SAFE_CLOSE_KEY(hSparamKey);
+ SAFE_CLOSE_KEY(hUparamKey);
+ SAFE_CLOSE_KEY(hRootKey);
+ SAFE_CLOSE_KEY(hServKey);
+ SAFE_CLOSE_KEY(hUserKey);
+
+ SetLastError(rc);
+ return NULL;
+}
+
+APXHANDLE
+apxCreateRegistryA(APXHANDLE hPool, REGSAM samDesired,
+ LPCSTR szRoot,
+ LPCSTR szKeyName,
+ DWORD dwOptions)
+{
+ WCHAR wcRoot[SIZ_RESLEN];
+ WCHAR wcKey[SIZ_RESLEN];
+ LPWSTR wsRoot = NULL;
+ if (szRoot) {
+ AsciiToWide(szRoot, wcRoot);
+ wsRoot = wcRoot;
+ }
+ AsciiToWide(szKeyName, wcKey);
+ return apxCreateRegistryW(hPool, samDesired, wsRoot, wcKey, dwOptions);
+}
+
+LPSTR
+apxRegistryGetStringA(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCSTR szSubkey, LPCSTR szValueName)
+{
+ LPAPXREGISTRY lpReg;
+ HKEY hKey, hSub = NULL;
+ if (IS_INVALID_HANDLE(hRegistry) ||
+ hRegistry->dwType != APXHANDLE_TYPE_REGISTRY)
+ return NULL;
+ lpReg = APXHANDLE_DATA(hRegistry);
+
+ REG_GET_KEY(lpReg, dwFrom, hKey);
+ if (!hKey)
+ return NULL;
+ if (szSubkey) {
+ SAFE_CLOSE_KEY(lpReg->hCurrKey);
+ if (RegOpenKeyExA(hKey, szSubkey, 0,
+ lpReg->samOptions, &hSub) != ERROR_SUCCESS)
+ return NULL;
+ lpReg->hCurrKey = hSub;
+ hKey = hSub;
+ }
+ lpReg->pCurrVal = __apxGetRegistrySzA(hRegistry->hPool, hKey, szValueName);
+
+ return lpReg->pCurrVal;
+}
+
+LPWSTR
+apxRegistryGetStringW(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCWSTR szSubkey, LPCWSTR szValueName)
+{
+ LPAPXREGISTRY lpReg;
+ HKEY hKey, hSub = NULL;
+ if (IS_INVALID_HANDLE(hRegistry) ||
+ hRegistry->dwType != APXHANDLE_TYPE_REGISTRY)
+ return NULL;
+ lpReg = APXHANDLE_DATA(hRegistry);
+
+ REG_GET_KEY(lpReg, dwFrom, hKey);
+ if (!hKey)
+ return NULL;
+ if (szSubkey) {
+ SAFE_CLOSE_KEY(lpReg->hCurrKey);
+ if (RegOpenKeyExW(hKey, szSubkey, 0,
+ lpReg->samOptions, &hSub) != ERROR_SUCCESS)
+ return NULL;
+ lpReg->hCurrKey = hSub;
+ hKey = hSub;
+ }
+ lpReg->pCurrVal = __apxGetRegistrySzW(hRegistry->hPool, hKey, szValueName);
+
+ return lpReg->pCurrVal;
+}
+
+LPBYTE
+apxRegistryGetBinaryA(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCSTR szSubkey, LPCSTR szValueName,
+ LPBYTE lpData, LPDWORD lpdwLength)
+{
+ LPAPXREGISTRY lpReg;
+ HKEY hKey, hSub = NULL;
+ if (IS_INVALID_HANDLE(hRegistry) ||
+ hRegistry->dwType != APXHANDLE_TYPE_REGISTRY)
+ return NULL;
+ lpReg = APXHANDLE_DATA(hRegistry);
+ REG_GET_KEY(lpReg, dwFrom, hKey);
+ if (!hKey)
+ return NULL;
+ if (szSubkey) {
+ SAFE_CLOSE_KEY(lpReg->hCurrKey);
+ if (RegOpenKeyExA(hKey, szSubkey, 0,
+ lpReg->samOptions, &hSub) != ERROR_SUCCESS)
+ return NULL;
+ lpReg->hCurrKey = hSub;
+ hKey = hSub;
+ }
+ if (lpData && lpdwLength && *lpdwLength) {
+ DWORD rc, dwType = REG_BINARY;
+ rc = RegQueryValueExA(hKey, szValueName, NULL, &dwType, lpData, lpdwLength);
+ if (rc != ERROR_SUCCESS || dwType != REG_BINARY) {
+ ErrorMessage(NULL, FALSE);
+ return NULL;
+ }
+ lpReg->pCurrVal = lpData;
+ }
+ else {
+ lpReg->pCurrVal = __apxGetRegistryBinaryA(hRegistry->hPool, hKey, szValueName, lpdwLength);
+ }
+
+ return lpReg->pCurrVal;
+}
+
+LPBYTE
+apxRegistryGetBinaryW(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCWSTR szSubkey, LPCWSTR szValueName,
+ LPBYTE lpData, LPDWORD lpdwLength)
+{
+ LPAPXREGISTRY lpReg;
+ HKEY hKey, hSub = NULL;
+ if (IS_INVALID_HANDLE(hRegistry) ||
+ hRegistry->dwType != APXHANDLE_TYPE_REGISTRY)
+ return NULL;
+ lpReg = APXHANDLE_DATA(hRegistry);
+
+ REG_GET_KEY(lpReg, dwFrom, hKey);
+ if (!hKey)
+ return NULL;
+ if (szSubkey) {
+ SAFE_CLOSE_KEY(lpReg->hCurrKey);
+ if (RegOpenKeyExW(hKey, szSubkey, 0,
+ lpReg->samOptions, &hSub) != ERROR_SUCCESS)
+ return NULL;
+ lpReg->hCurrKey = hSub;
+ hKey = hSub;
+ }
+ if (lpData && lpdwLength && *lpdwLength) {
+ DWORD rc, dwType = REG_BINARY;
+ rc = RegQueryValueExW(hKey, szValueName, NULL, &dwType, lpData, lpdwLength);
+ if (rc != ERROR_SUCCESS || dwType != REG_BINARY) {
+ return NULL;
+ }
+ lpReg->pCurrVal = lpData;
+ }
+ else {
+ lpReg->pCurrVal = __apxGetRegistryBinaryW(hRegistry->hPool, hKey, szValueName, lpdwLength);
+ }
+ return lpReg->pCurrVal;
+}
+
+DWORD
+apxRegistryGetNumberW(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCWSTR szSubkey, LPCWSTR szValueName)
+{
+ LPAPXREGISTRY lpReg;
+ HKEY hKey, hSub = NULL;
+ DWORD dwRval, rl;
+ DWORD rc, dwType = REG_DWORD;
+
+ if (IS_INVALID_HANDLE(hRegistry) ||
+ hRegistry->dwType != APXHANDLE_TYPE_REGISTRY)
+ return 0;
+ lpReg = APXHANDLE_DATA(hRegistry);
+
+ REG_GET_KEY(lpReg, dwFrom, hKey);
+ if (!hKey)
+ return 0;
+ if (szSubkey) {
+ SAFE_CLOSE_KEY(lpReg->hCurrKey);
+ if (RegOpenKeyExW(hKey, szSubkey, 0,
+ lpReg->samOptions, &hSub) != ERROR_SUCCESS)
+ return 0;
+ lpReg->hCurrKey = hSub;
+ hKey = hSub;
+ }
+ rl = sizeof(DWORD);
+ rc = RegQueryValueExW(hKey, szValueName, NULL, &dwType, (LPBYTE)&dwRval, &rl);
+ if (rc != ERROR_SUCCESS || dwType != REG_DWORD)
+ return 0;
+ else
+ return dwRval;
+}
+
+LPWSTR
+apxRegistryGetMzStrW(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCWSTR szSubkey, LPCWSTR szValueName,
+ LPWSTR lpData, LPDWORD lpdwLength)
+{
+ LPAPXREGISTRY lpReg;
+ HKEY hKey, hSub = NULL;
+ if (IS_INVALID_HANDLE(hRegistry) ||
+ hRegistry->dwType != APXHANDLE_TYPE_REGISTRY)
+ return NULL;
+ lpReg = APXHANDLE_DATA(hRegistry);
+
+ REG_GET_KEY(lpReg, dwFrom, hKey);
+ if (!hKey)
+ return NULL;
+ if (szSubkey) {
+ SAFE_CLOSE_KEY(lpReg->hCurrKey);
+ if (RegOpenKeyExW(hKey, szSubkey, 0,
+ lpReg->samOptions, &hSub) != ERROR_SUCCESS)
+ return NULL;
+ lpReg->hCurrKey = hSub;
+ hKey = hSub;
+ }
+ if (lpData && lpdwLength && *lpdwLength) {
+ DWORD rc, dwType = REG_MULTI_SZ;
+ rc = RegQueryValueExW(hKey, szValueName, NULL, &dwType, (BYTE *)lpData, lpdwLength);
+ if (rc != ERROR_SUCCESS || dwType != REG_MULTI_SZ) {
+ return NULL;
+ }
+ lpReg->pCurrVal = lpData;
+ }
+ else {
+ lpReg->pCurrVal = __apxGetRegistryBinaryW(hRegistry->hPool, hKey, szValueName, lpdwLength);
+ if (lpReg->pCurrVal && lpdwLength)
+ *lpdwLength = *lpdwLength * sizeof(WCHAR);
+ }
+ return lpReg->pCurrVal;
+}
+
+BOOL
+apxRegistrySetBinaryA(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCSTR szSubkey, LPCSTR szValueName,
+ const LPBYTE lpData, DWORD dwLength)
+{
+ LPAPXREGISTRY lpReg;
+ HKEY hKey, hSub = NULL;
+ DWORD dwType = REG_BINARY;
+ if (IS_INVALID_HANDLE(hRegistry) ||
+ hRegistry->dwType != APXHANDLE_TYPE_REGISTRY)
+ return FALSE;
+ lpReg = APXHANDLE_DATA(hRegistry);
+
+ REG_GET_KEY(lpReg, dwFrom, hKey);
+ if (!hKey)
+ return FALSE;
+
+ if (szSubkey) {
+ SAFE_CLOSE_KEY(lpReg->hCurrKey);
+ if (RegCreateKeyExA(hKey, szSubkey, 0,
+ NULL, 0, lpReg->samOptions,
+ NULL, &hSub, NULL) != ERROR_SUCCESS)
+ return FALSE;
+ lpReg->hCurrKey = hSub;
+ hKey = hSub;
+ }
+ if (RegSetValueExA(hKey, szValueName, 0, dwType,
+ lpData, dwLength) != ERROR_SUCCESS)
+ return FALSE;
+
+ return TRUE;
+}
+
+BOOL
+apxRegistrySetBinaryW(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCWSTR szSubkey, LPCWSTR szValueName,
+ const LPBYTE lpData, DWORD dwLength)
+{
+ LPAPXREGISTRY lpReg;
+ HKEY hKey, hSub = NULL;
+ DWORD dwType = REG_BINARY;
+ if (IS_INVALID_HANDLE(hRegistry) ||
+ hRegistry->dwType != APXHANDLE_TYPE_REGISTRY)
+ return FALSE;
+ lpReg = APXHANDLE_DATA(hRegistry);
+
+ REG_GET_KEY(lpReg, dwFrom, hKey);
+ if (!hKey)
+ return FALSE;
+
+ if (szSubkey) {
+ SAFE_CLOSE_KEY(lpReg->hCurrKey);
+ if (RegCreateKeyExW(hKey, szSubkey, 0,
+ NULL, 0, lpReg->samOptions,
+ NULL, &hSub, NULL) != ERROR_SUCCESS)
+ return FALSE;
+ lpReg->hCurrKey = hSub;
+ hKey = hSub;
+ }
+ if (RegSetValueExW(hKey, szValueName, 0, dwType,
+ lpData, dwLength) != ERROR_SUCCESS)
+ return FALSE;
+
+ return TRUE;
+}
+
+BOOL
+apxRegistrySetMzStrW(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCWSTR szSubkey, LPCWSTR szValueName,
+ LPCWSTR lpData, DWORD dwLength)
+{
+ LPAPXREGISTRY lpReg;
+ HKEY hKey, hSub = NULL;
+ DWORD dwType = REG_MULTI_SZ;
+ if (IS_INVALID_HANDLE(hRegistry) ||
+ hRegistry->dwType != APXHANDLE_TYPE_REGISTRY)
+ return FALSE;
+ lpReg = APXHANDLE_DATA(hRegistry);
+
+ REG_GET_KEY(lpReg, dwFrom, hKey);
+ if (!hKey)
+ return FALSE;
+
+ if (szSubkey) {
+ SAFE_CLOSE_KEY(lpReg->hCurrKey);
+ if (RegCreateKeyExW(hKey, szSubkey, 0,
+ NULL, 0, lpReg->samOptions,
+ NULL, &hSub, NULL) != ERROR_SUCCESS)
+ return FALSE;
+ lpReg->hCurrKey = hSub;
+ hKey = hSub;
+ }
+ if (RegSetValueExW(hKey, szValueName, 0, dwType,
+ (const BYTE *)lpData, dwLength) != ERROR_SUCCESS)
+ return FALSE;
+
+ return TRUE;
+}
+
+BOOL
+apxRegistrySetStrA(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCSTR szSubkey, LPCSTR szValueName,
+ LPCSTR szValue)
+{
+ LPAPXREGISTRY lpReg;
+ HKEY hKey, hSub = NULL;
+ DWORD dwType = REG_SZ;
+ if (IS_INVALID_HANDLE(hRegistry) ||
+ hRegistry->dwType != APXHANDLE_TYPE_REGISTRY)
+ return FALSE;
+ lpReg = APXHANDLE_DATA(hRegistry);
+
+ REG_GET_KEY(lpReg, dwFrom, hKey);
+ if (!hKey)
+ return FALSE;
+
+ if (szSubkey) {
+ SAFE_CLOSE_KEY(lpReg->hCurrKey);
+ if (RegCreateKeyExA(hKey, szSubkey, 0,
+ NULL, 0, lpReg->samOptions,
+ NULL, &hSub, NULL) != ERROR_SUCCESS)
+ return FALSE;
+ lpReg->hCurrKey = hSub;
+ hKey = hSub;
+ }
+ if (!szValue || !lstrlenA(szValue)) {
+ if (RegDeleteValueA(hKey, szValueName) != ERROR_SUCCESS)
+ return FALSE;
+ }
+ else if (RegSetValueExA(hKey, szValueName, 0, dwType,
+ (LPBYTE)szValue, lstrlenA(szValue)) != ERROR_SUCCESS)
+ return FALSE;
+
+ return TRUE;
+}
+
+BOOL
+apxRegistrySetStrW(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCWSTR szSubkey, LPCWSTR szValueName,
+ LPCWSTR szValue)
+{
+ LPAPXREGISTRY lpReg;
+ HKEY hKey, hSub = NULL;
+ DWORD dwType = REG_SZ;
+ if (IS_INVALID_HANDLE(hRegistry) ||
+ hRegistry->dwType != APXHANDLE_TYPE_REGISTRY)
+ return FALSE;
+ lpReg = APXHANDLE_DATA(hRegistry);
+
+ REG_GET_KEY(lpReg, dwFrom, hKey);
+ if (!hKey)
+ return FALSE;
+
+ if (szSubkey) {
+ SAFE_CLOSE_KEY(lpReg->hCurrKey);
+ if (RegCreateKeyExW(hKey, szSubkey, 0,
+ NULL, 0, lpReg->samOptions,
+ NULL, &hSub, NULL) != ERROR_SUCCESS)
+ return FALSE;
+ lpReg->hCurrKey = hSub;
+ hKey = hSub;
+ }
+ if (!szValue || !lstrlenW(szValue)) {
+ if (RegDeleteValueW(hKey, szValueName) != ERROR_SUCCESS)
+ return FALSE;
+ }
+ else if (RegSetValueExW(hKey, szValueName, 0, dwType,
+ (LPBYTE)szValue,
+ lstrlenW(szValue) * sizeof(WCHAR)) != ERROR_SUCCESS)
+ return FALSE;
+
+ return TRUE;
+}
+
+BOOL
+apxRegistrySetNumW(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCWSTR szSubkey, LPCWSTR szValueName,
+ DWORD dwValue)
+{
+ LPAPXREGISTRY lpReg;
+ HKEY hKey, hSub = NULL;
+ DWORD dwType = REG_DWORD;
+ if (IS_INVALID_HANDLE(hRegistry) ||
+ hRegistry->dwType != APXHANDLE_TYPE_REGISTRY)
+ return FALSE;
+ lpReg = APXHANDLE_DATA(hRegistry);
+
+ REG_GET_KEY(lpReg, dwFrom, hKey);
+ if (!hKey)
+ return FALSE;
+
+ if (szSubkey) {
+ SAFE_CLOSE_KEY(lpReg->hCurrKey);
+ if (RegCreateKeyExW(hKey, szSubkey, 0,
+ NULL, 0, lpReg->samOptions,
+ NULL, &hSub, NULL) != ERROR_SUCCESS)
+ return FALSE;
+ lpReg->hCurrKey = hSub;
+ hKey = hSub;
+ }
+ if (RegSetValueExW(hKey, szValueName, 0, dwType,
+ (LPBYTE)&dwValue,
+ sizeof(DWORD)) != ERROR_SUCCESS)
+ return FALSE;
+
+ return TRUE;
+}
+
+
+BOOL
+apxRegistryDeleteW(APXHANDLE hRegistry, DWORD dwFrom,
+ LPCWSTR szSubkey, LPCWSTR szValueName)
+{
+ LPAPXREGISTRY lpReg;
+ HKEY hKey, hSub = NULL;
+ DWORD dwType = REG_SZ;
+ if (IS_INVALID_HANDLE(hRegistry) ||
+ hRegistry->dwType != APXHANDLE_TYPE_REGISTRY)
+ return FALSE;
+ lpReg = APXHANDLE_DATA(hRegistry);
+
+ REG_GET_KEY(lpReg, dwFrom, hKey);
+ if (!hKey)
+ return FALSE;
+
+ if (szSubkey) {
+ SAFE_CLOSE_KEY(lpReg->hCurrKey);
+ if (RegOpenKeyExW(hKey, szSubkey, 0,
+ lpReg->samOptions, &hSub) != ERROR_SUCCESS)
+ return FALSE;
+ lpReg->hCurrKey = hSub;
+ hKey = hSub;
+ }
+ if (RegDeleteValueW(hKey, szValueName) != ERROR_SUCCESS)
+ return FALSE;
+
+ return TRUE;
+}
+
+
+BOOL
+apxDeleteRegistryW(LPCWSTR szRoot,
+ LPCWSTR szKeyName,
+ BOOL bDeleteEmpty)
+{
+ WCHAR buff[SIZ_BUFLEN];
+ BOOL rv;
+
+ if (!szKeyName || lstrlenW(szKeyName) > SIZ_RESMAX)
+ return FALSE;
+ if (szRoot && lstrlenW(szRoot) > SIZ_RESMAX)
+ return FALSE;
+
+ lstrcpyW(buff, REGSOFTWARE_ROOT);
+ if (szRoot)
+ lstrcatW(buff, szRoot);
+ else
+ lstrcatW(buff, REGAPACHE_ROOT);
+ lstrcatW(buff, REGSEPARATOR);
+ lstrcatW(buff, szKeyName);
+
+ rv = SHDeleteKeyW(HKEY_LOCAL_MACHINE, buff);
+ rv += SHDeleteKeyW(HKEY_CURRENT_USER, buff);
+
+ if (bDeleteEmpty) {
+ lstrcpyW(buff, REGSOFTWARE_ROOT);
+ if (szRoot)
+ lstrcatW(buff, szRoot);
+ else
+ lstrcatW(buff, REGAPACHE_ROOT);
+
+ SHDeleteEmptyKeyW(HKEY_LOCAL_MACHINE, buff);
+ SHDeleteEmptyKeyW(HKEY_CURRENT_USER, buff);
+ }
+ return rv;
+}
+
+BOOL
+apxDeleteRegistryA(LPCSTR szRoot,
+ LPCSTR szKeyName,
+ BOOL bDeleteEmpty)
+{
+ WCHAR wcRoot[SIZ_RESLEN];
+ WCHAR wcKey[SIZ_RESLEN];
+ LPWSTR wsRoot = NULL;
+ if (szRoot) {
+ AsciiToWide(szRoot, wcRoot);
+ wsRoot = wcRoot;
+ }
+ AsciiToWide(szKeyName, wcKey);
+
+ return apxDeleteRegistryW(wsRoot, wcKey, bDeleteEmpty);
+}
+
+
+LPWSTR apxGetJavaSoftHome(APXHANDLE hPool, BOOL bPreferJre)
+{
+ LPWSTR wsJhome, off;
+ DWORD err, dwLen;
+ HKEY hKey;
+ WCHAR wsBuf[SIZ_BUFLEN];
+ WCHAR wsKey[SIZ_RESLEN];
+#if 1 /* XXX: Add that customizable using function call arg */
+ if (!bPreferJre && (wsJhome = __apxGetEnvironmentVariableW(hPool, JAVA_HOME)))
+ return wsJhome;
+#endif
+ lstrcpyW(wsKey, JAVA_CURRENT);
+ if (bPreferJre)
+ lstrcpyW(wsBuf, JRE_REGKEY);
+ else
+ lstrcpyW(wsBuf, JDK_REGKEY);
+ dwLen = lstrlenW(wsBuf);
+ off = &wsBuf[dwLen];
+ dwLen = SIZ_RESMAX;
+ if ((err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, wsBuf,
+ 0, KEY_READ, &hKey)) != ERROR_SUCCESS) {
+ return NULL;
+ }
+ if ((err = RegQueryValueExW(hKey, JAVA_CURRENT, NULL, NULL,
+ (LPBYTE)off,
+ &dwLen)) != ERROR_SUCCESS) {
+ RegCloseKey(hKey);
+ return NULL;
+ }
+ RegCloseKey(hKey);
+ if ((err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, wsBuf,
+ 0, KEY_READ, &hKey)) != ERROR_SUCCESS) {
+ return NULL;
+ }
+ wsJhome = __apxGetRegistrySzW(hPool, hKey, JAVAHOME);
+ if (wsJhome)
+ SetEnvironmentVariableW(JAVA_HOME, wsJhome);
+ RegCloseKey(hKey);
+
+ return wsJhome;
+}
+
+LPWSTR apxGetJavaSoftRuntimeLib(APXHANDLE hPool)
+{
+ LPWSTR wsRtlib, off;
+ DWORD err, dwLen = SIZ_RESLEN;
+ HKEY hKey;
+ WCHAR wsBuf[SIZ_BUFLEN];
+
+ lstrcpyW(wsBuf, JRE_REGKEY);
+
+ dwLen = lstrlenW(wsBuf);
+ off = &wsBuf[dwLen];
+ dwLen = SIZ_RESLEN;
+ if ((err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, wsBuf,
+ 0, KEY_READ, &hKey)) != ERROR_SUCCESS) {
+ return NULL;
+ }
+ if ((err = RegQueryValueExW(hKey, JAVA_CURRENT, NULL, NULL,
+ (LPBYTE)off,
+ &dwLen)) != ERROR_SUCCESS) {
+ RegCloseKey(hKey);
+ return NULL;
+ }
+ RegCloseKey(hKey);
+ if ((err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, wsBuf,
+ 0, KEY_READ, &hKey)) != ERROR_SUCCESS) {
+ return NULL;
+ }
+ wsRtlib = __apxGetRegistrySzW(hPool, hKey, JAVA_RUNTIME);
+ RegCloseKey(hKey);
+
+ return wsRtlib;
+}
+
+/* Service Registry helper functions */
+
+BOOL apxRegistryEnumServices(LPAPXREGENUM lpEnum, LPAPXSERVENTRY lpEntry)
+{
+ DWORD rc, dwLength = SIZ_RESLEN;
+
+ if (IS_INVALID_HANDLE(lpEnum->hServicesKey)) {
+ rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, REGSERVICE_ROOT, 0,
+ KEY_READ, &(lpEnum->hServicesKey));
+ if (rc != ERROR_SUCCESS) {
+ return FALSE;
+ }
+ rc = RegQueryInfoKeyW(lpEnum->hServicesKey,
+ NULL,
+ NULL,
+ NULL,
+ &lpEnum->cSubKeys,
+ &lpEnum->cbMaxSubKey,
+ &lpEnum->cchMaxClass,
+ &lpEnum->cValues,
+ &lpEnum->cchMaxValue,
+ &lpEnum->cbMaxValueData,
+ NULL,
+ NULL);
+ /* TODO: add dynamic maxsubkey length */
+ if (rc != ERROR_SUCCESS || lpEnum->cbMaxSubKey > SIZ_RESLEN) {
+ SAFE_CLOSE_KEY(lpEnum->hServicesKey);
+ return FALSE;
+ }
+ }
+ if (lpEnum->dwIndex >= lpEnum->cSubKeys) {
+ SAFE_CLOSE_KEY(lpEnum->hServicesKey);
+ return FALSE;
+ }
+ rc = RegEnumKeyExW(lpEnum->hServicesKey,
+ lpEnum->dwIndex++,
+ lpEntry->szServiceName,
+ &dwLength,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ if (rc != ERROR_SUCCESS) {
+ SAFE_CLOSE_KEY(lpEnum->hServicesKey);
+ return FALSE;
+ }
+ else {
+ HKEY hKey;
+ rc = RegOpenKeyExW(lpEnum->hServicesKey, lpEntry->szServiceName,
+ 0, KEY_READ, &hKey);
+ if (rc != ERROR_SUCCESS) {
+ SAFE_CLOSE_KEY(lpEnum->hServicesKey);
+ return FALSE;
+ }
+ __apxGetRegistryStrW(NULL, hKey, REGDESCRIPTION,
+ lpEntry->szServiceDescription, SIZ_DESLEN);
+ __apxGetRegistryStrW(NULL, hKey, REGSERVICE_USER,
+ lpEntry->szObjectName, SIZ_RESLEN);
+ lpEntry->dwStart = __apxGetRegistryDwordW(NULL, hKey, REGSERVICE_START);
+ RegCloseKey(hKey);
+
+ }
+ return TRUE;
+}
+
+/* We could use the ChangeServiceConfig2 on WIN2K+
+ * For now use the registry.
+ */
+BOOL apxSetServiceDescriptionW(LPCWSTR szServiceName, LPCWSTR szDescription)
+{
+ HKEY hKey;
+ WCHAR wcName[SIZ_RESLEN];
+ DWORD rc;
+
+ if (lstrlenW(szServiceName) > SIZ_RESMAX)
+ return FALSE;
+ lstrcpyW(wcName, REGSERVICE_ROOT);
+ lstrcatW(wcName, szServiceName);
+
+ rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, wcName, 0, KEY_WRITE, &hKey);
+ if (rc != ERROR_SUCCESS) {
+ return FALSE;
+ }
+
+ rc = RegSetValueExW(hKey, REGDESCRIPTION, 0, REG_SZ, (CONST BYTE *)szDescription,
+ lstrlenW(szDescription) * sizeof(WCHAR));
+ SAFE_CLOSE_KEY(hKey);
+
+ return rc = ERROR_SUCCESS;
+}
+
+BOOL apxGetServiceDescriptionW(LPCWSTR szServiceName, LPWSTR szDescription,
+ DWORD dwDescriptionLength)
+{
+ HKEY hKey;
+ WCHAR wcName[SIZ_RESLEN];
+ DWORD rc, l = dwDescriptionLength * sizeof(WCHAR);
+ DWORD t = REG_SZ;
+ if (lstrlenW(szServiceName) > SIZ_RESMAX)
+ return FALSE;
+ lstrcpyW(wcName, REGSERVICE_ROOT);
+ lstrcatW(wcName, szServiceName);
+
+ rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, wcName, 0, KEY_READ, &hKey);
+ if (rc != ERROR_SUCCESS) {
+ return FALSE;
+ }
+ rc = RegQueryValueExW(hKey, REGDESCRIPTION, NULL, &t, (BYTE *)szDescription,
+ &l);
+ SAFE_CLOSE_KEY(hKey);
+ if (rc == ERROR_SUCCESS && t == REG_SZ)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+BOOL apxGetServiceUserW(LPCWSTR szServiceName, LPWSTR szUser,
+ DWORD dwUserLength)
+{
+ HKEY hKey;
+ WCHAR wcName[SIZ_RESLEN];
+ DWORD rc, l = dwUserLength * sizeof(WCHAR);
+ DWORD t = REG_SZ;
+ if (lstrlenW(szServiceName) > SIZ_RESMAX)
+ return FALSE;
+ lstrcpyW(wcName, REGSERVICE_ROOT);
+ lstrcatW(wcName, szServiceName);
+
+ rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, wcName, 0, KEY_READ, &hKey);
+ if (rc != ERROR_SUCCESS) {
+ return FALSE;
+ }
+ rc = RegQueryValueExW(hKey, REGSERVICE_USER, NULL, &t, (BYTE *)szUser,
+ &l);
+ SAFE_CLOSE_KEY(hKey);
+ if (rc == ERROR_SUCCESS && t == REG_SZ)
+ return TRUE;
+ else
+ return FALSE;
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/rprocess.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/rprocess.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/rprocess.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,938 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apxwin.h"
+#include "private.h"
+
+#define CHILD_RUNNING 0x0001
+#define CHILD_INITIALIZED 0x0002
+#define CHILD_MAINTREAD_FINISHED 0x0004
+#define PROC_INITIALIZED 0x0008
+#define CHILD_TERMINATE_CODE 19640323 /* Could be any value like my birthday ;-)*/
+
+DYNOLAD_TYPE_DECLARE(CreateRemoteThread,
+ __stdcall, HANDLE)(HANDLE, LPSECURITY_ATTRIBUTES,
+ DWORD, LPTHREAD_START_ROUTINE,
+ LPVOID, DWORD, LPDWORD);
+
+DYNOLAD_TYPE_DECLARE(ExitProcess, __stdcall, void)(UINT);
+
+#define CHECK_IF_ACTIVE(proc) \
+ APXMACRO_BEGIN \
+ DWORD __st; \
+ if (!GetExitCodeProcess((proc)->stProcInfo.hProcess, &__st) || \
+ (__st != STILL_ACTIVE)) \
+ goto cleanup; \
+ APXMACRO_END
+
+#define SAVE_STD_HANDLES(p) \
+ APXMACRO_BEGIN \
+ if ((p)->bSaveHandles) { \
+ (p)->hParentStdSave[0] = GetStdHandle(STD_INPUT_HANDLE); \
+ (p)->hParentStdSave[1] = GetStdHandle(STD_OUTPUT_HANDLE); \
+ (p)->hParentStdSave[2] = GetStdHandle(STD_ERROR_HANDLE); \
+ } APXMACRO_END
+
+#define RESTORE_STD_HANDLES(p) \
+ APXMACRO_BEGIN \
+ if ((p)->bSaveHandles) { \
+ SetStdHandle(STD_INPUT_HANDLE, (p)->hParentStdSave[0]); \
+ SetStdHandle(STD_OUTPUT_HANDLE, (p)->hParentStdSave[1]); \
+ SetStdHandle(STD_ERROR_HANDLE, (p)->hParentStdSave[2]); \
+ } APXMACRO_END
+
+#define REDIRECT_STD_HANDLES(p) \
+ APXMACRO_BEGIN \
+ if ((p)->bSaveHandles) { \
+ SetStdHandle(STD_INPUT_HANDLE, (p)->hChildStdInp); \
+ SetStdHandle(STD_OUTPUT_HANDLE, (p)->hChildStdOut); \
+ SetStdHandle(STD_ERROR_HANDLE, (p)->hChildStdErr); \
+ } APXMACRO_END
+
+typedef struct APXPROCESS {
+ DWORD dwChildStatus;
+ DWORD dwOptions;
+ PROCESS_INFORMATION stProcInfo;
+ /* Size of chars for ANSI/Unicode programs */
+ DWORD chSize;
+ /* application working path */
+ LPWSTR szWorkingPath;
+ /* executable name */
+ LPWSTR szApplicationExec;
+ /* command line (first arg is program name for argv[0]) */
+ LPWSTR szCommandLine;
+ LPWSTR lpEnvironment;
+ /* set of child inherited pipes */
+ HANDLE hChildStdInp;
+ HANDLE hChildStdOut;
+ HANDLE hChildStdErr;
+ /* parent ends of child pipes */
+ HANDLE hChildInpWr;
+ HANDLE hChildOutRd;
+ HANDLE hChildErrRd;
+ /* Saved console pipes */
+ HANDLE hParentStdSave[3];
+ HANDLE hWorkerThreads[3];
+ HANDLE hUserToken;
+ HANDLE hCurrentProcess;
+ BOOL bSaveHandles;
+ /** callback function */
+ LPAPXFNCALLBACK fnUserCallback;
+ LPSECURITY_ATTRIBUTES lpSA;
+ LPVOID lpSD;
+ BYTE bSD[SECURITY_DESCRIPTOR_MIN_LENGTH];
+ BYTE bSA[sizeof(SECURITY_ATTRIBUTES)];
+
+} APXPROCESS, *LPAPXPROCESS;
+
+/** Process worker thread
+ * Monitors the process thread
+ */
+static DWORD WINAPI __apxProcWorkerThread(LPVOID lpParameter)
+{
+ APXHANDLE hProcess = (APXHANDLE)lpParameter;
+ LPAPXPROCESS lpProc;
+ DWORD dwExitCode = 0;
+
+ lpProc = APXHANDLE_DATA(hProcess);
+ /* Wait util a process has finished its initialization.
+ */
+ WaitForInputIdle(lpProc->stProcInfo.hProcess, INFINITE);
+ lpProc->dwChildStatus |= CHILD_INITIALIZED;
+ /* Wait until the child process exits */
+ if (WaitForSingleObject(lpProc->stProcInfo.hProcess,
+ INFINITE) == WAIT_OBJECT_0) {
+ lpProc->dwChildStatus |= CHILD_MAINTREAD_FINISHED;
+#if 0
+ if (hProcess->fnCallback)
+ (*hProcess->fnCallback)(hProcess, WM_QUIT, (WPARAM)dwExitCode, 0);
+ lpProc->dwChildStatus &= ~CHILD_RUNNING;
+ GetExitCodeProcess(lpProc->stProcInfo.hProcess, &dwExitCode);
+
+ /* Close that handle */
+#endif
+ }
+ ExitThread(0);
+ return 0;
+}
+
+static DWORD WINAPI __apxProcStdoutThread(LPVOID lpParameter)
+{
+ APXHANDLE hProcess = (APXHANDLE)lpParameter;
+ LPAPXPROCESS lpProc;
+ APXCALLHOOK *lpCall;
+ INT ch;
+ DWORD dwReaded;
+ lpProc = APXHANDLE_DATA(hProcess);
+ while (lpProc->dwChildStatus & CHILD_RUNNING) {
+ ch = 0;
+ if (!ReadFile(lpProc->hChildOutRd, &ch, lpProc->chSize,
+ &dwReaded, NULL) || !dwReaded) {
+
+ break;
+ }
+ if (lpProc->fnUserCallback)
+ (*lpProc->fnUserCallback)(hProcess, WM_CHAR, (WPARAM)ch, (LPARAM)0);
+ TAILQ_FOREACH(lpCall, &hProcess->lCallbacks, queue) {
+ (*lpCall->fnCallback)(hProcess, WM_CHAR, (WPARAM)ch, (LPARAM)0);
+ }
+ dwReaded = 0;
+ SwitchToThread();
+ }
+ ExitThread(0);
+ return 0;
+}
+
+static DWORD WINAPI __apxProcStderrThread(LPVOID lpParameter)
+{
+ APXHANDLE hProcess = (APXHANDLE)lpParameter;
+ LPAPXPROCESS lpProc;
+ APXCALLHOOK *lpCall;
+ INT ch;
+ DWORD dwReaded;
+ lpProc = APXHANDLE_DATA(hProcess);
+ while (lpProc->dwChildStatus & CHILD_RUNNING) {
+ if (!ReadFile(lpProc->hChildErrRd, &ch, lpProc->chSize,
+ &dwReaded, NULL) || !dwReaded) {
+
+ break;
+ }
+ if (lpProc->fnUserCallback)
+ (*lpProc->fnUserCallback)(hProcess, WM_CHAR, (WPARAM)ch, (LPARAM)1);
+ TAILQ_FOREACH(lpCall, &hProcess->lCallbacks, queue) {
+ (*lpCall->fnCallback)(hProcess, WM_CHAR, (WPARAM)ch, (LPARAM)1);
+ }
+
+ dwReaded = 0;
+ SwitchToThread();
+ }
+
+ ExitThread(0);
+ return 0;
+}
+
+static DWORD __apxProcessPutc(LPAPXPROCESS lpProc, INT ch, DWORD dwSize)
+{
+ if (lpProc->dwChildStatus & CHILD_RUNNING) {
+ DWORD wr = 0;
+ if (WriteFile(lpProc->hChildInpWr, &ch, dwSize, &wr, NULL) &&
+ wr == dwSize) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+static DWORD __apxProcessPuts(LPAPXPROCESS lpProc, LPCTSTR szString)
+{
+ DWORD l, n = 0;
+ l = lstrlen(szString) * lpProc->chSize;
+ if (lpProc->dwChildStatus & CHILD_RUNNING && l) {
+ DWORD wr = 0;
+ while (TRUE) {
+ if (WriteFile(lpProc->hChildInpWr, szString, l,
+ &wr, NULL)) {
+ n += wr;
+ if (wr < l) {
+ l -= wr;
+ szString += wr;
+ }
+ else {
+ /* Flush the buffer */
+ FlushFileBuffers(lpProc->hChildInpWr);
+ break;
+ }
+ }
+ else
+ break;
+ }
+ }
+
+ return n;
+}
+
+static DWORD __apxProcessWrite(LPAPXPROCESS lpProc, LPCVOID lpData, DWORD dwLen)
+{
+ LPBYTE buf = (LPBYTE)lpData;
+ DWORD n = 0;
+ if (!lpData || !dwLen)
+ return 0;
+
+ if (lpProc->dwChildStatus & CHILD_RUNNING) {
+ DWORD wr = 0;
+ while (lpProc->dwChildStatus & CHILD_RUNNING) {
+ if (WriteFile(lpProc->hChildInpWr, buf, dwLen,
+ &wr, NULL)) {
+ n += wr;
+ if (wr < dwLen) {
+ dwLen -= wr;
+ buf += wr;
+ }
+ else
+ break;
+ }
+ else
+ break;
+ }
+ }
+
+ return n;
+}
+
+/** Helper functions */
+static BOOL __apxProcCreateChildPipes(LPAPXPROCESS lpProc)
+{
+ BOOL rv = FALSE;
+
+ if (!CreatePipe(&(lpProc->hChildStdInp),
+ &(lpProc->hChildInpWr),
+ lpProc->lpSA, 0)) {
+ ErrorMessage(NULL, FALSE);
+ goto cleanup;
+ }
+ if (!SetHandleInformation(lpProc->hChildInpWr,
+ HANDLE_FLAG_INHERIT, 0)) {
+ ErrorMessage(NULL, FALSE);
+ goto cleanup;
+ }
+
+ if (!CreatePipe(&(lpProc->hChildOutRd),
+ &(lpProc->hChildStdOut),
+ lpProc->lpSA, 0)) {
+ ErrorMessage(NULL, FALSE);
+ goto cleanup;
+ }
+
+ if (!SetHandleInformation(lpProc->hChildOutRd,
+ HANDLE_FLAG_INHERIT, 0)) {
+ ErrorMessage(NULL, FALSE);
+ goto cleanup;
+ }
+
+ if (!CreatePipe(&(lpProc->hChildErrRd),
+ &(lpProc->hChildStdErr),
+ lpProc->lpSA, 0)) {
+ ErrorMessage(NULL, FALSE);
+ goto cleanup;
+ }
+
+ if (!SetHandleInformation(lpProc->hChildErrRd,
+ HANDLE_FLAG_INHERIT, 0)) {
+ ErrorMessage(NULL, FALSE);
+ goto cleanup;
+ }
+ rv = TRUE;
+cleanup:
+
+ return rv;
+}
+
+/* Close the process.
+ * Create the remote thread and call the ExitProcess
+ * Terminate the process, if all of the above fails.
+ */
+static BOOL __apxProcessClose(APXHANDLE hProcess)
+{
+ LPAPXPROCESS lpProc;
+ DYNLOAD_FPTR_DECLARE(CreateRemoteThread);
+ DYNLOAD_FPTR_DECLARE(ExitProcess);
+
+ UINT uExitCode = CHILD_TERMINATE_CODE; /* Could be any value like my birthday ;-)*/
+ HANDLE hDup, hRemote;
+
+ lpProc = APXHANDLE_DATA(hProcess);
+ CHECK_IF_ACTIVE(lpProc);
+
+ /* Try to close the child's stdin first */
+ SAFE_CLOSE_HANDLE(lpProc->hChildInpWr);
+ /* Wait 1 sec for child process to
+ * recognize that the stdin has been closed.
+ */
+ if (WaitForSingleObject(lpProc->stProcInfo.hProcess, 1000) == WAIT_OBJECT_0)
+ goto cleanup;
+
+ CHECK_IF_ACTIVE(lpProc);
+
+ /* Try to create the remote thread in the child address space */
+ DYNLOAD_FPTR_ADDRESS(CreateRemoteThread, KERNEL32);
+ if (DuplicateHandle(lpProc->hCurrentProcess,
+ lpProc->stProcInfo.hProcess,
+ lpProc->hCurrentProcess,
+ &hDup,
+ PROCESS_ALL_ACCESS,
+ FALSE, 0)) {
+ DYNLOAD_FPTR_ADDRESS(ExitProcess, KERNEL32);
+ /* Now call the ExitProcess from inside the client
+ * This will safely unload all the dll's.
+ */
+ hRemote = DYNLOAD_CALL(CreateRemoteThread)(hDup,
+ NULL, 0,
+ (LPTHREAD_START_ROUTINE)DYNLOAD_FPTR(ExitProcess),
+ (PVOID)&uExitCode, 0, NULL);
+ if (!IS_INVALID_HANDLE(hRemote)) {
+ if (WaitForSingleObject(lpProc->stProcInfo.hProcess,
+ 2000) == WAIT_OBJECT_0) {
+
+ }
+ else {
+ TerminateProcess(lpProc->stProcInfo.hProcess, CHILD_TERMINATE_CODE);
+ }
+ CloseHandle(hRemote);
+ }
+ CloseHandle(hDup);
+ goto cleanup;
+ }
+
+ TerminateProcess(lpProc->stProcInfo.hProcess, CHILD_TERMINATE_CODE);
+
+cleanup:
+ /* Close the process handle */
+ SAFE_CLOSE_HANDLE(lpProc->stProcInfo.hProcess);
+ lpProc->dwChildStatus &= ~CHILD_RUNNING;
+ return TRUE;
+}
+
+static BOOL __apxProcessCallback(APXHANDLE hObject, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ LPAPXPROCESS lpProc;
+
+ lpProc = APXHANDLE_DATA(hObject);
+ /* Call the user supplied callback first */
+ if (lpProc->fnUserCallback)
+ (*lpProc->fnUserCallback)(hObject, uMsg, wParam, lParam);
+ switch (uMsg) {
+ case WM_CLOSE:
+ if (lpProc->dwChildStatus & CHILD_RUNNING) {
+ __apxProcessClose(hObject);
+ /* Wait for all worker threads to exit */
+ WaitForMultipleObjects(3, lpProc->hWorkerThreads, TRUE, INFINITE);
+ }
+ SAFE_CLOSE_HANDLE(lpProc->stProcInfo.hProcess);
+
+ /* Close parent side of the pipes */
+ SAFE_CLOSE_HANDLE(lpProc->hChildInpWr);
+ SAFE_CLOSE_HANDLE(lpProc->hChildOutRd);
+ SAFE_CLOSE_HANDLE(lpProc->hChildErrRd);
+
+ SAFE_CLOSE_HANDLE(lpProc->hWorkerThreads[0]);
+ SAFE_CLOSE_HANDLE(lpProc->hWorkerThreads[1]);
+ SAFE_CLOSE_HANDLE(lpProc->hWorkerThreads[2]);
+ SAFE_CLOSE_HANDLE(lpProc->hUserToken);
+ apxFree(lpProc->szApplicationExec);
+ apxFree(lpProc->szCommandLine);
+ apxFree(lpProc->szWorkingPath);
+ RESTORE_STD_HANDLES(lpProc);
+ SAFE_CLOSE_HANDLE(lpProc->hCurrentProcess);
+ if (lpProc->lpEnvironment)
+ FreeEnvironmentStringsW(lpProc->lpEnvironment);
+
+ case WM_QUIT:
+ /* The process has finished
+ * This is a WorkerThread message
+ */
+ lpProc->dwChildStatus &= ~CHILD_RUNNING;
+ break;
+ case WM_CHAR:
+ __apxProcessPutc(lpProc, (INT)lParam, lpProc->chSize);
+ break;
+ case WM_SETTEXT:
+ if (wParam)
+ __apxProcessWrite(lpProc, (LPCVOID)lParam, (DWORD)wParam);
+ else
+ __apxProcessPuts(lpProc, (LPCTSTR)lParam);
+ break;
+ default:
+ break;
+ }
+
+ return TRUE;
+}
+
+/** Create the process but don't start it
+ *
+ APXHANDLE
+apxCreateProcessW(APXHANDLE hPool, DWORD dwOptions,
+ LPAPXFNCALLBACK fnCallback,
+ LPCWSTR szUsername, LPCWSTR szPassword,
+ BOOL bLogonAsService)
+{
+ APXHANDLE hProcess;
+ LPAPXPROCESS lpProc;
+ HANDLE hUserToken = NULL;
+ if (szUsername && (APX_GET_OSLEVEL() >= APX_WINVER_NT_4)) {
+ HANDLE hUser;
+#ifndef _UNICODE
+ WCHAR wsUsername[256];
+ WCHAR wsPassword[256];
+ AsciiToWide(szUsername, wsUsername);
+ AsciiToWide(szPassword, wsPassword);
+#else
+ LPCWSTR wsUsername = szUsername;
+ LPCWSTR wsPassword = szPassword;
+#endif
+
+ */
+
+
+ APXHANDLE
+apxCreateProcessA(APXHANDLE hPool, DWORD dwOptions,
+ LPAPXFNCALLBACK fnCallback,
+ LPCSTR szUsername, LPCSTR szPassword,
+ BOOL bLogonAsService)
+{
+
+ if (szUsername && szPassword) {
+ WCHAR wsUsername[256];
+ WCHAR wsPassword[256];
+ AsciiToWide(szUsername, wsUsername);
+ AsciiToWide(szPassword, wsPassword);
+ return apxCreateProcessW(hPool, dwOptions, fnCallback,
+ wsUsername, wsPassword, bLogonAsService);
+ }
+ else
+ return apxCreateProcessW(hPool, dwOptions, fnCallback,
+ NULL, NULL, bLogonAsService);
+}
+
+APXHANDLE
+apxCreateProcessW(APXHANDLE hPool, DWORD dwOptions,
+ LPAPXFNCALLBACK fnCallback,
+ LPCWSTR szUsername, LPCWSTR szPassword,
+ BOOL bLogonAsService)
+{
+ APXHANDLE hProcess;
+ LPAPXPROCESS lpProc;
+ HANDLE hUserToken = NULL;
+ /* CreateProcessAsUser is supported only on NT */
+ if (szUsername && (APX_GET_OSLEVEL() >= APX_WINVER_NT_4)) {
+ HANDLE hUser;
+ if (!LogonUserW(szUsername,
+ NULL,
+ szPassword,
+ bLogonAsService ? LOGON32_LOGON_SERVICE : LOGON32_LOGON_NETWORK,
+ LOGON32_PROVIDER_DEFAULT,
+ &hUser)) {
+ /* Logon Failed */
+ ErrorMessage(NULL, TRUE);
+ return NULL;
+ }
+ if (!DuplicateTokenEx(hUser,
+ TOKEN_QUERY | TOKEN_DUPLICATE | TOKEN_ASSIGN_PRIMARY,
+ NULL,
+ SecurityImpersonation,
+ TokenPrimary,
+ &hUserToken)) {
+ CloseHandle(hUser);
+ /* Failed to duplicate the user token */
+ ErrorMessage(NULL, TRUE);
+ return NULL;
+ }
+ if (!ImpersonateLoggedOnUser(hUserToken)) {
+ CloseHandle(hUser);
+ CloseHandle(hUserToken);
+ /* failed to impersonate the logged user */
+ ErrorMessage(NULL, TRUE);
+ return NULL;
+ }
+ CloseHandle(hUser);
+ }
+
+ hProcess = apxHandleCreate(hPool, APXHANDLE_HAS_EVENT,
+ NULL, sizeof(APXPROCESS),
+ __apxProcessCallback);
+ if (IS_INVALID_HANDLE(hProcess))
+ return NULL;
+ hProcess->dwType = APXHANDLE_TYPE_PROCESS;
+ lpProc = APXHANDLE_DATA(hProcess);
+ lpProc->dwOptions = dwOptions;
+ lpProc->fnUserCallback = fnCallback;
+ lpProc->hUserToken = hUserToken;
+ /* set the CHAR length */
+ if (dwOptions & CREATE_UNICODE_ENVIRONMENT)
+ lpProc->chSize = sizeof(WCHAR);
+ else
+ lpProc->chSize = sizeof(CHAR);
+#if 1
+ DuplicateHandle(GetCurrentProcess(),
+ GetCurrentProcess(),
+ GetCurrentProcess(),
+ &lpProc->hCurrentProcess,
+ PROCESS_ALL_ACCESS,
+ FALSE,
+ 0);
+#else
+ lpProc->hCurrentProcess = GetCurrentProcess();
+#endif
+ lpProc->lpSD = &lpProc->bSD;
+
+ InitializeSecurityDescriptor(lpProc->lpSD, SECURITY_DESCRIPTOR_REVISION);
+ SetSecurityDescriptorDacl(lpProc->lpSD, -1, 0, 0);
+
+ lpProc->lpSA = (LPSECURITY_ATTRIBUTES)&lpProc->bSA[0];
+ lpProc->lpSA->nLength = sizeof (SECURITY_ATTRIBUTES);
+ lpProc->lpSA->lpSecurityDescriptor = lpProc->lpSD;
+ lpProc->lpSA->bInheritHandle = TRUE;
+
+ return hProcess;
+}
+
+static WCHAR _desktop_name[] =
+ {'W', 'i', 'n', 's', 't', 'a', '0', '\\', 'D', 'e', 'f', 'a', 'u', 'l', 't', 0};
+
+BOOL
+apxProcessExecute(APXHANDLE hProcess)
+{
+ LPAPXPROCESS lpProc;
+ STARTUPINFOW si;
+ DWORD id;
+ BOOL bS = FALSE;
+
+ if (hProcess->dwType != APXHANDLE_TYPE_PROCESS)
+ return FALSE;
+
+ lpProc = APXHANDLE_DATA(hProcess);
+ /* don't allow multiple execute calls on the same object */
+ if (lpProc->dwChildStatus & PROC_INITIALIZED)
+ return FALSE;
+ lpProc->bSaveHandles = TRUE;
+ SAVE_STD_HANDLES(lpProc);
+ if (!__apxProcCreateChildPipes(lpProc))
+ goto cleanup;
+ REDIRECT_STD_HANDLES(lpProc);
+ AplZeroMemory(&si, sizeof(STARTUPINFO));
+
+ si.cb = sizeof(STARTUPINFO);
+ si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
+ si.wShowWindow = SW_HIDE;
+ /* Set the redirected handles */
+ si.hStdOutput = lpProc->hChildStdOut;
+ si.hStdError = lpProc->hChildStdErr;
+ si.hStdInput = lpProc->hChildStdInp;
+
+ if (lpProc->lpEnvironment)
+ FreeEnvironmentStringsW(lpProc->lpEnvironment);
+ lpProc->lpEnvironment = GetEnvironmentStringsW();
+
+ if (!IS_INVALID_HANDLE(lpProc->hUserToken)) {
+ si.lpDesktop = _desktop_name;
+ bS = CreateProcessAsUserW(lpProc->hUserToken,
+ lpProc->szApplicationExec,
+ lpProc->szCommandLine,
+ lpProc->lpSA,
+ NULL,
+ TRUE,
+ CREATE_SUSPENDED | CREATE_UNICODE_ENVIRONMENT | lpProc->dwOptions,
+ lpProc->lpEnvironment,
+ lpProc->szWorkingPath,
+ &si,
+ &(lpProc->stProcInfo));
+ }
+ else {
+ OutputDebugStringW(lpProc->szApplicationExec);
+ OutputDebugStringW(lpProc->szCommandLine);
+
+ bS = CreateProcessW(lpProc->szApplicationExec,
+ lpProc->szCommandLine,
+ lpProc->lpSA,
+ NULL,
+ TRUE,
+ CREATE_SUSPENDED | CREATE_UNICODE_ENVIRONMENT | lpProc->dwOptions,
+ lpProc->lpEnvironment,
+ lpProc->szWorkingPath,
+ &si,
+ &(lpProc->stProcInfo));
+ }
+ /* Close unused sides of pipes */
+ SAFE_CLOSE_HANDLE(lpProc->hChildStdInp);
+ SAFE_CLOSE_HANDLE(lpProc->hChildStdOut);
+ SAFE_CLOSE_HANDLE(lpProc->hChildStdErr);
+ if (!bS)
+ goto cleanup;
+ /* Set the running flag */
+ lpProc->dwChildStatus |= (CHILD_RUNNING | PROC_INITIALIZED);
+
+ lpProc->hWorkerThreads[0] = CreateThread(NULL, 0, __apxProcStdoutThread,
+ hProcess, 0, &id);
+ lpProc->hWorkerThreads[1] = CreateThread(NULL, 0, __apxProcStderrThread,
+ hProcess, 0, &id);
+ ResumeThread(lpProc->stProcInfo.hThread);
+ lpProc->hWorkerThreads[2] = CreateThread(NULL, 0, __apxProcWorkerThread,
+ hProcess, 0, &id);
+
+ SAFE_CLOSE_HANDLE(lpProc->stProcInfo.hThread);
+ /* Close child handles first */
+ return TRUE;
+cleanup:
+ /* Close parent side of the pipes */
+ SAFE_CLOSE_HANDLE(lpProc->hChildInpWr);
+ SAFE_CLOSE_HANDLE(lpProc->hChildOutRd);
+ SAFE_CLOSE_HANDLE(lpProc->hChildErrRd);
+
+ return FALSE;
+}
+
+BOOL
+apxProcessSetExecutableA(APXHANDLE hProcess, LPCSTR szName)
+{
+ LPAPXPROCESS lpProc;
+
+ if (hProcess->dwType != APXHANDLE_TYPE_PROCESS)
+ return FALSE;
+
+ lpProc = APXHANDLE_DATA(hProcess);
+ apxFree(lpProc->szApplicationExec);
+ lpProc->szApplicationExec = apxPoolWStrdupA(hProcess->hPool, szName);
+ OutputDebugStringW(lpProc->szApplicationExec);
+ return lpProc->szApplicationExec != NULL;
+}
+
+BOOL
+apxProcessSetExecutableW(APXHANDLE hProcess, LPCWSTR szName)
+{
+ LPAPXPROCESS lpProc;
+
+ if (hProcess->dwType != APXHANDLE_TYPE_PROCESS)
+ return FALSE;
+
+ lpProc = APXHANDLE_DATA(hProcess);
+ apxFree(lpProc->szApplicationExec);
+ lpProc->szApplicationExec = apxPoolStrdupW(hProcess->hPool, szName);
+ OutputDebugStringW(lpProc->szApplicationExec);
+ return lpProc->szApplicationExec != NULL;
+}
+
+BOOL
+apxProcessSetCommandLineA(APXHANDLE hProcess, LPCSTR szCmdline)
+{
+ LPAPXPROCESS lpProc;
+
+ if (hProcess->dwType != APXHANDLE_TYPE_PROCESS)
+ return FALSE;
+
+ lpProc = APXHANDLE_DATA(hProcess);
+ apxFree(lpProc->szCommandLine);
+ lpProc->szCommandLine = apxPoolWStrdupA(hProcess->hPool, szCmdline);
+
+ return lpProc->szCommandLine != NULL;
+}
+
+BOOL
+apxProcessSetCommandLineW(APXHANDLE hProcess, LPCWSTR szCmdline)
+{
+ LPAPXPROCESS lpProc;
+
+ if (hProcess->dwType != APXHANDLE_TYPE_PROCESS)
+ return FALSE;
+
+ lpProc = APXHANDLE_DATA(hProcess);
+ apxFree(lpProc->szCommandLine);
+ lpProc->szCommandLine = apxPoolStrdupW(hProcess->hPool, szCmdline);
+
+ return lpProc->szCommandLine != NULL;
+}
+
+BOOL
+apxProcessSetWorkingPathA(APXHANDLE hProcess, LPCSTR szPath)
+{
+ LPAPXPROCESS lpProc;
+
+ if (hProcess->dwType != APXHANDLE_TYPE_PROCESS)
+ return FALSE;
+
+ lpProc = APXHANDLE_DATA(hProcess);
+ apxFree(lpProc->szWorkingPath);
+ lpProc->szWorkingPath = apxPoolWStrdupA(hProcess->hPool, szPath);
+
+ return lpProc->szWorkingPath != NULL;
+}
+
+BOOL
+apxProcessSetWorkingPathW(APXHANDLE hProcess, LPCWSTR szPath)
+{
+ LPAPXPROCESS lpProc;
+
+ if (hProcess->dwType != APXHANDLE_TYPE_PROCESS)
+ return FALSE;
+
+ lpProc = APXHANDLE_DATA(hProcess);
+ apxFree(lpProc->szWorkingPath);
+ if (!szPath) {
+ /* Clear the WorkingPath */
+ lpProc->szWorkingPath = NULL;
+ return TRUE;
+ }
+ lpProc->szWorkingPath = apxPoolWStrdupW(hProcess->hPool, szPath);
+
+ return lpProc->szWorkingPath != NULL;
+}
+
+DWORD
+apxProcessPutcA(APXHANDLE hProcess, INT ch)
+{
+ LPAPXPROCESS lpProc;
+
+ if (hProcess->dwType != APXHANDLE_TYPE_PROCESS)
+ return 0;
+
+ lpProc = APXHANDLE_DATA(hProcess);
+ return __apxProcessPutc(lpProc, ch, sizeof(CHAR));
+}
+
+DWORD
+apxProcessPutcW(APXHANDLE hProcess, INT ch)
+{
+ LPAPXPROCESS lpProc;
+
+ if (hProcess->dwType != APXHANDLE_TYPE_PROCESS)
+ return 0;
+
+ lpProc = APXHANDLE_DATA(hProcess);
+ return __apxProcessPutc(lpProc, ch, sizeof(WCHAR));
+}
+
+DWORD
+apxProcessPutsA(APXHANDLE hProcess, LPCSTR szString)
+{
+ LPAPXPROCESS lpProc;
+ DWORD len;
+ if (hProcess->dwType != APXHANDLE_TYPE_PROCESS || !szString)
+ return 0;
+ lpProc = APXHANDLE_DATA(hProcess);
+ len = lstrlenA(szString);
+ len = __apxProcessWrite(lpProc, szString, len);
+ if (len) {
+ FlushFileBuffers(lpProc->hChildInpWr);
+ return len;
+ }
+ else
+ return 0;
+}
+
+DWORD
+apxProcessPutsW(APXHANDLE hProcess, LPCWSTR szString)
+{
+ LPAPXPROCESS lpProc;
+ DWORD len;
+ if (hProcess->dwType != APXHANDLE_TYPE_PROCESS || !szString)
+ return 0;
+ lpProc = APXHANDLE_DATA(hProcess);
+ len = lstrlenW(szString);
+ len = __apxProcessWrite(lpProc, szString, len * 2);
+ if (len) {
+ FlushFileBuffers(lpProc->hChildInpWr);
+ return (len / sizeof(WCHAR));
+ }
+ else
+ return 0;
+}
+
+DWORD
+apxProcessWrite(APXHANDLE hProcess, LPCVOID lpData, DWORD dwLen)
+{
+ LPAPXPROCESS lpProc;
+ if (hProcess->dwType != APXHANDLE_TYPE_PROCESS)
+ return 0;
+
+ lpProc = APXHANDLE_DATA(hProcess);
+
+ return __apxProcessWrite(lpProc, lpData, dwLen);
+}
+
+BOOL
+apxProcessFlushStdin(APXHANDLE hProcess)
+{
+ LPAPXPROCESS lpProc;
+
+ if (hProcess->dwType != APXHANDLE_TYPE_PROCESS)
+ return FALSE;
+
+ lpProc = APXHANDLE_DATA(hProcess);
+
+ if (lpProc->dwChildStatus & CHILD_RUNNING) {
+ return FlushFileBuffers(lpProc->hChildInpWr);
+ }
+
+ return FALSE;
+}
+
+VOID
+apxProcessCloseInputStream(APXHANDLE hProcess)
+{
+ if (hProcess->dwType == APXHANDLE_TYPE_PROCESS) {
+ LPAPXPROCESS lpProc = APXHANDLE_DATA(hProcess);
+ if (lpProc->dwChildStatus & CHILD_RUNNING)
+ SAFE_CLOSE_HANDLE(lpProc->hChildInpWr);
+ }
+}
+
+DWORD
+apxProcessWait(APXHANDLE hProcess, DWORD dwMilliseconds, BOOL bKill)
+{
+ LPAPXPROCESS lpProc;
+
+ if (hProcess->dwType != APXHANDLE_TYPE_PROCESS)
+ return WAIT_ABANDONED;
+
+ lpProc = APXHANDLE_DATA(hProcess);
+
+ if (lpProc->dwChildStatus & CHILD_RUNNING) {
+ DWORD rv = WaitForMultipleObjects(3, lpProc->hWorkerThreads,
+ TRUE, dwMilliseconds);
+ if (rv == WAIT_TIMEOUT && bKill) {
+ __apxProcessCallback(hProcess, WM_CLOSE, 0, 0);
+ }
+ return rv;
+ }
+ else
+ return WAIT_OBJECT_0;
+}
+
+BOOL
+apxProcessRunning(APXHANDLE hProcess)
+{
+ LPAPXPROCESS lpProc;
+
+ if (hProcess->dwType != APXHANDLE_TYPE_PROCESS)
+ return FALSE;
+
+ lpProc = APXHANDLE_DATA(hProcess);
+
+ return (lpProc->dwChildStatus & CHILD_RUNNING);
+}
+
+static LPWSTR __apxStrQuote(LPWSTR lpDest, LPCWSTR szSrc)
+{
+ LPWSTR p;
+ BOOL q = FALSE;
+
+ /* Find if string has embeded spaces
+ */
+ for (p = (LPWSTR)szSrc; *p; p++) {
+ if (*p == L' ' || *p == '\t' ||
+ *p == '"' || *p == '\\') {
+ q = TRUE;
+ break;
+ }
+ }
+ p = lpDest;
+ if (q) *p++ = L'"';
+ while (*szSrc) {
+ if (*szSrc == '"' || *szSrc == '\\')
+ *p++ = L'\\';
+ *p++ = *szSrc++;
+ }
+ if (q) *p++ = L'"';
+ return p;
+}
+
+BOOL
+apxProcessSetCommandArgsW(APXHANDLE hProcess, LPCWSTR szTitle,
+ DWORD dwArgc, LPCWSTR *lpArgs)
+{
+ LPAPXPROCESS lpProc;
+ DWORD i, l = 0;
+ LPWSTR p;
+ if (hProcess->dwType != APXHANDLE_TYPE_PROCESS)
+ return FALSE;
+
+ lpProc = APXHANDLE_DATA(hProcess);
+ apxFree(lpProc->szCommandLine);
+
+ l = lstrlenW(szTitle) + 3;
+ for (i = 0; i < (DWORD)lstrlenW(szTitle); i++) {
+ if (szTitle[i] == L'"')
+ ++l;
+ }
+ for (i = 0; i < dwArgc; i++) {
+ int x, q = 0;
+ l += (lstrlenW(lpArgs[i]) + 3);
+ for (x = 0; x < lstrlenW(lpArgs[i]); x++) {
+ if (lpArgs[i][x] == L'"')
+ ++q;
+ }
+ l += q;
+ }
+ p = lpProc->szCommandLine = apxPoolAlloc(hProcess->hPool, l * sizeof(WCHAR));
+ p = __apxStrQuote(p, szTitle);
+ for (i = 0; i < dwArgc; i++) {
+ *p++ = L' ';
+ p = __apxStrQuote(p, lpArgs[i]);
+ }
+ *p = L'\0';
+ OutputDebugStringW(lpProc->szCommandLine);
+ return lpProc->szCommandLine != NULL;
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/service.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/service.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/service.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,562 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apxwin.h"
+#include "private.h"
+
+#define SAFE_CLOSE_SCH(h) \
+ if ((h) != NULL && (h) != INVALID_HANDLE_VALUE) { \
+ CloseServiceHandle((h)); \
+ (h) = NULL; \
+ }
+
+#define CHANGE_SERVICE(h, b, u, p, d) \
+ ChangeServiceConfigW(h, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, \
+ SERVICE_NO_CHANGE,b,NULL,NULL,NULL, \
+ u,p,d)
+
+typedef struct APXSERVICE {
+ /* Are we a service manager or we are the service itself */
+ BOOL bManagerMode;
+ /* Handle to the current service */
+ SC_HANDLE hService;
+ /* Handle of the Service manager */
+ SC_HANDLE hManager;
+ APXSERVENTRY stServiceEntry;
+
+} APXSERVICE, *LPAPXSERVICE;
+
+static BOOL __apxIsValidServiceName(LPCWSTR szServiceName)
+{
+ do {
+ if (!IsCharAlphaNumericW(*szServiceName)) {
+ apxDisplayError(TRUE, NULL, 0, "NonAlpha %d", *szServiceName);
+ return FALSE;
+ }
+ } while( *(++szServiceName));
+ return TRUE;
+}
+
+static BOOL __apxServiceCallback(APXHANDLE hObject, UINT uMsg,
+ WPARAM wParam, LPARAM lParam)
+{
+ LPAPXSERVICE lpService;
+
+ lpService = APXHANDLE_DATA(hObject);
+ switch (uMsg) {
+ case WM_CLOSE:
+ apxFree(lpService->stServiceEntry.lpConfig);
+ lpService->stServiceEntry.lpConfig = NULL;
+ SAFE_CLOSE_SCH(lpService->hService);
+ SAFE_CLOSE_SCH(lpService->hManager);
+ break;
+ default:
+ break;
+ }
+ return TRUE;
+}
+
+APXHANDLE
+apxCreateService(APXHANDLE hPool, DWORD dwOptions, BOOL bManagerMode)
+{
+ APXHANDLE hService;
+ LPAPXSERVICE lpService;
+ SC_HANDLE hManager;
+
+ if (!(hManager = OpenSCManager(NULL, NULL, dwOptions))) {
+ apxLogWrite(APXLOG_MARK_SYSERR);
+ return NULL;
+ }
+ hService = apxHandleCreate(hPool, 0,
+ NULL, sizeof(APXSERVICE),
+ __apxServiceCallback);
+ if (IS_INVALID_HANDLE(hService)) {
+ apxLogWrite(APXLOG_MARK_ERROR "Failed to Create Handle for Service");
+ return NULL;
+ }
+ hService->dwType = APXHANDLE_TYPE_SERVICE;
+ lpService = APXHANDLE_DATA(hService);
+ lpService->hManager = hManager;
+ lpService->bManagerMode = bManagerMode;
+
+ return hService;
+}
+
+BOOL
+apxServiceOpen(APXHANDLE hService, LPCWSTR szServiceName, DWORD dwOptions)
+{
+ LPAPXSERVICE lpService;
+ DWORD dwNeeded;
+
+ if (hService->dwType != APXHANDLE_TYPE_SERVICE)
+ return FALSE;
+
+ lpService = APXHANDLE_DATA(hService);
+ /* Manager mode cannot handle services */
+ if (lpService->bManagerMode)
+ return FALSE;
+
+ /* Close any previous instance
+ * Same handle can manage multiple services
+ */
+ SAFE_CLOSE_SCH(lpService->hService);
+ *lpService->stServiceEntry.szServiceDescription = L'\0';
+ *lpService->stServiceEntry.szObjectName = L'\0';
+ apxFree(lpService->stServiceEntry.lpConfig);
+ lpService->stServiceEntry.lpConfig = NULL;
+ /* Open the service */
+ lpService->hService = OpenServiceW(lpService->hManager,
+ szServiceName,
+ dwOptions);
+
+ if (IS_INVALID_HANDLE(lpService->hService)) {
+ apxLogWrite(APXLOG_MARK_SYSERR);
+ return FALSE;
+ }
+ lstrcpyW(lpService->stServiceEntry.szServiceName, szServiceName);
+ if (!apxGetServiceDescriptionW(szServiceName,
+ lpService->stServiceEntry.szServiceDescription,
+ SIZ_DESLEN)) {
+ apxLogWrite(APXLOG_MARK_WARN "Failed obtaing service description");
+ lpService->stServiceEntry.szServiceDescription[0] = L'\0';
+ }
+ if (!apxGetServiceUserW(szServiceName,
+ lpService->stServiceEntry.szObjectName,
+ SIZ_RESLEN)) {
+ apxLogWrite(APXLOG_MARK_WARN "Failed obtaing service user name");
+ lpService->stServiceEntry.szObjectName[0] = L'\0';
+ }
+ if (!QueryServiceConfigW(lpService->hService, NULL, 0, &dwNeeded)) {
+ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
+ apxLogWrite(APXLOG_MARK_SYSERR);
+ }
+ /* TODO: Check GetLastError ERROR_INSUFFICIENT_BUFFER */
+ lpService->stServiceEntry.lpConfig = (LPQUERY_SERVICE_CONFIGW)apxPoolAlloc(hService->hPool,
+ dwNeeded);
+ return QueryServiceConfigW(lpService->hService,
+ lpService->stServiceEntry.lpConfig,
+ dwNeeded, &dwNeeded);
+}
+
+LPAPXSERVENTRY
+apxServiceEntry(APXHANDLE hService, BOOL bRequeryStatus)
+{
+ LPAPXSERVICE lpService;
+
+ if (hService->dwType != APXHANDLE_TYPE_SERVICE)
+ return NULL;
+
+ lpService = APXHANDLE_DATA(hService);
+ /* Manager mode cannot handle services */
+ if (lpService->bManagerMode)
+ return NULL;
+
+ if (bRequeryStatus && !QueryServiceStatus(lpService->hService,
+ &(lpService->stServiceEntry.stServiceStatus))) {
+ apxLogWrite(APXLOG_MARK_SYSERR);
+ return NULL;
+ }
+
+ return &lpService->stServiceEntry;
+}
+
+/* Set the service names etc...
+ * If the ImagePath contains a space, it must be quoted
+ */
+BOOL
+apxServiceSetNames(APXHANDLE hService,
+ LPCWSTR szImagePath,
+ LPCWSTR szDisplayName,
+ LPCWSTR szDescription,
+ LPCWSTR szUsername,
+ LPCWSTR szPassword)
+{
+ LPAPXSERVICE lpService;
+
+ if (hService->dwType != APXHANDLE_TYPE_SERVICE)
+ return FALSE;
+
+ lpService = APXHANDLE_DATA(hService);
+ /* Manager mode cannot handle services */
+ if (lpService->bManagerMode)
+ return FALSE;
+ /* Check if the ServiceOpen has been called */
+ if (IS_INVALID_HANDLE(lpService->hService))
+ return FALSE;
+ if (szDisplayName &&!CHANGE_SERVICE(lpService->hService,
+ szImagePath,
+ szUsername,
+ szPassword,
+ szDisplayName))
+ return FALSE;
+ if (szDescription) {
+ return apxSetServiceDescriptionW(lpService->stServiceEntry.szServiceName,
+ szDescription);
+ }
+ return TRUE;
+}
+
+BOOL
+apxServiceSetOptions(APXHANDLE hService,
+ DWORD dwServiceType,
+ DWORD dwStartType,
+ DWORD dwErrorControl)
+{
+ LPAPXSERVICE lpService;
+
+ if (hService->dwType != APXHANDLE_TYPE_SERVICE)
+ return FALSE;
+
+ lpService = APXHANDLE_DATA(hService);
+ /* Manager mode cannot handle services */
+ if (lpService->bManagerMode)
+ return FALSE;
+ /* Check if the ServixeOpen has been called */
+ if (IS_INVALID_HANDLE(lpService->hService))
+ return FALSE;
+ return ChangeServiceConfig(lpService->hService, dwServiceType,
+ dwStartType, dwErrorControl,
+ NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL);
+}
+
+BOOL
+apxServiceControl(APXHANDLE hService, DWORD dwControl, UINT uMsg,
+ LPAPXFNCALLBACK fnControlCallback,
+ LPVOID lpCbData)
+{
+ LPAPXSERVICE lpService;
+ SERVICE_STATUS stStatus;
+ DWORD dwPending = 0;
+ DWORD dwState = 0;
+ DWORD dwTick = 0;
+ DWORD dwWait, dwCheck, dwStart;
+ BOOL bStatus;
+
+ if (hService->dwType != APXHANDLE_TYPE_SERVICE)
+ return FALSE;
+
+ lpService = APXHANDLE_DATA(hService);
+ /* Manager mode cannot handle services */
+ if (lpService->bManagerMode)
+ return FALSE;
+ /* Check if the ServixeOpen has been called */
+ if (IS_INVALID_HANDLE(lpService->hService))
+ return FALSE;
+ switch (dwControl) {
+ case SERVICE_CONTROL_CONTINUE:
+ dwPending = SERVICE_START_PENDING;
+ dwState = SERVICE_RUNNING;
+ break;
+ case SERVICE_CONTROL_STOP:
+ dwPending = SERVICE_STOP_PENDING;
+ dwState = SERVICE_STOPPED;
+ break;
+ case SERVICE_CONTROL_PAUSE:
+ dwPending = SERVICE_PAUSE_PENDING;
+ dwState = SERVICE_PAUSED;
+ break;
+ default:
+ break;
+ }
+ /* user defined controls */
+ if (dwControl > 127 && dwControl < 224) {
+ /* 128 ... 159 start signals
+ * 160 ... 191 stop signals
+ * 192 ... 223 pause signals
+ */
+ switch (dwControl & 0xE0) {
+ case 0x80:
+ case 0x90:
+ dwPending = SERVICE_START_PENDING;
+ dwState = SERVICE_RUNNING;
+ break;
+ case 0xA0:
+ case 0xB0:
+ dwPending = SERVICE_STOP_PENDING;
+ dwState = SERVICE_STOPPED;
+ break;
+ case 0xC0:
+ case 0xD0:
+ dwPending = SERVICE_PAUSE_PENDING;
+ dwState = SERVICE_PAUSED;
+ break;
+ default:
+ break;
+ }
+ }
+ if (!dwPending && !dwState)
+ return FALSE;
+ /* Now lets control */
+ if (!QueryServiceStatus(lpService->hService, &stStatus)) {
+ apxLogWrite(APXLOG_MARK_SYSERR);
+ return FALSE;
+ }
+ /* signal that we are about to control the service */
+ if (fnControlCallback)
+ (*fnControlCallback)(lpCbData, uMsg, (WPARAM)1, (LPARAM)dwState);
+ if (dwControl == SERVICE_CONTROL_CONTINUE &&
+ stStatus.dwCurrentState != SERVICE_PAUSED)
+ bStatus = StartService(lpService->hService, 0, NULL);
+ else
+ bStatus = ControlService(lpService->hService, dwControl, &stStatus);
+ dwStart = GetTickCount();
+ dwCheck = stStatus.dwCheckPoint;
+ if (bStatus) {
+ Sleep(100); /* Initial Sleep period */
+ while (QueryServiceStatus(lpService->hService, &stStatus)) {
+ if (stStatus.dwCurrentState == dwPending) {
+ /* Do not wait longer than the wait hint. A good interval is
+ * one tenth the wait hint, but no less than 1 second and no
+ * more than 10 seconds.
+ */
+ dwWait = stStatus.dwWaitHint / 10;
+
+ if( dwWait < 1000 )
+ dwWait = 1000;
+ else if ( dwWait > 10000 )
+ dwWait = 10000;
+ /* Signal to the callback that we are pending
+ * break if callback returns false.
+ */
+ if (fnControlCallback) {
+ if (!(*fnControlCallback)(lpCbData, uMsg, (WPARAM)2,
+ (LPARAM)dwTick++))
+ break;
+ }
+ Sleep(dwWait);
+ if (stStatus.dwCheckPoint > dwCheck) {
+ /* The service is making progress. */
+ dwStart = GetTickCount();
+ dwCheck = stStatus.dwCheckPoint;
+ }
+ else {
+ if(GetTickCount() - dwStart > stStatus.dwWaitHint) {
+ /* No progress made within the wait hint */
+ break;
+ }
+ }
+ }
+ else
+ break;
+ }
+ }
+ /* signal that we are done with controling the service */
+ if (fnControlCallback)
+ (*fnControlCallback)(lpCbData, uMsg, (WPARAM)3, (LPARAM)0);
+ /* Check if we are in the desired state */
+ Sleep(1000);
+
+ if (QueryServiceStatus(lpService->hService, &stStatus)) {
+ if (fnControlCallback)
+ (*fnControlCallback)(lpCbData, uMsg, (WPARAM)4,
+ (LPARAM)&stStatus);
+ if (stStatus.dwCurrentState == dwState)
+ return TRUE;
+
+ }
+
+ return FALSE;
+}
+
+BOOL
+apxServiceInstall(APXHANDLE hService, LPCWSTR szServiceName,
+ LPCWSTR szDisplayName, LPCWSTR szImagePath,
+ LPCWSTR lpDependencies, DWORD dwServiceType,
+ DWORD dwStartType)
+{
+ LPAPXSERVICE lpService;
+
+ if (hService->dwType != APXHANDLE_TYPE_SERVICE)
+ return FALSE;
+
+ lpService = APXHANDLE_DATA(hService);
+ /* Manager mode cannot handle services */
+ if (lpService->bManagerMode)
+ return FALSE;
+ if (IS_INVALID_HANDLE(lpService->hManager))
+ return FALSE;
+ if (!__apxIsValidServiceName(szServiceName))
+ return FALSE;
+ /* Close any previous instance
+ * Same handle can install multiple services
+ */
+ SAFE_CLOSE_SCH(lpService->hService);
+
+ apxFree(lpService->stServiceEntry.lpConfig);
+ lpService->stServiceEntry.lpConfig = NULL;
+ AplZeroMemory(&lpService->stServiceEntry, sizeof(APXSERVENTRY));
+
+ lpService->hService = CreateServiceW(lpService->hManager,
+ szServiceName,
+ szDisplayName,
+ SERVICE_ALL_ACCESS,
+ dwServiceType,
+ dwStartType,
+ SERVICE_ERROR_NORMAL,
+ szImagePath,
+ NULL,
+ NULL,
+ lpDependencies,
+ NULL,
+ NULL);
+
+ if (IS_INVALID_HANDLE(lpService->hService)) {
+ apxLogWrite(APXLOG_MARK_SYSERR);
+
+ ErrorMessage(NULL, FALSE);
+ return FALSE;
+ }
+ else {
+ lstrcpyW(lpService->stServiceEntry.szServiceName, szServiceName);
+ lpService->stServiceEntry.dwStart = dwStartType;
+ return TRUE;
+ }
+}
+
+BOOL
+apxServiceDelete(APXHANDLE hService)
+{
+ LPAPXSERVICE lpService;
+ SERVICE_STATUS stStatus;
+ if (hService->dwType != APXHANDLE_TYPE_SERVICE)
+ return FALSE;
+
+ lpService = APXHANDLE_DATA(hService);
+ /* Manager mode cannot handle services */
+ if (lpService->bManagerMode)
+ return FALSE;
+ /* Check if the ServiceOpen has been called */
+ if (IS_INVALID_HANDLE(lpService->hService))
+ return FALSE;
+ if (QueryServiceStatus(lpService->hService, &stStatus)) {
+ BOOL rv;
+ if (stStatus.dwCurrentState != SERVICE_STOPPED)
+ apxServiceControl(hService, SERVICE_CONTROL_STOP, 0, NULL, NULL);
+ rv = DeleteService(lpService->hService);
+ SAFE_CLOSE_SCH(lpService->hService);
+ SAFE_CLOSE_SCH(lpService->hManager);
+
+ return rv;
+ }
+ return FALSE;
+}
+
+/* Browse the services */
+DWORD
+apxServiceBrowse(APXHANDLE hService,
+ LPCWSTR szIncludeNamePattern,
+ LPCWSTR szIncludeImagePattern,
+ LPCWSTR szExcludeNamePattern,
+ LPCWSTR szExcludeImagePattern,
+ UINT uMsg,
+ LPAPXFNCALLBACK fnDisplayCallback,
+ LPVOID lpCbData)
+{
+ DWORD nFound = 0;
+ APXREGENUM stEnum;
+ LPAPXSERVICE lpService;
+ SC_LOCK hLock;
+ if (hService->dwType != APXHANDLE_TYPE_SERVICE || !fnDisplayCallback)
+ return 0;
+
+ lpService = APXHANDLE_DATA(hService);
+ /* Only the manager mode can browse services */
+ if (!lpService->bManagerMode ||
+ IS_INVALID_HANDLE(lpService->hManager))
+ return 0;
+ hLock = LockServiceDatabase(lpService->hManager);
+ if (IS_INVALID_HANDLE(hLock)) {
+ apxLogWrite(APXLOG_MARK_SYSERR);
+
+ ErrorMessage(NULL, FALSE);
+ return 0;
+ }
+ AplZeroMemory(&stEnum, sizeof(APXREGENUM));
+
+ while (TRUE) {
+ APXSERVENTRY stEntry;
+ BOOL rv;
+ AplZeroMemory(&stEntry, sizeof(APXSERVENTRY));
+ rv = apxRegistryEnumServices(&stEnum, &stEntry);
+
+ if (rv) {
+ INT fm = -1;
+ SC_HANDLE hSrv = NULL;
+ DWORD dwNeeded = 0;
+ hSrv = OpenServiceW(lpService->hManager,
+ stEntry.szServiceName,
+ GENERIC_READ);
+ if (!IS_INVALID_HANDLE(hSrv)) {
+ QueryServiceConfigW(hSrv, NULL, 0, &dwNeeded);
+ stEntry.lpConfig = (LPQUERY_SERVICE_CONFIGW)apxPoolAlloc(hService->hPool,
+ dwNeeded);
+ /* Call the QueryServiceConfig againg with allocated config */
+ if (QueryServiceConfigW(hSrv, stEntry.lpConfig, dwNeeded, &dwNeeded)) {
+ /* Make that customizable so that kernel mode drivers can be
+ * displayed and maintained. For now skip the
+ * filesystem and device drivers.
+ * XXX: Do we need that customizable after all?
+ */
+ if ((stEntry.lpConfig->dwServiceType &
+ ~SERVICE_INTERACTIVE_PROCESS) & SERVICE_WIN32)
+ fm = 0;
+
+ if (!fm && szIncludeNamePattern) {
+ fm = apxMultiStrMatchW(stEntry.szServiceName,
+ szIncludeNamePattern, L';', TRUE);
+ }
+ if (!fm && szExcludeNamePattern) {
+ fm = !apxMultiStrMatchW(stEntry.szServiceName,
+ szExcludeNamePattern, L';', TRUE);
+ }
+ if (!fm && szIncludeImagePattern) {
+ fm = apxMultiStrMatchW(stEntry.lpConfig->lpBinaryPathName,
+ szIncludeImagePattern, L';', TRUE);
+ }
+ if (!fm && szExcludeImagePattern) {
+ fm = !apxMultiStrMatchW(stEntry.szServiceName,
+ szExcludeImagePattern, L';', TRUE);
+ }
+ if (!fm) {
+ QueryServiceStatus(hSrv, &(stEntry.stServiceStatus));
+ /* WIN2K + extended service info */
+ if (_st_apx_oslevel >= 4) {
+ DWORD dwNeed;
+ QueryServiceStatusEx(hSrv, SC_STATUS_PROCESS_INFO,
+ (LPBYTE)(&(stEntry.stStatusProcess)),
+ sizeof(SERVICE_STATUS_PROCESS),
+ &dwNeed);
+ }
+ /* finaly call the provided callback */
+ rv = (*fnDisplayCallback)(lpCbData, uMsg,
+ (WPARAM)&stEntry,
+ (LPARAM)nFound++);
+ }
+ }
+ /* release the skipped service config */
+ if (fm) {
+ apxFree(stEntry.lpConfig);
+ }
+ }
+ SAFE_CLOSE_SCH(hSrv);
+ }
+ if (!rv)
+ break;
+ }
+
+ UnlockServiceDatabase(hLock);
+ return nFound;
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/utils.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/utils.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/src/utils.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,990 @@
+/* Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apxwin.h"
+#include "private.h"
+
+APX_OSLEVEL _st_apx_oslevel = APX_WINVER_UNK;
+
+/* Apache's APR stripped Os level detection */
+APX_OSLEVEL apxGetOsLevel()
+{
+ if (_st_apx_oslevel == APX_WINVER_UNK) {
+ static OSVERSIONINFO oslev;
+ oslev.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&oslev);
+
+ if (oslev.dwPlatformId == VER_PLATFORM_WIN32_NT) {
+ if (oslev.dwMajorVersion < 4)
+ _st_apx_oslevel = APX_WINVER_UNSUP;
+ else if (oslev.dwMajorVersion == 4)
+ _st_apx_oslevel = APX_WINVER_NT_4;
+ else if (oslev.dwMajorVersion == 5) {
+ if (oslev.dwMinorVersion == 0)
+ _st_apx_oslevel = APX_WINVER_2000;
+ else
+ _st_apx_oslevel = APX_WINVER_XP;
+ }
+ else
+ _st_apx_oslevel = APX_WINVER_XP;
+ }
+#ifndef WINNT
+ else if (oslev.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
+ if (oslev.dwMinorVersion < 10)
+ _st_apx_oslevel = APX_WINVER_95;
+ else if (oslev.dwMinorVersion < 90)
+ _st_apx_oslevel = APX_WINVER_98;
+ else
+ _st_apx_oslevel = APX_WINVER_ME;
+ }
+#endif
+#ifdef _WIN32_WCE
+ else if (oslev.dwPlatformId == VER_PLATFORM_WIN32_CE) {
+ if (oslev.dwMajorVersion < 3)
+ _st_apx_oslevel = APX_WINVER_UNSUP;
+ else
+ _st_apx_oslevel = APX_WINVER_CE_3;
+ }
+#endif
+ else
+ _st_apx_oslevel = APX_WINVER_UNSUP;
+ }
+
+ if (_st_apx_oslevel < APX_WINVER_UNSUP)
+ return APX_WINVER_UNK;
+ else
+ return _st_apx_oslevel;
+}
+
+LPWSTR __apxGetEnvironmentVariableW(APXHANDLE hPool, LPCWSTR wsName)
+{
+ LPWSTR wsRet;
+ DWORD rc;
+
+ rc = GetEnvironmentVariableW(wsName, NULL, 0);
+ if (rc == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)
+ return NULL;
+
+ if (!(wsRet = apxPoolAlloc(hPool, (rc + 1) * sizeof(WCHAR))))
+ return NULL;
+ if (!GetEnvironmentVariableW(wsName, wsRet, rc)) {
+ apxFree(wsRet);
+ ErrorMessage(NULL, FALSE);
+ return NULL;
+ }
+ return wsRet;
+}
+
+LPSTR __apxGetEnvironmentVariableA(APXHANDLE hPool, LPCSTR szName)
+{
+ LPSTR szRet;
+ DWORD rc;
+
+ rc = GetEnvironmentVariableA(szName, NULL, 0);
+ if (rc == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)
+ return NULL;
+
+ if (!(szRet = apxPoolAlloc(hPool, rc + 1)))
+ return NULL;
+ if (!GetEnvironmentVariableA(szName, szRet, rc)) {
+ apxFree(szRet);
+ ErrorMessage(NULL, FALSE);
+ return NULL;
+ }
+ return szRet;
+}
+
+
+LPWSTR AsciiToWide(LPCSTR s, LPWSTR ws)
+{
+ LPWSTR pszSave = ws;
+
+ if (!s) {
+ *ws = L'\0';
+ return pszSave;
+ }
+ do {
+ *ws++ = (WCHAR)*s;
+ } while (*s++);
+ return pszSave;
+}
+
+LPSTR WideToAscii(LPCWSTR ws, LPSTR s)
+{
+ LPSTR pszSave = s;
+
+ if (!ws) {
+ *s = '\0';
+ return pszSave;
+ }
+ do {
+ *s++ = (CHAR)*ws;
+ } while( *ws++);
+ return pszSave;
+}
+
+LPSTR MzWideToAscii(LPCWSTR ws, LPSTR s)
+{
+ LPSTR pszSave = s;
+
+ if (ws) {
+ do {
+ *s++ = (CHAR)*ws;
+ ws++;
+ } while( *ws || *(ws + 1));
+ }
+ /* double terminate */
+ *s++ = '\0';
+ *s = '\0';
+ return pszSave;
+}
+
+#ifdef _DEBUG
+
+void ErrorMessage(LPCTSTR szError, BOOL bFatal)
+{
+ LPVOID lpMsgBuf = NULL;
+ UINT nType;
+ int nRet;
+ DWORD dwErr = GetLastError();
+ if (bFatal)
+ nType = MB_ICONERROR | MB_ABORTRETRYIGNORE | MB_SYSTEMMODAL;
+ else
+ nType = MB_ICONEXCLAMATION | MB_OK;
+ if (szError) {
+ nRet = MessageBox(NULL, szError, TEXT("Application Error"), nType);
+ }
+ else {
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ dwErr,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
+ (LPTSTR) &lpMsgBuf, 0, NULL);
+ nRet = MessageBox(NULL, (LPCTSTR)lpMsgBuf,
+ TEXT("Application System Error"), nType);
+ LocalFree(lpMsgBuf);
+ }
+ if (bFatal && (nRet == IDCANCEL || nRet == IDABORT)) {
+ ExitProcess(dwErr);
+ }
+}
+#endif /* _DEBUG */
+
+DWORD __apxGetMultiSzLengthA(LPCSTR lpStr, LPDWORD lpdwCount)
+{
+ LPCSTR p = lpStr;
+ if (lpdwCount)
+ *lpdwCount = 0;
+ for ( ; p && *p; p++) {
+ if (lpdwCount)
+ *lpdwCount += 1;
+ while (*p)
+ p++;
+ }
+ return (DWORD)(p - lpStr);
+}
+
+DWORD __apxGetMultiSzLengthW(LPCWSTR lpStr, LPDWORD lpdwCount)
+{
+ LPCWSTR p = lpStr;
+ if (lpdwCount)
+ *lpdwCount = 0;
+ for ( ; p && *p; p++) {
+ if (lpdwCount)
+ *lpdwCount += 1;
+ while (*p)
+ p++;
+ }
+ return (DWORD)((p - lpStr));
+}
+
+LPWSTR apxMultiSzCombine(APXHANDLE hPool, LPCWSTR lpStrA, LPCWSTR lpStrB,
+ LPDWORD lpdwLength)
+{
+ LPWSTR rv;
+ DWORD la = 0, lb = 0;
+ if (!lpStrA && !lpStrB)
+ return NULL; /* Nothing to do if both are NULL */
+
+ la = __apxGetMultiSzLengthW(lpStrA, NULL);
+ lb = __apxGetMultiSzLengthW(lpStrB, NULL);
+
+ rv = apxPoolCalloc(hPool, (la + lb + 1) * sizeof(WCHAR));
+ if (la) {
+ AplMoveMemory(rv, lpStrA, la * sizeof(WCHAR));
+ }
+ if (lb) {
+ AplMoveMemory(&rv[la], lpStrB, lb * sizeof(WCHAR));
+ }
+ if (*lpdwLength)
+ *lpdwLength = (la + lb + 1) * sizeof(WCHAR);
+ return rv;
+}
+
+BOOL
+apxSetEnvironmentVariable(APXHANDLE hPool, LPCTSTR szName, LPCTSTR szValue,
+ BOOL bAppend)
+{
+ LPTSTR szNew = (LPTSTR)szValue;
+
+ if (bAppend) {
+ DWORD l = GetEnvironmentVariable(szName, NULL, 0);
+ if (l > 0) {
+ BOOL rv;
+ if (IS_INVALID_HANDLE(hPool))
+ szNew = apxAlloc(l + lstrlen(szValue) + 3);
+ else
+ szNew = apxPoolAlloc(hPool, l + lstrlen(szValue) + 3);
+ GetEnvironmentVariable(szName, szNew, l + 1);
+ lstrcat(szNew, TEXT(";"));
+ lstrcat(szNew, szValue);
+ rv = SetEnvironmentVariable(szName, szNew);
+ apxFree(szNew);
+ return rv;
+ }
+ }
+ return SetEnvironmentVariable(szName, szNew);
+}
+
+
+/** Convert null separated double null terimated string to LPTSTR array)
+ * returns array size
+ */
+DWORD
+apxMultiSzToArrayW(APXHANDLE hPool, LPCWSTR lpString, LPWSTR **lppArray)
+{
+ DWORD i, n, l;
+ char *buff;
+ LPWSTR p;
+
+ l = __apxGetMultiSzLengthW(lpString, &n);
+ if (!n || !l)
+ return 0;
+ if (IS_INVALID_HANDLE(hPool))
+ buff = apxPoolAlloc(hPool, (n + 2) * sizeof(LPWSTR) + (l + 1) * sizeof(WCHAR));
+ else
+ buff = apxAlloc((n + 2) * sizeof(LPWSTR) + (l + 1) * sizeof(WCHAR));
+
+ *lppArray = (LPWSTR *)buff;
+ p = (LPWSTR)(buff + (n + 2) * sizeof(LPWSTR));
+ AplCopyMemory(p, lpString, (l + 1) * sizeof(WCHAR) + sizeof(WCHAR));
+ for (i = 0; i < n; i++) {
+ (*lppArray)[i] = p;
+ while (*p)
+ p++;
+ p++;
+ }
+ (*lppArray)[++i] = NULL;
+
+ return n;
+}
+
+DWORD
+apxMultiSzToArrayA(APXHANDLE hPool, LPCSTR lpString, LPSTR **lppArray)
+{
+ DWORD i, n, l;
+ char *buff;
+ LPSTR p;
+
+ l = __apxGetMultiSzLengthA(lpString, &n);
+ if (!n || !l)
+ return 0;
+ if (IS_INVALID_HANDLE(hPool))
+ buff = apxPoolAlloc(hPool, (n + 2) * sizeof(LPTSTR) + (l + 1));
+ else
+ buff = apxAlloc((n + 2) * sizeof(LPSTR) + (l + 1) * sizeof(CHAR));
+
+ *lppArray = (LPSTR *)buff;
+ p = (LPSTR)(buff + (n + 2) * sizeof(LPSTR));
+ AplCopyMemory(p, lpString, (l + 1) * sizeof(CHAR) + sizeof(CHAR));
+ for (i = 0; i < n; i++) {
+ (*lppArray)[i] = p;
+ while (*p)
+ p++;
+ p++;
+ }
+ (*lppArray)[++i] = NULL;
+
+ return n;
+}
+
+#define QSTR_BOUNDARY 127
+#define QSTR_ALIGN(size) \
+ (((size) + QSTR_BOUNDARY + sizeof(APXMULTISZ) + 2) & ~(QSTR_BOUNDARY))
+
+#define QSTR_SIZE(size) \
+ ((QSTR_ALIGN(size)) - sizeof(APXMULTISZ))
+
+#define QSTR_DATA(q) ((char *)(q) + sizeof(APXMULTISZ))
+
+#if 0
+LPAPXMULTISZ apxMultiSzStrdup(LPCTSTR szSrc)
+{
+ LPAPXMULTISZ q;
+
+ if (szSrc) {
+ DWORD l = lstrlen(szSrc);
+ q = (LPAPXMULTISZ)apxAlloc(QSTR_ALIGN(l));
+ q->dwAllocated = QSTR_SIZE(l);
+ q->dwInsert = l + 1;
+ AplMoveMemory(QSTR_DATA(q), szSrc, l);
+ RtlZeroMemory(QSTR_DATA(q) + l, q->dwAllocated - l);
+ }
+ else {
+ q = (LPAPXMULTISZ)apxCalloc(QSTR_ALIGN(0));
+ q->dwAllocated = QSTR_SIZE(0);
+ }
+
+ return q;
+}
+
+LPTSTR apxMultiSzStrcat(LPAPXMULTISZ lpmSz, LPCTSTR szSrc)
+{
+ DWORD l = lstrlen(szSrc);
+ LPTSTR p;
+
+ if (lpmSz->dwInsert + l + 2 > lpmSz->dwAllocated) {
+ if ((lpmSz = (LPAPXMULTISZ )apxRealloc(lpmSz, QSTR_ALIGN(lpmSz->dwInsert + l))) == NULL)
+ return NULL;
+
+ lpmSz->dwAllocated = QSTR_SIZE(lpmSz->dwInsert + l);
+ AplZeroMemory(QSTR_DATA(lpmSz) + lpmSz->dwInsert + l,
+ lpmSz->dwAllocated - (lpmSz->dwInsert + l));
+ }
+ p = (LPTSTR)QSTR_DATA(lpmSz) + lpmSz->dwInsert;
+ AplMoveMemory(p, szSrc, l);
+
+ lpmSz->dwInsert += (l + 1);
+ return p;
+}
+
+DWORD apxMultiSzLen(LPAPXMULTISZ lpmSz)
+{
+ if (lpmSz->dwInsert)
+ return lpmSz->dwInsert - 1;
+ else
+ return 0;
+}
+
+LPCTSTR apxMultiSzGet(LPAPXMULTISZ lpmSz)
+{
+ return (LPCTSTR)QSTR_DATA(lpmSz);
+}
+#endif
+
+LPTSTR apxStrCharRemove(LPTSTR szString, TCHAR chSkip)
+{
+ LPTSTR p = szString;
+ LPTSTR q = szString;
+ while (*p) {
+ if(*p != chSkip)
+ *q++ = *p;
+ ++p;
+ }
+ *q = TEXT('\0');
+
+ return szString;
+}
+
+DWORD apxStrCharRemoveA(LPSTR szString, CHAR chSkip)
+{
+ LPSTR p = szString;
+ LPSTR q = szString;
+ DWORD c = 0;
+ while (*p) {
+ if(*p != chSkip)
+ *q++ = *p;
+ else
+ ++c;
+ ++p;
+ }
+ *q = '\0';
+
+ return c;
+}
+
+DWORD apxStrCharRemoveW(LPWSTR szString, WCHAR chSkip)
+{
+ LPWSTR p = szString;
+ LPWSTR q = szString;
+ DWORD c = 0;
+ while (*p) {
+ if(*p != chSkip)
+ *q++ = *p;
+ else
+ ++c;
+ ++p;
+ }
+ *q = L'\0';
+
+ return c;
+}
+
+void
+apxStrCharReplaceA(LPSTR szString, CHAR chReplace, CHAR chReplaceWith)
+{
+ LPSTR p = szString;
+ LPSTR q = szString;
+ while (*p) {
+ if(*p == chReplace)
+ *q++ = chReplaceWith;
+ else
+ *q++ = *p;
+ ++p;
+ }
+ *q = '\0';
+}
+
+void
+apxStrCharReplaceW(LPWSTR szString, WCHAR chReplace, WCHAR chReplaceWith)
+{
+ LPWSTR p = szString;
+ LPWSTR q = szString;
+ while (*p) {
+ if(*p == chReplace)
+ *q++ = chReplaceWith;
+ else
+ *q++ = *p;
+ ++p;
+ }
+ *q = L'\0';
+}
+
+static const LPCTSTR _st_hex = TEXT("0123456789abcdef");
+#define XTOABUFFER_SIZE (sizeof(ULONG) * 2 + 2)
+#define UTOABUFFER_SIZE (sizeof(ULONG_PTR) * 2 + 2)
+#define LO_NIBLE(x) ((BYTE)((x) & 0x0000000F))
+
+BOOL apxUltohex(ULONG n, LPTSTR lpBuff, DWORD dwBuffLength)
+{
+ LPTSTR p;
+ DWORD i;
+ *lpBuff = 0;
+ if (dwBuffLength < XTOABUFFER_SIZE)
+ return FALSE;
+ p = lpBuff + XTOABUFFER_SIZE;
+ *p-- = 0;
+ for (i = 0; i < sizeof(ULONG) * 2; i++) {
+ *p-- = _st_hex[LO_NIBLE(n)];
+ n = n >> 4;
+ }
+ *p-- = TEXT('x');
+ *p = TEXT('0');
+ return TRUE;
+}
+
+BOOL apxUptohex(ULONG_PTR n, LPTSTR lpBuff, DWORD dwBuffLength)
+{
+ LPTSTR p;
+ DWORD i;
+ *lpBuff = 0;
+ if (dwBuffLength < UTOABUFFER_SIZE)
+ return FALSE;
+ p = lpBuff + UTOABUFFER_SIZE;
+ *p-- = 0;
+ for (i = 0; i < sizeof(ULONG_PTR) * 2; i++) {
+ *p-- = _st_hex[LO_NIBLE(n)];
+ n = n >> 4;
+ }
+ *p-- = TEXT('x');
+ *p = TEXT('0');
+ return TRUE;
+}
+
+ULONG apxStrToul(LPCTSTR szNum)
+{
+ ULONG rv = 0;
+ DWORD sh = 0;
+ LPCTSTR p = szNum;
+ ++p;
+ while (*p && (*p != TEXT('x')) && (*(p - 1) != TEXT('0')))
+ p++;
+ if (*p != 'x')
+ return 0;
+ /* go to the last digit */
+ while (*(p + 1)) p++;
+
+ /* go back to 'x' */
+ while (*p != TEXT('x')) {
+ ULONG v = 0;
+ switch (*p--) {
+ case TEXT('0'): v = 0UL; break;
+ case TEXT('1'): v = 1UL; break;
+ case TEXT('2'): v = 2UL; break;
+ case TEXT('3'): v = 3UL; break;
+ case TEXT('4'): v = 4UL; break;
+ case TEXT('5'): v = 5UL; break;
+ case TEXT('6'): v = 6UL; break;
+ case TEXT('7'): v = 7UL; break;
+ case TEXT('8'): v = 8UL; break;
+ case TEXT('9'): v = 9UL; break;
+ case TEXT('a'): case TEXT('A'): v = 10UL; break;
+ case TEXT('b'): case TEXT('B'): v = 11UL; break;
+ case TEXT('c'): case TEXT('C'): v = 12UL; break;
+ case TEXT('d'): case TEXT('D'): v = 13UL; break;
+ case TEXT('e'): case TEXT('E'): v = 14UL; break;
+ case TEXT('f'): case TEXT('F'): v = 15UL; break;
+ default:
+ return 0;
+ break;
+ }
+ rv |= rv + (v << sh);
+ sh += 4;
+ }
+ return rv;
+}
+
+ULONG apxStrToulW(LPCWSTR szNum)
+{
+ ULONG rv = 0;
+ DWORD sh = 0;
+ LPCWSTR p = szNum;
+ ++p;
+ while (*p && (*p != L'x') && (*(p - 1) != L'0'))
+ p++;
+ if (*p != L'x')
+ return 0;
+ /* go to the last digit */
+ while (*(p + 1)) p++;
+
+ /* go back to 'x' */
+ while (*p != L'x') {
+ ULONG v = 0;
+ switch (*p--) {
+ case L'0': v = 0UL; break;
+ case L'1': v = 1UL; break;
+ case L'2': v = 2UL; break;
+ case L'3': v = 3UL; break;
+ case L'4': v = 4UL; break;
+ case L'5': v = 5UL; break;
+ case L'6': v = 6UL; break;
+ case L'7': v = 7UL; break;
+ case L'8': v = 8UL; break;
+ case L'9': v = 9UL; break;
+ case L'a': case L'A': v = 10UL; break;
+ case L'b': case L'B': v = 11UL; break;
+ case L'c': case L'C': v = 12UL; break;
+ case L'd': case L'D': v = 13UL; break;
+ case L'e': case L'E': v = 14UL; break;
+ case L'f': case L'F': v = 15UL; break;
+ default:
+ return 0;
+ break;
+ }
+ rv |= rv + (v << sh);
+ sh += 4;
+ }
+ return rv;
+}
+
+ULONG apxAtoulW(LPCWSTR szNum)
+{
+ ULONG rv = 0;
+ DWORD sh = 1;
+ int s = 1;
+ LPCWSTR p = szNum;
+
+ /* go to the last digit */
+ if (!p || !*p)
+ return 0;
+ if (*p == L'-') {
+ s = -1;
+ ++p;
+ }
+ while (*(p + 1)) p++;
+
+ /* go back */
+ while (p >= szNum) {
+ ULONG v = 0;
+ switch (*p--) {
+ case L'0': v = 0UL; break;
+ case L'1': v = 1UL; break;
+ case L'2': v = 2UL; break;
+ case L'3': v = 3UL; break;
+ case L'4': v = 4UL; break;
+ case L'5': v = 5UL; break;
+ case L'6': v = 6UL; break;
+ case L'7': v = 7UL; break;
+ case L'8': v = 8UL; break;
+ case L'9': v = 9UL; break;
+ default:
+ return rv * s;
+ break;
+ }
+ rv = rv + (v * sh);
+ sh = sh * 10;
+ }
+ return rv * s;
+}
+
+/* Make the unique system resource name from prefix and process id
+ *
+ */
+BOOL
+apxMakeResourceName(LPCTSTR szPrefix, LPTSTR lpBuff, DWORD dwBuffLength)
+{
+ DWORD pl = lstrlen(szPrefix);
+ if (dwBuffLength < (pl + 11))
+ return FALSE;
+ lstrcpy(lpBuff, szPrefix);
+ return apxUltohex(GetCurrentProcessId(), lpBuff + pl, dwBuffLength - pl);
+}
+/** apxStrMatchA ANSI string pattern matching
+ * Match = 0, NoMatch = 1, Abort = -1
+ * Based loosely on sections of wildmat.c by Rich Salz
+ */
+INT apxStrMatchA(LPCSTR szString, LPCSTR szPattern, BOOL bIgnoreCase)
+{
+ int x, y;
+
+ for (x = 0, y = 0; szPattern[y]; ++y, ++x) {
+ if (!szPattern[x] && (szPattern[y] != '*' || szPattern[y] != '?'))
+ return -1;
+ if (szPattern[y] == '*') {
+ while (szPattern[++y] == '*');
+ if (!szPattern[y])
+ return 0;
+ while (szString[x]) {
+ INT rc;
+ if ((rc = apxStrMatchA(&szString[x++], &szPattern[y],
+ bIgnoreCase)) != 1)
+ return rc;
+ }
+ return -1;
+ }
+ else if (szPattern[y] != '?') {
+ if (bIgnoreCase) {
+ if (CharLowerA((LPSTR)((SIZE_T)szString[x])) !=
+ CharLowerA((LPSTR)((SIZE_T)szPattern[y])))
+ return 1;
+ }
+ else {
+ if (szString[x] != szPattern[y])
+ return 1;
+ }
+ }
+ }
+ return (szString[x] != '\0');
+}
+
+INT apxStrMatchW(LPCWSTR szString, LPCWSTR szPattern, BOOL bIgnoreCase)
+{
+ int x, y;
+
+ for (x = 0, y = 0; szPattern[y]; ++y, ++x) {
+ if (!szPattern[x] && (szPattern[y] != L'*' || szPattern[y] != L'?'))
+ return -1;
+ if (szPattern[y] == L'*') {
+ while (szPattern[++y] == L'*');
+ if (!szPattern[y])
+ return 0;
+ while (szString[x]) {
+ INT rc;
+ if ((rc = apxStrMatchW(&szString[x++], &szPattern[y],
+ bIgnoreCase)) != 1)
+ return rc;
+ }
+ return -1;
+ }
+ else if (szPattern[y] != L'?') {
+ if (bIgnoreCase) {
+ if (CharLowerW((LPWSTR)((SIZE_T)szString[x])) !=
+ CharLowerW((LPWSTR)((SIZE_T)szPattern[y])))
+ return 1;
+ }
+ else {
+ if (szString[x] != szPattern[y])
+ return 1;
+ }
+ }
+ }
+ return (szString[x] != L'\0');
+}
+
+INT apxMultiStrMatchW(LPCWSTR szString, LPCWSTR szPattern,
+ WCHAR chSeparator, BOOL bIgnoreCase)
+{
+ WCHAR szM[SIZ_HUGLEN];
+ DWORD i = 0;
+ LPCWSTR p = szPattern;
+ INT m = -1;
+
+ if (chSeparator == 0)
+ return apxStrMatchW(szString, szPattern, bIgnoreCase);
+ while (*p != L'\0') {
+ if (*p == chSeparator) {
+ m = apxStrMatchW(szString, szM, bIgnoreCase);
+ if (m == 0)
+ return 0;
+ p++;
+ i = 0;
+ szM[0] = L'\0';
+ }
+ else {
+ if (i < SIZ_HUGMAX)
+ szM[i++] = *p++;
+ else
+ return -1;
+ }
+ }
+ szM[i] = L'\0';
+ if (szM[0])
+ return apxStrMatchW(szString, szM, bIgnoreCase);
+ else
+ return m;
+}
+
+LPSTR apxArrayToMultiSzA(APXHANDLE hPool, DWORD nArgs, LPCSTR *lpArgs)
+{
+ DWORD i, l = 0;
+ LPSTR lpSz, p;
+ if (!nArgs)
+ return NULL;
+ for (i = 0; i < nArgs; i++)
+ l += lstrlenA(lpArgs[i]);
+ l += (nArgs + 2);
+
+ p = lpSz = (LPSTR)apxPoolAlloc(hPool, l);
+ for (i = 0; i < nArgs; i++) {
+ lstrcpyA(p, lpArgs[i]);
+ p += lstrlenA(lpArgs[i]);
+ *p++ = '\0';
+ }
+ *p++ = '\0';
+ *p++ = '\0';
+ return lpSz;
+}
+
+void apxStrQuoteInplaceW(LPWSTR szString)
+{
+ LPWSTR p = szString;
+ BOOL needsQuote = FALSE;
+ while (*p) {
+ if (*p++ == L' ') {
+ needsQuote = TRUE;
+ break;
+ }
+ }
+ if (needsQuote) {
+ DWORD l = lstrlenW(szString);
+ AplMoveMemory(&szString[1], szString, l * sizeof(WCHAR));
+ szString[0] = L'"';
+ szString[++l] = L'"';
+ szString[++l] = L'\0';
+ }
+}
+
+DWORD apxStrUnQuoteInplaceA(LPSTR szString)
+{
+ LPSTR p = szString;
+ BOOL needsQuote = FALSE;
+ BOOL inQuote = FALSE;
+ while (*p) {
+ if (*p == '"') {
+ if (inQuote)
+ break;
+ else
+ inQuote = TRUE;
+ }
+ else if (*p == ' ') {
+ if (inQuote) {
+ needsQuote = TRUE;
+ break;
+ }
+ }
+ ++p;
+ }
+ if (!needsQuote)
+ return apxStrCharRemoveA(szString, '"');
+ else
+ return 0;
+}
+
+DWORD apxStrUnQuoteInplaceW(LPWSTR szString)
+{
+ LPWSTR p = szString;
+ BOOL needsQuote = FALSE;
+ BOOL inQuote = FALSE;
+ while (*p) {
+ if (*p == L'"') {
+ if (inQuote)
+ break;
+ else
+ inQuote = TRUE;
+ }
+ else if (*p == L' ') {
+ if (inQuote) {
+ needsQuote = TRUE;
+ break;
+ }
+ }
+ ++p;
+ }
+ if (!needsQuote)
+ return apxStrCharRemoveW(szString, L'"');
+ else
+ return 0;
+}
+
+LPWSTR
+apxMszToCRLFW(APXHANDLE hPool, LPCWSTR szStr)
+{
+ DWORD l, c;
+ LPWSTR rv, b;
+ LPCWSTR p = szStr;
+
+ l = __apxGetMultiSzLengthW(szStr, &c);
+ b = rv = apxPoolCalloc(hPool, (l + c + 2) * sizeof(WCHAR));
+ do {
+ if (*p)
+ *b++ = *p;
+ else {
+ *b++ = L'\r';
+ *b++ = L'\n';
+ }
+ p++;
+ } while( *p || *(p + 1));
+
+ return rv;
+}
+
+LPWSTR
+apxCRLFToMszW(APXHANDLE hPool, LPCWSTR szStr, LPDWORD lpdwBytes)
+{
+ DWORD l, c, n = 0;
+ LPWSTR rv, b;
+
+ l = lstrlenW(szStr);
+ b = rv = apxPoolCalloc(hPool, (l + 2) * sizeof(WCHAR));
+ for (c = 0; c < l; c++) {
+ if (szStr[c] == L'\r') {
+ *b++ = '\0';
+ n++;
+ }
+ else if (szStr[c] != L'\n') {
+ *b++ = szStr[c];
+ n++;
+ }
+ }
+ if (lpdwBytes)
+ *lpdwBytes = (n + 2) * sizeof(WCHAR);
+ return rv;
+}
+
+LPSTR
+apxExpandStrA(APXHANDLE hPool, LPCSTR szString)
+{
+ LPCSTR p = szString;
+ while (*p) {
+ if (*p == '%') {
+ p = szString;
+ break;
+ }
+ ++p;
+ }
+ if (p != szString)
+ return apxPoolStrdupA(hPool, szString);
+ else {
+ DWORD l = ExpandEnvironmentStringsA(szString, NULL, 0);
+ if (l) {
+ LPSTR rv = apxPoolAlloc(hPool, l);
+ l = ExpandEnvironmentStringsA(szString, rv, l);
+ if (l)
+ return rv;
+ else {
+ apxFree(rv);
+ return NULL;
+ }
+ }
+ else
+ return NULL;
+ }
+}
+
+LPWSTR
+apxExpandStrW(APXHANDLE hPool, LPCWSTR szString)
+{
+ LPCWSTR p = szString;
+ while (*p) {
+ if (*p == L'%') {
+ p = szString;
+ break;
+ }
+ ++p;
+ }
+ if (p != szString)
+ return apxPoolStrdupW(hPool, szString);
+ else {
+ DWORD l = ExpandEnvironmentStringsW(szString, NULL, 0);
+ if (l) {
+ LPWSTR rv = apxPoolAlloc(hPool, l * sizeof(WCHAR));
+ l = ExpandEnvironmentStringsW(szString, rv, l);
+ if (l)
+ return rv;
+ else {
+ apxFree(rv);
+ return NULL;
+ }
+ }
+ else
+ return NULL;
+ }
+}
+
+/* To share the semaphores with other processes, we need a NULL ACL
+ * Code from MS KB Q106387
+ */
+PSECURITY_ATTRIBUTES GetNullACL()
+{
+ PSECURITY_DESCRIPTOR pSD;
+ PSECURITY_ATTRIBUTES sa;
+
+ sa = (PSECURITY_ATTRIBUTES) LocalAlloc(LPTR, sizeof(SECURITY_ATTRIBUTES));
+ sa->nLength = sizeof(sizeof(SECURITY_ATTRIBUTES));
+
+ pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH);
+ sa->lpSecurityDescriptor = pSD;
+
+ if (pSD == NULL || sa == NULL) {
+ return NULL;
+ }
+ SetLastError(0);
+ if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION)
+ || GetLastError()) {
+ LocalFree( pSD );
+ LocalFree( sa );
+ return NULL;
+ }
+ if (!SetSecurityDescriptorDacl(pSD, TRUE, (PACL) NULL, FALSE)
+ || GetLastError()) {
+ LocalFree( pSD );
+ LocalFree( sa );
+ return NULL;
+ }
+
+ sa->bInheritHandle = FALSE;
+ return sa;
+}
+
+
+void CleanNullACL(void *sa)
+{
+ if (sa) {
+ LocalFree(((PSECURITY_ATTRIBUTES)sa)->lpSecurityDescriptor);
+ LocalFree(sa);
+ }
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/testchild/testchild.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/testchild/testchild.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/testchild/testchild.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2002-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* ====================================================================
+ * testchild.c
+ *
+ * Contributed by Mladen Turk <mturk at mappingsoft.com>
+ *
+ * 05 Aug 2002
+ * ====================================================================
+ */
+
+#ifndef STRICT
+#define STRICT
+#endif
+#ifndef OEMRESOURCE
+#define OEMRESOURCE
+#endif
+
+#include <windows.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <io.h>
+#include <fcntl.h>
+#include <process.h>
+#include <time.h>
+#include <stdarg.h>
+
+BOOL WINAPI ControlHandler ( DWORD dwCtrlType )
+{
+ switch (dwCtrlType) {
+ case CTRL_BREAK_EVENT:
+ printf("got CTRL+BREAK Event\n");
+ exit(1);
+ return TRUE;
+ case CTRL_C_EVENT:
+ printf("got CTRL+C Event\n");
+ exit(2);
+ return TRUE;
+ break;
+
+ }
+ return FALSE;
+}
+
+//int main(int argc, char **argv, char **envp)
+void __cdecl main(int argc, char **argv)
+
+{
+ int i;
+ char **envp = _environ;
+ SetConsoleCtrlHandler(ControlHandler, TRUE);
+
+ printf("Testing child\n");
+ printf("ARGV:\n");
+ for (i = 0; i < argc; i++)
+ printf("\t%d %s\n", i, argv[i]);
+ printf("ENVP:\n");
+ for (i = 0; envp[i]; i++)
+ printf("\t%d %s\n", i, envp[i]);
+
+ printf("\nChild done...\n");
+ fflush(stdout);
+ for (i = 0; i < 1000; i++)
+ Sleep(100);
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/testchild/testchild.dsp
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/testchild/testchild.dsp 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/testchild/testchild.dsp 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,106 @@
+# Microsoft Developer Studio Project File - Name="testchild" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=testchild - 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 "testchild.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 "testchild.mak" CFG="testchild - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "testchild - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "testchild - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "testchild - 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 Target_Dir ""
+# ADD BASE CPP /nologo /MDd /ZI /W3 /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Gm PRECOMP_VC7_TOBEREMOVED /GZ /c /GX
+# ADD CPP /nologo /MDd /ZI /W3 /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Gm PRECOMP_VC7_TOBEREMOVED /GZ /c /GX
+# ADD BASE MTL /nologo /win32
+# ADD MTL /nologo /win32
+# ADD BASE RSC /l 1033
+# ADD RSC /l 1033
+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 /nologo /out:"Debug\testchild.exe" /incremental:yes /debug /pdb:"Debug\testchild.pdb" /pdbtype:sept /subsystem:console /machine:ix86
+# 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 /nologo /out:"Debug\testchild.exe" /incremental:yes /debug /pdb:"Debug\testchild.pdb" /pdbtype:sept /subsystem:console /machine:ix86
+
+!ELSEIF "$(CFG)" == "testchild - 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 Target_Dir ""
+# ADD BASE CPP /nologo /MD /Zi /W3 /O2 /Ob1 /Oy /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /GF /Gy PRECOMP_VC7_TOBEREMOVED /c /GX
+# ADD CPP /nologo /MD /Zi /W3 /O2 /Ob1 /Oy /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /GF /Gy PRECOMP_VC7_TOBEREMOVED /c /GX
+# ADD BASE MTL /nologo /win32
+# ADD MTL /nologo /win32
+# ADD BASE RSC /l 1033
+# ADD RSC /l 1033
+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 /nologo /out:"Release\testchild.exe" /incremental:no /debug /pdbtype:sept /subsystem:console /opt:ref /opt:icf /machine:ix86
+# 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 /nologo /out:"Release\testchild.exe" /incremental:no /debug /pdbtype:sept /subsystem:console /opt:ref /opt:icf /machine:ix86
+
+!ENDIF
+
+# Begin Target
+
+# Name "testchild - Win32 Debug"
+# Name "testchild - Win32 Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;def;odl;idl;hpj;bat;asm"
+# Begin Source File
+
+SOURCE=testchild.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl;inc"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/testchild/testchild.vcproj
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/testchild/testchild.vcproj 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/testchild/testchild.vcproj 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding = "windows-1250"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.00"
+ Name="testchild"
+ ProjectGUID="{C815B005-1292-47F7-9052-F46676CE2879}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/testchild.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/testchild.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ InlineFunctionExpansion="1"
+ OmitFramePointers="TRUE"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ StringPooling="TRUE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="TRUE"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/testchild.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ </Configuration>
+ </Configurations>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
+ <File
+ RelativePath="testchild.c">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc">
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/xdocs/index.xml
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/xdocs/index.xml 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/procrun/xdocs/index.xml 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+
+<document>
+ <properties>
+ <title>Daemon : Procrun</title>
+ <author email="mturk at apache.org">Mladen Turk</author>
+ </properties>
+
+<body>
+<section name="Introduction">
+<p>
+ Procrun is a set of libraries and applications for making Java
+ applications to run on WIN32 much easier.
+</p>
+</section>
+
+</body>
+</document>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/service/Makefile
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/service/Makefile 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/service/Makefile 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,9 @@
+INCLUDE=-I../lib -I ../../unix/native
+../../../../dist/INSTSVC: instmain.c arguments.o debug.o
+ gcc $(INCLUDE) instmain.c -o ../../../../dist/INSTSVC arguments.o debug.o
+arguments.o: ../../unix/native/arguments.c
+ gcc -c $(INCLUDE) ../../unix/native/arguments.c
+debug.o: ../../unix/native/debug.c
+ gcc -c $(INCLUDE) ../../unix/native/debug.c
+clean:
+ rm -f arguments.o debug.o
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/service/instmain.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/service/instmain.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/service/instmain.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,436 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* @version $Id: instmain.c 232844 2005-08-15 18:16:16Z jfclere $ */
+
+/*
+ * jsvc.exe install program, create the service JavaService
+ */
+
+/* includes */
+#include <windows.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "moni_inst.h"
+
+/* Definitions for booleans */
+typedef enum {
+ false,
+ true
+} bool;
+#include "arguments.h"
+
+VOID Usage()
+{
+ printf( "\r\n - Java service installer\r\n\r\n");
+ printf( " - Usage :\r\n");
+
+ printf( " To install Java service : InstSvc -install ");
+ printf( " [-home JAVA_HOME] [-Dproperty=value]\r\n");
+ printf( " [-cp CLASSPATH] startclass\r\n");
+ printf( " Like:\r\n");
+
+ printf( " InstSvc -install -home c:\\jdk1.3.1_02");
+ printf( " -Dcatalina.home=/home1/jakarta/jakarta-tomcat-4.1/build");
+ printf( " -Djava.io.tmpdir=/var/tmp ");
+ printf( " -cp \"c:\\jdk1.3.1_02\\lib\\tools.jar;");
+ printf( "c:\\home1\\jakarta\\jakarta-tomcat-4.1\\build\\bin\\commons-daemon.jar;");
+ printf( "c:\\home1\\jakarta\\jakarta-tomcat-4.1\\build\\bin\\bootstrap.jar\"");
+ printf( " org.apache.catalina.startup.BootstrapService\r\n");
+
+ printf( " To remove Java service : InstSvc -remove\r\n\r\n");
+ printf( " Use regedit if you want to change something\r\n\r\n");
+ printf( " Note that the service keys are stored under:\r\n");
+ printf( " HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\");
+ printf( "%s",SZSERVICENAME);
+ printf( "\r\n");
+ printf( " The environment keys in:\r\n");
+ printf( " ");
+ printf( "%s",SZKEY_ONSERVE);
+ printf( "\r\n");
+ return;
+}
+
+/* from src/os/win32/service.c (httpd-1.3!) */
+
+BOOL isWindowsNT(void)
+{
+ static BOOL once = FALSE;
+ static BOOL isNT = FALSE;
+
+ if (!once)
+ {
+ OSVERSIONINFO osver;
+ osver.dwOSVersionInfoSize = sizeof(osver);
+ if (GetVersionEx(&osver))
+ if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT)
+ isNT = TRUE;
+ once = TRUE;
+ }
+ return isNT;
+}
+
+
+/* remove the service (first stop it!) NT version */
+
+BOOL RemoveSvcNT (VOID)
+{
+ BOOL removed;
+ SC_HANDLE hManager;
+ SC_HANDLE hService;
+ SERVICE_STATUS svcStatus;
+ DWORD dwCount;
+
+ removed = FALSE;
+ /* open service control manager with full access right */
+ hManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
+ if (NULL != hManager) {
+ /* open existing service */
+ hService = OpenService(hManager, SZSERVICENAME, SERVICE_ALL_ACCESS);
+ if (NULL != hService) {
+ /* get the status of the service */
+ if (QueryServiceStatus(hService, &svcStatus)) {
+ /* and see if the service is stopped */
+ if (SERVICE_STOPPED != svcStatus.dwCurrentState) {
+ /* if not stop the service */
+ ControlService(hService, SERVICE_CONTROL_STOP, &svcStatus);
+ }
+ dwCount = 0;
+ do {
+ if (SERVICE_STOPPED == svcStatus.dwCurrentState) {
+ /* delete the service */
+ if (DeleteService(hService)) {
+ removed = TRUE;
+ break;
+ }
+ }
+ /* wait 10 seconds for the service to stop */
+ Sleep(10000);
+ if (!QueryServiceStatus(hService, &svcStatus)) {
+ /* something went wrong */
+ break;
+ }
+ dwCount++;
+ } while (10 > dwCount);
+ }
+ /* close service handle */
+ CloseServiceHandle(hService);
+ }
+ /* close service control manager */
+ CloseServiceHandle(hManager);
+ }
+ return removed;
+} /* RemoveSvc */
+
+/* remove service (non NT) stopping it looks ugly!!! */
+BOOL RemoveSvc (VOID)
+{
+ HKEY hkey;
+ DWORD rv;
+
+ rv = RegOpenKey(HKEY_LOCAL_MACHINE,
+ "Software\\Microsoft\\Windows\\CurrentVersion\\RunServices",
+ &hkey);
+ if (rv != ERROR_SUCCESS) {
+ printf( "Could not open the RunServices registry key.\r\n");
+ return FALSE;
+ }
+ rv = RegDeleteValue(hkey, SZSERVICENAME);
+ RegCloseKey(hkey);
+ if (rv != ERROR_SUCCESS)
+ printf( "Could not delete the RunServices entry.\r\n");
+
+ rv = RegOpenKey(HKEY_LOCAL_MACHINE,
+ "SYSTEM\\CurrentControlSet\\Services", &hkey);
+ if (rv != ERROR_SUCCESS) {
+ printf( "Could not open the Services registry key.\r\n");
+ return FALSE;
+ }
+ rv = RegDeleteKey(hkey, SZSERVICENAME);
+ RegCloseKey(hkey);
+ if (rv != ERROR_SUCCESS) {
+ printf( "Could not delete the Services registry key.\r\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+/* Install service (NT version) */
+
+BOOL InstallSvcNT (CHAR *svcExePath)
+{
+ BOOL installed;
+ SC_HANDLE hManager;
+ SC_HANDLE hService;
+
+ installed = FALSE;
+ /* open the service control manager with full access right */
+ hManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
+ if (NULL != hManager) {
+ /* create the service */
+ hService = CreateService(hManager,
+ SZSERVICENAME, /* name of the service */
+ SZSERVICEDISPLAYNAME, /* description */
+ SERVICE_ALL_ACCESS,
+ SERVICE_WIN32_OWN_PROCESS, /* type of service */
+ SERVICE_DEMAND_START, /* AUTO_START, startmode */
+ SERVICE_ERROR_NORMAL, /* error treatment */
+ svcExePath, /* path_name */
+ NULL, /* no load order enty */
+ NULL, /* no tag identifier. */
+ NULL, /* dependencies. */
+ NULL, /* LocalSystem account */
+ NULL); /* dummy user password */
+ if (NULL != hService) {
+ /* close service handle */
+ CloseServiceHandle(hService);
+ installed = TRUE;
+ }
+ } else {
+ printf( "OpenSCManager failed\r\n");
+ }
+ return installed;
+}
+
+/* Install service */
+
+BOOL InstallSvc (CHAR *svcExePath)
+{
+ HKEY hkey;
+ DWORD rv;
+ char szPath[MAX_PATH];
+
+ printf( "InstallSvc for non-NT\r\n");
+
+ rv = RegCreateKey(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows"
+ "\\CurrentVersion\\RunServices", &hkey);
+ if (rv != ERROR_SUCCESS) {
+ printf( "Could not open the RunServices registry key\r\n");
+ return FALSE;
+ }
+ rv = RegSetValueEx(hkey, SZSERVICENAME, 0, REG_SZ,
+ (unsigned char *) svcExePath,
+ strlen(svcExePath) + 1);
+ RegCloseKey(hkey);
+ if (rv != ERROR_SUCCESS) {
+ printf( "Could not add %s:%s ",SZSERVICENAME, svcExePath);
+ printf( "to RunServices Registry Key\r\n");
+ return FALSE;
+ }
+
+ strcpy(szPath,
+ "SYSTEM\\CurrentControlSet\\Services\\");
+ strcat(szPath,SZSERVICENAME);
+ rv = RegCreateKey(HKEY_LOCAL_MACHINE, szPath, &hkey);
+ if (rv != ERROR_SUCCESS) {
+ printf( "Could not create/open the %s registry key\r\n",
+ szPath);
+ return FALSE;
+ }
+ rv = RegSetValueEx(hkey, "ImagePath", 0, REG_SZ,
+ (unsigned char *) svcExePath,
+ strlen(svcExePath) + 1);
+ if (rv != ERROR_SUCCESS) {
+ RegCloseKey(hkey);
+ printf( "Could not add ImagePath to our Registry Key\r\n");
+ return FALSE;
+ }
+ rv = RegSetValueEx(hkey, "DisplayName", 0, REG_SZ,
+ (unsigned char *) SZSERVICEDISPLAYNAME,
+ strlen(SZSERVICEDISPLAYNAME) + 1);
+ RegCloseKey(hkey);
+ if (rv != ERROR_SUCCESS) {
+ printf( "Could not add DisplayName to our Registry Key\r\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/*
+ * Fill the registry with the environment variables
+ */
+BOOL InstallEnv (char *var, char *value)
+{
+ BOOL installed;
+ HKEY hKey;
+
+ installed = FALSE;
+ /* create the parameters registry tree */
+ log_debug("InstallEnv: %s:%s",var,value);
+ if (ERROR_SUCCESS == RegCreateKeyEx(HKEY_LOCAL_MACHINE, SZKEY_ONSERVE, 0,
+ NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,
+ &hKey, NULL)) {
+ /* key is created or opened */
+ RegSetValueEx(hKey,var,0,REG_SZ,(BYTE *)value,lstrlen(value)+1);
+ RegCloseKey(hKey);
+ installed = TRUE;
+ }
+ return installed;
+} /* InstallEnv */
+
+/*
+ * Add the arguments to start jsvc like -Dcatalina.home=/home/jakarta/tomcat.
+ */
+BOOL InstallEnvParm(int i,char *value)
+{
+ BOOL installed;
+ HKEY hKey;
+ char var[64];
+
+ sprintf(var,"arg%d",i);
+ log_debug("InstallEnvParm: %s:%s",var,value);
+
+ installed = FALSE;
+ /* create the parameters registry tree */
+ if (ERROR_SUCCESS == RegCreateKeyEx(HKEY_LOCAL_MACHINE,
+ SZKEY_ONSERVEARG, 0,
+ NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,
+ &hKey, NULL)) {
+ /* key is created or opened */
+ RegSetValueEx(hKey,var,0,REG_SZ,
+ (BYTE *)value,lstrlen(value)+1);
+ RegCloseKey(hKey);
+ installed = TRUE;
+ }
+ return installed;
+}
+
+/*
+ * Remove the created keys
+ */
+BOOL RemoveEnv()
+{
+ HKEY hkey;
+ DWORD rv;
+
+ log_debug("RemoveEnv");
+
+ rv = RegOpenKey(HKEY_LOCAL_MACHINE,
+ NULL,
+ &hkey);
+ if (rv != ERROR_SUCCESS) {
+ printf( "Could not open the jsvc registry key.\r\n");
+ return FALSE;
+ }
+ rv = RegDeleteKey(hkey, SZKEY_ONSERVE);
+ RegCloseKey(hkey);
+ if (rv != ERROR_SUCCESS)
+ printf( "Could not delete the jsvc entry.\r\n");
+
+ /* remove the key tree if empty */
+
+ return TRUE;
+}
+
+
+/*
+ * Install or remove the OnServe service and Key in the registry.
+ * no parameter install the OnServe.
+ * -REMOVE: desinstall the OnServe service and Keys.
+ */
+
+INT main (INT argc, CHAR *argv[])
+{
+ BOOL done;
+ arg_data *args=NULL;
+ char szPath[512];
+ char szExePath[512];
+ int i;
+
+ printf( "\r\n - Copyright (c) 2001 The Apache Software Foundation. \r\n");
+ printf( "\r\n");
+ if (GetModuleFileName(NULL, szPath, sizeof(szPath))) {
+ printf( "%s\r\n",szPath);
+ }
+
+ args=arguments(argc,argv);
+ if (args==NULL) {
+ Usage();
+ return(1);
+ }
+
+
+ if (args->install==true) {
+ if (args->home==NULL) {
+ printf( "home empty or not defined...\r\n\r\n");
+ Usage();
+ return(1);
+ }
+ if (args->clas==NULL) {
+ printf( "startclass empty or not defined...\r\n\r\n");
+ Usage();
+ return(1);
+ }
+ printf( "\r\ninstalling...\r\n\r\n");
+
+ /* get the patch from the executable name */
+ for(i=strlen(szPath);i>0;i--)
+ if (szPath[i]=='\\') {
+ szPath[i]='\0';
+ break;
+ }
+ strcpy(szExePath,szPath);
+ strcat(szExePath,SZDEFMONISVCPATH);
+ /* install jsvcservice.exe as a service */
+ if (isWindowsNT())
+ done = InstallSvcNT(szExePath);
+ else
+ done = InstallSvc(szExePath);
+
+ if (done)
+ printf( "InstallSvc done\r\n");
+ else
+ printf( "InstallSvc failed\r\n");
+
+ /* install the environment variable in registry */
+
+ /* should get it from szPath */
+ InstallEnv("JAKARTA_HOME",szPath);
+
+ InstallEnv("CYGWIN",SZCYGWINPATH); /* need APR to get ride of it */
+
+ InstallEnv("JAVA_HOME",args->home);
+
+ InstallEnv("STARTCLASS",args->clas);
+
+ if (args->onum==0) return(0);
+
+ for(i=0;i<args->onum;i++)
+ InstallEnvParm(i,args->opts[i]);
+
+ return(0);
+ }
+
+ if (args->remove==true) {
+ /* remove the service. removing the keys not yet done!!! */
+ printf( "\r\n - removing Java Service...\r\n\r\n");
+ if (isWindowsNT())
+ done = RemoveSvcNT();
+ else
+ done = RemoveSvc();
+ if (!done) {
+ printf( "\r\n - REMOVE FAILED....\r\n\r\n");
+ return(2);
+ }
+ RemoveEnv();
+ return(0);
+ }
+ printf( "\r\nonly -install or -remove supported...\r\n\r\n");
+ Usage();
+ return(1);
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/service/instsvc.dsp
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/service/instsvc.dsp 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/service/instsvc.dsp 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,104 @@
+# Microsoft Developer Studio Project File - Name="InstSvc" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=InstSvc - Win32 Release
+!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 "INSTSVC.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 "INSTSVC.MAK" CFG="InstSvc - Win32 Release"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "InstSvc - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "InstSvc - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "InstSvc - 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 ".\InstSvc.Release"
+# PROP Intermediate_Dir ".\InstSvc.Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
+# ADD CPP /nologo /W3 /GX /O2 /I "../lib" /D "WIN32" /D "_CONSOLE" /YX /FD /D "NDEBUG" /c
+# ADD BASE RSC /l 0x407 /d "NDEBUG"
+# ADD RSC /l 0x407 /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 /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 /nologo /subsystem:console /machine:I386 /out:"../bin/INSTSVC.exe"
+
+!ELSEIF "$(CFG)" == "InstSvc - 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 ".\InstSvc.Debug"
+# PROP Intermediate_Dir ".\InstSvc.Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
+# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /FR /YX /FD /c
+# ADD BASE RSC /l 0x407 /d "_DEBUG"
+# ADD RSC /l 0x407 /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 /nologo /subsystem:console /debug /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 /nologo /subsystem:console /debug /machine:I386
+
+!ENDIF
+
+# Begin Target
+
+# Name "InstSvc - Win32 Release"
+# Name "InstSvc - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
+# Begin Source File
+
+SOURCE=.\instmain.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
+# Begin Source File
+
+SOURCE=..\lib\moni_inst.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/service/instsvc.dsw
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/service/instsvc.dsw 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/service/instsvc.dsw 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 5.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "InstSvc"=.\INSTSVC.DSP - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/signals/kills.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/signals/kills.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/signals/kills.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,47 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* @version $Id: kills.c 155409 2005-02-26 12:57:06Z dirkv $ */
+
+/*
+ * as Windows does not support signal, jsvc uses events to emulate them.
+ * The supported signal is SIGTERM.
+ * signals.c contains the signal handler logic.
+ */
+#include <windows.h>
+#include <stdio.h>
+
+/*
+ * Send a clean termination signal to a process
+ * it is like kill(pid,SIGTERM);
+ */
+int TermPid(long pid)
+{
+char Name[256];
+HANDLE hevint;
+BOOL rc;
+
+ sprintf(Name,"TERM%ld",pid);
+
+ hevint = OpenEvent(EVENT_MODIFY_STATE,FALSE,Name);
+ if (hevint == NULL) return(-1); /* failed */
+
+ rc = SetEvent(hevint);
+ CloseHandle(hevint);
+
+ if (rc) return(0);
+ return(-1);
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/supcalls_nt/vdenv.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/supcalls_nt/vdenv.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/nt/supcalls_nt/vdenv.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,178 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* @version $Id: vdenv.c 155409 2005-02-26 12:57:06Z dirkv $ */
+
+/* Read the Win-NT register and set the jsvc environment variable. */
+/* XXX We should use a property file instead registry */
+
+/* XXX Set the PATH (for dynamic linking!) what about libapr*.so? */
+
+#include <windows.h>
+#include "moni_inst.h"
+
+#define ENVSIZE 1024
+
+int MySetEnvironmentVariable(char *name, char *data)
+{
+char Variable[ENVSIZE];
+
+ strcpy(Variable,name);
+ strcat(Variable,"=");
+ strcat(Variable,data);
+ if (putenv(Variable)) return(-1);
+ return(0);
+}
+/*
+ * FUNCTION: OnServeSetEnv()
+ *
+ * PURPOSE: Actual code of the routine that reads the registry and
+ * set the OnServe environment variables.
+ * The PATH is needed for the dynamic linking.
+ *
+ * RETURN VALUE:
+ * 0 : All OK.
+ * <0: Something Failed. (Registry cannot be read or one key cannot be read).
+ *
+*/
+int OnServeSetEnv ()
+{
+HKEY hKey=NULL;
+DWORD Type;
+char jakarta_home[ENVSIZE]; /* for the path */
+char cygwin[ENVSIZE]; /* for the path */
+char Data[ENVSIZE];
+DWORD LData;
+int qreturn=0;
+
+
+ /* Read the registry and set environment. */
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, SZKEY_ONSERVE,
+ 0, KEY_READ,&hKey) != ERROR_SUCCESS)
+ return(-1);
+
+ /* read key and set environment. */
+
+ /* JAKARTA_HOME */
+ LData = sizeof(Data);
+ if (RegQueryValueEx(hKey,"JAKARTA_HOME",NULL,&Type,Data,&LData)==ERROR_SUCCESS) {
+ strcpy(jakarta_home,Data);
+ MySetEnvironmentVariable("JAKARTA_HOME",Data);
+ }
+ else
+ qreturn = -2;
+
+ /* CYGWIN */
+ LData = sizeof(Data);
+ if (RegQueryValueEx(hKey,"CYGWIN",NULL,&Type,Data,&LData)==ERROR_SUCCESS) {
+ strcpy(cygwin,Data);
+ MySetEnvironmentVariable("CYGWIN",Data);
+ }
+ else
+ qreturn = -3;
+
+ /* JAVA_HOME */
+ LData = sizeof(Data);
+ if (RegQueryValueEx(hKey,"JAVA_HOME",NULL,&Type,Data,&LData)
+ ==ERROR_SUCCESS) {
+ MySetEnvironmentVariable("JAVA_HOME",Data);
+ }
+ else
+ qreturn = -4;
+
+ RegCloseKey(hKey);
+ hKey = NULL;
+
+ /* set the PATH otherwise nothing works!!! */
+ LData = sizeof(Data);
+ if (!GetEnvironmentVariable("PATH",Data,LData)) {
+ strcpy(Data,jakarta_home);
+ }
+ else {
+ strcat(Data,";");
+ strcat(Data,jakarta_home);
+ }
+ strcat(Data,"\\bin");
+
+ strcat(Data,";");
+ strcat(Data,cygwin);
+ strcat(Data,"\\bin");
+
+ MySetEnvironmentVariable("PATH",Data);
+
+ return(qreturn);
+}
+
+/*
+ * Build the jsvc.exe command using the registry information.
+ */
+int BuildCommand(char *data)
+{
+ int i;
+ LONG lRet;
+ DWORD dwIndex;
+ char name[128];
+ DWORD lname;
+ char value[256];
+ DWORD lvalue;
+ DWORD nvalue;
+ DWORD Type;
+ HKEY hKey=NULL;
+
+
+ strcat(data,"\\jsvc.exe -nodetach ");
+
+ /* Read the registry and set environment. */
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, SZKEY_ONSERVEARG,
+ 0, KEY_READ,&hKey) != ERROR_SUCCESS)
+ return(-1);
+ if (RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL,
+ &nvalue,NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
+ return(-2);
+
+ /* Read the arguments */
+ for (i=0;i<nvalue;i++) {
+ lname = sizeof(name);
+ lvalue = sizeof(value);
+
+ lRet = RegEnumValue (hKey, i, name, &lname, NULL, NULL,
+ value, &lvalue);
+ if (lRet != ERROR_SUCCESS) {
+ RegCloseKey(hKey);
+ return(-3);
+ }
+
+ strncat(data,value,lvalue);
+ strcat(data," ");
+ }
+ RegCloseKey(hKey);
+
+ /* Read the start class. */
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, SZKEY_ONSERVE,
+ 0, KEY_READ,&hKey) != ERROR_SUCCESS)
+ return(-4);
+ lvalue = sizeof(value);
+ if (RegQueryValueEx(hKey,"STARTCLASS",NULL,&Type,value,&lvalue)
+ !=ERROR_SUCCESS) {
+ RegCloseKey(hKey);
+ return(-5);
+ }
+ RegCloseKey(hKey);
+
+ strncat(data,value,lvalue);
+
+ return(0);
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/CHANGES.txt
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/CHANGES.txt 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/CHANGES.txt 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,30 @@
+JAKARTA COMMONS DAEMON (UNIX) CHANGELOG:
+Last modified at [$Date: 2006-04-27 12:38:15 +0200 (tor, 27 apr 2006) $]
+
+Changes with 1.0.1
+ * Allow enableassertions -ea (PR 304310).
+ * Add -lpthread to LDFLAGS on Linux (PR 30177).
+ * Add support for x86_64 (PR 27523).
+ * Add support for Tru64 (PR 29465).
+ * Remove the pid file when son exits correctly (PR 31614).
+ * Add support for JVM-4.1.x on MAC OS X (part of PR 31613).
+ * Prevent starting jsvc several times with the same pidfile (PR 33580).
+ * Finish fixing 31613, automatic detection of JAVA_HOME and headers locations.
+ * -wait and -stop parameters.
+ * fix 34851.
+ * Don't break when set_caps() failed and the user is unchanged (linux).
+
+Changes with next-unreleased-yet version.
+ * Add support for hp-ux.
+ * fix 35017.
+ * fix 36051.
+ * fix 35318.
+ * fix 35340.
+ * fix 36030. (using /proc/self/exe and readlink).
+ * fix 35403.
+ * fix 35659.
+ * fix 36031.
+ * fix 36058. (mask used for pid/log and load: 0077).
+ * fix 38992.
+ * Improve support of Mac OS X Server 10.4
+ * Restart when JVM process is killed (abort is not alway called).
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/INSTALL.txt
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/INSTALL.txt 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/INSTALL.txt 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,47 @@
+To build the service libraries and binary under an UNIX operating
+system you will need:
+
+ An ANSI-C compliant compiler (GCC is good)
+ A Java Platform 2 compliant SDK
+ GNU AutoConf (when building for SVN).
+
+When building from SVN sources you need to build the "configure" program with:
+
+ sh support/buildconf.sh
+(Note it is possible to replace sh by any compatible shell like bash, ksh).
+
+Once the configure script is generated, run it (remember to specify
+either the --with-java=<dir> parameter or set the JAVA_HOME environment
+to point to your JDK installation. For example:
+
+ ./configure --with-java=/usr/java
+
+or
+
+ JAVA_HOME=/usr/java
+ export JAVA_HOME
+ ./configure
+
+or (when using gcj (use fastjar for jar))
+ JAVAC=gcj; export JAVAC
+ JAVACFLAGS=-c; export JAVACFLAGS
+ ./configure
+
+Note: On Mac OS X <dir> is /System/Library/Frameworks/JavaVM.framework/Home.
+
+If your operating system is supported, configure will go thru cleanly,
+otherwise it will report an error (please send us the details of your
+OS/JDK, or a patch against the sources). To build the binaries and
+libraries simply do:
+
+ make
+
+This will generate the file: ./jsvc.
+It should be straightforward from here on. To check the allowed parameters
+for the jsvc binary simply do
+
+ ./native/jsvc -help
+
+Note: On Linux the module capabilities should be loaded, when using -user root
+make sure you REALLY understand what capabilities does (for example for
+files access: the downgraded root may not be able to read some files!).
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/Makedefs.in
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/Makedefs.in 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/Makedefs.in 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,31 @@
+#
+# Copyright 1999-2004 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# @author Pier Fumagalli <mailto:pier.fumagalli at eng.sun.com>
+# @version $Id: Makedefs.in 410153 2006-05-29 21:05:17Z jfclere $
+
+CC = @CC@
+JAVAC = @JAVAC@
+JAR = @JAR@
+CFLAGS = @CFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+JAVACFLAGS = @JAVACFLAGS@
+RANLIB = @RANLIB@
+LDCMD = @LDCMD@
+
+.c.o:
+ $(CC) $(CFLAGS) -c $< -o $@
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/Makefile.in
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/Makefile.in 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/Makefile.in 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,39 @@
+#
+# Copyright 1999-2004 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# @author Pier Fumagalli <mailto:pier.fumagalli at eng.sun.com>
+# @version $Id: Makefile.in 208816 2005-07-02 02:08:43Z billbarker $
+
+SUBDIRS = native
+
+all: native/all
+
+native/all:
+ (cd native; $(MAKE) all)
+
+clean:
+ (cd native; $(MAKE) clean)
+
+distclean: clean
+ rm -f config.cache
+ rm -f config.log
+ rm -f config.status
+ rm -f native/Makefile
+ rm -f Makefile
+ rm -f Makedefs
+
+realclean: distclean
+ rm -f configure
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/configure.in
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/configure.in 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/configure.in 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,114 @@
+dnl
+dnl Copyright 1999-2004 The Apache Software Foundation
+dnl
+dnl Licensed under the Apache License, Version 2.0 (the "License");
+dnl you may not use this file except in compliance with the License.
+dnl You may obtain a copy of the License at
+dnl
+dnl http://www.apache.org/licenses/LICENSE-2.0
+dnl
+dnl Unless required by applicable law or agreed to in writing, software
+dnl distributed under the License is distributed on an "AS IS" BASIS,
+dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+dnl See the License for the specific language governing permissions and
+dnl limitations under the License.
+dnl
+
+dnl -------------------------------------------------------------------------
+dnl Author Pier Fumagalli <mailto:pier.fumagalli at eng.sun.com>
+dnl Version $Id: configure.in 292274 2005-09-28 19:26:12Z jfclere $
+dnl -------------------------------------------------------------------------
+
+dnl -------------------------------------------------------------------------
+dnl Initialize AutoConf
+dnl -------------------------------------------------------------------------
+
+AC_PREREQ(2.53)
+
+sinclude(./support/apfunctions.m4)dnl
+sinclude(./support/apjava.m4)dnl
+sinclude(./support/apsupport.m4)dnl
+AC_INIT(configure.in)
+AC_CONFIG_AUX_DIR(./support)
+
+dnl -------------------------------------------------------------------------
+dnl Check current host (forget about cross compilation) and validate it
+dnl against the cache (fail if the cache differs)
+dnl -------------------------------------------------------------------------
+AP_MSG_HEADER([Current host])
+AC_CANONICAL_HOST()
+AP_CANONICAL_HOST_CHECK()
+
+dnl -------------------------------------------------------------------------
+dnl Check C environment
+dnl -------------------------------------------------------------------------
+AP_MSG_HEADER([C-Language compilation tools])
+AC_PROG_CC()
+AC_CHECK_TOOL(RANLIB, ranlib, :)
+
+dnl -------------------------------------------------------------------------
+dnl Check if this host is supported
+dnl -------------------------------------------------------------------------
+AP_MSG_HEADER([Host support])
+AP_SUPPORTED_HOST()
+if test "$supported_os" = "darwin"
+then
+ if test -z "$JAVA_HOME" -a -d /System/Library/Frameworks/JavaVM.framework/Home; then
+ JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
+ fi
+
+ _prevdir=`/bin/pwd`
+ if test -n "$JAVA_HOME" -a -d "$JAVA_HOME/include"; then
+ cd "$JAVA_HOME/include"
+ elif test -n "$JAVA_HOME" -a -d "$JAVA_HOME/../Headers"; then
+ cd "$JAVA_HOME/../Headers"
+ else
+ cd /System/Library/Frameworks/JavaVM.framework/Headers
+ fi
+ CFLAGS="$CFLAGS -I`/bin/pwd -P`"
+ cd $_prevdir
+ unset _prevdir
+fi
+
+dnl -------------------------------------------------------------------------
+dnl Check JAVA environment
+dnl -------------------------------------------------------------------------
+AP_MSG_HEADER([Java compilation tools])
+AP_JAVA()
+AP_SABLEVM()
+AP_KAFFE()
+AP_PROG_JAVAC()
+AP_PROG_JAR()
+if test "$supported_os" != "darwin"
+then
+ CFLAGS="$CFLAGS -I$JAVA_HOME/include -I$JAVA_HOME/include/$supported_os"
+fi
+
+dnl -------------------------------------------------------------------------
+dnl Add gcc specific CFLAGS.
+dnl -------------------------------------------------------------------------
+if test "$GCC" = "yes"
+then
+ CFLAGS="$CFLAGS -Wall -Wstrict-prototypes"
+ AC_MSG_RESULT([gcc flags added])
+fi
+dnl -------------------------------------------------------------------------
+dnl Add gcc specific CFLAGS.
+dnl -------------------------------------------------------------------------
+if test -z "$LDCMD"
+then
+ LDCMD="$CC"
+fi
+AC_SUBST(LDCMD)
+
+dnl -------------------------------------------------------------------------
+dnl Random programs we need to compile locally
+dnl -------------------------------------------------------------------------
+AP_MSG_HEADER([Writing output files])
+AC_OUTPUT(Makefile Makedefs native/Makefile)
+
+dnl -------------------------------------------------------------------------
+dnl Done
+dnl -------------------------------------------------------------------------
+AP_MSG_HEADER([All done])
+AC_MSG_RESULT([Now you can issue "make"])
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/man/README
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/man/README 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/man/README 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,20 @@
+To build it use:
+docbook2man jsvc.1.xml
+
+If your docbook2man uses xalan and you are behind a firewall
+Modify jsvc.1.xml as below:
++++
+Index: jsvc.1.xml
+===================================================================
+--- jsvc.1.xml (revision 170004)
++++ jsvc.1.xml (working copy)
+@@ -1,6 +1,6 @@
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+- "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
++ "docbookx.dtd">
+ <refentry id='jsvc1'>
+ <refmeta>
+ <refentrytitle>JSVC</refentrytitle>
++++
+Use fetch.sh to get docbook files.
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/man/fetch.sh
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/man/fetch.sh 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/man/fetch.sh 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,21 @@
+mkdir -p ent
+rm -f JSVC.1
+while true
+do
+ FILE=`docbook2man jsvc.1.xml 2>&1 | grep FileNotFoundException | awk -F FileNotFoundException: ' { print $2 } ' | awk ' { print $1 } '`
+ if [ -f JSVC.1 ]
+ then
+ break
+ fi
+ echo "FILE: $FILE"
+ file=`basename $FILE`
+ dir=`dirname $FILE`
+ man=`basename $dir`
+ echo "file: $file dir: $dir man: $man"
+ if [ "$man" = "ent" ]
+ then
+ (cd ent; wget http://www.oasis-open.org/docbook/xml/4.1.2/ent/$file)
+ else
+ wget http://www.oasis-open.org/docbook/xml/4.1.2/$file
+ fi
+done
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/man/jsvc.1.xml
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/man/jsvc.1.xml 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/man/jsvc.1.xml 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
+<refentry id='jsvc1'>
+ <refmeta>
+ <refentrytitle>JSVC</refentrytitle>
+ <manvolnum>1</manvolnum>
+ <refmiscinfo class='date'>May 2005</refmiscinfo>
+ <refmiscinfo class='source'>Jsvc version 1.0.1</refmiscinfo>
+ <refmiscinfo class='manual'>Jakarta project</refmiscinfo>
+ </refmeta>
+ <refnamediv id='name'>
+ <refname>jsvc</refname>
+ <refpurpose>application to launch java daemon</refpurpose>
+ </refnamediv>
+ <!-- body begins here -->
+ <refsynopsisdiv id='synopsis'>
+ <cmdsynopsis>
+ <command>jsvc</command>
+ <arg choice='opt'>-jvm <replaceable>JVM name</replaceable></arg>
+ <arg choice='opt'>-classpath <replaceable>path</replaceable></arg>
+ <arg choice='opt'>-cp <replaceable>path</replaceable></arg>
+ <arg choice='opt'>-home <replaceable>directory</replaceable></arg>
+ <arg choice='opt'>-version</arg>
+ <arg choice='opt'>-help</arg>
+ <arg choice='opt'>-?</arg>
+ <arg choice='opt'>-nodetach</arg>
+ <arg choice='opt'>-debug</arg>
+ <arg choice='opt'>-check</arg>
+ <arg choice='opt'>-user <replaceable>user</replaceable></arg>
+ <arg choice='opt'>-wait <replaceable>waittime</replaceable></arg>
+ <arg choice='opt'>-stop</arg>
+ <arg choice='opt'>-verbose<replaceable>:class|gc|jni</replaceable></arg>
+ <arg choice='opt'>-outfile <replaceable>/full/path/to/file</replaceable></arg>
+ <arg choice='opt'>-errfile <replaceable>/full/path/to/file</replaceable></arg>
+ <arg choice='opt'>-pidfile <replaceable>/full/path/to/file</replaceable></arg>
+ <arg choice='opt'>-Dproperty=<replaceable>value</replaceable></arg>
+ <arg choice='opt'>-X<replaceable>option</replaceable></arg>
+ <!-- end of the new arguments -->
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1 id="description">
+ <title>DESCRIPTION</title>
+ <para><command>jsvc</command> executes <emphasis remap="I">classfile</emphasis>
+ that implements a Daemon interface.</para>
+ </refsect1>
+
+ <refsect1 id="options">
+ <title>OPTIONS</title>
+
+ <variablelist remap="TP">
+ <varlistentry>
+ <term><option>-jvm</option> JVM name</term>
+ <listitem>
+ <para>use a specific Java Virtual Machine.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-cp/ -classpath</option> directory and zip/jar
+ files</term>
+ <listitem>
+ <para>set search path for service classes and resouces</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-home</option> directory</term>
+ <listitem>
+ <para>set the path of your JDK or JRE installation (or set
+ the JAVA_HOME environment variable)
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-version</option></term>
+ <listitem>
+ <para>show the current Java environment version (to check
+ correctness of -home and -jvm. Implies -nodetach)</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-help</option></term>
+ <listitem>
+ <para>show this help page (implies -nodetach)</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-nodetach</option></term>
+ <listitem>
+ <para>don't detach from parent process and become a daemon</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-debug</option></term>
+ <listitem>
+ <para>verbosely print debugging information</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-check</option></term>
+ <listitem>
+ <para>only check service (implies -nodetach)</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-stop</option></term>
+ <listitem>
+ <para>stop the service using the file given in the -pidfile option</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-wait</option> waittime</term>
+ <listitem>
+ <para>wait up to waittime seconds for the service to start
+ waittime should multiple of 10 (min=10)
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-user</option> user</term>
+ <listitem>
+ <para>user used to run the daemon (defaults to current user)</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-verbose[:class|gc|jni]</option></term>
+ <listitem>
+ <para>enable verbose output</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-outfile</option> /full/path/to/file</term>
+ <listitem>
+ <para>Location for output from stdout (defaults to /dev/null). Use
+ the value '&2' to simulate '1>&2'</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-errfile</option> /full/path/to/file</term>
+ <listitem>
+ <para>Location for output from stderr (defaults to /dev/null). Use
+ the value '&1' to simulate '2>&1'</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-pidfile</option> /full/path/to/file</term>
+ <listitem>
+ <para>Location for output from the file containing the pid of jsvc
+ (defaults to /var/run/jsvc.pid)</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-D</option><name>=<value></term>
+ <listitem>
+ <para>set a Java system property</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-X</option><option></term>
+ <listitem>
+ <para>set Virtual Machine specific option</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+
+ <refsect1 id='author'><title>AUTHOR</title>
+ <para>JSVC is part of the Jakarta Commons Daemon project. Authors are
+ Jean-Frederic Clere, Remy Maucherat, Yoav Shapira, Bill Barker. JSVC is
+ under the Apache License Version 2.0.</para>
+ </refsect1>
+
+</refentry>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/Makefile.in
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/Makefile.in 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/Makefile.in 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,43 @@
+#
+# Copyright 2001-2004 The Apache Software Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# @author Pier Fumagalli <mailto:pier.fumagalli at eng.sun.com>
+# @version $Id: Makefile.in 410153 2006-05-29 21:05:17Z jfclere $
+
+include ../Makedefs
+
+OBJS = arguments.o \
+ debug.o \
+ dso-dlfcn.o \
+ dso-dyld.o \
+ help.o \
+ home.o \
+ java.o \
+ location.o \
+ replace.o \
+ signals.o
+
+all: jsvc libservice.a
+
+libservice.a: $(OBJS)
+ ar cr libservice.a $(OBJS)
+ $(RANLIB) libservice.a
+
+jsvc: jsvc-unix.o libservice.a
+ $(LDCMD) $(LDFLAGS) jsvc-unix.o libservice.a $(LIBS) -o ../jsvc
+
+clean:
+ rm -f $(OBJS) ../jsvc jsvc-unix.o libservice.a
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/Tomcat.sh
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/Tomcat.sh 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/Tomcat.sh 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,77 @@
+#!/bin/sh
+##############################################################################
+#
+# Copyright 2001-2004 The Apache Software Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+##############################################################################
+#
+# Small shell script to show how to start/stop Tomcat using jsvc
+# If you want to have Tomcat running on port 80 please modify the server.xml
+# file:
+#
+# <!-- Define a non-SSL HTTP/1.1 Connector on port 80 -->
+# <Connector className="org.apache.catalina.connector.http.HttpConnector"
+# port="80" minProcessors="5" maxProcessors="75"
+# enableLookups="true" redirectPort="8443"
+# acceptCount="10" debug="0" connectionTimeout="60000"/>
+#
+# This is for of Tomcat-4.1.x (Apache Tomcat/4.1)
+#
+# Adapt the following lines to your configuration
+JAVA_HOME=/usr/java/jdk1.3.1
+CATALINA_HOME=/home1/jakarta/jakarta-tomcat-4.1/build
+DAEMON_HOME=/home1/jakarta/jakarta-commons/daemon
+TOMCAT_USER=jakarta
+TMP_DIR=/var/tmp
+CATALINA_OPTS=
+CLASSPATH=\
+$JAVA_HOME/lib/tools.jar:\
+$DAEMON_HOME/dist/commons-daemon.jar:\
+$CATALINA_HOME/bin/bootstrap.jar
+
+case "$1" in
+ start)
+ #
+ # Start Tomcat
+ #
+ $DAEMON_HOME/src/native/unix/jsvc \
+ -user $TOMCAT_USER \
+ -home $JAVA_HOME \
+ -Dcatalina.home=$CATALINA_HOME \
+ -Djava.io.tmpdir=$TMP_DIR \
+ -outfile $CATALINA_HOME/logs/catalina.out \
+ -errfile '&1' \
+ $CATALINA_OPTS \
+ -cp $CLASSPATH \
+ org.apache.catalina.startup.BootstrapService
+ #
+ # To get a verbose JVM
+ #-verbose \
+ # To get a debug of jsvc.
+ #-debug \
+ ;;
+
+ stop)
+ #
+ # Stop Tomcat
+ #
+ PID=`cat /var/run/jsvc.pid`
+ kill $PID
+ ;;
+
+ *)
+ echo "Usage tomcat.sh start/stop"
+ exit 1;;
+esac
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/Tomcat.sh
___________________________________________________________________
Name: svn:executable
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/Tomcat5.sh
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/Tomcat5.sh 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/Tomcat5.sh 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,88 @@
+#!/bin/sh
+##############################################################################
+#
+# Copyright 2004 The Apache Software Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##############################################################################
+#
+# Small shell script to show how to start/stop Tomcat using jsvc
+# If you want to have Tomcat running on port 80 please modify the server.xml
+# file:
+#
+# <!-- Define a non-SSL HTTP/1.1 Connector on port 80 -->
+# <Connector className="org.apache.catalina.connector.http.HttpConnector"
+# port="80" minProcessors="5" maxProcessors="75"
+# enableLookups="true" redirectPort="8443"
+# acceptCount="10" debug="0" connectionTimeout="60000"/>
+#
+# That is for Tomcat-5.0.x (Apache Tomcat/5.0)
+#
+# Adapt the following lines to your configuration
+JAVA_HOME=/home2/java/j2sdk1.4.2_03
+CATALINA_HOME=/home/tomcat5/tomcat5/jakarta-tomcat-5/build
+DAEMON_HOME=/home/jfclere/daemon
+TOMCAT_USER=tomcat5
+
+# for multi instances adapt those lines.
+TMP_DIR=/var/tmp
+PID_FILE=/var/run/jsvc.pid
+CATALINA_BASE=/home/tomcat5/tomcat5/jakarta-tomcat-5/build
+
+CATALINA_OPTS="-Djava.library.path=/home/jfclere/jakarta-tomcat-connectors/jni/native/.libs"
+CLASSPATH=\
+$JAVA_HOME/lib/tools.jar:\
+$CATALINA_HOME/bin/commons-daemon.jar:\
+$CATALINA_HOME/bin/bootstrap.jar
+
+case "$1" in
+ start)
+ #
+ # Start Tomcat
+ #
+ $DAEMON_HOME/src/native/unix/jsvc \
+ -user $TOMCAT_USER \
+ -home $JAVA_HOME \
+ -Dcatalina.home=$CATALINA_HOME \
+ -Dcatalina.base=$CATALINA_BASE \
+ -Djava.io.tmpdir=$TMP_DIR \
+ -wait 10 \
+ -pidfile $PID_FILE \
+ -outfile $CATALINA_HOME/logs/catalina.out \
+ -errfile '&1' \
+ $CATALINA_OPTS \
+ -cp $CLASSPATH \
+ org.apache.catalina.startup.Bootstrap
+ #
+ # To get a verbose JVM
+ #-verbose \
+ # To get a debug of jsvc.
+ #-debug \
+ exit $?
+ ;;
+
+ stop)
+ #
+ # Stop Tomcat
+ #
+ $DAEMON_HOME/src/native/unix/jsvc \
+ -stop \
+ -pidfile $PID_FILE \
+ org.apache.catalina.startup.Bootstrap
+ exit $?
+ ;;
+
+ *)
+ echo "Usage tomcat.sh start/stop"
+ exit 1;;
+esac
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/Tomcat5.sh
___________________________________________________________________
Name: svn:executable
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/arguments.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/arguments.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/arguments.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,310 @@
+/*
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+/* @version $Id: arguments.c 396993 2006-04-25 21:50:36Z jfclere $ */
+#include "jsvc.h"
+
+/* Return the argument of a command line option */
+static char *optional(int argc, char *argv[], int argi) {
+
+ argi++;
+ if (argi>=argc) return(NULL);
+ if (argv[argi]==NULL) return(NULL);
+ if (argv[argi][0]=='-') return(NULL);
+ return(strdup(argv[argi]));
+}
+
+/* Parse command line arguments */
+static arg_data *parse(int argc, char *argv[]) {
+ arg_data *args=NULL;
+ char *temp=NULL;
+ char *cmnd=NULL;
+ int tlen=0;
+ int x=0;
+
+ /* Create the default command line arguments */
+ args=(arg_data *)malloc(sizeof(arg_data));
+ args->pidf="/var/run/jsvc.pid"; /* The default PID file */
+ args->user=NULL; /* No user switching by default */
+ args->dtch=true; /* Do detach from parent */
+ 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->stop=false; /* Stop a running jsvc */
+ args->wait=0; /* Wait until jsvc has started the JVM */
+ 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 */
+ args->opts=(char **)malloc(argc*sizeof(char *));
+ args->clas=NULL; /* No class predefined */
+ args->anum=0; /* Zero class specific arguments but make room*/
+ args->outfile="/dev/null"; /* Swallow by default */
+ args->errfile="/dev/null"; /* Swallow by default */
+ args->args=(char **)malloc(argc*sizeof(char *));
+ args->procname = "jsvc.exec";
+ /* Set up the command name */
+ cmnd=strrchr(argv[0],'/');
+ if (cmnd==NULL) cmnd=argv[0];
+ else cmnd++;
+ log_prog=strdup(cmnd);
+
+ /* Iterate thru command line arguments */
+ for (x=1; x<argc; x++) {
+
+ if ((strcmp(argv[x],"-cp")==0)||(strcmp(argv[x],"-classpath")==0)) {
+ temp=optional(argc,argv,x++);
+ if (temp==NULL) {
+ log_error("Invalid classpath specified");
+ return(NULL);
+ }
+ tlen=strlen(temp)+20;
+ args->opts[args->onum]=(char *)malloc(tlen*sizeof(char));
+ sprintf(args->opts[args->onum],"-Djava.class.path=%s",temp);
+ args->onum++;
+
+ } else if (strcmp(argv[x],"-jvm")==0) {
+ args->name=optional(argc,argv,x++);
+ if (args->name==NULL) {
+ log_error("Invalid Java VM name specified");
+ return(NULL);
+ }
+
+ } else if (strcmp(argv[x],"-home")==0) {
+ args->home=optional(argc,argv,x++);
+ if (args->home==NULL) {
+ log_error("Invalid Java Home specified");
+ return(NULL);
+ }
+
+ } else if (strcmp(argv[x],"-user")==0) {
+ args->user=optional(argc,argv,x++);
+ if (args->user==NULL) {
+ log_error("Invalid user name specified");
+ return(NULL);
+ }
+
+ } else if (strcmp(argv[x],"-version")==0) {
+ args->vers=true;
+ args->dtch=false;
+
+ } else if ((strcmp(argv[x],"-?")==0)||(strcmp(argv[x],"-help")==0)
+ ||(strcmp(argv[x],"--help")==0)) {
+ args->help=true;
+ args->dtch=false;
+ return(args);
+
+ } else if (strcmp(argv[x],"-X")==0) {
+ log_error("Option -X currently unsupported");
+ log_error("Please use \"java -X\" to see your extra VM options");
+
+ } else if (strcmp(argv[x],"-debug")==0) {
+ log_debug_flag=true;
+
+ } else if (strcmp(argv[x],"-wait")==0) {
+ temp=optional(argc,argv,x++);
+ if (temp!=NULL)
+ args->wait=atoi(temp);
+ if (args->wait<10) {
+ log_error("Invalid wait time specified (min=10)");
+ return(NULL);
+ }
+
+ } else if (strcmp(argv[x],"-stop")==0) {
+ args->stop=true;
+
+ } else if (strcmp(argv[x],"-check")==0) {
+ args->chck=true;
+ args->dtch=false;
+
+ } 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) {
+ log_error("Invalid PID file specified");
+ return(NULL);
+ }
+
+ } else if(strcmp(argv[x],"-outfile") == 0) {
+ args->outfile=optional(argc, argv, x++);
+ if(args->outfile == NULL) {
+ log_error("Invalid Output File specified");
+ return(NULL);
+ }
+ } else if(strcmp(argv[x],"-errfile") == 0) {
+ args->errfile=optional(argc, argv, x++);
+ if(args->errfile == NULL) {
+ log_error("Invalid Error File specified");
+ return(NULL);
+ }
+ } else if (strstr(argv[x],"-verbose")==argv[x]) {
+ args->opts[args->onum++]=strdup(argv[x]);
+
+#ifdef HAVE_KAFFEVM
+ } else if (strstr(argv[x],"-vmdebug")==argv[x]) {
+ args->opts[args->onum++]=strdup(argv[x]);
+ temp=optional(argc,argv,x++);
+ if (temp==NULL) {
+ log_error("vmdebug option requires a debug flag.");
+ return(NULL);
+ }
+ args->opts[args->onum++]=strdup(temp);
+#endif
+ } else if (strcmp(argv[x],"-D")==0) {
+ log_error("Parameter -D must be followed by <name>=<value>");
+ return(NULL);
+
+ } else if (strstr(argv[x],"-D")==argv[x]) {
+ temp=strchr(argv[x],'=');
+ if (temp==NULL) {
+ log_debug("Parameter -D must contain one '=' character");
+ }
+ if (temp==argv[x]+2) {
+ log_error("A property name must be specified before '='");
+ return(NULL);
+ }
+ args->opts[args->onum++]=strdup(argv[x]);
+
+ } else if (strstr(argv[x],"-X")==argv[x]) {
+ args->opts[args->onum++]=strdup(argv[x]);
+
+ } else if (strstr(argv[x],"-ea")==argv[x]) {
+ args->opts[args->onum++]=strdup(argv[x]);
+
+ } else if (strcmp(argv[x],"-procname") == 0) {
+ args->procname = optional(argc, argv, x++);
+ if( args->procname == NULL) {
+ log_error("Invalid process name specified");
+ return (NULL);
+ }
+
+ /* -agentlib: -agentpath: -javaagent: 1.5.x JVM */
+ } else if (strstr(argv[x],"-agentlib:")==argv[x]) {
+ args->opts[args->onum++]=strdup(argv[x]);
+
+ } else if (strstr(argv[x],"-agentpath:")==argv[x]) {
+ args->opts[args->onum++]=strdup(argv[x]);
+
+ } else if (strstr(argv[x],"-javaagent:")==argv[x]) {
+ args->opts[args->onum++]=strdup(argv[x]);
+
+ } else if (strstr(argv[x],"-")==argv[x]) {
+ log_error("Invalid option %s",argv[x]);
+ return(NULL);
+
+ } else {
+ args->clas=strdup(argv[x]);
+ break;
+ }
+ }
+
+ if (args->clas==NULL && args->remove==false) {
+ log_error("No class specified");
+ return(NULL);
+ }
+
+ x++;
+ while (x<argc) args->args[args->anum++]=strdup(argv[x++]);
+
+ 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[]) {
+ arg_data *args=parse(argc,argv);
+ int x=0;
+
+ if (args==NULL) {
+ log_error("Cannot parse command line arguments");
+ return(NULL);
+ }
+
+ if (log_debug_flag==true) {
+ char *temp;
+
+ log_debug("+-- DUMPING PARSED COMMAND LINE ARGUMENTS --------------");
+
+ log_debug("| Detach: %s",IsTrueFalse(args->dtch));
+
+ log_debug("| Show Version: %s",IsYesNo(args->vers));
+
+ log_debug("| Show Help: %s",IsYesNo(args->help));
+
+ log_debug("| Check Only: %s",IsEnabledDisabled(args->chck));
+
+ log_debug("| Stop: %s",IsTrueFalse(args->stop));
+
+ log_debug("| Wait: %d",args->wait);
+
+ 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\"",PRINT_NULL(args->name));
+ log_debug("| Java Home: \"%s\"",PRINT_NULL(args->home));
+ log_debug("| PID File: \"%s\"",PRINT_NULL(args->pidf));
+ log_debug("| User Name: \"%s\"",PRINT_NULL(args->user));
+
+ log_debug("| Extra Options: %d",args->onum);
+ for (x=0; x<args->onum; x++) log_debug("| \"%s\"",args->opts[x]);
+
+ log_debug("| Class Invoked: \"%s\"",PRINT_NULL(args->clas));
+
+ log_debug("| Class Arguments: %d",args->anum);
+ for (x=0; x<args->anum; x++)log_debug("| \"%s\"",args->args[x]);
+ log_debug("+-------------------------------------------------------");
+ }
+
+ return(args);
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/arguments.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/arguments.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/arguments.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,85 @@
+/*
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+/* @version $Id: arguments.h 165124 2005-04-28 09:36:02Z jfclere $ */
+#ifndef __JSVC_ARGUMENTS_H__
+#define __JSVC_ARGUMENTS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * The structure holding all parsed command line options.
+ */
+typedef struct {
+ /** The name of the PID file. */
+ char *pidf;
+ /** The name of the user. */
+ char *user;
+ /** The name of the JVM to use. */
+ char *name;
+ /** The JDK or JRE installation path (JAVA_HOME). */
+ char *home;
+ /** Options used to invoke the JVM. */
+ char **opts;
+ /** Number of JVM options. */
+ int onum;
+ /** The name of the class to invoke. */
+ char *clas;
+ /** Command line arguments to the class. */
+ char **args;
+ /** Number of class command line arguments. */
+ int anum;
+ /** Wether to detach from parent process or not. */
+ bool dtch;
+ /** Wether to print the VM version number or not. */
+ bool vers;
+ /** Wether to display the help page or not. */
+ bool help;
+ /** Only check environment without running the service. */
+ bool chck;
+ /** Stop running jsvc */
+ bool stop;
+ /** number of seconds to until service started */
+ int wait;
+ /** Install as a service (win32) */
+ bool install;
+ /** Remove when installed as a service (win32) */
+ bool remove;
+ /** Run as a service (win32) */
+ bool service;
+ /** Destination for stdout */
+ char *outfile;
+ /** Destination for stderr */
+ char *errfile;
+ /** Program name for Linux **/
+ char *procname;
+} arg_data;
+
+/**
+ * Parse command line arguments.
+ *
+ * @param argc The number of command line arguments.
+ * @param argv Pointers to the different arguments.
+ * @return A pointer to a arg_data structure containing the parsed command
+ * line arguments, or NULL if an error was detected.
+ */
+arg_data *arguments(int argc, char *argv[]);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* ifndef __JSVC_ARGUMENTS_H__ */
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/debug.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/debug.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/debug.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,70 @@
+/*
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+/* @version $Id: debug.c 165119 2005-04-28 09:00:08Z jfclere $ */
+#include "jsvc.h"
+#include <sys/types.h>
+#include <unistd.h>
+#include <time.h>
+
+/* Wether debug is enabled or not */
+bool log_debug_flag = false;
+
+/* The name of the jsvc binary. */
+char *log_prog = "jsvc";
+
+/* Dump a debug message to stderr */
+void log_debug(const char *fmt, ...) {
+ va_list ap;
+ time_t now;
+ struct tm *nowtm;
+ char buff[80];
+
+ if (log_debug_flag==false) return;
+ if (fmt==NULL) return;
+
+ now = time(NULL);
+ nowtm = localtime(&now);
+ strftime(buff, sizeof(buff), "%d/%m/%Y %T", nowtm);
+
+ va_start(ap,fmt);
+ fprintf(stderr,"%s %d %s debug: ", buff, getpid(), log_prog);
+ vfprintf(stderr,fmt,ap);
+ fprintf(stderr,"\n");
+ fflush(stderr);
+ va_end(ap);
+}
+
+/* Dump an error message to stderr */
+void log_error(const char *fmt, ...) {
+ va_list ap;
+ time_t now;
+ struct tm *nowtm;
+ char buff[80];
+
+ if (fmt==NULL) return;
+
+ now = time(NULL);
+ nowtm = localtime(&now);
+ strftime(buff, sizeof(buff), "%d/%m/%Y %T", nowtm);
+
+ va_start(ap,fmt);
+ fprintf(stderr,"%s %d %s error: ", buff, getpid(), log_prog);
+ vfprintf(stderr,fmt,ap);
+ fprintf(stderr,"\n");
+ fflush(stderr);
+ va_end(ap);
+}
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/debug.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/debug.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/debug.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,58 @@
+/*
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+/* @version $Id: debug.h 155409 2005-02-26 12:57:06Z dirkv $ */
+#ifndef __JSVC_DEBUG_H__
+#define __JSVC_DEBUG_H__
+
+/**
+ * Wether debugging is enabled or not.
+ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern bool log_debug_flag;
+
+/**
+ * The name of the jsvc binary.
+ */
+extern char *log_prog;
+
+/**
+ * Helper macro to avoid NPEs in printf.
+ */
+#define PRINT_NULL(x) ((x) == NULL ? "null" : (x))
+
+/**
+ * Dump a debug message.
+ *
+ * @param fmt The printf style message format.
+ * @param ... Any optional parameter for the message.
+ */
+void log_debug(const char *fmt, ...);
+
+/**
+ * Dump an error message.
+ *
+ * @param fmt The printf style message format.
+ * @param ... Any optional parameter for the message.
+ */
+void log_error(const char *fmt, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ifndef __JSVC_DEBUG_H__ */
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/dso-dlfcn.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/dso-dlfcn.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/dso-dlfcn.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,55 @@
+/*
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+/* @version $Id: dso-dlfcn.c 155409 2005-02-26 12:57:06Z dirkv $ */
+#include "jsvc.h"
+
+#ifdef DSO_DLFCN
+
+#include <dlfcn.h>
+
+#ifdef OS_LINUX
+bool ld_library_path_set=false;
+#endif /* ifdef OS_LINUX */
+
+/* Initialize all DSO stuff */
+bool dso_init() {
+ return(true);
+}
+
+/* Attempt to link a library from a specified filename */
+dso_handle dso_link(const char *path) {
+ log_debug("Attemtping to load library %s",path);
+
+ return((void *)dlopen(path,RTLD_GLOBAL|RTLD_NOW));
+}
+
+/* Attempt to unload a library */
+bool dso_unlink(dso_handle libr) {
+ if (dlclose(libr)==0) return(true);
+ else return(false);
+}
+
+/* Get the address for a specifed symbol */
+void *dso_symbol(dso_handle hdl, const char *nam) {
+ return(dlsym(hdl,nam));
+}
+
+/* Return the error message from dlopen */
+char *dso_error() {
+ return(dlerror());
+}
+
+#endif /* ifdef DSO_DLFCN */
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/dso-dyld.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/dso-dyld.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/dso-dyld.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,139 @@
+/*
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+/* @version $Id: dso-dyld.c 351602 2005-12-02 05:28:57Z billbarker $ */
+#include "jsvc.h"
+
+#ifdef DSO_DYLD
+
+#include <mach-o/dyld.h>
+
+#ifdef __bool_true_false_are_defined
+/* We define these differently than stdbool.h, so ignore the defs there */
+#undef bool
+#undef true
+#undef false
+#endif
+
+
+/* Print an error message and abort all if a specified symbol wasn't found */
+static void nosymbol(const char *s) {
+ log_error("Cannot find symbol '%s' in library",s);
+ abort();
+}
+
+/* We found two symbols for the same name in two different modules */
+static NSModule multiple(NSSymbol s, NSModule om, NSModule nm) {
+ NSModule ret=nm;
+
+ log_debug("Symbol \"%s\" found in modules \"%s\" and \"%s\" (using %s)",
+ NSNameOfSymbol(s), NSNameOfModule(om), NSNameOfModule(nm),
+ NSNameOfModule(ret));
+
+ return(ret);
+}
+
+/* We got an error while linking a module, and if it's not a warning we have
+ to abort the whole program */
+static void linkedit(NSLinkEditErrors category, int number, const char *file,
+ const char *message) {
+ log_error("Errors during link edit of file \"%s\" (error=%d): %s", file,
+ number,message);
+ /* Check if this error was only a warning */
+ if (category!=NSLinkEditWarningError) {
+ log_error("Cannot continue");
+ abort();
+ }
+}
+
+/* Initialize all DSO stuff */
+bool dso_init() {
+ NSLinkEditErrorHandlers h;
+
+ h.undefined=nosymbol;
+ h.multiple=multiple;
+ h.linkEdit=linkedit;
+
+ NSInstallLinkEditErrorHandlers(&h);
+ return(true);
+}
+
+/* Attempt to link a library from a specified filename */
+dso_handle dso_link(const char *path) {
+ /* We need to load the library publically as NSModuleFileImage is not
+ yet implemented (at least for non MH_BUNDLE libraries */
+ if (NSAddLibrary(path)!=TRUE) return(NULL);
+ /* We need to return a non-null value, even if it has no meaning. One day
+ this whole crap will be fixed */
+ return((void *)!NULL);
+}
+
+/* Attempt to unload a library */
+bool dso_unlink(dso_handle libr) {
+ /* Check the handle */
+ if (libr==NULL) {
+ log_error("Attempting to unload a module without handle");
+ return(false);
+ }
+
+ /* We don't have a module, so, we don't really have to do anything */
+ return(true);
+}
+
+/* Get the address for a specifed symbol */
+void *dso_symbol(dso_handle hdl, const char *nam) {
+ NSSymbol sym=NULL;
+ NSModule mod=NULL;
+ char *und=NULL;
+ void *add=NULL;
+ int x=0;
+
+ /* Check parameters */
+ if (hdl==NULL) {
+ log_error("Invalid library handler specified");
+ return(NULL);
+ }
+
+ if (nam==NULL) {
+ log_error("Invalid symbol name specified");
+ return(NULL);
+ }
+
+ /* Process the correct name (add a _ before the name) */
+ while (nam[x]!='\0') x++;
+ und=(char*)malloc(sizeof(char)*(x+2));
+ while(x>=0) und[x+1]=nam[x--];
+ und[0]='_';
+
+ /* Find the symbol */
+ sym=NSLookupAndBindSymbol(und);
+ free(und);
+ if (sym==NULL) return(NULL);
+
+ /* Dump some debugging output since this part is shaky */
+ mod=NSModuleForSymbol(sym);
+ add=NSAddressOfSymbol(sym);
+ log_debug("Symbol \"%s\" found in module \"%s\" at address \"0x%08X\"",
+ NSNameOfSymbol(sym),NSNameOfModule(mod),add);
+
+ /* We want to return the address of the symbol */
+ return(add);
+}
+/* Return the error message from dlopen: Well we already print it */
+char *dso_error() {
+ return("no additional message");
+}
+
+#endif /* ifdef DSO_DYLD */
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/dso.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/dso.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/dso.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,27 @@
+/*
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+/* @version $Id: dso.h 155409 2005-02-26 12:57:06Z dirkv $ */
+#include "jsvc.h"
+
+/**
+ * A library handle represents a unique pointer to its location in memory.
+ */
+typedef void *dso_handle;
+
+bool dso_init(void);
+dso_handle dso_link(const char *pth);
+bool dso_unlink(dso_handle lib);
+void *dso_symbol(dso_handle lib, const char *nam);
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/help.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/help.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/help.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,93 @@
+/*
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+/* @version $Id: help.c 232775 2005-08-15 08:50:17Z jfclere $ */
+#include "jsvc.h"
+
+void help(home_data *data) {
+ int x;
+
+ printf("Usage: %s [-options] class [args...]\n",log_prog);
+ printf("\n");
+ printf("Where options include:\n");
+ printf("\n");
+
+ printf(" -jvm <JVM name>\n");
+ printf(" use a specific Java Virtual Machine. Available JVMs:\n");
+ printf(" ");
+ for (x=0; x<data->jnum; x++) {
+ printf(" '%s'",PRINT_NULL(data->jvms[x]->name));
+ }
+ printf("\n");
+
+ printf(" -cp / -classpath <directories and zip/jar files>\n");
+ printf(" set search path for service classes and resouces\n");
+
+ printf(" -home <directory>\n");
+ printf(" set the path of your JDK or JRE installation (or set\n");
+ printf(" the JAVA_HOME environment variable)\n");
+
+ printf(" -version\n");
+ printf(" show the current Java environment version (to check\n");
+ printf(" correctness of -home and -jvm. Implies -nodetach)\n");
+
+ printf(" -help / -?\n");
+ printf(" show this help page (implies -nodetach)\n");
+
+ printf(" -nodetach\n");
+ printf(" don't detach from parent process and become a daemon\n");
+
+ printf(" -debug\n");
+ printf(" verbosely print debugging information\n");
+
+ printf(" -check\n");
+ printf(" only check service (implies -nodetach)\n");
+
+ printf(" -user <user>\n");
+ printf(" user used to run the daemon (defaults to current user)\n");
+
+ printf(" -verbose[:class|gc|jni]\n");
+ printf(" enable verbose output\n");
+
+ printf(" -outfile </full/path/to/file>\n");
+ printf(" Location for output from stdout (defaults to /dev/null)\n");
+ printf(" Use the value '&2' to simulate '1>&2'\n");
+
+ printf(" -errfile </full/path/to/file>\n");
+ printf(" Location for output from stderr (defaults to /dev/null)\n");
+ printf(" Use the value '&1' to simulate '2>&1'\n");
+
+ printf(" -pidfile </full/path/to/file>\n");
+ printf(" Location for output from the file containing the pid of jsvc\n");
+ printf(" (defaults to /var/run/jsvc.pid)\n");
+
+ printf(" -D<name>=<value>\n");
+ printf(" set a Java system property\n");
+
+ printf(" -X<option>\n");
+ printf(" set Virtual Machine specific option\n");
+
+ printf(" -procname <procname>\n");
+ printf(" use the specified process name (works only for Linux)\n");
+
+ printf(" -wait <waittime>\n");
+ printf(" wait waittime seconds for the service to start\n");
+ printf(" waittime should multiple of 10 (min=10)\n");
+
+ printf(" -stop\n");
+ printf(" stop the service using the file given in the -pidfile option\n");
+
+ printf("\n");
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/help.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/help.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/help.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,17 @@
+/*
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+/* @version $Id: help.h 155409 2005-02-26 12:57:06Z dirkv $ */
+void help(home_data *data);
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/home.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/home.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/home.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,243 @@
+/*
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+/* @version $Id: home.c 155409 2005-02-26 12:57:06Z dirkv $ */
+#include "jsvc.h"
+
+/* Check if a path is a directory */
+static bool checkdir(char *path) {
+ struct stat home;
+
+ if (path==NULL) return(false);
+ if (stat(path,&home)!=0) return(false);
+ if (S_ISDIR(home.st_mode)) return(true);
+ return(false);
+}
+
+/* Check if a path is a file */
+static bool checkfile(char *path) {
+ struct stat home;
+
+ if (path==NULL) return(false);
+ if (stat(path,&home)!=0) return(false);
+ if (S_ISREG(home.st_mode)) return(true);
+ return(false);
+}
+
+/* Parse a VM configuration file */
+static bool parse(home_data *data) {
+ FILE *cfgf=fopen(data->cfgf,"r");
+ char *ret=NULL, *sp;
+ char buf[1024];
+
+ if (cfgf==NULL) {
+ log_debug("Can't open %s\n",data->cfgf);
+ return(false);
+ }
+
+ data->jvms=(home_jvm **)malloc(256*sizeof(home_jvm *));
+
+ while((ret=fgets(buf,1024,cfgf))!=NULL) {
+ char *tmp=strchr(ret,'#');
+ int pos;
+
+ /* Clear the string at the first occurrence of '#' */
+ if (tmp!=NULL) tmp[0]='\0';
+
+ /* Trim the string (including leading '-' chars */
+ while((ret[0]==' ')||(ret[0]=='\t')||(ret[0]=='-')) ret++;
+ pos=strlen(ret);
+ while(pos>=0) {
+ if ((ret[pos]=='\r')||(ret[pos]=='\n')||(ret[pos]=='\t')||
+ (ret[pos]=='\0')||(ret[pos]==' ')) {
+ ret[pos--]='\0';
+ } else break;
+ }
+ /* Format changed for 1.4 JVMs */
+ sp = strchr(ret, ' ');
+ if(sp != NULL)
+ *sp = '\0';
+
+ /* Did we find something significant? */
+ if (strlen(ret)>0) {
+ char *libf=NULL;
+ int x=0;
+
+ log_debug("Found VM %s definition in configuration",ret);
+ while(location_jvm_configured[x]!=NULL) {
+ char *orig=location_jvm_configured[x];
+ char temp[1024];
+ char repl[1024];
+ int k;
+
+ k=replace(temp,1024,orig,"$JAVA_HOME",data->path);
+ if (k!=0) {
+ log_error("Can't replace home in VM library (%d)",k);
+ return(false);
+ }
+ k=replace(repl,1024,temp,"$VM_NAME",ret);
+ if (k!=0) {
+ log_error("Can't replace name in VM library (%d)",k);
+ return(false);
+ }
+
+ log_debug("Checking library %s",repl);
+ if (checkfile(repl)) {
+ libf=strdup(repl);
+ break;
+ }
+ x++;
+ }
+
+ if (libf==NULL) {
+ log_debug("Cannot locate library for VM %s (skipping)",ret);
+ } else {
+ data->jvms[data->jnum]=(home_jvm *)malloc(sizeof(home_jvm));
+ data->jvms[data->jnum]->name=strdup(ret);
+ data->jvms[data->jnum]->libr=libf;
+ data->jnum++;
+ data->jvms[data->jnum]=NULL;
+ }
+ }
+ }
+ return(true);
+}
+
+/* Build a Java Home structure for a path */
+static home_data *build(char *path) {
+ home_data *data=NULL;
+ char *cfgf=NULL;
+ char buf[1024];
+ int x=0;
+ int k=0;
+
+ if (path==NULL) return(NULL);
+
+ log_debug("Attempting to locate Java Home in %s",path);
+ if (checkdir(path)==false) {
+ log_debug("Path %s is not a directory",path);
+ return(NULL);
+ }
+
+ while(location_jvm_cfg[x]!=NULL) {
+ if ((k=replace(buf,1024,location_jvm_cfg[x],"$JAVA_HOME",path))!=0) {
+ log_error("Error replacing values for jvm.cfg (%d)",k);
+ return(NULL);
+ }
+ log_debug("Attempting to locate VM configuration file %s",buf);
+ if(checkfile(buf)==true) {
+ log_debug("Found VM configuration file at %s",buf);
+ cfgf=strdup(buf);
+ break;
+ }
+ x++;
+ }
+
+ data=(home_data *)malloc(sizeof(home_data));
+ data->path=strdup(path);
+ data->cfgf=cfgf;
+ data->jvms=NULL;
+ data->jnum=0;
+
+ /* We don't have a jvm.cfg configuration file, so all we have to do is
+ trying to locate the "default" Java Virtual Machine library */
+ if (cfgf==NULL) {
+ log_debug("VM configuration file not found");
+ x=0;
+ while(location_jvm_default[x]!=NULL) {
+ char *libr=location_jvm_default[x];
+
+ if ((k=replace(buf,1024,libr,"$JAVA_HOME",path))!=0) {
+ log_error("Error replacing values for JVM library (%d)",k);
+ return(NULL);
+ }
+ log_debug("Attempting to locate VM library %s",buf);
+ if (checkfile(buf)==true) {
+ data->jvms=(home_jvm **)malloc(2*sizeof(home_jvm *));
+ data->jvms[0]=(home_jvm *)malloc(sizeof(home_jvm));
+ data->jvms[0]->name=NULL;
+ data->jvms[0]->libr=strdup(buf);
+ data->jvms[1]=NULL;
+ data->jnum=1;
+ return(data);
+ }
+ x++;
+ }
+
+ return(data);
+ }
+
+ /* If we got here, we most definitely found a jvm.cfg file */
+ if (parse(data)==false) {
+ log_error("Cannot parse VM configuration file %s",data->cfgf);
+ }
+
+ return(data);
+}
+
+/* Find the Java Home */
+static home_data *find(char *path) {
+ home_data *data=NULL;
+ int x=0;
+
+ if (path==NULL) {
+ log_debug("Home not specified on command line, using environment");
+ path=getenv("JAVA_HOME");
+ }
+
+ if (path==NULL) {
+ log_debug("Home not on command line or in environment, searching");
+ while (location_home[x]!=NULL) {
+ if ((data=build(location_home[x]))!=NULL) {
+ log_debug("Java Home located in %s",data->path);
+ return(data);
+ }
+ x++;
+ }
+ } else {
+ if ((data=build(path))!=NULL) {
+ log_debug("Java Home located in %s",data->path);
+ return(data);
+ }
+ }
+
+ return(NULL);
+}
+
+/* Main entry point: locate home and dump structure */
+home_data *home(char *path) {
+ home_data *data=find(path);
+ int x=0;
+
+ if (data==NULL) {
+ log_error("Cannot locate Java Home");
+ return(NULL);
+ }
+
+ if (log_debug_flag==true) {
+ log_debug("+-- DUMPING JAVA HOME STRUCTURE ------------------------");
+ log_debug("| Java Home: \"%s\"",PRINT_NULL(data->path));
+ log_debug("| Java VM Config.: \"%s\"",PRINT_NULL(data->cfgf));
+ log_debug("| Found JVMs: %d",data->jnum);
+ for (x=0; x<data->jnum; x++) {
+ home_jvm *jvm=data->jvms[x];
+ log_debug("| JVM Name: \"%s\"",PRINT_NULL(jvm->name));
+ log_debug("| \"%s\"",PRINT_NULL(jvm->libr));
+ }
+ log_debug("+-------------------------------------------------------");
+ }
+
+ return(data);
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/home.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/home.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/home.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,44 @@
+/*
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+/* @version $Id: home.h 155409 2005-02-26 12:57:06Z dirkv $ */
+#ifndef __JSVC_HOME_H__
+#define __JSVC_HOME_H__
+
+typedef struct home_jvm home_jvm;
+typedef struct home_data home_data;
+
+struct home_jvm {
+ char *name;
+ char *libr;
+};
+
+struct home_data {
+ char *path;
+ char *cfgf;
+ home_jvm **jvms;
+ int jnum;
+};
+
+/**
+ * Attempt to locate a Java Home directory and build its structure.
+ *
+ * @param path The java home path specified on the command line.
+ * @return A home_data structure containing all informations related to
+ * the Java environment, or NULL if no home was found.
+ */
+home_data *home(char *path);
+
+#endif /* ifndef __JSVC_HOME_H__ */
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/java.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/java.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/java.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,519 @@
+/*
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+/* @version $Id: java.c 354472 2005-12-06 16:48:47Z jfclere $ */
+#include "jsvc.h"
+
+#ifdef OS_CYGWIN
+typedef long long __int64;
+#endif
+#include <jni.h>
+
+#ifdef CHARSET_EBCDIC
+#ifdef OSD_POSIX
+#include <ascii_ebcdic.h>
+#define jsvc_xlate_to_ascii(b) _e2a(b)
+#define jsvc_xlate_from_ascii(b) _a2e(b)
+#endif
+#else
+#define jsvc_xlate_to_ascii(b) /* NOOP */
+#define jsvc_xlate_from_ascii(b) /* NOOP */
+#endif
+
+static JavaVM *jvm=NULL;
+static JNIEnv *env=NULL;
+static jclass cls=NULL;
+
+#define FALSE 0
+#define TRUE !FALSE
+
+static void shutdown(JNIEnv *env, jobject source, jboolean reload) {
+ log_debug("Shutdown requested (reload is %d)",reload);
+ if (reload==TRUE) main_reload();
+ else main_shutdown();
+}
+/* Automaticly restart when the JVM crashes */
+static void java_abort123()
+{
+ exit(123);
+}
+
+char *java_library(arg_data *args, home_data *data) {
+ char *libf=NULL;
+
+ /* Did we find ANY virtual machine? */
+ if (data->jnum==0) {
+ log_error("Cannot find any VM in Java Home %s",data->path);
+ return(NULL);
+ }
+
+ /* Select the VM */
+ if (args->name==NULL) {
+ libf=data->jvms[0]->libr;
+ log_debug("Using default JVM in %s",libf);
+ } else {
+ int x;
+ for (x=0; x<data->jnum; x++) {
+ if (data->jvms[x]->name==NULL) continue;
+ if (strcmp(args->name,data->jvms[x]->name)==0) {
+ libf=data->jvms[x]->libr;
+ log_debug("Using specific JVM in %s",libf);
+ break;
+ }
+ }
+ if (libf==NULL) {
+ log_error("Invalid JVM name specified %s",args->name);
+ return(NULL);
+ }
+ }
+ return(libf);
+}
+
+/* Initialize the JVM and its environment, loading libraries and all */
+bool java_init(arg_data *args, home_data *data) {
+#ifdef OS_DARWIN
+ dso_handle apph=NULL;
+ char appf[1024];
+ struct stat sb;
+#endif /* ifdef OS_DARWIN */
+ jint (*symb)(JavaVM **, JNIEnv **, JavaVMInitArgs *);
+ JNINativeMethod nativemethod;
+ JavaVMOption *opt=NULL;
+ dso_handle libh=NULL;
+ JavaVMInitArgs arg;
+ char *libf=NULL;
+ jint ret;
+ int x;
+ char loaderclass[]=LOADER;
+ char shutdownclass[]="shutdown";
+ char shutdownparams[]="(Z)V";
+
+ /* Decide WHAT virtual machine we need to use */
+ libf=java_library(args,data);
+ if (libf==NULL) {
+ log_error("Cannot locate JVM library file");
+ return(false);
+ }
+
+ /* Initialize the DSO library */
+ if (dso_init()!=true) {
+ log_error("Cannot initialize the dynamic library loader");
+ return(false);
+ }
+
+ /* Load the JVM library */
+#if defined(OSD_POSIX) || defined(HAVE_KAFFEVM)
+#else
+ libh=dso_link(libf);
+ if (libh==NULL) {
+ log_error("Cannot dynamically link to %s",libf);
+ log_error("%s",dso_error());
+ return(false);
+ }
+ log_debug("JVM library %s loaded",libf);
+#endif
+
+#ifdef OS_DARWIN
+ /*
+ MacOS/X actually has two libraries, one with the REAL vm, and one for
+ the VM startup.
+ before JVM 1.4.1 The first one (libappshell.dyld) contains CreateVM
+ after JVM 1.4.1 The library name is libjvm_compat.dylib.
+ */
+ if (replace(appf,1024,"$JAVA_HOME/../Libraries/libappshell.dylib",
+ "$JAVA_HOME",data->path)!=0) {
+ log_error("Cannot replace values in loader library");
+ return(false);
+ }
+ if (stat(appf, &sb)) {
+ if (replace(appf,1024,"$JAVA_HOME/../Libraries/libjvm_compat.dylib",
+ "$JAVA_HOME",data->path)!=0) {
+ log_error("Cannot replace values in loader library");
+ return(false);
+ }
+ }
+ apph=dso_link(appf);
+ if (apph==NULL) {
+ log_error("Cannot load required shell library %s",appf);
+ return(false);
+ }
+ log_debug("Shell library %s loaded",appf);
+#endif /* ifdef OS_DARWIN */
+#if defined(OSD_POSIX) || defined(HAVE_KAFFEVM)
+ /* BS2000 and kaffe does not allow to call JNI_CreateJavaVM indirectly */
+#else
+ symb=dso_symbol(libh,"JNI_CreateJavaVM");
+ if (symb==NULL) {
+#ifdef OS_DARWIN
+ symb=dso_symbol(apph,"JNI_CreateJavaVM");
+ if (symb==NULL) {
+#endif /* ifdef OS_DARWIN */
+ log_error("Cannot find JVM library entry point");
+ return(false);
+#ifdef OS_DARWIN
+ }
+#endif /* ifdef OS_DARWIN */
+ }
+ log_debug("JVM library entry point found (0x%08X)",symb);
+#endif
+
+ /* Prepare the VM initialization arguments */
+
+ /*
+ Mac OS X Java will load JVM 1.3.1 instead of 1.4.2 if JNI_VERSION_1_2
+ is specified. So use JNI_VERSION_1_4 if we can.
+ */
+ #if defined(JNI_VERSION_1_4)
+ arg.version=JNI_VERSION_1_4;
+ #else
+ arg.version=JNI_VERSION_1_2;
+ #endif
+#if defined(OSD_POSIX) || defined(HAVE_KAFFEVM)
+
+#if defined(HAVE_KAFFEVM)
+ memset(&arg, 0, sizeof(arg));
+ arg.version = JNI_VERSION_1_4;
+#endif
+
+ if (JNI_GetDefaultJavaVMInitArgs(&arg)<0) {
+ log_error("Cannot init default JVM default args");
+ return(false);
+ }
+#endif
+ arg.ignoreUnrecognized=FALSE;
+ arg.nOptions=args->onum;
+ arg.nOptions++; /* Add abort code */
+ opt=(JavaVMOption *)malloc(arg.nOptions*sizeof(JavaVMOption));
+ for (x=0; x<args->onum; x++) {
+ opt[x].optionString=strdup(args->opts[x]);
+ jsvc_xlate_to_ascii(opt[x].optionString);
+ opt[x].extraInfo=NULL;
+ }
+ opt[x].optionString=strdup("abort");
+ jsvc_xlate_to_ascii(opt[x].optionString);
+ opt[x].extraInfo=java_abort123;
+ arg.options=opt;
+
+ /* Do some debugging */
+ if (log_debug_flag==true) {
+ log_debug("+-- DUMPING JAVA VM CREATION ARGUMENTS -----------------");
+ log_debug("| Version: %#08x",arg.version);
+ log_debug("| Ignore Unrecognized Arguments: %s",
+ arg.ignoreUnrecognized==TRUE?"True":"False");
+ log_debug("| Extra options: %d",arg.nOptions);
+
+ for (x=0; x<args->onum; x++) {
+ jsvc_xlate_from_ascii(opt[x].optionString);
+ log_debug("| \"%s\" (0x%08x)",opt[x].optionString,
+ opt[x].extraInfo);
+ jsvc_xlate_to_ascii(opt[x].optionString);
+ }
+ log_debug("+-------------------------------------------------------");
+ }
+
+ /* And finally create the Java VM */
+#if defined(OSD_POSIX) || defined(HAVE_KAFFEVM)
+ ret=JNI_CreateJavaVM(&jvm, &env, &arg);
+#else
+ ret=(*symb)(&jvm, &env, &arg);
+#endif
+ if (ret<0) {
+ log_error("Cannot create Java VM");
+ return(false);
+ }
+ log_debug("Java VM created successfully");
+
+ jsvc_xlate_to_ascii(loaderclass);
+ cls=(*env)->FindClass(env,loaderclass);
+ jsvc_xlate_from_ascii(loaderclass);
+ if (cls==NULL) {
+ log_error("Cannot find daemon loader %s",loaderclass);
+ return(false);
+ }
+ log_debug("Class %s found",loaderclass);
+
+#if defined(HAVE_SABLEVM)
+ log_debug("sableVM doesn't support RegisterNatives");
+#else
+ jsvc_xlate_to_ascii(shutdownclass);
+ nativemethod.name=shutdownclass;
+ jsvc_xlate_to_ascii(shutdownparams);
+ nativemethod.signature=shutdownparams;
+ nativemethod.fnPtr=shutdown;
+ if((*env)->RegisterNatives(env,cls,&nativemethod,1)!=0) {
+ log_error("Cannot register native methods");
+ return(false);
+ }
+ log_debug("Native methods registered");
+#endif
+
+ return(true);
+}
+
+/* Destroy the Java VM */
+bool JVM_destroy(int exit) {
+ jclass system=NULL;
+ jmethodID method;
+ char System[]="java/lang/System";
+ char exitclass[]="exit";
+ char exitparams[]="(I)V";
+
+ jsvc_xlate_to_ascii(System);
+ system=(*env)->FindClass(env,System);
+ jsvc_xlate_from_ascii(System);
+ if (system==NULL) {
+ log_error("Cannot find class %s",System);
+ return(false);
+ }
+
+ jsvc_xlate_to_ascii(exitclass);
+ jsvc_xlate_to_ascii(exitparams);
+ method=(*env)->GetStaticMethodID(env,system,exitclass,exitparams);
+ if (method==NULL) {
+ log_error("Cannot find \"System.exit(int)\" entry point");
+ return(false);
+ }
+
+ log_debug("Calling System.exit(%d)",exit);
+ (*env)->CallStaticVoidMethod(env,system,method,(jint)exit);
+
+ /* We shouldn't get here, but just in case... */
+ log_debug("Destroying the Java VM");
+ if ((*jvm)->DestroyJavaVM(jvm)!=0) return(false);
+ log_debug("Java VM destroyed");
+ return(true);
+}
+
+/* Call the load method in our DaemonLoader class */
+bool java_load(arg_data *args) {
+ jclass stringClass=NULL;
+ jstring className=NULL;
+ jstring currentArgument=NULL;
+ jobjectArray stringArray=NULL;
+ jmethodID method=NULL;
+ jboolean ret=FALSE;
+ int x;
+ char lang[]="java/lang/String";
+ char load[]="load";
+ char loadparams[]="(Ljava/lang/String;[Ljava/lang/String;)Z";
+
+ jsvc_xlate_to_ascii(args->clas);
+ className=(*env)->NewStringUTF(env,args->clas);
+ jsvc_xlate_from_ascii(args->clas);
+ if (className==NULL) {
+ log_error("Cannot create string for class name");
+ return(false);
+ }
+
+ jsvc_xlate_to_ascii(lang);
+ stringClass=(*env)->FindClass(env,lang);
+ jsvc_xlate_from_ascii(lang);
+ if (stringClass==NULL) {
+ log_error("Cannot find class java/lang/String");
+ return(false);
+ }
+
+ stringArray=(*env)->NewObjectArray(env,args->anum,stringClass,NULL);
+ if (stringArray==NULL) {
+ log_error("Cannot create arguments array");
+ return(false);
+ }
+
+ for (x=0; x<args->anum; x++) {
+ jsvc_xlate_to_ascii(args->args[x]);
+ currentArgument=(*env)->NewStringUTF(env,args->args[x]);
+ jsvc_xlate_from_ascii(args->args[x]);
+ if (currentArgument==NULL) {
+ log_error("Cannot create string for argument %s",args->args[x]);
+ return(false);
+ }
+ (*env)->SetObjectArrayElement(env,stringArray,x,currentArgument);
+ }
+
+ jsvc_xlate_to_ascii(load);
+ jsvc_xlate_to_ascii(loadparams);
+ method=(*env)->GetStaticMethodID(env,cls,load,loadparams);
+ if (method==NULL) {
+ log_error("Cannot find Daemon Loader \"load\" entry point");
+ return(false);
+ }
+
+ log_debug("Daemon loading...");
+ ret=(*env)->CallStaticBooleanMethod(env,cls,method,className,stringArray);
+ if (ret==FALSE) {
+ log_error("Cannot load daemon");
+ return(false);
+ }
+
+ log_debug("Daemon loaded successfully");
+ return(true);
+}
+
+/* Call the start method in our daemon loader */
+bool java_start(void) {
+ jmethodID method;
+ jboolean ret;
+ char start[]="start";
+ char startparams[]="()Z";
+
+ jsvc_xlate_to_ascii(start);
+ jsvc_xlate_to_ascii(startparams);
+ method=(*env)->GetStaticMethodID(env,cls,start,startparams);
+ if (method==NULL) {
+ log_error("Cannot find Daemon Loader \"start\" entry point");
+ return(false);
+ }
+
+ ret=(*env)->CallStaticBooleanMethod(env,cls,method);
+ if (ret==FALSE) {
+ log_error("Cannot start daemon");
+ return(false);
+ }
+
+ log_debug("Daemon started successfully");
+ return(true);
+}
+
+/*
+ * call the java sleep to prevent problems with threads
+ */
+void java_sleep(int wait) {
+ jclass clsThread;
+ jmethodID method;
+ char jsleep[]="sleep";
+ char jsleepparams[]="(J)V";
+ char jthread[]="java/lang/Thread";
+
+ jsvc_xlate_to_ascii(jsleep);
+ jsvc_xlate_to_ascii(jsleepparams);
+ jsvc_xlate_to_ascii(jthread);
+
+ clsThread = (*env)->FindClass(env,jthread);
+ if (clsThread==NULL) {
+ log_error("Cannot find java/lang/Thread class");
+ return;
+ }
+ method=(*env)->GetStaticMethodID(env,clsThread,jsleep,jsleepparams);
+ if (method==NULL) {
+ log_error("Cannot found the sleep entry point");
+ return;
+ }
+
+ (*env)->CallStaticVoidMethod(env,clsThread,method,(jlong)wait*1000);
+}
+
+/* Call the stop method in our daemon loader */
+bool java_stop(void) {
+ jmethodID method;
+ jboolean ret;
+ char stop[]="stop";
+ char stopparams[]="()Z";
+
+ jsvc_xlate_to_ascii(stop);
+ jsvc_xlate_to_ascii(stopparams);
+ method=(*env)->GetStaticMethodID(env,cls,stop,stopparams);
+ if (method==NULL) {
+ log_error("Cannot found Daemon Loader \"stop\" entry point");
+ return(false);
+ }
+
+ ret=(*env)->CallStaticBooleanMethod(env,cls,method);
+ if (ret==FALSE) {
+ log_error("Cannot stop daemon");
+ return(false);
+ }
+
+ log_debug("Daemon stopped successfully");
+ return(true);
+}
+
+/* Call the version method in our daemon loader */
+bool java_version(void) {
+ jmethodID method;
+ char version[]="version";
+ char versionparams[]="()Z";
+
+ jsvc_xlate_to_ascii(version);
+ jsvc_xlate_to_ascii(versionparams);
+ method=(*env)->GetStaticMethodID(env,cls,version,versionparams);
+ if (method==NULL) {
+ log_error("Cannot found Daemon Loader \"version\" entry point");
+ return(false);
+ }
+
+ (*env)->CallStaticVoidMethod(env,cls,method);
+ return(true);
+}
+
+/* Call the check method in our DaemonLoader class */
+bool java_check(arg_data *args) {
+ jstring className=NULL;
+ jmethodID method=NULL;
+ jboolean ret=FALSE;
+ char check[]="check";
+ char checkparams[]="(Ljava/lang/String;)Z";
+
+ log_debug("Checking daemon");
+
+ jsvc_xlate_to_ascii(args->clas);
+ className=(*env)->NewStringUTF(env,args->clas);
+ jsvc_xlate_from_ascii(args->clas);
+ if (className==NULL) {
+ log_error("Cannot create string for class name");
+ return(false);
+ }
+
+ jsvc_xlate_to_ascii(check);
+ jsvc_xlate_to_ascii(checkparams);
+ method=(*env)->GetStaticMethodID(env,cls,check,checkparams);
+ if (method==NULL) {
+ log_error("Cannot found Daemon Loader \"check\" entry point");
+ return(false);
+ }
+
+ ret=(*env)->CallStaticBooleanMethod(env,cls,method,className);
+ if (ret==FALSE) {
+ log_error("An error was detected checking the %s daemon",args->clas);
+ return(false);
+ }
+
+ log_debug("Daemon checked successfully");
+ return(true);
+}
+
+/* Call the destroy method in our daemon loader */
+bool java_destroy(void) {
+ jmethodID method;
+ jboolean ret;
+ char destroy[]="destroy";
+ char destroyparams[]="()Z";
+
+ jsvc_xlate_to_ascii(destroy);
+ jsvc_xlate_to_ascii(destroyparams);
+ method=(*env)->GetStaticMethodID(env,cls,destroy,destroyparams);
+ if (method==NULL) {
+ log_error("Cannot found Daemon Loader \"destroy\" entry point");
+ return(false);
+ }
+
+ ret=(*env)->CallStaticBooleanMethod(env,cls,method);
+ if (ret==FALSE) {
+ log_error("Cannot destroy daemon");
+ return(false);
+ }
+
+ log_debug("Daemon destroyed successfully");
+ return(true);
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/java.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/java.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/java.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,28 @@
+/*
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+/* @version $Id: java.h 155409 2005-02-26 12:57:06Z dirkv $ */
+
+#define LOADER "org/apache/commons/daemon/support/DaemonLoader"
+
+char *java_library(arg_data *args, home_data *data);
+bool java_init(arg_data *args, home_data *data);
+bool java_destroy(void);
+bool java_load(arg_data *args);
+bool java_start(void);
+bool java_stop(void);
+bool java_version(void);
+bool java_check(arg_data *args);
+bool JVM_destroy(int exit);
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/jsvc-unix.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/jsvc-unix.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/jsvc-unix.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,832 @@
+/*
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+/* @version $Id: jsvc-unix.c 397516 2006-04-27 10:36:27Z jfclere $ */
+#include "jsvc.h"
+
+#include <signal.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <pwd.h>
+#include <grp.h>
+#ifdef OS_LINUX
+#include <sys/prctl.h>
+#include <sys/syscall.h>
+#define _LINUX_FS_H
+#include <linux/capability.h>
+#endif
+#include <time.h>
+
+#ifdef OS_CYGWIN
+#include <sys/fcntl.h>
+#define F_ULOCK 0 /* Unlock a previously locked region */
+#define F_LOCK 1 /* Lock a region for exclusive use */
+#endif
+
+extern char **environ;
+
+static mode_t envmask; /* mask to create the files */
+
+pid_t controlled=0; /* the son process pid */
+static bool stopping=false;
+static bool doreload=false;
+static void (*handler_int)(int)=NULL;
+static void (*handler_hup)(int)=NULL;
+static void (*handler_trm)(int)=NULL;
+
+#ifdef OS_CYGWIN
+/*
+ * File locking routine
+ */
+static int lockf(int fildes, int function, off_t size)
+{
+ struct flock buf;
+
+ switch (function) {
+ case F_LOCK:
+ buf.l_type = F_WRLCK;
+ break;
+ case F_ULOCK:
+ buf.l_type = F_UNLCK;
+ break;
+ default:
+ return -1;
+ }
+ buf.l_whence = 0;
+ buf.l_start = 0;
+ buf.l_len = size;
+
+ return fcntl(fildes, F_SETLK, &buf);
+}
+
+#endif
+
+static void handler(int sig) {
+ switch (sig) {
+ case SIGTERM: {
+ log_debug("Caught SIGTERM: Scheduling a shutdown");
+ if (stopping==true) {
+ log_error("Shutdown or reload already scheduled");
+ } else {
+ stopping=true;
+ }
+ break;
+ }
+
+ case SIGINT: {
+ log_debug("Caught SIGINT: Scheduling a shutdown");
+ if (stopping==true) {
+ log_error("Shutdown or reload already scheduled");
+ } else {
+ stopping=true;
+ }
+ break;
+ }
+
+ case SIGHUP: {
+ log_debug("Caught SIGHUP: Scheduling a reload");
+ if (stopping==true) {
+ log_error("Shutdown or reload already scheduled");
+ } else {
+ stopping=true;
+ doreload=true;
+ }
+ break;
+ }
+
+ default: {
+ log_debug("Caught unknown signal %d",sig);
+ break;
+ }
+ }
+}
+
+/* user and group */
+static int set_user_group(char *user, int uid, int gid)
+{
+ if (user!=NULL) {
+ if (setgid(gid)!=0) {
+ log_error("Cannot set group id for user '%s'",user);
+ return(-1);
+ }
+ if (initgroups(user, gid)!=0) {
+ if (getuid()!= uid) {
+ log_error("Cannot set supplement group list for user '%s'",user);
+ return(-1);
+ } else
+ log_debug("Cannot set supplement group list for user '%s'",user);
+ }
+ if (getuid() == uid) {
+ log_debug("No need to change user to '%s'!",user);
+ return(0);
+ }
+ if (setuid(uid)!=0) {
+ log_error("Cannot set user id for user '%s'",user);
+ return(-1);
+ }
+ log_debug("user changed to '%s'",user);
+ }
+ return(0);
+}
+/* Set linux capability, user and group */
+#ifdef OS_LINUX
+/* CAPSALL is to allow to read/write at any location */
+#define CAPSALL (1 << CAP_NET_BIND_SERVICE)+ \
+ (1 << CAP_SETUID)+ \
+ (1 << CAP_SETGID)+ \
+ (1 << CAP_DAC_READ_SEARCH)+ \
+ (1 << CAP_DAC_OVERRIDE)
+#define CAPSMAX (1 << CAP_NET_BIND_SERVICE)+ \
+ (1 << CAP_DAC_READ_SEARCH)+ \
+ (1 << CAP_DAC_OVERRIDE)
+/* That a more reasonable configuration */
+#define CAPS (1 << CAP_NET_BIND_SERVICE)+ \
+ (1 << CAP_SETUID)+ \
+ (1 << CAP_SETGID)
+/* probably the only one Java could use */
+#define CAPSMIN (1 << CAP_NET_BIND_SERVICE)
+static int set_caps(int caps)
+{
+ struct __user_cap_header_struct caphead;
+ struct __user_cap_data_struct cap;
+
+ memset(&caphead, 0, sizeof caphead);
+ caphead.version = _LINUX_CAPABILITY_VERSION;
+ caphead.pid = 0;
+ memset(&cap, 0, sizeof cap);
+ cap.effective = caps;
+ cap.permitted = caps;
+ cap.inheritable = caps;
+ if (syscall(__NR_capset, &caphead, &cap) < 0) {
+ log_error("syscall failed in set_caps");
+ return(-1);
+ }
+ return(0);
+}
+static int linuxset_user_group(char *user, int uid, int gid)
+{
+ /* set capabilities enough for binding port 80 setuid/getuid */
+ if (set_caps(CAPS)!=0) {
+ if (getuid()!= uid) {
+ log_error("set_caps(CAPS) failed");
+ return(-1);
+ }
+ log_debug("set_caps(CAPS) failed");
+ }
+
+ /* make sure they are kept after setuid */
+ if (prctl(PR_SET_KEEPCAPS,1,0,0,0) < 0) {
+ log_error("prctl failed in linuxset_user_group");
+ return(-1);
+ }
+
+ /* set setuid/getuid */
+ if (set_user_group(user,uid,gid)!=0) {
+ log_error("set_user_group failed in linuxset_user_group");
+ return(-1);
+ }
+
+ /* set capability to binding port 80 read conf */
+ if (set_caps(CAPSMIN)!=0) {
+ if (getuid()!= uid) {
+ log_error("set_caps(CAPSMIN) failed");
+ return(-1);
+ }
+ log_debug("set_caps(CAPSMIN) failed");
+ }
+
+ return(0);
+}
+#endif
+
+
+static bool checkuser(char *user, uid_t *uid, gid_t *gid) {
+ struct passwd *pwds=NULL;
+ int status=0;
+ pid_t pid=0;
+
+ /* Do we actually _have_ to switch user? */
+ if (user==NULL) return(true);
+
+ pwds=getpwnam(user);
+ if (pwds==NULL) {
+ log_error("Invalid user name '%s' specified",user);
+ return(false);
+ }
+
+ *uid=pwds->pw_uid;
+ *gid=pwds->pw_gid;
+
+ /* Validate the user name in another process */
+ pid=fork();
+ if (pid==-1) {
+ log_error("Cannot validate user name");
+ return(false);
+ }
+
+ /* If we're in the child process, let's validate */
+ if (pid==0) {
+ if (set_user_group(user,*uid,*gid)!=0)
+ exit(1);
+ /* If we got here we switched user/group */
+ exit(0);
+ }
+
+ while (waitpid(pid,&status,0)!=pid);
+
+ /* The child must have exited cleanly */
+ if (WIFEXITED(status)) {
+ status=WEXITSTATUS(status);
+
+ /* If the child got out with 0 the user is ok */
+ if (status==0) {
+ log_debug("User '%s' validated",user);
+ return(true);
+ }
+ }
+
+ log_error("Error validating user '%s'",user);
+ return(false);
+}
+
+#ifdef OS_CYGWIN
+static void cygwincontroller() {
+ raise(SIGTERM);
+}
+#endif
+static void controller(int sig) {
+ switch (sig) {
+ case SIGTERM:
+ case SIGINT:
+ case SIGHUP:
+ log_debug("Forwarding signal %d to process %d",sig,controlled);
+ kill(controlled,sig);
+ signal(sig,controller);
+ break;
+ default:
+ log_debug("Caught unknown signal %d",sig);
+ break;
+ }
+}
+/*
+ * Return the address of the current signal handler and set the new one.
+ */
+static void * signal_set(int sig, void * newHandler) {
+ void *hand;
+
+ hand=signal(sig,newHandler);
+#ifdef SIG_ERR
+ if (hand==SIG_ERR)
+ hand=NULL;
+#endif
+ if (hand==handler || hand==controller)
+ hand=NULL;
+ return(hand);
+}
+
+/*
+ * Check pid and if still running
+ */
+
+static int check_pid(arg_data *args) {
+ int fd;
+ FILE *pidf;
+ char buff[80];
+ pid_t pidn=getpid();
+ int i,pid;
+
+ fd = open(args->pidf,O_RDWR|O_CREAT,S_IRUSR|S_IWUSR);
+ if (fd<0) {
+ log_error("Cannot open PID file %s, PID is %d",args->pidf,pidn);
+ return(-1);
+ } else {
+ lockf(fd,F_LOCK,0);
+ i = read(fd,buff,sizeof(buff));
+ if (i>0) {
+ buff[i] = '\0';
+ pid = atoi(buff);
+ if (kill(pid, 0)==0) {
+ log_error("Still running according to PID file %s, PID is %d",args->pidf,pid);
+ lockf(fd,F_ULOCK,0);
+ close(fd);
+ return(122);
+ }
+ }
+
+ /* skip writing the pid file if version or check */
+ if (args->vers!=true && args->chck!=true) {
+ lseek(fd, SEEK_SET, 0);
+ pidf = fdopen(fd,"r+");
+ fprintf(pidf,"%d\n",(int)getpid());
+ fflush(pidf);
+ lockf(fd,F_ULOCK,0);
+ fclose(pidf);
+ close(fd);
+ } else {
+ lockf(fd,F_ULOCK,0);
+ close(fd);
+ }
+ }
+ return(0);
+}
+
+/*
+ * read the pid from the pidfile
+ */
+static int get_pidf(arg_data *args) {
+ int fd;
+ int i;
+ char buff[80];
+
+ fd = open(args->pidf, O_RDONLY, 0);
+ log_debug("get_pidf: %d in %s", fd, args->pidf);
+ if (fd<0)
+ return(-1); /* something has gone wrong the JVM has stopped */
+ lockf(fd,F_LOCK,0);
+ i = read(fd,buff,sizeof(buff));
+ lockf(fd,F_ULOCK,0);
+ close(fd);
+ if (i>0) {
+ buff[i] = '\0';
+ i = atoi(buff);
+ log_debug("get_pidf: pid %d", i);
+ if (kill(i, 0)==0)
+ return(i);
+ }
+ return(-1);
+}
+
+/*
+ * Check temporatory file created by controller
+ * /tmp/pid.jsvc_up
+ * Notes:
+ * we fork several times
+ * 1 - to be a daemon before the setsid(), the son is the controler process.
+ * 2 - to start the JVM in the son process. (whose pid is stored in pidfile).
+ */
+static int check_tmp_file(arg_data *args) {
+ int pid;
+ char buff[80];
+ int fd;
+ pid = get_pidf(args);
+ if (pid<0)
+ return(-1);
+ sprintf(buff,"/tmp/%d.jsvc_up", pid);
+ log_debug("check_tmp_file: %s", buff);
+ fd = open(buff, O_RDONLY);
+ if (fd<0)
+ return(-1);
+ close(fd);
+ return(0);
+}
+static void create_tmp_file(arg_data *args) {
+ char buff[80];
+ int fd;
+ sprintf(buff,"/tmp/%d.jsvc_up", (int) getpid());
+ log_debug("create_tmp_file: %s", buff);
+ fd = open(buff, O_RDWR|O_CREAT,S_IRUSR|S_IWUSR);
+ if (fd<0)
+ return;
+ close(fd);
+}
+static void remove_tmp_file(arg_data *args) {
+ char buff[80];
+ sprintf(buff,"/tmp/%d.jsvc_up", (int) getpid());
+ log_debug("remove_tmp_file: %s", buff);
+ unlink(buff);
+}
+
+/*
+ * wait until jsvc create the I am ready file
+ * pid is the controller and args->pidf the JVM itself.
+ */
+static int wait_child(arg_data *args, int pid) {
+ int count=10;
+ bool havejvm=false;
+ int fd;
+ char buff[80];
+ int i, status, waittime;
+ log_debug("wait_child %d", pid);
+ waittime = args->wait/10;
+ if (waittime>10) {
+ count = waittime;
+ waittime = 10;
+ }
+ while (count>0) {
+ sleep(1);
+ /* check if the controler is still running */
+ if (waitpid(pid,&status,WNOHANG)==pid) {
+ if (WIFEXITED(status))
+ return(WEXITSTATUS(status));
+ else
+ return(1);
+ }
+
+ /* check if the pid file process exists */
+ fd = open(args->pidf, O_RDONLY);
+ if (fd<0 && havejvm)
+ return(1); /* something has gone wrong the JVM has stopped */
+ lockf(fd,F_LOCK,0);
+ i = read(fd,buff,sizeof(buff));
+ lockf(fd,F_ULOCK,0);
+ close(fd);
+ if (i>0) {
+ buff[i] = '\0';
+ i = atoi(buff);
+ if (kill(i, 0)==0) {
+ /* the JVM process has started */
+ havejvm=true;
+ if (check_tmp_file(args)==0) {
+ /* the JVM is started */
+ if (waitpid(pid,&status,WNOHANG)==pid) {
+ if (WIFEXITED(status))
+ return(WEXITSTATUS(status));
+ else
+ return(1);
+ }
+ return(0); /* ready JVM started */
+ }
+ }
+ }
+ sleep(waittime);
+ count--;
+ }
+ return(1); /* It takes more than the wait time to start, something must be wrong */
+}
+
+/*
+ * stop the running jsvc
+ */
+static int stop_child(arg_data *args) {
+ int pid=get_pidf(args);
+ int count=10;
+ if (pid>0) {
+ /* kill the process and wait until the pidfile has been removed by the controler */
+ kill(pid,SIGTERM);
+ while (count>0) {
+ sleep(6);
+ pid=get_pidf(args);
+ if (pid<=0)
+ return(0); /* JVM has stopped */
+ count--;
+ }
+ }
+ return(-1);
+}
+
+/*
+ * son process logic.
+ */
+
+static int child(arg_data *args, home_data *data, uid_t uid, gid_t gid) {
+ int ret=0;
+
+ /* check the pid file */
+ ret = check_pid(args);
+ if (args->vers!=true && args->chck!=true) {
+ if (ret==122)
+ return(ret);
+ if (ret<0)
+ return(ret);
+ }
+
+ /* create a new process group to prevent kill 0 killing the monitor process */
+#if defined(OS_FREEBSD) || defined(OS_DARWIN)
+ setpgid(0,0);
+#else
+ setpgrp();
+#endif
+
+#ifdef OS_LINUX
+ /* setuid()/setgid() only apply the current thread so we must do it now */
+ if (linuxset_user_group(args->user,uid,gid)!=0)
+ return(4);
+#endif
+ /* Initialize the Java VM */
+ if (java_init(args,data)!=true) {
+ log_debug("java_init failed");
+ return(1);
+ } else
+ log_debug("java_init done");
+
+ /* Check wether we need to dump the VM version */
+ if (args->vers==true) {
+ if (java_version()!=true) {
+ return(-1);
+ } else return(0);
+ }
+
+ /* Do we have to do a "check-only" initialization? */
+ if (args->chck==true) {
+ if (java_check(args)!=true) return(2);
+ printf("Service \"%s\" checked successfully\n",args->clas);
+ return(0);
+ }
+
+ /* Load the service */
+ if (java_load(args)!=true) {
+ log_debug("java_load failed");
+ return(3);
+ } else
+ log_debug("java_load done");
+
+ /* Downgrade user */
+#ifdef OS_LINUX
+ if (set_caps(0)!=0) {
+ log_debug("set_caps (0) failed");
+ return(4);
+ }
+#else
+ if (set_user_group(args->user,uid,gid)!=0)
+ return(4);
+#endif
+
+ /* Start the service */
+ umask(envmask);
+ if (java_start()!=true) {
+ log_debug("java_start failed");
+ return(5);
+ } else
+ log_debug("java_start done");
+
+ /* Install signal handlers */
+ handler_hup=signal_set(SIGHUP,handler);
+ handler_trm=signal_set(SIGTERM,handler);
+ handler_int=signal_set(SIGINT,handler);
+ controlled = getpid();
+ log_debug("Waiting for a signal to be delivered");
+ create_tmp_file(args);
+ while (!stopping) {
+#if defined(OSD_POSIX) || defined(HAVE_KAFFEVM)
+ java_sleep(60);
+ /* pause(); */
+#else
+ sleep(60); /* pause() not threadsafe */
+#endif
+ }
+ remove_tmp_file(args);
+ log_debug("Shutdown or reload requested: exiting");
+
+ /* Stop the service */
+ if (java_stop()!=true) return(6);
+
+ if (doreload==true) ret=123;
+ else ret=0;
+
+ /* Destroy the service */
+ java_destroy();
+
+ /* Destroy the Java VM */
+ if (JVM_destroy(ret)!=true) return(7);
+
+ return(ret);
+}
+
+/*
+ * freopen close the file first and then open the new file
+ * that is not very good if we are try to trace the output
+ * note the code assumes that the errors are configuration errors.
+ */
+static FILE *loc_freopen(char *outfile, char *mode, FILE *stream)
+{
+ FILE *ftest;
+ ftest = fopen(outfile,mode);
+ if (ftest == NULL) {
+ fprintf(stderr,"Unable to redirect to %s\n", outfile);
+ return(stream);
+ }
+ fclose(ftest);
+ return(freopen(outfile,mode,stream));
+}
+
+/**
+ * Redirect stdin, stdout, stderr.
+ */
+static void set_output(char *outfile, char *errfile) {
+ freopen("/dev/null", "r", stdin);
+ log_debug("redirecting stdout to %s and stderr to %s",outfile,errfile);
+
+ /* make sure the debug goes out */
+ if (log_debug_flag==true && strcmp(errfile,"/dev/null") == 0)
+ return;
+
+ /* Handle malicious case here */
+ if(strcmp(outfile, "&2") == 0 && strcmp(errfile,"&1") == 0) {
+ outfile="/dev/null";
+ }
+ if(strcmp(outfile, "&2") != 0) {
+ loc_freopen(outfile, "a", stdout);
+ }
+
+ if(strcmp(errfile,"&1") != 0) {
+ loc_freopen(errfile, "a", stderr);
+ } else {
+ close(2);
+ dup(1);
+ }
+ if(strcmp(outfile, "&2") == 0) {
+ close(1);
+ dup(2);
+ }
+}
+
+int main(int argc, char *argv[]) {
+ arg_data *args=NULL;
+ home_data *data=NULL;
+ int status=0;
+ pid_t pid=0;
+ uid_t uid=0;
+ gid_t gid=0;
+ time_t laststart;
+
+ /* Parse command line arguments */
+ args=arguments(argc,argv);
+ if (args==NULL) return(1);
+
+ /* Stop running jsvc if required */
+ if (args->stop==true)
+ return(stop_child(args));
+
+ /* Let's check if we can switch user/group IDs */
+ if (checkuser(args->user, &uid, &gid)==false) return(1);
+
+ /* Retrieve JAVA_HOME layout */
+ data=home(args->home);
+ if (data==NULL) return(1);
+
+ /* Check for help */
+ if (args->help==true) {
+ help(data);
+ return(0);
+ }
+
+#ifdef OS_LINUX
+ /* On some UNIX operating systems, we need to REPLACE this current
+ process image with another one (thru execve) to allow the correct
+ loading of VMs (notably this is for Linux). Set, replace, and go. */
+ if (strcmp(argv[0],args->procname)!=0) {
+ char *oldpath=getenv("LD_LIBRARY_PATH");
+ char *libf=java_library(args,data);
+ char *filename;
+ char buf[2048];
+ int ret;
+ char *tmp=NULL;
+ char *p1=NULL;
+ char *p2=NULL;
+
+ /*
+ * There is no need to change LD_LIBRARY_PATH
+ * if we were not able to find a path to libjvm.so
+ * (additionaly a strdup(NULL) cores dump on my machine).
+ */
+ if (libf!=NULL) {
+ p1=strdup(libf);
+ tmp=strrchr(p1,'/');
+ if (tmp!=NULL) tmp[0]='\0';
+
+ p2=strdup(p1);
+ tmp=strrchr(p2,'/');
+ if (tmp!=NULL) tmp[0]='\0';
+
+ if (oldpath==NULL) snprintf(buf,2048,"%s:%s",p1,p2);
+ else snprintf(buf,2048,"%s:%s:%s",oldpath,p1,p2);
+
+ tmp=strdup(buf);
+ setenv("LD_LIBRARY_PATH",tmp,1);
+
+ log_debug("Invoking w/ LD_LIBRARY_PATH=%s",getenv("LD_LIBRARY_PATH"));
+ }
+
+ /* execve needs a full path */
+ ret = readlink("/proc/self/exe",buf,sizeof(buf)-1);
+ if (ret<=0)
+ strcpy(buf,argv[0]);
+ else
+ buf[ret]='\0';
+
+ filename=buf;
+
+ argv[0]=args->procname;
+ execve(filename,argv,environ);
+ log_error("Cannot execute JSVC executor process (%s)",filename);
+ return(1);
+ }
+ log_debug("Running w/ LD_LIBRARY_PATH=%s",getenv("LD_LIBRARY_PATH"));
+#endif /* ifdef OS_LINUX */
+
+ /* If we have to detach, let's do it now */
+ if (args->dtch==true) {
+ pid=fork();
+ if (pid==-1) {
+ log_error("Cannot detach from parent process");
+ return(1);
+ }
+ /* If we're in the parent process */
+ if (pid!=0) {
+ if (args->wait>=10)
+ return(wait_child(args,pid));
+ else
+ return(0);
+ }
+#ifndef NO_SETSID
+ setsid();
+#endif
+ }
+
+ envmask = umask(0077);
+ set_output(args->outfile, args->errfile);
+
+ /* We have to fork: this process will become the controller and the other
+ will be the child */
+ while ((pid=fork())!=-1) {
+ /* We forked (again), if this is the child, we go on normally */
+ if (pid==0) exit(child(args,data,uid,gid));
+ laststart = time(NULL);
+
+ /* We are in the controller, we have to forward all interesting signals
+ to the child, and wait for it to die */
+ controlled=pid;
+#ifdef OS_CYGWIN
+ SetTerm(cygwincontroller);
+#endif
+ signal(SIGHUP,controller);
+ signal(SIGTERM,controller);
+ signal(SIGINT,controller);
+
+ while (waitpid(pid,&status,0)!=pid);
+
+ /* The child must have exited cleanly */
+ if (WIFEXITED(status)) {
+ status=WEXITSTATUS(status);
+
+ /* Delete the pid file */
+ if (args->vers!=true && args->chck!=true && status!=122)
+ unlink(args->pidf);
+
+ /* If the child got out with 123 he wants to be restarted */
+ /* See java_abort123 (we use this return code to restart when the JVM aborts) */
+ if (status==123) {
+ log_debug("Reloading service");
+ /* prevent looping */
+ if (laststart+60>time(NULL)) {
+ log_debug("Waiting 60 s to prevent looping");
+ sleep(60);
+ }
+ continue;
+ }
+ /* If the child got out with 0 he is shutting down */
+ if (status==0) {
+ log_debug("Service shut down");
+ return(0);
+ }
+ /* Otherwise we don't rerun it */
+ log_error("Service exit with a return value of %d",status);
+ return(1);
+
+ } else {
+ if (WIFSIGNALED(status)) {
+ log_error("Service killed by signal %d",WTERMSIG(status));
+ /* prevent looping */
+ if (laststart+60>time(NULL)) {
+ log_debug("Waiting 60 s to prevent looping");
+ sleep(60);
+ }
+ continue;
+ }
+ log_error("Service did not exit cleanly",status);
+ return(1);
+ }
+ }
+
+ /* Got out of the loop? A fork() failed then. */
+ log_error("Cannot decouple controller/child processes");
+ return(1);
+
+}
+
+void main_reload(void) {
+ log_debug("Killing self with HUP signal");
+ kill(controlled,SIGHUP);
+}
+
+void main_shutdown(void) {
+ log_debug("Killing self with TERM signal");
+ kill(controlled,SIGTERM);
+}
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/jsvc.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/jsvc.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/jsvc.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,46 @@
+/*
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+/* @version $Id: jsvc.h 155409 2005-02-26 12:57:06Z dirkv $ */
+#ifndef __JSVC_H__
+#define __JSVC_H__
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+/* Definitions for booleans */
+typedef enum {
+ false,
+ true
+} bool;
+
+#include "debug.h"
+#include "arguments.h"
+#include "home.h"
+#include "location.h"
+#include "replace.h"
+#include "dso.h"
+#include "java.h"
+#include "help.h"
+
+int main(int argc, char *argv[]);
+void main_reload(void);
+void main_shutdown(void);
+
+#endif /* ifndef __JSVC_H__ */
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/location.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/location.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/location.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,143 @@
+/*
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+/* @version $Id: location.c 410151 2006-05-29 20:45:22Z jfclere $ */
+#include "jsvc.h"
+
+/* Locations of various JVM files. We have to deal with all this madness since
+ we're not distributed togheter (yet!) with an official VM distribution. All
+ this CRAP needs improvement, and based on the observation of default
+ distributions of VMs and OSes. If it doesn't work for you, please report
+ your VM layout (ls -laR) and system details (build/config.guess) so that we
+ can improve the search algorithms. */
+
+/* If JAVA_HOME is not defined we search this list of paths (OS-dependant)
+ to find the default location of the JVM. */
+char *location_home[] = {
+#if defined(OS_DARWIN)
+ "/System/Library/Frameworks/JavaVM.framework/Home",
+ "/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home/",
+#elif defined(OS_LINUX) || defined(OS_SOLARIS) || defined(OS_BSD)
+ "/usr/java",
+ "/usr/local/java",
+#elif defined(OS_CYGWIN)
+ "/cygdrive/c/WINNT/system32/java",
+#elif defined(OS_SYSV)
+ "/opt/java",
+ "/opt/java/jdk13",
+#elif defined(OS_TRU64)
+ "/usr/opt/java142",
+ "/usr/opt/java13",
+#elif defined(OS_HPUX)
+ "/opt/java1.4",
+ "/opt/java1.3",
+#endif
+ NULL,
+};
+
+/* The jvm.cfg file defines the VMs available for invocation. So far, on all
+ all systems I've seen it's in $JAVA_HOME/lib. If this file is not found,
+ then the "default" VMs (from location_jvm_default) is searched, otherwise,
+ we're going to look thru the "configured" VMs (from lod_cfgvm) lying
+ somewhere around JAVA_HOME. (Only two, I'm happy) */
+char *location_jvm_cfg[] = {
+ "$JAVA_HOME/jre/lib/jvm.cfg", /* JDK */
+ "$JAVA_HOME/lib/jvm.cfg", /* JRE */
+ "$JAVA_HOME/jre/lib/" CPU "/jvm.cfg", /* JDK */
+ "$JAVA_HOME/lib/" CPU "/jvm.cfg", /* JRE */
+ NULL,
+};
+
+/* This is the list of "defaults" VM (searched when jvm.cfg is not found, as
+ in the case of most JDKs 1.2.2 */
+char *location_jvm_default[] = {
+#if defined(OS_DARWIN)
+ "$JAVA_HOME/../Libraries/libjvm.dylib",
+#elif defined(OS_CYGWIN)
+ "$JAVA_HOME/jre/bin/classic/jvm.dll", /* Sun JDK 1.3 */
+ "$JAVA_HOME/jre/bin/client/jvm.dll", /* Sun JDK 1.4 */
+#elif defined(OS_LINUX) || defined(OS_SOLARIS) || defined(OS_BSD) || defined(OS_SYSV) || defined(OS_FREEBSD) || defined(OS_TRU64)
+#if defined(HAVE_SABLEVM)
+ "$JAVA_HOME/lib/libsablevm.so", /* sableVM */
+#endif
+#if defined(HAVE_KAFFEVM)
+ "$JAVA_HOME/jre/lib/" CPU "/libkaffevm.so", /* kaffe */
+#endif
+ "$JAVA_HOME/jre/lib/" CPU "/classic/libjvm.so", /* Sun JDK 1.2 */
+ "$JAVA_HOME/jre/lib/" CPU "/client/libjvm.so", /* Sun JDK 1.3 */
+ "$JAVA_HOME/jre/lib/" CPU "/libjvm.so", /* Sun JDK */
+ "$JAVA_HOME/lib/" CPU "/classic/libjvm.so", /* Sun JRE 1.2 */
+ "$JAVA_HOME/lib/" CPU "/client/libjvm.so", /* Sun JRE 1.3 */
+ "$JAVA_HOME/lib/" CPU "/libjvm.so", /* Sun JRE */
+ "$JAVA_HOME/jre/bin/" CPU "/classic/libjvm.so", /* IBM JDK 1.3 */
+ "$JAVA_HOME/jre/bin/" CPU "/libjvm.so", /* IBM JDK */
+ "$JAVA_HOME/bin/" CPU "/classic/libjvm.so", /* IBM JRE 1.3 */
+ "$JAVA_HOME/bin/" CPU "/libjvm.so", /* IBM JRE */
+ /* Those are "weirdos: if we got here, we're probably in troubles and
+ we're not going to find anything, but hope never dies... */
+ "$JAVA_HOME/jre/lib/" CPU "/classic/green_threads/libjvm.so",
+#if defined(OSD_POSIX)
+ "$JAVA_HOME/lib/s390/client/green_threads/libjvm.so",
+ "$JAVA_HOME/lib/sparc/client/green_threads/libjvm.so",
+#endif
+ "$JAVA_HOME/jre/lib/classic/libjvm.so",
+ "$JAVA_HOME/jre/lib/client/libjvm.so",
+ "$JAVA_HOME/jre/lib/libjvm.so",
+ "$JAVA_HOME/lib/classic/libjvm.so",
+ "$JAVA_HOME/lib/client/libjvm.so",
+ "$JAVA_HOME/lib/libjvm.so",
+ "$JAVA_HOME/jre/bin/classic/libjvm.so",
+ "$JAVA_HOME/jre/bin/client/libjvm.so",
+ "$JAVA_HOME/jre/bin/libjvm.so",
+ "$JAVA_HOME/bin/classic/libjvm.so",
+ "$JAVA_HOME/bin/client/libjvm.so",
+ "$JAVA_HOME/bin/libjvm.so",
+ "$JAVA_HOME/jre/lib/" CPU "/fast64/libjvm.so",
+ "$JAVA_HOME/jre/lib/" CPU "/fast32/libjvm.so",
+ "$JAVA_HOME/lib/" CPU "/fast64/libjvm.so",
+ "$JAVA_HOME/lib/" CPU "/fast32/libjvm.so",
+#elif defined(OS_HPUX)
+ "$JAVA_HOME/jre/lib/" CPU "/server/libjvm.sl",
+ "$JAVA_HOME/jre/lib/" CPU "/client/libjvm.sl",
+ "$JAVA_HOME/jre/lib/" CPU "/hotspot/libjvm.sl",
+ "$JAVA_HOME/jre/lib/" CPU "/classic/libjvm.sl",
+#endif
+ "/usr/lib/libgcj.so.7", /* gcc java libraries */
+ "/usr/lib/libgcj.so.6",
+ NULL,
+};
+
+/* This is the list of "configured" VM (searched when jvm.cfg is found, as
+ in the case of most JDKs 1.3 (not IBM, for example), way easier than
+ before, and lovely, indeed... */
+char *location_jvm_configured[] = {
+#if defined(OS_DARWIN)
+ "$JAVA_HOME/../Libraries/lib$VM_NAME.dylib",
+#elif defined(OS_CYGWIN)
+ "$JAVA_HOME/jre/bin/$VM_NAME/jvm.dll", /* Sun JDK 1.3 */
+#elif defined(OS_LINUX) || defined(OS_SOLARIS) || defined(OS_BSD) || defined(OS_FREEBSD) || defined(OS_TRU64)
+ "$JAVA_HOME/jre/lib/" CPU "/$VM_NAME/libjvm.so",/* Sun JDK 1.3 */
+ "$JAVA_HOME/lib/" CPU "/$VM_NAME/libjvm.so", /* Sun JRE 1.3 */
+#elif defined(OS_HPUX)
+ "$JAVA_HOME/jre/lib/" CPU "/$VM_NAME/libjvm.sl",
+ "$JAVA_HOME/lib/" CPU "/$VM_NAME/libjvm.sl",
+#elif defined(OS_SYSV)
+ "$JAVA_HOME/jre/lib/" CPU "/$VM_NAME/dce_threads/libjvm.so",
+ "$JAVA_HOME/jre/lib/" CPU "/$VM_NAME/green_threads/libjvm.so",
+ "$JAVA_HOME/lib/" CPU "/$VM_NAME/dce_threads/libjvm.so",
+ "$JAVA_HOME/lib/" CPU "/$VM_NAME/green_threads/libjvm.so",
+#endif
+ NULL,
+};
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/location.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/location.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/location.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,22 @@
+/*
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+/* @version $Id: location.h 155409 2005-02-26 12:57:06Z dirkv $ */
+#include "jsvc.h"
+
+extern char *location_home[];
+extern char *location_jvm_cfg[];
+extern char *location_jvm_default[];
+extern char *location_jvm_configured[];
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/replace.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/replace.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/replace.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,109 @@
+/*
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+/* @version $Id: replace.c 155409 2005-02-26 12:57:06Z dirkv $ */
+#include "jsvc.h"
+
+/* Replace all occurrences of a string in another */
+int replace(char *new, int len, char *old, char *mch, char *rpl) {
+ char *tmp;
+ int count;
+ int shift;
+ int nlen;
+ int olen;
+ int mlen;
+ int rlen;
+ int x;
+
+ /* The new buffer is NULL, fail */
+ if (new==NULL) return(-1);
+ /* The length of the buffer is less than zero, fail */
+ if (len<0) return(-2);
+ /* The old buffer is NULL, fail */
+ if (old==NULL) return(-3);
+
+ /* The string to be matched is NULL or empty, simply copy */
+ if ((mch==NULL)||(strlen(mch)==0)) {
+ olen=strlen(old);
+ if (len<=olen) return(olen+1);
+ strcpy(new,old);
+ return(0);
+ }
+
+ /* The string to be replaced is NULL, assume it's an empty string */
+ if (rpl==NULL) rpl="";
+
+ /* Evaluate some lengths */
+ olen=strlen(old);
+ mlen=strlen(mch);
+ rlen=strlen(rpl);
+
+ /* Calculate how many times the mch string appears in old */
+ tmp=old;
+ count=0;
+ while((tmp=strstr(tmp,mch))!=NULL) {
+ count++;
+ tmp+=mlen;
+ }
+
+ /* We have no matches, simply copy */
+ if (count==0) {
+ olen=strlen(old);
+ if (len<=olen) return(olen+1);
+ strcpy(new,old);
+ return(0);
+ }
+
+ /* Calculate how big the buffer must be to hold the translation
+ and of how many bytes we need to shift the data */
+ shift=rlen-mlen;
+ nlen=olen+(shift*count);
+ /* printf("Count=%d Shift= %d OLen=%d NLen=%d\n",count,shift,olen,nlen); */
+
+ /* Check if we have enough size in the buffer */
+ if (nlen>=len) return(nlen+1);
+
+ /* Copy over the old buffer in the new one (save memory) */
+ strcpy(new,old);
+
+ /* Start replacing */
+ tmp=new;
+ while((tmp=strstr(tmp,mch))!=NULL) {
+ /* If shift is > 0 we need to move data from right to left */
+ if (shift>0) {
+ for (x=(strlen(tmp)+shift);x>shift;x--) {
+ /*
+ printf("src %c(%d) dst %c(%d)\n",
+ tmp[x-shift],tmp[x-shift],tmp[x],tmp[x]);
+ */
+ tmp[x]=tmp[x-shift];
+ }
+ /* If shift is < 0 we need to move data from left to right */
+ } else if (shift<0) {
+ for (x=mlen;x<strlen(tmp)-shift;x++) {
+ /*
+ printf("src %c(%d) dst %c(%d)\n",
+ tmp[x],tmp[x],tmp[x+shift],tmp[x+shift]);
+ */
+ tmp[x+shift]=tmp[x];
+ }
+ }
+ /* If shift is = 0 we don't have to shift data */
+ strncpy(tmp,rpl,rlen);
+ tmp+=rlen;
+ /* printf("\"%s\"\n",tmp); */
+ }
+ return(0);
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/replace.h
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/replace.h 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/replace.h 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,37 @@
+/*
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+/* @version $Id: replace.h 155409 2005-02-26 12:57:06Z dirkv $ */
+#ifndef __JSVC_REPLACE_H__
+#define __JSVC_REPLACE_H__
+
+/**
+ * Replace all occurrences of mch in old with the new string rpl, and
+ * stores the result in new, provided that its length (specified in len)
+ * is enough.
+ *
+ * @param new The buffer where the result of the replace operation will be
+ * stored into.
+ * @param len The length of the previous buffer.
+ * @param old The string where occurrences of mtch must be searched.
+ * @param mch The characters to match in old (and to be replaced)
+ * @param rpl The characters that will be replaced in place of mch.
+ * @return Zero on success, a value less than 0 if an error was encountered
+ * or a value greater than zero (indicating the required storage size
+ * for new) if the buffer was too short to hold the new string.
+ */
+int replace(char *new, int len, char *old, char *mch, char *rpl);
+
+#endif /* ifndef __JSVC_REPLACE_H__ */
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/signals.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/signals.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/native/signals.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,99 @@
+/*
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+/* @version $Id: signals.c 155409 2005-02-26 12:57:06Z dirkv $ */
+
+/*
+ * as Windows does not support signal, jsvc use event to emulate them.
+ * The supported signal is SIGTERM.
+ * The kills.c contains the kill logic.
+ */
+#ifdef OS_CYGWIN
+#include <windows.h>
+#include <stdio.h>
+static void (*HandleTerm)()=NULL; /* address of the handler routine. */
+
+/*
+ * Event handling routine
+ */
+void v_difthf(LPVOID par)
+{
+HANDLE hevint; /* make a local copy because the parameter is shared! */
+
+ hevint = (HANDLE) par;
+
+ for (;;) {
+ if (WaitForSingleObject(hevint,INFINITE) == WAIT_FAILED) {
+ /* something have gone wrong. */
+ return; /* may be something more is needed. */
+ }
+
+ /* call the interrupt handler. */
+ if (HandleTerm==NULL) return;
+ HandleTerm();
+ }
+}
+
+/*
+ * set a routine handler for the signal
+ * note that it cannot be used to change the signal handler
+ */
+int SetTerm(void (*func)())
+{
+char Name[256];
+HANDLE hevint, hthread;
+DWORD ThreadId;
+SECURITY_ATTRIBUTES sa;
+SECURITY_DESCRIPTOR sd;
+
+ sprintf(Name,"TERM%ld",GetCurrentProcessId());
+
+ /*
+ * event cannot be inherited.
+ * the event is reseted to nonsignaled after the waiting thread is released.
+ * the start state is resetted.
+ */
+
+ /* Initialize the new security descriptor. */
+ InitializeSecurityDescriptor (&sd, SECURITY_DESCRIPTOR_REVISION);
+
+ /* Add a NULL descriptor ACL to the security descriptor. */
+ SetSecurityDescriptorDacl (&sd, TRUE, (PACL)NULL, FALSE);
+
+ sa.nLength = sizeof(sa);
+ sa.lpSecurityDescriptor = &sd;
+ sa.bInheritHandle = TRUE;
+
+
+ /* It works also with NULL instead &sa!! */
+ hevint = CreateEvent(&sa,FALSE, FALSE,Name);
+
+ HandleTerm = (int (*)()) func;
+
+ if (hevint == NULL) return(-1); /* failed */
+
+ /* create the thread to wait for event */
+ hthread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE) v_difthf,
+ (LPVOID) hevint, 0, &ThreadId);
+ if (hthread == NULL) {
+ /* failed remove the event */
+ CloseHandle(hevint); /* windows will remove it. */
+ return(-1);
+ }
+
+ CloseHandle(hthread); /* not needed */
+ return(0);
+}
+#endif
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/apfunctions.m4
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/apfunctions.m4 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/apfunctions.m4 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,39 @@
+dnl
+dnl Copyright 1999-2004 The Apache Software Foundation
+dnl
+dnl Licensed under the Apache License, Version 2.0 (the "License");
+dnl you may not use this file except in compliance with the License.
+dnl You may obtain a copy of the License at
+dnl
+dnl http://www.apache.org/licenses/LICENSE-2.0
+dnl
+dnl Unless required by applicable law or agreed to in writing, software
+dnl distributed under the License is distributed on an "AS IS" BASIS,
+dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+dnl See the License for the specific language governing permissions and
+dnl limitations under the License.
+dnl
+
+dnl -------------------------------------------------------------------------
+dnl Author Pier Fumagalli <mailto:pier.fumagalli at eng.sun.com>
+dnl Version $Id: apfunctions.m4 140756 2004-02-27 08:40:46Z jfclere $
+dnl -------------------------------------------------------------------------
+
+AC_DEFUN(AP_MSG_HEADER,[
+ printf "*** %s ***\n" "$1" 1>&2
+ AC_PROVIDE([$0])
+])
+
+AC_DEFUN(AP_CANONICAL_HOST_CHECK,[
+ AC_MSG_CHECKING([cached host system type])
+ if { test x"${ac_cv_host_system_type+set}" = x"set" &&
+ test x"$ac_cv_host_system_type" != x"$host" ; }
+ then
+ AC_MSG_RESULT([$ac_cv_host_system_type])
+ AC_MSG_ERROR([remove the \"$cache_file\" file and re-run configure])
+ else
+ AC_MSG_RESULT(ok)
+ ac_cv_host_system_type="$host"
+ fi
+ AC_PROVIDE([$0])
+])
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/apjava.m4
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/apjava.m4 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/apjava.m4 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,141 @@
+dnl
+dnl Copyright 1999-2004 The Apache Software Foundation
+dnl
+dnl Licensed under the Apache License, Version 2.0 (the "License");
+dnl you may not use this file except in compliance with the License.
+dnl You may obtain a copy of the License at
+dnl
+dnl http://www.apache.org/licenses/LICENSE-2.0
+dnl
+dnl Unless required by applicable law or agreed to in writing, software
+dnl distributed under the License is distributed on an "AS IS" BASIS,
+dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+dnl See the License for the specific language governing permissions and
+dnl limitations under the License.
+dnl
+
+dnl -------------------------------------------------------------------------
+dnl Author Pier Fumagalli <mailto:pier.fumagalli at eng.sun.com>
+dnl Version $Id: apjava.m4 396916 2006-04-25 17:04:38Z jfclere $
+dnl -------------------------------------------------------------------------
+
+AC_DEFUN([AP_PROG_JAVAC_WORKS],[
+ AC_CACHE_CHECK([wether the Java compiler ($JAVAC) works],ap_cv_prog_javac_works,[
+ echo "public class Test {}" > Test.java
+ $JAVAC $JAVACFLAGS Test.java > /dev/null 2>&1
+ if test $? -eq 0
+ then
+ rm -f Test.java Test.class
+ ap_cv_prog_javac_works=yes
+ else
+ rm -f Test.java Test.class
+ AC_MSG_RESULT(no)
+ AC_MSG_ERROR([installation or configuration problem: javac cannot compile])
+ fi
+ ])
+])
+
+dnl Check for JAVA compilers.
+AC_DEFUN([AP_PROG_JAVAC],[
+ if test "$SABLEVM" != "NONE"
+ then
+ AC_PATH_PROG(JAVACSABLE,javac-sablevm,NONE,$JAVA_HOME/bin)
+ else
+ JAVACSABLE="NONE"
+ fi
+ if test "$JAVACSABLE" = "NONE"
+ then
+ XPATH="$JAVA_HOME/bin:$JAVA_HOME/Commands:$PATH"
+ AC_PATH_PROG(JAVAC,javac,NONE,$XPATH)
+ else
+ AC_PATH_PROG(JAVAC,javac-sablevm,NONE,$JAVA_HOME/bin)
+ fi
+ AC_MSG_RESULT([$JAVAC])
+ if test "$JAVAC" = "NONE"
+ then
+ AC_MSG_ERROR([javac not found])
+ fi
+ AP_PROG_JAVAC_WORKS()
+ AC_PROVIDE([$0])
+ AC_SUBST(JAVAC)
+ AC_SUBST(JAVACFLAGS)
+])
+
+dnl Check for jar archivers.
+AC_DEFUN([AP_PROG_JAR],[
+ if test "$SABLEVM" != "NONE"
+ then
+ AC_PATH_PROG(JARSABLE,jar-sablevm,NONE,$JAVA_HOME/bin)
+ else
+ JARSABLE="NONE"
+ fi
+ if test "$JARSABLE" = "NONE"
+ then
+ XPATH="$JAVA_HOME/bin:$JAVA_HOME/Commands:$PATH"
+ AC_PATH_PROG(JAR,jar,NONE,$XPATH)
+ else
+ AC_PATH_PROG(JAR,jar-sablevm,NONE,$JAVA_HOME/bin)
+ fi
+ if test "$JAR" = "NONE"
+ then
+ AC_MSG_ERROR([jar not found])
+ fi
+ AC_PROVIDE([$0])
+ AC_SUBST(JAR)
+])
+
+AC_DEFUN([AP_JAVA],[
+ AC_ARG_WITH(java,[ --with-java=DIR Specify the location of your JDK installation],[
+ AC_MSG_CHECKING([JAVA_HOME])
+ if test -d "$withval"
+ then
+ JAVA_HOME="$withval"
+ AC_MSG_RESULT([$JAVA_HOME])
+ else
+ AC_MSG_RESULT([failed])
+ AC_MSG_ERROR([$withval is not a directory])
+ fi
+ AC_SUBST(JAVA_HOME)
+ ])
+ if test x"$JAVA_HOME" = x
+ then
+ AC_MSG_ERROR([Java Home not defined. Rerun with --with-java=[...] parameter])
+ fi
+])
+
+dnl check if the JVM in JAVA_HOME is sableVM
+dnl $JAVA_HOME/bin/sablevm and /opt/java/lib/sablevm/bin are tested.
+AC_DEFUN([AP_SABLEVM],[
+ if test x"$JAVA_HOME" != x
+ then
+ AC_PATH_PROG(SABLEVM,sablevm,NONE,$JAVA_HOME/bin)
+ if test "$SABLEVM" = "NONE"
+ then
+ dnl java may be SableVM.
+ if $JAVA_HOME/bin/java -version 2> /dev/null | grep SableVM > /dev/null
+ then
+ SABLEVM=$JAVA_HOME/bin/java
+ fi
+ fi
+ if test "$SABLEVM" != "NONE"
+ then
+ AC_MSG_RESULT([Using sableVM: $SABLEVM])
+ CFLAGS="$CFLAGS -DHAVE_SABLEVM"
+ fi
+ fi
+])
+
+dnl check if the JVM in JAVA_HOME is kaffe
+dnl $JAVA_HOME/bin/kaffe is tested.
+AC_DEFUN([AP_KAFFE],[
+ if test x"$JAVA_HOME" != x
+ then
+ AC_PATH_PROG(KAFFEVM,kaffe,NONE,$JAVA_HOME/bin)
+ if test "$KAFFEVM" != "NONE"
+ then
+ AC_MSG_RESULT([Using kaffe: $KAFFEVM])
+ CFLAGS="$CFLAGS -DHAVE_KAFFEVM"
+ LDFLAGS="$LDFLAGS -Wl,-rpath $JAVA_HOME/jre/lib/$HOST_CPU -L $JAVA_HOME/jre/lib/$HOST_CPU -lkaffevm"
+ fi
+ fi
+])
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/apsupport.m4
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/apsupport.m4 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/apsupport.m4 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,128 @@
+dnl
+dnl Copyright 1999-2004 The Apache Software Foundation
+dnl
+dnl Licensed under the Apache License, Version 2.0 (the "License");
+dnl you may not use this file except in compliance with the License.
+dnl You may obtain a copy of the License at
+dnl
+dnl http://www.apache.org/licenses/LICENSE-2.0
+dnl
+dnl Unless required by applicable law or agreed to in writing, software
+dnl distributed under the License is distributed on an "AS IS" BASIS,
+dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+dnl See the License for the specific language governing permissions and
+dnl limitations under the License.
+dnl
+
+dnl -------------------------------------------------------------------------
+dnl Author Pier Fumagalli <mailto:pier.fumagalli at eng.sun.com>
+dnl Version $Id: apsupport.m4 410153 2006-05-29 21:05:17Z jfclere $
+dnl -------------------------------------------------------------------------
+
+AC_DEFUN(AP_SUPPORTED_HOST,[
+ AC_MSG_CHECKING([C flags dependant on host system type])
+
+ case $host_os in
+ darwin*)
+ CFLAGS="$CFLAGS -DOS_DARWIN -DDSO_DYLD"
+ supported_os="darwin"
+ ;;
+ solaris*)
+ CFLAGS="$CFLAGS -DOS_SOLARIS -DDSO_DLFCN"
+ supported_os="solaris"
+ LIBS="$LIBS -ldl -lthread"
+ ;;
+ linux*)
+ CFLAGS="$CFLAGS -DOS_LINUX -DDSO_DLFCN"
+ supported_os="linux"
+ LIBS="$LIBS -ldl -lpthread"
+ ;;
+ cygwin)
+ CFLAGS="$CFLAGS -DOS_CYGWIN -DDSO_DLFCN -DNO_SETSID"
+ supported_os="win32"
+ ;;
+ sysv)
+ CFLAGS="$CFLAGS -DOS_SYSV -DDSO_DLFCN"
+ LIBS="$LIBS -ldl"
+ ;;
+ sysv4)
+ CFLAGS="$CFLAGS -DOS_SYSV -DDSO_DLFCN -Kthread"
+ LDFLAGS="-Kthread $LDFLAGS"
+ LIBS="$LIBS -ldl"
+ ;;
+ freebsd*)
+ CFLAGS="$CFLAGS -DOS_FREEBSD -DDSO_DLFCN -D_THREAD_SAFE -pthread"
+ LDFLAGS="-pthread $LDFLAGS"
+ supported_os="freebsd"
+ ;;
+ osf5*)
+ CFLAGS="$CFLAGS -pthread -DOS_TRU64 -DDSO_DLFCN -D_XOPEN_SOURCE_EXTENDED"
+ LDFLAGS="$LDFLAGS -pthread"
+ ;;
+ hpux11*)
+ CFLAGS="$CFLAGS -pthread -DOS_HPUX -DDSO_DLFCN"
+ LDFLAGS="$LDFLAGS -pthread"
+ LIBS="$LIBS -lpthread"
+ ;;
+ *)
+ AC_MSG_RESULT([failed])
+ AC_MSG_ERROR([Unsupported operating system "$host_os"])
+ ;;
+ esac
+ case $host_cpu in
+ powerpc)
+ CFLAGS="$CFLAGS -DCPU=\\\"$host_cpu\\\""
+ HOST_CPU=$host_cpu;;
+ sparc*)
+ CFLAGS="$CFLAGS -DCPU=\\\"$host_cpu\\\""
+ HOST_CPU=$host_cpu;;
+ i?86)
+ CFLAGS="$CFLAGS -DCPU=\\\"i386\\\""
+ HOST_CPU=i386;;
+ x86_64)
+ CFLAGS="$CFLAGS -DCPU=\\\"amd64\\\""
+ HOST_CPU=amd64;;
+ bs2000)
+ CFLAGS="$CFLAGS -DCPU=\\\"osd\\\" -DCHARSET_EBCDIC -DOSD_POSIX"
+ supported_os="osd"
+ LDFLAGS="-Kno_link_stdlibs -B llm4"
+ LIBS="$LIBS -lBLSLIB"
+ LDCMD="/opt/C/bin/cc"
+ HOST_CPU=osd;;
+ mips)
+ CFLAGS="$CFLAGS -DCPU=\\\"mips\\\""
+ supported_os="mips"
+ HOST_CPU=mips;;
+ alpha*)
+ CFLAGS="$CFLAGS -DCPU=\\\"alpha\\\""
+ supported_os="alpha"
+ HOST_CPU=alpha;;
+ hppa2.0w)
+ CFLAGS="$CFLAGS -DCPU=\\\"PA_RISC2.0W\\\""
+ supported_os="hp-ux"
+ HOST_CPU=PA_RISC2.0W;;
+ hppa2.0)
+ CFLAGS="$CFLAGS -DCPU=\\\"PA_RISC2.0\\\""
+ supported_os="hp-ux"
+ HOST_CPU=PA_RISC2.0;;
+ mipsel)
+ CFLAGS="$CFLAGS -DCPU=\\\"mipsel\\\""
+ supported_os="mipsel"
+ HOST_CPU=mipsel;;
+ ia64)
+ CFLAGS="$CFLAGS -DCPU=\\\"ia64\\\""
+ supported_os="ia64"
+ HOST_CPU=ia64;;
+ s390)
+ CFLAGS="$CFLAGS -DCPU=\\\"s390\\\""
+ supported_os="s390"
+ HOST_CPU=s390;;
+ *)
+ AC_MSG_RESULT([failed])
+ AC_MSG_ERROR([Unsupported CPU architecture "$host_cpu"]);;
+ esac
+
+ AC_MSG_RESULT([ok])
+ AC_SUBST(CFLAGS)
+ AC_SUBST(LDFLAGS)
+])
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/buildconf.sh
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/buildconf.sh 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/buildconf.sh 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,33 @@
+#!/bin/sh
+#
+# Copyright 1999-2004 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# @author Pier Fumagalli <mailto:pier.fumagalli at eng.sun.com>
+# @version $Id: buildconf.sh 191365 2005-06-19 21:57:53Z billbarker $
+
+# The cache of automake always brings problems when changing *.m4 files.
+rm -rf autom4te.cache
+
+if test -f configure.in ; then
+ autoconf
+ if test $? -ne 0 ; then
+ echo "$0: cannot generate configure script"
+ else
+ echo "$0: configure script generated successfully"
+ fi
+else
+ echo "$0: cannot find source file configure.in"
+fi
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/buildconf.sh
___________________________________________________________________
Name: svn:executable
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/config.guess
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/config.guess 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/config.guess 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,1371 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+# Free Software Foundation, Inc.
+
+timestamp='2001-04-20'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Written by Per Bothner <bothner at cygnus.com>.
+# Please send patches to <config-patches at gnu.org>.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub. If it succeeds, it prints the system name on stdout, and
+# exits with 0. Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches at gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2000
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit 0 ;;
+ --version | -v )
+ echo "$version" ; exit 0 ;;
+ --help | --h* | -h )
+ echo "$usage"; exit 0 ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help" >&2
+ exit 1 ;;
+ * )
+ break ;;
+ esac
+done
+
+if test $# != 0; then
+ echo "$me: too many arguments$help" >&2
+ exit 1
+fi
+
+
+dummy=dummy-$$
+trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script.
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,) echo "int dummy(){}" > $dummy.c
+ for c in cc gcc c89 ; do
+ ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1
+ if test $? = 0 ; then
+ CC_FOR_BUILD="$c"; break
+ fi
+ done
+ rm -f $dummy.c $dummy.o $dummy.rel
+ if test x"$CC_FOR_BUILD" = x ; then
+ CC_FOR_BUILD=no_compiler_found
+ fi
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+esac
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi at noc.rutgers.edu 8/24/94.)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+ PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ *:NetBSD:*:*)
+ # Netbsd (nbsd) targets should (where applicable) match one or
+ # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
+ # switched to ELF, *-*-netbsd* would select the old
+ # object file format. This provides both forward
+ # compatibility and a consistent mechanism for selecting the
+ # object file format.
+ # Determine the machine/vendor (is the vendor relevant).
+ case "${UNAME_MACHINE}" in
+ amiga) machine=m68k-unknown ;;
+ arm32) machine=arm-unknown ;;
+ atari*) machine=m68k-atari ;;
+ sun3*) machine=m68k-sun ;;
+ mac68k) machine=m68k-apple ;;
+ macppc) machine=powerpc-apple ;;
+ hp3[0-9][05]) machine=m68k-hp ;;
+ ibmrt|romp-ibm) machine=romp-ibm ;;
+ *) machine=${UNAME_MACHINE}-unknown ;;
+ esac
+ # The Operating System including object format, if it has switched
+ # to ELF recently, or will in the future.
+ case "${UNAME_MACHINE}" in
+ i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k)
+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep __ELF__ >/dev/null
+ then
+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+ # Return netbsd for either. FIX?
+ os=netbsd
+ else
+ os=netbsdelf
+ fi
+ ;;
+ *)
+ os=netbsd
+ ;;
+ esac
+ # The OS release
+ release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+ # contains redundant information, the shorter form:
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ echo "${machine}-${os}${release}"
+ exit 0 ;;
+ alpha:OSF1:*:*)
+ if test $UNAME_RELEASE = "V4.0"; then
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ fi
+ # A Vn.n version is a released version.
+ # A Tn.n version is a released field test version.
+ # A Xn.n version is an unreleased experimental baselevel.
+ # 1.2 uses "1.2" for uname -r.
+ cat <<EOF >$dummy.s
+ .data
+\$Lformat:
+ .byte 37,100,45,37,120,10,0 # "%d-%x\n"
+
+ .text
+ .globl main
+ .align 4
+ .ent main
+main:
+ .frame \$30,16,\$26,0
+ ldgp \$29,0(\$27)
+ .prologue 1
+ .long 0x47e03d80 # implver \$0
+ lda \$2,-1
+ .long 0x47e20c21 # amask \$2,\$1
+ lda \$16,\$Lformat
+ mov \$0,\$17
+ not \$1,\$18
+ jsr \$26,printf
+ ldgp \$29,0(\$26)
+ mov 0,\$16
+ jsr \$26,exit
+ .end main
+EOF
+ $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
+ if test "$?" = 0 ; then
+ case `./$dummy` in
+ 0-0)
+ UNAME_MACHINE="alpha"
+ ;;
+ 1-0)
+ UNAME_MACHINE="alphaev5"
+ ;;
+ 1-1)
+ UNAME_MACHINE="alphaev56"
+ ;;
+ 1-101)
+ UNAME_MACHINE="alphapca56"
+ ;;
+ 2-303)
+ UNAME_MACHINE="alphaev6"
+ ;;
+ 2-307)
+ UNAME_MACHINE="alphaev67"
+ ;;
+ esac
+ fi
+ rm -f $dummy.s $dummy
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ exit 0 ;;
+ Alpha\ *:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # Should we change UNAME_MACHINE based on the output of uname instead
+ # of the specific Alpha model?
+ echo alpha-pc-interix
+ exit 0 ;;
+ 21064:Windows_NT:50:3)
+ echo alpha-dec-winnt3.5
+ exit 0 ;;
+ Amiga*:UNIX_System_V:4.0:*)
+ echo m68k-unknown-sysv4
+ exit 0;;
+ amiga:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-amigaos
+ exit 0 ;;
+ arc64:OpenBSD:*:*)
+ echo mips64el-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ arc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ hkmips:OpenBSD:*:*)
+ echo mips-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ pmax:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ sgi:OpenBSD:*:*)
+ echo mips-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ wgrisc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ *:OS/390:*:*)
+ echo i370-ibm-openedition
+ exit 0 ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ echo arm-acorn-riscix${UNAME_RELEASE}
+ exit 0;;
+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit 0;;
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+ # akee at wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+ if test "`(/bin/universe) 2>/dev/null`" = att ; then
+ echo pyramid-pyramid-sysv3
+ else
+ echo pyramid-pyramid-bsd
+ fi
+ exit 0 ;;
+ NILE*:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+ exit 0 ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+ echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ i86pc:SunOS:5.*:*)
+ echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:6*:*)
+ # According to config.sub, this is the proper way to canonicalize
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
+ # it's likely to be more like Solaris than SunOS4.
+ echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:*:*)
+ case "`/usr/bin/arch -k`" in
+ Series*|S4*)
+ UNAME_RELEASE=`uname -v`
+ ;;
+ esac
+ # Japanese Language versions have a version number like `4.1.3-JL'.
+ echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+ exit 0 ;;
+ sun3*:SunOS:*:*)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ exit 0 ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+ case "`/bin/arch`" in
+ sun3)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ ;;
+ sun4)
+ echo sparc-sun-sunos${UNAME_RELEASE}
+ ;;
+ esac
+ exit 0 ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos${UNAME_RELEASE}
+ exit 0 ;;
+ atari*:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ # The situation for MiNT is a little confusing. The machine name
+ # can be virtually everything (everything which is not
+ # "atarist" or "atariste" at least should have a processor
+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
+ # to the lowercase version "mint" (or "freemint"). Finally
+ # the system name "TOS" denotes a system which is actually not
+ # MiNT. But MiNT is downward compatible to TOS, so this should
+ # be no problem.
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ echo m68k-milan-mint${UNAME_RELEASE}
+ exit 0 ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ echo m68k-hades-mint${UNAME_RELEASE}
+ exit 0 ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ echo m68k-unknown-mint${UNAME_RELEASE}
+ exit 0 ;;
+ sun3*:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mac68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme88k:OpenBSD:*:*)
+ echo m88k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten${UNAME_RELEASE}
+ exit 0 ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+ exit 0 ;;
+ RISC*:ULTRIX:*:*)
+ echo mips-dec-ultrix${UNAME_RELEASE}
+ exit 0 ;;
+ VAX*:ULTRIX*:*:*)
+ echo vax-dec-ultrix${UNAME_RELEASE}
+ exit 0 ;;
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
+ exit 0 ;;
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ sed 's/^ //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+ #if defined (host_mips) && defined (MIPSEB)
+ #if defined (SYSTYPE_SYSV)
+ printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_SVR4)
+ printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+ printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+ #endif
+ #endif
+ exit (-1);
+ }
+EOF
+ $CC_FOR_BUILD $dummy.c -o $dummy \
+ && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+ && rm -f $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
+ echo mips-mips-riscos${UNAME_RELEASE}
+ exit 0 ;;
+ Motorola:PowerMAX_OS:*:*)
+ echo powerpc-motorola-powermax
+ exit 0 ;;
+ Night_Hawk:Power_UNIX:*:*)
+ echo powerpc-harris-powerunix
+ exit 0 ;;
+ m88k:CX/UX:7*:*)
+ echo m88k-harris-cxux7
+ exit 0 ;;
+ m88k:*:4*:R4*)
+ echo m88k-motorola-sysv4
+ exit 0 ;;
+ m88k:*:3*:R3*)
+ echo m88k-motorola-sysv3
+ exit 0 ;;
+ AViiON:dgux:*:*)
+ # DG/UX returns AViiON for all architectures
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+ then
+ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+ [ ${TARGET_BINARY_INTERFACE}x = x ]
+ then
+ echo m88k-dg-dgux${UNAME_RELEASE}
+ else
+ echo m88k-dg-dguxbcs${UNAME_RELEASE}
+ fi
+ else
+ echo i586-dg-dgux${UNAME_RELEASE}
+ fi
+ exit 0 ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ echo m88k-dolphin-sysv3
+ exit 0 ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ echo m88k-motorola-sysv3
+ exit 0 ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ echo m88k-tektronix-sysv3
+ exit 0 ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ echo m68k-tektronix-bsd
+ exit 0 ;;
+ *:IRIX*:*:*)
+ echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+ exit 0 ;;
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ i*86:AIX:*:*)
+ echo i386-ibm-aix
+ exit 0 ;;
+ ia64:AIX:*:*)
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+ exit 0 ;;
+ *:AIX:2:3)
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ sed 's/^ //' << EOF >$dummy.c
+ #include <sys/systemcfg.h>
+
+ main()
+ {
+ if (!__power_pc())
+ exit(1);
+ puts("powerpc-ibm-aix3.2.5");
+ exit(0);
+ }
+EOF
+ $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
+ echo rs6000-ibm-aix3.2.5
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+ echo rs6000-ibm-aix3.2.4
+ else
+ echo rs6000-ibm-aix3.2
+ fi
+ exit 0 ;;
+ *:AIX:*:[45])
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+ IBM_ARCH=rs6000
+ else
+ IBM_ARCH=powerpc
+ fi
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+ exit 0 ;;
+ *:AIX:*:*)
+ echo rs6000-ibm-aix
+ exit 0 ;;
+ ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+ echo romp-ibm-bsd4.4
+ exit 0 ;;
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
+ echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
+ exit 0 ;; # report: romp-ibm BSD 4.3
+ *:BOSX:*:*)
+ echo rs6000-bull-bosx
+ exit 0 ;;
+ DPX/2?00:B.O.S.:*:*)
+ echo m68k-bull-sysv3
+ exit 0 ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ echo m68k-hp-bsd
+ exit 0 ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ echo m68k-hp-bsd4.4
+ exit 0 ;;
+ 9000/[34678]??:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ case "${UNAME_MACHINE}" in
+ 9000/31? ) HP_ARCH=m68000 ;;
+ 9000/[34]?? ) HP_ARCH=m68k ;;
+ 9000/[678][0-9][0-9])
+ case "${HPUX_REV}" in
+ 11.[0-9][0-9])
+ if [ -x /usr/bin/getconf ]; then
+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+ case "${sc_cpu_version}" in
+ 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+ 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+ 532) # CPU_PA_RISC2_0
+ case "${sc_kernel_bits}" in
+ 32) HP_ARCH="hppa2.0n" ;;
+ 64) HP_ARCH="hppa2.0w" ;;
+ esac ;;
+ esac
+ fi ;;
+ esac
+ if [ "${HP_ARCH}" = "" ]; then
+ sed 's/^ //' << EOF >$dummy.c
+
+ #define _HPUX_SOURCE
+ #include <stdlib.h>
+ #include <unistd.h>
+
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy`
+ if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi
+ rm -f $dummy.c $dummy
+ fi ;;
+ esac
+ echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+ exit 0 ;;
+ ia64:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ia64-hp-hpux${HPUX_REV}
+ exit 0 ;;
+ 3050*:HI-UX:*:*)
+ sed 's/^ //' << EOF >$dummy.c
+ #include <unistd.h>
+ int
+ main ()
+ {
+ long cpu = sysconf (_SC_CPU_VERSION);
+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
+ results, however. */
+ if (CPU_IS_PA_RISC (cpu))
+ {
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+ default: puts ("hppa-hitachi-hiuxwe2"); break;
+ }
+ }
+ else if (CPU_IS_HP_MC68K (cpu))
+ puts ("m68k-hitachi-hiuxwe2");
+ else puts ("unknown-hitachi-hiuxwe2");
+ exit (0);
+ }
+EOF
+ $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
+ echo unknown-hitachi-hiuxwe2
+ exit 0 ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+ echo hppa1.1-hp-bsd
+ exit 0 ;;
+ 9000/8??:4.3bsd:*:*)
+ echo hppa1.0-hp-bsd
+ exit 0 ;;
+ *9??*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+ exit 0 ;;
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+ echo hppa1.1-hp-osf
+ exit 0 ;;
+ hp8??:OSF1:*:*)
+ echo hppa1.0-hp-osf
+ exit 0 ;;
+ i*86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo ${UNAME_MACHINE}-unknown-osf1mk
+ else
+ echo ${UNAME_MACHINE}-unknown-osf1
+ fi
+ exit 0 ;;
+ parisc*:Lites*:*:*)
+ echo hppa1.1-hp-lites
+ exit 0 ;;
+ hppa*:OpenBSD:*:*)
+ echo hppa-unknown-openbsd
+ exit 0 ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ echo c1-convex-bsd
+ exit 0 ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit 0 ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ echo c34-convex-bsd
+ exit 0 ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ echo c38-convex-bsd
+ exit 0 ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ echo c4-convex-bsd
+ exit 0 ;;
+ CRAY*X-MP:*:*:*)
+ echo xmp-cray-unicos
+ exit 0 ;;
+ CRAY*Y-MP:*:*:*)
+ echo ymp-cray-unicos${UNAME_RELEASE}
+ exit 0 ;;
+ CRAY*[A-Z]90:*:*:*)
+ echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
+ exit 0 ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY*T3D:*:*:*)
+ echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY*T3E:*:*:*)
+ echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY*SV1:*:*:*)
+ echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY-2:*:*:*)
+ echo cray2-cray-unicos
+ exit 0 ;;
+ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+ FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit 0 ;;
+ hp300:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+ echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ *:FreeBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ exit 0 ;;
+ *:OpenBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ exit 0 ;;
+ i*:CYGWIN*:*)
+ echo ${UNAME_MACHINE}-pc-cygwin
+ exit 0 ;;
+ i*:MINGW*:*)
+ echo ${UNAME_MACHINE}-pc-mingw32
+ exit 0 ;;
+ i*:PW*:*)
+ echo ${UNAME_MACHINE}-pc-pw32
+ exit 0 ;;
+ i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+ # UNAME_MACHINE based on the output of uname instead of i386?
+ echo i386-pc-interix
+ exit 0 ;;
+ i*:UWIN*:*)
+ echo ${UNAME_MACHINE}-pc-uwin
+ exit 0 ;;
+ p*:CYGWIN*:*)
+ echo powerpcle-unknown-cygwin
+ exit 0 ;;
+ prep*:SunOS:5.*:*)
+ echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ *:GNU:*:*)
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ exit 0 ;;
+ i*86:Minix:*:*)
+ echo ${UNAME_MACHINE}-pc-minix
+ exit 0 ;;
+ arm*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ ia64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux
+ exit 0 ;;
+ m68*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ mips:Linux:*:*)
+ cat >$dummy.c <<EOF
+#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
+int main (int argc, char *argv[]) {
+#else
+int main (argc, argv) int argc; char *argv[]; {
+#endif
+#ifdef __MIPSEB__
+ printf ("%s-unknown-linux-gnu\n", argv[1]);
+#endif
+#ifdef __MIPSEL__
+ printf ("%sel-unknown-linux-gnu\n", argv[1]);
+#endif
+ return 0;
+}
+EOF
+ $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
+ ;;
+ ppc:Linux:*:*)
+ # Determine Lib Version
+ cat >$dummy.c <<EOF
+#include <features.h>
+#if defined(__GLIBC__)
+extern char __libc_version[];
+extern char __libc_release[];
+#endif
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+#if defined(__GLIBC__)
+ printf("%s %s\n", __libc_version, __libc_release);
+#else
+ printf("unknown\n");
+#endif
+ return 0;
+}
+EOF
+ LIBC=""
+ $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null
+ if test "$?" = 0 ; then
+ ./$dummy | grep 1\.99 > /dev/null
+ if test "$?" = 0 ; then LIBC="libc1" ; fi
+ fi
+ rm -f $dummy.c $dummy
+ echo powerpc-unknown-linux-gnu${LIBC}
+ exit 0 ;;
+ alpha:Linux:*:*)
+ cat <<EOF >$dummy.s
+ .data
+ \$Lformat:
+ .byte 37,100,45,37,120,10,0 # "%d-%x\n"
+ .text
+ .globl main
+ .align 4
+ .ent main
+ main:
+ .frame \$30,16,\$26,0
+ ldgp \$29,0(\$27)
+ .prologue 1
+ .long 0x47e03d80 # implver \$0
+ lda \$2,-1
+ .long 0x47e20c21 # amask \$2,\$1
+ lda \$16,\$Lformat
+ mov \$0,\$17
+ not \$1,\$18
+ jsr \$26,printf
+ ldgp \$29,0(\$26)
+ mov 0,\$16
+ jsr \$26,exit
+ .end main
+EOF
+ LIBC=""
+ $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
+ if test "$?" = 0 ; then
+ case `./$dummy` in
+ 0-0) UNAME_MACHINE="alpha" ;;
+ 1-0) UNAME_MACHINE="alphaev5" ;;
+ 1-1) UNAME_MACHINE="alphaev56" ;;
+ 1-101) UNAME_MACHINE="alphapca56" ;;
+ 2-303) UNAME_MACHINE="alphaev6" ;;
+ 2-307) UNAME_MACHINE="alphaev67" ;;
+ esac
+ objdump --private-headers $dummy | \
+ grep ld.so.1 > /dev/null
+ if test "$?" = 0 ; then
+ LIBC="libc1"
+ fi
+ fi
+ rm -f $dummy.s $dummy
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+ exit 0 ;;
+ parisc:Linux:*:* | hppa:Linux:*:*)
+ # Look for CPU level
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+ PA7*) echo hppa1.1-unknown-linux-gnu ;;
+ PA8*) echo hppa2.0-unknown-linux-gnu ;;
+ *) echo hppa-unknown-linux-gnu ;;
+ esac
+ exit 0 ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ echo hppa64-unknown-linux-gnu
+ exit 0 ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ echo ${UNAME_MACHINE}-ibm-linux
+ exit 0 ;;
+ sh*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ x86_64:Linux:*:*)
+ echo x86_64-unknown-linux-gnu
+ exit 0 ;;
+ i*86:Linux:*:*)
+ # The BFD linker knows what the default object file format is, so
+ # first see if it will tell us. cd to the root directory to prevent
+ # problems with other programs or directories called `ld' in the path.
+ ld_supported_emulations=`cd /; ld --help 2>&1 \
+ | sed -ne '/supported emulations:/!d
+ s/[ ][ ]*/ /g
+ s/.*supported emulations: *//
+ s/ .*//
+ p'`
+ case "$ld_supported_emulations" in
+ i*86linux)
+ echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+ exit 0
+ ;;
+ elf_i*86)
+ TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+ ;;
+ i*86coff)
+ echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+ exit 0
+ ;;
+ esac
+ # Either a pre-BFD a.out linker (linux-gnuoldld)
+ # or one that does not give us useful --help.
+ # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
+ # If ld does not provide *any* "supported emulations:"
+ # that means it is gnuoldld.
+ test -z "$ld_supported_emulations" && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
+ case "${UNAME_MACHINE}" in
+ i*86)
+ VENDOR=pc;
+ ;;
+ *)
+ VENDOR=unknown;
+ ;;
+ esac
+ # Determine whether the default compiler is a.out or elf
+ cat >$dummy.c <<EOF
+#include <features.h>
+#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+#ifdef __ELF__
+# ifdef __GLIBC__
+# if __GLIBC__ >= 2
+ printf ("%s-${VENDOR}-linux-gnu\n", argv[1]);
+# else
+ printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
+# endif
+# else
+ printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
+# endif
+#else
+ printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]);
+#endif
+ return 0;
+}
+EOF
+ $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
+ test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
+ ;;
+# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions
+# are messed up and put the nodename in both sysname and nodename.
+ i*86:DYNIX/ptx:4*:*)
+ echo i386-sequent-sysv4
+ exit 0 ;;
+ i*86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+ exit 0 ;;
+ i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+ UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+ echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+ fi
+ exit 0 ;;
+ i*86:*:5:7*)
+ # Fixed at (any) Pentium or better
+ UNAME_MACHINE=i586
+ if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then
+ echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION}
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
+ fi
+ exit 0 ;;
+ i*86:*:3.2:*)
+ if test -f /usr/options/cb.name; then
+ UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+ echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+ elif /bin/uname -X 2>/dev/null >/dev/null ; then
+ UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+ (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
+ echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+ else
+ echo ${UNAME_MACHINE}-pc-sysv32
+ fi
+ exit 0 ;;
+ i*86:*DOS:*:*)
+ echo ${UNAME_MACHINE}-pc-msdosdjgpp
+ exit 0 ;;
+ pc:*:*:*)
+ # Left here for compatibility:
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i386.
+ echo i386-pc-msdosdjgpp
+ exit 0 ;;
+ Intel:Mach:3*:*)
+ echo i386-pc-mach3
+ exit 0 ;;
+ paragon:*:*:*)
+ echo i860-intel-osf1
+ exit 0 ;;
+ i860:*:4.*:*) # i860-SVR4
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+ echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+ else # Add other i860-SVR4 vendors below as they are discovered.
+ echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
+ fi
+ exit 0 ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ echo m68010-convergent-sysv
+ exit 0 ;;
+ M68*:*:R3V[567]*:*)
+ test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
+ 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
+ OS_REL=''
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && echo i486-ncr-sysv4.3${OS_REL} && exit 0
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && echo i486-ncr-sysv4 && exit 0 ;;
+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+ echo m68k-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ mc68030:UNIX_System_V:4.*:*)
+ echo m68k-atari-sysv4
+ exit 0 ;;
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ rs6000:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+ echo powerpc-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv${UNAME_RELEASE}
+ exit 0 ;;
+ RM*:ReliantUNIX-*:*:*)
+ echo mips-sni-sysv4
+ exit 0 ;;
+ RM*:SINIX-*:*:*)
+ echo mips-sni-sysv4
+ exit 0 ;;
+ *:SINIX-*:*:*)
+ if uname -p 2>/dev/null >/dev/null ; then
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ echo ${UNAME_MACHINE}-sni-sysv4
+ else
+ echo ns32k-sni-sysv
+ fi
+ exit 0 ;;
+ PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel at ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+ exit 0 ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes <hewes at openmarket.com>.
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+ exit 0 ;;
+ *:*:*:FTX*)
+ # From seanf at swdc.stratus.com.
+ echo i860-stratus-sysv4
+ exit 0 ;;
+ mc68*:A/UX:*:*)
+ echo m68k-apple-aux${UNAME_RELEASE}
+ exit 0 ;;
+ news*:NEWS-OS:6*:*)
+ echo mips-sony-newsos6
+ exit 0 ;;
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+ if [ -d /usr/nec ]; then
+ echo mips-nec-sysv${UNAME_RELEASE}
+ else
+ echo mips-unknown-sysv${UNAME_RELEASE}
+ fi
+ exit 0 ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+ exit 0 ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+ exit 0 ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+ exit 0 ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux${UNAME_RELEASE}
+ exit 0 ;;
+ SX-5:SUPER-UX:*:*)
+ echo sx5-nec-superux${UNAME_RELEASE}
+ exit 0 ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody${UNAME_RELEASE}
+ exit 0 ;;
+ *:Rhapsody:*:*)
+ echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+ exit 0 ;;
+ *:Darwin:*:*)
+ echo `uname -p`-apple-darwin${UNAME_RELEASE}
+ exit 0 ;;
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
+ if test "${UNAME_MACHINE}" = "x86pc"; then
+ UNAME_MACHINE=pc
+ fi
+ echo `uname -p`-${UNAME_MACHINE}-nto-qnx
+ exit 0 ;;
+ *:QNX:*:4*)
+ echo i386-pc-qnx
+ exit 0 ;;
+ NSR-[KW]:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk${UNAME_RELEASE}
+ exit 0 ;;
+ *:NonStop-UX:*:*)
+ echo mips-compaq-nonstopux
+ exit 0 ;;
+ BS2000:POSIX*:*:*)
+ echo bs2000-siemens-sysv
+ exit 0 ;;
+ DS/*:UNIX_System_V:*:*)
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+ exit 0 ;;
+ *:Plan9:*:*)
+ # "uname -m" is not consistent, so use $cputype instead. 386
+ # is converted to i386 for consistency with other x86
+ # operating systems.
+ if test "$cputype" = "386"; then
+ UNAME_MACHINE=i386
+ else
+ UNAME_MACHINE="$cputype"
+ fi
+ echo ${UNAME_MACHINE}-unknown-plan9
+ exit 0 ;;
+ i*86:OS/2:*:*)
+ # If we were able to find `uname', then EMX Unix compatibility
+ # is probably installed.
+ echo ${UNAME_MACHINE}-pc-os2-emx
+ exit 0 ;;
+ *:TOPS-10:*:*)
+ echo pdp10-unknown-tops10
+ exit 0 ;;
+ *:TENEX:*:*)
+ echo pdp10-unknown-tenex
+ exit 0 ;;
+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+ echo pdp10-dec-tops20
+ exit 0 ;;
+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+ echo pdp10-xkl-tops20
+ exit 0 ;;
+ *:TOPS-20:*:*)
+ echo pdp10-unknown-tops20
+ exit 0 ;;
+ *:ITS:*:*)
+ echo pdp10-unknown-its
+ exit 0 ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
+ I don't know.... */
+ printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+ printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+ "4"
+#else
+ ""
+#endif
+ ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+ printf ("arm-acorn-riscix"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+ printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+ int version;
+ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+ if (version < 4)
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ else
+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+ exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+ printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+ printf ("ns32k-encore-mach\n"); exit (0);
+#else
+ printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+ printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+ printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+ printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+ struct utsname un;
+
+ uname(&un);
+
+ if (strncmp(un.version, "V2", 2) == 0) {
+ printf ("i386-sequent-ptx2\n"); exit (0);
+ }
+ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+ printf ("i386-sequent-ptx1\n"); exit (0);
+ }
+ printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+# include <sys/param.h>
+# if defined (BSD)
+# if BSD == 43
+ printf ("vax-dec-bsd4.3\n"); exit (0);
+# else
+# if BSD == 199006
+ printf ("vax-dec-bsd4.3reno\n"); exit (0);
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# endif
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# else
+ printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+ printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+ exit (1);
+}
+EOF
+
+$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0
+rm -f $dummy.c $dummy
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+ case `getsysinfo -f cpu_type` in
+ c1*)
+ echo c1-convex-bsd
+ exit 0 ;;
+ c2*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit 0 ;;
+ c34*)
+ echo c34-convex-bsd
+ exit 0 ;;
+ c38*)
+ echo c38-convex-bsd
+ exit 0 ;;
+ c4*)
+ echo c4-convex-bsd
+ exit 0 ;;
+ esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+ ftp://ftp.gnu.org/pub/gnu/config/
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches at gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo = `(hostinfo) 2>/dev/null`
+/bin/universe = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/config.guess
___________________________________________________________________
Name: svn:executable
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/config.sub
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/config.sub 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/config.sub 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,1362 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+# Free Software Foundation, Inc.
+
+timestamp='2001-05-11'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine. It does not imply ALL GNU software can.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Please send patches to <config-patches at gnu.org>.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support. The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+ $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches at gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit 0 ;;
+ --version | -v )
+ echo "$version" ; exit 0 ;;
+ --help | --h* | -h )
+ echo "$usage"; exit 0 ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help"
+ exit 1 ;;
+
+ *local*)
+ # First pass through any local machine types.
+ echo $1
+ exit 0;;
+
+ * )
+ break ;;
+ esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+ exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+ exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+ nto-qnx* | linux-gnu* | storm-chaos* | os2-emx*)
+ os=-$maybe_os
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ ;;
+ *)
+ basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+ if [ $basic_machine != $1 ]
+ then os=`echo $1 | sed 's/.*-/-/'`
+ else os=; fi
+ ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work. We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+ -sun*os*)
+ # Prevent following clause from handling this invalid input.
+ ;;
+ -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+ -apple | -axis)
+ os=
+ basic_machine=$1
+ ;;
+ -sim | -cisco | -oki | -wec | -winbond)
+ os=
+ basic_machine=$1
+ ;;
+ -scout)
+ ;;
+ -wrs)
+ os=-vxworks
+ basic_machine=$1
+ ;;
+ -hiux*)
+ os=-hiuxwe2
+ ;;
+ -sco5)
+ os=-sco3.2v5
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco4)
+ os=-sco3.2v4
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2.[4-9]*)
+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2v[4-9]*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco*)
+ os=-sco3.2v2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -udk*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -isc)
+ os=-isc2.2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -clix*)
+ basic_machine=clipper-intergraph
+ ;;
+ -isc*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -lynx*)
+ os=-lynxos
+ ;;
+ -ptx*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+ ;;
+ -windowsnt*)
+ os=`echo $os | sed -e 's/windowsnt/winnt/'`
+ ;;
+ -psos*)
+ os=-psos
+ ;;
+ -mint | -mint[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+ # Recognize the basic CPU types without company name.
+ # Some are omitted here because they have special meanings below.
+ tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc \
+ | arm | arme[lb] | arm[bl]e | armv[2345] | armv[345][lb] | strongarm | xscale \
+ | pyramid | mn10200 | mn10300 | tron | a29k \
+ | 580 | i960 | h8300 \
+ | x86 | ppcbe | mipsbe | mipsle | shbe | shle \
+ | hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \
+ | hppa64 \
+ | alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \
+ | alphaev6[78] \
+ | we32k | ns16k | clipper | i370 | sh | sh[34] \
+ | powerpc | powerpcle \
+ | 1750a | dsp16xx | pdp10 | pdp11 \
+ | mips16 | mips64 | mipsel | mips64el \
+ | mips64orion | mips64orionel | mipstx39 | mipstx39el \
+ | mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \
+ | mips64vr5000 | miprs64vr5000el | mcore | s390 | s390x \
+ | sparc | sparclet | sparclite | sparc64 | sparcv9 | sparcv9b \
+ | v850 | c4x \
+ | thumb | d10v | d30v | fr30 | avr | openrisc | tic80 \
+ | pj | pjl | h8500 | z8k)
+ basic_machine=$basic_machine-unknown
+ ;;
+ m6811 | m68hc11 | m6812 | m68hc12)
+ # Motorola 68HC11/12.
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | w65 | z8k)
+ ;;
+
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i*86 | x86_64)
+ basic_machine=$basic_machine-pc
+ ;;
+ # Object if more than one company name word.
+ *-*-*)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+ # Recognize the basic CPU types with company name.
+ # FIXME: clean up the formatting here.
+ vax-* | tahoe-* | i*86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
+ | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | c[123]* \
+ | arm-* | armbe-* | armle-* | armv*-* | strongarm-* | xscale-* \
+ | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
+ | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \
+ | xmp-* | ymp-* \
+ | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* \
+ | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \
+ | hppa2.0n-* | hppa64-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \
+ | alphaev6[78]-* \
+ | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \
+ | clipper-* | orion-* \
+ | sparclite-* | pdp10-* | pdp11-* | sh-* | sh[34]-* | sh[34]eb-* \
+ | powerpc-* | powerpcle-* | sparc64-* | sparcv9-* | sparcv9b-* | sparc86x-* \
+ | mips16-* | mips64-* | mipsel-* \
+ | mips64el-* | mips64orion-* | mips64orionel-* \
+ | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \
+ | mipstx39-* | mipstx39el-* | mcore-* \
+ | f30[01]-* | f700-* | s390-* | s390x-* | sv1-* | t3e-* \
+ | [cjt]90-* \
+ | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
+ | thumb-* | v850-* | d30v-* | tic30-* | tic80-* | c30-* | fr30-* \
+ | bs2000-* | tic54x-* | c54x-* | x86_64-* | pj-* | pjl-*)
+ ;;
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 386bsd)
+ basic_machine=i386-unknown
+ os=-bsd
+ ;;
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ basic_machine=m68000-att
+ ;;
+ 3b*)
+ basic_machine=we32k-att
+ ;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=-scout
+ ;;
+ alliant | fx80)
+ basic_machine=fx80-alliant
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=-bsd
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=-sysv
+ ;;
+ amiga | amiga-*)
+ basic_machine=m68k-unknown
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-unknown
+ os=-amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-unknown
+ os=-sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=-sysv
+ ;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=-bsd
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ os=-aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=-dynix
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=-bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=-bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=-bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=-bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=-bsd
+ ;;
+ cray | ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
+ cray2)
+ basic_machine=cray2-cray
+ os=-unicos
+ ;;
+ [cjt]90)
+ basic_machine=${basic_machine}-cray
+ os=-unicos
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+ cris | cris-* | etrax*)
+ basic_machine=cris-axis
+ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+ decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ ;;
+ delta | 3300 | motorola-3300 | motorola-delta \
+ | 3300-motorola | delta-motorola)
+ basic_machine=m68k-motorola
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=-sysv3
+ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
+ ;;
+ dpx2* | dpx2*-bull)
+ basic_machine=m68k-bull
+ os=-sysv3
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=-ebmon
+ ;;
+ elxsi)
+ basic_machine=elxsi-elxsi
+ os=-bsd
+ ;;
+ encore | umax | mmax)
+ basic_machine=ns32k-encore
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=-ose
+ ;;
+ fx2800)
+ basic_machine=i860-alliant
+ ;;
+ genix)
+ basic_machine=ns32k-ns
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=-sysv
+ ;;
+ go32)
+ basic_machine=i386-pc
+ os=-go32
+ ;;
+ h3050r* | hiux*)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=-hms
+ ;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=-xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=-hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=-sysv3
+ ;;
+ hp300-*)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=-bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=-hpux
+ ;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ basic_machine=m68000-hp
+ ;;
+ hp9k3[2-9][0-9])
+ basic_machine=m68k-hp
+ ;;
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hppa-next)
+ os=-nextstep3
+ ;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=-osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=-proelf
+ ;;
+ i370-ibm* | ibm*)
+ basic_machine=i370-ibm
+ ;;
+# I'm not sure what "Sysv32" means. Should this be sysv3.2?
+ i*86v32)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv32
+ ;;
+ i*86v4*)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv4
+ ;;
+ i*86v)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv
+ ;;
+ i*86sol2)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-solaris2
+ ;;
+ i386mach)
+ basic_machine=i386-mach
+ os=-mach
+ ;;
+ i386-vsta | vsta)
+ basic_machine=i386-unknown
+ os=-vsta
+ ;;
+ iris | iris4d)
+ basic_machine=mips-sgi
+ case $os in
+ -irix*)
+ ;;
+ *)
+ os=-irix4
+ ;;
+ esac
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=-sysv
+ ;;
+ m88k-omron*)
+ basic_machine=m88k-omron
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=-sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=-sysv
+ ;;
+ mingw32)
+ basic_machine=i386-pc
+ os=-mingw32
+ ;;
+ miniframe)
+ basic_machine=m68000-convergent
+ ;;
+ *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+ mipsel*-linux*)
+ basic_machine=mipsel-unknown
+ os=-linux-gnu
+ ;;
+ mips*-linux*)
+ basic_machine=mips-unknown
+ os=-linux-gnu
+ ;;
+ mips3*-*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+ ;;
+ mips3*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ ;;
+ mmix*)
+ basic_machine=mmix-knuth
+ os=-mmixware
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ msdos)
+ basic_machine=i386-pc
+ os=-msdos
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=-sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-unknown
+ os=-netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ os=-linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=-newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=-newsos
+ ;;
+ news-3600 | risc-news)
+ basic_machine=mips-sony
+ os=-newsos
+ ;;
+ necv70)
+ basic_machine=v70-nec
+ os=-sysv
+ ;;
+ next | m*-next )
+ basic_machine=m68k-next
+ case $os in
+ -nextstep* )
+ ;;
+ -ns2*)
+ os=-nextstep2
+ ;;
+ *)
+ os=-nextstep3
+ ;;
+ esac
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=-cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=-cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=-nindy
+ ;;
+ mon960)
+ basic_machine=i960-intel
+ os=-mon960
+ ;;
+ nonstopux)
+ basic_machine=mips-compaq
+ os=-nonstopux
+ ;;
+ np1)
+ basic_machine=np1-gould
+ ;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
+ op50n-* | op60c-*)
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=-ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=-os68k
+ ;;
+ pa-hitachi)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=-osf
+ ;;
+ pbd)
+ basic_machine=sparc-tti
+ ;;
+ pbb)
+ basic_machine=m68k-tti
+ ;;
+ pc532 | pc532-*)
+ basic_machine=ns32k-pc532
+ ;;
+ pentium | p5 | k5 | k6 | nexgen)
+ basic_machine=i586-pc
+ ;;
+ pentiumpro | p6 | 6x86 | athlon)
+ basic_machine=i686-pc
+ ;;
+ pentiumii | pentium2)
+ basic_machine=i686-pc
+ ;;
+ pentium-* | p5-* | k5-* | k6-* | nexgen-*)
+ basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumpro-* | p6-* | 6x86-* | athlon-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumii-* | pentium2-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pn)
+ basic_machine=pn-gould
+ ;;
+ power) basic_machine=power-ibm
+ ;;
+ ppc) basic_machine=powerpc-unknown
+ ;;
+ ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppcle | powerpclittle | ppc-le | powerpc-little)
+ basic_machine=powerpcle-unknown
+ ;;
+ ppcle-* | powerpclittle-*)
+ basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ps2)
+ basic_machine=i386-ibm
+ ;;
+ pw32)
+ basic_machine=i586-unknown
+ os=-pw32
+ ;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ rm[46]00)
+ basic_machine=mips-siemens
+ ;;
+ rtpc | rtpc-*)
+ basic_machine=romp-ibm
+ ;;
+ sa29200)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ ;;
+ sh)
+ basic_machine=sh-hitachi
+ os=-hms
+ ;;
+ sparclite-wrs)
+ basic_machine=sparclite-wrs
+ os=-vxworks
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ os=-sysv2
+ ;;
+ spur)
+ basic_machine=spur-unknown
+ ;;
+ st2000)
+ basic_machine=m68k-tandem
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ os=-sysv4
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ os=-sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ os=-sunos4
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ os=-sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ os=-sunos4
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ os=-sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ os=-sunos4
+ ;;
+ sun4sol2)
+ basic_machine=sparc-sun
+ os=-solaris2
+ ;;
+ sun3 | sun3-*)
+ basic_machine=m68k-sun
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ ;;
+ sv1)
+ basic_machine=sv1-cray
+ os=-unicos
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ os=-dynix
+ ;;
+ t3e)
+ basic_machine=t3e-cray
+ os=-unicos
+ ;;
+ tic54x | c54x*)
+ basic_machine=tic54x-unknown
+ os=-coff
+ ;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
+ tower | tower-32)
+ basic_machine=m68k-ncr
+ ;;
+ udi29k)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ os=-sym1
+ ;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=-none
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ os=-sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ os=-vms
+ ;;
+ vpp*|vx|vx-*)
+ basic_machine=f301-fujitsu
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ os=-vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=-vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ os=-vxworks
+ ;;
+ w65*)
+ basic_machine=w65-wdc
+ os=-none
+ ;;
+ w89k-*)
+ basic_machine=hppa1.1-winbond
+ os=-proelf
+ ;;
+ xmp)
+ basic_machine=xmp-cray
+ os=-unicos
+ ;;
+ xps | xps100)
+ basic_machine=xps100-honeywell
+ ;;
+ z8k-*-coff)
+ basic_machine=z8k-unknown
+ os=-sim
+ ;;
+ none)
+ basic_machine=none-none
+ os=-none
+ ;;
+
+# Here we handle the default manufacturer of certain CPU types. It is in
+# some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ basic_machine=hppa1.1-winbond
+ ;;
+ op50n)
+ basic_machine=hppa1.1-oki
+ ;;
+ op60c)
+ basic_machine=hppa1.1-oki
+ ;;
+ mips)
+ if [ x$os = x-linux-gnu ]; then
+ basic_machine=mips-unknown
+ else
+ basic_machine=mips-mips
+ fi
+ ;;
+ romp)
+ basic_machine=romp-ibm
+ ;;
+ rs6000)
+ basic_machine=rs6000-ibm
+ ;;
+ vax)
+ basic_machine=vax-dec
+ ;;
+ pdp10)
+ # there are many clones, so DEC is not a safe bet
+ basic_machine=pdp10-unknown
+ ;;
+ pdp11)
+ basic_machine=pdp11-dec
+ ;;
+ we32k)
+ basic_machine=we32k-att
+ ;;
+ sh3 | sh4)
+ basic_machine=sh-unknown
+ ;;
+ sparc | sparcv9 | sparcv9b)
+ basic_machine=sparc-sun
+ ;;
+ cydra)
+ basic_machine=cydra-cydrome
+ ;;
+ orion)
+ basic_machine=orion-highlevel
+ ;;
+ orion105)
+ basic_machine=clipper-highlevel
+ ;;
+ mac | mpw | mac-mpw)
+ basic_machine=m68k-apple
+ ;;
+ pmac | pmac-mpw)
+ basic_machine=powerpc-apple
+ ;;
+ c4x*)
+ basic_machine=c4x-none
+ os=-coff
+ ;;
+ *-unknown)
+ # Make sure to match an already-canonicalized machine name.
+ ;;
+ *)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+ *-digital*)
+ basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+ ;;
+ *-commodore*)
+ basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+ ;;
+ *)
+ ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+ # First match some system type aliases
+ # that might get confused with valid system types.
+ # -solaris* is a basic system type, with this one exception.
+ -solaris1 | -solaris1.*)
+ os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ ;;
+ -solaris)
+ os=-solaris2
+ ;;
+ -svr4*)
+ os=-sysv4
+ ;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
+ -gnu/linux*)
+ os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+ ;;
+ # First accept the basic system types.
+ # The portable systems comes first.
+ # Each alternative MUST END IN A *, to match a version number.
+ # -sysv* is not here because it comes later, after sysvr4.
+ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
+ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* | -os2*)
+ # Remember, each alternative MUST END IN *, to match a version number.
+ ;;
+ -qnx*)
+ case $basic_machine in
+ x86-* | i*86-*)
+ ;;
+ *)
+ os=-nto$os
+ ;;
+ esac
+ ;;
+ -nto*)
+ os=-nto-qnx
+ ;;
+ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+ ;;
+ -mac*)
+ os=`echo $os | sed -e 's|mac|macos|'`
+ ;;
+ -linux*)
+ os=`echo $os | sed -e 's|linux|linux-gnu|'`
+ ;;
+ -sunos5*)
+ os=`echo $os | sed -e 's|sunos5|solaris2|'`
+ ;;
+ -sunos6*)
+ os=`echo $os | sed -e 's|sunos6|solaris3|'`
+ ;;
+ -opened*)
+ os=-openedition
+ ;;
+ -wince*)
+ os=-wince
+ ;;
+ -osfrose*)
+ os=-osfrose
+ ;;
+ -osf*)
+ os=-osf
+ ;;
+ -utek*)
+ os=-bsd
+ ;;
+ -dynix*)
+ os=-bsd
+ ;;
+ -acis*)
+ os=-aos
+ ;;
+ -386bsd)
+ os=-bsd
+ ;;
+ -ctix* | -uts*)
+ os=-sysv
+ ;;
+ -ns2 )
+ os=-nextstep2
+ ;;
+ -nsk*)
+ os=-nsk
+ ;;
+ # Preserve the version number of sinix5.
+ -sinix5.*)
+ os=`echo $os | sed -e 's|sinix|sysv|'`
+ ;;
+ -sinix*)
+ os=-sysv4
+ ;;
+ -triton*)
+ os=-sysv3
+ ;;
+ -oss*)
+ os=-sysv3
+ ;;
+ -svr4)
+ os=-sysv4
+ ;;
+ -svr3)
+ os=-sysv3
+ ;;
+ -sysvr4)
+ os=-sysv4
+ ;;
+ # This must come after -sysvr4.
+ -sysv*)
+ ;;
+ -ose*)
+ os=-ose
+ ;;
+ -es1800*)
+ os=-ose
+ ;;
+ -xenix)
+ os=-xenix
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ os=-mint
+ ;;
+ -none)
+ ;;
+ *)
+ # Get rid of the `-' at the beginning of $os.
+ os=`echo $os | sed 's/[^-]*-//'`
+ echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system. Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+ *-acorn)
+ os=-riscix1.2
+ ;;
+ arm*-rebel)
+ os=-linux
+ ;;
+ arm*-semi)
+ os=-aout
+ ;;
+ pdp10-*)
+ os=-tops20
+ ;;
+ pdp11-*)
+ os=-none
+ ;;
+ *-dec | vax-*)
+ os=-ultrix4.2
+ ;;
+ m68*-apollo)
+ os=-domain
+ ;;
+ i386-sun)
+ os=-sunos4.0.2
+ ;;
+ m68000-sun)
+ os=-sunos3
+ # This also exists in the configure program, but was not the
+ # default.
+ # os=-sunos4
+ ;;
+ m68*-cisco)
+ os=-aout
+ ;;
+ mips*-cisco)
+ os=-elf
+ ;;
+ mips*-*)
+ os=-elf
+ ;;
+ *-tti) # must be before sparc entry or we get the wrong os.
+ os=-sysv3
+ ;;
+ sparc-* | *-sun)
+ os=-sunos4.1.1
+ ;;
+ *-be)
+ os=-beos
+ ;;
+ *-ibm)
+ os=-aix
+ ;;
+ *-wec)
+ os=-proelf
+ ;;
+ *-winbond)
+ os=-proelf
+ ;;
+ *-oki)
+ os=-proelf
+ ;;
+ *-hp)
+ os=-hpux
+ ;;
+ *-hitachi)
+ os=-hiux
+ ;;
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+ os=-sysv
+ ;;
+ *-cbm)
+ os=-amigaos
+ ;;
+ *-dg)
+ os=-dgux
+ ;;
+ *-dolphin)
+ os=-sysv3
+ ;;
+ m68k-ccur)
+ os=-rtu
+ ;;
+ m88k-omron*)
+ os=-luna
+ ;;
+ *-next )
+ os=-nextstep
+ ;;
+ *-sequent)
+ os=-ptx
+ ;;
+ *-crds)
+ os=-unos
+ ;;
+ *-ns)
+ os=-genix
+ ;;
+ i370-*)
+ os=-mvs
+ ;;
+ *-next)
+ os=-nextstep3
+ ;;
+ *-gould)
+ os=-sysv
+ ;;
+ *-highlevel)
+ os=-bsd
+ ;;
+ *-encore)
+ os=-bsd
+ ;;
+ *-sgi)
+ os=-irix
+ ;;
+ *-siemens)
+ os=-sysv4
+ ;;
+ *-masscomp)
+ os=-rtu
+ ;;
+ f30[01]-fujitsu | f700-fujitsu)
+ os=-uxpv
+ ;;
+ *-rom68k)
+ os=-coff
+ ;;
+ *-*bug)
+ os=-coff
+ ;;
+ *-apple)
+ os=-macos
+ ;;
+ *-atari*)
+ os=-mint
+ ;;
+ *)
+ os=-none
+ ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer. We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+ *-unknown)
+ case $os in
+ -riscix*)
+ vendor=acorn
+ ;;
+ -sunos*)
+ vendor=sun
+ ;;
+ -aix*)
+ vendor=ibm
+ ;;
+ -beos*)
+ vendor=be
+ ;;
+ -hpux*)
+ vendor=hp
+ ;;
+ -mpeix*)
+ vendor=hp
+ ;;
+ -hiux*)
+ vendor=hitachi
+ ;;
+ -unos*)
+ vendor=crds
+ ;;
+ -dgux*)
+ vendor=dg
+ ;;
+ -luna*)
+ vendor=omron
+ ;;
+ -genix*)
+ vendor=ns
+ ;;
+ -mvs* | -opened*)
+ vendor=ibm
+ ;;
+ -ptx*)
+ vendor=sequent
+ ;;
+ -vxsim* | -vxworks*)
+ vendor=wrs
+ ;;
+ -aux*)
+ vendor=apple
+ ;;
+ -hms*)
+ vendor=hitachi
+ ;;
+ -mpw* | -macos*)
+ vendor=apple
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ vendor=atari
+ ;;
+ esac
+ basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+ ;;
+esac
+
+echo $basic_machine$os
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/config.sub
___________________________________________________________________
Name: svn:executable
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/install.sh
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/install.sh 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/install.sh 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,127 @@
+#!/bin/sh
+#
+# Copyright 1999-2004 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+##
+## install.sh -- install a program, script or datafile
+##
+## Based on `install-sh' from the X Consortium's X11R5 distribution
+## as of 89/12/18 which is freely available.
+## Cleaned up for Apache's Autoconf-style Interface (APACI)
+## by Ralf S. Engelschall <rse at apache.org>
+##
+#
+# This script falls under the Apache License.
+# See http://www.apache.org/docs/LICENSE
+
+
+#
+# put in absolute paths if you don't have them in your path;
+# or use env. vars.
+#
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+
+#
+# parse argument line
+#
+instcmd="$mvprog"
+chmodcmd=""
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+ext=""
+src=""
+dst=""
+while [ "x$1" != "x" ]; do
+ case $1 in
+ -c) instcmd="$cpprog"
+ shift; continue
+ ;;
+ -m) chmodcmd="$chmodprog $2"
+ shift; shift; continue
+ ;;
+ -o) chowncmd="$chownprog $2"
+ shift; shift; continue
+ ;;
+ -g) chgrpcmd="$chgrpprog $2"
+ shift; shift; continue
+ ;;
+ -s) stripcmd="$stripprog"
+ shift; continue
+ ;;
+ -S) stripcmd="$stripprog $2"
+ shift; shift; continue
+ ;;
+ -e) ext="$2"
+ shift; shift; continue
+ ;;
+ *) if [ "x$src" = "x" ]; then
+ src=$1
+ else
+ dst=$1
+ fi
+ shift; continue
+ ;;
+ esac
+done
+if [ "x$src" = "x" ]; then
+ echo "install.sh: no input file specified"
+ exit 1
+fi
+if [ "x$dst" = "x" ]; then
+ echo "install.sh: no destination specified"
+ exit 1
+fi
+
+#
+# If destination is a directory, append the input filename; if
+# your system does not like double slashes in filenames, you may
+# need to add some logic
+#
+if [ -d $dst ]; then
+ dst="$dst/`basename $src`"
+fi
+
+# Add a possible extension (such as ".exe") to src and dst
+src="$src$ext"
+dst="$dst$ext"
+
+# Make a temp file name in the proper directory.
+dstdir=`dirname $dst`
+dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+$instcmd $src $dsttmp
+
+# And set any options; do chmod last to preserve setuid bits
+if [ "x$chowncmd" != "x" ]; then $chowncmd $dsttmp; fi
+if [ "x$chgrpcmd" != "x" ]; then $chgrpcmd $dsttmp; fi
+if [ "x$stripcmd" != "x" ]; then $stripcmd $dsttmp; fi
+if [ "x$chmodcmd" != "x" ]; then $chmodcmd $dsttmp; fi
+
+# Now rename the file to the real destination.
+$rmcmd $dst
+$mvcmd $dsttmp $dst
+
+exit 0
+
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/src/native/unix/support/install.sh
___________________________________________________________________
Name: svn:executable
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/AloneDaemon.sh
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/AloneDaemon.sh 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/AloneDaemon.sh 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+# Copyright 1999-2004 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+# Small shell script to show how to start the sample services.
+# That is for linux, if your are using cygwin look to ServiceDaemon.sh.
+#
+# Adapt the following lines to your configuration
+JAVA_HOME=`echo $JAVA_HOME`
+DAEMON_HOME=`(cd ../..; pwd)`
+USER_HOME=`(cd ../../../..; pwd)`
+TOMCAT_USER=`echo $USER`
+CLASSPATH=\
+$DAEMON_HOME/dist/commons-daemon.jar:\
+$USER_HOME/commons-collections-2.1/commons-collections.jar:\
+$DAEMON_HOME/dist/aloneservice.jar
+
+$DAEMON_HOME/src/native/unix/jsvc \
+ -home $JAVA_HOME \
+ -cp $CLASSPATH \
+ -pidfile ./pidfile \
+ -debug \
+ AloneService
+#
+# To get a verbose JVM
+#-verbose \
+# To get a debug of jsvc.
+#-debug \
+# -user $TOMCAT_USER \
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/AloneDaemon.sh
___________________________________________________________________
Name: svn:executable
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/AloneService.java
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/AloneService.java 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/AloneService.java 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,127 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* @version $Id: AloneService.java 155409 2005-02-26 12:57:06Z dirkv $ */
+
+import java.io.*;
+import java.net.*;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Enumeration;
+
+import org.apache.commons.collections.ExtendedProperties;
+import java.io.IOException;
+import java.util.Iterator;
+
+/*
+ * That is like the ServiceDaemon but it does used the interface.
+ */
+public class AloneService {
+
+ private ExtendedProperties prop = null;
+ private Process proc[] = null;
+ private ServiceDaemonReadThread readout[] = null;
+ private ServiceDaemonReadThread readerr[] = null;
+
+ protected void finalize() {
+ System.err.println("ServiceDaemon: instance "+this.hashCode()+
+ " garbage collected");
+ }
+
+ /**
+ * init and destroy were added in jakarta-tomcat-daemon.
+ */
+ public void init(String[] arguments)
+ throws Exception {
+ /* Set the err */
+ System.setErr(new PrintStream(new FileOutputStream(new File("/ServiceDaemon.err"),true)));
+ System.err.println("ServiceDaemon: instance "+this.hashCode()+
+ " init");
+
+ /* read the properties file */
+ prop = new ExtendedProperties("startfile");
+
+ /* create an array to store the processes */
+ int i=0;
+ for (Iterator e = prop.getKeys(); e.hasNext() ;) {
+ e.next();
+ i++;
+ }
+ System.err.println("ServiceDaemon: init for " + i + " processes");
+ proc = new Process[i];
+ readout = new ServiceDaemonReadThread[i];
+ readerr = new ServiceDaemonReadThread[i];
+ for (i=0;i<proc.length;i++) {
+ proc[i] = null;
+ readout[i] = null;
+ readerr[i] = null;
+ }
+
+ System.err.println("ServiceDaemon: init done ");
+
+ }
+
+ public void start() {
+ /* Dump a message */
+ System.err.println("ServiceDaemon: starting");
+
+ /* Start */
+ int i=0;
+ for (Iterator e = prop.getKeys(); e.hasNext() ;) {
+ String name = (String) e.next();
+ System.err.println("ServiceDaemon: starting: " + name + " : " + prop.getString(name));
+ try {
+ proc[i] = Runtime.getRuntime().exec(prop.getString(name));
+ } catch(Exception ex) {
+ System.err.println("Exception: " + ex);
+ }
+ /* Start threads to read from Error and Out streams */
+ readerr[i] =
+ new ServiceDaemonReadThread(proc[i].getErrorStream());
+ readout[i] =
+ new ServiceDaemonReadThread(proc[i].getInputStream());
+ readerr[i].start();
+ readout[i].start();
+ i++;
+ }
+ }
+
+ public void stop()
+ throws IOException, InterruptedException {
+ /* Dump a message */
+ System.err.println("ServiceDaemon: stopping");
+
+ for (int i=0;i<proc.length;i++) {
+ if ( proc[i]==null)
+ continue;
+ proc[i].destroy();
+ try {
+ proc[i].waitFor();
+ } catch(InterruptedException ex) {
+ System.err.println("ServiceDaemon: exception while stopping:" +
+ ex);
+ }
+ }
+
+ System.err.println("ServiceDaemon: stopped");
+ }
+
+ public void destroy() {
+ System.err.println("ServiceDaemon: instance "+this.hashCode()+
+ " destroy");
+ }
+
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/Native.c
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/Native.c 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/Native.c 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,43 @@
+/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Native routine to core JVM
+ */
+#include <jni.h>
+
+#ifndef _Included_Native
+#define _Included_Native
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: Native
+ * Method: toto
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_SimpleDaemon_toto
+ (JNIEnv *env, jclass class) {
+ int i;
+ i = -1;
+ memcpy(&i, &i, i);
+ memset(&i, ' ', 1024);
+}
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/Native.sh
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/Native.sh 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/Native.sh 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,32 @@
+## Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+## applicable.
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+# for linux ;-) and Mac OS X
+case `uname -s` in
+ Darwin)
+ JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
+ INCLUDE=Headers
+ OS=
+ FLAGS=-dynamiclib
+ ;;
+ Linux)
+ OS=linux
+ INCLUDE=include
+ FLAGS=-shared
+ ;;
+esac
+
+gcc -c -I${JAVA_HOME}/${INCLUDE} -I${JAVA_HOME}/${INCLUDE}/${OS} Native.c
+gcc ${FLAGS} -o Native.so Native.o
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/README.txt
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/README.txt 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/README.txt 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,39 @@
+The directory contains examples of java daemons.
+The examples are compiled using ant (just type ant). Each example creates a
+jar file in ../../dist
+
+SimpleDaemon:
+
+SimpleDaemon demonstrates the feature of the daemon ofered by
+jakarta-commons/daemon.
+To run it adapt the SimpleDaemon.sh file and connect to it using:
+telnet localhost 1200
+Additional information in ../native/unix/INSTALL.txt
+
+ServiceDaemon:
+
+ServiceDaemon allows to start programs using the jakarta daemon.
+That could be usefull when using cygwin under win9x because cygwin only offers
+services support under win NT/2000/XP.
+(See in ../native/nt/README how to install jsvc as a service in win32).
+
+It uses jakarta Commons Collections:
+http://jakarta.apache.org/commons/collections/
+To use it you need at least commons-collections-1.0
+Check in build.xml that the property commons-collections.jar correspond to thei
+location of your commons-collections.jar file.
+
+You have to create a file named startfile that uses a property format:
+name = string to start the program
+
+For example:
+sshd=/usr/sbin/sshd -D
+router1=/home/Standard/router/router pop3 pop3.example.net
+router2=/home/Standard/router/smtp smtp.example.net
+socks5=/usr/local/bin/socks5 -f
+
+To run it adapt the ServiceDaemon.sh file.
+
+AloneService:
+
+AloneService is like ServiceDaemon except it does not use the Daemon interface.
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/ServiceDaemon.java
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/ServiceDaemon.java 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/ServiceDaemon.java 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,133 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* @version $Id: ServiceDaemon.java 155409 2005-02-26 12:57:06Z dirkv $ */
+
+import java.io.*;
+import java.net.*;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Enumeration;
+import org.apache.commons.daemon.Daemon;
+import org.apache.commons.daemon.DaemonController;
+import org.apache.commons.daemon.DaemonContext;
+
+import org.apache.commons.collections.ExtendedProperties;
+import java.io.IOException;
+import java.util.Iterator;
+
+public class ServiceDaemon implements Daemon {
+
+ private ExtendedProperties prop = null;
+ private Process proc[] = null;
+ private ServiceDaemonReadThread readout[] = null;
+ private ServiceDaemonReadThread readerr[] = null;
+
+ public ServiceDaemon() {
+ super();
+ System.err.println("ServiceDaemon: instance "+this.hashCode()+
+ " created");
+ }
+
+ protected void finalize() {
+ System.err.println("ServiceDaemon: instance "+this.hashCode()+
+ " garbage collected");
+ }
+
+ /**
+ * init and destroy were added in jakarta-tomcat-daemon.
+ */
+ public void init(DaemonContext context)
+ throws Exception {
+ /* Set the err */
+ System.setErr(new PrintStream(new FileOutputStream(new File("ServiceDaemon.err")),true));
+ System.err.println("ServiceDaemon: instance "+this.hashCode()+
+ " init");
+
+ /* read the properties file */
+ prop = new ExtendedProperties("startfile");
+
+ /* create an array to store the processes */
+ int i=0;
+ for (Iterator e = prop.getKeys(); e.hasNext() ;) {
+ e.next();
+ i++;
+ }
+ System.err.println("ServiceDaemon: init for " + i + " processes");
+ proc = new Process[i];
+ readout = new ServiceDaemonReadThread[i];
+ readerr = new ServiceDaemonReadThread[i];
+ for (i=0;i<proc.length;i++) {
+ proc[i] = null;
+ readout[i] = null;
+ readerr[i] = null;
+ }
+
+ System.err.println("ServiceDaemon: init done ");
+
+ }
+
+ public void start() {
+ /* Dump a message */
+ System.err.println("ServiceDaemon: starting");
+
+ /* Start */
+ int i=0;
+ for (Iterator e = prop.getKeys(); e.hasNext() ;) {
+ String name = (String) e.next();
+ System.err.println("ServiceDaemon: starting: " + name + " : " + prop.getString(name));
+ try {
+ proc[i] = Runtime.getRuntime().exec(prop.getString(name));
+ } catch(Exception ex) {
+ System.err.println("Exception: " + ex);
+ }
+ /* Start threads to read from Error and Out streams */
+ readerr[i] =
+ new ServiceDaemonReadThread(proc[i].getErrorStream());
+ readout[i] =
+ new ServiceDaemonReadThread(proc[i].getInputStream());
+ readerr[i].start();
+ readout[i].start();
+ i++;
+ }
+ }
+
+ public void stop()
+ throws IOException, InterruptedException {
+ /* Dump a message */
+ System.err.println("ServiceDaemon: stopping");
+
+ for (int i=0;i<proc.length;i++) {
+ if ( proc[i]==null)
+ continue;
+ proc[i].destroy();
+ try {
+ proc[i].waitFor();
+ } catch(InterruptedException ex) {
+ System.err.println("ServiceDaemon: exception while stopping:" +
+ ex);
+ }
+ }
+
+ System.err.println("ServiceDaemon: stopped");
+ }
+
+ public void destroy() {
+ System.err.println("ServiceDaemon: instance "+this.hashCode()+
+ " destroy");
+ }
+
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/ServiceDaemon.sh
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/ServiceDaemon.sh 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/ServiceDaemon.sh 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# Copyright 1999-2004 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+# Small shell script to show how to start the sample services.
+#
+# Adapt the following lines to your configuration
+JAVA_HOME=/cygdrive/c/jdk1.3.1_02
+HOME=c:\\cygwin\\home\\Standard
+DAEMON_HOME=$HOME\\jakarta-commons-sandbox\\daemon
+DAEMON_HOME_SH=/home/Standard/jakarta-commons-sandbox/daemon
+TOMCAT_USER=jakarta
+CLASSPATH=\
+$DAEMON_HOME\\dist\\commons-daemon.jar\;\
+$HOME\\commons-collections-1.0\\commons-collections.jar\;\
+$DAEMON_HOME\\dist\\Service.jar
+
+$DAEMON_HOME_SH/dist/jsvc \
+ -home $JAVA_HOME \
+ -cp $CLASSPATH \
+ ServiceDaemon
+#
+# To get a verbose JVM
+#-verbose \
+# To get a debug of jsvc.
+#-debug \
+# -user $TOMCAT_USER \
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/ServiceDaemon.sh
___________________________________________________________________
Name: svn:executable
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/ServiceDaemonReadThread.java
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/ServiceDaemonReadThread.java 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/ServiceDaemonReadThread.java 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,41 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* @version $Id: ServiceDaemonReadThread.java 155409 2005-02-26 12:57:06Z dirkv $ */
+import java.io.InputStream;
+import java.io.IOException;
+import java.lang.Thread;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+public class ServiceDaemonReadThread extends Thread {
+ private BufferedReader in;
+ ServiceDaemonReadThread(InputStream in) {
+ this.in = new BufferedReader(new InputStreamReader(in));
+ }
+ public void run() {
+ String buff;
+ for (;;) {
+ try {
+ buff = in.readLine();
+ if (buff == null) break;
+ System.err.print(in.readLine());
+ } catch (IOException ex) {
+ break; // Exit thread.
+ }
+ }
+ }
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/SimpleDaemon.java
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/SimpleDaemon.java 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/SimpleDaemon.java 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,341 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* @version $Id: SimpleDaemon.java 397480 2006-04-27 08:58:27Z jfclere $ */
+
+import java.io.*;
+import java.net.*;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.Vector;
+import org.apache.commons.daemon.Daemon;
+import org.apache.commons.daemon.DaemonController;
+import org.apache.commons.daemon.DaemonContext;
+
+public class SimpleDaemon implements Daemon, Runnable {
+
+ private ServerSocket server=null;
+ private Thread thread=null;
+ private DaemonController controller=null;
+ private boolean stopping=false;
+ private String directory=null;
+ private Vector handlers=null;
+
+ public static native void toto();
+
+ public SimpleDaemon() {
+ super();
+ System.err.println("SimpleDaemon: instance "+this.hashCode()+
+ " created");
+ this.handlers=new Vector();
+ }
+
+ protected void finalize() {
+ System.err.println("SimpleDaemon: instance "+this.hashCode()+
+ " garbage collected");
+ }
+
+ /**
+ * init and destroy were added in jakarta-tomcat-daemon.
+ */
+ public void init(DaemonContext context)
+ throws Exception {
+ System.err.println("SimpleDaemon: instance "+this.hashCode()+
+ " init");
+
+ int port=1200;
+
+ String[] a = context.getArguments();
+
+ if (a.length>0) port=Integer.parseInt(a[0]);
+ if (a.length>1) this.directory=a[1];
+ else this.directory="/tmp";
+
+ /* Dump a message */
+ System.err.println("SimpleDaemon: loading on port "+port);
+
+ /* Set up this simple daemon */
+ this.controller=context.getController();
+ this.server=new ServerSocket(port);
+ this.thread=new Thread(this);
+ }
+
+ public void start() {
+ /* Dump a message */
+ System.err.println("SimpleDaemon: starting");
+
+ /* Start */
+ this.thread.start();
+ }
+
+ public void stop()
+ throws IOException, InterruptedException {
+ /* Dump a message */
+ System.err.println("SimpleDaemon: stopping");
+
+ /* Close the ServerSocket. This will make our thread to terminate */
+ this.stopping=true;
+ this.server.close();
+
+ /* Wait for the main thread to exit and dump a message */
+ this.thread.join(5000);
+ System.err.println("SimpleDaemon: stopped");
+ }
+
+ public void destroy() {
+ System.err.println("SimpleDaemon: instance "+this.hashCode()+
+ " destroy");
+ }
+
+ public void run() {
+ int number=0;
+
+ System.err.println("SimpleDaemon: started acceptor loop");
+ try {
+ while(!this.stopping) {
+ Socket socket=this.server.accept();
+ Handler handler=new Handler(socket,this,this.controller);
+ handler.setConnectionNumber(number++);
+ handler.setDirectoryName(this.directory);
+ new Thread(handler).start();
+ }
+ } catch (IOException e) {
+ /* Don't dump any error message if we are stopping. A IOException
+ is generated when the ServerSocket is closed in stop() */
+ if (!this.stopping) e.printStackTrace(System.err);
+ }
+
+ /* Terminate all handlers that at this point are still open */
+ Enumeration openhandlers=this.handlers.elements();
+ while (openhandlers.hasMoreElements()) {
+ Handler handler=(Handler)openhandlers.nextElement();
+ System.err.println("SimpleDaemon: dropping connection "+
+ handler.getConnectionNumber());
+ handler.close();
+ }
+
+ System.err.println("SimpleDaemon: exiting acceptor loop");
+ }
+
+ protected void addHandler(Handler handler) {
+ synchronized (handler) {
+ this.handlers.add(handler);
+ }
+ }
+
+ protected void removeHandler(Handler handler) {
+ synchronized (handler) {
+ this.handlers.remove(handler);
+ }
+ }
+
+ public static class Handler implements Runnable {
+
+ private DaemonController controller=null;
+ private SimpleDaemon parent=null;
+ private String directory=null;
+ private Socket socket=null;
+ private int number=0;
+
+ public Handler(Socket s, SimpleDaemon p, DaemonController c) {
+ super();
+ this.socket=s;
+ this.parent=p;
+ this.controller=c;
+ }
+
+ public void run() {
+ this.parent.addHandler(this);
+ System.err.println("SimpleDaemon: connection "+this.number+
+ " opened from "+this.socket.getInetAddress());
+ try {
+ InputStream in=this.socket.getInputStream();
+ OutputStream out=this.socket.getOutputStream();
+ handle(in,out);
+ this.socket.close();
+ } catch (IOException e) {
+ e.printStackTrace(System.err);
+ }
+ System.err.println("SimpleDaemon: connection "+this.number+
+ " closed");
+ this.parent.removeHandler(this);
+ }
+
+ public void close() {
+ try {
+ this.socket.close();
+ } catch (IOException e) {
+ e.printStackTrace(System.err);
+ }
+ }
+
+ public void setConnectionNumber(int number) {
+ this.number=number;
+ }
+
+ public int getConnectionNumber() {
+ return(this.number);
+ }
+
+ public void setDirectoryName(String directory) {
+ this.directory=directory;
+ }
+
+ public String getDirectoryName() {
+ return(this.directory);
+ }
+
+ public void createFile(String name)
+ throws IOException {
+ OutputStream file=new FileOutputStream(name,true);
+ PrintStream out=new PrintStream(file);
+ SimpleDateFormat fmt=new SimpleDateFormat();
+
+ out.println(fmt.format(new Date()));
+ out.close();
+ file.close();
+ }
+
+ public void createDir(String name)
+ throws IOException {
+ File file = new File(name);
+ boolean ok = file.mkdirs();
+ if(! ok)
+ throw new IOException("mkdirs for "+name+" failed");
+ createFile(name);
+ }
+
+ public void handle(InputStream in, OutputStream os) {
+ PrintStream out=null;
+ try {
+ out=new PrintStream(os, true, "US-ASCII");
+ } catch (UnsupportedEncodingException ex) {
+ out=new PrintStream(os);
+ }
+
+ while(true) {
+ try {
+ /* If we don't have data in the System InputStream, we want
+ to ask to the user for an option. */
+ if (in.available()==0) {
+ out.println();
+ out.println("Please select one of the following:");
+ out.println(" 1) Shutdown");
+ out.println(" 2) Reload");
+ out.println(" 3) Create a file");
+ out.println(" 4) Disconnect");
+ out.println(" 5) Cause a core of the JVM");
+ out.println(" 6) Create a directory");
+ out.print("Your choice: ");
+ }
+
+ /* Read an option from the client */
+ int x=in.read();
+
+ switch (x) {
+ /* If the socket was closed, we simply return */
+ case -1:
+ return;
+
+ /* Attempt to shutdown */
+ case '1':
+ out.println("Attempting a shutdown...");
+ try {
+ this.controller.shutdown();
+ } catch (IllegalStateException e) {
+ out.println();
+ out.println("Can't shutdown now");
+ e.printStackTrace(out);
+ }
+ break;
+
+ /* Attempt to reload */
+ case '2':
+ out.println("Attempting a reload...");
+ try {
+ this.controller.reload();
+ } catch (IllegalStateException e) {
+ out.println();
+ out.println("Can't reload now");
+ e.printStackTrace(out);
+ }
+ break;
+
+ /* Create a file */
+ case '3':
+ String name=this.getDirectoryName()+
+ "/SimpleDaemon."+
+ this.getConnectionNumber()+
+ ".tmp";
+ try {
+ this.createFile(name);
+ out.println("File '"+name+"' created");
+ } catch (IOException e) {
+ e.printStackTrace(out);
+ }
+ break;
+
+ /* Disconnect */
+ case '4':
+ out.println("Disconnecting...");
+ return;
+
+ /* Crash JVM in a native call: It need an so file ;-) */
+ case '5':
+ System.load(System.getProperty("native.library", "./Native.so"));
+ toto();
+ break;
+
+ /* Create a directory (PR 30177 with 1.4.x and 1.5.0 */
+ case '6':
+ String name1=this.getDirectoryName()+
+ "/a/b/c/d/e"+
+ "/SimpleDaemon."+
+ this.getConnectionNumber()+
+ ".tmp";
+ try {
+ this.createDir(name1);
+ out.println("File '"+name1+"' created");
+ } catch (IOException e) {
+ e.printStackTrace(out);
+ }
+ break;
+
+
+ /* Discard any carriage return / newline characters */
+ case '\r':
+ case '\n':
+ break;
+
+ /* We got something that we weren't supposed to get */
+ default:
+ out.println("Unknown option '"+(char)x+"'");
+ break;
+
+ }
+
+ /* If we get an IOException we return (disconnect) */
+ } catch (IOException e) {
+ System.err.println("SimpleDaemon: IOException in "+
+ "connection "+
+ this.getConnectionNumber());
+ return;
+ }
+ }
+ }
+ }
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/SimpleDaemon.sh
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/SimpleDaemon.sh 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/SimpleDaemon.sh 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+# Copyright 1999-2005 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+# Small shell script to show how to start the sample services.
+#
+# Adapt the following lines to your configuration
+JAVA_HOME=`echo $JAVA_HOME`
+#JAVA_HOME=/opt/java
+#JAVA_HOME=/opt/kaffe
+DAEMON_HOME=`(cd ../..; pwd)`
+TOMCAT_USER=`echo $USER`
+CLASSPATH=\
+$DAEMON_HOME/dist/commons-daemon.jar:\
+$DAEMON_HOME/dist/SimpleDaemon.jar
+
+PATH=$PATH:$DAEMON_HOME/src/native/unix
+export PATH
+
+# library could be used to test restart after a core.
+# -Dnative.library=${DAEMON_HOME}/src/samples/Native.so \
+
+# options below are for kaffe.
+# -Xclasspath/a:$CLASSPATH \
+# (to debug the class loader
+# -vmdebug VMCLASSLOADER \
+
+# option below is for the sun JVM.
+# -cp $CLASSPATH \
+
+if [ -f $JAVA_HOME/bin/kaffe ]
+then
+ CLOPT="-Xclasspath/a:$CLASSPATH"
+else
+ CLOPT="-cp $CLASSPATH"
+fi
+
+jsvc \
+ -user $TOMCAT_USER \
+ -home $JAVA_HOME \
+ $CLOPT \
+ -pidfile ./pidfile \
+ -wait 90 \
+ -debug \
+ -outfile toto.txt \
+ -errfile '&1' \
+ -Dnative.library=${DAEMON_HOME}/src/samples/Native.so \
+ SimpleDaemon \
+#
+# To get a verbose JVM (sun JVM for example)
+#-verbose \
+# To get a debug of jsvc.
+#-debug \
+
+echo "result: $?"
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/SimpleDaemon.sh
___________________________________________________________________
Name: svn:executable
+
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/build.xml
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/build.xml 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/samples/build.xml 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,75 @@
+<project name="daemons samples" default="jars" basedir=".">
+
+<!-- ========== Initialize Properties ===================================== -->
+ <property file="build.properties"/>
+ <property name="commons-daemon.jar" value="../../dist/commons-daemon.jar"/>
+ <property name="dist.home" value="../../dist"/>
+ <property name="build.home" value="./build"/>
+ <property name="source.home" value="."/>
+ <property name="commons-collections.jar" value="${user.home}/java/commons-collections-3.1/commons-collections-3.1.jar"/>
+
+ <target name="jars" depends="SimpleDaemon,ServiceDaemon,AloneService"/>
+
+ <target name="SimpleDaemon" depends="compile"
+ description="Create SimpleDaemon.jar">
+ <mkdir dir="${dist.home}"/>
+ <mkdir dir="${build.home}/classes/META-INF"/>
+ <copy file="../../LICENSE"
+ tofile="${build.home}/classes/META-INF/LICENSE.txt"/>
+ <jar jarfile="${dist.home}/SimpleDaemon.jar">
+ <fileset dir="${build.home}/classes">
+ <include name="SimpleDaemon*.class" />
+ </fileset>
+ </jar>
+ </target>
+
+ <target name="ServiceDaemon" depends="compile"
+ description="Create ServiceDaemon.jar">
+ <mkdir dir="${dist.home}"/>
+ <mkdir dir="${build.home}/classes/META-INF"/>
+ <copy file="../../LICENSE"
+ tofile="${build.home}/classes/META-INF/LICENSE.txt"/>
+ <jar jarfile="${dist.home}/service.jar">
+ <fileset dir="${build.home}/classes">
+ <include name="ServiceDaemon*.class" />
+ </fileset>
+ </jar>
+ </target>
+
+ <target name="AloneService" depends="compile"
+ description="Create aloneservice.jar">
+ <mkdir dir="${dist.home}"/>
+ <mkdir dir="${build.home}/classes/META-INF"/>
+ <copy file="../../LICENSE"
+ tofile="${build.home}/classes/META-INF/LICENSE.txt"/>
+ <jar jarfile="${dist.home}/aloneservice.jar">
+ <fileset dir="${build.home}/classes">
+ <include name="AloneService*.class" />
+ <include name="ServiceDaemonReadThread*.class" />
+ </fileset>
+ </jar>
+ </target>
+
+ <target name="compile" depends="prepare"
+ description="Create class files">
+ <javac srcdir="${source.home}"
+ destdir="${build.home}/classes"
+ debug="${compile.debug}"
+ deprecation="${compile.deprecation}"
+ optimize="${compile.optimize}">
+ <classpath refid="compile.classpath"/>
+ </javac>
+ </target>
+
+ <target name="prepare">
+ <mkdir dir="${build.home}"/>
+ <mkdir dir="${build.home}/classes"/>
+ </target>
+
+ <!-- Construct compile classpath -->
+ <path id="compile.classpath">
+ <pathelement location="${commons-daemon.jar}"/>
+ <pathelement location="${commons-collections.jar}"/>
+ </path>
+
+</project>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/src/test/org/apache/commons/daemon/SimpleDaemon.java
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/src/test/org/apache/commons/daemon/SimpleDaemon.java 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/src/test/org/apache/commons/daemon/SimpleDaemon.java 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,303 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* @version $Id: SimpleDaemon.java 155409 2005-02-26 12:57:06Z dirkv $ */
+
+package org.apache.commons.daemon;
+
+import java.io.*;
+import java.net.*;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.Vector;
+import org.apache.commons.daemon.Daemon;
+import org.apache.commons.daemon.DaemonController;
+import org.apache.commons.daemon.DaemonContext;
+
+public class SimpleDaemon implements Daemon, Runnable {
+
+ private ServerSocket server=null;
+ private Thread thread=null;
+ private DaemonController controller=null;
+ private boolean stopping=false;
+ private String directory=null;
+ private Vector handlers=null;
+
+ public SimpleDaemon() {
+ super();
+ System.err.println("SimpleDaemon: instance "+this.hashCode()+
+ " created");
+ this.handlers=new Vector();
+ }
+
+ protected void finalize() {
+ System.err.println("SimpleDaemon: instance "+this.hashCode()+
+ " garbage collected");
+ }
+
+ /**
+ * init and destroy were added in jakarta-tomcat-daemon.
+ */
+ public void init(DaemonContext context)
+ throws Exception {
+ System.err.println("SimpleDaemon: instance "+this.hashCode()+
+ " init");
+
+ int port=1200;
+
+ String[] a = context.getArguments();
+
+ if (a.length>0) port=Integer.parseInt(a[0]);
+ if (a.length>1) this.directory=a[1];
+ else this.directory="/tmp";
+
+ /* Dump a message */
+ System.err.println("SimpleDaemon: loading on port "+port);
+
+ /* Set up this simple daemon */
+ this.controller=context.getController();
+ this.server=new ServerSocket(port);
+ this.thread=new Thread(this);
+ }
+
+ public void start() {
+ /* Dump a message */
+ System.err.println("SimpleDaemon: starting");
+
+ /* Start */
+ this.thread.start();
+ }
+
+ public void stop()
+ throws IOException, InterruptedException {
+ /* Dump a message */
+ System.err.println("SimpleDaemon: stopping");
+
+ /* Close the ServerSocket. This will make our thread to terminate */
+ this.stopping=true;
+ this.server.close();
+
+ /* Wait for the main thread to exit and dump a message */
+ this.thread.join(5000);
+ System.err.println("SimpleDaemon: stopped");
+ }
+
+ public void destroy() {
+ System.err.println("SimpleDaemon: instance "+this.hashCode()+
+ " destroy");
+ }
+
+ public void run() {
+ int number=0;
+
+ System.err.println("SimpleDaemon: started acceptor loop");
+ try {
+ while(!this.stopping) {
+ Socket socket=this.server.accept();
+ Handler handler=new Handler(socket,this,this.controller);
+ handler.setConnectionNumber(number++);
+ handler.setDirectoryName(this.directory);
+ new Thread(handler).start();
+ }
+ } catch (IOException e) {
+ /* Don't dump any error message if we are stopping. A IOException
+ is generated when the ServerSocket is closed in stop() */
+ if (!this.stopping) e.printStackTrace(System.err);
+ }
+
+ /* Terminate all handlers that at this point are still open */
+ Enumeration openhandlers=this.handlers.elements();
+ while (openhandlers.hasMoreElements()) {
+ Handler handler=(Handler)openhandlers.nextElement();
+ System.err.println("SimpleDaemon: dropping connection "+
+ handler.getConnectionNumber());
+ handler.close();
+ }
+
+ System.err.println("SimpleDaemon: exiting acceptor loop");
+ }
+
+ protected void addHandler(Handler handler) {
+ synchronized (handler) {
+ this.handlers.add(handler);
+ }
+ }
+
+ protected void removeHandler(Handler handler) {
+ synchronized (handler) {
+ this.handlers.remove(handler);
+ }
+ }
+
+ public static class Handler implements Runnable {
+
+ private DaemonController controller=null;
+ private SimpleDaemon parent=null;
+ private String directory=null;
+ private Socket socket=null;
+ private int number=0;
+
+ public Handler(Socket s, SimpleDaemon p, DaemonController c) {
+ super();
+ this.socket=s;
+ this.parent=p;
+ this.controller=c;
+ }
+
+ public void run() {
+ this.parent.addHandler(this);
+ System.err.println("SimpleDaemon: connection "+this.number+
+ " opened from "+this.socket.getInetAddress());
+ try {
+ InputStream in=this.socket.getInputStream();
+ OutputStream out=this.socket.getOutputStream();
+ handle(in,out);
+ this.socket.close();
+ } catch (IOException e) {
+ e.printStackTrace(System.err);
+ }
+ System.err.println("SimpleDaemon: connection "+this.number+
+ " closed");
+ this.parent.removeHandler(this);
+ }
+
+ public void close() {
+ try {
+ this.socket.close();
+ } catch (IOException e) {
+ e.printStackTrace(System.err);
+ }
+ }
+
+ public void setConnectionNumber(int number) {
+ this.number=number;
+ }
+
+ public int getConnectionNumber() {
+ return(this.number);
+ }
+
+ public void setDirectoryName(String directory) {
+ this.directory=directory;
+ }
+
+ public String getDirectoryName() {
+ return(this.directory);
+ }
+
+ public void log(String name)
+ throws IOException {
+ OutputStream file=new FileOutputStream(name,true);
+ PrintStream out=new PrintStream(file);
+ SimpleDateFormat fmt=new SimpleDateFormat();
+
+ out.println(fmt.format(new Date()));
+ out.close();
+ file.close();
+ }
+
+ public void handle(InputStream in, OutputStream os) {
+ PrintStream out=new PrintStream(os);
+
+ while(true) {
+ try {
+ /* If we don't have data in the System InputStream, we want
+ to ask to the user for an option. */
+ if (in.available()==0) {
+ out.println();
+ out.println("Please select one of the following:");
+ out.println(" 1) Shutdown");
+ out.println(" 2) Reload");
+ out.println(" 3) Create a file");
+ out.println(" 4) Disconnect");
+ out.print("Your choiche: ");
+ }
+
+ /* Read an option from the client */
+ int x=in.read();
+
+ switch (x) {
+ /* If the socket was closed, we simply return */
+ case -1:
+ return;
+
+ /* Attempt to shutdown */
+ case '1':
+ out.println("Attempting a shutdown...");
+ try {
+ this.controller.shutdown();
+ } catch (IllegalStateException e) {
+ out.println();
+ out.println("Can't shutdown now");
+ e.printStackTrace(out);
+ }
+ break;
+
+ /* Attempt to reload */
+ case '2':
+ out.println("Attempting a reload...");
+ try {
+ this.controller.reload();
+ } catch (IllegalStateException e) {
+ out.println();
+ out.println("Can't reload now");
+ e.printStackTrace(out);
+ }
+ break;
+
+ /* Disconnect */
+ case '3':
+ String name=this.getDirectoryName()+
+ "/SimpleDaemon."+
+ this.getConnectionNumber()+
+ ".tmp";
+ try {
+ this.log(name);
+ out.println("File '"+name+"' created");
+ } catch (IOException e) {
+ e.printStackTrace(out);
+ }
+ break;
+
+ /* Disconnect */
+ case '4':
+ out.println("Disconnecting...");
+ return;
+
+ /* Discard any carriage return / newline characters */
+ case '\r':
+ case '\n':
+ break;
+
+ /* We got something that we weren't supposed to get */
+ default:
+ out.println("Unknown option '"+(char)x+"'");
+ break;
+
+ }
+
+ /* If we get an IOException we return (disconnect) */
+ } catch (IOException e) {
+ System.err.println("SimpleDaemon: IOException in "+
+ "connection "+
+ this.getConnectionNumber());
+ return;
+ }
+ }
+ }
+ }
+}
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/binaries.xml
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/binaries.xml 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/binaries.xml 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+
+<document>
+
+ <properties>
+ <title>Daemon : binaries</title>
+ <author email="jfrederic.clere at fujitsu-siemens.con">Jean-Frederic Clere</author>
+ </properties>
+
+<body>
+<section name="What to download">
+<p>
+In the directory
+<a href="http://www.apache.org/dist/jakarta/commons/daemon/binaries/">binaries</a>
+you found subdirectories containing executables
+corresponding to your operating system. If your machine is not in the list
+mail us we will try to make it available or try to build it on your own.
+The files are compressed tar files. They are named jvm_name-os_name.
+For example: In the directory freebsd we have jdk1.4.1-FreeBSD_4.9.tar.gz
+That a file build on FreeBSD 4.9 using the FreeBSD JVM 1.4.1.
+</p>
+</section>
+
+<section name="What to do to get the excutable">
+<subsection name="jsvc">
+<p>
+You have to do the following:
+<ul>
+ <li>Find the nearest tar file corresponding to our configuration.</li>
+ <li>Download it.</li>
+ <li>Uncompress the tar file and extract it (better with a gnu tar).</li>
+ <li>Copy the executable in the location where you want to run it.</li>
+ <li>Write a rc shell
+ (see in src/samples and src/native/unix/native/Tomcat.sh)
+ to get your java application started as a daemon.
+ </li>
+</ul>
+</p>
+</subsection>
+<subsection name="procrun">
+<p>
+The procrun.exe has to be installed as a service.
+(See <a href="procrun.html">procrun</a> for more information.
+</p>
+</subsection>
+</section>
+
+</body>
+</document>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/faq.xml
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/faq.xml 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/faq.xml 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,84 @@
+<?xml version="1.0"?>
+
+<document>
+
+ <properties>
+ <title>Daemon : FAQ</title>
+ <author email="jfrederic.clere at fujitsu-siemens.con">Jean-Frederic Clere</author>
+ </properties>
+
+<body>
+<section name="Buildconf problems">
+<p>
+<source>
+$ sh support/buildconf.sh
+autoconf: Undefined macros:
+***BUG in Autoconf--please report*** AC_PATH
+***BUG in Autoconf--please report*** AC_PATH
+***BUG in Autoconf--please report*** AC_PATH
+</source>
+Your version of autoconf is to old, upgrade your autoconf and retry.
+Or run support/buildconf.sh in another machine and copy the daemon tree in
+the machine where you want to compile jsvc.
+</p>
+</section>
+
+<section name="Configure problems">
+<p>
+<source>
+configure: creating ./config.status
+config.status: creating Makefile
+mv: Makefile: set owner/group (was: 1670/0): Operation not permitted
+config.status: creating Makedefs
+mv: Makedefs: set owner/group (was: 1670/0): Operation not permitted
+config.status: creating native/Makefile
+mv: native/Makefile: set owner/group (was: 1670/0): Operation not permitted
+*** All done ***
+Now you can issue "make"
+</source>
+You should ignore those error messages they are normal in FreeBSD.
+config.status creates files in /tmp and move them in the current directory.
+When FreeBSD creates files it sets the group of the files to
+the group of the directory where the files are created.
+So if /tmp is group "wheel" the files are "wheel". When moving the files in
+the current directory (if you are not member of group "wheel")
+the group "wheel" cannot be set on the moved files.
+</p>
+</section>
+<section name="Runtime problems">
+<p>
+On linux 2.6.x jsvc does not start and write the following error:
+<source>
+jsvc.exec error: syscall failed in set_caps
+jsvc.exec error: Service exit with a return value of 4
+</source>
+CONFIG_SECURITY_CAPABILITIES in missing in your kernel try the following in the kernel sources:
+<ul>
+<li>
+Configure the kernel with "Default Linux Capabilities" and reboot
+ (by make gconfig or make xconfig under "security options" and "Enable different security models")
+</li>
+<li>
+Insert the module "capability":
+<source>
+modprobe capability
+</source>
+</li>
+</ul>
+</p>
+</section>
+
+<section name="Cygwin configuration problems">
+<p>
+The configure of jsvc does not like spaces in directory name.
+To configure with java installed in directory whose name contains a space,
+use the 8 characters name of the directory.
+For example for java in installed in <code>c:\Archivos de programa\java\jdk1.5.0_06</code>:
+<source>
+./configure --with-java=/cygdrive/c/Archiv~1/java/jdk1.5.0_06
+</source>
+</p>
+</section>
+
+</body>
+</document>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/images/logo.gif
===================================================================
(Binary files differ)
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/images/logo.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/images/logo.png
===================================================================
(Binary files differ)
Property changes on: branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/images/logo.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/index.xml
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/index.xml 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/index.xml 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,93 @@
+<?xml version="1.0"?>
+
+<document>
+
+ <properties>
+ <title>Daemon : Java based daemons or services</title>
+ <author email="jfrederic.clere at fujitsu-siemens.con">Jean-Frederic Clere</author>
+ </properties>
+
+<body>
+<section name="Introduction">
+<p>
+ Since 1994, the Java programming language evolved and became a
+ valid tool to develop, other than applets and client applications,
+ reliable and performant server applications. The major disadvantage of
+ the Java platform is that still today the only portable way to
+ start a Java application relies on a single point of entry: the
+ <CODE><EM CLASS="key">public static void</EM>
+ main(<EM CLASS="ref">String</EM>[])</CODE> method.
+</p>
+<p>
+ Having a single-point of entry is a valid solution for client
+ applications, where interactively a user can command to the application
+ to quit (which can terminate the Virtual Machine process at calling the
+ <CODE><EM CLASS="ref">System</EM>.exit(<EM CLASS="key">int</EM>)</CODE>
+ method), but in those cases where the application is not interactive
+ (server applications) there is currently no portable way to notify
+ the Virtual Machine of its imminent shutdown.
+</p>
+<p>
+ A server application written in Java might have to perform several tasks
+ before being able to shutdown the Virtual Machine process. For example
+ in the case of a Servlet container, before the VM process is shut down,
+ sessions might need to be serialized to disk, and web applications need
+ to be destroyed.
+</p>
+<p>
+ One common solution to this problem is to create (for example) a
+ <CODE><EM CLASS="ref">ServerSocket</EM></CODE> and wait for a particular
+ message to be issued. When the message is received, all operations
+ required to shut down the server applications are performed and at the
+ end the <CODE><EM CLASS="ref">System</EM>.exit</CODE> method is called
+ to terminate the Virtual Machine process. This method, however, implies
+ several disadvantages and risks: for example in case of a system-wide
+ shutdown, it might happen that the Virtual Machine process will be shut
+ down directly by the operating system, without notifying the running
+ server application. Or, for example, if an attacker finds out what is
+ the required message to send to the server, and discovers a way to send
+ this message to the running server application, he can easily interrupt
+ the operation of a server, bypassing all the security restrictions
+ implemented in the operating system.
+</p>
+<p>
+ Most multi-user operating systems already have a way in which server
+ applications are started and stopped, under Unix based operating systems
+ non interactive server applications are called <em>daemons</em> and are
+ controlled by the operating system with a set of specified
+ <em>signals</em>. Under Windows such programs are called <em>services</em>
+ and are controlled by appropriate calls to specific functions defined in
+ the application binary, but although the ways of dealing with the problem
+ are different, in both cases the operating system can notify a server
+ application of its imminent shutdown, and the application has the
+ ability to perform certain tasks before its process of execution is
+ destroyed.
+</p>
+</section>
+
+<section name="Structure">
+<p>
+ Daemon is made of 2 parts. One written in C that makes the interface to
+ the operating system and the other in Java that provides the
+ Daemon API.
+</p>
+</section>
+
+<section name="Platforms">
+<p>
+ Actually win32 and the UNIX like platforms are supported.
+ For win32 platfroms use <a href="procrun.html">procrun</a>.
+ For UNIX like platforms use <a href="jsvc.html">jsvc</a>.
+</p>
+</section>
+<section name="Initial Source of the Package">
+
+<p>The original Java classes come from the Jakarta Tomcat 4.0 project.</p>
+
+<p>The proposed package name for the Daemon component is
+<code>org.apache.commons.daemon</code>.
+</p>
+</section>
+
+</body>
+</document>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/jsvc.xml
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/jsvc.xml 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/jsvc.xml 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,244 @@
+<?xml version="1.0"?>
+
+<document>
+
+ <properties>
+ <title>Daemon : Java Service</title>
+ <author email="jfrederic.clere at fujitsu-siemens.con">Jean-Frederic Clere</author>
+ </properties>
+
+<body>
+<section name="Introduction">
+<p>
+ Actualy only the UNIX like platforms are supported.
+ The sources are located in the src/native/unix subdirectory of the
+ project sources.
+ For win32 platfroms the cygwin emulation layer is used. See
+ <a href="http://www.cygwin.com/"> cygwin</a> for more informations.
+</p>
+<p>
+ In the futur <a href="http://apr.apache.org/"> APR </a> may be used
+ to provide more convinient platform support.
+</p>
+</section>
+
+<section name="Building from cvs">
+<p>
+To build under an UNIX operating system you will need:
+<ul>
+ <li>GNU AutoConf (at least version 2.53)</li>
+ <li>An ANSI-C compliant compiler (GCC is good)</li>
+ <li>GNU Make</li>
+ <li>A Java Platform 2 compliant SDK</li>
+</ul>
+
+
+You need to build the "configure" program with:
+
+ sh support/buildconf.sh
+(Note it is possible to replace sh by any compatible shell like bash, ksh).
+
+The result should be something like:
+<source>
+support/buildconf.sh
+support/buildconf.sh: configure script generated successfully
+</source>
+Once the configure script is generated, follow the next section.
+</p>
+</section>
+
+<section name="Building for a release tarball">
+<p>
+To build the binary under an UNIX operating system you will need:
+<ul>
+ <li>An ANSI-C compliant compiler (GCC is good)</li>
+ <li>GNU Make</li>
+ <li>A Java Platform 2 compliant SDK</li>
+</ul>
+
+You have to specify the JAVA_HOME of the SDK
+either the --with-java=<dir> parameter or set the JAVA_HOME environment
+to point to your SDK installation. For example:
+<source>
+ ./configure --with-java=/usr/java
+</source>
+or
+<source>
+ export JAVA_HOME
+ ./configure
+</source>
+
+If your operating system is supported, configure will go thru cleanly,
+otherwise it will report an error (please send us the details of your
+OS/JDK, or a patch against the sources). To build the binaries and
+libraries simply do:
+<source>
+ make
+</source>
+This will generate the executable file jsvc.
+</p>
+</section>
+
+<section name="Starting jsvc">
+<p>
+To check the allowed parameters for the jsvc binary simply do:
+<source>
+./jsvc -help
+Usage: jsvc [-options] class [args...]
+
+Where options include:
+
+ -jvm <JVM name>
+ use a specific Java Virtual Machine. Available JVMs:
+ 'client' 'server'
+ -cp / -classpath <directories and zip/jar files>
+ set search path for service classes and resouces
+ -home <directory>
+ set the path of your JDK or JRE installation (or set
+ the JAVA_HOME environment variable)
+ -version
+ show the current Java environment version (to check
+ correctness of -home and -jvm. Implies -nodetach)
+ -help / -?
+ show this help page (implies -nodetach)
+ -nodetach
+ don't detach from parent process and become a daemon
+ -debug
+ verbosely print debugging information
+ -check
+ only check service (implies -nodetach)
+ -user <user>
+ user used to run the daemon (defaults to current user)
+ -verbose[:class|gc|jni]
+ enable verbose output
+ -outfile </full/path/to/file>
+ Location for output from stdout (defaults to /dev/null)
+ Use the value '&2' to simulate '1>&2'
+ -errfile </full/path/to/file>
+ Location for output from stderr (defaults to /dev/null)
+ Use the value '&1' to simulate '2>&1'
+ -pidfile </full/path/to/file>
+ Location for output from the file containing the pid of jsvc
+ (defaults to /var/run/jsvc.pid)
+ -D<name>=<value>
+ set a Java system property
+ -X<option>
+ set Virtual Machine specific option
+ -wait <waittime>
+ wait waittime seconds for the service to start
+ waittime should multiple of 10 (min=10)
+ -stop
+ stop the service using the file given in the -pidfile option
+
+</source>
+</p>
+
+</section>
+<section name="Using jsvc">
+<p>
+There two ways to use jsvc: via a Class that implements the Daemon interface or
+via calling a Class that have the required methods.
+For example Tomcat-4.1.x uses the Daemon interface
+and Tomcat-5.0.x provide a Class whose methods are called by jsvc directly.
+</p>
+<subsection name="Via Daemon interface">
+<p>
+You have to do the following.
+<ul>
+ <li>Write a Class that implements the Daemon interface (MyClass).</li>
+ <li>Put it in the jarfile (my.jar).</li>
+ <li>Call jsvc like:
+ <source>
+ ./jsvc -cp commons-daemon.jar:my.jar MyClass
+ </source>
+ </li>
+</ul>
+</p>
+</subsection>
+<subsection name="Directly">
+<p>
+You have to write a Class (MyClass) that implements the following methods:
+<ul>
+ <li>void load(String[] arguments): Here open the configuration files, create the trace file, create
+ the ServerSockets, the Threads</li>
+ <li>void start(): Start the Thread, accept incomming connections</li>
+ <li>void stop(): Inform the Thread to live the run(), close the ServerSockets</li>
+ <li>void destroy(): Destroy any object created in init()</li>
+</ul>
+Store it in a jarfile and use as above:
+<source>
+ ./jsvc -cp commons-daemon.jar:my.jar MyClass
+</source>
+</p>
+</subsection>
+</section>
+<section name="How jsvc works">
+<p>
+Jsvc uses 3 processes: a launcher process, a controller process and a controlled process.
+The controlled process is also the main java thread, if the JVM crashes
+the controller will restart it in the next minute.
+Jsvc is a daemon process so it should be started as root and the -user parameter
+allows to downgrade to an unprivilegded user.
+When -wait parameter is used, the launcher process waits until the controller says
+"I am ready", otherwise it returns after creating the controller process.
+</p>
+
+<subsection name="Forks in jakarta-daemon">
+<p>
+Launcher process:
+<source>
+main()
+{
+ fork()
+ parent: wait_child(), wait until JAVA service started when the child says "I am ready".
+ child: controller process.
+}
+</source>
+
+Controller process:
+<source>
+ while (fork()) {
+ parent: wait_for_child.
+ if exited and restart needed continue
+ else exit.
+ child: exit(child()). controlled process.
+ }
+</source>
+
+Controlled process:
+<source>
+In child(): controlled process.
+ init_JVM().
+ load_service().
+ start_service().
+ say "I am ready"
+ wait for signal or pool for stop
+ stop_service().
+ destroy_service().
+ destroy_JVM().
+ exit (with different codes so that parent knows if it has to restart us).
+</source>
+Note: The controller process uses signals to stop the controlled process.
+</p>
+</subsection>
+
+<subsection name="Downgrading user">
+<p>
+On linux setuid()/setgid() + capabilities are used on other unix setgid/initgroups are used.
+
+we have something like:
+<source>
+/* as root */
+init_JVM().
+load_service. /* java_load() calls the load method */
+downgrade user (set_caps() or set_user_group())
+/* as the user $USER (from -user $USER parameter) */
+umask()
+start_service. /* java_start() calls the start method */
+</source>
+</p>
+</subsection>
+</section>
+
+</body>
+</document>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/navigation.xml
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/navigation.xml 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/navigation.xml 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE org.apache.commons.menus SYSTEM '../../commons-build/menus/menus.dtd'>
+<project name="Daemon">
+
+ <title>Daemon</title>
+ <organizationLogo href="/images/jakarta-logo-blue.gif">
+ Jakarta
+ </organizationLogo>
+
+ <body>
+ <links>
+ <item name="Jakarta Commons"
+ href="http://jakarta.apache.org/commons/"/>
+ </links>
+
+ <menu name="Commons Daemon">
+ <item name="Overview"
+ href="/index.html"/>
+ <item name="Procrun"
+ href="/procrun.html"/>
+ <item name="Jsvc"
+ href="/jsvc.html"/>
+ <item name="Native binaries"
+ href="/binaries.html"/>
+ <item name="FAQ"
+ href="/faq.html"/>
+
+ </menu>
+
+ &common-menus;
+
+ </body>
+</project>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/procrun.xml
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/procrun.xml 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/procrun.xml 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,337 @@
+<?xml version="1.0"?>
+
+<document>
+ <properties>
+ <title>Daemon : Procrun</title>
+ <author email="mturk at apache.org">Mladen Turk</author>
+ </properties>
+
+<body>
+<section name="Introduction">
+<p>
+ Procrun is a set of libraries and applications for making Java
+ applications to run on WIN32 much easier.
+</p>
+<subsection name="Procrun service application">
+<p>
+ <b>Prunsrv</b> is a service application for running applications as services.
+ It can convert any application to run as a service.
+</p>
+</subsection>
+<subsection name="Procrun monitor application">
+<p>
+ <b>Prunmgr</b> is a GUI application for monitoring and configuring procrun
+ services.
+</p>
+ <p>The available command line options are:</p>
+<p>
+ <table>
+ <tr><th>//ES//</th>
+ <td>Edit service configuration</td>
+ <td>This is the default operation. It is called if the no option is
+ provided but the executable is renamed to <b>servicenameW.exe</b></td>
+ </tr>
+ <tr><th>//MS//</th>
+ <td>Monitor service</td>
+ <td>Put the icon in the system try</td>
+ </tr>
+ </table>
+</p>
+</subsection>
+</section>
+<section name="Command line arguments">
+<p>
+ Each command line directive is in the form of <b>//XX//ServiceName</b>
+</p>
+ <p>The available command line options are:</p>
+<p>
+ <table>
+ <tr><th>//TS//</th>
+ <td>Run the service as console application</td>
+ <td>This is the default operation. It is called if the no option is
+ provided but the executable is renamed to <b>servicename.exe</b></td>
+ </tr>
+ <tr><th>//RS//</th>
+ <td>Run the service</td>
+ <td>Called only from ServiceManager</td>
+ </tr>
+ <tr><th>//SS//</th>
+ <td>Stop the service</td>
+ <td></td>
+ </tr>
+ <tr><th>//US//</th>
+ <td>Update service parameters</td>
+ <td></td>
+ </tr>
+ <tr><th>//IS//</th>
+ <td>Install service</td>
+ <td></td>
+ </tr>
+ <tr><th>//DS//</th>
+ <td>Delete service</td>
+ <td>Stops the service if running</td>
+ </tr>
+ </table>
+</p>
+</section>
+<section name="Command line parameters">
+<p>
+ Each command parameter is prefixed with <b>--</b>.
+ If the command line is prefixed with <b>++</b> then it's value will
+ be appended to the existing option.
+ If the environment variable with the same name as command line parameter but
+ prefixed with <code>PR_</code> exists it will take precedence.
+ For example:
+<source>set PR_CLASSPATH=xx.jar</source>
+</p>
+<p>is equivalent to providing
+<source>--Classpath=xx.jar</source>
+</p>
+<p> as command line parameter.</p>
+<p>
+ <table>
+ <tr>
+ <th>ParameterName</th>
+ <th>Default</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>--Description</td>
+ <td></td>
+ <td>Service name description (maximum 1024 characters)</td>
+ </tr>
+ <tr>
+ <td>--DisplayName</td>
+ <td>ServiceName</td>
+ <td>Service display name</td>
+ </tr>
+ <tr>
+ <td>--Install</td>
+ <td>procrun.exe //RS//ServiceName</td>
+ <td>Install image</td>
+ </tr>
+ <tr>
+ <td>--Startup</td>
+ <td>manual</td>
+ <td>Service startup mode can be either <b>auto</b> or <b>manual</b></td>
+ </tr>
+ <tr>
+ <td>--DependsOn</td>
+ <td></td>
+ <td>List of services that this service depend on. Dependent services
+ are separated using either <b>#</b> or <b>;</b> characters</td>
+ </tr>
+ <tr>
+ <td>--Environment</td>
+ <td></td>
+ <td>List of environment variables that will be provided to the service
+ in the form <b>key=value</b>. They are separated using either
+ <b>#</b> or <b>;</b> characters</td>
+ </tr>
+ <tr>
+ <td>--User</td>
+ <td></td>
+ <td>User account used for running executable. It is used only for
+ StartMode <b>java</b> or <b>exe</b> and enables running applications
+ as service under account without LogonAsService privilege.</td>
+ </tr>
+ <tr>
+ <td>--Password</td>
+ <td></td>
+ <td>Password for user account set by --User parameter</td>
+ </tr>
+ <tr>
+ <td>--JavaHome</td>
+ <td>JAVA_HOME</td>
+ <td>Set a different JAVA_HOME then defined by JAVA_HOME environment
+ variable</td>
+ </tr>
+ <tr>
+ <td>--Jvm</td>
+ <td>auto</td>
+ <td>Use either <b>auto</b> or specify the full path to the <b>jvm.dll</b>.
+ You can use the environment variable expansion here.</td>
+ </tr>
+ <tr>
+ <td>--JvmOptions</td>
+ <td>-Xrs</td>
+ <td>List of options in the form of <b>-D</b> or <b>-X</b> that will be
+ passed to the JVM. The options are separated using either
+ <b>#</b> or <b>;</b> characters.</td>
+ </tr>
+ <tr>
+ <td>--Classpath</td>
+ <td></td>
+ <td>Set the Java classpath</td>
+ </tr>
+ <tr>
+ <td>--JvmMs</td>
+ <td></td>
+ <td>Initial memory pool size in MB</td>
+ </tr>
+ <tr>
+ <td>--JvmMx</td>
+ <td></td>
+ <td>Maximum memory pool size in MB</td>
+ </tr>
+ <tr>
+ <td>--JvmSs</td>
+ <td></td>
+ <td>Thread stack size in KB</td>
+ </tr>
+ <tr>
+ <tr>
+ <td>--StartImage</td>
+ <td></td>
+ <td>Executable that will be run.</td>
+ </tr>
+ <tr>
+ <td>--StartPath</td>
+ <td></td>
+ <td>Working path for the start image executable.</td>
+ </tr>
+ <tr>
+ <td>--StartClass</td>
+ <td></td>
+ <td>Class that will be used for startup.</td>
+ </tr>
+ <tr>
+ <td>--StartParams</td>
+ <td></td>
+ <td>List of parameters that will be passed to either StartImage or
+ StartClass. Parameters are separated using either <b>#</b> or
+ <b>;</b> character.</td>
+ </tr>
+ <tr>
+ <td>--StartMethod</td>
+ <td>Main</td>
+ <td>Method name if differs then main</td>
+ </tr>
+ <tr>
+ <td>--StartMode</td>
+ <td>executable</td>
+ <td>Can one of <b>jvm</b> <b>java</b> or <b>exe</b></td>
+ </tr>
+ <td>--StopImage</td>
+ <td></td>
+ <td>Executable that will be run on Stop service signal.</td>
+ </tr>
+ <tr>
+ <td>--StopPath</td>
+ <td></td>
+ <td>Working path for the stop image executable.</td>
+ </tr>
+ <tr>
+ <td>--StopClass</td>
+ <td></td>
+ <td>Class that will be used on Stop service signal.</td>
+ </tr>
+ <tr>
+ <td>--StopParams</td>
+ <td></td>
+ <td>List of parameters that will be passed to either StopImage or
+ StopClass. Parameters are separated using either <b>#</b> or
+ <b>;</b> character.</td>
+ </tr>
+ <tr>
+ <td>--StopMethod</td>
+ <td>Main</td>
+ <td>Method name if differs then main</td>
+ </tr>
+ <tr>
+ <td>--StopMode</td>
+ <td>executable</td>
+ <td>Can one of <b>jvm</b> <b>java</b> or <b>exe</b></td>
+ </tr>
+ <tr>
+ <td>--StopTimeout</td>
+ <td>No Timeout</td>
+ <td>Defines the timeout in seconds that procrun waits for service to
+ exit gracefully.</td>
+ </tr>
+ <tr>
+ <td>--LogPath</td>
+ <td>working path</td>
+ <td>Defines the path for logging</td>
+ </tr>
+ <tr>
+ <td>--LogPrefix</td>
+ <td>jakarta_service</td>
+ <td>Defines the service log filename</td>
+ </tr>
+ <tr>
+ <td>--LogLevel</td>
+ <td>INFO</td>
+ <td>Defines the logging level and can be either <b>error</b>,
+ <b>info</b>, <b>warn</b> or <b>debug</b></td>
+ </tr>
+ <tr>
+ <td>--StdOutput</td>
+ <td></td>
+ <td>Redirected stdout filename</td>
+ </tr>
+ <tr>
+ <td>--StdError</td>
+ <td></td>
+ <td>Redirected stderr filename</td>
+ </tr>
+ </table>
+</p>
+</section>
+<section name="Installing services">
+<p>
+To install the service, you need to use the <b>//IS//</b> parameter.
+</p>
+<p>
+<screen>
+<note>Install the service named 'TestService'</note>
+<type>prunsrv //IS//TestService --DisplayName="Test Service" \</type>
+<type>--Install=prunsrv.exe --Jvm=auto --StartMode=jvm --StopMode=jvm \</type>
+<type>--StartClass=org.apache.SomeStartClass --StartParams=arg1;arg2;arg3 \</type>
+<type>--StopClass=org.apache.SomeStopClass --StopParams=arg1#arg2 \</type>
+</screen>
+</p>
+</section>
+<section name="Updating services">
+<p>
+To update the service parameters, you need to use the <b>//US//</b> parameter.
+</p>
+<p>
+<screen>
+<note>Update the service named 'TestService'</note>
+<type>prunsrv //US//TestService --Description="Some Dummy Test Service" \</type>
+<type>--Startup=auto --Classpath=%CLASSPATH%;test.jar</type>
+</screen>
+</p>
+</section>
+<section name="Removing services">
+<p>
+To remove the service, you need to use the <b>//DS//</b> parameter.
+If the service is running it will be stopped and then deleted.
+</p>
+<p>
+<screen>
+<note>Remove the service named 'TestService'</note>
+<type>prunsrv //DS//TestService</type>
+</screen>
+</p>
+</section>
+
+<section name="Debugging services">
+<p>
+To run the service in console mode, you need to use the <b>//TS//</b> parameter.
+The service shutdown can be initiated by pressing <b>CTRL+C</b> or
+<b>CTRL+BREAK</b>.
+If you rename the prunsrv.exe to testservice.exe then you can just execute the
+testservice.exe and this command mode will be executed by default.
+</p>
+<p>
+<screen>
+<note>Run the service named 'TestService' in console mode</note>
+<type>prunsrv //TS//TestService [additional arguments]</type>
+</screen>
+</p>
+</section>
+
+</body>
+</document>
Added: branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/style/project.css
===================================================================
--- branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/style/project.css 2006-11-25 20:20:14 UTC (rev 2793)
+++ branches/commons-daemon/upstream/1.0.2~svn20061127/xdocs/style/project.css 2006-11-28 09:08:26 UTC (rev 2794)
@@ -0,0 +1,5 @@
+#banner, #banner td {
+ background: #fff;
+ color: #000;
+}
+
More information about the pkg-java-commits
mailing list